M_fs_error_t M_fs_move(const char *path_old, const char *path_new, M_uint32 mode, M_fs_progress_cb_t cb, M_uint32 progress_flags)
{
	char            *norm_path_old;
	char            *norm_path_new;
	char            *resolve_path;
	M_fs_info_t     *info;
	M_fs_progress_t *progress      = NULL;
	M_uint64         entry_size;
	M_fs_error_t     res;

	if (path_old == NULL || *path_old == '\0' || path_new == NULL || *path_new == '\0') {
		return M_FS_ERROR_INVALID;
	}

	/* It's okay if new path doesn't exist. */
	res = M_fs_path_norm(&norm_path_new, path_new, M_FS_PATH_NORM_RESDIR, M_FS_SYSTEM_AUTO);
	if (res != M_FS_ERROR_SUCCESS) {
		M_free(norm_path_new);
		return res;
	}

	/* If a path is a file and the destination is a directory the file should be moved
	 * into the directory. E.g. /file.txt -> /dir = /dir/file.txt */
	if (M_fs_isfileintodir(path_old, path_new, &norm_path_old)) {
		M_free(norm_path_new);
		res = M_fs_move(path_old, norm_path_old, mode, cb, progress_flags);
		M_free(norm_path_old);
		return res;
	}

	/* Normalize the old path and do basic checks that it exists. We'll leave really checking that the old path
	 * existing to rename because any check we perform may not be true when rename is called. */
	res = M_fs_path_norm(&norm_path_old, path_old, M_FS_PATH_NORM_RESALL, M_FS_SYSTEM_AUTO);
	if (res != M_FS_ERROR_SUCCESS) {
		M_free(norm_path_new);
		M_free(norm_path_old);
		return res;
	}

	progress = M_fs_progress_create();

	res = M_fs_info(&info, path_old, (mode & M_FS_FILE_MODE_PRESERVE_PERMS)?M_FS_PATH_INFO_FLAGS_NONE:M_FS_PATH_INFO_FLAGS_BASIC);
	if (res != M_FS_ERROR_SUCCESS) {
		M_fs_progress_destroy(progress);
		M_free(norm_path_new);
		M_free(norm_path_old);
		return res;
	}

	/* There is a race condition where the path could not exist but be created between the exists check and calling
	 * rename to move the file but there isn't much we can do in this case. copy will delete and the file so this
	 * situation won't cause an error. */
	if (!M_fs_check_overwrite_allowed(norm_path_old, norm_path_new, mode)) {
		M_fs_progress_destroy(progress);
		M_free(norm_path_new);
		M_free(norm_path_old);
		return M_FS_ERROR_FILE_EXISTS;
	}

	if (cb) {
		entry_size = M_fs_info_get_size(info);

		M_fs_progress_set_path(progress, norm_path_new);
		M_fs_progress_set_type(progress, M_fs_info_get_type(info));
		if (progress_flags & M_FS_PROGRESS_SIZE_TOTAL) {
			M_fs_progress_set_size_total(progress, entry_size);
			M_fs_progress_set_size_total_progess(progress, entry_size);
		}
		if (progress_flags & M_FS_PROGRESS_SIZE_CUR) {
			M_fs_progress_set_size_current(progress, entry_size);
			M_fs_progress_set_size_current_progress(progress, entry_size);
		}
		/* Change the progress count to reflect the count. */
		if (progress_flags & M_FS_PROGRESS_COUNT) {
			M_fs_progress_set_count_total(progress, 1);
			M_fs_progress_set_count(progress, 1);
		}
	}

	/* Move the file. */
	if (M_fs_info_get_type(info) == M_FS_TYPE_SYMLINK) {
		res = M_fs_path_readlink(&resolve_path, norm_path_old);
		if (res == M_FS_ERROR_SUCCESS) {
			res = M_fs_symlink(norm_path_new, resolve_path);
		}
		M_free(resolve_path);
	} else {
		res = M_fs_move_file(norm_path_old, norm_path_new);
	}
	/* Failure was because we're crossing mount points. */
	if (res == M_FS_ERROR_NOT_SAMEDEV) {
		/* Can't rename so copy and delete. */
		if (M_fs_copy(norm_path_old, norm_path_new, mode, cb, progress_flags) == M_FS_ERROR_SUCCESS) {
			/* Success - Delete the original files since this is a move. */
			res = M_fs_delete(norm_path_old, M_TRUE, NULL, M_FS_PROGRESS_NOEXTRA);
		} else {
			/* Failure - Delete the new files that were copied but only if we are not overwriting. We don't
			 * want to remove any existing files (especially if the dest is a dir). */
			if (!(mode & M_FS_FILE_MODE_OVERWRITE)) {
				M_fs_delete(norm_path_new, M_TRUE, NULL, M_FS_PROGRESS_NOEXTRA);
			}
			res = M_FS_ERROR_GENERIC;
		}
	} else {
		/* Call the cb with the result of the move whether it was a success for fail. We call the cb only if the
		 * result of the move is not M_FS_ERROR_NOT_SAMEDEV because the copy operation will call the cb for us. */
		if (cb) {
			M_fs_progress_set_result(progress, res);
			if (!cb(progress)) {
				res = M_FS_ERROR_CANCELED;
			}
		}
	}

	M_fs_info_destroy(info);
	M_fs_progress_destroy(progress);
	M_free(norm_path_new);
	M_free(norm_path_old);

	return res;
}


