id
int32 0
27.3k
| func
stringlengths 26
142k
| target
bool 2
classes | project
stringclasses 2
values | commit_id
stringlengths 40
40
| func_clean
stringlengths 26
131k
| vul_lines
dict | normalized_func
stringlengths 24
132k
| lines
sequencelengths 1
2.8k
| label
sequencelengths 1
2.8k
| line_no
sequencelengths 1
2.8k
|
---|---|---|---|---|---|---|---|---|---|---|
22,239 | static int rv40_h_loop_filter_strength(uint8_t *src, int stride,
int beta, int beta2, int edge,
int *p1, int *q1)
{
return rv40_loop_filter_strength(src, stride, 1, beta, beta2, edge, p1, q1);
}
| true | FFmpeg | 3ab9a2a5577d445252724af4067d2a7c8a378efa | static int rv40_h_loop_filter_strength(uint8_t *src, int stride,
int beta, int beta2, int edge,
int *p1, int *q1)
{
return rv40_loop_filter_strength(src, stride, 1, beta, beta2, edge, p1, q1);
}
| {
"code": [
"static int rv40_h_loop_filter_strength(uint8_t *src, int stride,"
],
"line_no": [
1
]
} | static int FUNC_0(uint8_t *VAR_0, int VAR_1,
int VAR_2, int VAR_3, int VAR_4,
int *VAR_5, int *VAR_6)
{
return rv40_loop_filter_strength(VAR_0, VAR_1, 1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6);
}
| [
"static int FUNC_0(uint8_t *VAR_0, int VAR_1,\nint VAR_2, int VAR_3, int VAR_4,\nint *VAR_5, int *VAR_6)\n{",
"return rv40_loop_filter_strength(VAR_0, VAR_1, 1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6);",
"}"
] | [
1,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
]
] |
22,240 | static int decode_pic(AVSContext *h) {
MpegEncContext *s = &h->s;
int skip_count;
enum cavs_mb mb_type;
if (!s->context_initialized) {
s->avctx->idct_algo = FF_IDCT_CAVS;
if (MPV_common_init(s) < 0)
return -1;
ff_init_scantable(s->dsp.idct_permutation,&h->scantable,ff_zigzag_direct);
}
skip_bits(&s->gb,16);//bbv_dwlay
if(h->stc == PIC_PB_START_CODE) {
h->pic_type = get_bits(&s->gb,2) + FF_I_TYPE;
if(h->pic_type > FF_B_TYPE) {
av_log(s->avctx, AV_LOG_ERROR, "illegal picture type\n");
return -1;
}
/* make sure we have the reference frames we need */
if(!h->DPB[0].data[0] ||
(!h->DPB[1].data[0] && h->pic_type == FF_B_TYPE))
return -1;
} else {
h->pic_type = FF_I_TYPE;
if(get_bits1(&s->gb))
skip_bits(&s->gb,24);//time_code
}
/* release last B frame */
if(h->picture.data[0])
s->avctx->release_buffer(s->avctx, (AVFrame *)&h->picture);
s->avctx->get_buffer(s->avctx, (AVFrame *)&h->picture);
ff_cavs_init_pic(h);
h->picture.poc = get_bits(&s->gb,8)*2;
/* get temporal distances and MV scaling factors */
if(h->pic_type != FF_B_TYPE) {
h->dist[0] = (h->picture.poc - h->DPB[0].poc + 512) % 512;
} else {
h->dist[0] = (h->DPB[0].poc - h->picture.poc + 512) % 512;
}
h->dist[1] = (h->picture.poc - h->DPB[1].poc + 512) % 512;
h->scale_den[0] = h->dist[0] ? 512/h->dist[0] : 0;
h->scale_den[1] = h->dist[1] ? 512/h->dist[1] : 0;
if(h->pic_type == FF_B_TYPE) {
h->sym_factor = h->dist[0]*h->scale_den[1];
} else {
h->direct_den[0] = h->dist[0] ? 16384/h->dist[0] : 0;
h->direct_den[1] = h->dist[1] ? 16384/h->dist[1] : 0;
}
if(s->low_delay)
get_ue_golomb(&s->gb); //bbv_check_times
h->progressive = get_bits1(&s->gb);
h->pic_structure = 1;
if(!h->progressive)
h->pic_structure = get_bits1(&s->gb);
if(!h->pic_structure && h->stc == PIC_PB_START_CODE)
skip_bits1(&s->gb); //advanced_pred_mode_disable
skip_bits1(&s->gb); //top_field_first
skip_bits1(&s->gb); //repeat_first_field
h->qp_fixed = get_bits1(&s->gb);
h->qp = get_bits(&s->gb,6);
if(h->pic_type == FF_I_TYPE) {
if(!h->progressive && !h->pic_structure)
skip_bits1(&s->gb);//what is this?
skip_bits(&s->gb,4); //reserved bits
} else {
if(!(h->pic_type == FF_B_TYPE && h->pic_structure == 1))
h->ref_flag = get_bits1(&s->gb);
skip_bits(&s->gb,4); //reserved bits
h->skip_mode_flag = get_bits1(&s->gb);
}
h->loop_filter_disable = get_bits1(&s->gb);
if(!h->loop_filter_disable && get_bits1(&s->gb)) {
h->alpha_offset = get_se_golomb(&s->gb);
h->beta_offset = get_se_golomb(&s->gb);
} else {
h->alpha_offset = h->beta_offset = 0;
}
if(h->pic_type == FF_I_TYPE) {
do {
check_for_slice(h);
decode_mb_i(h, 0);
} while(ff_cavs_next_mb(h));
} else if(h->pic_type == FF_P_TYPE) {
do {
check_for_slice(h);
if(h->skip_mode_flag) {
skip_count = get_ue_golomb(&s->gb);
while(skip_count--) {
decode_mb_p(h,P_SKIP);
if(!ff_cavs_next_mb(h))
goto done;
}
check_for_slice(h);
mb_type = get_ue_golomb(&s->gb) + P_16X16;
} else
mb_type = get_ue_golomb(&s->gb) + P_SKIP;
if(mb_type > P_8X8) {
decode_mb_i(h, mb_type - P_8X8 - 1);
} else
decode_mb_p(h,mb_type);
} while(ff_cavs_next_mb(h));
} else { /* FF_B_TYPE */
do {
check_for_slice(h);
if(h->skip_mode_flag) {
skip_count = get_ue_golomb(&s->gb);
while(skip_count--) {
decode_mb_b(h,B_SKIP);
if(!ff_cavs_next_mb(h))
goto done;
}
check_for_slice(h);
mb_type = get_ue_golomb(&s->gb) + B_DIRECT;
} else
mb_type = get_ue_golomb(&s->gb) + B_SKIP;
if(mb_type > B_8X8) {
decode_mb_i(h, mb_type - B_8X8 - 1);
} else
decode_mb_b(h,mb_type);
} while(ff_cavs_next_mb(h));
}
done:
if(h->pic_type != FF_B_TYPE) {
if(h->DPB[1].data[0])
s->avctx->release_buffer(s->avctx, (AVFrame *)&h->DPB[1]);
h->DPB[1] = h->DPB[0];
h->DPB[0] = h->picture;
memset(&h->picture,0,sizeof(Picture));
}
return 0;
}
| false | FFmpeg | 88db5551cf1ced4ea3e5e8bd5b684d2dc74b1ed2 | static int decode_pic(AVSContext *h) {
MpegEncContext *s = &h->s;
int skip_count;
enum cavs_mb mb_type;
if (!s->context_initialized) {
s->avctx->idct_algo = FF_IDCT_CAVS;
if (MPV_common_init(s) < 0)
return -1;
ff_init_scantable(s->dsp.idct_permutation,&h->scantable,ff_zigzag_direct);
}
skip_bits(&s->gb,16);
if(h->stc == PIC_PB_START_CODE) {
h->pic_type = get_bits(&s->gb,2) + FF_I_TYPE;
if(h->pic_type > FF_B_TYPE) {
av_log(s->avctx, AV_LOG_ERROR, "illegal picture type\n");
return -1;
}
if(!h->DPB[0].data[0] ||
(!h->DPB[1].data[0] && h->pic_type == FF_B_TYPE))
return -1;
} else {
h->pic_type = FF_I_TYPE;
if(get_bits1(&s->gb))
skip_bits(&s->gb,24);
}
if(h->picture.data[0])
s->avctx->release_buffer(s->avctx, (AVFrame *)&h->picture);
s->avctx->get_buffer(s->avctx, (AVFrame *)&h->picture);
ff_cavs_init_pic(h);
h->picture.poc = get_bits(&s->gb,8)*2;
if(h->pic_type != FF_B_TYPE) {
h->dist[0] = (h->picture.poc - h->DPB[0].poc + 512) % 512;
} else {
h->dist[0] = (h->DPB[0].poc - h->picture.poc + 512) % 512;
}
h->dist[1] = (h->picture.poc - h->DPB[1].poc + 512) % 512;
h->scale_den[0] = h->dist[0] ? 512/h->dist[0] : 0;
h->scale_den[1] = h->dist[1] ? 512/h->dist[1] : 0;
if(h->pic_type == FF_B_TYPE) {
h->sym_factor = h->dist[0]*h->scale_den[1];
} else {
h->direct_den[0] = h->dist[0] ? 16384/h->dist[0] : 0;
h->direct_den[1] = h->dist[1] ? 16384/h->dist[1] : 0;
}
if(s->low_delay)
get_ue_golomb(&s->gb);
h->progressive = get_bits1(&s->gb);
h->pic_structure = 1;
if(!h->progressive)
h->pic_structure = get_bits1(&s->gb);
if(!h->pic_structure && h->stc == PIC_PB_START_CODE)
skip_bits1(&s->gb);
skip_bits1(&s->gb);
skip_bits1(&s->gb);
h->qp_fixed = get_bits1(&s->gb);
h->qp = get_bits(&s->gb,6);
if(h->pic_type == FF_I_TYPE) {
if(!h->progressive && !h->pic_structure)
skip_bits1(&s->gb);
skip_bits(&s->gb,4);
} else {
if(!(h->pic_type == FF_B_TYPE && h->pic_structure == 1))
h->ref_flag = get_bits1(&s->gb);
skip_bits(&s->gb,4);
h->skip_mode_flag = get_bits1(&s->gb);
}
h->loop_filter_disable = get_bits1(&s->gb);
if(!h->loop_filter_disable && get_bits1(&s->gb)) {
h->alpha_offset = get_se_golomb(&s->gb);
h->beta_offset = get_se_golomb(&s->gb);
} else {
h->alpha_offset = h->beta_offset = 0;
}
if(h->pic_type == FF_I_TYPE) {
do {
check_for_slice(h);
decode_mb_i(h, 0);
} while(ff_cavs_next_mb(h));
} else if(h->pic_type == FF_P_TYPE) {
do {
check_for_slice(h);
if(h->skip_mode_flag) {
skip_count = get_ue_golomb(&s->gb);
while(skip_count--) {
decode_mb_p(h,P_SKIP);
if(!ff_cavs_next_mb(h))
goto done;
}
check_for_slice(h);
mb_type = get_ue_golomb(&s->gb) + P_16X16;
} else
mb_type = get_ue_golomb(&s->gb) + P_SKIP;
if(mb_type > P_8X8) {
decode_mb_i(h, mb_type - P_8X8 - 1);
} else
decode_mb_p(h,mb_type);
} while(ff_cavs_next_mb(h));
} else {
do {
check_for_slice(h);
if(h->skip_mode_flag) {
skip_count = get_ue_golomb(&s->gb);
while(skip_count--) {
decode_mb_b(h,B_SKIP);
if(!ff_cavs_next_mb(h))
goto done;
}
check_for_slice(h);
mb_type = get_ue_golomb(&s->gb) + B_DIRECT;
} else
mb_type = get_ue_golomb(&s->gb) + B_SKIP;
if(mb_type > B_8X8) {
decode_mb_i(h, mb_type - B_8X8 - 1);
} else
decode_mb_b(h,mb_type);
} while(ff_cavs_next_mb(h));
}
done:
if(h->pic_type != FF_B_TYPE) {
if(h->DPB[1].data[0])
s->avctx->release_buffer(s->avctx, (AVFrame *)&h->DPB[1]);
h->DPB[1] = h->DPB[0];
h->DPB[0] = h->picture;
memset(&h->picture,0,sizeof(Picture));
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVSContext *VAR_0) {
MpegEncContext *s = &VAR_0->s;
int VAR_1;
enum cavs_mb VAR_2;
if (!s->context_initialized) {
s->avctx->idct_algo = FF_IDCT_CAVS;
if (MPV_common_init(s) < 0)
return -1;
ff_init_scantable(s->dsp.idct_permutation,&VAR_0->scantable,ff_zigzag_direct);
}
skip_bits(&s->gb,16);
if(VAR_0->stc == PIC_PB_START_CODE) {
VAR_0->pic_type = get_bits(&s->gb,2) + FF_I_TYPE;
if(VAR_0->pic_type > FF_B_TYPE) {
av_log(s->avctx, AV_LOG_ERROR, "illegal picture type\n");
return -1;
}
if(!VAR_0->DPB[0].data[0] ||
(!VAR_0->DPB[1].data[0] && VAR_0->pic_type == FF_B_TYPE))
return -1;
} else {
VAR_0->pic_type = FF_I_TYPE;
if(get_bits1(&s->gb))
skip_bits(&s->gb,24);
}
if(VAR_0->picture.data[0])
s->avctx->release_buffer(s->avctx, (AVFrame *)&VAR_0->picture);
s->avctx->get_buffer(s->avctx, (AVFrame *)&VAR_0->picture);
ff_cavs_init_pic(VAR_0);
VAR_0->picture.poc = get_bits(&s->gb,8)*2;
if(VAR_0->pic_type != FF_B_TYPE) {
VAR_0->dist[0] = (VAR_0->picture.poc - VAR_0->DPB[0].poc + 512) % 512;
} else {
VAR_0->dist[0] = (VAR_0->DPB[0].poc - VAR_0->picture.poc + 512) % 512;
}
VAR_0->dist[1] = (VAR_0->picture.poc - VAR_0->DPB[1].poc + 512) % 512;
VAR_0->scale_den[0] = VAR_0->dist[0] ? 512/VAR_0->dist[0] : 0;
VAR_0->scale_den[1] = VAR_0->dist[1] ? 512/VAR_0->dist[1] : 0;
if(VAR_0->pic_type == FF_B_TYPE) {
VAR_0->sym_factor = VAR_0->dist[0]*VAR_0->scale_den[1];
} else {
VAR_0->direct_den[0] = VAR_0->dist[0] ? 16384/VAR_0->dist[0] : 0;
VAR_0->direct_den[1] = VAR_0->dist[1] ? 16384/VAR_0->dist[1] : 0;
}
if(s->low_delay)
get_ue_golomb(&s->gb);
VAR_0->progressive = get_bits1(&s->gb);
VAR_0->pic_structure = 1;
if(!VAR_0->progressive)
VAR_0->pic_structure = get_bits1(&s->gb);
if(!VAR_0->pic_structure && VAR_0->stc == PIC_PB_START_CODE)
skip_bits1(&s->gb);
skip_bits1(&s->gb);
skip_bits1(&s->gb);
VAR_0->qp_fixed = get_bits1(&s->gb);
VAR_0->qp = get_bits(&s->gb,6);
if(VAR_0->pic_type == FF_I_TYPE) {
if(!VAR_0->progressive && !VAR_0->pic_structure)
skip_bits1(&s->gb);
skip_bits(&s->gb,4);
} else {
if(!(VAR_0->pic_type == FF_B_TYPE && VAR_0->pic_structure == 1))
VAR_0->ref_flag = get_bits1(&s->gb);
skip_bits(&s->gb,4);
VAR_0->skip_mode_flag = get_bits1(&s->gb);
}
VAR_0->loop_filter_disable = get_bits1(&s->gb);
if(!VAR_0->loop_filter_disable && get_bits1(&s->gb)) {
VAR_0->alpha_offset = get_se_golomb(&s->gb);
VAR_0->beta_offset = get_se_golomb(&s->gb);
} else {
VAR_0->alpha_offset = VAR_0->beta_offset = 0;
}
if(VAR_0->pic_type == FF_I_TYPE) {
do {
check_for_slice(VAR_0);
decode_mb_i(VAR_0, 0);
} while(ff_cavs_next_mb(VAR_0));
} else if(VAR_0->pic_type == FF_P_TYPE) {
do {
check_for_slice(VAR_0);
if(VAR_0->skip_mode_flag) {
VAR_1 = get_ue_golomb(&s->gb);
while(VAR_1--) {
decode_mb_p(VAR_0,P_SKIP);
if(!ff_cavs_next_mb(VAR_0))
goto done;
}
check_for_slice(VAR_0);
VAR_2 = get_ue_golomb(&s->gb) + P_16X16;
} else
VAR_2 = get_ue_golomb(&s->gb) + P_SKIP;
if(VAR_2 > P_8X8) {
decode_mb_i(VAR_0, VAR_2 - P_8X8 - 1);
} else
decode_mb_p(VAR_0,VAR_2);
} while(ff_cavs_next_mb(VAR_0));
} else {
do {
check_for_slice(VAR_0);
if(VAR_0->skip_mode_flag) {
VAR_1 = get_ue_golomb(&s->gb);
while(VAR_1--) {
decode_mb_b(VAR_0,B_SKIP);
if(!ff_cavs_next_mb(VAR_0))
goto done;
}
check_for_slice(VAR_0);
VAR_2 = get_ue_golomb(&s->gb) + B_DIRECT;
} else
VAR_2 = get_ue_golomb(&s->gb) + B_SKIP;
if(VAR_2 > B_8X8) {
decode_mb_i(VAR_0, VAR_2 - B_8X8 - 1);
} else
decode_mb_b(VAR_0,VAR_2);
} while(ff_cavs_next_mb(VAR_0));
}
done:
if(VAR_0->pic_type != FF_B_TYPE) {
if(VAR_0->DPB[1].data[0])
s->avctx->release_buffer(s->avctx, (AVFrame *)&VAR_0->DPB[1]);
VAR_0->DPB[1] = VAR_0->DPB[0];
VAR_0->DPB[0] = VAR_0->picture;
memset(&VAR_0->picture,0,sizeof(Picture));
}
return 0;
}
| [
"static int FUNC_0(AVSContext *VAR_0) {",
"MpegEncContext *s = &VAR_0->s;",
"int VAR_1;",
"enum cavs_mb VAR_2;",
"if (!s->context_initialized) {",
"s->avctx->idct_algo = FF_IDCT_CAVS;",
"if (MPV_common_init(s) < 0)\nreturn -1;",
"ff_init_scantable(s->dsp.idct_permutation,&VAR_0->scantable,ff_zigzag_direct);",
"}",
"skip_bits(&s->gb,16);",
"if(VAR_0->stc == PIC_PB_START_CODE) {",
"VAR_0->pic_type = get_bits(&s->gb,2) + FF_I_TYPE;",
"if(VAR_0->pic_type > FF_B_TYPE) {",
"av_log(s->avctx, AV_LOG_ERROR, \"illegal picture type\\n\");",
"return -1;",
"}",
"if(!VAR_0->DPB[0].data[0] ||\n(!VAR_0->DPB[1].data[0] && VAR_0->pic_type == FF_B_TYPE))\nreturn -1;",
"} else {",
"VAR_0->pic_type = FF_I_TYPE;",
"if(get_bits1(&s->gb))\nskip_bits(&s->gb,24);",
"}",
"if(VAR_0->picture.data[0])\ns->avctx->release_buffer(s->avctx, (AVFrame *)&VAR_0->picture);",
"s->avctx->get_buffer(s->avctx, (AVFrame *)&VAR_0->picture);",
"ff_cavs_init_pic(VAR_0);",
"VAR_0->picture.poc = get_bits(&s->gb,8)*2;",
"if(VAR_0->pic_type != FF_B_TYPE) {",
"VAR_0->dist[0] = (VAR_0->picture.poc - VAR_0->DPB[0].poc + 512) % 512;",
"} else {",
"VAR_0->dist[0] = (VAR_0->DPB[0].poc - VAR_0->picture.poc + 512) % 512;",
"}",
"VAR_0->dist[1] = (VAR_0->picture.poc - VAR_0->DPB[1].poc + 512) % 512;",
"VAR_0->scale_den[0] = VAR_0->dist[0] ? 512/VAR_0->dist[0] : 0;",
"VAR_0->scale_den[1] = VAR_0->dist[1] ? 512/VAR_0->dist[1] : 0;",
"if(VAR_0->pic_type == FF_B_TYPE) {",
"VAR_0->sym_factor = VAR_0->dist[0]*VAR_0->scale_den[1];",
"} else {",
"VAR_0->direct_den[0] = VAR_0->dist[0] ? 16384/VAR_0->dist[0] : 0;",
"VAR_0->direct_den[1] = VAR_0->dist[1] ? 16384/VAR_0->dist[1] : 0;",
"}",
"if(s->low_delay)\nget_ue_golomb(&s->gb);",
"VAR_0->progressive = get_bits1(&s->gb);",
"VAR_0->pic_structure = 1;",
"if(!VAR_0->progressive)\nVAR_0->pic_structure = get_bits1(&s->gb);",
"if(!VAR_0->pic_structure && VAR_0->stc == PIC_PB_START_CODE)\nskip_bits1(&s->gb);",
"skip_bits1(&s->gb);",
"skip_bits1(&s->gb);",
"VAR_0->qp_fixed = get_bits1(&s->gb);",
"VAR_0->qp = get_bits(&s->gb,6);",
"if(VAR_0->pic_type == FF_I_TYPE) {",
"if(!VAR_0->progressive && !VAR_0->pic_structure)\nskip_bits1(&s->gb);",
"skip_bits(&s->gb,4);",
"} else {",
"if(!(VAR_0->pic_type == FF_B_TYPE && VAR_0->pic_structure == 1))\nVAR_0->ref_flag = get_bits1(&s->gb);",
"skip_bits(&s->gb,4);",
"VAR_0->skip_mode_flag = get_bits1(&s->gb);",
"}",
"VAR_0->loop_filter_disable = get_bits1(&s->gb);",
"if(!VAR_0->loop_filter_disable && get_bits1(&s->gb)) {",
"VAR_0->alpha_offset = get_se_golomb(&s->gb);",
"VAR_0->beta_offset = get_se_golomb(&s->gb);",
"} else {",
"VAR_0->alpha_offset = VAR_0->beta_offset = 0;",
"}",
"if(VAR_0->pic_type == FF_I_TYPE) {",
"do {",
"check_for_slice(VAR_0);",
"decode_mb_i(VAR_0, 0);",
"} while(ff_cavs_next_mb(VAR_0));",
"} else if(VAR_0->pic_type == FF_P_TYPE) {",
"do {",
"check_for_slice(VAR_0);",
"if(VAR_0->skip_mode_flag) {",
"VAR_1 = get_ue_golomb(&s->gb);",
"while(VAR_1--) {",
"decode_mb_p(VAR_0,P_SKIP);",
"if(!ff_cavs_next_mb(VAR_0))\ngoto done;",
"}",
"check_for_slice(VAR_0);",
"VAR_2 = get_ue_golomb(&s->gb) + P_16X16;",
"} else",
"VAR_2 = get_ue_golomb(&s->gb) + P_SKIP;",
"if(VAR_2 > P_8X8) {",
"decode_mb_i(VAR_0, VAR_2 - P_8X8 - 1);",
"} else",
"decode_mb_p(VAR_0,VAR_2);",
"} while(ff_cavs_next_mb(VAR_0));",
"} else {",
"do {",
"check_for_slice(VAR_0);",
"if(VAR_0->skip_mode_flag) {",
"VAR_1 = get_ue_golomb(&s->gb);",
"while(VAR_1--) {",
"decode_mb_b(VAR_0,B_SKIP);",
"if(!ff_cavs_next_mb(VAR_0))\ngoto done;",
"}",
"check_for_slice(VAR_0);",
"VAR_2 = get_ue_golomb(&s->gb) + B_DIRECT;",
"} else",
"VAR_2 = get_ue_golomb(&s->gb) + B_SKIP;",
"if(VAR_2 > B_8X8) {",
"decode_mb_i(VAR_0, VAR_2 - B_8X8 - 1);",
"} else",
"decode_mb_b(VAR_0,VAR_2);",
"} while(ff_cavs_next_mb(VAR_0));",
"}",
"done:\nif(VAR_0->pic_type != FF_B_TYPE) {",
"if(VAR_0->DPB[1].data[0])\ns->avctx->release_buffer(s->avctx, (AVFrame *)&VAR_0->DPB[1]);",
"VAR_0->DPB[1] = VAR_0->DPB[0];",
"VAR_0->DPB[0] = VAR_0->picture;",
"memset(&VAR_0->picture,0,sizeof(Picture));",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1
],
[
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15,
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39,
41,
43
],
[
45
],
[
47
],
[
49,
51
],
[
53
],
[
57,
59
],
[
63
],
[
65
],
[
67
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
103,
105
],
[
107
],
[
109
],
[
111,
113
],
[
115,
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129,
131
],
[
133
],
[
135
],
[
137,
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185,
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223,
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249,
251
],
[
253,
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267
]
] |
22,241 | static int gxf_interleave_packet(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush)
{
GXFContext *gxf = s->priv_data;
AVPacket new_pkt;
int i;
for (i = 0; i < s->nb_streams; i++) {
if (s->streams[i]->codec->codec_type == CODEC_TYPE_AUDIO) {
GXFStreamContext *sc = &gxf->streams[i];
if (pkt && pkt->stream_index == i) {
av_fifo_write(&sc->audio_buffer, pkt->data, pkt->size);
pkt = NULL;
}
if (flush || av_fifo_size(&sc->audio_buffer) >= GXF_AUDIO_PACKET_SIZE) {
if (!pkt && gxf_new_audio_packet(gxf, sc, &new_pkt, flush) > 0) {
pkt = &new_pkt;
break; /* add pkt right now into list */
}
}
}
}
return av_interleave_packet_per_dts(s, out, pkt, flush);
}
| false | FFmpeg | 6a287fd7ce5ea69f4eeadda6a049d669eb8efb46 | static int gxf_interleave_packet(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush)
{
GXFContext *gxf = s->priv_data;
AVPacket new_pkt;
int i;
for (i = 0; i < s->nb_streams; i++) {
if (s->streams[i]->codec->codec_type == CODEC_TYPE_AUDIO) {
GXFStreamContext *sc = &gxf->streams[i];
if (pkt && pkt->stream_index == i) {
av_fifo_write(&sc->audio_buffer, pkt->data, pkt->size);
pkt = NULL;
}
if (flush || av_fifo_size(&sc->audio_buffer) >= GXF_AUDIO_PACKET_SIZE) {
if (!pkt && gxf_new_audio_packet(gxf, sc, &new_pkt, flush) > 0) {
pkt = &new_pkt;
break;
}
}
}
}
return av_interleave_packet_per_dts(s, out, pkt, flush);
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1, AVPacket *VAR_2, int VAR_3)
{
GXFContext *gxf = VAR_0->priv_data;
AVPacket new_pkt;
int VAR_4;
for (VAR_4 = 0; VAR_4 < VAR_0->nb_streams; VAR_4++) {
if (VAR_0->streams[VAR_4]->codec->codec_type == CODEC_TYPE_AUDIO) {
GXFStreamContext *sc = &gxf->streams[VAR_4];
if (VAR_2 && VAR_2->stream_index == VAR_4) {
av_fifo_write(&sc->audio_buffer, VAR_2->data, VAR_2->size);
VAR_2 = NULL;
}
if (VAR_3 || av_fifo_size(&sc->audio_buffer) >= GXF_AUDIO_PACKET_SIZE) {
if (!VAR_2 && gxf_new_audio_packet(gxf, sc, &new_pkt, VAR_3) > 0) {
VAR_2 = &new_pkt;
break;
}
}
}
}
return av_interleave_packet_per_dts(VAR_0, VAR_1, VAR_2, VAR_3);
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1, AVPacket *VAR_2, int VAR_3)\n{",
"GXFContext *gxf = VAR_0->priv_data;",
"AVPacket new_pkt;",
"int VAR_4;",
"for (VAR_4 = 0; VAR_4 < VAR_0->nb_streams; VAR_4++) {",
"if (VAR_0->streams[VAR_4]->codec->codec_type == CODEC_TYPE_AUDIO) {",
"GXFStreamContext *sc = &gxf->streams[VAR_4];",
"if (VAR_2 && VAR_2->stream_index == VAR_4) {",
"av_fifo_write(&sc->audio_buffer, VAR_2->data, VAR_2->size);",
"VAR_2 = NULL;",
"}",
"if (VAR_3 || av_fifo_size(&sc->audio_buffer) >= GXF_AUDIO_PACKET_SIZE) {",
"if (!VAR_2 && gxf_new_audio_packet(gxf, sc, &new_pkt, VAR_3) > 0) {",
"VAR_2 = &new_pkt;",
"break;",
"}",
"}",
"}",
"}",
"return av_interleave_packet_per_dts(VAR_0, VAR_1, VAR_2, VAR_3);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
]
] |
22,242 | int ff_nvdec_decode_init(AVCodecContext *avctx)
{
NVDECContext *ctx = avctx->internal->hwaccel_priv_data;
NVDECFramePool *pool;
AVHWFramesContext *frames_ctx;
const AVPixFmtDescriptor *sw_desc;
CUVIDDECODECREATEINFO params = { 0 };
int cuvid_codec_type, cuvid_chroma_format;
int ret = 0;
sw_desc = av_pix_fmt_desc_get(avctx->sw_pix_fmt);
if (!sw_desc)
return AVERROR_BUG;
cuvid_codec_type = map_avcodec_id(avctx->codec_id);
if (cuvid_codec_type < 0) {
av_log(avctx, AV_LOG_ERROR, "Unsupported codec ID\n");
return AVERROR_BUG;
}
cuvid_chroma_format = map_chroma_format(avctx->sw_pix_fmt);
if (cuvid_chroma_format < 0) {
av_log(avctx, AV_LOG_ERROR, "Unsupported chroma format\n");
return AVERROR(ENOSYS);
}
if (!avctx->hw_frames_ctx) {
ret = ff_decode_get_hw_frames_ctx(avctx, AV_HWDEVICE_TYPE_CUDA);
if (ret < 0)
return ret;
}
frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data;
params.ulWidth = avctx->coded_width;
params.ulHeight = avctx->coded_height;
params.ulTargetWidth = avctx->coded_width;
params.ulTargetHeight = avctx->coded_height;
params.bitDepthMinus8 = sw_desc->comp[0].depth - 8;
params.OutputFormat = params.bitDepthMinus8 ?
cudaVideoSurfaceFormat_P016 : cudaVideoSurfaceFormat_NV12;
params.CodecType = cuvid_codec_type;
params.ChromaFormat = cuvid_chroma_format;
params.ulNumDecodeSurfaces = frames_ctx->initial_pool_size;
params.ulNumOutputSurfaces = 1;
ret = nvdec_decoder_create(&ctx->decoder_ref, frames_ctx->device_ref, ¶ms, avctx);
if (ret < 0)
return ret;
pool = av_mallocz(sizeof(*pool));
if (!pool) {
ret = AVERROR(ENOMEM);
goto fail;
}
pool->dpb_size = frames_ctx->initial_pool_size;
ctx->decoder_pool = av_buffer_pool_init2(sizeof(int), pool,
nvdec_decoder_frame_alloc, av_free);
if (!ctx->decoder_pool) {
ret = AVERROR(ENOMEM);
goto fail;
}
return 0;
fail:
ff_nvdec_decode_uninit(avctx);
return ret;
}
| false | FFmpeg | 538de4354dcd6c57154c5a5dec0744dcaa06b874 | int ff_nvdec_decode_init(AVCodecContext *avctx)
{
NVDECContext *ctx = avctx->internal->hwaccel_priv_data;
NVDECFramePool *pool;
AVHWFramesContext *frames_ctx;
const AVPixFmtDescriptor *sw_desc;
CUVIDDECODECREATEINFO params = { 0 };
int cuvid_codec_type, cuvid_chroma_format;
int ret = 0;
sw_desc = av_pix_fmt_desc_get(avctx->sw_pix_fmt);
if (!sw_desc)
return AVERROR_BUG;
cuvid_codec_type = map_avcodec_id(avctx->codec_id);
if (cuvid_codec_type < 0) {
av_log(avctx, AV_LOG_ERROR, "Unsupported codec ID\n");
return AVERROR_BUG;
}
cuvid_chroma_format = map_chroma_format(avctx->sw_pix_fmt);
if (cuvid_chroma_format < 0) {
av_log(avctx, AV_LOG_ERROR, "Unsupported chroma format\n");
return AVERROR(ENOSYS);
}
if (!avctx->hw_frames_ctx) {
ret = ff_decode_get_hw_frames_ctx(avctx, AV_HWDEVICE_TYPE_CUDA);
if (ret < 0)
return ret;
}
frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data;
params.ulWidth = avctx->coded_width;
params.ulHeight = avctx->coded_height;
params.ulTargetWidth = avctx->coded_width;
params.ulTargetHeight = avctx->coded_height;
params.bitDepthMinus8 = sw_desc->comp[0].depth - 8;
params.OutputFormat = params.bitDepthMinus8 ?
cudaVideoSurfaceFormat_P016 : cudaVideoSurfaceFormat_NV12;
params.CodecType = cuvid_codec_type;
params.ChromaFormat = cuvid_chroma_format;
params.ulNumDecodeSurfaces = frames_ctx->initial_pool_size;
params.ulNumOutputSurfaces = 1;
ret = nvdec_decoder_create(&ctx->decoder_ref, frames_ctx->device_ref, ¶ms, avctx);
if (ret < 0)
return ret;
pool = av_mallocz(sizeof(*pool));
if (!pool) {
ret = AVERROR(ENOMEM);
goto fail;
}
pool->dpb_size = frames_ctx->initial_pool_size;
ctx->decoder_pool = av_buffer_pool_init2(sizeof(int), pool,
nvdec_decoder_frame_alloc, av_free);
if (!ctx->decoder_pool) {
ret = AVERROR(ENOMEM);
goto fail;
}
return 0;
fail:
ff_nvdec_decode_uninit(avctx);
return ret;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(AVCodecContext *VAR_0)
{
NVDECContext *ctx = VAR_0->internal->hwaccel_priv_data;
NVDECFramePool *pool;
AVHWFramesContext *frames_ctx;
const AVPixFmtDescriptor *VAR_1;
CUVIDDECODECREATEINFO params = { 0 };
int VAR_2, VAR_3;
int VAR_4 = 0;
VAR_1 = av_pix_fmt_desc_get(VAR_0->sw_pix_fmt);
if (!VAR_1)
return AVERROR_BUG;
VAR_2 = map_avcodec_id(VAR_0->codec_id);
if (VAR_2 < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Unsupported codec ID\n");
return AVERROR_BUG;
}
VAR_3 = map_chroma_format(VAR_0->sw_pix_fmt);
if (VAR_3 < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Unsupported chroma format\n");
return AVERROR(ENOSYS);
}
if (!VAR_0->hw_frames_ctx) {
VAR_4 = ff_decode_get_hw_frames_ctx(VAR_0, AV_HWDEVICE_TYPE_CUDA);
if (VAR_4 < 0)
return VAR_4;
}
frames_ctx = (AVHWFramesContext*)VAR_0->hw_frames_ctx->data;
params.ulWidth = VAR_0->coded_width;
params.ulHeight = VAR_0->coded_height;
params.ulTargetWidth = VAR_0->coded_width;
params.ulTargetHeight = VAR_0->coded_height;
params.bitDepthMinus8 = VAR_1->comp[0].depth - 8;
params.OutputFormat = params.bitDepthMinus8 ?
cudaVideoSurfaceFormat_P016 : cudaVideoSurfaceFormat_NV12;
params.CodecType = VAR_2;
params.ChromaFormat = VAR_3;
params.ulNumDecodeSurfaces = frames_ctx->initial_pool_size;
params.ulNumOutputSurfaces = 1;
VAR_4 = nvdec_decoder_create(&ctx->decoder_ref, frames_ctx->device_ref, ¶ms, VAR_0);
if (VAR_4 < 0)
return VAR_4;
pool = av_mallocz(sizeof(*pool));
if (!pool) {
VAR_4 = AVERROR(ENOMEM);
goto fail;
}
pool->dpb_size = frames_ctx->initial_pool_size;
ctx->decoder_pool = av_buffer_pool_init2(sizeof(int), pool,
nvdec_decoder_frame_alloc, av_free);
if (!ctx->decoder_pool) {
VAR_4 = AVERROR(ENOMEM);
goto fail;
}
return 0;
fail:
ff_nvdec_decode_uninit(VAR_0);
return VAR_4;
}
| [
"int FUNC_0(AVCodecContext *VAR_0)\n{",
"NVDECContext *ctx = VAR_0->internal->hwaccel_priv_data;",
"NVDECFramePool *pool;",
"AVHWFramesContext *frames_ctx;",
"const AVPixFmtDescriptor *VAR_1;",
"CUVIDDECODECREATEINFO params = { 0 };",
"int VAR_2, VAR_3;",
"int VAR_4 = 0;",
"VAR_1 = av_pix_fmt_desc_get(VAR_0->sw_pix_fmt);",
"if (!VAR_1)\nreturn AVERROR_BUG;",
"VAR_2 = map_avcodec_id(VAR_0->codec_id);",
"if (VAR_2 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Unsupported codec ID\\n\");",
"return AVERROR_BUG;",
"}",
"VAR_3 = map_chroma_format(VAR_0->sw_pix_fmt);",
"if (VAR_3 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Unsupported chroma format\\n\");",
"return AVERROR(ENOSYS);",
"}",
"if (!VAR_0->hw_frames_ctx) {",
"VAR_4 = ff_decode_get_hw_frames_ctx(VAR_0, AV_HWDEVICE_TYPE_CUDA);",
"if (VAR_4 < 0)\nreturn VAR_4;",
"}",
"frames_ctx = (AVHWFramesContext*)VAR_0->hw_frames_ctx->data;",
"params.ulWidth = VAR_0->coded_width;",
"params.ulHeight = VAR_0->coded_height;",
"params.ulTargetWidth = VAR_0->coded_width;",
"params.ulTargetHeight = VAR_0->coded_height;",
"params.bitDepthMinus8 = VAR_1->comp[0].depth - 8;",
"params.OutputFormat = params.bitDepthMinus8 ?\ncudaVideoSurfaceFormat_P016 : cudaVideoSurfaceFormat_NV12;",
"params.CodecType = VAR_2;",
"params.ChromaFormat = VAR_3;",
"params.ulNumDecodeSurfaces = frames_ctx->initial_pool_size;",
"params.ulNumOutputSurfaces = 1;",
"VAR_4 = nvdec_decoder_create(&ctx->decoder_ref, frames_ctx->device_ref, ¶ms, VAR_0);",
"if (VAR_4 < 0)\nreturn VAR_4;",
"pool = av_mallocz(sizeof(*pool));",
"if (!pool) {",
"VAR_4 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"pool->dpb_size = frames_ctx->initial_pool_size;",
"ctx->decoder_pool = av_buffer_pool_init2(sizeof(int), pool,\nnvdec_decoder_frame_alloc, av_free);",
"if (!ctx->decoder_pool) {",
"VAR_4 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"return 0;",
"fail:\nff_nvdec_decode_uninit(VAR_0);",
"return VAR_4;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
17
],
[
21
],
[
23
],
[
27
],
[
29,
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63,
65
],
[
67
],
[
71
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85,
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
99
],
[
101,
103
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
121,
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
135
],
[
137,
139
],
[
141
],
[
143
]
] |
22,243 | static void versatile_init(ram_addr_t ram_size,
const char *boot_device,
const char *kernel_filename, const char *kernel_cmdline,
const char *initrd_filename, const char *cpu_model,
int board_id)
{
CPUState *env;
ram_addr_t ram_offset;
qemu_irq *cpu_pic;
qemu_irq pic[32];
qemu_irq sic[32];
DeviceState *dev;
PCIBus *pci_bus;
NICInfo *nd;
int n;
int done_smc = 0;
if (!cpu_model)
cpu_model = "arm926";
env = cpu_init(cpu_model);
if (!env) {
fprintf(stderr, "Unable to find CPU definition\n");
exit(1);
}
ram_offset = qemu_ram_alloc(NULL, "versatile.ram", ram_size);
/* ??? RAM should repeat to fill physical memory space. */
/* SDRAM at address zero. */
cpu_register_physical_memory(0, ram_size, ram_offset | IO_MEM_RAM);
arm_sysctl_init(0x10000000, 0x41007004, 0x02000000);
cpu_pic = arm_pic_init_cpu(env);
dev = sysbus_create_varargs("pl190", 0x10140000,
cpu_pic[0], cpu_pic[1], NULL);
for (n = 0; n < 32; n++) {
pic[n] = qdev_get_gpio_in(dev, n);
}
dev = sysbus_create_simple("versatilepb_sic", 0x10003000, NULL);
for (n = 0; n < 32; n++) {
sysbus_connect_irq(sysbus_from_qdev(dev), n, pic[n]);
sic[n] = qdev_get_gpio_in(dev, n);
}
sysbus_create_simple("pl050_keyboard", 0x10006000, sic[3]);
sysbus_create_simple("pl050_mouse", 0x10007000, sic[4]);
dev = sysbus_create_varargs("versatile_pci", 0x40000000,
sic[27], sic[28], sic[29], sic[30], NULL);
pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci");
/* The Versatile PCI bridge does not provide access to PCI IO space,
so many of the qemu PCI devices are not useable. */
for(n = 0; n < nb_nics; n++) {
nd = &nd_table[n];
if ((!nd->model && !done_smc) || strcmp(nd->model, "smc91c111") == 0) {
smc91c111_init(nd, 0x10010000, sic[25]);
done_smc = 1;
} else {
pci_nic_init_nofail(nd, "rtl8139", NULL);
}
}
if (usb_enabled) {
usb_ohci_init_pci(pci_bus, -1);
}
n = drive_get_max_bus(IF_SCSI);
while (n >= 0) {
pci_create_simple(pci_bus, -1, "lsi53c895a");
n--;
}
sysbus_create_simple("pl011", 0x101f1000, pic[12]);
sysbus_create_simple("pl011", 0x101f2000, pic[13]);
sysbus_create_simple("pl011", 0x101f3000, pic[14]);
sysbus_create_simple("pl011", 0x10009000, sic[6]);
sysbus_create_simple("pl080", 0x10130000, pic[17]);
sysbus_create_simple("sp804", 0x101e2000, pic[4]);
sysbus_create_simple("sp804", 0x101e3000, pic[5]);
/* The versatile/PB actually has a modified Color LCD controller
that includes hardware cursor support from the PL111. */
sysbus_create_simple("pl110_versatile", 0x10120000, pic[16]);
sysbus_create_varargs("pl181", 0x10005000, sic[22], sic[1], NULL);
sysbus_create_varargs("pl181", 0x1000b000, sic[23], sic[2], NULL);
/* Add PL031 Real Time Clock. */
sysbus_create_simple("pl031", 0x101e8000, pic[10]);
/* Memory map for Versatile/PB: */
/* 0x10000000 System registers. */
/* 0x10001000 PCI controller config registers. */
/* 0x10002000 Serial bus interface. */
/* 0x10003000 Secondary interrupt controller. */
/* 0x10004000 AACI (audio). */
/* 0x10005000 MMCI0. */
/* 0x10006000 KMI0 (keyboard). */
/* 0x10007000 KMI1 (mouse). */
/* 0x10008000 Character LCD Interface. */
/* 0x10009000 UART3. */
/* 0x1000a000 Smart card 1. */
/* 0x1000b000 MMCI1. */
/* 0x10010000 Ethernet. */
/* 0x10020000 USB. */
/* 0x10100000 SSMC. */
/* 0x10110000 MPMC. */
/* 0x10120000 CLCD Controller. */
/* 0x10130000 DMA Controller. */
/* 0x10140000 Vectored interrupt controller. */
/* 0x101d0000 AHB Monitor Interface. */
/* 0x101e0000 System Controller. */
/* 0x101e1000 Watchdog Interface. */
/* 0x101e2000 Timer 0/1. */
/* 0x101e3000 Timer 2/3. */
/* 0x101e4000 GPIO port 0. */
/* 0x101e5000 GPIO port 1. */
/* 0x101e6000 GPIO port 2. */
/* 0x101e7000 GPIO port 3. */
/* 0x101e8000 RTC. */
/* 0x101f0000 Smart card 0. */
/* 0x101f1000 UART0. */
/* 0x101f2000 UART1. */
/* 0x101f3000 UART2. */
/* 0x101f4000 SSPI. */
versatile_binfo.ram_size = ram_size;
versatile_binfo.kernel_filename = kernel_filename;
versatile_binfo.kernel_cmdline = kernel_cmdline;
versatile_binfo.initrd_filename = initrd_filename;
versatile_binfo.board_id = board_id;
arm_load_kernel(env, &versatile_binfo);
}
| true | qemu | e6b3c8ca0222f6633516c0461a713e7bddc4f076 | static void versatile_init(ram_addr_t ram_size,
const char *boot_device,
const char *kernel_filename, const char *kernel_cmdline,
const char *initrd_filename, const char *cpu_model,
int board_id)
{
CPUState *env;
ram_addr_t ram_offset;
qemu_irq *cpu_pic;
qemu_irq pic[32];
qemu_irq sic[32];
DeviceState *dev;
PCIBus *pci_bus;
NICInfo *nd;
int n;
int done_smc = 0;
if (!cpu_model)
cpu_model = "arm926";
env = cpu_init(cpu_model);
if (!env) {
fprintf(stderr, "Unable to find CPU definition\n");
exit(1);
}
ram_offset = qemu_ram_alloc(NULL, "versatile.ram", ram_size);
cpu_register_physical_memory(0, ram_size, ram_offset | IO_MEM_RAM);
arm_sysctl_init(0x10000000, 0x41007004, 0x02000000);
cpu_pic = arm_pic_init_cpu(env);
dev = sysbus_create_varargs("pl190", 0x10140000,
cpu_pic[0], cpu_pic[1], NULL);
for (n = 0; n < 32; n++) {
pic[n] = qdev_get_gpio_in(dev, n);
}
dev = sysbus_create_simple("versatilepb_sic", 0x10003000, NULL);
for (n = 0; n < 32; n++) {
sysbus_connect_irq(sysbus_from_qdev(dev), n, pic[n]);
sic[n] = qdev_get_gpio_in(dev, n);
}
sysbus_create_simple("pl050_keyboard", 0x10006000, sic[3]);
sysbus_create_simple("pl050_mouse", 0x10007000, sic[4]);
dev = sysbus_create_varargs("versatile_pci", 0x40000000,
sic[27], sic[28], sic[29], sic[30], NULL);
pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci");
for(n = 0; n < nb_nics; n++) {
nd = &nd_table[n];
if ((!nd->model && !done_smc) || strcmp(nd->model, "smc91c111") == 0) {
smc91c111_init(nd, 0x10010000, sic[25]);
done_smc = 1;
} else {
pci_nic_init_nofail(nd, "rtl8139", NULL);
}
}
if (usb_enabled) {
usb_ohci_init_pci(pci_bus, -1);
}
n = drive_get_max_bus(IF_SCSI);
while (n >= 0) {
pci_create_simple(pci_bus, -1, "lsi53c895a");
n--;
}
sysbus_create_simple("pl011", 0x101f1000, pic[12]);
sysbus_create_simple("pl011", 0x101f2000, pic[13]);
sysbus_create_simple("pl011", 0x101f3000, pic[14]);
sysbus_create_simple("pl011", 0x10009000, sic[6]);
sysbus_create_simple("pl080", 0x10130000, pic[17]);
sysbus_create_simple("sp804", 0x101e2000, pic[4]);
sysbus_create_simple("sp804", 0x101e3000, pic[5]);
sysbus_create_simple("pl110_versatile", 0x10120000, pic[16]);
sysbus_create_varargs("pl181", 0x10005000, sic[22], sic[1], NULL);
sysbus_create_varargs("pl181", 0x1000b000, sic[23], sic[2], NULL);
sysbus_create_simple("pl031", 0x101e8000, pic[10]);
versatile_binfo.ram_size = ram_size;
versatile_binfo.kernel_filename = kernel_filename;
versatile_binfo.kernel_cmdline = kernel_cmdline;
versatile_binfo.initrd_filename = initrd_filename;
versatile_binfo.board_id = board_id;
arm_load_kernel(env, &versatile_binfo);
}
| {
"code": [
" if ((!nd->model && !done_smc) || strcmp(nd->model, \"smc91c111\") == 0) {"
],
"line_no": [
109
]
} | static void FUNC_0(ram_addr_t VAR_0,
const char *VAR_1,
const char *VAR_2, const char *VAR_3,
const char *VAR_4, const char *VAR_5,
int VAR_6)
{
CPUState *env;
ram_addr_t ram_offset;
qemu_irq *cpu_pic;
qemu_irq pic[32];
qemu_irq sic[32];
DeviceState *dev;
PCIBus *pci_bus;
NICInfo *nd;
int VAR_7;
int VAR_8 = 0;
if (!VAR_5)
VAR_5 = "arm926";
env = cpu_init(VAR_5);
if (!env) {
fprintf(stderr, "Unable to find CPU definition\VAR_7");
exit(1);
}
ram_offset = qemu_ram_alloc(NULL, "versatile.ram", VAR_0);
cpu_register_physical_memory(0, VAR_0, ram_offset | IO_MEM_RAM);
arm_sysctl_init(0x10000000, 0x41007004, 0x02000000);
cpu_pic = arm_pic_init_cpu(env);
dev = sysbus_create_varargs("pl190", 0x10140000,
cpu_pic[0], cpu_pic[1], NULL);
for (VAR_7 = 0; VAR_7 < 32; VAR_7++) {
pic[VAR_7] = qdev_get_gpio_in(dev, VAR_7);
}
dev = sysbus_create_simple("versatilepb_sic", 0x10003000, NULL);
for (VAR_7 = 0; VAR_7 < 32; VAR_7++) {
sysbus_connect_irq(sysbus_from_qdev(dev), VAR_7, pic[VAR_7]);
sic[VAR_7] = qdev_get_gpio_in(dev, VAR_7);
}
sysbus_create_simple("pl050_keyboard", 0x10006000, sic[3]);
sysbus_create_simple("pl050_mouse", 0x10007000, sic[4]);
dev = sysbus_create_varargs("versatile_pci", 0x40000000,
sic[27], sic[28], sic[29], sic[30], NULL);
pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci");
for(VAR_7 = 0; VAR_7 < nb_nics; VAR_7++) {
nd = &nd_table[VAR_7];
if ((!nd->model && !VAR_8) || strcmp(nd->model, "smc91c111") == 0) {
smc91c111_init(nd, 0x10010000, sic[25]);
VAR_8 = 1;
} else {
pci_nic_init_nofail(nd, "rtl8139", NULL);
}
}
if (usb_enabled) {
usb_ohci_init_pci(pci_bus, -1);
}
VAR_7 = drive_get_max_bus(IF_SCSI);
while (VAR_7 >= 0) {
pci_create_simple(pci_bus, -1, "lsi53c895a");
VAR_7--;
}
sysbus_create_simple("pl011", 0x101f1000, pic[12]);
sysbus_create_simple("pl011", 0x101f2000, pic[13]);
sysbus_create_simple("pl011", 0x101f3000, pic[14]);
sysbus_create_simple("pl011", 0x10009000, sic[6]);
sysbus_create_simple("pl080", 0x10130000, pic[17]);
sysbus_create_simple("sp804", 0x101e2000, pic[4]);
sysbus_create_simple("sp804", 0x101e3000, pic[5]);
sysbus_create_simple("pl110_versatile", 0x10120000, pic[16]);
sysbus_create_varargs("pl181", 0x10005000, sic[22], sic[1], NULL);
sysbus_create_varargs("pl181", 0x1000b000, sic[23], sic[2], NULL);
sysbus_create_simple("pl031", 0x101e8000, pic[10]);
versatile_binfo.VAR_0 = VAR_0;
versatile_binfo.VAR_2 = VAR_2;
versatile_binfo.VAR_3 = VAR_3;
versatile_binfo.VAR_4 = VAR_4;
versatile_binfo.VAR_6 = VAR_6;
arm_load_kernel(env, &versatile_binfo);
}
| [
"static void FUNC_0(ram_addr_t VAR_0,\nconst char *VAR_1,\nconst char *VAR_2, const char *VAR_3,\nconst char *VAR_4, const char *VAR_5,\nint VAR_6)\n{",
"CPUState *env;",
"ram_addr_t ram_offset;",
"qemu_irq *cpu_pic;",
"qemu_irq pic[32];",
"qemu_irq sic[32];",
"DeviceState *dev;",
"PCIBus *pci_bus;",
"NICInfo *nd;",
"int VAR_7;",
"int VAR_8 = 0;",
"if (!VAR_5)\nVAR_5 = \"arm926\";",
"env = cpu_init(VAR_5);",
"if (!env) {",
"fprintf(stderr, \"Unable to find CPU definition\\VAR_7\");",
"exit(1);",
"}",
"ram_offset = qemu_ram_alloc(NULL, \"versatile.ram\", VAR_0);",
"cpu_register_physical_memory(0, VAR_0, ram_offset | IO_MEM_RAM);",
"arm_sysctl_init(0x10000000, 0x41007004, 0x02000000);",
"cpu_pic = arm_pic_init_cpu(env);",
"dev = sysbus_create_varargs(\"pl190\", 0x10140000,\ncpu_pic[0], cpu_pic[1], NULL);",
"for (VAR_7 = 0; VAR_7 < 32; VAR_7++) {",
"pic[VAR_7] = qdev_get_gpio_in(dev, VAR_7);",
"}",
"dev = sysbus_create_simple(\"versatilepb_sic\", 0x10003000, NULL);",
"for (VAR_7 = 0; VAR_7 < 32; VAR_7++) {",
"sysbus_connect_irq(sysbus_from_qdev(dev), VAR_7, pic[VAR_7]);",
"sic[VAR_7] = qdev_get_gpio_in(dev, VAR_7);",
"}",
"sysbus_create_simple(\"pl050_keyboard\", 0x10006000, sic[3]);",
"sysbus_create_simple(\"pl050_mouse\", 0x10007000, sic[4]);",
"dev = sysbus_create_varargs(\"versatile_pci\", 0x40000000,\nsic[27], sic[28], sic[29], sic[30], NULL);",
"pci_bus = (PCIBus *)qdev_get_child_bus(dev, \"pci\");",
"for(VAR_7 = 0; VAR_7 < nb_nics; VAR_7++) {",
"nd = &nd_table[VAR_7];",
"if ((!nd->model && !VAR_8) || strcmp(nd->model, \"smc91c111\") == 0) {",
"smc91c111_init(nd, 0x10010000, sic[25]);",
"VAR_8 = 1;",
"} else {",
"pci_nic_init_nofail(nd, \"rtl8139\", NULL);",
"}",
"}",
"if (usb_enabled) {",
"usb_ohci_init_pci(pci_bus, -1);",
"}",
"VAR_7 = drive_get_max_bus(IF_SCSI);",
"while (VAR_7 >= 0) {",
"pci_create_simple(pci_bus, -1, \"lsi53c895a\");",
"VAR_7--;",
"}",
"sysbus_create_simple(\"pl011\", 0x101f1000, pic[12]);",
"sysbus_create_simple(\"pl011\", 0x101f2000, pic[13]);",
"sysbus_create_simple(\"pl011\", 0x101f3000, pic[14]);",
"sysbus_create_simple(\"pl011\", 0x10009000, sic[6]);",
"sysbus_create_simple(\"pl080\", 0x10130000, pic[17]);",
"sysbus_create_simple(\"sp804\", 0x101e2000, pic[4]);",
"sysbus_create_simple(\"sp804\", 0x101e3000, pic[5]);",
"sysbus_create_simple(\"pl110_versatile\", 0x10120000, pic[16]);",
"sysbus_create_varargs(\"pl181\", 0x10005000, sic[22], sic[1], NULL);",
"sysbus_create_varargs(\"pl181\", 0x1000b000, sic[23], sic[2], NULL);",
"sysbus_create_simple(\"pl031\", 0x101e8000, pic[10]);",
"versatile_binfo.VAR_0 = VAR_0;",
"versatile_binfo.VAR_2 = VAR_2;",
"versatile_binfo.VAR_3 = VAR_3;",
"versatile_binfo.VAR_4 = VAR_4;",
"versatile_binfo.VAR_6 = VAR_6;",
"arm_load_kernel(env, &versatile_binfo);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35,
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
55
],
[
59
],
[
61
],
[
63,
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87
],
[
91,
93
],
[
95
],
[
103
],
[
105
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
141
],
[
143
],
[
145
],
[
147
],
[
151
],
[
153
],
[
155
],
[
163
],
[
167
],
[
169
],
[
175
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
]
] |
22,245 | static void kvm_mem_ioeventfd_add(MemoryListener *listener,
MemoryRegionSection *section,
bool match_data, uint64_t data,
EventNotifier *e)
{
int fd = event_notifier_get_fd(e);
int r;
r = kvm_set_ioeventfd_mmio(fd, section->offset_within_address_space,
data, true, int128_get64(section->size),
match_data);
if (r < 0) {
abort();
}
} | true | qemu | fa4ba923bd539647ace9d70d226a848bd6a89dac | static void kvm_mem_ioeventfd_add(MemoryListener *listener,
MemoryRegionSection *section,
bool match_data, uint64_t data,
EventNotifier *e)
{
int fd = event_notifier_get_fd(e);
int r;
r = kvm_set_ioeventfd_mmio(fd, section->offset_within_address_space,
data, true, int128_get64(section->size),
match_data);
if (r < 0) {
abort();
}
} | {
"code": [],
"line_no": []
} | static void FUNC_0(MemoryListener *VAR_0,
MemoryRegionSection *VAR_1,
bool VAR_2, uint64_t VAR_3,
EventNotifier *VAR_4)
{
int VAR_5 = event_notifier_get_fd(VAR_4);
int VAR_6;
VAR_6 = kvm_set_ioeventfd_mmio(VAR_5, VAR_1->offset_within_address_space,
VAR_3, true, int128_get64(VAR_1->size),
VAR_2);
if (VAR_6 < 0) {
abort();
}
} | [
"static void FUNC_0(MemoryListener *VAR_0,\nMemoryRegionSection *VAR_1,\nbool VAR_2, uint64_t VAR_3,\nEventNotifier *VAR_4)\n{",
"int VAR_5 = event_notifier_get_fd(VAR_4);",
"int VAR_6;",
"VAR_6 = kvm_set_ioeventfd_mmio(VAR_5, VAR_1->offset_within_address_space,\nVAR_3, true, int128_get64(VAR_1->size),\nVAR_2);",
"if (VAR_6 < 0) {",
"abort();",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
17,
19,
21
],
[
23
],
[
27
],
[
29
],
[
31
]
] |
22,246 | static void vfio_probe_rtl8168_bar2_window_quirk(VFIOPCIDevice *vdev, int nr)
{
PCIDevice *pdev = &vdev->pdev;
VFIOQuirk *quirk;
if (pci_get_word(pdev->config + PCI_VENDOR_ID) != PCI_VENDOR_ID_REALTEK ||
pci_get_word(pdev->config + PCI_DEVICE_ID) != 0x8168 || nr != 2) {
return;
}
quirk = g_malloc0(sizeof(*quirk));
quirk->vdev = vdev;
quirk->data.bar = nr;
memory_region_init_io(&quirk->mem, OBJECT(vdev), &vfio_rtl8168_window_quirk,
quirk, "vfio-rtl8168-window-quirk", 8);
memory_region_add_subregion_overlap(&vdev->bars[nr].region.mem,
0x70, &quirk->mem, 1);
QLIST_INSERT_HEAD(&vdev->bars[nr].quirks, quirk, next);
trace_vfio_probe_rtl8168_bar2_window_quirk(vdev->vbasedev.name);
}
| true | qemu | d451008e0fdf7fb817c791397e7999d5f3687e58 | static void vfio_probe_rtl8168_bar2_window_quirk(VFIOPCIDevice *vdev, int nr)
{
PCIDevice *pdev = &vdev->pdev;
VFIOQuirk *quirk;
if (pci_get_word(pdev->config + PCI_VENDOR_ID) != PCI_VENDOR_ID_REALTEK ||
pci_get_word(pdev->config + PCI_DEVICE_ID) != 0x8168 || nr != 2) {
return;
}
quirk = g_malloc0(sizeof(*quirk));
quirk->vdev = vdev;
quirk->data.bar = nr;
memory_region_init_io(&quirk->mem, OBJECT(vdev), &vfio_rtl8168_window_quirk,
quirk, "vfio-rtl8168-window-quirk", 8);
memory_region_add_subregion_overlap(&vdev->bars[nr].region.mem,
0x70, &quirk->mem, 1);
QLIST_INSERT_HEAD(&vdev->bars[nr].quirks, quirk, next);
trace_vfio_probe_rtl8168_bar2_window_quirk(vdev->vbasedev.name);
}
| {
"code": [
" trace_vfio_probe_rtl8168_bar2_window_quirk(vdev->vbasedev.name);"
],
"line_no": [
43
]
} | static void FUNC_0(VFIOPCIDevice *VAR_0, int VAR_1)
{
PCIDevice *pdev = &VAR_0->pdev;
VFIOQuirk *quirk;
if (pci_get_word(pdev->config + PCI_VENDOR_ID) != PCI_VENDOR_ID_REALTEK ||
pci_get_word(pdev->config + PCI_DEVICE_ID) != 0x8168 || VAR_1 != 2) {
return;
}
quirk = g_malloc0(sizeof(*quirk));
quirk->VAR_0 = VAR_0;
quirk->data.bar = VAR_1;
memory_region_init_io(&quirk->mem, OBJECT(VAR_0), &vfio_rtl8168_window_quirk,
quirk, "vfio-rtl8168-window-quirk", 8);
memory_region_add_subregion_overlap(&VAR_0->bars[VAR_1].region.mem,
0x70, &quirk->mem, 1);
QLIST_INSERT_HEAD(&VAR_0->bars[VAR_1].quirks, quirk, next);
trace_vfio_probe_rtl8168_bar2_window_quirk(VAR_0->vbasedev.name);
}
| [
"static void FUNC_0(VFIOPCIDevice *VAR_0, int VAR_1)\n{",
"PCIDevice *pdev = &VAR_0->pdev;",
"VFIOQuirk *quirk;",
"if (pci_get_word(pdev->config + PCI_VENDOR_ID) != PCI_VENDOR_ID_REALTEK ||\npci_get_word(pdev->config + PCI_DEVICE_ID) != 0x8168 || VAR_1 != 2) {",
"return;",
"}",
"quirk = g_malloc0(sizeof(*quirk));",
"quirk->VAR_0 = VAR_0;",
"quirk->data.bar = VAR_1;",
"memory_region_init_io(&quirk->mem, OBJECT(VAR_0), &vfio_rtl8168_window_quirk,\nquirk, \"vfio-rtl8168-window-quirk\", 8);",
"memory_region_add_subregion_overlap(&VAR_0->bars[VAR_1].region.mem,\n0x70, &quirk->mem, 1);",
"QLIST_INSERT_HEAD(&VAR_0->bars[VAR_1].quirks, quirk, next);",
"trace_vfio_probe_rtl8168_bar2_window_quirk(VAR_0->vbasedev.name);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
29,
31
],
[
33,
35
],
[
39
],
[
43
],
[
45
]
] |
22,247 | tcp_listen(Slirp *slirp, u_int32_t haddr, u_int hport, u_int32_t laddr,
u_int lport, int flags)
{
struct sockaddr_in addr;
struct socket *so;
int s, opt = 1;
socklen_t addrlen = sizeof(addr);
DEBUG_CALL("tcp_listen");
DEBUG_ARG("haddr = %x", haddr);
DEBUG_ARG("hport = %d", hport);
DEBUG_ARG("laddr = %x", laddr);
DEBUG_ARG("lport = %d", lport);
DEBUG_ARG("flags = %x", flags);
so = socreate(slirp);
if (!so) {
return NULL;
}
/* Don't tcp_attach... we don't need so_snd nor so_rcv */
if ((so->so_tcpcb = tcp_newtcpcb(so)) == NULL) {
free(so);
return NULL;
}
insque(so, &slirp->tcb);
/*
* SS_FACCEPTONCE sockets must time out.
*/
if (flags & SS_FACCEPTONCE)
so->so_tcpcb->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT*2;
so->so_state &= SS_PERSISTENT_MASK;
so->so_state |= (SS_FACCEPTCONN | flags);
so->so_lport = lport; /* Kept in network format */
so->so_laddr.s_addr = laddr; /* Ditto */
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = haddr;
addr.sin_port = hport;
if (((s = socket(AF_INET,SOCK_STREAM,0)) < 0) ||
(setsockopt(s,SOL_SOCKET,SO_REUSEADDR,(char *)&opt,sizeof(int)) < 0) ||
(bind(s,(struct sockaddr *)&addr, sizeof(addr)) < 0) ||
(listen(s,1) < 0)) {
int tmperrno = errno; /* Don't clobber the real reason we failed */
close(s);
sofree(so);
/* Restore the real errno */
#ifdef _WIN32
WSASetLastError(tmperrno);
#else
errno = tmperrno;
#endif
return NULL;
}
setsockopt(s,SOL_SOCKET,SO_OOBINLINE,(char *)&opt,sizeof(int));
getsockname(s,(struct sockaddr *)&addr,&addrlen);
so->so_fport = addr.sin_port;
if (addr.sin_addr.s_addr == 0 || addr.sin_addr.s_addr == loopback_addr.s_addr)
so->so_faddr = slirp->vhost_addr;
else
so->so_faddr = addr.sin_addr;
so->s = s;
return so;
}
| true | qemu | 40ff6d7e8dceca227e7f8a3e8e0d58b2c66d19b4 | tcp_listen(Slirp *slirp, u_int32_t haddr, u_int hport, u_int32_t laddr,
u_int lport, int flags)
{
struct sockaddr_in addr;
struct socket *so;
int s, opt = 1;
socklen_t addrlen = sizeof(addr);
DEBUG_CALL("tcp_listen");
DEBUG_ARG("haddr = %x", haddr);
DEBUG_ARG("hport = %d", hport);
DEBUG_ARG("laddr = %x", laddr);
DEBUG_ARG("lport = %d", lport);
DEBUG_ARG("flags = %x", flags);
so = socreate(slirp);
if (!so) {
return NULL;
}
if ((so->so_tcpcb = tcp_newtcpcb(so)) == NULL) {
free(so);
return NULL;
}
insque(so, &slirp->tcb);
if (flags & SS_FACCEPTONCE)
so->so_tcpcb->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT*2;
so->so_state &= SS_PERSISTENT_MASK;
so->so_state |= (SS_FACCEPTCONN | flags);
so->so_lport = lport;
so->so_laddr.s_addr = laddr;
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = haddr;
addr.sin_port = hport;
if (((s = socket(AF_INET,SOCK_STREAM,0)) < 0) ||
(setsockopt(s,SOL_SOCKET,SO_REUSEADDR,(char *)&opt,sizeof(int)) < 0) ||
(bind(s,(struct sockaddr *)&addr, sizeof(addr)) < 0) ||
(listen(s,1) < 0)) {
int tmperrno = errno;
close(s);
sofree(so);
#ifdef _WIN32
WSASetLastError(tmperrno);
#else
errno = tmperrno;
#endif
return NULL;
}
setsockopt(s,SOL_SOCKET,SO_OOBINLINE,(char *)&opt,sizeof(int));
getsockname(s,(struct sockaddr *)&addr,&addrlen);
so->so_fport = addr.sin_port;
if (addr.sin_addr.s_addr == 0 || addr.sin_addr.s_addr == loopback_addr.s_addr)
so->so_faddr = slirp->vhost_addr;
else
so->so_faddr = addr.sin_addr;
so->s = s;
return so;
}
| {
"code": [
"\tif (((s = socket(AF_INET,SOCK_STREAM,0)) < 0) ||"
],
"line_no": [
85
]
} | FUNC_0(Slirp *VAR_0, u_int32_t VAR_1, u_int VAR_2, u_int32_t VAR_3,
u_int VAR_4, int VAR_5)
{
struct sockaddr_in VAR_6;
struct socket *VAR_7;
int VAR_8, VAR_9 = 1;
socklen_t addrlen = sizeof(VAR_6);
DEBUG_CALL("FUNC_0");
DEBUG_ARG("VAR_1 = %x", VAR_1);
DEBUG_ARG("VAR_2 = %d", VAR_2);
DEBUG_ARG("VAR_3 = %x", VAR_3);
DEBUG_ARG("VAR_4 = %d", VAR_4);
DEBUG_ARG("VAR_5 = %x", VAR_5);
VAR_7 = socreate(VAR_0);
if (!VAR_7) {
return NULL;
}
if ((VAR_7->so_tcpcb = tcp_newtcpcb(VAR_7)) == NULL) {
free(VAR_7);
return NULL;
}
insque(VAR_7, &VAR_0->tcb);
if (VAR_5 & SS_FACCEPTONCE)
VAR_7->so_tcpcb->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT*2;
VAR_7->so_state &= SS_PERSISTENT_MASK;
VAR_7->so_state |= (SS_FACCEPTCONN | VAR_5);
VAR_7->so_lport = VAR_4;
VAR_7->so_laddr.s_addr = VAR_3;
VAR_6.sin_family = AF_INET;
VAR_6.sin_addr.s_addr = VAR_1;
VAR_6.sin_port = VAR_2;
if (((VAR_8 = socket(AF_INET,SOCK_STREAM,0)) < 0) ||
(setsockopt(VAR_8,SOL_SOCKET,SO_REUSEADDR,(char *)&VAR_9,sizeof(int)) < 0) ||
(bind(VAR_8,(struct sockaddr *)&VAR_6, sizeof(VAR_6)) < 0) ||
(listen(VAR_8,1) < 0)) {
int VAR_10 = errno;
close(VAR_8);
sofree(VAR_7);
#ifdef _WIN32
WSASetLastError(VAR_10);
#else
errno = VAR_10;
#endif
return NULL;
}
setsockopt(VAR_8,SOL_SOCKET,SO_OOBINLINE,(char *)&VAR_9,sizeof(int));
getsockname(VAR_8,(struct sockaddr *)&VAR_6,&addrlen);
VAR_7->so_fport = VAR_6.sin_port;
if (VAR_6.sin_addr.s_addr == 0 || VAR_6.sin_addr.s_addr == loopback_addr.s_addr)
VAR_7->so_faddr = VAR_0->vhost_addr;
else
VAR_7->so_faddr = VAR_6.sin_addr;
VAR_7->VAR_8 = VAR_8;
return VAR_7;
}
| [
"FUNC_0(Slirp *VAR_0, u_int32_t VAR_1, u_int VAR_2, u_int32_t VAR_3,\nu_int VAR_4, int VAR_5)\n{",
"struct sockaddr_in VAR_6;",
"struct socket *VAR_7;",
"int VAR_8, VAR_9 = 1;",
"socklen_t addrlen = sizeof(VAR_6);",
"DEBUG_CALL(\"FUNC_0\");",
"DEBUG_ARG(\"VAR_1 = %x\", VAR_1);",
"DEBUG_ARG(\"VAR_2 = %d\", VAR_2);",
"DEBUG_ARG(\"VAR_3 = %x\", VAR_3);",
"DEBUG_ARG(\"VAR_4 = %d\", VAR_4);",
"DEBUG_ARG(\"VAR_5 = %x\", VAR_5);",
"VAR_7 = socreate(VAR_0);",
"if (!VAR_7) {",
"return NULL;",
"}",
"if ((VAR_7->so_tcpcb = tcp_newtcpcb(VAR_7)) == NULL) {",
"free(VAR_7);",
"return NULL;",
"}",
"insque(VAR_7, &VAR_0->tcb);",
"if (VAR_5 & SS_FACCEPTONCE)\nVAR_7->so_tcpcb->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT*2;",
"VAR_7->so_state &= SS_PERSISTENT_MASK;",
"VAR_7->so_state |= (SS_FACCEPTCONN | VAR_5);",
"VAR_7->so_lport = VAR_4;",
"VAR_7->so_laddr.s_addr = VAR_3;",
"VAR_6.sin_family = AF_INET;",
"VAR_6.sin_addr.s_addr = VAR_1;",
"VAR_6.sin_port = VAR_2;",
"if (((VAR_8 = socket(AF_INET,SOCK_STREAM,0)) < 0) ||\n(setsockopt(VAR_8,SOL_SOCKET,SO_REUSEADDR,(char *)&VAR_9,sizeof(int)) < 0) ||\n(bind(VAR_8,(struct sockaddr *)&VAR_6, sizeof(VAR_6)) < 0) ||\n(listen(VAR_8,1) < 0)) {",
"int VAR_10 = errno;",
"close(VAR_8);",
"sofree(VAR_7);",
"#ifdef _WIN32\nWSASetLastError(VAR_10);",
"#else\nerrno = VAR_10;",
"#endif\nreturn NULL;",
"}",
"setsockopt(VAR_8,SOL_SOCKET,SO_OOBINLINE,(char *)&VAR_9,sizeof(int));",
"getsockname(VAR_8,(struct sockaddr *)&VAR_6,&addrlen);",
"VAR_7->so_fport = VAR_6.sin_port;",
"if (VAR_6.sin_addr.s_addr == 0 || VAR_6.sin_addr.s_addr == loopback_addr.s_addr)\nVAR_7->so_faddr = VAR_0->vhost_addr;",
"else\nVAR_7->so_faddr = VAR_6.sin_addr;",
"VAR_7->VAR_8 = VAR_8;",
"return VAR_7;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
61,
63
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
81
],
[
85,
87,
89,
91
],
[
93
],
[
97
],
[
99
],
[
103,
105
],
[
107,
109
],
[
111,
113
],
[
115
],
[
117
],
[
121
],
[
123
],
[
125,
127
],
[
129,
131
],
[
135
],
[
137
],
[
139
]
] |
22,248 | static void test_dummy_createcmdl(void)
{
QemuOpts *opts;
DummyObject *dobj;
Error *err = NULL;
const char *params = TYPE_DUMMY \
",id=dev0," \
"bv=yes,sv=Hiss hiss hiss,av=platypus";
qemu_add_opts(&qemu_object_opts);
opts = qemu_opts_parse(&qemu_object_opts, params, true, &err);
g_assert(err == NULL);
g_assert(opts);
dobj = DUMMY_OBJECT(user_creatable_add_opts(opts, &err));
g_assert(err == NULL);
g_assert(dobj);
g_assert_cmpstr(dobj->sv, ==, "Hiss hiss hiss");
g_assert(dobj->bv == true);
g_assert(dobj->av == DUMMY_PLATYPUS);
user_creatable_del("dev0", &err);
g_assert(err == NULL);
error_free(err);
/*
* cmdline-parsing via qemu_opts_parse() results in a QemuOpts entry
* corresponding to the Object's ID to be added to the QemuOptsList
* for objects. To avoid having this entry conflict with future
* Objects using the same ID (which can happen in cases where
* qemu_opts_parse() is used to parse the object params, such as
* with hmp_object_add() at the time of this comment), we need to
* check for this in user_creatable_del() and remove the QemuOpts if
* it is present.
*
* The below check ensures this works as expected.
*/
g_assert_null(qemu_opts_find(&qemu_object_opts, "dev0"));
} | true | qemu | 80792eb9257588d9a554605f3411cbc7ed51e9bc | static void test_dummy_createcmdl(void)
{
QemuOpts *opts;
DummyObject *dobj;
Error *err = NULL;
const char *params = TYPE_DUMMY \
",id=dev0," \
"bv=yes,sv=Hiss hiss hiss,av=platypus";
qemu_add_opts(&qemu_object_opts);
opts = qemu_opts_parse(&qemu_object_opts, params, true, &err);
g_assert(err == NULL);
g_assert(opts);
dobj = DUMMY_OBJECT(user_creatable_add_opts(opts, &err));
g_assert(err == NULL);
g_assert(dobj);
g_assert_cmpstr(dobj->sv, ==, "Hiss hiss hiss");
g_assert(dobj->bv == true);
g_assert(dobj->av == DUMMY_PLATYPUS);
user_creatable_del("dev0", &err);
g_assert(err == NULL);
error_free(err);
g_assert_null(qemu_opts_find(&qemu_object_opts, "dev0"));
} | {
"code": [],
"line_no": []
} | static void FUNC_0(void)
{
QemuOpts *opts;
DummyObject *dobj;
Error *err = NULL;
const char *VAR_0 = TYPE_DUMMY \
",id=dev0," \
"bv=yes,sv=Hiss hiss hiss,av=platypus";
qemu_add_opts(&qemu_object_opts);
opts = qemu_opts_parse(&qemu_object_opts, VAR_0, true, &err);
g_assert(err == NULL);
g_assert(opts);
dobj = DUMMY_OBJECT(user_creatable_add_opts(opts, &err));
g_assert(err == NULL);
g_assert(dobj);
g_assert_cmpstr(dobj->sv, ==, "Hiss hiss hiss");
g_assert(dobj->bv == true);
g_assert(dobj->av == DUMMY_PLATYPUS);
user_creatable_del("dev0", &err);
g_assert(err == NULL);
error_free(err);
g_assert_null(qemu_opts_find(&qemu_object_opts, "dev0"));
} | [
"static void FUNC_0(void)\n{",
"QemuOpts *opts;",
"DummyObject *dobj;",
"Error *err = NULL;",
"const char *VAR_0 = TYPE_DUMMY \\\n\",id=dev0,\" \\\n\"bv=yes,sv=Hiss hiss hiss,av=platypus\";",
"qemu_add_opts(&qemu_object_opts);",
"opts = qemu_opts_parse(&qemu_object_opts, VAR_0, true, &err);",
"g_assert(err == NULL);",
"g_assert(opts);",
"dobj = DUMMY_OBJECT(user_creatable_add_opts(opts, &err));",
"g_assert(err == NULL);",
"g_assert(dobj);",
"g_assert_cmpstr(dobj->sv, ==, \"Hiss hiss hiss\");",
"g_assert(dobj->bv == true);",
"g_assert(dobj->av == DUMMY_PLATYPUS);",
"user_creatable_del(\"dev0\", &err);",
"g_assert(err == NULL);",
"error_free(err);",
"g_assert_null(qemu_opts_find(&qemu_object_opts, \"dev0\"));",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
2
],
[
3
],
[
4
],
[
5
],
[
6,
7,
8
],
[
9
],
[
10
],
[
11
],
[
12
],
[
13
],
[
14
],
[
15
],
[
16
],
[
17
],
[
18
],
[
19
],
[
20
],
[
21
],
[
34
],
[
35
]
] |
22,249 | static int thp_read_packet(AVFormatContext *s,
AVPacket *pkt)
{
ThpDemuxContext *thp = s->priv_data;
AVIOContext *pb = s->pb;
unsigned int size;
int ret;
if (thp->audiosize == 0) {
/* Terminate when last frame is reached. */
if (thp->frame >= thp->framecnt)
return AVERROR_EOF;
avio_seek(pb, thp->next_frame, SEEK_SET);
/* Locate the next frame and read out its size. */
thp->next_frame += FFMAX(thp->next_framesz, 1);
thp->next_framesz = avio_rb32(pb);
avio_rb32(pb); /* Previous total size. */
size = avio_rb32(pb); /* Total size of this frame. */
/* Store the audiosize so the next time this function is called,
the audio can be read. */
if (thp->has_audio)
thp->audiosize = avio_rb32(pb); /* Audio size. */
else
thp->frame++;
ret = av_get_packet(pb, pkt, size);
if (ret != size) {
av_free_packet(pkt);
return AVERROR(EIO);
}
pkt->stream_index = thp->video_stream_index;
} else {
ret = av_get_packet(pb, pkt, thp->audiosize);
if (ret != thp->audiosize) {
av_free_packet(pkt);
return AVERROR(EIO);
}
pkt->stream_index = thp->audio_stream_index;
if (thp->audiosize >= 8)
pkt->duration = AV_RB32(&pkt->data[4]);
thp->audiosize = 0;
thp->frame++;
}
return 0;
} | true | FFmpeg | dc3c3758ce6368aa2f0a9a9b544bce2e130cc4e1 | static int thp_read_packet(AVFormatContext *s,
AVPacket *pkt)
{
ThpDemuxContext *thp = s->priv_data;
AVIOContext *pb = s->pb;
unsigned int size;
int ret;
if (thp->audiosize == 0) {
if (thp->frame >= thp->framecnt)
return AVERROR_EOF;
avio_seek(pb, thp->next_frame, SEEK_SET);
thp->next_frame += FFMAX(thp->next_framesz, 1);
thp->next_framesz = avio_rb32(pb);
avio_rb32(pb);
size = avio_rb32(pb);
if (thp->has_audio)
thp->audiosize = avio_rb32(pb);
else
thp->frame++;
ret = av_get_packet(pb, pkt, size);
if (ret != size) {
av_free_packet(pkt);
return AVERROR(EIO);
}
pkt->stream_index = thp->video_stream_index;
} else {
ret = av_get_packet(pb, pkt, thp->audiosize);
if (ret != thp->audiosize) {
av_free_packet(pkt);
return AVERROR(EIO);
}
pkt->stream_index = thp->audio_stream_index;
if (thp->audiosize >= 8)
pkt->duration = AV_RB32(&pkt->data[4]);
thp->audiosize = 0;
thp->frame++;
}
return 0;
} | {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0,
AVPacket *VAR_1)
{
ThpDemuxContext *thp = VAR_0->priv_data;
AVIOContext *pb = VAR_0->pb;
unsigned int VAR_2;
int VAR_3;
if (thp->audiosize == 0) {
if (thp->frame >= thp->framecnt)
return AVERROR_EOF;
avio_seek(pb, thp->next_frame, SEEK_SET);
thp->next_frame += FFMAX(thp->next_framesz, 1);
thp->next_framesz = avio_rb32(pb);
avio_rb32(pb);
VAR_2 = avio_rb32(pb);
if (thp->has_audio)
thp->audiosize = avio_rb32(pb);
else
thp->frame++;
VAR_3 = av_get_packet(pb, VAR_1, VAR_2);
if (VAR_3 != VAR_2) {
av_free_packet(VAR_1);
return AVERROR(EIO);
}
VAR_1->stream_index = thp->video_stream_index;
} else {
VAR_3 = av_get_packet(pb, VAR_1, thp->audiosize);
if (VAR_3 != thp->audiosize) {
av_free_packet(VAR_1);
return AVERROR(EIO);
}
VAR_1->stream_index = thp->audio_stream_index;
if (thp->audiosize >= 8)
VAR_1->duration = AV_RB32(&VAR_1->data[4]);
thp->audiosize = 0;
thp->frame++;
}
return 0;
} | [
"static int FUNC_0(AVFormatContext *VAR_0,\nAVPacket *VAR_1)\n{",
"ThpDemuxContext *thp = VAR_0->priv_data;",
"AVIOContext *pb = VAR_0->pb;",
"unsigned int VAR_2;",
"int VAR_3;",
"if (thp->audiosize == 0) {",
"if (thp->frame >= thp->framecnt)\nreturn AVERROR_EOF;",
"avio_seek(pb, thp->next_frame, SEEK_SET);",
"thp->next_frame += FFMAX(thp->next_framesz, 1);",
"thp->next_framesz = avio_rb32(pb);",
"avio_rb32(pb);",
"VAR_2 = avio_rb32(pb);",
"if (thp->has_audio)\nthp->audiosize = avio_rb32(pb);",
"else\nthp->frame++;",
"VAR_3 = av_get_packet(pb, VAR_1, VAR_2);",
"if (VAR_3 != VAR_2) {",
"av_free_packet(VAR_1);",
"return AVERROR(EIO);",
"}",
"VAR_1->stream_index = thp->video_stream_index;",
"} else {",
"VAR_3 = av_get_packet(pb, VAR_1, thp->audiosize);",
"if (VAR_3 != thp->audiosize) {",
"av_free_packet(VAR_1);",
"return AVERROR(EIO);",
"}",
"VAR_1->stream_index = thp->audio_stream_index;",
"if (thp->audiosize >= 8)\nVAR_1->duration = AV_RB32(&VAR_1->data[4]);",
"thp->audiosize = 0;",
"thp->frame++;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
21,
23
],
[
27
],
[
33
],
[
35
],
[
39
],
[
41
],
[
49,
51
],
[
53,
55
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
77
],
[
81
],
[
83
],
[
85
],
[
87
],
[
91
],
[
93,
95
],
[
99
],
[
101
],
[
103
],
[
107
],
[
109
]
] |
22,251 | static int RENAME(resample_common)(ResampleContext *c,
DELEM *dst, const DELEM *src,
int n, int update_ctx)
{
int dst_index;
int index= c->index;
int frac= c->frac;
int sample_index = index >> c->phase_shift;
index &= c->phase_mask;
for (dst_index = 0; dst_index < n; dst_index++) {
FELEM *filter = ((FELEM *) c->filter_bank) + c->filter_alloc * index;
FELEM2 val=0;
int i;
for (i = 0; i < c->filter_length; i++) {
val += src[sample_index + i] * (FELEM2)filter[i];
}
OUT(dst[dst_index], val);
frac += c->dst_incr_mod;
index += c->dst_incr_div;
if (frac >= c->src_incr) {
frac -= c->src_incr;
index++;
}
sample_index += index >> c->phase_shift;
index &= c->phase_mask;
}
if(update_ctx){
c->frac= frac;
c->index= index;
}
return sample_index;
}
| false | FFmpeg | 857cd1f33bcf86005529af2a77f861f884327be5 | static int RENAME(resample_common)(ResampleContext *c,
DELEM *dst, const DELEM *src,
int n, int update_ctx)
{
int dst_index;
int index= c->index;
int frac= c->frac;
int sample_index = index >> c->phase_shift;
index &= c->phase_mask;
for (dst_index = 0; dst_index < n; dst_index++) {
FELEM *filter = ((FELEM *) c->filter_bank) + c->filter_alloc * index;
FELEM2 val=0;
int i;
for (i = 0; i < c->filter_length; i++) {
val += src[sample_index + i] * (FELEM2)filter[i];
}
OUT(dst[dst_index], val);
frac += c->dst_incr_mod;
index += c->dst_incr_div;
if (frac >= c->src_incr) {
frac -= c->src_incr;
index++;
}
sample_index += index >> c->phase_shift;
index &= c->phase_mask;
}
if(update_ctx){
c->frac= frac;
c->index= index;
}
return sample_index;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(resample_common)(ResampleContext *c,
DELEM *dst, const DELEM *src,
int n, int update_ctx)
{
int VAR_0;
int VAR_1= c->VAR_1;
int VAR_2= c->VAR_2;
int VAR_3 = VAR_1 >> c->phase_shift;
VAR_1 &= c->phase_mask;
for (VAR_0 = 0; VAR_0 < n; VAR_0++) {
FELEM *filter = ((FELEM *) c->filter_bank) + c->filter_alloc * VAR_1;
FELEM2 val=0;
int i;
for (i = 0; i < c->filter_length; i++) {
val += src[VAR_3 + i] * (FELEM2)filter[i];
}
OUT(dst[VAR_0], val);
VAR_2 += c->dst_incr_mod;
VAR_1 += c->dst_incr_div;
if (VAR_2 >= c->src_incr) {
VAR_2 -= c->src_incr;
VAR_1++;
}
VAR_3 += VAR_1 >> c->phase_shift;
VAR_1 &= c->phase_mask;
}
if(update_ctx){
c->VAR_2= VAR_2;
c->VAR_1= VAR_1;
}
return VAR_3;
}
| [
"static int FUNC_0(resample_common)(ResampleContext *c,\nDELEM *dst, const DELEM *src,\nint n, int update_ctx)\n{",
"int VAR_0;",
"int VAR_1= c->VAR_1;",
"int VAR_2= c->VAR_2;",
"int VAR_3 = VAR_1 >> c->phase_shift;",
"VAR_1 &= c->phase_mask;",
"for (VAR_0 = 0; VAR_0 < n; VAR_0++) {",
"FELEM *filter = ((FELEM *) c->filter_bank) + c->filter_alloc * VAR_1;",
"FELEM2 val=0;",
"int i;",
"for (i = 0; i < c->filter_length; i++) {",
"val += src[VAR_3 + i] * (FELEM2)filter[i];",
"}",
"OUT(dst[VAR_0], val);",
"VAR_2 += c->dst_incr_mod;",
"VAR_1 += c->dst_incr_div;",
"if (VAR_2 >= c->src_incr) {",
"VAR_2 -= c->src_incr;",
"VAR_1++;",
"}",
"VAR_3 += VAR_1 >> c->phase_shift;",
"VAR_1 &= c->phase_mask;",
"}",
"if(update_ctx){",
"c->VAR_2= VAR_2;",
"c->VAR_1= VAR_1;",
"}",
"return VAR_3;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
]
] |
22,252 | static int send_status(int sockfd, struct iovec *iovec, int status)
{
ProxyHeader header;
int retval, msg_size;
if (status < 0) {
header.type = T_ERROR;
} else {
header.type = T_SUCCESS;
header.size = sizeof(status);
/*
* marshal the return status. We don't check error.
* because we are sure we have enough space for the status
*/
msg_size = proxy_marshal(iovec, 0, "ddd", header.type,
header.size, status);
retval = socket_write(sockfd, iovec->iov_base, msg_size);
if (retval < 0) {
return retval;
return 0;
| true | qemu | 821c447675728ca06c8d2e4ac8a0e7a1adf775b8 | static int send_status(int sockfd, struct iovec *iovec, int status)
{
ProxyHeader header;
int retval, msg_size;
if (status < 0) {
header.type = T_ERROR;
} else {
header.type = T_SUCCESS;
header.size = sizeof(status);
msg_size = proxy_marshal(iovec, 0, "ddd", header.type,
header.size, status);
retval = socket_write(sockfd, iovec->iov_base, msg_size);
if (retval < 0) {
return retval;
return 0;
| {
"code": [],
"line_no": []
} | static int FUNC_0(int VAR_0, struct VAR_1 *VAR_1, int VAR_2)
{
ProxyHeader header;
int VAR_3, VAR_4;
if (VAR_2 < 0) {
header.type = T_ERROR;
} else {
header.type = T_SUCCESS;
header.size = sizeof(VAR_2);
VAR_4 = proxy_marshal(VAR_1, 0, "ddd", header.type,
header.size, VAR_2);
VAR_3 = socket_write(VAR_0, VAR_1->iov_base, VAR_4);
if (VAR_3 < 0) {
return VAR_3;
return 0;
| [
"static int FUNC_0(int VAR_0, struct VAR_1 *VAR_1, int VAR_2)\n{",
"ProxyHeader header;",
"int VAR_3, VAR_4;",
"if (VAR_2 < 0) {",
"header.type = T_ERROR;",
"} else {",
"header.type = T_SUCCESS;",
"header.size = sizeof(VAR_2);",
"VAR_4 = proxy_marshal(VAR_1, 0, \"ddd\", header.type,\nheader.size, VAR_2);",
"VAR_3 = socket_write(VAR_0, VAR_1->iov_base, VAR_4);",
"if (VAR_3 < 0) {",
"return VAR_3;",
"return 0;"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
20
],
[
30,
32
],
[
37
],
[
39
],
[
41
],
[
44
]
] |
22,253 | int av_image_fill_pointers(uint8_t *data[4], enum PixelFormat pix_fmt, int height,
uint8_t *ptr, const int linesizes[4])
{
int i, total_size, size[4], has_plane[4];
const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt];
memset(data , 0, sizeof(data[0])*4);
memset(size , 0, sizeof(size));
memset(has_plane, 0, sizeof(has_plane));
if ((unsigned)pix_fmt >= PIX_FMT_NB || desc->flags & PIX_FMT_HWACCEL)
return AVERROR(EINVAL);
data[0] = ptr;
if (linesizes[0] > (INT_MAX - 1024) / height)
return AVERROR(EINVAL);
size[0] = linesizes[0] * height;
if (desc->flags & PIX_FMT_PAL) {
size[0] = (size[0] + 3) & ~3;
data[1] = ptr + size[0]; /* palette is stored here as 256 32 bits words */
return size[0] + 256 * 4;
}
for (i = 0; i < 4; i++)
has_plane[desc->comp[i].plane] = 1;
total_size = size[0];
for (i = 1; i < 4 && has_plane[i]; i++) {
int h, s = (i == 1 || i == 2) ? desc->log2_chroma_h : 0;
data[i] = data[i-1] + size[i-1];
h = (height + (1 << s) - 1) >> s;
if (linesizes[i] > INT_MAX / h)
return AVERROR(EINVAL);
size[i] = h * linesizes[i];
if (total_size > INT_MAX - size[i])
return AVERROR(EINVAL);
total_size += size[i];
}
return total_size;
}
| true | FFmpeg | 38d553322891c8e47182f05199d19888422167dc | int av_image_fill_pointers(uint8_t *data[4], enum PixelFormat pix_fmt, int height,
uint8_t *ptr, const int linesizes[4])
{
int i, total_size, size[4], has_plane[4];
const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt];
memset(data , 0, sizeof(data[0])*4);
memset(size , 0, sizeof(size));
memset(has_plane, 0, sizeof(has_plane));
if ((unsigned)pix_fmt >= PIX_FMT_NB || desc->flags & PIX_FMT_HWACCEL)
return AVERROR(EINVAL);
data[0] = ptr;
if (linesizes[0] > (INT_MAX - 1024) / height)
return AVERROR(EINVAL);
size[0] = linesizes[0] * height;
if (desc->flags & PIX_FMT_PAL) {
size[0] = (size[0] + 3) & ~3;
data[1] = ptr + size[0];
return size[0] + 256 * 4;
}
for (i = 0; i < 4; i++)
has_plane[desc->comp[i].plane] = 1;
total_size = size[0];
for (i = 1; i < 4 && has_plane[i]; i++) {
int h, s = (i == 1 || i == 2) ? desc->log2_chroma_h : 0;
data[i] = data[i-1] + size[i-1];
h = (height + (1 << s) - 1) >> s;
if (linesizes[i] > INT_MAX / h)
return AVERROR(EINVAL);
size[i] = h * linesizes[i];
if (total_size > INT_MAX - size[i])
return AVERROR(EINVAL);
total_size += size[i];
}
return total_size;
}
| {
"code": [
" if (desc->flags & PIX_FMT_PAL) {",
" if (desc->flags & PIX_FMT_PAL) {"
],
"line_no": [
37,
37
]
} | int FUNC_0(uint8_t *VAR_0[4], enum PixelFormat VAR_1, int VAR_2,
uint8_t *VAR_3, const int VAR_4[4])
{
int VAR_5, VAR_6, VAR_7[4], VAR_8[4];
const AVPixFmtDescriptor *VAR_9 = &av_pix_fmt_descriptors[VAR_1];
memset(VAR_0 , 0, sizeof(VAR_0[0])*4);
memset(VAR_7 , 0, sizeof(VAR_7));
memset(VAR_8, 0, sizeof(VAR_8));
if ((unsigned)VAR_1 >= PIX_FMT_NB || VAR_9->flags & PIX_FMT_HWACCEL)
return AVERROR(EINVAL);
VAR_0[0] = VAR_3;
if (VAR_4[0] > (INT_MAX - 1024) / VAR_2)
return AVERROR(EINVAL);
VAR_7[0] = VAR_4[0] * VAR_2;
if (VAR_9->flags & PIX_FMT_PAL) {
VAR_7[0] = (VAR_7[0] + 3) & ~3;
VAR_0[1] = VAR_3 + VAR_7[0];
return VAR_7[0] + 256 * 4;
}
for (VAR_5 = 0; VAR_5 < 4; VAR_5++)
VAR_8[VAR_9->comp[VAR_5].plane] = 1;
VAR_6 = VAR_7[0];
for (VAR_5 = 1; VAR_5 < 4 && VAR_8[VAR_5]; VAR_5++) {
int VAR_10, VAR_11 = (VAR_5 == 1 || VAR_5 == 2) ? VAR_9->log2_chroma_h : 0;
VAR_0[VAR_5] = VAR_0[VAR_5-1] + VAR_7[VAR_5-1];
VAR_10 = (VAR_2 + (1 << VAR_11) - 1) >> VAR_11;
if (VAR_4[VAR_5] > INT_MAX / VAR_10)
return AVERROR(EINVAL);
VAR_7[VAR_5] = VAR_10 * VAR_4[VAR_5];
if (VAR_6 > INT_MAX - VAR_7[VAR_5])
return AVERROR(EINVAL);
VAR_6 += VAR_7[VAR_5];
}
return VAR_6;
}
| [
"int FUNC_0(uint8_t *VAR_0[4], enum PixelFormat VAR_1, int VAR_2,\nuint8_t *VAR_3, const int VAR_4[4])\n{",
"int VAR_5, VAR_6, VAR_7[4], VAR_8[4];",
"const AVPixFmtDescriptor *VAR_9 = &av_pix_fmt_descriptors[VAR_1];",
"memset(VAR_0 , 0, sizeof(VAR_0[0])*4);",
"memset(VAR_7 , 0, sizeof(VAR_7));",
"memset(VAR_8, 0, sizeof(VAR_8));",
"if ((unsigned)VAR_1 >= PIX_FMT_NB || VAR_9->flags & PIX_FMT_HWACCEL)\nreturn AVERROR(EINVAL);",
"VAR_0[0] = VAR_3;",
"if (VAR_4[0] > (INT_MAX - 1024) / VAR_2)\nreturn AVERROR(EINVAL);",
"VAR_7[0] = VAR_4[0] * VAR_2;",
"if (VAR_9->flags & PIX_FMT_PAL) {",
"VAR_7[0] = (VAR_7[0] + 3) & ~3;",
"VAR_0[1] = VAR_3 + VAR_7[0];",
"return VAR_7[0] + 256 * 4;",
"}",
"for (VAR_5 = 0; VAR_5 < 4; VAR_5++)",
"VAR_8[VAR_9->comp[VAR_5].plane] = 1;",
"VAR_6 = VAR_7[0];",
"for (VAR_5 = 1; VAR_5 < 4 && VAR_8[VAR_5]; VAR_5++) {",
"int VAR_10, VAR_11 = (VAR_5 == 1 || VAR_5 == 2) ? VAR_9->log2_chroma_h : 0;",
"VAR_0[VAR_5] = VAR_0[VAR_5-1] + VAR_7[VAR_5-1];",
"VAR_10 = (VAR_2 + (1 << VAR_11) - 1) >> VAR_11;",
"if (VAR_4[VAR_5] > INT_MAX / VAR_10)\nreturn AVERROR(EINVAL);",
"VAR_7[VAR_5] = VAR_10 * VAR_4[VAR_5];",
"if (VAR_6 > INT_MAX - VAR_7[VAR_5])\nreturn AVERROR(EINVAL);",
"VAR_6 += VAR_7[VAR_5];",
"}",
"return VAR_6;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21,
23
],
[
27
],
[
29,
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65,
67
],
[
69
],
[
71,
73
],
[
75
],
[
77
],
[
81
],
[
83
]
] |
22,254 | int64_t qmp_query_migrate_cache_size(Error **errp)
{
return migrate_xbzrle_cache_size();
}
| true | qemu | 60fe637bf0e4d7989e21e50f52526444765c63b4 | int64_t qmp_query_migrate_cache_size(Error **errp)
{
return migrate_xbzrle_cache_size();
}
| {
"code": [],
"line_no": []
} | int64_t FUNC_0(Error **errp)
{
return migrate_xbzrle_cache_size();
}
| [
"int64_t FUNC_0(Error **errp)\n{",
"return migrate_xbzrle_cache_size();",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
22,255 | av_cold int MPV_common_init(MpegEncContext *s)
{
int y_size, c_size, yc_size, i, mb_array_size, mv_table_size, x, y, threads;
if(s->codec_id == CODEC_ID_MPEG2VIDEO && !s->progressive_sequence)
s->mb_height = (s->height + 31) / 32 * 2;
else
s->mb_height = (s->height + 15) / 16;
if(s->avctx->pix_fmt == PIX_FMT_NONE){
av_log(s->avctx, AV_LOG_ERROR, "decoding to PIX_FMT_NONE is not supported.\n");
return -1;
}
if(s->avctx->thread_count > MAX_THREADS || (s->avctx->thread_count > s->mb_height && s->mb_height)){
av_log(s->avctx, AV_LOG_ERROR, "too many threads\n");
return -1;
}
if((s->width || s->height) && avcodec_check_dimensions(s->avctx, s->width, s->height))
return -1;
dsputil_init(&s->dsp, s->avctx);
ff_dct_common_init(s);
s->flags= s->avctx->flags;
s->flags2= s->avctx->flags2;
s->mb_width = (s->width + 15) / 16;
s->mb_stride = s->mb_width + 1;
s->b8_stride = s->mb_width*2 + 1;
s->b4_stride = s->mb_width*4 + 1;
mb_array_size= s->mb_height * s->mb_stride;
mv_table_size= (s->mb_height+2) * s->mb_stride + 1;
/* set chroma shifts */
avcodec_get_chroma_sub_sample(s->avctx->pix_fmt,&(s->chroma_x_shift),
&(s->chroma_y_shift) );
/* set default edge pos, will be overriden in decode_header if needed */
s->h_edge_pos= s->mb_width*16;
s->v_edge_pos= s->mb_height*16;
s->mb_num = s->mb_width * s->mb_height;
s->block_wrap[0]=
s->block_wrap[1]=
s->block_wrap[2]=
s->block_wrap[3]= s->b8_stride;
s->block_wrap[4]=
s->block_wrap[5]= s->mb_stride;
y_size = s->b8_stride * (2 * s->mb_height + 1);
c_size = s->mb_stride * (s->mb_height + 1);
yc_size = y_size + 2 * c_size;
/* convert fourcc to upper case */
s->codec_tag = ff_toupper4(s->avctx->codec_tag);
s->stream_codec_tag = ff_toupper4(s->avctx->stream_codec_tag);
s->avctx->coded_frame= (AVFrame*)&s->current_picture;
FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_index2xy, (s->mb_num+1)*sizeof(int), fail) //error ressilience code looks cleaner with this
for(y=0; y<s->mb_height; y++){
for(x=0; x<s->mb_width; x++){
s->mb_index2xy[ x + y*s->mb_width ] = x + y*s->mb_stride;
}
}
s->mb_index2xy[ s->mb_height*s->mb_width ] = (s->mb_height-1)*s->mb_stride + s->mb_width; //FIXME really needed?
if (s->encoding) {
/* Allocate MV tables */
FF_ALLOCZ_OR_GOTO(s->avctx, s->p_mv_table_base , mv_table_size * 2 * sizeof(int16_t), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->b_forw_mv_table_base , mv_table_size * 2 * sizeof(int16_t), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->b_back_mv_table_base , mv_table_size * 2 * sizeof(int16_t), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_forw_mv_table_base , mv_table_size * 2 * sizeof(int16_t), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_back_mv_table_base , mv_table_size * 2 * sizeof(int16_t), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->b_direct_mv_table_base , mv_table_size * 2 * sizeof(int16_t), fail)
s->p_mv_table = s->p_mv_table_base + s->mb_stride + 1;
s->b_forw_mv_table = s->b_forw_mv_table_base + s->mb_stride + 1;
s->b_back_mv_table = s->b_back_mv_table_base + s->mb_stride + 1;
s->b_bidir_forw_mv_table= s->b_bidir_forw_mv_table_base + s->mb_stride + 1;
s->b_bidir_back_mv_table= s->b_bidir_back_mv_table_base + s->mb_stride + 1;
s->b_direct_mv_table = s->b_direct_mv_table_base + s->mb_stride + 1;
if(s->msmpeg4_version){
FF_ALLOCZ_OR_GOTO(s->avctx, s->ac_stats, 2*2*(MAX_LEVEL+1)*(MAX_RUN+1)*2*sizeof(int), fail);
}
FF_ALLOCZ_OR_GOTO(s->avctx, s->avctx->stats_out, 256, fail);
/* Allocate MB type table */
FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_type , mb_array_size * sizeof(uint16_t), fail) //needed for encoding
FF_ALLOCZ_OR_GOTO(s->avctx, s->lambda_table, mb_array_size * sizeof(int), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->q_intra_matrix , 64*32 * sizeof(int), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->q_inter_matrix , 64*32 * sizeof(int), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->q_intra_matrix16, 64*32*2 * sizeof(uint16_t), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->q_inter_matrix16, 64*32*2 * sizeof(uint16_t), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->input_picture, MAX_PICTURE_COUNT * sizeof(Picture*), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->reordered_input_picture, MAX_PICTURE_COUNT * sizeof(Picture*), fail)
if(s->avctx->noise_reduction){
FF_ALLOCZ_OR_GOTO(s->avctx, s->dct_offset, 2 * 64 * sizeof(uint16_t), fail)
}
}
FF_ALLOCZ_OR_GOTO(s->avctx, s->picture, MAX_PICTURE_COUNT * sizeof(Picture), fail)
for(i = 0; i < MAX_PICTURE_COUNT; i++) {
avcodec_get_frame_defaults((AVFrame *)&s->picture[i]);
}
FF_ALLOCZ_OR_GOTO(s->avctx, s->error_status_table, mb_array_size*sizeof(uint8_t), fail)
if(s->codec_id==CODEC_ID_MPEG4 || (s->flags & CODEC_FLAG_INTERLACED_ME)){
/* interlaced direct mode decoding tables */
for(i=0; i<2; i++){
int j, k;
for(j=0; j<2; j++){
for(k=0; k<2; k++){
FF_ALLOCZ_OR_GOTO(s->avctx, s->b_field_mv_table_base[i][j][k], mv_table_size * 2 * sizeof(int16_t), fail)
s->b_field_mv_table[i][j][k] = s->b_field_mv_table_base[i][j][k] + s->mb_stride + 1;
}
FF_ALLOCZ_OR_GOTO(s->avctx, s->b_field_select_table [i][j], mb_array_size * 2 * sizeof(uint8_t), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->p_field_mv_table_base[i][j], mv_table_size * 2 * sizeof(int16_t), fail)
s->p_field_mv_table[i][j] = s->p_field_mv_table_base[i][j]+ s->mb_stride + 1;
}
FF_ALLOCZ_OR_GOTO(s->avctx, s->p_field_select_table[i], mb_array_size * 2 * sizeof(uint8_t), fail)
}
}
if (s->out_format == FMT_H263) {
/* ac values */
FF_ALLOCZ_OR_GOTO(s->avctx, s->ac_val_base, yc_size * sizeof(int16_t) * 16, fail);
s->ac_val[0] = s->ac_val_base + s->b8_stride + 1;
s->ac_val[1] = s->ac_val_base + y_size + s->mb_stride + 1;
s->ac_val[2] = s->ac_val[1] + c_size;
/* cbp values */
FF_ALLOCZ_OR_GOTO(s->avctx, s->coded_block_base, y_size, fail);
s->coded_block= s->coded_block_base + s->b8_stride + 1;
/* cbp, ac_pred, pred_dir */
FF_ALLOCZ_OR_GOTO(s->avctx, s->cbp_table , mb_array_size * sizeof(uint8_t), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->pred_dir_table, mb_array_size * sizeof(uint8_t), fail)
}
if (s->h263_pred || s->h263_plus || !s->encoding) {
/* dc values */
//MN: we need these for error resilience of intra-frames
FF_ALLOCZ_OR_GOTO(s->avctx, s->dc_val_base, yc_size * sizeof(int16_t), fail);
s->dc_val[0] = s->dc_val_base + s->b8_stride + 1;
s->dc_val[1] = s->dc_val_base + y_size + s->mb_stride + 1;
s->dc_val[2] = s->dc_val[1] + c_size;
for(i=0;i<yc_size;i++)
s->dc_val_base[i] = 1024;
}
/* which mb is a intra block */
FF_ALLOCZ_OR_GOTO(s->avctx, s->mbintra_table, mb_array_size, fail);
memset(s->mbintra_table, 1, mb_array_size);
/* init macroblock skip table */
FF_ALLOCZ_OR_GOTO(s->avctx, s->mbskip_table, mb_array_size+2, fail);
//Note the +1 is for a quicker mpeg4 slice_end detection
FF_ALLOCZ_OR_GOTO(s->avctx, s->prev_pict_types, PREV_PICT_TYPES_BUFFER_SIZE, fail);
s->parse_context.state= -1;
if((s->avctx->debug&(FF_DEBUG_VIS_QP|FF_DEBUG_VIS_MB_TYPE)) || (s->avctx->debug_mv)){
s->visualization_buffer[0] = av_malloc((s->mb_width*16 + 2*EDGE_WIDTH) * s->mb_height*16 + 2*EDGE_WIDTH);
s->visualization_buffer[1] = av_malloc((s->mb_width*16 + 2*EDGE_WIDTH) * s->mb_height*16 + 2*EDGE_WIDTH);
s->visualization_buffer[2] = av_malloc((s->mb_width*16 + 2*EDGE_WIDTH) * s->mb_height*16 + 2*EDGE_WIDTH);
}
s->context_initialized = 1;
s->thread_context[0]= s;
threads = s->avctx->thread_count;
for(i=1; i<threads; i++){
s->thread_context[i]= av_malloc(sizeof(MpegEncContext));
memcpy(s->thread_context[i], s, sizeof(MpegEncContext));
}
for(i=0; i<threads; i++){
if(init_duplicate_context(s->thread_context[i], s) < 0)
goto fail;
s->thread_context[i]->start_mb_y= (s->mb_height*(i ) + s->avctx->thread_count/2) / s->avctx->thread_count;
s->thread_context[i]->end_mb_y = (s->mb_height*(i+1) + s->avctx->thread_count/2) / s->avctx->thread_count;
}
return 0;
fail:
MPV_common_end(s);
return -1;
}
| true | FFmpeg | 79042a6eb150e5d80a0e7bf242d9945d1246703b | av_cold int MPV_common_init(MpegEncContext *s)
{
int y_size, c_size, yc_size, i, mb_array_size, mv_table_size, x, y, threads;
if(s->codec_id == CODEC_ID_MPEG2VIDEO && !s->progressive_sequence)
s->mb_height = (s->height + 31) / 32 * 2;
else
s->mb_height = (s->height + 15) / 16;
if(s->avctx->pix_fmt == PIX_FMT_NONE){
av_log(s->avctx, AV_LOG_ERROR, "decoding to PIX_FMT_NONE is not supported.\n");
return -1;
}
if(s->avctx->thread_count > MAX_THREADS || (s->avctx->thread_count > s->mb_height && s->mb_height)){
av_log(s->avctx, AV_LOG_ERROR, "too many threads\n");
return -1;
}
if((s->width || s->height) && avcodec_check_dimensions(s->avctx, s->width, s->height))
return -1;
dsputil_init(&s->dsp, s->avctx);
ff_dct_common_init(s);
s->flags= s->avctx->flags;
s->flags2= s->avctx->flags2;
s->mb_width = (s->width + 15) / 16;
s->mb_stride = s->mb_width + 1;
s->b8_stride = s->mb_width*2 + 1;
s->b4_stride = s->mb_width*4 + 1;
mb_array_size= s->mb_height * s->mb_stride;
mv_table_size= (s->mb_height+2) * s->mb_stride + 1;
avcodec_get_chroma_sub_sample(s->avctx->pix_fmt,&(s->chroma_x_shift),
&(s->chroma_y_shift) );
s->h_edge_pos= s->mb_width*16;
s->v_edge_pos= s->mb_height*16;
s->mb_num = s->mb_width * s->mb_height;
s->block_wrap[0]=
s->block_wrap[1]=
s->block_wrap[2]=
s->block_wrap[3]= s->b8_stride;
s->block_wrap[4]=
s->block_wrap[5]= s->mb_stride;
y_size = s->b8_stride * (2 * s->mb_height + 1);
c_size = s->mb_stride * (s->mb_height + 1);
yc_size = y_size + 2 * c_size;
s->codec_tag = ff_toupper4(s->avctx->codec_tag);
s->stream_codec_tag = ff_toupper4(s->avctx->stream_codec_tag);
s->avctx->coded_frame= (AVFrame*)&s->current_picture;
FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_index2xy, (s->mb_num+1)*sizeof(int), fail)
for(y=0; y<s->mb_height; y++){
for(x=0; x<s->mb_width; x++){
s->mb_index2xy[ x + y*s->mb_width ] = x + y*s->mb_stride;
}
}
s->mb_index2xy[ s->mb_height*s->mb_width ] = (s->mb_height-1)*s->mb_stride + s->mb_width;
if (s->encoding) {
FF_ALLOCZ_OR_GOTO(s->avctx, s->p_mv_table_base , mv_table_size * 2 * sizeof(int16_t), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->b_forw_mv_table_base , mv_table_size * 2 * sizeof(int16_t), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->b_back_mv_table_base , mv_table_size * 2 * sizeof(int16_t), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_forw_mv_table_base , mv_table_size * 2 * sizeof(int16_t), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_back_mv_table_base , mv_table_size * 2 * sizeof(int16_t), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->b_direct_mv_table_base , mv_table_size * 2 * sizeof(int16_t), fail)
s->p_mv_table = s->p_mv_table_base + s->mb_stride + 1;
s->b_forw_mv_table = s->b_forw_mv_table_base + s->mb_stride + 1;
s->b_back_mv_table = s->b_back_mv_table_base + s->mb_stride + 1;
s->b_bidir_forw_mv_table= s->b_bidir_forw_mv_table_base + s->mb_stride + 1;
s->b_bidir_back_mv_table= s->b_bidir_back_mv_table_base + s->mb_stride + 1;
s->b_direct_mv_table = s->b_direct_mv_table_base + s->mb_stride + 1;
if(s->msmpeg4_version){
FF_ALLOCZ_OR_GOTO(s->avctx, s->ac_stats, 2*2*(MAX_LEVEL+1)*(MAX_RUN+1)*2*sizeof(int), fail);
}
FF_ALLOCZ_OR_GOTO(s->avctx, s->avctx->stats_out, 256, fail);
FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_type , mb_array_size * sizeof(uint16_t), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->lambda_table, mb_array_size * sizeof(int), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->q_intra_matrix , 64*32 * sizeof(int), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->q_inter_matrix , 64*32 * sizeof(int), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->q_intra_matrix16, 64*32*2 * sizeof(uint16_t), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->q_inter_matrix16, 64*32*2 * sizeof(uint16_t), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->input_picture, MAX_PICTURE_COUNT * sizeof(Picture*), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->reordered_input_picture, MAX_PICTURE_COUNT * sizeof(Picture*), fail)
if(s->avctx->noise_reduction){
FF_ALLOCZ_OR_GOTO(s->avctx, s->dct_offset, 2 * 64 * sizeof(uint16_t), fail)
}
}
FF_ALLOCZ_OR_GOTO(s->avctx, s->picture, MAX_PICTURE_COUNT * sizeof(Picture), fail)
for(i = 0; i < MAX_PICTURE_COUNT; i++) {
avcodec_get_frame_defaults((AVFrame *)&s->picture[i]);
}
FF_ALLOCZ_OR_GOTO(s->avctx, s->error_status_table, mb_array_size*sizeof(uint8_t), fail)
if(s->codec_id==CODEC_ID_MPEG4 || (s->flags & CODEC_FLAG_INTERLACED_ME)){
for(i=0; i<2; i++){
int j, k;
for(j=0; j<2; j++){
for(k=0; k<2; k++){
FF_ALLOCZ_OR_GOTO(s->avctx, s->b_field_mv_table_base[i][j][k], mv_table_size * 2 * sizeof(int16_t), fail)
s->b_field_mv_table[i][j][k] = s->b_field_mv_table_base[i][j][k] + s->mb_stride + 1;
}
FF_ALLOCZ_OR_GOTO(s->avctx, s->b_field_select_table [i][j], mb_array_size * 2 * sizeof(uint8_t), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->p_field_mv_table_base[i][j], mv_table_size * 2 * sizeof(int16_t), fail)
s->p_field_mv_table[i][j] = s->p_field_mv_table_base[i][j]+ s->mb_stride + 1;
}
FF_ALLOCZ_OR_GOTO(s->avctx, s->p_field_select_table[i], mb_array_size * 2 * sizeof(uint8_t), fail)
}
}
if (s->out_format == FMT_H263) {
FF_ALLOCZ_OR_GOTO(s->avctx, s->ac_val_base, yc_size * sizeof(int16_t) * 16, fail);
s->ac_val[0] = s->ac_val_base + s->b8_stride + 1;
s->ac_val[1] = s->ac_val_base + y_size + s->mb_stride + 1;
s->ac_val[2] = s->ac_val[1] + c_size;
FF_ALLOCZ_OR_GOTO(s->avctx, s->coded_block_base, y_size, fail);
s->coded_block= s->coded_block_base + s->b8_stride + 1;
FF_ALLOCZ_OR_GOTO(s->avctx, s->cbp_table , mb_array_size * sizeof(uint8_t), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->pred_dir_table, mb_array_size * sizeof(uint8_t), fail)
}
if (s->h263_pred || s->h263_plus || !s->encoding) {
FF_ALLOCZ_OR_GOTO(s->avctx, s->dc_val_base, yc_size * sizeof(int16_t), fail);
s->dc_val[0] = s->dc_val_base + s->b8_stride + 1;
s->dc_val[1] = s->dc_val_base + y_size + s->mb_stride + 1;
s->dc_val[2] = s->dc_val[1] + c_size;
for(i=0;i<yc_size;i++)
s->dc_val_base[i] = 1024;
}
FF_ALLOCZ_OR_GOTO(s->avctx, s->mbintra_table, mb_array_size, fail);
memset(s->mbintra_table, 1, mb_array_size);
FF_ALLOCZ_OR_GOTO(s->avctx, s->mbskip_table, mb_array_size+2, fail);
FF_ALLOCZ_OR_GOTO(s->avctx, s->prev_pict_types, PREV_PICT_TYPES_BUFFER_SIZE, fail);
s->parse_context.state= -1;
if((s->avctx->debug&(FF_DEBUG_VIS_QP|FF_DEBUG_VIS_MB_TYPE)) || (s->avctx->debug_mv)){
s->visualization_buffer[0] = av_malloc((s->mb_width*16 + 2*EDGE_WIDTH) * s->mb_height*16 + 2*EDGE_WIDTH);
s->visualization_buffer[1] = av_malloc((s->mb_width*16 + 2*EDGE_WIDTH) * s->mb_height*16 + 2*EDGE_WIDTH);
s->visualization_buffer[2] = av_malloc((s->mb_width*16 + 2*EDGE_WIDTH) * s->mb_height*16 + 2*EDGE_WIDTH);
}
s->context_initialized = 1;
s->thread_context[0]= s;
threads = s->avctx->thread_count;
for(i=1; i<threads; i++){
s->thread_context[i]= av_malloc(sizeof(MpegEncContext));
memcpy(s->thread_context[i], s, sizeof(MpegEncContext));
}
for(i=0; i<threads; i++){
if(init_duplicate_context(s->thread_context[i], s) < 0)
goto fail;
s->thread_context[i]->start_mb_y= (s->mb_height*(i ) + s->avctx->thread_count/2) / s->avctx->thread_count;
s->thread_context[i]->end_mb_y = (s->mb_height*(i+1) + s->avctx->thread_count/2) / s->avctx->thread_count;
}
return 0;
fail:
MPV_common_end(s);
return -1;
}
| {
"code": [
" FF_ALLOCZ_OR_GOTO(s->avctx, s->ac_val_base, yc_size * sizeof(int16_t) * 16, fail);",
" s->ac_val[0] = s->ac_val_base + s->b8_stride + 1;",
" s->ac_val[1] = s->ac_val_base + y_size + s->mb_stride + 1;",
" s->ac_val[2] = s->ac_val[1] + c_size;"
],
"line_no": [
265,
267,
269,
271
]
} | av_cold int FUNC_0(MpegEncContext *s)
{
int VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8;
if(s->codec_id == CODEC_ID_MPEG2VIDEO && !s->progressive_sequence)
s->mb_height = (s->height + 31) / 32 * 2;
else
s->mb_height = (s->height + 15) / 16;
if(s->avctx->pix_fmt == PIX_FMT_NONE){
av_log(s->avctx, AV_LOG_ERROR, "decoding to PIX_FMT_NONE is not supported.\n");
return -1;
}
if(s->avctx->thread_count > MAX_THREADS || (s->avctx->thread_count > s->mb_height && s->mb_height)){
av_log(s->avctx, AV_LOG_ERROR, "too many VAR_8\n");
return -1;
}
if((s->width || s->height) && avcodec_check_dimensions(s->avctx, s->width, s->height))
return -1;
dsputil_init(&s->dsp, s->avctx);
ff_dct_common_init(s);
s->flags= s->avctx->flags;
s->flags2= s->avctx->flags2;
s->mb_width = (s->width + 15) / 16;
s->mb_stride = s->mb_width + 1;
s->b8_stride = s->mb_width*2 + 1;
s->b4_stride = s->mb_width*4 + 1;
VAR_4= s->mb_height * s->mb_stride;
VAR_5= (s->mb_height+2) * s->mb_stride + 1;
avcodec_get_chroma_sub_sample(s->avctx->pix_fmt,&(s->chroma_x_shift),
&(s->chroma_y_shift) );
s->h_edge_pos= s->mb_width*16;
s->v_edge_pos= s->mb_height*16;
s->mb_num = s->mb_width * s->mb_height;
s->block_wrap[0]=
s->block_wrap[1]=
s->block_wrap[2]=
s->block_wrap[3]= s->b8_stride;
s->block_wrap[4]=
s->block_wrap[5]= s->mb_stride;
VAR_0 = s->b8_stride * (2 * s->mb_height + 1);
VAR_1 = s->mb_stride * (s->mb_height + 1);
VAR_2 = VAR_0 + 2 * VAR_1;
s->codec_tag = ff_toupper4(s->avctx->codec_tag);
s->stream_codec_tag = ff_toupper4(s->avctx->stream_codec_tag);
s->avctx->coded_frame= (AVFrame*)&s->current_picture;
FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_index2xy, (s->mb_num+1)*sizeof(int), fail)
for(VAR_7=0; VAR_7<s->mb_height; VAR_7++){
for(VAR_6=0; VAR_6<s->mb_width; VAR_6++){
s->mb_index2xy[ VAR_6 + VAR_7*s->mb_width ] = VAR_6 + VAR_7*s->mb_stride;
}
}
s->mb_index2xy[ s->mb_height*s->mb_width ] = (s->mb_height-1)*s->mb_stride + s->mb_width;
if (s->encoding) {
FF_ALLOCZ_OR_GOTO(s->avctx, s->p_mv_table_base , VAR_5 * 2 * sizeof(int16_t), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->b_forw_mv_table_base , VAR_5 * 2 * sizeof(int16_t), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->b_back_mv_table_base , VAR_5 * 2 * sizeof(int16_t), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_forw_mv_table_base , VAR_5 * 2 * sizeof(int16_t), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_back_mv_table_base , VAR_5 * 2 * sizeof(int16_t), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->b_direct_mv_table_base , VAR_5 * 2 * sizeof(int16_t), fail)
s->p_mv_table = s->p_mv_table_base + s->mb_stride + 1;
s->b_forw_mv_table = s->b_forw_mv_table_base + s->mb_stride + 1;
s->b_back_mv_table = s->b_back_mv_table_base + s->mb_stride + 1;
s->b_bidir_forw_mv_table= s->b_bidir_forw_mv_table_base + s->mb_stride + 1;
s->b_bidir_back_mv_table= s->b_bidir_back_mv_table_base + s->mb_stride + 1;
s->b_direct_mv_table = s->b_direct_mv_table_base + s->mb_stride + 1;
if(s->msmpeg4_version){
FF_ALLOCZ_OR_GOTO(s->avctx, s->ac_stats, 2*2*(MAX_LEVEL+1)*(MAX_RUN+1)*2*sizeof(int), fail);
}
FF_ALLOCZ_OR_GOTO(s->avctx, s->avctx->stats_out, 256, fail);
FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_type , VAR_4 * sizeof(uint16_t), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->lambda_table, VAR_4 * sizeof(int), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->q_intra_matrix , 64*32 * sizeof(int), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->q_inter_matrix , 64*32 * sizeof(int), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->q_intra_matrix16, 64*32*2 * sizeof(uint16_t), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->q_inter_matrix16, 64*32*2 * sizeof(uint16_t), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->input_picture, MAX_PICTURE_COUNT * sizeof(Picture*), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->reordered_input_picture, MAX_PICTURE_COUNT * sizeof(Picture*), fail)
if(s->avctx->noise_reduction){
FF_ALLOCZ_OR_GOTO(s->avctx, s->dct_offset, 2 * 64 * sizeof(uint16_t), fail)
}
}
FF_ALLOCZ_OR_GOTO(s->avctx, s->picture, MAX_PICTURE_COUNT * sizeof(Picture), fail)
for(VAR_3 = 0; VAR_3 < MAX_PICTURE_COUNT; VAR_3++) {
avcodec_get_frame_defaults((AVFrame *)&s->picture[VAR_3]);
}
FF_ALLOCZ_OR_GOTO(s->avctx, s->error_status_table, VAR_4*sizeof(uint8_t), fail)
if(s->codec_id==CODEC_ID_MPEG4 || (s->flags & CODEC_FLAG_INTERLACED_ME)){
for(VAR_3=0; VAR_3<2; VAR_3++){
int j, k;
for(j=0; j<2; j++){
for(k=0; k<2; k++){
FF_ALLOCZ_OR_GOTO(s->avctx, s->b_field_mv_table_base[VAR_3][j][k], VAR_5 * 2 * sizeof(int16_t), fail)
s->b_field_mv_table[VAR_3][j][k] = s->b_field_mv_table_base[VAR_3][j][k] + s->mb_stride + 1;
}
FF_ALLOCZ_OR_GOTO(s->avctx, s->b_field_select_table [VAR_3][j], VAR_4 * 2 * sizeof(uint8_t), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->p_field_mv_table_base[VAR_3][j], VAR_5 * 2 * sizeof(int16_t), fail)
s->p_field_mv_table[VAR_3][j] = s->p_field_mv_table_base[VAR_3][j]+ s->mb_stride + 1;
}
FF_ALLOCZ_OR_GOTO(s->avctx, s->p_field_select_table[VAR_3], VAR_4 * 2 * sizeof(uint8_t), fail)
}
}
if (s->out_format == FMT_H263) {
FF_ALLOCZ_OR_GOTO(s->avctx, s->ac_val_base, VAR_2 * sizeof(int16_t) * 16, fail);
s->ac_val[0] = s->ac_val_base + s->b8_stride + 1;
s->ac_val[1] = s->ac_val_base + VAR_0 + s->mb_stride + 1;
s->ac_val[2] = s->ac_val[1] + VAR_1;
FF_ALLOCZ_OR_GOTO(s->avctx, s->coded_block_base, VAR_0, fail);
s->coded_block= s->coded_block_base + s->b8_stride + 1;
FF_ALLOCZ_OR_GOTO(s->avctx, s->cbp_table , VAR_4 * sizeof(uint8_t), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->pred_dir_table, VAR_4 * sizeof(uint8_t), fail)
}
if (s->h263_pred || s->h263_plus || !s->encoding) {
FF_ALLOCZ_OR_GOTO(s->avctx, s->dc_val_base, VAR_2 * sizeof(int16_t), fail);
s->dc_val[0] = s->dc_val_base + s->b8_stride + 1;
s->dc_val[1] = s->dc_val_base + VAR_0 + s->mb_stride + 1;
s->dc_val[2] = s->dc_val[1] + VAR_1;
for(VAR_3=0;VAR_3<VAR_2;VAR_3++)
s->dc_val_base[VAR_3] = 1024;
}
FF_ALLOCZ_OR_GOTO(s->avctx, s->mbintra_table, VAR_4, fail);
memset(s->mbintra_table, 1, VAR_4);
FF_ALLOCZ_OR_GOTO(s->avctx, s->mbskip_table, VAR_4+2, fail);
FF_ALLOCZ_OR_GOTO(s->avctx, s->prev_pict_types, PREV_PICT_TYPES_BUFFER_SIZE, fail);
s->parse_context.state= -1;
if((s->avctx->debug&(FF_DEBUG_VIS_QP|FF_DEBUG_VIS_MB_TYPE)) || (s->avctx->debug_mv)){
s->visualization_buffer[0] = av_malloc((s->mb_width*16 + 2*EDGE_WIDTH) * s->mb_height*16 + 2*EDGE_WIDTH);
s->visualization_buffer[1] = av_malloc((s->mb_width*16 + 2*EDGE_WIDTH) * s->mb_height*16 + 2*EDGE_WIDTH);
s->visualization_buffer[2] = av_malloc((s->mb_width*16 + 2*EDGE_WIDTH) * s->mb_height*16 + 2*EDGE_WIDTH);
}
s->context_initialized = 1;
s->thread_context[0]= s;
VAR_8 = s->avctx->thread_count;
for(VAR_3=1; VAR_3<VAR_8; VAR_3++){
s->thread_context[VAR_3]= av_malloc(sizeof(MpegEncContext));
memcpy(s->thread_context[VAR_3], s, sizeof(MpegEncContext));
}
for(VAR_3=0; VAR_3<VAR_8; VAR_3++){
if(init_duplicate_context(s->thread_context[VAR_3], s) < 0)
goto fail;
s->thread_context[VAR_3]->start_mb_y= (s->mb_height*(VAR_3 ) + s->avctx->thread_count/2) / s->avctx->thread_count;
s->thread_context[VAR_3]->end_mb_y = (s->mb_height*(VAR_3+1) + s->avctx->thread_count/2) / s->avctx->thread_count;
}
return 0;
fail:
MPV_common_end(s);
return -1;
}
| [
"av_cold int FUNC_0(MpegEncContext *s)\n{",
"int VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8;",
"if(s->codec_id == CODEC_ID_MPEG2VIDEO && !s->progressive_sequence)\ns->mb_height = (s->height + 31) / 32 * 2;",
"else\ns->mb_height = (s->height + 15) / 16;",
"if(s->avctx->pix_fmt == PIX_FMT_NONE){",
"av_log(s->avctx, AV_LOG_ERROR, \"decoding to PIX_FMT_NONE is not supported.\\n\");",
"return -1;",
"}",
"if(s->avctx->thread_count > MAX_THREADS || (s->avctx->thread_count > s->mb_height && s->mb_height)){",
"av_log(s->avctx, AV_LOG_ERROR, \"too many VAR_8\\n\");",
"return -1;",
"}",
"if((s->width || s->height) && avcodec_check_dimensions(s->avctx, s->width, s->height))\nreturn -1;",
"dsputil_init(&s->dsp, s->avctx);",
"ff_dct_common_init(s);",
"s->flags= s->avctx->flags;",
"s->flags2= s->avctx->flags2;",
"s->mb_width = (s->width + 15) / 16;",
"s->mb_stride = s->mb_width + 1;",
"s->b8_stride = s->mb_width*2 + 1;",
"s->b4_stride = s->mb_width*4 + 1;",
"VAR_4= s->mb_height * s->mb_stride;",
"VAR_5= (s->mb_height+2) * s->mb_stride + 1;",
"avcodec_get_chroma_sub_sample(s->avctx->pix_fmt,&(s->chroma_x_shift),\n&(s->chroma_y_shift) );",
"s->h_edge_pos= s->mb_width*16;",
"s->v_edge_pos= s->mb_height*16;",
"s->mb_num = s->mb_width * s->mb_height;",
"s->block_wrap[0]=\ns->block_wrap[1]=\ns->block_wrap[2]=\ns->block_wrap[3]= s->b8_stride;",
"s->block_wrap[4]=\ns->block_wrap[5]= s->mb_stride;",
"VAR_0 = s->b8_stride * (2 * s->mb_height + 1);",
"VAR_1 = s->mb_stride * (s->mb_height + 1);",
"VAR_2 = VAR_0 + 2 * VAR_1;",
"s->codec_tag = ff_toupper4(s->avctx->codec_tag);",
"s->stream_codec_tag = ff_toupper4(s->avctx->stream_codec_tag);",
"s->avctx->coded_frame= (AVFrame*)&s->current_picture;",
"FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_index2xy, (s->mb_num+1)*sizeof(int), fail)\nfor(VAR_7=0; VAR_7<s->mb_height; VAR_7++){",
"for(VAR_6=0; VAR_6<s->mb_width; VAR_6++){",
"s->mb_index2xy[ VAR_6 + VAR_7*s->mb_width ] = VAR_6 + VAR_7*s->mb_stride;",
"}",
"}",
"s->mb_index2xy[ s->mb_height*s->mb_width ] = (s->mb_height-1)*s->mb_stride + s->mb_width;",
"if (s->encoding) {",
"FF_ALLOCZ_OR_GOTO(s->avctx, s->p_mv_table_base , VAR_5 * 2 * sizeof(int16_t), fail)\nFF_ALLOCZ_OR_GOTO(s->avctx, s->b_forw_mv_table_base , VAR_5 * 2 * sizeof(int16_t), fail)\nFF_ALLOCZ_OR_GOTO(s->avctx, s->b_back_mv_table_base , VAR_5 * 2 * sizeof(int16_t), fail)\nFF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_forw_mv_table_base , VAR_5 * 2 * sizeof(int16_t), fail)\nFF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_back_mv_table_base , VAR_5 * 2 * sizeof(int16_t), fail)\nFF_ALLOCZ_OR_GOTO(s->avctx, s->b_direct_mv_table_base , VAR_5 * 2 * sizeof(int16_t), fail)\ns->p_mv_table = s->p_mv_table_base + s->mb_stride + 1;",
"s->b_forw_mv_table = s->b_forw_mv_table_base + s->mb_stride + 1;",
"s->b_back_mv_table = s->b_back_mv_table_base + s->mb_stride + 1;",
"s->b_bidir_forw_mv_table= s->b_bidir_forw_mv_table_base + s->mb_stride + 1;",
"s->b_bidir_back_mv_table= s->b_bidir_back_mv_table_base + s->mb_stride + 1;",
"s->b_direct_mv_table = s->b_direct_mv_table_base + s->mb_stride + 1;",
"if(s->msmpeg4_version){",
"FF_ALLOCZ_OR_GOTO(s->avctx, s->ac_stats, 2*2*(MAX_LEVEL+1)*(MAX_RUN+1)*2*sizeof(int), fail);",
"}",
"FF_ALLOCZ_OR_GOTO(s->avctx, s->avctx->stats_out, 256, fail);",
"FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_type , VAR_4 * sizeof(uint16_t), fail)\nFF_ALLOCZ_OR_GOTO(s->avctx, s->lambda_table, VAR_4 * sizeof(int), fail)\nFF_ALLOCZ_OR_GOTO(s->avctx, s->q_intra_matrix , 64*32 * sizeof(int), fail)\nFF_ALLOCZ_OR_GOTO(s->avctx, s->q_inter_matrix , 64*32 * sizeof(int), fail)\nFF_ALLOCZ_OR_GOTO(s->avctx, s->q_intra_matrix16, 64*32*2 * sizeof(uint16_t), fail)\nFF_ALLOCZ_OR_GOTO(s->avctx, s->q_inter_matrix16, 64*32*2 * sizeof(uint16_t), fail)\nFF_ALLOCZ_OR_GOTO(s->avctx, s->input_picture, MAX_PICTURE_COUNT * sizeof(Picture*), fail)\nFF_ALLOCZ_OR_GOTO(s->avctx, s->reordered_input_picture, MAX_PICTURE_COUNT * sizeof(Picture*), fail)\nif(s->avctx->noise_reduction){",
"FF_ALLOCZ_OR_GOTO(s->avctx, s->dct_offset, 2 * 64 * sizeof(uint16_t), fail)\n}",
"}",
"FF_ALLOCZ_OR_GOTO(s->avctx, s->picture, MAX_PICTURE_COUNT * sizeof(Picture), fail)\nfor(VAR_3 = 0; VAR_3 < MAX_PICTURE_COUNT; VAR_3++) {",
"avcodec_get_frame_defaults((AVFrame *)&s->picture[VAR_3]);",
"}",
"FF_ALLOCZ_OR_GOTO(s->avctx, s->error_status_table, VAR_4*sizeof(uint8_t), fail)\nif(s->codec_id==CODEC_ID_MPEG4 || (s->flags & CODEC_FLAG_INTERLACED_ME)){",
"for(VAR_3=0; VAR_3<2; VAR_3++){",
"int j, k;",
"for(j=0; j<2; j++){",
"for(k=0; k<2; k++){",
"FF_ALLOCZ_OR_GOTO(s->avctx, s->b_field_mv_table_base[VAR_3][j][k], VAR_5 * 2 * sizeof(int16_t), fail)\ns->b_field_mv_table[VAR_3][j][k] = s->b_field_mv_table_base[VAR_3][j][k] + s->mb_stride + 1;",
"}",
"FF_ALLOCZ_OR_GOTO(s->avctx, s->b_field_select_table [VAR_3][j], VAR_4 * 2 * sizeof(uint8_t), fail)\nFF_ALLOCZ_OR_GOTO(s->avctx, s->p_field_mv_table_base[VAR_3][j], VAR_5 * 2 * sizeof(int16_t), fail)\ns->p_field_mv_table[VAR_3][j] = s->p_field_mv_table_base[VAR_3][j]+ s->mb_stride + 1;",
"}",
"FF_ALLOCZ_OR_GOTO(s->avctx, s->p_field_select_table[VAR_3], VAR_4 * 2 * sizeof(uint8_t), fail)\n}",
"}",
"if (s->out_format == FMT_H263) {",
"FF_ALLOCZ_OR_GOTO(s->avctx, s->ac_val_base, VAR_2 * sizeof(int16_t) * 16, fail);",
"s->ac_val[0] = s->ac_val_base + s->b8_stride + 1;",
"s->ac_val[1] = s->ac_val_base + VAR_0 + s->mb_stride + 1;",
"s->ac_val[2] = s->ac_val[1] + VAR_1;",
"FF_ALLOCZ_OR_GOTO(s->avctx, s->coded_block_base, VAR_0, fail);",
"s->coded_block= s->coded_block_base + s->b8_stride + 1;",
"FF_ALLOCZ_OR_GOTO(s->avctx, s->cbp_table , VAR_4 * sizeof(uint8_t), fail)\nFF_ALLOCZ_OR_GOTO(s->avctx, s->pred_dir_table, VAR_4 * sizeof(uint8_t), fail)\n}",
"if (s->h263_pred || s->h263_plus || !s->encoding) {",
"FF_ALLOCZ_OR_GOTO(s->avctx, s->dc_val_base, VAR_2 * sizeof(int16_t), fail);",
"s->dc_val[0] = s->dc_val_base + s->b8_stride + 1;",
"s->dc_val[1] = s->dc_val_base + VAR_0 + s->mb_stride + 1;",
"s->dc_val[2] = s->dc_val[1] + VAR_1;",
"for(VAR_3=0;VAR_3<VAR_2;VAR_3++)",
"s->dc_val_base[VAR_3] = 1024;",
"}",
"FF_ALLOCZ_OR_GOTO(s->avctx, s->mbintra_table, VAR_4, fail);",
"memset(s->mbintra_table, 1, VAR_4);",
"FF_ALLOCZ_OR_GOTO(s->avctx, s->mbskip_table, VAR_4+2, fail);",
"FF_ALLOCZ_OR_GOTO(s->avctx, s->prev_pict_types, PREV_PICT_TYPES_BUFFER_SIZE, fail);",
"s->parse_context.state= -1;",
"if((s->avctx->debug&(FF_DEBUG_VIS_QP|FF_DEBUG_VIS_MB_TYPE)) || (s->avctx->debug_mv)){",
"s->visualization_buffer[0] = av_malloc((s->mb_width*16 + 2*EDGE_WIDTH) * s->mb_height*16 + 2*EDGE_WIDTH);",
"s->visualization_buffer[1] = av_malloc((s->mb_width*16 + 2*EDGE_WIDTH) * s->mb_height*16 + 2*EDGE_WIDTH);",
"s->visualization_buffer[2] = av_malloc((s->mb_width*16 + 2*EDGE_WIDTH) * s->mb_height*16 + 2*EDGE_WIDTH);",
"}",
"s->context_initialized = 1;",
"s->thread_context[0]= s;",
"VAR_8 = s->avctx->thread_count;",
"for(VAR_3=1; VAR_3<VAR_8; VAR_3++){",
"s->thread_context[VAR_3]= av_malloc(sizeof(MpegEncContext));",
"memcpy(s->thread_context[VAR_3], s, sizeof(MpegEncContext));",
"}",
"for(VAR_3=0; VAR_3<VAR_8; VAR_3++){",
"if(init_duplicate_context(s->thread_context[VAR_3], s) < 0)\ngoto fail;",
"s->thread_context[VAR_3]->start_mb_y= (s->mb_height*(VAR_3 ) + s->avctx->thread_count/2) / s->avctx->thread_count;",
"s->thread_context[VAR_3]->end_mb_y = (s->mb_height*(VAR_3+1) + s->avctx->thread_count/2) / s->avctx->thread_count;",
"}",
"return 0;",
"fail:\nMPV_common_end(s);",
"return -1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9,
11
],
[
13,
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39,
41
],
[
45
],
[
47
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
73,
75
],
[
81
],
[
83
],
[
87
],
[
91,
93,
95,
97
],
[
99,
101
],
[
105
],
[
107
],
[
109
],
[
115
],
[
119
],
[
123
],
[
127,
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
143
],
[
147,
149,
151,
153,
155,
157,
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
173
],
[
175
],
[
177
],
[
179
],
[
185,
189,
193,
195,
197,
199,
201,
203,
207
],
[
209,
211
],
[
213
],
[
215,
217
],
[
219
],
[
221
],
[
225,
229
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241,
243
],
[
245
],
[
247,
249,
251
],
[
253
],
[
255,
257
],
[
259
],
[
261
],
[
265
],
[
267
],
[
269
],
[
271
],
[
277
],
[
279
],
[
285,
287,
289
],
[
293
],
[
299
],
[
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
311
],
[
317
],
[
319
],
[
325
],
[
329
],
[
333
],
[
335
],
[
337
],
[
339
],
[
341
],
[
343
],
[
347
],
[
351
],
[
353
],
[
357
],
[
359
],
[
361
],
[
363
],
[
367
],
[
369,
371
],
[
373
],
[
375
],
[
377
],
[
381
],
[
383,
385
],
[
387
],
[
389
]
] |
22,256 | static av_cold int aac_decode_init(AVCodecContext *avctx)
{
AACContext *ac = avctx->priv_data;
int ret;
ac->avctx = avctx;
ac->oc[1].m4ac.sample_rate = avctx->sample_rate;
aacdec_init(ac);
#if USE_FIXED
avctx->sample_fmt = AV_SAMPLE_FMT_S32P;
#else
avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
#endif /* USE_FIXED */
if (avctx->extradata_size > 0) {
if ((ret = decode_audio_specific_config(ac, ac->avctx, &ac->oc[1].m4ac,
avctx->extradata,
avctx->extradata_size * 8,
1)) < 0)
return ret;
} else {
int sr, i;
uint8_t layout_map[MAX_ELEM_ID*4][3];
int layout_map_tags;
sr = sample_rate_idx(avctx->sample_rate);
ac->oc[1].m4ac.sampling_index = sr;
ac->oc[1].m4ac.channels = avctx->channels;
ac->oc[1].m4ac.sbr = -1;
ac->oc[1].m4ac.ps = -1;
for (i = 0; i < FF_ARRAY_ELEMS(ff_mpeg4audio_channels); i++)
if (ff_mpeg4audio_channels[i] == avctx->channels)
break;
if (i == FF_ARRAY_ELEMS(ff_mpeg4audio_channels)) {
i = 0;
}
ac->oc[1].m4ac.chan_config = i;
if (ac->oc[1].m4ac.chan_config) {
int ret = set_default_channel_config(avctx, layout_map,
&layout_map_tags, ac->oc[1].m4ac.chan_config);
if (!ret)
output_configure(ac, layout_map, layout_map_tags,
OC_GLOBAL_HDR, 0);
else if (avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
}
}
if (avctx->channels > MAX_CHANNELS) {
av_log(avctx, AV_LOG_ERROR, "Too many channels\n");
return AVERROR_INVALIDDATA;
}
AAC_INIT_VLC_STATIC( 0, 304);
AAC_INIT_VLC_STATIC( 1, 270);
AAC_INIT_VLC_STATIC( 2, 550);
AAC_INIT_VLC_STATIC( 3, 300);
AAC_INIT_VLC_STATIC( 4, 328);
AAC_INIT_VLC_STATIC( 5, 294);
AAC_INIT_VLC_STATIC( 6, 306);
AAC_INIT_VLC_STATIC( 7, 268);
AAC_INIT_VLC_STATIC( 8, 510);
AAC_INIT_VLC_STATIC( 9, 366);
AAC_INIT_VLC_STATIC(10, 462);
AAC_RENAME(ff_aac_sbr_init)();
#if USE_FIXED
ac->fdsp = avpriv_alloc_fixed_dsp(avctx->flags & AV_CODEC_FLAG_BITEXACT);
#else
ac->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);
#endif /* USE_FIXED */
if (!ac->fdsp) {
return AVERROR(ENOMEM);
}
ac->random_state = 0x1f2e3d4c;
ff_aac_tableinit();
INIT_VLC_STATIC(&vlc_scalefactors, 7,
FF_ARRAY_ELEMS(ff_aac_scalefactor_code),
ff_aac_scalefactor_bits,
sizeof(ff_aac_scalefactor_bits[0]),
sizeof(ff_aac_scalefactor_bits[0]),
ff_aac_scalefactor_code,
sizeof(ff_aac_scalefactor_code[0]),
sizeof(ff_aac_scalefactor_code[0]),
352);
AAC_RENAME_32(ff_mdct_init)(&ac->mdct, 11, 1, 1.0 / RANGE15(1024.0));
AAC_RENAME_32(ff_mdct_init)(&ac->mdct_ld, 10, 1, 1.0 / RANGE15(512.0));
AAC_RENAME_32(ff_mdct_init)(&ac->mdct_small, 8, 1, 1.0 / RANGE15(128.0));
AAC_RENAME_32(ff_mdct_init)(&ac->mdct_ltp, 11, 0, RANGE15(-2.0));
#if !USE_FIXED
ret = ff_imdct15_init(&ac->mdct480, 5);
if (ret < 0)
return ret;
#endif
// window initialization
AAC_RENAME(ff_kbd_window_init)(AAC_RENAME(ff_aac_kbd_long_1024), 4.0, 1024);
AAC_RENAME(ff_kbd_window_init)(AAC_RENAME(ff_aac_kbd_short_128), 6.0, 128);
AAC_RENAME(ff_init_ff_sine_windows)(10);
AAC_RENAME(ff_init_ff_sine_windows)( 9);
AAC_RENAME(ff_init_ff_sine_windows)( 7);
AAC_RENAME(cbrt_tableinit)();
return 0;
}
| true | FFmpeg | 7f46a641bf2540b8cf1293d5e50c0c0e34264254 | static av_cold int aac_decode_init(AVCodecContext *avctx)
{
AACContext *ac = avctx->priv_data;
int ret;
ac->avctx = avctx;
ac->oc[1].m4ac.sample_rate = avctx->sample_rate;
aacdec_init(ac);
#if USE_FIXED
avctx->sample_fmt = AV_SAMPLE_FMT_S32P;
#else
avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
#endif
if (avctx->extradata_size > 0) {
if ((ret = decode_audio_specific_config(ac, ac->avctx, &ac->oc[1].m4ac,
avctx->extradata,
avctx->extradata_size * 8,
1)) < 0)
return ret;
} else {
int sr, i;
uint8_t layout_map[MAX_ELEM_ID*4][3];
int layout_map_tags;
sr = sample_rate_idx(avctx->sample_rate);
ac->oc[1].m4ac.sampling_index = sr;
ac->oc[1].m4ac.channels = avctx->channels;
ac->oc[1].m4ac.sbr = -1;
ac->oc[1].m4ac.ps = -1;
for (i = 0; i < FF_ARRAY_ELEMS(ff_mpeg4audio_channels); i++)
if (ff_mpeg4audio_channels[i] == avctx->channels)
break;
if (i == FF_ARRAY_ELEMS(ff_mpeg4audio_channels)) {
i = 0;
}
ac->oc[1].m4ac.chan_config = i;
if (ac->oc[1].m4ac.chan_config) {
int ret = set_default_channel_config(avctx, layout_map,
&layout_map_tags, ac->oc[1].m4ac.chan_config);
if (!ret)
output_configure(ac, layout_map, layout_map_tags,
OC_GLOBAL_HDR, 0);
else if (avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
}
}
if (avctx->channels > MAX_CHANNELS) {
av_log(avctx, AV_LOG_ERROR, "Too many channels\n");
return AVERROR_INVALIDDATA;
}
AAC_INIT_VLC_STATIC( 0, 304);
AAC_INIT_VLC_STATIC( 1, 270);
AAC_INIT_VLC_STATIC( 2, 550);
AAC_INIT_VLC_STATIC( 3, 300);
AAC_INIT_VLC_STATIC( 4, 328);
AAC_INIT_VLC_STATIC( 5, 294);
AAC_INIT_VLC_STATIC( 6, 306);
AAC_INIT_VLC_STATIC( 7, 268);
AAC_INIT_VLC_STATIC( 8, 510);
AAC_INIT_VLC_STATIC( 9, 366);
AAC_INIT_VLC_STATIC(10, 462);
AAC_RENAME(ff_aac_sbr_init)();
#if USE_FIXED
ac->fdsp = avpriv_alloc_fixed_dsp(avctx->flags & AV_CODEC_FLAG_BITEXACT);
#else
ac->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);
#endif
if (!ac->fdsp) {
return AVERROR(ENOMEM);
}
ac->random_state = 0x1f2e3d4c;
ff_aac_tableinit();
INIT_VLC_STATIC(&vlc_scalefactors, 7,
FF_ARRAY_ELEMS(ff_aac_scalefactor_code),
ff_aac_scalefactor_bits,
sizeof(ff_aac_scalefactor_bits[0]),
sizeof(ff_aac_scalefactor_bits[0]),
ff_aac_scalefactor_code,
sizeof(ff_aac_scalefactor_code[0]),
sizeof(ff_aac_scalefactor_code[0]),
352);
AAC_RENAME_32(ff_mdct_init)(&ac->mdct, 11, 1, 1.0 / RANGE15(1024.0));
AAC_RENAME_32(ff_mdct_init)(&ac->mdct_ld, 10, 1, 1.0 / RANGE15(512.0));
AAC_RENAME_32(ff_mdct_init)(&ac->mdct_small, 8, 1, 1.0 / RANGE15(128.0));
AAC_RENAME_32(ff_mdct_init)(&ac->mdct_ltp, 11, 0, RANGE15(-2.0));
#if !USE_FIXED
ret = ff_imdct15_init(&ac->mdct480, 5);
if (ret < 0)
return ret;
#endif
AAC_RENAME(ff_kbd_window_init)(AAC_RENAME(ff_aac_kbd_long_1024), 4.0, 1024);
AAC_RENAME(ff_kbd_window_init)(AAC_RENAME(ff_aac_kbd_short_128), 6.0, 128);
AAC_RENAME(ff_init_ff_sine_windows)(10);
AAC_RENAME(ff_init_ff_sine_windows)( 9);
AAC_RENAME(ff_init_ff_sine_windows)( 7);
AAC_RENAME(cbrt_tableinit)();
return 0;
}
| {
"code": [
" avctx->extradata_size * 8,"
],
"line_no": [
37
]
} | static av_cold int FUNC_0(AVCodecContext *avctx)
{
AACContext *ac = avctx->priv_data;
int VAR_4;
ac->avctx = avctx;
ac->oc[1].m4ac.sample_rate = avctx->sample_rate;
aacdec_init(ac);
#if USE_FIXED
avctx->sample_fmt = AV_SAMPLE_FMT_S32P;
#else
avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
#endif
if (avctx->extradata_size > 0) {
if ((VAR_4 = decode_audio_specific_config(ac, ac->avctx, &ac->oc[1].m4ac,
avctx->extradata,
avctx->extradata_size * 8,
1)) < 0)
return VAR_4;
} else {
int VAR_1, VAR_2;
uint8_t layout_map[MAX_ELEM_ID*4][3];
int VAR_3;
VAR_1 = sample_rate_idx(avctx->sample_rate);
ac->oc[1].m4ac.sampling_index = VAR_1;
ac->oc[1].m4ac.channels = avctx->channels;
ac->oc[1].m4ac.sbr = -1;
ac->oc[1].m4ac.ps = -1;
for (VAR_2 = 0; VAR_2 < FF_ARRAY_ELEMS(ff_mpeg4audio_channels); VAR_2++)
if (ff_mpeg4audio_channels[VAR_2] == avctx->channels)
break;
if (VAR_2 == FF_ARRAY_ELEMS(ff_mpeg4audio_channels)) {
VAR_2 = 0;
}
ac->oc[1].m4ac.chan_config = VAR_2;
if (ac->oc[1].m4ac.chan_config) {
int VAR_4 = set_default_channel_config(avctx, layout_map,
&VAR_3, ac->oc[1].m4ac.chan_config);
if (!VAR_4)
output_configure(ac, layout_map, VAR_3,
OC_GLOBAL_HDR, 0);
else if (avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
}
}
if (avctx->channels > MAX_CHANNELS) {
av_log(avctx, AV_LOG_ERROR, "Too many channels\n");
return AVERROR_INVALIDDATA;
}
AAC_INIT_VLC_STATIC( 0, 304);
AAC_INIT_VLC_STATIC( 1, 270);
AAC_INIT_VLC_STATIC( 2, 550);
AAC_INIT_VLC_STATIC( 3, 300);
AAC_INIT_VLC_STATIC( 4, 328);
AAC_INIT_VLC_STATIC( 5, 294);
AAC_INIT_VLC_STATIC( 6, 306);
AAC_INIT_VLC_STATIC( 7, 268);
AAC_INIT_VLC_STATIC( 8, 510);
AAC_INIT_VLC_STATIC( 9, 366);
AAC_INIT_VLC_STATIC(10, 462);
AAC_RENAME(ff_aac_sbr_init)();
#if USE_FIXED
ac->fdsp = avpriv_alloc_fixed_dsp(avctx->flags & AV_CODEC_FLAG_BITEXACT);
#else
ac->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);
#endif
if (!ac->fdsp) {
return AVERROR(ENOMEM);
}
ac->random_state = 0x1f2e3d4c;
ff_aac_tableinit();
INIT_VLC_STATIC(&vlc_scalefactors, 7,
FF_ARRAY_ELEMS(ff_aac_scalefactor_code),
ff_aac_scalefactor_bits,
sizeof(ff_aac_scalefactor_bits[0]),
sizeof(ff_aac_scalefactor_bits[0]),
ff_aac_scalefactor_code,
sizeof(ff_aac_scalefactor_code[0]),
sizeof(ff_aac_scalefactor_code[0]),
352);
AAC_RENAME_32(ff_mdct_init)(&ac->mdct, 11, 1, 1.0 / RANGE15(1024.0));
AAC_RENAME_32(ff_mdct_init)(&ac->mdct_ld, 10, 1, 1.0 / RANGE15(512.0));
AAC_RENAME_32(ff_mdct_init)(&ac->mdct_small, 8, 1, 1.0 / RANGE15(128.0));
AAC_RENAME_32(ff_mdct_init)(&ac->mdct_ltp, 11, 0, RANGE15(-2.0));
#if !USE_FIXED
VAR_4 = ff_imdct15_init(&ac->mdct480, 5);
if (VAR_4 < 0)
return VAR_4;
#endif
AAC_RENAME(ff_kbd_window_init)(AAC_RENAME(ff_aac_kbd_long_1024), 4.0, 1024);
AAC_RENAME(ff_kbd_window_init)(AAC_RENAME(ff_aac_kbd_short_128), 6.0, 128);
AAC_RENAME(ff_init_ff_sine_windows)(10);
AAC_RENAME(ff_init_ff_sine_windows)( 9);
AAC_RENAME(ff_init_ff_sine_windows)( 7);
AAC_RENAME(cbrt_tableinit)();
return 0;
}
| [
"static av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"AACContext *ac = avctx->priv_data;",
"int VAR_4;",
"ac->avctx = avctx;",
"ac->oc[1].m4ac.sample_rate = avctx->sample_rate;",
"aacdec_init(ac);",
"#if USE_FIXED\navctx->sample_fmt = AV_SAMPLE_FMT_S32P;",
"#else\navctx->sample_fmt = AV_SAMPLE_FMT_FLTP;",
"#endif\nif (avctx->extradata_size > 0) {",
"if ((VAR_4 = decode_audio_specific_config(ac, ac->avctx, &ac->oc[1].m4ac,\navctx->extradata,\navctx->extradata_size * 8,\n1)) < 0)\nreturn VAR_4;",
"} else {",
"int VAR_1, VAR_2;",
"uint8_t layout_map[MAX_ELEM_ID*4][3];",
"int VAR_3;",
"VAR_1 = sample_rate_idx(avctx->sample_rate);",
"ac->oc[1].m4ac.sampling_index = VAR_1;",
"ac->oc[1].m4ac.channels = avctx->channels;",
"ac->oc[1].m4ac.sbr = -1;",
"ac->oc[1].m4ac.ps = -1;",
"for (VAR_2 = 0; VAR_2 < FF_ARRAY_ELEMS(ff_mpeg4audio_channels); VAR_2++)",
"if (ff_mpeg4audio_channels[VAR_2] == avctx->channels)\nbreak;",
"if (VAR_2 == FF_ARRAY_ELEMS(ff_mpeg4audio_channels)) {",
"VAR_2 = 0;",
"}",
"ac->oc[1].m4ac.chan_config = VAR_2;",
"if (ac->oc[1].m4ac.chan_config) {",
"int VAR_4 = set_default_channel_config(avctx, layout_map,\n&VAR_3, ac->oc[1].m4ac.chan_config);",
"if (!VAR_4)\noutput_configure(ac, layout_map, VAR_3,\nOC_GLOBAL_HDR, 0);",
"else if (avctx->err_recognition & AV_EF_EXPLODE)\nreturn AVERROR_INVALIDDATA;",
"}",
"}",
"if (avctx->channels > MAX_CHANNELS) {",
"av_log(avctx, AV_LOG_ERROR, \"Too many channels\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"AAC_INIT_VLC_STATIC( 0, 304);",
"AAC_INIT_VLC_STATIC( 1, 270);",
"AAC_INIT_VLC_STATIC( 2, 550);",
"AAC_INIT_VLC_STATIC( 3, 300);",
"AAC_INIT_VLC_STATIC( 4, 328);",
"AAC_INIT_VLC_STATIC( 5, 294);",
"AAC_INIT_VLC_STATIC( 6, 306);",
"AAC_INIT_VLC_STATIC( 7, 268);",
"AAC_INIT_VLC_STATIC( 8, 510);",
"AAC_INIT_VLC_STATIC( 9, 366);",
"AAC_INIT_VLC_STATIC(10, 462);",
"AAC_RENAME(ff_aac_sbr_init)();",
"#if USE_FIXED\nac->fdsp = avpriv_alloc_fixed_dsp(avctx->flags & AV_CODEC_FLAG_BITEXACT);",
"#else\nac->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);",
"#endif\nif (!ac->fdsp) {",
"return AVERROR(ENOMEM);",
"}",
"ac->random_state = 0x1f2e3d4c;",
"ff_aac_tableinit();",
"INIT_VLC_STATIC(&vlc_scalefactors, 7,\nFF_ARRAY_ELEMS(ff_aac_scalefactor_code),\nff_aac_scalefactor_bits,\nsizeof(ff_aac_scalefactor_bits[0]),\nsizeof(ff_aac_scalefactor_bits[0]),\nff_aac_scalefactor_code,\nsizeof(ff_aac_scalefactor_code[0]),\nsizeof(ff_aac_scalefactor_code[0]),\n352);",
"AAC_RENAME_32(ff_mdct_init)(&ac->mdct, 11, 1, 1.0 / RANGE15(1024.0));",
"AAC_RENAME_32(ff_mdct_init)(&ac->mdct_ld, 10, 1, 1.0 / RANGE15(512.0));",
"AAC_RENAME_32(ff_mdct_init)(&ac->mdct_small, 8, 1, 1.0 / RANGE15(128.0));",
"AAC_RENAME_32(ff_mdct_init)(&ac->mdct_ltp, 11, 0, RANGE15(-2.0));",
"#if !USE_FIXED\nVAR_4 = ff_imdct15_init(&ac->mdct480, 5);",
"if (VAR_4 < 0)\nreturn VAR_4;",
"#endif\nAAC_RENAME(ff_kbd_window_init)(AAC_RENAME(ff_aac_kbd_long_1024), 4.0, 1024);",
"AAC_RENAME(ff_kbd_window_init)(AAC_RENAME(ff_aac_kbd_short_128), 6.0, 128);",
"AAC_RENAME(ff_init_ff_sine_windows)(10);",
"AAC_RENAME(ff_init_ff_sine_windows)( 9);",
"AAC_RENAME(ff_init_ff_sine_windows)( 7);",
"AAC_RENAME(cbrt_tableinit)();",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
17
],
[
19,
21
],
[
23,
25
],
[
27,
31
],
[
33,
35,
37,
39,
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67,
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81
],
[
83,
85
],
[
87,
89,
91
],
[
93,
95
],
[
97
],
[
99
],
[
103
],
[
105
],
[
107
],
[
109
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
137
],
[
141,
143
],
[
145,
147
],
[
149,
151
],
[
153
],
[
155
],
[
159
],
[
163
],
[
167,
169,
171,
173,
175,
177,
179,
181,
183
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195,
197
],
[
199,
201
],
[
203,
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
219
],
[
223
],
[
225
]
] |
22,257 | PPC_OP(addic)
{
T1 = T0;
T0 += PARAM(1);
if (T0 < T1) {
xer_ca = 1;
} else {
xer_ca = 0;
}
RETURN();
}
| true | qemu | d9bce9d99f4656ae0b0127f7472db9067b8f84ab | PPC_OP(addic)
{
T1 = T0;
T0 += PARAM(1);
if (T0 < T1) {
xer_ca = 1;
} else {
xer_ca = 0;
}
RETURN();
}
| {
"code": [
" RETURN();",
" xer_ca = 1;",
"PPC_OP(addic)",
" T1 = T0;",
" T0 += PARAM(1);",
" if (T0 < T1) {",
" } else {",
" xer_ca = 0;",
" T1 = T0;",
" T1 = T0;",
" if (T0 < T1) {",
" xer_ca = 1;",
" } else {",
" xer_ca = 0;",
" xer_ca = 1;",
" } else {",
" if (T0 < T1) {",
" if (T0 < T1) {",
" T1 = T0;",
" } else {",
" xer_ca = 0;",
" } else {",
" xer_ca = 1;",
" } else {",
" } else {",
" xer_ca = 0;",
" } else {",
" RETURN();",
" xer_ca = 0;",
" } else {",
" xer_ca = 1;",
" xer_ca = 0;",
" } else {"
],
"line_no": [
19,
11,
1,
5,
7,
9,
13,
15,
5,
5,
9,
11,
13,
15,
11,
13,
9,
9,
5,
13,
15,
13,
11,
13,
13,
15,
13,
19,
15,
13,
11,
15,
13
]
} | FUNC_0(VAR_0)
{
T1 = T0;
T0 += PARAM(1);
if (T0 < T1) {
xer_ca = 1;
} else {
xer_ca = 0;
}
RETURN();
}
| [
"FUNC_0(VAR_0)\n{",
"T1 = T0;",
"T0 += PARAM(1);",
"if (T0 < T1) {",
"xer_ca = 1;",
"} else {",
"xer_ca = 0;",
"}",
"RETURN();",
"}"
] | [
1,
1,
1,
1,
1,
0,
1,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
22,258 | void qemu_update_position(QEMUFile *f, size_t size)
{
f->pos += size;
}
| true | qemu | 60fe637bf0e4d7989e21e50f52526444765c63b4 | void qemu_update_position(QEMUFile *f, size_t size)
{
f->pos += size;
}
| {
"code": [],
"line_no": []
} | void FUNC_0(QEMUFile *VAR_0, size_t VAR_1)
{
VAR_0->pos += VAR_1;
}
| [
"void FUNC_0(QEMUFile *VAR_0, size_t VAR_1)\n{",
"VAR_0->pos += VAR_1;",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
22,259 | static ExitStatus translate_one(DisasContext *ctx, uint32_t insn)
{
int32_t disp21, disp16, disp12 __attribute__((unused));
uint16_t fn11;
uint8_t opc, ra, rb, rc, fpfn, fn7, lit;
bool islit;
TCGv va, vb, vc, tmp;
TCGv_i32 t32;
ExitStatus ret;
/* Decode all instruction fields */
opc = extract32(insn, 26, 6);
ra = extract32(insn, 21, 5);
rb = extract32(insn, 16, 5);
rc = extract32(insn, 0, 5);
islit = extract32(insn, 12, 1);
lit = extract32(insn, 13, 8);
disp21 = sextract32(insn, 0, 21);
disp16 = sextract32(insn, 0, 16);
disp12 = sextract32(insn, 0, 12);
fn11 = extract32(insn, 5, 11);
fpfn = extract32(insn, 5, 6);
fn7 = extract32(insn, 5, 7);
if (rb == 31 && !islit) {
islit = true;
lit = 0;
}
ret = NO_EXIT;
switch (opc) {
case 0x00:
/* CALL_PAL */
ret = gen_call_pal(ctx, insn & 0x03ffffff);
break;
case 0x01:
/* OPC01 */
goto invalid_opc;
case 0x02:
/* OPC02 */
goto invalid_opc;
case 0x03:
/* OPC03 */
goto invalid_opc;
case 0x04:
/* OPC04 */
goto invalid_opc;
case 0x05:
/* OPC05 */
goto invalid_opc;
case 0x06:
/* OPC06 */
goto invalid_opc;
case 0x07:
/* OPC07 */
goto invalid_opc;
case 0x09:
/* LDAH */
disp16 = (uint32_t)disp16 << 16;
/* fall through */
case 0x08:
/* LDA */
va = dest_gpr(ctx, ra);
/* It's worth special-casing immediate loads. */
if (rb == 31) {
tcg_gen_movi_i64(va, disp16);
} else {
tcg_gen_addi_i64(va, load_gpr(ctx, rb), disp16);
}
break;
case 0x0A:
/* LDBU */
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_BWX);
gen_load_mem(ctx, &tcg_gen_qemu_ld8u, ra, rb, disp16, 0, 0);
break;
case 0x0B:
/* LDQ_U */
gen_load_mem(ctx, &tcg_gen_qemu_ld64, ra, rb, disp16, 0, 1);
break;
case 0x0C:
/* LDWU */
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_BWX);
gen_load_mem(ctx, &tcg_gen_qemu_ld16u, ra, rb, disp16, 0, 0);
break;
case 0x0D:
/* STW */
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_BWX);
gen_store_mem(ctx, &tcg_gen_qemu_st16, ra, rb, disp16, 0, 0);
break;
case 0x0E:
/* STB */
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_BWX);
gen_store_mem(ctx, &tcg_gen_qemu_st8, ra, rb, disp16, 0, 0);
break;
case 0x0F:
/* STQ_U */
gen_store_mem(ctx, &tcg_gen_qemu_st64, ra, rb, disp16, 0, 1);
break;
case 0x10:
vc = dest_gpr(ctx, rc);
vb = load_gpr_lit(ctx, rb, lit, islit);
if (ra == 31) {
if (fn7 == 0x00) {
/* Special case ADDL as SEXTL. */
tcg_gen_ext32s_i64(vc, vb);
break;
}
if (fn7 == 0x29) {
/* Special case SUBQ as NEGQ. */
tcg_gen_neg_i64(vc, vb);
break;
}
}
va = load_gpr(ctx, ra);
switch (fn7) {
case 0x00:
/* ADDL */
tcg_gen_add_i64(vc, va, vb);
tcg_gen_ext32s_i64(vc, vc);
break;
case 0x02:
/* S4ADDL */
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 2);
tcg_gen_add_i64(tmp, tmp, vb);
tcg_gen_ext32s_i64(vc, tmp);
tcg_temp_free(tmp);
break;
case 0x09:
/* SUBL */
tcg_gen_sub_i64(vc, va, vb);
tcg_gen_ext32s_i64(vc, vc);
break;
case 0x0B:
/* S4SUBL */
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 2);
tcg_gen_sub_i64(tmp, tmp, vb);
tcg_gen_ext32s_i64(vc, tmp);
tcg_temp_free(tmp);
break;
case 0x0F:
/* CMPBGE */
gen_helper_cmpbge(vc, va, vb);
break;
case 0x12:
/* S8ADDL */
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 3);
tcg_gen_add_i64(tmp, tmp, vb);
tcg_gen_ext32s_i64(vc, tmp);
tcg_temp_free(tmp);
break;
case 0x1B:
/* S8SUBL */
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 3);
tcg_gen_sub_i64(tmp, tmp, vb);
tcg_gen_ext32s_i64(vc, tmp);
tcg_temp_free(tmp);
break;
case 0x1D:
/* CMPULT */
tcg_gen_setcond_i64(TCG_COND_LTU, vc, va, vb);
break;
case 0x20:
/* ADDQ */
tcg_gen_add_i64(vc, va, vb);
break;
case 0x22:
/* S4ADDQ */
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 2);
tcg_gen_add_i64(vc, tmp, vb);
tcg_temp_free(tmp);
break;
case 0x29:
/* SUBQ */
tcg_gen_sub_i64(vc, va, vb);
break;
case 0x2B:
/* S4SUBQ */
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 2);
tcg_gen_sub_i64(vc, tmp, vb);
tcg_temp_free(tmp);
break;
case 0x2D:
/* CMPEQ */
tcg_gen_setcond_i64(TCG_COND_EQ, vc, va, vb);
break;
case 0x32:
/* S8ADDQ */
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 3);
tcg_gen_add_i64(vc, tmp, vb);
tcg_temp_free(tmp);
break;
case 0x3B:
/* S8SUBQ */
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 3);
tcg_gen_sub_i64(vc, tmp, vb);
tcg_temp_free(tmp);
break;
case 0x3D:
/* CMPULE */
tcg_gen_setcond_i64(TCG_COND_LEU, vc, va, vb);
break;
case 0x40:
/* ADDL/V */
gen_helper_addlv(vc, cpu_env, va, vb);
break;
case 0x49:
/* SUBL/V */
gen_helper_sublv(vc, cpu_env, va, vb);
break;
case 0x4D:
/* CMPLT */
tcg_gen_setcond_i64(TCG_COND_LT, vc, va, vb);
break;
case 0x60:
/* ADDQ/V */
gen_helper_addqv(vc, cpu_env, va, vb);
break;
case 0x69:
/* SUBQ/V */
gen_helper_subqv(vc, cpu_env, va, vb);
break;
case 0x6D:
/* CMPLE */
tcg_gen_setcond_i64(TCG_COND_LE, vc, va, vb);
break;
default:
goto invalid_opc;
}
break;
case 0x11:
if (fn7 == 0x20) {
if (rc == 31) {
/* Special case BIS as NOP. */
break;
}
if (ra == 31) {
/* Special case BIS as MOV. */
vc = dest_gpr(ctx, rc);
if (islit) {
tcg_gen_movi_i64(vc, lit);
} else {
tcg_gen_mov_i64(vc, load_gpr(ctx, rb));
}
break;
}
}
vc = dest_gpr(ctx, rc);
vb = load_gpr_lit(ctx, rb, lit, islit);
if (fn7 == 0x28 && ra == 31) {
/* Special case ORNOT as NOT. */
tcg_gen_not_i64(vc, vb);
break;
}
va = load_gpr(ctx, ra);
switch (fn7) {
case 0x00:
/* AND */
tcg_gen_and_i64(vc, va, vb);
break;
case 0x08:
/* BIC */
tcg_gen_andc_i64(vc, va, vb);
break;
case 0x14:
/* CMOVLBS */
tmp = tcg_temp_new();
tcg_gen_andi_i64(tmp, va, 1);
tcg_gen_movcond_i64(TCG_COND_NE, vc, tmp, load_zero(ctx),
vb, load_gpr(ctx, rc));
tcg_temp_free(tmp);
break;
case 0x16:
/* CMOVLBC */
tmp = tcg_temp_new();
tcg_gen_andi_i64(tmp, va, 1);
tcg_gen_movcond_i64(TCG_COND_EQ, vc, tmp, load_zero(ctx),
vb, load_gpr(ctx, rc));
tcg_temp_free(tmp);
break;
case 0x20:
/* BIS */
tcg_gen_or_i64(vc, va, vb);
break;
case 0x24:
/* CMOVEQ */
tcg_gen_movcond_i64(TCG_COND_EQ, vc, va, load_zero(ctx),
vb, load_gpr(ctx, rc));
break;
case 0x26:
/* CMOVNE */
tcg_gen_movcond_i64(TCG_COND_NE, vc, va, load_zero(ctx),
vb, load_gpr(ctx, rc));
break;
case 0x28:
/* ORNOT */
tcg_gen_orc_i64(vc, va, vb);
break;
case 0x40:
/* XOR */
tcg_gen_xor_i64(vc, va, vb);
break;
case 0x44:
/* CMOVLT */
tcg_gen_movcond_i64(TCG_COND_LT, vc, va, load_zero(ctx),
vb, load_gpr(ctx, rc));
break;
case 0x46:
/* CMOVGE */
tcg_gen_movcond_i64(TCG_COND_GE, vc, va, load_zero(ctx),
vb, load_gpr(ctx, rc));
break;
case 0x48:
/* EQV */
tcg_gen_eqv_i64(vc, va, vb);
break;
case 0x61:
/* AMASK */
REQUIRE_REG_31(ra);
{
uint64_t amask = ctx->tb->flags >> TB_FLAGS_AMASK_SHIFT;
tcg_gen_andi_i64(vc, vb, ~amask);
}
break;
case 0x64:
/* CMOVLE */
tcg_gen_movcond_i64(TCG_COND_LE, vc, va, load_zero(ctx),
vb, load_gpr(ctx, rc));
break;
case 0x66:
/* CMOVGT */
tcg_gen_movcond_i64(TCG_COND_GT, vc, va, load_zero(ctx),
vb, load_gpr(ctx, rc));
break;
case 0x6C:
/* IMPLVER */
REQUIRE_REG_31(ra);
tcg_gen_movi_i64(vc, ctx->implver);
break;
default:
goto invalid_opc;
}
break;
case 0x12:
vc = dest_gpr(ctx, rc);
va = load_gpr(ctx, ra);
switch (fn7) {
case 0x02:
/* MSKBL */
gen_msk_l(ctx, vc, va, rb, islit, lit, 0x01);
break;
case 0x06:
/* EXTBL */
gen_ext_l(ctx, vc, va, rb, islit, lit, 0x01);
break;
case 0x0B:
/* INSBL */
gen_ins_l(ctx, vc, va, rb, islit, lit, 0x01);
break;
case 0x12:
/* MSKWL */
gen_msk_l(ctx, vc, va, rb, islit, lit, 0x03);
break;
case 0x16:
/* EXTWL */
gen_ext_l(ctx, vc, va, rb, islit, lit, 0x03);
break;
case 0x1B:
/* INSWL */
gen_ins_l(ctx, vc, va, rb, islit, lit, 0x03);
break;
case 0x22:
/* MSKLL */
gen_msk_l(ctx, vc, va, rb, islit, lit, 0x0f);
break;
case 0x26:
/* EXTLL */
gen_ext_l(ctx, vc, va, rb, islit, lit, 0x0f);
break;
case 0x2B:
/* INSLL */
gen_ins_l(ctx, vc, va, rb, islit, lit, 0x0f);
break;
case 0x30:
/* ZAP */
if (islit) {
gen_zapnoti(vc, va, ~lit);
} else {
gen_helper_zap(vc, va, load_gpr(ctx, rb));
}
break;
case 0x31:
/* ZAPNOT */
if (islit) {
gen_zapnoti(vc, va, lit);
} else {
gen_helper_zapnot(vc, va, load_gpr(ctx, rb));
}
break;
case 0x32:
/* MSKQL */
gen_msk_l(ctx, vc, va, rb, islit, lit, 0xff);
break;
case 0x34:
/* SRL */
if (islit) {
tcg_gen_shri_i64(vc, va, lit & 0x3f);
} else {
tmp = tcg_temp_new();
vb = load_gpr(ctx, rb);
tcg_gen_andi_i64(tmp, vb, 0x3f);
tcg_gen_shr_i64(vc, va, tmp);
tcg_temp_free(tmp);
}
break;
case 0x36:
/* EXTQL */
gen_ext_l(ctx, vc, va, rb, islit, lit, 0xff);
break;
case 0x39:
/* SLL */
if (islit) {
tcg_gen_shli_i64(vc, va, lit & 0x3f);
} else {
tmp = tcg_temp_new();
vb = load_gpr(ctx, rb);
tcg_gen_andi_i64(tmp, vb, 0x3f);
tcg_gen_shl_i64(vc, va, tmp);
tcg_temp_free(tmp);
}
break;
case 0x3B:
/* INSQL */
gen_ins_l(ctx, vc, va, rb, islit, lit, 0xff);
break;
case 0x3C:
/* SRA */
if (islit) {
tcg_gen_sari_i64(vc, va, lit & 0x3f);
} else {
tmp = tcg_temp_new();
vb = load_gpr(ctx, rb);
tcg_gen_andi_i64(tmp, vb, 0x3f);
tcg_gen_sar_i64(vc, va, tmp);
tcg_temp_free(tmp);
}
break;
case 0x52:
/* MSKWH */
gen_msk_h(ctx, vc, va, rb, islit, lit, 0x03);
break;
case 0x57:
/* INSWH */
gen_ins_h(ctx, vc, va, rb, islit, lit, 0x03);
break;
case 0x5A:
/* EXTWH */
gen_ext_h(ctx, vc, va, rb, islit, lit, 0x03);
break;
case 0x62:
/* MSKLH */
gen_msk_h(ctx, vc, va, rb, islit, lit, 0x0f);
break;
case 0x67:
/* INSLH */
gen_ins_h(ctx, vc, va, rb, islit, lit, 0x0f);
break;
case 0x6A:
/* EXTLH */
gen_ext_h(ctx, vc, va, rb, islit, lit, 0x0f);
break;
case 0x72:
/* MSKQH */
gen_msk_h(ctx, vc, va, rb, islit, lit, 0xff);
break;
case 0x77:
/* INSQH */
gen_ins_h(ctx, vc, va, rb, islit, lit, 0xff);
break;
case 0x7A:
/* EXTQH */
gen_ext_h(ctx, vc, va, rb, islit, lit, 0xff);
break;
default:
goto invalid_opc;
}
break;
case 0x13:
vc = dest_gpr(ctx, rc);
vb = load_gpr_lit(ctx, rb, lit, islit);
va = load_gpr(ctx, ra);
switch (fn7) {
case 0x00:
/* MULL */
tcg_gen_mul_i64(vc, va, vb);
tcg_gen_ext32s_i64(vc, vc);
break;
case 0x20:
/* MULQ */
tcg_gen_mul_i64(vc, va, vb);
break;
case 0x30:
/* UMULH */
tmp = tcg_temp_new();
tcg_gen_mulu2_i64(tmp, vc, va, vb);
tcg_temp_free(tmp);
break;
case 0x40:
/* MULL/V */
gen_helper_mullv(vc, cpu_env, va, vb);
break;
case 0x60:
/* MULQ/V */
gen_helper_mulqv(vc, cpu_env, va, vb);
break;
default:
goto invalid_opc;
}
break;
case 0x14:
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_FIX);
vc = dest_fpr(ctx, rc);
switch (fpfn) { /* fn11 & 0x3F */
case 0x04:
/* ITOFS */
REQUIRE_REG_31(rb);
t32 = tcg_temp_new_i32();
va = load_gpr(ctx, ra);
tcg_gen_trunc_i64_i32(t32, va);
gen_helper_memory_to_s(vc, t32);
tcg_temp_free_i32(t32);
break;
case 0x0A:
/* SQRTF */
REQUIRE_REG_31(ra);
vb = load_fpr(ctx, rb);
gen_helper_sqrtf(vc, cpu_env, vb);
break;
case 0x0B:
/* SQRTS */
REQUIRE_REG_31(ra);
gen_sqrts(ctx, rb, rc, fn11);
break;
case 0x14:
/* ITOFF */
REQUIRE_REG_31(rb);
t32 = tcg_temp_new_i32();
va = load_gpr(ctx, ra);
tcg_gen_trunc_i64_i32(t32, va);
gen_helper_memory_to_f(vc, t32);
tcg_temp_free_i32(t32);
break;
case 0x24:
/* ITOFT */
REQUIRE_REG_31(rb);
va = load_gpr(ctx, ra);
tcg_gen_mov_i64(vc, va);
break;
case 0x2A:
/* SQRTG */
REQUIRE_REG_31(ra);
vb = load_fpr(ctx, rb);
gen_helper_sqrtg(vc, cpu_env, vb);
break;
case 0x02B:
/* SQRTT */
REQUIRE_REG_31(ra);
gen_sqrtt(ctx, rb, rc, fn11);
break;
default:
goto invalid_opc;
}
break;
case 0x15:
/* VAX floating point */
/* XXX: rounding mode and trap are ignored (!) */
vc = dest_fpr(ctx, rc);
vb = load_fpr(ctx, rb);
va = load_fpr(ctx, ra);
switch (fpfn) { /* fn11 & 0x3F */
case 0x00:
/* ADDF */
gen_helper_addf(vc, cpu_env, va, vb);
break;
case 0x01:
/* SUBF */
gen_helper_subf(vc, cpu_env, va, vb);
break;
case 0x02:
/* MULF */
gen_helper_mulf(vc, cpu_env, va, vb);
break;
case 0x03:
/* DIVF */
gen_helper_divf(vc, cpu_env, va, vb);
break;
case 0x1E:
/* CVTDG -- TODO */
REQUIRE_REG_31(ra);
goto invalid_opc;
case 0x20:
/* ADDG */
gen_helper_addg(vc, cpu_env, va, vb);
break;
case 0x21:
/* SUBG */
gen_helper_subg(vc, cpu_env, va, vb);
break;
case 0x22:
/* MULG */
gen_helper_mulg(vc, cpu_env, va, vb);
break;
case 0x23:
/* DIVG */
gen_helper_divg(vc, cpu_env, va, vb);
break;
case 0x25:
/* CMPGEQ */
gen_helper_cmpgeq(vc, cpu_env, va, vb);
break;
case 0x26:
/* CMPGLT */
gen_helper_cmpglt(vc, cpu_env, va, vb);
break;
case 0x27:
/* CMPGLE */
gen_helper_cmpgle(vc, cpu_env, va, vb);
break;
case 0x2C:
/* CVTGF */
REQUIRE_REG_31(ra);
gen_helper_cvtgf(vc, cpu_env, vb);
break;
case 0x2D:
/* CVTGD -- TODO */
REQUIRE_REG_31(ra);
goto invalid_opc;
case 0x2F:
/* CVTGQ */
REQUIRE_REG_31(ra);
gen_helper_cvtgq(vc, cpu_env, vb);
break;
case 0x3C:
/* CVTQF */
REQUIRE_REG_31(ra);
gen_helper_cvtqf(vc, cpu_env, vb);
break;
case 0x3E:
/* CVTQG */
REQUIRE_REG_31(ra);
gen_helper_cvtqg(vc, cpu_env, vb);
break;
default:
goto invalid_opc;
}
break;
case 0x16:
/* IEEE floating-point */
switch (fpfn) { /* fn11 & 0x3F */
case 0x00:
/* ADDS */
gen_adds(ctx, ra, rb, rc, fn11);
break;
case 0x01:
/* SUBS */
gen_subs(ctx, ra, rb, rc, fn11);
break;
case 0x02:
/* MULS */
gen_muls(ctx, ra, rb, rc, fn11);
break;
case 0x03:
/* DIVS */
gen_divs(ctx, ra, rb, rc, fn11);
break;
case 0x20:
/* ADDT */
gen_addt(ctx, ra, rb, rc, fn11);
break;
case 0x21:
/* SUBT */
gen_subt(ctx, ra, rb, rc, fn11);
break;
case 0x22:
/* MULT */
gen_mult(ctx, ra, rb, rc, fn11);
break;
case 0x23:
/* DIVT */
gen_divt(ctx, ra, rb, rc, fn11);
break;
case 0x24:
/* CMPTUN */
gen_cmptun(ctx, ra, rb, rc, fn11);
break;
case 0x25:
/* CMPTEQ */
gen_cmpteq(ctx, ra, rb, rc, fn11);
break;
case 0x26:
/* CMPTLT */
gen_cmptlt(ctx, ra, rb, rc, fn11);
break;
case 0x27:
/* CMPTLE */
gen_cmptle(ctx, ra, rb, rc, fn11);
break;
case 0x2C:
REQUIRE_REG_31(ra);
if (fn11 == 0x2AC || fn11 == 0x6AC) {
/* CVTST */
gen_cvtst(ctx, rb, rc, fn11);
} else {
/* CVTTS */
gen_cvtts(ctx, rb, rc, fn11);
}
break;
case 0x2F:
/* CVTTQ */
REQUIRE_REG_31(ra);
gen_cvttq(ctx, rb, rc, fn11);
break;
case 0x3C:
/* CVTQS */
REQUIRE_REG_31(ra);
gen_cvtqs(ctx, rb, rc, fn11);
break;
case 0x3E:
/* CVTQT */
REQUIRE_REG_31(ra);
gen_cvtqt(ctx, rb, rc, fn11);
break;
default:
goto invalid_opc;
}
break;
case 0x17:
switch (fn11) {
case 0x010:
/* CVTLQ */
REQUIRE_REG_31(ra);
vc = dest_fpr(ctx, rc);
vb = load_fpr(ctx, rb);
gen_cvtlq(vc, vb);
break;
case 0x020:
/* CPYS */
if (rc == 31) {
/* Special case CPYS as FNOP. */
} else {
vc = dest_fpr(ctx, rc);
va = load_fpr(ctx, ra);
if (ra == rb) {
/* Special case CPYS as FMOV. */
tcg_gen_mov_i64(vc, va);
} else {
vb = load_fpr(ctx, rb);
gen_cpy_mask(vc, va, vb, 0, 0x8000000000000000ULL);
}
}
break;
case 0x021:
/* CPYSN */
vc = dest_fpr(ctx, rc);
vb = load_fpr(ctx, rb);
va = load_fpr(ctx, ra);
gen_cpy_mask(vc, va, vb, 1, 0x8000000000000000ULL);
break;
case 0x022:
/* CPYSE */
vc = dest_fpr(ctx, rc);
vb = load_fpr(ctx, rb);
va = load_fpr(ctx, ra);
gen_cpy_mask(vc, va, vb, 0, 0xFFF0000000000000ULL);
break;
case 0x024:
/* MT_FPCR */
va = load_fpr(ctx, ra);
gen_helper_store_fpcr(cpu_env, va);
if (ctx->tb_rm == QUAL_RM_D) {
/* Re-do the copy of the rounding mode to fp_status
the next time we use dynamic rounding. */
ctx->tb_rm = -1;
}
break;
case 0x025:
/* MF_FPCR */
va = dest_fpr(ctx, ra);
gen_helper_load_fpcr(va, cpu_env);
break;
case 0x02A:
/* FCMOVEQ */
gen_fcmov(ctx, TCG_COND_EQ, ra, rb, rc);
break;
case 0x02B:
/* FCMOVNE */
gen_fcmov(ctx, TCG_COND_NE, ra, rb, rc);
break;
case 0x02C:
/* FCMOVLT */
gen_fcmov(ctx, TCG_COND_LT, ra, rb, rc);
break;
case 0x02D:
/* FCMOVGE */
gen_fcmov(ctx, TCG_COND_GE, ra, rb, rc);
break;
case 0x02E:
/* FCMOVLE */
gen_fcmov(ctx, TCG_COND_LE, ra, rb, rc);
break;
case 0x02F:
/* FCMOVGT */
gen_fcmov(ctx, TCG_COND_GT, ra, rb, rc);
break;
case 0x030:
/* CVTQL */
REQUIRE_REG_31(ra);
vc = dest_fpr(ctx, rc);
vb = load_fpr(ctx, rb);
gen_cvtql(vc, vb);
break;
case 0x130:
/* CVTQL/V */
case 0x530:
/* CVTQL/SV */
REQUIRE_REG_31(ra);
/* ??? I'm pretty sure there's nothing that /sv needs to do that
/v doesn't do. The only thing I can think is that /sv is a
valid instruction merely for completeness in the ISA. */
vc = dest_fpr(ctx, rc);
vb = load_fpr(ctx, rb);
gen_helper_cvtql_v_input(cpu_env, vb);
gen_cvtql(vc, vb);
break;
default:
goto invalid_opc;
}
break;
case 0x18:
switch ((uint16_t)disp16) {
case 0x0000:
/* TRAPB */
/* No-op. */
break;
case 0x0400:
/* EXCB */
/* No-op. */
break;
case 0x4000:
/* MB */
/* No-op */
break;
case 0x4400:
/* WMB */
/* No-op */
break;
case 0x8000:
/* FETCH */
/* No-op */
break;
case 0xA000:
/* FETCH_M */
/* No-op */
break;
case 0xC000:
/* RPCC */
va = dest_gpr(ctx, ra);
if (ctx->tb->cflags & CF_USE_ICOUNT) {
gen_io_start();
gen_helper_load_pcc(va, cpu_env);
gen_io_end();
ret = EXIT_PC_STALE;
} else {
gen_helper_load_pcc(va, cpu_env);
}
break;
case 0xE000:
/* RC */
gen_rx(ra, 0);
break;
case 0xE800:
/* ECB */
break;
case 0xF000:
/* RS */
gen_rx(ra, 1);
break;
case 0xF800:
/* WH64 */
/* No-op */
break;
default:
goto invalid_opc;
}
break;
case 0x19:
/* HW_MFPR (PALcode) */
#ifndef CONFIG_USER_ONLY
REQUIRE_TB_FLAG(TB_FLAGS_PAL_MODE);
va = dest_gpr(ctx, ra);
ret = gen_mfpr(ctx, va, insn & 0xffff);
break;
#else
goto invalid_opc;
#endif
case 0x1A:
/* JMP, JSR, RET, JSR_COROUTINE. These only differ by the branch
prediction stack action, which of course we don't implement. */
vb = load_gpr(ctx, rb);
tcg_gen_andi_i64(cpu_pc, vb, ~3);
if (ra != 31) {
tcg_gen_movi_i64(cpu_ir[ra], ctx->pc);
}
ret = EXIT_PC_UPDATED;
break;
case 0x1B:
/* HW_LD (PALcode) */
#ifndef CONFIG_USER_ONLY
REQUIRE_TB_FLAG(TB_FLAGS_PAL_MODE);
{
TCGv addr = tcg_temp_new();
vb = load_gpr(ctx, rb);
va = dest_gpr(ctx, ra);
tcg_gen_addi_i64(addr, vb, disp12);
switch ((insn >> 12) & 0xF) {
case 0x0:
/* Longword physical access (hw_ldl/p) */
gen_helper_ldl_phys(va, cpu_env, addr);
break;
case 0x1:
/* Quadword physical access (hw_ldq/p) */
gen_helper_ldq_phys(va, cpu_env, addr);
break;
case 0x2:
/* Longword physical access with lock (hw_ldl_l/p) */
gen_helper_ldl_l_phys(va, cpu_env, addr);
break;
case 0x3:
/* Quadword physical access with lock (hw_ldq_l/p) */
gen_helper_ldq_l_phys(va, cpu_env, addr);
break;
case 0x4:
/* Longword virtual PTE fetch (hw_ldl/v) */
goto invalid_opc;
case 0x5:
/* Quadword virtual PTE fetch (hw_ldq/v) */
goto invalid_opc;
break;
case 0x6:
/* Incpu_ir[ra]id */
goto invalid_opc;
case 0x7:
/* Incpu_ir[ra]id */
goto invalid_opc;
case 0x8:
/* Longword virtual access (hw_ldl) */
goto invalid_opc;
case 0x9:
/* Quadword virtual access (hw_ldq) */
goto invalid_opc;
case 0xA:
/* Longword virtual access with protection check (hw_ldl/w) */
tcg_gen_qemu_ld_i64(va, addr, MMU_KERNEL_IDX, MO_LESL);
break;
case 0xB:
/* Quadword virtual access with protection check (hw_ldq/w) */
tcg_gen_qemu_ld_i64(va, addr, MMU_KERNEL_IDX, MO_LEQ);
break;
case 0xC:
/* Longword virtual access with alt access mode (hw_ldl/a)*/
goto invalid_opc;
case 0xD:
/* Quadword virtual access with alt access mode (hw_ldq/a) */
goto invalid_opc;
case 0xE:
/* Longword virtual access with alternate access mode and
protection checks (hw_ldl/wa) */
tcg_gen_qemu_ld_i64(va, addr, MMU_USER_IDX, MO_LESL);
break;
case 0xF:
/* Quadword virtual access with alternate access mode and
protection checks (hw_ldq/wa) */
tcg_gen_qemu_ld_i64(va, addr, MMU_USER_IDX, MO_LEQ);
break;
}
tcg_temp_free(addr);
break;
}
#else
goto invalid_opc;
#endif
case 0x1C:
vc = dest_gpr(ctx, rc);
if (fn7 == 0x70) {
/* FTOIT */
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_FIX);
REQUIRE_REG_31(rb);
va = load_fpr(ctx, ra);
tcg_gen_mov_i64(vc, va);
break;
} else if (fn7 == 0x78) {
/* FTOIS */
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_FIX);
REQUIRE_REG_31(rb);
t32 = tcg_temp_new_i32();
va = load_fpr(ctx, ra);
gen_helper_s_to_memory(t32, va);
tcg_gen_ext_i32_i64(vc, t32);
tcg_temp_free_i32(t32);
break;
}
vb = load_gpr_lit(ctx, rb, lit, islit);
switch (fn7) {
case 0x00:
/* SEXTB */
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_BWX);
REQUIRE_REG_31(ra);
tcg_gen_ext8s_i64(vc, vb);
break;
case 0x01:
/* SEXTW */
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_BWX);
REQUIRE_REG_31(ra);
tcg_gen_ext16s_i64(vc, vb);
break;
case 0x30:
/* CTPOP */
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_CIX);
REQUIRE_REG_31(ra);
gen_helper_ctpop(vc, vb);
break;
case 0x31:
/* PERR */
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);
va = load_gpr(ctx, ra);
gen_helper_perr(vc, va, vb);
break;
case 0x32:
/* CTLZ */
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_CIX);
REQUIRE_REG_31(ra);
gen_helper_ctlz(vc, vb);
break;
case 0x33:
/* CTTZ */
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_CIX);
REQUIRE_REG_31(ra);
gen_helper_cttz(vc, vb);
break;
case 0x34:
/* UNPKBW */
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);
REQUIRE_REG_31(ra);
gen_helper_unpkbw(vc, vb);
break;
case 0x35:
/* UNPKBL */
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);
REQUIRE_REG_31(ra);
gen_helper_unpkbl(vc, vb);
break;
case 0x36:
/* PKWB */
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);
REQUIRE_REG_31(ra);
gen_helper_pkwb(vc, vb);
break;
case 0x37:
/* PKLB */
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);
REQUIRE_REG_31(ra);
gen_helper_pklb(vc, vb);
break;
case 0x38:
/* MINSB8 */
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);
va = load_gpr(ctx, ra);
gen_helper_minsb8(vc, va, vb);
break;
case 0x39:
/* MINSW4 */
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);
va = load_gpr(ctx, ra);
gen_helper_minsw4(vc, va, vb);
break;
case 0x3A:
/* MINUB8 */
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);
va = load_gpr(ctx, ra);
gen_helper_minub8(vc, va, vb);
break;
case 0x3B:
/* MINUW4 */
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);
va = load_gpr(ctx, ra);
gen_helper_minuw4(vc, va, vb);
break;
case 0x3C:
/* MAXUB8 */
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);
va = load_gpr(ctx, ra);
gen_helper_maxub8(vc, va, vb);
break;
case 0x3D:
/* MAXUW4 */
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);
va = load_gpr(ctx, ra);
gen_helper_maxuw4(vc, va, vb);
break;
case 0x3E:
/* MAXSB8 */
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);
va = load_gpr(ctx, ra);
gen_helper_maxsb8(vc, va, vb);
break;
case 0x3F:
/* MAXSW4 */
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);
va = load_gpr(ctx, ra);
gen_helper_maxsw4(vc, va, vb);
break;
default:
goto invalid_opc;
}
break;
case 0x1D:
/* HW_MTPR (PALcode) */
#ifndef CONFIG_USER_ONLY
REQUIRE_TB_FLAG(TB_FLAGS_PAL_MODE);
vb = load_gpr(ctx, rb);
ret = gen_mtpr(ctx, vb, insn & 0xffff);
break;
#else
goto invalid_opc;
#endif
case 0x1E:
/* HW_RET (PALcode) */
#ifndef CONFIG_USER_ONLY
REQUIRE_TB_FLAG(TB_FLAGS_PAL_MODE);
if (rb == 31) {
/* Pre-EV6 CPUs interpreted this as HW_REI, loading the return
address from EXC_ADDR. This turns out to be useful for our
emulation PALcode, so continue to accept it. */
tmp = tcg_temp_new();
tcg_gen_ld_i64(tmp, cpu_env, offsetof(CPUAlphaState, exc_addr));
gen_helper_hw_ret(cpu_env, tmp);
tcg_temp_free(tmp);
} else {
gen_helper_hw_ret(cpu_env, load_gpr(ctx, rb));
}
ret = EXIT_PC_UPDATED;
break;
#else
goto invalid_opc;
#endif
case 0x1F:
/* HW_ST (PALcode) */
#ifndef CONFIG_USER_ONLY
REQUIRE_TB_FLAG(TB_FLAGS_PAL_MODE);
{
TCGv addr = tcg_temp_new();
va = load_gpr(ctx, ra);
vb = load_gpr(ctx, rb);
tcg_gen_addi_i64(addr, vb, disp12);
switch ((insn >> 12) & 0xF) {
case 0x0:
/* Longword physical access */
gen_helper_stl_phys(cpu_env, addr, va);
break;
case 0x1:
/* Quadword physical access */
gen_helper_stq_phys(cpu_env, addr, va);
break;
case 0x2:
/* Longword physical access with lock */
gen_helper_stl_c_phys(dest_gpr(ctx, ra), cpu_env, addr, va);
break;
case 0x3:
/* Quadword physical access with lock */
gen_helper_stq_c_phys(dest_gpr(ctx, ra), cpu_env, addr, va);
break;
case 0x4:
/* Longword virtual access */
goto invalid_opc;
case 0x5:
/* Quadword virtual access */
goto invalid_opc;
case 0x6:
/* Invalid */
goto invalid_opc;
case 0x7:
/* Invalid */
goto invalid_opc;
case 0x8:
/* Invalid */
goto invalid_opc;
case 0x9:
/* Invalid */
goto invalid_opc;
case 0xA:
/* Invalid */
goto invalid_opc;
case 0xB:
/* Invalid */
goto invalid_opc;
case 0xC:
/* Longword virtual access with alternate access mode */
goto invalid_opc;
case 0xD:
/* Quadword virtual access with alternate access mode */
goto invalid_opc;
case 0xE:
/* Invalid */
goto invalid_opc;
case 0xF:
/* Invalid */
goto invalid_opc;
}
tcg_temp_free(addr);
break;
}
#else
goto invalid_opc;
#endif
case 0x20:
/* LDF */
gen_load_mem(ctx, &gen_qemu_ldf, ra, rb, disp16, 1, 0);
break;
case 0x21:
/* LDG */
gen_load_mem(ctx, &gen_qemu_ldg, ra, rb, disp16, 1, 0);
break;
case 0x22:
/* LDS */
gen_load_mem(ctx, &gen_qemu_lds, ra, rb, disp16, 1, 0);
break;
case 0x23:
/* LDT */
gen_load_mem(ctx, &tcg_gen_qemu_ld64, ra, rb, disp16, 1, 0);
break;
case 0x24:
/* STF */
gen_store_mem(ctx, &gen_qemu_stf, ra, rb, disp16, 1, 0);
break;
case 0x25:
/* STG */
gen_store_mem(ctx, &gen_qemu_stg, ra, rb, disp16, 1, 0);
break;
case 0x26:
/* STS */
gen_store_mem(ctx, &gen_qemu_sts, ra, rb, disp16, 1, 0);
break;
case 0x27:
/* STT */
gen_store_mem(ctx, &tcg_gen_qemu_st64, ra, rb, disp16, 1, 0);
break;
case 0x28:
/* LDL */
gen_load_mem(ctx, &tcg_gen_qemu_ld32s, ra, rb, disp16, 0, 0);
break;
case 0x29:
/* LDQ */
gen_load_mem(ctx, &tcg_gen_qemu_ld64, ra, rb, disp16, 0, 0);
break;
case 0x2A:
/* LDL_L */
gen_load_mem(ctx, &gen_qemu_ldl_l, ra, rb, disp16, 0, 0);
break;
case 0x2B:
/* LDQ_L */
gen_load_mem(ctx, &gen_qemu_ldq_l, ra, rb, disp16, 0, 0);
break;
case 0x2C:
/* STL */
gen_store_mem(ctx, &tcg_gen_qemu_st32, ra, rb, disp16, 0, 0);
break;
case 0x2D:
/* STQ */
gen_store_mem(ctx, &tcg_gen_qemu_st64, ra, rb, disp16, 0, 0);
break;
case 0x2E:
/* STL_C */
ret = gen_store_conditional(ctx, ra, rb, disp16, 0);
break;
case 0x2F:
/* STQ_C */
ret = gen_store_conditional(ctx, ra, rb, disp16, 1);
break;
case 0x30:
/* BR */
ret = gen_bdirect(ctx, ra, disp21);
break;
case 0x31: /* FBEQ */
ret = gen_fbcond(ctx, TCG_COND_EQ, ra, disp21);
break;
case 0x32: /* FBLT */
ret = gen_fbcond(ctx, TCG_COND_LT, ra, disp21);
break;
case 0x33: /* FBLE */
ret = gen_fbcond(ctx, TCG_COND_LE, ra, disp21);
break;
case 0x34:
/* BSR */
ret = gen_bdirect(ctx, ra, disp21);
break;
case 0x35: /* FBNE */
ret = gen_fbcond(ctx, TCG_COND_NE, ra, disp21);
break;
case 0x36: /* FBGE */
ret = gen_fbcond(ctx, TCG_COND_GE, ra, disp21);
break;
case 0x37: /* FBGT */
ret = gen_fbcond(ctx, TCG_COND_GT, ra, disp21);
break;
case 0x38:
/* BLBC */
ret = gen_bcond(ctx, TCG_COND_EQ, ra, disp21, 1);
break;
case 0x39:
/* BEQ */
ret = gen_bcond(ctx, TCG_COND_EQ, ra, disp21, 0);
break;
case 0x3A:
/* BLT */
ret = gen_bcond(ctx, TCG_COND_LT, ra, disp21, 0);
break;
case 0x3B:
/* BLE */
ret = gen_bcond(ctx, TCG_COND_LE, ra, disp21, 0);
break;
case 0x3C:
/* BLBS */
ret = gen_bcond(ctx, TCG_COND_NE, ra, disp21, 1);
break;
case 0x3D:
/* BNE */
ret = gen_bcond(ctx, TCG_COND_NE, ra, disp21, 0);
break;
case 0x3E:
/* BGE */
ret = gen_bcond(ctx, TCG_COND_GE, ra, disp21, 0);
break;
case 0x3F:
/* BGT */
ret = gen_bcond(ctx, TCG_COND_GT, ra, disp21, 0);
break;
invalid_opc:
ret = gen_invalid(ctx);
break;
}
return ret;
}
| true | qemu | 4d1628e832dfc6ec02b0d196f6cc250aaa7bf3b3 | static ExitStatus translate_one(DisasContext *ctx, uint32_t insn)
{
int32_t disp21, disp16, disp12 __attribute__((unused));
uint16_t fn11;
uint8_t opc, ra, rb, rc, fpfn, fn7, lit;
bool islit;
TCGv va, vb, vc, tmp;
TCGv_i32 t32;
ExitStatus ret;
opc = extract32(insn, 26, 6);
ra = extract32(insn, 21, 5);
rb = extract32(insn, 16, 5);
rc = extract32(insn, 0, 5);
islit = extract32(insn, 12, 1);
lit = extract32(insn, 13, 8);
disp21 = sextract32(insn, 0, 21);
disp16 = sextract32(insn, 0, 16);
disp12 = sextract32(insn, 0, 12);
fn11 = extract32(insn, 5, 11);
fpfn = extract32(insn, 5, 6);
fn7 = extract32(insn, 5, 7);
if (rb == 31 && !islit) {
islit = true;
lit = 0;
}
ret = NO_EXIT;
switch (opc) {
case 0x00:
ret = gen_call_pal(ctx, insn & 0x03ffffff);
break;
case 0x01:
goto invalid_opc;
case 0x02:
goto invalid_opc;
case 0x03:
goto invalid_opc;
case 0x04:
goto invalid_opc;
case 0x05:
goto invalid_opc;
case 0x06:
goto invalid_opc;
case 0x07:
goto invalid_opc;
case 0x09:
disp16 = (uint32_t)disp16 << 16;
case 0x08:
va = dest_gpr(ctx, ra);
if (rb == 31) {
tcg_gen_movi_i64(va, disp16);
} else {
tcg_gen_addi_i64(va, load_gpr(ctx, rb), disp16);
}
break;
case 0x0A:
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_BWX);
gen_load_mem(ctx, &tcg_gen_qemu_ld8u, ra, rb, disp16, 0, 0);
break;
case 0x0B:
gen_load_mem(ctx, &tcg_gen_qemu_ld64, ra, rb, disp16, 0, 1);
break;
case 0x0C:
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_BWX);
gen_load_mem(ctx, &tcg_gen_qemu_ld16u, ra, rb, disp16, 0, 0);
break;
case 0x0D:
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_BWX);
gen_store_mem(ctx, &tcg_gen_qemu_st16, ra, rb, disp16, 0, 0);
break;
case 0x0E:
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_BWX);
gen_store_mem(ctx, &tcg_gen_qemu_st8, ra, rb, disp16, 0, 0);
break;
case 0x0F:
gen_store_mem(ctx, &tcg_gen_qemu_st64, ra, rb, disp16, 0, 1);
break;
case 0x10:
vc = dest_gpr(ctx, rc);
vb = load_gpr_lit(ctx, rb, lit, islit);
if (ra == 31) {
if (fn7 == 0x00) {
tcg_gen_ext32s_i64(vc, vb);
break;
}
if (fn7 == 0x29) {
tcg_gen_neg_i64(vc, vb);
break;
}
}
va = load_gpr(ctx, ra);
switch (fn7) {
case 0x00:
tcg_gen_add_i64(vc, va, vb);
tcg_gen_ext32s_i64(vc, vc);
break;
case 0x02:
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 2);
tcg_gen_add_i64(tmp, tmp, vb);
tcg_gen_ext32s_i64(vc, tmp);
tcg_temp_free(tmp);
break;
case 0x09:
tcg_gen_sub_i64(vc, va, vb);
tcg_gen_ext32s_i64(vc, vc);
break;
case 0x0B:
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 2);
tcg_gen_sub_i64(tmp, tmp, vb);
tcg_gen_ext32s_i64(vc, tmp);
tcg_temp_free(tmp);
break;
case 0x0F:
gen_helper_cmpbge(vc, va, vb);
break;
case 0x12:
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 3);
tcg_gen_add_i64(tmp, tmp, vb);
tcg_gen_ext32s_i64(vc, tmp);
tcg_temp_free(tmp);
break;
case 0x1B:
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 3);
tcg_gen_sub_i64(tmp, tmp, vb);
tcg_gen_ext32s_i64(vc, tmp);
tcg_temp_free(tmp);
break;
case 0x1D:
tcg_gen_setcond_i64(TCG_COND_LTU, vc, va, vb);
break;
case 0x20:
tcg_gen_add_i64(vc, va, vb);
break;
case 0x22:
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 2);
tcg_gen_add_i64(vc, tmp, vb);
tcg_temp_free(tmp);
break;
case 0x29:
tcg_gen_sub_i64(vc, va, vb);
break;
case 0x2B:
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 2);
tcg_gen_sub_i64(vc, tmp, vb);
tcg_temp_free(tmp);
break;
case 0x2D:
tcg_gen_setcond_i64(TCG_COND_EQ, vc, va, vb);
break;
case 0x32:
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 3);
tcg_gen_add_i64(vc, tmp, vb);
tcg_temp_free(tmp);
break;
case 0x3B:
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 3);
tcg_gen_sub_i64(vc, tmp, vb);
tcg_temp_free(tmp);
break;
case 0x3D:
tcg_gen_setcond_i64(TCG_COND_LEU, vc, va, vb);
break;
case 0x40:
gen_helper_addlv(vc, cpu_env, va, vb);
break;
case 0x49:
gen_helper_sublv(vc, cpu_env, va, vb);
break;
case 0x4D:
tcg_gen_setcond_i64(TCG_COND_LT, vc, va, vb);
break;
case 0x60:
gen_helper_addqv(vc, cpu_env, va, vb);
break;
case 0x69:
gen_helper_subqv(vc, cpu_env, va, vb);
break;
case 0x6D:
tcg_gen_setcond_i64(TCG_COND_LE, vc, va, vb);
break;
default:
goto invalid_opc;
}
break;
case 0x11:
if (fn7 == 0x20) {
if (rc == 31) {
break;
}
if (ra == 31) {
vc = dest_gpr(ctx, rc);
if (islit) {
tcg_gen_movi_i64(vc, lit);
} else {
tcg_gen_mov_i64(vc, load_gpr(ctx, rb));
}
break;
}
}
vc = dest_gpr(ctx, rc);
vb = load_gpr_lit(ctx, rb, lit, islit);
if (fn7 == 0x28 && ra == 31) {
tcg_gen_not_i64(vc, vb);
break;
}
va = load_gpr(ctx, ra);
switch (fn7) {
case 0x00:
tcg_gen_and_i64(vc, va, vb);
break;
case 0x08:
tcg_gen_andc_i64(vc, va, vb);
break;
case 0x14:
tmp = tcg_temp_new();
tcg_gen_andi_i64(tmp, va, 1);
tcg_gen_movcond_i64(TCG_COND_NE, vc, tmp, load_zero(ctx),
vb, load_gpr(ctx, rc));
tcg_temp_free(tmp);
break;
case 0x16:
tmp = tcg_temp_new();
tcg_gen_andi_i64(tmp, va, 1);
tcg_gen_movcond_i64(TCG_COND_EQ, vc, tmp, load_zero(ctx),
vb, load_gpr(ctx, rc));
tcg_temp_free(tmp);
break;
case 0x20:
tcg_gen_or_i64(vc, va, vb);
break;
case 0x24:
tcg_gen_movcond_i64(TCG_COND_EQ, vc, va, load_zero(ctx),
vb, load_gpr(ctx, rc));
break;
case 0x26:
tcg_gen_movcond_i64(TCG_COND_NE, vc, va, load_zero(ctx),
vb, load_gpr(ctx, rc));
break;
case 0x28:
tcg_gen_orc_i64(vc, va, vb);
break;
case 0x40:
tcg_gen_xor_i64(vc, va, vb);
break;
case 0x44:
tcg_gen_movcond_i64(TCG_COND_LT, vc, va, load_zero(ctx),
vb, load_gpr(ctx, rc));
break;
case 0x46:
tcg_gen_movcond_i64(TCG_COND_GE, vc, va, load_zero(ctx),
vb, load_gpr(ctx, rc));
break;
case 0x48:
tcg_gen_eqv_i64(vc, va, vb);
break;
case 0x61:
REQUIRE_REG_31(ra);
{
uint64_t amask = ctx->tb->flags >> TB_FLAGS_AMASK_SHIFT;
tcg_gen_andi_i64(vc, vb, ~amask);
}
break;
case 0x64:
tcg_gen_movcond_i64(TCG_COND_LE, vc, va, load_zero(ctx),
vb, load_gpr(ctx, rc));
break;
case 0x66:
tcg_gen_movcond_i64(TCG_COND_GT, vc, va, load_zero(ctx),
vb, load_gpr(ctx, rc));
break;
case 0x6C:
REQUIRE_REG_31(ra);
tcg_gen_movi_i64(vc, ctx->implver);
break;
default:
goto invalid_opc;
}
break;
case 0x12:
vc = dest_gpr(ctx, rc);
va = load_gpr(ctx, ra);
switch (fn7) {
case 0x02:
gen_msk_l(ctx, vc, va, rb, islit, lit, 0x01);
break;
case 0x06:
gen_ext_l(ctx, vc, va, rb, islit, lit, 0x01);
break;
case 0x0B:
gen_ins_l(ctx, vc, va, rb, islit, lit, 0x01);
break;
case 0x12:
gen_msk_l(ctx, vc, va, rb, islit, lit, 0x03);
break;
case 0x16:
gen_ext_l(ctx, vc, va, rb, islit, lit, 0x03);
break;
case 0x1B:
gen_ins_l(ctx, vc, va, rb, islit, lit, 0x03);
break;
case 0x22:
gen_msk_l(ctx, vc, va, rb, islit, lit, 0x0f);
break;
case 0x26:
gen_ext_l(ctx, vc, va, rb, islit, lit, 0x0f);
break;
case 0x2B:
gen_ins_l(ctx, vc, va, rb, islit, lit, 0x0f);
break;
case 0x30:
if (islit) {
gen_zapnoti(vc, va, ~lit);
} else {
gen_helper_zap(vc, va, load_gpr(ctx, rb));
}
break;
case 0x31:
if (islit) {
gen_zapnoti(vc, va, lit);
} else {
gen_helper_zapnot(vc, va, load_gpr(ctx, rb));
}
break;
case 0x32:
gen_msk_l(ctx, vc, va, rb, islit, lit, 0xff);
break;
case 0x34:
if (islit) {
tcg_gen_shri_i64(vc, va, lit & 0x3f);
} else {
tmp = tcg_temp_new();
vb = load_gpr(ctx, rb);
tcg_gen_andi_i64(tmp, vb, 0x3f);
tcg_gen_shr_i64(vc, va, tmp);
tcg_temp_free(tmp);
}
break;
case 0x36:
gen_ext_l(ctx, vc, va, rb, islit, lit, 0xff);
break;
case 0x39:
if (islit) {
tcg_gen_shli_i64(vc, va, lit & 0x3f);
} else {
tmp = tcg_temp_new();
vb = load_gpr(ctx, rb);
tcg_gen_andi_i64(tmp, vb, 0x3f);
tcg_gen_shl_i64(vc, va, tmp);
tcg_temp_free(tmp);
}
break;
case 0x3B:
gen_ins_l(ctx, vc, va, rb, islit, lit, 0xff);
break;
case 0x3C:
if (islit) {
tcg_gen_sari_i64(vc, va, lit & 0x3f);
} else {
tmp = tcg_temp_new();
vb = load_gpr(ctx, rb);
tcg_gen_andi_i64(tmp, vb, 0x3f);
tcg_gen_sar_i64(vc, va, tmp);
tcg_temp_free(tmp);
}
break;
case 0x52:
gen_msk_h(ctx, vc, va, rb, islit, lit, 0x03);
break;
case 0x57:
gen_ins_h(ctx, vc, va, rb, islit, lit, 0x03);
break;
case 0x5A:
gen_ext_h(ctx, vc, va, rb, islit, lit, 0x03);
break;
case 0x62:
gen_msk_h(ctx, vc, va, rb, islit, lit, 0x0f);
break;
case 0x67:
gen_ins_h(ctx, vc, va, rb, islit, lit, 0x0f);
break;
case 0x6A:
gen_ext_h(ctx, vc, va, rb, islit, lit, 0x0f);
break;
case 0x72:
gen_msk_h(ctx, vc, va, rb, islit, lit, 0xff);
break;
case 0x77:
gen_ins_h(ctx, vc, va, rb, islit, lit, 0xff);
break;
case 0x7A:
gen_ext_h(ctx, vc, va, rb, islit, lit, 0xff);
break;
default:
goto invalid_opc;
}
break;
case 0x13:
vc = dest_gpr(ctx, rc);
vb = load_gpr_lit(ctx, rb, lit, islit);
va = load_gpr(ctx, ra);
switch (fn7) {
case 0x00:
tcg_gen_mul_i64(vc, va, vb);
tcg_gen_ext32s_i64(vc, vc);
break;
case 0x20:
tcg_gen_mul_i64(vc, va, vb);
break;
case 0x30:
tmp = tcg_temp_new();
tcg_gen_mulu2_i64(tmp, vc, va, vb);
tcg_temp_free(tmp);
break;
case 0x40:
gen_helper_mullv(vc, cpu_env, va, vb);
break;
case 0x60:
gen_helper_mulqv(vc, cpu_env, va, vb);
break;
default:
goto invalid_opc;
}
break;
case 0x14:
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_FIX);
vc = dest_fpr(ctx, rc);
switch (fpfn) {
case 0x04:
REQUIRE_REG_31(rb);
t32 = tcg_temp_new_i32();
va = load_gpr(ctx, ra);
tcg_gen_trunc_i64_i32(t32, va);
gen_helper_memory_to_s(vc, t32);
tcg_temp_free_i32(t32);
break;
case 0x0A:
REQUIRE_REG_31(ra);
vb = load_fpr(ctx, rb);
gen_helper_sqrtf(vc, cpu_env, vb);
break;
case 0x0B:
REQUIRE_REG_31(ra);
gen_sqrts(ctx, rb, rc, fn11);
break;
case 0x14:
REQUIRE_REG_31(rb);
t32 = tcg_temp_new_i32();
va = load_gpr(ctx, ra);
tcg_gen_trunc_i64_i32(t32, va);
gen_helper_memory_to_f(vc, t32);
tcg_temp_free_i32(t32);
break;
case 0x24:
REQUIRE_REG_31(rb);
va = load_gpr(ctx, ra);
tcg_gen_mov_i64(vc, va);
break;
case 0x2A:
REQUIRE_REG_31(ra);
vb = load_fpr(ctx, rb);
gen_helper_sqrtg(vc, cpu_env, vb);
break;
case 0x02B:
REQUIRE_REG_31(ra);
gen_sqrtt(ctx, rb, rc, fn11);
break;
default:
goto invalid_opc;
}
break;
case 0x15:
vc = dest_fpr(ctx, rc);
vb = load_fpr(ctx, rb);
va = load_fpr(ctx, ra);
switch (fpfn) {
case 0x00:
gen_helper_addf(vc, cpu_env, va, vb);
break;
case 0x01:
gen_helper_subf(vc, cpu_env, va, vb);
break;
case 0x02:
gen_helper_mulf(vc, cpu_env, va, vb);
break;
case 0x03:
gen_helper_divf(vc, cpu_env, va, vb);
break;
case 0x1E:
REQUIRE_REG_31(ra);
goto invalid_opc;
case 0x20:
gen_helper_addg(vc, cpu_env, va, vb);
break;
case 0x21:
gen_helper_subg(vc, cpu_env, va, vb);
break;
case 0x22:
gen_helper_mulg(vc, cpu_env, va, vb);
break;
case 0x23:
gen_helper_divg(vc, cpu_env, va, vb);
break;
case 0x25:
gen_helper_cmpgeq(vc, cpu_env, va, vb);
break;
case 0x26:
gen_helper_cmpglt(vc, cpu_env, va, vb);
break;
case 0x27:
gen_helper_cmpgle(vc, cpu_env, va, vb);
break;
case 0x2C:
REQUIRE_REG_31(ra);
gen_helper_cvtgf(vc, cpu_env, vb);
break;
case 0x2D:
REQUIRE_REG_31(ra);
goto invalid_opc;
case 0x2F:
REQUIRE_REG_31(ra);
gen_helper_cvtgq(vc, cpu_env, vb);
break;
case 0x3C:
REQUIRE_REG_31(ra);
gen_helper_cvtqf(vc, cpu_env, vb);
break;
case 0x3E:
REQUIRE_REG_31(ra);
gen_helper_cvtqg(vc, cpu_env, vb);
break;
default:
goto invalid_opc;
}
break;
case 0x16:
switch (fpfn) {
case 0x00:
gen_adds(ctx, ra, rb, rc, fn11);
break;
case 0x01:
gen_subs(ctx, ra, rb, rc, fn11);
break;
case 0x02:
gen_muls(ctx, ra, rb, rc, fn11);
break;
case 0x03:
gen_divs(ctx, ra, rb, rc, fn11);
break;
case 0x20:
gen_addt(ctx, ra, rb, rc, fn11);
break;
case 0x21:
gen_subt(ctx, ra, rb, rc, fn11);
break;
case 0x22:
gen_mult(ctx, ra, rb, rc, fn11);
break;
case 0x23:
gen_divt(ctx, ra, rb, rc, fn11);
break;
case 0x24:
gen_cmptun(ctx, ra, rb, rc, fn11);
break;
case 0x25:
gen_cmpteq(ctx, ra, rb, rc, fn11);
break;
case 0x26:
gen_cmptlt(ctx, ra, rb, rc, fn11);
break;
case 0x27:
gen_cmptle(ctx, ra, rb, rc, fn11);
break;
case 0x2C:
REQUIRE_REG_31(ra);
if (fn11 == 0x2AC || fn11 == 0x6AC) {
gen_cvtst(ctx, rb, rc, fn11);
} else {
gen_cvtts(ctx, rb, rc, fn11);
}
break;
case 0x2F:
REQUIRE_REG_31(ra);
gen_cvttq(ctx, rb, rc, fn11);
break;
case 0x3C:
REQUIRE_REG_31(ra);
gen_cvtqs(ctx, rb, rc, fn11);
break;
case 0x3E:
REQUIRE_REG_31(ra);
gen_cvtqt(ctx, rb, rc, fn11);
break;
default:
goto invalid_opc;
}
break;
case 0x17:
switch (fn11) {
case 0x010:
REQUIRE_REG_31(ra);
vc = dest_fpr(ctx, rc);
vb = load_fpr(ctx, rb);
gen_cvtlq(vc, vb);
break;
case 0x020:
if (rc == 31) {
} else {
vc = dest_fpr(ctx, rc);
va = load_fpr(ctx, ra);
if (ra == rb) {
tcg_gen_mov_i64(vc, va);
} else {
vb = load_fpr(ctx, rb);
gen_cpy_mask(vc, va, vb, 0, 0x8000000000000000ULL);
}
}
break;
case 0x021:
vc = dest_fpr(ctx, rc);
vb = load_fpr(ctx, rb);
va = load_fpr(ctx, ra);
gen_cpy_mask(vc, va, vb, 1, 0x8000000000000000ULL);
break;
case 0x022:
vc = dest_fpr(ctx, rc);
vb = load_fpr(ctx, rb);
va = load_fpr(ctx, ra);
gen_cpy_mask(vc, va, vb, 0, 0xFFF0000000000000ULL);
break;
case 0x024:
va = load_fpr(ctx, ra);
gen_helper_store_fpcr(cpu_env, va);
if (ctx->tb_rm == QUAL_RM_D) {
ctx->tb_rm = -1;
}
break;
case 0x025:
va = dest_fpr(ctx, ra);
gen_helper_load_fpcr(va, cpu_env);
break;
case 0x02A:
gen_fcmov(ctx, TCG_COND_EQ, ra, rb, rc);
break;
case 0x02B:
gen_fcmov(ctx, TCG_COND_NE, ra, rb, rc);
break;
case 0x02C:
gen_fcmov(ctx, TCG_COND_LT, ra, rb, rc);
break;
case 0x02D:
gen_fcmov(ctx, TCG_COND_GE, ra, rb, rc);
break;
case 0x02E:
gen_fcmov(ctx, TCG_COND_LE, ra, rb, rc);
break;
case 0x02F:
gen_fcmov(ctx, TCG_COND_GT, ra, rb, rc);
break;
case 0x030:
REQUIRE_REG_31(ra);
vc = dest_fpr(ctx, rc);
vb = load_fpr(ctx, rb);
gen_cvtql(vc, vb);
break;
case 0x130:
case 0x530:
REQUIRE_REG_31(ra);
vc = dest_fpr(ctx, rc);
vb = load_fpr(ctx, rb);
gen_helper_cvtql_v_input(cpu_env, vb);
gen_cvtql(vc, vb);
break;
default:
goto invalid_opc;
}
break;
case 0x18:
switch ((uint16_t)disp16) {
case 0x0000:
break;
case 0x0400:
break;
case 0x4000:
break;
case 0x4400:
break;
case 0x8000:
break;
case 0xA000:
break;
case 0xC000:
va = dest_gpr(ctx, ra);
if (ctx->tb->cflags & CF_USE_ICOUNT) {
gen_io_start();
gen_helper_load_pcc(va, cpu_env);
gen_io_end();
ret = EXIT_PC_STALE;
} else {
gen_helper_load_pcc(va, cpu_env);
}
break;
case 0xE000:
gen_rx(ra, 0);
break;
case 0xE800:
break;
case 0xF000:
gen_rx(ra, 1);
break;
case 0xF800:
break;
default:
goto invalid_opc;
}
break;
case 0x19:
#ifndef CONFIG_USER_ONLY
REQUIRE_TB_FLAG(TB_FLAGS_PAL_MODE);
va = dest_gpr(ctx, ra);
ret = gen_mfpr(ctx, va, insn & 0xffff);
break;
#else
goto invalid_opc;
#endif
case 0x1A:
vb = load_gpr(ctx, rb);
tcg_gen_andi_i64(cpu_pc, vb, ~3);
if (ra != 31) {
tcg_gen_movi_i64(cpu_ir[ra], ctx->pc);
}
ret = EXIT_PC_UPDATED;
break;
case 0x1B:
#ifndef CONFIG_USER_ONLY
REQUIRE_TB_FLAG(TB_FLAGS_PAL_MODE);
{
TCGv addr = tcg_temp_new();
vb = load_gpr(ctx, rb);
va = dest_gpr(ctx, ra);
tcg_gen_addi_i64(addr, vb, disp12);
switch ((insn >> 12) & 0xF) {
case 0x0:
gen_helper_ldl_phys(va, cpu_env, addr);
break;
case 0x1:
gen_helper_ldq_phys(va, cpu_env, addr);
break;
case 0x2:
gen_helper_ldl_l_phys(va, cpu_env, addr);
break;
case 0x3:
gen_helper_ldq_l_phys(va, cpu_env, addr);
break;
case 0x4:
goto invalid_opc;
case 0x5:
goto invalid_opc;
break;
case 0x6:
goto invalid_opc;
case 0x7:
goto invalid_opc;
case 0x8:
goto invalid_opc;
case 0x9:
goto invalid_opc;
case 0xA:
tcg_gen_qemu_ld_i64(va, addr, MMU_KERNEL_IDX, MO_LESL);
break;
case 0xB:
tcg_gen_qemu_ld_i64(va, addr, MMU_KERNEL_IDX, MO_LEQ);
break;
case 0xC:
goto invalid_opc;
case 0xD:
goto invalid_opc;
case 0xE:
tcg_gen_qemu_ld_i64(va, addr, MMU_USER_IDX, MO_LESL);
break;
case 0xF:
tcg_gen_qemu_ld_i64(va, addr, MMU_USER_IDX, MO_LEQ);
break;
}
tcg_temp_free(addr);
break;
}
#else
goto invalid_opc;
#endif
case 0x1C:
vc = dest_gpr(ctx, rc);
if (fn7 == 0x70) {
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_FIX);
REQUIRE_REG_31(rb);
va = load_fpr(ctx, ra);
tcg_gen_mov_i64(vc, va);
break;
} else if (fn7 == 0x78) {
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_FIX);
REQUIRE_REG_31(rb);
t32 = tcg_temp_new_i32();
va = load_fpr(ctx, ra);
gen_helper_s_to_memory(t32, va);
tcg_gen_ext_i32_i64(vc, t32);
tcg_temp_free_i32(t32);
break;
}
vb = load_gpr_lit(ctx, rb, lit, islit);
switch (fn7) {
case 0x00:
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_BWX);
REQUIRE_REG_31(ra);
tcg_gen_ext8s_i64(vc, vb);
break;
case 0x01:
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_BWX);
REQUIRE_REG_31(ra);
tcg_gen_ext16s_i64(vc, vb);
break;
case 0x30:
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_CIX);
REQUIRE_REG_31(ra);
gen_helper_ctpop(vc, vb);
break;
case 0x31:
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);
va = load_gpr(ctx, ra);
gen_helper_perr(vc, va, vb);
break;
case 0x32:
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_CIX);
REQUIRE_REG_31(ra);
gen_helper_ctlz(vc, vb);
break;
case 0x33:
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_CIX);
REQUIRE_REG_31(ra);
gen_helper_cttz(vc, vb);
break;
case 0x34:
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);
REQUIRE_REG_31(ra);
gen_helper_unpkbw(vc, vb);
break;
case 0x35:
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);
REQUIRE_REG_31(ra);
gen_helper_unpkbl(vc, vb);
break;
case 0x36:
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);
REQUIRE_REG_31(ra);
gen_helper_pkwb(vc, vb);
break;
case 0x37:
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);
REQUIRE_REG_31(ra);
gen_helper_pklb(vc, vb);
break;
case 0x38:
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);
va = load_gpr(ctx, ra);
gen_helper_minsb8(vc, va, vb);
break;
case 0x39:
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);
va = load_gpr(ctx, ra);
gen_helper_minsw4(vc, va, vb);
break;
case 0x3A:
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);
va = load_gpr(ctx, ra);
gen_helper_minub8(vc, va, vb);
break;
case 0x3B:
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);
va = load_gpr(ctx, ra);
gen_helper_minuw4(vc, va, vb);
break;
case 0x3C:
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);
va = load_gpr(ctx, ra);
gen_helper_maxub8(vc, va, vb);
break;
case 0x3D:
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);
va = load_gpr(ctx, ra);
gen_helper_maxuw4(vc, va, vb);
break;
case 0x3E:
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);
va = load_gpr(ctx, ra);
gen_helper_maxsb8(vc, va, vb);
break;
case 0x3F:
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);
va = load_gpr(ctx, ra);
gen_helper_maxsw4(vc, va, vb);
break;
default:
goto invalid_opc;
}
break;
case 0x1D:
#ifndef CONFIG_USER_ONLY
REQUIRE_TB_FLAG(TB_FLAGS_PAL_MODE);
vb = load_gpr(ctx, rb);
ret = gen_mtpr(ctx, vb, insn & 0xffff);
break;
#else
goto invalid_opc;
#endif
case 0x1E:
#ifndef CONFIG_USER_ONLY
REQUIRE_TB_FLAG(TB_FLAGS_PAL_MODE);
if (rb == 31) {
tmp = tcg_temp_new();
tcg_gen_ld_i64(tmp, cpu_env, offsetof(CPUAlphaState, exc_addr));
gen_helper_hw_ret(cpu_env, tmp);
tcg_temp_free(tmp);
} else {
gen_helper_hw_ret(cpu_env, load_gpr(ctx, rb));
}
ret = EXIT_PC_UPDATED;
break;
#else
goto invalid_opc;
#endif
case 0x1F:
#ifndef CONFIG_USER_ONLY
REQUIRE_TB_FLAG(TB_FLAGS_PAL_MODE);
{
TCGv addr = tcg_temp_new();
va = load_gpr(ctx, ra);
vb = load_gpr(ctx, rb);
tcg_gen_addi_i64(addr, vb, disp12);
switch ((insn >> 12) & 0xF) {
case 0x0:
gen_helper_stl_phys(cpu_env, addr, va);
break;
case 0x1:
gen_helper_stq_phys(cpu_env, addr, va);
break;
case 0x2:
gen_helper_stl_c_phys(dest_gpr(ctx, ra), cpu_env, addr, va);
break;
case 0x3:
gen_helper_stq_c_phys(dest_gpr(ctx, ra), cpu_env, addr, va);
break;
case 0x4:
goto invalid_opc;
case 0x5:
goto invalid_opc;
case 0x6:
goto invalid_opc;
case 0x7:
goto invalid_opc;
case 0x8:
goto invalid_opc;
case 0x9:
goto invalid_opc;
case 0xA:
goto invalid_opc;
case 0xB:
goto invalid_opc;
case 0xC:
goto invalid_opc;
case 0xD:
goto invalid_opc;
case 0xE:
goto invalid_opc;
case 0xF:
goto invalid_opc;
}
tcg_temp_free(addr);
break;
}
#else
goto invalid_opc;
#endif
case 0x20:
gen_load_mem(ctx, &gen_qemu_ldf, ra, rb, disp16, 1, 0);
break;
case 0x21:
gen_load_mem(ctx, &gen_qemu_ldg, ra, rb, disp16, 1, 0);
break;
case 0x22:
gen_load_mem(ctx, &gen_qemu_lds, ra, rb, disp16, 1, 0);
break;
case 0x23:
gen_load_mem(ctx, &tcg_gen_qemu_ld64, ra, rb, disp16, 1, 0);
break;
case 0x24:
gen_store_mem(ctx, &gen_qemu_stf, ra, rb, disp16, 1, 0);
break;
case 0x25:
gen_store_mem(ctx, &gen_qemu_stg, ra, rb, disp16, 1, 0);
break;
case 0x26:
gen_store_mem(ctx, &gen_qemu_sts, ra, rb, disp16, 1, 0);
break;
case 0x27:
gen_store_mem(ctx, &tcg_gen_qemu_st64, ra, rb, disp16, 1, 0);
break;
case 0x28:
gen_load_mem(ctx, &tcg_gen_qemu_ld32s, ra, rb, disp16, 0, 0);
break;
case 0x29:
gen_load_mem(ctx, &tcg_gen_qemu_ld64, ra, rb, disp16, 0, 0);
break;
case 0x2A:
gen_load_mem(ctx, &gen_qemu_ldl_l, ra, rb, disp16, 0, 0);
break;
case 0x2B:
gen_load_mem(ctx, &gen_qemu_ldq_l, ra, rb, disp16, 0, 0);
break;
case 0x2C:
gen_store_mem(ctx, &tcg_gen_qemu_st32, ra, rb, disp16, 0, 0);
break;
case 0x2D:
gen_store_mem(ctx, &tcg_gen_qemu_st64, ra, rb, disp16, 0, 0);
break;
case 0x2E:
ret = gen_store_conditional(ctx, ra, rb, disp16, 0);
break;
case 0x2F:
ret = gen_store_conditional(ctx, ra, rb, disp16, 1);
break;
case 0x30:
ret = gen_bdirect(ctx, ra, disp21);
break;
case 0x31:
ret = gen_fbcond(ctx, TCG_COND_EQ, ra, disp21);
break;
case 0x32:
ret = gen_fbcond(ctx, TCG_COND_LT, ra, disp21);
break;
case 0x33:
ret = gen_fbcond(ctx, TCG_COND_LE, ra, disp21);
break;
case 0x34:
ret = gen_bdirect(ctx, ra, disp21);
break;
case 0x35:
ret = gen_fbcond(ctx, TCG_COND_NE, ra, disp21);
break;
case 0x36:
ret = gen_fbcond(ctx, TCG_COND_GE, ra, disp21);
break;
case 0x37:
ret = gen_fbcond(ctx, TCG_COND_GT, ra, disp21);
break;
case 0x38:
ret = gen_bcond(ctx, TCG_COND_EQ, ra, disp21, 1);
break;
case 0x39:
ret = gen_bcond(ctx, TCG_COND_EQ, ra, disp21, 0);
break;
case 0x3A:
ret = gen_bcond(ctx, TCG_COND_LT, ra, disp21, 0);
break;
case 0x3B:
ret = gen_bcond(ctx, TCG_COND_LE, ra, disp21, 0);
break;
case 0x3C:
ret = gen_bcond(ctx, TCG_COND_NE, ra, disp21, 1);
break;
case 0x3D:
ret = gen_bcond(ctx, TCG_COND_NE, ra, disp21, 0);
break;
case 0x3E:
ret = gen_bcond(ctx, TCG_COND_GE, ra, disp21, 0);
break;
case 0x3F:
ret = gen_bcond(ctx, TCG_COND_GT, ra, disp21, 0);
break;
invalid_opc:
ret = gen_invalid(ctx);
break;
}
return ret;
}
| {
"code": [
" TCGv va, vb, vc, tmp;",
" gen_helper_addlv(vc, cpu_env, va, vb);",
" gen_helper_sublv(vc, cpu_env, va, vb);",
" gen_helper_addqv(vc, cpu_env, va, vb);",
" gen_helper_subqv(vc, cpu_env, va, vb);",
" gen_helper_mullv(vc, cpu_env, va, vb);",
" gen_helper_mulqv(vc, cpu_env, va, vb);"
],
"line_no": [
13,
437,
445,
461,
469,
1059,
1067
]
} | static ExitStatus FUNC_0(DisasContext *ctx, uint32_t insn)
{
int32_t disp21, disp16, disp12 __attribute__((unused));
uint16_t fn11;
uint8_t opc, ra, rb, rc, fpfn, fn7, lit;
bool islit;
TCGv va, vb, vc, tmp;
TCGv_i32 t32;
ExitStatus ret;
opc = extract32(insn, 26, 6);
ra = extract32(insn, 21, 5);
rb = extract32(insn, 16, 5);
rc = extract32(insn, 0, 5);
islit = extract32(insn, 12, 1);
lit = extract32(insn, 13, 8);
disp21 = sextract32(insn, 0, 21);
disp16 = sextract32(insn, 0, 16);
disp12 = sextract32(insn, 0, 12);
fn11 = extract32(insn, 5, 11);
fpfn = extract32(insn, 5, 6);
fn7 = extract32(insn, 5, 7);
if (rb == 31 && !islit) {
islit = true;
lit = 0;
}
ret = NO_EXIT;
switch (opc) {
case 0x00:
ret = gen_call_pal(ctx, insn & 0x03ffffff);
break;
case 0x01:
goto invalid_opc;
case 0x02:
goto invalid_opc;
case 0x03:
goto invalid_opc;
case 0x04:
goto invalid_opc;
case 0x05:
goto invalid_opc;
case 0x06:
goto invalid_opc;
case 0x07:
goto invalid_opc;
case 0x09:
disp16 = (uint32_t)disp16 << 16;
case 0x08:
va = dest_gpr(ctx, ra);
if (rb == 31) {
tcg_gen_movi_i64(va, disp16);
} else {
tcg_gen_addi_i64(va, load_gpr(ctx, rb), disp16);
}
break;
case 0x0A:
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_BWX);
gen_load_mem(ctx, &tcg_gen_qemu_ld8u, ra, rb, disp16, 0, 0);
break;
case 0x0B:
gen_load_mem(ctx, &tcg_gen_qemu_ld64, ra, rb, disp16, 0, 1);
break;
case 0x0C:
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_BWX);
gen_load_mem(ctx, &tcg_gen_qemu_ld16u, ra, rb, disp16, 0, 0);
break;
case 0x0D:
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_BWX);
gen_store_mem(ctx, &tcg_gen_qemu_st16, ra, rb, disp16, 0, 0);
break;
case 0x0E:
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_BWX);
gen_store_mem(ctx, &tcg_gen_qemu_st8, ra, rb, disp16, 0, 0);
break;
case 0x0F:
gen_store_mem(ctx, &tcg_gen_qemu_st64, ra, rb, disp16, 0, 1);
break;
case 0x10:
vc = dest_gpr(ctx, rc);
vb = load_gpr_lit(ctx, rb, lit, islit);
if (ra == 31) {
if (fn7 == 0x00) {
tcg_gen_ext32s_i64(vc, vb);
break;
}
if (fn7 == 0x29) {
tcg_gen_neg_i64(vc, vb);
break;
}
}
va = load_gpr(ctx, ra);
switch (fn7) {
case 0x00:
tcg_gen_add_i64(vc, va, vb);
tcg_gen_ext32s_i64(vc, vc);
break;
case 0x02:
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 2);
tcg_gen_add_i64(tmp, tmp, vb);
tcg_gen_ext32s_i64(vc, tmp);
tcg_temp_free(tmp);
break;
case 0x09:
tcg_gen_sub_i64(vc, va, vb);
tcg_gen_ext32s_i64(vc, vc);
break;
case 0x0B:
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 2);
tcg_gen_sub_i64(tmp, tmp, vb);
tcg_gen_ext32s_i64(vc, tmp);
tcg_temp_free(tmp);
break;
case 0x0F:
gen_helper_cmpbge(vc, va, vb);
break;
case 0x12:
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 3);
tcg_gen_add_i64(tmp, tmp, vb);
tcg_gen_ext32s_i64(vc, tmp);
tcg_temp_free(tmp);
break;
case 0x1B:
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 3);
tcg_gen_sub_i64(tmp, tmp, vb);
tcg_gen_ext32s_i64(vc, tmp);
tcg_temp_free(tmp);
break;
case 0x1D:
tcg_gen_setcond_i64(TCG_COND_LTU, vc, va, vb);
break;
case 0x20:
tcg_gen_add_i64(vc, va, vb);
break;
case 0x22:
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 2);
tcg_gen_add_i64(vc, tmp, vb);
tcg_temp_free(tmp);
break;
case 0x29:
tcg_gen_sub_i64(vc, va, vb);
break;
case 0x2B:
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 2);
tcg_gen_sub_i64(vc, tmp, vb);
tcg_temp_free(tmp);
break;
case 0x2D:
tcg_gen_setcond_i64(TCG_COND_EQ, vc, va, vb);
break;
case 0x32:
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 3);
tcg_gen_add_i64(vc, tmp, vb);
tcg_temp_free(tmp);
break;
case 0x3B:
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 3);
tcg_gen_sub_i64(vc, tmp, vb);
tcg_temp_free(tmp);
break;
case 0x3D:
tcg_gen_setcond_i64(TCG_COND_LEU, vc, va, vb);
break;
case 0x40:
gen_helper_addlv(vc, cpu_env, va, vb);
break;
case 0x49:
gen_helper_sublv(vc, cpu_env, va, vb);
break;
case 0x4D:
tcg_gen_setcond_i64(TCG_COND_LT, vc, va, vb);
break;
case 0x60:
gen_helper_addqv(vc, cpu_env, va, vb);
break;
case 0x69:
gen_helper_subqv(vc, cpu_env, va, vb);
break;
case 0x6D:
tcg_gen_setcond_i64(TCG_COND_LE, vc, va, vb);
break;
default:
goto invalid_opc;
}
break;
case 0x11:
if (fn7 == 0x20) {
if (rc == 31) {
break;
}
if (ra == 31) {
vc = dest_gpr(ctx, rc);
if (islit) {
tcg_gen_movi_i64(vc, lit);
} else {
tcg_gen_mov_i64(vc, load_gpr(ctx, rb));
}
break;
}
}
vc = dest_gpr(ctx, rc);
vb = load_gpr_lit(ctx, rb, lit, islit);
if (fn7 == 0x28 && ra == 31) {
tcg_gen_not_i64(vc, vb);
break;
}
va = load_gpr(ctx, ra);
switch (fn7) {
case 0x00:
tcg_gen_and_i64(vc, va, vb);
break;
case 0x08:
tcg_gen_andc_i64(vc, va, vb);
break;
case 0x14:
tmp = tcg_temp_new();
tcg_gen_andi_i64(tmp, va, 1);
tcg_gen_movcond_i64(TCG_COND_NE, vc, tmp, load_zero(ctx),
vb, load_gpr(ctx, rc));
tcg_temp_free(tmp);
break;
case 0x16:
tmp = tcg_temp_new();
tcg_gen_andi_i64(tmp, va, 1);
tcg_gen_movcond_i64(TCG_COND_EQ, vc, tmp, load_zero(ctx),
vb, load_gpr(ctx, rc));
tcg_temp_free(tmp);
break;
case 0x20:
tcg_gen_or_i64(vc, va, vb);
break;
case 0x24:
tcg_gen_movcond_i64(TCG_COND_EQ, vc, va, load_zero(ctx),
vb, load_gpr(ctx, rc));
break;
case 0x26:
tcg_gen_movcond_i64(TCG_COND_NE, vc, va, load_zero(ctx),
vb, load_gpr(ctx, rc));
break;
case 0x28:
tcg_gen_orc_i64(vc, va, vb);
break;
case 0x40:
tcg_gen_xor_i64(vc, va, vb);
break;
case 0x44:
tcg_gen_movcond_i64(TCG_COND_LT, vc, va, load_zero(ctx),
vb, load_gpr(ctx, rc));
break;
case 0x46:
tcg_gen_movcond_i64(TCG_COND_GE, vc, va, load_zero(ctx),
vb, load_gpr(ctx, rc));
break;
case 0x48:
tcg_gen_eqv_i64(vc, va, vb);
break;
case 0x61:
REQUIRE_REG_31(ra);
{
uint64_t amask = ctx->tb->flags >> TB_FLAGS_AMASK_SHIFT;
tcg_gen_andi_i64(vc, vb, ~amask);
}
break;
case 0x64:
tcg_gen_movcond_i64(TCG_COND_LE, vc, va, load_zero(ctx),
vb, load_gpr(ctx, rc));
break;
case 0x66:
tcg_gen_movcond_i64(TCG_COND_GT, vc, va, load_zero(ctx),
vb, load_gpr(ctx, rc));
break;
case 0x6C:
REQUIRE_REG_31(ra);
tcg_gen_movi_i64(vc, ctx->implver);
break;
default:
goto invalid_opc;
}
break;
case 0x12:
vc = dest_gpr(ctx, rc);
va = load_gpr(ctx, ra);
switch (fn7) {
case 0x02:
gen_msk_l(ctx, vc, va, rb, islit, lit, 0x01);
break;
case 0x06:
gen_ext_l(ctx, vc, va, rb, islit, lit, 0x01);
break;
case 0x0B:
gen_ins_l(ctx, vc, va, rb, islit, lit, 0x01);
break;
case 0x12:
gen_msk_l(ctx, vc, va, rb, islit, lit, 0x03);
break;
case 0x16:
gen_ext_l(ctx, vc, va, rb, islit, lit, 0x03);
break;
case 0x1B:
gen_ins_l(ctx, vc, va, rb, islit, lit, 0x03);
break;
case 0x22:
gen_msk_l(ctx, vc, va, rb, islit, lit, 0x0f);
break;
case 0x26:
gen_ext_l(ctx, vc, va, rb, islit, lit, 0x0f);
break;
case 0x2B:
gen_ins_l(ctx, vc, va, rb, islit, lit, 0x0f);
break;
case 0x30:
if (islit) {
gen_zapnoti(vc, va, ~lit);
} else {
gen_helper_zap(vc, va, load_gpr(ctx, rb));
}
break;
case 0x31:
if (islit) {
gen_zapnoti(vc, va, lit);
} else {
gen_helper_zapnot(vc, va, load_gpr(ctx, rb));
}
break;
case 0x32:
gen_msk_l(ctx, vc, va, rb, islit, lit, 0xff);
break;
case 0x34:
if (islit) {
tcg_gen_shri_i64(vc, va, lit & 0x3f);
} else {
tmp = tcg_temp_new();
vb = load_gpr(ctx, rb);
tcg_gen_andi_i64(tmp, vb, 0x3f);
tcg_gen_shr_i64(vc, va, tmp);
tcg_temp_free(tmp);
}
break;
case 0x36:
gen_ext_l(ctx, vc, va, rb, islit, lit, 0xff);
break;
case 0x39:
if (islit) {
tcg_gen_shli_i64(vc, va, lit & 0x3f);
} else {
tmp = tcg_temp_new();
vb = load_gpr(ctx, rb);
tcg_gen_andi_i64(tmp, vb, 0x3f);
tcg_gen_shl_i64(vc, va, tmp);
tcg_temp_free(tmp);
}
break;
case 0x3B:
gen_ins_l(ctx, vc, va, rb, islit, lit, 0xff);
break;
case 0x3C:
if (islit) {
tcg_gen_sari_i64(vc, va, lit & 0x3f);
} else {
tmp = tcg_temp_new();
vb = load_gpr(ctx, rb);
tcg_gen_andi_i64(tmp, vb, 0x3f);
tcg_gen_sar_i64(vc, va, tmp);
tcg_temp_free(tmp);
}
break;
case 0x52:
gen_msk_h(ctx, vc, va, rb, islit, lit, 0x03);
break;
case 0x57:
gen_ins_h(ctx, vc, va, rb, islit, lit, 0x03);
break;
case 0x5A:
gen_ext_h(ctx, vc, va, rb, islit, lit, 0x03);
break;
case 0x62:
gen_msk_h(ctx, vc, va, rb, islit, lit, 0x0f);
break;
case 0x67:
gen_ins_h(ctx, vc, va, rb, islit, lit, 0x0f);
break;
case 0x6A:
gen_ext_h(ctx, vc, va, rb, islit, lit, 0x0f);
break;
case 0x72:
gen_msk_h(ctx, vc, va, rb, islit, lit, 0xff);
break;
case 0x77:
gen_ins_h(ctx, vc, va, rb, islit, lit, 0xff);
break;
case 0x7A:
gen_ext_h(ctx, vc, va, rb, islit, lit, 0xff);
break;
default:
goto invalid_opc;
}
break;
case 0x13:
vc = dest_gpr(ctx, rc);
vb = load_gpr_lit(ctx, rb, lit, islit);
va = load_gpr(ctx, ra);
switch (fn7) {
case 0x00:
tcg_gen_mul_i64(vc, va, vb);
tcg_gen_ext32s_i64(vc, vc);
break;
case 0x20:
tcg_gen_mul_i64(vc, va, vb);
break;
case 0x30:
tmp = tcg_temp_new();
tcg_gen_mulu2_i64(tmp, vc, va, vb);
tcg_temp_free(tmp);
break;
case 0x40:
gen_helper_mullv(vc, cpu_env, va, vb);
break;
case 0x60:
gen_helper_mulqv(vc, cpu_env, va, vb);
break;
default:
goto invalid_opc;
}
break;
case 0x14:
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_FIX);
vc = dest_fpr(ctx, rc);
switch (fpfn) {
case 0x04:
REQUIRE_REG_31(rb);
t32 = tcg_temp_new_i32();
va = load_gpr(ctx, ra);
tcg_gen_trunc_i64_i32(t32, va);
gen_helper_memory_to_s(vc, t32);
tcg_temp_free_i32(t32);
break;
case 0x0A:
REQUIRE_REG_31(ra);
vb = load_fpr(ctx, rb);
gen_helper_sqrtf(vc, cpu_env, vb);
break;
case 0x0B:
REQUIRE_REG_31(ra);
gen_sqrts(ctx, rb, rc, fn11);
break;
case 0x14:
REQUIRE_REG_31(rb);
t32 = tcg_temp_new_i32();
va = load_gpr(ctx, ra);
tcg_gen_trunc_i64_i32(t32, va);
gen_helper_memory_to_f(vc, t32);
tcg_temp_free_i32(t32);
break;
case 0x24:
REQUIRE_REG_31(rb);
va = load_gpr(ctx, ra);
tcg_gen_mov_i64(vc, va);
break;
case 0x2A:
REQUIRE_REG_31(ra);
vb = load_fpr(ctx, rb);
gen_helper_sqrtg(vc, cpu_env, vb);
break;
case 0x02B:
REQUIRE_REG_31(ra);
gen_sqrtt(ctx, rb, rc, fn11);
break;
default:
goto invalid_opc;
}
break;
case 0x15:
vc = dest_fpr(ctx, rc);
vb = load_fpr(ctx, rb);
va = load_fpr(ctx, ra);
switch (fpfn) {
case 0x00:
gen_helper_addf(vc, cpu_env, va, vb);
break;
case 0x01:
gen_helper_subf(vc, cpu_env, va, vb);
break;
case 0x02:
gen_helper_mulf(vc, cpu_env, va, vb);
break;
case 0x03:
gen_helper_divf(vc, cpu_env, va, vb);
break;
case 0x1E:
REQUIRE_REG_31(ra);
goto invalid_opc;
case 0x20:
gen_helper_addg(vc, cpu_env, va, vb);
break;
case 0x21:
gen_helper_subg(vc, cpu_env, va, vb);
break;
case 0x22:
gen_helper_mulg(vc, cpu_env, va, vb);
break;
case 0x23:
gen_helper_divg(vc, cpu_env, va, vb);
break;
case 0x25:
gen_helper_cmpgeq(vc, cpu_env, va, vb);
break;
case 0x26:
gen_helper_cmpglt(vc, cpu_env, va, vb);
break;
case 0x27:
gen_helper_cmpgle(vc, cpu_env, va, vb);
break;
case 0x2C:
REQUIRE_REG_31(ra);
gen_helper_cvtgf(vc, cpu_env, vb);
break;
case 0x2D:
REQUIRE_REG_31(ra);
goto invalid_opc;
case 0x2F:
REQUIRE_REG_31(ra);
gen_helper_cvtgq(vc, cpu_env, vb);
break;
case 0x3C:
REQUIRE_REG_31(ra);
gen_helper_cvtqf(vc, cpu_env, vb);
break;
case 0x3E:
REQUIRE_REG_31(ra);
gen_helper_cvtqg(vc, cpu_env, vb);
break;
default:
goto invalid_opc;
}
break;
case 0x16:
switch (fpfn) {
case 0x00:
gen_adds(ctx, ra, rb, rc, fn11);
break;
case 0x01:
gen_subs(ctx, ra, rb, rc, fn11);
break;
case 0x02:
gen_muls(ctx, ra, rb, rc, fn11);
break;
case 0x03:
gen_divs(ctx, ra, rb, rc, fn11);
break;
case 0x20:
gen_addt(ctx, ra, rb, rc, fn11);
break;
case 0x21:
gen_subt(ctx, ra, rb, rc, fn11);
break;
case 0x22:
gen_mult(ctx, ra, rb, rc, fn11);
break;
case 0x23:
gen_divt(ctx, ra, rb, rc, fn11);
break;
case 0x24:
gen_cmptun(ctx, ra, rb, rc, fn11);
break;
case 0x25:
gen_cmpteq(ctx, ra, rb, rc, fn11);
break;
case 0x26:
gen_cmptlt(ctx, ra, rb, rc, fn11);
break;
case 0x27:
gen_cmptle(ctx, ra, rb, rc, fn11);
break;
case 0x2C:
REQUIRE_REG_31(ra);
if (fn11 == 0x2AC || fn11 == 0x6AC) {
gen_cvtst(ctx, rb, rc, fn11);
} else {
gen_cvtts(ctx, rb, rc, fn11);
}
break;
case 0x2F:
REQUIRE_REG_31(ra);
gen_cvttq(ctx, rb, rc, fn11);
break;
case 0x3C:
REQUIRE_REG_31(ra);
gen_cvtqs(ctx, rb, rc, fn11);
break;
case 0x3E:
REQUIRE_REG_31(ra);
gen_cvtqt(ctx, rb, rc, fn11);
break;
default:
goto invalid_opc;
}
break;
case 0x17:
switch (fn11) {
case 0x010:
REQUIRE_REG_31(ra);
vc = dest_fpr(ctx, rc);
vb = load_fpr(ctx, rb);
gen_cvtlq(vc, vb);
break;
case 0x020:
if (rc == 31) {
} else {
vc = dest_fpr(ctx, rc);
va = load_fpr(ctx, ra);
if (ra == rb) {
tcg_gen_mov_i64(vc, va);
} else {
vb = load_fpr(ctx, rb);
gen_cpy_mask(vc, va, vb, 0, 0x8000000000000000ULL);
}
}
break;
case 0x021:
vc = dest_fpr(ctx, rc);
vb = load_fpr(ctx, rb);
va = load_fpr(ctx, ra);
gen_cpy_mask(vc, va, vb, 1, 0x8000000000000000ULL);
break;
case 0x022:
vc = dest_fpr(ctx, rc);
vb = load_fpr(ctx, rb);
va = load_fpr(ctx, ra);
gen_cpy_mask(vc, va, vb, 0, 0xFFF0000000000000ULL);
break;
case 0x024:
va = load_fpr(ctx, ra);
gen_helper_store_fpcr(cpu_env, va);
if (ctx->tb_rm == QUAL_RM_D) {
ctx->tb_rm = -1;
}
break;
case 0x025:
va = dest_fpr(ctx, ra);
gen_helper_load_fpcr(va, cpu_env);
break;
case 0x02A:
gen_fcmov(ctx, TCG_COND_EQ, ra, rb, rc);
break;
case 0x02B:
gen_fcmov(ctx, TCG_COND_NE, ra, rb, rc);
break;
case 0x02C:
gen_fcmov(ctx, TCG_COND_LT, ra, rb, rc);
break;
case 0x02D:
gen_fcmov(ctx, TCG_COND_GE, ra, rb, rc);
break;
case 0x02E:
gen_fcmov(ctx, TCG_COND_LE, ra, rb, rc);
break;
case 0x02F:
gen_fcmov(ctx, TCG_COND_GT, ra, rb, rc);
break;
case 0x030:
REQUIRE_REG_31(ra);
vc = dest_fpr(ctx, rc);
vb = load_fpr(ctx, rb);
gen_cvtql(vc, vb);
break;
case 0x130:
case 0x530:
REQUIRE_REG_31(ra);
vc = dest_fpr(ctx, rc);
vb = load_fpr(ctx, rb);
gen_helper_cvtql_v_input(cpu_env, vb);
gen_cvtql(vc, vb);
break;
default:
goto invalid_opc;
}
break;
case 0x18:
switch ((uint16_t)disp16) {
case 0x0000:
break;
case 0x0400:
break;
case 0x4000:
break;
case 0x4400:
break;
case 0x8000:
break;
case 0xA000:
break;
case 0xC000:
va = dest_gpr(ctx, ra);
if (ctx->tb->cflags & CF_USE_ICOUNT) {
gen_io_start();
gen_helper_load_pcc(va, cpu_env);
gen_io_end();
ret = EXIT_PC_STALE;
} else {
gen_helper_load_pcc(va, cpu_env);
}
break;
case 0xE000:
gen_rx(ra, 0);
break;
case 0xE800:
break;
case 0xF000:
gen_rx(ra, 1);
break;
case 0xF800:
break;
default:
goto invalid_opc;
}
break;
case 0x19:
#ifndef CONFIG_USER_ONLY
REQUIRE_TB_FLAG(TB_FLAGS_PAL_MODE);
va = dest_gpr(ctx, ra);
ret = gen_mfpr(ctx, va, insn & 0xffff);
break;
#else
goto invalid_opc;
#endif
case 0x1A:
vb = load_gpr(ctx, rb);
tcg_gen_andi_i64(cpu_pc, vb, ~3);
if (ra != 31) {
tcg_gen_movi_i64(cpu_ir[ra], ctx->pc);
}
ret = EXIT_PC_UPDATED;
break;
case 0x1B:
#ifndef CONFIG_USER_ONLY
REQUIRE_TB_FLAG(TB_FLAGS_PAL_MODE);
{
TCGv addr = tcg_temp_new();
vb = load_gpr(ctx, rb);
va = dest_gpr(ctx, ra);
tcg_gen_addi_i64(addr, vb, disp12);
switch ((insn >> 12) & 0xF) {
case 0x0:
gen_helper_ldl_phys(va, cpu_env, addr);
break;
case 0x1:
gen_helper_ldq_phys(va, cpu_env, addr);
break;
case 0x2:
gen_helper_ldl_l_phys(va, cpu_env, addr);
break;
case 0x3:
gen_helper_ldq_l_phys(va, cpu_env, addr);
break;
case 0x4:
goto invalid_opc;
case 0x5:
goto invalid_opc;
break;
case 0x6:
goto invalid_opc;
case 0x7:
goto invalid_opc;
case 0x8:
goto invalid_opc;
case 0x9:
goto invalid_opc;
case 0xA:
tcg_gen_qemu_ld_i64(va, addr, MMU_KERNEL_IDX, MO_LESL);
break;
case 0xB:
tcg_gen_qemu_ld_i64(va, addr, MMU_KERNEL_IDX, MO_LEQ);
break;
case 0xC:
goto invalid_opc;
case 0xD:
goto invalid_opc;
case 0xE:
tcg_gen_qemu_ld_i64(va, addr, MMU_USER_IDX, MO_LESL);
break;
case 0xF:
tcg_gen_qemu_ld_i64(va, addr, MMU_USER_IDX, MO_LEQ);
break;
}
tcg_temp_free(addr);
break;
}
#else
goto invalid_opc;
#endif
case 0x1C:
vc = dest_gpr(ctx, rc);
if (fn7 == 0x70) {
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_FIX);
REQUIRE_REG_31(rb);
va = load_fpr(ctx, ra);
tcg_gen_mov_i64(vc, va);
break;
} else if (fn7 == 0x78) {
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_FIX);
REQUIRE_REG_31(rb);
t32 = tcg_temp_new_i32();
va = load_fpr(ctx, ra);
gen_helper_s_to_memory(t32, va);
tcg_gen_ext_i32_i64(vc, t32);
tcg_temp_free_i32(t32);
break;
}
vb = load_gpr_lit(ctx, rb, lit, islit);
switch (fn7) {
case 0x00:
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_BWX);
REQUIRE_REG_31(ra);
tcg_gen_ext8s_i64(vc, vb);
break;
case 0x01:
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_BWX);
REQUIRE_REG_31(ra);
tcg_gen_ext16s_i64(vc, vb);
break;
case 0x30:
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_CIX);
REQUIRE_REG_31(ra);
gen_helper_ctpop(vc, vb);
break;
case 0x31:
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);
va = load_gpr(ctx, ra);
gen_helper_perr(vc, va, vb);
break;
case 0x32:
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_CIX);
REQUIRE_REG_31(ra);
gen_helper_ctlz(vc, vb);
break;
case 0x33:
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_CIX);
REQUIRE_REG_31(ra);
gen_helper_cttz(vc, vb);
break;
case 0x34:
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);
REQUIRE_REG_31(ra);
gen_helper_unpkbw(vc, vb);
break;
case 0x35:
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);
REQUIRE_REG_31(ra);
gen_helper_unpkbl(vc, vb);
break;
case 0x36:
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);
REQUIRE_REG_31(ra);
gen_helper_pkwb(vc, vb);
break;
case 0x37:
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);
REQUIRE_REG_31(ra);
gen_helper_pklb(vc, vb);
break;
case 0x38:
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);
va = load_gpr(ctx, ra);
gen_helper_minsb8(vc, va, vb);
break;
case 0x39:
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);
va = load_gpr(ctx, ra);
gen_helper_minsw4(vc, va, vb);
break;
case 0x3A:
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);
va = load_gpr(ctx, ra);
gen_helper_minub8(vc, va, vb);
break;
case 0x3B:
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);
va = load_gpr(ctx, ra);
gen_helper_minuw4(vc, va, vb);
break;
case 0x3C:
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);
va = load_gpr(ctx, ra);
gen_helper_maxub8(vc, va, vb);
break;
case 0x3D:
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);
va = load_gpr(ctx, ra);
gen_helper_maxuw4(vc, va, vb);
break;
case 0x3E:
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);
va = load_gpr(ctx, ra);
gen_helper_maxsb8(vc, va, vb);
break;
case 0x3F:
REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);
va = load_gpr(ctx, ra);
gen_helper_maxsw4(vc, va, vb);
break;
default:
goto invalid_opc;
}
break;
case 0x1D:
#ifndef CONFIG_USER_ONLY
REQUIRE_TB_FLAG(TB_FLAGS_PAL_MODE);
vb = load_gpr(ctx, rb);
ret = gen_mtpr(ctx, vb, insn & 0xffff);
break;
#else
goto invalid_opc;
#endif
case 0x1E:
#ifndef CONFIG_USER_ONLY
REQUIRE_TB_FLAG(TB_FLAGS_PAL_MODE);
if (rb == 31) {
tmp = tcg_temp_new();
tcg_gen_ld_i64(tmp, cpu_env, offsetof(CPUAlphaState, exc_addr));
gen_helper_hw_ret(cpu_env, tmp);
tcg_temp_free(tmp);
} else {
gen_helper_hw_ret(cpu_env, load_gpr(ctx, rb));
}
ret = EXIT_PC_UPDATED;
break;
#else
goto invalid_opc;
#endif
case 0x1F:
#ifndef CONFIG_USER_ONLY
REQUIRE_TB_FLAG(TB_FLAGS_PAL_MODE);
{
TCGv addr = tcg_temp_new();
va = load_gpr(ctx, ra);
vb = load_gpr(ctx, rb);
tcg_gen_addi_i64(addr, vb, disp12);
switch ((insn >> 12) & 0xF) {
case 0x0:
gen_helper_stl_phys(cpu_env, addr, va);
break;
case 0x1:
gen_helper_stq_phys(cpu_env, addr, va);
break;
case 0x2:
gen_helper_stl_c_phys(dest_gpr(ctx, ra), cpu_env, addr, va);
break;
case 0x3:
gen_helper_stq_c_phys(dest_gpr(ctx, ra), cpu_env, addr, va);
break;
case 0x4:
goto invalid_opc;
case 0x5:
goto invalid_opc;
case 0x6:
goto invalid_opc;
case 0x7:
goto invalid_opc;
case 0x8:
goto invalid_opc;
case 0x9:
goto invalid_opc;
case 0xA:
goto invalid_opc;
case 0xB:
goto invalid_opc;
case 0xC:
goto invalid_opc;
case 0xD:
goto invalid_opc;
case 0xE:
goto invalid_opc;
case 0xF:
goto invalid_opc;
}
tcg_temp_free(addr);
break;
}
#else
goto invalid_opc;
#endif
case 0x20:
gen_load_mem(ctx, &gen_qemu_ldf, ra, rb, disp16, 1, 0);
break;
case 0x21:
gen_load_mem(ctx, &gen_qemu_ldg, ra, rb, disp16, 1, 0);
break;
case 0x22:
gen_load_mem(ctx, &gen_qemu_lds, ra, rb, disp16, 1, 0);
break;
case 0x23:
gen_load_mem(ctx, &tcg_gen_qemu_ld64, ra, rb, disp16, 1, 0);
break;
case 0x24:
gen_store_mem(ctx, &gen_qemu_stf, ra, rb, disp16, 1, 0);
break;
case 0x25:
gen_store_mem(ctx, &gen_qemu_stg, ra, rb, disp16, 1, 0);
break;
case 0x26:
gen_store_mem(ctx, &gen_qemu_sts, ra, rb, disp16, 1, 0);
break;
case 0x27:
gen_store_mem(ctx, &tcg_gen_qemu_st64, ra, rb, disp16, 1, 0);
break;
case 0x28:
gen_load_mem(ctx, &tcg_gen_qemu_ld32s, ra, rb, disp16, 0, 0);
break;
case 0x29:
gen_load_mem(ctx, &tcg_gen_qemu_ld64, ra, rb, disp16, 0, 0);
break;
case 0x2A:
gen_load_mem(ctx, &gen_qemu_ldl_l, ra, rb, disp16, 0, 0);
break;
case 0x2B:
gen_load_mem(ctx, &gen_qemu_ldq_l, ra, rb, disp16, 0, 0);
break;
case 0x2C:
gen_store_mem(ctx, &tcg_gen_qemu_st32, ra, rb, disp16, 0, 0);
break;
case 0x2D:
gen_store_mem(ctx, &tcg_gen_qemu_st64, ra, rb, disp16, 0, 0);
break;
case 0x2E:
ret = gen_store_conditional(ctx, ra, rb, disp16, 0);
break;
case 0x2F:
ret = gen_store_conditional(ctx, ra, rb, disp16, 1);
break;
case 0x30:
ret = gen_bdirect(ctx, ra, disp21);
break;
case 0x31:
ret = gen_fbcond(ctx, TCG_COND_EQ, ra, disp21);
break;
case 0x32:
ret = gen_fbcond(ctx, TCG_COND_LT, ra, disp21);
break;
case 0x33:
ret = gen_fbcond(ctx, TCG_COND_LE, ra, disp21);
break;
case 0x34:
ret = gen_bdirect(ctx, ra, disp21);
break;
case 0x35:
ret = gen_fbcond(ctx, TCG_COND_NE, ra, disp21);
break;
case 0x36:
ret = gen_fbcond(ctx, TCG_COND_GE, ra, disp21);
break;
case 0x37:
ret = gen_fbcond(ctx, TCG_COND_GT, ra, disp21);
break;
case 0x38:
ret = gen_bcond(ctx, TCG_COND_EQ, ra, disp21, 1);
break;
case 0x39:
ret = gen_bcond(ctx, TCG_COND_EQ, ra, disp21, 0);
break;
case 0x3A:
ret = gen_bcond(ctx, TCG_COND_LT, ra, disp21, 0);
break;
case 0x3B:
ret = gen_bcond(ctx, TCG_COND_LE, ra, disp21, 0);
break;
case 0x3C:
ret = gen_bcond(ctx, TCG_COND_NE, ra, disp21, 1);
break;
case 0x3D:
ret = gen_bcond(ctx, TCG_COND_NE, ra, disp21, 0);
break;
case 0x3E:
ret = gen_bcond(ctx, TCG_COND_GE, ra, disp21, 0);
break;
case 0x3F:
ret = gen_bcond(ctx, TCG_COND_GT, ra, disp21, 0);
break;
invalid_opc:
ret = gen_invalid(ctx);
break;
}
return ret;
}
| [
"static ExitStatus FUNC_0(DisasContext *ctx, uint32_t insn)\n{",
"int32_t disp21, disp16, disp12 __attribute__((unused));",
"uint16_t fn11;",
"uint8_t opc, ra, rb, rc, fpfn, fn7, lit;",
"bool islit;",
"TCGv va, vb, vc, tmp;",
"TCGv_i32 t32;",
"ExitStatus ret;",
"opc = extract32(insn, 26, 6);",
"ra = extract32(insn, 21, 5);",
"rb = extract32(insn, 16, 5);",
"rc = extract32(insn, 0, 5);",
"islit = extract32(insn, 12, 1);",
"lit = extract32(insn, 13, 8);",
"disp21 = sextract32(insn, 0, 21);",
"disp16 = sextract32(insn, 0, 16);",
"disp12 = sextract32(insn, 0, 12);",
"fn11 = extract32(insn, 5, 11);",
"fpfn = extract32(insn, 5, 6);",
"fn7 = extract32(insn, 5, 7);",
"if (rb == 31 && !islit) {",
"islit = true;",
"lit = 0;",
"}",
"ret = NO_EXIT;",
"switch (opc) {",
"case 0x00:\nret = gen_call_pal(ctx, insn & 0x03ffffff);",
"break;",
"case 0x01:\ngoto invalid_opc;",
"case 0x02:\ngoto invalid_opc;",
"case 0x03:\ngoto invalid_opc;",
"case 0x04:\ngoto invalid_opc;",
"case 0x05:\ngoto invalid_opc;",
"case 0x06:\ngoto invalid_opc;",
"case 0x07:\ngoto invalid_opc;",
"case 0x09:\ndisp16 = (uint32_t)disp16 << 16;",
"case 0x08:\nva = dest_gpr(ctx, ra);",
"if (rb == 31) {",
"tcg_gen_movi_i64(va, disp16);",
"} else {",
"tcg_gen_addi_i64(va, load_gpr(ctx, rb), disp16);",
"}",
"break;",
"case 0x0A:\nREQUIRE_TB_FLAG(TB_FLAGS_AMASK_BWX);",
"gen_load_mem(ctx, &tcg_gen_qemu_ld8u, ra, rb, disp16, 0, 0);",
"break;",
"case 0x0B:\ngen_load_mem(ctx, &tcg_gen_qemu_ld64, ra, rb, disp16, 0, 1);",
"break;",
"case 0x0C:\nREQUIRE_TB_FLAG(TB_FLAGS_AMASK_BWX);",
"gen_load_mem(ctx, &tcg_gen_qemu_ld16u, ra, rb, disp16, 0, 0);",
"break;",
"case 0x0D:\nREQUIRE_TB_FLAG(TB_FLAGS_AMASK_BWX);",
"gen_store_mem(ctx, &tcg_gen_qemu_st16, ra, rb, disp16, 0, 0);",
"break;",
"case 0x0E:\nREQUIRE_TB_FLAG(TB_FLAGS_AMASK_BWX);",
"gen_store_mem(ctx, &tcg_gen_qemu_st8, ra, rb, disp16, 0, 0);",
"break;",
"case 0x0F:\ngen_store_mem(ctx, &tcg_gen_qemu_st64, ra, rb, disp16, 0, 1);",
"break;",
"case 0x10:\nvc = dest_gpr(ctx, rc);",
"vb = load_gpr_lit(ctx, rb, lit, islit);",
"if (ra == 31) {",
"if (fn7 == 0x00) {",
"tcg_gen_ext32s_i64(vc, vb);",
"break;",
"}",
"if (fn7 == 0x29) {",
"tcg_gen_neg_i64(vc, vb);",
"break;",
"}",
"}",
"va = load_gpr(ctx, ra);",
"switch (fn7) {",
"case 0x00:\ntcg_gen_add_i64(vc, va, vb);",
"tcg_gen_ext32s_i64(vc, vc);",
"break;",
"case 0x02:\ntmp = tcg_temp_new();",
"tcg_gen_shli_i64(tmp, va, 2);",
"tcg_gen_add_i64(tmp, tmp, vb);",
"tcg_gen_ext32s_i64(vc, tmp);",
"tcg_temp_free(tmp);",
"break;",
"case 0x09:\ntcg_gen_sub_i64(vc, va, vb);",
"tcg_gen_ext32s_i64(vc, vc);",
"break;",
"case 0x0B:\ntmp = tcg_temp_new();",
"tcg_gen_shli_i64(tmp, va, 2);",
"tcg_gen_sub_i64(tmp, tmp, vb);",
"tcg_gen_ext32s_i64(vc, tmp);",
"tcg_temp_free(tmp);",
"break;",
"case 0x0F:\ngen_helper_cmpbge(vc, va, vb);",
"break;",
"case 0x12:\ntmp = tcg_temp_new();",
"tcg_gen_shli_i64(tmp, va, 3);",
"tcg_gen_add_i64(tmp, tmp, vb);",
"tcg_gen_ext32s_i64(vc, tmp);",
"tcg_temp_free(tmp);",
"break;",
"case 0x1B:\ntmp = tcg_temp_new();",
"tcg_gen_shli_i64(tmp, va, 3);",
"tcg_gen_sub_i64(tmp, tmp, vb);",
"tcg_gen_ext32s_i64(vc, tmp);",
"tcg_temp_free(tmp);",
"break;",
"case 0x1D:\ntcg_gen_setcond_i64(TCG_COND_LTU, vc, va, vb);",
"break;",
"case 0x20:\ntcg_gen_add_i64(vc, va, vb);",
"break;",
"case 0x22:\ntmp = tcg_temp_new();",
"tcg_gen_shli_i64(tmp, va, 2);",
"tcg_gen_add_i64(vc, tmp, vb);",
"tcg_temp_free(tmp);",
"break;",
"case 0x29:\ntcg_gen_sub_i64(vc, va, vb);",
"break;",
"case 0x2B:\ntmp = tcg_temp_new();",
"tcg_gen_shli_i64(tmp, va, 2);",
"tcg_gen_sub_i64(vc, tmp, vb);",
"tcg_temp_free(tmp);",
"break;",
"case 0x2D:\ntcg_gen_setcond_i64(TCG_COND_EQ, vc, va, vb);",
"break;",
"case 0x32:\ntmp = tcg_temp_new();",
"tcg_gen_shli_i64(tmp, va, 3);",
"tcg_gen_add_i64(vc, tmp, vb);",
"tcg_temp_free(tmp);",
"break;",
"case 0x3B:\ntmp = tcg_temp_new();",
"tcg_gen_shli_i64(tmp, va, 3);",
"tcg_gen_sub_i64(vc, tmp, vb);",
"tcg_temp_free(tmp);",
"break;",
"case 0x3D:\ntcg_gen_setcond_i64(TCG_COND_LEU, vc, va, vb);",
"break;",
"case 0x40:\ngen_helper_addlv(vc, cpu_env, va, vb);",
"break;",
"case 0x49:\ngen_helper_sublv(vc, cpu_env, va, vb);",
"break;",
"case 0x4D:\ntcg_gen_setcond_i64(TCG_COND_LT, vc, va, vb);",
"break;",
"case 0x60:\ngen_helper_addqv(vc, cpu_env, va, vb);",
"break;",
"case 0x69:\ngen_helper_subqv(vc, cpu_env, va, vb);",
"break;",
"case 0x6D:\ntcg_gen_setcond_i64(TCG_COND_LE, vc, va, vb);",
"break;",
"default:\ngoto invalid_opc;",
"}",
"break;",
"case 0x11:\nif (fn7 == 0x20) {",
"if (rc == 31) {",
"break;",
"}",
"if (ra == 31) {",
"vc = dest_gpr(ctx, rc);",
"if (islit) {",
"tcg_gen_movi_i64(vc, lit);",
"} else {",
"tcg_gen_mov_i64(vc, load_gpr(ctx, rb));",
"}",
"break;",
"}",
"}",
"vc = dest_gpr(ctx, rc);",
"vb = load_gpr_lit(ctx, rb, lit, islit);",
"if (fn7 == 0x28 && ra == 31) {",
"tcg_gen_not_i64(vc, vb);",
"break;",
"}",
"va = load_gpr(ctx, ra);",
"switch (fn7) {",
"case 0x00:\ntcg_gen_and_i64(vc, va, vb);",
"break;",
"case 0x08:\ntcg_gen_andc_i64(vc, va, vb);",
"break;",
"case 0x14:\ntmp = tcg_temp_new();",
"tcg_gen_andi_i64(tmp, va, 1);",
"tcg_gen_movcond_i64(TCG_COND_NE, vc, tmp, load_zero(ctx),\nvb, load_gpr(ctx, rc));",
"tcg_temp_free(tmp);",
"break;",
"case 0x16:\ntmp = tcg_temp_new();",
"tcg_gen_andi_i64(tmp, va, 1);",
"tcg_gen_movcond_i64(TCG_COND_EQ, vc, tmp, load_zero(ctx),\nvb, load_gpr(ctx, rc));",
"tcg_temp_free(tmp);",
"break;",
"case 0x20:\ntcg_gen_or_i64(vc, va, vb);",
"break;",
"case 0x24:\ntcg_gen_movcond_i64(TCG_COND_EQ, vc, va, load_zero(ctx),\nvb, load_gpr(ctx, rc));",
"break;",
"case 0x26:\ntcg_gen_movcond_i64(TCG_COND_NE, vc, va, load_zero(ctx),\nvb, load_gpr(ctx, rc));",
"break;",
"case 0x28:\ntcg_gen_orc_i64(vc, va, vb);",
"break;",
"case 0x40:\ntcg_gen_xor_i64(vc, va, vb);",
"break;",
"case 0x44:\ntcg_gen_movcond_i64(TCG_COND_LT, vc, va, load_zero(ctx),\nvb, load_gpr(ctx, rc));",
"break;",
"case 0x46:\ntcg_gen_movcond_i64(TCG_COND_GE, vc, va, load_zero(ctx),\nvb, load_gpr(ctx, rc));",
"break;",
"case 0x48:\ntcg_gen_eqv_i64(vc, va, vb);",
"break;",
"case 0x61:\nREQUIRE_REG_31(ra);",
"{",
"uint64_t amask = ctx->tb->flags >> TB_FLAGS_AMASK_SHIFT;",
"tcg_gen_andi_i64(vc, vb, ~amask);",
"}",
"break;",
"case 0x64:\ntcg_gen_movcond_i64(TCG_COND_LE, vc, va, load_zero(ctx),\nvb, load_gpr(ctx, rc));",
"break;",
"case 0x66:\ntcg_gen_movcond_i64(TCG_COND_GT, vc, va, load_zero(ctx),\nvb, load_gpr(ctx, rc));",
"break;",
"case 0x6C:\nREQUIRE_REG_31(ra);",
"tcg_gen_movi_i64(vc, ctx->implver);",
"break;",
"default:\ngoto invalid_opc;",
"}",
"break;",
"case 0x12:\nvc = dest_gpr(ctx, rc);",
"va = load_gpr(ctx, ra);",
"switch (fn7) {",
"case 0x02:\ngen_msk_l(ctx, vc, va, rb, islit, lit, 0x01);",
"break;",
"case 0x06:\ngen_ext_l(ctx, vc, va, rb, islit, lit, 0x01);",
"break;",
"case 0x0B:\ngen_ins_l(ctx, vc, va, rb, islit, lit, 0x01);",
"break;",
"case 0x12:\ngen_msk_l(ctx, vc, va, rb, islit, lit, 0x03);",
"break;",
"case 0x16:\ngen_ext_l(ctx, vc, va, rb, islit, lit, 0x03);",
"break;",
"case 0x1B:\ngen_ins_l(ctx, vc, va, rb, islit, lit, 0x03);",
"break;",
"case 0x22:\ngen_msk_l(ctx, vc, va, rb, islit, lit, 0x0f);",
"break;",
"case 0x26:\ngen_ext_l(ctx, vc, va, rb, islit, lit, 0x0f);",
"break;",
"case 0x2B:\ngen_ins_l(ctx, vc, va, rb, islit, lit, 0x0f);",
"break;",
"case 0x30:\nif (islit) {",
"gen_zapnoti(vc, va, ~lit);",
"} else {",
"gen_helper_zap(vc, va, load_gpr(ctx, rb));",
"}",
"break;",
"case 0x31:\nif (islit) {",
"gen_zapnoti(vc, va, lit);",
"} else {",
"gen_helper_zapnot(vc, va, load_gpr(ctx, rb));",
"}",
"break;",
"case 0x32:\ngen_msk_l(ctx, vc, va, rb, islit, lit, 0xff);",
"break;",
"case 0x34:\nif (islit) {",
"tcg_gen_shri_i64(vc, va, lit & 0x3f);",
"} else {",
"tmp = tcg_temp_new();",
"vb = load_gpr(ctx, rb);",
"tcg_gen_andi_i64(tmp, vb, 0x3f);",
"tcg_gen_shr_i64(vc, va, tmp);",
"tcg_temp_free(tmp);",
"}",
"break;",
"case 0x36:\ngen_ext_l(ctx, vc, va, rb, islit, lit, 0xff);",
"break;",
"case 0x39:\nif (islit) {",
"tcg_gen_shli_i64(vc, va, lit & 0x3f);",
"} else {",
"tmp = tcg_temp_new();",
"vb = load_gpr(ctx, rb);",
"tcg_gen_andi_i64(tmp, vb, 0x3f);",
"tcg_gen_shl_i64(vc, va, tmp);",
"tcg_temp_free(tmp);",
"}",
"break;",
"case 0x3B:\ngen_ins_l(ctx, vc, va, rb, islit, lit, 0xff);",
"break;",
"case 0x3C:\nif (islit) {",
"tcg_gen_sari_i64(vc, va, lit & 0x3f);",
"} else {",
"tmp = tcg_temp_new();",
"vb = load_gpr(ctx, rb);",
"tcg_gen_andi_i64(tmp, vb, 0x3f);",
"tcg_gen_sar_i64(vc, va, tmp);",
"tcg_temp_free(tmp);",
"}",
"break;",
"case 0x52:\ngen_msk_h(ctx, vc, va, rb, islit, lit, 0x03);",
"break;",
"case 0x57:\ngen_ins_h(ctx, vc, va, rb, islit, lit, 0x03);",
"break;",
"case 0x5A:\ngen_ext_h(ctx, vc, va, rb, islit, lit, 0x03);",
"break;",
"case 0x62:\ngen_msk_h(ctx, vc, va, rb, islit, lit, 0x0f);",
"break;",
"case 0x67:\ngen_ins_h(ctx, vc, va, rb, islit, lit, 0x0f);",
"break;",
"case 0x6A:\ngen_ext_h(ctx, vc, va, rb, islit, lit, 0x0f);",
"break;",
"case 0x72:\ngen_msk_h(ctx, vc, va, rb, islit, lit, 0xff);",
"break;",
"case 0x77:\ngen_ins_h(ctx, vc, va, rb, islit, lit, 0xff);",
"break;",
"case 0x7A:\ngen_ext_h(ctx, vc, va, rb, islit, lit, 0xff);",
"break;",
"default:\ngoto invalid_opc;",
"}",
"break;",
"case 0x13:\nvc = dest_gpr(ctx, rc);",
"vb = load_gpr_lit(ctx, rb, lit, islit);",
"va = load_gpr(ctx, ra);",
"switch (fn7) {",
"case 0x00:\ntcg_gen_mul_i64(vc, va, vb);",
"tcg_gen_ext32s_i64(vc, vc);",
"break;",
"case 0x20:\ntcg_gen_mul_i64(vc, va, vb);",
"break;",
"case 0x30:\ntmp = tcg_temp_new();",
"tcg_gen_mulu2_i64(tmp, vc, va, vb);",
"tcg_temp_free(tmp);",
"break;",
"case 0x40:\ngen_helper_mullv(vc, cpu_env, va, vb);",
"break;",
"case 0x60:\ngen_helper_mulqv(vc, cpu_env, va, vb);",
"break;",
"default:\ngoto invalid_opc;",
"}",
"break;",
"case 0x14:\nREQUIRE_TB_FLAG(TB_FLAGS_AMASK_FIX);",
"vc = dest_fpr(ctx, rc);",
"switch (fpfn) {",
"case 0x04:\nREQUIRE_REG_31(rb);",
"t32 = tcg_temp_new_i32();",
"va = load_gpr(ctx, ra);",
"tcg_gen_trunc_i64_i32(t32, va);",
"gen_helper_memory_to_s(vc, t32);",
"tcg_temp_free_i32(t32);",
"break;",
"case 0x0A:\nREQUIRE_REG_31(ra);",
"vb = load_fpr(ctx, rb);",
"gen_helper_sqrtf(vc, cpu_env, vb);",
"break;",
"case 0x0B:\nREQUIRE_REG_31(ra);",
"gen_sqrts(ctx, rb, rc, fn11);",
"break;",
"case 0x14:\nREQUIRE_REG_31(rb);",
"t32 = tcg_temp_new_i32();",
"va = load_gpr(ctx, ra);",
"tcg_gen_trunc_i64_i32(t32, va);",
"gen_helper_memory_to_f(vc, t32);",
"tcg_temp_free_i32(t32);",
"break;",
"case 0x24:\nREQUIRE_REG_31(rb);",
"va = load_gpr(ctx, ra);",
"tcg_gen_mov_i64(vc, va);",
"break;",
"case 0x2A:\nREQUIRE_REG_31(ra);",
"vb = load_fpr(ctx, rb);",
"gen_helper_sqrtg(vc, cpu_env, vb);",
"break;",
"case 0x02B:\nREQUIRE_REG_31(ra);",
"gen_sqrtt(ctx, rb, rc, fn11);",
"break;",
"default:\ngoto invalid_opc;",
"}",
"break;",
"case 0x15:\nvc = dest_fpr(ctx, rc);",
"vb = load_fpr(ctx, rb);",
"va = load_fpr(ctx, ra);",
"switch (fpfn) {",
"case 0x00:\ngen_helper_addf(vc, cpu_env, va, vb);",
"break;",
"case 0x01:\ngen_helper_subf(vc, cpu_env, va, vb);",
"break;",
"case 0x02:\ngen_helper_mulf(vc, cpu_env, va, vb);",
"break;",
"case 0x03:\ngen_helper_divf(vc, cpu_env, va, vb);",
"break;",
"case 0x1E:\nREQUIRE_REG_31(ra);",
"goto invalid_opc;",
"case 0x20:\ngen_helper_addg(vc, cpu_env, va, vb);",
"break;",
"case 0x21:\ngen_helper_subg(vc, cpu_env, va, vb);",
"break;",
"case 0x22:\ngen_helper_mulg(vc, cpu_env, va, vb);",
"break;",
"case 0x23:\ngen_helper_divg(vc, cpu_env, va, vb);",
"break;",
"case 0x25:\ngen_helper_cmpgeq(vc, cpu_env, va, vb);",
"break;",
"case 0x26:\ngen_helper_cmpglt(vc, cpu_env, va, vb);",
"break;",
"case 0x27:\ngen_helper_cmpgle(vc, cpu_env, va, vb);",
"break;",
"case 0x2C:\nREQUIRE_REG_31(ra);",
"gen_helper_cvtgf(vc, cpu_env, vb);",
"break;",
"case 0x2D:\nREQUIRE_REG_31(ra);",
"goto invalid_opc;",
"case 0x2F:\nREQUIRE_REG_31(ra);",
"gen_helper_cvtgq(vc, cpu_env, vb);",
"break;",
"case 0x3C:\nREQUIRE_REG_31(ra);",
"gen_helper_cvtqf(vc, cpu_env, vb);",
"break;",
"case 0x3E:\nREQUIRE_REG_31(ra);",
"gen_helper_cvtqg(vc, cpu_env, vb);",
"break;",
"default:\ngoto invalid_opc;",
"}",
"break;",
"case 0x16:\nswitch (fpfn) {",
"case 0x00:\ngen_adds(ctx, ra, rb, rc, fn11);",
"break;",
"case 0x01:\ngen_subs(ctx, ra, rb, rc, fn11);",
"break;",
"case 0x02:\ngen_muls(ctx, ra, rb, rc, fn11);",
"break;",
"case 0x03:\ngen_divs(ctx, ra, rb, rc, fn11);",
"break;",
"case 0x20:\ngen_addt(ctx, ra, rb, rc, fn11);",
"break;",
"case 0x21:\ngen_subt(ctx, ra, rb, rc, fn11);",
"break;",
"case 0x22:\ngen_mult(ctx, ra, rb, rc, fn11);",
"break;",
"case 0x23:\ngen_divt(ctx, ra, rb, rc, fn11);",
"break;",
"case 0x24:\ngen_cmptun(ctx, ra, rb, rc, fn11);",
"break;",
"case 0x25:\ngen_cmpteq(ctx, ra, rb, rc, fn11);",
"break;",
"case 0x26:\ngen_cmptlt(ctx, ra, rb, rc, fn11);",
"break;",
"case 0x27:\ngen_cmptle(ctx, ra, rb, rc, fn11);",
"break;",
"case 0x2C:\nREQUIRE_REG_31(ra);",
"if (fn11 == 0x2AC || fn11 == 0x6AC) {",
"gen_cvtst(ctx, rb, rc, fn11);",
"} else {",
"gen_cvtts(ctx, rb, rc, fn11);",
"}",
"break;",
"case 0x2F:\nREQUIRE_REG_31(ra);",
"gen_cvttq(ctx, rb, rc, fn11);",
"break;",
"case 0x3C:\nREQUIRE_REG_31(ra);",
"gen_cvtqs(ctx, rb, rc, fn11);",
"break;",
"case 0x3E:\nREQUIRE_REG_31(ra);",
"gen_cvtqt(ctx, rb, rc, fn11);",
"break;",
"default:\ngoto invalid_opc;",
"}",
"break;",
"case 0x17:\nswitch (fn11) {",
"case 0x010:\nREQUIRE_REG_31(ra);",
"vc = dest_fpr(ctx, rc);",
"vb = load_fpr(ctx, rb);",
"gen_cvtlq(vc, vb);",
"break;",
"case 0x020:\nif (rc == 31) {",
"} else {",
"vc = dest_fpr(ctx, rc);",
"va = load_fpr(ctx, ra);",
"if (ra == rb) {",
"tcg_gen_mov_i64(vc, va);",
"} else {",
"vb = load_fpr(ctx, rb);",
"gen_cpy_mask(vc, va, vb, 0, 0x8000000000000000ULL);",
"}",
"}",
"break;",
"case 0x021:\nvc = dest_fpr(ctx, rc);",
"vb = load_fpr(ctx, rb);",
"va = load_fpr(ctx, ra);",
"gen_cpy_mask(vc, va, vb, 1, 0x8000000000000000ULL);",
"break;",
"case 0x022:\nvc = dest_fpr(ctx, rc);",
"vb = load_fpr(ctx, rb);",
"va = load_fpr(ctx, ra);",
"gen_cpy_mask(vc, va, vb, 0, 0xFFF0000000000000ULL);",
"break;",
"case 0x024:\nva = load_fpr(ctx, ra);",
"gen_helper_store_fpcr(cpu_env, va);",
"if (ctx->tb_rm == QUAL_RM_D) {",
"ctx->tb_rm = -1;",
"}",
"break;",
"case 0x025:\nva = dest_fpr(ctx, ra);",
"gen_helper_load_fpcr(va, cpu_env);",
"break;",
"case 0x02A:\ngen_fcmov(ctx, TCG_COND_EQ, ra, rb, rc);",
"break;",
"case 0x02B:\ngen_fcmov(ctx, TCG_COND_NE, ra, rb, rc);",
"break;",
"case 0x02C:\ngen_fcmov(ctx, TCG_COND_LT, ra, rb, rc);",
"break;",
"case 0x02D:\ngen_fcmov(ctx, TCG_COND_GE, ra, rb, rc);",
"break;",
"case 0x02E:\ngen_fcmov(ctx, TCG_COND_LE, ra, rb, rc);",
"break;",
"case 0x02F:\ngen_fcmov(ctx, TCG_COND_GT, ra, rb, rc);",
"break;",
"case 0x030:\nREQUIRE_REG_31(ra);",
"vc = dest_fpr(ctx, rc);",
"vb = load_fpr(ctx, rb);",
"gen_cvtql(vc, vb);",
"break;",
"case 0x130:\ncase 0x530:\nREQUIRE_REG_31(ra);",
"vc = dest_fpr(ctx, rc);",
"vb = load_fpr(ctx, rb);",
"gen_helper_cvtql_v_input(cpu_env, vb);",
"gen_cvtql(vc, vb);",
"break;",
"default:\ngoto invalid_opc;",
"}",
"break;",
"case 0x18:\nswitch ((uint16_t)disp16) {",
"case 0x0000:\nbreak;",
"case 0x0400:\nbreak;",
"case 0x4000:\nbreak;",
"case 0x4400:\nbreak;",
"case 0x8000:\nbreak;",
"case 0xA000:\nbreak;",
"case 0xC000:\nva = dest_gpr(ctx, ra);",
"if (ctx->tb->cflags & CF_USE_ICOUNT) {",
"gen_io_start();",
"gen_helper_load_pcc(va, cpu_env);",
"gen_io_end();",
"ret = EXIT_PC_STALE;",
"} else {",
"gen_helper_load_pcc(va, cpu_env);",
"}",
"break;",
"case 0xE000:\ngen_rx(ra, 0);",
"break;",
"case 0xE800:\nbreak;",
"case 0xF000:\ngen_rx(ra, 1);",
"break;",
"case 0xF800:\nbreak;",
"default:\ngoto invalid_opc;",
"}",
"break;",
"case 0x19:\n#ifndef CONFIG_USER_ONLY\nREQUIRE_TB_FLAG(TB_FLAGS_PAL_MODE);",
"va = dest_gpr(ctx, ra);",
"ret = gen_mfpr(ctx, va, insn & 0xffff);",
"break;",
"#else\ngoto invalid_opc;",
"#endif\ncase 0x1A:\nvb = load_gpr(ctx, rb);",
"tcg_gen_andi_i64(cpu_pc, vb, ~3);",
"if (ra != 31) {",
"tcg_gen_movi_i64(cpu_ir[ra], ctx->pc);",
"}",
"ret = EXIT_PC_UPDATED;",
"break;",
"case 0x1B:\n#ifndef CONFIG_USER_ONLY\nREQUIRE_TB_FLAG(TB_FLAGS_PAL_MODE);",
"{",
"TCGv addr = tcg_temp_new();",
"vb = load_gpr(ctx, rb);",
"va = dest_gpr(ctx, ra);",
"tcg_gen_addi_i64(addr, vb, disp12);",
"switch ((insn >> 12) & 0xF) {",
"case 0x0:\ngen_helper_ldl_phys(va, cpu_env, addr);",
"break;",
"case 0x1:\ngen_helper_ldq_phys(va, cpu_env, addr);",
"break;",
"case 0x2:\ngen_helper_ldl_l_phys(va, cpu_env, addr);",
"break;",
"case 0x3:\ngen_helper_ldq_l_phys(va, cpu_env, addr);",
"break;",
"case 0x4:\ngoto invalid_opc;",
"case 0x5:\ngoto invalid_opc;",
"break;",
"case 0x6:\ngoto invalid_opc;",
"case 0x7:\ngoto invalid_opc;",
"case 0x8:\ngoto invalid_opc;",
"case 0x9:\ngoto invalid_opc;",
"case 0xA:\ntcg_gen_qemu_ld_i64(va, addr, MMU_KERNEL_IDX, MO_LESL);",
"break;",
"case 0xB:\ntcg_gen_qemu_ld_i64(va, addr, MMU_KERNEL_IDX, MO_LEQ);",
"break;",
"case 0xC:\ngoto invalid_opc;",
"case 0xD:\ngoto invalid_opc;",
"case 0xE:\ntcg_gen_qemu_ld_i64(va, addr, MMU_USER_IDX, MO_LESL);",
"break;",
"case 0xF:\ntcg_gen_qemu_ld_i64(va, addr, MMU_USER_IDX, MO_LEQ);",
"break;",
"}",
"tcg_temp_free(addr);",
"break;",
"}",
"#else\ngoto invalid_opc;",
"#endif\ncase 0x1C:\nvc = dest_gpr(ctx, rc);",
"if (fn7 == 0x70) {",
"REQUIRE_TB_FLAG(TB_FLAGS_AMASK_FIX);",
"REQUIRE_REG_31(rb);",
"va = load_fpr(ctx, ra);",
"tcg_gen_mov_i64(vc, va);",
"break;",
"} else if (fn7 == 0x78) {",
"REQUIRE_TB_FLAG(TB_FLAGS_AMASK_FIX);",
"REQUIRE_REG_31(rb);",
"t32 = tcg_temp_new_i32();",
"va = load_fpr(ctx, ra);",
"gen_helper_s_to_memory(t32, va);",
"tcg_gen_ext_i32_i64(vc, t32);",
"tcg_temp_free_i32(t32);",
"break;",
"}",
"vb = load_gpr_lit(ctx, rb, lit, islit);",
"switch (fn7) {",
"case 0x00:\nREQUIRE_TB_FLAG(TB_FLAGS_AMASK_BWX);",
"REQUIRE_REG_31(ra);",
"tcg_gen_ext8s_i64(vc, vb);",
"break;",
"case 0x01:\nREQUIRE_TB_FLAG(TB_FLAGS_AMASK_BWX);",
"REQUIRE_REG_31(ra);",
"tcg_gen_ext16s_i64(vc, vb);",
"break;",
"case 0x30:\nREQUIRE_TB_FLAG(TB_FLAGS_AMASK_CIX);",
"REQUIRE_REG_31(ra);",
"gen_helper_ctpop(vc, vb);",
"break;",
"case 0x31:\nREQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);",
"va = load_gpr(ctx, ra);",
"gen_helper_perr(vc, va, vb);",
"break;",
"case 0x32:\nREQUIRE_TB_FLAG(TB_FLAGS_AMASK_CIX);",
"REQUIRE_REG_31(ra);",
"gen_helper_ctlz(vc, vb);",
"break;",
"case 0x33:\nREQUIRE_TB_FLAG(TB_FLAGS_AMASK_CIX);",
"REQUIRE_REG_31(ra);",
"gen_helper_cttz(vc, vb);",
"break;",
"case 0x34:\nREQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);",
"REQUIRE_REG_31(ra);",
"gen_helper_unpkbw(vc, vb);",
"break;",
"case 0x35:\nREQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);",
"REQUIRE_REG_31(ra);",
"gen_helper_unpkbl(vc, vb);",
"break;",
"case 0x36:\nREQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);",
"REQUIRE_REG_31(ra);",
"gen_helper_pkwb(vc, vb);",
"break;",
"case 0x37:\nREQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);",
"REQUIRE_REG_31(ra);",
"gen_helper_pklb(vc, vb);",
"break;",
"case 0x38:\nREQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);",
"va = load_gpr(ctx, ra);",
"gen_helper_minsb8(vc, va, vb);",
"break;",
"case 0x39:\nREQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);",
"va = load_gpr(ctx, ra);",
"gen_helper_minsw4(vc, va, vb);",
"break;",
"case 0x3A:\nREQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);",
"va = load_gpr(ctx, ra);",
"gen_helper_minub8(vc, va, vb);",
"break;",
"case 0x3B:\nREQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);",
"va = load_gpr(ctx, ra);",
"gen_helper_minuw4(vc, va, vb);",
"break;",
"case 0x3C:\nREQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);",
"va = load_gpr(ctx, ra);",
"gen_helper_maxub8(vc, va, vb);",
"break;",
"case 0x3D:\nREQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);",
"va = load_gpr(ctx, ra);",
"gen_helper_maxuw4(vc, va, vb);",
"break;",
"case 0x3E:\nREQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);",
"va = load_gpr(ctx, ra);",
"gen_helper_maxsb8(vc, va, vb);",
"break;",
"case 0x3F:\nREQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI);",
"va = load_gpr(ctx, ra);",
"gen_helper_maxsw4(vc, va, vb);",
"break;",
"default:\ngoto invalid_opc;",
"}",
"break;",
"case 0x1D:\n#ifndef CONFIG_USER_ONLY\nREQUIRE_TB_FLAG(TB_FLAGS_PAL_MODE);",
"vb = load_gpr(ctx, rb);",
"ret = gen_mtpr(ctx, vb, insn & 0xffff);",
"break;",
"#else\ngoto invalid_opc;",
"#endif\ncase 0x1E:\n#ifndef CONFIG_USER_ONLY\nREQUIRE_TB_FLAG(TB_FLAGS_PAL_MODE);",
"if (rb == 31) {",
"tmp = tcg_temp_new();",
"tcg_gen_ld_i64(tmp, cpu_env, offsetof(CPUAlphaState, exc_addr));",
"gen_helper_hw_ret(cpu_env, tmp);",
"tcg_temp_free(tmp);",
"} else {",
"gen_helper_hw_ret(cpu_env, load_gpr(ctx, rb));",
"}",
"ret = EXIT_PC_UPDATED;",
"break;",
"#else\ngoto invalid_opc;",
"#endif\ncase 0x1F:\n#ifndef CONFIG_USER_ONLY\nREQUIRE_TB_FLAG(TB_FLAGS_PAL_MODE);",
"{",
"TCGv addr = tcg_temp_new();",
"va = load_gpr(ctx, ra);",
"vb = load_gpr(ctx, rb);",
"tcg_gen_addi_i64(addr, vb, disp12);",
"switch ((insn >> 12) & 0xF) {",
"case 0x0:\ngen_helper_stl_phys(cpu_env, addr, va);",
"break;",
"case 0x1:\ngen_helper_stq_phys(cpu_env, addr, va);",
"break;",
"case 0x2:\ngen_helper_stl_c_phys(dest_gpr(ctx, ra), cpu_env, addr, va);",
"break;",
"case 0x3:\ngen_helper_stq_c_phys(dest_gpr(ctx, ra), cpu_env, addr, va);",
"break;",
"case 0x4:\ngoto invalid_opc;",
"case 0x5:\ngoto invalid_opc;",
"case 0x6:\ngoto invalid_opc;",
"case 0x7:\ngoto invalid_opc;",
"case 0x8:\ngoto invalid_opc;",
"case 0x9:\ngoto invalid_opc;",
"case 0xA:\ngoto invalid_opc;",
"case 0xB:\ngoto invalid_opc;",
"case 0xC:\ngoto invalid_opc;",
"case 0xD:\ngoto invalid_opc;",
"case 0xE:\ngoto invalid_opc;",
"case 0xF:\ngoto invalid_opc;",
"}",
"tcg_temp_free(addr);",
"break;",
"}",
"#else\ngoto invalid_opc;",
"#endif\ncase 0x20:\ngen_load_mem(ctx, &gen_qemu_ldf, ra, rb, disp16, 1, 0);",
"break;",
"case 0x21:\ngen_load_mem(ctx, &gen_qemu_ldg, ra, rb, disp16, 1, 0);",
"break;",
"case 0x22:\ngen_load_mem(ctx, &gen_qemu_lds, ra, rb, disp16, 1, 0);",
"break;",
"case 0x23:\ngen_load_mem(ctx, &tcg_gen_qemu_ld64, ra, rb, disp16, 1, 0);",
"break;",
"case 0x24:\ngen_store_mem(ctx, &gen_qemu_stf, ra, rb, disp16, 1, 0);",
"break;",
"case 0x25:\ngen_store_mem(ctx, &gen_qemu_stg, ra, rb, disp16, 1, 0);",
"break;",
"case 0x26:\ngen_store_mem(ctx, &gen_qemu_sts, ra, rb, disp16, 1, 0);",
"break;",
"case 0x27:\ngen_store_mem(ctx, &tcg_gen_qemu_st64, ra, rb, disp16, 1, 0);",
"break;",
"case 0x28:\ngen_load_mem(ctx, &tcg_gen_qemu_ld32s, ra, rb, disp16, 0, 0);",
"break;",
"case 0x29:\ngen_load_mem(ctx, &tcg_gen_qemu_ld64, ra, rb, disp16, 0, 0);",
"break;",
"case 0x2A:\ngen_load_mem(ctx, &gen_qemu_ldl_l, ra, rb, disp16, 0, 0);",
"break;",
"case 0x2B:\ngen_load_mem(ctx, &gen_qemu_ldq_l, ra, rb, disp16, 0, 0);",
"break;",
"case 0x2C:\ngen_store_mem(ctx, &tcg_gen_qemu_st32, ra, rb, disp16, 0, 0);",
"break;",
"case 0x2D:\ngen_store_mem(ctx, &tcg_gen_qemu_st64, ra, rb, disp16, 0, 0);",
"break;",
"case 0x2E:\nret = gen_store_conditional(ctx, ra, rb, disp16, 0);",
"break;",
"case 0x2F:\nret = gen_store_conditional(ctx, ra, rb, disp16, 1);",
"break;",
"case 0x30:\nret = gen_bdirect(ctx, ra, disp21);",
"break;",
"case 0x31:\nret = gen_fbcond(ctx, TCG_COND_EQ, ra, disp21);",
"break;",
"case 0x32:\nret = gen_fbcond(ctx, TCG_COND_LT, ra, disp21);",
"break;",
"case 0x33:\nret = gen_fbcond(ctx, TCG_COND_LE, ra, disp21);",
"break;",
"case 0x34:\nret = gen_bdirect(ctx, ra, disp21);",
"break;",
"case 0x35:\nret = gen_fbcond(ctx, TCG_COND_NE, ra, disp21);",
"break;",
"case 0x36:\nret = gen_fbcond(ctx, TCG_COND_GE, ra, disp21);",
"break;",
"case 0x37:\nret = gen_fbcond(ctx, TCG_COND_GT, ra, disp21);",
"break;",
"case 0x38:\nret = gen_bcond(ctx, TCG_COND_EQ, ra, disp21, 1);",
"break;",
"case 0x39:\nret = gen_bcond(ctx, TCG_COND_EQ, ra, disp21, 0);",
"break;",
"case 0x3A:\nret = gen_bcond(ctx, TCG_COND_LT, ra, disp21, 0);",
"break;",
"case 0x3B:\nret = gen_bcond(ctx, TCG_COND_LE, ra, disp21, 0);",
"break;",
"case 0x3C:\nret = gen_bcond(ctx, TCG_COND_NE, ra, disp21, 1);",
"break;",
"case 0x3D:\nret = gen_bcond(ctx, TCG_COND_NE, ra, disp21, 0);",
"break;",
"case 0x3E:\nret = gen_bcond(ctx, TCG_COND_GE, ra, disp21, 0);",
"break;",
"case 0x3F:\nret = gen_bcond(ctx, TCG_COND_GT, ra, disp21, 0);",
"break;",
"invalid_opc:\nret = gen_invalid(ctx);",
"break;",
"}",
"return ret;",
"}"
] | [
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
1,
0,
0,
0,
1,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67,
71
],
[
73
],
[
75,
79
],
[
81,
85
],
[
87,
91
],
[
93,
97
],
[
99,
103
],
[
105,
109
],
[
111,
115
],
[
119,
123
],
[
127,
131
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
149,
153
],
[
155
],
[
157
],
[
159,
163
],
[
165
],
[
167,
171
],
[
173
],
[
175
],
[
177,
181
],
[
183
],
[
185
],
[
187,
191
],
[
193
],
[
195
],
[
197,
201
],
[
203
],
[
207,
209
],
[
211
],
[
215
],
[
217
],
[
221
],
[
223
],
[
225
],
[
227
],
[
231
],
[
233
],
[
235
],
[
237
],
[
241
],
[
243
],
[
245,
249
],
[
251
],
[
253
],
[
255,
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271,
275
],
[
277
],
[
279
],
[
281,
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297,
301
],
[
303
],
[
305,
309
],
[
311
],
[
313
],
[
315
],
[
317
],
[
319
],
[
321,
325
],
[
327
],
[
329
],
[
331
],
[
333
],
[
335
],
[
337,
341
],
[
343
],
[
345,
349
],
[
351
],
[
353,
357
],
[
359
],
[
361
],
[
363
],
[
365
],
[
367,
371
],
[
373
],
[
375,
379
],
[
381
],
[
383
],
[
385
],
[
387
],
[
389,
393
],
[
395
],
[
397,
401
],
[
403
],
[
405
],
[
407
],
[
409
],
[
411,
415
],
[
417
],
[
419
],
[
421
],
[
423
],
[
425,
429
],
[
431
],
[
433,
437
],
[
439
],
[
441,
445
],
[
447
],
[
449,
453
],
[
455
],
[
457,
461
],
[
463
],
[
465,
469
],
[
471
],
[
473,
477
],
[
479
],
[
481,
483
],
[
485
],
[
487
],
[
491,
493
],
[
495
],
[
499
],
[
501
],
[
503
],
[
507
],
[
509
],
[
511
],
[
513
],
[
515
],
[
517
],
[
519
],
[
521
],
[
523
],
[
527
],
[
529
],
[
533
],
[
537
],
[
539
],
[
541
],
[
545
],
[
547
],
[
549,
553
],
[
555
],
[
557,
561
],
[
563
],
[
565,
569
],
[
571
],
[
573,
575
],
[
577
],
[
579
],
[
581,
585
],
[
587
],
[
589,
591
],
[
593
],
[
595
],
[
597,
601
],
[
603
],
[
605,
609,
611
],
[
613
],
[
615,
619,
621
],
[
623
],
[
625,
629
],
[
631
],
[
633,
637
],
[
639
],
[
641,
645,
647
],
[
649
],
[
651,
655,
657
],
[
659
],
[
661,
665
],
[
667
],
[
669,
673
],
[
675
],
[
677
],
[
679
],
[
681
],
[
683
],
[
685,
689,
691
],
[
693
],
[
695,
699,
701
],
[
703
],
[
705,
709
],
[
711
],
[
713
],
[
715,
717
],
[
719
],
[
721
],
[
725,
727
],
[
729
],
[
731
],
[
733,
737
],
[
739
],
[
741,
745
],
[
747
],
[
749,
753
],
[
755
],
[
757,
761
],
[
763
],
[
765,
769
],
[
771
],
[
773,
777
],
[
779
],
[
781,
785
],
[
787
],
[
789,
793
],
[
795
],
[
797,
801
],
[
803
],
[
805,
809
],
[
811
],
[
813
],
[
815
],
[
817
],
[
819
],
[
821,
825
],
[
827
],
[
829
],
[
831
],
[
833
],
[
835
],
[
837,
841
],
[
843
],
[
845,
849
],
[
851
],
[
853
],
[
855
],
[
857
],
[
859
],
[
861
],
[
863
],
[
865
],
[
867
],
[
869,
873
],
[
875
],
[
877,
881
],
[
883
],
[
885
],
[
887
],
[
889
],
[
891
],
[
893
],
[
895
],
[
897
],
[
899
],
[
901,
905
],
[
907
],
[
909,
913
],
[
915
],
[
917
],
[
919
],
[
921
],
[
923
],
[
925
],
[
927
],
[
929
],
[
931
],
[
933,
937
],
[
939
],
[
941,
945
],
[
947
],
[
949,
953
],
[
955
],
[
957,
961
],
[
963
],
[
965,
969
],
[
971
],
[
973,
977
],
[
979
],
[
981,
985
],
[
987
],
[
989,
993
],
[
995
],
[
997,
1001
],
[
1003
],
[
1005,
1007
],
[
1009
],
[
1011
],
[
1015,
1017
],
[
1019
],
[
1021
],
[
1023
],
[
1025,
1029
],
[
1031
],
[
1033
],
[
1035,
1039
],
[
1041
],
[
1043,
1047
],
[
1049
],
[
1051
],
[
1053
],
[
1055,
1059
],
[
1061
],
[
1063,
1067
],
[
1069
],
[
1071,
1073
],
[
1075
],
[
1077
],
[
1081,
1083
],
[
1085
],
[
1087
],
[
1089,
1093
],
[
1095
],
[
1097
],
[
1099
],
[
1101
],
[
1103
],
[
1105
],
[
1107,
1111
],
[
1113
],
[
1115
],
[
1117
],
[
1119,
1123
],
[
1125
],
[
1127
],
[
1129,
1133
],
[
1135
],
[
1137
],
[
1139
],
[
1141
],
[
1143
],
[
1145
],
[
1147,
1151
],
[
1153
],
[
1155
],
[
1157
],
[
1159,
1163
],
[
1165
],
[
1167
],
[
1169
],
[
1171,
1175
],
[
1177
],
[
1179
],
[
1181,
1183
],
[
1185
],
[
1187
],
[
1191,
1197
],
[
1199
],
[
1201
],
[
1203
],
[
1205,
1209
],
[
1211
],
[
1213,
1217
],
[
1219
],
[
1221,
1225
],
[
1227
],
[
1229,
1233
],
[
1235
],
[
1237,
1241
],
[
1243
],
[
1245,
1249
],
[
1251
],
[
1253,
1257
],
[
1259
],
[
1261,
1265
],
[
1267
],
[
1269,
1273
],
[
1275
],
[
1277,
1281
],
[
1283
],
[
1285,
1289
],
[
1291
],
[
1293,
1297
],
[
1299
],
[
1301,
1305
],
[
1307
],
[
1309
],
[
1311,
1315
],
[
1317
],
[
1319,
1323
],
[
1325
],
[
1327
],
[
1329,
1333
],
[
1335
],
[
1337
],
[
1339,
1343
],
[
1345
],
[
1347
],
[
1349,
1351
],
[
1353
],
[
1355
],
[
1359,
1363
],
[
1365,
1369
],
[
1371
],
[
1373,
1377
],
[
1379
],
[
1381,
1385
],
[
1387
],
[
1389,
1393
],
[
1395
],
[
1397,
1401
],
[
1403
],
[
1405,
1409
],
[
1411
],
[
1413,
1417
],
[
1419
],
[
1421,
1425
],
[
1427
],
[
1429,
1433
],
[
1435
],
[
1437,
1441
],
[
1443
],
[
1445,
1449
],
[
1451
],
[
1453,
1457
],
[
1459
],
[
1461,
1463
],
[
1465
],
[
1469
],
[
1471
],
[
1475
],
[
1477
],
[
1479
],
[
1481,
1485
],
[
1487
],
[
1489
],
[
1491,
1495
],
[
1497
],
[
1499
],
[
1501,
1505
],
[
1507
],
[
1509
],
[
1511,
1513
],
[
1515
],
[
1517
],
[
1521,
1523
],
[
1525,
1529
],
[
1531
],
[
1533
],
[
1535
],
[
1537
],
[
1539,
1543
],
[
1547
],
[
1549
],
[
1551
],
[
1553
],
[
1557
],
[
1559
],
[
1561
],
[
1563
],
[
1565
],
[
1567
],
[
1569
],
[
1571,
1575
],
[
1577
],
[
1579
],
[
1581
],
[
1583
],
[
1585,
1589
],
[
1591
],
[
1593
],
[
1595
],
[
1597
],
[
1599,
1603
],
[
1605
],
[
1607
],
[
1613
],
[
1615
],
[
1617
],
[
1619,
1623
],
[
1625
],
[
1627
],
[
1629,
1633
],
[
1635
],
[
1637,
1641
],
[
1643
],
[
1645,
1649
],
[
1651
],
[
1653,
1657
],
[
1659
],
[
1661,
1665
],
[
1667
],
[
1669,
1673
],
[
1675
],
[
1677,
1681
],
[
1683
],
[
1685
],
[
1687
],
[
1689
],
[
1691,
1695,
1699
],
[
1707
],
[
1709
],
[
1711
],
[
1713
],
[
1715
],
[
1717,
1719
],
[
1721
],
[
1723
],
[
1727,
1729
],
[
1731,
1737
],
[
1739,
1745
],
[
1747,
1753
],
[
1755,
1761
],
[
1763,
1769
],
[
1771,
1777
],
[
1779,
1783
],
[
1785
],
[
1787
],
[
1789
],
[
1791
],
[
1793
],
[
1795
],
[
1797
],
[
1799
],
[
1801
],
[
1803,
1807
],
[
1809
],
[
1811,
1815
],
[
1817,
1821
],
[
1823
],
[
1825,
1831
],
[
1833,
1835
],
[
1837
],
[
1839
],
[
1843,
1847,
1849
],
[
1851
],
[
1853
],
[
1855
],
[
1857,
1859
],
[
1861,
1865,
1871
],
[
1873
],
[
1875
],
[
1877
],
[
1879
],
[
1881
],
[
1883
],
[
1887,
1891,
1893
],
[
1895
],
[
1897
],
[
1899
],
[
1901
],
[
1905
],
[
1907
],
[
1909,
1913
],
[
1915
],
[
1917,
1921
],
[
1923
],
[
1925,
1929
],
[
1931
],
[
1933,
1937
],
[
1939
],
[
1941,
1945
],
[
1947,
1951
],
[
1953
],
[
1955,
1959
],
[
1961,
1965
],
[
1967,
1971
],
[
1973,
1977
],
[
1979,
1983
],
[
1985
],
[
1987,
1991
],
[
1993
],
[
1995,
1999
],
[
2001,
2005
],
[
2007,
2013
],
[
2015
],
[
2017,
2023
],
[
2025
],
[
2027
],
[
2029
],
[
2031
],
[
2033
],
[
2035,
2037
],
[
2039,
2043,
2045
],
[
2047
],
[
2051
],
[
2053
],
[
2055
],
[
2057
],
[
2059
],
[
2061
],
[
2065
],
[
2067
],
[
2069
],
[
2071
],
[
2073
],
[
2075
],
[
2077
],
[
2079
],
[
2081
],
[
2085
],
[
2087
],
[
2089,
2093
],
[
2095
],
[
2097
],
[
2099
],
[
2101,
2105
],
[
2107
],
[
2109
],
[
2111
],
[
2113,
2117
],
[
2119
],
[
2121
],
[
2123
],
[
2125,
2129
],
[
2131
],
[
2133
],
[
2135
],
[
2137,
2141
],
[
2143
],
[
2145
],
[
2147
],
[
2149,
2153
],
[
2155
],
[
2157
],
[
2159
],
[
2161,
2165
],
[
2167
],
[
2169
],
[
2171
],
[
2173,
2177
],
[
2179
],
[
2181
],
[
2183
],
[
2185,
2189
],
[
2191
],
[
2193
],
[
2195
],
[
2197,
2201
],
[
2203
],
[
2205
],
[
2207
],
[
2209,
2213
],
[
2215
],
[
2217
],
[
2219
],
[
2221,
2225
],
[
2227
],
[
2229
],
[
2231
],
[
2233,
2237
],
[
2239
],
[
2241
],
[
2243
],
[
2245,
2249
],
[
2251
],
[
2253
],
[
2255
],
[
2257,
2261
],
[
2263
],
[
2265
],
[
2267
],
[
2269,
2273
],
[
2275
],
[
2277
],
[
2279
],
[
2281,
2285
],
[
2287
],
[
2289
],
[
2291
],
[
2293,
2297
],
[
2299
],
[
2301
],
[
2303
],
[
2305,
2307
],
[
2309
],
[
2311
],
[
2315,
2319,
2321
],
[
2323
],
[
2325
],
[
2327
],
[
2329,
2331
],
[
2333,
2337,
2341,
2343
],
[
2345
],
[
2353
],
[
2355
],
[
2357
],
[
2359
],
[
2361
],
[
2363
],
[
2365
],
[
2367
],
[
2369
],
[
2371,
2373
],
[
2375,
2379,
2383,
2385
],
[
2387
],
[
2389
],
[
2391
],
[
2393
],
[
2397
],
[
2399
],
[
2401,
2405
],
[
2407
],
[
2409,
2413
],
[
2415
],
[
2417,
2421
],
[
2423
],
[
2425,
2429
],
[
2431
],
[
2433,
2437
],
[
2439,
2443
],
[
2445,
2449
],
[
2451,
2455
],
[
2457,
2461
],
[
2463,
2467
],
[
2469,
2473
],
[
2475,
2479
],
[
2481,
2485
],
[
2487,
2491
],
[
2493,
2497
],
[
2499,
2503
],
[
2505
],
[
2507
],
[
2509
],
[
2511
],
[
2513,
2515
],
[
2517,
2519,
2523
],
[
2525
],
[
2527,
2531
],
[
2533
],
[
2535,
2539
],
[
2541
],
[
2543,
2547
],
[
2549
],
[
2551,
2555
],
[
2557
],
[
2559,
2563
],
[
2565
],
[
2567,
2571
],
[
2573
],
[
2575,
2579
],
[
2581
],
[
2583,
2587
],
[
2589
],
[
2591,
2595
],
[
2597
],
[
2599,
2603
],
[
2605
],
[
2607,
2611
],
[
2613
],
[
2615,
2619
],
[
2621
],
[
2623,
2627
],
[
2629
],
[
2631,
2635
],
[
2637
],
[
2639,
2643
],
[
2645
],
[
2647,
2651
],
[
2653
],
[
2655,
2657
],
[
2659
],
[
2661,
2663
],
[
2665
],
[
2667,
2669
],
[
2671
],
[
2673,
2677
],
[
2679
],
[
2681,
2683
],
[
2685
],
[
2687,
2689
],
[
2691
],
[
2693,
2695
],
[
2697
],
[
2699,
2703
],
[
2705
],
[
2707,
2711
],
[
2713
],
[
2715,
2719
],
[
2721
],
[
2723,
2727
],
[
2729
],
[
2731,
2735
],
[
2737
],
[
2739,
2743
],
[
2745
],
[
2747,
2751
],
[
2753
],
[
2755,
2759
],
[
2761
],
[
2763,
2765
],
[
2767
],
[
2769
],
[
2773
],
[
2775
]
] |
22,260 | CPUMIPSState *cpu_mips_init (const char *cpu_model)
{
CPUMIPSState *env;
const mips_def_t *def;
def = cpu_mips_find_by_name(cpu_model);
if (!def)
return NULL;
env = qemu_mallocz(sizeof(CPUMIPSState));
env->cpu_model = def;
cpu_exec_init(env);
env->cpu_model_str = cpu_model;
mips_tcg_init();
cpu_reset(env);
qemu_init_vcpu(env);
return env;
}
| true | qemu | 51cc2e783af5586b2e742ce9e5b2762dc50ad325 | CPUMIPSState *cpu_mips_init (const char *cpu_model)
{
CPUMIPSState *env;
const mips_def_t *def;
def = cpu_mips_find_by_name(cpu_model);
if (!def)
return NULL;
env = qemu_mallocz(sizeof(CPUMIPSState));
env->cpu_model = def;
cpu_exec_init(env);
env->cpu_model_str = cpu_model;
mips_tcg_init();
cpu_reset(env);
qemu_init_vcpu(env);
return env;
}
| {
"code": [
" env->cpu_model_str = cpu_model;"
],
"line_no": [
25
]
} | CPUMIPSState *FUNC_0 (const char *cpu_model)
{
CPUMIPSState *env;
const mips_def_t *VAR_0;
VAR_0 = cpu_mips_find_by_name(cpu_model);
if (!VAR_0)
return NULL;
env = qemu_mallocz(sizeof(CPUMIPSState));
env->cpu_model = VAR_0;
cpu_exec_init(env);
env->cpu_model_str = cpu_model;
mips_tcg_init();
cpu_reset(env);
qemu_init_vcpu(env);
return env;
}
| [
"CPUMIPSState *FUNC_0 (const char *cpu_model)\n{",
"CPUMIPSState *env;",
"const mips_def_t *VAR_0;",
"VAR_0 = cpu_mips_find_by_name(cpu_model);",
"if (!VAR_0)\nreturn NULL;",
"env = qemu_mallocz(sizeof(CPUMIPSState));",
"env->cpu_model = VAR_0;",
"cpu_exec_init(env);",
"env->cpu_model_str = cpu_model;",
"mips_tcg_init();",
"cpu_reset(env);",
"qemu_init_vcpu(env);",
"return env;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13,
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
]
] |
22,262 | static void *qpa_thread_out (void *arg)
{
PAVoiceOut *pa = arg;
HWVoiceOut *hw = &pa->hw;
int threshold;
threshold = conf.divisor ? hw->samples / conf.divisor : 0;
if (audio_pt_lock (&pa->pt, AUDIO_FUNC)) {
return NULL;
}
for (;;) {
int decr, to_mix, rpos;
for (;;) {
if (pa->done) {
goto exit;
}
if (pa->live > threshold) {
break;
}
if (audio_pt_wait (&pa->pt, AUDIO_FUNC)) {
goto exit;
}
}
decr = to_mix = pa->live;
rpos = hw->rpos;
if (audio_pt_unlock (&pa->pt, AUDIO_FUNC)) {
return NULL;
}
while (to_mix) {
int error;
int chunk = audio_MIN (to_mix, hw->samples - rpos);
struct st_sample *src = hw->mix_buf + rpos;
hw->clip (pa->pcm_buf, src, chunk);
if (pa_simple_write (pa->s, pa->pcm_buf,
chunk << hw->info.shift, &error) < 0) {
qpa_logerr (error, "pa_simple_write failed\n");
return NULL;
}
rpos = (rpos + chunk) % hw->samples;
to_mix -= chunk;
}
if (audio_pt_lock (&pa->pt, AUDIO_FUNC)) {
return NULL;
}
pa->rpos = rpos;
pa->live -= decr;
pa->decr += decr;
}
exit:
audio_pt_unlock (&pa->pt, AUDIO_FUNC);
return NULL;
}
| true | qemu | fd5723b385557bc77b93dfe5ab591813407686c0 | static void *qpa_thread_out (void *arg)
{
PAVoiceOut *pa = arg;
HWVoiceOut *hw = &pa->hw;
int threshold;
threshold = conf.divisor ? hw->samples / conf.divisor : 0;
if (audio_pt_lock (&pa->pt, AUDIO_FUNC)) {
return NULL;
}
for (;;) {
int decr, to_mix, rpos;
for (;;) {
if (pa->done) {
goto exit;
}
if (pa->live > threshold) {
break;
}
if (audio_pt_wait (&pa->pt, AUDIO_FUNC)) {
goto exit;
}
}
decr = to_mix = pa->live;
rpos = hw->rpos;
if (audio_pt_unlock (&pa->pt, AUDIO_FUNC)) {
return NULL;
}
while (to_mix) {
int error;
int chunk = audio_MIN (to_mix, hw->samples - rpos);
struct st_sample *src = hw->mix_buf + rpos;
hw->clip (pa->pcm_buf, src, chunk);
if (pa_simple_write (pa->s, pa->pcm_buf,
chunk << hw->info.shift, &error) < 0) {
qpa_logerr (error, "pa_simple_write failed\n");
return NULL;
}
rpos = (rpos + chunk) % hw->samples;
to_mix -= chunk;
}
if (audio_pt_lock (&pa->pt, AUDIO_FUNC)) {
return NULL;
}
pa->rpos = rpos;
pa->live -= decr;
pa->decr += decr;
}
exit:
audio_pt_unlock (&pa->pt, AUDIO_FUNC);
return NULL;
}
| {
"code": [
" pa->live -= decr;"
],
"line_no": [
117
]
} | static void *FUNC_0 (void *VAR_0)
{
PAVoiceOut *pa = VAR_0;
HWVoiceOut *hw = &pa->hw;
int VAR_1;
VAR_1 = conf.divisor ? hw->samples / conf.divisor : 0;
if (audio_pt_lock (&pa->pt, AUDIO_FUNC)) {
return NULL;
}
for (;;) {
int VAR_2, VAR_3, VAR_4;
for (;;) {
if (pa->done) {
goto exit;
}
if (pa->live > VAR_1) {
break;
}
if (audio_pt_wait (&pa->pt, AUDIO_FUNC)) {
goto exit;
}
}
VAR_2 = VAR_3 = pa->live;
VAR_4 = hw->VAR_4;
if (audio_pt_unlock (&pa->pt, AUDIO_FUNC)) {
return NULL;
}
while (VAR_3) {
int VAR_5;
int VAR_6 = audio_MIN (VAR_3, hw->samples - VAR_4);
struct st_sample *VAR_7 = hw->mix_buf + VAR_4;
hw->clip (pa->pcm_buf, VAR_7, VAR_6);
if (pa_simple_write (pa->s, pa->pcm_buf,
VAR_6 << hw->info.shift, &VAR_5) < 0) {
qpa_logerr (VAR_5, "pa_simple_write failed\n");
return NULL;
}
VAR_4 = (VAR_4 + VAR_6) % hw->samples;
VAR_3 -= VAR_6;
}
if (audio_pt_lock (&pa->pt, AUDIO_FUNC)) {
return NULL;
}
pa->VAR_4 = VAR_4;
pa->live -= VAR_2;
pa->VAR_2 += VAR_2;
}
exit:
audio_pt_unlock (&pa->pt, AUDIO_FUNC);
return NULL;
}
| [
"static void *FUNC_0 (void *VAR_0)\n{",
"PAVoiceOut *pa = VAR_0;",
"HWVoiceOut *hw = &pa->hw;",
"int VAR_1;",
"VAR_1 = conf.divisor ? hw->samples / conf.divisor : 0;",
"if (audio_pt_lock (&pa->pt, AUDIO_FUNC)) {",
"return NULL;",
"}",
"for (;;) {",
"int VAR_2, VAR_3, VAR_4;",
"for (;;) {",
"if (pa->done) {",
"goto exit;",
"}",
"if (pa->live > VAR_1) {",
"break;",
"}",
"if (audio_pt_wait (&pa->pt, AUDIO_FUNC)) {",
"goto exit;",
"}",
"}",
"VAR_2 = VAR_3 = pa->live;",
"VAR_4 = hw->VAR_4;",
"if (audio_pt_unlock (&pa->pt, AUDIO_FUNC)) {",
"return NULL;",
"}",
"while (VAR_3) {",
"int VAR_5;",
"int VAR_6 = audio_MIN (VAR_3, hw->samples - VAR_4);",
"struct st_sample *VAR_7 = hw->mix_buf + VAR_4;",
"hw->clip (pa->pcm_buf, VAR_7, VAR_6);",
"if (pa_simple_write (pa->s, pa->pcm_buf,\nVAR_6 << hw->info.shift, &VAR_5) < 0) {",
"qpa_logerr (VAR_5, \"pa_simple_write failed\\n\");",
"return NULL;",
"}",
"VAR_4 = (VAR_4 + VAR_6) % hw->samples;",
"VAR_3 -= VAR_6;",
"}",
"if (audio_pt_lock (&pa->pt, AUDIO_FUNC)) {",
"return NULL;",
"}",
"pa->VAR_4 = VAR_4;",
"pa->live -= VAR_2;",
"pa->VAR_2 += VAR_2;",
"}",
"exit:\naudio_pt_unlock (&pa->pt, AUDIO_FUNC);",
"return NULL;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
87,
89
],
[
91
],
[
93
],
[
95
],
[
99
],
[
101
],
[
103
],
[
107
],
[
109
],
[
111
],
[
115
],
[
117
],
[
119
],
[
121
],
[
125,
127
],
[
129
],
[
131
]
] |
22,263 | static void complete_collecting_data(Flash *s)
{
int i;
s->cur_addr = 0;
for (i = 0; i < get_addr_length(s); ++i) {
s->cur_addr <<= 8;
s->cur_addr |= s->data[i];
}
if (get_addr_length(s) == 3) {
s->cur_addr += s->ear * MAX_3BYTES_SIZE;
}
s->state = STATE_IDLE;
switch (s->cmd_in_progress) {
case DPP:
case QPP:
case PP:
case PP4:
case PP4_4:
s->state = STATE_PAGE_PROGRAM;
break;
case READ:
case READ4:
case FAST_READ:
case FAST_READ4:
case DOR:
case DOR4:
case QOR:
case QOR4:
case DIOR:
case DIOR4:
case QIOR:
case QIOR4:
s->state = STATE_READ;
break;
case ERASE_4K:
case ERASE4_4K:
case ERASE_32K:
case ERASE4_32K:
case ERASE_SECTOR:
case ERASE4_SECTOR:
flash_erase(s, s->cur_addr, s->cmd_in_progress);
break;
case WRSR:
switch (get_man(s)) {
case MAN_SPANSION:
s->quad_enable = !!(s->data[1] & 0x02);
break;
case MAN_MACRONIX:
s->quad_enable = extract32(s->data[0], 6, 1);
if (s->len > 1) {
s->four_bytes_address_mode = extract32(s->data[1], 5, 1);
}
break;
default:
break;
}
if (s->write_enable) {
s->write_enable = false;
}
break;
case EXTEND_ADDR_WRITE:
s->ear = s->data[0];
break;
case WNVCR:
s->nonvolatile_cfg = s->data[0] | (s->data[1] << 8);
break;
case WVCR:
s->volatile_cfg = s->data[0];
break;
case WEVCR:
s->enh_volatile_cfg = s->data[0];
break;
default:
break;
}
}
| true | qemu | b68cb06093a36bd6fbd4d06cd62c08629fea2242 | static void complete_collecting_data(Flash *s)
{
int i;
s->cur_addr = 0;
for (i = 0; i < get_addr_length(s); ++i) {
s->cur_addr <<= 8;
s->cur_addr |= s->data[i];
}
if (get_addr_length(s) == 3) {
s->cur_addr += s->ear * MAX_3BYTES_SIZE;
}
s->state = STATE_IDLE;
switch (s->cmd_in_progress) {
case DPP:
case QPP:
case PP:
case PP4:
case PP4_4:
s->state = STATE_PAGE_PROGRAM;
break;
case READ:
case READ4:
case FAST_READ:
case FAST_READ4:
case DOR:
case DOR4:
case QOR:
case QOR4:
case DIOR:
case DIOR4:
case QIOR:
case QIOR4:
s->state = STATE_READ;
break;
case ERASE_4K:
case ERASE4_4K:
case ERASE_32K:
case ERASE4_32K:
case ERASE_SECTOR:
case ERASE4_SECTOR:
flash_erase(s, s->cur_addr, s->cmd_in_progress);
break;
case WRSR:
switch (get_man(s)) {
case MAN_SPANSION:
s->quad_enable = !!(s->data[1] & 0x02);
break;
case MAN_MACRONIX:
s->quad_enable = extract32(s->data[0], 6, 1);
if (s->len > 1) {
s->four_bytes_address_mode = extract32(s->data[1], 5, 1);
}
break;
default:
break;
}
if (s->write_enable) {
s->write_enable = false;
}
break;
case EXTEND_ADDR_WRITE:
s->ear = s->data[0];
break;
case WNVCR:
s->nonvolatile_cfg = s->data[0] | (s->data[1] << 8);
break;
case WVCR:
s->volatile_cfg = s->data[0];
break;
case WEVCR:
s->enh_volatile_cfg = s->data[0];
break;
default:
break;
}
}
| {
"code": [
" int i;",
" s->cur_addr = 0;",
" for (i = 0; i < get_addr_length(s); ++i) {",
" if (get_addr_length(s) == 3) {",
" s->cur_addr += s->ear * MAX_3BYTES_SIZE;"
],
"line_no": [
5,
9,
13,
23,
25
]
} | static void FUNC_0(Flash *VAR_0)
{
int VAR_1;
VAR_0->cur_addr = 0;
for (VAR_1 = 0; VAR_1 < get_addr_length(VAR_0); ++VAR_1) {
VAR_0->cur_addr <<= 8;
VAR_0->cur_addr |= VAR_0->data[VAR_1];
}
if (get_addr_length(VAR_0) == 3) {
VAR_0->cur_addr += VAR_0->ear * MAX_3BYTES_SIZE;
}
VAR_0->state = STATE_IDLE;
switch (VAR_0->cmd_in_progress) {
case DPP:
case QPP:
case PP:
case PP4:
case PP4_4:
VAR_0->state = STATE_PAGE_PROGRAM;
break;
case READ:
case READ4:
case FAST_READ:
case FAST_READ4:
case DOR:
case DOR4:
case QOR:
case QOR4:
case DIOR:
case DIOR4:
case QIOR:
case QIOR4:
VAR_0->state = STATE_READ;
break;
case ERASE_4K:
case ERASE4_4K:
case ERASE_32K:
case ERASE4_32K:
case ERASE_SECTOR:
case ERASE4_SECTOR:
flash_erase(VAR_0, VAR_0->cur_addr, VAR_0->cmd_in_progress);
break;
case WRSR:
switch (get_man(VAR_0)) {
case MAN_SPANSION:
VAR_0->quad_enable = !!(VAR_0->data[1] & 0x02);
break;
case MAN_MACRONIX:
VAR_0->quad_enable = extract32(VAR_0->data[0], 6, 1);
if (VAR_0->len > 1) {
VAR_0->four_bytes_address_mode = extract32(VAR_0->data[1], 5, 1);
}
break;
default:
break;
}
if (VAR_0->write_enable) {
VAR_0->write_enable = false;
}
break;
case EXTEND_ADDR_WRITE:
VAR_0->ear = VAR_0->data[0];
break;
case WNVCR:
VAR_0->nonvolatile_cfg = VAR_0->data[0] | (VAR_0->data[1] << 8);
break;
case WVCR:
VAR_0->volatile_cfg = VAR_0->data[0];
break;
case WEVCR:
VAR_0->enh_volatile_cfg = VAR_0->data[0];
break;
default:
break;
}
}
| [
"static void FUNC_0(Flash *VAR_0)\n{",
"int VAR_1;",
"VAR_0->cur_addr = 0;",
"for (VAR_1 = 0; VAR_1 < get_addr_length(VAR_0); ++VAR_1) {",
"VAR_0->cur_addr <<= 8;",
"VAR_0->cur_addr |= VAR_0->data[VAR_1];",
"}",
"if (get_addr_length(VAR_0) == 3) {",
"VAR_0->cur_addr += VAR_0->ear * MAX_3BYTES_SIZE;",
"}",
"VAR_0->state = STATE_IDLE;",
"switch (VAR_0->cmd_in_progress) {",
"case DPP:\ncase QPP:\ncase PP:\ncase PP4:\ncase PP4_4:\nVAR_0->state = STATE_PAGE_PROGRAM;",
"break;",
"case READ:\ncase READ4:\ncase FAST_READ:\ncase FAST_READ4:\ncase DOR:\ncase DOR4:\ncase QOR:\ncase QOR4:\ncase DIOR:\ncase DIOR4:\ncase QIOR:\ncase QIOR4:\nVAR_0->state = STATE_READ;",
"break;",
"case ERASE_4K:\ncase ERASE4_4K:\ncase ERASE_32K:\ncase ERASE4_32K:\ncase ERASE_SECTOR:\ncase ERASE4_SECTOR:\nflash_erase(VAR_0, VAR_0->cur_addr, VAR_0->cmd_in_progress);",
"break;",
"case WRSR:\nswitch (get_man(VAR_0)) {",
"case MAN_SPANSION:\nVAR_0->quad_enable = !!(VAR_0->data[1] & 0x02);",
"break;",
"case MAN_MACRONIX:\nVAR_0->quad_enable = extract32(VAR_0->data[0], 6, 1);",
"if (VAR_0->len > 1) {",
"VAR_0->four_bytes_address_mode = extract32(VAR_0->data[1], 5, 1);",
"}",
"break;",
"default:\nbreak;",
"}",
"if (VAR_0->write_enable) {",
"VAR_0->write_enable = false;",
"}",
"break;",
"case EXTEND_ADDR_WRITE:\nVAR_0->ear = VAR_0->data[0];",
"break;",
"case WNVCR:\nVAR_0->nonvolatile_cfg = VAR_0->data[0] | (VAR_0->data[1] << 8);",
"break;",
"case WVCR:\nVAR_0->volatile_cfg = VAR_0->data[0];",
"break;",
"case WEVCR:\nVAR_0->enh_volatile_cfg = VAR_0->data[0];",
"break;",
"default:\nbreak;",
"}",
"}"
] | [
0,
1,
1,
1,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
31
],
[
35
],
[
37,
39,
41,
43,
45,
47
],
[
49
],
[
51,
53,
55,
57,
59,
61,
63,
65,
67,
69,
71,
73,
75
],
[
77
],
[
79,
81,
83,
85,
87,
89,
91
],
[
93
],
[
95,
97
],
[
99,
101
],
[
103
],
[
105,
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117,
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131,
133
],
[
135
],
[
137,
139
],
[
141
],
[
143,
145
],
[
147
],
[
149,
151
],
[
153
],
[
155,
157
],
[
159
],
[
161
]
] |
22,264 | static inline void gen_op_fpexception_im(int fsr_flags)
{
TCGv r_const;
tcg_gen_andi_tl(cpu_fsr, cpu_fsr, ~FSR_FTT_MASK);
tcg_gen_ori_tl(cpu_fsr, cpu_fsr, fsr_flags);
r_const = tcg_const_i32(TT_FP_EXCP);
tcg_gen_helper_0_1(raise_exception, r_const);
tcg_temp_free(r_const);
}
| true | qemu | 47ad35f16ae4b6b93cbfa238d51d4edc7dea90b5 | static inline void gen_op_fpexception_im(int fsr_flags)
{
TCGv r_const;
tcg_gen_andi_tl(cpu_fsr, cpu_fsr, ~FSR_FTT_MASK);
tcg_gen_ori_tl(cpu_fsr, cpu_fsr, fsr_flags);
r_const = tcg_const_i32(TT_FP_EXCP);
tcg_gen_helper_0_1(raise_exception, r_const);
tcg_temp_free(r_const);
}
| {
"code": [
" tcg_gen_andi_tl(cpu_fsr, cpu_fsr, ~FSR_FTT_MASK);"
],
"line_no": [
9
]
} | static inline void FUNC_0(int VAR_0)
{
TCGv r_const;
tcg_gen_andi_tl(cpu_fsr, cpu_fsr, ~FSR_FTT_MASK);
tcg_gen_ori_tl(cpu_fsr, cpu_fsr, VAR_0);
r_const = tcg_const_i32(TT_FP_EXCP);
tcg_gen_helper_0_1(raise_exception, r_const);
tcg_temp_free(r_const);
}
| [
"static inline void FUNC_0(int VAR_0)\n{",
"TCGv r_const;",
"tcg_gen_andi_tl(cpu_fsr, cpu_fsr, ~FSR_FTT_MASK);",
"tcg_gen_ori_tl(cpu_fsr, cpu_fsr, VAR_0);",
"r_const = tcg_const_i32(TT_FP_EXCP);",
"tcg_gen_helper_0_1(raise_exception, r_const);",
"tcg_temp_free(r_const);",
"}"
] | [
0,
0,
1,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
]
] |
22,266 | static int msf_probe(AVProbeData *p)
{
if (memcmp(p->buf, "MSF", 3))
return 0;
if (AV_RB32(p->buf+8) <= 0)
return 0;
if (AV_RB32(p->buf+16) <= 0)
return 0;
return AVPROBE_SCORE_MAX / 3 * 2;
} | true | FFmpeg | a6cd817a544e4e526f18391bd2c7112dc12d2f94 | static int msf_probe(AVProbeData *p)
{
if (memcmp(p->buf, "MSF", 3))
return 0;
if (AV_RB32(p->buf+8) <= 0)
return 0;
if (AV_RB32(p->buf+16) <= 0)
return 0;
return AVPROBE_SCORE_MAX / 3 * 2;
} | {
"code": [],
"line_no": []
} | static int FUNC_0(AVProbeData *VAR_0)
{
if (memcmp(VAR_0->buf, "MSF", 3))
return 0;
if (AV_RB32(VAR_0->buf+8) <= 0)
return 0;
if (AV_RB32(VAR_0->buf+16) <= 0)
return 0;
return AVPROBE_SCORE_MAX / 3 * 2;
} | [
"static int FUNC_0(AVProbeData *VAR_0)\n{",
"if (memcmp(VAR_0->buf, \"MSF\", 3))\nreturn 0;",
"if (AV_RB32(VAR_0->buf+8) <= 0)\nreturn 0;",
"if (AV_RB32(VAR_0->buf+16) <= 0)\nreturn 0;",
"return AVPROBE_SCORE_MAX / 3 * 2;",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
2
],
[
3,
4
],
[
5,
6
],
[
7,
8
],
[
9
],
[
10
]
] |
22,267 | static void check_exception(PowerPCCPU *cpu, sPAPREnvironment *spapr,
uint32_t token, uint32_t nargs,
target_ulong args,
uint32_t nret, target_ulong rets)
{
uint32_t mask, buf, len, event_len;
uint64_t xinfo;
sPAPREventLogEntry *event;
struct rtas_error_log *hdr;
if ((nargs < 6) || (nargs > 7) || nret != 1) {
rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
return;
}
xinfo = rtas_ld(args, 1);
mask = rtas_ld(args, 2);
buf = rtas_ld(args, 4);
len = rtas_ld(args, 5);
if (nargs == 7) {
xinfo |= (uint64_t)rtas_ld(args, 6) << 32;
}
event = rtas_event_log_dequeue(mask);
if (!event) {
goto out_no_events;
}
hdr = event->data;
event_len = be32_to_cpu(hdr->extended_length) + sizeof(*hdr);
if (event_len < len) {
len = event_len;
}
cpu_physical_memory_write(buf, event->data, len);
rtas_st(rets, 0, RTAS_OUT_SUCCESS);
g_free(event->data);
g_free(event);
/* according to PAPR+, the IRQ must be left asserted, or re-asserted, if
* there are still pending events to be fetched via check-exception. We
* do the latter here, since our code relies on edge-triggered
* interrupts.
*/
if (rtas_event_log_contains(mask)) {
qemu_irq_pulse(xics_get_qirq(spapr->icp, spapr->check_exception_irq));
}
return;
out_no_events:
rtas_st(rets, 0, RTAS_OUT_NO_ERRORS_FOUND);
}
| false | qemu | 79853e18d904b0a4bcef62701d48559688007c93 | static void check_exception(PowerPCCPU *cpu, sPAPREnvironment *spapr,
uint32_t token, uint32_t nargs,
target_ulong args,
uint32_t nret, target_ulong rets)
{
uint32_t mask, buf, len, event_len;
uint64_t xinfo;
sPAPREventLogEntry *event;
struct rtas_error_log *hdr;
if ((nargs < 6) || (nargs > 7) || nret != 1) {
rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
return;
}
xinfo = rtas_ld(args, 1);
mask = rtas_ld(args, 2);
buf = rtas_ld(args, 4);
len = rtas_ld(args, 5);
if (nargs == 7) {
xinfo |= (uint64_t)rtas_ld(args, 6) << 32;
}
event = rtas_event_log_dequeue(mask);
if (!event) {
goto out_no_events;
}
hdr = event->data;
event_len = be32_to_cpu(hdr->extended_length) + sizeof(*hdr);
if (event_len < len) {
len = event_len;
}
cpu_physical_memory_write(buf, event->data, len);
rtas_st(rets, 0, RTAS_OUT_SUCCESS);
g_free(event->data);
g_free(event);
if (rtas_event_log_contains(mask)) {
qemu_irq_pulse(xics_get_qirq(spapr->icp, spapr->check_exception_irq));
}
return;
out_no_events:
rtas_st(rets, 0, RTAS_OUT_NO_ERRORS_FOUND);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(PowerPCCPU *VAR_0, sPAPREnvironment *VAR_1,
uint32_t VAR_2, uint32_t VAR_3,
target_ulong VAR_4,
uint32_t VAR_5, target_ulong VAR_6)
{
uint32_t mask, buf, len, event_len;
uint64_t xinfo;
sPAPREventLogEntry *event;
struct rtas_error_log *VAR_7;
if ((VAR_3 < 6) || (VAR_3 > 7) || VAR_5 != 1) {
rtas_st(VAR_6, 0, RTAS_OUT_PARAM_ERROR);
return;
}
xinfo = rtas_ld(VAR_4, 1);
mask = rtas_ld(VAR_4, 2);
buf = rtas_ld(VAR_4, 4);
len = rtas_ld(VAR_4, 5);
if (VAR_3 == 7) {
xinfo |= (uint64_t)rtas_ld(VAR_4, 6) << 32;
}
event = rtas_event_log_dequeue(mask);
if (!event) {
goto out_no_events;
}
VAR_7 = event->data;
event_len = be32_to_cpu(VAR_7->extended_length) + sizeof(*VAR_7);
if (event_len < len) {
len = event_len;
}
cpu_physical_memory_write(buf, event->data, len);
rtas_st(VAR_6, 0, RTAS_OUT_SUCCESS);
g_free(event->data);
g_free(event);
if (rtas_event_log_contains(mask)) {
qemu_irq_pulse(xics_get_qirq(VAR_1->icp, VAR_1->check_exception_irq));
}
return;
out_no_events:
rtas_st(VAR_6, 0, RTAS_OUT_NO_ERRORS_FOUND);
}
| [
"static void FUNC_0(PowerPCCPU *VAR_0, sPAPREnvironment *VAR_1,\nuint32_t VAR_2, uint32_t VAR_3,\ntarget_ulong VAR_4,\nuint32_t VAR_5, target_ulong VAR_6)\n{",
"uint32_t mask, buf, len, event_len;",
"uint64_t xinfo;",
"sPAPREventLogEntry *event;",
"struct rtas_error_log *VAR_7;",
"if ((VAR_3 < 6) || (VAR_3 > 7) || VAR_5 != 1) {",
"rtas_st(VAR_6, 0, RTAS_OUT_PARAM_ERROR);",
"return;",
"}",
"xinfo = rtas_ld(VAR_4, 1);",
"mask = rtas_ld(VAR_4, 2);",
"buf = rtas_ld(VAR_4, 4);",
"len = rtas_ld(VAR_4, 5);",
"if (VAR_3 == 7) {",
"xinfo |= (uint64_t)rtas_ld(VAR_4, 6) << 32;",
"}",
"event = rtas_event_log_dequeue(mask);",
"if (!event) {",
"goto out_no_events;",
"}",
"VAR_7 = event->data;",
"event_len = be32_to_cpu(VAR_7->extended_length) + sizeof(*VAR_7);",
"if (event_len < len) {",
"len = event_len;",
"}",
"cpu_physical_memory_write(buf, event->data, len);",
"rtas_st(VAR_6, 0, RTAS_OUT_SUCCESS);",
"g_free(event->data);",
"g_free(event);",
"if (rtas_event_log_contains(mask)) {",
"qemu_irq_pulse(xics_get_qirq(VAR_1->icp, VAR_1->check_exception_irq));",
"}",
"return;",
"out_no_events:\nrtas_st(VAR_6, 0, RTAS_OUT_NO_ERRORS_FOUND);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77
],
[
91
],
[
93
],
[
95
],
[
99
],
[
103,
105
],
[
107
]
] |
22,268 | static void raw_fd_pool_put(RawAIOCB *acb)
{
BDRVRawState *s = acb->common.bs->opaque;
int i;
for (i = 0; i < RAW_FD_POOL_SIZE; i++) {
if (s->fd_pool[i] == acb->fd) {
close(s->fd_pool[i]);
s->fd_pool[i] = -1;
}
}
}
| false | qemu | 3c529d935923a70519557d420db1d5a09a65086a | static void raw_fd_pool_put(RawAIOCB *acb)
{
BDRVRawState *s = acb->common.bs->opaque;
int i;
for (i = 0; i < RAW_FD_POOL_SIZE; i++) {
if (s->fd_pool[i] == acb->fd) {
close(s->fd_pool[i]);
s->fd_pool[i] = -1;
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(RawAIOCB *VAR_0)
{
BDRVRawState *s = VAR_0->common.bs->opaque;
int VAR_1;
for (VAR_1 = 0; VAR_1 < RAW_FD_POOL_SIZE; VAR_1++) {
if (s->fd_pool[VAR_1] == VAR_0->fd) {
close(s->fd_pool[VAR_1]);
s->fd_pool[VAR_1] = -1;
}
}
}
| [
"static void FUNC_0(RawAIOCB *VAR_0)\n{",
"BDRVRawState *s = VAR_0->common.bs->opaque;",
"int VAR_1;",
"for (VAR_1 = 0; VAR_1 < RAW_FD_POOL_SIZE; VAR_1++) {",
"if (s->fd_pool[VAR_1] == VAR_0->fd) {",
"close(s->fd_pool[VAR_1]);",
"s->fd_pool[VAR_1] = -1;",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
]
] |
22,271 | static void test_redirector_rx(void)
{
int backend_sock[2], send_sock;
char *cmdline;
uint32_t ret = 0, len = 0;
char send_buf[] = "Hello!!";
char sock_path0[] = "filter-redirector0.XXXXXX";
char sock_path1[] = "filter-redirector1.XXXXXX";
char *recv_buf;
uint32_t size = sizeof(send_buf);
size = htonl(size);
ret = socketpair(PF_UNIX, SOCK_STREAM, 0, backend_sock);
g_assert_cmpint(ret, !=, -1);
ret = mkstemp(sock_path0);
g_assert_cmpint(ret, !=, -1);
ret = mkstemp(sock_path1);
g_assert_cmpint(ret, !=, -1);
cmdline = g_strdup_printf("-netdev socket,id=qtest-bn0,fd=%d "
"-device rtl8139,netdev=qtest-bn0,id=qtest-e0 "
"-chardev socket,id=redirector0,path=%s,server,nowait "
"-chardev socket,id=redirector1,path=%s,server,nowait "
"-chardev socket,id=redirector2,path=%s,nowait "
"-object filter-redirector,id=qtest-f0,netdev=qtest-bn0,"
"queue=rx,indev=redirector0 "
"-object filter-redirector,id=qtest-f1,netdev=qtest-bn0,"
"queue=rx,outdev=redirector2 "
"-object filter-redirector,id=qtest-f2,netdev=qtest-bn0,"
"queue=rx,indev=redirector1 "
, backend_sock[1], sock_path0, sock_path1, sock_path0);
qtest_start(cmdline);
g_free(cmdline);
struct iovec iov[] = {
{
.iov_base = &size,
.iov_len = sizeof(size),
}, {
.iov_base = send_buf,
.iov_len = sizeof(send_buf),
},
};
send_sock = unix_connect(sock_path1, NULL);
g_assert_cmpint(send_sock, !=, -1);
/* send a qmp command to guarantee that 'connected' is setting to true. */
qmp_discard_response("{ 'execute' : 'query-status'}");
ret = iov_send(send_sock, iov, 2, 0, sizeof(size) + sizeof(send_buf));
g_assert_cmpint(ret, ==, sizeof(send_buf) + sizeof(size));
close(send_sock);
ret = qemu_recv(backend_sock[0], &len, sizeof(len), 0);
g_assert_cmpint(ret, ==, sizeof(len));
len = ntohl(len);
g_assert_cmpint(len, ==, sizeof(send_buf));
recv_buf = g_malloc(len);
ret = qemu_recv(backend_sock[0], recv_buf, len, 0);
g_assert_cmpstr(recv_buf, ==, send_buf);
g_free(recv_buf);
unlink(sock_path0);
unlink(sock_path1);
qtest_end();
}
| false | qemu | ea5bef49eadd240c7924f287f2da1bb457a3f92c | static void test_redirector_rx(void)
{
int backend_sock[2], send_sock;
char *cmdline;
uint32_t ret = 0, len = 0;
char send_buf[] = "Hello!!";
char sock_path0[] = "filter-redirector0.XXXXXX";
char sock_path1[] = "filter-redirector1.XXXXXX";
char *recv_buf;
uint32_t size = sizeof(send_buf);
size = htonl(size);
ret = socketpair(PF_UNIX, SOCK_STREAM, 0, backend_sock);
g_assert_cmpint(ret, !=, -1);
ret = mkstemp(sock_path0);
g_assert_cmpint(ret, !=, -1);
ret = mkstemp(sock_path1);
g_assert_cmpint(ret, !=, -1);
cmdline = g_strdup_printf("-netdev socket,id=qtest-bn0,fd=%d "
"-device rtl8139,netdev=qtest-bn0,id=qtest-e0 "
"-chardev socket,id=redirector0,path=%s,server,nowait "
"-chardev socket,id=redirector1,path=%s,server,nowait "
"-chardev socket,id=redirector2,path=%s,nowait "
"-object filter-redirector,id=qtest-f0,netdev=qtest-bn0,"
"queue=rx,indev=redirector0 "
"-object filter-redirector,id=qtest-f1,netdev=qtest-bn0,"
"queue=rx,outdev=redirector2 "
"-object filter-redirector,id=qtest-f2,netdev=qtest-bn0,"
"queue=rx,indev=redirector1 "
, backend_sock[1], sock_path0, sock_path1, sock_path0);
qtest_start(cmdline);
g_free(cmdline);
struct iovec iov[] = {
{
.iov_base = &size,
.iov_len = sizeof(size),
}, {
.iov_base = send_buf,
.iov_len = sizeof(send_buf),
},
};
send_sock = unix_connect(sock_path1, NULL);
g_assert_cmpint(send_sock, !=, -1);
qmp_discard_response("{ 'execute' : 'query-status'}");
ret = iov_send(send_sock, iov, 2, 0, sizeof(size) + sizeof(send_buf));
g_assert_cmpint(ret, ==, sizeof(send_buf) + sizeof(size));
close(send_sock);
ret = qemu_recv(backend_sock[0], &len, sizeof(len), 0);
g_assert_cmpint(ret, ==, sizeof(len));
len = ntohl(len);
g_assert_cmpint(len, ==, sizeof(send_buf));
recv_buf = g_malloc(len);
ret = qemu_recv(backend_sock[0], recv_buf, len, 0);
g_assert_cmpstr(recv_buf, ==, send_buf);
g_free(recv_buf);
unlink(sock_path0);
unlink(sock_path1);
qtest_end();
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void)
{
int VAR_0[2], VAR_1;
char *VAR_2;
uint32_t ret = 0, len = 0;
char VAR_3[] = "Hello!!";
char VAR_4[] = "filter-redirector0.XXXXXX";
char VAR_5[] = "filter-redirector1.XXXXXX";
char *VAR_6;
uint32_t size = sizeof(VAR_3);
size = htonl(size);
ret = socketpair(PF_UNIX, SOCK_STREAM, 0, VAR_0);
g_assert_cmpint(ret, !=, -1);
ret = mkstemp(VAR_4);
g_assert_cmpint(ret, !=, -1);
ret = mkstemp(VAR_5);
g_assert_cmpint(ret, !=, -1);
VAR_2 = g_strdup_printf("-netdev socket,id=qtest-bn0,fd=%d "
"-device rtl8139,netdev=qtest-bn0,id=qtest-e0 "
"-chardev socket,id=redirector0,path=%s,server,nowait "
"-chardev socket,id=redirector1,path=%s,server,nowait "
"-chardev socket,id=redirector2,path=%s,nowait "
"-object filter-redirector,id=qtest-f0,netdev=qtest-bn0,"
"queue=rx,indev=redirector0 "
"-object filter-redirector,id=qtest-f1,netdev=qtest-bn0,"
"queue=rx,outdev=redirector2 "
"-object filter-redirector,id=qtest-f2,netdev=qtest-bn0,"
"queue=rx,indev=redirector1 "
, VAR_0[1], VAR_4, VAR_5, VAR_4);
qtest_start(VAR_2);
g_free(VAR_2);
struct iovec VAR_7[] = {
{
.iov_base = &size,
.iov_len = sizeof(size),
}, {
.iov_base = VAR_3,
.iov_len = sizeof(VAR_3),
},
};
VAR_1 = unix_connect(VAR_5, NULL);
g_assert_cmpint(VAR_1, !=, -1);
qmp_discard_response("{ 'execute' : 'query-status'}");
ret = iov_send(VAR_1, VAR_7, 2, 0, sizeof(size) + sizeof(VAR_3));
g_assert_cmpint(ret, ==, sizeof(VAR_3) + sizeof(size));
close(VAR_1);
ret = qemu_recv(VAR_0[0], &len, sizeof(len), 0);
g_assert_cmpint(ret, ==, sizeof(len));
len = ntohl(len);
g_assert_cmpint(len, ==, sizeof(VAR_3));
VAR_6 = g_malloc(len);
ret = qemu_recv(VAR_0[0], VAR_6, len, 0);
g_assert_cmpstr(VAR_6, ==, VAR_3);
g_free(VAR_6);
unlink(VAR_4);
unlink(VAR_5);
qtest_end();
}
| [
"static void FUNC_0(void)\n{",
"int VAR_0[2], VAR_1;",
"char *VAR_2;",
"uint32_t ret = 0, len = 0;",
"char VAR_3[] = \"Hello!!\";",
"char VAR_4[] = \"filter-redirector0.XXXXXX\";",
"char VAR_5[] = \"filter-redirector1.XXXXXX\";",
"char *VAR_6;",
"uint32_t size = sizeof(VAR_3);",
"size = htonl(size);",
"ret = socketpair(PF_UNIX, SOCK_STREAM, 0, VAR_0);",
"g_assert_cmpint(ret, !=, -1);",
"ret = mkstemp(VAR_4);",
"g_assert_cmpint(ret, !=, -1);",
"ret = mkstemp(VAR_5);",
"g_assert_cmpint(ret, !=, -1);",
"VAR_2 = g_strdup_printf(\"-netdev socket,id=qtest-bn0,fd=%d \"\n\"-device rtl8139,netdev=qtest-bn0,id=qtest-e0 \"\n\"-chardev socket,id=redirector0,path=%s,server,nowait \"\n\"-chardev socket,id=redirector1,path=%s,server,nowait \"\n\"-chardev socket,id=redirector2,path=%s,nowait \"\n\"-object filter-redirector,id=qtest-f0,netdev=qtest-bn0,\"\n\"queue=rx,indev=redirector0 \"\n\"-object filter-redirector,id=qtest-f1,netdev=qtest-bn0,\"\n\"queue=rx,outdev=redirector2 \"\n\"-object filter-redirector,id=qtest-f2,netdev=qtest-bn0,\"\n\"queue=rx,indev=redirector1 \"\n, VAR_0[1], VAR_4, VAR_5, VAR_4);",
"qtest_start(VAR_2);",
"g_free(VAR_2);",
"struct iovec VAR_7[] = {",
"{",
".iov_base = &size,\n.iov_len = sizeof(size),\n}, {",
".iov_base = VAR_3,\n.iov_len = sizeof(VAR_3),\n},",
"};",
"VAR_1 = unix_connect(VAR_5, NULL);",
"g_assert_cmpint(VAR_1, !=, -1);",
"qmp_discard_response(\"{ 'execute' : 'query-status'}\");",
"ret = iov_send(VAR_1, VAR_7, 2, 0, sizeof(size) + sizeof(VAR_3));",
"g_assert_cmpint(ret, ==, sizeof(VAR_3) + sizeof(size));",
"close(VAR_1);",
"ret = qemu_recv(VAR_0[0], &len, sizeof(len), 0);",
"g_assert_cmpint(ret, ==, sizeof(len));",
"len = ntohl(len);",
"g_assert_cmpint(len, ==, sizeof(VAR_3));",
"VAR_6 = g_malloc(len);",
"ret = qemu_recv(VAR_0[0], VAR_6, len, 0);",
"g_assert_cmpstr(VAR_6, ==, VAR_3);",
"g_free(VAR_6);",
"unlink(VAR_4);",
"unlink(VAR_5);",
"qtest_end();",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41,
43,
45,
47,
49,
51,
53,
55,
57,
59,
61,
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75,
77,
79
],
[
81,
83,
85
],
[
87
],
[
91
],
[
93
],
[
97
],
[
101
],
[
103
],
[
105
],
[
109
],
[
111
],
[
113
],
[
117
],
[
119
],
[
121
],
[
123
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
]
] |
22,272 | static void cpu_openrisc_load_kernel(ram_addr_t ram_size,
const char *kernel_filename,
OpenRISCCPU *cpu)
{
long kernel_size;
uint64_t elf_entry;
hwaddr entry;
if (kernel_filename && !qtest_enabled()) {
kernel_size = load_elf(kernel_filename, NULL, NULL,
&elf_entry, NULL, NULL, 1, EM_OPENRISC,
1, 0);
entry = elf_entry;
if (kernel_size < 0) {
kernel_size = load_uimage(kernel_filename,
&entry, NULL, NULL, NULL, NULL);
}
if (kernel_size < 0) {
kernel_size = load_image_targphys(kernel_filename,
KERNEL_LOAD_ADDR,
ram_size - KERNEL_LOAD_ADDR);
entry = KERNEL_LOAD_ADDR;
}
if (kernel_size < 0) {
fprintf(stderr, "QEMU: couldn't load the kernel '%s'\n",
kernel_filename);
exit(1);
}
cpu->env.pc = entry;
}
}
| false | qemu | 13f1c773640171efa8175b1ba6dcd624c1ad68c1 | static void cpu_openrisc_load_kernel(ram_addr_t ram_size,
const char *kernel_filename,
OpenRISCCPU *cpu)
{
long kernel_size;
uint64_t elf_entry;
hwaddr entry;
if (kernel_filename && !qtest_enabled()) {
kernel_size = load_elf(kernel_filename, NULL, NULL,
&elf_entry, NULL, NULL, 1, EM_OPENRISC,
1, 0);
entry = elf_entry;
if (kernel_size < 0) {
kernel_size = load_uimage(kernel_filename,
&entry, NULL, NULL, NULL, NULL);
}
if (kernel_size < 0) {
kernel_size = load_image_targphys(kernel_filename,
KERNEL_LOAD_ADDR,
ram_size - KERNEL_LOAD_ADDR);
entry = KERNEL_LOAD_ADDR;
}
if (kernel_size < 0) {
fprintf(stderr, "QEMU: couldn't load the kernel '%s'\n",
kernel_filename);
exit(1);
}
cpu->env.pc = entry;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(ram_addr_t VAR_0,
const char *VAR_1,
OpenRISCCPU *VAR_2)
{
long VAR_3;
uint64_t elf_entry;
hwaddr entry;
if (VAR_1 && !qtest_enabled()) {
VAR_3 = load_elf(VAR_1, NULL, NULL,
&elf_entry, NULL, NULL, 1, EM_OPENRISC,
1, 0);
entry = elf_entry;
if (VAR_3 < 0) {
VAR_3 = load_uimage(VAR_1,
&entry, NULL, NULL, NULL, NULL);
}
if (VAR_3 < 0) {
VAR_3 = load_image_targphys(VAR_1,
KERNEL_LOAD_ADDR,
VAR_0 - KERNEL_LOAD_ADDR);
entry = KERNEL_LOAD_ADDR;
}
if (VAR_3 < 0) {
fprintf(stderr, "QEMU: couldn't load the kernel '%s'\n",
VAR_1);
exit(1);
}
VAR_2->env.pc = entry;
}
}
| [
"static void FUNC_0(ram_addr_t VAR_0,\nconst char *VAR_1,\nOpenRISCCPU *VAR_2)\n{",
"long VAR_3;",
"uint64_t elf_entry;",
"hwaddr entry;",
"if (VAR_1 && !qtest_enabled()) {",
"VAR_3 = load_elf(VAR_1, NULL, NULL,\n&elf_entry, NULL, NULL, 1, EM_OPENRISC,\n1, 0);",
"entry = elf_entry;",
"if (VAR_3 < 0) {",
"VAR_3 = load_uimage(VAR_1,\n&entry, NULL, NULL, NULL, NULL);",
"}",
"if (VAR_3 < 0) {",
"VAR_3 = load_image_targphys(VAR_1,\nKERNEL_LOAD_ADDR,\nVAR_0 - KERNEL_LOAD_ADDR);",
"entry = KERNEL_LOAD_ADDR;",
"}",
"if (VAR_3 < 0) {",
"fprintf(stderr, \"QEMU: couldn't load the kernel '%s'\\n\",\nVAR_1);",
"exit(1);",
"}",
"VAR_2->env.pc = entry;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19,
21,
23
],
[
25
],
[
27
],
[
29,
31
],
[
33
],
[
35
],
[
37,
39,
41
],
[
43
],
[
45
],
[
49
],
[
51,
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
]
] |
22,274 | static void configure_rtc_date_offset(const char *startdate, int legacy)
{
time_t rtc_start_date;
struct tm tm;
if (!strcmp(startdate, "now") && legacy) {
rtc_date_offset = -1;
} else {
if (sscanf(startdate, "%d-%d-%dT%d:%d:%d",
&tm.tm_year,
&tm.tm_mon,
&tm.tm_mday,
&tm.tm_hour,
&tm.tm_min,
&tm.tm_sec) == 6) {
/* OK */
} else if (sscanf(startdate, "%d-%d-%d",
&tm.tm_year,
&tm.tm_mon,
&tm.tm_mday) == 3) {
tm.tm_hour = 0;
tm.tm_min = 0;
tm.tm_sec = 0;
} else {
goto date_fail;
}
tm.tm_year -= 1900;
tm.tm_mon--;
rtc_start_date = mktimegm(&tm);
if (rtc_start_date == -1) {
date_fail:
fprintf(stderr, "Invalid date format. Valid formats are:\n"
"'2006-06-17T16:01:21' or '2006-06-17'\n");
exit(1);
}
rtc_date_offset = time(NULL) - rtc_start_date;
}
}
| false | qemu | 2ed1ebcf65edf6757d8904000889ce52cc0a9d1b | static void configure_rtc_date_offset(const char *startdate, int legacy)
{
time_t rtc_start_date;
struct tm tm;
if (!strcmp(startdate, "now") && legacy) {
rtc_date_offset = -1;
} else {
if (sscanf(startdate, "%d-%d-%dT%d:%d:%d",
&tm.tm_year,
&tm.tm_mon,
&tm.tm_mday,
&tm.tm_hour,
&tm.tm_min,
&tm.tm_sec) == 6) {
} else if (sscanf(startdate, "%d-%d-%d",
&tm.tm_year,
&tm.tm_mon,
&tm.tm_mday) == 3) {
tm.tm_hour = 0;
tm.tm_min = 0;
tm.tm_sec = 0;
} else {
goto date_fail;
}
tm.tm_year -= 1900;
tm.tm_mon--;
rtc_start_date = mktimegm(&tm);
if (rtc_start_date == -1) {
date_fail:
fprintf(stderr, "Invalid date format. Valid formats are:\n"
"'2006-06-17T16:01:21' or '2006-06-17'\n");
exit(1);
}
rtc_date_offset = time(NULL) - rtc_start_date;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(const char *VAR_0, int VAR_1)
{
time_t rtc_start_date;
struct VAR_2 VAR_2;
if (!strcmp(VAR_0, "now") && VAR_1) {
rtc_date_offset = -1;
} else {
if (sscanf(VAR_0, "%d-%d-%dT%d:%d:%d",
&VAR_2.tm_year,
&VAR_2.tm_mon,
&VAR_2.tm_mday,
&VAR_2.tm_hour,
&VAR_2.tm_min,
&VAR_2.tm_sec) == 6) {
} else if (sscanf(VAR_0, "%d-%d-%d",
&VAR_2.tm_year,
&VAR_2.tm_mon,
&VAR_2.tm_mday) == 3) {
VAR_2.tm_hour = 0;
VAR_2.tm_min = 0;
VAR_2.tm_sec = 0;
} else {
goto date_fail;
}
VAR_2.tm_year -= 1900;
VAR_2.tm_mon--;
rtc_start_date = mktimegm(&VAR_2);
if (rtc_start_date == -1) {
date_fail:
fprintf(stderr, "Invalid date format. Valid formats are:\n"
"'2006-06-17T16:01:21' or '2006-06-17'\n");
exit(1);
}
rtc_date_offset = time(NULL) - rtc_start_date;
}
}
| [
"static void FUNC_0(const char *VAR_0, int VAR_1)\n{",
"time_t rtc_start_date;",
"struct VAR_2 VAR_2;",
"if (!strcmp(VAR_0, \"now\") && VAR_1) {",
"rtc_date_offset = -1;",
"} else {",
"if (sscanf(VAR_0, \"%d-%d-%dT%d:%d:%d\",\n&VAR_2.tm_year,\n&VAR_2.tm_mon,\n&VAR_2.tm_mday,\n&VAR_2.tm_hour,\n&VAR_2.tm_min,\n&VAR_2.tm_sec) == 6) {",
"} else if (sscanf(VAR_0, \"%d-%d-%d\",",
"&VAR_2.tm_year,\n&VAR_2.tm_mon,\n&VAR_2.tm_mday) == 3) {",
"VAR_2.tm_hour = 0;",
"VAR_2.tm_min = 0;",
"VAR_2.tm_sec = 0;",
"} else {",
"goto date_fail;",
"}",
"VAR_2.tm_year -= 1900;",
"VAR_2.tm_mon--;",
"rtc_start_date = mktimegm(&VAR_2);",
"if (rtc_start_date == -1) {",
"date_fail:\nfprintf(stderr, \"Invalid date format. Valid formats are:\\n\"\n\"'2006-06-17T16:01:21' or '2006-06-17'\\n\");",
"exit(1);",
"}",
"rtc_date_offset = time(NULL) - rtc_start_date;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17,
19,
21,
23,
25,
27,
29
],
[
33
],
[
35,
37,
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61,
63,
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
]
] |
22,275 | void ppc_slb_invalidate_all (CPUPPCState *env)
{
/* XXX: TODO */
tlb_flush(env, 1);
}
| false | qemu | eacc324914c2dc7aecec3b4ea920252b685b5c8e | void ppc_slb_invalidate_all (CPUPPCState *env)
{
tlb_flush(env, 1);
}
| {
"code": [],
"line_no": []
} | void FUNC_0 (CPUPPCState *VAR_0)
{
tlb_flush(VAR_0, 1);
}
| [
"void FUNC_0 (CPUPPCState *VAR_0)\n{",
"tlb_flush(VAR_0, 1);",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
7
],
[
9
]
] |
22,277 | int load_image_targphys(const char *filename,
target_phys_addr_t addr, int max_sz)
{
FILE *f;
size_t got;
f = fopen(filename, "rb");
if (!f) return -1;
got = fread_targphys(addr, max_sz, f);
if (ferror(f)) { fclose(f); return -1; }
fclose(f);
return got;
}
| false | qemu | 45a50b1668822c23afc2a89f724654e176518bc4 | int load_image_targphys(const char *filename,
target_phys_addr_t addr, int max_sz)
{
FILE *f;
size_t got;
f = fopen(filename, "rb");
if (!f) return -1;
got = fread_targphys(addr, max_sz, f);
if (ferror(f)) { fclose(f); return -1; }
fclose(f);
return got;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(const char *VAR_0,
target_phys_addr_t VAR_1, int VAR_2)
{
FILE *f;
size_t got;
f = fopen(VAR_0, "rb");
if (!f) return -1;
got = fread_targphys(VAR_1, VAR_2, f);
if (ferror(f)) { fclose(f); return -1; }
fclose(f);
return got;
}
| [
"int FUNC_0(const char *VAR_0,\ntarget_phys_addr_t VAR_1, int VAR_2)\n{",
"FILE *f;",
"size_t got;",
"f = fopen(VAR_0, \"rb\");",
"if (!f) return -1;",
"got = fread_targphys(VAR_1, VAR_2, f);",
"if (ferror(f)) { fclose(f); return -1; }",
"fclose(f);",
"return got;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
]
] |
22,278 | int gdbserver_start(int port)
{
gdbserver_fd = gdbserver_open(port);
if (gdbserver_fd < 0)
return -1;
/* accept connections */
gdb_accept (NULL);
return 0;
}
| false | qemu | 880a7578381d1c7ed4d41c7599ae3cc06567a824 | int gdbserver_start(int port)
{
gdbserver_fd = gdbserver_open(port);
if (gdbserver_fd < 0)
return -1;
gdb_accept (NULL);
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(int VAR_0)
{
gdbserver_fd = gdbserver_open(VAR_0);
if (gdbserver_fd < 0)
return -1;
gdb_accept (NULL);
return 0;
}
| [
"int FUNC_0(int VAR_0)\n{",
"gdbserver_fd = gdbserver_open(VAR_0);",
"if (gdbserver_fd < 0)\nreturn -1;",
"gdb_accept (NULL);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7,
9
],
[
13
],
[
15
],
[
17
]
] |
22,281 | CaptureVoiceOut *AUD_add_capture (
AudioState *s,
audsettings_t *as,
struct audio_capture_ops *ops,
void *cb_opaque
)
{
CaptureVoiceOut *cap;
struct capture_callback *cb;
if (!s) {
/* XXX suppress */
s = &glob_audio_state;
}
if (audio_validate_settings (as)) {
dolog ("Invalid settings were passed when trying to add capture\n");
audio_print_settings (as);
goto err0;
}
cb = audio_calloc (AUDIO_FUNC, 1, sizeof (*cb));
if (!cb) {
dolog ("Could not allocate capture callback information, size %zu\n",
sizeof (*cb));
goto err0;
}
cb->ops = *ops;
cb->opaque = cb_opaque;
cap = audio_pcm_capture_find_specific (s, as);
if (cap) {
LIST_INSERT_HEAD (&cap->cb_head, cb, entries);
return cap;
}
else {
HWVoiceOut *hw;
CaptureVoiceOut *cap;
cap = audio_calloc (AUDIO_FUNC, 1, sizeof (*cap));
if (!cap) {
dolog ("Could not allocate capture voice, size %zu\n",
sizeof (*cap));
goto err1;
}
hw = &cap->hw;
LIST_INIT (&hw->sw_head);
LIST_INIT (&cap->cb_head);
/* XXX find a more elegant way */
hw->samples = 4096 * 4;
hw->mix_buf = audio_calloc (AUDIO_FUNC, hw->samples,
sizeof (st_sample_t));
if (!hw->mix_buf) {
dolog ("Could not allocate capture mix buffer (%d samples)\n",
hw->samples);
goto err2;
}
audio_pcm_init_info (&hw->info, as);
cap->buf = audio_calloc (AUDIO_FUNC, hw->samples, 1 << hw->info.shift);
if (!cap->buf) {
dolog ("Could not allocate capture buffer "
"(%d samples, each %d bytes)\n",
hw->samples, 1 << hw->info.shift);
goto err3;
}
hw->clip = mixeng_clip
[hw->info.nchannels == 2]
[hw->info.sign]
[hw->info.swap_endianness]
[audio_bits_to_index (hw->info.bits)];
LIST_INSERT_HEAD (&s->cap_head, cap, entries);
LIST_INSERT_HEAD (&cap->cb_head, cb, entries);
hw = NULL;
while ((hw = audio_pcm_hw_find_any_out (s, hw))) {
audio_attach_capture (s, hw);
}
return cap;
err3:
qemu_free (cap->hw.mix_buf);
err2:
qemu_free (cap);
err1:
qemu_free (cb);
err0:
return NULL;
}
}
| false | qemu | 1ea879e5580f63414693655fcf0328559cdce138 | CaptureVoiceOut *AUD_add_capture (
AudioState *s,
audsettings_t *as,
struct audio_capture_ops *ops,
void *cb_opaque
)
{
CaptureVoiceOut *cap;
struct capture_callback *cb;
if (!s) {
s = &glob_audio_state;
}
if (audio_validate_settings (as)) {
dolog ("Invalid settings were passed when trying to add capture\n");
audio_print_settings (as);
goto err0;
}
cb = audio_calloc (AUDIO_FUNC, 1, sizeof (*cb));
if (!cb) {
dolog ("Could not allocate capture callback information, size %zu\n",
sizeof (*cb));
goto err0;
}
cb->ops = *ops;
cb->opaque = cb_opaque;
cap = audio_pcm_capture_find_specific (s, as);
if (cap) {
LIST_INSERT_HEAD (&cap->cb_head, cb, entries);
return cap;
}
else {
HWVoiceOut *hw;
CaptureVoiceOut *cap;
cap = audio_calloc (AUDIO_FUNC, 1, sizeof (*cap));
if (!cap) {
dolog ("Could not allocate capture voice, size %zu\n",
sizeof (*cap));
goto err1;
}
hw = &cap->hw;
LIST_INIT (&hw->sw_head);
LIST_INIT (&cap->cb_head);
hw->samples = 4096 * 4;
hw->mix_buf = audio_calloc (AUDIO_FUNC, hw->samples,
sizeof (st_sample_t));
if (!hw->mix_buf) {
dolog ("Could not allocate capture mix buffer (%d samples)\n",
hw->samples);
goto err2;
}
audio_pcm_init_info (&hw->info, as);
cap->buf = audio_calloc (AUDIO_FUNC, hw->samples, 1 << hw->info.shift);
if (!cap->buf) {
dolog ("Could not allocate capture buffer "
"(%d samples, each %d bytes)\n",
hw->samples, 1 << hw->info.shift);
goto err3;
}
hw->clip = mixeng_clip
[hw->info.nchannels == 2]
[hw->info.sign]
[hw->info.swap_endianness]
[audio_bits_to_index (hw->info.bits)];
LIST_INSERT_HEAD (&s->cap_head, cap, entries);
LIST_INSERT_HEAD (&cap->cb_head, cb, entries);
hw = NULL;
while ((hw = audio_pcm_hw_find_any_out (s, hw))) {
audio_attach_capture (s, hw);
}
return cap;
err3:
qemu_free (cap->hw.mix_buf);
err2:
qemu_free (cap);
err1:
qemu_free (cb);
err0:
return NULL;
}
}
| {
"code": [],
"line_no": []
} | CaptureVoiceOut *FUNC_0 (
AudioState *s,
audsettings_t *as,
struct audio_capture_ops *ops,
void *cb_opaque
)
{
CaptureVoiceOut *cap;
struct capture_callback *VAR_0;
if (!s) {
s = &glob_audio_state;
}
if (audio_validate_settings (as)) {
dolog ("Invalid settings were passed when trying to add capture\n");
audio_print_settings (as);
goto err0;
}
VAR_0 = audio_calloc (AUDIO_FUNC, 1, sizeof (*VAR_0));
if (!VAR_0) {
dolog ("Could not allocate capture callback information, size %zu\n",
sizeof (*VAR_0));
goto err0;
}
VAR_0->ops = *ops;
VAR_0->opaque = cb_opaque;
cap = audio_pcm_capture_find_specific (s, as);
if (cap) {
LIST_INSERT_HEAD (&cap->cb_head, VAR_0, entries);
return cap;
}
else {
HWVoiceOut *hw;
CaptureVoiceOut *cap;
cap = audio_calloc (AUDIO_FUNC, 1, sizeof (*cap));
if (!cap) {
dolog ("Could not allocate capture voice, size %zu\n",
sizeof (*cap));
goto err1;
}
hw = &cap->hw;
LIST_INIT (&hw->sw_head);
LIST_INIT (&cap->cb_head);
hw->samples = 4096 * 4;
hw->mix_buf = audio_calloc (AUDIO_FUNC, hw->samples,
sizeof (st_sample_t));
if (!hw->mix_buf) {
dolog ("Could not allocate capture mix buffer (%d samples)\n",
hw->samples);
goto err2;
}
audio_pcm_init_info (&hw->info, as);
cap->buf = audio_calloc (AUDIO_FUNC, hw->samples, 1 << hw->info.shift);
if (!cap->buf) {
dolog ("Could not allocate capture buffer "
"(%d samples, each %d bytes)\n",
hw->samples, 1 << hw->info.shift);
goto err3;
}
hw->clip = mixeng_clip
[hw->info.nchannels == 2]
[hw->info.sign]
[hw->info.swap_endianness]
[audio_bits_to_index (hw->info.bits)];
LIST_INSERT_HEAD (&s->cap_head, cap, entries);
LIST_INSERT_HEAD (&cap->cb_head, VAR_0, entries);
hw = NULL;
while ((hw = audio_pcm_hw_find_any_out (s, hw))) {
audio_attach_capture (s, hw);
}
return cap;
err3:
qemu_free (cap->hw.mix_buf);
err2:
qemu_free (cap);
err1:
qemu_free (VAR_0);
err0:
return NULL;
}
}
| [
"CaptureVoiceOut *FUNC_0 (\nAudioState *s,\naudsettings_t *as,\nstruct audio_capture_ops *ops,\nvoid *cb_opaque\n)\n{",
"CaptureVoiceOut *cap;",
"struct capture_callback *VAR_0;",
"if (!s) {",
"s = &glob_audio_state;",
"}",
"if (audio_validate_settings (as)) {",
"dolog (\"Invalid settings were passed when trying to add capture\\n\");",
"audio_print_settings (as);",
"goto err0;",
"}",
"VAR_0 = audio_calloc (AUDIO_FUNC, 1, sizeof (*VAR_0));",
"if (!VAR_0) {",
"dolog (\"Could not allocate capture callback information, size %zu\\n\",\nsizeof (*VAR_0));",
"goto err0;",
"}",
"VAR_0->ops = *ops;",
"VAR_0->opaque = cb_opaque;",
"cap = audio_pcm_capture_find_specific (s, as);",
"if (cap) {",
"LIST_INSERT_HEAD (&cap->cb_head, VAR_0, entries);",
"return cap;",
"}",
"else {",
"HWVoiceOut *hw;",
"CaptureVoiceOut *cap;",
"cap = audio_calloc (AUDIO_FUNC, 1, sizeof (*cap));",
"if (!cap) {",
"dolog (\"Could not allocate capture voice, size %zu\\n\",\nsizeof (*cap));",
"goto err1;",
"}",
"hw = &cap->hw;",
"LIST_INIT (&hw->sw_head);",
"LIST_INIT (&cap->cb_head);",
"hw->samples = 4096 * 4;",
"hw->mix_buf = audio_calloc (AUDIO_FUNC, hw->samples,\nsizeof (st_sample_t));",
"if (!hw->mix_buf) {",
"dolog (\"Could not allocate capture mix buffer (%d samples)\\n\",\nhw->samples);",
"goto err2;",
"}",
"audio_pcm_init_info (&hw->info, as);",
"cap->buf = audio_calloc (AUDIO_FUNC, hw->samples, 1 << hw->info.shift);",
"if (!cap->buf) {",
"dolog (\"Could not allocate capture buffer \"\n\"(%d samples, each %d bytes)\\n\",\nhw->samples, 1 << hw->info.shift);",
"goto err3;",
"}",
"hw->clip = mixeng_clip\n[hw->info.nchannels == 2]\n[hw->info.sign]\n[hw->info.swap_endianness]\n[audio_bits_to_index (hw->info.bits)];",
"LIST_INSERT_HEAD (&s->cap_head, cap, entries);",
"LIST_INSERT_HEAD (&cap->cb_head, VAR_0, entries);",
"hw = NULL;",
"while ((hw = audio_pcm_hw_find_any_out (s, hw))) {",
"audio_attach_capture (s, hw);",
"}",
"return cap;",
"err3:\nqemu_free (cap->hw.mix_buf);",
"err2:\nqemu_free (cap);",
"err1:\nqemu_free (VAR_0);",
"err0:\nreturn NULL;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
11,
13
],
[
15
],
[
17
],
[
21
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47,
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83,
85
],
[
87
],
[
89
],
[
93
],
[
95
],
[
97
],
[
103
],
[
105,
107
],
[
109
],
[
111,
113
],
[
115
],
[
117
],
[
121
],
[
125
],
[
127
],
[
129,
131,
133
],
[
135
],
[
137
],
[
141,
143,
145,
147,
149
],
[
153
],
[
155
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
171,
173
],
[
175,
177
],
[
179,
181
],
[
183,
185
],
[
187
],
[
189
]
] |
22,282 | static int nbd_co_writev(BlockDriverState *bs, int64_t sector_num,
int nb_sectors, QEMUIOVector *qiov)
{
BDRVNBDState *s = bs->opaque;
return nbd_client_session_co_writev(&s->client, sector_num,
nb_sectors, qiov);
}
| false | qemu | f53a829bb9ef14be800556cbc02d8b20fc1050a7 | static int nbd_co_writev(BlockDriverState *bs, int64_t sector_num,
int nb_sectors, QEMUIOVector *qiov)
{
BDRVNBDState *s = bs->opaque;
return nbd_client_session_co_writev(&s->client, sector_num,
nb_sectors, qiov);
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1,
int VAR_2, QEMUIOVector *VAR_3)
{
BDRVNBDState *s = VAR_0->opaque;
return nbd_client_session_co_writev(&s->client, VAR_1,
VAR_2, VAR_3);
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1,\nint VAR_2, QEMUIOVector *VAR_3)\n{",
"BDRVNBDState *s = VAR_0->opaque;",
"return nbd_client_session_co_writev(&s->client, VAR_1,\nVAR_2, VAR_3);",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11,
13
],
[
15
]
] |
22,283 | static void megasas_mmio_write(void *opaque, target_phys_addr_t addr,
uint64_t val, unsigned size)
{
MegasasState *s = opaque;
uint64_t frame_addr;
uint32_t frame_count;
int i;
trace_megasas_mmio_writel(addr, val);
switch (addr) {
case MFI_IDB:
if (val & MFI_FWINIT_ABORT) {
/* Abort all pending cmds */
for (i = 0; i < s->fw_cmds; i++) {
megasas_abort_command(&s->frames[i]);
}
}
if (val & MFI_FWINIT_READY) {
/* move to FW READY */
megasas_soft_reset(s);
}
if (val & MFI_FWINIT_MFIMODE) {
/* discard MFIs */
}
break;
case MFI_OMSK:
s->intr_mask = val;
if (!megasas_intr_enabled(s) && !msix_enabled(&s->dev)) {
trace_megasas_irq_lower();
qemu_irq_lower(s->dev.irq[0]);
}
if (megasas_intr_enabled(s)) {
trace_megasas_intr_enabled();
} else {
trace_megasas_intr_disabled();
}
break;
case MFI_ODCR0:
s->doorbell = 0;
if (s->producer_pa && megasas_intr_enabled(s)) {
/* Update reply queue pointer */
trace_megasas_qf_update(s->reply_queue_head, s->busy);
stl_le_phys(s->producer_pa, s->reply_queue_head);
if (!msix_enabled(&s->dev)) {
trace_megasas_irq_lower();
qemu_irq_lower(s->dev.irq[0]);
}
}
break;
case MFI_IQPH:
/* Received high 32 bits of a 64 bit MFI frame address */
s->frame_hi = val;
break;
case MFI_IQPL:
/* Received low 32 bits of a 64 bit MFI frame address */
case MFI_IQP:
/* Received 32 bit MFI frame address */
frame_addr = (val & ~0x1F);
/* Add possible 64 bit offset */
frame_addr |= ((uint64_t)s->frame_hi << 32);
s->frame_hi = 0;
frame_count = (val >> 1) & 0xF;
megasas_handle_frame(s, frame_addr, frame_count);
break;
default:
trace_megasas_mmio_invalid_writel(addr, val);
break;
}
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static void megasas_mmio_write(void *opaque, target_phys_addr_t addr,
uint64_t val, unsigned size)
{
MegasasState *s = opaque;
uint64_t frame_addr;
uint32_t frame_count;
int i;
trace_megasas_mmio_writel(addr, val);
switch (addr) {
case MFI_IDB:
if (val & MFI_FWINIT_ABORT) {
for (i = 0; i < s->fw_cmds; i++) {
megasas_abort_command(&s->frames[i]);
}
}
if (val & MFI_FWINIT_READY) {
megasas_soft_reset(s);
}
if (val & MFI_FWINIT_MFIMODE) {
}
break;
case MFI_OMSK:
s->intr_mask = val;
if (!megasas_intr_enabled(s) && !msix_enabled(&s->dev)) {
trace_megasas_irq_lower();
qemu_irq_lower(s->dev.irq[0]);
}
if (megasas_intr_enabled(s)) {
trace_megasas_intr_enabled();
} else {
trace_megasas_intr_disabled();
}
break;
case MFI_ODCR0:
s->doorbell = 0;
if (s->producer_pa && megasas_intr_enabled(s)) {
trace_megasas_qf_update(s->reply_queue_head, s->busy);
stl_le_phys(s->producer_pa, s->reply_queue_head);
if (!msix_enabled(&s->dev)) {
trace_megasas_irq_lower();
qemu_irq_lower(s->dev.irq[0]);
}
}
break;
case MFI_IQPH:
s->frame_hi = val;
break;
case MFI_IQPL:
case MFI_IQP:
frame_addr = (val & ~0x1F);
frame_addr |= ((uint64_t)s->frame_hi << 32);
s->frame_hi = 0;
frame_count = (val >> 1) & 0xF;
megasas_handle_frame(s, frame_addr, frame_count);
break;
default:
trace_megasas_mmio_invalid_writel(addr, val);
break;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,
uint64_t VAR_2, unsigned VAR_3)
{
MegasasState *s = VAR_0;
uint64_t frame_addr;
uint32_t frame_count;
int VAR_4;
trace_megasas_mmio_writel(VAR_1, VAR_2);
switch (VAR_1) {
case MFI_IDB:
if (VAR_2 & MFI_FWINIT_ABORT) {
for (VAR_4 = 0; VAR_4 < s->fw_cmds; VAR_4++) {
megasas_abort_command(&s->frames[VAR_4]);
}
}
if (VAR_2 & MFI_FWINIT_READY) {
megasas_soft_reset(s);
}
if (VAR_2 & MFI_FWINIT_MFIMODE) {
}
break;
case MFI_OMSK:
s->intr_mask = VAR_2;
if (!megasas_intr_enabled(s) && !msix_enabled(&s->dev)) {
trace_megasas_irq_lower();
qemu_irq_lower(s->dev.irq[0]);
}
if (megasas_intr_enabled(s)) {
trace_megasas_intr_enabled();
} else {
trace_megasas_intr_disabled();
}
break;
case MFI_ODCR0:
s->doorbell = 0;
if (s->producer_pa && megasas_intr_enabled(s)) {
trace_megasas_qf_update(s->reply_queue_head, s->busy);
stl_le_phys(s->producer_pa, s->reply_queue_head);
if (!msix_enabled(&s->dev)) {
trace_megasas_irq_lower();
qemu_irq_lower(s->dev.irq[0]);
}
}
break;
case MFI_IQPH:
s->frame_hi = VAR_2;
break;
case MFI_IQPL:
case MFI_IQP:
frame_addr = (VAR_2 & ~0x1F);
frame_addr |= ((uint64_t)s->frame_hi << 32);
s->frame_hi = 0;
frame_count = (VAR_2 >> 1) & 0xF;
megasas_handle_frame(s, frame_addr, frame_count);
break;
default:
trace_megasas_mmio_invalid_writel(VAR_1, VAR_2);
break;
}
}
| [
"static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{",
"MegasasState *s = VAR_0;",
"uint64_t frame_addr;",
"uint32_t frame_count;",
"int VAR_4;",
"trace_megasas_mmio_writel(VAR_1, VAR_2);",
"switch (VAR_1) {",
"case MFI_IDB:\nif (VAR_2 & MFI_FWINIT_ABORT) {",
"for (VAR_4 = 0; VAR_4 < s->fw_cmds; VAR_4++) {",
"megasas_abort_command(&s->frames[VAR_4]);",
"}",
"}",
"if (VAR_2 & MFI_FWINIT_READY) {",
"megasas_soft_reset(s);",
"}",
"if (VAR_2 & MFI_FWINIT_MFIMODE) {",
"}",
"break;",
"case MFI_OMSK:\ns->intr_mask = VAR_2;",
"if (!megasas_intr_enabled(s) && !msix_enabled(&s->dev)) {",
"trace_megasas_irq_lower();",
"qemu_irq_lower(s->dev.irq[0]);",
"}",
"if (megasas_intr_enabled(s)) {",
"trace_megasas_intr_enabled();",
"} else {",
"trace_megasas_intr_disabled();",
"}",
"break;",
"case MFI_ODCR0:\ns->doorbell = 0;",
"if (s->producer_pa && megasas_intr_enabled(s)) {",
"trace_megasas_qf_update(s->reply_queue_head, s->busy);",
"stl_le_phys(s->producer_pa, s->reply_queue_head);",
"if (!msix_enabled(&s->dev)) {",
"trace_megasas_irq_lower();",
"qemu_irq_lower(s->dev.irq[0]);",
"}",
"}",
"break;",
"case MFI_IQPH:\ns->frame_hi = VAR_2;",
"break;",
"case MFI_IQPL:\ncase MFI_IQP:\nframe_addr = (VAR_2 & ~0x1F);",
"frame_addr |= ((uint64_t)s->frame_hi << 32);",
"s->frame_hi = 0;",
"frame_count = (VAR_2 >> 1) & 0xF;",
"megasas_handle_frame(s, frame_addr, frame_count);",
"break;",
"default:\ntrace_megasas_mmio_invalid_writel(VAR_1, VAR_2);",
"break;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21,
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51,
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75,
77
],
[
79
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99,
103
],
[
105
],
[
107,
111,
115
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129,
131
],
[
133
],
[
135
],
[
137
]
] |
22,284 | static int mpjpeg_read_packet(AVFormatContext *s, AVPacket *pkt)
{
int size;
int ret;
MPJPEGDemuxContext *mpjpeg = s->priv_data;
if (mpjpeg->boundary == NULL) {
mpjpeg->boundary = av_strdup("--");
mpjpeg->searchstr = av_strdup("\r\n--");
if (!mpjpeg->boundary || !mpjpeg->searchstr) {
av_freep(&mpjpeg->boundary);
av_freep(&mpjpeg->searchstr);
return AVERROR(ENOMEM);
}
mpjpeg->searchstr_len = strlen(mpjpeg->searchstr);
}
ret = parse_multipart_header(s->pb, &size, mpjpeg->boundary, s);
if (ret < 0)
return ret;
if (size > 0) {
/* size has been provided to us in MIME header */
ret = av_get_packet(s->pb, pkt, size);
} else {
/* no size was given -- we read until the next boundary or end-of-file */
int remaining = 0, len;
const int read_chunk = 2048;
av_init_packet(pkt);
pkt->data = NULL;
pkt->size = 0;
pkt->pos = avio_tell(s->pb);
/* we may need to return as much as all we've read back to the buffer */
ffio_ensure_seekback(s->pb, read_chunk);
while ((ret = av_append_packet(s->pb, pkt, read_chunk - remaining)) >= 0) {
/* scan the new data */
len = ret + remaining;
char *start = pkt->data + pkt->size - len;
do {
if (!memcmp(start, mpjpeg->searchstr, mpjpeg->searchstr_len)) {
// got the boundary! rewind the stream
avio_seek(s->pb, -(len-2), SEEK_CUR);
pkt->size -= (len-2);
return pkt->size;
}
len--;
start++;
} while (len >= mpjpeg->searchstr_len);
remaining = len;
}
/* error or EOF occurred */
if (ret == AVERROR_EOF) {
ret = pkt->size > 0 ? pkt->size : AVERROR_EOF;
} else {
av_packet_unref(pkt);
}
}
return ret;
}
| false | FFmpeg | 259c71c199e9b4ea89bf4cb90ed0e207ddc9dff7 | static int mpjpeg_read_packet(AVFormatContext *s, AVPacket *pkt)
{
int size;
int ret;
MPJPEGDemuxContext *mpjpeg = s->priv_data;
if (mpjpeg->boundary == NULL) {
mpjpeg->boundary = av_strdup("--");
mpjpeg->searchstr = av_strdup("\r\n--");
if (!mpjpeg->boundary || !mpjpeg->searchstr) {
av_freep(&mpjpeg->boundary);
av_freep(&mpjpeg->searchstr);
return AVERROR(ENOMEM);
}
mpjpeg->searchstr_len = strlen(mpjpeg->searchstr);
}
ret = parse_multipart_header(s->pb, &size, mpjpeg->boundary, s);
if (ret < 0)
return ret;
if (size > 0) {
ret = av_get_packet(s->pb, pkt, size);
} else {
int remaining = 0, len;
const int read_chunk = 2048;
av_init_packet(pkt);
pkt->data = NULL;
pkt->size = 0;
pkt->pos = avio_tell(s->pb);
ffio_ensure_seekback(s->pb, read_chunk);
while ((ret = av_append_packet(s->pb, pkt, read_chunk - remaining)) >= 0) {
len = ret + remaining;
char *start = pkt->data + pkt->size - len;
do {
if (!memcmp(start, mpjpeg->searchstr, mpjpeg->searchstr_len)) {
avio_seek(s->pb, -(len-2), SEEK_CUR);
pkt->size -= (len-2);
return pkt->size;
}
len--;
start++;
} while (len >= mpjpeg->searchstr_len);
remaining = len;
}
if (ret == AVERROR_EOF) {
ret = pkt->size > 0 ? pkt->size : AVERROR_EOF;
} else {
av_packet_unref(pkt);
}
}
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)
{
int VAR_2;
int VAR_3;
MPJPEGDemuxContext *mpjpeg = VAR_0->priv_data;
if (mpjpeg->boundary == NULL) {
mpjpeg->boundary = av_strdup("--");
mpjpeg->searchstr = av_strdup("\r\n--");
if (!mpjpeg->boundary || !mpjpeg->searchstr) {
av_freep(&mpjpeg->boundary);
av_freep(&mpjpeg->searchstr);
return AVERROR(ENOMEM);
}
mpjpeg->searchstr_len = strlen(mpjpeg->searchstr);
}
VAR_3 = parse_multipart_header(VAR_0->pb, &VAR_2, mpjpeg->boundary, VAR_0);
if (VAR_3 < 0)
return VAR_3;
if (VAR_2 > 0) {
VAR_3 = av_get_packet(VAR_0->pb, VAR_1, VAR_2);
} else {
int VAR_4 = 0, VAR_5;
const int VAR_6 = 2048;
av_init_packet(VAR_1);
VAR_1->data = NULL;
VAR_1->VAR_2 = 0;
VAR_1->pos = avio_tell(VAR_0->pb);
ffio_ensure_seekback(VAR_0->pb, VAR_6);
while ((VAR_3 = av_append_packet(VAR_0->pb, VAR_1, VAR_6 - VAR_4)) >= 0) {
VAR_5 = VAR_3 + VAR_4;
char *VAR_7 = VAR_1->data + VAR_1->VAR_2 - VAR_5;
do {
if (!memcmp(VAR_7, mpjpeg->searchstr, mpjpeg->searchstr_len)) {
avio_seek(VAR_0->pb, -(VAR_5-2), SEEK_CUR);
VAR_1->VAR_2 -= (VAR_5-2);
return VAR_1->VAR_2;
}
VAR_5--;
VAR_7++;
} while (VAR_5 >= mpjpeg->searchstr_len);
VAR_4 = VAR_5;
}
if (VAR_3 == AVERROR_EOF) {
VAR_3 = VAR_1->VAR_2 > 0 ? VAR_1->VAR_2 : AVERROR_EOF;
} else {
av_packet_unref(VAR_1);
}
}
return VAR_3;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)\n{",
"int VAR_2;",
"int VAR_3;",
"MPJPEGDemuxContext *mpjpeg = VAR_0->priv_data;",
"if (mpjpeg->boundary == NULL) {",
"mpjpeg->boundary = av_strdup(\"--\");",
"mpjpeg->searchstr = av_strdup(\"\\r\\n--\");",
"if (!mpjpeg->boundary || !mpjpeg->searchstr) {",
"av_freep(&mpjpeg->boundary);",
"av_freep(&mpjpeg->searchstr);",
"return AVERROR(ENOMEM);",
"}",
"mpjpeg->searchstr_len = strlen(mpjpeg->searchstr);",
"}",
"VAR_3 = parse_multipart_header(VAR_0->pb, &VAR_2, mpjpeg->boundary, VAR_0);",
"if (VAR_3 < 0)\nreturn VAR_3;",
"if (VAR_2 > 0) {",
"VAR_3 = av_get_packet(VAR_0->pb, VAR_1, VAR_2);",
"} else {",
"int VAR_4 = 0, VAR_5;",
"const int VAR_6 = 2048;",
"av_init_packet(VAR_1);",
"VAR_1->data = NULL;",
"VAR_1->VAR_2 = 0;",
"VAR_1->pos = avio_tell(VAR_0->pb);",
"ffio_ensure_seekback(VAR_0->pb, VAR_6);",
"while ((VAR_3 = av_append_packet(VAR_0->pb, VAR_1, VAR_6 - VAR_4)) >= 0) {",
"VAR_5 = VAR_3 + VAR_4;",
"char *VAR_7 = VAR_1->data + VAR_1->VAR_2 - VAR_5;",
"do {",
"if (!memcmp(VAR_7, mpjpeg->searchstr, mpjpeg->searchstr_len)) {",
"avio_seek(VAR_0->pb, -(VAR_5-2), SEEK_CUR);",
"VAR_1->VAR_2 -= (VAR_5-2);",
"return VAR_1->VAR_2;",
"}",
"VAR_5--;",
"VAR_7++;",
"} while (VAR_5 >= mpjpeg->searchstr_len);",
"VAR_4 = VAR_5;",
"}",
"if (VAR_3 == AVERROR_EOF) {",
"VAR_3 = VAR_1->VAR_2 > 0 ? VAR_1->VAR_2 : AVERROR_EOF;",
"} else {",
"av_packet_unref(VAR_1);",
"}",
"}",
"return VAR_3;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
41,
43
],
[
47
],
[
51
],
[
53
],
[
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
75
],
[
79
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
129
],
[
131
]
] |
22,285 | static void gen_flt3_arith (DisasContext *ctx, uint32_t opc,
int fd, int fr, int fs, int ft)
{
const char *opn = "flt3_arith";
switch (opc) {
case OPC_ALNV_PS:
check_cp1_64bitmode(ctx);
{
TCGv t0 = tcg_temp_local_new();
TCGv_i32 fp = tcg_temp_new_i32();
TCGv_i32 fph = tcg_temp_new_i32();
int l1 = gen_new_label();
int l2 = gen_new_label();
gen_load_gpr(t0, fr);
tcg_gen_andi_tl(t0, t0, 0x7);
tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0, l1);
gen_load_fpr32(fp, fs);
gen_load_fpr32h(ctx, fph, fs);
gen_store_fpr32(fp, fd);
gen_store_fpr32h(ctx, fph, fd);
tcg_gen_br(l2);
gen_set_label(l1);
tcg_gen_brcondi_tl(TCG_COND_NE, t0, 4, l2);
tcg_temp_free(t0);
#ifdef TARGET_WORDS_BIGENDIAN
gen_load_fpr32(fp, fs);
gen_load_fpr32h(ctx, fph, ft);
gen_store_fpr32h(ctx, fp, fd);
gen_store_fpr32(fph, fd);
#else
gen_load_fpr32h(ctx, fph, fs);
gen_load_fpr32(fp, ft);
gen_store_fpr32(fph, fd);
gen_store_fpr32h(ctx, fp, fd);
#endif
gen_set_label(l2);
tcg_temp_free_i32(fp);
tcg_temp_free_i32(fph);
}
opn = "alnv.ps";
break;
case OPC_MADD_S:
check_cop1x(ctx);
{
TCGv_i32 fp0 = tcg_temp_new_i32();
TCGv_i32 fp1 = tcg_temp_new_i32();
TCGv_i32 fp2 = tcg_temp_new_i32();
gen_load_fpr32(fp0, fs);
gen_load_fpr32(fp1, ft);
gen_load_fpr32(fp2, fr);
gen_helper_float_madd_s(fp2, cpu_env, fp0, fp1, fp2);
tcg_temp_free_i32(fp0);
tcg_temp_free_i32(fp1);
gen_store_fpr32(fp2, fd);
tcg_temp_free_i32(fp2);
}
opn = "madd.s";
break;
case OPC_MADD_D:
check_cop1x(ctx);
check_cp1_registers(ctx, fd | fs | ft | fr);
{
TCGv_i64 fp0 = tcg_temp_new_i64();
TCGv_i64 fp1 = tcg_temp_new_i64();
TCGv_i64 fp2 = tcg_temp_new_i64();
gen_load_fpr64(ctx, fp0, fs);
gen_load_fpr64(ctx, fp1, ft);
gen_load_fpr64(ctx, fp2, fr);
gen_helper_float_madd_d(fp2, cpu_env, fp0, fp1, fp2);
tcg_temp_free_i64(fp0);
tcg_temp_free_i64(fp1);
gen_store_fpr64(ctx, fp2, fd);
tcg_temp_free_i64(fp2);
}
opn = "madd.d";
break;
case OPC_MADD_PS:
check_cp1_64bitmode(ctx);
{
TCGv_i64 fp0 = tcg_temp_new_i64();
TCGv_i64 fp1 = tcg_temp_new_i64();
TCGv_i64 fp2 = tcg_temp_new_i64();
gen_load_fpr64(ctx, fp0, fs);
gen_load_fpr64(ctx, fp1, ft);
gen_load_fpr64(ctx, fp2, fr);
gen_helper_float_madd_ps(fp2, cpu_env, fp0, fp1, fp2);
tcg_temp_free_i64(fp0);
tcg_temp_free_i64(fp1);
gen_store_fpr64(ctx, fp2, fd);
tcg_temp_free_i64(fp2);
}
opn = "madd.ps";
break;
case OPC_MSUB_S:
check_cop1x(ctx);
{
TCGv_i32 fp0 = tcg_temp_new_i32();
TCGv_i32 fp1 = tcg_temp_new_i32();
TCGv_i32 fp2 = tcg_temp_new_i32();
gen_load_fpr32(fp0, fs);
gen_load_fpr32(fp1, ft);
gen_load_fpr32(fp2, fr);
gen_helper_float_msub_s(fp2, cpu_env, fp0, fp1, fp2);
tcg_temp_free_i32(fp0);
tcg_temp_free_i32(fp1);
gen_store_fpr32(fp2, fd);
tcg_temp_free_i32(fp2);
}
opn = "msub.s";
break;
case OPC_MSUB_D:
check_cop1x(ctx);
check_cp1_registers(ctx, fd | fs | ft | fr);
{
TCGv_i64 fp0 = tcg_temp_new_i64();
TCGv_i64 fp1 = tcg_temp_new_i64();
TCGv_i64 fp2 = tcg_temp_new_i64();
gen_load_fpr64(ctx, fp0, fs);
gen_load_fpr64(ctx, fp1, ft);
gen_load_fpr64(ctx, fp2, fr);
gen_helper_float_msub_d(fp2, cpu_env, fp0, fp1, fp2);
tcg_temp_free_i64(fp0);
tcg_temp_free_i64(fp1);
gen_store_fpr64(ctx, fp2, fd);
tcg_temp_free_i64(fp2);
}
opn = "msub.d";
break;
case OPC_MSUB_PS:
check_cp1_64bitmode(ctx);
{
TCGv_i64 fp0 = tcg_temp_new_i64();
TCGv_i64 fp1 = tcg_temp_new_i64();
TCGv_i64 fp2 = tcg_temp_new_i64();
gen_load_fpr64(ctx, fp0, fs);
gen_load_fpr64(ctx, fp1, ft);
gen_load_fpr64(ctx, fp2, fr);
gen_helper_float_msub_ps(fp2, cpu_env, fp0, fp1, fp2);
tcg_temp_free_i64(fp0);
tcg_temp_free_i64(fp1);
gen_store_fpr64(ctx, fp2, fd);
tcg_temp_free_i64(fp2);
}
opn = "msub.ps";
break;
case OPC_NMADD_S:
check_cop1x(ctx);
{
TCGv_i32 fp0 = tcg_temp_new_i32();
TCGv_i32 fp1 = tcg_temp_new_i32();
TCGv_i32 fp2 = tcg_temp_new_i32();
gen_load_fpr32(fp0, fs);
gen_load_fpr32(fp1, ft);
gen_load_fpr32(fp2, fr);
gen_helper_float_nmadd_s(fp2, cpu_env, fp0, fp1, fp2);
tcg_temp_free_i32(fp0);
tcg_temp_free_i32(fp1);
gen_store_fpr32(fp2, fd);
tcg_temp_free_i32(fp2);
}
opn = "nmadd.s";
break;
case OPC_NMADD_D:
check_cop1x(ctx);
check_cp1_registers(ctx, fd | fs | ft | fr);
{
TCGv_i64 fp0 = tcg_temp_new_i64();
TCGv_i64 fp1 = tcg_temp_new_i64();
TCGv_i64 fp2 = tcg_temp_new_i64();
gen_load_fpr64(ctx, fp0, fs);
gen_load_fpr64(ctx, fp1, ft);
gen_load_fpr64(ctx, fp2, fr);
gen_helper_float_nmadd_d(fp2, cpu_env, fp0, fp1, fp2);
tcg_temp_free_i64(fp0);
tcg_temp_free_i64(fp1);
gen_store_fpr64(ctx, fp2, fd);
tcg_temp_free_i64(fp2);
}
opn = "nmadd.d";
break;
case OPC_NMADD_PS:
check_cp1_64bitmode(ctx);
{
TCGv_i64 fp0 = tcg_temp_new_i64();
TCGv_i64 fp1 = tcg_temp_new_i64();
TCGv_i64 fp2 = tcg_temp_new_i64();
gen_load_fpr64(ctx, fp0, fs);
gen_load_fpr64(ctx, fp1, ft);
gen_load_fpr64(ctx, fp2, fr);
gen_helper_float_nmadd_ps(fp2, cpu_env, fp0, fp1, fp2);
tcg_temp_free_i64(fp0);
tcg_temp_free_i64(fp1);
gen_store_fpr64(ctx, fp2, fd);
tcg_temp_free_i64(fp2);
}
opn = "nmadd.ps";
break;
case OPC_NMSUB_S:
check_cop1x(ctx);
{
TCGv_i32 fp0 = tcg_temp_new_i32();
TCGv_i32 fp1 = tcg_temp_new_i32();
TCGv_i32 fp2 = tcg_temp_new_i32();
gen_load_fpr32(fp0, fs);
gen_load_fpr32(fp1, ft);
gen_load_fpr32(fp2, fr);
gen_helper_float_nmsub_s(fp2, cpu_env, fp0, fp1, fp2);
tcg_temp_free_i32(fp0);
tcg_temp_free_i32(fp1);
gen_store_fpr32(fp2, fd);
tcg_temp_free_i32(fp2);
}
opn = "nmsub.s";
break;
case OPC_NMSUB_D:
check_cop1x(ctx);
check_cp1_registers(ctx, fd | fs | ft | fr);
{
TCGv_i64 fp0 = tcg_temp_new_i64();
TCGv_i64 fp1 = tcg_temp_new_i64();
TCGv_i64 fp2 = tcg_temp_new_i64();
gen_load_fpr64(ctx, fp0, fs);
gen_load_fpr64(ctx, fp1, ft);
gen_load_fpr64(ctx, fp2, fr);
gen_helper_float_nmsub_d(fp2, cpu_env, fp0, fp1, fp2);
tcg_temp_free_i64(fp0);
tcg_temp_free_i64(fp1);
gen_store_fpr64(ctx, fp2, fd);
tcg_temp_free_i64(fp2);
}
opn = "nmsub.d";
break;
case OPC_NMSUB_PS:
check_cp1_64bitmode(ctx);
{
TCGv_i64 fp0 = tcg_temp_new_i64();
TCGv_i64 fp1 = tcg_temp_new_i64();
TCGv_i64 fp2 = tcg_temp_new_i64();
gen_load_fpr64(ctx, fp0, fs);
gen_load_fpr64(ctx, fp1, ft);
gen_load_fpr64(ctx, fp2, fr);
gen_helper_float_nmsub_ps(fp2, cpu_env, fp0, fp1, fp2);
tcg_temp_free_i64(fp0);
tcg_temp_free_i64(fp1);
gen_store_fpr64(ctx, fp2, fd);
tcg_temp_free_i64(fp2);
}
opn = "nmsub.ps";
break;
default:
MIPS_INVAL(opn);
generate_exception (ctx, EXCP_RI);
return;
}
(void)opn; /* avoid a compiler warning */
MIPS_DEBUG("%s %s, %s, %s, %s", opn, fregnames[fd], fregnames[fr],
fregnames[fs], fregnames[ft]);
}
| false | qemu | 42a268c241183877192c376d03bd9b6d527407c7 | static void gen_flt3_arith (DisasContext *ctx, uint32_t opc,
int fd, int fr, int fs, int ft)
{
const char *opn = "flt3_arith";
switch (opc) {
case OPC_ALNV_PS:
check_cp1_64bitmode(ctx);
{
TCGv t0 = tcg_temp_local_new();
TCGv_i32 fp = tcg_temp_new_i32();
TCGv_i32 fph = tcg_temp_new_i32();
int l1 = gen_new_label();
int l2 = gen_new_label();
gen_load_gpr(t0, fr);
tcg_gen_andi_tl(t0, t0, 0x7);
tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0, l1);
gen_load_fpr32(fp, fs);
gen_load_fpr32h(ctx, fph, fs);
gen_store_fpr32(fp, fd);
gen_store_fpr32h(ctx, fph, fd);
tcg_gen_br(l2);
gen_set_label(l1);
tcg_gen_brcondi_tl(TCG_COND_NE, t0, 4, l2);
tcg_temp_free(t0);
#ifdef TARGET_WORDS_BIGENDIAN
gen_load_fpr32(fp, fs);
gen_load_fpr32h(ctx, fph, ft);
gen_store_fpr32h(ctx, fp, fd);
gen_store_fpr32(fph, fd);
#else
gen_load_fpr32h(ctx, fph, fs);
gen_load_fpr32(fp, ft);
gen_store_fpr32(fph, fd);
gen_store_fpr32h(ctx, fp, fd);
#endif
gen_set_label(l2);
tcg_temp_free_i32(fp);
tcg_temp_free_i32(fph);
}
opn = "alnv.ps";
break;
case OPC_MADD_S:
check_cop1x(ctx);
{
TCGv_i32 fp0 = tcg_temp_new_i32();
TCGv_i32 fp1 = tcg_temp_new_i32();
TCGv_i32 fp2 = tcg_temp_new_i32();
gen_load_fpr32(fp0, fs);
gen_load_fpr32(fp1, ft);
gen_load_fpr32(fp2, fr);
gen_helper_float_madd_s(fp2, cpu_env, fp0, fp1, fp2);
tcg_temp_free_i32(fp0);
tcg_temp_free_i32(fp1);
gen_store_fpr32(fp2, fd);
tcg_temp_free_i32(fp2);
}
opn = "madd.s";
break;
case OPC_MADD_D:
check_cop1x(ctx);
check_cp1_registers(ctx, fd | fs | ft | fr);
{
TCGv_i64 fp0 = tcg_temp_new_i64();
TCGv_i64 fp1 = tcg_temp_new_i64();
TCGv_i64 fp2 = tcg_temp_new_i64();
gen_load_fpr64(ctx, fp0, fs);
gen_load_fpr64(ctx, fp1, ft);
gen_load_fpr64(ctx, fp2, fr);
gen_helper_float_madd_d(fp2, cpu_env, fp0, fp1, fp2);
tcg_temp_free_i64(fp0);
tcg_temp_free_i64(fp1);
gen_store_fpr64(ctx, fp2, fd);
tcg_temp_free_i64(fp2);
}
opn = "madd.d";
break;
case OPC_MADD_PS:
check_cp1_64bitmode(ctx);
{
TCGv_i64 fp0 = tcg_temp_new_i64();
TCGv_i64 fp1 = tcg_temp_new_i64();
TCGv_i64 fp2 = tcg_temp_new_i64();
gen_load_fpr64(ctx, fp0, fs);
gen_load_fpr64(ctx, fp1, ft);
gen_load_fpr64(ctx, fp2, fr);
gen_helper_float_madd_ps(fp2, cpu_env, fp0, fp1, fp2);
tcg_temp_free_i64(fp0);
tcg_temp_free_i64(fp1);
gen_store_fpr64(ctx, fp2, fd);
tcg_temp_free_i64(fp2);
}
opn = "madd.ps";
break;
case OPC_MSUB_S:
check_cop1x(ctx);
{
TCGv_i32 fp0 = tcg_temp_new_i32();
TCGv_i32 fp1 = tcg_temp_new_i32();
TCGv_i32 fp2 = tcg_temp_new_i32();
gen_load_fpr32(fp0, fs);
gen_load_fpr32(fp1, ft);
gen_load_fpr32(fp2, fr);
gen_helper_float_msub_s(fp2, cpu_env, fp0, fp1, fp2);
tcg_temp_free_i32(fp0);
tcg_temp_free_i32(fp1);
gen_store_fpr32(fp2, fd);
tcg_temp_free_i32(fp2);
}
opn = "msub.s";
break;
case OPC_MSUB_D:
check_cop1x(ctx);
check_cp1_registers(ctx, fd | fs | ft | fr);
{
TCGv_i64 fp0 = tcg_temp_new_i64();
TCGv_i64 fp1 = tcg_temp_new_i64();
TCGv_i64 fp2 = tcg_temp_new_i64();
gen_load_fpr64(ctx, fp0, fs);
gen_load_fpr64(ctx, fp1, ft);
gen_load_fpr64(ctx, fp2, fr);
gen_helper_float_msub_d(fp2, cpu_env, fp0, fp1, fp2);
tcg_temp_free_i64(fp0);
tcg_temp_free_i64(fp1);
gen_store_fpr64(ctx, fp2, fd);
tcg_temp_free_i64(fp2);
}
opn = "msub.d";
break;
case OPC_MSUB_PS:
check_cp1_64bitmode(ctx);
{
TCGv_i64 fp0 = tcg_temp_new_i64();
TCGv_i64 fp1 = tcg_temp_new_i64();
TCGv_i64 fp2 = tcg_temp_new_i64();
gen_load_fpr64(ctx, fp0, fs);
gen_load_fpr64(ctx, fp1, ft);
gen_load_fpr64(ctx, fp2, fr);
gen_helper_float_msub_ps(fp2, cpu_env, fp0, fp1, fp2);
tcg_temp_free_i64(fp0);
tcg_temp_free_i64(fp1);
gen_store_fpr64(ctx, fp2, fd);
tcg_temp_free_i64(fp2);
}
opn = "msub.ps";
break;
case OPC_NMADD_S:
check_cop1x(ctx);
{
TCGv_i32 fp0 = tcg_temp_new_i32();
TCGv_i32 fp1 = tcg_temp_new_i32();
TCGv_i32 fp2 = tcg_temp_new_i32();
gen_load_fpr32(fp0, fs);
gen_load_fpr32(fp1, ft);
gen_load_fpr32(fp2, fr);
gen_helper_float_nmadd_s(fp2, cpu_env, fp0, fp1, fp2);
tcg_temp_free_i32(fp0);
tcg_temp_free_i32(fp1);
gen_store_fpr32(fp2, fd);
tcg_temp_free_i32(fp2);
}
opn = "nmadd.s";
break;
case OPC_NMADD_D:
check_cop1x(ctx);
check_cp1_registers(ctx, fd | fs | ft | fr);
{
TCGv_i64 fp0 = tcg_temp_new_i64();
TCGv_i64 fp1 = tcg_temp_new_i64();
TCGv_i64 fp2 = tcg_temp_new_i64();
gen_load_fpr64(ctx, fp0, fs);
gen_load_fpr64(ctx, fp1, ft);
gen_load_fpr64(ctx, fp2, fr);
gen_helper_float_nmadd_d(fp2, cpu_env, fp0, fp1, fp2);
tcg_temp_free_i64(fp0);
tcg_temp_free_i64(fp1);
gen_store_fpr64(ctx, fp2, fd);
tcg_temp_free_i64(fp2);
}
opn = "nmadd.d";
break;
case OPC_NMADD_PS:
check_cp1_64bitmode(ctx);
{
TCGv_i64 fp0 = tcg_temp_new_i64();
TCGv_i64 fp1 = tcg_temp_new_i64();
TCGv_i64 fp2 = tcg_temp_new_i64();
gen_load_fpr64(ctx, fp0, fs);
gen_load_fpr64(ctx, fp1, ft);
gen_load_fpr64(ctx, fp2, fr);
gen_helper_float_nmadd_ps(fp2, cpu_env, fp0, fp1, fp2);
tcg_temp_free_i64(fp0);
tcg_temp_free_i64(fp1);
gen_store_fpr64(ctx, fp2, fd);
tcg_temp_free_i64(fp2);
}
opn = "nmadd.ps";
break;
case OPC_NMSUB_S:
check_cop1x(ctx);
{
TCGv_i32 fp0 = tcg_temp_new_i32();
TCGv_i32 fp1 = tcg_temp_new_i32();
TCGv_i32 fp2 = tcg_temp_new_i32();
gen_load_fpr32(fp0, fs);
gen_load_fpr32(fp1, ft);
gen_load_fpr32(fp2, fr);
gen_helper_float_nmsub_s(fp2, cpu_env, fp0, fp1, fp2);
tcg_temp_free_i32(fp0);
tcg_temp_free_i32(fp1);
gen_store_fpr32(fp2, fd);
tcg_temp_free_i32(fp2);
}
opn = "nmsub.s";
break;
case OPC_NMSUB_D:
check_cop1x(ctx);
check_cp1_registers(ctx, fd | fs | ft | fr);
{
TCGv_i64 fp0 = tcg_temp_new_i64();
TCGv_i64 fp1 = tcg_temp_new_i64();
TCGv_i64 fp2 = tcg_temp_new_i64();
gen_load_fpr64(ctx, fp0, fs);
gen_load_fpr64(ctx, fp1, ft);
gen_load_fpr64(ctx, fp2, fr);
gen_helper_float_nmsub_d(fp2, cpu_env, fp0, fp1, fp2);
tcg_temp_free_i64(fp0);
tcg_temp_free_i64(fp1);
gen_store_fpr64(ctx, fp2, fd);
tcg_temp_free_i64(fp2);
}
opn = "nmsub.d";
break;
case OPC_NMSUB_PS:
check_cp1_64bitmode(ctx);
{
TCGv_i64 fp0 = tcg_temp_new_i64();
TCGv_i64 fp1 = tcg_temp_new_i64();
TCGv_i64 fp2 = tcg_temp_new_i64();
gen_load_fpr64(ctx, fp0, fs);
gen_load_fpr64(ctx, fp1, ft);
gen_load_fpr64(ctx, fp2, fr);
gen_helper_float_nmsub_ps(fp2, cpu_env, fp0, fp1, fp2);
tcg_temp_free_i64(fp0);
tcg_temp_free_i64(fp1);
gen_store_fpr64(ctx, fp2, fd);
tcg_temp_free_i64(fp2);
}
opn = "nmsub.ps";
break;
default:
MIPS_INVAL(opn);
generate_exception (ctx, EXCP_RI);
return;
}
(void)opn;
MIPS_DEBUG("%s %s, %s, %s, %s", opn, fregnames[fd], fregnames[fr],
fregnames[fs], fregnames[ft]);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0 (DisasContext *VAR_0, uint32_t VAR_1,
int VAR_2, int VAR_3, int VAR_4, int VAR_5)
{
const char *VAR_6 = "flt3_arith";
switch (VAR_1) {
case OPC_ALNV_PS:
check_cp1_64bitmode(VAR_0);
{
TCGv t0 = tcg_temp_local_new();
TCGv_i32 fp = tcg_temp_new_i32();
TCGv_i32 fph = tcg_temp_new_i32();
int VAR_7 = gen_new_label();
int VAR_8 = gen_new_label();
gen_load_gpr(t0, VAR_3);
tcg_gen_andi_tl(t0, t0, 0x7);
tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0, VAR_7);
gen_load_fpr32(fp, VAR_4);
gen_load_fpr32h(VAR_0, fph, VAR_4);
gen_store_fpr32(fp, VAR_2);
gen_store_fpr32h(VAR_0, fph, VAR_2);
tcg_gen_br(VAR_8);
gen_set_label(VAR_7);
tcg_gen_brcondi_tl(TCG_COND_NE, t0, 4, VAR_8);
tcg_temp_free(t0);
#ifdef TARGET_WORDS_BIGENDIAN
gen_load_fpr32(fp, VAR_4);
gen_load_fpr32h(VAR_0, fph, VAR_5);
gen_store_fpr32h(VAR_0, fp, VAR_2);
gen_store_fpr32(fph, VAR_2);
#else
gen_load_fpr32h(VAR_0, fph, VAR_4);
gen_load_fpr32(fp, VAR_5);
gen_store_fpr32(fph, VAR_2);
gen_store_fpr32h(VAR_0, fp, VAR_2);
#endif
gen_set_label(VAR_8);
tcg_temp_free_i32(fp);
tcg_temp_free_i32(fph);
}
VAR_6 = "alnv.ps";
break;
case OPC_MADD_S:
check_cop1x(VAR_0);
{
TCGv_i32 fp0 = tcg_temp_new_i32();
TCGv_i32 fp1 = tcg_temp_new_i32();
TCGv_i32 fp2 = tcg_temp_new_i32();
gen_load_fpr32(fp0, VAR_4);
gen_load_fpr32(fp1, VAR_5);
gen_load_fpr32(fp2, VAR_3);
gen_helper_float_madd_s(fp2, cpu_env, fp0, fp1, fp2);
tcg_temp_free_i32(fp0);
tcg_temp_free_i32(fp1);
gen_store_fpr32(fp2, VAR_2);
tcg_temp_free_i32(fp2);
}
VAR_6 = "madd.s";
break;
case OPC_MADD_D:
check_cop1x(VAR_0);
check_cp1_registers(VAR_0, VAR_2 | VAR_4 | VAR_5 | VAR_3);
{
TCGv_i64 fp0 = tcg_temp_new_i64();
TCGv_i64 fp1 = tcg_temp_new_i64();
TCGv_i64 fp2 = tcg_temp_new_i64();
gen_load_fpr64(VAR_0, fp0, VAR_4);
gen_load_fpr64(VAR_0, fp1, VAR_5);
gen_load_fpr64(VAR_0, fp2, VAR_3);
gen_helper_float_madd_d(fp2, cpu_env, fp0, fp1, fp2);
tcg_temp_free_i64(fp0);
tcg_temp_free_i64(fp1);
gen_store_fpr64(VAR_0, fp2, VAR_2);
tcg_temp_free_i64(fp2);
}
VAR_6 = "madd.d";
break;
case OPC_MADD_PS:
check_cp1_64bitmode(VAR_0);
{
TCGv_i64 fp0 = tcg_temp_new_i64();
TCGv_i64 fp1 = tcg_temp_new_i64();
TCGv_i64 fp2 = tcg_temp_new_i64();
gen_load_fpr64(VAR_0, fp0, VAR_4);
gen_load_fpr64(VAR_0, fp1, VAR_5);
gen_load_fpr64(VAR_0, fp2, VAR_3);
gen_helper_float_madd_ps(fp2, cpu_env, fp0, fp1, fp2);
tcg_temp_free_i64(fp0);
tcg_temp_free_i64(fp1);
gen_store_fpr64(VAR_0, fp2, VAR_2);
tcg_temp_free_i64(fp2);
}
VAR_6 = "madd.ps";
break;
case OPC_MSUB_S:
check_cop1x(VAR_0);
{
TCGv_i32 fp0 = tcg_temp_new_i32();
TCGv_i32 fp1 = tcg_temp_new_i32();
TCGv_i32 fp2 = tcg_temp_new_i32();
gen_load_fpr32(fp0, VAR_4);
gen_load_fpr32(fp1, VAR_5);
gen_load_fpr32(fp2, VAR_3);
gen_helper_float_msub_s(fp2, cpu_env, fp0, fp1, fp2);
tcg_temp_free_i32(fp0);
tcg_temp_free_i32(fp1);
gen_store_fpr32(fp2, VAR_2);
tcg_temp_free_i32(fp2);
}
VAR_6 = "msub.s";
break;
case OPC_MSUB_D:
check_cop1x(VAR_0);
check_cp1_registers(VAR_0, VAR_2 | VAR_4 | VAR_5 | VAR_3);
{
TCGv_i64 fp0 = tcg_temp_new_i64();
TCGv_i64 fp1 = tcg_temp_new_i64();
TCGv_i64 fp2 = tcg_temp_new_i64();
gen_load_fpr64(VAR_0, fp0, VAR_4);
gen_load_fpr64(VAR_0, fp1, VAR_5);
gen_load_fpr64(VAR_0, fp2, VAR_3);
gen_helper_float_msub_d(fp2, cpu_env, fp0, fp1, fp2);
tcg_temp_free_i64(fp0);
tcg_temp_free_i64(fp1);
gen_store_fpr64(VAR_0, fp2, VAR_2);
tcg_temp_free_i64(fp2);
}
VAR_6 = "msub.d";
break;
case OPC_MSUB_PS:
check_cp1_64bitmode(VAR_0);
{
TCGv_i64 fp0 = tcg_temp_new_i64();
TCGv_i64 fp1 = tcg_temp_new_i64();
TCGv_i64 fp2 = tcg_temp_new_i64();
gen_load_fpr64(VAR_0, fp0, VAR_4);
gen_load_fpr64(VAR_0, fp1, VAR_5);
gen_load_fpr64(VAR_0, fp2, VAR_3);
gen_helper_float_msub_ps(fp2, cpu_env, fp0, fp1, fp2);
tcg_temp_free_i64(fp0);
tcg_temp_free_i64(fp1);
gen_store_fpr64(VAR_0, fp2, VAR_2);
tcg_temp_free_i64(fp2);
}
VAR_6 = "msub.ps";
break;
case OPC_NMADD_S:
check_cop1x(VAR_0);
{
TCGv_i32 fp0 = tcg_temp_new_i32();
TCGv_i32 fp1 = tcg_temp_new_i32();
TCGv_i32 fp2 = tcg_temp_new_i32();
gen_load_fpr32(fp0, VAR_4);
gen_load_fpr32(fp1, VAR_5);
gen_load_fpr32(fp2, VAR_3);
gen_helper_float_nmadd_s(fp2, cpu_env, fp0, fp1, fp2);
tcg_temp_free_i32(fp0);
tcg_temp_free_i32(fp1);
gen_store_fpr32(fp2, VAR_2);
tcg_temp_free_i32(fp2);
}
VAR_6 = "nmadd.s";
break;
case OPC_NMADD_D:
check_cop1x(VAR_0);
check_cp1_registers(VAR_0, VAR_2 | VAR_4 | VAR_5 | VAR_3);
{
TCGv_i64 fp0 = tcg_temp_new_i64();
TCGv_i64 fp1 = tcg_temp_new_i64();
TCGv_i64 fp2 = tcg_temp_new_i64();
gen_load_fpr64(VAR_0, fp0, VAR_4);
gen_load_fpr64(VAR_0, fp1, VAR_5);
gen_load_fpr64(VAR_0, fp2, VAR_3);
gen_helper_float_nmadd_d(fp2, cpu_env, fp0, fp1, fp2);
tcg_temp_free_i64(fp0);
tcg_temp_free_i64(fp1);
gen_store_fpr64(VAR_0, fp2, VAR_2);
tcg_temp_free_i64(fp2);
}
VAR_6 = "nmadd.d";
break;
case OPC_NMADD_PS:
check_cp1_64bitmode(VAR_0);
{
TCGv_i64 fp0 = tcg_temp_new_i64();
TCGv_i64 fp1 = tcg_temp_new_i64();
TCGv_i64 fp2 = tcg_temp_new_i64();
gen_load_fpr64(VAR_0, fp0, VAR_4);
gen_load_fpr64(VAR_0, fp1, VAR_5);
gen_load_fpr64(VAR_0, fp2, VAR_3);
gen_helper_float_nmadd_ps(fp2, cpu_env, fp0, fp1, fp2);
tcg_temp_free_i64(fp0);
tcg_temp_free_i64(fp1);
gen_store_fpr64(VAR_0, fp2, VAR_2);
tcg_temp_free_i64(fp2);
}
VAR_6 = "nmadd.ps";
break;
case OPC_NMSUB_S:
check_cop1x(VAR_0);
{
TCGv_i32 fp0 = tcg_temp_new_i32();
TCGv_i32 fp1 = tcg_temp_new_i32();
TCGv_i32 fp2 = tcg_temp_new_i32();
gen_load_fpr32(fp0, VAR_4);
gen_load_fpr32(fp1, VAR_5);
gen_load_fpr32(fp2, VAR_3);
gen_helper_float_nmsub_s(fp2, cpu_env, fp0, fp1, fp2);
tcg_temp_free_i32(fp0);
tcg_temp_free_i32(fp1);
gen_store_fpr32(fp2, VAR_2);
tcg_temp_free_i32(fp2);
}
VAR_6 = "nmsub.s";
break;
case OPC_NMSUB_D:
check_cop1x(VAR_0);
check_cp1_registers(VAR_0, VAR_2 | VAR_4 | VAR_5 | VAR_3);
{
TCGv_i64 fp0 = tcg_temp_new_i64();
TCGv_i64 fp1 = tcg_temp_new_i64();
TCGv_i64 fp2 = tcg_temp_new_i64();
gen_load_fpr64(VAR_0, fp0, VAR_4);
gen_load_fpr64(VAR_0, fp1, VAR_5);
gen_load_fpr64(VAR_0, fp2, VAR_3);
gen_helper_float_nmsub_d(fp2, cpu_env, fp0, fp1, fp2);
tcg_temp_free_i64(fp0);
tcg_temp_free_i64(fp1);
gen_store_fpr64(VAR_0, fp2, VAR_2);
tcg_temp_free_i64(fp2);
}
VAR_6 = "nmsub.d";
break;
case OPC_NMSUB_PS:
check_cp1_64bitmode(VAR_0);
{
TCGv_i64 fp0 = tcg_temp_new_i64();
TCGv_i64 fp1 = tcg_temp_new_i64();
TCGv_i64 fp2 = tcg_temp_new_i64();
gen_load_fpr64(VAR_0, fp0, VAR_4);
gen_load_fpr64(VAR_0, fp1, VAR_5);
gen_load_fpr64(VAR_0, fp2, VAR_3);
gen_helper_float_nmsub_ps(fp2, cpu_env, fp0, fp1, fp2);
tcg_temp_free_i64(fp0);
tcg_temp_free_i64(fp1);
gen_store_fpr64(VAR_0, fp2, VAR_2);
tcg_temp_free_i64(fp2);
}
VAR_6 = "nmsub.ps";
break;
default:
MIPS_INVAL(VAR_6);
generate_exception (VAR_0, EXCP_RI);
return;
}
(void)VAR_6;
MIPS_DEBUG("%s %s, %s, %s, %s", VAR_6, fregnames[VAR_2], fregnames[VAR_3],
fregnames[VAR_4], fregnames[VAR_5]);
}
| [
"static void FUNC_0 (DisasContext *VAR_0, uint32_t VAR_1,\nint VAR_2, int VAR_3, int VAR_4, int VAR_5)\n{",
"const char *VAR_6 = \"flt3_arith\";",
"switch (VAR_1) {",
"case OPC_ALNV_PS:\ncheck_cp1_64bitmode(VAR_0);",
"{",
"TCGv t0 = tcg_temp_local_new();",
"TCGv_i32 fp = tcg_temp_new_i32();",
"TCGv_i32 fph = tcg_temp_new_i32();",
"int VAR_7 = gen_new_label();",
"int VAR_8 = gen_new_label();",
"gen_load_gpr(t0, VAR_3);",
"tcg_gen_andi_tl(t0, t0, 0x7);",
"tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0, VAR_7);",
"gen_load_fpr32(fp, VAR_4);",
"gen_load_fpr32h(VAR_0, fph, VAR_4);",
"gen_store_fpr32(fp, VAR_2);",
"gen_store_fpr32h(VAR_0, fph, VAR_2);",
"tcg_gen_br(VAR_8);",
"gen_set_label(VAR_7);",
"tcg_gen_brcondi_tl(TCG_COND_NE, t0, 4, VAR_8);",
"tcg_temp_free(t0);",
"#ifdef TARGET_WORDS_BIGENDIAN\ngen_load_fpr32(fp, VAR_4);",
"gen_load_fpr32h(VAR_0, fph, VAR_5);",
"gen_store_fpr32h(VAR_0, fp, VAR_2);",
"gen_store_fpr32(fph, VAR_2);",
"#else\ngen_load_fpr32h(VAR_0, fph, VAR_4);",
"gen_load_fpr32(fp, VAR_5);",
"gen_store_fpr32(fph, VAR_2);",
"gen_store_fpr32h(VAR_0, fp, VAR_2);",
"#endif\ngen_set_label(VAR_8);",
"tcg_temp_free_i32(fp);",
"tcg_temp_free_i32(fph);",
"}",
"VAR_6 = \"alnv.ps\";",
"break;",
"case OPC_MADD_S:\ncheck_cop1x(VAR_0);",
"{",
"TCGv_i32 fp0 = tcg_temp_new_i32();",
"TCGv_i32 fp1 = tcg_temp_new_i32();",
"TCGv_i32 fp2 = tcg_temp_new_i32();",
"gen_load_fpr32(fp0, VAR_4);",
"gen_load_fpr32(fp1, VAR_5);",
"gen_load_fpr32(fp2, VAR_3);",
"gen_helper_float_madd_s(fp2, cpu_env, fp0, fp1, fp2);",
"tcg_temp_free_i32(fp0);",
"tcg_temp_free_i32(fp1);",
"gen_store_fpr32(fp2, VAR_2);",
"tcg_temp_free_i32(fp2);",
"}",
"VAR_6 = \"madd.s\";",
"break;",
"case OPC_MADD_D:\ncheck_cop1x(VAR_0);",
"check_cp1_registers(VAR_0, VAR_2 | VAR_4 | VAR_5 | VAR_3);",
"{",
"TCGv_i64 fp0 = tcg_temp_new_i64();",
"TCGv_i64 fp1 = tcg_temp_new_i64();",
"TCGv_i64 fp2 = tcg_temp_new_i64();",
"gen_load_fpr64(VAR_0, fp0, VAR_4);",
"gen_load_fpr64(VAR_0, fp1, VAR_5);",
"gen_load_fpr64(VAR_0, fp2, VAR_3);",
"gen_helper_float_madd_d(fp2, cpu_env, fp0, fp1, fp2);",
"tcg_temp_free_i64(fp0);",
"tcg_temp_free_i64(fp1);",
"gen_store_fpr64(VAR_0, fp2, VAR_2);",
"tcg_temp_free_i64(fp2);",
"}",
"VAR_6 = \"madd.d\";",
"break;",
"case OPC_MADD_PS:\ncheck_cp1_64bitmode(VAR_0);",
"{",
"TCGv_i64 fp0 = tcg_temp_new_i64();",
"TCGv_i64 fp1 = tcg_temp_new_i64();",
"TCGv_i64 fp2 = tcg_temp_new_i64();",
"gen_load_fpr64(VAR_0, fp0, VAR_4);",
"gen_load_fpr64(VAR_0, fp1, VAR_5);",
"gen_load_fpr64(VAR_0, fp2, VAR_3);",
"gen_helper_float_madd_ps(fp2, cpu_env, fp0, fp1, fp2);",
"tcg_temp_free_i64(fp0);",
"tcg_temp_free_i64(fp1);",
"gen_store_fpr64(VAR_0, fp2, VAR_2);",
"tcg_temp_free_i64(fp2);",
"}",
"VAR_6 = \"madd.ps\";",
"break;",
"case OPC_MSUB_S:\ncheck_cop1x(VAR_0);",
"{",
"TCGv_i32 fp0 = tcg_temp_new_i32();",
"TCGv_i32 fp1 = tcg_temp_new_i32();",
"TCGv_i32 fp2 = tcg_temp_new_i32();",
"gen_load_fpr32(fp0, VAR_4);",
"gen_load_fpr32(fp1, VAR_5);",
"gen_load_fpr32(fp2, VAR_3);",
"gen_helper_float_msub_s(fp2, cpu_env, fp0, fp1, fp2);",
"tcg_temp_free_i32(fp0);",
"tcg_temp_free_i32(fp1);",
"gen_store_fpr32(fp2, VAR_2);",
"tcg_temp_free_i32(fp2);",
"}",
"VAR_6 = \"msub.s\";",
"break;",
"case OPC_MSUB_D:\ncheck_cop1x(VAR_0);",
"check_cp1_registers(VAR_0, VAR_2 | VAR_4 | VAR_5 | VAR_3);",
"{",
"TCGv_i64 fp0 = tcg_temp_new_i64();",
"TCGv_i64 fp1 = tcg_temp_new_i64();",
"TCGv_i64 fp2 = tcg_temp_new_i64();",
"gen_load_fpr64(VAR_0, fp0, VAR_4);",
"gen_load_fpr64(VAR_0, fp1, VAR_5);",
"gen_load_fpr64(VAR_0, fp2, VAR_3);",
"gen_helper_float_msub_d(fp2, cpu_env, fp0, fp1, fp2);",
"tcg_temp_free_i64(fp0);",
"tcg_temp_free_i64(fp1);",
"gen_store_fpr64(VAR_0, fp2, VAR_2);",
"tcg_temp_free_i64(fp2);",
"}",
"VAR_6 = \"msub.d\";",
"break;",
"case OPC_MSUB_PS:\ncheck_cp1_64bitmode(VAR_0);",
"{",
"TCGv_i64 fp0 = tcg_temp_new_i64();",
"TCGv_i64 fp1 = tcg_temp_new_i64();",
"TCGv_i64 fp2 = tcg_temp_new_i64();",
"gen_load_fpr64(VAR_0, fp0, VAR_4);",
"gen_load_fpr64(VAR_0, fp1, VAR_5);",
"gen_load_fpr64(VAR_0, fp2, VAR_3);",
"gen_helper_float_msub_ps(fp2, cpu_env, fp0, fp1, fp2);",
"tcg_temp_free_i64(fp0);",
"tcg_temp_free_i64(fp1);",
"gen_store_fpr64(VAR_0, fp2, VAR_2);",
"tcg_temp_free_i64(fp2);",
"}",
"VAR_6 = \"msub.ps\";",
"break;",
"case OPC_NMADD_S:\ncheck_cop1x(VAR_0);",
"{",
"TCGv_i32 fp0 = tcg_temp_new_i32();",
"TCGv_i32 fp1 = tcg_temp_new_i32();",
"TCGv_i32 fp2 = tcg_temp_new_i32();",
"gen_load_fpr32(fp0, VAR_4);",
"gen_load_fpr32(fp1, VAR_5);",
"gen_load_fpr32(fp2, VAR_3);",
"gen_helper_float_nmadd_s(fp2, cpu_env, fp0, fp1, fp2);",
"tcg_temp_free_i32(fp0);",
"tcg_temp_free_i32(fp1);",
"gen_store_fpr32(fp2, VAR_2);",
"tcg_temp_free_i32(fp2);",
"}",
"VAR_6 = \"nmadd.s\";",
"break;",
"case OPC_NMADD_D:\ncheck_cop1x(VAR_0);",
"check_cp1_registers(VAR_0, VAR_2 | VAR_4 | VAR_5 | VAR_3);",
"{",
"TCGv_i64 fp0 = tcg_temp_new_i64();",
"TCGv_i64 fp1 = tcg_temp_new_i64();",
"TCGv_i64 fp2 = tcg_temp_new_i64();",
"gen_load_fpr64(VAR_0, fp0, VAR_4);",
"gen_load_fpr64(VAR_0, fp1, VAR_5);",
"gen_load_fpr64(VAR_0, fp2, VAR_3);",
"gen_helper_float_nmadd_d(fp2, cpu_env, fp0, fp1, fp2);",
"tcg_temp_free_i64(fp0);",
"tcg_temp_free_i64(fp1);",
"gen_store_fpr64(VAR_0, fp2, VAR_2);",
"tcg_temp_free_i64(fp2);",
"}",
"VAR_6 = \"nmadd.d\";",
"break;",
"case OPC_NMADD_PS:\ncheck_cp1_64bitmode(VAR_0);",
"{",
"TCGv_i64 fp0 = tcg_temp_new_i64();",
"TCGv_i64 fp1 = tcg_temp_new_i64();",
"TCGv_i64 fp2 = tcg_temp_new_i64();",
"gen_load_fpr64(VAR_0, fp0, VAR_4);",
"gen_load_fpr64(VAR_0, fp1, VAR_5);",
"gen_load_fpr64(VAR_0, fp2, VAR_3);",
"gen_helper_float_nmadd_ps(fp2, cpu_env, fp0, fp1, fp2);",
"tcg_temp_free_i64(fp0);",
"tcg_temp_free_i64(fp1);",
"gen_store_fpr64(VAR_0, fp2, VAR_2);",
"tcg_temp_free_i64(fp2);",
"}",
"VAR_6 = \"nmadd.ps\";",
"break;",
"case OPC_NMSUB_S:\ncheck_cop1x(VAR_0);",
"{",
"TCGv_i32 fp0 = tcg_temp_new_i32();",
"TCGv_i32 fp1 = tcg_temp_new_i32();",
"TCGv_i32 fp2 = tcg_temp_new_i32();",
"gen_load_fpr32(fp0, VAR_4);",
"gen_load_fpr32(fp1, VAR_5);",
"gen_load_fpr32(fp2, VAR_3);",
"gen_helper_float_nmsub_s(fp2, cpu_env, fp0, fp1, fp2);",
"tcg_temp_free_i32(fp0);",
"tcg_temp_free_i32(fp1);",
"gen_store_fpr32(fp2, VAR_2);",
"tcg_temp_free_i32(fp2);",
"}",
"VAR_6 = \"nmsub.s\";",
"break;",
"case OPC_NMSUB_D:\ncheck_cop1x(VAR_0);",
"check_cp1_registers(VAR_0, VAR_2 | VAR_4 | VAR_5 | VAR_3);",
"{",
"TCGv_i64 fp0 = tcg_temp_new_i64();",
"TCGv_i64 fp1 = tcg_temp_new_i64();",
"TCGv_i64 fp2 = tcg_temp_new_i64();",
"gen_load_fpr64(VAR_0, fp0, VAR_4);",
"gen_load_fpr64(VAR_0, fp1, VAR_5);",
"gen_load_fpr64(VAR_0, fp2, VAR_3);",
"gen_helper_float_nmsub_d(fp2, cpu_env, fp0, fp1, fp2);",
"tcg_temp_free_i64(fp0);",
"tcg_temp_free_i64(fp1);",
"gen_store_fpr64(VAR_0, fp2, VAR_2);",
"tcg_temp_free_i64(fp2);",
"}",
"VAR_6 = \"nmsub.d\";",
"break;",
"case OPC_NMSUB_PS:\ncheck_cp1_64bitmode(VAR_0);",
"{",
"TCGv_i64 fp0 = tcg_temp_new_i64();",
"TCGv_i64 fp1 = tcg_temp_new_i64();",
"TCGv_i64 fp2 = tcg_temp_new_i64();",
"gen_load_fpr64(VAR_0, fp0, VAR_4);",
"gen_load_fpr64(VAR_0, fp1, VAR_5);",
"gen_load_fpr64(VAR_0, fp2, VAR_3);",
"gen_helper_float_nmsub_ps(fp2, cpu_env, fp0, fp1, fp2);",
"tcg_temp_free_i64(fp0);",
"tcg_temp_free_i64(fp1);",
"gen_store_fpr64(VAR_0, fp2, VAR_2);",
"tcg_temp_free_i64(fp2);",
"}",
"VAR_6 = \"nmsub.ps\";",
"break;",
"default:\nMIPS_INVAL(VAR_6);",
"generate_exception (VAR_0, EXCP_RI);",
"return;",
"}",
"(void)VAR_6;",
"MIPS_DEBUG(\"%s %s, %s, %s, %s\", VAR_6, fregnames[VAR_2], fregnames[VAR_3],\nfregnames[VAR_4], fregnames[VAR_5]);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13,
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
65,
67
],
[
69
],
[
71
],
[
73
],
[
75,
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89,
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125,
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163,
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199,
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235,
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273,
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
305
],
[
307
],
[
309,
311
],
[
313
],
[
315
],
[
317
],
[
319
],
[
323
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333
],
[
335
],
[
337
],
[
339
],
[
341
],
[
343
],
[
345,
347
],
[
349
],
[
351
],
[
353
],
[
355
],
[
357
],
[
361
],
[
363
],
[
365
],
[
367
],
[
369
],
[
371
],
[
373
],
[
375
],
[
377
],
[
379
],
[
381
],
[
383,
385
],
[
387
],
[
389
],
[
391
],
[
393
],
[
397
],
[
399
],
[
401
],
[
403
],
[
405
],
[
407
],
[
409
],
[
411
],
[
413
],
[
415
],
[
417
],
[
419,
421
],
[
423
],
[
425
],
[
427
],
[
429
],
[
433
],
[
435
],
[
437
],
[
439
],
[
441
],
[
443
],
[
445
],
[
447
],
[
449
],
[
451
],
[
453
],
[
455,
457
],
[
459
],
[
461
],
[
463
],
[
465
],
[
467
],
[
471
],
[
473
],
[
475
],
[
477
],
[
479
],
[
481
],
[
483
],
[
485
],
[
487
],
[
489
],
[
491
],
[
493,
495
],
[
497
],
[
499
],
[
501
],
[
503
],
[
507
],
[
509
],
[
511
],
[
513
],
[
515
],
[
517
],
[
519
],
[
521
],
[
523
],
[
525
],
[
527
],
[
529,
531
],
[
533
],
[
535
],
[
537
],
[
539
],
[
541,
543
],
[
545
]
] |
22,286 | static void pc_compat_2_1(MachineState *machine)
{
PCMachineState *pcms = PC_MACHINE(machine);
pc_compat_2_2(machine);
pcms->enforce_aligned_dimm = false;
smbios_uuid_encoded = false;
x86_cpu_change_kvm_default("svm", NULL);
}
| false | qemu | 7102fa7073b2cefb33ab4012a11f15fbf297a74b | static void pc_compat_2_1(MachineState *machine)
{
PCMachineState *pcms = PC_MACHINE(machine);
pc_compat_2_2(machine);
pcms->enforce_aligned_dimm = false;
smbios_uuid_encoded = false;
x86_cpu_change_kvm_default("svm", NULL);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(MachineState *VAR_0)
{
PCMachineState *pcms = PC_MACHINE(VAR_0);
pc_compat_2_2(VAR_0);
pcms->enforce_aligned_dimm = false;
smbios_uuid_encoded = false;
x86_cpu_change_kvm_default("svm", NULL);
}
| [
"static void FUNC_0(MachineState *VAR_0)\n{",
"PCMachineState *pcms = PC_MACHINE(VAR_0);",
"pc_compat_2_2(VAR_0);",
"pcms->enforce_aligned_dimm = false;",
"smbios_uuid_encoded = false;",
"x86_cpu_change_kvm_default(\"svm\", NULL);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
22,287 | qemu_irq *openpic_init (MemoryRegion **pmem, int nb_cpus,
qemu_irq **irqs, qemu_irq irq_out)
{
openpic_t *opp;
int i, m;
struct {
const char *name;
MemoryRegionOps const *ops;
hwaddr start_addr;
ram_addr_t size;
} const list[] = {
{"glb", &openpic_glb_ops, OPENPIC_GLB_REG_START, OPENPIC_GLB_REG_SIZE},
{"tmr", &openpic_tmr_ops, OPENPIC_TMR_REG_START, OPENPIC_TMR_REG_SIZE},
{"src", &openpic_src_ops, OPENPIC_SRC_REG_START, OPENPIC_SRC_REG_SIZE},
{"cpu", &openpic_cpu_ops, OPENPIC_CPU_REG_START, OPENPIC_CPU_REG_SIZE},
};
/* XXX: for now, only one CPU is supported */
if (nb_cpus != 1)
return NULL;
opp = g_malloc0(sizeof(openpic_t));
memory_region_init(&opp->mem, "openpic", 0x40000);
for (i = 0; i < ARRAY_SIZE(list); i++) {
memory_region_init_io(&opp->sub_io_mem[i], list[i].ops, opp,
list[i].name, list[i].size);
memory_region_add_subregion(&opp->mem, list[i].start_addr,
&opp->sub_io_mem[i]);
}
// isu_base &= 0xFFFC0000;
opp->nb_cpus = nb_cpus;
opp->max_irq = OPENPIC_MAX_IRQ;
opp->irq_ipi0 = OPENPIC_IRQ_IPI0;
opp->irq_tim0 = OPENPIC_IRQ_TIM0;
/* Set IRQ types */
for (i = 0; i < OPENPIC_EXT_IRQ; i++) {
opp->src[i].type = IRQ_EXTERNAL;
}
for (; i < OPENPIC_IRQ_TIM0; i++) {
opp->src[i].type = IRQ_SPECIAL;
}
m = OPENPIC_IRQ_IPI0;
for (; i < m; i++) {
opp->src[i].type = IRQ_TIMER;
}
for (; i < OPENPIC_MAX_IRQ; i++) {
opp->src[i].type = IRQ_INTERNAL;
}
for (i = 0; i < nb_cpus; i++)
opp->dst[i].irqs = irqs[i];
opp->irq_out = irq_out;
register_savevm(&opp->pci_dev.qdev, "openpic", 0, 2,
openpic_save, openpic_load, opp);
qemu_register_reset(openpic_reset, opp);
opp->irq_raise = openpic_irq_raise;
opp->reset = openpic_reset;
if (pmem)
*pmem = &opp->mem;
return qemu_allocate_irqs(openpic_set_irq, opp, opp->max_irq);
}
| false | qemu | 5861a33898bbddfd1a80c2e202cb9352e3b1ba62 | qemu_irq *openpic_init (MemoryRegion **pmem, int nb_cpus,
qemu_irq **irqs, qemu_irq irq_out)
{
openpic_t *opp;
int i, m;
struct {
const char *name;
MemoryRegionOps const *ops;
hwaddr start_addr;
ram_addr_t size;
} const list[] = {
{"glb", &openpic_glb_ops, OPENPIC_GLB_REG_START, OPENPIC_GLB_REG_SIZE},
{"tmr", &openpic_tmr_ops, OPENPIC_TMR_REG_START, OPENPIC_TMR_REG_SIZE},
{"src", &openpic_src_ops, OPENPIC_SRC_REG_START, OPENPIC_SRC_REG_SIZE},
{"cpu", &openpic_cpu_ops, OPENPIC_CPU_REG_START, OPENPIC_CPU_REG_SIZE},
};
if (nb_cpus != 1)
return NULL;
opp = g_malloc0(sizeof(openpic_t));
memory_region_init(&opp->mem, "openpic", 0x40000);
for (i = 0; i < ARRAY_SIZE(list); i++) {
memory_region_init_io(&opp->sub_io_mem[i], list[i].ops, opp,
list[i].name, list[i].size);
memory_region_add_subregion(&opp->mem, list[i].start_addr,
&opp->sub_io_mem[i]);
}
opp->nb_cpus = nb_cpus;
opp->max_irq = OPENPIC_MAX_IRQ;
opp->irq_ipi0 = OPENPIC_IRQ_IPI0;
opp->irq_tim0 = OPENPIC_IRQ_TIM0;
for (i = 0; i < OPENPIC_EXT_IRQ; i++) {
opp->src[i].type = IRQ_EXTERNAL;
}
for (; i < OPENPIC_IRQ_TIM0; i++) {
opp->src[i].type = IRQ_SPECIAL;
}
m = OPENPIC_IRQ_IPI0;
for (; i < m; i++) {
opp->src[i].type = IRQ_TIMER;
}
for (; i < OPENPIC_MAX_IRQ; i++) {
opp->src[i].type = IRQ_INTERNAL;
}
for (i = 0; i < nb_cpus; i++)
opp->dst[i].irqs = irqs[i];
opp->irq_out = irq_out;
register_savevm(&opp->pci_dev.qdev, "openpic", 0, 2,
openpic_save, openpic_load, opp);
qemu_register_reset(openpic_reset, opp);
opp->irq_raise = openpic_irq_raise;
opp->reset = openpic_reset;
if (pmem)
*pmem = &opp->mem;
return qemu_allocate_irqs(openpic_set_irq, opp, opp->max_irq);
}
| {
"code": [],
"line_no": []
} | qemu_irq *FUNC_0 (MemoryRegion **pmem, int nb_cpus,
qemu_irq **irqs, qemu_irq irq_out)
{
openpic_t *opp;
int VAR_0, VAR_1;
struct {
const char *name;
MemoryRegionOps const *ops;
hwaddr start_addr;
ram_addr_t size;
} const VAR_2[] = {
{"glb", &openpic_glb_ops, OPENPIC_GLB_REG_START, OPENPIC_GLB_REG_SIZE},
{"tmr", &openpic_tmr_ops, OPENPIC_TMR_REG_START, OPENPIC_TMR_REG_SIZE},
{"src", &openpic_src_ops, OPENPIC_SRC_REG_START, OPENPIC_SRC_REG_SIZE},
{"cpu", &openpic_cpu_ops, OPENPIC_CPU_REG_START, OPENPIC_CPU_REG_SIZE},
};
if (nb_cpus != 1)
return NULL;
opp = g_malloc0(sizeof(openpic_t));
memory_region_init(&opp->mem, "openpic", 0x40000);
for (VAR_0 = 0; VAR_0 < ARRAY_SIZE(VAR_2); VAR_0++) {
memory_region_init_io(&opp->sub_io_mem[VAR_0], VAR_2[VAR_0].ops, opp,
VAR_2[VAR_0].name, VAR_2[VAR_0].size);
memory_region_add_subregion(&opp->mem, VAR_2[VAR_0].start_addr,
&opp->sub_io_mem[VAR_0]);
}
opp->nb_cpus = nb_cpus;
opp->max_irq = OPENPIC_MAX_IRQ;
opp->irq_ipi0 = OPENPIC_IRQ_IPI0;
opp->irq_tim0 = OPENPIC_IRQ_TIM0;
for (VAR_0 = 0; VAR_0 < OPENPIC_EXT_IRQ; VAR_0++) {
opp->src[VAR_0].type = IRQ_EXTERNAL;
}
for (; VAR_0 < OPENPIC_IRQ_TIM0; VAR_0++) {
opp->src[VAR_0].type = IRQ_SPECIAL;
}
VAR_1 = OPENPIC_IRQ_IPI0;
for (; VAR_0 < VAR_1; VAR_0++) {
opp->src[VAR_0].type = IRQ_TIMER;
}
for (; VAR_0 < OPENPIC_MAX_IRQ; VAR_0++) {
opp->src[VAR_0].type = IRQ_INTERNAL;
}
for (VAR_0 = 0; VAR_0 < nb_cpus; VAR_0++)
opp->dst[VAR_0].irqs = irqs[VAR_0];
opp->irq_out = irq_out;
register_savevm(&opp->pci_dev.qdev, "openpic", 0, 2,
openpic_save, openpic_load, opp);
qemu_register_reset(openpic_reset, opp);
opp->irq_raise = openpic_irq_raise;
opp->reset = openpic_reset;
if (pmem)
*pmem = &opp->mem;
return qemu_allocate_irqs(openpic_set_irq, opp, opp->max_irq);
}
| [
"qemu_irq *FUNC_0 (MemoryRegion **pmem, int nb_cpus,\nqemu_irq **irqs, qemu_irq irq_out)\n{",
"openpic_t *opp;",
"int VAR_0, VAR_1;",
"struct {",
"const char *name;",
"MemoryRegionOps const *ops;",
"hwaddr start_addr;",
"ram_addr_t size;",
"} const VAR_2[] = {",
"{\"glb\", &openpic_glb_ops, OPENPIC_GLB_REG_START, OPENPIC_GLB_REG_SIZE},",
"{\"tmr\", &openpic_tmr_ops, OPENPIC_TMR_REG_START, OPENPIC_TMR_REG_SIZE},",
"{\"src\", &openpic_src_ops, OPENPIC_SRC_REG_START, OPENPIC_SRC_REG_SIZE},",
"{\"cpu\", &openpic_cpu_ops, OPENPIC_CPU_REG_START, OPENPIC_CPU_REG_SIZE},",
"};",
"if (nb_cpus != 1)\nreturn NULL;",
"opp = g_malloc0(sizeof(openpic_t));",
"memory_region_init(&opp->mem, \"openpic\", 0x40000);",
"for (VAR_0 = 0; VAR_0 < ARRAY_SIZE(VAR_2); VAR_0++) {",
"memory_region_init_io(&opp->sub_io_mem[VAR_0], VAR_2[VAR_0].ops, opp,\nVAR_2[VAR_0].name, VAR_2[VAR_0].size);",
"memory_region_add_subregion(&opp->mem, VAR_2[VAR_0].start_addr,\n&opp->sub_io_mem[VAR_0]);",
"}",
"opp->nb_cpus = nb_cpus;",
"opp->max_irq = OPENPIC_MAX_IRQ;",
"opp->irq_ipi0 = OPENPIC_IRQ_IPI0;",
"opp->irq_tim0 = OPENPIC_IRQ_TIM0;",
"for (VAR_0 = 0; VAR_0 < OPENPIC_EXT_IRQ; VAR_0++) {",
"opp->src[VAR_0].type = IRQ_EXTERNAL;",
"}",
"for (; VAR_0 < OPENPIC_IRQ_TIM0; VAR_0++) {",
"opp->src[VAR_0].type = IRQ_SPECIAL;",
"}",
"VAR_1 = OPENPIC_IRQ_IPI0;",
"for (; VAR_0 < VAR_1; VAR_0++) {",
"opp->src[VAR_0].type = IRQ_TIMER;",
"}",
"for (; VAR_0 < OPENPIC_MAX_IRQ; VAR_0++) {",
"opp->src[VAR_0].type = IRQ_INTERNAL;",
"}",
"for (VAR_0 = 0; VAR_0 < nb_cpus; VAR_0++)",
"opp->dst[VAR_0].irqs = irqs[VAR_0];",
"opp->irq_out = irq_out;",
"register_savevm(&opp->pci_dev.qdev, \"openpic\", 0, 2,\nopenpic_save, openpic_load, opp);",
"qemu_register_reset(openpic_reset, opp);",
"opp->irq_raise = openpic_irq_raise;",
"opp->reset = openpic_reset;",
"if (pmem)\n*pmem = &opp->mem;",
"return qemu_allocate_irqs(openpic_set_irq, opp, opp->max_irq);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
37,
39
],
[
41
],
[
45
],
[
49
],
[
53,
55
],
[
59,
61
],
[
63
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
113,
115
],
[
117
],
[
121
],
[
123
],
[
127,
129
],
[
133
],
[
135
]
] |
22,288 | void do_interrupt(CPUARMState *env)
{
uint32_t addr;
uint32_t mask;
int new_mode;
uint32_t offset;
if (IS_M(env)) {
do_interrupt_v7m(env);
return;
}
/* TODO: Vectored interrupt controller. */
switch (env->exception_index) {
case EXCP_UDEF:
new_mode = ARM_CPU_MODE_UND;
addr = 0x04;
mask = CPSR_I;
if (env->thumb)
offset = 2;
else
offset = 4;
break;
case EXCP_SWI:
if (semihosting_enabled) {
/* Check for semihosting interrupt. */
if (env->thumb) {
mask = lduw_code(env->regs[15] - 2) & 0xff;
} else {
mask = ldl_code(env->regs[15] - 4) & 0xffffff;
}
/* Only intercept calls from privileged modes, to provide some
semblance of security. */
if (((mask == 0x123456 && !env->thumb)
|| (mask == 0xab && env->thumb))
&& (env->uncached_cpsr & CPSR_M) != ARM_CPU_MODE_USR) {
env->regs[0] = do_arm_semihosting(env);
return;
}
}
new_mode = ARM_CPU_MODE_SVC;
addr = 0x08;
mask = CPSR_I;
/* The PC already points to the next instruction. */
offset = 0;
break;
case EXCP_BKPT:
/* See if this is a semihosting syscall. */
if (env->thumb && semihosting_enabled) {
mask = lduw_code(env->regs[15]) & 0xff;
if (mask == 0xab
&& (env->uncached_cpsr & CPSR_M) != ARM_CPU_MODE_USR) {
env->regs[15] += 2;
env->regs[0] = do_arm_semihosting(env);
return;
}
}
/* Fall through to prefetch abort. */
case EXCP_PREFETCH_ABORT:
new_mode = ARM_CPU_MODE_ABT;
addr = 0x0c;
mask = CPSR_A | CPSR_I;
offset = 4;
break;
case EXCP_DATA_ABORT:
new_mode = ARM_CPU_MODE_ABT;
addr = 0x10;
mask = CPSR_A | CPSR_I;
offset = 8;
break;
case EXCP_IRQ:
new_mode = ARM_CPU_MODE_IRQ;
addr = 0x18;
/* Disable IRQ and imprecise data aborts. */
mask = CPSR_A | CPSR_I;
offset = 4;
break;
case EXCP_FIQ:
new_mode = ARM_CPU_MODE_FIQ;
addr = 0x1c;
/* Disable FIQ, IRQ and imprecise data aborts. */
mask = CPSR_A | CPSR_I | CPSR_F;
offset = 4;
break;
default:
cpu_abort(env, "Unhandled exception 0x%x\n", env->exception_index);
return; /* Never happens. Keep compiler happy. */
}
/* High vectors. */
if (env->cp15.c1_sys & (1 << 13)) {
addr += 0xffff0000;
}
switch_mode (env, new_mode);
env->spsr = cpsr_read(env);
/* Clear IT bits. */
env->condexec_bits = 0;
/* Switch to the new mode, and to the correct instruction set. */
env->uncached_cpsr = (env->uncached_cpsr & ~CPSR_M) | new_mode;
env->uncached_cpsr |= mask;
env->thumb = (env->cp15.c1_sys & (1 << 30)) != 0;
env->regs[14] = env->regs[15] + offset;
env->regs[15] = addr;
env->interrupt_request |= CPU_INTERRUPT_EXITTB;
}
| false | qemu | be5e7a76010bd14d09f74504ed6368782e701888 | void do_interrupt(CPUARMState *env)
{
uint32_t addr;
uint32_t mask;
int new_mode;
uint32_t offset;
if (IS_M(env)) {
do_interrupt_v7m(env);
return;
}
switch (env->exception_index) {
case EXCP_UDEF:
new_mode = ARM_CPU_MODE_UND;
addr = 0x04;
mask = CPSR_I;
if (env->thumb)
offset = 2;
else
offset = 4;
break;
case EXCP_SWI:
if (semihosting_enabled) {
if (env->thumb) {
mask = lduw_code(env->regs[15] - 2) & 0xff;
} else {
mask = ldl_code(env->regs[15] - 4) & 0xffffff;
}
if (((mask == 0x123456 && !env->thumb)
|| (mask == 0xab && env->thumb))
&& (env->uncached_cpsr & CPSR_M) != ARM_CPU_MODE_USR) {
env->regs[0] = do_arm_semihosting(env);
return;
}
}
new_mode = ARM_CPU_MODE_SVC;
addr = 0x08;
mask = CPSR_I;
offset = 0;
break;
case EXCP_BKPT:
if (env->thumb && semihosting_enabled) {
mask = lduw_code(env->regs[15]) & 0xff;
if (mask == 0xab
&& (env->uncached_cpsr & CPSR_M) != ARM_CPU_MODE_USR) {
env->regs[15] += 2;
env->regs[0] = do_arm_semihosting(env);
return;
}
}
case EXCP_PREFETCH_ABORT:
new_mode = ARM_CPU_MODE_ABT;
addr = 0x0c;
mask = CPSR_A | CPSR_I;
offset = 4;
break;
case EXCP_DATA_ABORT:
new_mode = ARM_CPU_MODE_ABT;
addr = 0x10;
mask = CPSR_A | CPSR_I;
offset = 8;
break;
case EXCP_IRQ:
new_mode = ARM_CPU_MODE_IRQ;
addr = 0x18;
mask = CPSR_A | CPSR_I;
offset = 4;
break;
case EXCP_FIQ:
new_mode = ARM_CPU_MODE_FIQ;
addr = 0x1c;
mask = CPSR_A | CPSR_I | CPSR_F;
offset = 4;
break;
default:
cpu_abort(env, "Unhandled exception 0x%x\n", env->exception_index);
return;
}
if (env->cp15.c1_sys & (1 << 13)) {
addr += 0xffff0000;
}
switch_mode (env, new_mode);
env->spsr = cpsr_read(env);
env->condexec_bits = 0;
env->uncached_cpsr = (env->uncached_cpsr & ~CPSR_M) | new_mode;
env->uncached_cpsr |= mask;
env->thumb = (env->cp15.c1_sys & (1 << 30)) != 0;
env->regs[14] = env->regs[15] + offset;
env->regs[15] = addr;
env->interrupt_request |= CPU_INTERRUPT_EXITTB;
}
| {
"code": [],
"line_no": []
} | void FUNC_0(CPUARMState *VAR_0)
{
uint32_t addr;
uint32_t mask;
int VAR_1;
uint32_t offset;
if (IS_M(VAR_0)) {
do_interrupt_v7m(VAR_0);
return;
}
switch (VAR_0->exception_index) {
case EXCP_UDEF:
VAR_1 = ARM_CPU_MODE_UND;
addr = 0x04;
mask = CPSR_I;
if (VAR_0->thumb)
offset = 2;
else
offset = 4;
break;
case EXCP_SWI:
if (semihosting_enabled) {
if (VAR_0->thumb) {
mask = lduw_code(VAR_0->regs[15] - 2) & 0xff;
} else {
mask = ldl_code(VAR_0->regs[15] - 4) & 0xffffff;
}
if (((mask == 0x123456 && !VAR_0->thumb)
|| (mask == 0xab && VAR_0->thumb))
&& (VAR_0->uncached_cpsr & CPSR_M) != ARM_CPU_MODE_USR) {
VAR_0->regs[0] = do_arm_semihosting(VAR_0);
return;
}
}
VAR_1 = ARM_CPU_MODE_SVC;
addr = 0x08;
mask = CPSR_I;
offset = 0;
break;
case EXCP_BKPT:
if (VAR_0->thumb && semihosting_enabled) {
mask = lduw_code(VAR_0->regs[15]) & 0xff;
if (mask == 0xab
&& (VAR_0->uncached_cpsr & CPSR_M) != ARM_CPU_MODE_USR) {
VAR_0->regs[15] += 2;
VAR_0->regs[0] = do_arm_semihosting(VAR_0);
return;
}
}
case EXCP_PREFETCH_ABORT:
VAR_1 = ARM_CPU_MODE_ABT;
addr = 0x0c;
mask = CPSR_A | CPSR_I;
offset = 4;
break;
case EXCP_DATA_ABORT:
VAR_1 = ARM_CPU_MODE_ABT;
addr = 0x10;
mask = CPSR_A | CPSR_I;
offset = 8;
break;
case EXCP_IRQ:
VAR_1 = ARM_CPU_MODE_IRQ;
addr = 0x18;
mask = CPSR_A | CPSR_I;
offset = 4;
break;
case EXCP_FIQ:
VAR_1 = ARM_CPU_MODE_FIQ;
addr = 0x1c;
mask = CPSR_A | CPSR_I | CPSR_F;
offset = 4;
break;
default:
cpu_abort(VAR_0, "Unhandled exception 0x%x\n", VAR_0->exception_index);
return;
}
if (VAR_0->cp15.c1_sys & (1 << 13)) {
addr += 0xffff0000;
}
switch_mode (VAR_0, VAR_1);
VAR_0->spsr = cpsr_read(VAR_0);
VAR_0->condexec_bits = 0;
VAR_0->uncached_cpsr = (VAR_0->uncached_cpsr & ~CPSR_M) | VAR_1;
VAR_0->uncached_cpsr |= mask;
VAR_0->thumb = (VAR_0->cp15.c1_sys & (1 << 30)) != 0;
VAR_0->regs[14] = VAR_0->regs[15] + offset;
VAR_0->regs[15] = addr;
VAR_0->interrupt_request |= CPU_INTERRUPT_EXITTB;
}
| [
"void FUNC_0(CPUARMState *VAR_0)\n{",
"uint32_t addr;",
"uint32_t mask;",
"int VAR_1;",
"uint32_t offset;",
"if (IS_M(VAR_0)) {",
"do_interrupt_v7m(VAR_0);",
"return;",
"}",
"switch (VAR_0->exception_index) {",
"case EXCP_UDEF:\nVAR_1 = ARM_CPU_MODE_UND;",
"addr = 0x04;",
"mask = CPSR_I;",
"if (VAR_0->thumb)\noffset = 2;",
"else\noffset = 4;",
"break;",
"case EXCP_SWI:\nif (semihosting_enabled) {",
"if (VAR_0->thumb) {",
"mask = lduw_code(VAR_0->regs[15] - 2) & 0xff;",
"} else {",
"mask = ldl_code(VAR_0->regs[15] - 4) & 0xffffff;",
"}",
"if (((mask == 0x123456 && !VAR_0->thumb)\n|| (mask == 0xab && VAR_0->thumb))\n&& (VAR_0->uncached_cpsr & CPSR_M) != ARM_CPU_MODE_USR) {",
"VAR_0->regs[0] = do_arm_semihosting(VAR_0);",
"return;",
"}",
"}",
"VAR_1 = ARM_CPU_MODE_SVC;",
"addr = 0x08;",
"mask = CPSR_I;",
"offset = 0;",
"break;",
"case EXCP_BKPT:\nif (VAR_0->thumb && semihosting_enabled) {",
"mask = lduw_code(VAR_0->regs[15]) & 0xff;",
"if (mask == 0xab\n&& (VAR_0->uncached_cpsr & CPSR_M) != ARM_CPU_MODE_USR) {",
"VAR_0->regs[15] += 2;",
"VAR_0->regs[0] = do_arm_semihosting(VAR_0);",
"return;",
"}",
"}",
"case EXCP_PREFETCH_ABORT:\nVAR_1 = ARM_CPU_MODE_ABT;",
"addr = 0x0c;",
"mask = CPSR_A | CPSR_I;",
"offset = 4;",
"break;",
"case EXCP_DATA_ABORT:\nVAR_1 = ARM_CPU_MODE_ABT;",
"addr = 0x10;",
"mask = CPSR_A | CPSR_I;",
"offset = 8;",
"break;",
"case EXCP_IRQ:\nVAR_1 = ARM_CPU_MODE_IRQ;",
"addr = 0x18;",
"mask = CPSR_A | CPSR_I;",
"offset = 4;",
"break;",
"case EXCP_FIQ:\nVAR_1 = ARM_CPU_MODE_FIQ;",
"addr = 0x1c;",
"mask = CPSR_A | CPSR_I | CPSR_F;",
"offset = 4;",
"break;",
"default:\ncpu_abort(VAR_0, \"Unhandled exception 0x%x\\n\", VAR_0->exception_index);",
"return;",
"}",
"if (VAR_0->cp15.c1_sys & (1 << 13)) {",
"addr += 0xffff0000;",
"}",
"switch_mode (VAR_0, VAR_1);",
"VAR_0->spsr = cpsr_read(VAR_0);",
"VAR_0->condexec_bits = 0;",
"VAR_0->uncached_cpsr = (VAR_0->uncached_cpsr & ~CPSR_M) | VAR_1;",
"VAR_0->uncached_cpsr |= mask;",
"VAR_0->thumb = (VAR_0->cp15.c1_sys & (1 << 30)) != 0;",
"VAR_0->regs[14] = VAR_0->regs[15] + offset;",
"VAR_0->regs[15] = addr;",
"VAR_0->interrupt_request |= CPU_INTERRUPT_EXITTB;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27,
29
],
[
31
],
[
33
],
[
35,
37
],
[
39,
41
],
[
43
],
[
45,
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
65,
67,
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89
],
[
91,
95
],
[
97
],
[
99,
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
115,
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127,
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139,
141
],
[
143
],
[
147
],
[
149
],
[
151
],
[
153,
155
],
[
157
],
[
161
],
[
163
],
[
165
],
[
167,
169
],
[
171
],
[
173
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
189
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
]
] |
22,289 | int stpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba, uint8_t ar)
{
CPUS390XState *env = &cpu->env;
uint32_t fh;
ZpciFib fib;
S390PCIBusDevice *pbdev;
uint32_t data;
uint64_t cc = ZPCI_PCI_LS_OK;
if (env->psw.mask & PSW_MASK_PSTATE) {
program_interrupt(env, PGM_PRIVILEGED, 6);
return 0;
}
fh = env->regs[r1] >> 32;
if (fiba & 0x7) {
program_interrupt(env, PGM_SPECIFICATION, 6);
return 0;
}
pbdev = s390_pci_find_dev_by_fh(fh);
if (!pbdev) {
setcc(cpu, ZPCI_PCI_LS_INVAL_HANDLE);
return 0;
}
memset(&fib, 0, sizeof(fib));
stq_p(&fib.pba, pbdev->pba);
stq_p(&fib.pal, pbdev->pal);
stq_p(&fib.iota, pbdev->g_iota);
stq_p(&fib.aibv, pbdev->routes.adapter.ind_addr);
stq_p(&fib.aisb, pbdev->routes.adapter.summary_addr);
stq_p(&fib.fmb_addr, pbdev->fmb_addr);
data = ((uint32_t)pbdev->isc << 28) | ((uint32_t)pbdev->noi << 16) |
((uint32_t)pbdev->routes.adapter.ind_offset << 8) |
((uint32_t)pbdev->sum << 7) | pbdev->routes.adapter.summary_offset;
stl_p(&fib.data, data);
if (pbdev->fh & FH_MASK_ENABLE) {
fib.fc |= 0x80;
}
if (pbdev->error_state) {
fib.fc |= 0x40;
}
if (pbdev->lgstg_blocked) {
fib.fc |= 0x20;
}
if (pbdev->g_iota) {
fib.fc |= 0x10;
}
if (s390_cpu_virt_mem_write(cpu, fiba, ar, (uint8_t *)&fib, sizeof(fib))) {
return 0;
}
setcc(cpu, cc);
return 0;
}
| false | qemu | 5d1abf234462d13bef3617cc2c55b6815703ddf2 | int stpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba, uint8_t ar)
{
CPUS390XState *env = &cpu->env;
uint32_t fh;
ZpciFib fib;
S390PCIBusDevice *pbdev;
uint32_t data;
uint64_t cc = ZPCI_PCI_LS_OK;
if (env->psw.mask & PSW_MASK_PSTATE) {
program_interrupt(env, PGM_PRIVILEGED, 6);
return 0;
}
fh = env->regs[r1] >> 32;
if (fiba & 0x7) {
program_interrupt(env, PGM_SPECIFICATION, 6);
return 0;
}
pbdev = s390_pci_find_dev_by_fh(fh);
if (!pbdev) {
setcc(cpu, ZPCI_PCI_LS_INVAL_HANDLE);
return 0;
}
memset(&fib, 0, sizeof(fib));
stq_p(&fib.pba, pbdev->pba);
stq_p(&fib.pal, pbdev->pal);
stq_p(&fib.iota, pbdev->g_iota);
stq_p(&fib.aibv, pbdev->routes.adapter.ind_addr);
stq_p(&fib.aisb, pbdev->routes.adapter.summary_addr);
stq_p(&fib.fmb_addr, pbdev->fmb_addr);
data = ((uint32_t)pbdev->isc << 28) | ((uint32_t)pbdev->noi << 16) |
((uint32_t)pbdev->routes.adapter.ind_offset << 8) |
((uint32_t)pbdev->sum << 7) | pbdev->routes.adapter.summary_offset;
stl_p(&fib.data, data);
if (pbdev->fh & FH_MASK_ENABLE) {
fib.fc |= 0x80;
}
if (pbdev->error_state) {
fib.fc |= 0x40;
}
if (pbdev->lgstg_blocked) {
fib.fc |= 0x20;
}
if (pbdev->g_iota) {
fib.fc |= 0x10;
}
if (s390_cpu_virt_mem_write(cpu, fiba, ar, (uint8_t *)&fib, sizeof(fib))) {
return 0;
}
setcc(cpu, cc);
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(S390CPU *VAR_0, uint8_t VAR_1, uint64_t VAR_2, uint8_t VAR_3)
{
CPUS390XState *env = &VAR_0->env;
uint32_t fh;
ZpciFib fib;
S390PCIBusDevice *pbdev;
uint32_t data;
uint64_t cc = ZPCI_PCI_LS_OK;
if (env->psw.mask & PSW_MASK_PSTATE) {
program_interrupt(env, PGM_PRIVILEGED, 6);
return 0;
}
fh = env->regs[VAR_1] >> 32;
if (VAR_2 & 0x7) {
program_interrupt(env, PGM_SPECIFICATION, 6);
return 0;
}
pbdev = s390_pci_find_dev_by_fh(fh);
if (!pbdev) {
setcc(VAR_0, ZPCI_PCI_LS_INVAL_HANDLE);
return 0;
}
memset(&fib, 0, sizeof(fib));
stq_p(&fib.pba, pbdev->pba);
stq_p(&fib.pal, pbdev->pal);
stq_p(&fib.iota, pbdev->g_iota);
stq_p(&fib.aibv, pbdev->routes.adapter.ind_addr);
stq_p(&fib.aisb, pbdev->routes.adapter.summary_addr);
stq_p(&fib.fmb_addr, pbdev->fmb_addr);
data = ((uint32_t)pbdev->isc << 28) | ((uint32_t)pbdev->noi << 16) |
((uint32_t)pbdev->routes.adapter.ind_offset << 8) |
((uint32_t)pbdev->sum << 7) | pbdev->routes.adapter.summary_offset;
stl_p(&fib.data, data);
if (pbdev->fh & FH_MASK_ENABLE) {
fib.fc |= 0x80;
}
if (pbdev->error_state) {
fib.fc |= 0x40;
}
if (pbdev->lgstg_blocked) {
fib.fc |= 0x20;
}
if (pbdev->g_iota) {
fib.fc |= 0x10;
}
if (s390_cpu_virt_mem_write(VAR_0, VAR_2, VAR_3, (uint8_t *)&fib, sizeof(fib))) {
return 0;
}
setcc(VAR_0, cc);
return 0;
}
| [
"int FUNC_0(S390CPU *VAR_0, uint8_t VAR_1, uint64_t VAR_2, uint8_t VAR_3)\n{",
"CPUS390XState *env = &VAR_0->env;",
"uint32_t fh;",
"ZpciFib fib;",
"S390PCIBusDevice *pbdev;",
"uint32_t data;",
"uint64_t cc = ZPCI_PCI_LS_OK;",
"if (env->psw.mask & PSW_MASK_PSTATE) {",
"program_interrupt(env, PGM_PRIVILEGED, 6);",
"return 0;",
"}",
"fh = env->regs[VAR_1] >> 32;",
"if (VAR_2 & 0x7) {",
"program_interrupt(env, PGM_SPECIFICATION, 6);",
"return 0;",
"}",
"pbdev = s390_pci_find_dev_by_fh(fh);",
"if (!pbdev) {",
"setcc(VAR_0, ZPCI_PCI_LS_INVAL_HANDLE);",
"return 0;",
"}",
"memset(&fib, 0, sizeof(fib));",
"stq_p(&fib.pba, pbdev->pba);",
"stq_p(&fib.pal, pbdev->pal);",
"stq_p(&fib.iota, pbdev->g_iota);",
"stq_p(&fib.aibv, pbdev->routes.adapter.ind_addr);",
"stq_p(&fib.aisb, pbdev->routes.adapter.summary_addr);",
"stq_p(&fib.fmb_addr, pbdev->fmb_addr);",
"data = ((uint32_t)pbdev->isc << 28) | ((uint32_t)pbdev->noi << 16) |\n((uint32_t)pbdev->routes.adapter.ind_offset << 8) |\n((uint32_t)pbdev->sum << 7) | pbdev->routes.adapter.summary_offset;",
"stl_p(&fib.data, data);",
"if (pbdev->fh & FH_MASK_ENABLE) {",
"fib.fc |= 0x80;",
"}",
"if (pbdev->error_state) {",
"fib.fc |= 0x40;",
"}",
"if (pbdev->lgstg_blocked) {",
"fib.fc |= 0x20;",
"}",
"if (pbdev->g_iota) {",
"fib.fc |= 0x10;",
"}",
"if (s390_cpu_virt_mem_write(VAR_0, VAR_2, VAR_3, (uint8_t *)&fib, sizeof(fib))) {",
"return 0;",
"}",
"setcc(VAR_0, cc);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71,
73,
75
],
[
77
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91
],
[
93
],
[
97
],
[
99
],
[
101
],
[
105
],
[
107
],
[
109
],
[
113
],
[
115
],
[
117
],
[
121
],
[
123
],
[
125
]
] |
22,290 | static void mv88w8618_wlan_write(void *opaque, target_phys_addr_t offset,
uint64_t value, unsigned size)
{
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static void mv88w8618_wlan_write(void *opaque, target_phys_addr_t offset,
uint64_t value, unsigned size)
{
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,
uint64_t VAR_2, unsigned VAR_3)
{
}
| [
"static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{",
"}"
] | [
0,
0
] | [
[
1,
3,
5
],
[
7
]
] |
22,292 | START_TEST(qint_from_int_test)
{
QInt *qi;
const int value = -42;
qi = qint_from_int(value);
fail_unless(qi != NULL);
fail_unless(qi->value == value);
fail_unless(qi->base.refcnt == 1);
fail_unless(qobject_type(QOBJECT(qi)) == QTYPE_QINT);
// destroy doesn't exit yet
g_free(qi);
}
| false | qemu | 65cdadd2e2de76f7db3bf6b7d8dd8c67abff9659 | START_TEST(qint_from_int_test)
{
QInt *qi;
const int value = -42;
qi = qint_from_int(value);
fail_unless(qi != NULL);
fail_unless(qi->value == value);
fail_unless(qi->base.refcnt == 1);
fail_unless(qobject_type(QOBJECT(qi)) == QTYPE_QINT);
g_free(qi);
}
| {
"code": [],
"line_no": []
} | FUNC_0(VAR_0)
{
QInt *qi;
const int VAR_1 = -42;
qi = qint_from_int(VAR_1);
fail_unless(qi != NULL);
fail_unless(qi->VAR_1 == VAR_1);
fail_unless(qi->base.refcnt == 1);
fail_unless(qobject_type(QOBJECT(qi)) == QTYPE_QINT);
g_free(qi);
}
| [
"FUNC_0(VAR_0)\n{",
"QInt *qi;",
"const int VAR_1 = -42;",
"qi = qint_from_int(VAR_1);",
"fail_unless(qi != NULL);",
"fail_unless(qi->VAR_1 == VAR_1);",
"fail_unless(qi->base.refcnt == 1);",
"fail_unless(qobject_type(QOBJECT(qi)) == QTYPE_QINT);",
"g_free(qi);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
25
],
[
27
]
] |
22,293 | static int kvm_s390_store_adtl_status(S390CPU *cpu, hwaddr addr)
{
void *mem;
hwaddr len = ADTL_SAVE_AREA_SIZE;
mem = cpu_physical_memory_map(addr, &len, 1);
if (!mem) {
return -EFAULT;
}
if (len != ADTL_SAVE_AREA_SIZE) {
cpu_physical_memory_unmap(mem, len, 1, 0);
return -EFAULT;
}
memcpy(mem, &cpu->env.vregs, 512);
cpu_physical_memory_unmap(mem, len, 1, len);
return 0;
}
| false | qemu | 62deb62d999cf9e2be61272c6b720104f764bd6a | static int kvm_s390_store_adtl_status(S390CPU *cpu, hwaddr addr)
{
void *mem;
hwaddr len = ADTL_SAVE_AREA_SIZE;
mem = cpu_physical_memory_map(addr, &len, 1);
if (!mem) {
return -EFAULT;
}
if (len != ADTL_SAVE_AREA_SIZE) {
cpu_physical_memory_unmap(mem, len, 1, 0);
return -EFAULT;
}
memcpy(mem, &cpu->env.vregs, 512);
cpu_physical_memory_unmap(mem, len, 1, len);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(S390CPU *VAR_0, hwaddr VAR_1)
{
void *VAR_2;
hwaddr len = ADTL_SAVE_AREA_SIZE;
VAR_2 = cpu_physical_memory_map(VAR_1, &len, 1);
if (!VAR_2) {
return -EFAULT;
}
if (len != ADTL_SAVE_AREA_SIZE) {
cpu_physical_memory_unmap(VAR_2, len, 1, 0);
return -EFAULT;
}
memcpy(VAR_2, &VAR_0->env.vregs, 512);
cpu_physical_memory_unmap(VAR_2, len, 1, len);
return 0;
}
| [
"static int FUNC_0(S390CPU *VAR_0, hwaddr VAR_1)\n{",
"void *VAR_2;",
"hwaddr len = ADTL_SAVE_AREA_SIZE;",
"VAR_2 = cpu_physical_memory_map(VAR_1, &len, 1);",
"if (!VAR_2) {",
"return -EFAULT;",
"}",
"if (len != ADTL_SAVE_AREA_SIZE) {",
"cpu_physical_memory_unmap(VAR_2, len, 1, 0);",
"return -EFAULT;",
"}",
"memcpy(VAR_2, &VAR_0->env.vregs, 512);",
"cpu_physical_memory_unmap(VAR_2, len, 1, len);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
33
],
[
37
],
[
39
]
] |
22,294 | int page_unprotect(target_ulong address, unsigned long pc, void *puc)
{
unsigned int page_index, prot, pindex;
PageDesc *p, *p1;
target_ulong host_start, host_end, addr;
/* Technically this isn't safe inside a signal handler. However we
know this only ever happens in a synchronous SEGV handler, so in
practice it seems to be ok. */
mmap_lock();
host_start = address & qemu_host_page_mask;
page_index = host_start >> TARGET_PAGE_BITS;
p1 = page_find(page_index);
if (!p1) {
mmap_unlock();
return 0;
}
host_end = host_start + qemu_host_page_size;
p = p1;
prot = 0;
for(addr = host_start;addr < host_end; addr += TARGET_PAGE_SIZE) {
prot |= p->flags;
p++;
}
/* if the page was really writable, then we change its
protection back to writable */
if (prot & PAGE_WRITE_ORG) {
pindex = (address - host_start) >> TARGET_PAGE_BITS;
if (!(p1[pindex].flags & PAGE_WRITE)) {
mprotect((void *)g2h(host_start), qemu_host_page_size,
(prot & PAGE_BITS) | PAGE_WRITE);
p1[pindex].flags |= PAGE_WRITE;
/* and since the content will be modified, we must invalidate
the corresponding translated code. */
tb_invalidate_phys_page(address, pc, puc);
#ifdef DEBUG_TB_CHECK
tb_invalidate_check(address);
#endif
mmap_unlock();
return 1;
}
}
mmap_unlock();
return 0;
}
| false | qemu | 45d679d64350c44df93d918ddacd6ae0c6da9dbb | int page_unprotect(target_ulong address, unsigned long pc, void *puc)
{
unsigned int page_index, prot, pindex;
PageDesc *p, *p1;
target_ulong host_start, host_end, addr;
mmap_lock();
host_start = address & qemu_host_page_mask;
page_index = host_start >> TARGET_PAGE_BITS;
p1 = page_find(page_index);
if (!p1) {
mmap_unlock();
return 0;
}
host_end = host_start + qemu_host_page_size;
p = p1;
prot = 0;
for(addr = host_start;addr < host_end; addr += TARGET_PAGE_SIZE) {
prot |= p->flags;
p++;
}
if (prot & PAGE_WRITE_ORG) {
pindex = (address - host_start) >> TARGET_PAGE_BITS;
if (!(p1[pindex].flags & PAGE_WRITE)) {
mprotect((void *)g2h(host_start), qemu_host_page_size,
(prot & PAGE_BITS) | PAGE_WRITE);
p1[pindex].flags |= PAGE_WRITE;
tb_invalidate_phys_page(address, pc, puc);
#ifdef DEBUG_TB_CHECK
tb_invalidate_check(address);
#endif
mmap_unlock();
return 1;
}
}
mmap_unlock();
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(target_ulong VAR_0, unsigned long VAR_1, void *VAR_2)
{
unsigned int VAR_3, VAR_4, VAR_5;
PageDesc *p, *p1;
target_ulong host_start, host_end, addr;
mmap_lock();
host_start = VAR_0 & qemu_host_page_mask;
VAR_3 = host_start >> TARGET_PAGE_BITS;
p1 = page_find(VAR_3);
if (!p1) {
mmap_unlock();
return 0;
}
host_end = host_start + qemu_host_page_size;
p = p1;
VAR_4 = 0;
for(addr = host_start;addr < host_end; addr += TARGET_PAGE_SIZE) {
VAR_4 |= p->flags;
p++;
}
if (VAR_4 & PAGE_WRITE_ORG) {
VAR_5 = (VAR_0 - host_start) >> TARGET_PAGE_BITS;
if (!(p1[VAR_5].flags & PAGE_WRITE)) {
mprotect((void *)g2h(host_start), qemu_host_page_size,
(VAR_4 & PAGE_BITS) | PAGE_WRITE);
p1[VAR_5].flags |= PAGE_WRITE;
tb_invalidate_phys_page(VAR_0, VAR_1, VAR_2);
#ifdef DEBUG_TB_CHECK
tb_invalidate_check(VAR_0);
#endif
mmap_unlock();
return 1;
}
}
mmap_unlock();
return 0;
}
| [
"int FUNC_0(target_ulong VAR_0, unsigned long VAR_1, void *VAR_2)\n{",
"unsigned int VAR_3, VAR_4, VAR_5;",
"PageDesc *p, *p1;",
"target_ulong host_start, host_end, addr;",
"mmap_lock();",
"host_start = VAR_0 & qemu_host_page_mask;",
"VAR_3 = host_start >> TARGET_PAGE_BITS;",
"p1 = page_find(VAR_3);",
"if (!p1) {",
"mmap_unlock();",
"return 0;",
"}",
"host_end = host_start + qemu_host_page_size;",
"p = p1;",
"VAR_4 = 0;",
"for(addr = host_start;addr < host_end; addr += TARGET_PAGE_SIZE) {",
"VAR_4 |= p->flags;",
"p++;",
"}",
"if (VAR_4 & PAGE_WRITE_ORG) {",
"VAR_5 = (VAR_0 - host_start) >> TARGET_PAGE_BITS;",
"if (!(p1[VAR_5].flags & PAGE_WRITE)) {",
"mprotect((void *)g2h(host_start), qemu_host_page_size,\n(VAR_4 & PAGE_BITS) | PAGE_WRITE);",
"p1[VAR_5].flags |= PAGE_WRITE;",
"tb_invalidate_phys_page(VAR_0, VAR_1, VAR_2);",
"#ifdef DEBUG_TB_CHECK\ntb_invalidate_check(VAR_0);",
"#endif\nmmap_unlock();",
"return 1;",
"}",
"}",
"mmap_unlock();",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
55
],
[
57
],
[
59
],
[
61,
63
],
[
65
],
[
71
],
[
73,
75
],
[
77,
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
]
] |
22,295 | static int mov_read_enda(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
{
AVStream *st = c->fc->streams[c->fc->nb_streams-1];
int little_endian = get_be16(pb);
dprintf(c->fc, "enda %d\n", little_endian);
if (little_endian == 1) {
switch (st->codec->codec_id) {
case CODEC_ID_PCM_S24BE:
st->codec->codec_id = CODEC_ID_PCM_S24LE;
break;
case CODEC_ID_PCM_S32BE:
st->codec->codec_id = CODEC_ID_PCM_S32LE;
break;
case CODEC_ID_PCM_F32BE:
st->codec->codec_id = CODEC_ID_PCM_F32LE;
break;
case CODEC_ID_PCM_F64BE:
st->codec->codec_id = CODEC_ID_PCM_F64LE;
break;
default:
break;
}
}
return 0;
}
| false | FFmpeg | 6a63ff19b6a7fe3bc32c7fb4a62fca8f65786432 | static int mov_read_enda(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
{
AVStream *st = c->fc->streams[c->fc->nb_streams-1];
int little_endian = get_be16(pb);
dprintf(c->fc, "enda %d\n", little_endian);
if (little_endian == 1) {
switch (st->codec->codec_id) {
case CODEC_ID_PCM_S24BE:
st->codec->codec_id = CODEC_ID_PCM_S24LE;
break;
case CODEC_ID_PCM_S32BE:
st->codec->codec_id = CODEC_ID_PCM_S32LE;
break;
case CODEC_ID_PCM_F32BE:
st->codec->codec_id = CODEC_ID_PCM_F32LE;
break;
case CODEC_ID_PCM_F64BE:
st->codec->codec_id = CODEC_ID_PCM_F64LE;
break;
default:
break;
}
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(MOVContext *VAR_0, ByteIOContext *VAR_1, MOVAtom VAR_2)
{
AVStream *st = VAR_0->fc->streams[VAR_0->fc->nb_streams-1];
int VAR_3 = get_be16(VAR_1);
dprintf(VAR_0->fc, "enda %d\n", VAR_3);
if (VAR_3 == 1) {
switch (st->codec->codec_id) {
case CODEC_ID_PCM_S24BE:
st->codec->codec_id = CODEC_ID_PCM_S24LE;
break;
case CODEC_ID_PCM_S32BE:
st->codec->codec_id = CODEC_ID_PCM_S32LE;
break;
case CODEC_ID_PCM_F32BE:
st->codec->codec_id = CODEC_ID_PCM_F32LE;
break;
case CODEC_ID_PCM_F64BE:
st->codec->codec_id = CODEC_ID_PCM_F64LE;
break;
default:
break;
}
}
return 0;
}
| [
"static int FUNC_0(MOVContext *VAR_0, ByteIOContext *VAR_1, MOVAtom VAR_2)\n{",
"AVStream *st = VAR_0->fc->streams[VAR_0->fc->nb_streams-1];",
"int VAR_3 = get_be16(VAR_1);",
"dprintf(VAR_0->fc, \"enda %d\\n\", VAR_3);",
"if (VAR_3 == 1) {",
"switch (st->codec->codec_id) {",
"case CODEC_ID_PCM_S24BE:\nst->codec->codec_id = CODEC_ID_PCM_S24LE;",
"break;",
"case CODEC_ID_PCM_S32BE:\nst->codec->codec_id = CODEC_ID_PCM_S32LE;",
"break;",
"case CODEC_ID_PCM_F32BE:\nst->codec->codec_id = CODEC_ID_PCM_F32LE;",
"break;",
"case CODEC_ID_PCM_F64BE:\nst->codec->codec_id = CODEC_ID_PCM_F64LE;",
"break;",
"default:\nbreak;",
"}",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17,
19
],
[
21
],
[
23,
25
],
[
27
],
[
29,
31
],
[
33
],
[
35,
37
],
[
39
],
[
41,
43
],
[
45
],
[
47
],
[
49
],
[
51
]
] |
22,296 | static inline int decode_scalar(GetBitContext *gb, int k, int limit, int readsamplesize){
int x = get_unary_0_9(gb);
if (x > 8) { /* RICE THRESHOLD */
/* use alternative encoding */
x = get_bits(gb, readsamplesize);
} else {
if (k >= limit)
k = limit;
if (k != 1) {
int extrabits = show_bits(gb, k);
/* multiply x by 2^k - 1, as part of their strange algorithm */
x = (x << k) - x;
if (extrabits > 1) {
x += extrabits - 1;
skip_bits(gb, k);
} else
skip_bits(gb, k - 1);
}
}
return x;
}
| false | FFmpeg | d9837434a91dbb3632df335414aad538e5b0a6e9 | static inline int decode_scalar(GetBitContext *gb, int k, int limit, int readsamplesize){
int x = get_unary_0_9(gb);
if (x > 8) {
x = get_bits(gb, readsamplesize);
} else {
if (k >= limit)
k = limit;
if (k != 1) {
int extrabits = show_bits(gb, k);
x = (x << k) - x;
if (extrabits > 1) {
x += extrabits - 1;
skip_bits(gb, k);
} else
skip_bits(gb, k - 1);
}
}
return x;
}
| {
"code": [],
"line_no": []
} | static inline int FUNC_0(GetBitContext *VAR_0, int VAR_1, int VAR_2, int VAR_3){
int VAR_4 = get_unary_0_9(VAR_0);
if (VAR_4 > 8) {
VAR_4 = get_bits(VAR_0, VAR_3);
} else {
if (VAR_1 >= VAR_2)
VAR_1 = VAR_2;
if (VAR_1 != 1) {
int VAR_5 = show_bits(VAR_0, VAR_1);
VAR_4 = (VAR_4 << VAR_1) - VAR_4;
if (VAR_5 > 1) {
VAR_4 += VAR_5 - 1;
skip_bits(VAR_0, VAR_1);
} else
skip_bits(VAR_0, VAR_1 - 1);
}
}
return VAR_4;
}
| [
"static inline int FUNC_0(GetBitContext *VAR_0, int VAR_1, int VAR_2, int VAR_3){",
"int VAR_4 = get_unary_0_9(VAR_0);",
"if (VAR_4 > 8) {",
"VAR_4 = get_bits(VAR_0, VAR_3);",
"} else {",
"if (VAR_1 >= VAR_2)\nVAR_1 = VAR_2;",
"if (VAR_1 != 1) {",
"int VAR_5 = show_bits(VAR_0, VAR_1);",
"VAR_4 = (VAR_4 << VAR_1) - VAR_4;",
"if (VAR_5 > 1) {",
"VAR_4 += VAR_5 - 1;",
"skip_bits(VAR_0, VAR_1);",
"} else",
"skip_bits(VAR_0, VAR_1 - 1);",
"}",
"}",
"return VAR_4;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1
],
[
3
],
[
7
],
[
11
],
[
13
],
[
15,
17
],
[
21
],
[
23
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
]
] |
22,297 | static void opt_b_frames(const char *arg)
{
b_frames = atoi(arg);
if (b_frames > FF_MAX_B_FRAMES) {
fprintf(stderr, "\nCannot have more than %d B frames, increase FF_MAX_B_FRAMES.\n", FF_MAX_B_FRAMES);
exit(1);
} else if (b_frames < 1) {
fprintf(stderr, "\nNumber of B frames must be higher than 0\n");
exit(1);
}
}
| false | FFmpeg | 315b0f974252120cfacb0346954a2d817dff279a | static void opt_b_frames(const char *arg)
{
b_frames = atoi(arg);
if (b_frames > FF_MAX_B_FRAMES) {
fprintf(stderr, "\nCannot have more than %d B frames, increase FF_MAX_B_FRAMES.\n", FF_MAX_B_FRAMES);
exit(1);
} else if (b_frames < 1) {
fprintf(stderr, "\nNumber of B frames must be higher than 0\n");
exit(1);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(const char *VAR_0)
{
b_frames = atoi(VAR_0);
if (b_frames > FF_MAX_B_FRAMES) {
fprintf(stderr, "\nCannot have more than %d B frames, increase FF_MAX_B_FRAMES.\n", FF_MAX_B_FRAMES);
exit(1);
} else if (b_frames < 1) {
fprintf(stderr, "\nNumber of B frames must be higher than 0\n");
exit(1);
}
}
| [
"static void FUNC_0(const char *VAR_0)\n{",
"b_frames = atoi(VAR_0);",
"if (b_frames > FF_MAX_B_FRAMES) {",
"fprintf(stderr, \"\\nCannot have more than %d B frames, increase FF_MAX_B_FRAMES.\\n\", FF_MAX_B_FRAMES);",
"exit(1);",
"} else if (b_frames < 1) {",
"fprintf(stderr, \"\\nNumber of B frames must be higher than 0\\n\");",
"exit(1);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
22,298 | static av_cold int encode_init(AVCodecContext* avc_context)
{
theora_info t_info;
theora_comment t_comment;
ogg_packet o_packet;
unsigned int offset;
TheoraContext *h = avc_context->priv_data;
/* Set up the theora_info struct */
theora_info_init( &t_info );
t_info.width = FFALIGN(avc_context->width, 16);
t_info.height = FFALIGN(avc_context->height, 16);
t_info.frame_width = avc_context->width;
t_info.frame_height = avc_context->height;
t_info.offset_x = 0;
t_info.offset_y = avc_context->height & 0xf;
/* Swap numerator and denominator as time_base in AVCodecContext gives the
* time period between frames, but theora_info needs the framerate. */
t_info.fps_numerator = avc_context->time_base.den;
t_info.fps_denominator = avc_context->time_base.num;
if (avc_context->sample_aspect_ratio.num != 0) {
t_info.aspect_numerator = avc_context->sample_aspect_ratio.num;
t_info.aspect_denominator = avc_context->sample_aspect_ratio.den;
} else {
t_info.aspect_numerator = 1;
t_info.aspect_denominator = 1;
}
t_info.colorspace = OC_CS_UNSPECIFIED;
t_info.pixelformat = OC_PF_420;
t_info.target_bitrate = avc_context->bit_rate;
t_info.keyframe_frequency = avc_context->gop_size;
t_info.keyframe_frequency_force = avc_context->gop_size;
t_info.keyframe_mindistance = avc_context->keyint_min;
t_info.quality = 0;
t_info.quick_p = 1;
t_info.dropframes_p = 0;
t_info.keyframe_auto_p = 1;
t_info.keyframe_data_target_bitrate = t_info.target_bitrate * 1.5;
t_info.keyframe_auto_threshold = 80;
t_info.noise_sensitivity = 1;
t_info.sharpness = 0;
/* Now initialise libtheora */
if (theora_encode_init( &(h->t_state), &t_info ) != 0) {
av_log(avc_context, AV_LOG_ERROR, "theora_encode_init failed\n");
return -1;
}
/* Clear up theora_info struct */
theora_info_clear( &t_info );
/*
Output first header packet consisting of theora
header, comment, and tables.
Each one is prefixed with a 16bit size, then they
are concatenated together into ffmpeg's extradata.
*/
offset = 0;
/* Header */
theora_encode_header( &(h->t_state), &o_packet );
if (concatenate_packet( &offset, avc_context, &o_packet ) != 0) {
return -1;
}
/* Comment */
theora_comment_init( &t_comment );
theora_encode_comment( &t_comment, &o_packet );
if (concatenate_packet( &offset, avc_context, &o_packet ) != 0) {
return -1;
}
/* Tables */
theora_encode_tables( &(h->t_state), &o_packet );
if (concatenate_packet( &offset, avc_context, &o_packet ) != 0) {
return -1;
}
/* Clear up theora_comment struct */
theora_comment_clear( &t_comment );
/* Set up the output AVFrame */
avc_context->coded_frame= avcodec_alloc_frame();
return 0;
}
| true | FFmpeg | 870ee6f71579f2f3f20dee93d6246d12871c280d | static av_cold int encode_init(AVCodecContext* avc_context)
{
theora_info t_info;
theora_comment t_comment;
ogg_packet o_packet;
unsigned int offset;
TheoraContext *h = avc_context->priv_data;
theora_info_init( &t_info );
t_info.width = FFALIGN(avc_context->width, 16);
t_info.height = FFALIGN(avc_context->height, 16);
t_info.frame_width = avc_context->width;
t_info.frame_height = avc_context->height;
t_info.offset_x = 0;
t_info.offset_y = avc_context->height & 0xf;
t_info.fps_numerator = avc_context->time_base.den;
t_info.fps_denominator = avc_context->time_base.num;
if (avc_context->sample_aspect_ratio.num != 0) {
t_info.aspect_numerator = avc_context->sample_aspect_ratio.num;
t_info.aspect_denominator = avc_context->sample_aspect_ratio.den;
} else {
t_info.aspect_numerator = 1;
t_info.aspect_denominator = 1;
}
t_info.colorspace = OC_CS_UNSPECIFIED;
t_info.pixelformat = OC_PF_420;
t_info.target_bitrate = avc_context->bit_rate;
t_info.keyframe_frequency = avc_context->gop_size;
t_info.keyframe_frequency_force = avc_context->gop_size;
t_info.keyframe_mindistance = avc_context->keyint_min;
t_info.quality = 0;
t_info.quick_p = 1;
t_info.dropframes_p = 0;
t_info.keyframe_auto_p = 1;
t_info.keyframe_data_target_bitrate = t_info.target_bitrate * 1.5;
t_info.keyframe_auto_threshold = 80;
t_info.noise_sensitivity = 1;
t_info.sharpness = 0;
if (theora_encode_init( &(h->t_state), &t_info ) != 0) {
av_log(avc_context, AV_LOG_ERROR, "theora_encode_init failed\n");
return -1;
}
theora_info_clear( &t_info );
offset = 0;
theora_encode_header( &(h->t_state), &o_packet );
if (concatenate_packet( &offset, avc_context, &o_packet ) != 0) {
return -1;
}
theora_comment_init( &t_comment );
theora_encode_comment( &t_comment, &o_packet );
if (concatenate_packet( &offset, avc_context, &o_packet ) != 0) {
return -1;
}
theora_encode_tables( &(h->t_state), &o_packet );
if (concatenate_packet( &offset, avc_context, &o_packet ) != 0) {
return -1;
}
theora_comment_clear( &t_comment );
avc_context->coded_frame= avcodec_alloc_frame();
return 0;
}
| {
"code": [
" theora_comment_clear( &t_comment );"
],
"line_no": [
163
]
} | static av_cold int FUNC_0(AVCodecContext* avc_context)
{
theora_info t_info;
theora_comment t_comment;
ogg_packet o_packet;
unsigned int VAR_0;
TheoraContext *h = avc_context->priv_data;
theora_info_init( &t_info );
t_info.width = FFALIGN(avc_context->width, 16);
t_info.height = FFALIGN(avc_context->height, 16);
t_info.frame_width = avc_context->width;
t_info.frame_height = avc_context->height;
t_info.offset_x = 0;
t_info.offset_y = avc_context->height & 0xf;
t_info.fps_numerator = avc_context->time_base.den;
t_info.fps_denominator = avc_context->time_base.num;
if (avc_context->sample_aspect_ratio.num != 0) {
t_info.aspect_numerator = avc_context->sample_aspect_ratio.num;
t_info.aspect_denominator = avc_context->sample_aspect_ratio.den;
} else {
t_info.aspect_numerator = 1;
t_info.aspect_denominator = 1;
}
t_info.colorspace = OC_CS_UNSPECIFIED;
t_info.pixelformat = OC_PF_420;
t_info.target_bitrate = avc_context->bit_rate;
t_info.keyframe_frequency = avc_context->gop_size;
t_info.keyframe_frequency_force = avc_context->gop_size;
t_info.keyframe_mindistance = avc_context->keyint_min;
t_info.quality = 0;
t_info.quick_p = 1;
t_info.dropframes_p = 0;
t_info.keyframe_auto_p = 1;
t_info.keyframe_data_target_bitrate = t_info.target_bitrate * 1.5;
t_info.keyframe_auto_threshold = 80;
t_info.noise_sensitivity = 1;
t_info.sharpness = 0;
if (theora_encode_init( &(h->t_state), &t_info ) != 0) {
av_log(avc_context, AV_LOG_ERROR, "theora_encode_init failed\n");
return -1;
}
theora_info_clear( &t_info );
VAR_0 = 0;
theora_encode_header( &(h->t_state), &o_packet );
if (concatenate_packet( &VAR_0, avc_context, &o_packet ) != 0) {
return -1;
}
theora_comment_init( &t_comment );
theora_encode_comment( &t_comment, &o_packet );
if (concatenate_packet( &VAR_0, avc_context, &o_packet ) != 0) {
return -1;
}
theora_encode_tables( &(h->t_state), &o_packet );
if (concatenate_packet( &VAR_0, avc_context, &o_packet ) != 0) {
return -1;
}
theora_comment_clear( &t_comment );
avc_context->coded_frame= avcodec_alloc_frame();
return 0;
}
| [
"static av_cold int FUNC_0(AVCodecContext* avc_context)\n{",
"theora_info t_info;",
"theora_comment t_comment;",
"ogg_packet o_packet;",
"unsigned int VAR_0;",
"TheoraContext *h = avc_context->priv_data;",
"theora_info_init( &t_info );",
"t_info.width = FFALIGN(avc_context->width, 16);",
"t_info.height = FFALIGN(avc_context->height, 16);",
"t_info.frame_width = avc_context->width;",
"t_info.frame_height = avc_context->height;",
"t_info.offset_x = 0;",
"t_info.offset_y = avc_context->height & 0xf;",
"t_info.fps_numerator = avc_context->time_base.den;",
"t_info.fps_denominator = avc_context->time_base.num;",
"if (avc_context->sample_aspect_ratio.num != 0) {",
"t_info.aspect_numerator = avc_context->sample_aspect_ratio.num;",
"t_info.aspect_denominator = avc_context->sample_aspect_ratio.den;",
"} else {",
"t_info.aspect_numerator = 1;",
"t_info.aspect_denominator = 1;",
"}",
"t_info.colorspace = OC_CS_UNSPECIFIED;",
"t_info.pixelformat = OC_PF_420;",
"t_info.target_bitrate = avc_context->bit_rate;",
"t_info.keyframe_frequency = avc_context->gop_size;",
"t_info.keyframe_frequency_force = avc_context->gop_size;",
"t_info.keyframe_mindistance = avc_context->keyint_min;",
"t_info.quality = 0;",
"t_info.quick_p = 1;",
"t_info.dropframes_p = 0;",
"t_info.keyframe_auto_p = 1;",
"t_info.keyframe_data_target_bitrate = t_info.target_bitrate * 1.5;",
"t_info.keyframe_auto_threshold = 80;",
"t_info.noise_sensitivity = 1;",
"t_info.sharpness = 0;",
"if (theora_encode_init( &(h->t_state), &t_info ) != 0) {",
"av_log(avc_context, AV_LOG_ERROR, \"theora_encode_init failed\\n\");",
"return -1;",
"}",
"theora_info_clear( &t_info );",
"VAR_0 = 0;",
"theora_encode_header( &(h->t_state), &o_packet );",
"if (concatenate_packet( &VAR_0, avc_context, &o_packet ) != 0) {",
"return -1;",
"}",
"theora_comment_init( &t_comment );",
"theora_encode_comment( &t_comment, &o_packet );",
"if (concatenate_packet( &VAR_0, avc_context, &o_packet ) != 0) {",
"return -1;",
"}",
"theora_encode_tables( &(h->t_state), &o_packet );",
"if (concatenate_packet( &VAR_0, avc_context, &o_packet ) != 0) {",
"return -1;",
"}",
"theora_comment_clear( &t_comment );",
"avc_context->coded_frame= avcodec_alloc_frame();",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
89
],
[
91
],
[
93
],
[
95
],
[
101
],
[
119
],
[
125
],
[
127
],
[
129
],
[
131
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
151
],
[
153
],
[
155
],
[
157
],
[
163
],
[
169
],
[
173
],
[
175
]
] |
22,299 | static int frame_thread_init(AVCodecContext *avctx)
{
int thread_count = avctx->thread_count;
AVCodec *codec = avctx->codec;
AVCodecContext *src = avctx;
FrameThreadContext *fctx;
int i, err = 0;
if (thread_count <= 1) {
avctx->active_thread_type = 0;
return 0;
}
avctx->thread_opaque = fctx = av_mallocz(sizeof(FrameThreadContext));
fctx->threads = av_mallocz(sizeof(PerThreadContext) * thread_count);
pthread_mutex_init(&fctx->buffer_mutex, NULL);
fctx->delaying = 1;
for (i = 0; i < thread_count; i++) {
AVCodecContext *copy = av_malloc(sizeof(AVCodecContext));
PerThreadContext *p = &fctx->threads[i];
pthread_mutex_init(&p->mutex, NULL);
pthread_mutex_init(&p->progress_mutex, NULL);
pthread_cond_init(&p->input_cond, NULL);
pthread_cond_init(&p->progress_cond, NULL);
pthread_cond_init(&p->output_cond, NULL);
p->parent = fctx;
p->avctx = copy;
if (!copy) {
err = AVERROR(ENOMEM);
goto error;
}
*copy = *src;
copy->thread_opaque = p;
copy->pkt = &p->avpkt;
if (!i) {
src = copy;
if (codec->init)
err = codec->init(copy);
update_context_from_thread(avctx, copy, 1);
} else {
copy->priv_data = av_malloc(codec->priv_data_size);
if (!copy->priv_data) {
err = AVERROR(ENOMEM);
goto error;
}
memcpy(copy->priv_data, src->priv_data, codec->priv_data_size);
copy->internal = av_malloc(sizeof(AVCodecInternal));
if (!copy->internal) {
err = AVERROR(ENOMEM);
goto error;
}
*(copy->internal) = *(src->internal);
copy->internal->is_copy = 1;
if (codec->init_thread_copy)
err = codec->init_thread_copy(copy);
}
if (err) goto error;
pthread_create(&p->thread, NULL, frame_worker_thread, p);
}
return 0;
error:
frame_thread_free(avctx, i+1);
return err;
}
| true | FFmpeg | 2bb79b23fe106a45eab6ff80d7ef7519d542d1f7 | static int frame_thread_init(AVCodecContext *avctx)
{
int thread_count = avctx->thread_count;
AVCodec *codec = avctx->codec;
AVCodecContext *src = avctx;
FrameThreadContext *fctx;
int i, err = 0;
if (thread_count <= 1) {
avctx->active_thread_type = 0;
return 0;
}
avctx->thread_opaque = fctx = av_mallocz(sizeof(FrameThreadContext));
fctx->threads = av_mallocz(sizeof(PerThreadContext) * thread_count);
pthread_mutex_init(&fctx->buffer_mutex, NULL);
fctx->delaying = 1;
for (i = 0; i < thread_count; i++) {
AVCodecContext *copy = av_malloc(sizeof(AVCodecContext));
PerThreadContext *p = &fctx->threads[i];
pthread_mutex_init(&p->mutex, NULL);
pthread_mutex_init(&p->progress_mutex, NULL);
pthread_cond_init(&p->input_cond, NULL);
pthread_cond_init(&p->progress_cond, NULL);
pthread_cond_init(&p->output_cond, NULL);
p->parent = fctx;
p->avctx = copy;
if (!copy) {
err = AVERROR(ENOMEM);
goto error;
}
*copy = *src;
copy->thread_opaque = p;
copy->pkt = &p->avpkt;
if (!i) {
src = copy;
if (codec->init)
err = codec->init(copy);
update_context_from_thread(avctx, copy, 1);
} else {
copy->priv_data = av_malloc(codec->priv_data_size);
if (!copy->priv_data) {
err = AVERROR(ENOMEM);
goto error;
}
memcpy(copy->priv_data, src->priv_data, codec->priv_data_size);
copy->internal = av_malloc(sizeof(AVCodecInternal));
if (!copy->internal) {
err = AVERROR(ENOMEM);
goto error;
}
*(copy->internal) = *(src->internal);
copy->internal->is_copy = 1;
if (codec->init_thread_copy)
err = codec->init_thread_copy(copy);
}
if (err) goto error;
pthread_create(&p->thread, NULL, frame_worker_thread, p);
}
return 0;
error:
frame_thread_free(avctx, i+1);
return err;
}
| {
"code": [
" pthread_create(&p->thread, NULL, frame_worker_thread, p);"
],
"line_no": [
139
]
} | static int FUNC_0(AVCodecContext *VAR_0)
{
int VAR_1 = VAR_0->VAR_1;
AVCodec *codec = VAR_0->codec;
AVCodecContext *src = VAR_0;
FrameThreadContext *fctx;
int VAR_2, VAR_3 = 0;
if (VAR_1 <= 1) {
VAR_0->active_thread_type = 0;
return 0;
}
VAR_0->thread_opaque = fctx = av_mallocz(sizeof(FrameThreadContext));
fctx->threads = av_mallocz(sizeof(PerThreadContext) * VAR_1);
pthread_mutex_init(&fctx->buffer_mutex, NULL);
fctx->delaying = 1;
for (VAR_2 = 0; VAR_2 < VAR_1; VAR_2++) {
AVCodecContext *copy = av_malloc(sizeof(AVCodecContext));
PerThreadContext *p = &fctx->threads[VAR_2];
pthread_mutex_init(&p->mutex, NULL);
pthread_mutex_init(&p->progress_mutex, NULL);
pthread_cond_init(&p->input_cond, NULL);
pthread_cond_init(&p->progress_cond, NULL);
pthread_cond_init(&p->output_cond, NULL);
p->parent = fctx;
p->VAR_0 = copy;
if (!copy) {
VAR_3 = AVERROR(ENOMEM);
goto error;
}
*copy = *src;
copy->thread_opaque = p;
copy->pkt = &p->avpkt;
if (!VAR_2) {
src = copy;
if (codec->init)
VAR_3 = codec->init(copy);
update_context_from_thread(VAR_0, copy, 1);
} else {
copy->priv_data = av_malloc(codec->priv_data_size);
if (!copy->priv_data) {
VAR_3 = AVERROR(ENOMEM);
goto error;
}
memcpy(copy->priv_data, src->priv_data, codec->priv_data_size);
copy->internal = av_malloc(sizeof(AVCodecInternal));
if (!copy->internal) {
VAR_3 = AVERROR(ENOMEM);
goto error;
}
*(copy->internal) = *(src->internal);
copy->internal->is_copy = 1;
if (codec->init_thread_copy)
VAR_3 = codec->init_thread_copy(copy);
}
if (VAR_3) goto error;
pthread_create(&p->thread, NULL, frame_worker_thread, p);
}
return 0;
error:
frame_thread_free(VAR_0, VAR_2+1);
return VAR_3;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0)\n{",
"int VAR_1 = VAR_0->VAR_1;",
"AVCodec *codec = VAR_0->codec;",
"AVCodecContext *src = VAR_0;",
"FrameThreadContext *fctx;",
"int VAR_2, VAR_3 = 0;",
"if (VAR_1 <= 1) {",
"VAR_0->active_thread_type = 0;",
"return 0;",
"}",
"VAR_0->thread_opaque = fctx = av_mallocz(sizeof(FrameThreadContext));",
"fctx->threads = av_mallocz(sizeof(PerThreadContext) * VAR_1);",
"pthread_mutex_init(&fctx->buffer_mutex, NULL);",
"fctx->delaying = 1;",
"for (VAR_2 = 0; VAR_2 < VAR_1; VAR_2++) {",
"AVCodecContext *copy = av_malloc(sizeof(AVCodecContext));",
"PerThreadContext *p = &fctx->threads[VAR_2];",
"pthread_mutex_init(&p->mutex, NULL);",
"pthread_mutex_init(&p->progress_mutex, NULL);",
"pthread_cond_init(&p->input_cond, NULL);",
"pthread_cond_init(&p->progress_cond, NULL);",
"pthread_cond_init(&p->output_cond, NULL);",
"p->parent = fctx;",
"p->VAR_0 = copy;",
"if (!copy) {",
"VAR_3 = AVERROR(ENOMEM);",
"goto error;",
"}",
"*copy = *src;",
"copy->thread_opaque = p;",
"copy->pkt = &p->avpkt;",
"if (!VAR_2) {",
"src = copy;",
"if (codec->init)\nVAR_3 = codec->init(copy);",
"update_context_from_thread(VAR_0, copy, 1);",
"} else {",
"copy->priv_data = av_malloc(codec->priv_data_size);",
"if (!copy->priv_data) {",
"VAR_3 = AVERROR(ENOMEM);",
"goto error;",
"}",
"memcpy(copy->priv_data, src->priv_data, codec->priv_data_size);",
"copy->internal = av_malloc(sizeof(AVCodecInternal));",
"if (!copy->internal) {",
"VAR_3 = AVERROR(ENOMEM);",
"goto error;",
"}",
"*(copy->internal) = *(src->internal);",
"copy->internal->is_copy = 1;",
"if (codec->init_thread_copy)\nVAR_3 = codec->init_thread_copy(copy);",
"}",
"if (VAR_3) goto error;",
"pthread_create(&p->thread, NULL, frame_worker_thread, p);",
"}",
"return 0;",
"error:\nframe_thread_free(VAR_0, VAR_2+1);",
"return VAR_3;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
],
[
89,
91
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
127,
129
],
[
131
],
[
135
],
[
139
],
[
141
],
[
145
],
[
149,
151
],
[
155
],
[
157
]
] |
22,301 | static char *shorts2str(int16_t *sp, int count, const char *sep)
{
int i;
char *ap, *ap0;
if (!sep) sep = ", ";
ap = av_malloc((5 + strlen(sep)) * count);
if (!ap)
return NULL;
ap0 = ap;
ap[0] = '\0';
for (i = 0; i < count; i++) {
int l = snprintf(ap, 5 + strlen(sep), "%d%s", sp[i], sep);
ap += l;
}
ap0[strlen(ap0) - strlen(sep)] = '\0';
return ap0;
}
| false | FFmpeg | e1219cdaf9fb4bc8cea410e1caf802373c1bfe51 | static char *shorts2str(int16_t *sp, int count, const char *sep)
{
int i;
char *ap, *ap0;
if (!sep) sep = ", ";
ap = av_malloc((5 + strlen(sep)) * count);
if (!ap)
return NULL;
ap0 = ap;
ap[0] = '\0';
for (i = 0; i < count; i++) {
int l = snprintf(ap, 5 + strlen(sep), "%d%s", sp[i], sep);
ap += l;
}
ap0[strlen(ap0) - strlen(sep)] = '\0';
return ap0;
}
| {
"code": [],
"line_no": []
} | static char *FUNC_0(int16_t *VAR_0, int VAR_1, const char *VAR_2)
{
int VAR_3;
char *VAR_4, *VAR_5;
if (!VAR_2) VAR_2 = ", ";
VAR_4 = av_malloc((5 + strlen(VAR_2)) * VAR_1);
if (!VAR_4)
return NULL;
VAR_5 = VAR_4;
VAR_4[0] = '\0';
for (VAR_3 = 0; VAR_3 < VAR_1; VAR_3++) {
int VAR_6 = snprintf(VAR_4, 5 + strlen(VAR_2), "%d%s", VAR_0[VAR_3], VAR_2);
VAR_4 += VAR_6;
}
VAR_5[strlen(VAR_5) - strlen(VAR_2)] = '\0';
return VAR_5;
}
| [
"static char *FUNC_0(int16_t *VAR_0, int VAR_1, const char *VAR_2)\n{",
"int VAR_3;",
"char *VAR_4, *VAR_5;",
"if (!VAR_2) VAR_2 = \", \";",
"VAR_4 = av_malloc((5 + strlen(VAR_2)) * VAR_1);",
"if (!VAR_4)\nreturn NULL;",
"VAR_5 = VAR_4;",
"VAR_4[0] = '\\0';",
"for (VAR_3 = 0; VAR_3 < VAR_1; VAR_3++) {",
"int VAR_6 = snprintf(VAR_4, 5 + strlen(VAR_2), \"%d%s\", VAR_0[VAR_3], VAR_2);",
"VAR_4 += VAR_6;",
"}",
"VAR_5[strlen(VAR_5) - strlen(VAR_2)] = '\\0';",
"return VAR_5;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13,
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
]
] |
22,302 | static int h264_set_parameter_from_sps(H264Context *h)
{
if (h->flags & CODEC_FLAG_LOW_DELAY ||
(h->sps.bitstream_restriction_flag &&
!h->sps.num_reorder_frames)) {
if (h->avctx->has_b_frames > 1 || h->delayed_pic[0])
av_log(h->avctx, AV_LOG_WARNING, "Delayed frames seen. "
"Reenabling low delay requires a codec flush.\n");
else
h->low_delay = 1;
if (h->avctx->has_b_frames < 2)
h->avctx->has_b_frames = !h->low_delay;
if (h->avctx->bits_per_raw_sample != h->sps.bit_depth_luma ||
h->cur_chroma_format_idc != h->sps.chroma_format_idc) {
if (h->avctx->codec &&
h->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU &&
(h->sps.bit_depth_luma != 8 || h->sps.chroma_format_idc > 1)) {
av_log(h->avctx, AV_LOG_ERROR,
"VDPAU decoding does not support video colorspace.\n");
return AVERROR_INVALIDDATA;
if (h->sps.bit_depth_luma >= 8 && h->sps.bit_depth_luma <= 10) {
h->avctx->bits_per_raw_sample = h->sps.bit_depth_luma;
h->cur_chroma_format_idc = h->sps.chroma_format_idc;
h->pixel_shift = h->sps.bit_depth_luma > 8;
ff_h264dsp_init(&h->h264dsp, h->sps.bit_depth_luma,
h->sps.chroma_format_idc);
ff_h264chroma_init(&h->h264chroma, h->sps.bit_depth_chroma);
ff_h264qpel_init(&h->h264qpel, h->sps.bit_depth_luma);
ff_h264_pred_init(&h->hpc, h->avctx->codec_id, h->sps.bit_depth_luma,
h->sps.chroma_format_idc);
h->dsp.dct_bits = h->sps.bit_depth_luma > 8 ? 32 : 16;
ff_dsputil_init(&h->dsp, h->avctx);
ff_videodsp_init(&h->vdsp, h->sps.bit_depth_luma);
} else {
av_log(h->avctx, AV_LOG_ERROR, "Unsupported bit depth: %d\n",
h->sps.bit_depth_luma);
return AVERROR_INVALIDDATA;
return 0; | true | FFmpeg | 4987faee78b9869f8f4646b8dd971d459df218a5 | static int h264_set_parameter_from_sps(H264Context *h)
{
if (h->flags & CODEC_FLAG_LOW_DELAY ||
(h->sps.bitstream_restriction_flag &&
!h->sps.num_reorder_frames)) {
if (h->avctx->has_b_frames > 1 || h->delayed_pic[0])
av_log(h->avctx, AV_LOG_WARNING, "Delayed frames seen. "
"Reenabling low delay requires a codec flush.\n");
else
h->low_delay = 1;
if (h->avctx->has_b_frames < 2)
h->avctx->has_b_frames = !h->low_delay;
if (h->avctx->bits_per_raw_sample != h->sps.bit_depth_luma ||
h->cur_chroma_format_idc != h->sps.chroma_format_idc) {
if (h->avctx->codec &&
h->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU &&
(h->sps.bit_depth_luma != 8 || h->sps.chroma_format_idc > 1)) {
av_log(h->avctx, AV_LOG_ERROR,
"VDPAU decoding does not support video colorspace.\n");
return AVERROR_INVALIDDATA;
if (h->sps.bit_depth_luma >= 8 && h->sps.bit_depth_luma <= 10) {
h->avctx->bits_per_raw_sample = h->sps.bit_depth_luma;
h->cur_chroma_format_idc = h->sps.chroma_format_idc;
h->pixel_shift = h->sps.bit_depth_luma > 8;
ff_h264dsp_init(&h->h264dsp, h->sps.bit_depth_luma,
h->sps.chroma_format_idc);
ff_h264chroma_init(&h->h264chroma, h->sps.bit_depth_chroma);
ff_h264qpel_init(&h->h264qpel, h->sps.bit_depth_luma);
ff_h264_pred_init(&h->hpc, h->avctx->codec_id, h->sps.bit_depth_luma,
h->sps.chroma_format_idc);
h->dsp.dct_bits = h->sps.bit_depth_luma > 8 ? 32 : 16;
ff_dsputil_init(&h->dsp, h->avctx);
ff_videodsp_init(&h->vdsp, h->sps.bit_depth_luma);
} else {
av_log(h->avctx, AV_LOG_ERROR, "Unsupported bit depth: %d\n",
h->sps.bit_depth_luma);
return AVERROR_INVALIDDATA;
return 0; | {
"code": [],
"line_no": []
} | static int FUNC_0(H264Context *VAR_0)
{
if (VAR_0->flags & CODEC_FLAG_LOW_DELAY ||
(VAR_0->sps.bitstream_restriction_flag &&
!VAR_0->sps.num_reorder_frames)) {
if (VAR_0->avctx->has_b_frames > 1 || VAR_0->delayed_pic[0])
av_log(VAR_0->avctx, AV_LOG_WARNING, "Delayed frames seen. "
"Reenabling low delay requires a codec flush.\n");
else
VAR_0->low_delay = 1;
if (VAR_0->avctx->has_b_frames < 2)
VAR_0->avctx->has_b_frames = !VAR_0->low_delay;
if (VAR_0->avctx->bits_per_raw_sample != VAR_0->sps.bit_depth_luma ||
VAR_0->cur_chroma_format_idc != VAR_0->sps.chroma_format_idc) {
if (VAR_0->avctx->codec &&
VAR_0->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU &&
(VAR_0->sps.bit_depth_luma != 8 || VAR_0->sps.chroma_format_idc > 1)) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"VDPAU decoding does not support video colorspace.\n");
return AVERROR_INVALIDDATA;
if (VAR_0->sps.bit_depth_luma >= 8 && VAR_0->sps.bit_depth_luma <= 10) {
VAR_0->avctx->bits_per_raw_sample = VAR_0->sps.bit_depth_luma;
VAR_0->cur_chroma_format_idc = VAR_0->sps.chroma_format_idc;
VAR_0->pixel_shift = VAR_0->sps.bit_depth_luma > 8;
ff_h264dsp_init(&VAR_0->h264dsp, VAR_0->sps.bit_depth_luma,
VAR_0->sps.chroma_format_idc);
ff_h264chroma_init(&VAR_0->h264chroma, VAR_0->sps.bit_depth_chroma);
ff_h264qpel_init(&VAR_0->h264qpel, VAR_0->sps.bit_depth_luma);
ff_h264_pred_init(&VAR_0->hpc, VAR_0->avctx->codec_id, VAR_0->sps.bit_depth_luma,
VAR_0->sps.chroma_format_idc);
VAR_0->dsp.dct_bits = VAR_0->sps.bit_depth_luma > 8 ? 32 : 16;
ff_dsputil_init(&VAR_0->dsp, VAR_0->avctx);
ff_videodsp_init(&VAR_0->vdsp, VAR_0->sps.bit_depth_luma);
} else {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Unsupported bit depth: %d\n",
VAR_0->sps.bit_depth_luma);
return AVERROR_INVALIDDATA;
return 0; | [
"static int FUNC_0(H264Context *VAR_0)\n{",
"if (VAR_0->flags & CODEC_FLAG_LOW_DELAY ||\n(VAR_0->sps.bitstream_restriction_flag &&\n!VAR_0->sps.num_reorder_frames)) {",
"if (VAR_0->avctx->has_b_frames > 1 || VAR_0->delayed_pic[0])\nav_log(VAR_0->avctx, AV_LOG_WARNING, \"Delayed frames seen. \"\n\"Reenabling low delay requires a codec flush.\\n\");",
"else\nVAR_0->low_delay = 1;",
"if (VAR_0->avctx->has_b_frames < 2)\nVAR_0->avctx->has_b_frames = !VAR_0->low_delay;",
"if (VAR_0->avctx->bits_per_raw_sample != VAR_0->sps.bit_depth_luma ||\nVAR_0->cur_chroma_format_idc != VAR_0->sps.chroma_format_idc) {",
"if (VAR_0->avctx->codec &&\nVAR_0->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU &&\n(VAR_0->sps.bit_depth_luma != 8 || VAR_0->sps.chroma_format_idc > 1)) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"VDPAU decoding does not support video colorspace.\\n\");",
"return AVERROR_INVALIDDATA;",
"if (VAR_0->sps.bit_depth_luma >= 8 && VAR_0->sps.bit_depth_luma <= 10) {",
"VAR_0->avctx->bits_per_raw_sample = VAR_0->sps.bit_depth_luma;",
"VAR_0->cur_chroma_format_idc = VAR_0->sps.chroma_format_idc;",
"VAR_0->pixel_shift = VAR_0->sps.bit_depth_luma > 8;",
"ff_h264dsp_init(&VAR_0->h264dsp, VAR_0->sps.bit_depth_luma,\nVAR_0->sps.chroma_format_idc);",
"ff_h264chroma_init(&VAR_0->h264chroma, VAR_0->sps.bit_depth_chroma);",
"ff_h264qpel_init(&VAR_0->h264qpel, VAR_0->sps.bit_depth_luma);",
"ff_h264_pred_init(&VAR_0->hpc, VAR_0->avctx->codec_id, VAR_0->sps.bit_depth_luma,\nVAR_0->sps.chroma_format_idc);",
"VAR_0->dsp.dct_bits = VAR_0->sps.bit_depth_luma > 8 ? 32 : 16;",
"ff_dsputil_init(&VAR_0->dsp, VAR_0->avctx);",
"ff_videodsp_init(&VAR_0->vdsp, VAR_0->sps.bit_depth_luma);",
"} else {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Unsupported bit depth: %d\\n\",\nVAR_0->sps.bit_depth_luma);",
"return AVERROR_INVALIDDATA;",
"return 0;"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
2
],
[
3,
4,
5
],
[
6,
7,
8
],
[
9,
10
],
[
11,
12
],
[
13,
14
],
[
15,
16,
17
],
[
18,
19
],
[
20
],
[
21
],
[
22
],
[
23
],
[
24
],
[
25,
26
],
[
27
],
[
28
],
[
29,
30
],
[
31
],
[
32
],
[
33
],
[
34
],
[
35,
36
],
[
37
],
[
38
]
] |
22,303 | static inline int array_roll(array_t* array,int index_to,int index_from,int count)
{
char* buf;
char* from;
char* to;
int is;
if(!array ||
index_to<0 || index_to>=array->next ||
index_from<0 || index_from>=array->next)
return -1;
if(index_to==index_from)
return 0;
is=array->item_size;
from=array->pointer+index_from*is;
to=array->pointer+index_to*is;
buf=g_malloc(is*count);
memcpy(buf,from,is*count);
if(index_to<index_from)
memmove(to+is*count,to,from-to);
else
memmove(from,from+is*count,to-from);
memcpy(to,buf,is*count);
free(buf);
return 0;
}
| true | qemu | ce137829e7e58fcdc5ba63b5e256f972e80be438 | static inline int array_roll(array_t* array,int index_to,int index_from,int count)
{
char* buf;
char* from;
char* to;
int is;
if(!array ||
index_to<0 || index_to>=array->next ||
index_from<0 || index_from>=array->next)
return -1;
if(index_to==index_from)
return 0;
is=array->item_size;
from=array->pointer+index_from*is;
to=array->pointer+index_to*is;
buf=g_malloc(is*count);
memcpy(buf,from,is*count);
if(index_to<index_from)
memmove(to+is*count,to,from-to);
else
memmove(from,from+is*count,to-from);
memcpy(to,buf,is*count);
free(buf);
return 0;
}
| {
"code": [
" free(buf);"
],
"line_no": [
57
]
} | static inline int FUNC_0(array_t* VAR_0,int VAR_1,int VAR_2,int VAR_3)
{
char* VAR_4;
char* VAR_5;
char* VAR_6;
int VAR_7;
if(!VAR_0 ||
VAR_1<0 || VAR_1>=VAR_0->next ||
VAR_2<0 || VAR_2>=VAR_0->next)
return -1;
if(VAR_1==VAR_2)
return 0;
VAR_7=VAR_0->item_size;
VAR_5=VAR_0->pointer+VAR_2*VAR_7;
VAR_6=VAR_0->pointer+VAR_1*VAR_7;
VAR_4=g_malloc(VAR_7*VAR_3);
memcpy(VAR_4,VAR_5,VAR_7*VAR_3);
if(VAR_1<VAR_2)
memmove(VAR_6+VAR_7*VAR_3,VAR_6,VAR_5-VAR_6);
else
memmove(VAR_5,VAR_5+VAR_7*VAR_3,VAR_6-VAR_5);
memcpy(VAR_6,VAR_4,VAR_7*VAR_3);
free(VAR_4);
return 0;
}
| [
"static inline int FUNC_0(array_t* VAR_0,int VAR_1,int VAR_2,int VAR_3)\n{",
"char* VAR_4;",
"char* VAR_5;",
"char* VAR_6;",
"int VAR_7;",
"if(!VAR_0 ||\nVAR_1<0 || VAR_1>=VAR_0->next ||\nVAR_2<0 || VAR_2>=VAR_0->next)\nreturn -1;",
"if(VAR_1==VAR_2)\nreturn 0;",
"VAR_7=VAR_0->item_size;",
"VAR_5=VAR_0->pointer+VAR_2*VAR_7;",
"VAR_6=VAR_0->pointer+VAR_1*VAR_7;",
"VAR_4=g_malloc(VAR_7*VAR_3);",
"memcpy(VAR_4,VAR_5,VAR_7*VAR_3);",
"if(VAR_1<VAR_2)\nmemmove(VAR_6+VAR_7*VAR_3,VAR_6,VAR_5-VAR_6);",
"else\nmemmove(VAR_5,VAR_5+VAR_7*VAR_3,VAR_6-VAR_5);",
"memcpy(VAR_6,VAR_4,VAR_7*VAR_3);",
"free(VAR_4);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15,
17,
19,
21
],
[
25,
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43,
45
],
[
47,
49
],
[
53
],
[
57
],
[
61
],
[
63
]
] |
22,304 | int ff_raw_video_read_header(AVFormatContext *s)
{
AVStream *st;
FFRawVideoDemuxerContext *s1 = s->priv_data;
AVRational framerate;
int ret = 0;
st = avformat_new_stream(s, NULL);
if (!st) {
ret = AVERROR(ENOMEM);
goto fail;
}
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = s->iformat->raw_codec_id;
st->need_parsing = AVSTREAM_PARSE_FULL;
if ((ret = av_parse_video_rate(&framerate, s1->framerate)) < 0) {
av_log(s, AV_LOG_ERROR, "Could not parse framerate: %s.\n", s1->framerate);
goto fail;
}
st->r_frame_rate = st->avg_frame_rate = framerate;
avpriv_set_pts_info(st, 64, framerate.den, framerate.num);
fail:
return ret;
}
| true | FFmpeg | aba232cfa9b193604ed98f3fa505378d006b1b3b | int ff_raw_video_read_header(AVFormatContext *s)
{
AVStream *st;
FFRawVideoDemuxerContext *s1 = s->priv_data;
AVRational framerate;
int ret = 0;
st = avformat_new_stream(s, NULL);
if (!st) {
ret = AVERROR(ENOMEM);
goto fail;
}
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = s->iformat->raw_codec_id;
st->need_parsing = AVSTREAM_PARSE_FULL;
if ((ret = av_parse_video_rate(&framerate, s1->framerate)) < 0) {
av_log(s, AV_LOG_ERROR, "Could not parse framerate: %s.\n", s1->framerate);
goto fail;
}
st->r_frame_rate = st->avg_frame_rate = framerate;
avpriv_set_pts_info(st, 64, framerate.den, framerate.num);
fail:
return ret;
}
| {
"code": [
" st->r_frame_rate = st->avg_frame_rate = framerate;"
],
"line_no": [
47
]
} | int FUNC_0(AVFormatContext *VAR_0)
{
AVStream *st;
FFRawVideoDemuxerContext *s1 = VAR_0->priv_data;
AVRational framerate;
int VAR_1 = 0;
st = avformat_new_stream(VAR_0, NULL);
if (!st) {
VAR_1 = AVERROR(ENOMEM);
goto fail;
}
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = VAR_0->iformat->raw_codec_id;
st->need_parsing = AVSTREAM_PARSE_FULL;
if ((VAR_1 = av_parse_video_rate(&framerate, s1->framerate)) < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Could not parse framerate: %VAR_0.\n", s1->framerate);
goto fail;
}
st->r_frame_rate = st->avg_frame_rate = framerate;
avpriv_set_pts_info(st, 64, framerate.den, framerate.num);
fail:
return VAR_1;
}
| [
"int FUNC_0(AVFormatContext *VAR_0)\n{",
"AVStream *st;",
"FFRawVideoDemuxerContext *s1 = VAR_0->priv_data;",
"AVRational framerate;",
"int VAR_1 = 0;",
"st = avformat_new_stream(VAR_0, NULL);",
"if (!st) {",
"VAR_1 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"st->codec->codec_type = AVMEDIA_TYPE_VIDEO;",
"st->codec->codec_id = VAR_0->iformat->raw_codec_id;",
"st->need_parsing = AVSTREAM_PARSE_FULL;",
"if ((VAR_1 = av_parse_video_rate(&framerate, s1->framerate)) < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Could not parse framerate: %VAR_0.\\n\", s1->framerate);",
"goto fail;",
"}",
"st->r_frame_rate = st->avg_frame_rate = framerate;",
"avpriv_set_pts_info(st, 64, framerate.den, framerate.num);",
"fail:\nreturn VAR_1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
53,
55
],
[
57
]
] |
22,305 | static int mov_read_packet(AVFormatContext *s, AVPacket *pkt)
{
MOVContext *mov = s->priv_data;
MOVStreamContext *sc;
AVIndexEntry *sample;
AVStream *st = NULL;
int ret;
mov->fc = s;
retry:
sample = mov_find_next_sample(s, &st);
if (!sample) {
mov->found_mdat = 0;
if (!mov->next_root_atom)
return AVERROR_EOF;
avio_seek(s->pb, mov->next_root_atom, SEEK_SET);
mov->next_root_atom = 0;
if (mov_read_default(mov, s->pb, (MOVAtom){ AV_RL32("root"), INT64_MAX }) < 0 ||
url_feof(s->pb))
return AVERROR_EOF;
av_dlog(s, "read fragments, offset 0x%"PRIx64"\n", avio_tell(s->pb));
goto retry;
sc = st->priv_data;
/* must be done just before reading, to avoid infinite loop on sample */
sc->current_sample++;
if (st->discard != AVDISCARD_ALL) {
if (avio_seek(sc->pb, sample->pos, SEEK_SET) != sample->pos) {
av_log(mov->fc, AV_LOG_ERROR, "stream %d, offset 0x%"PRIx64": partial file\n",
sc->ffindex, sample->pos);
return AVERROR_INVALIDDATA;
ret = av_get_packet(sc->pb, pkt, sample->size);
if (ret < 0)
return ret;
if (sc->has_palette) {
uint8_t *pal;
pal = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE, AVPALETTE_SIZE);
if (!pal) {
av_log(mov->fc, AV_LOG_ERROR, "Cannot append palette to packet\n");
} else {
memcpy(pal, sc->palette, AVPALETTE_SIZE);
sc->has_palette = 0;
#if CONFIG_DV_DEMUXER
if (mov->dv_demux && sc->dv_audio_container) {
avpriv_dv_produce_packet(mov->dv_demux, pkt, pkt->data, pkt->size, pkt->pos);
av_free(pkt->data);
pkt->size = 0;
ret = avpriv_dv_get_packet(mov->dv_demux, pkt);
if (ret < 0)
return ret;
#endif
pkt->stream_index = sc->ffindex;
pkt->dts = sample->timestamp;
if (sc->ctts_data && sc->ctts_index < sc->ctts_count) {
pkt->pts = pkt->dts + sc->dts_shift + sc->ctts_data[sc->ctts_index].duration;
/* update ctts context */
sc->ctts_sample++;
if (sc->ctts_index < sc->ctts_count &&
sc->ctts_data[sc->ctts_index].count == sc->ctts_sample) {
sc->ctts_index++;
sc->ctts_sample = 0;
if (sc->wrong_dts)
pkt->dts = AV_NOPTS_VALUE;
} else {
int64_t next_dts = (sc->current_sample < st->nb_index_entries) ?
st->index_entries[sc->current_sample].timestamp : st->duration;
pkt->duration = next_dts - pkt->dts;
pkt->pts = pkt->dts;
if (st->discard == AVDISCARD_ALL)
goto retry;
pkt->flags |= sample->flags & AVINDEX_KEYFRAME ? AV_PKT_FLAG_KEY : 0;
pkt->pos = sample->pos;
av_dlog(s, "stream %d, pts %"PRId64", dts %"PRId64", pos 0x%"PRIx64", duration %d\n",
pkt->stream_index, pkt->pts, pkt->dts, pkt->pos, pkt->duration);
return 0; | true | FFmpeg | b1d61eb7aaaef84391130b6f5e83942cc829a8c8 | static int mov_read_packet(AVFormatContext *s, AVPacket *pkt)
{
MOVContext *mov = s->priv_data;
MOVStreamContext *sc;
AVIndexEntry *sample;
AVStream *st = NULL;
int ret;
mov->fc = s;
retry:
sample = mov_find_next_sample(s, &st);
if (!sample) {
mov->found_mdat = 0;
if (!mov->next_root_atom)
return AVERROR_EOF;
avio_seek(s->pb, mov->next_root_atom, SEEK_SET);
mov->next_root_atom = 0;
if (mov_read_default(mov, s->pb, (MOVAtom){ AV_RL32("root"), INT64_MAX }) < 0 ||
url_feof(s->pb))
return AVERROR_EOF;
av_dlog(s, "read fragments, offset 0x%"PRIx64"\n", avio_tell(s->pb));
goto retry;
sc = st->priv_data;
sc->current_sample++;
if (st->discard != AVDISCARD_ALL) {
if (avio_seek(sc->pb, sample->pos, SEEK_SET) != sample->pos) {
av_log(mov->fc, AV_LOG_ERROR, "stream %d, offset 0x%"PRIx64": partial file\n",
sc->ffindex, sample->pos);
return AVERROR_INVALIDDATA;
ret = av_get_packet(sc->pb, pkt, sample->size);
if (ret < 0)
return ret;
if (sc->has_palette) {
uint8_t *pal;
pal = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE, AVPALETTE_SIZE);
if (!pal) {
av_log(mov->fc, AV_LOG_ERROR, "Cannot append palette to packet\n");
} else {
memcpy(pal, sc->palette, AVPALETTE_SIZE);
sc->has_palette = 0;
#if CONFIG_DV_DEMUXER
if (mov->dv_demux && sc->dv_audio_container) {
avpriv_dv_produce_packet(mov->dv_demux, pkt, pkt->data, pkt->size, pkt->pos);
av_free(pkt->data);
pkt->size = 0;
ret = avpriv_dv_get_packet(mov->dv_demux, pkt);
if (ret < 0)
return ret;
#endif
pkt->stream_index = sc->ffindex;
pkt->dts = sample->timestamp;
if (sc->ctts_data && sc->ctts_index < sc->ctts_count) {
pkt->pts = pkt->dts + sc->dts_shift + sc->ctts_data[sc->ctts_index].duration;
sc->ctts_sample++;
if (sc->ctts_index < sc->ctts_count &&
sc->ctts_data[sc->ctts_index].count == sc->ctts_sample) {
sc->ctts_index++;
sc->ctts_sample = 0;
if (sc->wrong_dts)
pkt->dts = AV_NOPTS_VALUE;
} else {
int64_t next_dts = (sc->current_sample < st->nb_index_entries) ?
st->index_entries[sc->current_sample].timestamp : st->duration;
pkt->duration = next_dts - pkt->dts;
pkt->pts = pkt->dts;
if (st->discard == AVDISCARD_ALL)
goto retry;
pkt->flags |= sample->flags & AVINDEX_KEYFRAME ? AV_PKT_FLAG_KEY : 0;
pkt->pos = sample->pos;
av_dlog(s, "stream %d, pts %"PRId64", dts %"PRId64", pos 0x%"PRIx64", duration %d\n",
pkt->stream_index, pkt->pts, pkt->dts, pkt->pos, pkt->duration);
return 0; | {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)
{
MOVContext *mov = VAR_0->priv_data;
MOVStreamContext *sc;
AVIndexEntry *sample;
AVStream *st = NULL;
int VAR_2;
mov->fc = VAR_0;
retry:
sample = mov_find_next_sample(VAR_0, &st);
if (!sample) {
mov->found_mdat = 0;
if (!mov->next_root_atom)
return AVERROR_EOF;
avio_seek(VAR_0->pb, mov->next_root_atom, SEEK_SET);
mov->next_root_atom = 0;
if (mov_read_default(mov, VAR_0->pb, (MOVAtom){ AV_RL32("root"), INT64_MAX }) < 0 ||
url_feof(VAR_0->pb))
return AVERROR_EOF;
av_dlog(VAR_0, "read fragments, offset 0x%"PRIx64"\n", avio_tell(VAR_0->pb));
goto retry;
sc = st->priv_data;
sc->current_sample++;
if (st->discard != AVDISCARD_ALL) {
if (avio_seek(sc->pb, sample->pos, SEEK_SET) != sample->pos) {
av_log(mov->fc, AV_LOG_ERROR, "stream %d, offset 0x%"PRIx64": partial file\n",
sc->ffindex, sample->pos);
return AVERROR_INVALIDDATA;
VAR_2 = av_get_packet(sc->pb, VAR_1, sample->size);
if (VAR_2 < 0)
return VAR_2;
if (sc->has_palette) {
uint8_t *pal;
pal = av_packet_new_side_data(VAR_1, AV_PKT_DATA_PALETTE, AVPALETTE_SIZE);
if (!pal) {
av_log(mov->fc, AV_LOG_ERROR, "Cannot append palette to packet\n");
} else {
memcpy(pal, sc->palette, AVPALETTE_SIZE);
sc->has_palette = 0;
#if CONFIG_DV_DEMUXER
if (mov->dv_demux && sc->dv_audio_container) {
avpriv_dv_produce_packet(mov->dv_demux, VAR_1, VAR_1->data, VAR_1->size, VAR_1->pos);
av_free(VAR_1->data);
VAR_1->size = 0;
VAR_2 = avpriv_dv_get_packet(mov->dv_demux, VAR_1);
if (VAR_2 < 0)
return VAR_2;
#endif
VAR_1->stream_index = sc->ffindex;
VAR_1->dts = sample->timestamp;
if (sc->ctts_data && sc->ctts_index < sc->ctts_count) {
VAR_1->pts = VAR_1->dts + sc->dts_shift + sc->ctts_data[sc->ctts_index].duration;
sc->ctts_sample++;
if (sc->ctts_index < sc->ctts_count &&
sc->ctts_data[sc->ctts_index].count == sc->ctts_sample) {
sc->ctts_index++;
sc->ctts_sample = 0;
if (sc->wrong_dts)
VAR_1->dts = AV_NOPTS_VALUE;
} else {
int64_t next_dts = (sc->current_sample < st->nb_index_entries) ?
st->index_entries[sc->current_sample].timestamp : st->duration;
VAR_1->duration = next_dts - VAR_1->dts;
VAR_1->pts = VAR_1->dts;
if (st->discard == AVDISCARD_ALL)
goto retry;
VAR_1->flags |= sample->flags & AVINDEX_KEYFRAME ? AV_PKT_FLAG_KEY : 0;
VAR_1->pos = sample->pos;
av_dlog(VAR_0, "stream %d, pts %"PRId64", dts %"PRId64", pos 0x%"PRIx64", duration %d\n",
VAR_1->stream_index, VAR_1->pts, VAR_1->dts, VAR_1->pos, VAR_1->duration);
return 0; | [
"static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)\n{",
"MOVContext *mov = VAR_0->priv_data;",
"MOVStreamContext *sc;",
"AVIndexEntry *sample;",
"AVStream *st = NULL;",
"int VAR_2;",
"mov->fc = VAR_0;",
"retry:\nsample = mov_find_next_sample(VAR_0, &st);",
"if (!sample) {",
"mov->found_mdat = 0;",
"if (!mov->next_root_atom)\nreturn AVERROR_EOF;",
"avio_seek(VAR_0->pb, mov->next_root_atom, SEEK_SET);",
"mov->next_root_atom = 0;",
"if (mov_read_default(mov, VAR_0->pb, (MOVAtom){ AV_RL32(\"root\"), INT64_MAX }) < 0 ||",
"url_feof(VAR_0->pb))\nreturn AVERROR_EOF;",
"av_dlog(VAR_0, \"read fragments, offset 0x%\"PRIx64\"\\n\", avio_tell(VAR_0->pb));",
"goto retry;",
"sc = st->priv_data;",
"sc->current_sample++;",
"if (st->discard != AVDISCARD_ALL) {",
"if (avio_seek(sc->pb, sample->pos, SEEK_SET) != sample->pos) {",
"av_log(mov->fc, AV_LOG_ERROR, \"stream %d, offset 0x%\"PRIx64\": partial file\\n\",\nsc->ffindex, sample->pos);",
"return AVERROR_INVALIDDATA;",
"VAR_2 = av_get_packet(sc->pb, VAR_1, sample->size);",
"if (VAR_2 < 0)\nreturn VAR_2;",
"if (sc->has_palette) {",
"uint8_t *pal;",
"pal = av_packet_new_side_data(VAR_1, AV_PKT_DATA_PALETTE, AVPALETTE_SIZE);",
"if (!pal) {",
"av_log(mov->fc, AV_LOG_ERROR, \"Cannot append palette to packet\\n\");",
"} else {",
"memcpy(pal, sc->palette, AVPALETTE_SIZE);",
"sc->has_palette = 0;",
"#if CONFIG_DV_DEMUXER\nif (mov->dv_demux && sc->dv_audio_container) {",
"avpriv_dv_produce_packet(mov->dv_demux, VAR_1, VAR_1->data, VAR_1->size, VAR_1->pos);",
"av_free(VAR_1->data);",
"VAR_1->size = 0;",
"VAR_2 = avpriv_dv_get_packet(mov->dv_demux, VAR_1);",
"if (VAR_2 < 0)\nreturn VAR_2;",
"#endif\nVAR_1->stream_index = sc->ffindex;",
"VAR_1->dts = sample->timestamp;",
"if (sc->ctts_data && sc->ctts_index < sc->ctts_count) {",
"VAR_1->pts = VAR_1->dts + sc->dts_shift + sc->ctts_data[sc->ctts_index].duration;",
"sc->ctts_sample++;",
"if (sc->ctts_index < sc->ctts_count &&\nsc->ctts_data[sc->ctts_index].count == sc->ctts_sample) {",
"sc->ctts_index++;",
"sc->ctts_sample = 0;",
"if (sc->wrong_dts)\nVAR_1->dts = AV_NOPTS_VALUE;",
"} else {",
"int64_t next_dts = (sc->current_sample < st->nb_index_entries) ?\nst->index_entries[sc->current_sample].timestamp : st->duration;",
"VAR_1->duration = next_dts - VAR_1->dts;",
"VAR_1->pts = VAR_1->dts;",
"if (st->discard == AVDISCARD_ALL)\ngoto retry;",
"VAR_1->flags |= sample->flags & AVINDEX_KEYFRAME ? AV_PKT_FLAG_KEY : 0;",
"VAR_1->pos = sample->pos;",
"av_dlog(VAR_0, \"stream %d, pts %\"PRId64\", dts %\"PRId64\", pos 0x%\"PRIx64\", duration %d\\n\",\nVAR_1->stream_index, VAR_1->pts, VAR_1->dts, VAR_1->pos, VAR_1->duration);",
"return 0;"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
2
],
[
3
],
[
4
],
[
5
],
[
6
],
[
7
],
[
8
],
[
9,
10
],
[
11
],
[
12
],
[
13,
14
],
[
15
],
[
16
],
[
17
],
[
18,
19
],
[
20
],
[
21
],
[
22
],
[
24
],
[
25
],
[
26
],
[
27,
28
],
[
29
],
[
30
],
[
31,
32
],
[
33
],
[
34
],
[
35
],
[
36
],
[
37
],
[
38
],
[
39
],
[
40
],
[
41,
42
],
[
43
],
[
44
],
[
45
],
[
46
],
[
47,
48
],
[
49,
50
],
[
51
],
[
52
],
[
53
],
[
55
],
[
56,
57
],
[
58
],
[
59
],
[
60,
61
],
[
62
],
[
63,
64
],
[
65
],
[
66
],
[
67,
68
],
[
69
],
[
70
],
[
71,
72
],
[
73
]
] |
22,306 | QEMUSizedBuffer *qsb_create(const uint8_t *buffer, size_t len)
{
QEMUSizedBuffer *qsb;
size_t alloc_len, num_chunks, i, to_copy;
size_t chunk_size = (len > QSB_MAX_CHUNK_SIZE)
? QSB_MAX_CHUNK_SIZE
: QSB_CHUNK_SIZE;
num_chunks = DIV_ROUND_UP(len ? len : QSB_CHUNK_SIZE, chunk_size);
alloc_len = num_chunks * chunk_size;
qsb = g_try_new0(QEMUSizedBuffer, 1);
if (!qsb) {
return NULL;
}
qsb->iov = g_try_new0(struct iovec, num_chunks);
if (!qsb->iov) {
g_free(qsb);
return NULL;
}
qsb->n_iov = num_chunks;
for (i = 0; i < num_chunks; i++) {
qsb->iov[i].iov_base = g_try_malloc0(chunk_size);
if (!qsb->iov[i].iov_base) {
/* qsb_free is safe since g_free can cope with NULL */
qsb_free(qsb);
return NULL;
}
qsb->iov[i].iov_len = chunk_size;
if (buffer) {
to_copy = (len - qsb->used) > chunk_size
? chunk_size : (len - qsb->used);
memcpy(qsb->iov[i].iov_base, &buffer[qsb->used], to_copy);
qsb->used += to_copy;
}
}
qsb->size = alloc_len;
return qsb;
}
| true | qemu | 60fe637bf0e4d7989e21e50f52526444765c63b4 | QEMUSizedBuffer *qsb_create(const uint8_t *buffer, size_t len)
{
QEMUSizedBuffer *qsb;
size_t alloc_len, num_chunks, i, to_copy;
size_t chunk_size = (len > QSB_MAX_CHUNK_SIZE)
? QSB_MAX_CHUNK_SIZE
: QSB_CHUNK_SIZE;
num_chunks = DIV_ROUND_UP(len ? len : QSB_CHUNK_SIZE, chunk_size);
alloc_len = num_chunks * chunk_size;
qsb = g_try_new0(QEMUSizedBuffer, 1);
if (!qsb) {
return NULL;
}
qsb->iov = g_try_new0(struct iovec, num_chunks);
if (!qsb->iov) {
g_free(qsb);
return NULL;
}
qsb->n_iov = num_chunks;
for (i = 0; i < num_chunks; i++) {
qsb->iov[i].iov_base = g_try_malloc0(chunk_size);
if (!qsb->iov[i].iov_base) {
qsb_free(qsb);
return NULL;
}
qsb->iov[i].iov_len = chunk_size;
if (buffer) {
to_copy = (len - qsb->used) > chunk_size
? chunk_size : (len - qsb->used);
memcpy(qsb->iov[i].iov_base, &buffer[qsb->used], to_copy);
qsb->used += to_copy;
}
}
qsb->size = alloc_len;
return qsb;
}
| {
"code": [],
"line_no": []
} | QEMUSizedBuffer *FUNC_0(const uint8_t *buffer, size_t len)
{
QEMUSizedBuffer *qsb;
size_t alloc_len, num_chunks, i, to_copy;
size_t chunk_size = (len > QSB_MAX_CHUNK_SIZE)
? QSB_MAX_CHUNK_SIZE
: QSB_CHUNK_SIZE;
num_chunks = DIV_ROUND_UP(len ? len : QSB_CHUNK_SIZE, chunk_size);
alloc_len = num_chunks * chunk_size;
qsb = g_try_new0(QEMUSizedBuffer, 1);
if (!qsb) {
return NULL;
}
qsb->iov = g_try_new0(struct iovec, num_chunks);
if (!qsb->iov) {
g_free(qsb);
return NULL;
}
qsb->n_iov = num_chunks;
for (i = 0; i < num_chunks; i++) {
qsb->iov[i].iov_base = g_try_malloc0(chunk_size);
if (!qsb->iov[i].iov_base) {
qsb_free(qsb);
return NULL;
}
qsb->iov[i].iov_len = chunk_size;
if (buffer) {
to_copy = (len - qsb->used) > chunk_size
? chunk_size : (len - qsb->used);
memcpy(qsb->iov[i].iov_base, &buffer[qsb->used], to_copy);
qsb->used += to_copy;
}
}
qsb->size = alloc_len;
return qsb;
}
| [
"QEMUSizedBuffer *FUNC_0(const uint8_t *buffer, size_t len)\n{",
"QEMUSizedBuffer *qsb;",
"size_t alloc_len, num_chunks, i, to_copy;",
"size_t chunk_size = (len > QSB_MAX_CHUNK_SIZE)\n? QSB_MAX_CHUNK_SIZE\n: QSB_CHUNK_SIZE;",
"num_chunks = DIV_ROUND_UP(len ? len : QSB_CHUNK_SIZE, chunk_size);",
"alloc_len = num_chunks * chunk_size;",
"qsb = g_try_new0(QEMUSizedBuffer, 1);",
"if (!qsb) {",
"return NULL;",
"}",
"qsb->iov = g_try_new0(struct iovec, num_chunks);",
"if (!qsb->iov) {",
"g_free(qsb);",
"return NULL;",
"}",
"qsb->n_iov = num_chunks;",
"for (i = 0; i < num_chunks; i++) {",
"qsb->iov[i].iov_base = g_try_malloc0(chunk_size);",
"if (!qsb->iov[i].iov_base) {",
"qsb_free(qsb);",
"return NULL;",
"}",
"qsb->iov[i].iov_len = chunk_size;",
"if (buffer) {",
"to_copy = (len - qsb->used) > chunk_size\n? chunk_size : (len - qsb->used);",
"memcpy(qsb->iov[i].iov_base, &buffer[qsb->used], to_copy);",
"qsb->used += to_copy;",
"}",
"}",
"qsb->size = alloc_len;",
"return qsb;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9,
11,
13
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69,
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
87
],
[
89
]
] |
22,307 | static void virtio_notify_vector(VirtIODevice *vdev, uint16_t vector)
{
BusState *qbus = qdev_get_parent_bus(DEVICE(vdev));
VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
if (k->notify) {
k->notify(qbus->parent, vector); | true | qemu | f5ed36635d8fa73feb66fe12b3b9c2ed90a1adbe | static void virtio_notify_vector(VirtIODevice *vdev, uint16_t vector)
{
BusState *qbus = qdev_get_parent_bus(DEVICE(vdev));
VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
if (k->notify) {
k->notify(qbus->parent, vector); | {
"code": [],
"line_no": []
} | static void FUNC_0(VirtIODevice *VAR_0, uint16_t VAR_1)
{
BusState *qbus = qdev_get_parent_bus(DEVICE(VAR_0));
VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
if (k->notify) {
k->notify(qbus->parent, VAR_1); | [
"static void FUNC_0(VirtIODevice *VAR_0, uint16_t VAR_1)\n{",
"BusState *qbus = qdev_get_parent_bus(DEVICE(VAR_0));",
"VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);",
"if (k->notify) {",
"k->notify(qbus->parent, VAR_1);"
] | [
0,
0,
0,
0,
0
] | [
[
1,
2
],
[
3
],
[
4
],
[
5
],
[
6
]
] |
22,308 | static int svq1_motion_inter_4v_block(DSPContext *dsp, GetBitContext *bitbuf,
uint8_t *current, uint8_t *previous,
int pitch, svq1_pmv *motion, int x, int y)
{
uint8_t *src;
uint8_t *dst;
svq1_pmv mv;
svq1_pmv *pmv[4];
int i, result;
/* predict and decode motion vector (0) */
pmv[0] = &motion[0];
if (y == 0) {
pmv[1] =
pmv[2] = pmv[0];
} else {
pmv[1] = &motion[(x / 8) + 2];
pmv[2] = &motion[(x / 8) + 4];
}
result = svq1_decode_motion_vector(bitbuf, &mv, pmv);
if (result != 0)
return result;
/* predict and decode motion vector (1) */
pmv[0] = &mv;
if (y == 0) {
pmv[1] =
pmv[2] = pmv[0];
} else {
pmv[1] = &motion[(x / 8) + 3];
}
result = svq1_decode_motion_vector(bitbuf, &motion[0], pmv);
if (result != 0)
return result;
/* predict and decode motion vector (2) */
pmv[1] = &motion[0];
pmv[2] = &motion[(x / 8) + 1];
result = svq1_decode_motion_vector(bitbuf, &motion[(x / 8) + 2], pmv);
if (result != 0)
return result;
/* predict and decode motion vector (3) */
pmv[2] = &motion[(x / 8) + 2];
pmv[3] = &motion[(x / 8) + 3];
result = svq1_decode_motion_vector(bitbuf, pmv[3], pmv);
if (result != 0)
return result;
/* form predictions */
for (i = 0; i < 4; i++) {
int mvx = pmv[i]->x + (i & 1) * 16;
int mvy = pmv[i]->y + (i >> 1) * 16;
// FIXME: clipping or padding?
if (y + (mvy >> 1) < 0)
mvy = 0;
if (x + (mvx >> 1) < 0)
mvx = 0;
src = &previous[(x + (mvx >> 1)) + (y + (mvy >> 1)) * pitch];
dst = current;
dsp->put_pixels_tab[1][((mvy & 1) << 1) | (mvx & 1)](dst, src, pitch, 8);
/* select next block */
if (i & 1)
current += 8 * (pitch - 1);
else
current += 8;
}
return 0;
}
| true | FFmpeg | ecff5acb5a738fcb4f9e206a12070dac4bf259b3 | static int svq1_motion_inter_4v_block(DSPContext *dsp, GetBitContext *bitbuf,
uint8_t *current, uint8_t *previous,
int pitch, svq1_pmv *motion, int x, int y)
{
uint8_t *src;
uint8_t *dst;
svq1_pmv mv;
svq1_pmv *pmv[4];
int i, result;
pmv[0] = &motion[0];
if (y == 0) {
pmv[1] =
pmv[2] = pmv[0];
} else {
pmv[1] = &motion[(x / 8) + 2];
pmv[2] = &motion[(x / 8) + 4];
}
result = svq1_decode_motion_vector(bitbuf, &mv, pmv);
if (result != 0)
return result;
pmv[0] = &mv;
if (y == 0) {
pmv[1] =
pmv[2] = pmv[0];
} else {
pmv[1] = &motion[(x / 8) + 3];
}
result = svq1_decode_motion_vector(bitbuf, &motion[0], pmv);
if (result != 0)
return result;
pmv[1] = &motion[0];
pmv[2] = &motion[(x / 8) + 1];
result = svq1_decode_motion_vector(bitbuf, &motion[(x / 8) + 2], pmv);
if (result != 0)
return result;
pmv[2] = &motion[(x / 8) + 2];
pmv[3] = &motion[(x / 8) + 3];
result = svq1_decode_motion_vector(bitbuf, pmv[3], pmv);
if (result != 0)
return result;
for (i = 0; i < 4; i++) {
int mvx = pmv[i]->x + (i & 1) * 16;
int mvy = pmv[i]->y + (i >> 1) * 16;
if (y + (mvy >> 1) < 0)
mvy = 0;
if (x + (mvx >> 1) < 0)
mvx = 0;
src = &previous[(x + (mvx >> 1)) + (y + (mvy >> 1)) * pitch];
dst = current;
dsp->put_pixels_tab[1][((mvy & 1) << 1) | (mvx & 1)](dst, src, pitch, 8);
if (i & 1)
current += 8 * (pitch - 1);
else
current += 8;
}
return 0;
}
| {
"code": [
" int pitch, svq1_pmv *motion, int x, int y)",
" if (y + (mvy >> 1) < 0)",
" mvy = 0;",
" if (x + (mvx >> 1) < 0)",
" mvx = 0;"
],
"line_no": [
5,
125,
127,
129,
131
]
} | static int FUNC_0(DSPContext *VAR_0, GetBitContext *VAR_1,
uint8_t *VAR_2, uint8_t *VAR_3,
int VAR_4, svq1_pmv *VAR_5, int VAR_6, int VAR_7)
{
uint8_t *src;
uint8_t *dst;
svq1_pmv mv;
svq1_pmv *pmv[4];
int VAR_8, VAR_9;
pmv[0] = &VAR_5[0];
if (VAR_7 == 0) {
pmv[1] =
pmv[2] = pmv[0];
} else {
pmv[1] = &VAR_5[(VAR_6 / 8) + 2];
pmv[2] = &VAR_5[(VAR_6 / 8) + 4];
}
VAR_9 = svq1_decode_motion_vector(VAR_1, &mv, pmv);
if (VAR_9 != 0)
return VAR_9;
pmv[0] = &mv;
if (VAR_7 == 0) {
pmv[1] =
pmv[2] = pmv[0];
} else {
pmv[1] = &VAR_5[(VAR_6 / 8) + 3];
}
VAR_9 = svq1_decode_motion_vector(VAR_1, &VAR_5[0], pmv);
if (VAR_9 != 0)
return VAR_9;
pmv[1] = &VAR_5[0];
pmv[2] = &VAR_5[(VAR_6 / 8) + 1];
VAR_9 = svq1_decode_motion_vector(VAR_1, &VAR_5[(VAR_6 / 8) + 2], pmv);
if (VAR_9 != 0)
return VAR_9;
pmv[2] = &VAR_5[(VAR_6 / 8) + 2];
pmv[3] = &VAR_5[(VAR_6 / 8) + 3];
VAR_9 = svq1_decode_motion_vector(VAR_1, pmv[3], pmv);
if (VAR_9 != 0)
return VAR_9;
for (VAR_8 = 0; VAR_8 < 4; VAR_8++) {
int VAR_10 = pmv[VAR_8]->VAR_6 + (VAR_8 & 1) * 16;
int VAR_11 = pmv[VAR_8]->VAR_7 + (VAR_8 >> 1) * 16;
if (VAR_7 + (VAR_11 >> 1) < 0)
VAR_11 = 0;
if (VAR_6 + (VAR_10 >> 1) < 0)
VAR_10 = 0;
src = &VAR_3[(VAR_6 + (VAR_10 >> 1)) + (VAR_7 + (VAR_11 >> 1)) * VAR_4];
dst = VAR_2;
VAR_0->put_pixels_tab[1][((VAR_11 & 1) << 1) | (VAR_10 & 1)](dst, src, VAR_4, 8);
if (VAR_8 & 1)
VAR_2 += 8 * (VAR_4 - 1);
else
VAR_2 += 8;
}
return 0;
}
| [
"static int FUNC_0(DSPContext *VAR_0, GetBitContext *VAR_1,\nuint8_t *VAR_2, uint8_t *VAR_3,\nint VAR_4, svq1_pmv *VAR_5, int VAR_6, int VAR_7)\n{",
"uint8_t *src;",
"uint8_t *dst;",
"svq1_pmv mv;",
"svq1_pmv *pmv[4];",
"int VAR_8, VAR_9;",
"pmv[0] = &VAR_5[0];",
"if (VAR_7 == 0) {",
"pmv[1] =\npmv[2] = pmv[0];",
"} else {",
"pmv[1] = &VAR_5[(VAR_6 / 8) + 2];",
"pmv[2] = &VAR_5[(VAR_6 / 8) + 4];",
"}",
"VAR_9 = svq1_decode_motion_vector(VAR_1, &mv, pmv);",
"if (VAR_9 != 0)\nreturn VAR_9;",
"pmv[0] = &mv;",
"if (VAR_7 == 0) {",
"pmv[1] =\npmv[2] = pmv[0];",
"} else {",
"pmv[1] = &VAR_5[(VAR_6 / 8) + 3];",
"}",
"VAR_9 = svq1_decode_motion_vector(VAR_1, &VAR_5[0], pmv);",
"if (VAR_9 != 0)\nreturn VAR_9;",
"pmv[1] = &VAR_5[0];",
"pmv[2] = &VAR_5[(VAR_6 / 8) + 1];",
"VAR_9 = svq1_decode_motion_vector(VAR_1, &VAR_5[(VAR_6 / 8) + 2], pmv);",
"if (VAR_9 != 0)\nreturn VAR_9;",
"pmv[2] = &VAR_5[(VAR_6 / 8) + 2];",
"pmv[3] = &VAR_5[(VAR_6 / 8) + 3];",
"VAR_9 = svq1_decode_motion_vector(VAR_1, pmv[3], pmv);",
"if (VAR_9 != 0)\nreturn VAR_9;",
"for (VAR_8 = 0; VAR_8 < 4; VAR_8++) {",
"int VAR_10 = pmv[VAR_8]->VAR_6 + (VAR_8 & 1) * 16;",
"int VAR_11 = pmv[VAR_8]->VAR_7 + (VAR_8 >> 1) * 16;",
"if (VAR_7 + (VAR_11 >> 1) < 0)\nVAR_11 = 0;",
"if (VAR_6 + (VAR_10 >> 1) < 0)\nVAR_10 = 0;",
"src = &VAR_3[(VAR_6 + (VAR_10 >> 1)) + (VAR_7 + (VAR_11 >> 1)) * VAR_4];",
"dst = VAR_2;",
"VAR_0->put_pixels_tab[1][((VAR_11 & 1) << 1) | (VAR_10 & 1)](dst, src, VAR_4, 8);",
"if (VAR_8 & 1)\nVAR_2 += 8 * (VAR_4 - 1);",
"else\nVAR_2 += 8;",
"}",
"return 0;",
"}"
] | [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
23
],
[
25
],
[
27,
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
45,
47
],
[
53
],
[
55
],
[
57,
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71,
73
],
[
79
],
[
81
],
[
85
],
[
89,
91
],
[
97
],
[
99
],
[
103
],
[
107,
109
],
[
115
],
[
117
],
[
119
],
[
125,
127
],
[
129,
131
],
[
135
],
[
137
],
[
141
],
[
147,
149
],
[
151,
153
],
[
155
],
[
159
],
[
161
]
] |
22,309 | CPUState *cpu_create(const char *typename)
{
Error *err = NULL;
CPUState *cpu = CPU(object_new(typename));
object_property_set_bool(OBJECT(cpu), true, "realized", &err);
if (err != NULL) {
error_report_err(err);
object_unref(OBJECT(cpu));
return NULL;
}
return cpu;
}
| true | qemu | 4482e05cbbb7e50e476f6a9500cf0b38913bd939 | CPUState *cpu_create(const char *typename)
{
Error *err = NULL;
CPUState *cpu = CPU(object_new(typename));
object_property_set_bool(OBJECT(cpu), true, "realized", &err);
if (err != NULL) {
error_report_err(err);
object_unref(OBJECT(cpu));
return NULL;
}
return cpu;
}
| {
"code": [
" return NULL;",
" Error *err = NULL;",
" return NULL;",
" if (err != NULL) {",
" error_report_err(err);",
" return NULL;"
],
"line_no": [
17,
5,
17,
11,
13,
17
]
} | CPUState *FUNC_0(const char *typename)
{
Error *err = NULL;
CPUState *cpu = CPU(object_new(typename));
object_property_set_bool(OBJECT(cpu), true, "realized", &err);
if (err != NULL) {
error_report_err(err);
object_unref(OBJECT(cpu));
return NULL;
}
return cpu;
}
| [
"CPUState *FUNC_0(const char *typename)\n{",
"Error *err = NULL;",
"CPUState *cpu = CPU(object_new(typename));",
"object_property_set_bool(OBJECT(cpu), true, \"realized\", &err);",
"if (err != NULL) {",
"error_report_err(err);",
"object_unref(OBJECT(cpu));",
"return NULL;",
"}",
"return cpu;",
"}"
] | [
0,
1,
0,
0,
1,
1,
0,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
]
] |
22,310 | static int qio_channel_socket_connect_worker(QIOTask *task,
Error **errp,
gpointer opaque)
{
QIOChannelSocket *ioc = QIO_CHANNEL_SOCKET(qio_task_get_source(task));
SocketAddress *addr = opaque;
int ret;
ret = qio_channel_socket_connect_sync(ioc,
addr,
errp);
object_unref(OBJECT(ioc));
return ret;
}
| true | qemu | 937470bb5470825e781ae50e92ff973a6b54d80f | static int qio_channel_socket_connect_worker(QIOTask *task,
Error **errp,
gpointer opaque)
{
QIOChannelSocket *ioc = QIO_CHANNEL_SOCKET(qio_task_get_source(task));
SocketAddress *addr = opaque;
int ret;
ret = qio_channel_socket_connect_sync(ioc,
addr,
errp);
object_unref(OBJECT(ioc));
return ret;
}
| {
"code": [
" object_unref(OBJECT(ioc));",
" object_unref(OBJECT(ioc));",
" object_unref(OBJECT(ioc));"
],
"line_no": [
25,
25,
25
]
} | static int FUNC_0(QIOTask *VAR_0,
Error **VAR_1,
gpointer VAR_2)
{
QIOChannelSocket *ioc = QIO_CHANNEL_SOCKET(qio_task_get_source(VAR_0));
SocketAddress *addr = VAR_2;
int VAR_3;
VAR_3 = qio_channel_socket_connect_sync(ioc,
addr,
VAR_1);
object_unref(OBJECT(ioc));
return VAR_3;
}
| [
"static int FUNC_0(QIOTask *VAR_0,\nError **VAR_1,\ngpointer VAR_2)\n{",
"QIOChannelSocket *ioc = QIO_CHANNEL_SOCKET(qio_task_get_source(VAR_0));",
"SocketAddress *addr = VAR_2;",
"int VAR_3;",
"VAR_3 = qio_channel_socket_connect_sync(ioc,\naddr,\nVAR_1);",
"object_unref(OBJECT(ioc));",
"return VAR_3;",
"}"
] | [
0,
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
17,
19,
21
],
[
25
],
[
27
],
[
29
]
] |
22,311 | static const void *boston_kernel_filter(void *opaque, const void *kernel,
hwaddr *load_addr, hwaddr *entry_addr)
{
BostonState *s = BOSTON(opaque);
s->kernel_entry = *entry_addr;
return kernel;
}
| true | qemu | 2d896b454a0e19ec4c1ddbb0e0b65b7e54fcedf3 | static const void *boston_kernel_filter(void *opaque, const void *kernel,
hwaddr *load_addr, hwaddr *entry_addr)
{
BostonState *s = BOSTON(opaque);
s->kernel_entry = *entry_addr;
return kernel;
}
| {
"code": [
" BostonState *s = BOSTON(opaque);",
"static const void *boston_kernel_filter(void *opaque, const void *kernel,",
" hwaddr *load_addr, hwaddr *entry_addr)",
" BostonState *s = BOSTON(opaque);",
" s->kernel_entry = *entry_addr;",
" return kernel;"
],
"line_no": [
7,
1,
3,
7,
11,
15
]
} | static const void *FUNC_0(void *VAR_0, const void *VAR_1,
hwaddr *VAR_2, hwaddr *VAR_3)
{
BostonState *s = BOSTON(VAR_0);
s->kernel_entry = *VAR_3;
return VAR_1;
}
| [
"static const void *FUNC_0(void *VAR_0, const void *VAR_1,\nhwaddr *VAR_2, hwaddr *VAR_3)\n{",
"BostonState *s = BOSTON(VAR_0);",
"s->kernel_entry = *VAR_3;",
"return VAR_1;",
"}"
] | [
1,
1,
1,
1,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
15
],
[
17
]
] |
22,312 | static av_always_inline void idct_mb(VP8Context *s, uint8_t *dst[3], VP8Macroblock *mb)
{
int x, y, ch;
if (mb->mode != MODE_I4x4) {
uint8_t *y_dst = dst[0];
for (y = 0; y < 4; y++) {
uint32_t nnz4 = AV_RL32(s->non_zero_count_cache[y]);
if (nnz4) {
if (nnz4&~0x01010101) {
for (x = 0; x < 4; x++) {
if ((uint8_t)nnz4 == 1)
s->vp8dsp.vp8_idct_dc_add(y_dst+4*x, s->block[y][x], s->linesize);
else if((uint8_t)nnz4 > 1)
s->vp8dsp.vp8_idct_add(y_dst+4*x, s->block[y][x], s->linesize);
nnz4 >>= 8;
if (!nnz4)
break;
}
} else {
s->vp8dsp.vp8_idct_dc_add4y(y_dst, s->block[y], s->linesize);
}
}
y_dst += 4*s->linesize;
}
}
for (ch = 0; ch < 2; ch++) {
uint32_t nnz4 = AV_RL32(s->non_zero_count_cache[4+ch]);
if (nnz4) {
uint8_t *ch_dst = dst[1+ch];
if (nnz4&~0x01010101) {
for (y = 0; y < 2; y++) {
for (x = 0; x < 2; x++) {
if ((uint8_t)nnz4 == 1)
s->vp8dsp.vp8_idct_dc_add(ch_dst+4*x, s->block[4+ch][(y<<1)+x], s->uvlinesize);
else if((uint8_t)nnz4 > 1)
s->vp8dsp.vp8_idct_add(ch_dst+4*x, s->block[4+ch][(y<<1)+x], s->uvlinesize);
nnz4 >>= 8;
if (!nnz4)
break;
}
ch_dst += 4*s->uvlinesize;
}
} else {
s->vp8dsp.vp8_idct_dc_add4uv(ch_dst, s->block[4+ch], s->uvlinesize);
}
}
}
}
| false | FFmpeg | 628b48db85dae7ad212a63dafcd6a3bf8d8e93f3 | static av_always_inline void idct_mb(VP8Context *s, uint8_t *dst[3], VP8Macroblock *mb)
{
int x, y, ch;
if (mb->mode != MODE_I4x4) {
uint8_t *y_dst = dst[0];
for (y = 0; y < 4; y++) {
uint32_t nnz4 = AV_RL32(s->non_zero_count_cache[y]);
if (nnz4) {
if (nnz4&~0x01010101) {
for (x = 0; x < 4; x++) {
if ((uint8_t)nnz4 == 1)
s->vp8dsp.vp8_idct_dc_add(y_dst+4*x, s->block[y][x], s->linesize);
else if((uint8_t)nnz4 > 1)
s->vp8dsp.vp8_idct_add(y_dst+4*x, s->block[y][x], s->linesize);
nnz4 >>= 8;
if (!nnz4)
break;
}
} else {
s->vp8dsp.vp8_idct_dc_add4y(y_dst, s->block[y], s->linesize);
}
}
y_dst += 4*s->linesize;
}
}
for (ch = 0; ch < 2; ch++) {
uint32_t nnz4 = AV_RL32(s->non_zero_count_cache[4+ch]);
if (nnz4) {
uint8_t *ch_dst = dst[1+ch];
if (nnz4&~0x01010101) {
for (y = 0; y < 2; y++) {
for (x = 0; x < 2; x++) {
if ((uint8_t)nnz4 == 1)
s->vp8dsp.vp8_idct_dc_add(ch_dst+4*x, s->block[4+ch][(y<<1)+x], s->uvlinesize);
else if((uint8_t)nnz4 > 1)
s->vp8dsp.vp8_idct_add(ch_dst+4*x, s->block[4+ch][(y<<1)+x], s->uvlinesize);
nnz4 >>= 8;
if (!nnz4)
break;
}
ch_dst += 4*s->uvlinesize;
}
} else {
s->vp8dsp.vp8_idct_dc_add4uv(ch_dst, s->block[4+ch], s->uvlinesize);
}
}
}
}
| {
"code": [],
"line_no": []
} | static av_always_inline void FUNC_0(VP8Context *s, uint8_t *dst[3], VP8Macroblock *mb)
{
int VAR_0, VAR_1, VAR_2;
if (mb->mode != MODE_I4x4) {
uint8_t *y_dst = dst[0];
for (VAR_1 = 0; VAR_1 < 4; VAR_1++) {
uint32_t nnz4 = AV_RL32(s->non_zero_count_cache[VAR_1]);
if (nnz4) {
if (nnz4&~0x01010101) {
for (VAR_0 = 0; VAR_0 < 4; VAR_0++) {
if ((uint8_t)nnz4 == 1)
s->vp8dsp.vp8_idct_dc_add(y_dst+4*VAR_0, s->block[VAR_1][VAR_0], s->linesize);
else if((uint8_t)nnz4 > 1)
s->vp8dsp.vp8_idct_add(y_dst+4*VAR_0, s->block[VAR_1][VAR_0], s->linesize);
nnz4 >>= 8;
if (!nnz4)
break;
}
} else {
s->vp8dsp.vp8_idct_dc_add4y(y_dst, s->block[VAR_1], s->linesize);
}
}
y_dst += 4*s->linesize;
}
}
for (VAR_2 = 0; VAR_2 < 2; VAR_2++) {
uint32_t nnz4 = AV_RL32(s->non_zero_count_cache[4+VAR_2]);
if (nnz4) {
uint8_t *ch_dst = dst[1+VAR_2];
if (nnz4&~0x01010101) {
for (VAR_1 = 0; VAR_1 < 2; VAR_1++) {
for (VAR_0 = 0; VAR_0 < 2; VAR_0++) {
if ((uint8_t)nnz4 == 1)
s->vp8dsp.vp8_idct_dc_add(ch_dst+4*VAR_0, s->block[4+VAR_2][(VAR_1<<1)+VAR_0], s->uvlinesize);
else if((uint8_t)nnz4 > 1)
s->vp8dsp.vp8_idct_add(ch_dst+4*VAR_0, s->block[4+VAR_2][(VAR_1<<1)+VAR_0], s->uvlinesize);
nnz4 >>= 8;
if (!nnz4)
break;
}
ch_dst += 4*s->uvlinesize;
}
} else {
s->vp8dsp.vp8_idct_dc_add4uv(ch_dst, s->block[4+VAR_2], s->uvlinesize);
}
}
}
}
| [
"static av_always_inline void FUNC_0(VP8Context *s, uint8_t *dst[3], VP8Macroblock *mb)\n{",
"int VAR_0, VAR_1, VAR_2;",
"if (mb->mode != MODE_I4x4) {",
"uint8_t *y_dst = dst[0];",
"for (VAR_1 = 0; VAR_1 < 4; VAR_1++) {",
"uint32_t nnz4 = AV_RL32(s->non_zero_count_cache[VAR_1]);",
"if (nnz4) {",
"if (nnz4&~0x01010101) {",
"for (VAR_0 = 0; VAR_0 < 4; VAR_0++) {",
"if ((uint8_t)nnz4 == 1)\ns->vp8dsp.vp8_idct_dc_add(y_dst+4*VAR_0, s->block[VAR_1][VAR_0], s->linesize);",
"else if((uint8_t)nnz4 > 1)\ns->vp8dsp.vp8_idct_add(y_dst+4*VAR_0, s->block[VAR_1][VAR_0], s->linesize);",
"nnz4 >>= 8;",
"if (!nnz4)\nbreak;",
"}",
"} else {",
"s->vp8dsp.vp8_idct_dc_add4y(y_dst, s->block[VAR_1], s->linesize);",
"}",
"}",
"y_dst += 4*s->linesize;",
"}",
"}",
"for (VAR_2 = 0; VAR_2 < 2; VAR_2++) {",
"uint32_t nnz4 = AV_RL32(s->non_zero_count_cache[4+VAR_2]);",
"if (nnz4) {",
"uint8_t *ch_dst = dst[1+VAR_2];",
"if (nnz4&~0x01010101) {",
"for (VAR_1 = 0; VAR_1 < 2; VAR_1++) {",
"for (VAR_0 = 0; VAR_0 < 2; VAR_0++) {",
"if ((uint8_t)nnz4 == 1)\ns->vp8dsp.vp8_idct_dc_add(ch_dst+4*VAR_0, s->block[4+VAR_2][(VAR_1<<1)+VAR_0], s->uvlinesize);",
"else if((uint8_t)nnz4 > 1)\ns->vp8dsp.vp8_idct_add(ch_dst+4*VAR_0, s->block[4+VAR_2][(VAR_1<<1)+VAR_0], s->uvlinesize);",
"nnz4 >>= 8;",
"if (!nnz4)\nbreak;",
"}",
"ch_dst += 4*s->uvlinesize;",
"}",
"} else {",
"s->vp8dsp.vp8_idct_dc_add4uv(ch_dst, s->block[4+VAR_2], s->uvlinesize);",
"}",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23,
25
],
[
27,
29
],
[
31
],
[
33,
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69,
71
],
[
73,
75
],
[
77
],
[
79,
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
]
] |
22,314 | PCIDevice *virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn)
{
VirtIONet *n;
static int virtio_net_id;
n = (VirtIONet *)virtio_init_pci(bus, "virtio-net",
PCI_VENDOR_ID_REDHAT_QUMRANET,
PCI_DEVICE_ID_VIRTIO_NET,
PCI_VENDOR_ID_REDHAT_QUMRANET,
VIRTIO_ID_NET,
PCI_CLASS_NETWORK_ETHERNET, 0x00,
sizeof(struct virtio_net_config),
sizeof(VirtIONet));
if (!n)
return NULL;
n->vdev.get_config = virtio_net_get_config;
n->vdev.set_config = virtio_net_set_config;
n->vdev.get_features = virtio_net_get_features;
n->vdev.set_features = virtio_net_set_features;
n->vdev.bad_features = virtio_net_bad_features;
n->vdev.reset = virtio_net_reset;
n->rx_vq = virtio_add_queue(&n->vdev, 256, virtio_net_handle_rx);
n->tx_vq = virtio_add_queue(&n->vdev, 256, virtio_net_handle_tx);
n->ctrl_vq = virtio_add_queue(&n->vdev, 16, virtio_net_handle_ctrl);
memcpy(n->mac, nd->macaddr, ETH_ALEN);
n->status = VIRTIO_NET_S_LINK_UP;
n->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
virtio_net_receive, virtio_net_can_receive, n);
n->vc->link_status_changed = virtio_net_set_link_status;
qemu_format_nic_info_str(n->vc, n->mac);
n->tx_timer = qemu_new_timer(vm_clock, virtio_net_tx_timer, n);
n->tx_timer_active = 0;
n->mergeable_rx_bufs = 0;
n->promisc = 1; /* for compatibility */
n->mac_table.macs = qemu_mallocz(MAC_TABLE_ENTRIES * ETH_ALEN);
n->vlans = qemu_mallocz(MAX_VLAN >> 3);
register_savevm("virtio-net", virtio_net_id++, VIRTIO_NET_VM_VERSION,
virtio_net_save, virtio_net_load, n);
return (PCIDevice *)n;
}
| true | qemu | b946a1533209f61a93e34898aebb5b43154b99c3 | PCIDevice *virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn)
{
VirtIONet *n;
static int virtio_net_id;
n = (VirtIONet *)virtio_init_pci(bus, "virtio-net",
PCI_VENDOR_ID_REDHAT_QUMRANET,
PCI_DEVICE_ID_VIRTIO_NET,
PCI_VENDOR_ID_REDHAT_QUMRANET,
VIRTIO_ID_NET,
PCI_CLASS_NETWORK_ETHERNET, 0x00,
sizeof(struct virtio_net_config),
sizeof(VirtIONet));
if (!n)
return NULL;
n->vdev.get_config = virtio_net_get_config;
n->vdev.set_config = virtio_net_set_config;
n->vdev.get_features = virtio_net_get_features;
n->vdev.set_features = virtio_net_set_features;
n->vdev.bad_features = virtio_net_bad_features;
n->vdev.reset = virtio_net_reset;
n->rx_vq = virtio_add_queue(&n->vdev, 256, virtio_net_handle_rx);
n->tx_vq = virtio_add_queue(&n->vdev, 256, virtio_net_handle_tx);
n->ctrl_vq = virtio_add_queue(&n->vdev, 16, virtio_net_handle_ctrl);
memcpy(n->mac, nd->macaddr, ETH_ALEN);
n->status = VIRTIO_NET_S_LINK_UP;
n->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
virtio_net_receive, virtio_net_can_receive, n);
n->vc->link_status_changed = virtio_net_set_link_status;
qemu_format_nic_info_str(n->vc, n->mac);
n->tx_timer = qemu_new_timer(vm_clock, virtio_net_tx_timer, n);
n->tx_timer_active = 0;
n->mergeable_rx_bufs = 0;
n->promisc = 1;
n->mac_table.macs = qemu_mallocz(MAC_TABLE_ENTRIES * ETH_ALEN);
n->vlans = qemu_mallocz(MAX_VLAN >> 3);
register_savevm("virtio-net", virtio_net_id++, VIRTIO_NET_VM_VERSION,
virtio_net_save, virtio_net_load, n);
return (PCIDevice *)n;
}
| {
"code": [
" virtio_net_receive, virtio_net_can_receive, n);"
],
"line_no": [
57
]
} | PCIDevice *FUNC_0(PCIBus *bus, NICInfo *nd, int devfn)
{
VirtIONet *n;
static int VAR_0;
n = (VirtIONet *)virtio_init_pci(bus, "virtio-net",
PCI_VENDOR_ID_REDHAT_QUMRANET,
PCI_DEVICE_ID_VIRTIO_NET,
PCI_VENDOR_ID_REDHAT_QUMRANET,
VIRTIO_ID_NET,
PCI_CLASS_NETWORK_ETHERNET, 0x00,
sizeof(struct virtio_net_config),
sizeof(VirtIONet));
if (!n)
return NULL;
n->vdev.get_config = virtio_net_get_config;
n->vdev.set_config = virtio_net_set_config;
n->vdev.get_features = virtio_net_get_features;
n->vdev.set_features = virtio_net_set_features;
n->vdev.bad_features = virtio_net_bad_features;
n->vdev.reset = virtio_net_reset;
n->rx_vq = virtio_add_queue(&n->vdev, 256, virtio_net_handle_rx);
n->tx_vq = virtio_add_queue(&n->vdev, 256, virtio_net_handle_tx);
n->ctrl_vq = virtio_add_queue(&n->vdev, 16, virtio_net_handle_ctrl);
memcpy(n->mac, nd->macaddr, ETH_ALEN);
n->status = VIRTIO_NET_S_LINK_UP;
n->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
virtio_net_receive, virtio_net_can_receive, n);
n->vc->link_status_changed = virtio_net_set_link_status;
qemu_format_nic_info_str(n->vc, n->mac);
n->tx_timer = qemu_new_timer(vm_clock, virtio_net_tx_timer, n);
n->tx_timer_active = 0;
n->mergeable_rx_bufs = 0;
n->promisc = 1;
n->mac_table.macs = qemu_mallocz(MAC_TABLE_ENTRIES * ETH_ALEN);
n->vlans = qemu_mallocz(MAX_VLAN >> 3);
register_savevm("virtio-net", VAR_0++, VIRTIO_NET_VM_VERSION,
virtio_net_save, virtio_net_load, n);
return (PCIDevice *)n;
}
| [
"PCIDevice *FUNC_0(PCIBus *bus, NICInfo *nd, int devfn)\n{",
"VirtIONet *n;",
"static int VAR_0;",
"n = (VirtIONet *)virtio_init_pci(bus, \"virtio-net\",\nPCI_VENDOR_ID_REDHAT_QUMRANET,\nPCI_DEVICE_ID_VIRTIO_NET,\nPCI_VENDOR_ID_REDHAT_QUMRANET,\nVIRTIO_ID_NET,\nPCI_CLASS_NETWORK_ETHERNET, 0x00,\nsizeof(struct virtio_net_config),\nsizeof(VirtIONet));",
"if (!n)\nreturn NULL;",
"n->vdev.get_config = virtio_net_get_config;",
"n->vdev.set_config = virtio_net_set_config;",
"n->vdev.get_features = virtio_net_get_features;",
"n->vdev.set_features = virtio_net_set_features;",
"n->vdev.bad_features = virtio_net_bad_features;",
"n->vdev.reset = virtio_net_reset;",
"n->rx_vq = virtio_add_queue(&n->vdev, 256, virtio_net_handle_rx);",
"n->tx_vq = virtio_add_queue(&n->vdev, 256, virtio_net_handle_tx);",
"n->ctrl_vq = virtio_add_queue(&n->vdev, 16, virtio_net_handle_ctrl);",
"memcpy(n->mac, nd->macaddr, ETH_ALEN);",
"n->status = VIRTIO_NET_S_LINK_UP;",
"n->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,\nvirtio_net_receive, virtio_net_can_receive, n);",
"n->vc->link_status_changed = virtio_net_set_link_status;",
"qemu_format_nic_info_str(n->vc, n->mac);",
"n->tx_timer = qemu_new_timer(vm_clock, virtio_net_tx_timer, n);",
"n->tx_timer_active = 0;",
"n->mergeable_rx_bufs = 0;",
"n->promisc = 1;",
"n->mac_table.macs = qemu_mallocz(MAC_TABLE_ENTRIES * ETH_ALEN);",
"n->vlans = qemu_mallocz(MAX_VLAN >> 3);",
"register_savevm(\"virtio-net\", VAR_0++, VIRTIO_NET_VM_VERSION,\nvirtio_net_save, virtio_net_load, n);",
"return (PCIDevice *)n;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13,
15,
17,
19,
21,
23,
25
],
[
27,
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55,
57
],
[
59
],
[
63
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77
],
[
81
],
[
85,
87
],
[
89
],
[
91
]
] |
22,317 | static inline void RENAME(rgb15to16)(const uint8_t *src, uint8_t *dst, int src_size)
{
register const uint8_t* s=src;
register uint8_t* d=dst;
register const uint8_t *end;
const uint8_t *mm_end;
end = s + src_size;
__asm__ volatile(PREFETCH" %0"::"m"(*s));
__asm__ volatile("movq %0, %%mm4"::"m"(mask15s));
mm_end = end - 15;
while (s<mm_end) {
__asm__ volatile(
PREFETCH" 32%1 \n\t"
"movq %1, %%mm0 \n\t"
"movq 8%1, %%mm2 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm2, %%mm3 \n\t"
"pand %%mm4, %%mm0 \n\t"
"pand %%mm4, %%mm2 \n\t"
"paddw %%mm1, %%mm0 \n\t"
"paddw %%mm3, %%mm2 \n\t"
MOVNTQ" %%mm0, %0 \n\t"
MOVNTQ" %%mm2, 8%0"
:"=m"(*d)
:"m"(*s)
);
d+=16;
s+=16;
}
__asm__ volatile(SFENCE:::"memory");
__asm__ volatile(EMMS:::"memory");
mm_end = end - 3;
while (s < mm_end) {
register unsigned x= *((const uint32_t *)s);
*((uint32_t *)d) = (x&0x7FFF7FFF) + (x&0x7FE07FE0);
d+=4;
s+=4;
}
if (s < end) {
register unsigned short x= *((const uint16_t *)s);
*((uint16_t *)d) = (x&0x7FFF) + (x&0x7FE0);
}
}
| true | FFmpeg | 90540c2d5ace46a1e9789c75fde0b1f7dbb12a9b | static inline void RENAME(rgb15to16)(const uint8_t *src, uint8_t *dst, int src_size)
{
register const uint8_t* s=src;
register uint8_t* d=dst;
register const uint8_t *end;
const uint8_t *mm_end;
end = s + src_size;
__asm__ volatile(PREFETCH" %0"::"m"(*s));
__asm__ volatile("movq %0, %%mm4"::"m"(mask15s));
mm_end = end - 15;
while (s<mm_end) {
__asm__ volatile(
PREFETCH" 32%1 \n\t"
"movq %1, %%mm0 \n\t"
"movq 8%1, %%mm2 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm2, %%mm3 \n\t"
"pand %%mm4, %%mm0 \n\t"
"pand %%mm4, %%mm2 \n\t"
"paddw %%mm1, %%mm0 \n\t"
"paddw %%mm3, %%mm2 \n\t"
MOVNTQ" %%mm0, %0 \n\t"
MOVNTQ" %%mm2, 8%0"
:"=m"(*d)
:"m"(*s)
);
d+=16;
s+=16;
}
__asm__ volatile(SFENCE:::"memory");
__asm__ volatile(EMMS:::"memory");
mm_end = end - 3;
while (s < mm_end) {
register unsigned x= *((const uint32_t *)s);
*((uint32_t *)d) = (x&0x7FFF7FFF) + (x&0x7FE07FE0);
d+=4;
s+=4;
}
if (s < end) {
register unsigned short x= *((const uint16_t *)s);
*((uint16_t *)d) = (x&0x7FFF) + (x&0x7FE0);
}
}
| {
"code": [
" :\"m\"(*s)",
" :\"m\"(*s)",
" PREFETCH\" 32%1 \\n\\t\"",
" \"movq %1, %%mm0 \\n\\t\"",
" \"movq 8%1, %%mm2 \\n\\t\"",
" MOVNTQ\" %%mm0, %0 \\n\\t\"",
" MOVNTQ\" %%mm2, 8%0\"",
" :\"=m\"(*d)",
" :\"m\"(*s)",
" PREFETCH\" 32%1 \\n\\t\"",
" \"movq %1, %%mm0 \\n\\t\"",
" \"movq 8%1, %%mm2 \\n\\t\"",
" MOVNTQ\" %%mm0, %0 \\n\\t\"",
" MOVNTQ\" %%mm2, 8%0\"",
" :\"=m\"(*d)",
" :\"m\"(*s)",
" :\"=m\"(*d)",
" :\"m\"(*s)",
" :\"=m\"(*d)",
" :\"m\"(*s)",
" :\"=m\"(*d)",
" :\"=m\"(*d)"
],
"line_no": [
49,
49,
25,
27,
29,
43,
45,
47,
49,
25,
27,
29,
43,
45,
47,
49,
47,
49,
47,
49,
47,
47
]
} | static inline void FUNC_0(rgb15to16)(const uint8_t *src, uint8_t *dst, int src_size)
{
register const uint8_t* VAR_0=src;
register uint8_t* VAR_1=dst;
register const uint8_t *VAR_2;
const uint8_t *VAR_3;
VAR_2 = VAR_0 + src_size;
__asm__ volatile(PREFETCH" %0"::"m"(*VAR_0));
__asm__ volatile("movq %0, %%mm4"::"m"(mask15s));
VAR_3 = VAR_2 - 15;
while (VAR_0<VAR_3) {
__asm__ volatile(
PREFETCH" 32%1 \n\t"
"movq %1, %%mm0 \n\t"
"movq 8%1, %%mm2 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm2, %%mm3 \n\t"
"pand %%mm4, %%mm0 \n\t"
"pand %%mm4, %%mm2 \n\t"
"paddw %%mm1, %%mm0 \n\t"
"paddw %%mm3, %%mm2 \n\t"
MOVNTQ" %%mm0, %0 \n\t"
MOVNTQ" %%mm2, 8%0"
:"=m"(*VAR_1)
:"m"(*VAR_0)
);
VAR_1+=16;
VAR_0+=16;
}
__asm__ volatile(SFENCE:::"memory");
__asm__ volatile(EMMS:::"memory");
VAR_3 = VAR_2 - 3;
while (VAR_0 < VAR_3) {
register unsigned VAR_5= *((const uint32_t *)VAR_0);
*((uint32_t *)VAR_1) = (VAR_5&0x7FFF7FFF) + (VAR_5&0x7FE07FE0);
VAR_1+=4;
VAR_0+=4;
}
if (VAR_0 < VAR_2) {
register unsigned short VAR_5= *((const uint16_t *)VAR_0);
*((uint16_t *)VAR_1) = (VAR_5&0x7FFF) + (VAR_5&0x7FE0);
}
}
| [
"static inline void FUNC_0(rgb15to16)(const uint8_t *src, uint8_t *dst, int src_size)\n{",
"register const uint8_t* VAR_0=src;",
"register uint8_t* VAR_1=dst;",
"register const uint8_t *VAR_2;",
"const uint8_t *VAR_3;",
"VAR_2 = VAR_0 + src_size;",
"__asm__ volatile(PREFETCH\" %0\"::\"m\"(*VAR_0));",
"__asm__ volatile(\"movq %0, %%mm4\"::\"m\"(mask15s));",
"VAR_3 = VAR_2 - 15;",
"while (VAR_0<VAR_3) {",
"__asm__ volatile(\nPREFETCH\" 32%1 \\n\\t\"\n\"movq %1, %%mm0 \\n\\t\"\n\"movq 8%1, %%mm2 \\n\\t\"\n\"movq %%mm0, %%mm1 \\n\\t\"\n\"movq %%mm2, %%mm3 \\n\\t\"\n\"pand %%mm4, %%mm0 \\n\\t\"\n\"pand %%mm4, %%mm2 \\n\\t\"\n\"paddw %%mm1, %%mm0 \\n\\t\"\n\"paddw %%mm3, %%mm2 \\n\\t\"\nMOVNTQ\" %%mm0, %0 \\n\\t\"\nMOVNTQ\" %%mm2, 8%0\"\n:\"=m\"(*VAR_1)\n:\"m\"(*VAR_0)\n);",
"VAR_1+=16;",
"VAR_0+=16;",
"}",
"__asm__ volatile(SFENCE:::\"memory\");",
"__asm__ volatile(EMMS:::\"memory\");",
"VAR_3 = VAR_2 - 3;",
"while (VAR_0 < VAR_3) {",
"register unsigned VAR_5= *((const uint32_t *)VAR_0);",
"*((uint32_t *)VAR_1) = (VAR_5&0x7FFF7FFF) + (VAR_5&0x7FE07FE0);",
"VAR_1+=4;",
"VAR_0+=4;",
"}",
"if (VAR_0 < VAR_2) {",
"register unsigned short VAR_5= *((const uint16_t *)VAR_0);",
"*((uint16_t *)VAR_1) = (VAR_5&0x7FFF) + (VAR_5&0x7FE0);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23,
25,
27,
29,
31,
33,
35,
37,
39,
41,
43,
45,
47,
49,
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
]
] |
22,318 | static inline void RENAME(rgb15to32)(const uint8_t *src, uint8_t *dst, long src_size)
{
const uint16_t *end;
#ifdef HAVE_MMX
const uint16_t *mm_end;
#endif
uint8_t *d = (uint8_t *)dst;
const uint16_t *s = (const uint16_t *)src;
end = s + src_size/2;
#ifdef HAVE_MMX
__asm __volatile(PREFETCH" %0"::"m"(*s):"memory");
__asm __volatile("pxor %%mm7,%%mm7\n\t":::"memory");
mm_end = end - 3;
while(s < mm_end)
{
__asm __volatile(
PREFETCH" 32%1\n\t"
"movq %1, %%mm0\n\t"
"movq %1, %%mm1\n\t"
"movq %1, %%mm2\n\t"
"pand %2, %%mm0\n\t"
"pand %3, %%mm1\n\t"
"pand %4, %%mm2\n\t"
"psllq $3, %%mm0\n\t"
"psrlq $2, %%mm1\n\t"
"psrlq $7, %%mm2\n\t"
"movq %%mm0, %%mm3\n\t"
"movq %%mm1, %%mm4\n\t"
"movq %%mm2, %%mm5\n\t"
"punpcklwd %%mm7, %%mm0\n\t"
"punpcklwd %%mm7, %%mm1\n\t"
"punpcklwd %%mm7, %%mm2\n\t"
"punpckhwd %%mm7, %%mm3\n\t"
"punpckhwd %%mm7, %%mm4\n\t"
"punpckhwd %%mm7, %%mm5\n\t"
"psllq $8, %%mm1\n\t"
"psllq $16, %%mm2\n\t"
"por %%mm1, %%mm0\n\t"
"por %%mm2, %%mm0\n\t"
"psllq $8, %%mm4\n\t"
"psllq $16, %%mm5\n\t"
"por %%mm4, %%mm3\n\t"
"por %%mm5, %%mm3\n\t"
MOVNTQ" %%mm0, %0\n\t"
MOVNTQ" %%mm3, 8%0\n\t"
:"=m"(*d)
:"m"(*s),"m"(mask15b),"m"(mask15g),"m"(mask15r)
:"memory");
d += 16;
s += 4;
}
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#endif
while(s < end)
{
#if 0 //slightly slower on athlon
int bgr= *s++;
*((uint32_t*)d)++ = ((bgr&0x1F)<<3) + ((bgr&0x3E0)<<6) + ((bgr&0x7C00)<<9);
#else
register uint16_t bgr;
bgr = *s++;
#ifdef WORDS_BIGENDIAN
*d++ = 0;
*d++ = (bgr&0x7C00)>>7;
*d++ = (bgr&0x3E0)>>2;
*d++ = (bgr&0x1F)<<3;
#else
*d++ = (bgr&0x1F)<<3;
*d++ = (bgr&0x3E0)>>2;
*d++ = (bgr&0x7C00)>>7;
*d++ = 0;
#endif
#endif
}
}
| true | FFmpeg | 6e42e6c4b410dbef8b593c2d796a5dad95f89ee4 | static inline void RENAME(rgb15to32)(const uint8_t *src, uint8_t *dst, long src_size)
{
const uint16_t *end;
#ifdef HAVE_MMX
const uint16_t *mm_end;
#endif
uint8_t *d = (uint8_t *)dst;
const uint16_t *s = (const uint16_t *)src;
end = s + src_size/2;
#ifdef HAVE_MMX
__asm __volatile(PREFETCH" %0"::"m"(*s):"memory");
__asm __volatile("pxor %%mm7,%%mm7\n\t":::"memory");
mm_end = end - 3;
while(s < mm_end)
{
__asm __volatile(
PREFETCH" 32%1\n\t"
"movq %1, %%mm0\n\t"
"movq %1, %%mm1\n\t"
"movq %1, %%mm2\n\t"
"pand %2, %%mm0\n\t"
"pand %3, %%mm1\n\t"
"pand %4, %%mm2\n\t"
"psllq $3, %%mm0\n\t"
"psrlq $2, %%mm1\n\t"
"psrlq $7, %%mm2\n\t"
"movq %%mm0, %%mm3\n\t"
"movq %%mm1, %%mm4\n\t"
"movq %%mm2, %%mm5\n\t"
"punpcklwd %%mm7, %%mm0\n\t"
"punpcklwd %%mm7, %%mm1\n\t"
"punpcklwd %%mm7, %%mm2\n\t"
"punpckhwd %%mm7, %%mm3\n\t"
"punpckhwd %%mm7, %%mm4\n\t"
"punpckhwd %%mm7, %%mm5\n\t"
"psllq $8, %%mm1\n\t"
"psllq $16, %%mm2\n\t"
"por %%mm1, %%mm0\n\t"
"por %%mm2, %%mm0\n\t"
"psllq $8, %%mm4\n\t"
"psllq $16, %%mm5\n\t"
"por %%mm4, %%mm3\n\t"
"por %%mm5, %%mm3\n\t"
MOVNTQ" %%mm0, %0\n\t"
MOVNTQ" %%mm3, 8%0\n\t"
:"=m"(*d)
:"m"(*s),"m"(mask15b),"m"(mask15g),"m"(mask15r)
:"memory");
d += 16;
s += 4;
}
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#endif
while(s < end)
{
#if 0
int bgr= *s++;
*((uint32_t*)d)++ = ((bgr&0x1F)<<3) + ((bgr&0x3E0)<<6) + ((bgr&0x7C00)<<9);
#else
register uint16_t bgr;
bgr = *s++;
#ifdef WORDS_BIGENDIAN
*d++ = 0;
*d++ = (bgr&0x7C00)>>7;
*d++ = (bgr&0x3E0)>>2;
*d++ = (bgr&0x1F)<<3;
#else
*d++ = (bgr&0x1F)<<3;
*d++ = (bgr&0x3E0)>>2;
*d++ = (bgr&0x7C00)>>7;
*d++ = 0;
#endif
#endif
}
}
| {
"code": [
"\tconst uint16_t *end;",
"\tuint8_t *d = (uint8_t *)dst;",
"\tend = s + src_size/2;",
"\twhile(s < end)",
"\t\tregister uint16_t bgr;",
"\t\tbgr = *s++;",
"\tconst uint16_t *end;",
"\tuint8_t *d = (uint8_t *)dst;",
"\tconst uint16_t *s = (const uint16_t *)src;",
"\tend = s + src_size/2;",
"\twhile(s < end)",
"\t\tregister uint16_t bgr;",
"\t\tbgr = *s++;",
"\t\t*d++ = (bgr&0x1F)<<3;",
"\tconst uint16_t *end;",
"\tuint8_t *d = (uint8_t *)dst;",
"\tconst uint16_t *s = (const uint16_t *)src;",
"\tend = s + src_size/2;",
"\twhile(s < end)",
"\t\tregister uint16_t bgr;",
"\t\tbgr = *s++;",
"\tconst uint16_t *end;",
"\tuint8_t *d = (uint8_t *)dst;",
"\tend = s + src_size/2;",
"\twhile(s < end)",
"\t\tregister uint16_t bgr;",
"\t\tbgr = *s++;",
"\t\t*d++ = (bgr&0x7C00)>>7;",
"\t\t*d++ = (bgr&0x3E0)>>2;",
"\t\t*d++ = (bgr&0x1F)<<3;",
"#ifdef HAVE_MMX",
"#endif",
"#ifdef HAVE_MMX",
"#endif",
"#ifdef WORDS_BIGENDIAN",
"#else",
"#endif",
"#endif",
"\t\t\"movq\t%1, %%mm0\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t\t:\"=m\"(*d)",
"\t\t\"movq\t%1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t\t:\"=m\"(*d)",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"pand\t%2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"#endif",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"pand\t%2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"#endif",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"pand\t%2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"pand\t%2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\tconst uint16_t *end;",
"\tconst uint16_t *mm_end;",
"\tuint8_t *d = (uint8_t *)dst;",
"\tend = s + src_size/2;",
"\t__asm __volatile(PREFETCH\"\t%0\"::\"m\"(*s):\"memory\");",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"movq\t%1, %%mm0\\n\\t\"",
"\t\t\"movq\t%1, %%mm1\\n\\t\"",
"\t\t\"movq\t%1, %%mm2\\n\\t\"",
"\t\t\"pand\t%2, %%mm0\\n\\t\"",
"\t\t\"pand\t%3, %%mm1\\n\\t\"",
"\t\t\"pand\t%4, %%mm2\\n\\t\"",
"\t\t\"psllq\t$3, %%mm0\\n\\t\"",
"\t\t\"psrlq\t$2, %%mm1\\n\\t\"",
"\t\t\"psrlq\t$7, %%mm2\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm3\\n\\t\"",
"\t\t\"movq\t%%mm1, %%mm4\\n\\t\"",
"\t\t\"movq\t%%mm2, %%mm5\\n\\t\"",
"\t\t\"psllq\t$8, %%mm1\\n\\t\"",
"\t\t\"psllq\t$16, %%mm2\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"psllq\t$8, %%mm4\\n\\t\"",
"\t\t\"psllq\t$16, %%mm5\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\t\"pand\t%2, %%mm0\\n\\t\"",
"\t\t\"pand\t%3, %%mm1\\n\\t\"",
"\t\t\"pand\t%4, %%mm2\\n\\t\"",
"\t\t\"psllq\t$3, %%mm0\\n\\t\"",
"\t\t\"psrlq\t$2, %%mm1\\n\\t\"",
"\t\t\"psrlq\t$7, %%mm2\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm3\\n\\t\"",
"\t\t\"movq\t%%mm1, %%mm4\\n\\t\"",
"\t\t\"movq\t%%mm2, %%mm5\\n\\t\"",
"\t\t\"psllq\t$8, %%mm1\\n\\t\"",
"\t\t\"psllq\t$16, %%mm2\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"psllq\t$8, %%mm4\\n\\t\"",
"\t\t\"psllq\t$16, %%mm5\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\t:\"=m\"(*d)",
"\t\t:\"memory\");",
"\t __asm __volatile(",
"\t\t\"pand\t%2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"pand\t%4, %%mm2\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"psllq\t$16, %%mm5\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t\t:\"=m\"(*d)",
"\t\t:\"memory\");",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\t\tregister uint16_t bgr;",
"\t\tbgr = *s++;",
"\t\t*d++ = (bgr&0x1F)<<3;",
"\t\t*d++ = (bgr&0x3E0)>>2;",
"\t\t*d++ = (bgr&0x7C00)>>7;",
"\tconst uint16_t *end;",
"\tconst uint16_t *mm_end;",
"\tuint8_t *d = (uint8_t *)dst;",
"\tconst uint16_t *s = (const uint16_t *)src;",
"\tend = s + src_size/2;",
"\t__asm __volatile(PREFETCH\"\t%0\"::\"m\"(*s):\"memory\");",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"movq\t%1, %%mm0\\n\\t\"",
"\t\t\"movq\t%1, %%mm1\\n\\t\"",
"\t\t\"movq\t%1, %%mm2\\n\\t\"",
"\t\t\"pand\t%2, %%mm0\\n\\t\"",
"\t\t\"pand\t%3, %%mm1\\n\\t\"",
"\t\t\"pand\t%4, %%mm2\\n\\t\"",
"\t\t\"psllq\t$3, %%mm0\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm3\\n\\t\"",
"\t\t\"movq\t%%mm1, %%mm4\\n\\t\"",
"\t\t\"movq\t%%mm2, %%mm5\\n\\t\"",
"\t\t\"psllq\t$8, %%mm1\\n\\t\"",
"\t\t\"psllq\t$16, %%mm2\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"psllq\t$8, %%mm4\\n\\t\"",
"\t\t\"psllq\t$16, %%mm5\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\t\"pand\t%2, %%mm0\\n\\t\"",
"\t\t\"pand\t%3, %%mm1\\n\\t\"",
"\t\t\"pand\t%4, %%mm2\\n\\t\"",
"\t\t\"psllq\t$3, %%mm0\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm3\\n\\t\"",
"\t\t\"movq\t%%mm1, %%mm4\\n\\t\"",
"\t\t\"movq\t%%mm2, %%mm5\\n\\t\"",
"\t\t\"psllq\t$8, %%mm1\\n\\t\"",
"\t\t\"psllq\t$16, %%mm2\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"psllq\t$8, %%mm4\\n\\t\"",
"\t\t\"psllq\t$16, %%mm5\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\t:\"=m\"(*d)",
"\t\t:\"memory\");",
"\t __asm __volatile(",
"\t\t\"pand\t%2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"pand\t%4, %%mm2\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"psllq\t$16, %%mm5\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t\t:\"=m\"(*d)",
"\t\t:\"memory\");",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\t\tregister uint16_t bgr;",
"\t\tbgr = *s++;",
"\t\t*d++ = (bgr&0x1F)<<3;",
"\tconst uint16_t *end;",
"\tconst uint16_t *mm_end;",
"\tuint8_t *d = (uint8_t *)dst;",
"\tconst uint16_t *s = (const uint16_t *)src;",
"\tend = s + src_size/2;",
"\t__asm __volatile(PREFETCH\"\t%0\"::\"m\"(*s):\"memory\");",
"\t__asm __volatile(\"pxor\t%%mm7,%%mm7\\n\\t\":::\"memory\");",
"\tmm_end = end - 3;",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"movq\t%1, %%mm0\\n\\t\"",
"\t\t\"movq\t%1, %%mm1\\n\\t\"",
"\t\t\"movq\t%1, %%mm2\\n\\t\"",
"\t\t\"pand\t%2, %%mm0\\n\\t\"",
"\t\t\"pand\t%3, %%mm1\\n\\t\"",
"\t\t\"pand\t%4, %%mm2\\n\\t\"",
"\t\t\"psllq\t$3, %%mm0\\n\\t\"",
"\t\t\"psrlq\t$2, %%mm1\\n\\t\"",
"\t\t\"psrlq\t$7, %%mm2\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm3\\n\\t\"",
"\t\t\"movq\t%%mm1, %%mm4\\n\\t\"",
"\t\t\"movq\t%%mm2, %%mm5\\n\\t\"",
"\t\t\"punpcklwd %%mm7, %%mm0\\n\\t\"",
"\t\t\"punpcklwd %%mm7, %%mm1\\n\\t\"",
"\t\t\"punpcklwd %%mm7, %%mm2\\n\\t\"",
"\t\t\"punpckhwd %%mm7, %%mm3\\n\\t\"",
"\t\t\"punpckhwd %%mm7, %%mm4\\n\\t\"",
"\t\t\"punpckhwd %%mm7, %%mm5\\n\\t\"",
"\t\t\"psllq\t$8, %%mm1\\n\\t\"",
"\t\t\"psllq\t$16, %%mm2\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"psllq\t$8, %%mm4\\n\\t\"",
"\t\t\"psllq\t$16, %%mm5\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm3, 8%0\\n\\t\"",
"\t\t:\"=m\"(*d)",
"\t\t:\"m\"(*s),\"m\"(mask15b),\"m\"(mask15g),\"m\"(mask15r)",
"\t\t:\"memory\");",
"\t\td += 16;",
"\t\ts += 4;",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\t\tint bgr= *s++;",
"\t\t*((uint32_t*)d)++ = ((bgr&0x1F)<<3) + ((bgr&0x3E0)<<6) + ((bgr&0x7C00)<<9);",
"\t\tregister uint16_t bgr;",
"\t\tbgr = *s++;",
"\t\t*d++ = 0;",
"\t\t*d++ = (bgr&0x7C00)>>7;",
"\t\t*d++ = (bgr&0x3E0)>>2;",
"\t\t*d++ = (bgr&0x1F)<<3;",
"\t\t*d++ = (bgr&0x1F)<<3;",
"\t\t*d++ = (bgr&0x3E0)>>2;",
"\t\t*d++ = (bgr&0x7C00)>>7;",
"\t\t*d++ = 0;",
"\tconst uint16_t *end;",
"\tconst uint16_t *mm_end;",
"\tuint8_t *d = (uint8_t *)dst;",
"\tend = s + src_size/2;",
"\t__asm __volatile(PREFETCH\"\t%0\"::\"m\"(*s):\"memory\");",
"\t__asm __volatile(\"pxor\t%%mm7,%%mm7\\n\\t\":::\"memory\");",
"\tmm_end = end - 3;",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"movq\t%1, %%mm0\\n\\t\"",
"\t\t\"movq\t%1, %%mm1\\n\\t\"",
"\t\t\"movq\t%1, %%mm2\\n\\t\"",
"\t\t\"pand\t%2, %%mm0\\n\\t\"",
"\t\t\"pand\t%3, %%mm1\\n\\t\"",
"\t\t\"pand\t%4, %%mm2\\n\\t\"",
"\t\t\"psllq\t$3, %%mm0\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm3\\n\\t\"",
"\t\t\"movq\t%%mm1, %%mm4\\n\\t\"",
"\t\t\"movq\t%%mm2, %%mm5\\n\\t\"",
"\t\t\"punpcklwd %%mm7, %%mm0\\n\\t\"",
"\t\t\"punpcklwd %%mm7, %%mm1\\n\\t\"",
"\t\t\"punpcklwd %%mm7, %%mm2\\n\\t\"",
"\t\t\"punpckhwd %%mm7, %%mm3\\n\\t\"",
"\t\t\"punpckhwd %%mm7, %%mm4\\n\\t\"",
"\t\t\"punpckhwd %%mm7, %%mm5\\n\\t\"",
"\t\t\"psllq\t$8, %%mm1\\n\\t\"",
"\t\t\"psllq\t$16, %%mm2\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"psllq\t$8, %%mm4\\n\\t\"",
"\t\t\"psllq\t$16, %%mm5\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm3, 8%0\\n\\t\"",
"\t\t:\"=m\"(*d)",
"\t\t:\"memory\");",
"\t\td += 16;",
"\t\ts += 4;",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\t\tregister uint16_t bgr;",
"\t\tbgr = *s++;",
"\t\t*d++ = 0;",
"\t\t*d++ = (bgr&0x1F)<<3;",
"\t\t*d++ = (bgr&0x1F)<<3;",
"\t\t*d++ = 0;",
"#endif",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t\t:\"memory\");",
"#endif",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t\t:\"memory\");",
"#endif",
"\t\t\"movq\t%%mm0, %%mm3\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm3\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm3\\n\\t\"",
"\t\t:\"memory\");",
"#endif"
],
"line_no": [
5,
13,
17,
109,
121,
123,
5,
13,
15,
17,
109,
121,
123,
133,
5,
13,
15,
17,
109,
121,
123,
5,
13,
17,
109,
121,
123,
129,
131,
133,
7,
11,
7,
11,
125,
119,
11,
11,
35,
87,
91,
35,
75,
87,
91,
27,
31,
33,
41,
75,
83,
77,
85,
87,
11,
103,
105,
11,
109,
27,
31,
33,
75,
83,
77,
85,
87,
103,
105,
11,
109,
27,
31,
33,
41,
75,
83,
77,
85,
87,
11,
103,
105,
11,
109,
27,
31,
33,
75,
83,
77,
85,
87,
103,
105,
11,
109,
27,
31,
33,
41,
75,
83,
77,
85,
87,
103,
105,
11,
109,
27,
31,
33,
75,
83,
77,
85,
87,
103,
105,
11,
109,
27,
31,
33,
41,
75,
83,
77,
85,
87,
103,
105,
11,
109,
27,
31,
33,
75,
83,
77,
85,
87,
103,
105,
11,
109,
5,
9,
13,
17,
21,
27,
31,
33,
35,
37,
39,
41,
43,
45,
47,
49,
51,
53,
55,
57,
71,
73,
75,
77,
79,
81,
83,
85,
41,
43,
45,
47,
49,
51,
53,
55,
57,
71,
73,
75,
77,
79,
81,
83,
85,
91,
95,
31,
41,
77,
45,
77,
81,
87,
91,
95,
103,
105,
11,
109,
121,
123,
133,
131,
129,
5,
9,
13,
15,
17,
21,
27,
31,
33,
35,
37,
39,
41,
43,
45,
47,
53,
55,
57,
71,
73,
75,
77,
79,
81,
83,
85,
41,
43,
45,
47,
53,
55,
57,
71,
73,
75,
77,
79,
81,
83,
85,
91,
95,
31,
41,
77,
45,
77,
81,
87,
91,
95,
103,
105,
11,
109,
121,
123,
133,
5,
9,
13,
15,
17,
21,
23,
25,
27,
31,
33,
35,
37,
39,
41,
43,
45,
47,
49,
51,
53,
55,
57,
59,
61,
63,
65,
67,
69,
71,
73,
75,
77,
79,
81,
83,
85,
87,
89,
91,
93,
95,
97,
99,
103,
105,
11,
109,
115,
117,
121,
123,
127,
129,
131,
133,
133,
131,
129,
127,
5,
9,
13,
17,
21,
23,
25,
27,
31,
33,
35,
37,
39,
41,
43,
45,
47,
53,
55,
57,
59,
61,
63,
65,
67,
69,
71,
73,
75,
77,
79,
81,
83,
85,
87,
89,
91,
95,
97,
99,
103,
105,
11,
109,
121,
123,
127,
133,
133,
127,
11,
103,
105,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
11,
33,
87,
95,
11,
33,
87,
95,
11,
53,
53,
53,
95,
11
]
} | static inline void FUNC_0(rgb15to32)(const uint8_t *src, uint8_t *dst, long src_size)
{
const uint16_t *VAR_0;
#ifdef HAVE_MMX
const uint16_t *mm_end;
#endif
uint8_t *d = (uint8_t *)dst;
const uint16_t *VAR_1 = (const uint16_t *)src;
VAR_0 = VAR_1 + src_size/2;
#ifdef HAVE_MMX
__asm __volatile(PREFETCH" %0"::"m"(*VAR_1):"memory");
__asm __volatile("pxor %%mm7,%%mm7\n\t":::"memory");
mm_end = VAR_0 - 3;
while(VAR_1 < mm_end)
{
__asm __volatile(
PREFETCH" 32%1\n\t"
"movq %1, %%mm0\n\t"
"movq %1, %%mm1\n\t"
"movq %1, %%mm2\n\t"
"pand %2, %%mm0\n\t"
"pand %3, %%mm1\n\t"
"pand %4, %%mm2\n\t"
"psllq $3, %%mm0\n\t"
"psrlq $2, %%mm1\n\t"
"psrlq $7, %%mm2\n\t"
"movq %%mm0, %%mm3\n\t"
"movq %%mm1, %%mm4\n\t"
"movq %%mm2, %%mm5\n\t"
"punpcklwd %%mm7, %%mm0\n\t"
"punpcklwd %%mm7, %%mm1\n\t"
"punpcklwd %%mm7, %%mm2\n\t"
"punpckhwd %%mm7, %%mm3\n\t"
"punpckhwd %%mm7, %%mm4\n\t"
"punpckhwd %%mm7, %%mm5\n\t"
"psllq $8, %%mm1\n\t"
"psllq $16, %%mm2\n\t"
"por %%mm1, %%mm0\n\t"
"por %%mm2, %%mm0\n\t"
"psllq $8, %%mm4\n\t"
"psllq $16, %%mm5\n\t"
"por %%mm4, %%mm3\n\t"
"por %%mm5, %%mm3\n\t"
MOVNTQ" %%mm0, %0\n\t"
MOVNTQ" %%mm3, 8%0\n\t"
:"=m"(*d)
:"m"(*VAR_1),"m"(mask15b),"m"(mask15g),"m"(mask15r)
:"memory");
d += 16;
VAR_1 += 4;
}
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#endif
while(VAR_1 < VAR_0)
{
#if 0
int VAR_2= *VAR_1++;
*((uint32_t*)d)++ = ((VAR_2&0x1F)<<3) + ((VAR_2&0x3E0)<<6) + ((VAR_2&0x7C00)<<9);
#else
register uint16_t VAR_2;
VAR_2 = *VAR_1++;
#ifdef WORDS_BIGENDIAN
*d++ = 0;
*d++ = (VAR_2&0x7C00)>>7;
*d++ = (VAR_2&0x3E0)>>2;
*d++ = (VAR_2&0x1F)<<3;
#else
*d++ = (VAR_2&0x1F)<<3;
*d++ = (VAR_2&0x3E0)>>2;
*d++ = (VAR_2&0x7C00)>>7;
*d++ = 0;
#endif
#endif
}
}
| [
"static inline void FUNC_0(rgb15to32)(const uint8_t *src, uint8_t *dst, long src_size)\n{",
"const uint16_t *VAR_0;",
"#ifdef HAVE_MMX\nconst uint16_t *mm_end;",
"#endif\nuint8_t *d = (uint8_t *)dst;",
"const uint16_t *VAR_1 = (const uint16_t *)src;",
"VAR_0 = VAR_1 + src_size/2;",
"#ifdef HAVE_MMX\n__asm __volatile(PREFETCH\"\t%0\"::\"m\"(*VAR_1):\"memory\");",
"__asm __volatile(\"pxor\t%%mm7,%%mm7\\n\\t\":::\"memory\");",
"mm_end = VAR_0 - 3;",
"while(VAR_1 < mm_end)\n{",
"__asm __volatile(\nPREFETCH\" 32%1\\n\\t\"\n\"movq\t%1, %%mm0\\n\\t\"\n\"movq\t%1, %%mm1\\n\\t\"\n\"movq\t%1, %%mm2\\n\\t\"\n\"pand\t%2, %%mm0\\n\\t\"\n\"pand\t%3, %%mm1\\n\\t\"\n\"pand\t%4, %%mm2\\n\\t\"\n\"psllq\t$3, %%mm0\\n\\t\"\n\"psrlq\t$2, %%mm1\\n\\t\"\n\"psrlq\t$7, %%mm2\\n\\t\"\n\"movq\t%%mm0, %%mm3\\n\\t\"\n\"movq\t%%mm1, %%mm4\\n\\t\"\n\"movq\t%%mm2, %%mm5\\n\\t\"\n\"punpcklwd %%mm7, %%mm0\\n\\t\"\n\"punpcklwd %%mm7, %%mm1\\n\\t\"\n\"punpcklwd %%mm7, %%mm2\\n\\t\"\n\"punpckhwd %%mm7, %%mm3\\n\\t\"\n\"punpckhwd %%mm7, %%mm4\\n\\t\"\n\"punpckhwd %%mm7, %%mm5\\n\\t\"\n\"psllq\t$8, %%mm1\\n\\t\"\n\"psllq\t$16, %%mm2\\n\\t\"\n\"por\t%%mm1, %%mm0\\n\\t\"\n\"por\t%%mm2, %%mm0\\n\\t\"\n\"psllq\t$8, %%mm4\\n\\t\"\n\"psllq\t$16, %%mm5\\n\\t\"\n\"por\t%%mm4, %%mm3\\n\\t\"\n\"por\t%%mm5, %%mm3\\n\\t\"\nMOVNTQ\"\t%%mm0, %0\\n\\t\"\nMOVNTQ\"\t%%mm3, 8%0\\n\\t\"\n:\"=m\"(*d)\n:\"m\"(*VAR_1),\"m\"(mask15b),\"m\"(mask15g),\"m\"(mask15r)\n:\"memory\");",
"d += 16;",
"VAR_1 += 4;",
"}",
"__asm __volatile(SFENCE:::\"memory\");",
"__asm __volatile(EMMS:::\"memory\");",
"#endif\nwhile(VAR_1 < VAR_0)\n{",
"#if 0\nint VAR_2= *VAR_1++;",
"*((uint32_t*)d)++ = ((VAR_2&0x1F)<<3) + ((VAR_2&0x3E0)<<6) + ((VAR_2&0x7C00)<<9);",
"#else\nregister uint16_t VAR_2;",
"VAR_2 = *VAR_1++;",
"#ifdef WORDS_BIGENDIAN\n*d++ = 0;",
"*d++ = (VAR_2&0x7C00)>>7;",
"*d++ = (VAR_2&0x3E0)>>2;",
"*d++ = (VAR_2&0x1F)<<3;",
"#else\n*d++ = (VAR_2&0x1F)<<3;",
"*d++ = (VAR_2&0x3E0)>>2;",
"*d++ = (VAR_2&0x7C00)>>7;",
"*d++ = 0;",
"#endif\n#endif\n}",
"}"
] | [
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7,
9
],
[
11,
13
],
[
15
],
[
17
],
[
19,
21
],
[
23
],
[
25
],
[
27,
29
],
[
31,
33,
35,
37,
39,
41,
43,
45,
47,
49,
51,
53,
55,
57,
59,
61,
63,
65,
67,
69,
71,
73,
75,
77,
79,
81,
83,
85,
87,
89,
91,
93,
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107,
109,
111
],
[
113,
115
],
[
117
],
[
119,
121
],
[
123
],
[
125,
127
],
[
129
],
[
131
],
[
133
],
[
135,
137
],
[
139
],
[
141
],
[
143
],
[
145,
149,
151
],
[
153
]
] |
22,319 | static void tap_send(void *opaque)
{
TAPState *s = opaque;
int size;
do {
uint8_t *buf = s->buf;
size = tap_read_packet(s->fd, s->buf, sizeof(s->buf));
if (size <= 0) {
break;
}
if (s->host_vnet_hdr_len && !s->using_vnet_hdr) {
buf += s->host_vnet_hdr_len;
size -= s->host_vnet_hdr_len;
}
size = qemu_send_packet_async(&s->nc, buf, size, tap_send_completed);
if (size == 0) {
tap_read_poll(s, false);
}
} while (size > 0 && qemu_can_send_packet(&s->nc));
}
| true | qemu | 68e5ec64009812dbaa03ed9cfded9344986f5304 | static void tap_send(void *opaque)
{
TAPState *s = opaque;
int size;
do {
uint8_t *buf = s->buf;
size = tap_read_packet(s->fd, s->buf, sizeof(s->buf));
if (size <= 0) {
break;
}
if (s->host_vnet_hdr_len && !s->using_vnet_hdr) {
buf += s->host_vnet_hdr_len;
size -= s->host_vnet_hdr_len;
}
size = qemu_send_packet_async(&s->nc, buf, size, tap_send_completed);
if (size == 0) {
tap_read_poll(s, false);
}
} while (size > 0 && qemu_can_send_packet(&s->nc));
}
| {
"code": [
" do {",
" } while (size > 0 && qemu_can_send_packet(&s->nc));"
],
"line_no": [
11,
45
]
} | static void FUNC_0(void *VAR_0)
{
TAPState *s = VAR_0;
int VAR_1;
do {
uint8_t *buf = s->buf;
VAR_1 = tap_read_packet(s->fd, s->buf, sizeof(s->buf));
if (VAR_1 <= 0) {
break;
}
if (s->host_vnet_hdr_len && !s->using_vnet_hdr) {
buf += s->host_vnet_hdr_len;
VAR_1 -= s->host_vnet_hdr_len;
}
VAR_1 = qemu_send_packet_async(&s->nc, buf, VAR_1, tap_send_completed);
if (VAR_1 == 0) {
tap_read_poll(s, false);
}
} while (VAR_1 > 0 && qemu_can_send_packet(&s->nc));
}
| [
"static void FUNC_0(void *VAR_0)\n{",
"TAPState *s = VAR_0;",
"int VAR_1;",
"do {",
"uint8_t *buf = s->buf;",
"VAR_1 = tap_read_packet(s->fd, s->buf, sizeof(s->buf));",
"if (VAR_1 <= 0) {",
"break;",
"}",
"if (s->host_vnet_hdr_len && !s->using_vnet_hdr) {",
"buf += s->host_vnet_hdr_len;",
"VAR_1 -= s->host_vnet_hdr_len;",
"}",
"VAR_1 = qemu_send_packet_async(&s->nc, buf, VAR_1, tap_send_completed);",
"if (VAR_1 == 0) {",
"tap_read_poll(s, false);",
"}",
"} while (VAR_1 > 0 && qemu_can_send_packet(&s->nc));",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
]
] |
22,320 | int decode_splitmvs(VP8Context *s, VP56RangeCoder *c, VP8Macroblock *mb, int layout)
{
int part_idx;
int n, num;
VP8Macroblock *top_mb;
VP8Macroblock *left_mb = &mb[-1];
const uint8_t *mbsplits_left = vp8_mbsplits[left_mb->partitioning];
const uint8_t *mbsplits_top, *mbsplits_cur, *firstidx;
VP56mv *top_mv;
VP56mv *left_mv = left_mb->bmv;
VP56mv *cur_mv = mb->bmv;
if (!layout) // layout is inlined, s->mb_layout is not
top_mb = &mb[2];
else
top_mb = &mb[-s->mb_width - 1];
mbsplits_top = vp8_mbsplits[top_mb->partitioning];
top_mv = top_mb->bmv;
if (vp56_rac_get_prob_branchy(c, vp8_mbsplit_prob[0])) {
if (vp56_rac_get_prob_branchy(c, vp8_mbsplit_prob[1]))
part_idx = VP8_SPLITMVMODE_16x8 + vp56_rac_get_prob(c, vp8_mbsplit_prob[2]);
else
part_idx = VP8_SPLITMVMODE_8x8;
} else {
part_idx = VP8_SPLITMVMODE_4x4;
}
num = vp8_mbsplit_count[part_idx];
mbsplits_cur = vp8_mbsplits[part_idx],
firstidx = vp8_mbfirstidx[part_idx];
mb->partitioning = part_idx;
for (n = 0; n < num; n++) {
int k = firstidx[n];
uint32_t left, above;
const uint8_t *submv_prob;
if (!(k & 3))
left = AV_RN32A(&left_mv[mbsplits_left[k + 3]]);
else
left = AV_RN32A(&cur_mv[mbsplits_cur[k - 1]]);
if (k <= 3)
above = AV_RN32A(&top_mv[mbsplits_top[k + 12]]);
else
above = AV_RN32A(&cur_mv[mbsplits_cur[k - 4]]);
submv_prob = get_submv_prob(left, above);
if (vp56_rac_get_prob_branchy(c, submv_prob[0])) {
if (vp56_rac_get_prob_branchy(c, submv_prob[1])) {
if (vp56_rac_get_prob_branchy(c, submv_prob[2])) {
mb->bmv[n].y = mb->mv.y + read_mv_component(c, s->prob->mvc[0]);
mb->bmv[n].x = mb->mv.x + read_mv_component(c, s->prob->mvc[1]);
} else {
AV_ZERO32(&mb->bmv[n]);
}
} else {
AV_WN32A(&mb->bmv[n], above);
}
} else {
AV_WN32A(&mb->bmv[n], left);
}
}
return num;
}
| true | FFmpeg | ac4b32df71bd932838043a4838b86d11e169707f | int decode_splitmvs(VP8Context *s, VP56RangeCoder *c, VP8Macroblock *mb, int layout)
{
int part_idx;
int n, num;
VP8Macroblock *top_mb;
VP8Macroblock *left_mb = &mb[-1];
const uint8_t *mbsplits_left = vp8_mbsplits[left_mb->partitioning];
const uint8_t *mbsplits_top, *mbsplits_cur, *firstidx;
VP56mv *top_mv;
VP56mv *left_mv = left_mb->bmv;
VP56mv *cur_mv = mb->bmv;
if (!layout)
top_mb = &mb[2];
else
top_mb = &mb[-s->mb_width - 1];
mbsplits_top = vp8_mbsplits[top_mb->partitioning];
top_mv = top_mb->bmv;
if (vp56_rac_get_prob_branchy(c, vp8_mbsplit_prob[0])) {
if (vp56_rac_get_prob_branchy(c, vp8_mbsplit_prob[1]))
part_idx = VP8_SPLITMVMODE_16x8 + vp56_rac_get_prob(c, vp8_mbsplit_prob[2]);
else
part_idx = VP8_SPLITMVMODE_8x8;
} else {
part_idx = VP8_SPLITMVMODE_4x4;
}
num = vp8_mbsplit_count[part_idx];
mbsplits_cur = vp8_mbsplits[part_idx],
firstidx = vp8_mbfirstidx[part_idx];
mb->partitioning = part_idx;
for (n = 0; n < num; n++) {
int k = firstidx[n];
uint32_t left, above;
const uint8_t *submv_prob;
if (!(k & 3))
left = AV_RN32A(&left_mv[mbsplits_left[k + 3]]);
else
left = AV_RN32A(&cur_mv[mbsplits_cur[k - 1]]);
if (k <= 3)
above = AV_RN32A(&top_mv[mbsplits_top[k + 12]]);
else
above = AV_RN32A(&cur_mv[mbsplits_cur[k - 4]]);
submv_prob = get_submv_prob(left, above);
if (vp56_rac_get_prob_branchy(c, submv_prob[0])) {
if (vp56_rac_get_prob_branchy(c, submv_prob[1])) {
if (vp56_rac_get_prob_branchy(c, submv_prob[2])) {
mb->bmv[n].y = mb->mv.y + read_mv_component(c, s->prob->mvc[0]);
mb->bmv[n].x = mb->mv.x + read_mv_component(c, s->prob->mvc[1]);
} else {
AV_ZERO32(&mb->bmv[n]);
}
} else {
AV_WN32A(&mb->bmv[n], above);
}
} else {
AV_WN32A(&mb->bmv[n], left);
}
}
return num;
}
| {
"code": [
"int decode_splitmvs(VP8Context *s, VP56RangeCoder *c, VP8Macroblock *mb, int layout)",
" submv_prob = get_submv_prob(left, above);",
" mb->bmv[n].y = mb->mv.y + read_mv_component(c, s->prob->mvc[0]);",
" mb->bmv[n].x = mb->mv.x + read_mv_component(c, s->prob->mvc[1]);"
],
"line_no": [
1,
95,
105,
107
]
} | int FUNC_0(VP8Context *VAR_0, VP56RangeCoder *VAR_1, VP8Macroblock *VAR_2, int VAR_3)
{
int VAR_4;
int VAR_5, VAR_6;
VP8Macroblock *top_mb;
VP8Macroblock *left_mb = &VAR_2[-1];
const uint8_t *VAR_7 = vp8_mbsplits[left_mb->partitioning];
const uint8_t *VAR_8, *mbsplits_cur, *firstidx;
VP56mv *top_mv;
VP56mv *left_mv = left_mb->bmv;
VP56mv *cur_mv = VAR_2->bmv;
if (!VAR_3)
top_mb = &VAR_2[2];
else
top_mb = &VAR_2[-VAR_0->mb_width - 1];
VAR_8 = vp8_mbsplits[top_mb->partitioning];
top_mv = top_mb->bmv;
if (vp56_rac_get_prob_branchy(VAR_1, vp8_mbsplit_prob[0])) {
if (vp56_rac_get_prob_branchy(VAR_1, vp8_mbsplit_prob[1]))
VAR_4 = VP8_SPLITMVMODE_16x8 + vp56_rac_get_prob(VAR_1, vp8_mbsplit_prob[2]);
else
VAR_4 = VP8_SPLITMVMODE_8x8;
} else {
VAR_4 = VP8_SPLITMVMODE_4x4;
}
VAR_6 = vp8_mbsplit_count[VAR_4];
mbsplits_cur = vp8_mbsplits[VAR_4],
firstidx = vp8_mbfirstidx[VAR_4];
VAR_2->partitioning = VAR_4;
for (VAR_5 = 0; VAR_5 < VAR_6; VAR_5++) {
int VAR_9 = firstidx[VAR_5];
uint32_t left, above;
const uint8_t *VAR_10;
if (!(VAR_9 & 3))
left = AV_RN32A(&left_mv[VAR_7[VAR_9 + 3]]);
else
left = AV_RN32A(&cur_mv[mbsplits_cur[VAR_9 - 1]]);
if (VAR_9 <= 3)
above = AV_RN32A(&top_mv[VAR_8[VAR_9 + 12]]);
else
above = AV_RN32A(&cur_mv[mbsplits_cur[VAR_9 - 4]]);
VAR_10 = get_submv_prob(left, above);
if (vp56_rac_get_prob_branchy(VAR_1, VAR_10[0])) {
if (vp56_rac_get_prob_branchy(VAR_1, VAR_10[1])) {
if (vp56_rac_get_prob_branchy(VAR_1, VAR_10[2])) {
VAR_2->bmv[VAR_5].y = VAR_2->mv.y + read_mv_component(VAR_1, VAR_0->prob->mvc[0]);
VAR_2->bmv[VAR_5].x = VAR_2->mv.x + read_mv_component(VAR_1, VAR_0->prob->mvc[1]);
} else {
AV_ZERO32(&VAR_2->bmv[VAR_5]);
}
} else {
AV_WN32A(&VAR_2->bmv[VAR_5], above);
}
} else {
AV_WN32A(&VAR_2->bmv[VAR_5], left);
}
}
return VAR_6;
}
| [
"int FUNC_0(VP8Context *VAR_0, VP56RangeCoder *VAR_1, VP8Macroblock *VAR_2, int VAR_3)\n{",
"int VAR_4;",
"int VAR_5, VAR_6;",
"VP8Macroblock *top_mb;",
"VP8Macroblock *left_mb = &VAR_2[-1];",
"const uint8_t *VAR_7 = vp8_mbsplits[left_mb->partitioning];",
"const uint8_t *VAR_8, *mbsplits_cur, *firstidx;",
"VP56mv *top_mv;",
"VP56mv *left_mv = left_mb->bmv;",
"VP56mv *cur_mv = VAR_2->bmv;",
"if (!VAR_3)\ntop_mb = &VAR_2[2];",
"else\ntop_mb = &VAR_2[-VAR_0->mb_width - 1];",
"VAR_8 = vp8_mbsplits[top_mb->partitioning];",
"top_mv = top_mb->bmv;",
"if (vp56_rac_get_prob_branchy(VAR_1, vp8_mbsplit_prob[0])) {",
"if (vp56_rac_get_prob_branchy(VAR_1, vp8_mbsplit_prob[1]))\nVAR_4 = VP8_SPLITMVMODE_16x8 + vp56_rac_get_prob(VAR_1, vp8_mbsplit_prob[2]);",
"else\nVAR_4 = VP8_SPLITMVMODE_8x8;",
"} else {",
"VAR_4 = VP8_SPLITMVMODE_4x4;",
"}",
"VAR_6 = vp8_mbsplit_count[VAR_4];",
"mbsplits_cur = vp8_mbsplits[VAR_4],\nfirstidx = vp8_mbfirstidx[VAR_4];",
"VAR_2->partitioning = VAR_4;",
"for (VAR_5 = 0; VAR_5 < VAR_6; VAR_5++) {",
"int VAR_9 = firstidx[VAR_5];",
"uint32_t left, above;",
"const uint8_t *VAR_10;",
"if (!(VAR_9 & 3))\nleft = AV_RN32A(&left_mv[VAR_7[VAR_9 + 3]]);",
"else\nleft = AV_RN32A(&cur_mv[mbsplits_cur[VAR_9 - 1]]);",
"if (VAR_9 <= 3)\nabove = AV_RN32A(&top_mv[VAR_8[VAR_9 + 12]]);",
"else\nabove = AV_RN32A(&cur_mv[mbsplits_cur[VAR_9 - 4]]);",
"VAR_10 = get_submv_prob(left, above);",
"if (vp56_rac_get_prob_branchy(VAR_1, VAR_10[0])) {",
"if (vp56_rac_get_prob_branchy(VAR_1, VAR_10[1])) {",
"if (vp56_rac_get_prob_branchy(VAR_1, VAR_10[2])) {",
"VAR_2->bmv[VAR_5].y = VAR_2->mv.y + read_mv_component(VAR_1, VAR_0->prob->mvc[0]);",
"VAR_2->bmv[VAR_5].x = VAR_2->mv.x + read_mv_component(VAR_1, VAR_0->prob->mvc[1]);",
"} else {",
"AV_ZERO32(&VAR_2->bmv[VAR_5]);",
"}",
"} else {",
"AV_WN32A(&VAR_2->bmv[VAR_5], above);",
"}",
"} else {",
"AV_WN32A(&VAR_2->bmv[VAR_5], left);",
"}",
"}",
"return VAR_6;",
"}"
] | [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25,
27
],
[
29,
31
],
[
33
],
[
35
],
[
39
],
[
41,
43
],
[
45,
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59,
61
],
[
63
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77,
79
],
[
81,
83
],
[
85,
87
],
[
89,
91
],
[
95
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
131
],
[
133
]
] |
22,321 | static inline void FUNC(idctSparseColPut)(pixel *dest, int line_size,
DCTELEM *col)
{
int a0, a1, a2, a3, b0, b1, b2, b3;
INIT_CLIP;
IDCT_COLS;
dest[0] = CLIP((a0 + b0) >> COL_SHIFT);
dest += line_size;
dest[0] = CLIP((a1 + b1) >> COL_SHIFT);
dest += line_size;
dest[0] = CLIP((a2 + b2) >> COL_SHIFT);
dest += line_size;
dest[0] = CLIP((a3 + b3) >> COL_SHIFT);
dest += line_size;
dest[0] = CLIP((a3 - b3) >> COL_SHIFT);
dest += line_size;
dest[0] = CLIP((a2 - b2) >> COL_SHIFT);
dest += line_size;
dest[0] = CLIP((a1 - b1) >> COL_SHIFT);
dest += line_size;
dest[0] = CLIP((a0 - b0) >> COL_SHIFT);
}
| true | FFmpeg | c23acbaed40101c677dfcfbbfe0d2c230a8e8f44 | static inline void FUNC(idctSparseColPut)(pixel *dest, int line_size,
DCTELEM *col)
{
int a0, a1, a2, a3, b0, b1, b2, b3;
INIT_CLIP;
IDCT_COLS;
dest[0] = CLIP((a0 + b0) >> COL_SHIFT);
dest += line_size;
dest[0] = CLIP((a1 + b1) >> COL_SHIFT);
dest += line_size;
dest[0] = CLIP((a2 + b2) >> COL_SHIFT);
dest += line_size;
dest[0] = CLIP((a3 + b3) >> COL_SHIFT);
dest += line_size;
dest[0] = CLIP((a3 - b3) >> COL_SHIFT);
dest += line_size;
dest[0] = CLIP((a2 - b2) >> COL_SHIFT);
dest += line_size;
dest[0] = CLIP((a1 - b1) >> COL_SHIFT);
dest += line_size;
dest[0] = CLIP((a0 - b0) >> COL_SHIFT);
}
| {
"code": [
" INIT_CLIP;",
" dest[0] = CLIP((a0 + b0) >> COL_SHIFT);",
" dest[0] = CLIP((a1 + b1) >> COL_SHIFT);",
" dest[0] = CLIP((a2 + b2) >> COL_SHIFT);",
" dest[0] = CLIP((a3 + b3) >> COL_SHIFT);",
" dest[0] = CLIP((a3 - b3) >> COL_SHIFT);",
" dest[0] = CLIP((a2 - b2) >> COL_SHIFT);",
" dest[0] = CLIP((a1 - b1) >> COL_SHIFT);",
" dest[0] = CLIP((a0 - b0) >> COL_SHIFT);",
" INIT_CLIP;"
],
"line_no": [
9,
17,
21,
25,
29,
33,
37,
41,
45,
9
]
} | static inline void FUNC_0(idctSparseColPut)(pixel *dest, int line_size,
DCTELEM *col)
{
int VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;
INIT_CLIP;
IDCT_COLS;
dest[0] = CLIP((VAR_0 + VAR_4) >> COL_SHIFT);
dest += line_size;
dest[0] = CLIP((VAR_1 + VAR_5) >> COL_SHIFT);
dest += line_size;
dest[0] = CLIP((VAR_2 + VAR_6) >> COL_SHIFT);
dest += line_size;
dest[0] = CLIP((VAR_3 + VAR_7) >> COL_SHIFT);
dest += line_size;
dest[0] = CLIP((VAR_3 - VAR_7) >> COL_SHIFT);
dest += line_size;
dest[0] = CLIP((VAR_2 - VAR_6) >> COL_SHIFT);
dest += line_size;
dest[0] = CLIP((VAR_1 - VAR_5) >> COL_SHIFT);
dest += line_size;
dest[0] = CLIP((VAR_0 - VAR_4) >> COL_SHIFT);
}
| [
"static inline void FUNC_0(idctSparseColPut)(pixel *dest, int line_size,\nDCTELEM *col)\n{",
"int VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;",
"INIT_CLIP;",
"IDCT_COLS;",
"dest[0] = CLIP((VAR_0 + VAR_4) >> COL_SHIFT);",
"dest += line_size;",
"dest[0] = CLIP((VAR_1 + VAR_5) >> COL_SHIFT);",
"dest += line_size;",
"dest[0] = CLIP((VAR_2 + VAR_6) >> COL_SHIFT);",
"dest += line_size;",
"dest[0] = CLIP((VAR_3 + VAR_7) >> COL_SHIFT);",
"dest += line_size;",
"dest[0] = CLIP((VAR_3 - VAR_7) >> COL_SHIFT);",
"dest += line_size;",
"dest[0] = CLIP((VAR_2 - VAR_6) >> COL_SHIFT);",
"dest += line_size;",
"dest[0] = CLIP((VAR_1 - VAR_5) >> COL_SHIFT);",
"dest += line_size;",
"dest[0] = CLIP((VAR_0 - VAR_4) >> COL_SHIFT);",
"}"
] | [
0,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0,
1,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
]
] |
22,322 | void hbitmap_reset(HBitmap *hb, uint64_t start, uint64_t count)
{
/* Compute range in the last layer. */
uint64_t last = start + count - 1;
trace_hbitmap_reset(hb, start, count,
start >> hb->granularity, last >> hb->granularity);
start >>= hb->granularity;
last >>= hb->granularity;
hb->count -= hb_count_between(hb, start, last);
hb_reset_between(hb, HBITMAP_LEVELS - 1, start, last);
} | true | qemu | 0e321191224c8cd137eef41da3257e096965c3d6 | void hbitmap_reset(HBitmap *hb, uint64_t start, uint64_t count)
{
uint64_t last = start + count - 1;
trace_hbitmap_reset(hb, start, count,
start >> hb->granularity, last >> hb->granularity);
start >>= hb->granularity;
last >>= hb->granularity;
hb->count -= hb_count_between(hb, start, last);
hb_reset_between(hb, HBITMAP_LEVELS - 1, start, last);
} | {
"code": [],
"line_no": []
} | void FUNC_0(HBitmap *VAR_0, uint64_t VAR_1, uint64_t VAR_2)
{
uint64_t last = VAR_1 + VAR_2 - 1;
trace_hbitmap_reset(VAR_0, VAR_1, VAR_2,
VAR_1 >> VAR_0->granularity, last >> VAR_0->granularity);
VAR_1 >>= VAR_0->granularity;
last >>= VAR_0->granularity;
VAR_0->VAR_2 -= hb_count_between(VAR_0, VAR_1, last);
hb_reset_between(VAR_0, HBITMAP_LEVELS - 1, VAR_1, last);
} | [
"void FUNC_0(HBitmap *VAR_0, uint64_t VAR_1, uint64_t VAR_2)\n{",
"uint64_t last = VAR_1 + VAR_2 - 1;",
"trace_hbitmap_reset(VAR_0, VAR_1, VAR_2,\nVAR_1 >> VAR_0->granularity, last >> VAR_0->granularity);",
"VAR_1 >>= VAR_0->granularity;",
"last >>= VAR_0->granularity;",
"VAR_0->VAR_2 -= hb_count_between(VAR_0, VAR_1, last);",
"hb_reset_between(VAR_0, HBITMAP_LEVELS - 1, VAR_1, last);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
7
],
[
11,
13
],
[
17
],
[
19
],
[
24
],
[
26
],
[
28
]
] |
22,323 | static int raw_create(const char *filename, QemuOpts *opts, Error **errp)
{
int fd;
int result = 0;
int64_t total_size = 0;
bool nocow = false;
PreallocMode prealloc;
char *buf = NULL;
Error *local_err = NULL;
strstart(filename, "file:", &filename);
/* Read out options */
total_size = ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0),
BDRV_SECTOR_SIZE);
nocow = qemu_opt_get_bool(opts, BLOCK_OPT_NOCOW, false);
buf = qemu_opt_get_del(opts, BLOCK_OPT_PREALLOC);
prealloc = qapi_enum_parse(PreallocMode_lookup, buf,
PREALLOC_MODE__MAX, PREALLOC_MODE_OFF,
&local_err);
g_free(buf);
if (local_err) {
error_propagate(errp, local_err);
result = -EINVAL;
goto out;
}
fd = qemu_open(filename, O_RDWR | O_CREAT | O_TRUNC | O_BINARY,
0644);
if (fd < 0) {
result = -errno;
error_setg_errno(errp, -result, "Could not create file");
goto out;
}
if (nocow) {
#ifdef __linux__
/* Set NOCOW flag to solve performance issue on fs like btrfs.
* This is an optimisation. The FS_IOC_SETFLAGS ioctl return value
* will be ignored since any failure of this operation should not
* block the left work.
*/
int attr;
if (ioctl(fd, FS_IOC_GETFLAGS, &attr) == 0) {
attr |= FS_NOCOW_FL;
ioctl(fd, FS_IOC_SETFLAGS, &attr);
}
#endif
}
if (ftruncate(fd, total_size) != 0) {
result = -errno;
error_setg_errno(errp, -result, "Could not resize file");
goto out_close;
}
switch (prealloc) {
#ifdef CONFIG_POSIX_FALLOCATE
case PREALLOC_MODE_FALLOC:
/* posix_fallocate() doesn't set errno. */
result = -posix_fallocate(fd, 0, total_size);
if (result != 0) {
error_setg_errno(errp, -result,
"Could not preallocate data for the new file");
}
break;
#endif
case PREALLOC_MODE_FULL:
{
int64_t num = 0, left = total_size;
buf = g_malloc0(65536);
while (left > 0) {
num = MIN(left, 65536);
result = write(fd, buf, num);
if (result < 0) {
result = -errno;
error_setg_errno(errp, -result,
"Could not write to the new file");
break;
}
left -= result;
}
if (result >= 0) {
result = fsync(fd);
if (result < 0) {
result = -errno;
error_setg_errno(errp, -result,
"Could not flush new file to disk");
}
}
g_free(buf);
break;
}
case PREALLOC_MODE_OFF:
break;
default:
result = -EINVAL;
error_setg(errp, "Unsupported preallocation mode: %s",
PreallocMode_lookup[prealloc]);
break;
}
out_close:
if (qemu_close(fd) != 0 && result == 0) {
result = -errno;
error_setg_errno(errp, -result, "Could not close the new file");
}
out:
return result;
}
| true | qemu | f6a7240442727cefe000a5b4fdee4d844ddd6bfe | static int raw_create(const char *filename, QemuOpts *opts, Error **errp)
{
int fd;
int result = 0;
int64_t total_size = 0;
bool nocow = false;
PreallocMode prealloc;
char *buf = NULL;
Error *local_err = NULL;
strstart(filename, "file:", &filename);
total_size = ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0),
BDRV_SECTOR_SIZE);
nocow = qemu_opt_get_bool(opts, BLOCK_OPT_NOCOW, false);
buf = qemu_opt_get_del(opts, BLOCK_OPT_PREALLOC);
prealloc = qapi_enum_parse(PreallocMode_lookup, buf,
PREALLOC_MODE__MAX, PREALLOC_MODE_OFF,
&local_err);
g_free(buf);
if (local_err) {
error_propagate(errp, local_err);
result = -EINVAL;
goto out;
}
fd = qemu_open(filename, O_RDWR | O_CREAT | O_TRUNC | O_BINARY,
0644);
if (fd < 0) {
result = -errno;
error_setg_errno(errp, -result, "Could not create file");
goto out;
}
if (nocow) {
#ifdef __linux__
int attr;
if (ioctl(fd, FS_IOC_GETFLAGS, &attr) == 0) {
attr |= FS_NOCOW_FL;
ioctl(fd, FS_IOC_SETFLAGS, &attr);
}
#endif
}
if (ftruncate(fd, total_size) != 0) {
result = -errno;
error_setg_errno(errp, -result, "Could not resize file");
goto out_close;
}
switch (prealloc) {
#ifdef CONFIG_POSIX_FALLOCATE
case PREALLOC_MODE_FALLOC:
result = -posix_fallocate(fd, 0, total_size);
if (result != 0) {
error_setg_errno(errp, -result,
"Could not preallocate data for the new file");
}
break;
#endif
case PREALLOC_MODE_FULL:
{
int64_t num = 0, left = total_size;
buf = g_malloc0(65536);
while (left > 0) {
num = MIN(left, 65536);
result = write(fd, buf, num);
if (result < 0) {
result = -errno;
error_setg_errno(errp, -result,
"Could not write to the new file");
break;
}
left -= result;
}
if (result >= 0) {
result = fsync(fd);
if (result < 0) {
result = -errno;
error_setg_errno(errp, -result,
"Could not flush new file to disk");
}
}
g_free(buf);
break;
}
case PREALLOC_MODE_OFF:
break;
default:
result = -EINVAL;
error_setg(errp, "Unsupported preallocation mode: %s",
PreallocMode_lookup[prealloc]);
break;
}
out_close:
if (qemu_close(fd) != 0 && result == 0) {
result = -errno;
error_setg_errno(errp, -result, "Could not close the new file");
}
out:
return result;
}
| {
"code": [
" if (ftruncate(fd, total_size) != 0) {",
" result = -errno;",
" error_setg_errno(errp, -result, \"Could not resize file\");",
" goto out_close;",
"out_close:"
],
"line_no": [
101,
61,
105,
107,
207
]
} | static int FUNC_0(const char *VAR_0, QemuOpts *VAR_1, Error **VAR_2)
{
int VAR_3;
int VAR_4 = 0;
int64_t total_size = 0;
bool nocow = false;
PreallocMode prealloc;
char *VAR_5 = NULL;
Error *local_err = NULL;
strstart(VAR_0, "file:", &VAR_0);
total_size = ROUND_UP(qemu_opt_get_size_del(VAR_1, BLOCK_OPT_SIZE, 0),
BDRV_SECTOR_SIZE);
nocow = qemu_opt_get_bool(VAR_1, BLOCK_OPT_NOCOW, false);
VAR_5 = qemu_opt_get_del(VAR_1, BLOCK_OPT_PREALLOC);
prealloc = qapi_enum_parse(PreallocMode_lookup, VAR_5,
PREALLOC_MODE__MAX, PREALLOC_MODE_OFF,
&local_err);
g_free(VAR_5);
if (local_err) {
error_propagate(VAR_2, local_err);
VAR_4 = -EINVAL;
goto out;
}
VAR_3 = qemu_open(VAR_0, O_RDWR | O_CREAT | O_TRUNC | O_BINARY,
0644);
if (VAR_3 < 0) {
VAR_4 = -errno;
error_setg_errno(VAR_2, -VAR_4, "Could not create file");
goto out;
}
if (nocow) {
#ifdef __linux__
int attr;
if (ioctl(VAR_3, FS_IOC_GETFLAGS, &attr) == 0) {
attr |= FS_NOCOW_FL;
ioctl(VAR_3, FS_IOC_SETFLAGS, &attr);
}
#endif
}
if (ftruncate(VAR_3, total_size) != 0) {
VAR_4 = -errno;
error_setg_errno(VAR_2, -VAR_4, "Could not resize file");
goto out_close;
}
switch (prealloc) {
#ifdef CONFIG_POSIX_FALLOCATE
case PREALLOC_MODE_FALLOC:
VAR_4 = -posix_fallocate(VAR_3, 0, total_size);
if (VAR_4 != 0) {
error_setg_errno(VAR_2, -VAR_4,
"Could not preallocate data for the new file");
}
break;
#endif
case PREALLOC_MODE_FULL:
{
int64_t num = 0, left = total_size;
VAR_5 = g_malloc0(65536);
while (left > 0) {
num = MIN(left, 65536);
VAR_4 = write(VAR_3, VAR_5, num);
if (VAR_4 < 0) {
VAR_4 = -errno;
error_setg_errno(VAR_2, -VAR_4,
"Could not write to the new file");
break;
}
left -= VAR_4;
}
if (VAR_4 >= 0) {
VAR_4 = fsync(VAR_3);
if (VAR_4 < 0) {
VAR_4 = -errno;
error_setg_errno(VAR_2, -VAR_4,
"Could not flush new file to disk");
}
}
g_free(VAR_5);
break;
}
case PREALLOC_MODE_OFF:
break;
default:
VAR_4 = -EINVAL;
error_setg(VAR_2, "Unsupported preallocation mode: %s",
PreallocMode_lookup[prealloc]);
break;
}
out_close:
if (qemu_close(VAR_3) != 0 && VAR_4 == 0) {
VAR_4 = -errno;
error_setg_errno(VAR_2, -VAR_4, "Could not close the new file");
}
out:
return VAR_4;
}
| [
"static int FUNC_0(const char *VAR_0, QemuOpts *VAR_1, Error **VAR_2)\n{",
"int VAR_3;",
"int VAR_4 = 0;",
"int64_t total_size = 0;",
"bool nocow = false;",
"PreallocMode prealloc;",
"char *VAR_5 = NULL;",
"Error *local_err = NULL;",
"strstart(VAR_0, \"file:\", &VAR_0);",
"total_size = ROUND_UP(qemu_opt_get_size_del(VAR_1, BLOCK_OPT_SIZE, 0),\nBDRV_SECTOR_SIZE);",
"nocow = qemu_opt_get_bool(VAR_1, BLOCK_OPT_NOCOW, false);",
"VAR_5 = qemu_opt_get_del(VAR_1, BLOCK_OPT_PREALLOC);",
"prealloc = qapi_enum_parse(PreallocMode_lookup, VAR_5,\nPREALLOC_MODE__MAX, PREALLOC_MODE_OFF,\n&local_err);",
"g_free(VAR_5);",
"if (local_err) {",
"error_propagate(VAR_2, local_err);",
"VAR_4 = -EINVAL;",
"goto out;",
"}",
"VAR_3 = qemu_open(VAR_0, O_RDWR | O_CREAT | O_TRUNC | O_BINARY,\n0644);",
"if (VAR_3 < 0) {",
"VAR_4 = -errno;",
"error_setg_errno(VAR_2, -VAR_4, \"Could not create file\");",
"goto out;",
"}",
"if (nocow) {",
"#ifdef __linux__\nint attr;",
"if (ioctl(VAR_3, FS_IOC_GETFLAGS, &attr) == 0) {",
"attr |= FS_NOCOW_FL;",
"ioctl(VAR_3, FS_IOC_SETFLAGS, &attr);",
"}",
"#endif\n}",
"if (ftruncate(VAR_3, total_size) != 0) {",
"VAR_4 = -errno;",
"error_setg_errno(VAR_2, -VAR_4, \"Could not resize file\");",
"goto out_close;",
"}",
"switch (prealloc) {",
"#ifdef CONFIG_POSIX_FALLOCATE\ncase PREALLOC_MODE_FALLOC:\nVAR_4 = -posix_fallocate(VAR_3, 0, total_size);",
"if (VAR_4 != 0) {",
"error_setg_errno(VAR_2, -VAR_4,\n\"Could not preallocate data for the new file\");",
"}",
"break;",
"#endif\ncase PREALLOC_MODE_FULL:\n{",
"int64_t num = 0, left = total_size;",
"VAR_5 = g_malloc0(65536);",
"while (left > 0) {",
"num = MIN(left, 65536);",
"VAR_4 = write(VAR_3, VAR_5, num);",
"if (VAR_4 < 0) {",
"VAR_4 = -errno;",
"error_setg_errno(VAR_2, -VAR_4,\n\"Could not write to the new file\");",
"break;",
"}",
"left -= VAR_4;",
"}",
"if (VAR_4 >= 0) {",
"VAR_4 = fsync(VAR_3);",
"if (VAR_4 < 0) {",
"VAR_4 = -errno;",
"error_setg_errno(VAR_2, -VAR_4,\n\"Could not flush new file to disk\");",
"}",
"}",
"g_free(VAR_5);",
"break;",
"}",
"case PREALLOC_MODE_OFF:\nbreak;",
"default:\nVAR_4 = -EINVAL;",
"error_setg(VAR_2, \"Unsupported preallocation mode: %s\",\nPreallocMode_lookup[prealloc]);",
"break;",
"}",
"out_close:\nif (qemu_close(VAR_3) != 0 && VAR_4 == 0) {",
"VAR_4 = -errno;",
"error_setg_errno(VAR_2, -VAR_4, \"Could not close the new file\");",
"}",
"out:\nreturn VAR_4;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
27,
29
],
[
31
],
[
33
],
[
35,
37,
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73,
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95,
97
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
113
],
[
115,
117,
121
],
[
123
],
[
125,
127
],
[
129
],
[
131
],
[
133,
135,
137
],
[
139
],
[
141
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155,
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175,
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189,
191
],
[
193,
195
],
[
197,
199
],
[
201
],
[
203
],
[
207,
209
],
[
211
],
[
213
],
[
215
],
[
217,
219
],
[
221
]
] |
22,324 | static int aasc_decode_frame(AVCodecContext *avctx,
void *data, int *got_frame,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
AascContext *s = avctx->priv_data;
int compr, i, stride, ret;
if (buf_size < 4)
if ((ret = ff_reget_buffer(avctx, s->frame)) < 0) {
av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
return ret;
}
compr = AV_RL32(buf);
buf += 4;
buf_size -= 4;
switch (compr) {
case 0:
stride = (avctx->width * 3 + 3) & ~3;
for (i = avctx->height - 1; i >= 0; i--) {
memcpy(s->frame->data[0] + i * s->frame->linesize[0], buf, avctx->width * 3);
buf += stride;
}
break;
case 1:
bytestream2_init(&s->gb, buf, buf_size);
ff_msrle_decode(avctx, (AVPicture*)s->frame, 8, &s->gb);
break;
default:
av_log(avctx, AV_LOG_ERROR, "Unknown compression type %d\n", compr);
}
*got_frame = 1;
if ((ret = av_frame_ref(data, s->frame)) < 0)
return ret;
/* report that the buffer was completely consumed */
return buf_size;
} | true | FFmpeg | 62b1e3b1031e901105d78e831120de8e4c3e0013 | static int aasc_decode_frame(AVCodecContext *avctx,
void *data, int *got_frame,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
AascContext *s = avctx->priv_data;
int compr, i, stride, ret;
if (buf_size < 4)
if ((ret = ff_reget_buffer(avctx, s->frame)) < 0) {
av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
return ret;
}
compr = AV_RL32(buf);
buf += 4;
buf_size -= 4;
switch (compr) {
case 0:
stride = (avctx->width * 3 + 3) & ~3;
for (i = avctx->height - 1; i >= 0; i--) {
memcpy(s->frame->data[0] + i * s->frame->linesize[0], buf, avctx->width * 3);
buf += stride;
}
break;
case 1:
bytestream2_init(&s->gb, buf, buf_size);
ff_msrle_decode(avctx, (AVPicture*)s->frame, 8, &s->gb);
break;
default:
av_log(avctx, AV_LOG_ERROR, "Unknown compression type %d\n", compr);
}
*got_frame = 1;
if ((ret = av_frame_ref(data, s->frame)) < 0)
return ret;
return buf_size;
} | {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0,
void *VAR_1, int *VAR_2,
AVPacket *VAR_3)
{
const uint8_t *VAR_4 = VAR_3->VAR_1;
int VAR_5 = VAR_3->size;
AascContext *s = VAR_0->priv_data;
int VAR_6, VAR_7, VAR_8, VAR_9;
if (VAR_5 < 4)
if ((VAR_9 = ff_reget_buffer(VAR_0, s->frame)) < 0) {
av_log(VAR_0, AV_LOG_ERROR, "reget_buffer() failed\n");
return VAR_9;
}
VAR_6 = AV_RL32(VAR_4);
VAR_4 += 4;
VAR_5 -= 4;
switch (VAR_6) {
case 0:
VAR_8 = (VAR_0->width * 3 + 3) & ~3;
for (VAR_7 = VAR_0->height - 1; VAR_7 >= 0; VAR_7--) {
memcpy(s->frame->VAR_1[0] + VAR_7 * s->frame->linesize[0], VAR_4, VAR_0->width * 3);
VAR_4 += VAR_8;
}
break;
case 1:
bytestream2_init(&s->gb, VAR_4, VAR_5);
ff_msrle_decode(VAR_0, (AVPicture*)s->frame, 8, &s->gb);
break;
default:
av_log(VAR_0, AV_LOG_ERROR, "Unknown compression type %d\n", VAR_6);
}
*VAR_2 = 1;
if ((VAR_9 = av_frame_ref(VAR_1, s->frame)) < 0)
return VAR_9;
return VAR_5;
} | [
"static int FUNC_0(AVCodecContext *VAR_0,\nvoid *VAR_1, int *VAR_2,\nAVPacket *VAR_3)\n{",
"const uint8_t *VAR_4 = VAR_3->VAR_1;",
"int VAR_5 = VAR_3->size;",
"AascContext *s = VAR_0->priv_data;",
"int VAR_6, VAR_7, VAR_8, VAR_9;",
"if (VAR_5 < 4)\nif ((VAR_9 = ff_reget_buffer(VAR_0, s->frame)) < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"reget_buffer() failed\\n\");",
"return VAR_9;",
"}",
"VAR_6 = AV_RL32(VAR_4);",
"VAR_4 += 4;",
"VAR_5 -= 4;",
"switch (VAR_6) {",
"case 0:\nVAR_8 = (VAR_0->width * 3 + 3) & ~3;",
"for (VAR_7 = VAR_0->height - 1; VAR_7 >= 0; VAR_7--) {",
"memcpy(s->frame->VAR_1[0] + VAR_7 * s->frame->linesize[0], VAR_4, VAR_0->width * 3);",
"VAR_4 += VAR_8;",
"}",
"break;",
"case 1:\nbytestream2_init(&s->gb, VAR_4, VAR_5);",
"ff_msrle_decode(VAR_0, (AVPicture*)s->frame, 8, &s->gb);",
"break;",
"default:\nav_log(VAR_0, AV_LOG_ERROR, \"Unknown compression type %d\\n\", VAR_6);",
"}",
"*VAR_2 = 1;",
"if ((VAR_9 = av_frame_ref(VAR_1, s->frame)) < 0)\nreturn VAR_9;",
"return VAR_5;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19,
24
],
[
26
],
[
28
],
[
30
],
[
34
],
[
36
],
[
38
],
[
40
],
[
42,
44
],
[
48
],
[
50
],
[
52
],
[
54
],
[
56
],
[
58,
60
],
[
62
],
[
64
],
[
66,
68
],
[
71
],
[
75
],
[
77,
79
],
[
85
],
[
87
]
] |
22,325 | void mips_malta_init(MachineState *machine)
{
ram_addr_t ram_size = machine->ram_size;
ram_addr_t ram_low_size;
const char *cpu_model = machine->cpu_model;
const char *kernel_filename = machine->kernel_filename;
const char *kernel_cmdline = machine->kernel_cmdline;
const char *initrd_filename = machine->initrd_filename;
char *filename;
pflash_t *fl;
MemoryRegion *system_memory = get_system_memory();
MemoryRegion *ram_high = g_new(MemoryRegion, 1);
MemoryRegion *ram_low_preio = g_new(MemoryRegion, 1);
MemoryRegion *ram_low_postio;
MemoryRegion *bios, *bios_copy = g_new(MemoryRegion, 1);
target_long bios_size = FLASH_SIZE;
const size_t smbus_eeprom_size = 8 * 256;
uint8_t *smbus_eeprom_buf = g_malloc0(smbus_eeprom_size);
int64_t kernel_entry, bootloader_run_addr;
PCIBus *pci_bus;
ISABus *isa_bus;
MIPSCPU *cpu;
CPUMIPSState *env;
qemu_irq *isa_irq;
qemu_irq *cpu_exit_irq;
int piix4_devfn;
I2CBus *smbus;
int i;
DriveInfo *dinfo;
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
DriveInfo *fd[MAX_FD];
int fl_idx = 0;
int fl_sectors = bios_size >> 16;
int be;
DeviceState *dev = qdev_create(NULL, TYPE_MIPS_MALTA);
MaltaState *s = MIPS_MALTA(dev);
/* The whole address space decoded by the GT-64120A doesn't generate
exception when accessing invalid memory. Create an empty slot to
emulate this feature. */
empty_slot_init(0, 0x20000000);
qdev_init_nofail(dev);
/* Make sure the first 3 serial ports are associated with a device. */
for(i = 0; i < 3; i++) {
if (!serial_hds[i]) {
char label[32];
snprintf(label, sizeof(label), "serial%d", i);
serial_hds[i] = qemu_chr_new(label, "null", NULL);
}
}
/* init CPUs */
if (cpu_model == NULL) {
#ifdef TARGET_MIPS64
cpu_model = "20Kc";
#else
cpu_model = "24Kf";
#endif
}
for (i = 0; i < smp_cpus; i++) {
cpu = cpu_mips_init(cpu_model);
if (cpu == NULL) {
fprintf(stderr, "Unable to find CPU definition\n");
exit(1);
}
env = &cpu->env;
/* Init internal devices */
cpu_mips_irq_init_cpu(env);
cpu_mips_clock_init(env);
qemu_register_reset(main_cpu_reset, cpu);
}
cpu = MIPS_CPU(first_cpu);
env = &cpu->env;
/* allocate RAM */
if (ram_size > (2048u << 20)) {
fprintf(stderr,
"qemu: Too much memory for this machine: %d MB, maximum 2048 MB\n",
((unsigned int)ram_size / (1 << 20)));
exit(1);
}
/* register RAM at high address where it is undisturbed by IO */
memory_region_allocate_system_memory(ram_high, NULL, "mips_malta.ram",
ram_size);
memory_region_add_subregion(system_memory, 0x80000000, ram_high);
/* alias for pre IO hole access */
memory_region_init_alias(ram_low_preio, NULL, "mips_malta_low_preio.ram",
ram_high, 0, MIN(ram_size, (256 << 20)));
memory_region_add_subregion(system_memory, 0, ram_low_preio);
/* alias for post IO hole access, if there is enough RAM */
if (ram_size > (512 << 20)) {
ram_low_postio = g_new(MemoryRegion, 1);
memory_region_init_alias(ram_low_postio, NULL,
"mips_malta_low_postio.ram",
ram_high, 512 << 20,
ram_size - (512 << 20));
memory_region_add_subregion(system_memory, 512 << 20, ram_low_postio);
}
/* generate SPD EEPROM data */
generate_eeprom_spd(&smbus_eeprom_buf[0 * 256], ram_size);
generate_eeprom_serial(&smbus_eeprom_buf[6 * 256]);
#ifdef TARGET_WORDS_BIGENDIAN
be = 1;
#else
be = 0;
#endif
/* FPGA */
/* The CBUS UART is attached to the MIPS CPU INT2 pin, ie interrupt 4 */
malta_fpga_init(system_memory, FPGA_ADDRESS, env->irq[4], serial_hds[2]);
/* Load firmware in flash / BIOS. */
dinfo = drive_get(IF_PFLASH, 0, fl_idx);
#ifdef DEBUG_BOARD_INIT
if (dinfo) {
printf("Register parallel flash %d size " TARGET_FMT_lx " at "
"addr %08llx '%s' %x\n",
fl_idx, bios_size, FLASH_ADDRESS,
blk_name(dinfo->bdrv), fl_sectors);
}
#endif
fl = pflash_cfi01_register(FLASH_ADDRESS, NULL, "mips_malta.bios",
BIOS_SIZE,
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
65536, fl_sectors,
4, 0x0000, 0x0000, 0x0000, 0x0000, be);
bios = pflash_cfi01_get_memory(fl);
fl_idx++;
if (kernel_filename) {
ram_low_size = MIN(ram_size, 256 << 20);
/* For KVM we reserve 1MB of RAM for running bootloader */
if (kvm_enabled()) {
ram_low_size -= 0x100000;
bootloader_run_addr = 0x40000000 + ram_low_size;
} else {
bootloader_run_addr = 0xbfc00000;
}
/* Write a small bootloader to the flash location. */
loaderparams.ram_size = ram_low_size;
loaderparams.kernel_filename = kernel_filename;
loaderparams.kernel_cmdline = kernel_cmdline;
loaderparams.initrd_filename = initrd_filename;
kernel_entry = load_kernel();
write_bootloader(env, memory_region_get_ram_ptr(bios),
bootloader_run_addr, kernel_entry);
if (kvm_enabled()) {
/* Write the bootloader code @ the end of RAM, 1MB reserved */
write_bootloader(env, memory_region_get_ram_ptr(ram_low_preio) +
ram_low_size,
bootloader_run_addr, kernel_entry);
}
} else {
/* The flash region isn't executable from a KVM guest */
if (kvm_enabled()) {
error_report("KVM enabled but no -kernel argument was specified. "
"Booting from flash is not supported with KVM.");
exit(1);
}
/* Load firmware from flash. */
if (!dinfo) {
/* Load a BIOS image. */
if (bios_name == NULL) {
bios_name = BIOS_FILENAME;
}
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (filename) {
bios_size = load_image_targphys(filename, FLASH_ADDRESS,
BIOS_SIZE);
g_free(filename);
} else {
bios_size = -1;
}
if ((bios_size < 0 || bios_size > BIOS_SIZE) &&
!kernel_filename && !qtest_enabled()) {
error_report("Could not load MIPS bios '%s', and no "
"-kernel argument was specified", bios_name);
exit(1);
}
}
/* In little endian mode the 32bit words in the bios are swapped,
a neat trick which allows bi-endian firmware. */
#ifndef TARGET_WORDS_BIGENDIAN
{
uint32_t *end, *addr = rom_ptr(FLASH_ADDRESS);
if (!addr) {
addr = memory_region_get_ram_ptr(bios);
}
end = (void *)addr + MIN(bios_size, 0x3e0000);
while (addr < end) {
bswap32s(addr);
addr++;
}
}
#endif
}
/*
* Map the BIOS at a 2nd physical location, as on the real board.
* Copy it so that we can patch in the MIPS revision, which cannot be
* handled by an overlapping region as the resulting ROM code subpage
* regions are not executable.
*/
memory_region_init_ram(bios_copy, NULL, "bios.1fc", BIOS_SIZE,
&error_abort);
if (!rom_copy(memory_region_get_ram_ptr(bios_copy),
FLASH_ADDRESS, BIOS_SIZE)) {
memcpy(memory_region_get_ram_ptr(bios_copy),
memory_region_get_ram_ptr(bios), BIOS_SIZE);
}
memory_region_set_readonly(bios_copy, true);
memory_region_add_subregion(system_memory, RESET_ADDRESS, bios_copy);
/* Board ID = 0x420 (Malta Board with CoreLV) */
stl_p(memory_region_get_ram_ptr(bios_copy) + 0x10, 0x00000420);
/* Init internal devices */
cpu_mips_irq_init_cpu(env);
cpu_mips_clock_init(env);
/*
* We have a circular dependency problem: pci_bus depends on isa_irq,
* isa_irq is provided by i8259, i8259 depends on ISA, ISA depends
* on piix4, and piix4 depends on pci_bus. To stop the cycle we have
* qemu_irq_proxy() adds an extra bit of indirection, allowing us
* to resolve the isa_irq -> i8259 dependency after i8259 is initialized.
*/
isa_irq = qemu_irq_proxy(&s->i8259, 16);
/* Northbridge */
pci_bus = gt64120_register(isa_irq);
/* Southbridge */
ide_drive_get(hd, ARRAY_SIZE(hd));
piix4_devfn = piix4_init(pci_bus, &isa_bus, 80);
/* Interrupt controller */
/* The 8259 is attached to the MIPS CPU INT0 pin, ie interrupt 2 */
s->i8259 = i8259_init(isa_bus, env->irq[2]);
isa_bus_irqs(isa_bus, s->i8259);
pci_piix4_ide_init(pci_bus, hd, piix4_devfn + 1);
pci_create_simple(pci_bus, piix4_devfn + 2, "piix4-usb-uhci");
smbus = piix4_pm_init(pci_bus, piix4_devfn + 3, 0x1100,
isa_get_irq(NULL, 9), NULL, 0, NULL, NULL);
smbus_eeprom_init(smbus, 8, smbus_eeprom_buf, smbus_eeprom_size);
g_free(smbus_eeprom_buf);
pit = pit_init(isa_bus, 0x40, 0, NULL);
cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1);
DMA_init(0, cpu_exit_irq);
/* Super I/O */
isa_create_simple(isa_bus, "i8042");
rtc_init(isa_bus, 2000, NULL);
serial_hds_isa_init(isa_bus, 2);
parallel_hds_isa_init(isa_bus, 1);
for(i = 0; i < MAX_FD; i++) {
fd[i] = drive_get(IF_FLOPPY, 0, i);
}
fdctrl_init_isa(isa_bus, fd);
/* Network card */
network_init(pci_bus);
/* Optional PCI video card */
pci_vga_init(pci_bus);
}
| false | qemu | 6e7d82497dc8da7d420c8fa6632d759e08a18bc3 | void mips_malta_init(MachineState *machine)
{
ram_addr_t ram_size = machine->ram_size;
ram_addr_t ram_low_size;
const char *cpu_model = machine->cpu_model;
const char *kernel_filename = machine->kernel_filename;
const char *kernel_cmdline = machine->kernel_cmdline;
const char *initrd_filename = machine->initrd_filename;
char *filename;
pflash_t *fl;
MemoryRegion *system_memory = get_system_memory();
MemoryRegion *ram_high = g_new(MemoryRegion, 1);
MemoryRegion *ram_low_preio = g_new(MemoryRegion, 1);
MemoryRegion *ram_low_postio;
MemoryRegion *bios, *bios_copy = g_new(MemoryRegion, 1);
target_long bios_size = FLASH_SIZE;
const size_t smbus_eeprom_size = 8 * 256;
uint8_t *smbus_eeprom_buf = g_malloc0(smbus_eeprom_size);
int64_t kernel_entry, bootloader_run_addr;
PCIBus *pci_bus;
ISABus *isa_bus;
MIPSCPU *cpu;
CPUMIPSState *env;
qemu_irq *isa_irq;
qemu_irq *cpu_exit_irq;
int piix4_devfn;
I2CBus *smbus;
int i;
DriveInfo *dinfo;
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
DriveInfo *fd[MAX_FD];
int fl_idx = 0;
int fl_sectors = bios_size >> 16;
int be;
DeviceState *dev = qdev_create(NULL, TYPE_MIPS_MALTA);
MaltaState *s = MIPS_MALTA(dev);
empty_slot_init(0, 0x20000000);
qdev_init_nofail(dev);
for(i = 0; i < 3; i++) {
if (!serial_hds[i]) {
char label[32];
snprintf(label, sizeof(label), "serial%d", i);
serial_hds[i] = qemu_chr_new(label, "null", NULL);
}
}
if (cpu_model == NULL) {
#ifdef TARGET_MIPS64
cpu_model = "20Kc";
#else
cpu_model = "24Kf";
#endif
}
for (i = 0; i < smp_cpus; i++) {
cpu = cpu_mips_init(cpu_model);
if (cpu == NULL) {
fprintf(stderr, "Unable to find CPU definition\n");
exit(1);
}
env = &cpu->env;
cpu_mips_irq_init_cpu(env);
cpu_mips_clock_init(env);
qemu_register_reset(main_cpu_reset, cpu);
}
cpu = MIPS_CPU(first_cpu);
env = &cpu->env;
if (ram_size > (2048u << 20)) {
fprintf(stderr,
"qemu: Too much memory for this machine: %d MB, maximum 2048 MB\n",
((unsigned int)ram_size / (1 << 20)));
exit(1);
}
memory_region_allocate_system_memory(ram_high, NULL, "mips_malta.ram",
ram_size);
memory_region_add_subregion(system_memory, 0x80000000, ram_high);
memory_region_init_alias(ram_low_preio, NULL, "mips_malta_low_preio.ram",
ram_high, 0, MIN(ram_size, (256 << 20)));
memory_region_add_subregion(system_memory, 0, ram_low_preio);
if (ram_size > (512 << 20)) {
ram_low_postio = g_new(MemoryRegion, 1);
memory_region_init_alias(ram_low_postio, NULL,
"mips_malta_low_postio.ram",
ram_high, 512 << 20,
ram_size - (512 << 20));
memory_region_add_subregion(system_memory, 512 << 20, ram_low_postio);
}
generate_eeprom_spd(&smbus_eeprom_buf[0 * 256], ram_size);
generate_eeprom_serial(&smbus_eeprom_buf[6 * 256]);
#ifdef TARGET_WORDS_BIGENDIAN
be = 1;
#else
be = 0;
#endif
malta_fpga_init(system_memory, FPGA_ADDRESS, env->irq[4], serial_hds[2]);
dinfo = drive_get(IF_PFLASH, 0, fl_idx);
#ifdef DEBUG_BOARD_INIT
if (dinfo) {
printf("Register parallel flash %d size " TARGET_FMT_lx " at "
"addr %08llx '%s' %x\n",
fl_idx, bios_size, FLASH_ADDRESS,
blk_name(dinfo->bdrv), fl_sectors);
}
#endif
fl = pflash_cfi01_register(FLASH_ADDRESS, NULL, "mips_malta.bios",
BIOS_SIZE,
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
65536, fl_sectors,
4, 0x0000, 0x0000, 0x0000, 0x0000, be);
bios = pflash_cfi01_get_memory(fl);
fl_idx++;
if (kernel_filename) {
ram_low_size = MIN(ram_size, 256 << 20);
if (kvm_enabled()) {
ram_low_size -= 0x100000;
bootloader_run_addr = 0x40000000 + ram_low_size;
} else {
bootloader_run_addr = 0xbfc00000;
}
loaderparams.ram_size = ram_low_size;
loaderparams.kernel_filename = kernel_filename;
loaderparams.kernel_cmdline = kernel_cmdline;
loaderparams.initrd_filename = initrd_filename;
kernel_entry = load_kernel();
write_bootloader(env, memory_region_get_ram_ptr(bios),
bootloader_run_addr, kernel_entry);
if (kvm_enabled()) {
write_bootloader(env, memory_region_get_ram_ptr(ram_low_preio) +
ram_low_size,
bootloader_run_addr, kernel_entry);
}
} else {
if (kvm_enabled()) {
error_report("KVM enabled but no -kernel argument was specified. "
"Booting from flash is not supported with KVM.");
exit(1);
}
if (!dinfo) {
if (bios_name == NULL) {
bios_name = BIOS_FILENAME;
}
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (filename) {
bios_size = load_image_targphys(filename, FLASH_ADDRESS,
BIOS_SIZE);
g_free(filename);
} else {
bios_size = -1;
}
if ((bios_size < 0 || bios_size > BIOS_SIZE) &&
!kernel_filename && !qtest_enabled()) {
error_report("Could not load MIPS bios '%s', and no "
"-kernel argument was specified", bios_name);
exit(1);
}
}
#ifndef TARGET_WORDS_BIGENDIAN
{
uint32_t *end, *addr = rom_ptr(FLASH_ADDRESS);
if (!addr) {
addr = memory_region_get_ram_ptr(bios);
}
end = (void *)addr + MIN(bios_size, 0x3e0000);
while (addr < end) {
bswap32s(addr);
addr++;
}
}
#endif
}
memory_region_init_ram(bios_copy, NULL, "bios.1fc", BIOS_SIZE,
&error_abort);
if (!rom_copy(memory_region_get_ram_ptr(bios_copy),
FLASH_ADDRESS, BIOS_SIZE)) {
memcpy(memory_region_get_ram_ptr(bios_copy),
memory_region_get_ram_ptr(bios), BIOS_SIZE);
}
memory_region_set_readonly(bios_copy, true);
memory_region_add_subregion(system_memory, RESET_ADDRESS, bios_copy);
stl_p(memory_region_get_ram_ptr(bios_copy) + 0x10, 0x00000420);
cpu_mips_irq_init_cpu(env);
cpu_mips_clock_init(env);
isa_irq = qemu_irq_proxy(&s->i8259, 16);
pci_bus = gt64120_register(isa_irq);
ide_drive_get(hd, ARRAY_SIZE(hd));
piix4_devfn = piix4_init(pci_bus, &isa_bus, 80);
s->i8259 = i8259_init(isa_bus, env->irq[2]);
isa_bus_irqs(isa_bus, s->i8259);
pci_piix4_ide_init(pci_bus, hd, piix4_devfn + 1);
pci_create_simple(pci_bus, piix4_devfn + 2, "piix4-usb-uhci");
smbus = piix4_pm_init(pci_bus, piix4_devfn + 3, 0x1100,
isa_get_irq(NULL, 9), NULL, 0, NULL, NULL);
smbus_eeprom_init(smbus, 8, smbus_eeprom_buf, smbus_eeprom_size);
g_free(smbus_eeprom_buf);
pit = pit_init(isa_bus, 0x40, 0, NULL);
cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1);
DMA_init(0, cpu_exit_irq);
isa_create_simple(isa_bus, "i8042");
rtc_init(isa_bus, 2000, NULL);
serial_hds_isa_init(isa_bus, 2);
parallel_hds_isa_init(isa_bus, 1);
for(i = 0; i < MAX_FD; i++) {
fd[i] = drive_get(IF_FLOPPY, 0, i);
}
fdctrl_init_isa(isa_bus, fd);
network_init(pci_bus);
pci_vga_init(pci_bus);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(MachineState *VAR_0)
{
ram_addr_t ram_size = VAR_0->ram_size;
ram_addr_t ram_low_size;
const char *VAR_1 = VAR_0->VAR_1;
const char *VAR_2 = VAR_0->VAR_2;
const char *VAR_3 = VAR_0->VAR_3;
const char *VAR_4 = VAR_0->VAR_4;
char *VAR_5;
pflash_t *fl;
MemoryRegion *system_memory = get_system_memory();
MemoryRegion *ram_high = g_new(MemoryRegion, 1);
MemoryRegion *ram_low_preio = g_new(MemoryRegion, 1);
MemoryRegion *ram_low_postio;
MemoryRegion *bios, *bios_copy = g_new(MemoryRegion, 1);
target_long bios_size = FLASH_SIZE;
const size_t VAR_6 = 8 * 256;
uint8_t *smbus_eeprom_buf = g_malloc0(VAR_6);
int64_t kernel_entry, bootloader_run_addr;
PCIBus *pci_bus;
ISABus *isa_bus;
MIPSCPU *cpu;
CPUMIPSState *env;
qemu_irq *isa_irq;
qemu_irq *cpu_exit_irq;
int VAR_7;
I2CBus *smbus;
int VAR_8;
DriveInfo *dinfo;
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
DriveInfo *fd[MAX_FD];
int VAR_9 = 0;
int VAR_10 = bios_size >> 16;
int VAR_11;
DeviceState *dev = qdev_create(NULL, TYPE_MIPS_MALTA);
MaltaState *s = MIPS_MALTA(dev);
empty_slot_init(0, 0x20000000);
qdev_init_nofail(dev);
for(VAR_8 = 0; VAR_8 < 3; VAR_8++) {
if (!serial_hds[VAR_8]) {
char VAR_12[32];
snprintf(VAR_12, sizeof(VAR_12), "serial%d", VAR_8);
serial_hds[VAR_8] = qemu_chr_new(VAR_12, "null", NULL);
}
}
if (VAR_1 == NULL) {
#ifdef TARGET_MIPS64
VAR_1 = "20Kc";
#else
VAR_1 = "24Kf";
#endif
}
for (VAR_8 = 0; VAR_8 < smp_cpus; VAR_8++) {
cpu = cpu_mips_init(VAR_1);
if (cpu == NULL) {
fprintf(stderr, "Unable to find CPU definition\n");
exit(1);
}
env = &cpu->env;
cpu_mips_irq_init_cpu(env);
cpu_mips_clock_init(env);
qemu_register_reset(main_cpu_reset, cpu);
}
cpu = MIPS_CPU(first_cpu);
env = &cpu->env;
if (ram_size > (2048u << 20)) {
fprintf(stderr,
"qemu: Too much memory for this VAR_0: %d MB, maximum 2048 MB\n",
((unsigned int)ram_size / (1 << 20)));
exit(1);
}
memory_region_allocate_system_memory(ram_high, NULL, "mips_malta.ram",
ram_size);
memory_region_add_subregion(system_memory, 0x80000000, ram_high);
memory_region_init_alias(ram_low_preio, NULL, "mips_malta_low_preio.ram",
ram_high, 0, MIN(ram_size, (256 << 20)));
memory_region_add_subregion(system_memory, 0, ram_low_preio);
if (ram_size > (512 << 20)) {
ram_low_postio = g_new(MemoryRegion, 1);
memory_region_init_alias(ram_low_postio, NULL,
"mips_malta_low_postio.ram",
ram_high, 512 << 20,
ram_size - (512 << 20));
memory_region_add_subregion(system_memory, 512 << 20, ram_low_postio);
}
generate_eeprom_spd(&smbus_eeprom_buf[0 * 256], ram_size);
generate_eeprom_serial(&smbus_eeprom_buf[6 * 256]);
#ifdef TARGET_WORDS_BIGENDIAN
VAR_11 = 1;
#else
VAR_11 = 0;
#endif
malta_fpga_init(system_memory, FPGA_ADDRESS, env->irq[4], serial_hds[2]);
dinfo = drive_get(IF_PFLASH, 0, VAR_9);
#ifdef DEBUG_BOARD_INIT
if (dinfo) {
printf("Register parallel flash %d size " TARGET_FMT_lx " at "
"addr %08llx '%s' %x\n",
VAR_9, bios_size, FLASH_ADDRESS,
blk_name(dinfo->bdrv), VAR_10);
}
#endif
fl = pflash_cfi01_register(FLASH_ADDRESS, NULL, "mips_malta.bios",
BIOS_SIZE,
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
65536, VAR_10,
4, 0x0000, 0x0000, 0x0000, 0x0000, VAR_11);
bios = pflash_cfi01_get_memory(fl);
VAR_9++;
if (VAR_2) {
ram_low_size = MIN(ram_size, 256 << 20);
if (kvm_enabled()) {
ram_low_size -= 0x100000;
bootloader_run_addr = 0x40000000 + ram_low_size;
} else {
bootloader_run_addr = 0xbfc00000;
}
loaderparams.ram_size = ram_low_size;
loaderparams.VAR_2 = VAR_2;
loaderparams.VAR_3 = VAR_3;
loaderparams.VAR_4 = VAR_4;
kernel_entry = load_kernel();
write_bootloader(env, memory_region_get_ram_ptr(bios),
bootloader_run_addr, kernel_entry);
if (kvm_enabled()) {
write_bootloader(env, memory_region_get_ram_ptr(ram_low_preio) +
ram_low_size,
bootloader_run_addr, kernel_entry);
}
} else {
if (kvm_enabled()) {
error_report("KVM enabled but no -kernel argument was specified. "
"Booting from flash is not supported with KVM.");
exit(1);
}
if (!dinfo) {
if (bios_name == NULL) {
bios_name = BIOS_FILENAME;
}
VAR_5 = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (VAR_5) {
bios_size = load_image_targphys(VAR_5, FLASH_ADDRESS,
BIOS_SIZE);
g_free(VAR_5);
} else {
bios_size = -1;
}
if ((bios_size < 0 || bios_size > BIOS_SIZE) &&
!VAR_2 && !qtest_enabled()) {
error_report("Could not load MIPS bios '%s', and no "
"-kernel argument was specified", bios_name);
exit(1);
}
}
#ifndef TARGET_WORDS_BIGENDIAN
{
uint32_t *end, *addr = rom_ptr(FLASH_ADDRESS);
if (!addr) {
addr = memory_region_get_ram_ptr(bios);
}
end = (void *)addr + MIN(bios_size, 0x3e0000);
while (addr < end) {
bswap32s(addr);
addr++;
}
}
#endif
}
memory_region_init_ram(bios_copy, NULL, "bios.1fc", BIOS_SIZE,
&error_abort);
if (!rom_copy(memory_region_get_ram_ptr(bios_copy),
FLASH_ADDRESS, BIOS_SIZE)) {
memcpy(memory_region_get_ram_ptr(bios_copy),
memory_region_get_ram_ptr(bios), BIOS_SIZE);
}
memory_region_set_readonly(bios_copy, true);
memory_region_add_subregion(system_memory, RESET_ADDRESS, bios_copy);
stl_p(memory_region_get_ram_ptr(bios_copy) + 0x10, 0x00000420);
cpu_mips_irq_init_cpu(env);
cpu_mips_clock_init(env);
isa_irq = qemu_irq_proxy(&s->i8259, 16);
pci_bus = gt64120_register(isa_irq);
ide_drive_get(hd, ARRAY_SIZE(hd));
VAR_7 = piix4_init(pci_bus, &isa_bus, 80);
s->i8259 = i8259_init(isa_bus, env->irq[2]);
isa_bus_irqs(isa_bus, s->i8259);
pci_piix4_ide_init(pci_bus, hd, VAR_7 + 1);
pci_create_simple(pci_bus, VAR_7 + 2, "piix4-usb-uhci");
smbus = piix4_pm_init(pci_bus, VAR_7 + 3, 0x1100,
isa_get_irq(NULL, 9), NULL, 0, NULL, NULL);
smbus_eeprom_init(smbus, 8, smbus_eeprom_buf, VAR_6);
g_free(smbus_eeprom_buf);
pit = pit_init(isa_bus, 0x40, 0, NULL);
cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1);
DMA_init(0, cpu_exit_irq);
isa_create_simple(isa_bus, "i8042");
rtc_init(isa_bus, 2000, NULL);
serial_hds_isa_init(isa_bus, 2);
parallel_hds_isa_init(isa_bus, 1);
for(VAR_8 = 0; VAR_8 < MAX_FD; VAR_8++) {
fd[VAR_8] = drive_get(IF_FLOPPY, 0, VAR_8);
}
fdctrl_init_isa(isa_bus, fd);
network_init(pci_bus);
pci_vga_init(pci_bus);
}
| [
"void FUNC_0(MachineState *VAR_0)\n{",
"ram_addr_t ram_size = VAR_0->ram_size;",
"ram_addr_t ram_low_size;",
"const char *VAR_1 = VAR_0->VAR_1;",
"const char *VAR_2 = VAR_0->VAR_2;",
"const char *VAR_3 = VAR_0->VAR_3;",
"const char *VAR_4 = VAR_0->VAR_4;",
"char *VAR_5;",
"pflash_t *fl;",
"MemoryRegion *system_memory = get_system_memory();",
"MemoryRegion *ram_high = g_new(MemoryRegion, 1);",
"MemoryRegion *ram_low_preio = g_new(MemoryRegion, 1);",
"MemoryRegion *ram_low_postio;",
"MemoryRegion *bios, *bios_copy = g_new(MemoryRegion, 1);",
"target_long bios_size = FLASH_SIZE;",
"const size_t VAR_6 = 8 * 256;",
"uint8_t *smbus_eeprom_buf = g_malloc0(VAR_6);",
"int64_t kernel_entry, bootloader_run_addr;",
"PCIBus *pci_bus;",
"ISABus *isa_bus;",
"MIPSCPU *cpu;",
"CPUMIPSState *env;",
"qemu_irq *isa_irq;",
"qemu_irq *cpu_exit_irq;",
"int VAR_7;",
"I2CBus *smbus;",
"int VAR_8;",
"DriveInfo *dinfo;",
"DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];",
"DriveInfo *fd[MAX_FD];",
"int VAR_9 = 0;",
"int VAR_10 = bios_size >> 16;",
"int VAR_11;",
"DeviceState *dev = qdev_create(NULL, TYPE_MIPS_MALTA);",
"MaltaState *s = MIPS_MALTA(dev);",
"empty_slot_init(0, 0x20000000);",
"qdev_init_nofail(dev);",
"for(VAR_8 = 0; VAR_8 < 3; VAR_8++) {",
"if (!serial_hds[VAR_8]) {",
"char VAR_12[32];",
"snprintf(VAR_12, sizeof(VAR_12), \"serial%d\", VAR_8);",
"serial_hds[VAR_8] = qemu_chr_new(VAR_12, \"null\", NULL);",
"}",
"}",
"if (VAR_1 == NULL) {",
"#ifdef TARGET_MIPS64\nVAR_1 = \"20Kc\";",
"#else\nVAR_1 = \"24Kf\";",
"#endif\n}",
"for (VAR_8 = 0; VAR_8 < smp_cpus; VAR_8++) {",
"cpu = cpu_mips_init(VAR_1);",
"if (cpu == NULL) {",
"fprintf(stderr, \"Unable to find CPU definition\\n\");",
"exit(1);",
"}",
"env = &cpu->env;",
"cpu_mips_irq_init_cpu(env);",
"cpu_mips_clock_init(env);",
"qemu_register_reset(main_cpu_reset, cpu);",
"}",
"cpu = MIPS_CPU(first_cpu);",
"env = &cpu->env;",
"if (ram_size > (2048u << 20)) {",
"fprintf(stderr,\n\"qemu: Too much memory for this VAR_0: %d MB, maximum 2048 MB\\n\",\n((unsigned int)ram_size / (1 << 20)));",
"exit(1);",
"}",
"memory_region_allocate_system_memory(ram_high, NULL, \"mips_malta.ram\",\nram_size);",
"memory_region_add_subregion(system_memory, 0x80000000, ram_high);",
"memory_region_init_alias(ram_low_preio, NULL, \"mips_malta_low_preio.ram\",\nram_high, 0, MIN(ram_size, (256 << 20)));",
"memory_region_add_subregion(system_memory, 0, ram_low_preio);",
"if (ram_size > (512 << 20)) {",
"ram_low_postio = g_new(MemoryRegion, 1);",
"memory_region_init_alias(ram_low_postio, NULL,\n\"mips_malta_low_postio.ram\",\nram_high, 512 << 20,\nram_size - (512 << 20));",
"memory_region_add_subregion(system_memory, 512 << 20, ram_low_postio);",
"}",
"generate_eeprom_spd(&smbus_eeprom_buf[0 * 256], ram_size);",
"generate_eeprom_serial(&smbus_eeprom_buf[6 * 256]);",
"#ifdef TARGET_WORDS_BIGENDIAN\nVAR_11 = 1;",
"#else\nVAR_11 = 0;",
"#endif\nmalta_fpga_init(system_memory, FPGA_ADDRESS, env->irq[4], serial_hds[2]);",
"dinfo = drive_get(IF_PFLASH, 0, VAR_9);",
"#ifdef DEBUG_BOARD_INIT\nif (dinfo) {",
"printf(\"Register parallel flash %d size \" TARGET_FMT_lx \" at \"\n\"addr %08llx '%s' %x\\n\",\nVAR_9, bios_size, FLASH_ADDRESS,\nblk_name(dinfo->bdrv), VAR_10);",
"}",
"#endif\nfl = pflash_cfi01_register(FLASH_ADDRESS, NULL, \"mips_malta.bios\",\nBIOS_SIZE,\ndinfo ? blk_by_legacy_dinfo(dinfo) : NULL,\n65536, VAR_10,\n4, 0x0000, 0x0000, 0x0000, 0x0000, VAR_11);",
"bios = pflash_cfi01_get_memory(fl);",
"VAR_9++;",
"if (VAR_2) {",
"ram_low_size = MIN(ram_size, 256 << 20);",
"if (kvm_enabled()) {",
"ram_low_size -= 0x100000;",
"bootloader_run_addr = 0x40000000 + ram_low_size;",
"} else {",
"bootloader_run_addr = 0xbfc00000;",
"}",
"loaderparams.ram_size = ram_low_size;",
"loaderparams.VAR_2 = VAR_2;",
"loaderparams.VAR_3 = VAR_3;",
"loaderparams.VAR_4 = VAR_4;",
"kernel_entry = load_kernel();",
"write_bootloader(env, memory_region_get_ram_ptr(bios),\nbootloader_run_addr, kernel_entry);",
"if (kvm_enabled()) {",
"write_bootloader(env, memory_region_get_ram_ptr(ram_low_preio) +\nram_low_size,\nbootloader_run_addr, kernel_entry);",
"}",
"} else {",
"if (kvm_enabled()) {",
"error_report(\"KVM enabled but no -kernel argument was specified. \"\n\"Booting from flash is not supported with KVM.\");",
"exit(1);",
"}",
"if (!dinfo) {",
"if (bios_name == NULL) {",
"bios_name = BIOS_FILENAME;",
"}",
"VAR_5 = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);",
"if (VAR_5) {",
"bios_size = load_image_targphys(VAR_5, FLASH_ADDRESS,\nBIOS_SIZE);",
"g_free(VAR_5);",
"} else {",
"bios_size = -1;",
"}",
"if ((bios_size < 0 || bios_size > BIOS_SIZE) &&\n!VAR_2 && !qtest_enabled()) {",
"error_report(\"Could not load MIPS bios '%s', and no \"\n\"-kernel argument was specified\", bios_name);",
"exit(1);",
"}",
"}",
"#ifndef TARGET_WORDS_BIGENDIAN\n{",
"uint32_t *end, *addr = rom_ptr(FLASH_ADDRESS);",
"if (!addr) {",
"addr = memory_region_get_ram_ptr(bios);",
"}",
"end = (void *)addr + MIN(bios_size, 0x3e0000);",
"while (addr < end) {",
"bswap32s(addr);",
"addr++;",
"}",
"}",
"#endif\n}",
"memory_region_init_ram(bios_copy, NULL, \"bios.1fc\", BIOS_SIZE,\n&error_abort);",
"if (!rom_copy(memory_region_get_ram_ptr(bios_copy),\nFLASH_ADDRESS, BIOS_SIZE)) {",
"memcpy(memory_region_get_ram_ptr(bios_copy),\nmemory_region_get_ram_ptr(bios), BIOS_SIZE);",
"}",
"memory_region_set_readonly(bios_copy, true);",
"memory_region_add_subregion(system_memory, RESET_ADDRESS, bios_copy);",
"stl_p(memory_region_get_ram_ptr(bios_copy) + 0x10, 0x00000420);",
"cpu_mips_irq_init_cpu(env);",
"cpu_mips_clock_init(env);",
"isa_irq = qemu_irq_proxy(&s->i8259, 16);",
"pci_bus = gt64120_register(isa_irq);",
"ide_drive_get(hd, ARRAY_SIZE(hd));",
"VAR_7 = piix4_init(pci_bus, &isa_bus, 80);",
"s->i8259 = i8259_init(isa_bus, env->irq[2]);",
"isa_bus_irqs(isa_bus, s->i8259);",
"pci_piix4_ide_init(pci_bus, hd, VAR_7 + 1);",
"pci_create_simple(pci_bus, VAR_7 + 2, \"piix4-usb-uhci\");",
"smbus = piix4_pm_init(pci_bus, VAR_7 + 3, 0x1100,\nisa_get_irq(NULL, 9), NULL, 0, NULL, NULL);",
"smbus_eeprom_init(smbus, 8, smbus_eeprom_buf, VAR_6);",
"g_free(smbus_eeprom_buf);",
"pit = pit_init(isa_bus, 0x40, 0, NULL);",
"cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1);",
"DMA_init(0, cpu_exit_irq);",
"isa_create_simple(isa_bus, \"i8042\");",
"rtc_init(isa_bus, 2000, NULL);",
"serial_hds_isa_init(isa_bus, 2);",
"parallel_hds_isa_init(isa_bus, 1);",
"for(VAR_8 = 0; VAR_8 < MAX_FD; VAR_8++) {",
"fd[VAR_8] = drive_get(IF_FLOPPY, 0, VAR_8);",
"}",
"fdctrl_init_isa(isa_bus, fd);",
"network_init(pci_bus);",
"pci_vga_init(pci_bus);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
83
],
[
87
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
111
],
[
113,
115
],
[
117,
119
],
[
121,
123
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
161
],
[
163,
165,
167
],
[
169
],
[
171
],
[
177,
179
],
[
181
],
[
187,
189
],
[
191
],
[
197
],
[
199
],
[
201,
203,
205,
207
],
[
209
],
[
211
],
[
217
],
[
219
],
[
223,
225
],
[
227,
229
],
[
231,
237
],
[
243
],
[
245,
247
],
[
249,
251,
253,
255
],
[
257
],
[
259,
261,
263,
265,
267,
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
297
],
[
299
],
[
301
],
[
303
],
[
305
],
[
309,
311
],
[
313
],
[
317,
319,
321
],
[
323
],
[
325
],
[
329
],
[
331,
333
],
[
335
],
[
337
],
[
341
],
[
345
],
[
347
],
[
349
],
[
351
],
[
353
],
[
355,
357
],
[
359
],
[
361
],
[
363
],
[
365
],
[
367,
369
],
[
371,
373
],
[
375
],
[
377
],
[
379
],
[
385,
387
],
[
389
],
[
391
],
[
393
],
[
395
],
[
397
],
[
399
],
[
401
],
[
403
],
[
405
],
[
407
],
[
409,
411
],
[
427,
429
],
[
431,
433
],
[
435,
437
],
[
439
],
[
441
],
[
443
],
[
449
],
[
455
],
[
457
],
[
475
],
[
481
],
[
487
],
[
491
],
[
499
],
[
503
],
[
505
],
[
507
],
[
509,
511
],
[
513
],
[
515
],
[
517
],
[
519
],
[
521
],
[
527
],
[
531
],
[
533
],
[
535
],
[
539
],
[
541
],
[
543
],
[
545
],
[
551
],
[
557
],
[
559
]
] |
22,326 | static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
const char *desc_file_path, QDict *options,
Error **errp)
{
int ret;
int matches;
char access[11];
char type[11];
char fname[512];
const char *p = desc;
int64_t sectors = 0;
int64_t flat_offset;
char *extent_path;
BdrvChild *extent_file;
BDRVVmdkState *s = bs->opaque;
VmdkExtent *extent;
char extent_opt_prefix[32];
Error *local_err = NULL;
while (*p) {
/* parse extent line in one of below formats:
*
* RW [size in sectors] FLAT "file-name.vmdk" OFFSET
* RW [size in sectors] SPARSE "file-name.vmdk"
* RW [size in sectors] VMFS "file-name.vmdk"
* RW [size in sectors] VMFSSPARSE "file-name.vmdk"
*/
flat_offset = -1;
matches = sscanf(p, "%10s %" SCNd64 " %10s \"%511[^\n\r\"]\" %" SCNd64,
access, §ors, type, fname, &flat_offset);
if (matches < 4 || strcmp(access, "RW")) {
goto next_line;
} else if (!strcmp(type, "FLAT")) {
if (matches != 5 || flat_offset < 0) {
error_setg(errp, "Invalid extent lines: \n%s", p);
return -EINVAL;
}
} else if (!strcmp(type, "VMFS")) {
if (matches == 4) {
flat_offset = 0;
} else {
error_setg(errp, "Invalid extent lines:\n%s", p);
return -EINVAL;
}
} else if (matches != 4) {
error_setg(errp, "Invalid extent lines:\n%s", p);
return -EINVAL;
}
if (sectors <= 0 ||
(strcmp(type, "FLAT") && strcmp(type, "SPARSE") &&
strcmp(type, "VMFS") && strcmp(type, "VMFSSPARSE")) ||
(strcmp(access, "RW"))) {
goto next_line;
}
if (!path_is_absolute(fname) && !path_has_protocol(fname) &&
!desc_file_path[0])
{
error_setg(errp, "Cannot use relative extent paths with VMDK "
"descriptor file '%s'", bs->file->bs->filename);
return -EINVAL;
}
extent_path = g_malloc0(PATH_MAX);
path_combine(extent_path, PATH_MAX, desc_file_path, fname);
ret = snprintf(extent_opt_prefix, 32, "extents.%d", s->num_extents);
assert(ret < 32);
extent_file = bdrv_open_child(extent_path, options, extent_opt_prefix,
bs, &child_file, false, &local_err);
g_free(extent_path);
if (local_err) {
error_propagate(errp, local_err);
return -EINVAL;
}
/* save to extents array */
if (!strcmp(type, "FLAT") || !strcmp(type, "VMFS")) {
/* FLAT extent */
ret = vmdk_add_extent(bs, extent_file, true, sectors,
0, 0, 0, 0, 0, &extent, errp);
if (ret < 0) {
bdrv_unref_child(bs, extent_file);
return ret;
}
extent->flat_start_offset = flat_offset << 9;
} else if (!strcmp(type, "SPARSE") || !strcmp(type, "VMFSSPARSE")) {
/* SPARSE extent and VMFSSPARSE extent are both "COWD" sparse file*/
char *buf = vmdk_read_desc(extent_file->bs, 0, errp);
if (!buf) {
ret = -EINVAL;
} else {
ret = vmdk_open_sparse(bs, extent_file, bs->open_flags, buf,
options, errp);
}
g_free(buf);
if (ret) {
bdrv_unref_child(bs, extent_file);
return ret;
}
extent = &s->extents[s->num_extents - 1];
} else {
error_setg(errp, "Unsupported extent type '%s'", type);
bdrv_unref_child(bs, extent_file);
return -ENOTSUP;
}
extent->type = g_strdup(type);
next_line:
/* move to next line */
while (*p) {
if (*p == '\n') {
p++;
break;
}
p++;
}
}
return 0;
}
| false | qemu | e4937694b66d1468aec3cd95e90888f291c3f599 | static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
const char *desc_file_path, QDict *options,
Error **errp)
{
int ret;
int matches;
char access[11];
char type[11];
char fname[512];
const char *p = desc;
int64_t sectors = 0;
int64_t flat_offset;
char *extent_path;
BdrvChild *extent_file;
BDRVVmdkState *s = bs->opaque;
VmdkExtent *extent;
char extent_opt_prefix[32];
Error *local_err = NULL;
while (*p) {
flat_offset = -1;
matches = sscanf(p, "%10s %" SCNd64 " %10s \"%511[^\n\r\"]\" %" SCNd64,
access, §ors, type, fname, &flat_offset);
if (matches < 4 || strcmp(access, "RW")) {
goto next_line;
} else if (!strcmp(type, "FLAT")) {
if (matches != 5 || flat_offset < 0) {
error_setg(errp, "Invalid extent lines: \n%s", p);
return -EINVAL;
}
} else if (!strcmp(type, "VMFS")) {
if (matches == 4) {
flat_offset = 0;
} else {
error_setg(errp, "Invalid extent lines:\n%s", p);
return -EINVAL;
}
} else if (matches != 4) {
error_setg(errp, "Invalid extent lines:\n%s", p);
return -EINVAL;
}
if (sectors <= 0 ||
(strcmp(type, "FLAT") && strcmp(type, "SPARSE") &&
strcmp(type, "VMFS") && strcmp(type, "VMFSSPARSE")) ||
(strcmp(access, "RW"))) {
goto next_line;
}
if (!path_is_absolute(fname) && !path_has_protocol(fname) &&
!desc_file_path[0])
{
error_setg(errp, "Cannot use relative extent paths with VMDK "
"descriptor file '%s'", bs->file->bs->filename);
return -EINVAL;
}
extent_path = g_malloc0(PATH_MAX);
path_combine(extent_path, PATH_MAX, desc_file_path, fname);
ret = snprintf(extent_opt_prefix, 32, "extents.%d", s->num_extents);
assert(ret < 32);
extent_file = bdrv_open_child(extent_path, options, extent_opt_prefix,
bs, &child_file, false, &local_err);
g_free(extent_path);
if (local_err) {
error_propagate(errp, local_err);
return -EINVAL;
}
if (!strcmp(type, "FLAT") || !strcmp(type, "VMFS")) {
ret = vmdk_add_extent(bs, extent_file, true, sectors,
0, 0, 0, 0, 0, &extent, errp);
if (ret < 0) {
bdrv_unref_child(bs, extent_file);
return ret;
}
extent->flat_start_offset = flat_offset << 9;
} else if (!strcmp(type, "SPARSE") || !strcmp(type, "VMFSSPARSE")) {
char *buf = vmdk_read_desc(extent_file->bs, 0, errp);
if (!buf) {
ret = -EINVAL;
} else {
ret = vmdk_open_sparse(bs, extent_file, bs->open_flags, buf,
options, errp);
}
g_free(buf);
if (ret) {
bdrv_unref_child(bs, extent_file);
return ret;
}
extent = &s->extents[s->num_extents - 1];
} else {
error_setg(errp, "Unsupported extent type '%s'", type);
bdrv_unref_child(bs, extent_file);
return -ENOTSUP;
}
extent->type = g_strdup(type);
next_line:
while (*p) {
if (*p == '\n') {
p++;
break;
}
p++;
}
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(const char *VAR_0, BlockDriverState *VAR_1,
const char *VAR_2, QDict *VAR_3,
Error **VAR_4)
{
int VAR_5;
int VAR_6;
char VAR_7[11];
char VAR_8[11];
char VAR_9[512];
const char *VAR_10 = VAR_0;
int64_t sectors = 0;
int64_t flat_offset;
char *VAR_11;
BdrvChild *extent_file;
BDRVVmdkState *s = VAR_1->opaque;
VmdkExtent *extent;
char VAR_12[32];
Error *local_err = NULL;
while (*VAR_10) {
flat_offset = -1;
VAR_6 = sscanf(VAR_10, "%10s %" SCNd64 " %10s \"%511[^\n\r\"]\" %" SCNd64,
VAR_7, §ors, VAR_8, VAR_9, &flat_offset);
if (VAR_6 < 4 || strcmp(VAR_7, "RW")) {
goto next_line;
} else if (!strcmp(VAR_8, "FLAT")) {
if (VAR_6 != 5 || flat_offset < 0) {
error_setg(VAR_4, "Invalid extent lines: \n%s", VAR_10);
return -EINVAL;
}
} else if (!strcmp(VAR_8, "VMFS")) {
if (VAR_6 == 4) {
flat_offset = 0;
} else {
error_setg(VAR_4, "Invalid extent lines:\n%s", VAR_10);
return -EINVAL;
}
} else if (VAR_6 != 4) {
error_setg(VAR_4, "Invalid extent lines:\n%s", VAR_10);
return -EINVAL;
}
if (sectors <= 0 ||
(strcmp(VAR_8, "FLAT") && strcmp(VAR_8, "SPARSE") &&
strcmp(VAR_8, "VMFS") && strcmp(VAR_8, "VMFSSPARSE")) ||
(strcmp(VAR_7, "RW"))) {
goto next_line;
}
if (!path_is_absolute(VAR_9) && !path_has_protocol(VAR_9) &&
!VAR_2[0])
{
error_setg(VAR_4, "Cannot use relative extent paths with VMDK "
"descriptor file '%s'", VAR_1->file->VAR_1->filename);
return -EINVAL;
}
VAR_11 = g_malloc0(PATH_MAX);
path_combine(VAR_11, PATH_MAX, VAR_2, VAR_9);
VAR_5 = snprintf(VAR_12, 32, "extents.%d", s->num_extents);
assert(VAR_5 < 32);
extent_file = bdrv_open_child(VAR_11, VAR_3, VAR_12,
VAR_1, &child_file, false, &local_err);
g_free(VAR_11);
if (local_err) {
error_propagate(VAR_4, local_err);
return -EINVAL;
}
if (!strcmp(VAR_8, "FLAT") || !strcmp(VAR_8, "VMFS")) {
VAR_5 = vmdk_add_extent(VAR_1, extent_file, true, sectors,
0, 0, 0, 0, 0, &extent, VAR_4);
if (VAR_5 < 0) {
bdrv_unref_child(VAR_1, extent_file);
return VAR_5;
}
extent->flat_start_offset = flat_offset << 9;
} else if (!strcmp(VAR_8, "SPARSE") || !strcmp(VAR_8, "VMFSSPARSE")) {
char *VAR_13 = vmdk_read_desc(extent_file->VAR_1, 0, VAR_4);
if (!VAR_13) {
VAR_5 = -EINVAL;
} else {
VAR_5 = vmdk_open_sparse(VAR_1, extent_file, VAR_1->open_flags, VAR_13,
VAR_3, VAR_4);
}
g_free(VAR_13);
if (VAR_5) {
bdrv_unref_child(VAR_1, extent_file);
return VAR_5;
}
extent = &s->extents[s->num_extents - 1];
} else {
error_setg(VAR_4, "Unsupported extent VAR_8 '%s'", VAR_8);
bdrv_unref_child(VAR_1, extent_file);
return -ENOTSUP;
}
extent->VAR_8 = g_strdup(VAR_8);
next_line:
while (*VAR_10) {
if (*VAR_10 == '\n') {
VAR_10++;
break;
}
VAR_10++;
}
}
return 0;
}
| [
"static int FUNC_0(const char *VAR_0, BlockDriverState *VAR_1,\nconst char *VAR_2, QDict *VAR_3,\nError **VAR_4)\n{",
"int VAR_5;",
"int VAR_6;",
"char VAR_7[11];",
"char VAR_8[11];",
"char VAR_9[512];",
"const char *VAR_10 = VAR_0;",
"int64_t sectors = 0;",
"int64_t flat_offset;",
"char *VAR_11;",
"BdrvChild *extent_file;",
"BDRVVmdkState *s = VAR_1->opaque;",
"VmdkExtent *extent;",
"char VAR_12[32];",
"Error *local_err = NULL;",
"while (*VAR_10) {",
"flat_offset = -1;",
"VAR_6 = sscanf(VAR_10, \"%10s %\" SCNd64 \" %10s \\\"%511[^\\n\\r\\\"]\\\" %\" SCNd64,\nVAR_7, §ors, VAR_8, VAR_9, &flat_offset);",
"if (VAR_6 < 4 || strcmp(VAR_7, \"RW\")) {",
"goto next_line;",
"} else if (!strcmp(VAR_8, \"FLAT\")) {",
"if (VAR_6 != 5 || flat_offset < 0) {",
"error_setg(VAR_4, \"Invalid extent lines: \\n%s\", VAR_10);",
"return -EINVAL;",
"}",
"} else if (!strcmp(VAR_8, \"VMFS\")) {",
"if (VAR_6 == 4) {",
"flat_offset = 0;",
"} else {",
"error_setg(VAR_4, \"Invalid extent lines:\\n%s\", VAR_10);",
"return -EINVAL;",
"}",
"} else if (VAR_6 != 4) {",
"error_setg(VAR_4, \"Invalid extent lines:\\n%s\", VAR_10);",
"return -EINVAL;",
"}",
"if (sectors <= 0 ||\n(strcmp(VAR_8, \"FLAT\") && strcmp(VAR_8, \"SPARSE\") &&\nstrcmp(VAR_8, \"VMFS\") && strcmp(VAR_8, \"VMFSSPARSE\")) ||\n(strcmp(VAR_7, \"RW\"))) {",
"goto next_line;",
"}",
"if (!path_is_absolute(VAR_9) && !path_has_protocol(VAR_9) &&\n!VAR_2[0])\n{",
"error_setg(VAR_4, \"Cannot use relative extent paths with VMDK \"\n\"descriptor file '%s'\", VAR_1->file->VAR_1->filename);",
"return -EINVAL;",
"}",
"VAR_11 = g_malloc0(PATH_MAX);",
"path_combine(VAR_11, PATH_MAX, VAR_2, VAR_9);",
"VAR_5 = snprintf(VAR_12, 32, \"extents.%d\", s->num_extents);",
"assert(VAR_5 < 32);",
"extent_file = bdrv_open_child(VAR_11, VAR_3, VAR_12,\nVAR_1, &child_file, false, &local_err);",
"g_free(VAR_11);",
"if (local_err) {",
"error_propagate(VAR_4, local_err);",
"return -EINVAL;",
"}",
"if (!strcmp(VAR_8, \"FLAT\") || !strcmp(VAR_8, \"VMFS\")) {",
"VAR_5 = vmdk_add_extent(VAR_1, extent_file, true, sectors,\n0, 0, 0, 0, 0, &extent, VAR_4);",
"if (VAR_5 < 0) {",
"bdrv_unref_child(VAR_1, extent_file);",
"return VAR_5;",
"}",
"extent->flat_start_offset = flat_offset << 9;",
"} else if (!strcmp(VAR_8, \"SPARSE\") || !strcmp(VAR_8, \"VMFSSPARSE\")) {",
"char *VAR_13 = vmdk_read_desc(extent_file->VAR_1, 0, VAR_4);",
"if (!VAR_13) {",
"VAR_5 = -EINVAL;",
"} else {",
"VAR_5 = vmdk_open_sparse(VAR_1, extent_file, VAR_1->open_flags, VAR_13,\nVAR_3, VAR_4);",
"}",
"g_free(VAR_13);",
"if (VAR_5) {",
"bdrv_unref_child(VAR_1, extent_file);",
"return VAR_5;",
"}",
"extent = &s->extents[s->num_extents - 1];",
"} else {",
"error_setg(VAR_4, \"Unsupported extent VAR_8 '%s'\", VAR_8);",
"bdrv_unref_child(VAR_1, extent_file);",
"return -ENOTSUP;",
"}",
"extent->VAR_8 = g_strdup(VAR_8);",
"next_line:\nwhile (*VAR_10) {",
"if (*VAR_10 == '\\n') {",
"VAR_10++;",
"break;",
"}",
"VAR_10++;",
"}",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
55
],
[
57,
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
99,
101,
103,
105
],
[
107
],
[
109
],
[
113,
115,
117
],
[
119,
121
],
[
123
],
[
125
],
[
129
],
[
131
],
[
135
],
[
137
],
[
141,
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
159
],
[
165,
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191,
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221,
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
]
] |
22,327 | static void external_snapshot_prepare(BlkTransactionState *common,
Error **errp)
{
BlockDriver *drv;
int flags, ret;
QDict *options = NULL;
Error *local_err = NULL;
bool has_device = false;
const char *device;
bool has_node_name = false;
const char *node_name;
bool has_snapshot_node_name = false;
const char *snapshot_node_name;
const char *new_image_file;
const char *format = "qcow2";
enum NewImageMode mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS;
ExternalSnapshotState *state =
DO_UPCAST(ExternalSnapshotState, common, common);
TransactionAction *action = common->action;
/* get parameters */
g_assert(action->kind == TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC);
has_device = action->blockdev_snapshot_sync->has_device;
device = action->blockdev_snapshot_sync->device;
has_node_name = action->blockdev_snapshot_sync->has_node_name;
node_name = action->blockdev_snapshot_sync->node_name;
has_snapshot_node_name =
action->blockdev_snapshot_sync->has_snapshot_node_name;
snapshot_node_name = action->blockdev_snapshot_sync->snapshot_node_name;
new_image_file = action->blockdev_snapshot_sync->snapshot_file;
if (action->blockdev_snapshot_sync->has_format) {
format = action->blockdev_snapshot_sync->format;
}
if (action->blockdev_snapshot_sync->has_mode) {
mode = action->blockdev_snapshot_sync->mode;
}
/* start processing */
drv = bdrv_find_format(format);
if (!drv) {
error_set(errp, QERR_INVALID_BLOCK_FORMAT, format);
return;
}
state->old_bs = bdrv_lookup_bs(has_device ? device : NULL,
has_node_name ? node_name : NULL,
&local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
}
if (has_node_name && !has_snapshot_node_name) {
error_setg(errp, "New snapshot node name missing");
return;
}
if (has_snapshot_node_name && bdrv_find_node(snapshot_node_name)) {
error_setg(errp, "New snapshot node name already existing");
return;
}
if (!bdrv_is_inserted(state->old_bs)) {
error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
return;
}
if (bdrv_in_use(state->old_bs)) {
error_set(errp, QERR_DEVICE_IN_USE, device);
return;
}
if (!bdrv_is_read_only(state->old_bs)) {
if (bdrv_flush(state->old_bs)) {
error_set(errp, QERR_IO_ERROR);
return;
}
}
if (!bdrv_is_first_non_filter(state->old_bs)) {
error_set(errp, QERR_FEATURE_DISABLED, "snapshot");
return;
}
flags = state->old_bs->open_flags;
/* create new image w/backing file */
if (mode != NEW_IMAGE_MODE_EXISTING) {
bdrv_img_create(new_image_file, format,
state->old_bs->filename,
state->old_bs->drv->format_name,
NULL, -1, flags, &local_err, false);
if (local_err) {
error_propagate(errp, local_err);
return;
}
}
if (has_snapshot_node_name) {
options = qdict_new();
qdict_put(options, "node-name",
qstring_from_str(snapshot_node_name));
}
/* TODO Inherit bs->options or only take explicit options with an
* extended QMP command? */
assert(state->new_bs == NULL);
ret = bdrv_open(&state->new_bs, new_image_file, NULL, options,
flags | BDRV_O_NO_BACKING, drv, &local_err);
/* We will manually add the backing_hd field to the bs later */
if (ret != 0) {
error_propagate(errp, local_err);
}
}
| false | qemu | 3718d8ab65f68de2acccbe6a315907805f54e3cc | static void external_snapshot_prepare(BlkTransactionState *common,
Error **errp)
{
BlockDriver *drv;
int flags, ret;
QDict *options = NULL;
Error *local_err = NULL;
bool has_device = false;
const char *device;
bool has_node_name = false;
const char *node_name;
bool has_snapshot_node_name = false;
const char *snapshot_node_name;
const char *new_image_file;
const char *format = "qcow2";
enum NewImageMode mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS;
ExternalSnapshotState *state =
DO_UPCAST(ExternalSnapshotState, common, common);
TransactionAction *action = common->action;
g_assert(action->kind == TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC);
has_device = action->blockdev_snapshot_sync->has_device;
device = action->blockdev_snapshot_sync->device;
has_node_name = action->blockdev_snapshot_sync->has_node_name;
node_name = action->blockdev_snapshot_sync->node_name;
has_snapshot_node_name =
action->blockdev_snapshot_sync->has_snapshot_node_name;
snapshot_node_name = action->blockdev_snapshot_sync->snapshot_node_name;
new_image_file = action->blockdev_snapshot_sync->snapshot_file;
if (action->blockdev_snapshot_sync->has_format) {
format = action->blockdev_snapshot_sync->format;
}
if (action->blockdev_snapshot_sync->has_mode) {
mode = action->blockdev_snapshot_sync->mode;
}
drv = bdrv_find_format(format);
if (!drv) {
error_set(errp, QERR_INVALID_BLOCK_FORMAT, format);
return;
}
state->old_bs = bdrv_lookup_bs(has_device ? device : NULL,
has_node_name ? node_name : NULL,
&local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
}
if (has_node_name && !has_snapshot_node_name) {
error_setg(errp, "New snapshot node name missing");
return;
}
if (has_snapshot_node_name && bdrv_find_node(snapshot_node_name)) {
error_setg(errp, "New snapshot node name already existing");
return;
}
if (!bdrv_is_inserted(state->old_bs)) {
error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
return;
}
if (bdrv_in_use(state->old_bs)) {
error_set(errp, QERR_DEVICE_IN_USE, device);
return;
}
if (!bdrv_is_read_only(state->old_bs)) {
if (bdrv_flush(state->old_bs)) {
error_set(errp, QERR_IO_ERROR);
return;
}
}
if (!bdrv_is_first_non_filter(state->old_bs)) {
error_set(errp, QERR_FEATURE_DISABLED, "snapshot");
return;
}
flags = state->old_bs->open_flags;
if (mode != NEW_IMAGE_MODE_EXISTING) {
bdrv_img_create(new_image_file, format,
state->old_bs->filename,
state->old_bs->drv->format_name,
NULL, -1, flags, &local_err, false);
if (local_err) {
error_propagate(errp, local_err);
return;
}
}
if (has_snapshot_node_name) {
options = qdict_new();
qdict_put(options, "node-name",
qstring_from_str(snapshot_node_name));
}
assert(state->new_bs == NULL);
ret = bdrv_open(&state->new_bs, new_image_file, NULL, options,
flags | BDRV_O_NO_BACKING, drv, &local_err);
if (ret != 0) {
error_propagate(errp, local_err);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(BlkTransactionState *VAR_0,
Error **VAR_1)
{
BlockDriver *drv;
int VAR_2, VAR_3;
QDict *options = NULL;
Error *local_err = NULL;
bool has_device = false;
const char *VAR_4;
bool has_node_name = false;
const char *VAR_5;
bool has_snapshot_node_name = false;
const char *VAR_6;
const char *VAR_7;
const char *VAR_8 = "qcow2";
enum NewImageMode VAR_9 = NEW_IMAGE_MODE_ABSOLUTE_PATHS;
ExternalSnapshotState *state =
DO_UPCAST(ExternalSnapshotState, VAR_0, VAR_0);
TransactionAction *action = VAR_0->action;
g_assert(action->kind == TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC);
has_device = action->blockdev_snapshot_sync->has_device;
VAR_4 = action->blockdev_snapshot_sync->VAR_4;
has_node_name = action->blockdev_snapshot_sync->has_node_name;
VAR_5 = action->blockdev_snapshot_sync->VAR_5;
has_snapshot_node_name =
action->blockdev_snapshot_sync->has_snapshot_node_name;
VAR_6 = action->blockdev_snapshot_sync->VAR_6;
VAR_7 = action->blockdev_snapshot_sync->snapshot_file;
if (action->blockdev_snapshot_sync->has_format) {
VAR_8 = action->blockdev_snapshot_sync->VAR_8;
}
if (action->blockdev_snapshot_sync->has_mode) {
VAR_9 = action->blockdev_snapshot_sync->VAR_9;
}
drv = bdrv_find_format(VAR_8);
if (!drv) {
error_set(VAR_1, QERR_INVALID_BLOCK_FORMAT, VAR_8);
return;
}
state->old_bs = bdrv_lookup_bs(has_device ? VAR_4 : NULL,
has_node_name ? VAR_5 : NULL,
&local_err);
if (local_err) {
error_propagate(VAR_1, local_err);
return;
}
if (has_node_name && !has_snapshot_node_name) {
error_setg(VAR_1, "New snapshot node name missing");
return;
}
if (has_snapshot_node_name && bdrv_find_node(VAR_6)) {
error_setg(VAR_1, "New snapshot node name already existing");
return;
}
if (!bdrv_is_inserted(state->old_bs)) {
error_set(VAR_1, QERR_DEVICE_HAS_NO_MEDIUM, VAR_4);
return;
}
if (bdrv_in_use(state->old_bs)) {
error_set(VAR_1, QERR_DEVICE_IN_USE, VAR_4);
return;
}
if (!bdrv_is_read_only(state->old_bs)) {
if (bdrv_flush(state->old_bs)) {
error_set(VAR_1, QERR_IO_ERROR);
return;
}
}
if (!bdrv_is_first_non_filter(state->old_bs)) {
error_set(VAR_1, QERR_FEATURE_DISABLED, "snapshot");
return;
}
VAR_2 = state->old_bs->open_flags;
if (VAR_9 != NEW_IMAGE_MODE_EXISTING) {
bdrv_img_create(VAR_7, VAR_8,
state->old_bs->filename,
state->old_bs->drv->format_name,
NULL, -1, VAR_2, &local_err, false);
if (local_err) {
error_propagate(VAR_1, local_err);
return;
}
}
if (has_snapshot_node_name) {
options = qdict_new();
qdict_put(options, "node-name",
qstring_from_str(VAR_6));
}
assert(state->new_bs == NULL);
VAR_3 = bdrv_open(&state->new_bs, VAR_7, NULL, options,
VAR_2 | BDRV_O_NO_BACKING, drv, &local_err);
if (VAR_3 != 0) {
error_propagate(VAR_1, local_err);
}
}
| [
"static void FUNC_0(BlkTransactionState *VAR_0,\nError **VAR_1)\n{",
"BlockDriver *drv;",
"int VAR_2, VAR_3;",
"QDict *options = NULL;",
"Error *local_err = NULL;",
"bool has_device = false;",
"const char *VAR_4;",
"bool has_node_name = false;",
"const char *VAR_5;",
"bool has_snapshot_node_name = false;",
"const char *VAR_6;",
"const char *VAR_7;",
"const char *VAR_8 = \"qcow2\";",
"enum NewImageMode VAR_9 = NEW_IMAGE_MODE_ABSOLUTE_PATHS;",
"ExternalSnapshotState *state =\nDO_UPCAST(ExternalSnapshotState, VAR_0, VAR_0);",
"TransactionAction *action = VAR_0->action;",
"g_assert(action->kind == TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC);",
"has_device = action->blockdev_snapshot_sync->has_device;",
"VAR_4 = action->blockdev_snapshot_sync->VAR_4;",
"has_node_name = action->blockdev_snapshot_sync->has_node_name;",
"VAR_5 = action->blockdev_snapshot_sync->VAR_5;",
"has_snapshot_node_name =\naction->blockdev_snapshot_sync->has_snapshot_node_name;",
"VAR_6 = action->blockdev_snapshot_sync->VAR_6;",
"VAR_7 = action->blockdev_snapshot_sync->snapshot_file;",
"if (action->blockdev_snapshot_sync->has_format) {",
"VAR_8 = action->blockdev_snapshot_sync->VAR_8;",
"}",
"if (action->blockdev_snapshot_sync->has_mode) {",
"VAR_9 = action->blockdev_snapshot_sync->VAR_9;",
"}",
"drv = bdrv_find_format(VAR_8);",
"if (!drv) {",
"error_set(VAR_1, QERR_INVALID_BLOCK_FORMAT, VAR_8);",
"return;",
"}",
"state->old_bs = bdrv_lookup_bs(has_device ? VAR_4 : NULL,\nhas_node_name ? VAR_5 : NULL,\n&local_err);",
"if (local_err) {",
"error_propagate(VAR_1, local_err);",
"return;",
"}",
"if (has_node_name && !has_snapshot_node_name) {",
"error_setg(VAR_1, \"New snapshot node name missing\");",
"return;",
"}",
"if (has_snapshot_node_name && bdrv_find_node(VAR_6)) {",
"error_setg(VAR_1, \"New snapshot node name already existing\");",
"return;",
"}",
"if (!bdrv_is_inserted(state->old_bs)) {",
"error_set(VAR_1, QERR_DEVICE_HAS_NO_MEDIUM, VAR_4);",
"return;",
"}",
"if (bdrv_in_use(state->old_bs)) {",
"error_set(VAR_1, QERR_DEVICE_IN_USE, VAR_4);",
"return;",
"}",
"if (!bdrv_is_read_only(state->old_bs)) {",
"if (bdrv_flush(state->old_bs)) {",
"error_set(VAR_1, QERR_IO_ERROR);",
"return;",
"}",
"}",
"if (!bdrv_is_first_non_filter(state->old_bs)) {",
"error_set(VAR_1, QERR_FEATURE_DISABLED, \"snapshot\");",
"return;",
"}",
"VAR_2 = state->old_bs->open_flags;",
"if (VAR_9 != NEW_IMAGE_MODE_EXISTING) {",
"bdrv_img_create(VAR_7, VAR_8,\nstate->old_bs->filename,\nstate->old_bs->drv->format_name,\nNULL, -1, VAR_2, &local_err, false);",
"if (local_err) {",
"error_propagate(VAR_1, local_err);",
"return;",
"}",
"}",
"if (has_snapshot_node_name) {",
"options = qdict_new();",
"qdict_put(options, \"node-name\",\nqstring_from_str(VAR_6));",
"}",
"assert(state->new_bs == NULL);",
"VAR_3 = bdrv_open(&state->new_bs, VAR_7, NULL, options,\nVAR_2 | BDRV_O_NO_BACKING, drv, &local_err);",
"if (VAR_3 != 0) {",
"error_propagate(VAR_1, local_err);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33,
35
],
[
37
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55,
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93,
95,
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
109
],
[
111
],
[
113
],
[
115
],
[
119
],
[
121
],
[
123
],
[
125
],
[
129
],
[
131
],
[
133
],
[
135
],
[
139
],
[
141
],
[
143
],
[
145
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
163
],
[
165
],
[
167
],
[
169
],
[
173
],
[
179
],
[
181,
183,
185,
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
201
],
[
203
],
[
205,
207
],
[
209
],
[
217
],
[
219,
221
],
[
225
],
[
227
],
[
229
],
[
231
]
] |
22,328 | static void t_gen_lsl(TCGv d, TCGv a, TCGv b)
{
TCGv t0, t_31;
t0 = tcg_temp_new(TCG_TYPE_TL);
t_31 = tcg_const_tl(31);
tcg_gen_shl_tl(d, a, b);
tcg_gen_sub_tl(t0, t_31, b);
tcg_gen_sar_tl(t0, t0, t_31);
tcg_gen_and_tl(t0, t0, d);
tcg_gen_xor_tl(d, d, t0);
tcg_temp_free(t0);
tcg_temp_free(t_31);
}
| false | qemu | a7812ae412311d7d47f8aa85656faadac9d64b56 | static void t_gen_lsl(TCGv d, TCGv a, TCGv b)
{
TCGv t0, t_31;
t0 = tcg_temp_new(TCG_TYPE_TL);
t_31 = tcg_const_tl(31);
tcg_gen_shl_tl(d, a, b);
tcg_gen_sub_tl(t0, t_31, b);
tcg_gen_sar_tl(t0, t0, t_31);
tcg_gen_and_tl(t0, t0, d);
tcg_gen_xor_tl(d, d, t0);
tcg_temp_free(t0);
tcg_temp_free(t_31);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(TCGv VAR_0, TCGv VAR_1, TCGv VAR_2)
{
TCGv t0, t_31;
t0 = tcg_temp_new(TCG_TYPE_TL);
t_31 = tcg_const_tl(31);
tcg_gen_shl_tl(VAR_0, VAR_1, VAR_2);
tcg_gen_sub_tl(t0, t_31, VAR_2);
tcg_gen_sar_tl(t0, t0, t_31);
tcg_gen_and_tl(t0, t0, VAR_0);
tcg_gen_xor_tl(VAR_0, VAR_0, t0);
tcg_temp_free(t0);
tcg_temp_free(t_31);
}
| [
"static void FUNC_0(TCGv VAR_0, TCGv VAR_1, TCGv VAR_2)\n{",
"TCGv t0, t_31;",
"t0 = tcg_temp_new(TCG_TYPE_TL);",
"t_31 = tcg_const_tl(31);",
"tcg_gen_shl_tl(VAR_0, VAR_1, VAR_2);",
"tcg_gen_sub_tl(t0, t_31, VAR_2);",
"tcg_gen_sar_tl(t0, t0, t_31);",
"tcg_gen_and_tl(t0, t0, VAR_0);",
"tcg_gen_xor_tl(VAR_0, VAR_0, t0);",
"tcg_temp_free(t0);",
"tcg_temp_free(t_31);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
]
] |
22,329 | int unix_listen_opts(QemuOpts *opts, Error **errp)
{
struct sockaddr_un un;
const char *path = qemu_opt_get(opts, "path");
int sock, fd;
sock = qemu_socket(PF_UNIX, SOCK_STREAM, 0);
if (sock < 0) {
error_setg_errno(errp, errno, "Failed to create socket");
return -1;
}
memset(&un, 0, sizeof(un));
un.sun_family = AF_UNIX;
if (path && strlen(path)) {
snprintf(un.sun_path, sizeof(un.sun_path), "%s", path);
} else {
char *tmpdir = getenv("TMPDIR");
snprintf(un.sun_path, sizeof(un.sun_path), "%s/qemu-socket-XXXXXX",
tmpdir ? tmpdir : "/tmp");
/*
* This dummy fd usage silences the mktemp() unsecure warning.
* Using mkstemp() doesn't make things more secure here
* though. bind() complains about existing files, so we have
* to unlink first and thus re-open the race window. The
* worst case possible is bind() failing, i.e. a DoS attack.
*/
fd = mkstemp(un.sun_path); close(fd);
qemu_opt_set(opts, "path", un.sun_path);
}
unlink(un.sun_path);
if (bind(sock, (struct sockaddr*) &un, sizeof(un)) < 0) {
error_setg_errno(errp, errno, "Failed to bind socket");
goto err;
}
if (listen(sock, 1) < 0) {
error_setg_errno(errp, errno, "Failed to listen on socket");
goto err;
}
return sock;
err:
closesocket(sock);
return -1;
}
| false | qemu | b658c53d2b87c1e9e0ade887a70ecb0de1474a7b | int unix_listen_opts(QemuOpts *opts, Error **errp)
{
struct sockaddr_un un;
const char *path = qemu_opt_get(opts, "path");
int sock, fd;
sock = qemu_socket(PF_UNIX, SOCK_STREAM, 0);
if (sock < 0) {
error_setg_errno(errp, errno, "Failed to create socket");
return -1;
}
memset(&un, 0, sizeof(un));
un.sun_family = AF_UNIX;
if (path && strlen(path)) {
snprintf(un.sun_path, sizeof(un.sun_path), "%s", path);
} else {
char *tmpdir = getenv("TMPDIR");
snprintf(un.sun_path, sizeof(un.sun_path), "%s/qemu-socket-XXXXXX",
tmpdir ? tmpdir : "/tmp");
fd = mkstemp(un.sun_path); close(fd);
qemu_opt_set(opts, "path", un.sun_path);
}
unlink(un.sun_path);
if (bind(sock, (struct sockaddr*) &un, sizeof(un)) < 0) {
error_setg_errno(errp, errno, "Failed to bind socket");
goto err;
}
if (listen(sock, 1) < 0) {
error_setg_errno(errp, errno, "Failed to listen on socket");
goto err;
}
return sock;
err:
closesocket(sock);
return -1;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(QemuOpts *VAR_0, Error **VAR_1)
{
struct sockaddr_un VAR_2;
const char *VAR_3 = qemu_opt_get(VAR_0, "VAR_3");
int VAR_4, VAR_5;
VAR_4 = qemu_socket(PF_UNIX, SOCK_STREAM, 0);
if (VAR_4 < 0) {
error_setg_errno(VAR_1, errno, "Failed to create socket");
return -1;
}
memset(&VAR_2, 0, sizeof(VAR_2));
VAR_2.sun_family = AF_UNIX;
if (VAR_3 && strlen(VAR_3)) {
snprintf(VAR_2.sun_path, sizeof(VAR_2.sun_path), "%s", VAR_3);
} else {
char *VAR_6 = getenv("TMPDIR");
snprintf(VAR_2.sun_path, sizeof(VAR_2.sun_path), "%s/qemu-socket-XXXXXX",
VAR_6 ? VAR_6 : "/tmp");
VAR_5 = mkstemp(VAR_2.sun_path); close(VAR_5);
qemu_opt_set(VAR_0, "VAR_3", VAR_2.sun_path);
}
unlink(VAR_2.sun_path);
if (bind(VAR_4, (struct sockaddr*) &VAR_2, sizeof(VAR_2)) < 0) {
error_setg_errno(VAR_1, errno, "Failed to bind socket");
goto err;
}
if (listen(VAR_4, 1) < 0) {
error_setg_errno(VAR_1, errno, "Failed to listen on socket");
goto err;
}
return VAR_4;
err:
closesocket(VAR_4);
return -1;
}
| [
"int FUNC_0(QemuOpts *VAR_0, Error **VAR_1)\n{",
"struct sockaddr_un VAR_2;",
"const char *VAR_3 = qemu_opt_get(VAR_0, \"VAR_3\");",
"int VAR_4, VAR_5;",
"VAR_4 = qemu_socket(PF_UNIX, SOCK_STREAM, 0);",
"if (VAR_4 < 0) {",
"error_setg_errno(VAR_1, errno, \"Failed to create socket\");",
"return -1;",
"}",
"memset(&VAR_2, 0, sizeof(VAR_2));",
"VAR_2.sun_family = AF_UNIX;",
"if (VAR_3 && strlen(VAR_3)) {",
"snprintf(VAR_2.sun_path, sizeof(VAR_2.sun_path), \"%s\", VAR_3);",
"} else {",
"char *VAR_6 = getenv(\"TMPDIR\");",
"snprintf(VAR_2.sun_path, sizeof(VAR_2.sun_path), \"%s/qemu-socket-XXXXXX\",\nVAR_6 ? VAR_6 : \"/tmp\");",
"VAR_5 = mkstemp(VAR_2.sun_path); close(VAR_5);",
"qemu_opt_set(VAR_0, \"VAR_3\", VAR_2.sun_path);",
"}",
"unlink(VAR_2.sun_path);",
"if (bind(VAR_4, (struct sockaddr*) &VAR_2, sizeof(VAR_2)) < 0) {",
"error_setg_errno(VAR_1, errno, \"Failed to bind socket\");",
"goto err;",
"}",
"if (listen(VAR_4, 1) < 0) {",
"error_setg_errno(VAR_1, errno, \"Failed to listen on socket\");",
"goto err;",
"}",
"return VAR_4;",
"err:\nclosesocket(VAR_4);",
"return -1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37,
39
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
87,
89
],
[
91
],
[
93
]
] |
22,332 | int check_codec_match(AVCodecContext *ccf, AVCodecContext *ccs, int stream)
{
int matches = 1;
#define CHECK_CODEC(x) (ccf->x != ccs->x)
if (CHECK_CODEC(codec_id) || CHECK_CODEC(codec_type)) {
http_log("Codecs do not match for stream %d\n", stream);
matches = 0;
} else if (CHECK_CODEC(bit_rate) || CHECK_CODEC(flags)) {
http_log("Codec bitrates do not match for stream %d\n", stream);
matches = 0;
} else if (ccf->codec_type == AVMEDIA_TYPE_VIDEO) {
if (CHECK_CODEC(time_base.den) ||
CHECK_CODEC(time_base.num) ||
CHECK_CODEC(width) ||
CHECK_CODEC(height)) {
http_log("Codec width, height or framerate do not match for stream %d\n", stream);
matches = 0;
}
} else if (ccf->codec_type == AVMEDIA_TYPE_AUDIO) {
if (CHECK_CODEC(sample_rate) ||
CHECK_CODEC(channels) ||
CHECK_CODEC(frame_size)) {
http_log("Codec sample_rate, channels, frame_size do not match for stream %d\n", stream);
matches = 0;
}
} else {
http_log("Unknown codec type for stream %d\n", stream);
matches = 0;
}
return matches;
}
| false | FFmpeg | 311107a65d0105044d1691b5e85d6f30879b0eb4 | int check_codec_match(AVCodecContext *ccf, AVCodecContext *ccs, int stream)
{
int matches = 1;
#define CHECK_CODEC(x) (ccf->x != ccs->x)
if (CHECK_CODEC(codec_id) || CHECK_CODEC(codec_type)) {
http_log("Codecs do not match for stream %d\n", stream);
matches = 0;
} else if (CHECK_CODEC(bit_rate) || CHECK_CODEC(flags)) {
http_log("Codec bitrates do not match for stream %d\n", stream);
matches = 0;
} else if (ccf->codec_type == AVMEDIA_TYPE_VIDEO) {
if (CHECK_CODEC(time_base.den) ||
CHECK_CODEC(time_base.num) ||
CHECK_CODEC(width) ||
CHECK_CODEC(height)) {
http_log("Codec width, height or framerate do not match for stream %d\n", stream);
matches = 0;
}
} else if (ccf->codec_type == AVMEDIA_TYPE_AUDIO) {
if (CHECK_CODEC(sample_rate) ||
CHECK_CODEC(channels) ||
CHECK_CODEC(frame_size)) {
http_log("Codec sample_rate, channels, frame_size do not match for stream %d\n", stream);
matches = 0;
}
} else {
http_log("Unknown codec type for stream %d\n", stream);
matches = 0;
}
return matches;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(AVCodecContext *VAR_0, AVCodecContext *VAR_1, int VAR_2)
{
int VAR_3 = 1;
#define CHECK_CODEC(x) (VAR_0->x != VAR_1->x)
if (CHECK_CODEC(codec_id) || CHECK_CODEC(codec_type)) {
http_log("Codecs do not match for VAR_2 %d\n", VAR_2);
VAR_3 = 0;
} else if (CHECK_CODEC(bit_rate) || CHECK_CODEC(flags)) {
http_log("Codec bitrates do not match for VAR_2 %d\n", VAR_2);
VAR_3 = 0;
} else if (VAR_0->codec_type == AVMEDIA_TYPE_VIDEO) {
if (CHECK_CODEC(time_base.den) ||
CHECK_CODEC(time_base.num) ||
CHECK_CODEC(width) ||
CHECK_CODEC(height)) {
http_log("Codec width, height or framerate do not match for VAR_2 %d\n", VAR_2);
VAR_3 = 0;
}
} else if (VAR_0->codec_type == AVMEDIA_TYPE_AUDIO) {
if (CHECK_CODEC(sample_rate) ||
CHECK_CODEC(channels) ||
CHECK_CODEC(frame_size)) {
http_log("Codec sample_rate, channels, frame_size do not match for VAR_2 %d\n", VAR_2);
VAR_3 = 0;
}
} else {
http_log("Unknown codec type for VAR_2 %d\n", VAR_2);
VAR_3 = 0;
}
return VAR_3;
}
| [
"int FUNC_0(AVCodecContext *VAR_0, AVCodecContext *VAR_1, int VAR_2)\n{",
"int VAR_3 = 1;",
"#define CHECK_CODEC(x) (VAR_0->x != VAR_1->x)\nif (CHECK_CODEC(codec_id) || CHECK_CODEC(codec_type)) {",
"http_log(\"Codecs do not match for VAR_2 %d\\n\", VAR_2);",
"VAR_3 = 0;",
"} else if (CHECK_CODEC(bit_rate) || CHECK_CODEC(flags)) {",
"http_log(\"Codec bitrates do not match for VAR_2 %d\\n\", VAR_2);",
"VAR_3 = 0;",
"} else if (VAR_0->codec_type == AVMEDIA_TYPE_VIDEO) {",
"if (CHECK_CODEC(time_base.den) ||\nCHECK_CODEC(time_base.num) ||\nCHECK_CODEC(width) ||\nCHECK_CODEC(height)) {",
"http_log(\"Codec width, height or framerate do not match for VAR_2 %d\\n\", VAR_2);",
"VAR_3 = 0;",
"}",
"} else if (VAR_0->codec_type == AVMEDIA_TYPE_AUDIO) {",
"if (CHECK_CODEC(sample_rate) ||\nCHECK_CODEC(channels) ||\nCHECK_CODEC(frame_size)) {",
"http_log(\"Codec sample_rate, channels, frame_size do not match for VAR_2 %d\\n\", VAR_2);",
"VAR_3 = 0;",
"}",
"} else {",
"http_log(\"Unknown codec type for VAR_2 %d\\n\", VAR_2);",
"VAR_3 = 0;",
"}",
"return VAR_3;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9,
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25,
27,
29,
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41,
43,
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
]
] |
22,335 | void memory_region_add_subregion(MemoryRegion *mr,
hwaddr offset,
MemoryRegion *subregion)
{
subregion->may_overlap = false;
subregion->priority = 0;
memory_region_add_subregion_common(mr, offset, subregion);
}
| false | qemu | b61359781958759317ee6fd1a45b59be0b7dbbe1 | void memory_region_add_subregion(MemoryRegion *mr,
hwaddr offset,
MemoryRegion *subregion)
{
subregion->may_overlap = false;
subregion->priority = 0;
memory_region_add_subregion_common(mr, offset, subregion);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(MemoryRegion *VAR_0,
hwaddr VAR_1,
MemoryRegion *VAR_2)
{
VAR_2->may_overlap = false;
VAR_2->priority = 0;
memory_region_add_subregion_common(VAR_0, VAR_1, VAR_2);
}
| [
"void FUNC_0(MemoryRegion *VAR_0,\nhwaddr VAR_1,\nMemoryRegion *VAR_2)\n{",
"VAR_2->may_overlap = false;",
"VAR_2->priority = 0;",
"memory_region_add_subregion_common(VAR_0, VAR_1, VAR_2);",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
]
] |
22,336 | static void xen_be_evtchn_event(void *opaque)
{
struct XenDevice *xendev = opaque;
evtchn_port_t port;
port = xc_evtchn_pending(xendev->evtchndev);
if (port != xendev->local_port) {
xen_be_printf(xendev, 0, "xc_evtchn_pending returned %d (expected %d)\n",
port, xendev->local_port);
return;
}
xc_evtchn_unmask(xendev->evtchndev, port);
if (xendev->ops->event) {
xendev->ops->event(xendev);
}
}
| false | qemu | a2db2a1edd06a50b8a862c654cf993368cf9f1d9 | static void xen_be_evtchn_event(void *opaque)
{
struct XenDevice *xendev = opaque;
evtchn_port_t port;
port = xc_evtchn_pending(xendev->evtchndev);
if (port != xendev->local_port) {
xen_be_printf(xendev, 0, "xc_evtchn_pending returned %d (expected %d)\n",
port, xendev->local_port);
return;
}
xc_evtchn_unmask(xendev->evtchndev, port);
if (xendev->ops->event) {
xendev->ops->event(xendev);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0)
{
struct XenDevice *VAR_1 = VAR_0;
evtchn_port_t port;
port = xc_evtchn_pending(VAR_1->evtchndev);
if (port != VAR_1->local_port) {
xen_be_printf(VAR_1, 0, "xc_evtchn_pending returned %d (expected %d)\n",
port, VAR_1->local_port);
return;
}
xc_evtchn_unmask(VAR_1->evtchndev, port);
if (VAR_1->ops->event) {
VAR_1->ops->event(VAR_1);
}
}
| [
"static void FUNC_0(void *VAR_0)\n{",
"struct XenDevice *VAR_1 = VAR_0;",
"evtchn_port_t port;",
"port = xc_evtchn_pending(VAR_1->evtchndev);",
"if (port != VAR_1->local_port) {",
"xen_be_printf(VAR_1, 0, \"xc_evtchn_pending returned %d (expected %d)\\n\",\nport, VAR_1->local_port);",
"return;",
"}",
"xc_evtchn_unmask(VAR_1->evtchndev, port);",
"if (VAR_1->ops->event) {",
"VAR_1->ops->event(VAR_1);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15,
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
]
] |
22,337 | static void qpi_mem_writel(void *opaque, target_phys_addr_t addr, uint32_t val)
{
CPUState *env;
env = cpu_single_env;
if (!env)
return;
env->eflags = (env->eflags & ~(IF_MASK | IOPL_MASK)) |
(val & (IF_MASK | IOPL_MASK));
}
| false | qemu | 4a1418e07bdcfaa3177739e04707ecaec75d89e1 | static void qpi_mem_writel(void *opaque, target_phys_addr_t addr, uint32_t val)
{
CPUState *env;
env = cpu_single_env;
if (!env)
return;
env->eflags = (env->eflags & ~(IF_MASK | IOPL_MASK)) |
(val & (IF_MASK | IOPL_MASK));
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1, uint32_t VAR_2)
{
CPUState *env;
env = cpu_single_env;
if (!env)
return;
env->eflags = (env->eflags & ~(IF_MASK | IOPL_MASK)) |
(VAR_2 & (IF_MASK | IOPL_MASK));
}
| [
"static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1, uint32_t VAR_2)\n{",
"CPUState *env;",
"env = cpu_single_env;",
"if (!env)\nreturn;",
"env->eflags = (env->eflags & ~(IF_MASK | IOPL_MASK)) |\n(VAR_2 & (IF_MASK | IOPL_MASK));",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11,
13
],
[
15,
17
],
[
19
]
] |
22,338 | static int pci_apb_map_irq(PCIDevice *pci_dev, int irq_num)
{
return ((pci_dev->devfn & 0x18) >> 1) + irq_num;
}
| false | qemu | 6864fa38972081833f79b39df74b9c08cc94f6cc | static int pci_apb_map_irq(PCIDevice *pci_dev, int irq_num)
{
return ((pci_dev->devfn & 0x18) >> 1) + irq_num;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(PCIDevice *VAR_0, int VAR_1)
{
return ((VAR_0->devfn & 0x18) >> 1) + VAR_1;
}
| [
"static int FUNC_0(PCIDevice *VAR_0, int VAR_1)\n{",
"return ((VAR_0->devfn & 0x18) >> 1) + VAR_1;",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
22,339 | static void mirror_read_complete(void *opaque, int ret)
{
MirrorOp *op = opaque;
MirrorBlockJob *s = op->s;
aio_context_acquire(blk_get_aio_context(s->common.blk));
if (ret < 0) {
BlockErrorAction action;
bdrv_set_dirty_bitmap(s->dirty_bitmap, op->sector_num, op->nb_sectors);
action = mirror_error_action(s, true, -ret);
if (action == BLOCK_ERROR_ACTION_REPORT && s->ret >= 0) {
s->ret = ret;
}
mirror_iteration_done(op, ret);
} else {
blk_aio_pwritev(s->target, op->sector_num * BDRV_SECTOR_SIZE, &op->qiov,
0, mirror_write_complete, op);
}
aio_context_release(blk_get_aio_context(s->common.blk));
}
| false | qemu | b436982f04fb33bb29fcdea190bd1fdc97dc65ef | static void mirror_read_complete(void *opaque, int ret)
{
MirrorOp *op = opaque;
MirrorBlockJob *s = op->s;
aio_context_acquire(blk_get_aio_context(s->common.blk));
if (ret < 0) {
BlockErrorAction action;
bdrv_set_dirty_bitmap(s->dirty_bitmap, op->sector_num, op->nb_sectors);
action = mirror_error_action(s, true, -ret);
if (action == BLOCK_ERROR_ACTION_REPORT && s->ret >= 0) {
s->ret = ret;
}
mirror_iteration_done(op, ret);
} else {
blk_aio_pwritev(s->target, op->sector_num * BDRV_SECTOR_SIZE, &op->qiov,
0, mirror_write_complete, op);
}
aio_context_release(blk_get_aio_context(s->common.blk));
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, int VAR_1)
{
MirrorOp *op = VAR_0;
MirrorBlockJob *s = op->s;
aio_context_acquire(blk_get_aio_context(s->common.blk));
if (VAR_1 < 0) {
BlockErrorAction action;
bdrv_set_dirty_bitmap(s->dirty_bitmap, op->sector_num, op->nb_sectors);
action = mirror_error_action(s, true, -VAR_1);
if (action == BLOCK_ERROR_ACTION_REPORT && s->VAR_1 >= 0) {
s->VAR_1 = VAR_1;
}
mirror_iteration_done(op, VAR_1);
} else {
blk_aio_pwritev(s->target, op->sector_num * BDRV_SECTOR_SIZE, &op->qiov,
0, mirror_write_complete, op);
}
aio_context_release(blk_get_aio_context(s->common.blk));
}
| [
"static void FUNC_0(void *VAR_0, int VAR_1)\n{",
"MirrorOp *op = VAR_0;",
"MirrorBlockJob *s = op->s;",
"aio_context_acquire(blk_get_aio_context(s->common.blk));",
"if (VAR_1 < 0) {",
"BlockErrorAction action;",
"bdrv_set_dirty_bitmap(s->dirty_bitmap, op->sector_num, op->nb_sectors);",
"action = mirror_error_action(s, true, -VAR_1);",
"if (action == BLOCK_ERROR_ACTION_REPORT && s->VAR_1 >= 0) {",
"s->VAR_1 = VAR_1;",
"}",
"mirror_iteration_done(op, VAR_1);",
"} else {",
"blk_aio_pwritev(s->target, op->sector_num * BDRV_SECTOR_SIZE, &op->qiov,\n0, mirror_write_complete, op);",
"}",
"aio_context_release(blk_get_aio_context(s->common.blk));",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35,
37
],
[
39
],
[
41
],
[
43
]
] |
22,340 | static struct omap_mpu_timer_s *omap_mpu_timer_init(MemoryRegion *system_memory,
target_phys_addr_t base,
qemu_irq irq, omap_clk clk)
{
struct omap_mpu_timer_s *s = (struct omap_mpu_timer_s *)
g_malloc0(sizeof(struct omap_mpu_timer_s));
s->irq = irq;
s->clk = clk;
s->timer = qemu_new_timer_ns(vm_clock, omap_timer_tick, s);
s->tick = qemu_bh_new(omap_timer_fire, s);
omap_mpu_timer_reset(s);
omap_timer_clk_setup(s);
memory_region_init_io(&s->iomem, &omap_mpu_timer_ops, s,
"omap-mpu-timer", 0x100);
memory_region_add_subregion(system_memory, base, &s->iomem);
return s;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static struct omap_mpu_timer_s *omap_mpu_timer_init(MemoryRegion *system_memory,
target_phys_addr_t base,
qemu_irq irq, omap_clk clk)
{
struct omap_mpu_timer_s *s = (struct omap_mpu_timer_s *)
g_malloc0(sizeof(struct omap_mpu_timer_s));
s->irq = irq;
s->clk = clk;
s->timer = qemu_new_timer_ns(vm_clock, omap_timer_tick, s);
s->tick = qemu_bh_new(omap_timer_fire, s);
omap_mpu_timer_reset(s);
omap_timer_clk_setup(s);
memory_region_init_io(&s->iomem, &omap_mpu_timer_ops, s,
"omap-mpu-timer", 0x100);
memory_region_add_subregion(system_memory, base, &s->iomem);
return s;
}
| {
"code": [],
"line_no": []
} | static struct omap_mpu_timer_s *FUNC_0(MemoryRegion *VAR_0,
target_phys_addr_t VAR_1,
qemu_irq VAR_2, omap_clk VAR_3)
{
struct omap_mpu_timer_s *VAR_4 = (struct omap_mpu_timer_s *)
g_malloc0(sizeof(struct omap_mpu_timer_s));
VAR_4->VAR_2 = VAR_2;
VAR_4->VAR_3 = VAR_3;
VAR_4->timer = qemu_new_timer_ns(vm_clock, omap_timer_tick, VAR_4);
VAR_4->tick = qemu_bh_new(omap_timer_fire, VAR_4);
omap_mpu_timer_reset(VAR_4);
omap_timer_clk_setup(VAR_4);
memory_region_init_io(&VAR_4->iomem, &omap_mpu_timer_ops, VAR_4,
"omap-mpu-timer", 0x100);
memory_region_add_subregion(VAR_0, VAR_1, &VAR_4->iomem);
return VAR_4;
}
| [
"static struct omap_mpu_timer_s *FUNC_0(MemoryRegion *VAR_0,\ntarget_phys_addr_t VAR_1,\nqemu_irq VAR_2, omap_clk VAR_3)\n{",
"struct omap_mpu_timer_s *VAR_4 = (struct omap_mpu_timer_s *)\ng_malloc0(sizeof(struct omap_mpu_timer_s));",
"VAR_4->VAR_2 = VAR_2;",
"VAR_4->VAR_3 = VAR_3;",
"VAR_4->timer = qemu_new_timer_ns(vm_clock, omap_timer_tick, VAR_4);",
"VAR_4->tick = qemu_bh_new(omap_timer_fire, VAR_4);",
"omap_mpu_timer_reset(VAR_4);",
"omap_timer_clk_setup(VAR_4);",
"memory_region_init_io(&VAR_4->iomem, &omap_mpu_timer_ops, VAR_4,\n\"omap-mpu-timer\", 0x100);",
"memory_region_add_subregion(VAR_0, VAR_1, &VAR_4->iomem);",
"return VAR_4;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9,
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29,
31
],
[
35
],
[
39
],
[
41
]
] |
22,341 | static void arm_cpu_reset(CPUState *s)
{
ARMCPU *cpu = ARM_CPU(s);
ARMCPUClass *acc = ARM_CPU_GET_CLASS(cpu);
CPUARMState *env = &cpu->env;
acc->parent_reset(s);
memset(env, 0, offsetof(CPUARMState, end_reset_fields));
g_hash_table_foreach(cpu->cp_regs, cp_reg_reset, cpu);
g_hash_table_foreach(cpu->cp_regs, cp_reg_check_reset, cpu);
env->vfp.xregs[ARM_VFP_FPSID] = cpu->reset_fpsid;
env->vfp.xregs[ARM_VFP_MVFR0] = cpu->mvfr0;
env->vfp.xregs[ARM_VFP_MVFR1] = cpu->mvfr1;
env->vfp.xregs[ARM_VFP_MVFR2] = cpu->mvfr2;
cpu->power_state = cpu->start_powered_off ? PSCI_OFF : PSCI_ON;
s->halted = cpu->start_powered_off;
if (arm_feature(env, ARM_FEATURE_IWMMXT)) {
env->iwmmxt.cregs[ARM_IWMMXT_wCID] = 0x69051000 | 'Q';
}
if (arm_feature(env, ARM_FEATURE_AARCH64)) {
/* 64 bit CPUs always start in 64 bit mode */
env->aarch64 = 1;
#if defined(CONFIG_USER_ONLY)
env->pstate = PSTATE_MODE_EL0t;
/* Userspace expects access to DC ZVA, CTL_EL0 and the cache ops */
env->cp15.sctlr_el[1] |= SCTLR_UCT | SCTLR_UCI | SCTLR_DZE;
/* and to the FP/Neon instructions */
env->cp15.cpacr_el1 = deposit64(env->cp15.cpacr_el1, 20, 2, 3);
#else
/* Reset into the highest available EL */
if (arm_feature(env, ARM_FEATURE_EL3)) {
env->pstate = PSTATE_MODE_EL3h;
} else if (arm_feature(env, ARM_FEATURE_EL2)) {
env->pstate = PSTATE_MODE_EL2h;
} else {
env->pstate = PSTATE_MODE_EL1h;
}
env->pc = cpu->rvbar;
#endif
} else {
#if defined(CONFIG_USER_ONLY)
/* Userspace expects access to cp10 and cp11 for FP/Neon */
env->cp15.cpacr_el1 = deposit64(env->cp15.cpacr_el1, 20, 4, 0xf);
#endif
}
#if defined(CONFIG_USER_ONLY)
env->uncached_cpsr = ARM_CPU_MODE_USR;
/* For user mode we must enable access to coprocessors */
env->vfp.xregs[ARM_VFP_FPEXC] = 1 << 30;
if (arm_feature(env, ARM_FEATURE_IWMMXT)) {
env->cp15.c15_cpar = 3;
} else if (arm_feature(env, ARM_FEATURE_XSCALE)) {
env->cp15.c15_cpar = 1;
}
#else
/* SVC mode with interrupts disabled. */
env->uncached_cpsr = ARM_CPU_MODE_SVC;
env->daif = PSTATE_D | PSTATE_A | PSTATE_I | PSTATE_F;
if (arm_feature(env, ARM_FEATURE_M)) {
uint32_t initial_msp; /* Loaded from 0x0 */
uint32_t initial_pc; /* Loaded from 0x4 */
uint8_t *rom;
if (arm_feature(env, ARM_FEATURE_M_SECURITY)) {
env->v7m.secure = true;
}
/* The reset value of this bit is IMPDEF, but ARM recommends
* that it resets to 1, so QEMU always does that rather than making
* it dependent on CPU model.
*/
env->v7m.ccr = R_V7M_CCR_STKALIGN_MASK;
/* Unlike A/R profile, M profile defines the reset LR value */
env->regs[14] = 0xffffffff;
/* Load the initial SP and PC from the vector table at address 0 */
rom = rom_ptr(0);
if (rom) {
/* Address zero is covered by ROM which hasn't yet been
* copied into physical memory.
*/
initial_msp = ldl_p(rom);
initial_pc = ldl_p(rom + 4);
} else {
/* Address zero not covered by a ROM blob, or the ROM blob
* is in non-modifiable memory and this is a second reset after
* it got copied into memory. In the latter case, rom_ptr
* will return a NULL pointer and we should use ldl_phys instead.
*/
initial_msp = ldl_phys(s->as, 0);
initial_pc = ldl_phys(s->as, 4);
}
env->regs[13] = initial_msp & 0xFFFFFFFC;
env->regs[15] = initial_pc & ~1;
env->thumb = initial_pc & 1;
}
/* AArch32 has a hard highvec setting of 0xFFFF0000. If we are currently
* executing as AArch32 then check if highvecs are enabled and
* adjust the PC accordingly.
*/
if (A32_BANKED_CURRENT_REG_GET(env, sctlr) & SCTLR_V) {
env->regs[15] = 0xFFFF0000;
}
env->vfp.xregs[ARM_VFP_FPEXC] = 0;
#endif
if (arm_feature(env, ARM_FEATURE_PMSA)) {
if (cpu->pmsav7_dregion > 0) {
if (arm_feature(env, ARM_FEATURE_V8)) {
memset(env->pmsav8.rbar[M_REG_NS], 0,
sizeof(*env->pmsav8.rbar[M_REG_NS])
* cpu->pmsav7_dregion);
memset(env->pmsav8.rlar[M_REG_NS], 0,
sizeof(*env->pmsav8.rlar[M_REG_NS])
* cpu->pmsav7_dregion);
if (arm_feature(env, ARM_FEATURE_M_SECURITY)) {
memset(env->pmsav8.rbar[M_REG_S], 0,
sizeof(*env->pmsav8.rbar[M_REG_S])
* cpu->pmsav7_dregion);
memset(env->pmsav8.rlar[M_REG_S], 0,
sizeof(*env->pmsav8.rlar[M_REG_S])
* cpu->pmsav7_dregion);
}
} else if (arm_feature(env, ARM_FEATURE_V7)) {
memset(env->pmsav7.drbar, 0,
sizeof(*env->pmsav7.drbar) * cpu->pmsav7_dregion);
memset(env->pmsav7.drsr, 0,
sizeof(*env->pmsav7.drsr) * cpu->pmsav7_dregion);
memset(env->pmsav7.dracr, 0,
sizeof(*env->pmsav7.dracr) * cpu->pmsav7_dregion);
}
}
env->pmsav7.rnr[M_REG_NS] = 0;
env->pmsav7.rnr[M_REG_S] = 0;
env->pmsav8.mair0[M_REG_NS] = 0;
env->pmsav8.mair0[M_REG_S] = 0;
env->pmsav8.mair1[M_REG_NS] = 0;
env->pmsav8.mair1[M_REG_S] = 0;
}
set_flush_to_zero(1, &env->vfp.standard_fp_status);
set_flush_inputs_to_zero(1, &env->vfp.standard_fp_status);
set_default_nan_mode(1, &env->vfp.standard_fp_status);
set_float_detect_tininess(float_tininess_before_rounding,
&env->vfp.fp_status);
set_float_detect_tininess(float_tininess_before_rounding,
&env->vfp.standard_fp_status);
#ifndef CONFIG_USER_ONLY
if (kvm_enabled()) {
kvm_arm_reset_vcpu(cpu);
}
#endif
hw_breakpoint_update_all(cpu);
hw_watchpoint_update_all(cpu);
}
| false | qemu | 9d40cd8a68cfc7606f4548cc9e812bab15c6dc28 | static void arm_cpu_reset(CPUState *s)
{
ARMCPU *cpu = ARM_CPU(s);
ARMCPUClass *acc = ARM_CPU_GET_CLASS(cpu);
CPUARMState *env = &cpu->env;
acc->parent_reset(s);
memset(env, 0, offsetof(CPUARMState, end_reset_fields));
g_hash_table_foreach(cpu->cp_regs, cp_reg_reset, cpu);
g_hash_table_foreach(cpu->cp_regs, cp_reg_check_reset, cpu);
env->vfp.xregs[ARM_VFP_FPSID] = cpu->reset_fpsid;
env->vfp.xregs[ARM_VFP_MVFR0] = cpu->mvfr0;
env->vfp.xregs[ARM_VFP_MVFR1] = cpu->mvfr1;
env->vfp.xregs[ARM_VFP_MVFR2] = cpu->mvfr2;
cpu->power_state = cpu->start_powered_off ? PSCI_OFF : PSCI_ON;
s->halted = cpu->start_powered_off;
if (arm_feature(env, ARM_FEATURE_IWMMXT)) {
env->iwmmxt.cregs[ARM_IWMMXT_wCID] = 0x69051000 | 'Q';
}
if (arm_feature(env, ARM_FEATURE_AARCH64)) {
env->aarch64 = 1;
#if defined(CONFIG_USER_ONLY)
env->pstate = PSTATE_MODE_EL0t;
env->cp15.sctlr_el[1] |= SCTLR_UCT | SCTLR_UCI | SCTLR_DZE;
env->cp15.cpacr_el1 = deposit64(env->cp15.cpacr_el1, 20, 2, 3);
#else
if (arm_feature(env, ARM_FEATURE_EL3)) {
env->pstate = PSTATE_MODE_EL3h;
} else if (arm_feature(env, ARM_FEATURE_EL2)) {
env->pstate = PSTATE_MODE_EL2h;
} else {
env->pstate = PSTATE_MODE_EL1h;
}
env->pc = cpu->rvbar;
#endif
} else {
#if defined(CONFIG_USER_ONLY)
env->cp15.cpacr_el1 = deposit64(env->cp15.cpacr_el1, 20, 4, 0xf);
#endif
}
#if defined(CONFIG_USER_ONLY)
env->uncached_cpsr = ARM_CPU_MODE_USR;
env->vfp.xregs[ARM_VFP_FPEXC] = 1 << 30;
if (arm_feature(env, ARM_FEATURE_IWMMXT)) {
env->cp15.c15_cpar = 3;
} else if (arm_feature(env, ARM_FEATURE_XSCALE)) {
env->cp15.c15_cpar = 1;
}
#else
env->uncached_cpsr = ARM_CPU_MODE_SVC;
env->daif = PSTATE_D | PSTATE_A | PSTATE_I | PSTATE_F;
if (arm_feature(env, ARM_FEATURE_M)) {
uint32_t initial_msp;
uint32_t initial_pc;
uint8_t *rom;
if (arm_feature(env, ARM_FEATURE_M_SECURITY)) {
env->v7m.secure = true;
}
env->v7m.ccr = R_V7M_CCR_STKALIGN_MASK;
env->regs[14] = 0xffffffff;
rom = rom_ptr(0);
if (rom) {
initial_msp = ldl_p(rom);
initial_pc = ldl_p(rom + 4);
} else {
initial_msp = ldl_phys(s->as, 0);
initial_pc = ldl_phys(s->as, 4);
}
env->regs[13] = initial_msp & 0xFFFFFFFC;
env->regs[15] = initial_pc & ~1;
env->thumb = initial_pc & 1;
}
if (A32_BANKED_CURRENT_REG_GET(env, sctlr) & SCTLR_V) {
env->regs[15] = 0xFFFF0000;
}
env->vfp.xregs[ARM_VFP_FPEXC] = 0;
#endif
if (arm_feature(env, ARM_FEATURE_PMSA)) {
if (cpu->pmsav7_dregion > 0) {
if (arm_feature(env, ARM_FEATURE_V8)) {
memset(env->pmsav8.rbar[M_REG_NS], 0,
sizeof(*env->pmsav8.rbar[M_REG_NS])
* cpu->pmsav7_dregion);
memset(env->pmsav8.rlar[M_REG_NS], 0,
sizeof(*env->pmsav8.rlar[M_REG_NS])
* cpu->pmsav7_dregion);
if (arm_feature(env, ARM_FEATURE_M_SECURITY)) {
memset(env->pmsav8.rbar[M_REG_S], 0,
sizeof(*env->pmsav8.rbar[M_REG_S])
* cpu->pmsav7_dregion);
memset(env->pmsav8.rlar[M_REG_S], 0,
sizeof(*env->pmsav8.rlar[M_REG_S])
* cpu->pmsav7_dregion);
}
} else if (arm_feature(env, ARM_FEATURE_V7)) {
memset(env->pmsav7.drbar, 0,
sizeof(*env->pmsav7.drbar) * cpu->pmsav7_dregion);
memset(env->pmsav7.drsr, 0,
sizeof(*env->pmsav7.drsr) * cpu->pmsav7_dregion);
memset(env->pmsav7.dracr, 0,
sizeof(*env->pmsav7.dracr) * cpu->pmsav7_dregion);
}
}
env->pmsav7.rnr[M_REG_NS] = 0;
env->pmsav7.rnr[M_REG_S] = 0;
env->pmsav8.mair0[M_REG_NS] = 0;
env->pmsav8.mair0[M_REG_S] = 0;
env->pmsav8.mair1[M_REG_NS] = 0;
env->pmsav8.mair1[M_REG_S] = 0;
}
set_flush_to_zero(1, &env->vfp.standard_fp_status);
set_flush_inputs_to_zero(1, &env->vfp.standard_fp_status);
set_default_nan_mode(1, &env->vfp.standard_fp_status);
set_float_detect_tininess(float_tininess_before_rounding,
&env->vfp.fp_status);
set_float_detect_tininess(float_tininess_before_rounding,
&env->vfp.standard_fp_status);
#ifndef CONFIG_USER_ONLY
if (kvm_enabled()) {
kvm_arm_reset_vcpu(cpu);
}
#endif
hw_breakpoint_update_all(cpu);
hw_watchpoint_update_all(cpu);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(CPUState *VAR_0)
{
ARMCPU *cpu = ARM_CPU(VAR_0);
ARMCPUClass *acc = ARM_CPU_GET_CLASS(cpu);
CPUARMState *env = &cpu->env;
acc->parent_reset(VAR_0);
memset(env, 0, offsetof(CPUARMState, end_reset_fields));
g_hash_table_foreach(cpu->cp_regs, cp_reg_reset, cpu);
g_hash_table_foreach(cpu->cp_regs, cp_reg_check_reset, cpu);
env->vfp.xregs[ARM_VFP_FPSID] = cpu->reset_fpsid;
env->vfp.xregs[ARM_VFP_MVFR0] = cpu->mvfr0;
env->vfp.xregs[ARM_VFP_MVFR1] = cpu->mvfr1;
env->vfp.xregs[ARM_VFP_MVFR2] = cpu->mvfr2;
cpu->power_state = cpu->start_powered_off ? PSCI_OFF : PSCI_ON;
VAR_0->halted = cpu->start_powered_off;
if (arm_feature(env, ARM_FEATURE_IWMMXT)) {
env->iwmmxt.cregs[ARM_IWMMXT_wCID] = 0x69051000 | 'Q';
}
if (arm_feature(env, ARM_FEATURE_AARCH64)) {
env->aarch64 = 1;
#if defined(CONFIG_USER_ONLY)
env->pstate = PSTATE_MODE_EL0t;
env->cp15.sctlr_el[1] |= SCTLR_UCT | SCTLR_UCI | SCTLR_DZE;
env->cp15.cpacr_el1 = deposit64(env->cp15.cpacr_el1, 20, 2, 3);
#else
if (arm_feature(env, ARM_FEATURE_EL3)) {
env->pstate = PSTATE_MODE_EL3h;
} else if (arm_feature(env, ARM_FEATURE_EL2)) {
env->pstate = PSTATE_MODE_EL2h;
} else {
env->pstate = PSTATE_MODE_EL1h;
}
env->pc = cpu->rvbar;
#endif
} else {
#if defined(CONFIG_USER_ONLY)
env->cp15.cpacr_el1 = deposit64(env->cp15.cpacr_el1, 20, 4, 0xf);
#endif
}
#if defined(CONFIG_USER_ONLY)
env->uncached_cpsr = ARM_CPU_MODE_USR;
env->vfp.xregs[ARM_VFP_FPEXC] = 1 << 30;
if (arm_feature(env, ARM_FEATURE_IWMMXT)) {
env->cp15.c15_cpar = 3;
} else if (arm_feature(env, ARM_FEATURE_XSCALE)) {
env->cp15.c15_cpar = 1;
}
#else
env->uncached_cpsr = ARM_CPU_MODE_SVC;
env->daif = PSTATE_D | PSTATE_A | PSTATE_I | PSTATE_F;
if (arm_feature(env, ARM_FEATURE_M)) {
uint32_t initial_msp;
uint32_t initial_pc;
uint8_t *rom;
if (arm_feature(env, ARM_FEATURE_M_SECURITY)) {
env->v7m.secure = true;
}
env->v7m.ccr = R_V7M_CCR_STKALIGN_MASK;
env->regs[14] = 0xffffffff;
rom = rom_ptr(0);
if (rom) {
initial_msp = ldl_p(rom);
initial_pc = ldl_p(rom + 4);
} else {
initial_msp = ldl_phys(VAR_0->as, 0);
initial_pc = ldl_phys(VAR_0->as, 4);
}
env->regs[13] = initial_msp & 0xFFFFFFFC;
env->regs[15] = initial_pc & ~1;
env->thumb = initial_pc & 1;
}
if (A32_BANKED_CURRENT_REG_GET(env, sctlr) & SCTLR_V) {
env->regs[15] = 0xFFFF0000;
}
env->vfp.xregs[ARM_VFP_FPEXC] = 0;
#endif
if (arm_feature(env, ARM_FEATURE_PMSA)) {
if (cpu->pmsav7_dregion > 0) {
if (arm_feature(env, ARM_FEATURE_V8)) {
memset(env->pmsav8.rbar[M_REG_NS], 0,
sizeof(*env->pmsav8.rbar[M_REG_NS])
* cpu->pmsav7_dregion);
memset(env->pmsav8.rlar[M_REG_NS], 0,
sizeof(*env->pmsav8.rlar[M_REG_NS])
* cpu->pmsav7_dregion);
if (arm_feature(env, ARM_FEATURE_M_SECURITY)) {
memset(env->pmsav8.rbar[M_REG_S], 0,
sizeof(*env->pmsav8.rbar[M_REG_S])
* cpu->pmsav7_dregion);
memset(env->pmsav8.rlar[M_REG_S], 0,
sizeof(*env->pmsav8.rlar[M_REG_S])
* cpu->pmsav7_dregion);
}
} else if (arm_feature(env, ARM_FEATURE_V7)) {
memset(env->pmsav7.drbar, 0,
sizeof(*env->pmsav7.drbar) * cpu->pmsav7_dregion);
memset(env->pmsav7.drsr, 0,
sizeof(*env->pmsav7.drsr) * cpu->pmsav7_dregion);
memset(env->pmsav7.dracr, 0,
sizeof(*env->pmsav7.dracr) * cpu->pmsav7_dregion);
}
}
env->pmsav7.rnr[M_REG_NS] = 0;
env->pmsav7.rnr[M_REG_S] = 0;
env->pmsav8.mair0[M_REG_NS] = 0;
env->pmsav8.mair0[M_REG_S] = 0;
env->pmsav8.mair1[M_REG_NS] = 0;
env->pmsav8.mair1[M_REG_S] = 0;
}
set_flush_to_zero(1, &env->vfp.standard_fp_status);
set_flush_inputs_to_zero(1, &env->vfp.standard_fp_status);
set_default_nan_mode(1, &env->vfp.standard_fp_status);
set_float_detect_tininess(float_tininess_before_rounding,
&env->vfp.fp_status);
set_float_detect_tininess(float_tininess_before_rounding,
&env->vfp.standard_fp_status);
#ifndef CONFIG_USER_ONLY
if (kvm_enabled()) {
kvm_arm_reset_vcpu(cpu);
}
#endif
hw_breakpoint_update_all(cpu);
hw_watchpoint_update_all(cpu);
}
| [
"static void FUNC_0(CPUState *VAR_0)\n{",
"ARMCPU *cpu = ARM_CPU(VAR_0);",
"ARMCPUClass *acc = ARM_CPU_GET_CLASS(cpu);",
"CPUARMState *env = &cpu->env;",
"acc->parent_reset(VAR_0);",
"memset(env, 0, offsetof(CPUARMState, end_reset_fields));",
"g_hash_table_foreach(cpu->cp_regs, cp_reg_reset, cpu);",
"g_hash_table_foreach(cpu->cp_regs, cp_reg_check_reset, cpu);",
"env->vfp.xregs[ARM_VFP_FPSID] = cpu->reset_fpsid;",
"env->vfp.xregs[ARM_VFP_MVFR0] = cpu->mvfr0;",
"env->vfp.xregs[ARM_VFP_MVFR1] = cpu->mvfr1;",
"env->vfp.xregs[ARM_VFP_MVFR2] = cpu->mvfr2;",
"cpu->power_state = cpu->start_powered_off ? PSCI_OFF : PSCI_ON;",
"VAR_0->halted = cpu->start_powered_off;",
"if (arm_feature(env, ARM_FEATURE_IWMMXT)) {",
"env->iwmmxt.cregs[ARM_IWMMXT_wCID] = 0x69051000 | 'Q';",
"}",
"if (arm_feature(env, ARM_FEATURE_AARCH64)) {",
"env->aarch64 = 1;",
"#if defined(CONFIG_USER_ONLY)\nenv->pstate = PSTATE_MODE_EL0t;",
"env->cp15.sctlr_el[1] |= SCTLR_UCT | SCTLR_UCI | SCTLR_DZE;",
"env->cp15.cpacr_el1 = deposit64(env->cp15.cpacr_el1, 20, 2, 3);",
"#else\nif (arm_feature(env, ARM_FEATURE_EL3)) {",
"env->pstate = PSTATE_MODE_EL3h;",
"} else if (arm_feature(env, ARM_FEATURE_EL2)) {",
"env->pstate = PSTATE_MODE_EL2h;",
"} else {",
"env->pstate = PSTATE_MODE_EL1h;",
"}",
"env->pc = cpu->rvbar;",
"#endif\n} else {",
"#if defined(CONFIG_USER_ONLY)\nenv->cp15.cpacr_el1 = deposit64(env->cp15.cpacr_el1, 20, 4, 0xf);",
"#endif\n}",
"#if defined(CONFIG_USER_ONLY)\nenv->uncached_cpsr = ARM_CPU_MODE_USR;",
"env->vfp.xregs[ARM_VFP_FPEXC] = 1 << 30;",
"if (arm_feature(env, ARM_FEATURE_IWMMXT)) {",
"env->cp15.c15_cpar = 3;",
"} else if (arm_feature(env, ARM_FEATURE_XSCALE)) {",
"env->cp15.c15_cpar = 1;",
"}",
"#else\nenv->uncached_cpsr = ARM_CPU_MODE_SVC;",
"env->daif = PSTATE_D | PSTATE_A | PSTATE_I | PSTATE_F;",
"if (arm_feature(env, ARM_FEATURE_M)) {",
"uint32_t initial_msp;",
"uint32_t initial_pc;",
"uint8_t *rom;",
"if (arm_feature(env, ARM_FEATURE_M_SECURITY)) {",
"env->v7m.secure = true;",
"}",
"env->v7m.ccr = R_V7M_CCR_STKALIGN_MASK;",
"env->regs[14] = 0xffffffff;",
"rom = rom_ptr(0);",
"if (rom) {",
"initial_msp = ldl_p(rom);",
"initial_pc = ldl_p(rom + 4);",
"} else {",
"initial_msp = ldl_phys(VAR_0->as, 0);",
"initial_pc = ldl_phys(VAR_0->as, 4);",
"}",
"env->regs[13] = initial_msp & 0xFFFFFFFC;",
"env->regs[15] = initial_pc & ~1;",
"env->thumb = initial_pc & 1;",
"}",
"if (A32_BANKED_CURRENT_REG_GET(env, sctlr) & SCTLR_V) {",
"env->regs[15] = 0xFFFF0000;",
"}",
"env->vfp.xregs[ARM_VFP_FPEXC] = 0;",
"#endif\nif (arm_feature(env, ARM_FEATURE_PMSA)) {",
"if (cpu->pmsav7_dregion > 0) {",
"if (arm_feature(env, ARM_FEATURE_V8)) {",
"memset(env->pmsav8.rbar[M_REG_NS], 0,\nsizeof(*env->pmsav8.rbar[M_REG_NS])\n* cpu->pmsav7_dregion);",
"memset(env->pmsav8.rlar[M_REG_NS], 0,\nsizeof(*env->pmsav8.rlar[M_REG_NS])\n* cpu->pmsav7_dregion);",
"if (arm_feature(env, ARM_FEATURE_M_SECURITY)) {",
"memset(env->pmsav8.rbar[M_REG_S], 0,\nsizeof(*env->pmsav8.rbar[M_REG_S])\n* cpu->pmsav7_dregion);",
"memset(env->pmsav8.rlar[M_REG_S], 0,\nsizeof(*env->pmsav8.rlar[M_REG_S])\n* cpu->pmsav7_dregion);",
"}",
"} else if (arm_feature(env, ARM_FEATURE_V7)) {",
"memset(env->pmsav7.drbar, 0,\nsizeof(*env->pmsav7.drbar) * cpu->pmsav7_dregion);",
"memset(env->pmsav7.drsr, 0,\nsizeof(*env->pmsav7.drsr) * cpu->pmsav7_dregion);",
"memset(env->pmsav7.dracr, 0,\nsizeof(*env->pmsav7.dracr) * cpu->pmsav7_dregion);",
"}",
"}",
"env->pmsav7.rnr[M_REG_NS] = 0;",
"env->pmsav7.rnr[M_REG_S] = 0;",
"env->pmsav8.mair0[M_REG_NS] = 0;",
"env->pmsav8.mair0[M_REG_S] = 0;",
"env->pmsav8.mair1[M_REG_NS] = 0;",
"env->pmsav8.mair1[M_REG_S] = 0;",
"}",
"set_flush_to_zero(1, &env->vfp.standard_fp_status);",
"set_flush_inputs_to_zero(1, &env->vfp.standard_fp_status);",
"set_default_nan_mode(1, &env->vfp.standard_fp_status);",
"set_float_detect_tininess(float_tininess_before_rounding,\n&env->vfp.fp_status);",
"set_float_detect_tininess(float_tininess_before_rounding,\n&env->vfp.standard_fp_status);",
"#ifndef CONFIG_USER_ONLY\nif (kvm_enabled()) {",
"kvm_arm_reset_vcpu(cpu);",
"}",
"#endif\nhw_breakpoint_update_all(cpu);",
"hw_watchpoint_update_all(cpu);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
51
],
[
55
],
[
57,
59
],
[
63
],
[
67
],
[
69,
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89,
91
],
[
93,
97
],
[
99,
101
],
[
105,
107
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123,
127
],
[
129
],
[
133
],
[
135
],
[
137
],
[
139
],
[
143
],
[
145
],
[
147
],
[
159
],
[
165
],
[
171
],
[
173
],
[
181
],
[
183
],
[
185
],
[
197
],
[
199
],
[
201
],
[
205
],
[
207
],
[
209
],
[
211
],
[
223
],
[
225
],
[
227
],
[
231
],
[
233,
237
],
[
239
],
[
241
],
[
243,
245,
247
],
[
249,
251,
253
],
[
255
],
[
257,
259,
261
],
[
263,
265,
267
],
[
269
],
[
271
],
[
273,
275
],
[
277,
279
],
[
281,
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
305
],
[
307
],
[
309
],
[
311,
313
],
[
315,
317
],
[
319,
321
],
[
323
],
[
325
],
[
327,
331
],
[
333
],
[
335
]
] |
22,342 | void json_start_array(QJSON *json, const char *name)
{
json_emit_element(json, name);
qstring_append(json->str, "[ ");
json->omit_comma = true;
}
| false | qemu | 17b74b98676aee5bc470b173b1e528d2fce2cf18 | void json_start_array(QJSON *json, const char *name)
{
json_emit_element(json, name);
qstring_append(json->str, "[ ");
json->omit_comma = true;
}
| {
"code": [],
"line_no": []
} | void FUNC_0(QJSON *VAR_0, const char *VAR_1)
{
json_emit_element(VAR_0, VAR_1);
qstring_append(VAR_0->str, "[ ");
VAR_0->omit_comma = true;
}
| [
"void FUNC_0(QJSON *VAR_0, const char *VAR_1)\n{",
"json_emit_element(VAR_0, VAR_1);",
"qstring_append(VAR_0->str, \"[ \");",
"VAR_0->omit_comma = true;",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
]
] |
22,343 | vreader_get_reader_by_id(vreader_id_t id)
{
VReader *reader = NULL;
VReaderListEntry *current_entry = NULL;
if (id == (vreader_id_t) -1) {
return NULL;
}
vreader_list_lock();
for (current_entry = vreader_list_get_first(vreader_list); current_entry;
current_entry = vreader_list_get_next(current_entry)) {
VReader *creader = vreader_list_get_reader(current_entry);
if (creader->id == id) {
reader = creader;
break;
}
vreader_free(creader);
}
vreader_list_unlock();
return reader;
}
| false | qemu | 1687a089f103f9b7a1b4a1555068054cb46ee9e9 | vreader_get_reader_by_id(vreader_id_t id)
{
VReader *reader = NULL;
VReaderListEntry *current_entry = NULL;
if (id == (vreader_id_t) -1) {
return NULL;
}
vreader_list_lock();
for (current_entry = vreader_list_get_first(vreader_list); current_entry;
current_entry = vreader_list_get_next(current_entry)) {
VReader *creader = vreader_list_get_reader(current_entry);
if (creader->id == id) {
reader = creader;
break;
}
vreader_free(creader);
}
vreader_list_unlock();
return reader;
}
| {
"code": [],
"line_no": []
} | FUNC_0(vreader_id_t VAR_0)
{
VReader *reader = NULL;
VReaderListEntry *current_entry = NULL;
if (VAR_0 == (vreader_id_t) -1) {
return NULL;
}
vreader_list_lock();
for (current_entry = vreader_list_get_first(vreader_list); current_entry;
current_entry = vreader_list_get_next(current_entry)) {
VReader *creader = vreader_list_get_reader(current_entry);
if (creader->VAR_0 == VAR_0) {
reader = creader;
break;
}
vreader_free(creader);
}
vreader_list_unlock();
return reader;
}
| [
"FUNC_0(vreader_id_t VAR_0)\n{",
"VReader *reader = NULL;",
"VReaderListEntry *current_entry = NULL;",
"if (VAR_0 == (vreader_id_t) -1) {",
"return NULL;",
"}",
"vreader_list_lock();",
"for (current_entry = vreader_list_get_first(vreader_list); current_entry;",
"current_entry = vreader_list_get_next(current_entry)) {",
"VReader *creader = vreader_list_get_reader(current_entry);",
"if (creader->VAR_0 == VAR_0) {",
"reader = creader;",
"break;",
"}",
"vreader_free(creader);",
"}",
"vreader_list_unlock();",
"return reader;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
]
] |
22,344 | AVFilter **av_filter_next(AVFilter **filter)
{
return filter ? ++filter : ®istered_avfilters[0];
}
| false | FFmpeg | fa2a34cd40d124161c748bb0f430dc63c94dd0da | AVFilter **av_filter_next(AVFilter **filter)
{
return filter ? ++filter : ®istered_avfilters[0];
}
| {
"code": [],
"line_no": []
} | AVFilter **FUNC_0(AVFilter **filter)
{
return filter ? ++filter : ®istered_avfilters[0];
}
| [
"AVFilter **FUNC_0(AVFilter **filter)\n{",
"return filter ? ++filter : ®istered_avfilters[0];",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
22,345 | static void gem_cleanup(NetClientState *nc)
{
GemState *s = qemu_get_nic_opaque(nc);
DB_PRINT("\n");
s->nic = NULL;
}
| false | qemu | 57407ea44cc0a3d630b9b89a2be011f1955ce5c1 | static void gem_cleanup(NetClientState *nc)
{
GemState *s = qemu_get_nic_opaque(nc);
DB_PRINT("\n");
s->nic = NULL;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(NetClientState *VAR_0)
{
GemState *s = qemu_get_nic_opaque(VAR_0);
DB_PRINT("\n");
s->nic = NULL;
}
| [
"static void FUNC_0(NetClientState *VAR_0)\n{",
"GemState *s = qemu_get_nic_opaque(VAR_0);",
"DB_PRINT(\"\\n\");",
"s->nic = NULL;",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
]
] |
22,346 | void qxl_render_cursor(PCIQXLDevice *qxl, QXLCommandExt *ext)
{
QXLCursorCmd *cmd = qxl_phys2virt(qxl, ext->cmd.data, ext->group_id);
QXLCursor *cursor;
QEMUCursor *c;
if (!qxl->ssd.ds->mouse_set || !qxl->ssd.ds->cursor_define) {
return;
}
if (qxl->debug > 1 && cmd->type != QXL_CURSOR_MOVE) {
fprintf(stderr, "%s", __FUNCTION__);
qxl_log_cmd_cursor(qxl, cmd, ext->group_id);
fprintf(stderr, "\n");
}
switch (cmd->type) {
case QXL_CURSOR_SET:
cursor = qxl_phys2virt(qxl, cmd->u.set.shape, ext->group_id);
if (cursor->chunk.data_size != cursor->data_size) {
fprintf(stderr, "%s: multiple chunks\n", __FUNCTION__);
return;
}
c = qxl_cursor(qxl, cursor);
if (c == NULL) {
c = cursor_builtin_left_ptr();
}
qemu_mutex_lock(&qxl->ssd.lock);
if (qxl->ssd.cursor) {
cursor_put(qxl->ssd.cursor);
}
qxl->ssd.cursor = c;
qxl->ssd.mouse_x = cmd->u.set.position.x;
qxl->ssd.mouse_y = cmd->u.set.position.y;
qemu_mutex_unlock(&qxl->ssd.lock);
break;
case QXL_CURSOR_MOVE:
qemu_mutex_lock(&qxl->ssd.lock);
qxl->ssd.mouse_x = cmd->u.position.x;
qxl->ssd.mouse_y = cmd->u.position.y;
qemu_mutex_unlock(&qxl->ssd.lock);
break;
}
}
| false | qemu | fae2afb10e3fdceab612c62a2b1e8b944ff578d9 | void qxl_render_cursor(PCIQXLDevice *qxl, QXLCommandExt *ext)
{
QXLCursorCmd *cmd = qxl_phys2virt(qxl, ext->cmd.data, ext->group_id);
QXLCursor *cursor;
QEMUCursor *c;
if (!qxl->ssd.ds->mouse_set || !qxl->ssd.ds->cursor_define) {
return;
}
if (qxl->debug > 1 && cmd->type != QXL_CURSOR_MOVE) {
fprintf(stderr, "%s", __FUNCTION__);
qxl_log_cmd_cursor(qxl, cmd, ext->group_id);
fprintf(stderr, "\n");
}
switch (cmd->type) {
case QXL_CURSOR_SET:
cursor = qxl_phys2virt(qxl, cmd->u.set.shape, ext->group_id);
if (cursor->chunk.data_size != cursor->data_size) {
fprintf(stderr, "%s: multiple chunks\n", __FUNCTION__);
return;
}
c = qxl_cursor(qxl, cursor);
if (c == NULL) {
c = cursor_builtin_left_ptr();
}
qemu_mutex_lock(&qxl->ssd.lock);
if (qxl->ssd.cursor) {
cursor_put(qxl->ssd.cursor);
}
qxl->ssd.cursor = c;
qxl->ssd.mouse_x = cmd->u.set.position.x;
qxl->ssd.mouse_y = cmd->u.set.position.y;
qemu_mutex_unlock(&qxl->ssd.lock);
break;
case QXL_CURSOR_MOVE:
qemu_mutex_lock(&qxl->ssd.lock);
qxl->ssd.mouse_x = cmd->u.position.x;
qxl->ssd.mouse_y = cmd->u.position.y;
qemu_mutex_unlock(&qxl->ssd.lock);
break;
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(PCIQXLDevice *VAR_0, QXLCommandExt *VAR_1)
{
QXLCursorCmd *cmd = qxl_phys2virt(VAR_0, VAR_1->cmd.data, VAR_1->group_id);
QXLCursor *cursor;
QEMUCursor *c;
if (!VAR_0->ssd.ds->mouse_set || !VAR_0->ssd.ds->cursor_define) {
return;
}
if (VAR_0->debug > 1 && cmd->type != QXL_CURSOR_MOVE) {
fprintf(stderr, "%s", __FUNCTION__);
qxl_log_cmd_cursor(VAR_0, cmd, VAR_1->group_id);
fprintf(stderr, "\n");
}
switch (cmd->type) {
case QXL_CURSOR_SET:
cursor = qxl_phys2virt(VAR_0, cmd->u.set.shape, VAR_1->group_id);
if (cursor->chunk.data_size != cursor->data_size) {
fprintf(stderr, "%s: multiple chunks\n", __FUNCTION__);
return;
}
c = qxl_cursor(VAR_0, cursor);
if (c == NULL) {
c = cursor_builtin_left_ptr();
}
qemu_mutex_lock(&VAR_0->ssd.lock);
if (VAR_0->ssd.cursor) {
cursor_put(VAR_0->ssd.cursor);
}
VAR_0->ssd.cursor = c;
VAR_0->ssd.mouse_x = cmd->u.set.position.x;
VAR_0->ssd.mouse_y = cmd->u.set.position.y;
qemu_mutex_unlock(&VAR_0->ssd.lock);
break;
case QXL_CURSOR_MOVE:
qemu_mutex_lock(&VAR_0->ssd.lock);
VAR_0->ssd.mouse_x = cmd->u.position.x;
VAR_0->ssd.mouse_y = cmd->u.position.y;
qemu_mutex_unlock(&VAR_0->ssd.lock);
break;
}
}
| [
"void FUNC_0(PCIQXLDevice *VAR_0, QXLCommandExt *VAR_1)\n{",
"QXLCursorCmd *cmd = qxl_phys2virt(VAR_0, VAR_1->cmd.data, VAR_1->group_id);",
"QXLCursor *cursor;",
"QEMUCursor *c;",
"if (!VAR_0->ssd.ds->mouse_set || !VAR_0->ssd.ds->cursor_define) {",
"return;",
"}",
"if (VAR_0->debug > 1 && cmd->type != QXL_CURSOR_MOVE) {",
"fprintf(stderr, \"%s\", __FUNCTION__);",
"qxl_log_cmd_cursor(VAR_0, cmd, VAR_1->group_id);",
"fprintf(stderr, \"\\n\");",
"}",
"switch (cmd->type) {",
"case QXL_CURSOR_SET:\ncursor = qxl_phys2virt(VAR_0, cmd->u.set.shape, VAR_1->group_id);",
"if (cursor->chunk.data_size != cursor->data_size) {",
"fprintf(stderr, \"%s: multiple chunks\\n\", __FUNCTION__);",
"return;",
"}",
"c = qxl_cursor(VAR_0, cursor);",
"if (c == NULL) {",
"c = cursor_builtin_left_ptr();",
"}",
"qemu_mutex_lock(&VAR_0->ssd.lock);",
"if (VAR_0->ssd.cursor) {",
"cursor_put(VAR_0->ssd.cursor);",
"}",
"VAR_0->ssd.cursor = c;",
"VAR_0->ssd.mouse_x = cmd->u.set.position.x;",
"VAR_0->ssd.mouse_y = cmd->u.set.position.y;",
"qemu_mutex_unlock(&VAR_0->ssd.lock);",
"break;",
"case QXL_CURSOR_MOVE:\nqemu_mutex_lock(&VAR_0->ssd.lock);",
"VAR_0->ssd.mouse_x = cmd->u.position.x;",
"VAR_0->ssd.mouse_y = cmd->u.position.y;",
"qemu_mutex_unlock(&VAR_0->ssd.lock);",
"break;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33,
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71,
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
]
] |
22,347 | static uint64_t qemu_opt_get_number_helper(QemuOpts *opts, const char *name,
uint64_t defval, bool del)
{
QemuOpt *opt = qemu_opt_find(opts, name);
uint64_t ret = defval;
if (opt == NULL) {
const QemuOptDesc *desc = find_desc_by_name(opts->list->desc, name);
if (desc && desc->def_value_str) {
parse_option_number(name, desc->def_value_str, &ret, &error_abort);
}
return ret;
}
assert(opt->desc && opt->desc->type == QEMU_OPT_NUMBER);
ret = opt->value.uint;
if (del) {
qemu_opt_del_all(opts, name);
}
return ret;
}
| false | qemu | 435db4cf29b88b6612e30acda01cd18788dff458 | static uint64_t qemu_opt_get_number_helper(QemuOpts *opts, const char *name,
uint64_t defval, bool del)
{
QemuOpt *opt = qemu_opt_find(opts, name);
uint64_t ret = defval;
if (opt == NULL) {
const QemuOptDesc *desc = find_desc_by_name(opts->list->desc, name);
if (desc && desc->def_value_str) {
parse_option_number(name, desc->def_value_str, &ret, &error_abort);
}
return ret;
}
assert(opt->desc && opt->desc->type == QEMU_OPT_NUMBER);
ret = opt->value.uint;
if (del) {
qemu_opt_del_all(opts, name);
}
return ret;
}
| {
"code": [],
"line_no": []
} | static uint64_t FUNC_0(QemuOpts *opts, const char *name,
uint64_t defval, bool del)
{
QemuOpt *opt = qemu_opt_find(opts, name);
uint64_t ret = defval;
if (opt == NULL) {
const QemuOptDesc *VAR_0 = find_desc_by_name(opts->list->VAR_0, name);
if (VAR_0 && VAR_0->def_value_str) {
parse_option_number(name, VAR_0->def_value_str, &ret, &error_abort);
}
return ret;
}
assert(opt->VAR_0 && opt->VAR_0->type == QEMU_OPT_NUMBER);
ret = opt->value.uint;
if (del) {
qemu_opt_del_all(opts, name);
}
return ret;
}
| [
"static uint64_t FUNC_0(QemuOpts *opts, const char *name,\nuint64_t defval, bool del)\n{",
"QemuOpt *opt = qemu_opt_find(opts, name);",
"uint64_t ret = defval;",
"if (opt == NULL) {",
"const QemuOptDesc *VAR_0 = find_desc_by_name(opts->list->VAR_0, name);",
"if (VAR_0 && VAR_0->def_value_str) {",
"parse_option_number(name, VAR_0->def_value_str, &ret, &error_abort);",
"}",
"return ret;",
"}",
"assert(opt->VAR_0 && opt->VAR_0->type == QEMU_OPT_NUMBER);",
"ret = opt->value.uint;",
"if (del) {",
"qemu_opt_del_all(opts, name);",
"}",
"return ret;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
]
] |
22,348 | void helper_unlock(void)
{
spin_unlock(&global_cpu_lock);
}
| false | qemu | 677ef6230b603571ae05125db469f7b4c8912a77 | void helper_unlock(void)
{
spin_unlock(&global_cpu_lock);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(void)
{
spin_unlock(&global_cpu_lock);
}
| [
"void FUNC_0(void)\n{",
"spin_unlock(&global_cpu_lock);",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
22,349 | static void vmsvga_screen_dump(void *opaque, const char *filename, bool cswitch,
Error **errp)
{
struct vmsvga_state_s *s = opaque;
DisplaySurface *surface = qemu_console_surface(s->vga.con);
if (!s->enable) {
s->vga.screen_dump(&s->vga, filename, cswitch, errp);
return;
}
if (surface_bits_per_pixel(surface) == 32) {
DisplaySurface *ds = qemu_create_displaysurface_from(
surface_width(surface),
surface_height(surface),
32,
surface_stride(surface),
s->vga.vram_ptr, false);
ppm_save(filename, ds, errp);
g_free(ds);
}
}
| false | qemu | 2c62f08ddbf3fa80dc7202eb9a2ea60ae44e2cc5 | static void vmsvga_screen_dump(void *opaque, const char *filename, bool cswitch,
Error **errp)
{
struct vmsvga_state_s *s = opaque;
DisplaySurface *surface = qemu_console_surface(s->vga.con);
if (!s->enable) {
s->vga.screen_dump(&s->vga, filename, cswitch, errp);
return;
}
if (surface_bits_per_pixel(surface) == 32) {
DisplaySurface *ds = qemu_create_displaysurface_from(
surface_width(surface),
surface_height(surface),
32,
surface_stride(surface),
s->vga.vram_ptr, false);
ppm_save(filename, ds, errp);
g_free(ds);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, const char *VAR_1, bool VAR_2,
Error **VAR_3)
{
struct vmsvga_state_s *VAR_4 = VAR_0;
DisplaySurface *surface = qemu_console_surface(VAR_4->vga.con);
if (!VAR_4->enable) {
VAR_4->vga.screen_dump(&VAR_4->vga, VAR_1, VAR_2, VAR_3);
return;
}
if (surface_bits_per_pixel(surface) == 32) {
DisplaySurface *ds = qemu_create_displaysurface_from(
surface_width(surface),
surface_height(surface),
32,
surface_stride(surface),
VAR_4->vga.vram_ptr, false);
ppm_save(VAR_1, ds, VAR_3);
g_free(ds);
}
}
| [
"static void FUNC_0(void *VAR_0, const char *VAR_1, bool VAR_2,\nError **VAR_3)\n{",
"struct vmsvga_state_s *VAR_4 = VAR_0;",
"DisplaySurface *surface = qemu_console_surface(VAR_4->vga.con);",
"if (!VAR_4->enable) {",
"VAR_4->vga.screen_dump(&VAR_4->vga, VAR_1, VAR_2, VAR_3);",
"return;",
"}",
"if (surface_bits_per_pixel(surface) == 32) {",
"DisplaySurface *ds = qemu_create_displaysurface_from(\nsurface_width(surface),\nsurface_height(surface),\n32,\nsurface_stride(surface),\nVAR_4->vga.vram_ptr, false);",
"ppm_save(VAR_1, ds, VAR_3);",
"g_free(ds);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25,
27,
29,
31,
33,
35
],
[
37
],
[
39
],
[
41
],
[
43
]
] |
22,351 | static void get_tag(AVFormatContext *s, const char *key, int type, int len, int type2_size)
{
char *value;
int64_t off = avio_tell(s->pb);
if ((unsigned)len >= (UINT_MAX - 1) / 2)
return;
value = av_malloc(2 * len + 1);
if (!value)
goto finish;
if (type == 0) { // UTF16-LE
avio_get_str16le(s->pb, len, value, 2 * len + 1);
} else if (type == -1) { // ASCII
avio_read(s->pb, value, len);
value[len]=0;
} else if (type == 1) { // byte array
if (!strcmp(key, "WM/Picture")) { // handle cover art
asf_read_picture(s, len);
} else if (!strcmp(key, "ID3")) { // handle ID3 tag
get_id3_tag(s, len);
} else {
av_log(s, AV_LOG_VERBOSE, "Unsupported byte array in tag %s.\n", key);
}
goto finish;
} else if (type > 1 && type <= 5) { // boolean or DWORD or QWORD or WORD
uint64_t num = get_value(s->pb, type, type2_size);
snprintf(value, len, "%"PRIu64, num);
} else if (type == 6) { // (don't) handle GUID
av_log(s, AV_LOG_DEBUG, "Unsupported GUID value in tag %s.\n", key);
goto finish;
} else {
av_log(s, AV_LOG_DEBUG,
"Unsupported value type %d in tag %s.\n", type, key);
goto finish;
}
if (*value)
av_dict_set(&s->metadata, key, value, 0);
finish:
av_freep(&value);
avio_seek(s->pb, off + len, SEEK_SET);
}
| true | FFmpeg | d9293648147013403de729958ea4c19a5b6c40e4 | static void get_tag(AVFormatContext *s, const char *key, int type, int len, int type2_size)
{
char *value;
int64_t off = avio_tell(s->pb);
if ((unsigned)len >= (UINT_MAX - 1) / 2)
return;
value = av_malloc(2 * len + 1);
if (!value)
goto finish;
if (type == 0) {
avio_get_str16le(s->pb, len, value, 2 * len + 1);
} else if (type == -1) {
avio_read(s->pb, value, len);
value[len]=0;
} else if (type == 1) {
if (!strcmp(key, "WM/Picture")) {
asf_read_picture(s, len);
} else if (!strcmp(key, "ID3")) {
get_id3_tag(s, len);
} else {
av_log(s, AV_LOG_VERBOSE, "Unsupported byte array in tag %s.\n", key);
}
goto finish;
} else if (type > 1 && type <= 5) {
uint64_t num = get_value(s->pb, type, type2_size);
snprintf(value, len, "%"PRIu64, num);
} else if (type == 6) {
av_log(s, AV_LOG_DEBUG, "Unsupported GUID value in tag %s.\n", key);
goto finish;
} else {
av_log(s, AV_LOG_DEBUG,
"Unsupported value type %d in tag %s.\n", type, key);
goto finish;
}
if (*value)
av_dict_set(&s->metadata, key, value, 0);
finish:
av_freep(&value);
avio_seek(s->pb, off + len, SEEK_SET);
}
| {
"code": [
" if ((unsigned)len >= (UINT_MAX - 1) / 2)",
" value = av_malloc(2 * len + 1);",
" snprintf(value, len, \"%\"PRIu64, num);"
],
"line_no": [
11,
17,
57
]
} | static void FUNC_0(AVFormatContext *VAR_0, const char *VAR_1, int VAR_2, int VAR_3, int VAR_4)
{
char *VAR_5;
int64_t off = avio_tell(VAR_0->pb);
if ((unsigned)VAR_3 >= (UINT_MAX - 1) / 2)
return;
VAR_5 = av_malloc(2 * VAR_3 + 1);
if (!VAR_5)
goto finish;
if (VAR_2 == 0) {
avio_get_str16le(VAR_0->pb, VAR_3, VAR_5, 2 * VAR_3 + 1);
} else if (VAR_2 == -1) {
avio_read(VAR_0->pb, VAR_5, VAR_3);
VAR_5[VAR_3]=0;
} else if (VAR_2 == 1) {
if (!strcmp(VAR_1, "WM/Picture")) {
asf_read_picture(VAR_0, VAR_3);
} else if (!strcmp(VAR_1, "ID3")) {
get_id3_tag(VAR_0, VAR_3);
} else {
av_log(VAR_0, AV_LOG_VERBOSE, "Unsupported byte array in tag %VAR_0.\n", VAR_1);
}
goto finish;
} else if (VAR_2 > 1 && VAR_2 <= 5) {
uint64_t num = get_value(VAR_0->pb, VAR_2, VAR_4);
snprintf(VAR_5, VAR_3, "%"PRIu64, num);
} else if (VAR_2 == 6) {
av_log(VAR_0, AV_LOG_DEBUG, "Unsupported GUID VAR_5 in tag %VAR_0.\n", VAR_1);
goto finish;
} else {
av_log(VAR_0, AV_LOG_DEBUG,
"Unsupported VAR_5 VAR_2 %d in tag %VAR_0.\n", VAR_2, VAR_1);
goto finish;
}
if (*VAR_5)
av_dict_set(&VAR_0->metadata, VAR_1, VAR_5, 0);
finish:
av_freep(&VAR_5);
avio_seek(VAR_0->pb, off + VAR_3, SEEK_SET);
}
| [
"static void FUNC_0(AVFormatContext *VAR_0, const char *VAR_1, int VAR_2, int VAR_3, int VAR_4)\n{",
"char *VAR_5;",
"int64_t off = avio_tell(VAR_0->pb);",
"if ((unsigned)VAR_3 >= (UINT_MAX - 1) / 2)\nreturn;",
"VAR_5 = av_malloc(2 * VAR_3 + 1);",
"if (!VAR_5)\ngoto finish;",
"if (VAR_2 == 0) {",
"avio_get_str16le(VAR_0->pb, VAR_3, VAR_5, 2 * VAR_3 + 1);",
"} else if (VAR_2 == -1) {",
"avio_read(VAR_0->pb, VAR_5, VAR_3);",
"VAR_5[VAR_3]=0;",
"} else if (VAR_2 == 1) {",
"if (!strcmp(VAR_1, \"WM/Picture\")) {",
"asf_read_picture(VAR_0, VAR_3);",
"} else if (!strcmp(VAR_1, \"ID3\")) {",
"get_id3_tag(VAR_0, VAR_3);",
"} else {",
"av_log(VAR_0, AV_LOG_VERBOSE, \"Unsupported byte array in tag %VAR_0.\\n\", VAR_1);",
"}",
"goto finish;",
"} else if (VAR_2 > 1 && VAR_2 <= 5) {",
"uint64_t num = get_value(VAR_0->pb, VAR_2, VAR_4);",
"snprintf(VAR_5, VAR_3, \"%\"PRIu64, num);",
"} else if (VAR_2 == 6) {",
"av_log(VAR_0, AV_LOG_DEBUG, \"Unsupported GUID VAR_5 in tag %VAR_0.\\n\", VAR_1);",
"goto finish;",
"} else {",
"av_log(VAR_0, AV_LOG_DEBUG,\n\"Unsupported VAR_5 VAR_2 %d in tag %VAR_0.\\n\", VAR_2, VAR_1);",
"goto finish;",
"}",
"if (*VAR_5)\nav_dict_set(&VAR_0->metadata, VAR_1, VAR_5, 0);",
"finish:\nav_freep(&VAR_5);",
"avio_seek(VAR_0->pb, off + VAR_3, SEEK_SET);",
"}"
] | [
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
17
],
[
19,
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67,
69
],
[
71
],
[
73
],
[
75,
77
],
[
81,
83
],
[
85
],
[
87
]
] |
22,352 | void sth_tce(VIOsPAPRDevice *dev, uint64_t taddr, uint16_t val)
{
val = tswap16(val);
spapr_tce_dma_write(dev, taddr, &val, sizeof(val));
}
| true | qemu | ad0ebb91cd8b5fdc4a583b03645677771f420a46 | void sth_tce(VIOsPAPRDevice *dev, uint64_t taddr, uint16_t val)
{
val = tswap16(val);
spapr_tce_dma_write(dev, taddr, &val, sizeof(val));
}
| {
"code": [
" spapr_tce_dma_write(dev, taddr, &val, sizeof(val));",
"void sth_tce(VIOsPAPRDevice *dev, uint64_t taddr, uint16_t val)",
" val = tswap16(val);",
" spapr_tce_dma_write(dev, taddr, &val, sizeof(val));",
" spapr_tce_dma_write(dev, taddr, &val, sizeof(val));",
" spapr_tce_dma_write(dev, taddr, &val, sizeof(val));"
],
"line_no": [
7,
1,
5,
7,
7,
7
]
} | void FUNC_0(VIOsPAPRDevice *VAR_0, uint64_t VAR_1, uint16_t VAR_2)
{
VAR_2 = tswap16(VAR_2);
spapr_tce_dma_write(VAR_0, VAR_1, &VAR_2, sizeof(VAR_2));
}
| [
"void FUNC_0(VIOsPAPRDevice *VAR_0, uint64_t VAR_1, uint16_t VAR_2)\n{",
"VAR_2 = tswap16(VAR_2);",
"spapr_tce_dma_write(VAR_0, VAR_1, &VAR_2, sizeof(VAR_2));",
"}"
] | [
1,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
22,353 | av_cold int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4], int fullRange,
int brightness, int contrast, int saturation)
{
const int isRgb = c->dstFormat==PIX_FMT_RGB32
|| c->dstFormat==PIX_FMT_RGB32_1
|| c->dstFormat==PIX_FMT_BGR24
|| c->dstFormat==PIX_FMT_RGB565BE
|| c->dstFormat==PIX_FMT_RGB565LE
|| c->dstFormat==PIX_FMT_RGB555BE
|| c->dstFormat==PIX_FMT_RGB555LE
|| c->dstFormat==PIX_FMT_RGB444BE
|| c->dstFormat==PIX_FMT_RGB444LE
|| c->dstFormat==PIX_FMT_RGB8
|| c->dstFormat==PIX_FMT_RGB4
|| c->dstFormat==PIX_FMT_RGB4_BYTE
|| c->dstFormat==PIX_FMT_MONOBLACK;
const int isNotNe = c->dstFormat==PIX_FMT_NE(RGB565LE,RGB565BE)
|| c->dstFormat==PIX_FMT_NE(RGB555LE,RGB555BE)
|| c->dstFormat==PIX_FMT_NE(RGB444LE,RGB444BE)
|| c->dstFormat==PIX_FMT_NE(BGR565LE,BGR565BE)
|| c->dstFormat==PIX_FMT_NE(BGR555LE,BGR555BE)
|| c->dstFormat==PIX_FMT_NE(BGR444LE,BGR444BE);
const int bpp = c->dstFormatBpp;
uint8_t *y_table;
uint16_t *y_table16;
uint32_t *y_table32;
int i, base, rbase, gbase, bbase, abase, needAlpha;
const int yoffs = fullRange ? 384 : 326;
int64_t crv = inv_table[0];
int64_t cbu = inv_table[1];
int64_t cgu = -inv_table[2];
int64_t cgv = -inv_table[3];
int64_t cy = 1<<16;
int64_t oy = 0;
int64_t yb = 0;
if (!fullRange) {
cy = (cy*255) / 219;
oy = 16<<16;
} else {
crv = (crv*224) / 255;
cbu = (cbu*224) / 255;
cgu = (cgu*224) / 255;
cgv = (cgv*224) / 255;
}
cy = (cy *contrast ) >> 16;
crv = (crv*contrast * saturation) >> 32;
cbu = (cbu*contrast * saturation) >> 32;
cgu = (cgu*contrast * saturation) >> 32;
cgv = (cgv*contrast * saturation) >> 32;
oy -= 256*brightness;
c->uOffset= 0x0400040004000400LL;
c->vOffset= 0x0400040004000400LL;
c->yCoeff= roundToInt16(cy *8192) * 0x0001000100010001ULL;
c->vrCoeff= roundToInt16(crv*8192) * 0x0001000100010001ULL;
c->ubCoeff= roundToInt16(cbu*8192) * 0x0001000100010001ULL;
c->vgCoeff= roundToInt16(cgv*8192) * 0x0001000100010001ULL;
c->ugCoeff= roundToInt16(cgu*8192) * 0x0001000100010001ULL;
c->yOffset= roundToInt16(oy * 8) * 0x0001000100010001ULL;
c->yuv2rgb_y_coeff = (int16_t)roundToInt16(cy <<13);
c->yuv2rgb_y_offset = (int16_t)roundToInt16(oy << 9);
c->yuv2rgb_v2r_coeff= (int16_t)roundToInt16(crv<<13);
c->yuv2rgb_v2g_coeff= (int16_t)roundToInt16(cgv<<13);
c->yuv2rgb_u2g_coeff= (int16_t)roundToInt16(cgu<<13);
c->yuv2rgb_u2b_coeff= (int16_t)roundToInt16(cbu<<13);
//scale coefficients by cy
crv = ((crv << 16) + 0x8000) / cy;
cbu = ((cbu << 16) + 0x8000) / cy;
cgu = ((cgu << 16) + 0x8000) / cy;
cgv = ((cgv << 16) + 0x8000) / cy;
av_free(c->yuvTable);
switch (bpp) {
case 1:
c->yuvTable = av_malloc(1024);
y_table = c->yuvTable;
yb = -(384<<16) - oy;
for (i = 0; i < 1024-110; i++) {
y_table[i+110] = av_clip_uint8((yb + 0x8000) >> 16) >> 7;
yb += cy;
}
fill_table(c->table_gU, 1, cgu, y_table + yoffs);
fill_gv_table(c->table_gV, 1, cgv);
break;
case 4:
case 4|128:
rbase = isRgb ? 3 : 0;
gbase = 1;
bbase = isRgb ? 0 : 3;
c->yuvTable = av_malloc(1024*3);
y_table = c->yuvTable;
yb = -(384<<16) - oy;
for (i = 0; i < 1024-110; i++) {
int yval = av_clip_uint8((yb + 0x8000) >> 16);
y_table[i+110 ] = (yval >> 7) << rbase;
y_table[i+ 37+1024] = ((yval + 43) / 85) << gbase;
y_table[i+110+2048] = (yval >> 7) << bbase;
yb += cy;
}
fill_table(c->table_rV, 1, crv, y_table + yoffs);
fill_table(c->table_gU, 1, cgu, y_table + yoffs + 1024);
fill_table(c->table_bU, 1, cbu, y_table + yoffs + 2048);
fill_gv_table(c->table_gV, 1, cgv);
break;
case 8:
rbase = isRgb ? 5 : 0;
gbase = isRgb ? 2 : 3;
bbase = isRgb ? 0 : 6;
c->yuvTable = av_malloc(1024*3);
y_table = c->yuvTable;
yb = -(384<<16) - oy;
for (i = 0; i < 1024-38; i++) {
int yval = av_clip_uint8((yb + 0x8000) >> 16);
y_table[i+16 ] = ((yval + 18) / 36) << rbase;
y_table[i+16+1024] = ((yval + 18) / 36) << gbase;
y_table[i+37+2048] = ((yval + 43) / 85) << bbase;
yb += cy;
}
fill_table(c->table_rV, 1, crv, y_table + yoffs);
fill_table(c->table_gU, 1, cgu, y_table + yoffs + 1024);
fill_table(c->table_bU, 1, cbu, y_table + yoffs + 2048);
fill_gv_table(c->table_gV, 1, cgv);
break;
case 12:
rbase = isRgb ? 8 : 0;
gbase = 4;
bbase = isRgb ? 0 : 8;
c->yuvTable = av_malloc(1024*3*2);
y_table16 = c->yuvTable;
yb = -(384<<16) - oy;
for (i = 0; i < 1024; i++) {
uint8_t yval = av_clip_uint8((yb + 0x8000) >> 16);
y_table16[i ] = (yval >> 4) << rbase;
y_table16[i+1024] = (yval >> 4) << gbase;
y_table16[i+2048] = (yval >> 4) << bbase;
yb += cy;
}
if (isNotNe)
for (i = 0; i < 1024*3; i++)
y_table16[i] = av_bswap16(y_table16[i]);
fill_table(c->table_rV, 2, crv, y_table16 + yoffs);
fill_table(c->table_gU, 2, cgu, y_table16 + yoffs + 1024);
fill_table(c->table_bU, 2, cbu, y_table16 + yoffs + 2048);
fill_gv_table(c->table_gV, 2, cgv);
break;
case 15:
case 16:
rbase = isRgb ? bpp - 5 : 0;
gbase = 5;
bbase = isRgb ? 0 : (bpp - 5);
c->yuvTable = av_malloc(1024*3*2);
y_table16 = c->yuvTable;
yb = -(384<<16) - oy;
for (i = 0; i < 1024; i++) {
uint8_t yval = av_clip_uint8((yb + 0x8000) >> 16);
y_table16[i ] = (yval >> 3) << rbase;
y_table16[i+1024] = (yval >> (18 - bpp)) << gbase;
y_table16[i+2048] = (yval >> 3) << bbase;
yb += cy;
}
if(isNotNe)
for (i = 0; i < 1024*3; i++)
y_table16[i] = av_bswap16(y_table16[i]);
fill_table(c->table_rV, 2, crv, y_table16 + yoffs);
fill_table(c->table_gU, 2, cgu, y_table16 + yoffs + 1024);
fill_table(c->table_bU, 2, cbu, y_table16 + yoffs + 2048);
fill_gv_table(c->table_gV, 2, cgv);
break;
case 24:
case 48:
c->yuvTable = av_malloc(1024);
y_table = c->yuvTable;
yb = -(384<<16) - oy;
for (i = 0; i < 1024; i++) {
y_table[i] = av_clip_uint8((yb + 0x8000) >> 16);
yb += cy;
}
fill_table(c->table_rV, 1, crv, y_table + yoffs);
fill_table(c->table_gU, 1, cgu, y_table + yoffs);
fill_table(c->table_bU, 1, cbu, y_table + yoffs);
fill_gv_table(c->table_gV, 1, cgv);
break;
case 32:
base = (c->dstFormat == PIX_FMT_RGB32_1 || c->dstFormat == PIX_FMT_BGR32_1) ? 8 : 0;
rbase = base + (isRgb ? 16 : 0);
gbase = base + 8;
bbase = base + (isRgb ? 0 : 16);
needAlpha = CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat);
if (!needAlpha)
abase = (base + 24) & 31;
c->yuvTable = av_malloc(1024*3*4);
y_table32 = c->yuvTable;
yb = -(384<<16) - oy;
for (i = 0; i < 1024; i++) {
unsigned yval = av_clip_uint8((yb + 0x8000) >> 16);
y_table32[i ] = (yval << rbase) + (needAlpha ? 0 : (255u << abase));
y_table32[i+1024] = yval << gbase;
y_table32[i+2048] = yval << bbase;
yb += cy;
}
fill_table(c->table_rV, 4, crv, y_table32 + yoffs);
fill_table(c->table_gU, 4, cgu, y_table32 + yoffs + 1024);
fill_table(c->table_bU, 4, cbu, y_table32 + yoffs + 2048);
fill_gv_table(c->table_gV, 4, cgv);
break;
default:
c->yuvTable = NULL;
av_log(c, AV_LOG_ERROR, "%ibpp not supported by yuv2rgb\n", bpp);
return -1;
}
return 0;
}
| true | FFmpeg | 6ed000c8e6e8a5f55433b2d67e21bcba2ebc4b5d | av_cold int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4], int fullRange,
int brightness, int contrast, int saturation)
{
const int isRgb = c->dstFormat==PIX_FMT_RGB32
|| c->dstFormat==PIX_FMT_RGB32_1
|| c->dstFormat==PIX_FMT_BGR24
|| c->dstFormat==PIX_FMT_RGB565BE
|| c->dstFormat==PIX_FMT_RGB565LE
|| c->dstFormat==PIX_FMT_RGB555BE
|| c->dstFormat==PIX_FMT_RGB555LE
|| c->dstFormat==PIX_FMT_RGB444BE
|| c->dstFormat==PIX_FMT_RGB444LE
|| c->dstFormat==PIX_FMT_RGB8
|| c->dstFormat==PIX_FMT_RGB4
|| c->dstFormat==PIX_FMT_RGB4_BYTE
|| c->dstFormat==PIX_FMT_MONOBLACK;
const int isNotNe = c->dstFormat==PIX_FMT_NE(RGB565LE,RGB565BE)
|| c->dstFormat==PIX_FMT_NE(RGB555LE,RGB555BE)
|| c->dstFormat==PIX_FMT_NE(RGB444LE,RGB444BE)
|| c->dstFormat==PIX_FMT_NE(BGR565LE,BGR565BE)
|| c->dstFormat==PIX_FMT_NE(BGR555LE,BGR555BE)
|| c->dstFormat==PIX_FMT_NE(BGR444LE,BGR444BE);
const int bpp = c->dstFormatBpp;
uint8_t *y_table;
uint16_t *y_table16;
uint32_t *y_table32;
int i, base, rbase, gbase, bbase, abase, needAlpha;
const int yoffs = fullRange ? 384 : 326;
int64_t crv = inv_table[0];
int64_t cbu = inv_table[1];
int64_t cgu = -inv_table[2];
int64_t cgv = -inv_table[3];
int64_t cy = 1<<16;
int64_t oy = 0;
int64_t yb = 0;
if (!fullRange) {
cy = (cy*255) / 219;
oy = 16<<16;
} else {
crv = (crv*224) / 255;
cbu = (cbu*224) / 255;
cgu = (cgu*224) / 255;
cgv = (cgv*224) / 255;
}
cy = (cy *contrast ) >> 16;
crv = (crv*contrast * saturation) >> 32;
cbu = (cbu*contrast * saturation) >> 32;
cgu = (cgu*contrast * saturation) >> 32;
cgv = (cgv*contrast * saturation) >> 32;
oy -= 256*brightness;
c->uOffset= 0x0400040004000400LL;
c->vOffset= 0x0400040004000400LL;
c->yCoeff= roundToInt16(cy *8192) * 0x0001000100010001ULL;
c->vrCoeff= roundToInt16(crv*8192) * 0x0001000100010001ULL;
c->ubCoeff= roundToInt16(cbu*8192) * 0x0001000100010001ULL;
c->vgCoeff= roundToInt16(cgv*8192) * 0x0001000100010001ULL;
c->ugCoeff= roundToInt16(cgu*8192) * 0x0001000100010001ULL;
c->yOffset= roundToInt16(oy * 8) * 0x0001000100010001ULL;
c->yuv2rgb_y_coeff = (int16_t)roundToInt16(cy <<13);
c->yuv2rgb_y_offset = (int16_t)roundToInt16(oy << 9);
c->yuv2rgb_v2r_coeff= (int16_t)roundToInt16(crv<<13);
c->yuv2rgb_v2g_coeff= (int16_t)roundToInt16(cgv<<13);
c->yuv2rgb_u2g_coeff= (int16_t)roundToInt16(cgu<<13);
c->yuv2rgb_u2b_coeff= (int16_t)roundToInt16(cbu<<13);
crv = ((crv << 16) + 0x8000) / cy;
cbu = ((cbu << 16) + 0x8000) / cy;
cgu = ((cgu << 16) + 0x8000) / cy;
cgv = ((cgv << 16) + 0x8000) / cy;
av_free(c->yuvTable);
switch (bpp) {
case 1:
c->yuvTable = av_malloc(1024);
y_table = c->yuvTable;
yb = -(384<<16) - oy;
for (i = 0; i < 1024-110; i++) {
y_table[i+110] = av_clip_uint8((yb + 0x8000) >> 16) >> 7;
yb += cy;
}
fill_table(c->table_gU, 1, cgu, y_table + yoffs);
fill_gv_table(c->table_gV, 1, cgv);
break;
case 4:
case 4|128:
rbase = isRgb ? 3 : 0;
gbase = 1;
bbase = isRgb ? 0 : 3;
c->yuvTable = av_malloc(1024*3);
y_table = c->yuvTable;
yb = -(384<<16) - oy;
for (i = 0; i < 1024-110; i++) {
int yval = av_clip_uint8((yb + 0x8000) >> 16);
y_table[i+110 ] = (yval >> 7) << rbase;
y_table[i+ 37+1024] = ((yval + 43) / 85) << gbase;
y_table[i+110+2048] = (yval >> 7) << bbase;
yb += cy;
}
fill_table(c->table_rV, 1, crv, y_table + yoffs);
fill_table(c->table_gU, 1, cgu, y_table + yoffs + 1024);
fill_table(c->table_bU, 1, cbu, y_table + yoffs + 2048);
fill_gv_table(c->table_gV, 1, cgv);
break;
case 8:
rbase = isRgb ? 5 : 0;
gbase = isRgb ? 2 : 3;
bbase = isRgb ? 0 : 6;
c->yuvTable = av_malloc(1024*3);
y_table = c->yuvTable;
yb = -(384<<16) - oy;
for (i = 0; i < 1024-38; i++) {
int yval = av_clip_uint8((yb + 0x8000) >> 16);
y_table[i+16 ] = ((yval + 18) / 36) << rbase;
y_table[i+16+1024] = ((yval + 18) / 36) << gbase;
y_table[i+37+2048] = ((yval + 43) / 85) << bbase;
yb += cy;
}
fill_table(c->table_rV, 1, crv, y_table + yoffs);
fill_table(c->table_gU, 1, cgu, y_table + yoffs + 1024);
fill_table(c->table_bU, 1, cbu, y_table + yoffs + 2048);
fill_gv_table(c->table_gV, 1, cgv);
break;
case 12:
rbase = isRgb ? 8 : 0;
gbase = 4;
bbase = isRgb ? 0 : 8;
c->yuvTable = av_malloc(1024*3*2);
y_table16 = c->yuvTable;
yb = -(384<<16) - oy;
for (i = 0; i < 1024; i++) {
uint8_t yval = av_clip_uint8((yb + 0x8000) >> 16);
y_table16[i ] = (yval >> 4) << rbase;
y_table16[i+1024] = (yval >> 4) << gbase;
y_table16[i+2048] = (yval >> 4) << bbase;
yb += cy;
}
if (isNotNe)
for (i = 0; i < 1024*3; i++)
y_table16[i] = av_bswap16(y_table16[i]);
fill_table(c->table_rV, 2, crv, y_table16 + yoffs);
fill_table(c->table_gU, 2, cgu, y_table16 + yoffs + 1024);
fill_table(c->table_bU, 2, cbu, y_table16 + yoffs + 2048);
fill_gv_table(c->table_gV, 2, cgv);
break;
case 15:
case 16:
rbase = isRgb ? bpp - 5 : 0;
gbase = 5;
bbase = isRgb ? 0 : (bpp - 5);
c->yuvTable = av_malloc(1024*3*2);
y_table16 = c->yuvTable;
yb = -(384<<16) - oy;
for (i = 0; i < 1024; i++) {
uint8_t yval = av_clip_uint8((yb + 0x8000) >> 16);
y_table16[i ] = (yval >> 3) << rbase;
y_table16[i+1024] = (yval >> (18 - bpp)) << gbase;
y_table16[i+2048] = (yval >> 3) << bbase;
yb += cy;
}
if(isNotNe)
for (i = 0; i < 1024*3; i++)
y_table16[i] = av_bswap16(y_table16[i]);
fill_table(c->table_rV, 2, crv, y_table16 + yoffs);
fill_table(c->table_gU, 2, cgu, y_table16 + yoffs + 1024);
fill_table(c->table_bU, 2, cbu, y_table16 + yoffs + 2048);
fill_gv_table(c->table_gV, 2, cgv);
break;
case 24:
case 48:
c->yuvTable = av_malloc(1024);
y_table = c->yuvTable;
yb = -(384<<16) - oy;
for (i = 0; i < 1024; i++) {
y_table[i] = av_clip_uint8((yb + 0x8000) >> 16);
yb += cy;
}
fill_table(c->table_rV, 1, crv, y_table + yoffs);
fill_table(c->table_gU, 1, cgu, y_table + yoffs);
fill_table(c->table_bU, 1, cbu, y_table + yoffs);
fill_gv_table(c->table_gV, 1, cgv);
break;
case 32:
base = (c->dstFormat == PIX_FMT_RGB32_1 || c->dstFormat == PIX_FMT_BGR32_1) ? 8 : 0;
rbase = base + (isRgb ? 16 : 0);
gbase = base + 8;
bbase = base + (isRgb ? 0 : 16);
needAlpha = CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat);
if (!needAlpha)
abase = (base + 24) & 31;
c->yuvTable = av_malloc(1024*3*4);
y_table32 = c->yuvTable;
yb = -(384<<16) - oy;
for (i = 0; i < 1024; i++) {
unsigned yval = av_clip_uint8((yb + 0x8000) >> 16);
y_table32[i ] = (yval << rbase) + (needAlpha ? 0 : (255u << abase));
y_table32[i+1024] = yval << gbase;
y_table32[i+2048] = yval << bbase;
yb += cy;
}
fill_table(c->table_rV, 4, crv, y_table32 + yoffs);
fill_table(c->table_gU, 4, cgu, y_table32 + yoffs + 1024);
fill_table(c->table_bU, 4, cbu, y_table32 + yoffs + 2048);
fill_gv_table(c->table_gV, 4, cgv);
break;
default:
c->yuvTable = NULL;
av_log(c, AV_LOG_ERROR, "%ibpp not supported by yuv2rgb\n", bpp);
return -1;
}
return 0;
}
| {
"code": [
" int i, base, rbase, gbase, bbase, abase, needAlpha;"
],
"line_no": [
53
]
} | av_cold int FUNC_0(SwsContext *c, const int inv_table[4], int fullRange,
int brightness, int contrast, int saturation)
{
const int VAR_0 = c->dstFormat==PIX_FMT_RGB32
|| c->dstFormat==PIX_FMT_RGB32_1
|| c->dstFormat==PIX_FMT_BGR24
|| c->dstFormat==PIX_FMT_RGB565BE
|| c->dstFormat==PIX_FMT_RGB565LE
|| c->dstFormat==PIX_FMT_RGB555BE
|| c->dstFormat==PIX_FMT_RGB555LE
|| c->dstFormat==PIX_FMT_RGB444BE
|| c->dstFormat==PIX_FMT_RGB444LE
|| c->dstFormat==PIX_FMT_RGB8
|| c->dstFormat==PIX_FMT_RGB4
|| c->dstFormat==PIX_FMT_RGB4_BYTE
|| c->dstFormat==PIX_FMT_MONOBLACK;
const int VAR_1 = c->dstFormat==PIX_FMT_NE(RGB565LE,RGB565BE)
|| c->dstFormat==PIX_FMT_NE(RGB555LE,RGB555BE)
|| c->dstFormat==PIX_FMT_NE(RGB444LE,RGB444BE)
|| c->dstFormat==PIX_FMT_NE(BGR565LE,BGR565BE)
|| c->dstFormat==PIX_FMT_NE(BGR555LE,BGR555BE)
|| c->dstFormat==PIX_FMT_NE(BGR444LE,BGR444BE);
const int VAR_2 = c->dstFormatBpp;
uint8_t *y_table;
uint16_t *y_table16;
uint32_t *y_table32;
int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9;
const int VAR_10 = fullRange ? 384 : 326;
int64_t crv = inv_table[0];
int64_t cbu = inv_table[1];
int64_t cgu = -inv_table[2];
int64_t cgv = -inv_table[3];
int64_t cy = 1<<16;
int64_t oy = 0;
int64_t yb = 0;
if (!fullRange) {
cy = (cy*255) / 219;
oy = 16<<16;
} else {
crv = (crv*224) / 255;
cbu = (cbu*224) / 255;
cgu = (cgu*224) / 255;
cgv = (cgv*224) / 255;
}
cy = (cy *contrast ) >> 16;
crv = (crv*contrast * saturation) >> 32;
cbu = (cbu*contrast * saturation) >> 32;
cgu = (cgu*contrast * saturation) >> 32;
cgv = (cgv*contrast * saturation) >> 32;
oy -= 256*brightness;
c->uOffset= 0x0400040004000400LL;
c->vOffset= 0x0400040004000400LL;
c->yCoeff= roundToInt16(cy *8192) * 0x0001000100010001ULL;
c->vrCoeff= roundToInt16(crv*8192) * 0x0001000100010001ULL;
c->ubCoeff= roundToInt16(cbu*8192) * 0x0001000100010001ULL;
c->vgCoeff= roundToInt16(cgv*8192) * 0x0001000100010001ULL;
c->ugCoeff= roundToInt16(cgu*8192) * 0x0001000100010001ULL;
c->yOffset= roundToInt16(oy * 8) * 0x0001000100010001ULL;
c->yuv2rgb_y_coeff = (int16_t)roundToInt16(cy <<13);
c->yuv2rgb_y_offset = (int16_t)roundToInt16(oy << 9);
c->yuv2rgb_v2r_coeff= (int16_t)roundToInt16(crv<<13);
c->yuv2rgb_v2g_coeff= (int16_t)roundToInt16(cgv<<13);
c->yuv2rgb_u2g_coeff= (int16_t)roundToInt16(cgu<<13);
c->yuv2rgb_u2b_coeff= (int16_t)roundToInt16(cbu<<13);
crv = ((crv << 16) + 0x8000) / cy;
cbu = ((cbu << 16) + 0x8000) / cy;
cgu = ((cgu << 16) + 0x8000) / cy;
cgv = ((cgv << 16) + 0x8000) / cy;
av_free(c->yuvTable);
switch (VAR_2) {
case 1:
c->yuvTable = av_malloc(1024);
y_table = c->yuvTable;
yb = -(384<<16) - oy;
for (VAR_3 = 0; VAR_3 < 1024-110; VAR_3++) {
y_table[VAR_3+110] = av_clip_uint8((yb + 0x8000) >> 16) >> 7;
yb += cy;
}
fill_table(c->table_gU, 1, cgu, y_table + VAR_10);
fill_gv_table(c->table_gV, 1, cgv);
break;
case 4:
case 4|128:
VAR_5 = VAR_0 ? 3 : 0;
VAR_6 = 1;
VAR_7 = VAR_0 ? 0 : 3;
c->yuvTable = av_malloc(1024*3);
y_table = c->yuvTable;
yb = -(384<<16) - oy;
for (VAR_3 = 0; VAR_3 < 1024-110; VAR_3++) {
int VAR_12 = av_clip_uint8((yb + 0x8000) >> 16);
y_table[VAR_3+110 ] = (VAR_12 >> 7) << VAR_5;
y_table[VAR_3+ 37+1024] = ((VAR_12 + 43) / 85) << VAR_6;
y_table[VAR_3+110+2048] = (VAR_12 >> 7) << VAR_7;
yb += cy;
}
fill_table(c->table_rV, 1, crv, y_table + VAR_10);
fill_table(c->table_gU, 1, cgu, y_table + VAR_10 + 1024);
fill_table(c->table_bU, 1, cbu, y_table + VAR_10 + 2048);
fill_gv_table(c->table_gV, 1, cgv);
break;
case 8:
VAR_5 = VAR_0 ? 5 : 0;
VAR_6 = VAR_0 ? 2 : 3;
VAR_7 = VAR_0 ? 0 : 6;
c->yuvTable = av_malloc(1024*3);
y_table = c->yuvTable;
yb = -(384<<16) - oy;
for (VAR_3 = 0; VAR_3 < 1024-38; VAR_3++) {
int VAR_12 = av_clip_uint8((yb + 0x8000) >> 16);
y_table[VAR_3+16 ] = ((VAR_12 + 18) / 36) << VAR_5;
y_table[VAR_3+16+1024] = ((VAR_12 + 18) / 36) << VAR_6;
y_table[VAR_3+37+2048] = ((VAR_12 + 43) / 85) << VAR_7;
yb += cy;
}
fill_table(c->table_rV, 1, crv, y_table + VAR_10);
fill_table(c->table_gU, 1, cgu, y_table + VAR_10 + 1024);
fill_table(c->table_bU, 1, cbu, y_table + VAR_10 + 2048);
fill_gv_table(c->table_gV, 1, cgv);
break;
case 12:
VAR_5 = VAR_0 ? 8 : 0;
VAR_6 = 4;
VAR_7 = VAR_0 ? 0 : 8;
c->yuvTable = av_malloc(1024*3*2);
y_table16 = c->yuvTable;
yb = -(384<<16) - oy;
for (VAR_3 = 0; VAR_3 < 1024; VAR_3++) {
uint8_t VAR_12 = av_clip_uint8((yb + 0x8000) >> 16);
y_table16[VAR_3 ] = (VAR_12 >> 4) << VAR_5;
y_table16[VAR_3+1024] = (VAR_12 >> 4) << VAR_6;
y_table16[VAR_3+2048] = (VAR_12 >> 4) << VAR_7;
yb += cy;
}
if (VAR_1)
for (VAR_3 = 0; VAR_3 < 1024*3; VAR_3++)
y_table16[VAR_3] = av_bswap16(y_table16[VAR_3]);
fill_table(c->table_rV, 2, crv, y_table16 + VAR_10);
fill_table(c->table_gU, 2, cgu, y_table16 + VAR_10 + 1024);
fill_table(c->table_bU, 2, cbu, y_table16 + VAR_10 + 2048);
fill_gv_table(c->table_gV, 2, cgv);
break;
case 15:
case 16:
VAR_5 = VAR_0 ? VAR_2 - 5 : 0;
VAR_6 = 5;
VAR_7 = VAR_0 ? 0 : (VAR_2 - 5);
c->yuvTable = av_malloc(1024*3*2);
y_table16 = c->yuvTable;
yb = -(384<<16) - oy;
for (VAR_3 = 0; VAR_3 < 1024; VAR_3++) {
uint8_t VAR_12 = av_clip_uint8((yb + 0x8000) >> 16);
y_table16[VAR_3 ] = (VAR_12 >> 3) << VAR_5;
y_table16[VAR_3+1024] = (VAR_12 >> (18 - VAR_2)) << VAR_6;
y_table16[VAR_3+2048] = (VAR_12 >> 3) << VAR_7;
yb += cy;
}
if(VAR_1)
for (VAR_3 = 0; VAR_3 < 1024*3; VAR_3++)
y_table16[VAR_3] = av_bswap16(y_table16[VAR_3]);
fill_table(c->table_rV, 2, crv, y_table16 + VAR_10);
fill_table(c->table_gU, 2, cgu, y_table16 + VAR_10 + 1024);
fill_table(c->table_bU, 2, cbu, y_table16 + VAR_10 + 2048);
fill_gv_table(c->table_gV, 2, cgv);
break;
case 24:
case 48:
c->yuvTable = av_malloc(1024);
y_table = c->yuvTable;
yb = -(384<<16) - oy;
for (VAR_3 = 0; VAR_3 < 1024; VAR_3++) {
y_table[VAR_3] = av_clip_uint8((yb + 0x8000) >> 16);
yb += cy;
}
fill_table(c->table_rV, 1, crv, y_table + VAR_10);
fill_table(c->table_gU, 1, cgu, y_table + VAR_10);
fill_table(c->table_bU, 1, cbu, y_table + VAR_10);
fill_gv_table(c->table_gV, 1, cgv);
break;
case 32:
VAR_4 = (c->dstFormat == PIX_FMT_RGB32_1 || c->dstFormat == PIX_FMT_BGR32_1) ? 8 : 0;
VAR_5 = VAR_4 + (VAR_0 ? 16 : 0);
VAR_6 = VAR_4 + 8;
VAR_7 = VAR_4 + (VAR_0 ? 0 : 16);
VAR_9 = CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat);
if (!VAR_9)
VAR_8 = (VAR_4 + 24) & 31;
c->yuvTable = av_malloc(1024*3*4);
y_table32 = c->yuvTable;
yb = -(384<<16) - oy;
for (VAR_3 = 0; VAR_3 < 1024; VAR_3++) {
unsigned VAR_12 = av_clip_uint8((yb + 0x8000) >> 16);
y_table32[VAR_3 ] = (VAR_12 << VAR_5) + (VAR_9 ? 0 : (255u << VAR_8));
y_table32[VAR_3+1024] = VAR_12 << VAR_6;
y_table32[VAR_3+2048] = VAR_12 << VAR_7;
yb += cy;
}
fill_table(c->table_rV, 4, crv, y_table32 + VAR_10);
fill_table(c->table_gU, 4, cgu, y_table32 + VAR_10 + 1024);
fill_table(c->table_bU, 4, cbu, y_table32 + VAR_10 + 2048);
fill_gv_table(c->table_gV, 4, cgv);
break;
default:
c->yuvTable = NULL;
av_log(c, AV_LOG_ERROR, "%ibpp not supported by yuv2rgb\n", VAR_2);
return -1;
}
return 0;
}
| [
"av_cold int FUNC_0(SwsContext *c, const int inv_table[4], int fullRange,\nint brightness, int contrast, int saturation)\n{",
"const int VAR_0 = c->dstFormat==PIX_FMT_RGB32\n|| c->dstFormat==PIX_FMT_RGB32_1\n|| c->dstFormat==PIX_FMT_BGR24\n|| c->dstFormat==PIX_FMT_RGB565BE\n|| c->dstFormat==PIX_FMT_RGB565LE\n|| c->dstFormat==PIX_FMT_RGB555BE\n|| c->dstFormat==PIX_FMT_RGB555LE\n|| c->dstFormat==PIX_FMT_RGB444BE\n|| c->dstFormat==PIX_FMT_RGB444LE\n|| c->dstFormat==PIX_FMT_RGB8\n|| c->dstFormat==PIX_FMT_RGB4\n|| c->dstFormat==PIX_FMT_RGB4_BYTE\n|| c->dstFormat==PIX_FMT_MONOBLACK;",
"const int VAR_1 = c->dstFormat==PIX_FMT_NE(RGB565LE,RGB565BE)\n|| c->dstFormat==PIX_FMT_NE(RGB555LE,RGB555BE)\n|| c->dstFormat==PIX_FMT_NE(RGB444LE,RGB444BE)\n|| c->dstFormat==PIX_FMT_NE(BGR565LE,BGR565BE)\n|| c->dstFormat==PIX_FMT_NE(BGR555LE,BGR555BE)\n|| c->dstFormat==PIX_FMT_NE(BGR444LE,BGR444BE);",
"const int VAR_2 = c->dstFormatBpp;",
"uint8_t *y_table;",
"uint16_t *y_table16;",
"uint32_t *y_table32;",
"int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9;",
"const int VAR_10 = fullRange ? 384 : 326;",
"int64_t crv = inv_table[0];",
"int64_t cbu = inv_table[1];",
"int64_t cgu = -inv_table[2];",
"int64_t cgv = -inv_table[3];",
"int64_t cy = 1<<16;",
"int64_t oy = 0;",
"int64_t yb = 0;",
"if (!fullRange) {",
"cy = (cy*255) / 219;",
"oy = 16<<16;",
"} else {",
"crv = (crv*224) / 255;",
"cbu = (cbu*224) / 255;",
"cgu = (cgu*224) / 255;",
"cgv = (cgv*224) / 255;",
"}",
"cy = (cy *contrast ) >> 16;",
"crv = (crv*contrast * saturation) >> 32;",
"cbu = (cbu*contrast * saturation) >> 32;",
"cgu = (cgu*contrast * saturation) >> 32;",
"cgv = (cgv*contrast * saturation) >> 32;",
"oy -= 256*brightness;",
"c->uOffset= 0x0400040004000400LL;",
"c->vOffset= 0x0400040004000400LL;",
"c->yCoeff= roundToInt16(cy *8192) * 0x0001000100010001ULL;",
"c->vrCoeff= roundToInt16(crv*8192) * 0x0001000100010001ULL;",
"c->ubCoeff= roundToInt16(cbu*8192) * 0x0001000100010001ULL;",
"c->vgCoeff= roundToInt16(cgv*8192) * 0x0001000100010001ULL;",
"c->ugCoeff= roundToInt16(cgu*8192) * 0x0001000100010001ULL;",
"c->yOffset= roundToInt16(oy * 8) * 0x0001000100010001ULL;",
"c->yuv2rgb_y_coeff = (int16_t)roundToInt16(cy <<13);",
"c->yuv2rgb_y_offset = (int16_t)roundToInt16(oy << 9);",
"c->yuv2rgb_v2r_coeff= (int16_t)roundToInt16(crv<<13);",
"c->yuv2rgb_v2g_coeff= (int16_t)roundToInt16(cgv<<13);",
"c->yuv2rgb_u2g_coeff= (int16_t)roundToInt16(cgu<<13);",
"c->yuv2rgb_u2b_coeff= (int16_t)roundToInt16(cbu<<13);",
"crv = ((crv << 16) + 0x8000) / cy;",
"cbu = ((cbu << 16) + 0x8000) / cy;",
"cgu = ((cgu << 16) + 0x8000) / cy;",
"cgv = ((cgv << 16) + 0x8000) / cy;",
"av_free(c->yuvTable);",
"switch (VAR_2) {",
"case 1:\nc->yuvTable = av_malloc(1024);",
"y_table = c->yuvTable;",
"yb = -(384<<16) - oy;",
"for (VAR_3 = 0; VAR_3 < 1024-110; VAR_3++) {",
"y_table[VAR_3+110] = av_clip_uint8((yb + 0x8000) >> 16) >> 7;",
"yb += cy;",
"}",
"fill_table(c->table_gU, 1, cgu, y_table + VAR_10);",
"fill_gv_table(c->table_gV, 1, cgv);",
"break;",
"case 4:\ncase 4|128:\nVAR_5 = VAR_0 ? 3 : 0;",
"VAR_6 = 1;",
"VAR_7 = VAR_0 ? 0 : 3;",
"c->yuvTable = av_malloc(1024*3);",
"y_table = c->yuvTable;",
"yb = -(384<<16) - oy;",
"for (VAR_3 = 0; VAR_3 < 1024-110; VAR_3++) {",
"int VAR_12 = av_clip_uint8((yb + 0x8000) >> 16);",
"y_table[VAR_3+110 ] = (VAR_12 >> 7) << VAR_5;",
"y_table[VAR_3+ 37+1024] = ((VAR_12 + 43) / 85) << VAR_6;",
"y_table[VAR_3+110+2048] = (VAR_12 >> 7) << VAR_7;",
"yb += cy;",
"}",
"fill_table(c->table_rV, 1, crv, y_table + VAR_10);",
"fill_table(c->table_gU, 1, cgu, y_table + VAR_10 + 1024);",
"fill_table(c->table_bU, 1, cbu, y_table + VAR_10 + 2048);",
"fill_gv_table(c->table_gV, 1, cgv);",
"break;",
"case 8:\nVAR_5 = VAR_0 ? 5 : 0;",
"VAR_6 = VAR_0 ? 2 : 3;",
"VAR_7 = VAR_0 ? 0 : 6;",
"c->yuvTable = av_malloc(1024*3);",
"y_table = c->yuvTable;",
"yb = -(384<<16) - oy;",
"for (VAR_3 = 0; VAR_3 < 1024-38; VAR_3++) {",
"int VAR_12 = av_clip_uint8((yb + 0x8000) >> 16);",
"y_table[VAR_3+16 ] = ((VAR_12 + 18) / 36) << VAR_5;",
"y_table[VAR_3+16+1024] = ((VAR_12 + 18) / 36) << VAR_6;",
"y_table[VAR_3+37+2048] = ((VAR_12 + 43) / 85) << VAR_7;",
"yb += cy;",
"}",
"fill_table(c->table_rV, 1, crv, y_table + VAR_10);",
"fill_table(c->table_gU, 1, cgu, y_table + VAR_10 + 1024);",
"fill_table(c->table_bU, 1, cbu, y_table + VAR_10 + 2048);",
"fill_gv_table(c->table_gV, 1, cgv);",
"break;",
"case 12:\nVAR_5 = VAR_0 ? 8 : 0;",
"VAR_6 = 4;",
"VAR_7 = VAR_0 ? 0 : 8;",
"c->yuvTable = av_malloc(1024*3*2);",
"y_table16 = c->yuvTable;",
"yb = -(384<<16) - oy;",
"for (VAR_3 = 0; VAR_3 < 1024; VAR_3++) {",
"uint8_t VAR_12 = av_clip_uint8((yb + 0x8000) >> 16);",
"y_table16[VAR_3 ] = (VAR_12 >> 4) << VAR_5;",
"y_table16[VAR_3+1024] = (VAR_12 >> 4) << VAR_6;",
"y_table16[VAR_3+2048] = (VAR_12 >> 4) << VAR_7;",
"yb += cy;",
"}",
"if (VAR_1)\nfor (VAR_3 = 0; VAR_3 < 1024*3; VAR_3++)",
"y_table16[VAR_3] = av_bswap16(y_table16[VAR_3]);",
"fill_table(c->table_rV, 2, crv, y_table16 + VAR_10);",
"fill_table(c->table_gU, 2, cgu, y_table16 + VAR_10 + 1024);",
"fill_table(c->table_bU, 2, cbu, y_table16 + VAR_10 + 2048);",
"fill_gv_table(c->table_gV, 2, cgv);",
"break;",
"case 15:\ncase 16:\nVAR_5 = VAR_0 ? VAR_2 - 5 : 0;",
"VAR_6 = 5;",
"VAR_7 = VAR_0 ? 0 : (VAR_2 - 5);",
"c->yuvTable = av_malloc(1024*3*2);",
"y_table16 = c->yuvTable;",
"yb = -(384<<16) - oy;",
"for (VAR_3 = 0; VAR_3 < 1024; VAR_3++) {",
"uint8_t VAR_12 = av_clip_uint8((yb + 0x8000) >> 16);",
"y_table16[VAR_3 ] = (VAR_12 >> 3) << VAR_5;",
"y_table16[VAR_3+1024] = (VAR_12 >> (18 - VAR_2)) << VAR_6;",
"y_table16[VAR_3+2048] = (VAR_12 >> 3) << VAR_7;",
"yb += cy;",
"}",
"if(VAR_1)\nfor (VAR_3 = 0; VAR_3 < 1024*3; VAR_3++)",
"y_table16[VAR_3] = av_bswap16(y_table16[VAR_3]);",
"fill_table(c->table_rV, 2, crv, y_table16 + VAR_10);",
"fill_table(c->table_gU, 2, cgu, y_table16 + VAR_10 + 1024);",
"fill_table(c->table_bU, 2, cbu, y_table16 + VAR_10 + 2048);",
"fill_gv_table(c->table_gV, 2, cgv);",
"break;",
"case 24:\ncase 48:\nc->yuvTable = av_malloc(1024);",
"y_table = c->yuvTable;",
"yb = -(384<<16) - oy;",
"for (VAR_3 = 0; VAR_3 < 1024; VAR_3++) {",
"y_table[VAR_3] = av_clip_uint8((yb + 0x8000) >> 16);",
"yb += cy;",
"}",
"fill_table(c->table_rV, 1, crv, y_table + VAR_10);",
"fill_table(c->table_gU, 1, cgu, y_table + VAR_10);",
"fill_table(c->table_bU, 1, cbu, y_table + VAR_10);",
"fill_gv_table(c->table_gV, 1, cgv);",
"break;",
"case 32:\nVAR_4 = (c->dstFormat == PIX_FMT_RGB32_1 || c->dstFormat == PIX_FMT_BGR32_1) ? 8 : 0;",
"VAR_5 = VAR_4 + (VAR_0 ? 16 : 0);",
"VAR_6 = VAR_4 + 8;",
"VAR_7 = VAR_4 + (VAR_0 ? 0 : 16);",
"VAR_9 = CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat);",
"if (!VAR_9)\nVAR_8 = (VAR_4 + 24) & 31;",
"c->yuvTable = av_malloc(1024*3*4);",
"y_table32 = c->yuvTable;",
"yb = -(384<<16) - oy;",
"for (VAR_3 = 0; VAR_3 < 1024; VAR_3++) {",
"unsigned VAR_12 = av_clip_uint8((yb + 0x8000) >> 16);",
"y_table32[VAR_3 ] = (VAR_12 << VAR_5) + (VAR_9 ? 0 : (255u << VAR_8));",
"y_table32[VAR_3+1024] = VAR_12 << VAR_6;",
"y_table32[VAR_3+2048] = VAR_12 << VAR_7;",
"yb += cy;",
"}",
"fill_table(c->table_rV, 4, crv, y_table32 + VAR_10);",
"fill_table(c->table_gU, 4, cgu, y_table32 + VAR_10 + 1024);",
"fill_table(c->table_bU, 4, cbu, y_table32 + VAR_10 + 2048);",
"fill_gv_table(c->table_gV, 4, cgv);",
"break;",
"default:\nc->yuvTable = NULL;",
"av_log(c, AV_LOG_ERROR, \"%ibpp not supported by yuv2rgb\\n\", VAR_2);",
"return -1;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7,
9,
11,
13,
15,
17,
19,
21,
23,
25,
27,
29,
31
],
[
33,
35,
37,
39,
41,
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
145
],
[
147
],
[
149
],
[
151
],
[
155
],
[
159
],
[
161,
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183,
185,
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223,
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261,
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289,
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
305,
307,
309
],
[
311
],
[
313
],
[
315
],
[
317
],
[
319
],
[
321
],
[
323
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333
],
[
335,
337
],
[
339
],
[
341
],
[
343
],
[
345
],
[
347
],
[
349
],
[
351,
353,
355
],
[
357
],
[
359
],
[
361
],
[
363
],
[
365
],
[
367
],
[
369
],
[
371
],
[
373
],
[
375
],
[
377
],
[
379,
381
],
[
383
],
[
385
],
[
387
],
[
389
],
[
391,
393
],
[
395
],
[
397
],
[
399
],
[
401
],
[
403
],
[
405
],
[
407
],
[
409
],
[
411
],
[
413
],
[
415
],
[
417
],
[
419
],
[
421
],
[
423
],
[
425,
427
],
[
429
],
[
431
],
[
433
],
[
435
],
[
437
]
] |
22,354 | static inline int opsize_bytes(int opsize)
{
switch (opsize) {
case OS_BYTE: return 1;
case OS_WORD: return 2;
case OS_LONG: return 4;
case OS_SINGLE: return 4;
case OS_DOUBLE: return 8;
default:
qemu_assert(0, "bad operand size");
return 0;
}
}
| true | qemu | 7372c2b926200db295412efbb53f93773b7f1754 | static inline int opsize_bytes(int opsize)
{
switch (opsize) {
case OS_BYTE: return 1;
case OS_WORD: return 2;
case OS_LONG: return 4;
case OS_SINGLE: return 4;
case OS_DOUBLE: return 8;
default:
qemu_assert(0, "bad operand size");
return 0;
}
}
| {
"code": [
" qemu_assert(0, \"bad operand size\");",
" return 0;"
],
"line_no": [
19,
21
]
} | static inline int FUNC_0(int VAR_0)
{
switch (VAR_0) {
case OS_BYTE: return 1;
case OS_WORD: return 2;
case OS_LONG: return 4;
case OS_SINGLE: return 4;
case OS_DOUBLE: return 8;
default:
qemu_assert(0, "bad operand size");
return 0;
}
}
| [
"static inline int FUNC_0(int VAR_0)\n{",
"switch (VAR_0) {",
"case OS_BYTE: return 1;",
"case OS_WORD: return 2;",
"case OS_LONG: return 4;",
"case OS_SINGLE: return 4;",
"case OS_DOUBLE: return 8;",
"default:\nqemu_assert(0, \"bad operand size\");",
"return 0;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17,
19
],
[
21
],
[
23
],
[
25
]
] |
22,355 | static int config_input_ref(AVFilterLink *inlink)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
AVFilterContext *ctx = inlink->dst;
PSNRContext *s = ctx->priv;
unsigned sum;
int j;
s->nb_components = desc->nb_components;
if (ctx->inputs[0]->w != ctx->inputs[1]->w ||
ctx->inputs[0]->h != ctx->inputs[1]->h) {
av_log(ctx, AV_LOG_ERROR, "Width and height of input videos must be same.\n");
return AVERROR(EINVAL);
}
if (ctx->inputs[0]->format != ctx->inputs[1]->format) {
av_log(ctx, AV_LOG_ERROR, "Inputs must be of same pixel format.\n");
return AVERROR(EINVAL);
}
s->max[0] = (1 << (desc->comp[0].depth_minus1 + 1)) - 1;
s->max[1] = (1 << (desc->comp[1].depth_minus1 + 1)) - 1;
s->max[2] = (1 << (desc->comp[2].depth_minus1 + 1)) - 1;
s->max[3] = (1 << (desc->comp[3].depth_minus1 + 1)) - 1;
s->is_rgb = ff_fill_rgba_map(s->rgba_map, inlink->format) >= 0;
s->comps[0] = s->is_rgb ? 'r' : 'y' ;
s->comps[1] = s->is_rgb ? 'g' : 'u' ;
s->comps[2] = s->is_rgb ? 'b' : 'v' ;
s->comps[3] = 'a';
s->planeheight[1] = s->planeheight[2] = FF_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
s->planeheight[0] = s->planeheight[3] = inlink->h;
s->planewidth[1] = s->planewidth[2] = FF_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
s->planewidth[0] = s->planewidth[3] = inlink->w;
sum = 0;
for (j = 0; j < s->nb_components; j++)
sum += s->planeheight[j] * s->planewidth[j];
for (j = 0; j < s->nb_components; j++) {
s->planeweight[j] = (double) s->planeheight[j] * s->planewidth[j] / sum;
s->average_max += s->max[j] * s->planeweight[j];
}
s->compute_mse = desc->comp[0].depth_minus1 > 7 ? compute_images_mse_16bit : compute_images_mse;
return 0;
}
| true | FFmpeg | ae4c9ddebc32eaacbd62681d776881e59ca6e6f7 | static int config_input_ref(AVFilterLink *inlink)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
AVFilterContext *ctx = inlink->dst;
PSNRContext *s = ctx->priv;
unsigned sum;
int j;
s->nb_components = desc->nb_components;
if (ctx->inputs[0]->w != ctx->inputs[1]->w ||
ctx->inputs[0]->h != ctx->inputs[1]->h) {
av_log(ctx, AV_LOG_ERROR, "Width and height of input videos must be same.\n");
return AVERROR(EINVAL);
}
if (ctx->inputs[0]->format != ctx->inputs[1]->format) {
av_log(ctx, AV_LOG_ERROR, "Inputs must be of same pixel format.\n");
return AVERROR(EINVAL);
}
s->max[0] = (1 << (desc->comp[0].depth_minus1 + 1)) - 1;
s->max[1] = (1 << (desc->comp[1].depth_minus1 + 1)) - 1;
s->max[2] = (1 << (desc->comp[2].depth_minus1 + 1)) - 1;
s->max[3] = (1 << (desc->comp[3].depth_minus1 + 1)) - 1;
s->is_rgb = ff_fill_rgba_map(s->rgba_map, inlink->format) >= 0;
s->comps[0] = s->is_rgb ? 'r' : 'y' ;
s->comps[1] = s->is_rgb ? 'g' : 'u' ;
s->comps[2] = s->is_rgb ? 'b' : 'v' ;
s->comps[3] = 'a';
s->planeheight[1] = s->planeheight[2] = FF_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
s->planeheight[0] = s->planeheight[3] = inlink->h;
s->planewidth[1] = s->planewidth[2] = FF_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
s->planewidth[0] = s->planewidth[3] = inlink->w;
sum = 0;
for (j = 0; j < s->nb_components; j++)
sum += s->planeheight[j] * s->planewidth[j];
for (j = 0; j < s->nb_components; j++) {
s->planeweight[j] = (double) s->planeheight[j] * s->planewidth[j] / sum;
s->average_max += s->max[j] * s->planeweight[j];
}
s->compute_mse = desc->comp[0].depth_minus1 > 7 ? compute_images_mse_16bit : compute_images_mse;
return 0;
}
| {
"code": [
" s->compute_mse = desc->comp[0].depth_minus1 > 7 ? compute_images_mse_16bit : compute_images_mse;"
],
"line_no": [
85
]
} | static int FUNC_0(AVFilterLink *VAR_0)
{
const AVPixFmtDescriptor *VAR_1 = av_pix_fmt_desc_get(VAR_0->format);
AVFilterContext *ctx = VAR_0->dst;
PSNRContext *s = ctx->priv;
unsigned VAR_2;
int VAR_3;
s->nb_components = VAR_1->nb_components;
if (ctx->inputs[0]->w != ctx->inputs[1]->w ||
ctx->inputs[0]->h != ctx->inputs[1]->h) {
av_log(ctx, AV_LOG_ERROR, "Width and height of input videos must be same.\n");
return AVERROR(EINVAL);
}
if (ctx->inputs[0]->format != ctx->inputs[1]->format) {
av_log(ctx, AV_LOG_ERROR, "Inputs must be of same pixel format.\n");
return AVERROR(EINVAL);
}
s->max[0] = (1 << (VAR_1->comp[0].depth_minus1 + 1)) - 1;
s->max[1] = (1 << (VAR_1->comp[1].depth_minus1 + 1)) - 1;
s->max[2] = (1 << (VAR_1->comp[2].depth_minus1 + 1)) - 1;
s->max[3] = (1 << (VAR_1->comp[3].depth_minus1 + 1)) - 1;
s->is_rgb = ff_fill_rgba_map(s->rgba_map, VAR_0->format) >= 0;
s->comps[0] = s->is_rgb ? 'r' : 'y' ;
s->comps[1] = s->is_rgb ? 'g' : 'u' ;
s->comps[2] = s->is_rgb ? 'b' : 'v' ;
s->comps[3] = 'a';
s->planeheight[1] = s->planeheight[2] = FF_CEIL_RSHIFT(VAR_0->h, VAR_1->log2_chroma_h);
s->planeheight[0] = s->planeheight[3] = VAR_0->h;
s->planewidth[1] = s->planewidth[2] = FF_CEIL_RSHIFT(VAR_0->w, VAR_1->log2_chroma_w);
s->planewidth[0] = s->planewidth[3] = VAR_0->w;
VAR_2 = 0;
for (VAR_3 = 0; VAR_3 < s->nb_components; VAR_3++)
VAR_2 += s->planeheight[VAR_3] * s->planewidth[VAR_3];
for (VAR_3 = 0; VAR_3 < s->nb_components; VAR_3++) {
s->planeweight[VAR_3] = (double) s->planeheight[VAR_3] * s->planewidth[VAR_3] / VAR_2;
s->average_max += s->max[VAR_3] * s->planeweight[VAR_3];
}
s->compute_mse = VAR_1->comp[0].depth_minus1 > 7 ? compute_images_mse_16bit : compute_images_mse;
return 0;
}
| [
"static int FUNC_0(AVFilterLink *VAR_0)\n{",
"const AVPixFmtDescriptor *VAR_1 = av_pix_fmt_desc_get(VAR_0->format);",
"AVFilterContext *ctx = VAR_0->dst;",
"PSNRContext *s = ctx->priv;",
"unsigned VAR_2;",
"int VAR_3;",
"s->nb_components = VAR_1->nb_components;",
"if (ctx->inputs[0]->w != ctx->inputs[1]->w ||\nctx->inputs[0]->h != ctx->inputs[1]->h) {",
"av_log(ctx, AV_LOG_ERROR, \"Width and height of input videos must be same.\\n\");",
"return AVERROR(EINVAL);",
"}",
"if (ctx->inputs[0]->format != ctx->inputs[1]->format) {",
"av_log(ctx, AV_LOG_ERROR, \"Inputs must be of same pixel format.\\n\");",
"return AVERROR(EINVAL);",
"}",
"s->max[0] = (1 << (VAR_1->comp[0].depth_minus1 + 1)) - 1;",
"s->max[1] = (1 << (VAR_1->comp[1].depth_minus1 + 1)) - 1;",
"s->max[2] = (1 << (VAR_1->comp[2].depth_minus1 + 1)) - 1;",
"s->max[3] = (1 << (VAR_1->comp[3].depth_minus1 + 1)) - 1;",
"s->is_rgb = ff_fill_rgba_map(s->rgba_map, VAR_0->format) >= 0;",
"s->comps[0] = s->is_rgb ? 'r' : 'y' ;",
"s->comps[1] = s->is_rgb ? 'g' : 'u' ;",
"s->comps[2] = s->is_rgb ? 'b' : 'v' ;",
"s->comps[3] = 'a';",
"s->planeheight[1] = s->planeheight[2] = FF_CEIL_RSHIFT(VAR_0->h, VAR_1->log2_chroma_h);",
"s->planeheight[0] = s->planeheight[3] = VAR_0->h;",
"s->planewidth[1] = s->planewidth[2] = FF_CEIL_RSHIFT(VAR_0->w, VAR_1->log2_chroma_w);",
"s->planewidth[0] = s->planewidth[3] = VAR_0->w;",
"VAR_2 = 0;",
"for (VAR_3 = 0; VAR_3 < s->nb_components; VAR_3++)",
"VAR_2 += s->planeheight[VAR_3] * s->planewidth[VAR_3];",
"for (VAR_3 = 0; VAR_3 < s->nb_components; VAR_3++) {",
"s->planeweight[VAR_3] = (double) s->planeheight[VAR_3] * s->planewidth[VAR_3] / VAR_2;",
"s->average_max += s->max[VAR_3] * s->planeweight[VAR_3];",
"}",
"s->compute_mse = VAR_1->comp[0].depth_minus1 > 7 ? compute_images_mse_16bit : compute_images_mse;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19,
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
85
],
[
89
],
[
91
]
] |
22,356 | int dv_produce_packet(DVDemuxContext *c, AVPacket *pkt,
uint8_t* buf, int buf_size)
{
int size, i;
uint8_t *ppcm[4] = {0};
if (buf_size < DV_PROFILE_BYTES ||
!(c->sys = dv_frame_profile(buf)) ||
buf_size < c->sys->frame_size) {
return -1; /* Broken frame, or not enough data */
}
/* Queueing audio packet */
/* FIXME: in case of no audio/bad audio we have to do something */
size = dv_extract_audio_info(c, buf);
for (i = 0; i < c->ach; i++) {
c->audio_pkt[i].size = size;
c->audio_pkt[i].pts = c->abytes * 30000*8 / c->ast[i]->codec->bit_rate;
ppcm[i] = c->audio_buf[i];
}
dv_extract_audio(buf, ppcm, c->sys);
c->abytes += size;
/* We work with 720p frames split in half, thus even frames have
* channels 0,1 and odd 2,3. */
if (c->sys->height == 720) {
if (buf[1] & 0x0C)
c->audio_pkt[2].size = c->audio_pkt[3].size = 0;
else
c->audio_pkt[0].size = c->audio_pkt[1].size = 0;
}
/* Now it's time to return video packet */
size = dv_extract_video_info(c, buf);
av_init_packet(pkt);
pkt->data = buf;
pkt->size = size;
pkt->flags |= PKT_FLAG_KEY;
pkt->stream_index = c->vst->id;
pkt->pts = c->frames;
c->frames++;
return size;
}
| true | FFmpeg | d509c743b78da198af385fea362b632292cd00ad | int dv_produce_packet(DVDemuxContext *c, AVPacket *pkt,
uint8_t* buf, int buf_size)
{
int size, i;
uint8_t *ppcm[4] = {0};
if (buf_size < DV_PROFILE_BYTES ||
!(c->sys = dv_frame_profile(buf)) ||
buf_size < c->sys->frame_size) {
return -1;
}
size = dv_extract_audio_info(c, buf);
for (i = 0; i < c->ach; i++) {
c->audio_pkt[i].size = size;
c->audio_pkt[i].pts = c->abytes * 30000*8 / c->ast[i]->codec->bit_rate;
ppcm[i] = c->audio_buf[i];
}
dv_extract_audio(buf, ppcm, c->sys);
c->abytes += size;
if (c->sys->height == 720) {
if (buf[1] & 0x0C)
c->audio_pkt[2].size = c->audio_pkt[3].size = 0;
else
c->audio_pkt[0].size = c->audio_pkt[1].size = 0;
}
size = dv_extract_video_info(c, buf);
av_init_packet(pkt);
pkt->data = buf;
pkt->size = size;
pkt->flags |= PKT_FLAG_KEY;
pkt->stream_index = c->vst->id;
pkt->pts = c->frames;
c->frames++;
return size;
}
| {
"code": [
" !(c->sys = dv_frame_profile(buf)) ||"
],
"line_no": [
15
]
} | int FUNC_0(DVDemuxContext *VAR_0, AVPacket *VAR_1,
uint8_t* VAR_2, int VAR_3)
{
int VAR_4, VAR_5;
uint8_t *ppcm[4] = {0};
if (VAR_3 < DV_PROFILE_BYTES ||
!(VAR_0->sys = dv_frame_profile(VAR_2)) ||
VAR_3 < VAR_0->sys->frame_size) {
return -1;
}
VAR_4 = dv_extract_audio_info(VAR_0, VAR_2);
for (VAR_5 = 0; VAR_5 < VAR_0->ach; VAR_5++) {
VAR_0->audio_pkt[VAR_5].VAR_4 = VAR_4;
VAR_0->audio_pkt[VAR_5].pts = VAR_0->abytes * 30000*8 / VAR_0->ast[VAR_5]->codec->bit_rate;
ppcm[VAR_5] = VAR_0->audio_buf[VAR_5];
}
dv_extract_audio(VAR_2, ppcm, VAR_0->sys);
VAR_0->abytes += VAR_4;
if (VAR_0->sys->height == 720) {
if (VAR_2[1] & 0x0C)
VAR_0->audio_pkt[2].VAR_4 = VAR_0->audio_pkt[3].VAR_4 = 0;
else
VAR_0->audio_pkt[0].VAR_4 = VAR_0->audio_pkt[1].VAR_4 = 0;
}
VAR_4 = dv_extract_video_info(VAR_0, VAR_2);
av_init_packet(VAR_1);
VAR_1->data = VAR_2;
VAR_1->VAR_4 = VAR_4;
VAR_1->flags |= PKT_FLAG_KEY;
VAR_1->stream_index = VAR_0->vst->id;
VAR_1->pts = VAR_0->frames;
VAR_0->frames++;
return VAR_4;
}
| [
"int FUNC_0(DVDemuxContext *VAR_0, AVPacket *VAR_1,\nuint8_t* VAR_2, int VAR_3)\n{",
"int VAR_4, VAR_5;",
"uint8_t *ppcm[4] = {0};",
"if (VAR_3 < DV_PROFILE_BYTES ||\n!(VAR_0->sys = dv_frame_profile(VAR_2)) ||\nVAR_3 < VAR_0->sys->frame_size) {",
"return -1;",
"}",
"VAR_4 = dv_extract_audio_info(VAR_0, VAR_2);",
"for (VAR_5 = 0; VAR_5 < VAR_0->ach; VAR_5++) {",
"VAR_0->audio_pkt[VAR_5].VAR_4 = VAR_4;",
"VAR_0->audio_pkt[VAR_5].pts = VAR_0->abytes * 30000*8 / VAR_0->ast[VAR_5]->codec->bit_rate;",
"ppcm[VAR_5] = VAR_0->audio_buf[VAR_5];",
"}",
"dv_extract_audio(VAR_2, ppcm, VAR_0->sys);",
"VAR_0->abytes += VAR_4;",
"if (VAR_0->sys->height == 720) {",
"if (VAR_2[1] & 0x0C)\nVAR_0->audio_pkt[2].VAR_4 = VAR_0->audio_pkt[3].VAR_4 = 0;",
"else\nVAR_0->audio_pkt[0].VAR_4 = VAR_0->audio_pkt[1].VAR_4 = 0;",
"}",
"VAR_4 = dv_extract_video_info(VAR_0, VAR_2);",
"av_init_packet(VAR_1);",
"VAR_1->data = VAR_2;",
"VAR_1->VAR_4 = VAR_4;",
"VAR_1->flags |= PKT_FLAG_KEY;",
"VAR_1->stream_index = VAR_0->vst->id;",
"VAR_1->pts = VAR_0->frames;",
"VAR_0->frames++;",
"return VAR_4;",
"}"
] | [
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13,
15,
17
],
[
19
],
[
21
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
51
],
[
53,
55
],
[
57,
59
],
[
61
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
87
],
[
89
]
] |
22,357 | int ff_rtmp_packet_create(RTMPPacket *pkt, int channel_id, RTMPPacketType type,
int timestamp, int size)
{
pkt->data = av_malloc(size);
if (!pkt->data)
return AVERROR(ENOMEM);
pkt->data_size = size;
pkt->channel_id = channel_id;
pkt->type = type;
pkt->timestamp = timestamp;
pkt->extra = 0;
pkt->ts_delta = 0;
return 0;
| true | FFmpeg | 271c869cc3285dac2b6f2663a87c70bf3ba2b04f | int ff_rtmp_packet_create(RTMPPacket *pkt, int channel_id, RTMPPacketType type,
int timestamp, int size)
{
pkt->data = av_malloc(size);
if (!pkt->data)
return AVERROR(ENOMEM);
pkt->data_size = size;
pkt->channel_id = channel_id;
pkt->type = type;
pkt->timestamp = timestamp;
pkt->extra = 0;
pkt->ts_delta = 0;
return 0;
| {
"code": [],
"line_no": []
} | int FUNC_0(RTMPPacket *VAR_0, int VAR_1, RTMPPacketType VAR_2,
int VAR_3, int VAR_4)
{
VAR_0->data = av_malloc(VAR_4);
if (!VAR_0->data)
return AVERROR(ENOMEM);
VAR_0->data_size = VAR_4;
VAR_0->VAR_1 = VAR_1;
VAR_0->VAR_2 = VAR_2;
VAR_0->VAR_3 = VAR_3;
VAR_0->extra = 0;
VAR_0->ts_delta = 0;
return 0;
| [
"int FUNC_0(RTMPPacket *VAR_0, int VAR_1, RTMPPacketType VAR_2,\nint VAR_3, int VAR_4)\n{",
"VAR_0->data = av_malloc(VAR_4);",
"if (!VAR_0->data)\nreturn AVERROR(ENOMEM);",
"VAR_0->data_size = VAR_4;",
"VAR_0->VAR_1 = VAR_1;",
"VAR_0->VAR_2 = VAR_2;",
"VAR_0->VAR_3 = VAR_3;",
"VAR_0->extra = 0;",
"VAR_0->ts_delta = 0;",
"return 0;"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
8
],
[
10,
12
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
]
] |
22,358 | static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
AC3DecodeContext *s = avctx->priv_data;
int16_t *out_samples = (int16_t *)data;
int blk, ch, err;
const uint8_t *channel_map;
const float *output[AC3_MAX_CHANNELS];
/* initialize the GetBitContext with the start of valid AC-3 Frame */
if (s->input_buffer) {
/* copy input buffer to decoder context to avoid reading past the end
of the buffer, which can be caused by a damaged input stream. */
memcpy(s->input_buffer, buf, FFMIN(buf_size, AC3_FRAME_BUFFER_SIZE));
init_get_bits(&s->gbc, s->input_buffer, buf_size * 8);
} else {
init_get_bits(&s->gbc, buf, buf_size * 8);
}
/* parse the syncinfo */
*data_size = 0;
err = parse_frame_header(s);
/* 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;
}
/* check for crc mismatch */
if(err != AAC_AC3_PARSE_ERROR_FRAME_SIZE && avctx->error_recognition >= FF_ER_CAREFUL) {
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(err && err != AAC_AC3_PARSE_ERROR_CRC) {
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");
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;
}
}
/* 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 = ff_ac3_channel_layout_tab[s->output_mode];
}
avctx->channels = s->out_channels;
avctx->channel_layout = s->channel_layout;
/* 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;
}
/* decode the audio blocks */
channel_map = ff_ac3_dec_channel_map[s->output_mode & ~AC3_OUTPUT_LFEON][s->lfe_on];
for (ch = 0; ch < s->out_channels; ch++)
output[ch] = s->output[channel_map[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;
}
s->dsp.float_to_int16_interleave(out_samples, output, 256, s->out_channels);
out_samples += 256 * s->out_channels;
}
*data_size = s->num_blocks * 256 * avctx->channels * sizeof (int16_t);
return s->frame_size;
}
| false | FFmpeg | 008f872f614e6646c5b1fc8888e40bea4796eb5f | static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
AC3DecodeContext *s = avctx->priv_data;
int16_t *out_samples = (int16_t *)data;
int blk, ch, err;
const uint8_t *channel_map;
const float *output[AC3_MAX_CHANNELS];
if (s->input_buffer) {
memcpy(s->input_buffer, buf, FFMIN(buf_size, AC3_FRAME_BUFFER_SIZE));
init_get_bits(&s->gbc, s->input_buffer, buf_size * 8);
} else {
init_get_bits(&s->gbc, buf, buf_size * 8);
}
*data_size = 0;
err = parse_frame_header(s);
if(s->frame_size > buf_size) {
av_log(avctx, AV_LOG_ERROR, "incomplete frame\n");
err = AAC_AC3_PARSE_ERROR_FRAME_SIZE;
}
if(err != AAC_AC3_PARSE_ERROR_FRAME_SIZE && avctx->error_recognition >= FF_ER_CAREFUL) {
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(err && err != AAC_AC3_PARSE_ERROR_CRC) {
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:
if(s->frame_type == EAC3_FRAME_TYPE_DEPENDENT || s->substreamid) {
av_log(avctx, AV_LOG_ERROR, "unsupported frame type : skipping frame\n");
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;
}
}
if (!err) {
avctx->sample_rate = s->sample_rate;
avctx->bit_rate = s->bit_rate;
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 = ff_ac3_channel_layout_tab[s->output_mode];
}
avctx->channels = s->out_channels;
avctx->channel_layout = s->channel_layout;
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;
}
channel_map = ff_ac3_dec_channel_map[s->output_mode & ~AC3_OUTPUT_LFEON][s->lfe_on];
for (ch = 0; ch < s->out_channels; ch++)
output[ch] = s->output[channel_map[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;
}
s->dsp.float_to_int16_interleave(out_samples, output, 256, s->out_channels);
out_samples += 256 * s->out_channels;
}
*data_size = s->num_blocks * 256 * avctx->channels * sizeof (int16_t);
return s->frame_size;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext * VAR_0, void *VAR_1, int *VAR_2,
AVPacket *VAR_3)
{
const uint8_t *VAR_4 = VAR_3->VAR_1;
int VAR_5 = VAR_3->size;
AC3DecodeContext *s = VAR_0->priv_data;
int16_t *out_samples = (int16_t *)VAR_1;
int VAR_6, VAR_7, VAR_8;
const uint8_t *VAR_9;
const float *VAR_10[AC3_MAX_CHANNELS];
if (s->input_buffer) {
memcpy(s->input_buffer, VAR_4, FFMIN(VAR_5, AC3_FRAME_BUFFER_SIZE));
init_get_bits(&s->gbc, s->input_buffer, VAR_5 * 8);
} else {
init_get_bits(&s->gbc, VAR_4, VAR_5 * 8);
}
*VAR_2 = 0;
VAR_8 = parse_frame_header(s);
if(s->frame_size > VAR_5) {
av_log(VAR_0, AV_LOG_ERROR, "incomplete frame\n");
VAR_8 = AAC_AC3_PARSE_ERROR_FRAME_SIZE;
}
if(VAR_8 != AAC_AC3_PARSE_ERROR_FRAME_SIZE && VAR_0->error_recognition >= FF_ER_CAREFUL) {
if(av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, &VAR_4[2], s->frame_size-2)) {
av_log(VAR_0, AV_LOG_ERROR, "frame CRC mismatch\n");
VAR_8 = AAC_AC3_PARSE_ERROR_CRC;
}
}
if(VAR_8 && VAR_8 != AAC_AC3_PARSE_ERROR_CRC) {
switch(VAR_8) {
case AAC_AC3_PARSE_ERROR_SYNC:
av_log(VAR_0, AV_LOG_ERROR, "frame sync error\n");
return -1;
case AAC_AC3_PARSE_ERROR_BSID:
av_log(VAR_0, AV_LOG_ERROR, "invalid bitstream id\n");
break;
case AAC_AC3_PARSE_ERROR_SAMPLE_RATE:
av_log(VAR_0, AV_LOG_ERROR, "invalid sample rate\n");
break;
case AAC_AC3_PARSE_ERROR_FRAME_SIZE:
av_log(VAR_0, AV_LOG_ERROR, "invalid frame size\n");
break;
case AAC_AC3_PARSE_ERROR_FRAME_TYPE:
if(s->frame_type == EAC3_FRAME_TYPE_DEPENDENT || s->substreamid) {
av_log(VAR_0, AV_LOG_ERROR, "unsupported frame type : skipping frame\n");
return s->frame_size;
} else {
av_log(VAR_0, AV_LOG_ERROR, "invalid frame type\n");
}
break;
default:
av_log(VAR_0, AV_LOG_ERROR, "invalid header\n");
break;
}
}
if (!VAR_8) {
VAR_0->sample_rate = s->sample_rate;
VAR_0->bit_rate = s->bit_rate;
s->out_channels = s->channels;
s->output_mode = s->channel_mode;
if(s->lfe_on)
s->output_mode |= AC3_OUTPUT_LFEON;
if (VAR_0->request_channels > 0 && VAR_0->request_channels <= 2 &&
VAR_0->request_channels < s->channels) {
s->out_channels = VAR_0->request_channels;
s->output_mode = VAR_0->request_channels == 1 ? AC3_CHMODE_MONO : AC3_CHMODE_STEREO;
s->channel_layout = ff_ac3_channel_layout_tab[s->output_mode];
}
VAR_0->channels = s->out_channels;
VAR_0->channel_layout = s->channel_layout;
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 = VAR_0->channels;
if(s->out_channels < s->channels)
s->output_mode = s->out_channels == 1 ? AC3_CHMODE_MONO : AC3_CHMODE_STEREO;
}
VAR_9 = ff_ac3_dec_channel_map[s->output_mode & ~AC3_OUTPUT_LFEON][s->lfe_on];
for (VAR_7 = 0; VAR_7 < s->out_channels; VAR_7++)
VAR_10[VAR_7] = s->VAR_10[VAR_9[VAR_7]];
for (VAR_6 = 0; VAR_6 < s->num_blocks; VAR_6++) {
if (!VAR_8 && decode_audio_block(s, VAR_6)) {
av_log(VAR_0, AV_LOG_ERROR, "error decoding the audio block\n");
VAR_8 = 1;
}
s->dsp.float_to_int16_interleave(out_samples, VAR_10, 256, s->out_channels);
out_samples += 256 * s->out_channels;
}
*VAR_2 = s->num_blocks * 256 * VAR_0->channels * sizeof (int16_t);
return s->frame_size;
}
| [
"static int FUNC_0(AVCodecContext * VAR_0, void *VAR_1, int *VAR_2,\nAVPacket *VAR_3)\n{",
"const uint8_t *VAR_4 = VAR_3->VAR_1;",
"int VAR_5 = VAR_3->size;",
"AC3DecodeContext *s = VAR_0->priv_data;",
"int16_t *out_samples = (int16_t *)VAR_1;",
"int VAR_6, VAR_7, VAR_8;",
"const uint8_t *VAR_9;",
"const float *VAR_10[AC3_MAX_CHANNELS];",
"if (s->input_buffer) {",
"memcpy(s->input_buffer, VAR_4, FFMIN(VAR_5, AC3_FRAME_BUFFER_SIZE));",
"init_get_bits(&s->gbc, s->input_buffer, VAR_5 * 8);",
"} else {",
"init_get_bits(&s->gbc, VAR_4, VAR_5 * 8);",
"}",
"*VAR_2 = 0;",
"VAR_8 = parse_frame_header(s);",
"if(s->frame_size > VAR_5) {",
"av_log(VAR_0, AV_LOG_ERROR, \"incomplete frame\\n\");",
"VAR_8 = AAC_AC3_PARSE_ERROR_FRAME_SIZE;",
"}",
"if(VAR_8 != AAC_AC3_PARSE_ERROR_FRAME_SIZE && VAR_0->error_recognition >= FF_ER_CAREFUL) {",
"if(av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, &VAR_4[2], s->frame_size-2)) {",
"av_log(VAR_0, AV_LOG_ERROR, \"frame CRC mismatch\\n\");",
"VAR_8 = AAC_AC3_PARSE_ERROR_CRC;",
"}",
"}",
"if(VAR_8 && VAR_8 != AAC_AC3_PARSE_ERROR_CRC) {",
"switch(VAR_8) {",
"case AAC_AC3_PARSE_ERROR_SYNC:\nav_log(VAR_0, AV_LOG_ERROR, \"frame sync error\\n\");",
"return -1;",
"case AAC_AC3_PARSE_ERROR_BSID:\nav_log(VAR_0, AV_LOG_ERROR, \"invalid bitstream id\\n\");",
"break;",
"case AAC_AC3_PARSE_ERROR_SAMPLE_RATE:\nav_log(VAR_0, AV_LOG_ERROR, \"invalid sample rate\\n\");",
"break;",
"case AAC_AC3_PARSE_ERROR_FRAME_SIZE:\nav_log(VAR_0, AV_LOG_ERROR, \"invalid frame size\\n\");",
"break;",
"case AAC_AC3_PARSE_ERROR_FRAME_TYPE:\nif(s->frame_type == EAC3_FRAME_TYPE_DEPENDENT || s->substreamid) {",
"av_log(VAR_0, AV_LOG_ERROR, \"unsupported frame type : skipping frame\\n\");",
"return s->frame_size;",
"} else {",
"av_log(VAR_0, AV_LOG_ERROR, \"invalid frame type\\n\");",
"}",
"break;",
"default:\nav_log(VAR_0, AV_LOG_ERROR, \"invalid header\\n\");",
"break;",
"}",
"}",
"if (!VAR_8) {",
"VAR_0->sample_rate = s->sample_rate;",
"VAR_0->bit_rate = s->bit_rate;",
"s->out_channels = s->channels;",
"s->output_mode = s->channel_mode;",
"if(s->lfe_on)\ns->output_mode |= AC3_OUTPUT_LFEON;",
"if (VAR_0->request_channels > 0 && VAR_0->request_channels <= 2 &&\nVAR_0->request_channels < s->channels) {",
"s->out_channels = VAR_0->request_channels;",
"s->output_mode = VAR_0->request_channels == 1 ? AC3_CHMODE_MONO : AC3_CHMODE_STEREO;",
"s->channel_layout = ff_ac3_channel_layout_tab[s->output_mode];",
"}",
"VAR_0->channels = s->out_channels;",
"VAR_0->channel_layout = s->channel_layout;",
"if(s->channels != s->out_channels && !((s->output_mode & AC3_OUTPUT_LFEON) &&\ns->fbw_channels == s->out_channels)) {",
"set_downmix_coeffs(s);",
"}",
"} else if (!s->out_channels) {",
"s->out_channels = VAR_0->channels;",
"if(s->out_channels < s->channels)\ns->output_mode = s->out_channels == 1 ? AC3_CHMODE_MONO : AC3_CHMODE_STEREO;",
"}",
"VAR_9 = ff_ac3_dec_channel_map[s->output_mode & ~AC3_OUTPUT_LFEON][s->lfe_on];",
"for (VAR_7 = 0; VAR_7 < s->out_channels; VAR_7++)",
"VAR_10[VAR_7] = s->VAR_10[VAR_9[VAR_7]];",
"for (VAR_6 = 0; VAR_6 < s->num_blocks; VAR_6++) {",
"if (!VAR_8 && decode_audio_block(s, VAR_6)) {",
"av_log(VAR_0, AV_LOG_ERROR, \"error decoding the audio block\\n\");",
"VAR_8 = 1;",
"}",
"s->dsp.float_to_int16_interleave(out_samples, VAR_10, 256, s->out_channels);",
"out_samples += 256 * s->out_channels;",
"}",
"*VAR_2 = s->num_blocks * 256 * VAR_0->channels * sizeof (int16_t);",
"return s->frame_size;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
25
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
45
],
[
47
],
[
53
],
[
55
],
[
57
],
[
59
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83,
85
],
[
87
],
[
89,
91
],
[
93
],
[
95,
97
],
[
99
],
[
101,
103
],
[
105
],
[
107,
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127,
129
],
[
131
],
[
133
],
[
135
],
[
141
],
[
143
],
[
145
],
[
151
],
[
153
],
[
155,
157
],
[
159,
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
179,
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191,
193
],
[
195
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
]
] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.