int streamAppendItem(stream *s, robj **argv, int64_t numfields, streamID *added_id, streamID *use_id) {

    /* Generate the new entry ID. */
    streamID id;
    if (use_id)
        id = *use_id;
    else
        streamNextID(&s->last_id,&id);

    /* Check that the new ID is greater than the last entry ID
     * or return an error. Automatically generated IDs might
     * overflow (and wrap-around) when incrementing the sequence
       part. */
    if (streamCompareID(&id,&s->last_id) <= 0) return C_ERR;

    /* Add the new entry. */
    raxIterator ri;
    raxStart(&ri,s->rax);
    raxSeek(&ri,"$",NULL,0);

    size_t lp_bytes = 0;        /* Total bytes in the tail listpack. */
    unsigned char *lp = NULL;   /* Tail listpack pointer. */

    /* Get a reference to the tail node listpack. */
    if (raxNext(&ri)) {
        lp = ri.data;
        lp_bytes = lpBytes(lp);
    }
    raxStop(&ri);

    /* We have to add the key into the radix tree in lexicographic order,
     * to do so we consider the ID as a single 128 bit number written in
     * big endian, so that the most significant bytes are the first ones. */
    uint64_t rax_key[2];    /* Key in the radix tree containing the listpack.*/
    streamID master_id;     /* ID of the master entry in the listpack. */

    /* Create a new listpack and radix tree node if needed. Note that when
     * a new listpack is created, we populate it with a "master entry". This
     * is just a set of fields that is taken as references in order to compress
     * the stream entries that we'll add inside the listpack.
     *
     * Note that while we use the first added entry fields to create
     * the master entry, the first added entry is NOT represented in the master
     * entry, which is a stand alone object. But of course, the first entry
     * will compress well because it's used as reference.
     *
     * The master entry is composed like in the following example:
     *
     * +-------+---------+------------+---------+--/--+---------+---------+-+
     * | count | deleted | num-fields | field_1 | field_2 | ... | field_N |0|
     * +-------+---------+------------+---------+--/--+---------+---------+-+
     *
     * count and deleted just represent respectively the total number of
     * entries inside the listpack that are valid, and marked as deleted
     * (deleted flag in the entry flags set). So the total number of items
     * actually inside the listpack (both deleted and not) is count+deleted.
     *
     * The real entries will be encoded with an ID that is just the
     * millisecond and sequence difference compared to the key stored at
     * the radix tree node containing the listpack (delta encoding), and
     * if the fields of the entry are the same as the master entry fields, the
     * entry flags will specify this fact and the entry fields and number
     * of fields will be omitted (see later in the code of this function).
     *
     * The "0" entry at the end is the same as the 'lp-count' entry in the
     * regular stream entries (see below), and marks the fact that there are
     * no more entries, when we scan the stream from right to left. */

    /* First of all, check if we can append to the current macro node or
     * if we need to switch to the next one. 'lp' will be set to NULL if
     * the current node is full. */
    if (lp != NULL) {
        if (server.stream_node_max_bytes &&
            lp_bytes >= server.stream_node_max_bytes)
        {
            lp = NULL;
        } else if (server.stream_node_max_entries) {
            int64_t count = lpGetInteger(lpFirst(lp));
            if (count >= server.stream_node_max_entries) lp = NULL;
        }
    }

    int flags = STREAM_ITEM_FLAG_NONE;
    if (lp == NULL || lp_bytes >= server.stream_node_max_bytes) {
        master_id = id;
        streamEncodeID(rax_key,&id);
        /* Create the listpack having the master entry ID and fields. */
        lp = lpNew();
        lp = lpAppendInteger(lp,1); /* One item, the one we are adding. */
        lp = lpAppendInteger(lp,0); /* Zero deleted so far. */
        lp = lpAppendInteger(lp,numfields);
        for (int64_t i = 0; i < numfields; i++) {
            sds field = argv[i*2]->ptr;
            lp = lpAppend(lp,(unsigned char*)field,sdslen(field));
        }
        lp = lpAppendInteger(lp,0); /* Master entry zero terminator. */
        raxInsert(s->rax,(unsigned char*)&rax_key,sizeof(rax_key),lp,NULL);
        /* The first entry we insert, has obviously the same fields of the
         * master entry. */
        flags |= STREAM_ITEM_FLAG_SAMEFIELDS;
    } else {
        serverAssert(ri.key_len == sizeof(rax_key));
        memcpy(rax_key,ri.key,sizeof(rax_key));

        /* Read the master ID from the radix tree key. */
        streamDecodeID(rax_key,&master_id);
        unsigned char *lp_ele = lpFirst(lp);

        /* Update count and skip the deleted fields. */
        int64_t count = lpGetInteger(lp_ele);
        lp = lpReplaceInteger(lp,&lp_ele,count+1);
        lp_ele = lpNext(lp,lp_ele); /* seek deleted. */
        lp_ele = lpNext(lp,lp_ele); /* seek master entry num fields. */

        /* Check if the entry we are adding, have the same fields
         * as the master entry. */
        int64_t master_fields_count = lpGetInteger(lp_ele);
        lp_ele = lpNext(lp,lp_ele);
        if (numfields == master_fields_count) {
            int64_t i;
            for (i = 0; i < master_fields_count; i++) {
                sds field = argv[i*2]->ptr;
                int64_t e_len;
                unsigned char buf[LP_INTBUF_SIZE];
                unsigned char *e = lpGet(lp_ele,&e_len,buf);
                /* Stop if there is a mismatch. */
                if (sdslen(field) != (size_t)e_len ||
                    memcmp(e,field,e_len) != 0) break;
                lp_ele = lpNext(lp,lp_ele);
            }
            /* All fields are the same! We can compress the field names
             * setting a single bit in the flags. */
            if (i == master_fields_count) flags |= STREAM_ITEM_FLAG_SAMEFIELDS;
        }
    }

    /* Populate the listpack with the new entry. We use the following
     * encoding:
     *
     * +-----+--------+----------+-------+-------+-/-+-------+-------+--------+
     * |flags|entry-id|num-fields|field-1|value-1|...|field-N|value-N|lp-count|
     * +-----+--------+----------+-------+-------+-/-+-------+-------+--------+
     *
     * However if the SAMEFIELD flag is set, we have just to populate
     * the entry with the values, so it becomes:
     *
     * +-----+--------+-------+-/-+-------+--------+
     * |flags|entry-id|value-1|...|value-N|lp-count|
     * +-----+--------+-------+-/-+-------+--------+
     *
     * The entry-id field is actually two separated fields: the ms
     * and seq difference compared to the master entry.
     *
     * The lp-count field is a number that states the number of listpack pieces
     * that compose the entry, so that it's possible to travel the entry
     * in reverse order: we can just start from the end of the listpack, read
     * the entry, and jump back N times to seek the "flags" field to read
     * the stream full entry. */
    lp = lpAppendInteger(lp,flags);
    lp = lpAppendInteger(lp,id.ms - master_id.ms);
    lp = lpAppendInteger(lp,id.seq - master_id.seq);
    if (!(flags & STREAM_ITEM_FLAG_SAMEFIELDS))
        lp = lpAppendInteger(lp,numfields);
    for (int64_t i = 0; i < numfields; i++) {
        sds field = argv[i*2]->ptr, value = argv[i*2+1]->ptr;
        if (!(flags & STREAM_ITEM_FLAG_SAMEFIELDS))
            lp = lpAppend(lp,(unsigned char*)field,sdslen(field));
        lp = lpAppend(lp,(unsigned char*)value,sdslen(value));
    }
    /* Compute and store the lp-count field. */
    int64_t lp_count = numfields;
    lp_count += 3; /* Add the 3 fixed fields flags + ms-diff + seq-diff. */
    if (!(flags & STREAM_ITEM_FLAG_SAMEFIELDS)) {
        /* If the item is not compressed, it also has the fields other than
         * the values, and an additional num-fileds field. */
        lp_count += numfields+1;
    }
    lp = lpAppendInteger(lp,lp_count);

    /* Insert back into the tree in order to update the listpack pointer. */
    if (ri.data != lp)
        raxInsert(s->rax,(unsigned char*)&rax_key,sizeof(rax_key),lp,NULL);
    s->length++;
    s->last_id = id;
    if (added_id) *added_id = id;
    return C_OK;
}


char *redisProtocolToLuaType_Aggregate(lua_State *lua, char *reply, int atype) {
    char *p = strchr(reply+1,'\r');
    long long mbulklen;
    int j = 0;

    string2ll(reply+1,p-reply-1,&mbulklen);
    if (server.lua_client->resp == 2 || atype == '*') {
        p += 2;
        if (mbulklen == -1) {
            lua_pushboolean(lua,0);
            return p;
        }
        lua_newtable(lua);
        for (j = 0; j < mbulklen; j++) {
            lua_pushnumber(lua,j+1);
            p = redisProtocolToLuaType(lua,p);
            lua_settable(lua,-3);
        }
    } else if (server.lua_client->resp == 3) {
        /* Here we handle only Set and Map replies in RESP3 mode, since arrays
         * follow the above RESP2 code path. Note that those are represented
         * as a table with the "map" or "set" field populated with the actual
         * table representing the set or the map type. */
        p += 2;
        lua_newtable(lua);
        lua_pushstring(lua,atype == '%' ? "map" : "set");
        lua_newtable(lua);
        for (j = 0; j < mbulklen; j++) {
            p = redisProtocolToLuaType(lua,p);
            if (atype == '%') {
                p = redisProtocolToLuaType(lua,p);
            } else {
                lua_pushboolean(lua,1);
            }
            lua_settable(lua,-3);
        }
        lua_settable(lua,-3);
    }
    return p;
}


static VALUE int_ossl_asn1_decode0_cons ( unsigned char * * pp , long max_len , long length , long * offset , int depth , int yield , int j , int tag , VALUE tc , long * num_read ) {
 VALUE value , asn1data , ary ;
 int infinite ;
 long available_len , off = * offset ;
 infinite = ( j == 0x21 ) ;
 ary = rb_ary_new ( ) ;
 available_len = infinite ? max_len : length ;
 while ( available_len > 0 ) {
 long inner_read = 0 ;
 value = ossl_asn1_decode0 ( pp , available_len , & off , depth + 1 , yield , & inner_read ) ;
 * num_read += inner_read ;
 available_len -= inner_read ;
 rb_ary_push ( ary , value ) ;
 if ( infinite && NUM2INT ( ossl_asn1_get_tag ( value ) ) == V_ASN1_EOC && ossl_asn1_get_tag_class ( value ) == sym_UNIVERSAL ) {
 break ;
 }
 }
 if ( tc == sym_UNIVERSAL ) {
 VALUE args [ 4 ] ;
 int not_sequence_or_set ;
 not_sequence_or_set = tag != V_ASN1_SEQUENCE && tag != V_ASN1_SET ;
 if ( not_sequence_or_set ) {
 if ( infinite ) {
 asn1data = rb_obj_alloc ( cASN1Constructive ) ;
 }
 else {
 ossl_raise ( eASN1Error , "invalid non-infinite tag" ) ;
 return Qnil ;
 }
 }
 else {
 VALUE klass = * ossl_asn1_info [ tag ] . klass ;
 asn1data = rb_obj_alloc ( klass ) ;
 }
 args [ 0 ] = ary ;
 args [ 1 ] = INT2NUM ( tag ) ;
 args [ 2 ] = Qnil ;
 args [ 3 ] = tc ;
 ossl_asn1_initialize ( 4 , args , asn1data ) ;
 }
 else {
 asn1data = rb_obj_alloc ( cASN1Data ) ;
 ossl_asn1data_initialize ( asn1data , ary , INT2NUM ( tag ) , tc ) ;
 }
 if ( infinite ) ossl_asn1_set_infinite_length ( asn1data , Qtrue ) ;
 else ossl_asn1_set_infinite_length ( asn1data , Qfalse ) ;
 * offset = off ;
 return asn1data ;
 }


void qmp_migrate_set_parameters(bool has_compress_level, int64_t compress_level, bool has_compress_threads, int64_t compress_threads, bool has_decompress_threads, int64_t decompress_threads, bool has_cpu_throttle_initial, int64_t cpu_throttle_initial, bool has_cpu_throttle_increment, int64_t cpu_throttle_increment, Error **errp) { MigrationState *s = migrate_get_current(); if (has_compress_level && (compress_level < 0 || compress_level > 9)) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "compress_level", "is invalid, it should be in the range of 0 to 9"); return; } if (has_compress_threads && (compress_threads < 1 || compress_threads > 255)) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "compress_threads", "is invalid, it should be in the range of 1 to 255"); return; } if (has_decompress_threads && (decompress_threads < 1 || decompress_threads > 255)) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "decompress_threads", "is invalid, it should be in the range of 1 to 255"); return; } if (has_cpu_throttle_initial && (cpu_throttle_initial < 1 || cpu_throttle_initial > 99)) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "cpu_throttle_initial", "an integer in the range of 1 to 99"); } if (has_cpu_throttle_increment && (cpu_throttle_increment < 1 || cpu_throttle_increment > 99)) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "cpu_throttle_increment", "an integer in the range of 1 to 99"); } if (has_compress_level) { s->parameters.compress_level = compress_level; } if (has_compress_threads) { s->parameters.compress_threads = compress_threads; } if (has_decompress_threads) { s->parameters.decompress_threads = decompress_threads; } if (has_cpu_throttle_initial) { s->parameters.cpu_throttle_initial = cpu_throttle_initial; } if (has_cpu_throttle_increment) { s->parameters.cpu_throttle_increment = cpu_throttle_increment; } if (has_tls_creds) { g_free(s->parameters.tls_creds); s->parameters.tls_creds = g_strdup(tls_creds); } if (has_tls_hostname) { g_free(s->parameters.tls_hostname); s->parameters.tls_hostname = g_strdup(tls_hostname); } }


static guint32 dissect_netb_add_name ( tvbuff_t * tvb , packet_info * pinfo _U_ , int offset , proto_tree * tree ) {
 nb_resp_corrl ( tvb , offset , tree ) ;
 netbios_add_name ( "Name to add" , tvb , offset + NB_SENDER_NAME , tree ) ;
 return 0 ;
 }


static int swf_write_packet(AVFormatContext *s, int stream_index, const uint8_t *buf, int size, int64_t pts) { AVCodecContext *codec = &s->streams[stream_index]->codec; if (codec->codec_type == CODEC_TYPE_AUDIO) return swf_write_audio(s, buf, size); else return swf_write_video(s, codec, buf, size); }


static void alpha_cpu_realizefn(DeviceState *dev, Error **errp) { AlphaCPUClass *acc = ALPHA_CPU_GET_CLASS(dev); acc->parent_realize(dev, errp); }


MOBI_RET mobi_parse_huffdic(const MOBIData *m, MOBIHuffCdic *huffcdic) {
    MOBI_RET ret;
    const size_t offset = mobi_get_kf8offset(m);
    if (m->mh == NULL || m->mh->huff_rec_index == NULL || m->mh->huff_rec_count == NULL) {
        debug_print("%s", "HUFF/CDIC records metadata not found in MOBI header\n");
        return MOBI_DATA_CORRUPT;
    }
    const size_t huff_rec_index = *m->mh->huff_rec_index + offset;
    const size_t huff_rec_count = *m->mh->huff_rec_count;
    if (huff_rec_count > HUFF_RECORD_MAXCNT) {
        debug_print("Too many HUFF record (%zu)\n", huff_rec_count);
        return MOBI_DATA_CORRUPT;
    }
    const MOBIPdbRecord *curr = mobi_get_record_by_seqnumber(m, huff_rec_index);
    if (curr == NULL || huff_rec_count < 2) {
        debug_print("%s", "HUFF/CDIC record not found\n");
        return MOBI_DATA_CORRUPT;
    }
    if (curr->size < HUFF_RECORD_MINSIZE) {
        debug_print("HUFF record too short (%zu b)\n", curr->size);
        return MOBI_DATA_CORRUPT;
    }
    ret = mobi_parse_huff(huffcdic, curr);
    if (ret != MOBI_SUCCESS) {
        debug_print("%s", "HUFF parsing failed\n");
        return ret;
    }
    curr = curr->next;
    /* allocate memory for symbols data in each CDIC record */
    huffcdic->symbols = malloc((huff_rec_count - 1) * sizeof(*huffcdic->symbols));
    if (huffcdic->symbols == NULL) {
        debug_print("%s\n", "Memory allocation failed");
        return MOBI_MALLOC_FAILED;
    }
    /* get following CDIC records */
    size_t i = 0;
    while (i < huff_rec_count - 1) {
        if (curr == NULL) {
            debug_print("%s\n", "CDIC record not found");
            return MOBI_DATA_CORRUPT;
        }
        ret = mobi_parse_cdic(huffcdic, curr, i++);
        if (ret != MOBI_SUCCESS) {
            debug_print("%s", "CDIC parsing failed\n");
            return ret;
        }
        curr = curr->next;
    }
    return MOBI_SUCCESS;
}


