int ff_vp8_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,

                        AVPacket *avpkt)

{

    VP8Context *s = avctx->priv_data;

    int ret, i, referenced, num_jobs;

    enum AVDiscard skip_thresh;

    VP8Frame *av_uninit(curframe), *prev_frame;

    if ((ret = decode_frame_header(s, avpkt->data, avpkt->size)) < 0)

        goto err;

    prev_frame = s->framep[VP56_FRAME_CURRENT];

    referenced = s->update_last || s->update_golden == VP56_FRAME_CURRENT ||

                 s->update_altref == VP56_FRAME_CURRENT;

    skip_thresh = !referenced ? AVDISCARD_NONREF

                              : !s->keyframe ? AVDISCARD_NONKEY

                                             : AVDISCARD_ALL;

    if (avctx->skip_frame >= skip_thresh) {

        s->invisible = 1;

        memcpy(&s->next_framep[0], &s->framep[0], sizeof(s->framep[0]) * 4);

        goto skip_decode;

    }

    s->deblock_filter = s->filter.level && avctx->skip_loop_filter < skip_thresh;

    // release no longer referenced frames

    for (i = 0; i < 5; i++)

        if (s->frames[i].tf.f->data[0] &&

            &s->frames[i] != prev_frame &&

            &s->frames[i] != s->framep[VP56_FRAME_PREVIOUS] &&

            &s->frames[i] != s->framep[VP56_FRAME_GOLDEN]   &&

            &s->frames[i] != s->framep[VP56_FRAME_GOLDEN2])

            vp8_release_frame(s, &s->frames[i]);

    // find a free buffer

    for (i = 0; i < 5; i++)

        if (&s->frames[i] != prev_frame &&

            &s->frames[i] != s->framep[VP56_FRAME_PREVIOUS] &&

            &s->frames[i] != s->framep[VP56_FRAME_GOLDEN]   &&

            &s->frames[i] != s->framep[VP56_FRAME_GOLDEN2]) {

            curframe = s->framep[VP56_FRAME_CURRENT] = &s->frames[i];

            break;

        }

    if (i == 5) {

        av_log(avctx, AV_LOG_FATAL, "Ran out of free frames!\n");

        abort();

    }

    if (curframe->tf.f->data[0])

        vp8_release_frame(s, curframe);

    /* Given that arithmetic probabilities are updated every frame, it's quite

     * likely that the values we have on a random interframe are complete

     * junk if we didn't start decode on a keyframe. So just don't display

     * anything rather than junk. */

    if (!s->keyframe && (!s->framep[VP56_FRAME_PREVIOUS] ||

                         !s->framep[VP56_FRAME_GOLDEN]   ||

                         !s->framep[VP56_FRAME_GOLDEN2])) {

        av_log(avctx, AV_LOG_WARNING,

               "Discarding interframe without a prior keyframe!\n");

        ret = AVERROR_INVALIDDATA;

        goto err;

    }

    curframe->tf.f->key_frame = s->keyframe;

    curframe->tf.f->pict_type = s->keyframe ? AV_PICTURE_TYPE_I

                                            : AV_PICTURE_TYPE_P;

    if ((ret = vp8_alloc_frame(s, curframe, referenced))) {

        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed!\n");

        goto err;

    }

    // check if golden and altref are swapped

    if (s->update_altref != VP56_FRAME_NONE)

        s->next_framep[VP56_FRAME_GOLDEN2] = s->framep[s->update_altref];

    else

        s->next_framep[VP56_FRAME_GOLDEN2] = s->framep[VP56_FRAME_GOLDEN2];

    if (s->update_golden != VP56_FRAME_NONE)

        s->next_framep[VP56_FRAME_GOLDEN] = s->framep[s->update_golden];

    else

        s->next_framep[VP56_FRAME_GOLDEN] = s->framep[VP56_FRAME_GOLDEN];

    if (s->update_last)

        s->next_framep[VP56_FRAME_PREVIOUS] = curframe;

    else

        s->next_framep[VP56_FRAME_PREVIOUS] = s->framep[VP56_FRAME_PREVIOUS];

    s->next_framep[VP56_FRAME_CURRENT] = curframe;

    ff_thread_finish_setup(avctx);

    s->linesize   = curframe->tf.f->linesize[0];

    s->uvlinesize = curframe->tf.f->linesize[1];

    memset(s->top_nnz, 0, s->mb_width * sizeof(*s->top_nnz));

    /* Zero macroblock structures for top/top-left prediction

     * from outside the frame. */

    if (!s->mb_layout)

        memset(s->macroblocks + s->mb_height * 2 - 1, 0,

               (s->mb_width + 1) * sizeof(*s->macroblocks));

    if (!s->mb_layout && s->keyframe)

        memset(s->intra4x4_pred_mode_top, DC_PRED, s->mb_width * 4);

    memset(s->ref_count, 0, sizeof(s->ref_count));

    if (s->mb_layout == 1) {

        // Make sure the previous frame has read its segmentation map,

        // if we re-use the same map.

        if (prev_frame && s->segmentation.enabled &&

            !s->segmentation.update_map)

            ff_thread_await_progress(&prev_frame->tf, 1, 0);

        vp8_decode_mv_mb_modes(avctx, curframe, prev_frame);

    }

    if (avctx->active_thread_type == FF_THREAD_FRAME)

        num_jobs = 1;

    else

        num_jobs = FFMIN(s->num_coeff_partitions, avctx->thread_count);

    s->num_jobs   = num_jobs;

    s->curframe   = curframe;

    s->prev_frame = prev_frame;

    s->mv_min.y   = -MARGIN;

    s->mv_max.y   = ((s->mb_height - 1) << 6) + MARGIN;

    for (i = 0; i < MAX_THREADS; i++) {

        s->thread_data[i].thread_mb_pos = 0;

        s->thread_data[i].wait_mb_pos   = INT_MAX;

    }

    avctx->execute2(avctx, vp8_decode_mb_row_sliced,

                    s->thread_data, NULL, num_jobs);

    ff_thread_report_progress(&curframe->tf, INT_MAX, 0);

    memcpy(&s->framep[0], &s->next_framep[0], sizeof(s->framep[0]) * 4);

skip_decode:

    // if future frames don't use the updated probabilities,

    // reset them to the values we saved

    if (!s->update_probabilities)

        s->prob[0] = s->prob[1];

    if (!s->invisible) {

        if ((ret = av_frame_ref(data, curframe->tf.f)) < 0)

            return ret;

        *got_frame = 1;

    }

    return avpkt->size;

err:

    memcpy(&s->next_framep[0], &s->framep[0], sizeof(s->framep[0]) * 4);

    return ret;

}


static void getKeySizes(redisReply *keys, int *types,
                        unsigned long long *sizes)
{
    redisReply *reply;
    char *sizecmds[] = {"STRLEN","LLEN","SCARD","HLEN","ZCARD"};
    unsigned int i;

    /* Pipeline size commands */
    for(i=0;i<keys->elements;i++) {
        /* Skip keys that were deleted */
        if(types[i]==TYPE_NONE)
            continue;

        redisAppendCommand(context, "%s %s", sizecmds[types[i]],
            keys->element[i]->str);
    }

    /* Retreive sizes */
    for(i=0;i<keys->elements;i++) {
        /* Skip keys that dissapeared between SCAN and TYPE */
        if(types[i] == TYPE_NONE) {
            sizes[i] = 0;
            continue;
        }

        /* Retreive size */
        if(redisGetReply(context, (void**)&reply)!=REDIS_OK) {
            fprintf(stderr, "Error getting size for key '%s' (%d: %s)\n",
                keys->element[i]->str, context->err, context->errstr);
            exit(1);
        } else if(reply->type != REDIS_REPLY_INTEGER) {
            /* Theoretically the key could have been removed and
             * added as a different type between TYPE and SIZE */
            fprintf(stderr,
                "Warning:  %s on '%s' failed (may have changed type)\n",
                 sizecmds[types[i]], keys->element[i]->str);
            sizes[i] = 0;
        } else {
            sizes[i] = reply->integer;
        }

        freeReplyObject(reply);
    }
}


static void cstmlist(JF, js_Ast *list)
{
	while (list) {
		cstm(J, F, list->a);
		list = list->b;
	}
}


 png_get_asm_flags (png_structp png_ptr)
 {
     /* Obsolete, to be removed from libpng-1.4.0 */
    PNG_UNUSED(png_ptr)
    return 0L;
 }


static void hns_ppe_set_port_mode(struct hns_ppe_cb *ppe_cb,
				  enum ppe_port_mode mode)
{
	dsaf_write_dev(ppe_cb, PPE_CFG_XGE_MODE_REG, mode);
}


void SaveTime(DictionaryValue* dictionary, const char* key, const Time& time) {
  if (!dictionary)
    return;
  std::string string_value = base::Int64ToString(time.ToInternalValue());
  dictionary->SetString(key, string_value);
}


bool RenderWidgetHostImpl::IsFullscreen() const {
  return false;
}


map_engine_get_framerate(void)
{
	return s_frame_rate;
}


static int pn_recvmsg(struct kiocb *iocb, struct sock *sk,
			struct msghdr *msg, size_t len, int noblock,
			int flags, int *addr_len)
{
	struct sk_buff *skb = NULL;
	struct sockaddr_pn sa;
	int rval = -EOPNOTSUPP;
	int copylen;

	if (flags & ~(MSG_PEEK|MSG_TRUNC|MSG_DONTWAIT|MSG_NOSIGNAL|
			MSG_CMSG_COMPAT))
		goto out_nofree;

	skb = skb_recv_datagram(sk, flags, noblock, &rval);
	if (skb == NULL)
		goto out_nofree;

	pn_skb_get_src_sockaddr(skb, &sa);

	copylen = skb->len;
	if (len < copylen) {
		msg->msg_flags |= MSG_TRUNC;
		copylen = len;
	}

	rval = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copylen);
	if (rval) {
		rval = -EFAULT;
		goto out;
	}

	rval = (flags & MSG_TRUNC) ? skb->len : copylen;

	if (msg->msg_name != NULL) {
		memcpy(msg->msg_name, &sa, sizeof(sa));
		*addr_len = sizeof(sa);
	}

out:
	skb_free_datagram(sk, skb);

out_nofree:
	return rval;
}


static void tg3_frob_aux_power_5717(struct tg3 *tp, bool wol_enable)
{
	u32 msg = 0;

	/* Serialize power state transitions */
	if (tg3_ape_lock(tp, TG3_APE_LOCK_GPIO))
		return;

	if (tg3_flag(tp, ENABLE_ASF) || tg3_flag(tp, ENABLE_APE) || wol_enable)
		msg = TG3_GPIO_MSG_NEED_VAUX;

	msg = tg3_set_function_status(tp, msg);

	if (msg & TG3_GPIO_MSG_ALL_DRVR_PRES_MASK)
		goto done;

	if (msg & TG3_GPIO_MSG_ALL_NEED_VAUX_MASK)
		tg3_pwrsrc_switch_to_vaux(tp);
	else
		tg3_pwrsrc_die_with_vmain(tp);

done:
	tg3_ape_unlock(tp, TG3_APE_LOCK_GPIO);
}


static void vvalue_strbuf_append_null ( wmem_strbuf_t * strbuf _U_ , void * ptr _U_ ) {
 }


