int security_bounded_transition(u32 old_sid, u32 new_sid)
{
	struct context *old_context, *new_context;
	struct type_datum *type;
	int index;
	int rc;

	read_lock(&policy_rwlock);

	rc = -EINVAL;
	old_context = sidtab_search(&sidtab, old_sid);
	if (!old_context) {
		printk(KERN_ERR "SELinux: %s: unrecognized SID %u\n",
		       __func__, old_sid);
		goto out;
	}

	rc = -EINVAL;
	new_context = sidtab_search(&sidtab, new_sid);
	if (!new_context) {
		printk(KERN_ERR "SELinux: %s: unrecognized SID %u\n",
		       __func__, new_sid);
		goto out;
	}

	rc = 0;
	/* type/domain unchanged */
	if (old_context->type == new_context->type)
		goto out;

	index = new_context->type;
	while (true) {
		type = flex_array_get_ptr(policydb.type_val_to_struct_array,
					  index - 1);
		BUG_ON(!type);

		/* not bounded anymore */
		rc = -EPERM;
		if (!type->bounds)
			break;

		/* @newsid is bounded by @oldsid */
		rc = 0;
		if (type->bounds == old_context->type)
			break;

		index = type->bounds;
	}

	if (rc) {
		char *old_name = NULL;
		char *new_name = NULL;
		u32 length;

		if (!context_struct_to_string(old_context,
					      &old_name, &length) &&
		    !context_struct_to_string(new_context,
					      &new_name, &length)) {
			audit_log(current->audit_context,
				  GFP_ATOMIC, AUDIT_SELINUX_ERR,
				  "op=security_bounded_transition "
				  "result=denied "
				  "oldcontext=%s newcontext=%s",
				  old_name, new_name);
		}
		kfree(new_name);
		kfree(old_name);
	}
out:
	read_unlock(&policy_rwlock);

	return rc;
}


AP_DECLARE(const char *) ap_get_remote_logname(request_rec *r)
{
    if (r->connection->remote_logname != NULL) {
        return r->connection->remote_logname;
    }

    if (ident_lookup) {
        return ident_lookup(r);
    }

    return NULL;
}


nv_abbrev(cmdarg_T *cap)
{
    if (cap->cmdchar == K_DEL || cap->cmdchar == K_KDEL)
	cap->cmdchar = 'x';		// DEL key behaves like 'x'

    // in Visual mode these commands are operators
    if (VIsual_active)
	v_visop(cap);
    else
	nv_optrans(cap);
}


static void _slurm_rpc_resv_update ( slurm_msg_t * msg ) {
 int error_code = SLURM_SUCCESS ;
 DEF_TIMERS ;
 resv_desc_msg_t * resv_desc_ptr = ( resv_desc_msg_t * ) msg -> data ;
 slurmctld_lock_t node_write_lock = {
 READ_LOCK , READ_LOCK , WRITE_LOCK , READ_LOCK , NO_LOCK }
 ;
 uid_t uid = g_slurm_auth_get_uid ( msg -> auth_cred , slurmctld_config . auth_info ) ;
 START_TIMER ;
 debug2 ( "Processing RPC: REQUEST_UPDATE_RESERVATION from uid=%d" , uid ) ;
 if ( ! validate_operator ( uid ) ) {
 error_code = ESLURM_USER_ID_MISSING ;
 error ( "Security violation, UPDATE_RESERVATION RPC from uid=%d" , uid ) ;
 }
 if ( error_code == SLURM_SUCCESS ) {
 lock_slurmctld ( node_write_lock ) ;
 error_code = update_resv ( resv_desc_ptr ) ;
 unlock_slurmctld ( node_write_lock ) ;
 END_TIMER2 ( "_slurm_rpc_resv_update" ) ;
 }
 if ( error_code ) {
 info ( "_slurm_rpc_resv_update reservation=%s: %s" , resv_desc_ptr -> name , slurm_strerror ( error_code ) ) ;
 slurm_send_rc_msg ( msg , error_code ) ;
 }
 else {
 debug2 ( "_slurm_rpc_resv_update complete for %s %s" , resv_desc_ptr -> name , TIME_STR ) ;
 slurm_send_rc_msg ( msg , SLURM_SUCCESS ) ;
 queue_job_scheduler ( ) ;
 }
 }


gadgetfs_disconnect (struct usb_gadget *gadget)
{
	struct dev_data		*dev = get_gadget_data (gadget);
	unsigned long		flags;

	spin_lock_irqsave (&dev->lock, flags);
	if (dev->state == STATE_DEV_UNCONNECTED)
		goto exit;
	dev->state = STATE_DEV_UNCONNECTED;

	INFO (dev, "disconnected\n");
	next_event (dev, GADGETFS_DISCONNECT);
	ep0_readable (dev);
exit:
	spin_unlock_irqrestore (&dev->lock, flags);
}


void blk_mq_start_hw_queue(struct blk_mq_hw_ctx *hctx)
{
	clear_bit(BLK_MQ_S_STOPPED, &hctx->state);

	blk_mq_run_hw_queue(hctx, false);
}


void TestRenderFrame::SetEditableSelectionOffsets(int start, int end) {
  GetFrameInputHandler()->SetEditableSelectionOffsets(start, end);
}


static ssize_t v1f_read ( const struct vfp_ctx * vc , struct http_conn * htc , void * d , ssize_t len ) {
 ssize_t l ;
 unsigned char * p ;
 ssize_t i = 0 ;
 CHECK_OBJ_NOTNULL ( vc , VFP_CTX_MAGIC ) ;
 CHECK_OBJ_NOTNULL ( htc , HTTP_CONN_MAGIC ) ;
 assert ( len > 0 ) ;
 l = 0 ;
 p = d ;
 if ( htc -> pipeline_b ) {
 l = htc -> pipeline_e - htc -> pipeline_b ;
 assert ( l > 0 ) ;
 if ( l > len ) l = len ;
 memcpy ( p , htc -> pipeline_b , l ) ;
 p += l ;
 len -= l ;
 htc -> pipeline_b += l ;
 if ( htc -> pipeline_b == htc -> pipeline_e ) htc -> pipeline_b = htc -> pipeline_e = NULL ;
 }
 if ( len > 0 ) {
 i = read ( * htc -> rfd , p , len ) ;
 if ( i < 0 ) {
 VSLb ( vc -> wrk -> vsl , SLT_FetchError , "%s" , strerror ( errno ) ) ;
 return ( i ) ;
 }
 }
 return ( i + l ) ;
 }


void MediaStreamDevicesController::NotifyUIRequestDenied() const {
  if (!content_settings_)
    return;

  if (request_.audio_type == content::MEDIA_TAB_AUDIO_CAPTURE ||
      request_.video_type == content::MEDIA_TAB_VIDEO_CAPTURE) {
      return;
  }

  if (request_.audio_type == content::MEDIA_DEVICE_AUDIO_CAPTURE)
    content_settings_->OnMicrophoneAccessBlocked();
  if (request_.video_type == content::MEDIA_DEVICE_VIDEO_CAPTURE)
    content_settings_->OnCameraAccessBlocked();
}


static u32 map_id_up(struct uid_gid_map *map, u32 id)
{
	struct uid_gid_extent *extent;
	unsigned extents = map->nr_extents;
	smp_rmb();

	if (extents <= UID_GID_MAP_MAX_BASE_EXTENTS)
		extent = map_id_up_base(extents, map, id);
	else
		extent = map_id_up_max(extents, map, id);

	/* Map the id or note failure */
	if (extent)
		id = (id - extent->lower_first) + extent->first;
	else
		id = (u32) -1;

	return id;
}


expr_value_type_to_string(enum expr_value_type type)
{
    if (type >= _EXPR_TYPE_NUM_VALUES)
        return NULL;
    return expr_value_type_strings[type];
}


nm_device_ipv6_sysctl_set (NMDevice *self, const char *property, const char *value)
{
	return nm_platform_sysctl_set (nm_utils_ip6_property_path (nm_device_get_ip_iface (self), property), value);
 	return nm_platform_sysctl_set (nm_utils_ip6_property_path (nm_device_get_ip_iface (self), property), value);
 }


static int fd_compat_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd,
		    unsigned long param)
{
	int drive = (long)bdev->bd_disk->private_data;
	switch (cmd) {
	case CDROMEJECT: /* CD-ROM eject */
	case 0x6470:	 /* SunOS floppy eject */

	case FDMSGON:
	case FDMSGOFF:
	case FDSETEMSGTRESH:
	case FDFLUSH:
	case FDWERRORCLR:
	case FDEJECT:
	case FDCLRPRM:
	case FDFMTBEG:
	case FDRESET:
	case FDTWADDLE:
		return fd_ioctl(bdev, mode, cmd, param);
	case FDSETMAXERRS:
	case FDGETMAXERRS:
	case FDGETDRVTYP:
	case FDFMTEND:
	case FDFMTTRK:
	case FDRAWCMD:
		return fd_ioctl(bdev, mode, cmd,
				(unsigned long)compat_ptr(param));
	case FDSETPRM32:
	case FDDEFPRM32:
		return compat_set_geometry(bdev, mode, cmd, compat_ptr(param));
	case FDGETPRM32:
		return compat_get_prm(drive, compat_ptr(param));
	case FDSETDRVPRM32:
		return compat_setdrvprm(drive, compat_ptr(param));
	case FDGETDRVPRM32:
		return compat_getdrvprm(drive, compat_ptr(param));
	case FDPOLLDRVSTAT32:
		return compat_getdrvstat(drive, true, compat_ptr(param));
	case FDGETDRVSTAT32:
		return compat_getdrvstat(drive, false, compat_ptr(param));
	case FDGETFDCSTAT32:
		return compat_getfdcstat(drive, compat_ptr(param));
	case FDWERRORGET32:
		return compat_werrorget(drive, compat_ptr(param));
	}
	return -EINVAL;
}


void helper_done(CPUSPARCState *env)

{

    trap_state *tsptr = cpu_tsptr(env);

    env->pc = tsptr->tnpc;

    env->npc = tsptr->tnpc + 4;

    cpu_put_ccr(env, tsptr->tstate >> 32);

    env->asi = (tsptr->tstate >> 24) & 0xff;

    cpu_change_pstate(env, (tsptr->tstate >> 8) & 0xf3f);

    cpu_put_cwp64(env, tsptr->tstate & 0xff);

    if (cpu_has_hypervisor(env)) {

        uint32_t new_gl = (tsptr->tstate >> 40) & 7;

        env->hpstate = env->htstate[env->tl];

        cpu_gl_switch_gregs(env, new_gl);

        env->gl = new_gl;

    }

    env->tl--;

    trace_win_helper_done(env->tl);

#if !defined(CONFIG_USER_ONLY)

    if (cpu_interrupts_enabled(env)) {

        cpu_check_irqs(env);

    }

#endif

}


void ff_avg_h264_qpel16_mc33_msa(uint8_t *dst, const uint8_t *src,

                                 ptrdiff_t stride)

{

    avc_luma_hv_qrt_and_aver_dst_16x16_msa(src + stride - 2,

                                           src - (stride * 2) +

                                           sizeof(uint8_t), stride,

                                           dst, stride);

}


static void virtser_port_device_unrealize(DeviceState *dev, Error **errp)
{
    VirtIOSerialPort *port = VIRTIO_SERIAL_PORT(dev);
    VirtIOSerialPortClass *vsc = VIRTIO_SERIAL_PORT_GET_CLASS(dev);
    VirtIOSerial *vser = port->vser;

    qemu_bh_delete(port->bh);
    remove_port(port->vser, port->id);

    QTAILQ_REMOVE(&vser->ports, port, next);

    if (vsc->unrealize) {
        vsc->unrealize(dev, errp);
    }
}


static inline void perf_read_regs(struct pt_regs *regs)
{
	regs->dsisr = mfspr(SPRN_MMCRA);
}


bool RunIdentifySystem ( PGconn * conn , char * * sysid , TimeLineID * starttli , XLogRecPtr * startpos , char * * db_name ) {
 PGresult * res ;
 uint32 hi , lo ;
 Assert ( conn != NULL ) ;
 res = PQexec ( conn , "IDENTIFY_SYSTEM" ) ;
 if ( PQresultStatus ( res ) != PGRES_TUPLES_OK ) {
 fprintf ( stderr , _ ( "%s: could not send replication command \"%s\": %s" ) , progname , "IDENTIFY_SYSTEM" , PQerrorMessage ( conn ) ) ;
 PQclear ( res ) ;
 return false ;
 }
 if ( PQntuples ( res ) != 1 || PQnfields ( res ) < 3 ) {
 fprintf ( stderr , _ ( "%s: could not identify system: got %d rows and %d fields, expected %d rows and %d or more fields\n" ) , progname , PQntuples ( res ) , PQnfields ( res ) , 1 , 3 ) ;
 PQclear ( res ) ;
 return false ;
 }
 if ( sysid != NULL ) * sysid = pg_strdup ( PQgetvalue ( res , 0 , 0 ) ) ;
 if ( starttli != NULL ) * starttli = atoi ( PQgetvalue ( res , 0 , 1 ) ) ;
 if ( startpos != NULL ) {
 if ( sscanf ( PQgetvalue ( res , 0 , 2 ) , "%X/%X" , & hi , & lo ) != 2 ) {
 fprintf ( stderr , _ ( "%s: could not parse transaction log location \"%s\"\n" ) , progname , PQgetvalue ( res , 0 , 2 ) ) ;
 PQclear ( res ) ;
 return false ;
 }
 * startpos = ( ( uint64 ) hi ) << 32 | lo ;
 }
 if ( db_name != NULL ) {
 * db_name = NULL ;
 if ( PQserverVersion ( conn ) >= 90400 ) {
 if ( PQnfields ( res ) < 4 ) {
 fprintf ( stderr , _ ( "%s: could not identify system: got %d rows and %d fields, expected %d rows and %d or more fields\n" ) , progname , PQntuples ( res ) , PQnfields ( res ) , 1 , 4 ) ;
 PQclear ( res ) ;
 return false ;
 }
 if ( ! PQgetisnull ( res , 0 , 3 ) ) * db_name = pg_strdup ( PQgetvalue ( res , 0 , 3 ) ) ;
 }
 }
 PQclear ( res ) ;
 return true ;
 }


