int set_file_attrs ( const char * fname , struct file_struct * file , stat_x * sxp , const char * fnamecmp , int flags ) {
 int updated = 0 ;
 stat_x sx2 ;
 int change_uid , change_gid ;
 mode_t new_mode = file -> mode ;
 int inherit ;
 if ( ! sxp ) {
 if ( dry_run ) return 1 ;
 if ( link_stat ( fname , & sx2 . st , 0 ) < 0 ) {
 rsyserr ( FERROR_XFER , errno , "stat %s failed" , full_fname ( fname ) ) ;
 return 0 ;
 }
 init_stat_x ( & sx2 ) ;
 sxp = & sx2 ;
 inherit = ! preserve_perms ;
 }
 else inherit = ! preserve_perms && file -> flags & FLAG_DIR_CREATED ;
 if ( inherit && S_ISDIR ( new_mode ) && sxp -> st . st_mode & S_ISGID ) {
 new_mode |= S_ISGID ;
 }
 if ( daemon_chmod_modes && ! S_ISLNK ( new_mode ) ) new_mode = tweak_mode ( new_mode , daemon_chmod_modes ) ;
 # ifdef SUPPORT_ACLS if ( preserve_acls && ! S_ISLNK ( file -> mode ) && ! ACL_READY ( * sxp ) ) get_acl ( fname , sxp ) ;
 # endif change_uid = am_root && uid_ndx && sxp -> st . st_uid != ( uid_t ) F_OWNER ( file ) ;
 change_gid = gid_ndx && ! ( file -> flags & FLAG_SKIP_GROUP ) && sxp -> st . st_gid != ( gid_t ) F_GROUP ( file ) ;
 # ifndef CAN_CHOWN_SYMLINK if ( S_ISLNK ( sxp -> st . st_mode ) ) {
 ;
 }
 else # endif if ( change_uid || change_gid ) {
 if ( DEBUG_GTE ( OWN , 1 ) ) {
 if ( change_uid ) {
 rprintf ( FINFO , "set uid of %s from %u to %u\n" , fname , ( unsigned ) sxp -> st . st_uid , F_OWNER ( file ) ) ;
 }
 if ( change_gid ) {
 rprintf ( FINFO , "set gid of %s from %u to %u\n" , fname , ( unsigned ) sxp -> st . st_gid , F_GROUP ( file ) ) ;
 }
 }
 if ( am_root >= 0 ) {
 uid_t uid = change_uid ? ( uid_t ) F_OWNER ( file ) : sxp -> st . st_uid ;
 gid_t gid = change_gid ? ( gid_t ) F_GROUP ( file ) : sxp -> st . st_gid ;
 if ( do_lchown ( fname , uid , gid ) != 0 ) {
 rsyserr ( FERROR_XFER , errno , "%s %s failed" , change_uid ? "chown" : "chgrp" , full_fname ( fname ) ) ;
 goto cleanup ;
 }
 if ( uid == ( uid_t ) - 1 && sxp -> st . st_uid != ( uid_t ) - 1 ) rprintf ( FERROR_XFER , "uid 4294967295 (-1) is impossible to set on %s\n" , full_fname ( fname ) ) ;
 if ( gid == ( gid_t ) - 1 && sxp -> st . st_gid != ( gid_t ) - 1 ) rprintf ( FERROR_XFER , "gid 4294967295 (-1) is impossible to set on %s\n" , full_fname ( fname ) ) ;
 if ( sxp -> st . st_mode & ( S_ISUID | S_ISGID ) ) {
 link_stat ( fname , & sxp -> st , keep_dirlinks && S_ISDIR ( sxp -> st . st_mode ) ) ;
 }
 }
 updated = 1 ;
 }
 # ifdef SUPPORT_XATTRS if ( am_root < 0 ) set_stat_xattr ( fname , file , new_mode ) ;
 if ( preserve_xattrs && fnamecmp ) set_xattr ( fname , file , fnamecmp , sxp ) ;
 # endif if ( ! preserve_times || ( ! ( preserve_times & PRESERVE_DIR_TIMES ) && S_ISDIR ( sxp -> st . st_mode ) ) || ( ! ( preserve_times & PRESERVE_LINK_TIMES ) && S_ISLNK ( sxp -> st . st_mode ) ) ) flags |= ATTRS_SKIP_MTIME ;
 if ( ! ( flags & ATTRS_SKIP_MTIME ) && ( sxp -> st . st_mtime != file -> modtime # ifdef ST_MTIME_NSEC || ( NSEC_BUMP ( file ) && ( uint32 ) sxp -> st . ST_MTIME_NSEC != F_MOD_NSEC ( file ) ) # endif ) ) {
 int ret = set_modtime ( fname , file -> modtime , F_MOD_NSEC ( file ) , sxp -> st . st_mode ) ;
 if ( ret < 0 ) {
 rsyserr ( FERROR_XFER , errno , "failed to set times on %s" , full_fname ( fname ) ) ;
 goto cleanup ;
 }
 if ( ret == 0 ) updated = 1 ;
 else file -> flags |= FLAG_TIME_FAILED ;
 }
 # ifdef SUPPORT_ACLS if ( preserve_acls && ! S_ISLNK ( new_mode ) ) {
 if ( set_acl ( fname , file , sxp , new_mode ) > 0 ) updated = 1 ;
 }
 # endif # ifdef HAVE_CHMOD if ( ! BITS_EQUAL ( sxp -> st . st_mode , new_mode , CHMOD_BITS ) ) {
 int ret = am_root < 0 ? 0 : do_chmod ( fname , new_mode ) ;
 if ( ret < 0 ) {
 rsyserr ( FERROR_XFER , errno , "failed to set permissions on %s" , full_fname ( fname ) ) ;
 goto cleanup ;
 }
 if ( ret == 0 ) updated = 1 ;
 }
 # endif if ( INFO_GTE ( NAME , 2 ) && flags & ATTRS_REPORT ) {
 if ( updated ) rprintf ( FCLIENT , "%s\n" , fname ) ;
 else rprintf ( FCLIENT , "%s is uptodate\n" , fname ) ;
 }
 cleanup : if ( sxp == & sx2 ) free_stat_x ( & sx2 ) ;
 return updated ;
 }


