text:
package org.hsqldb.result;

import org.hsqldb.StatementTypes;

/**
 * An enumeration of the request and response mode values used to communicate
 * between the client and the engine when sending Result objects back
 * and forth.
 *
 * @author Campbell Boucher-Burnet (boucherb@users dot sourceforge.net)
 * @author Fred Toussi (fredt@users dot sourceforge.net)
 * @since 2.1.1
 * @version 1.7.2
 */

// fredt@users - the constants from the SQL standards are used freely where a
// similar function is performed. The Result objects do not necessarily contain
// the same information as stated in SQL standard for CLI.
public interface ResultConstants {

    /** The offset at which HSQLDB API Result mode values start. */
    int HSQL_API_BASE = 0;

    /**
     * Not a result
     */
    int NONE = HSQL_API_BASE + 0;

    /**
     * Indicates that the Result object encapsulates an update
     * count response.
     */
    int UPDATECOUNT = HSQL_API_BASE + 1;

    /**
     * Indicates that the Result object encapsualtes an
     * error response.
     */
    int ERROR = HSQL_API_BASE + 2;

    /**
     * Indicates that the Result object encapsulates a result
     * set response containing data.
     */
    int DATA = HSQL_API_BASE + 3;

    /**
     * Indicates that the Result object encapsulates a response
     * that communicates the acknowlegement of newly allocated
     * Statement object in the form of its statementID
     * and metadata
     */
    int PREPARE_ACK = HSQL_API_BASE + 4;

    /**
     * Indicates that the Result object encapsulates a result
     * set for setting session attributes.
     */
    int SETSESSIONATTR = HSQL_API_BASE + 6;

    /**
     * Indicates that the Result object encapsulates a request
     * to get session attributes.
     */
    int GETSESSIONATTR = HSQL_API_BASE + 7;

    /**
     * Indicates that the Result object encapsulates a batch of statements
     */
    int BATCHEXECDIRECT = HSQL_API_BASE + 8;

    /**
     * Indicates that the Result object encapsulates a batch of prepared
     * statement parameter values
     */
    int BATCHEXECUTE = HSQL_API_BASE + 9;

    /**
     * Indicates that the Result object encapsulates a request to start a new
     * internal session for the connection
     */
    int RESETSESSION = HSQL_API_BASE + 10;

    /**
     * Indicates that the Result object encapsulates a response to a connection
     * attempt that was successful
     */
    int CONNECTACKNOWLEDGE = HSQL_API_BASE + 11;

    /**
     * Indicates that the Result object encapsulates a request to prepare
     * to commit as the first phase of a two-phase commit
     */
    int PREPARECOMMIT = HSQL_API_BASE + 12;

    /**
     * Indicates that the Result object encapsulates a request to return
     * some rows of data
     */
    int REQUESTDATA = HSQL_API_BASE + 13;

    /**
     * Indicates that the Result object encapsulates a set of data rows
     * without metadata
     */
    int DATAROWS = HSQL_API_BASE + 14;

    /**
     * Indicates that the Result object encapsulates a set of data rows
     * with metadata
     */
    int DATAHEAD = HSQL_API_BASE + 15;

    /**
     * Indicates that the Result object encapsulates a set of update counts
     * for a batch execution
     */
    int BATCHEXECRESPONSE = HSQL_API_BASE + 16;

    /**
     * Only for metadata, indicates that the metadata is for the parameters.
     */
    int PARAM_METADATA = HSQL_API_BASE + 17;

    /**
     * Common result type for all large object operations
     */
    int LARGE_OBJECT_OP = HSQL_API_BASE + 18;

    /**
     * Warning
     */
    int WARNING = HSQL_API_BASE + 19;

    /**
     * generated data
     */
    int GENERATED = HSQL_API_BASE + 20;

    /**
     * attempt to execute invalid statement
     */
    int EXECUTE_INVALID = HSQL_API_BASE + 21;

    /**
     * Indicates that Result encapsulates a request to establish a connection.
     */
    int CONNECT = HSQL_API_BASE + 31;

    /**
     * Indicates that Result encapsulates a request to terminate an
     * established connection.
     */
    int DISCONNECT = HSQL_API_BASE + 32;

    /**
     * Indicates that Result encapsulates a request to terminate an
     * SQL-transaction.
     */
    int ENDTRAN = HSQL_API_BASE + 33;

    /**
     * Indicates that Result encapsulates a request to execute a statement
     * directly.
     */
    int EXECDIRECT = HSQL_API_BASE + 34;

    /**
     * Indicates that Result encapsulates a request to execute a prepared
     * statement.
     */
    int EXECUTE = HSQL_API_BASE + 35;

    /**
     * Indicates that Result encapsulates a request to deallocate an
     * SQL-statement.
     */
    int FREESTMT = HSQL_API_BASE + 36;

    /**
     * Indicates that Result encapsulates a request to prepare a statement.
     */
    int PREPARE = HSQL_API_BASE + 37;

    /**
     * Indicates that Result encapsulates a request to set the value of an
     * SQL-connection attribute.
     */
    int SETCONNECTATTR = HSQL_API_BASE + 38;

    /**
     * Indicates that Result encapsulates a request to explicitly start an
     * SQL-transaction and set its characteristics.
     */
    int STARTTRAN = HSQL_API_BASE + 39;

    /**
     * Indicates that the Result encapsulates a request to close a result set
     */
    int CLOSE_RESULT = HSQL_API_BASE + 40;

    /**
     * Indicates that the Result encapsulates a request to update or insert into a result set
     */
    int UPDATE_RESULT = HSQL_API_BASE + 41;

    /**
     * Indicates that the Result encapsulates a simple value for internal use
     */
    int VALUE = HSQL_API_BASE + 42;

    /**
     * Indicates that the Result encapsulates a response to a procedure call via CallableStatement
     */
    int CALL_RESPONSE = HSQL_API_BASE + 43;

    /**
     * Indicates that the Result encapsulates a data change set
     */
    int CHANGE_SET = HSQL_API_BASE + 44;

    /**
     * Constants above this limit are handled as non-HSQLDB results
     */
    int MODE_UPPER_LIMIT = HSQL_API_BASE + 48;

//    /** The offset at which the standard SQL API Result mode values start. */
//    int SQL_API_BASE = 0x00010000;
//
//    /**
//     * Indicates that Result encapsulates a request to allocate an
//     * SQL-connection and assign a handle to it.
//     */
//    int SQLALLOCCONNECT     = SQL_API_BASE + 1;
//    /**
//     * Indicates that Result encapsulates a request to allocate an
//     * SQL-environment and assign a handle to it.
//     */
//    int SQLALLOCENV         = SQL_API_BASE + 2;
//
//    /**
//     * Indicates that Result encapsulates a request to allocate a resource
//     * and assign a handle to it.
//     */
//    int SQLALLOCHANDLE      = SQL_API_BASE + 1001;
//
//    /**
//     * Indicates that Result encapsulates a request to allocate an
//     * SQL-statement and assign a handle to it.
//     */
//    int SQLALLOCSTMT        = SQL_API_BASE + 3;
//
//    /**
//     * Indicates that Result encapsulates a request to describe a target
//     * specification or array of target specifications.
//     */
//    int SQLBINDCOL          = SQL_API_BASE + 4;
//
//    /**
//     * Indicates that Result encapsulates a request to describe a
//     * dynamic parameter specification and its value.
//     */
//    int SQLBINDPARAMETER    = SQL_API_BASE + 72;
//
//    /**
//     * Indicates that Result encapsulates a request to cancel execution of
//     * a CLI routine.
//     */
//    int SQLCANCEL           = SQL_API_BASE + 5;
//
//    /** Indicates that Result encapsulates a request to close a cursor. */
//    int SQLCLOSECURSOR      = SQL_API_BASE + 1003;
//
//    /**
//     * Indicates that Result encapsulates a request to get a
//     * column attribute.
//     */
//    int SQLCOLATTRIBUTE     = SQL_API_BASE + 6;
//
//    /**
//     * Indicates that Result encapsulates a request to return a result set that
//     * contains a list of the privileges held on the columns whose names adhere
//     * to the requested pattern or patterns within a single specified table
//     * stored in the Information Schema of the connected data source.
//     */
//    int SQLCOLUMNPRIVILEGES = SQL_API_BASE + 56;
//
//    /**
//     * Indicates that Result encapsulates a request to, based on the specified
//     * selection criteria, return a result set that contains information about
//     * columns of tables stored in the information schemas of the connected
//     * data source.
//     */
//    int SQLCOLUMNS          = SQL_API_BASE + 40;
//
//
//    /**
//     * Indicates that Result encapsulates a request to establish a connection.
//     */
//    int SQLCONNECT = SQL_API_BASE + 7;
//
//    /**
//     * Indicates that Result encapsulates a request to copy a CLI descriptor.
//     */
//    int SQLCOPYDESC         = SQL_API_BASE + 1004;
//
//    /**
//     * Indicates that Result encapsulates a request to get server name(s) that
//     * the application can connect to, along with description information,
//     * if available.
//     */
//    int SQLDATASOURCES      = SQL_API_BASE + 57;
//
//    /**
//     * Indicates that Result encapsulates a request to get column attributes.
//     */
//    int SQLDESCRIBECOL      = SQL_API_BASE + 8;
//
//
//    /**
//     * Indicates that Result encapsulates a request to terminate an
//     * established connection.
//     */
//    int SQLDISCONNECT = SQL_API_BASE + 9;
//
//    /**
//     * Indicates that Result encapsulates a request to terminate an
//     * SQL-transaction.
//     */
//    int SQLENDTRAN = SQL_API_BASE + 1005;
//
//    /**
//     * Indicates that Result encapsulates a request to return diagnostic
//     * information.
//     */
//    int SQLERROR            = SQL_API_BASE + 10;
//
//    /**
//     * Indicates that Result encapsulates a request to execute a statement
//     * directly.
//     */
//    int SQLEXECDIRECT = SQL_API_BASE + 11;
//
//    /**
//     * Indicates that Result encapsulates a request to execute a prepared
//     * statement.
//     */
//    int SQLEXECUTE = SQL_API_BASE + 12;
//
//    /**
//     * Indicates that Result encapsulates a request to fetch the next row of
//     * a cursor.
//     */
//
//  int SQLFETCH = SQL_API_BASE + 13;
//
//    /**
//     * Indicates that Result encapsulates a request to position a cursor on
//     * the specified row and retrieve values from that row.
//     */
//  int SQLFETCHSCROLL = SQL_API_BASE + 1021;
//    /**
//     * Indicates that Result encapsulates a request to return a result set
//     * that contains information about foreign keys either in or referencing
//     * a single specified table stored in the Information Schema of the
//     * connected data source.
//     */
//    int SQLFOREIGNKEYS      = SQL_API_BASE + 60;
//
//    /**
//     * Indicates that Result encapsulates a request to deallocate an
//     * SQL-connection.
//     */
//    int SQLFREECONNECT      = SQL_API_BASE + 14;
//
//    /**
//     * Indicates that Result encapsulates a request to deallocate an
//     * SQL-environment.
//     */
//    int SQLFREEENV          = SQL_API_BASE + 15;
//
//    /**
//     * Indicates that Result encapsulates a request to free a resource.
//     */
//    int SQLFREEHANDLE       = SQL_API_BASE + 1006;
//
//    /**
//     * Indicates that Result encapsulates a request to deallocate an
//     * SQL-statement.
//     */
//    int SQLFREESTMT = SQL_API_BASE + 16;
//
//    /**
//     * Indicates that Result encapsulates a request to get the value of an
//     * SQL-connection attribute.
//     */
//    int SQLGETCONNECTATTR   = SQL_API_BASE + 1007;
//
//    /**
//     * Indicates that Result encapsulates a request to get a cursor name.
//     */
//    int SQLGETCURSORNAME    = SQL_API_BASE + 17;
//
//    /**
//     * Indicates that Result encapsulates a request to retrieve a column value.
//     */
//    int SQLGETDATA          = SQL_API_BASE + 43;
//
//    /**
//     * Indicates that Result encapsulates a request to get a field from a CLI
//     * descriptor area.
//     */
//    int SQLGETDESCFIELD     = SQL_API_BASE + 1008;
//
//    /**
//     * Indicates that Result encapsulates a request to get commonly-used
//     * fields from a CLI descriptor area.
//     */
//    int SQLGETDESCREC       = SQL_API_BASE + 1009;
//
//    /**
//     * Indicates that Result encapsulates a request to get information from a
//     * CLI diagnostics area.
//     */
//    int SQLGETDIAGFIELD     = SQL_API_BASE + 1010;
//
//    /** Indicates that Result encapsulates a request to get commonly-used
//     * information from a CLI diagnostics area.
//     */
//    int SQLGETDIAGREC       = SQL_API_BASE + 1011;
//
//    /**
//     * Indicates that Result encapsulates a request to get the value of an
//     * SQL-environment attribute.
//     */
//    int SQLGETENVATTR       = SQL_API_BASE + 1012;
//
//    /**
//     * Indicates that Result encapsulates a request to get information
//     * about features supported by the CLI implementation.
//     */
//    int SQLGETFEATUREINFO   = SQL_API_BASE + 1027;
//
//    /**
//     * Indicates that Result encapsulates a request to determine whether a CLI
//     * routine is supported.
//     */
//    int SQLGETFUNCTIONS     = SQL_API_BASE + 44;
//
//    /**
//     * Indicates that Result encapsulates a request to get information about
//     * the implementation.
//     */
//    int SQLGETINFO          = SQL_API_BASE + 45;
//
//    /**
//     * Indicates that Result encapsulates a request to retrieve the length of
//     * the character or octet string value represented by a Large Object
//     * locator.
//     */
//    int SQLGETLENGTH        = SQL_API_BASE + 1022;
//
//    /**
//     * Indicates that Result encapsulates a request to retrieve the value of a
//     * dynamic output parameter.
//     */
//    int SQLGETPARAMDATA     = SQL_API_BASE + 1025;
//
//    /**
//     * Indicates that Result encapsulates a request to retrieve the starting
//     * position of a string value within another string value, where the second
//     * string value is represented by a Large Object locator.
//     */
//    int SQLGETPOSITION      = SQL_API_BASE + 1023;
//
//
//    /**
//     * Indicates that Result encapsulates a request to get information about
//     * general value specifications supported by the implementation.
//     */
//    int SQLGETSESSIONINFO = SQL_API_BASE + 1028;
//    /**
//     * Indicates that Result encapsulates a request to get the value of an
//     * SQL-statement attribute.
//     */
//    int SQLGETSTMTATTR      = SQL_API_BASE + 1014;
//
//    /**
//     * Indicates that Result encapsulates a request to either retrieve a
//     * portion of a character or octet string value that is represented by
//     * a Large Object locator or create a Large Object value at the server
//     * and retrieve a Large Object locator for that value.
//     */
//    int SQLGETSUBSTRING     = SQL_API_BASE + 1024;
//
//    /**
//     * Indicates that Result encapsulates a request to get information about
//     * one or all of the predefined data types supported by the implementation.
//     */
//    int SQLGETTYPEINFO      = SQL_API_BASE + 47;
//
//    /**
//     * Indicates that Result encapsulates a request to determine whether there
//     * are more result sets available on a statement handle and, if there are,
//     * initialize processing for those result sets.
//     */
//  int SQLMORERESULTS = SQL_API_BASE + 61;
//
//    /**
//     * Indicates that Result encapsulates a request to determine whether there
//     * are more result sets available on a statement handle and, if there are,
//     * initialize processing for the next result set on a separate statement
//     * handle.
//     */
//  int SQLNEXTRESULT = SQL_API_BASE + 73;
//    /**
//     * Indicates that Result encapsulates a request to get the number of
//     * result columns of a prepared or executed statement.
//     */
//    int SQLNUMRESULTCOLS = SQL_API_BASE + 18;
//    /**
//     * Indicates that Result encapsulates a request to process a deferred
//     * parameter value. For example, a streamed or locator identified
//     * parameter.
//     */
//    int SQLPARAMDATA        = SQL_API_BASE + 48;
//
//    /**
//     * Indicates that Result encapsulates a request to prepare a statement.
//     */
//    int SQLPREPARE = SQL_API_BASE + 19;
//
//    /**
//     * Indicates that Result encapsulates a request to return a result set that
//     * contains a list of the column names that comprise the primary key for a
//     * single specified table stored in the information schemas of the
//     * connected data source.
//     */
//    int SQLPRIMARYKEYS      = SQL_API_BASE + 65;
//
//    /**
//     * Indicates that Result encapsulates a request to provide a deferred
//     * parameter value. For example, a streamed or locator-identified
//     * parameter.
//     */
//    int SQLPUTDATA          = SQL_API_BASE + 49;
//
//    /**
//     * Indicates that Result encapsulates a request to get the row count of an
//     * executed statement.
//     */
//    int SQLROWCOUNT = SQL_API_BASE + 20;
//
//    /**
//     * Indicates that Result encapsulates a request to set the value of an
//     * SQL-connection attribute.
//     */
//    int SQLSETCONNECTATTR = SQL_API_BASE + 1016;
//
//
//    /** Indicates that Result encapsulates a request to set a cursor name. */
//    int SQLSETCURSORNAME    = SQL_API_BASE + 21;
//
//    /**
//     * Indicates that Result encapsulates a request to set a field in a CLI
//     * descriptor area.
//     */
//    int SQLSETDESCFIELD     = SQL_API_BASE + 1017;
//
//    /**
//     * Indicates that Result encapsulates a request to set commonly-used
//     * fields in a CLI descriptor area.
//     */
//    int SQLSETDESCREC       = SQL_API_BASE + 1018;
//
//
//    /**
//     * Indicates that Result encapsulates a request to set the value of an
//     * SQL-environment attribute.
//     */
//  int SQLSETENVATTR = SQL_API_BASE + 1019;
//    /** Indicates that Result encapsulates a request to set the value of an
//     * SQL-statement attribute.
//     */
//    int SQLSETSTMTATTR      = SQL_API_BASE + 1020;
//
//    /**
//     * Indicates that Result encapsulates a request to return a result set that
//     * contains a list of columns the combined values of which can uniquely
//     * identify any row within a single specified table described by the
//     * Information Schemas of the connected data source.
//     */
//    int SQLSPECIALCOLUMNS   = SQL_API_BASE + 52;
//
//
//    /**
//     * Indicates that Result encapsulates a request to explicitly start an
//     * SQL-transaction and set its characteristics.
//     */
//    int SQLSTARTTRAN = SQL_API_BASE + 74;
//
//    /**
//     * Indicates that Result encapsulates a request to return a result set that
//     * contains a list of the privileges held on the tables whose names adhere
//     * to the requested pattern(s) within tables described by the Information
//     * Schemas of the connected data source.
//     */
//    int SQLTABLES           = SQL_API_BASE + 54;
//
//    /**
//     * Indicates that Result encapsulates a request to, based on the specified
//     * selection criteria, return a result set that contains information about
//     * tables described by the Information Schema of the connected data source.
//     */
//    int SQLTABLEPRIVILEGES  = SQL_API_BASE + 70;
/*
 Codes for transaction termination:

 COMMIT 0
 ROLLBACK 1
 SAVEPOINT NAME ROLLBACK 2
 SAVEPOINT NAME RELEASE 4
 COMMIT AND CHAIN 6
 ROLLBACK AND CHAIN 7
 Implementation-defined termination type <0
 */
    int TX_COMMIT                  = 0;
    int TX_ROLLBACK                = 1;
    int TX_SAVEPOINT_NAME_ROLLBACK = 2;
    int TX_SAVEPOINT_NAME_RELEASE  = 4;
    int TX_COMMIT_AND_CHAIN        = 6;
    int TX_ROLLBACK_AND_CHAIN      = 7;

/* StatementType codes duplicated for cursor operations */
    int UPDATE_CURSOR = StatementTypes.UPDATE_CURSOR;
    int DELETE_CURSOR = StatementTypes.DELETE_CURSOR;
    int INSERT_CURSOR = StatementTypes.INSERT;

/* Environment attributes */

//#define SQL_ATTR_OUTPUT_NTS 10001

/* Connection attributes */

//#define SQL_ATTR_AUTO_IPD 10001
//#define SQL_ATTR_SAVEPOINT_NAME 10027
    int SQL_ATTR_SAVEPOINT_NAME = 10027;

// Batched execution constants:

    /** batch item failed */
    int EXECUTE_FAILED = -3;

    /**
     * Batch item succeeded but does not generate an update count,
     * for example a call having no return value
     */
    int SUCCESS_NO_INFO = -2;
/*
   SQL standard properties
   The operational sensitivity property (either SENSITIVE, INSENSITIVE, or ASENSITIVE).
   The operational scrollability property (either SCROLL or NO SCROLL).
   The operational holdability property (either WITH HOLD or WITHOUT HOLD).
   The operational returnability property (either WITH RETURN or WITHOUT RETURN).
*/
    int SQL_ASENSITIVE    = 0;
    int SQL_INSENSITIVE   = 1;
    int SQL_SENSITIVE     = 2;
    int SQL_NONSCROLLABLE = 0;
    int SQL_SCROLLABLE    = 1;
    int SQL_NONHOLDABLE   = 0;
    int SQL_HOLDABLE      = 1;

//
    int SQL_WITHOUT_RETURN = 0;
    int SQL_WITH_RETURN    = 1;
    int SQL_NOT_UPDATABLE  = 0;
    int SQL_UPDATABLE      = 1;

// data result properties - matching java.sql.ResultSet constants
    int TYPE_FORWARD_ONLY       = 1003;
    int TYPE_SCROLL_INSENSITIVE = 1004;
    int TYPE_SCROLL_SENSITIVE   = 1005;

    //
    int CONCUR_READ_ONLY = 1007;
    int CONCUR_UPDATABLE = 1008;

    //
    int HOLD_CURSORS_OVER_COMMIT = 1;
    int CLOSE_CURSORS_AT_COMMIT  = 2;

    /** Constants indicating generated key return behaviour */
    int RETURN_GENERATED_KEYS             = 1;     // matching java.sql.Statement constant
    int RETURN_NO_GENERATED_KEYS          = 2;     // matching java.sql.Statement constant
    int RETURN_GENERATED_KEYS_COL_NAMES   = 11;    // constant in HSQLDB only
    int RETURN_GENERATED_KEYS_COL_INDEXES = 21;    // constant in HSQLDB only
}


text:
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = multiplyB;
/**
 * multiplies {from} deltas to {left} and {right}
 * @param {Matrix} product
 * @param {Matrix} left
 * @param {Matrix} right
 */
function multiplyB(product, left, right) {
  var leftRows = left.rows;
  var leftColumns = left.columns;
  var rightColumns = right.columns;

  // loop over rows of left
  for (var leftRow = 0; leftRow < leftRows; leftRow++) {
    var leftRowBase = leftColumns * leftRow;
    var rightRowBase = rightColumns * leftRow;
    // loop over cols of right
    for (var rightColumn = 0; rightColumn < rightColumns; rightColumn++) {

      //loop over columns of left
      for (var leftColumn = 0; leftColumn < leftColumns; leftColumn++) {
        var rightColumnBase = rightColumns * leftColumn;
        var _leftRow = leftRowBase + leftColumn;
        var rightRow = rightColumnBase + rightColumn;
        var backPropagateValue = product.deltas[rightRowBase + rightColumn];
        left.deltas[_leftRow] += right.weights[rightRow] * backPropagateValue;
        right.deltas[rightRow] += left.weights[_leftRow] * backPropagateValue;
      }
    }
  }
}
//# sourceMappingURL=multiply-b.js.map

redpajama_set_name: RedPajamaGithub


text:
START_ATF_NAMESPACE
    namespace Info
    {
        using _guild_member_infoIsFill2_ptr = bool (WINAPIV*)(struct _guild_member_info*);
        using _guild_member_infoIsFill2_clbk = bool (WINAPIV*)(struct _guild_member_info*, _guild_member_infoIsFill2_ptr);

        using _guild_member_infoctor__guild_member_info4_ptr = void (WINAPIV*)(struct _guild_member_info*);
        using _guild_member_infoctor__guild_member_info4_clbk = void (WINAPIV*)(struct _guild_member_info*, _guild_member_infoctor__guild_member_info4_ptr);
        using _guild_member_infoinit6_ptr = void (WINAPIV*)(struct _guild_member_info*);
        using _guild_member_infoinit6_clbk = void (WINAPIV*)(struct _guild_member_info*, _guild_member_infoinit6_ptr);
    }; // end namespace Info
END_ATF_NAMESPACE


text:
class Scene;

class SceneManagerService : public Service
{
public:
    SceneManagerService();
    ~SceneManagerService();

    virtual void initialize() override;
    virtual void terminate() override;

    void updateCurrentScene(float deltaTime);
    void drawCurrentScene(float deltaTime);
    void startWith(Scene* firstScene);
    void to(Scene* nextScene);

    READONLY_PROPERTY(bool, isStarted)
private:
    Scene* _currentScene;
};


text: Web stories core dashboard.


text:
package com.ubiquity.datastorage.kernel.exceptions;

public class ObjectTypeCannotBeAnIndexException extends UbiquityException {
    public ObjectTypeCannotBeAnIndexException(String fieldName) {
        super("Field \"" + fieldName + "\" is indexed and is of 'OBJECT' type");
    }
}


text:
class AddAdministrativeToPrivilege < ActiveRecord::Migration[5.2]
  def up
    unless column_exists?(:privileges, :administrative)
      add_column :privileges, :administrative, :boolean, default: true, null: false
    end
  end

  def down
    # No need to rollback
  end
end


text:
package br.com.arbo.java.util.concurrent;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.function.Supplier;

public class Parallel<T> implements Supplier<T> {

	public Parallel(Supplier<T> loader) {
		this.loader = loader;
		this.executor = newSingleDaemonThread();
	}

	@Override
	public T get() {
		return FutureUtils.get(state);
	}

	public void start() {
		this.submit();
	}

	public void stop() {
		executor.shutdown();
	}

	public void submit() {
		this.state = this.executor.submit(loader::get);
	}

	private ExecutorService newSingleDaemonThread() {
		return Executors.newFixedThreadPool(
				1, DaemonThreadFactory.forClass(this.getClass()));
	}

	private final ExecutorService executor;

	private final Supplier<T> loader;

	private Future<T> state;
}