void var_set(const char *var_name, const char *var_name_end,
             const char *var_val, const char *var_val_end)
{
  int digit, env_var= 0;
  VAR *v;
  DBUG_ENTER("var_set");
  DBUG_PRINT("enter", ("var_name: '%.*s' = '%.*s' (length: %d)",
                       (int) (var_name_end - var_name), var_name,
                       (int) (var_val_end - var_val), var_val,
                       (int) (var_val_end - var_val)));

  if (*var_name != '$')
    env_var= 1;
  else
    var_name++;

  digit= *var_name - '0';
  if (!(digit < 10 && digit >= 0))
  {
    v= var_obtain(var_name, (uint) (var_name_end - var_name));
  }
  else
    v= var_reg + digit;

  eval_expr(v, var_val, (const char**) &var_val_end);

  if (env_var)
  {
    if (v->int_dirty)
    {
      sprintf(v->str_val, "%d", v->int_val);
      v->int_dirty=false;
      v->str_val_len= strlen(v->str_val);
    }
    /* setenv() expects \0-terminated strings */
    DBUG_ASSERT(v->name[v->name_len] == 0);
    setenv(v->name, v->str_val, 1);
  }
  DBUG_VOID_RETURN;
}


static void kvm_init_tsc_catchup(struct kvm_vcpu *vcpu, u32 this_tsc_khz)
{
	/* Compute a scale to convert nanoseconds in TSC cycles */
	kvm_get_time_scale(this_tsc_khz, NSEC_PER_SEC / 1000,
			   &vcpu->arch.tsc_catchup_shift,
			   &vcpu->arch.tsc_catchup_mult);
}


R_API RList *r_bin_java_get_symbols(RBinJavaObj *bin) {
	RListIter *iter = NULL, *iter_tmp = NULL;
	RList *imports, *symbols = r_list_newf (free);
	RBinSymbol *sym = NULL;
	RBinImport *imp;
	RBinJavaField *fm_type;
	r_list_foreach_safe (bin->methods_list, iter, iter_tmp, fm_type) {
		sym = r_bin_java_create_new_symbol_from_field (fm_type, bin->loadaddr);
		if (sym) {
			r_list_append (symbols, (void *) sym);
		}
		sym = r_bin_java_create_new_symbol_from_fm_type_meta (fm_type, bin->loadaddr);
		if (sym) {
			r_list_append (symbols, (void *) sym);
		}
	}
	r_list_foreach_safe (bin->fields_list, iter, iter_tmp, fm_type) {
		sym = r_bin_java_create_new_symbol_from_field (fm_type, bin->loadaddr);
		if (sym) {
			r_list_append (symbols, (void *) sym);
		}
		sym = r_bin_java_create_new_symbol_from_fm_type_meta (fm_type, bin->loadaddr);
		if (sym) {
			r_list_append (symbols, (void *) sym);
		}
	}
	bin->lang = "java";
	imports = r_bin_java_get_imports (bin);
	r_list_foreach (imports, iter, imp) {
		sym = R_NEW0 (RBinSymbol);
		if (!sym) {
			break;
		}
		if (imp->classname && !strncmp (imp->classname, "kotlin/jvm", 10)) {
			bin->lang = "kotlin";
		}
		sym->name = r_str_newf ("imp.%s", imp->name);
		if (!sym->name) {
			free (sym);
			break;
		}
		sym->type = r_str_const ("import");
		if (!sym->type) {
			free (sym);
			break;
		}
		sym->vaddr = sym->paddr = imp->ordinal;
		sym->ordinal = imp->ordinal;
		r_list_append (symbols, (void *) sym);
	}
	r_list_free (imports);
	return symbols;
}


void wake_up_nohz_cpu(int cpu)
{
	if (!wake_up_full_nohz_cpu(cpu))
		wake_up_idle_cpu(cpu);
}


kadm5_chpass_principal(void *server_handle,
                       krb5_principal principal, char *password)
{
    return
        kadm5_chpass_principal_3(server_handle, principal, FALSE,
                                 0, NULL, password);
}


static void *session_malloc(size_t size, void *ctx)
{
    h2_session *session = ctx;
    ap_log_cerror(APLOG_MARK, APLOG_TRACE6, 0, session->c,
                  "h2_session(%ld): malloc(%ld)",
                  session->id, (long)size);
    return malloc(size);
}


static int __i40e_setup_tc(struct net_device *netdev, enum tc_setup_type type,
			   void *type_data)
{
	struct i40e_netdev_priv *np = netdev_priv(netdev);

	switch (type) {
	case TC_SETUP_QDISC_MQPRIO:
		return i40e_setup_tc(netdev, type_data);
	case TC_SETUP_BLOCK:
		return flow_block_cb_setup_simple(type_data,
						  &i40e_block_cb_list,
						  i40e_setup_tc_block_cb,
						  np, np, true);
	default:
		return -EOPNOTSUPP;
	}
}


static void reds_mig_release(void)
{
    if (reds->mig_spice) {
        free(reds->mig_spice->cert_subject);
        free(reds->mig_spice->host);
        free(reds->mig_spice);
        reds->mig_spice = NULL;
    }
}


static int ac3_decode_frame(AVCodecContext * avctx, void *data,

                            int *got_frame_ptr, AVPacket *avpkt)