void kvm_inject_x86_mce(CPUState *cenv, int bank, uint64_t status, uint64_t mcg_status, uint64_t addr, uint64_t misc, int abort_on_error) { #ifdef KVM_CAP_MCE struct kvm_x86_mce mce = { .bank = bank, .status = status, .mcg_status = mcg_status, .addr = addr, .misc = misc, }; struct kvm_x86_mce_data data = { .env = cenv, .mce = &mce, }; if (!cenv->mcg_cap) { fprintf(stderr, "MCE support is not enabled!\n"); return; } run_on_cpu(cenv, kvm_do_inject_x86_mce, &data); #else if (abort_on_error) abort(); #endif }


GList *range_list_insert(GList *list, Range *data) { GList *l, *next = NULL; Range *r, *nextr; if (!list) { list = g_list_insert_sorted(list, data, range_compare); return list; } nextr = data; l = list; while (l && l != next && nextr) { r = l->data; if (ranges_can_merge(r, nextr)) { range_merge(r, nextr); l = g_list_remove_link(l, next); next = g_list_next(l); if (next) { nextr = next->data; } else { nextr = NULL; } } else { l = g_list_next(l); } } if (!l) { list = g_list_insert_sorted(list, data, range_compare); } return list; }


static VALUE cState_array_nl ( VALUE self ) {
 GET_STATE ( self ) ;
 return state -> array_nl ? rb_str_new ( state -> array_nl , state -> array_nl_len ) : rb_str_new2 ( "" ) ;
 }


static int read_packet(AVFormatContext *s, AVPacket *pkt) { MmDemuxContext *mm = s->priv_data; AVIOContext *pb = s->pb; unsigned char preamble[MM_PREAMBLE_SIZE]; unsigned int type, length; while(1) { if (avio_read(pb, preamble, MM_PREAMBLE_SIZE) != MM_PREAMBLE_SIZE) { return AVERROR(EIO); } type = AV_RL16(&preamble[0]); length = AV_RL16(&preamble[2]); switch(type) { case MM_TYPE_PALETTE : case MM_TYPE_INTER : case MM_TYPE_INTRA : case MM_TYPE_INTRA_HH : case MM_TYPE_INTER_HH : case MM_TYPE_INTRA_HHV : case MM_TYPE_INTER_HHV : /* output preamble + data */ if (av_new_packet(pkt, length + MM_PREAMBLE_SIZE)) return AVERROR(ENOMEM); memcpy(pkt->data, preamble, MM_PREAMBLE_SIZE); if (avio_read(pb, pkt->data + MM_PREAMBLE_SIZE, length) != length) return AVERROR(EIO); pkt->size = length + MM_PREAMBLE_SIZE; pkt->stream_index = 0; pkt->pts = mm->video_pts; if (type!=MM_TYPE_PALETTE) mm->video_pts++; return 0; case MM_TYPE_AUDIO : if (av_get_packet(s->pb, pkt, length)<0) return AVERROR(ENOMEM); pkt->size = length; pkt->stream_index = 1; pkt->pts = mm->audio_pts++; return 0; default : av_log(s, AV_LOG_INFO, "unknown chunk type 0x%x\n", type); avio_skip(pb, length); } } }


static int kvm_put_one_msr ( X86CPU * cpu , int index , uint64_t value ) {
 kvm_msr_buf_reset ( cpu ) ;
 kvm_msr_entry_add ( cpu , index , value ) ;
 return kvm_vcpu_ioctl ( CPU ( cpu ) , KVM_SET_MSRS , cpu -> kvm_msr_buf ) ;
 }


static int qio_dns_resolver_lookup_sync_inet(QIODNSResolver *resolver, SocketAddress *addr, size_t *naddrs, SocketAddress ***addrs, Error **errp) { struct addrinfo ai, *res, *e; InetSocketAddress *iaddr = addr->u.inet.data; char port[33]; char uaddr[INET6_ADDRSTRLEN + 1]; char uport[33]; int rc; Error *err = NULL; size_t i; *naddrs = 0; *addrs = NULL; memset(&ai, 0, sizeof(ai)); ai.ai_flags = AI_PASSIVE; if (iaddr->has_numeric && iaddr->numeric) { ai.ai_flags |= AI_NUMERICHOST | AI_NUMERICSERV; } ai.ai_family = inet_ai_family_from_address(iaddr, &err); ai.ai_socktype = SOCK_STREAM; if (err) { error_propagate(errp, err); return -1; } if (iaddr->host == NULL) { error_setg(errp, "host not specified"); return -1; } if (iaddr->port != NULL) { pstrcpy(port, sizeof(port), iaddr->port); } else { port[0] = '\0'; } rc = getaddrinfo(strlen(iaddr->host) ? iaddr->host : NULL, strlen(port) ? port : NULL, &ai, &res); if (rc != 0) { error_setg(errp, "address resolution failed for %s:%s: %s", iaddr->host, port, gai_strerror(rc)); return -1; } for (e = res; e != NULL; e = e->ai_next) { (*naddrs)++; } *addrs = g_new0(SocketAddress *, *naddrs); /* create socket + bind */ for (i = 0, e = res; e != NULL; i++, e = e->ai_next) { SocketAddress *newaddr = g_new0(SocketAddress, 1); InetSocketAddress *newiaddr = g_new0(InetSocketAddress, 1); newaddr->u.inet.data = newiaddr; newaddr->type = SOCKET_ADDRESS_KIND_INET; getnameinfo((struct sockaddr *)e->ai_addr, e->ai_addrlen, uaddr, INET6_ADDRSTRLEN, uport, 32, NI_NUMERICHOST | NI_NUMERICSERV); *newiaddr = (InetSocketAddress){ .host = g_strdup(uaddr), .port = g_strdup(uport), .has_numeric = true, .numeric = true, .has_to = iaddr->has_to, .to = iaddr->to, .has_ipv4 = false, .has_ipv6 = false, }; (*addrs)[i] = newaddr; } freeaddrinfo(res); return 0; }


static int still_interesting(struct commit_list *src, unsigned long date, int slop)
{
	/*
	 * No source list at all? We're definitely done..
	 */
	if (!src)
		return 0;

	/*
	 * Does the destination list contain entries with a date
	 * before the source list? Definitely _not_ done.
	 */
	if (date < src->item->date)
		return SLOP;

	/*
	 * Does the source list still have interesting commits in
	 * it? Definitely not done..
	 */
	if (!everybody_uninteresting(src))
		return SLOP;

	/* Ok, we're closing in.. */
	return slop-1;
}


static int parse_num(const char **cp_p)
{
	unsigned long num, scale;
	int ch, dot;
	const char *cp = *cp_p;

	num = 0;
	scale = 1;
	dot = 0;
	for(;;) {
		ch = *cp;
		if ( !dot && ch == '.' ) {
			scale = 1;
			dot = 1;
		} else if ( ch == '%' ) {
			scale = dot ? scale*100 : 100;
			cp++;	/* % is always at the end */
			break;
		} else if ( ch >= '0' && ch <= '9' ) {
			if ( scale < 100000 ) {
				scale *= 10;
				num = (num*10) + (ch-'0');
			}
		} else {
			break;
		}
		cp++;
	}
	*cp_p = cp;

	/* user says num divided by scale and we say internally that
	 * is MAX_SCORE * num / scale.
	 */
	return (int)((num >= scale) ? MAX_SCORE : (MAX_SCORE * num / scale));
}


static void diff_resolve_rename_copy(void)
{
	int i;
	struct diff_filepair *p;
	struct diff_queue_struct *q = &diff_queued_diff;

	diff_debug_queue("resolve-rename-copy", q);

	for (i = 0; i < q->nr; i++) {
		p = q->queue[i];
		p->status = 0; /* undecided */
		if (DIFF_PAIR_UNMERGED(p))
			p->status = DIFF_STATUS_UNMERGED;
		else if (!DIFF_FILE_VALID(p->one))
			p->status = DIFF_STATUS_ADDED;
		else if (!DIFF_FILE_VALID(p->two))
			p->status = DIFF_STATUS_DELETED;
		else if (DIFF_PAIR_TYPE_CHANGED(p))
			p->status = DIFF_STATUS_TYPE_CHANGED;

		/* from this point on, we are dealing with a pair
		 * whose both sides are valid and of the same type, i.e.
		 * either in-place edit or rename/copy edit.
		 */
		else if (DIFF_PAIR_RENAME(p)) {
			/*
			 * A rename might have re-connected a broken
			 * pair up, causing the pathnames to be the
			 * same again. If so, that's not a rename at
			 * all, just a modification..
			 *
			 * Otherwise, see if this source was used for
			 * multiple renames, in which case we decrement
			 * the count, and call it a copy.
			 */
			if (!strcmp(p->one->path, p->two->path))
				p->status = DIFF_STATUS_MODIFIED;
			else if (--p->one->rename_used > 0)
				p->status = DIFF_STATUS_COPIED;
			else
				p->status = DIFF_STATUS_RENAMED;
		}
		else if (hashcmp(p->one->sha1, p->two->sha1) ||
			 p->one->mode != p->two->mode ||
			 is_null_sha1(p->one->sha1))
			p->status = DIFF_STATUS_MODIFIED;
		else {
			/* This is a "no-change" entry and should not
			 * happen anymore, but prepare for broken callers.
			 */
			error("feeding unmodified %s to diffcore",
			      p->one->path);
			p->status = DIFF_STATUS_UNKNOWN;
		}
	}
	diff_debug_queue("resolve-rename-copy done", q);
}


static void write_vec_element_i32(DisasContext *s, TCGv_i32 tcg_src, int destidx, int element, TCGMemOp memop) { int vect_off = vec_reg_offset(destidx, element, memop & MO_SIZE); switch (memop) { case MO_8: tcg_gen_st8_i32(tcg_src, cpu_env, vect_off); break; case MO_16: tcg_gen_st16_i32(tcg_src, cpu_env, vect_off); break; case MO_32: tcg_gen_st_i32(tcg_src, cpu_env, vect_off); break; default: g_assert_not_reached(); } }


static inline int diff_might_be_rename(void)
{
	return diff_queued_diff.nr == 1 &&
		!DIFF_FILE_VALID(diff_queued_diff.queue[0]->one);
}


static uint32_t taihu_cpld_readl (void *opaque, hwaddr addr) { uint32_t ret; ret = taihu_cpld_readb(opaque, addr) << 24; ret |= taihu_cpld_readb(opaque, addr + 1) << 16; ret |= taihu_cpld_readb(opaque, addr + 2) << 8; ret |= taihu_cpld_readb(opaque, addr + 3); return ret; }


static void handle_reflog(struct rev_info *revs, unsigned flags)
{
	struct all_refs_cb cb;
	cb.all_revs = revs;
	cb.all_flags = flags;
	for_each_reflog(handle_one_reflog, &cb);
}


static int aac_encode_frame(AVCodecContext *avctx, uint8_t *frame, int buf_size, void *data) { AACEncContext *s = avctx->priv_data; int16_t *samples = s->samples, *samples2, *la; ChannelElement *cpe; int i, j, chans, tag, start_ch; const uint8_t *chan_map = aac_chan_configs[avctx->channels-1]; int chan_el_counter[4]; FFPsyWindowInfo windows[avctx->channels]; if (s->last_frame) return 0; if (data) { if (!s->psypp) { memcpy(s->samples + 1024 * avctx->channels, data, 1024 * avctx->channels * sizeof(s->samples[0])); } else { start_ch = 0; samples2 = s->samples + 1024 * avctx->channels; for (i = 0; i < chan_map[0]; i++) { tag = chan_map[i+1]; chans = tag == TYPE_CPE ? 2 : 1; ff_psy_preprocess(s->psypp, (uint16_t*)data + start_ch, samples2 + start_ch, start_ch, chans); start_ch += chans; } } } if (!avctx->frame_number) { memcpy(s->samples, s->samples + 1024 * avctx->channels, 1024 * avctx->channels * sizeof(s->samples[0])); return 0; } start_ch = 0; for (i = 0; i < chan_map[0]; i++) { FFPsyWindowInfo* wi = windows + start_ch; tag = chan_map[i+1]; chans = tag == TYPE_CPE ? 2 : 1; cpe = &s->cpe[i]; samples2 = samples + start_ch; la = samples2 + 1024 * avctx->channels + start_ch; if (!data) la = NULL; for (j = 0; j < chans; j++) { IndividualChannelStream *ics = &cpe->ch[j].ics; int k; wi[j] = ff_psy_suggest_window(&s->psy, samples2, la, start_ch + j, ics->window_sequence[0]); ics->window_sequence[1] = ics->window_sequence[0]; ics->window_sequence[0] = wi[j].window_type[0]; ics->use_kb_window[1] = ics->use_kb_window[0]; ics->use_kb_window[0] = wi[j].window_shape; ics->num_windows = wi[j].num_windows; ics->swb_sizes = s->psy.bands [ics->num_windows == 8]; ics->num_swb = s->psy.num_bands[ics->num_windows == 8]; for (k = 0; k < ics->num_windows; k++) ics->group_len[k] = wi[j].grouping[k]; s->cur_channel = start_ch + j; apply_window_and_mdct(avctx, s, &cpe->ch[j], samples2, j); } start_ch += chans; } init_put_bits(&s->pb, frame, buf_size*8); if ((avctx->frame_number & 0xFF)==1 && !(avctx->flags & CODEC_FLAG_BITEXACT)) put_bitstream_info(avctx, s, LIBAVCODEC_IDENT); start_ch = 0; memset(chan_el_counter, 0, sizeof(chan_el_counter)); for (i = 0; i < chan_map[0]; i++) { FFPsyWindowInfo* wi = windows + start_ch; tag = chan_map[i+1]; chans = tag == TYPE_CPE ? 2 : 1; cpe = &s->cpe[i]; for (j = 0; j < chans; j++) { s->coder->search_for_quantizers(avctx, s, &cpe->ch[j], s->lambda); } cpe->common_window = 0; if (chans > 1 && wi[0].window_type[0] == wi[1].window_type[0] && wi[0].window_shape == wi[1].window_shape) { cpe->common_window = 1; for (j = 0; j < wi[0].num_windows; j++) { if (wi[0].grouping[j] != wi[1].grouping[j]) { cpe->common_window = 0; break; } } } if (cpe->common_window && s->coder->search_for_ms) s->coder->search_for_ms(s, cpe, s->lambda); adjust_frame_information(s, cpe, chans); put_bits(&s->pb, 3, tag); put_bits(&s->pb, 4, chan_el_counter[tag]++); if (chans == 2) { put_bits(&s->pb, 1, cpe->common_window); if (cpe->common_window) { put_ics_info(s, &cpe->ch[0].ics); encode_ms_info(&s->pb, cpe); } } for (j = 0; j < chans; j++) { s->cur_channel = start_ch + j; ff_psy_set_band_info(&s->psy, s->cur_channel, cpe->ch[j].coeffs, &wi[j]); encode_individual_channel(avctx, s, &cpe->ch[j], cpe->common_window); } start_ch += chans; } put_bits(&s->pb, 3, TYPE_END); flush_put_bits(&s->pb); avctx->frame_bits = put_bits_count(&s->pb); // rate control stuff if (!(avctx->flags & CODEC_FLAG_QSCALE)) { float ratio = avctx->bit_rate * 1024.0f / avctx->sample_rate / avctx->frame_bits; s->lambda *= ratio; s->lambda = fminf(s->lambda, 65536.f); } if (avctx->frame_bits > 6144*avctx->channels) av_log(avctx, AV_LOG_ERROR, "input buffer violation %d > %d.\n", avctx->frame_bits, 6144*avctx->channels); if (!data) s->last_frame = 1; memcpy(s->samples, s->samples + 1024 * avctx->channels, 1024 * avctx->channels * sizeof(s->samples[0])); return put_bits_count(&s->pb)>>3; }


int archive_strncat_l ( struct archive_string * as , const void * _p , size_t n , struct archive_string_conv * sc ) {
 const void * s ;
 size_t length = 0 ;
 int i , r = 0 , r2 ;
 if ( _p != NULL && n > 0 ) {
 if ( sc != NULL && ( sc -> flag & SCONV_FROM_UTF16 ) ) length = utf16nbytes ( _p , n ) ;
 else length = mbsnbytes ( _p , n ) ;
 }
 if ( length == 0 ) {
 int tn = 1 ;
 if ( sc != NULL && ( sc -> flag & SCONV_TO_UTF16 ) ) tn = 2 ;
 if ( archive_string_ensure ( as , as -> length + tn ) == NULL ) return ( - 1 ) ;
 as -> s [ as -> length ] = 0 ;
 if ( tn == 2 ) as -> s [ as -> length + 1 ] = 0 ;
 return ( 0 ) ;
 }
 if ( sc == NULL ) {
 if ( archive_string_append ( as , _p , length ) == NULL ) return ( - 1 ) ;
 return ( 0 ) ;
 }
 s = _p ;
 i = 0 ;
 if ( sc -> nconverter > 1 ) {
 sc -> utftmp . length = 0 ;
 r2 = sc -> converter [ 0 ] ( & ( sc -> utftmp ) , s , length , sc ) ;
 if ( r2 != 0 && errno == ENOMEM ) return ( r2 ) ;
 if ( r > r2 ) r = r2 ;
 s = sc -> utftmp . s ;
 length = sc -> utftmp . length ;
 ++ i ;
 }
 r2 = sc -> converter [ i ] ( as , s , length , sc ) ;
 if ( r > r2 ) r = r2 ;
 return ( r ) ;
 }


void unistim_calls_init_tap ( void ) {
 GString * error_string ;
 if ( have_unistim_tap_listener == FALSE ) {
 error_string = register_tap_listener ( "unistim" , & ( the_tapinfo_struct . unistim_dummy ) , NULL , 0 , voip_calls_dlg_reset , unistim_calls_packet , voip_calls_dlg_draw ) ;
 if ( error_string != NULL ) {
 simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK , "%s" , error_string -> str ) ;
 g_string_free ( error_string , TRUE ) ;
 exit ( 1 ) ;
 }
 have_unistim_tap_listener = TRUE ;
 }
 }


type_init(serial_register_types) static bool serial_isa_init(ISABus *bus, int index, CharDriverState *chr) { DeviceState *dev; ISADevice *isadev; isadev = isa_try_create(bus, TYPE_ISA_SERIAL); if (!isadev) { return false; } dev = DEVICE(isadev); qdev_prop_set_uint32(dev, "index", index); qdev_prop_set_chr(dev, "chardev", chr); if (qdev_init(dev) < 0) { return false; } return true; }


void fill_filespec(struct diff_filespec *spec, const unsigned char *sha1,
		   unsigned short mode)
{
	if (mode) {
		spec->mode = canon_mode(mode);
		hashcpy(spec->sha1, sha1);
		spec->sha1_valid = !is_null_sha1(sha1);
	}
}


static void show_name(FILE *file,
		      const char *prefix, const char *name, int len,
		      const char *reset, const char *set)
{
	fprintf(file, " %s%s%-*s%s |", set, prefix, len, name, reset);
}


static int vp3_decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size) { Vp3DecodeContext *s = avctx->priv_data; GetBitContext gb; static int counter = 0; init_get_bits(&gb, buf, buf_size * 8); if (s->theora && get_bits1(&gb)) { int ptype = get_bits(&gb, 7); skip_bits(&gb, 6*8); /* "theora" */ switch(ptype) { case 1: theora_decode_comments(avctx, gb); break; case 2: theora_decode_tables(avctx, gb); init_dequantizer(s); break; default: av_log(avctx, AV_LOG_ERROR, "Unknown Theora config packet: %d\n", ptype); } return buf_size; } s->keyframe = !get_bits1(&gb); if (!s->theora) skip_bits(&gb, 1); s->last_quality_index = s->quality_index; s->quality_index = get_bits(&gb, 6); if (s->theora >= 0x030200) skip_bits1(&gb); if (s->avctx->debug & FF_DEBUG_PICT_INFO) av_log(s->avctx, AV_LOG_INFO, " VP3 %sframe #%d: Q index = %d\n", s->keyframe?"key":"", counter, s->quality_index); counter++; if (s->quality_index != s->last_quality_index) init_dequantizer(s); if (s->keyframe) { if (!s->theora) { skip_bits(&gb, 4); /* width code */ skip_bits(&gb, 4); /* height code */ if (s->version) { s->version = get_bits(&gb, 5); if (counter == 1) av_log(s->avctx, AV_LOG_DEBUG, "VP version: %d\n", s->version); } } if (s->version || s->theora) { if (get_bits1(&gb)) av_log(s->avctx, AV_LOG_ERROR, "Warning, unsupported keyframe coding type?!\n"); skip_bits(&gb, 2); /* reserved? */ } if (s->last_frame.data[0] == s->golden_frame.data[0]) { if (s->golden_frame.data[0]) avctx->release_buffer(avctx, &s->golden_frame); s->last_frame= s->golden_frame; /* ensure that we catch any access to this released frame */ } else { if (s->golden_frame.data[0]) avctx->release_buffer(avctx, &s->golden_frame); if (s->last_frame.data[0]) avctx->release_buffer(avctx, &s->last_frame); } s->golden_frame.reference = 3; if(avctx->get_buffer(avctx, &s->golden_frame) < 0) { av_log(s->avctx, AV_LOG_ERROR, "vp3: get_buffer() failed\n"); return -1; } /* golden frame is also the current frame */ memcpy(&s->current_frame, &s->golden_frame, sizeof(AVFrame)); /* time to figure out pixel addresses? */ if (!s->pixel_addresses_inited) { if (!s->flipped_image) vp3_calculate_pixel_addresses(s); else theora_calculate_pixel_addresses(s); } } else { /* allocate a new current frame */ s->current_frame.reference = 3; if(avctx->get_buffer(avctx, &s->current_frame) < 0) { av_log(s->avctx, AV_LOG_ERROR, "vp3: get_buffer() failed\n"); return -1; } } s->current_frame.qscale_table= s->qscale_table; //FIXME allocate individual tables per AVFrame s->current_frame.qstride= 0; init_frame(s, &gb); #if KEYFRAMES_ONLY if (!s->keyframe) { memcpy(s->current_frame.data[0], s->golden_frame.data[0], s->current_frame.linesize[0] * s->height); memcpy(s->current_frame.data[1], s->golden_frame.data[1], s->current_frame.linesize[1] * s->height / 2); memcpy(s->current_frame.data[2], s->golden_frame.data[2], s->current_frame.linesize[2] * s->height / 2); } else { #endif if (unpack_superblocks(s, &gb) || unpack_modes(s, &gb) || unpack_vectors(s, &gb) || unpack_dct_coeffs(s, &gb)) { av_log(s->avctx, AV_LOG_ERROR, " vp3: could not decode frame\n"); return -1; } reverse_dc_prediction(s, 0, s->fragment_width, s->fragment_height); render_fragments(s, 0, s->width, s->height, 0); // apply_loop_filter(s); if ((avctx->flags & CODEC_FLAG_GRAY) == 0) { reverse_dc_prediction(s, s->u_fragment_start, s->fragment_width / 2, s->fragment_height / 2); reverse_dc_prediction(s, s->v_fragment_start, s->fragment_width / 2, s->fragment_height / 2); render_fragments(s, s->u_fragment_start, s->width / 2, s->height / 2, 1); render_fragments(s, s->v_fragment_start, s->width / 2, s->height / 2, 2); } else { memset(s->current_frame.data[1], 0x80, s->width * s->height / 4); memset(s->current_frame.data[2], 0x80, s->width * s->height / 4); } #if KEYFRAMES_ONLY } #endif *data_size=sizeof(AVFrame); *(AVFrame*)data= s->current_frame; /* release the last frame, if it is allocated and if it is not the * golden frame */ if ((s->last_frame.data[0]) && (s->last_frame.data[0] != s->golden_frame.data[0])) avctx->release_buffer(avctx, &s->last_frame); /* shuffle frames (last = current) */ memcpy(&s->last_frame, &s->current_frame, sizeof(AVFrame)); s->current_frame.data[0]= NULL; /* ensure that we catch any access to this released frame */ return buf_size; }


bool memory_region_present(MemoryRegion *container, hwaddr addr) { MemoryRegion *mr = memory_region_find(container, addr, 1).mr; if (!mr || (mr == container)) { return false; } memory_region_unref(mr); return true; }


static inline int bidir_refine ( MpegEncContext * s , int mb_x , int mb_y ) {
 MotionEstContext * const c = & s -> me ;
 const int mot_stride = s -> mb_stride ;
 const int xy = mb_y * mot_stride + mb_x ;
 int fbmin ;
 int pred_fx = s -> b_bidir_forw_mv_table [ xy - 1 ] [ 0 ] ;
 int pred_fy = s -> b_bidir_forw_mv_table [ xy - 1 ] [ 1 ] ;
 int pred_bx = s -> b_bidir_back_mv_table [ xy - 1 ] [ 0 ] ;
 int pred_by = s -> b_bidir_back_mv_table [ xy - 1 ] [ 1 ] ;
 int motion_fx = s -> b_bidir_forw_mv_table [ xy ] [ 0 ] = s -> b_forw_mv_table [ xy ] [ 0 ] ;
 int motion_fy = s -> b_bidir_forw_mv_table [ xy ] [ 1 ] = s -> b_forw_mv_table [ xy ] [ 1 ] ;
 int motion_bx = s -> b_bidir_back_mv_table [ xy ] [ 0 ] = s -> b_back_mv_table [ xy ] [ 0 ] ;
 int motion_by = s -> b_bidir_back_mv_table [ xy ] [ 1 ] = s -> b_back_mv_table [ xy ] [ 1 ] ;
 const int flags = c -> sub_flags ;
 const int qpel = flags & FLAG_QPEL ;
 const int shift = 1 + qpel ;
 const int xmin = c -> xmin << shift ;
 const int ymin = c -> ymin << shift ;
 const int xmax = c -> xmax << shift ;
 const int ymax = c -> ymax << shift ;
 # define HASH ( fx , fy , bx , by ) ( ( fx ) + 17 * ( fy ) + 63 * ( bx ) + 117 * ( by ) ) # define HASH8 ( fx , fy , bx , by ) ( ( uint8_t ) HASH ( fx , fy , bx , by ) ) int hashidx = HASH ( motion_fx , motion_fy , motion_bx , motion_by ) ;
 uint8_t map [ 256 ] = {
 0 }
 ;
 map [ hashidx & 255 ] = 1 ;
 fbmin = check_bidir_mv ( s , motion_fx , motion_fy , motion_bx , motion_by , pred_fx , pred_fy , pred_bx , pred_by , 0 , 16 ) ;
 if ( s -> avctx -> bidir_refine ) {
 int end ;
 static const uint8_t limittab [ 5 ] = {
 0 , 8 , 32 , 64 , 80 }
 ;
 const int limit = limittab [ s -> avctx -> bidir_refine ] ;
 static const int8_t vect [ ] [ 4 ] = {
 {
 0 , 0 , 0 , 1 }
 , {
 0 , 0 , 0 , - 1 }
 , {
 0 , 0 , 1 , 0 }
 , {
 0 , 0 , - 1 , 0 }
 , {
 0 , 1 , 0 , 0 }
 , {
 0 , - 1 , 0 , 0 }
 , {
 1 , 0 , 0 , 0 }
 , {
 - 1 , 0 , 0 , 0 }
 , {
 0 , 0 , 1 , 1 }
 , {
 0 , 0 , - 1 , - 1 }
 , {
 0 , 1 , 1 , 0 }
 , {
 0 , - 1 , - 1 , 0 }
 , {
 1 , 1 , 0 , 0 }
 , {
 - 1 , - 1 , 0 , 0 }
 , {
 1 , 0 , 0 , 1 }
 , {
 - 1 , 0 , 0 , - 1 }
 , {
 0 , 1 , 0 , 1 }
 , {
 0 , - 1 , 0 , - 1 }
 , {
 1 , 0 , 1 , 0 }
 , {
 - 1 , 0 , - 1 , 0 }
 , {
 0 , 0 , - 1 , 1 }
 , {
 0 , 0 , 1 , - 1 }
 , {
 0 , - 1 , 1 , 0 }
 , {
 0 , 1 , - 1 , 0 }
 , {
 - 1 , 1 , 0 , 0 }
 , {
 1 , - 1 , 0 , 0 }
 , {
 1 , 0 , 0 , - 1 }
 , {
 - 1 , 0 , 0 , 1 }
 , {
 0 , - 1 , 0 , 1 }
 , {
 0 , 1 , 0 , - 1 }
 , {
 - 1 , 0 , 1 , 0 }
 , {
 1 , 0 , - 1 , 0 }
 , {
 0 , 1 , 1 , 1 }
 , {
 0 , - 1 , - 1 , - 1 }
 , {
 1 , 1 , 1 , 0 }
 , {
 - 1 , - 1 , - 1 , 0 }
 , {
 1 , 1 , 0 , 1 }
 , {
 - 1 , - 1 , 0 , - 1 }
 , {
 1 , 0 , 1 , 1 }
 , {
 - 1 , 0 , - 1 , - 1 }
 , {
 0 , - 1 , 1 , 1 }
 , {
 0 , 1 , - 1 , - 1 }
 , {
 - 1 , 1 , 1 , 0 }
 , {
 1 , - 1 , - 1 , 0 }
 , {
 1 , 1 , 0 , - 1 }
 , {
 - 1 , - 1 , 0 , 1 }
 , {
 1 , 0 , - 1 , 1 }
 , {
 - 1 , 0 , 1 , - 1 }
 , {
 0 , 1 , - 1 , 1 }
 , {
 0 , - 1 , 1 , - 1 }
 , {
 1 , - 1 , 1 , 0 }
 , {
 - 1 , 1 , - 1 , 0 }
 , {
 - 1 , 1 , 0 , 1 }
 , {
 1 , - 1 , 0 , - 1 }
 , {
 1 , 0 , 1 , - 1 }
 , {
 - 1 , 0 , - 1 , 1 }
 , {
 0 , 1 , 1 , - 1 }
 , {
 0 , - 1 , - 1 , 1 }
 , {
 1 , 1 , - 1 , 0 }
 , {
 - 1 , - 1 , 1 , 0 }
 , {
 1 , - 1 , 0 , 1 }
 , {
 - 1 , 1 , 0 , - 1 }
 , {
 - 1 , 0 , 1 , 1 }
 , {
 1 , 0 , - 1 , - 1 }
 , {
 1 , 1 , 1 , 1 }
 , {
 - 1 , - 1 , - 1 , - 1 }
 , {
 1 , 1 , 1 , - 1 }
 , {
 - 1 , - 1 , - 1 , 1 }
 , {
 1 , 1 , - 1 , 1 }
 , {
 - 1 , - 1 , 1 , - 1 }
 , {
 1 , - 1 , 1 , 1 }
 , {
 - 1 , 1 , - 1 , - 1 }
 , {
 - 1 , 1 , 1 , 1 }
 , {
 1 , - 1 , - 1 , - 1 }
 , {
 1 , 1 , - 1 , - 1 }
 , {
 - 1 , - 1 , 1 , 1 }
 , {
 1 , - 1 , - 1 , 1 }
 , {
 - 1 , 1 , 1 , - 1 }
 , {
 1 , - 1 , 1 , - 1 }
 , {
 - 1 , 1 , - 1 , 1 }
 , }
 ;
 static const uint8_t hash [ ] = {
 HASH8 ( 0 , 0 , 0 , 1 ) , HASH8 ( 0 , 0 , 0 , - 1 ) , HASH8 ( 0 , 0 , 1 , 0 ) , HASH8 ( 0 , 0 , - 1 , 0 ) , HASH8 ( 0 , 1 , 0 , 0 ) , HASH8 ( 0 , - 1 , 0 , 0 ) , HASH8 ( 1 , 0 , 0 , 0 ) , HASH8 ( - 1 , 0 , 0 , 0 ) , HASH8 ( 0 , 0 , 1 , 1 ) , HASH8 ( 0 , 0 , - 1 , - 1 ) , HASH8 ( 0 , 1 , 1 , 0 ) , HASH8 ( 0 , - 1 , - 1 , 0 ) , HASH8 ( 1 , 1 , 0 , 0 ) , HASH8 ( - 1 , - 1 , 0 , 0 ) , HASH8 ( 1 , 0 , 0 , 1 ) , HASH8 ( - 1 , 0 , 0 , - 1 ) , HASH8 ( 0 , 1 , 0 , 1 ) , HASH8 ( 0 , - 1 , 0 , - 1 ) , HASH8 ( 1 , 0 , 1 , 0 ) , HASH8 ( - 1 , 0 , - 1 , 0 ) , HASH8 ( 0 , 0 , - 1 , 1 ) , HASH8 ( 0 , 0 , 1 , - 1 ) , HASH8 ( 0 , - 1 , 1 , 0 ) , HASH8 ( 0 , 1 , - 1 , 0 ) , HASH8 ( - 1 , 1 , 0 , 0 ) , HASH8 ( 1 , - 1 , 0 , 0 ) , HASH8 ( 1 , 0 , 0 , - 1 ) , HASH8 ( - 1 , 0 , 0 , 1 ) , HASH8 ( 0 , - 1 , 0 , 1 ) , HASH8 ( 0 , 1 , 0 , - 1 ) , HASH8 ( - 1 , 0 , 1 , 0 ) , HASH8 ( 1 , 0 , - 1 , 0 ) , HASH8 ( 0 , 1 , 1 , 1 ) , HASH8 ( 0 , - 1 , - 1 , - 1 ) , HASH8 ( 1 , 1 , 1 , 0 ) , HASH8 ( - 1 , - 1 , - 1 , 0 ) , HASH8 ( 1 , 1 , 0 , 1 ) , HASH8 ( - 1 , - 1 , 0 , - 1 ) , HASH8 ( 1 , 0 , 1 , 1 ) , HASH8 ( - 1 , 0 , - 1 , - 1 ) , HASH8 ( 0 , - 1 , 1 , 1 ) , HASH8 ( 0 , 1 , - 1 , - 1 ) , HASH8 ( - 1 , 1 , 1 , 0 ) , HASH8 ( 1 , - 1 , - 1 , 0 ) , HASH8 ( 1 , 1 , 0 , - 1 ) , HASH8 ( - 1 , - 1 , 0 , 1 ) , HASH8 ( 1 , 0 , - 1 , 1 ) , HASH8 ( - 1 , 0 , 1 , - 1 ) , HASH8 ( 0 , 1 , - 1 , 1 ) , HASH8 ( 0 , - 1 , 1 , - 1 ) , HASH8 ( 1 , - 1 , 1 , 0 ) , HASH8 ( - 1 , 1 , - 1 , 0 ) , HASH8 ( - 1 , 1 , 0 , 1 ) , HASH8 ( 1 , - 1 , 0 , - 1 ) , HASH8 ( 1 , 0 , 1 , - 1 ) , HASH8 ( - 1 , 0 , - 1 , 1 ) , HASH8 ( 0 , 1 , 1 , - 1 ) , HASH8 ( 0 , - 1 , - 1 , 1 ) , HASH8 ( 1 , 1 , - 1 , 0 ) , HASH8 ( - 1 , - 1 , 1 , 0 ) , HASH8 ( 1 , - 1 , 0 , 1 ) , HASH8 ( - 1 , 1 , 0 , - 1 ) , HASH8 ( - 1 , 0 , 1 , 1 ) , HASH8 ( 1 , 0 , - 1 , - 1 ) , HASH8 ( 1 , 1 , 1 , 1 ) , HASH8 ( - 1 , - 1 , - 1 , - 1 ) , HASH8 ( 1 , 1 , 1 , - 1 ) , HASH8 ( - 1 , - 1 , - 1 , 1 ) , HASH8 ( 1 , 1 , - 1 , 1 ) , HASH8 ( - 1 , - 1 , 1 , - 1 ) , HASH8 ( 1 , - 1 , 1 , 1 ) , HASH8 ( - 1 , 1 , - 1 , - 1 ) , HASH8 ( - 1 , 1 , 1 , 1 ) , HASH8 ( 1 , - 1 , - 1 , - 1 ) , HASH8 ( 1 , 1 , - 1 , - 1 ) , HASH8 ( - 1 , - 1 , 1 , 1 ) , HASH8 ( 1 , - 1 , - 1 , 1 ) , HASH8 ( - 1 , 1 , 1 , - 1 ) , HASH8 ( 1 , - 1 , 1 , - 1 ) , HASH8 ( - 1 , 1 , - 1 , 1 ) , }
 ;
 # define CHECK_BIDIR ( fx , fy , bx , by ) if ( ! map [ ( hashidx + HASH ( fx , fy , bx , by ) ) & 255 ] && ( fx <= 0 || motion_fx + fx <= xmax ) && ( fy <= 0 || motion_fy + fy <= ymax ) && ( bx <= 0 || motion_bx + bx <= xmax ) && ( by <= 0 || motion_by + by <= ymax ) && ( fx >= 0 || motion_fx + fx >= xmin ) && ( fy >= 0 || motion_fy + fy >= ymin ) && ( bx >= 0 || motion_bx + bx >= xmin ) && ( by >= 0 || motion_by + by >= ymin ) ) {
 int score ;
 map [ ( hashidx + HASH ( fx , fy , bx , by ) ) & 255 ] = 1 ;
 score = check_bidir_mv ( s , motion_fx + fx , motion_fy + fy , motion_bx + bx , motion_by + by , pred_fx , pred_fy , pred_bx , pred_by , 0 , 16 ) ;
 if ( score < fbmin ) {
 hashidx += HASH ( fx , fy , bx , by ) ;
 fbmin = score ;
 motion_fx += fx ;
 motion_fy += fy ;
 motion_bx += bx ;
 motion_by += by ;
 end = 0 ;
 }
 }
 # define CHECK_BIDIR2 ( a , b , c , d ) CHECK_BIDIR ( a , b , c , d ) CHECK_BIDIR ( - ( a ) , - ( b ) , - ( c ) , - ( d ) ) do {
 int i ;
 int borderdist = 0 ;
 end = 1 ;
 CHECK_BIDIR2 ( 0 , 0 , 0 , 1 ) CHECK_BIDIR2 ( 0 , 0 , 1 , 0 ) CHECK_BIDIR2 ( 0 , 1 , 0 , 0 ) CHECK_BIDIR2 ( 1 , 0 , 0 , 0 ) for ( i = 8 ;
 i < limit ;
 i ++ ) {
 int fx = motion_fx + vect [ i ] [ 0 ] ;
 int fy = motion_fy + vect [ i ] [ 1 ] ;
 int bx = motion_bx + vect [ i ] [ 2 ] ;
 int by = motion_by + vect [ i ] [ 3 ] ;
 if ( borderdist <= 0 ) {
 int a = ( xmax - FFMAX ( fx , bx ) ) | ( FFMIN ( fx , bx ) - xmin ) ;
 int b = ( ymax - FFMAX ( fy , by ) ) | ( FFMIN ( fy , by ) - ymin ) ;
 if ( ( a | b ) < 0 ) map [ ( hashidx + hash [ i ] ) & 255 ] = 1 ;
 }
 if ( ! map [ ( hashidx + hash [ i ] ) & 255 ] ) {
 int score ;
 map [ ( hashidx + hash [ i ] ) & 255 ] = 1 ;
 score = check_bidir_mv ( s , fx , fy , bx , by , pred_fx , pred_fy , pred_bx , pred_by , 0 , 16 ) ;
 if ( score < fbmin ) {
 hashidx += hash [ i ] ;
 fbmin = score ;
 motion_fx = fx ;
 motion_fy = fy ;
 motion_bx = bx ;
 motion_by = by ;
 end = 0 ;
 borderdist -- ;
 if ( borderdist <= 0 ) {
 int a = FFMIN ( xmax - FFMAX ( fx , bx ) , FFMIN ( fx , bx ) - xmin ) ;
 int b = FFMIN ( ymax - FFMAX ( fy , by ) , FFMIN ( fy , by ) - ymin ) ;
 borderdist = FFMIN ( a , b ) ;
 }
 }
 }
 }
 }
 while ( ! end ) ;
 }
 s -> b_bidir_forw_mv_table [ xy ] [ 0 ] = motion_fx ;
 s -> b_bidir_forw_mv_table [ xy ] [ 1 ] = motion_fy ;
 s -> b_bidir_back_mv_table [ xy ] [ 0 ] = motion_bx ;
 s -> b_bidir_back_mv_table [ xy ] [ 1 ] = motion_by ;
 return fbmin ;
 }


