static int hls_write_header(AVFormatContext *s)

{

    HLSContext *hls = s->priv_data;

    int ret, i;

    char *p;

    const char *pattern = "%d.ts";

    const char *pattern_localtime_fmt = "-%s.ts";

    const char *vtt_pattern = "%d.vtt";

    AVDictionary *options = NULL;

    int basename_size;

    int vtt_basename_size;

    hls->sequence       = hls->start_sequence;

    hls->recording_time = (hls->init_time ? hls->init_time : hls->time) * AV_TIME_BASE;

    hls->start_pts      = AV_NOPTS_VALUE;

    if (hls->flags & HLS_PROGRAM_DATE_TIME) {

        time_t now0;

        time(&now0);

        hls->initial_prog_date_time = now0;

    }

    if (hls->format_options_str) {

        ret = av_dict_parse_string(&hls->format_options, hls->format_options_str, "=", ":", 0);

        if (ret < 0) {

            av_log(s, AV_LOG_ERROR, "Could not parse format options list '%s'\n", hls->format_options_str);

            goto fail;

        }

    }

    for (i = 0; i < s->nb_streams; i++) {

        hls->has_video +=

            s->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO;

        hls->has_subtitle +=

            s->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE;

    }

    if (hls->has_video > 1)

        av_log(s, AV_LOG_WARNING,

               "More than a single video stream present, "

               "expect issues decoding it.\n");

    hls->oformat = av_guess_format("mpegts", NULL, NULL);

    if (!hls->oformat) {

        ret = AVERROR_MUXER_NOT_FOUND;

        goto fail;

    }

    if(hls->has_subtitle) {

        hls->vtt_oformat = av_guess_format("webvtt", NULL, NULL);

        if (!hls->oformat) {

            ret = AVERROR_MUXER_NOT_FOUND;

            goto fail;

        }

    }

    if (hls->segment_filename) {

        hls->basename = av_strdup(hls->segment_filename);

        if (!hls->basename) {

            ret = AVERROR(ENOMEM);

            goto fail;

        }

    } else {

        if (hls->flags & HLS_SINGLE_FILE)

            pattern = ".ts";

        if (hls->use_localtime) {

            basename_size = strlen(s->filename) + strlen(pattern_localtime_fmt) + 1;

        } else {

            basename_size = strlen(s->filename) + strlen(pattern) + 1;

        }

        hls->basename = av_malloc(basename_size);

        if (!hls->basename) {

            ret = AVERROR(ENOMEM);

            goto fail;

        }

        av_strlcpy(hls->basename, s->filename, basename_size);

        p = strrchr(hls->basename, '.');

        if (p)

            *p = '\0';

        if (hls->use_localtime) {

            av_strlcat(hls->basename, pattern_localtime_fmt, basename_size);

        } else {

            av_strlcat(hls->basename, pattern, basename_size);

        }

    }

    if (!hls->use_localtime && (hls->flags & HLS_SECOND_LEVEL_SEGMENT_INDEX)) {

        av_log(hls, AV_LOG_ERROR, "second_level_segment_index hls_flag requires use_localtime to be true\n");

        ret = AVERROR(EINVAL);

        goto fail;

    }

    if(hls->has_subtitle) {

        if (hls->flags & HLS_SINGLE_FILE)

            vtt_pattern = ".vtt";

        vtt_basename_size = strlen(s->filename) + strlen(vtt_pattern) + 1;

        hls->vtt_basename = av_malloc(vtt_basename_size);

        if (!hls->vtt_basename) {

            ret = AVERROR(ENOMEM);

            goto fail;

        }

        hls->vtt_m3u8_name = av_malloc(vtt_basename_size);

        if (!hls->vtt_m3u8_name ) {

            ret = AVERROR(ENOMEM);

            goto fail;

        }

        av_strlcpy(hls->vtt_basename, s->filename, vtt_basename_size);

        p = strrchr(hls->vtt_basename, '.');

        if (p)

            *p = '\0';

        if( hls->subtitle_filename ) {

            strcpy(hls->vtt_m3u8_name, hls->subtitle_filename);

        } else {

            strcpy(hls->vtt_m3u8_name, hls->vtt_basename);

            av_strlcat(hls->vtt_m3u8_name, "_vtt.m3u8", vtt_basename_size);

        }

        av_strlcat(hls->vtt_basename, vtt_pattern, vtt_basename_size);

    }

    if ((ret = hls_mux_init(s)) < 0)

        goto fail;

    if (hls->flags & HLS_APPEND_LIST) {

        parse_playlist(s, s->filename);

        hls->discontinuity = 1;

        if (hls->init_time > 0) {

            av_log(s, AV_LOG_WARNING, "append_list mode does not support hls_init_time,"

                   " hls_init_time value will have no effect\n");

            hls->init_time = 0;

            hls->recording_time = hls->time * AV_TIME_BASE;

        }

    }

    if ((ret = hls_start(s)) < 0)

        goto fail;

    av_dict_copy(&options, hls->format_options, 0);

    ret = avformat_write_header(hls->avf, &options);

    if (av_dict_count(options)) {

        av_log(s, AV_LOG_ERROR, "Some of provided format options in '%s' are not recognized\n", hls->format_options_str);

        ret = AVERROR(EINVAL);

        goto fail;

    }

    //av_assert0(s->nb_streams == hls->avf->nb_streams);

    for (i = 0; i < s->nb_streams; i++) {

        AVStream *inner_st;

        AVStream *outer_st = s->streams[i];

        if (hls->max_seg_size > 0) {

            if ((outer_st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) &&

                (outer_st->codecpar->bit_rate > hls->max_seg_size)) {

                av_log(s, AV_LOG_WARNING, "Your video bitrate is bigger than hls_segment_size, "

                       "(%"PRId64 " > %"PRId64 "), the result maybe not be what you want.",

                       outer_st->codecpar->bit_rate, hls->max_seg_size);

            }

        }

        if (outer_st->codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE)

            inner_st = hls->avf->streams[i];

        else if (hls->vtt_avf)

            inner_st = hls->vtt_avf->streams[0];

        else {

            /* We have a subtitle stream, when the user does not want one */

            inner_st = NULL;

            continue;

        }

        avpriv_set_pts_info(outer_st, inner_st->pts_wrap_bits, inner_st->time_base.num, inner_st->time_base.den);

    }

fail:

    av_dict_free(&options);

    if (ret < 0) {

        av_freep(&hls->basename);

        av_freep(&hls->vtt_basename);

        if (hls->avf)

            avformat_free_context(hls->avf);

        if (hls->vtt_avf)

            avformat_free_context(hls->vtt_avf);

    }

    return ret;

}


bool ProfilingProcessHost::OnMemoryDump(
    const base::trace_event::MemoryDumpArgs& args,
    base::trace_event::ProcessMemoryDump* pmd) {
  profiling_service_->DumpProcessesForTracing(
      base::BindOnce(&ProfilingProcessHost::OnDumpProcessesForTracingCallback,
                     base::Unretained(this), args.dump_guid));
  return true;
}


static int hns_nic_try_get_ae(struct net_device *ndev)
{
	struct hns_nic_priv *priv = netdev_priv(ndev);
	struct hnae_handle *h;
	int ret;

	h = hnae_get_handle(&priv->netdev->dev,
			    priv->fwnode, priv->port_id, NULL);
	if (IS_ERR_OR_NULL(h)) {
		ret = -ENODEV;
		dev_dbg(priv->dev, "has not handle, register notifier!\n");
		goto out;
	}
	priv->ae_handle = h;

	ret = hns_nic_init_phy(ndev, h);
	if (ret) {
		dev_err(priv->dev, "probe phy device fail!\n");
		goto out_init_phy;
	}

	ret = hns_nic_init_ring_data(priv);
	if (ret) {
		ret = -ENOMEM;
		goto out_init_ring_data;
	}

	hns_nic_set_priv_ops(ndev);

	ret = register_netdev(ndev);
	if (ret) {
		dev_err(priv->dev, "probe register netdev fail!\n");
		goto out_reg_ndev_fail;
	}
	return 0;

out_reg_ndev_fail:
	hns_nic_uninit_ring_data(priv);
	priv->ring_data = NULL;
out_init_phy:
out_init_ring_data:
	hnae_put_handle(priv->ae_handle);
	priv->ae_handle = NULL;
out:
	return ret;
}


int ConnectionImpl::onData(int32_t stream_id, const uint8_t* data, size_t len) {
  StreamImpl* stream = getStream(stream_id);
  // If this results in buffering too much data, the watermark buffer will call
  // pendingRecvBufferHighWatermark, resulting in ++read_disable_count_
  stream->pending_recv_data_.add(data, len);
  // Update the window to the peer unless some consumer of this stream's data has hit a flow control
  // limit and disabled reads on this stream
  if (!stream->buffers_overrun()) {
    nghttp2_session_consume(session_, stream_id, len);
  } else {
    stream->unconsumed_bytes_ += len;
  }
  return 0;
}


int jsi_PstateSetFile(jsi_Pstate *ps, Jsi_Channel fp, int skipbang)
{
    jsi_Lexer *l = ps->lexer;
    jsi_PstateClear(ps);
    l->ltype = LT_FILE;
    l->d.fp = fp;
    Jsi_Rewind(ps->interp, fp);
    if (skipbang) {
        char buf[1000];
        if (Jsi_Gets(ps->interp, fp, buf, 1000) && (buf[0] != '#' || buf[1] != '!')) {
            Jsi_Rewind(ps->interp, fp);
        }
    }

    return JSI_OK;
}


static inline void *id_to_ptr(__u64 nid)
{
 return (void *) (uintptr_t) nid;
}


static void floor_fit(venc_context_t * venc, floor_t * fc, float * coeffs, int * posts, int samples) {

    int range = 255 / fc->multiplier + 1;

    int i;

    for (i = 0; i < fc->values; i++) {

        int position = fc->list[fc->list[i].sort].x;

        int begin = fc->list[fc->list[FFMAX(i-1, 0)].sort].x;

        int end   = fc->list[fc->list[FFMIN(i+1, fc->values - 1)].sort].x;

        int j;

        float average = 0;

        begin = (position + begin) / 2;

        end   = (position + end  ) / 2;

        assert(end <= samples);

        for (j = begin; j < end; j++) average += fabs(coeffs[j]);

        average /= end - begin;

        average /= 32; // MAGIC!

        for (j = 0; j < range; j++) if (floor1_inverse_db_table[j * fc->multiplier] > average) break;

        posts[fc->list[i].sort] = j;

    }

}


 bool WebPageProxy::gestureWillBegin(const IntPoint& point)
 {
    bool canBeginPanning = false;
     process()->sendSync(Messages::WebPage::GestureWillBegin(point), Messages::WebPage::GestureWillBegin::Reply(canBeginPanning), m_pageID);
     return canBeginPanning;
 }


static void computeOverlayOffset(ut64 offset, ut64 size, ut64 file_size, ut64* largest_offset, ut64* largest_size) {
	if (offset + size <= file_size && offset + size > (*largest_offset + *largest_size)) {
		*largest_offset = offset;
		*largest_size = size;
	}
}


static aClient *decode_puid(char *puid)
{
	aClient *cptr;
	char *it, *it2;
	int cookie = 0;

	if ((it = strrchr(puid, '!')) == NULL)
		return NULL;

	*it++ = '\0';

	if ((it2 = strrchr(it, '.')) != NULL)
	{
		*it2++ = '\0';
		cookie = atoi(it2);
	}

	if (stricmp(me.name, puid))
		return NULL;

	list_for_each_entry(cptr, &unknown_list, lclient_node)
		if (cptr->local->sasl_cookie == cookie)
			return cptr;

	return NULL;
}


std::string BaseNode::GetTitle() const {
  std::string result;
  if (syncable::BOOKMARKS == GetModelType() &&
      GetEntry()->Get(syncable::SPECIFICS).has_encrypted()) {
    ServerNameToSyncAPIName(GetBookmarkSpecifics().title(), &result);
  } else {
    ServerNameToSyncAPIName(GetEntry()->Get(syncable::NON_UNIQUE_NAME),
                            &result);
  }
  return result;
}


omx_video::~omx_video()
{
    DEBUG_PRINT_HIGH("~omx_video(): Inside Destructor()");
 if (m_pipe_in >= 0) close(m_pipe_in);
 if (m_pipe_out >= 0) close(m_pipe_out);
    DEBUG_PRINT_HIGH("omx_video: Waiting on Msg Thread exit");
 if (msg_thread_created)
        pthread_join(msg_thread_id,NULL);
    DEBUG_PRINT_HIGH("omx_video: Waiting on Async Thread exit");
 /*For V4L2 based drivers, pthread_join is done in device_close
     * so no need to do it here*/
#ifndef _MSM8974_
 if (async_thread_created)
        pthread_join(async_thread_id,NULL);
#endif
    pthread_mutex_destroy(&m_lock);
    sem_destroy(&m_cmd_lock);
    DEBUG_PRINT_HIGH("m_etb_count = %" PRIu64 ", m_fbd_count = %" PRIu64, m_etb_count,
            m_fbd_count);
    DEBUG_PRINT_HIGH("omx_video: Destructor exit");
    DEBUG_PRINT_HIGH("Exiting OMX Video Encoder ...");
}


CMS_RecipientInfo *CMS_add1_recipient_cert(CMS_ContentInfo *cms,
                                           X509 *recip, unsigned int flags)
{
    CMS_RecipientInfo *ri = NULL;
    CMS_EnvelopedData *env;
    EVP_PKEY *pk = NULL;
    env = cms_get0_enveloped(cms);
    if (!env)
        goto err;

    /* Initialize recipient info */
    ri = M_ASN1_new_of(CMS_RecipientInfo);
    if (!ri)
        goto merr;

    pk = X509_get0_pubkey(recip);
    if (!pk) {
        CMSerr(CMS_F_CMS_ADD1_RECIPIENT_CERT, CMS_R_ERROR_GETTING_PUBLIC_KEY);
        goto err;
    }

    switch (cms_pkey_get_ri_type(pk)) {

    case CMS_RECIPINFO_TRANS:
        if (!cms_RecipientInfo_ktri_init(ri, recip, pk, flags))
            goto err;
        break;

    case CMS_RECIPINFO_AGREE:
        if (!cms_RecipientInfo_kari_init(ri, recip, pk, flags))
            goto err;
        break;

    default:
        CMSerr(CMS_F_CMS_ADD1_RECIPIENT_CERT,
               CMS_R_NOT_SUPPORTED_FOR_THIS_KEY_TYPE);
        goto err;

    }

    if (!sk_CMS_RecipientInfo_push(env->recipientInfos, ri))
        goto merr;

    return ri;

 merr:
    CMSerr(CMS_F_CMS_ADD1_RECIPIENT_CERT, ERR_R_MALLOC_FAILURE);
 err:
    M_ASN1_free_of(ri, CMS_RecipientInfo);
    return NULL;

}


int BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
                    const BIGNUM *p, BN_CTX *ctx)
{
    int ret = 0;
    const int max = BN_num_bits(p) + 1;
    int *arr = NULL;
    bn_check_top(a);
    bn_check_top(b);
    bn_check_top(p);
    if ((arr = OPENSSL_malloc(sizeof(*arr) * max)) == NULL)
        goto err;
    ret = BN_GF2m_poly2arr(p, arr, max);
    if (!ret || ret > max) {
        BNerr(BN_F_BN_GF2M_MOD_MUL, BN_R_INVALID_LENGTH);
        goto err;
    }
    ret = BN_GF2m_mod_mul_arr(r, a, b, arr, ctx);
    bn_check_top(r);
 err:
    OPENSSL_free(arr);
    return ret;
}


static int nntp_path_canon(char *buf, size_t buflen)
{
  if (!buf)
    return -1;

  return 0;
}


static void withActiveWindowAndFirstWindowMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
    TestObjectV8Internal::withActiveWindowAndFirstWindowMethod(info);
    TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
}


	BlockTransformation* NewEncryption(const byte *keyStr) const
		{return new E(keyStr, m_keylen);}


ves_icall_System_Threading_Thread_VolatileRead8 (void *ptr)
{
	return *((volatile gint64 *) (ptr));
}


static int do_move_page_to_node_array(struct mm_struct *mm,
				      struct page_to_node *pm,
				      int migrate_all)
{
	int err;
	struct page_to_node *pp;
	LIST_HEAD(pagelist);

	down_read(&mm->mmap_sem);

	/*
	 * Build a list of pages to migrate
	 */
	for (pp = pm; pp->node != MAX_NUMNODES; pp++) {
		struct vm_area_struct *vma;
		struct page *page;

		err = -EFAULT;
		vma = find_vma(mm, pp->addr);
		if (!vma || pp->addr < vma->vm_start || !vma_migratable(vma))
			goto set_status;

		/* FOLL_DUMP to ignore special (like zero) pages */
		page = follow_page(vma, pp->addr,
				FOLL_GET | FOLL_SPLIT | FOLL_DUMP);

		err = PTR_ERR(page);
		if (IS_ERR(page))
			goto set_status;

		err = -ENOENT;
		if (!page)
			goto set_status;

		pp->page = page;
		err = page_to_nid(page);

		if (err == pp->node)
			/*
			 * Node already in the right place
			 */
			goto put_and_set;

		err = -EACCES;
		if (page_mapcount(page) > 1 &&
				!migrate_all)
			goto put_and_set;

		if (PageHuge(page)) {
			if (PageHead(page))
				isolate_huge_page(page, &pagelist);
			goto put_and_set;
		}

		err = isolate_lru_page(page);
		if (!err) {
			list_add_tail(&page->lru, &pagelist);
			inc_zone_page_state(page, NR_ISOLATED_ANON +
					    page_is_file_cache(page));
		}
put_and_set:
		/*
		 * Either remove the duplicate refcount from
		 * isolate_lru_page() or drop the page ref if it was
		 * not isolated.
		 */
		put_page(page);
set_status:
		pp->status = err;
	}

	err = 0;
	if (!list_empty(&pagelist)) {
		err = migrate_pages(&pagelist, new_page_node, NULL,
				(unsigned long)pm, MIGRATE_SYNC, MR_SYSCALL);
		if (err)
			putback_movable_pages(&pagelist);
	}

	up_read(&mm->mmap_sem);
	return err;
}


static int add_push_report_sideband_pkt(git_push *push, git_pkt_data *data_pkt, git_buf *data_pkt_buf)
{
	git_pkt *pkt;
	const char *line, *line_end = NULL;
	size_t line_len;
	int error;
	int reading_from_buf = data_pkt_buf->size > 0;

	if (reading_from_buf) {
		/* We had an existing partial packet, so add the new
		 * packet to the buffer and parse the whole thing */
		git_buf_put(data_pkt_buf, data_pkt->data, data_pkt->len);
		line = data_pkt_buf->ptr;
		line_len = data_pkt_buf->size;
	}
	else {
		line = data_pkt->data;
		line_len = data_pkt->len;
	}

	while (line_len > 0) {
		error = git_pkt_parse_line(&pkt, line, &line_end, line_len);

		if (error == GIT_EBUFS) {
			/* Buffer the data when the inner packet is split
			 * across multiple sideband packets */
			if (!reading_from_buf)
				git_buf_put(data_pkt_buf, line, line_len);
			error = 0;
			goto done;
		}
		else if (error < 0)
			goto done;

		/* Advance in the buffer */
		line_len -= (line_end - line);
		line = line_end;

		/* When a valid packet with no content has been
		 * read, git_pkt_parse_line does not report an
		 * error, but the pkt pointer has not been set.
		 * Handle this by skipping over empty packets.
		 */
		if (pkt == NULL)
			continue;

		error = add_push_report_pkt(push, pkt);

		git_pkt_free(pkt);

		if (error < 0 && error != GIT_ITEROVER)
			goto done;
	}

	error = 0;

done:
	if (reading_from_buf)
		git_buf_consume(data_pkt_buf, line_end);
	return error;
}


    inline double _fibonacci(int exp) {
      double
        base = (1 + std::sqrt(5.))/2,
        result = 1/std::sqrt(5.);
      while (exp) {
        if (exp&1) result*=base;
        exp>>=1;
        base*=base;
      }
      return result;


OPJ_BOOL opj_tcd_init( opj_tcd_t *p_tcd,
                                           opj_image_t * p_image,
                                           opj_cp_t * p_cp )
{
        p_tcd->image = p_image;
        p_tcd->cp = p_cp;

        p_tcd->tcd_image->tiles = (opj_tcd_tile_t *) opj_calloc(1,sizeof(opj_tcd_tile_t));
        if (! p_tcd->tcd_image->tiles) {
                return OPJ_FALSE;
        }

        p_tcd->tcd_image->tiles->comps = (opj_tcd_tilecomp_t *) opj_calloc(p_image->numcomps,sizeof(opj_tcd_tilecomp_t));
        if (! p_tcd->tcd_image->tiles->comps ) {
                return OPJ_FALSE;
        }

        p_tcd->tcd_image->tiles->numcomps = p_image->numcomps;
        p_tcd->tp_pos = p_cp->m_specific_param.m_enc.m_tp_pos;

        return OPJ_TRUE;
}


static void async_set_reg_cb(struct urb *urb)
{
	struct async_req *req = (struct async_req *)urb->context;
	int status = urb->status;

	if (status < 0)
		dev_dbg(&urb->dev->dev, "%s failed with %d", __func__, status);
	kfree(req);
	usb_free_urb(urb);
}


static struct sk_buff *hns_assemble_skb(struct net_device *ndev)
{
	struct sk_buff *skb;
	struct ethhdr *ethhdr;
	int frame_len;

	/* allocate test skb */
	skb = alloc_skb(64, GFP_KERNEL);
	if (!skb)
		return NULL;

	skb_put(skb, 64);
	skb->dev = ndev;
	memset(skb->data, 0xFF, skb->len);

	/* must be tcp/ip package */
	ethhdr = (struct ethhdr *)skb->data;
	ethhdr->h_proto = htons(ETH_P_IP);

	frame_len = skb->len & (~1ul);
	memset(&skb->data[frame_len / 2], 0xAA,
	       frame_len / 2 - 1);

	skb->queue_mapping = HNS_LB_TX_RING;

	return skb;
}


StyleSheet* HTMLLinkElement::sheet() const
{
    return m_sheet.get();
}


static inline void switch_fpu_finish(struct task_struct *new, fpu_switch_t fpu)
{
	if (fpu.preload) {
		if (unlikely(restore_fpu_checking(new)))
			drop_init_fpu(new);
	}
}


static void delete_case6(Jsi_TreeEntry* n) {
    Jsi_TreeEntry* s = sibling(n);
    set_color(s, node_color(n->parent));
    set_color(n->parent, _JSI_TREE_BLACK);
    if (n == n->parent->left) {
        Assert (node_color(s->right) == _JSI_TREE_RED);
        set_color(s->right, _JSI_TREE_BLACK);
        rotate_left(n->parent);
    }
    else
    {
        //Assert (node_color(s->left) == _JSI_TREE_RED);
        set_color(s->left, _JSI_TREE_BLACK);
        rotate_right(n->parent);
    }
}


static inline void hidg_put_minor(int minor)
{
	ida_simple_remove(&hidg_ida, minor);
}


void FilterManager::setBufferLimit(uint32_t new_limit) {
  ENVOY_STREAM_LOG(debug, "setting buffer limit to {}", *this, new_limit);
  buffer_limit_ = new_limit;
  if (buffered_request_data_) {
    buffered_request_data_->setWatermarks(buffer_limit_);
  }
  if (buffered_response_data_) {
    buffered_response_data_->setWatermarks(buffer_limit_);
  }
}


bool MainWindow::isSourceClipMyProject(QString resource)
{
    if (m_player->tabIndex() == Player::ProjectTabIndex && MLT.savedProducer() && MLT.savedProducer()->is_valid())
        resource = QString::fromUtf8(MLT.savedProducer()->get("resource"));
    if (!resource.isEmpty() && QDir(resource) == QDir(fileName())) {
        QMessageBox dialog(QMessageBox::Information,
                           qApp->applicationName(),
                           tr("You cannot add a project to itself!"),
                           QMessageBox::Ok,
                           this);
        dialog.setDefaultButton(QMessageBox::Ok);
        dialog.setEscapeButton(QMessageBox::Ok);
        dialog.setWindowModality(QmlApplication::dialogModality());
        dialog.exec();
        return true;
    }
    return false;
}


void WallpaperManagerBase::OnPolicyCleared(const std::string& policy,
                                           const AccountId& account_id) {
  WallpaperInfo info;
  GetUserWallpaperInfo(account_id, &info);
  info.type = DEFAULT;
  SetUserWallpaperInfo(account_id, info, true /* is_persistent */);

  if (user_manager::UserManager::Get()->IsUserLoggedIn())
    SetDefaultWallpaperNow(account_id);
}


static guint32 dissect_netb_name_resp ( tvbuff_t * tvb , packet_info * pinfo _U_ , int offset , proto_tree * tree ) {
 guint8 local_session_number = tvb_get_guint8 ( tvb , offset + NB_DATA2 ) ;
 switch ( local_session_number ) {
 case 0x00 : proto_tree_add_uint_format_value ( tree , hf_netb_state_of_name , tvb , offset + NB_DATA2 , 1 , local_session_number , "No LISTEN pending, or FIND.NAME response" ) ;
 break ;
 case 0xFF : proto_tree_add_uint_format_value ( tree , hf_netb_state_of_name , tvb , offset + NB_DATA2 , 1 , local_session_number , "LISTEN pending, but insufficient resources to establish session" ) ;
 break ;
 default : proto_tree_add_item ( tree , hf_netb_local_session_no , tvb , offset + NB_DATA2 , 1 , ENC_LITTLE_ENDIAN ) ;
 break ;
 }
 nb_call_name_type ( tvb , offset , tree ) ;
 nb_xmit_corrl ( tvb , offset , tree ) ;
 if ( local_session_number != 0x00 && local_session_number != 0xFF ) nb_resp_corrl ( tvb , offset , tree ) ;
 netbios_add_name ( "Receiver's Name" , tvb , offset + NB_RECVER_NAME , tree ) ;
 if ( local_session_number != 0x00 && local_session_number != 0xFF ) {
 netbios_add_name ( "Sender's Name" , tvb , offset + NB_SENDER_NAME , tree ) ;
 }
 return 0 ;
 }


void WebGLRenderingContextBase::ApplyStencilTest() {
  bool have_stencil_buffer = false;

  if (framebuffer_binding_) {
    have_stencil_buffer = framebuffer_binding_->HasStencilBuffer();
  } else {
    base::Optional<WebGLContextAttributes> attributes;
    getContextAttributes(attributes);
    have_stencil_buffer = attributes && attributes->stencil();
  }
  EnableOrDisable(GL_STENCIL_TEST, stencil_enabled_ && have_stencil_buffer);
}


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

  test_object_v8_internal::ReadonlyWindowAttributeAttributeGetter(info);
}


void Browser::ContentsZoomChange(bool zoom_in) {
  ExecuteCommand(zoom_in ? IDC_ZOOM_PLUS : IDC_ZOOM_MINUS);
}


static int dissect_h245_SET_SIZE_1_256_OF_CapabilityTableEntry ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {
 offset = dissect_per_constrained_set_of ( tvb , offset , actx , tree , hf_index , ett_h245_SET_SIZE_1_256_OF_CapabilityTableEntry , SET_SIZE_1_256_OF_CapabilityTableEntry_set_of , 1 , 256 , FALSE ) ;
 return offset ;
 }


static struct tpm_chip *tpm_chip_find_get(int chip_num)
{
	struct tpm_chip *pos, *chip = NULL;

	rcu_read_lock();
	list_for_each_entry_rcu(pos, &tpm_chip_list, list) {
		if (chip_num != TPM_ANY_NUM && chip_num != pos->dev_num)
			continue;

		if (try_module_get(pos->dev->driver->owner)) {
			chip = pos;
			break;
		}
	}
	rcu_read_unlock();
	return chip;
}


tv2string(
    typval_T	*tv,
    char_u	**tofree,
    char_u	*numbuf,
    int		copyID)
{
    return echo_string_core(tv, tofree, numbuf, copyID, FALSE, TRUE, FALSE);
}