{

    const uint8_t *buf = avpkt->data;

    int buf_size = avpkt->size;

    AC3DecodeContext *s = avctx->priv_data;

    int blk, ch, err, ret;

    const uint8_t *channel_map;

    const float *output[AC3_MAX_CHANNELS];

    /* copy input buffer to decoder context to avoid reading past the end

       of the buffer, which can be caused by a damaged input stream. */

    if (buf_size >= 2 && AV_RB16(buf) == 0x770B) {

        // seems to be byte-swapped AC-3

        int cnt = FFMIN(buf_size, AC3_FRAME_BUFFER_SIZE) >> 1;

        s->dsp.bswap16_buf((uint16_t *)s->input_buffer, (const uint16_t *)buf, cnt);

    } else

        memcpy(s->input_buffer, buf, FFMIN(buf_size, AC3_FRAME_BUFFER_SIZE));

    buf = s->input_buffer;

    /* initialize the GetBitContext with the start of valid AC-3 Frame */

    init_get_bits(&s->gbc, buf, buf_size * 8);

    /* parse the syncinfo */

    err = parse_frame_header(s);

    if (err) {

        switch (err) {

        case AAC_AC3_PARSE_ERROR_SYNC:

            av_log(avctx, AV_LOG_ERROR, "frame sync error\n");

            return -1;

        case AAC_AC3_PARSE_ERROR_BSID:

            av_log(avctx, AV_LOG_ERROR, "invalid bitstream id\n");

            break;

        case AAC_AC3_PARSE_ERROR_SAMPLE_RATE:

            av_log(avctx, AV_LOG_ERROR, "invalid sample rate\n");

            break;

        case AAC_AC3_PARSE_ERROR_FRAME_SIZE:

            av_log(avctx, AV_LOG_ERROR, "invalid frame size\n");

            break;

        case AAC_AC3_PARSE_ERROR_FRAME_TYPE:

            /* skip frame if CRC is ok. otherwise use error concealment. */

            /* TODO: add support for substreams and dependent frames */

            if (s->frame_type == EAC3_FRAME_TYPE_DEPENDENT || s->substreamid) {

                av_log(avctx, AV_LOG_ERROR, "unsupported frame type : "

                       "skipping frame\n");

                *got_frame_ptr = 0;

                return s->frame_size;

            } else {

                av_log(avctx, AV_LOG_ERROR, "invalid frame type\n");

            }

            break;

        default:

            av_log(avctx, AV_LOG_ERROR, "invalid header\n");

            break;

        }

    } else {

        /* check that reported frame size fits in input buffer */

        if (s->frame_size > buf_size) {

            av_log(avctx, AV_LOG_ERROR, "incomplete frame\n");

            err = AAC_AC3_PARSE_ERROR_FRAME_SIZE;

        } else if (avctx->err_recognition & (AV_EF_CRCCHECK|AV_EF_CAREFUL)) {

            /* check for crc mismatch */

            if (av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, &buf[2],

                       s->frame_size - 2)) {

                av_log(avctx, AV_LOG_ERROR, "frame CRC mismatch\n");

                err = AAC_AC3_PARSE_ERROR_CRC;

            }

        }

    }

    /* if frame is ok, set audio parameters */

    if (!err) {

        avctx->sample_rate = s->sample_rate;

        avctx->bit_rate    = s->bit_rate;

        /* channel config */

        s->out_channels = s->channels;

        s->output_mode  = s->channel_mode;

        if (s->lfe_on)

            s->output_mode |= AC3_OUTPUT_LFEON;

        if (avctx->request_channels > 0 && avctx->request_channels <= 2 &&

                avctx->request_channels < s->channels) {

            s->out_channels = avctx->request_channels;

            s->output_mode  = avctx->request_channels == 1 ? AC3_CHMODE_MONO : AC3_CHMODE_STEREO;

            s->channel_layout = avpriv_ac3_channel_layout_tab[s->output_mode];

        }

        avctx->channels       = s->out_channels;

        avctx->channel_layout = s->channel_layout;

        s->loro_center_mix_level   = gain_levels[s->  center_mix_level];

        s->loro_surround_mix_level = gain_levels[s->surround_mix_level];

        s->ltrt_center_mix_level   = LEVEL_MINUS_3DB;

        s->ltrt_surround_mix_level = LEVEL_MINUS_3DB;

        /* set downmixing coefficients if needed */

        if (s->channels != s->out_channels && !((s->output_mode & AC3_OUTPUT_LFEON) &&

                s->fbw_channels == s->out_channels)) {

            set_downmix_coeffs(s);

        }

    } else if (!s->out_channels) {

        s->out_channels = avctx->channels;

        if (s->out_channels < s->channels)

            s->output_mode  = s->out_channels == 1 ? AC3_CHMODE_MONO : AC3_CHMODE_STEREO;

    }

    if (avctx->channels != s->out_channels) {

        av_log(avctx, AV_LOG_ERROR, "channel number mismatching on damaged frame\n");

        return AVERROR_INVALIDDATA;

    }

    /* set audio service type based on bitstream mode for AC-3 */

    avctx->audio_service_type = s->bitstream_mode;

    if (s->bitstream_mode == 0x7 && s->channels > 1)

        avctx->audio_service_type = AV_AUDIO_SERVICE_TYPE_KARAOKE;

    /* get output buffer */

    avctx->channels = s->out_channels;

    s->frame.nb_samples = s->num_blocks * 256;

    if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) {

        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");

        return ret;

    }

    /* decode the audio blocks */

    channel_map = ff_ac3_dec_channel_map[s->output_mode & ~AC3_OUTPUT_LFEON][s->lfe_on];

    for (ch = 0; ch < AC3_MAX_CHANNELS; ch++) {

        output[ch] = s->output[ch];

        s->outptr[ch] = s->output[ch];

    }

    for (ch = 0; ch < s->channels; ch++) {

        if (ch < s->out_channels)

            s->outptr[channel_map[ch]] = (float *)s->frame.data[ch];

    }

    for (blk = 0; blk < s->num_blocks; blk++) {

        if (!err && decode_audio_block(s, blk)) {

            av_log(avctx, AV_LOG_ERROR, "error decoding the audio block\n");

            err = 1;

        }

        if (err)

            for (ch = 0; ch < s->out_channels; ch++)

                memcpy(((float*)s->frame.data[ch]) + AC3_BLOCK_SIZE*blk, output[ch], 1024);

        for (ch = 0; ch < s->out_channels; ch++) {

            output[ch] = s->outptr[channel_map[ch]];

            if (!ch || channel_map[ch])

                s->outptr[channel_map[ch]] += AC3_BLOCK_SIZE;

        }

    }

    s->frame.decode_error_flags = err ? FF_DECODE_ERROR_INVALID_BITSTREAM : 0;

    /* keep last block for error concealment in next frame */

    for (ch = 0; ch < s->out_channels; ch++)

        memcpy(s->output[ch], output[ch], 1024);

    *got_frame_ptr   = 1;

    *(AVFrame *)data = s->frame;

    return FFMIN(buf_size, s->frame_size);

}