text:
if (typeof chromeDevice == "undefined") {

var DEBUG = false;
var logger = null;

function debug(message) {
  if (DEBUG) {
    //console.log(message);
  }
  if (logger == null)
    logger = new ledger.utils.ApduLogger("APDU", DEBUG);
  logger.trace(message)
}

function dump(array) {
  var hexchars = '0123456789ABCDEF';
  var hexrep = new Array(array.length * 2);

  for (var i = 0; i < array.length; i++) {
    hexrep[2 * i] = hexchars.charAt((array[i] >> 4) & 0x0f);
    hexrep[2 * i + 1] = hexchars.charAt(array[i] & 0x0f);
  }
  return hexrep.join('');
}

function hexToArrayBuffer(h) {
  var result = new ArrayBuffer(h.length / 2);
  var hexchars = '0123456789ABCDEFabcdef';
  var res = new Uint8Array(result);
  for (var i = 0; i < h.length; i += 2) {
    if (hexchars.indexOf(h.substring(i, i + 1)) == -1) break;
    res[i / 2] = parseInt(h.substring(i, i + 2), 16);
  }
  return result;
}

function winUSBDevice(hardwareId) {
    this.hardwareId = hardwareId;
    this.closedDevice = false;
    this.claimed = false;
    this.device = hardwareId.device;
    // Mark claimed
    for (var i=0; i<winUSBDevice.unclaimedDevices.length; i++) {
      if (winUSBDevice.unclaimedDevices.handle == this.device.handle) {
          winUSBDevice.unclaimedDevices[i] = undefined;
          break;
      }
    }
    // Locate the interface to open, the in/out endpoints and their sizes
    for (var i=0; i<hardwareId.interfaces.length; i++) {
      if (hardwareId.interfaces[i].interfaceClass == 0xff) {
          this.interfaceId = i;
          var currentInterface = hardwareId.interfaces[i];
          for (var j=0; j<currentInterface.endpoints.length; j++) {
              var currentEndpoint = currentInterface.endpoints[j];
              if (currentEndpoint.direction == "in") {
                  this.inEndpoint = 0x80 + currentEndpoint.address;
              }
              else
              if (currentEndpoint.direction == "out") {
                  this.outEndpoint = currentEndpoint.address;
              }
          }
      }
    }
}

winUSBDevice.prototype.open = function(callback) {
    debug("Open winUSBDevice " + this.interfaceId);
    debug(this.device);
    var currentDevice = this;
    chrome.usb.claimInterface(this.device, this.interfaceId, function() {
        currentDevice.claimed = true;
        chrome.runtime.sendMessage({usbClaimed: currentDevice});
        if (callback) callback(true);
    });
}

winUSBDevice.prototype.send = function(data, callback) {
      debug("=> " + data);
      chrome.usb.bulkTransfer(this.device,
        {
          direction: "out",
          endpoint: this.outEndpoint,
          data: hexToArrayBuffer(data)
        },
        function(result) {
          if (callback) {
            var exception = (result.resultCode != 0 ? "error " + result.resultCode : undefined);
            callback({
              resultCode: result.resultCode,
              exception: exception
            });
          }
        });
}

winUSBDevice.prototype.recv = function(size, callback) {
      chrome.usb.bulkTransfer(this.device,
        {
          direction: "in",
          endpoint: this.inEndpoint,
          length: size
        },
        function(result) {
            var data;
            if (result.resultCode == 0) {
              data = dump(new Uint8Array(result.data));
            }
            debug("<= " + data);
            if (callback) {
                var exception = (result.resultCode != 0 ? "error " + result.resultCode : undefined);
                callback({
                  resultCode: result.resultCode,
                  data: data,
                  exception: exception
              });
            }
        });
}

winUSBDevice.prototype.close = function(callback) {
    var currentDevice = this;
    if (this.claimed) {
      chrome.usb.releaseInterface(this.device, this.interfaceId, function() {
        currentDevice.claimed = false;
        chrome.usb.closeDevice(currentDevice.device, function() {
          currentDevice.closedDevice = true;
          chrome.runtime.sendMessage({usbClosed: currentDevice});
          if (callback) callback();
        });
      });
    }
    else
    if (!this.closedDevice) {
        chrome.usb.closeDevice(currentDevice.device, function() {
          currentDevice.closedDevice = true;
          chrome.runtime.sendMessage({usbClosed: currentDevice});
          if (callback) callback();
        });
    }
    else {
      if (callback) callback();
    }
}

winUSBDevice.unclaimedDevices = [];

winUSBDevice.enumerate = function(vid, pid, callback) {
  // First close all unclaimed devices to avoid leaking
  for (var i=0; i<winUSBDevice.unclaimedDevices.length; i++) {
    if (typeof winUSBDevice.unclaimedDevices[i] != "undefined") {
      debug("Closing");
      debug(winUSBDevice.unclaimedDevices[i]);
      chrome.usb.closeDevice(winUSBDevice.unclaimedDevices[i]);
    }
  }
  winUSBDevice.unclaimedDevices = [];
  chrome.usb.findDevices({
    vendorId: vid,
    productId: pid
  },
  function(devices) {
    debug(devices);

    var probedDevicesWithInterfaces = [];
    var probedDevices = 0;

    if (devices.length == 0) {
      // No devices, answer immediately
      if (callback) callback([]);
    }

    // Locate suitable interfaces

    for (var currentDevice=0; currentDevice<devices.length; currentDevice++) {
      (function(currentDevice) {
        chrome.usb.listInterfaces(devices[currentDevice], function(interfaceList) {
          probedDevices++;
          // If the device has at least one WinUSB interface, it can be probed
          var hasWinUSB = false;
          for (var i=0; i<interfaceList.length; i++) {
            if (interfaceList[i].interfaceClass == 0xff) {
              hasWinUSB = true;
              break;
            }
          }
          if (hasWinUSB) {
            winUSBDevice.unclaimedDevices.push(devices[currentDevice]);
            probedDevicesWithInterfaces.push({
              device: devices[currentDevice],
              interfaces: interfaceList,
              transport: 'winusb'
            });
          }
          else {
            debug("Closing");
            debug(devices[currentDevice]);
            chrome.usb.closeDevice(devices[currentDevice]);
          }
          if (probedDevices == devices.length) {
            if (callback) callback(probedDevicesWithInterfaces);
          }
        }); // chrome.usb.listInterfaces
      })(currentDevice); // per device closure
    }
  }); // chrome.usb.findDevices
}

function hidDevice(hardwareId) {
    this.hardwareId = hardwareId;
    this.closedDevice = false;
    this.claimed = false;
    this.device = hardwareId.device;
}

hidDevice.prototype.open = function(callback) {
    debug("Open hidDevice");
    debug(this.device);
    var currentDevice = this;
    chrome.hid.connect(this.device.deviceId, function (handle) {
      if (!handle) {
        debug("failed to connect");
        if (callback) callback(false);
      }
      currentDevice.claimed = true;
      chrome.runtime.sendMessage({usbClaimed: currentDevice});
      currentDevice.handle = handle;
      if (callback) callback(true);
    });
}

hidDevice.prototype.send = function(data, callback) {
  debug("=> " + data);
  if (typeof this.handle === "undefined" || this.handle === null) {
    if (callback)
      callback({resultCode: 0, exception: new Error()});
    return;
  }
  chrome.hid.send(this.handle.connectionId, 0, hexToArrayBuffer(data), function() {
    if (callback) {
      var exception = (chrome.runtime.lastError ? "error " + chrome.runtime.lastError : undefined);
        callback({
          resultCode: 0,
          exception: exception
        });
    }
  });
}

hidDevice.prototype.recv = function(size, callback) {
  chrome.hid.receive(this.handle.connectionId, function(reportId, data) {
    var receivedData;
    if (!chrome.runtime.lastError && data) {
      receivedData = dump(new Uint8Array(data));
    }
    debug("<= " + receivedData);
    if (callback) {
      var exception = ((chrome.runtime.lastError || !data) ? "error " + chrome.runtime.lastError : undefined);
      callback({
        resultCode: 0,
        data: receivedData,
        exception: exception
      });
    }
  });
}

hidDevice.prototype.close = function(callback) {
    var currentDevice = this;
    if (this.claimed) {
      chrome.hid.disconnect(this.handle.connectionId, function() {
        currentDevice.claimed = false;
        currentDevice.closedDevice = true;
        chrome.runtime.sendMessage({usbClosed: currentDevice});
        if (callback) callback();
      })
    }
    else {
      currentDevice.closedDevice = true;
      chrome.runtime.sendMessage({usbClosed: currentDevice});
      if (callback) callback();
    }
}

hidDevice.enumerate = function(vid, pid, usagePage, ledger, callback) {
  function enumerated(deviceArray) {
    var probedDevices = [];
    for (var i=0; i<deviceArray.length; i++) {
      probedDevices.push({
        device: deviceArray[i],
        transport: 'hid',
        ledger: ledger
      });
    }
    if (callback) callback(probedDevices);
  }

  var done = false;

  if (!chrome.hid) {
    // Chrome < 38
    debug("HID is not available");
    enumerated([]);
    return;
  }

  if (typeof usagePage != 'undefined') {
    try {
      // Chrome 39+ only
      chrome.hid.getDevices({filters: [{usagePage: usagePage}]}, enumerated);
      done = true;
    }
    catch(e) {
    }
  }
  if (!done) {
    try {
      // Chrome 39+ only
      chrome.hid.getDevices({filters: [{vendorId: vid, productId:pid}]}, enumerated);
      done = true;
    }
    catch(e) {
      debug(e);
    }
  }
  if (!done) {
    try {
      // Chrome 38
      chrome.hid.getDevices({vendorId: vid, productId:pid}, enumerated);
    }
    catch(e) {
      debug("All HID enumeration methods failed");
      enumerated([]);
    }
  }
}

var boundDevices = [];

var chromeDevice = function(enumeratedDevice) {
  this.device = enumeratedDevice;
}

chromeDevice.prototype.open_async = function() {
  var currentDevice = this;
  var msg = {
    parameters: {
      device: this.device
    }
  };

  var deferred = Q.defer();
  var parameters = msg.parameters;
  var device;
  if (parameters.device.transport == 'winusb') {
    device = new winUSBDevice(parameters.device);
  }
  else
  if (parameters.device.transport == 'hid') {
    device = new hidDevice(parameters.device);
  }
  boundDevices.push(device);
  var id = boundDevices.length - 1;
  device.open(function(result) {
    deferred.resolve({
      deviceId: id
    });
  });

  return deferred.promise.then(function(result) {
    currentDevice.id = result.deviceId;
  });
}

chromeDevice.prototype.send_async = function(data) {
  var msg = {
    parameters: {
      deviceId: this.id,
      data: data
    }
  };
  var deferred = Q.defer();
  var parameters = msg.parameters;
  var device = boundDevices[msg.parameters.deviceId]
  device.send(parameters.data, function(result) {
    deferred.resolve(result);
  });
  return deferred.promise;
}

chromeDevice.prototype.recv_async = function(size) {
  var msg = {
    parameters: {
      deviceId: this.id,
      size: size
    }
  };
  var deferred = Q.defer();
  var parameters = msg.parameters;
  var device = boundDevices[msg.parameters.deviceId]
  device.recv(parameters.size, function(result) {
    deferred.resolve(result);
  });
  return deferred.promise;
}

chromeDevice.prototype.close_async = function() {
  var msg = {
    parameters: {
      deviceId: this.id
    }
  };
  var deferred = Q.defer();

  var device = boundDevices[msg.parameters.deviceId];
  device.close(function() {
    deferred.resolve({});
  });
  return deferred.promise;
}

chromeDevice.enumerateDongles_async = function(pid) {
  var msg = {
    parameters: {
      vid: 0x2581,
      pid: pid || 0x1b7c
    }
  };

  var deferred = Q.defer();

  var vid = 0x2581;
  var pid = 0x1808;
  var parameters = msg.parameters;
  if (typeof parameters.vid != "undefined") {
    vid = parameters.vid;
  }
  if (typeof parameters.pid != "undefined") {
    pid = parameters.pid;
  }
  var vidHid = 0x2581;
  var pidHid = pid;
  var pidHid2 = pidHid;
  var pidHid3 = pidHid;
  var usagePage;
  // Probe automatically the associated transport supposing the client used the WinUSB transport
  if (pid == 0x1808) {
    pidHid = 0x1807;
  }
  else
  if (pid == 0x1b7c) {
    pidHid = 0x2b7c; // LW Legacy - old
    pidHid2 = 0x3b7c; // LW Legacy - Ledger Protocol
    pidHid3 = 0x4b7c; // LW Proton
  }
  debug("Looking up " + vid +  " " + pid);

  winUSBDevice.enumerate(vid, pid, function(devicesWinUSB) {
    debug("WinUSB devices");
    debug(devicesWinUSB);
    hidDevice.enumerate(vidHid, pidHid, usagePage, false, function(devicesHID) {
      debug("HID devices");
      debug(devicesHID);
      hidDevice.enumerate(vidHid, pidHid2, usagePage, true, function(devicesHID2) {
        debug("HID devices 2");
        debug(devicesHID2);
	hidDevice.enumerate(vidHid, pidHid3, usagePage, true, function(devicesHID3) {
		debug("HID devices 3");
		debug(devicesHID3);
        	for (var i=0; i<devicesHID.length; i++) {
          		devicesWinUSB.push(devicesHID[i]);
        	}
        	if (pidHid2 != pidHid) {
          		for (var i=0; i<devicesHID2.length; i++) {
            			devicesWinUSB.push(devicesHID2[i]);
          		}
        	}
		if (pidHid3 != pidHid) {
			for (var i=0; i<devicesHID3.length; i++) {
				devicesWinUSB.push(devicesHID3[i]);
			}
		}
        	deferred.resolve({
          		deviceList: devicesWinUSB
        	});
      	});
      });
   });
  });

  return deferred.promise;
}

}


text:
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.senac.tadsb.pi3.livrarianext.servicos;