static mbedtls_pkcs7* get_pkcs7(const struct efi_variable_authentication_2 *auth)
{
	char *checkpkcs7cert = NULL;
	size_t len;
	mbedtls_pkcs7 *pkcs7 = NULL;
	int rc;

	len = get_pkcs7_len(auth);

	pkcs7 = malloc(sizeof(struct mbedtls_pkcs7));
	if (!pkcs7)
		return NULL;

	mbedtls_pkcs7_init(pkcs7);
	rc = mbedtls_pkcs7_parse_der( auth->auth_info.cert_data, len, pkcs7);
	if (rc <= 0) {
		prlog(PR_ERR, "Parsing pkcs7 failed %04x\n", rc);
		goto out;
	}

	checkpkcs7cert = zalloc(CERT_BUFFER_SIZE);
	if (!checkpkcs7cert)
		goto out;

	rc = mbedtls_x509_crt_info(checkpkcs7cert, CERT_BUFFER_SIZE, "CRT:",
				   &(pkcs7->signed_data.certs));
	if (rc < 0) {
		prlog(PR_ERR, "Failed to parse the certificate in PKCS7 structure\n");
		free(checkpkcs7cert);
		goto out;
	}

	prlog(PR_DEBUG, "%s \n", checkpkcs7cert);
	free(checkpkcs7cert);
	return pkcs7;

out:
	mbedtls_pkcs7_free(pkcs7);
	pkcs7 = NULL;
	return pkcs7;
}


rb_dlhandle_disable_close(VALUE self)
{
  struct dl_handle *dlhandle;

  Data_Get_Struct(self, struct dl_handle, dlhandle);
  dlhandle->enable_close = 0;
  return Qnil;
}


static void virtio_balloon_receive_stats ( VirtIODevice * vdev , VirtQueue * vq ) {
 VirtIOBalloon * s = DO_UPCAST ( VirtIOBalloon , vdev , vdev ) ;
 VirtQueueElement * elem = & s -> stats_vq_elem ;
 VirtIOBalloonStat stat ;
 size_t offset = 0 ;
 if ( ! virtqueue_pop ( vq , elem ) ) {
 return ;
 }
 reset_stats ( s ) ;
 while ( iov_to_buf ( elem -> out_sg , elem -> out_num , offset , & stat , sizeof ( stat ) ) == sizeof ( stat ) ) {
 uint16_t tag = tswap16 ( stat . tag ) ;
 uint64_t val = tswap64 ( stat . val ) ;
 offset += sizeof ( stat ) ;
 if ( tag < VIRTIO_BALLOON_S_NR ) s -> stats [ tag ] = val ;
 }
 s -> stats_vq_offset = offset ;
 }


void ResourceLoader::DidFinishLoading(double finish_time,
                                      int64_t encoded_data_length,
                                      int64_t encoded_body_length,
                                      int64_t decoded_body_length) {
  resource_->SetEncodedDataLength(encoded_data_length);
  resource_->SetEncodedBodyLength(encoded_body_length);
  resource_->SetDecodedBodyLength(decoded_body_length);

  Release(ResourceLoadScheduler::ReleaseOption::kReleaseAndSchedule);
  loader_.reset();

  network_instrumentation::EndResourceLoad(
      resource_->Identifier(),
      network_instrumentation::RequestOutcome::kSuccess);

  fetcher_->HandleLoaderFinish(resource_.Get(), finish_time,
                               ResourceFetcher::kDidFinishLoading);
}


void RenderThreadImpl::WidgetDestroyed() {
  DCHECK_GT(widget_count_, 0);
  DCHECK_GT(widget_count_, hidden_widget_count_);
  widget_count_--;
  if (RendererIsHidden())
    OnRendererHidden();
}


bool GLES2DecoderPassthroughImpl::IsEmulatedQueryTarget(GLenum target) const {
  switch (target) {
    case GL_COMMANDS_COMPLETED_CHROMIUM:
    case GL_READBACK_SHADOW_COPIES_UPDATED_CHROMIUM:
    case GL_COMMANDS_ISSUED_CHROMIUM:
     case GL_LATENCY_QUERY_CHROMIUM:
     case GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM:
     case GL_GET_ERROR_QUERY_CHROMIUM:
    case GL_PROGRAM_COMPLETION_QUERY_CHROMIUM:
       return true;

     default:
       return false;
   }
 }


  void encode(bufferlist& bl) const {
    ::encode(request_type, bl);
  }


NO_INLINE JsVar *jspeStatementReturn() {
  JsVar *result = 0;
  JSP_ASSERT_MATCH(LEX_R_RETURN);
  if (lex->tk != ';' && lex->tk != '}') {
    // we only want the value, so skip the name if there was one
    result = jsvSkipNameAndUnLock(jspeExpression());
  }
  if (JSP_SHOULD_EXECUTE) {
    JsVar *resultVar = jspeiFindInScopes(JSPARSE_RETURN_VAR);
    if (resultVar) {
      jsvReplaceWith(resultVar, result);
      jsvUnLock(resultVar);
      execInfo.execute |= EXEC_RETURN; // Stop anything else in this function executing
    } else {
      jsExceptionHere(JSET_SYNTAXERROR, "RETURN statement, but not in a function.\n");
    }
  }
  jsvUnLock(result);
  return 0;
}


AP4_StszAtom::GetSampleCount()
{
    return m_SampleCount;
}


Response TargetHandler::CreateBrowserContext(std::string* out_context_id) {
  return Response::Error("Not supported");
}


static uint64_t ar_atol8 ( const char * p , unsigned char_cnt ) {
 uint64_t l , limit , last_digit_limit ;
 unsigned int digit , base ;
 base = 8 ;
 limit = UINT64_MAX / base ;
 last_digit_limit = UINT64_MAX % base ;
 while ( ( * p == ' ' || * p == '\t' ) && char_cnt -- > 0 ) p ++ ;
 l = 0 ;
 digit = * p - '0' ;
 while ( * p >= '0' && digit < base && char_cnt -- > 0 ) {
 if ( l > limit || ( l == limit && digit > last_digit_limit ) ) {
 l = UINT64_MAX ;
 break ;
 }
 l = ( l * base ) + digit ;
 digit = * ++ p - '0' ;
 }
 return ( l ) ;
 }


static int get_phys_addr_v6(CPUState *env, uint32_t address, int access_type,

			    int is_user, uint32_t *phys_ptr, int *prot)

{

    int code;

    uint32_t table;

    uint32_t desc;

    uint32_t xn;

    int type;

    int ap;

    int domain;

    uint32_t phys_addr;

    /* Pagetable walk.  */

    /* Lookup l1 descriptor.  */

    table = get_level1_table_address(env, address);

    desc = ldl_phys(table);

    type = (desc & 3);

    if (type == 0) {

        /* Section translation fault.  */

        code = 5;

        domain = 0;

        goto do_fault;

    } else if (type == 2 && (desc & (1 << 18))) {

        /* Supersection.  */

        domain = 0;

    } else {

        /* Section or page.  */

        domain = (desc >> 4) & 0x1e;

    }

    domain = (env->cp15.c3 >> domain) & 3;

    if (domain == 0 || domain == 2) {

        if (type == 2)

            code = 9; /* Section domain fault.  */

        else

            code = 11; /* Page domain fault.  */

        goto do_fault;

    }

    if (type == 2) {

        if (desc & (1 << 18)) {

            /* Supersection.  */

            phys_addr = (desc & 0xff000000) | (address & 0x00ffffff);

        } else {

            /* Section.  */

            phys_addr = (desc & 0xfff00000) | (address & 0x000fffff);

        }

        ap = ((desc >> 10) & 3) | ((desc >> 13) & 4);

        xn = desc & (1 << 4);

        code = 13;

    } else {

        /* Lookup l2 entry.  */

        table = (desc & 0xfffffc00) | ((address >> 10) & 0x3fc);

        desc = ldl_phys(table);

        ap = ((desc >> 4) & 3) | ((desc >> 7) & 4);

        switch (desc & 3) {

        case 0: /* Page translation fault.  */

            code = 7;

            goto do_fault;

        case 1: /* 64k page.  */

            phys_addr = (desc & 0xffff0000) | (address & 0xffff);

            xn = desc & (1 << 15);

            break;

        case 2: case 3: /* 4k page.  */

            phys_addr = (desc & 0xfffff000) | (address & 0xfff);

            xn = desc & 1;

            break;

        default:

            /* Never happens, but compiler isn't smart enough to tell.  */

            abort();

        }

        code = 15;

    }

    if (xn && access_type == 2)

        goto do_fault;

    /* The simplified model uses AP[0] as an access control bit.  */

    if ((env->cp15.c1_sys & (1 << 29)) && (ap & 1) == 0) {

        /* Access flag fault.  */

        code = (code == 15) ? 6 : 3;

        goto do_fault;

    }

    *prot = check_ap(env, ap, domain, access_type, is_user);

    if (!*prot) {

        /* Access permission fault.  */

        goto do_fault;

    }

    *phys_ptr = phys_addr;

    return 0;

do_fault:

    return code | (domain << 4);

}


void webkit_web_view_set_full_content_zoom(WebKitWebView* webView, gboolean zoomFullContent)
{
    g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));

    WebKitWebViewPrivate* priv = webView->priv;
    if (priv->zoomFullContent == zoomFullContent)
      return;

    Frame* frame = core(webView)->mainFrame();
    if (!frame)
      return;

    gfloat zoomLevel = priv->zoomFullContent ? frame->pageZoomFactor() : frame->textZoomFactor();

    priv->zoomFullContent = zoomFullContent;
    if (priv->zoomFullContent)
        frame->setPageAndTextZoomFactors(zoomLevel, 1);
    else
        frame->setPageAndTextZoomFactors(1, zoomLevel);

    g_object_notify(G_OBJECT(webView), "full-content-zoom");
}


static int vfio_initfn(PCIDevice *pdev)

{

    VFIOPCIDevice *vdev = DO_UPCAST(VFIOPCIDevice, pdev, pdev);

    VFIODevice *vbasedev_iter;

    VFIOGroup *group;

    char path[PATH_MAX], iommu_group_path[PATH_MAX], *group_name;

    ssize_t len;

    struct stat st;

    int groupid;

    int ret;

    /* Check that the host device exists */

    snprintf(path, sizeof(path),

             "/sys/bus/pci/devices/%04x:%02x:%02x.%01x/",

             vdev->host.domain, vdev->host.bus, vdev->host.slot,

             vdev->host.function);

    if (stat(path, &st) < 0) {

        error_report("vfio: error: no such host device: %s", path);

        return -errno;

    }

    vdev->vbasedev.ops = &vfio_pci_ops;

    vdev->vbasedev.type = VFIO_DEVICE_TYPE_PCI;

    vdev->vbasedev.name = g_strdup_printf("%04x:%02x:%02x.%01x",

                                          vdev->host.domain, vdev->host.bus,

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

    strncat(path, "iommu_group", sizeof(path) - strlen(path) - 1);

    len = readlink(path, iommu_group_path, sizeof(path));

    if (len <= 0 || len >= sizeof(path)) {

        error_report("vfio: error no iommu_group for device");

        return len < 0 ? -errno : -ENAMETOOLONG;

    }

    iommu_group_path[len] = 0;

    group_name = basename(iommu_group_path);

    if (sscanf(group_name, "%d", &groupid) != 1) {

        error_report("vfio: error reading %s: %m", path);

        return -errno;

    }

    trace_vfio_initfn(vdev->vbasedev.name, groupid);

    group = vfio_get_group(groupid, pci_device_iommu_address_space(pdev));

    if (!group) {

        error_report("vfio: failed to get group %d", groupid);

        return -ENOENT;

    }

    snprintf(path, sizeof(path), "%04x:%02x:%02x.%01x",

            vdev->host.domain, vdev->host.bus, vdev->host.slot,

            vdev->host.function);

    QLIST_FOREACH(vbasedev_iter, &group->device_list, next) {

        if (strcmp(vbasedev_iter->name, vdev->vbasedev.name) == 0) {

            error_report("vfio: error: device %s is already attached", path);

            vfio_put_group(group);

            return -EBUSY;

        }

    }

    ret = vfio_get_device(group, path, &vdev->vbasedev);

    if (ret) {

        error_report("vfio: failed to get device %s", path);

        vfio_put_group(group);

        return ret;

    }

    ret = vfio_populate_device(vdev);

    if (ret) {

        return ret;

    }

    /* Get a copy of config space */

    ret = pread(vdev->vbasedev.fd, vdev->pdev.config,

                MIN(pci_config_size(&vdev->pdev), vdev->config_size),

                vdev->config_offset);

    if (ret < (int)MIN(pci_config_size(&vdev->pdev), vdev->config_size)) {

        ret = ret < 0 ? -errno : -EFAULT;

        error_report("vfio: Failed to read device config space");

        return ret;

    }

    /* vfio emulates a lot for us, but some bits need extra love */

    vdev->emulated_config_bits = g_malloc0(vdev->config_size);

    /* QEMU can choose to expose the ROM or not */

    memset(vdev->emulated_config_bits + PCI_ROM_ADDRESS, 0xff, 4);

    /*

     * The PCI spec reserves vendor ID 0xffff as an invalid value.  The

     * device ID is managed by the vendor and need only be a 16-bit value.

     * Allow any 16-bit value for subsystem so they can be hidden or changed.

     */

    if (vdev->vendor_id != PCI_ANY_ID) {

        if (vdev->vendor_id >= 0xffff) {

            error_report("vfio: Invalid PCI vendor ID provided");

            return -EINVAL;

        }

        vfio_add_emulated_word(vdev, PCI_VENDOR_ID, vdev->vendor_id, ~0);

        trace_vfio_pci_emulated_vendor_id(vdev->vbasedev.name, vdev->vendor_id);

    } else {

        vdev->vendor_id = pci_get_word(pdev->config + PCI_VENDOR_ID);

    }

    if (vdev->device_id != PCI_ANY_ID) {

        if (vdev->device_id > 0xffff) {

            error_report("vfio: Invalid PCI device ID provided");

            return -EINVAL;

        }

        vfio_add_emulated_word(vdev, PCI_DEVICE_ID, vdev->device_id, ~0);

        trace_vfio_pci_emulated_device_id(vdev->vbasedev.name, vdev->device_id);

    } else {

        vdev->device_id = pci_get_word(pdev->config + PCI_DEVICE_ID);

    }

    if (vdev->sub_vendor_id != PCI_ANY_ID) {

        if (vdev->sub_vendor_id > 0xffff) {

            error_report("vfio: Invalid PCI subsystem vendor ID provided");

            return -EINVAL;

        }

        vfio_add_emulated_word(vdev, PCI_SUBSYSTEM_VENDOR_ID,

                               vdev->sub_vendor_id, ~0);

        trace_vfio_pci_emulated_sub_vendor_id(vdev->vbasedev.name,

                                              vdev->sub_vendor_id);

    }

    if (vdev->sub_device_id != PCI_ANY_ID) {

        if (vdev->sub_device_id > 0xffff) {

            error_report("vfio: Invalid PCI subsystem device ID provided");

            return -EINVAL;

        }

        vfio_add_emulated_word(vdev, PCI_SUBSYSTEM_ID, vdev->sub_device_id, ~0);

        trace_vfio_pci_emulated_sub_device_id(vdev->vbasedev.name,

                                              vdev->sub_device_id);

    }

    /* QEMU can change multi-function devices to single function, or reverse */

    vdev->emulated_config_bits[PCI_HEADER_TYPE] =

                                              PCI_HEADER_TYPE_MULTI_FUNCTION;

    /* Restore or clear multifunction, this is always controlled by QEMU */

    if (vdev->pdev.cap_present & QEMU_PCI_CAP_MULTIFUNCTION) {

        vdev->pdev.config[PCI_HEADER_TYPE] |= PCI_HEADER_TYPE_MULTI_FUNCTION;

    } else {

        vdev->pdev.config[PCI_HEADER_TYPE] &= ~PCI_HEADER_TYPE_MULTI_FUNCTION;

    }

    /*

     * Clear host resource mapping info.  If we choose not to register a

     * BAR, such as might be the case with the option ROM, we can get

     * confusing, unwritable, residual addresses from the host here.

     */

    memset(&vdev->pdev.config[PCI_BASE_ADDRESS_0], 0, 24);

    memset(&vdev->pdev.config[PCI_ROM_ADDRESS], 0, 4);

    vfio_pci_size_rom(vdev);

    ret = vfio_msix_early_setup(vdev);

    if (ret) {

        return ret;

    }

    vfio_map_bars(vdev);

    ret = vfio_add_capabilities(vdev);

    if (ret) {

        goto out_teardown;

    }

    /* QEMU emulates all of MSI & MSIX */

    if (pdev->cap_present & QEMU_PCI_CAP_MSIX) {

        memset(vdev->emulated_config_bits + pdev->msix_cap, 0xff,

               MSIX_CAP_LENGTH);

    }

    if (pdev->cap_present & QEMU_PCI_CAP_MSI) {

        memset(vdev->emulated_config_bits + pdev->msi_cap, 0xff,

               vdev->msi_cap_size);

    }

    if (vfio_pci_read_config(&vdev->pdev, PCI_INTERRUPT_PIN, 1)) {

        vdev->intx.mmap_timer = timer_new_ms(QEMU_CLOCK_VIRTUAL,

                                                  vfio_intx_mmap_enable, vdev);

        pci_device_set_intx_routing_notifier(&vdev->pdev, vfio_intx_update);

        ret = vfio_intx_enable(vdev);

        if (ret) {

            goto out_teardown;

        }

    }

    vfio_register_err_notifier(vdev);

    vfio_register_req_notifier(vdev);

    vfio_setup_resetfn_quirk(vdev);

    return 0;

out_teardown:

    pci_device_set_intx_routing_notifier(&vdev->pdev, NULL);

    vfio_teardown_msi(vdev);

    vfio_unregister_bars(vdev);

    return ret;

}


static RefPtr<Image> ImageFromNode(const Node& node) {
  DCHECK(!node.GetDocument().NeedsLayoutTreeUpdate());
  DocumentLifecycle::DisallowTransitionScope disallow_transition(
      node.GetDocument().Lifecycle());

  LayoutObject* layout_object = node.GetLayoutObject();
  if (!layout_object)
    return nullptr;

  if (layout_object->IsCanvas()) {
    return toHTMLCanvasElement(const_cast<Node&>(node))
        .CopiedImage(kFrontBuffer, kPreferNoAcceleration,
                     kSnapshotReasonCopyToClipboard);
  }

  if (layout_object->IsImage()) {
    LayoutImage* layout_image = ToLayoutImage(layout_object);
    if (!layout_image)
      return nullptr;

    ImageResourceContent* cached_image = layout_image->CachedImage();
    if (!cached_image || cached_image->ErrorOccurred())
      return nullptr;
    return cached_image->GetImage();
  }

  return nullptr;
}


static void methodWithEnforceRangeInt32Method(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    ExceptionState exceptionState(ExceptionState::ExecutionContext, "methodWithEnforceRangeInt32", "TestObject", info.Holder(), info.GetIsolate());
    if (UNLIKELY(info.Length() < 1)) {
        exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, info.Length()));
        exceptionState.throwIfNeeded();
        return;
    }
    TestObject* imp = V8TestObject::toNative(info.Holder());
    V8TRYCATCH_EXCEPTION_VOID(int, value, toInt32(info[0], EnforceRange, exceptionState), exceptionState);
    imp->methodWithEnforceRangeInt32(value);
}


