int ff_jpegls_decode_picture(MJpegDecodeContext *s, int near, int point_transform, int ilv){ int i, t = 0; uint8_t *zero, *last, *cur; JLSState *state; int off = 0, stride = 1, width, shift; zero = av_mallocz(s->picture.linesize[0]); last = zero; cur = s->picture.data[0]; state = av_mallocz(sizeof(JLSState)); /* initialize JPEG-LS state from JPEG parameters */ state->near = near; state->bpp = (s->bits < 2) ? 2 : s->bits; state->maxval = s->maxval; state->T1 = s->t1; state->T2 = s->t2; state->T3 = s->t3; state->reset = s->reset; ff_jpegls_reset_coding_parameters(state, 0); ff_jpegls_init_state(state); if(s->bits <= 8) shift = point_transform + (8 - s->bits); else shift = point_transform + (16 - s->bits); if (s->avctx->debug & FF_DEBUG_PICT_INFO) { av_log(s->avctx, AV_LOG_DEBUG, "JPEG-LS params: %ix%i NEAR=%i MV=%i T(%i,%i,%i) RESET=%i, LIMIT=%i, qbpp=%i, RANGE=%i\n", s->width, s->height, state->near, state->maxval, state->T1, state->T2, state->T3, state->reset, state->limit, state->qbpp, state->range); av_log(s->avctx, AV_LOG_DEBUG, "JPEG params: ILV=%i Pt=%i BPP=%i, scan = %i\n", ilv, point_transform, s->bits, s->cur_scan); } if(ilv == 0) { /* separate planes */ stride = (s->nb_components > 1) ? 3 : 1; off = av_clip(s->cur_scan - 1, 0, stride); width = s->width * stride; cur += off; for(i = 0; i < s->height; i++) { if(s->bits <= 8){ ls_decode_line(state, s, last, cur, t, width, stride, off, 8); t = last[0]; }else{ ls_decode_line(state, s, last, cur, t, width, stride, off, 16); t = *((uint16_t*)last); } last = cur; cur += s->picture.linesize[0]; if (s->restart_interval && !--s->restart_count) { align_get_bits(&s->gb); skip_bits(&s->gb, 16); /* skip RSTn */ } } } else if(ilv == 1) { /* line interleaving */ int j; int Rc[3] = {0, 0, 0}; stride = (s->nb_components > 1) ? 3 : 1; memset(cur, 0, s->picture.linesize[0]); width = s->width * stride; for(i = 0; i < s->height; i++) { for(j = 0; j < stride; j++) { ls_decode_line(state, s, last + j, cur + j, Rc[j], width, stride, j, 8); Rc[j] = last[j]; if (s->restart_interval && !--s->restart_count) { align_get_bits(&s->gb); skip_bits(&s->gb, 16); /* skip RSTn */ } } last = cur; cur += s->picture.linesize[0]; } } else if(ilv == 2) { /* sample interleaving */ av_log(s->avctx, AV_LOG_ERROR, "Sample interleaved images are not supported.\n"); av_free(state); av_free(zero); return -1; } if(shift){ /* we need to do point transform or normalize samples */ int x, w; w = s->width * s->nb_components; if(s->bits <= 8){ uint8_t *src = s->picture.data[0]; for(i = 0; i < s->height; i++){ for(x = off; x < w; x+= stride){ src[x] <<= shift; } src += s->picture.linesize[0]; } }else{ uint16_t *src = (uint16_t*) s->picture.data[0]; for(i = 0; i < s->height; i++){ for(x = 0; x < w; x++){ src[x] <<= shift; } src += s->picture.linesize[0]/2; } } } av_free(state); av_free(zero); return 0; }


int evdns_nameserver_add ( unsigned long int address ) {
 return _evdns_nameserver_add_impl ( address , 53 ) ;
 }


static int vp3_init_thread_copy ( AVCodecContext * avctx ) {
 Vp3DecodeContext * s = avctx -> priv_data ;
 s -> superblock_coding = NULL ;
 s -> all_fragments = NULL ;
 s -> coded_fragment_list [ 0 ] = NULL ;
 s -> dct_tokens_base = NULL ;
 s -> superblock_fragments = NULL ;
 s -> macroblock_coding = NULL ;
 s -> motion_val [ 0 ] = NULL ;
 s -> motion_val [ 1 ] = NULL ;
 s -> edge_emu_buffer = NULL ;
 return 0 ;
 }


static void mode_in ( struct cpio * cpio ) {
 struct archive * a ;
 struct archive_entry * entry ;
 struct archive * ext ;
 const char * destpath ;
 int r ;
 ext = archive_write_disk_new ( ) ;
 if ( ext == NULL ) lafe_errc ( 1 , 0 , "Couldn't allocate restore object" ) ;
 r = archive_write_disk_set_options ( ext , cpio -> extract_flags ) ;
 if ( r != ARCHIVE_OK ) lafe_errc ( 1 , 0 , "%s" , archive_error_string ( ext ) ) ;
 a = archive_read_new ( ) ;
 if ( a == NULL ) lafe_errc ( 1 , 0 , "Couldn't allocate archive object" ) ;
 archive_read_support_filter_all ( a ) ;
 archive_read_support_format_all ( a ) ;
 if ( cpio -> passphrase != NULL ) r = archive_read_add_passphrase ( a , cpio -> passphrase ) ;
 else r = archive_read_set_passphrase_callback ( a , cpio , & passphrase_callback ) ;
 if ( r != ARCHIVE_OK ) lafe_errc ( 1 , 0 , "%s" , archive_error_string ( a ) ) ;
 if ( archive_read_open_filename ( a , cpio -> filename , cpio -> bytes_per_block ) ) lafe_errc ( 1 , archive_errno ( a ) , "%s" , archive_error_string ( a ) ) ;
 for ( ;
 ;
 ) {
 r = archive_read_next_header ( a , & entry ) ;
 if ( r == ARCHIVE_EOF ) break ;
 if ( r != ARCHIVE_OK ) {
 lafe_errc ( 1 , archive_errno ( a ) , "%s" , archive_error_string ( a ) ) ;
 }
 if ( archive_match_path_excluded ( cpio -> matching , entry ) ) continue ;
 if ( cpio -> option_rename ) {
 destpath = cpio_rename ( archive_entry_pathname ( entry ) ) ;
 archive_entry_set_pathname ( entry , destpath ) ;
 }
 else destpath = archive_entry_pathname ( entry ) ;
 if ( destpath == NULL ) continue ;
 if ( cpio -> verbose ) fprintf ( stderr , "%s\n" , destpath ) ;
 if ( cpio -> dot ) fprintf ( stderr , "." ) ;
 if ( cpio -> uid_override >= 0 ) archive_entry_set_uid ( entry , cpio -> uid_override ) ;
 if ( cpio -> gid_override >= 0 ) archive_entry_set_gid ( entry , cpio -> gid_override ) ;
 r = archive_write_header ( ext , entry ) ;
 if ( r != ARCHIVE_OK ) {
 fprintf ( stderr , "%s: %s\n" , archive_entry_pathname ( entry ) , archive_error_string ( ext ) ) ;
 }
 else if ( ! archive_entry_size_is_set ( entry ) || archive_entry_size ( entry ) > 0 ) {
 r = extract_data ( a , ext ) ;
 if ( r != ARCHIVE_OK ) cpio -> return_value = 1 ;
 }
 }
 r = archive_read_close ( a ) ;
 if ( cpio -> dot ) fprintf ( stderr , "\n" ) ;
 if ( r != ARCHIVE_OK ) lafe_errc ( 1 , 0 , "%s" , archive_error_string ( a ) ) ;
 r = archive_write_close ( ext ) ;
 if ( r != ARCHIVE_OK ) lafe_errc ( 1 , 0 , "%s" , archive_error_string ( ext ) ) ;
 if ( ! cpio -> quiet ) {
 int64_t blocks = ( archive_filter_bytes ( a , 0 ) + 511 ) / 512 ;
 fprintf ( stderr , "%lu %s\n" , ( unsigned long ) blocks , blocks == 1 ? "block" : "blocks" ) ;
 }
 archive_read_free ( a ) ;
 archive_write_free ( ext ) ;
 exit ( cpio -> return_value ) ;
 }


static void ps2_keyboard_event ( DeviceState * dev , QemuConsole * src , InputEvent * evt ) {
 PS2KbdState * s = ( PS2KbdState * ) dev ;
 InputKeyEvent * key = evt -> u . key . data ;
 int qcode ;
 uint16_t keycode ;
 int mod ;
 qemu_system_wakeup_request ( QEMU_WAKEUP_REASON_OTHER ) ;
 assert ( evt -> type == INPUT_EVENT_KIND_KEY ) ;
 qcode = qemu_input_key_value_to_qcode ( key -> key ) ;
 mod = ps2_modifier_bit ( qcode ) ;
 trace_ps2_keyboard_event ( s , qcode , key -> down , mod , s -> modifiers ) ;
 if ( key -> down ) {
 s -> modifiers |= mod ;
 }
 else {
 s -> modifiers &= ~ mod ;
 }
 if ( s -> scancode_set == 1 ) {
 if ( qcode == Q_KEY_CODE_PAUSE ) {
 if ( s -> modifiers & ( MOD_CTRL_L | MOD_CTRL_R ) ) {
 if ( key -> down ) {
 ps2_put_keycode ( s , 0xe0 ) ;
 ps2_put_keycode ( s , 0x46 ) ;
 ps2_put_keycode ( s , 0xe0 ) ;
 ps2_put_keycode ( s , 0xc6 ) ;
 }
 }
 else {
 if ( key -> down ) {
 ps2_put_keycode ( s , 0xe1 ) ;
 ps2_put_keycode ( s , 0x1d ) ;
 ps2_put_keycode ( s , 0x45 ) ;
 ps2_put_keycode ( s , 0xe1 ) ;
 ps2_put_keycode ( s , 0x9d ) ;
 ps2_put_keycode ( s , 0xc5 ) ;
 }
 }
 }
 else if ( qcode == Q_KEY_CODE_PRINT ) {
 if ( s -> modifiers & MOD_ALT_L ) {
 if ( key -> down ) {
 ps2_put_keycode ( s , 0xb8 ) ;
 ps2_put_keycode ( s , 0x38 ) ;
 ps2_put_keycode ( s , 0x54 ) ;
 }
 else {
 ps2_put_keycode ( s , 0xd4 ) ;
 ps2_put_keycode ( s , 0xb8 ) ;
 ps2_put_keycode ( s , 0x38 ) ;
 }
 }
 else if ( s -> modifiers & MOD_ALT_R ) {
 if ( key -> down ) {
 ps2_put_keycode ( s , 0xe0 ) ;
 ps2_put_keycode ( s , 0xb8 ) ;
 ps2_put_keycode ( s , 0xe0 ) ;
 ps2_put_keycode ( s , 0x38 ) ;
 ps2_put_keycode ( s , 0x54 ) ;
 }
 else {
 ps2_put_keycode ( s , 0xd4 ) ;
 ps2_put_keycode ( s , 0xe0 ) ;
 ps2_put_keycode ( s , 0xb8 ) ;
 ps2_put_keycode ( s , 0xe0 ) ;
 ps2_put_keycode ( s , 0x38 ) ;
 }
 }
 else if ( s -> modifiers & ( MOD_SHIFT_L | MOD_CTRL_L | MOD_SHIFT_R | MOD_CTRL_R ) ) {
 if ( key -> down ) {
 ps2_put_keycode ( s , 0xe0 ) ;
 ps2_put_keycode ( s , 0x37 ) ;
 }
 else {
 ps2_put_keycode ( s , 0xe0 ) ;
 ps2_put_keycode ( s , 0xb7 ) ;
 }
 }
 else {
 if ( key -> down ) {
 ps2_put_keycode ( s , 0xe0 ) ;
 ps2_put_keycode ( s , 0x2a ) ;
 ps2_put_keycode ( s , 0xe0 ) ;
 ps2_put_keycode ( s , 0x37 ) ;
 }
 else {
 ps2_put_keycode ( s , 0xe0 ) ;
 ps2_put_keycode ( s , 0xb7 ) ;
 ps2_put_keycode ( s , 0xe0 ) ;
 ps2_put_keycode ( s , 0xaa ) ;
 }
 }
 }
 else {
 keycode = qcode_to_keycode_set1 [ qcode ] ;
 if ( keycode ) {
 if ( keycode & 0xff00 ) {
 ps2_put_keycode ( s , keycode >> 8 ) ;
 }
 if ( ! key -> down ) {
 keycode |= 0x80 ;
 }
 ps2_put_keycode ( s , keycode & 0xff ) ;
 }
 else {
 qemu_log_mask ( LOG_UNIMP , "ps2: ignoring key with qcode %d\n" , qcode ) ;
 }
 }
 }
 else if ( s -> scancode_set == 2 ) {
 if ( qcode == Q_KEY_CODE_PAUSE ) {
 if ( s -> modifiers & ( MOD_CTRL_L | MOD_CTRL_R ) ) {
 if ( key -> down ) {
 ps2_put_keycode ( s , 0xe0 ) ;
 ps2_put_keycode ( s , 0x7e ) ;
 ps2_put_keycode ( s , 0xe0 ) ;
 ps2_put_keycode ( s , 0xf0 ) ;
 ps2_put_keycode ( s , 0x7e ) ;
 }
 }
 else {
 if ( key -> down ) {
 ps2_put_keycode ( s , 0xe1 ) ;
 ps2_put_keycode ( s , 0x14 ) ;
 ps2_put_keycode ( s , 0x77 ) ;
 ps2_put_keycode ( s , 0xe1 ) ;
 ps2_put_keycode ( s , 0xf0 ) ;
 ps2_put_keycode ( s , 0x14 ) ;
 ps2_put_keycode ( s , 0xf0 ) ;
 ps2_put_keycode ( s , 0x77 ) ;
 }
 }
 }
 else if ( qcode == Q_KEY_CODE_PRINT ) {
 if ( s -> modifiers & MOD_ALT_L ) {
 if ( key -> down ) {
 ps2_put_keycode ( s , 0xf0 ) ;
 ps2_put_keycode ( s , 0x11 ) ;
 ps2_put_keycode ( s , 0x11 ) ;
 ps2_put_keycode ( s , 0x84 ) ;
 }
 else {
 ps2_put_keycode ( s , 0xf0 ) ;
 ps2_put_keycode ( s , 0x84 ) ;
 ps2_put_keycode ( s , 0xf0 ) ;
 ps2_put_keycode ( s , 0x11 ) ;
 ps2_put_keycode ( s , 0x11 ) ;
 }
 }
 else if ( s -> modifiers & MOD_ALT_R ) {
 if ( key -> down ) {
 ps2_put_keycode ( s , 0xe0 ) ;
 ps2_put_keycode ( s , 0xf0 ) ;
 ps2_put_keycode ( s , 0x11 ) ;
 ps2_put_keycode ( s , 0xe0 ) ;
 ps2_put_keycode ( s , 0x11 ) ;
 ps2_put_keycode ( s , 0x84 ) ;
 }
 else {
 ps2_put_keycode ( s , 0xf0 ) ;
 ps2_put_keycode ( s , 0x84 ) ;
 ps2_put_keycode ( s , 0xe0 ) ;
 ps2_put_keycode ( s , 0xf0 ) ;
 ps2_put_keycode ( s , 0x11 ) ;
 ps2_put_keycode ( s , 0xe0 ) ;
 ps2_put_keycode ( s , 0x11 ) ;
 }
 }
 else if ( s -> modifiers & ( MOD_SHIFT_L | MOD_CTRL_L | MOD_SHIFT_R | MOD_CTRL_R ) ) {
 if ( key -> down ) {
 ps2_put_keycode ( s , 0xe0 ) ;
 ps2_put_keycode ( s , 0x7c ) ;
 }
 else {
 ps2_put_keycode ( s , 0xe0 ) ;
 ps2_put_keycode ( s , 0xf0 ) ;
 ps2_put_keycode ( s , 0x7c ) ;
 }
 }
 else {
 if ( key -> down ) {
 ps2_put_keycode ( s , 0xe0 ) ;
 ps2_put_keycode ( s , 0x12 ) ;
 ps2_put_keycode ( s , 0xe0 ) ;
 ps2_put_keycode ( s , 0x7c ) ;
 }
 else {
 ps2_put_keycode ( s , 0xe0 ) ;
 ps2_put_keycode ( s , 0xf0 ) ;
 ps2_put_keycode ( s , 0x7c ) ;
 ps2_put_keycode ( s , 0xe0 ) ;
 ps2_put_keycode ( s , 0xf0 ) ;
 ps2_put_keycode ( s , 0x12 ) ;
 }
 }
 }
 else {
 keycode = qcode_to_keycode_set2 [ qcode ] ;
 if ( keycode ) {
 if ( keycode & 0xff00 ) {
 ps2_put_keycode ( s , keycode >> 8 ) ;
 }
 if ( ! key -> down ) {
 ps2_put_keycode ( s , 0xf0 ) ;
 }
 ps2_put_keycode ( s , keycode & 0xff ) ;
 }
 else {
 qemu_log_mask ( LOG_UNIMP , "ps2: ignoring key with qcode %d\n" , qcode ) ;
 }
 }
 }
 else if ( s -> scancode_set == 3 ) {
 keycode = qcode_to_keycode_set3 [ qcode ] ;
 if ( keycode ) {
 if ( ! key -> down ) {
 ps2_put_keycode ( s , 0xf0 ) ;
 }
 ps2_put_keycode ( s , keycode ) ;
 }
 else {
 qemu_log_mask ( LOG_UNIMP , "ps2: ignoring key with qcode %d\n" , qcode ) ;
 }
 }
 }