import br.senac.tadsb.pi3.livrarianext.database.Dao;
import br.senac.tadsb.pi3.livrarianext.exceptions.*;

/**
 *
 * @author roger
 * @param <T>
 */
public abstract class Servico<T> {

    protected Dao dao;

    public Servico(Dao dao){
        this.dao = dao;
    }

    protected void incluir(T dominio) throws ServicoException {
        try
        {
            dao.incluir(dominio);
        }
        catch(DaoException dx)
        {
            dx.printStackTrace();
            throw new ServicoException(dx.getMessage());
        }
    }
    protected void alterar(T dominio) throws ServicoException{
        try
        {
            dao.alterar(dominio);
        }
        catch(DaoException dx)
        {
            dx.printStackTrace();
            throw new ServicoException(dx.getMessage());
        }
    }
    protected void excluir(T dominio) throws ServicoException {
        try
        {
            dao.excluir(dominio);
        }
        catch(DaoException dx)
        {
            dx.printStackTrace();
            throw new ServicoException(dx.getMessage());
        }
    }
}


text:
package mesosphere.marathon.client.model.v2;

import mesosphere.client.common.ModelUtils;

public class HealthCheckResults {
    private Boolean alive;
    private Integer consecutiveFailures;
    private String firstSuccess;
    private String lastFailure;
    private String lastSuccess;
    private String lastFailureCause;
    private String taskId;

    public Boolean getAlive() {
        return alive;
    }

    public void setAlive(Boolean alive) {
        this.alive = alive;
    }

    public Integer getConsecutiveFailures() {
        return consecutiveFailures;
    }

    public void setConsecutiveFailures(Integer consecutiveFailures) {
        this.consecutiveFailures = consecutiveFailures;
    }

    public String getFirstSuccess() {
        return firstSuccess;
    }

    public void setFirstSuccess(String firstSuccess) {
        this.firstSuccess = firstSuccess;
    }

    public String getLastFailure() {
        return lastFailure;
    }

    public void setLastFailure(String lastFailure) {
        this.lastFailure = lastFailure;
    }

    public String getLastSuccess() {
        return lastSuccess;
    }

    public void setLastSuccess(String lastSuccess) {
        this.lastSuccess = lastSuccess;
    }

    public String getLastFailureCause() {
        return lastFailureCause;
    }

    public void setLastFailureCause(String lastFailureCause) {
        this.lastFailureCause = lastFailureCause;
    }

    public String getTaskId() {
        return taskId;
    }

    public void setTaskId(String taskId) {
        this.taskId = taskId;
    }

    @Override
    public String toString() {
        return ModelUtils.toString(this);
    }
}


text:
Load and parse toml files easily