static int getHeightForLineCount(RenderBlock* block, int l, bool includeBottom, int& count)
{
    if (block->style()->visibility() == VISIBLE) {
        if (block->childrenInline()) {
            for (RootInlineBox* box = block->firstRootBox(); box; box = box->nextRootBox()) {
                if (++count == l)
                    return box->lineBottom() + (includeBottom ? (block->borderBottom() + block->paddingBottom()) : LayoutUnit());
            }
        }
        else {
            RenderBox* normalFlowChildWithoutLines = 0;
            for (RenderBox* obj = block->firstChildBox(); obj; obj = obj->nextSiblingBox()) {
                if (shouldCheckLines(obj)) {
                    int result = getHeightForLineCount(toRenderBlock(obj), l, false, count);
                    if (result != -1)
                        return result + obj->y() + (includeBottom ? (block->borderBottom() + block->paddingBottom()) : LayoutUnit());
                } else if (!obj->isFloatingOrOutOfFlowPositioned())
                    normalFlowChildWithoutLines = obj;
            }
            if (normalFlowChildWithoutLines && l == 0)
                return normalFlowChildWithoutLines->y() + normalFlowChildWithoutLines->height();
        }
    }

    return -1;
}


void build_legacy_cpu_hotplug_aml(Aml *ctx, MachineState *machine,

                                  uint16_t io_base, uint16_t io_len)

{

    Aml *dev;

    Aml *crs;

    Aml *pkg;

    Aml *field;

    Aml *method;

    Aml *if_ctx;

    Aml *else_ctx;

    int i, apic_idx;

    Aml *sb_scope = aml_scope("_SB");

    uint8_t madt_tmpl[8] = {0x00, 0x08, 0x00, 0x00, 0x00, 0, 0, 0};

    Aml *cpu_id = aml_arg(0);

    Aml *cpu_on = aml_local(0);

    Aml *madt = aml_local(1);

    Aml *cpus_map = aml_name(CPU_ON_BITMAP);

    Aml *zero = aml_int(0);

    Aml *one = aml_int(1);

    MachineClass *mc = MACHINE_GET_CLASS(machine);

    CPUArchIdList *apic_ids = mc->possible_cpu_arch_ids(machine);

    PCMachineState *pcms = PC_MACHINE(machine);

    /*

     * _MAT method - creates an madt apic buffer

     * cpu_id = Arg0 = Processor ID = Local APIC ID

     * cpu_on = Local0 = CPON flag for this cpu

     * madt = Local1 = Buffer (in madt apic form) to return

     */

    method = aml_method(CPU_MAT_METHOD, 1, AML_NOTSERIALIZED);

    aml_append(method,

        aml_store(aml_derefof(aml_index(cpus_map, cpu_id)), cpu_on));

    aml_append(method,

        aml_store(aml_buffer(sizeof(madt_tmpl), madt_tmpl), madt));

    /* Update the processor id, lapic id, and enable/disable status */

    aml_append(method, aml_store(cpu_id, aml_index(madt, aml_int(2))));

    aml_append(method, aml_store(cpu_id, aml_index(madt, aml_int(3))));

    aml_append(method, aml_store(cpu_on, aml_index(madt, aml_int(4))));

    aml_append(method, aml_return(madt));

    aml_append(sb_scope, method);

    /*

     * _STA method - return ON status of cpu

     * cpu_id = Arg0 = Processor ID = Local APIC ID

     * cpu_on = Local0 = CPON flag for this cpu

     */

    method = aml_method(CPU_STATUS_METHOD, 1, AML_NOTSERIALIZED);

    aml_append(method,

        aml_store(aml_derefof(aml_index(cpus_map, cpu_id)), cpu_on));

    if_ctx = aml_if(cpu_on);

    {

        aml_append(if_ctx, aml_return(aml_int(0xF)));

    }

    aml_append(method, if_ctx);

    else_ctx = aml_else();

    {

        aml_append(else_ctx, aml_return(zero));

    }

    aml_append(method, else_ctx);

    aml_append(sb_scope, method);

    method = aml_method(CPU_EJECT_METHOD, 2, AML_NOTSERIALIZED);

    aml_append(method, aml_sleep(200));

    aml_append(sb_scope, method);

    method = aml_method(CPU_SCAN_METHOD, 0, AML_NOTSERIALIZED);

    {

        Aml *while_ctx, *if_ctx2, *else_ctx2;

        Aml *bus_check_evt = aml_int(1);

        Aml *remove_evt = aml_int(3);

        Aml *status_map = aml_local(5); /* Local5 = active cpu bitmap */

        Aml *byte = aml_local(2); /* Local2 = last read byte from bitmap */

        Aml *idx = aml_local(0); /* Processor ID / APIC ID iterator */

        Aml *is_cpu_on = aml_local(1); /* Local1 = CPON flag for cpu */

        Aml *status = aml_local(3); /* Local3 = active state for cpu */

        aml_append(method, aml_store(aml_name(CPU_STATUS_MAP), status_map));

        aml_append(method, aml_store(zero, byte));

        aml_append(method, aml_store(zero, idx));

        /* While (idx < SizeOf(CPON)) */

        while_ctx = aml_while(aml_lless(idx, aml_sizeof(cpus_map)));

        aml_append(while_ctx,

            aml_store(aml_derefof(aml_index(cpus_map, idx)), is_cpu_on));

        if_ctx = aml_if(aml_and(idx, aml_int(0x07), NULL));

        {

            /* Shift down previously read bitmap byte */

            aml_append(if_ctx, aml_shiftright(byte, one, byte));

        }

        aml_append(while_ctx, if_ctx);

        else_ctx = aml_else();

        {

            /* Read next byte from cpu bitmap */

            aml_append(else_ctx, aml_store(aml_derefof(aml_index(status_map,

                       aml_shiftright(idx, aml_int(3), NULL))), byte));

        }

        aml_append(while_ctx, else_ctx);

        aml_append(while_ctx, aml_store(aml_and(byte, one, NULL), status));

        if_ctx = aml_if(aml_lnot(aml_equal(is_cpu_on, status)));

        {

            /* State change - update CPON with new state */

            aml_append(if_ctx, aml_store(status, aml_index(cpus_map, idx)));

            if_ctx2 = aml_if(aml_equal(status, one));

            {

                aml_append(if_ctx2,

                    aml_call2(AML_NOTIFY_METHOD, idx, bus_check_evt));

            }

            aml_append(if_ctx, if_ctx2);

            else_ctx2 = aml_else();

            {

                aml_append(else_ctx2,

                    aml_call2(AML_NOTIFY_METHOD, idx, remove_evt));

            }

        }

        aml_append(if_ctx, else_ctx2);

        aml_append(while_ctx, if_ctx);

        aml_append(while_ctx, aml_increment(idx)); /* go to next cpu */

        aml_append(method, while_ctx);

    }

    aml_append(sb_scope, method);

    /* The current AML generator can cover the APIC ID range [0..255],

     * inclusive, for VCPU hotplug. */

    QEMU_BUILD_BUG_ON(ACPI_CPU_HOTPLUG_ID_LIMIT > 256);

    g_assert(pcms->apic_id_limit <= ACPI_CPU_HOTPLUG_ID_LIMIT);

    /* create PCI0.PRES device and its _CRS to reserve CPU hotplug MMIO */

    dev = aml_device("PCI0." stringify(CPU_HOTPLUG_RESOURCE_DEVICE));

    aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0A06")));

    aml_append(dev,

        aml_name_decl("_UID", aml_string("CPU Hotplug resources"))

    );

    /* device present, functioning, decoding, not shown in UI */

    aml_append(dev, aml_name_decl("_STA", aml_int(0xB)));

    crs = aml_resource_template();

    aml_append(crs,

        aml_io(AML_DECODE16, io_base, io_base, 1, io_len)

    );

    aml_append(dev, aml_name_decl("_CRS", crs));

    aml_append(sb_scope, dev);

    /* declare CPU hotplug MMIO region and PRS field to access it */

    aml_append(sb_scope, aml_operation_region(

        "PRST", AML_SYSTEM_IO, aml_int(io_base), io_len));

    field = aml_field("PRST", AML_BYTE_ACC, AML_NOLOCK, AML_PRESERVE);

    aml_append(field, aml_named_field("PRS", 256));

    aml_append(sb_scope, field);

    /* build Processor object for each processor */

    for (i = 0; i < apic_ids->len; i++) {

        int apic_id = apic_ids->cpus[i].arch_id;

        assert(apic_id < ACPI_CPU_HOTPLUG_ID_LIMIT);

        dev = aml_processor(apic_id, 0, 0, "CP%.02X", apic_id);

        method = aml_method("_MAT", 0, AML_NOTSERIALIZED);

        aml_append(method,

            aml_return(aml_call1(CPU_MAT_METHOD, aml_int(apic_id))));

        aml_append(dev, method);

        method = aml_method("_STA", 0, AML_NOTSERIALIZED);

        aml_append(method,

            aml_return(aml_call1(CPU_STATUS_METHOD, aml_int(apic_id))));

        aml_append(dev, method);

        method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);

        aml_append(method,

            aml_return(aml_call2(CPU_EJECT_METHOD, aml_int(apic_id),

                aml_arg(0)))

        );

        aml_append(dev, method);

        aml_append(sb_scope, dev);

    }

    /* build this code:

     *   Method(NTFY, 2) {If (LEqual(Arg0, 0x00)) {Notify(CP00, Arg1)} ...}

     */

    /* Arg0 = Processor ID = APIC ID */

    method = aml_method(AML_NOTIFY_METHOD, 2, AML_NOTSERIALIZED);

    for (i = 0; i < apic_ids->len; i++) {

        int apic_id = apic_ids->cpus[i].arch_id;

        if_ctx = aml_if(aml_equal(aml_arg(0), aml_int(apic_id)));

        aml_append(if_ctx,

            aml_notify(aml_name("CP%.02X", apic_id), aml_arg(1))

        );

        aml_append(method, if_ctx);

    }

    aml_append(sb_scope, method);

    /* build "Name(CPON, Package() { One, One, ..., Zero, Zero, ... })"

     *

     * Note: The ability to create variable-sized packages was first

     * introduced in ACPI 2.0. ACPI 1.0 only allowed fixed-size packages

     * ith up to 255 elements. Windows guests up to win2k8 fail when

     * VarPackageOp is used.

     */

    pkg = pcms->apic_id_limit <= 255 ? aml_package(pcms->apic_id_limit) :

                                       aml_varpackage(pcms->apic_id_limit);

    for (i = 0, apic_idx = 0; i < apic_ids->len; i++) {

        int apic_id = apic_ids->cpus[i].arch_id;

        for (; apic_idx < apic_id; apic_idx++) {

            aml_append(pkg, aml_int(0));

        }

        aml_append(pkg, aml_int(apic_ids->cpus[i].cpu ? 1 : 0));

        apic_idx = apic_id + 1;

    }

    aml_append(sb_scope, aml_name_decl(CPU_ON_BITMAP, pkg));

    g_free(apic_ids);

    aml_append(ctx, sb_scope);

    method = aml_method("\\_GPE._E02", 0, AML_NOTSERIALIZED);

    aml_append(method, aml_call0("\\_SB." CPU_SCAN_METHOD));

    aml_append(ctx, method);

}