int git_diff_basic_config(const char *var, const char *value, void *cb)
{
	if (!prefixcmp(var, "diff.color.") || !prefixcmp(var, "color.diff.")) {
		int slot = parse_diff_color_slot(var, 11);
		if (!value)
			return config_error_nonbool(var);
		color_parse(value, var, diff_colors[slot]);
		return 0;
	}

	if (!prefixcmp(var, "diff.")) {
		const char *ep = strrchr(var, '.');
		if (ep != var + 4) {
			if (!strcmp(ep, ".funcname")) {
				if (!value)
					return config_error_nonbool(var);
				return parse_funcname_pattern(var, ep, value);
			}
		}
	}

	return git_color_default_config(var, value, cb);
}


uint32_t kvmppc_get_dfp(void) { return kvmppc_read_int_cpu_dt("ibm,dfp"); }


int setup_revisions(int argc, const char **argv, struct rev_info *revs, const char *def)
{
	int i, flags, seen_dashdash, show_merge;
	const char **unrecognized = argv + 1;
	int left = 1;
	int all_match = 0;
	int regflags = 0;
	int fixed = 0;

	/* First, search for "--" */
	seen_dashdash = 0;
	for (i = 1; i < argc; i++) {
		const char *arg = argv[i];
		if (strcmp(arg, "--"))
			continue;
		argv[i] = NULL;
		argc = i;
		if (argv[i + 1])
			revs->prune_data = get_pathspec(revs->prefix, argv + i + 1);
		seen_dashdash = 1;
		break;
	}

	flags = show_merge = 0;
	for (i = 1; i < argc; i++) {
		const char *arg = argv[i];
		if (*arg == '-') {
			int opts;
			if (!prefixcmp(arg, "--max-count=")) {
				revs->max_count = atoi(arg + 12);
				continue;
			}
			if (!prefixcmp(arg, "--skip=")) {
				revs->skip_count = atoi(arg + 7);
				continue;
			}
			/* accept -<digit>, like traditional "head" */
			if ((*arg == '-') && isdigit(arg[1])) {
				revs->max_count = atoi(arg + 1);
				continue;
			}
			if (!strcmp(arg, "-n")) {
				if (argc <= i + 1)
					die("-n requires an argument");
				revs->max_count = atoi(argv[++i]);
				continue;
			}
			if (!prefixcmp(arg, "-n")) {
				revs->max_count = atoi(arg + 2);
				continue;
			}
			if (!prefixcmp(arg, "--max-age=")) {
				revs->max_age = atoi(arg + 10);
				continue;
			}
			if (!prefixcmp(arg, "--since=")) {
				revs->max_age = approxidate(arg + 8);
				continue;
			}
			if (!prefixcmp(arg, "--after=")) {
				revs->max_age = approxidate(arg + 8);
				continue;
			}
			if (!prefixcmp(arg, "--min-age=")) {
				revs->min_age = atoi(arg + 10);
				continue;
			}
			if (!prefixcmp(arg, "--before=")) {
				revs->min_age = approxidate(arg + 9);
				continue;
			}
			if (!prefixcmp(arg, "--until=")) {
				revs->min_age = approxidate(arg + 8);
				continue;
			}
			if (!strcmp(arg, "--all")) {
				handle_refs(revs, flags, for_each_ref);
				continue;
			}
			if (!strcmp(arg, "--branches")) {
				handle_refs(revs, flags, for_each_branch_ref);
				continue;
			}
			if (!strcmp(arg, "--tags")) {
				handle_refs(revs, flags, for_each_tag_ref);
				continue;
			}
			if (!strcmp(arg, "--remotes")) {
				handle_refs(revs, flags, for_each_remote_ref);
				continue;
			}
			if (!strcmp(arg, "--first-parent")) {
				revs->first_parent_only = 1;
				continue;
			}
			if (!strcmp(arg, "--reflog")) {
				handle_reflog(revs, flags);
				continue;
			}
			if (!strcmp(arg, "-g") ||
					!strcmp(arg, "--walk-reflogs")) {
				init_reflog_walk(&revs->reflog_info);
				continue;
			}
			if (!strcmp(arg, "--not")) {
				flags ^= UNINTERESTING;
				continue;
			}
			if (!strcmp(arg, "--default")) {
				if (++i >= argc)
					die("bad --default argument");
				def = argv[i];
				continue;
			}
			if (!strcmp(arg, "--merge")) {
				show_merge = 1;
				continue;
			}
			if (!strcmp(arg, "--topo-order")) {
				revs->lifo = 1;
				revs->topo_order = 1;
				continue;
			}
			if (!strcmp(arg, "--date-order")) {
				revs->lifo = 0;
				revs->topo_order = 1;
				continue;
			}
			if (!prefixcmp(arg, "--early-output")) {
				int count = 100;
				switch (arg[14]) {
				case '=':
					count = atoi(arg+15);
					/* Fallthrough */
				case 0:
					revs->topo_order = 1;
					revs->early_output = count;
					continue;
				}
			}
			if (!strcmp(arg, "--parents")) {
				revs->rewrite_parents = 1;
				revs->print_parents = 1;
				continue;
			}
			if (!strcmp(arg, "--dense")) {
				revs->dense = 1;
				continue;
			}
			if (!strcmp(arg, "--sparse")) {
				revs->dense = 0;
				continue;
			}
			if (!strcmp(arg, "--show-all")) {
				revs->show_all = 1;
				continue;
			}
			if (!strcmp(arg, "--remove-empty")) {
				revs->remove_empty_trees = 1;
				continue;
			}
			if (!strcmp(arg, "--no-merges")) {
				revs->no_merges = 1;
				continue;
			}
			if (!strcmp(arg, "--boundary")) {
				revs->boundary = 1;
				continue;
			}
			if (!strcmp(arg, "--left-right")) {
				revs->left_right = 1;
				continue;
			}
			if (!strcmp(arg, "--cherry-pick")) {
				revs->cherry_pick = 1;
				revs->limited = 1;
				continue;
			}
			if (!strcmp(arg, "--objects")) {
				revs->tag_objects = 1;
				revs->tree_objects = 1;
				revs->blob_objects = 1;
				continue;
			}
			if (!strcmp(arg, "--objects-edge")) {
				revs->tag_objects = 1;
				revs->tree_objects = 1;
				revs->blob_objects = 1;
				revs->edge_hint = 1;
				continue;
			}
			if (!strcmp(arg, "--unpacked")) {
				revs->unpacked = 1;
				free(revs->ignore_packed);
				revs->ignore_packed = NULL;
				revs->num_ignore_packed = 0;
				continue;
			}
			if (!prefixcmp(arg, "--unpacked=")) {
				revs->unpacked = 1;
				add_ignore_packed(revs, arg+11);
				continue;
			}
			if (!strcmp(arg, "-r")) {
				revs->diff = 1;
				DIFF_OPT_SET(&revs->diffopt, RECURSIVE);
				continue;
			}
			if (!strcmp(arg, "-t")) {
				revs->diff = 1;
				DIFF_OPT_SET(&revs->diffopt, RECURSIVE);
				DIFF_OPT_SET(&revs->diffopt, TREE_IN_RECURSIVE);
				continue;
			}
			if (!strcmp(arg, "-m")) {
				revs->ignore_merges = 0;
				continue;
			}
			if (!strcmp(arg, "-c")) {
				revs->diff = 1;
				revs->dense_combined_merges = 0;
				revs->combine_merges = 1;
				continue;
			}
			if (!strcmp(arg, "--cc")) {
				revs->diff = 1;
				revs->dense_combined_merges = 1;
				revs->combine_merges = 1;
				continue;
			}
			if (!strcmp(arg, "-v")) {
				revs->verbose_header = 1;
				continue;
			}
			if (!strcmp(arg, "--pretty")) {
				revs->verbose_header = 1;
				get_commit_format(arg+8, revs);
				continue;
			}
			if (!prefixcmp(arg, "--pretty=")) {
				revs->verbose_header = 1;
				get_commit_format(arg+9, revs);
				continue;
			}
			if (!strcmp(arg, "--graph")) {
				revs->topo_order = 1;
				revs->rewrite_parents = 1;
				revs->graph = graph_init(revs);
				continue;
			}
			if (!strcmp(arg, "--root")) {
				revs->show_root_diff = 1;
				continue;
			}
			if (!strcmp(arg, "--no-commit-id")) {
				revs->no_commit_id = 1;
				continue;
			}
			if (!strcmp(arg, "--always")) {
				revs->always_show_header = 1;
				continue;
			}
			if (!strcmp(arg, "--no-abbrev")) {
				revs->abbrev = 0;
				continue;
			}
			if (!strcmp(arg, "--abbrev")) {
				revs->abbrev = DEFAULT_ABBREV;
				continue;
			}
			if (!prefixcmp(arg, "--abbrev=")) {
				revs->abbrev = strtoul(arg + 9, NULL, 10);
				if (revs->abbrev < MINIMUM_ABBREV)
					revs->abbrev = MINIMUM_ABBREV;
				else if (revs->abbrev > 40)
					revs->abbrev = 40;
				continue;
			}
			if (!strcmp(arg, "--abbrev-commit")) {
				revs->abbrev_commit = 1;
				continue;
			}
			if (!strcmp(arg, "--full-diff")) {
				revs->diff = 1;
				revs->full_diff = 1;
				continue;
			}
			if (!strcmp(arg, "--full-history")) {
				revs->simplify_history = 0;
				continue;
			}
			if (!strcmp(arg, "--relative-date")) {
				revs->date_mode = DATE_RELATIVE;
				continue;
			}
			if (!strncmp(arg, "--date=", 7)) {
				revs->date_mode = parse_date_format(arg + 7);
				continue;
			}
			if (!strcmp(arg, "--log-size")) {
				revs->show_log_size = 1;
				continue;
			}

			/*
			 * Grepping the commit log
			 */
			if (!prefixcmp(arg, "--author=")) {
				add_header_grep(revs, "author", arg+9);
				continue;
			}
			if (!prefixcmp(arg, "--committer=")) {
				add_header_grep(revs, "committer", arg+12);
				continue;
			}
			if (!prefixcmp(arg, "--grep=")) {
				add_message_grep(revs, arg+7);
				continue;
			}
			if (!strcmp(arg, "--extended-regexp") ||
			    !strcmp(arg, "-E")) {
				regflags |= REG_EXTENDED;
				continue;
			}
			if (!strcmp(arg, "--regexp-ignore-case") ||
			    !strcmp(arg, "-i")) {
				regflags |= REG_ICASE;
				continue;
			}
			if (!strcmp(arg, "--fixed-strings") ||
			    !strcmp(arg, "-F")) {
				fixed = 1;
				continue;
			}
			if (!strcmp(arg, "--all-match")) {
				all_match = 1;
				continue;
			}
			if (!prefixcmp(arg, "--encoding=")) {
				arg += 11;
				if (strcmp(arg, "none"))
					git_log_output_encoding = xstrdup(arg);
				else
					git_log_output_encoding = "";
				continue;
			}
			if (!strcmp(arg, "--reverse")) {
				revs->reverse ^= 1;
				continue;
			}
			if (!strcmp(arg, "--no-walk")) {
				revs->no_walk = 1;
				continue;
			}
			if (!strcmp(arg, "--do-walk")) {
				revs->no_walk = 0;
				continue;
			}

			opts = diff_opt_parse(&revs->diffopt, argv+i, argc-i);
			if (opts > 0) {
				i += opts - 1;
				continue;
			}
			*unrecognized++ = arg;
			left++;
			continue;
		}

		if (handle_revision_arg(arg, revs, flags, seen_dashdash)) {
			int j;
			if (seen_dashdash || *arg == '^')
				die("bad revision '%s'", arg);

			/* If we didn't have a "--":
			 * (1) all filenames must exist;
			 * (2) all rev-args must not be interpretable
			 *     as a valid filename.
			 * but the latter we have checked in the main loop.
			 */
			for (j = i; j < argc; j++)
				verify_filename(revs->prefix, argv[j]);

			revs->prune_data = get_pathspec(revs->prefix,
							argv + i);
			break;
		}
	}

	if (revs->grep_filter) {
		revs->grep_filter->regflags |= regflags;
		revs->grep_filter->fixed = fixed;
	}

	if (show_merge)
		prepare_show_merge(revs);
	if (def && !revs->pending.nr) {
		unsigned char sha1[20];
		struct object *object;
		unsigned mode;
		if (get_sha1_with_mode(def, sha1, &mode))
			die("bad default revision '%s'", def);
		object = get_reference(revs, def, sha1, 0);
		add_pending_object_with_mode(revs, object, def, mode);
	}

	/* Did the user ask for any diff output? Run the diff! */
	if (revs->diffopt.output_format & ~DIFF_FORMAT_NO_OUTPUT)
		revs->diff = 1;

	/* Pickaxe, diff-filter and rename following need diffs */
	if (revs->diffopt.pickaxe ||
	    revs->diffopt.filter ||
	    DIFF_OPT_TST(&revs->diffopt, FOLLOW_RENAMES))
		revs->diff = 1;

	if (revs->topo_order)
		revs->limited = 1;

	if (revs->prune_data) {
		diff_tree_setup_paths(revs->prune_data, &revs->pruning);
		/* Can't prune commits with rename following: the paths change.. */
		if (!DIFF_OPT_TST(&revs->diffopt, FOLLOW_RENAMES))
			revs->prune = 1;
		if (!revs->full_diff)
			diff_tree_setup_paths(revs->prune_data, &revs->diffopt);
	}
	if (revs->combine_merges) {
		revs->ignore_merges = 0;
		if (revs->dense_combined_merges && !revs->diffopt.output_format)
			revs->diffopt.output_format = DIFF_FORMAT_PATCH;
	}
	revs->diffopt.abbrev = revs->abbrev;
	if (diff_setup_done(&revs->diffopt) < 0)
		die("diff_setup_done failed");

	if (revs->grep_filter) {
		revs->grep_filter->all_match = all_match;
		compile_grep_patterns(revs->grep_filter);
	}

	if (revs->reverse && revs->reflog_info)
		die("cannot combine --reverse with --walk-reflogs");

	/*
	 * Limitations on the graph functionality
	 */
	if (revs->reverse && revs->graph)
		die("cannot combine --reverse with --graph");

	if (revs->reflog_info && revs->graph)
		die("cannot combine --walk-reflogs with --graph");

	return left;
}


