text:
package org.pentaho.di.www;

import java.io.IOException;
import java.io.PrintWriter;
import java.lang.management.OperatingSystemMXBean;
import java.lang.management.RuntimeMXBean;
import java.lang.management.ThreadMXBean;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.pentaho.di.core.Const;
import org.pentaho.di.core.exception.KettleException;
import org.pentaho.di.core.xml.XMLHandler;
import org.pentaho.di.i18n.BaseMessages;
import org.pentaho.di.job.Job;
import org.pentaho.di.trans.Trans;

public class GetStatusServlet extends BaseHttpServlet implements CartePluginInterface {
  private static Class<?> PKG = GetStatusServlet.class; // for i18n purposes, needed by Translator2!!

  private static final long serialVersionUID = 3634806745372015720L;

  public static final String CONTEXT_PATH = "/kettle/status";

  public GetStatusServlet() {
  }

  public GetStatusServlet( TransformationMap transformationMap, JobMap jobMap ) {
    super( transformationMap, jobMap );
  }

  /**

/kettle/status

GET

Retrieve server status. The status contains information about the server itself (OS, memory, etc)
   and information about jobs and transformations present on the server.

Example Request:

   GET /kettle/status/?xml=Y

Parameters

   name
   description
   type

   xml
   Boolean flag which defines output format Y forces XML output to be generated.
   HTML is returned otherwise.
   boolean, optional

Response Body

   element:
   (custom)

   media types:
   text/xml, text/html

Response XML or HTML response containing details about the transformation specified.
   If an error occurs during method invocation result field of the response
   will contain ERROR status.

Example Response:

   <?xml version="1.0" encoding="UTF-8"?>
   <serverstatus>
   <statusdesc>Online</statusdesc>
   <memory_free>229093440</memory_free>
   <memory_total>285736960</memory_total>
   <cpu_cores>4</cpu_cores>
   <cpu_process_time>7534848300</cpu_process_time>
   <uptime>68818403</uptime>
   <thread_count>45</thread_count>
   <load_avg>-1.0</load_avg>
   <os_name>Windows 7</os_name>
   <os_version>6.1</os_version>
   <os_arch>amd64</os_arch>
   <transstatuslist>
   <transstatus>
   <transname>Row generator test</transname>
   <id>56c93d4e-96c1-4fae-92d9-d864b0779845</id>
   <status_desc>Waiting</status_desc>
   <error_desc/>
   <paused>N</paused>
   <stepstatuslist>
   </stepstatuslist>
   <first_log_line_nr>0</first_log_line_nr>
   <last_log_line_nr>0</last_log_line_nr>
   <logging_string><![CDATA[]]></logging_string>
   </transstatus>
   <transstatus>
   <transname>dummy-trans</transname>
   <id>c56961b2-c848-49b8-abde-76c8015e29b0</id>
   <status_desc>Stopped</status_desc>
   <error_desc/>
   <paused>N</paused>
   <stepstatuslist>
   </stepstatuslist>
   <first_log_line_nr>0</first_log_line_nr>
   <last_log_line_nr>0</last_log_line_nr>
   <logging_string><![CDATA[]]></logging_string>
   </transstatus>
   </transstatuslist>
   <jobstatuslist>
   <jobstatus>
   <jobname>dummy_job</jobname>
   <id>abd61143-8174-4f27-9037-6b22fbd3e229</id>
   <status_desc>Stopped</status_desc>
   <error_desc/>
   <logging_string><![CDATA[]]></logging_string>
   <first_log_line_nr>0</first_log_line_nr>
   <last_log_line_nr>0</last_log_line_nr>
   </jobstatus>
   </jobstatuslist>
   </serverstatus>

Status Codes

   code
   description

   200
   Request was processed.

   500
   Internal server error occurs during request processing.

   */
  public void doGet( HttpServletRequest request, HttpServletResponse response ) throws ServletException,
      IOException {
    if ( isJettyMode() && !request.getContextPath().startsWith( CONTEXT_PATH ) ) {
      return;
    }

    if ( log.isDebug() ) {
      logDebug( BaseMessages.getString( PKG, "GetStatusServlet.StatusRequested" ) );
    }
    response.setStatus( HttpServletResponse.SC_OK );
    String root = request.getRequestURI() == null ? StatusServletUtils.PENTAHO_ROOT
      : request.getRequestURI().substring( 0, request.getRequestURI().indexOf( CONTEXT_PATH ) );
    String prefix = isJettyMode() ? StatusServletUtils.STATIC_PATH : root + StatusServletUtils.RESOURCES_PATH;
    boolean useXML = "Y".equalsIgnoreCase( request.getParameter( "xml" ) );
    boolean useLightTheme = "Y".equalsIgnoreCase( request.getParameter( "useLightTheme" ) );

    if ( useXML ) {
      response.setContentType( "text/xml" );
      response.setCharacterEncoding( Const.XML_ENCODING );
    } else {
      response.setContentType( "text/html;charset=UTF-8" );
    }

    PrintWriter out = response.getWriter();

    List<CarteObjectEntry> transEntries = getTransformationMap().getTransformationObjects();
    List<CarteObjectEntry> jobEntries = getJobMap().getJobObjects();

    if ( useXML ) {
      out.print( XMLHandler.getXMLHeader( Const.XML_ENCODING ) );
      SlaveServerStatus serverStatus = new SlaveServerStatus();
      serverStatus.setStatusDescription( "Online" );

      getSystemInfo( serverStatus );

      for ( CarteObjectEntry entry : transEntries ) {
        Trans trans = getTransformationMap().getTransformation( entry );
        String status = trans.getStatus();

        SlaveServerTransStatus sstatus = new SlaveServerTransStatus( entry.getName(), entry.getId(), status );
        sstatus.setLogDate( trans.getLogDate() );
        sstatus.setPaused( trans.isPaused() );
        serverStatus.getTransStatusList().add( sstatus );
      }

      for ( CarteObjectEntry entry : jobEntries ) {
        Job job = getJobMap().getJob( entry );
        String status = job.getStatus();
        SlaveServerJobStatus jobStatus = new SlaveServerJobStatus( entry.getName(), entry.getId(), status );
        jobStatus.setLogDate( job.getLogDate() );
        serverStatus.getJobStatusList().add( jobStatus );
      }

      try {
        out.println( serverStatus.getXML() );
      } catch ( KettleException e ) {
        throw new ServletException( "Unable to get the server status in XML format", e );
      }
    } else {
      out.println( "" );
      out.println( "<TITLE>"
          + BaseMessages.getString( PKG, "GetStatusServlet.KettleSlaveServerStatus" ) + "</TITLE>" );
      out.println( "<META http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">" );

      int tableBorder = 1;
      if ( !useLightTheme ) {
        if ( isJettyMode() ) {
          out.println( "<link rel=\"stylesheet\" type=\"text/css\" href=\"/static/css/carte.css\" />" );
        } else {
          out.print( StatusServletUtils.getPentahoStyles() );
          out.println( "" );
        }
        tableBorder = 0;
      }

      out.println( "" );
      out.println( "" );

      // Empty div for containing currently selected item
      out.println( "
" );
      out.println( "<value></value>" ); //initialize to none
      out.println( "
" );

      out.println( "
" );

      String htmlClass = useLightTheme ? "h1" : "div";
      out.println( "<" + htmlClass + " class=\"workspaceHeading\" style=\"padding: 0px 0px 0px 10px;\">" + BaseMessages.getString( PKG, "GetStatusServlet.TopStatus" ) + "</" + htmlClass + ">" );
      out.println( "
" );

      // Tooltips
      String run = BaseMessages.getString( PKG, "CarteStatusServlet.Run" );
      String stop = BaseMessages.getString( PKG, "CarteStatusServlet.StopTrans" );
      String view = BaseMessages.getString( PKG, "CarteStatusServlet.ViewTransDetails" );
      String remove = BaseMessages.getString( PKG, "CarteStatusServlet.RemoveTrans" );
      String runJ = BaseMessages.getString( PKG, "CarteStatusServlet.Run" );
      String stopJ = BaseMessages.getString( PKG, "CarteStatusServlet.StopJob" );
      String viewJ = BaseMessages.getString( PKG, "CarteStatusServlet.ViewJobDetails" );
      String removeJ = BaseMessages.getString( PKG, "CarteStatusServlet.RemoveJob" );

      try {
        out.println( "
" );
        htmlClass = useLightTheme ? "h2" : "div";
        out.println( "
" );
        out.println( "<" + htmlClass + " class=\"workspaceHeading\" style=\"padding: 0px 0px 0px 0px;\">Transformations</" + htmlClass + ">" );
        out.println( "

" );
        out.println( "
" );
        out.println( "

" );
        out.println( "	" );
        out.println( "

	" );
        out.println( "

	" );
        out.println( "

	" );
        out.println( "

	" );
        out.println( "

" );
        out.println( "

Stop transformation

Stop input processing

" );
        out.println( messageDialog() );
        out.println( "
" );
        out.print( "
 "
            + BaseMessages.getString( PKG, "GetStatusServlet.TransName" ) + "	 "
            + BaseMessages.getString( PKG, "GetStatusServlet.CarteId" ) + "	 "
            + BaseMessages.getString( PKG, "GetStatusServlet.Status" ) + "	 "
            + BaseMessages.getString( PKG, "GetStatusServlet.LastLogDate" ) + "	 "
            + BaseMessages.getString( PKG, "GetStatusServlet.LastLogTime" ) + "
" );

        Comparator<CarteObjectEntry> transComparator = new Comparator<CarteObjectEntry>() {
          @Override
          public int compare( CarteObjectEntry o1, CarteObjectEntry o2 ) {
            Trans t1 = getTransformationMap().getTransformation( o1 );
            Trans t2 = getTransformationMap().getTransformation( o2 );
            Date d1 = t1.getLogDate();
            Date d2 = t2.getLogDate();
            // if both transformations have last log date, desc sort by log date
            if ( d1 != null && d2 != null ) {
              int logDateCompare = d2.compareTo( d1 );
              if ( logDateCompare != 0 ) {
                return logDateCompare;
              }
            }
            return o1.compareTo( o2 );
          }
        };

        Collections.sort( transEntries, transComparator );

        boolean evenRow = true;
        for ( int i = 0; i < transEntries.size(); i++ ) {
          String name = transEntries.get( i ).getName();
          String id = transEntries.get( i ).getId();
          Trans trans = getTransformationMap().getTransformation( transEntries.get( i ) );
          String status = trans.getStatus();
          String trClass = evenRow ? "cellTableEvenRow" : "cellTableOddRow"; // alternating row color
          String tdClass = evenRow ? "cellTableEvenRowCell" : "cellTableOddRowCell";
          evenRow = !evenRow; // flip
          String firstColumn = i == 0 ? "cellTableFirstColumn" : "";
          String lastColumn = i == transEntries.size() - 1 ? "cellTableLastColumn" : "";
          out.print( "
" );
          out.print( "" + name + "	" );
          out.print( "" + id + "	" );
          out.print( "" + status + "	" );
          String dateStr = XMLHandler.date2string( trans.getLogDate() );
          out.print( ""
              + ( trans.getLogDate() == null ? "-" : dateStr.substring( 0, dateStr.indexOf( ' ' ) ) ) + "	" );
          out.print( "" + dateStr.substring( dateStr.indexOf( ' ' ), dateStr.length() ) + "	" );
          out.print( "
" );
        }
        out.print( "

" );
        out.print( "
" ); // end div

        out.println( "
" );
        out.println( "<" + htmlClass + " class=\"workspaceHeading\" style=\"padding: 0px 0px 0px 0px;\">Jobs</" + htmlClass + ">" );
        out.println( "

" );
        out.println( "
" );
        out.println( "

" );
        out.println( "	" );
        out.println( "

	" );
        out.println( "

	" );
        out.println( "

	" );
        out.println( "

	" );
        out.println( "

" );
        out.println( "
" );
        out.print( "
 "
            + BaseMessages.getString( PKG, "GetStatusServlet.JobName" ) + "	 "
            + BaseMessages.getString( PKG, "GetStatusServlet.CarteId" ) + "	 "
            + BaseMessages.getString( PKG, "GetStatusServlet.Status" ) + "	 "
            + BaseMessages.getString( PKG, "GetStatusServlet.LastLogDate" ) + "	 "
            + BaseMessages.getString( PKG, "GetStatusServlet.LastLogTime" ) + "
" );

        Comparator<CarteObjectEntry> jobComparator = new Comparator<CarteObjectEntry>() {
          @Override
          public int compare( CarteObjectEntry o1, CarteObjectEntry o2 ) {
            Job t1 = getJobMap().getJob( o1 );
            Job t2 = getJobMap().getJob( o2 );
            Date d1 = t1.getLogDate();
            Date d2 = t2.getLogDate();
            // if both jobs have last log date, desc sort by log date
            if ( d1 != null && d2 != null ) {
              int logDateCompare = d2.compareTo( d1 );
              if ( logDateCompare != 0 ) {
                return logDateCompare;
              }
            }
            return o1.compareTo( o2 );
          }
        };

        Collections.sort( jobEntries, jobComparator );

        evenRow = true;
        for ( int i = 0; i < jobEntries.size(); i++ ) {
          String name = jobEntries.get( i ).getName();
          String id = jobEntries.get( i ).getId();
          Job job = getJobMap().getJob( jobEntries.get( i ) );
          String status = job.getStatus();
          String trClass = evenRow ? "cellTableEvenRow" : "cellTableOddRow"; // alternating row color
          String tdClass = evenRow ? "cellTableEvenRowCell" : "cellTableOddRowCell";
          evenRow = !evenRow; // flip
          out.print( "
" );
          out.print( "" + name + "	" );
          out.print( "" + id + "	" );
          out.print( "" + status + "	" );
          String dateStr = XMLHandler.date2string( job.getLogDate() );
          out.print( ""
              + ( job.getLogDate() == null ? "-" : dateStr.substring( 0, dateStr.indexOf( ' ' ) ) ) + "	" );
          out.print( "" + dateStr.substring( dateStr.indexOf( ' ' ), dateStr.length() ) + "	" );
          out.print( "
" );
        }
        out.print( "

" );
        out.print( "
" ); // end div

      } catch ( Exception ex ) {
        out.println( "
" );
        ex.printStackTrace( out );
        out.println( "
" );
      }

      out.println( "
" );
      htmlClass = useLightTheme ? "h3" : "div";
      out.println( "
<" + htmlClass + " class=\"workspaceHeading\">"
          + BaseMessages.getString( PKG, "GetStatusServlet.ConfigurationDetails.Title" ) + "</" + htmlClass + ">
" );
      out.println( "
" );
//      out.print( "
 "
//          + BaseMessages.getString( PKG, "GetStatusServlet.Parameter.Title" ) + "	 "
//          + BaseMessages.getString( PKG, "GetStatusServlet.Value.Title" ) + "
" );

      // The max number of log lines in the back-end
      //
      SlaveServerConfig serverConfig = getTransformationMap().getSlaveServerConfig();
      if ( serverConfig != null ) {
        String maxLines = "";
        if ( serverConfig.getMaxLogLines() == 0 ) {
          maxLines = BaseMessages.getString( PKG, "GetStatusServlet.NoLimit" );
        } else {
          maxLines = serverConfig.getMaxLogLines() + BaseMessages.getString( PKG, "GetStatusServlet.Lines" );
        }
        out.print( "
 "
            + BaseMessages.getString( PKG, "GetStatusServlet.Parameter.MaxLogLines" ) + "	 " + maxLines
            + "
" );

        // The max age of log lines
        //
        String maxAge = "";
        if ( serverConfig.getMaxLogTimeoutMinutes() == 0 ) {
          maxAge = BaseMessages.getString( PKG, "GetStatusServlet.NoLimit" );
        } else {
          maxAge = serverConfig.getMaxLogTimeoutMinutes() + BaseMessages.getString( PKG, "GetStatusServlet.Minutes" );
        }
        out.print( "
 "
            + BaseMessages.getString( PKG, "GetStatusServlet.Parameter.MaxLogLinesAge" ) + "	 " + maxAge
            + "
" );

        // The max age of stale objects
        //
        String maxObjAge = "";
        if ( serverConfig.getObjectTimeoutMinutes() == 0 ) {
          maxObjAge = BaseMessages.getString( PKG, "GetStatusServlet.NoLimit" );
        } else {
          maxObjAge = serverConfig.getObjectTimeoutMinutes() + BaseMessages.getString( PKG, "GetStatusServlet.Minutes" );
        }
        out.print( "
 "
            + BaseMessages.getString( PKG, "GetStatusServlet.Parameter.MaxObjectsAge" ) + "	 " + maxObjAge
            + "
" );

        // The name of the specified repository
        //
        String repositoryName;
        try {
          repositoryName = serverConfig.getRepository() != null ? serverConfig.getRepository().getName() : "";
        } catch ( Exception e ) {
          logError( BaseMessages.getString( PKG, "GetStatusServlet.Parameter.RepositoryName.UnableToConnect",
              serverConfig.getRepositoryId() ), e );
          repositoryName = BaseMessages.getString( PKG, "GetStatusServlet.Parameter.RepositoryName.UnableToConnect",
              serverConfig.getRepositoryId() );
        }
        out.print( "
 "
            + BaseMessages.getString( PKG, "GetStatusServlet.Parameter.RepositoryName" ) + "	 "
            + repositoryName + "
" );

        out.print( "
" );

        String filename = serverConfig.getFilename();
        if ( filename == null ) {
          filename = BaseMessages.getString( PKG, "GetStatusServlet.ConfigurationDetails.UsingDefaults" );
        }
        out.println( "
" ); // end div
        out.print( "
" );
        out
            .println( ""
                + BaseMessages.getString( PKG, "GetStatusServlet.ConfigurationDetails.Advice", filename )
                + "" );
        out.print( "
" );
        out.print( "
" );
        out.print( "
" );
      }

      out.println( "" );

      out.println( "" );
      out.println( "" );
    }
  }

  private static void getSystemInfo( SlaveServerStatus serverStatus ) {
    OperatingSystemMXBean operatingSystemMXBean =
        java.lang.management.ManagementFactory.getOperatingSystemMXBean();
    ThreadMXBean threadMXBean = java.lang.management.ManagementFactory.getThreadMXBean();
    RuntimeMXBean runtimeMXBean = java.lang.management.ManagementFactory.getRuntimeMXBean();

    int cores = Runtime.getRuntime().availableProcessors();

    long freeMemory = Runtime.getRuntime().freeMemory();
    long totalMemory = Runtime.getRuntime().totalMemory();
    String osArch = operatingSystemMXBean.getArch();
    String osName = operatingSystemMXBean.getName();
    String osVersion = operatingSystemMXBean.getVersion();
    double loadAvg = operatingSystemMXBean.getSystemLoadAverage();

    int threadCount = threadMXBean.getThreadCount();
    long allThreadsCpuTime = 0L;

    long[] threadIds = threadMXBean.getAllThreadIds();
    for ( int i = 0; i < threadIds.length; i++ ) {
      allThreadsCpuTime += threadMXBean.getThreadCpuTime( threadIds[i] );
    }

    long uptime = runtimeMXBean.getUptime();

    serverStatus.setCpuCores( cores );
    serverStatus.setCpuProcessTime( allThreadsCpuTime );
    serverStatus.setUptime( uptime );
    serverStatus.setThreadCount( threadCount );
    serverStatus.setLoadAvg( loadAvg );
    serverStatus.setOsName( osName );
    serverStatus.setOsVersion( osVersion );
    serverStatus.setOsArchitecture( osArch );
    serverStatus.setMemoryFree( freeMemory );
    serverStatus.setMemoryTotal( totalMemory );
  }

  public String toString() {
    return "Status Handler";
  }

  public String getService() {
    return CONTEXT_PATH + " (" + toString() + ")";
  }

  public String getContextPath() {
    return CONTEXT_PATH;
  }

  private String setupIconEnterLeaveJavascript( String id ) {
    return "onMouseEnter=\"if( !document.getElementById('"
      + id + "').classList.contains('toolbar-button-disabled') ) { document.getElementById('"
      + id + "').classList.add('toolbar-button-hovering') }\" onMouseLeave=\"document.getElementById('"
      + id + "').classList.remove('toolbar-button-hovering')\"";
  }

  private String messageDialog() {
    String retVal = "

\n";
    retVal += "<div class=\"pentaho-dialog\" id=\"messageDialog\" style=\"visibility: hidden; margin: 0; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); -ms-transform: translate(-50%, -50%);"
      + "-webkit-transform: translate(-50%, -50%); padding: 30px; height: auto; width: 423px; border: 1px solid #CCC; -webkit-box-shadow: none; -moz-box-shadow: none;"
      + "box-shadow: none; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; overflow: hidden; line-height: 20px; background-color: #FFF; z-index: 10000;\">\n";
    retVal += "

\n";
    retVal += "

\n";
    retVal += "
\n<button class=\"pentaho-button\" style=\"float: right;\" onclick=\"closeMessageDialog( true );\">\n" + BaseMessages.getString( PKG, "GetStatusServlet.Button.OK" ) + "\n</button>\n
\n";
    retVal += "
\n<button class=\"pentaho-button\" style=\"float: right; margin-left: 10px;\" onclick=\"closeMessageDialog( false );\">\n" + BaseMessages.getString( PKG, "GetStatusServlet.Button.No" ) + "\n</button>\n<button class=\"pentaho-button\" style=\"float: right;\" onclick=\"closeMessageDialog( false ); removeSelection();\">\n" + BaseMessages.getString( PKG, "GetStatusServlet.Button.YesRemove" ) + "\n</button>\n
\n";
    retVal += "
\n";
    return retVal;
  }

  private String setupAjaxCall( String uri, String title, String success, String failure ) {
    String retVal = "";
    retVal += "var xhttp = new XMLHttpRequest();\n";
    retVal += "xhttp.onreadystatechange = function() {\n";
    retVal += " if ( this.readyState === 4 ) {\n";
    retVal += "   if ( this.status === 200 ) {\n";
    retVal += "     openMessageDialog( '" + title + "', " + success + ", true );\n";
    retVal += "   } else {\n";
    retVal += "     openMessageDialog( '" + BaseMessages.getString( PKG, "GetStatusServlet.UnableTo.Label" )
      + " " + title + "', " + failure +  ", true );\n";
    retVal += "   }\n";
    retVal += " }\n";
    retVal += "};\n";
    retVal += "xhttp.open( \"GET\", " + uri + ", true );\n";
    retVal += "xhttp.send();\n";
    return retVal;
  }

  private String setupTransURI( String context ) {
    return "'" + context + "'"
      + " + '?name=' + document.getElementById( 'cellTableFirstCell' + selectedTransRowIndex ).innerHTML"
      + " + '&id=' + document.getElementById( 'cellTableCell' + selectedTransRowIndex ).innerHTML";
  }

  private String setupJobURI( String context ) {
    return "'" + context + "'"
      + " + '?name=' + document.getElementById( 'j-cellTableFirstCell' + selectedJobRowIndex ).innerHTML"
      + " + '&id=' + document.getElementById( 'j-cellTableCell' + selectedJobRowIndex ).innerHTML";
  }
}


text:
cask 'superproductivity' do
  version '4.1.1'
  sha256 '762b59b1a2fbc58590a129f6a13db30603642b044301ea95fc912c4c63c8e068'

  # github.com/johannesjo/super-productivity was verified as official when first introduced to the cask
  url "https://github.com/johannesjo/super-productivity/releases/download/v#{version}/superProductivity-#{version}-mac.zip"
  appcast 'https://github.com/johannesjo/super-productivity/releases.atom'
  name 'Super Productivity'
  homepage 'https://super-productivity.com/'

  app 'superProductivity.app'
end

redpajama_set_name: RedPajamaGithub


text:
<!doctype html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(() => {
  assert_throws_js(TypeError, () => {
    new NavigateEvent("navigate");
  });
}, "can't bypass required members by omitting the dictionary entirely");

test(() => {
  assert_throws_js(TypeError, () => {
    new NavigateEvent("navigate", {
      navigationType: "push",
      canIntercept: false,
      userInitiated: false,
      hashChange: false,
      signal: (new AbortController()).signal,
      formData: null,
      downloadRequest: null,
      info: null
    });
  });
}, "destination is required");

async_test(t => {
  // We need to grab an NavigationDestination.
  navigation.onnavigate = t.step_func_done(e => {
    assert_throws_js(TypeError, () => {
      new NavigateEvent("navigate", {
        navigationType: "push",
        destination: e.destination,
        canIntercept: false,
        userInitiated: false,
        hashChange: false,
        formData: null,
        downloadRequest: null,
        info: null
      });
    });
  });
  history.pushState(1, null, "#1");
}, "signal is required");

async_test(t => {
  // We need to grab an NavigationDestination.
  navigation.onnavigate = t.step_func_done(e => {
    const info = { some: "object with identity" };
    const formData = new FormData();
    const signal = (new AbortController()).signal;
    const downloadRequest = "abc";

    const event = new NavigateEvent("navigate", {
      navigationType: "replace",
      destination: e.destination,
      canIntercept: true,
      userInitiated: true,
      hashChange: true,
      signal,
      formData,
      downloadRequest,
      info
    });

    assert_equals(event.navigationType, "replace");
    assert_equals(event.destination, e.destination);
    assert_equals(event.canIntercept, true);
    assert_equals(event.userInitiated, true);
    assert_equals(event.hashChange, true);
    assert_equals(event.signal, signal);
    assert_equals(event.formData, formData);
    assert_equals(event.downloadRequest, downloadRequest);
    assert_equals(event.info, info);
  });
  history.pushState(2, null, "#2");
}, "all properties are reflected back");

async_test(t => {
  // We need to grab an NavigationDestination.
  navigation.onnavigate = t.step_func_done(e => {
    const event = new NavigateEvent("navigate", {
      destination: e.destination,
      signal: (new AbortController()).signal
    });

    assert_equals(event.navigationType, "push");
    assert_equals(event.canIntercept, false);
    assert_equals(event.userInitiated, false);
    assert_equals(event.hashChange, false);
    assert_equals(event.formData, null);
    assert_equals(event.downloadRequest, null);
    assert_equals(event.info, undefined);
  });
  history.pushState(3, null, "#3");
}, "defaults are as expected");
</script>


text:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <pthread.h>
#include <sched.h>
#include <sys/ioctl.h>
#ifdef HAVE_ALLOCA_H
# include <alloca.h>
#endif

#include "xf86drm.h"
#include "amdgpu_drm.h"
#include "amdgpu_internal.h"

static int amdgpu_cs_unreference_sem(amdgpu_semaphore_handle sem);
static int amdgpu_cs_reset_sem(amdgpu_semaphore_handle sem);

/**
 * Create command submission context
 *
 * \param   dev      - \c [in] Device handle. See #amdgpu_device_initialize()
 * \param   priority - \c [in] Context creation flags. See AMDGPU_CTX_PRIORITY_*
 * \param   context  - \c [out] GPU Context handle
 *
 * \return  0 on success otherwise POSIX Error code
*/
drm_public int amdgpu_cs_ctx_create2(amdgpu_device_handle dev,
				     uint32_t priority,
				     amdgpu_context_handle *context)
{
	struct amdgpu_context *gpu_context;
	union drm_amdgpu_ctx args;
	int i, j, k;
	int r;

	if (!dev || !context)
		return -EINVAL;

	gpu_context = calloc(1, sizeof(struct amdgpu_context));
	if (!gpu_context)
		return -ENOMEM;

	gpu_context->dev = dev;

	r = pthread_mutex_init(&gpu_context->sequence_mutex, NULL);
	if (r)
		goto error;

	/* Create the context */
	memset(&args, 0, sizeof(args));
	args.in.op = AMDGPU_CTX_OP_ALLOC_CTX;
	args.in.priority = priority;

	r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_CTX, &args, sizeof(args));
	if (r)
		goto error;

	gpu_context->id = args.out.alloc.ctx_id;
	for (i = 0; i < AMDGPU_HW_IP_NUM; i++)
		for (j = 0; j < AMDGPU_HW_IP_INSTANCE_MAX_COUNT; j++)
			for (k = 0; k < AMDGPU_CS_MAX_RINGS; k++)
				list_inithead(&gpu_context->sem_list[i][j][k]);
	*context = (amdgpu_context_handle)gpu_context;

	return 0;

error:
	pthread_mutex_destroy(&gpu_context->sequence_mutex);
	free(gpu_context);
	return r;
}

drm_public int amdgpu_cs_ctx_create(amdgpu_device_handle dev,
				    amdgpu_context_handle *context)
{
	return amdgpu_cs_ctx_create2(dev, AMDGPU_CTX_PRIORITY_NORMAL, context);
}

/**
 * Release command submission context
 *
 * \param   dev - \c [in] amdgpu device handle
 * \param   context - \c [in] amdgpu context handle
 *
 * \return  0 on success otherwise POSIX Error code
*/
drm_public int amdgpu_cs_ctx_free(amdgpu_context_handle context)
{
	union drm_amdgpu_ctx args;
	int i, j, k;
	int r;

	if (!context)
		return -EINVAL;

	pthread_mutex_destroy(&context->sequence_mutex);

	/* now deal with kernel side */
	memset(&args, 0, sizeof(args));
	args.in.op = AMDGPU_CTX_OP_FREE_CTX;
	args.in.ctx_id = context->id;
	r = drmCommandWriteRead(context->dev->fd, DRM_AMDGPU_CTX,
				&args, sizeof(args));
	for (i = 0; i < AMDGPU_HW_IP_NUM; i++) {
		for (j = 0; j < AMDGPU_HW_IP_INSTANCE_MAX_COUNT; j++) {
			for (k = 0; k < AMDGPU_CS_MAX_RINGS; k++) {
				amdgpu_semaphore_handle sem;
				LIST_FOR_EACH_ENTRY(sem, &context->sem_list[i][j][k], list) {
					list_del(&sem->list);
					amdgpu_cs_reset_sem(sem);
					amdgpu_cs_unreference_sem(sem);
				}
			}
		}
	}
	free(context);

	return r;
}

drm_public int amdgpu_cs_ctx_override_priority(amdgpu_device_handle dev,
                                               amdgpu_context_handle context,
                                               int master_fd,
                                               unsigned priority)
{
	union drm_amdgpu_sched args;
	int r;

	if (!dev || !context || master_fd < 0)
		return -EINVAL;

	memset(&args, 0, sizeof(args));

	args.in.op = AMDGPU_SCHED_OP_CONTEXT_PRIORITY_OVERRIDE;
	args.in.fd = dev->fd;
	args.in.priority = priority;
	args.in.ctx_id = context->id;

	r = drmCommandWrite(master_fd, DRM_AMDGPU_SCHED, &args, sizeof(args));
	if (r)
		return r;

	return 0;
}

drm_public int amdgpu_cs_query_reset_state(amdgpu_context_handle context,
					   uint32_t *state, uint32_t *hangs)
{
	union drm_amdgpu_ctx args;
	int r;

	if (!context)
		return -EINVAL;

	memset(&args, 0, sizeof(args));
	args.in.op = AMDGPU_CTX_OP_QUERY_STATE;
	args.in.ctx_id = context->id;
	r = drmCommandWriteRead(context->dev->fd, DRM_AMDGPU_CTX,
				&args, sizeof(args));
	if (!r) {
		*state = args.out.state.reset_status;
		*hangs = args.out.state.hangs;
	}
	return r;
}

drm_public int amdgpu_cs_query_reset_state2(amdgpu_context_handle context,
					    uint64_t *flags)
{
	union drm_amdgpu_ctx args;
	int r;

	if (!context)
		return -EINVAL;

	memset(&args, 0, sizeof(args));
	args.in.op = AMDGPU_CTX_OP_QUERY_STATE2;
	args.in.ctx_id = context->id;
	r = drmCommandWriteRead(context->dev->fd, DRM_AMDGPU_CTX,
				&args, sizeof(args));
	if (!r)
		*flags = args.out.state.flags;
	return r;
}

/**
 * Submit command to kernel DRM
 * \param   dev - \c [in]  Device handle
 * \param   context - \c [in]  GPU Context
 * \param   ibs_request - \c [in]  Pointer to submission requests
 * \param   fence - \c [out] return fence for this submission
 *
 * \return  0 on success otherwise POSIX Error code
 * \sa amdgpu_cs_submit()
*/
static int amdgpu_cs_submit_one(amdgpu_context_handle context,
				struct amdgpu_cs_request *ibs_request)
{
	union drm_amdgpu_cs cs;
	uint64_t *chunk_array;
	struct drm_amdgpu_cs_chunk *chunks;
	struct drm_amdgpu_cs_chunk_data *chunk_data;
	struct drm_amdgpu_cs_chunk_dep *dependencies = NULL;
	struct drm_amdgpu_cs_chunk_dep *sem_dependencies = NULL;
	struct list_head *sem_list;
	amdgpu_semaphore_handle sem, tmp;
	uint32_t i, size, sem_count = 0;
	bool user_fence;
	int r = 0;

	if (ibs_request->ip_type >= AMDGPU_HW_IP_NUM)
		return -EINVAL;
	if (ibs_request->ring >= AMDGPU_CS_MAX_RINGS)
		return -EINVAL;
	if (ibs_request->number_of_ibs == 0) {
		ibs_request->seq_no = AMDGPU_NULL_SUBMIT_SEQ;
		return 0;
	}
	user_fence = (ibs_request->fence_info.handle != NULL);

	size = ibs_request->number_of_ibs + (user_fence ? 2 : 1) + 1;

	chunk_array = alloca(sizeof(uint64_t) * size);
	chunks = alloca(sizeof(struct drm_amdgpu_cs_chunk) * size);

	size = ibs_request->number_of_ibs + (user_fence ? 1 : 0);

	chunk_data = alloca(sizeof(struct drm_amdgpu_cs_chunk_data) * size);

	memset(&cs, 0, sizeof(cs));
	cs.in.chunks = (uint64_t)(uintptr_t)chunk_array;
	cs.in.ctx_id = context->id;
	if (ibs_request->resources)
		cs.in.bo_list_handle = ibs_request->resources->handle;
	cs.in.num_chunks = ibs_request->number_of_ibs;
	/* IB chunks */
	for (i = 0; i < ibs_request->number_of_ibs; i++) {
		struct amdgpu_cs_ib_info *ib;
		chunk_array[i] = (uint64_t)(uintptr_t)&chunks[i];
		chunks[i].chunk_id = AMDGPU_CHUNK_ID_IB;
		chunks[i].length_dw = sizeof(struct drm_amdgpu_cs_chunk_ib) / 4;
		chunks[i].chunk_data = (uint64_t)(uintptr_t)&chunk_data[i];

		ib = &ibs_request->ibs[i];

		chunk_data[i].ib_data._pad = 0;
		chunk_data[i].ib_data.va_start = ib->ib_mc_address;
		chunk_data[i].ib_data.ib_bytes = ib->size * 4;
		chunk_data[i].ib_data.ip_type = ibs_request->ip_type;
		chunk_data[i].ib_data.ip_instance = ibs_request->ip_instance;
		chunk_data[i].ib_data.ring = ibs_request->ring;
		chunk_data[i].ib_data.flags = ib->flags;
	}

	pthread_mutex_lock(&context->sequence_mutex);

	if (user_fence) {
		i = cs.in.num_chunks++;

		/* fence chunk */
		chunk_array[i] = (uint64_t)(uintptr_t)&chunks[i];
		chunks[i].chunk_id = AMDGPU_CHUNK_ID_FENCE;
		chunks[i].length_dw = sizeof(struct drm_amdgpu_cs_chunk_fence) / 4;
		chunks[i].chunk_data = (uint64_t)(uintptr_t)&chunk_data[i];

		/* fence bo handle */
		chunk_data[i].fence_data.handle = ibs_request->fence_info.handle->handle;
		/* offset */
		chunk_data[i].fence_data.offset =
			ibs_request->fence_info.offset * sizeof(uint64_t);
	}

	if (ibs_request->number_of_dependencies) {
		dependencies = malloc(sizeof(struct drm_amdgpu_cs_chunk_dep) *
			ibs_request->number_of_dependencies);
		if (!dependencies) {
			r = -ENOMEM;
			goto error_unlock;
		}

		for (i = 0; i < ibs_request->number_of_dependencies; ++i) {
			struct amdgpu_cs_fence *info = &ibs_request->dependencies[i];
			struct drm_amdgpu_cs_chunk_dep *dep = &dependencies[i];
			dep->ip_type = info->ip_type;
			dep->ip_instance = info->ip_instance;
			dep->ring = info->ring;
			dep->ctx_id = info->context->id;
			dep->handle = info->fence;
		}

		i = cs.in.num_chunks++;

		/* dependencies chunk */
		chunk_array[i] = (uint64_t)(uintptr_t)&chunks[i];
		chunks[i].chunk_id = AMDGPU_CHUNK_ID_DEPENDENCIES;
		chunks[i].length_dw = sizeof(struct drm_amdgpu_cs_chunk_dep) / 4
			* ibs_request->number_of_dependencies;
		chunks[i].chunk_data = (uint64_t)(uintptr_t)dependencies;
	}

	sem_list = &context->sem_list[ibs_request->ip_type][ibs_request->ip_instance][ibs_request->ring];
	LIST_FOR_EACH_ENTRY(sem, sem_list, list)
		sem_count++;
	if (sem_count) {
		sem_dependencies = malloc(sizeof(struct drm_amdgpu_cs_chunk_dep) * sem_count);
		if (!sem_dependencies) {
			r = -ENOMEM;
			goto error_unlock;
		}
		sem_count = 0;
		LIST_FOR_EACH_ENTRY_SAFE(sem, tmp, sem_list, list) {
			struct amdgpu_cs_fence *info = &sem->signal_fence;
			struct drm_amdgpu_cs_chunk_dep *dep = &sem_dependencies[sem_count++];
			dep->ip_type = info->ip_type;
			dep->ip_instance = info->ip_instance;
			dep->ring = info->ring;
			dep->ctx_id = info->context->id;
			dep->handle = info->fence;

			list_del(&sem->list);
			amdgpu_cs_reset_sem(sem);
			amdgpu_cs_unreference_sem(sem);
		}
		i = cs.in.num_chunks++;

		/* dependencies chunk */
		chunk_array[i] = (uint64_t)(uintptr_t)&chunks[i];
		chunks[i].chunk_id = AMDGPU_CHUNK_ID_DEPENDENCIES;
		chunks[i].length_dw = sizeof(struct drm_amdgpu_cs_chunk_dep) / 4 * sem_count;
		chunks[i].chunk_data = (uint64_t)(uintptr_t)sem_dependencies;
	}

	r = drmCommandWriteRead(context->dev->fd, DRM_AMDGPU_CS,
				&cs, sizeof(cs));
	if (r)
		goto error_unlock;

	ibs_request->seq_no = cs.out.handle;
	context->last_seq[ibs_request->ip_type][ibs_request->ip_instance][ibs_request->ring] = ibs_request->seq_no;
error_unlock:
	pthread_mutex_unlock(&context->sequence_mutex);
	free(dependencies);
	free(sem_dependencies);
	return r;
}

drm_public int amdgpu_cs_submit(amdgpu_context_handle context,
				uint64_t flags,
				struct amdgpu_cs_request *ibs_request,
				uint32_t number_of_requests)
{
	uint32_t i;
	int r;

	if (!context || !ibs_request)
		return -EINVAL;

	r = 0;
	for (i = 0; i < number_of_requests; i++) {
		r = amdgpu_cs_submit_one(context, ibs_request);
		if (r)
			break;
		ibs_request++;
	}

	return r;
}

/**
 * Calculate absolute timeout.
 *
 * \param   timeout - \c [in] timeout in nanoseconds.
 *
 * \return  absolute timeout in nanoseconds
*/
drm_private uint64_t amdgpu_cs_calculate_timeout(uint64_t timeout)
{
	int r;

	if (timeout != AMDGPU_TIMEOUT_INFINITE) {
		struct timespec current;
		uint64_t current_ns;
		r = clock_gettime(CLOCK_MONOTONIC, &current);
		if (r) {
			fprintf(stderr, "clock_gettime() returned error (%d)!", errno);
			return AMDGPU_TIMEOUT_INFINITE;
		}

		current_ns = ((uint64_t)current.tv_sec) * 1000000000ull;
		current_ns += current.tv_nsec;
		timeout += current_ns;
		if (timeout < current_ns)
			timeout = AMDGPU_TIMEOUT_INFINITE;
	}
	return timeout;
}

static int amdgpu_ioctl_wait_cs(amdgpu_context_handle context,
				unsigned ip,
				unsigned ip_instance,
				uint32_t ring,
				uint64_t handle,
				uint64_t timeout_ns,
				uint64_t flags,
				bool *busy)
{
	amdgpu_device_handle dev = context->dev;
	union drm_amdgpu_wait_cs args;
	int r;

	memset(&args, 0, sizeof(args));
	args.in.handle = handle;
	args.in.ip_type = ip;
	args.in.ip_instance = ip_instance;
	args.in.ring = ring;
	args.in.ctx_id = context->id;

	if (flags & AMDGPU_QUERY_FENCE_TIMEOUT_IS_ABSOLUTE)
		args.in.timeout = timeout_ns;
	else
		args.in.timeout = amdgpu_cs_calculate_timeout(timeout_ns);

	r = drmIoctl(dev->fd, DRM_IOCTL_AMDGPU_WAIT_CS, &args);
	if (r)
		return -errno;

	*busy = args.out.status;
	return 0;
}

drm_public int amdgpu_cs_query_fence_status(struct amdgpu_cs_fence *fence,
					    uint64_t timeout_ns,
					    uint64_t flags,
					    uint32_t *expired)
{
	bool busy = true;
	int r;

	if (!fence || !expired || !fence->context)
		return -EINVAL;
	if (fence->ip_type >= AMDGPU_HW_IP_NUM)
		return -EINVAL;
	if (fence->ring >= AMDGPU_CS_MAX_RINGS)
		return -EINVAL;
	if (fence->fence == AMDGPU_NULL_SUBMIT_SEQ) {
		*expired = true;
		return 0;
	}

	*expired = false;

	r = amdgpu_ioctl_wait_cs(fence->context, fence->ip_type,
				fence->ip_instance, fence->ring,
			       	fence->fence, timeout_ns, flags, &busy);

	if (!r && !busy)
		*expired = true;

	return r;
}

static int amdgpu_ioctl_wait_fences(struct amdgpu_cs_fence *fences,
				    uint32_t fence_count,
				    bool wait_all,
				    uint64_t timeout_ns,
				    uint32_t *status,
				    uint32_t *first)
{
	struct drm_amdgpu_fence *drm_fences;
	amdgpu_device_handle dev = fences[0].context->dev;
	union drm_amdgpu_wait_fences args;
	int r;
	uint32_t i;

	drm_fences = alloca(sizeof(struct drm_amdgpu_fence) * fence_count);
	for (i = 0; i < fence_count; i++) {
		drm_fences[i].ctx_id = fences[i].context->id;
		drm_fences[i].ip_type = fences[i].ip_type;
		drm_fences[i].ip_instance = fences[i].ip_instance;
		drm_fences[i].ring = fences[i].ring;
		drm_fences[i].seq_no = fences[i].fence;
	}

	memset(&args, 0, sizeof(args));
	args.in.fences = (uint64_t)(uintptr_t)drm_fences;
	args.in.fence_count = fence_count;
	args.in.wait_all = wait_all;
	args.in.timeout_ns = amdgpu_cs_calculate_timeout(timeout_ns);

	r = drmIoctl(dev->fd, DRM_IOCTL_AMDGPU_WAIT_FENCES, &args);
	if (r)
		return -errno;

	*status = args.out.status;

	if (first)
		*first = args.out.first_signaled;

	return 0;
}

drm_public int amdgpu_cs_wait_fences(struct amdgpu_cs_fence *fences,
				     uint32_t fence_count,
				     bool wait_all,
				     uint64_t timeout_ns,
				     uint32_t *status,
				     uint32_t *first)
{
	uint32_t i;

	/* Sanity check */
	if (!fences || !status || !fence_count)
		return -EINVAL;

	for (i = 0; i < fence_count; i++) {
		if (NULL == fences[i].context)
			return -EINVAL;
		if (fences[i].ip_type >= AMDGPU_HW_IP_NUM)
			return -EINVAL;
		if (fences[i].ring >= AMDGPU_CS_MAX_RINGS)
			return -EINVAL;
	}

	*status = 0;

	return amdgpu_ioctl_wait_fences(fences, fence_count, wait_all,
					timeout_ns, status, first);
}

drm_public int amdgpu_cs_create_semaphore(amdgpu_semaphore_handle *sem)
{
	struct amdgpu_semaphore *gpu_semaphore;

	if (!sem)
		return -EINVAL;

	gpu_semaphore = calloc(1, sizeof(struct amdgpu_semaphore));
	if (!gpu_semaphore)
		return -ENOMEM;

	atomic_set(&gpu_semaphore->refcount, 1);
	*sem = gpu_semaphore;

	return 0;
}

drm_public int amdgpu_cs_signal_semaphore(amdgpu_context_handle ctx,
					  uint32_t ip_type,
			       uint32_t ip_instance,
			       uint32_t ring,
			       amdgpu_semaphore_handle sem)
{
	if (!ctx || !sem)
		return -EINVAL;
	if (ip_type >= AMDGPU_HW_IP_NUM)
		return -EINVAL;
	if (ring >= AMDGPU_CS_MAX_RINGS)
		return -EINVAL;
	/* sem has been signaled */
	if (sem->signal_fence.context)
		return -EINVAL;
	pthread_mutex_lock(&ctx->sequence_mutex);
	sem->signal_fence.context = ctx;
	sem->signal_fence.ip_type = ip_type;
	sem->signal_fence.ip_instance = ip_instance;
	sem->signal_fence.ring = ring;
	sem->signal_fence.fence = ctx->last_seq[ip_type][ip_instance][ring];
	update_references(NULL, &sem->refcount);
	pthread_mutex_unlock(&ctx->sequence_mutex);
	return 0;
}

drm_public int amdgpu_cs_wait_semaphore(amdgpu_context_handle ctx,
					uint32_t ip_type,
			     uint32_t ip_instance,
			     uint32_t ring,
			     amdgpu_semaphore_handle sem)
{
	if (!ctx || !sem)
		return -EINVAL;
	if (ip_type >= AMDGPU_HW_IP_NUM)
		return -EINVAL;
	if (ring >= AMDGPU_CS_MAX_RINGS)
		return -EINVAL;
	/* must signal first */
	if (!sem->signal_fence.context)
		return -EINVAL;

	pthread_mutex_lock(&ctx->sequence_mutex);
	list_add(&sem->list, &ctx->sem_list[ip_type][ip_instance][ring]);
	pthread_mutex_unlock(&ctx->sequence_mutex);
	return 0;
}

static int amdgpu_cs_reset_sem(amdgpu_semaphore_handle sem)
{
	if (!sem || !sem->signal_fence.context)
		return -EINVAL;

	sem->signal_fence.context = NULL;
	sem->signal_fence.ip_type = 0;
	sem->signal_fence.ip_instance = 0;
	sem->signal_fence.ring = 0;
	sem->signal_fence.fence = 0;

	return 0;
}

static int amdgpu_cs_unreference_sem(amdgpu_semaphore_handle sem)
{
	if (!sem)
		return -EINVAL;

	if (update_references(&sem->refcount, NULL))
		free(sem);
	return 0;
}

drm_public int amdgpu_cs_destroy_semaphore(amdgpu_semaphore_handle sem)
{
	return amdgpu_cs_unreference_sem(sem);
}

drm_public int amdgpu_cs_create_syncobj2(amdgpu_device_handle dev,
					 uint32_t  flags,
					 uint32_t *handle)
{
	if (NULL == dev)
		return -EINVAL;

	return drmSyncobjCreate(dev->fd, flags, handle);
}

drm_public int amdgpu_cs_create_syncobj(amdgpu_device_handle dev,
					uint32_t *handle)
{
	if (NULL == dev)
		return -EINVAL;

	return drmSyncobjCreate(dev->fd, 0, handle);
}

drm_public int amdgpu_cs_destroy_syncobj(amdgpu_device_handle dev,
					 uint32_t handle)
{
	if (NULL == dev)
		return -EINVAL;

	return drmSyncobjDestroy(dev->fd, handle);
}

drm_public int amdgpu_cs_syncobj_reset(amdgpu_device_handle dev,
				       const uint32_t *syncobjs,
				       uint32_t syncobj_count)
{
	if (NULL == dev)
		return -EINVAL;

	return drmSyncobjReset(dev->fd, syncobjs, syncobj_count);
}

drm_public int amdgpu_cs_syncobj_signal(amdgpu_device_handle dev,
					const uint32_t *syncobjs,
					uint32_t syncobj_count)
{
	if (NULL == dev)
		return -EINVAL;

	return drmSyncobjSignal(dev->fd, syncobjs, syncobj_count);
}

drm_public int amdgpu_cs_syncobj_timeline_signal(amdgpu_device_handle dev,
						 const uint32_t *syncobjs,
						 uint64_t *points,
						 uint32_t syncobj_count)
{
	if (NULL == dev)
		return -EINVAL;

	return drmSyncobjTimelineSignal(dev->fd, syncobjs,
					points, syncobj_count);
}

drm_public int amdgpu_cs_syncobj_wait(amdgpu_device_handle dev,
				      uint32_t *handles, unsigned num_handles,
				      int64_t timeout_nsec, unsigned flags,
				      uint32_t *first_signaled)
{
	if (NULL == dev)
		return -EINVAL;

	return drmSyncobjWait(dev->fd, handles, num_handles, timeout_nsec,
			      flags, first_signaled);
}

drm_public int amdgpu_cs_syncobj_timeline_wait(amdgpu_device_handle dev,
					       uint32_t *handles, uint64_t *points,
					       unsigned num_handles,
					       int64_t timeout_nsec, unsigned flags,
					       uint32_t *first_signaled)
{
	if (NULL == dev)
		return -EINVAL;

	return drmSyncobjTimelineWait(dev->fd, handles, points, num_handles,
				      timeout_nsec, flags, first_signaled);
}

drm_public int amdgpu_cs_syncobj_query(amdgpu_device_handle dev,
				       uint32_t *handles, uint64_t *points,
				       unsigned num_handles)
{
	if (NULL == dev)
		return -EINVAL;

	return drmSyncobjQuery(dev->fd, handles, points, num_handles);
}

drm_public int amdgpu_cs_export_syncobj(amdgpu_device_handle dev,
					uint32_t handle,
					int *shared_fd)
{
	if (NULL == dev)
		return -EINVAL;

	return drmSyncobjHandleToFD(dev->fd, handle, shared_fd);
}

drm_public int amdgpu_cs_import_syncobj(amdgpu_device_handle dev,
					int shared_fd,
					uint32_t *handle)
{
	if (NULL == dev)
		return -EINVAL;

	return drmSyncobjFDToHandle(dev->fd, shared_fd, handle);
}

drm_public int amdgpu_cs_syncobj_export_sync_file(amdgpu_device_handle dev,
						  uint32_t syncobj,
						  int *sync_file_fd)
{
	if (NULL == dev)
		return -EINVAL;

	return drmSyncobjExportSyncFile(dev->fd, syncobj, sync_file_fd);
}

drm_public int amdgpu_cs_syncobj_import_sync_file(amdgpu_device_handle dev,
						  uint32_t syncobj,
						  int sync_file_fd)
{
	if (NULL == dev)
		return -EINVAL;

	return drmSyncobjImportSyncFile(dev->fd, syncobj, sync_file_fd);
}

drm_public int amdgpu_cs_syncobj_export_sync_file2(amdgpu_device_handle dev,
						   uint32_t syncobj,
						   uint64_t point,
						   uint32_t flags,
						   int *sync_file_fd)
{
	uint32_t binary_handle;
	int ret;

	if (NULL == dev)
		return -EINVAL;

	if (!point)
		return drmSyncobjExportSyncFile(dev->fd, syncobj, sync_file_fd);

	ret = drmSyncobjCreate(dev->fd, 0, &binary_handle);
	if (ret)
		return ret;

	ret = drmSyncobjTransfer(dev->fd, binary_handle, 0,
				 syncobj, point, flags);
	if (ret)
		goto out;
	ret = drmSyncobjExportSyncFile(dev->fd, binary_handle, sync_file_fd);
out:
	drmSyncobjDestroy(dev->fd, binary_handle);
	return ret;
}

drm_public int amdgpu_cs_syncobj_import_sync_file2(amdgpu_device_handle dev,
						   uint32_t syncobj,
						   uint64_t point,
						   int sync_file_fd)
{
	uint32_t binary_handle;
	int ret;

	if (NULL == dev)
		return -EINVAL;

	if (!point)
		return drmSyncobjImportSyncFile(dev->fd, syncobj, sync_file_fd);

	ret = drmSyncobjCreate(dev->fd, 0, &binary_handle);
	if (ret)
		return ret;
	ret = drmSyncobjImportSyncFile(dev->fd, binary_handle, sync_file_fd);
	if (ret)
		goto out;
	ret = drmSyncobjTransfer(dev->fd, syncobj, point,
				 binary_handle, 0, 0);
out:
	drmSyncobjDestroy(dev->fd, binary_handle);
	return ret;
}

drm_public int amdgpu_cs_syncobj_transfer(amdgpu_device_handle dev,
					  uint32_t dst_handle,
					  uint64_t dst_point,
					  uint32_t src_handle,
					  uint64_t src_point,
					  uint32_t flags)
{
	if (NULL == dev)
		return -EINVAL;

	return drmSyncobjTransfer(dev->fd,
				  dst_handle, dst_point,
				  src_handle, src_point,
				  flags);
}

drm_public int amdgpu_cs_submit_raw(amdgpu_device_handle dev,
				    amdgpu_context_handle context,
				    amdgpu_bo_list_handle bo_list_handle,
				    int num_chunks,
				    struct drm_amdgpu_cs_chunk *chunks,
				    uint64_t *seq_no)
{
	union drm_amdgpu_cs cs;
	uint64_t *chunk_array;
	int i, r;
	if (num_chunks == 0)
		return -EINVAL;

	memset(&cs, 0, sizeof(cs));
	chunk_array = alloca(sizeof(uint64_t) * num_chunks);
	for (i = 0; i < num_chunks; i++)
		chunk_array[i] = (uint64_t)(uintptr_t)&chunks[i];
	cs.in.chunks = (uint64_t)(uintptr_t)chunk_array;
	cs.in.ctx_id = context->id;
	cs.in.bo_list_handle = bo_list_handle ? bo_list_handle->handle : 0;
	cs.in.num_chunks = num_chunks;
	r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_CS,
				&cs, sizeof(cs));
	if (r)
		return r;

	if (seq_no)
		*seq_no = cs.out.handle;
	return 0;
}

drm_public int amdgpu_cs_submit_raw2(amdgpu_device_handle dev,
				     amdgpu_context_handle context,
				     uint32_t bo_list_handle,
				     int num_chunks,
				     struct drm_amdgpu_cs_chunk *chunks,
				     uint64_t *seq_no)
{
	union drm_amdgpu_cs cs;
	uint64_t *chunk_array;
	int i, r;

	memset(&cs, 0, sizeof(cs));
	chunk_array = alloca(sizeof(uint64_t) * num_chunks);
	for (i = 0; i < num_chunks; i++)
		chunk_array[i] = (uint64_t)(uintptr_t)&chunks[i];
	cs.in.chunks = (uint64_t)(uintptr_t)chunk_array;
	cs.in.ctx_id = context->id;
	cs.in.bo_list_handle = bo_list_handle;
	cs.in.num_chunks = num_chunks;
	r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_CS,
				&cs, sizeof(cs));
	if (!r && seq_no)
		*seq_no = cs.out.handle;
	return r;
}

drm_public void amdgpu_cs_chunk_fence_info_to_data(struct amdgpu_cs_fence_info *fence_info,
					struct drm_amdgpu_cs_chunk_data *data)
{
	data->fence_data.handle = fence_info->handle->handle;
	data->fence_data.offset = fence_info->offset * sizeof(uint64_t);
}

drm_public void amdgpu_cs_chunk_fence_to_dep(struct amdgpu_cs_fence *fence,
					struct drm_amdgpu_cs_chunk_dep *dep)
{
	dep->ip_type = fence->ip_type;
	dep->ip_instance = fence->ip_instance;
	dep->ring = fence->ring;
	dep->ctx_id = fence->context->id;
	dep->handle = fence->fence;
}

drm_public int amdgpu_cs_fence_to_handle(amdgpu_device_handle dev,
					 struct amdgpu_cs_fence *fence,
					 uint32_t what,
					 uint32_t *out_handle)
{
	union drm_amdgpu_fence_to_handle fth;
	int r;

	memset(&fth, 0, sizeof(fth));
	fth.in.fence.ctx_id = fence->context->id;
	fth.in.fence.ip_type = fence->ip_type;
	fth.in.fence.ip_instance = fence->ip_instance;
	fth.in.fence.ring = fence->ring;
	fth.in.fence.seq_no = fence->fence;
	fth.in.what = what;

	r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_FENCE_TO_HANDLE,
				&fth, sizeof(fth));
	if (r == 0)
		*out_handle = fth.out.handle;
	return r;
}


text:
/*************************************************************************/
/*  test_io.cpp                                                          */
/*************************************************************************/
/*                       This file is part of:                           */
/*                           GODOT ENGINE                                */
/*                      https://godotengine.org                          */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur.                 */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md)    */
/*                                                                       */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the       */
/* "Software"), to deal in the Software without restriction, including   */
/* without limitation the rights to use, copy, modify, merge, publish,   */
/* distribute, sublicense, and/or sell copies of the Software, and to    */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions:                                             */
/*                                                                       */
/* The above copyright notice and this permission notice shall be        */
/* included in all copies or substantial portions of the Software.       */
/*                                                                       */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY  */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,  */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE     */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */
/*************************************************************************/
#include "test_io.h"

#ifdef MINIZIP_ENABLED

#include "core/project_settings.h"
#include "io/resource_loader.h"
#include "io/resource_saver.h"
#include "os/dir_access.h"
#include "os/main_loop.h"
#include "os/os.h"
#include "print_string.h"
#include "scene/resources/texture.h"

#include "io/file_access_memory.h"

namespace TestIO {

class TestMainLoop : public MainLoop {

	bool quit;

public:
	virtual void input_event(const InputEvent &p_event) {
	}
	virtual bool idle(float p_time) {
		return false;
	}

	virtual void request_quit() {

		quit = true;
	}
	virtual void init() {

		quit = true;
	}
	virtual bool iteration(float p_time) {

		return quit;
	}
	virtual void finish() {
	}
};

MainLoop *test() {

	print_line("this is test io");
	DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
	da->change_dir(".");
	print_line("Opening current dir " + da->get_current_dir());
	String entry;
	da->list_dir_begin();
	while ((entry = da->get_next()) != "") {

		print_line("entry " + entry + " is dir: " + Variant(da->current_is_dir()));
	};
	da->list_dir_end();

	RES texture = ResourceLoader::load("test_data/rock.png");
	ERR_FAIL_COND_V(texture.is_null(), NULL);

	ResourceSaver::save("test_data/rock.xml", texture);

	print_line("localize paths");
	print_line(ProjectSettings::get_singleton()->localize_path("algo.xml"));
	print_line(ProjectSettings::get_singleton()->localize_path("c:\\windows\\algo.xml"));
	print_line(ProjectSettings::get_singleton()->localize_path(ProjectSettings::get_singleton()->get_resource_path() + "/something/something.xml"));
	print_line(ProjectSettings::get_singleton()->localize_path("somedir/algo.xml"));

	{

		FileAccess *z = FileAccess::open("test_data/archive.zip", FileAccess::READ);
		int len = z->get_len();
		Vector<uint8_t> zip;
		zip.resize(len);
		z->get_buffer(&zip[0], len);
		z->close();
		memdelete(z);

		FileAccessMemory::register_file("a_package", zip);
		FileAccess::make_default<FileAccessMemory>(FileAccess::ACCESS_RESOURCES);
		FileAccess::make_default<FileAccessMemory>(FileAccess::ACCESS_FILESYSTEM);
		FileAccess::make_default<FileAccessMemory>(FileAccess::ACCESS_USERDATA);

		print_line("archive test");
	};

	print_line("test done");

	return memnew(TestMainLoop);
}
}

#else

namespace TestIO {

MainLoop *test() {

	return NULL;
}
}
#endif


text:
import * as volumeDataActions from './volume-data.actions'
import * as fromVolumeData from './volume-data.reducer'

describe('VolumeDataReducer', () => {
  const { initialState } = fromVolumeData

  describe('Destroy action', () => {
    it('should return the default state', () => {
      const action = new volumeDataActions.Destroy()
      const state = fromVolumeData.reducer(undefined, action)

      expect(state).toBe(initialState)
    })
  })

  describe('Load Fail action', () => {
    it('should set loadFail to true', () => {
      const action = new volumeDataActions.LoadFail()
      const state = fromVolumeData.reducer(initialState, action)

      expect(state.loadFail).toEqual(true)
    })
  })

  describe('Load Success action', () => {
    it('should populate volume data', () => {
      const volume = {
        header: {
          projectName: 'test',
          sources: [],
          subjectId: 'IFODJ',
          timeWindow: 'ONE_DAY'
        },
        dataset: [
          {
            startDateTime: '2017-08-28T23:00:00Z',
            value: 0
          }
        ]
      }

      const action = new volumeDataActions.LoadSuccess(volume)
      const state = fromVolumeData.reducer(initialState, action)

      expect(state.isLoaded).toEqual(true)
      expect(state.loadFail).toEqual(false)
      expect(state.timeWindowChanged).toEqual(false)
      expect(state.timeFrameChanged).toEqual(false)
      expect(state.entities[0]).toEqual({ id: '0', data: volume.dataset[0] })
    })
  })

  describe('Set Time Frame action', () => {
    it('should set timeframe', () => {
      const timeFrame = { startDateTime: new Date(), endDateTime: new Date() }
      const action = new volumeDataActions.SetTimeFrame(timeFrame)
      const state = fromVolumeData.reducer(initialState, action)

      expect(state.timeFrame).toEqual(timeFrame)
    })
  })

  describe('Set Time Frame action', () => {
    it('should set timeframe when no timeframe is specified', () => {
      const timeFrame = { startDateTime: null, endDateTime: null }
      const action = new volumeDataActions.SetTimeFrame(timeFrame)
      const state = fromVolumeData.reducer(initialState, action)

      expect(state.timeFrame.startDateTime).toBeTruthy()
    })
  })

  describe('Set Time Interval action', () => {
    it('should set time interval', () => {
      const timeInterval = 'ONE_HOUR'
      const action = new volumeDataActions.SetTimeInterval(timeInterval)
      const state = fromVolumeData.reducer(initialState, action)

      expect(state.timeWindow).toEqual(timeInterval)
    })
  })
})


text:
(function (factory) {
  if (typeof define === 'function' && define.amd) { define(['backbone', 'd3'], factory);
  } else if (typeof exports === 'object') { module.exports = factory(require('backbone'), require('d3'));
  } else { factory(Backbone, d3); }
}(function (Backbone, d3) {

  // Cached regex to match an opening '<' of an HTML tag, possibly left-padded
  // with whitespace.
  var paddedLt = /^\s*</;

  // Cache array methods for later use.
  var slice = [].slice;

  // Events need a unique id for attaching multiple events of the same type.
  var uniqueId = 0;

  // Store eventsMap for undelegation.
  var _eventsMap = {};

  Backbone.D3ViewMixin = {

    // A reference to the d3 selection backing the view.
    d3el: null,

    namespace: d3.ns.prefix.svg,

    $: function(selector) {
      return this.el.querySelectorAll(selector);
    },

    $$: function(selector) {
      return this.d3el.selectAll(selector);
    },

    _removeElement: function() {
      this.undelegateEvents();
      delete _eventsMap[this.cid];
      this.d3el.remove();
    },

    _createElement: function(tagName) {
      var ns = _.result(this, 'namespace');
      return ns ?
         document.createElementNS(ns, tagName) :
         document.createElement(tagName);
    },

    _setElement: function(element) {
      if (typeof element == 'string') {
        if (paddedLt.test(element)) {
          var el = document.createElement('div');
          el.innerHTML = element;
          this.el = el.firstChild;
        } else {
          this.el = document.querySelector(element);
        }
      } else {
        this.el = element;
      }

      this.d3el = d3.select(this.el);
    },

    _setAttributes: function(attributes) {
      this.d3el.attr(attributes);
    },

    // `delegate` supports two- and three-arg forms. The `selector` is optional.
    delegate: function(eventName, selector, listener) {
      var el;

      if (typeof selector === 'string') {
        el = selector === '' ? this.d3el : this.d3el.selectAll(selector);
      } else {
        el = this.d3el;
        listener = selector;
        selector = null;
      }

      // d3 needs `uniqueId` to delegate more than one listener per event type.
      var namespace = '.' + uniqueId++;

      var map = _eventsMap[this.cid] || (_eventsMap[this.cid] = {}),
          handlers = map[eventName] || (map[eventName] = []);

      handlers.push({selector: selector, listener: listener, namespace: namespace});

      // The `event` object is stored in `d3.event` but Backbone expects it as
      // the first argument to the listener.
      el.on(eventName + namespace, function() {
        var args = slice.call(arguments);
        args.unshift(d3.event);
        listener.apply(this, args);
      });
      return this;
    },

    undelegate: function(eventName, selector, listener) {
      if (typeof selector !== 'string') {
        listener = selector;
        selector = null;
      }

      var map = _eventsMap[this.cid] || (_eventsMap[this.cid] = {}),
          handlers = map[eventName];

      _(handlers).chain()
        .filter(function(handler) {
          return (listener ? handler.listener === listener : true) &&
            (selector ? handler.selector === selector : true);
        })
        .forEach(function(handler) {
          removeEvent(this.d3el, eventName, selector || handler.selector, handler.namespace);
          handlers.splice(_.indexOf(handlers, handler), 1);
        }, this);
    },

    undelegateEvents: function() {
      if (!this.d3el) return;

      var map = _eventsMap[this.cid] || (_eventsMap[this.cid] = {});

      for (var eventName in map) {
        _.each(map[eventName], function(handler) {
          removeEvent(this.d3el, eventName, handler.selector, handler.namespace);
        }, this);
      }

      _eventsMap[this.cid] = {};
      return this;
    }
  };

  // Avoid a costly loop through handlers for `undelegateEvents`.
  var removeEvent = function(d3el, eventName, selector, namespace) {
    var el = selector ? d3el.selectAll(selector) : d3el;
    el.on(eventName + namespace, null);
  }

  Backbone.D3View = Backbone.View.extend(Backbone.D3ViewMixin);

  return Backbone.D3View;
}));


text:
ACCEPTED

#### According to
Index Fungorum

#### Published in
null

#### Original name
Rhachomyces lathrobii Thaxt.

### Remarks
null


text:
extern crate libc;

// CUDA types

pub type size_t = ::libc::c_ulong;
pub type Enum_cudaError = ::libc::c_uint;
pub type Enum_cudaMemcpyKind = ::libc::c_uint;

pub type cudaMemoryPtr = *mut ::libc::c_void;

pub enum MemcpyKind {
    cudaMemcpyHostToHost = 0,
    cudaMemcpyHostToDevice = 1,
    cudaMemcpyDeviceToHost = 2,
    cudaMemcpyDeviceToDevice = 3,
    cudaMemcpyDefault = 4,
}

pub type cudaError_t = Enum_cudaError;

// CUDNN types

pub enum Struct_CUstream_st { }
pub type cudaStream_t = *mut Struct_CUstream_st;

pub enum Struct_cudnnContext { }
pub type cudnnHandle_t = *mut Struct_cudnnContext;

#[repr(C)]
#[derive(PartialEq, Debug, Copy, Clone)]
pub enum cudnnStatus_t {
    CUDNN_STATUS_SUCCESS = 0,
    CUDNN_STATUS_NOT_INITIALIZED = 1,
    CUDNN_STATUS_ALLOC_FAILED = 2,
    CUDNN_STATUS_BAD_PARAM = 3,
    CUDNN_STATUS_INTERNAL_ERROR = 4,
    CUDNN_STATUS_INVALID_VALUE = 5,
    CUDNN_STATUS_ARCH_MISMATCH = 6,
    CUDNN_STATUS_MAPPING_ERROR = 7,
    CUDNN_STATUS_EXECUTION_FAILED = 8,
    CUDNN_STATUS_NOT_SUPPORTED = 9,
    CUDNN_STATUS_LICENSE_ERROR = 10,
}

pub enum Struct_cudnnTensorStruct { }
pub type cudnnTensorDescriptor_t = *mut Struct_cudnnTensorStruct;

pub enum Struct_cudnnConvolutionStruct { }
pub type cudnnConvolutionDescriptor_t = *mut Struct_cudnnConvolutionStruct;

pub enum Struct_cudnnPoolingStruct { }
pub type cudnnPoolingDescriptor_t = *mut Struct_cudnnPoolingStruct;

pub enum Struct_cudnnFilterStruct { }
pub type cudnnFilterDescriptor_t = *mut Struct_cudnnFilterStruct;

pub enum Struct_cudnnLRNStruct { }
pub type cudnnLRNDescriptor_t = *mut Struct_cudnnLRNStruct;

#[repr(C)]
#[derive(PartialEq, Debug, Copy, Clone)]
pub enum cudnnDataType_t {
    CUDNN_DATA_FLOAT = 0,
    CUDNN_DATA_DOUBLE = 1,
    CUDNN_DATA_HALF = 2,
}

#[repr(C)]
#[derive(PartialEq, Debug, Copy, Clone)]
pub enum cudnnTensorFormat_t {
    CUDNN_TENSOR_NCHW = 0,
    CUDNN_TENSOR_NHWC = 1,
}

#[repr(C)]
#[derive(PartialEq, Debug, Copy, Clone)]
pub enum cudnnAddMode_t {
    CUDNN_ADD_IMAGE = 0,
    CUDNN_ADD_FEATURE_MAP = 1,
    CUDNN_ADD_SAME_C = 2,
    CUDNN_ADD_FULL_TENSOR = 3,
}

#[repr(C)]
#[derive(PartialEq, Debug, Copy, Clone)]
pub enum cudnnConvolutionMode_t {
    CUDNN_CONVOLUTION = 0,
    CUDNN_CROSS_CORRELATION = 1,
}

#[repr(C)]
#[derive(PartialEq, Debug, Copy, Clone)]
pub enum cudnnConvolutionFwdPreference_t {
    CUDNN_CONVOLUTION_FWD_NO_WORKSPACE = 0,
    CUDNN_CONVOLUTION_FWD_PREFER_FASTEST = 1,
    CUDNN_CONVOLUTION_FWD_SPECIFY_WORKSPACE_LIMIT = 2,
}

#[repr(C)]
#[derive(PartialEq, Debug, Copy, Clone)]
pub enum cudnnConvolutionFwdAlgo_t {
    CUDNN_CONVOLUTION_FWD_ALGO_IMPLICIT_GEMM = 0,
    CUDNN_CONVOLUTION_FWD_ALGO_IMPLICIT_PRECOMP_GEMM = 1,
    CUDNN_CONVOLUTION_FWD_ALGO_GEMM = 2,
    CUDNN_CONVOLUTION_FWD_ALGO_DIRECT = 3,
    CUDNN_CONVOLUTION_FWD_ALGO_FFT = 4,
    CUDNN_CONVOLUTION_FWD_ALGO_FFT_TILING = 5,
}

#[repr(C)]
#[derive(Copy)]
pub struct Struct_Unnamed14 {
    pub algo: cudnnConvolutionFwdAlgo_t,
    pub status: cudnnStatus_t,
    pub time: ::libc::c_float,
    pub memory: ::libc::size_t,
}
impl ::std::clone::Clone for Struct_Unnamed14 {
    fn clone(&self) -> Self { *self }
}
impl ::std::default::Default for Struct_Unnamed14 {
    fn default() -> Self { unsafe { ::std::mem::zeroed() } }
}
pub type cudnnConvolutionFwdAlgoPerf_t = Struct_Unnamed14;

#[repr(C)]
#[derive(PartialEq, Debug, Copy, Clone)]
pub enum cudnnConvolutionBwdFilterPreference_t {
    CUDNN_CONVOLUTION_BWD_FILTER_NO_WORKSPACE = 0,
    CUDNN_CONVOLUTION_BWD_FILTER_PREFER_FASTEST = 1,
    CUDNN_CONVOLUTION_BWD_FILTER_SPECIFY_WORKSPACE_LIMIT = 2,
}

#[repr(C)]
#[derive(PartialEq, Debug, Copy, Clone)]
pub enum cudnnConvolutionBwdFilterAlgo_t {
    CUDNN_CONVOLUTION_BWD_FILTER_ALGO_0 = 0,
    CUDNN_CONVOLUTION_BWD_FILTER_ALGO_1 = 1,
    CUDNN_CONVOLUTION_BWD_FILTER_ALGO_FFT = 2,
    CUDNN_CONVOLUTION_BWD_FILTER_ALGO_3 = 3,
}

#[repr(C)]
#[derive(Copy)]
pub struct Struct_Unnamed17 {
    pub algo: cudnnConvolutionBwdFilterAlgo_t,
    pub status: cudnnStatus_t,
    pub time: ::libc::c_float,
    pub memory: ::libc::size_t,
}

impl ::std::clone::Clone for Struct_Unnamed17 {
    fn clone(&self) -> Self { *self }
}

impl ::std::default::Default for Struct_Unnamed17 {
    fn default() -> Self { unsafe { ::std::mem::zeroed() } }
}

pub type cudnnConvolutionBwdFilterAlgoPerf_t = Struct_Unnamed17;

#[repr(C)]
#[derive(PartialEq, Debug, Copy, Clone)]
pub enum cudnnConvolutionBwdDataPreference_t {
    CUDNN_CONVOLUTION_BWD_DATA_NO_WORKSPACE = 0,
    CUDNN_CONVOLUTION_BWD_DATA_PREFER_FASTEST = 1,
    CUDNN_CONVOLUTION_BWD_DATA_SPECIFY_WORKSPACE_LIMIT = 2,
}

#[repr(C)]
#[derive(PartialEq, Debug, Copy, Clone)]
pub enum cudnnConvolutionBwdDataAlgo_t {
    CUDNN_CONVOLUTION_BWD_DATA_ALGO_0 = 0,
    CUDNN_CONVOLUTION_BWD_DATA_ALGO_1 = 1,
    CUDNN_CONVOLUTION_BWD_DATA_ALGO_FFT = 2,
    CUDNN_CONVOLUTION_BWD_DATA_ALGO_FFT_TILING = 3,
}

#[repr(C)]
#[derive(Copy)]
pub struct Struct_Unnamed20 {
    pub algo: cudnnConvolutionBwdDataAlgo_t,
    pub status: cudnnStatus_t,
    pub time: ::libc::c_float,
    pub memory: ::libc::size_t,
}

impl ::std::clone::Clone for Struct_Unnamed20 {
    fn clone(&self) -> Self { *self }
}

impl ::std::default::Default for Struct_Unnamed20 {
    fn default() -> Self { unsafe { ::std::mem::zeroed() } }
}

pub type cudnnConvolutionBwdDataAlgoPerf_t = Struct_Unnamed20;

#[repr(C)]
#[derive(PartialEq, Debug, Copy, Clone)]
pub enum cudnnSoftmaxAlgorithm_t {
    CUDNN_SOFTMAX_FAST = 0,
    CUDNN_SOFTMAX_ACCURATE = 1,
    CUDNN_SOFTMAX_LOG = 2,
}

#[repr(C)]
#[derive(PartialEq, Debug, Copy, Clone)]
pub enum cudnnSoftmaxMode_t {
    CUDNN_SOFTMAX_MODE_INSTANCE = 0,
    CUDNN_SOFTMAX_MODE_CHANNEL = 1,
}

#[repr(C)]
#[derive(PartialEq, Debug, Copy, Clone)]
pub enum cudnnPoolingMode_t {
    CUDNN_POOLING_MAX = 0,
    CUDNN_POOLING_AVERAGE_COUNT_INCLUDE_PADDING = 1,
    CUDNN_POOLING_AVERAGE_COUNT_EXCLUDE_PADDING = 2,
}

#[repr(C)]
#[derive(PartialEq, Debug, Copy, Clone)]
pub enum cudnnActivationMode_t {
    CUDNN_ACTIVATION_SIGMOID = 0,
    CUDNN_ACTIVATION_RELU = 1,
    CUDNN_ACTIVATION_TANH = 2,
}

pub type Enum_Unnamed25 = ::libc::c_uint;
pub const CUDNN_LRN_CROSS_CHANNEL_DIM1: ::libc::c_uint = 0;
pub type cudnnLRNMode_t = Enum_Unnamed25;

pub type Enum_Unnamed26 = ::libc::c_uint;
pub const CUDNN_DIVNORM_PRECOMPUTED_MEANS: ::libc::c_uint = 0;
pub type cudnnDivNormMode_t = Enum_Unnamed26;

extern "C" {
    pub fn cudnnGetVersion() -> ::libc::size_t;

    pub fn cudnnGetErrorString(status: cudnnStatus_t) -> *const ::libc::c_char;

    pub fn cudnnCreate(handle: *mut cudnnHandle_t) -> cudnnStatus_t;

    pub fn cudnnDestroy(handle: cudnnHandle_t) -> cudnnStatus_t;

    pub fn cudnnSetStream(handle: cudnnHandle_t, streamId: cudaStream_t) -> cudnnStatus_t;

    pub fn cudnnGetStream(handle: cudnnHandle_t, streamId: *mut cudaStream_t) -> cudnnStatus_t;

    pub fn cudnnCreateTensorDescriptor(tensorDesc: *mut cudnnTensorDescriptor_t) -> cudnnStatus_t;

    pub fn cudnnSetTensor4dDescriptor(
        tensorDesc: cudnnTensorDescriptor_t,
        format: cudnnTensorFormat_t,
        dataType: cudnnDataType_t,
        n: ::libc::c_int,
        c: ::libc::c_int,
        h: ::libc::c_int,
        w: ::libc::c_int
    ) -> cudnnStatus_t;

    pub fn cudnnSetTensor4dDescriptorEx(
        tensorDesc: cudnnTensorDescriptor_t,
        dataType: cudnnDataType_t,
        n: ::libc::c_int,
        c: ::libc::c_int,
        h: ::libc::c_int,
        w: ::libc::c_int,
        nStride: ::libc::c_int,
        cStride: ::libc::c_int,
        hStride: ::libc::c_int,
        wStride: ::libc::c_int
    ) -> cudnnStatus_t;

    pub fn cudnnGetTensor4dDescriptor(
        tensorDesc: cudnnTensorDescriptor_t,
        dataType: *mut cudnnDataType_t,
        n: *mut ::libc::c_int,
        c: *mut ::libc::c_int,
        h: *mut ::libc::c_int,
        w: *mut ::libc::c_int,
        nStride: *mut ::libc::c_int,
        cStride: *mut ::libc::c_int,
        hStride: *mut ::libc::c_int,
        wStride: *mut ::libc::c_int
    ) -> cudnnStatus_t;

    pub fn cudnnSetTensorNdDescriptor(
        tensorDesc: cudnnTensorDescriptor_t,
        dataType: cudnnDataType_t,
        nbDims: ::libc::c_int,
        dimA: *const ::libc::c_int,
        strideA: *const ::libc::c_int
    ) -> cudnnStatus_t;

    pub fn cudnnGetTensorNdDescriptor(
        tensorDesc: cudnnTensorDescriptor_t,
        nbDimsRequested: ::libc::c_int,
        dataType: *mut cudnnDataType_t,
        nbDims: *mut ::libc::c_int,
        dimA: *mut ::libc::c_int,
        strideA: *mut ::libc::c_int
    ) -> cudnnStatus_t;

    pub fn cudnnDestroyTensorDescriptor(tensorDesc: cudnnTensorDescriptor_t) -> cudnnStatus_t;

    pub fn cudnnTransformTensor(
        handle: cudnnHandle_t,
        alpha: *const ::libc::c_void,
        srcDesc: cudnnTensorDescriptor_t,
        srcData: *const ::libc::c_void,
        beta: *const ::libc::c_void,
        destDesc: cudnnTensorDescriptor_t,
        destData: *mut ::libc::c_void
    ) -> cudnnStatus_t;

    pub fn cudnnAddTensor(
        handle: cudnnHandle_t, mode: cudnnAddMode_t,
        alpha: *const ::libc::c_void,
        biasDesc: cudnnTensorDescriptor_t,
        biasData: *const ::libc::c_void,
        beta: *const ::libc::c_void,
        srcDestDesc: cudnnTensorDescriptor_t,
        srcDestData: *mut ::libc::c_void
    ) -> cudnnStatus_t;

    pub fn cudnnAddTensor_v3(
        handle: cudnnHandle_t,
        alpha: *const ::libc::c_void,
        biasDesc: cudnnTensorDescriptor_t,
        biasData: *const ::libc::c_void,
        beta: *const ::libc::c_void,
        srcDestDesc: cudnnTensorDescriptor_t,
        srcDestData: *mut ::libc::c_void
    ) -> cudnnStatus_t;

    pub fn cudnnSetTensor(
        handle: cudnnHandle_t,
        srcDestDesc: cudnnTensorDescriptor_t,
        srcDestData: *mut ::libc::c_void,
        value: *const ::libc::c_void
    ) -> cudnnStatus_t;

    pub fn cudnnScaleTensor(
        handle: cudnnHandle_t,
        srcDestDesc: cudnnTensorDescriptor_t,
        srcDestData: *mut ::libc::c_void,
        alpha: *const ::libc::c_void
    ) -> cudnnStatus_t;

    pub fn cudnnCreateFilterDescriptor(filterDesc: *mut cudnnFilterDescriptor_t) -> cudnnStatus_t;

    pub fn cudnnSetFilter4dDescriptor(
        filterDesc: cudnnFilterDescriptor_t,
        dataType: cudnnDataType_t,
        k: ::libc::c_int, c: ::libc::c_int,
        h: ::libc::c_int, w: ::libc::c_int
    ) -> cudnnStatus_t;

    pub fn cudnnGetFilter4dDescriptor(
        filterDesc: cudnnFilterDescriptor_t,
        dataType: *mut cudnnDataType_t,
        k: *mut ::libc::c_int,
        c: *mut ::libc::c_int,
        h: *mut ::libc::c_int,
        w: *mut ::libc::c_int
    ) -> cudnnStatus_t;

    pub fn cudnnSetFilterNdDescriptor(
        filterDesc: cudnnFilterDescriptor_t,
        dataType: cudnnDataType_t,
        nbDims: ::libc::c_int,
        filterDimA: *const ::libc::c_int
    ) -> cudnnStatus_t;

    pub fn cudnnGetFilterNdDescriptor(
        filterDesc: cudnnFilterDescriptor_t,
        nbDimsRequested: ::libc::c_int,
        dataType: *mut cudnnDataType_t,
        nbDims: *mut ::libc::c_int,
        filterDimA: *mut ::libc::c_int
    ) -> cudnnStatus_t;

    pub fn cudnnDestroyFilterDescriptor(filterDesc: cudnnFilterDescriptor_t) -> cudnnStatus_t;

    pub fn cudnnCreateConvolutionDescriptor(convDesc: *mut cudnnConvolutionDescriptor_t) -> cudnnStatus_t;

    pub fn cudnnSetConvolution2dDescriptor(
        convDesc: cudnnConvolutionDescriptor_t,
        pad_h: ::libc::c_int,
        pad_w: ::libc::c_int,
        u: ::libc::c_int, v: ::libc::c_int,
        upscalex: ::libc::c_int,
        upscaley: ::libc::c_int,
        mode: cudnnConvolutionMode_t
    ) -> cudnnStatus_t;

    pub fn cudnnGetConvolution2dDescriptor(
        convDesc: cudnnConvolutionDescriptor_t,
        pad_h: *mut ::libc::c_int,
        pad_w: *mut ::libc::c_int,
        u: *mut ::libc::c_int,
        v: *mut ::libc::c_int,
        upscalex: *mut ::libc::c_int,
        upscaley: *mut ::libc::c_int,
        mode: *mut cudnnConvolutionMode_t
    ) -> cudnnStatus_t;

    pub fn cudnnGetConvolution2dForwardOutputDim(
        convDesc: cudnnConvolutionDescriptor_t,
        inputTensorDesc: cudnnTensorDescriptor_t,
        filterDesc: cudnnFilterDescriptor_t,
        n: *mut ::libc::c_int,
        c: *mut ::libc::c_int,
        h: *mut ::libc::c_int,
        w: *mut ::libc::c_int
    ) -> cudnnStatus_t;

    pub fn cudnnSetConvolutionNdDescriptor(
        convDesc: cudnnConvolutionDescriptor_t,
        arrayLength: ::libc::c_int,
        padA: *const ::libc::c_int,
        filterStrideA: *const ::libc::c_int,
        upscaleA: *const ::libc::c_int,
        mode: cudnnConvolutionMode_t
    ) -> cudnnStatus_t;

    pub fn cudnnGetConvolutionNdDescriptor(
        convDesc: cudnnConvolutionDescriptor_t,
        arrayLengthRequested: ::libc::c_int,
        arrayLength: *mut ::libc::c_int,
        padA: *mut ::libc::c_int,
        strideA: *mut ::libc::c_int,
        upscaleA: *mut ::libc::c_int,
        mode: *mut cudnnConvolutionMode_t
    ) -> cudnnStatus_t;

    pub fn cudnnSetConvolutionNdDescriptor_v3(
        convDesc: cudnnConvolutionDescriptor_t,
        arrayLength: ::libc::c_int,
        padA: *const ::libc::c_int,
        filterStrideA: *const ::libc::c_int,
        upscaleA: *const ::libc::c_int,
        mode: cudnnConvolutionMode_t,
        dataType: cudnnDataType_t
    ) -> cudnnStatus_t;

    pub fn cudnnGetConvolutionNdDescriptor_v3(
        convDesc: cudnnConvolutionDescriptor_t,
        arrayLengthRequested: ::libc::c_int,
        arrayLength: *mut ::libc::c_int,
        padA: *mut ::libc::c_int,
        strideA: *mut ::libc::c_int,
        upscaleA: *mut ::libc::c_int,
        mode: *mut cudnnConvolutionMode_t,
        dataType: *mut cudnnDataType_t
    ) -> cudnnStatus_t;

    pub fn cudnnGetConvolutionNdForwardOutputDim(
        convDesc: cudnnConvolutionDescriptor_t,
        inputTensorDesc: cudnnTensorDescriptor_t,
        filterDesc: cudnnFilterDescriptor_t,
        nbDims: ::libc::c_int,
        tensorOuputDimA: *mut ::libc::c_int
    ) -> cudnnStatus_t;

    pub fn cudnnDestroyConvolutionDescriptor(convDesc: cudnnConvolutionDescriptor_t) -> cudnnStatus_t;

    pub fn cudnnFindConvolutionForwardAlgorithm(
        handle: cudnnHandle_t,
        srcDesc: cudnnTensorDescriptor_t,
        filterDesc: cudnnFilterDescriptor_t,
        convDesc: cudnnConvolutionDescriptor_t,
        destDesc: cudnnTensorDescriptor_t,
        requestedAlgoCount: ::libc::c_int,
        returnedAlgoCount: *mut ::libc::c_int,
        perfResults: *mut cudnnConvolutionFwdAlgoPerf_t
    ) -> cudnnStatus_t;

    pub fn cudnnGetConvolutionForwardAlgorithm(
        handle: cudnnHandle_t,
        srcDesc: cudnnTensorDescriptor_t,
        filterDesc: cudnnFilterDescriptor_t,
        convDesc: cudnnConvolutionDescriptor_t,
        destDesc: cudnnTensorDescriptor_t,
        preference: cudnnConvolutionFwdPreference_t,
        memoryLimitInbytes: ::libc::size_t,
        algo: *mut cudnnConvolutionFwdAlgo_t
    ) -> cudnnStatus_t;

    pub fn cudnnGetConvolutionForwardWorkspaceSize(
        handle: cudnnHandle_t,
        srcDesc: cudnnTensorDescriptor_t,
        filterDesc: cudnnFilterDescriptor_t,
        convDesc: cudnnConvolutionDescriptor_t,
        destDesc: cudnnTensorDescriptor_t,
        algo: cudnnConvolutionFwdAlgo_t,
        sizeInBytes: *mut ::libc::size_t,
    ) -> cudnnStatus_t;

    pub fn cudnnConvolutionForward(
        handle: cudnnHandle_t,
        alpha: *const ::libc::c_void,
        srcDesc: cudnnTensorDescriptor_t,
        srcData: *const ::libc::c_void,
        filterDesc: cudnnFilterDescriptor_t,
        filterData: *const ::libc::c_void,
        convDesc: cudnnConvolutionDescriptor_t,
        algo: cudnnConvolutionFwdAlgo_t,
        workSpace: *mut ::libc::c_void,
        workSpaceSizeInBytes: ::libc::size_t,
        beta: *const ::libc::c_void,
        destDesc: cudnnTensorDescriptor_t,
        destData: *mut ::libc::c_void
    ) -> cudnnStatus_t;

    pub fn cudnnConvolutionBackwardBias(
        handle: cudnnHandle_t,
        alpha: *const ::libc::c_void,
        srcDesc: cudnnTensorDescriptor_t,
        srcData: *const ::libc::c_void,
        beta: *const ::libc::c_void,
        destDesc: cudnnTensorDescriptor_t,
        destData: *mut ::libc::c_void
    ) -> cudnnStatus_t;

    pub fn cudnnFindConvolutionBackwardFilterAlgorithm(
        handle: cudnnHandle_t,
        srcDesc: cudnnTensorDescriptor_t,
        diffDesc: cudnnTensorDescriptor_t,
        convDesc: cudnnConvolutionDescriptor_t,
        gradDesc: cudnnFilterDescriptor_t,
        requestedAlgoCount: ::libc::c_int,
        returnedAlgoCount: *mut ::libc::c_int,
        perfResults: *mut cudnnConvolutionBwdFilterAlgoPerf_t
    ) -> cudnnStatus_t;

    pub fn cudnnGetConvolutionBackwardFilterAlgorithm(
        handle: cudnnHandle_t,
        srcDesc: cudnnTensorDescriptor_t,
        diffDesc: cudnnTensorDescriptor_t,
        convDesc: cudnnConvolutionDescriptor_t,
        gradDesc: cudnnFilterDescriptor_t,
        preference: cudnnConvolutionBwdFilterPreference_t,
        memoryLimitInbytes: ::libc::size_t,
        algo: *mut cudnnConvolutionBwdFilterAlgo_t
    ) -> cudnnStatus_t;

    pub fn cudnnGetConvolutionBackwardFilterWorkspaceSize(
        handle: cudnnHandle_t,
        srcDesc: cudnnTensorDescriptor_t,
        diffDesc: cudnnTensorDescriptor_t,
        convDesc: cudnnConvolutionDescriptor_t,
        gradDesc: cudnnFilterDescriptor_t,
        algo: cudnnConvolutionBwdFilterAlgo_t,
        sizeInBytes: *mut ::libc::size_t,
    ) -> cudnnStatus_t;

    pub fn cudnnConvolutionBackwardFilter_v3(
        handle: cudnnHandle_t,
        alpha: *const ::libc::c_void,
        srcDesc: cudnnTensorDescriptor_t,
        srcData: *const ::libc::c_void,
        diffDesc: cudnnTensorDescriptor_t,
        diffData: *const ::libc::c_void,
        convDesc: cudnnConvolutionDescriptor_t,
        algo: cudnnConvolutionBwdFilterAlgo_t,
        workSpace: *mut ::libc::c_void,
        workSpaceSizeInBytes: ::libc::size_t,
        beta: *const ::libc::c_void,
        gradDesc: cudnnFilterDescriptor_t,
        gradData: *mut ::libc::c_void
    ) -> cudnnStatus_t;

    pub fn cudnnConvolutionBackwardFilter(
        handle: cudnnHandle_t,
        alpha: *const ::libc::c_void,
        srcDesc: cudnnTensorDescriptor_t,
        srcData: *const ::libc::c_void,
        diffDesc: cudnnTensorDescriptor_t,
        diffData: *const ::libc::c_void,
        convDesc: cudnnConvolutionDescriptor_t,
        beta: *const ::libc::c_void,
        gradDesc: cudnnFilterDescriptor_t,
        gradData: *mut ::libc::c_void
    ) -> cudnnStatus_t;

    pub fn cudnnFindConvolutionBackwardDataAlgorithm(
        handle: cudnnHandle_t,
        filterDesc: cudnnFilterDescriptor_t,
        diffDesc: cudnnTensorDescriptor_t,
        convDesc: cudnnConvolutionDescriptor_t,
        gradDesc: cudnnTensorDescriptor_t,
        requestedAlgoCount: ::libc::c_int,
        returnedAlgoCount: *mut ::libc::c_int,
        perfResults: *mut cudnnConvolutionBwdDataAlgoPerf_t
    ) -> cudnnStatus_t;

    pub fn cudnnGetConvolutionBackwardDataAlgorithm(
        handle: cudnnHandle_t,
        filterDesc: cudnnFilterDescriptor_t,
        diffDesc: cudnnTensorDescriptor_t,
        convDesc: cudnnConvolutionDescriptor_t,
        gradDesc: cudnnTensorDescriptor_t,
        preference: cudnnConvolutionBwdDataPreference_t,
        memoryLimitInbytes: ::libc::size_t,
        algo: *mut cudnnConvolutionBwdDataAlgo_t
    ) -> cudnnStatus_t;

    pub fn cudnnGetConvolutionBackwardDataWorkspaceSize(
        handle: cudnnHandle_t,
        filterDesc: cudnnFilterDescriptor_t,
        diffDesc: cudnnTensorDescriptor_t,
        convDesc: cudnnConvolutionDescriptor_t,
        gradDesc: cudnnTensorDescriptor_t,
        algo: cudnnConvolutionBwdDataAlgo_t,
        sizeInBytes: *mut ::libc::size_t,
    ) -> cudnnStatus_t;

    pub fn cudnnConvolutionBackwardData_v3(
        handle: cudnnHandle_t,
        alpha: *const ::libc::c_void,
        filterDesc: cudnnFilterDescriptor_t,
        filterData: *const ::libc::c_void,
        diffDesc: cudnnTensorDescriptor_t,
        diffData: *const ::libc::c_void,
        convDesc: cudnnConvolutionDescriptor_t,
        algo: cudnnConvolutionBwdDataAlgo_t,
        workSpace: *mut ::libc::c_void,
        workSpaceSizeInBytes: ::libc::size_t,
        beta: *const ::libc::c_void,
        gradDesc: cudnnTensorDescriptor_t,
        gradData: *mut ::libc::c_void
    ) -> cudnnStatus_t;

    pub fn cudnnConvolutionBackwardData(
        handle: cudnnHandle_t,
        alpha: *const ::libc::c_void,
        filterDesc: cudnnFilterDescriptor_t,
        filterData: *const ::libc::c_void,
        diffDesc: cudnnTensorDescriptor_t,
        diffData: *const ::libc::c_void,
        convDesc: cudnnConvolutionDescriptor_t,
        beta: *const ::libc::c_void,
        gradDesc: cudnnTensorDescriptor_t,
        gradData: *mut ::libc::c_void
    ) -> cudnnStatus_t;

    pub fn cudnnIm2Col(
        handle: cudnnHandle_t,
        srcDesc: cudnnTensorDescriptor_t,
        srcData: *const ::libc::c_void,
        filterDesc: cudnnFilterDescriptor_t,
        convDesc: cudnnConvolutionDescriptor_t,
        colBuffer: *mut ::libc::c_void
    ) -> cudnnStatus_t;

    pub fn cudnnSoftmaxForward(
        handle: cudnnHandle_t,
        algorithm: cudnnSoftmaxAlgorithm_t,
        mode: cudnnSoftmaxMode_t,
        alpha: *const ::libc::c_void,
        srcDesc: cudnnTensorDescriptor_t,
        srcData: *const ::libc::c_void,
        beta: *const ::libc::c_void,
        destDesc: cudnnTensorDescriptor_t,
        destData: *mut ::libc::c_void
    ) -> cudnnStatus_t;

    pub fn cudnnSoftmaxBackward(
        handle: cudnnHandle_t,
        algorithm: cudnnSoftmaxAlgorithm_t,
        mode: cudnnSoftmaxMode_t,
        alpha: *const ::libc::c_void,
        srcDesc: cudnnTensorDescriptor_t,
        srcData: *const ::libc::c_void,
        srcDiffDesc: cudnnTensorDescriptor_t,
        srcDiffData: *const ::libc::c_void,
        beta: *const ::libc::c_void,
        destDiffDesc: cudnnTensorDescriptor_t,
        destDiffData: *mut ::libc::c_void
    ) -> cudnnStatus_t;

    pub fn cudnnCreatePoolingDescriptor(poolingDesc: *mut cudnnPoolingDescriptor_t) -> cudnnStatus_t;

    pub fn cudnnSetPooling2dDescriptor(
        poolingDesc: cudnnPoolingDescriptor_t,
        mode: cudnnPoolingMode_t,
        windowHeight: ::libc::c_int,
        windowWidth: ::libc::c_int,
        verticalPadding: ::libc::c_int,
        horizontalPadding: ::libc::c_int,
        verticalStride: ::libc::c_int,
        horizontalStride: ::libc::c_int
    ) -> cudnnStatus_t;

    pub fn cudnnGetPooling2dDescriptor(
        poolingDesc: cudnnPoolingDescriptor_t,
        mode: *mut cudnnPoolingMode_t,
        windowHeight: *mut ::libc::c_int,
        windowWidth: *mut ::libc::c_int,
        verticalPadding: *mut ::libc::c_int,
        horizontalPadding: *mut ::libc::c_int,
        verticalStride: *mut ::libc::c_int,
        horizontalStride: *mut ::libc::c_int
    ) -> cudnnStatus_t;

    pub fn cudnnSetPoolingNdDescriptor(
        poolingDesc: cudnnPoolingDescriptor_t,
        mode: cudnnPoolingMode_t,
        nbDims: ::libc::c_int,
        windowDimA: *const ::libc::c_int,
        paddingA: *const ::libc::c_int,
        strideA: *const ::libc::c_int
    ) -> cudnnStatus_t;

    pub fn cudnnGetPoolingNdDescriptor(
        poolingDesc: cudnnPoolingDescriptor_t,
        nbDimsRequested: ::libc::c_int,
        mode: *mut cudnnPoolingMode_t,
        nbDims: *mut ::libc::c_int,
        windowDimA: *mut ::libc::c_int,
        paddingA: *mut ::libc::c_int,
        strideA: *mut ::libc::c_int
    ) -> cudnnStatus_t;

    pub fn cudnnGetPoolingNdForwardOutputDim(
        poolingDesc: cudnnPoolingDescriptor_t,
        inputTensorDesc: cudnnTensorDescriptor_t,
        nbDims: ::libc::c_int,
        outputTensorDimA: *mut ::libc::c_int
    ) -> cudnnStatus_t;

    pub fn cudnnGetPooling2dForwardOutputDim(
        poolingDesc: cudnnPoolingDescriptor_t,
        inputTensorDesc: cudnnTensorDescriptor_t,
        outN: *mut ::libc::c_int,
        outC: *mut ::libc::c_int,
        outH: *mut ::libc::c_int,
        outW: *mut ::libc::c_int
    ) -> cudnnStatus_t;

    pub fn cudnnDestroyPoolingDescriptor(poolingDesc: cudnnPoolingDescriptor_t) -> cudnnStatus_t;

    pub fn cudnnPoolingForward(
        handle: cudnnHandle_t,
        poolingDesc: cudnnPoolingDescriptor_t,
        alpha: *const ::libc::c_void,
        srcDesc: cudnnTensorDescriptor_t,
        srcData: *const ::libc::c_void,
        beta: *const ::libc::c_void,
        destDesc: cudnnTensorDescriptor_t,
        destData: *mut ::libc::c_void
    ) -> cudnnStatus_t;

    pub fn cudnnPoolingBackward(
        handle: cudnnHandle_t,
        poolingDesc: cudnnPoolingDescriptor_t,
        alpha: *const ::libc::c_void,
        srcDesc: cudnnTensorDescriptor_t,
        srcData: *const ::libc::c_void,
        srcDiffDesc: cudnnTensorDescriptor_t,
        srcDiffData: *const ::libc::c_void,
        destDesc: cudnnTensorDescriptor_t,
        destData: *const ::libc::c_void,
        beta: *const ::libc::c_void,
        destDiffDesc: cudnnTensorDescriptor_t,
        destDiffData: *mut ::libc::c_void
    ) -> cudnnStatus_t;

    pub fn cudnnActivationForward(
        handle: cudnnHandle_t,
        mode: cudnnActivationMode_t,
        alpha: *const ::libc::c_void,
        srcDesc: cudnnTensorDescriptor_t,
        srcData: *const ::libc::c_void,
        beta: *const ::libc::c_void,
        destDesc: cudnnTensorDescriptor_t,
        destData: *mut ::libc::c_void
    ) -> cudnnStatus_t;

    pub fn cudnnActivationBackward(
        handle: cudnnHandle_t,
        mode: cudnnActivationMode_t,
        alpha: *const ::libc::c_void,
        srcDesc: cudnnTensorDescriptor_t,
        srcData: *const ::libc::c_void,
        srcDiffDesc: cudnnTensorDescriptor_t,
        srcDiffData: *const ::libc::c_void,
        destDesc: cudnnTensorDescriptor_t,
        destData: *const ::libc::c_void,
        beta: *const ::libc::c_void,
        destDiffDesc: cudnnTensorDescriptor_t,
        destDiffData: *mut ::libc::c_void
    ) -> cudnnStatus_t;

    pub fn cudnnCreateLRNDescriptor(normDesc: *mut cudnnLRNDescriptor_t) -> cudnnStatus_t;

    pub fn cudnnSetLRNDescriptor(
        normDesc: cudnnLRNDescriptor_t,
        lrnN: ::libc::c_uint,
        lrnAlpha: ::libc::c_double,
        lrnBeta: ::libc::c_double,
        lrnK: ::libc::c_double
    ) -> cudnnStatus_t;

    pub fn cudnnGetLRNDescriptor(
        normDesc: cudnnLRNDescriptor_t,
        lrnN: *mut ::libc::c_uint,
        lrnAlpha: *mut ::libc::c_double,
        lrnBeta: *mut ::libc::c_double,
        lrnK: *mut ::libc::c_double
    ) -> cudnnStatus_t;

    pub fn cudnnDestroyLRNDescriptor(lrnDesc: cudnnLRNDescriptor_t) -> cudnnStatus_t;

    pub fn cudnnLRNCrossChannelForward(
        handle: cudnnHandle_t,
        normDesc: cudnnLRNDescriptor_t,
        lrnMode: cudnnLRNMode_t,
        alpha: *const ::libc::c_void,
        srcDesc: cudnnTensorDescriptor_t,
        srcData: *const ::libc::c_void,
        beta: *const ::libc::c_void,
        destDesc: cudnnTensorDescriptor_t,
        destData: *mut ::libc::c_void
    ) -> cudnnStatus_t;

    pub fn cudnnLRNCrossChannelBackward(
        handle: cudnnHandle_t,
        normDesc: cudnnLRNDescriptor_t,
        lrnMode: cudnnLRNMode_t,
        alpha: *const ::libc::c_void,
        srcDesc: cudnnTensorDescriptor_t,
        srcData: *const ::libc::c_void,
        srcDiffDesc: cudnnTensorDescriptor_t,
        srcDiffData: *const ::libc::c_void,
        destDesc: cudnnTensorDescriptor_t,
        destData: *const ::libc::c_void,
        beta: *const ::libc::c_void,
        destDiffDesc: cudnnTensorDescriptor_t,
        destDiffData: *mut ::libc::c_void
    ) -> cudnnStatus_t;

    pub fn cudnnDivisiveNormalizationForward(
        handle: cudnnHandle_t,
        normDesc: cudnnLRNDescriptor_t,
        mode: cudnnDivNormMode_t,
        alpha: *const ::libc::c_void,
        srcDesc: cudnnTensorDescriptor_t,
        srcData: *const ::libc::c_void,
        srcMeansData:
        *const ::libc::c_void,
        tempData: *mut ::libc::c_void,
        tempData2: *mut ::libc::c_void,
        beta: *const ::libc::c_void,
        destDesc: cudnnTensorDescriptor_t,
        destData: *mut ::libc::c_void
    ) -> cudnnStatus_t;

    pub fn cudnnDivisiveNormalizationBackward(
        handle: cudnnHandle_t,
        normDesc: cudnnLRNDescriptor_t,
        mode: cudnnDivNormMode_t,
        alpha: *const ::libc::c_void,
        srcDesc: cudnnTensorDescriptor_t,
        srcData: *const ::libc::c_void,
        srcMeansData: *const ::libc::c_void,
        srcDiffData: *const ::libc::c_void,
        tempData: *mut ::libc::c_void,
        tempData2: *mut ::libc::c_void,
        betaData: *const ::libc::c_void,
        destDataDesc: cudnnTensorDescriptor_t,
        destDataDiff: *mut ::libc::c_void,
        destMeansDiff: *mut ::libc::c_void
    ) -> cudnnStatus_t;

    //pub fn cudaMalloc(devPtr: *mut cudaMemoryPtr, size: size_t) -> cudaError_t;

    // pub fn cudaFree(devPtr: cudaMemoryPtr) -> cudaError_t;

    // pub fn cudaMemcpy(
    //     dst: *mut ::libc::c_void,
    //     src: *const ::libc::c_void,
    //     count: size_t,
    //     kind: Enum_cudaMemcpyKind
    // ) -> cudaError_t;
}


text:
using Chromamboo.Providers.Presentation.Contracts;
using Chromamboo.Providers.Presentation.Factories.Contracts;
using Chromamboo.Providers.Presentation.RazerChroma;

using Newtonsoft.Json.Linq;

namespace Chromamboo.Providers.Presentation.Factories
{
    public class RazerChromaGitNotificationPresentationProviderFactory : PresentationProviderFactoryBase<RazerChromaGitNotificationPresentationProvider>
    {
        public override string Name => "razer-chroma";
        public override IPresentationProvider Create(JToken settings)
        {
            // TODO: Keys to light up in configuration
            return new RazerChromaGitNotificationPresentationProvider();
        }
    }
}


text:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.administrator.chatandroid">
    <uses-permission android:name="android.permission.INTERNET" />
    <application
        android:allowBackup="true"
        android:icon="@drawable/iconotc"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <meta-data android:name="DB" android:value="Chat.db" />
        <meta-data android:name="DB_VERSION" android:value="1" />
        <activity
            android:name=".Activities.MainActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".Activities.Contactos"
            android:label="@string/title_activity_contactos"
            android:theme="@style/AppTheme.NoActionBar" />
        <activity
            android:name=".Activities.Chat"
            android:label="@string/title_activity_chat"
            android:theme="@style/AppTheme.NoActionBar"></activity>
    </application>

</manifest>


text:
package fixio.handlers;

import fixio.fixprotocol.FixMessage;
import fixio.fixprotocol.FixMessageBuilder;
import fixio.fixprotocol.FixMessageBuilderImpl;
import fixio.fixprotocol.FixMessageImpl;
import fixio.validator.FixMessageValidator;
import io.netty.channel.ChannelHandlerContext;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InOrder;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;

import java.util.ArrayList;
import java.util.Arrays;

import static org.mockito.Matchers.same;
import static org.mockito.Mockito.*;

@RunWith(MockitoJUnitRunner.class)
public class CompositeFixApplicationAdapterTest {

    private CompositeFixApplicationAdapter adapter;
    @Mock
    private FixMessageValidator messageValidator1;
    @Mock
    private FixMessageValidator messageValidator2;
    @Mock
    private FixMessageHandler messageHandler1;
    @Mock
    private FixMessageHandler messageHandler2;
    @Mock
    private FixMessageHandler messageHandler3;
    @Mock
    private ChannelHandlerContext ctx;
    private ArrayList<Object> out;

    @Before
    public void setUp() throws Exception {
        adapter = new CompositeFixApplicationAdapter(
                Arrays.asList(messageValidator1, messageValidator2),
                Arrays.asList(messageHandler1, messageHandler2, messageHandler3));
        out = new ArrayList<Object>();
    }

    @Test
    public void testOnMessage() throws Exception {
        final FixMessage message = new FixMessageImpl();

        when(messageHandler1.handle(same(ctx), same(message))).thenReturn(true);
        when(messageHandler2.handle(same(ctx), same(message))).thenReturn(false);

        adapter.onMessage(ctx, message, out);

        InOrder inOrder = inOrder(
                messageValidator1, messageValidator2,
                messageHandler1, messageHandler2, messageHandler3,
                ctx);

        inOrder.verify(messageValidator1).validate(same(ctx), same(message));
        inOrder.verify(messageValidator2).validate(same(ctx), same(message));

        inOrder.verify(messageHandler1).handle(same(ctx), same(message));
        inOrder.verify(messageHandler2).handle(same(ctx), same(message));
        verifyZeroInteractions(messageHandler3);
    }

    @Test
    public void testBeforeSendMessage() throws Exception {
        final FixMessageBuilder message = new FixMessageBuilderImpl();

        adapter.beforeSendMessage(ctx, message);

        InOrder inOrder = inOrder(
                messageValidator1, messageValidator2,
                messageHandler1, messageHandler2, messageHandler3,
                ctx);

        inOrder.verify(messageHandler1).beforeSendMessage(same(ctx), same(message));
        inOrder.verify(messageHandler2).beforeSendMessage(same(ctx), same(message));
        inOrder.verify(messageHandler3).beforeSendMessage(same(ctx), same(message));
    }
}