SPL_METHOD(MultipleIterator, __construct)
{
	spl_SplObjectStorage   *intern;
	zend_long               flags = MIT_NEED_ALL|MIT_KEYS_NUMERIC;

	if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "|l", &flags) == FAILURE) {
		return;
	}

	intern = Z_SPLOBJSTORAGE_P(getThis());
	intern->flags = flags;
}


cifs_async_writev(struct cifs_writedata *wdata)
{
	int i, rc = -EACCES;
	WRITE_REQ *smb = NULL;
	int wct;
	struct cifs_tcon *tcon = tlink_tcon(wdata->cfile->tlink);
	struct inode *inode = wdata->cfile->dentry->d_inode;
	struct kvec *iov = NULL;

	if (tcon->ses->capabilities & CAP_LARGE_FILES) {
		wct = 14;
	} else {
		wct = 12;
		if (wdata->offset >> 32 > 0) {
			/* can not handle big offset for old srv */
			return -EIO;
		}
	}

	rc = small_smb_init(SMB_COM_WRITE_ANDX, wct, tcon, (void **)&smb);
	if (rc)
		goto async_writev_out;

	/* 1 iov per page + 1 for header */
	iov = kzalloc((wdata->nr_pages + 1) * sizeof(*iov), GFP_NOFS);
	if (iov == NULL) {
		rc = -ENOMEM;
		goto async_writev_out;
	}

	smb->hdr.Pid = cpu_to_le16((__u16)wdata->cfile->pid);
	smb->hdr.PidHigh = cpu_to_le16((__u16)(wdata->cfile->pid >> 16));

	smb->AndXCommand = 0xFF;	/* none */
	smb->Fid = wdata->cfile->netfid;
	smb->OffsetLow = cpu_to_le32(wdata->offset & 0xFFFFFFFF);
	if (wct == 14)
		smb->OffsetHigh = cpu_to_le32(wdata->offset >> 32);
	smb->Reserved = 0xFFFFFFFF;
	smb->WriteMode = 0;
	smb->Remaining = 0;

	smb->DataOffset =
	    cpu_to_le16(offsetof(struct smb_com_write_req, Data) - 4);

	/* 4 for RFC1001 length + 1 for BCC */
	iov[0].iov_len = be32_to_cpu(smb->hdr.smb_buf_length) + 4 + 1;
	iov[0].iov_base = smb;

	/* marshal up the pages into iov array */
	wdata->bytes = 0;
	for (i = 0; i < wdata->nr_pages; i++) {
		iov[i + 1].iov_len = min(inode->i_size -
				      page_offset(wdata->pages[i]),
					(loff_t)PAGE_CACHE_SIZE);
		iov[i + 1].iov_base = kmap(wdata->pages[i]);
		wdata->bytes += iov[i + 1].iov_len;
	}

	cFYI(1, "async write at %llu %u bytes", wdata->offset, wdata->bytes);

	smb->DataLengthLow = cpu_to_le16(wdata->bytes & 0xFFFF);
	smb->DataLengthHigh = cpu_to_le16(wdata->bytes >> 16);

	if (wct == 14) {
		inc_rfc1001_len(&smb->hdr, wdata->bytes + 1);
		put_bcc(wdata->bytes + 1, &smb->hdr);
	} else {
		/* wct == 12 */
		struct smb_com_writex_req *smbw =
				(struct smb_com_writex_req *)smb;
		inc_rfc1001_len(&smbw->hdr, wdata->bytes + 5);
		put_bcc(wdata->bytes + 5, &smbw->hdr);
		iov[0].iov_len += 4; /* pad bigger by four bytes */
	}

	kref_get(&wdata->refcount);
	rc = cifs_call_async(tcon->ses->server, iov, wdata->nr_pages + 1,
			     cifs_writev_callback, wdata, false);

	if (rc == 0)
		cifs_stats_inc(&tcon->num_writes);
	else
		kref_put(&wdata->refcount, cifs_writedata_release);

	/* send is done, unmap pages */
	for (i = 0; i < wdata->nr_pages; i++)
		kunmap(wdata->pages[i]);

async_writev_out:
	cifs_small_buf_release(smb);
	kfree(iov);
	return rc;
}


static void S_AL_BufferUseDefault(sfxHandle_t sfx)
{
	if(sfx == default_sfx)
		Com_Error(ERR_FATAL, "Can't load default sound effect %s", knownSfx[sfx].filename);

	Com_Printf( S_COLOR_YELLOW "WARNING: Using default sound for %s\n", knownSfx[sfx].filename);
	knownSfx[sfx].isDefault = qtrue;
	knownSfx[sfx].buffer = knownSfx[default_sfx].buffer;
}


static void jpc_crg_destroyparms(jpc_ms_t *ms)
{
	jpc_crg_t *crg = &ms->parms.crg;
	if (crg->comps) {
		jas_free(crg->comps);
	}
}


static ZEND_INI_MH(OnUpdateSmartStr) /* {{{ */
{
	smart_str *p;
#ifndef ZTS
	char *base = (char *) mh_arg2;
#else
	char *base;

	base = (char *) ts_resource(*((int *) mh_arg2));
#endif

	p = (smart_str *) (base+(size_t) mh_arg1);

	smart_str_sets(p, new_value);

	return SUCCESS;
}


void MainWindow::configureVideoWidget()
{
    LOG_DEBUG() << "begin";
    if (m_profileGroup->checkedAction())
        setProfile(m_profileGroup->checkedAction()->data().toString());
    MLT.videoWidget()->setProperty("realtime", ui->actionRealtime->isChecked());
    bool ok = false;
    m_externalGroup->checkedAction()->data().toInt(&ok);
    if (!ui->menuExternal || m_externalGroup->checkedAction()->data().toString().isEmpty() || ok) {
        MLT.videoWidget()->setProperty("progressive", ui->actionProgressive->isChecked());
    } else {
        MLT.videoWidget()->setProperty("mlt_service", m_externalGroup->checkedAction()->data());
        MLT.videoWidget()->setProperty("progressive", MLT.profile().progressive());
        ui->actionProgressive->setEnabled(false);
    }
    if (ui->actionChannels1->isChecked())
        setAudioChannels(1);
    else if (ui->actionChannels2->isChecked())
        setAudioChannels(2);
    else
        setAudioChannels(6);
    if (ui->actionOneField->isChecked())
        MLT.videoWidget()->setProperty("deinterlace_method", "onefield");
    else if (ui->actionLinearBlend->isChecked())
        MLT.videoWidget()->setProperty("deinterlace_method", "linearblend");
    else if (ui->actionYadifTemporal->isChecked())
        MLT.videoWidget()->setProperty("deinterlace_method", "yadif-nospatial");
    else
        MLT.videoWidget()->setProperty("deinterlace_method", "yadif");
    if (ui->actionNearest->isChecked())
        MLT.videoWidget()->setProperty("rescale", "nearest");
    else if (ui->actionBilinear->isChecked())
        MLT.videoWidget()->setProperty("rescale", "bilinear");
    else if (ui->actionBicubic->isChecked())
        MLT.videoWidget()->setProperty("rescale", "bicubic");
    else
        MLT.videoWidget()->setProperty("rescale", "hyper");
    if (m_keyerGroup)
        MLT.videoWidget()->setProperty("keyer", m_keyerGroup->checkedAction()->data());
    LOG_DEBUG() << "end";
}


status_t MediaPlayerService::AudioOutput::attachAuxEffect(int effectId)
{
    ALOGV("attachAuxEffect(%d)", effectId);
 Mutex::Autolock lock(mLock);
    mAuxEffectId = effectId;
 if (mTrack != 0) {
 return mTrack->attachAuxEffect(effectId);
 }
 return NO_ERROR;
}


void normalizeTV(struct timeval& tv)
{
  if(tv.tv_usec > 1000000) {
    ++tv.tv_sec;
    tv.tv_usec-=1000000;
  }
  else if(tv.tv_usec < 0) {
    --tv.tv_sec;
    tv.tv_usec+=1000000;
  }
}


void QPaintEngineEx::drawImage(const QPointF &pos, const QImage &image)
{
    drawImage(QRectF(pos, image.size() / image.devicePixelRatio()), image, image.rect());
}


static int avs_read_packet(AVFormatContext * s, AVPacket * pkt)

{

    AvsFormat *avs = s->priv_data;

    int sub_type = 0, size = 0;

    AvsBlockType type = AVS_NONE;

    int palette_size = 0;

    uint8_t palette[4 + 3 * 256];

    int ret;

    if (avs->remaining_audio_size > 0)

        if (avs_read_audio_packet(s, pkt) > 0)

            return 0;

    while (1) {

        if (avs->remaining_frame_size <= 0) {

            if (!avio_rl16(s->pb))    /* found EOF */

                return AVERROR(EIO);

            avs->remaining_frame_size = avio_rl16(s->pb) - 4;

        }

        while (avs->remaining_frame_size > 0) {

            sub_type = avio_r8(s->pb);

            type = avio_r8(s->pb);

            size = avio_rl16(s->pb);

            if (size < 4)

                return AVERROR_INVALIDDATA;

            avs->remaining_frame_size -= size;

            switch (type) {

            case AVS_PALETTE:

                if (size - 4 > sizeof(palette))

                    return AVERROR_INVALIDDATA;

                ret = avio_read(s->pb, palette, size - 4);

                if (ret < size - 4)

                    return AVERROR(EIO);

                palette_size = size;

                break;

            case AVS_VIDEO:

                if (!avs->st_video) {

                    avs->st_video = avformat_new_stream(s, NULL);

                    if (avs->st_video == NULL)

                        return AVERROR(ENOMEM);

                    avs->st_video->codec->codec_type = AVMEDIA_TYPE_VIDEO;

                    avs->st_video->codec->codec_id = AV_CODEC_ID_AVS;

                    avs->st_video->codec->width = avs->width;

                    avs->st_video->codec->height = avs->height;

                    avs->st_video->codec->bits_per_coded_sample=avs->bits_per_sample;

                    avs->st_video->nb_frames = avs->nb_frames;

                    avs->st_video->avg_frame_rate = (AVRational){avs->fps, 1};

                }

                return avs_read_video_packet(s, pkt, type, sub_type, size,

                                             palette, palette_size);

            case AVS_AUDIO:

                if (!avs->st_audio) {

                    avs->st_audio = avformat_new_stream(s, NULL);

                    if (avs->st_audio == NULL)

                        return AVERROR(ENOMEM);

                    avs->st_audio->codec->codec_type = AVMEDIA_TYPE_AUDIO;

                }

                avs->remaining_audio_size = size - 4;

                size = avs_read_audio_packet(s, pkt);

                if (size != 0)

                    return size;

                break;

            default:

                avio_skip(s->pb, size - 4);

            }

        }

    }

}


void WebContentsImpl::DidChangeLoadProgress(double progress) {
  if (delegate_)
    delegate_->LoadProgressChanged(this, progress);
}


int oz_hcd_init(void)
{
	int err;

	if (usb_disabled())
		return -ENODEV;

	oz_urb_link_cache = KMEM_CACHE(oz_urb_link, 0);
	if (!oz_urb_link_cache)
		return -ENOMEM;

	tasklet_init(&g_urb_process_tasklet, oz_urb_process_tasklet, 0);
	tasklet_init(&g_urb_cancel_tasklet, oz_urb_cancel_tasklet, 0);
	err = platform_driver_register(&g_oz_plat_drv);
	oz_dbg(ON, "platform_driver_register() returned %d\n", err);
	if (err)
		goto error;
	g_plat_dev = platform_device_alloc(OZ_PLAT_DEV_NAME, -1);
	if (g_plat_dev == NULL) {
		err = -ENOMEM;
		goto error1;
	}
	oz_dbg(ON, "platform_device_alloc() succeeded\n");
	err = platform_device_add(g_plat_dev);
	if (err)
		goto error2;
	oz_dbg(ON, "platform_device_add() succeeded\n");
	return 0;
error2:
	platform_device_put(g_plat_dev);
error1:
	platform_driver_unregister(&g_oz_plat_drv);
error:
	tasklet_disable(&g_urb_process_tasklet);
	tasklet_disable(&g_urb_cancel_tasklet);
	oz_dbg(ON, "oz_hcd_init() failed %d\n", err);
	return err;
}