static int usb_host_usbfs_type(USBHostDevice *s, USBPacket *p) { static const int usbfs[] = { [USB_ENDPOINT_XFER_CONTROL] = USBDEVFS_URB_TYPE_CONTROL, [USB_ENDPOINT_XFER_ISOC] = USBDEVFS_URB_TYPE_ISO, [USB_ENDPOINT_XFER_BULK] = USBDEVFS_URB_TYPE_BULK, [USB_ENDPOINT_XFER_INT] = USBDEVFS_URB_TYPE_INTERRUPT, }; uint8_t type = usb_ep_get_type(&s->dev, p->pid, p->devep); assert(type < ARRAY_SIZE(usbfs)); return usbfs[type]; }


static struct match_attr *parse_attr_line(const char *line, const char *src,
					  int lineno, int macro_ok)
{
	int namelen;
	int num_attr;
	const char *cp, *name;
	struct match_attr *res = NULL;
	int pass;
	int is_macro;

	cp = line + strspn(line, blank);
	if (!*cp || *cp == '#')
		return NULL;
	name = cp;
	namelen = strcspn(name, blank);
	if (strlen(ATTRIBUTE_MACRO_PREFIX) < namelen &&
	    !prefixcmp(name, ATTRIBUTE_MACRO_PREFIX)) {
		if (!macro_ok) {
			fprintf(stderr, "%s not allowed: %s:%d\n",
				name, src, lineno);
			return NULL;
		}
		is_macro = 1;
		name += strlen(ATTRIBUTE_MACRO_PREFIX);
		name += strspn(name, blank);
		namelen = strcspn(name, blank);
		if (invalid_attr_name(name, namelen)) {
			fprintf(stderr,
				"%.*s is not a valid attribute name: %s:%d\n",
				namelen, name, src, lineno);
			return NULL;
		}
	}
	else
		is_macro = 0;

	for (pass = 0; pass < 2; pass++) {
		/* pass 0 counts and allocates, pass 1 fills */
		num_attr = 0;
		cp = name + namelen;
		cp = cp + strspn(cp, blank);
		while (*cp) {
			cp = parse_attr(src, lineno, cp, &num_attr, res);
			if (!cp)
				return NULL;
		}
		if (pass)
			break;
		res = xcalloc(1,
			      sizeof(*res) +
			      sizeof(struct attr_state) * num_attr +
			      (is_macro ? 0 : namelen + 1));
		if (is_macro)
			res->u.attr = git_attr(name, namelen);
		else {
			res->u.pattern = (char*)&(res->state[num_attr]);
			memcpy(res->u.pattern, name, namelen);
			res->u.pattern[namelen] = 0;
		}
		res->is_macro = is_macro;
		res->num_attr = num_attr;
	}
	return res;
}


static void DangerousDownloadValidated ( JNIEnv * env , const JavaParamRef < jclass > & clazz , const JavaParamRef < jobject > & tab , jint download_id , jboolean accept ) {
 TabAndroid * tab_android = TabAndroid : : GetNativeTab ( env , tab ) ;
 content : : DownloadControllerAndroid : : Get ( ) -> DangerousDownloadValidated ( tab_android -> web_contents ( ) , download_id , accept ) ;
 }


static hb_segment_properties_t * segment_properties_reference ( hb_segment_properties_t * g ) {
 hb_segment_properties_t * c = ( hb_segment_properties_t * ) calloc ( 1 , sizeof ( hb_segment_properties_t ) ) ;
 if ( unlikely ( ! c ) ) return NULL ;
 * c = * g ;
 return c ;
 }


static void csselr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { env->cp15.c0_cssel = value & 0xf; }


static void *read_index_data(const char *path)
{
	int pos, len;
	unsigned long sz;
	enum object_type type;
	void *data;

	len = strlen(path);
	pos = cache_name_pos(path, len);
	if (pos < 0) {
		/*
		 * We might be in the middle of a merge, in which
		 * case we would read stage #2 (ours).
		 */
		int i;
		for (i = -pos - 1;
		     (pos < 0 && i < active_nr &&
		      !strcmp(active_cache[i]->name, path));
		     i++)
			if (ce_stage(active_cache[i]) == 2)
				pos = i;
	}
	if (pos < 0)
		return NULL;
	data = read_sha1_file(active_cache[pos]->sha1, &type, &sz);
	if (!data || type != OBJ_BLOB) {
		free(data);
		return NULL;
	}
	return data;
}


static struct attr_stack *read_attr_from_array(const char **list)
{
	struct attr_stack *res;
	const char *line;
	int lineno = 0;

	res = xcalloc(1, sizeof(*res));
	while ((line = *(list++)) != NULL)
		handle_attr_line(res, line, "[builtin]", ++lineno, 1);
	return res;
}


static void check_external_clock_sync(VideoState *is, double pts) { if (fabs(get_external_clock(is) - pts) > AV_NOSYNC_THRESHOLD) { update_external_clock_pts(is, pts); } }