static int tiff_unpack_strip(TiffContext *s, AVFrame *p, uint8_t *dst, int stride,

                             const uint8_t *src, int size, int strip_start, int lines)

{

    PutByteContext pb;

    int c, line, pixels, code, ret;

    const uint8_t *ssrc = src;

    int width = ((s->width * s->bpp) + 7) >> 3;

    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(p->format);

    int is_yuv = !(desc->flags & AV_PIX_FMT_FLAG_RGB) && desc->nb_components >= 2;

    if (s->planar)

        width /= s->bppcount;

    if (size <= 0)

        return AVERROR_INVALIDDATA;

    if (is_yuv) {

        int bytes_per_row = (((s->width - 1) / s->subsampling[0] + 1) * s->bpp *

                            s->subsampling[0] * s->subsampling[1] + 7) >> 3;

        av_fast_padded_malloc(&s->yuv_line, &s->yuv_line_size, bytes_per_row);

        if (s->yuv_line == NULL) {

            av_log(s->avctx, AV_LOG_ERROR, "Not enough memory\n");

            return AVERROR(ENOMEM);

        }

        dst = s->yuv_line;

        stride = 0;

        width = s->width * s->subsampling[1] + 2*(s->width / s->subsampling[0]);

        av_assert0(width <= bytes_per_row);

        av_assert0(s->bpp == 24);

    }

    if (s->compr == TIFF_DEFLATE || s->compr == TIFF_ADOBE_DEFLATE) {

#if CONFIG_ZLIB

        return tiff_unpack_zlib(s, p, dst, stride, src, size, width, lines,

                                strip_start, is_yuv);

#else

        av_log(s->avctx, AV_LOG_ERROR,

               "zlib support not enabled, "

               "deflate compression not supported\n");

        return AVERROR(ENOSYS);

#endif

    }

    if (s->compr == TIFF_LZMA) {

#if CONFIG_LZMA

        return tiff_unpack_lzma(s, p, dst, stride, src, size, width, lines,

                                strip_start, is_yuv);

#else

        av_log(s->avctx, AV_LOG_ERROR,

               "LZMA support not enabled\n");

        return AVERROR(ENOSYS);

#endif

    }

    if (s->compr == TIFF_LZW) {

        if (s->fill_order) {

            if ((ret = deinvert_buffer(s, src, size)) < 0)

                return ret;

            ssrc = src = s->deinvert_buf;

        }

        if (size > 1 && !src[0] && (src[1]&1)) {

            av_log(s->avctx, AV_LOG_ERROR, "Old style LZW is unsupported\n");

        }

        if ((ret = ff_lzw_decode_init(s->lzw, 8, src, size, FF_LZW_TIFF)) < 0) {

            av_log(s->avctx, AV_LOG_ERROR, "Error initializing LZW decoder\n");

            return ret;

        }

        for (line = 0; line < lines; line++) {

            pixels = ff_lzw_decode(s->lzw, dst, width);

            if (pixels < width) {

                av_log(s->avctx, AV_LOG_ERROR, "Decoded only %i bytes of %i\n",

                       pixels, width);

                return AVERROR_INVALIDDATA;

            }

            if (s->bpp < 8 && s->avctx->pix_fmt == AV_PIX_FMT_PAL8)

                horizontal_fill(s->bpp, dst, 1, dst, 0, width, 0);

            if (is_yuv) {

                unpack_yuv(s, p, dst, strip_start + line);

                line += s->subsampling[1] - 1;

            }

            dst += stride;

        }

        return 0;

    }

    if (s->compr == TIFF_CCITT_RLE ||

        s->compr == TIFF_G3        ||

        s->compr == TIFF_G4) {

        if (is_yuv)

            return AVERROR_INVALIDDATA;

        return tiff_unpack_fax(s, dst, stride, src, size, width, lines);

    }

    bytestream2_init(&s->gb, src, size);

    bytestream2_init_writer(&pb, dst, is_yuv ? s->yuv_line_size : (stride * lines));

    for (line = 0; line < lines; line++) {

        if (src - ssrc > size) {

            av_log(s->avctx, AV_LOG_ERROR, "Source data overread\n");

            return AVERROR_INVALIDDATA;

        }

        if (bytestream2_get_bytes_left(&s->gb) == 0 || bytestream2_get_eof(&pb))

            break;

        bytestream2_seek_p(&pb, stride * line, SEEK_SET);

        switch (s->compr) {

        case TIFF_RAW:

            if (ssrc + size - src < width)

                return AVERROR_INVALIDDATA;

            if (!s->fill_order) {

                horizontal_fill(s->bpp * (s->avctx->pix_fmt == AV_PIX_FMT_PAL8),

                                dst, 1, src, 0, width, 0);

            } else {

                int i;

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

                    dst[i] = ff_reverse[src[i]];

            }

            src += width;

            break;

        case TIFF_PACKBITS:

            for (pixels = 0; pixels < width;) {

                if (ssrc + size - src < 2) {

                    av_log(s->avctx, AV_LOG_ERROR, "Read went out of bounds\n");

                    return AVERROR_INVALIDDATA;

                }

                code = s->fill_order ? (int8_t) ff_reverse[*src++]: (int8_t) *src++;

                if (code >= 0) {

                    code++;

                    if (pixels + code > width ||

                        ssrc + size - src < code) {

                        av_log(s->avctx, AV_LOG_ERROR,

                               "Copy went out of bounds\n");

                        return AVERROR_INVALIDDATA;

                    }

                    horizontal_fill(s->bpp * (s->avctx->pix_fmt == AV_PIX_FMT_PAL8),

                                    dst, 1, src, 0, code, pixels);

                    src    += code;

                    pixels += code;

                } else if (code != -128) { // -127..-1

                    code = (-code) + 1;

                    if (pixels + code > width) {

                        av_log(s->avctx, AV_LOG_ERROR,

                               "Run went out of bounds\n");

                        return AVERROR_INVALIDDATA;

                    }

                    c = *src++;

                    horizontal_fill(s->bpp * (s->avctx->pix_fmt == AV_PIX_FMT_PAL8),

                                    dst, 0, NULL, c, code, pixels);

                    pixels += code;

                }

            }

            if (s->fill_order) {

                int i;

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

                    dst[i] = ff_reverse[dst[i]];

            }

            break;

        }

        if (is_yuv) {

            unpack_yuv(s, p, dst, strip_start + line);

            line += s->subsampling[1] - 1;

        }

        dst += stride;

    }

    return 0;

}