int dbd_bind_ph(SV *sth, imp_sth_t *imp_sth, SV *param, SV *value,
		 IV sql_type, SV *attribs, int is_inout, IV maxlen) {
  dTHX;
  int rc;
  int param_num= SvIV(param);
  int idx= param_num - 1;
  char err_msg[64];
  D_imp_xxh(sth);

#if MYSQL_VERSION_ID >= SERVER_PREPARE_VERSION
  STRLEN slen;
  char *buffer= NULL;
  int buffer_is_null= 0;
  int buffer_length= slen;
  unsigned int buffer_type= 0;
#endif

  D_imp_dbh_from_sth;
  ASYNC_CHECK_RETURN(sth, FALSE);

  if (DBIc_TRACE_LEVEL(imp_xxh) >= 2)
    PerlIO_printf(DBIc_LOGPIO(imp_xxh),
                  "   Called: dbd_bind_ph\n");

  attribs= attribs;
  maxlen= maxlen;

  if (param_num <= 0  ||  param_num > DBIc_NUM_PARAMS(imp_sth))
  {
    do_error(sth, JW_ERR_ILLEGAL_PARAM_NUM, "Illegal parameter number", NULL);
    return FALSE;
  }

  /*
     This fixes the bug whereby no warning was issued upone binding a
     defined non-numeric as numeric
   */
  if (SvOK(value) &&
      (sql_type == SQL_NUMERIC  ||
       sql_type == SQL_DECIMAL  ||
       sql_type == SQL_INTEGER  ||
       sql_type == SQL_SMALLINT ||
       sql_type == SQL_FLOAT    ||
       sql_type == SQL_REAL     ||
       sql_type == SQL_DOUBLE) )
  {
    if (! looks_like_number(value))
    {
      sprintf(err_msg,
              "Binding non-numeric field %d, value %s as a numeric!",
              param_num, neatsvpv(value,0));
      do_error(sth, JW_ERR_ILLEGAL_PARAM_NUM, err_msg, NULL);
    }
  }

  if (is_inout)
  {
    do_error(sth, JW_ERR_NOT_IMPLEMENTED, "Output parameters not implemented", NULL);
    return FALSE;
  }

  rc = bind_param(&imp_sth->params[idx], value, sql_type);

#if MYSQL_VERSION_ID >= SERVER_PREPARE_VERSION
  if (imp_sth->use_server_side_prepare)
  {
      switch(sql_type) {
      case SQL_NUMERIC:
      case SQL_INTEGER:
      case SQL_SMALLINT:
      case SQL_BIGINT:
      case SQL_TINYINT:
          buffer_type= MYSQL_TYPE_LONG;
          break;
      case SQL_DOUBLE:
      case SQL_DECIMAL:
      case SQL_FLOAT:
      case SQL_REAL:
          buffer_type= MYSQL_TYPE_DOUBLE;
          break;
      case SQL_CHAR:
      case SQL_VARCHAR:
      case SQL_DATE:
      case SQL_TIME:
      case SQL_TIMESTAMP:
      case SQL_LONGVARCHAR:
      case SQL_BINARY:
      case SQL_VARBINARY:
      case SQL_LONGVARBINARY:
          buffer_type= MYSQL_TYPE_BLOB;
          break;
      default:
          buffer_type= MYSQL_TYPE_STRING;
    }
    buffer_is_null = !(SvOK(imp_sth->params[idx].value) && imp_sth->params[idx].value);
    if (! buffer_is_null) {
      switch(buffer_type) {
        case MYSQL_TYPE_LONG:
          /* INT */
          if (!SvIOK(imp_sth->params[idx].value) && DBIc_TRACE_LEVEL(imp_xxh) >= 2)
            PerlIO_printf(DBIc_LOGPIO(imp_xxh), "\t\tTRY TO BIND AN INT NUMBER\n");
          buffer_length = sizeof imp_sth->fbind[idx].numeric_val.lval;
          imp_sth->fbind[idx].numeric_val.lval= SvIV(imp_sth->params[idx].value);
          buffer=(void*)&(imp_sth->fbind[idx].numeric_val.lval);
          if (DBIc_TRACE_LEVEL(imp_xxh) >= 2)
            PerlIO_printf(DBIc_LOGPIO(imp_xxh),
                          "   SCALAR type %d ->%ld<- IS A INT NUMBER\n",
                          (int) sql_type, (long) (*buffer));
          break;

        case MYSQL_TYPE_DOUBLE:
          if (!SvNOK(imp_sth->params[idx].value) && DBIc_TRACE_LEVEL(imp_xxh) >= 2)
            PerlIO_printf(DBIc_LOGPIO(imp_xxh), "\t\tTRY TO BIND A FLOAT NUMBER\n");
          buffer_length = sizeof imp_sth->fbind[idx].numeric_val.dval;
          imp_sth->fbind[idx].numeric_val.dval= SvNV(imp_sth->params[idx].value);
          buffer=(char*)&(imp_sth->fbind[idx].numeric_val.dval);
          if (DBIc_TRACE_LEVEL(imp_xxh) >= 2)
            PerlIO_printf(DBIc_LOGPIO(imp_xxh),
                          "   SCALAR type %d ->%f<- IS A FLOAT NUMBER\n",
                          (int) sql_type, (double)(*buffer));
          break;

        case MYSQL_TYPE_BLOB:
          if (DBIc_TRACE_LEVEL(imp_xxh) >= 2)
            PerlIO_printf(DBIc_LOGPIO(imp_xxh),
                          "   SCALAR type BLOB\n");
          break;

        case MYSQL_TYPE_STRING:
          if (DBIc_TRACE_LEVEL(imp_xxh) >= 2)
            PerlIO_printf(DBIc_LOGPIO(imp_xxh),
                          "   SCALAR type STRING %d, buffertype=%d\n", (int) sql_type, buffer_type);
          break;

        default:
          croak("Bug in DBD::Mysql file dbdimp.c#dbd_bind_ph: do not know how to handle unknown buffer type.");
      }

      if (buffer_type == MYSQL_TYPE_STRING || buffer_type == MYSQL_TYPE_BLOB)
      {
        buffer= SvPV(imp_sth->params[idx].value, slen);
        buffer_length= slen;
        if (DBIc_TRACE_LEVEL(imp_xxh) >= 2)
          PerlIO_printf(DBIc_LOGPIO(imp_xxh),
                        " SCALAR type %d ->length %d<- IS A STRING or BLOB\n",
                        (int) sql_type, buffer_length);
      }
    }
    else
    {
      /*case: buffer_is_null != 0*/
      buffer= NULL;
      if (DBIc_TRACE_LEVEL(imp_xxh) >= 2)
        PerlIO_printf(DBIc_LOGPIO(imp_xxh),
                      "   SCALAR NULL VALUE: buffer type is: %d\n", buffer_type);
    }

    /* Type of column was changed. Force to rebind */
    if (imp_sth->bind[idx].buffer_type != buffer_type) {
      /* Note: this looks like being another bug:
       * if type of parameter N changes, then a bind is triggered
       * with an only partially filled bind structure ??
       */
      if (DBIc_TRACE_LEVEL(imp_xxh) >= 2)
          PerlIO_printf(DBIc_LOGPIO(imp_xxh),
                        "   FORCE REBIND: buffer type changed from %d to %d, sql-type=%d\n",
                        (int) imp_sth->bind[idx].buffer_type, buffer_type, (int) sql_type);
      imp_sth->has_been_bound = 0;
    }

    /* prepare has not been called */
    if (imp_sth->has_been_bound == 0)
    {
      imp_sth->bind[idx].buffer_type= buffer_type;
      imp_sth->bind[idx].buffer= buffer;
      imp_sth->bind[idx].buffer_length= buffer_length;
    }
    else /* prepare has been called */
    {
      imp_sth->stmt->params[idx].buffer= buffer;
      imp_sth->stmt->params[idx].buffer_length= buffer_length;
    }
    imp_sth->fbind[idx].length= buffer_length;
    imp_sth->fbind[idx].is_null= buffer_is_null;
  }
#endif
  return rc;
}


void ide_flush_cache(IDEState *s)
{
    if (s->blk == NULL) {
        ide_flush_cb(s, 0);
        return;
    }

    s->status |= BUSY_STAT;
    block_acct_start(blk_get_stats(s->blk), &s->acct, 0, BLOCK_ACCT_FLUSH);
    s->pio_aiocb = blk_aio_flush(s->blk, ide_flush_cb, s);
}


void *g_malloc0_n(size_t nmemb, size_t size)

{

    size_t sz;

    void *ptr;

    __coverity_negative_sink__(nmemb);

    __coverity_negative_sink__(size);

    sz = nmemb * size;

    ptr = __coverity_alloc__(size);

    __coverity_writeall0__(ptr);

    __coverity_mark_as_afm_allocated__(ptr, AFM_free);

    return ptr;

}


  bool DecodeNextName(HpackInputStream* in, StringPiece* out) {
    return decoder_->DecodeNextName(in, out);
  }


struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr)
{
	struct phy_device *phydev;
	int err;

	phydev = get_phy_device(bus, addr, false);
	if (IS_ERR(phydev))
		return phydev;

	/*
	 * For DT, see if the auto-probed phy has a correspoding child
	 * in the bus node, and set the of_node pointer in this case.
	 */
	of_mdiobus_link_mdiodev(bus, &phydev->mdio);

	err = phy_device_register(phydev);
	if (err) {
		phy_device_free(phydev);
		return ERR_PTR(-ENODEV);
	}

	return phydev;
}


static void kvm_release_vm_pages(struct kvm *kvm)
{
	struct kvm_memslots *slots;
	struct kvm_memory_slot *memslot;
	int j;
	unsigned long base_gfn;

	slots = kvm_memslots(kvm);
	kvm_for_each_memslot(memslot, slots) {
		base_gfn = memslot->base_gfn;
		for (j = 0; j < memslot->npages; j++) {
			if (memslot->rmap[j])
				put_page((struct page *)memslot->rmap[j]);
		}
	}
}


print_browse(netdissect_options *ndo,
             const u_char *param, int paramlen, const u_char *data, int datalen)
{
    const u_char *maxbuf = data + datalen;
    int command;

    ND_TCHECK(data[0]);
    command = data[0];

    smb_fdata(ndo, param, "BROWSE PACKET\n|Param ", param+paramlen, unicodestr);

    switch (command) {
    case 0xF:
	data = smb_fdata(ndo, data,
	    "BROWSE PACKET:\nType=[B] (LocalMasterAnnouncement)\nUpdateCount=[w]\nRes1=[B]\nAnnounceInterval=[d]\nName=[n2]\nMajorVersion=[B]\nMinorVersion=[B]\nServerType=[W]\nElectionVersion=[w]\nBrowserConstant=[w]\n",
	    maxbuf, unicodestr);
	break;

    case 0x1:
	data = smb_fdata(ndo, data,
	    "BROWSE PACKET:\nType=[B] (HostAnnouncement)\nUpdateCount=[w]\nRes1=[B]\nAnnounceInterval=[d]\nName=[n2]\nMajorVersion=[B]\nMinorVersion=[B]\nServerType=[W]\nElectionVersion=[w]\nBrowserConstant=[w]\n",
	    maxbuf, unicodestr);
	break;

    case 0x2:
	data = smb_fdata(ndo, data,
	    "BROWSE PACKET:\nType=[B] (AnnouncementRequest)\nFlags=[B]\nReplySystemName=[S]\n",
	    maxbuf, unicodestr);
	break;

    case 0xc:
	data = smb_fdata(ndo, data,
	    "BROWSE PACKET:\nType=[B] (WorkgroupAnnouncement)\nUpdateCount=[w]\nRes1=[B]\nAnnounceInterval=[d]\nName=[n2]\nMajorVersion=[B]\nMinorVersion=[B]\nServerType=[W]\nCommentPointer=[W]\nServerName=[S]\n",
	    maxbuf, unicodestr);
	break;

    case 0x8:
	data = smb_fdata(ndo, data,
	    "BROWSE PACKET:\nType=[B] (ElectionFrame)\nElectionVersion=[B]\nOSSummary=[W]\nUptime=[(W, W)]\nServerName=[S]\n",
	    maxbuf, unicodestr);
	break;

    case 0xb:
	data = smb_fdata(ndo, data,
	    "BROWSE PACKET:\nType=[B] (BecomeBackupBrowser)\nName=[S]\n",
	    maxbuf, unicodestr);
	break;

    case 0x9:
	data = smb_fdata(ndo, data,
	    "BROWSE PACKET:\nType=[B] (GetBackupList)\nListCount?=[B]\nToken=[W]\n",
	    maxbuf, unicodestr);
	break;

    case 0xa:
	data = smb_fdata(ndo, data,
	    "BROWSE PACKET:\nType=[B] (BackupListResponse)\nServerCount?=[B]\nToken=[W]\n*Name=[S]\n",
	    maxbuf, unicodestr);
	break;

    case 0xd:
	data = smb_fdata(ndo, data,
	    "BROWSE PACKET:\nType=[B] (MasterAnnouncement)\nMasterName=[S]\n",
	    maxbuf, unicodestr);
	break;

    case 0xe:
	data = smb_fdata(ndo, data,
	    "BROWSE PACKET:\nType=[B] (ResetBrowser)\nOptions=[B]\n", maxbuf, unicodestr);
	break;

    default:
	data = smb_fdata(ndo, data, "Unknown Browser Frame ", maxbuf, unicodestr);
	break;
    }
    return;
trunc:
    ND_PRINT((ndo, "%s", tstr));
}


GpuServiceImpl* gpu_service() { return gpu_service_holder_->gpu_service(); }


    void Greeter::stop() {
        // check flag
        if (!m_started)
            return;

        // log message
        qDebug() << "Greeter stopping...";

        if (daemonApp->testing()) {
            // terminate process
            m_process->terminate();

            // wait for finished
            if (!m_process->waitForFinished(5000))
                m_process->kill();
        }
    }


bool initiate_stratum(struct pool *pool)
{
	bool ret = false, recvd = false, noresume = false, sockd = false;
	char s[RBUFSIZE], *sret = NULL, *nonce1, *sessionid;
	json_t *val = NULL, *res_val, *err_val;
	json_error_t err;
	int n2size;

resend:
	if (!setup_stratum_socket(pool)) {
		sockd = false;
		goto out;
	}

	sockd = true;

	if (recvd) {
		/* Get rid of any crap lying around if we're resending */
		clear_sock(pool);
		sprintf(s, "{\"id\": %d, \"method\": \"mining.subscribe\", \"params\": []}", swork_id++);
	} else {
		if (pool->sessionid)
			sprintf(s, "{\"id\": %d, \"method\": \"mining.subscribe\", \"params\": [\""PACKAGE"/"VERSION"\", \"%s\"]}", swork_id++, pool->sessionid);
		else
			sprintf(s, "{\"id\": %d, \"method\": \"mining.subscribe\", \"params\": [\""PACKAGE"/"VERSION"\"]}", swork_id++);
	}

	if (__stratum_send(pool, s, strlen(s)) != SEND_OK) {
		applog(LOG_DEBUG, "Failed to send s in initiate_stratum");
		goto out;
	}

	if (!socket_full(pool, DEFAULT_SOCKWAIT)) {
		applog(LOG_DEBUG, "Timed out waiting for response in initiate_stratum");
		goto out;
	}

	sret = recv_line(pool);
	if (!sret)
		goto out;

	recvd = true;

	val = JSON_LOADS(sret, &err);
	free(sret);
	if (!val) {
		applog(LOG_INFO, "JSON decode failed(%d): %s", err.line, err.text);
		goto out;
	}

	res_val = json_object_get(val, "result");
	err_val = json_object_get(val, "error");

	if (!res_val || json_is_null(res_val) ||
	    (err_val && !json_is_null(err_val))) {
		char *ss;

		if (err_val)
			ss = json_dumps(err_val, JSON_INDENT(3));
		else
			ss = strdup("(unknown reason)");

		applog(LOG_INFO, "JSON-RPC decode failed: %s", ss);

		free(ss);

		goto out;
	}

	sessionid = get_sessionid(res_val);
	if (!sessionid)
		applog(LOG_DEBUG, "Failed to get sessionid in initiate_stratum");
	nonce1 = json_array_string(res_val, 1);
	if (!nonce1) {
		applog(LOG_INFO, "Failed to get nonce1 in initiate_stratum");
		free(sessionid);
		goto out;
	}
	n2size = json_integer_value(json_array_get(res_val, 2));
	if (!n2size) {
		applog(LOG_INFO, "Failed to get n2size in initiate_stratum");
		free(sessionid);
		free(nonce1);
		goto out;
	}

	cg_wlock(&pool->data_lock);
	pool->sessionid = sessionid;
	pool->nonce1 = nonce1;
	pool->n1_len = strlen(nonce1) / 2;
	free(pool->nonce1bin);
	pool->nonce1bin = calloc(pool->n1_len, 1);
	if (unlikely(!pool->nonce1bin))
		quithere(1, "Failed to calloc pool->nonce1bin");
	hex2bin(pool->nonce1bin, pool->nonce1, pool->n1_len);
	pool->n2size = n2size;
	cg_wunlock(&pool->data_lock);

	if (sessionid)
		applog(LOG_DEBUG, "Pool %d stratum session id: %s", pool->pool_no, pool->sessionid);

	ret = true;
out:
	if (ret) {
		if (!pool->stratum_url)
			pool->stratum_url = pool->sockaddr_url;
		pool->stratum_active = true;
		pool->sdiff = 1;
		if (opt_protocol) {
			applog(LOG_DEBUG, "Pool %d confirmed mining.subscribe with extranonce1 %s extran2size %d",
			       pool->pool_no, pool->nonce1, pool->n2size);
		}
	} else {
		if (recvd && !noresume) {
			/* Reset the sessionid used for stratum resuming in case the pool
			* does not support it, or does not know how to respond to the
			* presence of the sessionid parameter. */
			cg_wlock(&pool->data_lock);
			free(pool->sessionid);
			free(pool->nonce1);
			pool->sessionid = pool->nonce1 = NULL;
			cg_wunlock(&pool->data_lock);

			applog(LOG_DEBUG, "Failed to resume stratum, trying afresh");
			noresume = true;
			json_decref(val);
			goto resend;
		}
		applog(LOG_DEBUG, "Initiate stratum failed");
		if (sockd)
			suspend_stratum(pool);
	}

	json_decref(val);
	return ret;
}