static char *addr_to_string(const char *format,
                            struct sockaddr_storage *sa,
                            socklen_t salen) {
    char *addr;
    char host[NI_MAXHOST];
    char serv[NI_MAXSERV];
    int err;
    size_t addrlen;

    if ((err = getnameinfo((struct sockaddr *)sa, salen,
                           host, sizeof(host),
                           serv, sizeof(serv),
                           NI_NUMERICHOST | NI_NUMERICSERV)) != 0) {
        VNC_DEBUG("Cannot resolve address %d: %s\n",
                  err, gai_strerror(err));
        return NULL;
    }

    /* Enough for the existing format + the 2 vars we're
     * substituting in. */
    addrlen = strlen(format) + strlen(host) + strlen(serv);
    addr = g_malloc(addrlen + 1);
    snprintf(addr, addrlen, format, host, serv);
    addr[addrlen] = '\0';

    return addr;
}


void BluetoothAdapter::NotifyDeviceBatteryChanged(BluetoothDevice* device) {
  DCHECK_EQ(device->GetAdapter(), this);
  for (auto& observer : observers_) {
    observer.DeviceBatteryChanged(this, device, device->battery_percentage());
  }
}


static void  opj_j2k_read_float32_to_float(const void * p_src_data,
        void * p_dest_data, OPJ_UINT32 p_nb_elem)
{
    OPJ_BYTE * l_src_data = (OPJ_BYTE *) p_src_data;
    OPJ_FLOAT32 * l_dest_data = (OPJ_FLOAT32 *) p_dest_data;
    OPJ_UINT32 i;
    OPJ_FLOAT32 l_temp;

    for (i = 0; i < p_nb_elem; ++i) {
        opj_read_float(l_src_data, &l_temp);

        l_src_data += sizeof(OPJ_FLOAT32);

        *(l_dest_data++) = l_temp;
    }
}


void check_tmp_dir(){
#if !defined(WIN32)
	if (!RmFlag) return;

	const char *tmpDir = NULL;
	bool newLock = param_boolean("CREATE_LOCKS_ON_LOCAL_DISK", true);
	if (newLock) {
		FileLock *lock = new FileLock(-1, NULL, NULL);
		tmpDir = lock->GetTempPath();
		delete lock;
		rec_lock_cleanup(tmpDir, 3);
		if (tmpDir != NULL)
			delete []tmpDir;
	}

#endif
}


static int init_suite1(void) { return 0; }