static int flush_grep(struct grep_opt *opt,
		      int argc, int arg0, const char **argv, int *kept)
{
	int status;
	int count = argc - arg0;
	const char *kept_0 = NULL;

	if (count <= 2) {
		/*
		 * Because we keep at least 2 paths in the call from
		 * the main loop (i.e. kept != NULL), and MAXARGS is
		 * far greater than 2, this usually is a call to
		 * conclude the grep.  However, the user could attempt
		 * to overflow the argv buffer by giving too many
		 * options to leave very small number of real
		 * arguments even for the call in the main loop.
		 */
		if (kept)
			die("insanely many options to grep");

		/*
		 * If we have two or more paths, we do not have to do
		 * anything special, but we need to push /dev/null to
		 * get "-H" behaviour of GNU grep portably but when we
		 * are not doing "-l" nor "-L" nor "-c".
		 */
		if (count == 1 &&
		    !opt->name_only &&
		    !opt->unmatch_name_only &&
		    !opt->count) {
			argv[argc++] = "/dev/null";
			argv[argc] = NULL;
		}
	}

	else if (kept) {
		/*
		 * Called because we found many paths and haven't finished
		 * iterating over the cache yet.  We keep two paths
		 * for the concluding call.  argv[argc-2] and argv[argc-1]
		 * has the last two paths, so save the first one away,
		 * replace it with NULL while sending the list to grep,
		 * and recover them after we are done.
		 */
		*kept = 2;
		kept_0 = argv[argc-2];
		argv[argc-2] = NULL;
		argc -= 2;
	}

	status = exec_grep(argc, argv);

	if (kept_0) {
		/*
		 * Then recover them.  Now the last arg is beyond the
		 * terminating NULL which is at argc, and the second
		 * from the last is what we saved away in kept_0
		 */
		argv[arg0++] = kept_0;
		argv[arg0] = argv[argc+1];
	}
	return status;
}


static int exec_grep(int argc, const char **argv)
{
	pid_t pid;
	int status;

	argv[argc] = NULL;
	pid = fork();
	if (pid < 0)
		return pid;
	if (!pid) {
		execvp("grep", (char **) argv);
		exit(255);
	}
	while (waitpid(pid, &status, 0) < 0) {
		if (errno == EINTR)
			continue;
		return -1;
	}
	if (WIFEXITED(status)) {
		if (!WEXITSTATUS(status))
			return 1;
		return 0;
	}
	return -1;
}


static gpgme_error_t gpgsm_encrypt ( void * engine , gpgme_key_t recp [ ] , gpgme_encrypt_flags_t flags , gpgme_data_t plain , gpgme_data_t ciph , int use_armor ) {
 engine_gpgsm_t gpgsm = engine ;
 gpgme_error_t err ;
 if ( ! gpgsm ) return gpg_error ( GPG_ERR_INV_VALUE ) ;
 if ( ! recp ) return gpg_error ( GPG_ERR_NOT_IMPLEMENTED ) ;
 if ( flags & GPGME_ENCRYPT_NO_ENCRYPT_TO ) {
 err = gpgsm_assuan_simple_command ( gpgsm -> assuan_ctx , "OPTION no-encrypt-to" , NULL , NULL ) ;
 if ( err ) return err ;
 }
 gpgsm -> input_cb . data = plain ;
 err = gpgsm_set_fd ( gpgsm , INPUT_FD , map_data_enc ( gpgsm -> input_cb . data ) ) ;
 if ( err ) return err ;
 gpgsm -> output_cb . data = ciph ;
 err = gpgsm_set_fd ( gpgsm , OUTPUT_FD , use_armor ? "--armor" : map_data_enc ( gpgsm -> output_cb . data ) ) ;
 if ( err ) return err ;
 gpgsm_clear_fd ( gpgsm , MESSAGE_FD ) ;
 gpgsm -> inline_data = NULL ;
 err = set_recipients ( gpgsm , recp ) ;
 if ( ! err ) err = start ( gpgsm , "ENCRYPT" ) ;
 return err ;
 }


static void __exit dccp_fini(void)
{
	dccp_mib_exit();
	free_pages((unsigned long)dccp_hashinfo.bhash,
		   get_order(dccp_hashinfo.bhash_size *
			     sizeof(struct inet_bind_hashbucket)));
	free_pages((unsigned long)dccp_hashinfo.ehash,
		   get_order(dccp_hashinfo.ehash_size *
			     sizeof(struct inet_ehash_bucket)));
	inet_ehash_locks_free(&dccp_hashinfo);
	kmem_cache_destroy(dccp_hashinfo.bind_bucket_cachep);
	dccp_ackvec_exit();
	dccp_sysctl_exit();
}


static inline int dccp_mib_init(void)
{
	return snmp_mib_init((void**)dccp_statistics, sizeof(struct dccp_mib));
}


const char *dccp_state_name(const int state)
{
	static char *dccp_state_names[] = {
	[DCCP_OPEN]		= "OPEN",
	[DCCP_REQUESTING]	= "REQUESTING",
	[DCCP_PARTOPEN]		= "PARTOPEN",
	[DCCP_LISTEN]		= "LISTEN",
	[DCCP_RESPOND]		= "RESPOND",
	[DCCP_CLOSING]		= "CLOSING",
	[DCCP_ACTIVE_CLOSEREQ]	= "CLOSEREQ",
	[DCCP_PASSIVE_CLOSE]	= "PASSIVE_CLOSE",
	[DCCP_PASSIVE_CLOSEREQ]	= "PASSIVE_CLOSEREQ",
	[DCCP_TIME_WAIT]	= "TIME_WAIT",
	[DCCP_CLOSED]		= "CLOSED",
	};

	if (state >= DCCP_MAX_STATES)
		return "INVALID STATE!";
	else
		return dccp_state_names[state];
}


static int iscsi_truncate(BlockDriverState *bs, int64_t offset) { IscsiLun *iscsilun = bs->opaque; Error *local_err = NULL; if (iscsilun->type != TYPE_DISK) { return -ENOTSUP; } iscsi_readcapacity_sync(iscsilun, &local_err); if (local_err != NULL) { error_free(local_err); return -EIO; } if (offset > iscsi_getlength(bs)) { return -EINVAL; } if (iscsilun->allocationmap != NULL) { g_free(iscsilun->allocationmap); iscsilun->allocationmap = bitmap_new(DIV_ROUND_UP(bs->total_sectors, iscsilun->cluster_sectors)); } return 0; }


START_TEST(qdict_del_test) { const char *key = "key test"; qdict_put(tests_dict, key, qstring_from_str("foo")); fail_unless(qdict_size(tests_dict) == 1); qdict_del(tests_dict, key); fail_unless(qdict_size(tests_dict) == 0); fail_unless(qdict_haskey(tests_dict, key) == 0); }


static inline int dccp_need_reset(int state)
{
	return state != DCCP_CLOSED && state != DCCP_LISTEN &&
	       state != DCCP_REQUESTING;
}


static int hls_window(AVFormatContext *s, int last) { HLSContext *hls = s->priv_data; ListEntry *en; int64_t target_duration = 0; int ret = 0; AVIOContext *out = NULL; char temp_filename[1024]; int64_t sequence = FFMAX(hls->start_sequence, hls->sequence - hls->size); snprintf(temp_filename, sizeof(temp_filename), "%s.tmp", s->filename); if ((ret = avio_open2(&out, temp_filename, AVIO_FLAG_WRITE, &s->interrupt_callback, NULL)) < 0) goto fail; for (en = hls->list; en; en = en->next) { if (target_duration < en->duration) target_duration = en->duration; } avio_printf(out, "#EXTM3U\n"); avio_printf(out, "#EXT-X-VERSION:%d\n", hls->version); if (hls->allowcache == 0 || hls->allowcache == 1) { avio_printf(out, "#EXT-X-ALLOW-CACHE:%s\n", hls->allowcache == 0 ? "NO" : "YES"); } avio_printf(out, "#EXT-X-TARGETDURATION:%"PRId64"\n", av_rescale_rnd(target_duration, 1, AV_TIME_BASE, AV_ROUND_UP)); avio_printf(out, "#EXT-X-MEDIA-SEQUENCE:%"PRId64"\n", sequence); av_log(s, AV_LOG_VERBOSE, "EXT-X-MEDIA-SEQUENCE:%"PRId64"\n", sequence); for (en = hls->list; en; en = en->next) { if (hls->version > 2) avio_printf(out, "#EXTINF:%f\n", (double)en->duration / AV_TIME_BASE); else avio_printf(out, "#EXTINF:%"PRId64",\n", av_rescale(en->duration, 1, AV_TIME_BASE)); if (hls->baseurl) avio_printf(out, "%s", hls->baseurl); avio_printf(out, "%s\n", en->name); } if (last) avio_printf(out, "#EXT-X-ENDLIST\n"); fail: avio_closep(&out); if (ret >= 0) ff_rename(temp_filename, s->filename); return ret; }


END_TEST START_TEST ( test_find_user_by_ip ) {
 in_addr_t ip ;
 unsigned int testip ;
 ip = inet_addr ( "127.0.0.1" ) ;
 init_users ( ip , 27 ) ;
 users [ 0 ] . conn = CONN_DNS_NULL ;
 testip = ( unsigned int ) inet_addr ( "10.0.0.1" ) ;
 fail_unless ( find_user_by_ip ( testip ) == - 1 ) ;
 testip = ( unsigned int ) inet_addr ( "127.0.0.2" ) ;
 fail_unless ( find_user_by_ip ( testip ) == - 1 ) ;
 users [ 0 ] . active = 1 ;
 testip = ( unsigned int ) inet_addr ( "127.0.0.2" ) ;
 fail_unless ( find_user_by_ip ( testip ) == - 1 ) ;
 users [ 0 ] . last_pkt = time ( NULL ) ;
 testip = ( unsigned int ) inet_addr ( "127.0.0.2" ) ;
 fail_unless ( find_user_by_ip ( testip ) == 0 ) ;
 }


static int rv34_set_deblock_coef ( RV34DecContext * r ) {
 MpegEncContext * s = & r -> s ;
 int hmvmask = 0 , vmvmask = 0 , i , j ;
 int midx = s -> mb_x * 2 + s -> mb_y * 2 * s -> b8_stride ;
 int16_t ( * motion_val ) [ 2 ] = & s -> current_picture_ptr -> motion_val [ 0 ] [ midx ] ;
 for ( j = 0 ;
 j < 16 ;
 j += 8 ) {
 for ( i = 0 ;
 i < 2 ;
 i ++ ) {
 if ( is_mv_diff_gt_3 ( motion_val + i , 1 ) ) vmvmask |= 0x11 << ( j + i * 2 ) ;
 if ( ( j || s -> mb_y ) && is_mv_diff_gt_3 ( motion_val + i , s -> b8_stride ) ) hmvmask |= 0x03 << ( j + i * 2 ) ;
 }
 motion_val += s -> b8_stride ;
 }
 if ( s -> first_slice_line ) hmvmask &= ~ 0x000F ;
 if ( ! s -> mb_x ) vmvmask &= ~ 0x1111 ;
 if ( r -> rv30 ) {
 vmvmask |= ( vmvmask & 0x4444 ) >> 1 ;
 hmvmask |= ( hmvmask & 0x0F00 ) >> 4 ;
 if ( s -> mb_x ) r -> deblock_coefs [ s -> mb_x - 1 + s -> mb_y * s -> mb_stride ] |= ( vmvmask & 0x1111 ) << 3 ;
 if ( ! s -> first_slice_line ) r -> deblock_coefs [ s -> mb_x + ( s -> mb_y - 1 ) * s -> mb_stride ] |= ( hmvmask & 0xF ) << 12 ;
 }
 return hmvmask | vmvmask ;
 }


static void setup_frame(int sig, struct target_sigaction *ka, target_sigset_t *set, CPUPPCState *env) { struct target_sigframe *frame; struct target_sigcontext *sc; target_ulong frame_addr, newsp; int err = 0; int signal; frame_addr = get_sigframe(ka, env, sizeof(*frame)); if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 1)) goto sigsegv; sc = &frame->sctx; signal = current_exec_domain_sig(sig); __put_user(ka->_sa_handler, &sc->handler); __put_user(set->sig[0], &sc->oldmask); #if defined(TARGET_PPC64) __put_user(set->sig[0] >> 32, &sc->_unused[3]); #else __put_user(set->sig[1], &sc->_unused[3]); #endif __put_user(h2g(&frame->mctx), &sc->regs); __put_user(sig, &sc->signal); /* Save user regs. */ err |= save_user_regs(env, &frame->mctx, TARGET_NR_sigreturn); /* The kernel checks for the presence of a VDSO here. We don't emulate a vdso, so use a sigreturn system call. */ env->lr = (target_ulong) h2g(frame->mctx.tramp); /* Turn off all fp exceptions. */ env->fpscr = 0; /* Create a stack frame for the caller of the handler. */ newsp = frame_addr - SIGNAL_FRAMESIZE; err |= put_user(env->gpr[1], newsp, target_ulong); if (err) goto sigsegv; /* Set up registers for signal handler. */ env->gpr[1] = newsp; env->gpr[3] = signal; env->gpr[4] = frame_addr + offsetof(struct target_sigframe, sctx); env->nip = (target_ulong) ka->_sa_handler; /* Signal handlers are entered in big-endian mode. */ env->msr &= ~MSR_LE; unlock_user_struct(frame, frame_addr, 1); return; sigsegv: unlock_user_struct(frame, frame_addr, 1); qemu_log("segfaulting from setup_frame\n"); force_sig(TARGET_SIGSEGV); }


SCTP_STATIC void sctp_destroy_sock(struct sock *sk)
{
	struct sctp_endpoint *ep;

	SCTP_DEBUG_PRINTK("sctp_destroy_sock(sk: %p)\n", sk);

	/* Release our hold on the endpoint. */
	ep = sctp_sk(sk)->ep;
	sctp_endpoint_free(ep);
	atomic_dec(&sctp_sockets_allocated);
}


static int sctp_getsockopt_mappedv4(struct sock *sk, int len,
				    char __user *optval, int __user *optlen)
{
	int val;
	struct sctp_sock *sp = sctp_sk(sk);

	if (len < sizeof(int))
		return -EINVAL;

	len = sizeof(int);
	val = sp->v4mapped;
	if (put_user(len, optlen))
		return -EFAULT;
	if (copy_to_user(optval, &val, len))
		return -EFAULT;

	return 0;
}


void get_op_opfamily_properties ( Oid opno , Oid opfamily , bool ordering_op , int * strategy , Oid * lefttype , Oid * righttype ) {
 HeapTuple tp ;
 Form_pg_amop amop_tup ;
 tp = SearchSysCache3 ( AMOPOPID , ObjectIdGetDatum ( opno ) , CharGetDatum ( ordering_op ? AMOP_ORDER : AMOP_SEARCH ) , ObjectIdGetDatum ( opfamily ) ) ;
 if ( ! HeapTupleIsValid ( tp ) ) elog ( ERROR , "operator %u is not a member of opfamily %u" , opno , opfamily ) ;
 amop_tup = ( Form_pg_amop ) GETSTRUCT ( tp ) ;
 * strategy = amop_tup -> amopstrategy ;
 * lefttype = amop_tup -> amoplefttype ;
 * righttype = amop_tup -> amoprighttype ;
 ReleaseSysCache ( tp ) ;
 }


static struct sctp_transport *sctp_addr_id2transport(struct sock *sk,
					      struct sockaddr_storage *addr,
					      sctp_assoc_t id)
{
	struct sctp_association *addr_asoc = NULL, *id_asoc = NULL;
	struct sctp_transport *transport;
	union sctp_addr *laddr = (union sctp_addr *)addr;

	addr_asoc = sctp_endpoint_lookup_assoc(sctp_sk(sk)->ep,
					       laddr,
					       &transport);

	if (!addr_asoc)
		return NULL;

	id_asoc = sctp_id2assoc(sk, id);
	if (id_asoc && (id_asoc != addr_asoc))
		return NULL;

	sctp_get_pf_specific(sk->sk_family)->addr_v4map(sctp_sk(sk),
						(union sctp_addr *)addr);

	return transport;
}


static int sctp_getsockopt_adaptation_layer(struct sock *sk, int len,
				  char __user *optval, int __user *optlen)
{
	struct sctp_setadaptation adaptation;

	if (len < sizeof(struct sctp_setadaptation))
		return -EINVAL;

	len = sizeof(struct sctp_setadaptation);

	adaptation.ssb_adaptation_ind = sctp_sk(sk)->adaptation_ind;

	if (put_user(len, optlen))
		return -EFAULT;
	if (copy_to_user(optval, &adaptation, len))
		return -EFAULT;

	return 0;
}