printNewMessages( ClassAd* result_ad, StringList* ids )
{
	char* tmp;
	char* msg;
	PROC_ID job_id;
	bool rval;

	JobActionResults results;
	results.readResults( result_ad );

	ids->rewind();
	while( (tmp = ids->next()) ) {
		job_id = getProcByString( tmp );
		rval = results.getResultString( job_id, &msg );
		if( rval ) {
			fprintf( stdout, "%s\n", msg );
		} else {
			fprintf( stderr, "%s\n", msg );
		}
		free( msg );
	}
}


static int scsi_hot_add(Monitor *mon, DeviceState *adapter,

                        DriveInfo *dinfo, int printinfo)

{

    SCSIBus *scsibus;

    SCSIDevice *scsidev;

    scsibus = DO_UPCAST(SCSIBus, qbus, QLIST_FIRST(&adapter->child_bus));

    if (!scsibus || strcmp(scsibus->qbus.info->name, "SCSI") != 0) {

        error_report("Device is not a SCSI adapter");

    /*

     * drive_init() tries to find a default for dinfo->unit.  Doesn't

     * work at all for hotplug though as we assign the device to a

     * specific bus instead of the first bus with spare scsi ids.

     *

     * Ditch the calculated value and reload from option string (if

     * specified).

     */

    dinfo->unit = qemu_opt_get_number(dinfo->opts, "unit", -1);

    scsidev = scsi_bus_legacy_add_drive(scsibus, dinfo, dinfo->unit);

    dinfo->unit = scsidev->id;

    if (printinfo)

        monitor_printf(mon, "OK bus %d, unit %d\n",

                       scsibus->busnr, scsidev->id);

    return 0;


static int qemu_rdma_write(QEMUFile *f, RDMAContext *rdma,

                           uint64_t block_offset, uint64_t offset,

                           uint64_t len)

{

    uint64_t current_addr = block_offset + offset;

    uint64_t index = rdma->current_index;

    uint64_t chunk = rdma->current_chunk;

    int ret;

    /* If we cannot merge it, we flush the current buffer first. */

    if (!qemu_rdma_buffer_mergable(rdma, current_addr, len)) {

        ret = qemu_rdma_write_flush(f, rdma);

        if (ret) {

            return ret;

        }

        rdma->current_length = 0;

        rdma->current_addr = current_addr;

        ret = qemu_rdma_search_ram_block(rdma, block_offset,

                                         offset, len, &index, &chunk);

        if (ret) {

            fprintf(stderr, "ram block search failed\n");

            return ret;

        }

        rdma->current_index = index;

        rdma->current_chunk = chunk;

    }

    /* merge it */

    rdma->current_length += len;

    /* flush it if buffer is too large */

    if (rdma->current_length >= RDMA_MERGE_MAX) {

        return qemu_rdma_write_flush(f, rdma);

    }

    return 0;

}


netdutils::Status XfrmController::fillXfrmId(const std::string& sourceAddress,
 const std::string& destinationAddress, int32_t spi,
 int32_t markValue, int32_t markMask,
 int32_t transformId, XfrmId* xfrmId) {
    xfrmId->transformId = transformId;
    xfrmId->spi = htonl(spi);
    xfrmId->mark.v = markValue;
    xfrmId->mark.m = markMask;

 xfrm_address_t sourceXfrmAddr{}, destXfrmAddr{};
 StatusOr<int> sourceFamily, destFamily;
    sourceFamily = convertToXfrmAddr(sourceAddress, &sourceXfrmAddr);
    destFamily = convertToXfrmAddr(destinationAddress, &destXfrmAddr);
 if (!isOk(sourceFamily) || !isOk(destFamily)) {
 return netdutils::statusFromErrno(EINVAL, "Invalid address " + sourceAddress + "/" +
                                                      destinationAddress);
 }

 if (destFamily.value() == AF_UNSPEC ||
 (sourceFamily.value() != AF_UNSPEC && sourceFamily.value() != destFamily.value())) {
        ALOGD("Invalid or Mismatched Address Families, %d != %d, line=%d", sourceFamily.value(),
              destFamily.value(), __LINE__);
 return netdutils::statusFromErrno(EINVAL, "Invalid or mismatched address families");
 }

    xfrmId->addrFamily = destFamily.value();

    xfrmId->dstAddr = destXfrmAddr;
    xfrmId->srcAddr = sourceXfrmAddr;
 return netdutils::status::ok;
}


static int findlocal(JF, const char *name)
{
	int i;
	for (i = F->varlen; i > 0; --i)
		if (!strcmp(F->vartab[i-1], name))
			return i;
	return -1;
}


static int load_all_firmwares(struct dvb_frontend *fe,
			      const struct firmware *fw)
{
	struct xc2028_data    *priv = fe->tuner_priv;
	const unsigned char   *p, *endp;
	int                   rc = 0;
	int		      n, n_array;
	char		      name[33];

	tuner_dbg("%s called\n", __func__);

	p = fw->data;
	endp = p + fw->size;

	if (fw->size < sizeof(name) - 1 + 2 + 2) {
		tuner_err("Error: firmware file %s has invalid size!\n",
			  priv->fname);
		goto corrupt;
	}

	memcpy(name, p, sizeof(name) - 1);
	name[sizeof(name) - 1] = 0;
	p += sizeof(name) - 1;

	priv->firm_version = get_unaligned_le16(p);
	p += 2;

	n_array = get_unaligned_le16(p);
	p += 2;

	tuner_info("Loading %d firmware images from %s, type: %s, ver %d.%d\n",
		   n_array, priv->fname, name,
		   priv->firm_version >> 8, priv->firm_version & 0xff);

	priv->firm = kcalloc(n_array, sizeof(*priv->firm), GFP_KERNEL);
	if (priv->firm == NULL) {
		tuner_err("Not enough memory to load firmware file.\n");
		rc = -ENOMEM;
		goto err;
	}
	priv->firm_size = n_array;

	n = -1;
	while (p < endp) {
		__u32 type, size;
		v4l2_std_id id;
		__u16 int_freq = 0;

		n++;
		if (n >= n_array) {
			tuner_err("More firmware images in file than "
				  "were expected!\n");
			goto corrupt;
		}

		/* Checks if there's enough bytes to read */
		if (endp - p < sizeof(type) + sizeof(id) + sizeof(size))
			goto header;

		type = get_unaligned_le32(p);
		p += sizeof(type);

		id = get_unaligned_le64(p);
		p += sizeof(id);

		if (type & HAS_IF) {
			int_freq = get_unaligned_le16(p);
			p += sizeof(int_freq);
			if (endp - p < sizeof(size))
				goto header;
		}

		size = get_unaligned_le32(p);
		p += sizeof(size);

		if (!size || size > endp - p) {
			tuner_err("Firmware type ");
			dump_firm_type(type);
			printk("(%x), id %llx is corrupted "
			       "(size=%d, expected %d)\n",
			       type, (unsigned long long)id,
			       (unsigned)(endp - p), size);
			goto corrupt;
		}

		priv->firm[n].ptr = kzalloc(size, GFP_KERNEL);
		if (priv->firm[n].ptr == NULL) {
			tuner_err("Not enough memory to load firmware file.\n");
			rc = -ENOMEM;
			goto err;
		}
		tuner_dbg("Reading firmware type ");
		if (debug) {
			dump_firm_type_and_int_freq(type, int_freq);
			printk("(%x), id %llx, size=%d.\n",
			       type, (unsigned long long)id, size);
		}

		memcpy(priv->firm[n].ptr, p, size);
		priv->firm[n].type = type;
		priv->firm[n].id   = id;
		priv->firm[n].size = size;
		priv->firm[n].int_freq = int_freq;

		p += size;
	}

	if (n + 1 != priv->firm_size) {
		tuner_err("Firmware file is incomplete!\n");
		goto corrupt;
	}

	goto done;

header:
	tuner_err("Firmware header is incomplete!\n");
corrupt:
	rc = -EINVAL;
	tuner_err("Error: firmware file is corrupted!\n");

err:
	tuner_info("Releasing partially loaded firmware file.\n");
	free_firmware(priv);

done:
	if (rc == 0)
		tuner_dbg("Firmware files loaded.\n");
	else
		priv->state = XC2028_NODEV;

	return rc;
}


static int mxf_compute_sample_count(MXFContext *mxf, int stream_index,
                                    uint64_t *sample_count)
{
    int i, total = 0, size = 0;
    AVStream *st = mxf->fc->streams[stream_index];
    MXFTrack *track = st->priv_data;
    AVRational time_base = av_inv_q(track->edit_rate);
    AVRational sample_rate = av_inv_q(st->time_base);
    const MXFSamplesPerFrame *spf = NULL;

    if ((sample_rate.num / sample_rate.den) == 48000)
        spf = ff_mxf_get_samples_per_frame(mxf->fc, time_base);
    if (!spf) {
        int remainder = (sample_rate.num * time_base.num) %
                        (time_base.den * sample_rate.den);
        *sample_count = av_q2d(av_mul_q((AVRational){mxf->current_edit_unit, 1},
                                        av_mul_q(sample_rate, time_base)));
        if (remainder)
            av_log(mxf->fc, AV_LOG_WARNING,
                   "seeking detected on stream #%d with time base (%d/%d) and "
                   "sample rate (%d/%d), audio pts won't be accurate.\n",
                   stream_index, time_base.num, time_base.den,
                   sample_rate.num, sample_rate.den);
        return 0;
    }

    while (spf->samples_per_frame[size]) {
        total += spf->samples_per_frame[size];
        size++;
    }

    av_assert2(size);

    *sample_count = (mxf->current_edit_unit / size) * (uint64_t)total;
    for (i = 0; i < mxf->current_edit_unit % size; i++) {
        *sample_count += spf->samples_per_frame[i];
    }

    return 0;
}


static oe_fd_t* _hostfs_opendir(oe_device_t* device, const char* name)
{
    oe_fd_t* ret = NULL;
    device_t* fs = _cast_device(device);
    dir_t* dir = NULL;
    char host_name[OE_PATH_MAX];
    uint64_t retval = 0;

    if (!fs || !name)
        OE_RAISE_ERRNO(OE_EINVAL);

    if (_make_host_path(fs, name, host_name) != 0)
        OE_RAISE_ERRNO_MSG(oe_errno, "name=%s", name);

    if (!(dir = oe_calloc(1, sizeof(dir_t))))
        OE_RAISE_ERRNO(OE_ENOMEM);

    if (oe_syscall_opendir_ocall(&retval, host_name) != OE_OK)
        OE_RAISE_ERRNO(OE_EINVAL);

    if (!retval)
        OE_RAISE_ERRNO(oe_errno);

    dir->base.type = OE_FD_TYPE_FILE;
    dir->magic = DIR_MAGIC;
    dir->base.ops.file = _get_file_ops();
    dir->host_dir = retval;

    ret = &dir->base;
    dir = NULL;

done:

    if (dir)
        oe_free(dir);

    return ret;
}


qemuProcessStartHook(virQEMUDriverPtr driver,
                     virDomainObjPtr vm,
                     virHookQemuOpType op,
                     virHookSubopType subop)
{
    qemuDomainObjPrivatePtr priv = vm->privateData;
    g_autofree char *xml = NULL;
    int ret;

    if (!virHookPresent(VIR_HOOK_DRIVER_QEMU))
        return 0;

    if (!(xml = qemuDomainDefFormatXML(driver, priv->qemuCaps, vm->def, 0)))
        return -1;

    ret = virHookCall(VIR_HOOK_DRIVER_QEMU, vm->def->name, op, subop,
                      NULL, xml, NULL);

    return ret;
}


static int iwgif_read_screen_descriptor(struct iwgifrcontext *rctx)
{
	int has_global_ct;
	int global_ct_size;
	int aspect_ratio_code;

	// The screen descriptor is always 7 bytes in size.
	if(!iwgif_read(rctx,rctx->rbuf,7)) return 0;
	rctx->screen_width = (int)iw_get_ui16le(&rctx->rbuf[0]);
	rctx->screen_height = (int)iw_get_ui16le(&rctx->rbuf[2]);
	// screen_width and _height may be updated in iwgif_init_screen().

	has_global_ct = (int)((rctx->rbuf[4]>>7)&0x01);

	if(has_global_ct) {
		// Size of global color table
		global_ct_size = (int)(rctx->rbuf[4]&0x07);
		rctx->colortable.num_entries = 1<<(1+global_ct_size);

		// Background color
		rctx->bg_color_index = (int)rctx->rbuf[5];
		if(rctx->bg_color_index < rctx->colortable.num_entries)
			rctx->has_bg_color = 1;
	}

	aspect_ratio_code = (int)rctx->rbuf[6];
	if(aspect_ratio_code!=0) {
		// [aspect ratio = (pixel width)/(pixel height)]
		rctx->img->density_code = IW_DENSITY_UNITS_UNKNOWN;
		rctx->img->density_x = 64000.0/(double)(aspect_ratio_code + 15);
		rctx->img->density_y = 1000.0;
	}

	return 1;
}


MemoryRegion *flatview_translate(FlatView *fv, hwaddr addr, hwaddr *xlat,
                                 hwaddr *plen, bool is_write,
                                 MemTxAttrs attrs)
{
    MemoryRegion *mr;
    MemoryRegionSection section;
    AddressSpace *as = NULL;

    /* This can be MMIO, so setup MMIO bit. */
    section = flatview_do_translate(fv, addr, xlat, plen, NULL,
                                    is_write, true, &as, attrs);
    mr = section.mr;

    if (xen_enabled() && memory_access_is_direct(mr, is_write)) {
        hwaddr page = ((addr & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE) - addr;
        *plen = MIN(page, *plen);
    }

    return mr;
}


  bool peekList() {
    return false;
  }


static av_cold int vaapi_encode_h264_init(AVCodecContext *avctx)

{

    return ff_vaapi_encode_init(avctx, &vaapi_encode_type_h264);

}


Capabilities GLES2DecoderImpl::GetCapabilities() {
  DCHECK(initialized());

  Capabilities caps;

  caps.fast_npot_mo8_textures =
      feature_info_->workarounds().enable_chromium_fast_npot_mo8_textures;
  caps.egl_image_external =
      feature_info_->feature_flags().oes_egl_image_external;
  caps.texture_format_bgra8888 =
      feature_info_->feature_flags().ext_texture_format_bgra8888;
  caps.texture_format_etc1 =
      feature_info_->feature_flags().oes_compressed_etc1_rgb8_texture;
  caps.texture_rectangle = feature_info_->feature_flags().arb_texture_rectangle;
  caps.texture_usage = feature_info_->feature_flags().angle_texture_usage;
  caps.texture_storage = feature_info_->feature_flags().ext_texture_storage;
  caps.discard_framebuffer =
      feature_info_->feature_flags().ext_discard_framebuffer;
  caps.sync_query = feature_info_->feature_flags().chromium_sync_query;

#if defined(OS_MACOSX)
  caps.iosurface = true;
#endif

  caps.post_sub_buffer = supports_post_sub_buffer_;
  caps.map_image = !!image_manager();

  return caps;
}


str_matches_option(const char *s1, const char *optionname)
{
	/* Option names are given as "option:" We accept either 'option' in
	 * s1, or 'option:randomjunk'.  The latter form is to implement the
	 * resolv.conf parser. */
	size_t optlen = strlen(optionname);
	size_t slen = strlen(s1);
	if (slen == optlen || slen == optlen - 1)
		return !strncmp(s1, optionname, slen);
	else if (slen > optlen)
		return !strncmp(s1, optionname, optlen);
	else
		return 0;
}


static uint8_t *extend_raw_data(LHAFileHeader **header,
                                LHAInputStream *stream,
                                size_t nbytes)
{
	LHAFileHeader *new_header;
	size_t new_raw_len;
	uint8_t *result;

	// Reallocate the header and raw_data area to be larger.

	new_raw_len = RAW_DATA_LEN(header) + nbytes;
	new_header = realloc(*header, sizeof(LHAFileHeader) + new_raw_len);

	if (new_header == NULL) {
		return NULL;
	}

	// Update the header pointer to point to the new area.

	*header = new_header;
	new_header->raw_data = (uint8_t *) (new_header + 1);
	result = new_header->raw_data + new_header->raw_data_len;

	// Read data from stream into new area.

	if (!lha_input_stream_read(stream, result, nbytes)) {
		return NULL;
	}

	new_header->raw_data_len = new_raw_len;

	return result;
}


MediaStreamManager::~MediaStreamManager() {
  DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::IO));
  DVLOG(1) << "~MediaStreamManager";
  DCHECK(requests_.empty());

  base::PowerMonitor* power_monitor = base::PowerMonitor::Get();
  if (power_monitor)
    power_monitor->RemoveObserver(this);
}


static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
{
	struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
	struct rb_node **rb_link, *rb_parent;
	int retval;
	unsigned long charge;
	struct mempolicy *pol;

	down_write(&oldmm->mmap_sem);
	flush_cache_dup_mm(oldmm);
	/*
	 * Not linked in yet - no deadlock potential:
	 */
	down_write_nested(&mm->mmap_sem, SINGLE_DEPTH_NESTING);

	mm->locked_vm = 0;
	mm->mmap = NULL;
	mm->mmap_cache = NULL;
	mm->free_area_cache = oldmm->mmap_base;
	mm->cached_hole_size = ~0UL;
	mm->map_count = 0;
	cpumask_clear(mm_cpumask(mm));
	mm->mm_rb = RB_ROOT;
	rb_link = &mm->mm_rb.rb_node;
	rb_parent = NULL;
	pprev = &mm->mmap;
	retval = ksm_fork(mm, oldmm);
	if (retval)
		goto out;

	prev = NULL;
	for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
		struct file *file;

		if (mpnt->vm_flags & VM_DONTCOPY) {
			long pages = vma_pages(mpnt);
			mm->total_vm -= pages;
			vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
								-pages);
			continue;
		}
		charge = 0;
		if (mpnt->vm_flags & VM_ACCOUNT) {
			unsigned int len = (mpnt->vm_end - mpnt->vm_start) >> PAGE_SHIFT;
			if (security_vm_enough_memory(len))
				goto fail_nomem;
			charge = len;
		}
		tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
		if (!tmp)
			goto fail_nomem;
		*tmp = *mpnt;
		INIT_LIST_HEAD(&tmp->anon_vma_chain);
		pol = mpol_dup(vma_policy(mpnt));
		retval = PTR_ERR(pol);
		if (IS_ERR(pol))
			goto fail_nomem_policy;
		vma_set_policy(tmp, pol);
		tmp->vm_mm = mm;
		if (anon_vma_fork(tmp, mpnt))
			goto fail_nomem_anon_vma_fork;
		tmp->vm_flags &= ~VM_LOCKED;
		tmp->vm_next = tmp->vm_prev = NULL;
		file = tmp->vm_file;
		if (file) {
			struct inode *inode = file->f_path.dentry->d_inode;
			struct address_space *mapping = file->f_mapping;

			get_file(file);
			if (tmp->vm_flags & VM_DENYWRITE)
				atomic_dec(&inode->i_writecount);
			spin_lock(&mapping->i_mmap_lock);
			if (tmp->vm_flags & VM_SHARED)
				mapping->i_mmap_writable++;
			tmp->vm_truncate_count = mpnt->vm_truncate_count;
			flush_dcache_mmap_lock(mapping);
			/* insert tmp into the share list, just after mpnt */
			vma_prio_tree_add(tmp, mpnt);
			flush_dcache_mmap_unlock(mapping);
			spin_unlock(&mapping->i_mmap_lock);
		}

		/*
		 * Clear hugetlb-related page reserves for children. This only
		 * affects MAP_PRIVATE mappings. Faults generated by the child
		 * are not guaranteed to succeed, even if read-only
		 */
		if (is_vm_hugetlb_page(tmp))
			reset_vma_resv_huge_pages(tmp);

		/*
		 * Link in the new vma and copy the page table entries.
		 */
		*pprev = tmp;
		pprev = &tmp->vm_next;
		tmp->vm_prev = prev;
		prev = tmp;

		__vma_link_rb(mm, tmp, rb_link, rb_parent);
		rb_link = &tmp->vm_rb.rb_right;
		rb_parent = &tmp->vm_rb;

		mm->map_count++;
		retval = copy_page_range(mm, oldmm, mpnt);

		if (tmp->vm_ops && tmp->vm_ops->open)
			tmp->vm_ops->open(tmp);

		if (retval)
			goto out;
	}
	/* a new mm has just been created */
	arch_dup_mmap(oldmm, mm);
	retval = 0;