[![Build Status](https://img.shields.io/travis/kerhong/toml-loader.svg)](https://travis-ci.org/kerhong/toml-loader)
[![Crates.io](https://img.shields.io/crates/v/toml-loader.svg)](https://crates.io/crates/toml-loader)
[![Coveralls.io](https://img.shields.io/coveralls/kerhong/toml-loader.svg)](https://coveralls.io/github/kerhong/toml-loader)

## License
MIT

## Documentation
[https://kerhong.github.io/toml-loader](https://kerhong.github.io/toml-loader)

## Examples
```rust
use toml_loader::Loader
use std::path::Path;

let toml = Loader::from_file(Path::new("some.toml")).unwrap();
```


text:
Error originates from HTTP status
=================================

By default, Cycles treats a response with HTTP status above 400 (including 400)
as a failure -- a NSError object will be created and passed as parameter `error`
to the `completionHandler`::

  Cycle.get("http://www.apple.com/404/",
      completionHandler: {cycle, error in
          println("\(error!.domain)") // CycleError
          println("\(CycleErrorCode.fromRaw(error!.code))") // StatusCodeSeemsToHaveErred
          println("\(cycle.response.statusCode)") // 404
      })

This behavior helps you write less code since you don't have to examine status code
for "logic errors". And if you handle the NSError objects in certain ways like
displaying a visual clue, these "logic errors" will also be presented which is
good in most cases.

If you want to handle the status code all by yourself (no longer creates NSError
objects for status above 400), you can change the behavior through the delegate
of the Session. Steps:

#. Create a class conforms to SessionDelegate.
#. Implement this optional method for the class::

    sessionShouldTreatStatusCodeAsFailure(session: Session, status: Int) -> Bool;

#. Create an object of this class and assign this object as the property `delegate`
   of the Session.

::

  class SessionDelegateNoneStatusFailure : SessionDelegate {
      func sessionShouldTreatStatusCodeAsFailure(session: Session, status: Int) -> Bool {
          return false
      }
  }

  let TheDelegate = SessionDelegateNoneStatusFailure()

  func foo() {
    var URL = tu_("http://www.apple.com/404/")
    var cycle = Cycle(requestURL: URL)
    // Make sure TheDelegate exist until the response is received
    cycle.session.delegate = TheDelegate

    cycle.start { (cycle, error) in
      if !error {
        println("none error") // none error
      }
      println("\(cycle.response.statusCode)") // 404
    }
  }

  foo()

In this code snippet, the method `sessionShouldTreatStatusCodeAsFailure` of
SessionDelegateNoneStatusFailure always returns false, meaning that no status
code will be treated as error. Also, a SessionDelegateNoneStatusFailure is
created and assigned to a Session as the property `delegate`.

.. note:: The property `delegate` is a weak reference. Make sure the object it
          references to exist until the response is received.


text:
require 'spec_helper'

begin
  ActiveRecord::Base.connection
rescue ActiveRecord::ConnectionNotEstablished
  ActiveRecord::Base.establish_connection(
    adapter: 'postgresql',
    host: 'localhost',
    database: 'ancestry_joins_test'
  )
end

ActiveRecord::Schema.define do
  create_table :items, force: true do |t|
    t.string :name
    t.string :ancestry
  end
  add_index :items, :ancestry
end

describe AncestryJoins do
  class Item < ActiveRecord::Base
    self.table_name = 'items'
    has_ancestry
    include AncestryJoins
  end

  before(:all) do
    # data setup
    a1 = Item.create name: 'a1'
    a2 = Item.create name: 'a2', parent: a1
    a3 = Item.create name: 'a3', parent: a2

    b1 = Item.create name: 'b1'
    b2 = Item.create name: 'b2', parent: b1
    b22 = Item.create name: 'b22', parent: b1
  end

  context 'all records' do
    it 'returns with parents' do
      expect(Item.all.with_ancestors.map(&:name)).to match_array(%w(
        a1
        a2 a1
        a3 a2 a1
        b1
        b2  b1
        b22 b1
      ))
    end
  end

  describe '#with_ancestors' do
    def names_for(name, **options)
      Item.where(name: name).with_ancestors(**options).map(&:name)
    end

    it 'returns itself' do
      expect(names_for('a1')).to(match_array(%w(a1)))
    end

    it 'returns itself and parents' do
      expect(names_for('a2')).to(match_array(%w(a1 a2)))
      expect(names_for('a3')).to(match_array(%w(a1 a2 a3)))
    end

    it 'returns first parent' do
      expect(names_for('a3', nth: 1)).to(match_array(%w(a1)))
    end
    it 'returns last child' do
      expect(names_for('a3', nth_reverse: 1)).to(match_array(%w(a3)))
    end
  end

  describe '#with_ancestors_only' do
    def names_for(name)
      Item.where(name: name).with_ancestors_only.map(&:name)
    end

    it 'returns nothing' do
      expect(names_for('a1')).to be_empty
    end

    it 'returns only its parent' do
      expect(names_for('a2')).to(match_array(%w(a1)))
      expect(names_for('a3')).to(match_array(%w(a1 a2)))
    end
  end

  describe '#with_ancestors_leafs_only' do
    it 'returns only children' do
      children = Item.with_ancestors_leafs_only.map(&:name)
      expect(children).to(
        match_array(%w(a3 b2 b22))
      )
    end
  end
end


text:
@if "%_echo%"=="" echo off
call %~d0%~p0..\..\..\..\config.bat

IF /I "%INSTALL_SKU%" NEQ "ULTIMATE" (
    echo Test not supported except on Ultimate
    exit /b 0
)

"%MSBUILDTOOLSPATH%\msbuild.exe" ..\netcore.sln /p:Configuration=Debug /p:TestProfile=Profile259 /t:Rebuild
exit /b %ERRORLEVEL%


text:
require 'spec_helper'

describe Rack::AMQP::Server do
  it 'passes input to rack'
  it 'keeps running'

  it 'calls handle_request on event input'

  describe '#construct_app' do
    it 'builds a Rack app with the given rackup file inside'
  end

  describe '#default_env' do
    it 'looks like HTTP enough'
  end

  describe 'command line' do
    it 'handles when the user forgets to specity the rackup file'
  end

  describe 'client failures' do
    it 'handles when the client forgets to specify the http_method'
  end
end


text:
This project contains some enhancements to the xv6 core, including:

- Process parents and forking,
- new scheduling method,
- process priority and queuing,
- `nice()`-like feature and priority management functionality,
- initialization by parent process,
- and some other experiments.

### xv6 Educational Operating System

xv6 is a re-implementation of Dennis Ritchie's and Ken Thompson's Unix
Version 6 (v6). xv6 loosely follows the structure and style of v6,
but it is implemented for a modern x86-based multiprocessor using ANSI C.

### Copyright and License

All copyrighted materials and licenses belong to the respected authors or copyright owners.


text:
<?php
// Filename: /module/Application/src/Application/Model/User.php
namespace Application\Model;

class DebtListItem
{
    public $DT_RowId;
    public $username;
    public $agency;
    public $provider;
    public $agency_pay;
    public $provider_pay;
    public $total;
}


text:
package org.apache.hadoop.hdfs.server.federation.router;

import static org.apache.hadoop.hdfs.server.federation.FederationTestUtils.createFile;
import static org.apache.hadoop.hdfs.server.federation.FederationTestUtils.verifyFileExists;
import static org.apache.hadoop.test.GenericTestUtils.getMethodName;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.verify;

import java.io.IOException;
import java.util.List;
import java.util.Arrays;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;

import org.apache.hadoop.fs.FileContext;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hdfs.DFSClient;
import org.apache.hadoop.hdfs.protocol.ClientProtocol;
import org.apache.hadoop.hdfs.server.federation.MiniRouterDFSCluster;
import org.apache.hadoop.hdfs.server.federation.MiniRouterDFSCluster.RouterContext;
import org.apache.hadoop.hdfs.server.federation.resolver.RemoteLocation;
import org.apache.hadoop.ipc.RemoteException;
import org.apache.hadoop.security.GroupMappingServiceProvider;
import org.apache.hadoop.test.LambdaTestUtils;
import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableSet;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.mockito.Mockito;

/**
 * Basic tests of router federation rename. Rename across namespaces.
 */
public class TestRouterFederationRename extends TestRouterFederationRenameBase {

  public static class MockGroupsMapping implements
      GroupMappingServiceProvider {

    @Override
    public List<String> getGroups(String user) {
      return Arrays.asList(user+"_group");
    }

    @Override
    public void cacheGroupsRefresh() {
    }

    @Override
    public void cacheGroupsAdd(List<String> groups) {
    }

    @Override
    public Set<String> getGroupsSet(String user) {
      return ImmutableSet.of(user+"_group");
    }
  }

  private RouterContext router;
  private FileSystem routerFS;
  private MiniRouterDFSCluster cluster;

  @BeforeClass
  public static void before() throws Exception {
    globalSetUp();
  }

  @AfterClass
  public static void after() {
    tearDown();
  }

  @Before
  public void testSetup() throws Exception {
    setup();
    router = getRouterContext();
    routerFS = getRouterFileSystem();
    cluster = getCluster();
  }

  private void testRenameDir(RouterContext testRouter, String path,
      String renamedPath, boolean exceptionExpected, Callable<Object> call)
      throws IOException {
    createDir(testRouter.getFileSystem(), path);
    // rename
    boolean exceptionThrown = false;
    try {
      call.call();
      assertFalse(verifyFileExists(testRouter.getFileSystem(), path));
      assertTrue(
          verifyFileExists(testRouter.getFileSystem(), renamedPath + "/file"));
    } catch (Exception ex) {
      exceptionThrown = true;
      assertTrue(verifyFileExists(testRouter.getFileSystem(), path + "/file"));
      assertFalse(verifyFileExists(testRouter.getFileSystem(), renamedPath));
    } finally {
      FileContext fileContext = testRouter.getFileContext();
      fileContext.delete(new Path(path), true);
      fileContext.delete(new Path(renamedPath), true);
    }
    if (exceptionExpected) {
      // Error was expected.
      assertTrue(exceptionThrown);
    } else {
      // No error was expected.
      assertFalse(exceptionThrown);
    }
  }

  @Test
  public void testSuccessfulRbfRename() throws Exception {
    List<String> nss = cluster.getNameservices();
    String ns0 = nss.get(0);
    String ns1 = nss.get(1);

    // Test successfully rename a dir to a destination that is in a different
    // namespace.
    String dir =
        cluster.getFederatedTestDirectoryForNS(ns0) + "/" + getMethodName();
    String renamedDir =
        cluster.getFederatedTestDirectoryForNS(ns1) + "/" + getMethodName();
    testRenameDir(router, dir, renamedDir, false, () -> {
      DFSClient client = router.getClient();
      ClientProtocol clientProtocol = client.getNamenode();
      clientProtocol.rename(dir, renamedDir);
      return null;
    });
    testRenameDir(router, dir, renamedDir, false, () -> {
      DFSClient client = router.getClient();
      ClientProtocol clientProtocol = client.getNamenode();
      clientProtocol.rename2(dir, renamedDir);
      return null;
    });
  }

  @Test
  public void testRbfRenameFile() throws Exception {
    List<String> nss = cluster.getNameservices();
    String ns0 = nss.get(0);
    String ns1 = nss.get(1);

    // Test router federation rename a file.
    String file =
        cluster.getFederatedTestDirectoryForNS(ns0) + "/" + getMethodName();
    String renamedFile =
        cluster.getFederatedTestDirectoryForNS(ns1) + "/" + getMethodName();
    createFile(routerFS, file, 32);
    getRouterFileSystem().mkdirs(new Path(renamedFile));
    LambdaTestUtils.intercept(RemoteException.class, "should be a directory",
        "Expect RemoteException.", () -> {
          DFSClient client = router.getClient();
          ClientProtocol clientProtocol = client.getNamenode();
          clientProtocol.rename(file, renamedFile);
          return null;
        });
    LambdaTestUtils.intercept(RemoteException.class, "should be a directory",
        "Expect RemoteException.", () -> {
          DFSClient client = router.getClient();
          ClientProtocol clientProtocol = client.getNamenode();
          clientProtocol.rename2(file, renamedFile);
          return null;
        });
    getRouterFileSystem().delete(new Path(file), true);
    getRouterFileSystem().delete(new Path(renamedFile), true);
  }

  @Test
  public void testRbfRenameWhenDstAlreadyExists() throws Exception {
    List<String> nss = cluster.getNameservices();
    String ns0 = nss.get(0);
    String ns1 = nss.get(1);

    // Test router federation rename a path to a destination that is in a
    // different namespace and already exists.
    String dir =
        cluster.getFederatedTestDirectoryForNS(ns0) + "/" + getMethodName();
    String renamedDir =
        cluster.getFederatedTestDirectoryForNS(ns1) + "/" + getMethodName();
    createDir(routerFS, dir);
    getRouterFileSystem().mkdirs(new Path(renamedDir));
    LambdaTestUtils.intercept(RemoteException.class, "already exists",
        "Expect RemoteException.", () -> {
          DFSClient client = router.getClient();
          ClientProtocol clientProtocol = client.getNamenode();
          clientProtocol.rename(dir, renamedDir);
          return null;
        });
    LambdaTestUtils.intercept(RemoteException.class, "already exists",
        "Expect RemoteException.", () -> {
          DFSClient client = router.getClient();
          ClientProtocol clientProtocol = client.getNamenode();
          clientProtocol.rename2(dir, renamedDir);
          return null;
        });
    getRouterFileSystem().delete(new Path(dir), true);
    getRouterFileSystem().delete(new Path(renamedDir), true);
  }

  @Test
  public void testRbfRenameWhenSrcNotExists() throws Exception {
    List<String> nss = cluster.getNameservices();
    String ns0 = nss.get(0);
    String ns1 = nss.get(1);

    // Test router federation rename un-existed path.
    String dir =
        cluster.getFederatedTestDirectoryForNS(ns0) + "/" + getMethodName();
    String renamedDir =
        cluster.getFederatedTestDirectoryForNS(ns1) + "/" + getMethodName();
    LambdaTestUtils.intercept(RemoteException.class, "File does not exist",
        "Expect RemoteException.", () -> {
          DFSClient client = router.getClient();
          ClientProtocol clientProtocol = client.getNamenode();
          clientProtocol.rename(dir, renamedDir);
          return null;
        });
    LambdaTestUtils.intercept(RemoteException.class, "File does not exist",
        "Expect RemoteException.", () -> {
          DFSClient client = router.getClient();
          ClientProtocol clientProtocol = client.getNamenode();
          clientProtocol.rename2(dir, renamedDir);
          return null;
        });
  }

  @Test
  public void testRbfRenameOfMountPoint() throws Exception {
    List<String> nss = cluster.getNameservices();
    String ns0 = nss.get(0);
    String ns1 = nss.get(1);

    // Test router federation rename a mount point.
    String dir = cluster.getFederatedPathForNS(ns0);
    String renamedDir = cluster.getFederatedPathForNS(ns1);
    LambdaTestUtils.intercept(RemoteException.class, "is a mount point",
        "Expect RemoteException.", () -> {
          DFSClient client = router.getClient();
          ClientProtocol clientProtocol = client.getNamenode();
          clientProtocol.rename(dir, renamedDir);
          return null;
        });
    LambdaTestUtils.intercept(RemoteException.class, "is a mount point",
        "Expect RemoteException.", () -> {
          DFSClient client = router.getClient();
          ClientProtocol clientProtocol = client.getNamenode();
          clientProtocol.rename2(dir, renamedDir);
          return null;
        });
  }

  @Test
  public void testRbfRenameWithMultiDestination() throws Exception {
    List<String> nss = cluster.getNameservices();
    String ns1 = nss.get(1);
    FileSystem rfs = getRouterFileSystem();

    // Test router federation rename a path with multi-destination.
    String dir = "/same/" + getMethodName();
    String renamedDir = cluster.getFederatedTestDirectoryForNS(ns1) + "/"
        + getMethodName();
    createDir(rfs, dir);
    getRouterFileSystem().mkdirs(new Path(renamedDir));
    LambdaTestUtils.intercept(RemoteException.class,
        "The remote location should be exactly one", "Expect RemoteException.",
        () -> {
          DFSClient client = router.getClient();
          ClientProtocol clientProtocol = client.getNamenode();
          clientProtocol.rename(dir, renamedDir);
          return null;
        });
    LambdaTestUtils.intercept(RemoteException.class,
        "The remote location should be exactly one", "Expect RemoteException.",
        () -> {
          DFSClient client = router.getClient();
          ClientProtocol clientProtocol = client.getNamenode();
          clientProtocol.rename2(dir, renamedDir);
          return null;
        });
    getRouterFileSystem().delete(new Path(dir), true);
    getRouterFileSystem().delete(new Path(renamedDir), true);
  }

  @Test(timeout = 20000)
  public void testCounter() throws Exception {
    final RouterRpcServer rpcServer = router.getRouter().getRpcServer();
    List<String> nss = cluster.getNameservices();
    String ns0 = nss.get(0);
    String ns1 = nss.get(1);
    RouterFederationRename rbfRename =
        Mockito.spy(new RouterFederationRename(rpcServer, router.getConf()));
    String path = "/src";
    createDir(cluster.getCluster().getFileSystem(0), path);
    // Watch the scheduler job count.
    int expectedSchedulerCount = rpcServer.getSchedulerJobCount() + 1;
    AtomicInteger maxSchedulerCount = new AtomicInteger();
    AtomicBoolean watch = new AtomicBoolean(true);
    Thread watcher = new Thread(() -> {
      while (watch.get()) {
        int schedulerCount = rpcServer.getSchedulerJobCount();
        if (schedulerCount > maxSchedulerCount.get()) {
          maxSchedulerCount.set(schedulerCount);
        }
        try {
          Thread.sleep(1);
        } catch (InterruptedException e) {
        }
      }
    });
    watcher.start();
    // Trigger rename.
    rbfRename.routerFedRename("/src", "/dst",
        Arrays.asList(new RemoteLocation(ns0, path, null)),
        Arrays.asList(new RemoteLocation(ns1, path, null)));
    // Verify count.
    verify(rbfRename).countIncrement();
    verify(rbfRename).countDecrement();
    watch.set(false);
    watcher.interrupt();
    watcher.join();
    assertEquals(expectedSchedulerCount, maxSchedulerCount.get());
    // Clean up.
    assertFalse(cluster.getCluster().getFileSystem(0).exists(new Path(path)));
    assertTrue(
        cluster.getCluster().getFileSystem(1).delete(new Path(path), true));
  }
}


text:
001
032
033    package com.jeantessier.classreader;
034
035    import java.util.*;
036
037    public interface Code_attribute extends Attribute_info, Iterable<Instruction> {
038        public int getMaxStack();
039        public int getMaxLocals();
040        public byte[] getCode();
041        public Iterator<Instruction> iterator();
042        public Collection<? extends ExceptionHandler> getExceptionHandlers();
043        public Collection<? extends Attribute_info> getAttributes();
044    }


text:
#include <linux/audit.h>
#include <linux/compat.h>
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/mm.h>
#include <linux/smp.h>
#include <linux/ptrace.h>
#include <linux/user.h>
#include <linux/seccomp.h>
#include <linux/security.h>
#include <linux/init.h>
#include <linux/signal.h>
#include <linux/uaccess.h>
#include <linux/perf_event.h>
#include <linux/hw_breakpoint.h>
#include <linux/regset.h>
#include <linux/tracehook.h>
#include <linux/elf.h>

#include <asm/compat.h>
#include <asm/debug-monitors.h>
#include <asm/pgtable.h>
#include <asm/syscall.h>
#include <asm/traps.h>
#include <asm/system_misc.h>

#define CREATE_TRACE_POINTS
#include <trace/events/syscalls.h>

/*
 * TODO: does not yet catch signals sent when the child dies.
 * in exit.c or in signal.c.
 */

/*
 * Called by kernel/ptrace.c when detaching..
 */
void ptrace_disable(struct task_struct *child)
{
	/*
	 * This would be better off in core code, but PTRACE_DETACH has
	 * grown its fair share of arch-specific worts and changing it
	 * is likely to cause regressions on obscure architectures.
	 */
	user_disable_single_step(child);
}

#ifdef CONFIG_HAVE_HW_BREAKPOINT
/*
 * Handle hitting a HW-breakpoint.
 */
static void ptrace_hbptriggered(struct perf_event *bp,
				struct perf_sample_data *data,
				struct pt_regs *regs)
{
	struct arch_hw_breakpoint *bkpt = counter_arch_bp(bp);
	siginfo_t info = {
		.si_signo	= SIGTRAP,
		.si_errno	= 0,
		.si_code	= TRAP_HWBKPT,
		.si_addr	= (void __user *)(bkpt->trigger),
	};

#ifdef CONFIG_COMPAT
	int i;

	if (!is_compat_task())
		goto send_sig;

	for (i = 0; i < ARM_MAX_BRP; ++i) {
		if (current->thread.debug.hbp_break[i] == bp) {
			info.si_errno = (i << 1) + 1;
			break;
		}
	}

	for (i = 0; i < ARM_MAX_WRP; ++i) {
		if (current->thread.debug.hbp_watch[i] == bp) {
			info.si_errno = -((i << 1) + 1);
			break;
		}
	}

send_sig:
#endif
	force_sig_info(SIGTRAP, &info, current);
}

/*
 * Unregister breakpoints from this task and reset the pointers in
 * the thread_struct.
 */
void flush_ptrace_hw_breakpoint(struct task_struct *tsk)
{
	int i;
	struct thread_struct *t = &tsk->thread;

	for (i = 0; i < ARM_MAX_BRP; i++) {
		if (t->debug.hbp_break[i]) {
			unregister_hw_breakpoint(t->debug.hbp_break[i]);
			t->debug.hbp_break[i] = NULL;
		}
	}

	for (i = 0; i < ARM_MAX_WRP; i++) {
		if (t->debug.hbp_watch[i]) {
			unregister_hw_breakpoint(t->debug.hbp_watch[i]);
			t->debug.hbp_watch[i] = NULL;
		}
	}
}

void ptrace_hw_copy_thread(struct task_struct *tsk)
{
	memset(&tsk->thread.debug, 0, sizeof(struct debug_info));
}

static struct perf_event *ptrace_hbp_get_event(unsigned int note_type,
					       struct task_struct *tsk,
					       unsigned long idx)
{
	struct perf_event *bp = ERR_PTR(-EINVAL);

	switch (note_type) {
	case NT_ARM_HW_BREAK:
		if (idx < ARM_MAX_BRP)
			bp = tsk->thread.debug.hbp_break[idx];
		break;
	case NT_ARM_HW_WATCH:
		if (idx < ARM_MAX_WRP)
			bp = tsk->thread.debug.hbp_watch[idx];
		break;
	}

	return bp;
}

static int ptrace_hbp_set_event(unsigned int note_type,
				struct task_struct *tsk,
				unsigned long idx,
				struct perf_event *bp)
{
	int err = -EINVAL;

	switch (note_type) {
	case NT_ARM_HW_BREAK:
		if (idx < ARM_MAX_BRP) {
			tsk->thread.debug.hbp_break[idx] = bp;
			err = 0;
		}
		break;
	case NT_ARM_HW_WATCH:
		if (idx < ARM_MAX_WRP) {
			tsk->thread.debug.hbp_watch[idx] = bp;
			err = 0;
		}
		break;
	}

	return err;
}

static struct perf_event *ptrace_hbp_create(unsigned int note_type,
					    struct task_struct *tsk,
					    unsigned long idx)
{
	struct perf_event *bp;
	struct perf_event_attr attr;
	int err, type;

	switch (note_type) {
	case NT_ARM_HW_BREAK:
		type = HW_BREAKPOINT_X;
		break;
	case NT_ARM_HW_WATCH:
		type = HW_BREAKPOINT_RW;
		break;
	default:
		return ERR_PTR(-EINVAL);
	}

	ptrace_breakpoint_init(&attr);

	/*
	 * Initialise fields to sane defaults
	 * (i.e. values that will pass validation).
	 */
	attr.bp_addr	= 0;
	attr.bp_len	= HW_BREAKPOINT_LEN_4;
	attr.bp_type	= type;
	attr.disabled	= 1;

	bp = register_user_hw_breakpoint(&attr, ptrace_hbptriggered, NULL, tsk);
	if (IS_ERR(bp))
		return bp;

	err = ptrace_hbp_set_event(note_type, tsk, idx, bp);
	if (err)
		return ERR_PTR(err);

	return bp;
}

static int ptrace_hbp_fill_attr_ctrl(unsigned int note_type,
				     struct arch_hw_breakpoint_ctrl ctrl,
				     struct perf_event_attr *attr)
{
	int err, len, type, disabled = !ctrl.enabled;

	attr->disabled = disabled;
	if (disabled)
		return 0;

	err = arch_bp_generic_fields(ctrl, &len, &type);
	if (err)
		return err;

	switch (note_type) {
	case NT_ARM_HW_BREAK:
		if ((type & HW_BREAKPOINT_X) != type)
			return -EINVAL;
		break;
	case NT_ARM_HW_WATCH:
		if ((type & HW_BREAKPOINT_RW) != type)
			return -EINVAL;
		break;
	default:
		return -EINVAL;
	}

	attr->bp_len	= len;
	attr->bp_type	= type;

	return 0;
}

static int ptrace_hbp_get_resource_info(unsigned int note_type, u32 *info)
{
	u8 num;
	u32 reg = 0;

	switch (note_type) {
	case NT_ARM_HW_BREAK:
		num = hw_breakpoint_slots(TYPE_INST);
		break;
	case NT_ARM_HW_WATCH:
		num = hw_breakpoint_slots(TYPE_DATA);
		break;
	default:
		return -EINVAL;
	}

	reg |= debug_monitors_arch();
	reg <<= 8;
	reg |= num;

	*info = reg;
	return 0;
}

static int ptrace_hbp_get_ctrl(unsigned int note_type,
			       struct task_struct *tsk,
			       unsigned long idx,
			       u32 *ctrl)
{
	struct perf_event *bp = ptrace_hbp_get_event(note_type, tsk, idx);

	if (IS_ERR(bp))
		return PTR_ERR(bp);

	*ctrl = bp ? encode_ctrl_reg(counter_arch_bp(bp)->ctrl) : 0;
	return 0;
}

static int ptrace_hbp_get_addr(unsigned int note_type,
			       struct task_struct *tsk,
			       unsigned long idx,
			       u64 *addr)
{
	struct perf_event *bp = ptrace_hbp_get_event(note_type, tsk, idx);

	if (IS_ERR(bp))
		return PTR_ERR(bp);

	*addr = bp ? bp->attr.bp_addr : 0;
	return 0;
}

static struct perf_event *ptrace_hbp_get_initialised_bp(unsigned int note_type,
							struct task_struct *tsk,
							unsigned long idx)
{
	struct perf_event *bp = ptrace_hbp_get_event(note_type, tsk, idx);

	if (!bp)
		bp = ptrace_hbp_create(note_type, tsk, idx);

	return bp;
}

static int ptrace_hbp_set_ctrl(unsigned int note_type,
			       struct task_struct *tsk,
			       unsigned long idx,
			       u32 uctrl)
{
	int err;
	struct perf_event *bp;
	struct perf_event_attr attr;
	struct arch_hw_breakpoint_ctrl ctrl;

	bp = ptrace_hbp_get_initialised_bp(note_type, tsk, idx);
	if (IS_ERR(bp)) {
		err = PTR_ERR(bp);
		return err;
	}

	attr = bp->attr;
	decode_ctrl_reg(uctrl, &ctrl);
	err = ptrace_hbp_fill_attr_ctrl(note_type, ctrl, &attr);
	if (err)
		return err;

	return modify_user_hw_breakpoint(bp, &attr);
}

static int ptrace_hbp_set_addr(unsigned int note_type,
			       struct task_struct *tsk,
			       unsigned long idx,
			       u64 addr)
{
	int err;
	struct perf_event *bp;
	struct perf_event_attr attr;

	bp = ptrace_hbp_get_initialised_bp(note_type, tsk, idx);
	if (IS_ERR(bp)) {
		err = PTR_ERR(bp);
		return err;
	}

	attr = bp->attr;
	attr.bp_addr = addr;
	err = modify_user_hw_breakpoint(bp, &attr);
	return err;
}

#define PTRACE_HBP_ADDR_SZ	sizeof(u64)
#define PTRACE_HBP_CTRL_SZ	sizeof(u32)
#define PTRACE_HBP_PAD_SZ	sizeof(u32)

static int hw_break_get(struct task_struct *target,
			const struct user_regset *regset,
			unsigned int pos, unsigned int count,
			void *kbuf, void __user *ubuf)
{
	unsigned int note_type = regset->core_note_type;
	int ret, idx = 0, offset, limit;
	u32 info, ctrl;
	u64 addr;

	/* Resource info */
	ret = ptrace_hbp_get_resource_info(note_type, &info);
	if (ret)
		return ret;

	ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, &info, 0,
				  sizeof(info));
	if (ret)
		return ret;

	/* Pad */
	offset = offsetof(struct user_hwdebug_state, pad);
	ret = user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf, offset,
				       offset + PTRACE_HBP_PAD_SZ);
	if (ret)
		return ret;

	/* (address, ctrl) registers */
	offset = offsetof(struct user_hwdebug_state, dbg_regs);
	limit = regset->n * regset->size;
	while (count && offset < limit) {
		ret = ptrace_hbp_get_addr(note_type, target, idx, &addr);
		if (ret)
			return ret;
		ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, &addr,
					  offset, offset + PTRACE_HBP_ADDR_SZ);
		if (ret)
			return ret;
		offset += PTRACE_HBP_ADDR_SZ;

		ret = ptrace_hbp_get_ctrl(note_type, target, idx, &ctrl);
		if (ret)
			return ret;
		ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, &ctrl,
					  offset, offset + PTRACE_HBP_CTRL_SZ);
		if (ret)
			return ret;
		offset += PTRACE_HBP_CTRL_SZ;

		ret = user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf,
					       offset,
					       offset + PTRACE_HBP_PAD_SZ);
		if (ret)
			return ret;
		offset += PTRACE_HBP_PAD_SZ;
		idx++;
	}

	return 0;
}

static int hw_break_set(struct task_struct *target,
			const struct user_regset *regset,
			unsigned int pos, unsigned int count,
			const void *kbuf, const void __user *ubuf)
{
	unsigned int note_type = regset->core_note_type;
	int ret, idx = 0, offset, limit;
	u32 ctrl;
	u64 addr;

	/* Resource info and pad */
	offset = offsetof(struct user_hwdebug_state, dbg_regs);
	ret = user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf, 0, offset);
	if (ret)
		return ret;

	/* (address, ctrl) registers */
	limit = regset->n * regset->size;
	while (count && offset < limit) {
		ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &addr,
					 offset, offset + PTRACE_HBP_ADDR_SZ);
		if (ret)
			return ret;
		ret = ptrace_hbp_set_addr(note_type, target, idx, addr);
		if (ret)
			return ret;
		offset += PTRACE_HBP_ADDR_SZ;

		ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &ctrl,
					 offset, offset + PTRACE_HBP_CTRL_SZ);
		if (ret)
			return ret;
		ret = ptrace_hbp_set_ctrl(note_type, target, idx, ctrl);
		if (ret)
			return ret;
		offset += PTRACE_HBP_CTRL_SZ;

		ret = user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf,
						offset,
						offset + PTRACE_HBP_PAD_SZ);
		if (ret)
			return ret;
		offset += PTRACE_HBP_PAD_SZ;
		idx++;
	}

	return 0;
}
#endif	/* CONFIG_HAVE_HW_BREAKPOINT */