TEST_F(TestCustomAllocation, CustomInputAndOutputAllocs) {
  // Set custom allocations for all IO tensors.
  AssignCustomAllocForTensor(interpreter_->inputs()[0],
                             /*required_alignment=*/kDefaultTensorAlignment);
  AssignCustomAllocForTensor(interpreter_->inputs()[1],
                             /*required_alignment=*/kDefaultTensorAlignment);
  AssignCustomAllocForTensor(interpreter_->outputs()[0],
                             /*required_alignment=*/kDefaultTensorAlignment);
  AssignCustomAllocForTensor(interpreter_->outputs()[1],
                             /*required_alignment=*/kDefaultTensorAlignment);

  ASSERT_EQ(interpreter_->AllocateTensors(), kTfLiteOk);
  VerifyInvoke();
}


static int md_compat_ioctl(struct block_device *bdev, fmode_t mode,
		    unsigned int cmd, unsigned long arg)
{
	switch (cmd) {
	case HOT_REMOVE_DISK:
	case HOT_ADD_DISK:
	case SET_DISK_FAULTY:
	case SET_BITMAP_FILE:
		/* These take in integer arg, do not convert */
		break;
	default:
		arg = (unsigned long)compat_ptr(arg);
		break;
	}

	return md_ioctl(bdev, mode, cmd, arg);
}


encode_CHECK_PKT_LARGER(const struct ofpact_check_pkt_larger *check_pkt_larger,
                 enum ofp_version ofp_version OVS_UNUSED,
                 struct ofpbuf *out)
{
    struct nx_action_check_pkt_larger *ncpl = put_NXAST_CHECK_PKT_LARGER(out);
    ncpl->pkt_len = htons(check_pkt_larger->pkt_len);
    ncpl->offset = htons(check_pkt_larger->dst.ofs);

    if (check_pkt_larger->dst.field) {
        size_t size = out->size;
        out->size = size - sizeof ncpl->pad;
        nx_put_mff_header(out, check_pkt_larger->dst.field, 0, false);
        out->size = size;
    }
}


void qmp_blockdev_snapshot_sync(bool has_device, const char *device,

                                bool has_node_name, const char *node_name,

                                const char *snapshot_file,

                                bool has_snapshot_node_name,

                                const char *snapshot_node_name,

                                bool has_format, const char *format,

                                bool has_mode, NewImageMode mode, Error **errp)