out:
	up_write(&mm->mmap_sem);
	flush_tlb_mm(oldmm);
	up_write(&oldmm->mmap_sem);
	return retval;
fail_nomem_anon_vma_fork:
	mpol_put(pol);
fail_nomem_policy:
	kmem_cache_free(vm_area_cachep, tmp);
fail_nomem:
	retval = -ENOMEM;
	vm_unacct_memory(charge);
	goto out;
}


 void BlobURLRegistry::registerURL(SecurityOrigin* origin, const KURL& publicURL, URLRegistrable* blob)
 {
     ASSERT(&blob->registry() == this);
    BlobRegistry::registerBlobURL(origin, publicURL, static_cast<Blob*>(blob)->url());
 }


static int init_nss_hash(struct crypto_instance *instance)
{
	PK11SlotInfo*	hash_slot = NULL;
	SECItem		hash_param;

	if (!hash_to_nss[instance->crypto_hash_type]) {
		return 0;
	}

	hash_param.type = siBuffer;
	hash_param.data = 0;
	hash_param.len = 0;

	hash_slot = PK11_GetBestSlot(hash_to_nss[instance->crypto_hash_type], NULL);
	if (hash_slot == NULL) {
		log_printf(instance->log_level_security, "Unable to find security slot (err %d)",
			   PR_GetError());
		return -1;
	}

	instance->nss_sym_key_sign = PK11_ImportSymKey(hash_slot,
						       hash_to_nss[instance->crypto_hash_type],
						       PK11_OriginUnwrap, CKA_SIGN,
						       &hash_param, NULL);
	if (instance->nss_sym_key_sign == NULL) {
		log_printf(instance->log_level_security, "Failure to import key into NSS (err %d)",
			   PR_GetError());
		return -1;
	}

	PK11_FreeSlot(hash_slot);

	return 0;
}


int qemuMonitorJSONGetVirtType ( qemuMonitorPtr mon , int * virtType ) {
 int ret ;
 virJSONValuePtr cmd = qemuMonitorJSONMakeCommand ( "query-kvm" , NULL ) ;
 virJSONValuePtr reply = NULL ;
 * virtType = VIR_DOMAIN_VIRT_QEMU ;
 if ( ! cmd ) return - 1 ;
 ret = qemuMonitorJSONCommand ( mon , cmd , & reply ) ;
 if ( ret == 0 ) ret = qemuMonitorJSONCheckError ( cmd , reply ) ;
 if ( ret == 0 ) {
 virJSONValuePtr data ;
 bool val = false ;
 if ( ! ( data = virJSONValueObjectGet ( reply , "return" ) ) ) {
 qemuReportError ( VIR_ERR_INTERNAL_ERROR , "%s" , _ ( "info kvm reply was missing return data" ) ) ;
 ret = - 1 ;
 goto cleanup ;
 }
 if ( virJSONValueObjectGetBoolean ( data , "enabled" , & val ) < 0 ) {
 qemuReportError ( VIR_ERR_INTERNAL_ERROR , "%s" , _ ( "info kvm reply missing 'running' field" ) ) ;
 ret = - 1 ;
 goto cleanup ;
 }
 if ( val ) * virtType = VIR_DOMAIN_VIRT_KVM ;
 }
 cleanup : virJSONValueFree ( cmd ) ;
 virJSONValueFree ( reply ) ;
 return ret ;
 }


static inline void cil_reset_userrange(struct cil_userrange *userrange)
{
	if (userrange->range_str == NULL) {
		cil_reset_levelrange(userrange->range);
	}
}


static void reg_set_min_max_inv(struct bpf_reg_state *true_reg,
				struct bpf_reg_state *false_reg,
				u64 val, u32 val32,
				u8 opcode, bool is_jmp32)
{
	opcode = flip_opcode(opcode);
	/* This uses zero as "not present in table"; luckily the zero opcode,
	 * BPF_JA, can't get here.
	 */
	if (opcode)
		reg_set_min_max(true_reg, false_reg, val, val32, opcode, is_jmp32);
}


static unsigned long nested_svm_get_tdp_cr3(struct kvm_vcpu *vcpu)
{
	struct vcpu_svm *svm = to_svm(vcpu);

	return svm->nested.nested_cr3;
}


type_init(assign_register_types)

static void assigned_dev_load_option_rom(AssignedDevice *dev)

{

    int size = 0;

    pci_assign_dev_load_option_rom(&dev->dev, OBJECT(dev), &size,

                                   dev->host.domain, dev->host.bus,

                                   dev->host.slot, dev->host.function);

    if (!size) {

        error_report("pci-assign: Invalid ROM.");

    }

}


ExprList_Finish(ExprList *l, PyArena *arena)
{
    asdl_seq *seq;

    ExprList_check_invariants(l);

    /* Allocate the asdl_seq and copy the expressions in to it. */
    seq = _Ta3_asdl_seq_new(l->size, arena);
    if (seq) {
        Py_ssize_t i;
        for (i = 0; i < l->size; i++)
            asdl_seq_SET(seq, i, l->p[i]);
    }
    ExprList_Dealloc(l);
    return seq;
}


static void FLOATING_POINT_RESTORE ( ) {
 }


static int gen_set_psr(DisasContext *s, uint32_t mask, int spsr, TCGv t0)

{

    TCGv tmp;

    if (spsr) {

        /* ??? This is also undefined in system mode.  */

        if (IS_USER(s))

            return 1;

        tmp = load_cpu_field(spsr);

        tcg_gen_andi_i32(tmp, tmp, ~mask);

        tcg_gen_andi_i32(t0, t0, mask);

        tcg_gen_or_i32(tmp, tmp, t0);

        store_cpu_field(tmp, spsr);

    } else {

        gen_set_cpsr(t0, mask);

    }

    dead_tmp(t0);

    gen_lookup_tb(s);

    return 0;

}


bool WebContext::IsInitialized() const {
  return context_.get() != nullptr;
}


decode_bytes_with_escapes(struct compiling *c, const node *n, const char *s,
                          size_t len)
{
    const char *first_invalid_escape;
    PyObject *result = _PyBytes_DecodeEscape(s, len, NULL, 0, NULL,
                                             &first_invalid_escape);
    if (result == NULL)
        return NULL;

    if (first_invalid_escape != NULL) {
        if (warn_invalid_escape_sequence(c, n, *first_invalid_escape) < 0) {
            Py_DECREF(result);
            return NULL;
        }
    }
    return result;
}


void V8TestObject::HighEntropyReadonlyAttributeWithMeasureAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
  RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestObject_highEntropyReadonlyAttributeWithMeasure_Getter");

  ExecutionContext* execution_context_for_measurement = CurrentExecutionContext(info.GetIsolate());
  UseCounter::Count(execution_context_for_measurement, WebFeature::kV8TestObject_HighEntropyReadonlyAttributeWithMeasure_AttributeGetter);
  Dactyloscoper::Record(execution_context_for_measurement, WebFeature::kV8TestObject_HighEntropyReadonlyAttributeWithMeasure_AttributeGetter);

  test_object_v8_internal::HighEntropyReadonlyAttributeWithMeasureAttributeGetter(info);
}


reset_completer_word_break_chars ()
{
  rl_completer_word_break_characters = perform_hostname_completion ? savestring (bash_completer_word_break_characters) : savestring (bash_nohostname_word_break_characters);
}


static __init int veth_init(void)
{
	return rtnl_link_register(&veth_link_ops);
}


static int RENAME(dct_quantize)(MpegEncContext *s,

                            int16_t *block, int n,

                            int qscale, int *overflow)