static BOOL rdp_read_input_capability_set(wStream* s, UINT16 length, rdpSettings* settings)
{
	UINT16 inputFlags;

	if (length < 88)
		return FALSE;

	Stream_Read_UINT16(s, inputFlags); /* inputFlags (2 bytes) */
	Stream_Seek_UINT16(s);             /* pad2OctetsA (2 bytes) */

	if (settings->ServerMode)
	{
		Stream_Read_UINT32(s, settings->KeyboardLayout);      /* keyboardLayout (4 bytes) */
		Stream_Read_UINT32(s, settings->KeyboardType);        /* keyboardType (4 bytes) */
		Stream_Read_UINT32(s, settings->KeyboardSubType);     /* keyboardSubType (4 bytes) */
		Stream_Read_UINT32(s, settings->KeyboardFunctionKey); /* keyboardFunctionKeys (4 bytes) */
	}
	else
	{
		Stream_Seek_UINT32(s); /* keyboardLayout (4 bytes) */
		Stream_Seek_UINT32(s); /* keyboardType (4 bytes) */
		Stream_Seek_UINT32(s); /* keyboardSubType (4 bytes) */
		Stream_Seek_UINT32(s); /* keyboardFunctionKeys (4 bytes) */
	}

	Stream_Seek(s, 64); /* imeFileName (64 bytes) */

	if (!settings->ServerMode)
	{
		if (inputFlags & INPUT_FLAG_FASTPATH_INPUT)
		{
			/* advertised by RDP 5.0 and 5.1 servers */
		}
		else if (inputFlags & INPUT_FLAG_FASTPATH_INPUT2)
		{
			/* advertised by RDP 5.2, 6.0, 6.1 and 7.0 servers */
		}
		else
		{
			/* server does not support fastpath input */
			settings->FastPathInput = FALSE;
		}

		if (inputFlags & TS_INPUT_FLAG_MOUSE_HWHEEL)
			settings->HasHorizontalWheel = TRUE;

		if (inputFlags & INPUT_FLAG_UNICODE)
			settings->UnicodeInput = TRUE;

		if (inputFlags & INPUT_FLAG_MOUSEX)
			settings->HasExtendedMouseEvent = TRUE;
	}

	return TRUE;
}


static bool pi_test_and_clear_on(struct pi_desc *pi_desc)
{
	return test_and_clear_bit(POSTED_INTR_ON,
			(unsigned long *)&pi_desc->control);
}


static int crypto_ablkcipher_report(struct sk_buff *skb, struct crypto_alg *alg)
{
	return -ENOSYS;
}


char* String8::find_extension(void) const
{
 const char* lastSlash;
 const char* lastDot;
 const char* const str = mString;

    lastSlash = strrchr(str, OS_PATH_SEPARATOR);
 if (lastSlash == NULL)
        lastSlash = str;
 else
        lastSlash++;

    lastDot = strrchr(lastSlash, '.');
 if (lastDot == NULL)
 return NULL;

 return const_cast<char*>(lastDot);
}


	__acquires(tp->lock)
{
	int err;

	err = tg3_init_hw(tp, reset_phy);
	if (err) {
		netdev_err(tp->dev,
			   "Failed to re-initialize device, aborting\n");
		tg3_halt(tp, RESET_KIND_SHUTDOWN, 1);
		tg3_full_unlock(tp);
		tg3_timer_stop(tp);
		tp->irq_sync = 0;
		tg3_napi_enable(tp);
		dev_close(tp->dev);
		tg3_full_lock(tp, 0);
	}
	return err;
}


ModuleExport void UnregisterCUTImage(void)
{
  (void) UnregisterMagickInfo("CUT");
}


bool WebPagePrivate::useFixedLayout() const
{
    return true;
}


bool X86_insn_reg_att2(unsigned int id, x86_reg *reg1, enum cs_ac_type *access1, x86_reg *reg2, enum cs_ac_type *access2)
{
	unsigned int i;

	for (i = 0; i < ARR_SIZE(insn_regs_intel2); i++) {
		if (insn_regs_intel2[i].insn == id) {
			// reverse order of Intel syntax registers
			*reg1 = insn_regs_intel2[i].reg2;
			*reg2 = insn_regs_intel2[i].reg1;
            if (access1)
                *access1 = insn_regs_intel2[i].access2;
            if (access2)
                *access2 = insn_regs_intel2[i].access1;
			return true;
		}
	}

	// not found
	return false;
}


bool checkreturn pb_read(pb_istream_t *stream, uint8_t *buf, size_t count)
{
#ifndef PB_BUFFER_ONLY
	if (buf == NULL && stream->callback != buf_read)
	{
		/* Skip input bytes */
		uint8_t tmp[16];
		while (count > 16)
		{
			if (!pb_read(stream, tmp, 16))
				return false;

			count -= 16;
		}

		return pb_read(stream, tmp, count);
	}
#endif

    if (stream->bytes_left < count)
        PB_RETURN_ERROR(stream, "end-of-stream");

#ifndef PB_BUFFER_ONLY
    if (!stream->callback(stream, buf, count))
        PB_RETURN_ERROR(stream, "io error");
#else
    if (!buf_read(stream, buf, count))
        return false;
#endif

    stream->bytes_left -= count;
    return true;
}


inline char* StringData::mutableData() const {
  assertx(!isImmutable());
  return const_cast<char*>(data());
}


static void gen_tlbia(DisasContext *ctx)

{

#if defined(CONFIG_USER_ONLY)

    gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);

#else

    if (unlikely(ctx->pr)) {

        gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);

        return;

    }

    gen_helper_tlbia(cpu_env);

#endif

}


void unsetparam(char *param) {
   int i;

   for (i = 0; i < MAX_PARAM; i++)
      if (strieq(param, _param[i]))
         break;

   if (i < MAX_PARAM) {
      for (; i < MAX_PARAM - 1; i++) {
         strlcpy(_param[i], _param[i + 1], NAME_LENGTH);
         strlcpy(_value[i], _value[i + 1], NAME_LENGTH);
      }
      _param[MAX_PARAM - 1][0] = 0;
      _value[MAX_PARAM - 1][0] = 0;
   }
}


f_inputsave(typval_T *argvars UNUSED, typval_T *rettv)
{
    /* Add an entry to the stack of typeahead storage. */
    if (ga_grow(&ga_userinput, 1) == OK)
    {
	save_typeahead((tasave_T *)(ga_userinput.ga_data)
						       + ga_userinput.ga_len);
	++ga_userinput.ga_len;
	/* default return is zero == OK */
    }
    else
	rettv->vval.v_number = 1; /* Failed */
}


extractContigSamples32bits (uint8 *in, uint8 *out, uint32 cols,
                            tsample_t sample, uint16 spp, uint16 bps,
 			    tsample_t count, uint32 start, uint32 end)
  {
  int    ready_bits = 0, sindex = 0 /*, shift_width = 0 */;
  uint32 col, src_byte, src_bit, bit_offset;
  uint32 longbuff1 = 0, longbuff2 = 0;
  uint64 maskbits = 0, matchbits = 0;
  uint64 buff1 = 0, buff2 = 0, buff3 = 0;
  uint8  bytebuff1 = 0, bytebuff2 = 0, bytebuff3 = 0, bytebuff4 = 0;
  uint8 *src = in;
  uint8 *dst = out;

  if ((in == NULL) || (out == NULL))
    {
    TIFFError("extractContigSamples32bits","Invalid input or output buffer");
    return (1);
    }

  if ((start > end) || (start > cols))
    {
    TIFFError ("extractContigSamples32bits",
               "Invalid start column value %d ignored", start);
    start = 0;
    }
  if ((end == 0) || (end > cols))
    {
    TIFFError ("extractContigSamples32bits",
               "Invalid end column value %d ignored", end);
    end = cols;
    }

  /* shift_width = ((bps + 7) / 8) + 1; */
  ready_bits = 0;
  maskbits =  (uint64)-1 >> ( 64 - bps);
  for (col = start; col < end; col++)
    {
    /* Compute src byte(s) and bits within byte(s) */
    bit_offset = col * bps * spp;
    for (sindex = sample; (sindex < spp) && (sindex < (sample + count)); sindex++)
      {
      if (sindex == 0)
        {
        src_byte = bit_offset / 8;
        src_bit  = bit_offset % 8;
        }
      else
        {
        src_byte = (bit_offset + (sindex * bps)) / 8;
        src_bit  = (bit_offset + (sindex * bps)) % 8;
        }

      src = in + src_byte;
      matchbits = maskbits << (64 - src_bit - bps);
      if (little_endian)
        {
	longbuff1 = (src[0] << 24) | (src[1] << 16)  | (src[2] << 8) | src[3];
	longbuff2 = longbuff1;
        }
      else
        {
	longbuff1 = (src[3] << 24) | (src[2] << 16) | (src[1] << 8) | src[0];
	longbuff2 = longbuff1;
	}

      buff3 = ((uint64)longbuff1 << 32) | longbuff2;
      buff1 = (buff3 & matchbits) << (src_bit);

      /* If we have a full buffer's worth, write it out */
      if (ready_bits >= 32)
        {
        bytebuff1 = (buff2 >> 56);
        *dst++ = bytebuff1;
        bytebuff2 = (buff2 >> 48);
        *dst++ = bytebuff2;
        bytebuff3 = (buff2 >> 40);
        *dst++ = bytebuff3;
        bytebuff4 = (buff2 >> 32);
        *dst++ = bytebuff4;
        ready_bits -= 32;

        /* shift in new bits */
        buff2 = ((buff2 << 32) | (buff1 >> ready_bits));
        }
      else
        { /* add another bps bits to the buffer */
        bytebuff1 = bytebuff2 = bytebuff3 = bytebuff4 = 0;
        buff2 = (buff2 | (buff1 >> ready_bits));
        }
      ready_bits += bps;
      }
    }
  while (ready_bits > 0)
    {
    bytebuff1 = (buff2 >> 56);
    *dst++ = bytebuff1;
    buff2 = (buff2 << 8);
    ready_bits -= 8;
    }

  return (0);
  } /* end extractContigSamples32bits */


static int shorten_decode_frame(AVCodecContext *avctx, void *data,

                                int *got_frame_ptr, AVPacket *avpkt)

{

    AVFrame *frame     = data;

    const uint8_t *buf = avpkt->data;

    int buf_size       = avpkt->size;

    ShortenContext *s  = avctx->priv_data;

    int i, input_buf_size = 0;

    int ret;

    /* allocate internal bitstream buffer */

    if (s->max_framesize == 0) {

        void *tmp_ptr;

        s->max_framesize = 8192; // should hopefully be enough for the first header

        tmp_ptr = av_fast_realloc(s->bitstream, &s->allocated_bitstream_size,

                                  s->max_framesize + FF_INPUT_BUFFER_PADDING_SIZE);

        if (!tmp_ptr) {

            av_log(avctx, AV_LOG_ERROR, "error allocating bitstream buffer\n");

            return AVERROR(ENOMEM);

        }

        s->bitstream = tmp_ptr;

    }

    /* append current packet data to bitstream buffer */

    if (1 && s->max_framesize) { //FIXME truncated

        buf_size       = FFMIN(buf_size, s->max_framesize - s->bitstream_size);

        input_buf_size = buf_size;

        if (s->bitstream_index + s->bitstream_size + buf_size >

            s->allocated_bitstream_size) {

            memmove(s->bitstream, &s->bitstream[s->bitstream_index],

                    s->bitstream_size);

            s->bitstream_index = 0;

        }

        if (buf)

            memcpy(&s->bitstream[s->bitstream_index + s->bitstream_size], buf,

                   buf_size);

        buf               = &s->bitstream[s->bitstream_index];

        buf_size         += s->bitstream_size;

        s->bitstream_size = buf_size;

        /* do not decode until buffer has at least max_framesize bytes or

         * the end of the file has been reached */

        if (buf_size < s->max_framesize && avpkt->data) {

            *got_frame_ptr = 0;

            return input_buf_size;

        }

    }

    /* init and position bitstream reader */

    init_get_bits(&s->gb, buf, buf_size * 8);

    skip_bits(&s->gb, s->bitindex);

    /* process header or next subblock */

    if (!s->got_header) {

        if ((ret = read_header(s)) < 0)

            return ret;

        *got_frame_ptr = 0;

        goto finish_frame;

    }

    /* if quit command was read previously, don't decode anything */

    if (s->got_quit_command) {

        *got_frame_ptr = 0;

        return avpkt->size;

    }

    s->cur_chan = 0;

    while (s->cur_chan < s->channels) {

        unsigned cmd;

        int len;

        if (get_bits_left(&s->gb) < 3 + FNSIZE) {

            *got_frame_ptr = 0;

            break;

        }

        cmd = get_ur_golomb_shorten(&s->gb, FNSIZE);

        if (cmd > FN_VERBATIM) {

            av_log(avctx, AV_LOG_ERROR, "unknown shorten function %d\n", cmd);

            *got_frame_ptr = 0;

            break;

        }

        if (!is_audio_command[cmd]) {

            /* process non-audio command */

            switch (cmd) {

            case FN_VERBATIM:

                len = get_ur_golomb_shorten(&s->gb, VERBATIM_CKSIZE_SIZE);

                while (len--)

                    get_ur_golomb_shorten(&s->gb, VERBATIM_BYTE_SIZE);

                break;

            case FN_BITSHIFT:

                s->bitshift = get_ur_golomb_shorten(&s->gb, BITSHIFTSIZE);

                break;

            case FN_BLOCKSIZE: {

                unsigned blocksize = get_uint(s, av_log2(s->blocksize));

                if (blocksize > s->blocksize) {

                    av_log(avctx, AV_LOG_ERROR,

                           "Increasing block size is not supported\n");

                    return AVERROR_PATCHWELCOME;

                }

                if (!blocksize || blocksize > MAX_BLOCKSIZE) {

                    av_log(avctx, AV_LOG_ERROR, "invalid or unsupported "

                                                "block size: %d\n", blocksize);

                    return AVERROR(EINVAL);

                }

                s->blocksize = blocksize;

                break;

            }

            case FN_QUIT:

                s->got_quit_command = 1;

                break;

            }

            if (cmd == FN_BLOCKSIZE || cmd == FN_QUIT) {

                *got_frame_ptr = 0;

                break;

            }

        } else {

            /* process audio command */

            int residual_size = 0;

            int channel = s->cur_chan;

            int32_t coffset;

            /* get Rice code for residual decoding */

            if (cmd != FN_ZERO) {

                residual_size = get_ur_golomb_shorten(&s->gb, ENERGYSIZE);

                /* This is a hack as version 0 differed in the definition

                 * of get_sr_golomb_shorten(). */

                if (s->version == 0)

                    residual_size--;

            }

            /* calculate sample offset using means from previous blocks */

            if (s->nmean == 0)

                coffset = s->offset[channel][0];

            else {

                int32_t sum = (s->version < 2) ? 0 : s->nmean / 2;

                for (i = 0; i < s->nmean; i++)

                    sum += s->offset[channel][i];

                coffset = sum / s->nmean;

                if (s->version >= 2)

                    coffset = s->bitshift == 0 ? coffset : coffset >> s->bitshift - 1 >> 1;

            }

            /* decode samples for this channel */

            if (cmd == FN_ZERO) {

                for (i = 0; i < s->blocksize; i++)

                    s->decoded[channel][i] = 0;

            } else {

                if ((ret = decode_subframe_lpc(s, cmd, channel,

                                               residual_size, coffset)) < 0)

                    return ret;

            }

            /* update means with info from the current block */

            if (s->nmean > 0) {

                int32_t sum = (s->version < 2) ? 0 : s->blocksize / 2;

                for (i = 0; i < s->blocksize; i++)

                    sum += s->decoded[channel][i];

                for (i = 1; i < s->nmean; i++)

                    s->offset[channel][i - 1] = s->offset[channel][i];

                if (s->version < 2)

                    s->offset[channel][s->nmean - 1] = sum / s->blocksize;

                else

                    s->offset[channel][s->nmean - 1] = (sum / s->blocksize) << s->bitshift;

            }

            /* copy wrap samples for use with next block */

            for (i = -s->nwrap; i < 0; i++)

                s->decoded[channel][i] = s->decoded[channel][i + s->blocksize];

            /* shift samples to add in unused zero bits which were removed

             * during encoding */

            fix_bitshift(s, s->decoded[channel]);

            /* if this is the last channel in the block, output the samples */

            s->cur_chan++;

            if (s->cur_chan == s->channels) {

                uint8_t *samples_u8;

                int16_t *samples_s16;

                int chan;

                /* get output buffer */

                frame->nb_samples = s->blocksize;

                if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)

                    return ret;

                for (chan = 0; chan < s->channels; chan++) {

                    samples_u8  = ((uint8_t **)frame->extended_data)[chan];

                    samples_s16 = ((int16_t **)frame->extended_data)[chan];

                    for (i = 0; i < s->blocksize; i++) {

                        switch (s->internal_ftype) {

                        case TYPE_U8:

                            *samples_u8++ = av_clip_uint8(s->decoded[chan][i]);

                            break;

                        case TYPE_S16HL:

                        case TYPE_S16LH:

                            *samples_s16++ = av_clip_int16(s->decoded[chan][i]);

                            break;

                        }

                    }

                }

                *got_frame_ptr = 1;

            }

        }

    }

    if (s->cur_chan < s->channels)

        *got_frame_ptr = 0;