{

    BlockdevSnapshotSync snapshot = {

        .has_device = has_device,

        .device = (char *) device,

        .has_node_name = has_node_name,

        .node_name = (char *) node_name,

        .snapshot_file = (char *) snapshot_file,

        .has_snapshot_node_name = has_snapshot_node_name,

        .snapshot_node_name = (char *) snapshot_node_name,

        .has_format = has_format,

        .format = (char *) format,

        .has_mode = has_mode,

        .mode = mode,

    };

    TransactionAction action = {

        .type = TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC,

        .u.blockdev_snapshot_sync = &snapshot,

    };

    blockdev_do_action(&action, errp);

}


static_track_group_group_handler(vector_t *strvec)
{
	static_track_group_t *tgroup = LIST_TAIL_DATA(vrrp_data->static_track_groups);

	if (tgroup->iname) {
		report_config_error(CONFIG_GENERAL_ERROR, "Group list already specified for sync group %s", tgroup->gname);
		skip_block(true);
		return;
	}

	tgroup->iname = read_value_block(strvec);

	if (!tgroup->iname)
		report_config_error(CONFIG_GENERAL_ERROR, "Warning - track group %s has empty group block", tgroup->gname);
}


static void byteMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    TestObjectPython* imp = V8TestObjectPython::toNative(info.Holder());
    v8SetReturnValueInt(info, imp->byteMethod());
}


static void compress ( int init_bits , gdIOCtxPtr outfile , gdImagePtr im , GifCtx * ctx ) {
 register long fcode ;
 register code_int i ;
 register int c ;
 register code_int ent ;
 register code_int disp ;
 register code_int hsize_reg ;
 register int hshift ;
 ctx -> g_init_bits = init_bits ;
 ctx -> g_outfile = outfile ;
 ctx -> offset = 0 ;
 ctx -> out_count = 0 ;
 ctx -> clear_flg = 0 ;
 ctx -> in_count = 1 ;
 ctx -> maxcode = MAXCODE ( ctx -> n_bits = ctx -> g_init_bits ) ;
 ctx -> ClearCode = ( 1 << ( init_bits - 1 ) ) ;
 ctx -> EOFCode = ctx -> ClearCode + 1 ;
 ctx -> free_ent = ctx -> ClearCode + 2 ;
 char_init ( ctx ) ;
 ent = GIFNextPixel ( im , ctx ) ;
 hshift = 0 ;
 for ( fcode = ( long ) hsize ;
 fcode < 65536L ;
 fcode *= 2L ) {
 ++ hshift ;
 }
 hshift = 8 - hshift ;
 hsize_reg = hsize ;
 cl_hash ( ( count_int ) hsize_reg , ctx ) ;
 output ( ( code_int ) ctx -> ClearCode , ctx ) ;
 # ifdef SIGNED_COMPARE_SLOW while ( ( c = GIFNextPixel ( im ) ) != ( unsigned ) EOF ) {
 # else while ( ( c = GIFNextPixel ( im , ctx ) ) != EOF ) {
 # endif ++ ( ctx -> in_count ) ;
 fcode = ( long ) ( ( ( long ) c << maxbits ) + ent ) ;
 i = ( ( ( code_int ) c << hshift ) ^ ent ) ;
 if ( HashTabOf ( i ) == fcode ) {
 ent = CodeTabOf ( i ) ;
 continue ;
 }
 else if ( ( long ) HashTabOf ( i ) < 0 ) {
 goto nomatch ;
 }
 disp = hsize_reg - i ;
 if ( i == 0 ) {
 disp = 1 ;
 }
 probe : if ( ( i -= disp ) < 0 ) {
 i += hsize_reg ;
 }
 if ( HashTabOf ( i ) == fcode ) {
 ent = CodeTabOf ( i ) ;
 continue ;
 }
 if ( ( long ) HashTabOf ( i ) > 0 ) {
 goto probe ;
 }
 nomatch : output ( ( code_int ) ent , ctx ) ;
 ++ ( ctx -> out_count ) ;
 ent = c ;
 # ifdef SIGNED_COMPARE_SLOW if ( ( unsigned ) ctx -> free_ent < ( unsigned ) maxmaxcode ) {
 # else if ( ctx -> free_ent < maxmaxcode ) {
 # endif CodeTabOf ( i ) = ctx -> free_ent ++ ;
 HashTabOf ( i ) = fcode ;
 }
 else {
 cl_block ( ctx ) ;
 }
 }
 output ( ( code_int ) ent , ctx ) ;
 ++ ( ctx -> out_count ) ;
 output ( ( code_int ) ctx -> EOFCode , ctx ) ;
 }


enum nss_status _nss_dns_gethostbyname_r ( const char * name , struct hostent * result , char * buffer , size_t buflen , int * errnop , int * h_errnop ) {
 enum nss_status status = NSS_STATUS_NOTFOUND ;
 if ( _res . options & RES_USE_INET6 ) status = _nss_dns_gethostbyname3_r ( name , AF_INET6 , result , buffer , buflen , errnop , h_errnop , NULL , NULL ) ;
 if ( status == NSS_STATUS_NOTFOUND ) status = _nss_dns_gethostbyname3_r ( name , AF_INET , result , buffer , buflen , errnop , h_errnop , NULL , NULL ) ;
 return status ;
 }