static void gen_msa_elm_df(CPUMIPSState *env, DisasContext *ctx, uint32_t df, uint32_t n) { #define MASK_MSA_ELM(op) (MASK_MSA_MINOR(op) | (op & (0xf << 22))) uint8_t ws = (ctx->opcode >> 11) & 0x1f; uint8_t wd = (ctx->opcode >> 6) & 0x1f; TCGv_i32 tws = tcg_const_i32(ws); TCGv_i32 twd = tcg_const_i32(wd); TCGv_i32 tn = tcg_const_i32(n); TCGv_i32 tdf = tcg_const_i32(df); switch (MASK_MSA_ELM(ctx->opcode)) { case OPC_SLDI_df: gen_helper_msa_sldi_df(cpu_env, tdf, twd, tws, tn); break; case OPC_SPLATI_df: gen_helper_msa_splati_df(cpu_env, tdf, twd, tws, tn); break; case OPC_INSVE_df: gen_helper_msa_insve_df(cpu_env, tdf, twd, tws, tn); break; case OPC_COPY_S_df: case OPC_COPY_U_df: case OPC_INSERT_df: #if !defined(TARGET_MIPS64) /* Double format valid only for MIPS64 */ if (df == DF_DOUBLE) { generate_exception_end(ctx, EXCP_RI); break; } #endif switch (MASK_MSA_ELM(ctx->opcode)) { case OPC_COPY_S_df: gen_helper_msa_copy_s_df(cpu_env, tdf, twd, tws, tn); break; case OPC_COPY_U_df: gen_helper_msa_copy_u_df(cpu_env, tdf, twd, tws, tn); break; case OPC_INSERT_df: gen_helper_msa_insert_df(cpu_env, tdf, twd, tws, tn); break; } break; default: MIPS_INVAL("MSA instruction"); generate_exception_end(ctx, EXCP_RI); } tcg_temp_free_i32(twd); tcg_temp_free_i32(tws); tcg_temp_free_i32(tn); tcg_temp_free_i32(tdf); }


static uint32_t get_features(VirtIODevice *vdev, uint32_t features) { VirtIOSerial *vser; vser = DO_UPCAST(VirtIOSerial, vdev, vdev); if (vser->bus->max_nr_ports > 1) { features |= (1 << VIRTIO_CONSOLE_F_MULTIPORT); } return features; }


av_cold int ff_vaapi_encode_close(AVCodecContext *avctx) { VAAPIEncodeContext *ctx = avctx->priv_data; VAAPIEncodePicture *pic, *next; for (pic = ctx->pic_start; pic; pic = next) { next = pic->next; vaapi_encode_free(avctx, pic); } if (ctx->va_context != VA_INVALID_ID) vaDestroyContext(ctx->hwctx->display, ctx->va_context); if (ctx->va_config != VA_INVALID_ID) vaDestroyConfig(ctx->hwctx->display, ctx->va_config); if (ctx->codec->close) ctx->codec->close(avctx); av_freep(&ctx->codec_sequence_params); av_freep(&ctx->codec_picture_params); av_buffer_unref(&ctx->recon_frames_ref); av_buffer_unref(&ctx->input_frames_ref); av_buffer_unref(&ctx->device_ref); av_freep(&ctx->priv_data); return 0; }


static int trim_filter_frame(AVFilterLink *inlink, AVFrame *frame) { AVFilterContext *ctx = inlink->dst; TrimContext *s = ctx->priv; int drop; /* drop everything if EOF has already been returned */ if (s->eof) { av_frame_free(&frame); return 0; } if (s->start_frame >= 0 || s->start_pts != AV_NOPTS_VALUE) { drop = 1; if (s->start_frame >= 0 && s->nb_frames >= s->start_frame) drop = 0; if (s->start_pts != AV_NOPTS_VALUE && frame->pts != AV_NOPTS_VALUE && frame->pts >= s->start_pts) drop = 0; if (drop) goto drop; } if (s->first_pts == AV_NOPTS_VALUE && frame->pts != AV_NOPTS_VALUE) s->first_pts = frame->pts; if (s->end_frame != INT64_MAX || s->end_pts != AV_NOPTS_VALUE || s->duration_tb) { drop = 1; if (s->end_frame != INT64_MAX && s->nb_frames < s->end_frame) drop = 0; if (s->end_pts != AV_NOPTS_VALUE && frame->pts != AV_NOPTS_VALUE && frame->pts < s->end_pts) drop = 0; if (s->duration_tb && frame->pts != AV_NOPTS_VALUE && frame->pts - s->first_pts < s->duration_tb) drop = 0; if (drop) { s->eof = 1; goto drop; } } s->nb_frames++; s->got_output = 1; return ff_filter_frame(ctx->outputs[0], frame); drop: s->nb_frames++; av_frame_free(&frame); return 0; }


static void flush_change ( H264Context * h ) {
 int i , j ;
 h -> outputed_poc = h -> next_outputed_poc = INT_MIN ;
 h -> prev_interlaced_frame = 1 ;
 idr ( h ) ;
 h -> prev_frame_num = - 1 ;
 if ( h -> cur_pic_ptr ) {
 h -> cur_pic_ptr -> reference = 0 ;
 for ( j = i = 0 ;
 h -> delayed_pic [ i ] ;
 i ++ ) if ( h -> delayed_pic [ i ] != h -> cur_pic_ptr ) h -> delayed_pic [ j ++ ] = h -> delayed_pic [ i ] ;
 h -> delayed_pic [ j ] = NULL ;
 }
 h -> first_field = 0 ;
 memset ( h -> ref_list [ 0 ] , 0 , sizeof ( h -> ref_list [ 0 ] ) ) ;
 memset ( h -> ref_list [ 1 ] , 0 , sizeof ( h -> ref_list [ 1 ] ) ) ;
 memset ( h -> default_ref_list [ 0 ] , 0 , sizeof ( h -> default_ref_list [ 0 ] ) ) ;
 memset ( h -> default_ref_list [ 1 ] , 0 , sizeof ( h -> default_ref_list [ 1 ] ) ) ;
 ff_h264_reset_sei ( h ) ;
 h -> recovery_frame = - 1 ;
 h -> frame_recovered = 0 ;
 h -> list_count = 0 ;
 h -> current_slice = 0 ;
 h -> mmco_reset = 1 ;
 }


void block_job_completed(BlockJob *job, int ret) { BlockDriverState *bs = job->bs; assert(bs->job == job); job->cb(job->opaque, ret); bs->job = NULL; bdrv_op_unblock_all(bs, job->blocker); error_free(job->blocker); g_free(job); }


static struct sk_buff *sctp_skb_recv_datagram(struct sock *sk, int flags,
					      int noblock, int *err)
{
	int error;
	struct sk_buff *skb;
	long timeo;

	timeo = sock_rcvtimeo(sk, noblock);

	SCTP_DEBUG_PRINTK("Timeout: timeo: %ld, MAX: %ld.\n",
			  timeo, MAX_SCHEDULE_TIMEOUT);

	do {
		/* Again only user level code calls this function,
		 * so nothing interrupt level
		 * will suddenly eat the receive_queue.
		 *
		 *  Look at current nfs client by the way...
		 *  However, this function was corrent in any case. 8)
		 */
		if (flags & MSG_PEEK) {
			spin_lock_bh(&sk->sk_receive_queue.lock);
			skb = skb_peek(&sk->sk_receive_queue);
			if (skb)
				atomic_inc(&skb->users);
			spin_unlock_bh(&sk->sk_receive_queue.lock);
		} else {
			skb = skb_dequeue(&sk->sk_receive_queue);
		}

		if (skb)
			return skb;

		/* Caller is allowed not to check sk->sk_err before calling. */
		error = sock_error(sk);
		if (error)
			goto no_packet;

		if (sk->sk_shutdown & RCV_SHUTDOWN)
			break;

		/* User doesn't want to wait.  */
		error = -EAGAIN;
		if (!timeo)
			goto no_packet;
	} while (sctp_wait_for_packet(sk, err, &timeo) == 0);

	return NULL;

no_packet:
	*err = error;
	return NULL;
}


static target_ulong h_resize_hpt_commit(PowerPCCPU *cpu, sPAPRMachineState *spapr, target_ulong opcode, target_ulong *args) { target_ulong flags = args[0]; target_ulong shift = args[1]; sPAPRPendingHPT *pending = spapr->pending_hpt; int rc; size_t newsize; if (spapr->resize_hpt == SPAPR_RESIZE_HPT_DISABLED) { return H_AUTHORITY; } trace_spapr_h_resize_hpt_commit(flags, shift); rc = kvmppc_resize_hpt_commit(cpu, flags, shift); if (rc != -ENOSYS) { return resize_hpt_convert_rc(rc); } if (flags != 0) { return H_PARAMETER; } if (!pending || (pending->shift != shift)) { /* no matching prepare */ return H_CLOSED; } if (!pending->complete) { /* prepare has not completed */ return H_BUSY; } /* Shouldn't have got past PREPARE without an HPT */ g_assert(spapr->htab_shift); newsize = 1ULL << pending->shift; rc = rehash_hpt(cpu, spapr->htab, HTAB_SIZE(spapr), pending->hpt, newsize); if (rc == H_SUCCESS) { qemu_vfree(spapr->htab); spapr->htab = pending->hpt; spapr->htab_shift = pending->shift; if (kvm_enabled()) { /* For KVM PR, update the HPT pointer */ target_ulong sdr1 = (target_ulong)(uintptr_t)spapr->htab | (spapr->htab_shift - 18); kvmppc_update_sdr1(sdr1); } pending->hpt = NULL; /* so it's not free()d */ } /* Clean up */ spapr->pending_hpt = NULL; free_pending_hpt(pending); return rc; }


static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
				  int __user *optlen)
{
	if (len < sizeof(struct sctp_event_subscribe))
		return -EINVAL;
	len = sizeof(struct sctp_event_subscribe);
	if (put_user(len, optlen))
		return -EFAULT;
	if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
		return -EFAULT;
	return 0;
}


static void U_CALLCONV UConverter_toUnicode_HZ_OFFSETS_LOGIC ( UConverterToUnicodeArgs * args , UErrorCode * err ) {
 char tempBuf [ 2 ] ;
 const char * mySource = ( char * ) args -> source ;
 UChar * myTarget = args -> target ;
 const char * mySourceLimit = args -> sourceLimit ;
 UChar32 targetUniChar = 0x0000 ;
 int32_t mySourceChar = 0x0000 ;
 UConverterDataHZ * myData = ( UConverterDataHZ * ) ( args -> converter -> extraInfo ) ;
 tempBuf [ 0 ] = 0 ;
 tempBuf [ 1 ] = 0 ;
 while ( mySource < mySourceLimit ) {
 if ( myTarget < args -> targetLimit ) {
 mySourceChar = ( unsigned char ) * mySource ++ ;
 if ( args -> converter -> mode == UCNV_TILDE ) {
 args -> converter -> mode = 0 ;
 switch ( mySourceChar ) {
 case 0x0A : continue ;
 case UCNV_TILDE : if ( args -> offsets ) {
 args -> offsets [ myTarget - args -> target ] = ( int32_t ) ( mySource - args -> source - 2 ) ;
 }
 * ( myTarget ++ ) = ( UChar ) mySourceChar ;
 myData -> isEmptySegment = FALSE ;
 continue ;
 case UCNV_OPEN_BRACE : case UCNV_CLOSE_BRACE : myData -> isStateDBCS = ( mySourceChar == UCNV_OPEN_BRACE ) ;
 if ( myData -> isEmptySegment ) {
 myData -> isEmptySegment = FALSE ;
 * err = U_ILLEGAL_ESCAPE_SEQUENCE ;
 args -> converter -> toUCallbackReason = UCNV_IRREGULAR ;
 args -> converter -> toUBytes [ 0 ] = UCNV_TILDE ;
 args -> converter -> toUBytes [ 1 ] = mySourceChar ;
 args -> converter -> toULength = 2 ;
 args -> target = myTarget ;
 args -> source = mySource ;
 return ;
 }
 myData -> isEmptySegment = TRUE ;
 continue ;
 default : myData -> isEmptySegment = FALSE ;
 * err = U_ILLEGAL_ESCAPE_SEQUENCE ;
 args -> converter -> toUBytes [ 0 ] = UCNV_TILDE ;
 if ( myData -> isStateDBCS ? ( 0x21 <= mySourceChar && mySourceChar <= 0x7e ) : mySourceChar <= 0x7f ) {
 args -> converter -> toULength = 1 ;
 -- mySource ;
 }
 else {
 args -> converter -> toUBytes [ 1 ] = mySourceChar ;
 args -> converter -> toULength = 2 ;
 }
 args -> target = myTarget ;
 args -> source = mySource ;
 return ;
 }
 }
 else if ( myData -> isStateDBCS ) {
 if ( args -> converter -> toUnicodeStatus == 0x00 ) {
 if ( mySourceChar == UCNV_TILDE ) {
 args -> converter -> mode = UCNV_TILDE ;
 }
 else {
 args -> converter -> toUnicodeStatus = ( uint32_t ) ( mySourceChar | 0x100 ) ;
 myData -> isEmptySegment = FALSE ;
 }
 continue ;
 }
 else {
 int leadIsOk , trailIsOk ;
 uint32_t leadByte = args -> converter -> toUnicodeStatus & 0xff ;
 targetUniChar = 0xffff ;
 leadIsOk = ( uint8_t ) ( leadByte - 0x21 ) <= ( 0x7d - 0x21 ) ;
 trailIsOk = ( uint8_t ) ( mySourceChar - 0x21 ) <= ( 0x7e - 0x21 ) ;
 if ( leadIsOk && trailIsOk ) {
 tempBuf [ 0 ] = ( char ) ( leadByte + 0x80 ) ;
 tempBuf [ 1 ] = ( char ) ( mySourceChar + 0x80 ) ;
 targetUniChar = ucnv_MBCSSimpleGetNextUChar ( myData -> gbConverter -> sharedData , tempBuf , 2 , args -> converter -> useFallback ) ;
 mySourceChar = ( leadByte << 8 ) | mySourceChar ;
 }
 else if ( trailIsOk ) {
 -- mySource ;
 mySourceChar = ( int32_t ) leadByte ;
 }
 else {
 mySourceChar = 0x10000 | ( leadByte << 8 ) | mySourceChar ;
 }
 args -> converter -> toUnicodeStatus = 0x00 ;
 }
 }
 else {
 if ( mySourceChar == UCNV_TILDE ) {
 args -> converter -> mode = UCNV_TILDE ;
 continue ;
 }
 else if ( mySourceChar <= 0x7f ) {
 targetUniChar = ( UChar ) mySourceChar ;
 myData -> isEmptySegment = FALSE ;
 }
 else {
 targetUniChar = 0xffff ;
 myData -> isEmptySegment = FALSE ;
 }
 }
 if ( targetUniChar < 0xfffe ) {
 if ( args -> offsets ) {
 args -> offsets [ myTarget - args -> target ] = ( int32_t ) ( mySource - args -> source - 1 - ( myData -> isStateDBCS ) ) ;
 }
 * ( myTarget ++ ) = ( UChar ) targetUniChar ;
 }
 else {
 if ( targetUniChar == 0xfffe ) {
 * err = U_INVALID_CHAR_FOUND ;
 }
 else {
 * err = U_ILLEGAL_CHAR_FOUND ;
 }
 if ( mySourceChar > 0xff ) {
 args -> converter -> toUBytes [ 0 ] = ( uint8_t ) ( mySourceChar >> 8 ) ;
 args -> converter -> toUBytes [ 1 ] = ( uint8_t ) mySourceChar ;
 args -> converter -> toULength = 2 ;
 }
 else {
 args -> converter -> toUBytes [ 0 ] = ( uint8_t ) mySourceChar ;
 args -> converter -> toULength = 1 ;
 }
 break ;
 }
 }
 else {
 * err = U_BUFFER_OVERFLOW_ERROR ;
 break ;
 }
 }
 args -> target = myTarget ;
 args -> source = mySource ;
 }


void ff_mpeg_unref_picture(MpegEncContext *s, Picture *pic) { int off = offsetof(Picture, mb_mean) + sizeof(pic->mb_mean); pic->tf.f = &pic->f; /* WM Image / Screen codecs allocate internal buffers with different * dimensions / colorspaces; ignore user-defined callbacks for these. */ if (s->codec_id != AV_CODEC_ID_WMV3IMAGE && s->codec_id != AV_CODEC_ID_VC1IMAGE && s->codec_id != AV_CODEC_ID_MSS2) ff_thread_release_buffer(s->avctx, &pic->tf); else av_frame_unref(&pic->f); av_buffer_unref(&pic->hwaccel_priv_buf); if (pic->needs_realloc) ff_free_picture_tables(pic); memset((uint8_t*)pic + off, 0, sizeof(*pic) - off); }


