static int mov_text_decode_frame(AVCodecContext *avctx, void *data, int *got_sub_ptr, AVPacket *avpkt) { AVSubtitle *sub = data; MovTextContext *m = avctx->priv_data; int ret; AVBPrint buf; char *ptr = avpkt->data; char *end; int text_length, tsmb_type, ret_tsmb; uint64_t tsmb_size; const uint8_t *tsmb; if (!ptr || avpkt->size < 2) return AVERROR_INVALIDDATA; /* * A packet of size two with value zero is an empty subtitle * used to mark the end of the previous non-empty subtitle. * We can just drop them here as we have duration information * already. If the value is non-zero, then it's technically a * bad packet. */ if (avpkt->size == 2) return AV_RB16(ptr) == 0 ? 0 : AVERROR_INVALIDDATA; /* * The first two bytes of the packet are the length of the text string * In complex cases, there are style descriptors appended to the string * so we can't just assume the packet size is the string size. */ text_length = AV_RB16(ptr); end = ptr + FFMIN(2 + text_length, avpkt->size); ptr += 2; tsmb_size = 0; m->tracksize = 2 + text_length; m->style_entries = 0; m->box_flags = 0; m->count_s = 0; // Note that the spec recommends lines be no longer than 2048 characters. av_bprint_init(&buf, 0, AV_BPRINT_SIZE_UNLIMITED); if (text_length + 2 != avpkt->size) { while (m->tracksize + 8 <= avpkt->size) { // A box is a minimum of 8 bytes. tsmb = ptr + m->tracksize - 2; tsmb_size = AV_RB32(tsmb); tsmb += 4; tsmb_type = AV_RB32(tsmb); tsmb += 4; if (tsmb_size == 1) { if (m->tracksize + 16 > avpkt->size) break; tsmb_size = AV_RB64(tsmb); tsmb += 8; m->size_var = 16; } else m->size_var = 8; //size_var is equal to 8 or 16 depending on the size of box if (tsmb_size == 0) { av_log(avctx, AV_LOG_ERROR, "tsmb_size is 0\n"); return AVERROR_INVALIDDATA; } if (tsmb_size > avpkt->size - m->tracksize) break; for (size_t i = 0; i < box_count; i++) { if (tsmb_type == box_types[i].type) { if (m->tracksize + m->size_var + box_types[i].base_size > avpkt->size) break; ret_tsmb = box_types[i].decode(tsmb, m, avpkt); if (ret_tsmb == -1) break; } } m->tracksize = m->tracksize + tsmb_size; } text_to_ass(&buf, ptr, end, m); } else text_to_ass(&buf, ptr, end, m); ret = ff_ass_add_rect(sub, buf.str, m->readorder++, 0, NULL, NULL); av_bprint_finalize(&buf, NULL); if (ret < 0) return ret; *got_sub_ptr = sub->num_rects > 0; return avpkt->size; }


static void iscsi_timed_set_events(void *opaque) { IscsiLun *iscsilun = opaque; iscsi_set_events(iscsilun); }


static int try_seek_hole(BlockDriverState *bs, off_t start, off_t *data, off_t *hole) { #if defined SEEK_HOLE && defined SEEK_DATA BDRVRawState *s = bs->opaque; *hole = lseek(s->fd, start, SEEK_HOLE); if (*hole == -1) { return -errno; } if (*hole > start) { *data = start; } else { /* On a hole. We need another syscall to find its end. */ *data = lseek(s->fd, start, SEEK_DATA); if (*data == -1) { *data = lseek(s->fd, 0, SEEK_END); } } return 0; #else return -ENOTSUP; #endif }


static inline bool regime_is_secure(CPUARMState *env, ARMMMUIdx mmu_idx) { switch (mmu_idx) { case ARMMMUIdx_S12NSE0: case ARMMMUIdx_S12NSE1: case ARMMMUIdx_S1NSE0: case ARMMMUIdx_S1NSE1: case ARMMMUIdx_S1E2: case ARMMMUIdx_S2NS: return false; case ARMMMUIdx_S1E3: case ARMMMUIdx_S1SE0: case ARMMMUIdx_S1SE1: return true; default: g_assert_not_reached(); } }


static enum fetch_step vbf_stp_error ( struct worker * wrk , struct busyobj * bo ) {
 ssize_t l , ll , o ;
 double now ;
 uint8_t * ptr ;
 struct vsb * synth_body ;
 CHECK_OBJ_NOTNULL ( wrk , WORKER_MAGIC ) ;
 CHECK_OBJ_NOTNULL ( bo , BUSYOBJ_MAGIC ) ;
 CHECK_OBJ_NOTNULL ( bo -> fetch_objcore , OBJCORE_MAGIC ) ;
 AN ( bo -> fetch_objcore -> flags & OC_F_BUSY ) ;
 assert ( bo -> director_state == DIR_S_NULL ) ;
 wrk -> stats -> fetch_failed ++ ;
 now = W_TIM_real ( wrk ) ;
 VSLb_ts_busyobj ( bo , "Error" , now ) ;
 if ( bo -> fetch_objcore -> stobj -> stevedore != NULL ) ObjFreeObj ( bo -> wrk , bo -> fetch_objcore ) ;
 HTTP_Setup ( bo -> beresp , bo -> ws , bo -> vsl , SLT_BerespMethod ) ;
 http_PutResponse ( bo -> beresp , "HTTP/1.1" , 503 , "Backend fetch failed" ) ;
 http_TimeHeader ( bo -> beresp , "Date: " , now ) ;
 http_SetHeader ( bo -> beresp , "Server: Varnish" ) ;
 bo -> fetch_objcore -> t_origin = now ;
 if ( ! VTAILQ_EMPTY ( & bo -> fetch_objcore -> objhead -> waitinglist ) ) {
 bo -> fetch_objcore -> ttl = 1 ;
 bo -> fetch_objcore -> grace = 5 ;
 bo -> fetch_objcore -> keep = 5 ;
 }
 else {
 bo -> fetch_objcore -> ttl = 0 ;
 bo -> fetch_objcore -> grace = 0 ;
 bo -> fetch_objcore -> keep = 0 ;
 }
 synth_body = VSB_new_auto ( ) ;
 AN ( synth_body ) ;
 VCL_backend_error_method ( bo -> vcl , wrk , NULL , bo , synth_body ) ;
 AZ ( VSB_finish ( synth_body ) ) ;
 if ( wrk -> handling == VCL_RET_ABANDON || wrk -> handling == VCL_RET_FAIL ) {
 VSB_destroy ( & synth_body ) ;
 return ( F_STP_FAIL ) ;
 }
 if ( wrk -> handling == VCL_RET_RETRY ) {
 VSB_destroy ( & synth_body ) ;
 if ( bo -> retries ++ < cache_param -> max_retries ) return ( F_STP_RETRY ) ;
 VSLb ( bo -> vsl , SLT_VCL_Error , "Too many retries, failing" ) ;
 return ( F_STP_FAIL ) ;
 }
 assert ( wrk -> handling == VCL_RET_DELIVER ) ;
 bo -> vfc -> bo = bo ;
 bo -> vfc -> wrk = bo -> wrk ;
 bo -> vfc -> oc = bo -> fetch_objcore ;
 bo -> vfc -> http = bo -> beresp ;
 bo -> vfc -> esi_req = bo -> bereq ;
 if ( vbf_beresp2obj ( bo ) ) {
 ( void ) VFP_Error ( bo -> vfc , "Could not get storage" ) ;
 VSB_destroy ( & synth_body ) ;
 return ( F_STP_FAIL ) ;
 }
 ll = VSB_len ( synth_body ) ;
 o = 0 ;
 while ( ll > 0 ) {
 l = ll ;
 if ( VFP_GetStorage ( bo -> vfc , & l , & ptr ) != VFP_OK ) break ;
 if ( l > ll ) l = ll ;
 memcpy ( ptr , VSB_data ( synth_body ) + o , l ) ;
 VFP_Extend ( bo -> vfc , l ) ;
 ll -= l ;
 o += l ;
 }
 AZ ( ObjSetU64 ( wrk , bo -> fetch_objcore , OA_LEN , o ) ) ;
 VSB_destroy ( & synth_body ) ;
 HSH_Unbusy ( wrk , bo -> fetch_objcore ) ;
 ObjSetState ( wrk , bo -> fetch_objcore , BOS_FINISHED ) ;
 return ( F_STP_DONE ) ;
 }


static void unescape ( FILE * file , char * pos , size_t length ) {
 char * tmp ;
 DBUG_ENTER ( "unescape" ) ;
 if ( ! ( tmp = ( char * ) my_malloc ( length * 2 + 1 , MYF ( MY_WME ) ) ) ) die ( EX_MYSQLERR , "Couldn't allocate memory" ) ;
 mysql_real_escape_string ( & mysql_connection , tmp , pos , ( ulong ) length ) ;
 fputc ( '\'' , file ) ;
 fputs ( tmp , file ) ;
 fputc ( '\'' , file ) ;
 check_io ( file ) ;
 my_free ( tmp ) ;
 DBUG_VOID_RETURN ;
 }


static void init_once(void *foo)
{
	struct shmem_inode_info *p = (struct shmem_inode_info *) foo;

	inode_init_once(&p->vfs_inode);
#ifdef CONFIG_TMPFS_POSIX_ACL
	p->i_acl = NULL;
	p->i_default_acl = NULL;
#endif
}


START_TEST(qdict_iterapi_test) { int count; const QDictEntry *ent; fail_unless(qdict_first(tests_dict) == NULL); qdict_put(tests_dict, "key1", qint_from_int(1)); qdict_put(tests_dict, "key2", qint_from_int(2)); qdict_put(tests_dict, "key3", qint_from_int(3)); count = 0; for (ent = qdict_first(tests_dict); ent; ent = qdict_next(tests_dict, ent)){ fail_unless(qdict_haskey(tests_dict, qdict_entry_key(ent)) == 1); count++; } fail_unless(count == qdict_size(tests_dict)); /* Do it again to test restarting */ count = 0; for (ent = qdict_first(tests_dict); ent; ent = qdict_next(tests_dict, ent)){ fail_unless(qdict_haskey(tests_dict, qdict_entry_key(ent)) == 1); count++; } fail_unless(count == qdict_size(tests_dict)); }


int process_netbios_name ( const guchar * name_ptr , char * name_ret , int name_ret_len ) {
 int i ;
 int name_type = * ( name_ptr + NETBIOS_NAME_LEN - 1 ) ;
 guchar name_char ;
 char * name_ret_orig = name_ret ;
 static const char hex_digits [ 16 ] = {
 '0' , '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' , 'a' , 'b' , 'c' , 'd' , 'e' , 'f' }
 ;
 for ( i = 0 ;
 i < NETBIOS_NAME_LEN - 1 ;
 i ++ ) {
 name_char = * name_ptr ++ ;
 if ( name_char >= ' ' && name_char <= '~' ) {
 if ( -- name_ret_len > 0 ) * name_ret ++ = name_char ;
 }
 else {
 if ( -- name_ret_len > 0 ) * name_ret ++ = '<' ;
 if ( -- name_ret_len > 0 ) * name_ret ++ = hex_digits [ ( name_char >> 4 ) ] ;
 if ( -- name_ret_len > 0 ) * name_ret ++ = hex_digits [ ( name_char & 0x0F ) ] ;
 if ( -- name_ret_len > 0 ) * name_ret ++ = '>' ;
 }
 }
 * name_ret = '\0' ;
 name_ret -- ;
 while ( name_ret >= name_ret_orig ) {
 if ( * name_ret != ' ' ) {
 * ( name_ret + 1 ) = 0 ;
 break ;
 }
 name_ret -- ;
 }
 return name_type ;
 }


static void socket_connect_data_free(socket_connect_data *c) { qapi_free_SocketAddressLegacy(c->saddr); g_free(c->model); g_free(c->name); g_free(c); }


static bool hyperv_runtime_enable_needed ( void * opaque ) {
 X86CPU * cpu = opaque ;
 CPUX86State * env = & cpu -> env ;
 if ( ! cpu -> hyperv_runtime ) {
 return false ;
 }
 return env -> msr_hv_runtime != 0 ;
 }


static guint composite_offset ( const tvbuff_t * tvb , const guint counter ) {
 const struct tvb_composite * composite_tvb = ( const struct tvb_composite * ) tvb ;
 const tvbuff_t * member = ( const tvbuff_t * ) composite_tvb -> composite . tvbs -> data ;
 return tvb_offset_from_real_beginning_counter ( member , counter ) ;
 }


static int virtio_blk_device_init(VirtIODevice *vdev) { DeviceState *qdev = DEVICE(vdev); VirtIOBlock *s = VIRTIO_BLK(vdev); VirtIOBlkConf *blk = &(s->blk); static int virtio_blk_id; if (!blk->conf.bs) { error_report("drive property not set"); return -1; } if (!bdrv_is_inserted(blk->conf.bs)) { error_report("Device needs media, but drive is empty"); return -1; } blkconf_serial(&blk->conf, &blk->serial); if (blkconf_geometry(&blk->conf, NULL, 65535, 255, 255) < 0) { return -1; } virtio_init(vdev, "virtio-blk", VIRTIO_ID_BLOCK, sizeof(struct virtio_blk_config)); vdev->get_config = virtio_blk_update_config; vdev->set_config = virtio_blk_set_config; vdev->get_features = virtio_blk_get_features; vdev->set_status = virtio_blk_set_status; vdev->reset = virtio_blk_reset; s->bs = blk->conf.bs; s->conf = &blk->conf; memcpy(&(s->blk), blk, sizeof(struct VirtIOBlkConf)); s->rq = NULL; s->sector_mask = (s->conf->logical_block_size / BDRV_SECTOR_SIZE) - 1; s->vq = virtio_add_queue(vdev, 128, virtio_blk_handle_output); #ifdef CONFIG_VIRTIO_BLK_DATA_PLANE if (!virtio_blk_data_plane_create(vdev, blk, &s->dataplane)) { virtio_cleanup(vdev); return -1; } #endif s->change = qemu_add_vm_change_state_handler(virtio_blk_dma_restart_cb, s); register_savevm(qdev, "virtio-blk", virtio_blk_id++, 2, virtio_blk_save, virtio_blk_load, s); bdrv_set_dev_ops(s->bs, &virtio_block_ops, s); bdrv_set_buffer_alignment(s->bs, s->conf->logical_block_size); bdrv_iostatus_enable(s->bs); add_boot_device_path(s->conf->bootindex, qdev, "/disk@0,0"); return 0; }


int filemap_write_and_wait(struct address_space *mapping)
{
	int err = 0;

	if (mapping->nrpages) {
		err = filemap_fdatawrite(mapping);
		/*
		 * Even if the above returned error, the pages may be
		 * written partially (e.g. -ENOSPC), so we wait for it.
		 * But the -EIO is special case, it may indicate the worst
		 * thing (e.g. bug) happened, so we avoid waiting for it.
		 */
		if (err != -EIO) {
			int err2 = filemap_fdatawait(mapping);
			if (!err)
				err = err2;
		}
	}
	return err;
}


static void sparc_cpu_realizefn(DeviceState *dev, Error **errp) { SPARCCPUClass *scc = SPARC_CPU_GET_CLASS(dev); scc->parent_realize(dev, errp); }


static int decode_frame ( AVCodecContext * avctx , void * data , int * got_frame , AVPacket * avpkt ) {
 const uint8_t * buf = avpkt -> data ;
 int buf_size = avpkt -> size ;
 CamtasiaContext * const c = avctx -> priv_data ;
 const unsigned char * encoded = buf ;
 AVFrame * frame = data ;
 int zret ;
 int ret , len = buf_size ;
 if ( ( ret = ff_get_buffer ( avctx , frame , 0 ) ) < 0 ) {
 av_log ( avctx , AV_LOG_ERROR , "get_buffer() failed\n" ) ;
 return ret ;
 }
 zret = inflateReset ( & c -> zstream ) ;
 if ( zret != Z_OK ) {
 av_log ( avctx , AV_LOG_ERROR , "Inflate reset error: %d\n" , zret ) ;
 return AVERROR_UNKNOWN ;
 }
 c -> zstream . next_in = encoded ;
 c -> zstream . avail_in = len ;
 c -> zstream . next_out = c -> decomp_buf ;
 c -> zstream . avail_out = c -> decomp_size ;
 zret = inflate ( & c -> zstream , Z_FINISH ) ;
 if ( ( zret != Z_OK ) && ( zret != Z_STREAM_END ) && ( zret != Z_DATA_ERROR ) ) {
 av_log ( avctx , AV_LOG_ERROR , "Inflate error: %d\n" , zret ) ;
 return AVERROR_UNKNOWN ;
 }
 if ( zret != Z_DATA_ERROR ) {
 bytestream2_init ( & c -> gb , c -> decomp_buf , c -> decomp_size - c -> zstream . avail_out ) ;
 ff_msrle_decode ( avctx , ( AVPicture * ) frame , c -> bpp , & c -> gb ) ;
 }
 if ( c -> avctx -> pix_fmt == AV_PIX_FMT_PAL8 ) {
 const uint8_t * pal = av_packet_get_side_data ( avpkt , AV_PKT_DATA_PALETTE , NULL ) ;
 if ( pal ) {
 frame -> palette_has_changed = 1 ;
 memcpy ( c -> pal , pal , AVPALETTE_SIZE ) ;
 }
 memcpy ( frame -> data [ 1 ] , c -> pal , AVPALETTE_SIZE ) ;
 }
 * got_frame = 1 ;
 return buf_size ;
 }


static int allocate_buffers ( ShortenContext * s ) {
 int i , chan ;
 int * coeffs ;
 void * tmp_ptr ;
 for ( chan = 0 ;
 chan < s -> channels ;
 chan ++ ) {
 if ( FFMAX ( 1 , s -> nmean ) >= UINT_MAX / sizeof ( int32_t ) ) {
 av_log ( s -> avctx , AV_LOG_ERROR , "nmean too large\n" ) ;
 return AVERROR_INVALIDDATA ;
 }
 if ( s -> blocksize + s -> nwrap >= UINT_MAX / sizeof ( int32_t ) || s -> blocksize + s -> nwrap <= ( unsigned ) s -> nwrap ) {
 av_log ( s -> avctx , AV_LOG_ERROR , "s->blocksize + s->nwrap too large\n" ) ;
 return AVERROR_INVALIDDATA ;
 }
 tmp_ptr = av_realloc ( s -> offset [ chan ] , sizeof ( int32_t ) * FFMAX ( 1 , s -> nmean ) ) ;
 if ( ! tmp_ptr ) return AVERROR ( ENOMEM ) ;
 s -> offset [ chan ] = tmp_ptr ;
 tmp_ptr = av_realloc ( s -> decoded_base [ chan ] , ( s -> blocksize + s -> nwrap ) * sizeof ( s -> decoded_base [ 0 ] [ 0 ] ) ) ;
 if ( ! tmp_ptr ) return AVERROR ( ENOMEM ) ;
 s -> decoded_base [ chan ] = tmp_ptr ;
 for ( i = 0 ;
 i < s -> nwrap ;
 i ++ ) s -> decoded_base [ chan ] [ i ] = 0 ;
 s -> decoded [ chan ] = s -> decoded_base [ chan ] + s -> nwrap ;
 }
 coeffs = av_realloc ( s -> coeffs , s -> nwrap * sizeof ( * s -> coeffs ) ) ;
 if ( ! coeffs ) return AVERROR ( ENOMEM ) ;
 s -> coeffs = coeffs ;
 return 0 ;
 }


void TSVConnShutdown ( TSVConn connp , int read , int write ) {
 sdk_assert ( sdk_sanity_check_iocore_structure ( connp ) == TS_SUCCESS ) ;
 VConnection * vc = ( VConnection * ) connp ;
 if ( read && write ) {
 vc -> do_io_shutdown ( IO_SHUTDOWN_READWRITE ) ;
 }
 else if ( read ) {
 vc -> do_io_shutdown ( IO_SHUTDOWN_READ ) ;
 }
 else if ( write ) {
 vc -> do_io_shutdown ( IO_SHUTDOWN_WRITE ) ;
 }
 }


static int mpsub_probe(AVProbeData *p) { const char *ptr = p->buf; const char *ptr_end = p->buf + p->buf_size; while (ptr < ptr_end) { if (!memcmp(ptr, "FORMAT=TIME", 11)) return AVPROBE_SCORE_EXTENSION; if (!memcmp(ptr, "FORMAT=", 7)) return AVPROBE_SCORE_EXTENSION / 3; ptr += strcspn(ptr, "\n") + 1; } return 0; }


static ssize_t generic_perform_write_2copy(struct file *file,
				struct iov_iter *i, loff_t pos)
{
	struct address_space *mapping = file->f_mapping;
	const struct address_space_operations *a_ops = mapping->a_ops;
	struct inode *inode = mapping->host;
	long status = 0;
	ssize_t written = 0;

	do {
		struct page *src_page;
		struct page *page;
		pgoff_t index;		/* Pagecache index for current page */
		unsigned long offset;	/* Offset into pagecache page */
		unsigned long bytes;	/* Bytes to write to page */
		size_t copied;		/* Bytes copied from user */

		offset = (pos & (PAGE_CACHE_SIZE - 1));
		index = pos >> PAGE_CACHE_SHIFT;
		bytes = min_t(unsigned long, PAGE_CACHE_SIZE - offset,
						iov_iter_count(i));

		/*
		 * a non-NULL src_page indicates that we're doing the
		 * copy via get_user_pages and kmap.
		 */
		src_page = NULL;

		/*
		 * Bring in the user page that we will copy from _first_.
		 * Otherwise there's a nasty deadlock on copying from the
		 * same page as we're writing to, without it being marked
		 * up-to-date.
		 *
		 * Not only is this an optimisation, but it is also required
		 * to check that the address is actually valid, when atomic
		 * usercopies are used, below.
		 */
		if (unlikely(iov_iter_fault_in_readable(i, bytes))) {
			status = -EFAULT;
			break;
		}

		page = __grab_cache_page(mapping, index);
		if (!page) {
			status = -ENOMEM;
			break;
		}

		/*
		 * non-uptodate pages cannot cope with short copies, and we
		 * cannot take a pagefault with the destination page locked.
		 * So pin the source page to copy it.
		 */
		if (!PageUptodate(page) && !segment_eq(get_fs(), KERNEL_DS)) {
			unlock_page(page);

			src_page = alloc_page(GFP_KERNEL);
			if (!src_page) {
				page_cache_release(page);
				status = -ENOMEM;
				break;
			}

			/*
			 * Cannot get_user_pages with a page locked for the
			 * same reason as we can't take a page fault with a
			 * page locked (as explained below).
			 */
			copied = iov_iter_copy_from_user(src_page, i,
								offset, bytes);
			if (unlikely(copied == 0)) {
				status = -EFAULT;
				page_cache_release(page);
				page_cache_release(src_page);
				break;
			}
			bytes = copied;

			lock_page(page);
			/*
			 * Can't handle the page going uptodate here, because
			 * that means we would use non-atomic usercopies, which
			 * zero out the tail of the page, which can cause
			 * zeroes to become transiently visible. We could just
			 * use a non-zeroing copy, but the APIs aren't too
			 * consistent.
			 */
			if (unlikely(!page->mapping || PageUptodate(page))) {
				unlock_page(page);
				page_cache_release(page);
				page_cache_release(src_page);
				continue;
			}
		}

		status = a_ops->prepare_write(file, page, offset, offset+bytes);
		if (unlikely(status))
			goto fs_write_aop_error;

		if (!src_page) {
			/*
			 * Must not enter the pagefault handler here, because
			 * we hold the page lock, so we might recursively
			 * deadlock on the same lock, or get an ABBA deadlock
			 * against a different lock, or against the mmap_sem
			 * (which nests outside the page lock).  So increment
			 * preempt count, and use _atomic usercopies.
			 *
			 * The page is uptodate so we are OK to encounter a
			 * short copy: if unmodified parts of the page are
			 * marked dirty and written out to disk, it doesn't
			 * really matter.
			 */
			pagefault_disable();
			copied = iov_iter_copy_from_user_atomic(page, i,
								offset, bytes);
			pagefault_enable();
		} else {
			void *src, *dst;
			src = kmap_atomic(src_page, KM_USER0);
			dst = kmap_atomic(page, KM_USER1);
			memcpy(dst + offset, src + offset, bytes);
			kunmap_atomic(dst, KM_USER1);
			kunmap_atomic(src, KM_USER0);
			copied = bytes;
		}
		flush_dcache_page(page);

		status = a_ops->commit_write(file, page, offset, offset+bytes);
		if (unlikely(status < 0))
			goto fs_write_aop_error;
		if (unlikely(status > 0)) /* filesystem did partial write */
			copied = min_t(size_t, copied, status);

		unlock_page(page);
		mark_page_accessed(page);
		page_cache_release(page);
		if (src_page)
			page_cache_release(src_page);

		iov_iter_advance(i, copied);
		pos += copied;
		written += copied;

		balance_dirty_pages_ratelimited(mapping);
		cond_resched();
		continue;

fs_write_aop_error:
		unlock_page(page);
		page_cache_release(page);
		if (src_page)
			page_cache_release(src_page);

		/*
		 * prepare_write() may have instantiated a few blocks
		 * outside i_size.  Trim these off again. Don't need
		 * i_size_read because we hold i_mutex.
		 */
		if (pos + bytes > inode->i_size)
			vmtruncate(inode, inode->i_size);
		break;
	} while (iov_iter_count(i));

	return written ? written : status;
}


generic_file_buffered_write(struct kiocb *iocb, const struct iovec *iov,
		unsigned long nr_segs, loff_t pos, loff_t *ppos,
		size_t count, ssize_t written)
{
	struct file *file = iocb->ki_filp;
	struct address_space *mapping = file->f_mapping;
	const struct address_space_operations *a_ops = mapping->a_ops;
	struct inode *inode = mapping->host;
	ssize_t status;
	struct iov_iter i;

	iov_iter_init(&i, iov, nr_segs, count, written);
	if (a_ops->write_begin)
		status = generic_perform_write(file, &i, pos);
	else
		status = generic_perform_write_2copy(file, &i, pos);

	if (likely(status >= 0)) {
		written += status;
		*ppos = pos + status;

		/*
		 * For now, when the user asks for O_SYNC, we'll actually give
		 * O_DSYNC
		 */
		if (unlikely((file->f_flags & O_SYNC) || IS_SYNC(inode))) {
			if (!a_ops->writepage || !is_sync_kiocb(iocb))
				status = generic_osync_inode(inode, mapping,
						OSYNC_METADATA|OSYNC_DATA);
		}
  	}

	/*
	 * If we get here for O_DIRECT writes then we must have fallen through
	 * to buffered writes (block instantiation inside i_size).  So we sync
	 * the file data here, to try to honour O_DIRECT expectations.
	 */
	if (unlikely(file->f_flags & O_DIRECT) && written)
		status = filemap_write_and_wait(mapping);

	return written ? written : status;
}


static void gst_asf_demux_reset_stream_state_after_discont ( GstASFDemux * demux ) {
 guint n ;
 gst_adapter_clear ( demux -> adapter ) ;
 GST_DEBUG_OBJECT ( demux , "reset stream state" ) ;
 gst_flow_combiner_reset ( demux -> flowcombiner ) ;
 for ( n = 0 ;
 n < demux -> num_streams ;
 n ++ ) {
 demux -> stream [ n ] . discont = TRUE ;
 demux -> stream [ n ] . first_buffer = TRUE ;
 while ( demux -> stream [ n ] . payloads -> len > 0 ) {
 AsfPayload * payload ;
 guint last ;
 last = demux -> stream [ n ] . payloads -> len - 1 ;
 payload = & g_array_index ( demux -> stream [ n ] . payloads , AsfPayload , last ) ;
 gst_buffer_replace ( & payload -> buf , NULL ) ;
 g_array_remove_index ( demux -> stream [ n ] . payloads , last ) ;
 }
 }
 }


static inline void wake_up_page(struct page *page, int bit)
{
	__wake_up_bit(page_waitqueue(page), &page->flags, bit);
}


void unlock_page(struct page *page)
{
	smp_mb__before_clear_bit();
	if (!TestClearPageLocked(page))
		BUG();
	smp_mb__after_clear_bit();
	wake_up_page(page, PG_locked);
}


static int idreg_init1 ( SysBusDevice * dev ) {
 IDRegState * s = FROM_SYSBUS ( IDRegState , dev ) ;
 memory_region_init_ram ( & s -> mem , OBJECT ( s ) , "sun4m.idreg" , sizeof ( idreg_data ) ) ;
 vmstate_register_ram_global ( & s -> mem ) ;
 memory_region_set_readonly ( & s -> mem , true ) ;
 sysbus_init_mmio ( dev , & s -> mem ) ;
 return 0 ;
 }


void helper_fsqrtq(CPUSPARCState *env) { clear_float_exceptions(env); QT0 = float128_sqrt(QT1, &env->fp_status); check_ieee_exceptions(env); }


static void shrink_readahead_size_eio(struct file *filp,
					struct file_ra_state *ra)
{
	if (!ra->ra_pages)
		return;

	ra->ra_pages /= 4;
}


static void alloc_limit_failure ( char * fn_name , size_t size ) {
 fprintf ( stderr , "%s: Maximum allocation size exceeded " "(maxsize = %lu;
 size = %lu).\n" , fn_name , ( unsigned long ) alloc_limit , ( unsigned long ) size ) ;
 }


av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx) { int i; ff_check_alignment(); #if CONFIG_ENCODERS if (avctx->bits_per_raw_sample == 10) { c->fdct = ff_jpeg_fdct_islow_10; c->fdct248 = ff_fdct248_islow_10; } else { if(avctx->dct_algo==FF_DCT_FASTINT) { c->fdct = fdct_ifast; c->fdct248 = fdct_ifast248; } else if(avctx->dct_algo==FF_DCT_FAAN) { c->fdct = ff_faandct; c->fdct248 = ff_faandct248; } else { c->fdct = ff_jpeg_fdct_islow_8; //slow/accurate/default c->fdct248 = ff_fdct248_islow_8; } } #endif //CONFIG_ENCODERS if(avctx->lowres==1){ c->idct_put= ff_jref_idct4_put; c->idct_add= ff_jref_idct4_add; c->idct = j_rev_dct4; c->idct_permutation_type= FF_NO_IDCT_PERM; }else if(avctx->lowres==2){ c->idct_put= ff_jref_idct2_put; c->idct_add= ff_jref_idct2_add; c->idct = j_rev_dct2; c->idct_permutation_type= FF_NO_IDCT_PERM; }else if(avctx->lowres==3){ c->idct_put= ff_jref_idct1_put; c->idct_add= ff_jref_idct1_add; c->idct = j_rev_dct1; c->idct_permutation_type= FF_NO_IDCT_PERM; }else{ if (avctx->bits_per_raw_sample == 10) { c->idct_put = ff_simple_idct_put_10; c->idct_add = ff_simple_idct_add_10; c->idct = ff_simple_idct_10; c->idct_permutation_type = FF_NO_IDCT_PERM; } else { if(avctx->idct_algo==FF_IDCT_INT){ c->idct_put= ff_jref_idct_put; c->idct_add= ff_jref_idct_add; c->idct = j_rev_dct; c->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM; }else if((CONFIG_VP3_DECODER || CONFIG_VP5_DECODER || CONFIG_VP6_DECODER ) && avctx->idct_algo==FF_IDCT_VP3){ c->idct_put= ff_vp3_idct_put_c; c->idct_add= ff_vp3_idct_add_c; c->idct = ff_vp3_idct_c; c->idct_permutation_type= FF_NO_IDCT_PERM; }else if(avctx->idct_algo==FF_IDCT_WMV2){ c->idct_put= ff_wmv2_idct_put_c; c->idct_add= ff_wmv2_idct_add_c; c->idct = ff_wmv2_idct_c; c->idct_permutation_type= FF_NO_IDCT_PERM; }else if(avctx->idct_algo==FF_IDCT_FAAN){ c->idct_put= ff_faanidct_put; c->idct_add= ff_faanidct_add; c->idct = ff_faanidct; c->idct_permutation_type= FF_NO_IDCT_PERM; }else if(CONFIG_EATGQ_DECODER && avctx->idct_algo==FF_IDCT_EA) { c->idct_put= ff_ea_idct_put_c; c->idct_permutation_type= FF_NO_IDCT_PERM; }else{ //accurate/default c->idct_put = ff_simple_idct_put_8; c->idct_add = ff_simple_idct_add_8; c->idct = ff_simple_idct_8; c->idct_permutation_type= FF_NO_IDCT_PERM; } } } c->diff_pixels = diff_pixels_c; c->put_pixels_clamped = ff_put_pixels_clamped_c; c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_c; c->add_pixels_clamped = ff_add_pixels_clamped_c; c->sum_abs_dctelem = sum_abs_dctelem_c; c->gmc1 = gmc1_c; c->gmc = ff_gmc_c; c->pix_sum = pix_sum_c; c->pix_norm1 = pix_norm1_c; c->fill_block_tab[0] = fill_block16_c; c->fill_block_tab[1] = fill_block8_c; /* TODO [0] 16 [1] 8 */ c->pix_abs[0][0] = pix_abs16_c; c->pix_abs[0][1] = pix_abs16_x2_c; c->pix_abs[0][2] = pix_abs16_y2_c; c->pix_abs[0][3] = pix_abs16_xy2_c; c->pix_abs[1][0] = pix_abs8_c; c->pix_abs[1][1] = pix_abs8_x2_c; c->pix_abs[1][2] = pix_abs8_y2_c; c->pix_abs[1][3] = pix_abs8_xy2_c; c->put_tpel_pixels_tab[ 0] = put_tpel_pixels_mc00_c; c->put_tpel_pixels_tab[ 1] = put_tpel_pixels_mc10_c; c->put_tpel_pixels_tab[ 2] = put_tpel_pixels_mc20_c; c->put_tpel_pixels_tab[ 4] = put_tpel_pixels_mc01_c; c->put_tpel_pixels_tab[ 5] = put_tpel_pixels_mc11_c; c->put_tpel_pixels_tab[ 6] = put_tpel_pixels_mc21_c; c->put_tpel_pixels_tab[ 8] = put_tpel_pixels_mc02_c; c->put_tpel_pixels_tab[ 9] = put_tpel_pixels_mc12_c; c->put_tpel_pixels_tab[10] = put_tpel_pixels_mc22_c; c->avg_tpel_pixels_tab[ 0] = avg_tpel_pixels_mc00_c; c->avg_tpel_pixels_tab[ 1] = avg_tpel_pixels_mc10_c; c->avg_tpel_pixels_tab[ 2] = avg_tpel_pixels_mc20_c; c->avg_tpel_pixels_tab[ 4] = avg_tpel_pixels_mc01_c; c->avg_tpel_pixels_tab[ 5] = avg_tpel_pixels_mc11_c; c->avg_tpel_pixels_tab[ 6] = avg_tpel_pixels_mc21_c; c->avg_tpel_pixels_tab[ 8] = avg_tpel_pixels_mc02_c; c->avg_tpel_pixels_tab[ 9] = avg_tpel_pixels_mc12_c; c->avg_tpel_pixels_tab[10] = avg_tpel_pixels_mc22_c; #define dspfunc(PFX, IDX, NUM) \ c->PFX ## _pixels_tab[IDX][ 0] = PFX ## NUM ## _mc00_c; \ c->PFX ## _pixels_tab[IDX][ 1] = PFX ## NUM ## _mc10_c; \ c->PFX ## _pixels_tab[IDX][ 2] = PFX ## NUM ## _mc20_c; \ c->PFX ## _pixels_tab[IDX][ 3] = PFX ## NUM ## _mc30_c; \ c->PFX ## _pixels_tab[IDX][ 4] = PFX ## NUM ## _mc01_c; \ c->PFX ## _pixels_tab[IDX][ 5] = PFX ## NUM ## _mc11_c; \ c->PFX ## _pixels_tab[IDX][ 6] = PFX ## NUM ## _mc21_c; \ c->PFX ## _pixels_tab[IDX][ 7] = PFX ## NUM ## _mc31_c; \ c->PFX ## _pixels_tab[IDX][ 8] = PFX ## NUM ## _mc02_c; \ c->PFX ## _pixels_tab[IDX][ 9] = PFX ## NUM ## _mc12_c; \ c->PFX ## _pixels_tab[IDX][10] = PFX ## NUM ## _mc22_c; \ c->PFX ## _pixels_tab[IDX][11] = PFX ## NUM ## _mc32_c; \ c->PFX ## _pixels_tab[IDX][12] = PFX ## NUM ## _mc03_c; \ c->PFX ## _pixels_tab[IDX][13] = PFX ## NUM ## _mc13_c; \ c->PFX ## _pixels_tab[IDX][14] = PFX ## NUM ## _mc23_c; \ c->PFX ## _pixels_tab[IDX][15] = PFX ## NUM ## _mc33_c dspfunc(put_qpel, 0, 16); dspfunc(put_no_rnd_qpel, 0, 16); dspfunc(avg_qpel, 0, 16); /* dspfunc(avg_no_rnd_qpel, 0, 16); */ dspfunc(put_qpel, 1, 8); dspfunc(put_no_rnd_qpel, 1, 8); dspfunc(avg_qpel, 1, 8); /* dspfunc(avg_no_rnd_qpel, 1, 8); */ #undef dspfunc #if CONFIG_MLP_DECODER || CONFIG_TRUEHD_DECODER ff_mlp_init(c, avctx); #endif #if CONFIG_WMV2_DECODER || CONFIG_VC1_DECODER ff_intrax8dsp_init(c,avctx); #endif c->put_mspel_pixels_tab[0]= ff_put_pixels8x8_c; c->put_mspel_pixels_tab[1]= put_mspel8_mc10_c; c->put_mspel_pixels_tab[2]= put_mspel8_mc20_c; c->put_mspel_pixels_tab[3]= put_mspel8_mc30_c; c->put_mspel_pixels_tab[4]= put_mspel8_mc02_c; c->put_mspel_pixels_tab[5]= put_mspel8_mc12_c; c->put_mspel_pixels_tab[6]= put_mspel8_mc22_c; c->put_mspel_pixels_tab[7]= put_mspel8_mc32_c; #define SET_CMP_FUNC(name) \ c->name[0]= name ## 16_c;\ c->name[1]= name ## 8x8_c; SET_CMP_FUNC(hadamard8_diff) c->hadamard8_diff[4]= hadamard8_intra16_c; c->hadamard8_diff[5]= hadamard8_intra8x8_c; SET_CMP_FUNC(dct_sad) SET_CMP_FUNC(dct_max) #if CONFIG_GPL SET_CMP_FUNC(dct264_sad) #endif c->sad[0]= pix_abs16_c; c->sad[1]= pix_abs8_c; c->sse[0]= sse16_c; c->sse[1]= sse8_c; c->sse[2]= sse4_c; SET_CMP_FUNC(quant_psnr) SET_CMP_FUNC(rd) SET_CMP_FUNC(bit) c->vsad[0]= vsad16_c; c->vsad[4]= vsad_intra16_c; c->vsad[5]= vsad_intra8_c; c->vsse[0]= vsse16_c; c->vsse[4]= vsse_intra16_c; c->vsse[5]= vsse_intra8_c; c->nsse[0]= nsse16_c; c->nsse[1]= nsse8_c; #if CONFIG_DWT ff_dsputil_init_dwt(c); #endif c->ssd_int8_vs_int16 = ssd_int8_vs_int16_c; c->add_bytes= add_bytes_c; c->diff_bytes= diff_bytes_c; c->add_hfyu_median_prediction= add_hfyu_median_prediction_c; c->sub_hfyu_median_prediction= sub_hfyu_median_prediction_c; c->add_hfyu_left_prediction = add_hfyu_left_prediction_c; c->add_hfyu_left_prediction_bgr32 = add_hfyu_left_prediction_bgr32_c; c->bswap_buf= bswap_buf; c->bswap16_buf = bswap16_buf; if (CONFIG_H263_DECODER || CONFIG_H263_ENCODER) { c->h263_h_loop_filter= h263_h_loop_filter_c; c->h263_v_loop_filter= h263_v_loop_filter_c; } if (CONFIG_VP3_DECODER) { c->vp3_h_loop_filter= ff_vp3_h_loop_filter_c; c->vp3_v_loop_filter= ff_vp3_v_loop_filter_c; c->vp3_idct_dc_add= ff_vp3_idct_dc_add_c; } c->h261_loop_filter= h261_loop_filter_c; c->try_8x8basis= try_8x8basis_c; c->add_8x8basis= add_8x8basis_c; #if CONFIG_VORBIS_DECODER c->vorbis_inverse_coupling = vorbis_inverse_coupling; #endif #if CONFIG_AC3_DECODER c->ac3_downmix = ff_ac3_downmix_c; #endif c->vector_fmul = vector_fmul_c; c->vector_fmul_reverse = vector_fmul_reverse_c; c->vector_fmul_add = vector_fmul_add_c; c->vector_fmul_window = vector_fmul_window_c; c->vector_clipf = vector_clipf_c; c->scalarproduct_int16 = scalarproduct_int16_c; c->scalarproduct_and_madd_int16 = scalarproduct_and_madd_int16_c; c->apply_window_int16 = apply_window_int16_c; c->vector_clip_int32 = vector_clip_int32_c; c->scalarproduct_float = scalarproduct_float_c; c->butterflies_float = butterflies_float_c; c->butterflies_float_interleave = butterflies_float_interleave_c; c->vector_fmul_scalar = vector_fmul_scalar_c; c->vector_fmac_scalar = vector_fmac_scalar_c; c->shrink[0]= av_image_copy_plane; c->shrink[1]= ff_shrink22; c->shrink[2]= ff_shrink44; c->shrink[3]= ff_shrink88; c->prefetch= just_return; memset(c->put_2tap_qpel_pixels_tab, 0, sizeof(c->put_2tap_qpel_pixels_tab)); memset(c->avg_2tap_qpel_pixels_tab, 0, sizeof(c->avg_2tap_qpel_pixels_tab)); #undef FUNC #undef FUNCC #define FUNC(f, depth) f ## _ ## depth #define FUNCC(f, depth) f ## _ ## depth ## _c #define dspfunc1(PFX, IDX, NUM, depth)\ c->PFX ## _pixels_tab[IDX][0] = FUNCC(PFX ## _pixels ## NUM , depth);\ c->PFX ## _pixels_tab[IDX][1] = FUNCC(PFX ## _pixels ## NUM ## _x2 , depth);\ c->PFX ## _pixels_tab[IDX][2] = FUNCC(PFX ## _pixels ## NUM ## _y2 , depth);\ c->PFX ## _pixels_tab[IDX][3] = FUNCC(PFX ## _pixels ## NUM ## _xy2, depth) #define dspfunc2(PFX, IDX, NUM, depth)\ c->PFX ## _pixels_tab[IDX][ 0] = FUNCC(PFX ## NUM ## _mc00, depth);\ c->PFX ## _pixels_tab[IDX][ 1] = FUNCC(PFX ## NUM ## _mc10, depth);\ c->PFX ## _pixels_tab[IDX][ 2] = FUNCC(PFX ## NUM ## _mc20, depth);\ c->PFX ## _pixels_tab[IDX][ 3] = FUNCC(PFX ## NUM ## _mc30, depth);\ c->PFX ## _pixels_tab[IDX][ 4] = FUNCC(PFX ## NUM ## _mc01, depth);\ c->PFX ## _pixels_tab[IDX][ 5] = FUNCC(PFX ## NUM ## _mc11, depth);\ c->PFX ## _pixels_tab[IDX][ 6] = FUNCC(PFX ## NUM ## _mc21, depth);\ c->PFX ## _pixels_tab[IDX][ 7] = FUNCC(PFX ## NUM ## _mc31, depth);\ c->PFX ## _pixels_tab[IDX][ 8] = FUNCC(PFX ## NUM ## _mc02, depth);\ c->PFX ## _pixels_tab[IDX][ 9] = FUNCC(PFX ## NUM ## _mc12, depth);\ c->PFX ## _pixels_tab[IDX][10] = FUNCC(PFX ## NUM ## _mc22, depth);\ c->PFX ## _pixels_tab[IDX][11] = FUNCC(PFX ## NUM ## _mc32, depth);\ c->PFX ## _pixels_tab[IDX][12] = FUNCC(PFX ## NUM ## _mc03, depth);\ c->PFX ## _pixels_tab[IDX][13] = FUNCC(PFX ## NUM ## _mc13, depth);\ c->PFX ## _pixels_tab[IDX][14] = FUNCC(PFX ## NUM ## _mc23, depth);\ c->PFX ## _pixels_tab[IDX][15] = FUNCC(PFX ## NUM ## _mc33, depth) #define BIT_DEPTH_FUNCS(depth, dct)\ c->get_pixels = FUNCC(get_pixels ## dct , depth);\ c->draw_edges = FUNCC(draw_edges , depth);\ c->emulated_edge_mc = FUNC (ff_emulated_edge_mc , depth);\ c->clear_block = FUNCC(clear_block ## dct , depth);\ c->clear_blocks = FUNCC(clear_blocks ## dct , depth);\ c->add_pixels8 = FUNCC(add_pixels8 ## dct , depth);\ c->add_pixels4 = FUNCC(add_pixels4 ## dct , depth);\ c->put_no_rnd_pixels_l2[0] = FUNCC(put_no_rnd_pixels16_l2, depth);\ c->put_no_rnd_pixels_l2[1] = FUNCC(put_no_rnd_pixels8_l2 , depth);\ \ c->put_h264_chroma_pixels_tab[0] = FUNCC(put_h264_chroma_mc8 , depth);\ c->put_h264_chroma_pixels_tab[1] = FUNCC(put_h264_chroma_mc4 , depth);\ c->put_h264_chroma_pixels_tab[2] = FUNCC(put_h264_chroma_mc2 , depth);\ c->avg_h264_chroma_pixels_tab[0] = FUNCC(avg_h264_chroma_mc8 , depth);\ c->avg_h264_chroma_pixels_tab[1] = FUNCC(avg_h264_chroma_mc4 , depth);\ c->avg_h264_chroma_pixels_tab[2] = FUNCC(avg_h264_chroma_mc2 , depth);\ \ dspfunc1(put , 0, 16, depth);\ dspfunc1(put , 1, 8, depth);\ dspfunc1(put , 2, 4, depth);\ dspfunc1(put , 3, 2, depth);\ dspfunc1(put_no_rnd, 0, 16, depth);\ dspfunc1(put_no_rnd, 1, 8, depth);\ dspfunc1(avg , 0, 16, depth);\ dspfunc1(avg , 1, 8, depth);\ dspfunc1(avg , 2, 4, depth);\ dspfunc1(avg , 3, 2, depth);\ dspfunc1(avg_no_rnd, 0, 16, depth);\ dspfunc1(avg_no_rnd, 1, 8, depth);\ \ dspfunc2(put_h264_qpel, 0, 16, depth);\ dspfunc2(put_h264_qpel, 1, 8, depth);\ dspfunc2(put_h264_qpel, 2, 4, depth);\ dspfunc2(put_h264_qpel, 3, 2, depth);\ dspfunc2(avg_h264_qpel, 0, 16, depth);\ dspfunc2(avg_h264_qpel, 1, 8, depth);\ dspfunc2(avg_h264_qpel, 2, 4, depth); switch (avctx->bits_per_raw_sample) { case 9: if (c->dct_bits == 32) { BIT_DEPTH_FUNCS(9, _32); } else { BIT_DEPTH_FUNCS(9, _16); } break; case 10: if (c->dct_bits == 32) { BIT_DEPTH_FUNCS(10, _32); } else { BIT_DEPTH_FUNCS(10, _16); } break; default: av_log(avctx, AV_LOG_DEBUG, "Unsupported bit depth: %d\n", avctx->bits_per_raw_sample); case 8: BIT_DEPTH_FUNCS(8, _16); break; } if (HAVE_MMX) dsputil_init_mmx (c, avctx); if (ARCH_ARM) dsputil_init_arm (c, avctx); if (CONFIG_MLIB) dsputil_init_mlib (c, avctx); if (HAVE_VIS) dsputil_init_vis (c, avctx); if (ARCH_ALPHA) dsputil_init_alpha (c, avctx); if (ARCH_PPC) dsputil_init_ppc (c, avctx); if (HAVE_MMI) dsputil_init_mmi (c, avctx); if (ARCH_SH4) dsputil_init_sh4 (c, avctx); if (ARCH_BFIN) dsputil_init_bfin (c, avctx); for(i=0; i<64; i++){ if(!c->put_2tap_qpel_pixels_tab[0][i]) c->put_2tap_qpel_pixels_tab[0][i]= c->put_h264_qpel_pixels_tab[0][i]; if(!c->avg_2tap_qpel_pixels_tab[0][i]) c->avg_2tap_qpel_pixels_tab[0][i]= c->avg_h264_qpel_pixels_tab[0][i]; } ff_init_scantable_permutation(c->idct_permutation, c->idct_permutation_type); }


static DriveInfo *blockdev_init(QDict *bs_opts, BlockInterfaceType type, DriveMediaType media) { const char *buf; const char *file = NULL; const char *serial; int ro = 0; int bdrv_flags = 0; int on_read_error, on_write_error; DriveInfo *dinfo; ThrottleConfig cfg; int snapshot = 0; bool copy_on_read; int ret; Error *error = NULL; QemuOpts *opts; const char *id; bool has_driver_specific_opts; BlockDriver *drv = NULL; /* Check common options by copying from bs_opts to opts, all other options * stay in bs_opts for processing by bdrv_open(). */ id = qdict_get_try_str(bs_opts, "id"); opts = qemu_opts_create(&qemu_common_drive_opts, id, 1, &error); if (error_is_set(&error)) { qerror_report_err(error); error_free(error); return NULL; } qemu_opts_absorb_qdict(opts, bs_opts, &error); if (error_is_set(&error)) { qerror_report_err(error); error_free(error); return NULL; } if (id) { qdict_del(bs_opts, "id"); } has_driver_specific_opts = !!qdict_size(bs_opts); /* extract parameters */ snapshot = qemu_opt_get_bool(opts, "snapshot", 0); ro = qemu_opt_get_bool(opts, "read-only", 0); copy_on_read = qemu_opt_get_bool(opts, "copy-on-read", false); file = qemu_opt_get(opts, "file"); serial = qemu_opt_get(opts, "serial"); if ((buf = qemu_opt_get(opts, "discard")) != NULL) { if (bdrv_parse_discard_flags(buf, &bdrv_flags) != 0) { error_report("invalid discard option"); return NULL; } } if (qemu_opt_get_bool(opts, "cache.writeback", true)) { bdrv_flags |= BDRV_O_CACHE_WB; } if (qemu_opt_get_bool(opts, "cache.direct", false)) { bdrv_flags |= BDRV_O_NOCACHE; } if (qemu_opt_get_bool(opts, "cache.no-flush", false)) { bdrv_flags |= BDRV_O_NO_FLUSH; } #ifdef CONFIG_LINUX_AIO if ((buf = qemu_opt_get(opts, "aio")) != NULL) { if (!strcmp(buf, "native")) { bdrv_flags |= BDRV_O_NATIVE_AIO; } else if (!strcmp(buf, "threads")) { /* this is the default */ } else { error_report("invalid aio option"); return NULL; } } #endif if ((buf = qemu_opt_get(opts, "format")) != NULL) { if (is_help_option(buf)) { error_printf("Supported formats:"); bdrv_iterate_format(bdrv_format_print, NULL); error_printf("\n"); return NULL; } drv = bdrv_find_format(buf); if (!drv) { error_report("'%s' invalid format", buf); return NULL; } } /* disk I/O throttling */ memset(&cfg, 0, sizeof(cfg)); cfg.buckets[THROTTLE_BPS_TOTAL].avg = qemu_opt_get_number(opts, "throttling.bps-total", 0); cfg.buckets[THROTTLE_BPS_READ].avg = qemu_opt_get_number(opts, "throttling.bps-read", 0); cfg.buckets[THROTTLE_BPS_WRITE].avg = qemu_opt_get_number(opts, "throttling.bps-write", 0); cfg.buckets[THROTTLE_OPS_TOTAL].avg = qemu_opt_get_number(opts, "throttling.iops-total", 0); cfg.buckets[THROTTLE_OPS_READ].avg = qemu_opt_get_number(opts, "throttling.iops-read", 0); cfg.buckets[THROTTLE_OPS_WRITE].avg = qemu_opt_get_number(opts, "throttling.iops-write", 0); cfg.buckets[THROTTLE_BPS_TOTAL].max = qemu_opt_get_number(opts, "throttling.bps-total-max", 0); cfg.buckets[THROTTLE_BPS_READ].max = qemu_opt_get_number(opts, "throttling.bps-read-max", 0); cfg.buckets[THROTTLE_BPS_WRITE].max = qemu_opt_get_number(opts, "throttling.bps-write-max", 0); cfg.buckets[THROTTLE_OPS_TOTAL].max = qemu_opt_get_number(opts, "throttling.iops-total-max", 0); cfg.buckets[THROTTLE_OPS_READ].max = qemu_opt_get_number(opts, "throttling.iops-read-max", 0); cfg.buckets[THROTTLE_OPS_WRITE].max = qemu_opt_get_number(opts, "throttling.iops-write-max", 0); cfg.op_size = qemu_opt_get_number(opts, "throttling.iops-size", 0); if (!check_throttle_config(&cfg, &error)) { error_report("%s", error_get_pretty(error)); error_free(error); return NULL; } on_write_error = BLOCKDEV_ON_ERROR_ENOSPC; if ((buf = qemu_opt_get(opts, "werror")) != NULL) { if (type != IF_IDE && type != IF_SCSI && type != IF_VIRTIO && type != IF_NONE) { error_report("werror is not supported by this bus type"); return NULL; } on_write_error = parse_block_error_action(buf, 0); if (on_write_error < 0) { return NULL; } } on_read_error = BLOCKDEV_ON_ERROR_REPORT; if ((buf = qemu_opt_get(opts, "rerror")) != NULL) { if (type != IF_IDE && type != IF_VIRTIO && type != IF_SCSI && type != IF_NONE) { error_report("rerror is not supported by this bus type"); return NULL; } on_read_error = parse_block_error_action(buf, 1); if (on_read_error < 0) { return NULL; } } /* init */ dinfo = g_malloc0(sizeof(*dinfo)); dinfo->id = g_strdup(qemu_opts_id(opts)); dinfo->bdrv = bdrv_new(dinfo->id); dinfo->bdrv->open_flags = snapshot ? BDRV_O_SNAPSHOT : 0; dinfo->bdrv->read_only = ro; dinfo->type = type; dinfo->refcount = 1; if (serial != NULL) { dinfo->serial = g_strdup(serial); } QTAILQ_INSERT_TAIL(&drives, dinfo, next); bdrv_set_on_error(dinfo->bdrv, on_read_error, on_write_error); /* disk I/O throttling */ if (throttle_enabled(&cfg)) { bdrv_io_limits_enable(dinfo->bdrv); bdrv_set_io_limits(dinfo->bdrv, &cfg); } switch(type) { case IF_IDE: case IF_SCSI: case IF_XEN: case IF_NONE: dinfo->media_cd = media == MEDIA_CDROM; break; case IF_SD: case IF_FLOPPY: case IF_PFLASH: case IF_MTD: case IF_VIRTIO: break; default: abort(); } if (!file || !*file) { if (has_driver_specific_opts) { file = NULL; } else { return dinfo; } } if (snapshot) { /* always use cache=unsafe with snapshot */ bdrv_flags &= ~BDRV_O_CACHE_MASK; bdrv_flags |= (BDRV_O_SNAPSHOT|BDRV_O_CACHE_WB|BDRV_O_NO_FLUSH); } if (copy_on_read) { bdrv_flags |= BDRV_O_COPY_ON_READ; } if (runstate_check(RUN_STATE_INMIGRATE)) { bdrv_flags |= BDRV_O_INCOMING; } if (media == MEDIA_CDROM) { /* CDROM is fine for any interface, don't check. */ ro = 1; } else if (ro == 1) { if (type != IF_SCSI && type != IF_VIRTIO && type != IF_FLOPPY && type != IF_NONE && type != IF_PFLASH) { error_report("read-only not supported by this bus type"); goto err; } } bdrv_flags |= ro ? 0 : BDRV_O_RDWR; if (ro && copy_on_read) { error_report("warning: disabling copy_on_read on read-only drive"); } QINCREF(bs_opts); ret = bdrv_open(dinfo->bdrv, file, bs_opts, bdrv_flags, drv, &error); if (ret < 0) { error_report("could not open disk image %s: %s", file ?: dinfo->id, error_get_pretty(error)); goto err; } if (bdrv_key_required(dinfo->bdrv)) autostart = 0; QDECREF(bs_opts); qemu_opts_del(opts); return dinfo; err: qemu_opts_del(opts); QDECREF(bs_opts); bdrv_unref(dinfo->bdrv); g_free(dinfo->id); QTAILQ_REMOVE(&drives, dinfo, next); g_free(dinfo); return NULL; }


unsigned find_get_pages(struct address_space *mapping, pgoff_t start,
			    unsigned int nr_pages, struct page **pages)
{
	unsigned int i;
	unsigned int ret;
	unsigned int nr_found;

	rcu_read_lock();
restart:
	nr_found = radix_tree_gang_lookup_slot(&mapping->page_tree,
				(void ***)pages, start, nr_pages);
	ret = 0;
	for (i = 0; i < nr_found; i++) {
		struct page *page;
repeat:
		page = radix_tree_deref_slot((void **)pages[i]);
		if (unlikely(!page))
			continue;
		/*
		 * this can only trigger if nr_found == 1, making livelock
		 * a non issue.
		 */
		if (unlikely(page == RADIX_TREE_RETRY))
			goto restart;

		if (!page_cache_get_speculative(page))
			goto repeat;

		/* Has the page moved? */
		if (unlikely(page != *((void **)pages[i]))) {
			page_cache_release(page);
			goto repeat;
		}

		pages[ret] = page;
		ret++;
	}
	rcu_read_unlock();
	return ret;
}


static void write_clockstatus ( struct recvbuf * rbufp , int restrict_mask ) {
 ctl_error ( CERR_PERMISSION ) ;
 }


static inline void SetPixelCbTraits ( Image * image , const PixelTrait traits ) {
 image -> channel_map [ CbPixelChannel ] . traits = traits ;
 }


generic_file_aio_read(struct kiocb *iocb, const struct iovec *iov,
		unsigned long nr_segs, loff_t pos)
{
	struct file *filp = iocb->ki_filp;
	ssize_t retval;
	unsigned long seg;
	size_t count;
	loff_t *ppos = &iocb->ki_pos;

	count = 0;
	retval = generic_segment_checks(iov, &nr_segs, &count, VERIFY_WRITE);
	if (retval)
		return retval;

	/* coalesce the iovecs and go direct-to-BIO for O_DIRECT */
	if (filp->f_flags & O_DIRECT) {
		loff_t size;
		struct address_space *mapping;
		struct inode *inode;

		mapping = filp->f_mapping;
		inode = mapping->host;
		if (!count)
			goto out; /* skip atime */
		size = i_size_read(inode);
		if (pos < size) {
			retval = filemap_write_and_wait(mapping);
			if (!retval) {
				retval = mapping->a_ops->direct_IO(READ, iocb,
							iov, pos, nr_segs);
			}
			if (retval > 0)
				*ppos = pos + retval;
			if (retval) {
				file_accessed(filp);
				goto out;
			}
		}
	}

	for (seg = 0; seg < nr_segs; seg++) {
		read_descriptor_t desc;

		desc.written = 0;
		desc.arg.buf = iov[seg].iov_base;
		desc.count = iov[seg].iov_len;
		if (desc.count == 0)
			continue;
		desc.error = 0;
		do_generic_file_read(filp, ppos, &desc, file_read_actor);
		retval += desc.written;
		if (desc.error) {
			retval = retval ?: desc.error;
			break;
		}
		if (desc.count > 0)
			break;
	}
out:
	return retval;
}


SPL_METHOD ( SplDoublyLinkedList , serialize ) {
 spl_dllist_object * intern = ( spl_dllist_object * ) zend_object_store_get_object ( getThis ( ) TSRMLS_CC ) ;
 smart_str buf = {
 0 }
 ;
 spl_ptr_llist_element * current = intern -> llist -> head , * next ;
 zval * flags ;
 php_serialize_data_t var_hash ;
 if ( zend_parse_parameters_none ( ) == FAILURE ) {
 return ;
 }
 PHP_VAR_SERIALIZE_INIT ( var_hash ) ;
 MAKE_STD_ZVAL ( flags ) ;
 ZVAL_LONG ( flags , intern -> flags ) ;
 php_var_serialize ( & buf , & flags , & var_hash TSRMLS_CC ) ;
 zval_ptr_dtor ( & flags ) ;
 while ( current ) {
 smart_str_appendc ( & buf , ':' ) ;
 next = current -> next ;
 php_var_serialize ( & buf , ( zval * * ) & current -> data , & var_hash TSRMLS_CC ) ;
 current = next ;
 }
 smart_str_0 ( & buf ) ;
 PHP_VAR_SERIALIZE_DESTROY ( var_hash ) ;
 if ( buf . c ) {
 RETURN_STRINGL ( buf . c , buf . len , 0 ) ;
 }
 else {
 RETURN_NULL ( ) ;
 }
 }


static __always_inline int __vfs_follow_link(struct nameidata *nd, const char *link)
{
	int res = 0;
	char *name;
	if (IS_ERR(link))
		goto fail;

	if (*link == '/') {
		path_put(&nd->path);
		if (!walk_init_root(link, nd))
			/* weird __emul_prefix() stuff did it */
			goto out;
	}
	res = link_path_walk(link, nd);
out:
	if (nd->depth || res || nd->last_type!=LAST_NORM)
		return res;
	/*
	 * If it is an iterative symlinks resolution in open_namei() we
	 * have to copy the last component. And all that crap because of
	 * bloody create() on broken symlinks. Furrfu...
	 */
	name = __getname();
	if (unlikely(!name)) {
		path_put(&nd->path);
		return -ENOMEM;
	}
	strcpy(name, nd->last.name);
	nd->last.name = name;
	return 0;
fail:
	path_put(&nd->path);
	return PTR_ERR(link);
}


static void gen_add16(TCGv t0, TCGv t1) { TCGv tmp = new_tmp(); tcg_gen_xor_i32(tmp, t0, t1); tcg_gen_andi_i32(tmp, tmp, 0x8000); tcg_gen_andi_i32(t0, t0, ~0x8000); tcg_gen_andi_i32(t1, t1, ~0x8000); tcg_gen_add_i32(t0, t0, t1); tcg_gen_xor_i32(t0, t0, tmp); dead_tmp(tmp); dead_tmp(t1); }


static inline void FUNC(idctRowCondDC)(int16_t *row, int extra_shift) { int a0, a1, a2, a3, b0, b1, b2, b3; #if HAVE_FAST_64BIT #define ROW0_MASK (0xffffLL << 48 * HAVE_BIGENDIAN) if (((((uint64_t *)row)[0] & ~ROW0_MASK) | ((uint64_t *)row)[1]) == 0) { uint64_t temp; if (DC_SHIFT - extra_shift > 0) { temp = (row[0] << (DC_SHIFT - extra_shift)) & 0xffff; } else { temp = (row[0] >> (extra_shift - DC_SHIFT)) & 0xffff; } temp += temp << 16; temp += temp << 32; ((uint64_t *)row)[0] = temp; ((uint64_t *)row)[1] = temp; return; } #else if (!(((uint32_t*)row)[1] | ((uint32_t*)row)[2] | ((uint32_t*)row)[3] | row[1])) { uint32_t temp; if (DC_SHIFT - extra_shift > 0) { temp = (row[0] << (DC_SHIFT - extra_shift)) & 0xffff; } else { temp = (row[0] >> (extra_shift - DC_SHIFT)) & 0xffff; } temp += temp << 16; ((uint32_t*)row)[0]=((uint32_t*)row)[1] = ((uint32_t*)row)[2]=((uint32_t*)row)[3] = temp; return; } #endif a0 = (W4 * row[0]) + (1 << (ROW_SHIFT - 1)); a1 = a0; a2 = a0; a3 = a0; a0 += W2 * row[2]; a1 += W6 * row[2]; a2 -= W6 * row[2]; a3 -= W2 * row[2]; b0 = MUL(W1, row[1]); MAC(b0, W3, row[3]); b1 = MUL(W3, row[1]); MAC(b1, -W7, row[3]); b2 = MUL(W5, row[1]); MAC(b2, -W1, row[3]); b3 = MUL(W7, row[1]); MAC(b3, -W5, row[3]); if (AV_RN64A(row + 4)) { a0 += W4*row[4] + W6*row[6]; a1 += - W4*row[4] - W2*row[6]; a2 += - W4*row[4] + W2*row[6]; a3 += W4*row[4] - W6*row[6]; MAC(b0, W5, row[5]); MAC(b0, W7, row[7]); MAC(b1, -W1, row[5]); MAC(b1, -W5, row[7]); MAC(b2, W7, row[5]); MAC(b2, W3, row[7]); MAC(b3, W3, row[5]); MAC(b3, -W1, row[7]); } row[0] = (a0 + b0) >> (ROW_SHIFT + extra_shift); row[7] = (a0 - b0) >> (ROW_SHIFT + extra_shift); row[1] = (a1 + b1) >> (ROW_SHIFT + extra_shift); row[6] = (a1 - b1) >> (ROW_SHIFT + extra_shift); row[2] = (a2 + b2) >> (ROW_SHIFT + extra_shift); row[5] = (a2 - b2) >> (ROW_SHIFT + extra_shift); row[3] = (a3 + b3) >> (ROW_SHIFT + extra_shift); row[4] = (a3 - b3) >> (ROW_SHIFT + extra_shift); }


static uint64_t bonito_readl(void *opaque, hwaddr addr, unsigned size) { PCIBonitoState *s = opaque; uint32_t saddr; saddr = (addr - BONITO_REGBASE) >> 2; DPRINTF("bonito_readl "TARGET_FMT_plx"\n", addr); switch (saddr) { case BONITO_INTISR: return s->regs[saddr]; default: return s->regs[saddr]; } }


static gint protobuf_verify_wiretype ( protobuf_desc_t * pb , protobuf_tag_t * tag , packet_info * pinfo , proto_tree * tree , guint8 expected_wire_type ) {
 gint len ;
 gint64 len_prefix ;
 proto_item * ti = NULL ;
 if ( expected_wire_type == tag -> wire_type ) {
 if ( expected_wire_type == PROTOBUF_WIRETYPE_LENGTHDELIMITED ) {
 len_prefix = get_varint64 ( pb -> tvb , pb -> offset , pb -> bytes_left , & len ) ;
 if ( len_prefix < 0 || len_prefix > G_MAXINT ) {
 ti = proto_tree_add_item ( tree , hf_steam_ihs_discovery_unknown_data , pb -> tvb , pb -> offset + len , pb -> bytes_left - len , ENC_NA ) ;
 expert_add_info_format ( pinfo , ti , & ei_steam_ihs_discovery_invalid_length , "Length-delimited field %" G_GUINT64_FORMAT " has length prefix %" G_GINT64_FORMAT " outside valid range (0 <= x <= G_MAXINT)." , tag -> field_number , len_prefix ) ;
 return pb -> bytes_left ;
 }
 else if ( ( ( gint ) len_prefix ) > ( pb -> bytes_left - len ) ) {
 ti = proto_tree_add_item ( tree , hf_steam_ihs_discovery_unknown_data , pb -> tvb , pb -> offset + len , pb -> bytes_left - len , ENC_NA ) ;
 expert_add_info_format ( pinfo , ti , & ei_steam_ihs_discovery_invalid_length , "Length-delimited field %" G_GUINT64_FORMAT " has length prefix %" G_GINT64_FORMAT ", but buffer is only %d bytes long." , tag -> field_number , len_prefix , ( pb -> bytes_left - len ) ) ;
 return pb -> bytes_left ;
 }
 }
 return 0 ;
 }
 len = protobuf_dissect_unknown_field ( pb , tag , pinfo , tree , & ti ) ;
 expert_add_info_format ( pinfo , ti , & ei_steam_ihs_discovery_invalid_wiretype , "Expected wiretype %d (%s) for field %" G_GUINT64_FORMAT ", but got %d (%s) instead." , expected_wire_type , protobuf_get_wiretype_name ( expected_wire_type ) , tag -> field_number , tag -> wire_type , protobuf_get_wiretype_name ( tag -> wire_type ) ) ;
 return len ;
 }


gen_intermediate_code_internal(MicroBlazeCPU *cpu, TranslationBlock *tb, bool search_pc) { CPUState *cs = CPU(cpu); CPUMBState *env = &cpu->env; uint32_t pc_start; int j, lj; struct DisasContext ctx; struct DisasContext *dc = &ctx; uint32_t next_page_start, org_flags; target_ulong npc; int num_insns; int max_insns; pc_start = tb->pc; dc->cpu = cpu; dc->tb = tb; org_flags = dc->synced_flags = dc->tb_flags = tb->flags; dc->is_jmp = DISAS_NEXT; dc->jmp = 0; dc->delayed_branch = !!(dc->tb_flags & D_FLAG); if (dc->delayed_branch) { dc->jmp = JMP_INDIRECT; } dc->pc = pc_start; dc->singlestep_enabled = cs->singlestep_enabled; dc->cpustate_changed = 0; dc->abort_at_next_insn = 0; dc->nr_nops = 0; if (pc_start & 3) { cpu_abort(cs, "Microblaze: unaligned PC=%x\n", pc_start); } if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) { #if !SIM_COMPAT qemu_log("--------------\n"); log_cpu_state(CPU(cpu), 0); #endif } next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; lj = -1; num_insns = 0; max_insns = tb->cflags & CF_COUNT_MASK; if (max_insns == 0) max_insns = CF_COUNT_MASK; gen_tb_start(tb); do { #if SIM_COMPAT if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) { tcg_gen_movi_tl(cpu_SR[SR_PC], dc->pc); gen_helper_debug(); } #endif check_breakpoint(env, dc); if (search_pc) { j = tcg_op_buf_count(); if (lj < j) { lj++; while (lj < j) tcg_ctx.gen_opc_instr_start[lj++] = 0; } tcg_ctx.gen_opc_pc[lj] = dc->pc; tcg_ctx.gen_opc_instr_start[lj] = 1; tcg_ctx.gen_opc_icount[lj] = num_insns; } /* Pretty disas. */ LOG_DIS("%8.8x:\t", dc->pc); if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO)) gen_io_start(); dc->clear_imm = 1; decode(dc, cpu_ldl_code(env, dc->pc)); if (dc->clear_imm) dc->tb_flags &= ~IMM_FLAG; dc->pc += 4; num_insns++; if (dc->delayed_branch) { dc->delayed_branch--; if (!dc->delayed_branch) { if (dc->tb_flags & DRTI_FLAG) do_rti(dc); if (dc->tb_flags & DRTB_FLAG) do_rtb(dc); if (dc->tb_flags & DRTE_FLAG) do_rte(dc); /* Clear the delay slot flag. */ dc->tb_flags &= ~D_FLAG; /* If it is a direct jump, try direct chaining. */ if (dc->jmp == JMP_INDIRECT) { eval_cond_jmp(dc, env_btarget, tcg_const_tl(dc->pc)); dc->is_jmp = DISAS_JUMP; } else if (dc->jmp == JMP_DIRECT) { t_sync_flags(dc); gen_goto_tb(dc, 0, dc->jmp_pc); dc->is_jmp = DISAS_TB_JUMP; } else if (dc->jmp == JMP_DIRECT_CC) { int l1; t_sync_flags(dc); l1 = gen_new_label(); /* Conditional jmp. */ tcg_gen_brcondi_tl(TCG_COND_NE, env_btaken, 0, l1); gen_goto_tb(dc, 1, dc->pc); gen_set_label(l1); gen_goto_tb(dc, 0, dc->jmp_pc); dc->is_jmp = DISAS_TB_JUMP; } break; } } if (cs->singlestep_enabled) { break; } } while (!dc->is_jmp && !dc->cpustate_changed && !tcg_op_buf_full() && !singlestep && (dc->pc < next_page_start) && num_insns < max_insns); npc = dc->pc; if (dc->jmp == JMP_DIRECT || dc->jmp == JMP_DIRECT_CC) { if (dc->tb_flags & D_FLAG) { dc->is_jmp = DISAS_UPDATE; tcg_gen_movi_tl(cpu_SR[SR_PC], npc); sync_jmpstate(dc); } else npc = dc->jmp_pc; } if (tb->cflags & CF_LAST_IO) gen_io_end(); /* Force an update if the per-tb cpu state has changed. */ if (dc->is_jmp == DISAS_NEXT && (dc->cpustate_changed || org_flags != dc->tb_flags)) { dc->is_jmp = DISAS_UPDATE; tcg_gen_movi_tl(cpu_SR[SR_PC], npc); } t_sync_flags(dc); if (unlikely(cs->singlestep_enabled)) { TCGv_i32 tmp = tcg_const_i32(EXCP_DEBUG); if (dc->is_jmp != DISAS_JUMP) { tcg_gen_movi_tl(cpu_SR[SR_PC], npc); } gen_helper_raise_exception(cpu_env, tmp); tcg_temp_free_i32(tmp); } else { switch(dc->is_jmp) { case DISAS_NEXT: gen_goto_tb(dc, 1, npc); break; default: case DISAS_JUMP: case DISAS_UPDATE: /* indicate that the hash table must be used to find the next TB */ tcg_gen_exit_tb(0); break; case DISAS_TB_JUMP: /* nothing more to generate */ break; } } gen_tb_end(tb, num_insns); if (search_pc) { j = tcg_op_buf_count(); lj++; while (lj <= j) tcg_ctx.gen_opc_instr_start[lj++] = 0; } else { tb->size = dc->pc - pc_start; tb->icount = num_insns; } #ifdef DEBUG_DISAS #if !SIM_COMPAT if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) { qemu_log("\n"); #if DISAS_GNU log_target_disas(env, pc_start, dc->pc - pc_start, 0); #endif qemu_log("\nisize=%d osize=%d\n", dc->pc - pc_start, tcg_op_buf_count()); } #endif #endif assert(!dc->abort_at_next_insn); }


static void test_bug9992 ( ) {
 MYSQL * mysql1 ;
 MYSQL_RES * res ;
 int rc ;
 myheader ( "test_bug9992" ) ;
 if ( ! opt_silent ) printf ( "Establishing a connection with option CLIENT_MULTI_STATEMENTS..\n" ) ;
 mysql1 = mysql_client_init ( NULL ) ;
 if ( ! mysql_real_connect ( mysql1 , opt_host , opt_user , opt_password , opt_db ? opt_db : "test" , opt_port , opt_unix_socket , CLIENT_MULTI_STATEMENTS ) ) {
 fprintf ( stderr , "Failed to connect to the database\n" ) ;
 DIE_UNLESS ( 0 ) ;
 }
 rc = mysql_query ( mysql1 , "SHOW TABLES;
 SHOW DATABASE;
 SELECT 1;
" ) ;
 if ( rc ) {
 fprintf ( stderr , "[%d] %s\n" , mysql_errno ( mysql1 ) , mysql_error ( mysql1 ) ) ;
 DIE_UNLESS ( 0 ) ;
 }
 if ( ! opt_silent ) printf ( "Testing mysql_store_result/mysql_next_result..\n" ) ;
 res = mysql_store_result ( mysql1 ) ;
 DIE_UNLESS ( res ) ;
 mysql_free_result ( res ) ;
 rc = mysql_next_result ( mysql1 ) ;
 DIE_UNLESS ( rc == 1 ) ;
 if ( ! opt_silent ) fprintf ( stdout , "Got error, as expected:\n [%d] %s\n" , mysql_errno ( mysql1 ) , mysql_error ( mysql1 ) ) ;
 mysql_close ( mysql1 ) ;
 }


TSReturnCode TSAIOWrite ( int fd , off_t offset , char * buf , const size_t bufSize , TSCont contp ) {
 sdk_assert ( sdk_sanity_check_iocore_structure ( contp ) == TS_SUCCESS ) ;
 Continuation * pCont = ( Continuation * ) contp ;
 AIOCallback * pAIO = new_AIOCallback ( ) ;
 sdk_assert ( sdk_sanity_check_null_ptr ( ( void * ) pAIO ) == TS_SUCCESS ) ;
 pAIO -> aiocb . aio_fildes = fd ;
 pAIO -> aiocb . aio_offset = offset ;
 pAIO -> aiocb . aio_buf = buf ;
 pAIO -> aiocb . aio_nbytes = bufSize ;
 pAIO -> action = pCont ;
 pAIO -> thread = pCont -> mutex -> thread_holding ;
 if ( ink_aio_write ( pAIO , 1 ) == 1 ) {
 return TS_SUCCESS ;
 }
 return TS_ERROR ;
 }


static void test_bug4026 ( ) {
 MYSQL_STMT * stmt ;
 MYSQL_BIND my_bind [ 2 ] ;
 MYSQL_TIME time_in , time_out ;
 MYSQL_TIME datetime_in , datetime_out ;
 const char * stmt_text ;
 int rc ;
 myheader ( "test_bug4026" ) ;
 stmt = mysql_stmt_init ( mysql ) ;
 stmt_text = "SELECT ?, ?" ;
 rc = mysql_stmt_prepare ( stmt , stmt_text , strlen ( stmt_text ) ) ;
 check_execute ( stmt , rc ) ;
 memset ( my_bind , 0 , sizeof ( my_bind ) ) ;
 memset ( & time_in , 0 , sizeof ( time_in ) ) ;
 memset ( & time_out , 0 , sizeof ( time_out ) ) ;
 memset ( & datetime_in , 0 , sizeof ( datetime_in ) ) ;
 memset ( & datetime_out , 0 , sizeof ( datetime_out ) ) ;
 my_bind [ 0 ] . buffer_type = MYSQL_TYPE_TIME ;
 my_bind [ 0 ] . buffer = ( void * ) & time_in ;
 my_bind [ 1 ] . buffer_type = MYSQL_TYPE_DATETIME ;
 my_bind [ 1 ] . buffer = ( void * ) & datetime_in ;
 time_in . hour = 23 ;
 time_in . minute = 59 ;
 time_in . second = 59 ;
 time_in . second_part = 123456 ;
 time_in . time_type = MYSQL_TIMESTAMP_TIME ;
 datetime_in = time_in ;
 datetime_in . year = 2003 ;
 datetime_in . month = 12 ;
 datetime_in . day = 31 ;
 datetime_in . time_type = MYSQL_TIMESTAMP_DATETIME ;
 mysql_stmt_bind_param ( stmt , my_bind ) ;
 rc = mysql_stmt_execute ( stmt ) ;
 check_execute ( stmt , rc ) ;
 my_bind [ 0 ] . buffer = ( void * ) & time_out ;
 my_bind [ 1 ] . buffer = ( void * ) & datetime_out ;
 mysql_stmt_bind_result ( stmt , my_bind ) ;
 rc = mysql_stmt_fetch ( stmt ) ;
 DIE_UNLESS ( rc == 0 ) ;
 if ( ! opt_silent ) {
 printf ( "%d:%d:%d.%lu\n" , time_out . hour , time_out . minute , time_out . second , time_out . second_part ) ;
 printf ( "%d-%d-%d %d:%d:%d.%lu\n" , datetime_out . year , datetime_out . month , datetime_out . day , datetime_out . hour , datetime_out . minute , datetime_out . second , datetime_out . second_part ) ;
 }
 DIE_UNLESS ( memcmp ( & time_in , & time_out , sizeof ( time_in ) ) == 0 ) ;
 DIE_UNLESS ( memcmp ( & datetime_in , & datetime_out , sizeof ( datetime_in ) ) == 0 ) ;
 mysql_stmt_close ( stmt ) ;
 }


static long do_rmdir(int dfd, const char __user *pathname)
{
	int error = 0;
	char * name;
	struct dentry *dentry;
	struct nameidata nd;

	name = getname(pathname);
	if(IS_ERR(name))
		return PTR_ERR(name);

	error = do_path_lookup(dfd, name, LOOKUP_PARENT, &nd);
	if (error)
		goto exit;

	switch(nd.last_type) {
		case LAST_DOTDOT:
			error = -ENOTEMPTY;
			goto exit1;
		case LAST_DOT:
			error = -EINVAL;
			goto exit1;
		case LAST_ROOT:
			error = -EBUSY;
			goto exit1;
	}
	mutex_lock_nested(&nd.path.dentry->d_inode->i_mutex, I_MUTEX_PARENT);
	dentry = lookup_hash(&nd);
	error = PTR_ERR(dentry);
	if (IS_ERR(dentry))
		goto exit2;
	error = mnt_want_write(nd.path.mnt);
	if (error)
		goto exit3;
	error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
	mnt_drop_write(nd.path.mnt);
exit3:
	dput(dentry);
exit2:
	mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
exit1:
	path_put(&nd.path);
exit:
	putname(name);
	return error;
}


static int show_programs ( WriterContext * w , InputFile * ifile ) {
 AVFormatContext * fmt_ctx = ifile -> fmt_ctx ;
 int i , ret = 0 ;
 writer_print_section_header ( w , SECTION_ID_PROGRAMS ) ;
 for ( i = 0 ;
 i < fmt_ctx -> nb_programs ;
 i ++ ) {
 AVProgram * program = fmt_ctx -> programs [ i ] ;
 if ( ! program ) continue ;
 ret = show_program ( w , ifile , program ) ;
 if ( ret < 0 ) break ;
 }
 writer_print_section_footer ( w ) ;
 return ret ;
 }


static int vdpau_h264_end_frame ( AVCodecContext * avctx ) {
 AVVDPAUContext * hwctx = avctx -> hwaccel_context ;
 H264Context * h = avctx -> priv_data ;
 VdpVideoSurface surf = ff_vdpau_get_surface_id ( h -> cur_pic_ptr ) ;
 hwctx -> render ( hwctx -> decoder , surf , ( void * ) & hwctx -> info , hwctx -> bitstream_buffers_used , hwctx -> bitstream_buffers ) ;
 ff_h264_draw_horiz_band ( h , 0 , h -> avctx -> height ) ;
 hwctx -> bitstream_buffers_used = 0 ;
 return 0 ;
 }


void set_sys_var ( const char * data , u_long size , u_short def ) {
 set_var ( & ext_sys_var , data , size , def ) ;
 }


static void omap_pwl_update(struct omap_pwl_s *s) { int output = (s->clk && s->enable) ? s->level : 0; if (output != s->output) { s->output = output; printf("%s: Backlight now at %i/256\n", __FUNCTION__, output); } }


static void amdvi_realize(DeviceState *dev, Error **err) { int ret = 0; AMDVIState *s = AMD_IOMMU_DEVICE(dev); X86IOMMUState *x86_iommu = X86_IOMMU_DEVICE(dev); MachineState *ms = MACHINE(qdev_get_machine()); MachineClass *mc = MACHINE_GET_CLASS(ms); PCMachineState *pcms = PC_MACHINE(object_dynamic_cast(OBJECT(ms), TYPE_PC_MACHINE)); PCIBus *bus; if (!pcms) { error_setg(err, "Machine-type '%s' not supported by amd-iommu", mc->name); return; } bus = pcms->bus; s->iotlb = g_hash_table_new_full(amdvi_uint64_hash, amdvi_uint64_equal, g_free, g_free); /* This device should take care of IOMMU PCI properties */ x86_iommu->type = TYPE_AMD; qdev_set_parent_bus(DEVICE(&s->pci), &bus->qbus); object_property_set_bool(OBJECT(&s->pci), true, "realized", err); ret = pci_add_capability(&s->pci.dev, AMDVI_CAPAB_ID_SEC, 0, AMDVI_CAPAB_SIZE, err); if (ret < 0) { return; } s->capab_offset = ret; ret = pci_add_capability(&s->pci.dev, PCI_CAP_ID_MSI, 0, AMDVI_CAPAB_REG_SIZE, err); if (ret < 0) { return; } ret = pci_add_capability(&s->pci.dev, PCI_CAP_ID_HT, 0, AMDVI_CAPAB_REG_SIZE, err); if (ret < 0) { return; } /* set up MMIO */ memory_region_init_io(&s->mmio, OBJECT(s), &mmio_mem_ops, s, "amdvi-mmio", AMDVI_MMIO_SIZE); sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->mmio); sysbus_mmio_map(SYS_BUS_DEVICE(s), 0, AMDVI_BASE_ADDR); pci_setup_iommu(bus, amdvi_host_dma_iommu, s); s->devid = object_property_get_int(OBJECT(&s->pci), "addr", err); msi_init(&s->pci.dev, 0, 1, true, false, err); amdvi_init(s); }


int parse_CColumnGroup ( tvbuff_t * tvb , int offset , proto_tree * parent_tree , proto_tree * pad_tree _U_ , const char * fmt , ... ) {
 proto_tree * tree ;
 proto_item * item , * ti ;
 va_list ap ;
 const char * txt ;
 guint32 count , groupPid , i ;
 va_start ( ap , fmt ) ;
 txt = wmem_strdup_vprintf ( wmem_packet_scope ( ) , fmt , ap ) ;
 va_end ( ap ) ;
 tree = proto_tree_add_subtree ( parent_tree , tvb , offset , 0 , ett_CColumnGroup , & item , txt ) ;
 count = tvb_get_letohl ( tvb , offset ) ;
 proto_tree_add_uint ( tree , hf_mswsp_ccolumngroup_count , tvb , offset , 4 , count ) ;
 offset += 4 ;
 groupPid = tvb_get_letohl ( tvb , offset ) ;
 ti = proto_tree_add_uint ( tree , hf_mswsp_ccolumngroup_grouppid , tvb , offset , 4 , groupPid ) ;
 if ( ( 0xFFFF0000 & groupPid ) == 0x7FFF0000 ) {
 proto_item_append_text ( ti , " Idx: %u" , groupPid & 0xFFFF ) ;
 }
 else {
 proto_item_append_text ( ti , "<Invalid>" ) ;
 }
 offset += 4 ;
 for ( i = 0 ;
 i < count ;
 i ++ ) {
 guint32 pid , weight ;
 pid = tvb_get_letohl ( tvb , offset ) ;
 weight = tvb_get_letohl ( tvb , offset + 4 ) ;
 proto_tree_add_uint_format ( tree , hf_mswsp_ccolumngroup_pid , tvb , offset , 8 , pid , "Props[%u]: pid: %u weight: %u" , i , pid , weight ) ;
 offset += 8 ;
 }
 proto_item_set_end ( item , tvb , offset ) ;
 return offset ;
 }


int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
{
	int len;

	len = PTR_ERR(link);
	if (IS_ERR(link))
		goto out;

	len = strlen(link);
	if (len > (unsigned) buflen)
		len = buflen;
	if (copy_to_user(buffer, link, len))
		len = -EFAULT;
out:
	return len;
}


struct file *do_filp_open(int dfd, const char *pathname,
		int open_flag, int mode)
{
	struct file *filp;
	struct nameidata nd;
	int acc_mode, error;
	struct path path;
	struct dentry *dir;
	int count = 0;
	int will_write;
	int flag = open_to_namei_flags(open_flag);

	acc_mode = ACC_MODE(flag);

	/* O_TRUNC implies we need access checks for write permissions */
	if (flag & O_TRUNC)
		acc_mode |= MAY_WRITE;

	/* Allow the LSM permission hook to distinguish append
	   access from general write access. */
	if (flag & O_APPEND)
		acc_mode |= MAY_APPEND;

	/*
	 * The simplest case - just a plain lookup.
	 */
	if (!(flag & O_CREAT)) {
		error = path_lookup_open(dfd, pathname, lookup_flags(flag),
					 &nd, flag);
		if (error)
			return ERR_PTR(error);
		goto ok;
	}

	/*
	 * Create - we need to know the parent.
	 */
	error = path_lookup_create(dfd, pathname, LOOKUP_PARENT,
				   &nd, flag, mode);
	if (error)
		return ERR_PTR(error);

	/*
	 * We have the parent and last component. First of all, check
	 * that we are not asked to creat(2) an obvious directory - that
	 * will not do.
	 */
	error = -EISDIR;
	if (nd.last_type != LAST_NORM || nd.last.name[nd.last.len])
		goto exit;

	dir = nd.path.dentry;
	nd.flags &= ~LOOKUP_PARENT;
	mutex_lock(&dir->d_inode->i_mutex);
	path.dentry = lookup_hash(&nd);
	path.mnt = nd.path.mnt;

do_last:
	error = PTR_ERR(path.dentry);
	if (IS_ERR(path.dentry)) {
		mutex_unlock(&dir->d_inode->i_mutex);
		goto exit;
	}

	if (IS_ERR(nd.intent.open.file)) {
		error = PTR_ERR(nd.intent.open.file);
		goto exit_mutex_unlock;
	}

	/* Negative dentry, just create the file */
	if (!path.dentry->d_inode) {
		/*
		 * This write is needed to ensure that a
		 * ro->rw transition does not occur between
		 * the time when the file is created and when
		 * a permanent write count is taken through
		 * the 'struct file' in nameidata_to_filp().
		 */
		error = mnt_want_write(nd.path.mnt);
		if (error)
			goto exit_mutex_unlock;
		error = __open_namei_create(&nd, &path, flag, mode);
		if (error) {
			mnt_drop_write(nd.path.mnt);
			goto exit;
		}
		filp = nameidata_to_filp(&nd, open_flag);
		mnt_drop_write(nd.path.mnt);
		return filp;
	}

	/*
	 * It already exists.
	 */
	mutex_unlock(&dir->d_inode->i_mutex);
	audit_inode(pathname, path.dentry);

	error = -EEXIST;
	if (flag & O_EXCL)
		goto exit_dput;

	if (__follow_mount(&path)) {
		error = -ELOOP;
		if (flag & O_NOFOLLOW)
			goto exit_dput;
	}

	error = -ENOENT;
	if (!path.dentry->d_inode)
		goto exit_dput;
	if (path.dentry->d_inode->i_op && path.dentry->d_inode->i_op->follow_link)
		goto do_link;

	path_to_nameidata(&path, &nd);
	error = -EISDIR;
	if (path.dentry->d_inode && S_ISDIR(path.dentry->d_inode->i_mode))
		goto exit;
ok:
	/*
	 * Consider:
	 * 1. may_open() truncates a file
	 * 2. a rw->ro mount transition occurs
	 * 3. nameidata_to_filp() fails due to
	 *    the ro mount.
	 * That would be inconsistent, and should
	 * be avoided. Taking this mnt write here
	 * ensures that (2) can not occur.
	 */
	will_write = open_will_write_to_fs(flag, nd.path.dentry->d_inode);
	if (will_write) {
		error = mnt_want_write(nd.path.mnt);
		if (error)
			goto exit;
	}
	error = may_open(&nd, acc_mode, flag);
	if (error) {
		if (will_write)
			mnt_drop_write(nd.path.mnt);
		goto exit;
	}
	filp = nameidata_to_filp(&nd, open_flag);
	/*
	 * It is now safe to drop the mnt write
	 * because the filp has had a write taken
	 * on its behalf.
	 */
	if (will_write)
		mnt_drop_write(nd.path.mnt);
	return filp;

exit_mutex_unlock:
	mutex_unlock(&dir->d_inode->i_mutex);
exit_dput:
	path_put_conditional(&path, &nd);
exit:
	if (!IS_ERR(nd.intent.open.file))
		release_open_intent(&nd);
	path_put(&nd.path);
	return ERR_PTR(error);

do_link:
	error = -ELOOP;
	if (flag & O_NOFOLLOW)
		goto exit_dput;
	/*
	 * This is subtle. Instead of calling do_follow_link() we do the
	 * thing by hands. The reason is that this way we have zero link_count
	 * and path_walk() (called from ->follow_link) honoring LOOKUP_PARENT.
	 * After that we have the parent and last component, i.e.
	 * we are in the same situation as after the first path_walk().
	 * Well, almost - if the last component is normal we get its copy
	 * stored in nd->last.name and we will have to putname() it when we
	 * are done. Procfs-like symlinks just set LAST_BIND.
	 */
	nd.flags |= LOOKUP_PARENT;
	error = security_inode_follow_link(path.dentry, &nd);
	if (error)
		goto exit_dput;
	error = __do_follow_link(&path, &nd);
	if (error) {
		/* Does someone understand code flow here? Or it is only
		 * me so stupid? Anathema to whoever designed this non-sense
		 * with "intent.open".
		 */
		release_open_intent(&nd);
		return ERR_PTR(error);
	}
	nd.flags &= ~LOOKUP_PARENT;
	if (nd.last_type == LAST_BIND)
		goto ok;
	error = -EISDIR;
	if (nd.last_type != LAST_NORM)
		goto exit;
	if (nd.last.name[nd.last.len]) {
		__putname(nd.last.name);
		goto exit;
	}
	error = -ELOOP;
	if (count++==32) {
		__putname(nd.last.name);
		goto exit;
	}
	dir = nd.path.dentry;
	mutex_lock(&dir->d_inode->i_mutex);
	path.dentry = lookup_hash(&nd);
	path.mnt = nd.path.mnt;
	__putname(nd.last.name);
	goto do_last;
}


void xen_map_cache_init(phys_offset_to_gaddr_t f, void *opaque) { unsigned long size; struct rlimit rlimit_as; mapcache = g_malloc0(sizeof (MapCache)); mapcache->phys_offset_to_gaddr = f; mapcache->opaque = opaque; qemu_mutex_init(&mapcache->lock); QTAILQ_INIT(&mapcache->locked_entries); if (geteuid() == 0) { rlimit_as.rlim_cur = RLIM_INFINITY; rlimit_as.rlim_max = RLIM_INFINITY; mapcache->max_mcache_size = MCACHE_MAX_SIZE; } else { getrlimit(RLIMIT_AS, &rlimit_as); rlimit_as.rlim_cur = rlimit_as.rlim_max; if (rlimit_as.rlim_max != RLIM_INFINITY) { fprintf(stderr, "Warning: QEMU's maximum size of virtual" " memory is not infinity.\n"); } if (rlimit_as.rlim_max < MCACHE_MAX_SIZE + NON_MCACHE_MEMORY_SIZE) { mapcache->max_mcache_size = rlimit_as.rlim_max - NON_MCACHE_MEMORY_SIZE; } else { mapcache->max_mcache_size = MCACHE_MAX_SIZE; } } setrlimit(RLIMIT_AS, &rlimit_as); mapcache->nr_buckets = (((mapcache->max_mcache_size >> XC_PAGE_SHIFT) + (1UL << (MCACHE_BUCKET_SHIFT - XC_PAGE_SHIFT)) - 1) >> (MCACHE_BUCKET_SHIFT - XC_PAGE_SHIFT)); size = mapcache->nr_buckets * sizeof (MapCacheEntry); size = (size + XC_PAGE_SIZE - 1) & ~(XC_PAGE_SIZE - 1); DPRINTF("%s, nr_buckets = %lx size %lu\n", __func__, mapcache->nr_buckets, size); mapcache->entry = g_malloc0(size); }


static gboolean delete_cb ( GtkDialog * dialog ) {
 gtk_dialog_response ( dialog , GTK_RESPONSE_DELETE_EVENT ) ;
 return TRUE ;
 }


static void pdf_show_image ( fz_context * ctx , pdf_run_processor * pr , fz_image * image ) {
 pdf_gstate * gstate = pr -> gstate + pr -> gtop ;
 fz_matrix image_ctm ;
 fz_rect bbox ;
 softmask_save softmask = {
 NULL }
 ;
 if ( pr -> super . hidden ) return ;
 image_ctm = gstate -> ctm ;
 fz_pre_scale ( fz_pre_translate ( & image_ctm , 0 , 1 ) , 1 , - 1 ) ;
 bbox = fz_unit_rect ;
 fz_transform_rect ( & bbox , & image_ctm ) ;
 if ( image -> mask ) {
 if ( gstate -> blendmode ) fz_begin_group ( ctx , pr -> dev , & bbox , NULL , 0 , 0 , gstate -> blendmode , 1 ) ;
 fz_clip_image_mask ( ctx , pr -> dev , image -> mask , & image_ctm , & bbox ) ;
 }
 else gstate = pdf_begin_group ( ctx , pr , & bbox , & softmask ) ;
 if ( ! image -> colorspace ) {
 switch ( gstate -> fill . kind ) {
 case PDF_MAT_NONE : break ;
 case PDF_MAT_COLOR : fz_fill_image_mask ( ctx , pr -> dev , image , & image_ctm , gstate -> fill . colorspace , gstate -> fill . v , gstate -> fill . alpha , & gstate -> fill . color_params ) ;
 break ;
 case PDF_MAT_PATTERN : if ( gstate -> fill . pattern ) {
 fz_clip_image_mask ( ctx , pr -> dev , image , & image_ctm , & bbox ) ;
 pdf_show_pattern ( ctx , pr , gstate -> fill . pattern , & pr -> gstate [ gstate -> fill . gstate_num ] , & bbox , PDF_FILL ) ;
 fz_pop_clip ( ctx , pr -> dev ) ;
 }
 break ;
 case PDF_MAT_SHADE : if ( gstate -> fill . shade ) {
 fz_clip_image_mask ( ctx , pr -> dev , image , & image_ctm , & bbox ) ;
 fz_fill_shade ( ctx , pr -> dev , gstate -> fill . shade , & pr -> gstate [ gstate -> fill . gstate_num ] . ctm , gstate -> fill . alpha , & gstate -> fill . color_params ) ;
 fz_pop_clip ( ctx , pr -> dev ) ;
 }
 break ;
 }
 }
 else {
 fz_fill_image ( ctx , pr -> dev , image , & image_ctm , gstate -> fill . alpha , & gstate -> fill . color_params ) ;
 }
 if ( image -> mask ) {
 fz_pop_clip ( ctx , pr -> dev ) ;
 if ( gstate -> blendmode ) fz_end_group ( ctx , pr -> dev ) ;
 }
 else pdf_end_group ( ctx , pr , & softmask ) ;
 }


void aio_set_fd_handler(AioContext *ctx, int fd, IOHandler *io_read, IOHandler *io_write, AioFlushHandler *io_flush, void *opaque) { AioHandler *node; node = find_aio_handler(ctx, fd); /* Are we deleting the fd handler? */ if (!io_read && !io_write) { if (node) { g_source_remove_poll(&ctx->source, &node->pfd); /* If the lock is held, just mark the node as deleted */ if (ctx->walking_handlers) { node->deleted = 1; node->pfd.revents = 0; } else { /* Otherwise, delete it for real. We can't just mark it as * deleted because deleted nodes are only cleaned up after * releasing the walking_handlers lock. */ QLIST_REMOVE(node, node); g_free(node); } } } else { if (node == NULL) { /* Alloc and insert if it's not already there */ node = g_malloc0(sizeof(AioHandler)); node->pfd.fd = fd; QLIST_INSERT_HEAD(&ctx->aio_handlers, node, node); g_source_add_poll(&ctx->source, &node->pfd); } /* Update handler with latest information */ node->io_read = io_read; node->io_write = io_write; node->io_flush = io_flush; node->opaque = opaque; node->pollfds_idx = -1; node->pfd.events = (io_read ? G_IO_IN | G_IO_HUP | G_IO_ERR : 0); node->pfd.events |= (io_write ? G_IO_OUT | G_IO_ERR : 0); } aio_notify(ctx); }


const char *qdict_get_try_str(const QDict *qdict, const char *key) { QObject *obj; obj = qdict_get(qdict, key); if (!obj || qobject_type(obj) != QTYPE_QSTRING) return NULL; return qstring_get_str(qobject_to_qstring(obj)); }


snd_seq_oss_synth_addr(struct seq_oss_devinfo *dp, int dev, struct snd_seq_event *ev)
{
	if (! snd_seq_oss_synth_is_valid(dp, dev))
		return -EINVAL;
	snd_seq_oss_fill_addr(dp, ev, dp->synths[dev].arg.addr.client,
			      dp->synths[dev].arg.addr.port);
	return 0;
}


vnc_display_setup_auth(VncDisplay *vd, bool password, bool sasl, bool websocket, Error **errp) { /* * We have a choice of 3 authentication options * * 1. none * 2. vnc * 3. sasl * * The channel can be run in 2 modes * * 1. clear * 2. tls * * And TLS can use 2 types of credentials * * 1. anon * 2. x509 * * We thus have 9 possible logical combinations * * 1. clear + none * 2. clear + vnc * 3. clear + sasl * 4. tls + anon + none * 5. tls + anon + vnc * 6. tls + anon + sasl * 7. tls + x509 + none * 8. tls + x509 + vnc * 9. tls + x509 + sasl * * These need to be mapped into the VNC auth schemes * in an appropriate manner. In regular VNC, all the * TLS options get mapped into VNC_AUTH_VENCRYPT * sub-auth types. * * In websockets, the https:// protocol already provides * TLS support, so there is no need to make use of the * VeNCrypt extension. Furthermore, websockets browser * clients could not use VeNCrypt even if they wanted to, * as they cannot control when the TLS handshake takes * place. Thus there is no option but to rely on https://, * meaning combinations 4->6 and 7->9 will be mapped to * VNC auth schemes in the same way as combos 1->3. * * Regardless of fact that we have a different mapping to * VNC auth mechs for plain VNC vs websockets VNC, the end * result has the same security characteristics. */ if (password) { if (vd->tlscreds) { vd->auth = VNC_AUTH_VENCRYPT; if (object_dynamic_cast(OBJECT(vd->tlscreds), TYPE_QCRYPTO_TLS_CREDS_X509)) { VNC_DEBUG("Initializing VNC server with x509 password auth\n"); vd->subauth = VNC_AUTH_VENCRYPT_X509VNC; } else if (object_dynamic_cast(OBJECT(vd->tlscreds), TYPE_QCRYPTO_TLS_CREDS_ANON)) { VNC_DEBUG("Initializing VNC server with TLS password auth\n"); vd->subauth = VNC_AUTH_VENCRYPT_TLSVNC; } else { error_setg(errp, "Unsupported TLS cred type %s", object_get_typename(OBJECT(vd->tlscreds))); return -1; } } else { VNC_DEBUG("Initializing VNC server with password auth\n"); vd->auth = VNC_AUTH_VNC; vd->subauth = VNC_AUTH_INVALID; } if (websocket) { vd->ws_auth = VNC_AUTH_VNC; } else { vd->ws_auth = VNC_AUTH_INVALID; } } else if (sasl) { if (vd->tlscreds) { vd->auth = VNC_AUTH_VENCRYPT; if (object_dynamic_cast(OBJECT(vd->tlscreds), TYPE_QCRYPTO_TLS_CREDS_X509)) { VNC_DEBUG("Initializing VNC server with x509 SASL auth\n"); vd->subauth = VNC_AUTH_VENCRYPT_X509SASL; } else if (object_dynamic_cast(OBJECT(vd->tlscreds), TYPE_QCRYPTO_TLS_CREDS_ANON)) { VNC_DEBUG("Initializing VNC server with TLS SASL auth\n"); vd->subauth = VNC_AUTH_VENCRYPT_TLSSASL; } else { error_setg(errp, "Unsupported TLS cred type %s", object_get_typename(OBJECT(vd->tlscreds))); return -1; } } else { VNC_DEBUG("Initializing VNC server with SASL auth\n"); vd->auth = VNC_AUTH_SASL; vd->subauth = VNC_AUTH_INVALID; } if (websocket) { vd->ws_auth = VNC_AUTH_SASL; } else { vd->ws_auth = VNC_AUTH_INVALID; } } else { if (vd->tlscreds) { vd->auth = VNC_AUTH_VENCRYPT; if (object_dynamic_cast(OBJECT(vd->tlscreds), TYPE_QCRYPTO_TLS_CREDS_X509)) { VNC_DEBUG("Initializing VNC server with x509 no auth\n"); vd->subauth = VNC_AUTH_VENCRYPT_X509NONE; } else if (object_dynamic_cast(OBJECT(vd->tlscreds), TYPE_QCRYPTO_TLS_CREDS_ANON)) { VNC_DEBUG("Initializing VNC server with TLS no auth\n"); vd->subauth = VNC_AUTH_VENCRYPT_TLSNONE; } else { error_setg(errp, "Unsupported TLS cred type %s", object_get_typename(OBJECT(vd->tlscreds))); return -1; } } else { VNC_DEBUG("Initializing VNC server with no auth\n"); vd->auth = VNC_AUTH_NONE; vd->subauth = VNC_AUTH_INVALID; } if (websocket) { vd->ws_auth = VNC_AUTH_NONE; } else { vd->ws_auth = VNC_AUTH_INVALID; } } return 0; }


reset_channels(struct seq_oss_synthinfo *info)
{
	int i;
	if (info->ch == NULL || ! info->nr_voices)
		return;
	for (i = 0; i < info->nr_voices; i++) {
		info->ch[i].note = -1;
		info->ch[i].vel = 0;
	}
}


static int parse_funcname_pattern(const char *var, const char *ep, const char *value)
{
	const char *name;
	int namelen;
	struct funcname_pattern *pp;

	name = var + 5; /* "diff." */
	namelen = ep - name;

	for (pp = funcname_pattern_list; pp; pp = pp->next)
		if (!strncmp(pp->name, name, namelen) && !pp->name[namelen])
			break;
	if (!pp) {
		pp = xcalloc(1, sizeof(*pp));
		pp->name = xmemdupz(name, namelen);
		pp->next = funcname_pattern_list;
		funcname_pattern_list = pp;
	}
	free(pp->pattern);
	pp->pattern = xstrdup(value);
	return 0;
}


static int rev_compare_tree(struct rev_info *revs, struct tree *t1, struct tree *t2)
{
	if (!t1)
		return REV_TREE_NEW;
	if (!t2)
		return REV_TREE_DIFFERENT;
	tree_difference = REV_TREE_SAME;
	DIFF_OPT_CLR(&revs->pruning, HAS_CHANGES);
	if (diff_tree_sha1(t1->object.sha1, t2->object.sha1, "",
			   &revs->pruning) < 0)
		return REV_TREE_DIFFERENT;
	return tree_difference;
}


static void prepare_temp_file(const char *name,
			      struct diff_tempfile *temp,
			      struct diff_filespec *one)
{
	if (!DIFF_FILE_VALID(one)) {
	not_a_valid_file:
		/* A '-' entry produces this for file-2, and
		 * a '+' entry produces this for file-1.
		 */
		temp->name = "/dev/null";
		strcpy(temp->hex, ".");
		strcpy(temp->mode, ".");
		return;
	}

	if (!one->sha1_valid ||
	    reuse_worktree_file(name, one->sha1, 1)) {
		struct stat st;
		if (lstat(name, &st) < 0) {
			if (errno == ENOENT)
				goto not_a_valid_file;
			die("stat(%s): %s", name, strerror(errno));
		}
		if (S_ISLNK(st.st_mode)) {
			int ret;
			char buf[PATH_MAX + 1]; /* ought to be SYMLINK_MAX */
			size_t sz = xsize_t(st.st_size);
			if (sizeof(buf) <= st.st_size)
				die("symlink too long: %s", name);
			ret = readlink(name, buf, sz);
			if (ret < 0)
				die("readlink(%s)", name);
			prep_temp_blob(temp, buf, sz,
				       (one->sha1_valid ?
					one->sha1 : null_sha1),
				       (one->sha1_valid ?
					one->mode : S_IFLNK));
		}
		else {
			/* we can borrow from the file in the work tree */
			temp->name = name;
			if (!one->sha1_valid)
				strcpy(temp->hex, sha1_to_hex(null_sha1));
			else
				strcpy(temp->hex, sha1_to_hex(one->sha1));
			/* Even though we may sometimes borrow the
			 * contents from the work tree, we always want
			 * one->mode.  mode is trustworthy even when
			 * !(one->sha1_valid), as long as
			 * DIFF_FILE_VALID(one).
			 */
			sprintf(temp->mode, "%06o", one->mode);
		}
		return;
	}
	else {
		if (diff_populate_filespec(one, 0))
			die("cannot read data blob for %s", one->path);
		prep_temp_blob(temp, one->data, one->size,
			       one->sha1, one->mode);
	}
}


static always_inline void gen_qemu_ldf (TCGv t0, TCGv t1, int flags) { TCGv tmp = tcg_temp_new(TCG_TYPE_I32); tcg_gen_qemu_ld32u(tmp, t1, flags); tcg_gen_helper_1_1(helper_memory_to_f, t0, tmp); tcg_temp_free(tmp); }


static Node * substitute_actual_parameters_mutator ( Node * node , substitute_actual_parameters_context * context ) {
 if ( node == NULL ) return NULL ;
 if ( IsA ( node , Param ) ) {
 Param * param = ( Param * ) node ;
 if ( param -> paramkind != PARAM_EXTERN ) elog ( ERROR , "unexpected paramkind: %d" , ( int ) param -> paramkind ) ;
 if ( param -> paramid <= 0 || param -> paramid > context -> nargs ) elog ( ERROR , "invalid paramid: %d" , param -> paramid ) ;
 context -> usecounts [ param -> paramid - 1 ] ++ ;
 return list_nth ( context -> args , param -> paramid - 1 ) ;
 }
 return expression_tree_mutator ( node , substitute_actual_parameters_mutator , ( void * ) context ) ;
 }


static inline PageDesc *page_find(target_ulong index) { PageDesc *p; p = l1_map[index >> L2_BITS]; if (!p) return 0; return p + (index & (L2_SIZE - 1)); }


int diff_queue_is_empty(void)
{
	struct diff_queue_struct *q = &diff_queued_diff;
	int i;
	for (i = 0; i < q->nr; i++)
		if (!diff_unmodified_pair(q->queue[i]))
			return 0;
	return 1;
}


static void inject_file ( const char * path , char * file ) {
 char * filename ;
 int fd ;
 void * buf ;
 size_t size , ret ;
 DEBUG_MSG ( "inject_file %s/%s" , path , file ) ;
 SAFE_CALLOC ( filename , strlen ( path ) + strlen ( file ) + 2 , sizeof ( char ) ) ;
 snprintf ( filename , strlen ( path ) + strlen ( file ) + 2 , "%s/%s" , path , file ) ;
 if ( ( fd = open ( filename , O_RDONLY | O_BINARY ) ) == - 1 ) {
 ui_error ( "Can't load the file" ) ;
 return ;
 }
 SAFE_FREE ( filename ) ;
 size = lseek ( fd , 0 , SEEK_END ) ;
 SAFE_CALLOC ( buf , size , sizeof ( char ) ) ;
 lseek ( fd , 0 , SEEK_SET ) ;
 ret = read ( fd , buf , size ) ;
 close ( fd ) ;
 if ( ret != size ) {
 ui_error ( "Cannot read the file into memory" ) ;
 return ;
 }
 if ( wdg_c1 -> flags & WDG_OBJ_FOCUSED ) {
 user_inject ( buf , size , curr_conn , 1 ) ;
 }
 else if ( wdg_c2 -> flags & WDG_OBJ_FOCUSED ) {
 user_inject ( buf , size , curr_conn , 2 ) ;
 }
 SAFE_FREE ( buf ) ;
 }


static int count_paths(const char **paths)
{
	int i = 0;
	while (*paths++)
		i++;
	return i;
}


static ExitStatus trans_fop_wew_0e(DisasContext *ctx, uint32_t insn, const DisasInsn *di) { unsigned rt = assemble_rt64(insn); unsigned ra = assemble_ra64(insn); return do_fop_wew(ctx, rt, ra, di->f_wew); }


static hb_ ## name ## _t * _hb_ ## name ## _reference ( const hb_ ## name ## _t * l ) {
 hb_ ## name ## _t * c = ( hb_ ## name ## _t * ) calloc ( 1 , sizeof ( hb_ ## name ## _t ) ) ;
 if ( unlikely ( ! c ) ) return NULL ;
 * c = * l ;
 return c ;
 }
 static void _hb_ ## name ## _destroy ( hb_ ## name ## _t * l ) {
 free ( l ) ;
 }
 HB_DEFINE_BOXED_TYPE ( name , _hb_ ## name ## _reference , _hb_ ## name ## _destroy ) ;
 HB_DEFINE_OBJECT_TYPE ( buffer ) HB_DEFINE_OBJECT_TYPE ( blob ) HB_DEFINE_OBJECT_TYPE ( face ) HB_DEFINE_OBJECT_TYPE ( font ) HB_DEFINE_OBJECT_TYPE ( font_funcs ) HB_DEFINE_OBJECT_TYPE ( set ) HB_DEFINE_OBJECT_TYPE ( shape_plan ) HB_DEFINE_OBJECT_TYPE ( unicode_funcs ) HB_DEFINE_VALUE_TYPE ( feature ) HB_DEFINE_VALUE_TYPE ( glyph_info ) HB_DEFINE_VALUE_TYPE ( glyph_position )


extern int name ( int ) __THROW __exctype ( isalnum ) ;
 __exctype ( isalpha ) ;
 __exctype ( iscntrl ) ;
 __exctype ( isdigit ) ;
 __exctype ( islower ) ;
 __exctype ( isgraph ) ;
 __exctype ( isprint ) ;
 __exctype ( ispunct ) ;
 __exctype ( isspace ) ;
 __exctype ( isupper ) ;
 __exctype ( isxdigit ) ;
 extern int tolower ( int __c ) __THROW ;
 extern int toupper ( int __c ) __THROW ;
 # ifdef __USE_ISOC99 __exctype ( isblank )


static void print_word(FILE *file, struct diff_words_buffer *buffer, int len, int color,
		int suppress_newline)
{
	const char *ptr;
	int eol = 0;

	if (len == 0)
		return;

	ptr  = buffer->text.ptr + buffer->current;
	buffer->current += len;

	if (ptr[len - 1] == '\n') {
		eol = 1;
		len--;
	}

	fputs(diff_get_color(1, color), file);
	fwrite(ptr, len, 1, file);
	fputs(diff_get_color(1, DIFF_RESET), file);

	if (eol) {
		if (suppress_newline)
			buffer->suppressed_newline = 1;
		else
			putc('\n', file);
	}
}


static void add_message_grep(struct rev_info *revs, const char *pattern)
{
	add_grep(revs, pattern, GREP_PATTERN_BODY);
}


static void run_external_diff(const char *pgm,
			      const char *name,
			      const char *other,
			      struct diff_filespec *one,
			      struct diff_filespec *two,
			      const char *xfrm_msg,
			      int complete_rewrite)
{
	const char *spawn_arg[10];
	struct diff_tempfile *temp = diff_temp;
	int retval;
	static int atexit_asked = 0;
	const char *othername;
	const char **arg = &spawn_arg[0];

	othername = (other? other : name);
	if (one && two) {
		prepare_temp_file(name, &temp[0], one);
		prepare_temp_file(othername, &temp[1], two);
		if (! atexit_asked &&
		    (temp[0].name == temp[0].tmp_path ||
		     temp[1].name == temp[1].tmp_path)) {
			atexit_asked = 1;
			atexit(remove_tempfile);
		}
		signal(SIGINT, remove_tempfile_on_signal);
	}

	if (one && two) {
		*arg++ = pgm;
		*arg++ = name;
		*arg++ = temp[0].name;
		*arg++ = temp[0].hex;
		*arg++ = temp[0].mode;
		*arg++ = temp[1].name;
		*arg++ = temp[1].hex;
		*arg++ = temp[1].mode;
		if (other) {
			*arg++ = other;
			*arg++ = xfrm_msg;
		}
	} else {
		*arg++ = pgm;
		*arg++ = name;
	}
	*arg = NULL;
	fflush(NULL);
	retval = run_command_v_opt(spawn_arg, 0);
	remove_tempfile();
	if (retval) {
		fprintf(stderr, "external diff died, stopping at %s.\n", name);
		exit(1);
	}
}


static int ehci_fill_queue(EHCIPacket *p) { USBEndpoint *ep = p->packet.ep; EHCIQueue *q = p->queue; EHCIqtd qtd = p->qtd; uint32_t qtdaddr; for (;;) { if (NLPTR_TBIT(qtd.next) != 0) { qtdaddr = qtd.next; /* * Detect circular td lists, Windows creates these, counting on the * active bit going low after execution to make the queue stop. */ QTAILQ_FOREACH(p, &q->packets, next) { if (p->qtdaddr == qtdaddr) { goto leave; if (get_dwords(q->ehci, NLPTR_GET(qtdaddr), (uint32_t *) &qtd, sizeof(EHCIqtd) >> 2) < 0) { return -1; ehci_trace_qtd(q, NLPTR_GET(qtdaddr), &qtd); if (!(qtd.token & QTD_TOKEN_ACTIVE)) { p = ehci_alloc_packet(q); p->qtdaddr = qtdaddr; p->qtd = qtd; if (ehci_execute(p, "queue") == -1) { return -1; assert(p->packet.status == USB_RET_ASYNC); p->async = EHCI_ASYNC_INFLIGHT; leave: usb_device_flush_ep_queue(ep->dev, ep); return 1;


void bdrv_close(BlockDriverState *bs) { if (bs->drv) { if (bs->backing_hd) bdrv_delete(bs->backing_hd); bs->drv->bdrv_close(bs); qemu_free(bs->opaque); #ifdef _WIN32 if (bs->is_temporary) { unlink(bs->filename); } #endif bs->opaque = NULL; bs->drv = NULL; /* call the change callback */ bs->total_sectors = 0; bs->media_changed = 1; if (bs->change_cb) bs->change_cb(bs->change_opaque); } }


void bdrv_attach_aio_context(BlockDriverState *bs, AioContext *new_context) { BdrvAioNotifier *ban; BdrvChild *child; if (!bs->drv) { return; } bs->aio_context = new_context; QLIST_FOREACH(child, &bs->children, next) { bdrv_attach_aio_context(child->bs, new_context); } if (bs->drv->bdrv_attach_aio_context) { bs->drv->bdrv_attach_aio_context(bs, new_context); } QLIST_FOREACH(ban, &bs->aio_notifiers, list) { ban->attached_aio_context(new_context, ban->opaque); } }


gpg_error_t keydb_search_first ( KEYDB_HANDLE hd ) {
 gpg_error_t err ;
 KEYDB_SEARCH_DESC desc ;
 memset ( & desc , 0 , sizeof desc ) ;
 desc . mode = KEYDB_SEARCH_MODE_FIRST ;
 err = keydb_search ( hd , & desc , 1 , NULL ) ;
 if ( gpg_err_code ( err ) == GPG_ERR_LEGACY_KEY ) err = keydb_search_next ( hd ) ;
 return err ;
 }


static int RTP_packet ( void * ptr _U_ , packet_info * pinfo , epan_dissect_t * edt _U_ , void const * RTPinfo ) {
 voip_rtp_tapinfo_t * tapinfo = & the_tapinfo_rtp_struct ;
 voip_rtp_stream_info_t * tmp_listinfo ;
 voip_rtp_stream_info_t * strinfo = NULL ;
 GList * list ;
 struct _rtp_conversation_info * p_conv_data = NULL ;
 const struct _rtp_info * pi = ( const struct _rtp_info * ) RTPinfo ;
 if ( pi -> info_setup_frame_num == 0 ) {
 return 0 ;
 }
 # ifdef HAVE_LIBPORTAUDIO add_rtp_packet ( pi , pinfo ) ;
 # endif list = g_list_first ( tapinfo -> list ) ;
 while ( list ) {
 tmp_listinfo = ( voip_rtp_stream_info_t * ) list -> data ;
 if ( ( tmp_listinfo -> setup_frame_number == pi -> info_setup_frame_num ) && ( tmp_listinfo -> ssrc == pi -> info_sync_src ) && ( tmp_listinfo -> end_stream == FALSE ) ) {
 if ( tmp_listinfo -> pt != pi -> info_payload_type ) {
 tmp_listinfo -> end_stream = TRUE ;
 }
 else {
 strinfo = ( voip_rtp_stream_info_t * ) ( list -> data ) ;
 break ;
 }
 }
 list = g_list_next ( list ) ;
 }
 if ( ( rtp_evt_frame_num == pinfo -> fd -> num ) && ! strinfo && ( rtp_evt_end == TRUE ) ) {
 return 0 ;
 }
 if ( strinfo == NULL ) {
 strinfo = ( voip_rtp_stream_info_t * ) g_malloc ( sizeof ( voip_rtp_stream_info_t ) ) ;
 COPY_ADDRESS ( & ( strinfo -> src_addr ) , & ( pinfo -> src ) ) ;
 strinfo -> src_port = pinfo -> srcport ;
 COPY_ADDRESS ( & ( strinfo -> dest_addr ) , & ( pinfo -> dst ) ) ;
 strinfo -> dest_port = pinfo -> destport ;
 strinfo -> ssrc = pi -> info_sync_src ;
 strinfo -> end_stream = FALSE ;
 strinfo -> pt = pi -> info_payload_type ;
 strinfo -> pt_str = NULL ;
 strinfo -> is_srtp = pi -> info_is_srtp ;
 if ( ( strinfo -> pt >= PT_UNDF_96 ) && ( strinfo -> pt <= PT_UNDF_127 ) ) {
 p_conv_data = ( struct _rtp_conversation_info * ) p_get_proto_data ( wmem_file_scope ( ) , pinfo , proto_get_id_by_filter_name ( "rtp" ) , 0 ) ;
 if ( p_conv_data && p_conv_data -> rtp_dyn_payload ) {
 encoding_name_and_rate_t * encoding_name_and_rate_pt = NULL ;
 encoding_name_and_rate_pt = ( encoding_name_and_rate_t * ) g_hash_table_lookup ( p_conv_data -> rtp_dyn_payload , & strinfo -> pt ) ;
 if ( encoding_name_and_rate_pt ) {
 strinfo -> pt_str = g_strdup ( encoding_name_and_rate_pt -> encoding_name ) ;
 }
 }
 }
 if ( ! strinfo -> pt_str ) strinfo -> pt_str = g_strdup ( val_to_str_ext ( strinfo -> pt , & rtp_payload_type_short_vals_ext , "%u" ) ) ;
 strinfo -> npackets = 0 ;
 strinfo -> start_fd = pinfo -> fd ;
 strinfo -> start_rel_ts = pinfo -> rel_ts ;
 strinfo -> setup_frame_number = pi -> info_setup_frame_num ;
 strinfo -> rtp_event = - 1 ;
 tapinfo -> list = g_list_prepend ( tapinfo -> list , strinfo ) ;
 }
 strinfo -> npackets ++ ;
 strinfo -> stop_fd = pinfo -> fd ;
 strinfo -> stop_rel_ts = pinfo -> rel_ts ;
 if ( rtp_evt_frame_num == pinfo -> fd -> num ) {
 strinfo -> rtp_event = rtp_evt ;
 if ( rtp_evt_end == TRUE ) {
 strinfo -> end_stream = TRUE ;
 }
 }
 the_tapinfo_struct . redraw = TRUE ;
 return 1 ;
 }


int diff_tree(struct tree_desc *t1, struct tree_desc *t2, const char *base, struct diff_options *opt)
{
	int baselen = strlen(base);

	for (;;) {
		if (DIFF_OPT_TST(opt, QUIET) && DIFF_OPT_TST(opt, HAS_CHANGES))
			break;
		if (opt->nr_paths) {
			skip_uninteresting(t1, base, baselen, opt);
			skip_uninteresting(t2, base, baselen, opt);
		}
		if (!t1->size) {
			if (!t2->size)
				break;
			show_entry(opt, "+", t2, base, baselen);
			update_tree_entry(t2);
			continue;
		}
		if (!t2->size) {
			show_entry(opt, "-", t1, base, baselen);
			update_tree_entry(t1);
			continue;
		}
		switch (compare_tree_entry(t1, t2, base, baselen, opt)) {
		case -1:
			update_tree_entry(t1);
			continue;
		case 0:
			update_tree_entry(t1);
			/* Fallthrough */
		case 1:
			update_tree_entry(t2);
			continue;
		}
		die("git-diff-tree: internal error");
	}
	return 0;
}


static void spoolss_printserver_specific_rights ( tvbuff_t * tvb , gint offset , proto_tree * tree , guint32 access ) {
 proto_tree_add_boolean ( tree , hf_server_access_enum , tvb , offset , 4 , access ) ;
 proto_tree_add_boolean ( tree , hf_server_access_admin , tvb , offset , 4 , access ) ;
 }


static char *path_name(struct name_path *path, const char *name)
{
	struct name_path *p;
	char *n, *m;
	int nlen = strlen(name);
	int len = nlen + 1;

	for (p = path; p; p = p->up) {
		if (p->elem_len)
			len += p->elem_len + 1;
	}
	n = xmalloc(len);
	m = n + len - (nlen + 1);
	strcpy(m, name);
	for (p = path; p; p = p->up) {
		if (p->elem_len) {
			m -= p->elem_len + 1;
			memcpy(m, p->elem, p->elem_len);
			m[p->elem_len] = '/';
		}
	}
	return n;
}


static int cmp(const void *a, const void *b) { const double va = *(const double *)a, vb = *(const double *)b; return va < vb ? -1 : ( va > vb ? 1 : 0 ); }


static void remove_duplicate_parents(struct commit *commit)
{
	struct commit_list **pp, *p;

	/* Examine existing parents while marking ones we have seen... */
	pp = &commit->parents;
	while ((p = *pp) != NULL) {
		struct commit *parent = p->item;
		if (parent->object.flags & TMP_MARK) {
			*pp = p->next;
			continue;
		}
		parent->object.flags |= TMP_MARK;
		pp = &p->next;
	}
	/* ... and clear the temporary mark */
	for (p = commit->parents; p; p = p->next)
		p->item->object.flags &= ~TMP_MARK;
}


static int get_and_cmp_point ( const char * name , const char * mpi_x_string , const char * mpi_y_string , const char * desc , gcry_ctx_t ctx ) {
 gcry_mpi_point_t point ;
 gcry_mpi_t x , y , z ;
 int result = 0 ;
 point = gcry_mpi_ec_get_point ( name , ctx , 1 ) ;
 if ( ! point ) {
 fail ( "error getting point parameter '%s' of curve '%s'\n" , name , desc ) ;
 return 1 ;
 }
 if ( debug ) print_point ( name , point ) ;
 x = gcry_mpi_new ( 0 ) ;
 y = gcry_mpi_new ( 0 ) ;
 z = gcry_mpi_new ( 0 ) ;
 gcry_mpi_point_snatch_get ( x , y , z , point ) ;
 if ( cmp_mpihex ( x , mpi_x_string ) ) {
 fail ( "x coordinate of '%s' of curve '%s' does not match\n" , name , desc ) ;
 result = 1 ;
 }
 if ( cmp_mpihex ( y , mpi_y_string ) ) {
 fail ( "y coordinate of '%s' of curve '%s' does not match\n" , name , desc ) ;
 result = 1 ;
 }
 if ( cmp_mpihex ( z , "01" ) ) {
 fail ( "z coordinate of '%s' of curve '%s' is not 1\n" , name , desc ) ;
 result = 1 ;
 }
 gcry_mpi_release ( x ) ;
 gcry_mpi_release ( y ) ;
 gcry_mpi_release ( z ) ;
 return result ;
 }


static void fill_print_name(struct diffstat_file *file)
{
	char *pname;

	if (file->print_name)
		return;

	if (!file->is_renamed) {
		struct strbuf buf;
		strbuf_init(&buf, 0);
		if (quote_c_style(file->name, &buf, NULL, 0)) {
			pname = strbuf_detach(&buf, NULL);
		} else {
			pname = file->name;
			strbuf_release(&buf);
		}
	} else {
		pname = pprint_rename(file->from_name, file->name);
	}
	file->print_name = pname;
}


static int selinux_file_alloc_security ( struct file * file ) {
 return file_alloc_security ( file ) ;
 }


static ssize_t nic_receive(VLANClientState *nc, const uint8_t * buf, size_t size) { /* TODO: * - Magic packets should set bit 30 in power management driver register. * - Interesting packets should set bit 29 in power management driver register. */ EEPRO100State *s = DO_UPCAST(NICState, nc, nc)->opaque; uint16_t rfd_status = 0xa000; static const uint8_t broadcast_macaddr[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; /* TODO: check multiple IA bit. */ if (s->configuration[20] & BIT(6)) { missing("Multiple IA bit"); return -1; } if (s->configuration[8] & 0x80) { /* CSMA is disabled. */ logout("%p received while CSMA is disabled\n", s); return -1; } else if (size < 64 && (s->configuration[7] & BIT(0))) { /* Short frame and configuration byte 7/0 (discard short receive) set: * Short frame is discarded */ logout("%p received short frame (%zu byte)\n", s, size); s->statistics.rx_short_frame_errors++; #if 0 return -1; #endif } else if ((size > MAX_ETH_FRAME_SIZE + 4) && !(s->configuration[18] & BIT(3))) { /* Long frame and configuration byte 18/3 (long receive ok) not set: * Long frames are discarded. */ logout("%p received long frame (%zu byte), ignored\n", s, size); return -1; } else if (memcmp(buf, s->conf.macaddr.a, 6) == 0) { /* !!! */ /* Frame matches individual address. */ /* TODO: check configuration byte 15/4 (ignore U/L). */ TRACE(RXTX, logout("%p received frame for me, len=%zu\n", s, size)); } else if (memcmp(buf, broadcast_macaddr, 6) == 0) { /* Broadcast frame. */ TRACE(RXTX, logout("%p received broadcast, len=%zu\n", s, size)); rfd_status |= 0x0002; } else if (buf[0] & 0x01) { /* Multicast frame. */ TRACE(RXTX, logout("%p received multicast, len=%zu,%s\n", s, size, nic_dump(buf, size))); if (s->configuration[21] & BIT(3)) { /* Multicast all bit is set, receive all multicast frames. */ } else { unsigned mcast_idx = compute_mcast_idx(buf); assert(mcast_idx < 64); if (s->mult[mcast_idx >> 3] & (1 << (mcast_idx & 7))) { /* Multicast frame is allowed in hash table. */ } else if (s->configuration[15] & BIT(0)) { /* Promiscuous: receive all. */ rfd_status |= 0x0004; } else { TRACE(RXTX, logout("%p multicast ignored\n", s)); return -1; } } /* TODO: Next not for promiscuous mode? */ rfd_status |= 0x0002; } else if (s->configuration[15] & BIT(0)) { /* Promiscuous: receive all. */ TRACE(RXTX, logout("%p received frame in promiscuous mode, len=%zu\n", s, size)); rfd_status |= 0x0004; } else { TRACE(RXTX, logout("%p received frame, ignored, len=%zu,%s\n", s, size, nic_dump(buf, size))); return size; } if (get_ru_state(s) != ru_ready) { /* No resources available. */ logout("no resources, state=%u\n", get_ru_state(s)); /* TODO: RNR interrupt only at first failed frame? */ eepro100_rnr_interrupt(s); s->statistics.rx_resource_errors++; #if 0 assert(!"no resources"); #endif return -1; } /* !!! */ eepro100_rx_t rx; cpu_physical_memory_read(s->ru_base + s->ru_offset, (uint8_t *) & rx, offsetof(eepro100_rx_t, packet)); uint16_t rfd_command = le16_to_cpu(rx.command); uint16_t rfd_size = le16_to_cpu(rx.size); if (size > rfd_size) { logout("Receive buffer (%" PRId16 " bytes) too small for data " "(%zu bytes); data truncated\n", rfd_size, size); size = rfd_size; } if (size < 64) { rfd_status |= 0x0080; } TRACE(OTHER, logout("command 0x%04x, link 0x%08x, addr 0x%08x, size %u\n", rfd_command, rx.link, rx.rx_buf_addr, rfd_size)); stw_phys(s->ru_base + s->ru_offset + offsetof(eepro100_rx_t, status), rfd_status); stw_phys(s->ru_base + s->ru_offset + offsetof(eepro100_rx_t, count), size); /* Early receive interrupt not supported. */ #if 0 eepro100_er_interrupt(s); #endif /* Receive CRC Transfer not supported. */ if (s->configuration[18] & BIT(2)) { missing("Receive CRC Transfer"); return -1; } /* TODO: check stripping enable bit. */ #if 0 assert(!(s->configuration[17] & BIT(0))); #endif cpu_physical_memory_write(s->ru_base + s->ru_offset + offsetof(eepro100_rx_t, packet), buf, size); s->statistics.rx_good_frames++; eepro100_fr_interrupt(s); s->ru_offset = le32_to_cpu(rx.link); if (rfd_command & COMMAND_EL) { /* EL bit is set, so this was the last frame. */ logout("receive: Running out of frames\n"); set_ru_state(s, ru_suspended); } if (rfd_command & COMMAND_S) { /* S bit is set. */ set_ru_state(s, ru_suspended); } return size; }


static int zcountexecstack ( i_ctx_t * i_ctx_p ) {
 os_ptr op = osp ;
 push ( 1 ) ;
 make_int ( op , count_exec_stack ( i_ctx_p , false ) ) ;
 return 0 ;
 }