void HTMLMediaElement::setReadyState(ReadyState state) {
  BLINK_MEDIA_LOG << "setReadyState(" << (void*)this << ", "
                  << static_cast<int>(state) << ") - current state is "
                  << static_cast<int>(m_readyState);

  bool wasPotentiallyPlaying = potentiallyPlaying();

  ReadyState oldState = m_readyState;
  ReadyState newState = state;

  bool tracksAreReady = textTracksAreReady();

  if (newState == oldState && m_tracksAreReady == tracksAreReady)
    return;

  m_tracksAreReady = tracksAreReady;

  if (tracksAreReady) {
    m_readyState = newState;
  } else {
    if (newState <= kHaveMetadata)
      m_readyState = newState;
    else
      m_readyState = kHaveCurrentData;
  }

  if (oldState > m_readyStateMaximum)
    m_readyStateMaximum = oldState;

  if (m_networkState == kNetworkEmpty)
    return;

  if (m_seeking) {
    if (wasPotentiallyPlaying && m_readyState < kHaveFutureData)
      scheduleEvent(EventTypeNames::waiting);

    if (m_readyState >= kHaveCurrentData)
      finishSeek();
  } else {
    if (wasPotentiallyPlaying && m_readyState < kHaveFutureData) {
      setOfficialPlaybackPosition(currentPlaybackPosition());

      scheduleTimeupdateEvent(false);
      scheduleEvent(EventTypeNames::waiting);
    }
  }

  if (m_readyState >= kHaveMetadata && oldState < kHaveMetadata) {
    createPlaceholderTracksIfNecessary();

    selectInitialTracksIfNecessary();

    MediaFragmentURIParser fragmentParser(m_currentSrc);
    m_fragmentEndTime = fragmentParser.endTime();

    setOfficialPlaybackPosition(earliestPossiblePosition());

    m_duration = m_webMediaPlayer->duration();
    scheduleEvent(EventTypeNames::durationchange);

    if (isHTMLVideoElement())
      scheduleEvent(EventTypeNames::resize);
    scheduleEvent(EventTypeNames::loadedmetadata);

    bool jumped = false;
    if (m_defaultPlaybackStartPosition > 0) {
      seek(m_defaultPlaybackStartPosition);
      jumped = true;
    }
    m_defaultPlaybackStartPosition = 0;

    double initialPlaybackPosition = fragmentParser.startTime();
    if (std::isnan(initialPlaybackPosition))
      initialPlaybackPosition = 0;

    if (!jumped && initialPlaybackPosition > 0) {
      UseCounter::count(document(),
                        UseCounter::HTMLMediaElementSeekToFragmentStart);
      seek(initialPlaybackPosition);
      jumped = true;
    }

    if (layoutObject())
      layoutObject()->updateFromElement();
  }

  bool shouldUpdateDisplayState = false;

  if (m_readyState >= kHaveCurrentData && oldState < kHaveCurrentData &&
      !m_haveFiredLoadedData) {
    setOfficialPlaybackPosition(currentPlaybackPosition());

    m_haveFiredLoadedData = true;
    shouldUpdateDisplayState = true;
    scheduleEvent(EventTypeNames::loadeddata);
    setShouldDelayLoadEvent(false);
  }

  bool isPotentiallyPlaying = potentiallyPlaying();
  if (m_readyState == kHaveFutureData && oldState <= kHaveCurrentData &&
      tracksAreReady) {
    scheduleEvent(EventTypeNames::canplay);
    if (isPotentiallyPlaying)
      scheduleNotifyPlaying();
    shouldUpdateDisplayState = true;
  }

  if (m_readyState == kHaveEnoughData && oldState < kHaveEnoughData &&
      tracksAreReady) {
    if (oldState <= kHaveCurrentData) {
      scheduleEvent(EventTypeNames::canplay);
      if (isPotentiallyPlaying)
        scheduleNotifyPlaying();
    }

    if (shouldAutoplay()) {
      m_autoplayUmaHelper->onAutoplayInitiated(AutoplaySource::Attribute);

      if (!isGestureNeededForPlayback()) {
        if (isGestureNeededForPlaybackIfCrossOriginExperimentEnabled()) {
          m_autoplayUmaHelper->recordCrossOriginAutoplayResult(
              CrossOriginAutoplayResult::AutoplayBlocked);
        } else {
          m_autoplayUmaHelper->recordCrossOriginAutoplayResult(
              CrossOriginAutoplayResult::AutoplayAllowed);
        }
        if (isHTMLVideoElement() && muted() &&
            RuntimeEnabledFeatures::autoplayMutedVideosEnabled()) {
          if (!m_autoplayVisibilityObserver) {
            m_autoplayVisibilityObserver = new ElementVisibilityObserver(
                this,
                WTF::bind(&HTMLMediaElement::onVisibilityChangedForAutoplay,
                          wrapWeakPersistent(this)));
            m_autoplayVisibilityObserver->start();
          }
        } else {
          m_paused = false;
          scheduleEvent(EventTypeNames::play);
          scheduleNotifyPlaying();
          m_autoplaying = false;
        }
      } else {
        m_autoplayUmaHelper->recordCrossOriginAutoplayResult(
            CrossOriginAutoplayResult::AutoplayBlocked);
      }
    }

    scheduleEvent(EventTypeNames::canplaythrough);

    shouldUpdateDisplayState = true;
  }

  if (shouldUpdateDisplayState)
    updateDisplayState();

  updatePlayState();
  cueTimeline().updateActiveCues(currentTime());
}


      static double mp_vector_init(_cimg_math_parser& mp) {
        unsigned int
          ptrs = 4U,
          ptrd = (unsigned int)mp.opcode[1] + 1,
          siz = (unsigned int)mp.opcode[3];
        switch (mp.opcode[2] - 4) {
        case 0 : std::memset(mp.mem._data + ptrd,0,siz*sizeof(double)); break; // 0 values given
        case 1 : { const double val = _mp_arg(ptrs); while (siz-->0) mp.mem[ptrd++] = val; } break;
        default : while (siz-->0) { mp.mem[ptrd++] = _mp_arg(ptrs++); if (ptrs>=mp.opcode[2]) ptrs = 4U; }
        }
        return cimg::type<double>::nan();


static void handle_RNFR(ctrl_t *ctrl, char *arg)
{
}


DOMString getElementValue(IXML_Node *node)
{
	IXML_Node *child = (IXML_Node *)ixmlNode_getFirstChild(node);
	const DOMString temp = NULL;

	if (child && ixmlNode_getNodeType(child) == eTEXT_NODE) {
		temp = ixmlNode_getNodeValue(child);

		return ixmlCloneDOMString(temp);
	} else {
		return NULL;
	}
}


static uint32_t getHostID ( const ILcidPosixMap * this_0 , const char * posixID , UErrorCode * status ) {
 int32_t bestIdx = 0 ;
 int32_t bestIdxDiff = 0 ;
 int32_t posixIDlen = ( int32_t ) uprv_strlen ( posixID ) ;
 uint32_t idx ;
 for ( idx = 0 ;
 idx < this_0 -> numRegions ;
 idx ++ ) {
 int32_t sameChars = idCmp ( posixID , this_0 -> regionMaps [ idx ] . posixID ) ;
 if ( sameChars > bestIdxDiff && this_0 -> regionMaps [ idx ] . posixID [ sameChars ] == 0 ) {
 if ( posixIDlen == sameChars ) {
 return this_0 -> regionMaps [ idx ] . hostID ;
 }
 bestIdxDiff = sameChars ;
 bestIdx = idx ;
 }
 }
 if ( ( posixID [ bestIdxDiff ] == '_' || posixID [ bestIdxDiff ] == '@' ) && this_0 -> regionMaps [ bestIdx ] . posixID [ bestIdxDiff ] == 0 ) {
 * status = U_USING_FALLBACK_WARNING ;
 return this_0 -> regionMaps [ bestIdx ] . hostID ;
 }
 * status = U_ILLEGAL_ARGUMENT_ERROR ;
 return this_0 -> regionMaps -> hostID ;
 }


static void sig_server_reconnect_removed ( RECONNECT_REC * reconnect ) {
 g_return_if_fail ( reconnect != NULL ) ;
 printformat ( NULL , NULL , MSGLEVEL_CLIENTNOTICE , TXT_RECONNECT_REMOVED , reconnect -> conn -> address , reconnect -> conn -> port , reconnect -> conn -> chatnet == NULL ? "" : reconnect -> conn -> chatnet ) ;
 }


static void reflectedClassAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
{
    TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter");
    CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope;
    TestObjectPythonV8Internal::reflectedClassAttributeSetter(jsValue, info);
    TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
}


void RenderViewImpl::Repaint(const gfx::Size& size) {
  OnRepaint(size);
}


static int create_window_attributes(NPSetWindowCallbackStruct *ws_info)
{
  if (ws_info == NULL)
	return -1;
  GdkVisual *gdk_visual;
  if (ws_info->visual)
	gdk_visual = gdkx_visual_get((uintptr_t)ws_info->visual);
  else
	gdk_visual = gdk_visual_get_system();
  if (gdk_visual == NULL) {
	npw_printf("ERROR: could not reconstruct XVisual from visualID\n");
	return -2;
  }
  ws_info->display = x_display;
  ws_info->visual = gdk_x11_visual_get_xvisual(gdk_visual);
  return 0;
}


static int __init fscrypt_init(void)
{
	fscrypt_read_workqueue = alloc_workqueue("fscrypt_read_queue",
							WQ_HIGHPRI, 0);
	if (!fscrypt_read_workqueue)
		goto fail;

	fscrypt_ctx_cachep = KMEM_CACHE(fscrypt_ctx, SLAB_RECLAIM_ACCOUNT);
	if (!fscrypt_ctx_cachep)
		goto fail_free_queue;

	fscrypt_info_cachep = KMEM_CACHE(fscrypt_info, SLAB_RECLAIM_ACCOUNT);
	if (!fscrypt_info_cachep)
		goto fail_free_ctx;

	return 0;

fail_free_ctx:
	kmem_cache_destroy(fscrypt_ctx_cachep);
fail_free_queue:
	destroy_workqueue(fscrypt_read_workqueue);
fail:
	return -ENOMEM;
}


void GLES2DecoderImpl::DoCompileShader(GLuint client_id) {
  TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCompileShader");
  Shader* shader = GetShaderInfoNotProgram(client_id, "glCompileShader");
  if (!shader) {
    return;
  }

  scoped_refptr<ShaderTranslatorInterface> translator;
  if (!feature_info_->disable_shader_translator())
    translator = GetOrCreateTranslator(shader->shader_type());

  const Shader::TranslatedShaderSourceType source_type =
      feature_info_->feature_flags().angle_translated_shader_source ?
      Shader::kANGLE : Shader::kGL;
  shader->RequestCompile(translator, source_type);
}


AP_DECLARE(request_rec *) ap_sub_req_lookup_dirent(const apr_finfo_t *dirent,
                                                   const request_rec *r,
                                                   int subtype,
                                                   ap_filter_t *next_filter)
{
    request_rec *rnew;
    int res;
    char *fdir;
    char *udir;

    rnew = make_sub_request(r, next_filter);

    /* Special case: we are looking at a relative lookup in the same directory.
     * This is 100% safe, since dirent->name just came from the filesystem.
     */
    if (r->path_info && *r->path_info) {
        /* strip path_info off the end of the uri to keep it in sync
         * with r->filename, which has already been stripped by directory_walk,
         * merge the dirent->name, and then, if the caller wants us to remerge
         * the original path info, do so.  Note we never fix the path_info back
         * to r->filename, since dir_walk would do so (but we don't expect it
         * to happen in the usual cases)
         */
        udir = apr_pstrdup(rnew->pool, r->uri);
        udir[ap_find_path_info(udir, r->path_info)] = '\0';
        udir = ap_make_dirstr_parent(rnew->pool, udir);

        rnew->uri = ap_make_full_path(rnew->pool, udir, dirent->name);
        if (subtype == AP_SUBREQ_MERGE_ARGS) {
            rnew->uri = ap_make_full_path(rnew->pool, rnew->uri, r->path_info + 1);
            rnew->path_info = apr_pstrdup(rnew->pool, r->path_info);
        }
        rnew->uri = ap_escape_uri(rnew->pool, rnew->uri);
    }
    else {
        udir = ap_make_dirstr_parent(rnew->pool, r->uri);
        rnew->uri = ap_escape_uri(rnew->pool, ap_make_full_path(rnew->pool,
                                                                udir,
                                                                dirent->name));
    }

    fdir = ap_make_dirstr_parent(rnew->pool, r->filename);
    rnew->filename = ap_make_full_path(rnew->pool, fdir, dirent->name);
    if (r->canonical_filename == r->filename) {
        rnew->canonical_filename = rnew->filename;
    }

    /* XXX This is now less relevant; we will do a full location walk
     * these days for this case.  Preserve the apr_stat results, and
     * perhaps we also tag that symlinks were tested and/or found for
     * r->filename.
     */
    rnew->per_dir_config = r->server->lookup_defaults;

    if ((dirent->valid & APR_FINFO_MIN) != APR_FINFO_MIN) {
        /*
         * apr_dir_read isn't very complete on this platform, so
         * we need another apr_stat (with or without APR_FINFO_LINK
         * depending on whether we allow all symlinks here.)  If this
         * is an APR_LNK that resolves to an APR_DIR, then we will rerun
         * everything anyways... this should be safe.
         */
        apr_status_t rv;
        if (ap_allow_options(rnew) & OPT_SYM_LINKS) {
            if (((rv = apr_stat(&rnew->finfo, rnew->filename,
                                APR_FINFO_MIN, rnew->pool)) != APR_SUCCESS)
                && (rv != APR_INCOMPLETE)) {
                rnew->finfo.filetype = APR_NOFILE;
            }
        }
        else {
            if (((rv = apr_stat(&rnew->finfo, rnew->filename,
                                APR_FINFO_LINK | APR_FINFO_MIN,
                                rnew->pool)) != APR_SUCCESS)
                && (rv != APR_INCOMPLETE)) {
                rnew->finfo.filetype = APR_NOFILE;
            }
        }
    }
    else {
        memcpy(&rnew->finfo, dirent, sizeof(apr_finfo_t));
    }

    if (rnew->finfo.filetype == APR_LNK) {
        /*
         * Resolve this symlink.  We should tie this back to dir_walk's cache
         */
        if ((res = resolve_symlink(rnew->filename, &rnew->finfo,
                                   ap_allow_options(rnew), rnew->pool))
            != OK) {
            rnew->status = res;
            return rnew;
        }
    }

    if (rnew->finfo.filetype == APR_DIR) {
        /* ap_make_full_path and ap_escape_uri overallocated the buffers
         * by one character to help us out here.
         */
        strcat(rnew->filename, "/");
        if (!rnew->path_info || !*rnew->path_info) {
            strcat(rnew->uri, "/");
        }
    }

    /* fill in parsed_uri values
     */
    if (r->args && *r->args && (subtype == AP_SUBREQ_MERGE_ARGS)) {
        ap_parse_uri(rnew, apr_pstrcat(r->pool, rnew->uri, "?",
                                       r->args, NULL));
    }
    else {
        ap_parse_uri(rnew, rnew->uri);
    }

    /* We cannot return NULL without violating the API. So just turn this
     * subrequest into a 500. */
    if (ap_is_recursion_limit_exceeded(r)) {
        rnew->status = HTTP_INTERNAL_SERVER_ERROR;
        return rnew;
    }

    if ((res = ap_process_request_internal(rnew))) {
        rnew->status = res;
    }

    return rnew;
}


static u32 svc_rdma_get_inv_rkey(struct rpcrdma_msg *rdma_argp,
				 struct rpcrdma_write_array *wr_ary,
				 struct rpcrdma_write_array *rp_ary)
 {
	struct rpcrdma_read_chunk *rd_ary;
	struct rpcrdma_segment *arg_ch;

	rd_ary = (struct rpcrdma_read_chunk *)&rdma_argp->rm_body.rm_chunks[0];
	if (rd_ary->rc_discrim != xdr_zero)
		return be32_to_cpu(rd_ary->rc_target.rs_handle);

	if (wr_ary && be32_to_cpu(wr_ary->wc_nchunks)) {
		arg_ch = &wr_ary->wc_array[0].wc_target;
		return be32_to_cpu(arg_ch->rs_handle);
	}

	if (rp_ary && be32_to_cpu(rp_ary->wc_nchunks)) {
		arg_ch = &rp_ary->wc_array[0].wc_target;
		return be32_to_cpu(arg_ch->rs_handle);
	}

 	return 0;
 }


static void *make_block_array(void *mem, int count, int size)
{
   int i;
   void ** p = (void **) mem;
   char *q = (char *) (p + count);
   for (i=0; i < count; ++i) {
      p[i] = q;
      q += size;
   }
   return p;
}


unsigned long long Track::GetUid() const
{
    return m_info.uid;
}


static ulmbcs_byte_t FindLMBCSLocale ( const char * LocaleID ) {
 const struct _LocaleLMBCSGrpMap * pTable = LocaleLMBCSGrpMap ;
 if ( ( ! LocaleID ) || ( ! * LocaleID ) ) {
 return 0 ;
 }
 while ( pTable -> LocaleID ) {
 if ( * pTable -> LocaleID == * LocaleID ) {
 if ( uprv_strncmp ( pTable -> LocaleID , LocaleID , strlen ( pTable -> LocaleID ) ) == 0 ) return pTable -> OptGroup ;
 }
 else if ( * pTable -> LocaleID > * LocaleID ) break ;
 pTable ++ ;
 }
 return ULMBCS_GRP_L1 ;
 }


GF_Err co64_box_read(GF_Box *s,GF_BitStream *bs)
{
	u32 entries;
	GF_ChunkLargeOffsetBox *ptr = (GF_ChunkLargeOffsetBox *) s;
	ptr->nb_entries = gf_bs_read_u32(bs);

	ISOM_DECREASE_SIZE(ptr, 4)

	if ((u64)ptr->nb_entries > ptr->size / 8 || (u64)ptr->nb_entries > (u64)SIZE_MAX/sizeof(u64)) {
		GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Invalid number of entries %d in co64\n", ptr->nb_entries));
		return GF_ISOM_INVALID_FILE;
	}

	ptr->offsets = (u64 *) gf_malloc(ptr->nb_entries * sizeof(u64) );
	if (ptr->offsets == NULL) return GF_OUT_OF_MEM;
	ptr->alloc_size = ptr->nb_entries;
	for (entries = 0; entries < ptr->nb_entries; entries++) {
		ptr->offsets[entries] = gf_bs_read_u64(bs);
	}
	return GF_OK;
}


void nghttp2_session_keep_closed_stream(nghttp2_session *session,
                                        nghttp2_stream *stream) {
  DEBUGF("stream: keep closed stream(%p)=%d, state=%d\n", stream,
         stream->stream_id, stream->state);

  if (session->closed_stream_tail) {
    session->closed_stream_tail->closed_next = stream;
    stream->closed_prev = session->closed_stream_tail;
  } else {
    session->closed_stream_head = stream;
  }
  session->closed_stream_tail = stream;

  ++session->num_closed_streams;
}


    uint32 JavascriptCopyOnAccessNativeIntArray::GetNextIndex(uint32 index) const
    {
        if (this->length == 0 || (index != Js::JavascriptArray::InvalidIndex && index >= this->length))
        {
            return Js::JavascriptArray::InvalidIndex;
        }
        else if (index == Js::JavascriptArray::InvalidIndex)
        {
            return 0;
        }
        else
        {
            return index + 1;
        }
    }


void ConstantFolding::SimplifySqueeze(const GraphProperties& properties,
                                      bool use_shape_info,
                                      GraphDef* optimized_graph,
                                      NodeDef* node) {
  if (use_shape_info && IsSqueeze(*node) &&
      !properties.GetInputProperties(node->name()).empty()) {
    // https://www.tensorflow.org/api_docs/python/tf/squeeze mentions it's
    // error to squeeze a dimension that is not 1, so we only need to check
    // whether the input has > 1 size for each dimension.
    const auto& shape = properties.GetInputProperties(node->name())[0].shape();
    // The node is replaceable iff
    // unknown_rank == false && (dim_size == 0 || all dims have size > 1)
    bool replaceable = !shape.unknown_rank();
    for (int j = 0; replaceable && j < shape.dim_size(); ++j) {
      replaceable &= shape.dim(j).size() > 1;
    }
    if (replaceable) {
      ReplaceOperationWithIdentity(0, properties, node, optimized_graph);
    }
  }
}


inline int MatchingElementsSize(const RuntimeShape& shape,
                                const RuntimeShape& check_shape_0) {
  const int size_1 = shape.FlatSize();
  const int size_2 = check_shape_0.FlatSize();
  TFLITE_CHECK_EQ(size_1, size_2);
  return size_1;
}


static int vqa_decode_init(AVCodecContext *avctx)

{

    VqaContext *s = (VqaContext *)avctx->priv_data;

    unsigned char *vqa_header;

    int i, j, codebook_index;;

    s->avctx = avctx;

    avctx->pix_fmt = PIX_FMT_PAL8;

    avctx->has_b_frames = 0;

    dsputil_init(&s->dsp, avctx);

    /* make sure the extradata made it */

    if (s->avctx->extradata_size != VQA_HEADER_SIZE) {

        av_log(s->avctx, AV_LOG_ERROR, "  VQA video: expected extradata size of %d\n", VQA_HEADER_SIZE);

    /* load up the VQA parameters from the header */

    vqa_header = (unsigned char *)s->avctx->extradata;

    s->vqa_version = vqa_header[0];

    s->width = LE_16(&vqa_header[6]);

    s->height = LE_16(&vqa_header[8]);

    s->vector_width = vqa_header[10];

    s->vector_height = vqa_header[11];

    s->partial_count = s->partial_countdown = vqa_header[13];

    /* the vector dimensions have to meet very stringent requirements */

    if ((s->vector_width != 4) ||

        ((s->vector_height != 2) && (s->vector_height != 4))) {

        /* return without further initialization */

    /* allocate codebooks */

    s->codebook_size = MAX_CODEBOOK_SIZE;

    s->codebook = av_malloc(s->codebook_size);

    s->next_codebook_buffer = av_malloc(s->codebook_size);

    /* initialize the solid-color vectors */

    if (s->vector_height == 4) {

        codebook_index = 0xFF00 * 16;

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

            for (j = 0; j < 16; j++)

                s->codebook[codebook_index++] = i;

    } else {

        codebook_index = 0xF00 * 8;

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

            for (j = 0; j < 8; j++)

                s->codebook[codebook_index++] = i;

    s->next_codebook_buffer_index = 0;

    /* allocate decode buffer */

    s->decode_buffer_size = (s->width / s->vector_width) *

        (s->height / s->vector_height) * 2;

    s->decode_buffer = av_malloc(s->decode_buffer_size);

    s->frame.data[0] = NULL;

    return 0;


static inline void boundaryNodeChildrenWillBeRemoved(RangeBoundaryPoint& boundary, ContainerNode* container)
{
    for (Node* nodeToBeRemoved = container->firstChild(); nodeToBeRemoved; nodeToBeRemoved = nodeToBeRemoved->nextSibling()) {
        if (boundary.childBefore() == nodeToBeRemoved) {
            boundary.setToStartOfNode(container);
            return;
        }

        for (Node* n = boundary.container(); n; n = n->parentNode()) {
            if (n == nodeToBeRemoved) {
                boundary.setToStartOfNode(container);
                return;
            }
        }
    }
}


static void ldb_dn_mark_invalid(struct ldb_dn *dn)
{
	dn->invalid = true;
}


static int cma_ib_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event)
{
	struct rdma_id_private *id_priv = cm_id->context;
	struct rdma_cm_event event;
	int ret = 0;

	if ((ib_event->event != IB_CM_TIMEWAIT_EXIT &&
		cma_disable_callback(id_priv, RDMA_CM_CONNECT)) ||
	    (ib_event->event == IB_CM_TIMEWAIT_EXIT &&
		cma_disable_callback(id_priv, RDMA_CM_DISCONNECT)))
		return 0;

	memset(&event, 0, sizeof event);
	switch (ib_event->event) {
	case IB_CM_REQ_ERROR:
	case IB_CM_REP_ERROR:
		event.event = RDMA_CM_EVENT_UNREACHABLE;
		event.status = -ETIMEDOUT;
		break;
	case IB_CM_REP_RECEIVED:
		if (id_priv->id.qp) {
			event.status = cma_rep_recv(id_priv);
			event.event = event.status ? RDMA_CM_EVENT_CONNECT_ERROR :
						     RDMA_CM_EVENT_ESTABLISHED;
		} else {
			event.event = RDMA_CM_EVENT_CONNECT_RESPONSE;
		}
		cma_set_rep_event_data(&event, &ib_event->param.rep_rcvd,
				       ib_event->private_data);
		break;
	case IB_CM_RTU_RECEIVED:
	case IB_CM_USER_ESTABLISHED:
		event.event = RDMA_CM_EVENT_ESTABLISHED;
		break;
	case IB_CM_DREQ_ERROR:
		event.status = -ETIMEDOUT; /* fall through */
	case IB_CM_DREQ_RECEIVED:
	case IB_CM_DREP_RECEIVED:
		if (!cma_comp_exch(id_priv, RDMA_CM_CONNECT,
				   RDMA_CM_DISCONNECT))
			goto out;
		event.event = RDMA_CM_EVENT_DISCONNECTED;
		break;
	case IB_CM_TIMEWAIT_EXIT:
		event.event = RDMA_CM_EVENT_TIMEWAIT_EXIT;
		break;
	case IB_CM_MRA_RECEIVED:
		/* ignore event */
		goto out;
	case IB_CM_REJ_RECEIVED:
		cma_modify_qp_err(id_priv);
		event.status = ib_event->param.rej_rcvd.reason;
		event.event = RDMA_CM_EVENT_REJECTED;
		event.param.conn.private_data = ib_event->private_data;
		event.param.conn.private_data_len = IB_CM_REJ_PRIVATE_DATA_SIZE;
		break;
	default:
		printk(KERN_ERR "RDMA CMA: unexpected IB CM event: %d\n",
		       ib_event->event);
		goto out;
	}

	ret = id_priv->id.event_handler(&id_priv->id, &event);
	if (ret) {
		/* Destroy the CM ID by returning a non-zero value. */
		id_priv->cm_id.ib = NULL;
		cma_exch(id_priv, RDMA_CM_DESTROYING);
		mutex_unlock(&id_priv->handler_mutex);
		rdma_destroy_id(&id_priv->id);
		return ret;
	}
out:
	mutex_unlock(&id_priv->handler_mutex);
	return ret;
}


isdn_net_swapbind(int drvidx)
{
	isdn_net_dev *p;

#ifdef ISDN_DEBUG_NET_ICALL
	printk(KERN_DEBUG "n_fi: swapping ch of %d\n", drvidx);
#endif
	p = dev->netdev;
	while (p) {
		if (p->local->pre_device == drvidx)
			switch (p->local->pre_channel) {
				case 0:
					p->local->pre_channel = 1;
					break;
				case 1:
					p->local->pre_channel = 0;
					break;
			}
		p = (isdn_net_dev *) p->next;
	}
}


bool GLES2Implementation::GetSamplerParameterivHelper(GLuint /* sampler */,
                                                      GLenum /* pname */,
                                                      GLint* /* params */) {
  return false;
}


void RenderFrameDevToolsAgentHost::OnSignedExchangeCertificateResponseReceived(
    FrameTreeNode* frame_tree_node,
    const base::UnguessableToken& request_id,
    const base::UnguessableToken& loader_id,
    const GURL& url,
    const network::ResourceResponseHead& head) {
  DispatchToAgents(frame_tree_node, &protocol::NetworkHandler::ResponseReceived,
                   request_id.ToString(), loader_id.ToString(), url,
                   protocol::Network::ResourceTypeEnum::Other, head,
                   protocol::Maybe<std::string>());
}


xmlParseEndTag2(xmlParserCtxtPtr ctxt, const xmlChar *prefix,
                const xmlChar *URI, int line, int nsNr, int tlen) {
    const xmlChar *name;
    size_t curLength;

    GROW;
    if ((RAW != '<') || (NXT(1) != '/')) {
	xmlFatalErr(ctxt, XML_ERR_LTSLASH_REQUIRED, NULL);
	return;
    }
    SKIP(2);

    curLength = ctxt->input->end - ctxt->input->cur;
    if ((tlen > 0) && (curLength >= (size_t)tlen) &&
        (xmlStrncmp(ctxt->input->cur, ctxt->name, tlen) == 0)) {
        if ((curLength >= (size_t)(tlen + 1)) &&
	    (ctxt->input->cur[tlen] == '>')) {
	    ctxt->input->cur += tlen + 1;
	    ctxt->input->col += tlen + 1;
	    goto done;
	}
	ctxt->input->cur += tlen;
	ctxt->input->col += tlen;
	name = (xmlChar*)1;
    } else {
	if (prefix == NULL)
	    name = xmlParseNameAndCompare(ctxt, ctxt->name);
	else
	    name = xmlParseQNameAndCompare(ctxt, ctxt->name, prefix);
    }

    /*
     * We should definitely be at the ending "S? '>'" part
     */
    GROW;
    if (ctxt->instate == XML_PARSER_EOF)
        return;
    SKIP_BLANKS;
    if ((!IS_BYTE_CHAR(RAW)) || (RAW != '>')) {
	xmlFatalErr(ctxt, XML_ERR_GT_REQUIRED, NULL);
    } else
	NEXT1;

    /*
     * [ WFC: Element Type Match ]
     * The Name in an element's end-tag must match the element type in the
     * start-tag.
     *
     */
    if (name != (xmlChar*)1) {
        if (name == NULL) name = BAD_CAST "unparseable";
        if ((line == 0) && (ctxt->node != NULL))
            line = ctxt->node->line;
        xmlFatalErrMsgStrIntStr(ctxt, XML_ERR_TAG_NAME_MISMATCH,
		     "Opening and ending tag mismatch: %s line %d and %s\n",
		                ctxt->name, line, name);
    }

    /*
     * SAX: End of Tag
     */
done:
    if ((ctxt->sax != NULL) && (ctxt->sax->endElementNs != NULL) &&
	(!ctxt->disableSAX))
	ctxt->sax->endElementNs(ctxt->userData, ctxt->name, prefix, URI);

    spacePop(ctxt);
    if (nsNr != 0)
	nsPop(ctxt, nsNr);
    return;
}


static size_t encode_tiles ( VP9_COMP * cpi , uint8_t * data_ptr ) {
 VP9_COMMON * const cm = & cpi -> common ;
 vp9_writer residual_bc ;
 int tile_row , tile_col ;
 TOKENEXTRA * tok [ 4 ] [ 1 << 6 ] , * tok_end ;
 size_t total_size = 0 ;
 const int tile_cols = 1 << cm -> log2_tile_cols ;
 const int tile_rows = 1 << cm -> log2_tile_rows ;
 vpx_memset ( cm -> above_seg_context , 0 , sizeof ( * cm -> above_seg_context ) * mi_cols_aligned_to_sb ( cm -> mi_cols ) ) ;
 tok [ 0 ] [ 0 ] = cpi -> tok ;
 for ( tile_row = 0 ;
 tile_row < tile_rows ;
 tile_row ++ ) {
 if ( tile_row ) tok [ tile_row ] [ 0 ] = tok [ tile_row - 1 ] [ tile_cols - 1 ] + cpi -> tok_count [ tile_row - 1 ] [ tile_cols - 1 ] ;
 for ( tile_col = 1 ;
 tile_col < tile_cols ;
 tile_col ++ ) tok [ tile_row ] [ tile_col ] = tok [ tile_row ] [ tile_col - 1 ] + cpi -> tok_count [ tile_row ] [ tile_col - 1 ] ;
 }
 for ( tile_row = 0 ;
 tile_row < tile_rows ;
 tile_row ++ ) {
 for ( tile_col = 0 ;
 tile_col < tile_cols ;
 tile_col ++ ) {
 TileInfo tile ;
 vp9_tile_init ( & tile , cm , tile_row , tile_col ) ;
 tok_end = tok [ tile_row ] [ tile_col ] + cpi -> tok_count [ tile_row ] [ tile_col ] ;
 if ( tile_col < tile_cols - 1 || tile_row < tile_rows - 1 ) vp9_start_encode ( & residual_bc , data_ptr + total_size + 4 ) ;
 else vp9_start_encode ( & residual_bc , data_ptr + total_size ) ;
 write_modes ( cpi , & tile , & residual_bc , & tok [ tile_row ] [ tile_col ] , tok_end ) ;
 assert ( tok [ tile_row ] [ tile_col ] == tok_end ) ;
 vp9_stop_encode ( & residual_bc ) ;
 if ( tile_col < tile_cols - 1 || tile_row < tile_rows - 1 ) {
 mem_put_be32 ( data_ptr + total_size , residual_bc . pos ) ;
 total_size += 4 ;
 }
 total_size += residual_bc . pos ;
 }
 }
 return total_size ;
 }


TEST_F(AllowMissingInAndListTest, BadJwt) {
  // Bad JWT should fail.
  EXPECT_CALL(mock_cb_, onComplete(Status::JwtVerificationFail));
  auto headers = Http::TestRequestHeaderMapImpl{{kExampleHeader, NonExistKidToken}};
  context_ = Verifier::createContext(headers, parent_span_, &mock_cb_);
  verifier_->verify(context_);
  EXPECT_THAT(headers, JwtOutputFailedOrIgnore(kExampleHeader));
}


static void perf_free_event(struct perf_event *event,
			    struct perf_event_context *ctx)
{
	struct perf_event *parent = event->parent;

	if (WARN_ON_ONCE(!parent))
		return;

	mutex_lock(&parent->child_mutex);
	list_del_init(&event->child_list);
	mutex_unlock(&parent->child_mutex);

	put_event(parent);

	raw_spin_lock_irq(&ctx->lock);
	perf_group_detach(event);
	list_del_event(event, ctx);
	raw_spin_unlock_irq(&ctx->lock);
	free_event(event);
}


int bdrv_write_zeroes(BlockDriverState *bs, int64_t sector_num,

                      int nb_sectors, BdrvRequestFlags flags)

{

    return bdrv_rw_co(bs, sector_num, NULL, nb_sectors, true,

                      BDRV_REQ_ZERO_WRITE | flags);

}


  content::RenderFrameHost* GetMainFrame() {
    return GetWebContents()->GetMainFrame();
  }


static ssize_t proc_sessionid_read(struct file * file, char __user * buf,
				  size_t count, loff_t *ppos)
{
	struct inode * inode = file_inode(file);
	struct task_struct *task = get_proc_task(inode);
	ssize_t length;
	char tmpbuf[TMPBUFLEN];

	if (!task)
		return -ESRCH;
	length = scnprintf(tmpbuf, TMPBUFLEN, "%u",
				audit_get_sessionid(task));
	put_task_struct(task);
	return simple_read_from_buffer(buf, count, ppos, tmpbuf, length);
}


static void test_resp3_push_options(struct config config) {
    redisAsyncContext *ac;
    redisContext *c;
    redisOptions options;

    test("We set a default RESP3 handler for redisContext: ");
    options = get_redis_tcp_options(config);
    assert((c = redisConnectWithOptions(&options)) != NULL);
    test_cond(c->push_cb != NULL);
    redisFree(c);

    test("We don't set a default RESP3 push handler for redisAsyncContext: ");
    options = get_redis_tcp_options(config);
    assert((ac = redisAsyncConnectWithOptions(&options)) != NULL);
    test_cond(ac->c.push_cb == NULL);
    redisAsyncFree(ac);

    test("Our REDIS_OPT_NO_PUSH_AUTOFREE flag works: ");
    options = get_redis_tcp_options(config);
    options.options |= REDIS_OPT_NO_PUSH_AUTOFREE;
    assert((c = redisConnectWithOptions(&options)) != NULL);
    test_cond(c->push_cb == NULL);
    redisFree(c);

    test("We can use redisOptions to set a custom PUSH handler for redisContext: ");
    options = get_redis_tcp_options(config);
    options.push_cb = push_handler;
    assert((c = redisConnectWithOptions(&options)) != NULL);
    test_cond(c->push_cb == push_handler);
    redisFree(c);

    test("We can use redisOptions to set a custom PUSH handler for redisAsyncContext: ");
    options = get_redis_tcp_options(config);
    options.async_push_cb = push_handler_async;
    assert((ac = redisAsyncConnectWithOptions(&options)) != NULL);
    test_cond(ac->push_cb == push_handler_async);
    redisAsyncFree(ac);
}


static void trace_create_eval_file(struct dentry *d_tracer)
{
	trace_create_file("eval_map", 0444, d_tracer,
			  NULL, &tracing_eval_map_fops);
}


static int check_issued(X509_STORE_CTX *ctx, X509 *x, X509 *issuer)
{
    int ret;
    if (x == issuer)
        return cert_self_signed(x);
    ret = X509_check_issued(issuer, x);
    if (ret == X509_V_OK) {
        int i;
        X509 *ch;
        /* Special case: single self signed certificate */
        if (cert_self_signed(x) && sk_X509_num(ctx->chain) == 1)
            return 1;
        for (i = 0; i < sk_X509_num(ctx->chain); i++) {
            ch = sk_X509_value(ctx->chain, i);
            if (ch == issuer || !X509_cmp(ch, issuer)) {
                ret = X509_V_ERR_PATH_LOOP;
                break;
            }
        }
    }

    if (ret == X509_V_OK)
        return 1;
    /* If we haven't asked for issuer errors don't set ctx */
    if (!(ctx->param->flags & X509_V_FLAG_CB_ISSUER_CHECK))
        return 0;

    ctx->error = ret;
    ctx->current_cert = x;
    ctx->current_issuer = issuer;
    return ctx->verify_cb(0, ctx);
}


void perf_event_mmap(struct vm_area_struct *vma)
{
	struct perf_mmap_event mmap_event;

	if (!atomic_read(&nr_mmap_events))
		return;

	mmap_event = (struct perf_mmap_event){
		.vma	= vma,
		/* .file_name */
		/* .file_size */
		.event_id  = {
			.header = {
				.type = PERF_RECORD_MMAP,
				.misc = PERF_RECORD_MISC_USER,
				/* .size */
			},
			/* .pid */
			/* .tid */
			.start  = vma->vm_start,
			.len    = vma->vm_end - vma->vm_start,
			.pgoff  = (u64)vma->vm_pgoff << PAGE_SHIFT,
		},
	};

	perf_event_mmap_event(&mmap_event);
}


archive_mstring_copy_mbs_len(struct archive_mstring *aes, const char *mbs,
    size_t len)
{
	if (mbs == NULL) {
		aes->aes_set = 0;
		return (0);
	}
	aes->aes_set = AES_SET_MBS; /* Only MBS form is set now. */
	archive_strncpy(&(aes->aes_mbs), mbs, len);
	archive_string_empty(&(aes->aes_utf8));
	archive_wstring_empty(&(aes->aes_wcs));
	return (0);
}


static void DeleteDecoder ( decoder_t * p_dec ) {
 decoder_owner_sys_t * p_owner = p_dec -> p_owner ;
 msg_Dbg ( p_dec , "killing decoder fourcc `%4.4s', %u PES in FIFO" , ( char * ) & p_dec -> fmt_in . i_codec , ( unsigned ) block_FifoCount ( p_owner -> p_fifo ) ) ;
 block_FifoEmpty ( p_owner -> p_fifo ) ;
 block_FifoRelease ( p_owner -> p_fifo ) ;
 if ( p_owner -> p_aout ) {
 aout_DecFlush ( p_owner -> p_aout ) ;
 aout_DecDelete ( p_owner -> p_aout ) ;
 input_resource_PutAout ( p_owner -> p_resource , p_owner -> p_aout ) ;
 if ( p_owner -> p_input != NULL ) input_SendEventAout ( p_owner -> p_input ) ;
 }
 if ( p_owner -> p_vout ) {
 vout_Reset ( p_owner -> p_vout ) ;
 input_resource_RequestVout ( p_owner -> p_resource , p_owner -> p_vout , NULL , 0 , true ) ;
 if ( p_owner -> p_input != NULL ) input_SendEventVout ( p_owner -> p_input ) ;
 }
 # ifdef ENABLE_SOUT if ( p_owner -> p_sout_input ) {
 sout_InputDelete ( p_owner -> p_sout_input ) ;
 es_format_Clean ( & p_owner -> sout ) ;
 }
 # endif if ( p_dec -> fmt_out . i_cat == SPU_ES ) {
 vout_thread_t * p_vout = input_resource_HoldVout ( p_owner -> p_resource ) ;
 if ( p_vout ) {
 if ( p_owner -> p_spu_vout == p_vout ) vout_FlushSubpictureChannel ( p_vout , p_owner -> i_spu_channel ) ;
 vlc_object_release ( p_vout ) ;
 }
 }
 es_format_Clean ( & p_dec -> fmt_in ) ;
 es_format_Clean ( & p_dec -> fmt_out ) ;
 if ( p_dec -> p_description ) vlc_meta_Delete ( p_dec -> p_description ) ;
 es_format_Clean ( & p_owner -> fmt_description ) ;
 if ( p_owner -> p_description ) vlc_meta_Delete ( p_owner -> p_description ) ;
 if ( p_owner -> p_packetizer ) {
 module_unneed ( p_owner -> p_packetizer , p_owner -> p_packetizer -> p_module ) ;
 es_format_Clean ( & p_owner -> p_packetizer -> fmt_in ) ;
 es_format_Clean ( & p_owner -> p_packetizer -> fmt_out ) ;
 if ( p_owner -> p_packetizer -> p_description ) vlc_meta_Delete ( p_owner -> p_packetizer -> p_description ) ;
 vlc_object_release ( p_owner -> p_packetizer ) ;
 }
 vlc_cond_destroy ( & p_owner -> wait_acknowledge ) ;
 vlc_cond_destroy ( & p_owner -> wait_request ) ;
 vlc_mutex_destroy ( & p_owner -> lock ) ;
 vlc_object_release ( p_dec ) ;
 free ( p_owner ) ;
 }


  int agent_get_num_ops() {
    Mutex::Locker l(agent_lock);
    return agent_ops;
  }


  PosibErr<void> open_file_readlock(FStream & in, ParmString file) {
    RET_ON_ERR(in.open(file, "r"));
#ifdef USE_FILE_LOCKS
    int fd = in.file_no();
    struct flock fl;
    fl.l_type   = F_RDLCK;
    fl.l_whence = SEEK_SET;
    fl.l_start  = 0;
    fl.l_len    = 0;
    fcntl(fd, F_SETLKW, &fl); // ignore errors
#endif
    return no_err;
  }


static int get_dirfd(char *path, bool symlinks)
{
	char *ch;
	char *item;
	char *linkpath = NULL;
	char *path_dupe;
	char *str;
	int components = 0;
	int dirfd;
	int flags = 0;
	int new_dirfd;
	struct stat st;
	ssize_t linksize;

	if (!path || *path != '/')
		eerrorx("%s: empty or relative path", applet);
	dirfd = openat(dirfd, "/", O_RDONLY);
	if (dirfd == -1)
		eerrorx("%s: unable to open the root directory: %s",
				applet, strerror(errno));
	path_dupe = xstrdup(path);
	ch = path_dupe;
	while (*ch) {
		if (*ch == '/')
			components++;
		ch++;
	}
	item = strtok(path_dupe, "/");
#ifdef O_PATH
	flags |= O_PATH;
#endif
	if (!symlinks)
		flags |= O_NOFOLLOW;
	flags |= O_RDONLY;
	while (dirfd > 0 && item && components > 1) {
		str = xstrdup(linkpath ? linkpath : item);
		new_dirfd = openat(dirfd, str, flags);
		if (new_dirfd == -1)
			eerrorx("%s: %s: could not open %s: %s", applet, path, str,
					strerror(errno));
		if (fstat(new_dirfd, &st) == -1)
			eerrorx("%s: %s: unable to stat %s: %s", applet, path, item,
					strerror(errno));
		if (S_ISLNK(st.st_mode) ) {
			if (st.st_uid != 0)
				eerrorx("%s: %s: symbolic link %s not owned by root",
						applet, path, str);
			linksize = st.st_size+1;
			if (linkpath)
				free(linkpath);
			linkpath = xmalloc(linksize);
			memset(linkpath, 0, linksize);
			if (readlinkat(new_dirfd, "", linkpath, linksize) != st.st_size)
				eerrorx("%s: symbolic link destination changed", applet);
			/*
			 * now follow the symlink.
			 */
			close(new_dirfd);
		} else {
			close(dirfd);
			dirfd = new_dirfd;
			free(linkpath);
			linkpath = NULL;
			item = strtok(NULL, "/");
			components--;
		}
	}
	free(path_dupe);
	if (linkpath) {
		free(linkpath);
		linkpath = NULL;
	}
	return dirfd;
}


get_time_t_min(void)
{
#if defined(TIME_T_MIN)
	return TIME_T_MIN;
#else
	if (((time_t)0) < ((time_t)-1)) {
		/* Time_t is unsigned */
		return (time_t)0;
	} else {
		/* Time_t is signed. */
		if (sizeof(time_t) == sizeof(int64_t)) {
			return (time_t)INT64_MIN;
		} else {
			return (time_t)INT32_MIN;
		}
	}
#endif
}


AckFeature(PPARANDIS_ADAPTER pContext, UINT32 Feature)
{
    if (VirtIOIsFeatureEnabled(pContext->u32HostFeatures, Feature))
    {
        VirtIOFeatureEnable(pContext->u32GuestFeatures, Feature);
        return TRUE;
    }
    return FALSE;
}


status_t MediaPlayerService::Client::setNextPlayer(const sp<IMediaPlayer>& player) {
    ALOGV("setNextPlayer");
 Mutex::Autolock l(mLock);
    sp<Client> c = static_cast<Client*>(player.get());
    mNextClient = c;

 if (c != NULL) {
 if (mAudioOutput != NULL) {
            mAudioOutput->setNextOutput(c->mAudioOutput);
 } else if ((mPlayer != NULL) && !mPlayer->hardwareOutput()) {
            ALOGE("no current audio output");
 }

 if ((mPlayer != NULL) && (mNextClient->getPlayer() != NULL)) {
            mPlayer->setNextPlayer(mNextClient->getPlayer());
 }
 }

 return OK;
}


static uint8_t cirrus_mmio_blt_read(CirrusVGAState * s, unsigned address)
{
    int value = 0xff;

    switch (address) {
    case (CIRRUS_MMIO_BLTBGCOLOR + 0):
	value = cirrus_vga_read_gr(s, 0x00);
	break;
    case (CIRRUS_MMIO_BLTBGCOLOR + 1):
	value = cirrus_vga_read_gr(s, 0x10);
	break;
    case (CIRRUS_MMIO_BLTBGCOLOR + 2):
	value = cirrus_vga_read_gr(s, 0x12);
	break;
    case (CIRRUS_MMIO_BLTBGCOLOR + 3):
	value = cirrus_vga_read_gr(s, 0x14);
	break;
    case (CIRRUS_MMIO_BLTFGCOLOR + 0):
	value = cirrus_vga_read_gr(s, 0x01);
	break;
    case (CIRRUS_MMIO_BLTFGCOLOR + 1):
	value = cirrus_vga_read_gr(s, 0x11);
	break;
    case (CIRRUS_MMIO_BLTFGCOLOR + 2):
	value = cirrus_vga_read_gr(s, 0x13);
	break;
    case (CIRRUS_MMIO_BLTFGCOLOR + 3):
	value = cirrus_vga_read_gr(s, 0x15);
	break;
    case (CIRRUS_MMIO_BLTWIDTH + 0):
	value = cirrus_vga_read_gr(s, 0x20);
	break;
    case (CIRRUS_MMIO_BLTWIDTH + 1):
	value = cirrus_vga_read_gr(s, 0x21);
	break;
    case (CIRRUS_MMIO_BLTHEIGHT + 0):
	value = cirrus_vga_read_gr(s, 0x22);
	break;
    case (CIRRUS_MMIO_BLTHEIGHT + 1):
	value = cirrus_vga_read_gr(s, 0x23);
	break;
    case (CIRRUS_MMIO_BLTDESTPITCH + 0):
	value = cirrus_vga_read_gr(s, 0x24);
	break;
    case (CIRRUS_MMIO_BLTDESTPITCH + 1):
	value = cirrus_vga_read_gr(s, 0x25);
	break;
    case (CIRRUS_MMIO_BLTSRCPITCH + 0):
	value = cirrus_vga_read_gr(s, 0x26);
	break;
    case (CIRRUS_MMIO_BLTSRCPITCH + 1):
	value = cirrus_vga_read_gr(s, 0x27);
	break;
    case (CIRRUS_MMIO_BLTDESTADDR + 0):
	value = cirrus_vga_read_gr(s, 0x28);
	break;
    case (CIRRUS_MMIO_BLTDESTADDR + 1):
	value = cirrus_vga_read_gr(s, 0x29);
	break;
    case (CIRRUS_MMIO_BLTDESTADDR + 2):
	value = cirrus_vga_read_gr(s, 0x2a);
	break;
    case (CIRRUS_MMIO_BLTSRCADDR + 0):
	value = cirrus_vga_read_gr(s, 0x2c);
	break;
    case (CIRRUS_MMIO_BLTSRCADDR + 1):
	value = cirrus_vga_read_gr(s, 0x2d);
	break;
    case (CIRRUS_MMIO_BLTSRCADDR + 2):
	value = cirrus_vga_read_gr(s, 0x2e);
	break;
    case CIRRUS_MMIO_BLTWRITEMASK:
	value = cirrus_vga_read_gr(s, 0x2f);
	break;
    case CIRRUS_MMIO_BLTMODE:
	value = cirrus_vga_read_gr(s, 0x30);
	break;
    case CIRRUS_MMIO_BLTROP:
	value = cirrus_vga_read_gr(s, 0x32);
	break;
    case CIRRUS_MMIO_BLTMODEEXT:
	value = cirrus_vga_read_gr(s, 0x33);
	break;
    case (CIRRUS_MMIO_BLTTRANSPARENTCOLOR + 0):
	value = cirrus_vga_read_gr(s, 0x34);
	break;
    case (CIRRUS_MMIO_BLTTRANSPARENTCOLOR + 1):
	value = cirrus_vga_read_gr(s, 0x35);
	break;
    case (CIRRUS_MMIO_BLTTRANSPARENTCOLORMASK + 0):
	value = cirrus_vga_read_gr(s, 0x38);
	break;
    case (CIRRUS_MMIO_BLTTRANSPARENTCOLORMASK + 1):
	value = cirrus_vga_read_gr(s, 0x39);
	break;
    case CIRRUS_MMIO_BLTSTATUS:
	value = cirrus_vga_read_gr(s, 0x31);
	break;
    default:
#ifdef DEBUG_CIRRUS
	printf("cirrus: mmio read - address 0x%04x\n", address);
#endif
	break;
    }

    return (uint8_t) value;
}


static inline void nested_release_vmcs12(struct vcpu_vmx *vmx)
{
	if (vmx->nested.current_vmptr == -1ull)
		return;

	/* current_vmptr and current_vmcs12 are always set/reset together */
	if (WARN_ON(vmx->nested.current_vmcs12 == NULL))
		return;

	if (enable_shadow_vmcs) {
		/* copy to memory all shadowed fields in case
		   they were modified */
		copy_shadow_to_vmcs12(vmx);
		vmx->nested.sync_shadow_vmcs = false;
		vmcs_clear_bits(SECONDARY_VM_EXEC_CONTROL,
				SECONDARY_EXEC_SHADOW_VMCS);
		vmcs_write64(VMCS_LINK_POINTER, -1ull);
	}
	vmx->nested.posted_intr_nv = -1;

	/* Flush VMCS12 to guest memory */
	memcpy(vmx->nested.current_vmcs12, vmx->nested.cached_vmcs12,
	       VMCS12_SIZE);

	kunmap(vmx->nested.current_vmcs12_page);
	nested_release_page(vmx->nested.current_vmcs12_page);
	vmx->nested.current_vmptr = -1ull;
	vmx->nested.current_vmcs12 = NULL;
}


void xfrm_policy_walk_done(struct xfrm_policy_walk *walk, struct net *net)
{
	if (list_empty(&walk->walk.all))
		return;

	spin_lock_bh(&net->xfrm.xfrm_policy_lock); /*FIXME where is net? */
	list_del(&walk->walk.all);
	spin_unlock_bh(&net->xfrm.xfrm_policy_lock);
}


static bool ReadChannelInfo(std::vector<ChannelInfo> &channels,
                            const std::vector<unsigned char> &data) {
  const char *p = reinterpret_cast<const char *>(&data.at(0));

  for (;;) {
    if ((*p) == 0) {
      break;
    }
    ChannelInfo info;

    tinyexr_int64 data_len = static_cast<tinyexr_int64>(data.size()) -
                             (p - reinterpret_cast<const char *>(data.data()));
    if (data_len < 0) {
      return false;
    }

    p = ReadString(&info.name, p, size_t(data_len));
    if ((p == NULL) && (info.name.empty())) {
      // Buffer overrun. Issue #51.
      return false;
    }

    const unsigned char *data_end =
        reinterpret_cast<const unsigned char *>(p) + 16;
    if (data_end >= (data.data() + data.size())) {
      return false;
    }

    memcpy(&info.pixel_type, p, sizeof(int));
    p += 4;
    info.p_linear = static_cast<unsigned char>(p[0]);  // uchar
    p += 1 + 3;                                        // reserved: uchar[3]
    memcpy(&info.x_sampling, p, sizeof(int));          // int
    p += 4;
    memcpy(&info.y_sampling, p, sizeof(int));  // int
    p += 4;

    tinyexr::swap4(reinterpret_cast<unsigned int *>(&info.pixel_type));
    tinyexr::swap4(reinterpret_cast<unsigned int *>(&info.x_sampling));
    tinyexr::swap4(reinterpret_cast<unsigned int *>(&info.y_sampling));

    channels.push_back(info);
  }

  return true;
}


 void PlatformSensorProviderBase::FreeResourcesIfNeeded() {
   DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
   if (sensor_map_.empty() && requests_map_.empty()) {
     FreeResources();
     shared_buffer_handle_.reset();
   }
 }


static PyObject *__pyx_f_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter_write_into_stream(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter *__pyx_v_self, int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("write_into_stream", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_write_into_stream); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 70, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter_3write_into_stream)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 70, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "clickhouse_driver/bufferedwriter.pyx":71
 *
 *     cpdef write_into_stream(self):
 *         self.sock.sendall(             # <<<<<<<<<<<<<<
 *             PyBytes_FromStringAndSize(self.buffer, self.position)
 *         )
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->sock, __pyx_n_s_sendall); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 71, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "clickhouse_driver/bufferedwriter.pyx":72
 *     cpdef write_into_stream(self):
 *         self.sock.sendall(
 *             PyBytes_FromStringAndSize(self.buffer, self.position)             # <<<<<<<<<<<<<<
 *         )
 *         self.position = 0
 */
  __pyx_t_3 = PyBytes_FromStringAndSize(__pyx_v_self->__pyx_base.buffer, __pyx_v_self->__pyx_base.position); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 72, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 71, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "clickhouse_driver/bufferedwriter.pyx":74
 *             PyBytes_FromStringAndSize(self.buffer, self.position)
 *         )
 *         self.position = 0             # <<<<<<<<<<<<<<
 *
 *
 */
  __pyx_v_self->__pyx_base.position = 0;

  /* "clickhouse_driver/bufferedwriter.pyx":70
 *         super(BufferedSocketWriter, self).__init__(bufsize)
 *
 *     cpdef write_into_stream(self):             # <<<<<<<<<<<<<<
 *         self.sock.sendall(
 *             PyBytes_FromStringAndSize(self.buffer, self.position)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.BufferedSocketWriter.write_into_stream", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}


long Cluster::Load(long long& pos, long& len) const
{
    assert(m_pSegment);
    assert(m_pos >= m_element_start);

    if (m_timecode >= 0)  //at least partially loaded
        return 0;

    assert(m_pos == m_element_start);
    assert(m_element_size < 0);

    IMkvReader* const pReader = m_pSegment->m_pReader;

    long long total, avail;

    const int status = pReader->Length(&total, &avail);

    if (status < 0)  //error
        return status;

    assert((total < 0) || (avail <= total));
    assert((total < 0) || (m_pos <= total));  //TODO: verify this

    pos = m_pos;

    long long cluster_size = -1;
    {
        if ((pos + 1) > avail)
        {
            len = 1;
            return E_BUFFER_NOT_FULL;
        }
        long long result = GetUIntLength(pReader, pos, len);
        if (result < 0)  //error or underflow
            return static_cast<long>(result);
        if (result > 0)  //underflow (weird)
            return E_BUFFER_NOT_FULL;
        if ((pos + len) > avail)
            return E_BUFFER_NOT_FULL;
        const long long id_ = ReadUInt(pReader, pos, len);
        if (id_ < 0)  //error
            return static_cast<long>(id_);
        if (id_ != 0x0F43B675)  //Cluster ID
            return E_FILE_FORMAT_INVALID;
        pos += len;  //consume id
        if ((pos + 1) > avail)
        {
            len = 1;
            return E_BUFFER_NOT_FULL;
        }
        result = GetUIntLength(pReader, pos, len);
        if (result < 0)  //error
            return static_cast<long>(result);
        if (result > 0)  //weird
            return E_BUFFER_NOT_FULL;
        if ((pos + len) > avail)
            return E_BUFFER_NOT_FULL;
        const long long size = ReadUInt(pReader, pos, len);
        if (size < 0)  //error
            return static_cast<long>(cluster_size);
        if (size == 0)
            return E_FILE_FORMAT_INVALID;  //TODO: verify this
        pos += len;  //consume length of size of element
        const long long unknown_size = (1LL << (7 * len)) - 1;
        if (size != unknown_size)
            cluster_size = size;
     }

//// pos points to start of payload

 #if 0
     len = static_cast<long>(size_);

 if (cluster_stop > avail)

         return E_BUFFER_NOT_FULL;
 #endif

    long long timecode = -1;
    long long new_pos = -1;
    bool bBlock = false;

    long long cluster_stop = (cluster_size < 0) ? -1 : pos + cluster_size;

    for (;;)
    {
        if ((cluster_stop >= 0) && (pos >= cluster_stop))
            break;

        if ((pos + 1) > avail)
        {
            len = 1;
            return E_BUFFER_NOT_FULL;
        }
        long long result = GetUIntLength(pReader, pos, len);
        if (result < 0)  //error
            return static_cast<long>(result);
        if (result > 0)  //weird
            return E_BUFFER_NOT_FULL;
        if ((cluster_stop >= 0) && ((pos + len) > cluster_stop))
            return E_FILE_FORMAT_INVALID;
        if ((pos + len) > avail)
            return E_BUFFER_NOT_FULL;
        const long long id = ReadUInt(pReader, pos, len);
        if (id < 0) //error
            return static_cast<long>(id);
        if (id == 0)
            return E_FILE_FORMAT_INVALID;
        if (id == 0x0F43B675)  //Cluster ID
            break;
        if (id == 0x0C53BB6B)  //Cues ID
            break;
        pos += len;  //consume ID field
        if ((pos + 1) > avail)
        {
            len = 1;
            return E_BUFFER_NOT_FULL;
        }
        result = GetUIntLength(pReader, pos, len);
        if (result < 0)  //error
            return static_cast<long>(result);
        if (result > 0)  //weird
            return E_BUFFER_NOT_FULL;
        if ((cluster_stop >= 0) && ((pos + len) > cluster_stop))
            return E_FILE_FORMAT_INVALID;
        if ((pos + len) > avail)
            return E_BUFFER_NOT_FULL;
        const long long size = ReadUInt(pReader, pos, len);
        if (size < 0)  //error
            return static_cast<long>(size);
        const long long unknown_size = (1LL << (7 * len)) - 1;
        if (size == unknown_size)
            return E_FILE_FORMAT_INVALID;
        pos += len;  //consume size field
        if ((cluster_stop >= 0) && (pos > cluster_stop))
            return E_FILE_FORMAT_INVALID;
        if (size == 0)  //weird
            continue;
        if ((cluster_stop >= 0) && ((pos + size) > cluster_stop))
            return E_FILE_FORMAT_INVALID;
        if (id == 0x67)  //TimeCode ID
        {
            len = static_cast<long>(size);
            if ((pos + size) > avail)
                return E_BUFFER_NOT_FULL;
            timecode = UnserializeUInt(pReader, pos, size);
            if (timecode < 0)  //error (or underflow)
                return static_cast<long>(timecode);
            new_pos = pos + size;
            if (bBlock)
                break;
        }
        else if (id == 0x20)  //BlockGroup ID
        {
            bBlock = true;
            break;
        }
        else if (id == 0x23)  //SimpleBlock ID
        {
            bBlock = true;
            break;
        }
        pos += size;  //consume payload
        assert((cluster_stop < 0) || (pos <= cluster_stop));
    }
    assert((cluster_stop < 0) || (pos <= cluster_stop));
    if (timecode < 0)  //no timecode found
        return E_FILE_FORMAT_INVALID;
    if (!bBlock)
        return E_FILE_FORMAT_INVALID;
    m_pos = new_pos;  //designates position just beyond timecode payload
    m_timecode = timecode;  // m_timecode >= 0 means we're partially loaded
    if (cluster_size >= 0)
        m_element_size = cluster_stop - m_element_start;
    return 0;
}


int encode_msg ( struct sip_msg * msg , char * payload , int len ) {
 int i , j , k , u , request ;
 unsigned short int h ;
 struct hdr_field * hf ;
 struct msg_start * ms ;
 struct sip_uri miuri ;
 char * myerror = NULL ;
 ptrdiff_t diff ;
 if ( len < MAX_ENCODED_MSG + MAX_MESSAGE_LEN ) return - 1 ;
 if ( parse_headers ( msg , HDR_EOH_F , 0 ) < 0 ) {
 myerror = "in parse_headers" ;
 goto error ;
 }
 memset ( payload , 0 , len ) ;
 ms = & msg -> first_line ;
 if ( ms -> type == SIP_REQUEST ) request = 1 ;
 else if ( ms -> type == SIP_REPLY ) request = 0 ;
 else {
 myerror = "message is neither request nor response" ;
 goto error ;
 }
 if ( request ) {
 for ( h = 0 ;
 h < 32 ;
 j = ( 0x01 << h ) , h ++ ) if ( j & ms -> u . request . method_value ) break ;
 }
 else {
 h = ( unsigned short ) ( ms -> u . reply . statuscode ) ;
 }
 if ( h == 32 ) {
 myerror = "unknown message type\n" ;
 goto error ;
 }
 h = htons ( h ) ;
 memcpy ( payload , & h , 2 ) ;
 h = htons ( ( unsigned short int ) msg -> len ) ;
 memcpy ( & payload [ MSG_LEN_IDX ] , & h , 2 ) ;
 if ( 0 > ( diff = ( get_body ( msg ) - ( msg -> buf ) ) ) ) {
 myerror = "body starts before the message (uh ?)" ;
 goto error ;
 }
 else h = htons ( ( unsigned short int ) diff ) ;
 memcpy ( payload + CONTENT_IDX , & h , 2 ) ;
 payload [ METHOD_CODE_IDX ] = ( unsigned char ) ( request ? ( ms -> u . request . method . s - msg -> buf ) : ( ms -> u . reply . status . s - msg -> buf ) ) ;
 payload [ METHOD_CODE_IDX + 1 ] = ( unsigned char ) ( request ? ( ms -> u . request . method . len ) : ( ms -> u . reply . status . len ) ) ;
 payload [ URI_REASON_IDX ] = ( unsigned char ) ( request ? ( ms -> u . request . uri . s - msg -> buf ) : ( ms -> u . reply . reason . s - msg -> buf ) ) ;
 payload [ URI_REASON_IDX + 1 ] = ( unsigned char ) ( request ? ( ms -> u . request . uri . len ) : ( ms -> u . reply . reason . len ) ) ;
 payload [ VERSION_IDX ] = ( unsigned char ) ( request ? ( ms -> u . request . version . s - msg -> buf ) : ( ms -> u . reply . version . s - msg -> buf ) ) ;
 if ( request ) {
 if ( parse_uri ( ms -> u . request . uri . s , ms -> u . request . uri . len , & miuri ) < 0 ) {
 LM_ERR ( "<%.*s>\n" , ms -> u . request . uri . len , ms -> u . request . uri . s ) ;
 myerror = "while parsing the R-URI" ;
 goto error ;
 }
 if ( 0 > ( j = encode_uri2 ( msg -> buf , ms -> u . request . method . s - msg -> buf + ms -> len , ms -> u . request . uri , & miuri , ( unsigned char * ) & payload [ REQUEST_URI_IDX + 1 ] ) ) ) {
 myerror = "ENCODE_MSG: ERROR while encoding the R-URI" ;
 goto error ;
 }
 payload [ REQUEST_URI_IDX ] = ( unsigned char ) j ;
 k = REQUEST_URI_IDX + 1 + j ;
 }
 else k = REQUEST_URI_IDX ;
 u = k ;
 k ++ ;
 for ( i = 0 , hf = msg -> headers ;
 hf ;
 hf = hf -> next , i ++ ) ;
 i ++ ;
 j = k + 3 * i ;
 for ( i = 0 , hf = msg -> headers ;
 hf ;
 hf = hf -> next , k += 3 ) {
 payload [ k ] = ( unsigned char ) ( hf -> type & 0xFF ) ;
 h = htons ( j ) ;
 memcpy ( & payload [ k + 1 ] , & h , 2 ) ;
 if ( 0 > ( i = encode_header ( msg , hf , ( unsigned char * ) ( payload + j ) , MAX_ENCODED_MSG + MAX_MESSAGE_LEN - j ) ) ) {
 LM_ERR ( "encoding header %.*s\n" , hf -> name . len , hf -> name . s ) ;
 goto error ;
 k -= 3 ;
 continue ;
 }
 j += ( unsigned short int ) i ;
 }
 payload [ u ] = ( unsigned char ) ( ( k - u - 1 ) / 3 ) ;
 j = htons ( j ) ;
 memcpy ( & payload [ k + 1 ] , & j , 2 ) ;
 k += 3 ;
 j = ntohs ( j ) ;
 if ( len < j + msg -> len + 1 ) {
 LM_ERR ( "not enough space to encode sip message\n" ) ;
 return - 1 ;
 }
 memcpy ( & payload [ j ] , msg -> buf , msg -> len ) ;
 LM_DBG ( "msglen = %d,msg starts at %d\n" , msg -> len , j ) ;
 j = htons ( j ) ;
 memcpy ( & payload [ MSG_START_IDX ] , & j , 2 ) ;
 return GET_PAY_SIZE ( payload ) ;
 error : LM_ERR ( "%s\n" , myerror ) ;
 return - 1 ;
 }


static int filter_frame(AVFilterLink *inlink, AVFrame *in)

{

    AVFilterContext *ctx = inlink->dst;

    HDCDContext *s = ctx->priv;

    AVFilterLink *outlink = ctx->outputs[0];

    AVFrame *out;

    const int16_t *in_data;

    int32_t *out_data;

    int n, c;

    int detect, packets, pe_packets;

    out = ff_get_audio_buffer(outlink, in->nb_samples);

    if (!out) {

        av_frame_free(&in);

        return AVERROR(ENOMEM);

    }

    av_frame_copy_props(out, in);

    out->format = outlink->format;

    in_data  = (int16_t*)in->data[0];

    out_data = (int32_t*)out->data[0];

    for (n = 0; n < in->nb_samples * in->channels; n++) {

        out_data[n] = in_data[n];

    }

    detect = 0;

    packets = 0;

    pe_packets = 0;

    s->det_errors = 0;

    for (c = 0; c < inlink->channels; c++) {

        hdcd_state_t *state = &s->state[c];

        hdcd_process(s, state, out_data + c, in->nb_samples, out->channels);

        if (state->sustain) detect++;

        packets += state->code_counterA + state->code_counterB;

        pe_packets += state->count_peak_extend;

        s->uses_transient_filter |= !!state->count_transient_filter;

        s->max_gain_adjustment = FFMIN(s->max_gain_adjustment, GAINTOFLOAT(state->max_gain));

        s->det_errors += state->code_counterA_almost

            + state->code_counterB_checkfails

            + state->code_counterC_unmatched;

    }

    if (pe_packets) {

        /* if every valid packet has used PE, call it permanent */

        if (packets == pe_packets)

            s->peak_extend = HDCD_PE_PERMANENT;

        else

            s->peak_extend = HDCD_PE_INTERMITTENT;

    } else {

        s->peak_extend = HDCD_PE_NEVER;

    }

    /* HDCD is detected if a valid packet is active in all (both)

     * channels at the same time. */

    if (detect == inlink->channels) s->hdcd_detected = 1;

    s->sample_count += in->nb_samples * in->channels;

    av_frame_free(&in);

    return ff_filter_frame(outlink, out);

}