static int gpr_get(struct task_struct *target,
		   const struct user_regset *regset,
		   unsigned int pos, unsigned int count,
		   void *kbuf, void __user *ubuf)
{
	struct user_pt_regs *uregs = &task_pt_regs(target)->user_regs;
	return user_regset_copyout(&pos, &count, &kbuf, &ubuf, uregs, 0, -1);
}

static int gpr_set(struct task_struct *target, const struct user_regset *regset,
		   unsigned int pos, unsigned int count,
		   const void *kbuf, const void __user *ubuf)
{
	int ret;
	struct user_pt_regs newregs;

	ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &newregs, 0, -1);
	if (ret)
		return ret;

	if (!valid_user_regs(&newregs, target))
		return -EINVAL;

	task_pt_regs(target)->user_regs = newregs;
	return 0;
}

/*
 * TODO: update fp accessors for lazy context switching (sync/flush hwstate)
 */
static int fpr_get(struct task_struct *target, const struct user_regset *regset,
		   unsigned int pos, unsigned int count,
		   void *kbuf, void __user *ubuf)
{
	struct user_fpsimd_state *uregs;
	uregs = &target->thread.fpsimd_state.user_fpsimd;
	return user_regset_copyout(&pos, &count, &kbuf, &ubuf, uregs, 0, -1);
}

static int fpr_set(struct task_struct *target, const struct user_regset *regset,
		   unsigned int pos, unsigned int count,
		   const void *kbuf, const void __user *ubuf)
{
	int ret;
	struct user_fpsimd_state newstate;

	ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &newstate, 0, -1);
	if (ret)
		return ret;

	target->thread.fpsimd_state.user_fpsimd = newstate;
	fpsimd_flush_task_state(target);
	return ret;
}

static int tls_get(struct task_struct *target, const struct user_regset *regset,
		   unsigned int pos, unsigned int count,
		   void *kbuf, void __user *ubuf)
{
	unsigned long *tls = &target->thread.tp_value;
	return user_regset_copyout(&pos, &count, &kbuf, &ubuf, tls, 0, -1);
}

static int tls_set(struct task_struct *target, const struct user_regset *regset,
		   unsigned int pos, unsigned int count,
		   const void *kbuf, const void __user *ubuf)
{
	int ret;
	unsigned long tls;

	ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &tls, 0, -1);
	if (ret)
		return ret;

	target->thread.tp_value = tls;
	return ret;
}

static int system_call_get(struct task_struct *target,
			   const struct user_regset *regset,
			   unsigned int pos, unsigned int count,
			   void *kbuf, void __user *ubuf)
{
	int syscallno = task_pt_regs(target)->syscallno;

	return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
				   &syscallno, 0, -1);
}

static int system_call_set(struct task_struct *target,
			   const struct user_regset *regset,
			   unsigned int pos, unsigned int count,
			   const void *kbuf, const void __user *ubuf)
{
	int syscallno, ret;

	ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &syscallno, 0, -1);
	if (ret)
		return ret;

	task_pt_regs(target)->syscallno = syscallno;
	return ret;
}

enum aarch64_regset {
	REGSET_GPR,
	REGSET_FPR,
	REGSET_TLS,
#ifdef CONFIG_HAVE_HW_BREAKPOINT
	REGSET_HW_BREAK,
	REGSET_HW_WATCH,
#endif
	REGSET_SYSTEM_CALL,
};

static const struct user_regset aarch64_regsets[] = {
	[REGSET_GPR] = {
		.core_note_type = NT_PRSTATUS,
		.n = sizeof(struct user_pt_regs) / sizeof(u64),
		.size = sizeof(u64),
		.align = sizeof(u64),
		.get = gpr_get,
		.set = gpr_set
	},
	[REGSET_FPR] = {
		.core_note_type = NT_PRFPREG,
		.n = sizeof(struct user_fpsimd_state) / sizeof(u32),
		/*
		 * We pretend we have 32-bit registers because the fpsr and
		 * fpcr are 32-bits wide.
		 */
		.size = sizeof(u32),
		.align = sizeof(u32),
		.get = fpr_get,
		.set = fpr_set
	},
	[REGSET_TLS] = {
		.core_note_type = NT_ARM_TLS,
		.n = 1,
		.size = sizeof(void *),
		.align = sizeof(void *),
		.get = tls_get,
		.set = tls_set,
	},
#ifdef CONFIG_HAVE_HW_BREAKPOINT
	[REGSET_HW_BREAK] = {
		.core_note_type = NT_ARM_HW_BREAK,
		.n = sizeof(struct user_hwdebug_state) / sizeof(u32),
		.size = sizeof(u32),
		.align = sizeof(u32),
		.get = hw_break_get,
		.set = hw_break_set,
	},
	[REGSET_HW_WATCH] = {
		.core_note_type = NT_ARM_HW_WATCH,
		.n = sizeof(struct user_hwdebug_state) / sizeof(u32),
		.size = sizeof(u32),
		.align = sizeof(u32),
		.get = hw_break_get,
		.set = hw_break_set,
	},
#endif
	[REGSET_SYSTEM_CALL] = {
		.core_note_type = NT_ARM_SYSTEM_CALL,
		.n = 1,
		.size = sizeof(int),
		.align = sizeof(int),
		.get = system_call_get,
		.set = system_call_set,
	},
};

static const struct user_regset_view user_aarch64_view = {
	.name = "aarch64", .e_machine = EM_AARCH64,
	.regsets = aarch64_regsets, .n = ARRAY_SIZE(aarch64_regsets)
};

#ifdef CONFIG_COMPAT
#include <linux/compat.h>

enum compat_regset {
	REGSET_COMPAT_GPR,
	REGSET_COMPAT_VFP,
};