static int shorten_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt) { AVFrame *frame = data; const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; ShortenContext *s = avctx->priv_data; int i, input_buf_size = 0; int ret; /* allocate internal bitstream buffer */ if (s->max_framesize == 0) { void *tmp_ptr; s->max_framesize = 8192; // should hopefully be enough for the first header tmp_ptr = av_fast_realloc(s->bitstream, &s->allocated_bitstream_size, s->max_framesize + FF_INPUT_BUFFER_PADDING_SIZE); if (!tmp_ptr) { av_log(avctx, AV_LOG_ERROR, "error allocating bitstream buffer\n"); return AVERROR(ENOMEM); } s->bitstream = tmp_ptr; } /* append current packet data to bitstream buffer */ if (1 && s->max_framesize) { //FIXME truncated buf_size = FFMIN(buf_size, s->max_framesize - s->bitstream_size); input_buf_size = buf_size; if (s->bitstream_index + s->bitstream_size + buf_size > s->allocated_bitstream_size) { memmove(s->bitstream, &s->bitstream[s->bitstream_index], s->bitstream_size); s->bitstream_index = 0; } if (buf) memcpy(&s->bitstream[s->bitstream_index + s->bitstream_size], buf, buf_size); buf = &s->bitstream[s->bitstream_index]; buf_size += s->bitstream_size; s->bitstream_size = buf_size; /* do not decode until buffer has at least max_framesize bytes or * the end of the file has been reached */ if (buf_size < s->max_framesize && avpkt->data) { *got_frame_ptr = 0; return input_buf_size; } } /* init and position bitstream reader */ init_get_bits(&s->gb, buf, buf_size * 8); skip_bits(&s->gb, s->bitindex); /* process header or next subblock */ if (!s->got_header) { if ((ret = read_header(s)) < 0) return ret; *got_frame_ptr = 0; goto finish_frame; } /* if quit command was read previously, don't decode anything */ if (s->got_quit_command) { *got_frame_ptr = 0; return avpkt->size; } s->cur_chan = 0; while (s->cur_chan < s->channels) { unsigned cmd; int len; if (get_bits_left(&s->gb) < 3 + FNSIZE) { *got_frame_ptr = 0; break; } cmd = get_ur_golomb_shorten(&s->gb, FNSIZE); if (cmd > FN_VERBATIM) { av_log(avctx, AV_LOG_ERROR, "unknown shorten function %d\n", cmd); *got_frame_ptr = 0; break; } if (!is_audio_command[cmd]) { /* process non-audio command */ switch (cmd) { case FN_VERBATIM: len = get_ur_golomb_shorten(&s->gb, VERBATIM_CKSIZE_SIZE); while (len--) get_ur_golomb_shorten(&s->gb, VERBATIM_BYTE_SIZE); break; case FN_BITSHIFT: s->bitshift = get_ur_golomb_shorten(&s->gb, BITSHIFTSIZE); break; case FN_BLOCKSIZE: { unsigned blocksize = get_uint(s, av_log2(s->blocksize)); if (blocksize > s->blocksize) { av_log(avctx, AV_LOG_ERROR, "Increasing block size is not supported\n"); return AVERROR_PATCHWELCOME; } if (!blocksize || blocksize > MAX_BLOCKSIZE) { av_log(avctx, AV_LOG_ERROR, "invalid or unsupported " "block size: %d\n", blocksize); return AVERROR(EINVAL); } s->blocksize = blocksize; break; } case FN_QUIT: s->got_quit_command = 1; break; } if (cmd == FN_BLOCKSIZE || cmd == FN_QUIT) { *got_frame_ptr = 0; break; } } else { /* process audio command */ int residual_size = 0; int channel = s->cur_chan; int32_t coffset; /* get Rice code for residual decoding */ if (cmd != FN_ZERO) { residual_size = get_ur_golomb_shorten(&s->gb, ENERGYSIZE); /* This is a hack as version 0 differed in the definition * of get_sr_golomb_shorten(). */ if (s->version == 0) residual_size--; } /* calculate sample offset using means from previous blocks */ if (s->nmean == 0) coffset = s->offset[channel][0]; else { int32_t sum = (s->version < 2) ? 0 : s->nmean / 2; for (i = 0; i < s->nmean; i++) sum += s->offset[channel][i]; coffset = sum / s->nmean; if (s->version >= 2) coffset = s->bitshift == 0 ? coffset : coffset >> s->bitshift - 1 >> 1; } /* decode samples for this channel */ if (cmd == FN_ZERO) { for (i = 0; i < s->blocksize; i++) s->decoded[channel][i] = 0; } else { if ((ret = decode_subframe_lpc(s, cmd, channel, residual_size, coffset)) < 0) return ret; } /* update means with info from the current block */ if (s->nmean > 0) { int32_t sum = (s->version < 2) ? 0 : s->blocksize / 2; for (i = 0; i < s->blocksize; i++) sum += s->decoded[channel][i]; for (i = 1; i < s->nmean; i++) s->offset[channel][i - 1] = s->offset[channel][i]; if (s->version < 2) s->offset[channel][s->nmean - 1] = sum / s->blocksize; else s->offset[channel][s->nmean - 1] = (sum / s->blocksize) << s->bitshift; } /* copy wrap samples for use with next block */ for (i = -s->nwrap; i < 0; i++) s->decoded[channel][i] = s->decoded[channel][i + s->blocksize]; /* shift samples to add in unused zero bits which were removed * during encoding */ fix_bitshift(s, s->decoded[channel]); /* if this is the last channel in the block, output the samples */ s->cur_chan++; if (s->cur_chan == s->channels) { uint8_t *samples_u8; int16_t *samples_s16; int chan; /* get output buffer */ frame->nb_samples = s->blocksize; if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) return ret; for (chan = 0; chan < s->channels; chan++) { samples_u8 = ((uint8_t **)frame->extended_data)[chan]; samples_s16 = ((int16_t **)frame->extended_data)[chan]; for (i = 0; i < s->blocksize; i++) { switch (s->internal_ftype) { case TYPE_U8: *samples_u8++ = av_clip_uint8(s->decoded[chan][i]); break; case TYPE_S16HL: case TYPE_S16LH: *samples_s16++ = av_clip_int16(s->decoded[chan][i]); break; } } } *got_frame_ptr = 1; } } } if (s->cur_chan < s->channels) *got_frame_ptr = 0; finish_frame: s->bitindex = get_bits_count(&s->gb) - 8 * (get_bits_count(&s->gb) / 8); i = get_bits_count(&s->gb) / 8; if (i > buf_size) { av_log(s->avctx, AV_LOG_ERROR, "overread: %d\n", i - buf_size); s->bitstream_size = 0; s->bitstream_index = 0; return AVERROR_INVALIDDATA; } if (s->bitstream_size) { s->bitstream_index += i; s->bitstream_size -= i; return input_buf_size; } else return i; }


static int sctp_wait_for_accept(struct sock *sk, long timeo)
{
	struct sctp_endpoint *ep;
	int err = 0;
	DEFINE_WAIT(wait);

	ep = sctp_sk(sk)->ep;

	for (;;) {
		prepare_to_wait_exclusive(sk->sk_sleep, &wait,
					  TASK_INTERRUPTIBLE);

		if (list_empty(&ep->asocs)) {
			sctp_release_sock(sk);
			timeo = schedule_timeout(timeo);
			sctp_lock_sock(sk);
		}

		err = -EINVAL;
		if (!sctp_sstate(sk, LISTENING))
			break;

		err = 0;
		if (!list_empty(&ep->asocs))
			break;

		err = sock_intr_errno(timeo);
		if (signal_pending(current))
			break;

		err = -EAGAIN;
		if (!timeo)
			break;
	}

	finish_wait(sk->sk_sleep, &wait);

	return err;
}


void do_store_601_batu (int nr) { do_store_ibatu(env, nr, T0); env->DBAT[0][nr] = env->IBAT[0][nr]; env->DBAT[1][nr] = env->IBAT[1][nr]; }


TEST_F ( ProtocolHandlerRegistryTest , TestRemovingDefaultDoesntChangeHandlers ) {
 ProtocolHandler ph1 = CreateProtocolHandler ( "mailto" , "test1" ) ;
 ProtocolHandler ph2 = CreateProtocolHandler ( "mailto" , "test2" ) ;
 ProtocolHandler ph3 = CreateProtocolHandler ( "mailto" , "test3" ) ;
 registry ( ) -> OnAcceptRegisterProtocolHandler ( ph1 ) ;
 registry ( ) -> OnAcceptRegisterProtocolHandler ( ph2 ) ;
 registry ( ) -> OnAcceptRegisterProtocolHandler ( ph3 ) ;
 registry ( ) -> RemoveHandler ( ph3 ) ;
 ProtocolHandlerRegistry : : ProtocolHandlerList handlers = registry ( ) -> GetHandlersFor ( "mailto" ) ;
 ASSERT_EQ ( static_cast < size_t > ( 2 ) , handlers . size ( ) ) ;
 ASSERT_EQ ( ph2 , handlers [ 0 ] ) ;
 ASSERT_EQ ( ph1 , handlers [ 1 ] ) ;
 }


void virLogMessage ( virLogSourcePtr source , virLogPriority priority , const char * filename , int linenr , const char * funcname , virLogMetadataPtr metadata , const char * fmt , ... ) {
 va_list ap ;
 va_start ( ap , fmt ) ;
 virLogVMessage ( source , priority , filename , linenr , funcname , metadata , fmt , ap ) ;
 va_end ( ap ) ;
 }


static int dissect_nlm4_test_res ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * tree , void * data ) {
 return dissect_nlm_test_res ( tvb , 0 , pinfo , tree , 4 , ( rpc_call_info_value * ) data ) ;
 }


static void selinux_task_to_inode ( struct task_struct * p , struct inode * inode ) {
 struct inode_security_struct * isec = inode -> i_security ;
 u32 sid = task_sid ( p ) ;
 spin_lock ( & isec -> lock ) ;
 isec -> sclass = inode_mode_to_security_class ( inode -> i_mode ) ;
 isec -> sid = sid ;
 isec -> initialized = LABEL_INITIALIZED ;
 spin_unlock ( & isec -> lock ) ;
 }


static int sctp_getsockopt_associnfo(struct sock *sk, int len,
				     char __user *optval,
				     int __user *optlen)
{

	struct sctp_assocparams assocparams;
	struct sctp_association *asoc;
	struct list_head *pos;
	int cnt = 0;

	if (len < sizeof (struct sctp_assocparams))
		return -EINVAL;

	len = sizeof(struct sctp_assocparams);

	if (copy_from_user(&assocparams, optval, len))
		return -EFAULT;

	asoc = sctp_id2assoc(sk, assocparams.sasoc_assoc_id);

	if (!asoc && assocparams.sasoc_assoc_id && sctp_style(sk, UDP))
		return -EINVAL;

	/* Values correspoinding to the specific association */
	if (asoc) {
		assocparams.sasoc_asocmaxrxt = asoc->max_retrans;
		assocparams.sasoc_peer_rwnd = asoc->peer.rwnd;
		assocparams.sasoc_local_rwnd = asoc->a_rwnd;
		assocparams.sasoc_cookie_life = (asoc->cookie_life.tv_sec
						* 1000) +
						(asoc->cookie_life.tv_usec
						/ 1000);

		list_for_each(pos, &asoc->peer.transport_addr_list) {
			cnt ++;
		}

		assocparams.sasoc_number_peer_destinations = cnt;
	} else {
		/* Values corresponding to the endpoint */
		struct sctp_sock *sp = sctp_sk(sk);

		assocparams.sasoc_asocmaxrxt = sp->assocparams.sasoc_asocmaxrxt;
		assocparams.sasoc_peer_rwnd = sp->assocparams.sasoc_peer_rwnd;
		assocparams.sasoc_local_rwnd = sp->assocparams.sasoc_local_rwnd;
		assocparams.sasoc_cookie_life =
					sp->assocparams.sasoc_cookie_life;
		assocparams.sasoc_number_peer_destinations =
					sp->assocparams.
					sasoc_number_peer_destinations;
	}

	if (put_user(len, optlen))
		return -EFAULT;

	if (copy_to_user(optval, &assocparams, len))
		return -EFAULT;

	return 0;
}


static uint64_t imx_timerp_read(void *opaque, target_phys_addr_t offset, unsigned size) { IMXTimerPState *s = (IMXTimerPState *)opaque; DPRINTF("p-read(offset=%x)", offset >> 2); switch (offset >> 2) { case 0: /* Control Register */ DPRINTF("cr %x\n", s->cr); return s->cr; case 1: /* Status Register */ DPRINTF("int_level %x\n", s->int_level); return s->int_level; case 2: /* LR - ticks*/ DPRINTF("lr %x\n", s->lr); return s->lr; case 3: /* CMP */ DPRINTF("cmp %x\n", s->cmp); return s->cmp; case 4: /* CNT */ return ptimer_get_count(s->timer); } IPRINTF("imx_timerp_read: Bad offset %x\n", (int)offset >> 2); return 0; }


static int dissect_h245_Scope ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {
 offset = dissect_per_choice ( tvb , offset , actx , tree , hf_index , ett_h245_Scope , Scope_choice , NULL ) ;
 return offset ;
 }


static int sctp_auth_compare_vectors(struct sctp_auth_bytes *vector1,
			      struct sctp_auth_bytes *vector2)
{
	int diff;
	int i;
	const __u8 *longer;

	diff = vector1->len - vector2->len;
	if (diff) {
		longer = (diff > 0) ? vector1->data : vector2->data;

		/* Check to see if the longer number is
		 * lead-zero padded.  If it is not, it
		 * is automatically larger numerically.
		 */
		for (i = 0; i < abs(diff); i++ ) {
			if (longer[i] != 0)
				return diff;
		}
	}

	/* lengths are the same, compare numbers */
	return memcmp(vector1->data, vector2->data, vector1->len);
}


static ssize_t vnc_tls_pull(gnutls_transport_ptr_t transport, void *data, size_t len) { VncState *vs = (VncState *)transport; int ret; retry: ret = qemu_recv(vs->csock, data, len, 0); if (ret < 0) { if (errno == EINTR) goto retry; return -1; } return ret; }


int sctp_auth_recv_cid(sctp_cid_t chunk, const struct sctp_association *asoc)
{
	if (!sctp_auth_enable || !asoc)
		return 0;

	return __sctp_auth_cid(chunk,
			      (struct sctp_chunks_param *)asoc->c.auth_chunks);
}


static const main_extcomp * main_get_compressor ( const char * ident ) {
 const main_extcomp * ext = main_ident_compressor ( ident ) ;
 if ( ext == NULL ) {
 if ( ! option_quiet ) {
 XPR ( NT "warning: cannot recompress output: " "unrecognized external compression ID: %s\n" , ident ) ;
 }
 return NULL ;
 }
 else if ( ! EXTERNAL_COMPRESSION ) {
 if ( ! option_quiet ) {
 XPR ( NT "warning: external support not compiled: " "original input was compressed: %s\n" , ext -> recomp_cmdname ) ;
 }
 return NULL ;
 }
 else {
 return ext ;
 }
 }


iscsi_co_generic_cb(struct iscsi_context *iscsi, int status, void *command_data, void *opaque) { struct IscsiTask *iTask = opaque; struct scsi_task *task = command_data; iTask->status = status; iTask->do_retry = 0; iTask->task = task; if (status != SCSI_STATUS_GOOD) { if (iTask->retries++ < ISCSI_CMD_RETRIES) { if (status == SCSI_STATUS_CHECK_CONDITION && task->sense.key == SCSI_SENSE_UNIT_ATTENTION) { error_report("iSCSI CheckCondition: %s", iscsi_get_error(iscsi)); iTask->do_retry = 1; goto out; } /* status 0x28 is SCSI_TASK_SET_FULL. It was first introduced * in libiscsi 1.10.0. Hardcode this value here to avoid * the need to bump the libiscsi requirement to 1.10.0 */ if (status == SCSI_STATUS_BUSY || status == 0x28) { unsigned retry_time = exp_random(iscsi_retry_times[iTask->retries - 1]); error_report("iSCSI Busy/TaskSetFull (retry #%u in %u ms): %s", iTask->retries, retry_time, iscsi_get_error(iscsi)); aio_timer_init(iTask->iscsilun->aio_context, &iTask->retry_timer, QEMU_CLOCK_REALTIME, SCALE_MS, iscsi_retry_timer_expired, iTask); timer_mod(&iTask->retry_timer, qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + retry_time); iTask->do_retry = 1; return; } } error_report("iSCSI Failure: %s", iscsi_get_error(iscsi)); } else { iTask->iscsilun->force_next_flush |= iTask->force_next_flush; } out: if (iTask->co) { iTask->bh = aio_bh_new(iTask->iscsilun->aio_context, iscsi_co_generic_bh_cb, iTask); qemu_bh_schedule(iTask->bh); } else { iTask->complete = 1; } }


static struct sctp_auth_bytes *sctp_auth_asoc_create_secret(
				 const struct sctp_association *asoc,
				 struct sctp_shared_key *ep_key,
				 gfp_t gfp)
{
	struct sctp_auth_bytes *local_key_vector;
	struct sctp_auth_bytes *peer_key_vector;
	struct sctp_auth_bytes	*first_vector,
				*last_vector;
	struct sctp_auth_bytes	*secret = NULL;
	int	cmp;

	/* Now we need to build the key vectors
	 * SCTP-AUTH , Section 6.1
	 *    The RANDOM parameter, the CHUNKS parameter and the HMAC-ALGO
	 *    parameter sent by each endpoint are concatenated as byte vectors.
	 *    These parameters include the parameter type, parameter length, and
	 *    the parameter value, but padding is omitted; all padding MUST be
	 *    removed from this concatenation before proceeding with further
	 *    computation of keys.  Parameters which were not sent are simply
	 *    omitted from the concatenation process.  The resulting two vectors
	 *    are called the two key vectors.
	 */

	local_key_vector = sctp_auth_make_local_vector(asoc, gfp);
	peer_key_vector = sctp_auth_make_peer_vector(asoc, gfp);

	if (!peer_key_vector || !local_key_vector)
		goto out;

	/* Figure out the order in wich the key_vectors will be
	 * added to the endpoint shared key.
	 * SCTP-AUTH, Section 6.1:
	 *   This is performed by selecting the numerically smaller key
	 *   vector and concatenating it to the endpoint pair shared
	 *   key, and then concatenating the numerically larger key
	 *   vector to that.  If the key vectors are equal as numbers
	 *   but differ in length, then the concatenation order is the
	 *   endpoint shared key, followed by the shorter key vector,
	 *   followed by the longer key vector.  Otherwise, the key
	 *   vectors are identical, and may be concatenated to the
	 *   endpoint pair key in any order.
	 */
	cmp = sctp_auth_compare_vectors(local_key_vector,
					peer_key_vector);
	if (cmp < 0) {
		first_vector = local_key_vector;
		last_vector = peer_key_vector;
	} else {
		first_vector = peer_key_vector;
		last_vector = local_key_vector;
	}

	secret = sctp_auth_asoc_set_secret(ep_key, first_vector, last_vector,
					    gfp);
out:
	kfree(local_key_vector);
	kfree(peer_key_vector);

	return secret;
}


int ff_vdpau_common_init(AVCodecContext *avctx, VdpDecoderProfile profile, int level) { VDPAUHWContext *hwctx = avctx->hwaccel_context; VDPAUContext *vdctx = avctx->internal->hwaccel_priv_data; VdpVideoSurfaceQueryCapabilities *surface_query_caps; VdpDecoderQueryCapabilities *decoder_query_caps; VdpDecoderCreate *create; void *func; VdpStatus status; VdpBool supported; uint32_t max_level, max_mb, max_width, max_height; VdpChromaType type; uint32_t width; uint32_t height; vdctx->width = UINT32_MAX; vdctx->height = UINT32_MAX; if (av_vdpau_get_surface_parameters(avctx, &type, &width, &height)) return AVERROR(ENOSYS); if (hwctx) { hwctx->reset = 0; if (hwctx->context.decoder != VDP_INVALID_HANDLE) { vdctx->decoder = hwctx->context.decoder; vdctx->render = hwctx->context.render; vdctx->device = VDP_INVALID_HANDLE; return 0; /* Decoder created by user */ } vdctx->device = hwctx->device; vdctx->get_proc_address = hwctx->get_proc_address; if (hwctx->flags & AV_HWACCEL_FLAG_IGNORE_LEVEL) level = 0; if (!(hwctx->flags & AV_HWACCEL_FLAG_ALLOW_HIGH_DEPTH) && type != VDP_CHROMA_TYPE_420) return AVERROR(ENOSYS); } else { AVHWFramesContext *frames_ctx = NULL; AVVDPAUDeviceContext *dev_ctx; // We assume the hw_frames_ctx always survives until ff_vdpau_common_uninit // is called. This holds true as the user is not allowed to touch // hw_device_ctx, or hw_frames_ctx after get_format (and ff_get_format // itself also uninits before unreffing hw_frames_ctx). if (avctx->hw_frames_ctx) { frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data; } else if (avctx->hw_device_ctx) { int ret; avctx->hw_frames_ctx = av_hwframe_ctx_alloc(avctx->hw_device_ctx); if (!avctx->hw_frames_ctx) return AVERROR(ENOMEM); frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data; frames_ctx->format = AV_PIX_FMT_VDPAU; frames_ctx->sw_format = avctx->sw_pix_fmt; frames_ctx->width = avctx->coded_width; frames_ctx->height = avctx->coded_height; ret = av_hwframe_ctx_init(avctx->hw_frames_ctx); if (ret < 0) { av_buffer_unref(&avctx->hw_frames_ctx); return ret; } } if (!frames_ctx) { av_log(avctx, AV_LOG_ERROR, "A hardware frames context is " "required for VDPAU decoding.\n"); return AVERROR(EINVAL); } dev_ctx = frames_ctx->device_ctx->hwctx; vdctx->device = dev_ctx->device; vdctx->get_proc_address = dev_ctx->get_proc_address; if (avctx->hwaccel_flags & AV_HWACCEL_FLAG_IGNORE_LEVEL) level = 0; } if (level < 0) return AVERROR(ENOTSUP); status = vdctx->get_proc_address(vdctx->device, VDP_FUNC_ID_GET_INFORMATION_STRING, &func); if (status != VDP_STATUS_OK) return vdpau_error(status); else info = func; status = info(&info_string); if (status != VDP_STATUS_OK) return vdpau_error(status); if (avctx->codec_id == AV_CODEC_ID_HEVC && strncmp(info_string, "NVIDIA ", 7) == 0 && !(avctx->hwaccel_flags & AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH)) { av_log(avctx, AV_LOG_VERBOSE, "HEVC with NVIDIA VDPAU drivers is buggy, skipping.\n"); return AVERROR(ENOTSUP); } status = vdctx->get_proc_address(vdctx->device, VDP_FUNC_ID_VIDEO_SURFACE_QUERY_CAPABILITIES, &func); if (status != VDP_STATUS_OK) return vdpau_error(status); else surface_query_caps = func; status = surface_query_caps(vdctx->device, type, &supported, &max_width, &max_height); if (status != VDP_STATUS_OK) return vdpau_error(status); if (supported != VDP_TRUE || max_width < width || max_height < height) return AVERROR(ENOTSUP); status = vdctx->get_proc_address(vdctx->device, VDP_FUNC_ID_DECODER_QUERY_CAPABILITIES, &func); if (status != VDP_STATUS_OK) return vdpau_error(status); else decoder_query_caps = func; status = decoder_query_caps(vdctx->device, profile, &supported, &max_level, &max_mb, &max_width, &max_height); #ifdef VDP_DECODER_PROFILE_H264_CONSTRAINED_BASELINE if ((status != VDP_STATUS_OK || supported != VDP_TRUE) && profile == VDP_DECODER_PROFILE_H264_CONSTRAINED_BASELINE) { profile = VDP_DECODER_PROFILE_H264_MAIN; status = decoder_query_caps(vdctx->device, profile, &supported, &max_level, &max_mb, &max_width, &max_height); } #endif if (status != VDP_STATUS_OK) return vdpau_error(status); if (supported != VDP_TRUE || max_level < level || max_width < width || max_height < height) return AVERROR(ENOTSUP); status = vdctx->get_proc_address(vdctx->device, VDP_FUNC_ID_DECODER_CREATE, &func); if (status != VDP_STATUS_OK) return vdpau_error(status); else create = func; status = vdctx->get_proc_address(vdctx->device, VDP_FUNC_ID_DECODER_RENDER, &func); if (status != VDP_STATUS_OK) return vdpau_error(status); else vdctx->render = func; status = create(vdctx->device, profile, width, height, avctx->refs, &vdctx->decoder); if (status == VDP_STATUS_OK) { vdctx->width = avctx->coded_width; vdctx->height = avctx->coded_height; } return vdpau_error(status); }


static inline int hpel_motion(MpegEncContext *s, uint8_t *dest, uint8_t *src, int src_x, int src_y, op_pixels_func *pix_op, int motion_x, int motion_y) { int dxy = 0; int emu = 0; src_x += motion_x >> 1; src_y += motion_y >> 1; /* WARNING: do no forget half pels */ src_x = av_clip(src_x, -16, s->width); // FIXME unneeded for emu? if (src_x != s->width) dxy |= motion_x & 1; src_y = av_clip(src_y, -16, s->height); if (src_y != s->height) dxy |= (motion_y & 1) << 1; src += src_y * s->linesize + src_x; if ((unsigned)src_x > FFMAX(s->h_edge_pos - (motion_x & 1) - 8, 0) || (unsigned)src_y > FFMAX(s->v_edge_pos - (motion_y & 1) - 8, 0)) { s->vdsp.emulated_edge_mc(s->edge_emu_buffer, src, s->linesize, s->linesize, 9, 9, src_x, src_y, s->h_edge_pos, s->v_edge_pos); src = s->edge_emu_buffer; emu = 1; } pix_op[dxy](dest, src, s->linesize, 8); return emu; }


static int libopenjpeg_copy_unpacked16(AVCodecContext *avctx, const AVFrame *frame, opj_image_t *image) { int compno; int x; int y; int width; int height; int *image_line; int frame_index; const int numcomps = image->numcomps; uint16_t *frame_ptr; for (compno = 0; compno < numcomps; ++compno) { if (image->comps[compno].w > frame->linesize[compno]) { av_log(avctx, AV_LOG_ERROR, "Error: frame's linesize is too small for the image\n"); return 0; } } for (compno = 0; compno < numcomps; ++compno) { width = avctx->width / image->comps[compno].dx; height = avctx->height / image->comps[compno].dy; frame_ptr = (uint16_t *)frame->data[compno]; for (y = 0; y < height; ++y) { image_line = image->comps[compno].data + y * image->comps[compno].w; frame_index = y * (frame->linesize[compno] / 2); for (x = 0; x < width; ++x) image_line[x] = frame_ptr[frame_index++]; for (; x < image->comps[compno].w; ++x) { image_line[x] = image_line[x - 1]; } } for (; y < image->comps[compno].h; ++y) { image_line = image->comps[compno].data + y * image->comps[compno].w; for (x = 0; x < image->comps[compno].w; ++x) { image_line[x] = image_line[x - image->comps[compno].w]; } } } return 1; }


card_start( struct net_device  *dev )
{
	struct net_local  *nl = (struct net_local *) dev->priv;

	nl->timer_ticks = CHANGE_LEVEL_START_TICKS;
	nl->state &= ~(FL_WAIT_ACK | FL_NEED_RESEND);
	nl->state |= FL_PREV_OK;

	nl->inppos = nl->outpos = 0;
	nl->wait_frameno = 0;
	nl->tx_frameno	 = 0;
	nl->framelen	 = 0;

	outb( *(u_char *)&nl->csr1 | PR_RES, dev->base_addr + CSR1 );
	outb( EN_INT, dev->base_addr + CSR0 );
}


timeout_change_level( struct net_device  *dev )
{
	struct net_local  *nl = (struct net_local *) dev->priv;

	nl->cur_rxl_index = timeout_rxl_tab[ nl->timeout_rxl ];
	if( ++nl->timeout_rxl >= 4 )
		nl->timeout_rxl = 0;

	nl->csr1.rxl = rxl_tab[ nl->cur_rxl_index ];
	inb( dev->base_addr + CSR0 );
	outb( *(unsigned char *)&nl->csr1, dev->base_addr + CSR1 );

	nl->prev_rxl_rcvd = nl->cur_rxl_rcvd;
	nl->cur_rxl_rcvd  = 0;
}


static int slice_end ( AVCodecContext * avctx , AVFrame * pict ) {
 Mpeg1Context * s1 = avctx -> priv_data ;
 MpegEncContext * s = & s1 -> mpeg_enc_ctx ;
 if ( ! s1 -> mpeg_enc_ctx_allocated || ! s -> current_picture_ptr ) return 0 ;
 if ( s -> avctx -> hwaccel ) {
 if ( s -> avctx -> hwaccel -> end_frame ( s -> avctx ) < 0 ) av_log ( avctx , AV_LOG_ERROR , "hardware accelerator failed to decode picture\n" ) ;
 }
 if ( CONFIG_MPEG_XVMC_DECODER && s -> avctx -> xvmc_acceleration ) ff_xvmc_field_end ( s ) ;
 if ( ! s -> first_field ) {
 ff_er_frame_end ( & s -> er ) ;
 ff_MPV_frame_end ( s ) ;
 if ( s -> pict_type == AV_PICTURE_TYPE_B || s -> low_delay ) {
 int ret = av_frame_ref ( pict , & s -> current_picture_ptr -> f ) ;
 if ( ret < 0 ) return ret ;
 ff_print_debug_info ( s , s -> current_picture_ptr ) ;
 }
 else {
 if ( avctx -> active_thread_type & FF_THREAD_FRAME ) s -> picture_number ++ ;
 if ( s -> last_picture_ptr != NULL ) {
 int ret = av_frame_ref ( pict , & s -> last_picture_ptr -> f ) ;
 if ( ret < 0 ) return ret ;
 ff_print_debug_info ( s , s -> last_picture_ptr ) ;
 }
 }
 return 1 ;
 }
 else {
 return 0 ;
 }
 }


static void superio_ioport_writeb(void *opaque, uint32_t addr, uint32_t data) { int can_write; SuperIOConfig *superio_conf = opaque; DPRINTF("superio_ioport_writeb address 0x%x val 0x%x \n", addr, data); if (addr == 0x3f0) { superio_conf->index = data & 0xff; } else { /* 0x3f1 */ switch (superio_conf->index) { case 0x00 ... 0xdf: case 0xe4: case 0xe5: case 0xe9 ... 0xed: case 0xf3: case 0xf5: case 0xf7: case 0xf9 ... 0xfb: case 0xfd ... 0xff: can_write = 0; break; default: can_write = 1; if (can_write) { switch (superio_conf->index) { case 0xe7: if ((data & 0xff) != 0xfe) { DPRINTF("chage uart 1 base. unsupported yet \n"); } break; case 0xe8: if ((data & 0xff) != 0xbe) { DPRINTF("chage uart 2 base. unsupported yet \n"); } break; default: superio_conf->config[superio_conf->index] = data & 0xff; } } } superio_conf->config[superio_conf->index] = data & 0xff; } }


int nbd_client_session_co_discard(NbdClientSession *client, int64_t sector_num, int nb_sectors) { struct nbd_request request = { .type = NBD_CMD_TRIM }; struct nbd_reply reply; ssize_t ret; if (!(client->nbdflags & NBD_FLAG_SEND_TRIM)) { return 0; } request.from = sector_num * 512; request.len = nb_sectors * 512; nbd_coroutine_start(client, &request); ret = nbd_co_send_request(client, &request, NULL, 0); if (ret < 0) { reply.error = -ret; } else { nbd_co_receive_reply(client, &request, &reply, NULL, 0); } nbd_coroutine_end(client, &request); return -reply.error; }


drop_xmit_queue( struct net_device  *dev )
{
	struct net_local  *nl = (struct net_local *) dev->priv;

	if( nl->tx_buf_p )
		dev_kfree_skb_any( nl->tx_buf_p ),
		nl->tx_buf_p = NULL,
#ifdef CONFIG_SBNI_MULTILINE
		((struct net_local *) nl->master->priv)
			->stats.tx_errors++,
		((struct net_local *) nl->master->priv)
			->stats.tx_carrier_errors++;
#else
		nl->stats.tx_errors++,
		nl->stats.tx_carrier_errors++;
#endif

	nl->tx_frameno	= 0;
	nl->framelen	= 0;
	nl->outpos	= 0;
	nl->state &= ~(FL_WAIT_ACK | FL_NEED_RESEND);
#ifdef CONFIG_SBNI_MULTILINE
	netif_start_queue( nl->master );
	nl->master->trans_start = jiffies;
#else
	netif_start_queue( dev );
	dev->trans_start = jiffies;
#endif
}


uint64_t blk_mig_bytes_remaining(void) { return blk_mig_bytes_total() - blk_mig_bytes_transferred(); }