static void btrfs_submit_direct(int rw, struct bio *bio, struct inode *inode,
				loff_t file_offset)
{
	struct btrfs_root *root = BTRFS_I(inode)->root;
	struct btrfs_dio_private *dip;
	struct bio_vec *bvec = bio->bi_io_vec;
	int skip_sum;
	int write = rw & REQ_WRITE;
	int ret = 0;

	skip_sum = BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM;

	dip = kmalloc(sizeof(*dip), GFP_NOFS);
	if (!dip) {
		ret = -ENOMEM;
		goto free_ordered;
	}

	dip->private = bio->bi_private;
	dip->inode = inode;
	dip->logical_offset = file_offset;

	dip->bytes = 0;
	do {
		dip->bytes += bvec->bv_len;
		bvec++;
	} while (bvec <= (bio->bi_io_vec + bio->bi_vcnt - 1));

	dip->disk_bytenr = (u64)bio->bi_sector << 9;
	bio->bi_private = dip;
	dip->errors = 0;
	dip->orig_bio = bio;
	atomic_set(&dip->pending_bios, 0);

	if (write)
		bio->bi_end_io = btrfs_endio_direct_write;
	else
		bio->bi_end_io = btrfs_endio_direct_read;

	ret = btrfs_submit_direct_hook(rw, dip, skip_sum);
	if (!ret)
		return;
free_ordered:
	/*
	 * If this is a write, we need to clean up the reserved space and kill
	 * the ordered extent.
	 */
	if (write) {
		struct btrfs_ordered_extent *ordered;
		ordered = btrfs_lookup_ordered_extent(inode, file_offset);
		if (!test_bit(BTRFS_ORDERED_PREALLOC, &ordered->flags) &&
		    !test_bit(BTRFS_ORDERED_NOCOW, &ordered->flags))
			btrfs_free_reserved_extent(root, ordered->start,
						   ordered->disk_len);
		btrfs_put_ordered_extent(ordered);
		btrfs_put_ordered_extent(ordered);
	}
	bio_endio(bio, ret);
}