static int compat_gpr_get(struct task_struct *target,
			  const struct user_regset *regset,
			  unsigned int pos, unsigned int count,
			  void *kbuf, void __user *ubuf)
{
	int ret = 0;
	unsigned int i, start, num_regs;

	/* Calculate the number of AArch32 registers contained in count */
	num_regs = count / regset->size;

	/* Convert pos into an register number */
	start = pos / regset->size;

	if (start + num_regs > regset->n)
		return -EIO;

	for (i = 0; i < num_regs; ++i) {
		unsigned int idx = start + i;
		compat_ulong_t reg;

		switch (idx) {
		case 15:
			reg = task_pt_regs(target)->pc;
			break;
		case 16:
			reg = task_pt_regs(target)->pstate;
			break;
		case 17:
			reg = task_pt_regs(target)->orig_x0;
			break;
		default:
			reg = task_pt_regs(target)->regs[idx];
		}

		if (kbuf) {
			memcpy(kbuf, &reg, sizeof(reg));
			kbuf += sizeof(reg);
		} else {
			ret = copy_to_user(ubuf, &reg, sizeof(reg));
			if (ret) {
				ret = -EFAULT;
				break;
			}

			ubuf += sizeof(reg);
		}
	}

	return ret;
}

static int compat_gpr_set(struct task_struct *target,
			  const struct user_regset *regset,
			  unsigned int pos, unsigned int count,
			  const void *kbuf, const void __user *ubuf)
{
	struct pt_regs newregs;
	int ret = 0;
	unsigned int i, start, num_regs;

	/* Calculate the number of AArch32 registers contained in count */
	num_regs = count / regset->size;

	/* Convert pos into an register number */
	start = pos / regset->size;

	if (start + num_regs > regset->n)
		return -EIO;

	newregs = *task_pt_regs(target);

	for (i = 0; i < num_regs; ++i) {
		unsigned int idx = start + i;
		compat_ulong_t reg;

		if (kbuf) {
			memcpy(&reg, kbuf, sizeof(reg));
			kbuf += sizeof(reg);
		} else {
			ret = copy_from_user(&reg, ubuf, sizeof(reg));
			if (ret) {
				ret = -EFAULT;
				break;
			}

			ubuf += sizeof(reg);
		}

		switch (idx) {
		case 15:
			newregs.pc = reg;
			break;
		case 16:
			newregs.pstate = reg;
			break;
		case 17:
			newregs.orig_x0 = reg;
			break;
		default:
			newregs.regs[idx] = reg;
		}

	}

	if (valid_user_regs(&newregs.user_regs, target))
		*task_pt_regs(target) = newregs;
	else
		ret = -EINVAL;

	return ret;
}

static int compat_vfp_get(struct task_struct *target,
			  const struct user_regset *regset,
			  unsigned int pos, unsigned int count,
			  void *kbuf, void __user *ubuf)
{
	struct user_fpsimd_state *uregs;
	compat_ulong_t fpscr;
	int ret;

	uregs = &target->thread.fpsimd_state.user_fpsimd;

	/*
	 * The VFP registers are packed into the fpsimd_state, so they all sit
	 * nicely together for us. We just need to create the fpscr separately.
	 */
	ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, uregs, 0,
				  VFP_STATE_SIZE - sizeof(compat_ulong_t));

	if (count && !ret) {
		fpscr = (uregs->fpsr & VFP_FPSCR_STAT_MASK) |
			(uregs->fpcr & VFP_FPSCR_CTRL_MASK);
		ret = put_user(fpscr, (compat_ulong_t *)ubuf);
	}

	return ret;
}

static int compat_vfp_set(struct task_struct *target,
			  const struct user_regset *regset,
			  unsigned int pos, unsigned int count,
			  const void *kbuf, const void __user *ubuf)
{
	struct user_fpsimd_state *uregs;
	compat_ulong_t fpscr;
	int ret;

	if (pos + count > VFP_STATE_SIZE)
		return -EIO;

	uregs = &target->thread.fpsimd_state.user_fpsimd;

	ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, uregs, 0,
				 VFP_STATE_SIZE - sizeof(compat_ulong_t));

	if (count && !ret) {
		ret = get_user(fpscr, (compat_ulong_t *)ubuf);
		uregs->fpsr = fpscr & VFP_FPSCR_STAT_MASK;
		uregs->fpcr = fpscr & VFP_FPSCR_CTRL_MASK;
	}

	fpsimd_flush_task_state(target);
	return ret;
}

static int compat_tls_get(struct task_struct *target,
			  const struct user_regset *regset, unsigned int pos,
			  unsigned int count, void *kbuf, void __user *ubuf)
{
	compat_ulong_t tls = (compat_ulong_t)target->thread.tp_value;
	return user_regset_copyout(&pos, &count, &kbuf, &ubuf, &tls, 0, -1);
}

static int compat_tls_set(struct task_struct *target,
			  const struct user_regset *regset, unsigned int pos,
			  unsigned int count, const void *kbuf,
			  const void __user *ubuf)
{
	int ret;
	compat_ulong_t tls;

	ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &tls, 0, -1);
	if (ret)
		return ret;

	target->thread.tp_value = tls;
	return ret;
}

static const struct user_regset aarch32_regsets[] = {
	[REGSET_COMPAT_GPR] = {
		.core_note_type = NT_PRSTATUS,
		.n = COMPAT_ELF_NGREG,
		.size = sizeof(compat_elf_greg_t),
		.align = sizeof(compat_elf_greg_t),
		.get = compat_gpr_get,
		.set = compat_gpr_set
	},
	[REGSET_COMPAT_VFP] = {
		.core_note_type = NT_ARM_VFP,
		.n = VFP_STATE_SIZE / sizeof(compat_ulong_t),
		.size = sizeof(compat_ulong_t),
		.align = sizeof(compat_ulong_t),
		.get = compat_vfp_get,
		.set = compat_vfp_set
	},
};

static const struct user_regset_view user_aarch32_view = {
	.name = "aarch32", .e_machine = EM_ARM,
	.regsets = aarch32_regsets, .n = ARRAY_SIZE(aarch32_regsets)
};

static const struct user_regset aarch32_ptrace_regsets[] = {
	[REGSET_GPR] = {
		.core_note_type = NT_PRSTATUS,
		.n = COMPAT_ELF_NGREG,
		.size = sizeof(compat_elf_greg_t),
		.align = sizeof(compat_elf_greg_t),
		.get = compat_gpr_get,
		.set = compat_gpr_set
	},
	[REGSET_FPR] = {
		.core_note_type = NT_ARM_VFP,
		.n = VFP_STATE_SIZE / sizeof(compat_ulong_t),
		.size = sizeof(compat_ulong_t),
		.align = sizeof(compat_ulong_t),
		.get = compat_vfp_get,
		.set = compat_vfp_set
	},
	[REGSET_TLS] = {
		.core_note_type = NT_ARM_TLS,
		.n = 1,
		.size = sizeof(compat_ulong_t),
		.align = sizeof(compat_ulong_t),
		.get = compat_tls_get,
		.set = compat_tls_set,
	},
#ifdef CONFIG_HAVE_HW_BREAKPOINT
	[REGSET_HW_BREAK] = {
		.core_note_type = NT_ARM_HW_BREAK,
		.n = sizeof(struct user_hwdebug_state) / sizeof(u32),
		.size = sizeof(u32),
		.align = sizeof(u32),
		.get = hw_break_get,
		.set = hw_break_set,
	},
	[REGSET_HW_WATCH] = {
		.core_note_type = NT_ARM_HW_WATCH,
		.n = sizeof(struct user_hwdebug_state) / sizeof(u32),
		.size = sizeof(u32),
		.align = sizeof(u32),
		.get = hw_break_get,
		.set = hw_break_set,
	},
#endif
	[REGSET_SYSTEM_CALL] = {
		.core_note_type = NT_ARM_SYSTEM_CALL,
		.n = 1,
		.size = sizeof(int),
		.align = sizeof(int),
		.get = system_call_get,
		.set = system_call_set,
	},
};

static const struct user_regset_view user_aarch32_ptrace_view = {
	.name = "aarch32", .e_machine = EM_ARM,
	.regsets = aarch32_ptrace_regsets, .n = ARRAY_SIZE(aarch32_ptrace_regsets)
};

static int compat_ptrace_read_user(struct task_struct *tsk, compat_ulong_t off,
				   compat_ulong_t __user *ret)
{
	compat_ulong_t tmp;

	if (off & 3)
		return -EIO;

	if (off == COMPAT_PT_TEXT_ADDR)
		tmp = tsk->mm->start_code;
	else if (off == COMPAT_PT_DATA_ADDR)
		tmp = tsk->mm->start_data;
	else if (off == COMPAT_PT_TEXT_END_ADDR)
		tmp = tsk->mm->end_code;
	else if (off < sizeof(compat_elf_gregset_t))
		return copy_regset_to_user(tsk, &user_aarch32_view,
					   REGSET_COMPAT_GPR, off,
					   sizeof(compat_ulong_t), ret);
	else if (off >= COMPAT_USER_SZ)
		return -EIO;
	else
		tmp = 0;

	return put_user(tmp, ret);
}

static int compat_ptrace_write_user(struct task_struct *tsk, compat_ulong_t off,
				    compat_ulong_t val)
{
	int ret;
	mm_segment_t old_fs = get_fs();

	if (off & 3 || off >= COMPAT_USER_SZ)
		return -EIO;

	if (off >= sizeof(compat_elf_gregset_t))
		return 0;

	set_fs(KERNEL_DS);
	ret = copy_regset_from_user(tsk, &user_aarch32_view,
				    REGSET_COMPAT_GPR, off,
				    sizeof(compat_ulong_t),
				    &val);
	set_fs(old_fs);

	return ret;
}

#ifdef CONFIG_HAVE_HW_BREAKPOINT

/*
 * Convert a virtual register number into an index for a thread_info
 * breakpoint array. Breakpoints are identified using positive numbers
 * whilst watchpoints are negative. The registers are laid out as pairs
 * of (address, control), each pair mapping to a unique hw_breakpoint struct.
 * Register 0 is reserved for describing resource information.
 */
static int compat_ptrace_hbp_num_to_idx(compat_long_t num)
{
	return (abs(num) - 1) >> 1;
}

static int compat_ptrace_hbp_get_resource_info(u32 *kdata)
{
	u8 num_brps, num_wrps, debug_arch, wp_len;
	u32 reg = 0;

	num_brps	= hw_breakpoint_slots(TYPE_INST);
	num_wrps	= hw_breakpoint_slots(TYPE_DATA);

	debug_arch	= debug_monitors_arch();
	wp_len		= 8;
	reg		|= debug_arch;
	reg		<<= 8;
	reg		|= wp_len;
	reg		<<= 8;
	reg		|= num_wrps;
	reg		<<= 8;
	reg		|= num_brps;

	*kdata = reg;
	return 0;
}

static int compat_ptrace_hbp_get(unsigned int note_type,
				 struct task_struct *tsk,
				 compat_long_t num,
				 u32 *kdata)
{
	u64 addr = 0;
	u32 ctrl = 0;

	int err, idx = compat_ptrace_hbp_num_to_idx(num);;

	if (num & 1) {
		err = ptrace_hbp_get_addr(note_type, tsk, idx, &addr);
		*kdata = (u32)addr;
	} else {
		err = ptrace_hbp_get_ctrl(note_type, tsk, idx, &ctrl);
		*kdata = ctrl;
	}

	return err;
}

static int compat_ptrace_hbp_set(unsigned int note_type,
				 struct task_struct *tsk,
				 compat_long_t num,
				 u32 *kdata)
{
	u64 addr;
	u32 ctrl;

	int err, idx = compat_ptrace_hbp_num_to_idx(num);

	if (num & 1) {
		addr = *kdata;
		err = ptrace_hbp_set_addr(note_type, tsk, idx, addr);
	} else {
		ctrl = *kdata;
		err = ptrace_hbp_set_ctrl(note_type, tsk, idx, ctrl);
	}

	return err;
}

static int compat_ptrace_gethbpregs(struct task_struct *tsk, compat_long_t num,
				    compat_ulong_t __user *data)
{
	int ret;
	u32 kdata;
	mm_segment_t old_fs = get_fs();

	set_fs(KERNEL_DS);
	/* Watchpoint */
	if (num < 0) {
		ret = compat_ptrace_hbp_get(NT_ARM_HW_WATCH, tsk, num, &kdata);
	/* Resource info */
	} else if (num == 0) {
		ret = compat_ptrace_hbp_get_resource_info(&kdata);
	/* Breakpoint */
	} else {
		ret = compat_ptrace_hbp_get(NT_ARM_HW_BREAK, tsk, num, &kdata);
	}
	set_fs(old_fs);

	if (!ret)
		ret = put_user(kdata, data);

	return ret;
}

static int compat_ptrace_sethbpregs(struct task_struct *tsk, compat_long_t num,
				    compat_ulong_t __user *data)
{
	int ret;
	u32 kdata = 0;
	mm_segment_t old_fs = get_fs();

	if (num == 0)
		return 0;

	ret = get_user(kdata, data);
	if (ret)
		return ret;

	set_fs(KERNEL_DS);
	if (num < 0)
		ret = compat_ptrace_hbp_set(NT_ARM_HW_WATCH, tsk, num, &kdata);
	else
		ret = compat_ptrace_hbp_set(NT_ARM_HW_BREAK, tsk, num, &kdata);
	set_fs(old_fs);

	return ret;
}
#endif	/* CONFIG_HAVE_HW_BREAKPOINT */