static int bit_allocation(IMCContext *q, IMCChannel *chctx, int stream_format_code, int freebits, int flag) { int i, j; const float limit = -1.e20; float highest = 0.0; int indx; int t1 = 0; int t2 = 1; float summa = 0.0; int iacc = 0; int summer = 0; int rres, cwlen; float lowest = 1.e10; int low_indx = 0; float workT[32]; int flg; int found_indx = 0; for (i = 0; i < BANDS; i++) highest = FFMAX(highest, chctx->flcoeffs1[i]); for (i = 0; i < BANDS - 1; i++) chctx->flcoeffs4[i] = chctx->flcoeffs3[i] - log2f(chctx->flcoeffs5[i]); chctx->flcoeffs4[BANDS - 1] = limit; highest = highest * 0.25; for (i = 0; i < BANDS; i++) { indx = -1; if ((band_tab[i + 1] - band_tab[i]) == chctx->bandWidthT[i]) indx = 0; if ((band_tab[i + 1] - band_tab[i]) > chctx->bandWidthT[i]) indx = 1; if (((band_tab[i + 1] - band_tab[i]) / 2) >= chctx->bandWidthT[i]) indx = 2; if (indx == -1) chctx->flcoeffs4[i] += xTab[(indx * 2 + (chctx->flcoeffs1[i] < highest)) * 2 + flag]; } if (stream_format_code & 0x2) { chctx->flcoeffs4[0] = limit; chctx->flcoeffs4[1] = limit; chctx->flcoeffs4[2] = limit; chctx->flcoeffs4[3] = limit; } for (i = (stream_format_code & 0x2) ? 4 : 0; i < BANDS - 1; i++) { iacc += chctx->bandWidthT[i]; summa += chctx->bandWidthT[i] * chctx->flcoeffs4[i]; } chctx->bandWidthT[BANDS - 1] = 0; summa = (summa * 0.5 - freebits) / iacc; for (i = 0; i < BANDS / 2; i++) { rres = summer - freebits; if ((rres >= -8) && (rres <= 8)) break; summer = 0; iacc = 0; for (j = (stream_format_code & 0x2) ? 4 : 0; j < BANDS; j++) { cwlen = av_clipf(((chctx->flcoeffs4[j] * 0.5) - summa + 0.5), 0, 6); chctx->bitsBandT[j] = cwlen; summer += chctx->bandWidthT[j] * cwlen; if (cwlen > 0) iacc += chctx->bandWidthT[j]; } flg = t2; t2 = 1; if (freebits < summer) t2 = -1; if (i == 0) flg = t2; if (flg != t2) t1++; summa = (float)(summer - freebits) / ((t1 + 1) * iacc) + summa; } for (i = (stream_format_code & 0x2) ? 4 : 0; i < BANDS; i++) { for (j = band_tab[i]; j < band_tab[i + 1]; j++) chctx->CWlengthT[j] = chctx->bitsBandT[i]; } if (freebits > summer) { for (i = 0; i < BANDS; i++) { workT[i] = (chctx->bitsBandT[i] == 6) ? -1.e20 : (chctx->bitsBandT[i] * -2 + chctx->flcoeffs4[i] - 0.415); } highest = 0.0; do { if (highest <= -1.e20) break; found_indx = 0; highest = -1.e20; for (i = 0; i < BANDS; i++) { if (workT[i] > highest) { highest = workT[i]; found_indx = i; } } if (highest > -1.e20) { workT[found_indx] -= 2.0; if (++chctx->bitsBandT[found_indx] == 6) workT[found_indx] = -1.e20; for (j = band_tab[found_indx]; j < band_tab[found_indx + 1] && (freebits > summer); j++) { chctx->CWlengthT[j]++; summer++; } } } while (freebits > summer); } if (freebits < summer) { for (i = 0; i < BANDS; i++) { workT[i] = chctx->bitsBandT[i] ? (chctx->bitsBandT[i] * -2 + chctx->flcoeffs4[i] + 1.585) : 1.e20; } if (stream_format_code & 0x2) { workT[0] = 1.e20; workT[1] = 1.e20; workT[2] = 1.e20; workT[3] = 1.e20; } while (freebits < summer) { lowest = 1.e10; low_indx = 0; for (i = 0; i < BANDS; i++) { if (workT[i] < lowest) { lowest = workT[i]; low_indx = i; } } // if (lowest >= 1.e10) // break; workT[low_indx] = lowest + 2.0; if (!--chctx->bitsBandT[low_indx]) workT[low_indx] = 1.e20; for (j = band_tab[low_indx]; j < band_tab[low_indx+1] && (freebits < summer); j++) { if (chctx->CWlengthT[j] > 0) { chctx->CWlengthT[j]--; summer--; } } } } return 0; }


TSReturnCode TSHttpTxnOutgoingAddrSet ( TSHttpTxn txnp , const struct sockaddr * addr ) {
 sdk_assert ( sdk_sanity_check_txn ( txnp ) == TS_SUCCESS ) ;
 HttpSM * sm = ( HttpSM * ) txnp ;
 sm -> ua_session -> set_outbound_port ( ats_ip_port_host_order ( addr ) ) ;
 sm -> ua_session -> set_outbound_ip ( IpAddr ( addr ) ) ;
 return TS_ERROR ;
 }


static int vio_make_devnode(VIOsPAPRDevice *dev, void *fdt) { VIOsPAPRDeviceClass *pc = VIO_SPAPR_DEVICE_GET_CLASS(dev); int vdevice_off, node_off, ret; char *dt_name; vdevice_off = fdt_path_offset(fdt, "/vdevice"); if (vdevice_off < 0) { return vdevice_off; } dt_name = vio_format_dev_name(dev); if (!dt_name) { return -ENOMEM; } node_off = fdt_add_subnode(fdt, vdevice_off, dt_name); free(dt_name); if (node_off < 0) { return node_off; } ret = fdt_setprop_cell(fdt, node_off, "reg", dev->reg); if (ret < 0) { return ret; } if (pc->dt_type) { ret = fdt_setprop_string(fdt, node_off, "device_type", pc->dt_type); if (ret < 0) { return ret; } } if (pc->dt_compatible) { ret = fdt_setprop_string(fdt, node_off, "compatible", pc->dt_compatible); if (ret < 0) { return ret; } } if (dev->qirq) { uint32_t ints_prop[] = {cpu_to_be32(dev->vio_irq_num), 0}; ret = fdt_setprop(fdt, node_off, "interrupts", ints_prop, sizeof(ints_prop)); if (ret < 0) { return ret; } } if (dev->rtce_window_size) { uint32_t dma_prop[] = {cpu_to_be32(dev->reg), 0, 0, 0, cpu_to_be32(dev->rtce_window_size)}; ret = fdt_setprop_cell(fdt, node_off, "ibm,#dma-address-cells", 2); if (ret < 0) { return ret; } ret = fdt_setprop_cell(fdt, node_off, "ibm,#dma-size-cells", 2); if (ret < 0) { return ret; } ret = fdt_setprop(fdt, node_off, "ibm,my-dma-window", dma_prop, sizeof(dma_prop)); if (ret < 0) { return ret; } } if (pc->devnode) { ret = (pc->devnode)(dev, fdt, node_off); if (ret < 0) { return ret; } } return node_off; }


static int l2cap_sock_getname(struct socket *sock, struct sockaddr *addr, int *len, int peer)
{
	struct sockaddr_l2 *la = (struct sockaddr_l2 *) addr;
	struct sock *sk = sock->sk;
	struct l2cap_chan *chan = l2cap_pi(sk)->chan;

	BT_DBG("sock %p, sk %p", sock, sk);

	addr->sa_family = AF_BLUETOOTH;
	*len = sizeof(struct sockaddr_l2);

	if (peer) {
		la->l2_psm = chan->psm;
		bacpy(&la->l2_bdaddr, &bt_sk(sk)->dst);
		la->l2_cid = cpu_to_le16(chan->dcid);
	} else {
		la->l2_psm = chan->sport;
		bacpy(&la->l2_bdaddr, &bt_sk(sk)->src);
		la->l2_cid = cpu_to_le16(chan->scid);
	}

	return 0;
}


static int dissect_ber_any_oid_str ( gboolean implicit_tag , asn1_ctx_t * actx , proto_tree * tree , tvbuff_t * tvb , int offset , gint hf_id , const char * * value_stringx , gboolean is_absolute ) {
 tvbuff_t * value_tvb = NULL ;
 guint length ;
 offset = dissect_ber_any_oid ( implicit_tag , actx , tree , tvb , offset , hf_id , ( value_stringx ) ? & value_tvb : NULL , is_absolute ) ;
 if ( value_stringx ) {
 if ( value_tvb && ( length = tvb_reported_length ( value_tvb ) ) ) {
 * value_stringx = oid_encoded2string ( wmem_packet_scope ( ) , tvb_get_ptr ( value_tvb , 0 , length ) , length ) ;
 }
 else {
 * value_stringx = "" ;
 }
 }
 return offset ;
 }


PCIBus *pci_device_root_bus(const PCIDevice *d) { PCIBus *bus = d->bus; while (!pci_bus_is_root(bus)) { d = bus->parent_dev; assert(d != NULL); bus = d->bus; } return bus; }


static void virtio_net_device_realize(DeviceState *dev, Error **errp) { VirtIODevice *vdev = VIRTIO_DEVICE(dev); VirtIONet *n = VIRTIO_NET(dev); NetClientState *nc; int i; virtio_init(vdev, "virtio-net", VIRTIO_ID_NET, n->config_size); n->max_queues = MAX(n->nic_conf.queues, 1); n->vqs = g_malloc0(sizeof(VirtIONetQueue) * n->max_queues); n->vqs[0].rx_vq = virtio_add_queue(vdev, 256, virtio_net_handle_rx); n->curr_queues = 1; n->vqs[0].n = n; n->tx_timeout = n->net_conf.txtimer; if (n->net_conf.tx && strcmp(n->net_conf.tx, "timer") && strcmp(n->net_conf.tx, "bh")) { error_report("virtio-net: " "Unknown option tx=%s, valid options: \"timer\" \"bh\"", n->net_conf.tx); error_report("Defaulting to \"bh\""); } if (n->net_conf.tx && !strcmp(n->net_conf.tx, "timer")) { n->vqs[0].tx_vq = virtio_add_queue(vdev, 256, virtio_net_handle_tx_timer); n->vqs[0].tx_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, virtio_net_tx_timer, &n->vqs[0]); } else { n->vqs[0].tx_vq = virtio_add_queue(vdev, 256, virtio_net_handle_tx_bh); n->vqs[0].tx_bh = qemu_bh_new(virtio_net_tx_bh, &n->vqs[0]); } n->ctrl_vq = virtio_add_queue(vdev, 64, virtio_net_handle_ctrl); qemu_macaddr_default_if_unset(&n->nic_conf.macaddr); memcpy(&n->mac[0], &n->nic_conf.macaddr, sizeof(n->mac)); n->status = VIRTIO_NET_S_LINK_UP; if (n->netclient_type) { /* * Happen when virtio_net_set_netclient_name has been called. */ n->nic = qemu_new_nic(&net_virtio_info, &n->nic_conf, n->netclient_type, n->netclient_name, n); } else { n->nic = qemu_new_nic(&net_virtio_info, &n->nic_conf, object_get_typename(OBJECT(dev)), dev->id, n); } peer_test_vnet_hdr(n); if (peer_has_vnet_hdr(n)) { for (i = 0; i < n->max_queues; i++) { qemu_peer_using_vnet_hdr(qemu_get_subqueue(n->nic, i), true); } n->host_hdr_len = sizeof(struct virtio_net_hdr); } else { n->host_hdr_len = 0; } qemu_format_nic_info_str(qemu_get_queue(n->nic), n->nic_conf.macaddr.a); n->vqs[0].tx_waiting = 0; n->tx_burst = n->net_conf.txburst; virtio_net_set_mrg_rx_bufs(n, 0); n->promisc = 1; /* for compatibility */ n->mac_table.macs = g_malloc0(MAC_TABLE_ENTRIES * ETH_ALEN); n->vlans = g_malloc0(MAX_VLAN >> 3); nc = qemu_get_queue(n->nic); nc->rxfilter_notify_enabled = 1; n->qdev = dev; register_savevm(dev, "virtio-net", -1, VIRTIO_NET_VM_VERSION, virtio_net_save, virtio_net_load, n); add_boot_device_path(n->nic_conf.bootindex, dev, "/ethernet-phy@0"); }


static inline int l2cap_connect_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u8 *data)
{
	struct l2cap_conn_rsp *rsp = (struct l2cap_conn_rsp *) data;
	u16 scid, dcid, result, status;
	struct sock *sk;
	u8 req[128];

	scid   = __le16_to_cpu(rsp->scid);
	dcid   = __le16_to_cpu(rsp->dcid);
	result = __le16_to_cpu(rsp->result);
	status = __le16_to_cpu(rsp->status);

	BT_DBG("dcid 0x%4.4x scid 0x%4.4x result 0x%2.2x status 0x%2.2x", dcid, scid, result, status);

	if (scid) {
		sk = l2cap_get_chan_by_scid(&conn->chan_list, scid);
		if (!sk)
			return 0;
	} else {
		sk = l2cap_get_chan_by_ident(&conn->chan_list, cmd->ident);
		if (!sk)
			return 0;
	}

	switch (result) {
	case L2CAP_CR_SUCCESS:
		sk->sk_state = BT_CONFIG;
		l2cap_pi(sk)->ident = 0;
		l2cap_pi(sk)->dcid = dcid;
		l2cap_pi(sk)->conf_state |= L2CAP_CONF_REQ_SENT;

		l2cap_pi(sk)->conf_state &= ~L2CAP_CONF_CONNECT_PEND;

		l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ,
					l2cap_build_conf_req(sk, req), req);
		break;

	case L2CAP_CR_PEND:
		l2cap_pi(sk)->conf_state |= L2CAP_CONF_CONNECT_PEND;
		break;

	default:
		l2cap_chan_del(sk, ECONNREFUSED);
		break;
	}

	bh_unlock_sock(sk);
	return 0;
}


UScriptCode hb_icu_script_from_script ( hb_script_t script ) {
 if ( unlikely ( script == HB_SCRIPT_INVALID ) ) return USCRIPT_INVALID_CODE ;
 for ( unsigned int i = 0 ;
 i < USCRIPT_CODE_LIMIT ;
 i ++ ) if ( unlikely ( hb_icu_script_to_script ( ( UScriptCode ) i ) == script ) ) return ( UScriptCode ) i ;
 return USCRIPT_UNKNOWN ;
 }