static uint32_t ide_ioport_read(void *opaque, uint32_t addr1)

{

    IDEState *ide_if = opaque;

    IDEState *s = ide_if->cur_drive;

    uint32_t addr;

    int ret, hob;

    addr = addr1 & 7;

    /* FIXME: HOB readback uses bit 7, but it's always set right now */

    //hob = s->select & (1 << 7);

    hob = 0;

    switch(addr) {

    case 0:

        ret = 0xff;

        break;

    case 1:

        if (!ide_if[0].bs && !ide_if[1].bs)

            ret = 0;

        else if (!hob)

            ret = s->error;

	else

	    ret = s->hob_feature;

        break;

    case 2:

        if (!ide_if[0].bs && !ide_if[1].bs)

            ret = 0;

        else if (!hob)

            ret = s->nsector & 0xff;

	else

	    ret = s->hob_nsector;

        break;

    case 3:

        if (!ide_if[0].bs && !ide_if[1].bs)

            ret = 0;

        else if (!hob)

            ret = s->sector;

	else

	    ret = s->hob_sector;

        break;

    case 4:

        if (!ide_if[0].bs && !ide_if[1].bs)

            ret = 0;

        else if (!hob)

            ret = s->lcyl;

	else

	    ret = s->hob_lcyl;

        break;

    case 5:

        if (!ide_if[0].bs && !ide_if[1].bs)

            ret = 0;

        else if (!hob)

            ret = s->hcyl;

	else

	    ret = s->hob_hcyl;

        break;

    case 6:

        if (!ide_if[0].bs && !ide_if[1].bs)

            ret = 0;

        else

            ret = s->select;

        break;

    default:

    case 7:

        if ((!ide_if[0].bs && !ide_if[1].bs) ||

            (s != ide_if && !s->bs))

            ret = 0;

        else

            ret = s->status;

        qemu_irq_lower(s->irq);

        break;

    }

#ifdef DEBUG_IDE

    printf("ide: read addr=0x%x val=%02x\n", addr1, ret);

#endif

    return ret;

}