long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
			compat_ulong_t caddr, compat_ulong_t cdata)
{
	unsigned long addr = caddr;
	unsigned long data = cdata;
	void __user *datap = compat_ptr(data);
	int ret;

	switch (request) {
		case PTRACE_PEEKUSR:
			ret = compat_ptrace_read_user(child, addr, datap);
			break;

		case PTRACE_POKEUSR:
			ret = compat_ptrace_write_user(child, addr, data);
			break;

		case COMPAT_PTRACE_GETREGS:
			ret = copy_regset_to_user(child,
						  &user_aarch32_view,
						  REGSET_COMPAT_GPR,
						  0, sizeof(compat_elf_gregset_t),
						  datap);
			break;

		case COMPAT_PTRACE_SETREGS:
			ret = copy_regset_from_user(child,
						    &user_aarch32_view,
						    REGSET_COMPAT_GPR,
						    0, sizeof(compat_elf_gregset_t),
						    datap);
			break;

		case COMPAT_PTRACE_GET_THREAD_AREA:
			ret = put_user((compat_ulong_t)child->thread.tp_value,
				       (compat_ulong_t __user *)datap);
			break;

		case COMPAT_PTRACE_SET_SYSCALL:
			task_pt_regs(child)->syscallno = data;
			ret = 0;
			break;

		case COMPAT_PTRACE_GETVFPREGS:
			ret = copy_regset_to_user(child,
						  &user_aarch32_view,
						  REGSET_COMPAT_VFP,
						  0, VFP_STATE_SIZE,
						  datap);
			break;

		case COMPAT_PTRACE_SETVFPREGS:
			ret = copy_regset_from_user(child,
						    &user_aarch32_view,
						    REGSET_COMPAT_VFP,
						    0, VFP_STATE_SIZE,
						    datap);
			break;

#ifdef CONFIG_HAVE_HW_BREAKPOINT
		case COMPAT_PTRACE_GETHBPREGS:
			ret = compat_ptrace_gethbpregs(child, addr, datap);
			break;

		case COMPAT_PTRACE_SETHBPREGS:
			ret = compat_ptrace_sethbpregs(child, addr, datap);
			break;
#endif

		default:
			ret = compat_ptrace_request(child, request, addr,
						    data);
			break;
	}

	return ret;
}
#endif /* CONFIG_COMPAT */

const struct user_regset_view *task_user_regset_view(struct task_struct *task)
{
#ifdef CONFIG_COMPAT
	/*
	 * Core dumping of 32-bit tasks or compat ptrace requests must use the
	 * user_aarch32_view compatible with arm32. Native ptrace requests on
	 * 32-bit children use an extended user_aarch32_ptrace_view to allow
	 * access to the TLS register.
	 */
	if (is_compat_task())
		return &user_aarch32_view;
	else if (is_compat_thread(task_thread_info(task)))
		return &user_aarch32_ptrace_view;
#endif
	return &user_aarch64_view;
}

long arch_ptrace(struct task_struct *child, long request,
		 unsigned long addr, unsigned long data)
{
	return ptrace_request(child, request, addr, data);
}

enum ptrace_syscall_dir {
	PTRACE_SYSCALL_ENTER = 0,
	PTRACE_SYSCALL_EXIT,
};

static void tracehook_report_syscall(struct pt_regs *regs,
				     enum ptrace_syscall_dir dir)
{
	int regno;
	unsigned long saved_reg;

	/*
	 * A scratch register (ip(r12) on AArch32, x7 on AArch64) is
	 * used to denote syscall entry/exit:
	 */
	regno = (is_compat_task() ? 12 : 7);
	saved_reg = regs->regs[regno];
	regs->regs[regno] = dir;

	if (dir == PTRACE_SYSCALL_EXIT)
		tracehook_report_syscall_exit(regs, 0);
	else if (tracehook_report_syscall_entry(regs))
		regs->syscallno = ~0UL;

	regs->regs[regno] = saved_reg;
}

asmlinkage int syscall_trace_enter(struct pt_regs *regs)
{
	/* Do the secure computing check first; failures should be fast. */
	if (secure_computing() == -1)
		return -1;

	if (test_thread_flag(TIF_SYSCALL_TRACE))
		tracehook_report_syscall(regs, PTRACE_SYSCALL_ENTER);

	if (test_thread_flag(TIF_SYSCALL_TRACEPOINT))
		trace_sys_enter(regs, regs->syscallno);

	audit_syscall_entry(regs->syscallno, regs->orig_x0, regs->regs[1],
			    regs->regs[2], regs->regs[3]);

	return regs->syscallno;
}

asmlinkage void syscall_trace_exit(struct pt_regs *regs)
{
	audit_syscall_exit(regs);

	if (test_thread_flag(TIF_SYSCALL_TRACEPOINT))
		trace_sys_exit(regs, regs_return_value(regs));

	if (test_thread_flag(TIF_SYSCALL_TRACE))
		tracehook_report_syscall(regs, PTRACE_SYSCALL_EXIT);
}

/*
 * Bits which are always architecturally RES0 per ARM DDI 0487A.h
 * Userspace cannot use these until they have an architectural meaning.
 * We also reserve IL for the kernel; SS is handled dynamically.
 */
#define SPSR_EL1_AARCH64_RES0_BITS \
	(GENMASK_ULL(63,32) | GENMASK_ULL(27, 22) | GENMASK_ULL(20, 10) | \
	 GENMASK_ULL(5, 5))
#define SPSR_EL1_AARCH32_RES0_BITS \
	(GENMASK_ULL(63,32) | GENMASK_ULL(24, 22) | GENMASK_ULL(20,20))

static int valid_compat_regs(struct user_pt_regs *regs)
{
	regs->pstate &= ~SPSR_EL1_AARCH32_RES0_BITS;

	if (!system_supports_mixed_endian_el0()) {
		if (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN))
			regs->pstate |= COMPAT_PSR_E_BIT;
		else
			regs->pstate &= ~COMPAT_PSR_E_BIT;
	}

	if (user_mode(regs) && (regs->pstate & PSR_MODE32_BIT) &&
	    (regs->pstate & COMPAT_PSR_A_BIT) == 0 &&
	    (regs->pstate & COMPAT_PSR_I_BIT) == 0 &&
	    (regs->pstate & COMPAT_PSR_F_BIT) == 0) {
		return 1;
	}

	/*
	 * Force PSR to a valid 32-bit EL0t, preserving the same bits as
	 * arch/arm.
	 */
	regs->pstate &= COMPAT_PSR_N_BIT | COMPAT_PSR_Z_BIT |
			COMPAT_PSR_C_BIT | COMPAT_PSR_V_BIT |
			COMPAT_PSR_Q_BIT | COMPAT_PSR_IT_MASK |
			COMPAT_PSR_GE_MASK | COMPAT_PSR_E_BIT |
			COMPAT_PSR_T_BIT;
	regs->pstate |= PSR_MODE32_BIT;

	return 0;
}

static int valid_native_regs(struct user_pt_regs *regs)
{
	regs->pstate &= ~SPSR_EL1_AARCH64_RES0_BITS;

	if (user_mode(regs) && !(regs->pstate & PSR_MODE32_BIT) &&
	    (regs->pstate & PSR_D_BIT) == 0 &&
	    (regs->pstate & PSR_A_BIT) == 0 &&
	    (regs->pstate & PSR_I_BIT) == 0 &&
	    (regs->pstate & PSR_F_BIT) == 0) {
		return 1;
	}

	/* Force PSR to a valid 64-bit EL0t */
	regs->pstate &= PSR_N_BIT | PSR_Z_BIT | PSR_C_BIT | PSR_V_BIT;

	return 0;
}

/*
 * Are the current registers suitable for user mode? (used to maintain
 * security in signal handlers)
 */
int valid_user_regs(struct user_pt_regs *regs, struct task_struct *task)
{
	if (!test_tsk_thread_flag(task, TIF_SINGLESTEP))
		regs->pstate &= ~DBG_SPSR_SS;

	if (is_compat_thread(task_thread_info(task)))
		return valid_compat_regs(regs);
	else
		return valid_native_regs(regs);
}


text:
module.exports = function(Validator) {

	var formatSpecsMsg = function(specs) {
		var result = []
		for (var i = 0; i < specs.length; i++) {
			result.push(specs[i].specFile.url);
		}
		return result.join('; ');
	};

	return Validator.create({
		"suites" : {
			"checkUnicTitle": function(spec, urlToSpec) {
				if (!spec || !spec.info || !spec.info.title) return;

				var self = this;
				var result = this.getSpecsByField({"key": "title", "value": spec.info.title});
				var currentCategory = urlToSpec && urlToSpec.length
					? urlToSpec.split("/")[0]
					: undefined;

				if (result.length <= 1) return;

				var nonUnicCounter = 0;
				for (var i = 0; i < result.length; i++) {
					var itemCategory = result[i].specFile.id && result[i].specFile.id.length
						? result[i].specFile.id.split("/")[0]
						: undefined;
					if (itemCategory && currentCategory && itemCategory !== currentCategory) {
						nonUnicCounter += 1;
					}
				}
				if (nonUnicCounter > 1) {
					return this.createException("IncorrectSpecTitle", [spec.info.title, formatSpecsMsg(result)]);
				}
			},
			"checkUnicKeywords": function(spec, urlToSpec) {
				if (!spec || !spec.info || !spec.info.title) return;

				var self = this;
				var result = this.getSpecsByField({"key": "keywords", "value": spec.info.keywords});

				if (result.length > 1) {
					return this.createException("IncorrectKeywordsSet", [spec.info.keywords, formatSpecsMsg(result)]);
				}
			}
		},
		"exceptions": {
			"IncorrectSpecTitle": {
				"message": "Spec title \"{0}\" is not unique. Specs with the same title: {1}.",
				"type": "error"
			},
			"IncorrectKeywordsSet": {
				"message": "Keywords \"{0}\" are not unique in {1}.",
				"type": "warning"
			}
		}
	});
};


text:
import logging

from sqlalchemy.inspection import inspect

from aquilon.worker.locks import NoLockKey, PlenaryKey
from aquilon.worker.templates import (Plenary, StructurePlenary,
                                      add_location_info)
from aquilon.worker.templates.panutils import pan_assign, pan_include
from aquilon.aqdb.model import NetworkDevice
from aquilon.utils import nlist_key_re

LOGGER = logging.getLogger(__name__)

class PlenaryNetworkDeviceInfo(StructurePlenary):

    @classmethod
    def template_name(cls, dbmachine):
        loc = dbmachine.location
        return "network_device/%s/%s/%s" % (loc.hub.fullname.lower(),
                                            loc.building, dbmachine.label)

    def get_key(self, exclusive=True):
        if inspect(self.dbobj).deleted:
            return NoLockKey(logger=self.logger)
        else:
            # TODO: this should become a CompileKey if we start generating
            # profiles for switches (see also templates/cluster.py)
            return PlenaryKey(network_device=self.dbobj, logger=self.logger,
                              exclusive=exclusive)

    def body(self, lines):
        pan_assign(lines, "nodename", self.dbobj.label)
        if self.dbobj.serial_no:
            pan_assign(lines, "serialnumber", self.dbobj.serial_no)
        lines.append("")

        pan_assign(lines, "model_type", self.dbobj.model.model_type)
        pan_include(lines, "hardware/network_device/%s/%s" %
                    (self.dbobj.model.vendor.name, self.dbobj.model.name))
        for port in self.dbobj.consoles:
            console_port = self.dbobj.consoles[port]
            pan_assign(lines, "hardware/console/port/%s/server_name" % console_port.client_port,
                       console_port.console_server)
            pan_assign(lines, "hardware/console/port/%s/server_port" % console_port.client_port,
                       console_port.port_number)
        lines.append("")

        add_location_info(lines, self.dbobj.location)
        lines.append("")

        interfaces = {}
        for interface in self.dbobj.interfaces:
            ifinfo = {}
            ifinfo["type"] = interface.interface_type
            if interface.mac:
                ifinfo["hwaddr"] = interface.mac
            interfaces[interface.name] = ifinfo
        for name in sorted(interfaces):
            # This is ugly. We can't blindly escape, because that would affect
            # e.g. VLAN interfaces. Calling unescape() for a non-escaped VLAN
            # interface name is safe though, so we can hopefully get rid of this
            # once the templates are changed to call unescape().
            if nlist_key_re.match(name):
                pan_assign(lines, "cards/nic/%s" % name,
                           interfaces[name])
            else:
                pan_assign(lines, "cards/nic/{%s}" % name,
                           interfaces[name])
        lines.append("")

Plenary.handlers[NetworkDevice] = PlenaryNetworkDeviceInfo


text:
package sagex.phoenix.util;

import java.io.File;
import java.io.FileFilter;

/**
 * Simple Name based exclude filter. Pass a comma separated list of dirs or
 * String array. For each dir that is passed, it will check for a name match. If
 * it matches, then the dir is excluded.
 *
 * @author seans
 */
public class DirExcludeFileFilter implements FileFilter {
    public String[] excludes = null;

    public DirExcludeFileFilter(String dirs) {
        this(dirs.split(","));
    }

    public DirExcludeFileFilter(String[] dirs) {
        this.excludes = dirs;
    }

    public boolean accept(File f) {
        if (f.isFile())
            return false;
        if (excludes == null)
            return true;
        for (String d : excludes) {
            if (d.equals(f.getName())) {
                return false;
            }
        }
        return true;
    }

}


text:
{% extends "base.html" %}
{% load i18n %}
{% load crispy_forms_tags %}
{%  load staticfiles %}

{%  block include_links %}
    <link href="{% static "css/login.css" %}" rel="stylesheet">
{% endblock %}
{% block title %}Activation Email{% endblock %}

{% block content %}

{% trans "You are now registered. Activation email sent." %}

{% endblock %}