finish_frame:

    s->bitindex = get_bits_count(&s->gb) - 8 * (get_bits_count(&s->gb) / 8);

    i           = get_bits_count(&s->gb) / 8;

    if (i > buf_size) {

        av_log(s->avctx, AV_LOG_ERROR, "overread: %d\n", i - buf_size);

        s->bitstream_size  = 0;

        s->bitstream_index = 0;

        return AVERROR_INVALIDDATA;

    }

    if (s->bitstream_size) {

        s->bitstream_index += i;

        s->bitstream_size  -= i;

        return input_buf_size;

    } else

        return i;

}


lua_Integer luaV_idiv (lua_State *L, lua_Integer m, lua_Integer n) {
  if (unlikely(l_castS2U(n) + 1u <= 1u)) {  /* special cases: -1 or 0 */
    if (n == 0)
      luaG_runerror(L, "attempt to divide by zero");
    return intop(-, 0, m);   /* n==-1; avoid overflow with 0x80000...//-1 */
  }
  else {
    lua_Integer q = m / n;  /* perform C division */
    if ((m ^ n) < 0 && m % n != 0)  /* 'm/n' would be negative non-integer? */
      q -= 1;  /* correct result for different rounding */
    return q;
  }
}


fwrite_crypt(bufinfo_T *bi, char_u *ptr, size_t len)
{
#ifdef FEAT_CRYPT
    char_u  *copy;
    char_u  small_buf[100];
    size_t  i;

    if (bi->bi_state != NULL && bi->bi_buffer == NULL)
    {
	/* crypting every piece of text separately */
	if (len < 100)
	    copy = small_buf;  /* no malloc()/free() for short strings */
	else
	{
	    copy = lalloc(len, FALSE);
	    if (copy == NULL)
		return 0;
	}
	crypt_encode(bi->bi_state, ptr, len, copy);
	i = fwrite(copy, len, (size_t)1, bi->bi_fp);
	if (copy != small_buf)
	    vim_free(copy);
	return i == 1 ? OK : FAIL;
    }
#endif
    return undo_write(bi, ptr, len);
}


void TabHelper::SetAppIcon(const SkBitmap& app_icon) {
  extension_app_icon_ = app_icon;
  web_contents()->NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TITLE);
}


int wc_MakeNtruCert(Cert* cert, byte* derBuffer, word32 derSz,
                  const byte* ntruKey, word16 keySz, WC_RNG* rng)
{
    return MakeAnyCert(cert, derBuffer, derSz, NULL, NULL, rng, NULL,
            ntruKey, keySz, NULL, NULL);
}


void TensorSliceReader::LoadShard(int shard) const {
  CHECK_LT(shard, sss_.size());
  if (sss_[shard] || !status_.ok()) {
    return;  // Already loaded, or invalid.
  }
  string value;
  SavedTensorSlices sts;
  const string fname = fnames_[shard];
  VLOG(1) << "Reading meta data from file " << fname << "...";
  Table* table;
  Status s = open_function_(fname, &table);
  if (!s.ok()) {
    status_ = errors::DataLoss("Unable to open table file ", fname, ": ",
                               s.ToString());
    return;
  }
  sss_[shard].reset(table);
  if (!(table->Get(kSavedTensorSlicesKey, &value) &&
        ParseProtoUnlimited(&sts, value))) {
    status_ = errors::Internal(
        "Failed to find the saved tensor slices at the beginning of the "
        "checkpoint file: ",
        fname);
    return;
  }
  status_ = CheckVersions(sts.meta().versions(), TF_CHECKPOINT_VERSION,
                          TF_CHECKPOINT_VERSION_MIN_PRODUCER, "Checkpoint",
                          "checkpoint");
  if (!status_.ok()) return;
  for (const SavedSliceMeta& ssm : sts.meta().tensor()) {
    TensorShape ssm_shape;
    status_ = TensorShape::BuildTensorShapeBase(ssm.shape(), &ssm_shape);
    if (!status_.ok()) return;
    for (const TensorSliceProto& tsp : ssm.slice()) {
      TensorSlice ss_slice(tsp);
      status_ = RegisterTensorSlice(ssm.name(), ssm_shape, ssm.type(), fname,
                                    ss_slice, &tensors_);
      if (!status_.ok()) return;
    }
  }
}


bool DeviceOrientationController::isNullEvent(Event* event)
{
    DeviceOrientationEvent* orientationEvent = toDeviceOrientationEvent(event);
    return !orientationEvent->orientation()->canProvideEventData();
}


static void php_apache_request_dtor(request_rec *r TSRMLS_DC)
{
	php_request_shutdown(NULL);
}


static int validate_nan_filter(struct nlattr *filter_attr)
{
	struct nlattr *attr;
	int len = 0, n_entries = 0, rem;

	nla_for_each_nested(attr, filter_attr, rem) {
		len += nla_len(attr);
		n_entries++;
	}

	if (len >= U8_MAX)
		return -EINVAL;

	return n_entries;
}


int ib_send_cm_rej(struct ib_cm_id *cm_id,
		   enum ib_cm_rej_reason reason,
		   void *ari,
		   u8 ari_length,
		   const void *private_data,
		   u8 private_data_len)
{
	struct cm_id_private *cm_id_priv;
	struct ib_mad_send_buf *msg;
	unsigned long flags;
	int ret;

	if ((private_data && private_data_len > IB_CM_REJ_PRIVATE_DATA_SIZE) ||
	    (ari && ari_length > IB_CM_REJ_ARI_LENGTH))
		return -EINVAL;

	cm_id_priv = container_of(cm_id, struct cm_id_private, id);

	spin_lock_irqsave(&cm_id_priv->lock, flags);
	switch (cm_id->state) {
	case IB_CM_REQ_SENT:
	case IB_CM_MRA_REQ_RCVD:
	case IB_CM_REQ_RCVD:
	case IB_CM_MRA_REQ_SENT:
	case IB_CM_REP_RCVD:
	case IB_CM_MRA_REP_SENT:
		ret = cm_alloc_msg(cm_id_priv, &msg);
		if (!ret)
			cm_format_rej((struct cm_rej_msg *) msg->mad,
				      cm_id_priv, reason, ari, ari_length,
				      private_data, private_data_len);

		cm_reset_to_idle(cm_id_priv);
		break;
	case IB_CM_REP_SENT:
	case IB_CM_MRA_REP_RCVD:
		ret = cm_alloc_msg(cm_id_priv, &msg);
		if (!ret)
			cm_format_rej((struct cm_rej_msg *) msg->mad,
				      cm_id_priv, reason, ari, ari_length,
				      private_data, private_data_len);

		cm_enter_timewait(cm_id_priv);
		break;
	default:
		ret = -EINVAL;
		goto out;
	}

	if (ret)
		goto out;

	ret = ib_post_send_mad(msg, NULL);
	if (ret)
		cm_free_msg(msg);

out:	spin_unlock_irqrestore(&cm_id_priv->lock, flags);
	return ret;
}


static void thumbnail_cancel ( NautilusDirectory * directory ) {
 if ( directory -> details -> thumbnail_state != NULL ) {
 g_cancellable_cancel ( directory -> details -> thumbnail_state -> cancellable ) ;
 directory -> details -> thumbnail_state -> directory = NULL ;
 directory -> details -> thumbnail_state = NULL ;
 async_job_end ( directory , "thumbnail" ) ;
 }
 }


void LayerWebKitThread::setDrawable(bool isDrawable)
{
    if (m_isDrawable == isDrawable)
        return;

    m_isDrawable = isDrawable;

    setNeedsTexture(m_isDrawable && (drawsContent() || contents() || pluginView() || mediaPlayer()));
    setNeedsCommit();
}


static void TestEnumOrDoubleAttributeAttributeSetter(
    v8::Local<v8::Value> v8_value, const v8::FunctionCallbackInfo<v8::Value>& info) {
  v8::Isolate* isolate = info.GetIsolate();
  ALLOW_UNUSED_LOCAL(isolate);

  v8::Local<v8::Object> holder = info.Holder();
  ALLOW_UNUSED_LOCAL(holder);

  TestObject* impl = V8TestObject::ToImpl(holder);

  ExceptionState exception_state(isolate, ExceptionState::kSetterContext, "TestObject", "testEnumOrDoubleAttribute");

  TestEnumOrDouble cpp_value;
  V8TestEnumOrDouble::ToImpl(info.GetIsolate(), v8_value, cpp_value, UnionTypeConversionMode::kNotNullable, exception_state);
  if (exception_state.HadException())
    return;

  impl->setTestEnumOrDoubleAttribute(cpp_value);
}


long do_sigreturn(CPUX86State *env)

{

    struct sigframe *frame;

    abi_ulong frame_addr = env->regs[R_ESP] - 8;

    target_sigset_t target_set;

    sigset_t set;

    int eax, i;

#if defined(DEBUG_SIGNAL)

    fprintf(stderr, "do_sigreturn\n");

#endif

    if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1))

        goto badframe;

    /* set blocked signals */

    if (__get_user(target_set.sig[0], &frame->sc.oldmask))

        goto badframe;

    for(i = 1; i < TARGET_NSIG_WORDS; i++) {

        if (__get_user(target_set.sig[i], &frame->extramask[i - 1]))

            goto badframe;

    }

    target_to_host_sigset_internal(&set, &target_set);

    sigprocmask(SIG_SETMASK, &set, NULL);

    /* restore registers */

    if (restore_sigcontext(env, &frame->sc, &eax))

        goto badframe;

    unlock_user_struct(frame, frame_addr, 0);

    return eax;

badframe:

    unlock_user_struct(frame, frame_addr, 0);

    force_sig(TARGET_SIGSEGV);

    return 0;

}


lookup_header_set(struct ctl_table_root *root)
{
	struct ctl_table_set *set = &root->default_set;
	if (root->lookup)
		set = root->lookup(root);
	return set;
}


void HTMLLinkElement::LinkLoaded() {
  DispatchEvent(*Event::Create(EventTypeNames::load));
}


SWFInput_stream_getChar(SWFInput input)
{
	struct SWFInputStreamData *data = (struct SWFInputStreamData *) input->data;

	if (input->offset >= MAX_INPUTSTREAM)
		return EOF;

	if ( input->offset == input->length )
	{
		/* fetch from stream, save in buffer */

		FILE *f = data->file;
		int c = fgetc(f);

		++input->offset;

		if ( c != EOF )
		{
			if ( input->length % INPUTSTREAM_INCREMENT == 0 )
			{
				data->buffer = (unsigned char*) realloc(data->buffer,
															 sizeof(unsigned char) *
															 (input->length + INPUTSTREAM_INCREMENT));
			}

			data->buffer[input->length] = c;
			++input->length;
		}

		return c;
	}
	else if ( input->offset < input->length )
	{
		/* fetch from buffer */
		return data->buffer[input->offset++];
	}
	else
		return EOF;
}


static void lfe_downsample(DCAEncContext *c, const int32_t *input)

{

    /* FIXME: make 128x LFE downsampling possible */

    const int lfech = lfe_index[c->channel_config];

    int i, j, lfes;

    int32_t hist[512];

    int32_t accum;

    int hist_start = 0;

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

        hist[i] = c->history[i][c->channels - 1];

    for (lfes = 0; lfes < DCA_LFE_SAMPLES; lfes++) {

        /* Calculate the convolution */

        accum = 0;

        for (i = hist_start, j = 0; i < 512; i++, j++)

            accum += mul32(hist[i], lfe_fir_64i[j]);

        for (i = 0; i < hist_start; i++, j++)

            accum += mul32(hist[i], lfe_fir_64i[j]);

        c->downsampled_lfe[lfes] = accum;

        /* Copy in 64 new samples from input */

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

            hist[i + hist_start] = input[(lfes * 64 + i) * c->channels + lfech];

        hist_start = (hist_start + 64) & 511;

    }

}