static void s390_cpu_initfn(Object *obj) { CPUState *cs = CPU(obj); S390CPU *cpu = S390_CPU(obj); CPUS390XState *env = &cpu->env; static bool inited; static int cpu_num = 0; #if !defined(CONFIG_USER_ONLY) struct tm tm; #endif cs->env_ptr = env; cpu_exec_init(env); #if !defined(CONFIG_USER_ONLY) qemu_register_reset(s390_cpu_machine_reset_cb, cpu); qemu_get_timedate(&tm, 0); env->tod_offset = TOD_UNIX_EPOCH + (time2tod(mktimegm(&tm)) * 1000000000ULL); env->tod_basetime = 0; env->tod_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, s390x_tod_timer, cpu); env->cpu_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, s390x_cpu_timer, cpu); s390_cpu_set_state(CPU_STATE_STOPPED, cpu); #endif env->cpu_num = cpu_num++; env->ext_index = -1; if (tcg_enabled() && !inited) { inited = true; s390x_translate_init(); } }


void vp9_setup_in_frame_q_adj ( VP9_COMP * cpi ) {
 VP9_COMMON * const cm = & cpi -> common ;
 struct segmentation * const seg = & cm -> seg ;
 vp9_clear_system_state ( ) ;
 if ( cm -> frame_type == KEY_FRAME || cpi -> refresh_alt_ref_frame || ( cpi -> refresh_golden_frame && ! cpi -> rc . is_src_frame_alt_ref ) ) {
 int segment ;
 const int aq_strength = get_aq_c_strength ( cm -> base_qindex ) ;
 const int active_segments = aq_c_active_segments [ aq_strength ] ;
 vpx_memset ( cpi -> segmentation_map , 0 , cm -> mi_rows * cm -> mi_cols ) ;
 vpx_memset ( cpi -> complexity_map , 0 , cm -> mi_rows * cm -> mi_cols ) ;
 vp9_clearall_segfeatures ( seg ) ;
 if ( cpi -> rc . sb64_target_rate < 256 ) {
 vp9_disable_segmentation ( seg ) ;
 return ;
 }
 vp9_enable_segmentation ( seg ) ;
 seg -> abs_delta = SEGMENT_DELTADATA ;
 vp9_disable_segfeature ( seg , 0 , SEG_LVL_ALT_Q ) ;
 for ( segment = 1 ;
 segment < active_segments ;
 ++ segment ) {
 int qindex_delta = vp9_compute_qdelta_by_rate ( & cpi -> rc , cm -> frame_type , cm -> base_qindex , aq_c_q_adj_factor [ aq_strength ] [ segment ] ) ;
 if ( ( cm -> base_qindex != 0 ) && ( ( cm -> base_qindex + qindex_delta ) == 0 ) ) {
 qindex_delta = - cm -> base_qindex + 1 ;
 }
 if ( ( cm -> base_qindex + qindex_delta ) > 0 ) {
 vp9_enable_segfeature ( seg , segment , SEG_LVL_ALT_Q ) ;
 vp9_set_segdata ( seg , segment , SEG_LVL_ALT_Q , qindex_delta ) ;
 }
 }
 }
 }


static int x8_decode_intra_mb(IntraX8Context *const w, const int chroma) { MpegEncContext *const s = w->s; uint8_t *scantable; int final, run, level; int ac_mode, dc_mode, est_run, dc_level; int pos, n; int zeros_only; int use_quant_matrix; int sign; assert(w->orient < 12); s->bdsp.clear_block(s->block[0]); if (chroma) dc_mode = 2; else dc_mode = !!w->est_run; // 0, 1 if (x8_get_dc_rlf(w, dc_mode, &dc_level, &final)) return -1; n = 0; zeros_only = 0; if (!final) { // decode ac use_quant_matrix = w->use_quant_matrix; if (chroma) { ac_mode = 1; est_run = 64; // not used } else { if (w->raw_orient < 3) use_quant_matrix = 0; if (w->raw_orient > 4) { ac_mode = 0; est_run = 64; } else { if (w->est_run > 1) { ac_mode = 2; est_run = w->est_run; } else { ac_mode = 3; est_run = 64; } } } x8_select_ac_table(w, ac_mode); /* scantable_selector[12] = { 0, 2, 0, 1, 1, 1, 0, 2, 2, 0, 1, 2 }; <- * -> 10'01' 00'10' 10'00' 01'01' 01'00' 10'00 => 0x928548 */ scantable = w->scantable[(0x928548 >> (2 * w->orient)) & 3].permutated; pos = 0; do { n++; if (n >= est_run) { ac_mode = 3; x8_select_ac_table(w, 3); } x8_get_ac_rlf(w, ac_mode, &run, &level, &final); pos += run + 1; if (pos > 63) { // this also handles vlc error in x8_get_ac_rlf return -1; } level = (level + 1) * w->dquant; level += w->qsum; sign = -get_bits1(&s->gb); level = (level ^ sign) - sign; if (use_quant_matrix) level = (level * quant_table[pos]) >> 8; s->block[0][scantable[pos]] = level; } while (!final); s->block_last_index[0] = pos; } else { // DC only s->block_last_index[0] = 0; if (w->flat_dc && ((unsigned) (dc_level + 1)) < 3) { // [-1; 1] int32_t divide_quant = !chroma ? w->divide_quant_dc_luma : w->divide_quant_dc_chroma; int32_t dc_quant = !chroma ? w->quant : w->quant_dc_chroma; // original intent dc_level += predicted_dc/quant; // but it got lost somewhere in the rounding dc_level += (w->predicted_dc * divide_quant + (1 << 12)) >> 13; dsp_x8_put_solidcolor(av_clip_uint8((dc_level * dc_quant + 4) >> 3), w->dest[chroma], s->current_picture.f->linesize[!!chroma]); goto block_placed; } zeros_only = (dc_level == 0); } if (!chroma) s->block[0][0] = dc_level * w->quant; else s->block[0][0] = dc_level * w->quant_dc_chroma; // there is !zero_only check in the original, but dc_level check is enough if ((unsigned int) (dc_level + 1) >= 3 && (w->edges & 3) != 3) { int direction; /* ac_comp_direction[orient] = { 0, 3, 3, 1, 1, 0, 0, 0, 2, 2, 2, 1 }; <- * -> 01'10' 10'10' 00'00' 00'01' 01'11' 11'00 => 0x6A017C */ direction = (0x6A017C >> (w->orient * 2)) & 3; if (direction != 3) { // modify block_last[] x8_ac_compensation(w, direction, s->block[0][0]); } } if (w->flat_dc) { dsp_x8_put_solidcolor(w->predicted_dc, w->dest[chroma], s->current_picture.f->linesize[!!chroma]); } else { w->dsp.spatial_compensation[w->orient](s->sc.edge_emu_buffer, w->dest[chroma], s->current_picture.f->linesize[!!chroma]); } if (!zeros_only) w->idsp.idct_add(w->dest[chroma], s->current_picture.f->linesize[!!chroma], s->block[0]); block_placed: if (!chroma) x8_update_predictions(w, w->orient, n); if (s->loop_filter) { uint8_t *ptr = w->dest[chroma]; int linesize = s->current_picture.f->linesize[!!chroma]; if (!((w->edges & 2) || (zeros_only && (w->orient | 4) == 4))) w->dsp.h_loop_filter(ptr, linesize, w->quant); if (!((w->edges & 1) || (zeros_only && (w->orient | 8) == 8))) w->dsp.v_loop_filter(ptr, linesize, w->quant); } return 0; }


static unsigned int dec_bound_m(DisasContext *dc) { TCGv l[2]; int memsize = memsize_zz(dc); int insn_len; DIS(fprintf (logfile, "bound.%d [$r%u%s, $r%u\n", memsize_char(memsize), dc->op1, dc->postinc ? "+]" : "]", dc->op2)); l[0] = tcg_temp_local_new(TCG_TYPE_TL); l[1] = tcg_temp_local_new(TCG_TYPE_TL); insn_len = dec_prep_alu_m(dc, 0, memsize, l[0], l[1]); cris_cc_mask(dc, CC_MASK_NZ); cris_alu(dc, CC_OP_BOUND, cpu_R[dc->op2], l[0], l[1], 4); do_postinc(dc, memsize); tcg_temp_free(l[0]); tcg_temp_free(l[1]); return insn_len; }


bytesPerDeepLineTable (const Header &header,
                       int minY, int maxY,
                       const char* base,
                       int xStride,
                       int yStride,
                       vector<size_t> &bytesPerLine)
{
    const Box2i &dataWindow = header.dataWindow();
    const ChannelList &channels = header.channels();

    for (ChannelList::ConstIterator c = channels.begin();
         c != channels.end();
         ++c)
    {
        const int ySampling = abs(c.channel().ySampling);
        const int xSampling = abs(c.channel().xSampling);
        const int pixelSize = pixelTypeSize (c.channel().type);

        // Here we transform from the domain over all pixels into the domain
        // of actual samples.  We want to sample points in [minY, maxY] where
        // (y % ySampling) == 0.  However, doing this by rejecting samples
        // requires O(height*width) modulo computations, which were a
        // significant bottleneck in the previous implementation of this
        // function.  For the low, low price of 4 divisions per channel, we
        // can tighten the y & x ranges to the least and greatest roots of the
        // sampling function and then stride by the sampling rate.
        const int sampleMinY = roundToNextMultiple(minY, ySampling);
        const int sampleMaxY = roundToPrevMultiple(maxY, ySampling);
        const int sampleMinX = roundToNextMultiple(dataWindow.min.x, xSampling);
        const int sampleMaxX = roundToPrevMultiple(dataWindow.max.x, xSampling);

        for (int y = sampleMinY; y <= sampleMaxY; y+=ySampling)
        {
            int nBytes = 0;
            for (int x = sampleMinX; x <= sampleMaxX; x += xSampling)
            {
                nBytes += pixelSize *
                          sampleCount(base, xStride, yStride, x, y);
            }
            bytesPerLine[y - dataWindow.min.y] += nBytes;
        }
    }

    size_t maxBytesPerLine = 0;

    for (int y = minY; y <= maxY; ++y)
        if (maxBytesPerLine < bytesPerLine[y - dataWindow.min.y])
            maxBytesPerLine = bytesPerLine[y - dataWindow.min.y];

    return maxBytesPerLine;
}


static void typhoon_set_irq ( void * opaque , int irq , int level ) {
 TyphoonState * s = opaque ;
 uint64_t drir ;
 int i ;
 drir = s -> cchip . drir ;
 if ( level ) {
 drir |= 1ull << irq ;
 }
 else {
 drir &= ~ ( 1ull << irq ) ;
 }
 s -> cchip . drir = drir ;
 for ( i = 0 ;
 i < 4 ;
 ++ i ) {
 cpu_irq_change ( s -> cchip . cpu [ i ] , s -> cchip . dim [ i ] & drir ) ;
 }
 }


List * find_forced_null_vars ( Node * node ) {
 List * result = NIL ;
 Var * var ;
 ListCell * l ;
 if ( node == NULL ) return NIL ;
 var = find_forced_null_var ( node ) ;
 if ( var ) {
 result = list_make1 ( var ) ;
 }
 else if ( IsA ( node , List ) ) {
 foreach ( l , ( List * ) node ) {
 result = list_concat ( result , find_forced_null_vars ( lfirst ( l ) ) ) ;
 }
 }
 else if ( IsA ( node , BoolExpr ) ) {
 BoolExpr * expr = ( BoolExpr * ) node ;
 if ( expr -> boolop == AND_EXPR ) {
 result = find_forced_null_vars ( ( Node * ) expr -> args ) ;
 }
 }
 return result ;
 }


static void tcg_reg_alloc_op(TCGContext *s, const TCGOpDef *def, TCGOpcode opc, const TCGArg *args, uint16_t dead_args, uint8_t sync_args) { TCGRegSet allocated_regs; int i, k, nb_iargs, nb_oargs, reg; TCGArg arg; const TCGArgConstraint *arg_ct; TCGTemp *ts; TCGArg new_args[TCG_MAX_OP_ARGS]; int const_args[TCG_MAX_OP_ARGS]; nb_oargs = def->nb_oargs; nb_iargs = def->nb_iargs; /* copy constants */ memcpy(new_args + nb_oargs + nb_iargs, args + nb_oargs + nb_iargs, sizeof(TCGArg) * def->nb_cargs); /* satisfy input constraints */ tcg_regset_set(allocated_regs, s->reserved_regs); for(k = 0; k < nb_iargs; k++) { i = def->sorted_args[nb_oargs + k]; arg = args[i]; arg_ct = &def->args_ct[i]; ts = &s->temps[arg]; if (ts->val_type == TEMP_VAL_MEM) { reg = tcg_reg_alloc(s, arg_ct->u.regs, allocated_regs); tcg_out_ld(s, ts->type, reg, ts->mem_reg, ts->mem_offset); ts->val_type = TEMP_VAL_REG; ts->reg = reg; ts->mem_coherent = 1; s->reg_to_temp[reg] = arg; } else if (ts->val_type == TEMP_VAL_CONST) { if (tcg_target_const_match(ts->val, ts->type, arg_ct)) { /* constant is OK for instruction */ const_args[i] = 1; new_args[i] = ts->val; goto iarg_end; } else { /* need to move to a register */ reg = tcg_reg_alloc(s, arg_ct->u.regs, allocated_regs); tcg_out_movi(s, ts->type, reg, ts->val); ts->val_type = TEMP_VAL_REG; ts->reg = reg; ts->mem_coherent = 0; s->reg_to_temp[reg] = arg; } } assert(ts->val_type == TEMP_VAL_REG); if (arg_ct->ct & TCG_CT_IALIAS) { if (ts->fixed_reg) { /* if fixed register, we must allocate a new register if the alias is not the same register */ if (arg != args[arg_ct->alias_index]) goto allocate_in_reg; } else { /* if the input is aliased to an output and if it is not dead after the instruction, we must allocate a new register and move it */ if (!IS_DEAD_ARG(i)) { goto allocate_in_reg; } /* check if the current register has already been allocated for another input aliased to an output */ int k2, i2; for (k2 = 0 ; k2 < k ; k2++) { i2 = def->sorted_args[nb_oargs + k2]; if ((def->args_ct[i2].ct & TCG_CT_IALIAS) && (new_args[i2] == ts->reg)) { goto allocate_in_reg; } } } } reg = ts->reg; if (tcg_regset_test_reg(arg_ct->u.regs, reg)) { /* nothing to do : the constraint is satisfied */ } else { allocate_in_reg: /* allocate a new register matching the constraint and move the temporary register into it */ reg = tcg_reg_alloc(s, arg_ct->u.regs, allocated_regs); tcg_out_mov(s, ts->type, reg, ts->reg); } new_args[i] = reg; const_args[i] = 0; tcg_regset_set_reg(allocated_regs, reg); iarg_end: ; } /* mark dead temporaries and free the associated registers */ for (i = nb_oargs; i < nb_oargs + nb_iargs; i++) { if (IS_DEAD_ARG(i)) { temp_dead(s, args[i]); } } if (def->flags & TCG_OPF_BB_END) { tcg_reg_alloc_bb_end(s, allocated_regs); } else { if (def->flags & TCG_OPF_CALL_CLOBBER) { /* XXX: permit generic clobber register list ? */ for(reg = 0; reg < TCG_TARGET_NB_REGS; reg++) { if (tcg_regset_test_reg(tcg_target_call_clobber_regs, reg)) { tcg_reg_free(s, reg); } } } if (def->flags & TCG_OPF_SIDE_EFFECTS) { /* sync globals if the op has side effects and might trigger an exception. */ sync_globals(s, allocated_regs); } /* satisfy the output constraints */ tcg_regset_set(allocated_regs, s->reserved_regs); for(k = 0; k < nb_oargs; k++) { i = def->sorted_args[k]; arg = args[i]; arg_ct = &def->args_ct[i]; ts = &s->temps[arg]; if (arg_ct->ct & TCG_CT_ALIAS) { reg = new_args[arg_ct->alias_index]; } else { /* if fixed register, we try to use it */ reg = ts->reg; if (ts->fixed_reg && tcg_regset_test_reg(arg_ct->u.regs, reg)) { goto oarg_end; } reg = tcg_reg_alloc(s, arg_ct->u.regs, allocated_regs); } tcg_regset_set_reg(allocated_regs, reg); /* if a fixed register is used, then a move will be done afterwards */ if (!ts->fixed_reg) { if (ts->val_type == TEMP_VAL_REG) { s->reg_to_temp[ts->reg] = -1; } ts->val_type = TEMP_VAL_REG; ts->reg = reg; /* temp value is modified, so the value kept in memory is potentially not the same */ ts->mem_coherent = 0; s->reg_to_temp[reg] = arg; } oarg_end: new_args[i] = reg; } } /* emit instruction */ tcg_out_op(s, opc, new_args, const_args); /* move the outputs in the correct register if needed */ for(i = 0; i < nb_oargs; i++) { ts = &s->temps[args[i]]; reg = new_args[i]; if (ts->fixed_reg && ts->reg != reg) { tcg_out_mov(s, ts->type, ts->reg, reg); } if (NEED_SYNC_ARG(i)) { tcg_reg_sync(s, reg); } if (IS_DEAD_ARG(i)) { temp_dead(s, args[i]); } } }


void slirp_input(const uint8_t *pkt, int pkt_len) { struct mbuf *m; int proto; if (pkt_len < ETH_HLEN) return; proto = ntohs(*(uint16_t *)(pkt + 12)); switch(proto) { case ETH_P_ARP: arp_input(pkt, pkt_len); break; case ETH_P_IP: m = m_get(); if (!m) return; /* Note: we add to align the IP header */ m->m_len = pkt_len + 2; memcpy(m->m_data + 2, pkt, pkt_len); m->m_data += 2 + ETH_HLEN; m->m_len -= 2 + ETH_HLEN; ip_input(m); break; default: break;


static void rv34_pred_mv_b ( RV34DecContext * r , int block_type , int dir ) {
 MpegEncContext * s = & r -> s ;
 int mb_pos = s -> mb_x + s -> mb_y * s -> mb_stride ;
 int mv_pos = s -> mb_x * 2 + s -> mb_y * 2 * s -> b8_stride ;
 int A [ 2 ] = {
 0 }
 , B [ 2 ] = {
 0 }
 , C [ 2 ] = {
 0 }
 ;
 int has_A = 0 , has_B = 0 , has_C = 0 ;
 int mx , my ;
 int i , j ;
 Picture * cur_pic = s -> current_picture_ptr ;
 const int mask = dir ? MB_TYPE_L1 : MB_TYPE_L0 ;
 int type = cur_pic -> mb_type [ mb_pos ] ;
 if ( ( r -> avail_cache [ 6 - 1 ] & type ) & mask ) {
 A [ 0 ] = cur_pic -> motion_val [ dir ] [ mv_pos - 1 ] [ 0 ] ;
 A [ 1 ] = cur_pic -> motion_val [ dir ] [ mv_pos - 1 ] [ 1 ] ;
 has_A = 1 ;
 }
 if ( ( r -> avail_cache [ 6 - 4 ] & type ) & mask ) {
 B [ 0 ] = cur_pic -> motion_val [ dir ] [ mv_pos - s -> b8_stride ] [ 0 ] ;
 B [ 1 ] = cur_pic -> motion_val [ dir ] [ mv_pos - s -> b8_stride ] [ 1 ] ;
 has_B = 1 ;
 }
 if ( r -> avail_cache [ 6 - 4 ] && ( r -> avail_cache [ 6 - 2 ] & type ) & mask ) {
 C [ 0 ] = cur_pic -> motion_val [ dir ] [ mv_pos - s -> b8_stride + 2 ] [ 0 ] ;
 C [ 1 ] = cur_pic -> motion_val [ dir ] [ mv_pos - s -> b8_stride + 2 ] [ 1 ] ;
 has_C = 1 ;
 }
 else if ( ( s -> mb_x + 1 ) == s -> mb_width && ( r -> avail_cache [ 6 - 5 ] & type ) & mask ) {
 C [ 0 ] = cur_pic -> motion_val [ dir ] [ mv_pos - s -> b8_stride - 1 ] [ 0 ] ;
 C [ 1 ] = cur_pic -> motion_val [ dir ] [ mv_pos - s -> b8_stride - 1 ] [ 1 ] ;
 has_C = 1 ;
 }
 rv34_pred_b_vector ( A , B , C , has_A , has_B , has_C , & mx , & my ) ;
 mx += r -> dmv [ dir ] [ 0 ] ;
 my += r -> dmv [ dir ] [ 1 ] ;
 for ( j = 0 ;
 j < 2 ;
 j ++ ) {
 for ( i = 0 ;
 i < 2 ;
 i ++ ) {
 cur_pic -> motion_val [ dir ] [ mv_pos + i + j * s -> b8_stride ] [ 0 ] = mx ;
 cur_pic -> motion_val [ dir ] [ mv_pos + i + j * s -> b8_stride ] [ 1 ] = my ;
 }
 }
 if ( block_type == RV34_MB_B_BACKWARD || block_type == RV34_MB_B_FORWARD ) {
 ZERO8x2 ( cur_pic -> motion_val [ ! dir ] [ mv_pos ] , s -> b8_stride ) ;
 }
 }


static int sig_cb ( int operation , ASN1_VALUE * * pval , const ASN1_ITEM * it , void * exarg ) {
 if ( operation == ASN1_OP_NEW_PRE ) {
 DSA_SIG * sig ;
 sig = OPENSSL_malloc ( sizeof ( DSA_SIG ) ) ;
 if ( ! sig ) {
 DSAerr ( DSA_F_SIG_CB , ERR_R_MALLOC_FAILURE ) ;
 return 0 ;
 }
 sig -> r = NULL ;
 sig -> s = NULL ;
 * pval = ( ASN1_VALUE * ) sig ;
 return 2 ;
 }
 return 1 ;
 }


static int decode_nal_sei_message(GetBitContext *gb, void *logctx, HEVCSEI *s, const HEVCParamSets *ps, int nal_unit_type) { int payload_type = 0; int payload_size = 0; int byte = 0xFF; av_log(logctx, AV_LOG_DEBUG, "Decoding SEI\n"); while (byte == 0xFF) { byte = get_bits(gb, 8); payload_type += byte; } byte = 0xFF; while (byte == 0xFF) { byte = get_bits(gb, 8); payload_size += byte; } if (nal_unit_type == HEVC_NAL_SEI_PREFIX) { return decode_nal_sei_prefix(gb, logctx, s, ps, payload_type, payload_size); } else { /* nal_unit_type == NAL_SEI_SUFFIX */ return decode_nal_sei_suffix(gb, logctx, s, payload_type, payload_size); } }


static int x ( struct vcache * avc , int afun , struct vrequest * areq , \ struct afs_pdata * ain , struct afs_pdata * aout , \ afs_ucred_t * * acred ) DECL_PIOCTL ( PGetFID ) ;
 DECL_PIOCTL ( PSetAcl ) ;
 DECL_PIOCTL ( PStoreBehind ) ;
 DECL_PIOCTL ( PGCPAGs ) ;
 DECL_PIOCTL ( PGetAcl ) ;
 DECL_PIOCTL ( PNoop ) ;
 DECL_PIOCTL ( PBogus ) ;
 DECL_PIOCTL ( PGetFileCell ) ;
 DECL_PIOCTL ( PGetWSCell ) ;
 DECL_PIOCTL ( PGetUserCell ) ;
 DECL_PIOCTL ( PSetTokens ) ;
 DECL_PIOCTL ( PGetVolumeStatus ) ;
 DECL_PIOCTL ( PSetVolumeStatus ) ;
 DECL_PIOCTL ( PFlush ) ;
 DECL_PIOCTL ( PNewStatMount ) ;
 DECL_PIOCTL ( PGetTokens )


set_fflags_platform(struct archive_write_disk *a, int fd, const char *name,
    mode_t mode, unsigned long set, unsigned long clear)
{
	int r;
	const int sf_mask = 0
#ifdef SF_APPEND
	    | SF_APPEND
#endif
#ifdef SF_ARCHIVED
	    | SF_ARCHIVED
#endif
#ifdef SF_IMMUTABLE
	    | SF_IMMUTABLE
#endif
#ifdef SF_NOUNLINK
	    | SF_NOUNLINK
#endif
	;
	(void)mode; /* UNUSED */

	if (set == 0  && clear == 0)
		return (ARCHIVE_OK);

	/*
	 * XXX Is the stat here really necessary?  Or can I just use
	 * the 'set' flags directly?  In particular, I'm not sure
	 * about the correct approach if we're overwriting an existing
	 * file that already has flags on it. XXX
	 */
	if ((r = lazy_stat(a)) != ARCHIVE_OK)
		return (r);

	a->st.st_flags &= ~clear;
	a->st.st_flags |= set;

	/* Only super-user may change SF_* flags */

	if (a->user_uid != 0)
		a->st.st_flags &= ~sf_mask;

#ifdef HAVE_FCHFLAGS
	/* If platform has fchflags() and we were given an fd, use it. */
	if (fd >= 0 && fchflags(fd, a->st.st_flags) == 0)
		return (ARCHIVE_OK);
#endif
	/*
	 * If we can't use the fd to set the flags, we'll use the
	 * pathname to set flags.  We prefer lchflags() but will use
	 * chflags() if we must.
	 */
#ifdef HAVE_LCHFLAGS
	if (lchflags(name, a->st.st_flags) == 0)
		return (ARCHIVE_OK);
#elif defined(HAVE_CHFLAGS)
	if (S_ISLNK(a->st.st_mode)) {
		archive_set_error(&a->archive, errno,
		    "Can't set file flags on symlink.");
		return (ARCHIVE_WARN);
	}
	if (chflags(name, a->st.st_flags) == 0)
		return (ARCHIVE_OK);
#endif
	archive_set_error(&a->archive, errno,
	    "Failed to set file flags");
	return (ARCHIVE_WARN);
}


static int64_t alloc_clusters_imrt(BlockDriverState *bs, int cluster_count, uint16_t **refcount_table, int64_t *imrt_nb_clusters, int64_t *first_free_cluster) { BDRVQcowState *s = bs->opaque; int64_t cluster = *first_free_cluster, i; bool first_gap = true; int contiguous_free_clusters; int ret; /* Starting at *first_free_cluster, find a range of at least cluster_count * continuously free clusters */ for (contiguous_free_clusters = 0; cluster < *imrt_nb_clusters && contiguous_free_clusters < cluster_count; cluster++) { if (!(*refcount_table)[cluster]) { contiguous_free_clusters++; if (first_gap) { /* If this is the first free cluster found, update * *first_free_cluster accordingly */ *first_free_cluster = cluster; first_gap = false; } } else if (contiguous_free_clusters) { contiguous_free_clusters = 0; } } /* If contiguous_free_clusters is greater than zero, it contains the number * of continuously free clusters until the current cluster; the first free * cluster in the current "gap" is therefore * cluster - contiguous_free_clusters */ /* If no such range could be found, grow the in-memory refcount table * accordingly to append free clusters at the end of the image */ if (contiguous_free_clusters < cluster_count) { /* contiguous_free_clusters clusters are already empty at the image end; * we need cluster_count clusters; therefore, we have to allocate * cluster_count - contiguous_free_clusters new clusters at the end of * the image (which is the current value of cluster; note that cluster * may exceed old_imrt_nb_clusters if *first_free_cluster pointed beyond * the image end) */ ret = realloc_refcount_array(s, refcount_table, imrt_nb_clusters, cluster + cluster_count - contiguous_free_clusters); if (ret < 0) { return ret; } } /* Go back to the first free cluster */ cluster -= contiguous_free_clusters; for (i = 0; i < cluster_count; i++) { (*refcount_table)[cluster + i] = 1; } return cluster << s->cluster_bits; }


void print_form_element ( int element , int cmd ) {
 time_t t ;
 int t_hour , t_min ;
 char buffer [ MAX_INPUT_BUFFER ] ;
 switch ( element ) {
 case PRINT_COMMON_HEADER : printf ( "

\n" ) ;
 printf ( "
Common Data
\n" ) ;
 printf ( "

\n" ) ;
 break ;
 case PRINT_AUTHOR : printf ( "
Author (Your Name):	" ) ;
 if ( lock_author_names == TRUE ) printf ( "<INPUT TYPE='HIDDEN' NAME='com_author' VALUE='%s'>%s
\n" , escape_string ( comment_author ) , escape_string ( comment_author ) ) ;
 else printf ( "<INPUT TYPE='INPUT' NAME='com_author' VALUE='%s'>
\n" , escape_string ( comment_author ) ) ;
 break ;
 case PRINT_COMMENT_BOX : strcpy ( help_text , "If you work with other administrators, you may find it useful to share information about a host/service " "that is having problems if more than one of you may be working on it. " "Make sure to enter a brief description of what you are doing." ) ;
 printf ( "
Comment:" ) ;
 print_help_box ( help_text ) ;
 printf ( "	" ) ;
 printf ( "<TEXTAREA ID=\"com_data\" NAME='com_data' COLS=25 ROWS=2 onkeyup=\"check_input();
\">%s</TEXTAREA>" , escape_string ( comment_data ) ) ;
 printf ( "

Comment data can't be sent empty
" ) ;
 printf ( "
\n" ) ;
 break ;
 case PRINT_CHECK_OUTPUT_BOX : snprintf ( help_text , sizeof ( help_text ) , "Fill in the exact output string which sould be sent to %s" , PROGRAM_NAME ) ;
 help_text [ sizeof ( help_text ) - 1 ] = '\x0' ;
 printf ( "
Check Output:" ) ;
 print_help_box ( help_text ) ;
 printf ( "	" ) ;
 printf ( "<TEXTAREA ID=\"plugin_output\" NAME='plugin_output' COLS=25 ROWS=2 onkeyup=\"check_input();
\"></TEXTAREA>" ) ;
 printf ( "

Output string can't be send empty
" ) ;
 printf ( "
\n" ) ;
 break ;
 case PRINT_PERFORMANCE_DATA_BOX : snprintf ( help_text , sizeof ( help_text ) , "Fill in the exact performance data string which sould be sent to %s" , PROGRAM_NAME ) ;
 help_text [ sizeof ( help_text ) - 1 ] = '\x0' ;
 printf ( "
Performance Data:" ) ;
 print_help_box ( help_text ) ;
 printf ( "	" ) ;
 printf ( "<TEXTAREA NAME='performance_data' COLS=25 ROWS=2></TEXTAREA>
\n" ) ;
 break ;
 case PRINT_STICKY_ACK : strcpy ( help_text , "If you want acknowledgement to disable notifications until the host/service recovers, check this option." ) ;
 printf ( "
Sticky Acknowledgement:" ) ;
 print_help_box ( help_text ) ;
 printf ( "	" ) ;
 printf ( "<INPUT TYPE='checkbox' NAME='sticky_ack' %s>
\n" , ( sticky_ack == TRUE ) ? "CHECKED" : "" ) ;
 break ;
 case PRINT_SEND_NOTFICATION : strcpy ( help_text , "If you do not want an acknowledgement notification sent out to the appropriate contacts, uncheck this option." ) ;
 printf ( "
Send Notification:" ) ;
 print_help_box ( help_text ) ;
 printf ( "	" ) ;
 printf ( "<INPUT TYPE='checkbox' NAME='send_notification' %s>
\n" , ( send_notification == TRUE ) ? "CHECKED" : "" ) ;
 break ;
 case PRINT_PERSISTENT : if ( cmd == CMD_ACKNOWLEDGE_HOST_PROBLEM || cmd == CMD_ACKNOWLEDGE_SVC_PROBLEM ) strcpy ( help_text , "If you would like the comment to remain once the acknowledgement is removed, check this checkbox." ) ;
 else {
 snprintf ( help_text , sizeof ( help_text ) , "If you uncheck this option, the comment will automatically be deleted the next time %s is restarted." , PROGRAM_NAME ) ;
 help_text [ sizeof ( help_text ) - 1 ] = '\x0' ;
 }
 printf ( "
Persistent%s:" , ( cmd == CMD_ACKNOWLEDGE_HOST_PROBLEM || cmd == CMD_ACKNOWLEDGE_SVC_PROBLEM ) ? " Comment" : "" ) ;
 print_help_box ( help_text ) ;
 printf ( "	" ) ;
 printf ( "<INPUT TYPE='checkbox' NAME='persistent' %s>
\n" , ( persistent_ack_comments == TRUE || cmd == CMD_ADD_HOST_COMMENT || cmd == CMD_ADD_SVC_COMMENT ) ? "CHECKED" : "" ) ;
 break ;
 case PRINT_NOTIFICATION_DELAY : strcpy ( help_text , "The notification delay will be disregarded if the host/service changes state before the next notification is scheduled to be sent out." ) ;
 printf ( "
Notification Delay (minutes from now):" ) ;
 print_help_box ( help_text ) ;
 printf ( "	" ) ;
 printf ( "<INPUT TYPE='TEXT' ID='not_dly' NAME='not_dly' VALUE='%d' SIZE=\"4\">" , notification_delay ) ;
 printf ( "

Notification delay can't be zero
" ) ;
 printf ( "
\n" ) ;
 break ;
 case PRINT_START_TIME : case PRINT_END_TIME : case PRINT_CHECK_TIME : time ( & t ) ;
 if ( element == PRINT_END_TIME ) t += ( unsigned long ) default_downtime_duration ;
 get_time_string ( & t , buffer , sizeof ( buffer ) - 1 , SHORT_DATE_TIME ) ;
 printf ( "
" ) ;
 if ( element == PRINT_START_TIME ) {
 strcpy ( help_text , "Set the start date/time for the downtime." ) ;
 printf ( "Start Time:" ) ;
 }
 else if ( element == PRINT_END_TIME ) {
 strcpy ( help_text , "Set the end date/time for the downtime." ) ;
 printf ( "End Time:" ) ;
 }
 else {
 strcpy ( help_text , "Set the date/time when this check should be schedule to." ) ;
 printf ( "Check Time:" ) ;
 }
 print_help_box ( help_text ) ;
 printf ( "	<INPUT TYPE='TEXT' class='timepicker' NAME='%s_time' VALUE='%s' SIZE=\"25\">
\n" , ( element == PRINT_END_TIME ) ? "end" : "start" , buffer ) ;
 break ;
 case PRINT_FIXED_FLEXIBLE_TYPE : default_downtime_duration = default_downtime_duration / 60 ;
 t_min = default_downtime_duration % 60 ;
 default_downtime_duration = default_downtime_duration - t_min ;
 t_hour = ( default_downtime_duration / 60 ) ;
 snprintf ( help_text , sizeof ( help_text ) , "If you select the fixed option, the downtime will be in effect between the start and end times you specify. If you do not select the fixed " "option, %s will treat this as flexible downtime. Flexible downtime starts when the host goes down or becomes unreachable / service becomes critical (sometime between the " "start and end times you specified) and lasts as long as the duration of time you enter. The duration fields do not apply for fixed downtime." , PROGRAM_NAME ) ;
 help_text [ sizeof ( help_text ) - 1 ] = '\x0' ;
 printf ( "
Type:" ) ;
 print_help_box ( help_text ) ;
 printf ( "	\n" ) ;
 printf ( "\t<SELECT ID=\"flexible_selection\" NAME='fixed' onChange=\"if (document.getElementById('flexible_selection').selectedIndex == 0) document.getElementById('fd_row').style.display = 'none';
 else document.getElementById('fd_row').style.display = '';
\">\n" ) ;
 printf ( "\t\t<OPTION VALUE=1\">Fixed</OPTION>\n" ) ;
 printf ( "\t\t<OPTION VALUE=0\">Flexible</OPTION>\n" ) ;
 printf ( "\t</SELECT>\n" ) ;
 snprintf ( help_text , sizeof ( help_text ) , "Enter here the duration of the downtime. %s will automatically delete the downtime after this time expired." , PROGRAM_NAME ) ;
 help_text [ sizeof ( help_text ) - 1 ] = '\x0' ;
 printf ( "
Flexible Duration:" ) ;
 print_help_box ( help_text ) ;
 printf ( "	\n" ) ;
 printf ( "\t
\n" ) ;
 printf ( "\t\t
\n" ) ;
 printf ( "\t\t\t<INPUT TYPE='TEXT' NAME='hours' VALUE='%d' SIZE=4 MAXLENGTH=4>	\n" , t_hour ) ;
 printf ( "\t\t\t
Hours	\n" ) ;
 printf ( "\t\t\t<INPUT TYPE='TEXT' NAME='minutes' VALUE='%d' SIZE=2 MAXLENGTH=2>	\n" , t_min ) ;
 printf ( "\t\t\t
Minutes	\n" ) ;
 printf ( "\t\t
\n" ) ;
 printf ( "\t
\n" ) ;
 printf ( "
\n" ) ;
 break ;
 case PRINT_EXPIRE_ACKNOWLEDGEMENT : strcpy ( help_text , "If you want to let the acknowledgement expire, check this option." ) ;
 printf ( "
Use Expire Time:" ) ;
 print_help_box ( help_text ) ;
 printf ( "	" ) ;
 printf ( "<INPUT TYPE='checkbox' ID='expire_checkbox' NAME='use_ack_end_time' onClick=\"if (document.getElementById('expire_checkbox').checked == true) document.getElementById('expired_date_row').style.display = '';
 else document.getElementById('expired_date_row').style.display = 'none';
\">
\n" ) ;
 snprintf ( help_text , sizeof ( help_text ) , "Enter here the expire date/time for this acknowledgement. %s will automatically delete the acknowledgement after this time expired." , PROGRAM_NAME ) ;
 help_text [ sizeof ( help_text ) - 1 ] = '\x0' ;
 time ( & t ) ;
 t += ( unsigned long ) default_expiring_acknowledgement_duration ;
 get_time_string ( & t , buffer , sizeof ( buffer ) - 1 , SHORT_DATE_TIME ) ;
 printf ( "
Expire Time:" ) ;
 print_help_box ( help_text ) ;
 printf ( "	<INPUT TYPE='TEXT' class='timepicker' NAME='end_time' VALUE='%s' SIZE=\"25\">
\n" , buffer ) ;
 break ;
 case PRINT_EXPIRE_DISABLE_NOTIFICATIONS : strcpy ( help_text , "If you want to let the disabled notifications expire, check this option." ) ;
 printf ( "
Use Expire Time:" ) ;
 print_help_box ( help_text ) ;
 printf ( "	" ) ;
 printf ( "<INPUT TYPE='checkbox' ID='expire_checkbox' NAME='use_disabled_notif_end_time' onClick=\"if (document.getElementById('expire_checkbox').checked == true) document.getElementById('expired_date_row').style.display = '';
 else document.getElementById('expired_date_row').style.display = 'none';
\">
\n" ) ;
 snprintf ( help_text , sizeof ( help_text ) , "Enter the expire date/time for disabled notifications. %s will automatically re-enable all notifications after this time expired." , PROGRAM_NAME ) ;
 help_text [ sizeof ( help_text ) - 1 ] = '\x0' ;
 time ( & t ) ;
 t += ( unsigned long ) default_expiring_disabled_notifications_duration ;
 get_time_string ( & t , buffer , sizeof ( buffer ) - 1 , SHORT_DATE_TIME ) ;
 printf ( "
Expire Time:" ) ;
 print_help_box ( help_text ) ;
 printf ( "	<INPUT TYPE='TEXT' class='timepicker' NAME='end_time' VALUE='%s' SIZE=\"25\">
\n" , buffer ) ;
 break ;
 case PRINT_FORCE_CHECK : snprintf ( help_text , sizeof ( help_text ) , "If you select this option, %s will force a check of the host/service regardless of both what time the scheduled check occurs and whether or not checks are enabled for the host/service." , PROGRAM_NAME ) ;
 help_text [ sizeof ( help_text ) - 1 ] = '\x0' ;
 printf ( "
Force Check:" ) ;
 print_help_box ( help_text ) ;
 printf ( "	" ) ;
 printf ( "<INPUT TYPE='checkbox' NAME='force_check' %s>
\n" , ( force_check == TRUE ) ? "CHECKED" : "" ) ;
 break ;
 case PRINT_BROADCAST_NOTIFICATION : strcpy ( help_text , "Selecting this option causes the notification to be sent out to all normal (non-escalated) and escalated contacts. These options allow you to override the normal notification logic if you need to get an important message out." ) ;
 printf ( "
Broadcast:" ) ;
 print_help_box ( help_text ) ;
 printf ( "	" ) ;
 printf ( "<INPUT TYPE='checkbox' NAME='broadcast_notification'>
\n" ) ;
 break ;
 case PRINT_FORCE_NOTIFICATION : snprintf ( help_text , sizeof ( help_text ) , "Custom notifications normally follow the regular notification logic in %s. Selecting this option will force the notification to be sent out, regardless of the time restrictions, whether or not notifications are enabled, etc." , PROGRAM_NAME ) ;
 help_text [ sizeof ( help_text ) - 1 ] = '\x0' ;
 printf ( "
Forced:" ) ;
 print_help_box ( help_text ) ;
 printf ( "	" ) ;
 printf ( "<INPUT TYPE='checkbox' NAME='force_notification'>
\n" ) ;
 break ;
 default : break ;
 }
 return ;
 }


av_cold void ff_rv34dsp_init(RV34DSPContext *c, DSPContext* dsp) { c->rv34_inv_transform = rv34_inv_transform_noround_c; c->rv34_inv_transform_dc = rv34_inv_transform_dc_noround_c; c->rv34_idct_add = rv34_idct_add_c; c->rv34_idct_dc_add = rv34_idct_dc_add_c; if (HAVE_NEON) ff_rv34dsp_init_neon(c, dsp); if (ARCH_X86) ff_rv34dsp_init_x86(c, dsp); }


static double http_parse_qvalue ( const char * & buf , int & len ) {
 double val = 1.0 ;
 if ( * buf != ';
' ) {
 return val ;
 }
 buf += 1 ;
 len -= 1 ;
 while ( len > 0 && * buf ) {
 http_skip_ws ( buf , len ) ;
 if ( * buf == 'q' ) {
 buf += 1 ;
 len -= 1 ;
 http_skip_ws ( buf , len ) ;
 if ( * buf == '=' ) {
 double n ;
 int f ;
 buf += 1 ;
 len -= 1 ;
 http_skip_ws ( buf , len ) ;
 n = 0.0 ;
 while ( len > 0 && * buf && ParseRules : : is_digit ( * buf ) ) {
 n = ( n * 10 ) + ( * buf ++ - '0' ) ;
 len -= 1 ;
 }
 if ( * buf == '.' ) {
 buf += 1 ;
 len -= 1 ;
 f = 10 ;
 while ( len > 0 && * buf && ParseRules : : is_digit ( * buf ) ) {
 n += ( * buf ++ - '0' ) / ( double ) f ;
 f *= 10 ;
 len -= 1 ;
 }
 }
 val = n ;
 }
 }
 else {
 while ( len > 0 && * buf ) {
 if ( * buf != ';
' ) {
 buf += 1 ;
 len -= 1 ;
 }
 else {
 buf += 1 ;
 len -= 1 ;
 break ;
 }
 }
 }
 }
 return val ;
 }


TSReturnCode TSMgmtStringGet ( const char * var_name , TSMgmtString * result ) {
 RecString tmp = nullptr ;
 ( void ) RecGetRecordString_Xmalloc ( ( char * ) var_name , & tmp ) ;
 if ( tmp ) {
 * result = tmp ;
 return TS_SUCCESS ;
 }
 return TS_ERROR ;
 }


zend_object_value pdo_row_new ( zend_class_entry * ce TSRMLS_DC ) {
 zend_object_value retval ;
 retval . handle = zend_objects_store_put ( NULL , ( zend_objects_store_dtor_t ) zend_objects_destroy_object , ( zend_objects_free_object_storage_t ) pdo_row_free_storage , NULL TSRMLS_CC ) ;
 retval . handlers = & pdo_row_object_handlers ;
 return retval ;
 }


int bdrv_is_encrypted(BlockDriverState *bs) { if (bs->backing_hd && bs->backing_hd->encrypted) return 1; return bs->encrypted; }


static inline void SetPixelWriteMask ( const Image * restrict image , const Quantum mask , Quantum * restrict pixel ) {
 if ( image -> channel_map [ WriteMaskPixelChannel ] . traits != UndefinedPixelTrait ) pixel [ image -> channel_map [ WriteMaskPixelChannel ] . offset ] = mask ;
 }


static int ffmpeg_va_GetFrameBuf ( struct AVCodecContext * p_context , AVFrame * p_ff_pic ) {
 decoder_t * p_dec = ( decoder_t * ) p_context -> opaque ;
 decoder_sys_t * p_sys = p_dec -> p_sys ;
 vlc_va_t * p_va = p_sys -> p_va ;
 if ( vlc_va_Setup ( p_va , & p_context -> hwaccel_context , & p_dec -> fmt_out . video . i_chroma , p_context -> coded_width , p_context -> coded_height ) ) {
 msg_Err ( p_dec , "vlc_va_Setup failed" ) ;
 return - 1 ;
 }
 if ( vlc_va_Get ( p_va , & p_ff_pic -> opaque , & p_ff_pic -> data [ 0 ] ) ) {
 msg_Err ( p_dec , "vlc_va_Get failed" ) ;
 return - 1 ;
 }
 p_ff_pic -> data [ 3 ] = p_ff_pic -> data [ 0 ] ;
 p_ff_pic -> type = FF_BUFFER_TYPE_USER ;
 return 0 ;
 }


static int pci_cmd646_ide_initfn(PCIDevice *dev) { PCIIDEState *d = DO_UPCAST(PCIIDEState, dev, dev); uint8_t *pci_conf = d->dev.config; qemu_irq *irq; int i; pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_CMD); pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_CMD_646); pci_conf[PCI_REVISION_ID] = 0x07; // IDE controller revision pci_conf[PCI_CLASS_PROG] = 0x8f; pci_config_set_class(pci_conf, PCI_CLASS_STORAGE_IDE); pci_conf[0x51] = 0x04; // enable IDE0 if (d->secondary) { /* XXX: if not enabled, really disable the seconday IDE controller */ pci_conf[0x51] |= 0x08; /* enable IDE1 */ } pci_register_bar(dev, 0, 0x8, PCI_BASE_ADDRESS_SPACE_IO, ide_map); pci_register_bar(dev, 1, 0x4, PCI_BASE_ADDRESS_SPACE_IO, ide_map); pci_register_bar(dev, 2, 0x8, PCI_BASE_ADDRESS_SPACE_IO, ide_map); pci_register_bar(dev, 3, 0x4, PCI_BASE_ADDRESS_SPACE_IO, ide_map); pci_register_bar(dev, 4, 0x10, PCI_BASE_ADDRESS_SPACE_IO, bmdma_map); /* TODO: RST# value should be 0 */ pci_conf[PCI_INTERRUPT_PIN] = 0x01; // interrupt on pin 1 irq = qemu_allocate_irqs(cmd646_set_irq, d, 2); for (i = 0; i < 2; i++) { ide_bus_new(&d->bus[i], &d->dev.qdev, i); ide_init2(&d->bus[i], irq[i]); bmdma_init(&d->bus[i], &d->bmdma[i]); d->bmdma[i].bus = &d->bus[i]; qemu_add_vm_change_state_handler(d->bus[i].dma->ops->restart_cb, &d->bmdma[i].dma); } vmstate_register(&dev->qdev, 0, &vmstate_ide_pci, d); qemu_register_reset(cmd646_reset, d); return 0; }


void * data_create_arabic ( const hb_ot_shape_plan_t * plan ) {
 arabic_shape_plan_t * arabic_plan = ( arabic_shape_plan_t * ) calloc ( 1 , sizeof ( arabic_shape_plan_t ) ) ;
 if ( unlikely ( ! arabic_plan ) ) return NULL ;
 arabic_plan -> do_fallback = plan -> props . script == HB_SCRIPT_ARABIC ;
 for ( unsigned int i = 0 ;
 i < ARABIC_NUM_FEATURES ;
 i ++ ) {
 arabic_plan -> mask_array [ i ] = plan -> map . get_1_mask ( arabic_features [ i ] ) ;
 arabic_plan -> do_fallback = arabic_plan -> do_fallback && ( FEATURE_IS_SYRIAC ( arabic_features [ i ] ) || plan -> map . needs_fallback ( arabic_features [ i ] ) ) ;
 }
 return arabic_plan ;
 }


static int load_input_picture ( MpegEncContext * s , const AVFrame * pic_arg ) {
 AVFrame * pic = NULL ;
 int64_t pts ;
 int i , display_picture_number = 0 ;
 const int encoding_delay = s -> max_b_frames ? s -> max_b_frames : ( s -> low_delay ? 0 : 1 ) ;
 int direct = 1 ;
 if ( pic_arg ) {
 pts = pic_arg -> pts ;
 display_picture_number = s -> input_picture_number ++ ;
 if ( pts != AV_NOPTS_VALUE ) {
 if ( s -> user_specified_pts != AV_NOPTS_VALUE ) {
 int64_t time = pts ;
 int64_t last = s -> user_specified_pts ;
 if ( time <= last ) {
 av_log ( s -> avctx , AV_LOG_ERROR , "Error, Invalid timestamp=%" PRId64 ", " "last=%" PRId64 "\n" , pts , s -> user_specified_pts ) ;
 return - 1 ;
 }
 if ( ! s -> low_delay && display_picture_number == 1 ) s -> dts_delta = time - last ;
 }
 s -> user_specified_pts = pts ;
 }
 else {
 if ( s -> user_specified_pts != AV_NOPTS_VALUE ) {
 s -> user_specified_pts = pts = s -> user_specified_pts + 1 ;
 av_log ( s -> avctx , AV_LOG_INFO , "Warning: AVFrame.pts=? trying to guess (%" PRId64 ")\n" , pts ) ;
 }
 else {
 pts = display_picture_number ;
 }
 }
 }
 if ( pic_arg ) {
 if ( encoding_delay && ! ( s -> flags & CODEC_FLAG_INPUT_PRESERVED ) ) direct = 0 ;
 if ( pic_arg -> linesize [ 0 ] != s -> linesize ) direct = 0 ;
 if ( pic_arg -> linesize [ 1 ] != s -> uvlinesize ) direct = 0 ;
 if ( pic_arg -> linesize [ 2 ] != s -> uvlinesize ) direct = 0 ;
 av_dlog ( s -> avctx , "%d %d %d %d\n" , pic_arg -> linesize [ 0 ] , pic_arg -> linesize [ 1 ] , s -> linesize , s -> uvlinesize ) ;
 if ( direct ) {
 i = ff_find_unused_picture ( s , 1 ) ;
 if ( i < 0 ) return i ;
 pic = & s -> picture [ i ] . f ;
 pic -> reference = 3 ;
 for ( i = 0 ;
 i < 4 ;
 i ++ ) {
 pic -> data [ i ] = pic_arg -> data [ i ] ;
 pic -> linesize [ i ] = pic_arg -> linesize [ i ] ;
 }
 if ( ff_alloc_picture ( s , ( Picture * ) pic , 1 ) < 0 ) {
 return - 1 ;
 }
 }
 else {
 i = ff_find_unused_picture ( s , 0 ) ;
 if ( i < 0 ) return i ;
 pic = & s -> picture [ i ] . f ;
 pic -> reference = 3 ;
 if ( ff_alloc_picture ( s , ( Picture * ) pic , 0 ) < 0 ) {
 return - 1 ;
 }
 if ( pic -> data [ 0 ] + INPLACE_OFFSET == pic_arg -> data [ 0 ] && pic -> data [ 1 ] + INPLACE_OFFSET == pic_arg -> data [ 1 ] && pic -> data [ 2 ] + INPLACE_OFFSET == pic_arg -> data [ 2 ] ) {
 }
 else {
 int h_chroma_shift , v_chroma_shift ;
 av_pix_fmt_get_chroma_sub_sample ( s -> avctx -> pix_fmt , & h_chroma_shift , & v_chroma_shift ) ;
 for ( i = 0 ;
 i < 3 ;
 i ++ ) {
 int src_stride = pic_arg -> linesize [ i ] ;
 int dst_stride = i ? s -> uvlinesize : s -> linesize ;
 int h_shift = i ? h_chroma_shift : 0 ;
 int v_shift = i ? v_chroma_shift : 0 ;
 int w = s -> width >> h_shift ;
 int h = s -> height >> v_shift ;
 uint8_t * src = pic_arg -> data [ i ] ;
 uint8_t * dst = pic -> data [ i ] ;
 if ( ! s -> avctx -> rc_buffer_size ) dst += INPLACE_OFFSET ;
 if ( src_stride == dst_stride ) memcpy ( dst , src , src_stride * h ) ;
 else {
 while ( h -- ) {
 memcpy ( dst , src , w ) ;
 dst += dst_stride ;
 src += src_stride ;
 }
 }
 }
 }
 }
 copy_picture_attributes ( s , pic , pic_arg ) ;
 pic -> display_picture_number = display_picture_number ;
 pic -> pts = pts ;
 }
 for ( i = 1 ;
 i < MAX_PICTURE_COUNT ;
 i ++ ) s -> input_picture [ i - 1 ] = s -> input_picture [ i ] ;
 s -> input_picture [ encoding_delay ] = ( Picture * ) pic ;
 return 0 ;
 }


static int key_pol_get_resp ( struct sock * sk , struct xfrm_policy * xp , const struct sadb_msg * hdr , int dir ) {
 int err ;
 struct sk_buff * out_skb ;
 struct sadb_msg * out_hdr ;
 err = 0 ;
 out_skb = pfkey_xfrm_policy2msg_prep ( xp ) ;
 if ( IS_ERR ( out_skb ) ) {
 err = PTR_ERR ( out_skb ) ;
 goto out ;
 }
 err = pfkey_xfrm_policy2msg ( out_skb , xp , dir ) ;
 if ( err < 0 ) goto out ;
 out_hdr = ( struct sadb_msg * ) out_skb -> data ;
 out_hdr -> sadb_msg_version = hdr -> sadb_msg_version ;
 out_hdr -> sadb_msg_type = hdr -> sadb_msg_type ;
 out_hdr -> sadb_msg_satype = 0 ;
 out_hdr -> sadb_msg_errno = 0 ;
 out_hdr -> sadb_msg_seq = hdr -> sadb_msg_seq ;
 out_hdr -> sadb_msg_pid = hdr -> sadb_msg_pid ;
 pfkey_broadcast ( out_skb , GFP_ATOMIC , BROADCAST_ONE , sk , xp_net ( xp ) ) ;
 err = 0 ;
 out : return err ;
 }


date_s__iso8601(VALUE klass, VALUE str)
{
    return date__iso8601(str);
}


static void decode_colskip(uint8_t* plane, int width, int height, int stride, VC9Context *v){ int x, y; GetBitContext *gb = &v->s.gb; for (x=0; x<width; x++){ if (!get_bits(gb, 1)) //colskip for (y=0; y<height; y++) plane[y*stride] = 0; else for (y=0; y<height; y++) plane[y*stride] = get_bits(gb, 1); plane ++; } }


datetime_s_rfc2822(int argc, VALUE *argv, VALUE klass)
{
    VALUE str, sg;

    rb_scan_args(argc, argv, "02", &str, &sg);

    switch (argc) {
      case 0:
	str = rb_str_new2("Mon, 1 Jan -4712 00:00:00 +0000");
      case 1:
	sg = INT2FIX(DEFAULT_SG);
    }

    {
	VALUE hash = date_s__rfc2822(klass, str);
	return dt_new_by_frags(klass, hash, sg);
    }
}


int mvfprintf ( FILE * fp , const char * fmt , va_list ap ) {
 # ifndef VSNPRINTF_PERCENT_M char nfmt [ 256 ] ;
 # else const char * nfmt = fmt ;
 # endif int errval ;
 # ifdef SYS_WINNT errval = GetLastError ( ) ;
 if ( NO_ERROR == errval ) # endif errval = errno ;
 # ifndef VSNPRINTF_PERCENT_M format_errmsg ( nfmt , sizeof ( nfmt ) , fmt , errval ) ;
 # else errno = errval ;
 # endif return vfprintf ( fp , nfmt , ap ) ;
 }


static void write_frame_size ( const VP9_COMMON * cm , struct vp9_write_bit_buffer * wb ) {
 vp9_wb_write_literal ( wb , cm -> width - 1 , 16 ) ;
 vp9_wb_write_literal ( wb , cm -> height - 1 , 16 ) ;
 write_display_size ( cm , wb ) ;
 }


static void vc1_h_overlap_c(uint8_t* src, int stride) { int i; int a, b, c, d; int d1, d2; int rnd = 1; for(i = 0; i < 8; i++) { a = src[-2]; b = src[-1]; c = src[0]; d = src[1]; d1 = (a - d + 3 + rnd) >> 3; d2 = (a - d + b - c + 4 - rnd) >> 3; src[-2] = a - d1; src[-1] = b - d2; src[0] = c + d2; src[1] = d + d1; src += stride; rnd = !rnd; } }


static int bpf_map_do_batch(const union bpf_attr *attr,
			    union bpf_attr __user *uattr,
			    int cmd)
{
	struct bpf_map *map;
	int err, ufd;
	struct fd f;

	if (CHECK_ATTR(BPF_MAP_BATCH))
		return -EINVAL;

	ufd = attr->batch.map_fd;
	f = fdget(ufd);
	map = __bpf_map_get(f);
	if (IS_ERR(map))
		return PTR_ERR(map);

	if ((cmd == BPF_MAP_LOOKUP_BATCH ||
	     cmd == BPF_MAP_LOOKUP_AND_DELETE_BATCH) &&
	    !(map_get_sys_perms(map, f) & FMODE_CAN_READ)) {
		err = -EPERM;
		goto err_put;
	}

	if (cmd != BPF_MAP_LOOKUP_BATCH &&
	    !(map_get_sys_perms(map, f) & FMODE_CAN_WRITE)) {
		err = -EPERM;
		goto err_put;
	}

	if (cmd == BPF_MAP_LOOKUP_BATCH)
		BPF_DO_BATCH(map->ops->map_lookup_batch);
	else if (cmd == BPF_MAP_LOOKUP_AND_DELETE_BATCH)
		BPF_DO_BATCH(map->ops->map_lookup_and_delete_batch);
	else if (cmd == BPF_MAP_UPDATE_BATCH)
		BPF_DO_BATCH(map->ops->map_update_batch);
	else
		BPF_DO_BATCH(map->ops->map_delete_batch);

err_put:
	fdput(f);
	return err;
}


static inline uint32_t xen_vcpu_eport(shared_iopage_t *shared_page, int i) { return shared_page->vcpu_iodata[i].vp_eport; }


static int msmpeg4v2_decode_motion ( MpegEncContext * s , int pred , int f_code ) {
 int code , val , sign , shift ;
 code = get_vlc2 ( & s -> gb , v2_mv_vlc . table , V2_MV_VLC_BITS , 2 ) ;
 av_dlog ( s , "MV code %d at %d %d pred: %d\n" , code , s -> mb_x , s -> mb_y , pred ) ;
 if ( code < 0 ) return 0xffff ;
 if ( code == 0 ) return pred ;
 sign = get_bits1 ( & s -> gb ) ;
 shift = f_code - 1 ;
 val = code ;
 if ( shift ) {
 val = ( val - 1 ) << shift ;
 val |= get_bits ( & s -> gb , shift ) ;
 val ++ ;
 }
 if ( sign ) val = - val ;
 val += pred ;
 if ( val <= - 64 ) val += 64 ;
 else if ( val >= 64 ) val -= 64 ;
 return val ;
 }


void rfbProcessUDPInput ( rfbScreenInfoPtr rfbScreen ) {
 int n ;
 rfbClientPtr cl = rfbScreen -> udpClient ;
 rfbClientToServerMsg msg ;
 if ( ( ! cl ) || cl -> onHold ) return ;
 if ( ( n = read ( rfbScreen -> udpSock , ( char * ) & msg , sizeof ( msg ) ) ) <= 0 ) {
 if ( n < 0 ) {
 rfbLogPerror ( "rfbProcessUDPInput: read" ) ;
 }
 rfbDisconnectUDPSock ( rfbScreen ) ;
 return ;
 }
 switch ( msg . type ) {
 case rfbKeyEvent : if ( n != sz_rfbKeyEventMsg ) {
 rfbErr ( "rfbProcessUDPInput: key event incorrect length\n" ) ;
 rfbDisconnectUDPSock ( rfbScreen ) ;
 return ;
 }
 cl -> screen -> kbdAddEvent ( msg . ke . down , ( rfbKeySym ) Swap32IfLE ( msg . ke . key ) , cl ) ;
 break ;
 case rfbPointerEvent : if ( n != sz_rfbPointerEventMsg ) {
 rfbErr ( "rfbProcessUDPInput: ptr event incorrect length\n" ) ;
 rfbDisconnectUDPSock ( rfbScreen ) ;
 return ;
 }
 cl -> screen -> ptrAddEvent ( msg . pe . buttonMask , Swap16IfLE ( msg . pe . x ) , Swap16IfLE ( msg . pe . y ) , cl ) ;
 break ;
 default : rfbErr ( "rfbProcessUDPInput: unknown message type %d\n" , msg . type ) ;
 rfbDisconnectUDPSock ( rfbScreen ) ;
 }
 }


print_actuals_and_locals(Dwarf_Debug dbg,
    Dwarf_Line_Context line_context,
    Dwarf_Unsigned bogus_bytes_count,
    Dwarf_Small *bogus_bytes_ptr,
    Dwarf_Small *orig_line_ptr,
    Dwarf_Small *line_ptr,
    Dwarf_Small *section_start,
    Dwarf_Small *line_ptr_actuals,
    Dwarf_Small *line_ptr_end,
    Dwarf_Half   address_size,
    int *        err_count_out,
    Dwarf_Error *error)
{
    int res = 0;
    dwarfstring m8;
    Dwarf_Unsigned offset = 0;

    dwarfstring_constructor(&m8);
    if (bogus_bytes_count > 0) {
        Dwarf_Unsigned wcount = bogus_bytes_count;
        Dwarf_Unsigned boffset = bogus_bytes_ptr - section_start;

        dwarfstring_append_printf_u(&m8,
            "*** DWARF CHECK: the line table prologue  header_length "
            " is %" DW_PR_DUu " too high, we pretend it is smaller.",
            wcount);
        dwarfstring_append_printf_u(&m8,
            "Section offset: 0x%"
            DW_PR_XZEROS DW_PR_DUx,
            boffset);
        dwarfstring_append_printf_u(&m8,
            " (%" DW_PR_DUu ") ***\n",
            boffset);
        *err_count_out += 1;
    }
    offset = line_ptr - section_start;
    dwarfstring_append_printf_u(&m8,
        "  statement prog offset in section: 0x%"
        DW_PR_XZEROS DW_PR_DUx,
        offset);
    dwarfstring_append_printf_u(&m8,
        " (%" DW_PR_DUu ")\n",
        offset);
    _dwarf_printf(dbg,dwarfstring_string(&m8));
    dwarfstring_reset(&m8);

    {
        Dwarf_Bool doaddrs = false;
        Dwarf_Bool dolines = true;

        if (!line_ptr_actuals) {
            /* Normal single level line table. */

            Dwarf_Bool is_single_table = true;
            Dwarf_Bool is_actuals_table = false;
            print_line_header(dbg, is_single_table, is_actuals_table);
            res = read_line_table_program(dbg,
                line_ptr, line_ptr_end, orig_line_ptr,
                section_start,
                line_context,
                address_size, doaddrs, dolines,
                is_single_table,
                is_actuals_table,
                error,
                err_count_out);
            if (res != DW_DLV_OK) {
                dwarfstring_destructor(&m8);
                dwarf_srclines_dealloc_b(line_context);
                return res;
            }
        } else {
            Dwarf_Bool is_single_table = false;
            Dwarf_Bool is_actuals_table = false;
            if (line_context->lc_version_number !=
                EXPERIMENTAL_LINE_TABLES_VERSION) {
                dwarf_srclines_dealloc_b(line_context);
                dwarfstring_destructor(&m8);
                _dwarf_error(dbg, error, DW_DLE_VERSION_STAMP_ERROR);
                return (DW_DLV_ERROR);
            }
            /* Read Logicals */
            print_line_header(dbg, is_single_table, is_actuals_table);
            res = read_line_table_program(dbg,
                line_ptr, line_ptr_actuals, orig_line_ptr,
                section_start,
                line_context,
                address_size, doaddrs, dolines,
                is_single_table,
                is_actuals_table,
                error,err_count_out);
            if (res != DW_DLV_OK) {
                dwarfstring_destructor(&m8);
                dwarf_srclines_dealloc_b(line_context);
                return res;
            }
            if (line_context->lc_actuals_table_offset > 0) {
                is_actuals_table = true;
                /* Read Actuals */

                print_line_header(dbg, is_single_table, is_actuals_table);
                res = read_line_table_program(dbg,
                    line_ptr_actuals, line_ptr_end, orig_line_ptr,
                    section_start,
                    line_context,
                    address_size, doaddrs, dolines,
                    is_single_table,
                    is_actuals_table,
                    error,
                    err_count_out);
                if (res != DW_DLV_OK) {
                    dwarfstring_destructor(&m8);
                    dwarf_srclines_dealloc_b(line_context);
                    return res;
                }
            }
        }
    }
    dwarfstring_destructor(&m8);
    dwarf_srclines_dealloc_b(line_context);
    return DW_DLV_OK;
}


static bool ieee80211_accept_frame(struct ieee80211_rx_data *rx)
{
	struct ieee80211_sub_if_data *sdata = rx->sdata;
	struct sk_buff *skb = rx->skb;
	struct ieee80211_hdr *hdr = (void *)skb->data;
	struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
	u8 *bssid = ieee80211_get_bssid(hdr, skb->len, sdata->vif.type);
	bool multicast = is_multicast_ether_addr(hdr->addr1);

	switch (sdata->vif.type) {
	case NL80211_IFTYPE_STATION:
		if (!bssid && !sdata->u.mgd.use_4addr)
			return false;
		if (multicast)
			return true;
		return ether_addr_equal(sdata->vif.addr, hdr->addr1);
	case NL80211_IFTYPE_ADHOC:
		if (!bssid)
			return false;
		if (ether_addr_equal(sdata->vif.addr, hdr->addr2) ||
		    ether_addr_equal(sdata->u.ibss.bssid, hdr->addr2))
			return false;
		if (ieee80211_is_beacon(hdr->frame_control))
			return true;
		if (!ieee80211_bssid_match(bssid, sdata->u.ibss.bssid))
			return false;
		if (!multicast &&
		    !ether_addr_equal(sdata->vif.addr, hdr->addr1))
			return false;
		if (!rx->sta) {
			int rate_idx;
			if (status->encoding != RX_ENC_LEGACY)
				rate_idx = 0; /* TODO: HT/VHT rates */
			else
				rate_idx = status->rate_idx;
			ieee80211_ibss_rx_no_sta(sdata, bssid, hdr->addr2,
						 BIT(rate_idx));
		}
		return true;
	case NL80211_IFTYPE_OCB:
		if (!bssid)
			return false;
		if (!ieee80211_is_data_present(hdr->frame_control))
			return false;
		if (!is_broadcast_ether_addr(bssid))
			return false;
		if (!multicast &&
		    !ether_addr_equal(sdata->dev->dev_addr, hdr->addr1))
			return false;
		if (!rx->sta) {
			int rate_idx;
			if (status->encoding != RX_ENC_LEGACY)
				rate_idx = 0; /* TODO: HT rates */
			else
				rate_idx = status->rate_idx;
			ieee80211_ocb_rx_no_sta(sdata, bssid, hdr->addr2,
						BIT(rate_idx));
		}
		return true;
	case NL80211_IFTYPE_MESH_POINT:
		if (ether_addr_equal(sdata->vif.addr, hdr->addr2))
			return false;
		if (multicast)
			return true;
		return ether_addr_equal(sdata->vif.addr, hdr->addr1);
	case NL80211_IFTYPE_AP_VLAN:
	case NL80211_IFTYPE_AP:
		if (!bssid)
			return ether_addr_equal(sdata->vif.addr, hdr->addr1);

		if (!ieee80211_bssid_match(bssid, sdata->vif.addr)) {
			/*
			 * Accept public action frames even when the
			 * BSSID doesn't match, this is used for P2P
			 * and location updates. Note that mac80211
			 * itself never looks at these frames.
			 */
			if (!multicast &&
			    !ether_addr_equal(sdata->vif.addr, hdr->addr1))
				return false;
			if (ieee80211_is_public_action(hdr, skb->len))
				return true;
			return ieee80211_is_beacon(hdr->frame_control);
		}

		if (!ieee80211_has_tods(hdr->frame_control)) {
			/* ignore data frames to TDLS-peers */
			if (ieee80211_is_data(hdr->frame_control))
				return false;
			/* ignore action frames to TDLS-peers */
			if (ieee80211_is_action(hdr->frame_control) &&
			    !is_broadcast_ether_addr(bssid) &&
			    !ether_addr_equal(bssid, hdr->addr1))
				return false;
		}

		/*
		 * 802.11-2016 Table 9-26 says that for data frames, A1 must be
		 * the BSSID - we've checked that already but may have accepted
		 * the wildcard (ff:ff:ff:ff:ff:ff).
		 *
		 * It also says:
		 *	The BSSID of the Data frame is determined as follows:
		 *	a) If the STA is contained within an AP or is associated
		 *	   with an AP, the BSSID is the address currently in use
		 *	   by the STA contained in the AP.
		 *
		 * So we should not accept data frames with an address that's
		 * multicast.
		 *
		 * Accepting it also opens a security problem because stations
		 * could encrypt it with the GTK and inject traffic that way.
		 */
		if (ieee80211_is_data(hdr->frame_control) && multicast)
			return false;

		return true;
	case NL80211_IFTYPE_WDS:
		if (bssid || !ieee80211_is_data(hdr->frame_control))
			return false;
		return ether_addr_equal(sdata->u.wds.remote_addr, hdr->addr2);
	case NL80211_IFTYPE_P2P_DEVICE:
		return ieee80211_is_public_action(hdr, skb->len) ||
		       ieee80211_is_probe_req(hdr->frame_control) ||
		       ieee80211_is_probe_resp(hdr->frame_control) ||
		       ieee80211_is_beacon(hdr->frame_control);
	case NL80211_IFTYPE_NAN:
		/* Currently no frames on NAN interface are allowed */
		return false;
	default:
		break;
	}

	WARN_ON_ONCE(1);
	return false;
}


static struct file *__fget_files(struct files_struct *files, unsigned int fd,
				 fmode_t mask, unsigned int refs)
{
	struct file *file;

	rcu_read_lock();
loop:
	file = files_lookup_fd_rcu(files, fd);
	if (file) {
		/* File object ref couldn't be taken.
		 * dup2() atomicity guarantee is the reason
		 * we loop to catch the new file (or NULL pointer)
		 */
		if (file->f_mode & mask)
			file = NULL;
		else if (!get_file_rcu_many(file, refs))
			goto loop;
	}
	rcu_read_unlock();

	return file;
}


static int i440fx_initfn(PCIDevice *dev) { PCII440FXState *d = DO_UPCAST(PCII440FXState, dev, dev); pci_config_set_vendor_id(d->dev.config, PCI_VENDOR_ID_INTEL); pci_config_set_device_id(d->dev.config, PCI_DEVICE_ID_INTEL_82441); d->dev.config[0x08] = 0x02; // revision pci_config_set_class(d->dev.config, PCI_CLASS_BRIDGE_HOST); d->dev.config[I440FX_SMRAM] = 0x02; cpu_smm_register(&i440fx_set_smm, d); return 0; }


static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s) { bool page_aligned = false; unsigned int n, begin; const uint16_t block_size = s->blksize & 0x0fff; uint32_t boundary_chk = 1 << (((s->blksize & 0xf000) >> 12) + 12); uint32_t boundary_count = boundary_chk - (s->sdmasysad % boundary_chk); /* XXX: Some sd/mmc drivers (for example, u-boot-slp) do not account for * possible stop at page boundary if initial address is not page aligned, * allow them to work properly */ if ((s->sdmasysad % boundary_chk) == 0) { page_aligned = true; } if (s->trnmod & SDHC_TRNS_READ) { s->prnsts |= SDHC_DOING_READ | SDHC_DATA_INHIBIT | SDHC_DAT_LINE_ACTIVE; while (s->blkcnt) { if (s->data_count == 0) { for (n = 0; n < block_size; n++) { s->fifo_buffer[n] = sdbus_read_data(&s->sdbus); } } begin = s->data_count; if (((boundary_count + begin) < block_size) && page_aligned) { s->data_count = boundary_count + begin; boundary_count = 0; } else { s->data_count = block_size; boundary_count -= block_size - begin; if (s->trnmod & SDHC_TRNS_BLK_CNT_EN) { s->blkcnt--; } } dma_memory_write(&address_space_memory, s->sdmasysad, &s->fifo_buffer[begin], s->data_count - begin); s->sdmasysad += s->data_count - begin; if (s->data_count == block_size) { s->data_count = 0; } if (page_aligned && boundary_count == 0) { break; } } } else { s->prnsts |= SDHC_DOING_WRITE | SDHC_DATA_INHIBIT | SDHC_DAT_LINE_ACTIVE; while (s->blkcnt) { begin = s->data_count; if (((boundary_count + begin) < block_size) && page_aligned) { s->data_count = boundary_count + begin; boundary_count = 0; } else { s->data_count = block_size; boundary_count -= block_size - begin; } dma_memory_read(&address_space_memory, s->sdmasysad, &s->fifo_buffer[begin], s->data_count); s->sdmasysad += s->data_count - begin; if (s->data_count == block_size) { for (n = 0; n < block_size; n++) { sdbus_write_data(&s->sdbus, s->fifo_buffer[n]); } s->data_count = 0; if (s->trnmod & SDHC_TRNS_BLK_CNT_EN) { s->blkcnt--; } } if (page_aligned && boundary_count == 0) { break; } } } if (s->blkcnt == 0) { sdhci_end_transfer(s); } else { if (s->norintstsen & SDHC_NISEN_DMA) { s->norintsts |= SDHC_NIS_DMA; } sdhci_update_irq(s); } }


static int coroutine_fn blkreplay_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags) { uint64_t reqid = request_id++; int ret = bdrv_co_preadv(bs->file->bs, offset, bytes, qiov, flags); block_request_create(reqid, bs, qemu_coroutine_self()); qemu_coroutine_yield(); return ret; }


static bool e1000e_intrmgr_delay_tx_causes ( E1000ECore * core , uint32_t * causes ) {
 static const uint32_t delayable_causes = E1000_ICR_TXQ0 | E1000_ICR_TXQ1 | E1000_ICR_TXQE | E1000_ICR_TXDW ;
 if ( msix_enabled ( core -> owner ) ) {
 return false ;
 }
 core -> delayed_causes |= * causes & delayable_causes ;
 * causes &= ~ delayable_causes ;
 if ( * causes != 0 ) {
 return false ;
 }
 e1000e_intrmgr_rearm_timer ( & core -> tidv ) ;
 if ( ! core -> tadv . running && ( core -> mac [ TADV ] != 0 ) ) {
 e1000e_intrmgr_rearm_timer ( & core -> tadv ) ;
 }
 return true ;
 }


static int reencrypt_init(struct crypt_device *cd,
		const char *name,
		struct luks2_hdr *hdr,
		const char *passphrase,
		size_t passphrase_size,
		int keyslot_old,
		int keyslot_new,
		const char *cipher,
		const char *cipher_mode,
		const struct crypt_params_reencrypt *params,
		struct volume_key **vks)
{
	bool move_first_segment;
	char _cipher[128];
	uint32_t sector_size;
	int r, reencrypt_keyslot, devfd = -1;
	uint64_t data_offset, dev_size = 0;
	struct crypt_dm_active_device dmd_target, dmd_source = {
		.uuid = crypt_get_uuid(cd),
		.flags = CRYPT_ACTIVATE_SHARED /* turn off exclusive open checks */
	};

	if (!params || params->mode > CRYPT_REENCRYPT_DECRYPT)
		return -EINVAL;

	if (params->mode != CRYPT_REENCRYPT_DECRYPT &&
	    (!params->luks2 || !(cipher && cipher_mode) || keyslot_new < 0))
		return -EINVAL;

	log_dbg(cd, "Initializing reencryption (mode: %s) in LUKS2 metadata.",
		    crypt_reencrypt_mode_to_str(params->mode));

	move_first_segment = (params->flags & CRYPT_REENCRYPT_MOVE_FIRST_SEGMENT);

	/* implicit sector size 512 for decryption */
	sector_size = params->luks2 ? params->luks2->sector_size : SECTOR_SIZE;
	if (sector_size < SECTOR_SIZE || sector_size > MAX_SECTOR_SIZE ||
	    NOTPOW2(sector_size)) {
		log_err(cd, _("Unsupported encryption sector size."));
		return -EINVAL;
	}

	if (!cipher_mode || *cipher_mode == '\0')
		r = snprintf(_cipher, sizeof(_cipher), "%s", cipher);
	else
		r = snprintf(_cipher, sizeof(_cipher), "%s-%s", cipher, cipher_mode);
	if (r < 0 || (size_t)r >= sizeof(_cipher))
		return -EINVAL;

	if (MISALIGNED(params->data_shift, sector_size >> SECTOR_SHIFT)) {
		log_err(cd, _("Data shift is not aligned to requested encryption sector size (%" PRIu32 " bytes)."), sector_size);
		return -EINVAL;
	}

	data_offset = LUKS2_get_data_offset(hdr) << SECTOR_SHIFT;

	r = device_check_access(cd, crypt_data_device(cd), DEV_OK);
	if (r)
		return r;

	r = device_check_size(cd, crypt_data_device(cd), data_offset, 1);
	if (r)
		return r;

	r = device_size(crypt_data_device(cd), &dev_size);
	if (r)
		return r;

	dev_size -= data_offset;

	if (MISALIGNED(dev_size, sector_size)) {
		log_err(cd, _("Data device is not aligned to requested encryption sector size (%" PRIu32 " bytes)."), sector_size);
		return -EINVAL;
	}

	reencrypt_keyslot = LUKS2_keyslot_find_empty(cd, hdr, 0);
	if (reencrypt_keyslot < 0) {
		log_err(cd, _("All key slots full."));
		return -EINVAL;
	}

	/*
	 * We must perform data move with exclusive open data device
	 * to exclude another cryptsetup process to colide with
	 * encryption initialization (or mount)
	 */
	if (move_first_segment) {
		if (dev_size < (params->data_shift << SECTOR_SHIFT)) {
			log_err(cd, _("Device %s is too small."), device_path(crypt_data_device(cd)));
			return -EINVAL;
		}
		if (params->data_shift < LUKS2_get_data_offset(hdr)) {
			log_err(cd, _("Data shift (%" PRIu64 " sectors) is less than future data offset (%" PRIu64 " sectors)."), params->data_shift, LUKS2_get_data_offset(hdr));
			return -EINVAL;
		}
		devfd = device_open_excl(cd, crypt_data_device(cd), O_RDWR);
		if (devfd < 0) {
			if (devfd == -EBUSY)
				log_err(cd,_("Failed to open %s in exclusive mode (already mapped or mounted)."), device_path(crypt_data_device(cd)));
			return -EINVAL;
		}
	}

	if (params->mode == CRYPT_REENCRYPT_ENCRYPT) {
		/* in-memory only */
		r = reencrypt_set_encrypt_segments(cd, hdr, dev_size, params->data_shift << SECTOR_SHIFT, move_first_segment, params->direction);
		if (r)
			goto out;
	}

	r = LUKS2_keyslot_reencrypt_create(cd, hdr, reencrypt_keyslot,
					   params);
	if (r < 0)
		goto out;

	r = reencrypt_make_backup_segments(cd, hdr, keyslot_new, _cipher, data_offset, params);
	if (r) {
		log_dbg(cd, "Failed to create reencryption backup device segments.");
		goto out;
	}

	r = LUKS2_keyslot_open_all_segments(cd, keyslot_old, keyslot_new, passphrase, passphrase_size, vks);
	if (r < 0)
		goto out;

	if (name && params->mode != CRYPT_REENCRYPT_ENCRYPT) {
		r = reencrypt_verify_and_upload_keys(cd, hdr, LUKS2_reencrypt_digest_old(hdr), LUKS2_reencrypt_digest_new(hdr), *vks);
		if (r)
			goto out;

		r = dm_query_device(cd, name, DM_ACTIVE_UUID | DM_ACTIVE_DEVICE |
				    DM_ACTIVE_CRYPT_KEYSIZE | DM_ACTIVE_CRYPT_KEY |
				    DM_ACTIVE_CRYPT_CIPHER, &dmd_target);
		if (r < 0)
			goto out;

		r = LUKS2_assembly_multisegment_dmd(cd, hdr, *vks, LUKS2_get_segments_jobj(hdr), &dmd_source);
		if (!r) {
			r = crypt_compare_dm_devices(cd, &dmd_source, &dmd_target);
			if (r)
				log_err(cd, _("Mismatching parameters on device %s."), name);
		}

		dm_targets_free(cd, &dmd_source);
		dm_targets_free(cd, &dmd_target);
		free(CONST_CAST(void*)dmd_target.uuid);

		if (r)
			goto out;
	}

	if (move_first_segment && reencrypt_move_data(cd, devfd, params->data_shift << SECTOR_SHIFT)) {
		r = -EIO;
		goto out;
	}

	/* This must be first and only write in LUKS2 metadata during _reencrypt_init */
	r = reencrypt_update_flag(cd, 1, true);
	if (r) {
		log_dbg(cd, "Failed to set online-reencryption requirement.");
		r = -EINVAL;
	} else
		r = reencrypt_keyslot;
out:
	device_release_excl(cd, crypt_data_device(cd));
	if (r < 0)
		crypt_load(cd, CRYPT_LUKS2, NULL);

	return r;
}


static void pflash_update(pflash_t *pfl, int offset, int size) { int offset_end; if (pfl->bs) { offset_end = offset + size; /* round to sectors */ offset = offset >> 9; offset_end = (offset_end + 511) >> 9; bdrv_write(pfl->bs, offset, pfl->storage + (offset << 9), offset_end - offset); } }


void create_script_for_cluster_analyze ( char * * analyze_script_file_name ) {
 FILE * script = NULL ;
 char * user_specification = "" ;
 prep_status ( "Creating script to analyze new cluster" ) ;
 if ( os_info . user_specified ) user_specification = psprintf ( "-U \"%s\" " , os_info . user ) ;
 * analyze_script_file_name = psprintf ( "%sanalyze_new_cluster.%s" , SCRIPT_PREFIX , SCRIPT_EXT ) ;
 if ( ( script = fopen_priv ( * analyze_script_file_name , "w" ) ) == NULL ) pg_fatal ( "Could not open file \"%s\": %s\n" , * analyze_script_file_name , getErrorText ( ) ) ;
 # ifndef WIN32 fprintf ( script , "#!/bin/sh\n\n" ) ;
 # else fprintf ( script , "@echo off\n" ) ;
 # endif fprintf ( script , "echo %sThis script will generate minimal optimizer statistics rapidly%s\n" , ECHO_QUOTE , ECHO_QUOTE ) ;
 fprintf ( script , "echo %sso your system is usable, and then gather statistics twice more%s\n" , ECHO_QUOTE , ECHO_QUOTE ) ;
 fprintf ( script , "echo %swith increasing accuracy. When it is done, your system will%s\n" , ECHO_QUOTE , ECHO_QUOTE ) ;
 fprintf ( script , "echo %shave the default level of optimizer statistics.%s\n" , ECHO_QUOTE , ECHO_QUOTE ) ;
 fprintf ( script , "echo%s\n\n" , ECHO_BLANK ) ;
 fprintf ( script , "echo %sIf you have used ALTER TABLE to modify the statistics target for%s\n" , ECHO_QUOTE , ECHO_QUOTE ) ;
 fprintf ( script , "echo %sany tables, you might want to remove them and restore them after%s\n" , ECHO_QUOTE , ECHO_QUOTE ) ;
 fprintf ( script , "echo %srunning this script because they will delay fast statistics generation.%s\n" , ECHO_QUOTE , ECHO_QUOTE ) ;
 fprintf ( script , "echo%s\n\n" , ECHO_BLANK ) ;
 fprintf ( script , "echo %sIf you would like default statistics as quickly as possible, cancel%s\n" , ECHO_QUOTE , ECHO_QUOTE ) ;
 fprintf ( script , "echo %sthis script and run:%s\n" , ECHO_QUOTE , ECHO_QUOTE ) ;
 fprintf ( script , "echo %s \"%s/vacuumdb\" %s--all %s%s\n" , ECHO_QUOTE , new_cluster . bindir , user_specification , ( GET_MAJOR_VERSION ( old_cluster . major_version ) >= 804 ) ? "--analyze-only" : "--analyze" , ECHO_QUOTE ) ;
 fprintf ( script , "echo%s\n\n" , ECHO_BLANK ) ;
 fprintf ( script , "\"%s/vacuumdb\" %s--all --analyze-in-stages\n" , new_cluster . bindir , user_specification ) ;
 if ( GET_MAJOR_VERSION ( old_cluster . major_version ) < 804 ) fprintf ( script , "\"%s/vacuumdb\" %s--all\n" , new_cluster . bindir , user_specification ) ;
 fprintf ( script , "echo%s\n\n" , ECHO_BLANK ) ;
 fprintf ( script , "echo %sDone%s\n" , ECHO_QUOTE , ECHO_QUOTE ) ;
 fclose ( script ) ;
 # ifndef WIN32 if ( chmod ( * analyze_script_file_name , S_IRWXU ) != 0 ) pg_fatal ( "Could not add execute permission to file \"%s\": %s\n" , * analyze_script_file_name , getErrorText ( ) ) ;
 # endif if ( os_info . user_specified ) pg_free ( user_specification ) ;
 check_ok ( ) ;
 }


void vp9_foreach_transformed_block ( const MACROBLOCKD * const xd , BLOCK_SIZE bsize , foreach_transformed_block_visitor visit , void * arg ) {
 int plane ;
 for ( plane = 0 ;
 plane < MAX_MB_PLANE ;
 plane ++ ) vp9_foreach_transformed_block_in_plane ( xd , bsize , plane , visit , arg ) ;
 }


static void test_hba_spec(void) { AHCIQState *ahci; ahci = ahci_boot(); ahci_pci_enable(ahci); ahci_test_hba_spec(ahci); ahci_shutdown(ahci); }


static void mirror_start_job(BlockDriverState *bs, BlockDriverState *target, const char *replaces, int64_t speed, int64_t granularity, int64_t buf_size, BlockdevOnError on_source_error, BlockdevOnError on_target_error, BlockCompletionFunc *cb, void *opaque, Error **errp, const BlockJobDriver *driver, bool is_none_mode, BlockDriverState *base) { MirrorBlockJob *s; if (granularity == 0) { /* Choose the default granularity based on the target file's cluster * size, clamped between 4k and 64k. */ BlockDriverInfo bdi; if (bdrv_get_info(target, &bdi) >= 0 && bdi.cluster_size != 0) { granularity = MAX(4096, bdi.cluster_size); granularity = MIN(65536, granularity); } else { granularity = 65536; } } assert ((granularity & (granularity - 1)) == 0); if ((on_source_error == BLOCKDEV_ON_ERROR_STOP || on_source_error == BLOCKDEV_ON_ERROR_ENOSPC) && !bdrv_iostatus_is_enabled(bs)) { error_set(errp, QERR_INVALID_PARAMETER, "on-source-error"); return; } s = block_job_create(driver, bs, speed, cb, opaque, errp); if (!s) { return; } s->replaces = g_strdup(replaces); s->on_source_error = on_source_error; s->on_target_error = on_target_error; s->target = target; s->is_none_mode = is_none_mode; s->base = base; s->granularity = granularity; s->buf_size = MAX(buf_size, granularity); s->dirty_bitmap = bdrv_create_dirty_bitmap(bs, granularity, errp); if (!s->dirty_bitmap) { return; } bdrv_set_enable_write_cache(s->target, true); bdrv_set_on_error(s->target, on_target_error, on_target_error); bdrv_iostatus_enable(s->target); s->common.co = qemu_coroutine_create(mirror_run); trace_mirror_start(bs, s, s->common.co, opaque); qemu_coroutine_enter(s->common.co, s); }


static void vnc_connect(VncDisplay *vd, QIOChannelSocket *sioc, bool skipauth, bool websocket) { VncState *vs = g_new0(VncState, 1); int i; vs->sioc = sioc; object_ref(OBJECT(vs->sioc)); vs->ioc = QIO_CHANNEL(sioc); object_ref(OBJECT(vs->ioc)); vs->vd = vd; buffer_init(&vs->input, "vnc-input/%p", sioc); buffer_init(&vs->output, "vnc-output/%p", sioc); buffer_init(&vs->jobs_buffer, "vnc-jobs_buffer/%p", sioc); buffer_init(&vs->tight.tight, "vnc-tight/%p", sioc); buffer_init(&vs->tight.zlib, "vnc-tight-zlib/%p", sioc); buffer_init(&vs->tight.gradient, "vnc-tight-gradient/%p", sioc); #ifdef CONFIG_VNC_JPEG buffer_init(&vs->tight.jpeg, "vnc-tight-jpeg/%p", sioc); #endif #ifdef CONFIG_VNC_PNG buffer_init(&vs->tight.png, "vnc-tight-png/%p", sioc); #endif buffer_init(&vs->zlib.zlib, "vnc-zlib/%p", sioc); buffer_init(&vs->zrle.zrle, "vnc-zrle/%p", sioc); buffer_init(&vs->zrle.fb, "vnc-zrle-fb/%p", sioc); buffer_init(&vs->zrle.zlib, "vnc-zrle-zlib/%p", sioc); if (skipauth) { vs->auth = VNC_AUTH_NONE; vs->subauth = VNC_AUTH_INVALID; } else { if (websocket) { vs->auth = vd->ws_auth; vs->subauth = VNC_AUTH_INVALID; } else { vs->auth = vd->auth; vs->subauth = vd->subauth; } } VNC_DEBUG("Client sioc=%p ws=%d auth=%d subauth=%d\n", sioc, websocket, vs->auth, vs->subauth); vs->lossy_rect = g_malloc0(VNC_STAT_ROWS * sizeof (*vs->lossy_rect)); for (i = 0; i < VNC_STAT_ROWS; ++i) { vs->lossy_rect[i] = g_new0(uint8_t, VNC_STAT_COLS); } VNC_DEBUG("New client on socket %p\n", vs->sioc); update_displaychangelistener(&vd->dcl, VNC_REFRESH_INTERVAL_BASE); qio_channel_set_blocking(vs->ioc, false, NULL); if (websocket) { vs->websocket = 1; if (vd->ws_tls) { vs->ioc_tag = qio_channel_add_watch( vs->ioc, G_IO_IN, vncws_tls_handshake_io, vs, NULL); } else { vs->ioc_tag = qio_channel_add_watch( vs->ioc, G_IO_IN, vncws_handshake_io, vs, NULL); } } else { vs->ioc_tag = qio_channel_add_watch( vs->ioc, G_IO_IN, vnc_client_io, vs, NULL); } vnc_client_cache_addr(vs); vnc_qmp_event(vs, QAPI_EVENT_VNC_CONNECTED); vnc_set_share_mode(vs, VNC_SHARE_MODE_CONNECTING); if (!vs->websocket) { vnc_init_state(vs); } if (vd->num_connecting > vd->connections_limit) { QTAILQ_FOREACH(vs, &vd->clients, next) { if (vs->share_mode == VNC_SHARE_MODE_CONNECTING) { vnc_disconnect_start(vs); return; } } } }


static void simple_dict(void) { int i; struct { const char *encoded; LiteralQObject decoded; } test_cases[] = { { .encoded = "{\"foo\": 42, \"bar\": \"hello world\"}", .decoded = QLIT_QDICT(((LiteralQDictEntry[]){ { "foo", QLIT_QINT(42) }, { "bar", QLIT_QSTR("hello world") }, { } })), }, { .encoded = "{}", .decoded = QLIT_QDICT(((LiteralQDictEntry[]){ { } })), }, { .encoded = "{\"foo\": 43}", .decoded = QLIT_QDICT(((LiteralQDictEntry[]){ { "foo", QLIT_QINT(43) }, { } })), }, { } }; for (i = 0; test_cases[i].encoded; i++) { QObject *obj; QString *str; obj = qobject_from_json(test_cases[i].encoded); g_assert(obj != NULL); g_assert(qobject_type(obj) == QTYPE_QDICT); g_assert(compare_litqobj_to_qobj(&test_cases[i].decoded, obj) == 1); str = qobject_to_json(obj); qobject_decref(obj); obj = qobject_from_json(qstring_get_str(str)); g_assert(obj != NULL); g_assert(qobject_type(obj) == QTYPE_QDICT); g_assert(compare_litqobj_to_qobj(&test_cases[i].decoded, obj) == 1); qobject_decref(obj); QDECREF(str); } }


static void evaluate_flags_writeback(uint32_t flags) { int x; /* Extended arithmetics, leave the z flag alone. */ x = env->cc_x; if ((x || env->cc_op == CC_OP_ADDC) && flags & Z_FLAG) env->cc_mask &= ~Z_FLAG; /* all insn clear the x-flag except setf or clrf. */ env->pregs[PR_CCS] &= ~(env->cc_mask | X_FLAG); flags &= env->cc_mask; env->pregs[PR_CCS] |= flags; }


void addDbAdminAnyDbPrivileges(PrivilegeVector* privileges) {
    Privilege::addPrivilegeToPrivilegeVector(
        privileges, Privilege(ResourcePattern::forClusterResource(), ActionType::listDatabases));
    Privilege::addPrivilegeToPrivilegeVector(
        privileges, Privilege(ResourcePattern::forAnyNormalResource(), dbAdminRoleActions));
    Privilege::addPrivilegeToPrivilegeVector(
        privileges,
        Privilege(ResourcePattern::forCollectionName("system.indexes"), readRoleActions));
    Privilege::addPrivilegeToPrivilegeVector(
        privileges,
        Privilege(ResourcePattern::forCollectionName("system.namespaces"), readRoleActions));
    ActionSet profileActions = readRoleActions;
    profileActions.addAction(ActionType::convertToCapped);
    profileActions.addAction(ActionType::createCollection);
    profileActions.addAction(ActionType::dropCollection);
    Privilege::addPrivilegeToPrivilegeVector(
        privileges,
        Privilege(ResourcePattern::forCollectionName("system.profile"), profileActions));
}


void s390_init_cpus(MachineState *machine) { int i; gchar *name; if (machine->cpu_model == NULL) { machine->cpu_model = "host"; } cpu_states = g_malloc0(sizeof(S390CPU *) * max_cpus); for (i = 0; i < max_cpus; i++) { name = g_strdup_printf("cpu[%i]", i); object_property_add_link(OBJECT(machine), name, TYPE_S390_CPU, (Object **) &cpu_states[i], object_property_allow_set_link, OBJ_PROP_LINK_UNREF_ON_RELEASE, &error_abort); g_free(name); } for (i = 0; i < smp_cpus; i++) { cpu_s390x_init(machine->cpu_model); } }


int tm_init ( void * info , struct tm_roots * roots ) {
 tm_event_t nevent , revent ;
 char * env , * hold ;
 int err ;
 int nerr = 0 ;
 struct tcp_chan * chan = NULL ;
 if ( init_done ) {
 return ( TM_BADINIT ) ;
 }
 if ( ( tm_jobid = getenv ( "PBS_JOBID" ) ) == NULL ) {
 return ( TM_EBADENVIRONMENT ) ;
 }
 tm_jobid_len = strlen ( tm_jobid ) ;
 if ( ( tm_jobcookie = getenv ( "PBS_JOBCOOKIE" ) ) == NULL ) return TM_EBADENVIRONMENT ;
 tm_jobcookie_len = strlen ( tm_jobcookie ) ;
 if ( ( env = getenv ( "PBS_NODENUM" ) ) == NULL ) return TM_EBADENVIRONMENT ;
 tm_jobndid = ( tm_node_id ) strtol ( env , & hold , 10 ) ;
 if ( env == hold ) return TM_EBADENVIRONMENT ;
 if ( ( env = getenv ( "PBS_TASKNUM" ) ) == NULL ) return TM_EBADENVIRONMENT ;
 if ( ( tm_jobtid = atoi ( env ) ) == 0 ) return TM_EBADENVIRONMENT ;
 if ( ( env = getenv ( "PBS_MOMPORT" ) ) == NULL ) return TM_EBADENVIRONMENT ;
 if ( ( tm_momport = atoi ( env ) ) == 0 ) return TM_EBADENVIRONMENT ;
 init_done = 1 ;
 nevent = new_event ( ) ;
 if ( startcom ( TM_INIT , nevent , & chan ) != DIS_SUCCESS ) return TM_ESYSTEM ;
 DIS_tcp_wflush ( chan ) ;
 DIS_tcp_cleanup ( chan ) ;
 add_event ( nevent , TM_ERROR_NODE , TM_INIT , ( void * ) roots ) ;
 while ( TRUE ) {
 if ( ( err = tm_poll ( TM_NULL_EVENT , & revent , 1 , & nerr ) ) != TM_SUCCESS ) return err ;
 if ( event_count == 0 ) break ;
 }
 return nerr ;
 }


static int ohci_service_iso_td ( OHCIState * ohci , struct ohci_ed * ed , int completion ) {
 int dir ;
 size_t len = 0 ;
 const char * str = NULL ;
 int pid ;
 int ret ;
 int i ;
 USBDevice * dev ;
 USBEndpoint * ep ;
 struct ohci_iso_td iso_td ;
 uint32_t addr ;
 uint16_t starting_frame ;
 int16_t relative_frame_number ;
 int frame_count ;
 uint32_t start_offset , next_offset , end_offset = 0 ;
 uint32_t start_addr , end_addr ;
 addr = ed -> head & OHCI_DPTR_MASK ;
 if ( ohci_read_iso_td ( ohci , addr , & iso_td ) ) {
 trace_usb_ohci_iso_td_read_failed ( addr ) ;
 ohci_die ( ohci ) ;
 return 0 ;
 }
 starting_frame = OHCI_BM ( iso_td . flags , TD_SF ) ;
 frame_count = OHCI_BM ( iso_td . flags , TD_FC ) ;
 relative_frame_number = USUB ( ohci -> frame_number , starting_frame ) ;
 trace_usb_ohci_iso_td_head ( ed -> head & OHCI_DPTR_MASK , ed -> tail & OHCI_DPTR_MASK , iso_td . flags , iso_td . bp , iso_td . next , iso_td . be , ohci -> frame_number , starting_frame , frame_count , relative_frame_number ) ;
 trace_usb_ohci_iso_td_head_offset ( iso_td . offset [ 0 ] , iso_td . offset [ 1 ] , iso_td . offset [ 2 ] , iso_td . offset [ 3 ] , iso_td . offset [ 4 ] , iso_td . offset [ 5 ] , iso_td . offset [ 6 ] , iso_td . offset [ 7 ] ) ;
 if ( relative_frame_number < 0 ) {
 trace_usb_ohci_iso_td_relative_frame_number_neg ( relative_frame_number ) ;
 return 1 ;
 }
 else if ( relative_frame_number > frame_count ) {
 trace_usb_ohci_iso_td_relative_frame_number_big ( relative_frame_number , frame_count ) ;
 OHCI_SET_BM ( iso_td . flags , TD_CC , OHCI_CC_DATAOVERRUN ) ;
 ed -> head &= ~ OHCI_DPTR_MASK ;
 ed -> head |= ( iso_td . next & OHCI_DPTR_MASK ) ;
 iso_td . next = ohci -> done ;
 ohci -> done = addr ;
 i = OHCI_BM ( iso_td . flags , TD_DI ) ;
 if ( i < ohci -> done_count ) ohci -> done_count = i ;
 if ( ohci_put_iso_td ( ohci , addr , & iso_td ) ) {
 ohci_die ( ohci ) ;
 return 1 ;
 }
 return 0 ;
 }
 dir = OHCI_BM ( ed -> flags , ED_D ) ;
 switch ( dir ) {
 case OHCI_TD_DIR_IN : str = "in" ;
 pid = USB_TOKEN_IN ;
 break ;
 case OHCI_TD_DIR_OUT : str = "out" ;
 pid = USB_TOKEN_OUT ;
 break ;
 case OHCI_TD_DIR_SETUP : str = "setup" ;
 pid = USB_TOKEN_SETUP ;
 break ;
 default : trace_usb_ohci_iso_td_bad_direction ( dir ) ;
 return 1 ;
 }
 if ( ! iso_td . bp || ! iso_td . be ) {
 trace_usb_ohci_iso_td_bad_bp_be ( iso_td . bp , iso_td . be ) ;
 return 1 ;
 }
 start_offset = iso_td . offset [ relative_frame_number ] ;
 next_offset = iso_td . offset [ relative_frame_number + 1 ] ;
 if ( ! ( OHCI_BM ( start_offset , TD_PSW_CC ) & 0xe ) || ( ( relative_frame_number < frame_count ) && ! ( OHCI_BM ( next_offset , TD_PSW_CC ) & 0xe ) ) ) {
 trace_usb_ohci_iso_td_bad_cc_not_accessed ( start_offset , next_offset ) ;
 return 1 ;
 }
 if ( ( relative_frame_number < frame_count ) && ( start_offset > next_offset ) ) {
 trace_usb_ohci_iso_td_bad_cc_overrun ( start_offset , next_offset ) ;
 return 1 ;
 }
 if ( ( start_offset & 0x1000 ) == 0 ) {
 start_addr = ( iso_td . bp & OHCI_PAGE_MASK ) | ( start_offset & OHCI_OFFSET_MASK ) ;
 }
 else {
 start_addr = ( iso_td . be & OHCI_PAGE_MASK ) | ( start_offset & OHCI_OFFSET_MASK ) ;
 }
 if ( relative_frame_number < frame_count ) {
 end_offset = next_offset - 1 ;
 if ( ( end_offset & 0x1000 ) == 0 ) {
 end_addr = ( iso_td . bp & OHCI_PAGE_MASK ) | ( end_offset & OHCI_OFFSET_MASK ) ;
 }
 else {
 end_addr = ( iso_td . be & OHCI_PAGE_MASK ) | ( end_offset & OHCI_OFFSET_MASK ) ;
 }
 }
 else {
 end_addr = iso_td . be ;
 }
 if ( ( start_addr & OHCI_PAGE_MASK ) != ( end_addr & OHCI_PAGE_MASK ) ) {
 len = ( end_addr & OHCI_OFFSET_MASK ) + 0x1001 - ( start_addr & OHCI_OFFSET_MASK ) ;
 }
 else {
 len = end_addr - start_addr + 1 ;
 }
 if ( len && dir != OHCI_TD_DIR_IN ) {
 if ( ohci_copy_iso_td ( ohci , start_addr , end_addr , ohci -> usb_buf , len , DMA_DIRECTION_TO_DEVICE ) ) {
 ohci_die ( ohci ) ;
 return 1 ;
 }
 }
 if ( ! completion ) {
 bool int_req = relative_frame_number == frame_count && OHCI_BM ( iso_td . flags , TD_DI ) == 0 ;
 dev = ohci_find_device ( ohci , OHCI_BM ( ed -> flags , ED_FA ) ) ;
 ep = usb_ep_get ( dev , pid , OHCI_BM ( ed -> flags , ED_EN ) ) ;
 usb_packet_setup ( & ohci -> usb_packet , pid , ep , 0 , addr , false , int_req ) ;
 usb_packet_addbuf ( & ohci -> usb_packet , ohci -> usb_buf , len ) ;
 usb_handle_packet ( dev , & ohci -> usb_packet ) ;
 if ( ohci -> usb_packet . status == USB_RET_ASYNC ) {
 usb_device_flush_ep_queue ( dev , ep ) ;
 return 1 ;
 }
 }
 if ( ohci -> usb_packet . status == USB_RET_SUCCESS ) {
 ret = ohci -> usb_packet . actual_length ;
 }
 else {
 ret = ohci -> usb_packet . status ;
 }
 trace_usb_ohci_iso_td_so ( start_offset , end_offset , start_addr , end_addr , str , len , ret ) ;
 if ( dir == OHCI_TD_DIR_IN && ret >= 0 && ret <= len ) {
 if ( ohci_copy_iso_td ( ohci , start_addr , end_addr , ohci -> usb_buf , ret , DMA_DIRECTION_FROM_DEVICE ) ) {
 ohci_die ( ohci ) ;
 return 1 ;
 }
 OHCI_SET_BM ( iso_td . offset [ relative_frame_number ] , TD_PSW_CC , OHCI_CC_NOERROR ) ;
 OHCI_SET_BM ( iso_td . offset [ relative_frame_number ] , TD_PSW_SIZE , ret ) ;
 }
 else if ( dir == OHCI_TD_DIR_OUT && ret == len ) {
 OHCI_SET_BM ( iso_td . offset [ relative_frame_number ] , TD_PSW_CC , OHCI_CC_NOERROR ) ;
 OHCI_SET_BM ( iso_td . offset [ relative_frame_number ] , TD_PSW_SIZE , 0 ) ;
 }
 else {
 if ( ret > ( ssize_t ) len ) {
 trace_usb_ohci_iso_td_data_overrun ( ret , len ) ;
 OHCI_SET_BM ( iso_td . offset [ relative_frame_number ] , TD_PSW_CC , OHCI_CC_DATAOVERRUN ) ;
 OHCI_SET_BM ( iso_td . offset [ relative_frame_number ] , TD_PSW_SIZE , len ) ;
 }
 else if ( ret >= 0 ) {
 trace_usb_ohci_iso_td_data_underrun ( ret ) ;
 OHCI_SET_BM ( iso_td . offset [ relative_frame_number ] , TD_PSW_CC , OHCI_CC_DATAUNDERRUN ) ;
 }
 else {
 switch ( ret ) {
 case USB_RET_IOERROR : case USB_RET_NODEV : OHCI_SET_BM ( iso_td . offset [ relative_frame_number ] , TD_PSW_CC , OHCI_CC_DEVICENOTRESPONDING ) ;
 OHCI_SET_BM ( iso_td . offset [ relative_frame_number ] , TD_PSW_SIZE , 0 ) ;
 break ;
 case USB_RET_NAK : case USB_RET_STALL : trace_usb_ohci_iso_td_nak ( ret ) ;
 OHCI_SET_BM ( iso_td . offset [ relative_frame_number ] , TD_PSW_CC , OHCI_CC_STALL ) ;
 OHCI_SET_BM ( iso_td . offset [ relative_frame_number ] , TD_PSW_SIZE , 0 ) ;
 break ;
 default : trace_usb_ohci_iso_td_bad_response ( ret ) ;
 OHCI_SET_BM ( iso_td . offset [ relative_frame_number ] , TD_PSW_CC , OHCI_CC_UNDEXPETEDPID ) ;
 break ;
 }
 }
 }
 if ( relative_frame_number == frame_count ) {
 OHCI_SET_BM ( iso_td . flags , TD_CC , OHCI_CC_NOERROR ) ;
 ed -> head &= ~ OHCI_DPTR_MASK ;
 ed -> head |= ( iso_td . next & OHCI_DPTR_MASK ) ;
 iso_td . next = ohci -> done ;
 ohci -> done = addr ;
 i = OHCI_BM ( iso_td . flags , TD_DI ) ;
 if ( i < ohci -> done_count ) ohci -> done_count = i ;
 }
 if ( ohci_put_iso_td ( ohci , addr , & iso_td ) ) {
 ohci_die ( ohci ) ;
 }
 return 1 ;
 }


inline int nci_request(struct nci_dev *ndev,
		       void (*req)(struct nci_dev *ndev,
				   const void *opt),
		       const void *opt, __u32 timeout)
{
	int rc;

	if (!test_bit(NCI_UP, &ndev->flags))
		return -ENETDOWN;

	/* Serialize all requests */
	mutex_lock(&ndev->req_lock);
	rc = __nci_request(ndev, req, opt, timeout);
	mutex_unlock(&ndev->req_lock);

	return rc;
}


static __always_inline int kvm_handle_hva_range(struct mmu_notifier *mn,
						unsigned long start,
						unsigned long end,
						pte_t pte,
						hva_handler_t handler)
{
	struct kvm *kvm = mmu_notifier_to_kvm(mn);
	const struct kvm_hva_range range = {
		.start		= start,
		.end		= end,
		.pte		= pte,
		.handler	= handler,
		.on_lock	= (void *)kvm_null_fn,
		.flush_on_ret	= true,
		.may_block	= false,
	};

	return __kvm_handle_hva_range(kvm, &range);