{

    x86_reg last_non_zero_p1;

    int level=0, q; //=0 is because gcc says uninitialized ...

    const uint16_t *qmat, *bias;

    LOCAL_ALIGNED_16(int16_t, temp_block, [64]);

    av_assert2((7&(int)(&temp_block[0])) == 0); //did gcc align it correctly?

    //s->fdct (block);

    RENAME_FDCT(ff_fdct)(block); // cannot be anything else ...

    if(s->dct_error_sum)

        s->denoise_dct(s, block);

    if (s->mb_intra) {

        int dummy;

        if (n < 4){

            q = s->y_dc_scale;

            bias = s->q_intra_matrix16[qscale][1];

            qmat = s->q_intra_matrix16[qscale][0];

        }else{

            q = s->c_dc_scale;

            bias = s->q_chroma_intra_matrix16[qscale][1];

            qmat = s->q_chroma_intra_matrix16[qscale][0];

        }

        /* note: block[0] is assumed to be positive */

        if (!s->h263_aic) {

        __asm__ volatile (

                "mul %%ecx                \n\t"

                : "=d" (level), "=a"(dummy)

                : "a" ((block[0]>>2) + q), "c" (ff_inverse[q<<1])

        );

        } else

            /* For AIC we skip quant/dequant of INTRADC */

            level = (block[0] + 4)>>3;

        block[0]=0; //avoid fake overflow

//        temp_block[0] = (block[0] + (q >> 1)) / q;

        last_non_zero_p1 = 1;

    } else {

        last_non_zero_p1 = 0;

        bias = s->q_inter_matrix16[qscale][1];

        qmat = s->q_inter_matrix16[qscale][0];

    }

    if((s->out_format == FMT_H263 || s->out_format == FMT_H261) && s->mpeg_quant==0){

        __asm__ volatile(

            "movd %%"FF_REG_a", "MM"3           \n\t" // last_non_zero_p1

            SPREADW(MM"3")

            "pxor "MM"7, "MM"7                  \n\t" // 0

            "pxor "MM"4, "MM"4                  \n\t" // 0

            MOVQ" (%2), "MM"5                   \n\t" // qmat[0]

            "pxor "MM"6, "MM"6                  \n\t"

            "psubw (%3), "MM"6                  \n\t" // -bias[0]

            "mov $-128, %%"FF_REG_a"            \n\t"

            ".p2align 4                         \n\t"

            "1:                                 \n\t"

            MOVQ" (%1, %%"FF_REG_a"), "MM"0     \n\t" // block[i]

            SAVE_SIGN(MM"1", MM"0")                   // ABS(block[i])

            "psubusw "MM"6, "MM"0               \n\t" // ABS(block[i]) + bias[0]

            "pmulhw "MM"5, "MM"0                \n\t" // (ABS(block[i])*qmat[0] - bias[0]*qmat[0])>>16

            "por "MM"0, "MM"4                   \n\t"

            RESTORE_SIGN(MM"1", MM"0")                // out=((ABS(block[i])*qmat[0] - bias[0]*qmat[0])>>16)*sign(block[i])

            MOVQ" "MM"0, (%5, %%"FF_REG_a")     \n\t"

            "pcmpeqw "MM"7, "MM"0               \n\t" // out==0 ? 0xFF : 0x00

            MOVQ" (%4, %%"FF_REG_a"), "MM"1     \n\t"

            MOVQ" "MM"7, (%1, %%"FF_REG_a")     \n\t" // 0

            "pandn "MM"1, "MM"0                 \n\t"

            PMAXW(MM"0", MM"3")

            "add $"MMREG_WIDTH", %%"FF_REG_a"   \n\t"

            " js 1b                             \n\t"

            PMAX(MM"3", MM"0")

            "movd "MM"3, %%"FF_REG_a"           \n\t"

            "movzbl %%al, %%eax                 \n\t" // last_non_zero_p1

            : "+a" (last_non_zero_p1)

            : "r" (block+64), "r" (qmat), "r" (bias),

              "r" (inv_zigzag_direct16 + 64), "r" (temp_block + 64)

              XMM_CLOBBERS_ONLY("%xmm0", "%xmm1", "%xmm2", "%xmm3",

                                "%xmm4", "%xmm5", "%xmm6", "%xmm7")

        );

    }else{ // FMT_H263

        __asm__ volatile(

            "movd %%"FF_REG_a", "MM"3           \n\t" // last_non_zero_p1

            SPREADW(MM"3")

            "pxor "MM"7, "MM"7                  \n\t" // 0

            "pxor "MM"4, "MM"4                  \n\t" // 0

            "mov $-128, %%"FF_REG_a"            \n\t"

            ".p2align 4                         \n\t"

            "1:                                 \n\t"

            MOVQ" (%1, %%"FF_REG_a"), "MM"0     \n\t" // block[i]

            SAVE_SIGN(MM"1", MM"0")                   // ABS(block[i])

            MOVQ" (%3, %%"FF_REG_a"), "MM"6     \n\t" // bias[0]

            "paddusw "MM"6, "MM"0               \n\t" // ABS(block[i]) + bias[0]

            MOVQ" (%2, %%"FF_REG_a"), "MM"5     \n\t" // qmat[i]

            "pmulhw "MM"5, "MM"0                \n\t" // (ABS(block[i])*qmat[0] + bias[0]*qmat[0])>>16

            "por "MM"0, "MM"4                   \n\t"

            RESTORE_SIGN(MM"1", MM"0")                // out=((ABS(block[i])*qmat[0] - bias[0]*qmat[0])>>16)*sign(block[i])

            MOVQ" "MM"0, (%5, %%"FF_REG_a")     \n\t"

            "pcmpeqw "MM"7, "MM"0               \n\t" // out==0 ? 0xFF : 0x00

            MOVQ" (%4, %%"FF_REG_a"), "MM"1     \n\t"

            MOVQ" "MM"7, (%1, %%"FF_REG_a")     \n\t" // 0

            "pandn "MM"1, "MM"0                 \n\t"

            PMAXW(MM"0", MM"3")

            "add $"MMREG_WIDTH", %%"FF_REG_a"   \n\t"

            " js 1b                             \n\t"

            PMAX(MM"3", MM"0")

            "movd "MM"3, %%"FF_REG_a"           \n\t"

            "movzbl %%al, %%eax                 \n\t" // last_non_zero_p1

            : "+a" (last_non_zero_p1)

            : "r" (block+64), "r" (qmat+64), "r" (bias+64),

              "r" (inv_zigzag_direct16 + 64), "r" (temp_block + 64)

              XMM_CLOBBERS_ONLY("%xmm0", "%xmm1", "%xmm2", "%xmm3",

                                "%xmm4", "%xmm5", "%xmm6", "%xmm7")

        );

    }

    __asm__ volatile(

        "movd %1, "MM"1                     \n\t" // max_qcoeff

        SPREADW(MM"1")

        "psubusw "MM"1, "MM"4               \n\t"

        "packuswb "MM"4, "MM"4              \n\t"

#if COMPILE_TEMPLATE_SSE2

        "packsswb "MM"4, "MM"4              \n\t"

#endif

        "movd "MM"4, %0                     \n\t" // *overflow

        : "=g" (*overflow)

        : "g" (s->max_qcoeff)

    );

    if(s->mb_intra) block[0]= level;

    else            block[0]= temp_block[0];

    if (s->idsp.perm_type == FF_IDCT_PERM_SIMPLE) {

        if(last_non_zero_p1 <= 1) goto end;

        block[0x08] = temp_block[0x01]; block[0x10] = temp_block[0x08];

        block[0x20] = temp_block[0x10];

        if(last_non_zero_p1 <= 4) goto end;

        block[0x18] = temp_block[0x09]; block[0x04] = temp_block[0x02];

        block[0x09] = temp_block[0x03];

        if(last_non_zero_p1 <= 7) goto end;

        block[0x14] = temp_block[0x0A]; block[0x28] = temp_block[0x11];

        block[0x12] = temp_block[0x18]; block[0x02] = temp_block[0x20];

        if(last_non_zero_p1 <= 11) goto end;

        block[0x1A] = temp_block[0x19]; block[0x24] = temp_block[0x12];

        block[0x19] = temp_block[0x0B]; block[0x01] = temp_block[0x04];

        block[0x0C] = temp_block[0x05];

        if(last_non_zero_p1 <= 16) goto end;

        block[0x11] = temp_block[0x0C]; block[0x29] = temp_block[0x13];

        block[0x16] = temp_block[0x1A]; block[0x0A] = temp_block[0x21];

        block[0x30] = temp_block[0x28]; block[0x22] = temp_block[0x30];

        block[0x38] = temp_block[0x29]; block[0x06] = temp_block[0x22];

        if(last_non_zero_p1 <= 24) goto end;

        block[0x1B] = temp_block[0x1B]; block[0x21] = temp_block[0x14];

        block[0x1C] = temp_block[0x0D]; block[0x05] = temp_block[0x06];

        block[0x0D] = temp_block[0x07]; block[0x15] = temp_block[0x0E];

        block[0x2C] = temp_block[0x15]; block[0x13] = temp_block[0x1C];

        if(last_non_zero_p1 <= 32) goto end;

        block[0x0B] = temp_block[0x23]; block[0x34] = temp_block[0x2A];

        block[0x2A] = temp_block[0x31]; block[0x32] = temp_block[0x38];

        block[0x3A] = temp_block[0x39]; block[0x26] = temp_block[0x32];

        block[0x39] = temp_block[0x2B]; block[0x03] = temp_block[0x24];

        if(last_non_zero_p1 <= 40) goto end;

        block[0x1E] = temp_block[0x1D]; block[0x25] = temp_block[0x16];

        block[0x1D] = temp_block[0x0F]; block[0x2D] = temp_block[0x17];

        block[0x17] = temp_block[0x1E]; block[0x0E] = temp_block[0x25];

        block[0x31] = temp_block[0x2C]; block[0x2B] = temp_block[0x33];

        if(last_non_zero_p1 <= 48) goto end;

        block[0x36] = temp_block[0x3A]; block[0x3B] = temp_block[0x3B];

        block[0x23] = temp_block[0x34]; block[0x3C] = temp_block[0x2D];

        block[0x07] = temp_block[0x26]; block[0x1F] = temp_block[0x1F];

        block[0x0F] = temp_block[0x27]; block[0x35] = temp_block[0x2E];

        if(last_non_zero_p1 <= 56) goto end;

        block[0x2E] = temp_block[0x35]; block[0x33] = temp_block[0x3C];

        block[0x3E] = temp_block[0x3D]; block[0x27] = temp_block[0x36];

        block[0x3D] = temp_block[0x2F]; block[0x2F] = temp_block[0x37];

        block[0x37] = temp_block[0x3E]; block[0x3F] = temp_block[0x3F];

    }else if(s->idsp.perm_type == FF_IDCT_PERM_LIBMPEG2){

        if(last_non_zero_p1 <= 1) goto end;

        block[0x04] = temp_block[0x01];

        block[0x08] = temp_block[0x08]; block[0x10] = temp_block[0x10];

        if(last_non_zero_p1 <= 4) goto end;

        block[0x0C] = temp_block[0x09]; block[0x01] = temp_block[0x02];

        block[0x05] = temp_block[0x03];

        if(last_non_zero_p1 <= 7) goto end;

        block[0x09] = temp_block[0x0A]; block[0x14] = temp_block[0x11];

        block[0x18] = temp_block[0x18]; block[0x20] = temp_block[0x20];

        if(last_non_zero_p1 <= 11) goto end;

        block[0x1C] = temp_block[0x19];

        block[0x11] = temp_block[0x12]; block[0x0D] = temp_block[0x0B];

        block[0x02] = temp_block[0x04]; block[0x06] = temp_block[0x05];

        if(last_non_zero_p1 <= 16) goto end;

        block[0x0A] = temp_block[0x0C]; block[0x15] = temp_block[0x13];

        block[0x19] = temp_block[0x1A]; block[0x24] = temp_block[0x21];

        block[0x28] = temp_block[0x28]; block[0x30] = temp_block[0x30];

        block[0x2C] = temp_block[0x29]; block[0x21] = temp_block[0x22];

        if(last_non_zero_p1 <= 24) goto end;

        block[0x1D] = temp_block[0x1B]; block[0x12] = temp_block[0x14];

        block[0x0E] = temp_block[0x0D]; block[0x03] = temp_block[0x06];

        block[0x07] = temp_block[0x07]; block[0x0B] = temp_block[0x0E];

        block[0x16] = temp_block[0x15]; block[0x1A] = temp_block[0x1C];

        if(last_non_zero_p1 <= 32) goto end;

        block[0x25] = temp_block[0x23]; block[0x29] = temp_block[0x2A];

        block[0x34] = temp_block[0x31]; block[0x38] = temp_block[0x38];

        block[0x3C] = temp_block[0x39]; block[0x31] = temp_block[0x32];

        block[0x2D] = temp_block[0x2B]; block[0x22] = temp_block[0x24];

        if(last_non_zero_p1 <= 40) goto end;

        block[0x1E] = temp_block[0x1D]; block[0x13] = temp_block[0x16];

        block[0x0F] = temp_block[0x0F]; block[0x17] = temp_block[0x17];

        block[0x1B] = temp_block[0x1E]; block[0x26] = temp_block[0x25];

        block[0x2A] = temp_block[0x2C]; block[0x35] = temp_block[0x33];

        if(last_non_zero_p1 <= 48) goto end;

        block[0x39] = temp_block[0x3A]; block[0x3D] = temp_block[0x3B];

        block[0x32] = temp_block[0x34]; block[0x2E] = temp_block[0x2D];

            block[0x23] = temp_block[0x26]; block[0x1F] = temp_block[0x1F];

        block[0x27] = temp_block[0x27]; block[0x2B] = temp_block[0x2E];

        if(last_non_zero_p1 <= 56) goto end;

        block[0x36] = temp_block[0x35]; block[0x3A] = temp_block[0x3C];

        block[0x3E] = temp_block[0x3D]; block[0x33] = temp_block[0x36];

        block[0x2F] = temp_block[0x2F]; block[0x37] = temp_block[0x37];

        block[0x3B] = temp_block[0x3E]; block[0x3F] = temp_block[0x3F];

    }else{

        if(last_non_zero_p1 <= 1) goto end;

        block[0x01] = temp_block[0x01];

        block[0x08] = temp_block[0x08]; block[0x10] = temp_block[0x10];

        if(last_non_zero_p1 <= 4) goto end;

        block[0x09] = temp_block[0x09]; block[0x02] = temp_block[0x02];

        block[0x03] = temp_block[0x03];

        if(last_non_zero_p1 <= 7) goto end;

        block[0x0A] = temp_block[0x0A]; block[0x11] = temp_block[0x11];

        block[0x18] = temp_block[0x18]; block[0x20] = temp_block[0x20];

        if(last_non_zero_p1 <= 11) goto end;

        block[0x19] = temp_block[0x19];

        block[0x12] = temp_block[0x12]; block[0x0B] = temp_block[0x0B];

        block[0x04] = temp_block[0x04]; block[0x05] = temp_block[0x05];

        if(last_non_zero_p1 <= 16) goto end;

        block[0x0C] = temp_block[0x0C]; block[0x13] = temp_block[0x13];

        block[0x1A] = temp_block[0x1A]; block[0x21] = temp_block[0x21];

        block[0x28] = temp_block[0x28]; block[0x30] = temp_block[0x30];

        block[0x29] = temp_block[0x29]; block[0x22] = temp_block[0x22];

        if(last_non_zero_p1 <= 24) goto end;

        block[0x1B] = temp_block[0x1B]; block[0x14] = temp_block[0x14];

        block[0x0D] = temp_block[0x0D]; block[0x06] = temp_block[0x06];

        block[0x07] = temp_block[0x07]; block[0x0E] = temp_block[0x0E];

        block[0x15] = temp_block[0x15]; block[0x1C] = temp_block[0x1C];

        if(last_non_zero_p1 <= 32) goto end;

        block[0x23] = temp_block[0x23]; block[0x2A] = temp_block[0x2A];

        block[0x31] = temp_block[0x31]; block[0x38] = temp_block[0x38];

        block[0x39] = temp_block[0x39]; block[0x32] = temp_block[0x32];

        block[0x2B] = temp_block[0x2B]; block[0x24] = temp_block[0x24];

        if(last_non_zero_p1 <= 40) goto end;

        block[0x1D] = temp_block[0x1D]; block[0x16] = temp_block[0x16];

        block[0x0F] = temp_block[0x0F]; block[0x17] = temp_block[0x17];

        block[0x1E] = temp_block[0x1E]; block[0x25] = temp_block[0x25];

        block[0x2C] = temp_block[0x2C]; block[0x33] = temp_block[0x33];

        if(last_non_zero_p1 <= 48) goto end;

        block[0x3A] = temp_block[0x3A]; block[0x3B] = temp_block[0x3B];

        block[0x34] = temp_block[0x34]; block[0x2D] = temp_block[0x2D];

        block[0x26] = temp_block[0x26]; block[0x1F] = temp_block[0x1F];

        block[0x27] = temp_block[0x27]; block[0x2E] = temp_block[0x2E];

        if(last_non_zero_p1 <= 56) goto end;

        block[0x35] = temp_block[0x35]; block[0x3C] = temp_block[0x3C];

        block[0x3D] = temp_block[0x3D]; block[0x36] = temp_block[0x36];

        block[0x2F] = temp_block[0x2F]; block[0x37] = temp_block[0x37];

        block[0x3E] = temp_block[0x3E]; block[0x3F] = temp_block[0x3F];

    }

    end:

    return last_non_zero_p1 - 1;

}