static int process_events_line(ASS_Track *track, char *str)
{
    if (!strncmp(str, "Format:", 7)) {
        char *p = str + 7;
        skip_spaces(&p);
        free(track->event_format);
        track->event_format = strdup(p);
        if (!track->event_format)
            return -1;
        ass_msg(track->library, MSGL_DBG2, "Event format: %s", track->event_format);
        if (track->track_type == TRACK_TYPE_ASS)
            custom_format_line_compatibility(track, p, ass_event_format);
        else
            custom_format_line_compatibility(track, p, ssa_event_format);

        // Guess if we are dealing with legacy ffmpeg subs and change accordingly
        // If file has no event format it was probably not created by ffmpeg/libav
        if (detect_legacy_conv_subs(track)) {
            track->ScaledBorderAndShadow = 1;
            ass_msg(track->library, MSGL_INFO,
                    "Track treated as legacy ffmpeg sub.");
        }
    } else if (!strncmp(str, "Dialogue:", 9)) {
        // This should never be reached for embedded subtitles.
        // They have slightly different format and are parsed in ass_process_chunk,
        // called directly from demuxer
        int eid;
        ASS_Event *event;

        // We can't parse events without event_format
        if (!track->event_format) {
            event_format_fallback(track);
            if (!track->event_format)
                return -1;
        }

        str += 9;
        skip_spaces(&str);

        eid = ass_alloc_event(track);
        if (eid < 0)
            return -1;
        event = track->events + eid;

        return process_event_tail(track, event, str, 0);
    } else {
        ass_msg(track->library, MSGL_V, "Not understood: '%.30s'", str);
    }
    return 0;
}