static void set_root ( const char * path ) {
 # if ! defined ( __WIN__ ) if ( chroot ( path ) == - 1 ) {
 sql_perror ( "chroot" ) ;
 unireg_abort ( 1 ) ;
 }
 my_setwd ( "/" , MYF ( 0 ) ) ;
 # endif }


static void float32ArrayAttributeAttributeSetter(v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
{
    TestObjectPython* imp = V8TestObjectPython::toNative(info.Holder());
    V8TRYCATCH_VOID(Float32Array*, cppValue, jsValue->IsFloat32Array() ? V8Float32Array::toNative(v8::Handle<v8::Float32Array>::Cast(jsValue)) : 0);
    imp->setFloat32ArrayAttribute(WTF::getPtr(cppValue));
}


  switch (value) {
    case 3:
      sprintf((TNEF->priority), "high");
      break;
    case 2:
      sprintf((TNEF->priority), "normal");
      break;
    case 1:
      sprintf((TNEF->priority), "low");
      break;
    default:
      sprintf((TNEF->priority), "N/A");
      break;
  }


int mnt_fs_is_pseudofs(struct libmnt_fs *fs)
{
	return mnt_fs_get_flags(fs) & MNT_FS_PSEUDO;
}


findfilendir(
    typval_T	*argvars UNUSED,
    typval_T	*rettv,
    int		find_what UNUSED)
{
#ifdef FEAT_SEARCHPATH
    char_u	*fname;
    char_u	*fresult = NULL;
    char_u	*path = *curbuf->b_p_path == NUL ? p_path : curbuf->b_p_path;
    char_u	*p;
    char_u	pathbuf[NUMBUFLEN];
    int		count = 1;
    int		first = TRUE;
    int		error = FALSE;
#endif

    rettv->vval.v_string = NULL;
    rettv->v_type = VAR_STRING;

#ifdef FEAT_SEARCHPATH
    fname = tv_get_string(&argvars[0]);

    if (argvars[1].v_type != VAR_UNKNOWN)
    {
	p = tv_get_string_buf_chk(&argvars[1], pathbuf);
	if (p == NULL)
	    error = TRUE;
	else
	{
	    if (*p != NUL)
		path = p;

	    if (argvars[2].v_type != VAR_UNKNOWN)
		count = (int)tv_get_number_chk(&argvars[2], &error);
	}
    }

    if (count < 0 && rettv_list_alloc(rettv) == FAIL)
	error = TRUE;

    if (*fname != NUL && !error)
    {
	do
	{
	    if (rettv->v_type == VAR_STRING || rettv->v_type == VAR_LIST)
		vim_free(fresult);
	    fresult = find_file_in_path_option(first ? fname : NULL,
					       first ? (int)STRLEN(fname) : 0,
					0, first, path,
					find_what,
					curbuf->b_ffname,
					find_what == FINDFILE_DIR
					    ? (char_u *)"" : curbuf->b_p_sua);
	    first = FALSE;

	    if (fresult != NULL && rettv->v_type == VAR_LIST)
		list_append_string(rettv->vval.v_list, fresult, -1);

	} while ((rettv->v_type == VAR_LIST || --count > 0) && fresult != NULL);
    }

    if (rettv->v_type == VAR_STRING)
	rettv->vval.v_string = fresult;
#endif
}


static void account_freq_event(void)
{
	if (tick_nohz_full_enabled())
		account_freq_event_nohz();
	else
		atomic_inc(&nr_freq_events);
}


BackingStore* RenderWidgetHostViewAndroid::AllocBackingStore(
    const gfx::Size& size) {
  NOTIMPLEMENTED();
  return NULL;
}


static void sig_complete_window ( GList * * list , WINDOW_REC * window , const char * word , const char * linestart , int * want_space ) {
 WINDOW_REC * win ;
 WI_ITEM_REC * item ;
 GSList * tmp ;
 int len ;
 g_return_if_fail ( list != NULL ) ;
 g_return_if_fail ( word != NULL ) ;
 len = strlen ( word ) ;
 for ( tmp = windows ;
 tmp != NULL ;
 tmp = tmp -> next ) {
 win = tmp -> data ;
 item = win -> active ;
 if ( win -> name != NULL && g_ascii_strncasecmp ( win -> name , word , len ) == 0 ) * list = g_list_append ( * list , g_strdup ( win -> name ) ) ;
 if ( item != NULL && g_ascii_strncasecmp ( item -> visible_name , word , len ) == 0 ) * list = g_list_append ( * list , g_strdup ( item -> visible_name ) ) ;
 }
 if ( * list != NULL ) signal_stop ( ) ;
 }


static inline bool lockdep_softirq_start(void)
{
	bool in_hardirq = false;

	if (trace_hardirq_context(current)) {
		in_hardirq = true;
		trace_hardirq_exit();
	}

	lockdep_softirq_enter();

	return in_hardirq;
}


PJ_DEF(const char*) pj_ssl_curve_name(pj_ssl_curve curve)
{
    unsigned i;

    ssl_ciphers_populate();

    for (i = 0; i < ssl_curves_num; ++i) {
	if (curve == ssl_curves[i].id)
	    return ssl_curves[i].name;
    }

    return NULL;
}


int etm_perf_symlink(struct coresight_device *csdev, bool link)
{
	char entry[sizeof("cpu9999999")];
	int ret = 0, cpu = source_ops(csdev)->cpu_id(csdev);
	struct device *pmu_dev = etm_pmu.dev;
	struct device *cs_dev = &csdev->dev;

	sprintf(entry, "cpu%d", cpu);

	if (!etm_perf_up)
		return -EPROBE_DEFER;

	if (link) {
		ret = sysfs_create_link(&pmu_dev->kobj, &cs_dev->kobj, entry);
		if (ret)
			return ret;
		per_cpu(csdev_src, cpu) = csdev;
	} else {
		sysfs_remove_link(&pmu_dev->kobj, entry);
		per_cpu(csdev_src, cpu) = NULL;
	}

	return 0;
}


std::string normalize_path(const std::string &fpath)
{
	if (fpath.empty()) {
		return fpath;
	}

	return bfs::absolute(fpath).string();
}


win_valid_any_tab(win_T *win)
{
    win_T	*wp;
    tabpage_T	*tp;

    if (win == NULL)
	return FALSE;
    FOR_ALL_TABPAGES(tp)
    {
	FOR_ALL_WINDOWS_IN_TAB(tp, wp)
	{
	    if (wp == win)
		return TRUE;
	}
#ifdef FEAT_TEXT_PROP
	for (wp = tp->tp_first_popupwin; wp != NULL; wp = wp->w_next)
	    if (wp == win)
		return TRUE;
#endif
    }
    return win_valid_popup(win);
}


static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd)
{
	struct address_space *mapping = mpd->inode->i_mapping;
	struct pagevec pvec;
	unsigned int nr_pages;
	long left = mpd->wbc->nr_to_write;
	pgoff_t index = mpd->first_page;
	pgoff_t end = mpd->last_page;
	xa_mark_t tag;
	int i, err = 0;
	int blkbits = mpd->inode->i_blkbits;
	ext4_lblk_t lblk;
	struct buffer_head *head;

	if (mpd->wbc->sync_mode == WB_SYNC_ALL || mpd->wbc->tagged_writepages)
		tag = PAGECACHE_TAG_TOWRITE;
	else
		tag = PAGECACHE_TAG_DIRTY;

	pagevec_init(&pvec);
	mpd->map.m_len = 0;
	mpd->next_page = index;
	while (index <= end) {
		nr_pages = pagevec_lookup_range_tag(&pvec, mapping, &index, end,
				tag);
		if (nr_pages == 0)
			goto out;

		for (i = 0; i < nr_pages; i++) {
			struct page *page = pvec.pages[i];

			/*
			 * Accumulated enough dirty pages? This doesn't apply
			 * to WB_SYNC_ALL mode. For integrity sync we have to
			 * keep going because someone may be concurrently
			 * dirtying pages, and we might have synced a lot of
			 * newly appeared dirty pages, but have not synced all
			 * of the old dirty pages.
			 */
			if (mpd->wbc->sync_mode == WB_SYNC_NONE && left <= 0)
				goto out;

			/* If we can't merge this page, we are done. */
			if (mpd->map.m_len > 0 && mpd->next_page != page->index)
				goto out;

			lock_page(page);
			/*
			 * If the page is no longer dirty, or its mapping no
			 * longer corresponds to inode we are writing (which
			 * means it has been truncated or invalidated), or the
			 * page is already under writeback and we are not doing
			 * a data integrity writeback, skip the page
			 */
			if (!PageDirty(page) ||
			    (PageWriteback(page) &&
			     (mpd->wbc->sync_mode == WB_SYNC_NONE)) ||
			    unlikely(page->mapping != mapping)) {
				unlock_page(page);
				continue;
			}

			wait_on_page_writeback(page);
			BUG_ON(PageWriteback(page));

			if (mpd->map.m_len == 0)
				mpd->first_page = page->index;
			mpd->next_page = page->index + 1;
			/* Add all dirty buffers to mpd */
			lblk = ((ext4_lblk_t)page->index) <<
				(PAGE_SHIFT - blkbits);
			head = page_buffers(page);
			err = mpage_process_page_bufs(mpd, head, head, lblk);
			if (err <= 0)
				goto out;
			err = 0;
			left--;
		}
		pagevec_release(&pvec);
		cond_resched();
	}
	return 0;
out:
	pagevec_release(&pvec);
	return err;
}


bool DataReductionProxyConfig::AreProxiesBypassed(
    const net::ProxyRetryInfoMap& retry_map,
    const net::ProxyConfig::ProxyRules& proxy_rules,
    bool is_https,
    base::TimeDelta* min_retry_delay) const {
  if (proxy_rules.type != net::ProxyConfig::ProxyRules::Type::PROXY_LIST_PER_SCHEME)
    return false;

  if (is_https)
    return false;

  const net::ProxyList* proxies =
      proxy_rules.MapUrlSchemeToProxyList(url::kHttpScheme);

  if (!proxies)
    return false;

  base::TimeDelta min_delay = base::TimeDelta::Max();
  bool bypassed = false;

  for (const net::ProxyServer& proxy : proxies->GetAll()) {
    if (!proxy.is_valid() || proxy.is_direct())
      continue;

    base::TimeDelta delay;
    if (FindConfiguredDataReductionProxy(proxy)) {
      if (!IsProxyBypassed(retry_map, proxy, &delay))
        return false;
      if (delay < min_delay)
        min_delay = delay;
      bypassed = true;
    }
  }

  if (min_retry_delay && bypassed)
    *min_retry_delay = min_delay;

  return bypassed;
}


 */
bool netdev_has_any_upper_dev(struct net_device *dev)
{
	ASSERT_RTNL();

	return !list_empty(&dev->adj_list.upper);


void HeapAllocator::backingFree(void* address) {
  if (!address)
    return;

  ThreadState* state = ThreadState::current();
  if (state->sweepForbidden())
    return;
  ASSERT(!state->isInGC());

  BasePage* page = pageFromObject(address);
  if (page->isLargeObjectPage() || page->arena()->getThreadState() != state)
     return;

   HeapObjectHeader* header = HeapObjectHeader::fromPayload(address);
  header->checkHeader();
   NormalPageArena* arena = static_cast<NormalPage*>(page)->arenaForNormalPage();
   state->promptlyFreed(header->gcInfoIndex());
   arena->promptlyFreeObject(header);
}


int test ( char * URL ) {
 int i ;
 ( void ) URL ;
 for ( i = 0 ;
 dates [ i ] ;
 i ++ ) {
 printf ( "%d: %s => %ld\n" , i , dates [ i ] , ( long ) curl_getdate ( dates [ i ] , NULL ) ) ;
 }
 return 0 ;
 }


WebView* RenderViewImpl::createView(
    WebFrame* creator,
    const WebURLRequest& request,
    const WebWindowFeatures& features,
    const WebString& frame_name,
    WebNavigationPolicy policy) {
  if (shared_popup_counter_->data > kMaximumNumberOfUnacknowledgedPopups)
    return NULL;

  ViewHostMsg_CreateWindow_Params params;
  params.opener_id = routing_id_;
  params.user_gesture = creator->isProcessingUserGesture();
  params.window_container_type = WindowFeaturesToContainerType(features);
  params.session_storage_namespace_id = session_storage_namespace_id_;
   params.frame_name = frame_name;
   params.opener_frame_id = creator->identifier();
   params.opener_url = creator->document().url();
  GURL security_url(creator->document().securityOrigin().toString().utf8());
  if (!security_url.is_valid())
    security_url = GURL();
  params.opener_security_origin = security_url;
   params.opener_suppressed = creator->willSuppressOpenerInNewFrame();
   params.disposition = NavigationPolicyToDisposition(policy);
   if (!request.isNull())
    params.target_url = request.url();

  int32 routing_id = MSG_ROUTING_NONE;
  int32 surface_id = 0;
  int64 cloned_session_storage_namespace_id;

  RenderThread::Get()->Send(
      new ViewHostMsg_CreateWindow(params,
                                   &routing_id,
                                   &surface_id,
                                   &cloned_session_storage_namespace_id));
  if (routing_id == MSG_ROUTING_NONE)
    return NULL;

  creator->consumeUserGesture();

  RenderViewImpl* view = RenderViewImpl::Create(
      routing_id_,
      renderer_preferences_,
      webkit_preferences_,
      shared_popup_counter_,
      routing_id,
      surface_id,
      cloned_session_storage_namespace_id,
      frame_name,
      true,
      false,
      1,
      screen_info_,
      accessibility_mode_);
  view->opened_by_user_gesture_ = params.user_gesture;

  view->opener_suppressed_ = params.opener_suppressed;

  view->alternate_error_page_url_ = alternate_error_page_url_;

  return view->webview();
}


void ptirq_remove_configured_intx_remappings(const struct acrn_vm *vm)
{
	const struct acrn_vm_config *vm_config = get_vm_config(vm->vm_id);
	uint32_t i;

	for (i = 0; i < vm_config->pt_intx_num; i++) {
		ptirq_remove_intx_remapping(vm, vm_config->pt_intx[i].virt_gsi, false);
	}
}


int trace_find_tgid(int pid)
{
	if (unlikely(!tgid_map || !pid || pid > PID_MAX_DEFAULT))
		return 0;

	return tgid_map[pid];
}


char * curl_escape ( const char * string , int inlength ) {
 return curl_easy_escape ( NULL , string , inlength ) ;
 }