_tiffSeekProc(thandle_t fd, uint64 off, int whence)
{
	off_t off_io = (off_t) off;
	if ((uint64) off_io != off)
	{
		errno=EINVAL;
		return (uint64) -1; /* this is really gross */
	}
	return((uint64)lseek((int)fd,off_io,whence));
}


static int tls1_generate_key_block(SSL *s, unsigned char *km, int num)
{
    int ret;
    ret = tls1_PRF(s,
                   TLS_MD_KEY_EXPANSION_CONST,
                   TLS_MD_KEY_EXPANSION_CONST_SIZE, s->s3->server_random,
                   SSL3_RANDOM_SIZE, s->s3->client_random, SSL3_RANDOM_SIZE,
                   NULL, 0, NULL, 0, s->session->master_key,
                   s->session->master_key_length, km, num);

    return ret;
}


int pnm_validate(jas_stream_t *in)
{
	jas_uchar buf[2];
	int i;
	int n;

	assert(JAS_STREAM_MAXPUTBACK >= 2);

	/* Read the first two characters that constitute the signature. */
	if ((n = jas_stream_read(in, buf, 2)) < 0) {
		return -1;
	}
	/* Put these characters back to the stream. */
	for (i = n - 1; i >= 0; --i) {
		if (jas_stream_ungetc(in, buf[i]) == EOF) {
			return -1;
		}
	}
	/* Did we read enough data? */
	if (n < 2) {
		return -1;
	}
	/* Is this the correct signature for a PNM file? */
	if (buf[0] == 'P' && isdigit(buf[1])) {
		return 0;
	}
	return -1;
}


void swallow_arg(int *argcp, char *argv[], char *which)
{
	int i;

	for (i = 1; argv[i]; i++) {
		if (strcmp(argv[i], which) != 0)
			continue;
		for (; argv[i]; i++) {
			argv[i] = argv[i+1];
		}
		(*argcp)--;
		return;
	}
}


static void sdma_put(struct sdma_state *ss)
{
	kref_put(&ss->kref, sdma_complete);
}


  void Play() {
    host_->OnPlayStream(kStreamId);
    SyncWithAudioThread();
  }


void QQuickWebViewFlickablePrivate::onComponentComplete()
{
    Q_Q(QQuickWebView);

    ASSERT(!flickProvider);
    flickProvider = new QtFlickProvider(q, pageView.data());

    const QQuickWebViewExperimental* experimental = q->experimental();
    QObject::connect(flickProvider, SIGNAL(contentWidthChanged()), experimental, SIGNAL(contentWidthChanged()));
    QObject::connect(flickProvider, SIGNAL(contentHeightChanged()), experimental, SIGNAL(contentHeightChanged()));
    QObject::connect(flickProvider, SIGNAL(contentXChanged()), experimental, SIGNAL(contentXChanged()));
    QObject::connect(flickProvider, SIGNAL(contentYChanged()), experimental, SIGNAL(contentYChanged()));

    interactionEngine.reset(new QtViewportInteractionEngine(q, pageView.data(), flickProvider));
    pageView->eventHandler()->setViewportInteractionEngine(interactionEngine.data());

    QObject::connect(interactionEngine.data(), SIGNAL(contentSuspendRequested()), q, SLOT(_q_suspend()));
    QObject::connect(interactionEngine.data(), SIGNAL(contentResumeRequested()), q, SLOT(_q_resume()));
    QObject::connect(interactionEngine.data(), SIGNAL(contentWasMoved(const QPointF&)), q, SLOT(_q_commitPositionChange(const QPointF&)));
    QObject::connect(interactionEngine.data(), SIGNAL(contentWasScaled()), q, SLOT(_q_commitScaleChange()));

    _q_resume();

    if (loadSuccessDispatchIsPending) {
        QQuickWebViewPrivate::loadDidSucceed();
        loadSuccessDispatchIsPending = false;
    }

    _q_onVisibleChanged();

    QQuickWebViewPrivate::onComponentComplete();
}


static void virtio_pci_device_unplugged(DeviceState *d)

{

    PCIDevice *pci_dev = PCI_DEVICE(d);

    VirtIOPCIProxy *proxy = VIRTIO_PCI(d);

    virtio_pci_stop_ioeventfd(proxy);

    msix_uninit_exclusive_bar(pci_dev);

}


ufmt_getLong(UFormattable *fmt, UErrorCode *status) {
  Formattable *obj = Formattable::fromUFormattable(fmt);

  return obj->getLong(*status);
}


static inline int get_bs ( cavs_vector * mvP , cavs_vector * mvQ , int b ) {
 if ( ( mvP -> ref == REF_INTRA ) || ( mvQ -> ref == REF_INTRA ) ) return 2 ;
 if ( ( abs ( mvP -> x - mvQ -> x ) >= 4 ) || ( abs ( mvP -> y - mvQ -> y ) >= 4 ) ) return 1 ;
 if ( b ) {
 mvP += MV_BWD_OFFS ;
 mvQ += MV_BWD_OFFS ;
 if ( ( abs ( mvP -> x - mvQ -> x ) >= 4 ) || ( abs ( mvP -> y - mvQ -> y ) >= 4 ) ) return 1 ;
 }
 else {
 if ( mvP -> ref != mvQ -> ref ) return 1 ;
 }
 return 0 ;
 }


void ChromeContentRendererClient::DidCreateScriptContext(
    WebFrame* frame, v8::Handle<v8::Context> context, int extension_group,
    int world_id) {
  extension_dispatcher_->DidCreateScriptContext(
      frame, context, extension_group, world_id);
}


X509_VERIFY_PARAM_set1_policies(X509_VERIFY_PARAM *param,
    STACK_OF(ASN1_OBJECT) *policies)
{
	int i;
	ASN1_OBJECT *oid, *doid;

	if (!param)
		return 0;
	if (param->policies)
		sk_ASN1_OBJECT_pop_free(param->policies, ASN1_OBJECT_free);

	if (!policies) {
		param->policies = NULL;
		return 1;
	}

	param->policies = sk_ASN1_OBJECT_new_null();
	if (!param->policies)
		return 0;

	for (i = 0; i < sk_ASN1_OBJECT_num(policies); i++) {
		oid = sk_ASN1_OBJECT_value(policies, i);
		doid = OBJ_dup(oid);
		if (!doid)
			return 0;
		if (!sk_ASN1_OBJECT_push(param->policies, doid)) {
			ASN1_OBJECT_free(doid);
			return 0;
		}
	}
	param->flags |= X509_V_FLAG_POLICY_CHECK;
	return 1;
}


void board_init_f_init_reserve(ulong base)
{
	struct global_data *gd_ptr;

	/*
	 * clear GD entirely and set it up.
	 * Use gd_ptr, as gd may not be properly set yet.
	 */

	gd_ptr = (struct global_data *)base;
	/* zero the area */
	memset(gd_ptr, '\0', sizeof(*gd));
	/* set GD unless architecture did it already */
#if !defined(CONFIG_ARM)
	arch_setup_gd(gd_ptr);
#endif

	if (CONFIG_IS_ENABLED(SYS_REPORT_STACK_F_USAGE))
		board_init_f_init_stack_protection_addr(base);

	/* next alloc will be higher by one GD plus 16-byte alignment */
	base += roundup(sizeof(struct global_data), 16);

	/*
	 * record early malloc arena start.
	 * Use gd as it is now properly set for all architectures.
	 */

 #if CONFIG_VAL(SYS_MALLOC_F_LEN)
 	/* go down one 'early malloc arena' */
 	gd->malloc_base = base;
 #endif

 	if (CONFIG_IS_ENABLED(SYS_REPORT_STACK_F_USAGE))
		board_init_f_init_stack_protection();
}


void RenderFrameHostImpl::SetNavigationRequest(
    std::unique_ptr<NavigationRequest> navigation_request) {
  DCHECK(navigation_request);
  if (FrameMsg_Navigate_Type::IsSameDocument(
          navigation_request->common_params().navigation_type)) {
    same_document_navigation_request_ = std::move(navigation_request);
    return;
  }
  navigation_requests_[navigation_request->navigation_handle()
                           ->GetNavigationId()] = std::move(navigation_request);
}


void AppCacheUpdateJob::HandleUrlFetchCompleted(URLFetcher* fetcher) {
  DCHECK(internal_state_ == DOWNLOADING);

  net::URLRequest* request = fetcher->request();
  const GURL& url = request->original_url();
  pending_url_fetches_.erase(url);
  NotifyAllProgress(url);
  ++url_fetches_completed_;

  int response_code = request->status().is_success()
                          ? request->GetResponseCode()
                          : fetcher->redirect_response_code();

  AppCacheEntry& entry = url_file_list_.find(url)->second;

  if (response_code / 100 == 2) {
    DCHECK(fetcher->response_writer());
    entry.set_response_id(fetcher->response_writer()->response_id());
    entry.set_response_size(fetcher->response_writer()->amount_written());
    if (!inprogress_cache_->AddOrModifyEntry(url, entry))
      duplicate_response_ids_.push_back(entry.response_id());

  } else {
    VLOG(1) << "Request status: " << request->status().status()
            << " error: " << request->status().error()
            << " response code: " << response_code;
    if (entry.IsExplicit() || entry.IsFallback() || entry.IsIntercept()) {
      if (response_code == 304 && fetcher->existing_entry().has_response_id()) {
        entry.set_response_id(fetcher->existing_entry().response_id());
        entry.set_response_size(fetcher->existing_entry().response_size());
        inprogress_cache_->AddOrModifyEntry(url, entry);
      } else {
        const char* kFormatString = "Resource fetch failed (%d) %s";
        std::string message = FormatUrlErrorMessage(
            kFormatString, url, fetcher->result(), response_code);
        ResultType result = fetcher->result();
        bool is_cross_origin = url.GetOrigin() != manifest_url_.GetOrigin();
        switch (result) {
          case DISKCACHE_ERROR:
            HandleCacheFailure(
                AppCacheErrorDetails(
                    message, APPCACHE_UNKNOWN_ERROR, GURL(), 0,
                    is_cross_origin),
                result,
                url);
            break;
          case NETWORK_ERROR:
            HandleCacheFailure(
                AppCacheErrorDetails(message, APPCACHE_RESOURCE_ERROR, url, 0,
                    is_cross_origin),
                result,
                url);
            break;
          default:
            HandleCacheFailure(AppCacheErrorDetails(message,
                                            APPCACHE_RESOURCE_ERROR,
                                            url,
                                            response_code,
                                            is_cross_origin),
                               result,
                               url);
            break;
        }
        return;
      }
    } else if (response_code == 404 || response_code == 410) {
    } else if (update_type_ == UPGRADE_ATTEMPT &&
               fetcher->existing_entry().has_response_id()) {
      entry.set_response_id(fetcher->existing_entry().response_id());
      entry.set_response_size(fetcher->existing_entry().response_size());
      inprogress_cache_->AddOrModifyEntry(url, entry);
    }
  }

  DCHECK(internal_state_ != CACHE_FAILURE);
  FetchUrls();
  MaybeCompleteUpdate();
}


int ctrl_x_mode_path_patterns(void) {
				  return ctrl_x_mode == CTRL_X_PATH_PATTERNS; }


async_job_start (NautilusDirectory *directory,
                 const char        *job)
{
#ifdef DEBUG_ASYNC_JOBS
    char *key;
#endif

#ifdef DEBUG_START_STOP
    g_message ("starting %s in %p", job, directory->details->location);
#endif

    g_assert (async_job_count >= 0);
    g_assert (async_job_count <= MAX_ASYNC_JOBS);

    if (async_job_count >= MAX_ASYNC_JOBS)
    {
        if (waiting_directories == NULL)
        {
            waiting_directories = g_hash_table_new (NULL, NULL);
        }

        g_hash_table_insert (waiting_directories,
                             directory,
                             directory);

        return FALSE;
    }

#ifdef DEBUG_ASYNC_JOBS
    {
        char *uri;
        if (async_jobs == NULL)
        {
            async_jobs = g_hash_table_new (g_str_hash, g_str_equal);
        }
        uri = nautilus_directory_get_uri (directory);
        key = g_strconcat (uri, ": ", job, NULL);
        if (g_hash_table_lookup (async_jobs, key) != NULL)
        {
            g_warning ("same job twice: %s in %s",
                       job, uri);
        }
        g_free (uri);
        g_hash_table_insert (async_jobs, key, directory);
    }
#endif

    async_job_count += 1;
    return TRUE;
}


NOEXPORT unsigned __stdcall daemon_thread(void *arg) {
    (void)arg; /* squash the unused parameter warning */

    tls_alloc(NULL, NULL, "main"); /* new thread-local storage */
    main_init();
    SetEvent(main_initialized); /* unlock the GUI thread */
    /* get a valid configuration */
    while(main_configure(cmdline.config_file, NULL)) {
        if(cmdline.config_file && *cmdline.config_file=='-')
            cmdline.config_file=NULL; /* don't retry commandline switches */
        PostMessage(hwnd, WM_INVALID_CONFIG, 0, 0); /* display error */
        WaitForSingleObject(config_ready, INFINITE);
    }
    PostMessage(hwnd, WM_VALID_CONFIG, 0, 0);

    /* start the main loop */
    daemon_loop();
    main_cleanup();
    _endthreadex(0); /* SIGNAL_TERMINATE received */
    return 0;
}