status_t MediaPlayer::setDataSource(const sp<IDataSource> &source)
{
    ALOGV("setDataSource(IDataSource)");
 status_t err = UNKNOWN_ERROR;
 const sp<IMediaPlayerService>& service(getMediaPlayerService());
 if (service != 0) {
        sp<IMediaPlayer> player(service->create(this, mAudioSessionId));
 if ((NO_ERROR != doSetRetransmitEndpoint(player)) ||
 (NO_ERROR != player->setDataSource(source))) {
            player.clear();
 }
        err = attachNewPlayer(player);
 }
 return err;
}


ssize_t vnc_client_read_buf(VncState *vs, uint8_t *data, size_t datalen)

{

    ssize_t ret;

#ifdef CONFIG_VNC_TLS

    if (vs->tls.session) {

        ret = vnc_client_read_tls(&vs->tls.session, data, datalen);

    } else {

#endif /* CONFIG_VNC_TLS */

        ret = qemu_recv(vs->csock, data, datalen, 0);

#ifdef CONFIG_VNC_TLS

    }

#endif /* CONFIG_VNC_TLS */

    VNC_DEBUG("Read wire %p %zd -> %ld\n", data, datalen, ret);

    return vnc_client_io_error(vs, ret, socket_error());

}


mono_ArgIterator_IntGetNextArgType (MonoArgIterator *iter)
{
	gint i;
	MONO_ARCH_SAVE_REGS;

	i = iter->sig->sentinelpos + iter->next_arg;

	g_assert (i < iter->sig->param_count);

	return iter->sig->params [i];
}


static void parse_rtcp_bye(pjmedia_rtcp_session *sess,
			   const void *pkt,
			   pj_size_t size)
{
    pj_str_t reason = {"-", 1};

    /* Check and get BYE reason */
    if (size > 8) {
    	/* Make sure the BYE reason does not exceed:
    	 * - the size of the available buffer
    	 * - the declared reason's length
    	 * - the actual packet size
    	 */
	reason.slen = PJ_MIN(sizeof(sess->stat.peer_sdes_buf_),
                             *((pj_uint8_t*)pkt+8));
        reason.slen = PJ_MIN(reason.slen, (pj_ssize_t)(size-9));

	pj_memcpy(sess->stat.peer_sdes_buf_, ((pj_uint8_t*)pkt+9),
		  reason.slen);
	reason.ptr = sess->stat.peer_sdes_buf_;
    }

    /* Just print RTCP BYE log */
    PJ_LOG(5, (sess->name, "Received RTCP BYE, reason: %.*s",
	       reason.slen, reason.ptr));
}


void GraphicsSurface::platformCopyFromTexture(uint32_t texture, const IntRect& sourceRect)
{
    m_private->copyFromTexture(texture, sourceRect);
}


 void WebContentsImpl::FocusThroughTabTraversal(bool reverse) {
   if (ShowingInterstitialPage()) {
    interstitial_page_->FocusThroughTabTraversal(reverse);
     return;
   }
   RenderWidgetHostView* const fullscreen_view =
      GetFullscreenRenderWidgetHostView();
  if (fullscreen_view) {
    fullscreen_view->Focus();
    return;
  }
  GetRenderViewHost()->SetInitialFocus(reverse);
 }


midi_outc(int midi_dev, int data)
{
	int             timeout;

	for (timeout = 0; timeout < 3200; timeout++)
		if (midi_devs[midi_dev]->outputc(midi_dev, (unsigned char) (data & 0xff)))
		  {
			  if (data & 0x80)	/*
						 * Status byte
						 */
				  prev_out_status[midi_dev] =
				      (unsigned char) (data & 0xff);	/*
									 * Store for running status
									 */
			  return;	/*
					 * Mission complete
					 */
		  }
	/*
	 * Sorry! No space on buffers.
	 */
	printk("Midi send timed out\n");
}


OfflineAudioContext* OfflineAudioDestinationHandler::Context() const {
  return static_cast<OfflineAudioContext*>(AudioDestinationHandler::Context());
}


OSDMapRef OSDService::_add_map(OSDMap *o)
{
  epoch_t e = o->get_epoch();

  if (cct->_conf->osd_map_dedup) {
    // Dedup against an existing map at a nearby epoch
    OSDMapRef for_dedup = map_cache.lower_bound(e);
    if (for_dedup) {
      OSDMap::dedup(for_dedup.get(), o);
    }
  }
  bool existed;
  OSDMapRef l = map_cache.add(e, o, &existed);
  if (existed) {
    delete o;
  }
  return l;
}


void kvm_get_segment(struct kvm_vcpu *vcpu,
		     struct kvm_segment *var, int seg)
{
	kvm_x86_ops->get_segment(vcpu, var, seg);
}


void RenderViewImpl::OnContextMenuClosed(
    const CustomContextMenuContext& custom_context) {
  if (custom_context.request_id) {
    ContextMenuClient* client =
        pending_context_menus_.Lookup(custom_context.request_id);
    if (client) {
      client->OnMenuClosed(custom_context.request_id);
      pending_context_menus_.Remove(custom_context.request_id);
    }
  } else {
    context_menu_node_.reset();
  }
}


int opt_default(void *optctx, const char *opt, const char *arg)