static void add_response_header(sapi_header_struct *h, zval *return_value TSRMLS_DC) /* {{{ */
{
	char *s, *p;
	int  len;
	ALLOCA_FLAG(use_heap)

	if (h->header_len > 0) {
		p = strchr(h->header, ':');
		len = p - h->header;
		if (p && (len > 0)) {
			while (len > 0 && (h->header[len-1] == ' ' || h->header[len-1] == '\t')) {
				len--;
			}
			if (len) {
				s = do_alloca(len + 1, use_heap);
				memcpy(s, h->header, len);
				s[len] = 0;
				do {
					p++;
				} while (*p == ' ' || *p == '\t');
				add_assoc_stringl_ex(return_value, s, len+1, p, h->header_len - (p - h->header), 1);
				free_alloca(s, use_heap);
			}
		}
	}
}
/* }}} */


 void PaymentRequest::Complete(mojom::PaymentComplete result) {
  if (!IsInitialized()) {
    log_.Error("Attempted complete without initialization");
    OnConnectionTerminated();
     return;
  }

  if (!IsThisPaymentRequestShowing()) {
    log_.Error("Attempted complete without show");
    OnConnectionTerminated();
    return;
  }

  if (result == mojom::PaymentComplete::FAIL) {
    delegate_->ShowErrorMessage();
  } else {
    DCHECK(!has_recorded_completion_);
    journey_logger_.SetCompleted();
    has_recorded_completion_ = true;

    delegate_->GetPrefService()->SetBoolean(kPaymentsFirstTransactionCompleted,
                                            true);
    client_->OnComplete();
    state_->RecordUseStats();
  }
 }


void FrameView::detachCustomScrollbars()
{
    Scrollbar* horizontalBar = horizontalScrollbar();
    if (horizontalBar && horizontalBar->isCustomScrollbar())
        setHasHorizontalScrollbar(false);

    Scrollbar* verticalBar = verticalScrollbar();
    if (verticalBar && verticalBar->isCustomScrollbar())
        setHasVerticalScrollbar(false);

    if (m_scrollCorner) {
        m_scrollCorner->destroy();
        m_scrollCorner = nullptr;
    }
}


OMX::node_id OMX::makeNodeID(OMXNodeInstance *instance) {

    node_id node = (node_id)++mNodeCounter;
    mNodeIDToInstance.add(node, instance);

 return node;
}


BackingStore* WebPage::backingStore() const
{
    return d->m_backingStore;
}


bool omx_vdec::release_done(void)
{
 bool bRet = false;

 if (release_input_done()) {
 if (release_output_done()) {
            bRet = true;
 }
 }
 return bRet;
}


inline WordCount SegmentReader::getSize() { return ptr.size() * WORDS; }


void GetDocumentResourceIdOnBlockingPool(
    const FilePath& local_file_path,
    std::string* resource_id) {
  DCHECK(resource_id);

  if (DocumentEntry::HasHostedDocumentExtension(local_file_path)) {
    std::string error;
    DictionaryValue* dict_value = NULL;
    JSONFileValueSerializer serializer(local_file_path);
    scoped_ptr<Value> value(serializer.Deserialize(NULL, &error));
    if (value.get() && value->GetAsDictionary(&dict_value))
      dict_value->GetString("resource_id", resource_id);
  }
}


TabStrip::TabStrip(std::unique_ptr<TabStripController> controller)
    : controller_(std::move(controller)),
      layout_helper_(std::make_unique<TabStripLayoutHelper>()),
      drag_context_(std::make_unique<TabDragContextImpl>(this)) {
  Init();
  SetEventTargeter(std::make_unique<views::ViewTargeter>(this));
  md_observer_.Add(MD::GetInstance());
}


void visit(User & /*ope*/) override { done_ = true; }


add_def_function(ufunc_T *ufunc)
{
    dfunc_T *dfunc;

    if (def_functions.ga_len == 0)
    {
	// The first position is not used, so that a zero uf_dfunc_idx means it
	// wasn't set.
	if (GA_GROW_FAILS(&def_functions, 1))
	    return FAIL;
	++def_functions.ga_len;
    }

    // Add the function to "def_functions".
    if (GA_GROW_FAILS(&def_functions, 1))
	return FAIL;
    dfunc = ((dfunc_T *)def_functions.ga_data) + def_functions.ga_len;
    CLEAR_POINTER(dfunc);
    dfunc->df_idx = def_functions.ga_len;
    ufunc->uf_dfunc_idx = dfunc->df_idx;
    dfunc->df_ufunc = ufunc;
    dfunc->df_name = vim_strsave(ufunc->uf_name);
    ga_init2(&dfunc->df_var_names, sizeof(char_u *), 10);
    ++dfunc->df_refcount;
    ++def_functions.ga_len;
    return OK;
}


void virtio_setup_block(struct subchannel_id schid)

{

    struct vq_info_block info;

    struct vq_config_block config = {};

    blk_cfg.blk_size = 0; /* mark "illegal" - setup started... */

    guessed_disk_nature = false;

    virtio_reset(schid);

    /*

     * Skipping CCW_CMD_READ_FEAT. We're not doing anything fancy, and

     * we'll just stop dead anyway if anything does not work like we

     * expect it.

     */

    config.index = 0;

    if (run_ccw(schid, CCW_CMD_READ_VQ_CONF, &config, sizeof(config))) {

        virtio_panic("Could not get block device VQ configuration\n");

    }

    if (run_ccw(schid, CCW_CMD_READ_CONF, &blk_cfg, sizeof(blk_cfg))) {

        virtio_panic("Could not get block device configuration\n");

    }

    vring_init(&block, config.num, ring_area,

               KVM_S390_VIRTIO_RING_ALIGN);

    info.queue = (unsigned long long) ring_area;

    info.align = KVM_S390_VIRTIO_RING_ALIGN;

    info.index = 0;

    info.num = config.num;

    block.schid = schid;

    if (!run_ccw(schid, CCW_CMD_SET_VQ, &info, sizeof(info))) {

        virtio_set_status(schid, VIRTIO_CONFIG_S_DRIVER_OK);

    }

    if (!virtio_ipl_disk_is_valid()) {

        /* make sure all getters but blocksize return 0 for invalid IPL disk */

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

        virtio_assume_scsi();

    }

}


static int sctp_bindx_rem(struct sock *sk, struct sockaddr *addrs, int addrcnt)
{
	struct sctp_sock *sp = sctp_sk(sk);
	struct sctp_endpoint *ep = sp->ep;
	int cnt;
	struct sctp_bind_addr *bp = &ep->base.bind_addr;
	int retval = 0;
	void *addr_buf;
	union sctp_addr *sa_addr;
	struct sctp_af *af;

	pr_debug("%s: sk:%p, addrs:%p, addrcnt:%d\n",
		 __func__, sk, addrs, addrcnt);

	addr_buf = addrs;
	for (cnt = 0; cnt < addrcnt; cnt++) {
		/* If the bind address list is empty or if there is only one
		 * bind address, there is nothing more to be removed (we need
		 * at least one address here).
		 */
		if (list_empty(&bp->address_list) ||
		    (sctp_list_single_entry(&bp->address_list))) {
			retval = -EBUSY;
			goto err_bindx_rem;
		}

		sa_addr = addr_buf;
		af = sctp_get_af_specific(sa_addr->sa.sa_family);
		if (!af) {
			retval = -EINVAL;
			goto err_bindx_rem;
		}

		if (!af->addr_valid(sa_addr, sp, NULL)) {
			retval = -EADDRNOTAVAIL;
			goto err_bindx_rem;
		}

		if (sa_addr->v4.sin_port &&
		    sa_addr->v4.sin_port != htons(bp->port)) {
			retval = -EINVAL;
			goto err_bindx_rem;
		}

		if (!sa_addr->v4.sin_port)
			sa_addr->v4.sin_port = htons(bp->port);

		/* FIXME - There is probably a need to check if sk->sk_saddr and
		 * sk->sk_rcv_addr are currently set to one of the addresses to
		 * be removed. This is something which needs to be looked into
		 * when we are fixing the outstanding issues with multi-homing
		 * socket routing and failover schemes. Refer to comments in
		 * sctp_do_bind(). -daisy
		 */
		retval = sctp_del_bind_addr(bp, sa_addr);

		addr_buf += af->sockaddr_len;
err_bindx_rem:
		if (retval < 0) {
			/* Failed. Add the ones that has been removed back */
			if (cnt > 0)
				sctp_bindx_add(sk, addrs, cnt);
			return retval;
		}
	}

	return retval;
}


  static void Encode(TensorBuffer* in, int64_t n, Destination* out) {
    port::EncodeStringList(in->base<const tstring>(), n, out);
  }