static int ssi_sd_load(QEMUFile *f, void *opaque, int version_id)
{
    SSISlave *ss = SSI_SLAVE(opaque);
    ssi_sd_state *s = (ssi_sd_state *)opaque;
    int i;

    if (version_id != 1)
        return -EINVAL;

    s->mode = qemu_get_be32(f);
    s->cmd = qemu_get_be32(f);
    for (i = 0; i < 4; i++)
        s->cmdarg[i] = qemu_get_be32(f);
     for (i = 0; i < 5; i++)
         s->response[i] = qemu_get_be32(f);
     s->arglen = qemu_get_be32(f);
     s->response_pos = qemu_get_be32(f);
     s->stopping = qemu_get_be32(f);

     ss->cs = qemu_get_be32(f);
    s->mode = SSI_SD_CMD;
    dinfo = drive_get_next(IF_SD);
    s->sd = sd_init(dinfo ? dinfo->bdrv : NULL, true);
    if (s->sd == NULL) {
        return -1;
    }
    register_savevm(dev, "ssi_sd", -1, 1, ssi_sd_save, ssi_sd_load, s);
    return 0;
}


static const wbxml_decoding * wv_csp_discriminator ( tvbuff_t * tvb , guint32 offset ) {
 guint32 magic_1 = tvb_get_ntohl ( tvb , offset + 0 ) ;
 guint16 magic_2 = tvb_get_ntohs ( tvb , offset + 4 ) ;
 if ( magic_1 == 0xFE050331 && magic_2 == 0x2e30 ) {
 return & decode_wv_cspc_10 ;
 }
 else if ( magic_1 == 0xC9050331 && magic_2 == 0x2e31 ) {
 return & decode_wv_cspc_11 ;
 }
 else if ( magic_1 == 0xC9080331 && magic_2 == 0x2e32 ) {
 return & decode_wv_cspc_12 ;
 }
 else if ( magic_1 == 0xC90B0331 && magic_2 == 0x2E33 ) {
 return & decode_wv_cspc_13 ;
 }
 return & decode_wv_cspc_12 ;
 }


static int sock_map_fd(struct socket *sock, int flags)
{
	struct file *newfile;
	int fd = get_unused_fd_flags(flags);
	if (unlikely(fd < 0))
		return fd;

	newfile = sock_alloc_file(sock, flags, NULL);
	if (likely(!IS_ERR(newfile))) {
		fd_install(fd, newfile);
		return fd;
	}

	put_unused_fd(fd);
	return PTR_ERR(newfile);
}


uint64_t qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs,

                                               uint64_t offset,

                                               int compressed_size)

{

    BDRVQcowState *s = bs->opaque;

    int l2_index, ret;

    uint64_t *l2_table;

    int64_t cluster_offset;

    int nb_csectors;

    ret = get_cluster_table(bs, offset, &l2_table, &l2_index);

    if (ret < 0) {

        return 0;

    }

    cluster_offset = be64_to_cpu(l2_table[l2_index]);

    if (cluster_offset & QCOW_OFLAG_COPIED) {

        qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table);

        return 0;

    }

    if (cluster_offset)

        qcow2_free_any_clusters(bs, cluster_offset, 1);

    cluster_offset = qcow2_alloc_bytes(bs, compressed_size);

    if (cluster_offset < 0) {

        qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table);

        return 0;

    }

    nb_csectors = ((cluster_offset + compressed_size - 1) >> 9) -

                  (cluster_offset >> 9);

    cluster_offset |= QCOW_OFLAG_COMPRESSED |

                      ((uint64_t)nb_csectors << s->csize_shift);

    /* update L2 table */

    /* compressed clusters never have the copied flag */

    BLKDBG_EVENT(bs->file, BLKDBG_L2_UPDATE_COMPRESSED);

    qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table);

    l2_table[l2_index] = cpu_to_be64(cluster_offset);

    ret = qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table);

    if (ret < 0) {

        return 0;

    }

    return cluster_offset;

}


const char *mg_url_uri(const char *url) {
  struct url u = urlparse(url);
  return u.uri ? url + u.uri : "/";
}


static long compat_mpctl_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
{
	long ret;
	mutex_lock(&mpctl_mutex);
	switch (cmd) {
	case MPTIOCINFO:
	case MPTIOCINFO1:
	case MPTIOCINFO2:
	case MPTTARGETINFO:
	case MPTEVENTQUERY:
	case MPTEVENTENABLE:
	case MPTEVENTREPORT:
	case MPTHARDRESET:
	case HP_GETHOSTINFO:
	case HP_GETTARGETINFO:
	case MPTTEST:
		ret = __mptctl_ioctl(f, cmd, arg);
		break;
	case MPTCOMMAND32:
		ret = compat_mpt_command(f, cmd, arg);
		break;
	case MPTFWDOWNLOAD32:
		ret = compat_mptfwxfer_ioctl(f, cmd, arg);
		break;
	default:
		ret = -ENOIOCTLCMD;
		break;
	}
	mutex_unlock(&mpctl_mutex);
	return ret;
}


void WorkerThread::didStopRunLoop()
{
    ASSERT(isCurrentThread());
    Platform::current()->didStopWorkerRunLoop();
}


set_ref_in_insexpand_funcs(int copyID)
{
    int abort = FALSE;

    abort = set_ref_in_callback(&cfu_cb, copyID);
    abort = abort || set_ref_in_callback(&ofu_cb, copyID);
    abort = abort || set_ref_in_callback(&tsrfu_cb, copyID);

    return abort;
}


int fscrypt_process_policy(struct inode *inode,
				const struct fscrypt_policy *policy)
{
	if (!inode_owner_or_capable(inode))
		return -EACCES;

	if (policy->version != 0)
		return -EINVAL;

	if (!inode_has_encryption_context(inode)) {
		if (!inode->i_sb->s_cop->empty_dir)
			return -EOPNOTSUPP;
		if (!inode->i_sb->s_cop->empty_dir(inode))
			return -ENOTEMPTY;
		return create_encryption_context_from_policy(inode, policy);
	}

	if (is_encryption_context_consistent_with_policy(inode, policy))
		return 0;

	printk(KERN_WARNING "%s: Policy inconsistent with encryption context\n",
	       __func__);
	return -EINVAL;
}


void wcall_set_media_laddr(WUSER_HANDLE wuser, struct sa *laddr)
{
	struct calling_instance *inst;
	struct sa *maddr;

	if (!laddr)
		return;

	inst = wuser2inst(wuser);
	if (!inst) {
		warning("wcall: set_media_laddr: invalid wuser=0x%08X\n",
			wuser);
		return;
	}

	inst->media_laddr = mem_deref(inst->media_laddr);
	maddr = mem_zalloc(sizeof(*maddr), NULL);
	if (!maddr) {
		warning("wcall(%p): could not alloc media laddr\n", inst);
		return;
	}
	sa_cpy(maddr, laddr);
	inst->media_laddr = maddr;
}


static int rtmp_server_handshake(URLContext *s, RTMPContext *rt)

{

    uint8_t buffer[RTMP_HANDSHAKE_PACKET_SIZE];

    uint32_t hs_epoch;

    uint32_t hs_my_epoch;

    uint8_t hs_c1[RTMP_HANDSHAKE_PACKET_SIZE];

    uint8_t hs_s1[RTMP_HANDSHAKE_PACKET_SIZE];

    uint32_t zeroes;

    uint32_t temp       = 0;

    int randomidx       = 0;

    int inoutsize       = 0;

    int ret;

    inoutsize = ffurl_read_complete(rt->stream, buffer, 1);       // Receive C0

    if (inoutsize <= 0) {

        av_log(s, AV_LOG_ERROR, "Unable to read handshake\n");

        return AVERROR(EIO);

    }

    // Check Version

    if (buffer[0] != 3) {

        av_log(s, AV_LOG_ERROR, "RTMP protocol version mismatch\n");

        return AVERROR(EIO);

    }

    if (ffurl_write(rt->stream, buffer, 1) <= 0) {                 // Send S0

        av_log(s, AV_LOG_ERROR,

               "Unable to write answer - RTMP S0\n");

        return AVERROR(EIO);

    }

    /* Receive C1 */

    ret = rtmp_receive_hs_packet(rt, &hs_epoch, &zeroes, hs_c1,

                                 RTMP_HANDSHAKE_PACKET_SIZE);

    if (ret) {

        av_log(s, AV_LOG_ERROR, "RTMP Handshake C1 Error\n");

        return ret;

    }

    if (zeroes)

        av_log(s, AV_LOG_WARNING, "Erroneous C1 Message zero != 0\n");

    /* Send S1 */

    /* By now same epoch will be sent */

    hs_my_epoch = hs_epoch;

    /* Generate random */

    for (randomidx = 0; randomidx < (RTMP_HANDSHAKE_PACKET_SIZE);

         randomidx += 4)

        AV_WB32(hs_s1 + 8 + randomidx, av_get_random_seed());

    ret = rtmp_send_hs_packet(rt, hs_my_epoch, 0, hs_s1,

                              RTMP_HANDSHAKE_PACKET_SIZE);

    if (ret) {

        av_log(s, AV_LOG_ERROR, "RTMP Handshake S1 Error\n");

        return ret;

    }

    /* Send S2 */

    ret = rtmp_send_hs_packet(rt, hs_epoch, 0, hs_c1,

                              RTMP_HANDSHAKE_PACKET_SIZE);

    if (ret) {

        av_log(s, AV_LOG_ERROR, "RTMP Handshake S2 Error\n");

        return ret;

    }

    /* Receive C2 */

    ret = rtmp_receive_hs_packet(rt, &temp, &zeroes, buffer,

                                 RTMP_HANDSHAKE_PACKET_SIZE);

    if (ret) {

        av_log(s, AV_LOG_ERROR, "RTMP Handshake C2 Error\n");

        return ret;

    }

    if (temp != hs_my_epoch)

        av_log(s, AV_LOG_WARNING,

               "Erroneous C2 Message epoch does not match up with C1 epoch\n");

    if (memcmp(buffer + 8, hs_s1 + 8,

               RTMP_HANDSHAKE_PACKET_SIZE - 8))

        av_log(s, AV_LOG_WARNING,

               "Erroneous C2 Message random does not match up\n");

    return 0;

}


UserImageView* OobeUI::GetUserImageView() {
  return user_image_view_;
}


int ip_send_skb(struct net *net, struct sk_buff *skb)
{
	int err;

	err = ip_local_out(skb);
	if (err) {
		if (err > 0)
			err = net_xmit_errno(err);
		if (err)
			IP_INC_STATS(net, IPSTATS_MIB_OUTDISCARDS);
	}

	return err;
}


static int decode_space_limit(struct xdr_stream *xdr, u64 *maxsize)
{
        __be32 *p;
	uint32_t limit_type, nblocks, blocksize;

	READ_BUF(12);
	READ32(limit_type);
	switch (limit_type) {
		case 1:
			READ64(*maxsize);
			break;
		case 2:
			READ32(nblocks);
			READ32(blocksize);
			*maxsize = (uint64_t)nblocks * (uint64_t)blocksize;
	}
	return 0;
}


void WebContents::WebContentsDestroyed() {
  // Give chance for guest delegate to cleanup its observers
  // since the native class is only destroyed in the next tick.
  if (guest_delegate_)
    guest_delegate_->WillDestroy();

  // Cleanup relationships with other parts.

  // We can not call Destroy here because we need to call Emit first, but we
  // also do not want any method to be used, so just mark as destroyed here.
  MarkDestroyed();

  Emit("destroyed");

  // For guest view based on OOPIF, the WebContents is released by the embedder
  // frame, and we need to clear the reference to the memory.
  if (IsGuest() && inspectable_web_contents_) {
    inspectable_web_contents_->ReleaseWebContents();
    ResetManagedWebContents(false);
  }

  // Destroy the native class in next tick.
  base::ThreadTaskRunnerHandle::Get()->PostTask(
      FROM_HERE, base::BindOnce(
                     [](base::WeakPtr<WebContents> wc) {
                       if (wc)
                         delete wc.get();
                     },
                     GetWeakPtr()));
}


Formattable::adoptArray(Formattable* array, int32_t count)
{
    dispose();
    fType = kArray;
    fValue.fArrayAndCount.fArray = array;
    fValue.fArrayAndCount.fCount = count;
}


static int reorder_sequencer(input_translation_t *table) {
int i, n;
sequence_map_t *sequence = table->sequence;

#ifdef DEVEL
	printf("\nReorder Sequencer. Sequence steps: %u\n", table->number_of_sequences);
	for ( i=0; i<table->number_of_sequences; i++ ) {
		printf("Order: %i, Sequence: %u, Type: %u, Input length: %u, Output offset: %u, Skip Count: %u\n",
			i, sequence[i].id, sequence[i].type, sequence[i].input_length,
			sequence[i].output_offset, sequence[i].skip_count);
	}
#endif

	n = 0;	// index into sequencer table
	// reorder Sequencer steps, so they follow input order
	// insert skip counts if needed
	for ( i=0; i<cache.input_count; i++ ) {
		if ( cache.input_order[i].type == SKIP_ELEMENT ) {
			// skip dyn length or no previous slot in sequence map
			if ( cache.input_order[i].length == DYN_FIELD_LENGTH || n == 0 ) {
				int j;
				// insert skip sequence

				if ( !CheckSequenceMap(table) )
					return 0;

				// make room for new sequence - shift down slots
				for ( j=table->number_of_sequences-1; j>=n; j-- ) {
					sequence[j+1] = sequence[j];
				}

				// slot n now available - create nop sequence with skip count
				if ( cache.input_order[i].length == DYN_FIELD_LENGTH ) {
					sequence[n].id = dyn_skip;
					sequence[n].skip_count = 0;
				} else {
					sequence[n].id = nop;
					sequence[n].skip_count = cache.input_order[i].length;
				}
				sequence[n].type = SKIP_ELEMENT;
				sequence[n].input_length = 0;
				sequence[n].stack = NULL;
				table->number_of_sequences++;
				dbg_printf("Insert skip sequence in slot: %u, skip count: %u, dyn: %u\n",
					n, sequence[n].skip_count, cache.input_order[i].length == DYN_FIELD_LENGTH ? 1 : 0);
			} else {
				sequence[n-1].skip_count += cache.input_order[i].length;
				dbg_printf("Merge skip count: %u into previous sequence: %u\n", cache.input_order[i].length, n-1);
				continue;
			}
		} else {
			// reorder input element if needed
			if ( sequence[n].type != cache.input_order[i].type ) {
				sequence_map_t _s;
				int j = n+1;

				while ( sequence[j].type != cache.input_order[i].type && j < table->number_of_sequences )
					j++;

				// must never happen!
				if ( j == table->number_of_sequences ) {
					// skip this field
					if ( n == 0 ) {
						// XXX fix this
						return 0;
					} else {
						sequence[n-1].skip_count += cache.input_order[i].length;
						dbg_printf("Merge skip count: %u into previous sequence: %u\n", cache.input_order[i].length, n-1);
						continue;
					}
					return 0;
				}
				// swap slots
				_s = sequence[n];
				sequence[n] = sequence[j];
				sequence[j] = _s;
				dbg_printf("Swap slots %u <-> %u\n", n, j);
			} else {
				dbg_printf("In order slot %u\n", n);
			}
		}
		// advance sequence slot
		n++;
	}

#ifdef DEVEL
	printf("\nReordered Sequencer. Sequence steps: %u\n", table->number_of_sequences);
	for ( int i=0; i<table->number_of_sequences; i++ ) {
		printf("Order: %i, Sequence: %u, Type: %u, Input length: %u, Output offset: %u, Skip Count: %u\n",
			i, sequence[i].id, sequence[i].type, sequence[i].input_length,
			sequence[i].output_offset, sequence[i].skip_count);
	}
	printf("\n");
#endif

	return 1;

} // End of reorder_sequencer