{

    const AVOption *o;

    int consumed = 0;

    char opt_stripped[128];

    const char *p;

    const AVClass *cc = avcodec_get_class(), *fc = avformat_get_class();

#if CONFIG_AVRESAMPLE

    const AVClass *rc = avresample_get_class();

#endif

    const AVClass *sc, *swr_class;

    if (!strcmp(opt, "debug") || !strcmp(opt, "fdebug"))

        av_log_set_level(AV_LOG_DEBUG);

    if (!(p = strchr(opt, ':')))

        p = opt + strlen(opt);

    av_strlcpy(opt_stripped, opt, FFMIN(sizeof(opt_stripped), p - opt + 1));

    if ((o = opt_find(&cc, opt_stripped, NULL, 0,

                         AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ)) ||

        ((opt[0] == 'v' || opt[0] == 'a' || opt[0] == 's') &&

         (o = opt_find(&cc, opt + 1, NULL, 0, AV_OPT_SEARCH_FAKE_OBJ)))) {

        av_dict_set(&codec_opts, opt, arg, FLAGS);

        consumed = 1;

    }

    if ((o = opt_find(&fc, opt, NULL, 0,

                         AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) {

        av_dict_set(&format_opts, opt, arg, FLAGS);

        if (consumed)

            av_log(NULL, AV_LOG_VERBOSE, "Routing option %s to both codec and muxer layer\n", opt);

        consumed = 1;

    }

#if CONFIG_SWSCALE

    sc = sws_get_class();

    if (!consumed && (o = opt_find(&sc, opt, NULL, 0,

                         AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) {

        struct SwsContext *sws = sws_alloc_context();

        int ret = av_opt_set(sws, opt, arg, 0);

        sws_freeContext(sws);

        if (!strcmp(opt, "srcw") || !strcmp(opt, "srch") ||

            !strcmp(opt, "dstw") || !strcmp(opt, "dsth") ||

            !strcmp(opt, "src_format") || !strcmp(opt, "dst_format")) {

            av_log(NULL, AV_LOG_ERROR, "Directly using swscale dimensions/format options is not supported, please use the -s or -pix_fmt options\n");

            return AVERROR(EINVAL);

        }

        if (ret < 0) {

            av_log(NULL, AV_LOG_ERROR, "Error setting option %s.\n", opt);

            return ret;

        }

        av_dict_set(&sws_dict, opt, arg, FLAGS);

        consumed = 1;

    }

#else

    if (!consumed && !strcmp(opt, "sws_flags")) {

        av_log(NULL, AV_LOG_WARNING, "Ignoring %s %s, due to disabled swscale\n", opt, arg);

        consumed = 1;

    }

#endif

#if CONFIG_SWRESAMPLE

    swr_class = swr_get_class();

    if (!consumed && (o=opt_find(&swr_class, opt, NULL, 0,

                                    AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) {

        struct SwrContext *swr = swr_alloc();

        int ret = av_opt_set(swr, opt, arg, 0);

        swr_free(&swr);

        if (ret < 0) {

            av_log(NULL, AV_LOG_ERROR, "Error setting option %s.\n", opt);

            return ret;

        }

        av_dict_set(&swr_opts, opt, arg, FLAGS);

        consumed = 1;

    }

#endif

#if CONFIG_AVRESAMPLE

    if ((o=opt_find(&rc, opt, NULL, 0,

                       AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) {

        av_dict_set(&resample_opts, opt, arg, FLAGS);

        consumed = 1;

    }

#endif

    if (consumed)

        return 0;

    return AVERROR_OPTION_NOT_FOUND;

}


static int mount_entry_on_absolute_rootfs(struct mntent *mntent,
					  const struct lxc_rootfs *rootfs,
					  const char *lxc_name)
{
	char *aux;
	char path[MAXPATHLEN];
	int r, ret = 0, offset;
	const char *lxcpath;

	lxcpath = lxc_global_config_value("lxc.lxcpath");
	if (!lxcpath) {
		ERROR("Out of memory");
		return -1;
	}

	/* if rootfs->path is a blockdev path, allow container fstab to
	 * use $lxcpath/CN/rootfs as the target prefix */
	r = snprintf(path, MAXPATHLEN, "%s/%s/rootfs", lxcpath, lxc_name);
	if (r < 0 || r >= MAXPATHLEN)
		goto skipvarlib;

	aux = strstr(mntent->mnt_dir, path);
	if (aux) {
		offset = strlen(path);
		goto skipabs;
	}

skipvarlib:
	aux = strstr(mntent->mnt_dir, rootfs->path);
	if (!aux) {
		WARN("ignoring mount point '%s'", mntent->mnt_dir);
		return ret;
	}
	offset = strlen(rootfs->path);

skipabs:

	r = snprintf(path, MAXPATHLEN, "%s/%s", rootfs->mount,
		 aux + offset);
	if (r < 0 || r >= MAXPATHLEN) {
		WARN("pathnme too long for '%s'", mntent->mnt_dir);
		return -1;
	}

	return mount_entry_on_generic(mntent, path);
}


static inline u32 tcp_wnd_end(const struct tcp_sock *tp)
{
	return tp->snd_una + tp->snd_wnd;
}


const struct exception_table_entry *search_module_extables(unsigned long addr)
{
	const struct exception_table_entry *e = NULL;
	struct module *mod;

	preempt_disable();
	mod = __module_address(addr);
	if (!mod)
		goto out;

	if (!mod->num_exentries)
		goto out;

	e = search_extable(mod->extable,
			   mod->num_exentries,
			   addr);
out:
	preempt_enable();

	/*
	 * Now, if we found one, we are running inside it now, hence
	 * we cannot unload the module, hence no refcnt needed.
	 */
	return e;
}