text
stringlengths 2
100k
| meta
dict |
---|---|
<?xml version="1.0" encoding="utf-8"?>
<style xmlns="http://purl.org/net/xbiblio/csl" version="1.0" default-locale="en-US">
<!-- Generated with https://github.com/citation-style-language/utilities/tree/master/generate_dependent_styles/data/springer -->
<info>
<title>Journal of Polymers and the Environment</title>
<title-short>J Polym Environ</title-short>
<id>http://www.zotero.org/styles/journal-of-polymers-and-the-environment</id>
<link href="http://www.zotero.org/styles/journal-of-polymers-and-the-environment" rel="self"/>
<link href="http://www.zotero.org/styles/springer-basic-brackets" rel="independent-parent"/>
<link href="http://www.springer.com/cda/content/document/cda_downloaddocument/Key_Style_Points_1.0.pdf" rel="documentation"/>
<link href="http://www.springer.com/cda/content/document/cda_downloaddocument/manuscript-guidelines-1.0.pdf" rel="documentation"/>
<category citation-format="numeric"/>
<category field="science"/>
<issn>1566-2543</issn>
<eissn>1572-8900</eissn>
<updated>2014-05-15T12:00:00+00:00</updated>
<rights license="http://creativecommons.org/licenses/by-sa/3.0/">This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License</rights>
</info>
</style>
| {
"pile_set_name": "Github"
} |
#!/usr/bin/env python
import unittest
import util
class TestCards(unittest.TestCase):
def setUp(self):
util.invoke('createDeck', deck='test')
note = {'deckName': 'test', 'modelName': 'Basic', 'fields': {'Front': 'front1', 'Back': 'back1'}, 'tags': ['tag1']}
self.noteId = util.invoke('addNote', note=note)
def tearDown(self):
util.invoke('deleteDecks', decks=['test'], cardsToo=True)
def runTest(self):
# findCards
cardIds = util.invoke('findCards', query='deck:test')
self.assertEqual(len(cardIds), 1)
# setEaseFactors
EASE_TO_TRY = 4200
easeFactors = [EASE_TO_TRY for card in cardIds]
couldGetEaseFactors = util.invoke('setEaseFactors', cards=cardIds, easeFactors=easeFactors)
self.assertEqual([True for card in cardIds], couldGetEaseFactors)
# getEaseFactors
easeFactorsFound = util.invoke('getEaseFactors', cards=cardIds)
self.assertEqual(easeFactors, easeFactorsFound)
# suspend
util.invoke('suspend', cards=cardIds)
# areSuspended (part 1)
suspendedStates = util.invoke('areSuspended', cards=cardIds)
self.assertEqual(len(cardIds), len(suspendedStates))
self.assertNotIn(False, suspendedStates)
# unsuspend
util.invoke('unsuspend', cards=cardIds)
# areSuspended (part 2)
suspendedStates = util.invoke('areSuspended', cards=cardIds)
self.assertEqual(len(cardIds), len(suspendedStates))
self.assertNotIn(True, suspendedStates)
# areDue
dueStates = util.invoke('areDue', cards=cardIds)
self.assertEqual(len(cardIds), len(dueStates))
self.assertNotIn(False, dueStates)
# getIntervals
util.invoke('getIntervals', cards=cardIds, complete=True)
util.invoke('getIntervals', cards=cardIds, complete=False)
# cardsToNotes
noteIds = util.invoke('cardsToNotes', cards=cardIds)
self.assertEqual(len(noteIds), len(cardIds))
self.assertIn(self.noteId, noteIds)
# cardsInfo
cardsInfo = util.invoke('cardsInfo', cards=cardIds)
self.assertEqual(len(cardsInfo), len(cardIds))
for i, cardInfo in enumerate(cardsInfo):
self.assertEqual(cardInfo['cardId'], cardIds[i])
if __name__ == '__main__':
unittest.main()
| {
"pile_set_name": "Github"
} |
package daemon // import "github.com/docker/docker/daemon"
import (
"fmt"
"io/ioutil"
"os"
"testing"
"github.com/docker/docker/api/types"
containertypes "github.com/docker/docker/api/types/container"
"github.com/docker/docker/container"
"gotest.tools/assert"
is "gotest.tools/assert/cmp"
)
func newDaemonWithTmpRoot(t *testing.T) (*Daemon, func()) {
tmp, err := ioutil.TempDir("", "docker-daemon-unix-test-")
assert.NilError(t, err)
d := &Daemon{
repository: tmp,
root: tmp,
}
d.containers = container.NewMemoryStore()
return d, func() { os.RemoveAll(tmp) }
}
func newContainerWithState(state *container.State) *container.Container {
return &container.Container{
ID: "test",
State: state,
Config: &containertypes.Config{},
}
}
// TestContainerDelete tests that a useful error message and instructions is
// given when attempting to remove a container (#30842)
func TestContainerDelete(t *testing.T) {
tt := []struct {
errMsg string
fixMsg string
initContainer func() *container.Container
}{
// a paused container
{
errMsg: "cannot remove a paused container",
fixMsg: "Unpause and then stop the container before attempting removal or force remove",
initContainer: func() *container.Container {
return newContainerWithState(&container.State{Paused: true, Running: true})
}},
// a restarting container
{
errMsg: "cannot remove a restarting container",
fixMsg: "Stop the container before attempting removal or force remove",
initContainer: func() *container.Container {
c := newContainerWithState(container.NewState())
c.SetRunning(0, true)
c.SetRestarting(&container.ExitStatus{})
return c
}},
// a running container
{
errMsg: "cannot remove a running container",
fixMsg: "Stop the container before attempting removal or force remove",
initContainer: func() *container.Container {
return newContainerWithState(&container.State{Running: true})
}},
}
for _, te := range tt {
c := te.initContainer()
d, cleanup := newDaemonWithTmpRoot(t)
defer cleanup()
d.containers.Add(c.ID, c)
err := d.ContainerRm(c.ID, &types.ContainerRmConfig{ForceRemove: false})
assert.Check(t, is.ErrorContains(err, te.errMsg))
assert.Check(t, is.ErrorContains(err, te.fixMsg))
}
}
func TestContainerDoubleDelete(t *testing.T) {
c := newContainerWithState(container.NewState())
// Mark the container as having a delete in progress
c.SetRemovalInProgress()
d, cleanup := newDaemonWithTmpRoot(t)
defer cleanup()
d.containers.Add(c.ID, c)
// Try to remove the container when its state is removalInProgress.
// It should return an error indicating it is under removal progress.
err := d.ContainerRm(c.ID, &types.ContainerRmConfig{ForceRemove: true})
assert.Check(t, is.ErrorContains(err, fmt.Sprintf("removal of container %s is already in progress", c.ID)))
}
| {
"pile_set_name": "Github"
} |
[GlobalParams]
order = SECOND
displacements = 'disp_x disp_y'
[]
[Mesh]
file = normalized_penalty_Q8.e
[]
[Problem]
type = ReferenceResidualProblem
extra_tag_vectors = 'ref'
reference_vector = 'ref'
[]
[Functions]
[./left_x]
type = PiecewiseLinear
x = '0 1 2'
y = '0 0.02 0'
[../]
[]
[AuxVariables]
[./saved_x]
[../]
[./saved_y]
[../]
[]
[Modules/TensorMechanics/Master]
[./all]
add_variables = true
strain = FINITE
generate_output = 'stress_xx'
save_in = 'saved_x saved_y'
extra_vector_tags = 'ref'
[]
[]
[Contact]
[./m3_s2]
primary = 3
secondary = 2
penalty = 1e10
normalize_penalty = true
formulation = penalty
tangential_tolerance = 1e-3
[../]
[]
[BCs]
[./left_x]
type = FunctionDirichletBC
variable = disp_x
boundary = 1
function = left_x
[../]
[./y]
type = DirichletBC
variable = disp_y
boundary = '1 2 3 4'
value = 0.0
[../]
[./right]
type = DirichletBC
variable = disp_x
boundary = '3 4'
value = 0
[../]
[]
[Materials]
[./stiffStuff1]
type = ComputeIsotropicElasticityTensor
block = '1 2 3 4 1000'
youngs_modulus = 3e8
poissons_ratio = 0.0
[../]
[./stiffStuff1_stress]
type = ComputeFiniteStrainElasticStress
block = '1 2 3 4 1000'
[../]
[]
[Executioner]
type = Transient
solve_type = 'PJFNK'
petsc_options_iname = '-pc_type -ksp_gmres_restart'
petsc_options_value = 'lu 101'
line_search = 'none'
nl_rel_tol = 1e-12
nl_abs_tol = 5e-8
l_max_its = 100
nl_max_its = 10
dt = 0.5
num_steps = 4
[]
[Outputs]
exodus = true
[]
| {
"pile_set_name": "Github"
} |
// <copyright file="TextAnalyticsEntity.cs" company="Microsoft Corporation">
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.
// </copyright>
namespace Connector.Serializable.TextAnalytics
{
using System;
using Connector.Enums;
public class TextAnalyticsEntity
{
public TextAnalyticsEntity(string text, string type, string subType, int offset, int length, float score)
{
Text = text;
TypeString = type;
SubType = subType;
Offset = offset;
Length = length;
Score = score;
}
public string Text { get; private set; }
public string SubType { get; private set; }
public int Offset { get; private set; }
public int Length { get; private set; }
public float Score { get; private set; }
public EntityType Type
{
get
{
if (Enum.TryParse(TypeString, out EntityType outputType))
{
return outputType;
}
return EntityType.Unknown;
}
}
private string TypeString { get; set; }
}
}
| {
"pile_set_name": "Github"
} |
CFile f;
if (!f.Open(_T("dump.txt"), CFile::modeCreate | CFile::modeWrite))
{
AFXDUMP(_T("Unable to open file\n"));
exit(1);
}
CDumpContext dc(&f); | {
"pile_set_name": "Github"
} |
{
'org.eclipse.jetty:jetty-project:jetty-util/src/main/java/org/eclipse/jetty/util/preventers/DOMLeakPreventer.java':[
40,
],
}
| {
"pile_set_name": "Github"
} |
package com.tencent.mm.d.a;
import com.tencent.mm.sdk.c.b;
import java.util.List;
public final class om
extends b
{
public static boolean arQ = false;
public static boolean arR = false;
public a eja = new a();
public b hOI = new b();
public om()
{
id = "WearAction";
jUI = arR;
}
public static final class a
{
public long aAL;
public int action;
}
public static final class b
{
public long aAL;
public long eRY;
public String mes;
public List met;
}
}
/* Location:
* Qualified Name: com.tencent.mm.d.a.om
* Java Class Version: 6 (50.0)
* JD-Core Version: 0.7.1
*/ | {
"pile_set_name": "Github"
} |
<?php
/*
* Copyright (c) e107 Inc 2009 - e107.org, Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id$
*
* 'Import plugin' global language defines
*/
define("LAN_PLUGIN_IMPORT_NAME", "Import into e107");
define("LAN_PLUGIN_IMPORT_DESCRIPTION", "Import data from Wordpress, Joomla, Drupal, Blogpost, RSS and other formats.");
| {
"pile_set_name": "Github"
} |
/* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef TENSORFLOW_LITE_DELEGATES_GPU_CL_KERNELS_UTIL_H_
#define TENSORFLOW_LITE_DELEGATES_GPU_CL_KERNELS_UTIL_H_
#include <string>
#include <vector>
#include "absl/types/span.h"
#include "tensorflow/lite/delegates/gpu/cl/device_info.h"
#include "tensorflow/lite/delegates/gpu/cl/precision.h"
#include "tensorflow/lite/delegates/gpu/common/data_type.h"
#include "tensorflow/lite/delegates/gpu/common/shape.h"
#include "tensorflow/lite/delegates/gpu/common/tensor.h"
#include "tensorflow/lite/delegates/gpu/common/types.h"
#include "tensorflow/lite/delegates/gpu/common/util.h"
namespace tflite {
namespace gpu {
namespace cl {
std::string GetCommonDefines(CalculationsPrecision precision);
// Calculates correct X coordinate when stride != 1 and batch != 1 for layouts
// with B after W (for example HWBC4) and WB stored in one axis of GPU
// resources.
std::string GetXStrideCorrected(const std::string& src_x,
const std::string& batch_size,
const std::string& stride_x,
const std::string& padding_x);
// Calculates correct X coordinate when stride != 1 and batch != 1 for layouts
// with B after W (for example HWBC4) and WB stored in one axis of GPU
// resources.
std::string GetXStrideCorrectedV2(const std::string& src_x,
const std::string& batch_size,
const std::string& stride_x,
const std::string& padding_x);
template <DataType S, typename T>
void RearrangeWeightsToOHWIOGroupI4O4(
const tflite::gpu::Tensor<OHWI, S>& weights, int out_group_size,
absl::Span<T> dst) {
const int dst_slices = DivideRoundUp(weights.shape.o, 4);
const int src_slices = DivideRoundUp(weights.shape.i, 4);
const int dst_groups = DivideRoundUp(dst_slices, out_group_size);
int counter = 0;
for (int d = 0; d < dst_groups; ++d) {
for (int y = 0; y < weights.shape.h; ++y) {
for (int x = 0; x < weights.shape.w; ++x) {
for (int s = 0; s < src_slices; ++s) {
for (int d_group = 0; d_group < out_group_size; ++d_group) {
for (int j = 0; j < 4; ++j) {
T filter;
for (int i = 0; i < 4; ++i) {
const int s_ch = s * 4 + j;
const int d_ch = (d * out_group_size + d_group) * 4 + i;
if (s_ch < weights.shape.i && d_ch < weights.shape.o) {
const int f_index =
weights.shape.LinearIndex({d_ch, y, x, s_ch});
filter[i] = weights.data[f_index];
} else {
filter[i] = 0.0f;
}
}
dst[counter++] = filter;
}
}
}
}
}
}
}
template <DataType S, typename T>
void RearrangeWeightsToODHWIOGroupI4O4(
const tflite::gpu::Tensor<OHWDI, S>& weights, int out_group_size,
absl::Span<T> dst) {
const int dst_slices = DivideRoundUp(weights.shape.o, 4);
const int src_slices = DivideRoundUp(weights.shape.i, 4);
const int dst_groups = DivideRoundUp(dst_slices, out_group_size);
int counter = 0;
for (int d = 0; d < dst_groups; ++d) {
for (int z = 0; z < weights.shape.d; ++z) {
for (int y = 0; y < weights.shape.h; ++y) {
for (int x = 0; x < weights.shape.w; ++x) {
for (int s = 0; s < src_slices; ++s) {
for (int d_group = 0; d_group < out_group_size; ++d_group) {
for (int j = 0; j < 4; ++j) {
T filter;
for (int i = 0; i < 4; ++i) {
const int s_ch = s * 4 + j;
const int d_ch = (d * out_group_size + d_group) * 4 + i;
if (s_ch < weights.shape.i && d_ch < weights.shape.o) {
const int f_index =
weights.shape.LinearIndex({d_ch, y, x, z, s_ch});
filter[i] = weights.data[f_index];
} else {
filter[i] = 0.0f;
}
}
dst[counter++] = filter;
}
}
}
}
}
}
}
}
template <DataType S, typename T>
void RearrangeWeightsToI4HWIOOGroupO4(
const tflite::gpu::Tensor<OHWI, S>& weights, int out_group_size,
absl::Span<T> dst) {
const int dst_slices = DivideRoundUp(weights.shape.o, 4);
const int src_slices = DivideRoundUp(weights.shape.i, 4);
const int dst_groups = DivideRoundUp(dst_slices, out_group_size);
int counter = 0;
for (int j = 0; j < 4; ++j) {
for (int y = 0; y < weights.shape.h; ++y) {
for (int x = 0; x < weights.shape.w; ++x) {
for (int s = 0; s < src_slices; ++s) {
for (int d = 0; d < dst_groups; ++d) {
for (int d_group = 0; d_group < out_group_size; ++d_group) {
T filter;
for (int i = 0; i < 4; ++i) {
const int s_ch = s * 4 + j;
const int d_ch = (d * out_group_size + d_group) * 4 + i;
if (s_ch < weights.shape.i && d_ch < weights.shape.o) {
const int f_index =
weights.shape.LinearIndex({d_ch, y, x, s_ch});
filter[i] = weights.data[f_index];
} else {
filter[i] = 0.0f;
}
}
dst[counter++] = filter;
}
}
}
}
}
}
}
template <DataType S, typename T>
void RearrangeWeightsToI4DHWIOOGroupO4(
const tflite::gpu::Tensor<OHWDI, S>& weights, int out_group_size,
absl::Span<T> dst) {
const int dst_slices = DivideRoundUp(weights.shape.o, 4);
const int src_slices = DivideRoundUp(weights.shape.i, 4);
const int dst_groups = DivideRoundUp(dst_slices, out_group_size);
int counter = 0;
for (int j = 0; j < 4; ++j) {
for (int z = 0; z < weights.shape.d; ++z) {
for (int y = 0; y < weights.shape.h; ++y) {
for (int x = 0; x < weights.shape.w; ++x) {
for (int s = 0; s < src_slices; ++s) {
for (int d = 0; d < dst_groups; ++d) {
for (int d_group = 0; d_group < out_group_size; ++d_group) {
T filter;
for (int i = 0; i < 4; ++i) {
const int s_ch = s * 4 + j;
const int d_ch = (d * out_group_size + d_group) * 4 + i;
if (s_ch < weights.shape.i && d_ch < weights.shape.o) {
const int f_index =
weights.shape.LinearIndex({d_ch, y, x, z, s_ch});
filter[i] = weights.data[f_index];
} else {
filter[i] = 0.0f;
}
}
dst[counter++] = filter;
}
}
}
}
}
}
}
}
// Returns float4 mask for last plane(batch of 4 channels)
// assumes that plane size is 4;
// for example we have 7 channels, in our data structures we align it to 8
// but 8s-channel will be empty, then last plane (batch of 4 channels) will
// have this mask (1, 1, 1, 0).
float4 GetMaskForLastPlane(int channels);
// returns first work group from wgs that has size not bigger than max_wg_size
// if no suitable groups among wgs, returns {1, 1, 1}
int3 GetFirstSuitableWorkGroup(const std::vector<int3>& wgs, int max_wg_size);
// task_size as amount of FLT4 processed elements.
int GetRecommendedBlockSizeForConv(const DeviceInfo& device,
CalculationsPrecision precision,
int task_size);
} // namespace cl
} // namespace gpu
} // namespace tflite
#endif // TENSORFLOW_LITE_DELEGATES_GPU_CL_KERNELS_UTIL_H_
| {
"pile_set_name": "Github"
} |
---
title: "Create roleScopeTag"
description: "Create a new roleScopeTag object."
author: "dougeby"
localization_priority: Normal
ms.prod: "intune"
doc_type: apiPageType
---
# Create roleScopeTag
Namespace: microsoft.graph
> **Important:** Microsoft Graph APIs under the /beta version are subject to change; production use is not supported.
> **Note:** The Microsoft Graph API for Intune requires an [active Intune license](https://go.microsoft.com/fwlink/?linkid=839381) for the tenant.
Create a new [roleScopeTag](../resources/intune-rbac-rolescopetag.md) object.
## Prerequisites
One of the following permissions is required to call this API. To learn more, including how to choose permissions, see [Permissions](/graph/permissions-reference).
|Permission type|Permissions (from most to least privileged)|
|:---|:---|
|Delegated (work or school account)|DeviceManagementRBAC.ReadWrite.All|
|Delegated (personal Microsoft account)|Not supported.|
|Application|DeviceManagementRBAC.ReadWrite.All|
## HTTP Request
<!-- {
"blockType": "ignored"
}
-->
``` http
POST /deviceManagement/roleScopeTags
POST /deviceManagement/roleDefinitions/{roleDefinitionId}/roleAssignments/{roleAssignmentId}/microsoft.graph.deviceAndAppManagementRoleAssignment/roleScopeTags
```
## Request headers
|Header|Value|
|:---|:---|
|Authorization|Bearer <token> Required.|
|Accept|application/json|
## Request body
In the request body, supply a JSON representation for the roleScopeTag object.
The following table shows the properties that are required when you create the roleScopeTag.
|Property|Type|Description|
|:---|:---|:---|
|id|String|Key of the entity. This is read-only and automatically generated.|
|displayName|String|The display or friendly name of the Role Scope Tag.|
|description|String|Description of the Role Scope Tag.|
|isBuiltIn|Boolean|Description of the Role Scope Tag.|
## Response
If successful, this method returns a `201 Created` response code and a [roleScopeTag](../resources/intune-rbac-rolescopetag.md) object in the response body.
## Example
### Request
Here is an example of the request.
``` http
POST https://graph.microsoft.com/beta/deviceManagement/roleScopeTags
Content-type: application/json
Content-length: 155
{
"@odata.type": "#microsoft.graph.roleScopeTag",
"displayName": "Display Name value",
"description": "Description value",
"isBuiltIn": true
}
```
### Response
Here is an example of the response. Note: The response object shown here may be truncated for brevity. All of the properties will be returned from an actual call.
``` http
HTTP/1.1 201 Created
Content-Type: application/json
Content-Length: 204
{
"@odata.type": "#microsoft.graph.roleScopeTag",
"id": "9ed1e179-e179-9ed1-79e1-d19e79e1d19e",
"displayName": "Display Name value",
"description": "Description value",
"isBuiltIn": true
}
```
| {
"pile_set_name": "Github"
} |
.. _tutorial:
pg_auto_failover Tutorial
=========================
In this guide we’ll create a primary and secondary Postgres node and set
up pg_auto_failover to replicate data between them. We’ll simulate failure in
the primary node and see how the system smoothly switches (fails over)
to the secondary.
For illustration, we'll run our databases on virtual machines in the Azure
platform, but the techniques here are relevant to any cloud provider or
on-premise network. We'll use four virtual machines: a primary database, a
secondary database, a monitor, and an "application." The monitor watches the
other nodes’ health, manages global state, and assigns nodes their roles.
Create virtual network
----------------------
Our database machines need to talk to each other and to the monitor node, so
let's create a virtual network.
.. code-block:: bash
az group create \
--name ha-demo \
--location eastus
az network vnet create \
--resource-group ha-demo \
--name ha-demo-net \
--address-prefix 10.0.0.0/16
We need to open ports 5432 (Postgres) and 22 (SSH) between the machines, and
also give ourselves access from our remote IP. We'll do this with a network
security group and a subnet.
.. code-block:: bash
az network nsg create \
--resource-group ha-demo \
--name ha-demo-nsg
az network nsg rule create \
--resource-group ha-demo \
--nsg-name ha-demo-nsg \
--name ha-demo-ssh-and-pg \
--access allow \
--protocol Tcp \
--direction Inbound \
--priority 100 \
--source-address-prefixes `curl ifconfig.me` 10.0.1.0/24 \
--source-port-range "*" \
--destination-address-prefix "*" \
--destination-port-ranges 22 5432
az network vnet subnet create \
--resource-group ha-demo \
--vnet-name ha-demo-net \
--name ha-demo-subnet \
--address-prefixes 10.0.1.0/24 \
--network-security-group ha-demo-nsg
Finally add four virtual machines (ha-demo-a, ha-demo-b, ha-demo-monitor, and
ha-demo-app). For speed we background the ``az vm create`` processes and run
them in parallel:
.. code-block:: bash
# create VMs in parallel
for node in monitor a b app
do
az vm create \
--resource-group ha-demo \
--name ha-demo-${node} \
--vnet-name ha-demo-net \
--subnet ha-demo-subnet \
--nsg ha-demo-nsg \
--public-ip-address ha-demo-${node}-ip \
--image debian \
--admin-username ha-admin \
--generate-ssh-keys &
done
wait
To make it easier to SSH into these VMs in future steps, let's make a shell
function to retrieve their IP addresses:
.. code-block:: bash
# run this in your local shell as well
vm_ip () {
az vm list-ip-addresses -g ha-demo -n ha-demo-$1 -o tsv \
--query '[] [] .virtualMachine.network.publicIpAddresses[0].ipAddress'
}
Let's review what we created so far.
.. code-block:: bash
az resource list --output table --query \
"[?resourceGroup=='ha-demo'].{ name: name, flavor: kind, resourceType: type, region: location }"
This shows the following resources:
::
Name ResourceType Region
------------------------------- ----------------------------------------------------- --------
ha-demo-a Microsoft.Compute/virtualMachines eastus
ha-demo-app Microsoft.Compute/virtualMachines eastus
ha-demo-b Microsoft.Compute/virtualMachines eastus
ha-demo-monitor Microsoft.Compute/virtualMachines eastus
ha-demo-appVMNic Microsoft.Network/networkInterfaces eastus
ha-demo-aVMNic Microsoft.Network/networkInterfaces eastus
ha-demo-bVMNic Microsoft.Network/networkInterfaces eastus
ha-demo-monitorVMNic Microsoft.Network/networkInterfaces eastus
ha-demo-nsg Microsoft.Network/networkSecurityGroups eastus
ha-demo-a-ip Microsoft.Network/publicIPAddresses eastus
ha-demo-app-ip Microsoft.Network/publicIPAddresses eastus
ha-demo-b-ip Microsoft.Network/publicIPAddresses eastus
ha-demo-monitor-ip Microsoft.Network/publicIPAddresses eastus
ha-demo-net Microsoft.Network/virtualNetworks eastus
Install the "pg_autoctl" executable
-----------------------------------
This guide uses Debian Linux, but similar steps will work on other
distributions. All that differs are the packages and paths. See :ref:`install`.
The pg_auto_failover system is distributed as a single ``pg_autoctl`` binary
with subcommands to initialize and manage a replicated PostgreSQL service.
We’ll install the binary with the operating system package manager on all
nodes. It will help us run and observe PostgreSQL.
.. code-block:: bash
for node in monitor a b app
do
az vm run-command invoke \
--resource-group ha-demo \
--name ha-demo-${node} \
--command-id RunShellScript \
--scripts \
"curl https://install.citusdata.com/community/deb.sh | sudo bash" \
"sudo apt-get install -q -y postgresql-common" \
"echo 'create_main_cluster = false' | sudo tee -a /etc/postgresql-common/createcluster.conf" \
"sudo apt-get install -q -y postgresql-11-auto-failover-1.4" \
"sudo usermod -a -G postgres ha-admin" &
done
wait
Run a monitor
-------------
The pg_auto_failover monitor is the first component to run. It periodically
attempts to contact the other nodes and watches their health. It also
maintains global state that “keepers” on each node consult to determine their
own roles in the system.
.. code-block:: bash
# on the monitor virtual machine
ssh -l ha-admin `vm_ip monitor` -- \
pg_autoctl create monitor \
--auth trust \
--ssl-self-signed \
--pgdata monitor \
--pgctl /usr/lib/postgresql/11/bin/pg_ctl
This command initializes a PostgreSQL cluster at the location pointed
by the ``--pgdata`` option. When ``--pgdata`` is omitted, ``pg_autoctl``
attempts to use the ``PGDATA`` environment variable. If a PostgreSQL
instance had already existing in the destination directory, this command
would have configured it to serve as a monitor.
``pg_auto_failover``, installs the ``pgautofailover`` Postgres extension, and
grants access to a new ``autoctl_node`` user.
In the Quick Start we use ``--auth trust`` to avoid complex security settings.
The Postgres `trust authentication method`__ is not considered a reasonable
choice for production environments. Consider either using the ``--skip-pg-hba``
option or ``--auth scram-sha-256`` and then setting up passwords yourself.
__ https://www.postgresql.org/docs/current/auth-trust.html_
At this point the monitor is created. Now we'll install it as a service with
systemd so that it will resume if the VM restarts.
.. code-block:: bash
ssh -l ha-admin `vm_ip monitor` << CMD
pg_autoctl -q show systemd --pgdata ~ha-admin/monitor > pgautofailover.service
sudo mv pgautofailover.service /etc/systemd/system
sudo systemctl daemon-reload
sudo systemctl enable pgautofailover
sudo systemctl start pgautofailover
CMD
Bring up the nodes
------------------
We’ll create the primary database using the ``pg_autoctl create`` subcommand.
.. code-block:: bash
ssh -l ha-admin `vm_ip a` -- \
pg_autoctl create postgres \
--pgdata ha \
--auth trust \
--ssl-self-signed \
--username ha-admin \
--dbname appdb \
--hostname ha-demo-a.internal.cloudapp.net \
--pgctl /usr/lib/postgresql/11/bin/pg_ctl \
--monitor 'postgres://[email protected]/pg_auto_failover?sslmode=require'
Notice the user and database name in the monitor connection string -- these
are what monitor init created. We also give it the path to pg_ctl so that the
keeper will use the correct version of pg_ctl in future even if other versions
of postgres are installed on the system.
In the example above, the keeper creates a primary database. It chooses to set
up node A as primary because the monitor reports there are no other nodes in
the system yet. This is one example of how the keeper is state-based: it makes
observations and then adjusts its state, in this case from "init" to "single."
Also add a setting to trust connections from our "application" VM:
.. code-block:: bash
ssh -l ha-admin `vm_ip a` << CMD
echo 'hostssl "appdb" "ha-admin" ha-demo-app.internal.cloudapp.net trust' \
>> ~ha-admin/ha/pg_hba.conf
CMD
At this point the monitor and primary node are created and running. Next we
need to run the keeper. It’s an independent process so that it can continue
operating even if the PostgreSQL process goes terminates on the node. We'll
install it as a service with systemd so that it will resume if the VM restarts.
.. code-block:: bash
ssh -l ha-admin `vm_ip a` << CMD
pg_autoctl -q show systemd --pgdata ~ha-admin/ha > pgautofailover.service
sudo mv pgautofailover.service /etc/systemd/system
sudo systemctl daemon-reload
sudo systemctl enable pgautofailover
sudo systemctl start pgautofailover
CMD
Next connect to node B and do the same process. We'll do both steps at once:
.. code-block:: bash
ssh -l ha-admin `vm_ip b` -- \
pg_autoctl create postgres \
--pgdata ha \
--auth trust \
--ssl-self-signed \
--username ha-admin \
--dbname appdb \
--hostname ha-demo-b.internal.cloudapp.net \
--pgctl /usr/lib/postgresql/11/bin/pg_ctl \
--monitor 'postgres://[email protected]/pg_auto_failover?sslmode=require'
ssh -l ha-admin `vm_ip b` << CMD
pg_autoctl -q show systemd --pgdata ~ha-admin/ha > pgautofailover.service
sudo mv pgautofailover.service /etc/systemd/system
sudo systemctl daemon-reload
sudo systemctl enable pgautofailover
sudo systemctl start pgautofailover
CMD
It discovers from the monitor that a primary exists, and then switches its own
state to be a hot standby and begins streaming WAL contents from the primary.
Node communication
------------------
For convenience, pg_autoctl modifies each node's ``pg_hba.conf`` file to allow
the nodes to connect to one another. For instance, pg_autoctl added the
following lines to node A:
.. code-block:: ini
# automatically added to node A
hostssl "appdb" "ha-admin" ha-demo-a.internal.cloudapp.net trust
hostssl replication "pgautofailover_replicator" ha-demo-b.internal.cloudapp.net trust
hostssl "appdb" "pgautofailover_replicator" ha-demo-b.internal.cloudapp.net trust
For ``pg_hba.conf`` on the monitor node pg_autoctl inspects the local network
and makes its best guess about the subnet to allow. In our case it guessed
correctly:
.. code-block:: ini
# automatically added to the monitor
hostssl "pg_auto_failover" "autoctl_node" 10.0.1.0/24 trust
If worker nodes have more ad-hoc addresses and are not in the same subnet, it's
better to disable pg_autoctl's automatic modification of pg_hba using the
``--skip-pg-hba`` command line option during creation. You will then need to
edit the hba file by hand. Another reason for manual edits would be to use
special authentication methods.
Watch the replication
---------------------
First let’s verify that the monitor knows about our nodes, and see what
states it has assigned them:
.. code-block:: bash
ssh -l ha-admin `vm_ip monitor` pg_autoctl show state --pgdata monitor
Name | Node | Host:Port | LSN | Reachable | Current State | Assigned State
-------+-------+--------------------------------------+-----------+-----------+---------------------+--------------------
node_1 | 1 | ha-demo-a.internal.cloudapp.net:5432 | 0/3000060 | yes | primary | primary
node_2 | 2 | ha-demo-b.internal.cloudapp.net:5432 | 0/3000060 | yes | secondary | secondary
This looks good. We can add data to the primary, and later see it appear in the
secondary. We'll connect to the database from inside our "app" virtual machine,
using a connection string obtained from the monitor.
.. code-block:: bash
ssh -l ha-admin `vm_ip monitor` pg_autoctl show uri --pgdata monitor
Type | Name | Connection String
-----------+---------+-------------------------------
monitor | monitor | postgres://[email protected]:5432/pg_auto_failover?sslmode=require
formation | default | postgres://ha-demo-b.internal.cloudapp.net:5432,ha-demo-a.internal.cloudapp.net:5432/appdb?target_session_attrs=read-write&sslmode=require
Now we'll get the connection string and store it in a local environment
variable:
.. code-block:: bash
APP_DB_URI=$( \
ssh -l ha-admin `vm_ip monitor` \
pg_autoctl show uri --formation default --pgdata monitor \
)
The connection string contains both our nodes, comma separated, and includes
the url parameter ``?target_session_attrs=read-write`` telling psql that we
want to connect to whichever of these servers supports reads *and* writes.
That will be the primary server.
.. code-block:: bash
# connect to database via psql on the app vm and
# create a table with a million rows
ssh -l ha-admin -t `vm_ip app` -- \
psql "\"$APP_DB_URI\"" \
-c "\"CREATE TABLE foo AS SELECT generate_series(1,1000000) bar;\""
Cause a failover
----------------
Now that we've added data to node A, let's switch which is considered
the primary and which the secondary. After the switch we'll connect again
and query the data, this time from node B.
.. code-block:: bash
# initiate failover to node B
ssh -l ha-admin -t `vm_ip monitor` \
pg_autoctl perform switchover --pgdata monitor
Once node B is marked "primary" (or "wait_primary") we can connect and verify
that the data is still present:
.. code-block:: bash
# connect to database via psql on the app vm
ssh -l ha-admin -t `vm_ip app` -- \
psql "\"$APP_DB_URI\"" \
-c "\"SELECT count(*) FROM foo;\""
It shows
.. code-block:: bash
count
---------
1000000
Cause a node failure
--------------------
This plot is too boring, time to introduce a problem. We’ll turn off VM for
node B (currently the primary after our previous failover) and watch node A
get promoted.
In one terminal let’s keep an eye on events:
.. code-block:: bash
ssh -t -l ha-admin `vm_ip monitor` -- \
watch -n 1 -d pg_autoctl show state --pgdata monitor
In another terminal we’ll turn off the virtual server.
.. code-block:: bash
az vm stop \
--resource-group ha-demo \
--name ha-demo-b
After a number of failed attempts to talk to node B, the monitor determines
the node is unhealthy and puts it into the "demoted" state. The monitor
promotes node A to be the new primary.
.. code-block:: bash
Name | Node | Host:Port | LSN | Reachable | Current State | Assigned State
-------+-------+--------------------------------------+-----------+-----------+---------------------+--------------------
node_1 | 1 | ha-demo-a.internal.cloudapp.net:5432 | 0/6D4E068 | yes | wait_primary | wait_primary
node_2 | 2 | ha-demo-b.internal.cloudapp.net:5432 | 0/6D4E000 | yes | demoted | catchingup
Node A cannot be considered in full "primary" state since there is no secondary
present, but it can still serve client requests. It is marked as "wait_primary"
until a secondary appears, to indicate that it's running without a backup.
Let's add some data while B is offline.
.. code-block:: bash
# notice how $APP_DB_URI continues to work no matter which node
# is serving as primary
ssh -l ha-admin -t `vm_ip app` -- \
psql "\"$APP_DB_URI\"" \
-c "\"INSERT INTO foo SELECT generate_series(1000001, 2000000);\""
Resurrect node B
----------------
Run this command to bring node B back online:
.. code-block:: bash
az vm start \
--resource-group ha-demo \
--name ha-demo-b
Now the next time the keeper retries its health check, it brings the node back.
Node B goes through the state "catchingup" while it updates its data to match
A. Once that's done, B becomes a secondary, and A is now a full primary again.
.. code-block:: bash
Name | Node | Host:Port | LSN | Reachable | Current State | Assigned State
-------+-------+--------------------------------------+------------+-----------+---------------------+--------------------
node_1 | 1 | ha-demo-a.internal.cloudapp.net:5432 | 0/12000738 | yes | primary | primary
node_2 | 2 | ha-demo-b.internal.cloudapp.net:5432 | 0/12000738 | yes | secondary | secondary
What's more, if we connect directly to the database again, all two million rows
are still present.
.. code-block:: bash
ssh -l ha-admin -t `vm_ip app` -- \
psql "\"$APP_DB_URI\"" \
-c "\"SELECT count(*) FROM foo;\""
It shows
.. code-block:: bash
count
---------
2000000
| {
"pile_set_name": "Github"
} |
/*
* Copyright (c) 2015, NVIDIA CORPORATION. All rights reserved.
*
* SPDX-License-Identifier: GPL-2.0+
*/
/*
* THIS FILE IS AUTO-GENERATED - DO NOT EDIT!
*
* To generate this file, use the tegra-pinmux-scripts tool available from
* https://github.com/NVIDIA/tegra-pinmux-scripts
* Run "board-to-uboot.py p2571".
*/
#ifndef _PINMUX_CONFIG_P2571_H_
#define _PINMUX_CONFIG_P2571_H_
#define GPIO_INIT(_port, _gpio, _init) \
{ \
.gpio = TEGRA_GPIO(_port, _gpio), \
.init = TEGRA_GPIO_INIT_##_init, \
}
static const struct tegra_gpio_config p2571_gpio_inits[] = {
/* port, pin, init_val */
GPIO_INIT(A, 0, IN),
GPIO_INIT(A, 5, IN),
GPIO_INIT(D, 4, IN),
GPIO_INIT(E, 4, OUT0),
GPIO_INIT(G, 0, IN),
GPIO_INIT(H, 0, OUT0),
GPIO_INIT(H, 2, IN),
GPIO_INIT(H, 3, OUT0),
GPIO_INIT(H, 4, OUT0),
GPIO_INIT(H, 5, IN),
GPIO_INIT(I, 0, OUT0),
GPIO_INIT(I, 1, IN),
GPIO_INIT(V, 1, OUT0),
GPIO_INIT(V, 6, OUT1),
GPIO_INIT(X, 4, IN),
GPIO_INIT(X, 6, IN),
GPIO_INIT(X, 7, IN),
GPIO_INIT(Y, 1, IN),
GPIO_INIT(Z, 0, IN),
GPIO_INIT(Z, 4, OUT0),
GPIO_INIT(BB, 2, OUT0),
GPIO_INIT(CC, 1, IN),
GPIO_INIT(CC, 3, IN),
};
#define PINCFG(_pingrp, _mux, _pull, _tri, _io, _od, _e_io_hv) \
{ \
.pingrp = PMUX_PINGRP_##_pingrp, \
.func = PMUX_FUNC_##_mux, \
.pull = PMUX_PULL_##_pull, \
.tristate = PMUX_TRI_##_tri, \
.io = PMUX_PIN_##_io, \
.od = PMUX_PIN_OD_##_od, \
.e_io_hv = PMUX_PIN_E_IO_HV_##_e_io_hv, \
.lock = PMUX_PIN_LOCK_DEFAULT, \
}
static const struct pmux_pingrp_config p2571_pingrps[] = {
/* pingrp, mux, pull, tri, e_input, od, e_io_hv */
PINCFG(PEX_L0_RST_N_PA0, DEFAULT, UP, NORMAL, INPUT, DISABLE, NORMAL),
PINCFG(PEX_L0_CLKREQ_N_PA1, RSVD1, DOWN, TRISTATE, OUTPUT, DISABLE, NORMAL),
PINCFG(PEX_WAKE_N_PA2, RSVD1, DOWN, TRISTATE, OUTPUT, DISABLE, NORMAL),
PINCFG(PEX_L1_RST_N_PA3, RSVD1, DOWN, TRISTATE, OUTPUT, DISABLE, NORMAL),
PINCFG(PEX_L1_CLKREQ_N_PA4, RSVD1, DOWN, TRISTATE, OUTPUT, DISABLE, NORMAL),
PINCFG(SATA_LED_ACTIVE_PA5, DEFAULT, UP, NORMAL, INPUT, DISABLE, DEFAULT),
PINCFG(PA6, RSVD1, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(DAP1_FS_PB0, RSVD1, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(DAP1_DIN_PB1, RSVD1, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(DAP1_DOUT_PB2, RSVD1, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(DAP1_SCLK_PB3, RSVD1, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(SPI2_MOSI_PB4, RSVD2, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(SPI2_MISO_PB5, RSVD2, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(SPI2_SCK_PB6, RSVD2, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(SPI2_CS0_PB7, RSVD2, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(SPI1_MOSI_PC0, RSVD1, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(SPI1_MISO_PC1, RSVD1, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(SPI1_SCK_PC2, RSVD1, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(SPI1_CS0_PC3, RSVD1, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(SPI1_CS1_PC4, RSVD1, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(SPI4_SCK_PC5, RSVD1, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(SPI4_CS0_PC6, RSVD1, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(SPI4_MOSI_PC7, RSVD1, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(SPI4_MISO_PD0, RSVD1, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(UART3_TX_PD1, RSVD2, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(UART3_RX_PD2, RSVD2, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(UART3_RTS_PD3, RSVD2, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(UART3_CTS_PD4, DEFAULT, NORMAL, NORMAL, INPUT, DISABLE, DEFAULT),
PINCFG(DMIC1_CLK_PE0, I2S3, NORMAL, NORMAL, INPUT, DISABLE, DEFAULT),
PINCFG(DMIC1_DAT_PE1, I2S3, NORMAL, NORMAL, INPUT, DISABLE, DEFAULT),
PINCFG(DMIC2_CLK_PE2, I2S3, NORMAL, NORMAL, INPUT, DISABLE, DEFAULT),
PINCFG(DMIC2_DAT_PE3, I2S3, NORMAL, NORMAL, INPUT, DISABLE, DEFAULT),
PINCFG(DMIC3_CLK_PE4, DEFAULT, NORMAL, NORMAL, OUTPUT, DISABLE, DEFAULT),
PINCFG(DMIC3_DAT_PE5, RSVD2, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(PE6, RSVD0, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(PE7, PWM3, NORMAL, NORMAL, OUTPUT, DISABLE, DEFAULT),
PINCFG(GEN3_I2C_SCL_PF0, I2C3, NORMAL, NORMAL, INPUT, DISABLE, NORMAL),
PINCFG(GEN3_I2C_SDA_PF1, I2C3, NORMAL, NORMAL, INPUT, DISABLE, NORMAL),
PINCFG(UART2_TX_PG0, DEFAULT, NORMAL, NORMAL, INPUT, DISABLE, DEFAULT),
PINCFG(UART2_RX_PG1, UARTB, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(UART2_RTS_PG2, RSVD2, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(UART2_CTS_PG3, RSVD2, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(WIFI_EN_PH0, DEFAULT, NORMAL, NORMAL, OUTPUT, DISABLE, DEFAULT),
PINCFG(WIFI_RST_PH1, RSVD0, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(WIFI_WAKE_AP_PH2, DEFAULT, UP, NORMAL, INPUT, DISABLE, DEFAULT),
PINCFG(AP_WAKE_BT_PH3, DEFAULT, NORMAL, NORMAL, OUTPUT, DISABLE, DEFAULT),
PINCFG(BT_RST_PH4, DEFAULT, NORMAL, NORMAL, OUTPUT, DISABLE, DEFAULT),
PINCFG(BT_WAKE_AP_PH5, DEFAULT, UP, NORMAL, INPUT, DISABLE, DEFAULT),
PINCFG(PH6, RSVD0, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(AP_WAKE_NFC_PH7, RSVD0, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(NFC_EN_PI0, DEFAULT, NORMAL, NORMAL, OUTPUT, DISABLE, DEFAULT),
PINCFG(NFC_INT_PI1, DEFAULT, NORMAL, NORMAL, INPUT, DISABLE, DEFAULT),
PINCFG(GPS_EN_PI2, RSVD0, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(GPS_RST_PI3, RSVD0, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(UART4_TX_PI4, UARTD, NORMAL, NORMAL, OUTPUT, DISABLE, DEFAULT),
PINCFG(UART4_RX_PI5, UARTD, NORMAL, NORMAL, INPUT, DISABLE, DEFAULT),
PINCFG(UART4_RTS_PI6, UARTD, NORMAL, NORMAL, OUTPUT, DISABLE, DEFAULT),
PINCFG(UART4_CTS_PI7, UARTD, NORMAL, NORMAL, INPUT, DISABLE, DEFAULT),
PINCFG(GEN1_I2C_SDA_PJ0, I2C1, NORMAL, NORMAL, INPUT, DISABLE, NORMAL),
PINCFG(GEN1_I2C_SCL_PJ1, I2C1, NORMAL, NORMAL, INPUT, DISABLE, NORMAL),
PINCFG(GEN2_I2C_SCL_PJ2, I2C2, NORMAL, NORMAL, INPUT, DISABLE, HIGH),
PINCFG(GEN2_I2C_SDA_PJ3, I2C2, NORMAL, NORMAL, INPUT, DISABLE, HIGH),
PINCFG(DAP4_FS_PJ4, RSVD1, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(DAP4_DIN_PJ5, RSVD1, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(DAP4_DOUT_PJ6, RSVD1, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(DAP4_SCLK_PJ7, RSVD1, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(PK0, RSVD2, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(PK1, RSVD2, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(PK2, RSVD2, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(PK3, RSVD2, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(PK4, RSVD1, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(PK5, RSVD1, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(PK6, RSVD1, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(PK7, RSVD1, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(PL0, RSVD0, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(PL1, RSVD1, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(SDMMC1_CLK_PM0, SDMMC1, NORMAL, NORMAL, INPUT, DISABLE, DEFAULT),
PINCFG(SDMMC1_CMD_PM1, SDMMC1, UP, NORMAL, INPUT, DISABLE, DEFAULT),
PINCFG(SDMMC1_DAT3_PM2, SDMMC1, UP, NORMAL, INPUT, DISABLE, DEFAULT),
PINCFG(SDMMC1_DAT2_PM3, SDMMC1, UP, NORMAL, INPUT, DISABLE, DEFAULT),
PINCFG(SDMMC1_DAT1_PM4, SDMMC1, UP, NORMAL, INPUT, DISABLE, DEFAULT),
PINCFG(SDMMC1_DAT0_PM5, SDMMC1, UP, NORMAL, INPUT, DISABLE, DEFAULT),
PINCFG(SDMMC3_CLK_PP0, SDMMC3, NORMAL, NORMAL, INPUT, DISABLE, DEFAULT),
PINCFG(SDMMC3_CMD_PP1, SDMMC3, UP, NORMAL, INPUT, DISABLE, DEFAULT),
PINCFG(SDMMC3_DAT3_PP2, SDMMC3, UP, NORMAL, INPUT, DISABLE, DEFAULT),
PINCFG(SDMMC3_DAT2_PP3, SDMMC3, UP, NORMAL, INPUT, DISABLE, DEFAULT),
PINCFG(SDMMC3_DAT1_PP4, SDMMC3, UP, NORMAL, INPUT, DISABLE, DEFAULT),
PINCFG(SDMMC3_DAT0_PP5, SDMMC3, UP, NORMAL, INPUT, DISABLE, DEFAULT),
PINCFG(CAM1_MCLK_PS0, RSVD1, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(CAM2_MCLK_PS1, RSVD1, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(CAM_I2C_SCL_PS2, I2CVI, NORMAL, NORMAL, INPUT, DISABLE, NORMAL),
PINCFG(CAM_I2C_SDA_PS3, I2CVI, NORMAL, NORMAL, INPUT, DISABLE, NORMAL),
PINCFG(CAM_RST_PS4, RSVD1, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(CAM_AF_EN_PS5, RSVD2, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(CAM_FLASH_EN_PS6, RSVD2, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(CAM1_PWDN_PS7, RSVD1, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(CAM2_PWDN_PT0, RSVD1, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(CAM1_STROBE_PT1, RSVD1, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(UART1_TX_PU0, UARTA, NORMAL, NORMAL, OUTPUT, DISABLE, DEFAULT),
PINCFG(UART1_RX_PU1, UARTA, UP, NORMAL, INPUT, DISABLE, DEFAULT),
PINCFG(UART1_RTS_PU2, UARTA, NORMAL, NORMAL, OUTPUT, DISABLE, DEFAULT),
PINCFG(UART1_CTS_PU3, UARTA, UP, NORMAL, INPUT, DISABLE, DEFAULT),
PINCFG(LCD_BL_PWM_PV0, PWM0, NORMAL, NORMAL, OUTPUT, DISABLE, DEFAULT),
PINCFG(LCD_BL_EN_PV1, DEFAULT, NORMAL, NORMAL, OUTPUT, DISABLE, DEFAULT),
PINCFG(LCD_RST_PV2, RSVD0, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(LCD_GPIO1_PV3, RSVD1, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(LCD_GPIO2_PV4, PWM1, NORMAL, NORMAL, OUTPUT, DISABLE, DEFAULT),
PINCFG(AP_READY_PV5, RSVD0, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(TOUCH_RST_PV6, DEFAULT, NORMAL, NORMAL, OUTPUT, DISABLE, DEFAULT),
PINCFG(TOUCH_CLK_PV7, RSVD1, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(MODEM_WAKE_AP_PX0, RSVD0, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(TOUCH_INT_PX1, RSVD0, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(MOTION_INT_PX2, RSVD0, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(ALS_PROX_INT_PX3, RSVD0, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(TEMP_ALERT_PX4, DEFAULT, UP, NORMAL, INPUT, DISABLE, DEFAULT),
PINCFG(BUTTON_POWER_ON_PX5, RSVD0, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(BUTTON_VOL_UP_PX6, DEFAULT, UP, NORMAL, INPUT, DISABLE, DEFAULT),
PINCFG(BUTTON_VOL_DOWN_PX7, DEFAULT, UP, NORMAL, INPUT, DISABLE, DEFAULT),
PINCFG(BUTTON_SLIDE_SW_PY0, RSVD0, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(BUTTON_HOME_PY1, DEFAULT, UP, NORMAL, INPUT, DISABLE, DEFAULT),
PINCFG(LCD_TE_PY2, RSVD1, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(PWR_I2C_SCL_PY3, I2CPMU, NORMAL, NORMAL, INPUT, DISABLE, NORMAL),
PINCFG(PWR_I2C_SDA_PY4, I2CPMU, NORMAL, NORMAL, INPUT, DISABLE, NORMAL),
PINCFG(CLK_32K_OUT_PY5, SOC, UP, NORMAL, INPUT, DISABLE, DEFAULT),
PINCFG(PZ0, DEFAULT, UP, NORMAL, INPUT, DISABLE, DEFAULT),
PINCFG(PZ1, SDMMC1, UP, NORMAL, INPUT, DISABLE, DEFAULT),
PINCFG(PZ2, RSVD2, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(PZ3, RSVD1, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(PZ4, DEFAULT, NORMAL, NORMAL, OUTPUT, DISABLE, DEFAULT),
PINCFG(PZ5, SOC, UP, NORMAL, INPUT, DISABLE, DEFAULT),
PINCFG(DAP2_FS_PAA0, I2S2, NORMAL, NORMAL, INPUT, DISABLE, DEFAULT),
PINCFG(DAP2_SCLK_PAA1, I2S2, NORMAL, NORMAL, INPUT, DISABLE, DEFAULT),
PINCFG(DAP2_DIN_PAA2, I2S2, NORMAL, NORMAL, INPUT, DISABLE, DEFAULT),
PINCFG(DAP2_DOUT_PAA3, I2S2, NORMAL, NORMAL, INPUT, DISABLE, DEFAULT),
PINCFG(AUD_MCLK_PBB0, AUD, NORMAL, NORMAL, OUTPUT, DISABLE, DEFAULT),
PINCFG(DVFS_PWM_PBB1, CLDVFS, NORMAL, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(DVFS_CLK_PBB2, DEFAULT, NORMAL, NORMAL, OUTPUT, DISABLE, DEFAULT),
PINCFG(GPIO_X1_AUD_PBB3, RSVD0, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(GPIO_X3_AUD_PBB4, RSVD0, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(HDMI_CEC_PCC0, CEC, NORMAL, NORMAL, INPUT, DISABLE, HIGH),
PINCFG(HDMI_INT_DP_HPD_PCC1, DEFAULT, DOWN, NORMAL, INPUT, DISABLE, NORMAL),
PINCFG(SPDIF_OUT_PCC2, RSVD1, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(SPDIF_IN_PCC3, DEFAULT, NORMAL, NORMAL, INPUT, DISABLE, DEFAULT),
PINCFG(USB_VBUS_EN0_PCC4, USB, NORMAL, NORMAL, INPUT, DISABLE, HIGH),
PINCFG(USB_VBUS_EN1_PCC5, USB, NORMAL, NORMAL, INPUT, DISABLE, HIGH),
PINCFG(DP_HPD0_PCC6, RSVD1, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(PCC7, RSVD0, DOWN, TRISTATE, OUTPUT, DISABLE, NORMAL),
PINCFG(SPI2_CS1_PDD0, RSVD1, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(QSPI_SCK_PEE0, RSVD1, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(QSPI_CS_N_PEE1, RSVD1, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(QSPI_IO0_PEE2, RSVD1, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(QSPI_IO1_PEE3, RSVD1, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(QSPI_IO2_PEE4, RSVD1, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(QSPI_IO3_PEE5, RSVD1, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(CORE_PWR_REQ, CORE, NORMAL, NORMAL, OUTPUT, DISABLE, DEFAULT),
PINCFG(CPU_PWR_REQ, CPU, NORMAL, NORMAL, OUTPUT, DISABLE, DEFAULT),
PINCFG(PWR_INT_N, PMI, UP, NORMAL, INPUT, DISABLE, DEFAULT),
PINCFG(CLK_32K_IN, CLK, NORMAL, NORMAL, INPUT, DISABLE, DEFAULT),
PINCFG(JTAG_RTCK, JTAG, NORMAL, NORMAL, OUTPUT, DISABLE, DEFAULT),
PINCFG(CLK_REQ, SYS, NORMAL, NORMAL, OUTPUT, DISABLE, DEFAULT),
PINCFG(SHUTDOWN, SHUTDOWN, NORMAL, NORMAL, OUTPUT, DISABLE, DEFAULT),
};
#define DRVCFG(_drvgrp, _slwf, _slwr, _drvup, _drvdn, _lpmd, _schmt, _hsm) \
{ \
.drvgrp = PMUX_DRVGRP_##_drvgrp, \
.slwf = _slwf, \
.slwr = _slwr, \
.drvup = _drvup, \
.drvdn = _drvdn, \
.lpmd = PMUX_LPMD_##_lpmd, \
.schmt = PMUX_SCHMT_##_schmt, \
.hsm = PMUX_HSM_##_hsm, \
}
static const struct pmux_drvgrp_config p2571_drvgrps[] = {
};
#endif /* PINMUX_CONFIG_P2571_H */
| {
"pile_set_name": "Github"
} |
{
"name": "@polymer/paper-toggle-button",
"private": true,
"description": "A material design toggle button control",
"repository": {
"type": "git",
"url": "git://github.com/PolymerElements/paper-toggle-button"
},
"license": "BSD-3-Clause",
"devDependencies": {
"@polymer/gen-typescript-declarations": "^1.2.0",
"bower": "^1.8.0",
"webmat": "^0.2.0"
},
"scripts": {
"update-types": "bower install && gen-typescript-declarations --deleteExisting --outDir .",
"format": "webmat && npm run update-types"
}
}
| {
"pile_set_name": "Github"
} |
// This module implements the QsciStyle class.
//
// Copyright (c) 2019 Riverbank Computing Limited <[email protected]>
//
// This file is part of QScintilla.
//
// This file may be used under the terms of the GNU General Public License
// version 3.0 as published by the Free Software Foundation and appearing in
// the file LICENSE included in the packaging of this file. Please review the
// following information to ensure the GNU General Public License version 3.0
// requirements will be met: http://www.gnu.org/copyleft/gpl.html.
//
// If you do not wish to use this file under the terms of the GPL version 3.0
// then you may purchase a commercial license. For more information contact
// [email protected].
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#include "Qsci/qscistyle.h"
#include <qapplication.h>
#include "Qsci/qsciscintillabase.h"
// A ctor.
QsciStyle::QsciStyle(int style)
{
init(style);
QPalette pal = QApplication::palette();
setColor(pal.text().color());
setPaper(pal.base().color());
setFont(QApplication::font());
setEolFill(false);
}
// A ctor.
QsciStyle::QsciStyle(int style, const QString &description,
const QColor &color, const QColor &paper, const QFont &font,
bool eolFill)
{
init(style);
setDescription(description);
setColor(color);
setPaper(paper);
setFont(font);
setEolFill(eolFill);
}
// Initialisation common to all ctors.
void QsciStyle::init(int style)
{
// The next style number to allocate. The initial values corresponds to
// the amount of space that Scintilla initially creates for styles.
static int next_style_nr = 63;
// See if a new style should be allocated. Note that we allow styles to be
// passed in that are bigger than STYLE_MAX because the styles used for
// annotations are allowed to be.
if (style < 0)
{
// Note that we don't deal with the situation where the newly allocated
// style number has already been used explicitly.
if (next_style_nr > QsciScintillaBase::STYLE_LASTPREDEFINED)
style = next_style_nr--;
}
style_nr = style;
// Initialise the minor attributes.
setTextCase(QsciStyle::OriginalCase);
setVisible(true);
setChangeable(true);
setHotspot(false);
}
// Apply the style to a particular editor.
void QsciStyle::apply(QsciScintillaBase *sci) const
{
// Don't do anything if the style is invalid.
if (style_nr < 0)
return;
sci->SendScintilla(QsciScintillaBase::SCI_STYLESETFORE, style_nr,
style_color);
sci->SendScintilla(QsciScintillaBase::SCI_STYLESETBACK, style_nr,
style_paper);
sci->SendScintilla(QsciScintillaBase::SCI_STYLESETFONT, style_nr,
style_font.family().toLatin1().data());
sci->SendScintilla(QsciScintillaBase::SCI_STYLESETSIZEFRACTIONAL, style_nr,
long(style_font.pointSizeF() * QsciScintillaBase::SC_FONT_SIZE_MULTIPLIER));
// Pass the Qt weight via the back door.
sci->SendScintilla(QsciScintillaBase::SCI_STYLESETWEIGHT, style_nr,
-style_font.weight());
sci->SendScintilla(QsciScintillaBase::SCI_STYLESETITALIC, style_nr,
style_font.italic());
sci->SendScintilla(QsciScintillaBase::SCI_STYLESETUNDERLINE, style_nr,
style_font.underline());
sci->SendScintilla(QsciScintillaBase::SCI_STYLESETEOLFILLED, style_nr,
style_eol_fill);
sci->SendScintilla(QsciScintillaBase::SCI_STYLESETCASE, style_nr,
(long)style_case);
sci->SendScintilla(QsciScintillaBase::SCI_STYLESETVISIBLE, style_nr,
style_visible);
sci->SendScintilla(QsciScintillaBase::SCI_STYLESETCHANGEABLE, style_nr,
style_changeable);
sci->SendScintilla(QsciScintillaBase::SCI_STYLESETHOTSPOT, style_nr,
style_hotspot);
}
// Set the color attribute.
void QsciStyle::setColor(const QColor &color)
{
style_color = color;
}
// Set the paper attribute.
void QsciStyle::setPaper(const QColor &paper)
{
style_paper = paper;
}
// Set the font attribute.
void QsciStyle::setFont(const QFont &font)
{
style_font = font;
}
// Set the eol fill attribute.
void QsciStyle::setEolFill(bool eolFill)
{
style_eol_fill = eolFill;
}
// Set the text case attribute.
void QsciStyle::setTextCase(QsciStyle::TextCase text_case)
{
style_case = text_case;
}
// Set the visible attribute.
void QsciStyle::setVisible(bool visible)
{
style_visible = visible;
}
// Set the changeable attribute.
void QsciStyle::setChangeable(bool changeable)
{
style_changeable = changeable;
}
// Set the hotspot attribute.
void QsciStyle::setHotspot(bool hotspot)
{
style_hotspot = hotspot;
}
// Refresh the style. Note that since we had to add apply() then this can't do
// anything useful so we leave it as a no-op.
void QsciStyle::refresh()
{
}
| {
"pile_set_name": "Github"
} |
#Generated by Maven Ant Plugin - DO NOT EDIT THIS FILE!
#Mon Nov 11 06:06:10 PST 2019
maven.settings.offline=false
maven.build.finalName=gson-2.6-SNAPSHOT
maven.build.resourceDir.0=src/main/resources
maven.build.testOutputDir=${maven.build.dir}/test-classes
maven.build.testResourceDir.0=src/test/resources
maven.reporting.outputDirectory=${maven.build.dir}/site
project.build.sourceEncoding=UTF-8
maven.build.srcDir.0=src/main/java
sonatypeOssDistMgmtSnapshotsUrl=https\://oss.sonatype.org/content/repositories/snapshots/
project.build.directory=${maven.build.dir}
maven.test.reports=${maven.build.dir}/test-reports
maven.build.dir=target
project.build.outputDirectory=${maven.build.outputDir}
maven.build.testDir.0=src/test/java
maven.settings.interactiveMode=true
maven.repo.local=${user.home}/.m2/repository
maven.build.outputDir=${maven.build.dir}/classes
arguments=
| {
"pile_set_name": "Github"
} |
<?php
/*
* Copyright 2004-2017, AfterLogic Corp.
* Licensed under AGPLv3 license or AfterLogic license
* if commercial version of the product was purchased.
* See the LICENSE file for a full license statement.
*/
namespace MailSo;
/**
* @category MailSo
*/
final class Version
{
/**
* @var string
*/
const APP_VERSION = '1.3.3';
/**
* @var string
*/
const MIME_X_MAILER = 'MailSo';
/**
* @return string
*/
public static function AppVersion()
{
return \MailSo\Version::APP_VERSION;
}
/**
* @return string
*/
public static function XMailer()
{
return \MailSo\Version::MIME_X_MAILER.'/'.\MailSo\Version::APP_VERSION;
}
/**
* @return string
*/
public static function Signature()
{
$sSignature = '';
if (\defined('MAILSO_LIBRARY_USE_PHAR'))
{
$oPhar = new \Phar('mailso.phar');
$sSignature = $oPhar->getSignature();
}
return $sSignature;
}
}
| {
"pile_set_name": "Github"
} |
/* Data structure definitions for a generic GCC target.
Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
Free Software Foundation, Inc.
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, 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; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>.
In other words, you are welcome to use, share and improve this program.
You are forbidden to forbid anyone else to use, share and improve
what you give them. Help stamp out software-hoarding! */
/* This file contains a data structure that describes a GCC target.
At present it is incomplete, but in future it should grow to
contain most or all target machine and target O/S specific
information.
This structure has its initializer declared in target-def.h in the
form of large macro TARGET_INITIALIZER that expands to many smaller
macros.
The smaller macros each initialize one component of the structure,
and each has a default. Each target should have a file that
includes target.h and target-def.h, and overrides any inappropriate
defaults by undefining the relevant macro and defining a suitable
replacement. That file should then contain the definition of
"targetm" like so:
struct gcc_target targetm = TARGET_INITIALIZER;
Doing things this way allows us to bring together everything that
defines a GCC target. By supplying a default that is appropriate
to most targets, we can easily add new items without needing to
edit dozens of target configuration files. It should also allow us
to gradually reduce the amount of conditional compilation that is
scattered throughout GCC. */
#ifndef GCC_TARGET_H
#define GCC_TARGET_H
#include "tm.h"
#include "insn-modes.h"
/* Types used by the record_gcc_switches() target function. */
typedef enum
{
SWITCH_TYPE_PASSED, /* A switch passed on the command line. */
SWITCH_TYPE_ENABLED, /* An option that is currently enabled. */
SWITCH_TYPE_DESCRIPTIVE, /* Descriptive text, not a switch or option. */
SWITCH_TYPE_LINE_START, /* Please emit any necessary text at the start of a line. */
SWITCH_TYPE_LINE_END /* Please emit a line terminator. */
}
print_switch_type;
typedef int (* print_switch_fn_type) (print_switch_type, const char *);
/* An example implementation for ELF targets. Defined in varasm.c */
extern int elf_record_gcc_switches (print_switch_type type, const char *);
/* Some places still assume that all pointer or address modes are the
standard Pmode and ptr_mode. These optimizations become invalid if
the target actually supports multiple different modes. For now,
we disable such optimizations on such targets, using this function. */
extern bool target_default_pointer_address_modes_p (void);
struct stdarg_info;
struct spec_info_def;
/* The struct used by the secondary_reload target hook. */
typedef struct secondary_reload_info
{
/* icode is actually an enum insn_code, but we don't want to force every
file that includes target.h to include optabs.h . */
int icode;
int extra_cost; /* Cost for using (a) scratch register(s) to be taken
into account by copy_cost. */
/* The next two members are for the use of the backward
compatibility hook. */
struct secondary_reload_info *prev_sri;
int t_icode; /* Actually an enum insn_code - see above. */
} secondary_reload_info;
/* This is defined in sched-int.h . */
struct _dep;
/* This is defined in ddg.h . */
struct ddg;
/* Assembler instructions for creating various kinds of integer object. */
struct asm_int_op
{
const char *hi;
const char *si;
const char *di;
const char *ti;
};
/* The target structure. This holds all the backend hooks. */
struct gcc_target
{
/* Functions that output assembler for the target. */
struct asm_out
{
/* Opening and closing parentheses for asm expression grouping. */
const char *open_paren, *close_paren;
/* Assembler instructions for creating various kinds of integer object. */
const char *byte_op;
struct asm_int_op aligned_op, unaligned_op;
/* Try to output the assembler code for an integer object whose
value is given by X. SIZE is the size of the object in bytes and
ALIGNED_P indicates whether it is aligned. Return true if
successful. Only handles cases for which BYTE_OP, ALIGNED_OP
and UNALIGNED_OP are NULL. */
bool (* integer) (rtx x, unsigned int size, int aligned_p);
/* Output code that will globalize a label. */
void (* globalize_label) (FILE *, const char *);
/* Output code that will globalize a declaration. */
void (* globalize_decl_name) (FILE *, tree);
/* Output code that will emit a label for unwind info, if this
target requires such labels. Second argument is the decl the
unwind info is associated with, third is a boolean: true if
this is for exception handling, fourth is a boolean: true if
this is only a placeholder for an omitted FDE. */
void (* unwind_label) (FILE *, tree, int, int);
/* Output code that will emit a label to divide up the exception
table. */
void (* except_table_label) (FILE *);
/* Emit any directives required to unwind this instruction. */
void (* unwind_emit) (FILE *, rtx);
/* Output an internal label. */
void (* internal_label) (FILE *, const char *, unsigned long);
/* Emit a ttype table reference to a typeinfo object. */
bool (* ttype) (rtx);
/* Emit an assembler directive to set visibility for the symbol
associated with the tree decl. */
void (* visibility) (tree, int);
/* Output the assembler code for entry to a function. */
void (* function_prologue) (FILE *, HOST_WIDE_INT);
/* Output the assembler code for end of prologue. */
void (* function_end_prologue) (FILE *);
/* Output the assembler code for start of epilogue. */
void (* function_begin_epilogue) (FILE *);
/* Output the assembler code for function exit. */
void (* function_epilogue) (FILE *, HOST_WIDE_INT);
/* Initialize target-specific sections. */
void (* init_sections) (void);
/* Tell assembler to change to section NAME with attributes FLAGS.
If DECL is non-NULL, it is the VAR_DECL or FUNCTION_DECL with
which this section is associated. */
void (* named_section) (const char *name, unsigned int flags, tree decl);
/* Return a mask describing how relocations should be treated when
selecting sections. Bit 1 should be set if global relocations
should be placed in a read-write section; bit 0 should be set if
local relocations should be placed in a read-write section. */
int (*reloc_rw_mask) (void);
/* Return a section for EXP. It may be a DECL or a constant. RELOC
is nonzero if runtime relocations must be applied; bit 1 will be
set if the runtime relocations require non-local name resolution.
ALIGN is the required alignment of the data. */
section *(* select_section) (tree, int, unsigned HOST_WIDE_INT);
/* Return a section for X. MODE is X's mode and ALIGN is its
alignment in bits. */
section *(* select_rtx_section) (enum machine_mode, rtx,
unsigned HOST_WIDE_INT);
/* Select a unique section name for DECL. RELOC is the same as
for SELECT_SECTION. */
void (* unique_section) (tree, int);
/* Return the readonly data section associated with function DECL. */
section *(* function_rodata_section) (tree);
/* Output a constructor for a symbol with a given priority. */
void (* constructor) (rtx, int);
/* Output a destructor for a symbol with a given priority. */
void (* destructor) (rtx, int);
/* Output the assembler code for a thunk function. THUNK_DECL is the
declaration for the thunk function itself, FUNCTION is the decl for
the target function. DELTA is an immediate constant offset to be
added to THIS. If VCALL_OFFSET is nonzero, the word at
*(*this + vcall_offset) should be added to THIS. */
void (* output_mi_thunk) (FILE *file, tree thunk_decl,
HOST_WIDE_INT delta, HOST_WIDE_INT vcall_offset,
tree function_decl);
/* Determine whether output_mi_thunk would succeed. */
/* ??? Ideally, this hook would not exist, and success or failure
would be returned from output_mi_thunk directly. But there's
too much undo-able setup involved in invoking output_mi_thunk.
Could be fixed by making output_mi_thunk emit rtl instead of
text to the output file. */
bool (* can_output_mi_thunk) (const_tree thunk_decl, HOST_WIDE_INT delta,
HOST_WIDE_INT vcall_offset,
const_tree function_decl);
/* Output any boilerplate text needed at the beginning of a
translation unit. */
void (*file_start) (void);
/* Output any boilerplate text needed at the end of a
translation unit. */
void (*file_end) (void);
/* Output any boilerplate text needed at the beginning of an
LTO output stream. */
void (*lto_start) (void);
/* Output any boilerplate text needed at the end of an
LTO output stream. */
void (*lto_end) (void);
/* Output any boilerplace text needed at the end of a
translation unit before debug and unwind info is emitted. */
void (*code_end) (void);
/* Output an assembler pseudo-op to declare a library function name
external. */
void (*external_libcall) (rtx);
/* Output an assembler directive to mark decl live. This instructs
linker to not dead code strip this symbol. */
void (*mark_decl_preserved) (const char *);
/* Output a record of the command line switches that have been passed. */
print_switch_fn_type record_gcc_switches;
/* The name of the section that the example ELF implementation of
record_gcc_switches will use to store the information. Target
specific versions of record_gcc_switches may or may not use
this information. */
const char * record_gcc_switches_section;
/* Output the definition of a section anchor. */
void (*output_anchor) (rtx);
/* Output a DTP-relative reference to a TLS symbol. */
void (*output_dwarf_dtprel) (FILE *file, int size, rtx x);
/* Some target machines need to postscan each insn after it is output. */
void (*final_postscan_insn) (FILE *, rtx, rtx *, int);
/* Emit the trampoline template. This hook may be NULL. */
void (*trampoline_template) (FILE *);
} asm_out;
/* Functions relating to instruction scheduling. */
struct sched
{
/* Given the current cost, COST, of an insn, INSN, calculate and
return a new cost based on its relationship to DEP_INSN through
the dependence LINK. The default is to make no adjustment. */
int (* adjust_cost) (rtx insn, rtx link, rtx dep_insn, int cost);
/* Adjust the priority of an insn as you see fit. Returns the new
priority. */
int (* adjust_priority) (rtx, int);
/* Function which returns the maximum number of insns that can be
scheduled in the same machine cycle. This must be constant
over an entire compilation. The default is 1. */
int (* issue_rate) (void);
/* Calculate how much this insn affects how many more insns we
can emit this cycle. Default is they all cost the same. */
int (* variable_issue) (FILE *, int, rtx, int);
/* Initialize machine-dependent scheduling code. */
void (* md_init) (FILE *, int, int);
/* Finalize machine-dependent scheduling code. */
void (* md_finish) (FILE *, int);
/* Initialize machine-dependent function wide scheduling code. */
void (* md_init_global) (FILE *, int, int);
/* Finalize machine-dependent function wide scheduling code. */
void (* md_finish_global) (FILE *, int);
/* Reorder insns in a machine-dependent fashion, in two different
places. Default does nothing. */
int (* reorder) (FILE *, int, rtx *, int *, int);
int (* reorder2) (FILE *, int, rtx *, int *, int);
/* The following member value is a pointer to a function called
after evaluation forward dependencies of insns in chain given
by two parameter values (head and tail correspondingly). */
void (* dependencies_evaluation_hook) (rtx, rtx);
/* The values of the following four members are pointers to
functions used to simplify the automaton descriptions.
dfa_pre_cycle_insn and dfa_post_cycle_insn give functions
returning insns which are used to change the pipeline hazard
recognizer state when the new simulated processor cycle
correspondingly starts and finishes. The function defined by
init_dfa_pre_cycle_insn and init_dfa_post_cycle_insn are used
to initialize the corresponding insns. The default values of
the members result in not changing the automaton state when
the new simulated processor cycle correspondingly starts and
finishes. */
void (* init_dfa_pre_cycle_insn) (void);
rtx (* dfa_pre_cycle_insn) (void);
void (* init_dfa_post_cycle_insn) (void);
rtx (* dfa_post_cycle_insn) (void);
/* The values of the following two members are pointers to
functions used to simplify the automaton descriptions.
dfa_pre_advance_cycle and dfa_post_advance_cycle are getting called
immediately before and after cycle is advanced. */
void (* dfa_pre_advance_cycle) (void);
void (* dfa_post_advance_cycle) (void);
/* The following member value is a pointer to a function returning value
which defines how many insns in queue `ready' will we try for
multi-pass scheduling. If the member value is nonzero and the
function returns positive value, the DFA based scheduler will make
multi-pass scheduling for the first cycle. In other words, we will
try to choose ready insn which permits to start maximum number of
insns on the same cycle. */
int (* first_cycle_multipass_dfa_lookahead) (void);
/* The following member value is pointer to a function controlling
what insns from the ready insn queue will be considered for the
multipass insn scheduling. If the hook returns zero for insn
passed as the parameter, the insn will be not chosen to be
issued. */
int (* first_cycle_multipass_dfa_lookahead_guard) (rtx);
/* The following member value is pointer to a function called by
the insn scheduler before issuing insn passed as the third
parameter on given cycle. If the hook returns nonzero, the
insn is not issued on given processors cycle. Instead of that,
the processor cycle is advanced. If the value passed through
the last parameter is zero, the insn ready queue is not sorted
on the new cycle start as usually. The first parameter passes
file for debugging output. The second one passes the scheduler
verbose level of the debugging output. The forth and the fifth
parameter values are correspondingly processor cycle on which
the previous insn has been issued and the current processor
cycle. */
int (* dfa_new_cycle) (FILE *, int, rtx, int, int, int *);
/* The following member value is a pointer to a function called by the
insn scheduler. It should return true if there exists a dependence
which is considered costly by the target, between the insn
DEP_PRO (&_DEP), and the insn DEP_CON (&_DEP). The first parameter is
the dep that represents the dependence between the two insns. The
second argument is the cost of the dependence as estimated by
the scheduler. The last argument is the distance in cycles
between the already scheduled insn (first parameter) and the
second insn (second parameter). */
bool (* is_costly_dependence) (struct _dep *_dep, int, int);
/* Given the current cost, COST, of an insn, INSN, calculate and
return a new cost based on its relationship to DEP_INSN through the
dependence of type DEP_TYPE. The default is to make no adjustment. */
int (* adjust_cost_2) (rtx insn, int, rtx dep_insn, int cost, int dw);
/* The following member value is a pointer to a function called
by the insn scheduler. This hook is called to notify the backend
that new instructions were emitted. */
void (* h_i_d_extended) (void);
/* Next 5 functions are for multi-point scheduling. */
/* Allocate memory for scheduler context. */
void *(* alloc_sched_context) (void);
/* Fills the context from the local machine scheduler context. */
void (* init_sched_context) (void *, bool);
/* Sets local machine scheduler context to a saved value. */
void (* set_sched_context) (void *);
/* Clears a scheduler context so it becomes like after init. */
void (* clear_sched_context) (void *);
/* Frees the scheduler context. */
void (* free_sched_context) (void *);
/* The following member value is a pointer to a function called
by the insn scheduler.
The first parameter is an instruction, the second parameter is the type
of the requested speculation, and the third parameter is a pointer to the
speculative pattern of the corresponding type (set if return value == 1).
It should return
-1, if there is no pattern, that will satisfy the requested speculation
type,
0, if current pattern satisfies the requested speculation type,
1, if pattern of the instruction should be changed to the newly
generated one. */
int (* speculate_insn) (rtx, int, rtx *);
/* The following member value is a pointer to a function called
by the insn scheduler. It should return true if the check instruction
passed as the parameter needs a recovery block. */
bool (* needs_block_p) (int);
/* The following member value is a pointer to a function called
by the insn scheduler. It should return a pattern for the check
instruction.
The first parameter is a speculative instruction, the second parameter
is the label of the corresponding recovery block (or null, if it is a
simple check). If the mutation of the check is requested (e.g. from
ld.c to chk.a), the third parameter is true - in this case the first
parameter is the previous check. */
rtx (* gen_spec_check) (rtx, rtx, int);
/* The following member value is a pointer to a function controlling
what insns from the ready insn queue will be considered for the
multipass insn scheduling. If the hook returns zero for the insn
passed as the parameter, the insn will not be chosen to be
issued. This hook is used to discard speculative instructions,
that stand at the first position of the ready list. */
bool (* first_cycle_multipass_dfa_lookahead_guard_spec) (const_rtx);
/* The following member value is a pointer to a function that provides
information about the speculation capabilities of the target.
The parameter is a pointer to spec_info variable. */
void (* set_sched_flags) (struct spec_info_def *);
/* Return speculation types of the instruction passed as the parameter. */
int (* get_insn_spec_ds) (rtx);
/* Return speculation types that are checked for the instruction passed as
the parameter. */
int (* get_insn_checked_ds) (rtx);
/* Return bool if rtx scanning should just skip current layer and
advance to the inner rtxes. */
bool (* skip_rtx_p) (const_rtx);
/* The following member value is a pointer to a function that provides
information about the target resource-based lower bound which is
used by the swing modulo scheduler. The parameter is a pointer
to ddg variable. */
int (* sms_res_mii) (struct ddg *);
} sched;
/* Functions relating to vectorization. */
struct vectorize
{
/* The following member value is a pointer to a function called
by the vectorizer, and return the decl of the target builtin
function. */
tree (* builtin_mask_for_load) (void);
/* Returns a code for builtin that realizes vectorized version of
function, or NULL_TREE if not available. */
tree (* builtin_vectorized_function) (tree, tree, tree);
/* Returns a code for builtin that realizes vectorized version of
conversion, or NULL_TREE if not available. */
tree (* builtin_conversion) (unsigned, tree);
/* Target builtin that implements vector widening multiplication.
builtin_mul_widen_eve computes the element-by-element products
for the even elements, and builtin_mul_widen_odd computes the
element-by-element products for the odd elements. */
tree (* builtin_mul_widen_even) (tree);
tree (* builtin_mul_widen_odd) (tree);
/* Returns the cost to be added to the overheads involved with
executing the vectorized version of a loop. */
int (*builtin_vectorization_cost) (bool);
/* Return true if vector alignment is reachable (by peeling N
iterations) for the given type. */
bool (* vector_alignment_reachable) (const_tree, bool);
/* Target builtin that implements vector permute. */
tree (* builtin_vec_perm) (tree, tree*);
/* Return true if a vector created for builtin_vec_perm is valid. */
bool (* builtin_vec_perm_ok) (tree, tree);
/* Return true if the target supports misaligned store/load of a
specific factor denoted in the third parameter. The last parameter
is true if the access is defined in a packed struct. */
bool (* builtin_support_vector_misalignment) (enum machine_mode,
const_tree, int, bool);
} vectorize;
/* The initial value of target_flags. */
int default_target_flags;
/* Allow target specific overriding of option settings after options have
been changed by an attribute or pragma or when it is reset at the
end of the code affected by an attribute or pragma. */
void (* override_options_after_change) (void);
/* Handle target switch CODE (an OPT_* value). ARG is the argument
passed to the switch; it is NULL if no argument was. VALUE is the
value of ARG if CODE specifies a UInteger option, otherwise it is
1 if the positive form of the switch was used and 0 if the negative
form was. Return true if the switch was valid. */
bool (* handle_option) (size_t code, const char *arg, int value);
/* Display extra, target specific information in response to a
--target-help switch. */
void (* target_help) (void);
/* Return machine mode for filter value. */
enum machine_mode (* eh_return_filter_mode) (void);
/* Return machine mode for libgcc expanded cmp instructions. */
enum machine_mode (* libgcc_cmp_return_mode) (void);
/* Return machine mode for libgcc expanded shift instructions. */
enum machine_mode (* libgcc_shift_count_mode) (void);
/* Return machine mode to be used for _Unwind_Word type. */
enum machine_mode (* unwind_word_mode) (void);
/* Given two decls, merge their attributes and return the result. */
tree (* merge_decl_attributes) (tree, tree);
/* Given two types, merge their attributes and return the result. */
tree (* merge_type_attributes) (tree, tree);
/* Table of machine attributes and functions to handle them.
Ignored if NULL. */
const struct attribute_spec *attribute_table;
/* Return zero if the attributes on TYPE1 and TYPE2 are incompatible,
one if they are compatible and two if they are nearly compatible
(which causes a warning to be generated). */
int (* comp_type_attributes) (const_tree type1, const_tree type2);
/* Assign default attributes to the newly defined TYPE. */
void (* set_default_type_attributes) (tree type);
/* Insert attributes on the newly created DECL. */
void (* insert_attributes) (tree decl, tree *attributes);
/* Return true if FNDECL (which has at least one machine attribute)
can be inlined despite its machine attributes, false otherwise. */
bool (* function_attribute_inlinable_p) (const_tree fndecl);
/* Return true if bitfields in RECORD_TYPE should follow the
Microsoft Visual C++ bitfield layout rules. */
bool (* ms_bitfield_layout_p) (const_tree record_type);
/* True if the target supports decimal floating point. */
bool (* decimal_float_supported_p) (void);
/* True if the target supports fixed-point. */
bool (* fixed_point_supported_p) (void);
/* Return true if anonymous bitfields affect structure alignment. */
bool (* align_anon_bitfield) (void);
/* Return true if volatile bitfields should use the narrowest type possible.
Return false if they should use the container type. */
bool (* narrow_volatile_bitfield) (void);
/* Set up target-specific built-in functions. */
void (* init_builtins) (void);
/* Initialize (if INITIALIZE_P is true) and return the target-specific
built-in function decl for CODE.
Return NULL if that is not possible. Return error_mark_node if CODE
is outside of the range of valid target builtin function codes. */
tree (* builtin_decl) (unsigned code, bool initialize_p);
/* Expand a target-specific builtin. */
rtx (* expand_builtin) (tree exp, rtx target, rtx subtarget,
enum machine_mode mode, int ignore);
/* Select a replacement for a target-specific builtin. This is done
*before* regular type checking, and so allows the target to
implement a crude form of function overloading. The result is a
complete expression that implements the operation. PARAMS really
has type VEC(tree,gc)*, but we don't want to include tree.h
here. */
tree (*resolve_overloaded_builtin) (unsigned int /*location_t*/,
tree decl, void *params);
/* Fold a target-specific builtin. */
tree (* fold_builtin) (tree fndecl, tree arglist, bool ignore);
/* Returns a code for a target-specific builtin that implements
reciprocal of the function, or NULL_TREE if not available. */
tree (* builtin_reciprocal) (unsigned, bool, bool);
/* For a vendor-specific TYPE, return a pointer to a statically-allocated
string containing the C++ mangling for TYPE. In all other cases, return
NULL. */
const char * (* mangle_type) (const_tree type);
/* Make any adjustments to libfunc names needed for this target. */
void (* init_libfuncs) (void);
/* Given a decl, a section name, and whether the decl initializer
has relocs, choose attributes for the section. */
/* ??? Should be merged with SELECT_SECTION and UNIQUE_SECTION. */
unsigned int (* section_type_flags) (tree, const char *, int);
/* True if new jumps cannot be created, to replace existing ones or
not, at the current point in the compilation. */
bool (* cannot_modify_jumps_p) (void);
/* Return a register class for which branch target register
optimizations should be applied. */
enum reg_class (* branch_target_register_class) (void);
/* Return true if branch target register optimizations should include
callee-saved registers that are not already live during the current
function. AFTER_PE_GEN is true if prologues and epilogues have
already been generated. */
bool (* branch_target_register_callee_saved) (bool after_pe_gen);
/* Return true if the target supports conditional execution. */
bool (* have_conditional_execution) (void);
/* True if the constant X cannot be placed in the constant pool. */
bool (* cannot_force_const_mem) (rtx);
/* True if the insn X cannot be duplicated. */
bool (* cannot_copy_insn_p) (rtx);
/* True if X is considered to be commutative. */
bool (* commutative_p) (const_rtx, int);
/* Given an invalid address X for a given machine mode, try machine-specific
ways to make it legitimate. Return X or an invalid address on failure. */
rtx (* legitimize_address) (rtx, rtx, enum machine_mode);
/* Given an address RTX, undo the effects of LEGITIMIZE_ADDRESS. */
rtx (* delegitimize_address) (rtx);
/* Given an address RTX, say whether it is valid. */
bool (* legitimate_address_p) (enum machine_mode, rtx, bool);
/* True if the given constant can be put into an object_block. */
bool (* use_blocks_for_constant_p) (enum machine_mode, const_rtx);
/* The minimum and maximum byte offsets for anchored addresses. */
HOST_WIDE_INT min_anchor_offset;
HOST_WIDE_INT max_anchor_offset;
/* True if section anchors can be used to access the given symbol. */
bool (* use_anchors_for_symbol_p) (const_rtx);
/* True if it is OK to do sibling call optimization for the specified
call expression EXP. DECL will be the called function, or NULL if
this is an indirect call. */
bool (*function_ok_for_sibcall) (tree decl, tree exp);
/* Establish appropriate back-end context for processing the function
FNDECL. The argument might be NULL to indicate processing at top
level, outside of any function scope. */
void (*set_current_function) (tree fndecl);
/* True if EXP should be placed in a "small data" section. */
bool (* in_small_data_p) (const_tree);
/* True if EXP names an object for which name resolution must resolve
to the current executable or shared library. */
bool (* binds_local_p) (const_tree);
/* Modify and return the identifier of a DECL's external name,
originally identified by ID, as required by the target,
(eg, append @nn to windows32 stdcall function names).
The default is to return ID without modification. */
tree (* mangle_decl_assembler_name) (tree decl, tree id);
/* Do something target-specific to record properties of the DECL into
the associated SYMBOL_REF. */
void (* encode_section_info) (tree, rtx, int);
/* Undo the effects of encode_section_info on the symbol string. */
const char * (* strip_name_encoding) (const char *);
/* If shift optabs for MODE are known to always truncate the shift count,
return the mask that they apply. Return 0 otherwise. */
unsigned HOST_WIDE_INT (* shift_truncation_mask) (enum machine_mode mode);
/* Return the number of divisions in the given MODE that should be present,
so that it is profitable to turn the division into a multiplication by
the reciprocal. */
unsigned int (* min_divisions_for_recip_mul) (enum machine_mode mode);
/* If the representation of integral MODE is such that values are
always sign-extended to a wider mode MODE_REP then return
SIGN_EXTEND. Return UNKNOWN otherwise. */
/* Note that the return type ought to be RTX_CODE, but that's not
necessarily defined at this point. */
int (* mode_rep_extended) (enum machine_mode mode,
enum machine_mode mode_rep);
/* True if MODE is valid for a pointer in __attribute__((mode("MODE"))). */
bool (* valid_pointer_mode) (enum machine_mode mode);
/* Support for named address spaces. */
struct addr_space {
/* MODE to use for a pointer into another address space. */
enum machine_mode (* pointer_mode) (addr_space_t);
/* MODE to use for an address in another address space. */
enum machine_mode (* address_mode) (addr_space_t);
/* True if MODE is valid for a pointer in __attribute__((mode("MODE")))
in another address space. */
bool (* valid_pointer_mode) (enum machine_mode, addr_space_t);
/* True if an address is a valid memory address to a given named address
space for a given mode. */
bool (* legitimate_address_p) (enum machine_mode, rtx, bool, addr_space_t);
/* Return an updated address to convert an invalid pointer to a named
address space to a valid one. If NULL_RTX is returned use machine
independent methods to make the address valid. */
rtx (* legitimize_address) (rtx, rtx, enum machine_mode, addr_space_t);
/* True if one named address space is a subset of another named address. */
bool (* subset_p) (addr_space_t, addr_space_t);
/* Function to convert an rtl expression from one address space to
another. */
rtx (* convert) (rtx, tree, tree);
} addr_space;
/* True if MODE is valid for the target. By "valid", we mean able to
be manipulated in non-trivial ways. In particular, this means all
the arithmetic is supported. */
bool (* scalar_mode_supported_p) (enum machine_mode mode);
/* Similarly for vector modes. "Supported" here is less strict. At
least some operations are supported; need to check optabs or builtins
for further details. */
bool (* vector_mode_supported_p) (enum machine_mode mode);
/* Compute a (partial) cost for rtx X. Return true if the complete
cost has been computed, and false if subexpressions should be
scanned. In either case, *TOTAL contains the cost result. */
/* Note that CODE and OUTER_CODE ought to be RTX_CODE, but that's
not necessarily defined at this point. */
bool (* rtx_costs) (rtx x, int code, int outer_code, int *total, bool speed);
/* Compute the cost of X, used as an address. Never called with
invalid addresses. */
int (* address_cost) (rtx x, bool speed);
/* Return where to allocate pseudo for a given hard register initial
value. */
rtx (* allocate_initial_value) (rtx x);
/* Return nonzero if evaluating UNSPEC[_VOLATILE] X might cause a trap.
FLAGS has the same meaning as in rtlanal.c: may_trap_p_1. */
int (* unspec_may_trap_p) (const_rtx x, unsigned flags);
/* Given a register, this hook should return a parallel of registers
to represent where to find the register pieces. Define this hook
if the register and its mode are represented in Dwarf in
non-contiguous locations, or if the register should be
represented in more than one register in Dwarf. Otherwise, this
hook should return NULL_RTX. */
rtx (* dwarf_register_span) (rtx);
/* If expand_builtin_init_dwarf_reg_sizes needs to fill in table
entries not corresponding directly to registers below
FIRST_PSEUDO_REGISTER, this hook should generate the necessary
code, given the address of the table. */
void (* init_dwarf_reg_sizes_extra) (tree);
/* Fetch the fixed register(s) which hold condition codes, for
targets where it makes sense to look for duplicate assignments to
the condition codes. This should return true if there is such a
register, false otherwise. The arguments should be set to the
fixed register numbers. Up to two condition code registers are
supported. If there is only one for this target, the int pointed
at by the second argument should be set to -1. */
bool (* fixed_condition_code_regs) (unsigned int *, unsigned int *);
/* If two condition code modes are compatible, return a condition
code mode which is compatible with both, such that a comparison
done in the returned mode will work for both of the original
modes. If the condition code modes are not compatible, return
VOIDmode. */
enum machine_mode (* cc_modes_compatible) (enum machine_mode,
enum machine_mode);
/* Do machine-dependent code transformations. Called just before
delayed-branch scheduling. */
void (* machine_dependent_reorg) (void);
/* Create the __builtin_va_list type. */
tree (* build_builtin_va_list) (void);
/* Get the cfun/fndecl calling abi __builtin_va_list type. */
tree (* fn_abi_va_list) (tree);
/* Get the __builtin_va_list type dependent on input type. */
tree (* canonical_va_list_type) (tree);
/* Expand the __builtin_va_start builtin. */
void (* expand_builtin_va_start) (tree valist, rtx nextarg);
/* Gimplifies a VA_ARG_EXPR. */
tree (* gimplify_va_arg_expr) (tree valist, tree type, gimple_seq *pre_p,
gimple_seq *post_p);
/* Validity-checking routines for PCH files, target-specific.
get_pch_validity returns a pointer to the data to be stored,
and stores the size in its argument. pch_valid_p gets the same
information back and returns NULL if the PCH is valid,
or an error message if not.
*/
void * (* get_pch_validity) (size_t *);
const char * (* pch_valid_p) (const void *, size_t);
/* If nonnull, this function checks whether a PCH file with the
given set of target flags can be used. It returns NULL if so,
otherwise it returns an error message. */
const char *(*check_pch_target_flags) (int);
/* True if the compiler should give an enum type only as many
bytes as it takes to represent the range of possible values of
that type. */
bool (* default_short_enums) (void);
/* This target hook returns an rtx that is used to store the address
of the current frame into the built-in setjmp buffer. */
rtx (* builtin_setjmp_frame_value) (void);
/* This target hook should add STRING_CST trees for any hard regs
the port wishes to automatically clobber for an asm. */
tree (* md_asm_clobbers) (tree, tree, tree);
/* This target hook allows the backend to specify a calling convention
in the debug information. This function actually returns an
enum dwarf_calling_convention, but because of forward declarations
and not wanting to include dwarf2.h everywhere target.h is included
the function is being declared as an int. */
int (* dwarf_calling_convention) (const_tree);
/* This target hook allows the backend to emit frame-related insns that
contain UNSPECs or UNSPEC_VOLATILEs. The call frame debugging info
engine will invoke it on insns of the form
(set (reg) (unspec [...] UNSPEC_INDEX))
and
(set (reg) (unspec_volatile [...] UNSPECV_INDEX))
to let the backend emit the call frame instructions. */
void (* dwarf_handle_frame_unspec) (const char *, rtx, int);
/* Perform architecture specific checking of statements gimplified
from VA_ARG_EXPR. STMT is the statement. Returns true if the statement
doesn't need to be checked for va_list references. */
bool (* stdarg_optimize_hook) (struct stdarg_info *ai, const_gimple stmt);
/* This target hook allows the operating system to override the DECL
that represents the external variable that contains the stack
protection guard variable. The type of this DECL is ptr_type_node. */
tree (* stack_protect_guard) (void);
/* This target hook allows the operating system to override the CALL_EXPR
that is invoked when a check vs the guard variable fails. */
tree (* stack_protect_fail) (void);
/* Returns NULL if target supports the insn within a doloop block,
otherwise it returns an error message. */
const char * (*invalid_within_doloop) (const_rtx);
/* DECL is a variable or function with __attribute__((dllimport))
specified. Use this hook if the target needs to add extra validation
checks to handle_dll_attribute (). */
bool (* valid_dllimport_attribute_p) (const_tree decl);
/* If non-zero, align constant anchors in CSE to a multiple of this
value. */
unsigned HOST_WIDE_INT const_anchor;
/* Functions relating to calls - argument passing, returns, etc. */
struct calls {
enum machine_mode (*promote_function_mode) (const_tree type,
enum machine_mode mode,
int *punsignedp,
const_tree fntype,
int for_return);
bool (*promote_prototypes) (const_tree fntype);
rtx (*struct_value_rtx) (tree fndecl, int incoming);
bool (*return_in_memory) (const_tree type, const_tree fndecl);
bool (*return_in_msb) (const_tree type);
/* Return true if a parameter must be passed by reference. TYPE may
be null if this is a libcall. CA may be null if this query is
from __builtin_va_arg. */
bool (*pass_by_reference) (CUMULATIVE_ARGS *ca, enum machine_mode mode,
const_tree type, bool named_arg);
rtx (*expand_builtin_saveregs) (void);
/* Returns pretend_argument_size. */
void (*setup_incoming_varargs) (CUMULATIVE_ARGS *ca, enum machine_mode mode,
tree type, int *pretend_arg_size,
int second_time);
bool (*strict_argument_naming) (CUMULATIVE_ARGS *ca);
/* Returns true if we should use
targetm.calls.setup_incoming_varargs() and/or
targetm.calls.strict_argument_naming(). */
bool (*pretend_outgoing_varargs_named) (CUMULATIVE_ARGS *ca);
/* Given a complex type T, return true if a parameter of type T
should be passed as two scalars. */
bool (* split_complex_arg) (const_tree type);
/* Return true if type T, mode MODE, may not be passed in registers,
but must be passed on the stack. */
/* ??? This predicate should be applied strictly after pass-by-reference.
Need audit to verify that this is the case. */
bool (* must_pass_in_stack) (enum machine_mode mode, const_tree t);
/* Return true if type TYPE, mode MODE, which is passed by reference,
should have the object copy generated by the callee rather than
the caller. It is never called for TYPE requiring constructors. */
bool (* callee_copies) (CUMULATIVE_ARGS *ca, enum machine_mode mode,
const_tree type, bool named);
/* Return zero for arguments passed entirely on the stack or entirely
in registers. If passed in both, return the number of bytes passed
in registers; the balance is therefore passed on the stack. */
int (* arg_partial_bytes) (CUMULATIVE_ARGS *ca, enum machine_mode mode,
tree type, bool named);
/* Return the diagnostic message string if function without a prototype
is not allowed for this 'val' argument; NULL otherwise. */
const char *(*invalid_arg_for_unprototyped_fn) (const_tree typelist,
const_tree funcdecl,
const_tree val);
/* Return an rtx for the return value location of the function
specified by FN_DECL_OR_TYPE with a return type of RET_TYPE. */
rtx (*function_value) (const_tree ret_type, const_tree fn_decl_or_type,
bool outgoing);
/* Return the rtx for the result of a libcall of mode MODE,
calling the function FN_NAME. */
rtx (*libcall_value) (enum machine_mode, const_rtx);
/* Return an rtx for the argument pointer incoming to the
current function. */
rtx (*internal_arg_pointer) (void);
/* Update the current function stack boundary if needed. */
void (*update_stack_boundary) (void);
/* Handle stack alignment and return an rtx for Dynamic Realign
Argument Pointer if necessary. */
rtx (*get_drap_rtx) (void);
/* Return true if all function parameters should be spilled to the
stack. */
bool (*allocate_stack_slots_for_args) (void);
/* Return an rtx for the static chain for FNDECL. If INCOMING_P is true,
then it should be for the callee; otherwise for the caller. */
rtx (*static_chain) (const_tree fndecl, bool incoming_p);
/* Fill in the trampoline at MEM with a call to FNDECL and a
static chain value of CHAIN. */
void (*trampoline_init) (rtx mem, tree fndecl, rtx chain);
/* Adjust the address of the trampoline in a target-specific way. */
rtx (*trampoline_adjust_address) (rtx addr);
} calls;
/* Return the diagnostic message string if conversion from FROMTYPE
to TOTYPE is not allowed, NULL otherwise. */
const char *(*invalid_conversion) (const_tree fromtype, const_tree totype);
/* Return the diagnostic message string if the unary operation OP is
not permitted on TYPE, NULL otherwise. */
const char *(*invalid_unary_op) (int op, const_tree type);
/* Return the diagnostic message string if the binary operation OP
is not permitted on TYPE1 and TYPE2, NULL otherwise. */
const char *(*invalid_binary_op) (int op, const_tree type1, const_tree type2);
/* Return the diagnostic message string if TYPE is not valid as a
function parameter type, NULL otherwise. */
const char *(*invalid_parameter_type) (const_tree type);
/* Return the diagnostic message string if TYPE is not valid as a
function return type, NULL otherwise. */
const char *(*invalid_return_type) (const_tree type);
/* If values of TYPE are promoted to some other type when used in
expressions (analogous to the integer promotions), return that type,
or NULL_TREE otherwise. */
tree (*promoted_type) (const_tree type);
/* Convert EXPR to TYPE, if target-specific types with special conversion
rules are involved. Return the converted expression, or NULL to apply
the standard conversion rules. */
tree (*convert_to_type) (tree type, tree expr);
/* Return the array of IRA cover classes for the current target. */
const enum reg_class *(*ira_cover_classes) (void);
/* Return the class for a secondary reload, and fill in extra information. */
enum reg_class (*secondary_reload) (bool, rtx, enum reg_class,
enum machine_mode,
secondary_reload_info *);
/* This target hook allows the backend to perform additional
processing while initializing for variable expansion. */
void (* expand_to_rtl_hook) (void);
/* This target hook allows the backend to perform additional
instantiations on rtx that are not actually in insns yet,
but will be later. */
void (* instantiate_decls) (void);
/* Return true if is OK to use a hard register REGNO as scratch register
in peephole2. */
bool (* hard_regno_scratch_ok) (unsigned int regno);
/* Return the smallest number of different values for which it is best to
use a jump-table instead of a tree of conditional branches. */
unsigned int (* case_values_threshold) (void);
/* Retutn true if a function must have and use a frame pointer. */
bool (* frame_pointer_required) (void);
/* Returns true if the compiler is allowed to try to replace register number
from-reg with register number to-reg. */
bool (* can_eliminate) (const int, const int);
/* Functions specific to the C family of frontends. */
struct c {
/* Return machine mode for non-standard suffix
or VOIDmode if non-standard suffixes are unsupported. */
enum machine_mode (*mode_for_suffix) (char);
} c;
/* Functions specific to the C++ frontend. */
struct cxx {
/* Return the integer type used for guard variables. */
tree (*guard_type) (void);
/* Return true if only the low bit of the guard should be tested. */
bool (*guard_mask_bit) (void);
/* Returns the size of the array cookie for an array of type. */
tree (*get_cookie_size) (tree);
/* Returns true if the element size should be stored in the
array cookie. */
bool (*cookie_has_size) (void);
/* Allows backends to perform additional processing when
deciding if a class should be exported or imported. */
int (*import_export_class) (tree, int);
/* Returns true if constructors and destructors return "this". */
bool (*cdtor_returns_this) (void);
/* Returns true if the key method for a class can be an inline
function, so long as it is not declared inline in the class
itself. Returning true is the behavior required by the Itanium
C++ ABI. */
bool (*key_method_may_be_inline) (void);
/* DECL is a virtual table, virtual table table, typeinfo object,
or other similar implicit class data object that will be
emitted with external linkage in this translation unit. No ELF
visibility has been explicitly specified. If the target needs
to specify a visibility other than that of the containing class,
use this hook to set DECL_VISIBILITY and
DECL_VISIBILITY_SPECIFIED. */
void (*determine_class_data_visibility) (tree decl);
/* Returns true (the default) if virtual tables and other
similar implicit class data objects are always COMDAT if they
have external linkage. If this hook returns false, then
class data for classes whose virtual table will be emitted in
only one translation unit will not be COMDAT. */
bool (*class_data_always_comdat) (void);
/* Returns true (the default) if the RTTI for the basic types,
which is always defined in the C++ runtime, should be COMDAT;
false if it should not be COMDAT. */
bool (*library_rtti_comdat) (void);
/* Returns true if __aeabi_atexit should be used to register static
destructors. */
bool (*use_aeabi_atexit) (void);
/* Returns true if target may use atexit in the same manner as
__cxa_atexit to register static destructors. */
bool (*use_atexit_for_cxa_atexit) (void);
/* TYPE is a C++ class (i.e., RECORD_TYPE or UNION_TYPE) that
has just been defined. Use this hook to make adjustments to the
class (eg, tweak visibility or perform any other required
target modifications). */
void (*adjust_class_at_definition) (tree type);
} cxx;
/* Functions and data for emulated TLS support. */
struct emutls {
/* Name of the address and common functions. */
const char *get_address;
const char *register_common;
/* Prefixes for proxy variable and template. */
const char *var_section;
const char *tmpl_section;
/* Prefixes for proxy variable and template. */
const char *var_prefix;
const char *tmpl_prefix;
/* Function to generate field definitions of the proxy variable. */
tree (*var_fields) (tree, tree *);
/* Function to initialize a proxy variable. */
tree (*var_init) (tree, tree, tree);
/* Whether we are allowed to alter the usual alignment of the
proxy variable. */
bool var_align_fixed;
/* Whether we can emit debug information for TLS vars. */
bool debug_form_tls_address;
} emutls;
struct target_option_hooks {
/* Function to validate the attribute((option(...))) strings or NULL. If
the option is validated, it is assumed that DECL_FUNCTION_SPECIFIC will
be filled in in the function decl node. */
bool (*valid_attribute_p) (tree, tree, tree, int);
/* Function to save any extra target state in the target options
structure. */
void (*save) (struct cl_target_option *);
/* Function to restore any extra target state from the target options
structure. */
void (*restore) (struct cl_target_option *);
/* Function to print any extra target state from the target options
structure. */
void (*print) (FILE *, int, struct cl_target_option *);
/* Function to parse arguments to be validated for #pragma option, and to
change the state if the options are valid. If the first argument is
NULL, the second argument specifies the default options to use. Return
true if the options are valid, and set the current state. */
bool (*pragma_parse) (tree, tree);
/* Function to determine if one function can inline another function. */
bool (*can_inline_p) (tree, tree);
} target_option;
/* For targets that need to mark extra registers as live on entry to
the function, they should define this target hook and set their
bits in the bitmap passed in. */
void (*live_on_entry) (bitmap);
/* True if unwinding tables should be generated by default. */
bool unwind_tables_default;
/* Leave the boolean fields at the end. */
/* True if arbitrary sections are supported. */
bool have_named_sections;
/* True if we can create zeroed data by switching to a BSS section
and then using ASM_OUTPUT_SKIP to allocate the space. */
bool have_switchable_bss_sections;
/* True if "native" constructors and destructors are supported,
false if we're using collect2 for the job. */
bool have_ctors_dtors;
/* True if thread-local storage is supported. */
bool have_tls;
/* True if a small readonly data section is supported. */
bool have_srodata_section;
/* True if EH frame info sections should be zero-terminated. */
bool terminate_dw2_eh_frame_info;
/* True if #NO_APP should be emitted at the beginning of
assembly output. */
bool file_start_app_off;
/* True if output_file_directive should be called for main_input_filename
at the beginning of assembly output. */
bool file_start_file_directive;
/* True if #pragma extern_prefix is to be supported. */
bool handle_pragma_extern_prefix;
/* True if the target is allowed to reorder memory accesses unless
synchronization is explicitly requested. */
bool relaxed_ordering;
/* Returns true if we should generate exception tables for use with the
ARM EABI. The effects the encoding of function exception specifications.
*/
bool arm_eabi_unwinder;
/* Leave the boolean fields at the end. */
};
extern struct gcc_target targetm;
struct gcc_targetcm {
/* Handle target switch CODE (an OPT_* value). ARG is the argument
passed to the switch; it is NULL if no argument was. VALUE is the
value of ARG if CODE specifies a UInteger option, otherwise it is
1 if the positive form of the switch was used and 0 if the negative
form was. Return true if the switch was valid. */
bool (*handle_c_option) (size_t code, const char *arg, int value);
};
/* Each target can provide their own. */
extern struct gcc_targetcm targetcm;
#endif /* GCC_TARGET_H */
| {
"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="X-UA-Compatible" content="IE=Edge" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>VS_WINRT_EXTENSIONS — CMake 3.14.5 Documentation</title>
<link rel="stylesheet" href="../_static/cmake.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script type="text/javascript" src="../_static/documentation_options.js"></script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<link rel="shortcut icon" href="../_static/cmake-favicon.ico"/>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="VS_WINRT_REFERENCES" href="VS_WINRT_REFERENCES.html" />
<link rel="prev" title="VS_WINRT_COMPONENT" href="VS_WINRT_COMPONENT.html" />
</head><body>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="VS_WINRT_REFERENCES.html" title="VS_WINRT_REFERENCES"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="VS_WINRT_COMPONENT.html" title="VS_WINRT_COMPONENT"
accesskey="P">previous</a> |</li>
<li>
<img src="../_static/cmake-logo-16.png" alt=""
style="vertical-align: middle; margin-top: -2px" />
</li>
<li>
<a href="https://cmake.org/">CMake</a> »
</li>
<li>
<a href="../index.html">3.14.5 Documentation</a> »
</li>
<li class="nav-item nav-item-1"><a href="../manual/cmake-properties.7.html" accesskey="U">cmake-properties(7)</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="vs-winrt-extensions">
<span id="prop_tgt:VS_WINRT_EXTENSIONS"></span><h1>VS_WINRT_EXTENSIONS<a class="headerlink" href="#vs-winrt-extensions" title="Permalink to this headline">¶</a></h1>
<p>Deprecated. Use <span class="target" id="index-0-prop_tgt:VS_WINRT_COMPONENT"></span><a class="reference internal" href="VS_WINRT_COMPONENT.html#prop_tgt:VS_WINRT_COMPONENT" title="VS_WINRT_COMPONENT"><code class="xref cmake cmake-prop_tgt docutils literal notranslate"><span class="pre">VS_WINRT_COMPONENT</span></code></a> instead.
This property was an experimental partial implementation of that one.</p>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h4>Previous topic</h4>
<p class="topless"><a href="VS_WINRT_COMPONENT.html"
title="previous chapter">VS_WINRT_COMPONENT</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="VS_WINRT_REFERENCES.html"
title="next chapter">VS_WINRT_REFERENCES</a></p>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../_sources/prop_tgt/VS_WINRT_EXTENSIONS.rst.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3>Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="VS_WINRT_REFERENCES.html" title="VS_WINRT_REFERENCES"
>next</a> |</li>
<li class="right" >
<a href="VS_WINRT_COMPONENT.html" title="VS_WINRT_COMPONENT"
>previous</a> |</li>
<li>
<img src="../_static/cmake-logo-16.png" alt=""
style="vertical-align: middle; margin-top: -2px" />
</li>
<li>
<a href="https://cmake.org/">CMake</a> »
</li>
<li>
<a href="../index.html">3.14.5 Documentation</a> »
</li>
<li class="nav-item nav-item-1"><a href="../manual/cmake-properties.7.html" >cmake-properties(7)</a> »</li>
</ul>
</div>
<div class="footer" role="contentinfo">
© Copyright 2000-2019 Kitware, Inc. and Contributors.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.2.
</div>
</body>
</html> | {
"pile_set_name": "Github"
} |
#include <Windows.h>
#include "entry.h"
#ifndef WDM_QUEUE_H
#define WDM_QUEUE_H
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
// ---------------------------------------------------------
// Types
// ---------------------------------------------------------
typedef enum {
WDM_QUEUE_ITEM_TYPE_ERROR,
WDM_QUEUE_ITEM_TYPE_DATA
} WDM_QueueItemType;
typedef struct {
WDM_PEntryUserData user_data;
BYTE buffer[WDM_BUFFER_SIZE];
} WDM_QueueItemData, *WDM_PQueueItemData;
typedef struct {
VALUE exception_klass;
LPSTR message;
} WDM_QueueItemError, *WDM_PQueueItemError;
typedef struct WDM_QueueItem {
WDM_QueueItemType type;
union {
WDM_PQueueItemData data;
WDM_PQueueItemError error;
};
struct WDM_QueueItem* next;
} WDM_QueueItem, *WDM_PQueueItem;
typedef struct {
CRITICAL_SECTION lock;
WDM_PQueueItem front;
WDM_PQueueItem rear;
} WDM_Queue, *WDM_PQueue;
// ---------------------------------------------------------
// Prototypes
// ---------------------------------------------------------
WDM_PQueueItemError wdm_queue_item_error_new(VALUE, LPCSTR, ...);
void wdm_queue_item_error_free(WDM_PQueueItemError);
WDM_PQueueItemData wdm_queue_item_data_new();
void wdm_queue_item_data_free(WDM_PQueueItemData);
WDM_PQueueItem wdm_queue_item_new(WDM_QueueItemType);
void wdm_queue_item_free(WDM_PQueueItem);
WDM_PQueue wdm_queue_new();
void wdm_queue_free(WDM_PQueue);
void wdm_queue_enqueue(WDM_PQueue, WDM_PQueueItem);
WDM_PQueueItem wdm_queue_dequeue(WDM_PQueue);
void wdm_queue_empty(WDM_PQueue);
BOOL wdm_queue_is_empty(WDM_PQueue);
// ---------------------------------------------------------
#ifdef __cplusplus
}
#endif // __cplusplus
#endif // WDM_QUEUE_H | {
"pile_set_name": "Github"
} |
// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. See the AUTHORS file for names of contributors.
#ifndef STORAGE_LEVELDB_TABLE_BLOCK_H_
#define STORAGE_LEVELDB_TABLE_BLOCK_H_
#include <stddef.h>
#include <stdint.h>
#include "leveldb/iterator.h"
namespace leveldb {
struct BlockContents;
class Comparator;
class Block {
public:
// Initialize the block with the specified contents.
explicit Block(const BlockContents& contents);
~Block();
size_t size() const { return size_; }
Iterator* NewIterator(const Comparator* comparator);
private:
uint32_t NumRestarts() const;
const char* data_;
size_t size_;
uint32_t restart_offset_; // Offset in data_ of restart array
bool owned_; // Block owns data_[]
// No copying allowed
Block(const Block&);
void operator=(const Block&);
class Iter;
};
} // namespace leveldb
#endif // STORAGE_LEVELDB_TABLE_BLOCK_H_
| {
"pile_set_name": "Github"
} |
// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
void defargs() {
auto l1 = [](int i, int j = 17, int k = 18) { return i + j + k; };
int i1 = l1(1);
int i2 = l1(1, 2);
int i3 = l1(1, 2, 3);
}
void defargs_errors() {
auto l1 = [](int i,
int j = 17,
int k) { }; // expected-error{{missing default argument on parameter 'k'}}
auto l2 = [](int i, int j = i) {}; // expected-error{{default argument references parameter 'i'}}
int foo;
auto l3 = [](int i = foo) {}; // expected-error{{default argument references local variable 'foo' of enclosing function}}
}
struct NonPOD {
NonPOD();
NonPOD(const NonPOD&);
~NonPOD();
};
struct NoDefaultCtor {
NoDefaultCtor(const NoDefaultCtor&); // expected-note{{candidate constructor}} \
// expected-note{{candidate constructor not viable: requires 1 argument, but 0 were provided}}
~NoDefaultCtor();
};
template<typename T>
void defargs_in_template_unused(T t) {
auto l1 = [](const T& value = T()) { }; // expected-error{{no matching constructor for initialization of 'NoDefaultCtor'}}
l1(t);
}
template void defargs_in_template_unused(NonPOD);
template void defargs_in_template_unused(NoDefaultCtor); // expected-note{{in instantiation of function template specialization 'defargs_in_template_unused<NoDefaultCtor>' requested here}}
template<typename T>
void defargs_in_template_used() {
auto l1 = [](const T& value = T()) { }; // expected-error{{no matching constructor for initialization of 'NoDefaultCtor'}} \
// expected-note{{candidate function not viable: requires single argument 'value', but no arguments were provided}} \
// expected-note{{conversion candidate of type 'void (*)(const NoDefaultCtor &)'}}
l1(); // expected-error{{no matching function for call to object of type '(lambda at }}
}
template void defargs_in_template_used<NonPOD>();
template void defargs_in_template_used<NoDefaultCtor>(); // expected-note{{in instantiation of function template specialization}}
| {
"pile_set_name": "Github"
} |
/* #line 1 "./ragel/tsip_parser_header_Dummy.rl" */
/*
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO 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.
*
* DOUBANGO 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 DOUBANGO.
*
*/
/**@file tsip_header_Dummy.c
* @brief SIP DUmmy header.
*
* @author Mamadou Diop <diopmamadou(at)doubango[dot]org>
*
*/
#include "tinysip/headers/tsip_header_Dummy.h"
#include "tinysip/parsers/tsip_parser_uri.h"
#include "tsk_debug.h"
#include "tsk_memory.h"
#include <string.h>
/***********************************
* Ragel state machine.
*/
/* #line 70 "./ragel/tsip_parser_header_Dummy.rl" */
tsip_header_Dummy_t* tsip_header_Dummy_create(const char* name, const char* value)
{
return tsk_object_new(TSIP_HEADER_DUMMY_VA_ARGS(name, value));
}
tsip_header_Dummy_t* tsip_header_Dummy_create_null()
{
return tsip_header_Dummy_create(tsk_null, tsk_null);
}
int tsip_header_Dummy_serialize(const tsip_header_t* header, tsk_buffer_t* output)
{
if(header) {
const tsip_header_Dummy_t *Dummy = (const tsip_header_Dummy_t *)header;
if(Dummy->value) {
tsk_buffer_append(output, Dummy->value, tsk_strlen(Dummy->value));
}
return 0;
}
return -1;
}
tsip_header_Dummy_t *tsip_header_Dummy_parse(const char *data, tsk_size_t size)
{
int cs = 0;
const char *p = data;
const char *pe = p + size;
const char *eof = pe;
tsip_header_Dummy_t *hdr_Dummy = tsip_header_Dummy_create_null();
const char *tag_start = tsk_null;
/* #line 85 "./src/headers/tsip_header_Dummy.c" */
static const char _tsip_machine_parser_header_Dummy_actions[] = {
0, 1, 0, 1, 1, 1, 2, 1,
3, 2, 0, 2
};
static const char _tsip_machine_parser_header_Dummy_key_offsets[] = {
0, 0, 14, 31, 34, 37, 38, 39,
40, 42, 45
};
static const char _tsip_machine_parser_header_Dummy_trans_keys[] = {
33, 37, 39, 126, 42, 43, 45, 46,
48, 57, 65, 90, 95, 122, 9, 32,
33, 37, 39, 58, 126, 42, 43, 45,
46, 48, 57, 65, 90, 95, 122, 9,
32, 58, 9, 13, 32, 13, 10, 10,
9, 32, 9, 13, 32, 0
};
static const char _tsip_machine_parser_header_Dummy_single_lengths[] = {
0, 4, 7, 3, 3, 1, 1, 1,
2, 3, 0
};
static const char _tsip_machine_parser_header_Dummy_range_lengths[] = {
0, 5, 5, 0, 0, 0, 0, 0,
0, 0, 0
};
static const char _tsip_machine_parser_header_Dummy_index_offsets[] = {
0, 0, 10, 23, 27, 31, 33, 35,
37, 40, 44
};
static const char _tsip_machine_parser_header_Dummy_indicies[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 2, 2, 3, 3, 3, 4,
3, 3, 3, 3, 3, 3, 1, 5,
5, 6, 1, 6, 8, 6, 7, 10,
9, 11, 1, 12, 1, 13, 13, 1,
13, 14, 13, 7, 1, 0
};
static const char _tsip_machine_parser_header_Dummy_trans_targs[] = {
2, 0, 3, 2, 4, 3, 4, 5,
7, 5, 6, 10, 8, 9, 6
};
static const char _tsip_machine_parser_header_Dummy_trans_actions[] = {
1, 0, 3, 0, 3, 0, 0, 1,
0, 0, 5, 7, 0, 0, 9
};
static const int tsip_machine_parser_header_Dummy_start = 1;
static const int tsip_machine_parser_header_Dummy_first_final = 10;
static const int tsip_machine_parser_header_Dummy_error = 0;
static const int tsip_machine_parser_header_Dummy_en_main = 1;
/* #line 106 "./ragel/tsip_parser_header_Dummy.rl" */
(void)(eof);
(void)(tsip_machine_parser_header_Dummy_first_final);
(void)(tsip_machine_parser_header_Dummy_error);
(void)(tsip_machine_parser_header_Dummy_en_main);
/* #line 152 "./src/headers/tsip_header_Dummy.c" */
{
cs = tsip_machine_parser_header_Dummy_start;
}
/* #line 111 "./ragel/tsip_parser_header_Dummy.rl" */
/* #line 159 "./src/headers/tsip_header_Dummy.c" */
{
int _klen;
unsigned int _trans;
const char *_acts;
unsigned int _nacts;
const char *_keys;
if ( p == pe ) {
goto _test_eof;
}
if ( cs == 0 ) {
goto _out;
}
_resume:
_keys = _tsip_machine_parser_header_Dummy_trans_keys + _tsip_machine_parser_header_Dummy_key_offsets[cs];
_trans = _tsip_machine_parser_header_Dummy_index_offsets[cs];
_klen = _tsip_machine_parser_header_Dummy_single_lengths[cs];
if ( _klen > 0 ) {
const char *_lower = _keys;
const char *_mid;
const char *_upper = _keys + _klen - 1;
while (1) {
if ( _upper < _lower ) {
break;
}
_mid = _lower + ((_upper-_lower) >> 1);
if ( (*p) < *_mid ) {
_upper = _mid - 1;
}
else if ( (*p) > *_mid ) {
_lower = _mid + 1;
}
else {
_trans += (_mid - _keys);
goto _match;
}
}
_keys += _klen;
_trans += _klen;
}
_klen = _tsip_machine_parser_header_Dummy_range_lengths[cs];
if ( _klen > 0 ) {
const char *_lower = _keys;
const char *_mid;
const char *_upper = _keys + (_klen<<1) - 2;
while (1) {
if ( _upper < _lower ) {
break;
}
_mid = _lower + (((_upper-_lower) >> 1) & ~1);
if ( (*p) < _mid[0] ) {
_upper = _mid - 2;
}
else if ( (*p) > _mid[1] ) {
_lower = _mid + 2;
}
else {
_trans += ((_mid - _keys)>>1);
goto _match;
}
}
_trans += _klen;
}
_match:
_trans = _tsip_machine_parser_header_Dummy_indicies[_trans];
cs = _tsip_machine_parser_header_Dummy_trans_targs[_trans];
if ( _tsip_machine_parser_header_Dummy_trans_actions[_trans] == 0 ) {
goto _again;
}
_acts = _tsip_machine_parser_header_Dummy_actions + _tsip_machine_parser_header_Dummy_trans_actions[_trans];
_nacts = (unsigned int) *_acts++;
while ( _nacts-- > 0 ) {
switch ( *_acts++ ) {
case 0:
/* #line 50 "./ragel/tsip_parser_header_Dummy.rl" */
{
tag_start = p;
}
break;
case 1:
/* #line 54 "./ragel/tsip_parser_header_Dummy.rl" */
{
TSK_PARSER_SET_STRING(hdr_Dummy->name);
}
break;
case 2:
/* #line 58 "./ragel/tsip_parser_header_Dummy.rl" */
{
TSK_PARSER_SET_STRING(hdr_Dummy->value);
}
break;
case 3:
/* #line 62 "./ragel/tsip_parser_header_Dummy.rl" */
{
}
break;
/* #line 256 "./src/headers/tsip_header_Dummy.c" */
}
}
_again:
if ( cs == 0 ) {
goto _out;
}
if ( ++p != pe ) {
goto _resume;
}
_test_eof: {
}
_out: {
}
}
/* #line 112 "./ragel/tsip_parser_header_Dummy.rl" */
if( cs <
/* #line 272 "./src/headers/tsip_header_Dummy.c" */
10
/* #line 113 "./ragel/tsip_parser_header_Dummy.rl" */
) {
TSK_DEBUG_ERROR("Failed to parse 'Dummy' header.");
TSK_OBJECT_SAFE_FREE(hdr_Dummy);
}
return hdr_Dummy;
}
//========================================================
// Dummy header object definition
//
static tsk_object_t* tsip_header_Dummy_ctor(tsk_object_t *self, va_list * app)
{
tsip_header_Dummy_t *Dummy = self;
if(Dummy) {
TSIP_HEADER(Dummy)->type = tsip_htype_Dummy;
TSIP_HEADER(Dummy)->serialize = tsip_header_Dummy_serialize;
Dummy->name = tsk_strdup(va_arg(*app, const char*));
Dummy->value = tsk_strdup(va_arg(*app, const char*));
}
else {
TSK_DEBUG_ERROR("Failed to create new Dummy header.");
}
return self;
}
static tsk_object_t* tsip_header_Dummy_dtor(tsk_object_t *self)
{
tsip_header_Dummy_t *Dummy = self;
if(Dummy) {
TSK_FREE(Dummy->name);
TSK_FREE(Dummy->value);
TSK_OBJECT_SAFE_FREE(TSIP_HEADER_PARAMS(Dummy));
}
else {
TSK_DEBUG_ERROR("Null Dummy header.");
}
return self;
}
static const tsk_object_def_t tsip_header_Dummy_def_s = {
sizeof(tsip_header_Dummy_t),
tsip_header_Dummy_ctor,
tsip_header_Dummy_dtor,
tsk_null
};
const tsk_object_def_t *tsip_header_Dummy_def_t = &tsip_header_Dummy_def_s;
| {
"pile_set_name": "Github"
} |
<?xml version="1.0" encoding="utf-8"?>
<com.hyphenate.easeui.widget.emojicon.EaseEmojiconMenu xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/emojicon"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
| {
"pile_set_name": "Github"
} |
package snake
import "testing"
func newDoubleSnake(d direction) *snake {
return newSnake(d, []coord{
coord{x: 1, y: 0},
coord{x: 1, y: 1},
coord{x: 1, y: 2},
coord{x: 1, y: 3},
coord{x: 1, y: 4},
})
}
func TestSnakeBodyMove(t *testing.T) {
snake := newDoubleSnake(RIGHT)
snake.move()
if snake.body[0].x != 1 || snake.body[0].y != 1 {
t.Fatalf("Invalid body position %x", snake.body[0])
}
if snake.body[1].x != 1 || snake.body[1].y != 2 {
t.Fatalf("Invalid body position %x", snake.body[1])
}
if snake.body[2].x != 1 || snake.body[2].y != 3 {
t.Fatalf("Invalid body position %x", snake.body[2])
}
if snake.body[3].x != 1 || snake.body[3].y != 4 {
t.Fatalf("Invalid body position %x", snake.body[3])
}
if snake.body[4].x != 2 || snake.body[4].y != 4 {
t.Fatalf("Invalid body position %x", snake.body[4])
}
}
func TestSnakeHeadMoveRight(t *testing.T) {
snake := newDoubleSnake(RIGHT)
snake.move()
if snake.head().x != 2 || snake.head().y != 4 {
t.Fatalf("Expected head to have moved to position [2 4], got %x", snake.head())
}
}
func TestSnakeHeadMoveUp(t *testing.T) {
snake := newDoubleSnake(UP)
snake.move()
if snake.head().x != 1 || snake.head().y != 5 {
t.Fatalf("Expected head to have moved to position [1 5], got %x", snake.head())
}
}
func TestSnakeHeadMoveDown(t *testing.T) {
snake := newDoubleSnake(RIGHT)
snake.move()
snake.changeDirection(DOWN)
snake.move()
if snake.head().x != 2 || snake.head().y != 3 {
t.Fatalf("Expected head to have moved to position [2 3], got %x", snake.head())
}
}
func TestSnakeHeadMoveLeft(t *testing.T) {
snake := newDoubleSnake(LEFT)
snake.move()
if snake.head().x != 0 || snake.head().y != 4 {
t.Fatalf("Expected head to have moved to position [0 4], got %x", snake.head())
}
}
func TestChangeDirectionToNotOposity(t *testing.T) {
snake := newDoubleSnake(DOWN)
snake.changeDirection(RIGHT)
if snake.direction != RIGHT {
t.Fatal("Expected to change Snake Direction to DOWN")
}
}
func TestChangeDirectionToOposity(t *testing.T) {
snake := newDoubleSnake(RIGHT)
snake.changeDirection(LEFT)
if snake.direction == LEFT {
t.Fatal("Expected not to have changed Snake Direction to LEFT")
}
}
func TestChangeDirectionToInvalidDirection(t *testing.T) {
snake := newDoubleSnake(RIGHT)
snake.changeDirection(5)
if snake.direction != RIGHT {
t.Fatal("Expected not to have changed Snake Direction")
}
}
func TestSnakeDie(t *testing.T) {
snake := newDoubleSnake(RIGHT)
if err := snake.die(); err.Error() != "Died" {
t.Fatal("Expected Snake die() to return error")
}
}
func TestSnakeDieWhenMoveOnTopOfItself(t *testing.T) {
snake := newDoubleSnake(RIGHT)
snake.move()
snake.changeDirection(DOWN)
snake.move()
snake.changeDirection(LEFT)
if err := snake.die(); err.Error() != "Died" {
t.Fatal("Expected Snake to die when moved on top of itself")
}
}
| {
"pile_set_name": "Github"
} |
# Reorder List
## Question
- leetcode: [Reorder List | LeetCode OJ](https://leetcode.com/problems/reorder-list/)
- lintcode: [(99) Reorder List](http://www.lintcode.com/en/problem/reorder-list/)
### Problem Statement
Given a singly linked list _L_: _L_0→_L_1→…→_L__n_-1→_L_n,
reorder it to: _L_0→_L__n_→_L_1→_L__n_-1→_L_2→_L__n_-2→…
You must do this in-place without altering the nodes' values.
For example,
Given `{1,2,3,4}`, reorder it to `{1,4,2,3}`.
### 题解1 - 链表长度(TLE) <i class="fa fa-thumbs-o-down"></i>
直观角度来考虑,如果把链表视为数组来处理,那么我们要做的就是依次将下标之和为`n`的两个节点链接到一块儿,使用两个索引即可解决问题,一个索引指向`i`, 另一个索引则指向其之后的第`n - 2*i`个节点(对于链表来说实际上需要获取的是其前一个节点), 直至第一个索引大于第二个索引为止即处理完毕。
既然依赖链表长度信息,那么要做的第一件事就是遍历当前链表获得其长度喽。获得长度后即对链表进行遍历,小心处理链表节点的断开及链接。用这种方法会提示 TLE,也就是说还存在较大的优化空间!
### C++ - TLE
```c++
/**
* Definition of ListNode
* class ListNode {
* public:
* int val;
* ListNode *next;
* ListNode(int val) {
* this->val = val;
* this->next = NULL;
* }
* }
*/
class Solution {
public:
/**
* @param head: The first node of linked list.
* @return: void
*/
void reorderList(ListNode *head) {
if (NULL == head || NULL == head->next || NULL == head->next->next) {
return;
}
ListNode *last = head;
int length = 0;
while (NULL != last) {
last = last->next;
++length;
}
last = head;
for (int i = 1; i < length - i; ++i) {
ListNode *beforeTail = last;
for (int j = i; j < length - i; ++j) {
beforeTail = beforeTail->next;
}
ListNode *temp = last->next;
last->next = beforeTail->next;
last->next->next = temp;
beforeTail->next = NULL;
last = temp;
}
}
};
```
### 源码分析
1. 异常处理,对于节点数目在两个以内的无需处理。
2. 遍历求得链表长度。
3. 遍历链表,第一个索引处的节点使用`last`表示,第二个索引处的节点的前一个节点使用`beforeTail`表示。
4. 处理链表的链接与断开,迭代处理下一个`last`。
### 复杂度分析
1. 遍历整个链表获得其长度,时间复杂度为 $$O(n)$$.
2. 双重`for`循环的时间复杂度为 $$(n-2) + (n-4) + ... + 2 = O(\frac{1}{2} \cdot n^2)$$.
3. 总的时间复杂度可近似认为是 $$O(n^2)$$, 空间复杂度为常数。
> **Warning** 使用这种方法务必注意`i`和`j`的终止条件,若取`i < length + 1 - i`, 则在处理最后两个节点时会出现环,且尾节点会被删掉。在对节点进行遍历时务必注意保留头节点的信息!
## 题解2 - 反转链表后归并
既然题解1存在较大的优化空间,那我们该从哪一点出发进行优化呢?擒贼先擒王,题解1中时间复杂度最高的地方在于双重`for`循环,在对第二个索引进行遍历时,`j`每次都从`i`处开始遍历,要是`j`能从链表尾部往前遍历该有多好啊!这样就能大大降低时间复杂度了,可惜本题的链表只是单向链表... 有什么特技可以在单向链表中进行反向遍历吗?还真有——反转链表!一语惊醒梦中人。
### C++
```c++
/**
* Definition of ListNode
* class ListNode {
* public:
* int val;
* ListNode *next;
* ListNode(int val) {
* this->val = val;
* this->next = NULL;
* }
* }
*/
class Solution {
public:
/**
* @param head: The first node of linked list.
* @return: void
*/
void reorderList(ListNode *head) {
if (head == NULL || head->next == NULL) return;
// find middle
ListNode *slow = head, *fast = head->next;
while (fast != NULL && fast->next != NULL) {
slow = slow->next;
fast = fast->next->next;
}
ListNode *rHead = slow->next;
slow->next = NULL;
// reverse ListNode on the right side
ListNode *prev = NULL;
while (rHead != NULL) {
ListNode *temp = rHead->next;
rHead->next = prev;
prev = rHead;
rHead = temp;
}
// merge two list
rHead = prev;
ListNode *lHead = head;
while (lHead != NULL && rHead != NULL) {
ListNode *temp1 = lHead->next;
lHead->next = rHead;
ListNode *temp2 = rHead->next;
rHead->next = temp1;
lHead = temp1;
rHead = temp2;
}
}
};
```
### Java
```java
/**
* Definition for ListNode.
* public class ListNode {
* int val;
* ListNode next;
* ListNode(int val) {
* this.val = val;
* this.next = null;
* }
* }
*/
public class Solution {
/**
* @param head: The head of linked list.
* @return: void
*/
public void reorderList(ListNode head) {
if (head == null || head.next == null) return;
// find middle
ListNode slow = head, fast = head.next;
while (fast != null && fast.next != null) {
slow = slow.next;
fast = fast.next.next;
}
ListNode rHead = slow.next;
slow.next = null;
// reverse ListNode on the right side
ListNode prev = null;
while (rHead != null) {
ListNode temp = rHead.next;
rHead.next = prev;
prev = rHead;
rHead = temp;
}
// merge two list
rHead = prev;
ListNode lHead = head;
while (lHead != null && rHead != null) {
ListNode temp1 = lHead.next;
lHead.next = rHead;
rHead = rHead.next;
lHead.next.next = temp1;
lHead = temp1;
}
}
}
```
### 源码分析
相对于题解1,题解2更多地利用了链表的常用操作如反转、找中点、合并。
1. 找中点:我在九章算法模板的基础上增加了对`head->next`的异常检测,增强了鲁棒性。
2. 反转:非常精炼的模板,记牢!
3. 合并:也可使用九章提供的模板,思想是一样的,需要注意`left`, `right`和`dummy`三者的赋值顺序,不能更改任何一步。
### 复杂度分析
找中点一次,时间复杂度近似为 $$O(n)$$. 反转链表一次,时间复杂度近似为 $$O(n/2)$$. 合并左右链表一次,时间复杂度近似为 $$O(n/2)$$. 故总的时间复杂度为 $$O(n)$$.
## Reference
- [Reorder List | 九章算法](http://www.jiuzhang.com/solutions/reorder-list/)
| {
"pile_set_name": "Github"
} |
public import libc.generated.*;
| {
"pile_set_name": "Github"
} |
function visualizeBoundaryLinear(X, y, model)
%VISUALIZEBOUNDARYLINEAR plots a linear decision boundary learned by the
%SVM
% VISUALIZEBOUNDARYLINEAR(X, y, model) plots a linear decision boundary
% learned by the SVM and overlays the data on it
w = model.w;
b = model.b;
xp = linspace(min(X(:,1)), max(X(:,1)), 100);
yp = - (w(1)*xp + b)/w(2);
plotData(X, y);
hold on;
plot(xp, yp, '-b');
hold off
end
| {
"pile_set_name": "Github"
} |
/*
Copyright 2016 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.
*/
package fake
import (
authorizationapi "k8s.io/api/authorization/v1beta1"
core "k8s.io/client-go/testing"
)
func (c *FakeSelfSubjectAccessReviews) Create(sar *authorizationapi.SelfSubjectAccessReview) (result *authorizationapi.SelfSubjectAccessReview, err error) {
obj, err := c.Fake.Invokes(core.NewRootCreateAction(authorizationapi.SchemeGroupVersion.WithResource("selfsubjectaccessreviews"), sar), &authorizationapi.SelfSubjectAccessReview{})
return obj.(*authorizationapi.SelfSubjectAccessReview), err
}
| {
"pile_set_name": "Github"
} |
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_BASE_UI_BASE_EXPORT_H_
#define UI_BASE_UI_BASE_EXPORT_H_
// Defines UI_BASE_EXPORT so that functionality implemented by the UI module
// can be exported to consumers.
#if defined(COMPONENT_BUILD)
#if defined(WIN32)
#if defined(UI_BASE_IMPLEMENTATION)
#define UI_BASE_EXPORT __declspec(dllexport)
#else
#define UI_BASE_EXPORT __declspec(dllimport)
#endif
#else // !defined(WIN32)
#if defined(UI_BASE_IMPLEMENTATION)
#define UI_BASE_EXPORT __attribute__((visibility("default")))
#else
#define UI_BASE_EXPORT
#endif
#endif
#else // !defined(COMPONENT_BUILD)
#define UI_BASE_EXPORT
#endif
#endif // UI_BASE_UI_BASE_EXPORT_H_
| {
"pile_set_name": "Github"
} |
/*
* Copyright (C) 2011 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "QuotedPrintable.h"
#include <wtf/ASCIICType.h>
namespace WebCore {
static const size_t maximumLineLength = 76;
static const char crlfLineEnding[] = "\r\n";
static size_t lengthOfLineEndingAtIndex(const char* input, size_t inputLength, size_t index)
{
ASSERT(index < inputLength);
if (input[index] == '\n')
return 1; // Single LF.
if (input[index] == '\r') {
if ((index + 1) == inputLength || input[index + 1] != '\n')
return 1; // Single CR (Classic Mac OS).
return 2; // CR-LF.
}
return 0;
}
void quotedPrintableEncode(const Vector<char>& in, Vector<char>& out)
{
quotedPrintableEncode(in.data(), in.size(), out);
}
void quotedPrintableEncode(const char* input, size_t inputLength, Vector<char>& out)
{
out.clear();
out.reserveCapacity(inputLength);
size_t currentLineLength = 0;
for (size_t i = 0; i < inputLength; ++i) {
bool isLastCharacter = (i == inputLength - 1);
char currentCharacter = input[i];
bool requiresEncoding = false;
// All non-printable ASCII characters and = require encoding.
if ((currentCharacter < ' ' || currentCharacter > '~' || currentCharacter == '=') && currentCharacter != '\t')
requiresEncoding = true;
// Space and tab characters have to be encoded if they appear at the end of a line.
if (!requiresEncoding && (currentCharacter == '\t' || currentCharacter == ' ') && (isLastCharacter || lengthOfLineEndingAtIndex(input, inputLength, i + 1)))
requiresEncoding = true;
// End of line should be converted to CR-LF sequences.
if (!isLastCharacter) {
size_t lengthOfLineEnding = lengthOfLineEndingAtIndex(input, inputLength, i);
if (lengthOfLineEnding) {
out.append(crlfLineEnding, strlen(crlfLineEnding));
currentLineLength = 0;
i += (lengthOfLineEnding - 1); // -1 because we'll ++ in the for() above.
continue;
}
}
size_t lengthOfEncodedCharacter = 1;
if (requiresEncoding)
lengthOfEncodedCharacter += 2;
if (!isLastCharacter)
lengthOfEncodedCharacter += 1; // + 1 for the = (soft line break).
// Insert a soft line break if necessary.
if (currentLineLength + lengthOfEncodedCharacter > maximumLineLength) {
out.append('=');
out.append(crlfLineEnding, strlen(crlfLineEnding));
currentLineLength = 0;
}
// Finally, insert the actual character(s).
if (requiresEncoding) {
out.append('=');
out.append(upperNibbleToASCIIHexDigit(currentCharacter));
out.append(lowerNibbleToASCIIHexDigit(currentCharacter));
currentLineLength += 3;
} else {
out.append(currentCharacter);
currentLineLength++;
}
}
}
void quotedPrintableDecode(const Vector<char>& in, Vector<char>& out)
{
quotedPrintableDecode(in.data(), in.size(), out);
}
void quotedPrintableDecode(const char* data, size_t dataLength, Vector<char>& out)
{
out.clear();
if (!dataLength)
return;
for (size_t i = 0; i < dataLength; ++i) {
char currentCharacter = data[i];
if (currentCharacter != '=') {
out.append(currentCharacter);
continue;
}
// We are dealing with a '=xx' sequence.
if (dataLength - i < 3) {
// Unfinished = sequence, append as is.
out.append(currentCharacter);
continue;
}
char upperCharacter = data[++i];
char lowerCharacter = data[++i];
if (upperCharacter == '\r' && lowerCharacter == '\n')
continue;
if (!isASCIIHexDigit(upperCharacter) || !isASCIIHexDigit(lowerCharacter)) {
// Invalid sequence, = followed by non hex digits, just insert the characters as is.
out.append('=');
out.append(upperCharacter);
out.append(lowerCharacter);
continue;
}
out.append(static_cast<char>(toASCIIHexValue(upperCharacter, lowerCharacter)));
}
}
}
| {
"pile_set_name": "Github"
} |
it('should show correct pluralized string', function() {
var withoutOffset = element.all(by.css('ng-pluralize')).get(0);
var withOffset = element.all(by.css('ng-pluralize')).get(1);
var countInput = element(by.model('personCount'));
expect(withoutOffset.getText()).toEqual('1 person is viewing.');
expect(withOffset.getText()).toEqual('Igor is viewing.');
countInput.clear();
countInput.sendKeys('0');
expect(withoutOffset.getText()).toEqual('Nobody is viewing.');
expect(withOffset.getText()).toEqual('Nobody is viewing.');
countInput.clear();
countInput.sendKeys('2');
expect(withoutOffset.getText()).toEqual('2 people are viewing.');
expect(withOffset.getText()).toEqual('Igor and Misko are viewing.');
countInput.clear();
countInput.sendKeys('3');
expect(withoutOffset.getText()).toEqual('3 people are viewing.');
expect(withOffset.getText()).toEqual('Igor, Misko and one other person are viewing.');
countInput.clear();
countInput.sendKeys('4');
expect(withoutOffset.getText()).toEqual('4 people are viewing.');
expect(withOffset.getText()).toEqual('Igor, Misko and 2 other people are viewing.');
});
it('should show data-bound names', function() {
var withOffset = element.all(by.css('ng-pluralize')).get(1);
var personCount = element(by.model('personCount'));
var person1 = element(by.model('person1'));
var person2 = element(by.model('person2'));
personCount.clear();
personCount.sendKeys('4');
person1.clear();
person1.sendKeys('Di');
person2.clear();
person2.sendKeys('Vojta');
expect(withOffset.getText()).toEqual('Di, Vojta and 2 other people are viewing.');
}); | {
"pile_set_name": "Github"
} |
class Showcase < ActiveRecord::Base
has_many :showcase_entries
scope :active, -> { where(ended_at: nil) }
def add!(product)
ShowcaseEntry.find_or_create_by!(showcase: self, product: product)
end
end
| {
"pile_set_name": "Github"
} |
require "socket"
# goes with tcp_server.cr
socket = TCPSocket.new "127.0.0.1", 9000
10.times do |i|
socket.puts i
puts "Server response: #{socket.gets}"
sleep 0.5
end
| {
"pile_set_name": "Github"
} |
module VagrantPlugins
module GuestWindows
module Cap
class FileSystem
# Create a temporary file or directory on the guest
#
# @param [Vagrant::Machine] machine Vagrant guest machine
# @param [Hash] opts Path options
# @return [String] path to temporary file or directory
def self.create_tmp_path(machine, opts)
comm = machine.communicate
path = ""
cmd = "Write-Output ([System.IO.Path]::Combine([System.IO.Path]::GetTempPath(), " \
"[System.IO.Path]::GetRandomFileName())) | Out-String -Width 2048"
comm.execute(cmd, shell: :powershell) do |type, data|
if type == :stdout
path << data
end
end
path.strip!
if opts[:extension]
path << opts[:extension].to_s
end
if opts[:type] == :directory
comm.execute("[System.IO.Directory]::CreateDirectory('#{path}')")
end
path
end
# Decompress zip file on guest to given location
#
# @param [Vagrant::Machine] machine Vagrant guest machine
# @param [String] compressed_file Path to compressed file on guest
# @param [String] destination Path for decompressed files on guest
def self.decompress_zip(machine, compressed_file, destination, opts={})
comm = machine.communicate
extract_dir = create_tmp_path(machine, type: :directory)
cmds = []
destination = destination.tr("/", "\\")
if opts[:type] == :directory
cmds << "New-Item -ItemType Directory -Force -Path \"#{destination}\""
else
d_parts = destination.split("\\")
d_parts.pop
parent_dir = d_parts.join("\\") + "\\"
cmds << "New-Item -ItemType Directory -Force -Path \"#{parent_dir}\""
end
cmd = "$f = \"#{compressed_file}\"; $d = \"#{extract_dir}\"; "
cmd << '$s = New-Object -ComObject "Shell.Application"; $z = $s.NameSpace($f); '
cmd << 'foreach($i in $z.items()){ $s.Namespace($d).copyhere($i); }'
cmds << cmd
cmds += [
"Move-Item -Force -Path \"#{extract_dir}\\*\" -Destination \"#{destination}\\\"",
"Remove-Item -Path \"#{compressed_file}\" -Force",
"Remove-Item -Path \"#{extract_dir}\" -Recurse -Force"
]
cmds.each do |cmd|
comm.execute(cmd, shell: :powershell)
end
true
end
end
end
end
end
| {
"pile_set_name": "Github"
} |
#ifndef BOOST_SERIALIZATION_UNORDERED_SET_HPP
#define BOOST_SERIALIZATION_UNORDERED_SET_HPP
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// unordered_set.hpp: serialization for stl unordered_set templates
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// (C) Copyright 2014 Jim Bell
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#include <boost/config.hpp>
#include <unordered_set>
#include <boost/serialization/unordered_collections_save_imp.hpp>
#include <boost/serialization/unordered_collections_load_imp.hpp>
#include <boost/serialization/archive_input_unordered_set.hpp>
#include <boost/serialization/split_free.hpp>
namespace boost {
namespace serialization {
template<
class Archive,
class Key,
class HashFcn,
class EqualKey,
class Allocator
>
inline void save(
Archive & ar,
const std::unordered_set<
Key, HashFcn, EqualKey, Allocator
> &t,
const unsigned int /*file_version*/
){
boost::serialization::stl::save_unordered_collection<
Archive,
std::unordered_set<Key, HashFcn, EqualKey, Allocator>
>(ar, t);
}
template<
class Archive,
class Key,
class HashFcn,
class EqualKey,
class Allocator
>
inline void load(
Archive & ar,
std::unordered_set<
Key, HashFcn, EqualKey, Allocator
> &t,
const unsigned int /*file_version*/
){
boost::serialization::stl::load_unordered_collection<
Archive,
std::unordered_set<Key, HashFcn, EqualKey, Allocator>,
stl::archive_input_unordered_set<
Archive,
std::unordered_set<
Key, HashFcn, EqualKey, Allocator
>
>
>(ar, t);
}
// split non-intrusive serialization function member into separate
// non intrusive save/load member functions
template<
class Archive,
class Key,
class HashFcn,
class EqualKey,
class Allocator
>
inline void serialize(
Archive & ar,
std::unordered_set<
Key, HashFcn, EqualKey, Allocator
> &t,
const unsigned int file_version
){
split_free(ar, t, file_version);
}
// unordered_multiset
template<
class Archive,
class Key,
class HashFcn,
class EqualKey,
class Allocator
>
inline void save(
Archive & ar,
const std::unordered_multiset<
Key, HashFcn, EqualKey, Allocator
> &t,
const unsigned int /*file_version*/
){
stl::save_unordered_collection<
Archive,
std::unordered_multiset<Key, HashFcn, EqualKey, Allocator>
>(ar, t);
}
template<
class Archive,
class Key,
class HashFcn,
class EqualKey,
class Allocator
>
inline void load(
Archive & ar,
std::unordered_multiset<
Key, HashFcn, EqualKey, Allocator
> &t,
const unsigned int /*file_version*/
){
boost::serialization::stl::load_unordered_collection<
Archive,
std::unordered_multiset<Key, HashFcn, EqualKey, Allocator>,
boost::serialization::stl::archive_input_unordered_multiset<
Archive,
std::unordered_multiset<Key, HashFcn, EqualKey, Allocator>
>
>(ar, t);
}
// split non-intrusive serialization function member into separate
// non intrusive save/load member functions
template<
class Archive,
class Key,
class HashFcn,
class EqualKey,
class Allocator
>
inline void serialize(
Archive & ar,
std::unordered_multiset<Key, HashFcn, EqualKey, Allocator> &t,
const unsigned int file_version
){
boost::serialization::split_free(ar, t, file_version);
}
} // namespace serialization
} // namespace boost
#endif // BOOST_SERIALIZATION_UNORDERED_SET_HPP
| {
"pile_set_name": "Github"
} |
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\IpMessaging\V1\Service;
use Twilio\Exceptions\TwilioException;
use Twilio\InstanceContext;
use Twilio\ListResource;
use Twilio\Options;
use Twilio\Rest\IpMessaging\V1\Service\Channel\InviteList;
use Twilio\Rest\IpMessaging\V1\Service\Channel\MemberList;
use Twilio\Rest\IpMessaging\V1\Service\Channel\MessageList;
use Twilio\Values;
use Twilio\Version;
/**
* @property MemberList $members
* @property MessageList $messages
* @property InviteList $invites
* @method \Twilio\Rest\IpMessaging\V1\Service\Channel\MemberContext members(string $sid)
* @method \Twilio\Rest\IpMessaging\V1\Service\Channel\MessageContext messages(string $sid)
* @method \Twilio\Rest\IpMessaging\V1\Service\Channel\InviteContext invites(string $sid)
*/
class ChannelContext extends InstanceContext {
protected $_members;
protected $_messages;
protected $_invites;
/**
* Initialize the ChannelContext
*
* @param Version $version Version that contains the resource
* @param string $serviceSid The SID of the Service to fetch the resource from
* @param string $sid The unique string that identifies the resource
*/
public function __construct(Version $version, $serviceSid, $sid) {
parent::__construct($version);
// Path Solution
$this->solution = ['serviceSid' => $serviceSid, 'sid' => $sid, ];
$this->uri = '/Services/' . \rawurlencode($serviceSid) . '/Channels/' . \rawurlencode($sid) . '';
}
/**
* Fetch the ChannelInstance
*
* @return ChannelInstance Fetched ChannelInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function fetch(): ChannelInstance {
$payload = $this->version->fetch('GET', $this->uri);
return new ChannelInstance(
$this->version,
$payload,
$this->solution['serviceSid'],
$this->solution['sid']
);
}
/**
* Delete the ChannelInstance
*
* @return bool True if delete succeeds, false otherwise
* @throws TwilioException When an HTTP error occurs.
*/
public function delete(): bool {
return $this->version->delete('DELETE', $this->uri);
}
/**
* Update the ChannelInstance
*
* @param array|Options $options Optional Arguments
* @return ChannelInstance Updated ChannelInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function update(array $options = []): ChannelInstance {
$options = new Values($options);
$data = Values::of([
'FriendlyName' => $options['friendlyName'],
'UniqueName' => $options['uniqueName'],
'Attributes' => $options['attributes'],
]);
$payload = $this->version->update('POST', $this->uri, [], $data);
return new ChannelInstance(
$this->version,
$payload,
$this->solution['serviceSid'],
$this->solution['sid']
);
}
/**
* Access the members
*/
protected function getMembers(): MemberList {
if (!$this->_members) {
$this->_members = new MemberList(
$this->version,
$this->solution['serviceSid'],
$this->solution['sid']
);
}
return $this->_members;
}
/**
* Access the messages
*/
protected function getMessages(): MessageList {
if (!$this->_messages) {
$this->_messages = new MessageList(
$this->version,
$this->solution['serviceSid'],
$this->solution['sid']
);
}
return $this->_messages;
}
/**
* Access the invites
*/
protected function getInvites(): InviteList {
if (!$this->_invites) {
$this->_invites = new InviteList(
$this->version,
$this->solution['serviceSid'],
$this->solution['sid']
);
}
return $this->_invites;
}
/**
* Magic getter to lazy load subresources
*
* @param string $name Subresource to return
* @return ListResource The requested subresource
* @throws TwilioException For unknown subresources
*/
public function __get(string $name): ListResource {
if (\property_exists($this, '_' . $name)) {
$method = 'get' . \ucfirst($name);
return $this->$method();
}
throw new TwilioException('Unknown subresource ' . $name);
}
/**
* Magic caller to get resource contexts
*
* @param string $name Resource to return
* @param array $arguments Context parameters
* @return InstanceContext The requested resource context
* @throws TwilioException For unknown resource
*/
public function __call(string $name, array $arguments): InstanceContext {
$property = $this->$name;
if (\method_exists($property, 'getContext')) {
return \call_user_func_array(array($property, 'getContext'), $arguments);
}
throw new TwilioException('Resource does not have a context');
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
$context = [];
foreach ($this->solution as $key => $value) {
$context[] = "$key=$value";
}
return '[Twilio.IpMessaging.V1.ChannelContext ' . \implode(' ', $context) . ']';
}
} | {
"pile_set_name": "Github"
} |
// mkerrors.sh -Wall -Werror -static -I/tmp/include -m64
// Code generated by the command above; see README.md. DO NOT EDIT.
// +build amd64,linux
// Created by cgo -godefs - DO NOT EDIT
// cgo -godefs -- -Wall -Werror -static -I/tmp/include -m64 _const.go
package unix
import "syscall"
const (
AF_ALG = 0x26
AF_APPLETALK = 0x5
AF_ASH = 0x12
AF_ATMPVC = 0x8
AF_ATMSVC = 0x14
AF_AX25 = 0x3
AF_BLUETOOTH = 0x1f
AF_BRIDGE = 0x7
AF_CAIF = 0x25
AF_CAN = 0x1d
AF_DECnet = 0xc
AF_ECONET = 0x13
AF_FILE = 0x1
AF_IB = 0x1b
AF_IEEE802154 = 0x24
AF_INET = 0x2
AF_INET6 = 0xa
AF_IPX = 0x4
AF_IRDA = 0x17
AF_ISDN = 0x22
AF_IUCV = 0x20
AF_KCM = 0x29
AF_KEY = 0xf
AF_LLC = 0x1a
AF_LOCAL = 0x1
AF_MAX = 0x2c
AF_MPLS = 0x1c
AF_NETBEUI = 0xd
AF_NETLINK = 0x10
AF_NETROM = 0x6
AF_NFC = 0x27
AF_PACKET = 0x11
AF_PHONET = 0x23
AF_PPPOX = 0x18
AF_QIPCRTR = 0x2a
AF_RDS = 0x15
AF_ROSE = 0xb
AF_ROUTE = 0x10
AF_RXRPC = 0x21
AF_SECURITY = 0xe
AF_SMC = 0x2b
AF_SNA = 0x16
AF_TIPC = 0x1e
AF_UNIX = 0x1
AF_UNSPEC = 0x0
AF_VSOCK = 0x28
AF_WANPIPE = 0x19
AF_X25 = 0x9
ALG_OP_DECRYPT = 0x0
ALG_OP_ENCRYPT = 0x1
ALG_SET_AEAD_ASSOCLEN = 0x4
ALG_SET_AEAD_AUTHSIZE = 0x5
ALG_SET_IV = 0x2
ALG_SET_KEY = 0x1
ALG_SET_OP = 0x3
ARPHRD_6LOWPAN = 0x339
ARPHRD_ADAPT = 0x108
ARPHRD_APPLETLK = 0x8
ARPHRD_ARCNET = 0x7
ARPHRD_ASH = 0x30d
ARPHRD_ATM = 0x13
ARPHRD_AX25 = 0x3
ARPHRD_BIF = 0x307
ARPHRD_CAIF = 0x336
ARPHRD_CAN = 0x118
ARPHRD_CHAOS = 0x5
ARPHRD_CISCO = 0x201
ARPHRD_CSLIP = 0x101
ARPHRD_CSLIP6 = 0x103
ARPHRD_DDCMP = 0x205
ARPHRD_DLCI = 0xf
ARPHRD_ECONET = 0x30e
ARPHRD_EETHER = 0x2
ARPHRD_ETHER = 0x1
ARPHRD_EUI64 = 0x1b
ARPHRD_FCAL = 0x311
ARPHRD_FCFABRIC = 0x313
ARPHRD_FCPL = 0x312
ARPHRD_FCPP = 0x310
ARPHRD_FDDI = 0x306
ARPHRD_FRAD = 0x302
ARPHRD_HDLC = 0x201
ARPHRD_HIPPI = 0x30c
ARPHRD_HWX25 = 0x110
ARPHRD_IEEE1394 = 0x18
ARPHRD_IEEE802 = 0x6
ARPHRD_IEEE80211 = 0x321
ARPHRD_IEEE80211_PRISM = 0x322
ARPHRD_IEEE80211_RADIOTAP = 0x323
ARPHRD_IEEE802154 = 0x324
ARPHRD_IEEE802154_MONITOR = 0x325
ARPHRD_IEEE802_TR = 0x320
ARPHRD_INFINIBAND = 0x20
ARPHRD_IP6GRE = 0x337
ARPHRD_IPDDP = 0x309
ARPHRD_IPGRE = 0x30a
ARPHRD_IRDA = 0x30f
ARPHRD_LAPB = 0x204
ARPHRD_LOCALTLK = 0x305
ARPHRD_LOOPBACK = 0x304
ARPHRD_METRICOM = 0x17
ARPHRD_NETLINK = 0x338
ARPHRD_NETROM = 0x0
ARPHRD_NONE = 0xfffe
ARPHRD_PHONET = 0x334
ARPHRD_PHONET_PIPE = 0x335
ARPHRD_PIMREG = 0x30b
ARPHRD_PPP = 0x200
ARPHRD_PRONET = 0x4
ARPHRD_RAWHDLC = 0x206
ARPHRD_ROSE = 0x10e
ARPHRD_RSRVD = 0x104
ARPHRD_SIT = 0x308
ARPHRD_SKIP = 0x303
ARPHRD_SLIP = 0x100
ARPHRD_SLIP6 = 0x102
ARPHRD_TUNNEL = 0x300
ARPHRD_TUNNEL6 = 0x301
ARPHRD_VOID = 0xffff
ARPHRD_VSOCKMON = 0x33a
ARPHRD_X25 = 0x10f
B0 = 0x0
B1000000 = 0x1008
B110 = 0x3
B115200 = 0x1002
B1152000 = 0x1009
B1200 = 0x9
B134 = 0x4
B150 = 0x5
B1500000 = 0x100a
B1800 = 0xa
B19200 = 0xe
B200 = 0x6
B2000000 = 0x100b
B230400 = 0x1003
B2400 = 0xb
B2500000 = 0x100c
B300 = 0x7
B3000000 = 0x100d
B3500000 = 0x100e
B38400 = 0xf
B4000000 = 0x100f
B460800 = 0x1004
B4800 = 0xc
B50 = 0x1
B500000 = 0x1005
B57600 = 0x1001
B576000 = 0x1006
B600 = 0x8
B75 = 0x2
B921600 = 0x1007
B9600 = 0xd
BLKBSZGET = 0x80081270
BLKBSZSET = 0x40081271
BLKFLSBUF = 0x1261
BLKFRAGET = 0x1265
BLKFRASET = 0x1264
BLKGETSIZE = 0x1260
BLKGETSIZE64 = 0x80081272
BLKPBSZGET = 0x127b
BLKRAGET = 0x1263
BLKRASET = 0x1262
BLKROGET = 0x125e
BLKROSET = 0x125d
BLKRRPART = 0x125f
BLKSECTGET = 0x1267
BLKSECTSET = 0x1266
BLKSSZGET = 0x1268
BOTHER = 0x1000
BPF_A = 0x10
BPF_ABS = 0x20
BPF_ADD = 0x0
BPF_ALU = 0x4
BPF_AND = 0x50
BPF_B = 0x10
BPF_DIV = 0x30
BPF_H = 0x8
BPF_IMM = 0x0
BPF_IND = 0x40
BPF_JA = 0x0
BPF_JEQ = 0x10
BPF_JGE = 0x30
BPF_JGT = 0x20
BPF_JMP = 0x5
BPF_JSET = 0x40
BPF_K = 0x0
BPF_LD = 0x0
BPF_LDX = 0x1
BPF_LEN = 0x80
BPF_LL_OFF = -0x200000
BPF_LSH = 0x60
BPF_MAJOR_VERSION = 0x1
BPF_MAXINSNS = 0x1000
BPF_MEM = 0x60
BPF_MEMWORDS = 0x10
BPF_MINOR_VERSION = 0x1
BPF_MISC = 0x7
BPF_MOD = 0x90
BPF_MSH = 0xa0
BPF_MUL = 0x20
BPF_NEG = 0x80
BPF_NET_OFF = -0x100000
BPF_OR = 0x40
BPF_RET = 0x6
BPF_RSH = 0x70
BPF_ST = 0x2
BPF_STX = 0x3
BPF_SUB = 0x10
BPF_TAX = 0x0
BPF_TXA = 0x80
BPF_W = 0x0
BPF_X = 0x8
BPF_XOR = 0xa0
BRKINT = 0x2
BS0 = 0x0
BS1 = 0x2000
BSDLY = 0x2000
CAN_BCM = 0x2
CAN_EFF_FLAG = 0x80000000
CAN_EFF_ID_BITS = 0x1d
CAN_EFF_MASK = 0x1fffffff
CAN_ERR_FLAG = 0x20000000
CAN_ERR_MASK = 0x1fffffff
CAN_INV_FILTER = 0x20000000
CAN_ISOTP = 0x6
CAN_MAX_DLC = 0x8
CAN_MAX_DLEN = 0x8
CAN_MCNET = 0x5
CAN_MTU = 0x10
CAN_NPROTO = 0x7
CAN_RAW = 0x1
CAN_RAW_FILTER_MAX = 0x200
CAN_RTR_FLAG = 0x40000000
CAN_SFF_ID_BITS = 0xb
CAN_SFF_MASK = 0x7ff
CAN_TP16 = 0x3
CAN_TP20 = 0x4
CBAUD = 0x100f
CBAUDEX = 0x1000
CFLUSH = 0xf
CIBAUD = 0x100f0000
CLOCAL = 0x800
CLOCK_BOOTTIME = 0x7
CLOCK_BOOTTIME_ALARM = 0x9
CLOCK_DEFAULT = 0x0
CLOCK_EXT = 0x1
CLOCK_INT = 0x2
CLOCK_MONOTONIC = 0x1
CLOCK_MONOTONIC_COARSE = 0x6
CLOCK_MONOTONIC_RAW = 0x4
CLOCK_PROCESS_CPUTIME_ID = 0x2
CLOCK_REALTIME = 0x0
CLOCK_REALTIME_ALARM = 0x8
CLOCK_REALTIME_COARSE = 0x5
CLOCK_TAI = 0xb
CLOCK_THREAD_CPUTIME_ID = 0x3
CLOCK_TXFROMRX = 0x4
CLOCK_TXINT = 0x3
CLONE_CHILD_CLEARTID = 0x200000
CLONE_CHILD_SETTID = 0x1000000
CLONE_DETACHED = 0x400000
CLONE_FILES = 0x400
CLONE_FS = 0x200
CLONE_IO = 0x80000000
CLONE_NEWCGROUP = 0x2000000
CLONE_NEWIPC = 0x8000000
CLONE_NEWNET = 0x40000000
CLONE_NEWNS = 0x20000
CLONE_NEWPID = 0x20000000
CLONE_NEWUSER = 0x10000000
CLONE_NEWUTS = 0x4000000
CLONE_PARENT = 0x8000
CLONE_PARENT_SETTID = 0x100000
CLONE_PTRACE = 0x2000
CLONE_SETTLS = 0x80000
CLONE_SIGHAND = 0x800
CLONE_SYSVSEM = 0x40000
CLONE_THREAD = 0x10000
CLONE_UNTRACED = 0x800000
CLONE_VFORK = 0x4000
CLONE_VM = 0x100
CMSPAR = 0x40000000
CR0 = 0x0
CR1 = 0x200
CR2 = 0x400
CR3 = 0x600
CRDLY = 0x600
CREAD = 0x80
CRTSCTS = 0x80000000
CS5 = 0x0
CS6 = 0x10
CS7 = 0x20
CS8 = 0x30
CSIGNAL = 0xff
CSIZE = 0x30
CSTART = 0x11
CSTATUS = 0x0
CSTOP = 0x13
CSTOPB = 0x40
CSUSP = 0x1a
DT_BLK = 0x6
DT_CHR = 0x2
DT_DIR = 0x4
DT_FIFO = 0x1
DT_LNK = 0xa
DT_REG = 0x8
DT_SOCK = 0xc
DT_UNKNOWN = 0x0
DT_WHT = 0xe
ECHO = 0x8
ECHOCTL = 0x200
ECHOE = 0x10
ECHOK = 0x20
ECHOKE = 0x800
ECHONL = 0x40
ECHOPRT = 0x400
EFD_CLOEXEC = 0x80000
EFD_NONBLOCK = 0x800
EFD_SEMAPHORE = 0x1
ENCODING_DEFAULT = 0x0
ENCODING_FM_MARK = 0x3
ENCODING_FM_SPACE = 0x4
ENCODING_MANCHESTER = 0x5
ENCODING_NRZ = 0x1
ENCODING_NRZI = 0x2
EPOLLERR = 0x8
EPOLLET = 0x80000000
EPOLLEXCLUSIVE = 0x10000000
EPOLLHUP = 0x10
EPOLLIN = 0x1
EPOLLMSG = 0x400
EPOLLONESHOT = 0x40000000
EPOLLOUT = 0x4
EPOLLPRI = 0x2
EPOLLRDBAND = 0x80
EPOLLRDHUP = 0x2000
EPOLLRDNORM = 0x40
EPOLLWAKEUP = 0x20000000
EPOLLWRBAND = 0x200
EPOLLWRNORM = 0x100
EPOLL_CLOEXEC = 0x80000
EPOLL_CTL_ADD = 0x1
EPOLL_CTL_DEL = 0x2
EPOLL_CTL_MOD = 0x3
ETH_P_1588 = 0x88f7
ETH_P_8021AD = 0x88a8
ETH_P_8021AH = 0x88e7
ETH_P_8021Q = 0x8100
ETH_P_80221 = 0x8917
ETH_P_802_2 = 0x4
ETH_P_802_3 = 0x1
ETH_P_802_3_MIN = 0x600
ETH_P_802_EX1 = 0x88b5
ETH_P_AARP = 0x80f3
ETH_P_AF_IUCV = 0xfbfb
ETH_P_ALL = 0x3
ETH_P_AOE = 0x88a2
ETH_P_ARCNET = 0x1a
ETH_P_ARP = 0x806
ETH_P_ATALK = 0x809b
ETH_P_ATMFATE = 0x8884
ETH_P_ATMMPOA = 0x884c
ETH_P_AX25 = 0x2
ETH_P_BATMAN = 0x4305
ETH_P_BPQ = 0x8ff
ETH_P_CAIF = 0xf7
ETH_P_CAN = 0xc
ETH_P_CANFD = 0xd
ETH_P_CONTROL = 0x16
ETH_P_CUST = 0x6006
ETH_P_DDCMP = 0x6
ETH_P_DEC = 0x6000
ETH_P_DIAG = 0x6005
ETH_P_DNA_DL = 0x6001
ETH_P_DNA_RC = 0x6002
ETH_P_DNA_RT = 0x6003
ETH_P_DSA = 0x1b
ETH_P_ECONET = 0x18
ETH_P_EDSA = 0xdada
ETH_P_FCOE = 0x8906
ETH_P_FIP = 0x8914
ETH_P_HDLC = 0x19
ETH_P_HSR = 0x892f
ETH_P_IBOE = 0x8915
ETH_P_IEEE802154 = 0xf6
ETH_P_IEEEPUP = 0xa00
ETH_P_IEEEPUPAT = 0xa01
ETH_P_IP = 0x800
ETH_P_IPV6 = 0x86dd
ETH_P_IPX = 0x8137
ETH_P_IRDA = 0x17
ETH_P_LAT = 0x6004
ETH_P_LINK_CTL = 0x886c
ETH_P_LOCALTALK = 0x9
ETH_P_LOOP = 0x60
ETH_P_LOOPBACK = 0x9000
ETH_P_MACSEC = 0x88e5
ETH_P_MOBITEX = 0x15
ETH_P_MPLS_MC = 0x8848
ETH_P_MPLS_UC = 0x8847
ETH_P_MVRP = 0x88f5
ETH_P_NCSI = 0x88f8
ETH_P_PAE = 0x888e
ETH_P_PAUSE = 0x8808
ETH_P_PHONET = 0xf5
ETH_P_PPPTALK = 0x10
ETH_P_PPP_DISC = 0x8863
ETH_P_PPP_MP = 0x8
ETH_P_PPP_SES = 0x8864
ETH_P_PRP = 0x88fb
ETH_P_PUP = 0x200
ETH_P_PUPAT = 0x201
ETH_P_QINQ1 = 0x9100
ETH_P_QINQ2 = 0x9200
ETH_P_QINQ3 = 0x9300
ETH_P_RARP = 0x8035
ETH_P_SCA = 0x6007
ETH_P_SLOW = 0x8809
ETH_P_SNAP = 0x5
ETH_P_TDLS = 0x890d
ETH_P_TEB = 0x6558
ETH_P_TIPC = 0x88ca
ETH_P_TRAILER = 0x1c
ETH_P_TR_802_2 = 0x11
ETH_P_TSN = 0x22f0
ETH_P_WAN_PPP = 0x7
ETH_P_WCCP = 0x883e
ETH_P_X25 = 0x805
ETH_P_XDSA = 0xf8
EXTA = 0xe
EXTB = 0xf
EXTPROC = 0x10000
FALLOC_FL_COLLAPSE_RANGE = 0x8
FALLOC_FL_INSERT_RANGE = 0x20
FALLOC_FL_KEEP_SIZE = 0x1
FALLOC_FL_NO_HIDE_STALE = 0x4
FALLOC_FL_PUNCH_HOLE = 0x2
FALLOC_FL_UNSHARE_RANGE = 0x40
FALLOC_FL_ZERO_RANGE = 0x10
FD_CLOEXEC = 0x1
FD_SETSIZE = 0x400
FF0 = 0x0
FF1 = 0x8000
FFDLY = 0x8000
FLUSHO = 0x1000
FS_ENCRYPTION_MODE_AES_128_CBC = 0x5
FS_ENCRYPTION_MODE_AES_128_CTS = 0x6
FS_ENCRYPTION_MODE_AES_256_CBC = 0x3
FS_ENCRYPTION_MODE_AES_256_CTS = 0x4
FS_ENCRYPTION_MODE_AES_256_GCM = 0x2
FS_ENCRYPTION_MODE_AES_256_XTS = 0x1
FS_ENCRYPTION_MODE_INVALID = 0x0
FS_IOC_GET_ENCRYPTION_POLICY = 0x400c6615
FS_IOC_GET_ENCRYPTION_PWSALT = 0x40106614
FS_IOC_SET_ENCRYPTION_POLICY = 0x800c6613
FS_KEY_DESCRIPTOR_SIZE = 0x8
FS_KEY_DESC_PREFIX = "fscrypt:"
FS_KEY_DESC_PREFIX_SIZE = 0x8
FS_MAX_KEY_SIZE = 0x40
FS_POLICY_FLAGS_PAD_16 = 0x2
FS_POLICY_FLAGS_PAD_32 = 0x3
FS_POLICY_FLAGS_PAD_4 = 0x0
FS_POLICY_FLAGS_PAD_8 = 0x1
FS_POLICY_FLAGS_PAD_MASK = 0x3
FS_POLICY_FLAGS_VALID = 0x3
F_DUPFD = 0x0
F_DUPFD_CLOEXEC = 0x406
F_EXLCK = 0x4
F_GETFD = 0x1
F_GETFL = 0x3
F_GETLEASE = 0x401
F_GETLK = 0x5
F_GETLK64 = 0x5
F_GETOWN = 0x9
F_GETOWN_EX = 0x10
F_GETPIPE_SZ = 0x408
F_GETSIG = 0xb
F_LOCK = 0x1
F_NOTIFY = 0x402
F_OFD_GETLK = 0x24
F_OFD_SETLK = 0x25
F_OFD_SETLKW = 0x26
F_OK = 0x0
F_RDLCK = 0x0
F_SETFD = 0x2
F_SETFL = 0x4
F_SETLEASE = 0x400
F_SETLK = 0x6
F_SETLK64 = 0x6
F_SETLKW = 0x7
F_SETLKW64 = 0x7
F_SETOWN = 0x8
F_SETOWN_EX = 0xf
F_SETPIPE_SZ = 0x407
F_SETSIG = 0xa
F_SHLCK = 0x8
F_TEST = 0x3
F_TLOCK = 0x2
F_ULOCK = 0x0
F_UNLCK = 0x2
F_WRLCK = 0x1
GENL_ADMIN_PERM = 0x1
GENL_CMD_CAP_DO = 0x2
GENL_CMD_CAP_DUMP = 0x4
GENL_CMD_CAP_HASPOL = 0x8
GENL_HDRLEN = 0x4
GENL_ID_CTRL = 0x10
GENL_ID_PMCRAID = 0x12
GENL_ID_VFS_DQUOT = 0x11
GENL_MAX_ID = 0x3ff
GENL_MIN_ID = 0x10
GENL_NAMSIZ = 0x10
GENL_START_ALLOC = 0x13
GENL_UNS_ADMIN_PERM = 0x10
GRND_NONBLOCK = 0x1
GRND_RANDOM = 0x2
HUPCL = 0x400
IBSHIFT = 0x10
ICANON = 0x2
ICMPV6_FILTER = 0x1
ICRNL = 0x100
IEXTEN = 0x8000
IFA_F_DADFAILED = 0x8
IFA_F_DEPRECATED = 0x20
IFA_F_HOMEADDRESS = 0x10
IFA_F_MANAGETEMPADDR = 0x100
IFA_F_MCAUTOJOIN = 0x400
IFA_F_NODAD = 0x2
IFA_F_NOPREFIXROUTE = 0x200
IFA_F_OPTIMISTIC = 0x4
IFA_F_PERMANENT = 0x80
IFA_F_SECONDARY = 0x1
IFA_F_STABLE_PRIVACY = 0x800
IFA_F_TEMPORARY = 0x1
IFA_F_TENTATIVE = 0x40
IFA_MAX = 0x8
IFF_ALLMULTI = 0x200
IFF_ATTACH_QUEUE = 0x200
IFF_AUTOMEDIA = 0x4000
IFF_BROADCAST = 0x2
IFF_DEBUG = 0x4
IFF_DETACH_QUEUE = 0x400
IFF_DORMANT = 0x20000
IFF_DYNAMIC = 0x8000
IFF_ECHO = 0x40000
IFF_LOOPBACK = 0x8
IFF_LOWER_UP = 0x10000
IFF_MASTER = 0x400
IFF_MULTICAST = 0x1000
IFF_MULTI_QUEUE = 0x100
IFF_NOARP = 0x80
IFF_NOFILTER = 0x1000
IFF_NOTRAILERS = 0x20
IFF_NO_PI = 0x1000
IFF_ONE_QUEUE = 0x2000
IFF_PERSIST = 0x800
IFF_POINTOPOINT = 0x10
IFF_PORTSEL = 0x2000
IFF_PROMISC = 0x100
IFF_RUNNING = 0x40
IFF_SLAVE = 0x800
IFF_TAP = 0x2
IFF_TUN = 0x1
IFF_TUN_EXCL = 0x8000
IFF_UP = 0x1
IFF_VNET_HDR = 0x4000
IFF_VOLATILE = 0x70c5a
IFNAMSIZ = 0x10
IGNBRK = 0x1
IGNCR = 0x80
IGNPAR = 0x4
IMAXBEL = 0x2000
INLCR = 0x40
INPCK = 0x10
IN_ACCESS = 0x1
IN_ALL_EVENTS = 0xfff
IN_ATTRIB = 0x4
IN_CLASSA_HOST = 0xffffff
IN_CLASSA_MAX = 0x80
IN_CLASSA_NET = 0xff000000
IN_CLASSA_NSHIFT = 0x18
IN_CLASSB_HOST = 0xffff
IN_CLASSB_MAX = 0x10000
IN_CLASSB_NET = 0xffff0000
IN_CLASSB_NSHIFT = 0x10
IN_CLASSC_HOST = 0xff
IN_CLASSC_NET = 0xffffff00
IN_CLASSC_NSHIFT = 0x8
IN_CLOEXEC = 0x80000
IN_CLOSE = 0x18
IN_CLOSE_NOWRITE = 0x10
IN_CLOSE_WRITE = 0x8
IN_CREATE = 0x100
IN_DELETE = 0x200
IN_DELETE_SELF = 0x400
IN_DONT_FOLLOW = 0x2000000
IN_EXCL_UNLINK = 0x4000000
IN_IGNORED = 0x8000
IN_ISDIR = 0x40000000
IN_LOOPBACKNET = 0x7f
IN_MASK_ADD = 0x20000000
IN_MODIFY = 0x2
IN_MOVE = 0xc0
IN_MOVED_FROM = 0x40
IN_MOVED_TO = 0x80
IN_MOVE_SELF = 0x800
IN_NONBLOCK = 0x800
IN_ONESHOT = 0x80000000
IN_ONLYDIR = 0x1000000
IN_OPEN = 0x20
IN_Q_OVERFLOW = 0x4000
IN_UNMOUNT = 0x2000
IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9
IPPROTO_AH = 0x33
IPPROTO_BEETPH = 0x5e
IPPROTO_COMP = 0x6c
IPPROTO_DCCP = 0x21
IPPROTO_DSTOPTS = 0x3c
IPPROTO_EGP = 0x8
IPPROTO_ENCAP = 0x62
IPPROTO_ESP = 0x32
IPPROTO_FRAGMENT = 0x2c
IPPROTO_GRE = 0x2f
IPPROTO_HOPOPTS = 0x0
IPPROTO_ICMP = 0x1
IPPROTO_ICMPV6 = 0x3a
IPPROTO_IDP = 0x16
IPPROTO_IGMP = 0x2
IPPROTO_IP = 0x0
IPPROTO_IPIP = 0x4
IPPROTO_IPV6 = 0x29
IPPROTO_MH = 0x87
IPPROTO_MPLS = 0x89
IPPROTO_MTP = 0x5c
IPPROTO_NONE = 0x3b
IPPROTO_PIM = 0x67
IPPROTO_PUP = 0xc
IPPROTO_RAW = 0xff
IPPROTO_ROUTING = 0x2b
IPPROTO_RSVP = 0x2e
IPPROTO_SCTP = 0x84
IPPROTO_TCP = 0x6
IPPROTO_TP = 0x1d
IPPROTO_UDP = 0x11
IPPROTO_UDPLITE = 0x88
IPV6_2292DSTOPTS = 0x4
IPV6_2292HOPLIMIT = 0x8
IPV6_2292HOPOPTS = 0x3
IPV6_2292PKTINFO = 0x2
IPV6_2292PKTOPTIONS = 0x6
IPV6_2292RTHDR = 0x5
IPV6_ADDRFORM = 0x1
IPV6_ADDR_PREFERENCES = 0x48
IPV6_ADD_MEMBERSHIP = 0x14
IPV6_AUTHHDR = 0xa
IPV6_AUTOFLOWLABEL = 0x46
IPV6_CHECKSUM = 0x7
IPV6_DONTFRAG = 0x3e
IPV6_DROP_MEMBERSHIP = 0x15
IPV6_DSTOPTS = 0x3b
IPV6_HDRINCL = 0x24
IPV6_HOPLIMIT = 0x34
IPV6_HOPOPTS = 0x36
IPV6_IPSEC_POLICY = 0x22
IPV6_JOIN_ANYCAST = 0x1b
IPV6_JOIN_GROUP = 0x14
IPV6_LEAVE_ANYCAST = 0x1c
IPV6_LEAVE_GROUP = 0x15
IPV6_MINHOPCOUNT = 0x49
IPV6_MTU = 0x18
IPV6_MTU_DISCOVER = 0x17
IPV6_MULTICAST_HOPS = 0x12
IPV6_MULTICAST_IF = 0x11
IPV6_MULTICAST_LOOP = 0x13
IPV6_NEXTHOP = 0x9
IPV6_ORIGDSTADDR = 0x4a
IPV6_PATHMTU = 0x3d
IPV6_PKTINFO = 0x32
IPV6_PMTUDISC_DO = 0x2
IPV6_PMTUDISC_DONT = 0x0
IPV6_PMTUDISC_INTERFACE = 0x4
IPV6_PMTUDISC_OMIT = 0x5
IPV6_PMTUDISC_PROBE = 0x3
IPV6_PMTUDISC_WANT = 0x1
IPV6_RECVDSTOPTS = 0x3a
IPV6_RECVERR = 0x19
IPV6_RECVFRAGSIZE = 0x4d
IPV6_RECVHOPLIMIT = 0x33
IPV6_RECVHOPOPTS = 0x35
IPV6_RECVORIGDSTADDR = 0x4a
IPV6_RECVPATHMTU = 0x3c
IPV6_RECVPKTINFO = 0x31
IPV6_RECVRTHDR = 0x38
IPV6_RECVTCLASS = 0x42
IPV6_ROUTER_ALERT = 0x16
IPV6_RTHDR = 0x39
IPV6_RTHDRDSTOPTS = 0x37
IPV6_RTHDR_LOOSE = 0x0
IPV6_RTHDR_STRICT = 0x1
IPV6_RTHDR_TYPE_0 = 0x0
IPV6_RXDSTOPTS = 0x3b
IPV6_RXHOPOPTS = 0x36
IPV6_TCLASS = 0x43
IPV6_TRANSPARENT = 0x4b
IPV6_UNICAST_HOPS = 0x10
IPV6_UNICAST_IF = 0x4c
IPV6_V6ONLY = 0x1a
IPV6_XFRM_POLICY = 0x23
IP_ADD_MEMBERSHIP = 0x23
IP_ADD_SOURCE_MEMBERSHIP = 0x27
IP_BIND_ADDRESS_NO_PORT = 0x18
IP_BLOCK_SOURCE = 0x26
IP_CHECKSUM = 0x17
IP_DEFAULT_MULTICAST_LOOP = 0x1
IP_DEFAULT_MULTICAST_TTL = 0x1
IP_DF = 0x4000
IP_DROP_MEMBERSHIP = 0x24
IP_DROP_SOURCE_MEMBERSHIP = 0x28
IP_FREEBIND = 0xf
IP_HDRINCL = 0x3
IP_IPSEC_POLICY = 0x10
IP_MAXPACKET = 0xffff
IP_MAX_MEMBERSHIPS = 0x14
IP_MF = 0x2000
IP_MINTTL = 0x15
IP_MSFILTER = 0x29
IP_MSS = 0x240
IP_MTU = 0xe
IP_MTU_DISCOVER = 0xa
IP_MULTICAST_ALL = 0x31
IP_MULTICAST_IF = 0x20
IP_MULTICAST_LOOP = 0x22
IP_MULTICAST_TTL = 0x21
IP_NODEFRAG = 0x16
IP_OFFMASK = 0x1fff
IP_OPTIONS = 0x4
IP_ORIGDSTADDR = 0x14
IP_PASSSEC = 0x12
IP_PKTINFO = 0x8
IP_PKTOPTIONS = 0x9
IP_PMTUDISC = 0xa
IP_PMTUDISC_DO = 0x2
IP_PMTUDISC_DONT = 0x0
IP_PMTUDISC_INTERFACE = 0x4
IP_PMTUDISC_OMIT = 0x5
IP_PMTUDISC_PROBE = 0x3
IP_PMTUDISC_WANT = 0x1
IP_RECVERR = 0xb
IP_RECVFRAGSIZE = 0x19
IP_RECVOPTS = 0x6
IP_RECVORIGDSTADDR = 0x14
IP_RECVRETOPTS = 0x7
IP_RECVTOS = 0xd
IP_RECVTTL = 0xc
IP_RETOPTS = 0x7
IP_RF = 0x8000
IP_ROUTER_ALERT = 0x5
IP_TOS = 0x1
IP_TRANSPARENT = 0x13
IP_TTL = 0x2
IP_UNBLOCK_SOURCE = 0x25
IP_UNICAST_IF = 0x32
IP_XFRM_POLICY = 0x11
ISIG = 0x1
ISTRIP = 0x20
IUCLC = 0x200
IUTF8 = 0x4000
IXANY = 0x800
IXOFF = 0x1000
IXON = 0x400
KEYCTL_ASSUME_AUTHORITY = 0x10
KEYCTL_CHOWN = 0x4
KEYCTL_CLEAR = 0x7
KEYCTL_DESCRIBE = 0x6
KEYCTL_DH_COMPUTE = 0x17
KEYCTL_GET_KEYRING_ID = 0x0
KEYCTL_GET_PERSISTENT = 0x16
KEYCTL_GET_SECURITY = 0x11
KEYCTL_INSTANTIATE = 0xc
KEYCTL_INSTANTIATE_IOV = 0x14
KEYCTL_INVALIDATE = 0x15
KEYCTL_JOIN_SESSION_KEYRING = 0x1
KEYCTL_LINK = 0x8
KEYCTL_NEGATE = 0xd
KEYCTL_READ = 0xb
KEYCTL_REJECT = 0x13
KEYCTL_RESTRICT_KEYRING = 0x1d
KEYCTL_REVOKE = 0x3
KEYCTL_SEARCH = 0xa
KEYCTL_SESSION_TO_PARENT = 0x12
KEYCTL_SETPERM = 0x5
KEYCTL_SET_REQKEY_KEYRING = 0xe
KEYCTL_SET_TIMEOUT = 0xf
KEYCTL_UNLINK = 0x9
KEYCTL_UPDATE = 0x2
KEY_REQKEY_DEFL_DEFAULT = 0x0
KEY_REQKEY_DEFL_GROUP_KEYRING = 0x6
KEY_REQKEY_DEFL_NO_CHANGE = -0x1
KEY_REQKEY_DEFL_PROCESS_KEYRING = 0x2
KEY_REQKEY_DEFL_REQUESTOR_KEYRING = 0x7
KEY_REQKEY_DEFL_SESSION_KEYRING = 0x3
KEY_REQKEY_DEFL_THREAD_KEYRING = 0x1
KEY_REQKEY_DEFL_USER_KEYRING = 0x4
KEY_REQKEY_DEFL_USER_SESSION_KEYRING = 0x5
KEY_SPEC_GROUP_KEYRING = -0x6
KEY_SPEC_PROCESS_KEYRING = -0x2
KEY_SPEC_REQKEY_AUTH_KEY = -0x7
KEY_SPEC_REQUESTOR_KEYRING = -0x8
KEY_SPEC_SESSION_KEYRING = -0x3
KEY_SPEC_THREAD_KEYRING = -0x1
KEY_SPEC_USER_KEYRING = -0x4
KEY_SPEC_USER_SESSION_KEYRING = -0x5
LINUX_REBOOT_CMD_CAD_OFF = 0x0
LINUX_REBOOT_CMD_CAD_ON = 0x89abcdef
LINUX_REBOOT_CMD_HALT = 0xcdef0123
LINUX_REBOOT_CMD_KEXEC = 0x45584543
LINUX_REBOOT_CMD_POWER_OFF = 0x4321fedc
LINUX_REBOOT_CMD_RESTART = 0x1234567
LINUX_REBOOT_CMD_RESTART2 = 0xa1b2c3d4
LINUX_REBOOT_CMD_SW_SUSPEND = 0xd000fce2
LINUX_REBOOT_MAGIC1 = 0xfee1dead
LINUX_REBOOT_MAGIC2 = 0x28121969
LOCK_EX = 0x2
LOCK_NB = 0x4
LOCK_SH = 0x1
LOCK_UN = 0x8
MADV_DODUMP = 0x11
MADV_DOFORK = 0xb
MADV_DONTDUMP = 0x10
MADV_DONTFORK = 0xa
MADV_DONTNEED = 0x4
MADV_FREE = 0x8
MADV_HUGEPAGE = 0xe
MADV_HWPOISON = 0x64
MADV_MERGEABLE = 0xc
MADV_NOHUGEPAGE = 0xf
MADV_NORMAL = 0x0
MADV_RANDOM = 0x1
MADV_REMOVE = 0x9
MADV_SEQUENTIAL = 0x2
MADV_UNMERGEABLE = 0xd
MADV_WILLNEED = 0x3
MAP_32BIT = 0x40
MAP_ANON = 0x20
MAP_ANONYMOUS = 0x20
MAP_DENYWRITE = 0x800
MAP_EXECUTABLE = 0x1000
MAP_FILE = 0x0
MAP_FIXED = 0x10
MAP_GROWSDOWN = 0x100
MAP_HUGETLB = 0x40000
MAP_HUGE_MASK = 0x3f
MAP_HUGE_SHIFT = 0x1a
MAP_LOCKED = 0x2000
MAP_NONBLOCK = 0x10000
MAP_NORESERVE = 0x4000
MAP_POPULATE = 0x8000
MAP_PRIVATE = 0x2
MAP_SHARED = 0x1
MAP_STACK = 0x20000
MAP_TYPE = 0xf
MCL_CURRENT = 0x1
MCL_FUTURE = 0x2
MCL_ONFAULT = 0x4
MNT_DETACH = 0x2
MNT_EXPIRE = 0x4
MNT_FORCE = 0x1
MSG_BATCH = 0x40000
MSG_CMSG_CLOEXEC = 0x40000000
MSG_CONFIRM = 0x800
MSG_CTRUNC = 0x8
MSG_DONTROUTE = 0x4
MSG_DONTWAIT = 0x40
MSG_EOR = 0x80
MSG_ERRQUEUE = 0x2000
MSG_FASTOPEN = 0x20000000
MSG_FIN = 0x200
MSG_MORE = 0x8000
MSG_NOSIGNAL = 0x4000
MSG_OOB = 0x1
MSG_PEEK = 0x2
MSG_PROXY = 0x10
MSG_RST = 0x1000
MSG_SYN = 0x400
MSG_TRUNC = 0x20
MSG_TRYHARD = 0x4
MSG_WAITALL = 0x100
MSG_WAITFORONE = 0x10000
MS_ACTIVE = 0x40000000
MS_ASYNC = 0x1
MS_BIND = 0x1000
MS_BORN = 0x20000000
MS_DIRSYNC = 0x80
MS_INVALIDATE = 0x2
MS_I_VERSION = 0x800000
MS_KERNMOUNT = 0x400000
MS_LAZYTIME = 0x2000000
MS_MANDLOCK = 0x40
MS_MGC_MSK = 0xffff0000
MS_MGC_VAL = 0xc0ed0000
MS_MOVE = 0x2000
MS_NOATIME = 0x400
MS_NODEV = 0x4
MS_NODIRATIME = 0x800
MS_NOEXEC = 0x8
MS_NOREMOTELOCK = 0x8000000
MS_NOSEC = 0x10000000
MS_NOSUID = 0x2
MS_NOUSER = -0x80000000
MS_POSIXACL = 0x10000
MS_PRIVATE = 0x40000
MS_RDONLY = 0x1
MS_REC = 0x4000
MS_RELATIME = 0x200000
MS_REMOUNT = 0x20
MS_RMT_MASK = 0x2800051
MS_SHARED = 0x100000
MS_SILENT = 0x8000
MS_SLAVE = 0x80000
MS_STRICTATIME = 0x1000000
MS_SUBMOUNT = 0x4000000
MS_SYNC = 0x4
MS_SYNCHRONOUS = 0x10
MS_UNBINDABLE = 0x20000
MS_VERBOSE = 0x8000
NAME_MAX = 0xff
NETLINK_ADD_MEMBERSHIP = 0x1
NETLINK_AUDIT = 0x9
NETLINK_BROADCAST_ERROR = 0x4
NETLINK_CAP_ACK = 0xa
NETLINK_CONNECTOR = 0xb
NETLINK_CRYPTO = 0x15
NETLINK_DNRTMSG = 0xe
NETLINK_DROP_MEMBERSHIP = 0x2
NETLINK_ECRYPTFS = 0x13
NETLINK_EXT_ACK = 0xb
NETLINK_FIB_LOOKUP = 0xa
NETLINK_FIREWALL = 0x3
NETLINK_GENERIC = 0x10
NETLINK_INET_DIAG = 0x4
NETLINK_IP6_FW = 0xd
NETLINK_ISCSI = 0x8
NETLINK_KOBJECT_UEVENT = 0xf
NETLINK_LISTEN_ALL_NSID = 0x8
NETLINK_LIST_MEMBERSHIPS = 0x9
NETLINK_NETFILTER = 0xc
NETLINK_NFLOG = 0x5
NETLINK_NO_ENOBUFS = 0x5
NETLINK_PKTINFO = 0x3
NETLINK_RDMA = 0x14
NETLINK_ROUTE = 0x0
NETLINK_RX_RING = 0x6
NETLINK_SCSITRANSPORT = 0x12
NETLINK_SELINUX = 0x7
NETLINK_SMC = 0x16
NETLINK_SOCK_DIAG = 0x4
NETLINK_TX_RING = 0x7
NETLINK_UNUSED = 0x1
NETLINK_USERSOCK = 0x2
NETLINK_XFRM = 0x6
NL0 = 0x0
NL1 = 0x100
NLA_ALIGNTO = 0x4
NLA_F_NESTED = 0x8000
NLA_F_NET_BYTEORDER = 0x4000
NLA_HDRLEN = 0x4
NLDLY = 0x100
NLMSG_ALIGNTO = 0x4
NLMSG_DONE = 0x3
NLMSG_ERROR = 0x2
NLMSG_HDRLEN = 0x10
NLMSG_MIN_TYPE = 0x10
NLMSG_NOOP = 0x1
NLMSG_OVERRUN = 0x4
NLM_F_ACK = 0x4
NLM_F_ACK_TLVS = 0x200
NLM_F_APPEND = 0x800
NLM_F_ATOMIC = 0x400
NLM_F_CAPPED = 0x100
NLM_F_CREATE = 0x400
NLM_F_DUMP = 0x300
NLM_F_DUMP_FILTERED = 0x20
NLM_F_DUMP_INTR = 0x10
NLM_F_ECHO = 0x8
NLM_F_EXCL = 0x200
NLM_F_MATCH = 0x200
NLM_F_MULTI = 0x2
NLM_F_REPLACE = 0x100
NLM_F_REQUEST = 0x1
NLM_F_ROOT = 0x100
NOFLSH = 0x80
OCRNL = 0x8
OFDEL = 0x80
OFILL = 0x40
OLCUC = 0x2
ONLCR = 0x4
ONLRET = 0x20
ONOCR = 0x10
OPOST = 0x1
O_ACCMODE = 0x3
O_APPEND = 0x400
O_ASYNC = 0x2000
O_CLOEXEC = 0x80000
O_CREAT = 0x40
O_DIRECT = 0x4000
O_DIRECTORY = 0x10000
O_DSYNC = 0x1000
O_EXCL = 0x80
O_FSYNC = 0x101000
O_LARGEFILE = 0x0
O_NDELAY = 0x800
O_NOATIME = 0x40000
O_NOCTTY = 0x100
O_NOFOLLOW = 0x20000
O_NONBLOCK = 0x800
O_PATH = 0x200000
O_RDONLY = 0x0
O_RDWR = 0x2
O_RSYNC = 0x101000
O_SYNC = 0x101000
O_TMPFILE = 0x410000
O_TRUNC = 0x200
O_WRONLY = 0x1
PACKET_ADD_MEMBERSHIP = 0x1
PACKET_AUXDATA = 0x8
PACKET_BROADCAST = 0x1
PACKET_COPY_THRESH = 0x7
PACKET_DROP_MEMBERSHIP = 0x2
PACKET_FANOUT = 0x12
PACKET_FANOUT_CBPF = 0x6
PACKET_FANOUT_CPU = 0x2
PACKET_FANOUT_DATA = 0x16
PACKET_FANOUT_EBPF = 0x7
PACKET_FANOUT_FLAG_DEFRAG = 0x8000
PACKET_FANOUT_FLAG_ROLLOVER = 0x1000
PACKET_FANOUT_FLAG_UNIQUEID = 0x2000
PACKET_FANOUT_HASH = 0x0
PACKET_FANOUT_LB = 0x1
PACKET_FANOUT_QM = 0x5
PACKET_FANOUT_RND = 0x4
PACKET_FANOUT_ROLLOVER = 0x3
PACKET_FASTROUTE = 0x6
PACKET_HDRLEN = 0xb
PACKET_HOST = 0x0
PACKET_KERNEL = 0x7
PACKET_LOOPBACK = 0x5
PACKET_LOSS = 0xe
PACKET_MR_ALLMULTI = 0x2
PACKET_MR_MULTICAST = 0x0
PACKET_MR_PROMISC = 0x1
PACKET_MR_UNICAST = 0x3
PACKET_MULTICAST = 0x2
PACKET_ORIGDEV = 0x9
PACKET_OTHERHOST = 0x3
PACKET_OUTGOING = 0x4
PACKET_QDISC_BYPASS = 0x14
PACKET_RECV_OUTPUT = 0x3
PACKET_RESERVE = 0xc
PACKET_ROLLOVER_STATS = 0x15
PACKET_RX_RING = 0x5
PACKET_STATISTICS = 0x6
PACKET_TIMESTAMP = 0x11
PACKET_TX_HAS_OFF = 0x13
PACKET_TX_RING = 0xd
PACKET_TX_TIMESTAMP = 0x10
PACKET_USER = 0x6
PACKET_VERSION = 0xa
PACKET_VNET_HDR = 0xf
PARENB = 0x100
PARITY_CRC16_PR0 = 0x2
PARITY_CRC16_PR0_CCITT = 0x4
PARITY_CRC16_PR1 = 0x3
PARITY_CRC16_PR1_CCITT = 0x5
PARITY_CRC32_PR0_CCITT = 0x6
PARITY_CRC32_PR1_CCITT = 0x7
PARITY_DEFAULT = 0x0
PARITY_NONE = 0x1
PARMRK = 0x8
PARODD = 0x200
PENDIN = 0x4000
PERF_EVENT_IOC_DISABLE = 0x2401
PERF_EVENT_IOC_ENABLE = 0x2400
PERF_EVENT_IOC_ID = 0x80082407
PERF_EVENT_IOC_PAUSE_OUTPUT = 0x40042409
PERF_EVENT_IOC_PERIOD = 0x40082404
PERF_EVENT_IOC_REFRESH = 0x2402
PERF_EVENT_IOC_RESET = 0x2403
PERF_EVENT_IOC_SET_BPF = 0x40042408
PERF_EVENT_IOC_SET_FILTER = 0x40082406
PERF_EVENT_IOC_SET_OUTPUT = 0x2405
PRIO_PGRP = 0x1
PRIO_PROCESS = 0x0
PRIO_USER = 0x2
PROT_EXEC = 0x4
PROT_GROWSDOWN = 0x1000000
PROT_GROWSUP = 0x2000000
PROT_NONE = 0x0
PROT_READ = 0x1
PROT_WRITE = 0x2
PR_CAPBSET_DROP = 0x18
PR_CAPBSET_READ = 0x17
PR_CAP_AMBIENT = 0x2f
PR_CAP_AMBIENT_CLEAR_ALL = 0x4
PR_CAP_AMBIENT_IS_SET = 0x1
PR_CAP_AMBIENT_LOWER = 0x3
PR_CAP_AMBIENT_RAISE = 0x2
PR_ENDIAN_BIG = 0x0
PR_ENDIAN_LITTLE = 0x1
PR_ENDIAN_PPC_LITTLE = 0x2
PR_FPEMU_NOPRINT = 0x1
PR_FPEMU_SIGFPE = 0x2
PR_FP_EXC_ASYNC = 0x2
PR_FP_EXC_DISABLED = 0x0
PR_FP_EXC_DIV = 0x10000
PR_FP_EXC_INV = 0x100000
PR_FP_EXC_NONRECOV = 0x1
PR_FP_EXC_OVF = 0x20000
PR_FP_EXC_PRECISE = 0x3
PR_FP_EXC_RES = 0x80000
PR_FP_EXC_SW_ENABLE = 0x80
PR_FP_EXC_UND = 0x40000
PR_FP_MODE_FR = 0x1
PR_FP_MODE_FRE = 0x2
PR_GET_CHILD_SUBREAPER = 0x25
PR_GET_DUMPABLE = 0x3
PR_GET_ENDIAN = 0x13
PR_GET_FPEMU = 0x9
PR_GET_FPEXC = 0xb
PR_GET_FP_MODE = 0x2e
PR_GET_KEEPCAPS = 0x7
PR_GET_NAME = 0x10
PR_GET_NO_NEW_PRIVS = 0x27
PR_GET_PDEATHSIG = 0x2
PR_GET_SECCOMP = 0x15
PR_GET_SECUREBITS = 0x1b
PR_GET_THP_DISABLE = 0x2a
PR_GET_TID_ADDRESS = 0x28
PR_GET_TIMERSLACK = 0x1e
PR_GET_TIMING = 0xd
PR_GET_TSC = 0x19
PR_GET_UNALIGN = 0x5
PR_MCE_KILL = 0x21
PR_MCE_KILL_CLEAR = 0x0
PR_MCE_KILL_DEFAULT = 0x2
PR_MCE_KILL_EARLY = 0x1
PR_MCE_KILL_GET = 0x22
PR_MCE_KILL_LATE = 0x0
PR_MCE_KILL_SET = 0x1
PR_MPX_DISABLE_MANAGEMENT = 0x2c
PR_MPX_ENABLE_MANAGEMENT = 0x2b
PR_SET_CHILD_SUBREAPER = 0x24
PR_SET_DUMPABLE = 0x4
PR_SET_ENDIAN = 0x14
PR_SET_FPEMU = 0xa
PR_SET_FPEXC = 0xc
PR_SET_FP_MODE = 0x2d
PR_SET_KEEPCAPS = 0x8
PR_SET_MM = 0x23
PR_SET_MM_ARG_END = 0x9
PR_SET_MM_ARG_START = 0x8
PR_SET_MM_AUXV = 0xc
PR_SET_MM_BRK = 0x7
PR_SET_MM_END_CODE = 0x2
PR_SET_MM_END_DATA = 0x4
PR_SET_MM_ENV_END = 0xb
PR_SET_MM_ENV_START = 0xa
PR_SET_MM_EXE_FILE = 0xd
PR_SET_MM_MAP = 0xe
PR_SET_MM_MAP_SIZE = 0xf
PR_SET_MM_START_BRK = 0x6
PR_SET_MM_START_CODE = 0x1
PR_SET_MM_START_DATA = 0x3
PR_SET_MM_START_STACK = 0x5
PR_SET_NAME = 0xf
PR_SET_NO_NEW_PRIVS = 0x26
PR_SET_PDEATHSIG = 0x1
PR_SET_PTRACER = 0x59616d61
PR_SET_PTRACER_ANY = 0xffffffffffffffff
PR_SET_SECCOMP = 0x16
PR_SET_SECUREBITS = 0x1c
PR_SET_THP_DISABLE = 0x29
PR_SET_TIMERSLACK = 0x1d
PR_SET_TIMING = 0xe
PR_SET_TSC = 0x1a
PR_SET_UNALIGN = 0x6
PR_TASK_PERF_EVENTS_DISABLE = 0x1f
PR_TASK_PERF_EVENTS_ENABLE = 0x20
PR_TIMING_STATISTICAL = 0x0
PR_TIMING_TIMESTAMP = 0x1
PR_TSC_ENABLE = 0x1
PR_TSC_SIGSEGV = 0x2
PR_UNALIGN_NOPRINT = 0x1
PR_UNALIGN_SIGBUS = 0x2
PTRACE_ARCH_PRCTL = 0x1e
PTRACE_ATTACH = 0x10
PTRACE_CONT = 0x7
PTRACE_DETACH = 0x11
PTRACE_EVENT_CLONE = 0x3
PTRACE_EVENT_EXEC = 0x4
PTRACE_EVENT_EXIT = 0x6
PTRACE_EVENT_FORK = 0x1
PTRACE_EVENT_SECCOMP = 0x7
PTRACE_EVENT_STOP = 0x80
PTRACE_EVENT_VFORK = 0x2
PTRACE_EVENT_VFORK_DONE = 0x5
PTRACE_GETEVENTMSG = 0x4201
PTRACE_GETFPREGS = 0xe
PTRACE_GETFPXREGS = 0x12
PTRACE_GETREGS = 0xc
PTRACE_GETREGSET = 0x4204
PTRACE_GETSIGINFO = 0x4202
PTRACE_GETSIGMASK = 0x420a
PTRACE_GET_THREAD_AREA = 0x19
PTRACE_INTERRUPT = 0x4207
PTRACE_KILL = 0x8
PTRACE_LISTEN = 0x4208
PTRACE_OLDSETOPTIONS = 0x15
PTRACE_O_EXITKILL = 0x100000
PTRACE_O_MASK = 0x3000ff
PTRACE_O_SUSPEND_SECCOMP = 0x200000
PTRACE_O_TRACECLONE = 0x8
PTRACE_O_TRACEEXEC = 0x10
PTRACE_O_TRACEEXIT = 0x40
PTRACE_O_TRACEFORK = 0x2
PTRACE_O_TRACESECCOMP = 0x80
PTRACE_O_TRACESYSGOOD = 0x1
PTRACE_O_TRACEVFORK = 0x4
PTRACE_O_TRACEVFORKDONE = 0x20
PTRACE_PEEKDATA = 0x2
PTRACE_PEEKSIGINFO = 0x4209
PTRACE_PEEKSIGINFO_SHARED = 0x1
PTRACE_PEEKTEXT = 0x1
PTRACE_PEEKUSR = 0x3
PTRACE_POKEDATA = 0x5
PTRACE_POKETEXT = 0x4
PTRACE_POKEUSR = 0x6
PTRACE_SECCOMP_GET_FILTER = 0x420c
PTRACE_SEIZE = 0x4206
PTRACE_SETFPREGS = 0xf
PTRACE_SETFPXREGS = 0x13
PTRACE_SETOPTIONS = 0x4200
PTRACE_SETREGS = 0xd
PTRACE_SETREGSET = 0x4205
PTRACE_SETSIGINFO = 0x4203
PTRACE_SETSIGMASK = 0x420b
PTRACE_SET_THREAD_AREA = 0x1a
PTRACE_SINGLEBLOCK = 0x21
PTRACE_SINGLESTEP = 0x9
PTRACE_SYSCALL = 0x18
PTRACE_SYSEMU = 0x1f
PTRACE_SYSEMU_SINGLESTEP = 0x20
PTRACE_TRACEME = 0x0
RLIMIT_AS = 0x9
RLIMIT_CORE = 0x4
RLIMIT_CPU = 0x0
RLIMIT_DATA = 0x2
RLIMIT_FSIZE = 0x1
RLIMIT_LOCKS = 0xa
RLIMIT_MEMLOCK = 0x8
RLIMIT_MSGQUEUE = 0xc
RLIMIT_NICE = 0xd
RLIMIT_NOFILE = 0x7
RLIMIT_NPROC = 0x6
RLIMIT_RSS = 0x5
RLIMIT_RTPRIO = 0xe
RLIMIT_RTTIME = 0xf
RLIMIT_SIGPENDING = 0xb
RLIMIT_STACK = 0x3
RLIM_INFINITY = 0xffffffffffffffff
RTAX_ADVMSS = 0x8
RTAX_CC_ALGO = 0x10
RTAX_CWND = 0x7
RTAX_FEATURES = 0xc
RTAX_FEATURE_ALLFRAG = 0x8
RTAX_FEATURE_ECN = 0x1
RTAX_FEATURE_MASK = 0xf
RTAX_FEATURE_SACK = 0x2
RTAX_FEATURE_TIMESTAMP = 0x4
RTAX_HOPLIMIT = 0xa
RTAX_INITCWND = 0xb
RTAX_INITRWND = 0xe
RTAX_LOCK = 0x1
RTAX_MAX = 0x10
RTAX_MTU = 0x2
RTAX_QUICKACK = 0xf
RTAX_REORDERING = 0x9
RTAX_RTO_MIN = 0xd
RTAX_RTT = 0x4
RTAX_RTTVAR = 0x5
RTAX_SSTHRESH = 0x6
RTAX_UNSPEC = 0x0
RTAX_WINDOW = 0x3
RTA_ALIGNTO = 0x4
RTA_MAX = 0x1a
RTCF_DIRECTSRC = 0x4000000
RTCF_DOREDIRECT = 0x1000000
RTCF_LOG = 0x2000000
RTCF_MASQ = 0x400000
RTCF_NAT = 0x800000
RTCF_VALVE = 0x200000
RTF_ADDRCLASSMASK = 0xf8000000
RTF_ADDRCONF = 0x40000
RTF_ALLONLINK = 0x20000
RTF_BROADCAST = 0x10000000
RTF_CACHE = 0x1000000
RTF_DEFAULT = 0x10000
RTF_DYNAMIC = 0x10
RTF_FLOW = 0x2000000
RTF_GATEWAY = 0x2
RTF_HOST = 0x4
RTF_INTERFACE = 0x40000000
RTF_IRTT = 0x100
RTF_LINKRT = 0x100000
RTF_LOCAL = 0x80000000
RTF_MODIFIED = 0x20
RTF_MSS = 0x40
RTF_MTU = 0x40
RTF_MULTICAST = 0x20000000
RTF_NAT = 0x8000000
RTF_NOFORWARD = 0x1000
RTF_NONEXTHOP = 0x200000
RTF_NOPMTUDISC = 0x4000
RTF_POLICY = 0x4000000
RTF_REINSTATE = 0x8
RTF_REJECT = 0x200
RTF_STATIC = 0x400
RTF_THROW = 0x2000
RTF_UP = 0x1
RTF_WINDOW = 0x80
RTF_XRESOLVE = 0x800
RTM_BASE = 0x10
RTM_DELACTION = 0x31
RTM_DELADDR = 0x15
RTM_DELADDRLABEL = 0x49
RTM_DELLINK = 0x11
RTM_DELMDB = 0x55
RTM_DELNEIGH = 0x1d
RTM_DELNETCONF = 0x51
RTM_DELNSID = 0x59
RTM_DELQDISC = 0x25
RTM_DELROUTE = 0x19
RTM_DELRULE = 0x21
RTM_DELTCLASS = 0x29
RTM_DELTFILTER = 0x2d
RTM_F_CLONED = 0x200
RTM_F_EQUALIZE = 0x400
RTM_F_FIB_MATCH = 0x2000
RTM_F_LOOKUP_TABLE = 0x1000
RTM_F_NOTIFY = 0x100
RTM_F_PREFIX = 0x800
RTM_GETACTION = 0x32
RTM_GETADDR = 0x16
RTM_GETADDRLABEL = 0x4a
RTM_GETANYCAST = 0x3e
RTM_GETDCB = 0x4e
RTM_GETLINK = 0x12
RTM_GETMDB = 0x56
RTM_GETMULTICAST = 0x3a
RTM_GETNEIGH = 0x1e
RTM_GETNEIGHTBL = 0x42
RTM_GETNETCONF = 0x52
RTM_GETNSID = 0x5a
RTM_GETQDISC = 0x26
RTM_GETROUTE = 0x1a
RTM_GETRULE = 0x22
RTM_GETSTATS = 0x5e
RTM_GETTCLASS = 0x2a
RTM_GETTFILTER = 0x2e
RTM_MAX = 0x63
RTM_NEWACTION = 0x30
RTM_NEWADDR = 0x14
RTM_NEWADDRLABEL = 0x48
RTM_NEWCACHEREPORT = 0x60
RTM_NEWLINK = 0x10
RTM_NEWMDB = 0x54
RTM_NEWNDUSEROPT = 0x44
RTM_NEWNEIGH = 0x1c
RTM_NEWNEIGHTBL = 0x40
RTM_NEWNETCONF = 0x50
RTM_NEWNSID = 0x58
RTM_NEWPREFIX = 0x34
RTM_NEWQDISC = 0x24
RTM_NEWROUTE = 0x18
RTM_NEWRULE = 0x20
RTM_NEWSTATS = 0x5c
RTM_NEWTCLASS = 0x28
RTM_NEWTFILTER = 0x2c
RTM_NR_FAMILIES = 0x15
RTM_NR_MSGTYPES = 0x54
RTM_SETDCB = 0x4f
RTM_SETLINK = 0x13
RTM_SETNEIGHTBL = 0x43
RTNH_ALIGNTO = 0x4
RTNH_COMPARE_MASK = 0x19
RTNH_F_DEAD = 0x1
RTNH_F_LINKDOWN = 0x10
RTNH_F_OFFLOAD = 0x8
RTNH_F_ONLINK = 0x4
RTNH_F_PERVASIVE = 0x2
RTNH_F_UNRESOLVED = 0x20
RTN_MAX = 0xb
RTPROT_BABEL = 0x2a
RTPROT_BIRD = 0xc
RTPROT_BOOT = 0x3
RTPROT_DHCP = 0x10
RTPROT_DNROUTED = 0xd
RTPROT_GATED = 0x8
RTPROT_KERNEL = 0x2
RTPROT_MROUTED = 0x11
RTPROT_MRT = 0xa
RTPROT_NTK = 0xf
RTPROT_RA = 0x9
RTPROT_REDIRECT = 0x1
RTPROT_STATIC = 0x4
RTPROT_UNSPEC = 0x0
RTPROT_XORP = 0xe
RTPROT_ZEBRA = 0xb
RT_CLASS_DEFAULT = 0xfd
RT_CLASS_LOCAL = 0xff
RT_CLASS_MAIN = 0xfe
RT_CLASS_MAX = 0xff
RT_CLASS_UNSPEC = 0x0
RUSAGE_CHILDREN = -0x1
RUSAGE_SELF = 0x0
RUSAGE_THREAD = 0x1
SCM_CREDENTIALS = 0x2
SCM_RIGHTS = 0x1
SCM_TIMESTAMP = 0x1d
SCM_TIMESTAMPING = 0x25
SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPING_PKTINFO = 0x3a
SCM_TIMESTAMPNS = 0x23
SCM_WIFI_STATUS = 0x29
SECCOMP_MODE_DISABLED = 0x0
SECCOMP_MODE_FILTER = 0x2
SECCOMP_MODE_STRICT = 0x1
SHUT_RD = 0x0
SHUT_RDWR = 0x2
SHUT_WR = 0x1
SIOCADDDLCI = 0x8980
SIOCADDMULTI = 0x8931
SIOCADDRT = 0x890b
SIOCATMARK = 0x8905
SIOCBONDCHANGEACTIVE = 0x8995
SIOCBONDENSLAVE = 0x8990
SIOCBONDINFOQUERY = 0x8994
SIOCBONDRELEASE = 0x8991
SIOCBONDSETHWADDR = 0x8992
SIOCBONDSLAVEINFOQUERY = 0x8993
SIOCBRADDBR = 0x89a0
SIOCBRADDIF = 0x89a2
SIOCBRDELBR = 0x89a1
SIOCBRDELIF = 0x89a3
SIOCDARP = 0x8953
SIOCDELDLCI = 0x8981
SIOCDELMULTI = 0x8932
SIOCDELRT = 0x890c
SIOCDEVPRIVATE = 0x89f0
SIOCDIFADDR = 0x8936
SIOCDRARP = 0x8960
SIOCETHTOOL = 0x8946
SIOCGARP = 0x8954
SIOCGHWTSTAMP = 0x89b1
SIOCGIFADDR = 0x8915
SIOCGIFBR = 0x8940
SIOCGIFBRDADDR = 0x8919
SIOCGIFCONF = 0x8912
SIOCGIFCOUNT = 0x8938
SIOCGIFDSTADDR = 0x8917
SIOCGIFENCAP = 0x8925
SIOCGIFFLAGS = 0x8913
SIOCGIFHWADDR = 0x8927
SIOCGIFINDEX = 0x8933
SIOCGIFMAP = 0x8970
SIOCGIFMEM = 0x891f
SIOCGIFMETRIC = 0x891d
SIOCGIFMTU = 0x8921
SIOCGIFNAME = 0x8910
SIOCGIFNETMASK = 0x891b
SIOCGIFPFLAGS = 0x8935
SIOCGIFSLAVE = 0x8929
SIOCGIFTXQLEN = 0x8942
SIOCGIFVLAN = 0x8982
SIOCGMIIPHY = 0x8947
SIOCGMIIREG = 0x8948
SIOCGPGRP = 0x8904
SIOCGRARP = 0x8961
SIOCGSKNS = 0x894c
SIOCGSTAMP = 0x8906
SIOCGSTAMPNS = 0x8907
SIOCINQ = 0x541b
SIOCOUTQ = 0x5411
SIOCOUTQNSD = 0x894b
SIOCPROTOPRIVATE = 0x89e0
SIOCRTMSG = 0x890d
SIOCSARP = 0x8955
SIOCSHWTSTAMP = 0x89b0
SIOCSIFADDR = 0x8916
SIOCSIFBR = 0x8941
SIOCSIFBRDADDR = 0x891a
SIOCSIFDSTADDR = 0x8918
SIOCSIFENCAP = 0x8926
SIOCSIFFLAGS = 0x8914
SIOCSIFHWADDR = 0x8924
SIOCSIFHWBROADCAST = 0x8937
SIOCSIFLINK = 0x8911
SIOCSIFMAP = 0x8971
SIOCSIFMEM = 0x8920
SIOCSIFMETRIC = 0x891e
SIOCSIFMTU = 0x8922
SIOCSIFNAME = 0x8923
SIOCSIFNETMASK = 0x891c
SIOCSIFPFLAGS = 0x8934
SIOCSIFSLAVE = 0x8930
SIOCSIFTXQLEN = 0x8943
SIOCSIFVLAN = 0x8983
SIOCSMIIREG = 0x8949
SIOCSPGRP = 0x8902
SIOCSRARP = 0x8962
SIOCWANDEV = 0x894a
SOCK_CLOEXEC = 0x80000
SOCK_DCCP = 0x6
SOCK_DGRAM = 0x2
SOCK_IOC_TYPE = 0x89
SOCK_NONBLOCK = 0x800
SOCK_PACKET = 0xa
SOCK_RAW = 0x3
SOCK_RDM = 0x4
SOCK_SEQPACKET = 0x5
SOCK_STREAM = 0x1
SOL_AAL = 0x109
SOL_ALG = 0x117
SOL_ATM = 0x108
SOL_CAIF = 0x116
SOL_CAN_BASE = 0x64
SOL_DCCP = 0x10d
SOL_DECNET = 0x105
SOL_ICMPV6 = 0x3a
SOL_IP = 0x0
SOL_IPV6 = 0x29
SOL_IRDA = 0x10a
SOL_IUCV = 0x115
SOL_KCM = 0x119
SOL_LLC = 0x10c
SOL_NETBEUI = 0x10b
SOL_NETLINK = 0x10e
SOL_NFC = 0x118
SOL_PACKET = 0x107
SOL_PNPIPE = 0x113
SOL_PPPOL2TP = 0x111
SOL_RAW = 0xff
SOL_RDS = 0x114
SOL_RXRPC = 0x110
SOL_SOCKET = 0x1
SOL_TCP = 0x6
SOL_TIPC = 0x10f
SOL_X25 = 0x106
SOMAXCONN = 0x80
SO_ACCEPTCONN = 0x1e
SO_ATTACH_BPF = 0x32
SO_ATTACH_FILTER = 0x1a
SO_ATTACH_REUSEPORT_CBPF = 0x33
SO_ATTACH_REUSEPORT_EBPF = 0x34
SO_BINDTODEVICE = 0x19
SO_BPF_EXTENSIONS = 0x30
SO_BROADCAST = 0x6
SO_BSDCOMPAT = 0xe
SO_BUSY_POLL = 0x2e
SO_CNX_ADVICE = 0x35
SO_COOKIE = 0x39
SO_DEBUG = 0x1
SO_DETACH_BPF = 0x1b
SO_DETACH_FILTER = 0x1b
SO_DOMAIN = 0x27
SO_DONTROUTE = 0x5
SO_ERROR = 0x4
SO_GET_FILTER = 0x1a
SO_INCOMING_CPU = 0x31
SO_INCOMING_NAPI_ID = 0x38
SO_KEEPALIVE = 0x9
SO_LINGER = 0xd
SO_LOCK_FILTER = 0x2c
SO_MARK = 0x24
SO_MAX_PACING_RATE = 0x2f
SO_MEMINFO = 0x37
SO_NOFCS = 0x2b
SO_NO_CHECK = 0xb
SO_OOBINLINE = 0xa
SO_PASSCRED = 0x10
SO_PASSSEC = 0x22
SO_PEEK_OFF = 0x2a
SO_PEERCRED = 0x11
SO_PEERGROUPS = 0x3b
SO_PEERNAME = 0x1c
SO_PEERSEC = 0x1f
SO_PRIORITY = 0xc
SO_PROTOCOL = 0x26
SO_RCVBUF = 0x8
SO_RCVBUFFORCE = 0x21
SO_RCVLOWAT = 0x12
SO_RCVTIMEO = 0x14
SO_REUSEADDR = 0x2
SO_REUSEPORT = 0xf
SO_RXQ_OVFL = 0x28
SO_SECURITY_AUTHENTICATION = 0x16
SO_SECURITY_ENCRYPTION_NETWORK = 0x18
SO_SECURITY_ENCRYPTION_TRANSPORT = 0x17
SO_SELECT_ERR_QUEUE = 0x2d
SO_SNDBUF = 0x7
SO_SNDBUFFORCE = 0x20
SO_SNDLOWAT = 0x13
SO_SNDTIMEO = 0x15
SO_TIMESTAMP = 0x1d
SO_TIMESTAMPING = 0x25
SO_TIMESTAMPNS = 0x23
SO_TYPE = 0x3
SO_VM_SOCKETS_BUFFER_MAX_SIZE = 0x2
SO_VM_SOCKETS_BUFFER_MIN_SIZE = 0x1
SO_VM_SOCKETS_BUFFER_SIZE = 0x0
SO_VM_SOCKETS_CONNECT_TIMEOUT = 0x6
SO_VM_SOCKETS_NONBLOCK_TXRX = 0x7
SO_VM_SOCKETS_PEER_HOST_VM_ID = 0x3
SO_VM_SOCKETS_TRUSTED = 0x5
SO_WIFI_STATUS = 0x29
SPLICE_F_GIFT = 0x8
SPLICE_F_MORE = 0x4
SPLICE_F_MOVE = 0x1
SPLICE_F_NONBLOCK = 0x2
S_BLKSIZE = 0x200
S_IEXEC = 0x40
S_IFBLK = 0x6000
S_IFCHR = 0x2000
S_IFDIR = 0x4000
S_IFIFO = 0x1000
S_IFLNK = 0xa000
S_IFMT = 0xf000
S_IFREG = 0x8000
S_IFSOCK = 0xc000
S_IREAD = 0x100
S_IRGRP = 0x20
S_IROTH = 0x4
S_IRUSR = 0x100
S_IRWXG = 0x38
S_IRWXO = 0x7
S_IRWXU = 0x1c0
S_ISGID = 0x400
S_ISUID = 0x800
S_ISVTX = 0x200
S_IWGRP = 0x10
S_IWOTH = 0x2
S_IWRITE = 0x80
S_IWUSR = 0x80
S_IXGRP = 0x8
S_IXOTH = 0x1
S_IXUSR = 0x40
TAB0 = 0x0
TAB1 = 0x800
TAB2 = 0x1000
TAB3 = 0x1800
TABDLY = 0x1800
TASKSTATS_CMD_ATTR_MAX = 0x4
TASKSTATS_CMD_MAX = 0x2
TASKSTATS_GENL_NAME = "TASKSTATS"
TASKSTATS_GENL_VERSION = 0x1
TASKSTATS_TYPE_MAX = 0x6
TASKSTATS_VERSION = 0x8
TCFLSH = 0x540b
TCGETA = 0x5405
TCGETS = 0x5401
TCGETS2 = 0x802c542a
TCGETX = 0x5432
TCIFLUSH = 0x0
TCIOFF = 0x2
TCIOFLUSH = 0x2
TCION = 0x3
TCOFLUSH = 0x1
TCOOFF = 0x0
TCOON = 0x1
TCP_CC_INFO = 0x1a
TCP_CONGESTION = 0xd
TCP_COOKIE_IN_ALWAYS = 0x1
TCP_COOKIE_MAX = 0x10
TCP_COOKIE_MIN = 0x8
TCP_COOKIE_OUT_NEVER = 0x2
TCP_COOKIE_PAIR_SIZE = 0x20
TCP_COOKIE_TRANSACTIONS = 0xf
TCP_CORK = 0x3
TCP_DEFER_ACCEPT = 0x9
TCP_FASTOPEN = 0x17
TCP_FASTOPEN_CONNECT = 0x1e
TCP_INFO = 0xb
TCP_KEEPCNT = 0x6
TCP_KEEPIDLE = 0x4
TCP_KEEPINTVL = 0x5
TCP_LINGER2 = 0x8
TCP_MAXSEG = 0x2
TCP_MAXWIN = 0xffff
TCP_MAX_WINSHIFT = 0xe
TCP_MD5SIG = 0xe
TCP_MD5SIG_MAXKEYLEN = 0x50
TCP_MSS = 0x200
TCP_MSS_DEFAULT = 0x218
TCP_MSS_DESIRED = 0x4c4
TCP_NODELAY = 0x1
TCP_NOTSENT_LOWAT = 0x19
TCP_QUEUE_SEQ = 0x15
TCP_QUICKACK = 0xc
TCP_REPAIR = 0x13
TCP_REPAIR_OPTIONS = 0x16
TCP_REPAIR_QUEUE = 0x14
TCP_REPAIR_WINDOW = 0x1d
TCP_SAVED_SYN = 0x1c
TCP_SAVE_SYN = 0x1b
TCP_SYNCNT = 0x7
TCP_S_DATA_IN = 0x4
TCP_S_DATA_OUT = 0x8
TCP_THIN_DUPACK = 0x11
TCP_THIN_LINEAR_TIMEOUTS = 0x10
TCP_TIMESTAMP = 0x18
TCP_USER_TIMEOUT = 0x12
TCP_WINDOW_CLAMP = 0xa
TCSAFLUSH = 0x2
TCSBRK = 0x5409
TCSBRKP = 0x5425
TCSETA = 0x5406
TCSETAF = 0x5408
TCSETAW = 0x5407
TCSETS = 0x5402
TCSETS2 = 0x402c542b
TCSETSF = 0x5404
TCSETSF2 = 0x402c542d
TCSETSW = 0x5403
TCSETSW2 = 0x402c542c
TCSETX = 0x5433
TCSETXF = 0x5434
TCSETXW = 0x5435
TCXONC = 0x540a
TIOCCBRK = 0x5428
TIOCCONS = 0x541d
TIOCEXCL = 0x540c
TIOCGDEV = 0x80045432
TIOCGETD = 0x5424
TIOCGEXCL = 0x80045440
TIOCGICOUNT = 0x545d
TIOCGLCKTRMIOS = 0x5456
TIOCGPGRP = 0x540f
TIOCGPKT = 0x80045438
TIOCGPTLCK = 0x80045439
TIOCGPTN = 0x80045430
TIOCGPTPEER = 0x5441
TIOCGRS485 = 0x542e
TIOCGSERIAL = 0x541e
TIOCGSID = 0x5429
TIOCGSOFTCAR = 0x5419
TIOCGWINSZ = 0x5413
TIOCINQ = 0x541b
TIOCLINUX = 0x541c
TIOCMBIC = 0x5417
TIOCMBIS = 0x5416
TIOCMGET = 0x5415
TIOCMIWAIT = 0x545c
TIOCMSET = 0x5418
TIOCM_CAR = 0x40
TIOCM_CD = 0x40
TIOCM_CTS = 0x20
TIOCM_DSR = 0x100
TIOCM_DTR = 0x2
TIOCM_LE = 0x1
TIOCM_RI = 0x80
TIOCM_RNG = 0x80
TIOCM_RTS = 0x4
TIOCM_SR = 0x10
TIOCM_ST = 0x8
TIOCNOTTY = 0x5422
TIOCNXCL = 0x540d
TIOCOUTQ = 0x5411
TIOCPKT = 0x5420
TIOCPKT_DATA = 0x0
TIOCPKT_DOSTOP = 0x20
TIOCPKT_FLUSHREAD = 0x1
TIOCPKT_FLUSHWRITE = 0x2
TIOCPKT_IOCTL = 0x40
TIOCPKT_NOSTOP = 0x10
TIOCPKT_START = 0x8
TIOCPKT_STOP = 0x4
TIOCSBRK = 0x5427
TIOCSCTTY = 0x540e
TIOCSERCONFIG = 0x5453
TIOCSERGETLSR = 0x5459
TIOCSERGETMULTI = 0x545a
TIOCSERGSTRUCT = 0x5458
TIOCSERGWILD = 0x5454
TIOCSERSETMULTI = 0x545b
TIOCSERSWILD = 0x5455
TIOCSER_TEMT = 0x1
TIOCSETD = 0x5423
TIOCSIG = 0x40045436
TIOCSLCKTRMIOS = 0x5457
TIOCSPGRP = 0x5410
TIOCSPTLCK = 0x40045431
TIOCSRS485 = 0x542f
TIOCSSERIAL = 0x541f
TIOCSSOFTCAR = 0x541a
TIOCSTI = 0x5412
TIOCSWINSZ = 0x5414
TIOCVHANGUP = 0x5437
TOSTOP = 0x100
TS_COMM_LEN = 0x20
TUNATTACHFILTER = 0x401054d5
TUNDETACHFILTER = 0x401054d6
TUNGETFEATURES = 0x800454cf
TUNGETFILTER = 0x801054db
TUNGETIFF = 0x800454d2
TUNGETSNDBUF = 0x800454d3
TUNGETVNETBE = 0x800454df
TUNGETVNETHDRSZ = 0x800454d7
TUNGETVNETLE = 0x800454dd
TUNSETDEBUG = 0x400454c9
TUNSETGROUP = 0x400454ce
TUNSETIFF = 0x400454ca
TUNSETIFINDEX = 0x400454da
TUNSETLINK = 0x400454cd
TUNSETNOCSUM = 0x400454c8
TUNSETOFFLOAD = 0x400454d0
TUNSETOWNER = 0x400454cc
TUNSETPERSIST = 0x400454cb
TUNSETQUEUE = 0x400454d9
TUNSETSNDBUF = 0x400454d4
TUNSETTXFILTER = 0x400454d1
TUNSETVNETBE = 0x400454de
TUNSETVNETHDRSZ = 0x400454d8
TUNSETVNETLE = 0x400454dc
UMOUNT_NOFOLLOW = 0x8
UTIME_NOW = 0x3fffffff
UTIME_OMIT = 0x3ffffffe
VDISCARD = 0xd
VEOF = 0x4
VEOL = 0xb
VEOL2 = 0x10
VERASE = 0x2
VINTR = 0x0
VKILL = 0x3
VLNEXT = 0xf
VMADDR_CID_ANY = 0xffffffff
VMADDR_CID_HOST = 0x2
VMADDR_CID_HYPERVISOR = 0x0
VMADDR_CID_RESERVED = 0x1
VMADDR_PORT_ANY = 0xffffffff
VMIN = 0x6
VM_SOCKETS_INVALID_VERSION = 0xffffffff
VQUIT = 0x1
VREPRINT = 0xc
VSTART = 0x8
VSTOP = 0x9
VSUSP = 0xa
VSWTC = 0x7
VT0 = 0x0
VT1 = 0x4000
VTDLY = 0x4000
VTIME = 0x5
VWERASE = 0xe
WALL = 0x40000000
WCLONE = 0x80000000
WCONTINUED = 0x8
WDIOC_GETBOOTSTATUS = 0x80045702
WDIOC_GETPRETIMEOUT = 0x80045709
WDIOC_GETSTATUS = 0x80045701
WDIOC_GETSUPPORT = 0x80285700
WDIOC_GETTEMP = 0x80045703
WDIOC_GETTIMELEFT = 0x8004570a
WDIOC_GETTIMEOUT = 0x80045707
WDIOC_KEEPALIVE = 0x80045705
WDIOC_SETOPTIONS = 0x80045704
WDIOC_SETPRETIMEOUT = 0xc0045708
WDIOC_SETTIMEOUT = 0xc0045706
WEXITED = 0x4
WNOHANG = 0x1
WNOTHREAD = 0x20000000
WNOWAIT = 0x1000000
WORDSIZE = 0x40
WSTOPPED = 0x2
WUNTRACED = 0x2
XATTR_CREATE = 0x1
XATTR_REPLACE = 0x2
XCASE = 0x4
XTABS = 0x1800
)
// Errors
const (
E2BIG = syscall.Errno(0x7)
EACCES = syscall.Errno(0xd)
EADDRINUSE = syscall.Errno(0x62)
EADDRNOTAVAIL = syscall.Errno(0x63)
EADV = syscall.Errno(0x44)
EAFNOSUPPORT = syscall.Errno(0x61)
EAGAIN = syscall.Errno(0xb)
EALREADY = syscall.Errno(0x72)
EBADE = syscall.Errno(0x34)
EBADF = syscall.Errno(0x9)
EBADFD = syscall.Errno(0x4d)
EBADMSG = syscall.Errno(0x4a)
EBADR = syscall.Errno(0x35)
EBADRQC = syscall.Errno(0x38)
EBADSLT = syscall.Errno(0x39)
EBFONT = syscall.Errno(0x3b)
EBUSY = syscall.Errno(0x10)
ECANCELED = syscall.Errno(0x7d)
ECHILD = syscall.Errno(0xa)
ECHRNG = syscall.Errno(0x2c)
ECOMM = syscall.Errno(0x46)
ECONNABORTED = syscall.Errno(0x67)
ECONNREFUSED = syscall.Errno(0x6f)
ECONNRESET = syscall.Errno(0x68)
EDEADLK = syscall.Errno(0x23)
EDEADLOCK = syscall.Errno(0x23)
EDESTADDRREQ = syscall.Errno(0x59)
EDOM = syscall.Errno(0x21)
EDOTDOT = syscall.Errno(0x49)
EDQUOT = syscall.Errno(0x7a)
EEXIST = syscall.Errno(0x11)
EFAULT = syscall.Errno(0xe)
EFBIG = syscall.Errno(0x1b)
EHOSTDOWN = syscall.Errno(0x70)
EHOSTUNREACH = syscall.Errno(0x71)
EHWPOISON = syscall.Errno(0x85)
EIDRM = syscall.Errno(0x2b)
EILSEQ = syscall.Errno(0x54)
EINPROGRESS = syscall.Errno(0x73)
EINTR = syscall.Errno(0x4)
EINVAL = syscall.Errno(0x16)
EIO = syscall.Errno(0x5)
EISCONN = syscall.Errno(0x6a)
EISDIR = syscall.Errno(0x15)
EISNAM = syscall.Errno(0x78)
EKEYEXPIRED = syscall.Errno(0x7f)
EKEYREJECTED = syscall.Errno(0x81)
EKEYREVOKED = syscall.Errno(0x80)
EL2HLT = syscall.Errno(0x33)
EL2NSYNC = syscall.Errno(0x2d)
EL3HLT = syscall.Errno(0x2e)
EL3RST = syscall.Errno(0x2f)
ELIBACC = syscall.Errno(0x4f)
ELIBBAD = syscall.Errno(0x50)
ELIBEXEC = syscall.Errno(0x53)
ELIBMAX = syscall.Errno(0x52)
ELIBSCN = syscall.Errno(0x51)
ELNRNG = syscall.Errno(0x30)
ELOOP = syscall.Errno(0x28)
EMEDIUMTYPE = syscall.Errno(0x7c)
EMFILE = syscall.Errno(0x18)
EMLINK = syscall.Errno(0x1f)
EMSGSIZE = syscall.Errno(0x5a)
EMULTIHOP = syscall.Errno(0x48)
ENAMETOOLONG = syscall.Errno(0x24)
ENAVAIL = syscall.Errno(0x77)
ENETDOWN = syscall.Errno(0x64)
ENETRESET = syscall.Errno(0x66)
ENETUNREACH = syscall.Errno(0x65)
ENFILE = syscall.Errno(0x17)
ENOANO = syscall.Errno(0x37)
ENOBUFS = syscall.Errno(0x69)
ENOCSI = syscall.Errno(0x32)
ENODATA = syscall.Errno(0x3d)
ENODEV = syscall.Errno(0x13)
ENOENT = syscall.Errno(0x2)
ENOEXEC = syscall.Errno(0x8)
ENOKEY = syscall.Errno(0x7e)
ENOLCK = syscall.Errno(0x25)
ENOLINK = syscall.Errno(0x43)
ENOMEDIUM = syscall.Errno(0x7b)
ENOMEM = syscall.Errno(0xc)
ENOMSG = syscall.Errno(0x2a)
ENONET = syscall.Errno(0x40)
ENOPKG = syscall.Errno(0x41)
ENOPROTOOPT = syscall.Errno(0x5c)
ENOSPC = syscall.Errno(0x1c)
ENOSR = syscall.Errno(0x3f)
ENOSTR = syscall.Errno(0x3c)
ENOSYS = syscall.Errno(0x26)
ENOTBLK = syscall.Errno(0xf)
ENOTCONN = syscall.Errno(0x6b)
ENOTDIR = syscall.Errno(0x14)
ENOTEMPTY = syscall.Errno(0x27)
ENOTNAM = syscall.Errno(0x76)
ENOTRECOVERABLE = syscall.Errno(0x83)
ENOTSOCK = syscall.Errno(0x58)
ENOTSUP = syscall.Errno(0x5f)
ENOTTY = syscall.Errno(0x19)
ENOTUNIQ = syscall.Errno(0x4c)
ENXIO = syscall.Errno(0x6)
EOPNOTSUPP = syscall.Errno(0x5f)
EOVERFLOW = syscall.Errno(0x4b)
EOWNERDEAD = syscall.Errno(0x82)
EPERM = syscall.Errno(0x1)
EPFNOSUPPORT = syscall.Errno(0x60)
EPIPE = syscall.Errno(0x20)
EPROTO = syscall.Errno(0x47)
EPROTONOSUPPORT = syscall.Errno(0x5d)
EPROTOTYPE = syscall.Errno(0x5b)
ERANGE = syscall.Errno(0x22)
EREMCHG = syscall.Errno(0x4e)
EREMOTE = syscall.Errno(0x42)
EREMOTEIO = syscall.Errno(0x79)
ERESTART = syscall.Errno(0x55)
ERFKILL = syscall.Errno(0x84)
EROFS = syscall.Errno(0x1e)
ESHUTDOWN = syscall.Errno(0x6c)
ESOCKTNOSUPPORT = syscall.Errno(0x5e)
ESPIPE = syscall.Errno(0x1d)
ESRCH = syscall.Errno(0x3)
ESRMNT = syscall.Errno(0x45)
ESTALE = syscall.Errno(0x74)
ESTRPIPE = syscall.Errno(0x56)
ETIME = syscall.Errno(0x3e)
ETIMEDOUT = syscall.Errno(0x6e)
ETOOMANYREFS = syscall.Errno(0x6d)
ETXTBSY = syscall.Errno(0x1a)
EUCLEAN = syscall.Errno(0x75)
EUNATCH = syscall.Errno(0x31)
EUSERS = syscall.Errno(0x57)
EWOULDBLOCK = syscall.Errno(0xb)
EXDEV = syscall.Errno(0x12)
EXFULL = syscall.Errno(0x36)
)
// Signals
const (
SIGABRT = syscall.Signal(0x6)
SIGALRM = syscall.Signal(0xe)
SIGBUS = syscall.Signal(0x7)
SIGCHLD = syscall.Signal(0x11)
SIGCLD = syscall.Signal(0x11)
SIGCONT = syscall.Signal(0x12)
SIGFPE = syscall.Signal(0x8)
SIGHUP = syscall.Signal(0x1)
SIGILL = syscall.Signal(0x4)
SIGINT = syscall.Signal(0x2)
SIGIO = syscall.Signal(0x1d)
SIGIOT = syscall.Signal(0x6)
SIGKILL = syscall.Signal(0x9)
SIGPIPE = syscall.Signal(0xd)
SIGPOLL = syscall.Signal(0x1d)
SIGPROF = syscall.Signal(0x1b)
SIGPWR = syscall.Signal(0x1e)
SIGQUIT = syscall.Signal(0x3)
SIGSEGV = syscall.Signal(0xb)
SIGSTKFLT = syscall.Signal(0x10)
SIGSTOP = syscall.Signal(0x13)
SIGSYS = syscall.Signal(0x1f)
SIGTERM = syscall.Signal(0xf)
SIGTRAP = syscall.Signal(0x5)
SIGTSTP = syscall.Signal(0x14)
SIGTTIN = syscall.Signal(0x15)
SIGTTOU = syscall.Signal(0x16)
SIGURG = syscall.Signal(0x17)
SIGUSR1 = syscall.Signal(0xa)
SIGUSR2 = syscall.Signal(0xc)
SIGVTALRM = syscall.Signal(0x1a)
SIGWINCH = syscall.Signal(0x1c)
SIGXCPU = syscall.Signal(0x18)
SIGXFSZ = syscall.Signal(0x19)
)
// Error table
var errors = [...]string{
1: "operation not permitted",
2: "no such file or directory",
3: "no such process",
4: "interrupted system call",
5: "input/output error",
6: "no such device or address",
7: "argument list too long",
8: "exec format error",
9: "bad file descriptor",
10: "no child processes",
11: "resource temporarily unavailable",
12: "cannot allocate memory",
13: "permission denied",
14: "bad address",
15: "block device required",
16: "device or resource busy",
17: "file exists",
18: "invalid cross-device link",
19: "no such device",
20: "not a directory",
21: "is a directory",
22: "invalid argument",
23: "too many open files in system",
24: "too many open files",
25: "inappropriate ioctl for device",
26: "text file busy",
27: "file too large",
28: "no space left on device",
29: "illegal seek",
30: "read-only file system",
31: "too many links",
32: "broken pipe",
33: "numerical argument out of domain",
34: "numerical result out of range",
35: "resource deadlock avoided",
36: "file name too long",
37: "no locks available",
38: "function not implemented",
39: "directory not empty",
40: "too many levels of symbolic links",
42: "no message of desired type",
43: "identifier removed",
44: "channel number out of range",
45: "level 2 not synchronized",
46: "level 3 halted",
47: "level 3 reset",
48: "link number out of range",
49: "protocol driver not attached",
50: "no CSI structure available",
51: "level 2 halted",
52: "invalid exchange",
53: "invalid request descriptor",
54: "exchange full",
55: "no anode",
56: "invalid request code",
57: "invalid slot",
59: "bad font file format",
60: "device not a stream",
61: "no data available",
62: "timer expired",
63: "out of streams resources",
64: "machine is not on the network",
65: "package not installed",
66: "object is remote",
67: "link has been severed",
68: "advertise error",
69: "srmount error",
70: "communication error on send",
71: "protocol error",
72: "multihop attempted",
73: "RFS specific error",
74: "bad message",
75: "value too large for defined data type",
76: "name not unique on network",
77: "file descriptor in bad state",
78: "remote address changed",
79: "can not access a needed shared library",
80: "accessing a corrupted shared library",
81: ".lib section in a.out corrupted",
82: "attempting to link in too many shared libraries",
83: "cannot exec a shared library directly",
84: "invalid or incomplete multibyte or wide character",
85: "interrupted system call should be restarted",
86: "streams pipe error",
87: "too many users",
88: "socket operation on non-socket",
89: "destination address required",
90: "message too long",
91: "protocol wrong type for socket",
92: "protocol not available",
93: "protocol not supported",
94: "socket type not supported",
95: "operation not supported",
96: "protocol family not supported",
97: "address family not supported by protocol",
98: "address already in use",
99: "cannot assign requested address",
100: "network is down",
101: "network is unreachable",
102: "network dropped connection on reset",
103: "software caused connection abort",
104: "connection reset by peer",
105: "no buffer space available",
106: "transport endpoint is already connected",
107: "transport endpoint is not connected",
108: "cannot send after transport endpoint shutdown",
109: "too many references: cannot splice",
110: "connection timed out",
111: "connection refused",
112: "host is down",
113: "no route to host",
114: "operation already in progress",
115: "operation now in progress",
116: "stale file handle",
117: "structure needs cleaning",
118: "not a XENIX named type file",
119: "no XENIX semaphores available",
120: "is a named type file",
121: "remote I/O error",
122: "disk quota exceeded",
123: "no medium found",
124: "wrong medium type",
125: "operation canceled",
126: "required key not available",
127: "key has expired",
128: "key has been revoked",
129: "key was rejected by service",
130: "owner died",
131: "state not recoverable",
132: "operation not possible due to RF-kill",
133: "memory page has hardware error",
}
// Signal table
var signals = [...]string{
1: "hangup",
2: "interrupt",
3: "quit",
4: "illegal instruction",
5: "trace/breakpoint trap",
6: "aborted",
7: "bus error",
8: "floating point exception",
9: "killed",
10: "user defined signal 1",
11: "segmentation fault",
12: "user defined signal 2",
13: "broken pipe",
14: "alarm clock",
15: "terminated",
16: "stack fault",
17: "child exited",
18: "continued",
19: "stopped (signal)",
20: "stopped",
21: "stopped (tty input)",
22: "stopped (tty output)",
23: "urgent I/O condition",
24: "CPU time limit exceeded",
25: "file size limit exceeded",
26: "virtual timer expired",
27: "profiling timer expired",
28: "window changed",
29: "I/O possible",
30: "power failure",
31: "bad system call",
}
| {
"pile_set_name": "Github"
} |
#region License
/*
* Copyright (C) 1999-2020 John Källén.
*
* 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, 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; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#endregion
using Reko.Core;
using Reko.Core.Expressions;
using Reko.Core.Machine;
using Reko.Core.Operators;
using Reko.Core.Rtl;
using Reko.Core.Serialization;
using Reko.Core.Types;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Reko.Arch.Mips
{
public partial class MipsRewriter
{
private void RewriteBgezal(MipsInstruction instr)
{
// The bgezal r0,XXXX instruction is aliased to bal (branch and link, or fn call)
// We handle that case here explicitly.
if (((RegisterOperand)instr.Operands[0]).Register.Number == 0)
{
// A special case is when we call to the location after
// the delay slot. This is an idiom to capture the
// program counter in the la register.
var dst = ((AddressOperand)instr.Operands[1]).Address;
if (instr.Address.ToLinear() + 8 == dst.ToLinear())
{
iclass = InstrClass.Linear;
var ra = binder.EnsureRegister(arch.LinkRegister);
m.Assign(ra, dst);
}
else
{
m.CallD(dst, 0);
}
return;
}
RewriteBranch0(instr, m.Ge, false);
}
private void RewriteBb(MipsInstruction instr, Func<Expression, Expression> condOp)
{
var reg = RewriteOperand0(instr.Operands[0]);
var bit = RewriteOperand(instr.Operands[1]);
var addr = (Address) RewriteOperand0(instr.Operands[2]);
var test = condOp(host.PseudoProcedure("__bit", PrimitiveType.Bool, reg, bit));
m.Branch(test, addr, instr.InstructionClass);
}
private void RewriteBranch(MipsInstruction instr, Func<Expression, Expression, Expression> condOp, bool link)
{
if (!link)
{
var reg1 = RewriteOperand0(instr.Operands[0]);
var reg2 = RewriteOperand0(instr.Operands[1]);
var addr = (Address)RewriteOperand0(instr.Operands[2]);
var cond = condOp(reg1, reg2);
if (condOp == m.Eq &&
((RegisterOperand)instr.Operands[0]).Register ==
((RegisterOperand)instr.Operands[1]).Register)
{
m.Goto(addr, instr.InstructionClass & ~InstrClass.Conditional);
}
else
{
m.Branch(cond, addr, instr.InstructionClass);
}
}
else
{
throw new NotImplementedException("Linked branches not implemented yet.");
}
}
private void RewriteBranch0(MipsInstruction instr, Func<Expression, Expression, Expression> condOp, bool link)
{
if (link)
{
m.Assign(
binder.EnsureRegister(arch.LinkRegister),
instr.Address + 8);
}
var reg = RewriteOperand0(instr.Operands[0]);
var addr = (Address)RewriteOperand0(instr.Operands[1]);
if (reg is Constant)
{
// r0 has been replaced with '0'.
if (condOp == m.Lt)
{
iclass = InstrClass.Linear;
return; // Branch will never be taken
}
}
var cond = condOp(reg, Constant.Zero(reg.DataType));
m.Branch(cond, addr, instr.InstructionClass);
}
private void RewriteBranchImm(MipsInstruction instr, Func<Expression, Expression, Expression> condOp, bool link)
{
if (link)
{
m.Assign(
binder.EnsureRegister(arch.LinkRegister),
instr.Address + 8);
}
var reg = RewriteOperand0(instr.Operands[0]);
var imm = RewriteOperand(instr.Operands[1]);
var addr = (Address) RewriteOperand0(instr.Operands[2]);
var cond = condOp(reg, imm);
m.Branch(cond, addr, instr.InstructionClass);
}
private void RewriteBranchLikely(MipsInstruction instr, Func<Expression, Expression, Expression> condOp)
{
var reg1 = RewriteOperand0(instr.Operands[0]);
var reg2 = RewriteOperand0(instr.Operands[1]);
var addr = (Address)RewriteOperand0(instr.Operands[2]);
var cond = condOp(reg1, reg2);
if (condOp == m.Eq &&
((RegisterOperand)instr.Operands[0]).Register ==
((RegisterOperand)instr.Operands[1]).Register)
{
m.GotoD(addr);
}
else
{
m.Branch(cond, addr, InstrClass.ConditionalTransfer | InstrClass.Delay);
}
}
private void RewriteBranchConditional1(MipsInstruction instr, bool opTrue)
{
var cond = RewriteOperand0(instr.Operands[0]);
if (!opTrue)
cond = m.Not(cond);
var addr = (Address)RewriteOperand0(instr.Operands[1]);
iclass = InstrClass.ConditionalTransfer | InstrClass.Delay;
m.Branch(cond, addr, iclass);
}
private void RewriteCall(MipsInstruction instr)
{
var dst = RewriteOperand0(instr.Operands[0]);
m.Call(dst, 0, instr.InstructionClass);
}
private void RewriteEret(MipsInstruction instr)
{
// Return from exception doesn't seem to modify any
// GPRs (as well it shouldn't).
// MIPS manual says it does _not_ have a delay slot.
m.Return(0, 0);
}
private void RewriteJal(MipsInstruction instr)
{
//$TODO: if we want explicit representation of the continuation of call
// use the line below
//emitter.Assign( frame.EnsureRegister(Registers.ra), instr.Address + 8);
m.CallD(RewriteOperand0(instr.Operands[0]), 0);
}
private void RewriteJalr(MipsInstruction instr)
{
//$TODO: if we want explicit representation of the continuation of call
// use the line below
//emitter.Assign( frame.EnsureRegister(Registers.ra), instr.Address + 8);
var dst = RewriteOperand0(instr.Operands[1]);
var lr = ((RegisterOperand)instr.Operands[0]).Register;
if (lr == arch.LinkRegister)
{
m.Call(dst, 0, instr.InstructionClass);
return;
}
else
{
m.Assign(binder.EnsureRegister(lr), instr.Address + 8);
m.Goto(dst, instr.InstructionClass & ~InstrClass.Call);
}
}
private void RewriteJr(MipsInstruction instr)
{
var dst = RewriteOperand(instr.Operands[0]);
var reg = (RegisterStorage)((Identifier)dst).Storage;
if (reg == arch.LinkRegister)
{
m.Return(0, 0, iclass);
}
else
{
m.Goto(dst, iclass);
}
}
private void RewriteJump(MipsInstruction instr)
{
var dst = RewriteOperand0(instr.Operands[0]);
m.Goto(dst, instr.InstructionClass);
}
private void RewriteMoveBalc(MipsInstruction instr)
{
var dst = RewriteOperand0(instr.Operands[0]);
var src = RewriteOperand0(instr.Operands[1]);
m.Assign(dst, src);
var addr = RewriteOperand(instr.Operands[2]);
m.Call(addr, 0);
}
private void RewriteSigrie(MipsInstruction instr)
{
var chr = new ProcedureCharacteristics
{
Terminates = true
};
m.SideEffect(host.PseudoProcedure("__reserved_instruction", chr,
VoidType.Instance, RewriteOperand(instr.Operands[0])));
}
}
}
| {
"pile_set_name": "Github"
} |
//C- -*- C++ -*-
//C- -------------------------------------------------------------------
//C- DjVuLibre-3.5
//C- Copyright (c) 2002 Leon Bottou and Yann Le Cun.
//C- Copyright (c) 2001 AT&T
//C-
//C- This software is subject to, and may be distributed under, the
//C- GNU General Public License, either Version 2 of the license,
//C- or (at your option) any later version. The license should have
//C- accompanied the software or you may obtain a copy of the license
//C- from the Free Software Foundation at http://www.fsf.org .
//C-
//C- This program is distributed in the hope that it will be useful,
//C- but WITHOUT ANY WARRANTY; without even the implied warranty of
//C- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//C- GNU General Public License for more details.
//C-
//C- DjVuLibre-3.5 is derived from the DjVu(r) Reference Library from
//C- Lizardtech Software. Lizardtech Software has authorized us to
//C- replace the original DjVu(r) Reference Library notice by the following
//C- text (see doc/lizard2002.djvu and doc/lizardtech2007.djvu):
//C-
//C- ------------------------------------------------------------------
//C- | DjVu (r) Reference Library (v. 3.5)
//C- | Copyright (c) 1999-2001 LizardTech, Inc. All Rights Reserved.
//C- | The DjVu Reference Library is protected by U.S. Pat. No.
//C- | 6,058,214 and patents pending.
//C- |
//C- | This software is subject to, and may be distributed under, the
//C- | GNU General Public License, either Version 2 of the license,
//C- | or (at your option) any later version. The license should have
//C- | accompanied the software or you may obtain a copy of the license
//C- | from the Free Software Foundation at http://www.fsf.org .
//C- |
//C- | The computer code originally released by LizardTech under this
//C- | license and unmodified by other parties is deemed "the LIZARDTECH
//C- | ORIGINAL CODE." Subject to any third party intellectual property
//C- | claims, LizardTech grants recipient a worldwide, royalty-free,
//C- | non-exclusive license to make, use, sell, or otherwise dispose of
//C- | the LIZARDTECH ORIGINAL CODE or of programs derived from the
//C- | LIZARDTECH ORIGINAL CODE in compliance with the terms of the GNU
//C- | General Public License. This grant only confers the right to
//C- | infringe patent claims underlying the LIZARDTECH ORIGINAL CODE to
//C- | the extent such infringement is reasonably necessary to enable
//C- | recipient to make, have made, practice, sell, or otherwise dispose
//C- | of the LIZARDTECH ORIGINAL CODE (or portions thereof) and not to
//C- | any greater extent that may be necessary to utilize further
//C- | modifications or combinations.
//C- |
//C- | The LIZARDTECH ORIGINAL CODE is provided "AS IS" WITHOUT WARRANTY
//C- | OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
//C- | TO ANY WARRANTY OF NON-INFRINGEMENT, OR ANY IMPLIED WARRANTY OF
//C- | MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
//C- +------------------------------------------------------------------
#ifndef _GOS_H_
#define _GOS_H_
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#if NEED_GNUG_PRAGMAS
# pragma interface
#endif
/** @name GOS.h
Files #"GOS.h"# and #"GOS.cpp"# implement operating system
dependent functions with a unified interface. All these functions
are implemented as static member of class \Ref{GOS}.
Functions are provided for testing the presence of a file or a directory
(\Ref{GOS::is_file}, \Ref{GOS::is_dir}), for manipulating file and directory names
(\Ref{GOS::dirname}, \Ref{GOS::basename}, \Ref{GOS::expand_name},
for obtaining and changing the current directory (\Ref{GOS::cwd}),
for converting between file names and urls (\Ref{GOS::filename_to_url},
\Ref{GOS::url_to_filename}), and for counting time (\Ref{GOS::ticks},
\Ref{GOS::sleep}).
@memo
Operating System dependent functions.
@author
L\'eon Bottou <[email protected]> -- Initial implementation
*/
//@{
#include "DjVuGlobal.h"
#include "GString.h"
#ifdef HAVE_NAMESPACES
namespace DJVU {
# ifdef NOT_DEFINED // Just to fool emacs c++ mode
}
#endif
#endif
class GURL;
/** Operating System dependent functions. */
class DJVUAPI GOS
{
public:
// -----------------------------------------
// Functions for dealing with filenames
// -----------------------------------------
/** Returns the last component of file name #filename#. If the filename
suffix matches argument #suffix#, the filename suffix is removed. This
function works like the unix command #/bin/basename#, but also supports
the naming conventions of other operating systems. */
static GUTF8String basename(const GUTF8String &filename, const char *suffix=0);
/** Sets and returns the current working directory.
When argument #dirname# is specified, the current directory is changed
to #dirname#. This function always returns the fully qualified name
of the current directory. */
static GUTF8String cwd(const GUTF8String &dirname=GUTF8String());
// -----------------------------------------
// Functions for measuring time
// -----------------------------------------
/** Returns a number of elapsed milliseconds. This number counts elapsed
milliseconds since a operating system dependent date. This function is
useful for timing code. */
static unsigned long ticks();
/** Sleeps during the specified time expressed in milliseconds.
Other threads can run while the calling thread sleeps. */
static void sleep(int milliseconds);
/// Read the named variable from the environment, and converts it to UTF8.
static GUTF8String getenv(const GUTF8String &name);
#if 0
// -------------------------------------------
// Functions for converting filenames and urls
// -------------------------------------------
/** Encodes all reserved characters, so that the #filename# can be
used inside a URL. Every reserved character is encoded using escape
sequence in the form of #%XX#. The legal characters are alphanumeric and
#$-_.+!*'(),:#.
Use \Ref{decode_reserved}() to convert the URL back to the filename. */
// static GString encode_reserved(const char * filename);
static GString encode_mbcs_reserved(const char * filename);/*MBCS*/
#endif
};
//@}
// ------------
#ifdef HAVE_NAMESPACES
}
# ifndef NOT_USING_DJVU_NAMESPACE
using namespace DJVU;
# endif
#endif
#endif
| {
"pile_set_name": "Github"
} |
后台 springMVC + mybatis/hibernate
前端 requireJS + bootstrap + jQuery + artTemplate
数据库 mysql | {
"pile_set_name": "Github"
} |
# Lines starting with '#' and sections without content
# are not displayed by a call to 'details'
#
[Website]
http://www.spaziogames.it/recensioni_videogiochi/console_pc/12318/battlefield-3.aspx
[filters]
http://adv2.spaziogames.it/index.ashx?f=300&i=0&r=68963
http://adv2.spaziogames.it/index.ashx?f=stripe&i=426&r=34540
[other]
# Any other details
[comments]
fanboy | {
"pile_set_name": "Github"
} |
/* Default target hook functions.
Copyright (C) 2003-2018 Free Software Foundation, Inc.
This file is part of GCC.
GCC 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, or (at your option) any later
version.
GCC 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 GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#ifndef GCC_TARGHOOKS_H
#define GCC_TARGHOOKS_H
extern bool default_legitimate_address_p (machine_mode, rtx, bool);
extern void default_external_libcall (rtx);
extern rtx default_legitimize_address (rtx, rtx, machine_mode);
extern bool default_legitimize_address_displacement (rtx *, rtx *,
poly_int64, machine_mode);
extern bool default_const_not_ok_for_debug_p (rtx);
extern int default_unspec_may_trap_p (const_rtx, unsigned);
extern machine_mode default_promote_function_mode (const_tree, machine_mode,
int *, const_tree, int);
extern machine_mode default_promote_function_mode_always_promote
(const_tree, machine_mode, int *, const_tree, int);
extern machine_mode default_cc_modes_compatible (machine_mode,
machine_mode);
extern bool default_return_in_memory (const_tree, const_tree);
extern rtx default_expand_builtin_saveregs (void);
extern void default_setup_incoming_varargs (cumulative_args_t, machine_mode, tree, int *, int);
extern rtx default_builtin_setjmp_frame_value (void);
extern bool default_pretend_outgoing_varargs_named (cumulative_args_t);
extern scalar_int_mode default_eh_return_filter_mode (void);
extern scalar_int_mode default_libgcc_cmp_return_mode (void);
extern scalar_int_mode default_libgcc_shift_count_mode (void);
extern scalar_int_mode default_unwind_word_mode (void);
extern unsigned HOST_WIDE_INT default_shift_truncation_mask
(machine_mode);
extern unsigned int default_min_divisions_for_recip_mul (machine_mode);
extern int default_mode_rep_extended (scalar_int_mode, scalar_int_mode);
extern tree default_stack_protect_guard (void);
extern tree default_external_stack_protect_fail (void);
extern tree default_hidden_stack_protect_fail (void);
extern machine_mode default_mode_for_suffix (char);
extern tree default_cxx_guard_type (void);
extern tree default_cxx_get_cookie_size (tree);
extern bool hook_pass_by_reference_must_pass_in_stack
(cumulative_args_t, machine_mode mode, const_tree, bool);
extern bool hook_callee_copies_named
(cumulative_args_t ca, machine_mode, const_tree, bool);
extern void default_print_operand (FILE *, rtx, int);
extern void default_print_operand_address (FILE *, machine_mode, rtx);
extern bool default_print_operand_punct_valid_p (unsigned char);
extern tree default_mangle_assembler_name (const char *);
extern bool default_scalar_mode_supported_p (scalar_mode);
extern bool default_libgcc_floating_mode_supported_p (scalar_float_mode);
extern opt_scalar_float_mode default_floatn_mode (int, bool);
extern bool default_floatn_builtin_p (int);
extern bool targhook_words_big_endian (void);
extern bool targhook_float_words_big_endian (void);
extern bool default_float_exceptions_rounding_supported_p (void);
extern bool default_decimal_float_supported_p (void);
extern bool default_fixed_point_supported_p (void);
extern bool default_has_ifunc_p (void);
extern const char * default_invalid_within_doloop (const rtx_insn *);
extern tree default_builtin_vectorized_function (unsigned int, tree, tree);
extern tree default_builtin_md_vectorized_function (tree, tree, tree);
extern tree default_builtin_vectorized_conversion (unsigned int, tree, tree);
extern int default_builtin_vectorization_cost (enum vect_cost_for_stmt, tree, int);
extern tree default_builtin_reciprocal (tree);
extern HOST_WIDE_INT default_static_rtx_alignment (machine_mode);
extern HOST_WIDE_INT default_constant_alignment (const_tree, HOST_WIDE_INT);
extern HOST_WIDE_INT constant_alignment_word_strings (const_tree,
HOST_WIDE_INT);
extern HOST_WIDE_INT default_vector_alignment (const_tree);
extern HOST_WIDE_INT default_preferred_vector_alignment (const_tree);
extern bool default_builtin_vector_alignment_reachable (const_tree, bool);
extern bool
default_builtin_support_vector_misalignment (machine_mode mode,
const_tree,
int, bool);
extern machine_mode default_preferred_simd_mode (scalar_mode mode);
extern machine_mode default_split_reduction (machine_mode);
extern void default_autovectorize_vector_sizes (vector_sizes *);
extern opt_machine_mode default_get_mask_mode (poly_uint64, poly_uint64);
extern bool default_empty_mask_is_expensive (unsigned);
extern void *default_init_cost (struct loop *);
extern unsigned default_add_stmt_cost (void *, int, enum vect_cost_for_stmt,
struct _stmt_vec_info *, int,
enum vect_cost_model_location);
extern void default_finish_cost (void *, unsigned *, unsigned *, unsigned *);
extern void default_destroy_cost_data (void *);
/* OpenACC hooks. */
extern bool default_goacc_validate_dims (tree, int [], int);
extern int default_goacc_dim_limit (int);
extern bool default_goacc_fork_join (gcall *, const int [], bool);
extern void default_goacc_reduction (gcall *);
/* These are here, and not in hooks.[ch], because not all users of
hooks.h include tm.h, and thus we don't have CUMULATIVE_ARGS. */
extern bool hook_bool_CUMULATIVE_ARGS_false (cumulative_args_t);
extern bool hook_bool_CUMULATIVE_ARGS_true (cumulative_args_t);
extern bool hook_bool_CUMULATIVE_ARGS_mode_tree_bool_false
(cumulative_args_t, machine_mode, const_tree, bool);
extern bool hook_bool_CUMULATIVE_ARGS_mode_tree_bool_true
(cumulative_args_t, machine_mode, const_tree, bool);
extern int hook_int_CUMULATIVE_ARGS_mode_tree_bool_0
(cumulative_args_t, machine_mode, tree, bool);
extern void hook_void_CUMULATIVE_ARGS_tree
(cumulative_args_t, tree);
extern const char *hook_invalid_arg_for_unprototyped_fn
(const_tree, const_tree, const_tree);
extern void default_function_arg_advance
(cumulative_args_t, machine_mode, const_tree, bool);
extern HOST_WIDE_INT default_function_arg_offset (machine_mode, const_tree);
extern pad_direction default_function_arg_padding (machine_mode, const_tree);
extern rtx default_function_arg
(cumulative_args_t, machine_mode, const_tree, bool);
extern rtx default_function_incoming_arg
(cumulative_args_t, machine_mode, const_tree, bool);
extern unsigned int default_function_arg_boundary (machine_mode,
const_tree);
extern unsigned int default_function_arg_round_boundary (machine_mode,
const_tree);
extern bool hook_bool_const_rtx_commutative_p (const_rtx, int);
extern rtx default_function_value (const_tree, const_tree, bool);
extern rtx default_libcall_value (machine_mode, const_rtx);
extern bool default_function_value_regno_p (const unsigned int);
extern rtx default_internal_arg_pointer (void);
extern rtx default_static_chain (const_tree, bool);
extern void default_trampoline_init (rtx, tree, rtx);
extern poly_int64 default_return_pops_args (tree, tree, poly_int64);
extern reg_class_t default_branch_target_register_class (void);
extern reg_class_t default_ira_change_pseudo_allocno_class (int, reg_class_t,
reg_class_t);
extern bool default_lra_p (void);
extern int default_register_priority (int);
extern bool default_register_usage_leveling_p (void);
extern bool default_different_addr_displacement_p (void);
extern reg_class_t default_secondary_reload (bool, rtx, reg_class_t,
machine_mode,
secondary_reload_info *);
extern machine_mode default_secondary_memory_needed_mode (machine_mode);
extern void default_target_option_override (void);
extern void hook_void_bitmap (bitmap);
extern int default_reloc_rw_mask (void);
extern tree default_mangle_decl_assembler_name (tree, tree);
extern tree default_emutls_var_fields (tree, tree *);
extern tree default_emutls_var_init (tree, tree, tree);
extern unsigned int default_hard_regno_nregs (unsigned int, machine_mode);
extern bool default_hard_regno_scratch_ok (unsigned int);
extern bool default_mode_dependent_address_p (const_rtx, addr_space_t);
extern bool default_target_option_valid_attribute_p (tree, tree, tree, int);
extern bool default_target_option_pragma_parse (tree, tree);
extern bool default_target_can_inline_p (tree, tree);
extern bool default_valid_pointer_mode (scalar_int_mode);
extern bool default_ref_may_alias_errno (struct ao_ref *);
extern scalar_int_mode default_addr_space_pointer_mode (addr_space_t);
extern scalar_int_mode default_addr_space_address_mode (addr_space_t);
extern bool default_addr_space_valid_pointer_mode (scalar_int_mode,
addr_space_t);
extern bool default_addr_space_legitimate_address_p (machine_mode, rtx,
bool, addr_space_t);
extern rtx default_addr_space_legitimize_address (rtx, rtx, machine_mode,
addr_space_t);
extern bool default_addr_space_subset_p (addr_space_t, addr_space_t);
extern bool default_addr_space_zero_address_valid (addr_space_t);
extern int default_addr_space_debug (addr_space_t);
extern void default_addr_space_diagnose_usage (addr_space_t, location_t);
extern rtx default_addr_space_convert (rtx, tree, tree);
extern unsigned int default_case_values_threshold (void);
extern bool default_have_conditional_execution (void);
extern bool default_libc_has_function (enum function_class);
extern bool no_c99_libc_has_function (enum function_class);
extern bool gnu_libc_has_function (enum function_class);
extern tree default_builtin_tm_load_store (tree);
extern int default_memory_move_cost (machine_mode, reg_class_t, bool);
extern int default_register_move_cost (machine_mode, reg_class_t,
reg_class_t);
extern bool default_slow_unaligned_access (machine_mode, unsigned int);
extern HOST_WIDE_INT default_estimated_poly_value (poly_int64);
extern bool default_use_by_pieces_infrastructure_p (unsigned HOST_WIDE_INT,
unsigned int,
enum by_pieces_operation,
bool);
extern int default_compare_by_pieces_branch_ratio (machine_mode);
extern void default_print_patchable_function_entry (FILE *,
unsigned HOST_WIDE_INT,
bool);
extern bool default_profile_before_prologue (void);
extern reg_class_t default_preferred_reload_class (rtx, reg_class_t);
extern reg_class_t default_preferred_output_reload_class (rtx, reg_class_t);
extern reg_class_t default_preferred_rename_class (reg_class_t rclass);
extern bool default_class_likely_spilled_p (reg_class_t);
extern unsigned char default_class_max_nregs (reg_class_t, machine_mode);
extern enum unwind_info_type default_debug_unwind_info (void);
extern void default_canonicalize_comparison (int *, rtx *, rtx *, bool);
extern int default_label_align_after_barrier_max_skip (rtx_insn *);
extern int default_loop_align_max_skip (rtx_insn *);
extern int default_label_align_max_skip (rtx_insn *);
extern int default_jump_align_max_skip (rtx_insn *);
extern section * default_function_section(tree decl, enum node_frequency freq,
bool startup, bool exit);
extern unsigned int default_dwarf_poly_indeterminate_value (unsigned int,
unsigned int *,
int *);
extern machine_mode default_dwarf_frame_reg_mode (int);
extern fixed_size_mode default_get_reg_raw_mode (int);
extern bool default_keep_leaf_when_profiled ();
extern void *default_get_pch_validity (size_t *);
extern const char *default_pch_valid_p (const void *, size_t);
extern void default_asm_output_ident_directive (const char*);
extern scalar_int_mode default_cstore_mode (enum insn_code);
extern bool default_member_type_forces_blk (const_tree, machine_mode);
extern void default_atomic_assign_expand_fenv (tree *, tree *, tree *);
extern tree build_va_arg_indirect_ref (tree);
extern tree std_gimplify_va_arg_expr (tree, tree, gimple_seq *, gimple_seq *);
extern bool can_use_doloop_if_innermost (const widest_int &,
const widest_int &,
unsigned int, bool);
extern rtx default_load_bounds_for_arg (rtx, rtx, rtx);
extern void default_store_bounds_for_arg (rtx, rtx, rtx, rtx);
extern rtx default_load_returned_bounds (rtx);
extern void default_store_returned_bounds (rtx,rtx);
extern tree default_chkp_bound_type (void);
extern machine_mode default_chkp_bound_mode (void);
extern tree default_builtin_chkp_function (unsigned int);
extern rtx default_chkp_function_value_bounds (const_tree, const_tree, bool);
extern tree default_chkp_make_bounds_constant (HOST_WIDE_INT lb, HOST_WIDE_INT ub);
extern int default_chkp_initialize_bounds (tree var, tree lb, tree ub,
tree *stmts);
extern void default_setup_incoming_vararg_bounds (cumulative_args_t ca ATTRIBUTE_UNUSED,
machine_mode mode ATTRIBUTE_UNUSED,
tree type ATTRIBUTE_UNUSED,
int *pretend_arg_size ATTRIBUTE_UNUSED,
int second_time ATTRIBUTE_UNUSED);
extern bool default_optab_supported_p (int, machine_mode, machine_mode,
optimization_type);
extern unsigned int default_max_noce_ifcvt_seq_cost (edge);
extern bool default_noce_conversion_profitable_p (rtx_insn *,
struct noce_if_info *);
extern unsigned int default_min_arithmetic_precision (void);
extern enum flt_eval_method
default_excess_precision (enum excess_precision_type ATTRIBUTE_UNUSED);
extern bool default_stack_clash_protection_final_dynamic_probe (rtx);
extern void default_select_early_remat_modes (sbitmap);
#endif /* GCC_TARGHOOKS_H */
| {
"pile_set_name": "Github"
} |
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-lmeshTools
| {
"pile_set_name": "Github"
} |
岗位职责:
1、按照产品设计完成安卓客户端产品的代码研发工作
2、参与安卓客户端产品的需求分析和产品设计,提供实现评估以及系统设计等;
3、与前端及后端工程师协作完成API等设计
4、参与设计和代码review,参与框架设计
5、调研新技术和技术革新方案,完成原型开发和推送产品重构工作
岗位要求:
1、精通JAVA编程语言,熟悉JNI编程,精通Android开发,有良好的编程习惯;
2、精通Android应用开发框架,以及UI实现相关技术,能独立开发高性能的Android应用;
3、3年以上android相关开发经验,有成功案例;
4、有对于安卓客户端做数据跟踪、性能优化、错误分析的经验
6、了解后端API设计、网络传输等相关知识,了解Native + HTML5 混合模式开发
7、有整体客户端框架设计经验优先
微信:Cathy-LYY
Mail: [email protected]
| {
"pile_set_name": "Github"
} |
/*!
@file
Defines `boost::hana::replace`.
@copyright Louis Dionne 2013-2017
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_HANA_REPLACE_HPP
#define BOOST_HANA_REPLACE_HPP
#include <boost/hana/fwd/replace.hpp>
#include <boost/hana/concept/functor.hpp>
#include <boost/hana/config.hpp>
#include <boost/hana/core/dispatch.hpp>
#include <boost/hana/equal.hpp>
#include <boost/hana/replace_if.hpp>
BOOST_HANA_NAMESPACE_BEGIN
//! @cond
template <typename Xs, typename OldVal, typename NewVal>
constexpr auto replace_t::operator()(Xs&& xs, OldVal&& oldval, NewVal&& newval) const {
using S = typename hana::tag_of<Xs>::type;
using Replace = BOOST_HANA_DISPATCH_IF(replace_impl<S>,
hana::Functor<S>::value
);
#ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS
static_assert(hana::Functor<S>::value,
"hana::replace(xs, oldval, newval) requires 'xs' to be a Functor");
#endif
return Replace::apply(static_cast<Xs&&>(xs),
static_cast<OldVal&&>(oldval),
static_cast<NewVal&&>(newval));
}
//! @endcond
template <typename Fun, bool condition>
struct replace_impl<Fun, when<condition>> : default_ {
template <typename Xs, typename OldVal, typename NewVal>
static constexpr decltype(auto)
apply(Xs&& xs, OldVal&& oldval, NewVal&& newval) {
return hana::replace_if(
static_cast<Xs&&>(xs),
hana::equal.to(static_cast<OldVal&&>(oldval)),
static_cast<NewVal&&>(newval)
);
}
};
BOOST_HANA_NAMESPACE_END
#endif // !BOOST_HANA_REPLACE_HPP
| {
"pile_set_name": "Github"
} |
/* ----------------------------------------------------------------- */
/* */
/* Copyright (c) 2009-2011 Nagoya Institute of Technology */
/* Department of Computer Science */
/* 2010-2012 hkrn */
/* */
/* All rights reserved. */
/* */
/* Redistribution and use in source and binary forms, with or */
/* without modification, are permitted provided that the following */
/* conditions are met: */
/* */
/* - Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* - Redistributions in binary form must reproduce the above */
/* copyright notice, this list of conditions and the following */
/* disclaimer in the documentation and/or other materials provided */
/* with the distribution. */
/* - Neither the name of the MMDAI project team nor the names of */
/* its contributors may be used to endorse or promote products */
/* derived from this software without specific prior written */
/* permission. */
/* */
/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND */
/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, */
/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS */
/* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, */
/* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */
/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */
/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */
/* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY */
/* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
/* POSSIBILITY OF SUCH DAMAGE. */
/* ----------------------------------------------------------------- */
#include "vpvl/vpvl.h"
#include "vpvl/internal/util.h"
namespace vpvl
{
struct InternalFaceKeyFrameList {
Face *face;
FaceKeyFrameList keyFrames;
float weight;
int lastIndex;
bool isNull() const {
if (keyFrames.count() == 1) {
const FaceKeyframe *keyFrame = keyFrames[0];
return keyFrame->weight() == 0.0f;
}
return false;
}
};
class FaceAnimationKeyFramePredication
{
public:
bool operator()(const BaseKeyframe *left, const BaseKeyframe *right) const {
return left->frameIndex() < right->frameIndex();
}
};
FaceAnimation::FaceAnimation()
: BaseAnimation(),
m_model(0),
m_enableNullFrame(false)
{
}
FaceAnimation::~FaceAnimation()
{
m_name2keyframes.releaseAll();
m_model = 0;
}
void FaceAnimation::read(const uint8_t *data, int size)
{
uint8_t *ptr = const_cast<uint8_t *>(data);
m_frames.reserve(size);
for (int i = 0; i < size; i++) {
FaceKeyframe *frame = new FaceKeyframe();
frame->read(ptr);
ptr += frame->stride();
m_frames.add(frame);
}
}
void FaceAnimation::seek(float frameAt)
{
const int nnodes = m_name2keyframes.count();
for (int i = 0; i < nnodes; i++) {
InternalFaceKeyFrameList *keyFrames = *m_name2keyframes.value(i);
if (m_enableNullFrame && keyFrames->isNull())
continue;
calculateFrames(frameAt, keyFrames);
Face *face = keyFrames->face;
face->setWeight(keyFrames->weight);
}
m_previousFrame = m_currentFrame;
m_currentFrame = frameAt;
}
void FaceAnimation::attachModel(PMDModel *model)
{
if (!m_model) {
buildInternalNodes(model);
m_model = model;
}
}
void FaceAnimation::refresh()
{
if (m_model) {
m_name2keyframes.releaseAll();
buildInternalNodes(m_model);
}
}
void FaceAnimation::buildInternalNodes(vpvl::PMDModel *model)
{
const int nframes = m_frames.count();
// Build internal node to find by name, not frame index
for (int i = 0; i < nframes; i++) {
FaceKeyframe *frame = static_cast<FaceKeyframe *>(m_frames.at(i));
HashString name(reinterpret_cast<const char *>(frame->name()));
InternalFaceKeyFrameList **ptr = m_name2keyframes[name], *node;
if (ptr) {
node = *ptr;
node->keyFrames.add(frame);
}
else {
Face *face = model->findFace(frame->name());
if (face) {
node = new InternalFaceKeyFrameList();
node->keyFrames.add(frame);
node->face = face;
node->lastIndex = 0;
node->weight = 0.0f;
m_name2keyframes.insert(name, node);
}
}
}
// Sort frames from each internal nodes by frame index ascend
const int nnodes = m_name2keyframes.count();
for (int i = 0; i < nnodes; i++) {
InternalFaceKeyFrameList *keyFrames = *m_name2keyframes.value(i);
FaceKeyFrameList &frames = keyFrames->keyFrames;
frames.sort(FaceAnimationKeyFramePredication());
btSetMax(m_maxFrame, frames[frames.count() - 1]->frameIndex());
}
}
void FaceAnimation::reset()
{
BaseAnimation::reset();
const int nnodes = m_name2keyframes.count();
for (int i = 0; i < nnodes; i++) {
InternalFaceKeyFrameList *node = *m_name2keyframes.value(i);
node->lastIndex = 0;
}
}
void FaceAnimation::calculateFrames(float frameAt, InternalFaceKeyFrameList *keyFrames)
{
FaceKeyFrameList &kframes = keyFrames->keyFrames;
const int nframes = kframes.count();
FaceKeyframe *lastKeyFrame = kframes.at(nframes - 1);
float currentFrame = btMin(frameAt, lastKeyFrame->frameIndex());
// Find the next frame index bigger than the frame index of last key frame
int k1 = 0, k2 = 0, lastIndex = keyFrames->lastIndex;
if (currentFrame >= kframes.at(lastIndex)->frameIndex()) {
for (int i = lastIndex; i < nframes; i++) {
if (currentFrame <= kframes.at(i)->frameIndex()) {
k2 = i;
break;
}
}
}
else {
for (int i = 0; i <= lastIndex && i < nframes; i++) {
if (currentFrame <= m_frames.at(i)->frameIndex()) {
k2 = i;
break;
}
}
}
if (k2 >= nframes)
k2 = nframes - 1;
k1 = k2 <= 1 ? 0 : k2 - 1;
keyFrames->lastIndex = k1;
const FaceKeyframe *keyFrameFrom = kframes.at(k1), *keyFrameTo = kframes.at(k2);
float frameIndexFrom = keyFrameFrom->frameIndex(), frameIndexTo = keyFrameTo->frameIndex();
float weightFrom = keyFrameFrom->weight();
float weightTo = keyFrameTo->weight();
if (frameIndexFrom != frameIndexTo) {
const float w = (currentFrame - frameIndexFrom) / (frameIndexTo - frameIndexFrom);
keyFrames->weight = internal::lerp(weightFrom, weightTo, w);
}
else {
keyFrames->weight = weightFrom;
}
m_previousFrame = m_currentFrame;
m_currentFrame = frameAt;
}
}
| {
"pile_set_name": "Github"
} |
#ifndef BOOST_ARCHIVE_BASIC_XML_GRAMMAR_HPP
#define BOOST_ARCHIVE_BASIC_XML_GRAMMAR_HPP
// MS compatible compilers support #pragma once
#if defined(_MSC_VER)
# pragma once
#endif
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// basic_xml_grammar.hpp
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
// this module is derived from simplexml.cpp - an example shipped as part of
// the spirit parser. This example contains the following notice:
/*=============================================================================
simplexml.cpp
Spirit V1.3
URL: http://spirit.sourceforge.net/
Copyright (c) 2001, Daniel C. Nuffer
This software is provided 'as-is', without any express or implied
warranty. In no event will the copyright holder be held liable for
any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute
it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product documentation
would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
=============================================================================*/
#include <string>
#include <boost/config.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/spirit/include/classic_rule.hpp>
#include <boost/spirit/include/classic_chset.hpp>
#include <boost/archive/basic_archive.hpp>
#include <boost/serialization/tracking.hpp>
#include <boost/serialization/version.hpp>
namespace boost {
namespace archive {
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// XML grammar parsing
template<class CharType>
class basic_xml_grammar {
public:
// The following is not necessary according to DR45, but at least
// one compiler (Compaq C++ 6.5 in strict_ansi mode) chokes otherwise.
struct return_values;
friend struct return_values;
private:
typedef typename std::basic_istream<CharType> IStream;
typedef typename std::basic_string<CharType> StringType;
typedef typename boost::spirit::classic::chset<CharType> chset_t;
typedef typename boost::spirit::classic::chlit<CharType> chlit_t;
typedef typename boost::spirit::classic::scanner<
typename std::basic_string<CharType>::iterator
> scanner_t;
typedef typename boost::spirit::classic::rule<scanner_t> rule_t;
// Start grammar definition
rule_t
Reference,
Eq,
STag,
ETag,
LetterOrUnderscoreOrColon,
AttValue,
CharRef1,
CharRef2,
CharRef,
AmpRef,
LTRef,
GTRef,
AposRef,
QuoteRef,
CharData,
CharDataChars,
content,
AmpName,
LTName,
GTName,
ClassNameChar,
ClassName,
Name,
XMLDecl,
XMLDeclChars,
DocTypeDecl,
DocTypeDeclChars,
ClassIDAttribute,
ObjectIDAttribute,
ClassNameAttribute,
TrackingAttribute,
VersionAttribute,
UnusedAttribute,
Attribute,
SignatureAttribute,
SerializationWrapper,
NameHead,
NameTail,
AttributeList,
S;
// XML Character classes
chset_t
BaseChar,
Ideographic,
Char,
Letter,
Digit,
CombiningChar,
Extender,
Sch,
NameChar;
void init_chset();
bool my_parse(
IStream & is,
const rule_t &rule_,
const CharType delimiter = L'>'
) const ;
public:
struct return_values {
StringType object_name;
StringType contents;
//class_id_type class_id;
int_least16_t class_id;
//object_id_type object_id;
uint_least32_t object_id;
//version_type version;
unsigned int version;
tracking_type tracking_level;
StringType class_name;
return_values() :
version(0),
tracking_level(false)
{}
} rv;
bool parse_start_tag(IStream & is) /*const*/;
bool parse_end_tag(IStream & is) const;
bool parse_string(IStream & is, StringType & s) /*const*/;
void init(IStream & is);
bool windup(IStream & is);
basic_xml_grammar();
};
} // namespace archive
} // namespace boost
#endif // BOOST_ARCHIVE_BASIC_XML_GRAMMAR_HPP
| {
"pile_set_name": "Github"
} |
require 'vagrant-multi-putty/command'
require 'vagrant-multi-putty/config'
require 'vagrant-multi-putty/plugin'
require 'vagrant-multi-putty/version'
| {
"pile_set_name": "Github"
} |
fileFormatVersion: 2
guid: 065e68e20109ef54f849092dee1f913b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
| {
"pile_set_name": "Github"
} |
package org.cbioportal.model;
import java.util.Objects;
import java.util.Set;
public class PatientTreatmentRow {
private String treatment;
private int count;
private Set<ClinicalEventSample> samples;
public PatientTreatmentRow() {}
public PatientTreatmentRow(String treatment, int count, Set<ClinicalEventSample> samples) {
this.treatment = treatment;
this.count = count;
this.samples = samples;
}
public String getTreatment() {
return treatment;
}
public void setTreatment(String treatment) {
this.treatment = treatment;
}
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
public Set<ClinicalEventSample> getSamples() {
return samples;
}
public void setSamples(Set<ClinicalEventSample> samples) {
this.samples = samples;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
PatientTreatmentRow that = (PatientTreatmentRow) o;
return getCount() == that.getCount() &&
getTreatment().equals(that.getTreatment()) &&
Objects.equals(getSamples(), that.getSamples());
}
@Override
public int hashCode() {
return Objects.hash(getTreatment(), getCount(), getSamples());
}
public void add(SampleTreatmentRow toAdd) {
setCount(getCount() + toAdd.getCount());
getSamples().addAll(toAdd.getSamples());
}
}
| {
"pile_set_name": "Github"
} |
<?xml version="1.0" encoding="utf-8"?>
<!--
**
** Copyright 2013, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<view xmlns:android="http://schemas.android.com/apk/res/android"
class="android.support.v7.widget.ActivityChooserView$InnerLayout"
android:id="@+id/activity_chooser_view_content"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
style="?attr/activityChooserViewStyle">
<FrameLayout
android:id="@+id/expand_activities_button"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:focusable="true"
android:addStatesFromChildren="true"
android:background="?attr/actionBarItemBackground"
android:paddingTop="2dip"
android:paddingBottom="2dip"
android:paddingLeft="12dip"
android:paddingRight="12dip">
<ImageView android:id="@+id/image"
android:layout_width="32dip"
android:layout_height="32dip"
android:layout_gravity="center"
android:scaleType="fitCenter"
android:adjustViewBounds="true" />
</FrameLayout>
<FrameLayout
android:id="@+id/default_activity_button"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:focusable="true"
android:addStatesFromChildren="true"
android:background="?attr/actionBarItemBackground"
android:paddingTop="2dip"
android:paddingBottom="2dip"
android:paddingLeft="12dip"
android:paddingRight="12dip">
<ImageView android:id="@+id/image"
android:layout_width="32dip"
android:layout_height="32dip"
android:layout_gravity="center"
android:scaleType="fitCenter"
android:adjustViewBounds="true" />
</FrameLayout>
</view>
| {
"pile_set_name": "Github"
} |
// mkerrors.sh
// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
// +build arm64,linux
// Created by cgo -godefs - DO NOT EDIT
// cgo -godefs -- _const.go
package unix
import "syscall"
const (
AF_ALG = 0x26
AF_APPLETALK = 0x5
AF_ASH = 0x12
AF_ATMPVC = 0x8
AF_ATMSVC = 0x14
AF_AX25 = 0x3
AF_BLUETOOTH = 0x1f
AF_BRIDGE = 0x7
AF_CAIF = 0x25
AF_CAN = 0x1d
AF_DECnet = 0xc
AF_ECONET = 0x13
AF_FILE = 0x1
AF_IEEE802154 = 0x24
AF_INET = 0x2
AF_INET6 = 0xa
AF_IPX = 0x4
AF_IRDA = 0x17
AF_ISDN = 0x22
AF_IUCV = 0x20
AF_KEY = 0xf
AF_LLC = 0x1a
AF_LOCAL = 0x1
AF_MAX = 0x29
AF_NETBEUI = 0xd
AF_NETLINK = 0x10
AF_NETROM = 0x6
AF_NFC = 0x27
AF_PACKET = 0x11
AF_PHONET = 0x23
AF_PPPOX = 0x18
AF_RDS = 0x15
AF_ROSE = 0xb
AF_ROUTE = 0x10
AF_RXRPC = 0x21
AF_SECURITY = 0xe
AF_SNA = 0x16
AF_TIPC = 0x1e
AF_UNIX = 0x1
AF_UNSPEC = 0x0
AF_VSOCK = 0x28
AF_WANPIPE = 0x19
AF_X25 = 0x9
ARPHRD_ADAPT = 0x108
ARPHRD_APPLETLK = 0x8
ARPHRD_ARCNET = 0x7
ARPHRD_ASH = 0x30d
ARPHRD_ATM = 0x13
ARPHRD_AX25 = 0x3
ARPHRD_BIF = 0x307
ARPHRD_CAIF = 0x336
ARPHRD_CAN = 0x118
ARPHRD_CHAOS = 0x5
ARPHRD_CISCO = 0x201
ARPHRD_CSLIP = 0x101
ARPHRD_CSLIP6 = 0x103
ARPHRD_DDCMP = 0x205
ARPHRD_DLCI = 0xf
ARPHRD_ECONET = 0x30e
ARPHRD_EETHER = 0x2
ARPHRD_ETHER = 0x1
ARPHRD_EUI64 = 0x1b
ARPHRD_FCAL = 0x311
ARPHRD_FCFABRIC = 0x313
ARPHRD_FCPL = 0x312
ARPHRD_FCPP = 0x310
ARPHRD_FDDI = 0x306
ARPHRD_FRAD = 0x302
ARPHRD_HDLC = 0x201
ARPHRD_HIPPI = 0x30c
ARPHRD_HWX25 = 0x110
ARPHRD_IEEE1394 = 0x18
ARPHRD_IEEE802 = 0x6
ARPHRD_IEEE80211 = 0x321
ARPHRD_IEEE80211_PRISM = 0x322
ARPHRD_IEEE80211_RADIOTAP = 0x323
ARPHRD_IEEE802154 = 0x324
ARPHRD_IEEE802154_MONITOR = 0x325
ARPHRD_IEEE802_TR = 0x320
ARPHRD_INFINIBAND = 0x20
ARPHRD_IP6GRE = 0x337
ARPHRD_IPDDP = 0x309
ARPHRD_IPGRE = 0x30a
ARPHRD_IRDA = 0x30f
ARPHRD_LAPB = 0x204
ARPHRD_LOCALTLK = 0x305
ARPHRD_LOOPBACK = 0x304
ARPHRD_METRICOM = 0x17
ARPHRD_NETLINK = 0x338
ARPHRD_NETROM = 0x0
ARPHRD_NONE = 0xfffe
ARPHRD_PHONET = 0x334
ARPHRD_PHONET_PIPE = 0x335
ARPHRD_PIMREG = 0x30b
ARPHRD_PPP = 0x200
ARPHRD_PRONET = 0x4
ARPHRD_RAWHDLC = 0x206
ARPHRD_ROSE = 0x10e
ARPHRD_RSRVD = 0x104
ARPHRD_SIT = 0x308
ARPHRD_SKIP = 0x303
ARPHRD_SLIP = 0x100
ARPHRD_SLIP6 = 0x102
ARPHRD_TUNNEL = 0x300
ARPHRD_TUNNEL6 = 0x301
ARPHRD_VOID = 0xffff
ARPHRD_X25 = 0x10f
B0 = 0x0
B1000000 = 0x1008
B110 = 0x3
B115200 = 0x1002
B1152000 = 0x1009
B1200 = 0x9
B134 = 0x4
B150 = 0x5
B1500000 = 0x100a
B1800 = 0xa
B19200 = 0xe
B200 = 0x6
B2000000 = 0x100b
B230400 = 0x1003
B2400 = 0xb
B2500000 = 0x100c
B300 = 0x7
B3000000 = 0x100d
B3500000 = 0x100e
B38400 = 0xf
B4000000 = 0x100f
B460800 = 0x1004
B4800 = 0xc
B50 = 0x1
B500000 = 0x1005
B57600 = 0x1001
B576000 = 0x1006
B600 = 0x8
B75 = 0x2
B921600 = 0x1007
B9600 = 0xd
BOTHER = 0x1000
BPF_A = 0x10
BPF_ABS = 0x20
BPF_ADD = 0x0
BPF_ALU = 0x4
BPF_AND = 0x50
BPF_B = 0x10
BPF_DIV = 0x30
BPF_H = 0x8
BPF_IMM = 0x0
BPF_IND = 0x40
BPF_JA = 0x0
BPF_JEQ = 0x10
BPF_JGE = 0x30
BPF_JGT = 0x20
BPF_JMP = 0x5
BPF_JSET = 0x40
BPF_K = 0x0
BPF_LD = 0x0
BPF_LDX = 0x1
BPF_LEN = 0x80
BPF_LSH = 0x60
BPF_MAJOR_VERSION = 0x1
BPF_MAXINSNS = 0x1000
BPF_MEM = 0x60
BPF_MEMWORDS = 0x10
BPF_MINOR_VERSION = 0x1
BPF_MISC = 0x7
BPF_MOD = 0x90
BPF_MSH = 0xa0
BPF_MUL = 0x20
BPF_NEG = 0x80
BPF_OR = 0x40
BPF_RET = 0x6
BPF_RSH = 0x70
BPF_ST = 0x2
BPF_STX = 0x3
BPF_SUB = 0x10
BPF_TAX = 0x0
BPF_TXA = 0x80
BPF_W = 0x0
BPF_X = 0x8
BPF_XOR = 0xa0
BRKINT = 0x2
BS0 = 0x0
BS1 = 0x2000
BSDLY = 0x2000
CAN_BCM = 0x2
CAN_EFF_FLAG = 0x80000000
CAN_EFF_ID_BITS = 0x1d
CAN_EFF_MASK = 0x1fffffff
CAN_ERR_FLAG = 0x20000000
CAN_ERR_MASK = 0x1fffffff
CAN_INV_FILTER = 0x20000000
CAN_ISOTP = 0x6
CAN_MAX_DLC = 0x8
CAN_MAX_DLEN = 0x8
CAN_MCNET = 0x5
CAN_MTU = 0x10
CAN_NPROTO = 0x7
CAN_RAW = 0x1
CAN_RTR_FLAG = 0x40000000
CAN_SFF_ID_BITS = 0xb
CAN_SFF_MASK = 0x7ff
CAN_TP16 = 0x3
CAN_TP20 = 0x4
CBAUD = 0x100f
CBAUDEX = 0x1000
CFLUSH = 0xf
CIBAUD = 0x100f0000
CLOCAL = 0x800
CLOCK_BOOTTIME = 0x7
CLOCK_BOOTTIME_ALARM = 0x9
CLOCK_DEFAULT = 0x0
CLOCK_EXT = 0x1
CLOCK_INT = 0x2
CLOCK_MONOTONIC = 0x1
CLOCK_MONOTONIC_COARSE = 0x6
CLOCK_MONOTONIC_RAW = 0x4
CLOCK_PROCESS_CPUTIME_ID = 0x2
CLOCK_REALTIME = 0x0
CLOCK_REALTIME_ALARM = 0x8
CLOCK_REALTIME_COARSE = 0x5
CLOCK_THREAD_CPUTIME_ID = 0x3
CLOCK_TXFROMRX = 0x4
CLOCK_TXINT = 0x3
CLONE_CHILD_CLEARTID = 0x200000
CLONE_CHILD_SETTID = 0x1000000
CLONE_DETACHED = 0x400000
CLONE_FILES = 0x400
CLONE_FS = 0x200
CLONE_IO = 0x80000000
CLONE_NEWCGROUP = 0x2000000
CLONE_NEWIPC = 0x8000000
CLONE_NEWNET = 0x40000000
CLONE_NEWNS = 0x20000
CLONE_NEWPID = 0x20000000
CLONE_NEWUSER = 0x10000000
CLONE_NEWUTS = 0x4000000
CLONE_PARENT = 0x8000
CLONE_PARENT_SETTID = 0x100000
CLONE_PTRACE = 0x2000
CLONE_SETTLS = 0x80000
CLONE_SIGHAND = 0x800
CLONE_SYSVSEM = 0x40000
CLONE_THREAD = 0x10000
CLONE_UNTRACED = 0x800000
CLONE_VFORK = 0x4000
CLONE_VM = 0x100
CMSPAR = 0x40000000
CR0 = 0x0
CR1 = 0x200
CR2 = 0x400
CR3 = 0x600
CRDLY = 0x600
CREAD = 0x80
CRTSCTS = 0x80000000
CS5 = 0x0
CS6 = 0x10
CS7 = 0x20
CS8 = 0x30
CSIGNAL = 0xff
CSIZE = 0x30
CSTART = 0x11
CSTATUS = 0x0
CSTOP = 0x13
CSTOPB = 0x40
CSUSP = 0x1a
DT_BLK = 0x6
DT_CHR = 0x2
DT_DIR = 0x4
DT_FIFO = 0x1
DT_LNK = 0xa
DT_REG = 0x8
DT_SOCK = 0xc
DT_UNKNOWN = 0x0
DT_WHT = 0xe
ECHO = 0x8
ECHOCTL = 0x200
ECHOE = 0x10
ECHOK = 0x20
ECHOKE = 0x800
ECHONL = 0x40
ECHOPRT = 0x400
ELF_NGREG = 0x22
ELF_PRARGSZ = 0x50
ENCODING_DEFAULT = 0x0
ENCODING_FM_MARK = 0x3
ENCODING_FM_SPACE = 0x4
ENCODING_MANCHESTER = 0x5
ENCODING_NRZ = 0x1
ENCODING_NRZI = 0x2
EPOLLERR = 0x8
EPOLLET = 0x80000000
EPOLLHUP = 0x10
EPOLLIN = 0x1
EPOLLMSG = 0x400
EPOLLONESHOT = 0x40000000
EPOLLOUT = 0x4
EPOLLPRI = 0x2
EPOLLRDBAND = 0x80
EPOLLRDHUP = 0x2000
EPOLLRDNORM = 0x40
EPOLLWAKEUP = 0x20000000
EPOLLWRBAND = 0x200
EPOLLWRNORM = 0x100
EPOLL_CLOEXEC = 0x80000
EPOLL_CTL_ADD = 0x1
EPOLL_CTL_DEL = 0x2
EPOLL_CTL_MOD = 0x3
ETH_P_1588 = 0x88f7
ETH_P_8021AD = 0x88a8
ETH_P_8021AH = 0x88e7
ETH_P_8021Q = 0x8100
ETH_P_802_2 = 0x4
ETH_P_802_3 = 0x1
ETH_P_802_3_MIN = 0x600
ETH_P_802_EX1 = 0x88b5
ETH_P_AARP = 0x80f3
ETH_P_AF_IUCV = 0xfbfb
ETH_P_ALL = 0x3
ETH_P_AOE = 0x88a2
ETH_P_ARCNET = 0x1a
ETH_P_ARP = 0x806
ETH_P_ATALK = 0x809b
ETH_P_ATMFATE = 0x8884
ETH_P_ATMMPOA = 0x884c
ETH_P_AX25 = 0x2
ETH_P_BATMAN = 0x4305
ETH_P_BPQ = 0x8ff
ETH_P_CAIF = 0xf7
ETH_P_CAN = 0xc
ETH_P_CANFD = 0xd
ETH_P_CONTROL = 0x16
ETH_P_CUST = 0x6006
ETH_P_DDCMP = 0x6
ETH_P_DEC = 0x6000
ETH_P_DIAG = 0x6005
ETH_P_DNA_DL = 0x6001
ETH_P_DNA_RC = 0x6002
ETH_P_DNA_RT = 0x6003
ETH_P_DSA = 0x1b
ETH_P_ECONET = 0x18
ETH_P_EDSA = 0xdada
ETH_P_FCOE = 0x8906
ETH_P_FIP = 0x8914
ETH_P_HDLC = 0x19
ETH_P_IEEE802154 = 0xf6
ETH_P_IEEEPUP = 0xa00
ETH_P_IEEEPUPAT = 0xa01
ETH_P_IP = 0x800
ETH_P_IPV6 = 0x86dd
ETH_P_IPX = 0x8137
ETH_P_IRDA = 0x17
ETH_P_LAT = 0x6004
ETH_P_LINK_CTL = 0x886c
ETH_P_LOCALTALK = 0x9
ETH_P_LOOP = 0x60
ETH_P_MOBITEX = 0x15
ETH_P_MPLS_MC = 0x8848
ETH_P_MPLS_UC = 0x8847
ETH_P_MVRP = 0x88f5
ETH_P_PAE = 0x888e
ETH_P_PAUSE = 0x8808
ETH_P_PHONET = 0xf5
ETH_P_PPPTALK = 0x10
ETH_P_PPP_DISC = 0x8863
ETH_P_PPP_MP = 0x8
ETH_P_PPP_SES = 0x8864
ETH_P_PRP = 0x88fb
ETH_P_PUP = 0x200
ETH_P_PUPAT = 0x201
ETH_P_QINQ1 = 0x9100
ETH_P_QINQ2 = 0x9200
ETH_P_QINQ3 = 0x9300
ETH_P_RARP = 0x8035
ETH_P_SCA = 0x6007
ETH_P_SLOW = 0x8809
ETH_P_SNAP = 0x5
ETH_P_TDLS = 0x890d
ETH_P_TEB = 0x6558
ETH_P_TIPC = 0x88ca
ETH_P_TRAILER = 0x1c
ETH_P_TR_802_2 = 0x11
ETH_P_WAN_PPP = 0x7
ETH_P_WCCP = 0x883e
ETH_P_X25 = 0x805
EXTA = 0xe
EXTB = 0xf
EXTPROC = 0x10000
FD_CLOEXEC = 0x1
FD_SETSIZE = 0x400
FF0 = 0x0
FF1 = 0x8000
FFDLY = 0x8000
FLUSHO = 0x1000
F_DUPFD = 0x0
F_DUPFD_CLOEXEC = 0x406
F_EXLCK = 0x4
F_GETFD = 0x1
F_GETFL = 0x3
F_GETLEASE = 0x401
F_GETLK = 0x5
F_GETLK64 = 0x5
F_GETOWN = 0x9
F_GETOWN_EX = 0x10
F_GETPIPE_SZ = 0x408
F_GETSIG = 0xb
F_LOCK = 0x1
F_NOTIFY = 0x402
F_OK = 0x0
F_RDLCK = 0x0
F_SETFD = 0x2
F_SETFL = 0x4
F_SETLEASE = 0x400
F_SETLK = 0x6
F_SETLK64 = 0x6
F_SETLKW = 0x7
F_SETLKW64 = 0x7
F_SETOWN = 0x8
F_SETOWN_EX = 0xf
F_SETPIPE_SZ = 0x407
F_SETSIG = 0xa
F_SHLCK = 0x8
F_TEST = 0x3
F_TLOCK = 0x2
F_ULOCK = 0x0
F_UNLCK = 0x2
F_WRLCK = 0x1
HUPCL = 0x400
IBSHIFT = 0x10
ICANON = 0x2
ICMPV6_FILTER = 0x1
ICRNL = 0x100
IEXTEN = 0x8000
IFA_F_DADFAILED = 0x8
IFA_F_DEPRECATED = 0x20
IFA_F_HOMEADDRESS = 0x10
IFA_F_NODAD = 0x2
IFA_F_OPTIMISTIC = 0x4
IFA_F_PERMANENT = 0x80
IFA_F_SECONDARY = 0x1
IFA_F_TEMPORARY = 0x1
IFA_F_TENTATIVE = 0x40
IFA_MAX = 0x7
IFF_802_1Q_VLAN = 0x1
IFF_ALLMULTI = 0x200
IFF_ATTACH_QUEUE = 0x200
IFF_AUTOMEDIA = 0x4000
IFF_BONDING = 0x20
IFF_BRIDGE_PORT = 0x4000
IFF_BROADCAST = 0x2
IFF_DEBUG = 0x4
IFF_DETACH_QUEUE = 0x400
IFF_DISABLE_NETPOLL = 0x1000
IFF_DONT_BRIDGE = 0x800
IFF_DORMANT = 0x20000
IFF_DYNAMIC = 0x8000
IFF_EBRIDGE = 0x2
IFF_ECHO = 0x40000
IFF_ISATAP = 0x80
IFF_LIVE_ADDR_CHANGE = 0x100000
IFF_LOOPBACK = 0x8
IFF_LOWER_UP = 0x10000
IFF_MACVLAN = 0x200000
IFF_MACVLAN_PORT = 0x2000
IFF_MASTER = 0x400
IFF_MASTER_8023AD = 0x8
IFF_MASTER_ALB = 0x10
IFF_MASTER_ARPMON = 0x100
IFF_MULTICAST = 0x1000
IFF_MULTI_QUEUE = 0x100
IFF_NOARP = 0x80
IFF_NOFILTER = 0x1000
IFF_NOTRAILERS = 0x20
IFF_NO_PI = 0x1000
IFF_ONE_QUEUE = 0x2000
IFF_OVS_DATAPATH = 0x8000
IFF_PERSIST = 0x800
IFF_POINTOPOINT = 0x10
IFF_PORTSEL = 0x2000
IFF_PROMISC = 0x100
IFF_RUNNING = 0x40
IFF_SLAVE = 0x800
IFF_SLAVE_INACTIVE = 0x4
IFF_SLAVE_NEEDARP = 0x40
IFF_SUPP_NOFCS = 0x80000
IFF_TAP = 0x2
IFF_TEAM_PORT = 0x40000
IFF_TUN = 0x1
IFF_TUN_EXCL = 0x8000
IFF_TX_SKB_SHARING = 0x10000
IFF_UNICAST_FLT = 0x20000
IFF_UP = 0x1
IFF_VNET_HDR = 0x4000
IFF_VOLATILE = 0x70c5a
IFF_WAN_HDLC = 0x200
IFF_XMIT_DST_RELEASE = 0x400
IFNAMSIZ = 0x10
IGNBRK = 0x1
IGNCR = 0x80
IGNPAR = 0x4
IMAXBEL = 0x2000
INLCR = 0x40
INPCK = 0x10
IN_ACCESS = 0x1
IN_ALL_EVENTS = 0xfff
IN_ATTRIB = 0x4
IN_CLASSA_HOST = 0xffffff
IN_CLASSA_MAX = 0x80
IN_CLASSA_NET = 0xff000000
IN_CLASSA_NSHIFT = 0x18
IN_CLASSB_HOST = 0xffff
IN_CLASSB_MAX = 0x10000
IN_CLASSB_NET = 0xffff0000
IN_CLASSB_NSHIFT = 0x10
IN_CLASSC_HOST = 0xff
IN_CLASSC_NET = 0xffffff00
IN_CLASSC_NSHIFT = 0x8
IN_CLOEXEC = 0x80000
IN_CLOSE = 0x18
IN_CLOSE_NOWRITE = 0x10
IN_CLOSE_WRITE = 0x8
IN_CREATE = 0x100
IN_DELETE = 0x200
IN_DELETE_SELF = 0x400
IN_DONT_FOLLOW = 0x2000000
IN_EXCL_UNLINK = 0x4000000
IN_IGNORED = 0x8000
IN_ISDIR = 0x40000000
IN_LOOPBACKNET = 0x7f
IN_MASK_ADD = 0x20000000
IN_MODIFY = 0x2
IN_MOVE = 0xc0
IN_MOVED_FROM = 0x40
IN_MOVED_TO = 0x80
IN_MOVE_SELF = 0x800
IN_NONBLOCK = 0x800
IN_ONESHOT = 0x80000000
IN_ONLYDIR = 0x1000000
IN_OPEN = 0x20
IN_Q_OVERFLOW = 0x4000
IN_UNMOUNT = 0x2000
IPPROTO_AH = 0x33
IPPROTO_BEETPH = 0x5e
IPPROTO_COMP = 0x6c
IPPROTO_DCCP = 0x21
IPPROTO_DSTOPTS = 0x3c
IPPROTO_EGP = 0x8
IPPROTO_ENCAP = 0x62
IPPROTO_ESP = 0x32
IPPROTO_FRAGMENT = 0x2c
IPPROTO_GRE = 0x2f
IPPROTO_HOPOPTS = 0x0
IPPROTO_ICMP = 0x1
IPPROTO_ICMPV6 = 0x3a
IPPROTO_IDP = 0x16
IPPROTO_IGMP = 0x2
IPPROTO_IP = 0x0
IPPROTO_IPIP = 0x4
IPPROTO_IPV6 = 0x29
IPPROTO_MH = 0x87
IPPROTO_MTP = 0x5c
IPPROTO_NONE = 0x3b
IPPROTO_PIM = 0x67
IPPROTO_PUP = 0xc
IPPROTO_RAW = 0xff
IPPROTO_ROUTING = 0x2b
IPPROTO_RSVP = 0x2e
IPPROTO_SCTP = 0x84
IPPROTO_TCP = 0x6
IPPROTO_TP = 0x1d
IPPROTO_UDP = 0x11
IPPROTO_UDPLITE = 0x88
IPV6_2292DSTOPTS = 0x4
IPV6_2292HOPLIMIT = 0x8
IPV6_2292HOPOPTS = 0x3
IPV6_2292PKTINFO = 0x2
IPV6_2292PKTOPTIONS = 0x6
IPV6_2292RTHDR = 0x5
IPV6_ADDRFORM = 0x1
IPV6_ADD_MEMBERSHIP = 0x14
IPV6_AUTHHDR = 0xa
IPV6_CHECKSUM = 0x7
IPV6_DROP_MEMBERSHIP = 0x15
IPV6_DSTOPTS = 0x3b
IPV6_HOPLIMIT = 0x34
IPV6_HOPOPTS = 0x36
IPV6_IPSEC_POLICY = 0x22
IPV6_JOIN_ANYCAST = 0x1b
IPV6_JOIN_GROUP = 0x14
IPV6_LEAVE_ANYCAST = 0x1c
IPV6_LEAVE_GROUP = 0x15
IPV6_MTU = 0x18
IPV6_MTU_DISCOVER = 0x17
IPV6_MULTICAST_HOPS = 0x12
IPV6_MULTICAST_IF = 0x11
IPV6_MULTICAST_LOOP = 0x13
IPV6_NEXTHOP = 0x9
IPV6_PKTINFO = 0x32
IPV6_PMTUDISC_DO = 0x2
IPV6_PMTUDISC_DONT = 0x0
IPV6_PMTUDISC_PROBE = 0x3
IPV6_PMTUDISC_WANT = 0x1
IPV6_RECVDSTOPTS = 0x3a
IPV6_RECVERR = 0x19
IPV6_RECVHOPLIMIT = 0x33
IPV6_RECVHOPOPTS = 0x35
IPV6_RECVPKTINFO = 0x31
IPV6_RECVRTHDR = 0x38
IPV6_RECVTCLASS = 0x42
IPV6_ROUTER_ALERT = 0x16
IPV6_RTHDR = 0x39
IPV6_RTHDRDSTOPTS = 0x37
IPV6_RTHDR_LOOSE = 0x0
IPV6_RTHDR_STRICT = 0x1
IPV6_RTHDR_TYPE_0 = 0x0
IPV6_RXDSTOPTS = 0x3b
IPV6_RXHOPOPTS = 0x36
IPV6_TCLASS = 0x43
IPV6_UNICAST_HOPS = 0x10
IPV6_V6ONLY = 0x1a
IPV6_XFRM_POLICY = 0x23
IP_ADD_MEMBERSHIP = 0x23
IP_ADD_SOURCE_MEMBERSHIP = 0x27
IP_BLOCK_SOURCE = 0x26
IP_DEFAULT_MULTICAST_LOOP = 0x1
IP_DEFAULT_MULTICAST_TTL = 0x1
IP_DF = 0x4000
IP_DROP_MEMBERSHIP = 0x24
IP_DROP_SOURCE_MEMBERSHIP = 0x28
IP_FREEBIND = 0xf
IP_HDRINCL = 0x3
IP_IPSEC_POLICY = 0x10
IP_MAXPACKET = 0xffff
IP_MAX_MEMBERSHIPS = 0x14
IP_MF = 0x2000
IP_MINTTL = 0x15
IP_MSFILTER = 0x29
IP_MSS = 0x240
IP_MTU = 0xe
IP_MTU_DISCOVER = 0xa
IP_MULTICAST_ALL = 0x31
IP_MULTICAST_IF = 0x20
IP_MULTICAST_LOOP = 0x22
IP_MULTICAST_TTL = 0x21
IP_OFFMASK = 0x1fff
IP_OPTIONS = 0x4
IP_ORIGDSTADDR = 0x14
IP_PASSSEC = 0x12
IP_PKTINFO = 0x8
IP_PKTOPTIONS = 0x9
IP_PMTUDISC = 0xa
IP_PMTUDISC_DO = 0x2
IP_PMTUDISC_DONT = 0x0
IP_PMTUDISC_PROBE = 0x3
IP_PMTUDISC_WANT = 0x1
IP_RECVERR = 0xb
IP_RECVOPTS = 0x6
IP_RECVORIGDSTADDR = 0x14
IP_RECVRETOPTS = 0x7
IP_RECVTOS = 0xd
IP_RECVTTL = 0xc
IP_RETOPTS = 0x7
IP_RF = 0x8000
IP_ROUTER_ALERT = 0x5
IP_TOS = 0x1
IP_TRANSPARENT = 0x13
IP_TTL = 0x2
IP_UNBLOCK_SOURCE = 0x25
IP_UNICAST_IF = 0x32
IP_XFRM_POLICY = 0x11
ISIG = 0x1
ISTRIP = 0x20
IUCLC = 0x200
IUTF8 = 0x4000
IXANY = 0x800
IXOFF = 0x1000
IXON = 0x400
LINUX_REBOOT_CMD_CAD_OFF = 0x0
LINUX_REBOOT_CMD_CAD_ON = 0x89abcdef
LINUX_REBOOT_CMD_HALT = 0xcdef0123
LINUX_REBOOT_CMD_KEXEC = 0x45584543
LINUX_REBOOT_CMD_POWER_OFF = 0x4321fedc
LINUX_REBOOT_CMD_RESTART = 0x1234567
LINUX_REBOOT_CMD_RESTART2 = 0xa1b2c3d4
LINUX_REBOOT_CMD_SW_SUSPEND = 0xd000fce2
LINUX_REBOOT_MAGIC1 = 0xfee1dead
LINUX_REBOOT_MAGIC2 = 0x28121969
LOCK_EX = 0x2
LOCK_NB = 0x4
LOCK_SH = 0x1
LOCK_UN = 0x8
MADV_DODUMP = 0x11
MADV_DOFORK = 0xb
MADV_DONTDUMP = 0x10
MADV_DONTFORK = 0xa
MADV_DONTNEED = 0x4
MADV_HUGEPAGE = 0xe
MADV_HWPOISON = 0x64
MADV_MERGEABLE = 0xc
MADV_NOHUGEPAGE = 0xf
MADV_NORMAL = 0x0
MADV_RANDOM = 0x1
MADV_REMOVE = 0x9
MADV_SEQUENTIAL = 0x2
MADV_UNMERGEABLE = 0xd
MADV_WILLNEED = 0x3
MAP_ANON = 0x20
MAP_ANONYMOUS = 0x20
MAP_DENYWRITE = 0x800
MAP_EXECUTABLE = 0x1000
MAP_FILE = 0x0
MAP_FIXED = 0x10
MAP_GROWSDOWN = 0x100
MAP_HUGETLB = 0x40000
MAP_HUGE_MASK = 0x3f
MAP_HUGE_SHIFT = 0x1a
MAP_LOCKED = 0x2000
MAP_NONBLOCK = 0x10000
MAP_NORESERVE = 0x4000
MAP_POPULATE = 0x8000
MAP_PRIVATE = 0x2
MAP_SHARED = 0x1
MAP_STACK = 0x20000
MAP_TYPE = 0xf
MCL_CURRENT = 0x1
MCL_FUTURE = 0x2
MNT_DETACH = 0x2
MNT_EXPIRE = 0x4
MNT_FORCE = 0x1
MSG_CMSG_CLOEXEC = 0x40000000
MSG_CONFIRM = 0x800
MSG_CTRUNC = 0x8
MSG_DONTROUTE = 0x4
MSG_DONTWAIT = 0x40
MSG_EOR = 0x80
MSG_ERRQUEUE = 0x2000
MSG_FASTOPEN = 0x20000000
MSG_FIN = 0x200
MSG_MORE = 0x8000
MSG_NOSIGNAL = 0x4000
MSG_OOB = 0x1
MSG_PEEK = 0x2
MSG_PROXY = 0x10
MSG_RST = 0x1000
MSG_SYN = 0x400
MSG_TRUNC = 0x20
MSG_TRYHARD = 0x4
MSG_WAITALL = 0x100
MSG_WAITFORONE = 0x10000
MS_ACTIVE = 0x40000000
MS_ASYNC = 0x1
MS_BIND = 0x1000
MS_DIRSYNC = 0x80
MS_INVALIDATE = 0x2
MS_I_VERSION = 0x800000
MS_KERNMOUNT = 0x400000
MS_MANDLOCK = 0x40
MS_MGC_MSK = 0xffff0000
MS_MGC_VAL = 0xc0ed0000
MS_MOVE = 0x2000
MS_NOATIME = 0x400
MS_NODEV = 0x4
MS_NODIRATIME = 0x800
MS_NOEXEC = 0x8
MS_NOSUID = 0x2
MS_NOUSER = -0x80000000
MS_POSIXACL = 0x10000
MS_PRIVATE = 0x40000
MS_RDONLY = 0x1
MS_REC = 0x4000
MS_RELATIME = 0x200000
MS_REMOUNT = 0x20
MS_RMT_MASK = 0x800051
MS_SHARED = 0x100000
MS_SILENT = 0x8000
MS_SLAVE = 0x80000
MS_STRICTATIME = 0x1000000
MS_SYNC = 0x4
MS_SYNCHRONOUS = 0x10
MS_UNBINDABLE = 0x20000
NAME_MAX = 0xff
NETLINK_ADD_MEMBERSHIP = 0x1
NETLINK_AUDIT = 0x9
NETLINK_BROADCAST_ERROR = 0x4
NETLINK_CONNECTOR = 0xb
NETLINK_CRYPTO = 0x15
NETLINK_DNRTMSG = 0xe
NETLINK_DROP_MEMBERSHIP = 0x2
NETLINK_ECRYPTFS = 0x13
NETLINK_FIB_LOOKUP = 0xa
NETLINK_FIREWALL = 0x3
NETLINK_GENERIC = 0x10
NETLINK_INET_DIAG = 0x4
NETLINK_IP6_FW = 0xd
NETLINK_ISCSI = 0x8
NETLINK_KOBJECT_UEVENT = 0xf
NETLINK_NETFILTER = 0xc
NETLINK_NFLOG = 0x5
NETLINK_NO_ENOBUFS = 0x5
NETLINK_PKTINFO = 0x3
NETLINK_RDMA = 0x14
NETLINK_ROUTE = 0x0
NETLINK_RX_RING = 0x6
NETLINK_SCSITRANSPORT = 0x12
NETLINK_SELINUX = 0x7
NETLINK_SOCK_DIAG = 0x4
NETLINK_TX_RING = 0x7
NETLINK_UNUSED = 0x1
NETLINK_USERSOCK = 0x2
NETLINK_XFRM = 0x6
NL0 = 0x0
NL1 = 0x100
NLA_ALIGNTO = 0x4
NLA_F_NESTED = 0x8000
NLA_F_NET_BYTEORDER = 0x4000
NLA_HDRLEN = 0x4
NLDLY = 0x100
NLMSG_ALIGNTO = 0x4
NLMSG_DONE = 0x3
NLMSG_ERROR = 0x2
NLMSG_HDRLEN = 0x10
NLMSG_MIN_TYPE = 0x10
NLMSG_NOOP = 0x1
NLMSG_OVERRUN = 0x4
NLM_F_ACK = 0x4
NLM_F_APPEND = 0x800
NLM_F_ATOMIC = 0x400
NLM_F_CREATE = 0x400
NLM_F_DUMP = 0x300
NLM_F_DUMP_INTR = 0x10
NLM_F_ECHO = 0x8
NLM_F_EXCL = 0x200
NLM_F_MATCH = 0x200
NLM_F_MULTI = 0x2
NLM_F_REPLACE = 0x100
NLM_F_REQUEST = 0x1
NLM_F_ROOT = 0x100
NOFLSH = 0x80
OCRNL = 0x8
OFDEL = 0x80
OFILL = 0x40
OLCUC = 0x2
ONLCR = 0x4
ONLRET = 0x20
ONOCR = 0x10
OPOST = 0x1
O_ACCMODE = 0x3
O_APPEND = 0x400
O_ASYNC = 0x2000
O_CLOEXEC = 0x80000
O_CREAT = 0x40
O_DIRECT = 0x10000
O_DIRECTORY = 0x4000
O_DSYNC = 0x1000
O_EXCL = 0x80
O_FSYNC = 0x101000
O_LARGEFILE = 0x0
O_NDELAY = 0x800
O_NOATIME = 0x40000
O_NOCTTY = 0x100
O_NOFOLLOW = 0x8000
O_NONBLOCK = 0x800
O_PATH = 0x200000
O_RDONLY = 0x0
O_RDWR = 0x2
O_RSYNC = 0x101000
O_SYNC = 0x101000
O_TMPFILE = 0x410000
O_TRUNC = 0x200
O_WRONLY = 0x1
PACKET_ADD_MEMBERSHIP = 0x1
PACKET_AUXDATA = 0x8
PACKET_BROADCAST = 0x1
PACKET_COPY_THRESH = 0x7
PACKET_DROP_MEMBERSHIP = 0x2
PACKET_FANOUT = 0x12
PACKET_FANOUT_CPU = 0x2
PACKET_FANOUT_FLAG_DEFRAG = 0x8000
PACKET_FANOUT_FLAG_ROLLOVER = 0x1000
PACKET_FANOUT_HASH = 0x0
PACKET_FANOUT_LB = 0x1
PACKET_FANOUT_RND = 0x4
PACKET_FANOUT_ROLLOVER = 0x3
PACKET_FASTROUTE = 0x6
PACKET_HDRLEN = 0xb
PACKET_HOST = 0x0
PACKET_LOOPBACK = 0x5
PACKET_LOSS = 0xe
PACKET_MR_ALLMULTI = 0x2
PACKET_MR_MULTICAST = 0x0
PACKET_MR_PROMISC = 0x1
PACKET_MR_UNICAST = 0x3
PACKET_MULTICAST = 0x2
PACKET_ORIGDEV = 0x9
PACKET_OTHERHOST = 0x3
PACKET_OUTGOING = 0x4
PACKET_RECV_OUTPUT = 0x3
PACKET_RESERVE = 0xc
PACKET_RX_RING = 0x5
PACKET_STATISTICS = 0x6
PACKET_TIMESTAMP = 0x11
PACKET_TX_HAS_OFF = 0x13
PACKET_TX_RING = 0xd
PACKET_TX_TIMESTAMP = 0x10
PACKET_VERSION = 0xa
PACKET_VNET_HDR = 0xf
PARENB = 0x100
PARITY_CRC16_PR0 = 0x2
PARITY_CRC16_PR0_CCITT = 0x4
PARITY_CRC16_PR1 = 0x3
PARITY_CRC16_PR1_CCITT = 0x5
PARITY_CRC32_PR0_CCITT = 0x6
PARITY_CRC32_PR1_CCITT = 0x7
PARITY_DEFAULT = 0x0
PARITY_NONE = 0x1
PARMRK = 0x8
PARODD = 0x200
PENDIN = 0x4000
PRIO_PGRP = 0x1
PRIO_PROCESS = 0x0
PRIO_USER = 0x2
PROT_EXEC = 0x4
PROT_GROWSDOWN = 0x1000000
PROT_GROWSUP = 0x2000000
PROT_NONE = 0x0
PROT_READ = 0x1
PROT_WRITE = 0x2
PR_CAPBSET_DROP = 0x18
PR_CAPBSET_READ = 0x17
PR_ENDIAN_BIG = 0x0
PR_ENDIAN_LITTLE = 0x1
PR_ENDIAN_PPC_LITTLE = 0x2
PR_FPEMU_NOPRINT = 0x1
PR_FPEMU_SIGFPE = 0x2
PR_FP_EXC_ASYNC = 0x2
PR_FP_EXC_DISABLED = 0x0
PR_FP_EXC_DIV = 0x10000
PR_FP_EXC_INV = 0x100000
PR_FP_EXC_NONRECOV = 0x1
PR_FP_EXC_OVF = 0x20000
PR_FP_EXC_PRECISE = 0x3
PR_FP_EXC_RES = 0x80000
PR_FP_EXC_SW_ENABLE = 0x80
PR_FP_EXC_UND = 0x40000
PR_GET_CHILD_SUBREAPER = 0x25
PR_GET_DUMPABLE = 0x3
PR_GET_ENDIAN = 0x13
PR_GET_FPEMU = 0x9
PR_GET_FPEXC = 0xb
PR_GET_KEEPCAPS = 0x7
PR_GET_NAME = 0x10
PR_GET_NO_NEW_PRIVS = 0x27
PR_GET_PDEATHSIG = 0x2
PR_GET_SECCOMP = 0x15
PR_GET_SECUREBITS = 0x1b
PR_GET_TID_ADDRESS = 0x28
PR_GET_TIMERSLACK = 0x1e
PR_GET_TIMING = 0xd
PR_GET_TSC = 0x19
PR_GET_UNALIGN = 0x5
PR_MCE_KILL = 0x21
PR_MCE_KILL_CLEAR = 0x0
PR_MCE_KILL_DEFAULT = 0x2
PR_MCE_KILL_EARLY = 0x1
PR_MCE_KILL_GET = 0x22
PR_MCE_KILL_LATE = 0x0
PR_MCE_KILL_SET = 0x1
PR_SET_CHILD_SUBREAPER = 0x24
PR_SET_DUMPABLE = 0x4
PR_SET_ENDIAN = 0x14
PR_SET_FPEMU = 0xa
PR_SET_FPEXC = 0xc
PR_SET_KEEPCAPS = 0x8
PR_SET_MM = 0x23
PR_SET_MM_ARG_END = 0x9
PR_SET_MM_ARG_START = 0x8
PR_SET_MM_AUXV = 0xc
PR_SET_MM_BRK = 0x7
PR_SET_MM_END_CODE = 0x2
PR_SET_MM_END_DATA = 0x4
PR_SET_MM_ENV_END = 0xb
PR_SET_MM_ENV_START = 0xa
PR_SET_MM_EXE_FILE = 0xd
PR_SET_MM_START_BRK = 0x6
PR_SET_MM_START_CODE = 0x1
PR_SET_MM_START_DATA = 0x3
PR_SET_MM_START_STACK = 0x5
PR_SET_NAME = 0xf
PR_SET_NO_NEW_PRIVS = 0x26
PR_SET_PDEATHSIG = 0x1
PR_SET_PTRACER = 0x59616d61
PR_SET_PTRACER_ANY = -0x1
PR_SET_SECCOMP = 0x16
PR_SET_SECUREBITS = 0x1c
PR_SET_TIMERSLACK = 0x1d
PR_SET_TIMING = 0xe
PR_SET_TSC = 0x1a
PR_SET_UNALIGN = 0x6
PR_TASK_PERF_EVENTS_DISABLE = 0x1f
PR_TASK_PERF_EVENTS_ENABLE = 0x20
PR_TIMING_STATISTICAL = 0x0
PR_TIMING_TIMESTAMP = 0x1
PR_TSC_ENABLE = 0x1
PR_TSC_SIGSEGV = 0x2
PR_UNALIGN_NOPRINT = 0x1
PR_UNALIGN_SIGBUS = 0x2
PTRACE_ATTACH = 0x10
PTRACE_CONT = 0x7
PTRACE_DETACH = 0x11
PTRACE_EVENT_CLONE = 0x3
PTRACE_EVENT_EXEC = 0x4
PTRACE_EVENT_EXIT = 0x6
PTRACE_EVENT_FORK = 0x1
PTRACE_EVENT_SECCOMP = 0x7
PTRACE_EVENT_STOP = 0x80
PTRACE_EVENT_VFORK = 0x2
PTRACE_EVENT_VFORK_DONE = 0x5
PTRACE_GETEVENTMSG = 0x4201
PTRACE_GETREGS = 0xc
PTRACE_GETREGSET = 0x4204
PTRACE_GETSIGINFO = 0x4202
PTRACE_GETSIGMASK = 0x420a
PTRACE_INTERRUPT = 0x4207
PTRACE_KILL = 0x8
PTRACE_LISTEN = 0x4208
PTRACE_O_EXITKILL = 0x100000
PTRACE_O_MASK = 0x1000ff
PTRACE_O_TRACECLONE = 0x8
PTRACE_O_TRACEEXEC = 0x10
PTRACE_O_TRACEEXIT = 0x40
PTRACE_O_TRACEFORK = 0x2
PTRACE_O_TRACESECCOMP = 0x80
PTRACE_O_TRACESYSGOOD = 0x1
PTRACE_O_TRACEVFORK = 0x4
PTRACE_O_TRACEVFORKDONE = 0x20
PTRACE_PEEKDATA = 0x2
PTRACE_PEEKSIGINFO = 0x4209
PTRACE_PEEKSIGINFO_SHARED = 0x1
PTRACE_PEEKTEXT = 0x1
PTRACE_PEEKUSR = 0x3
PTRACE_POKEDATA = 0x5
PTRACE_POKETEXT = 0x4
PTRACE_POKEUSR = 0x6
PTRACE_SEIZE = 0x4206
PTRACE_SETOPTIONS = 0x4200
PTRACE_SETREGS = 0xd
PTRACE_SETREGSET = 0x4205
PTRACE_SETSIGINFO = 0x4203
PTRACE_SETSIGMASK = 0x420b
PTRACE_SINGLESTEP = 0x9
PTRACE_SYSCALL = 0x18
PTRACE_TRACEME = 0x0
RLIMIT_AS = 0x9
RLIMIT_CORE = 0x4
RLIMIT_CPU = 0x0
RLIMIT_DATA = 0x2
RLIMIT_FSIZE = 0x1
RLIMIT_NOFILE = 0x7
RLIMIT_STACK = 0x3
RLIM_INFINITY = -0x1
RTAX_ADVMSS = 0x8
RTAX_CWND = 0x7
RTAX_FEATURES = 0xc
RTAX_FEATURE_ALLFRAG = 0x8
RTAX_FEATURE_ECN = 0x1
RTAX_FEATURE_SACK = 0x2
RTAX_FEATURE_TIMESTAMP = 0x4
RTAX_HOPLIMIT = 0xa
RTAX_INITCWND = 0xb
RTAX_INITRWND = 0xe
RTAX_LOCK = 0x1
RTAX_MAX = 0xf
RTAX_MTU = 0x2
RTAX_QUICKACK = 0xf
RTAX_REORDERING = 0x9
RTAX_RTO_MIN = 0xd
RTAX_RTT = 0x4
RTAX_RTTVAR = 0x5
RTAX_SSTHRESH = 0x6
RTAX_UNSPEC = 0x0
RTAX_WINDOW = 0x3
RTA_ALIGNTO = 0x4
RTA_MAX = 0x11
RTCF_DIRECTSRC = 0x4000000
RTCF_DOREDIRECT = 0x1000000
RTCF_LOG = 0x2000000
RTCF_MASQ = 0x400000
RTCF_NAT = 0x800000
RTCF_VALVE = 0x200000
RTF_ADDRCLASSMASK = 0xf8000000
RTF_ADDRCONF = 0x40000
RTF_ALLONLINK = 0x20000
RTF_BROADCAST = 0x10000000
RTF_CACHE = 0x1000000
RTF_DEFAULT = 0x10000
RTF_DYNAMIC = 0x10
RTF_FLOW = 0x2000000
RTF_GATEWAY = 0x2
RTF_HOST = 0x4
RTF_INTERFACE = 0x40000000
RTF_IRTT = 0x100
RTF_LINKRT = 0x100000
RTF_LOCAL = 0x80000000
RTF_MODIFIED = 0x20
RTF_MSS = 0x40
RTF_MTU = 0x40
RTF_MULTICAST = 0x20000000
RTF_NAT = 0x8000000
RTF_NOFORWARD = 0x1000
RTF_NONEXTHOP = 0x200000
RTF_NOPMTUDISC = 0x4000
RTF_POLICY = 0x4000000
RTF_REINSTATE = 0x8
RTF_REJECT = 0x200
RTF_STATIC = 0x400
RTF_THROW = 0x2000
RTF_UP = 0x1
RTF_WINDOW = 0x80
RTF_XRESOLVE = 0x800
RTM_BASE = 0x10
RTM_DELACTION = 0x31
RTM_DELADDR = 0x15
RTM_DELADDRLABEL = 0x49
RTM_DELLINK = 0x11
RTM_DELMDB = 0x55
RTM_DELNEIGH = 0x1d
RTM_DELQDISC = 0x25
RTM_DELROUTE = 0x19
RTM_DELRULE = 0x21
RTM_DELTCLASS = 0x29
RTM_DELTFILTER = 0x2d
RTM_F_CLONED = 0x200
RTM_F_EQUALIZE = 0x400
RTM_F_NOTIFY = 0x100
RTM_F_PREFIX = 0x800
RTM_GETACTION = 0x32
RTM_GETADDR = 0x16
RTM_GETADDRLABEL = 0x4a
RTM_GETANYCAST = 0x3e
RTM_GETDCB = 0x4e
RTM_GETLINK = 0x12
RTM_GETMDB = 0x56
RTM_GETMULTICAST = 0x3a
RTM_GETNEIGH = 0x1e
RTM_GETNEIGHTBL = 0x42
RTM_GETNETCONF = 0x52
RTM_GETQDISC = 0x26
RTM_GETROUTE = 0x1a
RTM_GETRULE = 0x22
RTM_GETTCLASS = 0x2a
RTM_GETTFILTER = 0x2e
RTM_MAX = 0x57
RTM_NEWACTION = 0x30
RTM_NEWADDR = 0x14
RTM_NEWADDRLABEL = 0x48
RTM_NEWLINK = 0x10
RTM_NEWMDB = 0x54
RTM_NEWNDUSEROPT = 0x44
RTM_NEWNEIGH = 0x1c
RTM_NEWNEIGHTBL = 0x40
RTM_NEWNETCONF = 0x50
RTM_NEWPREFIX = 0x34
RTM_NEWQDISC = 0x24
RTM_NEWROUTE = 0x18
RTM_NEWRULE = 0x20
RTM_NEWTCLASS = 0x28
RTM_NEWTFILTER = 0x2c
RTM_NR_FAMILIES = 0x12
RTM_NR_MSGTYPES = 0x48
RTM_SETDCB = 0x4f
RTM_SETLINK = 0x13
RTM_SETNEIGHTBL = 0x43
RTNH_ALIGNTO = 0x4
RTNH_F_DEAD = 0x1
RTNH_F_ONLINK = 0x4
RTNH_F_PERVASIVE = 0x2
RTN_MAX = 0xb
RTPROT_BIRD = 0xc
RTPROT_BOOT = 0x3
RTPROT_DHCP = 0x10
RTPROT_DNROUTED = 0xd
RTPROT_GATED = 0x8
RTPROT_KERNEL = 0x2
RTPROT_MROUTED = 0x11
RTPROT_MRT = 0xa
RTPROT_NTK = 0xf
RTPROT_RA = 0x9
RTPROT_REDIRECT = 0x1
RTPROT_STATIC = 0x4
RTPROT_UNSPEC = 0x0
RTPROT_XORP = 0xe
RTPROT_ZEBRA = 0xb
RT_CLASS_DEFAULT = 0xfd
RT_CLASS_LOCAL = 0xff
RT_CLASS_MAIN = 0xfe
RT_CLASS_MAX = 0xff
RT_CLASS_UNSPEC = 0x0
RUSAGE_CHILDREN = -0x1
RUSAGE_SELF = 0x0
RUSAGE_THREAD = 0x1
SCM_CREDENTIALS = 0x2
SCM_RIGHTS = 0x1
SCM_TIMESTAMP = 0x1d
SCM_TIMESTAMPING = 0x25
SCM_TIMESTAMPNS = 0x23
SCM_WIFI_STATUS = 0x29
SHUT_RD = 0x0
SHUT_RDWR = 0x2
SHUT_WR = 0x1
SIOCADDDLCI = 0x8980
SIOCADDMULTI = 0x8931
SIOCADDRT = 0x890b
SIOCATMARK = 0x8905
SIOCDARP = 0x8953
SIOCDELDLCI = 0x8981
SIOCDELMULTI = 0x8932
SIOCDELRT = 0x890c
SIOCDEVPRIVATE = 0x89f0
SIOCDIFADDR = 0x8936
SIOCDRARP = 0x8960
SIOCGARP = 0x8954
SIOCGIFADDR = 0x8915
SIOCGIFBR = 0x8940
SIOCGIFBRDADDR = 0x8919
SIOCGIFCONF = 0x8912
SIOCGIFCOUNT = 0x8938
SIOCGIFDSTADDR = 0x8917
SIOCGIFENCAP = 0x8925
SIOCGIFFLAGS = 0x8913
SIOCGIFHWADDR = 0x8927
SIOCGIFINDEX = 0x8933
SIOCGIFMAP = 0x8970
SIOCGIFMEM = 0x891f
SIOCGIFMETRIC = 0x891d
SIOCGIFMTU = 0x8921
SIOCGIFNAME = 0x8910
SIOCGIFNETMASK = 0x891b
SIOCGIFPFLAGS = 0x8935
SIOCGIFSLAVE = 0x8929
SIOCGIFTXQLEN = 0x8942
SIOCGPGRP = 0x8904
SIOCGRARP = 0x8961
SIOCGSTAMP = 0x8906
SIOCGSTAMPNS = 0x8907
SIOCPROTOPRIVATE = 0x89e0
SIOCRTMSG = 0x890d
SIOCSARP = 0x8955
SIOCSIFADDR = 0x8916
SIOCSIFBR = 0x8941
SIOCSIFBRDADDR = 0x891a
SIOCSIFDSTADDR = 0x8918
SIOCSIFENCAP = 0x8926
SIOCSIFFLAGS = 0x8914
SIOCSIFHWADDR = 0x8924
SIOCSIFHWBROADCAST = 0x8937
SIOCSIFLINK = 0x8911
SIOCSIFMAP = 0x8971
SIOCSIFMEM = 0x8920
SIOCSIFMETRIC = 0x891e
SIOCSIFMTU = 0x8922
SIOCSIFNAME = 0x8923
SIOCSIFNETMASK = 0x891c
SIOCSIFPFLAGS = 0x8934
SIOCSIFSLAVE = 0x8930
SIOCSIFTXQLEN = 0x8943
SIOCSPGRP = 0x8902
SIOCSRARP = 0x8962
SOCK_CLOEXEC = 0x80000
SOCK_DCCP = 0x6
SOCK_DGRAM = 0x2
SOCK_NONBLOCK = 0x800
SOCK_PACKET = 0xa
SOCK_RAW = 0x3
SOCK_RDM = 0x4
SOCK_SEQPACKET = 0x5
SOCK_STREAM = 0x1
SOL_AAL = 0x109
SOL_ATM = 0x108
SOL_DECNET = 0x105
SOL_ICMPV6 = 0x3a
SOL_IP = 0x0
SOL_IPV6 = 0x29
SOL_IRDA = 0x10a
SOL_PACKET = 0x107
SOL_RAW = 0xff
SOL_SOCKET = 0x1
SOL_TCP = 0x6
SOL_X25 = 0x106
SOMAXCONN = 0x80
SO_ACCEPTCONN = 0x1e
SO_ATTACH_FILTER = 0x1a
SO_BINDTODEVICE = 0x19
SO_BROADCAST = 0x6
SO_BSDCOMPAT = 0xe
SO_BUSY_POLL = 0x2e
SO_DEBUG = 0x1
SO_DETACH_FILTER = 0x1b
SO_DOMAIN = 0x27
SO_DONTROUTE = 0x5
SO_ERROR = 0x4
SO_GET_FILTER = 0x1a
SO_KEEPALIVE = 0x9
SO_LINGER = 0xd
SO_LOCK_FILTER = 0x2c
SO_MARK = 0x24
SO_MAX_PACING_RATE = 0x2f
SO_NOFCS = 0x2b
SO_NO_CHECK = 0xb
SO_OOBINLINE = 0xa
SO_PASSCRED = 0x10
SO_PASSSEC = 0x22
SO_PEEK_OFF = 0x2a
SO_PEERCRED = 0x11
SO_PEERNAME = 0x1c
SO_PEERSEC = 0x1f
SO_PRIORITY = 0xc
SO_PROTOCOL = 0x26
SO_RCVBUF = 0x8
SO_RCVBUFFORCE = 0x21
SO_RCVLOWAT = 0x12
SO_RCVTIMEO = 0x14
SO_REUSEADDR = 0x2
SO_REUSEPORT = 0xf
SO_RXQ_OVFL = 0x28
SO_SECURITY_AUTHENTICATION = 0x16
SO_SECURITY_ENCRYPTION_NETWORK = 0x18
SO_SECURITY_ENCRYPTION_TRANSPORT = 0x17
SO_SELECT_ERR_QUEUE = 0x2d
SO_SNDBUF = 0x7
SO_SNDBUFFORCE = 0x20
SO_SNDLOWAT = 0x13
SO_SNDTIMEO = 0x15
SO_TIMESTAMP = 0x1d
SO_TIMESTAMPING = 0x25
SO_TIMESTAMPNS = 0x23
SO_TYPE = 0x3
SO_WIFI_STATUS = 0x29
S_BLKSIZE = 0x200
S_IEXEC = 0x40
S_IFBLK = 0x6000
S_IFCHR = 0x2000
S_IFDIR = 0x4000
S_IFIFO = 0x1000
S_IFLNK = 0xa000
S_IFMT = 0xf000
S_IFREG = 0x8000
S_IFSOCK = 0xc000
S_IREAD = 0x100
S_IRGRP = 0x20
S_IROTH = 0x4
S_IRUSR = 0x100
S_IRWXG = 0x38
S_IRWXO = 0x7
S_IRWXU = 0x1c0
S_ISGID = 0x400
S_ISUID = 0x800
S_ISVTX = 0x200
S_IWGRP = 0x10
S_IWOTH = 0x2
S_IWRITE = 0x80
S_IWUSR = 0x80
S_IXGRP = 0x8
S_IXOTH = 0x1
S_IXUSR = 0x40
TAB0 = 0x0
TAB1 = 0x800
TAB2 = 0x1000
TAB3 = 0x1800
TABDLY = 0x1800
TCFLSH = 0x540b
TCGETA = 0x5405
TCGETS = 0x5401
TCGETS2 = 0x802c542a
TCGETX = 0x5432
TCIFLUSH = 0x0
TCIOFF = 0x2
TCIOFLUSH = 0x2
TCION = 0x3
TCOFLUSH = 0x1
TCOOFF = 0x0
TCOON = 0x1
TCP_CONGESTION = 0xd
TCP_COOKIE_IN_ALWAYS = 0x1
TCP_COOKIE_MAX = 0x10
TCP_COOKIE_MIN = 0x8
TCP_COOKIE_OUT_NEVER = 0x2
TCP_COOKIE_PAIR_SIZE = 0x20
TCP_COOKIE_TRANSACTIONS = 0xf
TCP_CORK = 0x3
TCP_DEFER_ACCEPT = 0x9
TCP_FASTOPEN = 0x17
TCP_INFO = 0xb
TCP_KEEPCNT = 0x6
TCP_KEEPIDLE = 0x4
TCP_KEEPINTVL = 0x5
TCP_LINGER2 = 0x8
TCP_MAXSEG = 0x2
TCP_MAXWIN = 0xffff
TCP_MAX_WINSHIFT = 0xe
TCP_MD5SIG = 0xe
TCP_MD5SIG_MAXKEYLEN = 0x50
TCP_MSS = 0x200
TCP_MSS_DEFAULT = 0x218
TCP_MSS_DESIRED = 0x4c4
TCP_NODELAY = 0x1
TCP_QUEUE_SEQ = 0x15
TCP_QUICKACK = 0xc
TCP_REPAIR = 0x13
TCP_REPAIR_OPTIONS = 0x16
TCP_REPAIR_QUEUE = 0x14
TCP_SYNCNT = 0x7
TCP_S_DATA_IN = 0x4
TCP_S_DATA_OUT = 0x8
TCP_THIN_DUPACK = 0x11
TCP_THIN_LINEAR_TIMEOUTS = 0x10
TCP_TIMESTAMP = 0x18
TCP_USER_TIMEOUT = 0x12
TCP_WINDOW_CLAMP = 0xa
TCSAFLUSH = 0x2
TCSBRK = 0x5409
TCSBRKP = 0x5425
TCSETA = 0x5406
TCSETAF = 0x5408
TCSETAW = 0x5407
TCSETS = 0x5402
TCSETS2 = 0x402c542b
TCSETSF = 0x5404
TCSETSF2 = 0x402c542d
TCSETSW = 0x5403
TCSETSW2 = 0x402c542c
TCSETX = 0x5433
TCSETXF = 0x5434
TCSETXW = 0x5435
TCXONC = 0x540a
TIOCCBRK = 0x5428
TIOCCONS = 0x541d
TIOCEXCL = 0x540c
TIOCGDEV = 0x80045432
TIOCGETD = 0x5424
TIOCGEXCL = 0x80045440
TIOCGICOUNT = 0x545d
TIOCGLCKTRMIOS = 0x5456
TIOCGPGRP = 0x540f
TIOCGPKT = 0x80045438
TIOCGPTLCK = 0x80045439
TIOCGPTN = 0x80045430
TIOCGRS485 = 0x542e
TIOCGSERIAL = 0x541e
TIOCGSID = 0x5429
TIOCGSOFTCAR = 0x5419
TIOCGWINSZ = 0x5413
TIOCINQ = 0x541b
TIOCLINUX = 0x541c
TIOCMBIC = 0x5417
TIOCMBIS = 0x5416
TIOCMGET = 0x5415
TIOCMIWAIT = 0x545c
TIOCMSET = 0x5418
TIOCM_CAR = 0x40
TIOCM_CD = 0x40
TIOCM_CTS = 0x20
TIOCM_DSR = 0x100
TIOCM_DTR = 0x2
TIOCM_LE = 0x1
TIOCM_RI = 0x80
TIOCM_RNG = 0x80
TIOCM_RTS = 0x4
TIOCM_SR = 0x10
TIOCM_ST = 0x8
TIOCNOTTY = 0x5422
TIOCNXCL = 0x540d
TIOCOUTQ = 0x5411
TIOCPKT = 0x5420
TIOCPKT_DATA = 0x0
TIOCPKT_DOSTOP = 0x20
TIOCPKT_FLUSHREAD = 0x1
TIOCPKT_FLUSHWRITE = 0x2
TIOCPKT_IOCTL = 0x40
TIOCPKT_NOSTOP = 0x10
TIOCPKT_START = 0x8
TIOCPKT_STOP = 0x4
TIOCSBRK = 0x5427
TIOCSCTTY = 0x540e
TIOCSERCONFIG = 0x5453
TIOCSERGETLSR = 0x5459
TIOCSERGETMULTI = 0x545a
TIOCSERGSTRUCT = 0x5458
TIOCSERGWILD = 0x5454
TIOCSERSETMULTI = 0x545b
TIOCSERSWILD = 0x5455
TIOCSER_TEMT = 0x1
TIOCSETD = 0x5423
TIOCSIG = 0x40045436
TIOCSLCKTRMIOS = 0x5457
TIOCSPGRP = 0x5410
TIOCSPTLCK = 0x40045431
TIOCSRS485 = 0x542f
TIOCSSERIAL = 0x541f
TIOCSSOFTCAR = 0x541a
TIOCSTI = 0x5412
TIOCSWINSZ = 0x5414
TIOCVHANGUP = 0x5437
TOSTOP = 0x100
TUNATTACHFILTER = 0x401054d5
TUNDETACHFILTER = 0x401054d6
TUNGETFEATURES = 0x800454cf
TUNGETFILTER = 0x801054db
TUNGETIFF = 0x800454d2
TUNGETSNDBUF = 0x800454d3
TUNGETVNETHDRSZ = 0x800454d7
TUNSETDEBUG = 0x400454c9
TUNSETGROUP = 0x400454ce
TUNSETIFF = 0x400454ca
TUNSETIFINDEX = 0x400454da
TUNSETLINK = 0x400454cd
TUNSETNOCSUM = 0x400454c8
TUNSETOFFLOAD = 0x400454d0
TUNSETOWNER = 0x400454cc
TUNSETPERSIST = 0x400454cb
TUNSETQUEUE = 0x400454d9
TUNSETSNDBUF = 0x400454d4
TUNSETTXFILTER = 0x400454d1
TUNSETVNETHDRSZ = 0x400454d8
VDISCARD = 0xd
VEOF = 0x4
VEOL = 0xb
VEOL2 = 0x10
VERASE = 0x2
VINTR = 0x0
VKILL = 0x3
VLNEXT = 0xf
VMIN = 0x6
VQUIT = 0x1
VREPRINT = 0xc
VSTART = 0x8
VSTOP = 0x9
VSUSP = 0xa
VSWTC = 0x7
VT0 = 0x0
VT1 = 0x4000
VTDLY = 0x4000
VTIME = 0x5
VWERASE = 0xe
WALL = 0x40000000
WCLONE = 0x80000000
WCONTINUED = 0x8
WEXITED = 0x4
WNOHANG = 0x1
WNOTHREAD = 0x20000000
WNOWAIT = 0x1000000
WORDSIZE = 0x40
WSTOPPED = 0x2
WUNTRACED = 0x2
XCASE = 0x4
XTABS = 0x1800
)
// Errors
const (
E2BIG = syscall.Errno(0x7)
EACCES = syscall.Errno(0xd)
EADDRINUSE = syscall.Errno(0x62)
EADDRNOTAVAIL = syscall.Errno(0x63)
EADV = syscall.Errno(0x44)
EAFNOSUPPORT = syscall.Errno(0x61)
EAGAIN = syscall.Errno(0xb)
EALREADY = syscall.Errno(0x72)
EBADE = syscall.Errno(0x34)
EBADF = syscall.Errno(0x9)
EBADFD = syscall.Errno(0x4d)
EBADMSG = syscall.Errno(0x4a)
EBADR = syscall.Errno(0x35)
EBADRQC = syscall.Errno(0x38)
EBADSLT = syscall.Errno(0x39)
EBFONT = syscall.Errno(0x3b)
EBUSY = syscall.Errno(0x10)
ECANCELED = syscall.Errno(0x7d)
ECHILD = syscall.Errno(0xa)
ECHRNG = syscall.Errno(0x2c)
ECOMM = syscall.Errno(0x46)
ECONNABORTED = syscall.Errno(0x67)
ECONNREFUSED = syscall.Errno(0x6f)
ECONNRESET = syscall.Errno(0x68)
EDEADLK = syscall.Errno(0x23)
EDEADLOCK = syscall.Errno(0x23)
EDESTADDRREQ = syscall.Errno(0x59)
EDOM = syscall.Errno(0x21)
EDOTDOT = syscall.Errno(0x49)
EDQUOT = syscall.Errno(0x7a)
EEXIST = syscall.Errno(0x11)
EFAULT = syscall.Errno(0xe)
EFBIG = syscall.Errno(0x1b)
EHOSTDOWN = syscall.Errno(0x70)
EHOSTUNREACH = syscall.Errno(0x71)
EHWPOISON = syscall.Errno(0x85)
EIDRM = syscall.Errno(0x2b)
EILSEQ = syscall.Errno(0x54)
EINPROGRESS = syscall.Errno(0x73)
EINTR = syscall.Errno(0x4)
EINVAL = syscall.Errno(0x16)
EIO = syscall.Errno(0x5)
EISCONN = syscall.Errno(0x6a)
EISDIR = syscall.Errno(0x15)
EISNAM = syscall.Errno(0x78)
EKEYEXPIRED = syscall.Errno(0x7f)
EKEYREJECTED = syscall.Errno(0x81)
EKEYREVOKED = syscall.Errno(0x80)
EL2HLT = syscall.Errno(0x33)
EL2NSYNC = syscall.Errno(0x2d)
EL3HLT = syscall.Errno(0x2e)
EL3RST = syscall.Errno(0x2f)
ELIBACC = syscall.Errno(0x4f)
ELIBBAD = syscall.Errno(0x50)
ELIBEXEC = syscall.Errno(0x53)
ELIBMAX = syscall.Errno(0x52)
ELIBSCN = syscall.Errno(0x51)
ELNRNG = syscall.Errno(0x30)
ELOOP = syscall.Errno(0x28)
EMEDIUMTYPE = syscall.Errno(0x7c)
EMFILE = syscall.Errno(0x18)
EMLINK = syscall.Errno(0x1f)
EMSGSIZE = syscall.Errno(0x5a)
EMULTIHOP = syscall.Errno(0x48)
ENAMETOOLONG = syscall.Errno(0x24)
ENAVAIL = syscall.Errno(0x77)
ENETDOWN = syscall.Errno(0x64)
ENETRESET = syscall.Errno(0x66)
ENETUNREACH = syscall.Errno(0x65)
ENFILE = syscall.Errno(0x17)
ENOANO = syscall.Errno(0x37)
ENOBUFS = syscall.Errno(0x69)
ENOCSI = syscall.Errno(0x32)
ENODATA = syscall.Errno(0x3d)
ENODEV = syscall.Errno(0x13)
ENOENT = syscall.Errno(0x2)
ENOEXEC = syscall.Errno(0x8)
ENOKEY = syscall.Errno(0x7e)
ENOLCK = syscall.Errno(0x25)
ENOLINK = syscall.Errno(0x43)
ENOMEDIUM = syscall.Errno(0x7b)
ENOMEM = syscall.Errno(0xc)
ENOMSG = syscall.Errno(0x2a)
ENONET = syscall.Errno(0x40)
ENOPKG = syscall.Errno(0x41)
ENOPROTOOPT = syscall.Errno(0x5c)
ENOSPC = syscall.Errno(0x1c)
ENOSR = syscall.Errno(0x3f)
ENOSTR = syscall.Errno(0x3c)
ENOSYS = syscall.Errno(0x26)
ENOTBLK = syscall.Errno(0xf)
ENOTCONN = syscall.Errno(0x6b)
ENOTDIR = syscall.Errno(0x14)
ENOTEMPTY = syscall.Errno(0x27)
ENOTNAM = syscall.Errno(0x76)
ENOTRECOVERABLE = syscall.Errno(0x83)
ENOTSOCK = syscall.Errno(0x58)
ENOTSUP = syscall.Errno(0x5f)
ENOTTY = syscall.Errno(0x19)
ENOTUNIQ = syscall.Errno(0x4c)
ENXIO = syscall.Errno(0x6)
EOPNOTSUPP = syscall.Errno(0x5f)
EOVERFLOW = syscall.Errno(0x4b)
EOWNERDEAD = syscall.Errno(0x82)
EPERM = syscall.Errno(0x1)
EPFNOSUPPORT = syscall.Errno(0x60)
EPIPE = syscall.Errno(0x20)
EPROTO = syscall.Errno(0x47)
EPROTONOSUPPORT = syscall.Errno(0x5d)
EPROTOTYPE = syscall.Errno(0x5b)
ERANGE = syscall.Errno(0x22)
EREMCHG = syscall.Errno(0x4e)
EREMOTE = syscall.Errno(0x42)
EREMOTEIO = syscall.Errno(0x79)
ERESTART = syscall.Errno(0x55)
ERFKILL = syscall.Errno(0x84)
EROFS = syscall.Errno(0x1e)
ESHUTDOWN = syscall.Errno(0x6c)
ESOCKTNOSUPPORT = syscall.Errno(0x5e)
ESPIPE = syscall.Errno(0x1d)
ESRCH = syscall.Errno(0x3)
ESRMNT = syscall.Errno(0x45)
ESTALE = syscall.Errno(0x74)
ESTRPIPE = syscall.Errno(0x56)
ETIME = syscall.Errno(0x3e)
ETIMEDOUT = syscall.Errno(0x6e)
ETOOMANYREFS = syscall.Errno(0x6d)
ETXTBSY = syscall.Errno(0x1a)
EUCLEAN = syscall.Errno(0x75)
EUNATCH = syscall.Errno(0x31)
EUSERS = syscall.Errno(0x57)
EWOULDBLOCK = syscall.Errno(0xb)
EXDEV = syscall.Errno(0x12)
EXFULL = syscall.Errno(0x36)
)
// Signals
const (
SIGABRT = syscall.Signal(0x6)
SIGALRM = syscall.Signal(0xe)
SIGBUS = syscall.Signal(0x7)
SIGCHLD = syscall.Signal(0x11)
SIGCLD = syscall.Signal(0x11)
SIGCONT = syscall.Signal(0x12)
SIGFPE = syscall.Signal(0x8)
SIGHUP = syscall.Signal(0x1)
SIGILL = syscall.Signal(0x4)
SIGINT = syscall.Signal(0x2)
SIGIO = syscall.Signal(0x1d)
SIGIOT = syscall.Signal(0x6)
SIGKILL = syscall.Signal(0x9)
SIGPIPE = syscall.Signal(0xd)
SIGPOLL = syscall.Signal(0x1d)
SIGPROF = syscall.Signal(0x1b)
SIGPWR = syscall.Signal(0x1e)
SIGQUIT = syscall.Signal(0x3)
SIGSEGV = syscall.Signal(0xb)
SIGSTKFLT = syscall.Signal(0x10)
SIGSTOP = syscall.Signal(0x13)
SIGSYS = syscall.Signal(0x1f)
SIGTERM = syscall.Signal(0xf)
SIGTRAP = syscall.Signal(0x5)
SIGTSTP = syscall.Signal(0x14)
SIGTTIN = syscall.Signal(0x15)
SIGTTOU = syscall.Signal(0x16)
SIGUNUSED = syscall.Signal(0x1f)
SIGURG = syscall.Signal(0x17)
SIGUSR1 = syscall.Signal(0xa)
SIGUSR2 = syscall.Signal(0xc)
SIGVTALRM = syscall.Signal(0x1a)
SIGWINCH = syscall.Signal(0x1c)
SIGXCPU = syscall.Signal(0x18)
SIGXFSZ = syscall.Signal(0x19)
)
// Error table
var errors = [...]string{
1: "operation not permitted",
2: "no such file or directory",
3: "no such process",
4: "interrupted system call",
5: "input/output error",
6: "no such device or address",
7: "argument list too long",
8: "exec format error",
9: "bad file descriptor",
10: "no child processes",
11: "resource temporarily unavailable",
12: "cannot allocate memory",
13: "permission denied",
14: "bad address",
15: "block device required",
16: "device or resource busy",
17: "file exists",
18: "invalid cross-device link",
19: "no such device",
20: "not a directory",
21: "is a directory",
22: "invalid argument",
23: "too many open files in system",
24: "too many open files",
25: "inappropriate ioctl for device",
26: "text file busy",
27: "file too large",
28: "no space left on device",
29: "illegal seek",
30: "read-only file system",
31: "too many links",
32: "broken pipe",
33: "numerical argument out of domain",
34: "numerical result out of range",
35: "resource deadlock avoided",
36: "file name too long",
37: "no locks available",
38: "function not implemented",
39: "directory not empty",
40: "too many levels of symbolic links",
42: "no message of desired type",
43: "identifier removed",
44: "channel number out of range",
45: "level 2 not synchronized",
46: "level 3 halted",
47: "level 3 reset",
48: "link number out of range",
49: "protocol driver not attached",
50: "no CSI structure available",
51: "level 2 halted",
52: "invalid exchange",
53: "invalid request descriptor",
54: "exchange full",
55: "no anode",
56: "invalid request code",
57: "invalid slot",
59: "bad font file format",
60: "device not a stream",
61: "no data available",
62: "timer expired",
63: "out of streams resources",
64: "machine is not on the network",
65: "package not installed",
66: "object is remote",
67: "link has been severed",
68: "advertise error",
69: "srmount error",
70: "communication error on send",
71: "protocol error",
72: "multihop attempted",
73: "RFS specific error",
74: "bad message",
75: "value too large for defined data type",
76: "name not unique on network",
77: "file descriptor in bad state",
78: "remote address changed",
79: "can not access a needed shared library",
80: "accessing a corrupted shared library",
81: ".lib section in a.out corrupted",
82: "attempting to link in too many shared libraries",
83: "cannot exec a shared library directly",
84: "invalid or incomplete multibyte or wide character",
85: "interrupted system call should be restarted",
86: "streams pipe error",
87: "too many users",
88: "socket operation on non-socket",
89: "destination address required",
90: "message too long",
91: "protocol wrong type for socket",
92: "protocol not available",
93: "protocol not supported",
94: "socket type not supported",
95: "operation not supported",
96: "protocol family not supported",
97: "address family not supported by protocol",
98: "address already in use",
99: "cannot assign requested address",
100: "network is down",
101: "network is unreachable",
102: "network dropped connection on reset",
103: "software caused connection abort",
104: "connection reset by peer",
105: "no buffer space available",
106: "transport endpoint is already connected",
107: "transport endpoint is not connected",
108: "cannot send after transport endpoint shutdown",
109: "too many references: cannot splice",
110: "connection timed out",
111: "connection refused",
112: "host is down",
113: "no route to host",
114: "operation already in progress",
115: "operation now in progress",
116: "stale file handle",
117: "structure needs cleaning",
118: "not a XENIX named type file",
119: "no XENIX semaphores available",
120: "is a named type file",
121: "remote I/O error",
122: "disk quota exceeded",
123: "no medium found",
124: "wrong medium type",
125: "operation canceled",
126: "required key not available",
127: "key has expired",
128: "key has been revoked",
129: "key was rejected by service",
130: "owner died",
131: "state not recoverable",
132: "operation not possible due to RF-kill",
133: "memory page has hardware error",
}
// Signal table
var signals = [...]string{
1: "hangup",
2: "interrupt",
3: "quit",
4: "illegal instruction",
5: "trace/breakpoint trap",
6: "aborted",
7: "bus error",
8: "floating point exception",
9: "killed",
10: "user defined signal 1",
11: "segmentation fault",
12: "user defined signal 2",
13: "broken pipe",
14: "alarm clock",
15: "terminated",
16: "stack fault",
17: "child exited",
18: "continued",
19: "stopped (signal)",
20: "stopped",
21: "stopped (tty input)",
22: "stopped (tty output)",
23: "urgent I/O condition",
24: "CPU time limit exceeded",
25: "file size limit exceeded",
26: "virtual timer expired",
27: "profiling timer expired",
28: "window changed",
29: "I/O possible",
30: "power failure",
31: "bad system call",
}
| {
"pile_set_name": "Github"
} |
# frozen_string_literal: true
RSpec.describe TTY::Prompt::Question, "#keypress" do
subject(:prompt) { TTY::Prompt::Test.new }
it "receives line feed with echo on" do
prompt.input << "\n"
prompt.input.rewind
answer = prompt.keypress("Press key:", echo: true)
expect(answer).to eq("\n")
expect(prompt.output.string).to eq([
"Press key: ",
"\e[2K\e[1G\e[1A\e[2K\e[1G",
"Press key: \n\n",
].join)
end
it "asks for a keypress with echo on" do
prompt.input << "abcd"
prompt.input.rewind
answer = prompt.keypress("Press key:", echo: true)
expect(answer).to eq("a")
expect(prompt.output.string).to eq([
"Press key: ",
"\e[2K\e[1G",
"Press key: \e[32ma\e[0m\n",
].join)
end
it "asks for a keypress with echo off" do
prompt.input << "abcd"
prompt.input.rewind
answer = prompt.keypress("Press key:")
expect(answer).to eq("a")
expect(prompt.output.string).to eq([
"Press key: ",
"\e[2K\e[1G",
"Press key: \n",
].join)
end
it "interrupts input" do
prompt = TTY::Prompt::Test.new(interrupt: :exit)
prompt.input << "\x03"
prompt.input.rewind
expect {
prompt.keypress("Press key:")
}.to raise_error(SystemExit)
end
it "timeouts when no key provided" do
prompt = TTY::Prompt::Test.new(interrupt: :exit)
prompt.keypress("Press any key or continue in :countdown", timeout: 0.01)
expect(prompt.output.string).to include("Press any key or continue in 0.00")
end
end
| {
"pile_set_name": "Github"
} |
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
// unit/quantity manipulation and conversion
//
// Copyright (C) 2003-2008 Matthias Christian Schabel
// Copyright (C) 2008 Steven Watanabe
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_UNITS_LUMINANCE_DERIVED_DIMENSION_HPP
#define BOOST_UNITS_LUMINANCE_DERIVED_DIMENSION_HPP
#include <boost/units/derived_dimension.hpp>
#include <boost/units/physical_dimensions/length.hpp>
#include <boost/units/physical_dimensions/luminous_intensity.hpp>
namespace boost {
namespace units {
/// derived dimension for luminance : L^-2 I
typedef derived_dimension<length_base_dimension,-2,
luminous_intensity_base_dimension,1>::type luminance_dimension;
} // namespace units
} // namespace boost
#endif // BOOST_UNITS_LUMINANCE_DERIVED_DIMENSION_HPP
| {
"pile_set_name": "Github"
} |
package pflag
import (
"fmt"
"net"
"strings"
)
// -- net.IP value
type ipValue net.IP
func newIPValue(val net.IP, p *net.IP) *ipValue {
*p = val
return (*ipValue)(p)
}
func (i *ipValue) String() string { return net.IP(*i).String() }
func (i *ipValue) Set(s string) error {
ip := net.ParseIP(strings.TrimSpace(s))
if ip == nil {
return fmt.Errorf("failed to parse IP: %q", s)
}
*i = ipValue(ip)
return nil
}
func (i *ipValue) Type() string {
return "ip"
}
func ipConv(sval string) (interface{}, error) {
ip := net.ParseIP(sval)
if ip != nil {
return ip, nil
}
return nil, fmt.Errorf("invalid string being converted to IP address: %s", sval)
}
// GetIP return the net.IP value of a flag with the given name
func (f *FlagSet) GetIP(name string) (net.IP, error) {
val, err := f.getFlagType(name, "ip", ipConv)
if err != nil {
return nil, err
}
return val.(net.IP), nil
}
// IPVar defines an net.IP flag with specified name, default value, and usage string.
// The argument p points to an net.IP variable in which to store the value of the flag.
func (f *FlagSet) IPVar(p *net.IP, name string, value net.IP, usage string) {
f.VarP(newIPValue(value, p), name, "", usage)
}
// IPVarP is like IPVar, but accepts a shorthand letter that can be used after a single dash.
func (f *FlagSet) IPVarP(p *net.IP, name, shorthand string, value net.IP, usage string) {
f.VarP(newIPValue(value, p), name, shorthand, usage)
}
// IPVar defines an net.IP flag with specified name, default value, and usage string.
// The argument p points to an net.IP variable in which to store the value of the flag.
func IPVar(p *net.IP, name string, value net.IP, usage string) {
CommandLine.VarP(newIPValue(value, p), name, "", usage)
}
// IPVarP is like IPVar, but accepts a shorthand letter that can be used after a single dash.
func IPVarP(p *net.IP, name, shorthand string, value net.IP, usage string) {
CommandLine.VarP(newIPValue(value, p), name, shorthand, usage)
}
// IP defines an net.IP flag with specified name, default value, and usage string.
// The return value is the address of an net.IP variable that stores the value of the flag.
func (f *FlagSet) IP(name string, value net.IP, usage string) *net.IP {
p := new(net.IP)
f.IPVarP(p, name, "", value, usage)
return p
}
// IPP is like IP, but accepts a shorthand letter that can be used after a single dash.
func (f *FlagSet) IPP(name, shorthand string, value net.IP, usage string) *net.IP {
p := new(net.IP)
f.IPVarP(p, name, shorthand, value, usage)
return p
}
// IP defines an net.IP flag with specified name, default value, and usage string.
// The return value is the address of an net.IP variable that stores the value of the flag.
func IP(name string, value net.IP, usage string) *net.IP {
return CommandLine.IPP(name, "", value, usage)
}
// IPP is like IP, but accepts a shorthand letter that can be used after a single dash.
func IPP(name, shorthand string, value net.IP, usage string) *net.IP {
return CommandLine.IPP(name, shorthand, value, usage)
}
| {
"pile_set_name": "Github"
} |
gcr.io/google_containers/kube-proxy-arm:v1.15.8
| {
"pile_set_name": "Github"
} |
# CS_ARCH_ARM, CS_MODE_THUMB, None
0xfb,0xff,0x20,0x04 = vrecpe.u32 d16, d16
0xfb,0xff,0x60,0x04 = vrecpe.u32 q8, q8
0xfb,0xff,0x20,0x05 = vrecpe.f32 d16, d16
0xfb,0xff,0x60,0x05 = vrecpe.f32 q8, q8
0x40,0xef,0xb1,0x0f = vrecps.f32 d16, d16, d17
0x40,0xef,0xf2,0x0f = vrecps.f32 q8, q8, q9
0xfb,0xff,0xa0,0x04 = vrsqrte.u32 d16, d16
0xfb,0xff,0xe0,0x04 = vrsqrte.u32 q8, q8
0xfb,0xff,0xa0,0x05 = vrsqrte.f32 d16, d16
0xfb,0xff,0xe0,0x05 = vrsqrte.f32 q8, q8
0x60,0xef,0xb1,0x0f = vrsqrts.f32 d16, d16, d17
0x60,0xef,0xf2,0x0f = vrsqrts.f32 q8, q8, q9
| {
"pile_set_name": "Github"
} |
//
// Copyright 2019 The ANGLE 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.
//
// EGLCreateContectAttribsTest.cpp:
// This suite of test cases test invalid attributes passed to eglCreateContext
// Section 3.7.1 of EGL 1.5 specification provides error cases
//
#include <gtest/gtest.h>
#include <vector>
#include "test_utils/ANGLETest.h"
using namespace angle;
class EGLCreateContextAttribsTest : public ANGLETest
{
public:
EGLCreateContextAttribsTest() : mDisplay(EGL_NO_DISPLAY) {}
void testSetUp() override
{
EGLint dispattrs[] = {EGL_PLATFORM_ANGLE_TYPE_ANGLE, GetParam().getRenderer(), EGL_NONE};
mDisplay = eglGetPlatformDisplayEXT(
EGL_PLATFORM_ANGLE_ANGLE, reinterpret_cast<void *>(EGL_DEFAULT_DISPLAY), dispattrs);
EXPECT_TRUE(mDisplay != EGL_NO_DISPLAY);
EXPECT_EGL_TRUE(eglInitialize(mDisplay, nullptr, nullptr) != EGL_FALSE);
}
EGLDisplay mDisplay;
};
// Specify invalid client version in the attributes to eglCreateContext
// and verify EGL_BAD_ATTRIBUTE
TEST_P(EGLCreateContextAttribsTest, InvalidClientVersion)
{
EGLContext context = EGL_NO_CONTEXT;
// Pick config
EGLConfig config = EGL_NO_CONFIG_KHR;
EGLint count = 0;
// Get a 1.0 compatible config
EGLint cfgAttribList1[] = {EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT, EGL_NONE};
EXPECT_EGL_TRUE(eglChooseConfig(mDisplay, cfgAttribList1, &config, 1, &count));
ANGLE_SKIP_TEST_IF(count == 0);
// GLES 0.0 is invalid verify invalid attribute request
EGLint contextAttribs1[] = {EGL_CONTEXT_MAJOR_VERSION, 0, EGL_CONTEXT_MINOR_VERSION, 0,
EGL_NONE};
context = eglCreateContext(mDisplay, config, nullptr, contextAttribs1);
EXPECT_EQ(context, EGL_NO_CONTEXT);
ASSERT_EGL_ERROR(EGL_BAD_ATTRIBUTE);
// Get a 2.0/3.x compatible config
EGLint cfgAttribList2[] = {EGL_RENDERABLE_TYPE, (EGL_OPENGL_ES2_BIT), EGL_NONE};
EXPECT_EGL_TRUE(eglChooseConfig(mDisplay, cfgAttribList2, &config, 1, &count));
ASSERT_TRUE(count > 0);
// GLES 2.1 is invalid verify invalid attribute request
EGLint contextAttribs2[] = {EGL_CONTEXT_MAJOR_VERSION, 2, EGL_CONTEXT_MINOR_VERSION, 1,
EGL_NONE};
context = eglCreateContext(mDisplay, config, nullptr, contextAttribs2);
EXPECT_EQ(context, EGL_NO_CONTEXT);
ASSERT_EGL_ERROR(EGL_BAD_ATTRIBUTE);
// GLES 3.3 is invalid verify invalid attribute request
EGLint contextAttribs3[] = {EGL_CONTEXT_MAJOR_VERSION, 3, EGL_CONTEXT_MINOR_VERSION, 3,
EGL_NONE};
context = eglCreateContext(mDisplay, config, nullptr, contextAttribs3);
EXPECT_EQ(context, EGL_NO_CONTEXT);
ASSERT_EGL_ERROR(EGL_BAD_ATTRIBUTE);
// GLES 4.0 is invalid verify invalid attribute request
EGLint contextAttribs4[] = {EGL_CONTEXT_MAJOR_VERSION, 4, EGL_CONTEXT_MINOR_VERSION, 0,
EGL_NONE};
context = eglCreateContext(mDisplay, config, nullptr, contextAttribs4);
EXPECT_EQ(context, EGL_NO_CONTEXT);
ASSERT_EGL_ERROR(EGL_BAD_ATTRIBUTE);
// Cleanup contexts
eglTerminate(mDisplay);
}
// Choose config that doesn't support requested client version, and verify that eglCreateContext
// sets EGL_BAD_MATCH
TEST_P(EGLCreateContextAttribsTest, IncompatibleConfig)
{
// Get all the configs
EGLint count;
EXPECT_EGL_TRUE(eglGetConfigs(mDisplay, nullptr, 0, &count) != EGL_FALSE);
EXPECT_TRUE(count > 0);
std::vector<EGLConfig> configs(count);
EXPECT_EGL_TRUE(eglGetConfigs(mDisplay, configs.data(), count, &count) != EGL_FALSE);
EGLConfig notGLES1Config = EGL_NO_CONFIG_KHR;
EGLConfig notGLES2Config = EGL_NO_CONFIG_KHR;
EGLConfig notGLES3Config = EGL_NO_CONFIG_KHR;
// Find non API matching configs
for (auto config : configs)
{
EGLint value = 0;
EXPECT_EGL_TRUE(eglGetConfigAttrib(mDisplay, config, EGL_RENDERABLE_TYPE, &value));
if (((value & EGL_OPENGL_ES_BIT) == 0) && (notGLES1Config == EGL_NO_CONFIG_KHR))
{
notGLES1Config = config;
continue;
}
if (((value & EGL_OPENGL_ES2_BIT) == 0) && (notGLES2Config == EGL_NO_CONFIG_KHR))
{
notGLES2Config = config;
continue;
}
if (((value & EGL_OPENGL_ES3_BIT) == 0) && (notGLES3Config == EGL_NO_CONFIG_KHR))
{
notGLES3Config = config;
continue;
}
}
// These selected configs should not be a match with the requested client version.
EGLContext context = EGL_NO_CONTEXT;
// Check GLES1
if (notGLES1Config != EGL_NO_CONFIG_KHR)
{
EGLint contextAttribs1[] = {EGL_CONTEXT_MAJOR_VERSION, 1, EGL_CONTEXT_MINOR_VERSION, 0,
EGL_NONE};
context = eglCreateContext(mDisplay, notGLES1Config, nullptr, contextAttribs1);
EXPECT_EQ(context, EGL_NO_CONTEXT);
ASSERT_EGL_ERROR(EGL_BAD_MATCH);
}
// Check GLES2
if (notGLES2Config != EGL_NO_CONFIG_KHR)
{
EGLint contextAttribs2[] = {EGL_CONTEXT_MAJOR_VERSION, 2, EGL_CONTEXT_MINOR_VERSION, 0,
EGL_NONE};
context = eglCreateContext(mDisplay, notGLES2Config, nullptr, contextAttribs2);
EXPECT_EQ(context, EGL_NO_CONTEXT);
ASSERT_EGL_ERROR(EGL_BAD_MATCH);
}
// Check GLES3
if (notGLES3Config != EGL_NO_CONFIG_KHR)
{
EGLint contextAttribs3[] = {EGL_CONTEXT_MAJOR_VERSION, 3, EGL_CONTEXT_MINOR_VERSION, 0,
EGL_NONE};
context = eglCreateContext(mDisplay, notGLES3Config, nullptr, contextAttribs3);
EXPECT_EQ(context, EGL_NO_CONTEXT);
ASSERT_EGL_ERROR(EGL_BAD_MATCH);
}
// Cleanup contexts
eglTerminate(mDisplay);
}
ANGLE_INSTANTIATE_TEST(EGLCreateContextAttribsTest,
WithNoFixture(ES2_D3D9()),
WithNoFixture(ES2_D3D11()),
WithNoFixture(ES2_OPENGL()),
WithNoFixture(ES2_VULKAN()),
WithNoFixture(ES3_D3D11()),
WithNoFixture(ES3_OPENGL()),
WithNoFixture(ES3_VULKAN()));
| {
"pile_set_name": "Github"
} |
Creates a tf.Session for a worker.
- - -
#### `tf.train.WorkerSessionCreator.__init__(scaffold=None, master='', config=None)` {#WorkerSessionCreator.__init__}
Initializes a worker session creator.
##### Args:
* <b>`scaffold`</b>: A `Scaffold` used for gathering or building supportive ops. If
not specified a default one is created. It's used to finalize the graph.
* <b>`master`</b>: `String` representation of the TensorFlow master to use.
* <b>`config`</b>: `ConfigProto` proto used to configure the session.
- - -
#### `tf.train.WorkerSessionCreator.create_session()` {#WorkerSessionCreator.create_session}
| {
"pile_set_name": "Github"
} |
/* asyn_synch() - step back to synch Author: Kees J. Bot
* 7 Jul 1997
*/
#include "asyn.h"
int asyn_synch(asynchio_t *asyn, int fd)
/* No more asynchronous operations on this file descriptor. */
{
asynfd_t *afd;
int op;
if ((unsigned) fd >= FD_SETSIZE) { errno= EBADF; return -1; }
afd= &asyn->asyn_afd[fd];
for (op= 0; op < SEL_NR; op++) {
if (afd->afd_state[op] != IDLE) {
errno= EAGAIN;
return -1;
}
}
/* Make sure the file flags are as they once were. */
if (afd->afd_seen && fcntl(fd, F_SETFL, afd->afd_flags) < 0) return -1;
afd->afd_seen= 0;
return 0;
}
| {
"pile_set_name": "Github"
} |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<meta name="viewport" content="user-scalable=no,initial-scale=1">
<style type="text/css">
@media only screen and (max-width:600px) {
.logo {
display: block;
float: none;
text-align: center;
width: 100%;
margin: 0px 8px 16px 0px;
}
.unsubscribe {
max-width: 100%;
width: 100%;
text-align: left;
margin-left: 8px;
}
}
</style>
</head>
<body class="content" style="font-size:14px;background:white;font-family:sans-serif;padding:0px;margin:0px;">
<div class="h1" style="font-weight:bold;text-align:center;margin-top:12px;padding:8px;font-size:18px;">
{{ if eq .Kind "reply" }}
Unread Reply: {{ .Title }}
{{ end }}
{{ if eq .Kind "pending-moderation" }}
Pending Moderation: {{ .Title }}
{{ end }}
</div>
<div class="comments-container" style="display:flex;justify-content:center;">
<div class="comments" style="max-width:600px;width:calc(100% - 20px);margin-top:16px;border-top:1px solid #eee;">
<div class="comment" style="border-radius:2px;width:calc(100% - 32px);padding:16px;margin:8px 0px 8px 0px;border-bottom:1px solid #eee;">
<div class="options" style="float:right;">
{{ if eq .Kind "pending-moderation" }}
<a href="{{ .Origin }}/api/email/moderate?commentHex={{ .CommentHex }}&action=approve&unsubscribeSecretHex={{ .UnsubscribeSecretHex }}" target="_black" class="option green" style="padding-right:5px;text-transform:uppercase;font-size:12px;font-weight:bold;text-decoration:none;color:#2f9e44;">Approve</a>
{{ end }}
{{ if ne .Kind "reply" }}
<a href="{{ .Origin }}/api/email/moderate?commentHex={{ .CommentHex }}&action=delete&unsubscribeSecretHex={{ .UnsubscribeSecretHex }}" target="_black" class="option red" style="padding-right:5px;text-transform:uppercase;font-size:12px;font-weight:bold;text-decoration:none;color:#f03e3e;">Delete</a>
{{ end }}
<a href="http://{{ .Domain }}{{ .Path }}#commento-{{ .CommentHex }}" class="option gray" style="padding-right:5px;text-transform:uppercase;font-size:12px;font-weight:bold;text-decoration:none;color:#495057;">Context</a>
</div>
<div class="header" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;padding-right:10px;">
<div class="name" style="display:inline;font-size:14px;font-weight:bold;color:#1e2127;">{{ .CommenterName }}</div>
on
<a href="http://{{ .Domain }}{{ .Path }}" class="page" style="margin-bottom:10px;text-decoration:none;color:#228be6;">"{{ .Title }}"</a>
</div>
<div class="text" style="line-height:20px;padding:10px;">
{{ .Html }}
</div>
</div>
<div class="footer" style="width:100%;margin-top:16px;">
<a href="https://commento.io" class="logo" style="float:right;font-weight:bold;color:#868e96;font-size:13px;text-decoration:none;">Powered by Commento</a>
<div class="unsubscribe" style="color:#868e96;font-size:13px;text-align:left;max-width:300px;margin-bottom:16px;">
{{ if eq .Kind "reply" }}
You've received this email because you opted in to receive email notifications for comment replies. To unsubscribe, <a href="{{ .Origin }}/unsubscribe?unsubscribeSecretHex={{ .UnsubscribeSecretHex }}" style="color:#868e96;font-weight:bold;text-decoration:none;">click here</a>.
{{ end }}
{{ if eq .Kind "pending-moderation" }}
You've received this email because the domain owner chose to notify moderators of comments pending moderation by email. To unsubscribe, <a href="{{ .Origin }}/unsubscribe?unsubscribeSecretHex={{ .UnsubscribeSecretHex }}" style="color:#868e96;font-weight:bold;text-decoration:none;">click here</a>.
{{ end }}
{{ if eq .Kind "all" }}
You've received this email because the domain owner chose to notify moderators for all new comments by email. To unsubscribe, <a href="{{ .Origin }}/unsubscribe?unsubscribeSecretHex={{ .UnsubscribeSecretHex }}" style="color:#868e96;font-weight:bold;text-decoration:none;">click here</a>.
{{ end }}
</div>
</div>
</div>
</div>
</body>
</html>
| {
"pile_set_name": "Github"
} |
#Tirol Region (556000) #see Italy.txt for balance of Region
#under the rule of Austria in 1836
#Innsbruck (236000/59000 POPS)
612 = {
aristocrats = {
culture = south_german
religion = catholic
size = 750
}
bureaucrats = {
culture = south_german
religion = catholic
size = 675
}
officers = {
culture = south_german
religion = catholic
size = 250
}
clergymen = {
culture = south_german
religion = catholic
size = 550
}
artisans = {
culture = south_german
religion = catholic
size = 2750
}
soldiers = {
culture = south_german
religion = catholic
size = 1100
}
farmers = {
culture = south_german
religion = catholic
size = 53325
}
}
#Salzburg (136000/34000 POPS)
613 = {
aristocrats = {
culture = south_german
religion = catholic
size = 450
}
clergymen = {
culture = south_german
religion = catholic
size = 650
}
artisans = {
culture = south_german
religion = catholic
size = 3250
}
soldiers = {
culture = south_german
religion = catholic
size = 1100
}
farmers = {
culture = south_german
religion = catholic
size = 28975
}
}
#Bregenz (132000/33000 POPS)
614 = {
aristocrats = {
culture = south_german
religion = catholic
size = 400
}
clergymen = {
culture = south_german
religion = catholic
size = 300
}
artisans = {
culture = south_german
religion = catholic
size = 1500
}
soldiers = {
culture = south_german
religion = catholic
size = 1100
}
farmers = {
culture = south_german
religion = catholic
size = 29700
}
}
#Lienz (52000/13000 POPS)
615 = {
aristocrats = {
culture = south_german
religion = catholic
size = 175
}
clergymen = {
culture = south_german
religion = catholic
size = 125
}
artisans = {
culture = south_german
religion = catholic
size = 600
}
soldiers = {
culture = south_german
religion = catholic
size = 125
}
farmers = {
culture = south_german
religion = catholic
size = 11975
}
}
#Carinthia-Styria Region (736000) #see Slovenia.txt for balance of Region
#under the rule of Austria in 1836
#Graz (380000/95000 POPS)
616 = {
aristocrats = {
culture = south_german
religion = catholic
size = 1550
}
bureaucrats = {
culture = south_german
religion = catholic
size = 525
}
officers = {
culture = south_german
religion = catholic
size = 275
}
clergymen = {
culture = south_german
religion = catholic
size = 1025
}
artisans = {
culture = south_german
religion = catholic
size = 10000
}
soldiers = {
culture = south_german
religion = catholic
size = 1050
}
farmers = {
culture = south_german
religion = catholic
size = 80675
}
}
#Judenburg (168000/42000 POPS)
617 = {
aristocrats = {
culture = south_german
religion = catholic
size = 700
}
clergymen = {
culture = south_german
religion = catholic
size = 450
}
artisans = {
culture = south_german
religion = catholic
size = 2250
}
soldiers = {
culture = south_german
religion = catholic
size = 450
}
farmers = {
culture = south_german
religion = catholic
size = 38150
}
}
#Klagenfurt (188000/47000 POPS)
618 = {
aristocrats = {
culture = south_german
religion = catholic
size = 450
}
clergymen = {
culture = south_german
religion = catholic
size = 325
}
artisans = {
culture = south_german
religion = catholic
size = 1550
}
soldiers = {
culture = south_german
religion = catholic
size = 1100
}
farmers = {
culture = south_german
religion = catholic
size = 25675
}
clergymen = {
culture = slovene
religion = catholic
size = 175
}
artisans = {
culture = slovene
religion = catholic
size = 950
}
soldiers = {
culture = slovene
religion = catholic
size = 200
}
farmers = {
culture = slovene
religion = catholic
size = 16675
}
}
#Austria Region (2000000)
#under the rule of Austria in 1836
#Vienna (1084000/271000 POPS)
619 = {
aristocrats = {
culture = south_german
religion = catholic
size = 4250
}
bureaucrats = {
culture = south_german
religion = catholic
size = 1400
}
officers = {
culture = south_german
religion = catholic
size = 600
}
clergymen = {
culture = south_german
religion = catholic
size = 2750
}
artisans = {
culture = south_german
religion = catholic
size = 10000
}
artisans = {
culture = south_german
religion = catholic
size = 10000
}
artisans = {
culture = south_german
religion = catholic
size = 10000
}
artisans = {
culture = south_german
religion = catholic
size = 10000
}
artisans = {
culture = south_german
religion = catholic
size = 10000
}
artisans = {
culture = south_german
religion = catholic
size = 7500
}
soldiers = {
culture = south_german
religion = catholic
size = 2750
}
farmers = {
culture = south_german
religion = catholic
size = 194550
}
clergymen = {
culture = czech
religion = catholic
size = 50
}
artisans = {
culture = czech
religion = catholic
size = 5950
}
clergymen = {
culture = hungarian
religion = catholic
size = 20
}
artisans = {
culture = hungarian
religion = catholic
size = 980
}
clergymen = {
culture = south_german
religion = jewish
size = 5
}
artisans = {
culture = south_german
religion = jewish
size = 495
}
}
#Sankt Polten (88000/22000 POPS)
620 = {
aristocrats = {
culture = south_german
religion = catholic
size = 375
}
bureaucrats = {
culture = south_german
religion = catholic
size = 600
}
clergymen = {
culture = south_german
religion = catholic
size = 250
}
artisans = {
culture = south_german
religion = catholic
size = 1200
}
soldiers = {
culture = south_german
religion = catholic
size = 250
}
farmers = {
culture = south_german
religion = catholic
size = 19925
}
}
#Krems (240000/60000 POPS)
621 = {
aristocrats = {
culture = south_german
religion = catholic
size = 925
}
clergymen = {
culture = south_german
religion = catholic
size = 625
}
artisans = {
culture = south_german
religion = catholic
size = 3100
}
soldiers = {
culture = south_german
religion = catholic
size = 650
}
farmers = {
culture = south_german
religion = catholic
size = 54700
}
}
#Linz (588000/147000 POPS)
622 = {
aristocrats = {
culture = south_german
religion = catholic
size = 2300
}
clergymen = {
culture = south_german
religion = catholic
size = 3200
}
artisans = {
culture = south_german
religion = catholic
size = 7650
}
soldiers = {
culture = south_german
religion = catholic
size = 1550
}
farmers = {
culture = south_german
religion = catholic
size = 133900
}
}
#Odenburg Region (196000) #see Hungary.txt for balance of region
#under the rule of Austria in 1836
#Eisenstadt (196000/49000 POPS)
624 = {
aristocrats = {
culture = south_german
religion = catholic
size = 700
}
clergymen = {
culture = south_german
religion = catholic
size = 475
}
artisans = {
culture = south_german
religion = catholic
size = 2450
}
soldiers = {
culture = south_german
religion = catholic
size = 1100
}
farmers = {
culture = south_german
religion = catholic
size = 41375
}
clergymen = {
culture = hungarian
religion = catholic
size = 60
}
artisans = {
culture = hungarian
religion = catholic
size = 150
}
soldiers = {
culture = hungarian
religion = catholic
size = 25
}
farmers = {
culture = hungarian
religion = catholic
size = 2765
}
clergymen = {
culture = hungarian
religion = protestant
size = 35
}
artisans = {
culture = hungarian
religion = protestant
size = 150
}
soldiers = {
culture = hungarian
religion = protestant
size = 25
}
farmers = {
culture = hungarian
religion = protestant
size = 1790
}
}
| {
"pile_set_name": "Github"
} |
# reserve-candidates
Finds places that could use a `reserve()` call.
Whenever you know how many elements a container will hold you should reserve
space in order to avoid repeated memory allocations.
#### Trivial example missing reserve()
QList<int> ages;
// list.reserve(people.size());
for (auto person : people)
list << person.age();
Example where reserve shouldn't be used:
QLost<int> list;
for (int i = 0; i < 1000; ++i) {
// reserve() will be called 1000 times, meaning 1000 allocations
// whilst without a reserve the internal exponential growth algorithm would do a better job
list.reserve(list.size() + 2);
for (int j = 0; j < 2; ++j) {
list << m;
}
}
#### Supported containers
`QVector`, `std::vector`, `QList`, `QSet` and `QVarLengthArray`
#### Pitfalls
Rate of false-positives is around 15%. Don't go blindly calling `reserve()` without proper analysis.
In doubt don't use it, all containers have a growth curve and usually only do log(N) allocations
when you append N items.
| {
"pile_set_name": "Github"
} |
/*
* Based on linux/arch/arm/mach-mpp/include/mfp-pxa168.h
* (C) Copyright 2007
* Marvell Semiconductor <www.marvell.com>
* 2007-08-21: eric miao <[email protected]>
*
* (C) Copyright 2010
* Marvell Semiconductor <www.marvell.com>
* Written-by: Prafulla Wadaskar <[email protected]>
* Contributor: Mahavir Jain <[email protected]>
*
* SPDX-License-Identifier: GPL-2.0+
*/
#ifndef __ARMADA100_MFP_H
#define __ARMADA100_MFP_H
/*
* Frequently used MFP Configuration macros for all ARMADA100 family of SoCs
*
* offset, pull,pF, drv,dF, edge,eF ,afn,aF
*/
/* UART1 */
#define MFP107_UART1_TXD (MFP_REG(0x01ac) | MFP_AF1 | MFP_DRIVE_FAST)
#define MFP107_UART1_RXD (MFP_REG(0x01ac) | MFP_AF2 | MFP_DRIVE_FAST)
#define MFP108_UART1_RXD (MFP_REG(0x01b0) | MFP_AF1 | MFP_DRIVE_FAST)
#define MFP108_UART1_TXD (MFP_REG(0x01b0) | MFP_AF2 | MFP_DRIVE_FAST)
#define MFP109_UART1_CTS (MFP_REG(0x01b4) | MFP_AF1 | MFP_DRIVE_MEDIUM)
#define MFP109_UART1_RTS (MFP_REG(0x01b4) | MFP_AF2 | MFP_DRIVE_MEDIUM)
#define MFP110_UART1_RTS (MFP_REG(0x01b8) | MFP_AF1 | MFP_DRIVE_MEDIUM)
#define MFP110_UART1_CTS (MFP_REG(0x01b8) | MFP_AF2 | MFP_DRIVE_MEDIUM)
#define MFP111_UART1_RI (MFP_REG(0x01bc) | MFP_AF1 | MFP_DRIVE_MEDIUM)
#define MFP111_UART1_DSR (MFP_REG(0x01bc) | MFP_AF2 | MFP_DRIVE_MEDIUM)
#define MFP112_UART1_DTR (MFP_REG(0x01c0) | MFP_AF1 | MFP_DRIVE_MEDIUM)
#define MFP112_UART1_DCD (MFP_REG(0x01c0) | MFP_AF2 | MFP_DRIVE_MEDIUM)
/* UART2 */
#define MFP47_UART2_RXD (MFP_REG(0x0028) | MFP_AF6 | MFP_DRIVE_MEDIUM)
#define MFP48_UART2_TXD (MFP_REG(0x002c) | MFP_AF6 | MFP_DRIVE_MEDIUM)
#define MFP88_UART2_RXD (MFP_REG(0x0160) | MFP_AF2 | MFP_DRIVE_MEDIUM)
#define MFP89_UART2_TXD (MFP_REG(0x0164) | MFP_AF2 | MFP_DRIVE_MEDIUM)
/* UART3 */
#define MFPO8_UART3_TXD (MFP_REG(0x06c) | MFP_AF2 | MFP_DRIVE_MEDIUM)
#define MFPO9_UART3_RXD (MFP_REG(0x070) | MFP_AF2 | MFP_DRIVE_MEDIUM)
/* I2c */
#define MFP105_CI2C_SDA (MFP_REG(0x1a4) | MFP_AF1 | MFP_DRIVE_MEDIUM)
#define MFP106_CI2C_SCL (MFP_REG(0x1a8) | MFP_AF1 | MFP_DRIVE_MEDIUM)
/* Fast Ethernet */
#define MFP086_ETH_TXCLK (MFP_REG(0x158) | MFP_AF5 | MFP_DRIVE_MEDIUM)
#define MFP087_ETH_TXEN (MFP_REG(0x15C) | MFP_AF5 | MFP_DRIVE_MEDIUM)
#define MFP088_ETH_TXDQ3 (MFP_REG(0x160) | MFP_AF5 | MFP_DRIVE_MEDIUM)
#define MFP089_ETH_TXDQ2 (MFP_REG(0x164) | MFP_AF5 | MFP_DRIVE_MEDIUM)
#define MFP090_ETH_TXDQ1 (MFP_REG(0x168) | MFP_AF5 | MFP_DRIVE_MEDIUM)
#define MFP091_ETH_TXDQ0 (MFP_REG(0x16C) | MFP_AF5 | MFP_DRIVE_MEDIUM)
#define MFP092_ETH_CRS (MFP_REG(0x170) | MFP_AF5 | MFP_DRIVE_MEDIUM)
#define MFP093_ETH_COL (MFP_REG(0x174) | MFP_AF5 | MFP_DRIVE_MEDIUM)
#define MFP094_ETH_RXCLK (MFP_REG(0x178) | MFP_AF5 | MFP_DRIVE_MEDIUM)
#define MFP095_ETH_RXER (MFP_REG(0x17C) | MFP_AF5 | MFP_DRIVE_MEDIUM)
#define MFP096_ETH_RXDQ3 (MFP_REG(0x180) | MFP_AF5 | MFP_DRIVE_MEDIUM)
#define MFP097_ETH_RXDQ2 (MFP_REG(0x184) | MFP_AF5 | MFP_DRIVE_MEDIUM)
#define MFP098_ETH_RXDQ1 (MFP_REG(0x188) | MFP_AF5 | MFP_DRIVE_MEDIUM)
#define MFP099_ETH_RXDQ0 (MFP_REG(0x18C) | MFP_AF5 | MFP_DRIVE_MEDIUM)
#define MFP100_ETH_MDC (MFP_REG(0x190) | MFP_AF5 | MFP_DRIVE_MEDIUM)
#define MFP101_ETH_MDIO (MFP_REG(0x194) | MFP_AF5 | MFP_DRIVE_MEDIUM)
#define MFP103_ETH_RXDV (MFP_REG(0x19C) | MFP_AF5 | MFP_DRIVE_MEDIUM)
/* SPI */
#define MFP107_SSP2_RXD (MFP_REG(0x1AC) | MFP_AF4 | MFP_DRIVE_MEDIUM)
#define MFP108_SSP2_TXD (MFP_REG(0x1B0) | MFP_AF4 | MFP_DRIVE_MEDIUM)
#define MFP110_SSP2_CS (MFP_REG(0x1B8) | MFP_AF0 | MFP_DRIVE_MEDIUM)
#define MFP111_SSP2_CLK (MFP_REG(0x1BC) | MFP_AF4 | MFP_DRIVE_MEDIUM)
/* More macros can be defined here... */
#define MFP_PIN_MAX 117
#endif /* __ARMADA100_MFP_H */
| {
"pile_set_name": "Github"
} |
-module(rafter_consensus_fsm).
-behaviour(gen_fsm).
-include("rafter.hrl").
-include("rafter_consensus_fsm.hrl").
-include("rafter_opts.hrl").
-define(CLIENT_TIMEOUT, 2000).
-define(ELECTION_TIMEOUT_MIN, 500).
-define(ELECTION_TIMEOUT_MAX, 1000).
-define(HEARTBEAT_TIMEOUT, 25).
%% API
-export([start_link/3, stop/1, get_leader/1, read_op/2, op/2,
set_config/2, send/2, send_sync/2]).
%% gen_fsm callbacks
-export([init/1, code_change/4, handle_event/3, handle_info/3,
handle_sync_event/4, terminate/3, format_status/2]).
%% States
-export([follower/2, follower/3, candidate/2, candidate/3, leader/2, leader/3]).
%% Testing outputs
-export([set_term/2, candidate_log_up_to_date/4]).
stop(Pid) ->
gen_fsm:send_all_state_event(Pid, stop).
start_link(NameAtom, Me, Opts) ->
gen_fsm:start_link({local, NameAtom}, ?MODULE, [Me, Opts], []).
op(Peer, Command) ->
gen_fsm:sync_send_event(Peer, {op, Command}).
read_op(Peer, Command) ->
gen_fsm:sync_send_event(Peer, {read_op, Command}).
set_config(Peer, Config) ->
gen_fsm:sync_send_event(Peer, {set_config, Config}).
get_leader(Pid) ->
gen_fsm:sync_send_all_state_event(Pid, get_leader).
-spec send(atom(), #vote{} | #append_entries_rpy{}) -> ok.
send(To, Msg) ->
%% Catch badarg error thrown if name is unregistered
catch gen_fsm:send_event(To, Msg).
-spec send_sync(atom(), #request_vote{} | #append_entries{}) ->
#vote{} | #append_entries_rpy{} | timeout.
send_sync(To, Msg) ->
Timeout=100,
gen_fsm:sync_send_event(To, Msg, Timeout).
%%=============================================================================
%% gen_fsm callbacks
%%=============================================================================
init([Me, #rafter_opts{state_machine=StateMachine}]) ->
Timer = gen_fsm:send_event_after(election_timeout(), timeout),
#meta{voted_for=VotedFor, term=Term} = rafter_log:get_metadata(Me),
BackendState = StateMachine:init(Me),
State = #state{term=Term,
voted_for=VotedFor,
me=Me,
responses=dict:new(),
followers=dict:new(),
timer=Timer,
state_machine=StateMachine,
backend_state=BackendState},
Config = rafter_log:get_config(Me),
NewState =
case Config#config.state of
blank ->
State#state{config=Config};
_ ->
State#state{config=Config, init_config=complete}
end,
{ok, follower, NewState}.
format_status(_, [_, State]) ->
Data = lager:pr(State, ?MODULE),
[{data, [{"StateData", Data}]}].
handle_event(stop, _, State) ->
{stop, normal, State};
handle_event(_Event, _StateName, State) ->
{stop, {error, badmsg}, State}.
handle_sync_event(get_leader, _, StateName, State=#state{leader=Leader}) ->
{reply, Leader, StateName, State};
handle_sync_event(_Event, _From, _StateName, State) ->
{stop, badmsg, State}.
handle_info({client_read_timeout, Clock, Id}, StateName,
#state{read_reqs=Reqs}=State) ->
ClientRequests = orddict:fetch(Clock, Reqs),
{ok, ClientReq} = find_client_req(Id, ClientRequests),
send_client_timeout_reply(ClientReq),
NewClientRequests = delete_client_req(Id, ClientRequests),
NewReqs = orddict:store(Clock, NewClientRequests, Reqs),
NewState = State#state{read_reqs=NewReqs},
{next_state, StateName, NewState};
handle_info({client_timeout, Id}, StateName, #state{client_reqs=Reqs}=State) ->
case find_client_req(Id, Reqs) of
{ok, ClientReq} ->
send_client_timeout_reply(ClientReq),
NewState = State#state{client_reqs=delete_client_req(Id, Reqs)},
{next_state, StateName, NewState};
not_found ->
{next_state, StateName, State}
end;
handle_info(_, _, State) ->
{stop, badmsg, State}.
terminate(_, _, _) ->
ok.
code_change(_OldVsn, StateName, State, _Extra) ->
{ok, StateName, State}.
%%=============================================================================
%% States
%%
%% Note: All RPC's and client requests get answered in State/3 functions.
%% RPC Responses get handled in State/2 functions.
%%=============================================================================
%% Election timeout has expired. Go to candidate state iff we are a voter.
follower(timeout, #state{config=Config, me=Me}=State0) ->
case rafter_config:has_vote(Me, Config) of
false ->
State = reset_timer(election_timeout(), State0),
NewState = State#state{leader=undefined},
{next_state, follower, NewState};
true ->
State = become_candidate(State0),
{next_state, candidate, State}
end;
%% Ignore stale messages.
follower(#vote{}, State) ->
{next_state, follower, State};
follower(#append_entries_rpy{}, State) ->
{next_state, follower, State}.
%% Vote for this candidate
follower(#request_vote{}=RequestVote, _From, State) ->
handle_request_vote(RequestVote, State);
follower(#append_entries{term=Term}, _From,
#state{term=CurrentTerm, me=Me}=State) when CurrentTerm > Term ->
Rpy = #append_entries_rpy{from=Me, term=CurrentTerm, success=false},
{reply, Rpy, follower, State};
follower(#append_entries{term=Term, from=From, prev_log_index=PrevLogIndex,
entries=Entries, commit_index=CommitIndex,
send_clock=Clock}=AppendEntries,
_From, #state{me=Me}=State) ->
State2=set_term(Term, State),
Rpy = #append_entries_rpy{send_clock=Clock,
term=Term,
success=false,
from=Me},
%% Always reset the election timer here, since the leader is valid,
%% but may have conflicting data to sync
State3 = reset_timer(election_timeout(), State2),
case consistency_check(AppendEntries, State3) of
false ->
{reply, Rpy, follower, State3};
true ->
{ok, CurrentIndex} = rafter_log:check_and_append(Me,
Entries, PrevLogIndex+1),
Config = rafter_log:get_config(Me),
NewRpy = Rpy#append_entries_rpy{success=true, index=CurrentIndex},
State4 = commit_entries(CommitIndex, State3),
State5 = State4#state{leader=From, config=Config},
{reply, NewRpy, follower, State5}
end;
%% Allow setting config in follower state only if the config is blank
%% (e.g. the log is empty). A config entry must always be the first
%% entry in every log.
follower({set_config, {Id, NewServers}}, From,
#state{me=Me, followers=F, config=#config{state=blank}=C}=State) ->
case lists:member(Me, NewServers) of
true ->
{Followers, Config} = reconfig(Me, F, C, NewServers, State),
NewState = State#state{config=Config, followers=Followers,
init_config=[Id, From]},
%% Transition to candidate state. Once we are elected leader we will
%% send the config to the other machines. We have to do it this way
%% so that the entry we log will have a valid term and can be
%% committed without a noop. Note that all other configs must
%% be blank on the other machines.
{next_state, candidate, NewState};
false ->
Error = {error, not_consensus_group_member},
{reply, Error, follower, State}
end;
follower({set_config, _}, _From, #state{leader=undefined, me=Me, config=C}=State) ->
Error = no_leader_error(Me, C),
{reply, {error, Error}, follower, State};
follower({set_config, _}, _From, #state{leader=Leader}=State) ->
Reply = {error, {redirect, Leader}},
{reply, Reply, follower, State};
follower({read_op, _}, _From, #state{me=Me, config=Config,
leader=undefined}=State) ->
Error = no_leader_error(Me, Config),
{reply, {error, Error}, follower, State};
follower({read_op, _}, _From, #state{leader=Leader}=State) ->
Reply = {error, {redirect, Leader}},
{reply, Reply, follower, State};
follower({op, _Command}, _From, #state{me=Me, config=Config,
leader=undefined}=State) ->
Error = no_leader_error(Me, Config),
{reply, {error, Error}, follower, State};
follower({op, _Command}, _From, #state{leader=Leader}=State) ->
Reply = {error, {redirect, Leader}},
{reply, Reply, follower, State}.
%% This is the initial election to set the initial config. We did not
%% get a quorum for our votes, so just reply to the user here and keep trying
%% until the other nodes come up.
candidate(timeout, #state{term=1, init_config=[_Id, From]}=S) ->
State0 = reset_timer(election_timeout(), S),
gen_fsm:reply(From, {error, peers_not_responding}),
State = State0#state{init_config=no_client},
{next_state, candidate, State};
%% The election timeout has elapsed so start an election
candidate(timeout, State) ->
NewState = become_candidate(State),
{next_state, candidate, NewState};
%% This should only happen if two machines are configured differently during
%% initial configuration such that one configuration includes both proposed leaders
%% and the other only itself. Additionally, there is not a quorum of either
%% configuration's servers running.
%%
%% (i.e. rafter:set_config(b, [k, b, j]), rafter:set_config(d, [i,k,b,d,o]).
%% when only b and d are running.)
%%
%% Thank you EQC for finding this one :)
candidate(#vote{term=VoteTerm, success=false},
#state{term=Term, init_config=[_Id, From]}=State)
when VoteTerm > Term ->
gen_fsm:reply(From, {error, invalid_initial_config}),
State2 = State#state{init_config=undefined, config=#config{state=blank}},
NewState = step_down(VoteTerm, State2),
{next_state, follower, NewState};
%% We are out of date. Go back to follower state.
candidate(#vote{term=VoteTerm, success=false}, #state{term=Term}=State)
when VoteTerm > Term ->
NewState = step_down(VoteTerm, State),
{next_state, follower, NewState};
%% This is a stale vote from an old request. Ignore it.
candidate(#vote{term=VoteTerm}, #state{term=CurrentTerm}=State)
when VoteTerm < CurrentTerm ->
{next_state, candidate, State};
candidate(#vote{success=false, from=From}, #state{responses=Responses}=State) ->
NewResponses = dict:store(From, false, Responses),
NewState = State#state{responses=NewResponses},
{next_state, candidate, NewState};
%% Sweet, someone likes us! Do we have enough votes to get elected?
candidate(#vote{success=true, from=From}, #state{responses=Responses, me=Me,
config=Config}=State) ->
NewResponses = dict:store(From, true, Responses),
case rafter_config:quorum(Me, Config, NewResponses) of
true ->
NewState = become_leader(State),
{next_state, leader, NewState};
false ->
NewState = State#state{responses=NewResponses},
{next_state, candidate, NewState}
end.
candidate({set_config, _}, _From, State) ->
Reply = {error, election_in_progress},
{reply, Reply, follower, State};
%% A Peer is simultaneously trying to become the leader
%% If it has a higher term, step down and become follower.
candidate(#request_vote{term=RequestTerm}=RequestVote, _From,
#state{term=Term}=State) when RequestTerm > Term ->
NewState = step_down(RequestTerm, State),
handle_request_vote(RequestVote, NewState);
candidate(#request_vote{}, _From, #state{term=CurrentTerm, me=Me}=State) ->
Vote = #vote{term=CurrentTerm, success=false, from=Me},
{reply, Vote, candidate, State};
%% Another peer is asserting itself as leader, and it must be correct because
%% it was elected. We are still in initial config, which must have been a
%% misconfiguration. Clear the initial configuration and step down. Since we
%% still have an outstanding client request for inital config send an error
%% response.
candidate(#append_entries{term=RequestTerm}, _From,
#state{init_config=[_, Client]}=State) ->
gen_fsm:reply(Client, {error, invalid_initial_config}),
%% Set to complete, we don't want another misconfiguration
State2 = State#state{init_config=complete, config=#config{state=blank}},
State3 = step_down(RequestTerm, State2),
{next_state, follower, State3};
%% Same as the above clause, but we don't need to send an error response.
candidate(#append_entries{term=RequestTerm}, _From,
#state{init_config=no_client}=State) ->
%% Set to complete, we don't want another misconfiguration
State2 = State#state{init_config=complete, config=#config{state=blank}},
State3 = step_down(RequestTerm, State2),
{next_state, follower, State3};
%% Another peer is asserting itself as leader. If it has a current term
%% step down and become follower. Otherwise do nothing
candidate(#append_entries{term=RequestTerm}, _From, #state{term=CurrentTerm}=State)
when RequestTerm >= CurrentTerm ->
NewState = step_down(RequestTerm, State),
{next_state, follower, NewState};
candidate(#append_entries{}, _From, State) ->
{next_state, candidate, State};
%% We are in the middle of an election.
%% Leader should always be undefined here.
candidate({read_op, _}, _, #state{leader=undefined}=State) ->
{reply, {error, election_in_progress}, candidate, State};
candidate({op, _Command}, _From, #state{leader=undefined}=State) ->
{reply, {error, election_in_progress}, candidate, State}.
leader(timeout, State0) ->
State = reset_timer(heartbeat_timeout(), State0),
NewState = send_append_entries(State),
{next_state, leader, NewState};
%% We are out of date. Go back to follower state.
leader(#append_entries_rpy{term=Term, success=false},
#state{term=CurrentTerm}=State) when Term > CurrentTerm ->
NewState = step_down(Term, State),
{next_state, follower, NewState};
%% This is a stale reply from an old request. Ignore it.
leader(#append_entries_rpy{term=Term, success=true},
#state{term=CurrentTerm}=State) when CurrentTerm > Term ->
{next_state, leader, State};
%% The follower is not synced yet. Try the previous entry
leader(#append_entries_rpy{from=From, success=false},
#state{followers=Followers, config=C, me=Me}=State) ->
case lists:member(From, rafter_config:followers(Me, C)) of
true ->
NextIndex = decrement_follower_index(From, Followers),
NewFollowers = dict:store(From, NextIndex, Followers),
NewState = State#state{followers=NewFollowers},
{next_state, leader, NewState};
false ->
%% This is a reply from a previous configuration. Ignore it.
{next_state, leader, State}
end;
%% Success!
leader(#append_entries_rpy{from=From, success=true}=Rpy,
#state{followers=Followers, config=C, me=Me}=State) ->
case lists:member(From, rafter_config:followers(Me, C)) of
true ->
NewState = save_rpy(Rpy, State),
State2 = maybe_commit(NewState),
State3 = maybe_send_read_replies(State2),
case State3#state.leader of
undefined ->
%% We just committed a config that doesn't include ourselves
{next_state, follower, State3};
_ ->
State4 =
maybe_increment_follower_index(From, Followers, State3),
{next_state, leader, State4}
end;
false ->
%% This is a reply from a previous configuration. Ignore it.
{next_state, leader, State}
end;
%% Ignore stale votes.
leader(#vote{}, State) ->
{next_state, leader, State}.
%% An out of date leader is sending append_entries, tell it to step down.
leader(#append_entries{term=Term}, _From, #state{term=CurrentTerm, me=Me}=State)
when Term < CurrentTerm ->
Rpy = #append_entries_rpy{from=Me, term=CurrentTerm, success=false},
{reply, Rpy, leader, State};
%% We are out of date. Step down
leader(#append_entries{term=Term}, _From, #state{term=CurrentTerm}=State)
when Term > CurrentTerm ->
NewState = step_down(Term, State),
{next_state, follower, NewState};
%% We are out of date. Step down
leader(#request_vote{term=Term}, _From, #state{term=CurrentTerm}=State)
when Term > CurrentTerm ->
NewState = step_down(Term, State),
{next_state, follower, NewState};
%% An out of date candidate is trying to steal our leadership role. Stop it.
leader(#request_vote{}, _From, #state{me=Me, term=CurrentTerm}=State) ->
Rpy = #vote{from=Me, term=CurrentTerm, success=false},
{reply, Rpy, leader, State};
leader({set_config, {Id, NewServers}}, From,
#state{me=Me, followers=F, term=Term, config=C}=State) ->
case rafter_config:allow_config(C, NewServers) of
true ->
{Followers, Config} = reconfig(Me, F, C, NewServers, State),
Entry = #rafter_entry{type=config, term=Term, cmd=Config},
NewState0 = State#state{config=Config, followers=Followers},
NewState = append(Id, From, Entry, NewState0, leader),
{next_state, leader, NewState};
Error ->
{reply, Error, leader, State}
end;
%% Handle client requests
leader({read_op, {Id, Command}}, From, State) ->
NewState = setup_read_request(Id, From, Command, State),
{next_state, leader, NewState};
leader({op, {Id, Command}}, From,
#state{term=Term}=State) ->
Entry = #rafter_entry{type=op, term=Term, cmd=Command},
NewState = append(Id, From, Entry, State, leader),
{next_state, leader, NewState}.
%%=============================================================================
%% Internal Functions
%%=============================================================================
no_leader_error(Me, Config) ->
case rafter_config:has_vote(Me, Config) of
false ->
not_consensus_group_member;
true ->
election_in_progress
end.
-spec reconfig(term(), dict(), #config{}, list(), #state{}) -> {dict(), #config{}}.
reconfig(Me, OldFollowers, Config0, NewServers, State) ->
Config = rafter_config:reconfig(Config0, NewServers),
NewFollowers = rafter_config:followers(Me, Config),
OldSet = sets:from_list([K || {K, _} <- dict:to_list(OldFollowers)]),
NewSet = sets:from_list(NewFollowers),
AddedServers = sets:to_list(sets:subtract(NewSet, OldSet)),
RemovedServers = sets:to_list(sets:subtract(OldSet, NewSet)),
Followers0 = add_followers(AddedServers, OldFollowers, State),
Followers = remove_followers(RemovedServers, Followers0),
{Followers, Config}.
-spec add_followers(list(), dict(), #state{}) -> dict().
add_followers(NewServers, Followers, #state{me=Me}) ->
NextIndex = rafter_log:get_last_index(Me) + 1,
NewFollowers = [{S, NextIndex} || S <- NewServers],
dict:from_list(NewFollowers ++ dict:to_list(Followers)).
-spec remove_followers(list(), dict()) -> dict().
remove_followers(Servers, Followers0) ->
lists:foldl(fun(S, Followers) ->
dict:erase(S, Followers)
end, Followers0, Servers).
-spec append(#rafter_entry{}, #state{}) -> #state{}.
append(Entry, #state{me=Me}=State) ->
{ok, _Index} = rafter_log:append(Me, [Entry]),
send_append_entries(State).
-spec append(binary(), term(), #rafter_entry{}, #state{}, leader) ->#state{}.
append(Id, From, Entry, State, leader) ->
NewState = append(Id, From, Entry, State),
send_append_entries(NewState).
-spec append(binary(), term(), #rafter_entry{}, #state{}) -> #state{}.
append(Id, From, Entry,
#state{me=Me, term=Term, client_reqs=Reqs}=State) ->
{ok, Index} = rafter_log:append(Me, [Entry]),
{ok, Timer} = timer:send_after(?CLIENT_TIMEOUT, Me, {client_timeout, Id}),
ClientRequest = #client_req{id=Id,
from=From,
index=Index,
term=Term,
timer=Timer},
State#state{client_reqs=[ClientRequest | Reqs]}.
setup_read_request(Id, From, Command, #state{send_clock=Clock,
me=Me,
term=Term}=State) ->
{ok, Timer} = timer:send_after(?CLIENT_TIMEOUT, Me,
{client_read_timeout, Clock, Id}),
ReadRequest = #client_req{id=Id,
from=From,
term=Term,
cmd=Command,
timer=Timer},
NewState = save_read_request(ReadRequest, State),
send_append_entries(NewState).
save_read_request(ReadRequest, #state{send_clock=Clock,
read_reqs=Requests}=State) ->
NewRequests =
case orddict:find(Clock, Requests) of
{ok, ReadRequests} ->
orddict:store(Clock, [ReadRequest | ReadRequests], Requests);
error ->
orddict:store(Clock, [ReadRequest], Requests)
end,
State#state{read_reqs=NewRequests}.
send_client_timeout_reply(#client_req{from=From}) ->
gen_fsm:reply(From, {error, timeout}).
send_client_reply(#client_req{timer=Timer, from=From}, Result) ->
{ok, cancel} = timer:cancel(Timer),
gen_fsm:reply(From, Result).
find_client_req(Id, ClientRequests) ->
Result = lists:filter(fun(Req) ->
Req#client_req.id =:= Id
end, ClientRequests),
case Result of
[Request] ->
{ok, Request};
[] ->
not_found
end.
delete_client_req(Id, ClientRequests) ->
lists:filter(fun(Req) ->
Req#client_req.id =/= Id
end, ClientRequests).
find_client_req_by_index(Index, ClientRequests) ->
Result = lists:filter(fun(Req) ->
Req#client_req.index =:= Index
end, ClientRequests),
case Result of
[Request] ->
{ok, Request};
[] ->
not_found
end.
delete_client_req_by_index(Index, ClientRequests) ->
lists:filter(fun(Req) ->
Req#client_req.index =/= Index
end, ClientRequests).
%% @doc Commit entries between the previous commit index and the new one.
%% Apply them to the local state machine and respond to any outstanding
%% client requests that these commits affect. Return the new state.
%% Ignore already committed entries.
-spec commit_entries(non_neg_integer(), #state{}) -> #state{}.
commit_entries(NewCommitIndex, #state{commit_index=CommitIndex}=State)
when CommitIndex >= NewCommitIndex ->
State;
commit_entries(NewCommitIndex, #state{commit_index=CommitIndex,
state_machine=StateMachine,
backend_state=BackendState,
me=Me}=State) ->
LastIndex = min(rafter_log:get_last_index(Me), NewCommitIndex),
lists:foldl(fun(Index, #state{client_reqs=CliReqs}=State1) ->
NewState = State1#state{commit_index=Index},
case rafter_log:get_entry(Me, Index) of
%% Noop - Ignore this request
{ok, #rafter_entry{type=noop}} ->
NewState;
%% Normal Operation. Apply Command to StateMachine.
{ok, #rafter_entry{type=op, cmd=Command}} ->
{Result, NewBackendState} =
StateMachine:write(Command, BackendState),
NewState2 = NewState#state{backend_state=NewBackendState},
maybe_send_client_reply(Index, CliReqs, NewState2, Result);
%% We have a committed transitional state, so reply
%% successfully to the client. Then set the new stable
%% configuration.
{ok, #rafter_entry{type=config,
cmd=#config{state=transitional}=C}} ->
S = stabilize_config(C, NewState),
Reply = {ok, S#state.config},
maybe_send_client_reply(Index, CliReqs, S, Reply);
%% The configuration has already been set. Initial configuration goes
%% directly to stable state so needs to send a reply. Checking for
%% a client request is expensive, but config changes happen
%% infrequently.
{ok, #rafter_entry{type=config,
cmd=#config{state=stable}}} ->
Reply = {ok, NewState#state.config},
maybe_send_client_reply(Index, CliReqs, NewState, Reply)
end
end, State, lists:seq(CommitIndex+1, LastIndex)).
-spec stabilize_config(#config{}, #state{}) -> #state{}.
stabilize_config(#config{state=transitional, newservers=New}=C,
#state{me=Me, term=Term}=S) when S#state.leader =:= S#state.me ->
Config = C#config{state=stable, oldservers=New, newservers=[]},
Entry = #rafter_entry{type=config, term=Term, cmd=Config},
State = S#state{config=Config},
{ok, _Index} = rafter_log:append(Me, [Entry]),
send_append_entries(State);
stabilize_config(_, State) ->
State.
-spec maybe_send_client_reply(non_neg_integer(), [#client_req{}], #state{},
term()) -> #state{}.
maybe_send_client_reply(Index, CliReqs, S, Result) when S#state.leader =:= S#state.me ->
case find_client_req_by_index(Index, CliReqs) of
{ok, Req} ->
send_client_reply(Req, Result),
Reqs = delete_client_req_by_index(Index, CliReqs),
S#state{client_reqs=Reqs};
not_found ->
S
end;
maybe_send_client_reply(_, _, State, _) ->
State.
maybe_send_read_replies(#state{me=Me,
config=Config,
send_clock_responses=Responses}=State0) ->
Clock = rafter_config:quorum_max(Me, Config, Responses),
{ok, Requests, State} = find_eligible_read_requests(Clock, State0),
NewState = send_client_read_replies(Requests, State),
NewState.
eligible_request(SendClock) ->
fun({Clock, _}) ->
SendClock > Clock
end.
find_eligible_read_requests(SendClock, #state{read_reqs=Requests}=State) ->
EligibleReq = eligible_request(SendClock),
Eligible = lists:takewhile(EligibleReq, Requests),
NewRequests = lists:dropwhile(EligibleReq, Requests),
NewState = State#state{read_reqs=NewRequests},
{ok, Eligible, NewState}.
send_client_read_replies([], State) ->
State;
send_client_read_replies(Requests, State=#state{state_machine=StateMachine,
backend_state=BackendState}) ->
NewBackendState =
lists:foldl(fun({_Clock, ClientReqs}, BeState) ->
read_and_send(ClientReqs, StateMachine, BeState)
end, BackendState, Requests),
State#state{backend_state=NewBackendState}.
read_and_send(ClientRequests, StateMachine, BackendState) ->
lists:foldl(fun(Req, Acc) ->
{Val, NewAcc} =
StateMachine:read(Req#client_req.cmd, Acc),
send_client_reply(Req, Val),
NewAcc
end, BackendState, ClientRequests).
maybe_commit(#state{me=Me,
commit_index=CommitIndex,
config=Config,
responses=Responses}=State) ->
Min = rafter_config:quorum_max(Me, Config, Responses),
case Min > CommitIndex andalso safe_to_commit(Min, State) of
true ->
NewState = commit_entries(Min, State),
case rafter_config:has_vote(Me, NewState#state.config) of
true ->
NewState;
false ->
%% We just committed a config that doesn't include ourself
step_down(NewState#state.term, NewState)
end;
false ->
State
end.
safe_to_commit(Index, #state{term=CurrentTerm, me=Me}) ->
CurrentTerm =:= rafter_log:get_term(Me, Index).
%% We are about to transition to the follower state. Reset the necessary state.
%% TODO: send errors to any outstanding client read or write requests and cleanup
%% timers
step_down(NewTerm, State0) ->
State = reset_timer(election_timeout(), State0),
NewState = State#state{term=NewTerm,
responses=dict:new(),
leader=undefined},
set_metadata(undefined, NewState).
save_rpy(#append_entries_rpy{from=From, index=Index, send_clock=Clock},
#state{responses=Responses, send_clock_responses=ClockResponses}=State) ->
NewResponses = save_greater(From, Index, Responses),
NewClockResponses = save_greater(From, Clock, ClockResponses),
State#state{responses=NewResponses, send_clock_responses=NewClockResponses}.
save_greater(Key, Val, Dict) ->
CurrentVal = dict:find(Key, Dict),
save_greater(Key, Val, Dict, CurrentVal).
save_greater(_Key, Val, Dict, {ok, CurrentVal}) when CurrentVal > Val ->
Dict;
save_greater(_Key, CurrentVal, Dict, {ok, CurrentVal}) ->
Dict;
save_greater(Key, Val, Dict, {ok, _}) ->
dict:store(Key, Val, Dict);
save_greater(Key, Val, Dict, error) ->
dict:store(Key, Val, Dict).
handle_request_vote(#request_vote{from=CandidateId, term=Term}=RequestVote,
State) ->
State2 = set_term(Term, State),
{ok, Vote} = vote(RequestVote, State2),
case Vote#vote.success of
true ->
State3 = set_metadata(CandidateId, State2),
State4 = reset_timer(election_timeout(), State3),
{reply, Vote, follower, State4};
false ->
{reply, Vote, follower, State2}
end.
set_metadata(CandidateId, State=#state{me=Me, term=Term}) ->
NewState = State#state{voted_for=CandidateId},
ok = rafter_log:set_metadata(Me, CandidateId, Term),
NewState.
maybe_increment_follower_index(From, Followers, State=#state{me=Me}) ->
LastLogIndex = rafter_log:get_last_index(Me),
{ok, Index} = dict:find(From, Followers),
case Index =< LastLogIndex of
true ->
State#state{followers=dict:store(From, Index+1, Followers)};
false ->
State
end.
get_prev(Me, Index) ->
case Index - 1 of
0 ->
{0, 0};
PrevIndex ->
{PrevIndex,
rafter_log:get_term(Me, PrevIndex)}
end.
%% TODO: Return a block of entries if more than one exist
get_entries(Me, Index) ->
case rafter_log:get_entry(Me, Index) of
{ok, not_found} ->
[];
{ok, Entry} ->
[Entry]
end.
send_entry(Peer, Index, #state{me=Me,
term=Term,
send_clock=Clock,
commit_index=CIdx}) ->
{PrevLogIndex, PrevLogTerm} = get_prev(Me, Index),
Entries = get_entries(Me, Index),
AppendEntries = #append_entries{term=Term,
from=Me,
prev_log_index=PrevLogIndex,
prev_log_term=PrevLogTerm,
entries=Entries,
commit_index=CIdx,
send_clock=Clock},
rafter_requester:send(Peer, AppendEntries).
send_append_entries(#state{followers=Followers, send_clock=SendClock}=State) ->
NewState = State#state{send_clock=SendClock+1},
_ = [send_entry(Peer, Index, NewState) ||
{Peer, Index} <- dict:to_list(Followers)],
NewState.
decrement_follower_index(From, Followers) ->
case dict:find(From, Followers) of
{ok, 1} ->
1;
{ok, Num} ->
Num - 1
end.
%% @doc Start a process to send a syncrhonous rpc to each peer. Votes will be sent
%% back as messages when the process receives them from the peer. If
%% there is an error or a timeout no message is sent. This helps preserve
%% the asynchrnony of the consensus fsm, while maintaining the rpc
%% semantics for the request_vote message as described in the raft paper.
request_votes(#state{config=Config, term=Term, me=Me}) ->
Voters = rafter_config:voters(Me, Config),
Msg = #request_vote{term=Term,
from=Me,
last_log_index=rafter_log:get_last_index(Me),
last_log_term=rafter_log:get_last_term(Me)},
[rafter_requester:send(Peer, Msg) || Peer <- Voters].
-spec become_candidate(#state{}) -> #state{}.
become_candidate(#state{term=CurrentTerm, me=Me}=State0) ->
State = reset_timer(election_timeout(), State0),
State2 = State#state{term=CurrentTerm + 1,
responses=dict:new(),
leader=undefined},
State3 = set_metadata(Me, State2),
_ = request_votes(State3),
State3.
become_leader(#state{me=Me, term=Term, config=Config, init_config=InitConfig}=State) ->
NewState0 = State#state{leader=Me,
responses=dict:new(),
followers=initialize_followers(State),
send_clock = 0,
send_clock_responses = dict:new(),
read_reqs = orddict:new()},
case InitConfig of
complete ->
%% Commit a noop entry to the log so we can move the commit index
Entry = #rafter_entry{type=noop, term=Term, cmd=noop},
append(Entry, NewState0);
undefined ->
%% Same as above, but we received our config from another node
Entry = #rafter_entry{type=noop, term=Term, cmd=noop},
NewState1 = append(Entry, NewState0),
NewState1#state{init_config=complete};
[Id, From] ->
%% Initial config, append it, and set init_config=complete
Entry = #rafter_entry{type=config, term=Term, cmd=Config},
NewState1 = append(Id, From, Entry, NewState0, leader),
NewState2 = reset_timer(heartbeat_timeout(), NewState1),
NewState2#state{init_config=complete};
no_client ->
%% Same as above, but no-one to tell
Entry = #rafter_entry{type=config, term=Term, cmd=Config},
NewState1 = append(Entry, NewState0),
NewState2 = reset_timer(heartbeat_timeout(), NewState1),
NewState2#state{init_config=complete}
end.
initialize_followers(#state{me=Me, config=Config}) ->
Peers = rafter_config:followers(Me, Config),
NextIndex = rafter_log:get_last_index(Me) + 1,
Followers = [{Peer, NextIndex} || Peer <- Peers],
dict:from_list(Followers).
%% There is no entry at t=0, so just return true.
consistency_check(#append_entries{prev_log_index=0,
prev_log_term=0}, _State) ->
true;
consistency_check(#append_entries{prev_log_index=Index,
prev_log_term=Term}, #state{me=Me}) ->
case rafter_log:get_entry(Me, Index) of
{ok, not_found} ->
false;
{ok, #rafter_entry{term=Term}} ->
true;
{ok, #rafter_entry{term=_DifferentTerm}} ->
false
end.
set_term(Term, #state{term=CurrentTerm}=State) when Term < CurrentTerm ->
State;
set_term(Term, #state{term=CurrentTerm}=State) when Term > CurrentTerm ->
set_metadata(undefined, State#state{term=Term});
set_term(Term, #state{term=Term}=State) ->
State.
vote(#request_vote{term=Term}, #state{term=CurrentTerm, me=Me})
when Term < CurrentTerm ->
fail_vote(CurrentTerm, Me);
vote(#request_vote{from=CandidateId, term=CurrentTerm}=RequestVote,
#state{voted_for=CandidateId, term=CurrentTerm, me=Me}=State) ->
maybe_successful_vote(RequestVote, CurrentTerm, Me, State);
vote(#request_vote{term=CurrentTerm}=RequestVote,
#state{voted_for=undefined, term=CurrentTerm, me=Me}=State) ->
maybe_successful_vote(RequestVote, CurrentTerm, Me, State);
vote(#request_vote{from=CandidateId, term=CurrentTerm},
#state{voted_for=AnotherId, term=CurrentTerm, me=Me})
when AnotherId =/= CandidateId ->
fail_vote(CurrentTerm, Me).
maybe_successful_vote(RequestVote, CurrentTerm, Me, State) ->
case candidate_log_up_to_date(RequestVote, State) of
true ->
successful_vote(CurrentTerm, Me);
false ->
fail_vote(CurrentTerm, Me)
end.
candidate_log_up_to_date(#request_vote{last_log_term=CandidateTerm,
last_log_index=CandidateIndex},
#state{me=Me}) ->
candidate_log_up_to_date(CandidateTerm,
CandidateIndex,
rafter_log:get_last_term(Me),
rafter_log:get_last_index(Me)).
candidate_log_up_to_date(CandidateTerm, _CandidateIndex, LogTerm, _LogIndex)
when CandidateTerm > LogTerm ->
true;
candidate_log_up_to_date(CandidateTerm, _CandidateIndex, LogTerm, _LogIndex)
when CandidateTerm < LogTerm ->
false;
candidate_log_up_to_date(Term, CandidateIndex, Term, LogIndex)
when CandidateIndex > LogIndex ->
true;
candidate_log_up_to_date(Term, CandidateIndex, Term, LogIndex)
when CandidateIndex < LogIndex ->
false;
candidate_log_up_to_date(Term, Index, Term, Index) ->
true.
successful_vote(CurrentTerm, Me) ->
{ok, #vote{term=CurrentTerm, success=true, from=Me}}.
fail_vote(CurrentTerm, Me) ->
{ok, #vote{term=CurrentTerm, success=false, from=Me}}.
election_timeout() ->
crypto:rand_uniform(?ELECTION_TIMEOUT_MIN, ?ELECTION_TIMEOUT_MAX).
heartbeat_timeout() ->
?HEARTBEAT_TIMEOUT.
-spec reset_timer(pos_integer(), #state{}) -> #state{}.
reset_timer(Duration, State=#state{timer=Timer}) ->
_ = gen_fsm:cancel_timer(Timer),
NewTimer = gen_fsm:send_event_after(Duration, timeout),
State#state{timer=NewTimer}.
%%=============================================================================
%% Tests
%%=============================================================================
-ifdef(TEST).
-include_lib("eunit/include/eunit.hrl").
-endif.
| {
"pile_set_name": "Github"
} |
@inherits MatBlazor.Demo.Components.BaseDocComponent
@* THIS FILE IS AUTOGENERATED FROM C# XML Comments! *@
@* ALL MANUAL CHANGES WILL BE REMOVED! *@
@if (!Secondary) {<h3 class="mat-h3">IMatVirtualScrollHelperTarget</h3> } else { <h5 class="mat-h5">IMatVirtualScrollHelperTarget</h5> }
<div><table class="article-table mat-elevation-z5 mdc-theme--surface">
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr>
</table></div>
| {
"pile_set_name": "Github"
} |
package {
public class Vector$object {}
}
var v:Vector.<String> = []
for each(var v2:<caret> in v) {} | {
"pile_set_name": "Github"
} |
/* -*- c-set-style: "K&R"; c-basic-offset: 8 -*-
*
* This file is part of PRoot.
*
* Copyright (C) 2015 STMicroelectronics
*
* 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 TRACEE_REG_H
#define TRACEE_REG_H
#include "tracee/tracee.h"
#include "arch.h"
typedef enum {
SYSARG_NUM = 0,
SYSARG_1,
SYSARG_2,
SYSARG_3,
SYSARG_4,
SYSARG_5,
SYSARG_6,
SYSARG_RESULT,
STACK_POINTER,
INSTR_POINTER,
RTLD_FINI,
STATE_FLAGS,
USERARG_1,
} Reg;
extern int fetch_regs(Tracee *tracee);
extern int push_regs(Tracee *tracee);
extern word_t peek_reg(const Tracee *tracee, RegVersion version, Reg reg);
extern void poke_reg(Tracee *tracee, Reg reg, word_t value);
extern void print_current_regs(Tracee *tracee, int verbose_level, const char *message);
extern void save_current_regs(Tracee *tracee, RegVersion version);
#endif /* TRACEE_REG_H */
| {
"pile_set_name": "Github"
} |
#ifndef slic3r_GCode_PressureEqualizer_hpp_
#define slic3r_GCode_PressureEqualizer_hpp_
#include "../libslic3r.h"
#include "../PrintConfig.hpp"
#include "../ExtrusionEntity.hpp"
namespace Slic3r {
// Processes a G-code. Finds changes in the volumetric extrusion speed and adjusts the transitions
// between these paths to limit fast changes in the volumetric extrusion speed.
class PressureEqualizer
{
public:
PressureEqualizer(const Slic3r::GCodeConfig *config);
~PressureEqualizer();
void reset();
// Process a next batch of G-code lines. Flush the internal buffers if asked for.
const char* process(const char *szGCode, bool flush);
size_t get_output_buffer_length() const { return output_buffer_length; }
private:
struct Statistics
{
void reset() {
volumetric_extrusion_rate_min = std::numeric_limits<float>::max();
volumetric_extrusion_rate_max = 0.f;
volumetric_extrusion_rate_avg = 0.f;
extrusion_length = 0.f;
}
void update(float volumetric_extrusion_rate, float length) {
volumetric_extrusion_rate_min = std::min(volumetric_extrusion_rate_min, volumetric_extrusion_rate);
volumetric_extrusion_rate_max = std::max(volumetric_extrusion_rate_max, volumetric_extrusion_rate);
volumetric_extrusion_rate_avg += volumetric_extrusion_rate * length;
extrusion_length += length;
}
float volumetric_extrusion_rate_min;
float volumetric_extrusion_rate_max;
float volumetric_extrusion_rate_avg;
float extrusion_length;
};
struct Statistics m_stat;
// Keeps the reference, does not own the config.
const Slic3r::GCodeConfig *m_config;
// Private configuration values
// How fast could the volumetric extrusion rate increase / decrase? mm^3/sec^2
struct ExtrusionRateSlope {
float positive;
float negative;
};
enum { numExtrusionRoles = erSupportMaterialInterface + 1 };
ExtrusionRateSlope m_max_volumetric_extrusion_rate_slopes[numExtrusionRoles];
float m_max_volumetric_extrusion_rate_slope_positive;
float m_max_volumetric_extrusion_rate_slope_negative;
// Maximum segment length to split a long segment, if the initial and the final flow rate differ.
float m_max_segment_length;
// Configuration extracted from config.
// Area of the crossestion of each filament. Necessary to calculate the volumetric flow rate.
std::vector<float> m_filament_crossections;
// Internal data.
// X,Y,Z,E,F
float m_current_pos[5];
size_t m_current_extruder;
ExtrusionRole m_current_extrusion_role;
bool m_retracted;
enum GCodeLineType
{
GCODELINETYPE_INVALID,
GCODELINETYPE_NOOP,
GCODELINETYPE_OTHER,
GCODELINETYPE_RETRACT,
GCODELINETYPE_UNRETRACT,
GCODELINETYPE_TOOL_CHANGE,
GCODELINETYPE_MOVE,
GCODELINETYPE_EXTRUDE,
};
struct GCodeLine
{
GCodeLine() :
type(GCODELINETYPE_INVALID),
raw_length(0),
modified(false),
extruder_id(0),
volumetric_extrusion_rate(0.f),
volumetric_extrusion_rate_start(0.f),
volumetric_extrusion_rate_end(0.f)
{}
bool moving_xy() const { return fabs(pos_end[0] - pos_start[0]) > 0.f || fabs(pos_end[1] - pos_start[1]) > 0.f; }
bool moving_z () const { return fabs(pos_end[2] - pos_start[2]) > 0.f; }
bool extruding() const { return moving_xy() && pos_end[3] > pos_start[3]; }
bool retracting() const { return pos_end[3] < pos_start[3]; }
bool deretracting() const { return ! moving_xy() && pos_end[3] > pos_start[3]; }
float dist_xy2() const { return (pos_end[0] - pos_start[0]) * (pos_end[0] - pos_start[0]) + (pos_end[1] - pos_start[1]) * (pos_end[1] - pos_start[1]); }
float dist_xyz2() const { return (pos_end[0] - pos_start[0]) * (pos_end[0] - pos_start[0]) + (pos_end[1] - pos_start[1]) * (pos_end[1] - pos_start[1]) + (pos_end[2] - pos_start[2]) * (pos_end[2] - pos_start[2]); }
float dist_xy() const { return sqrt(dist_xy2()); }
float dist_xyz() const { return sqrt(dist_xyz2()); }
float dist_e() const { return fabs(pos_end[3] - pos_start[3]); }
float feedrate() const { return pos_end[4]; }
float time() const { return dist_xyz() / feedrate(); }
float time_inv() const { return feedrate() / dist_xyz(); }
float volumetric_correction_avg() const {
float avg_correction = 0.5f * (volumetric_extrusion_rate_start + volumetric_extrusion_rate_end) / volumetric_extrusion_rate;
assert(avg_correction > 0.f);
assert(avg_correction <= 1.00000001f);
return avg_correction;
}
float time_corrected() const { return time() * volumetric_correction_avg(); }
GCodeLineType type;
// We try to keep the string buffer once it has been allocated, so it will not be reallocated over and over.
std::vector<char> raw;
size_t raw_length;
// If modified, the raw text has to be adapted by the new extrusion rate,
// or maybe the line needs to be split into multiple lines.
bool modified;
// float timeStart;
// float timeEnd;
// X,Y,Z,E,F. Storing the state of the currently active extruder only.
float pos_start[5];
float pos_end[5];
// Was the axis found on the G-code line? X,Y,Z,F
bool pos_provided[5];
// Index of the active extruder.
size_t extruder_id;
// Extrusion role of this segment.
ExtrusionRole extrusion_role;
// Current volumetric extrusion rate.
float volumetric_extrusion_rate;
// Volumetric extrusion rate at the start of this segment.
float volumetric_extrusion_rate_start;
// Volumetric extrusion rate at the end of this segment.
float volumetric_extrusion_rate_end;
// Volumetric extrusion rate slope limiting this segment.
// If set to zero, the slope is unlimited.
float max_volumetric_extrusion_rate_slope_positive;
float max_volumetric_extrusion_rate_slope_negative;
};
// Circular buffer of GCode lines. The circular buffer size will be limited to circular_buffer_size.
std::vector<GCodeLine> circular_buffer;
// Current position of the circular buffer (index, where to write the next line to, the line has to be pushed out before it is overwritten).
size_t circular_buffer_pos;
// Circular buffer size, configuration value.
size_t circular_buffer_size;
// Number of valid lines in the circular buffer. Lower or equal to circular_buffer_size.
size_t circular_buffer_items;
// Output buffer will only grow. It will not be reallocated over and over.
std::vector<char> output_buffer;
size_t output_buffer_length;
// For debugging purposes. Index of the G-code line processed.
size_t line_idx;
bool process_line(const char *line, const size_t len, GCodeLine &buf);
void output_gcode_line(GCodeLine &buf);
// Go back from the current circular_buffer_pos and lower the feedtrate to decrease the slope of the extrusion rate changes.
// Then go forward and adjust the feedrate to decrease the slope of the extrusion rate changes.
void adjust_volumetric_rate();
// Push the text to the end of the output_buffer.
void push_to_output(const char *text, const size_t len, bool add_eol = true);
// Push an axis assignment to the end of the output buffer.
void push_axis_to_output(const char axis, const float value, bool add_eol = false);
// Push a G-code line to the output,
void push_line_to_output(const GCodeLine &line, const float new_feedrate, const char *comment);
size_t circular_buffer_idx_head() const {
size_t idx = circular_buffer_pos + circular_buffer_size - circular_buffer_items;
if (idx >= circular_buffer_size)
idx -= circular_buffer_size;
return idx;
}
size_t circular_buffer_idx_tail() const { return circular_buffer_pos; }
size_t circular_buffer_idx_prev(size_t idx) const {
idx += circular_buffer_size - 1;
if (idx >= circular_buffer_size)
idx -= circular_buffer_size;
return idx;
}
size_t circular_buffer_idx_next(size_t idx) const {
if (++ idx >= circular_buffer_size)
idx -= circular_buffer_size;
return idx;
}
};
} // namespace Slic3r
#endif /* slic3r_GCode_PressureEqualizer_hpp_ */
| {
"pile_set_name": "Github"
} |
package links
import (
"fmt"
"path"
"strings"
"github.com/docker/go-connections/nat"
)
// Link struct holds informations about parent/child linked container
type Link struct {
// Parent container IP address
ParentIP string
// Child container IP address
ChildIP string
// Link name
Name string
// Child environments variables
ChildEnvironment []string
// Child exposed ports
Ports []nat.Port
}
// NewLink initializes a new Link struct with the provided options.
func NewLink(parentIP, childIP, name string, env []string, exposedPorts map[nat.Port]struct{}) *Link {
var (
i int
ports = make([]nat.Port, len(exposedPorts))
)
for p := range exposedPorts {
ports[i] = p
i++
}
return &Link{
Name: name,
ChildIP: childIP,
ParentIP: parentIP,
ChildEnvironment: env,
Ports: ports,
}
}
// ToEnv creates a string's slice containing child container informations in
// the form of environment variables which will be later exported on container
// startup.
func (l *Link) ToEnv() []string {
env := []string{}
_, n := path.Split(l.Name)
alias := strings.Replace(strings.ToUpper(n), "-", "_", -1)
if p := l.getDefaultPort(); p != nil {
env = append(env, fmt.Sprintf("%s_PORT=%s://%s:%s", alias, p.Proto(), l.ChildIP, p.Port()))
}
//sort the ports so that we can bulk the continuous ports together
nat.Sort(l.Ports, func(ip, jp nat.Port) bool {
// If the two ports have the same number, tcp takes priority
// Sort in desc order
return ip.Int() < jp.Int() || (ip.Int() == jp.Int() && strings.ToLower(ip.Proto()) == "tcp")
})
for i := 0; i < len(l.Ports); {
p := l.Ports[i]
j := nextContiguous(l.Ports, p.Int(), i)
if j > i+1 {
env = append(env, fmt.Sprintf("%s_PORT_%s_%s_START=%s://%s:%s", alias, p.Port(), strings.ToUpper(p.Proto()), p.Proto(), l.ChildIP, p.Port()))
env = append(env, fmt.Sprintf("%s_PORT_%s_%s_ADDR=%s", alias, p.Port(), strings.ToUpper(p.Proto()), l.ChildIP))
env = append(env, fmt.Sprintf("%s_PORT_%s_%s_PROTO=%s", alias, p.Port(), strings.ToUpper(p.Proto()), p.Proto()))
env = append(env, fmt.Sprintf("%s_PORT_%s_%s_PORT_START=%s", alias, p.Port(), strings.ToUpper(p.Proto()), p.Port()))
q := l.Ports[j]
env = append(env, fmt.Sprintf("%s_PORT_%s_%s_END=%s://%s:%s", alias, p.Port(), strings.ToUpper(q.Proto()), q.Proto(), l.ChildIP, q.Port()))
env = append(env, fmt.Sprintf("%s_PORT_%s_%s_PORT_END=%s", alias, p.Port(), strings.ToUpper(q.Proto()), q.Port()))
i = j + 1
continue
} else {
i++
}
}
for _, p := range l.Ports {
env = append(env, fmt.Sprintf("%s_PORT_%s_%s=%s://%s:%s", alias, p.Port(), strings.ToUpper(p.Proto()), p.Proto(), l.ChildIP, p.Port()))
env = append(env, fmt.Sprintf("%s_PORT_%s_%s_ADDR=%s", alias, p.Port(), strings.ToUpper(p.Proto()), l.ChildIP))
env = append(env, fmt.Sprintf("%s_PORT_%s_%s_PORT=%s", alias, p.Port(), strings.ToUpper(p.Proto()), p.Port()))
env = append(env, fmt.Sprintf("%s_PORT_%s_%s_PROTO=%s", alias, p.Port(), strings.ToUpper(p.Proto()), p.Proto()))
}
// Load the linked container's name into the environment
env = append(env, fmt.Sprintf("%s_NAME=%s", alias, l.Name))
if l.ChildEnvironment != nil {
for _, v := range l.ChildEnvironment {
parts := strings.SplitN(v, "=", 2)
if len(parts) < 2 {
continue
}
// Ignore a few variables that are added during docker build (and not really relevant to linked containers)
if parts[0] == "HOME" || parts[0] == "PATH" {
continue
}
env = append(env, fmt.Sprintf("%s_ENV_%s=%s", alias, parts[0], parts[1]))
}
}
return env
}
func nextContiguous(ports []nat.Port, value int, index int) int {
if index+1 == len(ports) {
return index
}
for i := index + 1; i < len(ports); i++ {
if ports[i].Int() > value+1 {
return i - 1
}
value++
}
return len(ports) - 1
}
// Default port rules
func (l *Link) getDefaultPort() *nat.Port {
var p nat.Port
i := len(l.Ports)
if i == 0 {
return nil
} else if i > 1 {
nat.Sort(l.Ports, func(ip, jp nat.Port) bool {
// If the two ports have the same number, tcp takes priority
// Sort in desc order
return ip.Int() < jp.Int() || (ip.Int() == jp.Int() && strings.ToLower(ip.Proto()) == "tcp")
})
}
p = l.Ports[0]
return &p
}
| {
"pile_set_name": "Github"
} |
using Identity.Dapper.Entities;
using Identity.Dapper.Factories;
using Identity.Dapper.Factories.Contracts;
using Identity.Dapper.Queries;
using Identity.Dapper.Queries.User;
using Identity.Dapper.SqlServer.Models;
using Identity.Dapper.Tests.Models;
using Microsoft.Extensions.DependencyInjection;
using Xunit;
namespace Identity.Dapper.Tests.Queries.SQLServer
{
public class SqlServerUserQueriesTests
{
private readonly IQueryFactory _queryFactory;
public SqlServerUserQueriesTests()
{
var services = new ServiceCollection();
services.AddIdentity<DapperIdentityUser, DapperIdentityRole>(x =>
{
x.Password.RequireDigit = false;
x.Password.RequiredLength = 1;
x.Password.RequireLowercase = false;
x.Password.RequireNonAlphanumeric = false;
x.Password.RequireUppercase = false;
})
.AddDapperIdentityFor<SqlServerConfiguration>();
var serviceProvider = services.BuildServiceProvider();
var queryList = new QueryList(serviceProvider);
_queryFactory = new QueryFactory(queryList);
}
[Fact]
public void DeleteUserQueryGeneratesCorrectQuery()
{
var generatedQuery = _queryFactory.GetDeleteQuery<DeleteUserQuery>();
const string expected = "DELETE FROM [dbo].[IdentityUser] WHERE [Id] = @Id";
Assert.Equal(expected, generatedQuery);
}
[Fact]
public void GetClaimsByUserIdQueryGeneratesCorrectQuery()
{
var generatedQuery = _queryFactory.GetQuery<GetClaimsByUserIdQuery>();
const string expected = "SELECT [ClaimType], [ClaimValue] FROM [dbo].[IdentityUserClaim] WHERE [UserId] = @UserId";
Assert.Equal(expected, generatedQuery);
}
[Fact]
public void GetRolesByUserIdQueryGeneratesCorrectQuery()
{
var generatedQuery = _queryFactory.GetQuery<GetRolesByUserIdQuery>();
const string expected = "SELECT [Name] FROM [dbo].[IdentityRole], [dbo].[IdentityUserRole] WHERE [UserId] = @UserId AND [dbo].[IdentityRole].[Id] = [dbo].[IdentityUserRole].[RoleId]";
Assert.Equal(expected, generatedQuery);
}
[Fact]
public void GetUserLoginByLoginProviderAndProviderKeyQueryGeneratesCorrectQuery()
{
var generatedQuery = _queryFactory.GetQuery<GetUserLoginByLoginProviderAndProviderKeyQuery, DapperIdentityUser>(new DapperIdentityUser());
const string expected = "SELECT TOP 1 [IdentityUser].[AccessFailedCount], [IdentityUser].[Email], [IdentityUser].[EmailConfirmed], [IdentityUser].[Id], [IdentityUser].[LockoutEnabled], [IdentityUser].[LockoutEnd], [IdentityUser].[PasswordHash], [IdentityUser].[PhoneNumber], [IdentityUser].[PhoneNumberConfirmed], [IdentityUser].[SecurityStamp], [IdentityUser].[TwoFactorEnabled], [IdentityUser].[UserName], [dbo].[IdentityUserRole].* FROM [dbo].[IdentityUser] LEFT JOIN [dbo].[IdentityUserRole] ON [dbo].[IdentityUserRole].[UserId] = [dbo].[IdentityUser].[Id] INNER JOIN [dbo].[IdentityLogin] ON [dbo].[IdentityUser].[Id] = [dbo].[IdentityLogin].[UserId] WHERE [LoginProvider] = @LoginProvider AND [ProviderKey] = @ProviderKey";
Assert.Equal(expected, generatedQuery);
}
[Fact]
public void GetUserLoginByLoginProviderAndProviderKeyQueryGeneratesCorrectQueryWhenUsingCustomUser()
{
var generatedQuery = _queryFactory.GetQuery<GetUserLoginByLoginProviderAndProviderKeyQuery, CustomDapperIdentityUser>(new CustomDapperIdentityUser());
const string expected = "SELECT TOP 1 [IdentityUser].[AccessFailedCount], [IdentityUser].[Dummy], [IdentityUser].[Email], [IdentityUser].[EmailConfirmed], [IdentityUser].[Id], [IdentityUser].[LockoutEnabled], [IdentityUser].[LockoutEnd], [IdentityUser].[PasswordHash], [IdentityUser].[PhoneNumber], [IdentityUser].[PhoneNumberConfirmed], [IdentityUser].[SecurityStamp], [IdentityUser].[TwoFactorEnabled], [IdentityUser].[UserName], [dbo].[IdentityUserRole].* FROM [dbo].[IdentityUser] LEFT JOIN [dbo].[IdentityUserRole] ON [dbo].[IdentityUserRole].[UserId] = [dbo].[IdentityUser].[Id] INNER JOIN [dbo].[IdentityLogin] ON [dbo].[IdentityUser].[Id] = [dbo].[IdentityLogin].[UserId] WHERE [LoginProvider] = @LoginProvider AND [ProviderKey] = @ProviderKey";
Assert.Equal(expected, generatedQuery);
}
[Fact]
public void GetUserLoginInfoByIdQueryGeneratesCorrectQuery()
{
var generatedQuery = _queryFactory.GetQuery<GetUserLoginInfoByIdQuery>();
const string expected = "SELECT [LoginProvider], [Name], [ProviderKey] FROM [dbo].[IdentityLogin] WHERE [UserId] = @UserId";
Assert.Equal(expected, generatedQuery);
}
[Fact]
public void GetUsersByClaimQueryGeneratesCorrectQuery()
{
var generatedQuery = _queryFactory.GetQuery<GetUsersByClaimQuery, DapperIdentityUser>(new DapperIdentityUser());
const string expected = "SELECT [IdentityUser].[AccessFailedCount], [IdentityUser].[Email], [IdentityUser].[EmailConfirmed], [IdentityUser].[LockoutEnabled], [IdentityUser].[LockoutEnd], [IdentityUser].[PasswordHash], [IdentityUser].[PhoneNumber], [IdentityUser].[PhoneNumberConfirmed], [IdentityUser].[SecurityStamp], [IdentityUser].[TwoFactorEnabled], [IdentityUser].[UserName] FROM [dbo].[IdentityUser], [dbo].[IdentityUserClaim] WHERE [ClaimValue] = @ClaimValue AND [ClaimType] = @ClaimType";
Assert.Equal(expected, generatedQuery);
}
[Fact]
public void GetUsersByClaimQueryGeneratesCorrectQueryWhenUsingCustomUser()
{
var generatedQuery = _queryFactory.GetQuery<GetUsersByClaimQuery, CustomDapperIdentityUser>(new CustomDapperIdentityUser());
const string expected = "SELECT [IdentityUser].[AccessFailedCount], [IdentityUser].[Dummy], [IdentityUser].[Email], [IdentityUser].[EmailConfirmed], [IdentityUser].[LockoutEnabled], [IdentityUser].[LockoutEnd], [IdentityUser].[PasswordHash], [IdentityUser].[PhoneNumber], [IdentityUser].[PhoneNumberConfirmed], [IdentityUser].[SecurityStamp], [IdentityUser].[TwoFactorEnabled], [IdentityUser].[UserName] FROM [dbo].[IdentityUser], [dbo].[IdentityUserClaim] WHERE [ClaimValue] = @ClaimValue AND [ClaimType] = @ClaimType";
Assert.Equal(expected, generatedQuery);
}
[Fact]
public void GetUsersInRoleQueryGeneratesCorrectQuery()
{
var generatedQuery = _queryFactory.GetQuery<GetUsersInRoleQuery, DapperIdentityUser>(new DapperIdentityUser());
const string expected = "SELECT [IdentityUser].[AccessFailedCount], [IdentityUser].[Email], [IdentityUser].[EmailConfirmed], [IdentityUser].[LockoutEnabled], [IdentityUser].[LockoutEnd], [IdentityUser].[PasswordHash], [IdentityUser].[PhoneNumber], [IdentityUser].[PhoneNumberConfirmed], [IdentityUser].[SecurityStamp], [IdentityUser].[TwoFactorEnabled], [IdentityUser].[UserName] FROM [dbo].[IdentityUser], [dbo].[IdentityUserRole], [dbo].[IdentityRole] WHERE [dbo].[IdentityRole].[Name] = @RoleName AND [dbo].[IdentityUserRole].[RoleId] = [dbo].[IdentityRole].[Id] AND [dbo].[IdentityUserRole].[UserId] = [dbo].[IdentityUser].[Id]";
Assert.Equal(expected, generatedQuery);
}
[Fact]
public void GetUsersInRoleQueryGeneratesCorrectQueryWhenUsingCustomUser()
{
var generatedQuery = _queryFactory.GetQuery<GetUsersInRoleQuery, CustomDapperIdentityUser>(new CustomDapperIdentityUser());
const string expected = "SELECT [IdentityUser].[AccessFailedCount], [IdentityUser].[Dummy], [IdentityUser].[Email], [IdentityUser].[EmailConfirmed], [IdentityUser].[LockoutEnabled], [IdentityUser].[LockoutEnd], [IdentityUser].[PasswordHash], [IdentityUser].[PhoneNumber], [IdentityUser].[PhoneNumberConfirmed], [IdentityUser].[SecurityStamp], [IdentityUser].[TwoFactorEnabled], [IdentityUser].[UserName] FROM [dbo].[IdentityUser], [dbo].[IdentityUserRole], [dbo].[IdentityRole] WHERE [dbo].[IdentityRole].[Name] = @RoleName AND [dbo].[IdentityUserRole].[RoleId] = [dbo].[IdentityRole].[Id] AND [dbo].[IdentityUserRole].[UserId] = [dbo].[IdentityUser].[Id]";
Assert.Equal(expected, generatedQuery);
}
[Fact]
public void InsertUserClaimQueryGeneratesCorrectQuery()
{
var generatedQuery = _queryFactory.GetInsertQuery<InsertUserClaimQuery, DapperIdentityUserClaim<int>>(new DapperIdentityUserClaim<int>());
const string expected = "INSERT INTO [dbo].[IdentityUserClaim] ([ClaimType], [ClaimValue], [UserId]) VALUES(@ClaimType, @ClaimValue, @UserId)";
Assert.Equal(expected, generatedQuery);
}
[Fact]
public void InsertUserClaimQueryGeneratesCorrectQueryWhenProvidingId()
{
var generatedQuery = _queryFactory.GetInsertQuery<InsertUserClaimQuery, DapperIdentityUserClaim<int>>(new DapperIdentityUserClaim<int> { Id = 123 });
const string expected = "INSERT INTO [dbo].[IdentityUserClaim] ([ClaimType], [ClaimValue], [Id], [UserId]) VALUES(@ClaimType, @ClaimValue, @Id, @UserId)";
Assert.Equal(expected, generatedQuery);
}
[Fact]
public void InsertUserLoginQueryGeneratesCorrectQuery()
{
var generatedQuery = _queryFactory.GetInsertQuery<InsertUserLoginQuery, DapperIdentityUserLogin<int>>(new DapperIdentityUserLogin<int>());
const string expected = "INSERT INTO [dbo].[IdentityLogin] ([LoginProvider], [ProviderDisplayName], [ProviderKey], [UserId]) VALUES(@LoginProvider, @ProviderDisplayName, @ProviderKey, @UserId)";
Assert.Equal(expected, generatedQuery);
}
[Fact]
public void InsertUserQueryGeneratesCorrectQuery()
{
var generatedQuery = _queryFactory.GetInsertQuery<InsertUserQuery, DapperIdentityUser>(new DapperIdentityUser());
const string expected = "INSERT INTO [dbo].[IdentityUser] ([AccessFailedCount], [Email], [EmailConfirmed], [LockoutEnabled], [LockoutEnd], [PasswordHash], [PhoneNumber], [PhoneNumberConfirmed], [SecurityStamp], [TwoFactorEnabled], [UserName]) OUTPUT INSERTED.Id VALUES(@AccessFailedCount, @Email, @EmailConfirmed, @LockoutEnabled, @LockoutEnd, @PasswordHash, @PhoneNumber, @PhoneNumberConfirmed, @SecurityStamp, @TwoFactorEnabled, @UserName)";
Assert.Equal(expected, generatedQuery);
}
[Fact]
public void InsertUserQueryGeneratesCorrectQueryWhenUsingCustomUser()
{
var generatedQuery = _queryFactory.GetInsertQuery<InsertUserQuery, CustomDapperIdentityUser>(new CustomDapperIdentityUser());
const string expected = "INSERT INTO [dbo].[IdentityUser] ([AccessFailedCount], [Dummy], [Email], [EmailConfirmed], [LockoutEnabled], [LockoutEnd], [PasswordHash], [PhoneNumber], [PhoneNumberConfirmed], [SecurityStamp], [TwoFactorEnabled], [UserName]) OUTPUT INSERTED.Id VALUES(@AccessFailedCount, @Dummy, @Email, @EmailConfirmed, @LockoutEnabled, @LockoutEnd, @PasswordHash, @PhoneNumber, @PhoneNumberConfirmed, @SecurityStamp, @TwoFactorEnabled, @UserName)";
Assert.Equal(expected, generatedQuery);
}
[Fact]
public void InsertUserRoleQueryGeneratesCorrectQuery()
{
var generatedQuery = _queryFactory.GetInsertQuery<InsertUserRoleQuery, DapperIdentityUserRole<int>>(new DapperIdentityUserRole<int>());
const string expected = "INSERT INTO [dbo].[IdentityUserRole] ([RoleId], [UserId]) VALUES(@RoleId, @UserId)";
Assert.Equal(expected, generatedQuery);
}
[Fact]
public void IsInRoleQueryGeneratesCorrectQuery()
{
var generatedQuery = _queryFactory.GetQuery<IsInRoleQuery, DapperIdentityUser>(new DapperIdentityUser());
const string expected = "SELECT 1 FROM [dbo].[IdentityUser], [dbo].[IdentityUserRole], [dbo].[IdentityRole] WHERE [dbo].[IdentityRole].[Name] = @RoleName AND [dbo].[IdentityUser].[Id] = @UserId AND [dbo].[IdentityUserRole].[RoleId] = [dbo].[IdentityRole].[Id] AND [dbo].[IdentityUserRole].[UserId] = [dbo].[IdentityUser].[Id]";
Assert.Equal(expected, generatedQuery);
}
[Fact]
public void RemoveClaimsQueryGeneratesCorrectQuery()
{
var generatedQuery = _queryFactory.GetDeleteQuery<RemoveClaimsQuery>();
const string expected = "DELETE FROM [dbo].[IdentityUserClaim] WHERE [UserId] = @UserId AND [ClaimType] = @ClaimType AND [ClaimValue] = @ClaimValue";
Assert.Equal(expected, generatedQuery);
}
[Fact]
public void RemoveLoginForUserQueryGeneratesCorrectQuery()
{
var generatedQuery = _queryFactory.GetDeleteQuery<RemoveLoginForUserQuery>();
const string expected = "DELETE FROM [dbo].[IdentityLogin] WHERE [UserId] = @UserId AND [LoginProvider] = @LoginProvider AND [ProviderKey] = @ProviderKey";
Assert.Equal(expected, generatedQuery);
}
[Fact]
public void RemoveUserFromRoleQueryGeneratesCorrectQuery()
{
var generatedQuery = _queryFactory.GetDeleteQuery<RemoveUserFromRoleQuery>();
const string expected = "DELETE FROM [dbo].[IdentityUserRole] WHERE [UserId] = @UserId AND [RoleId] = (SELECT [Id] FROM [dbo].[IdentityRole] WHERE [Name] = @RoleName)";
Assert.Equal(expected, generatedQuery);
}
[Fact]
public void SelectUserByEmailQueryGeneratesCorrectQuery()
{
var generatedQuery = _queryFactory.GetQuery<SelectUserByEmailQuery>();
const string expected = "SELECT [dbo].[IdentityUser].*, [dbo].[IdentityUserRole].* FROM [dbo].[IdentityUser] LEFT JOIN [dbo].[IdentityUserRole] ON [dbo].[IdentityUserRole].[UserId] = [dbo].[IdentityUser].[Id] WHERE [Email] = @Email";
Assert.Equal(expected, generatedQuery);
}
[Fact]
public void SelectUserByIdQueryGeneratesCorrectQuery()
{
var generatedQuery = _queryFactory.GetQuery<SelectUserByIdQuery>();
const string expected = "SELECT [dbo].[IdentityUser].*, [dbo].[IdentityUserRole].* FROM [dbo].[IdentityUser] LEFT JOIN [dbo].[IdentityUserRole] ON [dbo].[IdentityUserRole].[UserId] = [dbo].[IdentityUser].[Id] WHERE [Id] = @Id";
Assert.Equal(expected, generatedQuery);
}
[Fact]
public void SelectUserByUserNameQueryGeneratesCorrectQuery()
{
var generatedQuery = _queryFactory.GetQuery<SelectUserByUserNameQuery>();
const string expected = "SELECT [dbo].[IdentityUser].*, [dbo].[IdentityUserRole].* FROM [dbo].[IdentityUser] LEFT JOIN [dbo].[IdentityUserRole] ON [dbo].[IdentityUserRole].[UserId] = [dbo].[IdentityUser].[Id] WHERE [UserName] = @UserName";
Assert.Equal(expected, generatedQuery);
}
[Fact]
public void UpdateClaimForUserQueryGeneratesCorrectQuery()
{
var generatedQuery = _queryFactory.GetUpdateQuery<UpdateClaimForUserQuery, DapperIdentityUserClaim<int>>(new DapperIdentityUserClaim<int>());
const string expected = "UPDATE [dbo].[IdentityUserClaim] SET [ClaimType] = @NewClaimType, [ClaimValue] = @NewClaimValue WHERE [UserId] = @UserId AND [ClaimType] = @ClaimType AND [ClaimValue] = @ClaimValue";
Assert.Equal(expected, generatedQuery);
}
[Fact]
public void UpdateUserQueryGeneratesCorrectQuery()
{
var generatedQuery = _queryFactory.GetUpdateQuery<UpdateUserQuery, DapperIdentityUser>(new DapperIdentityUser());
const string expected = "UPDATE [dbo].[IdentityUser] SET [AccessFailedCount] = @AccessFailedCount, [Email] = @Email, [EmailConfirmed] = @EmailConfirmed, [LockoutEnabled] = @LockoutEnabled, [LockoutEnd] = @LockoutEnd, [PasswordHash] = @PasswordHash, [PhoneNumber] = @PhoneNumber, [PhoneNumberConfirmed] = @PhoneNumberConfirmed, [SecurityStamp] = @SecurityStamp, [TwoFactorEnabled] = @TwoFactorEnabled, [UserName] = @UserName WHERE [Id] = @Id";
Assert.Equal(expected, generatedQuery);
}
}
}
| {
"pile_set_name": "Github"
} |
/*
File: Collections.h
Contains: Collection Manager Interfaces
Version: Technology: System 7.x
Release: QuickTime 6.0.2
Copyright: (c) 1989-2001 by Apple Computer, Inc., all rights reserved
Bugs?: For bug reports, consult the following page on
the World Wide Web:
http://developer.apple.com/bugreporter/
*/
#ifndef __COLLECTIONS__
#define __COLLECTIONS__
#ifndef __MACTYPES__
#include "MacTypes.h"
#endif
#ifndef __MIXEDMODE__
#include "MixedMode.h"
#endif
#if PRAGMA_ONCE
#pragma once
#endif
#ifdef __cplusplus
extern "C" {
#endif
#if PRAGMA_IMPORT
#pragma import on
#endif
#if PRAGMA_STRUCT_ALIGN
#pragma options align=mac68k
#elif PRAGMA_STRUCT_PACKPUSH
#pragma pack(push, 2)
#elif PRAGMA_STRUCT_PACK
#pragma pack(2)
#endif
/*************/
/* Constants */
/*************/
/* Convenience constants for functions which optionally return values */
enum {
kCollectionDontWantTag = 0L,
kCollectionDontWantId = 0L,
kCollectionDontWantSize = 0L,
kCollectionDontWantAttributes = 0L,
kCollectionDontWantIndex = 0L,
kCollectionDontWantData = 0L
};
/* attributes bits */
enum {
kCollectionNoAttributes = 0x00000000, /* no attributes bits set */
kCollectionAllAttributes = (long)0xFFFFFFFF, /* all attributes bits set */
kCollectionUserAttributes = 0x0000FFFF, /* user attributes bits */
kCollectionDefaultAttributes = 0x40000000 /* default attributes - unlocked, persistent */
};
/*
Attribute bits 0 through 15 (entire low word) are reserved for use by the application.
Attribute bits 16 through 31 (entire high word) are reserved for use by the Collection Manager.
Only bits 31 (kCollectionLockBit) and 30 (kCollectionPersistenceBit) currently have meaning.
*/
enum {
kCollectionUser0Bit = 0,
kCollectionUser1Bit = 1,
kCollectionUser2Bit = 2,
kCollectionUser3Bit = 3,
kCollectionUser4Bit = 4,
kCollectionUser5Bit = 5,
kCollectionUser6Bit = 6,
kCollectionUser7Bit = 7,
kCollectionUser8Bit = 8,
kCollectionUser9Bit = 9,
kCollectionUser10Bit = 10,
kCollectionUser11Bit = 11,
kCollectionUser12Bit = 12,
kCollectionUser13Bit = 13,
kCollectionUser14Bit = 14,
kCollectionUser15Bit = 15,
kCollectionReserved0Bit = 16,
kCollectionReserved1Bit = 17,
kCollectionReserved2Bit = 18,
kCollectionReserved3Bit = 19,
kCollectionReserved4Bit = 20,
kCollectionReserved5Bit = 21,
kCollectionReserved6Bit = 22,
kCollectionReserved7Bit = 23,
kCollectionReserved8Bit = 24,
kCollectionReserved9Bit = 25,
kCollectionReserved10Bit = 26,
kCollectionReserved11Bit = 27,
kCollectionReserved12Bit = 28,
kCollectionReserved13Bit = 29,
kCollectionPersistenceBit = 30,
kCollectionLockBit = 31
};
/* attribute masks */
enum {
kCollectionUser0Mask = 1L << kCollectionUser0Bit,
kCollectionUser1Mask = 1L << kCollectionUser1Bit,
kCollectionUser2Mask = 1L << kCollectionUser2Bit,
kCollectionUser3Mask = 1L << kCollectionUser3Bit,
kCollectionUser4Mask = 1L << kCollectionUser4Bit,
kCollectionUser5Mask = 1L << kCollectionUser5Bit,
kCollectionUser6Mask = 1L << kCollectionUser6Bit,
kCollectionUser7Mask = 1L << kCollectionUser7Bit,
kCollectionUser8Mask = 1L << kCollectionUser8Bit,
kCollectionUser9Mask = 1L << kCollectionUser9Bit,
kCollectionUser10Mask = 1L << kCollectionUser10Bit,
kCollectionUser11Mask = 1L << kCollectionUser11Bit,
kCollectionUser12Mask = 1L << kCollectionUser12Bit,
kCollectionUser13Mask = 1L << kCollectionUser13Bit,
kCollectionUser14Mask = 1L << kCollectionUser14Bit,
kCollectionUser15Mask = 1L << kCollectionUser15Bit,
kCollectionReserved0Mask = 1L << kCollectionReserved0Bit,
kCollectionReserved1Mask = 1L << kCollectionReserved1Bit,
kCollectionReserved2Mask = 1L << kCollectionReserved2Bit,
kCollectionReserved3Mask = 1L << kCollectionReserved3Bit,
kCollectionReserved4Mask = 1L << kCollectionReserved4Bit,
kCollectionReserved5Mask = 1L << kCollectionReserved5Bit,
kCollectionReserved6Mask = 1L << kCollectionReserved6Bit,
kCollectionReserved7Mask = 1L << kCollectionReserved7Bit,
kCollectionReserved8Mask = 1L << kCollectionReserved8Bit,
kCollectionReserved9Mask = 1L << kCollectionReserved9Bit,
kCollectionReserved10Mask = 1L << kCollectionReserved10Bit,
kCollectionReserved11Mask = 1L << kCollectionReserved11Bit,
kCollectionReserved12Mask = 1L << kCollectionReserved12Bit,
kCollectionReserved13Mask = 1L << kCollectionReserved13Bit,
kCollectionPersistenceMask = 1L << kCollectionPersistenceBit,
kCollectionLockMask = 1L << kCollectionLockBit
};
/***********/
/* Types */
/***********/
/* abstract data type for a collection */
typedef struct OpaqueCollection* Collection;
/* collection member 4 byte tag */
typedef FourCharCode CollectionTag;
typedef CALLBACK_API( OSErr , CollectionFlattenProcPtr )(SInt32 size, void *data, void *refCon);
typedef CALLBACK_API( OSErr , CollectionExceptionProcPtr )(Collection c, OSErr status);
typedef STACK_UPP_TYPE(CollectionFlattenProcPtr) CollectionFlattenUPP;
typedef STACK_UPP_TYPE(CollectionExceptionProcPtr) CollectionExceptionUPP;
#if OPAQUE_UPP_TYPES
EXTERN_API(CollectionFlattenUPP)
NewCollectionFlattenUPP (CollectionFlattenProcPtr userRoutine);
EXTERN_API(CollectionExceptionUPP)
NewCollectionExceptionUPP (CollectionExceptionProcPtr userRoutine);
EXTERN_API(void)
DisposeCollectionFlattenUPP (CollectionFlattenUPP userUPP);
EXTERN_API(void)
DisposeCollectionExceptionUPP (CollectionExceptionUPP userUPP);
EXTERN_API(OSErr)
InvokeCollectionFlattenUPP (SInt32 size,
void * data,
void * refCon,
CollectionFlattenUPP userUPP);
EXTERN_API(OSErr)
InvokeCollectionExceptionUPP (Collection c,
OSErr status,
CollectionExceptionUPP userUPP);
#else
enum { uppCollectionFlattenProcInfo = 0x00000FE0 }; /* pascal 2_bytes Func(4_bytes, 4_bytes, 4_bytes) */
enum { uppCollectionExceptionProcInfo = 0x000002E0 }; /* pascal 2_bytes Func(4_bytes, 2_bytes) */
#define NewCollectionFlattenUPP(userRoutine) (CollectionFlattenUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppCollectionFlattenProcInfo, GetCurrentArchitecture())
#define NewCollectionExceptionUPP(userRoutine) (CollectionExceptionUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppCollectionExceptionProcInfo, GetCurrentArchitecture())
#define DisposeCollectionFlattenUPP(userUPP) DisposeRoutineDescriptor(userUPP)
#define DisposeCollectionExceptionUPP(userUPP) DisposeRoutineDescriptor(userUPP)
#define InvokeCollectionFlattenUPP(size, data, refCon, userUPP) (OSErr)CALL_THREE_PARAMETER_UPP((userUPP), uppCollectionFlattenProcInfo, (size), (data), (refCon))
#define InvokeCollectionExceptionUPP(c, status, userUPP) (OSErr)CALL_TWO_PARAMETER_UPP((userUPP), uppCollectionExceptionProcInfo, (c), (status))
#endif
/* support for pre-Carbon UPP routines: NewXXXProc and CallXXXProc */
#define NewCollectionFlattenProc(userRoutine) NewCollectionFlattenUPP(userRoutine)
#define NewCollectionExceptionProc(userRoutine) NewCollectionExceptionUPP(userRoutine)
#define CallCollectionFlattenProc(userRoutine, size, data, refCon) InvokeCollectionFlattenUPP(size, data, refCon, userRoutine)
#define CallCollectionExceptionProc(userRoutine, c, status) InvokeCollectionExceptionUPP(c, status, userRoutine)
/*********************************************/
/************* Public interfaces *************/
/*********************************************/
EXTERN_API( Collection )
NewCollection (void) TWOWORDINLINE(0x7000, 0xABF6);
EXTERN_API( void )
DisposeCollection (Collection c) TWOWORDINLINE(0x7001, 0xABF6);
EXTERN_API( Collection )
CloneCollection (Collection c) TWOWORDINLINE(0x7002, 0xABF6);
EXTERN_API( SInt32 )
CountCollectionOwners (Collection c) TWOWORDINLINE(0x7003, 0xABF6);
EXTERN_API( Collection )
CopyCollection (Collection srcCollection,
Collection dstCollection) TWOWORDINLINE(0x7004, 0xABF6);
EXTERN_API( SInt32 )
GetCollectionDefaultAttributes (Collection c) TWOWORDINLINE(0x7005, 0xABF6);
EXTERN_API( void )
SetCollectionDefaultAttributes (Collection c,
SInt32 whichAttributes,
SInt32 newAttributes) TWOWORDINLINE(0x7006, 0xABF6);
EXTERN_API( SInt32 )
CountCollectionItems (Collection c) TWOWORDINLINE(0x7007, 0xABF6);
EXTERN_API( OSErr )
AddCollectionItem (Collection c,
CollectionTag tag,
SInt32 id,
SInt32 itemSize,
const void * itemData) TWOWORDINLINE(0x7008, 0xABF6);
EXTERN_API( OSErr )
GetCollectionItem (Collection c,
CollectionTag tag,
SInt32 id,
SInt32 * itemSize,
void * itemData) TWOWORDINLINE(0x7009, 0xABF6);
EXTERN_API( OSErr )
RemoveCollectionItem (Collection c,
CollectionTag tag,
SInt32 id) TWOWORDINLINE(0x700A, 0xABF6);
EXTERN_API( OSErr )
SetCollectionItemInfo (Collection c,
CollectionTag tag,
SInt32 id,
SInt32 whichAttributes,
SInt32 newAttributes) TWOWORDINLINE(0x700B, 0xABF6);
EXTERN_API( OSErr )
GetCollectionItemInfo (Collection c,
CollectionTag tag,
SInt32 id,
SInt32 * index,
SInt32 * itemSize,
SInt32 * attributes) TWOWORDINLINE(0x700C, 0xABF6);
EXTERN_API( OSErr )
ReplaceIndexedCollectionItem (Collection c,
SInt32 index,
SInt32 itemSize,
const void * itemData) TWOWORDINLINE(0x700D, 0xABF6);
EXTERN_API( OSErr )
GetIndexedCollectionItem (Collection c,
SInt32 index,
SInt32 * itemSize,
void * itemData) TWOWORDINLINE(0x700E, 0xABF6);
EXTERN_API( OSErr )
RemoveIndexedCollectionItem (Collection c,
SInt32 index) TWOWORDINLINE(0x700F, 0xABF6);
EXTERN_API( OSErr )
SetIndexedCollectionItemInfo (Collection c,
SInt32 index,
SInt32 whichAttributes,
SInt32 newAttributes) TWOWORDINLINE(0x7010, 0xABF6);
EXTERN_API( OSErr )
GetIndexedCollectionItemInfo (Collection c,
SInt32 index,
CollectionTag * tag,
SInt32 * id,
SInt32 * itemSize,
SInt32 * attributes) TWOWORDINLINE(0x7011, 0xABF6);
EXTERN_API( Boolean )
CollectionTagExists (Collection c,
CollectionTag tag) TWOWORDINLINE(0x7012, 0xABF6);
EXTERN_API( SInt32 )
CountCollectionTags (Collection c) TWOWORDINLINE(0x7013, 0xABF6);
EXTERN_API( OSErr )
GetIndexedCollectionTag (Collection c,
SInt32 tagIndex,
CollectionTag * tag) TWOWORDINLINE(0x7014, 0xABF6);
EXTERN_API( SInt32 )
CountTaggedCollectionItems (Collection c,
CollectionTag tag) TWOWORDINLINE(0x7015, 0xABF6);
EXTERN_API( OSErr )
GetTaggedCollectionItem (Collection c,
CollectionTag tag,
SInt32 whichItem,
SInt32 * itemSize,
void * itemData) TWOWORDINLINE(0x7016, 0xABF6);
EXTERN_API( OSErr )
GetTaggedCollectionItemInfo (Collection c,
CollectionTag tag,
SInt32 whichItem,
SInt32 * id,
SInt32 * index,
SInt32 * itemSize,
SInt32 * attributes) TWOWORDINLINE(0x7017, 0xABF6);
EXTERN_API( void )
PurgeCollection (Collection c,
SInt32 whichAttributes,
SInt32 matchingAttributes) TWOWORDINLINE(0x7018, 0xABF6);
EXTERN_API( void )
PurgeCollectionTag (Collection c,
CollectionTag tag) TWOWORDINLINE(0x7019, 0xABF6);
EXTERN_API( void )
EmptyCollection (Collection c) TWOWORDINLINE(0x701A, 0xABF6);
EXTERN_API( OSErr )
FlattenCollection (Collection c,
CollectionFlattenUPP flattenProc,
void * refCon) TWOWORDINLINE(0x701B, 0xABF6);
EXTERN_API( OSErr )
FlattenPartialCollection (Collection c,
CollectionFlattenUPP flattenProc,
void * refCon,
SInt32 whichAttributes,
SInt32 matchingAttributes) TWOWORDINLINE(0x701C, 0xABF6);
EXTERN_API( OSErr )
UnflattenCollection (Collection c,
CollectionFlattenUPP flattenProc,
void * refCon) TWOWORDINLINE(0x701D, 0xABF6);
EXTERN_API( CollectionExceptionUPP )
GetCollectionExceptionProc (Collection c) TWOWORDINLINE(0x701E, 0xABF6);
EXTERN_API( void )
SetCollectionExceptionProc (Collection c,
CollectionExceptionUPP exceptionProc) TWOWORDINLINE(0x701F, 0xABF6);
EXTERN_API( Collection )
GetNewCollection (SInt16 collectionID) TWOWORDINLINE(0x7020, 0xABF6);
/**********************************************************************/
/************** Utility routines for handle-based access **************/
/**********************************************************************/
EXTERN_API( OSErr )
AddCollectionItemHdl (Collection aCollection,
CollectionTag tag,
SInt32 id,
Handle itemData) TWOWORDINLINE(0x7021, 0xABF6);
EXTERN_API( OSErr )
GetCollectionItemHdl (Collection aCollection,
CollectionTag tag,
SInt32 id,
Handle itemData) TWOWORDINLINE(0x7022, 0xABF6);
EXTERN_API( OSErr )
ReplaceIndexedCollectionItemHdl (Collection aCollection,
SInt32 index,
Handle itemData) TWOWORDINLINE(0x7023, 0xABF6);
EXTERN_API( OSErr )
GetIndexedCollectionItemHdl (Collection aCollection,
SInt32 index,
Handle itemData) TWOWORDINLINE(0x7024, 0xABF6);
EXTERN_API( OSErr )
FlattenCollectionToHdl (Collection aCollection,
Handle flattened) TWOWORDINLINE(0x7025, 0xABF6);
EXTERN_API( OSErr )
UnflattenCollectionFromHdl (Collection aCollection,
Handle flattened) TWOWORDINLINE(0x7026, 0xABF6);
#if OLDROUTINENAMES
enum {
dontWantTag = kCollectionDontWantTag,
dontWantId = kCollectionDontWantId,
dontWantSize = kCollectionDontWantSize,
dontWantAttributes = kCollectionDontWantAttributes,
dontWantIndex = kCollectionDontWantIndex,
dontWantData = kCollectionDontWantData
};
enum {
noCollectionAttributes = kCollectionNoAttributes,
allCollectionAttributes = kCollectionAllAttributes,
userCollectionAttributes = kCollectionUserAttributes,
defaultCollectionAttributes = kCollectionDefaultAttributes
};
enum {
collectionUser0Bit = kCollectionUser0Bit,
collectionUser1Bit = kCollectionUser1Bit,
collectionUser2Bit = kCollectionUser2Bit,
collectionUser3Bit = kCollectionUser3Bit,
collectionUser4Bit = kCollectionUser4Bit,
collectionUser5Bit = kCollectionUser5Bit,
collectionUser6Bit = kCollectionUser6Bit,
collectionUser7Bit = kCollectionUser7Bit,
collectionUser8Bit = kCollectionUser8Bit,
collectionUser9Bit = kCollectionUser9Bit,
collectionUser10Bit = kCollectionUser10Bit,
collectionUser11Bit = kCollectionUser11Bit,
collectionUser12Bit = kCollectionUser12Bit,
collectionUser13Bit = kCollectionUser13Bit,
collectionUser14Bit = kCollectionUser14Bit,
collectionUser15Bit = kCollectionUser15Bit,
collectionReserved0Bit = kCollectionReserved0Bit,
collectionReserved1Bit = kCollectionReserved1Bit,
collectionReserved2Bit = kCollectionReserved2Bit,
collectionReserved3Bit = kCollectionReserved3Bit,
collectionReserved4Bit = kCollectionReserved4Bit,
collectionReserved5Bit = kCollectionReserved5Bit,
collectionReserved6Bit = kCollectionReserved6Bit,
collectionReserved7Bit = kCollectionReserved7Bit,
collectionReserved8Bit = kCollectionReserved8Bit,
collectionReserved9Bit = kCollectionReserved9Bit,
collectionReserved10Bit = kCollectionReserved10Bit,
collectionReserved11Bit = kCollectionReserved11Bit,
collectionReserved12Bit = kCollectionReserved12Bit,
collectionReserved13Bit = kCollectionReserved13Bit,
collectionPersistenceBit = kCollectionPersistenceBit,
collectionLockBit = kCollectionLockBit
};
enum {
collectionUser0Mask = kCollectionUser0Mask,
collectionUser1Mask = kCollectionUser1Mask,
collectionUser2Mask = kCollectionUser2Mask,
collectionUser3Mask = kCollectionUser3Mask,
collectionUser4Mask = kCollectionUser4Mask,
collectionUser5Mask = kCollectionUser5Mask,
collectionUser6Mask = kCollectionUser6Mask,
collectionUser7Mask = kCollectionUser7Mask,
collectionUser8Mask = kCollectionUser8Mask,
collectionUser9Mask = kCollectionUser9Mask,
collectionUser10Mask = kCollectionUser10Mask,
collectionUser11Mask = kCollectionUser11Mask,
collectionUser12Mask = kCollectionUser12Mask,
collectionUser13Mask = kCollectionUser13Mask,
collectionUser14Mask = kCollectionUser14Mask,
collectionUser15Mask = kCollectionUser15Mask,
collectionReserved0Mask = kCollectionReserved0Mask,
collectionReserved1Mask = kCollectionReserved1Mask,
collectionReserved2Mask = kCollectionReserved2Mask,
collectionReserved3Mask = kCollectionReserved3Mask,
collectionReserved4Mask = kCollectionReserved4Mask,
collectionReserved5Mask = kCollectionReserved5Mask,
collectionReserved6Mask = kCollectionReserved6Mask,
collectionReserved7Mask = kCollectionReserved7Mask,
collectionReserved8Mask = kCollectionReserved8Mask,
collectionReserved9Mask = kCollectionReserved9Mask,
collectionReserved10Mask = kCollectionReserved10Mask,
collectionReserved11Mask = kCollectionReserved11Mask,
collectionReserved12Mask = kCollectionReserved12Mask,
collectionReserved13Mask = kCollectionReserved13Mask,
collectionPersistenceMask = kCollectionPersistenceMask,
collectionLockMask = kCollectionLockMask
};
#endif /* OLDROUTINENAMES */
#if PRAGMA_STRUCT_ALIGN
#pragma options align=reset
#elif PRAGMA_STRUCT_PACKPUSH
#pragma pack(pop)
#elif PRAGMA_STRUCT_PACK
#pragma pack()
#endif
#ifdef PRAGMA_IMPORT_OFF
#pragma import off
#elif PRAGMA_IMPORT
#pragma import reset
#endif
#ifdef __cplusplus
}
#endif
#endif /* __COLLECTIONS__ */
| {
"pile_set_name": "Github"
} |
fileFormatVersion: 2
guid: beb48511ef6091e4ba054ad1b618933c
timeCreated: 1508326108
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
| {
"pile_set_name": "Github"
} |
//Tablacus Explorer
function _s()
{
try {
window.te = external;
api = te.WindowsAPI;
fso = api.CreateObject("fso");
sha = api.CreateObject("sha");
wsh = api.CreateObject("wsh");
arg = api.CommandLineToArgv(api.GetCommandLine());
location = {href: arg[2], hash: ''};
var parent = fso.GetParentFolderName(arg[0]);
if (!/^[A-Z]:\\|^\\\\/i.test(location.href)) {
location.href = fso.BuildPath(parent, location.href);
}
for (var esw = new Enumerator(sha.Windows()); !esw.atEnd(); esw.moveNext()) {
var x = esw.item();
if (x && api.StrCmpI(fso.GetParentFolderName(x.FullName), parent) == 0) {
var w = x.Document.parentWindow;
if (!window.MainWindow || window.MainWindow.Exchange && window.MainWindow.Exchange[arg[3]]) {
window.MainWindow = w;
var rc = api.Memory('RECT');
api.GetWindowRect(w.te.hwnd, rc);
api.MoveWindow(te.hwnd, (rc.Left + rc.Right) / 2, (rc.Top + rc.Bottom) / 2, 0, 0, false);
}
}
}
api.AllowSetForegroundWindow(-1);
return _es(location.href);
} catch (e) {
wsh.Popup((e.stack || e.description || e.toString()), 0, 'Tablacus Explorer', 0x10);
}
}
function _es(fn)
{
if (!/^[A-Z]:\\|^\\\\/i.test(fn)) {
fn = fso.BuildPath(/^\\/.test(fn) ? fso.GetParentFolderName(api.GetModuleFileName(null)) : fso.GetParentFolderName(location.href), fn);
}
var s;
try {
var ado = api.CreateObject("ads");
ado.CharSet = 'utf-8';
ado.Open();
ado.LoadFromFile(fn);
s = ado.ReadText();
ado.Close();
} catch (e) {
if (MainWindow.Exchange) {
delete MainWindow.Exchange[arg[3]];
}
wsh.Popup((e.description || e.toString()) + '\n' + fn, 0, 'Tablacus Explorer', 0x10);
}
if (s) {
try {
return new Function(s)();
} catch (e) {
wsh.Popup((e.stack || e.description || e.toString()) + '\n' + fn, 0, 'Tablacus Explorer', 0x10);
}
}
}
function importScripts()
{
for (var i = 0; i < arguments.length; ++i) {
_es(arguments[i]);
}
}
| {
"pile_set_name": "Github"
} |
---
http_interactions:
- request:
method: get
uri: http://ps.pndsn.com/v2/auth/grant/sub-key/sub-a-mock-key?auth=ruby-authkey&m=0&pnsdk=PubNub-Ruby/4.1.0&r=1&signature=XAbJ7AMRlk1kRXUvk5yQB3kLAnpnt_-IBaa9PXFTg8Q=×tamp=1464189102&ttl=300&uuid=ruby-test-uuid-client-one&w=1
body:
encoding: UTF-8
string: ''
headers:
User-Agent:
- HTTPClient/1.0 (2.8.0, ruby 2.3.0 (2015-12-25))
Accept:
- "*/*"
Date:
- Wed, 25 May 2016 15:11:42 GMT
response:
status:
code: 400
message: Bad Request
headers:
Server:
- nginx
Date:
- Wed, 25 May 2016 15:11:42 GMT
Content-Type:
- text/javascript; charset=UTF-8
Transfer-Encoding:
- chunked
Connection:
- close
Access-Control-Allow-Origin:
- "*"
Access-Control-Allow-Methods:
- GET
body:
encoding: UTF-8
string: '{"message":"Auth-only grants are reserved for future use","error":true,"service":"Access
Manager","status":400}
'
http_version:
recorded_at: Wed, 25 May 2016 15:11:42 GMT
recorded_with: VCR 3.0.1
| {
"pile_set_name": "Github"
} |
using System;
using System.Linq;
using System.Windows.Forms;
using BizHawk.Emulation.Cores.Nintendo.NES;
namespace BizHawk.Client.EmuHawk
{
public partial class NesControllerSettings : Form
{
private readonly IMainFormForConfig _mainForm;
private readonly NES.NESSyncSettings _syncSettings;
public NesControllerSettings(
IMainFormForConfig mainForm,
NES.NESSyncSettings syncSettings)
{
_mainForm = mainForm;
_syncSettings = syncSettings;
InitializeComponent();
Icon = Properties.Resources.GameControllerIcon;
// TODO: use combobox extension and add descriptions to enum values
comboBoxFamicom.Items.AddRange(NESControlSettings.GetFamicomExpansionValues().ToArray());
comboBoxNESL.Items.AddRange(NESControlSettings.GetNesPortValues().ToArray());
comboBoxNESR.Items.AddRange(NESControlSettings.GetNesPortValues().ToArray());
comboBoxFamicom.SelectedItem = _syncSettings.Controls.FamicomExpPort;
comboBoxNESL.SelectedItem = _syncSettings.Controls.NesLeftPort;
comboBoxNESR.SelectedItem = _syncSettings.Controls.NesRightPort;
checkBoxFamicom.Checked = _syncSettings.Controls.Famicom;
}
private void CheckBoxFamicom_CheckedChanged(object sender, EventArgs e)
{
comboBoxFamicom.Enabled = checkBoxFamicom.Checked;
comboBoxNESL.Enabled = !checkBoxFamicom.Checked;
comboBoxNESR.Enabled = !checkBoxFamicom.Checked;
}
private void OkBtn_Click(object sender, EventArgs e)
{
var controls = new NESControlSettings
{
Famicom = checkBoxFamicom.Checked,
FamicomExpPort = (string)comboBoxFamicom.SelectedItem,
NesLeftPort = (string)comboBoxNESL.SelectedItem,
NesRightPort = (string)comboBoxNESR.SelectedItem
};
bool changed = NESControlSettings.NeedsReboot(controls, _syncSettings.Controls);
_syncSettings.Controls = controls;
if (changed)
{
_mainForm.PutCoreSyncSettings(_syncSettings);
}
DialogResult = DialogResult.OK;
Close();
}
private void CancelBtn_Click(object sender, EventArgs e)
{
_mainForm.AddOnScreenMessage("Controller settings aborted");
DialogResult = DialogResult.Cancel;
Close();
}
}
}
| {
"pile_set_name": "Github"
} |
package com.jsql.view.swing.radio;
import java.awt.Cursor;
import java.awt.Font;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.font.TextAttribute;
import java.util.HashMap;
import java.util.Map;
import javax.swing.JLabel;
import javax.swing.SwingUtilities;
import com.jsql.view.swing.util.UiUtil;
/**
* Mouse adapter for radio link effect (hover and click).
*/
public class RadioMethodMouseAdapter extends MouseAdapter {
/**
* Font to display on mouse exit: underline or bold.
*/
private Font original;
@Override
public void mouseClicked(MouseEvent e) {
super.mouseClicked(e);
AbstractRadioLink radio = (AbstractRadioLink) e.getComponent();
if (radio.isActivable() && SwingUtilities.isLeftMouseButton(e)) {
for (JLabel label: radio.getGroup()) {
if ((JLabel) e.getComponent() != label) {
label.setFont(UiUtil.FONT_SEGOE);
} else {
radio.action();
}
}
radio.setUnderlined();
this.original = e.getComponent().getFont();
radio.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
}
@Override
public void mouseEntered(MouseEvent e) {
super.mouseEntered(e);
AbstractRadioLink radio = (AbstractRadioLink) e.getComponent();
this.original = e.getComponent().getFont();
if (radio.isActivable()) {
Font font = radio.getFont();
Map<TextAttribute, Object> attributes = new HashMap<>(font.getAttributes());
attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
radio.setFont(font.deriveFont(attributes));
radio.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}
}
@Override
public void mouseExited(MouseEvent e) {
super.mouseExited(e);
AbstractRadioLink radio = (AbstractRadioLink) e.getComponent();
radio.setFont(this.original);
radio.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
} | {
"pile_set_name": "Github"
} |
/*
* tps65217-regulator.c
*
* Regulator driver for TPS65217 PMIC
*
* Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation version 2.
*
* This program is distributed "as is" WITHOUT ANY WARRANTY of any
* kind, whether express or implied; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/device.h>
#include <linux/init.h>
#include <linux/err.h>
#include <linux/platform_device.h>
#include <linux/regulator/of_regulator.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/machine.h>
#include <linux/mfd/tps65217.h>
#define TPS65217_REGULATOR(_name, _id, _of_match, _ops, _n, _vr, _vm, _em, \
_t, _lr, _nlr) \
{ \
.name = _name, \
.id = _id, \
.of_match = of_match_ptr(_of_match), \
.regulators_node= of_match_ptr("regulators"), \
.ops = &_ops, \
.n_voltages = _n, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
.vsel_reg = _vr, \
.vsel_mask = _vm, \
.enable_reg = TPS65217_REG_ENABLE, \
.enable_mask = _em, \
.volt_table = _t, \
.linear_ranges = _lr, \
.n_linear_ranges = _nlr, \
} \
static const unsigned int LDO1_VSEL_table[] = {
1000000, 1100000, 1200000, 1250000,
1300000, 1350000, 1400000, 1500000,
1600000, 1800000, 2500000, 2750000,
2800000, 3000000, 3100000, 3300000,
};
static const struct regulator_linear_range tps65217_uv1_ranges[] = {
REGULATOR_LINEAR_RANGE(900000, 0, 24, 25000),
REGULATOR_LINEAR_RANGE(1550000, 25, 30, 50000),
REGULATOR_LINEAR_RANGE(1850000, 31, 52, 50000),
REGULATOR_LINEAR_RANGE(3000000, 53, 55, 100000),
REGULATOR_LINEAR_RANGE(3300000, 56, 62, 0),
};
static const struct regulator_linear_range tps65217_uv2_ranges[] = {
REGULATOR_LINEAR_RANGE(1500000, 0, 8, 50000),
REGULATOR_LINEAR_RANGE(2000000, 9, 13, 100000),
REGULATOR_LINEAR_RANGE(2450000, 14, 31, 50000),
};
static int tps65217_pmic_enable(struct regulator_dev *dev)
{
struct tps65217 *tps = rdev_get_drvdata(dev);
int rid = rdev_get_id(dev);
if (rid < TPS65217_DCDC_1 || rid > TPS65217_LDO_4)
return -EINVAL;
/* Enable the regulator and password protection is level 1 */
return tps65217_set_bits(tps, TPS65217_REG_ENABLE,
dev->desc->enable_mask, dev->desc->enable_mask,
TPS65217_PROTECT_L1);
}
static int tps65217_pmic_disable(struct regulator_dev *dev)
{
struct tps65217 *tps = rdev_get_drvdata(dev);
int rid = rdev_get_id(dev);
if (rid < TPS65217_DCDC_1 || rid > TPS65217_LDO_4)
return -EINVAL;
/* Disable the regulator and password protection is level 1 */
return tps65217_clear_bits(tps, TPS65217_REG_ENABLE,
dev->desc->enable_mask, TPS65217_PROTECT_L1);
}
static int tps65217_pmic_set_voltage_sel(struct regulator_dev *dev,
unsigned selector)
{
int ret;
struct tps65217 *tps = rdev_get_drvdata(dev);
unsigned int rid = rdev_get_id(dev);
/* Set the voltage based on vsel value and write protect level is 2 */
ret = tps65217_set_bits(tps, dev->desc->vsel_reg, dev->desc->vsel_mask,
selector, TPS65217_PROTECT_L2);
/* Set GO bit for DCDCx to initiate voltage transistion */
switch (rid) {
case TPS65217_DCDC_1 ... TPS65217_DCDC_3:
ret = tps65217_set_bits(tps, TPS65217_REG_DEFSLEW,
TPS65217_DEFSLEW_GO, TPS65217_DEFSLEW_GO,
TPS65217_PROTECT_L2);
break;
}
return ret;
}
/* Operations permitted on DCDCx, LDO2, LDO3 and LDO4 */
static struct regulator_ops tps65217_pmic_ops = {
.is_enabled = regulator_is_enabled_regmap,
.enable = tps65217_pmic_enable,
.disable = tps65217_pmic_disable,
.get_voltage_sel = regulator_get_voltage_sel_regmap,
.set_voltage_sel = tps65217_pmic_set_voltage_sel,
.list_voltage = regulator_list_voltage_linear_range,
.map_voltage = regulator_map_voltage_linear_range,
};
/* Operations permitted on LDO1 */
static struct regulator_ops tps65217_pmic_ldo1_ops = {
.is_enabled = regulator_is_enabled_regmap,
.enable = tps65217_pmic_enable,
.disable = tps65217_pmic_disable,
.get_voltage_sel = regulator_get_voltage_sel_regmap,
.set_voltage_sel = tps65217_pmic_set_voltage_sel,
.list_voltage = regulator_list_voltage_table,
.map_voltage = regulator_map_voltage_ascend,
};
static const struct regulator_desc regulators[] = {
TPS65217_REGULATOR("DCDC1", TPS65217_DCDC_1, "dcdc1",
tps65217_pmic_ops, 64, TPS65217_REG_DEFDCDC1,
TPS65217_DEFDCDCX_DCDC_MASK, TPS65217_ENABLE_DC1_EN,
NULL, tps65217_uv1_ranges, 2),
TPS65217_REGULATOR("DCDC2", TPS65217_DCDC_2, "dcdc2",
tps65217_pmic_ops, 64, TPS65217_REG_DEFDCDC2,
TPS65217_DEFDCDCX_DCDC_MASK, TPS65217_ENABLE_DC2_EN,
NULL, tps65217_uv1_ranges,
ARRAY_SIZE(tps65217_uv1_ranges)),
TPS65217_REGULATOR("DCDC3", TPS65217_DCDC_3, "dcdc3",
tps65217_pmic_ops, 64, TPS65217_REG_DEFDCDC3,
TPS65217_DEFDCDCX_DCDC_MASK, TPS65217_ENABLE_DC3_EN,
NULL, tps65217_uv1_ranges, 1),
TPS65217_REGULATOR("LDO1", TPS65217_LDO_1, "ldo1",
tps65217_pmic_ldo1_ops, 16, TPS65217_REG_DEFLDO1,
TPS65217_DEFLDO1_LDO1_MASK, TPS65217_ENABLE_LDO1_EN,
LDO1_VSEL_table, NULL, 0),
TPS65217_REGULATOR("LDO2", TPS65217_LDO_2, "ldo2", tps65217_pmic_ops,
64, TPS65217_REG_DEFLDO2,
TPS65217_DEFLDO2_LDO2_MASK, TPS65217_ENABLE_LDO2_EN,
NULL, tps65217_uv1_ranges,
ARRAY_SIZE(tps65217_uv1_ranges)),
TPS65217_REGULATOR("LDO3", TPS65217_LDO_3, "ldo3", tps65217_pmic_ops,
32, TPS65217_REG_DEFLS1, TPS65217_DEFLDO3_LDO3_MASK,
TPS65217_ENABLE_LS1_EN | TPS65217_DEFLDO3_LDO3_EN,
NULL, tps65217_uv2_ranges,
ARRAY_SIZE(tps65217_uv2_ranges)),
TPS65217_REGULATOR("LDO4", TPS65217_LDO_4, "ldo4", tps65217_pmic_ops,
32, TPS65217_REG_DEFLS2, TPS65217_DEFLDO4_LDO4_MASK,
TPS65217_ENABLE_LS2_EN | TPS65217_DEFLDO4_LDO4_EN,
NULL, tps65217_uv2_ranges,
ARRAY_SIZE(tps65217_uv2_ranges)),
};
static int tps65217_regulator_probe(struct platform_device *pdev)
{
struct tps65217 *tps = dev_get_drvdata(pdev->dev.parent);
struct tps65217_board *pdata = dev_get_platdata(tps->dev);
struct regulator_dev *rdev;
struct regulator_config config = { };
int i;
if (tps65217_chip_id(tps) != TPS65217) {
dev_err(&pdev->dev, "Invalid tps chip version\n");
return -ENODEV;
}
platform_set_drvdata(pdev, tps);
for (i = 0; i < TPS65217_NUM_REGULATOR; i++) {
/* Register the regulators */
config.dev = tps->dev;
if (pdata)
config.init_data = pdata->tps65217_init_data[i];
config.driver_data = tps;
config.regmap = tps->regmap;
rdev = devm_regulator_register(&pdev->dev, ®ulators[i],
&config);
if (IS_ERR(rdev)) {
dev_err(tps->dev, "failed to register %s regulator\n",
pdev->name);
return PTR_ERR(rdev);
}
}
return 0;
}
static struct platform_driver tps65217_regulator_driver = {
.driver = {
.name = "tps65217-pmic",
},
.probe = tps65217_regulator_probe,
};
static int __init tps65217_regulator_init(void)
{
return platform_driver_register(&tps65217_regulator_driver);
}
subsys_initcall(tps65217_regulator_init);
static void __exit tps65217_regulator_exit(void)
{
platform_driver_unregister(&tps65217_regulator_driver);
}
module_exit(tps65217_regulator_exit);
MODULE_AUTHOR("AnilKumar Ch <[email protected]>");
MODULE_DESCRIPTION("TPS65217 voltage regulator driver");
MODULE_ALIAS("platform:tps65217-pmic");
MODULE_LICENSE("GPL v2");
| {
"pile_set_name": "Github"
} |
require_relative '../../spec_helper'
describe "RUBY_VERSION" do
it "is a String" do
RUBY_VERSION.should be_kind_of(String)
end
end
describe "RUBY_PATCHLEVEL" do
it "is a Fixnum" do
RUBY_PATCHLEVEL.should be_kind_of(Fixnum)
end
end
describe "RUBY_COPYRIGHT" do
it "is a String" do
RUBY_COPYRIGHT.should be_kind_of(String)
end
end
describe "RUBY_DESCRIPTION" do
it "is a String" do
RUBY_DESCRIPTION.should be_kind_of(String)
end
end
describe "RUBY_ENGINE" do
it "is a String" do
RUBY_ENGINE.should be_kind_of(String)
end
end
describe "RUBY_PLATFORM" do
it "is a String" do
RUBY_PLATFORM.should be_kind_of(String)
end
platform_is :darwin do
it 'ends with the build time kernel major version on darwin' do
RUBY_PLATFORM.should =~ /-darwin\d+$/
end
end
end
describe "RUBY_RELEASE_DATE" do
it "is a String" do
RUBY_RELEASE_DATE.should be_kind_of(String)
end
end
describe "RUBY_REVISION" do
ruby_version_is ""..."2.7" do
it "is an Integer" do
RUBY_REVISION.should be_kind_of(Fixnum)
end
end
ruby_version_is "2.7" do
it "is a String" do
RUBY_REVISION.should be_kind_of(String)
end
end
end
| {
"pile_set_name": "Github"
} |
/*
* Modified to interface to the Linux kernel
* Copyright (c) 2009, Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place - Suite 330, Boston, MA 02111-1307 USA.
*/
/* --------------------------------------------------------------------------
* VMAC and VHASH Implementation by Ted Krovetz ([email protected]) and Wei Dai.
* This implementation is herby placed in the public domain.
* The authors offers no warranty. Use at your own risk.
* Please send bug reports to the authors.
* Last modified: 17 APR 08, 1700 PDT
* ----------------------------------------------------------------------- */
#include <linux/init.h>
#include <linux/types.h>
#include <linux/crypto.h>
#include <linux/scatterlist.h>
#include <asm/byteorder.h>
#include <crypto/scatterwalk.h>
#include <crypto/vmac.h>
#include <crypto/internal/hash.h>
/*
* Constants and masks
*/
#define UINT64_C(x) x##ULL
const u64 p64 = UINT64_C(0xfffffffffffffeff); /* 2^64 - 257 prime */
const u64 m62 = UINT64_C(0x3fffffffffffffff); /* 62-bit mask */
const u64 m63 = UINT64_C(0x7fffffffffffffff); /* 63-bit mask */
const u64 m64 = UINT64_C(0xffffffffffffffff); /* 64-bit mask */
const u64 mpoly = UINT64_C(0x1fffffff1fffffff); /* Poly key mask */
#ifdef __LITTLE_ENDIAN
#define INDEX_HIGH 1
#define INDEX_LOW 0
#else
#define INDEX_HIGH 0
#define INDEX_LOW 1
#endif
/*
* The following routines are used in this implementation. They are
* written via macros to simulate zero-overhead call-by-reference.
*
* MUL64: 64x64->128-bit multiplication
* PMUL64: assumes top bits cleared on inputs
* ADD128: 128x128->128-bit addition
*/
#define ADD128(rh, rl, ih, il) \
do { \
u64 _il = (il); \
(rl) += (_il); \
if ((rl) < (_il)) \
(rh)++; \
(rh) += (ih); \
} while (0)
#define MUL32(i1, i2) ((u64)(u32)(i1)*(u32)(i2))
#define PMUL64(rh, rl, i1, i2) /* Assumes m doesn't overflow */ \
do { \
u64 _i1 = (i1), _i2 = (i2); \
u64 m = MUL32(_i1, _i2>>32) + MUL32(_i1>>32, _i2); \
rh = MUL32(_i1>>32, _i2>>32); \
rl = MUL32(_i1, _i2); \
ADD128(rh, rl, (m >> 32), (m << 32)); \
} while (0)
#define MUL64(rh, rl, i1, i2) \
do { \
u64 _i1 = (i1), _i2 = (i2); \
u64 m1 = MUL32(_i1, _i2>>32); \
u64 m2 = MUL32(_i1>>32, _i2); \
rh = MUL32(_i1>>32, _i2>>32); \
rl = MUL32(_i1, _i2); \
ADD128(rh, rl, (m1 >> 32), (m1 << 32)); \
ADD128(rh, rl, (m2 >> 32), (m2 << 32)); \
} while (0)
/*
* For highest performance the L1 NH and L2 polynomial hashes should be
* carefully implemented to take advantage of one's target architechture.
* Here these two hash functions are defined multiple time; once for
* 64-bit architectures, once for 32-bit SSE2 architectures, and once
* for the rest (32-bit) architectures.
* For each, nh_16 *must* be defined (works on multiples of 16 bytes).
* Optionally, nh_vmac_nhbytes can be defined (for multiples of
* VMAC_NHBYTES), and nh_16_2 and nh_vmac_nhbytes_2 (versions that do two
* NH computations at once).
*/
#ifdef CONFIG_64BIT
#define nh_16(mp, kp, nw, rh, rl) \
do { \
int i; u64 th, tl; \
rh = rl = 0; \
for (i = 0; i < nw; i += 2) { \
MUL64(th, tl, le64_to_cpup((mp)+i)+(kp)[i], \
le64_to_cpup((mp)+i+1)+(kp)[i+1]); \
ADD128(rh, rl, th, tl); \
} \
} while (0)
#define nh_16_2(mp, kp, nw, rh, rl, rh1, rl1) \
do { \
int i; u64 th, tl; \
rh1 = rl1 = rh = rl = 0; \
for (i = 0; i < nw; i += 2) { \
MUL64(th, tl, le64_to_cpup((mp)+i)+(kp)[i], \
le64_to_cpup((mp)+i+1)+(kp)[i+1]); \
ADD128(rh, rl, th, tl); \
MUL64(th, tl, le64_to_cpup((mp)+i)+(kp)[i+2], \
le64_to_cpup((mp)+i+1)+(kp)[i+3]); \
ADD128(rh1, rl1, th, tl); \
} \
} while (0)
#if (VMAC_NHBYTES >= 64) /* These versions do 64-bytes of message at a time */
#define nh_vmac_nhbytes(mp, kp, nw, rh, rl) \
do { \
int i; u64 th, tl; \
rh = rl = 0; \
for (i = 0; i < nw; i += 8) { \
MUL64(th, tl, le64_to_cpup((mp)+i)+(kp)[i], \
le64_to_cpup((mp)+i+1)+(kp)[i+1]); \
ADD128(rh, rl, th, tl); \
MUL64(th, tl, le64_to_cpup((mp)+i+2)+(kp)[i+2], \
le64_to_cpup((mp)+i+3)+(kp)[i+3]); \
ADD128(rh, rl, th, tl); \
MUL64(th, tl, le64_to_cpup((mp)+i+4)+(kp)[i+4], \
le64_to_cpup((mp)+i+5)+(kp)[i+5]); \
ADD128(rh, rl, th, tl); \
MUL64(th, tl, le64_to_cpup((mp)+i+6)+(kp)[i+6], \
le64_to_cpup((mp)+i+7)+(kp)[i+7]); \
ADD128(rh, rl, th, tl); \
} \
} while (0)
#define nh_vmac_nhbytes_2(mp, kp, nw, rh, rl, rh1, rl1) \
do { \
int i; u64 th, tl; \
rh1 = rl1 = rh = rl = 0; \
for (i = 0; i < nw; i += 8) { \
MUL64(th, tl, le64_to_cpup((mp)+i)+(kp)[i], \
le64_to_cpup((mp)+i+1)+(kp)[i+1]); \
ADD128(rh, rl, th, tl); \
MUL64(th, tl, le64_to_cpup((mp)+i)+(kp)[i+2], \
le64_to_cpup((mp)+i+1)+(kp)[i+3]); \
ADD128(rh1, rl1, th, tl); \
MUL64(th, tl, le64_to_cpup((mp)+i+2)+(kp)[i+2], \
le64_to_cpup((mp)+i+3)+(kp)[i+3]); \
ADD128(rh, rl, th, tl); \
MUL64(th, tl, le64_to_cpup((mp)+i+2)+(kp)[i+4], \
le64_to_cpup((mp)+i+3)+(kp)[i+5]); \
ADD128(rh1, rl1, th, tl); \
MUL64(th, tl, le64_to_cpup((mp)+i+4)+(kp)[i+4], \
le64_to_cpup((mp)+i+5)+(kp)[i+5]); \
ADD128(rh, rl, th, tl); \
MUL64(th, tl, le64_to_cpup((mp)+i+4)+(kp)[i+6], \
le64_to_cpup((mp)+i+5)+(kp)[i+7]); \
ADD128(rh1, rl1, th, tl); \
MUL64(th, tl, le64_to_cpup((mp)+i+6)+(kp)[i+6], \
le64_to_cpup((mp)+i+7)+(kp)[i+7]); \
ADD128(rh, rl, th, tl); \
MUL64(th, tl, le64_to_cpup((mp)+i+6)+(kp)[i+8], \
le64_to_cpup((mp)+i+7)+(kp)[i+9]); \
ADD128(rh1, rl1, th, tl); \
} \
} while (0)
#endif
#define poly_step(ah, al, kh, kl, mh, ml) \
do { \
u64 t1h, t1l, t2h, t2l, t3h, t3l, z = 0; \
/* compute ab*cd, put bd into result registers */ \
PMUL64(t3h, t3l, al, kh); \
PMUL64(t2h, t2l, ah, kl); \
PMUL64(t1h, t1l, ah, 2*kh); \
PMUL64(ah, al, al, kl); \
/* add 2 * ac to result */ \
ADD128(ah, al, t1h, t1l); \
/* add together ad + bc */ \
ADD128(t2h, t2l, t3h, t3l); \
/* now (ah,al), (t2l,2*t2h) need summing */ \
/* first add the high registers, carrying into t2h */ \
ADD128(t2h, ah, z, t2l); \
/* double t2h and add top bit of ah */ \
t2h = 2 * t2h + (ah >> 63); \
ah &= m63; \
/* now add the low registers */ \
ADD128(ah, al, mh, ml); \
ADD128(ah, al, z, t2h); \
} while (0)
#else /* ! CONFIG_64BIT */
#ifndef nh_16
#define nh_16(mp, kp, nw, rh, rl) \
do { \
u64 t1, t2, m1, m2, t; \
int i; \
rh = rl = t = 0; \
for (i = 0; i < nw; i += 2) { \
t1 = le64_to_cpup(mp+i) + kp[i]; \
t2 = le64_to_cpup(mp+i+1) + kp[i+1]; \
m2 = MUL32(t1 >> 32, t2); \
m1 = MUL32(t1, t2 >> 32); \
ADD128(rh, rl, MUL32(t1 >> 32, t2 >> 32), \
MUL32(t1, t2)); \
rh += (u64)(u32)(m1 >> 32) \
+ (u32)(m2 >> 32); \
t += (u64)(u32)m1 + (u32)m2; \
} \
ADD128(rh, rl, (t >> 32), (t << 32)); \
} while (0)
#endif
static void poly_step_func(u64 *ahi, u64 *alo,
const u64 *kh, const u64 *kl,
const u64 *mh, const u64 *ml)
{
#define a0 (*(((u32 *)alo)+INDEX_LOW))
#define a1 (*(((u32 *)alo)+INDEX_HIGH))
#define a2 (*(((u32 *)ahi)+INDEX_LOW))
#define a3 (*(((u32 *)ahi)+INDEX_HIGH))
#define k0 (*(((u32 *)kl)+INDEX_LOW))
#define k1 (*(((u32 *)kl)+INDEX_HIGH))
#define k2 (*(((u32 *)kh)+INDEX_LOW))
#define k3 (*(((u32 *)kh)+INDEX_HIGH))
u64 p, q, t;
u32 t2;
p = MUL32(a3, k3);
p += p;
p += *(u64 *)mh;
p += MUL32(a0, k2);
p += MUL32(a1, k1);
p += MUL32(a2, k0);
t = (u32)(p);
p >>= 32;
p += MUL32(a0, k3);
p += MUL32(a1, k2);
p += MUL32(a2, k1);
p += MUL32(a3, k0);
t |= ((u64)((u32)p & 0x7fffffff)) << 32;
p >>= 31;
p += (u64)(((u32 *)ml)[INDEX_LOW]);
p += MUL32(a0, k0);
q = MUL32(a1, k3);
q += MUL32(a2, k2);
q += MUL32(a3, k1);
q += q;
p += q;
t2 = (u32)(p);
p >>= 32;
p += (u64)(((u32 *)ml)[INDEX_HIGH]);
p += MUL32(a0, k1);
p += MUL32(a1, k0);
q = MUL32(a2, k3);
q += MUL32(a3, k2);
q += q;
p += q;
*(u64 *)(alo) = (p << 32) | t2;
p >>= 32;
*(u64 *)(ahi) = p + t;
#undef a0
#undef a1
#undef a2
#undef a3
#undef k0
#undef k1
#undef k2
#undef k3
}
#define poly_step(ah, al, kh, kl, mh, ml) \
poly_step_func(&(ah), &(al), &(kh), &(kl), &(mh), &(ml))
#endif /* end of specialized NH and poly definitions */
/* At least nh_16 is defined. Defined others as needed here */
#ifndef nh_16_2
#define nh_16_2(mp, kp, nw, rh, rl, rh2, rl2) \
do { \
nh_16(mp, kp, nw, rh, rl); \
nh_16(mp, ((kp)+2), nw, rh2, rl2); \
} while (0)
#endif
#ifndef nh_vmac_nhbytes
#define nh_vmac_nhbytes(mp, kp, nw, rh, rl) \
nh_16(mp, kp, nw, rh, rl)
#endif
#ifndef nh_vmac_nhbytes_2
#define nh_vmac_nhbytes_2(mp, kp, nw, rh, rl, rh2, rl2) \
do { \
nh_vmac_nhbytes(mp, kp, nw, rh, rl); \
nh_vmac_nhbytes(mp, ((kp)+2), nw, rh2, rl2); \
} while (0)
#endif
static void vhash_abort(struct vmac_ctx *ctx)
{
ctx->polytmp[0] = ctx->polykey[0] ;
ctx->polytmp[1] = ctx->polykey[1] ;
ctx->first_block_processed = 0;
}
static u64 l3hash(u64 p1, u64 p2,
u64 k1, u64 k2, u64 len)
{
u64 rh, rl, t, z = 0;
/* fully reduce (p1,p2)+(len,0) mod p127 */
t = p1 >> 63;
p1 &= m63;
ADD128(p1, p2, len, t);
/* At this point, (p1,p2) is at most 2^127+(len<<64) */
t = (p1 > m63) + ((p1 == m63) && (p2 == m64));
ADD128(p1, p2, z, t);
p1 &= m63;
/* compute (p1,p2)/(2^64-2^32) and (p1,p2)%(2^64-2^32) */
t = p1 + (p2 >> 32);
t += (t >> 32);
t += (u32)t > 0xfffffffeu;
p1 += (t >> 32);
p2 += (p1 << 32);
/* compute (p1+k1)%p64 and (p2+k2)%p64 */
p1 += k1;
p1 += (0 - (p1 < k1)) & 257;
p2 += k2;
p2 += (0 - (p2 < k2)) & 257;
/* compute (p1+k1)*(p2+k2)%p64 */
MUL64(rh, rl, p1, p2);
t = rh >> 56;
ADD128(t, rl, z, rh);
rh <<= 8;
ADD128(t, rl, z, rh);
t += t << 8;
rl += t;
rl += (0 - (rl < t)) & 257;
rl += (0 - (rl > p64-1)) & 257;
return rl;
}
static void vhash_update(const unsigned char *m,
unsigned int mbytes, /* Pos multiple of VMAC_NHBYTES */
struct vmac_ctx *ctx)
{
u64 rh, rl, *mptr;
const u64 *kptr = (u64 *)ctx->nhkey;
int i;
u64 ch, cl;
u64 pkh = ctx->polykey[0];
u64 pkl = ctx->polykey[1];
mptr = (u64 *)m;
i = mbytes / VMAC_NHBYTES; /* Must be non-zero */
ch = ctx->polytmp[0];
cl = ctx->polytmp[1];
if (!ctx->first_block_processed) {
ctx->first_block_processed = 1;
nh_vmac_nhbytes(mptr, kptr, VMAC_NHBYTES/8, rh, rl);
rh &= m62;
ADD128(ch, cl, rh, rl);
mptr += (VMAC_NHBYTES/sizeof(u64));
i--;
}
while (i--) {
nh_vmac_nhbytes(mptr, kptr, VMAC_NHBYTES/8, rh, rl);
rh &= m62;
poly_step(ch, cl, pkh, pkl, rh, rl);
mptr += (VMAC_NHBYTES/sizeof(u64));
}
ctx->polytmp[0] = ch;
ctx->polytmp[1] = cl;
}
static u64 vhash(unsigned char m[], unsigned int mbytes,
u64 *tagl, struct vmac_ctx *ctx)
{
u64 rh, rl, *mptr;
const u64 *kptr = (u64 *)ctx->nhkey;
int i, remaining;
u64 ch, cl;
u64 pkh = ctx->polykey[0];
u64 pkl = ctx->polykey[1];
mptr = (u64 *)m;
i = mbytes / VMAC_NHBYTES;
remaining = mbytes % VMAC_NHBYTES;
if (ctx->first_block_processed) {
ch = ctx->polytmp[0];
cl = ctx->polytmp[1];
} else if (i) {
nh_vmac_nhbytes(mptr, kptr, VMAC_NHBYTES/8, ch, cl);
ch &= m62;
ADD128(ch, cl, pkh, pkl);
mptr += (VMAC_NHBYTES/sizeof(u64));
i--;
} else if (remaining) {
nh_16(mptr, kptr, 2*((remaining+15)/16), ch, cl);
ch &= m62;
ADD128(ch, cl, pkh, pkl);
mptr += (VMAC_NHBYTES/sizeof(u64));
goto do_l3;
} else {/* Empty String */
ch = pkh; cl = pkl;
goto do_l3;
}
while (i--) {
nh_vmac_nhbytes(mptr, kptr, VMAC_NHBYTES/8, rh, rl);
rh &= m62;
poly_step(ch, cl, pkh, pkl, rh, rl);
mptr += (VMAC_NHBYTES/sizeof(u64));
}
if (remaining) {
nh_16(mptr, kptr, 2*((remaining+15)/16), rh, rl);
rh &= m62;
poly_step(ch, cl, pkh, pkl, rh, rl);
}
do_l3:
vhash_abort(ctx);
remaining *= 8;
return l3hash(ch, cl, ctx->l3key[0], ctx->l3key[1], remaining);
}
static u64 vmac(unsigned char m[], unsigned int mbytes,
unsigned char n[16], u64 *tagl,
struct vmac_ctx_t *ctx)
{
u64 *in_n, *out_p;
u64 p, h;
int i;
in_n = ctx->__vmac_ctx.cached_nonce;
out_p = ctx->__vmac_ctx.cached_aes;
i = n[15] & 1;
if ((*(u64 *)(n+8) != in_n[1]) || (*(u64 *)(n) != in_n[0])) {
in_n[0] = *(u64 *)(n);
in_n[1] = *(u64 *)(n+8);
((unsigned char *)in_n)[15] &= 0xFE;
crypto_cipher_encrypt_one(ctx->child,
(unsigned char *)out_p, (unsigned char *)in_n);
((unsigned char *)in_n)[15] |= (unsigned char)(1-i);
}
p = be64_to_cpup(out_p + i);
h = vhash(m, mbytes, (u64 *)0, &ctx->__vmac_ctx);
return p + h;
}
static int vmac_set_key(unsigned char user_key[], struct vmac_ctx_t *ctx)
{
u64 in[2] = {0}, out[2];
unsigned i;
int err = 0;
err = crypto_cipher_setkey(ctx->child, user_key, VMAC_KEY_LEN);
if (err)
return err;
/* Fill nh key */
((unsigned char *)in)[0] = 0x80;
for (i = 0; i < sizeof(ctx->__vmac_ctx.nhkey)/8; i += 2) {
crypto_cipher_encrypt_one(ctx->child,
(unsigned char *)out, (unsigned char *)in);
ctx->__vmac_ctx.nhkey[i] = be64_to_cpup(out);
ctx->__vmac_ctx.nhkey[i+1] = be64_to_cpup(out+1);
((unsigned char *)in)[15] += 1;
}
/* Fill poly key */
((unsigned char *)in)[0] = 0xC0;
in[1] = 0;
for (i = 0; i < sizeof(ctx->__vmac_ctx.polykey)/8; i += 2) {
crypto_cipher_encrypt_one(ctx->child,
(unsigned char *)out, (unsigned char *)in);
ctx->__vmac_ctx.polytmp[i] =
ctx->__vmac_ctx.polykey[i] =
be64_to_cpup(out) & mpoly;
ctx->__vmac_ctx.polytmp[i+1] =
ctx->__vmac_ctx.polykey[i+1] =
be64_to_cpup(out+1) & mpoly;
((unsigned char *)in)[15] += 1;
}
/* Fill ip key */
((unsigned char *)in)[0] = 0xE0;
in[1] = 0;
for (i = 0; i < sizeof(ctx->__vmac_ctx.l3key)/8; i += 2) {
do {
crypto_cipher_encrypt_one(ctx->child,
(unsigned char *)out, (unsigned char *)in);
ctx->__vmac_ctx.l3key[i] = be64_to_cpup(out);
ctx->__vmac_ctx.l3key[i+1] = be64_to_cpup(out+1);
((unsigned char *)in)[15] += 1;
} while (ctx->__vmac_ctx.l3key[i] >= p64
|| ctx->__vmac_ctx.l3key[i+1] >= p64);
}
/* Invalidate nonce/aes cache and reset other elements */
ctx->__vmac_ctx.cached_nonce[0] = (u64)-1; /* Ensure illegal nonce */
ctx->__vmac_ctx.cached_nonce[1] = (u64)0; /* Ensure illegal nonce */
ctx->__vmac_ctx.first_block_processed = 0;
return err;
}
static int vmac_setkey(struct crypto_shash *parent,
const u8 *key, unsigned int keylen)
{
struct vmac_ctx_t *ctx = crypto_shash_ctx(parent);
if (keylen != VMAC_KEY_LEN) {
crypto_shash_set_flags(parent, CRYPTO_TFM_RES_BAD_KEY_LEN);
return -EINVAL;
}
return vmac_set_key((u8 *)key, ctx);
}
static int vmac_init(struct shash_desc *pdesc)
{
struct crypto_shash *parent = pdesc->tfm;
struct vmac_ctx_t *ctx = crypto_shash_ctx(parent);
memset(&ctx->__vmac_ctx, 0, sizeof(struct vmac_ctx));
return 0;
}
static int vmac_update(struct shash_desc *pdesc, const u8 *p,
unsigned int len)
{
struct crypto_shash *parent = pdesc->tfm;
struct vmac_ctx_t *ctx = crypto_shash_ctx(parent);
vhash_update(p, len, &ctx->__vmac_ctx);
return 0;
}
static int vmac_final(struct shash_desc *pdesc, u8 *out)
{
struct crypto_shash *parent = pdesc->tfm;
struct vmac_ctx_t *ctx = crypto_shash_ctx(parent);
vmac_t mac;
u8 nonce[16] = {};
mac = vmac(NULL, 0, nonce, NULL, ctx);
memcpy(out, &mac, sizeof(vmac_t));
memset(&mac, 0, sizeof(vmac_t));
memset(&ctx->__vmac_ctx, 0, sizeof(struct vmac_ctx));
return 0;
}
static int vmac_init_tfm(struct crypto_tfm *tfm)
{
struct crypto_cipher *cipher;
struct crypto_instance *inst = (void *)tfm->__crt_alg;
struct crypto_spawn *spawn = crypto_instance_ctx(inst);
struct vmac_ctx_t *ctx = crypto_tfm_ctx(tfm);
cipher = crypto_spawn_cipher(spawn);
if (IS_ERR(cipher))
return PTR_ERR(cipher);
ctx->child = cipher;
return 0;
}
static void vmac_exit_tfm(struct crypto_tfm *tfm)
{
struct vmac_ctx_t *ctx = crypto_tfm_ctx(tfm);
crypto_free_cipher(ctx->child);
}
static int vmac_create(struct crypto_template *tmpl, struct rtattr **tb)
{
struct shash_instance *inst;
struct crypto_alg *alg;
int err;
err = crypto_check_attr_type(tb, CRYPTO_ALG_TYPE_SHASH);
if (err)
return err;
alg = crypto_get_attr_alg(tb, CRYPTO_ALG_TYPE_CIPHER,
CRYPTO_ALG_TYPE_MASK);
if (IS_ERR(alg))
return PTR_ERR(alg);
inst = shash_alloc_instance("vmac", alg);
err = PTR_ERR(inst);
if (IS_ERR(inst))
goto out_put_alg;
err = crypto_init_spawn(shash_instance_ctx(inst), alg,
shash_crypto_instance(inst),
CRYPTO_ALG_TYPE_MASK);
if (err)
goto out_free_inst;
inst->alg.base.cra_priority = alg->cra_priority;
inst->alg.base.cra_blocksize = alg->cra_blocksize;
inst->alg.base.cra_alignmask = alg->cra_alignmask;
inst->alg.digestsize = sizeof(vmac_t);
inst->alg.base.cra_ctxsize = sizeof(struct vmac_ctx_t);
inst->alg.base.cra_init = vmac_init_tfm;
inst->alg.base.cra_exit = vmac_exit_tfm;
inst->alg.init = vmac_init;
inst->alg.update = vmac_update;
inst->alg.final = vmac_final;
inst->alg.setkey = vmac_setkey;
err = shash_register_instance(tmpl, inst);
if (err) {
out_free_inst:
shash_free_instance(shash_crypto_instance(inst));
}
out_put_alg:
crypto_mod_put(alg);
return err;
}
static struct crypto_template vmac_tmpl = {
.name = "vmac",
.create = vmac_create,
.free = shash_free_instance,
.module = THIS_MODULE,
};
static int __init vmac_module_init(void)
{
return crypto_register_template(&vmac_tmpl);
}
static void __exit vmac_module_exit(void)
{
crypto_unregister_template(&vmac_tmpl);
}
module_init(vmac_module_init);
module_exit(vmac_module_exit);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("VMAC hash algorithm");
| {
"pile_set_name": "Github"
} |
<map id="Source/CPTPlotSymbol.m" name="Source/CPTPlotSymbol.m">
<area shape="rect" id="node2" href="$_c_p_t_plot_symbol_8h.html" title="CPTPlotSymbol.h" alt="" coords="4,86,133,117"/>
<area shape="rect" id="node3" href="$_c_p_t_definitions_8h.html" title="CPTDefinitions.h" alt="" coords="159,86,287,117"/>
<area shape="rect" id="node6" href="$_c_p_t_fill_8h.html" title="CPTFill.h" alt="" coords="311,86,387,117"/>
<area shape="rect" id="node7" href="$_c_p_t_line_style_8h.html" title="CPTLineStyle.h" alt="" coords="412,86,527,117"/>
<area shape="rect" id="node8" href="$_c_p_t_shadow_8h.html" title="CPTShadow.h" alt="" coords="551,86,659,117"/>
<area shape="rect" id="node9" href="$_n_s_coder_extensions_8h.html" title="NSCoderExtensions.h" alt="" coords="684,86,841,117"/>
</map>
| {
"pile_set_name": "Github"
} |
from numpy.testing import TestCase, run_module_suite, assert_allclose
from scipy.linalg import cython_lapack as cython_lapack
from scipy.linalg import lapack
class test_lamch(TestCase):
def test_slamch(self):
for c in [b'e', b's', b'b', b'p', b'n', b'r', b'm', b'u', b'l', b'o']:
assert_allclose(cython_lapack._test_slamch(c),
lapack.slamch(c))
def test_dlamch(self):
for c in [b'e', b's', b'b', b'p', b'n', b'r', b'm', b'u', b'l', b'o']:
assert_allclose(cython_lapack._test_dlamch(c),
lapack.dlamch(c))
if __name__ == "__main__":
run_module_suite()
| {
"pile_set_name": "Github"
} |
package org.develnext.jphp.zend.ext.json;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonParseException;
import com.google.gson.JsonSyntaxException;
import org.develnext.jphp.json.gson.MemoryDeserializer;
import org.develnext.jphp.json.gson.MemorySerializer;
import php.runtime.Memory;
import php.runtime.env.Environment;
import php.runtime.ext.support.compile.FunctionsContainer;
import php.runtime.memory.StringMemory;
import static php.runtime.annotation.Runtime.Immutable;
public class JsonFunctions extends FunctionsContainer {
public static Memory json_decode(Environment env, String json, boolean assoc, int depth) {
MemoryDeserializer memoryDeserializer = new MemoryDeserializer();
memoryDeserializer.setEnv(env);
GsonBuilder gsonBuilder = JsonExtension.createGsonBuilderForDecode(memoryDeserializer);
memoryDeserializer.setAssoc(assoc);
memoryDeserializer.setMaxDepth(depth);
Gson gson = gsonBuilder.create();
try {
env.setUserValue(JsonFunctions.class.getName() + "#error", null);
Memory r = gson.fromJson(json, Memory.class);
if (r == null)
return Memory.NULL;
else
return assoc ? r.toImmutable() : r;
} catch (MemoryDeserializer.MaxDepthException e) {
env.setUserValue(JsonFunctions.class.getName() + "#error", JsonConstants.JSON_ERROR_DEPTH);
} catch (JsonSyntaxException e) {
env.setUserValue(JsonFunctions.class.getName() + "#error", JsonConstants.JSON_ERROR_SYNTAX);
} catch (JsonParseException e) {
env.setUserValue(JsonFunctions.class.getName() + "#error", JsonConstants.JSON_ERROR_STATE_MISMATCH);
}
return Memory.NULL;
}
public static Memory json_decode(Environment env, String json, boolean assoc) {
return json_decode(env, json, assoc, 512);
}
public static int json_last_error(Environment env) {
Integer error = env.getUserValue(JsonFunctions.class.getName() + "#error", Integer.class);
if (error == null)
return JsonConstants.JSON_ERROR_NONE;
return error;
}
public static Memory json_last_error_msg(Environment env) {
switch (json_last_error(env)) {
case JsonConstants.JSON_ERROR_NONE: return Memory.NULL;
case JsonConstants.JSON_ERROR_DEPTH: return new StringMemory("Maximum stack depth exceeded");
case JsonConstants.JSON_ERROR_STATE_MISMATCH: return new StringMemory("Underflow or the modes mismatch");
case JsonConstants.JSON_ERROR_SYNTAX: return new StringMemory("Syntax error, malformed JSON");
case JsonConstants.JSON_ERROR_UTF8: return new StringMemory("Malformed UTF-8 characters, possibly incorrectly encoded");
case JsonConstants.JSON_ERROR_CTRL_CHAR: return new StringMemory("Unexpected control character found");
default:
return Memory.NULL;
}
}
public static Memory json_decode(Environment env, String json) {
return json_decode(env, json, false);
}
@Immutable
public static String json_encode(Memory memory, int options) {
GsonBuilder builder;
if (options != 0) {
MemorySerializer serializer = new MemorySerializer();
builder = JsonExtension.createGsonBuilder(serializer);
if ((options & JsonConstants.JSON_PRETTY_PRINT) == JsonConstants.JSON_PRETTY_PRINT) {
builder.setPrettyPrinting();
}
if ((options & JsonConstants.JSON_HEX_TAG) != JsonConstants.JSON_HEX_TAG) {
builder.disableHtmlEscaping();
}
if ((options & JsonConstants.JSON_FORCE_OBJECT) == JsonConstants.JSON_FORCE_OBJECT) {
serializer.setForceObject(true);
}
if ((options & JsonConstants.JSON_NUMERIC_CHECK) == JsonConstants.JSON_NUMERIC_CHECK) {
serializer.setNumericCheck(true);
}
if ((options & JsonConstants.JSON_UNESCAPED_UNICODE) == JsonConstants.JSON_UNESCAPED_UNICODE) {
serializer.unescapedUnicode(true);
}
} else {
builder = JsonExtension.DEFAULT_GSON_BUILDER;
}
Gson gson = builder.create();
return gson.toJson(memory);
}
@Immutable
public static String json_encode(Memory memory) {
return json_encode(memory, 0);
}
}
| {
"pile_set_name": "Github"
} |
{
"ids": {
"Note": 3
},
"models": {
"Note": {
"1": "{\"title\":\"Things I need to buy\",\"content\":\"milk, cereal, and waffles\",\"id\":1}",
"2": "{\"title\":\"Great frameworks\",\"content\":\"LoopBack is a great framework\",\"id\":2}"
}
}
}
| {
"pile_set_name": "Github"
} |
<!DOCTYPE html>
<html>
<head>
<title>mapEntries</title>
<link rel="stylesheet" href="prism.css">
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="header">
<div class="doc-title"><a href="folktale.html"><span class="doc-title"><span class="product-name">Folktale</span><span class="version">v2.3.0</span></span></a><ul class="navigation"><li class="navigation-item"><a href="https://github.com/origamitower/folktale" title="">GitHub</a></li><li class="navigation-item"><a href="/docs/support/" title="">Support</a></li><li class="navigation-item"><a href="/docs/v2.3.0/contributing/" title="">Contributing</a></li></ul></div>
</div>
<div id="content-wrapper"><div id="content-panel"><h1 class="entity-title">mapEntries</h1><div class="highlight-summary"><div><p>Transforms own properties of an object using a mapping function.</p>
</div></div><div class="definition"><h2 class="section-title" id="signature">Signature</h2><div class="signature">mapEntries(object, transform, define)</div><div class="type-definition"><div class="type-definition-container"><div class="type-title-container"><strong class="type-title">Type</strong><a class="info" href="/docs/v2.3.0/misc/type-notation/">(what is this?)</a></div><pre class="type"><code class="language-haskell">(
object : Object 'a,
transform : ((String, 'a)) => (String, 'b),
define : (('x : Object 'b), String, 'b) => Object 'b :: mutates 'x
) => Object 'b</code></pre></div></div></div><h2 class="section-title">Documentation</h2><div class="documentation"><div><p>Transforms own properties of an object using a mapping function.</p>
<p>The transformation takes a <code>[key, value]</code> pair, and is expected to return
a new <code>[key, value]</code> pair. The resulting object has not only its values
transformed, but also its keys.</p>
<h2 id="example-">Example:</h2>
<pre><code>const mapEntries = require('folktale/core/object/map-entries');
const pair = { x: 10, y: 20 };
mapEntries(
pair,
([key, value]) => [key.toUpperCase(), value * 2],
(result, key, value) => {
result[key] = value;
return result;
}
);
// ==> { X: 20, Y: 40 }
</code></pre><h2 id="handling-collisions">Handling collisions</h2>
<p>Since the mapping function returns a <code>[key, value]</code> pair, it's possible
that some of the returned keys collide with another. Since there's no
single answer that is correct for all cases when handling these collisions,
mapEntries expects an additional function that's used to define the
properties in the resulting object, and this function is expected to
deal with the collisions.</p>
<p>A definition function takes the result object, a property name, and
a value, and is expected to return a new object containing the provided
key/value pair, if it can be attached to the result object. This function
may mutate the object, but pure functions are also supported.</p>
<p>Specialised forms of this function exist to cover common cases.
<code>mapEntries.overwrite</code> will have later key/value pairs overwrite earlier
ones with the same key, while <code>mapEntries.unique</code> will throw whenever
a collision happens.</p>
<h2 id="caveats">Caveats</h2>
<p><code>mapEntries</code> will not preserve the shape of the original object.
It treats objects as plain maps from String to some value. It ignores
things like prototypical delegation, symbols, and non-enumerable
properties.</p>
</div></div><div class="members"><h2 class="section-title" id="properties">Properties</h2><div class="member-category"><h3 class="category" id="cat-convenience">Convenience</h3><div class="member-list"><div class="member"><a class="member-name" href="folktale.core.object.map-entries.overwrite.html">overwrite(object, transform)</a><div class="doc-summary"><div><p>Transforms own properties of an object using a mapping function.</p>
</div></div><div class="special-tags"></div></div><div class="member"><a class="member-name" href="folktale.core.object.map-entries.unique.html">unique(object, transform)</a><div class="doc-summary"><div><p>Transforms own properties of an object using a mapping function.</p>
</div></div><div class="special-tags"></div></div></div></div></div><div class="source-code"><h2 class="section-title" id="source-code">Source Code</h2><div class="source-location">Defined in source/core/object/map-entries.js at line 25, column 0</div><pre class="source-code"><code class="language-javascript">(object, transform, define) =>
Object.keys(object).reduce((result, key) => {
const [newKey, newValue] = transform([key, object[key]]);
return define(result, newKey, newValue);
}, {})</code></pre></div></div><div id="meta-panel"><div class="meta-section"><div class="meta-field"><strong class="meta-field-title">Stability</strong><div class="meta-field-value">stable</div></div><div class="meta-field"><strong class="meta-field-title">Licence</strong><div class="meta-field-value">MIT</div></div><div class="meta-field"><strong class="meta-field-title">Module</strong><div class="meta-field-value">folktale/core/object/map-entries</div></div></div><div class="table-of-contents"><div class="meta-section-title">On This Page</div><ul class="toc-list level-1"><li class="toc-item"><a href="#signature">Signature</a></li><li class="toc-item"><span class="no-anchor">Documentation</span><ul class="toc-list level-2"><li class="toc-item"><a href="#example-" title="Example:"><div><p>Example:</p>
</div></a></li><li class="toc-item"><a href="#handling-collisions" title="Handling collisions"><div><p>Handling collisions</p>
</div></a></li><li class="toc-item"><a href="#caveats" title="Caveats"><div><p>Caveats</p>
</div></a></li></ul></li><li class="toc-item"><a href="#properties">Properties</a><ul class="toc-list level-2"><li class="toc-item"><a href="#cat-convenience">Convenience</a></li></ul></li><li class="toc-item"><a href="#source-code">Source Code</a></li></ul></div><div class="meta-section"><strong class="meta-section-title">Authors</strong><div class="meta-field"><strong class="meta-field-title">Copyright</strong><div class="meta-field-value">(c) 2013-2017 Quildreen Motta, and CONTRIBUTORS</div></div><div class="meta-field"><strong class="meta-field-title">Authors</strong><div class="meta-field-value"><ul class="meta-list"><li>Quildreen Motta</li></ul></div></div><div class="meta-field"><strong class="meta-field-title">Maintainers</strong><div class="meta-field-value"><ul class="meta-list"><li>Quildreen Motta <[email protected]> (http://robotlolita.me/)</li></ul></div></div></div></div></div>
<script>
void function() {
var xs = document.querySelectorAll('.documentation pre code');
for (var i = 0; i < xs.length; ++i) {
xs[i].className = 'language-javascript code-block';
}
}()
</script>
<script src="prism.js"></script>
</body>
</html> | {
"pile_set_name": "Github"
} |
/*
* Copyright 2018 Analytics Zoo 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.
*/
package com.intel.analytics.zoo.models.image.objectdetection.common
import com.intel.analytics.bigdl.tensor.TensorNumericMath.TensorNumeric
import com.intel.analytics.bigdl.tensor.{Storage, Tensor}
import com.intel.analytics.bigdl.transform.vision.image.label.roi.RoiLabel
import com.intel.analytics.bigdl.transform.vision.image.util.BoundingBox
import org.apache.log4j.Logger
import scala.reflect.ClassTag
object BboxUtil {
/**
* Select tensor from matrix
*
* @param matrix source matrix
* @param indices indices array
* @param dim dimension
* @param indiceLen indice length
* @param out based tensor
* @return selected tensor
*/
def selectTensor(matrix: Tensor[Float], indices: Array[Int], dim: Int, indiceLen: Int = -1,
out: Tensor[Float] = null): Tensor[Float] = {
assert(dim == 1 || dim == 2)
var i = 1
val n = if (indiceLen == -1) indices.length else indiceLen
if (matrix.nDimension() == 1) {
val res = if (out == null) {
Tensor[Float](n)
} else {
out.resize(n)
}
while (i <= n) {
res.update(i, matrix.valueAt(indices(i - 1)))
i += 1
}
return res
}
// select rows
if (dim == 1) {
val res = if (out == null) {
Tensor[Float](n, matrix.size(2))
} else {
out.resize(n, matrix.size(2))
}
while (i <= n) {
res.update(i, matrix(indices(i - 1)))
i += 1
}
res
} else {
val res = if (out == null) {
Tensor[Float](matrix.size(1), n)
} else {
out.resize(matrix.size(1), n)
}
while (i <= n) {
var rid = 1
val value = matrix.select(2, indices(i - 1))
while (rid <= res.size(1)) {
res.setValue(rid, i, value.valueAt(rid))
rid += 1
}
i += 1
}
res
}
}
/**
* return the max value in rows(d=0) or in cols(d=1)
* arr = [4 9
* 5 7
* 8 5]
*
* argmax2(arr, 1) will return 3, 1
* argmax2(arr, 2) will return 2, 2, 1
*
* @return
* todo: this maybe removed
*/
def argmax2(arr: Tensor[Float], d: Int): Array[Int] = {
require(d >= 1)
arr.max(d)._2.storage().array().map(x => x.toInt)
}
/**
* Bounding-box regression targets (bboxTargetData) are stored in a
* compact form N x (class, tx, ty, tw, th)
* *
* This function expands those targets into the 4-of-4*K representation used
* by the network (i.e. only one class has non-zero targets).
* *
* Returns:
* bbox_target (ndarray): N x 4K blob of regression targets
* bbox_inside_weights (ndarray): N x 4K blob of loss weights
*
*/
def getBboxRegressionLabels(bboxTargetData: Tensor[Float],
numClasses: Int): (Tensor[Float], Tensor[Float]) = {
// Deprecated (inside weights)
val BBOX_INSIDE_WEIGHTS = Tensor(Storage(Array(1.0f, 1.0f, 1.0f, 1.0f)))
val bboxTargets = Tensor[Float](bboxTargetData.size(1), 4 * numClasses)
val bboxInsideWeights = Tensor[Float]().resizeAs(bboxTargets)
(1 to bboxTargetData.size(1)).foreach(ind => {
val cls = bboxTargetData.valueAt(ind, 1)
if (cls > 1) {
require(cls <= numClasses, s"$cls is not in range [1, $numClasses]")
val start = (4 * (cls - 1)).toInt
(2 to bboxTargetData.size(2)).foreach(x => {
bboxTargets.setValue(ind, x + start - 1, bboxTargetData.valueAt(ind, x))
bboxInsideWeights.setValue(ind, x + start - 1,
BBOX_INSIDE_WEIGHTS.valueAt(x - 1))
})
}
})
(bboxTargets, bboxInsideWeights)
}
/**
* Concat multiple 2D tensors vertically
*
* @param tensors tensor list
* @param ev
* @tparam T
* @return
*/
def vertcat2D[T: ClassTag](tensors: Tensor[T]*)
(implicit ev: TensorNumeric[T]): Tensor[T] = {
require(tensors(0).dim() == 2, "only support 2D")
var nRows = tensors(0).size(1)
val nCols = tensors(0).size(2)
for (i <- 1 until tensors.length) {
require(tensors(i).size(2) == nCols, "the cols length must be equal")
nRows += tensors(i).size(1)
}
val resData = Tensor[T](nRows, nCols)
var id = 0
tensors.foreach { tensor =>
(1 to tensor.size(1)).foreach(rid => {
id = id + 1
resData.update(id, tensor(rid))
})
}
resData
}
/**
* Concat multiple 1D tensors vertically
*
* @param tensors
* @param ev
* @tparam T
* @return
*/
def vertcat1D[T: ClassTag](tensors: Tensor[T]*)
(implicit ev: TensorNumeric[T]): Tensor[T] = {
require(tensors(0).dim() == 1, "only support 1D")
val nCols = tensors(0).size(1)
for (i <- 1 until tensors.length) {
require(tensors(i).size(1) == nCols, "the cols length must be equal")
}
val resData = Tensor[T](tensors.size, nCols)
var id = 0
tensors.foreach { tensor =>
id = id + 1
resData.update(id, tensor)
}
resData
}
/**
* Concat multiple 2D tensors horizontally
*
* @param tensors
* @return
*/
def horzcat(tensors: Tensor[Float]*): Tensor[Float] = {
require(tensors(0).dim() == 2, "currently only support 2D")
val nRows = tensors(0).size(1)
var nCols = tensors(0).size(2)
for (i <- 1 until tensors.length) {
require(tensors(i).size(1) == nRows, "the rows length must be equal")
nCols += tensors(i).size(2)
}
val resData = Tensor[Float](nRows, nCols)
var id = 1
tensors.foreach { tensor =>
updateRange(resData, 1, nRows, id, id + tensor.size(2) - 1, tensor)
id = id + tensor.size(2)
}
resData
}
/**
* update with 2d tensor, the range must be equal to the src tensor size
*
*/
def updateRange(dest: Tensor[Float], startR: Int, endR: Int, startC: Int, endC: Int,
src: Tensor[Float]): Unit = {
assert(src.size(1) == endR - startR + 1)
assert(src.size(2) == endC - startC + 1)
(startR to endR).zip(Stream.from(1)).foreach(r => {
(startC to endC).zip(Stream.from(1)).foreach(c => {
dest.setValue(r._1, c._1, src.valueAt(r._2, c._2))
})
})
}
/**
* Get the overlap between boxes and query_boxes
*
* @param boxes (N, 4) ndarray of float
* @param queryBoxes (K, >=4) ndarray of float
* @return overlaps: (N, K) ndarray of overlap between boxes and query_boxes
*/
def bboxOverlap(boxes: Tensor[Float], queryBoxes: Tensor[Float]): Tensor[Float] = {
require(boxes.size(2) >= 4)
require(queryBoxes.size(2) >= 4)
val N = boxes.size(1)
val K = queryBoxes.size(1)
val overlaps = Tensor[Float](N, K)
for (k <- 1 to K) {
val boxArea = (queryBoxes.valueAt(k, 3) - queryBoxes.valueAt(k, 1) + 1) *
(queryBoxes.valueAt(k, 4) - queryBoxes.valueAt(k, 2) + 1)
for (n <- 1 to N) {
val iw = Math.min(boxes.valueAt(n, 3), queryBoxes.valueAt(k, 3)) -
Math.max(boxes.valueAt(n, 1), queryBoxes.valueAt(k, 1)) + 1
if (iw > 0) {
val ih = Math.min(boxes.valueAt(n, 4), queryBoxes.valueAt(k, 4)) -
Math.max(boxes.valueAt(n, 2), queryBoxes.valueAt(k, 2)) + 1
if (ih > 0) {
val ua = (boxes.valueAt(n, 3) - boxes.valueAt(n, 1) + 1) *
(boxes.valueAt(n, 4) - boxes.valueAt(n, 2) + 1) + boxArea - iw * ih
overlaps.setValue(n, k, iw * ih / ua)
}
}
}
}
overlaps
}
/**
* Select tensor from matrix
*
* @param matrix source matrix
* @param indices indices array
* @param dim dimension
* @param indiceLen indice length
* @param out based tensor
* @return selected tensor
*/
def selectMatrix(matrix: Tensor[Float], indices: Array[Int], dim: Int, indiceLen: Int = -1,
out: Tensor[Float] = null): Tensor[Float] = {
assert(dim == 1 || dim == 2)
var i = 1
val n = if (indiceLen == -1) indices.length else indiceLen
if (matrix.nDimension() == 1) {
val res = if (out == null) {
Tensor[Float](n)
} else {
out.resize(n)
}
while (i <= n) {
res.update(i, matrix.valueAt(indices(i - 1)))
i += 1
}
return res
}
// select rows
if (dim == 1) {
val res = if (out == null) {
Tensor[Float](n, matrix.size(2))
} else {
out.resize(n, matrix.size(2))
}
while (i <= n) {
res.update(i, matrix(indices(i - 1)))
i += 1
}
res
} else {
val res = if (out == null) {
Tensor[Float](matrix.size(1), n)
} else {
out.resize(matrix.size(1), n)
}
while (i <= n) {
var rid = 1
val value = matrix.select(2, indices(i - 1))
while (rid <= res.size(1)) {
res.setValue(rid, i, value.valueAt(rid))
rid += 1
}
i += 1
}
res
}
}
def bboxTransform(sampledRois: Tensor[Float], gtRois: Tensor[Float]): Tensor[Float] = {
require(sampledRois.size(1) == gtRois.size(1), "each sampledRois should have a gtRoi")
require(sampledRois.size(2) == 4)
require(gtRois.size(2) == 4)
val transformed = Tensor[Float].resizeAs(sampledRois).copy(sampledRois)
(1 to sampledRois.size(1)).foreach(i => {
val sampleWidth = sampledRois.valueAt(i, 3) - sampledRois.valueAt(i, 1) + 1.0f
val sampleHeight = sampledRois.valueAt(i, 4) - sampledRois.valueAt(i, 2) + 1.0f
val sampleCtrX = sampledRois.valueAt(i, 1) + sampleWidth * 0.5f
val sampleCtrY = sampledRois.valueAt(i, 2) + sampleHeight * 0.5f
val gtWidth = gtRois.valueAt(i, 3) - gtRois.valueAt(i, 1) + 1.0f
val gtHeight = gtRois.valueAt(i, 4) - gtRois.valueAt(i, 2) + 1.0f
val gtCtrX = gtRois.valueAt(i, 1) + gtWidth * 0.5f
val gtCtrY = gtRois.valueAt(i, 2) + gtHeight * 0.5f
// targetsDx
transformed.setValue(i, 1, (gtCtrX - sampleCtrX) / sampleWidth)
// targetsDy
transformed.setValue(i, 2, (gtCtrY - sampleCtrY) / sampleHeight)
// targetsDw
transformed.setValue(i, 3, Math.log(gtWidth / sampleWidth).toFloat)
// targetsDh
transformed.setValue(i, 4, Math.log(gtHeight / sampleHeight).toFloat)
})
transformed
}
/**
* decode batch
*/
def decodeBatchOutput(output: Tensor[Float], nClass: Int): Array[Array[RoiLabel]] = {
var i = 0
val batch = output.size(1)
val decoded = new Array[Array[RoiLabel]](batch)
while (i < batch) {
decoded(i) = decodeRois(output(i + 1), nClass)
i += 1
}
decoded
}
private def decodeRois(output: Tensor[Float], nclass: Int)
: Array[RoiLabel] = {
val result = decodeRois(output)
val indices = getClassIndices(result)
val decoded = new Array[RoiLabel](nclass)
val iter = indices.iterator
while (iter.hasNext) {
val item = iter.next()
val sub = result.narrow(1, item._2._1, item._2._2)
decoded(item._1) = RoiLabel(sub.select(2, 2),
sub.narrow(2, 3, 4))
}
decoded
}
private def decodeRois(output: Tensor[Float]): Tensor[Float] = {
val num = output.valueAt(1).toInt
require(num >= 0, "output number should >= 0")
if (num == 0) {
Tensor[Float]()
} else {
output.narrow(1, 2, num * 6).view(num, 6)
}
}
private def getClassIndices(result: Tensor[Float]): Map[Int, (Int, Int)] = {
var indices = Map[Int, (Int, Int)]()
if (result.nElement() == 0) return indices
var prev = -1f
var i = 1
var start = 1
if (result.size(1) == 1) {
indices += (result.valueAt(i, 1).toInt -> (1, 1))
return indices
}
while (i <= result.size(1)) {
if (prev != result.valueAt(i, 1)) {
if (prev >= 0) {
indices += (prev.toInt -> (start, i - start))
}
start = i
}
prev = result.valueAt(i, 1)
if (i == result.size(1)) {
indices += (prev.toInt -> (start, i - start + 1))
}
i += 1
}
indices
}
/**
* Encode BBox
*
* @param priorBox
* @param priorVariance
* @param gtBox
* @param enodeBbox
*/
def encodeBBox(priorBox: Tensor[Float], priorVariance: Tensor[Float], gtBox: Tensor[Float],
enodeBbox: Tensor[Float]): Unit = {
val px1 = priorBox.valueAt(1)
val py1 = priorBox.valueAt(2)
val px2 = priorBox.valueAt(3)
val py2 = priorBox.valueAt(4)
val prior = BoundingBox(priorBox.valueAt(1), priorBox.valueAt(2),
priorBox.valueAt(3), priorBox.valueAt(4))
val bbox = BoundingBox(gtBox.valueAt(4), gtBox.valueAt(5),
gtBox.valueAt(6), gtBox.valueAt(7))
val priorWidth = prior.width()
val priorHeight = prior.height()
val bboxWidth = bbox.width()
val bboxHeight = bbox.height()
enodeBbox.setValue(1,
(bbox.centerX() - prior.centerX()) / priorWidth / priorVariance.valueAt(1))
enodeBbox.setValue(2,
(bbox.centerY() - prior.centerY()) / priorHeight / priorVariance.valueAt(2))
enodeBbox.setValue(3, Math.log(bboxWidth / priorWidth).toFloat / priorVariance.valueAt(3))
enodeBbox.setValue(4, Math.log(bboxHeight / priorHeight).toFloat / priorVariance.valueAt(4))
}
/**
* Get groud truth indices from result
*
* @param result
* @return
*/
def getGroundTruthIndices(result: Tensor[Float]): Map[Int, (Int, Int)] = {
var indices = Map[Int, (Int, Int)]()
if (result.nElement() == 0) return indices
var prev = -1f
var i = 1
var start = 1
if (result.size(1) == 1) {
indices += (result.valueAt(i, 1).toInt -> (1, 1))
return indices
}
while (i <= result.size(1)) {
if (prev != result.valueAt(i, 1)) {
if (prev >= 0) {
indices += (prev.toInt -> (start, i - start))
}
start = i
}
prev = result.valueAt(i, 1)
if (i == result.size(1)) {
indices += (prev.toInt -> (start, i - start + 1))
}
i += 1
}
indices
}
/**
* Get ground truth from result
*
* @param result
* @return
*/
def getGroundTruths(result: Tensor[Float]): Map[Int, Tensor[Float]] = {
val indices = getGroundTruthIndices(result).toArray.sortBy(_._1)
var gtMap = Map[Int, Tensor[Float]]()
var ind = 0
val iter = indices.iterator
while (iter.hasNext) {
val x = iter.next()
val gt = result.narrow(1, x._2._1, x._2._2)
// -1 represent those images without label
if (gt.size(1) > 1 || gt.valueAt(1, 2) != -1) {
gtMap += (ind -> gt)
}
ind += 1
}
gtMap
// indices.map(x => x._1 -> result.narrow(1, x._2._1, x._2._2))
}
val logger = Logger.getLogger(getClass)
/**
* Note that the output are stored in input deltas
*
* @param boxes (N, 4)
* @param deltas (N, 4a)
* @return
*/
def bboxTransformInv(boxes: Tensor[Float], deltas: Tensor[Float]): Tensor[Float] = {
if (boxes.size(1) == 0) {
return boxes
}
val output = Tensor[Float]().resizeAs(deltas).copy(deltas)
require(boxes.size(2) == 4,
s"boxes size ${boxes.size().mkString(",")} do not satisfy N*4 size")
require(output.size(2) % 4 == 0,
s"and deltas size ${output.size().mkString(",")} do not satisfy N*4a size")
val boxesArr = boxes.storage().array()
var offset = boxes.storageOffset() - 1
val rowLength = boxes.stride(1)
val deltasArr = output.storage().array()
var i = 0
val repeat = output.size(2) / boxes.size(2)
var deltasoffset = output.storageOffset() - 1
while (i < boxes.size(1)) {
val x1 = boxesArr(offset)
val y1 = boxesArr(offset + 1)
val width = boxesArr(offset + 2) - x1 + 1
val height = boxesArr(offset + 3) - y1 + 1
var j = 0
while (j < repeat) {
j += 1
// dx1*width + centerX
val predCtrX = deltasArr(deltasoffset) * width + x1 + width / 2
// dy1*height + centerY
val predCtrY = deltasArr(deltasoffset + 1) * height + y1 + height / 2
// exp(dx2)*width/2
val predW = Math.exp(deltasArr(deltasoffset + 2)).toFloat * width / 2
// exp(dy2)*height/2
val predH = Math.exp(deltasArr(deltasoffset + 3)).toFloat * height / 2
deltasArr(deltasoffset) = predCtrX - predW
deltasArr(deltasoffset + 1) = predCtrY - predH
deltasArr(deltasoffset + 2) = predCtrX + predW
deltasArr(deltasoffset + 3) = predCtrY + predH
deltasoffset += rowLength
}
offset += rowLength
i += 1
}
output
}
/**
* Clip boxes to image boundaries.
* set the score of all boxes with any side smaller than minSize to 0
*
* @param boxes N * 4a
* @param height height of image
* @param width width of image
* @param minH min height limit
* @param minW min width limit
* @param scores scores for boxes
* @return the number of boxes kept (score > 0)
*/
def clipBoxes(boxes: Tensor[Float], height: Float, width: Float, minH: Float = 0,
minW: Float = 0, scores: Tensor[Float] = null): Int = {
require(boxes.size(2) % 4 == 0, "boxes should have the shape N*4a")
val boxesArr = boxes.storage().array()
var offset = boxes.storageOffset() - 1
val scoresArr = if (scores != null) scores.storage().array() else null
var scoreOffset = if (scores != null) scores.storageOffset() - 1 else -1
var i = 0
var count = 0
val h = height - 1
val w = width - 1
val repeat = boxes.size(2) / 4
while (i < boxes.size(1)) {
var r = 0
while (r < repeat) {
boxesArr(offset) = Math.max(Math.min(boxesArr(offset), w), 0)
boxesArr(offset + 1) = Math.max(Math.min(boxesArr(offset + 1), h), 0)
boxesArr(offset + 2) = Math.max(Math.min(boxesArr(offset + 2), w), 0)
boxesArr(offset + 3) = Math.max(Math.min(boxesArr(offset + 3), h), 0)
if (scores != null) {
val width = boxesArr(offset + 2) - boxesArr(offset) + 1
if (width < minW) {
scoresArr(scoreOffset) = 0
} else {
val height = boxesArr(offset + 3) - boxesArr(offset + 1) + 1
if (height < minH) scoresArr(scoreOffset) = 0
else count += 1
}
scoreOffset += 1
}
r += 1
offset += 4
}
i += 1
}
count
}
/**
* BBox vote result
*
* @param scoresNms N
* @param bboxNms N * 4
* @param scoresAll M
* @param bboxAll M * 4
* @return
*/
def bboxVote(scoresNms: Tensor[Float], bboxNms: Tensor[Float],
scoresAll: Tensor[Float], bboxAll: Tensor[Float],
areasBuf: Tensor[Float] = null): RoiLabel = {
var accBox: Tensor[Float] = null
var accScore = 0f
var box: Tensor[Float] = null
val areasAll = if (areasBuf == null) {
Tensor[Float]
} else areasBuf
getAreas(bboxAll, areasAll)
var i = 1
while (i <= scoresNms.size(1)) {
box = bboxNms(i)
if (accBox == null) {
accBox = Tensor[Float](4)
} else {
accBox.fill(0f)
}
accScore = 0f
var m = 1
while (m <= scoresAll.size(1)) {
val boxA = bboxAll(m)
val iw = Math.min(box.valueAt(3), boxA.valueAt(3)) -
Math.max(box.valueAt(1), boxA.valueAt(1)) + 1
val ih = Math.min(box.valueAt(4), boxA.valueAt(4)) -
Math.max(box.valueAt(2), boxA.valueAt(2)) + 1
if (iw > 0 && ih > 0) {
val ua = getArea(box) + areasAll.valueAt(m) - iw * ih
val ov = iw * ih / ua
if (ov >= 0.5) {
accBox.add(scoresAll.valueAt(m), boxA)
accScore += scoresAll.valueAt(m)
}
}
m += 1
}
var x = 1
while (x <= 4) {
bboxNms.setValue(i, x, accBox.valueAt(x) / accScore)
x += 1
}
i += 1
}
RoiLabel(scoresNms, bboxNms)
}
private def getArea(box: Tensor[Float]): Float = {
require(box.dim() == 1 && box.nElement() >= 4)
(box.valueAt(3) - box.valueAt(1) + 1) * (box.valueAt(4) - box.valueAt(2) + 1)
}
/**
* get the areas of boxes
*
* @param boxes N * 4 tensor
* @param areas buffer to store the results
* @return areas array
*/
def getAreas(boxes: Tensor[Float], areas: Tensor[Float], startInd: Int = 1,
normalized: Boolean = false): Tensor[Float] = {
if (boxes.nElement() == 0) return areas
require(boxes.size(2) >= 4)
areas.resize(boxes.size(1))
val boxesArr = boxes.storage().array()
val offset = boxes.storageOffset() - 1
val rowLength = boxes.stride(1)
var i = 0
var boffset = offset + startInd - 1
while (i < boxes.size(1)) {
val x1 = boxesArr(boffset)
val y1 = boxesArr(boffset + 1)
val x2 = boxesArr(boffset + 2)
val y2 = boxesArr(boffset + 3)
if (normalized) areas.setValue(i + 1, (x2 - x1) * (y2 - y1))
else areas.setValue(i + 1, (x2 - x1 + 1) * (y2 - y1 + 1))
boffset += rowLength
i += 1
}
areas
}
private def decodeSingleBbox(i: Int, priorBox: Tensor[Float], priorVariance: Tensor[Float],
isClipBoxes: Boolean, bbox: Tensor[Float],
varianceEncodedInTarget: Boolean,
decodedBoxes: Tensor[Float]): Unit = {
val x1 = priorBox.valueAt(i, 1)
val y1 = priorBox.valueAt(i, 2)
val x2 = priorBox.valueAt(i, 3)
val y2 = priorBox.valueAt(i, 4)
val priorWidth = x2 - x1
require(priorWidth > 0)
val priorHeight = y2 - y1
require(priorHeight > 0)
val pCenterX = (x1 + x2) / 2
val pCenterY = (y1 + y2) / 2
var decodeCenterX = 0f
var decodeCenterY = 0f
var decodeWidth = 0f
var decodedHeight = 0f
if (varianceEncodedInTarget) {
// variance is encoded in target, we simply need to retore the offset
// predictions.
decodeCenterX = bbox.valueAt(i, 1) * priorWidth + pCenterX
decodeCenterY = bbox.valueAt(i, 2) * priorHeight + pCenterY
decodeWidth = Math.exp(bbox.valueAt(i, 3)).toFloat * priorWidth
decodedHeight = Math.exp(bbox.valueAt(i, 4)).toFloat * priorHeight
} else {
// variance is encoded in bbox, we need to scale the offset accordingly.
decodeCenterX = priorVariance.valueAt(i, 1) * bbox.valueAt(i, 1) * priorWidth + pCenterX
decodeCenterY = priorVariance.valueAt(i, 2) * bbox.valueAt(i, 2) * priorHeight + pCenterY
decodeWidth = Math.exp(priorVariance.valueAt(i, 3) * bbox.valueAt(i, 3)).toFloat * priorWidth
decodedHeight = Math.exp(priorVariance.valueAt(i, 4) * bbox.valueAt(i, 4))
.toFloat * priorHeight
}
decodedBoxes.setValue(i, 1, decodeCenterX - decodeWidth / 2)
decodedBoxes.setValue(i, 2, decodeCenterY - decodedHeight / 2)
decodedBoxes.setValue(i, 3, decodeCenterX + decodeWidth / 2)
decodedBoxes.setValue(i, 4, decodeCenterY + decodedHeight / 2)
if (isClipBoxes) {
clipBoxes(decodedBoxes)
}
}
def decodeBoxes(priorBoxes: Tensor[Float], priorVariances: Tensor[Float],
isClipBoxes: Boolean, bboxes: Tensor[Float],
varianceEncodedInTarget: Boolean, output: Tensor[Float] = null): Tensor[Float] = {
require(priorBoxes.size(1) == priorVariances.size(1))
require(priorBoxes.size(1) == bboxes.size(1))
val numBboxes = priorBoxes.size(1)
if (numBboxes > 0) {
require(priorBoxes.size(2) == 4)
}
val decodedBboxes = if (output == null) Tensor[Float](numBboxes, 4)
else output.resizeAs(priorBoxes)
var i = 1
while (i <= numBboxes) {
decodeSingleBbox(i, priorBoxes,
priorVariances, isClipBoxes, bboxes, varianceEncodedInTarget, decodedBboxes)
i += 1
}
decodedBboxes
}
def clipBoxes(bboxes: Tensor[Float]): Tensor[Float] = {
bboxes.cmax(0).apply1(x => Math.min(1, x))
}
def decodeBboxesAll(allLocPreds: Array[Array[Tensor[Float]]], priorBoxes: Tensor[Float],
priorVariances: Tensor[Float], nClasses: Int, bgLabel: Int,
clipBoxes: Boolean, varianceEncodedInTarget: Boolean,
shareLocation: Boolean, output: Array[Array[Tensor[Float]]] = null)
: Array[Array[Tensor[Float]]] = {
val batch = allLocPreds.length
val allDecodeBboxes = if (output == null) {
val all = new Array[Array[Tensor[Float]]](batch)
var i = 0
while (i < batch) {
all(i) = new Array[Tensor[Float]](nClasses)
i += 1
}
all
} else {
require(output.length == batch)
output
}
var i = 0
while (i < batch) {
val decodedBoxes = allDecodeBboxes(i)
var c = 0
while (c < nClasses) {
// Ignore background class.
if (shareLocation || c != bgLabel) {
// Something bad happened if there are no predictions for current label.
if (allLocPreds(i)(c).nElement() == 0) {
logger.warn(s"Could not find location predictions for label $c")
}
val labelLocPreds = allLocPreds(i)(c)
decodedBoxes(c) = decodeBoxes(priorBoxes, priorVariances, clipBoxes,
labelLocPreds, varianceEncodedInTarget, labelLocPreds)
}
c += 1
}
allDecodeBboxes(i) = decodedBoxes
i += 1
}
allDecodeBboxes
}
/**
* Get location prediction result
*
* @param loc
* @param numPredsPerClass
* @param numClasses
* @param shareLocation
* @param locPredsBuf
* @return
*/
def getLocPredictions(loc: Tensor[Float], numPredsPerClass: Int, numClasses: Int,
shareLocation: Boolean, locPredsBuf: Array[Array[Tensor[Float]]] = null)
: Array[Array[Tensor[Float]]] = {
// the outer array is the batch, each img contains an array of results, grouped by class
val locPreds = if (locPredsBuf == null) {
val out = new Array[Array[Tensor[Float]]](loc.size(1))
var i = 0
while (i < loc.size(1)) {
out(i) = new Array[Tensor[Float]](numClasses)
var c = 0
while (c < numClasses) {
out(i)(c) = Tensor[Float](numPredsPerClass, 4)
c += 1
}
i += 1
}
out
} else {
locPredsBuf
}
var i = 0
val locData = loc.storage().array()
var locDataOffset = loc.storageOffset() - 1
while (i < loc.size(1)) {
val labelBbox = locPreds(i)
var p = 0
while (p < numPredsPerClass) {
val startInd = p * numClasses * 4 + locDataOffset
var c = 0
while (c < numClasses) {
val label = if (shareLocation) labelBbox.length - 1 else c
val boxData = labelBbox(label).storage().array()
val boxOffset = p * 4 + labelBbox(label).storageOffset() - 1
val offset = startInd + c * 4
boxData(boxOffset) = locData(offset)
boxData(boxOffset + 1) = locData(offset + 1)
boxData(boxOffset + 2) = locData(offset + 2)
boxData(boxOffset + 3) = locData(offset + 3)
c += 1
}
p += 1
}
locDataOffset += numPredsPerClass * numClasses * 4
i += 1
}
locPreds
}
/**
* Get Confidence scores
*
* @param conf
* @param numPredsPerClass
* @param numClasses
* @param confBuf
* @return
*/
def getConfidenceScores(conf: Tensor[Float], numPredsPerClass: Int, numClasses: Int,
confBuf: Array[Array[Tensor[Float]]] = null)
: Array[Array[Tensor[Float]]] = {
val confPreds = if (confBuf == null) {
val out = new Array[Array[Tensor[Float]]](conf.size(1))
var i = 0
while (i < conf.size(1)) {
out(i) = new Array[Tensor[Float]](numClasses)
var c = 0
while (c < numClasses) {
out(i)(c) = Tensor[Float](numPredsPerClass)
c += 1
}
i += 1
}
out
}
else confBuf
val confData = conf.storage().array()
var confDataOffset = conf.storageOffset() - 1
var i = 0
while (i < conf.size(1)) {
val labelScores = confPreds(i)
var p = 0
while (p < numPredsPerClass) {
val startInd = p * numClasses + confDataOffset
var c = 0
while (c < numClasses) {
labelScores(c).setValue(p + 1, confData(startInd + c))
c += 1
}
p += 1
}
confDataOffset += numPredsPerClass * numClasses
i += 1
}
confPreds
}
def getPriorBboxes(prior: Tensor[Float], nPriors: Int): (Tensor[Float], Tensor[Float]) = {
val array = prior.storage()
val aOffset = prior.storageOffset()
val priorBoxes = Tensor(array, aOffset, Array(nPriors, 4))
val priorVariances = Tensor(array, aOffset + nPriors * 4, Array(nPriors, 4))
(priorBoxes, priorVariances)
}
def locateBBox(srcBox: BoundingBox, box: BoundingBox, locBox: BoundingBox)
: Unit = {
val srcW = srcBox.width()
val srcH = srcBox.height()
locBox.x1 = srcBox.x1 + box.x1 * srcW
locBox.y1 = srcBox.y1 + box.y1 * srcH
locBox.x2 = srcBox.x1 + box.x2 * srcW
locBox.y2 = srcBox.y1 + box.y2 * srcH
}
def clipBox(box: BoundingBox, clipedBox: BoundingBox): Unit = {
clipedBox.x1 = Math.max(Math.min(box.x1, 1f), 0f)
clipedBox.y1 = Math.max(Math.min(box.y1, 1f), 0f)
clipedBox.x2 = Math.max(Math.min(box.x2, 1f), 0f)
clipedBox.y2 = Math.max(Math.min(box.y2, 1f), 0f)
}
def scaleBox(box: BoundingBox, height: Int, width: Int, scaledBox: BoundingBox): Unit = {
scaledBox.x1 = box.x1 * width
scaledBox.y1 = box.y1 * height
scaledBox.x2 = box.x2 * width
scaledBox.y2 = box.y2 * height
}
/**
* Project bbox onto the coordinate system defined by src_bbox.
*
* @param srcBox
* @param bbox
* @param projBox
* @return
*/
def projectBbox(srcBox: BoundingBox, bbox: BoundingBox,
projBox: BoundingBox): Boolean = {
if (bbox.x1 >= srcBox.x2 || bbox.x2 <= srcBox.x1 ||
bbox.y1 >= srcBox.y2 || bbox.y2 <= srcBox.y1) {
return false
}
val srcWidth = srcBox.width()
val srcHeight = srcBox.height()
projBox.x1 = (bbox.x1 - srcBox.x1) / srcWidth
projBox.y1 = (bbox.y1 - srcBox.y1) / srcHeight
projBox.x2 = (bbox.x2 - srcBox.x1) / srcWidth
projBox.y2 = (bbox.y2 - srcBox.y1) / srcHeight
clipBox(projBox, projBox)
if (projBox.area() > 0) true
else false
}
def jaccardOverlap(bbox: BoundingBox, bbox2: BoundingBox): Float = {
val w = math.min(bbox.x2, bbox2.x2) - math.max(bbox.x1, bbox2.x1)
if (w < 0) return 0
val h = math.min(bbox.y2, bbox2.y2) - math.max(bbox.y1, bbox2.y1)
if (h < 0) return 0
val overlap = w * h
overlap / ((bbox.area() + bbox2.area()) - overlap)
}
def meetEmitCenterConstraint(srcBox: BoundingBox, bbox: BoundingBox): Boolean = {
val xCenter = bbox.centerX()
val yCenter = bbox.centerY()
if (xCenter >= srcBox.x1 && xCenter <= srcBox.x2 &&
yCenter >= srcBox.y1 && yCenter <= srcBox.y2) {
true
} else {
false
}
}
def getMaxOverlaps(gtBboxes: Tensor[Float], gtAreas: Tensor[Float], gtInds: Array[Int],
bbox: Tensor[Float], normalized: Boolean = false,
overlaps: Tensor[Float] = null, gtOffset: Int = 0)
: (Float, Int) = {
require(bbox.dim() == 1)
var maxOverlap = Float.MinValue
var maxInd = -1
if (overlaps != null) overlaps.resizeAs(gtAreas)
if (gtInds != null && gtInds.length > 0) {
var i = 1
while (i <= gtInds.length) {
val r = gtInds(i - 1)
val ixmin = Math.max(gtBboxes.valueAt(r, 1 + gtOffset), bbox.valueAt(1))
val iymin = Math.max(gtBboxes.valueAt(r, 2 + gtOffset), bbox.valueAt(2))
val ixmax = Math.min(gtBboxes.valueAt(r, 3 + gtOffset), bbox.valueAt(3))
val iymax = Math.min(gtBboxes.valueAt(r, 4 + gtOffset), bbox.valueAt(4))
val (inter, bbArea) = if (normalized) {
val inter = Math.max(ixmax - ixmin, 0) * Math.max(iymax - iymin, 0)
val bbArea = (bbox.valueAt(3) - bbox.valueAt(1)) *
(bbox.valueAt(4) - bbox.valueAt(2))
(inter, bbArea)
} else {
val inter = Math.max(ixmax - ixmin + 1, 0) * Math.max(iymax - iymin + 1, 0)
val bbArea = (bbox.valueAt(3) - bbox.valueAt(1) + 1f) *
(bbox.valueAt(4) - bbox.valueAt(2) + 1f)
(inter, bbArea)
}
val overlap = inter / (gtAreas.valueAt(r) - inter + bbArea)
if (maxOverlap < overlap) {
maxOverlap = overlap
maxInd = i - 1
}
if (overlaps != null) overlaps.setValue(i, overlap)
i += 1
}
}
(maxOverlap, maxInd)
}
}
| {
"pile_set_name": "Github"
} |
# $OpenBSD: stderr-data.sh,v 1.5 2017/04/30 23:34:55 djm Exp $
# Placed in the Public Domain.
tid="stderr data transfer"
for n in '' -n; do
verbose "test $tid: ($n)"
${SSH} $n -F $OBJ/ssh_proxy otherhost exec \
sh -c \'"exec > /dev/null; sleep 3; cat ${DATA} 1>&2 $s"\' \
2> ${COPY}
r=$?
if [ $r -ne 0 ]; then
fail "ssh failed with exit code $r"
fi
cmp ${DATA} ${COPY} || fail "stderr corrupt"
rm -f ${COPY}
${SSH} $n -F $OBJ/ssh_proxy otherhost exec \
sh -c \'"echo a; exec > /dev/null; sleep 3; cat ${DATA} 1>&2 $s"\' \
> /dev/null 2> ${COPY}
r=$?
if [ $r -ne 0 ]; then
fail "ssh failed with exit code $r"
fi
cmp ${DATA} ${COPY} || fail "stderr corrupt"
rm -f ${COPY}
done
| {
"pile_set_name": "Github"
} |
2 2 1
7 7 1
9 9 1
10 10 1
13 13 1
14 14 1
15 15 1
22 2 2
25 5 2
30 10 2
33 13 2
34 14 2
42 2 3
53 13 3
54 14 3
62 2 4
65 5 4
70 10 4
72 12 4
73 13 4
74 14 4
75 15 4
85 5 5
94 14 5
102 2 6
105 5 6
110 10 6
113 13 6
115 15 6
| {
"pile_set_name": "Github"
} |
/***********************************************************************
*
* Copyright (c) 2015-2020 Ansel Sermersheim
*
* This file is part of CsLibGuarded.
*
* CsLibGuarded is free software, released under the BSD 2-Clause license.
* For license details refer to LICENSE provided with this project.
*
* CopperSpice 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.
*
* https://opensource.org/licenses/BSD-2-Clause
*
***********************************************************************/
#ifndef CSLIBGUARDED_RCU_GUARDED_H
#define CSLIBGUARDED_RCU_GUARDED_H
#include <memory>
namespace libguarded
{
/**
\headerfile cs_rcu_guarded.h <CsLibGuarded/cs_rcu_guarded.h>
This templated class implements a mechanism which controls access
to an RCU data structure. The only way to access the underlying
data structure is to use either the lock_read or lock_write methods
to receive a read-only or writable handle to the data structure,
respectively.
*/
template <typename T>
class rcu_guarded
{
public:
class write_handle;
class read_handle;
template <typename... Us>
rcu_guarded(Us &&... data);
// write access
[[nodiscard]] write_handle lock_write();
// read access
[[nodiscard]] read_handle lock_read() const;
class write_handle
{
public:
using pointer = T *;
using element_type = T;
write_handle(T *ptr);
~write_handle()
{
if (m_accessed) {
m_guard.rcu_write_unlock(*m_ptr);
}
}
T &operator*() const {
access();
return *m_ptr;
}
T *operator->() const {
access();
return m_ptr;
}
private:
void access() const {
if (!m_accessed) {
m_guard.rcu_write_lock(*m_ptr);
m_accessed = true;
}
}
T *m_ptr;
mutable typename T::rcu_write_guard m_guard;
mutable bool m_accessed;
};
class read_handle
{
public:
using pointer = const T *;
using element_type = const T;
read_handle(const T *ptr)
: m_ptr(ptr), m_accessed(false)
{
}
~read_handle()
{
if (m_accessed) {
m_guard.rcu_read_unlock(*m_ptr);
}
}
const T &operator*() const {
access();
return *m_ptr;
}
const T *operator->() const {
access();
return m_ptr;
}
private:
void access() const {
if (! m_accessed) {
m_guard.rcu_read_lock(*m_ptr);
m_accessed = true;
}
}
const T *m_ptr;
mutable typename T::rcu_read_guard m_guard;
mutable bool m_accessed;
};
private:
T m_obj;
};
template <typename T>
template <typename... Us>
rcu_guarded<T>::rcu_guarded(Us &&... data)
: m_obj(std::forward<Us>(data)...)
{
}
template <typename T>
auto rcu_guarded<T>::lock_write() -> write_handle
{
return write_handle(&m_obj);
}
template <typename T>
auto rcu_guarded<T>::lock_read() const -> read_handle
{
return read_handle(&m_obj);
}
template <typename T>
rcu_guarded<T>::write_handle::write_handle(T *ptr)
: m_ptr(ptr), m_accessed(false)
{
}
} // namespace libguarded
#endif
| {
"pile_set_name": "Github"
} |
/*****************************************************************************
Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
more contributor license agreements. See the NOTICE file distributed
with this work for additional information regarding copyright ownership.
Accellera 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.
*****************************************************************************/
/*****************************************************************************
global.h --
Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15
*****************************************************************************/
/*****************************************************************************
MODIFICATION LOG - modifiers, enter your name, affiliation, date and
changes you are making here.
Name, Affiliation, Date:
Description of Modification:
*****************************************************************************/
#ifndef GLOBALH
#define GLOBALH
// #include <iostream.h>
#include <stdio.h>
#define MAXBUFLEN 64
// cos constants, factor 512
#define c1d4 362L
#define c1d8 473L
#define c3d8 196L
#define c1d16 502L
#define c3d16 426L
#define c5d16 284L
#define c7d16 100L
// correct digits
#define MSCALE(expr) (COEFF)((expr)>>9)
typedef unsigned char BYTE;
typedef unsigned short WORD;
typedef unsigned long DWORD;
typedef BYTE BLOCK[8][8];
typedef BYTE COMPRESSED[MAXBUFLEN];
typedef WORD MATRIX64x12[64];
// type of the coefficient arrays
typedef short COEFF;
// typedefs for huffman tables
typedef struct {
BYTE size;
WORD code;
} HUFFMTBL_ENTRY;
struct Block {
BYTE b[8][8];
Block();
Block(BLOCK *);
Block(const Block&);
void operator=(const Block&);
int operator==(const Block&) const;
BYTE get(int x, int y) const;
void put(int x, int y, BYTE val);
BLOCK* get_ptr() const;
};
struct Compressed {
BYTE c[MAXBUFLEN];
Compressed();
Compressed(const Compressed&);
void operator=(const Compressed&);
int operator==(const Compressed&) const;
void clear();
BYTE get(int x) const;
void put(int x, BYTE val);
};
struct Matrix64x12 {
WORD m[64];
Matrix64x12();
Matrix64x12(const Matrix64x12&);
void operator=(const Matrix64x12&);
int operator==(const Matrix64x12&) const;
WORD get(int x) const;
void put(int x, WORD val);
};
struct Coeff8 {
COEFF c[8];
Coeff8();
Coeff8(const Coeff8&);
void operator=(const Coeff8&);
int operator==(const Coeff8&) const;
COEFF get(int x) const;
void put(int x, COEFF val);
};
struct Coeff8x8 {
COEFF c[8][8];
Coeff8x8();
Coeff8x8(const Coeff8x8&);
void operator=(const Coeff8x8&);
int operator==(const Coeff8x8&) const;
COEFF get(int x, int y) const;
void put(int x, int y, COEFF val);
};
inline
void
sc_trace( sc_trace_file*, const Coeff8x8&, const std::string& )
{
// NOT IMPLEMENTED
}
// quantization table 8-bit unsigned integer
static const unsigned char coeff_quant[8][8] = { // v is row
{ 16, 11, 10, 16, 24, 40, 51, 61},
{ 12, 12, 14, 19, 26, 58, 60, 55},
{ 14, 13, 16, 24, 40, 57, 69, 56},
{ 14, 17, 22, 29, 51, 87, 80, 82},
{ 18, 22, 37, 56, 68, 109, 103, 77},
{ 24, 35, 55, 64, 81, 104, 113, 92},
{ 99, 64, 78, 87, 103, 121, 120, 101},
{ 72, 92, 95, 98, 112, 100, 103, 99}
};
// table of Huffman DC coefficients
static const HUFFMTBL_ENTRY huffm_dc[12] = {
{ 2, 0X0000 }, { 3, 0X0002 }, { 3, 0X0003 }, { 3, 0X0004 },
{ 3, 0X0005 }, { 3, 0X0006 }, { 4, 0X000E }, { 5, 0X001E },
{ 6, 0X003E }, { 7, 0X007E }, { 8, 0X00FE }, { 9, 0X01FE }
};
// table of Huffman AC coefficients
static const HUFFMTBL_ENTRY huffm_ac[256] = {
{ 4, 0x000a }, { 2, 0x0000 }, { 2, 0x0001 }, { 3, 0x0004 },
{ 4, 0x000b }, { 5, 0x001a }, { 7, 0x0078 }, { 8, 0x00f8 },
{ 10, 0x03f6 }, { 16, 0xff82 }, { 16, 0xff83 }, { 0, 0x0000 },
{ 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 },
{ 0, 0x0000 }, { 4, 0x000c }, { 5, 0x001b }, { 7, 0x0079 },
{ 9, 0x01f6 }, { 11, 0x07f6 }, { 16, 0xff84 }, { 16, 0xff85 },
{ 16, 0xff86 }, { 16, 0xff87 }, { 16, 0xff88 }, { 0, 0x0000 },
{ 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 },
{ 0, 0x0000 }, { 5, 0x001c }, { 8, 0x00f9 }, { 10, 0x03f7 },
{ 12, 0x0ff4 }, { 16, 0xff89 }, { 16, 0xff8a }, { 16, 0xff8b },
{ 16, 0xff8c }, { 16, 0xff8d }, { 16, 0xff8e }, { 0, 0x0000 },
{ 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 },
{ 0, 0x0000 }, { 6, 0x003a }, { 9, 0x01f7 }, { 12, 0x0ff5 },
{ 16, 0xff8f }, { 16, 0xff90 }, { 16, 0xff91 }, { 16, 0xff92 },
{ 16, 0xff93 }, { 16, 0xff94 }, { 16, 0xff95 }, { 0, 0x0000 },
{ 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 },
{ 0, 0x0000 }, { 6, 0x003b }, { 10, 0x03f8 }, { 16, 0xff96 },
{ 16, 0xff97 }, { 16, 0xff98 }, { 16, 0xff99 }, { 16, 0xff9a },
{ 16, 0xff9b }, { 16, 0xff9c }, { 16, 0xff9d }, { 0, 0x0000 },
{ 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 },
{ 0, 0x0000 }, { 7, 0x007a }, { 11, 0x07f7 }, { 16, 0xff9e },
{ 16, 0xff9f }, { 16, 0xffa0 }, { 16, 0xffa1 }, { 16, 0xffa2 },
{ 16, 0xffa3 }, { 16, 0xffa4 }, { 16, 0xffa5 }, { 0, 0x0000 },
{ 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 },
{ 0, 0x0000 }, { 7, 0x007b }, { 12, 0x0ff6 }, { 16, 0xffa6 },
{ 16, 0xffa7 }, { 16, 0xffa8 }, { 16, 0xffa9 }, { 16, 0xffaa },
{ 16, 0xffab }, { 16, 0xffac }, { 16, 0xffad }, { 0, 0x0000 },
{ 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 },
{ 0, 0x0000 }, { 8, 0x00fa }, { 12, 0x0ff7 }, { 16, 0xffae },
{ 16, 0xffaf }, { 16, 0xffb0 }, { 16, 0xffb1 }, { 16, 0xffb2 },
{ 16, 0xffb3 }, { 16, 0xffb4 }, { 16, 0xffb5 }, { 0, 0x0000 },
{ 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 },
{ 0, 0x0000 }, { 9, 0x01f8 }, { 15, 0x7fc0 }, { 16, 0xffb6 },
{ 16, 0xffb7 }, { 16, 0xffb8 }, { 16, 0xffb9 }, { 16, 0xffba },
{ 16, 0xffbb }, { 16, 0xffbc }, { 16, 0xffbd }, { 0, 0x0000 },
{ 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 },
{ 0, 0x0000 }, { 9, 0x01f9 }, { 16, 0xffbe }, { 16, 0xffbf },
{ 16, 0xffc0 }, { 16, 0xffc1 }, { 16, 0xffc2 }, { 16, 0xffc3 },
{ 16, 0xffc4 }, { 16, 0xffc5 }, { 16, 0xffc6 }, { 0, 0x0000 },
{ 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 },
{ 0, 0x0000 }, { 9, 0x01fa }, { 16, 0xffc7 }, { 16, 0xffc8 },
{ 16, 0xffc9 }, { 16, 0xffca }, { 16, 0xffcb }, { 16, 0xffcc },
{ 16, 0xffcd }, { 16, 0xffce }, { 16, 0xffcf }, { 0, 0x0000 },
{ 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 },
{ 0, 0x0000 }, { 10, 0x03f9 }, { 16, 0xffd0 }, { 16, 0xffd1 },
{ 16, 0xffd2 }, { 16, 0xffd3 }, { 16, 0xffd4 }, { 16, 0xffd5 },
{ 16, 0xffd6 }, { 16, 0xffd7 }, { 16, 0xffd8 }, { 0, 0x0000 },
{ 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 },
{ 0, 0x0000 }, { 10, 0x03fa }, { 16, 0xffd9 }, { 16, 0xffda },
{ 16, 0xffdb }, { 16, 0xffdc }, { 16, 0xffdd }, { 16, 0xffde },
{ 16, 0xffdf }, { 16, 0xffe0 }, { 16, 0xffe1 }, { 0, 0x0000 },
{ 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 },
{ 0, 0x0000 }, { 11, 0x07f8 }, { 16, 0xffe2 }, { 16, 0xffe3 },
{ 16, 0xffe4 }, { 16, 0xffe5 }, { 16, 0xffe6 }, { 16, 0xffe7 },
{ 16, 0xffe8 }, { 16, 0xffe9 }, { 16, 0xffea }, { 0, 0x0000 },
{ 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 },
{ 0, 0x0000 }, { 16, 0xffeb }, { 16, 0xffec }, { 16, 0xffed },
{ 16, 0xffee }, { 16, 0xffef }, { 16, 0xfff0 }, { 16, 0xfff1 },
{ 16, 0xfff2 }, { 16, 0xfff3 }, { 16, 0xfff4 }, { 0, 0x0000 },
{ 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 },
{ 11, 0x07f9 }, { 16, 0xfff5 }, { 16, 0xfff6 }, { 16, 0xfff7 },
{ 16, 0xfff8 }, { 16, 0xfff9 }, { 16, 0xfffa }, { 16, 0xfffb },
{ 16, 0xfffc }, { 16, 0xfffd }, { 16, 0xfffe }, { 0, 0x0000 },
{ 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }
};
#endif
| {
"pile_set_name": "Github"
} |
/* ************************************************************************
qooxdoo - the new era of web development
http://qooxdoo.org
Copyright:
2007-2009 1&1 Internet AG, Germany, http://www.1und1.de
License:
MIT: https://opensource.org/licenses/MIT
See the LICENSE file in the project's top-level directory for details.
Authors:
* Christian Hagendorn (chris_schmidt)
************************************************************************ */
qx.Class.define("qx.test.bom.Iframe",
{
extend : qx.dev.unit.TestCase,
members :
{
__iframe: null,
tearDown : function() {
this.__iframe = null;
},
testCreate : function()
{
this.__iframe = qx.bom.Iframe.create();
this.__testAttributes(qx.bom.Iframe.DEFAULT_ATTRIBUTES);
},
testCreateWithAttributes : function()
{
var attributes = qx.lang.Object.clone(qx.bom.Iframe.DEFAULT_ATTRIBUTES);
attributes.allowTransparency = false;
this.__iframe = qx.bom.Iframe.create(attributes);
this.__testAttributes(attributes);
},
__testAttributes : function(attributes)
{
// do not test 'onload' on IE, this returns always 'undefined'
// http://tobielangel.com/2007/1/11/attribute-nightmare-in-ie/
if(qx.core.Environment.get("engine.name") == "mshtml") {
delete attributes["onload"];
}
for(var key in attributes) {
this.assertEquals(attributes[key],
qx.bom.element.Attribute.get(this.__iframe, key),
"Wrong value on attribute '" + key + "'");
}
},
testGetWindow : function()
{
this.__iframe = qx.bom.Iframe.create();
qx.dom.Element.insertBegin(this.__iframe, document.body);
this.assertNotNull(qx.bom.Iframe.getWindow(this.__iframe));
qx.dom.Element.remove(this.__iframe);
}
}
});
| {
"pile_set_name": "Github"
} |
/*
* Copyright (C) Research In Motion Limited 2011. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef SVGAttributeToPropertyMap_h
#define SVGAttributeToPropertyMap_h
#if ENABLE(SVG)
#include "SVGPropertyInfo.h"
#include <wtf/HashMap.h>
namespace WebCore {
class SVGAnimatedProperty;
class SVGElement;
class SVGAttributeToPropertyMap {
public:
bool isEmpty() const { return m_map.isEmpty(); }
void addProperties(const SVGAttributeToPropertyMap&);
void addProperty(const SVGPropertyInfo*);
// FIXME: To match WebKit coding style either these functions should have return values instead of out parameters,
// or the word "get" should be added as a prefix to their names.
void animatedPropertiesForAttribute(SVGElement* contextElement, const QualifiedName& attributeName, Vector<RefPtr<SVGAnimatedProperty>>&);
void animatedPropertyTypeForAttribute(const QualifiedName& attributeName, Vector<AnimatedPropertyType>&);
void synchronizeProperties(SVGElement* contextElement);
bool synchronizeProperty(SVGElement* contextElement, const QualifiedName& attributeName);
private:
void synchronizeProperty(SVGElement* contextElement, const QualifiedName& attributeName, const SVGPropertyInfo*);
PassRefPtr<SVGAnimatedProperty> animatedProperty(SVGElement* contextElement, const QualifiedName& attributeName, const SVGPropertyInfo*);
typedef Vector<const SVGPropertyInfo*> PropertiesVector;
typedef HashMap<QualifiedName, std::unique_ptr<PropertiesVector>> AttributeToPropertiesMap;
AttributeToPropertiesMap m_map;
};
}
#endif
#endif
| {
"pile_set_name": "Github"
} |
# Route v1.2.6
Route - Fast, flexible routing for PHP, enabling you to quickly and easily build RESTful web applications.
## Installation
You can download it and using it without any changes.
OR use Composer.
It's recommended that you use [Composer](https://getcomposer.org/) to install Route.
```bash
$ composer require nezamy/route
```
Or if you looking for ready template for using this route Go to https://github.com/nezamy/just
Route requires PHP 5.4.0 or newer.
## Usage
Only if using composer create index.php in root.
Create an index.php file with the following contents:
```php
<?php
define('DS', DIRECTORY_SEPARATOR);
define('BASE_PATH', __DIR__ . DS);
//Show errors
//===================================
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
//===================================
require BASE_PATH.'vendor/autoload.php';
$app = System\App::instance();
$app->request = System\Request::instance();
$app->route = System\Route::instance($app->request);
$route = $app->route;
$route->any('/', function() {
echo 'Hello World';
});
$route->end();
```
If using apache make sure the .htaccess file has exists beside index.php
## How it works
Routing is done by matching a URL pattern with a callback function.
### index.php
```php
$route->any('/', function() {
echo 'Hello World';
});
$route->any('/about', function() {
echo 'About';
});
```
### The callback can be any object that is callable. So you can use a regular function:
```php
function pages() {
echo 'Page Content';
}
$route->get('/', 'pages');
```
### Or a class method:
```php
class home
{
function pages() {
echo 'Home page Content';
}
}
$route->get('/', ['home', 'pages']);
// OR
$home = new home;
$route->get('/', [$home, 'pages']);
// OR
$route->get('/', 'home@pages');
```
## Method Routing
```php
$route->any('/', function() {
// Any method requests
});
$route->get('/', function() {
// Only GET requests
});
$route->post('/', function() {
// Only POST requests
});
$route->put('/', function() {
// Only PUT requests
});
$route->patch('/', function() {
// Only PATCH requests
});
$route->delete('/', function() {
// Only DELETE requests
});
// You can use multiple methods. Just add _ between method names
$route->get_post('/', function() {
// Only GET and POST requests
});
```
## Multiple Routing (All in one)
```php
$route->get(['/', 'index', 'home'], function() {
// Will match 3 page in one
});
```
## Parameters
```php
// This example will match any page name
$route->get('/?', function($page) {
echo "you are in $page";
});
// This example will match anything after post/ - limited to 1 argument
$route->get('/post/?', function($id) {
// Will match anything like post/hello or post/5 ...
// But not match /post/5/title
echo "post id $id";
});
// more than parameters
$route->get('/post/?/?', function($id, $title) {
echo "post id $id and title $title";
});
```
### For “unlimited” optional parameters, you can do this:
```php
// This example will match anything after blog/ - unlimited arguments
$route->get('/blog/*', function() {
// [$this] instanceof ArrayObject so you can get all args by getArrayCopy()
pre($this->getArrayCopy());
pre($this[1]);
pre($this[2]);
});
```
## Named Parameters
You can specify named parameters in your routes which will be passed along to your callback function.
```php
$route->get('/{username}/{page}', function($username, $page) {
echo "Username $username and Page $page <br>";
// OR
echo "Username {$this['username']} and Page {$this['page']}";
});
```
## Regular Expressions
You can validate the args by regular expressions.
```php
// Validate args by regular expressions uses :(your pattern here)
$route->get('/{username}:([0-9a-z_.-]+)/post/{id}:([0-9]+)',
function($username, $id)
{
echo "author $username post id $id";
});
// You can add named regex pattern in routes
$route->addPattern([
'username' => '/([0-9a-z_.-]+)',
'id' => '/([0-9]+)'
]);
// Now you can use named regex
$route->get('/{username}:username/post/{id}:id', function($username, $id) {
echo "author $username post id $id";
});
```
### Some named regex patterns already registered in routes
```php
[
'int' => '/([0-9]+)',
'multiInt' => '/([0-9,]+)',
'title' => '/([a-z_-]+)',
'key' => '/([a-z0-9_]+)',
'multiKey' => '/([a-z0-9_,]+)',
'isoCode2' => '/([a-z]{2})',
'isoCode3' => '/([a-z]{3})',
'multiIsoCode2' => '/([a-z,]{2,})',
'multiIsoCode3' => '/([a-z,]{3,})'
]
```
## Optional parameters
You can specify named parameters that are optional for matching by adding (?)
```php
$route->get('/post/{title}?:title/{date}?',
function($title, $date) {
if ($title) {
echo "<h1>$title</h1>";
}else{
echo "<h1>Posts List</h1>";
}
if ($date) {
echo "<small>Published $date</small>";
}
});
```
## Groups
```php
$route->group('/admin', function()
{
// /admin/
$this->get('/', function() {
echo 'welcome to admin panel';
});
// /admin/settings
$this->get('/settings', function() {
echo 'list of settings';
});
// nested group
$this->group('/users', function()
{
// /admin/users
$this->get('/', function() {
echo 'list of users';
});
// /admin/users/add
$this->get('/add', function() {
echo 'add new user';
});
});
// Anything else
$this->any('/*', function() {
pre("Page ( {$this->app->request->path} ) Not Found", 6);
});
});
```
### Groups with parameters
```php
$route->group('/{lang}?:isoCode2', function($lang)
{
$default = $lang;
if (!in_array($lang, ['ar', 'en'])) {
$default = 'en';
}
$this->get('/', function($lang) use($default) {
echo "lang in request is $lang<br>";
echo "include page_{$default}.php";
});
$this->get('/page/{name}/', function($lang, $name)
{
pre(func_get_args());
pre($this->app->request->args);
});
});
```
### Middleware
```php
$route->use(function (){
$req = app('request');
pre('Do something before all routes', 3);
});
$route->before('/', function (){
pre('Do something before all routes', 4);
});
$route->before('/*!admin', function (){
pre('Do something before all routes except admin', 4);
});
$route->before('/admin|home', function (){
pre('Do something before admin and home only ', 4);
});
$route->after('/admin|home', function (){
pre('Do something after admin and home only ', 4);
});
```
# Full examples [here](http://nezamy.com/route)
## Support me
https://www.paypal.me/nezamy
| {
"pile_set_name": "Github"
} |
page_title: Understanding Docker
page_description: Docker explained in depth
page_keywords: docker, introduction, documentation, about, technology, understanding
# Understanding Docker
**What is Docker?**
Docker is an open platform for developing, shipping, and running applications.
Docker is designed to deliver your applications faster. With Docker you can
separate your applications from your infrastructure AND treat your
infrastructure like a managed application. Docker helps you ship code faster,
test faster, deploy faster, and shorten the cycle between writing code and
running code.
Docker does this by combining a lightweight container virtualization platform
with workflows and tooling that help you manage and deploy your applications.
At its core, Docker provides a way to run almost any application securely
isolated in a container. The isolation and security allow you to run many
containers simultaneously on your host. The lightweight nature of containers,
which run without the extra load of a hypervisor, means you can get more out of
your hardware.
Surrounding the container virtualization are tooling and a platform which can
help you in several ways:
* getting your applications (and supporting components) into Docker containers
* distributing and shipping those containers to your teams for further development
and testing
* deploying those applications to your production environment,
whether it be in a local data center or the Cloud.
## What can I use Docker for?
*Faster delivery of your applications*
Docker is perfect for helping you with the development lifecycle. Docker
allows your developers to develop on local containers that contain your
applications and services. It can then integrate into a continuous integration and
deployment workflow.
For example, your developers write code locally and share their development stack via
Docker with their colleagues. When they are ready, they push their code and the
stack they are developing onto a test environment and execute any required
tests. From the testing environment, you can then push the Docker images into
production and deploy your code.
*Deploying and scaling more easily*
Docker's container-based platform allows for highly portable workloads. Docker
containers can run on a developer's local host, on physical or virtual machines
in a data center, or in the Cloud.
Docker's portability and lightweight nature also make dynamically managing
workloads easy. You can use Docker to quickly scale up or tear down applications
and services. Docker's speed means that scaling can be near real time.
*Achieving higher density and running more workloads*
Docker is lightweight and fast. It provides a viable, cost-effective alternative
to hypervisor-based virtual machines. This is especially useful in high density
environments: for example, building your own Cloud or Platform-as-a-Service. But
it is also useful for small and medium deployments where you want to get more
out of the resources you have.
## What are the major Docker components?
Docker has two major components:
* Docker: the open source container virtualization platform.
* [Docker Hub](https://hub.docker.com): our Software-as-a-Service
platform for sharing and managing Docker containers.
**Note:** Docker is licensed under the open source Apache 2.0 license.
## What is Docker's architecture?
Docker uses a client-server architecture. The Docker *client* talks to the
Docker *daemon*, which does the heavy lifting of building, running, and
distributing your Docker containers. Both the Docker client and the daemon *can*
run on the same system, or you can connect a Docker client to a remote Docker
daemon. The Docker client and daemon communicate via sockets or through a
RESTful API.

### The Docker daemon
As shown in the diagram above, the Docker daemon runs on a host machine. The
user does not directly interact with the daemon, but instead through the Docker
client.
### The Docker client
The Docker client, in the form of the `docker` binary, is the primary user
interface to Docker. It accepts commands from the user and communicates back and
forth with a Docker daemon.
### Inside Docker
To understand Docker's internals, you need to know about three components:
* Docker images.
* Docker registries.
* Docker containers.
#### Docker images
A Docker image is a read-only template. For example, an image could contain an Ubuntu
operating system with Apache and your web application installed. Images are used to create
Docker containers. Docker provides a simple way to build new images or update existing
images, or you can download Docker images that other people have already created.
Docker images are the **build** component of Docker.
#### Docker Registries
Docker registries hold images. These are public or private stores from which you upload
or download images. The public Docker registry is called
[Docker Hub](http://hub.docker.com). It provides a huge collection of existing
images for your use. These can be images you create yourself or you
can use images that others have previously created. Docker registries are the
**distribution** component of Docker.
####Docker containers
Docker containers are similar to a directory. A Docker container holds everything that
is needed for an application to run. Each container is created from a Docker
image. Docker containers can be run, started, stopped, moved, and deleted. Each
container is an isolated and secure application platform. Docker containers are the
**run** component of Docker.
##So how does Docker work?
So far, we've learned that:
1. You can build Docker images that hold your applications.
2. You can create Docker containers from those Docker images to run your
applications.
3. You can share those Docker images via
[Docker Hub](https://hub.docker.com) or your own registry.
Let's look at how these elements combine together to make Docker work.
### How does a Docker Image work?
We've already seen that Docker images are read-only templates from which Docker
containers are launched. Each image consists of a series of layers. Docker
makes use of [union file systems](http://en.wikipedia.org/wiki/UnionFS) to
combine these layers into a single image. Union file systems allow files and
directories of separate file systems, known as branches, to be transparently
overlaid, forming a single coherent file system.
One of the reasons Docker is so lightweight is because of these layers. When you
change a Docker image—for example, update an application to a new version— a new layer
gets built. Thus, rather than replacing the whole image or entirely
rebuilding, as you may do with a virtual machine, only that layer is added or
updated. Now you don't need to distribute a whole new image, just the update,
making distributing Docker images faster and simpler.
Every image starts from a base image, for example `ubuntu`, a base Ubuntu image,
or `fedora`, a base Fedora image. You can also use images of your own as the
basis for a new image, for example if you have a base Apache image you could use
this as the base of all your web application images.
> **Note:** Docker usually gets these base images from
> [Docker Hub](https://hub.docker.com).
Docker images are then built from these base images using a simple, descriptive
set of steps we call *instructions*. Each instruction creates a new layer in our
image. Instructions include actions like:
* Run a command.
* Add a file or directory.
* Create an environment variable.
* What process to run when launching a container from this image.
These instructions are stored in a file called a `Dockerfile`. Docker reads this
`Dockerfile` when you request a build of an image, executes the instructions, and
returns a final image.
### How does a Docker registry work?
The Docker registry is the store for your Docker images. Once you build a Docker
image you can *push* it to a public registry [Docker Hub](https://hub.docker.com) or to
your own registry running behind your firewall.
Using the Docker client, you can search for already published images and then
pull them down to your Docker host to build containers from them.
[Docker Hub](https://hub.docker.com) provides both public and private storage
for images. Public storage is searchable and can be downloaded by anyone.
Private storage is excluded from search results and only you and your users can
pull images down and use them to build containers. You can [sign up for a storage plan
here](https://hub.docker.com/plans).
### How does a container work?
A container consists of an operating system, user-added files, and meta-data. As
we've seen, each container is built from an image. That image tells Docker
what the container holds, what process to run when the container is launched, and
a variety of other configuration data. The Docker image is read-only. When
Docker runs a container from an image, it adds a read-write layer on top of the
image (using a union file system as we saw earlier) in which your application can
then run.
### What happens when you run a container?
Either by using the `docker` binary or via the API, the Docker client tells the Docker
daemon to run a container.
$ sudo docker run -i -t ubuntu /bin/bash
Let's break down this command. The Docker client is launched using the `docker`
binary with the `run` option telling it to launch a new container. The bare
minimum the Docker client needs to tell the Docker daemon to run the container
is:
* What Docker image to build the container from, here `ubuntu`, a base Ubuntu
image;
* The command you want to run inside the container when it is launched,
here `/bin/bash`, to start the Bash shell inside the new container.
So what happens under the hood when we run this command?
In order, Docker does the following:
- **Pulls the `ubuntu` image:** Docker checks for the presence of the `ubuntu`
image and, if it doesn't exist locally on the host, then Docker downloads it from
[Docker Hub](https://hub.docker.com). If the image already exists, then Docker
uses it for the new container.
- **Creates a new container:** Once Docker has the image, it uses it to create a
container.
- **Allocates a filesystem and mounts a read-write _layer_:** The container is created in
the file system and a read-write layer is added to the image.
- **Allocates a network / bridge interface:** Creates a network interface that allows the
Docker container to talk to the local host.
- **Sets up an IP address:** Finds and attaches an available IP address from a pool.
- **Executes a process that you specify:** Runs your application, and;
- **Captures and provides application output:** Connects and logs standard input, outputs
and errors for you to see how your application is running.
You now have a running container! From here you can manage your container, interact with
your application and then, when finished, stop and remove your container.
## The underlying technology
Docker is written in Go and makes use of several Linux kernel features to
deliver the functionality we've seen.
### Namespaces
Docker takes advantage of a technology called `namespaces` to provide the
isolated workspace we call the *container*. When you run a container, Docker
creates a set of *namespaces* for that container.
This provides a layer of isolation: each aspect of a container runs in its own
namespace and does not have access outside it.
Some of the namespaces that Docker uses are:
- **The `pid` namespace:** Used for process isolation (PID: Process ID).
- **The `net` namespace:** Used for managing network interfaces (NET:
Networking).
- **The `ipc` namespace:** Used for managing access to IPC
resources (IPC: InterProcess Communication).
- **The `mnt` namespace:** Used for managing mount-points (MNT: Mount).
- **The `uts` namespace:** Used for isolating kernel and version identifiers. (UTS: Unix
Timesharing System).
### Control groups
Docker also makes use of another technology called `cgroups` or control groups.
A key to running applications in isolation is to have them only use the
resources you want. This ensures containers are good multi-tenant citizens on a
host. Control groups allow Docker to share available hardware resources to
containers and, if required, set up limits and constraints. For example,
limiting the memory available to a specific container.
### Union file systems
Union file systems, or UnionFS, are file systems that operate by creating layers,
making them very lightweight and fast. Docker uses union file systems to provide
the building blocks for containers. Docker can make use of several union file system variants
including: AUFS, btrfs, vfs, and DeviceMapper.
### Container format
Docker combines these components into a wrapper we call a container format. The
default container format is called `libcontainer`. Docker also supports
traditional Linux containers using [LXC](https://linuxcontainers.org/). In the
future, Docker may support other container formats, for example, by integrating with
BSD Jails or Solaris Zones.
## Next steps
### Installing Docker
Visit the [installation section](/installation/#installation).
### The Docker User Guide
[Learn Docker in depth](/userguide/).
| {
"pile_set_name": "Github"
} |
/*
** $Id: lgc.c,v 2.205 2015/03/25 13:42:19 roberto Exp $
** Garbage Collector
** See Copyright Notice in lua.h
*/
#define lgc_c
#define LUA_CORE
#include "lprefix.h"
#include <string.h>
#include "lua.h"
#include "ldebug.h"
#include "ldo.h"
#include "lfunc.h"
#include "lgc.h"
#include "lmem.h"
#include "lobject.h"
#include "lstate.h"
#include "lstring.h"
#include "ltable.h"
#include "ltm.h"
/*
** internal state for collector while inside the atomic phase. The
** collector should never be in this state while running regular code.
*/
#define GCSinsideatomic (GCSpause + 1)
/*
** cost of sweeping one element (the size of a small object divided
** by some adjust for the sweep speed)
*/
#define GCSWEEPCOST ((sizeof(TString) + 4) / 4)
/* maximum number of elements to sweep in each single step */
#define GCSWEEPMAX (cast_int((GCSTEPSIZE / GCSWEEPCOST) / 4))
/* cost of calling one finalizer */
#define GCFINALIZECOST GCSWEEPCOST
/*
** macro to adjust 'stepmul': 'stepmul' is actually used like
** 'stepmul / STEPMULADJ' (value chosen by tests)
*/
#define STEPMULADJ 200
/*
** macro to adjust 'pause': 'pause' is actually used like
** 'pause / PAUSEADJ' (value chosen by tests)
*/
#define PAUSEADJ 100
/*
** 'makewhite' erases all color bits then sets only the current white
** bit
*/
#define maskcolors (~(bitmask(BLACKBIT) | WHITEBITS))
#define makewhite(g,x) \
(x->marked = cast_byte((x->marked & maskcolors) | luaC_white(g)))
#define white2gray(x) resetbits(x->marked, WHITEBITS)
#define black2gray(x) resetbit(x->marked, BLACKBIT)
#define valiswhite(x) (iscollectable(x) && iswhite(gcvalue(x)))
#define checkdeadkey(n) lua_assert(!ttisdeadkey(gkey(n)) || ttisnil(gval(n)))
#define checkconsistency(obj) \
lua_longassert(!iscollectable(obj) || righttt(obj))
#define markvalue(g,o) { checkconsistency(o); \
if (valiswhite(o)) reallymarkobject(g,gcvalue(o)); }
#define markobject(g,t) { if (iswhite(t)) reallymarkobject(g, obj2gco(t)); }
/*
** mark an object that can be NULL (either because it is really optional,
** or it was stripped as debug info, or inside an uncompleted structure)
*/
#define markobjectN(g,t) { if (t) markobject(g,t); }
static void reallymarkobject (global_State *g, GCObject *o);
/*
** {======================================================
** Generic functions
** =======================================================
*/
/*
** one after last element in a hash array
*/
#define gnodelast(h) gnode(h, cast(size_t, sizenode(h)))
/*
** link collectable object 'o' into list pointed by 'p'
*/
#define linkgclist(o,p) ((o)->gclist = (p), (p) = obj2gco(o))
/*
** if key is not marked, mark its entry as dead (therefore removing it
** from the table)
*/
static void removeentry (Node *n) {
lua_assert(ttisnil(gval(n)));
if (valiswhite(gkey(n)))
setdeadvalue(wgkey(n)); /* unused and unmarked key; remove it */
}
/*
** tells whether a key or value can be cleared from a weak
** table. Non-collectable objects are never removed from weak
** tables. Strings behave as 'values', so are never removed too. for
** other objects: if really collected, cannot keep them; for objects
** being finalized, keep them in keys, but not in values
*/
static int iscleared (global_State *g, const TValue *o) {
if (!iscollectable(o)) return 0;
else if (ttisstring(o)) {
markobject(g, tsvalue(o)); /* strings are 'values', so are never weak */
return 0;
}
else return iswhite(gcvalue(o));
}
/*
** barrier that moves collector forward, that is, mark the white object
** being pointed by a black object. (If in sweep phase, clear the black
** object to white [sweep it] to avoid other barrier calls for this
** same object.)
*/
void luaC_barrier_ (lua_State *L, GCObject *o, GCObject *v) {
global_State *g = G(L);
lua_assert(isblack(o) && iswhite(v) && !isdead(g, v) && !isdead(g, o));
if (keepinvariant(g)) /* must keep invariant? */
reallymarkobject(g, v); /* restore invariant */
else { /* sweep phase */
lua_assert(issweepphase(g));
makewhite(g, o); /* mark main obj. as white to avoid other barriers */
}
}
/*
** barrier that moves collector backward, that is, mark the black object
** pointing to a white object as gray again.
*/
void luaC_barrierback_ (lua_State *L, Table *t) {
global_State *g = G(L);
lua_assert(isblack(t) && !isdead(g, t));
black2gray(t); /* make table gray (again) */
linkgclist(t, g->grayagain);
}
/*
** barrier for assignments to closed upvalues. Because upvalues are
** shared among closures, it is impossible to know the color of all
** closures pointing to it. So, we assume that the object being assigned
** must be marked.
*/
void luaC_upvalbarrier_ (lua_State *L, UpVal *uv) {
global_State *g = G(L);
GCObject *o = gcvalue(uv->v);
lua_assert(!upisopen(uv)); /* ensured by macro luaC_upvalbarrier */
if (keepinvariant(g))
markobject(g, o);
}
void luaC_fix (lua_State *L, GCObject *o) {
global_State *g = G(L);
lua_assert(g->allgc == o); /* object must be 1st in 'allgc' list! */
white2gray(o); /* they will be gray forever */
g->allgc = o->next; /* remove object from 'allgc' list */
o->next = g->fixedgc; /* link it to 'fixedgc' list */
g->fixedgc = o;
}
/*
** create a new collectable object (with given type and size) and link
** it to 'allgc' list.
*/
GCObject *luaC_newobj (lua_State *L, int tt, size_t sz) {
global_State *g = G(L);
GCObject *o = cast(GCObject *, luaM_newobject(L, novariant(tt), sz));
o->marked = luaC_white(g);
o->tt = tt;
o->next = g->allgc;
g->allgc = o;
return o;
}
/* }====================================================== */
/*
** {======================================================
** Mark functions
** =======================================================
*/
/*
** mark an object. Userdata, strings, and closed upvalues are visited
** and turned black here. Other objects are marked gray and added
** to appropriate list to be visited (and turned black) later. (Open
** upvalues are already linked in 'headuv' list.)
*/
static void reallymarkobject (global_State *g, GCObject *o) {
reentry:
white2gray(o);
switch (o->tt) {
case LUA_TSHRSTR: {
gray2black(o);
g->GCmemtrav += sizelstring(gco2ts(o)->shrlen);
break;
}
case LUA_TLNGSTR: {
gray2black(o);
g->GCmemtrav += sizelstring(gco2ts(o)->u.lnglen);
break;
}
case LUA_TUSERDATA: {
TValue uvalue;
markobjectN(g, gco2u(o)->metatable); /* mark its metatable */
gray2black(o);
g->GCmemtrav += sizeudata(gco2u(o));
getuservalue(g->mainthread, gco2u(o), &uvalue);
if (valiswhite(&uvalue)) { /* markvalue(g, &uvalue); */
o = gcvalue(&uvalue);
goto reentry;
}
break;
}
case LUA_TLCL: {
linkgclist(gco2lcl(o), g->gray);
break;
}
case LUA_TCCL: {
linkgclist(gco2ccl(o), g->gray);
break;
}
case LUA_TTABLE: {
linkgclist(gco2t(o), g->gray);
break;
}
case LUA_TTHREAD: {
linkgclist(gco2th(o), g->gray);
break;
}
case LUA_TPROTO: {
linkgclist(gco2p(o), g->gray);
break;
}
default: lua_assert(0); break;
}
}
/*
** mark metamethods for basic types
*/
static void markmt (global_State *g) {
int i;
for (i=0; i < LUA_NUMTAGS; i++)
markobjectN(g, g->mt[i]);
}
/*
** mark all objects in list of being-finalized
*/
static void markbeingfnz (global_State *g) {
GCObject *o;
for (o = g->tobefnz; o != NULL; o = o->next)
markobject(g, o);
}
/*
** Mark all values stored in marked open upvalues from non-marked threads.
** (Values from marked threads were already marked when traversing the
** thread.) Remove from the list threads that no longer have upvalues and
** not-marked threads.
*/
static void remarkupvals (global_State *g) {
lua_State *thread;
lua_State **p = &g->twups;
while ((thread = *p) != NULL) {
lua_assert(!isblack(thread)); /* threads are never black */
if (isgray(thread) && thread->openupval != NULL)
p = &thread->twups; /* keep marked thread with upvalues in the list */
else { /* thread is not marked or without upvalues */
UpVal *uv;
*p = thread->twups; /* remove thread from the list */
thread->twups = thread; /* mark that it is out of list */
for (uv = thread->openupval; uv != NULL; uv = uv->u.open.next) {
if (uv->u.open.touched) {
markvalue(g, uv->v); /* remark upvalue's value */
uv->u.open.touched = 0;
}
}
}
}
}
/*
** mark root set and reset all gray lists, to start a new collection
*/
static void restartcollection (global_State *g) {
g->gray = g->grayagain = NULL;
g->weak = g->allweak = g->ephemeron = NULL;
markobject(g, g->mainthread);
markvalue(g, &g->l_registry);
markmt(g);
markbeingfnz(g); /* mark any finalizing object left from previous cycle */
}
/* }====================================================== */
/*
** {======================================================
** Traverse functions
** =======================================================
*/
/*
** Traverse a table with weak values and link it to proper list. During
** propagate phase, keep it in 'grayagain' list, to be revisited in the
** atomic phase. In the atomic phase, if table has any white value,
** put it in 'weak' list, to be cleared.
*/
static void traverseweakvalue (global_State *g, Table *h) {
Node *n, *limit = gnodelast(h);
/* if there is array part, assume it may have white values (it is not
worth traversing it now just to check) */
int hasclears = (h->sizearray > 0);
for (n = gnode(h, 0); n < limit; n++) { /* traverse hash part */
checkdeadkey(n);
if (ttisnil(gval(n))) /* entry is empty? */
removeentry(n); /* remove it */
else {
lua_assert(!ttisnil(gkey(n)));
markvalue(g, gkey(n)); /* mark key */
if (!hasclears && iscleared(g, gval(n))) /* is there a white value? */
hasclears = 1; /* table will have to be cleared */
}
}
if (g->gcstate == GCSpropagate)
linkgclist(h, g->grayagain); /* must retraverse it in atomic phase */
else if (hasclears)
linkgclist(h, g->weak); /* has to be cleared later */
}
/*
** Traverse an ephemeron table and link it to proper list. Returns true
** iff any object was marked during this traversal (which implies that
** convergence has to continue). During propagation phase, keep table
** in 'grayagain' list, to be visited again in the atomic phase. In
** the atomic phase, if table has any white->white entry, it has to
** be revisited during ephemeron convergence (as that key may turn
** black). Otherwise, if it has any white key, table has to be cleared
** (in the atomic phase).
*/
static int traverseephemeron (global_State *g, Table *h) {
int marked = 0; /* true if an object is marked in this traversal */
int hasclears = 0; /* true if table has white keys */
int hasww = 0; /* true if table has entry "white-key -> white-value" */
Node *n, *limit = gnodelast(h);
unsigned int i;
/* traverse array part */
for (i = 0; i < h->sizearray; i++) {
if (valiswhite(&h->array[i])) {
marked = 1;
reallymarkobject(g, gcvalue(&h->array[i]));
}
}
/* traverse hash part */
for (n = gnode(h, 0); n < limit; n++) {
checkdeadkey(n);
if (ttisnil(gval(n))) /* entry is empty? */
removeentry(n); /* remove it */
else if (iscleared(g, gkey(n))) { /* key is not marked (yet)? */
hasclears = 1; /* table must be cleared */
if (valiswhite(gval(n))) /* value not marked yet? */
hasww = 1; /* white-white entry */
}
else if (valiswhite(gval(n))) { /* value not marked yet? */
marked = 1;
reallymarkobject(g, gcvalue(gval(n))); /* mark it now */
}
}
/* link table into proper list */
if (g->gcstate == GCSpropagate)
linkgclist(h, g->grayagain); /* must retraverse it in atomic phase */
else if (hasww) /* table has white->white entries? */
linkgclist(h, g->ephemeron); /* have to propagate again */
else if (hasclears) /* table has white keys? */
linkgclist(h, g->allweak); /* may have to clean white keys */
return marked;
}
static void traversestrongtable (global_State *g, Table *h) {
Node *n, *limit = gnodelast(h);
unsigned int i;
for (i = 0; i < h->sizearray; i++) /* traverse array part */
markvalue(g, &h->array[i]);
for (n = gnode(h, 0); n < limit; n++) { /* traverse hash part */
checkdeadkey(n);
if (ttisnil(gval(n))) /* entry is empty? */
removeentry(n); /* remove it */
else {
lua_assert(!ttisnil(gkey(n)));
markvalue(g, gkey(n)); /* mark key */
markvalue(g, gval(n)); /* mark value */
}
}
}
static lu_mem traversetable (global_State *g, Table *h) {
const char *weakkey, *weakvalue;
const TValue *mode = gfasttm(g, h->metatable, TM_MODE);
markobjectN(g, h->metatable);
if (mode && ttisstring(mode) && /* is there a weak mode? */
((weakkey = strchr(svalue(mode), 'k')),
(weakvalue = strchr(svalue(mode), 'v')),
(weakkey || weakvalue))) { /* is really weak? */
black2gray(h); /* keep table gray */
if (!weakkey) /* strong keys? */
traverseweakvalue(g, h);
else if (!weakvalue) /* strong values? */
traverseephemeron(g, h);
else /* all weak */
linkgclist(h, g->allweak); /* nothing to traverse now */
}
else /* not weak */
traversestrongtable(g, h);
return sizeof(Table) + sizeof(TValue) * h->sizearray +
sizeof(Node) * cast(size_t, sizenode(h));
}
/*
** Traverse a prototype. (While a prototype is being build, its
** arrays can be larger than needed; the extra slots are filled with
** NULL, so the use of 'markobjectN')
*/
static int traverseproto (global_State *g, Proto *f) {
int i;
if (f->cache && iswhite(f->cache))
f->cache = NULL; /* allow cache to be collected */
markobjectN(g, f->source);
for (i = 0; i < f->sizek; i++) /* mark literals */
markvalue(g, &f->k[i]);
for (i = 0; i < f->sizeupvalues; i++) /* mark upvalue names */
markobjectN(g, f->upvalues[i].name);
for (i = 0; i < f->sizep; i++) /* mark nested protos */
markobjectN(g, f->p[i]);
for (i = 0; i < f->sizelocvars; i++) /* mark local-variable names */
markobjectN(g, f->locvars[i].varname);
return sizeof(Proto) + sizeof(Instruction) * f->sizecode +
sizeof(Proto *) * f->sizep +
sizeof(TValue) * f->sizek +
sizeof(int) * f->sizelineinfo +
sizeof(LocVar) * f->sizelocvars +
sizeof(Upvaldesc) * f->sizeupvalues;
}
static lu_mem traverseCclosure (global_State *g, CClosure *cl) {
int i;
for (i = 0; i < cl->nupvalues; i++) /* mark its upvalues */
markvalue(g, &cl->upvalue[i]);
return sizeCclosure(cl->nupvalues);
}
/*
** open upvalues point to values in a thread, so those values should
** be marked when the thread is traversed except in the atomic phase
** (because then the value cannot be changed by the thread and the
** thread may not be traversed again)
*/
static lu_mem traverseLclosure (global_State *g, LClosure *cl) {
int i;
markobjectN(g, cl->p); /* mark its prototype */
for (i = 0; i < cl->nupvalues; i++) { /* mark its upvalues */
UpVal *uv = cl->upvals[i];
if (uv != NULL) {
if (upisopen(uv) && g->gcstate != GCSinsideatomic)
uv->u.open.touched = 1; /* can be marked in 'remarkupvals' */
else
markvalue(g, uv->v);
}
}
return sizeLclosure(cl->nupvalues);
}
static lu_mem traversethread (global_State *g, lua_State *th) {
StkId o = th->stack;
if (o == NULL)
return 1; /* stack not completely built yet */
lua_assert(g->gcstate == GCSinsideatomic ||
th->openupval == NULL || isintwups(th));
for (; o < th->top; o++) /* mark live elements in the stack */
markvalue(g, o);
if (g->gcstate == GCSinsideatomic) { /* final traversal? */
StkId lim = th->stack + th->stacksize; /* real end of stack */
for (; o < lim; o++) /* clear not-marked stack slice */
setnilvalue(o);
/* 'remarkupvals' may have removed thread from 'twups' list */
if (!isintwups(th) && th->openupval != NULL) {
th->twups = g->twups; /* link it back to the list */
g->twups = th;
}
}
else if (g->gckind != KGC_EMERGENCY)
luaD_shrinkstack(th); /* do not change stack in emergency cycle */
return (sizeof(lua_State) + sizeof(TValue) * th->stacksize);
}
/*
** traverse one gray object, turning it to black (except for threads,
** which are always gray).
*/
static void propagatemark (global_State *g) {
lu_mem size;
GCObject *o = g->gray;
lua_assert(isgray(o));
gray2black(o);
switch (o->tt) {
case LUA_TTABLE: {
Table *h = gco2t(o);
g->gray = h->gclist; /* remove from 'gray' list */
size = traversetable(g, h);
break;
}
case LUA_TLCL: {
LClosure *cl = gco2lcl(o);
g->gray = cl->gclist; /* remove from 'gray' list */
size = traverseLclosure(g, cl);
break;
}
case LUA_TCCL: {
CClosure *cl = gco2ccl(o);
g->gray = cl->gclist; /* remove from 'gray' list */
size = traverseCclosure(g, cl);
break;
}
case LUA_TTHREAD: {
lua_State *th = gco2th(o);
g->gray = th->gclist; /* remove from 'gray' list */
linkgclist(th, g->grayagain); /* insert into 'grayagain' list */
black2gray(o);
size = traversethread(g, th);
break;
}
case LUA_TPROTO: {
Proto *p = gco2p(o);
g->gray = p->gclist; /* remove from 'gray' list */
size = traverseproto(g, p);
break;
}
default: lua_assert(0); return;
}
g->GCmemtrav += size;
}
static void propagateall (global_State *g) {
while (g->gray) propagatemark(g);
}
static void convergeephemerons (global_State *g) {
int changed;
do {
GCObject *w;
GCObject *next = g->ephemeron; /* get ephemeron list */
g->ephemeron = NULL; /* tables may return to this list when traversed */
changed = 0;
while ((w = next) != NULL) {
next = gco2t(w)->gclist;
if (traverseephemeron(g, gco2t(w))) { /* traverse marked some value? */
propagateall(g); /* propagate changes */
changed = 1; /* will have to revisit all ephemeron tables */
}
}
} while (changed);
}
/* }====================================================== */
/*
** {======================================================
** Sweep Functions
** =======================================================
*/
/*
** clear entries with unmarked keys from all weaktables in list 'l' up
** to element 'f'
*/
static void clearkeys (global_State *g, GCObject *l, GCObject *f) {
for (; l != f; l = gco2t(l)->gclist) {
Table *h = gco2t(l);
Node *n, *limit = gnodelast(h);
for (n = gnode(h, 0); n < limit; n++) {
if (!ttisnil(gval(n)) && (iscleared(g, gkey(n)))) {
setnilvalue(gval(n)); /* remove value ... */
removeentry(n); /* and remove entry from table */
}
}
}
}
/*
** clear entries with unmarked values from all weaktables in list 'l' up
** to element 'f'
*/
static void clearvalues (global_State *g, GCObject *l, GCObject *f) {
for (; l != f; l = gco2t(l)->gclist) {
Table *h = gco2t(l);
Node *n, *limit = gnodelast(h);
unsigned int i;
for (i = 0; i < h->sizearray; i++) {
TValue *o = &h->array[i];
if (iscleared(g, o)) /* value was collected? */
setnilvalue(o); /* remove value */
}
for (n = gnode(h, 0); n < limit; n++) {
if (!ttisnil(gval(n)) && iscleared(g, gval(n))) {
setnilvalue(gval(n)); /* remove value ... */
removeentry(n); /* and remove entry from table */
}
}
}
}
void luaC_upvdeccount (lua_State *L, UpVal *uv) {
lua_assert(uv->refcount > 0);
uv->refcount--;
if (uv->refcount == 0 && !upisopen(uv))
luaM_free(L, uv);
}
static void freeLclosure (lua_State *L, LClosure *cl) {
int i;
for (i = 0; i < cl->nupvalues; i++) {
UpVal *uv = cl->upvals[i];
if (uv)
luaC_upvdeccount(L, uv);
}
luaM_freemem(L, cl, sizeLclosure(cl->nupvalues));
}
static void freeobj (lua_State *L, GCObject *o) {
switch (o->tt) {
case LUA_TPROTO: luaF_freeproto(L, gco2p(o)); break;
case LUA_TLCL: {
freeLclosure(L, gco2lcl(o));
break;
}
case LUA_TCCL: {
luaM_freemem(L, o, sizeCclosure(gco2ccl(o)->nupvalues));
break;
}
case LUA_TTABLE: luaH_free(L, gco2t(o)); break;
case LUA_TTHREAD: luaE_freethread(L, gco2th(o)); break;
case LUA_TUSERDATA: luaM_freemem(L, o, sizeudata(gco2u(o))); break;
case LUA_TSHRSTR:
luaS_remove(L, gco2ts(o)); /* remove it from hash table */
luaM_freemem(L, o, sizelstring(gco2ts(o)->shrlen));
break;
case LUA_TLNGSTR: {
luaM_freemem(L, o, sizelstring(gco2ts(o)->u.lnglen));
break;
}
default: lua_assert(0);
}
}
#define sweepwholelist(L,p) sweeplist(L,p,MAX_LUMEM)
static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count);
/*
** sweep at most 'count' elements from a list of GCObjects erasing dead
** objects, where a dead object is one marked with the old (non current)
** white; change all non-dead objects back to white, preparing for next
** collection cycle. Return where to continue the traversal or NULL if
** list is finished.
*/
static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count) {
global_State *g = G(L);
int ow = otherwhite(g);
int white = luaC_white(g); /* current white */
while (*p != NULL && count-- > 0) {
GCObject *curr = *p;
int marked = curr->marked;
if (isdeadm(ow, marked)) { /* is 'curr' dead? */
*p = curr->next; /* remove 'curr' from list */
freeobj(L, curr); /* erase 'curr' */
}
else { /* change mark to 'white' */
curr->marked = cast_byte((marked & maskcolors) | white);
p = &curr->next; /* go to next element */
}
}
return (*p == NULL) ? NULL : p;
}
/*
** sweep a list until a live object (or end of list)
*/
static GCObject **sweeptolive (lua_State *L, GCObject **p, int *n) {
GCObject **old = p;
int i = 0;
do {
i++;
p = sweeplist(L, p, 1);
} while (p == old);
if (n) *n += i;
return p;
}
/* }====================================================== */
/*
** {======================================================
** Finalization
** =======================================================
*/
/*
** If possible, free concatenation buffer and shrink string table
*/
static void checkSizes (lua_State *L, global_State *g) {
if (g->gckind != KGC_EMERGENCY) {
l_mem olddebt = g->GCdebt;
luaZ_freebuffer(L, &g->buff); /* free concatenation buffer */
if (g->strt.nuse < g->strt.size / 4) /* string table too big? */
luaS_resize(L, g->strt.size / 2); /* shrink it a little */
g->GCestimate += g->GCdebt - olddebt; /* update estimate */
}
}
static GCObject *udata2finalize (global_State *g) {
GCObject *o = g->tobefnz; /* get first element */
lua_assert(tofinalize(o));
g->tobefnz = o->next; /* remove it from 'tobefnz' list */
o->next = g->allgc; /* return it to 'allgc' list */
g->allgc = o;
resetbit(o->marked, FINALIZEDBIT); /* object is "normal" again */
if (issweepphase(g))
makewhite(g, o); /* "sweep" object */
return o;
}
static void dothecall (lua_State *L, void *ud) {
UNUSED(ud);
luaD_call(L, L->top - 2, 0, 0);
}
static void GCTM (lua_State *L, int propagateerrors) {
global_State *g = G(L);
const TValue *tm;
TValue v;
setgcovalue(L, &v, udata2finalize(g));
tm = luaT_gettmbyobj(L, &v, TM_GC);
if (tm != NULL && ttisfunction(tm)) { /* is there a finalizer? */
int status;
lu_byte oldah = L->allowhook;
int running = g->gcrunning;
L->allowhook = 0; /* stop debug hooks during GC metamethod */
g->gcrunning = 0; /* avoid GC steps */
setobj2s(L, L->top, tm); /* push finalizer... */
setobj2s(L, L->top + 1, &v); /* ... and its argument */
L->top += 2; /* and (next line) call the finalizer */
status = luaD_pcall(L, dothecall, NULL, savestack(L, L->top - 2), 0);
L->allowhook = oldah; /* restore hooks */
g->gcrunning = running; /* restore state */
if (status != LUA_OK && propagateerrors) { /* error while running __gc? */
if (status == LUA_ERRRUN) { /* is there an error object? */
const char *msg = (ttisstring(L->top - 1))
? svalue(L->top - 1)
: "no message";
luaO_pushfstring(L, "error in __gc metamethod (%s)", msg);
status = LUA_ERRGCMM; /* error in __gc metamethod */
}
luaD_throw(L, status); /* re-throw error */
}
}
}
/*
** call a few (up to 'g->gcfinnum') finalizers
*/
static int runafewfinalizers (lua_State *L) {
global_State *g = G(L);
unsigned int i;
lua_assert(!g->tobefnz || g->gcfinnum > 0);
for (i = 0; g->tobefnz && i < g->gcfinnum; i++)
GCTM(L, 1); /* call one finalizer */
g->gcfinnum = (!g->tobefnz) ? 0 /* nothing more to finalize? */
: g->gcfinnum * 2; /* else call a few more next time */
return i;
}
/*
** call all pending finalizers
*/
static void callallpendingfinalizers (lua_State *L, int propagateerrors) {
global_State *g = G(L);
while (g->tobefnz)
GCTM(L, propagateerrors);
}
/*
** find last 'next' field in list 'p' list (to add elements in its end)
*/
static GCObject **findlast (GCObject **p) {
while (*p != NULL)
p = &(*p)->next;
return p;
}
/*
** move all unreachable objects (or 'all' objects) that need
** finalization from list 'finobj' to list 'tobefnz' (to be finalized)
*/
static void separatetobefnz (global_State *g, int all) {
GCObject *curr;
GCObject **p = &g->finobj;
GCObject **lastnext = findlast(&g->tobefnz);
while ((curr = *p) != NULL) { /* traverse all finalizable objects */
lua_assert(tofinalize(curr));
if (!(iswhite(curr) || all)) /* not being collected? */
p = &curr->next; /* don't bother with it */
else {
*p = curr->next; /* remove 'curr' from 'finobj' list */
curr->next = *lastnext; /* link at the end of 'tobefnz' list */
*lastnext = curr;
lastnext = &curr->next;
}
}
}
/*
** if object 'o' has a finalizer, remove it from 'allgc' list (must
** search the list to find it) and link it in 'finobj' list.
*/
void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt) {
global_State *g = G(L);
if (tofinalize(o) || /* obj. is already marked... */
gfasttm(g, mt, TM_GC) == NULL) /* or has no finalizer? */
return; /* nothing to be done */
else { /* move 'o' to 'finobj' list */
GCObject **p;
if (issweepphase(g)) {
makewhite(g, o); /* "sweep" object 'o' */
if (g->sweepgc == &o->next) /* should not remove 'sweepgc' object */
g->sweepgc = sweeptolive(L, g->sweepgc, NULL); /* change 'sweepgc' */
}
/* search for pointer pointing to 'o' */
for (p = &g->allgc; *p != o; p = &(*p)->next) { /* empty */ }
*p = o->next; /* remove 'o' from 'allgc' list */
o->next = g->finobj; /* link it in 'finobj' list */
g->finobj = o;
l_setbit(o->marked, FINALIZEDBIT); /* mark it as such */
}
}
/* }====================================================== */
/*
** {======================================================
** GC control
** =======================================================
*/
/*
** Set a reasonable "time" to wait before starting a new GC cycle; cycle
** will start when memory use hits threshold. (Division by 'estimate'
** should be OK: it cannot be zero (because Lua cannot even start with
** less than PAUSEADJ bytes).
*/
static void setpause (global_State *g) {
l_mem threshold, debt;
l_mem estimate = g->GCestimate / PAUSEADJ; /* adjust 'estimate' */
lua_assert(estimate > 0);
threshold = (g->gcpause < MAX_LMEM / estimate) /* overflow? */
? estimate * g->gcpause /* no overflow */
: MAX_LMEM; /* overflow; truncate to maximum */
debt = gettotalbytes(g) - threshold;
luaE_setdebt(g, debt);
}
/*
** Enter first sweep phase.
** The call to 'sweeptolive' makes pointer point to an object inside
** the list (instead of to the header), so that the real sweep do not
** need to skip objects created between "now" and the start of the real
** sweep.
** Returns how many objects it swept.
*/
static int entersweep (lua_State *L) {
global_State *g = G(L);
int n = 0;
g->gcstate = GCSswpallgc;
lua_assert(g->sweepgc == NULL);
g->sweepgc = sweeptolive(L, &g->allgc, &n);
return n;
}
void luaC_freeallobjects (lua_State *L) {
global_State *g = G(L);
separatetobefnz(g, 1); /* separate all objects with finalizers */
lua_assert(g->finobj == NULL);
callallpendingfinalizers(L, 0);
lua_assert(g->tobefnz == NULL);
g->currentwhite = WHITEBITS; /* this "white" makes all objects look dead */
g->gckind = KGC_NORMAL;
sweepwholelist(L, &g->finobj);
sweepwholelist(L, &g->allgc);
sweepwholelist(L, &g->fixedgc); /* collect fixed objects */
lua_assert(g->strt.nuse == 0);
}
static l_mem atomic (lua_State *L) {
global_State *g = G(L);
l_mem work;
GCObject *origweak, *origall;
GCObject *grayagain = g->grayagain; /* save original list */
lua_assert(g->ephemeron == NULL && g->weak == NULL);
lua_assert(!iswhite(g->mainthread));
g->gcstate = GCSinsideatomic;
g->GCmemtrav = 0; /* start counting work */
markobject(g, L); /* mark running thread */
/* registry and global metatables may be changed by API */
markvalue(g, &g->l_registry);
markmt(g); /* mark global metatables */
/* remark occasional upvalues of (maybe) dead threads */
remarkupvals(g);
propagateall(g); /* propagate changes */
work = g->GCmemtrav; /* stop counting (do not recount 'grayagain') */
g->gray = grayagain;
propagateall(g); /* traverse 'grayagain' list */
g->GCmemtrav = 0; /* restart counting */
convergeephemerons(g);
/* at this point, all strongly accessible objects are marked. */
/* Clear values from weak tables, before checking finalizers */
clearvalues(g, g->weak, NULL);
clearvalues(g, g->allweak, NULL);
origweak = g->weak; origall = g->allweak;
work += g->GCmemtrav; /* stop counting (objects being finalized) */
separatetobefnz(g, 0); /* separate objects to be finalized */
g->gcfinnum = 1; /* there may be objects to be finalized */
markbeingfnz(g); /* mark objects that will be finalized */
propagateall(g); /* remark, to propagate 'resurrection' */
g->GCmemtrav = 0; /* restart counting */
convergeephemerons(g);
/* at this point, all resurrected objects are marked. */
/* remove dead objects from weak tables */
clearkeys(g, g->ephemeron, NULL); /* clear keys from all ephemeron tables */
clearkeys(g, g->allweak, NULL); /* clear keys from all 'allweak' tables */
/* clear values from resurrected weak tables */
clearvalues(g, g->weak, origweak);
clearvalues(g, g->allweak, origall);
luaS_clearcache(g);
g->currentwhite = cast_byte(otherwhite(g)); /* flip current white */
work += g->GCmemtrav; /* complete counting */
return work; /* estimate of memory marked by 'atomic' */
}
static lu_mem sweepstep (lua_State *L, global_State *g,
int nextstate, GCObject **nextlist) {
if (g->sweepgc) {
l_mem olddebt = g->GCdebt;
g->sweepgc = sweeplist(L, g->sweepgc, GCSWEEPMAX);
g->GCestimate += g->GCdebt - olddebt; /* update estimate */
if (g->sweepgc) /* is there still something to sweep? */
return (GCSWEEPMAX * GCSWEEPCOST);
}
/* else enter next state */
g->gcstate = nextstate;
g->sweepgc = nextlist;
return 0;
}
static lu_mem singlestep (lua_State *L) {
global_State *g = G(L);
switch (g->gcstate) {
case GCSpause: {
g->GCmemtrav = g->strt.size * sizeof(GCObject*);
restartcollection(g);
g->gcstate = GCSpropagate;
return g->GCmemtrav;
}
case GCSpropagate: {
g->GCmemtrav = 0;
lua_assert(g->gray);
propagatemark(g);
if (g->gray == NULL) /* no more gray objects? */
g->gcstate = GCSatomic; /* finish propagate phase */
return g->GCmemtrav; /* memory traversed in this step */
}
case GCSatomic: {
lu_mem work;
int sw;
propagateall(g); /* make sure gray list is empty */
work = atomic(L); /* work is what was traversed by 'atomic' */
sw = entersweep(L);
g->GCestimate = gettotalbytes(g); /* first estimate */;
return work + sw * GCSWEEPCOST;
}
case GCSswpallgc: { /* sweep "regular" objects */
return sweepstep(L, g, GCSswpfinobj, &g->finobj);
}
case GCSswpfinobj: { /* sweep objects with finalizers */
return sweepstep(L, g, GCSswptobefnz, &g->tobefnz);
}
case GCSswptobefnz: { /* sweep objects to be finalized */
return sweepstep(L, g, GCSswpend, NULL);
}
case GCSswpend: { /* finish sweeps */
makewhite(g, g->mainthread); /* sweep main thread */
checkSizes(L, g);
g->gcstate = GCScallfin;
return 0;
}
case GCScallfin: { /* call remaining finalizers */
if (g->tobefnz && g->gckind != KGC_EMERGENCY) {
int n = runafewfinalizers(L);
return (n * GCFINALIZECOST);
}
else { /* emergency mode or no more finalizers */
g->gcstate = GCSpause; /* finish collection */
return 0;
}
}
default: lua_assert(0); return 0;
}
}
/*
** advances the garbage collector until it reaches a state allowed
** by 'statemask'
*/
void luaC_runtilstate (lua_State *L, int statesmask) {
global_State *g = G(L);
while (!testbit(statesmask, g->gcstate))
singlestep(L);
}
/*
** get GC debt and convert it from Kb to 'work units' (avoid zero debt
** and overflows)
*/
static l_mem getdebt (global_State *g) {
l_mem debt = g->GCdebt;
int stepmul = g->gcstepmul;
debt = (debt / STEPMULADJ) + 1;
debt = (debt < MAX_LMEM / stepmul) ? debt * stepmul : MAX_LMEM;
return debt;
}
/*
** performs a basic GC step when collector is running
*/
void luaC_step (lua_State *L) {
global_State *g = G(L);
l_mem debt = getdebt(g); /* GC deficit (be paid now) */
if (!g->gcrunning) { /* not running? */
luaE_setdebt(g, -GCSTEPSIZE * 10); /* avoid being called too often */
return;
}
do { /* repeat until pause or enough "credit" (negative debt) */
lu_mem work = singlestep(L); /* perform one single step */
debt -= work;
} while (debt > -GCSTEPSIZE && g->gcstate != GCSpause);
if (g->gcstate == GCSpause)
setpause(g); /* pause until next cycle */
else {
debt = (debt / g->gcstepmul) * STEPMULADJ; /* convert 'work units' to Kb */
luaE_setdebt(g, debt);
runafewfinalizers(L);
}
}
/*
** Performs a full GC cycle; if 'isemergency', set a flag to avoid
** some operations which could change the interpreter state in some
** unexpected ways (running finalizers and shrinking some structures).
** Before running the collection, check 'keepinvariant'; if it is true,
** there may be some objects marked as black, so the collector has
** to sweep all objects to turn them back to white (as white has not
** changed, nothing will be collected).
*/
void luaC_fullgc (lua_State *L, int isemergency) {
global_State *g = G(L);
lua_assert(g->gckind == KGC_NORMAL);
if (isemergency) g->gckind = KGC_EMERGENCY; /* set flag */
if (keepinvariant(g)) { /* black objects? */
entersweep(L); /* sweep everything to turn them back to white */
}
/* finish any pending sweep phase to start a new cycle */
luaC_runtilstate(L, bitmask(GCSpause));
luaC_runtilstate(L, ~bitmask(GCSpause)); /* start new collection */
luaC_runtilstate(L, bitmask(GCScallfin)); /* run up to finalizers */
/* estimate must be correct after a full GC cycle */
lua_assert(g->GCestimate == gettotalbytes(g));
luaC_runtilstate(L, bitmask(GCSpause)); /* finish collection */
g->gckind = KGC_NORMAL;
setpause(g);
}
/* }====================================================== */
| {
"pile_set_name": "Github"
} |
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#include "cbase.h"
#include "ai_basenpc.h"
#include "ai_hull.h"
#include "ai_senses.h"
#include "ai_memory.h"
#include "soundent.h"
#include "smoke_trail.h"
#include "weapon_rpg.h"
#include "gib.h"
#include "ndebugoverlay.h"
#include "IEffects.h"
#include "vstdlib/random.h"
#include "engine/IEngineSound.h"
#include "ammodef.h"
#include "hl2_shareddefs.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
#define MD_FULLAMMO 50
#define MD_BC_YAW 0
#define MD_BC_PITCH 1
#define MD_AP_LGUN 2
#define MD_AP_RGUN 1
#define MD_GIB_COUNT 4
#define MD_GIB_MODEL "models/gibs/missile_defense_gibs.mdl"
#define MD_YAW_SPEED 24
#define MD_PITCH_SPEED 12
//=========================================================
//=========================================================
class CNPC_MissileDefense : public CAI_BaseNPC
{
DECLARE_CLASS( CNPC_MissileDefense, CAI_BaseNPC );
DECLARE_DATADESC();
public:
CNPC_MissileDefense( void ) { };
void Precache( void );
void Spawn( void );
Class_T Classify( void ) { return CLASS_NONE; }
int GetSoundInterests( void ) { return SOUND_NONE; }
float MaxYawSpeed( void ) { return 90.f; }
void RunAI(void);
void FireCannons( void );
void AimGun( void );
void EnemyShootPosition(CBaseEntity* pEnemy, Vector *vPosition);
void Event_Killed( const CTakeDamageInfo &info );
int OnTakeDamage_Alive( const CTakeDamageInfo &info );
void Gib();
void GetGunAim( Vector *vecAim );
~CNPC_MissileDefense();
Vector m_vGunAng;
int m_iAmmoLoaded;
float m_flReloadedTime;
};
LINK_ENTITY_TO_CLASS( npc_missiledefense, CNPC_MissileDefense );
//=========================================================
//=========================================================
BEGIN_DATADESC( CNPC_MissileDefense )
DEFINE_FIELD( m_iAmmoLoaded, FIELD_INTEGER ),
DEFINE_FIELD( m_flReloadedTime, FIELD_TIME ),
DEFINE_FIELD( m_vGunAng, FIELD_VECTOR ),
END_DATADESC()
//---------------------------------------------------------
//---------------------------------------------------------
void CNPC_MissileDefense::Precache( void )
{
PrecacheModel("models/missile_defense.mdl");
PrecacheModel(MD_GIB_MODEL);
PrecacheScriptSound( "NPC_MissileDefense.Attack" );
PrecacheScriptSound( "NPC_MissileDefense.Reload" );
PrecacheScriptSound( "NPC_MissileDefense.Turn" );
}
//---------------------------------------------------------
//---------------------------------------------------------
void CNPC_MissileDefense::GetGunAim( Vector *vecAim )
{
Vector vecPos;
QAngle vecAng;
GetAttachment( MD_AP_LGUN, vecPos, vecAng );
vecAng.x = GetLocalAngles().x + GetBoneController( MD_BC_PITCH );
vecAng.z = 0;
vecAng.y = GetLocalAngles().y + GetBoneController( MD_BC_YAW );
Vector vecForward;
AngleVectors( vecAng, &vecForward );
*vecAim = vecForward;
}
#define NOISE 0.035f
#define MD_ATTN_CANNON 0.4
//------------------------------------------------------------------------------
// Purpose :
// Input :
// Output :
//------------------------------------------------------------------------------
void CNPC_MissileDefense::FireCannons( void )
{
// ----------------------------------------------
// Make sure I have an enemy
// ----------------------------------------------
if (GetEnemy() == NULL)
{
return;
}
// ----------------------------------------------
// Make sure I have ammo
// ----------------------------------------------
if( m_iAmmoLoaded < 1 )
{
return;
}
// ----------------------------------------------
// Make sure gun it pointing in right direction
// ----------------------------------------------
Vector vGunDir;
GetGunAim( &vGunDir );
Vector vTargetPos;
EnemyShootPosition(GetEnemy(),&vTargetPos);
Vector vTargetDir = vTargetPos - GetAbsOrigin();
VectorNormalize( vTargetDir );
float fDotPr = DotProduct( vGunDir, vTargetDir );
if (fDotPr < 0.95)
{
return;
}
// ----------------------------------------------
// Check line of sight
// ----------------------------------------------
trace_t tr;
AI_TraceLine( GetEnemy()->EyePosition(), GetAbsOrigin(), MASK_SOLID_BRUSHONLY, this, COLLISION_GROUP_NONE, &tr);
if (tr.fraction < 1.0)
{
return;
}
Vector vecRight;
Vector vecDir;
Vector vecCenter;
AngleVectors( GetLocalAngles(), NULL, &vecRight, NULL );
vecCenter = WorldSpaceCenter();
if( GetEnemy() == NULL )
{
return;
}
bool fSound = false;
if( random->RandomInt( 0, 3 ) == 0 )
{
fSound = true;
}
EmitSound( "NPC_MissileDefense.Attack" );
Vector vecGun;
QAngle vecAng;
GetAttachment( MD_AP_LGUN, vecGun, vecAng );
Vector vecTarget;
EnemyShootPosition(GetEnemy(),&vecTarget);
vecDir = vecTarget - vecCenter;
VectorNormalize(vecDir);
vecDir.x += random->RandomFloat( -NOISE, NOISE );
vecDir.y += random->RandomFloat( -NOISE, NOISE );
Vector vecStart = vecGun + vecDir * 110;
Vector vecEnd = vecGun + vecDir * 4096;
UTIL_Tracer( vecStart, vecEnd, 0, TRACER_DONT_USE_ATTACHMENT, 3000 + random->RandomFloat( 0, 2000 ), fSound );
vecDir = vecTarget - vecCenter;
VectorNormalize(vecDir);
vecDir.x += random->RandomFloat( -NOISE, NOISE );
vecDir.y += random->RandomFloat( -NOISE, NOISE );
vecDir.z += random->RandomFloat( -NOISE, NOISE );
GetAttachment( MD_AP_RGUN, vecGun, vecAng );
vecStart = vecGun + vecDir * 110;
vecEnd = vecGun + vecDir * 4096;
UTIL_Tracer( vecStart, vecEnd, 0, TRACER_DONT_USE_ATTACHMENT, 3000 + random->RandomFloat( 0, 2000 ) );
m_iAmmoLoaded -= 2;
if( m_iAmmoLoaded < 1 )
{
// Incite a reload.
EmitSound( "NPC_MissileDefense.Reload" );
m_flReloadedTime = gpGlobals->curtime + 0.3;
return;
}
// Do damage to the missile based on distance.
// if < 1, make damage 0.
float flDist = (GetEnemy()->GetLocalOrigin() - vecGun).Length();
float flDamage;
flDamage = 4000 - flDist;
flDamage /= 1000.0;
if( flDamage > 0 )
{
if( flDist <= 1500 )
{
flDamage *= 2;
}
CTakeDamageInfo info( this, this, flDamage, DMG_MISSILEDEFENSE );
CalculateBulletDamageForce( &info, GetAmmoDef()->Index("SMG1"), vecDir, GetEnemy()->GetAbsOrigin() );
GetEnemy()->TakeDamage( info );
}
}
//---------------------------------------------------------
//---------------------------------------------------------
void CNPC_MissileDefense::Spawn( void )
{
Precache();
SetModel( "models/missile_defense.mdl" );
UTIL_SetSize( this, Vector( -36, -36 , 0 ), Vector( 36, 36, 64 ) );
SetSolid( SOLID_BBOX );
SetMoveType( MOVETYPE_NONE );
m_takedamage = DAMAGE_YES;
SetBloodColor( DONT_BLEED );
m_iHealth = 10;
m_flFieldOfView = 0.1;
m_NPCState = NPC_STATE_NONE;
CapabilitiesClear();
CapabilitiesAdd ( bits_CAP_INNATE_RANGE_ATTACK1 );
// Hate missiles
AddClassRelationship( CLASS_MISSILE, D_HT, 5 );
m_spawnflags |= SF_NPC_LONG_RANGE;
m_flReloadedTime = gpGlobals->curtime;
InitBoneControllers();
NPCInit();
SetBoneController( MD_BC_YAW, 10 );
SetBoneController( MD_BC_PITCH, 0 );
SetBodygroup( 1, 1 );
SetBodygroup( 2, 1 );
SetBodygroup( 3, 1 );
SetBodygroup( 4, 1 );
m_NPCState = NPC_STATE_IDLE;
}
//------------------------------------------------------------------------------
// Purpose :
// Input :
// Output :
//------------------------------------------------------------------------------
int CNPC_MissileDefense::OnTakeDamage_Alive( const CTakeDamageInfo &info )
{
// Only take blast damage
if (info.GetDamageType() & DMG_BLAST )
{
return BaseClass::OnTakeDamage_Alive( info );
}
else
{
return 0;
}
}
//------------------------------------------------------------------------------
// Purpose :
// Input :
// Output :
//------------------------------------------------------------------------------
void CNPC_MissileDefense::Event_Killed( const CTakeDamageInfo &info )
{
StopSound( "NPC_MissileDefense.Turn" );
Gib();
}
//------------------------------------------------------------------------------
// Purpose :
// Input :
// Output :
//------------------------------------------------------------------------------
void CNPC_MissileDefense::Gib(void)
{
// Sparks
for (int i = 0; i < 4; i++)
{
Vector sparkPos = GetAbsOrigin();
sparkPos.x += random->RandomFloat(-12,12);
sparkPos.y += random->RandomFloat(-12,12);
sparkPos.z += random->RandomFloat(-12,12);
g_pEffects->Sparks(sparkPos);
}
// Smoke
UTIL_Smoke(GetAbsOrigin(), random->RandomInt(10, 15), 10);
// Light
CBroadcastRecipientFilter filter;
te->DynamicLight( filter, 0.0,
&GetAbsOrigin(), 255, 180, 100, 0, 100, 0.1, 0 );
// Remove top parts
SetBodygroup( 1, 0 );
SetBodygroup( 2, 0 );
SetBodygroup( 3, 0 );
SetBodygroup( 4, 0 );
m_takedamage = 0;
SetThink(NULL);
// Throw manhackgibs
CGib::SpawnSpecificGibs( this, MD_GIB_COUNT, 300, 500, MD_GIB_MODEL);
}
//------------------------------------------------------------------------------
// Purpose :
// Input :
// Output :
//------------------------------------------------------------------------------
void CNPC_MissileDefense::RunAI( void )
{
// If my enemy is dead clear the memory and reset m_hEnemy
if (GetEnemy() != NULL &&
!GetEnemy()->IsAlive())
{
ClearEnemyMemory();
SetEnemy( NULL );
}
if (GetEnemy() == NULL )
{
GetSenses()->Look( 4092 );
SetEnemy( BestEnemy( ) );
if (GetEnemy() != NULL)
{
m_iAmmoLoaded = MD_FULLAMMO;
m_flReloadedTime = gpGlobals->curtime;
}
}
if( m_iAmmoLoaded < 1 && gpGlobals->curtime > m_flReloadedTime )
{
m_iAmmoLoaded = MD_FULLAMMO;
}
AimGun();
FireCannons();
SetNextThink( gpGlobals->curtime + 0.05 );
}
//------------------------------------------------------------------------------
// Purpose : Add a little prediction into my enemy aim position
// Input :
// Output :
//------------------------------------------------------------------------------
void CNPC_MissileDefense::EnemyShootPosition(CBaseEntity* pEnemy, Vector *vPosition)
{
// This should never happen, but just in case
if (!pEnemy)
{
return;
}
*vPosition = pEnemy->GetAbsOrigin();
// Add prediction but prevents us from flipping around as enemy approaches us
float flDist = (pEnemy->GetAbsOrigin() - GetAbsOrigin()).Length();
Vector vPredVel = pEnemy->GetSmoothedVelocity() * 0.5;
if ( flDist > vPredVel.Length())
{
*vPosition += vPredVel;
}
}
//------------------------------------------------------------------------------
// Purpose :
// Input :
// Output :
//------------------------------------------------------------------------------
void CNPC_MissileDefense::AimGun( void )
{
if (GetEnemy() == NULL)
{
StopSound( "NPC_MissileDefense.Turn" );
return;
}
Vector forward, right, up;
AngleVectors( GetLocalAngles(), &forward, &right, &up );
// Get gun attachment points
Vector vBasePos;
QAngle vBaseAng;
GetAttachment( MD_AP_LGUN, vBasePos, vBaseAng );
Vector vTargetPos;
EnemyShootPosition(GetEnemy(),&vTargetPos);
Vector vTargetDir = vTargetPos - vBasePos;
VectorNormalize( vTargetDir );
Vector vecOut;
vecOut.x = DotProduct( forward, vTargetDir );
vecOut.y = -DotProduct( right, vTargetDir );
vecOut.z = DotProduct( up, vTargetDir );
QAngle angles;
VectorAngles(vecOut, angles);
if (angles.y > 180)
angles.y = angles.y - 360;
if (angles.y < -180)
angles.y = angles.y + 360;
if (angles.x > 180)
angles.x = angles.x - 360;
if (angles.x < -180)
angles.x = angles.x + 360;
float flOldX = m_vGunAng.x;
float flOldY = m_vGunAng.y;
if (angles.x > m_vGunAng.x)
m_vGunAng.x = MIN( angles.x, m_vGunAng.x + MD_PITCH_SPEED );
if (angles.x < m_vGunAng.x)
m_vGunAng.x = MAX( angles.x, m_vGunAng.x - MD_PITCH_SPEED );
if (angles.y > m_vGunAng.y)
m_vGunAng.y = MIN( angles.y, m_vGunAng.y + MD_YAW_SPEED );
if (angles.y < m_vGunAng.y)
m_vGunAng.y = MAX( angles.y, m_vGunAng.y - MD_YAW_SPEED );
m_vGunAng.y = SetBoneController( MD_BC_YAW, m_vGunAng.y );
m_vGunAng.x = SetBoneController( MD_BC_PITCH, m_vGunAng.x );
if (flOldX != m_vGunAng.x || flOldY != m_vGunAng.y)
{
EmitSound( "NPC_MissileDefense.Turn" );
}
else
{
StopSound( "NPC_MissileDefense.Turn" );
}
}
//------------------------------------------------------------------------------
// Purpose :
// Input :
// Output :
//------------------------------------------------------------------------------
CNPC_MissileDefense::~CNPC_MissileDefense(void)
{
StopSound( "NPC_MissileDefense.Turn" );
}
| {
"pile_set_name": "Github"
} |
//
// Generated by class-dump 3.5 (64 bit) (Debug version compiled Oct 15 2018 10:31:50).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2015 by Steve Nygard.
//
#import <Foundation/NSDictionary.h>
@class NSOrderedSet;
@interface WFOrderedDictionary : NSDictionary
{
NSOrderedSet *_keys;
NSDictionary *_dictionary;
}
+ (BOOL)supportsSecureCoding;
- (void).cxx_destruct;
@property(readonly, nonatomic) NSDictionary *dictionary; // @synthesize dictionary=_dictionary;
@property(readonly, nonatomic) NSOrderedSet *keys; // @synthesize keys=_keys;
- (Class)classForCoder;
- (void)encodeWithCoder:(id)arg1;
- (id)initWithCoder:(id)arg1;
- (id)copyWithZone:(struct _NSZone *)arg1;
- (id)allKeys;
- (id)initWithObjects:(const id *)arg1 forKeys:(const id *)arg2 count:(unsigned long long)arg3;
- (id)init;
- (id)keyEnumerator;
- (id)objectForKey:(id)arg1;
- (unsigned long long)count;
- (id)initWithQueryItems:(id)arg1;
@end
| {
"pile_set_name": "Github"
} |
/*
* sys/irq.h --- STM32F4 IRQ numbers.
*
* Copyright (C) 2012, Galois, Inc.
* All Rights Reserved.
*
* This software is released under the "BSD3" license. Read the file
* "LICENSE" for more information.
*/
#ifndef __hwfr_sys_irq_h
#define __hwfr_sys_irq_h
#ifdef __cplusplus
extern "C" {
#endif
/**
* IRQ Definition
*/
enum IRQn {
/****** Cortex-M4 Processor Exceptions Numbers * *****************************/
NonMaskableInt_IRQn = -14, // Non Maskable Interrupt
MemoryManagement_IRQn = -12, // Cortex-M4 Memory Management Interrupt
BusFault_IRQn = -11, // Cortex-M4 Bus Fault Interrupt
UsageFault_IRQn = -10, // Cortex-M4 Usage Fault Interrupt
SVCall_IRQn = -5, // Cortex-M4 SV Call Interrupt
DebugMonitor_IRQn = -4, // Cortex-M4 Debug Monitor Interrupt
PendSV_IRQn = -2, // Cortex-M4 Pend SV Interrupt
SysTick_IRQn = -1, // Cortex-M4 System Tick Interrupt
/****** STM32 specific Interrupt Numbers *************************************/
WWDG_IRQn = 0, // Window WatchDog Interrupt
PVD_IRQn = 1, // PVD through EXTI Line detection Interrupt
TAMP_STAMP_IRQn = 2, // Tamper and TimeStamp interrupts through the EXTI line
RTC_WKUP_IRQn = 3, // RTC Wakeup interrupt through the EXTI line
FLASH_IRQn = 4, // FLASH global Interrupt
RCC_IRQn = 5, // RCC global Interrupt
EXTI0_IRQn = 6, // EXTI Line0 Interrupt
EXTI1_IRQn = 7, // EXTI Line1 Interrupt
EXTI2_IRQn = 8, // EXTI Line2 Interrupt
EXTI3_IRQn = 9, // EXTI Line3 Interrupt
EXTI4_IRQn = 10, // EXTI Line4 Interrupt
DMA1_Stream0_IRQn = 11, // DMA1 Stream 0 global Interrupt
DMA1_Stream1_IRQn = 12, // DMA1 Stream 1 global Interrupt
DMA1_Stream2_IRQn = 13, // DMA1 Stream 2 global Interrupt
DMA1_Stream3_IRQn = 14, // DMA1 Stream 3 global Interrupt
DMA1_Stream4_IRQn = 15, // DMA1 Stream 4 global Interrupt
DMA1_Stream5_IRQn = 16, // DMA1 Stream 5 global Interrupt
DMA1_Stream6_IRQn = 17, // DMA1 Stream 6 global Interrupt
ADC_IRQn = 18, // ADC1, ADC2 and ADC3 global Interrupts
CAN1_TX_IRQn = 19, // CAN1 TX Interrupt
CAN1_RX0_IRQn = 20, // CAN1 RX0 Interrupt
CAN1_RX1_IRQn = 21, // CAN1 RX1 Interrupt
CAN1_SCE_IRQn = 22, // CAN1 SCE Interrupt
EXTI9_5_IRQn = 23, // External Line[9:5] Interrupts
TIM1_BRK_TIM9_IRQn = 24, // TIM1 Break interrupt and TIM9 global interrupt
TIM1_UP_TIM10_IRQn = 25, // TIM1 Update Interrupt and TIM10 global interrupt
TIM1_TRG_COM_TIM11_IRQn = 26, // TIM1 Trigger and Commutation Interrupt and TIM11 global interrupt
TIM1_CC_IRQn = 27, // TIM1 Capture Compare Interrupt
TIM2_IRQn = 28, // TIM2 global Interrupt
TIM3_IRQn = 29, // TIM3 global Interrupt
TIM4_IRQn = 30, // TIM4 global Interrupt
I2C1_EV_IRQn = 31, // I2C1 Event Interrupt
I2C1_ER_IRQn = 32, // I2C1 Error Interrupt
I2C2_EV_IRQn = 33, // I2C2 Event Interrupt
I2C2_ER_IRQn = 34, // I2C2 Error Interrupt
SPI1_IRQn = 35, // SPI1 global Interrupt
SPI2_IRQn = 36, // SPI2 global Interrupt
USART1_IRQn = 37, // USART1 global Interrupt
USART2_IRQn = 38, // USART2 global Interrupt
USART3_IRQn = 39, // USART3 global Interrupt
EXTI15_10_IRQn = 40, // External Line[15:10] Interrupts
RTC_Alarm_IRQn = 41, // RTC Alarm (A and B) through EXTI Line Interrupt
OTG_FS_WKUP_IRQn = 42, // USB OTG FS Wakeup through EXTI line interrupt
TIM8_BRK_TIM12_IRQn = 43, // TIM8 Break Interrupt and TIM12 global interrupt
TIM8_UP_TIM13_IRQn = 44, // TIM8 Update Interrupt and TIM13 global interrupt
TIM8_TRG_COM_TIM14_IRQn = 45, // TIM8 Trigger and Commutation Interrupt and TIM14 global interrupt
TIM8_CC_IRQn = 46, // TIM8 Capture Compare Interrupt
DMA1_Stream7_IRQn = 47, // DMA1 Stream7 Interrupt
FSMC_IRQn = 48, // FSMC global Interrupt
SDIO_IRQn = 49, // SDIO global Interrupt
TIM5_IRQn = 50, // TIM5 global Interrupt
SPI3_IRQn = 51, // SPI3 global Interrupt
UART4_IRQn = 52, // UART4 global Interrupt
UART5_IRQn = 53, // UART5 global Interrupt
TIM6_DAC_IRQn = 54, // TIM6 global and DAC1&2 underrun error interrupts
TIM7_IRQn = 55, // TIM7 global interrupt
DMA2_Stream0_IRQn = 56, // DMA2 Stream 0 global Interrupt
DMA2_Stream1_IRQn = 57, // DMA2 Stream 1 global Interrupt
DMA2_Stream2_IRQn = 58, // DMA2 Stream 2 global Interrupt
DMA2_Stream3_IRQn = 59, // DMA2 Stream 3 global Interrupt
DMA2_Stream4_IRQn = 60, // DMA2 Stream 4 global Interrupt
ETH_IRQn = 61, // Ethernet global Interrupt
ETH_WKUP_IRQn = 62, // Ethernet Wakeup through EXTI line Interrupt
CAN2_TX_IRQn = 63, // CAN2 TX Interrupt
CAN2_RX0_IRQn = 64, // CAN2 RX0 Interrupt
CAN2_RX1_IRQn = 65, // CAN2 RX1 Interrupt
CAN2_SCE_IRQn = 66, // CAN2 SCE Interrupt
OTG_FS_IRQn = 67, // USB OTG FS global Interrupt
DMA2_Stream5_IRQn = 68, // DMA2 Stream 5 global interrupt
DMA2_Stream6_IRQn = 69, // DMA2 Stream 6 global interrupt
DMA2_Stream7_IRQn = 70, // DMA2 Stream 7 global interrupt
USART6_IRQn = 71, // USART6 global interrupt
I2C3_EV_IRQn = 72, // I2C3 event interrupt
I2C3_ER_IRQn = 73, // I2C3 error interrupt
OTG_HS_EP1_OUT_IRQn = 74, // USB OTG HS End Point 1 Out global interrupt
OTG_HS_EP1_IN_IRQn = 75, // USB OTG HS End Point 1 In global interrupt
OTG_HS_WKUP_IRQn = 76, // USB OTG HS Wakeup through EXTI interrupt
OTG_HS_IRQn = 77, // USB OTG HS global interrupt
DCMI_IRQn = 78, // DCMI global interrupt
CRYP_IRQn = 79, // CRYP crypto global interrupt
HASH_RNG_IRQn = 80, // Hash and Rng global interrupt
FPU_IRQn = 81 // FPU global interrupt
};
#ifdef __cplusplus
}
#endif
#endif /* __hwfr_sys_irq_h */
| {
"pile_set_name": "Github"
} |
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="线程池并发数目:" />
<EditText
android:id="@+id/config_threadpool_num"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:numeric="integer"
android:singleLine="true"
android:text="5" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="一次模拟的请求数目:" />
<EditText
android:id="@+id/config_request_num"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:numeric="integer"
android:singleLine="true"
android:text="10" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp" >
<Button
android:id="@+id/config_reset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="恢复默认" />
<Button
android:id="@+id/config_confirm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="保存设置" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#e8e8e8"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginTop="10dip"
android:text="并发任务:3个"
android:textColor="#4b4a4a"
android:textSize="16sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:gravity="center"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="3dip"
android:paddingBottom="2dip"
android:text="01"
android:textColor="#4b4a4a"
android:textSize="16sp" />
<SeekBar
android:id="@+id/seekBar1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:focusable="true"
android:max="10"
android:maxHeight="2dip"
android:minHeight="2dip"
android:progress="3"
android:progressDrawable="@drawable/seek_bar_bg"
android:thumb="@drawable/seek_thumb_bar" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="3dip"
android:paddingBottom="2dip"
android:text="10"
android:textColor="#4b4a4a"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="2dip"
android:background="#ebebeb" >
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginTop="10dip"
android:text="模拟任务总数:3个"
android:textColor="#4b4a4a"
android:textSize="16sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:gravity="center"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="3dip"
android:paddingBottom="2dip"
android:text="10"
android:textColor="#4b4a4a"
android:textSize="16sp" />
<SeekBar
android:id="@+id/seekBar2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:focusable="true"
android:max="1000"
android:maxHeight="2dip"
android:minHeight="2dip"
android:progress="50"
android:progressDrawable="@drawable/seek_bar_bg"
android:thumb="@drawable/seek_thumb_bar" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="-1dip"
android:paddingBottom="2dip"
android:text="1000"
android:textColor="#4b4a4a"
android:textSize="16sp" />
</LinearLayout>
</LinearLayout>
<!-- -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dip"
android:background="#e8e8e8"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dip"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginTop="10dip"
android:layout_weight="1"
android:text="私有HTTPDNS服务"
android:textColor="#4b4a4a"
android:textSize="16sp" />
<Switch
android:id="@+id/switch1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dip"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginTop="10dip"
android:textColor="#4b4a4a" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="2dip"
android:background="#ebebeb" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#e8e8e8"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginTop="10dip"
android:layout_weight="1"
android:text="私有HTTPDNS接口"
android:textColor="#4b4a4a"
android:textSize="16sp" />
<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dip"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_weight="1"
android:ems="1" >
<requestFocus />
</EditText>
</LinearLayout>
<!-- -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dip"
android:background="#e8e8e8"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dip"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginTop="10dip"
android:layout_weight="1"
android:text="DNSPOD服务"
android:textColor="#4b4a4a"
android:textSize="16sp" />
<Switch
android:id="@+id/switch2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dip"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginTop="10dip"
android:textColor="#4b4a4a" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="2dip"
android:background="#ebebeb" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#e8e8e8"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginTop="10dip"
android:layout_weight="1"
android:text="DNSPOD 接口"
android:textColor="#4b4a4a"
android:textSize="16sp" />
<EditText
android:id="@+id/editText2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dip"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_weight="1"
android:ems="1" >
<requestFocus />
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="2dip"
android:background="#ebebeb" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#e8e8e8"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginTop="10dip"
android:layout_weight="1"
android:text="DNSPOD ID"
android:textColor="#4b4a4a"
android:textSize="16sp" />
<EditText
android:id="@+id/editText3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dip"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_weight="1"
android:ems="1" >
<requestFocus />
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="2dip"
android:background="#ebebeb" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#e8e8e8"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginTop="10dip"
android:layout_weight="1"
android:text="DNSPOD KEY"
android:textColor="#4b4a4a"
android:textSize="16sp" />
<EditText
android:id="@+id/editText4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dip"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_weight="1"
android:ems="1" >
<requestFocus />
</EditText>
</LinearLayout>
<!-- -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dip"
android:background="#e8e8e8"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dip"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginTop="10dip"
android:layout_weight="1"
android:text="智能排序"
android:textColor="#4b4a4a"
android:textSize="16sp" />
<Switch
android:id="@+id/switch3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dip"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginTop="10dip"
android:textColor="#4b4a4a" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="2dip"
android:background="#ebebeb" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#e8e8e8"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginTop="10dip"
android:text="速度插件比重:40"
android:textColor="#4b4a4a"
android:textSize="16sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:gravity="center"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="3dip"
android:paddingBottom="2dip"
android:text="01"
android:textColor="#4b4a4a"
android:textSize="16sp" />
<SeekBar
android:id="@+id/seekBar3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:focusable="true"
android:max="100"
android:maxHeight="2dip"
android:minHeight="2dip"
android:progress="40"
android:progressDrawable="@drawable/seek_bar_bg"
android:thumb="@drawable/seek_thumb_bar" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="3dip"
android:paddingBottom="2dip"
android:text="100"
android:textColor="#4b4a4a"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="2dip"
android:background="#ebebeb" >
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginTop="10dip"
android:text="模拟任务总数:3个"
android:textColor="#4b4a4a"
android:textSize="16sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:gravity="center"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="3dip"
android:paddingBottom="2dip"
android:text="10"
android:textColor="#4b4a4a"
android:textSize="16sp" />
<SeekBar
android:id="@+id/seekBar2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:focusable="true"
android:max="1000"
android:maxHeight="2dip"
android:minHeight="2dip"
android:progress="50"
android:progressDrawable="@drawable/seek_bar_bg"
android:thumb="@drawable/seek_thumb_bar" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="-1dip"
android:paddingBottom="2dip"
android:text="1000"
android:textColor="#4b4a4a"
android:textSize="16sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout> | {
"pile_set_name": "Github"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.