void helper_fcmpu(CPUPPCState *env, uint64_t arg1, uint64_t arg2, uint32_t crfD) { CPU_DoubleU farg1, farg2; uint32_t ret = 0; farg1.ll = arg1; farg2.ll = arg2; if (unlikely(float64_is_any_nan(farg1.d) || float64_is_any_nan(farg2.d))) { ret = 0x01UL; } else if (float64_lt(farg1.d, farg2.d, &env->fp_status)) { ret = 0x08UL; } else if (!float64_le(farg1.d, farg2.d, &env->fp_status)) { ret = 0x04UL; } else { ret = 0x02UL; } env->fpscr &= ~(0x0F << FPSCR_FPRF); env->fpscr |= ret << FPSCR_FPRF; env->crf[crfD] = ret; if (unlikely(ret == 0x01UL && (float64_is_signaling_nan(farg1.d) || float64_is_signaling_nan(farg2.d)))) { /* sNaN comparison */ fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN); } }


static int tpm_passthrough_unix_tx_bufs(TPMPassthruState *tpm_pt, const uint8_t *in, uint32_t in_len, uint8_t *out, uint32_t out_len) { int ret; tpm_pt->tpm_op_canceled = false; tpm_pt->tpm_executing = true; ret = tpm_passthrough_unix_write(tpm_pt->tpm_fd, in, in_len); if (ret != in_len) { if (!tpm_pt->tpm_op_canceled || (tpm_pt->tpm_op_canceled && errno != ECANCELED)) { error_report("tpm_passthrough: error while transmitting data " "to TPM: %s (%i)\n", strerror(errno), errno); } goto err_exit; } tpm_pt->tpm_executing = false; ret = tpm_passthrough_unix_read(tpm_pt->tpm_fd, out, out_len); if (ret < 0) { if (!tpm_pt->tpm_op_canceled || (tpm_pt->tpm_op_canceled && errno != ECANCELED)) { error_report("tpm_passthrough: error while reading data from " "TPM: %s (%i)\n", strerror(errno), errno); } } else if (ret < sizeof(struct tpm_resp_hdr) || tpm_passthrough_get_size_from_buffer(out) != ret) { ret = -1; error_report("tpm_passthrough: received invalid response " "packet from TPM\n"); } err_exit: if (ret < 0) { tpm_write_fatal_error_response(out, out_len); } tpm_pt->tpm_executing = false; return ret; }


void usage_exit ( ) {
 fprintf ( stderr , "Usage: %s <infile> <outfile> <N-M|N/M>\n" , exec_name ) ;
 exit ( EXIT_FAILURE ) ;
 }


static int set_and_cost_bmi_mvs ( VP9_COMP * cpi , MACROBLOCKD * xd , int i , PREDICTION_MODE mode , int_mv this_mv [ 2 ] , int_mv frame_mv [ MB_MODE_COUNT ] [ MAX_REF_FRAMES ] , int_mv seg_mvs [ MAX_REF_FRAMES ] , int_mv * best_ref_mv [ 2 ] , const int * mvjcost , int * mvcost [ 2 ] ) {
 MODE_INFO * const mic = xd -> mi [ 0 ] . src_mi ;
 const MB_MODE_INFO * const mbmi = & mic -> mbmi ;
 int thismvcost = 0 ;
 int idx , idy ;
 const int num_4x4_blocks_wide = num_4x4_blocks_wide_lookup [ mbmi -> sb_type ] ;
 const int num_4x4_blocks_high = num_4x4_blocks_high_lookup [ mbmi -> sb_type ] ;
 const int is_compound = has_second_ref ( mbmi ) ;
 switch ( mode ) {
 case NEWMV : this_mv [ 0 ] . as_int = seg_mvs [ mbmi -> ref_frame [ 0 ] ] . as_int ;
 thismvcost += vp9_mv_bit_cost ( & this_mv [ 0 ] . as_mv , & best_ref_mv [ 0 ] -> as_mv , mvjcost , mvcost , MV_COST_WEIGHT_SUB ) ;
 if ( is_compound ) {
 this_mv [ 1 ] . as_int = seg_mvs [ mbmi -> ref_frame [ 1 ] ] . as_int ;
 thismvcost += vp9_mv_bit_cost ( & this_mv [ 1 ] . as_mv , & best_ref_mv [ 1 ] -> as_mv , mvjcost , mvcost , MV_COST_WEIGHT_SUB ) ;
 }
 break ;
 case NEARMV : case NEARESTMV : this_mv [ 0 ] . as_int = frame_mv [ mode ] [ mbmi -> ref_frame [ 0 ] ] . as_int ;
 if ( is_compound ) this_mv [ 1 ] . as_int = frame_mv [ mode ] [ mbmi -> ref_frame [ 1 ] ] . as_int ;
 break ;
 case ZEROMV : this_mv [ 0 ] . as_int = 0 ;
 if ( is_compound ) this_mv [ 1 ] . as_int = 0 ;
 break ;
 default : break ;
 }
 mic -> bmi [ i ] . as_mv [ 0 ] . as_int = this_mv [ 0 ] . as_int ;
 if ( is_compound ) mic -> bmi [ i ] . as_mv [ 1 ] . as_int = this_mv [ 1 ] . as_int ;
 mic -> bmi [ i ] . as_mode = mode ;
 for ( idy = 0 ;
 idy < num_4x4_blocks_high ;
 ++ idy ) for ( idx = 0 ;
 idx < num_4x4_blocks_wide ;
 ++ idx ) vpx_memcpy ( & mic -> bmi [ i + idy * 2 + idx ] , & mic -> bmi [ i ] , sizeof ( mic -> bmi [ i ] ) ) ;
 return cost_mv_ref ( cpi , mode , mbmi -> mode_context [ mbmi -> ref_frame [ 0 ] ] ) + thismvcost ;
 }