ex_disassemble(exarg_T *eap)
{
    char_u	*arg = eap->arg;
    char_u	*fname;
    ufunc_T	*ufunc;
    dfunc_T	*dfunc;
    isn_T	*instr;
    int		instr_count;
    int		is_global = FALSE;
    compiletype_T compile_type = CT_NONE;

    if (STRNCMP(arg, "profile", 7) == 0 && VIM_ISWHITE(arg[7]))
    {
	compile_type = CT_PROFILE;
	arg = skipwhite(arg + 7);
    }
    else if (STRNCMP(arg, "debug", 5) == 0 && VIM_ISWHITE(arg[5]))
    {
	compile_type = CT_DEBUG;
	arg = skipwhite(arg + 5);
    }

    if (STRNCMP(arg, "<lambda>", 8) == 0)
    {
	arg += 8;
	(void)getdigits(&arg);
	fname = vim_strnsave(eap->arg, arg - eap->arg);
    }
    else
	fname = trans_function_name(&arg, &is_global, FALSE,
		      TFN_INT | TFN_QUIET | TFN_NO_AUTOLOAD, NULL, NULL, NULL);
    if (fname == NULL)
    {
	semsg(_(e_invarg2), eap->arg);
	return;
    }

    ufunc = find_func(fname, is_global, NULL);
    if (ufunc == NULL)
    {
	char_u *p = untrans_function_name(fname);

	if (p != NULL)
	    // Try again without making it script-local.
	    ufunc = find_func(p, FALSE, NULL);
    }
    vim_free(fname);
    if (ufunc == NULL)
    {
	semsg(_(e_cannot_find_function_str), eap->arg);
	return;
    }
    if (func_needs_compiling(ufunc, compile_type)
	    && compile_def_function(ufunc, FALSE, compile_type, NULL) == FAIL)
	return;
    if (ufunc->uf_def_status != UF_COMPILED)
    {
	semsg(_(e_function_is_not_compiled_str), eap->arg);
	return;
    }
    msg((char *)printable_func_name(ufunc));

    dfunc = ((dfunc_T *)def_functions.ga_data) + ufunc->uf_dfunc_idx;
    switch (compile_type)
    {
	case CT_PROFILE:
#ifdef FEAT_PROFILE
	    instr = dfunc->df_instr_prof;
	    instr_count = dfunc->df_instr_prof_count;
	    break;
#endif
	    // FALLTHROUGH
	case CT_NONE:
	    instr = dfunc->df_instr;
	    instr_count = dfunc->df_instr_count;
	    break;
	case CT_DEBUG:
	    instr = dfunc->df_instr_debug;
	    instr_count = dfunc->df_instr_debug_count;
	    break;
    }

    list_instructions("", instr, instr_count, ufunc);
}


Browser::Browser(Type type, Profile* profile)
    : type_(type),
      profile_(profile),
      window_(NULL),
      ALLOW_THIS_IN_INITIALIZER_LIST(
          tab_handler_(TabHandler::CreateTabHandler(this))),
      command_updater_(this),
      toolbar_model_(this),
      chrome_updater_factory_(this),
      is_attempting_to_close_browser_(false),
      cancel_download_confirmation_state_(NOT_PROMPTED),
      maximized_state_(MAXIMIZED_STATE_DEFAULT),
      method_factory_(this),
      block_command_execution_(false),
      last_blocked_command_id_(-1),
      last_blocked_command_disposition_(CURRENT_TAB),
      pending_web_app_action_(NONE) {
  registrar_.Add(this, NotificationType::SSL_VISIBLE_STATE_CHANGED,
                 NotificationService::AllSources());
  registrar_.Add(this, NotificationType::EXTENSION_UPDATE_DISABLED,
                 NotificationService::AllSources());
  registrar_.Add(this, NotificationType::EXTENSION_LOADED,
                 NotificationService::AllSources());
  registrar_.Add(this, NotificationType::EXTENSION_UNLOADED,
                 NotificationService::AllSources());
  registrar_.Add(this, NotificationType::EXTENSION_PROCESS_TERMINATED,
                 NotificationService::AllSources());
  registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED,
                 NotificationService::AllSources());
  registrar_.Add(this, NotificationType::PROFILE_ERROR,
                 NotificationService::AllSources());

  registrar_.Add(this, NotificationType::EXTENSION_READY_FOR_INSTALL,
                 NotificationService::AllSources());

  PrefService* local_state = g_browser_process->local_state();
  if (local_state)
    printing_enabled_.Init(prefs::kPrintingEnabled, local_state, this);
  dev_tools_disabled_.Init(prefs::kDevToolsDisabled,
                           profile_->GetPrefs(), this);

  InitCommandState();
  BrowserList::AddBrowser(this);

  encoding_auto_detect_.Init(prefs::kWebKitUsesUniversalDetector,
                             profile_->GetPrefs(), NULL);
  use_vertical_tabs_.Init(prefs::kUseVerticalTabs, profile_->GetPrefs(), this);
  instant_enabled_.Init(prefs::kInstantEnabled, profile_->GetPrefs(), this);
  if (!TabMenuModel::AreVerticalTabsEnabled()) {
    use_vertical_tabs_.SetValue(false);
  }
  UpdateTabStripModelInsertionPolicy();

  tab_restore_service_ = profile->GetTabRestoreService();
  if (tab_restore_service_) {
    tab_restore_service_->AddObserver(this);
    TabRestoreServiceChanged(tab_restore_service_);
  }

  if (profile_->GetProfileSyncService())
    profile_->GetProfileSyncService()->AddObserver(this);

  CreateInstantIfNecessary();
}


static const struct arm_pmu *__init armv7_a8_pmu_init(void)
{
	return NULL;
}


fru_area_print_product(struct ipmi_intf * intf, struct fru_info * fru,
				uint8_t id, uint32_t offset)
{
	char * fru_area;
	uint8_t * fru_data;
	uint32_t fru_len, i;
	uint8_t tmp[2];

	fru_len = 0;

	/* read enough to check length field */
	if (read_fru_area(intf, fru, id, offset, 2, tmp) == 0) {
		fru_len = 8 * tmp[1];
	}

	if (fru_len == 0) {
		return;
	}

	fru_data = malloc(fru_len);
	if (!fru_data) {
		lprintf(LOG_ERR, "ipmitool: malloc failure");
		return;
	}

	memset(fru_data, 0, fru_len);

	/* read in the full fru */
	if (read_fru_area(intf, fru, id, offset, fru_len, fru_data) < 0) {
		free_n(&fru_data);
		return;
	}

	/*
	 * skip first three bytes which specify
	 * fru area version, fru area length
	 * and fru board language
	 */
	i = 3;

	fru_area = get_fru_area_str(fru_data, &i);
	if (fru_area) {
		if (strlen(fru_area) > 0) {
			printf(" Product Manufacturer  : %s\n", fru_area);
		}
		free_n(&fru_area);
	}

	fru_area = get_fru_area_str(fru_data, &i);
	if (fru_area) {
		if (strlen(fru_area) > 0) {
			printf(" Product Name          : %s\n", fru_area);
		}
		free_n(&fru_area);
	}

	fru_area = get_fru_area_str(fru_data, &i);
	if (fru_area) {
		if (strlen(fru_area) > 0) {
			printf(" Product Part Number   : %s\n", fru_area);
		}
		free_n(&fru_area);
	}

	fru_area = get_fru_area_str(fru_data, &i);
	if (fru_area) {
		if (strlen(fru_area) > 0) {
			printf(" Product Version       : %s\n", fru_area);
		}
		free_n(&fru_area);
	}

	fru_area = get_fru_area_str(fru_data, &i);
	if (fru_area) {
		if (strlen(fru_area) > 0) {
			printf(" Product Serial        : %s\n", fru_area);
		}
		free_n(&fru_area);
	}

	fru_area = get_fru_area_str(fru_data, &i);
	if (fru_area) {
		if (strlen(fru_area) > 0) {
			printf(" Product Asset Tag     : %s\n", fru_area);
		}
		free_n(&fru_area);
	}

	fru_area = get_fru_area_str(fru_data, &i);
	if (fru_area) {
		if (strlen(fru_area) > 0 && verbose > 0) {
			printf(" Product FRU ID        : %s\n", fru_area);
		}
		free_n(&fru_area);
	}

	/* read any extra fields */
	while ((i < fru_len) && (fru_data[i] != FRU_END_OF_FIELDS)) {
		int j = i;
		fru_area = get_fru_area_str(fru_data, &i);
		if (fru_area) {
			if (strlen(fru_area) > 0) {
				printf(" Product Extra         : %s\n", fru_area);
			}
			free_n(&fru_area);
		}
		if (i == j)
			break;
	}

	free_n(&fru_data);
}


find_script_callback(char_u *fname, void *cookie)
{
    int sid;
    int error = OK;
    int *ret_sid = cookie;

    sid = find_script_by_name(fname);
    if (sid < 0)
	// script does not exist yet, create a new scriptitem
	sid = get_new_scriptitem_for_fname(&error, fname);
    *ret_sid = sid;
}


      static double mp_Joff(_cimg_math_parser& mp) {
        double *ptrd = &_mp_arg(1) + 1;
        const unsigned int
          boundary_conditions = (unsigned int)_mp_arg(3),
          vsiz = (unsigned int)mp.opcode[4];
        const CImg<T> &img = mp.imgin;
        const int
          ox = (int)mp.mem[_cimg_mp_slot_x],
          oy = (int)mp.mem[_cimg_mp_slot_y],
          oz = (int)mp.mem[_cimg_mp_slot_z];
        const longT
          off = img.offset(ox,oy,oz) + (longT)_mp_arg(2),
          whd = (longT)img.width()*img.height()*img.depth();
        const T *ptrs;
        if (off>=0 && off<whd) {
          ptrs = &img[off];
          cimg_for_inC(img,0,vsiz - 1,c) { *(ptrd++) = *ptrs; ptrs+=whd; }
          return cimg::type<double>::nan();
        }
        if (img._data) switch (boundary_conditions) {
          case 3 : { // Mirror
            const longT whd2 = 2*whd, moff = cimg::mod(off,whd2);
            ptrs = &img[moff<whd?moff:whd2 - moff - 1];
            cimg_for_inC(img,0,vsiz - 1,c) { *(ptrd++) = *ptrs; ptrs+=whd; }
            return cimg::type<double>::nan();
          }
          case 2 : // Periodic
            ptrs = &img[cimg::mod(off,whd)];
            cimg_for_inC(img,0,vsiz - 1,c) { *(ptrd++) = *ptrs; ptrs+=whd; }
            return cimg::type<double>::nan();
          case 1 : // Neumann
            ptrs = off<0?&img[0]:&img[whd - 1];
            cimg_for_inC(img,0,vsiz - 1,c) { *(ptrd++) = *ptrs; ptrs+=whd; }
            return cimg::type<double>::nan();
          default : // Dirichlet
            std::memset(ptrd,0,vsiz*sizeof(double));
            return cimg::type<double>::nan();
          }
        std::memset(ptrd,0,vsiz*sizeof(double));
        return cimg::type<double>::nan();


static void ncq_finish(NCQTransferState *ncq_tfs)
{
    /* If we didn't error out, set our finished bit. Errored commands
     * do not get a bit set for the SDB FIS ACT register, nor do they
     * clear the outstanding bit in scr_act (PxSACT). */
    if (!(ncq_tfs->drive->port_regs.scr_err & (1 << ncq_tfs->tag))) {
        ncq_tfs->drive->finished |= (1 << ncq_tfs->tag);
    }

    ahci_write_fis_sdb(ncq_tfs->drive->hba, ncq_tfs);

    DPRINTF(ncq_tfs->drive->port_no, "NCQ transfer tag %d finished\n",
            ncq_tfs->tag);

    block_acct_done(blk_get_stats(ncq_tfs->drive->port.ifs[0].blk),
                    &ncq_tfs->acct);
    qemu_sglist_destroy(&ncq_tfs->sglist);
    ncq_tfs->used = 0;
}


SWFShape_setLineStyle_internal(SWFShape shape, unsigned short width,
                      byte r, byte g, byte b, byte a)
{
	int line;

	if ( shape->isEnded )
		return;

	for ( line=0; line<shape->nLines; ++line )
	{
		if ( SWFLineStyle_equals(shape->lines[line], width, r, g, b, a, 0) )
			break;
	}

	if ( line == shape->nLines )
		line = SWFShape_addLineStyle(shape, width, r, g, b, a);
	else
		++line;

	finishSetLine(shape, line, width);
}


void ImageLoader::setImage(ImageResourceContent* newImage) {
  setImageWithoutConsideringPendingLoadEvent(newImage);

  updatedHasPendingEvent();
}


void RenderView::SyncNavigationState() {
  if (!webview())
    return;

  const WebHistoryItem& item = webview()->mainFrame()->currentHistoryItem();
  if (item.isNull())
    return;

  Send(new ViewHostMsg_UpdateState(
      routing_id_, page_id_, webkit_glue::HistoryItemToString(item)));
}


static PHP_NAMED_FUNCTION(zif_zip_close)
{
	zval * zip;
	zip_rsrc *z_rsrc = NULL;

	if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &zip) == FAILURE) {
		return;
	}

	if ((z_rsrc = (zip_rsrc *)zend_fetch_resource(Z_RES_P(zip), le_zip_dir_name, le_zip_dir)) == NULL) {
		RETURN_FALSE;
	}

	/* really close the zip will break BC :-D */
	zend_list_close(Z_RES_P(zip));
}