static int64_t update_size(AVIOContext *pb, int64_t pos)
{
    int64_t curpos = avio_tell(pb);
    avio_seek(pb, pos, SEEK_SET);
    avio_wb32(pb, curpos - pos); /* rewrite size */
    avio_seek(pb, curpos, SEEK_SET);

    return curpos - pos;
}


int update_approximate_line_to_order(ORDER_INFO* orderInfo, const LINE_TO_ORDER* line_to)
{
	return 32;
}


  void Start() {
    DVLOG(2) << "Starting SafeBrowsing download check for: "
             << item_->DebugString(true);
    DCHECK_CURRENTLY_ON(BrowserThread::UI);
    DownloadCheckResultReason reason = REASON_MAX;
    if (!IsSupportedDownload(
        *item_, item_->GetTargetFilePath(), &reason, &type_)) {
      switch (reason) {
        case REASON_EMPTY_URL_CHAIN:
        case REASON_INVALID_URL:
        case REASON_UNSUPPORTED_URL_SCHEME:
          PostFinishTask(UNKNOWN, reason);
          return;

        case REASON_NOT_BINARY_FILE:
          RecordFileExtensionType(item_->GetTargetFilePath());
          PostFinishTask(UNKNOWN, reason);
          return;

        default:
          NOTREACHED();
      }
    }
    RecordFileExtensionType(item_->GetTargetFilePath());

     if (item_->GetTargetFilePath().MatchesExtension(
         FILE_PATH_LITERAL(".zip"))) {
       StartExtractZipFeatures();
#if defined(OS_MACOSX)
    } else if (item_->GetTargetFilePath().MatchesExtension(
                  FILE_PATH_LITERAL(".dmg"))) {
      StartExtractDmgFeatures();
#endif
     } else {
       DCHECK(!download_protection_util::IsArchiveFile(
           item_->GetTargetFilePath()));
      StartExtractFileFeatures();
    }
  }


pdf14_free_smask_color(pdf14_device * pdev)
{
    if (pdev->smaskcolor != NULL) {
        if ( pdev->smaskcolor->profiles != NULL) {
            /* Do not decrement the softmask enties.  They will remain
               in the icc_manager softmask member.  They were not
               incremented when moved here */
            gs_free_object(pdev->memory, pdev->smaskcolor->profiles,
                        "pdf14_free_smask_color");
        }
        gs_free_object(pdev->memory, pdev->smaskcolor, "pdf14_free_smask_color");
        pdev->smaskcolor = NULL;
    }
}


static void enabledAtRuntimeAttrAttributeSetter(v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
{
    ExceptionState exceptionState(ExceptionState::SetterContext, "enabledAtRuntimeAttr", "TestObject", info.Holder(), info.GetIsolate());
    TestObject* imp = V8TestObject::toNative(info.Holder());
    V8TRYCATCH_EXCEPTION_VOID(int, cppValue, toInt32(jsValue, exceptionState), exceptionState);
    imp->setEnabledAtRuntimeAttr(cppValue);
}


_public_ sd_bus_slot* sd_bus_get_current_slot(sd_bus *bus) {
        assert_return(bus, NULL);

        return bus->current_slot;
}


int BIO_vprintf ( BIO * bio , const char * format , va_list args ) {
 int ret ;
 size_t retlen ;
 char hugebuf [ 1024 * 2 ] ;
 char * hugebufp = hugebuf ;
 size_t hugebufsize = sizeof ( hugebuf ) ;
 char * dynbuf = NULL ;
 int ignored ;
 dynbuf = NULL ;
 CRYPTO_push_info ( "doapr()" ) ;
 _dopr ( & hugebufp , & dynbuf , & hugebufsize , & retlen , & ignored , format , args ) ;
 if ( dynbuf ) {
 ret = BIO_write ( bio , dynbuf , ( int ) retlen ) ;
 OPENSSL_free ( dynbuf ) ;
 }
 else {
 ret = BIO_write ( bio , hugebuf , ( int ) retlen ) ;
 }
 CRYPTO_pop_info ( ) ;
 return ( ret ) ;
 }


int getParamsType (const YCPMap&m)
{
    if (m->value(YCPString("match")).isNull())
	return -1;
    if (!isYCPStringPair (m->value (YCPString ("match"))))
	return -1;

    if (m->value(YCPString("multiline")).isNull())
	return 1;
    if (!isYCPStringPair (m->value (YCPString ("multiline"))))
	return 1;

    return 0;
}


xfs_bioerror(
	xfs_buf_t *bp)
{
#ifdef XFSERRORDEBUG
	ASSERT(XFS_BUF_ISREAD(bp) || bp->b_iodone);
#endif

	/*
	 * No need to wait until the buffer is unpinned, we aren't flushing it.
	 */
	xfs_buf_ioerror(bp, EIO);

	/*
	 * We're calling xfs_buf_ioend, so delete XBF_DONE flag.
	 */
	XFS_BUF_UNREAD(bp);
	XFS_BUF_UNDONE(bp);
	xfs_buf_stale(bp);

	xfs_buf_ioend(bp, 0);

	return EIO;
}


ldbm_config_mode_set(void *arg, void *value, char *errorbuf __attribute__((unused)), int phase __attribute__((unused)), int apply)
{
    struct ldbminfo *li = (struct ldbminfo *)arg;
    int retval = LDAP_SUCCESS;
    int val = (int)((uintptr_t)value);

    /* Do whatever we can to make sure the data is ok. */

    if (apply) {
        li->li_mode = val;
    }

    return retval;
}


static int xemaclite_mdio_setup(struct net_local *lp, struct device *dev)
{
	struct mii_bus *bus;
	int rc;
	struct resource res;
	struct device_node *np = of_get_parent(lp->phy_node);
	struct device_node *npp;

	/* Don't register the MDIO bus if the phy_node or its parent node
	 * can't be found.
	 */
	if (!np) {
		dev_err(dev, "Failed to register mdio bus.\n");
		return -ENODEV;
	}
	npp = of_get_parent(np);

	of_address_to_resource(npp, 0, &res);
	if (lp->ndev->mem_start != res.start) {
		struct phy_device *phydev;
		phydev = of_phy_find_device(lp->phy_node);
		if (!phydev)
			dev_info(dev,
				 "MDIO of the phy is not registered yet\n");
		else
			put_device(&phydev->mdio.dev);
		return 0;
	}

	/* Enable the MDIO bus by asserting the enable bit in MDIO Control
	 * register.
	 */
	xemaclite_writel(XEL_MDIOCTRL_MDIOEN_MASK,
			 lp->base_addr + XEL_MDIOCTRL_OFFSET);

	bus = mdiobus_alloc();
	if (!bus) {
		dev_err(dev, "Failed to allocate mdiobus\n");
		return -ENOMEM;
	}

	snprintf(bus->id, MII_BUS_ID_SIZE, "%.8llx",
		 (unsigned long long)res.start);
	bus->priv = lp;
	bus->name = "Xilinx Emaclite MDIO";
	bus->read = xemaclite_mdio_read;
	bus->write = xemaclite_mdio_write;
	bus->parent = dev;

	rc = of_mdiobus_register(bus, np);
	if (rc) {
		dev_err(dev, "Failed to register mdio bus.\n");
		goto err_register;
	}

	lp->mii_bus = bus;

	return 0;

err_register:
	mdiobus_free(bus);
	return rc;
}


  bool StateEquals(int index, const State& state) {
    State s = GetStateAt(index);
    return (s.src_contents == state.src_contents &&
            s.dst_contents == state.dst_contents &&
            s.src_index == state.src_index &&
            s.dst_index == state.dst_index &&
            s.user_gesture == state.user_gesture &&
            s.foreground == state.foreground &&
            s.action == state.action);
  }


extract_auth_val(char **q)
{
    unsigned char *qq = *(unsigned char **)q;
    int quoted = 0;
    Str val = Strnew();

    SKIP_BLANKS(qq);
    if (*qq == '"') {
	quoted = TRUE;
	Strcat_char(val, *qq++);
    }
    while (*qq != '\0') {
	if (quoted && *qq == '"') {
	    Strcat_char(val, *qq++);
	    break;
	}
	if (!quoted) {
	    switch (*qq) {
	    case '[':
	    case ']':
	    case '(':
	    case ')':
	    case '<':
	    case '>':
	    case '@':
	    case ';':
	    case ':':
	    case '\\':
	    case '"':
	    case '/':
	    case '?':
	    case '=':
	    case ' ':
	    case '\t':
		qq++;
	    case ',':
		goto end_token;
	    default:
		if (*qq <= 037 || *qq == 0177) {
		    qq++;
		    goto end_token;
		}
	    }
	}
	else if (quoted && *qq == '\\')
	    Strcat_char(val, *qq++);
	Strcat_char(val, *qq++);
    }
  end_token:
    *q = (char *)qq;
    return val;
}


void OSD::start_boot()
{
  if (!_is_healthy()) {
    // if we are not healthy, do not mark ourselves up (yet)
    dout(1) << "not healthy; waiting to boot" << dendl;
    if (!is_waiting_for_healthy())
      start_waiting_for_healthy();
    // send pings sooner rather than later
    heartbeat_kick();
    return;
  }
  dout(1) << __func__ << dendl;
  set_state(STATE_PREBOOT);
  waiting_for_luminous_mons = false;
  dout(10) << "start_boot - have maps " << superblock.oldest_map
	   << ".." << superblock.newest_map << dendl;
  C_OSD_GetVersion *c = new C_OSD_GetVersion(this);
  monc->get_version("osdmap", &c->newest, &c->oldest, c);
}


static int local_remove(FsContext *ctx, const char *path)

{

    int err;

    struct stat stbuf;

    char buffer[PATH_MAX];

    if (ctx->export_flags & V9FS_SM_MAPPED_FILE) {

        err =  lstat(rpath(ctx, path, buffer), &stbuf);

        if (err) {

            goto err_out;

        }

        /*

         * If directory remove .virtfs_metadata contained in the

         * directory

         */

        if (S_ISDIR(stbuf.st_mode)) {

            snprintf(buffer, ARRAY_SIZE(buffer), "%s/%s/%s",

                     ctx->fs_root, path, VIRTFS_META_DIR);

            err = remove(buffer);

            if (err < 0 && errno != ENOENT) {

                /*

                 * We didn't had the .virtfs_metadata file. May be file created

                 * in non-mapped mode ?. Ignore ENOENT.

                 */

                goto err_out;

            }

        }

        /*

         * Now remove the name from parent directory

         * .virtfs_metadata directory

         */

        err = remove(local_mapped_attr_path(ctx, path, buffer));

        if (err < 0 && errno != ENOENT) {

            /*

             * We didn't had the .virtfs_metadata file. May be file created

             * in non-mapped mode ?. Ignore ENOENT.

             */

            goto err_out;

        }

    }

    return remove(rpath(ctx, path, buffer));

err_out:

    return err;

}


static void ElementAttributeAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info) {
  v8::Local<v8::Object> holder = info.Holder();

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

  V8SetReturnValueFast(info, WTF::GetPtr(impl->elementAttribute()), impl);
}


bool TabletModeWindowManager::ShouldHandleWindow(aura::Window* window) {
  DCHECK(window);

  if (window->GetProperty(aura::client::kZOrderingKey) !=
      ui::ZOrderLevel::kNormal) {
    return false;
  }

  if (!wm::GetWindowState(window) ||
      wm::GetWindowState(window)->allow_set_bounds_direct()) {
    return false;
  }

  return window->type() == aura::client::WINDOW_TYPE_NORMAL;
}


fstring_find_literal(const char **str, const char *end, int raw,
                     PyObject **literal, int recurse_lvl,
                     struct compiling *c, const node *n)
{
    /* Get any literal string. It ends when we hit an un-doubled left
       brace (which isn't part of a unicode name escape such as
       "\N{EULER CONSTANT}"), or the end of the string. */

    const char *literal_start = *str;
    const char *literal_end;
    int in_named_escape = 0;
    int result = 0;

    assert(*literal == NULL);
    for (; *str < end; (*str)++) {
        char ch = **str;
        if (!in_named_escape && ch == '{' && (*str)-literal_start >= 2 &&
            *(*str-2) == '\\' && *(*str-1) == 'N') {
            in_named_escape = 1;
        } else if (in_named_escape && ch == '}') {
            in_named_escape = 0;
        } else if (ch == '{' || ch == '}') {
            /* Check for doubled braces, but only at the top level. If
               we checked at every level, then f'{0:{3}}' would fail
               with the two closing braces. */
            if (recurse_lvl == 0) {
                if (*str+1 < end && *(*str+1) == ch) {
                    /* We're going to tell the caller that the literal ends
                       here, but that they should continue scanning. But also
                       skip over the second brace when we resume scanning. */
                    literal_end = *str+1;
                    *str += 2;
                    result = 1;
                    goto done;
                }

                /* Where a single '{' is the start of a new expression, a
                   single '}' is not allowed. */
                if (ch == '}') {
                    ast_error(c, n, "f-string: single '}' is not allowed");
                    return -1;
                }
            }
            /* We're either at a '{', which means we're starting another
               expression; or a '}', which means we're at the end of this
               f-string (for a nested format_spec). */
            break;
        }
    }
    literal_end = *str;
    assert(*str <= end);
    assert(*str == end || **str == '{' || **str == '}');
done:
    if (literal_start != literal_end) {
        if (raw)
            *literal = PyUnicode_DecodeUTF8Stateful(literal_start,
                                                    literal_end-literal_start,
                                                    NULL, NULL);
        else
            *literal = decode_unicode_with_escapes(c, n, literal_start,
                                                   literal_end-literal_start);
        if (!*literal)
            return -1;
    }
    return result;
}


static void disable_pubkey_algo ( int algorithm ) {
 gcry_module_t pubkey ;
 ath_mutex_lock ( & pubkeys_registered_lock ) ;
 pubkey = _gcry_module_lookup_id ( pubkeys_registered , algorithm ) ;
 if ( pubkey ) {
 if ( ! ( pubkey -> flags & FLAG_MODULE_DISABLED ) ) pubkey -> flags |= FLAG_MODULE_DISABLED ;
 _gcry_module_release ( pubkey ) ;
 }
 ath_mutex_unlock ( & pubkeys_registered_lock ) ;
 }