int main(int argc, char **argv, char **envp) int i; int snapshot, linux_boot; const char *initrd_filename; const char *kernel_filename, *kernel_cmdline; const char *boot_order = NULL; const char *boot_once = NULL; DisplayState *ds; int cyls, heads, secs, translation; QemuOpts *opts, *machine_opts; QemuOpts *hda_opts = NULL, *icount_opts = NULL, *accel_opts = NULL; QemuOptsList *olist; int optind; const char *optarg; const char *loadvm = NULL; MachineClass *machine_class; const char *cpu_model; const char *vga_model = NULL; const char *qtest_chrdev = NULL; const char *qtest_log = NULL; const char *pid_file = NULL; const char *incoming = NULL; bool defconfig = true; bool userconfig = true; bool nographic = false; DisplayType display_type = DT_DEFAULT; int display_remote = 0; const char *log_mask = NULL; const char *log_file = NULL; char *trace_file = NULL; ram_addr_t maxram_size; uint64_t ram_slots = 0; FILE *vmstate_dump_file = NULL; Error *main_loop_err = NULL; Error *err = NULL; bool list_data_dirs = false; typedef struct BlockdevOptions_queue { BlockdevOptions *bdo; Location loc; QSIMPLEQ_ENTRY(BlockdevOptions_queue) entry; } BlockdevOptions_queue; QSIMPLEQ_HEAD(, BlockdevOptions_queue) bdo_queue = QSIMPLEQ_HEAD_INITIALIZER(bdo_queue); module_call_init(MODULE_INIT_TRACE); qemu_init_cpu_list(); qemu_init_cpu_loop(); qemu_mutex_lock_iothread(); atexit(qemu_run_exit_notifiers); error_set_progname(argv[0]); qemu_init_exec_dir(argv[0]); module_call_init(MODULE_INIT_QOM); monitor_init_qmp_commands(); qemu_add_opts(&qemu_drive_opts); qemu_add_drive_opts(&qemu_legacy_drive_opts); qemu_add_drive_opts(&qemu_common_drive_opts); qemu_add_drive_opts(&qemu_drive_opts); qemu_add_drive_opts(&bdrv_runtime_opts); qemu_add_opts(&qemu_chardev_opts); qemu_add_opts(&qemu_device_opts); qemu_add_opts(&qemu_netdev_opts); qemu_add_opts(&qemu_net_opts); qemu_add_opts(&qemu_rtc_opts); qemu_add_opts(&qemu_global_opts); qemu_add_opts(&qemu_mon_opts); qemu_add_opts(&qemu_trace_opts); qemu_add_opts(&qemu_option_rom_opts); qemu_add_opts(&qemu_machine_opts); qemu_add_opts(&qemu_accel_opts); qemu_add_opts(&qemu_mem_opts); qemu_add_opts(&qemu_smp_opts); qemu_add_opts(&qemu_boot_opts); qemu_add_opts(&qemu_sandbox_opts); qemu_add_opts(&qemu_add_fd_opts); qemu_add_opts(&qemu_object_opts); qemu_add_opts(&qemu_tpmdev_opts); qemu_add_opts(&qemu_realtime_opts); qemu_add_opts(&qemu_msg_opts); qemu_add_opts(&qemu_name_opts); qemu_add_opts(&qemu_numa_opts); qemu_add_opts(&qemu_icount_opts); qemu_add_opts(&qemu_semihosting_config_opts); qemu_add_opts(&qemu_fw_cfg_opts); module_call_init(MODULE_INIT_OPTS); runstate_init(); if (qcrypto_init(&err) < 0) { error_reportf_err(err, "cannot initialize crypto: "); rtc_clock = QEMU_CLOCK_HOST; QLIST_INIT (&vm_change_state_head); os_setup_early_signal_handling(); cpu_model = NULL; snapshot = 0; cyls = heads = secs = 0; translation = BIOS_ATA_TRANSLATION_AUTO; nb_nics = 0; bdrv_init_with_whitelist(); autostart = 1; /* first pass of option parsing */ optind = 1; while (optind < argc) { if (argv[optind][0] != '-') { /* disk image */ optind++; } else { const QEMUOption *popt; popt = lookup_opt(argc, argv, &optarg, &optind); switch (popt->index) { case QEMU_OPTION_nodefconfig: defconfig = false; case QEMU_OPTION_nouserconfig: userconfig = false; if (defconfig && userconfig) { if (qemu_read_default_config_file() < 0) { /* second pass of option parsing */ optind = 1; for(;;) { if (optind >= argc) if (argv[optind][0] != '-') { hda_opts = drive_add(IF_DEFAULT, 0, argv[optind++], HD_OPTS); } else { const QEMUOption *popt; popt = lookup_opt(argc, argv, &optarg, &optind); if (!(popt->arch_mask & arch_type)) { error_report("Option not supported for this target"); switch(popt->index) { case QEMU_OPTION_no_kvm_irqchip: { olist = qemu_find_opts("machine"); qemu_opts_parse_noisily(olist, "kernel_irqchip=off", false); case QEMU_OPTION_cpu: /* hw initialization will check this */ cpu_model = optarg; case QEMU_OPTION_hda: char buf[256]; if (cyls == 0) snprintf(buf, sizeof(buf), "%s", HD_OPTS); else snprintf(buf, sizeof(buf), "%s,cyls=%d,heads=%d,secs=%d%s", HD_OPTS , cyls, heads, secs, translation == BIOS_ATA_TRANSLATION_LBA ? ",trans=lba" : translation == BIOS_ATA_TRANSLATION_NONE ? ",trans=none" : ""); drive_add(IF_DEFAULT, 0, optarg, buf); case QEMU_OPTION_hdb: case QEMU_OPTION_hdc: case QEMU_OPTION_hdd: drive_add(IF_DEFAULT, popt->index - QEMU_OPTION_hda, optarg, HD_OPTS); case QEMU_OPTION_drive: if (drive_def(optarg) == NULL) { case QEMU_OPTION_set: if (qemu_set_option(optarg) != 0) case QEMU_OPTION_global: if (qemu_global_option(optarg) != 0) case QEMU_OPTION_mtdblock: drive_add(IF_MTD, -1, optarg, MTD_OPTS); case QEMU_OPTION_sd: drive_add(IF_SD, -1, optarg, SD_OPTS); case QEMU_OPTION_pflash: drive_add(IF_PFLASH, -1, optarg, PFLASH_OPTS); case QEMU_OPTION_snapshot: snapshot = 1; case QEMU_OPTION_hdachs: const char *p; p = optarg; cyls = strtol(p, (char **)&p, 0); if (cyls < 1 || cyls > 16383) goto chs_fail; if (*p != ',') goto chs_fail; p++; heads = strtol(p, (char **)&p, 0); if (heads < 1 || heads > 16) goto chs_fail; if (*p != ',') goto chs_fail; p++; secs = strtol(p, (char **)&p, 0); if (secs < 1 || secs > 63) goto chs_fail; if (*p == ',') { p++; if (!strcmp(p, "large")) { translation = BIOS_ATA_TRANSLATION_LARGE; } else if (!strcmp(p, "rechs")) { translation = BIOS_ATA_TRANSLATION_RECHS; } else if (!strcmp(p, "none")) { translation = BIOS_ATA_TRANSLATION_NONE; } else if (!strcmp(p, "lba")) { translation = BIOS_ATA_TRANSLATION_LBA; } else if (!strcmp(p, "auto")) { translation = BIOS_ATA_TRANSLATION_AUTO; } else { goto chs_fail; } else if (*p != '\0') { chs_fail: error_report("invalid physical CHS format"); if (hda_opts != NULL) { qemu_opt_set_number(hda_opts, "cyls", cyls, &error_abort); qemu_opt_set_number(hda_opts, "heads", heads, &error_abort); qemu_opt_set_number(hda_opts, "secs", secs, &error_abort); if (translation == BIOS_ATA_TRANSLATION_LARGE) { qemu_opt_set(hda_opts, "trans", "large", &error_abort); } else if (translation == BIOS_ATA_TRANSLATION_RECHS) { qemu_opt_set(hda_opts, "trans", "rechs", &error_abort); } else if (translation == BIOS_ATA_TRANSLATION_LBA) { qemu_opt_set(hda_opts, "trans", "lba", &error_abort); } else if (translation == BIOS_ATA_TRANSLATION_NONE) { qemu_opt_set(hda_opts, "trans", "none", &error_abort); case QEMU_OPTION_numa: opts = qemu_opts_parse_noisily(qemu_find_opts("numa"), optarg, true); if (!opts) { case QEMU_OPTION_display: display_type = select_display(optarg); case QEMU_OPTION_nographic: olist = qemu_find_opts("machine"); qemu_opts_parse_noisily(olist, "graphics=off", false); nographic = true; display_type = DT_NONE; case QEMU_OPTION_curses: #ifdef CONFIG_CURSES display_type = DT_CURSES; #else error_report("curses support is disabled"); #endif case QEMU_OPTION_portrait: graphic_rotate = 90; case QEMU_OPTION_rotate: graphic_rotate = strtol(optarg, (char **) &optarg, 10); if (graphic_rotate != 0 && graphic_rotate != 90 && graphic_rotate != 180 && graphic_rotate != 270) { error_report("only 90, 180, 270 deg rotation is available"); case QEMU_OPTION_kernel: qemu_opts_set(qemu_find_opts("machine"), 0, "kernel", optarg, &error_abort); case QEMU_OPTION_initrd: qemu_opts_set(qemu_find_opts("machine"), 0, "initrd", optarg, &error_abort); case QEMU_OPTION_append: qemu_opts_set(qemu_find_opts("machine"), 0, "append", optarg, &error_abort); case QEMU_OPTION_dtb: qemu_opts_set(qemu_find_opts("machine"), 0, "dtb", optarg, &error_abort); case QEMU_OPTION_cdrom: drive_add(IF_DEFAULT, 2, optarg, CDROM_OPTS); case QEMU_OPTION_boot: opts = qemu_opts_parse_noisily(qemu_find_opts("boot-opts"), optarg, true); if (!opts) { case QEMU_OPTION_fda: case QEMU_OPTION_fdb: drive_add(IF_FLOPPY, popt->index - QEMU_OPTION_fda, optarg, FD_OPTS); case QEMU_OPTION_no_fd_bootchk: fd_bootchk = 0; case QEMU_OPTION_netdev: default_net = 0; if (net_client_parse(qemu_find_opts("netdev"), optarg) == -1) { case QEMU_OPTION_net: default_net = 0; if (net_client_parse(qemu_find_opts("net"), optarg) == -1) { #ifdef CONFIG_LIBISCSI case QEMU_OPTION_iscsi: opts = qemu_opts_parse_noisily(qemu_find_opts("iscsi"), optarg, false); if (!opts) { #endif #ifdef CONFIG_SLIRP case QEMU_OPTION_tftp: error_report("The -tftp option is deprecated. " "Please use '-netdev user,tftp=...' instead."); legacy_tftp_prefix = optarg; case QEMU_OPTION_bootp: error_report("The -bootp option is deprecated. " "Please use '-netdev user,bootfile=...' instead."); legacy_bootp_filename = optarg; case QEMU_OPTION_redir: error_report("The -redir option is deprecated. " "Please use '-netdev user,hostfwd=...' instead."); if (net_slirp_redir(optarg) < 0) #endif case QEMU_OPTION_bt: add_device_config(DEV_BT, optarg); case QEMU_OPTION_audio_help: AUD_help (); exit (0); case QEMU_OPTION_soundhw: select_soundhw (optarg); case QEMU_OPTION_h: help(0); case QEMU_OPTION_version: version(); exit(0); case QEMU_OPTION_m: opts = qemu_opts_parse_noisily(qemu_find_opts("memory"), optarg, true); if (!opts) { exit(EXIT_FAILURE); #ifdef CONFIG_TPM case QEMU_OPTION_tpmdev: if (tpm_config_parse(qemu_find_opts("tpmdev"), optarg) < 0) { #endif case QEMU_OPTION_mempath: mem_path = optarg; case QEMU_OPTION_mem_prealloc: mem_prealloc = 1; case QEMU_OPTION_d: log_mask = optarg; case QEMU_OPTION_D: log_file = optarg; case QEMU_OPTION_DFILTER: qemu_set_dfilter_ranges(optarg, &error_fatal); case QEMU_OPTION_s: add_device_config(DEV_GDB, "tcp::" DEFAULT_GDBSTUB_PORT); case QEMU_OPTION_gdb: add_device_config(DEV_GDB, optarg); case QEMU_OPTION_L: if (is_help_option(optarg)) { list_data_dirs = true; } else if (data_dir_idx < ARRAY_SIZE(data_dir)) { data_dir[data_dir_idx++] = optarg; case QEMU_OPTION_bios: qemu_opts_set(qemu_find_opts("machine"), 0, "firmware", optarg, &error_abort); case QEMU_OPTION_singlestep: singlestep = 1; case QEMU_OPTION_S: autostart = 0; case QEMU_OPTION_k: keyboard_layout = optarg; case QEMU_OPTION_localtime: rtc_utc = 0; case QEMU_OPTION_vga: vga_model = optarg; default_vga = 0; case QEMU_OPTION_g: const char *p; int w, h, depth; p = optarg; w = strtol(p, (char **)&p, 10); if (w <= 0) { graphic_error: error_report("invalid resolution or depth"); if (*p != 'x') goto graphic_error; p++; h = strtol(p, (char **)&p, 10); if (h <= 0) goto graphic_error; if (*p == 'x') { p++; depth = strtol(p, (char **)&p, 10); if (depth != 8 && depth != 15 && depth != 16 && depth != 24 && depth != 32) goto graphic_error; } else if (*p == '\0') { depth = graphic_depth; } else { goto graphic_error; graphic_width = w; graphic_height = h; graphic_depth = depth; case QEMU_OPTION_echr: char *r; term_escape_char = strtol(optarg, &r, 0); if (r == optarg) printf("Bad argument to echr\n"); case QEMU_OPTION_monitor: default_monitor = 0; if (strncmp(optarg, "none", 4)) { monitor_parse(optarg, "readline", false); case QEMU_OPTION_qmp: monitor_parse(optarg, "control", false); default_monitor = 0; case QEMU_OPTION_qmp_pretty: monitor_parse(optarg, "control", true); default_monitor = 0; case QEMU_OPTION_mon: opts = qemu_opts_parse_noisily(qemu_find_opts("mon"), optarg, true); if (!opts) { default_monitor = 0; case QEMU_OPTION_chardev: opts = qemu_opts_parse_noisily(qemu_find_opts("chardev"), optarg, true); if (!opts) { case QEMU_OPTION_fsdev: olist = qemu_find_opts("fsdev"); if (!olist) { error_report("fsdev support is disabled"); opts = qemu_opts_parse_noisily(olist, optarg, true); if (!opts) { case QEMU_OPTION_virtfs: { QemuOpts *fsdev; QemuOpts *device; const char *writeout, *sock_fd, *socket; olist = qemu_find_opts("virtfs"); if (!olist) { error_report("virtfs support is disabled"); opts = qemu_opts_parse_noisily(olist, optarg, true); if (!opts) { if (qemu_opt_get(opts, "fsdriver") == NULL || qemu_opt_get(opts, "mount_tag") == NULL) { error_report("Usage: -virtfs fsdriver,mount_tag=tag"); fsdev = qemu_opts_create(qemu_find_opts("fsdev"), qemu_opt_get(opts, "mount_tag"), 1, NULL); if (!fsdev) { error_report("duplicate fsdev id: %s", qemu_opt_get(opts, "mount_tag")); writeout = qemu_opt_get(opts, "writeout"); if (writeout) { #ifdef CONFIG_SYNC_FILE_RANGE qemu_opt_set(fsdev, "writeout", writeout, &error_abort); #else error_report("writeout=immediate not supported " "on this platform"); #endif qemu_opt_set(fsdev, "fsdriver", qemu_opt_get(opts, "fsdriver"), &error_abort); qemu_opt_set(fsdev, "path", qemu_opt_get(opts, "path"), &error_abort); qemu_opt_set(fsdev, "security_model", qemu_opt_get(opts, "security_model"), &error_abort); socket = qemu_opt_get(opts, "socket"); if (socket) { qemu_opt_set(fsdev, "socket", socket, &error_abort); sock_fd = qemu_opt_get(opts, "sock_fd"); if (sock_fd) { qemu_opt_set(fsdev, "sock_fd", sock_fd, &error_abort); qemu_opt_set_bool(fsdev, "readonly", qemu_opt_get_bool(opts, "readonly", 0), &error_abort); device = qemu_opts_create(qemu_find_opts("device"), NULL, 0, &error_abort); qemu_opt_set(device, "driver", "virtio-9p-pci", &error_abort); qemu_opt_set(device, "fsdev", qemu_opt_get(opts, "mount_tag"), &error_abort); qemu_opt_set(device, "mount_tag", qemu_opt_get(opts, "mount_tag"), &error_abort); case QEMU_OPTION_virtfs_synth: { QemuOpts *fsdev; QemuOpts *device; fsdev = qemu_opts_create(qemu_find_opts("fsdev"), "v_synth", 1, NULL); if (!fsdev) { error_report("duplicate option: %s", "virtfs_synth"); qemu_opt_set(fsdev, "fsdriver", "synth", &error_abort); device = qemu_opts_create(qemu_find_opts("device"), NULL, 0, &error_abort); qemu_opt_set(device, "driver", "virtio-9p-pci", &error_abort); qemu_opt_set(device, "fsdev", "v_synth", &error_abort); qemu_opt_set(device, "mount_tag", "v_synth", &error_abort); case QEMU_OPTION_serial: add_device_config(DEV_SERIAL, optarg); default_serial = 0; if (strncmp(optarg, "mon:", 4) == 0) { default_monitor = 0; case QEMU_OPTION_watchdog: if (watchdog) { error_report("only one watchdog option may be given"); return 1; watchdog = optarg; case QEMU_OPTION_watchdog_action: if (select_watchdog_action(optarg) == -1) { error_report("unknown -watchdog-action parameter"); case QEMU_OPTION_virtiocon: add_device_config(DEV_VIRTCON, optarg); default_virtcon = 0; if (strncmp(optarg, "mon:", 4) == 0) { default_monitor = 0; case QEMU_OPTION_parallel: add_device_config(DEV_PARALLEL, optarg); default_parallel = 0; if (strncmp(optarg, "mon:", 4) == 0) { default_monitor = 0; case QEMU_OPTION_debugcon: add_device_config(DEV_DEBUGCON, optarg); case QEMU_OPTION_loadvm: loadvm = optarg; case QEMU_OPTION_full_screen: full_screen = 1; case QEMU_OPTION_no_frame: no_frame = 1; case QEMU_OPTION_alt_grab: alt_grab = 1; case QEMU_OPTION_ctrl_grab: ctrl_grab = 1; case QEMU_OPTION_no_quit: no_quit = 1; case QEMU_OPTION_sdl: #ifdef CONFIG_SDL display_type = DT_SDL; #else error_report("SDL support is disabled"); #endif case QEMU_OPTION_pidfile: pid_file = optarg; case QEMU_OPTION_win2k_hack: win2k_install_hack = 1; case QEMU_OPTION_rtc_td_hack: { static GlobalProperty slew_lost_ticks = { .driver = "mc146818rtc", .property = "lost_tick_policy", .value = "slew", }; qdev_prop_register_global(&slew_lost_ticks); case QEMU_OPTION_acpitable: opts = qemu_opts_parse_noisily(qemu_find_opts("acpi"), optarg, true); if (!opts) { acpi_table_add(opts, &error_fatal); case QEMU_OPTION_smbios: opts = qemu_opts_parse_noisily(qemu_find_opts("smbios"), optarg, false); if (!opts) { smbios_entry_add(opts, &error_fatal); case QEMU_OPTION_fwcfg: opts = qemu_opts_parse_noisily(qemu_find_opts("fw_cfg"), optarg, true); if (opts == NULL) { case QEMU_OPTION_enable_kvm: olist = qemu_find_opts("machine"); qemu_opts_parse_noisily(olist, "accel=kvm", false); case QEMU_OPTION_enable_hax: olist = qemu_find_opts("machine"); qemu_opts_parse_noisily(olist, "accel=hax", false); case QEMU_OPTION_M: case QEMU_OPTION_machine: olist = qemu_find_opts("machine"); opts = qemu_opts_parse_noisily(olist, optarg, true); if (!opts) { case QEMU_OPTION_no_kvm: olist = qemu_find_opts("machine"); qemu_opts_parse_noisily(olist, "accel=tcg", false); case QEMU_OPTION_no_kvm_pit: { error_report("warning: ignoring deprecated option"); case QEMU_OPTION_no_kvm_pit_reinjection: { static GlobalProperty kvm_pit_lost_tick_policy = { .driver = "kvm-pit", .property = "lost_tick_policy", .value = "discard", }; error_report("warning: deprecated, replaced by " "-global kvm-pit.lost_tick_policy=discard"); qdev_prop_register_global(&kvm_pit_lost_tick_policy); case QEMU_OPTION_accel: accel_opts = qemu_opts_parse_noisily(qemu_find_opts("accel"), optarg, true); optarg = qemu_opt_get(accel_opts, "accel"); olist = qemu_find_opts("machine"); if (strcmp("kvm", optarg) == 0) { qemu_opts_parse_noisily(olist, "accel=kvm", false); } else if (strcmp("xen", optarg) == 0) { qemu_opts_parse_noisily(olist, "accel=xen", false); } else if (strcmp("tcg", optarg) == 0) { qemu_opts_parse_noisily(olist, "accel=tcg", false); } else { if (!is_help_option(optarg)) { error_printf("Unknown accelerator: %s", optarg); error_printf("Supported accelerators: kvm, xen, tcg\n"); case QEMU_OPTION_usb: olist = qemu_find_opts("machine"); qemu_opts_parse_noisily(olist, "usb=on", false); case QEMU_OPTION_usbdevice: olist = qemu_find_opts("machine"); qemu_opts_parse_noisily(olist, "usb=on", false); add_device_config(DEV_USB, optarg); case QEMU_OPTION_device: if (!qemu_opts_parse_noisily(qemu_find_opts("device"), optarg, true)) { case QEMU_OPTION_smp: if (!qemu_opts_parse_noisily(qemu_find_opts("smp-opts"), optarg, true)) { case QEMU_OPTION_vnc: vnc_parse(optarg, &error_fatal); case QEMU_OPTION_no_acpi: acpi_enabled = 0; case QEMU_OPTION_no_hpet: no_hpet = 1; case QEMU_OPTION_balloon: if (balloon_parse(optarg) < 0) { error_report("unknown -balloon argument %s", optarg); case QEMU_OPTION_no_reboot: no_reboot = 1; case QEMU_OPTION_no_shutdown: no_shutdown = 1; case QEMU_OPTION_show_cursor: cursor_hide = 0; case QEMU_OPTION_uuid: if (qemu_uuid_parse(optarg, &qemu_uuid) < 0) { error_report("failed to parse UUID string: wrong format"); qemu_uuid_set = true; case QEMU_OPTION_option_rom: if (nb_option_roms >= MAX_OPTION_ROMS) { error_report("too many option ROMs"); opts = qemu_opts_parse_noisily(qemu_find_opts("option-rom"), optarg, true); if (!opts) { option_rom[nb_option_roms].name = qemu_opt_get(opts, "romfile"); option_rom[nb_option_roms].bootindex = qemu_opt_get_number(opts, "bootindex", -1); if (!option_rom[nb_option_roms].name) { error_report("Option ROM file is not specified"); nb_option_roms++; case QEMU_OPTION_semihosting: semihosting.enabled = true; semihosting.target = SEMIHOSTING_TARGET_AUTO; case QEMU_OPTION_semihosting_config: semihosting.enabled = true; opts = qemu_opts_parse_noisily(qemu_find_opts("semihosting-config"), optarg, false); if (opts != NULL) { semihosting.enabled = qemu_opt_get_bool(opts, "enable", true); const char *target = qemu_opt_get(opts, "target"); if (target != NULL) { if (strcmp("native", target) == 0) { semihosting.target = SEMIHOSTING_TARGET_NATIVE; } else if (strcmp("gdb", target) == 0) { semihosting.target = SEMIHOSTING_TARGET_GDB; } else if (strcmp("auto", target) == 0) { semihosting.target = SEMIHOSTING_TARGET_AUTO; } else { error_report("unsupported semihosting-config %s", optarg); } else { semihosting.target = SEMIHOSTING_TARGET_AUTO; /* Set semihosting argument count and vector */ qemu_opt_foreach(opts, add_semihosting_arg, &semihosting, NULL); } else { error_report("unsupported semihosting-config %s", optarg); case QEMU_OPTION_tdf: error_report("warning: ignoring deprecated option"); case QEMU_OPTION_name: opts = qemu_opts_parse_noisily(qemu_find_opts("name"), optarg, true); if (!opts) { case QEMU_OPTION_prom_env: if (nb_prom_envs >= MAX_PROM_ENVS) { error_report("too many prom variables"); prom_envs[nb_prom_envs] = optarg; nb_prom_envs++; case QEMU_OPTION_old_param: old_param = 1; case QEMU_OPTION_clock: /* Clock options no longer exist. Keep this option for * backward compatibility. */ case QEMU_OPTION_startdate: configure_rtc_date_offset(optarg, 1); case QEMU_OPTION_rtc: opts = qemu_opts_parse_noisily(qemu_find_opts("rtc"), optarg, false); if (!opts) { configure_rtc(opts); case QEMU_OPTION_tb_size: tcg_tb_size = strtol(optarg, NULL, 0); if (tcg_tb_size < 0) { tcg_tb_size = 0; case QEMU_OPTION_icount: icount_opts = qemu_opts_parse_noisily(qemu_find_opts("icount"), optarg, true); if (!icount_opts) { case QEMU_OPTION_incoming: if (!incoming) { runstate_set(RUN_STATE_INMIGRATE); incoming = optarg; case QEMU_OPTION_only_migratable: only_migratable = 1; case QEMU_OPTION_nodefaults: has_defaults = 0; case QEMU_OPTION_xen_domid: if (!(xen_available())) { error_report("Option not supported for this target"); xen_domid = atoi(optarg); case QEMU_OPTION_xen_create: if (!(xen_available())) { error_report("Option not supported for this target"); xen_mode = XEN_CREATE; case QEMU_OPTION_xen_attach: if (!(xen_available())) { error_report("Option not supported for this target"); xen_mode = XEN_ATTACH; case QEMU_OPTION_trace: g_free(trace_file); trace_file = trace_opt_parse(optarg); case QEMU_OPTION_readconfig: int ret = qemu_read_config_file(optarg); if (ret < 0) { error_report("read config %s: %s", optarg, strerror(-ret)); case QEMU_OPTION_spice: olist = qemu_find_opts("spice"); if (!olist) { error_report("spice support is disabled"); opts = qemu_opts_parse_noisily(olist, optarg, false); if (!opts) { display_remote++; case QEMU_OPTION_writeconfig: FILE *fp; if (strcmp(optarg, "-") == 0) { fp = stdout; } else { fp = fopen(optarg, "w"); if (fp == NULL) { error_report("open %s: %s", optarg, strerror(errno)); qemu_config_write(fp); if (fp != stdout) { fclose(fp); case QEMU_OPTION_qtest: qtest_chrdev = optarg; case QEMU_OPTION_qtest_log: qtest_log = optarg; case QEMU_OPTION_sandbox: opts = qemu_opts_parse_noisily(qemu_find_opts("sandbox"), optarg, true); if (!opts) { case QEMU_OPTION_add_fd: #ifndef _WIN32 opts = qemu_opts_parse_noisily(qemu_find_opts("add-fd"), optarg, false); if (!opts) { #else error_report("File descriptor passing is disabled on this " "platform"); #endif case QEMU_OPTION_object: opts = qemu_opts_parse_noisily(qemu_find_opts("object"), optarg, true); if (!opts) { case QEMU_OPTION_realtime: opts = qemu_opts_parse_noisily(qemu_find_opts("realtime"), optarg, false); if (!opts) { enable_mlock = qemu_opt_get_bool(opts, "mlock", true); case QEMU_OPTION_msg: opts = qemu_opts_parse_noisily(qemu_find_opts("msg"), optarg, false); if (!opts) { configure_msg(opts); case QEMU_OPTION_dump_vmstate: if (vmstate_dump_file) { error_report("only one '-dump-vmstate' " "option may be given"); vmstate_dump_file = fopen(optarg, "w"); if (vmstate_dump_file == NULL) { error_report("open %s: %s", optarg, strerror(errno)); default: os_parse_cmd_args(popt->index, optarg); /* * Clear error location left behind by the loop. * Best done right after the loop. Do not insert code here! */ loc_set_none(); replay_configure(icount_opts); qemu_tcg_configure(accel_opts, &error_fatal); machine_class = select_machine(); set_memory_options(&ram_slots, &maxram_size, machine_class); os_daemonize(); if (pid_file && qemu_create_pidfile(pid_file) != 0) { error_report("could not acquire pid file: %s", strerror(errno)); if (qemu_init_main_loop(&main_loop_err)) { error_report_err(main_loop_err); if (qemu_opts_foreach(qemu_find_opts("sandbox"), parse_sandbox, NULL, NULL)) { if (qemu_opts_foreach(qemu_find_opts("name"), parse_name, NULL, NULL)) { #ifndef _WIN32 if (qemu_opts_foreach(qemu_find_opts("add-fd"), parse_add_fd, NULL, NULL)) { if (qemu_opts_foreach(qemu_find_opts("add-fd"), cleanup_add_fd, NULL, NULL)) { #endif current_machine = MACHINE(object_new(object_class_get_name( OBJECT_CLASS(machine_class)))); if (machine_help_func(qemu_get_machine_opts(), current_machine)) { exit(0); object_property_add_child(object_get_root(), "machine", OBJECT(current_machine), &error_abort); if (machine_class->minimum_page_bits) { if (!set_preferred_target_page_bits(machine_class->minimum_page_bits)) { /* This would be a board error: specifying a minimum smaller than * a target's compile-time fixed setting. */ g_assert_not_reached(); cpu_exec_init_all(); if (machine_class->hw_version) { qemu_set_hw_version(machine_class->hw_version); if (cpu_model && is_help_option(cpu_model)) { list_cpus(stdout, &fprintf, cpu_model); exit(0); if (!trace_init_backends()) { trace_init_file(trace_file); /* Open the logfile at this point and set the log mask if necessary. */ if (log_file) { qemu_set_log_filename(log_file, &error_fatal); if (log_mask) { int mask; mask = qemu_str_to_log_mask(log_mask); if (!mask) { qemu_print_log_usage(stdout); qemu_set_log(mask); } else { qemu_set_log(0); /* If no data_dir is specified then try to find it relative to the executable path. */ if (data_dir_idx < ARRAY_SIZE(data_dir)) { data_dir[data_dir_idx] = os_find_datadir(); if (data_dir[data_dir_idx] != NULL) { data_dir_idx++; /* If all else fails use the install path specified when building. */ if (data_dir_idx < ARRAY_SIZE(data_dir)) { data_dir[data_dir_idx++] = CONFIG_QEMU_DATADIR; /* -L help lists the data directories and exits. */ if (list_data_dirs) { for (i = 0; i < data_dir_idx; i++) { printf("%s\n", data_dir[i]); exit(0); smp_parse(qemu_opts_find(qemu_find_opts("smp-opts"), NULL)); machine_class->max_cpus = machine_class->max_cpus ?: 1; /* Default to UP */ if (max_cpus > machine_class->max_cpus) { error_report("Number of SMP CPUs requested (%d) exceeds max CPUs " "supported by machine '%s' (%d)", max_cpus, machine_class->name, machine_class->max_cpus); /* * Get the default machine options from the machine if it is not already * specified either by the configuration file or by the command line. */ if (machine_class->default_machine_opts) { qemu_opts_set_defaults(qemu_find_opts("machine"), machine_class->default_machine_opts, 0); qemu_opts_foreach(qemu_find_opts("device"), default_driver_check, NULL, NULL); qemu_opts_foreach(qemu_find_opts("global"), default_driver_check, NULL, NULL); if (!vga_model && !default_vga) { vga_interface_type = VGA_DEVICE; if (!has_defaults || machine_class->no_serial) { default_serial = 0; if (!has_defaults || machine_class->no_parallel) { default_parallel = 0; if (!has_defaults || !machine_class->use_virtcon) { default_virtcon = 0; if (!has_defaults || !machine_class->use_sclp) { default_sclp = 0; if (!has_defaults || machine_class->no_floppy) { default_floppy = 0; if (!has_defaults || machine_class->no_cdrom) { default_cdrom = 0; if (!has_defaults || machine_class->no_sdcard) { default_sdcard = 0; if (!has_defaults) { default_monitor = 0; default_net = 0; default_vga = 0; if (is_daemonized()) { /* According to documentation and historically, -nographic redirects * serial port, parallel port and monitor to stdio, which does not work * with -daemonize. We can redirect these to null instead, but since * -nographic is legacy, let's just error out. * We disallow -nographic only if all other ports are not redirected * explicitly, to not break existing legacy setups which uses * -nographic _and_ redirects all ports explicitly - this is valid * usage, -nographic is just a no-op in this case. */ if (nographic && (default_parallel || default_serial || default_monitor || default_virtcon)) { error_report("-nographic cannot be used with -daemonize"); #ifdef CONFIG_CURSES if (display_type == DT_CURSES) { error_report("curses display cannot be used with -daemonize"); #endif if (nographic) { if (default_parallel) add_device_config(DEV_PARALLEL, "null"); if (default_serial && default_monitor) { add_device_config(DEV_SERIAL, "mon:stdio"); } else if (default_virtcon && default_monitor) { add_device_config(DEV_VIRTCON, "mon:stdio"); } else if (default_sclp && default_monitor) { add_device_config(DEV_SCLP, "mon:stdio"); } else { if (default_serial) add_device_config(DEV_SERIAL, "stdio"); if (default_virtcon) add_device_config(DEV_VIRTCON, "stdio"); if (default_sclp) { add_device_config(DEV_SCLP, "stdio"); if (default_monitor) monitor_parse("stdio", "readline", false); } else { if (default_serial) add_device_config(DEV_SERIAL, "vc:80Cx24C"); if (default_parallel) add_device_config(DEV_PARALLEL, "vc:80Cx24C"); if (default_monitor) monitor_parse("vc:80Cx24C", "readline", false); if (default_virtcon) add_device_config(DEV_VIRTCON, "vc:80Cx24C"); if (default_sclp) { add_device_config(DEV_SCLP, "vc:80Cx24C"); #if defined(CONFIG_VNC) if (!QTAILQ_EMPTY(&(qemu_find_opts("vnc")->head))) { display_remote++; #endif if (display_type == DT_DEFAULT && !display_remote) { #if defined(CONFIG_GTK) display_type = DT_GTK; #elif defined(CONFIG_SDL) display_type = DT_SDL; #elif defined(CONFIG_COCOA) display_type = DT_COCOA; #elif defined(CONFIG_VNC) vnc_parse("localhost:0,to=99,id=default", &error_abort); #else display_type = DT_NONE; #endif if ((no_frame || alt_grab || ctrl_grab) && display_type != DT_SDL) { error_report("-no-frame, -alt-grab and -ctrl-grab are only valid " "for SDL, ignoring option"); if (no_quit && (display_type != DT_GTK && display_type != DT_SDL)) { error_report("-no-quit is only valid for GTK and SDL, " "ignoring option"); if (display_type == DT_GTK) { early_gtk_display_init(request_opengl); if (display_type == DT_SDL) { sdl_display_early_init(request_opengl); qemu_console_early_init(); if (request_opengl == 1 && display_opengl == 0) { #if defined(CONFIG_OPENGL) error_report("OpenGL is not supported by the display"); #else error_report("OpenGL support is disabled"); #endif page_size_init(); socket_init(); if (qemu_opts_foreach(qemu_find_opts("object"), user_creatable_add_opts_foreach, object_create_initial, NULL)) { if (qemu_opts_foreach(qemu_find_opts("chardev"), chardev_init_func, NULL, NULL)) { #ifdef CONFIG_VIRTFS if (qemu_opts_foreach(qemu_find_opts("fsdev"), fsdev_init_func, NULL, NULL)) { #endif if (qemu_opts_foreach(qemu_find_opts("device"), device_help_func, NULL, NULL)) { exit(0); machine_opts = qemu_get_machine_opts(); if (qemu_opt_foreach(machine_opts, machine_set_property, current_machine, NULL)) { object_unref(OBJECT(current_machine)); configure_accelerator(current_machine); if (qtest_chrdev) { qtest_init(qtest_chrdev, qtest_log, &error_fatal); machine_opts = qemu_get_machine_opts(); kernel_filename = qemu_opt_get(machine_opts, "kernel"); initrd_filename = qemu_opt_get(machine_opts, "initrd"); kernel_cmdline = qemu_opt_get(machine_opts, "append"); bios_name = qemu_opt_get(machine_opts, "firmware"); opts = qemu_opts_find(qemu_find_opts("boot-opts"), NULL); if (opts) { boot_order = qemu_opt_get(opts, "order"); if (boot_order) { validate_bootdevices(boot_order, &error_fatal); boot_once = qemu_opt_get(opts, "once"); if (boot_once) { validate_bootdevices(boot_once, &error_fatal); boot_menu = qemu_opt_get_bool(opts, "menu", boot_menu); boot_strict = qemu_opt_get_bool(opts, "strict", false); if (!boot_order) { boot_order = machine_class->default_boot_order; if (!kernel_cmdline) { kernel_cmdline = ""; current_machine->kernel_cmdline = (char *)kernel_cmdline; linux_boot = (kernel_filename != NULL); if (!linux_boot && *kernel_cmdline != '\0') { error_report("-append only allowed with -kernel option"); if (!linux_boot && initrd_filename != NULL) { error_report("-initrd only allowed with -kernel option"); if (semihosting_enabled() && !semihosting_get_argc() && kernel_filename) { /* fall back to the -kernel/-append */ semihosting_arg_fallback(kernel_filename, kernel_cmdline); os_set_line_buffering(); /* spice needs the timers to be initialized by this point */ qemu_spice_init(); cpu_ticks_init(); if (icount_opts) { if (!tcg_enabled()) { error_report("-icount is not allowed with hardware virtualization"); } else if (qemu_tcg_mttcg_enabled()) { error_report("-icount does not currently work with MTTCG"); configure_icount(icount_opts, &error_abort); qemu_opts_del(icount_opts); if (default_net) { QemuOptsList *net = qemu_find_opts("net"); qemu_opts_set(net, NULL, "type", "nic", &error_abort); #ifdef CONFIG_SLIRP qemu_opts_set(net, NULL, "type", "user", &error_abort); #endif colo_info_init(); if (net_init_clients() < 0) { if (qemu_opts_foreach(qemu_find_opts("object"), user_creatable_add_opts_foreach, object_create_delayed, NULL)) { #ifdef CONFIG_TPM if (tpm_init() < 0) { #endif /* init the bluetooth world */ if (foreach_device_config(DEV_BT, bt_parse)) if (!xen_enabled()) { /* On 32-bit hosts, QEMU is limited by virtual address space */ if (ram_size > (2047 << 20) && HOST_LONG_BITS == 32) { error_report("at most 2047 MB RAM can be simulated"); blk_mig_init(); ram_mig_init(); /* If the currently selected machine wishes to override the units-per-bus * property of its default HBA interface type, do so now. */ if (machine_class->units_per_default_bus) { override_max_devs(machine_class->block_default_type, machine_class->units_per_default_bus); /* open the virtual block devices */ while (!QSIMPLEQ_EMPTY(&bdo_queue)) { BlockdevOptions_queue *bdo = QSIMPLEQ_FIRST(&bdo_queue); QSIMPLEQ_REMOVE_HEAD(&bdo_queue, entry); loc_push_restore(&bdo->loc); qmp_blockdev_add(bdo->bdo, &error_fatal); loc_pop(&bdo->loc); qapi_free_BlockdevOptions(bdo->bdo); g_free(bdo); if (snapshot || replay_mode != REPLAY_MODE_NONE) { qemu_opts_foreach(qemu_find_opts("drive"), drive_enable_snapshot, NULL, NULL); if (qemu_opts_foreach(qemu_find_opts("drive"), drive_init_func, &machine_class->block_default_type, NULL)) { default_drive(default_cdrom, snapshot, machine_class->block_default_type, 2, CDROM_OPTS); default_drive(default_floppy, snapshot, IF_FLOPPY, 0, FD_OPTS); default_drive(default_sdcard, snapshot, IF_SD, 0, SD_OPTS); parse_numa_opts(machine_class); if (qemu_opts_foreach(qemu_find_opts("mon"), mon_init_func, NULL, NULL)) { if (foreach_device_config(DEV_SERIAL, serial_parse) < 0) if (foreach_device_config(DEV_PARALLEL, parallel_parse) < 0) if (foreach_device_config(DEV_VIRTCON, virtcon_parse) < 0) if (foreach_device_config(DEV_SCLP, sclp_parse) < 0) { if (foreach_device_config(DEV_DEBUGCON, debugcon_parse) < 0) /* If no default VGA is requested, the default is "none". */ if (default_vga) { if (machine_class->default_display) { vga_model = machine_class->default_display; } else if (vga_interface_available(VGA_CIRRUS)) { vga_model = "cirrus"; } else if (vga_interface_available(VGA_STD)) { vga_model = "std"; if (vga_model) { select_vgahw(vga_model); if (watchdog) { i = select_watchdog(watchdog); if (i > 0) exit (i == 1 ? 1 : 0); machine_register_compat_props(current_machine); qemu_opts_foreach(qemu_find_opts("global"), global_init_func, NULL, NULL); /* This checkpoint is required by replay to separate prior clock reading from the other reads, because timer polling functions query clock values from the log. */ replay_checkpoint(CHECKPOINT_INIT); qdev_machine_init(); current_machine->ram_size = ram_size; current_machine->maxram_size = maxram_size; current_machine->ram_slots = ram_slots; current_machine->boot_order = boot_order; current_machine->cpu_model = cpu_model; machine_class->init(current_machine); realtime_init(); audio_init(); if (hax_enabled()) { hax_sync_vcpus(); if (qemu_opts_foreach(qemu_find_opts("fw_cfg"), parse_fw_cfg, fw_cfg_find(), NULL) != 0) { /* init USB devices */ if (machine_usb(current_machine)) { if (foreach_device_config(DEV_USB, usb_parse) < 0) /* Check if IGD GFX passthrough. */ igd_gfx_passthru(); /* init generic devices */ rom_set_order_override(FW_CFG_ORDER_OVERRIDE_DEVICE); if (qemu_opts_foreach(qemu_find_opts("device"), device_init_func, NULL, NULL)) { cpu_synchronize_all_post_init(); numa_post_machine_init(); rom_reset_order_override(); /* * Create frontends for -drive if=scsi leftovers. * Normally, frontends for -drive get created by machine * initialization for onboard SCSI HBAs. However, we create a few * more ever since SCSI qdevification, but this is pretty much an * implementation accident, and deprecated. */ scsi_legacy_handle_cmdline(); /* Did we create any drives that we failed to create a device for? */ drive_check_orphaned(); /* Don't warn about the default network setup that you get if * no command line -net or -netdev options are specified. There * are two cases that we would otherwise complain about: * (1) board doesn't support a NIC but the implicit "-net nic" * requested one * (2) CONFIG_SLIRP not set, in which case the implicit "-net nic" * sets up a nic that isn't connected to anything. */ if (!default_net) { net_check_clients(); if (boot_once) { qemu_boot_set(boot_once, &error_fatal); qemu_register_reset(restore_boot_order, g_strdup(boot_order)); ds = init_displaystate(); /* init local displays */ switch (display_type) { case DT_CURSES: curses_display_init(ds, full_screen); case DT_SDL: sdl_display_init(ds, full_screen, no_frame); case DT_COCOA: cocoa_display_init(ds, full_screen); case DT_GTK: gtk_display_init(ds, full_screen, grab_on_hover); default: /* must be after terminal init, SDL library changes signal handlers */ os_setup_signal_handling(); /* init remote displays */ #ifdef CONFIG_VNC qemu_opts_foreach(qemu_find_opts("vnc"), vnc_init_func, NULL, NULL); #endif if (using_spice) { qemu_spice_display_init(); if (foreach_device_config(DEV_GDB, gdbserver_start) < 0) { qdev_machine_creation_done(); /* TODO: once all bus devices are qdevified, this should be done * when bus is created by qdev.c */ qemu_register_reset(qbus_reset_all_fn, sysbus_get_default()); qemu_run_machine_init_done_notifiers(); if (rom_check_and_register_reset() != 0) { error_report("rom check and register reset failed"); replay_start(); /* This checkpoint is required by replay to separate prior clock reading from the other reads, because timer polling functions query clock values from the log. */ replay_checkpoint(CHECKPOINT_RESET); qemu_system_reset(VMRESET_SILENT); register_global_state(); if (replay_mode != REPLAY_MODE_NONE) { replay_vmstate_init(); } else if (loadvm) { if (load_vmstate(loadvm) < 0) { autostart = 0; qdev_prop_check_globals(); if (vmstate_dump_file) { /* dump and exit */ dump_vmstate_json_to_file(vmstate_dump_file); return 0; if (incoming) { Error *local_err = NULL; qemu_start_incoming_migration(incoming, &local_err); if (local_err) { error_reportf_err(local_err, "-incoming %s: ", incoming); } else if (autostart) { vm_start(); os_setup_post(); main_loop(); replay_disable_events(); iothread_stop_all(); bdrv_close_all(); pause_all_vcpus(); res_free(); /* vhost-user must be cleaned up before chardevs. */ net_cleanup(); audio_cleanup(); monitor_cleanup(); qemu_chr_cleanup(); return 0;


static int mv_err_cost ( const MV * mv , const MV * ref , const int * mvjcost , int * mvcost [ 2 ] , int error_per_bit ) {
 if ( mvcost ) {
 const MV diff = {
 mv -> row - ref -> row , mv -> col - ref -> col }
 ;
 return ROUND_POWER_OF_TWO ( mv_cost ( & diff , mvjcost , mvcost ) * error_per_bit , 13 ) ;
 }
 return 0 ;
 }


static av_cold int libopus_decode_init(AVCodecContext *avc) { struct libopus_context *opus = avc->priv_data; int ret, channel_map = 0, gain_db = 0, nb_streams, nb_coupled; uint8_t mapping_arr[8] = { 0, 1 }, *mapping; avc->sample_rate = 48000; avc->sample_fmt = avc->request_sample_fmt == AV_SAMPLE_FMT_FLT ? AV_SAMPLE_FMT_FLT : AV_SAMPLE_FMT_S16; avc->channel_layout = avc->channels > 8 ? 0 : ff_vorbis_channel_layouts[avc->channels - 1]; if (avc->extradata_size >= OPUS_HEAD_SIZE) { gain_db = sign_extend(AV_RL16(avc->extradata + 16), 16); channel_map = AV_RL8 (avc->extradata + 18); if (avc->extradata_size >= OPUS_HEAD_SIZE + 2 + avc->channels) { nb_streams = avc->extradata[OPUS_HEAD_SIZE + 0]; nb_coupled = avc->extradata[OPUS_HEAD_SIZE + 1]; if (nb_streams + nb_coupled != avc->channels) av_log(avc, AV_LOG_WARNING, "Inconsistent channel mapping.\n"); mapping = avc->extradata + OPUS_HEAD_SIZE + 2; } else { if (avc->channels > 2 || channel_map) { av_log(avc, AV_LOG_ERROR, "No channel mapping for %d channels.\n", avc->channels); return AVERROR(EINVAL); nb_streams = 1; nb_coupled = avc->channels > 1; mapping = mapping_arr; if (avc->channels > 2 && avc->channels <= 8) { const uint8_t *vorbis_offset = ff_vorbis_channel_layout_offsets[avc->channels - 1]; int ch; /* Remap channels from Vorbis order to libav order */ for (ch = 0; ch < avc->channels; ch++) mapping_arr[ch] = mapping[vorbis_offset[ch]]; mapping = mapping_arr; opus->dec = opus_multistream_decoder_create(avc->sample_rate, avc->channels, nb_streams, nb_coupled, mapping, &ret); if (!opus->dec) { av_log(avc, AV_LOG_ERROR, "Unable to create decoder: %s\n", opus_strerror(ret)); return ff_opus_error_to_averror(ret); ret = opus_multistream_decoder_ctl(opus->dec, OPUS_SET_GAIN(gain_db)); if (ret != OPUS_OK) av_log(avc, AV_LOG_WARNING, "Failed to set gain: %s\n", opus_strerror(ret)); avc->delay = 3840; /* Decoder delay (in samples) at 48kHz */ return 0;


gen_intermediate_code_internal(CPUCRISState *env, TranslationBlock *tb, int search_pc) { uint16_t *gen_opc_end; uint32_t pc_start; unsigned int insn_len; int j, lj; struct DisasContext ctx; struct DisasContext *dc = &ctx; uint32_t next_page_start; target_ulong npc; int num_insns; int max_insns; qemu_log_try_set_file(stderr); if (env->pregs[PR_VR] == 32) { dc->decoder = crisv32_decoder; dc->clear_locked_irq = 0; } else { dc->decoder = crisv10_decoder; dc->clear_locked_irq = 1; } /* Odd PC indicates that branch is rexecuting due to exception in the * delayslot, like in real hw. */ pc_start = tb->pc & ~1; dc->env = env; dc->tb = tb; gen_opc_end = tcg_ctx.gen_opc_buf + OPC_MAX_SIZE; dc->is_jmp = DISAS_NEXT; dc->ppc = pc_start; dc->pc = pc_start; dc->singlestep_enabled = env->singlestep_enabled; dc->flags_uptodate = 1; dc->flagx_known = 1; dc->flags_x = tb->flags & X_FLAG; dc->cc_x_uptodate = 0; dc->cc_mask = 0; dc->update_cc = 0; dc->clear_prefix = 0; cris_update_cc_op(dc, CC_OP_FLAGS, 4); dc->cc_size_uptodate = -1; /* Decode TB flags. */ dc->tb_flags = tb->flags & (S_FLAG | P_FLAG | U_FLAG \ | X_FLAG | PFIX_FLAG); dc->delayed_branch = !!(tb->flags & 7); if (dc->delayed_branch) { dc->jmp = JMP_INDIRECT; } else { dc->jmp = JMP_NOJMP; } dc->cpustate_changed = 0; if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) { qemu_log( "srch=%d pc=%x %x flg=%" PRIx64 " bt=%x ds=%u ccs=%x\n" "pid=%x usp=%x\n" "%x.%x.%x.%x\n" "%x.%x.%x.%x\n" "%x.%x.%x.%x\n" "%x.%x.%x.%x\n", search_pc, dc->pc, dc->ppc, (uint64_t)tb->flags, env->btarget, (unsigned)tb->flags & 7, env->pregs[PR_CCS], env->pregs[PR_PID], env->pregs[PR_USP], env->regs[0], env->regs[1], env->regs[2], env->regs[3], env->regs[4], env->regs[5], env->regs[6], env->regs[7], env->regs[8], env->regs[9], env->regs[10], env->regs[11], env->regs[12], env->regs[13], env->regs[14], env->regs[15]); qemu_log("--------------\n"); qemu_log("IN: %s\n", lookup_symbol(pc_start)); } 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_icount_start(); do { check_breakpoint(env, dc); if (search_pc) { j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf; if (lj < j) { lj++; while (lj < j) { tcg_ctx.gen_opc_instr_start[lj++] = 0; } } if (dc->delayed_branch == 1) { tcg_ctx.gen_opc_pc[lj] = dc->ppc | 1; } else { 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_x = 1; insn_len = dc->decoder(env, dc); dc->ppc = dc->pc; dc->pc += insn_len; if (dc->clear_x) { cris_clear_x_flag(dc); } num_insns++; /* Check for delayed branches here. If we do it before actually generating any host code, the simulator will just loop doing nothing for on this program location. */ if (dc->delayed_branch) { dc->delayed_branch--; if (dc->delayed_branch == 0) { if (tb->flags & 7) { t_gen_mov_env_TN(dslot, tcg_const_tl(0)); } if (dc->cpustate_changed || !dc->flagx_known || (dc->flags_x != (tb->flags & X_FLAG))) { cris_store_direct_jmp(dc); } if (dc->clear_locked_irq) { dc->clear_locked_irq = 0; t_gen_mov_env_TN(locked_irq, tcg_const_tl(0)); } if (dc->jmp == JMP_DIRECT_CC) { int l1; l1 = gen_new_label(); cris_evaluate_flags(dc); /* Conditional jmp. */ tcg_gen_brcondi_tl(TCG_COND_EQ, env_btaken, 0, l1); gen_goto_tb(dc, 1, dc->jmp_pc); gen_set_label(l1); gen_goto_tb(dc, 0, dc->pc); dc->is_jmp = DISAS_TB_JUMP; dc->jmp = JMP_NOJMP; } else if (dc->jmp == JMP_DIRECT) { cris_evaluate_flags(dc); gen_goto_tb(dc, 0, dc->jmp_pc); dc->is_jmp = DISAS_TB_JUMP; dc->jmp = JMP_NOJMP; } else { t_gen_cc_jmp(env_btarget, tcg_const_tl(dc->pc)); dc->is_jmp = DISAS_JUMP; } break; } } /* If we are rexecuting a branch due to exceptions on delay slots dont break. */ if (!(tb->pc & 1) && env->singlestep_enabled) { break; } } while (!dc->is_jmp && !dc->cpustate_changed && tcg_ctx.gen_opc_ptr < gen_opc_end && !singlestep && (dc->pc < next_page_start) && num_insns < max_insns); if (dc->clear_locked_irq) { t_gen_mov_env_TN(locked_irq, tcg_const_tl(0)); } npc = dc->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 || !dc->flagx_known || (dc->flags_x != (tb->flags & X_FLAG)))) { dc->is_jmp = DISAS_UPDATE; tcg_gen_movi_tl(env_pc, npc); } /* Broken branch+delayslot sequence. */ if (dc->delayed_branch == 1) { /* Set env->dslot to the size of the branch insn. */ t_gen_mov_env_TN(dslot, tcg_const_tl(dc->pc - dc->ppc)); cris_store_direct_jmp(dc); } cris_evaluate_flags(dc); if (unlikely(env->singlestep_enabled)) { if (dc->is_jmp == DISAS_NEXT) { tcg_gen_movi_tl(env_pc, npc); } t_gen_raise_exception(EXCP_DEBUG); } 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_SWI: case DISAS_TB_JUMP: /* nothing more to generate */ break; } } gen_icount_end(tb, num_insns); *tcg_ctx.gen_opc_ptr = INDEX_op_end; if (search_pc) { j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf; 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 !DISAS_CRIS if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) { log_target_disas(env, pc_start, dc->pc - pc_start, dc->env->pregs[PR_VR]); qemu_log("\nisize=%d osize=%td\n", dc->pc - pc_start, tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf); } #endif #endif }


METHOD ( certificate_t , get_encoding , bool , private_x509_cert_t * this , cred_encoding_type_t type , chunk_t * encoding ) {
 if ( type == CERT_ASN1_DER ) {
 * encoding = chunk_clone ( this -> encoding ) ;
 return TRUE ;
 }
 return lib -> encoding -> encode ( lib -> encoding , type , NULL , encoding , CRED_PART_X509_ASN1_DER , this -> encoding , CRED_PART_END ) ;
 }


static void clear_rulist(rzip_control *control)
{
	while (control->ruhead) {
		struct runzip_node *node = control->ruhead;
		struct stream_info *sinfo = node->sinfo;

		dealloc(sinfo->ucthreads);
		dealloc(node->pthreads);
		dealloc(sinfo->s);
		dealloc(sinfo);
		control->ruhead = node->prev;
		dealloc(node);
	}
}


inline void umtx_initOnce ( UInitOnce & uio , void ( U_CALLCONV * fp ) ( UErrorCode & ) , UErrorCode & errCode ) {
 if ( U_FAILURE ( errCode ) ) {
 return ;
 }
 if ( umtx_loadAcquire ( uio . fState ) != 2 && umtx_initImplPreInit ( uio ) ) {
 ( * fp ) ( errCode ) ;
 uio . fErrCode = errCode ;
 umtx_initImplPostInit ( uio ) ;
 }
 else {
 if ( U_FAILURE ( uio . fErrCode ) ) {
 errCode = uio . fErrCode ;
 }
 }
 }


int ffurl_read(URLContext *h, unsigned char *buf, int size) { if (h->flags & AVIO_FLAG_WRITE) return AVERROR(EIO); return retry_transfer_wrapper(h, buf, size, 1, h->prot->url_read); }


static int decode_nfs_fh(struct xdr_stream *xdr, struct nfs_fh *fh)
{
	__be32 *p;

	p = xdr_inline_decode(xdr, 4);
	if (unlikely(!p))
		return -ENOBUFS;
	fh->size = be32_to_cpup(p++);
	if (fh->size > sizeof(struct nfs_fh)) {
		printk(KERN_ERR "NFS flexfiles: Too big fh received %d\n",
		       fh->size);
		return -EOVERFLOW;
	}
	/* fh.data */
	p = xdr_inline_decode(xdr, fh->size);
	if (unlikely(!p))
		return -ENOBUFS;
	memcpy(&fh->data, p, fh->size);
	dprintk("%s: fh len %d\n", __func__, fh->size);

	return 0;
}


static int zvmstatus ( i_ctx_t * i_ctx_p ) {
 os_ptr op = osp ;
 gs_memory_status_t mstat , dstat ;
 gs_memory_status ( imemory , & mstat ) ;
 if ( imemory == imemory_global ) {
 gs_memory_status_t sstat ;
 gs_memory_status ( imemory_system , & sstat ) ;
 mstat . allocated += sstat . allocated ;
 mstat . used += sstat . used ;
 }
 gs_memory_status ( imemory -> non_gc_memory , & dstat ) ;
 push ( 3 ) ;
 make_int ( op - 2 , imemory_save_level ( iimemory_local ) ) ;
 make_int ( op - 1 , mstat . used ) ;
 make_int ( op , mstat . allocated + dstat . allocated - dstat . used ) ;
 return 0 ;
 }


int main(int argc, char *argv[])
{
    void *jfif = NULL;
    BMP   bmp  = {0};

    if (argc < 3) {
        printf(
            "jfif test program\n"
            "usage: ffjpeg -d filename decode jpg file to decode.bmp\n"
            "       ffjpeg -e filename encode bmp file to encode.jpg\n"
        );
        return 0;
    }

    if (strcmp(argv[1], "-d") == 0) {
        jfif = jfif_load(argv[2]);
        jfif_decode(jfif, &bmp);
        jfif_free  (jfif);
        bmp_save(&bmp, "decode.bmp");
        bmp_free(&bmp);
    } else if (strcmp(argv[1], "-e") == 0) {
        bmp_load(&bmp, argv[2]);
        jfif = jfif_encode(&bmp);
        bmp_free(&bmp);
        jfif_save(jfif, "encode.jpg");
        jfif_free(jfif);
    }

    return 0;
}


static int wv_get_value(WavpackFrameContext *ctx, GetBitContext *gb, int channel, int *last) { int t, t2; int sign, base, add, ret; WvChannel *c = &ctx->ch[channel]; *last = 0; if((ctx->ch[0].median[0] < 2U) && (ctx->ch[1].median[0] < 2U) && !ctx->zero && !ctx->one){ if(ctx->zeroes){ ctx->zeroes--; if(ctx->zeroes){ c->slow_level -= LEVEL_DECAY(c->slow_level); return 0; } }else{ t = get_unary_0_33(gb); if(t >= 2) t = get_bits(gb, t - 1) | (1 << (t-1)); ctx->zeroes = t; if(ctx->zeroes){ memset(ctx->ch[0].median, 0, sizeof(ctx->ch[0].median)); memset(ctx->ch[1].median, 0, sizeof(ctx->ch[1].median)); c->slow_level -= LEVEL_DECAY(c->slow_level); return 0; } } } if(get_bits_count(gb) >= ctx->data_size){ *last = 1; return 0; } if(ctx->zero){ t = 0; ctx->zero = 0; }else{ t = get_unary_0_33(gb); if(get_bits_count(gb) >= ctx->data_size){ *last = 1; return 0; } if(t == 16) { t2 = get_unary_0_33(gb); if(t2 < 2) t += t2; else t += get_bits(gb, t2 - 1) | (1 << (t2 - 1)); } if(ctx->one){ ctx->one = t&1; t = (t>>1) + 1; }else{ ctx->one = t&1; t >>= 1; } ctx->zero = !ctx->one; } if(ctx->hybrid && !channel) update_error_limit(ctx); if(!t){ base = 0; add = GET_MED(0) - 1; DEC_MED(0); }else if(t == 1){ base = GET_MED(0); add = GET_MED(1) - 1; INC_MED(0); DEC_MED(1); }else if(t == 2){ base = GET_MED(0) + GET_MED(1); add = GET_MED(2) - 1; INC_MED(0); INC_MED(1); DEC_MED(2); }else{ base = GET_MED(0) + GET_MED(1) + GET_MED(2) * (t - 2); add = GET_MED(2) - 1; INC_MED(0); INC_MED(1); INC_MED(2); } if(!c->error_limit){ ret = base + get_tail(gb, add); }else{ int mid = (base*2 + add + 1) >> 1; while(add > c->error_limit){ if(get_bits1(gb)){ add -= (mid - base); base = mid; }else add = mid - base - 1; mid = (base*2 + add + 1) >> 1; } ret = mid; } sign = get_bits1(gb); if(ctx->hybrid_bitrate) c->slow_level += wp_log2(ret) - LEVEL_DECAY(c->slow_level); return sign ? ~ret : ret; }


static int tty_open(struct inode *inode, struct file *filp)
{
	struct tty_struct *tty = NULL;
	int noctty, retval;
	struct tty_driver *driver;
	int index;
	dev_t device = inode->i_rdev;
	unsigned saved_flags = filp->f_flags;

	nonseekable_open(inode, filp);

retry_open:
	noctty = filp->f_flags & O_NOCTTY;
	index  = -1;
	retval = 0;

	mutex_lock(&tty_mutex);
	tty_lock();

	if (device == MKDEV(TTYAUX_MAJOR, 0)) {
		tty = get_current_tty();
		if (!tty) {
			tty_unlock();
			mutex_unlock(&tty_mutex);
			return -ENXIO;
		}
		driver = tty_driver_kref_get(tty->driver);
		index = tty->index;
		filp->f_flags |= O_NONBLOCK; /* Don't let /dev/tty block */
		/* noctty = 1; */
		/* FIXME: Should we take a driver reference ? */
		tty_kref_put(tty);
		goto got_driver;
	}
#ifdef CONFIG_VT
	if (device == MKDEV(TTY_MAJOR, 0)) {
		extern struct tty_driver *console_driver;
		driver = tty_driver_kref_get(console_driver);
		index = fg_console;
		noctty = 1;
		goto got_driver;
	}
#endif
	if (device == MKDEV(TTYAUX_MAJOR, 1)) {
		struct tty_driver *console_driver = console_device(&index);
		if (console_driver) {
			driver = tty_driver_kref_get(console_driver);
			if (driver) {
				/* Don't let /dev/console block */
				filp->f_flags |= O_NONBLOCK;
				noctty = 1;
				goto got_driver;
			}
		}
		tty_unlock();
		mutex_unlock(&tty_mutex);
		return -ENODEV;
	}

	driver = get_tty_driver(device, &index);
	if (!driver) {
		tty_unlock();
		mutex_unlock(&tty_mutex);
		return -ENODEV;
	}
got_driver:
	if (!tty) {
		/* check whether we're reopening an existing tty */
		tty = tty_driver_lookup_tty(driver, inode, index);

		if (IS_ERR(tty)) {
			tty_unlock();
			mutex_unlock(&tty_mutex);
			return PTR_ERR(tty);
		}
	}

	if (tty) {
		retval = tty_reopen(tty);
		if (retval)
			tty = ERR_PTR(retval);
	} else
		tty = tty_init_dev(driver, index, 0);

	mutex_unlock(&tty_mutex);
	tty_driver_kref_put(driver);
	if (IS_ERR(tty)) {
		tty_unlock();
		return PTR_ERR(tty);
	}

	retval = tty_add_file(tty, filp);
	if (retval) {
		tty_unlock();
		tty_release(inode, filp);
		return retval;
	}

	check_tty_count(tty, "tty_open");
	if (tty->driver->type == TTY_DRIVER_TYPE_PTY &&
	    tty->driver->subtype == PTY_TYPE_MASTER)
		noctty = 1;
#ifdef TTY_DEBUG_HANGUP
	printk(KERN_DEBUG "opening %s...", tty->name);
#endif
	if (tty->ops->open)
		retval = tty->ops->open(tty, filp);
	else
		retval = -ENODEV;
	filp->f_flags = saved_flags;

	if (!retval && test_bit(TTY_EXCLUSIVE, &tty->flags) &&
						!capable(CAP_SYS_ADMIN))
		retval = -EBUSY;

	if (retval) {
#ifdef TTY_DEBUG_HANGUP
		printk(KERN_DEBUG "error %d in opening %s...", retval,
		       tty->name);
#endif
		tty_unlock(); /* need to call tty_release without BTM */
		tty_release(inode, filp);
		if (retval != -ERESTARTSYS)
			return retval;

		if (signal_pending(current))
			return retval;

		schedule();
		/*
		 * Need to reset f_op in case a hangup happened.
		 */
		tty_lock();
		if (filp->f_op == &hung_up_tty_fops)
			filp->f_op = &tty_fops;
		tty_unlock();
		goto retry_open;
	}
	tty_unlock();

	mutex_lock(&tty_mutex);
	tty_lock();
	spin_lock_irq(&current->sighand->siglock);
	if (!noctty &&
	    current->signal->leader &&
	    !current->signal->tty &&
	    tty->session == NULL)
		__proc_set_tty(current, tty);
	spin_unlock_irq(&current->sighand->siglock);
	tty_unlock();
	mutex_unlock(&tty_mutex);
	return 0;
}


static int mace6_decode_frame(AVCodecContext *avctx, void *data, int *data_size, const uint8_t *buf, int buf_size) { int16_t *samples = data; MACEContext *ctx = avctx->priv_data; int i, j; for(i = 0; i < avctx->channels; i++) { int16_t *output = samples + i; for (j = 0; j < buf_size / avctx->channels; j++) { uint8_t pkt = buf[i + j*avctx->channels]; chomp6(&ctx->chd[i], output, pkt >> 5 , MACEtab1, MACEtab2, 8, avctx->channels); output += avctx->channels << 1; chomp6(&ctx->chd[i], output,(pkt >> 3) & 3, MACEtab3, MACEtab4, 4, avctx->channels); output += avctx->channels << 1; chomp6(&ctx->chd[i], output, pkt & 7, MACEtab1, MACEtab2, 8, avctx->channels); output += avctx->channels << 1; } } *data_size = 2 * 6 * buf_size; return buf_size; }


static void new_video_stream(AVFormatContext *oc) { AVStream *st; AVCodecContext *video_enc; enum CodecID codec_id; AVCodec *codec= NULL; st = av_new_stream(oc, oc->nb_streams < nb_streamid_map ? streamid_map[oc->nb_streams] : 0); if (!st) { fprintf(stderr, "Could not alloc stream\n"); ffmpeg_exit(1); } output_codecs = grow_array(output_codecs, sizeof(*output_codecs), &nb_output_codecs, nb_output_codecs + 1); if(!video_stream_copy){ if (video_codec_name) { codec_id = find_codec_or_die(video_codec_name, AVMEDIA_TYPE_VIDEO, 1, avcodec_opts[AVMEDIA_TYPE_VIDEO]->strict_std_compliance); codec = avcodec_find_encoder_by_name(video_codec_name); output_codecs[nb_output_codecs-1] = codec; } else { codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, AVMEDIA_TYPE_VIDEO); codec = avcodec_find_encoder(codec_id); } } avcodec_get_context_defaults3(st->codec, codec); bitstream_filters[nb_output_files] = grow_array(bitstream_filters[nb_output_files], sizeof(*bitstream_filters[nb_output_files]), &nb_bitstream_filters[nb_output_files], oc->nb_streams); bitstream_filters[nb_output_files][oc->nb_streams - 1]= video_bitstream_filters; video_bitstream_filters= NULL; avcodec_thread_init(st->codec, thread_count); video_enc = st->codec; if(video_codec_tag) video_enc->codec_tag= video_codec_tag; if( (video_global_header&1) || (video_global_header==0 && (oc->oformat->flags & AVFMT_GLOBALHEADER))){ video_enc->flags |= CODEC_FLAG_GLOBAL_HEADER; avcodec_opts[AVMEDIA_TYPE_VIDEO]->flags|= CODEC_FLAG_GLOBAL_HEADER; } if(video_global_header&2){ video_enc->flags2 |= CODEC_FLAG2_LOCAL_HEADER; avcodec_opts[AVMEDIA_TYPE_VIDEO]->flags2|= CODEC_FLAG2_LOCAL_HEADER; } if (video_stream_copy) { st->stream_copy = 1; video_enc->codec_type = AVMEDIA_TYPE_VIDEO; video_enc->sample_aspect_ratio = st->sample_aspect_ratio = av_d2q(frame_aspect_ratio*frame_height/frame_width, 255); } else { const char *p; int i; AVRational fps= frame_rate.num ? frame_rate : (AVRational){25,1}; video_enc->codec_id = codec_id; set_context_opts(video_enc, avcodec_opts[AVMEDIA_TYPE_VIDEO], AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM, codec); if (codec && codec->supported_framerates && !force_fps) fps = codec->supported_framerates[av_find_nearest_q_idx(fps, codec->supported_framerates)]; video_enc->time_base.den = fps.num; video_enc->time_base.num = fps.den; video_enc->width = frame_width; video_enc->height = frame_height; video_enc->sample_aspect_ratio = av_d2q(frame_aspect_ratio*video_enc->height/video_enc->width, 255); video_enc->pix_fmt = frame_pix_fmt; st->sample_aspect_ratio = video_enc->sample_aspect_ratio; choose_pixel_fmt(st, codec); if (intra_only) video_enc->gop_size = 0; if (video_qscale || same_quality) { video_enc->flags |= CODEC_FLAG_QSCALE; video_enc->global_quality= st->quality = FF_QP2LAMBDA * video_qscale; } if(intra_matrix) video_enc->intra_matrix = intra_matrix; if(inter_matrix) video_enc->inter_matrix = inter_matrix; p= video_rc_override_string; for(i=0; p; i++){ int start, end, q; int e=sscanf(p, "%d,%d,%d", &start, &end, &q); if(e!=3){ fprintf(stderr, "error parsing rc_override\n"); ffmpeg_exit(1); } video_enc->rc_override= av_realloc(video_enc->rc_override, sizeof(RcOverride)*(i+1)); video_enc->rc_override[i].start_frame= start; video_enc->rc_override[i].end_frame = end; if(q>0){ video_enc->rc_override[i].qscale= q; video_enc->rc_override[i].quality_factor= 1.0; } else{ video_enc->rc_override[i].qscale= 0; video_enc->rc_override[i].quality_factor= -q/100.0; } p= strchr(p, '/'); if(p) p++; } video_enc->rc_override_count=i; if (!video_enc->rc_initial_buffer_occupancy) video_enc->rc_initial_buffer_occupancy = video_enc->rc_buffer_size*3/4; video_enc->me_threshold= me_threshold; video_enc->intra_dc_precision= intra_dc_precision - 8; if (do_psnr) video_enc->flags|= CODEC_FLAG_PSNR; /* two pass mode */ if (do_pass) { if (do_pass == 1) { video_enc->flags |= CODEC_FLAG_PASS1; } else { video_enc->flags |= CODEC_FLAG_PASS2; } } } if (video_language) { av_metadata_set2(&st->metadata, "language", video_language, 0); av_freep(&video_language); } /* reset some key parameters */ video_disable = 0; av_freep(&video_codec_name); video_stream_copy = 0; frame_pix_fmt = PIX_FMT_NONE; }


void visit_start_implicit_struct(Visitor *v, void **obj, size_t size, Error **errp) { if (!error_is_set(errp) && v->start_implicit_struct) { v->start_implicit_struct(v, obj, size, errp); } }


int mbfl_strwidth ( mbfl_string * string ) {
 int len , n ;
 unsigned char * p ;
 mbfl_convert_filter * filter ;
 len = 0 ;
 if ( string -> len > 0 && string -> val != NULL ) {
 filter = mbfl_convert_filter_new ( string -> no_encoding , mbfl_no_encoding_wchar , filter_count_width , 0 , & len ) ;
 if ( filter == NULL ) {
 mbfl_convert_filter_delete ( filter ) ;
 return - 1 ;
 }
 p = string -> val ;
 n = string -> len ;
 while ( n > 0 ) {
 ( * filter -> filter_function ) ( * p ++ , filter ) ;
 n -- ;
 }
 mbfl_convert_filter_flush ( filter ) ;
 mbfl_convert_filter_delete ( filter ) ;
 }
 return len ;
 }


static int get_consumed_bytes ( int pos , int buf_size ) {
 if ( pos == 0 ) pos = 1 ;
 if ( pos + 10 > buf_size ) pos = buf_size ;
 return pos ;
 }


const char * TSUrlHttpQueryGet ( TSMBuffer bufp , TSMLoc obj , int * length ) {
 return URLPartGet ( bufp , obj , length , & URL : : query_get ) ;
 }


static void * Type_S15Fixed16_Read ( struct _cms_typehandler_struct * self , cmsIOHANDLER * io , cmsUInt32Number * nItems , cmsUInt32Number SizeOfTag ) {
 cmsFloat64Number * array_double ;
 cmsUInt32Number i , n ;
 * nItems = 0 ;
 n = SizeOfTag / sizeof ( cmsUInt32Number ) ;
 array_double = ( cmsFloat64Number * ) _cmsCalloc ( self -> ContextID , n , sizeof ( cmsFloat64Number ) ) ;
 if ( array_double == NULL ) return NULL ;
 for ( i = 0 ;
 i < n ;
 i ++ ) {
 if ( ! _cmsRead15Fixed16Number ( io , & array_double [ i ] ) ) {
 _cmsFree ( self -> ContextID , array_double ) ;
 return NULL ;
 }
 }
 * nItems = n ;
 return ( void * ) array_double ;
 }


TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
  const TfLiteTensor* indices = GetInput(context, node, kIndicesTensor);
  const TfLiteTensor* values = GetInput(context, node, kValueInputTensor);

  switch (values->type) {
    case kTfLiteFloat32:
      return EvalForIndexType<float>(context, node, indices);
    case kTfLiteInt32:
      return EvalForIndexType<int32_t>(context, node, indices);
    case kTfLiteInt64:
      return EvalForIndexType<int64_t>(context, node, indices);
    case kTfLiteInt8:
      return EvalForIndexType<int8_t>(context, node, indices);
    case kTfLiteUInt8:
      return EvalForIndexType<uint8_t>(context, node, indices);
    default:
      TF_LITE_KERNEL_LOG(
          context,
          "Value type %s is currently not supported by sparse to dense.",
          TfLiteTypeGetName(values->type));
      return kTfLiteError;
  }
}


void vp9_fht8x8_c ( const int16_t * input , tran_low_t * output , int stride , int tx_type ) {
 if ( tx_type == DCT_DCT ) {
 vp9_fdct8x8_c ( input , output , stride ) ;
 }
 else {
 tran_low_t out [ 64 ] ;
 tran_low_t * outptr = & out [ 0 ] ;
 int i , j ;
 tran_low_t temp_in [ 8 ] , temp_out [ 8 ] ;
 const transform_2d ht = FHT_8 [ tx_type ] ;
 for ( i = 0 ;
 i < 8 ;
 ++ i ) {
 for ( j = 0 ;
 j < 8 ;
 ++ j ) temp_in [ j ] = input [ j * stride + i ] * 4 ;
 ht . cols ( temp_in , temp_out ) ;
 for ( j = 0 ;
 j < 8 ;
 ++ j ) outptr [ j * 8 + i ] = temp_out [ j ] ;
 }
 for ( i = 0 ;
 i < 8 ;
 ++ i ) {
 for ( j = 0 ;
 j < 8 ;
 ++ j ) temp_in [ j ] = out [ j + i * 8 ] ;
 ht . rows ( temp_in , temp_out ) ;
 for ( j = 0 ;
 j < 8 ;
 ++ j ) output [ j + i * 8 ] = ( temp_out [ j ] + ( temp_out [ j ] < 0 ) ) >> 1 ;
 }
 }
 }


static int dnxhd_encode_picture(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data) { DNXHDEncContext *ctx = avctx->priv_data; int first_field = 1; int offset, i, ret; if (buf_size < ctx->cid_table->frame_size) { av_log(avctx, AV_LOG_ERROR, "output buffer is too small to compress picture\n"); return -1; } dnxhd_load_picture(ctx, data); encode_coding_unit: for (i = 0; i < 3; i++) { ctx->src[i] = ctx->frame.data[i]; if (ctx->interlaced && ctx->cur_field) ctx->src[i] += ctx->frame.linesize[i]; } dnxhd_write_header(avctx, buf); if (avctx->mb_decision == FF_MB_DECISION_RD) ret = dnxhd_encode_rdo(avctx, ctx); else ret = dnxhd_encode_fast(avctx, ctx); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "picture could not fit ratecontrol constraints\n"); return -1; } dnxhd_setup_threads_slices(ctx, buf); offset = 0; for (i = 0; i < ctx->m.mb_height; i++) { AV_WB32(ctx->msip + i * 4, offset); offset += ctx->slice_size[i]; assert(!(ctx->slice_size[i] & 3)); } avctx->execute(avctx, dnxhd_encode_thread, (void**)&ctx->thread[0], NULL, avctx->thread_count, sizeof(void*)); AV_WB32(buf + ctx->cid_table->coding_unit_size - 4, 0x600DC0DE); // EOF if (ctx->interlaced && first_field) { first_field = 0; ctx->cur_field ^= 1; buf += ctx->cid_table->coding_unit_size; buf_size -= ctx->cid_table->coding_unit_size; goto encode_coding_unit; } ctx->frame.quality = ctx->qscale*FF_QP2LAMBDA; return ctx->cid_table->frame_size; }


static void init_encode_frame_mb_context ( VP9_COMP * cpi ) {
 MACROBLOCK * const x = & cpi -> mb ;
 VP9_COMMON * const cm = & cpi -> common ;
 MACROBLOCKD * const xd = & x -> e_mbd ;
 const int aligned_mi_cols = mi_cols_aligned_to_sb ( cm -> mi_cols ) ;
 vp9_setup_src_planes ( x , cpi -> Source , 0 , 0 ) ;
 vp9_setup_block_planes ( & x -> e_mbd , cm -> subsampling_x , cm -> subsampling_y ) ;
 vpx_memset ( xd -> above_context [ 0 ] , 0 , sizeof ( * xd -> above_context [ 0 ] ) * * aligned_mi_cols * MAX_MB_PLANE ) ;
 vpx_memset ( xd -> above_seg_context , 0 , sizeof ( * xd -> above_seg_context ) * aligned_mi_cols ) ;
 }


static void init_dequant4_coeff_table ( H264Context * h ) {
 int i , j , q , x ;
 const int max_qp = 51 + 6 * ( h -> sps . bit_depth_luma - 8 ) ;
 for ( i = 0 ;
 i < 6 ;
 i ++ ) {
 h -> dequant4_coeff [ i ] = h -> dequant4_buffer [ i ] ;
 for ( j = 0 ;
 j < i ;
 j ++ ) if ( ! memcmp ( h -> pps . scaling_matrix4 [ j ] , h -> pps . scaling_matrix4 [ i ] , * sizeof ( uint8_t ) ) ) {
 h -> dequant4_coeff [ i ] = h -> dequant4_buffer [ j ] ;
 break ;
 }
 if ( j < i ) continue ;
 for ( q = 0 ;
 q < max_qp + 1 ;
 q ++ ) {
 int shift = div6 [ q ] + 2 ;
 int idx = rem6 [ q ] ;
 for ( x = 0 ;
 x < 16 ;
 x ++ ) h -> dequant4_coeff [ i ] [ q ] [ ( x >> 2 ) | ( ( x << 2 ) & 0xF ) ] = ( ( uint32_t ) dequant4_coeff_init [ idx ] [ ( x & 1 ) + ( ( x >> 2 ) & 1 ) ] * h -> pps . scaling_matrix4 [ i ] [ x ] ) << shift ;
 }
 }
 }


static void gen_dccci(DisasContext *ctx) { #if defined(CONFIG_USER_ONLY) gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC); #else if (unlikely(ctx->pr)) { gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC); return; } /* interpreted as no-op */ #endif }


extern int as_mysql_modify_resv ( mysql_conn_t * mysql_conn , slurmdb_reservation_rec_t * resv ) {
 MYSQL_RES * result = NULL ;
 MYSQL_ROW row ;
 int rc = SLURM_SUCCESS ;
 char * cols = NULL , * vals = NULL , * extra = NULL , * query = NULL ;
 time_t start = 0 , now = time ( NULL ) ;
 int i ;
 int set = 0 ;
 char * resv_req_inx [ ] = {
 "assoclist" , "time_start" , "time_end" , "resv_name" , "nodelist" , "node_inx" , "flags" , "tres" }
 ;
 enum {
 RESV_ASSOCS , RESV_START , RESV_END , RESV_NAME , RESV_NODES , RESV_NODE_INX , RESV_FLAGS , RESV_TRES , RESV_COUNT }
 ;
 if ( ! resv ) {
 error ( "No reservation was given to edit" ) ;
 return SLURM_ERROR ;
 }
 if ( ! resv -> id ) {
 error ( "We need an id to edit a reservation." ) ;
 return SLURM_ERROR ;
 }
 if ( ! resv -> time_start ) {
 error ( "We need a start time to edit a reservation." ) ;
 return SLURM_ERROR ;
 }
 if ( ! resv -> cluster || ! resv -> cluster [ 0 ] ) {
 error ( "We need a cluster name to edit a reservation." ) ;
 return SLURM_ERROR ;
 }
 if ( ! resv -> time_start_prev ) {
 error ( "We need a time to check for last " "start of reservation." ) ;
 return SLURM_ERROR ;
 }
 xstrfmtcat ( cols , "%s" , resv_req_inx [ 0 ] ) ;
 for ( i = 1 ;
 i < RESV_COUNT ;
 i ++ ) {
 xstrfmtcat ( cols , ", %s" , resv_req_inx [ i ] ) ;
 }
 query = xstrdup_printf ( "select %s from \"%s_%s\" where id_resv=%u " "and (time_start=%ld || time_start=%ld) " "and deleted=0 order by time_start desc " "limit 1 FOR UPDATE;
" , cols , resv -> cluster , resv_table , resv -> id , resv -> time_start , resv -> time_start_prev ) ;
 try_again : debug4 ( "%d(%s:%d) query\n%s" , mysql_conn -> conn , THIS_FILE , __LINE__ , query ) ;
 if ( ! ( result = mysql_db_query_ret ( mysql_conn , query , 0 ) ) ) {
 rc = SLURM_ERROR ;
 goto end_it ;
 }
 if ( ! ( row = mysql_fetch_row ( result ) ) ) {
 rc = SLURM_ERROR ;
 mysql_free_result ( result ) ;
 error ( "There is no reservation by id %u, " "time_start %ld, and cluster '%s'" , resv -> id , resv -> time_start_prev , resv -> cluster ) ;
 if ( ! set && resv -> time_end ) {
 xfree ( query ) ;
 query = xstrdup_printf ( "select %s from \"%s_%s\" where id_resv=%u " "and time_start <= %ld and deleted=0 " "order by time_start desc " "limit 1;
" , cols , resv -> cluster , resv_table , resv -> id , resv -> time_end ) ;
 set = 1 ;
 goto try_again ;
 }
 goto end_it ;
 }
 start = slurm_atoul ( row [ RESV_START ] ) ;
 xfree ( query ) ;
 xfree ( cols ) ;
 set = 0 ;
 if ( ! resv -> name && row [ RESV_NAME ] && row [ RESV_NAME ] [ 0 ] ) resv -> name = xstrdup ( row [ RESV_NAME ] ) ;
 if ( resv -> assocs ) set = 1 ;
 else if ( row [ RESV_ASSOCS ] && row [ RESV_ASSOCS ] [ 0 ] ) resv -> assocs = xstrdup ( row [ RESV_ASSOCS ] ) ;
 if ( resv -> flags != NO_VAL ) set = 1 ;
 else resv -> flags = slurm_atoul ( row [ RESV_FLAGS ] ) ;
 if ( resv -> nodes ) set = 1 ;
 else if ( row [ RESV_NODES ] && row [ RESV_NODES ] [ 0 ] ) {
 resv -> nodes = xstrdup ( row [ RESV_NODES ] ) ;
 resv -> node_inx = xstrdup ( row [ RESV_NODE_INX ] ) ;
 }
 if ( ! resv -> time_end ) resv -> time_end = slurm_atoul ( row [ RESV_END ] ) ;
 if ( resv -> tres_str ) set = 1 ;
 else if ( row [ RESV_TRES ] && row [ RESV_TRES ] [ 0 ] ) resv -> tres_str = xstrdup ( row [ RESV_TRES ] ) ;
 mysql_free_result ( result ) ;
 _setup_resv_limits ( resv , & cols , & vals , & extra ) ;
 if ( ( start > now ) || ! set ) {
 query = xstrdup_printf ( "update \"%s_%s\" set deleted=0%s " "where deleted=0 and id_resv=%u " "and time_start=%ld;
" , resv -> cluster , resv_table , extra , resv -> id , start ) ;
 }
 else {
 query = xstrdup_printf ( "update \"%s_%s\" set time_end=%ld " "where deleted=0 && id_resv=%u " "and time_start=%ld;
" , resv -> cluster , resv_table , resv -> time_start - 1 , resv -> id , start ) ;
 xstrfmtcat ( query , "insert into \"%s_%s\" (id_resv%s) " "values (%u%s) " "on duplicate key update deleted=0%s;
" , resv -> cluster , resv_table , cols , resv -> id , vals , extra ) ;
 }
 if ( debug_flags & DEBUG_FLAG_DB_RESV ) DB_DEBUG ( mysql_conn -> conn , "query\n%s" , query ) ;
 rc = mysql_db_query ( mysql_conn , query ) ;
 end_it : xfree ( query ) ;
 xfree ( cols ) ;
 xfree ( vals ) ;
 xfree ( extra ) ;
 return rc ;
 }


static inline void copy ( LZOContext * c , int cnt ) {
 register const uint8_t * src = c -> in ;
 register uint8_t * dst = c -> out ;
 if ( cnt < 0 ) {
 c -> error |= AV_LZO_ERROR ;
 return ;
 }
 if ( cnt > c -> in_end - src ) {
 cnt = FFMAX ( c -> in_end - src , 0 ) ;
 c -> error |= AV_LZO_INPUT_DEPLETED ;
 }
 if ( cnt > c -> out_end - dst ) {
 cnt = FFMAX ( c -> out_end - dst , 0 ) ;
 c -> error |= AV_LZO_OUTPUT_FULL ;
 }
 # if defined ( INBUF_PADDED ) && defined ( OUTBUF_PADDED ) AV_COPY32U ( dst , src ) ;
 src += 4 ;
 dst += 4 ;
 cnt -= 4 ;
 if ( cnt > 0 ) # endif memcpy ( dst , src , cnt ) ;
 c -> in = src + cnt ;
 c -> out = dst + cnt ;
 }


static void assert_codec_experimental(AVCodecContext *c, int encoder) { const char *codec_string = encoder ? "encoder" : "decoder"; AVCodec *codec; if (c->codec->capabilities & CODEC_CAP_EXPERIMENTAL && c->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) { av_log(NULL, AV_LOG_FATAL, "%s '%s' is experimental and might produce bad " "results.\nAdd '-strict experimental' if you want to use it.\n", codec_string, c->codec->name); codec = encoder ? avcodec_find_encoder(c->codec->id) : avcodec_find_decoder(c->codec->id); if (!(codec->capabilities & CODEC_CAP_EXPERIMENTAL)) av_log(NULL, AV_LOG_FATAL, "Or use the non experimental %s '%s'.\n", codec_string, codec->name); exit(1); } }


static void virtio_net_save ( QEMUFile * f , void * opaque ) {
 VirtIONet * n = opaque ;
 assert ( ! n -> vhost_started ) ;
 virtio_save ( & n -> vdev , f ) ;
 qemu_put_buffer ( f , n -> mac , ETH_ALEN ) ;
 qemu_put_be32 ( f , n -> tx_waiting ) ;
 qemu_put_be32 ( f , n -> mergeable_rx_bufs ) ;
 qemu_put_be16 ( f , n -> status ) ;
 qemu_put_byte ( f , n -> promisc ) ;
 qemu_put_byte ( f , n -> allmulti ) ;
 qemu_put_be32 ( f , n -> mac_table . in_use ) ;
 qemu_put_buffer ( f , n -> mac_table . macs , n -> mac_table . in_use * ETH_ALEN ) ;
 qemu_put_buffer ( f , ( uint8_t * ) n -> vlans , MAX_VLAN >> 3 ) ;
 qemu_put_be32 ( f , n -> has_vnet_hdr ) ;
 qemu_put_byte ( f , n -> mac_table . multi_overflow ) ;
 qemu_put_byte ( f , n -> mac_table . uni_overflow ) ;
 qemu_put_byte ( f , n -> alluni ) ;
 qemu_put_byte ( f , n -> nomulti ) ;
 qemu_put_byte ( f , n -> nouni ) ;
 qemu_put_byte ( f , n -> nobcast ) ;
 qemu_put_byte ( f , n -> has_ufo ) ;
 }


IN_PROC_BROWSER_TEST_F ( TabDragCaptureLostTest , ReleaseCaptureOnDrag ) {
 AddTabAndResetBrowser ( browser ( ) ) ;
 TabStrip * tab_strip = GetTabStripForBrowser ( browser ( ) ) ;
 gfx : : Point tab_1_center ( GetCenterInScreenCoordinates ( tab_strip -> tab_at ( 1 ) ) ) ;
 ASSERT_TRUE ( ui_test_utils : : SendMouseMoveSync ( tab_1_center ) && ui_test_utils : : SendMouseEventsSync ( ui_controls : : LEFT , ui_controls : : DOWN ) ) ;
 gfx : : Point tab_0_center ( GetCenterInScreenCoordinates ( tab_strip -> tab_at ( 0 ) ) ) ;
 TestDesktopBrowserFrameAura * frame = static_cast < TestDesktopBrowserFrameAura * > ( BrowserView : : GetBrowserViewForBrowser ( browser ( ) ) -> GetWidget ( ) -> native_widget_private ( ) ) ;
 frame -> ReleaseCaptureOnNextClear ( ) ;
 ASSERT_TRUE ( ui_test_utils : : SendMouseMoveSync ( tab_0_center ) ) ;
 EXPECT_FALSE ( tab_strip -> IsDragSessionActive ( ) ) ;
 }