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
|
---|---|---|---|---|---|---|---|---|---|---|
21,119 | static int pcm_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
uint8_t *buf, int buf_size)
{
PCMDecode *s = avctx->priv_data;
int n;
short *samples;
uint8_t *src;
samples = data;
src = buf;
switch(avctx->codec->id) {
case CODEC_ID_PCM_S16LE:
n = buf_size >> 1;
for(;n>0;n--) {
*samples++ = src[0] | (src[1] << 8);
src += 2;
}
break;
case CODEC_ID_PCM_S16BE:
n = buf_size >> 1;
for(;n>0;n--) {
*samples++ = (src[0] << 8) | src[1];
src += 2;
}
break;
case CODEC_ID_PCM_U16LE:
n = buf_size >> 1;
for(;n>0;n--) {
*samples++ = (src[0] | (src[1] << 8)) - 0x8000;
src += 2;
}
break;
case CODEC_ID_PCM_U16BE:
n = buf_size >> 1;
for(;n>0;n--) {
*samples++ = ((src[0] << 8) | src[1]) - 0x8000;
src += 2;
}
break;
case CODEC_ID_PCM_S8:
n = buf_size;
for(;n>0;n--) {
*samples++ = src[0] << 8;
src++;
}
break;
case CODEC_ID_PCM_U8:
n = buf_size;
for(;n>0;n--) {
*samples++ = ((int)src[0] - 128) << 8;
src++;
}
break;
case CODEC_ID_PCM_ALAW:
case CODEC_ID_PCM_MULAW:
n = buf_size;
for(;n>0;n--) {
*samples++ = s->table[src[0]];
src++;
}
break;
default:
return -1;
}
*data_size = (uint8_t *)samples - (uint8_t *)data;
return src - buf;
} | true | FFmpeg | a8d02f2bc90e8d963f1a95f7a75de520259bb2d2 | static int pcm_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
uint8_t *buf, int buf_size)
{
PCMDecode *s = avctx->priv_data;
int n;
short *samples;
uint8_t *src;
samples = data;
src = buf;
switch(avctx->codec->id) {
case CODEC_ID_PCM_S16LE:
n = buf_size >> 1;
for(;n>0;n--) {
*samples++ = src[0] | (src[1] << 8);
src += 2;
}
break;
case CODEC_ID_PCM_S16BE:
n = buf_size >> 1;
for(;n>0;n--) {
*samples++ = (src[0] << 8) | src[1];
src += 2;
}
break;
case CODEC_ID_PCM_U16LE:
n = buf_size >> 1;
for(;n>0;n--) {
*samples++ = (src[0] | (src[1] << 8)) - 0x8000;
src += 2;
}
break;
case CODEC_ID_PCM_U16BE:
n = buf_size >> 1;
for(;n>0;n--) {
*samples++ = ((src[0] << 8) | src[1]) - 0x8000;
src += 2;
}
break;
case CODEC_ID_PCM_S8:
n = buf_size;
for(;n>0;n--) {
*samples++ = src[0] << 8;
src++;
}
break;
case CODEC_ID_PCM_U8:
n = buf_size;
for(;n>0;n--) {
*samples++ = ((int)src[0] - 128) << 8;
src++;
}
break;
case CODEC_ID_PCM_ALAW:
case CODEC_ID_PCM_MULAW:
n = buf_size;
for(;n>0;n--) {
*samples++ = s->table[src[0]];
src++;
}
break;
default:
return -1;
}
*data_size = (uint8_t *)samples - (uint8_t *)data;
return src - buf;
} | {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0,
void *VAR_1, int *VAR_2,
uint8_t *VAR_3, int VAR_4)
{
PCMDecode *s = VAR_0->priv_data;
int VAR_5;
short *VAR_6;
uint8_t *src;
VAR_6 = VAR_1;
src = VAR_3;
switch(VAR_0->codec->id) {
case CODEC_ID_PCM_S16LE:
VAR_5 = VAR_4 >> 1;
for(;VAR_5>0;VAR_5--) {
*VAR_6++ = src[0] | (src[1] << 8);
src += 2;
}
break;
case CODEC_ID_PCM_S16BE:
VAR_5 = VAR_4 >> 1;
for(;VAR_5>0;VAR_5--) {
*VAR_6++ = (src[0] << 8) | src[1];
src += 2;
}
break;
case CODEC_ID_PCM_U16LE:
VAR_5 = VAR_4 >> 1;
for(;VAR_5>0;VAR_5--) {
*VAR_6++ = (src[0] | (src[1] << 8)) - 0x8000;
src += 2;
}
break;
case CODEC_ID_PCM_U16BE:
VAR_5 = VAR_4 >> 1;
for(;VAR_5>0;VAR_5--) {
*VAR_6++ = ((src[0] << 8) | src[1]) - 0x8000;
src += 2;
}
break;
case CODEC_ID_PCM_S8:
VAR_5 = VAR_4;
for(;VAR_5>0;VAR_5--) {
*VAR_6++ = src[0] << 8;
src++;
}
break;
case CODEC_ID_PCM_U8:
VAR_5 = VAR_4;
for(;VAR_5>0;VAR_5--) {
*VAR_6++ = ((int)src[0] - 128) << 8;
src++;
}
break;
case CODEC_ID_PCM_ALAW:
case CODEC_ID_PCM_MULAW:
VAR_5 = VAR_4;
for(;VAR_5>0;VAR_5--) {
*VAR_6++ = s->table[src[0]];
src++;
}
break;
default:
return -1;
}
*VAR_2 = (uint8_t *)VAR_6 - (uint8_t *)VAR_1;
return src - VAR_3;
} | [
"static int FUNC_0(AVCodecContext *VAR_0,\nvoid *VAR_1, int *VAR_2,\nuint8_t *VAR_3, int VAR_4)\n{",
"PCMDecode *s = VAR_0->priv_data;",
"int VAR_5;",
"short *VAR_6;",
"uint8_t *src;",
"VAR_6 = VAR_1;",
"src = VAR_3;",
"switch(VAR_0->codec->id) {",
"case CODEC_ID_PCM_S16LE:\nVAR_5 = VAR_4 >> 1;",
"for(;VAR_5>0;VAR_5--) {",
"*VAR_6++ = src[0] | (src[1] << 8);",
"src += 2;",
"}",
"break;",
"case CODEC_ID_PCM_S16BE:\nVAR_5 = VAR_4 >> 1;",
"for(;VAR_5>0;VAR_5--) {",
"*VAR_6++ = (src[0] << 8) | src[1];",
"src += 2;",
"}",
"break;",
"case CODEC_ID_PCM_U16LE:\nVAR_5 = VAR_4 >> 1;",
"for(;VAR_5>0;VAR_5--) {",
"*VAR_6++ = (src[0] | (src[1] << 8)) - 0x8000;",
"src += 2;",
"}",
"break;",
"case CODEC_ID_PCM_U16BE:\nVAR_5 = VAR_4 >> 1;",
"for(;VAR_5>0;VAR_5--) {",
"*VAR_6++ = ((src[0] << 8) | src[1]) - 0x8000;",
"src += 2;",
"}",
"break;",
"case CODEC_ID_PCM_S8:\nVAR_5 = VAR_4;",
"for(;VAR_5>0;VAR_5--) {",
"*VAR_6++ = src[0] << 8;",
"src++;",
"}",
"break;",
"case CODEC_ID_PCM_U8:\nVAR_5 = VAR_4;",
"for(;VAR_5>0;VAR_5--) {",
"*VAR_6++ = ((int)src[0] - 128) << 8;",
"src++;",
"}",
"break;",
"case CODEC_ID_PCM_ALAW:\ncase CODEC_ID_PCM_MULAW:\nVAR_5 = VAR_4;",
"for(;VAR_5>0;VAR_5--) {",
"*VAR_6++ = s->table[src[0]];",
"src++;",
"}",
"break;",
"default:\nreturn -1;",
"}",
"*VAR_2 = (uint8_t *)VAR_6 - (uint8_t *)VAR_1;",
"return src - 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,
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
],
[
39
],
[
40,
41
],
[
42
],
[
43
],
[
44
],
[
45
],
[
46
],
[
47,
48
],
[
49
],
[
50
],
[
51
],
[
52
],
[
53
],
[
54,
55,
56
],
[
57
],
[
58
],
[
59
],
[
60
],
[
61
],
[
62,
63
],
[
64
],
[
65
],
[
66
],
[
67
]
] |
21,120 | void FUNCC(ff_h264_idct8_dc_add)(uint8_t *_dst, int16_t *block, int stride){
int i, j;
int dc = (((dctcoef*)block)[0] + 32) >> 6;
pixel *dst = (pixel*)_dst;
stride >>= sizeof(pixel)-1;
for( j = 0; j < 8; j++ )
{
for( i = 0; i < 8; i++ )
dst[i] = av_clip_pixel( dst[i] + dc );
dst += stride;
}
}
| false | FFmpeg | 1acd7d594c15aa491729c837ad3519d3469e620a | void FUNCC(ff_h264_idct8_dc_add)(uint8_t *_dst, int16_t *block, int stride){
int i, j;
int dc = (((dctcoef*)block)[0] + 32) >> 6;
pixel *dst = (pixel*)_dst;
stride >>= sizeof(pixel)-1;
for( j = 0; j < 8; j++ )
{
for( i = 0; i < 8; i++ )
dst[i] = av_clip_pixel( dst[i] + dc );
dst += stride;
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(ff_h264_idct8_dc_add)(uint8_t *_dst, int16_t *block, int stride){
int VAR_0, VAR_1;
int VAR_2 = (((dctcoef*)block)[0] + 32) >> 6;
pixel *dst = (pixel*)_dst;
stride >>= sizeof(pixel)-1;
for( VAR_1 = 0; VAR_1 < 8; VAR_1++ )
{
for( VAR_0 = 0; VAR_0 < 8; VAR_0++ )
dst[VAR_0] = av_clip_pixel( dst[VAR_0] + VAR_2 );
dst += stride;
}
}
| [
"void FUNC_0(ff_h264_idct8_dc_add)(uint8_t *_dst, int16_t *block, int stride){",
"int VAR_0, VAR_1;",
"int VAR_2 = (((dctcoef*)block)[0] + 32) >> 6;",
"pixel *dst = (pixel*)_dst;",
"stride >>= sizeof(pixel)-1;",
"for( VAR_1 = 0; VAR_1 < 8; VAR_1++ )",
"{",
"for( VAR_0 = 0; VAR_0 < 8; VAR_0++ )",
"dst[VAR_0] = av_clip_pixel( dst[VAR_0] + VAR_2 );",
"dst += stride;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1
],
[
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
]
] |
21,121 | static int colo_packet_compare_other(Packet *spkt, Packet *ppkt)
{
trace_colo_compare_main("compare other");
if (trace_event_get_state(TRACE_COLO_COMPARE_MISCOMPARE)) {
char pri_ip_src[20], pri_ip_dst[20], sec_ip_src[20], sec_ip_dst[20];
strcpy(pri_ip_src, inet_ntoa(ppkt->ip->ip_src));
strcpy(pri_ip_dst, inet_ntoa(ppkt->ip->ip_dst));
strcpy(sec_ip_src, inet_ntoa(spkt->ip->ip_src));
strcpy(sec_ip_dst, inet_ntoa(spkt->ip->ip_dst));
trace_colo_compare_ip_info(ppkt->size, pri_ip_src,
pri_ip_dst, spkt->size,
sec_ip_src, sec_ip_dst);
}
return colo_packet_compare_common(ppkt, spkt, 0);
}
| true | qemu | d87aa138039a4be6d705793fd3e397c69c52405a | static int colo_packet_compare_other(Packet *spkt, Packet *ppkt)
{
trace_colo_compare_main("compare other");
if (trace_event_get_state(TRACE_COLO_COMPARE_MISCOMPARE)) {
char pri_ip_src[20], pri_ip_dst[20], sec_ip_src[20], sec_ip_dst[20];
strcpy(pri_ip_src, inet_ntoa(ppkt->ip->ip_src));
strcpy(pri_ip_dst, inet_ntoa(ppkt->ip->ip_dst));
strcpy(sec_ip_src, inet_ntoa(spkt->ip->ip_src));
strcpy(sec_ip_dst, inet_ntoa(spkt->ip->ip_dst));
trace_colo_compare_ip_info(ppkt->size, pri_ip_src,
pri_ip_dst, spkt->size,
sec_ip_src, sec_ip_dst);
}
return colo_packet_compare_common(ppkt, spkt, 0);
}
| {
"code": [
" if (trace_event_get_state(TRACE_COLO_COMPARE_MISCOMPARE)) {",
" if (trace_event_get_state(TRACE_COLO_COMPARE_MISCOMPARE)) {"
],
"line_no": [
7,
7
]
} | static int FUNC_0(Packet *VAR_0, Packet *VAR_1)
{
trace_colo_compare_main("compare other");
if (trace_event_get_state(TRACE_COLO_COMPARE_MISCOMPARE)) {
char VAR_2[20], VAR_3[20], VAR_4[20], VAR_5[20];
strcpy(VAR_2, inet_ntoa(VAR_1->ip->ip_src));
strcpy(VAR_3, inet_ntoa(VAR_1->ip->ip_dst));
strcpy(VAR_4, inet_ntoa(VAR_0->ip->ip_src));
strcpy(VAR_5, inet_ntoa(VAR_0->ip->ip_dst));
trace_colo_compare_ip_info(VAR_1->size, VAR_2,
VAR_3, VAR_0->size,
VAR_4, VAR_5);
}
return colo_packet_compare_common(VAR_1, VAR_0, 0);
}
| [
"static int FUNC_0(Packet *VAR_0, Packet *VAR_1)\n{",
"trace_colo_compare_main(\"compare other\");",
"if (trace_event_get_state(TRACE_COLO_COMPARE_MISCOMPARE)) {",
"char VAR_2[20], VAR_3[20], VAR_4[20], VAR_5[20];",
"strcpy(VAR_2, inet_ntoa(VAR_1->ip->ip_src));",
"strcpy(VAR_3, inet_ntoa(VAR_1->ip->ip_dst));",
"strcpy(VAR_4, inet_ntoa(VAR_0->ip->ip_src));",
"strcpy(VAR_5, inet_ntoa(VAR_0->ip->ip_dst));",
"trace_colo_compare_ip_info(VAR_1->size, VAR_2,\nVAR_3, VAR_0->size,\nVAR_4, VAR_5);",
"}",
"return colo_packet_compare_common(VAR_1, VAR_0, 0);",
"}"
] | [
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23,
25,
27
],
[
29
],
[
33
],
[
35
]
] |
21,122 | void *block_job_create(const BlockJobDriver *driver, BlockDriverState *bs,
int64_t speed, BlockCompletionFunc *cb,
void *opaque, Error **errp)
{
BlockBackend *blk;
BlockJob *job;
assert(cb);
if (bs->job) {
error_setg(errp, QERR_DEVICE_IN_USE, bdrv_get_device_name(bs));
return NULL;
}
blk = blk_new();
blk_insert_bs(blk, bs);
job = g_malloc0(driver->instance_size);
error_setg(&job->blocker, "block device is in use by block job: %s",
BlockJobType_lookup[driver->job_type]);
bdrv_op_block_all(bs, job->blocker);
bdrv_op_unblock(bs, BLOCK_OP_TYPE_DATAPLANE, job->blocker);
job->driver = driver;
job->id = g_strdup(bdrv_get_device_name(bs));
job->blk = blk;
job->cb = cb;
job->opaque = opaque;
job->busy = true;
job->refcnt = 1;
bs->job = job;
QLIST_INSERT_HEAD(&block_jobs, job, job_list);
blk_add_aio_context_notifier(blk, block_job_attached_aio_context,
block_job_detach_aio_context, job);
/* Only set speed when necessary to avoid NotSupported error */
if (speed != 0) {
Error *local_err = NULL;
block_job_set_speed(job, speed, &local_err);
if (local_err) {
block_job_unref(job);
error_propagate(errp, local_err);
return NULL;
}
}
return job;
}
| true | qemu | 7f0317cfc8da620cdb38cb5cfec5f82b8dd05403 | void *block_job_create(const BlockJobDriver *driver, BlockDriverState *bs,
int64_t speed, BlockCompletionFunc *cb,
void *opaque, Error **errp)
{
BlockBackend *blk;
BlockJob *job;
assert(cb);
if (bs->job) {
error_setg(errp, QERR_DEVICE_IN_USE, bdrv_get_device_name(bs));
return NULL;
}
blk = blk_new();
blk_insert_bs(blk, bs);
job = g_malloc0(driver->instance_size);
error_setg(&job->blocker, "block device is in use by block job: %s",
BlockJobType_lookup[driver->job_type]);
bdrv_op_block_all(bs, job->blocker);
bdrv_op_unblock(bs, BLOCK_OP_TYPE_DATAPLANE, job->blocker);
job->driver = driver;
job->id = g_strdup(bdrv_get_device_name(bs));
job->blk = blk;
job->cb = cb;
job->opaque = opaque;
job->busy = true;
job->refcnt = 1;
bs->job = job;
QLIST_INSERT_HEAD(&block_jobs, job, job_list);
blk_add_aio_context_notifier(blk, block_job_attached_aio_context,
block_job_detach_aio_context, job);
if (speed != 0) {
Error *local_err = NULL;
block_job_set_speed(job, speed, &local_err);
if (local_err) {
block_job_unref(job);
error_propagate(errp, local_err);
return NULL;
}
}
return job;
}
| {
"code": [
"void *block_job_create(const BlockJobDriver *driver, BlockDriverState *bs,",
" int64_t speed, BlockCompletionFunc *cb,",
" void *opaque, Error **errp)",
" job->id = g_strdup(bdrv_get_device_name(bs));",
"void *block_job_create(const BlockJobDriver *driver, BlockDriverState *bs,",
" int64_t speed, BlockCompletionFunc *cb,"
],
"line_no": [
1,
3,
5,
47,
1,
3
]
} | void *FUNC_0(const BlockJobDriver *VAR_0, BlockDriverState *VAR_1,
int64_t VAR_2, BlockCompletionFunc *VAR_3,
void *VAR_4, Error **VAR_5)
{
BlockBackend *blk;
BlockJob *job;
assert(VAR_3);
if (VAR_1->job) {
error_setg(VAR_5, QERR_DEVICE_IN_USE, bdrv_get_device_name(VAR_1));
return NULL;
}
blk = blk_new();
blk_insert_bs(blk, VAR_1);
job = g_malloc0(VAR_0->instance_size);
error_setg(&job->blocker, "block device is in use by block job: %s",
BlockJobType_lookup[VAR_0->job_type]);
bdrv_op_block_all(VAR_1, job->blocker);
bdrv_op_unblock(VAR_1, BLOCK_OP_TYPE_DATAPLANE, job->blocker);
job->VAR_0 = VAR_0;
job->id = g_strdup(bdrv_get_device_name(VAR_1));
job->blk = blk;
job->VAR_3 = VAR_3;
job->VAR_4 = VAR_4;
job->busy = true;
job->refcnt = 1;
VAR_1->job = job;
QLIST_INSERT_HEAD(&block_jobs, job, job_list);
blk_add_aio_context_notifier(blk, block_job_attached_aio_context,
block_job_detach_aio_context, job);
if (VAR_2 != 0) {
Error *local_err = NULL;
block_job_set_speed(job, VAR_2, &local_err);
if (local_err) {
block_job_unref(job);
error_propagate(VAR_5, local_err);
return NULL;
}
}
return job;
}
| [
"void *FUNC_0(const BlockJobDriver *VAR_0, BlockDriverState *VAR_1,\nint64_t VAR_2, BlockCompletionFunc *VAR_3,\nvoid *VAR_4, Error **VAR_5)\n{",
"BlockBackend *blk;",
"BlockJob *job;",
"assert(VAR_3);",
"if (VAR_1->job) {",
"error_setg(VAR_5, QERR_DEVICE_IN_USE, bdrv_get_device_name(VAR_1));",
"return NULL;",
"}",
"blk = blk_new();",
"blk_insert_bs(blk, VAR_1);",
"job = g_malloc0(VAR_0->instance_size);",
"error_setg(&job->blocker, \"block device is in use by block job: %s\",\nBlockJobType_lookup[VAR_0->job_type]);",
"bdrv_op_block_all(VAR_1, job->blocker);",
"bdrv_op_unblock(VAR_1, BLOCK_OP_TYPE_DATAPLANE, job->blocker);",
"job->VAR_0 = VAR_0;",
"job->id = g_strdup(bdrv_get_device_name(VAR_1));",
"job->blk = blk;",
"job->VAR_3 = VAR_3;",
"job->VAR_4 = VAR_4;",
"job->busy = true;",
"job->refcnt = 1;",
"VAR_1->job = job;",
"QLIST_INSERT_HEAD(&block_jobs, job, job_list);",
"blk_add_aio_context_notifier(blk, block_job_attached_aio_context,\nblock_job_detach_aio_context, job);",
"if (VAR_2 != 0) {",
"Error *local_err = NULL;",
"block_job_set_speed(job, VAR_2, &local_err);",
"if (local_err) {",
"block_job_unref(job);",
"error_propagate(VAR_5, local_err);",
"return NULL;",
"}",
"}",
"return job;",
"}"
] | [
1,
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
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
33
],
[
35,
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
67,
69
],
[
75
],
[
77
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
]
] |
21,123 | static int pxa2xx_ssp_load(QEMUFile *f, void *opaque, int version_id)
{
PXA2xxSSPState *s = (PXA2xxSSPState *) opaque;
int i;
s->enable = qemu_get_be32(f);
qemu_get_be32s(f, &s->sscr[0]);
qemu_get_be32s(f, &s->sscr[1]);
qemu_get_be32s(f, &s->sspsp);
qemu_get_be32s(f, &s->ssto);
qemu_get_be32s(f, &s->ssitr);
qemu_get_be32s(f, &s->sssr);
qemu_get_8s(f, &s->sstsa);
qemu_get_8s(f, &s->ssrsa);
qemu_get_8s(f, &s->ssacd);
s->rx_level = qemu_get_byte(f);
s->rx_start = 0;
for (i = 0; i < s->rx_level; i ++)
s->rx_fifo[i] = qemu_get_byte(f);
return 0;
}
| true | qemu | caa881abe0e01f9931125a0977ec33c5343e4aa7 | static int pxa2xx_ssp_load(QEMUFile *f, void *opaque, int version_id)
{
PXA2xxSSPState *s = (PXA2xxSSPState *) opaque;
int i;
s->enable = qemu_get_be32(f);
qemu_get_be32s(f, &s->sscr[0]);
qemu_get_be32s(f, &s->sscr[1]);
qemu_get_be32s(f, &s->sspsp);
qemu_get_be32s(f, &s->ssto);
qemu_get_be32s(f, &s->ssitr);
qemu_get_be32s(f, &s->sssr);
qemu_get_8s(f, &s->sstsa);
qemu_get_8s(f, &s->ssrsa);
qemu_get_8s(f, &s->ssacd);
s->rx_level = qemu_get_byte(f);
s->rx_start = 0;
for (i = 0; i < s->rx_level; i ++)
s->rx_fifo[i] = qemu_get_byte(f);
return 0;
}
| {
"code": [
" int i;",
" s->rx_level = qemu_get_byte(f);"
],
"line_no": [
7,
35
]
} | static int FUNC_0(QEMUFile *VAR_0, void *VAR_1, int VAR_2)
{
PXA2xxSSPState *s = (PXA2xxSSPState *) VAR_1;
int VAR_3;
s->enable = qemu_get_be32(VAR_0);
qemu_get_be32s(VAR_0, &s->sscr[0]);
qemu_get_be32s(VAR_0, &s->sscr[1]);
qemu_get_be32s(VAR_0, &s->sspsp);
qemu_get_be32s(VAR_0, &s->ssto);
qemu_get_be32s(VAR_0, &s->ssitr);
qemu_get_be32s(VAR_0, &s->sssr);
qemu_get_8s(VAR_0, &s->sstsa);
qemu_get_8s(VAR_0, &s->ssrsa);
qemu_get_8s(VAR_0, &s->ssacd);
s->rx_level = qemu_get_byte(VAR_0);
s->rx_start = 0;
for (VAR_3 = 0; VAR_3 < s->rx_level; VAR_3 ++)
s->rx_fifo[VAR_3] = qemu_get_byte(VAR_0);
return 0;
}
| [
"static int FUNC_0(QEMUFile *VAR_0, void *VAR_1, int VAR_2)\n{",
"PXA2xxSSPState *s = (PXA2xxSSPState *) VAR_1;",
"int VAR_3;",
"s->enable = qemu_get_be32(VAR_0);",
"qemu_get_be32s(VAR_0, &s->sscr[0]);",
"qemu_get_be32s(VAR_0, &s->sscr[1]);",
"qemu_get_be32s(VAR_0, &s->sspsp);",
"qemu_get_be32s(VAR_0, &s->ssto);",
"qemu_get_be32s(VAR_0, &s->ssitr);",
"qemu_get_be32s(VAR_0, &s->sssr);",
"qemu_get_8s(VAR_0, &s->sstsa);",
"qemu_get_8s(VAR_0, &s->ssrsa);",
"qemu_get_8s(VAR_0, &s->ssacd);",
"s->rx_level = qemu_get_byte(VAR_0);",
"s->rx_start = 0;",
"for (VAR_3 = 0; VAR_3 < s->rx_level; VAR_3 ++)",
"s->rx_fifo[VAR_3] = qemu_get_byte(VAR_0);",
"return 0;",
"}"
] | [
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
]
] |
21,125 | static void truncpasses(Jpeg2000EncoderContext *s, Jpeg2000Tile *tile)
{
int precno, compno, reslevelno, bandno, cblkno, lev;
Jpeg2000CodingStyle *codsty = &s->codsty;
for (compno = 0; compno < s->ncomponents; compno++){
Jpeg2000Component *comp = tile->comp + compno;
for (reslevelno = 0, lev = codsty->nreslevels-1; reslevelno < codsty->nreslevels; reslevelno++, lev--){
Jpeg2000ResLevel *reslevel = comp->reslevel + reslevelno;
for (precno = 0; precno < reslevel->num_precincts_x * reslevel->num_precincts_y; precno++){
for (bandno = 0; bandno < reslevel->nbands ; bandno++){
int bandpos = bandno + (reslevelno > 0);
Jpeg2000Band *band = reslevel->band + bandno;
Jpeg2000Prec *prec = band->prec + precno;
for (cblkno = 0; cblkno < prec->nb_codeblocks_height * prec->nb_codeblocks_width; cblkno++){
Jpeg2000Cblk *cblk = prec->cblk + cblkno;
cblk->ninclpasses = getcut(cblk, s->lambda,
(int64_t)dwt_norms[codsty->transform == FF_DWT53][bandpos][lev] * (int64_t)band->i_stepsize >> 16);
}
}
}
}
}
}
| true | FFmpeg | f57119b8e58cb5437c3ab40d797293ecb9b4a894 | static void truncpasses(Jpeg2000EncoderContext *s, Jpeg2000Tile *tile)
{
int precno, compno, reslevelno, bandno, cblkno, lev;
Jpeg2000CodingStyle *codsty = &s->codsty;
for (compno = 0; compno < s->ncomponents; compno++){
Jpeg2000Component *comp = tile->comp + compno;
for (reslevelno = 0, lev = codsty->nreslevels-1; reslevelno < codsty->nreslevels; reslevelno++, lev--){
Jpeg2000ResLevel *reslevel = comp->reslevel + reslevelno;
for (precno = 0; precno < reslevel->num_precincts_x * reslevel->num_precincts_y; precno++){
for (bandno = 0; bandno < reslevel->nbands ; bandno++){
int bandpos = bandno + (reslevelno > 0);
Jpeg2000Band *band = reslevel->band + bandno;
Jpeg2000Prec *prec = band->prec + precno;
for (cblkno = 0; cblkno < prec->nb_codeblocks_height * prec->nb_codeblocks_width; cblkno++){
Jpeg2000Cblk *cblk = prec->cblk + cblkno;
cblk->ninclpasses = getcut(cblk, s->lambda,
(int64_t)dwt_norms[codsty->transform == FF_DWT53][bandpos][lev] * (int64_t)band->i_stepsize >> 16);
}
}
}
}
}
}
| {
"code": [
" (int64_t)dwt_norms[codsty->transform == FF_DWT53][bandpos][lev] * (int64_t)band->i_stepsize >> 16);"
],
"line_no": [
43
]
} | static void FUNC_0(Jpeg2000EncoderContext *VAR_0, Jpeg2000Tile *VAR_1)
{
int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;
Jpeg2000CodingStyle *codsty = &VAR_0->codsty;
for (VAR_3 = 0; VAR_3 < VAR_0->ncomponents; VAR_3++){
Jpeg2000Component *comp = VAR_1->comp + VAR_3;
for (VAR_4 = 0, VAR_7 = codsty->nreslevels-1; VAR_4 < codsty->nreslevels; VAR_4++, VAR_7--){
Jpeg2000ResLevel *reslevel = comp->reslevel + VAR_4;
for (VAR_2 = 0; VAR_2 < reslevel->num_precincts_x * reslevel->num_precincts_y; VAR_2++){
for (VAR_5 = 0; VAR_5 < reslevel->nbands ; VAR_5++){
int bandpos = VAR_5 + (VAR_4 > 0);
Jpeg2000Band *band = reslevel->band + VAR_5;
Jpeg2000Prec *prec = band->prec + VAR_2;
for (VAR_6 = 0; VAR_6 < prec->nb_codeblocks_height * prec->nb_codeblocks_width; VAR_6++){
Jpeg2000Cblk *cblk = prec->cblk + VAR_6;
cblk->ninclpasses = getcut(cblk, VAR_0->lambda,
(int64_t)dwt_norms[codsty->transform == FF_DWT53][bandpos][VAR_7] * (int64_t)band->i_stepsize >> 16);
}
}
}
}
}
}
| [
"static void FUNC_0(Jpeg2000EncoderContext *VAR_0, Jpeg2000Tile *VAR_1)\n{",
"int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;",
"Jpeg2000CodingStyle *codsty = &VAR_0->codsty;",
"for (VAR_3 = 0; VAR_3 < VAR_0->ncomponents; VAR_3++){",
"Jpeg2000Component *comp = VAR_1->comp + VAR_3;",
"for (VAR_4 = 0, VAR_7 = codsty->nreslevels-1; VAR_4 < codsty->nreslevels; VAR_4++, VAR_7--){",
"Jpeg2000ResLevel *reslevel = comp->reslevel + VAR_4;",
"for (VAR_2 = 0; VAR_2 < reslevel->num_precincts_x * reslevel->num_precincts_y; VAR_2++){",
"for (VAR_5 = 0; VAR_5 < reslevel->nbands ; VAR_5++){",
"int bandpos = VAR_5 + (VAR_4 > 0);",
"Jpeg2000Band *band = reslevel->band + VAR_5;",
"Jpeg2000Prec *prec = band->prec + VAR_2;",
"for (VAR_6 = 0; VAR_6 < prec->nb_codeblocks_height * prec->nb_codeblocks_width; VAR_6++){",
"Jpeg2000Cblk *cblk = prec->cblk + VAR_6;",
"cblk->ninclpasses = getcut(cblk, VAR_0->lambda,\n(int64_t)dwt_norms[codsty->transform == FF_DWT53][bandpos][VAR_7] * (int64_t)band->i_stepsize >> 16);",
"}",
"}",
"}",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
41,
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
]
] |
21,126 | static void gen_rfdi(DisasContext *ctx)
{
#if defined(CONFIG_USER_ONLY)
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
#else
if (unlikely(ctx->pr)) {
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
return;
}
/* Restore CPU state */
gen_helper_rfdi(cpu_env);
gen_sync_exception(ctx);
#endif
}
| true | qemu | 9b2fadda3e0196ffd485adde4fe9cdd6fae35300 | static void gen_rfdi(DisasContext *ctx)
{
#if defined(CONFIG_USER_ONLY)
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
#else
if (unlikely(ctx->pr)) {
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
return;
}
gen_helper_rfdi(cpu_env);
gen_sync_exception(ctx);
#endif
}
| {
"code": [
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#if defined(CONFIG_USER_ONLY)",
"#else",
" if (unlikely(ctx->pr)) {",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
"#else",
" if (unlikely(ctx->pr)) {",
"#endif",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
"#else",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#else",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#else",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#else",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif"
],
"line_no": [
13,
7,
11,
13,
7,
11,
13,
7,
13,
5,
9,
11,
25,
5,
9,
11,
25,
25,
5,
9,
11,
7,
11,
13,
25,
11,
25,
11,
25,
11,
25,
11,
25,
11,
25,
11,
25,
11,
25,
11,
25,
11,
25,
11,
25,
11,
25,
7,
13,
25,
7,
11,
13,
25,
7,
13,
25,
7,
13,
25,
7,
11,
13,
25,
7,
11,
13,
25,
25,
7,
11,
13,
25,
7,
11,
13,
25,
7,
11,
13,
25,
7,
11,
13,
25,
7,
11,
13,
25,
7,
11,
13,
25,
7,
11,
13,
25,
7,
11,
13,
25,
7,
11,
13,
25,
7,
11,
13,
25,
11,
25,
11,
25,
11,
25,
11,
25,
5,
7,
9,
11,
13,
25,
7,
11,
13,
25,
5,
7,
9,
11,
13,
25,
5,
7,
9,
11,
13,
25,
7,
11,
13,
25,
7,
11,
13,
25,
7,
11,
13,
25,
7,
11,
13,
25,
7,
11,
13,
25,
7,
11,
13,
25,
7,
11,
13,
25,
7,
11,
13,
25,
7,
11,
13,
25,
7,
11,
13,
25,
5,
7,
11,
13,
25,
7,
11,
13,
25,
7,
11,
13,
25,
7,
11,
13,
25,
7,
11,
13,
25,
7,
11,
13,
25,
7,
11,
13,
25,
7,
11,
13,
25,
7,
11,
13,
25
]
} | static void FUNC_0(DisasContext *VAR_0)
{
#if defined(CONFIG_USER_ONLY)
gen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_OPC);
#else
if (unlikely(VAR_0->pr)) {
gen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_OPC);
return;
}
gen_helper_rfdi(cpu_env);
gen_sync_exception(VAR_0);
#endif
}
| [
"static void FUNC_0(DisasContext *VAR_0)\n{",
"#if defined(CONFIG_USER_ONLY)\ngen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_OPC);",
"#else\nif (unlikely(VAR_0->pr)) {",
"gen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_OPC);",
"return;",
"}",
"gen_helper_rfdi(cpu_env);",
"gen_sync_exception(VAR_0);",
"#endif\n}"
] | [
0,
1,
1,
1,
0,
0,
0,
0,
1
] | [
[
1,
3
],
[
5,
7
],
[
9,
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25,
27
]
] |
21,127 | void ide_data_writel(void *opaque, uint32_t addr, uint32_t val)
{
IDEBus *bus = opaque;
IDEState *s = idebus_active_if(bus);
uint8_t *p;
/* PIO data access allowed only when DRQ bit is set. The result of a write
* during PIO out is indeterminate, just ignore it. */
if (!(s->status & DRQ_STAT) || ide_is_pio_out(s)) {
p = s->data_ptr;
*(uint32_t *)p = le32_to_cpu(val);
p += 4;
s->data_ptr = p;
if (p >= s->data_end)
s->end_transfer_func(s); | true | qemu | d2ff85854512574e7209f295e87b0835d5b032c6 | void ide_data_writel(void *opaque, uint32_t addr, uint32_t val)
{
IDEBus *bus = opaque;
IDEState *s = idebus_active_if(bus);
uint8_t *p;
if (!(s->status & DRQ_STAT) || ide_is_pio_out(s)) {
p = s->data_ptr;
*(uint32_t *)p = le32_to_cpu(val);
p += 4;
s->data_ptr = p;
if (p >= s->data_end)
s->end_transfer_func(s); | {
"code": [],
"line_no": []
} | void FUNC_0(void *VAR_0, uint32_t VAR_1, uint32_t VAR_2)
{
IDEBus *bus = VAR_0;
IDEState *s = idebus_active_if(bus);
uint8_t *p;
if (!(s->status & DRQ_STAT) || ide_is_pio_out(s)) {
p = s->data_ptr;
*(uint32_t *)p = le32_to_cpu(VAR_2);
p += 4;
s->data_ptr = p;
if (p >= s->data_end)
s->end_transfer_func(s); | [
"void FUNC_0(void *VAR_0, uint32_t VAR_1, uint32_t VAR_2)\n{",
"IDEBus *bus = VAR_0;",
"IDEState *s = idebus_active_if(bus);",
"uint8_t *p;",
"if (!(s->status & DRQ_STAT) || ide_is_pio_out(s)) {",
"p = s->data_ptr;",
"*(uint32_t *)p = le32_to_cpu(VAR_2);",
"p += 4;",
"s->data_ptr = p;",
"if (p >= s->data_end)\ns->end_transfer_func(s);"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
2
],
[
3
],
[
4
],
[
5
],
[
8
],
[
9
],
[
10
],
[
11
],
[
12
],
[
13,
14
]
] |
21,128 | void OPPROTO op_addo (void)
{
do_addo();
RETURN();
}
| true | qemu | d9bce9d99f4656ae0b0127f7472db9067b8f84ab | void OPPROTO op_addo (void)
{
do_addo();
RETURN();
}
| {
"code": [
"void OPPROTO op_addo (void)",
" do_addo();",
" RETURN();",
" RETURN();"
],
"line_no": [
1,
5,
7,
7
]
} | void VAR_0 op_addo (void)
{
do_addo();
RETURN();
}
| [
"void VAR_0 op_addo (void)\n{",
"do_addo();",
"RETURN();",
"}"
] | [
1,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
21,129 | static bool run_poll_handlers_once(AioContext *ctx)
{
bool progress = false;
AioHandler *node;
QLIST_FOREACH_RCU(node, &ctx->aio_handlers, node) {
if (!node->deleted && node->io_poll &&
node->io_poll(node->opaque)) {
progress = true;
}
/* Caller handles freeing deleted nodes. Don't do it here. */
}
return progress;
}
| true | qemu | 59c9f437c59a4bf0594ed300d28fb24c645963a5 | static bool run_poll_handlers_once(AioContext *ctx)
{
bool progress = false;
AioHandler *node;
QLIST_FOREACH_RCU(node, &ctx->aio_handlers, node) {
if (!node->deleted && node->io_poll &&
node->io_poll(node->opaque)) {
progress = true;
}
}
return progress;
}
| {
"code": [
" node->io_poll(node->opaque)) {"
],
"line_no": [
15
]
} | static bool FUNC_0(AioContext *ctx)
{
bool progress = false;
AioHandler *node;
QLIST_FOREACH_RCU(node, &ctx->aio_handlers, node) {
if (!node->deleted && node->io_poll &&
node->io_poll(node->opaque)) {
progress = true;
}
}
return progress;
}
| [
"static bool FUNC_0(AioContext *ctx)\n{",
"bool progress = false;",
"AioHandler *node;",
"QLIST_FOREACH_RCU(node, &ctx->aio_handlers, node) {",
"if (!node->deleted && node->io_poll &&\nnode->io_poll(node->opaque)) {",
"progress = true;",
"}",
"}",
"return progress;",
"}"
] | [
0,
0,
0,
0,
1,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13,
15
],
[
17
],
[
19
],
[
25
],
[
29
],
[
31
]
] |
21,130 | static void filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize) {
MpegEncContext * const s = &h->s;
const int mb_xy= mb_x + mb_y*s->mb_stride;
const int mb_type = s->current_picture.mb_type[mb_xy];
const int mvy_limit = IS_INTERLACED(mb_type) ? 2 : 4;
int first_vertical_edge_done = 0;
int dir;
/* FIXME: A given frame may occupy more than one position in
* the reference list. So ref2frm should be populated with
* frame numbers, not indices. */
static const int ref2frm[34] = {-1,-1,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};
//for sufficiently low qp, filtering wouldn't do anything
//this is a conservative estimate: could also check beta_offset and more accurate chroma_qp
if(!FRAME_MBAFF){
int qp_thresh = 15 - h->slice_alpha_c0_offset - FFMAX(0, h->pps.chroma_qp_index_offset);
int qp = s->current_picture.qscale_table[mb_xy];
if(qp <= qp_thresh
&& (mb_x == 0 || ((qp + s->current_picture.qscale_table[mb_xy-1] + 1)>>1) <= qp_thresh)
&& (mb_y == 0 || ((qp + s->current_picture.qscale_table[h->top_mb_xy] + 1)>>1) <= qp_thresh)){
return;
}
}
if (FRAME_MBAFF
// left mb is in picture
&& h->slice_table[mb_xy-1] != 255
// and current and left pair do not have the same interlaced type
&& (IS_INTERLACED(mb_type) != IS_INTERLACED(s->current_picture.mb_type[mb_xy-1]))
// and left mb is in the same slice if deblocking_filter == 2
&& (h->deblocking_filter!=2 || h->slice_table[mb_xy-1] == h->slice_table[mb_xy])) {
/* First vertical edge is different in MBAFF frames
* There are 8 different bS to compute and 2 different Qp
*/
const int pair_xy = mb_x + (mb_y&~1)*s->mb_stride;
const int left_mb_xy[2] = { pair_xy-1, pair_xy-1+s->mb_stride };
int16_t bS[8];
int qp[2];
int chroma_qp[2];
int mb_qp, mbn0_qp, mbn1_qp;
int i;
first_vertical_edge_done = 1;
if( IS_INTRA(mb_type) )
bS[0] = bS[1] = bS[2] = bS[3] = bS[4] = bS[5] = bS[6] = bS[7] = 4;
else {
for( i = 0; i < 8; i++ ) {
int mbn_xy = MB_FIELD ? left_mb_xy[i>>2] : left_mb_xy[i&1];
if( IS_INTRA( s->current_picture.mb_type[mbn_xy] ) )
bS[i] = 4;
else if( h->non_zero_count_cache[12+8*(i>>1)] != 0 ||
/* FIXME: with 8x8dct + cavlc, should check cbp instead of nnz */
h->non_zero_count[mbn_xy][MB_FIELD ? i&3 : (i>>2)+(mb_y&1)*2] )
bS[i] = 2;
else
bS[i] = 1;
}
}
mb_qp = s->current_picture.qscale_table[mb_xy];
mbn0_qp = s->current_picture.qscale_table[left_mb_xy[0]];
mbn1_qp = s->current_picture.qscale_table[left_mb_xy[1]];
qp[0] = ( mb_qp + mbn0_qp + 1 ) >> 1;
chroma_qp[0] = ( get_chroma_qp( h, mb_qp ) +
get_chroma_qp( h, mbn0_qp ) + 1 ) >> 1;
qp[1] = ( mb_qp + mbn1_qp + 1 ) >> 1;
chroma_qp[1] = ( get_chroma_qp( h, mb_qp ) +
get_chroma_qp( h, mbn1_qp ) + 1 ) >> 1;
/* Filter edge */
tprintf(s->avctx, "filter mb:%d/%d MBAFF, QPy:%d/%d, QPc:%d/%d ls:%d uvls:%d", mb_x, mb_y, qp[0], qp[1], chroma_qp[0], chroma_qp[1], linesize, uvlinesize);
{ int i; for (i = 0; i < 8; i++) tprintf(s->avctx, " bS[%d]:%d", i, bS[i]); tprintf(s->avctx, "\n"); }
filter_mb_mbaff_edgev ( h, &img_y [0], linesize, bS, qp );
filter_mb_mbaff_edgecv( h, &img_cb[0], uvlinesize, bS, chroma_qp );
filter_mb_mbaff_edgecv( h, &img_cr[0], uvlinesize, bS, chroma_qp );
}
/* dir : 0 -> vertical edge, 1 -> horizontal edge */
for( dir = 0; dir < 2; dir++ )
{
int edge;
const int mbm_xy = dir == 0 ? mb_xy -1 : h->top_mb_xy;
const int mbm_type = s->current_picture.mb_type[mbm_xy];
int start = h->slice_table[mbm_xy] == 255 ? 1 : 0;
const int edges = (mb_type & (MB_TYPE_16x16|MB_TYPE_SKIP))
== (MB_TYPE_16x16|MB_TYPE_SKIP) ? 1 : 4;
// how often to recheck mv-based bS when iterating between edges
const int mask_edge = (mb_type & (MB_TYPE_16x16 | (MB_TYPE_16x8 << dir))) ? 3 :
(mb_type & (MB_TYPE_8x16 >> dir)) ? 1 : 0;
// how often to recheck mv-based bS when iterating along each edge
const int mask_par0 = mb_type & (MB_TYPE_16x16 | (MB_TYPE_8x16 >> dir));
if (first_vertical_edge_done) {
start = 1;
first_vertical_edge_done = 0;
}
if (h->deblocking_filter==2 && h->slice_table[mbm_xy] != h->slice_table[mb_xy])
start = 1;
if (FRAME_MBAFF && (dir == 1) && ((mb_y&1) == 0) && start == 0
&& !IS_INTERLACED(mb_type)
&& IS_INTERLACED(mbm_type)
) {
// This is a special case in the norm where the filtering must
// be done twice (one each of the field) even if we are in a
// frame macroblock.
//
static const int nnz_idx[4] = {4,5,6,3};
unsigned int tmp_linesize = 2 * linesize;
unsigned int tmp_uvlinesize = 2 * uvlinesize;
int mbn_xy = mb_xy - 2 * s->mb_stride;
int qp, chroma_qp;
int i, j;
int16_t bS[4];
for(j=0; j<2; j++, mbn_xy += s->mb_stride){
if( IS_INTRA(mb_type) ||
IS_INTRA(s->current_picture.mb_type[mbn_xy]) ) {
bS[0] = bS[1] = bS[2] = bS[3] = 3;
} else {
const uint8_t *mbn_nnz = h->non_zero_count[mbn_xy];
for( i = 0; i < 4; i++ ) {
if( h->non_zero_count_cache[scan8[0]+i] != 0 ||
mbn_nnz[nnz_idx[i]] != 0 )
bS[i] = 2;
else
bS[i] = 1;
}
}
// Do not use s->qscale as luma quantizer because it has not the same
// value in IPCM macroblocks.
qp = ( s->current_picture.qscale_table[mb_xy] + s->current_picture.qscale_table[mbn_xy] + 1 ) >> 1;
tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d ls:%d uvls:%d", mb_x, mb_y, dir, edge, qp, tmp_linesize, tmp_uvlinesize);
{ int i; for (i = 0; i < 4; i++) tprintf(s->avctx, " bS[%d]:%d", i, bS[i]); tprintf(s->avctx, "\n"); }
filter_mb_edgeh( h, &img_y[j*linesize], tmp_linesize, bS, qp );
chroma_qp = ( h->chroma_qp +
get_chroma_qp( h, s->current_picture.qscale_table[mbn_xy] ) + 1 ) >> 1;
filter_mb_edgech( h, &img_cb[j*uvlinesize], tmp_uvlinesize, bS, chroma_qp );
filter_mb_edgech( h, &img_cr[j*uvlinesize], tmp_uvlinesize, bS, chroma_qp );
}
start = 1;
}
/* Calculate bS */
for( edge = start; edge < edges; edge++ ) {
/* mbn_xy: neighbor macroblock */
const int mbn_xy = edge > 0 ? mb_xy : mbm_xy;
const int mbn_type = s->current_picture.mb_type[mbn_xy];
int16_t bS[4];
int qp;
if( (edge&1) && IS_8x8DCT(mb_type) )
continue;
if( IS_INTRA(mb_type) ||
IS_INTRA(mbn_type) ) {
int value;
if (edge == 0) {
if ( (!IS_INTERLACED(mb_type) && !IS_INTERLACED(mbm_type))
|| ((FRAME_MBAFF || (s->picture_structure != PICT_FRAME)) && (dir == 0))
) {
value = 4;
} else {
value = 3;
}
} else {
value = 3;
}
bS[0] = bS[1] = bS[2] = bS[3] = value;
} else {
int i, l;
int mv_done;
if( edge & mask_edge ) {
bS[0] = bS[1] = bS[2] = bS[3] = 0;
mv_done = 1;
}
else if( FRAME_MBAFF && IS_INTERLACED(mb_type ^ mbn_type)) {
bS[0] = bS[1] = bS[2] = bS[3] = 1;
mv_done = 1;
}
else if( mask_par0 && (edge || (mbn_type & (MB_TYPE_16x16 | (MB_TYPE_8x16 >> dir)))) ) {
int b_idx= 8 + 4 + edge * (dir ? 8:1);
int bn_idx= b_idx - (dir ? 8:1);
int v = 0;
for( l = 0; !v && l < 1 + (h->slice_type == B_TYPE); l++ ) {
v |= ref2frm[h->ref_cache[l][b_idx]+2] != ref2frm[h->ref_cache[l][bn_idx]+2] ||
FFABS( h->mv_cache[l][b_idx][0] - h->mv_cache[l][bn_idx][0] ) >= 4 ||
FFABS( h->mv_cache[l][b_idx][1] - h->mv_cache[l][bn_idx][1] ) >= mvy_limit;
}
bS[0] = bS[1] = bS[2] = bS[3] = v;
mv_done = 1;
}
else
mv_done = 0;
for( i = 0; i < 4; i++ ) {
int x = dir == 0 ? edge : i;
int y = dir == 0 ? i : edge;
int b_idx= 8 + 4 + x + 8*y;
int bn_idx= b_idx - (dir ? 8:1);
if( h->non_zero_count_cache[b_idx] != 0 ||
h->non_zero_count_cache[bn_idx] != 0 ) {
bS[i] = 2;
}
else if(!mv_done)
{
bS[i] = 0;
for( l = 0; l < 1 + (h->slice_type == B_TYPE); l++ ) {
if( ref2frm[h->ref_cache[l][b_idx]+2] != ref2frm[h->ref_cache[l][bn_idx]+2] ||
FFABS( h->mv_cache[l][b_idx][0] - h->mv_cache[l][bn_idx][0] ) >= 4 ||
FFABS( h->mv_cache[l][b_idx][1] - h->mv_cache[l][bn_idx][1] ) >= mvy_limit ) {
bS[i] = 1;
break;
}
}
}
}
if(bS[0]+bS[1]+bS[2]+bS[3] == 0)
continue;
}
/* Filter edge */
// Do not use s->qscale as luma quantizer because it has not the same
// value in IPCM macroblocks.
qp = ( s->current_picture.qscale_table[mb_xy] + s->current_picture.qscale_table[mbn_xy] + 1 ) >> 1;
//tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d, QPc:%d, QPcn:%d\n", mb_x, mb_y, dir, edge, qp, h->chroma_qp, s->current_picture.qscale_table[mbn_xy]);
tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d ls:%d uvls:%d", mb_x, mb_y, dir, edge, qp, linesize, uvlinesize);
{ int i; for (i = 0; i < 4; i++) tprintf(s->avctx, " bS[%d]:%d", i, bS[i]); tprintf(s->avctx, "\n"); }
if( dir == 0 ) {
filter_mb_edgev( h, &img_y[4*edge], linesize, bS, qp );
if( (edge&1) == 0 ) {
int chroma_qp = ( h->chroma_qp +
get_chroma_qp( h, s->current_picture.qscale_table[mbn_xy] ) + 1 ) >> 1;
filter_mb_edgecv( h, &img_cb[2*edge], uvlinesize, bS, chroma_qp );
filter_mb_edgecv( h, &img_cr[2*edge], uvlinesize, bS, chroma_qp );
}
} else {
filter_mb_edgeh( h, &img_y[4*edge*linesize], linesize, bS, qp );
if( (edge&1) == 0 ) {
int chroma_qp = ( h->chroma_qp +
get_chroma_qp( h, s->current_picture.qscale_table[mbn_xy] ) + 1 ) >> 1;
filter_mb_edgech( h, &img_cb[2*edge*uvlinesize], uvlinesize, bS, chroma_qp );
filter_mb_edgech( h, &img_cr[2*edge*uvlinesize], uvlinesize, bS, chroma_qp );
}
}
}
}
}
| true | FFmpeg | 4691a77db4672026d62d524fd292fb17db6514b4 | static void filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize) {
MpegEncContext * const s = &h->s;
const int mb_xy= mb_x + mb_y*s->mb_stride;
const int mb_type = s->current_picture.mb_type[mb_xy];
const int mvy_limit = IS_INTERLACED(mb_type) ? 2 : 4;
int first_vertical_edge_done = 0;
int dir;
static const int ref2frm[34] = {-1,-1,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};
if(!FRAME_MBAFF){
int qp_thresh = 15 - h->slice_alpha_c0_offset - FFMAX(0, h->pps.chroma_qp_index_offset);
int qp = s->current_picture.qscale_table[mb_xy];
if(qp <= qp_thresh
&& (mb_x == 0 || ((qp + s->current_picture.qscale_table[mb_xy-1] + 1)>>1) <= qp_thresh)
&& (mb_y == 0 || ((qp + s->current_picture.qscale_table[h->top_mb_xy] + 1)>>1) <= qp_thresh)){
return;
}
}
if (FRAME_MBAFF
&& h->slice_table[mb_xy-1] != 255
&& (IS_INTERLACED(mb_type) != IS_INTERLACED(s->current_picture.mb_type[mb_xy-1]))
&& (h->deblocking_filter!=2 || h->slice_table[mb_xy-1] == h->slice_table[mb_xy])) {
const int pair_xy = mb_x + (mb_y&~1)*s->mb_stride;
const int left_mb_xy[2] = { pair_xy-1, pair_xy-1+s->mb_stride };
int16_t bS[8];
int qp[2];
int chroma_qp[2];
int mb_qp, mbn0_qp, mbn1_qp;
int i;
first_vertical_edge_done = 1;
if( IS_INTRA(mb_type) )
bS[0] = bS[1] = bS[2] = bS[3] = bS[4] = bS[5] = bS[6] = bS[7] = 4;
else {
for( i = 0; i < 8; i++ ) {
int mbn_xy = MB_FIELD ? left_mb_xy[i>>2] : left_mb_xy[i&1];
if( IS_INTRA( s->current_picture.mb_type[mbn_xy] ) )
bS[i] = 4;
else if( h->non_zero_count_cache[12+8*(i>>1)] != 0 ||
h->non_zero_count[mbn_xy][MB_FIELD ? i&3 : (i>>2)+(mb_y&1)*2] )
bS[i] = 2;
else
bS[i] = 1;
}
}
mb_qp = s->current_picture.qscale_table[mb_xy];
mbn0_qp = s->current_picture.qscale_table[left_mb_xy[0]];
mbn1_qp = s->current_picture.qscale_table[left_mb_xy[1]];
qp[0] = ( mb_qp + mbn0_qp + 1 ) >> 1;
chroma_qp[0] = ( get_chroma_qp( h, mb_qp ) +
get_chroma_qp( h, mbn0_qp ) + 1 ) >> 1;
qp[1] = ( mb_qp + mbn1_qp + 1 ) >> 1;
chroma_qp[1] = ( get_chroma_qp( h, mb_qp ) +
get_chroma_qp( h, mbn1_qp ) + 1 ) >> 1;
tprintf(s->avctx, "filter mb:%d/%d MBAFF, QPy:%d/%d, QPc:%d/%d ls:%d uvls:%d", mb_x, mb_y, qp[0], qp[1], chroma_qp[0], chroma_qp[1], linesize, uvlinesize);
{ int i; for (i = 0; i < 8; i++) tprintf(s->avctx, " bS[%d]:%d", i, bS[i]); tprintf(s->avctx, "\n"); }
filter_mb_mbaff_edgev ( h, &img_y [0], linesize, bS, qp );
filter_mb_mbaff_edgecv( h, &img_cb[0], uvlinesize, bS, chroma_qp );
filter_mb_mbaff_edgecv( h, &img_cr[0], uvlinesize, bS, chroma_qp );
}
for( dir = 0; dir < 2; dir++ )
{
int edge;
const int mbm_xy = dir == 0 ? mb_xy -1 : h->top_mb_xy;
const int mbm_type = s->current_picture.mb_type[mbm_xy];
int start = h->slice_table[mbm_xy] == 255 ? 1 : 0;
const int edges = (mb_type & (MB_TYPE_16x16|MB_TYPE_SKIP))
== (MB_TYPE_16x16|MB_TYPE_SKIP) ? 1 : 4;
const int mask_edge = (mb_type & (MB_TYPE_16x16 | (MB_TYPE_16x8 << dir))) ? 3 :
(mb_type & (MB_TYPE_8x16 >> dir)) ? 1 : 0;
const int mask_par0 = mb_type & (MB_TYPE_16x16 | (MB_TYPE_8x16 >> dir));
if (first_vertical_edge_done) {
start = 1;
first_vertical_edge_done = 0;
}
if (h->deblocking_filter==2 && h->slice_table[mbm_xy] != h->slice_table[mb_xy])
start = 1;
if (FRAME_MBAFF && (dir == 1) && ((mb_y&1) == 0) && start == 0
&& !IS_INTERLACED(mb_type)
&& IS_INTERLACED(mbm_type)
) {
static const int nnz_idx[4] = {4,5,6,3};
unsigned int tmp_linesize = 2 * linesize;
unsigned int tmp_uvlinesize = 2 * uvlinesize;
int mbn_xy = mb_xy - 2 * s->mb_stride;
int qp, chroma_qp;
int i, j;
int16_t bS[4];
for(j=0; j<2; j++, mbn_xy += s->mb_stride){
if( IS_INTRA(mb_type) ||
IS_INTRA(s->current_picture.mb_type[mbn_xy]) ) {
bS[0] = bS[1] = bS[2] = bS[3] = 3;
} else {
const uint8_t *mbn_nnz = h->non_zero_count[mbn_xy];
for( i = 0; i < 4; i++ ) {
if( h->non_zero_count_cache[scan8[0]+i] != 0 ||
mbn_nnz[nnz_idx[i]] != 0 )
bS[i] = 2;
else
bS[i] = 1;
}
}
Do not use s->qscale as luma quantizer because it has not the same
value in IPCM macroblocks.
qp = ( s->current_picture.qscale_table[mb_xy] + s->current_picture.qscale_table[mbn_xy] + 1 ) >> 1;
tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d ls:%d uvls:%d", mb_x, mb_y, dir, edge, qp, tmp_linesize, tmp_uvlinesize);
{ int i; for (i = 0; i < 4; i++) tprintf(s->avctx, " bS[%d]:%d", i, bS[i]); tprintf(s->avctx, "\n"); }
filter_mb_edgeh( h, &img_y[j*linesize], tmp_linesize, bS, qp );
chroma_qp = ( h->chroma_qp +
get_chroma_qp( h, s->current_picture.qscale_table[mbn_xy] ) + 1 ) >> 1;
filter_mb_edgech( h, &img_cb[j*uvlinesize], tmp_uvlinesize, bS, chroma_qp );
filter_mb_edgech( h, &img_cr[j*uvlinesize], tmp_uvlinesize, bS, chroma_qp );
}
start = 1;
}
for( edge = start; edge < edges; edge++ ) {
const int mbn_xy = edge > 0 ? mb_xy : mbm_xy;
const int mbn_type = s->current_picture.mb_type[mbn_xy];
int16_t bS[4];
int qp;
if( (edge&1) && IS_8x8DCT(mb_type) )
continue;
if( IS_INTRA(mb_type) ||
IS_INTRA(mbn_type) ) {
int value;
if (edge == 0) {
if ( (!IS_INTERLACED(mb_type) && !IS_INTERLACED(mbm_type))
|| ((FRAME_MBAFF || (s->picture_structure != PICT_FRAME)) && (dir == 0))
) {
value = 4;
} else {
value = 3;
}
} else {
value = 3;
}
bS[0] = bS[1] = bS[2] = bS[3] = value;
} else {
int i, l;
int mv_done;
if( edge & mask_edge ) {
bS[0] = bS[1] = bS[2] = bS[3] = 0;
mv_done = 1;
}
else if( FRAME_MBAFF && IS_INTERLACED(mb_type ^ mbn_type)) {
bS[0] = bS[1] = bS[2] = bS[3] = 1;
mv_done = 1;
}
else if( mask_par0 && (edge || (mbn_type & (MB_TYPE_16x16 | (MB_TYPE_8x16 >> dir)))) ) {
int b_idx= 8 + 4 + edge * (dir ? 8:1);
int bn_idx= b_idx - (dir ? 8:1);
int v = 0;
for( l = 0; !v && l < 1 + (h->slice_type == B_TYPE); l++ ) {
v |= ref2frm[h->ref_cache[l][b_idx]+2] != ref2frm[h->ref_cache[l][bn_idx]+2] ||
FFABS( h->mv_cache[l][b_idx][0] - h->mv_cache[l][bn_idx][0] ) >= 4 ||
FFABS( h->mv_cache[l][b_idx][1] - h->mv_cache[l][bn_idx][1] ) >= mvy_limit;
}
bS[0] = bS[1] = bS[2] = bS[3] = v;
mv_done = 1;
}
else
mv_done = 0;
for( i = 0; i < 4; i++ ) {
int x = dir == 0 ? edge : i;
int y = dir == 0 ? i : edge;
int b_idx= 8 + 4 + x + 8*y;
int bn_idx= b_idx - (dir ? 8:1);
if( h->non_zero_count_cache[b_idx] != 0 ||
h->non_zero_count_cache[bn_idx] != 0 ) {
bS[i] = 2;
}
else if(!mv_done)
{
bS[i] = 0;
for( l = 0; l < 1 + (h->slice_type == B_TYPE); l++ ) {
if( ref2frm[h->ref_cache[l][b_idx]+2] != ref2frm[h->ref_cache[l][bn_idx]+2] ||
FFABS( h->mv_cache[l][b_idx][0] - h->mv_cache[l][bn_idx][0] ) >= 4 ||
FFABS( h->mv_cache[l][b_idx][1] - h->mv_cache[l][bn_idx][1] ) >= mvy_limit ) {
bS[i] = 1;
break;
}
}
}
}
if(bS[0]+bS[1]+bS[2]+bS[3] == 0)
continue;
}
Do not use s->qscale as luma quantizer because it has not the same
value in IPCM macroblocks.
qp = ( s->current_picture.qscale_table[mb_xy] + s->current_picture.qscale_table[mbn_xy] + 1 ) >> 1;
tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d, QPc:%d, QPcn:%d\n", mb_x, mb_y, dir, edge, qp, h->chroma_qp, s->current_picture.qscale_table[mbn_xy]);
tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d ls:%d uvls:%d", mb_x, mb_y, dir, edge, qp, linesize, uvlinesize);
{ int i; for (i = 0; i < 4; i++) tprintf(s->avctx, " bS[%d]:%d", i, bS[i]); tprintf(s->avctx, "\n"); }
if( dir == 0 ) {
filter_mb_edgev( h, &img_y[4*edge], linesize, bS, qp );
if( (edge&1) == 0 ) {
int chroma_qp = ( h->chroma_qp +
get_chroma_qp( h, s->current_picture.qscale_table[mbn_xy] ) + 1 ) >> 1;
filter_mb_edgecv( h, &img_cb[2*edge], uvlinesize, bS, chroma_qp );
filter_mb_edgecv( h, &img_cr[2*edge], uvlinesize, bS, chroma_qp );
}
} else {
filter_mb_edgeh( h, &img_y[4*edge*linesize], linesize, bS, qp );
if( (edge&1) == 0 ) {
int chroma_qp = ( h->chroma_qp +
get_chroma_qp( h, s->current_picture.qscale_table[mbn_xy] ) + 1 ) >> 1;
filter_mb_edgech( h, &img_cb[2*edge*uvlinesize], uvlinesize, bS, chroma_qp );
filter_mb_edgech( h, &img_cr[2*edge*uvlinesize], uvlinesize, bS, chroma_qp );
}
}
}
}
}
| {
"code": [
" int qp_thresh = 15 - h->slice_alpha_c0_offset - FFMAX(0, h->pps.chroma_qp_index_offset);",
" int chroma_qp[2];",
" chroma_qp[0] = ( get_chroma_qp( h, mb_qp ) +",
" get_chroma_qp( h, mbn0_qp ) + 1 ) >> 1;",
" chroma_qp[1] = ( get_chroma_qp( h, mb_qp ) +",
" get_chroma_qp( h, mbn1_qp ) + 1 ) >> 1;",
" tprintf(s->avctx, \"filter mb:%d/%d MBAFF, QPy:%d/%d, QPc:%d/%d ls:%d uvls:%d\", mb_x, mb_y, qp[0], qp[1], chroma_qp[0], chroma_qp[1], linesize, uvlinesize);",
" filter_mb_mbaff_edgecv( h, &img_cb[0], uvlinesize, bS, chroma_qp );",
" filter_mb_mbaff_edgecv( h, &img_cr[0], uvlinesize, bS, chroma_qp );",
" int qp, chroma_qp;",
" chroma_qp = ( h->chroma_qp +",
" get_chroma_qp( h, s->current_picture.qscale_table[mbn_xy] ) + 1 ) >> 1;",
" filter_mb_edgech( h, &img_cb[j*uvlinesize], tmp_uvlinesize, bS, chroma_qp );",
" filter_mb_edgech( h, &img_cr[j*uvlinesize], tmp_uvlinesize, bS, chroma_qp );",
" int chroma_qp = ( h->chroma_qp +",
" get_chroma_qp( h, s->current_picture.qscale_table[mbn_xy] ) + 1 ) >> 1;",
" filter_mb_edgecv( h, &img_cb[2*edge], uvlinesize, bS, chroma_qp );",
" filter_mb_edgecv( h, &img_cr[2*edge], uvlinesize, bS, chroma_qp );",
" int chroma_qp = ( h->chroma_qp +",
" get_chroma_qp( h, s->current_picture.qscale_table[mbn_xy] ) + 1 ) >> 1;",
" filter_mb_edgech( h, &img_cb[2*edge*uvlinesize], uvlinesize, bS, chroma_qp );",
" filter_mb_edgech( h, &img_cr[2*edge*uvlinesize], uvlinesize, bS, chroma_qp );"
],
"line_no": [
33,
79,
131,
133,
137,
139,
145,
151,
153,
229,
277,
279,
281,
283,
477,
479,
481,
483,
477,
479,
497,
499
]
} | static void FUNC_0( H264Context *VAR_0, int VAR_1, int VAR_2, uint8_t *VAR_3, uint8_t *VAR_4, uint8_t *VAR_5, unsigned int VAR_6, unsigned int VAR_7) {
MpegEncContext * const s = &VAR_0->s;
const int VAR_8= VAR_1 + VAR_2*s->mb_stride;
const int VAR_9 = s->current_picture.VAR_9[VAR_8];
const int VAR_10 = IS_INTERLACED(VAR_9) ? 2 : 4;
int VAR_11 = 0;
int VAR_12;
static const int VAR_13[34] = {-1,-1,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};
if(!FRAME_MBAFF){
int VAR_14 = 15 - VAR_0->slice_alpha_c0_offset - FFMAX(0, VAR_0->pps.chroma_qp_index_offset);
int VAR_37 = s->current_picture.qscale_table[VAR_8];
if(VAR_37 <= VAR_14
&& (VAR_1 == 0 || ((VAR_37 + s->current_picture.qscale_table[VAR_8-1] + 1)>>1) <= VAR_14)
&& (VAR_2 == 0 || ((VAR_37 + s->current_picture.qscale_table[VAR_0->top_mb_xy] + 1)>>1) <= VAR_14)){
return;
}
}
if (FRAME_MBAFF
&& VAR_0->slice_table[VAR_8-1] != 255
&& (IS_INTERLACED(VAR_9) != IS_INTERLACED(s->current_picture.VAR_9[VAR_8-1]))
&& (VAR_0->deblocking_filter!=2 || VAR_0->slice_table[VAR_8-1] == VAR_0->slice_table[VAR_8])) {
const int VAR_16 = VAR_1 + (VAR_2&~1)*s->mb_stride;
const int VAR_17[2] = { VAR_16-1, VAR_16-1+s->mb_stride };
int16_t bS[8];
int VAR_37[2];
int VAR_45[2];
int VAR_19, VAR_20, VAR_21;
int VAR_45;
VAR_11 = 1;
if( IS_INTRA(VAR_9) )
bS[0] = bS[1] = bS[2] = bS[3] = bS[4] = bS[5] = bS[6] = bS[7] = 4;
else {
for( VAR_45 = 0; VAR_45 < 8; VAR_45++ ) {
int VAR_36 = MB_FIELD ? VAR_17[VAR_45>>2] : VAR_17[VAR_45&1];
if( IS_INTRA( s->current_picture.VAR_9[VAR_36] ) )
bS[VAR_45] = 4;
else if( VAR_0->non_zero_count_cache[12+8*(VAR_45>>1)] != 0 ||
VAR_0->non_zero_count[VAR_36][MB_FIELD ? VAR_45&3 : (VAR_45>>2)+(VAR_2&1)*2] )
bS[VAR_45] = 2;
else
bS[VAR_45] = 1;
}
}
VAR_19 = s->current_picture.qscale_table[VAR_8];
VAR_20 = s->current_picture.qscale_table[VAR_17[0]];
VAR_21 = s->current_picture.qscale_table[VAR_17[1]];
VAR_37[0] = ( VAR_19 + VAR_20 + 1 ) >> 1;
VAR_45[0] = ( get_chroma_qp( VAR_0, VAR_19 ) +
get_chroma_qp( VAR_0, VAR_20 ) + 1 ) >> 1;
VAR_37[1] = ( VAR_19 + VAR_21 + 1 ) >> 1;
VAR_45[1] = ( get_chroma_qp( VAR_0, VAR_19 ) +
get_chroma_qp( VAR_0, VAR_21 ) + 1 ) >> 1;
tprintf(s->avctx, "filter mb:%d/%d MBAFF, QPy:%d/%d, QPc:%d/%d ls:%d uvls:%d", VAR_1, VAR_2, VAR_37[0], VAR_37[1], VAR_45[0], VAR_45[1], VAR_6, VAR_7);
{ int VAR_45; for (VAR_45 = 0; VAR_45 < 8; VAR_45++) tprintf(s->avctx, " bS[%d]:%d", VAR_45, bS[VAR_45]); tprintf(s->avctx, "\n"); }
filter_mb_mbaff_edgev ( VAR_0, &VAR_3 [0], VAR_6, bS, VAR_37 );
filter_mb_mbaff_edgecv( VAR_0, &VAR_4[0], VAR_7, bS, VAR_45 );
filter_mb_mbaff_edgecv( VAR_0, &VAR_5[0], VAR_7, bS, VAR_45 );
}
for( VAR_12 = 0; VAR_12 < 2; VAR_12++ )
{
int VAR_24;
const int VAR_25 = VAR_12 == 0 ? VAR_8 -1 : VAR_0->top_mb_xy;
const int VAR_26 = s->current_picture.VAR_9[VAR_25];
int VAR_27 = VAR_0->slice_table[VAR_25] == 255 ? 1 : 0;
const int VAR_28 = (VAR_9 & (MB_TYPE_16x16|MB_TYPE_SKIP))
== (MB_TYPE_16x16|MB_TYPE_SKIP) ? 1 : 4;
const int VAR_29 = (VAR_9 & (MB_TYPE_16x16 | (MB_TYPE_16x8 << VAR_12))) ? 3 :
(VAR_9 & (MB_TYPE_8x16 >> VAR_12)) ? 1 : 0;
const int VAR_30 = VAR_9 & (MB_TYPE_16x16 | (MB_TYPE_8x16 >> VAR_12));
if (VAR_11) {
VAR_27 = 1;
VAR_11 = 0;
}
if (VAR_0->deblocking_filter==2 && VAR_0->slice_table[VAR_25] != VAR_0->slice_table[VAR_8])
VAR_27 = 1;
if (FRAME_MBAFF && (VAR_12 == 1) && ((VAR_2&1) == 0) && VAR_27 == 0
&& !IS_INTERLACED(VAR_9)
&& IS_INTERLACED(VAR_26)
) {
static const int VAR_31[4] = {4,5,6,3};
unsigned int VAR_32 = 2 * VAR_6;
unsigned int VAR_33 = 2 * VAR_7;
int VAR_36 = VAR_8 - 2 * s->mb_stride;
int VAR_37, VAR_45;
int VAR_45, VAR_34;
int16_t bS[4];
for(VAR_34=0; VAR_34<2; VAR_34++, VAR_36 += s->mb_stride){
if( IS_INTRA(VAR_9) ||
IS_INTRA(s->current_picture.VAR_9[VAR_36]) ) {
bS[0] = bS[1] = bS[2] = bS[3] = 3;
} else {
const uint8_t *VAR_35 = VAR_0->non_zero_count[VAR_36];
for( VAR_45 = 0; VAR_45 < 4; VAR_45++ ) {
if( VAR_0->non_zero_count_cache[scan8[0]+VAR_45] != 0 ||
VAR_35[VAR_31[VAR_45]] != 0 )
bS[VAR_45] = 2;
else
bS[VAR_45] = 1;
}
}
Do not use s->qscale as luma quantizer because it has not the same
VAR_37 in IPCM macroblocks.
VAR_37 = ( s->current_picture.qscale_table[VAR_8] + s->current_picture.qscale_table[VAR_36] + 1 ) >> 1;
tprintf(s->avctx, "filter mb:%d/%d VAR_12:%d VAR_24:%d, QPy:%d ls:%d uvls:%d", VAR_1, VAR_2, VAR_12, VAR_24, VAR_37, VAR_32, VAR_33);
{ int VAR_45; for (VAR_45 = 0; VAR_45 < 4; VAR_45++) tprintf(s->avctx, " bS[%d]:%d", VAR_45, bS[VAR_45]); tprintf(s->avctx, "\n"); }
filter_mb_edgeh( VAR_0, &VAR_3[VAR_34*VAR_6], VAR_32, bS, VAR_37 );
VAR_45 = ( VAR_0->VAR_45 +
get_chroma_qp( VAR_0, s->current_picture.qscale_table[VAR_36] ) + 1 ) >> 1;
filter_mb_edgech( VAR_0, &VAR_4[VAR_34*VAR_7], VAR_33, bS, VAR_45 );
filter_mb_edgech( VAR_0, &VAR_5[VAR_34*VAR_7], VAR_33, bS, VAR_45 );
}
VAR_27 = 1;
}
for( VAR_24 = VAR_27; VAR_24 < VAR_28; VAR_24++ ) {
const int VAR_36 = VAR_24 > 0 ? VAR_8 : VAR_25;
const int VAR_36 = s->current_picture.VAR_9[VAR_36];
int16_t bS[4];
int VAR_37;
if( (VAR_24&1) && IS_8x8DCT(VAR_9) )
continue;
if( IS_INTRA(VAR_9) ||
IS_INTRA(VAR_36) ) {
int VAR_37;
if (VAR_24 == 0) {
if ( (!IS_INTERLACED(VAR_9) && !IS_INTERLACED(VAR_26))
|| ((FRAME_MBAFF || (s->picture_structure != PICT_FRAME)) && (VAR_12 == 0))
) {
VAR_37 = 4;
} else {
VAR_37 = 3;
}
} else {
VAR_37 = 3;
}
bS[0] = bS[1] = bS[2] = bS[3] = VAR_37;
} else {
int VAR_45, VAR_38;
int VAR_39;
if( VAR_24 & VAR_29 ) {
bS[0] = bS[1] = bS[2] = bS[3] = 0;
VAR_39 = 1;
}
else if( FRAME_MBAFF && IS_INTERLACED(VAR_9 ^ VAR_36)) {
bS[0] = bS[1] = bS[2] = bS[3] = 1;
VAR_39 = 1;
}
else if( VAR_30 && (VAR_24 || (VAR_36 & (MB_TYPE_16x16 | (MB_TYPE_8x16 >> VAR_12)))) ) {
int VAR_45= 8 + 4 + VAR_24 * (VAR_12 ? 8:1);
int VAR_45= VAR_45 - (VAR_12 ? 8:1);
int VAR_42 = 0;
for( VAR_38 = 0; !VAR_42 && VAR_38 < 1 + (VAR_0->slice_type == B_TYPE); VAR_38++ ) {
VAR_42 |= VAR_13[VAR_0->ref_cache[VAR_38][VAR_45]+2] != VAR_13[VAR_0->ref_cache[VAR_38][VAR_45]+2] ||
FFABS( VAR_0->mv_cache[VAR_38][VAR_45][0] - VAR_0->mv_cache[VAR_38][VAR_45][0] ) >= 4 ||
FFABS( VAR_0->mv_cache[VAR_38][VAR_45][1] - VAR_0->mv_cache[VAR_38][VAR_45][1] ) >= VAR_10;
}
bS[0] = bS[1] = bS[2] = bS[3] = VAR_42;
VAR_39 = 1;
}
else
VAR_39 = 0;
for( VAR_45 = 0; VAR_45 < 4; VAR_45++ ) {
int VAR_43 = VAR_12 == 0 ? VAR_24 : VAR_45;
int VAR_44 = VAR_12 == 0 ? VAR_45 : VAR_24;
int VAR_45= 8 + 4 + VAR_43 + 8*VAR_44;
int VAR_45= VAR_45 - (VAR_12 ? 8:1);
if( VAR_0->non_zero_count_cache[VAR_45] != 0 ||
VAR_0->non_zero_count_cache[VAR_45] != 0 ) {
bS[VAR_45] = 2;
}
else if(!VAR_39)
{
bS[VAR_45] = 0;
for( VAR_38 = 0; VAR_38 < 1 + (VAR_0->slice_type == B_TYPE); VAR_38++ ) {
if( VAR_13[VAR_0->ref_cache[VAR_38][VAR_45]+2] != VAR_13[VAR_0->ref_cache[VAR_38][VAR_45]+2] ||
FFABS( VAR_0->mv_cache[VAR_38][VAR_45][0] - VAR_0->mv_cache[VAR_38][VAR_45][0] ) >= 4 ||
FFABS( VAR_0->mv_cache[VAR_38][VAR_45][1] - VAR_0->mv_cache[VAR_38][VAR_45][1] ) >= VAR_10 ) {
bS[VAR_45] = 1;
break;
}
}
}
}
if(bS[0]+bS[1]+bS[2]+bS[3] == 0)
continue;
}
Do not use s->qscale as luma quantizer because it has not the same
VAR_37 in IPCM macroblocks.
VAR_37 = ( s->current_picture.qscale_table[VAR_8] + s->current_picture.qscale_table[VAR_36] + 1 ) >> 1;
tprintf(s->avctx, "filter mb:%d/%d VAR_12:%d VAR_24:%d, QPy:%d, QPc:%d, QPcn:%d\n", VAR_1, VAR_2, VAR_12, VAR_24, VAR_37, VAR_0->VAR_45, s->current_picture.qscale_table[VAR_36]);
tprintf(s->avctx, "filter mb:%d/%d VAR_12:%d VAR_24:%d, QPy:%d ls:%d uvls:%d", VAR_1, VAR_2, VAR_12, VAR_24, VAR_37, VAR_6, VAR_7);
{ int VAR_45; for (VAR_45 = 0; VAR_45 < 4; VAR_45++) tprintf(s->avctx, " bS[%d]:%d", VAR_45, bS[VAR_45]); tprintf(s->avctx, "\n"); }
if( VAR_12 == 0 ) {
filter_mb_edgev( VAR_0, &VAR_3[4*VAR_24], VAR_6, bS, VAR_37 );
if( (VAR_24&1) == 0 ) {
int VAR_45 = ( VAR_0->VAR_45 +
get_chroma_qp( VAR_0, s->current_picture.qscale_table[VAR_36] ) + 1 ) >> 1;
filter_mb_edgecv( VAR_0, &VAR_4[2*VAR_24], VAR_7, bS, VAR_45 );
filter_mb_edgecv( VAR_0, &VAR_5[2*VAR_24], VAR_7, bS, VAR_45 );
}
} else {
filter_mb_edgeh( VAR_0, &VAR_3[4*VAR_24*VAR_6], VAR_6, bS, VAR_37 );
if( (VAR_24&1) == 0 ) {
int VAR_45 = ( VAR_0->VAR_45 +
get_chroma_qp( VAR_0, s->current_picture.qscale_table[VAR_36] ) + 1 ) >> 1;
filter_mb_edgech( VAR_0, &VAR_4[2*VAR_24*VAR_7], VAR_7, bS, VAR_45 );
filter_mb_edgech( VAR_0, &VAR_5[2*VAR_24*VAR_7], VAR_7, bS, VAR_45 );
}
}
}
}
}
| [
"static void FUNC_0( H264Context *VAR_0, int VAR_1, int VAR_2, uint8_t *VAR_3, uint8_t *VAR_4, uint8_t *VAR_5, unsigned int VAR_6, unsigned int VAR_7) {",
"MpegEncContext * const s = &VAR_0->s;",
"const int VAR_8= VAR_1 + VAR_2*s->mb_stride;",
"const int VAR_9 = s->current_picture.VAR_9[VAR_8];",
"const int VAR_10 = IS_INTERLACED(VAR_9) ? 2 : 4;",
"int VAR_11 = 0;",
"int VAR_12;",
"static const int VAR_13[34] = {-1,-1,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};",
"if(!FRAME_MBAFF){",
"int VAR_14 = 15 - VAR_0->slice_alpha_c0_offset - FFMAX(0, VAR_0->pps.chroma_qp_index_offset);",
"int VAR_37 = s->current_picture.qscale_table[VAR_8];",
"if(VAR_37 <= VAR_14\n&& (VAR_1 == 0 || ((VAR_37 + s->current_picture.qscale_table[VAR_8-1] + 1)>>1) <= VAR_14)\n&& (VAR_2 == 0 || ((VAR_37 + s->current_picture.qscale_table[VAR_0->top_mb_xy] + 1)>>1) <= VAR_14)){",
"return;",
"}",
"}",
"if (FRAME_MBAFF\n&& VAR_0->slice_table[VAR_8-1] != 255\n&& (IS_INTERLACED(VAR_9) != IS_INTERLACED(s->current_picture.VAR_9[VAR_8-1]))\n&& (VAR_0->deblocking_filter!=2 || VAR_0->slice_table[VAR_8-1] == VAR_0->slice_table[VAR_8])) {",
"const int VAR_16 = VAR_1 + (VAR_2&~1)*s->mb_stride;",
"const int VAR_17[2] = { VAR_16-1, VAR_16-1+s->mb_stride };",
"int16_t bS[8];",
"int VAR_37[2];",
"int VAR_45[2];",
"int VAR_19, VAR_20, VAR_21;",
"int VAR_45;",
"VAR_11 = 1;",
"if( IS_INTRA(VAR_9) )\nbS[0] = bS[1] = bS[2] = bS[3] = bS[4] = bS[5] = bS[6] = bS[7] = 4;",
"else {",
"for( VAR_45 = 0; VAR_45 < 8; VAR_45++ ) {",
"int VAR_36 = MB_FIELD ? VAR_17[VAR_45>>2] : VAR_17[VAR_45&1];",
"if( IS_INTRA( s->current_picture.VAR_9[VAR_36] ) )\nbS[VAR_45] = 4;",
"else if( VAR_0->non_zero_count_cache[12+8*(VAR_45>>1)] != 0 ||\nVAR_0->non_zero_count[VAR_36][MB_FIELD ? VAR_45&3 : (VAR_45>>2)+(VAR_2&1)*2] )\nbS[VAR_45] = 2;",
"else\nbS[VAR_45] = 1;",
"}",
"}",
"VAR_19 = s->current_picture.qscale_table[VAR_8];",
"VAR_20 = s->current_picture.qscale_table[VAR_17[0]];",
"VAR_21 = s->current_picture.qscale_table[VAR_17[1]];",
"VAR_37[0] = ( VAR_19 + VAR_20 + 1 ) >> 1;",
"VAR_45[0] = ( get_chroma_qp( VAR_0, VAR_19 ) +\nget_chroma_qp( VAR_0, VAR_20 ) + 1 ) >> 1;",
"VAR_37[1] = ( VAR_19 + VAR_21 + 1 ) >> 1;",
"VAR_45[1] = ( get_chroma_qp( VAR_0, VAR_19 ) +\nget_chroma_qp( VAR_0, VAR_21 ) + 1 ) >> 1;",
"tprintf(s->avctx, \"filter mb:%d/%d MBAFF, QPy:%d/%d, QPc:%d/%d ls:%d uvls:%d\", VAR_1, VAR_2, VAR_37[0], VAR_37[1], VAR_45[0], VAR_45[1], VAR_6, VAR_7);",
"{ int VAR_45; for (VAR_45 = 0; VAR_45 < 8; VAR_45++) tprintf(s->avctx, \" bS[%d]:%d\", VAR_45, bS[VAR_45]); tprintf(s->avctx, \"\\n\"); }",
"filter_mb_mbaff_edgev ( VAR_0, &VAR_3 [0], VAR_6, bS, VAR_37 );",
"filter_mb_mbaff_edgecv( VAR_0, &VAR_4[0], VAR_7, bS, VAR_45 );",
"filter_mb_mbaff_edgecv( VAR_0, &VAR_5[0], VAR_7, bS, VAR_45 );",
"}",
"for( VAR_12 = 0; VAR_12 < 2; VAR_12++ )",
"{",
"int VAR_24;",
"const int VAR_25 = VAR_12 == 0 ? VAR_8 -1 : VAR_0->top_mb_xy;",
"const int VAR_26 = s->current_picture.VAR_9[VAR_25];",
"int VAR_27 = VAR_0->slice_table[VAR_25] == 255 ? 1 : 0;",
"const int VAR_28 = (VAR_9 & (MB_TYPE_16x16|MB_TYPE_SKIP))\n== (MB_TYPE_16x16|MB_TYPE_SKIP) ? 1 : 4;",
"const int VAR_29 = (VAR_9 & (MB_TYPE_16x16 | (MB_TYPE_16x8 << VAR_12))) ? 3 :\n(VAR_9 & (MB_TYPE_8x16 >> VAR_12)) ? 1 : 0;",
"const int VAR_30 = VAR_9 & (MB_TYPE_16x16 | (MB_TYPE_8x16 >> VAR_12));",
"if (VAR_11) {",
"VAR_27 = 1;",
"VAR_11 = 0;",
"}",
"if (VAR_0->deblocking_filter==2 && VAR_0->slice_table[VAR_25] != VAR_0->slice_table[VAR_8])\nVAR_27 = 1;",
"if (FRAME_MBAFF && (VAR_12 == 1) && ((VAR_2&1) == 0) && VAR_27 == 0\n&& !IS_INTERLACED(VAR_9)\n&& IS_INTERLACED(VAR_26)\n) {",
"static const int VAR_31[4] = {4,5,6,3};",
"unsigned int VAR_32 = 2 * VAR_6;",
"unsigned int VAR_33 = 2 * VAR_7;",
"int VAR_36 = VAR_8 - 2 * s->mb_stride;",
"int VAR_37, VAR_45;",
"int VAR_45, VAR_34;",
"int16_t bS[4];",
"for(VAR_34=0; VAR_34<2; VAR_34++, VAR_36 += s->mb_stride){",
"if( IS_INTRA(VAR_9) ||\nIS_INTRA(s->current_picture.VAR_9[VAR_36]) ) {",
"bS[0] = bS[1] = bS[2] = bS[3] = 3;",
"} else {",
"const uint8_t *VAR_35 = VAR_0->non_zero_count[VAR_36];",
"for( VAR_45 = 0; VAR_45 < 4; VAR_45++ ) {",
"if( VAR_0->non_zero_count_cache[scan8[0]+VAR_45] != 0 ||\nVAR_35[VAR_31[VAR_45]] != 0 )\nbS[VAR_45] = 2;",
"else\nbS[VAR_45] = 1;",
"}",
"}",
"Do not use s->qscale as luma quantizer because it has not the same\nVAR_37 in IPCM macroblocks.\nVAR_37 = ( s->current_picture.qscale_table[VAR_8] + s->current_picture.qscale_table[VAR_36] + 1 ) >> 1;",
"tprintf(s->avctx, \"filter mb:%d/%d VAR_12:%d VAR_24:%d, QPy:%d ls:%d uvls:%d\", VAR_1, VAR_2, VAR_12, VAR_24, VAR_37, VAR_32, VAR_33);",
"{ int VAR_45; for (VAR_45 = 0; VAR_45 < 4; VAR_45++) tprintf(s->avctx, \" bS[%d]:%d\", VAR_45, bS[VAR_45]); tprintf(s->avctx, \"\\n\"); }",
"filter_mb_edgeh( VAR_0, &VAR_3[VAR_34*VAR_6], VAR_32, bS, VAR_37 );",
"VAR_45 = ( VAR_0->VAR_45 +\nget_chroma_qp( VAR_0, s->current_picture.qscale_table[VAR_36] ) + 1 ) >> 1;",
"filter_mb_edgech( VAR_0, &VAR_4[VAR_34*VAR_7], VAR_33, bS, VAR_45 );",
"filter_mb_edgech( VAR_0, &VAR_5[VAR_34*VAR_7], VAR_33, bS, VAR_45 );",
"}",
"VAR_27 = 1;",
"}",
"for( VAR_24 = VAR_27; VAR_24 < VAR_28; VAR_24++ ) {",
"const int VAR_36 = VAR_24 > 0 ? VAR_8 : VAR_25;",
"const int VAR_36 = s->current_picture.VAR_9[VAR_36];",
"int16_t bS[4];",
"int VAR_37;",
"if( (VAR_24&1) && IS_8x8DCT(VAR_9) )\ncontinue;",
"if( IS_INTRA(VAR_9) ||\nIS_INTRA(VAR_36) ) {",
"int VAR_37;",
"if (VAR_24 == 0) {",
"if ( (!IS_INTERLACED(VAR_9) && !IS_INTERLACED(VAR_26))\n|| ((FRAME_MBAFF || (s->picture_structure != PICT_FRAME)) && (VAR_12 == 0))\n) {",
"VAR_37 = 4;",
"} else {",
"VAR_37 = 3;",
"}",
"} else {",
"VAR_37 = 3;",
"}",
"bS[0] = bS[1] = bS[2] = bS[3] = VAR_37;",
"} else {",
"int VAR_45, VAR_38;",
"int VAR_39;",
"if( VAR_24 & VAR_29 ) {",
"bS[0] = bS[1] = bS[2] = bS[3] = 0;",
"VAR_39 = 1;",
"}",
"else if( FRAME_MBAFF && IS_INTERLACED(VAR_9 ^ VAR_36)) {",
"bS[0] = bS[1] = bS[2] = bS[3] = 1;",
"VAR_39 = 1;",
"}",
"else if( VAR_30 && (VAR_24 || (VAR_36 & (MB_TYPE_16x16 | (MB_TYPE_8x16 >> VAR_12)))) ) {",
"int VAR_45= 8 + 4 + VAR_24 * (VAR_12 ? 8:1);",
"int VAR_45= VAR_45 - (VAR_12 ? 8:1);",
"int VAR_42 = 0;",
"for( VAR_38 = 0; !VAR_42 && VAR_38 < 1 + (VAR_0->slice_type == B_TYPE); VAR_38++ ) {",
"VAR_42 |= VAR_13[VAR_0->ref_cache[VAR_38][VAR_45]+2] != VAR_13[VAR_0->ref_cache[VAR_38][VAR_45]+2] ||\nFFABS( VAR_0->mv_cache[VAR_38][VAR_45][0] - VAR_0->mv_cache[VAR_38][VAR_45][0] ) >= 4 ||\nFFABS( VAR_0->mv_cache[VAR_38][VAR_45][1] - VAR_0->mv_cache[VAR_38][VAR_45][1] ) >= VAR_10;",
"}",
"bS[0] = bS[1] = bS[2] = bS[3] = VAR_42;",
"VAR_39 = 1;",
"}",
"else\nVAR_39 = 0;",
"for( VAR_45 = 0; VAR_45 < 4; VAR_45++ ) {",
"int VAR_43 = VAR_12 == 0 ? VAR_24 : VAR_45;",
"int VAR_44 = VAR_12 == 0 ? VAR_45 : VAR_24;",
"int VAR_45= 8 + 4 + VAR_43 + 8*VAR_44;",
"int VAR_45= VAR_45 - (VAR_12 ? 8:1);",
"if( VAR_0->non_zero_count_cache[VAR_45] != 0 ||\nVAR_0->non_zero_count_cache[VAR_45] != 0 ) {",
"bS[VAR_45] = 2;",
"}",
"else if(!VAR_39)\n{",
"bS[VAR_45] = 0;",
"for( VAR_38 = 0; VAR_38 < 1 + (VAR_0->slice_type == B_TYPE); VAR_38++ ) {",
"if( VAR_13[VAR_0->ref_cache[VAR_38][VAR_45]+2] != VAR_13[VAR_0->ref_cache[VAR_38][VAR_45]+2] ||\nFFABS( VAR_0->mv_cache[VAR_38][VAR_45][0] - VAR_0->mv_cache[VAR_38][VAR_45][0] ) >= 4 ||\nFFABS( VAR_0->mv_cache[VAR_38][VAR_45][1] - VAR_0->mv_cache[VAR_38][VAR_45][1] ) >= VAR_10 ) {",
"bS[VAR_45] = 1;",
"break;",
"}",
"}",
"}",
"}",
"if(bS[0]+bS[1]+bS[2]+bS[3] == 0)\ncontinue;",
"}",
"Do not use s->qscale as luma quantizer because it has not the same\nVAR_37 in IPCM macroblocks.\nVAR_37 = ( s->current_picture.qscale_table[VAR_8] + s->current_picture.qscale_table[VAR_36] + 1 ) >> 1;",
"tprintf(s->avctx, \"filter mb:%d/%d VAR_12:%d VAR_24:%d, QPy:%d, QPc:%d, QPcn:%d\\n\", VAR_1, VAR_2, VAR_12, VAR_24, VAR_37, VAR_0->VAR_45, s->current_picture.qscale_table[VAR_36]);",
"tprintf(s->avctx, \"filter mb:%d/%d VAR_12:%d VAR_24:%d, QPy:%d ls:%d uvls:%d\", VAR_1, VAR_2, VAR_12, VAR_24, VAR_37, VAR_6, VAR_7);",
"{ int VAR_45; for (VAR_45 = 0; VAR_45 < 4; VAR_45++) tprintf(s->avctx, \" bS[%d]:%d\", VAR_45, bS[VAR_45]); tprintf(s->avctx, \"\\n\"); }",
"if( VAR_12 == 0 ) {",
"filter_mb_edgev( VAR_0, &VAR_3[4*VAR_24], VAR_6, bS, VAR_37 );",
"if( (VAR_24&1) == 0 ) {",
"int VAR_45 = ( VAR_0->VAR_45 +\nget_chroma_qp( VAR_0, s->current_picture.qscale_table[VAR_36] ) + 1 ) >> 1;",
"filter_mb_edgecv( VAR_0, &VAR_4[2*VAR_24], VAR_7, bS, VAR_45 );",
"filter_mb_edgecv( VAR_0, &VAR_5[2*VAR_24], VAR_7, bS, VAR_45 );",
"}",
"} else {",
"filter_mb_edgeh( VAR_0, &VAR_3[4*VAR_24*VAR_6], VAR_6, bS, VAR_37 );",
"if( (VAR_24&1) == 0 ) {",
"int VAR_45 = ( VAR_0->VAR_45 +\nget_chroma_qp( VAR_0, s->current_picture.qscale_table[VAR_36] ) + 1 ) >> 1;",
"filter_mb_edgech( VAR_0, &VAR_4[2*VAR_24*VAR_7], VAR_7, bS, VAR_45 );",
"filter_mb_edgech( VAR_0, &VAR_5[2*VAR_24*VAR_7], VAR_7, bS, VAR_45 );",
"}",
"}",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
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,
1,
0,
1,
1,
0,
0,
1,
1,
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,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0
] | [
[
1
],
[
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
21
],
[
23
],
[
31
],
[
33
],
[
35
],
[
37,
39,
41
],
[
43
],
[
45
],
[
47
],
[
51,
55,
59,
63
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89,
91
],
[
93
],
[
95
],
[
97
],
[
101,
103
],
[
105,
109,
111
],
[
113,
115
],
[
117
],
[
119
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131,
133
],
[
135
],
[
137,
139
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
173,
175
],
[
179,
181
],
[
185
],
[
189
],
[
191
],
[
193
],
[
195
],
[
199,
201
],
[
205,
207,
209,
211
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
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
],
[
289
],
[
291
],
[
297
],
[
301
],
[
303
],
[
305
],
[
307
],
[
311,
313
],
[
317,
319
],
[
321
],
[
323
],
[
325,
327,
329
],
[
331
],
[
333
],
[
335
],
[
337
],
[
339
],
[
341
],
[
343
],
[
345
],
[
347
],
[
349
],
[
351
],
[
355
],
[
357
],
[
359
],
[
361
],
[
363
],
[
365
],
[
367
],
[
369
],
[
371
],
[
373
],
[
375
],
[
377
],
[
379
],
[
381,
383,
385
],
[
387
],
[
389
],
[
391
],
[
393
],
[
395,
397
],
[
401
],
[
403
],
[
405
],
[
407
],
[
409
],
[
413,
415
],
[
417
],
[
419
],
[
421,
423
],
[
425
],
[
427
],
[
429,
431,
433
],
[
435
],
[
437
],
[
439
],
[
441
],
[
443
],
[
445
],
[
449,
451
],
[
453
],
[
459,
461,
463
],
[
465
],
[
467
],
[
469
],
[
471
],
[
473
],
[
475
],
[
477,
479
],
[
481
],
[
483
],
[
485
],
[
487
],
[
489
],
[
491
],
[
493,
495
],
[
497
],
[
499
],
[
501
],
[
503
],
[
505
],
[
507
],
[
509
]
] |
21,131 | static void select_frame(AVFilterContext *ctx, AVFrame *frame)
{
SelectContext *select = ctx->priv;
AVFilterLink *inlink = ctx->inputs[0];
double res;
if (isnan(select->var_values[VAR_START_PTS]))
select->var_values[VAR_START_PTS] = TS2D(frame->pts);
if (isnan(select->var_values[VAR_START_T]))
select->var_values[VAR_START_T] = TS2D(frame->pts) * av_q2d(inlink->time_base);
select->var_values[VAR_N ] = inlink->frame_count;
select->var_values[VAR_PTS] = TS2D(frame->pts);
select->var_values[VAR_T ] = TS2D(frame->pts) * av_q2d(inlink->time_base);
select->var_values[VAR_POS] = av_frame_get_pkt_pos(frame) == -1 ? NAN : av_frame_get_pkt_pos(frame);
switch (inlink->type) {
case AVMEDIA_TYPE_AUDIO:
select->var_values[VAR_SAMPLES_N] = frame->nb_samples;
break;
case AVMEDIA_TYPE_VIDEO:
select->var_values[VAR_INTERLACE_TYPE] =
!frame->interlaced_frame ? INTERLACE_TYPE_P :
frame->top_field_first ? INTERLACE_TYPE_T : INTERLACE_TYPE_B;
select->var_values[VAR_PICT_TYPE] = frame->pict_type;
#if CONFIG_AVCODEC
if (select->do_scene_detect) {
char buf[32];
select->var_values[VAR_SCENE] = get_scene_score(ctx, frame);
// TODO: document metadata
snprintf(buf, sizeof(buf), "%f", select->var_values[VAR_SCENE]);
av_dict_set(avpriv_frame_get_metadatap(frame), "lavfi.scene_score", buf, 0);
}
#endif
break;
}
select->select = res = av_expr_eval(select->expr, select->var_values, NULL);
av_log(inlink->dst, AV_LOG_DEBUG,
"n:%f pts:%f t:%f key:%d",
select->var_values[VAR_N],
select->var_values[VAR_PTS],
select->var_values[VAR_T],
(int)select->var_values[VAR_KEY]);
switch (inlink->type) {
case AVMEDIA_TYPE_VIDEO:
av_log(inlink->dst, AV_LOG_DEBUG, " interlace_type:%c pict_type:%c scene:%f",
select->var_values[VAR_INTERLACE_TYPE] == INTERLACE_TYPE_P ? 'P' :
select->var_values[VAR_INTERLACE_TYPE] == INTERLACE_TYPE_T ? 'T' :
select->var_values[VAR_INTERLACE_TYPE] == INTERLACE_TYPE_B ? 'B' : '?',
av_get_picture_type_char(select->var_values[VAR_PICT_TYPE]),
select->var_values[VAR_SCENE]);
break;
case AVMEDIA_TYPE_AUDIO:
av_log(inlink->dst, AV_LOG_DEBUG, " samples_n:%d consumed_samples_n:%d",
(int)select->var_values[VAR_SAMPLES_N],
(int)select->var_values[VAR_CONSUMED_SAMPLES_N]);
break;
}
if (res == 0) {
select->select_out = -1; /* drop */
} else if (isnan(res) || res < 0) {
select->select_out = 0; /* first output */
} else {
select->select_out = FFMIN(ceilf(res)-1, select->nb_outputs-1); /* other outputs */
}
av_log(inlink->dst, AV_LOG_DEBUG, " -> select:%f select_out:%d\n", res, select->select_out);
if (res) {
select->var_values[VAR_PREV_SELECTED_N] = select->var_values[VAR_N];
select->var_values[VAR_PREV_SELECTED_PTS] = select->var_values[VAR_PTS];
select->var_values[VAR_PREV_SELECTED_T] = select->var_values[VAR_T];
select->var_values[VAR_SELECTED_N] += 1.0;
if (inlink->type == AVMEDIA_TYPE_AUDIO)
select->var_values[VAR_CONSUMED_SAMPLES_N] += frame->nb_samples;
}
select->var_values[VAR_PREV_PTS] = select->var_values[VAR_PTS];
select->var_values[VAR_PREV_T] = select->var_values[VAR_T];
}
| false | FFmpeg | 887d8d293fc31c949427f971f37c126b3812b451 | static void select_frame(AVFilterContext *ctx, AVFrame *frame)
{
SelectContext *select = ctx->priv;
AVFilterLink *inlink = ctx->inputs[0];
double res;
if (isnan(select->var_values[VAR_START_PTS]))
select->var_values[VAR_START_PTS] = TS2D(frame->pts);
if (isnan(select->var_values[VAR_START_T]))
select->var_values[VAR_START_T] = TS2D(frame->pts) * av_q2d(inlink->time_base);
select->var_values[VAR_N ] = inlink->frame_count;
select->var_values[VAR_PTS] = TS2D(frame->pts);
select->var_values[VAR_T ] = TS2D(frame->pts) * av_q2d(inlink->time_base);
select->var_values[VAR_POS] = av_frame_get_pkt_pos(frame) == -1 ? NAN : av_frame_get_pkt_pos(frame);
switch (inlink->type) {
case AVMEDIA_TYPE_AUDIO:
select->var_values[VAR_SAMPLES_N] = frame->nb_samples;
break;
case AVMEDIA_TYPE_VIDEO:
select->var_values[VAR_INTERLACE_TYPE] =
!frame->interlaced_frame ? INTERLACE_TYPE_P :
frame->top_field_first ? INTERLACE_TYPE_T : INTERLACE_TYPE_B;
select->var_values[VAR_PICT_TYPE] = frame->pict_type;
#if CONFIG_AVCODEC
if (select->do_scene_detect) {
char buf[32];
select->var_values[VAR_SCENE] = get_scene_score(ctx, frame);
snprintf(buf, sizeof(buf), "%f", select->var_values[VAR_SCENE]);
av_dict_set(avpriv_frame_get_metadatap(frame), "lavfi.scene_score", buf, 0);
}
#endif
break;
}
select->select = res = av_expr_eval(select->expr, select->var_values, NULL);
av_log(inlink->dst, AV_LOG_DEBUG,
"n:%f pts:%f t:%f key:%d",
select->var_values[VAR_N],
select->var_values[VAR_PTS],
select->var_values[VAR_T],
(int)select->var_values[VAR_KEY]);
switch (inlink->type) {
case AVMEDIA_TYPE_VIDEO:
av_log(inlink->dst, AV_LOG_DEBUG, " interlace_type:%c pict_type:%c scene:%f",
select->var_values[VAR_INTERLACE_TYPE] == INTERLACE_TYPE_P ? 'P' :
select->var_values[VAR_INTERLACE_TYPE] == INTERLACE_TYPE_T ? 'T' :
select->var_values[VAR_INTERLACE_TYPE] == INTERLACE_TYPE_B ? 'B' : '?',
av_get_picture_type_char(select->var_values[VAR_PICT_TYPE]),
select->var_values[VAR_SCENE]);
break;
case AVMEDIA_TYPE_AUDIO:
av_log(inlink->dst, AV_LOG_DEBUG, " samples_n:%d consumed_samples_n:%d",
(int)select->var_values[VAR_SAMPLES_N],
(int)select->var_values[VAR_CONSUMED_SAMPLES_N]);
break;
}
if (res == 0) {
select->select_out = -1;
} else if (isnan(res) || res < 0) {
select->select_out = 0;
} else {
select->select_out = FFMIN(ceilf(res)-1, select->nb_outputs-1);
}
av_log(inlink->dst, AV_LOG_DEBUG, " -> select:%f select_out:%d\n", res, select->select_out);
if (res) {
select->var_values[VAR_PREV_SELECTED_N] = select->var_values[VAR_N];
select->var_values[VAR_PREV_SELECTED_PTS] = select->var_values[VAR_PTS];
select->var_values[VAR_PREV_SELECTED_T] = select->var_values[VAR_T];
select->var_values[VAR_SELECTED_N] += 1.0;
if (inlink->type == AVMEDIA_TYPE_AUDIO)
select->var_values[VAR_CONSUMED_SAMPLES_N] += frame->nb_samples;
}
select->var_values[VAR_PREV_PTS] = select->var_values[VAR_PTS];
select->var_values[VAR_PREV_T] = select->var_values[VAR_T];
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(AVFilterContext *VAR_0, AVFrame *VAR_1)
{
SelectContext *select = VAR_0->priv;
AVFilterLink *inlink = VAR_0->inputs[0];
double VAR_2;
if (isnan(select->var_values[VAR_START_PTS]))
select->var_values[VAR_START_PTS] = TS2D(VAR_1->pts);
if (isnan(select->var_values[VAR_START_T]))
select->var_values[VAR_START_T] = TS2D(VAR_1->pts) * av_q2d(inlink->time_base);
select->var_values[VAR_N ] = inlink->frame_count;
select->var_values[VAR_PTS] = TS2D(VAR_1->pts);
select->var_values[VAR_T ] = TS2D(VAR_1->pts) * av_q2d(inlink->time_base);
select->var_values[VAR_POS] = av_frame_get_pkt_pos(VAR_1) == -1 ? NAN : av_frame_get_pkt_pos(VAR_1);
switch (inlink->type) {
case AVMEDIA_TYPE_AUDIO:
select->var_values[VAR_SAMPLES_N] = VAR_1->nb_samples;
break;
case AVMEDIA_TYPE_VIDEO:
select->var_values[VAR_INTERLACE_TYPE] =
!VAR_1->interlaced_frame ? INTERLACE_TYPE_P :
VAR_1->top_field_first ? INTERLACE_TYPE_T : INTERLACE_TYPE_B;
select->var_values[VAR_PICT_TYPE] = VAR_1->pict_type;
#if CONFIG_AVCODEC
if (select->do_scene_detect) {
char buf[32];
select->var_values[VAR_SCENE] = get_scene_score(VAR_0, VAR_1);
snprintf(buf, sizeof(buf), "%f", select->var_values[VAR_SCENE]);
av_dict_set(avpriv_frame_get_metadatap(VAR_1), "lavfi.scene_score", buf, 0);
}
#endif
break;
}
select->select = VAR_2 = av_expr_eval(select->expr, select->var_values, NULL);
av_log(inlink->dst, AV_LOG_DEBUG,
"n:%f pts:%f t:%f key:%d",
select->var_values[VAR_N],
select->var_values[VAR_PTS],
select->var_values[VAR_T],
(int)select->var_values[VAR_KEY]);
switch (inlink->type) {
case AVMEDIA_TYPE_VIDEO:
av_log(inlink->dst, AV_LOG_DEBUG, " interlace_type:%c pict_type:%c scene:%f",
select->var_values[VAR_INTERLACE_TYPE] == INTERLACE_TYPE_P ? 'P' :
select->var_values[VAR_INTERLACE_TYPE] == INTERLACE_TYPE_T ? 'T' :
select->var_values[VAR_INTERLACE_TYPE] == INTERLACE_TYPE_B ? 'B' : '?',
av_get_picture_type_char(select->var_values[VAR_PICT_TYPE]),
select->var_values[VAR_SCENE]);
break;
case AVMEDIA_TYPE_AUDIO:
av_log(inlink->dst, AV_LOG_DEBUG, " samples_n:%d consumed_samples_n:%d",
(int)select->var_values[VAR_SAMPLES_N],
(int)select->var_values[VAR_CONSUMED_SAMPLES_N]);
break;
}
if (VAR_2 == 0) {
select->select_out = -1;
} else if (isnan(VAR_2) || VAR_2 < 0) {
select->select_out = 0;
} else {
select->select_out = FFMIN(ceilf(VAR_2)-1, select->nb_outputs-1);
}
av_log(inlink->dst, AV_LOG_DEBUG, " -> select:%f select_out:%d\n", VAR_2, select->select_out);
if (VAR_2) {
select->var_values[VAR_PREV_SELECTED_N] = select->var_values[VAR_N];
select->var_values[VAR_PREV_SELECTED_PTS] = select->var_values[VAR_PTS];
select->var_values[VAR_PREV_SELECTED_T] = select->var_values[VAR_T];
select->var_values[VAR_SELECTED_N] += 1.0;
if (inlink->type == AVMEDIA_TYPE_AUDIO)
select->var_values[VAR_CONSUMED_SAMPLES_N] += VAR_1->nb_samples;
}
select->var_values[VAR_PREV_PTS] = select->var_values[VAR_PTS];
select->var_values[VAR_PREV_T] = select->var_values[VAR_T];
}
| [
"static void FUNC_0(AVFilterContext *VAR_0, AVFrame *VAR_1)\n{",
"SelectContext *select = VAR_0->priv;",
"AVFilterLink *inlink = VAR_0->inputs[0];",
"double VAR_2;",
"if (isnan(select->var_values[VAR_START_PTS]))\nselect->var_values[VAR_START_PTS] = TS2D(VAR_1->pts);",
"if (isnan(select->var_values[VAR_START_T]))\nselect->var_values[VAR_START_T] = TS2D(VAR_1->pts) * av_q2d(inlink->time_base);",
"select->var_values[VAR_N ] = inlink->frame_count;",
"select->var_values[VAR_PTS] = TS2D(VAR_1->pts);",
"select->var_values[VAR_T ] = TS2D(VAR_1->pts) * av_q2d(inlink->time_base);",
"select->var_values[VAR_POS] = av_frame_get_pkt_pos(VAR_1) == -1 ? NAN : av_frame_get_pkt_pos(VAR_1);",
"switch (inlink->type) {",
"case AVMEDIA_TYPE_AUDIO:\nselect->var_values[VAR_SAMPLES_N] = VAR_1->nb_samples;",
"break;",
"case AVMEDIA_TYPE_VIDEO:\nselect->var_values[VAR_INTERLACE_TYPE] =\n!VAR_1->interlaced_frame ? INTERLACE_TYPE_P :\nVAR_1->top_field_first ? INTERLACE_TYPE_T : INTERLACE_TYPE_B;",
"select->var_values[VAR_PICT_TYPE] = VAR_1->pict_type;",
"#if CONFIG_AVCODEC\nif (select->do_scene_detect) {",
"char buf[32];",
"select->var_values[VAR_SCENE] = get_scene_score(VAR_0, VAR_1);",
"snprintf(buf, sizeof(buf), \"%f\", select->var_values[VAR_SCENE]);",
"av_dict_set(avpriv_frame_get_metadatap(VAR_1), \"lavfi.scene_score\", buf, 0);",
"}",
"#endif\nbreak;",
"}",
"select->select = VAR_2 = av_expr_eval(select->expr, select->var_values, NULL);",
"av_log(inlink->dst, AV_LOG_DEBUG,\n\"n:%f pts:%f t:%f key:%d\",\nselect->var_values[VAR_N],\nselect->var_values[VAR_PTS],\nselect->var_values[VAR_T],\n(int)select->var_values[VAR_KEY]);",
"switch (inlink->type) {",
"case AVMEDIA_TYPE_VIDEO:\nav_log(inlink->dst, AV_LOG_DEBUG, \" interlace_type:%c pict_type:%c scene:%f\",\nselect->var_values[VAR_INTERLACE_TYPE] == INTERLACE_TYPE_P ? 'P' :\nselect->var_values[VAR_INTERLACE_TYPE] == INTERLACE_TYPE_T ? 'T' :\nselect->var_values[VAR_INTERLACE_TYPE] == INTERLACE_TYPE_B ? 'B' : '?',\nav_get_picture_type_char(select->var_values[VAR_PICT_TYPE]),\nselect->var_values[VAR_SCENE]);",
"break;",
"case AVMEDIA_TYPE_AUDIO:\nav_log(inlink->dst, AV_LOG_DEBUG, \" samples_n:%d consumed_samples_n:%d\",\n(int)select->var_values[VAR_SAMPLES_N],\n(int)select->var_values[VAR_CONSUMED_SAMPLES_N]);",
"break;",
"}",
"if (VAR_2 == 0) {",
"select->select_out = -1;",
"} else if (isnan(VAR_2) || VAR_2 < 0) {",
"select->select_out = 0;",
"} else {",
"select->select_out = FFMIN(ceilf(VAR_2)-1, select->nb_outputs-1);",
"}",
"av_log(inlink->dst, AV_LOG_DEBUG, \" -> select:%f select_out:%d\\n\", VAR_2, select->select_out);",
"if (VAR_2) {",
"select->var_values[VAR_PREV_SELECTED_N] = select->var_values[VAR_N];",
"select->var_values[VAR_PREV_SELECTED_PTS] = select->var_values[VAR_PTS];",
"select->var_values[VAR_PREV_SELECTED_T] = select->var_values[VAR_T];",
"select->var_values[VAR_SELECTED_N] += 1.0;",
"if (inlink->type == AVMEDIA_TYPE_AUDIO)\nselect->var_values[VAR_CONSUMED_SAMPLES_N] += VAR_1->nb_samples;",
"}",
"select->var_values[VAR_PREV_PTS] = select->var_values[VAR_PTS];",
"select->var_values[VAR_PREV_T] = select->var_values[VAR_T];",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35,
37
],
[
39
],
[
43,
45,
47,
49
],
[
51
],
[
53,
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69,
71
],
[
73
],
[
77
],
[
79,
81,
83,
85,
87,
89
],
[
93
],
[
95,
97,
99,
101,
103,
105,
107
],
[
109
],
[
111,
113,
115,
117
],
[
119
],
[
121
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
141
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155,
157
],
[
159
],
[
163
],
[
165
],
[
167
]
] |
21,132 | static int libkvazaar_encode(AVCodecContext *avctx,
AVPacket *avpkt,
const AVFrame *frame,
int *got_packet_ptr)
{
int retval = 0;
kvz_picture *img_in = NULL;
kvz_data_chunk *data_out = NULL;
uint32_t len_out = 0;
kvz_frame_info frame_info;
LibkvazaarContext *ctx = avctx->priv_data;
*got_packet_ptr = 0;
if (frame) {
int i = 0;
av_assert0(frame->width == ctx->config->width);
av_assert0(frame->height == ctx->config->height);
av_assert0(frame->format == avctx->pix_fmt);
// Allocate input picture for kvazaar.
img_in = ctx->api->picture_alloc(frame->width, frame->height);
if (!img_in) {
av_log(avctx, AV_LOG_ERROR, "Failed to allocate picture.\n");
retval = AVERROR(ENOMEM);
goto done;
}
// Copy pixels from frame to img_in.
for (i = 0; i < 3; ++i) {
uint8_t *dst = img_in->data[i];
uint8_t *src = frame->data[i];
int width = (i == 0) ? frame->width : (frame->width / 2);
int height = (i == 0) ? frame->height : (frame->height / 2);
int y = 0;
for (y = 0; y < height; ++y) {
memcpy(dst, src, width);
src += frame->linesize[i];
dst += width;
}
}
}
if (!ctx->api->encoder_encode(ctx->encoder, img_in,
&data_out, &len_out,
NULL, NULL,
&frame_info)) {
av_log(avctx, AV_LOG_ERROR, "Failed to encode frame.\n");
retval = AVERROR_EXTERNAL;
goto done;
}
if (data_out) {
kvz_data_chunk *chunk = NULL;
uint64_t written = 0;
retval = ff_alloc_packet(avpkt, len_out);
if (retval < 0) {
av_log(avctx, AV_LOG_ERROR, "Failed to allocate output packet.\n");
goto done;
}
for (chunk = data_out; chunk != NULL; chunk = chunk->next) {
av_assert0(written + chunk->len <= len_out);
memcpy(avpkt->data + written, chunk->data, chunk->len);
written += chunk->len;
}
*got_packet_ptr = 1;
ctx->api->chunk_free(data_out);
data_out = NULL;
avpkt->flags = 0;
// IRAP VCL NAL unit types span the range
// [BLA_W_LP (16), RSV_IRAP_VCL23 (23)].
if (frame_info.nal_unit_type >= KVZ_NAL_BLA_W_LP &&
frame_info.nal_unit_type <= KVZ_NAL_RSV_IRAP_VCL23) {
avpkt->flags |= AV_PKT_FLAG_KEY;
}
}
done:
ctx->api->picture_free(img_in);
ctx->api->chunk_free(data_out);
return retval;
}
| true | FFmpeg | c09419ca80f1b1de4ceb3b9c06f708914150fa45 | static int libkvazaar_encode(AVCodecContext *avctx,
AVPacket *avpkt,
const AVFrame *frame,
int *got_packet_ptr)
{
int retval = 0;
kvz_picture *img_in = NULL;
kvz_data_chunk *data_out = NULL;
uint32_t len_out = 0;
kvz_frame_info frame_info;
LibkvazaarContext *ctx = avctx->priv_data;
*got_packet_ptr = 0;
if (frame) {
int i = 0;
av_assert0(frame->width == ctx->config->width);
av_assert0(frame->height == ctx->config->height);
av_assert0(frame->format == avctx->pix_fmt);
img_in = ctx->api->picture_alloc(frame->width, frame->height);
if (!img_in) {
av_log(avctx, AV_LOG_ERROR, "Failed to allocate picture.\n");
retval = AVERROR(ENOMEM);
goto done;
}
for (i = 0; i < 3; ++i) {
uint8_t *dst = img_in->data[i];
uint8_t *src = frame->data[i];
int width = (i == 0) ? frame->width : (frame->width / 2);
int height = (i == 0) ? frame->height : (frame->height / 2);
int y = 0;
for (y = 0; y < height; ++y) {
memcpy(dst, src, width);
src += frame->linesize[i];
dst += width;
}
}
}
if (!ctx->api->encoder_encode(ctx->encoder, img_in,
&data_out, &len_out,
NULL, NULL,
&frame_info)) {
av_log(avctx, AV_LOG_ERROR, "Failed to encode frame.\n");
retval = AVERROR_EXTERNAL;
goto done;
}
if (data_out) {
kvz_data_chunk *chunk = NULL;
uint64_t written = 0;
retval = ff_alloc_packet(avpkt, len_out);
if (retval < 0) {
av_log(avctx, AV_LOG_ERROR, "Failed to allocate output packet.\n");
goto done;
}
for (chunk = data_out; chunk != NULL; chunk = chunk->next) {
av_assert0(written + chunk->len <= len_out);
memcpy(avpkt->data + written, chunk->data, chunk->len);
written += chunk->len;
}
*got_packet_ptr = 1;
ctx->api->chunk_free(data_out);
data_out = NULL;
avpkt->flags = 0;
if (frame_info.nal_unit_type >= KVZ_NAL_BLA_W_LP &&
frame_info.nal_unit_type <= KVZ_NAL_RSV_IRAP_VCL23) {
avpkt->flags |= AV_PKT_FLAG_KEY;
}
}
done:
ctx->api->picture_free(img_in);
ctx->api->chunk_free(data_out);
return retval;
}
| {
"code": [
" av_assert0(frame->width == ctx->config->width);",
" av_assert0(frame->height == ctx->config->height);",
" av_assert0(frame->format == avctx->pix_fmt);"
],
"line_no": [
39,
41,
43
]
} | static int FUNC_0(AVCodecContext *VAR_0,
AVPacket *VAR_1,
const AVFrame *VAR_2,
int *VAR_3)
{
int VAR_4 = 0;
kvz_picture *img_in = NULL;
kvz_data_chunk *data_out = NULL;
uint32_t len_out = 0;
kvz_frame_info frame_info;
LibkvazaarContext *ctx = VAR_0->priv_data;
*VAR_3 = 0;
if (VAR_2) {
int VAR_5 = 0;
av_assert0(VAR_2->VAR_6 == ctx->config->VAR_6);
av_assert0(VAR_2->VAR_7 == ctx->config->VAR_7);
av_assert0(VAR_2->format == VAR_0->pix_fmt);
img_in = ctx->api->picture_alloc(VAR_2->VAR_6, VAR_2->VAR_7);
if (!img_in) {
av_log(VAR_0, AV_LOG_ERROR, "Failed to allocate picture.\n");
VAR_4 = AVERROR(ENOMEM);
goto done;
}
for (VAR_5 = 0; VAR_5 < 3; ++VAR_5) {
uint8_t *dst = img_in->data[VAR_5];
uint8_t *src = VAR_2->data[VAR_5];
int VAR_6 = (VAR_5 == 0) ? VAR_2->VAR_6 : (VAR_2->VAR_6 / 2);
int VAR_7 = (VAR_5 == 0) ? VAR_2->VAR_7 : (VAR_2->VAR_7 / 2);
int VAR_8 = 0;
for (VAR_8 = 0; VAR_8 < VAR_7; ++VAR_8) {
memcpy(dst, src, VAR_6);
src += VAR_2->linesize[VAR_5];
dst += VAR_6;
}
}
}
if (!ctx->api->encoder_encode(ctx->encoder, img_in,
&data_out, &len_out,
NULL, NULL,
&frame_info)) {
av_log(VAR_0, AV_LOG_ERROR, "Failed to encode VAR_2.\n");
VAR_4 = AVERROR_EXTERNAL;
goto done;
}
if (data_out) {
kvz_data_chunk *chunk = NULL;
uint64_t written = 0;
VAR_4 = ff_alloc_packet(VAR_1, len_out);
if (VAR_4 < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Failed to allocate output packet.\n");
goto done;
}
for (chunk = data_out; chunk != NULL; chunk = chunk->next) {
av_assert0(written + chunk->len <= len_out);
memcpy(VAR_1->data + written, chunk->data, chunk->len);
written += chunk->len;
}
*VAR_3 = 1;
ctx->api->chunk_free(data_out);
data_out = NULL;
VAR_1->flags = 0;
if (frame_info.nal_unit_type >= KVZ_NAL_BLA_W_LP &&
frame_info.nal_unit_type <= KVZ_NAL_RSV_IRAP_VCL23) {
VAR_1->flags |= AV_PKT_FLAG_KEY;
}
}
done:
ctx->api->picture_free(img_in);
ctx->api->chunk_free(data_out);
return VAR_4;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0,\nAVPacket *VAR_1,\nconst AVFrame *VAR_2,\nint *VAR_3)\n{",
"int VAR_4 = 0;",
"kvz_picture *img_in = NULL;",
"kvz_data_chunk *data_out = NULL;",
"uint32_t len_out = 0;",
"kvz_frame_info frame_info;",
"LibkvazaarContext *ctx = VAR_0->priv_data;",
"*VAR_3 = 0;",
"if (VAR_2) {",
"int VAR_5 = 0;",
"av_assert0(VAR_2->VAR_6 == ctx->config->VAR_6);",
"av_assert0(VAR_2->VAR_7 == ctx->config->VAR_7);",
"av_assert0(VAR_2->format == VAR_0->pix_fmt);",
"img_in = ctx->api->picture_alloc(VAR_2->VAR_6, VAR_2->VAR_7);",
"if (!img_in) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Failed to allocate picture.\\n\");",
"VAR_4 = AVERROR(ENOMEM);",
"goto done;",
"}",
"for (VAR_5 = 0; VAR_5 < 3; ++VAR_5) {",
"uint8_t *dst = img_in->data[VAR_5];",
"uint8_t *src = VAR_2->data[VAR_5];",
"int VAR_6 = (VAR_5 == 0) ? VAR_2->VAR_6 : (VAR_2->VAR_6 / 2);",
"int VAR_7 = (VAR_5 == 0) ? VAR_2->VAR_7 : (VAR_2->VAR_7 / 2);",
"int VAR_8 = 0;",
"for (VAR_8 = 0; VAR_8 < VAR_7; ++VAR_8) {",
"memcpy(dst, src, VAR_6);",
"src += VAR_2->linesize[VAR_5];",
"dst += VAR_6;",
"}",
"}",
"}",
"if (!ctx->api->encoder_encode(ctx->encoder, img_in,\n&data_out, &len_out,\nNULL, NULL,\n&frame_info)) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Failed to encode VAR_2.\\n\");",
"VAR_4 = AVERROR_EXTERNAL;",
"goto done;",
"}",
"if (data_out) {",
"kvz_data_chunk *chunk = NULL;",
"uint64_t written = 0;",
"VAR_4 = ff_alloc_packet(VAR_1, len_out);",
"if (VAR_4 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Failed to allocate output packet.\\n\");",
"goto done;",
"}",
"for (chunk = data_out; chunk != NULL; chunk = chunk->next) {",
"av_assert0(written + chunk->len <= len_out);",
"memcpy(VAR_1->data + written, chunk->data, chunk->len);",
"written += chunk->len;",
"}",
"*VAR_3 = 1;",
"ctx->api->chunk_free(data_out);",
"data_out = NULL;",
"VAR_1->flags = 0;",
"if (frame_info.nal_unit_type >= KVZ_NAL_BLA_W_LP &&\nframe_info.nal_unit_type <= KVZ_NAL_RSV_IRAP_VCL23) {",
"VAR_1->flags |= AV_PKT_FLAG_KEY;",
"}",
"}",
"done:\nctx->api->picture_free(img_in);",
"ctx->api->chunk_free(data_out);",
"return VAR_4;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
25
],
[
29
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93,
95,
97,
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
111
],
[
113
],
[
115
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
145
],
[
147
],
[
151
],
[
157,
159
],
[
161
],
[
163
],
[
165
],
[
169,
171
],
[
173
],
[
175
],
[
177
]
] |
21,133 | static int send_extradata(APNGDemuxContext *ctx, AVPacket *pkt)
{
if (!ctx->extra_data_updated) {
uint8_t *side_data = av_packet_new_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, ctx->extra_data_size);
if (!side_data)
return AVERROR(ENOMEM);
memcpy(side_data, ctx->extra_data, ctx->extra_data_size);
ctx->extra_data_updated = 1;
}
return 0;
}
| true | FFmpeg | 16c429166ddf1736972b6ccce84bd3509ec16a34 | static int send_extradata(APNGDemuxContext *ctx, AVPacket *pkt)
{
if (!ctx->extra_data_updated) {
uint8_t *side_data = av_packet_new_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, ctx->extra_data_size);
if (!side_data)
return AVERROR(ENOMEM);
memcpy(side_data, ctx->extra_data, ctx->extra_data_size);
ctx->extra_data_updated = 1;
}
return 0;
}
| {
"code": [
"static int send_extradata(APNGDemuxContext *ctx, AVPacket *pkt)",
" if (!ctx->extra_data_updated) {",
" uint8_t *side_data = av_packet_new_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, ctx->extra_data_size);",
" if (!side_data)",
" return AVERROR(ENOMEM);",
" memcpy(side_data, ctx->extra_data, ctx->extra_data_size);",
" ctx->extra_data_updated = 1;",
" return 0;",
" return 0;"
],
"line_no": [
1,
5,
7,
9,
11,
13,
15,
19,
19
]
} | static int FUNC_0(APNGDemuxContext *VAR_0, AVPacket *VAR_1)
{
if (!VAR_0->extra_data_updated) {
uint8_t *side_data = av_packet_new_side_data(VAR_1, AV_PKT_DATA_NEW_EXTRADATA, VAR_0->extra_data_size);
if (!side_data)
return AVERROR(ENOMEM);
memcpy(side_data, VAR_0->extra_data, VAR_0->extra_data_size);
VAR_0->extra_data_updated = 1;
}
return 0;
}
| [
"static int FUNC_0(APNGDemuxContext *VAR_0, AVPacket *VAR_1)\n{",
"if (!VAR_0->extra_data_updated) {",
"uint8_t *side_data = av_packet_new_side_data(VAR_1, AV_PKT_DATA_NEW_EXTRADATA, VAR_0->extra_data_size);",
"if (!side_data)\nreturn AVERROR(ENOMEM);",
"memcpy(side_data, VAR_0->extra_data, VAR_0->extra_data_size);",
"VAR_0->extra_data_updated = 1;",
"}",
"return 0;",
"}"
] | [
1,
1,
1,
1,
1,
1,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9,
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
21,134 | static void vga_mm_init(VGAState *s, target_phys_addr_t vram_base,
target_phys_addr_t ctrl_base, int it_shift)
{
int s_ioport_ctrl, vga_io_memory;
s->it_shift = it_shift;
s_ioport_ctrl = cpu_register_io_memory(0, vga_mm_read_ctrl, vga_mm_write_ctrl, s);
vga_io_memory = cpu_register_io_memory(0, vga_mem_read, vga_mem_write, s);
register_savevm("vga", 0, 2, vga_save, vga_load, s);
cpu_register_physical_memory(ctrl_base, 0x100000, s_ioport_ctrl);
s->bank_offset = 0;
cpu_register_physical_memory(vram_base + 0x000a0000, 0x20000, vga_io_memory);
} | true | qemu | f65ed4c1529f29a7d62d6733eaa50bed24a4b2ed | static void vga_mm_init(VGAState *s, target_phys_addr_t vram_base,
target_phys_addr_t ctrl_base, int it_shift)
{
int s_ioport_ctrl, vga_io_memory;
s->it_shift = it_shift;
s_ioport_ctrl = cpu_register_io_memory(0, vga_mm_read_ctrl, vga_mm_write_ctrl, s);
vga_io_memory = cpu_register_io_memory(0, vga_mem_read, vga_mem_write, s);
register_savevm("vga", 0, 2, vga_save, vga_load, s);
cpu_register_physical_memory(ctrl_base, 0x100000, s_ioport_ctrl);
s->bank_offset = 0;
cpu_register_physical_memory(vram_base + 0x000a0000, 0x20000, vga_io_memory);
} | {
"code": [],
"line_no": []
} | static void FUNC_0(VGAState *VAR_0, target_phys_addr_t VAR_1,
target_phys_addr_t VAR_2, int VAR_3)
{
int VAR_4, VAR_5;
VAR_0->VAR_3 = VAR_3;
VAR_4 = cpu_register_io_memory(0, vga_mm_read_ctrl, vga_mm_write_ctrl, VAR_0);
VAR_5 = cpu_register_io_memory(0, vga_mem_read, vga_mem_write, VAR_0);
register_savevm("vga", 0, 2, vga_save, vga_load, VAR_0);
cpu_register_physical_memory(VAR_2, 0x100000, VAR_4);
VAR_0->bank_offset = 0;
cpu_register_physical_memory(VAR_1 + 0x000a0000, 0x20000, VAR_5);
} | [
"static void FUNC_0(VGAState *VAR_0, target_phys_addr_t VAR_1,\ntarget_phys_addr_t VAR_2, int VAR_3)\n{",
"int VAR_4, VAR_5;",
"VAR_0->VAR_3 = VAR_3;",
"VAR_4 = cpu_register_io_memory(0, vga_mm_read_ctrl, vga_mm_write_ctrl, VAR_0);",
"VAR_5 = cpu_register_io_memory(0, vga_mem_read, vga_mem_write, VAR_0);",
"register_savevm(\"vga\", 0, 2, vga_save, vga_load, VAR_0);",
"cpu_register_physical_memory(VAR_2, 0x100000, VAR_4);",
"VAR_0->bank_offset = 0;",
"cpu_register_physical_memory(VAR_1 + 0x000a0000, 0x20000, VAR_5);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
19
],
[
23
],
[
25
],
[
27
],
[
30
]
] |
21,136 | TranslationBlock *tb_gen_code(CPUState *cpu,
target_ulong pc, target_ulong cs_base,
uint32_t flags, int cflags)
{
CPUArchState *env = cpu->env_ptr;
TranslationBlock *tb;
tb_page_addr_t phys_pc, phys_page2;
target_ulong virt_page2;
tcg_insn_unit *gen_code_buf;
int gen_code_size, search_size;
#ifdef CONFIG_PROFILER
int64_t ti;
#endif
assert_memory_lock();
phys_pc = get_page_addr_code(env, pc);
if (use_icount && !(cflags & CF_IGNORE_ICOUNT)) {
cflags |= CF_USE_ICOUNT;
}
tb = tb_alloc(pc);
if (unlikely(!tb)) {
buffer_overflow:
/* flush must be done */
tb_flush(cpu);
mmap_unlock();
/* Make the execution loop process the flush as soon as possible. */
cpu->exception_index = EXCP_INTERRUPT;
cpu_loop_exit(cpu);
}
gen_code_buf = tcg_ctx.code_gen_ptr;
tb->tc_ptr = gen_code_buf;
tb->pc = pc;
tb->cs_base = cs_base;
tb->flags = flags;
tb->cflags = cflags;
tb->trace_vcpu_dstate = *cpu->trace_dstate;
tb->invalid = false;
#ifdef CONFIG_PROFILER
tcg_ctx.tb_count1++; /* includes aborted translations because of
exceptions */
ti = profile_getclock();
#endif
tcg_func_start(&tcg_ctx);
tcg_ctx.cpu = ENV_GET_CPU(env);
gen_intermediate_code(cpu, tb);
tcg_ctx.cpu = NULL;
trace_translate_block(tb, tb->pc, tb->tc_ptr);
/* generate machine code */
tb->jmp_reset_offset[0] = TB_JMP_RESET_OFFSET_INVALID;
tb->jmp_reset_offset[1] = TB_JMP_RESET_OFFSET_INVALID;
tcg_ctx.tb_jmp_reset_offset = tb->jmp_reset_offset;
if (TCG_TARGET_HAS_direct_jump) {
tcg_ctx.tb_jmp_insn_offset = tb->jmp_target_arg;
tcg_ctx.tb_jmp_target_addr = NULL;
} else {
tcg_ctx.tb_jmp_insn_offset = NULL;
tcg_ctx.tb_jmp_target_addr = tb->jmp_target_arg;
}
#ifdef CONFIG_PROFILER
tcg_ctx.tb_count++;
tcg_ctx.interm_time += profile_getclock() - ti;
tcg_ctx.code_time -= profile_getclock();
#endif
/* ??? Overflow could be handled better here. In particular, we
don't need to re-do gen_intermediate_code, nor should we re-do
the tcg optimization currently hidden inside tcg_gen_code. All
that should be required is to flush the TBs, allocate a new TB,
re-initialize it per above, and re-do the actual code generation. */
gen_code_size = tcg_gen_code(&tcg_ctx, tb);
if (unlikely(gen_code_size < 0)) {
goto buffer_overflow;
}
search_size = encode_search(tb, (void *)gen_code_buf + gen_code_size);
if (unlikely(search_size < 0)) {
goto buffer_overflow;
}
#ifdef CONFIG_PROFILER
tcg_ctx.code_time += profile_getclock();
tcg_ctx.code_in_len += tb->size;
tcg_ctx.code_out_len += gen_code_size;
tcg_ctx.search_out_len += search_size;
#endif
#ifdef DEBUG_DISAS
if (qemu_loglevel_mask(CPU_LOG_TB_OUT_ASM) &&
qemu_log_in_addr_range(tb->pc)) {
qemu_log_lock();
qemu_log("OUT: [size=%d]\n", gen_code_size);
if (tcg_ctx.data_gen_ptr) {
size_t code_size = tcg_ctx.data_gen_ptr - tb->tc_ptr;
size_t data_size = gen_code_size - code_size;
size_t i;
log_disas(tb->tc_ptr, code_size);
for (i = 0; i < data_size; i += sizeof(tcg_target_ulong)) {
if (sizeof(tcg_target_ulong) == 8) {
qemu_log("0x%08" PRIxPTR ": .quad 0x%016" PRIx64 "\n",
(uintptr_t)tcg_ctx.data_gen_ptr + i,
*(uint64_t *)(tcg_ctx.data_gen_ptr + i));
} else {
qemu_log("0x%08" PRIxPTR ": .long 0x%08x\n",
(uintptr_t)tcg_ctx.data_gen_ptr + i,
*(uint32_t *)(tcg_ctx.data_gen_ptr + i));
}
}
} else {
log_disas(tb->tc_ptr, gen_code_size);
}
qemu_log("\n");
qemu_log_flush();
qemu_log_unlock();
}
#endif
tcg_ctx.code_gen_ptr = (void *)
ROUND_UP((uintptr_t)gen_code_buf + gen_code_size + search_size,
CODE_GEN_ALIGN);
/* init jump list */
assert(((uintptr_t)tb & 3) == 0);
tb->jmp_list_first = (uintptr_t)tb | 2;
tb->jmp_list_next[0] = (uintptr_t)NULL;
tb->jmp_list_next[1] = (uintptr_t)NULL;
/* init original jump addresses wich has been set during tcg_gen_code() */
if (tb->jmp_reset_offset[0] != TB_JMP_RESET_OFFSET_INVALID) {
tb_reset_jump(tb, 0);
}
if (tb->jmp_reset_offset[1] != TB_JMP_RESET_OFFSET_INVALID) {
tb_reset_jump(tb, 1);
}
/* check next page if needed */
virt_page2 = (pc + tb->size - 1) & TARGET_PAGE_MASK;
phys_page2 = -1;
if ((pc & TARGET_PAGE_MASK) != virt_page2) {
phys_page2 = get_page_addr_code(env, virt_page2);
}
/* As long as consistency of the TB stuff is provided by tb_lock in user
* mode and is implicit in single-threaded softmmu emulation, no explicit
* memory barrier is required before tb_link_page() makes the TB visible
* through the physical hash table and physical page list.
*/
tb_link_page(tb, phys_pc, phys_page2);
return tb;
}
| true | qemu | 0aecede6121e56ccc5d6a82243f2ccccdfabe6d5 | TranslationBlock *tb_gen_code(CPUState *cpu,
target_ulong pc, target_ulong cs_base,
uint32_t flags, int cflags)
{
CPUArchState *env = cpu->env_ptr;
TranslationBlock *tb;
tb_page_addr_t phys_pc, phys_page2;
target_ulong virt_page2;
tcg_insn_unit *gen_code_buf;
int gen_code_size, search_size;
#ifdef CONFIG_PROFILER
int64_t ti;
#endif
assert_memory_lock();
phys_pc = get_page_addr_code(env, pc);
if (use_icount && !(cflags & CF_IGNORE_ICOUNT)) {
cflags |= CF_USE_ICOUNT;
}
tb = tb_alloc(pc);
if (unlikely(!tb)) {
buffer_overflow:
tb_flush(cpu);
mmap_unlock();
cpu->exception_index = EXCP_INTERRUPT;
cpu_loop_exit(cpu);
}
gen_code_buf = tcg_ctx.code_gen_ptr;
tb->tc_ptr = gen_code_buf;
tb->pc = pc;
tb->cs_base = cs_base;
tb->flags = flags;
tb->cflags = cflags;
tb->trace_vcpu_dstate = *cpu->trace_dstate;
tb->invalid = false;
#ifdef CONFIG_PROFILER
tcg_ctx.tb_count1++;
ti = profile_getclock();
#endif
tcg_func_start(&tcg_ctx);
tcg_ctx.cpu = ENV_GET_CPU(env);
gen_intermediate_code(cpu, tb);
tcg_ctx.cpu = NULL;
trace_translate_block(tb, tb->pc, tb->tc_ptr);
tb->jmp_reset_offset[0] = TB_JMP_RESET_OFFSET_INVALID;
tb->jmp_reset_offset[1] = TB_JMP_RESET_OFFSET_INVALID;
tcg_ctx.tb_jmp_reset_offset = tb->jmp_reset_offset;
if (TCG_TARGET_HAS_direct_jump) {
tcg_ctx.tb_jmp_insn_offset = tb->jmp_target_arg;
tcg_ctx.tb_jmp_target_addr = NULL;
} else {
tcg_ctx.tb_jmp_insn_offset = NULL;
tcg_ctx.tb_jmp_target_addr = tb->jmp_target_arg;
}
#ifdef CONFIG_PROFILER
tcg_ctx.tb_count++;
tcg_ctx.interm_time += profile_getclock() - ti;
tcg_ctx.code_time -= profile_getclock();
#endif
gen_code_size = tcg_gen_code(&tcg_ctx, tb);
if (unlikely(gen_code_size < 0)) {
goto buffer_overflow;
}
search_size = encode_search(tb, (void *)gen_code_buf + gen_code_size);
if (unlikely(search_size < 0)) {
goto buffer_overflow;
}
#ifdef CONFIG_PROFILER
tcg_ctx.code_time += profile_getclock();
tcg_ctx.code_in_len += tb->size;
tcg_ctx.code_out_len += gen_code_size;
tcg_ctx.search_out_len += search_size;
#endif
#ifdef DEBUG_DISAS
if (qemu_loglevel_mask(CPU_LOG_TB_OUT_ASM) &&
qemu_log_in_addr_range(tb->pc)) {
qemu_log_lock();
qemu_log("OUT: [size=%d]\n", gen_code_size);
if (tcg_ctx.data_gen_ptr) {
size_t code_size = tcg_ctx.data_gen_ptr - tb->tc_ptr;
size_t data_size = gen_code_size - code_size;
size_t i;
log_disas(tb->tc_ptr, code_size);
for (i = 0; i < data_size; i += sizeof(tcg_target_ulong)) {
if (sizeof(tcg_target_ulong) == 8) {
qemu_log("0x%08" PRIxPTR ": .quad 0x%016" PRIx64 "\n",
(uintptr_t)tcg_ctx.data_gen_ptr + i,
*(uint64_t *)(tcg_ctx.data_gen_ptr + i));
} else {
qemu_log("0x%08" PRIxPTR ": .long 0x%08x\n",
(uintptr_t)tcg_ctx.data_gen_ptr + i,
*(uint32_t *)(tcg_ctx.data_gen_ptr + i));
}
}
} else {
log_disas(tb->tc_ptr, gen_code_size);
}
qemu_log("\n");
qemu_log_flush();
qemu_log_unlock();
}
#endif
tcg_ctx.code_gen_ptr = (void *)
ROUND_UP((uintptr_t)gen_code_buf + gen_code_size + search_size,
CODE_GEN_ALIGN);
assert(((uintptr_t)tb & 3) == 0);
tb->jmp_list_first = (uintptr_t)tb | 2;
tb->jmp_list_next[0] = (uintptr_t)NULL;
tb->jmp_list_next[1] = (uintptr_t)NULL;
if (tb->jmp_reset_offset[0] != TB_JMP_RESET_OFFSET_INVALID) {
tb_reset_jump(tb, 0);
}
if (tb->jmp_reset_offset[1] != TB_JMP_RESET_OFFSET_INVALID) {
tb_reset_jump(tb, 1);
}
virt_page2 = (pc + tb->size - 1) & TARGET_PAGE_MASK;
phys_page2 = -1;
if ((pc & TARGET_PAGE_MASK) != virt_page2) {
phys_page2 = get_page_addr_code(env, virt_page2);
}
tb_link_page(tb, phys_pc, phys_page2);
return tb;
}
| {
"code": [
" tcg_ctx.code_time -= profile_getclock();",
" tcg_ctx.code_time += profile_getclock();"
],
"line_no": [
139,
175
]
} | TranslationBlock *FUNC_0(CPUState *cpu,
target_ulong pc, target_ulong cs_base,
uint32_t flags, int cflags)
{
CPUArchState *env = cpu->env_ptr;
TranslationBlock *tb;
tb_page_addr_t phys_pc, phys_page2;
target_ulong virt_page2;
tcg_insn_unit *gen_code_buf;
int VAR_0, VAR_1;
#ifdef CONFIG_PROFILER
int64_t ti;
#endif
assert_memory_lock();
phys_pc = get_page_addr_code(env, pc);
if (use_icount && !(cflags & CF_IGNORE_ICOUNT)) {
cflags |= CF_USE_ICOUNT;
}
tb = tb_alloc(pc);
if (unlikely(!tb)) {
buffer_overflow:
tb_flush(cpu);
mmap_unlock();
cpu->exception_index = EXCP_INTERRUPT;
cpu_loop_exit(cpu);
}
gen_code_buf = tcg_ctx.code_gen_ptr;
tb->tc_ptr = gen_code_buf;
tb->pc = pc;
tb->cs_base = cs_base;
tb->flags = flags;
tb->cflags = cflags;
tb->trace_vcpu_dstate = *cpu->trace_dstate;
tb->invalid = false;
#ifdef CONFIG_PROFILER
tcg_ctx.tb_count1++;
ti = profile_getclock();
#endif
tcg_func_start(&tcg_ctx);
tcg_ctx.cpu = ENV_GET_CPU(env);
gen_intermediate_code(cpu, tb);
tcg_ctx.cpu = NULL;
trace_translate_block(tb, tb->pc, tb->tc_ptr);
tb->jmp_reset_offset[0] = TB_JMP_RESET_OFFSET_INVALID;
tb->jmp_reset_offset[1] = TB_JMP_RESET_OFFSET_INVALID;
tcg_ctx.tb_jmp_reset_offset = tb->jmp_reset_offset;
if (TCG_TARGET_HAS_direct_jump) {
tcg_ctx.tb_jmp_insn_offset = tb->jmp_target_arg;
tcg_ctx.tb_jmp_target_addr = NULL;
} else {
tcg_ctx.tb_jmp_insn_offset = NULL;
tcg_ctx.tb_jmp_target_addr = tb->jmp_target_arg;
}
#ifdef CONFIG_PROFILER
tcg_ctx.tb_count++;
tcg_ctx.interm_time += profile_getclock() - ti;
tcg_ctx.code_time -= profile_getclock();
#endif
VAR_0 = tcg_gen_code(&tcg_ctx, tb);
if (unlikely(VAR_0 < 0)) {
goto buffer_overflow;
}
VAR_1 = encode_search(tb, (void *)gen_code_buf + VAR_0);
if (unlikely(VAR_1 < 0)) {
goto buffer_overflow;
}
#ifdef CONFIG_PROFILER
tcg_ctx.code_time += profile_getclock();
tcg_ctx.code_in_len += tb->size;
tcg_ctx.code_out_len += VAR_0;
tcg_ctx.search_out_len += VAR_1;
#endif
#ifdef DEBUG_DISAS
if (qemu_loglevel_mask(CPU_LOG_TB_OUT_ASM) &&
qemu_log_in_addr_range(tb->pc)) {
qemu_log_lock();
qemu_log("OUT: [size=%d]\n", VAR_0);
if (tcg_ctx.data_gen_ptr) {
size_t code_size = tcg_ctx.data_gen_ptr - tb->tc_ptr;
size_t data_size = VAR_0 - code_size;
size_t i;
log_disas(tb->tc_ptr, code_size);
for (i = 0; i < data_size; i += sizeof(tcg_target_ulong)) {
if (sizeof(tcg_target_ulong) == 8) {
qemu_log("0x%08" PRIxPTR ": .quad 0x%016" PRIx64 "\n",
(uintptr_t)tcg_ctx.data_gen_ptr + i,
*(uint64_t *)(tcg_ctx.data_gen_ptr + i));
} else {
qemu_log("0x%08" PRIxPTR ": .long 0x%08x\n",
(uintptr_t)tcg_ctx.data_gen_ptr + i,
*(uint32_t *)(tcg_ctx.data_gen_ptr + i));
}
}
} else {
log_disas(tb->tc_ptr, VAR_0);
}
qemu_log("\n");
qemu_log_flush();
qemu_log_unlock();
}
#endif
tcg_ctx.code_gen_ptr = (void *)
ROUND_UP((uintptr_t)gen_code_buf + VAR_0 + VAR_1,
CODE_GEN_ALIGN);
assert(((uintptr_t)tb & 3) == 0);
tb->jmp_list_first = (uintptr_t)tb | 2;
tb->jmp_list_next[0] = (uintptr_t)NULL;
tb->jmp_list_next[1] = (uintptr_t)NULL;
if (tb->jmp_reset_offset[0] != TB_JMP_RESET_OFFSET_INVALID) {
tb_reset_jump(tb, 0);
}
if (tb->jmp_reset_offset[1] != TB_JMP_RESET_OFFSET_INVALID) {
tb_reset_jump(tb, 1);
}
virt_page2 = (pc + tb->size - 1) & TARGET_PAGE_MASK;
phys_page2 = -1;
if ((pc & TARGET_PAGE_MASK) != virt_page2) {
phys_page2 = get_page_addr_code(env, virt_page2);
}
tb_link_page(tb, phys_pc, phys_page2);
return tb;
}
| [
"TranslationBlock *FUNC_0(CPUState *cpu,\ntarget_ulong pc, target_ulong cs_base,\nuint32_t flags, int cflags)\n{",
"CPUArchState *env = cpu->env_ptr;",
"TranslationBlock *tb;",
"tb_page_addr_t phys_pc, phys_page2;",
"target_ulong virt_page2;",
"tcg_insn_unit *gen_code_buf;",
"int VAR_0, VAR_1;",
"#ifdef CONFIG_PROFILER\nint64_t ti;",
"#endif\nassert_memory_lock();",
"phys_pc = get_page_addr_code(env, pc);",
"if (use_icount && !(cflags & CF_IGNORE_ICOUNT)) {",
"cflags |= CF_USE_ICOUNT;",
"}",
"tb = tb_alloc(pc);",
"if (unlikely(!tb)) {",
"buffer_overflow:\ntb_flush(cpu);",
"mmap_unlock();",
"cpu->exception_index = EXCP_INTERRUPT;",
"cpu_loop_exit(cpu);",
"}",
"gen_code_buf = tcg_ctx.code_gen_ptr;",
"tb->tc_ptr = gen_code_buf;",
"tb->pc = pc;",
"tb->cs_base = cs_base;",
"tb->flags = flags;",
"tb->cflags = cflags;",
"tb->trace_vcpu_dstate = *cpu->trace_dstate;",
"tb->invalid = false;",
"#ifdef CONFIG_PROFILER\ntcg_ctx.tb_count1++;",
"ti = profile_getclock();",
"#endif\ntcg_func_start(&tcg_ctx);",
"tcg_ctx.cpu = ENV_GET_CPU(env);",
"gen_intermediate_code(cpu, tb);",
"tcg_ctx.cpu = NULL;",
"trace_translate_block(tb, tb->pc, tb->tc_ptr);",
"tb->jmp_reset_offset[0] = TB_JMP_RESET_OFFSET_INVALID;",
"tb->jmp_reset_offset[1] = TB_JMP_RESET_OFFSET_INVALID;",
"tcg_ctx.tb_jmp_reset_offset = tb->jmp_reset_offset;",
"if (TCG_TARGET_HAS_direct_jump) {",
"tcg_ctx.tb_jmp_insn_offset = tb->jmp_target_arg;",
"tcg_ctx.tb_jmp_target_addr = NULL;",
"} else {",
"tcg_ctx.tb_jmp_insn_offset = NULL;",
"tcg_ctx.tb_jmp_target_addr = tb->jmp_target_arg;",
"}",
"#ifdef CONFIG_PROFILER\ntcg_ctx.tb_count++;",
"tcg_ctx.interm_time += profile_getclock() - ti;",
"tcg_ctx.code_time -= profile_getclock();",
"#endif\nVAR_0 = tcg_gen_code(&tcg_ctx, tb);",
"if (unlikely(VAR_0 < 0)) {",
"goto buffer_overflow;",
"}",
"VAR_1 = encode_search(tb, (void *)gen_code_buf + VAR_0);",
"if (unlikely(VAR_1 < 0)) {",
"goto buffer_overflow;",
"}",
"#ifdef CONFIG_PROFILER\ntcg_ctx.code_time += profile_getclock();",
"tcg_ctx.code_in_len += tb->size;",
"tcg_ctx.code_out_len += VAR_0;",
"tcg_ctx.search_out_len += VAR_1;",
"#endif\n#ifdef DEBUG_DISAS\nif (qemu_loglevel_mask(CPU_LOG_TB_OUT_ASM) &&\nqemu_log_in_addr_range(tb->pc)) {",
"qemu_log_lock();",
"qemu_log(\"OUT: [size=%d]\\n\", VAR_0);",
"if (tcg_ctx.data_gen_ptr) {",
"size_t code_size = tcg_ctx.data_gen_ptr - tb->tc_ptr;",
"size_t data_size = VAR_0 - code_size;",
"size_t i;",
"log_disas(tb->tc_ptr, code_size);",
"for (i = 0; i < data_size; i += sizeof(tcg_target_ulong)) {",
"if (sizeof(tcg_target_ulong) == 8) {",
"qemu_log(\"0x%08\" PRIxPTR \": .quad 0x%016\" PRIx64 \"\\n\",\n(uintptr_t)tcg_ctx.data_gen_ptr + i,\n*(uint64_t *)(tcg_ctx.data_gen_ptr + i));",
"} else {",
"qemu_log(\"0x%08\" PRIxPTR \": .long 0x%08x\\n\",\n(uintptr_t)tcg_ctx.data_gen_ptr + i,\n*(uint32_t *)(tcg_ctx.data_gen_ptr + i));",
"}",
"}",
"} else {",
"log_disas(tb->tc_ptr, VAR_0);",
"}",
"qemu_log(\"\\n\");",
"qemu_log_flush();",
"qemu_log_unlock();",
"}",
"#endif\ntcg_ctx.code_gen_ptr = (void *)\nROUND_UP((uintptr_t)gen_code_buf + VAR_0 + VAR_1,\nCODE_GEN_ALIGN);",
"assert(((uintptr_t)tb & 3) == 0);",
"tb->jmp_list_first = (uintptr_t)tb | 2;",
"tb->jmp_list_next[0] = (uintptr_t)NULL;",
"tb->jmp_list_next[1] = (uintptr_t)NULL;",
"if (tb->jmp_reset_offset[0] != TB_JMP_RESET_OFFSET_INVALID) {",
"tb_reset_jump(tb, 0);",
"}",
"if (tb->jmp_reset_offset[1] != TB_JMP_RESET_OFFSET_INVALID) {",
"tb_reset_jump(tb, 1);",
"}",
"virt_page2 = (pc + tb->size - 1) & TARGET_PAGE_MASK;",
"phys_page2 = -1;",
"if ((pc & TARGET_PAGE_MASK) != virt_page2) {",
"phys_page2 = get_page_addr_code(env, virt_page2);",
"}",
"tb_link_page(tb, phys_pc, phys_page2);",
"return tb;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
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
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21,
23
],
[
25,
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45,
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81,
83
],
[
87
],
[
89,
93
],
[
97
],
[
99
],
[
101
],
[
105
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
133,
135
],
[
137
],
[
139
],
[
141,
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
173,
175
],
[
177
],
[
179
],
[
181
],
[
183,
187,
189,
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
207
],
[
211
],
[
213
],
[
215,
217,
219
],
[
221
],
[
223,
225,
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247,
251,
253,
255
],
[
261
],
[
263
],
[
265
],
[
267
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
309
],
[
311
],
[
313
]
] |
21,137 | static void gen_store_exclusive(DisasContext *s, int rd, int rt, int rt2,
TCGv addr, int size)
{
TCGv tmp;
int done_label;
int fail_label;
/* if (env->exclusive_addr == addr && env->exclusive_val == [addr]) {
[addr] = {Rt};
{Rd} = 0;
} else {
{Rd} = 1;
} */
fail_label = gen_new_label();
done_label = gen_new_label();
tcg_gen_brcond_i32(TCG_COND_NE, addr, cpu_exclusive_addr, fail_label);
switch (size) {
case 0:
tmp = gen_ld8u(addr, IS_USER(s));
break;
case 1:
tmp = gen_ld16u(addr, IS_USER(s));
break;
case 2:
case 3:
tmp = gen_ld32(addr, IS_USER(s));
break;
default:
abort();
}
tcg_gen_brcond_i32(TCG_COND_NE, tmp, cpu_exclusive_val, fail_label);
dead_tmp(tmp);
if (size == 3) {
TCGv tmp2 = new_tmp();
tcg_gen_addi_i32(tmp2, addr, 4);
tmp = gen_ld32(tmp2, IS_USER(s));
dead_tmp(tmp2);
tcg_gen_brcond_i32(TCG_COND_NE, tmp, cpu_exclusive_high, fail_label);
dead_tmp(tmp);
}
tmp = load_reg(s, rt);
switch (size) {
case 0:
gen_st8(tmp, addr, IS_USER(s));
break;
case 1:
gen_st16(tmp, addr, IS_USER(s));
break;
case 2:
case 3:
gen_st32(tmp, addr, IS_USER(s));
break;
default:
abort();
}
if (size == 3) {
tcg_gen_addi_i32(addr, addr, 4);
tmp = load_reg(s, rt2);
gen_st32(tmp, addr, IS_USER(s));
}
tcg_gen_movi_i32(cpu_R[rd], 0);
tcg_gen_br(done_label);
gen_set_label(fail_label);
tcg_gen_movi_i32(cpu_R[rd], 1);
gen_set_label(done_label);
tcg_gen_movi_i32(cpu_exclusive_addr, -1);
}
| true | qemu | 7d1b0095bff7157e856d1d0e6c4295641ced2752 | static void gen_store_exclusive(DisasContext *s, int rd, int rt, int rt2,
TCGv addr, int size)
{
TCGv tmp;
int done_label;
int fail_label;
fail_label = gen_new_label();
done_label = gen_new_label();
tcg_gen_brcond_i32(TCG_COND_NE, addr, cpu_exclusive_addr, fail_label);
switch (size) {
case 0:
tmp = gen_ld8u(addr, IS_USER(s));
break;
case 1:
tmp = gen_ld16u(addr, IS_USER(s));
break;
case 2:
case 3:
tmp = gen_ld32(addr, IS_USER(s));
break;
default:
abort();
}
tcg_gen_brcond_i32(TCG_COND_NE, tmp, cpu_exclusive_val, fail_label);
dead_tmp(tmp);
if (size == 3) {
TCGv tmp2 = new_tmp();
tcg_gen_addi_i32(tmp2, addr, 4);
tmp = gen_ld32(tmp2, IS_USER(s));
dead_tmp(tmp2);
tcg_gen_brcond_i32(TCG_COND_NE, tmp, cpu_exclusive_high, fail_label);
dead_tmp(tmp);
}
tmp = load_reg(s, rt);
switch (size) {
case 0:
gen_st8(tmp, addr, IS_USER(s));
break;
case 1:
gen_st16(tmp, addr, IS_USER(s));
break;
case 2:
case 3:
gen_st32(tmp, addr, IS_USER(s));
break;
default:
abort();
}
if (size == 3) {
tcg_gen_addi_i32(addr, addr, 4);
tmp = load_reg(s, rt2);
gen_st32(tmp, addr, IS_USER(s));
}
tcg_gen_movi_i32(cpu_R[rd], 0);
tcg_gen_br(done_label);
gen_set_label(fail_label);
tcg_gen_movi_i32(cpu_R[rd], 1);
gen_set_label(done_label);
tcg_gen_movi_i32(cpu_exclusive_addr, -1);
}
| {
"code": [
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp2);",
" dead_tmp(tmp2);",
" dead_tmp(tmp);",
" dead_tmp(tmp2);",
" dead_tmp(tmp);",
" dead_tmp(tmp2);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp2);",
" dead_tmp(tmp);",
" dead_tmp(tmp2);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp2);",
" dead_tmp(tmp);",
" dead_tmp(tmp2);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp2);",
" dead_tmp(tmp);",
" TCGv tmp2 = new_tmp();",
" dead_tmp(tmp2);",
" dead_tmp(tmp);",
" TCGv tmp2 = new_tmp();",
" dead_tmp(tmp2);",
" dead_tmp(tmp);",
" dead_tmp(tmp);"
],
"line_no": [
63,
63,
63,
63,
63,
63,
63,
63,
63,
77,
77,
73,
73,
77,
73,
77,
73,
63,
77,
63,
77,
77,
77,
77,
73,
77,
73,
77,
77,
77,
77,
77,
73,
77,
73,
77,
77,
77,
63,
63,
63,
63,
63,
63,
63,
73,
63,
67,
73,
63,
67,
73,
77,
77
]
} | static void FUNC_0(DisasContext *VAR_0, int VAR_1, int VAR_2, int VAR_3,
TCGv VAR_4, int VAR_5)
{
TCGv tmp;
int VAR_6;
int VAR_7;
VAR_7 = gen_new_label();
VAR_6 = gen_new_label();
tcg_gen_brcond_i32(TCG_COND_NE, VAR_4, cpu_exclusive_addr, VAR_7);
switch (VAR_5) {
case 0:
tmp = gen_ld8u(VAR_4, IS_USER(VAR_0));
break;
case 1:
tmp = gen_ld16u(VAR_4, IS_USER(VAR_0));
break;
case 2:
case 3:
tmp = gen_ld32(VAR_4, IS_USER(VAR_0));
break;
default:
abort();
}
tcg_gen_brcond_i32(TCG_COND_NE, tmp, cpu_exclusive_val, VAR_7);
dead_tmp(tmp);
if (VAR_5 == 3) {
TCGv tmp2 = new_tmp();
tcg_gen_addi_i32(tmp2, VAR_4, 4);
tmp = gen_ld32(tmp2, IS_USER(VAR_0));
dead_tmp(tmp2);
tcg_gen_brcond_i32(TCG_COND_NE, tmp, cpu_exclusive_high, VAR_7);
dead_tmp(tmp);
}
tmp = load_reg(VAR_0, VAR_2);
switch (VAR_5) {
case 0:
gen_st8(tmp, VAR_4, IS_USER(VAR_0));
break;
case 1:
gen_st16(tmp, VAR_4, IS_USER(VAR_0));
break;
case 2:
case 3:
gen_st32(tmp, VAR_4, IS_USER(VAR_0));
break;
default:
abort();
}
if (VAR_5 == 3) {
tcg_gen_addi_i32(VAR_4, VAR_4, 4);
tmp = load_reg(VAR_0, VAR_3);
gen_st32(tmp, VAR_4, IS_USER(VAR_0));
}
tcg_gen_movi_i32(cpu_R[VAR_1], 0);
tcg_gen_br(VAR_6);
gen_set_label(VAR_7);
tcg_gen_movi_i32(cpu_R[VAR_1], 1);
gen_set_label(VAR_6);
tcg_gen_movi_i32(cpu_exclusive_addr, -1);
}
| [
"static void FUNC_0(DisasContext *VAR_0, int VAR_1, int VAR_2, int VAR_3,\nTCGv VAR_4, int VAR_5)\n{",
"TCGv tmp;",
"int VAR_6;",
"int VAR_7;",
"VAR_7 = gen_new_label();",
"VAR_6 = gen_new_label();",
"tcg_gen_brcond_i32(TCG_COND_NE, VAR_4, cpu_exclusive_addr, VAR_7);",
"switch (VAR_5) {",
"case 0:\ntmp = gen_ld8u(VAR_4, IS_USER(VAR_0));",
"break;",
"case 1:\ntmp = gen_ld16u(VAR_4, IS_USER(VAR_0));",
"break;",
"case 2:\ncase 3:\ntmp = gen_ld32(VAR_4, IS_USER(VAR_0));",
"break;",
"default:\nabort();",
"}",
"tcg_gen_brcond_i32(TCG_COND_NE, tmp, cpu_exclusive_val, VAR_7);",
"dead_tmp(tmp);",
"if (VAR_5 == 3) {",
"TCGv tmp2 = new_tmp();",
"tcg_gen_addi_i32(tmp2, VAR_4, 4);",
"tmp = gen_ld32(tmp2, IS_USER(VAR_0));",
"dead_tmp(tmp2);",
"tcg_gen_brcond_i32(TCG_COND_NE, tmp, cpu_exclusive_high, VAR_7);",
"dead_tmp(tmp);",
"}",
"tmp = load_reg(VAR_0, VAR_2);",
"switch (VAR_5) {",
"case 0:\ngen_st8(tmp, VAR_4, IS_USER(VAR_0));",
"break;",
"case 1:\ngen_st16(tmp, VAR_4, IS_USER(VAR_0));",
"break;",
"case 2:\ncase 3:\ngen_st32(tmp, VAR_4, IS_USER(VAR_0));",
"break;",
"default:\nabort();",
"}",
"if (VAR_5 == 3) {",
"tcg_gen_addi_i32(VAR_4, VAR_4, 4);",
"tmp = load_reg(VAR_0, VAR_3);",
"gen_st32(tmp, VAR_4, IS_USER(VAR_0));",
"}",
"tcg_gen_movi_i32(cpu_R[VAR_1], 0);",
"tcg_gen_br(VAR_6);",
"gen_set_label(VAR_7);",
"tcg_gen_movi_i32(cpu_R[VAR_1], 1);",
"gen_set_label(VAR_6);",
"tcg_gen_movi_i32(cpu_exclusive_addr, -1);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
1,
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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
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
]
] |
21,138 | static void syborg_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)
{
CPUState *env;
qemu_irq *cpu_pic;
qemu_irq pic[64];
ram_addr_t ram_addr;
DeviceState *dev;
int i;
if (!cpu_model)
cpu_model = "cortex-a8";
env = cpu_init(cpu_model);
if (!env) {
fprintf(stderr, "Unable to find CPU definition\n");
exit(1);
}
/* RAM at address zero. */
ram_addr = qemu_ram_alloc(ram_size);
cpu_register_physical_memory(0, ram_size, ram_addr | IO_MEM_RAM);
cpu_pic = arm_pic_init_cpu(env);
dev = sysbus_create_simple("syborg,interrupt", 0xC0000000,
cpu_pic[ARM_PIC_CPU_IRQ]);
for (i = 0; i < 64; i++) {
pic[i] = qdev_get_gpio_in(dev, i);
}
sysbus_create_simple("syborg,rtc", 0xC0001000, NULL);
dev = qdev_create(NULL, "syborg,timer");
qdev_prop_set_uint32(dev, "frequency", 1000000);
qdev_init(dev);
sysbus_mmio_map(sysbus_from_qdev(dev), 0, 0xC0002000);
sysbus_connect_irq(sysbus_from_qdev(dev), 0, pic[1]);
sysbus_create_simple("syborg,keyboard", 0xC0003000, pic[2]);
sysbus_create_simple("syborg,pointer", 0xC0004000, pic[3]);
sysbus_create_simple("syborg,framebuffer", 0xC0005000, pic[4]);
sysbus_create_simple("syborg,serial", 0xC0006000, pic[5]);
sysbus_create_simple("syborg,serial", 0xC0007000, pic[6]);
sysbus_create_simple("syborg,serial", 0xC0008000, pic[7]);
sysbus_create_simple("syborg,serial", 0xC0009000, pic[8]);
if (nd_table[0].vlan) {
DeviceState *dev;
SysBusDevice *s;
qemu_check_nic_model(&nd_table[0], "virtio");
dev = qdev_create(NULL, "syborg,virtio-net");
dev->nd = &nd_table[0];
qdev_init(dev);
s = sysbus_from_qdev(dev);
sysbus_mmio_map(s, 0, 0xc000c000);
sysbus_connect_irq(s, 0, pic[9]);
}
syborg_binfo.ram_size = ram_size;
syborg_binfo.kernel_filename = kernel_filename;
syborg_binfo.kernel_cmdline = kernel_cmdline;
syborg_binfo.initrd_filename = initrd_filename;
syborg_binfo.board_id = 0;
arm_load_kernel(env, &syborg_binfo);
}
| true | qemu | e23a1b33b53d25510320b26d9f154e19c6c99725 | static void syborg_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)
{
CPUState *env;
qemu_irq *cpu_pic;
qemu_irq pic[64];
ram_addr_t ram_addr;
DeviceState *dev;
int i;
if (!cpu_model)
cpu_model = "cortex-a8";
env = cpu_init(cpu_model);
if (!env) {
fprintf(stderr, "Unable to find CPU definition\n");
exit(1);
}
ram_addr = qemu_ram_alloc(ram_size);
cpu_register_physical_memory(0, ram_size, ram_addr | IO_MEM_RAM);
cpu_pic = arm_pic_init_cpu(env);
dev = sysbus_create_simple("syborg,interrupt", 0xC0000000,
cpu_pic[ARM_PIC_CPU_IRQ]);
for (i = 0; i < 64; i++) {
pic[i] = qdev_get_gpio_in(dev, i);
}
sysbus_create_simple("syborg,rtc", 0xC0001000, NULL);
dev = qdev_create(NULL, "syborg,timer");
qdev_prop_set_uint32(dev, "frequency", 1000000);
qdev_init(dev);
sysbus_mmio_map(sysbus_from_qdev(dev), 0, 0xC0002000);
sysbus_connect_irq(sysbus_from_qdev(dev), 0, pic[1]);
sysbus_create_simple("syborg,keyboard", 0xC0003000, pic[2]);
sysbus_create_simple("syborg,pointer", 0xC0004000, pic[3]);
sysbus_create_simple("syborg,framebuffer", 0xC0005000, pic[4]);
sysbus_create_simple("syborg,serial", 0xC0006000, pic[5]);
sysbus_create_simple("syborg,serial", 0xC0007000, pic[6]);
sysbus_create_simple("syborg,serial", 0xC0008000, pic[7]);
sysbus_create_simple("syborg,serial", 0xC0009000, pic[8]);
if (nd_table[0].vlan) {
DeviceState *dev;
SysBusDevice *s;
qemu_check_nic_model(&nd_table[0], "virtio");
dev = qdev_create(NULL, "syborg,virtio-net");
dev->nd = &nd_table[0];
qdev_init(dev);
s = sysbus_from_qdev(dev);
sysbus_mmio_map(s, 0, 0xc000c000);
sysbus_connect_irq(s, 0, pic[9]);
}
syborg_binfo.ram_size = ram_size;
syborg_binfo.kernel_filename = kernel_filename;
syborg_binfo.kernel_cmdline = kernel_cmdline;
syborg_binfo.initrd_filename = initrd_filename;
syborg_binfo.board_id = 0;
arm_load_kernel(env, &syborg_binfo);
}
| {
"code": [
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);"
],
"line_no": [
71,
71,
71,
71,
71,
71,
71,
71,
71,
71,
71,
71,
109,
71,
71,
71,
71,
71,
71,
71,
71,
71,
71,
71,
71,
71,
71,
71,
71,
71,
71,
71,
71,
71,
71,
71,
109,
71,
71,
71,
71,
71
]
} | 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)
{
CPUState *env;
qemu_irq *cpu_pic;
qemu_irq pic[64];
ram_addr_t ram_addr;
DeviceState *dev;
int VAR_6;
if (!VAR_5)
VAR_5 = "cortex-a8";
env = cpu_init(VAR_5);
if (!env) {
fprintf(stderr, "Unable to find CPU definition\n");
exit(1);
}
ram_addr = qemu_ram_alloc(VAR_0);
cpu_register_physical_memory(0, VAR_0, ram_addr | IO_MEM_RAM);
cpu_pic = arm_pic_init_cpu(env);
dev = sysbus_create_simple("syborg,interrupt", 0xC0000000,
cpu_pic[ARM_PIC_CPU_IRQ]);
for (VAR_6 = 0; VAR_6 < 64; VAR_6++) {
pic[VAR_6] = qdev_get_gpio_in(dev, VAR_6);
}
sysbus_create_simple("syborg,rtc", 0xC0001000, NULL);
dev = qdev_create(NULL, "syborg,timer");
qdev_prop_set_uint32(dev, "frequency", 1000000);
qdev_init(dev);
sysbus_mmio_map(sysbus_from_qdev(dev), 0, 0xC0002000);
sysbus_connect_irq(sysbus_from_qdev(dev), 0, pic[1]);
sysbus_create_simple("syborg,keyboard", 0xC0003000, pic[2]);
sysbus_create_simple("syborg,pointer", 0xC0004000, pic[3]);
sysbus_create_simple("syborg,framebuffer", 0xC0005000, pic[4]);
sysbus_create_simple("syborg,serial", 0xC0006000, pic[5]);
sysbus_create_simple("syborg,serial", 0xC0007000, pic[6]);
sysbus_create_simple("syborg,serial", 0xC0008000, pic[7]);
sysbus_create_simple("syborg,serial", 0xC0009000, pic[8]);
if (nd_table[0].vlan) {
DeviceState *dev;
SysBusDevice *s;
qemu_check_nic_model(&nd_table[0], "virtio");
dev = qdev_create(NULL, "syborg,virtio-net");
dev->nd = &nd_table[0];
qdev_init(dev);
s = sysbus_from_qdev(dev);
sysbus_mmio_map(s, 0, 0xc000c000);
sysbus_connect_irq(s, 0, pic[9]);
}
syborg_binfo.VAR_0 = VAR_0;
syborg_binfo.VAR_2 = VAR_2;
syborg_binfo.VAR_3 = VAR_3;
syborg_binfo.VAR_4 = VAR_4;
syborg_binfo.board_id = 0;
arm_load_kernel(env, &syborg_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)\n{",
"CPUState *env;",
"qemu_irq *cpu_pic;",
"qemu_irq pic[64];",
"ram_addr_t ram_addr;",
"DeviceState *dev;",
"int VAR_6;",
"if (!VAR_5)\nVAR_5 = \"cortex-a8\";",
"env = cpu_init(VAR_5);",
"if (!env) {",
"fprintf(stderr, \"Unable to find CPU definition\\n\");",
"exit(1);",
"}",
"ram_addr = qemu_ram_alloc(VAR_0);",
"cpu_register_physical_memory(0, VAR_0, ram_addr | IO_MEM_RAM);",
"cpu_pic = arm_pic_init_cpu(env);",
"dev = sysbus_create_simple(\"syborg,interrupt\", 0xC0000000,\ncpu_pic[ARM_PIC_CPU_IRQ]);",
"for (VAR_6 = 0; VAR_6 < 64; VAR_6++) {",
"pic[VAR_6] = qdev_get_gpio_in(dev, VAR_6);",
"}",
"sysbus_create_simple(\"syborg,rtc\", 0xC0001000, NULL);",
"dev = qdev_create(NULL, \"syborg,timer\");",
"qdev_prop_set_uint32(dev, \"frequency\", 1000000);",
"qdev_init(dev);",
"sysbus_mmio_map(sysbus_from_qdev(dev), 0, 0xC0002000);",
"sysbus_connect_irq(sysbus_from_qdev(dev), 0, pic[1]);",
"sysbus_create_simple(\"syborg,keyboard\", 0xC0003000, pic[2]);",
"sysbus_create_simple(\"syborg,pointer\", 0xC0004000, pic[3]);",
"sysbus_create_simple(\"syborg,framebuffer\", 0xC0005000, pic[4]);",
"sysbus_create_simple(\"syborg,serial\", 0xC0006000, pic[5]);",
"sysbus_create_simple(\"syborg,serial\", 0xC0007000, pic[6]);",
"sysbus_create_simple(\"syborg,serial\", 0xC0008000, pic[7]);",
"sysbus_create_simple(\"syborg,serial\", 0xC0009000, pic[8]);",
"if (nd_table[0].vlan) {",
"DeviceState *dev;",
"SysBusDevice *s;",
"qemu_check_nic_model(&nd_table[0], \"virtio\");",
"dev = qdev_create(NULL, \"syborg,virtio-net\");",
"dev->nd = &nd_table[0];",
"qdev_init(dev);",
"s = sysbus_from_qdev(dev);",
"sysbus_mmio_map(s, 0, 0xc000c000);",
"sysbus_connect_irq(s, 0, pic[9]);",
"}",
"syborg_binfo.VAR_0 = VAR_0;",
"syborg_binfo.VAR_2 = VAR_2;",
"syborg_binfo.VAR_3 = VAR_3;",
"syborg_binfo.VAR_4 = VAR_4;",
"syborg_binfo.board_id = 0;",
"arm_load_kernel(env, &syborg_binfo);",
"}"
] | [
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,
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
],
[
37
],
[
43
],
[
45
],
[
49
],
[
51,
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
95
],
[
97
],
[
99
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
]
] |
21,139 | static int decode_frame_headers(Indeo3DecodeContext *ctx, AVCodecContext *avctx,
const uint8_t *buf, int buf_size)
{
const uint8_t *buf_ptr = buf, *bs_hdr;
uint32_t frame_num, word2, check_sum, data_size;
uint32_t y_offset, u_offset, v_offset, starts[3], ends[3];
uint16_t height, width;
int i, j;
/* parse and check the OS header */
frame_num = bytestream_get_le32(&buf_ptr);
word2 = bytestream_get_le32(&buf_ptr);
check_sum = bytestream_get_le32(&buf_ptr);
data_size = bytestream_get_le32(&buf_ptr);
if ((frame_num ^ word2 ^ data_size ^ OS_HDR_ID) != check_sum) {
av_log(avctx, AV_LOG_ERROR, "OS header checksum mismatch!\n");
return AVERROR_INVALIDDATA;
}
/* parse the bitstream header */
bs_hdr = buf_ptr;
if (bytestream_get_le16(&buf_ptr) != 32) {
av_log(avctx, AV_LOG_ERROR, "Unsupported codec version!\n");
return AVERROR_INVALIDDATA;
}
ctx->frame_num = frame_num;
ctx->frame_flags = bytestream_get_le16(&buf_ptr);
ctx->data_size = (bytestream_get_le32(&buf_ptr) + 7) >> 3;
ctx->cb_offset = *buf_ptr++;
if (ctx->data_size == 16)
return 4;
if (ctx->data_size > buf_size)
ctx->data_size = buf_size;
buf_ptr += 3; // skip reserved byte and checksum
/* check frame dimensions */
height = bytestream_get_le16(&buf_ptr);
width = bytestream_get_le16(&buf_ptr);
if (av_image_check_size(width, height, 0, avctx))
return AVERROR_INVALIDDATA;
if (width != ctx->width || height != ctx->height) {
av_dlog(avctx, "Frame dimensions changed!\n");
ctx->width = width;
ctx->height = height;
free_frame_buffers(ctx);
allocate_frame_buffers(ctx, avctx);
avcodec_set_dimensions(avctx, width, height);
}
y_offset = bytestream_get_le32(&buf_ptr);
v_offset = bytestream_get_le32(&buf_ptr);
u_offset = bytestream_get_le32(&buf_ptr);
/* unfortunately there is no common order of planes in the buffer */
/* so we use that sorting algo for determining planes data sizes */
starts[0] = y_offset;
starts[1] = v_offset;
starts[2] = u_offset;
for (j = 0; j < 3; j++) {
ends[j] = ctx->data_size;
for (i = 2; i >= 0; i--)
if (starts[i] < ends[j] && starts[i] > starts[j])
ends[j] = starts[i];
}
ctx->y_data_size = ends[0] - starts[0];
ctx->v_data_size = ends[1] - starts[1];
ctx->u_data_size = ends[2] - starts[2];
if (FFMAX3(y_offset, v_offset, u_offset) >= ctx->data_size - 16 ||
FFMIN3(ctx->y_data_size, ctx->v_data_size, ctx->u_data_size) <= 0) {
av_log(avctx, AV_LOG_ERROR, "One of the y/u/v offsets is invalid\n");
return AVERROR_INVALIDDATA;
}
ctx->y_data_ptr = bs_hdr + y_offset;
ctx->v_data_ptr = bs_hdr + v_offset;
ctx->u_data_ptr = bs_hdr + u_offset;
ctx->alt_quant = buf_ptr + sizeof(uint32_t);
if (ctx->data_size == 16) {
av_log(avctx, AV_LOG_DEBUG, "Sync frame encountered!\n");
return 16;
}
if (ctx->frame_flags & BS_8BIT_PEL) {
av_log_ask_for_sample(avctx, "8-bit pixel format\n");
return AVERROR_PATCHWELCOME;
}
if (ctx->frame_flags & BS_MV_X_HALF || ctx->frame_flags & BS_MV_Y_HALF) {
av_log_ask_for_sample(avctx, "halfpel motion vectors\n");
return AVERROR_PATCHWELCOME;
}
return 0;
}
| false | FFmpeg | cd645c15d8d91444e49aea589ace4d9f76210641 | static int decode_frame_headers(Indeo3DecodeContext *ctx, AVCodecContext *avctx,
const uint8_t *buf, int buf_size)
{
const uint8_t *buf_ptr = buf, *bs_hdr;
uint32_t frame_num, word2, check_sum, data_size;
uint32_t y_offset, u_offset, v_offset, starts[3], ends[3];
uint16_t height, width;
int i, j;
frame_num = bytestream_get_le32(&buf_ptr);
word2 = bytestream_get_le32(&buf_ptr);
check_sum = bytestream_get_le32(&buf_ptr);
data_size = bytestream_get_le32(&buf_ptr);
if ((frame_num ^ word2 ^ data_size ^ OS_HDR_ID) != check_sum) {
av_log(avctx, AV_LOG_ERROR, "OS header checksum mismatch!\n");
return AVERROR_INVALIDDATA;
}
bs_hdr = buf_ptr;
if (bytestream_get_le16(&buf_ptr) != 32) {
av_log(avctx, AV_LOG_ERROR, "Unsupported codec version!\n");
return AVERROR_INVALIDDATA;
}
ctx->frame_num = frame_num;
ctx->frame_flags = bytestream_get_le16(&buf_ptr);
ctx->data_size = (bytestream_get_le32(&buf_ptr) + 7) >> 3;
ctx->cb_offset = *buf_ptr++;
if (ctx->data_size == 16)
return 4;
if (ctx->data_size > buf_size)
ctx->data_size = buf_size;
buf_ptr += 3;
height = bytestream_get_le16(&buf_ptr);
width = bytestream_get_le16(&buf_ptr);
if (av_image_check_size(width, height, 0, avctx))
return AVERROR_INVALIDDATA;
if (width != ctx->width || height != ctx->height) {
av_dlog(avctx, "Frame dimensions changed!\n");
ctx->width = width;
ctx->height = height;
free_frame_buffers(ctx);
allocate_frame_buffers(ctx, avctx);
avcodec_set_dimensions(avctx, width, height);
}
y_offset = bytestream_get_le32(&buf_ptr);
v_offset = bytestream_get_le32(&buf_ptr);
u_offset = bytestream_get_le32(&buf_ptr);
starts[0] = y_offset;
starts[1] = v_offset;
starts[2] = u_offset;
for (j = 0; j < 3; j++) {
ends[j] = ctx->data_size;
for (i = 2; i >= 0; i--)
if (starts[i] < ends[j] && starts[i] > starts[j])
ends[j] = starts[i];
}
ctx->y_data_size = ends[0] - starts[0];
ctx->v_data_size = ends[1] - starts[1];
ctx->u_data_size = ends[2] - starts[2];
if (FFMAX3(y_offset, v_offset, u_offset) >= ctx->data_size - 16 ||
FFMIN3(ctx->y_data_size, ctx->v_data_size, ctx->u_data_size) <= 0) {
av_log(avctx, AV_LOG_ERROR, "One of the y/u/v offsets is invalid\n");
return AVERROR_INVALIDDATA;
}
ctx->y_data_ptr = bs_hdr + y_offset;
ctx->v_data_ptr = bs_hdr + v_offset;
ctx->u_data_ptr = bs_hdr + u_offset;
ctx->alt_quant = buf_ptr + sizeof(uint32_t);
if (ctx->data_size == 16) {
av_log(avctx, AV_LOG_DEBUG, "Sync frame encountered!\n");
return 16;
}
if (ctx->frame_flags & BS_8BIT_PEL) {
av_log_ask_for_sample(avctx, "8-bit pixel format\n");
return AVERROR_PATCHWELCOME;
}
if (ctx->frame_flags & BS_MV_X_HALF || ctx->frame_flags & BS_MV_Y_HALF) {
av_log_ask_for_sample(avctx, "halfpel motion vectors\n");
return AVERROR_PATCHWELCOME;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(Indeo3DecodeContext *VAR_0, AVCodecContext *VAR_1,
const uint8_t *VAR_2, int VAR_3)
{
const uint8_t *VAR_4 = VAR_2, *bs_hdr;
uint32_t frame_num, word2, check_sum, data_size;
uint32_t y_offset, u_offset, v_offset, starts[3], ends[3];
uint16_t height, width;
int VAR_5, VAR_6;
frame_num = bytestream_get_le32(&VAR_4);
word2 = bytestream_get_le32(&VAR_4);
check_sum = bytestream_get_le32(&VAR_4);
data_size = bytestream_get_le32(&VAR_4);
if ((frame_num ^ word2 ^ data_size ^ OS_HDR_ID) != check_sum) {
av_log(VAR_1, AV_LOG_ERROR, "OS header checksum mismatch!\n");
return AVERROR_INVALIDDATA;
}
bs_hdr = VAR_4;
if (bytestream_get_le16(&VAR_4) != 32) {
av_log(VAR_1, AV_LOG_ERROR, "Unsupported codec version!\n");
return AVERROR_INVALIDDATA;
}
VAR_0->frame_num = frame_num;
VAR_0->frame_flags = bytestream_get_le16(&VAR_4);
VAR_0->data_size = (bytestream_get_le32(&VAR_4) + 7) >> 3;
VAR_0->cb_offset = *VAR_4++;
if (VAR_0->data_size == 16)
return 4;
if (VAR_0->data_size > VAR_3)
VAR_0->data_size = VAR_3;
VAR_4 += 3;
height = bytestream_get_le16(&VAR_4);
width = bytestream_get_le16(&VAR_4);
if (av_image_check_size(width, height, 0, VAR_1))
return AVERROR_INVALIDDATA;
if (width != VAR_0->width || height != VAR_0->height) {
av_dlog(VAR_1, "Frame dimensions changed!\n");
VAR_0->width = width;
VAR_0->height = height;
free_frame_buffers(VAR_0);
allocate_frame_buffers(VAR_0, VAR_1);
avcodec_set_dimensions(VAR_1, width, height);
}
y_offset = bytestream_get_le32(&VAR_4);
v_offset = bytestream_get_le32(&VAR_4);
u_offset = bytestream_get_le32(&VAR_4);
starts[0] = y_offset;
starts[1] = v_offset;
starts[2] = u_offset;
for (VAR_6 = 0; VAR_6 < 3; VAR_6++) {
ends[VAR_6] = VAR_0->data_size;
for (VAR_5 = 2; VAR_5 >= 0; VAR_5--)
if (starts[VAR_5] < ends[VAR_6] && starts[VAR_5] > starts[VAR_6])
ends[VAR_6] = starts[VAR_5];
}
VAR_0->y_data_size = ends[0] - starts[0];
VAR_0->v_data_size = ends[1] - starts[1];
VAR_0->u_data_size = ends[2] - starts[2];
if (FFMAX3(y_offset, v_offset, u_offset) >= VAR_0->data_size - 16 ||
FFMIN3(VAR_0->y_data_size, VAR_0->v_data_size, VAR_0->u_data_size) <= 0) {
av_log(VAR_1, AV_LOG_ERROR, "One of the y/u/v offsets is invalid\n");
return AVERROR_INVALIDDATA;
}
VAR_0->y_data_ptr = bs_hdr + y_offset;
VAR_0->v_data_ptr = bs_hdr + v_offset;
VAR_0->u_data_ptr = bs_hdr + u_offset;
VAR_0->alt_quant = VAR_4 + sizeof(uint32_t);
if (VAR_0->data_size == 16) {
av_log(VAR_1, AV_LOG_DEBUG, "Sync frame encountered!\n");
return 16;
}
if (VAR_0->frame_flags & BS_8BIT_PEL) {
av_log_ask_for_sample(VAR_1, "8-bit pixel format\n");
return AVERROR_PATCHWELCOME;
}
if (VAR_0->frame_flags & BS_MV_X_HALF || VAR_0->frame_flags & BS_MV_Y_HALF) {
av_log_ask_for_sample(VAR_1, "halfpel motion vectors\n");
return AVERROR_PATCHWELCOME;
}
return 0;
}
| [
"static int FUNC_0(Indeo3DecodeContext *VAR_0, AVCodecContext *VAR_1,\nconst uint8_t *VAR_2, int VAR_3)\n{",
"const uint8_t *VAR_4 = VAR_2, *bs_hdr;",
"uint32_t frame_num, word2, check_sum, data_size;",
"uint32_t y_offset, u_offset, v_offset, starts[3], ends[3];",
"uint16_t height, width;",
"int VAR_5, VAR_6;",
"frame_num = bytestream_get_le32(&VAR_4);",
"word2 = bytestream_get_le32(&VAR_4);",
"check_sum = bytestream_get_le32(&VAR_4);",
"data_size = bytestream_get_le32(&VAR_4);",
"if ((frame_num ^ word2 ^ data_size ^ OS_HDR_ID) != check_sum) {",
"av_log(VAR_1, AV_LOG_ERROR, \"OS header checksum mismatch!\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"bs_hdr = VAR_4;",
"if (bytestream_get_le16(&VAR_4) != 32) {",
"av_log(VAR_1, AV_LOG_ERROR, \"Unsupported codec version!\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_0->frame_num = frame_num;",
"VAR_0->frame_flags = bytestream_get_le16(&VAR_4);",
"VAR_0->data_size = (bytestream_get_le32(&VAR_4) + 7) >> 3;",
"VAR_0->cb_offset = *VAR_4++;",
"if (VAR_0->data_size == 16)\nreturn 4;",
"if (VAR_0->data_size > VAR_3)\nVAR_0->data_size = VAR_3;",
"VAR_4 += 3;",
"height = bytestream_get_le16(&VAR_4);",
"width = bytestream_get_le16(&VAR_4);",
"if (av_image_check_size(width, height, 0, VAR_1))\nreturn AVERROR_INVALIDDATA;",
"if (width != VAR_0->width || height != VAR_0->height) {",
"av_dlog(VAR_1, \"Frame dimensions changed!\\n\");",
"VAR_0->width = width;",
"VAR_0->height = height;",
"free_frame_buffers(VAR_0);",
"allocate_frame_buffers(VAR_0, VAR_1);",
"avcodec_set_dimensions(VAR_1, width, height);",
"}",
"y_offset = bytestream_get_le32(&VAR_4);",
"v_offset = bytestream_get_le32(&VAR_4);",
"u_offset = bytestream_get_le32(&VAR_4);",
"starts[0] = y_offset;",
"starts[1] = v_offset;",
"starts[2] = u_offset;",
"for (VAR_6 = 0; VAR_6 < 3; VAR_6++) {",
"ends[VAR_6] = VAR_0->data_size;",
"for (VAR_5 = 2; VAR_5 >= 0; VAR_5--)",
"if (starts[VAR_5] < ends[VAR_6] && starts[VAR_5] > starts[VAR_6])\nends[VAR_6] = starts[VAR_5];",
"}",
"VAR_0->y_data_size = ends[0] - starts[0];",
"VAR_0->v_data_size = ends[1] - starts[1];",
"VAR_0->u_data_size = ends[2] - starts[2];",
"if (FFMAX3(y_offset, v_offset, u_offset) >= VAR_0->data_size - 16 ||\nFFMIN3(VAR_0->y_data_size, VAR_0->v_data_size, VAR_0->u_data_size) <= 0) {",
"av_log(VAR_1, AV_LOG_ERROR, \"One of the y/u/v offsets is invalid\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_0->y_data_ptr = bs_hdr + y_offset;",
"VAR_0->v_data_ptr = bs_hdr + v_offset;",
"VAR_0->u_data_ptr = bs_hdr + u_offset;",
"VAR_0->alt_quant = VAR_4 + sizeof(uint32_t);",
"if (VAR_0->data_size == 16) {",
"av_log(VAR_1, AV_LOG_DEBUG, \"Sync frame encountered!\\n\");",
"return 16;",
"}",
"if (VAR_0->frame_flags & BS_8BIT_PEL) {",
"av_log_ask_for_sample(VAR_1, \"8-bit pixel format\\n\");",
"return AVERROR_PATCHWELCOME;",
"}",
"if (VAR_0->frame_flags & BS_MV_X_HALF || VAR_0->frame_flags & BS_MV_Y_HALF) {",
"av_log_ask_for_sample(VAR_1, \"halfpel motion vectors\\n\");",
"return AVERROR_PATCHWELCOME;",
"}",
"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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67,
69
],
[
71,
73
],
[
77
],
[
83
],
[
85
],
[
87,
89
],
[
93
],
[
95
],
[
99
],
[
101
],
[
105
],
[
107
],
[
109
],
[
111
],
[
115
],
[
117
],
[
119
],
[
127
],
[
129
],
[
131
],
[
135
],
[
137
],
[
139
],
[
141,
143
],
[
145
],
[
149
],
[
151
],
[
153
],
[
155,
157
],
[
159
],
[
161
],
[
163
],
[
167
],
[
169
],
[
171
],
[
173
],
[
177
],
[
179
],
[
181
],
[
183
],
[
187
],
[
189
],
[
191
],
[
193
],
[
197
],
[
199
],
[
201
],
[
203
],
[
207
],
[
209
]
] |
21,140 | static void cin_decode_rle(const unsigned char *src, int src_size,
unsigned char *dst, int dst_size)
{
int len, code;
unsigned char *dst_end = dst + dst_size;
const unsigned char *src_end = src + src_size;
while (src < src_end && dst < dst_end) {
code = *src++;
if (code & 0x80) {
len = code - 0x7F;
memset(dst, *src++, FFMIN(len, dst_end - dst));
} else {
len = code + 1;
memcpy(dst, src, FFMIN(len, dst_end - dst));
src += len;
}
dst += len;
}
}
| false | FFmpeg | dd0bfc3a6a310e3e3674ce7742672d689a9a0e93 | static void cin_decode_rle(const unsigned char *src, int src_size,
unsigned char *dst, int dst_size)
{
int len, code;
unsigned char *dst_end = dst + dst_size;
const unsigned char *src_end = src + src_size;
while (src < src_end && dst < dst_end) {
code = *src++;
if (code & 0x80) {
len = code - 0x7F;
memset(dst, *src++, FFMIN(len, dst_end - dst));
} else {
len = code + 1;
memcpy(dst, src, FFMIN(len, dst_end - dst));
src += len;
}
dst += len;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(const unsigned char *VAR_0, int VAR_1,
unsigned char *VAR_2, int VAR_3)
{
int VAR_4, VAR_5;
unsigned char *VAR_6 = VAR_2 + VAR_3;
const unsigned char *VAR_7 = VAR_0 + VAR_1;
while (VAR_0 < VAR_7 && VAR_2 < VAR_6) {
VAR_5 = *VAR_0++;
if (VAR_5 & 0x80) {
VAR_4 = VAR_5 - 0x7F;
memset(VAR_2, *VAR_0++, FFMIN(VAR_4, VAR_6 - VAR_2));
} else {
VAR_4 = VAR_5 + 1;
memcpy(VAR_2, VAR_0, FFMIN(VAR_4, VAR_6 - VAR_2));
VAR_0 += VAR_4;
}
VAR_2 += VAR_4;
}
}
| [
"static void FUNC_0(const unsigned char *VAR_0, int VAR_1,\nunsigned char *VAR_2, int VAR_3)\n{",
"int VAR_4, VAR_5;",
"unsigned char *VAR_6 = VAR_2 + VAR_3;",
"const unsigned char *VAR_7 = VAR_0 + VAR_1;",
"while (VAR_0 < VAR_7 && VAR_2 < VAR_6) {",
"VAR_5 = *VAR_0++;",
"if (VAR_5 & 0x80) {",
"VAR_4 = VAR_5 - 0x7F;",
"memset(VAR_2, *VAR_0++, FFMIN(VAR_4, VAR_6 - VAR_2));",
"} else {",
"VAR_4 = VAR_5 + 1;",
"memcpy(VAR_2, VAR_0, FFMIN(VAR_4, VAR_6 - VAR_2));",
"VAR_0 += VAR_4;",
"}",
"VAR_2 += VAR_4;",
"}",
"}"
] | [
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
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
]
] |
21,142 | BlockDriverAIOCB *bdrv_aio_flush(BlockDriverState *bs,
BlockDriverCompletionFunc *cb, void *opaque)
{
BlockDriver *drv = bs->drv;
if (!drv)
return NULL;
return drv->bdrv_aio_flush(bs, cb, opaque); | true | qemu | 016f5cf6ff465411733878a17c8f8febb7668321 | BlockDriverAIOCB *bdrv_aio_flush(BlockDriverState *bs,
BlockDriverCompletionFunc *cb, void *opaque)
{
BlockDriver *drv = bs->drv;
if (!drv)
return NULL;
return drv->bdrv_aio_flush(bs, cb, opaque); | {
"code": [],
"line_no": []
} | BlockDriverAIOCB *FUNC_0(BlockDriverState *bs,
BlockDriverCompletionFunc *cb, void *opaque)
{
BlockDriver *drv = bs->drv;
if (!drv)
return NULL;
return drv->FUNC_0(bs, cb, opaque); | [
"BlockDriverAIOCB *FUNC_0(BlockDriverState *bs,\nBlockDriverCompletionFunc *cb, void *opaque)\n{",
"BlockDriver *drv = bs->drv;",
"if (!drv)\nreturn NULL;",
"return drv->FUNC_0(bs, cb, opaque);"
] | [
0,
0,
0,
0
] | [
[
1,
2,
3
],
[
4
],
[
5,
6
],
[
7
]
] |
21,143 | abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
abi_long arg2, abi_long arg3, abi_long arg4,
abi_long arg5, abi_long arg6)
{
abi_long ret;
struct stat st;
struct statfs stfs;
void *p;
#ifdef DEBUG
gemu_log("syscall %d", num);
#endif
if(do_strace)
print_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6);
switch(num) {
case TARGET_NR_exit:
#ifdef CONFIG_USE_NPTL
/* In old applications this may be used to implement _exit(2).
However in threaded applictions it is used for thread termination,
and _exit_group is used for application termination.
Do thread termination if we have more then one thread. */
/* FIXME: This probably breaks if a signal arrives. We should probably
be disabling signals. */
if (first_cpu->next_cpu) {
TaskState *ts;
CPUState **lastp;
CPUState *p;
cpu_list_lock();
lastp = &first_cpu;
p = first_cpu;
while (p && p != (CPUState *)cpu_env) {
lastp = &p->next_cpu;
p = p->next_cpu;
}
/* If we didn't find the CPU for this thread then something is
horribly wrong. */
if (!p)
abort();
/* Remove the CPU from the list. */
*lastp = p->next_cpu;
cpu_list_unlock();
ts = ((CPUState *)cpu_env)->opaque;
if (ts->child_tidptr) {
put_user_u32(0, ts->child_tidptr);
sys_futex(g2h(ts->child_tidptr), FUTEX_WAKE, INT_MAX,
NULL, NULL, 0);
}
/* TODO: Free CPU state. */
pthread_exit(NULL);
}
#endif
#ifdef TARGET_GPROF
_mcleanup();
#endif
gdb_exit(cpu_env, arg1);
_exit(arg1);
ret = 0; /* avoid warning */
break;
case TARGET_NR_read:
if (arg3 == 0)
ret = 0;
else {
if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0)))
goto efault;
ret = get_errno(read(arg1, p, arg3));
unlock_user(p, arg2, ret);
}
break;
case TARGET_NR_write:
if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1)))
goto efault;
ret = get_errno(write(arg1, p, arg3));
unlock_user(p, arg2, 0);
break;
case TARGET_NR_open:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(open(path(p),
target_to_host_bitmask(arg2, fcntl_flags_tbl),
arg3));
unlock_user(p, arg1, 0);
break;
#if defined(TARGET_NR_openat) && defined(__NR_openat)
case TARGET_NR_openat:
if (!(p = lock_user_string(arg2)))
goto efault;
ret = get_errno(sys_openat(arg1,
path(p),
target_to_host_bitmask(arg3, fcntl_flags_tbl),
arg4));
unlock_user(p, arg2, 0);
break;
#endif
case TARGET_NR_close:
ret = get_errno(close(arg1));
break;
case TARGET_NR_brk:
ret = do_brk(arg1);
break;
case TARGET_NR_fork:
ret = get_errno(do_fork(cpu_env, SIGCHLD, 0, 0, 0, 0));
break;
#ifdef TARGET_NR_waitpid
case TARGET_NR_waitpid:
{
int status;
ret = get_errno(waitpid(arg1, &status, arg3));
if (!is_error(ret) && arg2
&& put_user_s32(host_to_target_waitstatus(status), arg2))
goto efault;
}
break;
#endif
#ifdef TARGET_NR_waitid
case TARGET_NR_waitid:
{
siginfo_t info;
info.si_pid = 0;
ret = get_errno(waitid(arg1, arg2, &info, arg4));
if (!is_error(ret) && arg3 && info.si_pid != 0) {
if (!(p = lock_user(VERIFY_WRITE, arg3, sizeof(target_siginfo_t), 0)))
goto efault;
host_to_target_siginfo(p, &info);
unlock_user(p, arg3, sizeof(target_siginfo_t));
}
}
break;
#endif
#ifdef TARGET_NR_creat /* not on alpha */
case TARGET_NR_creat:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(creat(p, arg2));
unlock_user(p, arg1, 0);
break;
#endif
case TARGET_NR_link:
{
void * p2;
p = lock_user_string(arg1);
p2 = lock_user_string(arg2);
if (!p || !p2)
ret = -TARGET_EFAULT;
else
ret = get_errno(link(p, p2));
unlock_user(p2, arg2, 0);
unlock_user(p, arg1, 0);
}
break;
#if defined(TARGET_NR_linkat) && defined(__NR_linkat)
case TARGET_NR_linkat:
{
void * p2 = NULL;
if (!arg2 || !arg4)
goto efault;
p = lock_user_string(arg2);
p2 = lock_user_string(arg4);
if (!p || !p2)
ret = -TARGET_EFAULT;
else
ret = get_errno(sys_linkat(arg1, p, arg3, p2, arg5));
unlock_user(p, arg2, 0);
unlock_user(p2, arg4, 0);
}
break;
#endif
case TARGET_NR_unlink:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(unlink(p));
unlock_user(p, arg1, 0);
break;
#if defined(TARGET_NR_unlinkat) && defined(__NR_unlinkat)
case TARGET_NR_unlinkat:
if (!(p = lock_user_string(arg2)))
goto efault;
ret = get_errno(sys_unlinkat(arg1, p, arg3));
unlock_user(p, arg2, 0);
break;
#endif
case TARGET_NR_execve:
{
char **argp, **envp;
int argc, envc;
abi_ulong gp;
abi_ulong guest_argp;
abi_ulong guest_envp;
abi_ulong addr;
char **q;
argc = 0;
guest_argp = arg2;
for (gp = guest_argp; gp; gp += sizeof(abi_ulong)) {
if (get_user_ual(addr, gp))
goto efault;
if (!addr)
break;
argc++;
}
envc = 0;
guest_envp = arg3;
for (gp = guest_envp; gp; gp += sizeof(abi_ulong)) {
if (get_user_ual(addr, gp))
goto efault;
if (!addr)
break;
envc++;
}
argp = alloca((argc + 1) * sizeof(void *));
envp = alloca((envc + 1) * sizeof(void *));
for (gp = guest_argp, q = argp; gp;
gp += sizeof(abi_ulong), q++) {
if (get_user_ual(addr, gp))
goto execve_efault;
if (!addr)
break;
if (!(*q = lock_user_string(addr)))
goto execve_efault;
}
*q = NULL;
for (gp = guest_envp, q = envp; gp;
gp += sizeof(abi_ulong), q++) {
if (get_user_ual(addr, gp))
goto execve_efault;
if (!addr)
break;
if (!(*q = lock_user_string(addr)))
goto execve_efault;
}
*q = NULL;
if (!(p = lock_user_string(arg1)))
goto execve_efault;
ret = get_errno(execve(p, argp, envp));
unlock_user(p, arg1, 0);
goto execve_end;
execve_efault:
ret = -TARGET_EFAULT;
execve_end:
for (gp = guest_argp, q = argp; *q;
gp += sizeof(abi_ulong), q++) {
if (get_user_ual(addr, gp)
|| !addr)
break;
unlock_user(*q, addr, 0);
}
for (gp = guest_envp, q = envp; *q;
gp += sizeof(abi_ulong), q++) {
if (get_user_ual(addr, gp)
|| !addr)
break;
unlock_user(*q, addr, 0);
}
}
break;
case TARGET_NR_chdir:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(chdir(p));
unlock_user(p, arg1, 0);
break;
#ifdef TARGET_NR_time
case TARGET_NR_time:
{
time_t host_time;
ret = get_errno(time(&host_time));
if (!is_error(ret)
&& arg1
&& put_user_sal(host_time, arg1))
goto efault;
}
break;
#endif
case TARGET_NR_mknod:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(mknod(p, arg2, arg3));
unlock_user(p, arg1, 0);
break;
#if defined(TARGET_NR_mknodat) && defined(__NR_mknodat)
case TARGET_NR_mknodat:
if (!(p = lock_user_string(arg2)))
goto efault;
ret = get_errno(sys_mknodat(arg1, p, arg3, arg4));
unlock_user(p, arg2, 0);
break;
#endif
case TARGET_NR_chmod:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(chmod(p, arg2));
unlock_user(p, arg1, 0);
break;
#ifdef TARGET_NR_break
case TARGET_NR_break:
goto unimplemented;
#endif
#ifdef TARGET_NR_oldstat
case TARGET_NR_oldstat:
goto unimplemented;
#endif
case TARGET_NR_lseek:
ret = get_errno(lseek(arg1, arg2, arg3));
break;
#ifdef TARGET_NR_getxpid
case TARGET_NR_getxpid:
#else
case TARGET_NR_getpid:
#endif
ret = get_errno(getpid());
break;
case TARGET_NR_mount:
{
/* need to look at the data field */
void *p2, *p3;
p = lock_user_string(arg1);
p2 = lock_user_string(arg2);
p3 = lock_user_string(arg3);
if (!p || !p2 || !p3)
ret = -TARGET_EFAULT;
else
/* FIXME - arg5 should be locked, but it isn't clear how to
* do that since it's not guaranteed to be a NULL-terminated
* string.
*/
ret = get_errno(mount(p, p2, p3, (unsigned long)arg4, g2h(arg5)));
unlock_user(p, arg1, 0);
unlock_user(p2, arg2, 0);
unlock_user(p3, arg3, 0);
break;
}
#ifdef TARGET_NR_umount
case TARGET_NR_umount:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(umount(p));
unlock_user(p, arg1, 0);
break;
#endif
#ifdef TARGET_NR_stime /* not on alpha */
case TARGET_NR_stime:
{
time_t host_time;
if (get_user_sal(host_time, arg1))
goto efault;
ret = get_errno(stime(&host_time));
}
break;
#endif
case TARGET_NR_ptrace:
goto unimplemented;
#ifdef TARGET_NR_alarm /* not on alpha */
case TARGET_NR_alarm:
ret = alarm(arg1);
break;
#endif
#ifdef TARGET_NR_oldfstat
case TARGET_NR_oldfstat:
goto unimplemented;
#endif
#ifdef TARGET_NR_pause /* not on alpha */
case TARGET_NR_pause:
ret = get_errno(pause());
break;
#endif
#ifdef TARGET_NR_utime
case TARGET_NR_utime:
{
struct utimbuf tbuf, *host_tbuf;
struct target_utimbuf *target_tbuf;
if (arg2) {
if (!lock_user_struct(VERIFY_READ, target_tbuf, arg2, 1))
goto efault;
tbuf.actime = tswapl(target_tbuf->actime);
tbuf.modtime = tswapl(target_tbuf->modtime);
unlock_user_struct(target_tbuf, arg2, 0);
host_tbuf = &tbuf;
} else {
host_tbuf = NULL;
}
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(utime(p, host_tbuf));
unlock_user(p, arg1, 0);
}
break;
#endif
case TARGET_NR_utimes:
{
struct timeval *tvp, tv[2];
if (arg2) {
if (copy_from_user_timeval(&tv[0], arg2)
|| copy_from_user_timeval(&tv[1],
arg2 + sizeof(struct target_timeval)))
goto efault;
tvp = tv;
} else {
tvp = NULL;
}
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(utimes(p, tvp));
unlock_user(p, arg1, 0);
}
break;
#if defined(TARGET_NR_futimesat) && defined(__NR_futimesat)
case TARGET_NR_futimesat:
{
struct timeval *tvp, tv[2];
if (arg3) {
if (copy_from_user_timeval(&tv[0], arg3)
|| copy_from_user_timeval(&tv[1],
arg3 + sizeof(struct target_timeval)))
goto efault;
tvp = tv;
} else {
tvp = NULL;
}
if (!(p = lock_user_string(arg2)))
goto efault;
ret = get_errno(sys_futimesat(arg1, path(p), tvp));
unlock_user(p, arg2, 0);
}
break;
#endif
#ifdef TARGET_NR_stty
case TARGET_NR_stty:
goto unimplemented;
#endif
#ifdef TARGET_NR_gtty
case TARGET_NR_gtty:
goto unimplemented;
#endif
case TARGET_NR_access:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(access(path(p), arg2));
unlock_user(p, arg1, 0);
break;
#if defined(TARGET_NR_faccessat) && defined(__NR_faccessat)
case TARGET_NR_faccessat:
if (!(p = lock_user_string(arg2)))
goto efault;
ret = get_errno(sys_faccessat(arg1, p, arg3));
unlock_user(p, arg2, 0);
break;
#endif
#ifdef TARGET_NR_nice /* not on alpha */
case TARGET_NR_nice:
ret = get_errno(nice(arg1));
break;
#endif
#ifdef TARGET_NR_ftime
case TARGET_NR_ftime:
goto unimplemented;
#endif
case TARGET_NR_sync:
sync();
ret = 0;
break;
case TARGET_NR_kill:
ret = get_errno(kill(arg1, target_to_host_signal(arg2)));
break;
case TARGET_NR_rename:
{
void *p2;
p = lock_user_string(arg1);
p2 = lock_user_string(arg2);
if (!p || !p2)
ret = -TARGET_EFAULT;
else
ret = get_errno(rename(p, p2));
unlock_user(p2, arg2, 0);
unlock_user(p, arg1, 0);
}
break;
#if defined(TARGET_NR_renameat) && defined(__NR_renameat)
case TARGET_NR_renameat:
{
void *p2;
p = lock_user_string(arg2);
p2 = lock_user_string(arg4);
if (!p || !p2)
ret = -TARGET_EFAULT;
else
ret = get_errno(sys_renameat(arg1, p, arg3, p2));
unlock_user(p2, arg4, 0);
unlock_user(p, arg2, 0);
}
break;
#endif
case TARGET_NR_mkdir:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(mkdir(p, arg2));
unlock_user(p, arg1, 0);
break;
#if defined(TARGET_NR_mkdirat) && defined(__NR_mkdirat)
case TARGET_NR_mkdirat:
if (!(p = lock_user_string(arg2)))
goto efault;
ret = get_errno(sys_mkdirat(arg1, p, arg3));
unlock_user(p, arg2, 0);
break;
#endif
case TARGET_NR_rmdir:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(rmdir(p));
unlock_user(p, arg1, 0);
break;
case TARGET_NR_dup:
ret = get_errno(dup(arg1));
break;
case TARGET_NR_pipe:
ret = do_pipe(cpu_env, arg1, 0);
break;
#ifdef TARGET_NR_pipe2
case TARGET_NR_pipe2:
ret = do_pipe(cpu_env, arg1, arg2);
break;
#endif
case TARGET_NR_times:
{
struct target_tms *tmsp;
struct tms tms;
ret = get_errno(times(&tms));
if (arg1) {
tmsp = lock_user(VERIFY_WRITE, arg1, sizeof(struct target_tms), 0);
if (!tmsp)
goto efault;
tmsp->tms_utime = tswapl(host_to_target_clock_t(tms.tms_utime));
tmsp->tms_stime = tswapl(host_to_target_clock_t(tms.tms_stime));
tmsp->tms_cutime = tswapl(host_to_target_clock_t(tms.tms_cutime));
tmsp->tms_cstime = tswapl(host_to_target_clock_t(tms.tms_cstime));
}
if (!is_error(ret))
ret = host_to_target_clock_t(ret);
}
break;
#ifdef TARGET_NR_prof
case TARGET_NR_prof:
goto unimplemented;
#endif
#ifdef TARGET_NR_signal
case TARGET_NR_signal:
goto unimplemented;
#endif
case TARGET_NR_acct:
if (arg1 == 0) {
ret = get_errno(acct(NULL));
} else {
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(acct(path(p)));
unlock_user(p, arg1, 0);
}
break;
#ifdef TARGET_NR_umount2 /* not on alpha */
case TARGET_NR_umount2:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(umount2(p, arg2));
unlock_user(p, arg1, 0);
break;
#endif
#ifdef TARGET_NR_lock
case TARGET_NR_lock:
goto unimplemented;
#endif
case TARGET_NR_ioctl:
ret = do_ioctl(arg1, arg2, arg3);
break;
case TARGET_NR_fcntl:
ret = do_fcntl(arg1, arg2, arg3);
break;
#ifdef TARGET_NR_mpx
case TARGET_NR_mpx:
goto unimplemented;
#endif
case TARGET_NR_setpgid:
ret = get_errno(setpgid(arg1, arg2));
break;
#ifdef TARGET_NR_ulimit
case TARGET_NR_ulimit:
goto unimplemented;
#endif
#ifdef TARGET_NR_oldolduname
case TARGET_NR_oldolduname:
goto unimplemented;
#endif
case TARGET_NR_umask:
ret = get_errno(umask(arg1));
break;
case TARGET_NR_chroot:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(chroot(p));
unlock_user(p, arg1, 0);
break;
case TARGET_NR_ustat:
goto unimplemented;
case TARGET_NR_dup2:
ret = get_errno(dup2(arg1, arg2));
break;
#ifdef TARGET_NR_getppid /* not on alpha */
case TARGET_NR_getppid:
ret = get_errno(getppid());
break;
#endif
case TARGET_NR_getpgrp:
ret = get_errno(getpgrp());
break;
case TARGET_NR_setsid:
ret = get_errno(setsid());
break;
#ifdef TARGET_NR_sigaction
case TARGET_NR_sigaction:
{
#if !defined(TARGET_MIPS)
struct target_old_sigaction *old_act;
struct target_sigaction act, oact, *pact;
if (arg2) {
if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1))
goto efault;
act._sa_handler = old_act->_sa_handler;
target_siginitset(&act.sa_mask, old_act->sa_mask);
act.sa_flags = old_act->sa_flags;
act.sa_restorer = old_act->sa_restorer;
unlock_user_struct(old_act, arg2, 0);
pact = &act;
} else {
pact = NULL;
}
ret = get_errno(do_sigaction(arg1, pact, &oact));
if (!is_error(ret) && arg3) {
if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0))
goto efault;
old_act->_sa_handler = oact._sa_handler;
old_act->sa_mask = oact.sa_mask.sig[0];
old_act->sa_flags = oact.sa_flags;
old_act->sa_restorer = oact.sa_restorer;
unlock_user_struct(old_act, arg3, 1);
}
#else
struct target_sigaction act, oact, *pact, *old_act;
if (arg2) {
if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1))
goto efault;
act._sa_handler = old_act->_sa_handler;
target_siginitset(&act.sa_mask, old_act->sa_mask.sig[0]);
act.sa_flags = old_act->sa_flags;
unlock_user_struct(old_act, arg2, 0);
pact = &act;
} else {
pact = NULL;
}
ret = get_errno(do_sigaction(arg1, pact, &oact));
if (!is_error(ret) && arg3) {
if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0))
goto efault;
old_act->_sa_handler = oact._sa_handler;
old_act->sa_flags = oact.sa_flags;
old_act->sa_mask.sig[0] = oact.sa_mask.sig[0];
old_act->sa_mask.sig[1] = 0;
old_act->sa_mask.sig[2] = 0;
old_act->sa_mask.sig[3] = 0;
unlock_user_struct(old_act, arg3, 1);
}
#endif
}
break;
#endif
case TARGET_NR_rt_sigaction:
{
struct target_sigaction *act;
struct target_sigaction *oact;
if (arg2) {
if (!lock_user_struct(VERIFY_READ, act, arg2, 1))
goto efault;
} else
act = NULL;
if (arg3) {
if (!lock_user_struct(VERIFY_WRITE, oact, arg3, 0)) {
ret = -TARGET_EFAULT;
goto rt_sigaction_fail;
}
} else
oact = NULL;
ret = get_errno(do_sigaction(arg1, act, oact));
rt_sigaction_fail:
if (act)
unlock_user_struct(act, arg2, 0);
if (oact)
unlock_user_struct(oact, arg3, 1);
}
break;
#ifdef TARGET_NR_sgetmask /* not on alpha */
case TARGET_NR_sgetmask:
{
sigset_t cur_set;
abi_ulong target_set;
sigprocmask(0, NULL, &cur_set);
host_to_target_old_sigset(&target_set, &cur_set);
ret = target_set;
}
break;
#endif
#ifdef TARGET_NR_ssetmask /* not on alpha */
case TARGET_NR_ssetmask:
{
sigset_t set, oset, cur_set;
abi_ulong target_set = arg1;
sigprocmask(0, NULL, &cur_set);
target_to_host_old_sigset(&set, &target_set);
sigorset(&set, &set, &cur_set);
sigprocmask(SIG_SETMASK, &set, &oset);
host_to_target_old_sigset(&target_set, &oset);
ret = target_set;
}
break;
#endif
#ifdef TARGET_NR_sigprocmask
case TARGET_NR_sigprocmask:
{
int how = arg1;
sigset_t set, oldset, *set_ptr;
if (arg2) {
switch(how) {
case TARGET_SIG_BLOCK:
how = SIG_BLOCK;
break;
case TARGET_SIG_UNBLOCK:
how = SIG_UNBLOCK;
break;
case TARGET_SIG_SETMASK:
how = SIG_SETMASK;
break;
default:
ret = -TARGET_EINVAL;
goto fail;
}
if (!(p = lock_user(VERIFY_READ, arg2, sizeof(target_sigset_t), 1)))
goto efault;
target_to_host_old_sigset(&set, p);
unlock_user(p, arg2, 0);
set_ptr = &set;
} else {
how = 0;
set_ptr = NULL;
}
ret = get_errno(sigprocmask(arg1, set_ptr, &oldset));
if (!is_error(ret) && arg3) {
if (!(p = lock_user(VERIFY_WRITE, arg3, sizeof(target_sigset_t), 0)))
goto efault;
host_to_target_old_sigset(p, &oldset);
unlock_user(p, arg3, sizeof(target_sigset_t));
}
}
break;
#endif
case TARGET_NR_rt_sigprocmask:
{
int how = arg1;
sigset_t set, oldset, *set_ptr;
if (arg2) {
switch(how) {
case TARGET_SIG_BLOCK:
how = SIG_BLOCK;
break;
case TARGET_SIG_UNBLOCK:
how = SIG_UNBLOCK;
break;
case TARGET_SIG_SETMASK:
how = SIG_SETMASK;
break;
default:
ret = -TARGET_EINVAL;
goto fail;
}
if (!(p = lock_user(VERIFY_READ, arg2, sizeof(target_sigset_t), 1)))
goto efault;
target_to_host_sigset(&set, p);
unlock_user(p, arg2, 0);
set_ptr = &set;
} else {
how = 0;
set_ptr = NULL;
}
ret = get_errno(sigprocmask(how, set_ptr, &oldset));
if (!is_error(ret) && arg3) {
if (!(p = lock_user(VERIFY_WRITE, arg3, sizeof(target_sigset_t), 0)))
goto efault;
host_to_target_sigset(p, &oldset);
unlock_user(p, arg3, sizeof(target_sigset_t));
}
}
break;
#ifdef TARGET_NR_sigpending
case TARGET_NR_sigpending:
{
sigset_t set;
ret = get_errno(sigpending(&set));
if (!is_error(ret)) {
if (!(p = lock_user(VERIFY_WRITE, arg1, sizeof(target_sigset_t), 0)))
goto efault;
host_to_target_old_sigset(p, &set);
unlock_user(p, arg1, sizeof(target_sigset_t));
}
}
break;
#endif
case TARGET_NR_rt_sigpending:
{
sigset_t set;
ret = get_errno(sigpending(&set));
if (!is_error(ret)) {
if (!(p = lock_user(VERIFY_WRITE, arg1, sizeof(target_sigset_t), 0)))
goto efault;
host_to_target_sigset(p, &set);
unlock_user(p, arg1, sizeof(target_sigset_t));
}
}
break;
#ifdef TARGET_NR_sigsuspend
case TARGET_NR_sigsuspend:
{
sigset_t set;
if (!(p = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1)))
goto efault;
target_to_host_old_sigset(&set, p);
unlock_user(p, arg1, 0);
ret = get_errno(sigsuspend(&set));
}
break;
#endif
case TARGET_NR_rt_sigsuspend:
{
sigset_t set;
if (!(p = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1)))
goto efault;
target_to_host_sigset(&set, p);
unlock_user(p, arg1, 0);
ret = get_errno(sigsuspend(&set));
}
break;
case TARGET_NR_rt_sigtimedwait:
{
sigset_t set;
struct timespec uts, *puts;
siginfo_t uinfo;
if (!(p = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1)))
goto efault;
target_to_host_sigset(&set, p);
unlock_user(p, arg1, 0);
if (arg3) {
puts = &uts;
target_to_host_timespec(puts, arg3);
} else {
puts = NULL;
}
ret = get_errno(sigtimedwait(&set, &uinfo, puts));
if (!is_error(ret) && arg2) {
if (!(p = lock_user(VERIFY_WRITE, arg2, sizeof(target_siginfo_t), 0)))
goto efault;
host_to_target_siginfo(p, &uinfo);
unlock_user(p, arg2, sizeof(target_siginfo_t));
}
}
break;
case TARGET_NR_rt_sigqueueinfo:
{
siginfo_t uinfo;
if (!(p = lock_user(VERIFY_READ, arg3, sizeof(target_sigset_t), 1)))
goto efault;
target_to_host_siginfo(&uinfo, p);
unlock_user(p, arg1, 0);
ret = get_errno(sys_rt_sigqueueinfo(arg1, arg2, &uinfo));
}
break;
#ifdef TARGET_NR_sigreturn
case TARGET_NR_sigreturn:
/* NOTE: ret is eax, so not transcoding must be done */
ret = do_sigreturn(cpu_env);
break;
#endif
case TARGET_NR_rt_sigreturn:
/* NOTE: ret is eax, so not transcoding must be done */
ret = do_rt_sigreturn(cpu_env);
break;
case TARGET_NR_sethostname:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(sethostname(p, arg2));
unlock_user(p, arg1, 0);
break;
case TARGET_NR_setrlimit:
{
/* XXX: convert resource ? */
int resource = arg1;
struct target_rlimit *target_rlim;
struct rlimit rlim;
if (!lock_user_struct(VERIFY_READ, target_rlim, arg2, 1))
goto efault;
rlim.rlim_cur = tswapl(target_rlim->rlim_cur);
rlim.rlim_max = tswapl(target_rlim->rlim_max);
unlock_user_struct(target_rlim, arg2, 0);
ret = get_errno(setrlimit(resource, &rlim));
}
break;
case TARGET_NR_getrlimit:
{
/* XXX: convert resource ? */
int resource = arg1;
struct target_rlimit *target_rlim;
struct rlimit rlim;
ret = get_errno(getrlimit(resource, &rlim));
if (!is_error(ret)) {
if (!lock_user_struct(VERIFY_WRITE, target_rlim, arg2, 0))
goto efault;
target_rlim->rlim_cur = tswapl(rlim.rlim_cur);
target_rlim->rlim_max = tswapl(rlim.rlim_max);
unlock_user_struct(target_rlim, arg2, 1);
}
}
break;
case TARGET_NR_getrusage:
{
struct rusage rusage;
ret = get_errno(getrusage(arg1, &rusage));
if (!is_error(ret)) {
host_to_target_rusage(arg2, &rusage);
}
}
break;
case TARGET_NR_gettimeofday:
{
struct timeval tv;
ret = get_errno(gettimeofday(&tv, NULL));
if (!is_error(ret)) {
if (copy_to_user_timeval(arg1, &tv))
goto efault;
}
}
break;
case TARGET_NR_settimeofday:
{
struct timeval tv;
if (copy_from_user_timeval(&tv, arg1))
goto efault;
ret = get_errno(settimeofday(&tv, NULL));
}
break;
#ifdef TARGET_NR_select
case TARGET_NR_select:
{
struct target_sel_arg_struct *sel;
abi_ulong inp, outp, exp, tvp;
long nsel;
if (!lock_user_struct(VERIFY_READ, sel, arg1, 1))
goto efault;
nsel = tswapl(sel->n);
inp = tswapl(sel->inp);
outp = tswapl(sel->outp);
exp = tswapl(sel->exp);
tvp = tswapl(sel->tvp);
unlock_user_struct(sel, arg1, 0);
ret = do_select(nsel, inp, outp, exp, tvp);
}
break;
#endif
case TARGET_NR_symlink:
{
void *p2;
p = lock_user_string(arg1);
p2 = lock_user_string(arg2);
if (!p || !p2)
ret = -TARGET_EFAULT;
else
ret = get_errno(symlink(p, p2));
unlock_user(p2, arg2, 0);
unlock_user(p, arg1, 0);
}
break;
#if defined(TARGET_NR_symlinkat) && defined(__NR_symlinkat)
case TARGET_NR_symlinkat:
{
void *p2;
p = lock_user_string(arg1);
p2 = lock_user_string(arg3);
if (!p || !p2)
ret = -TARGET_EFAULT;
else
ret = get_errno(sys_symlinkat(p, arg2, p2));
unlock_user(p2, arg3, 0);
unlock_user(p, arg1, 0);
}
break;
#endif
#ifdef TARGET_NR_oldlstat
case TARGET_NR_oldlstat:
goto unimplemented;
#endif
case TARGET_NR_readlink:
{
void *p2, *temp;
p = lock_user_string(arg1);
p2 = lock_user(VERIFY_WRITE, arg2, arg3, 0);
if (!p || !p2)
ret = -TARGET_EFAULT;
else {
if (strncmp((const char *)p, "/proc/self/exe", 14) == 0) {
char real[PATH_MAX];
temp = realpath(exec_path,real);
ret = (temp==NULL) ? get_errno(-1) : strlen(real) ;
snprintf((char *)p2, arg3, "%s", real);
}
else
ret = get_errno(readlink(path(p), p2, arg3));
}
unlock_user(p2, arg2, ret);
unlock_user(p, arg1, 0);
}
break;
#if defined(TARGET_NR_readlinkat) && defined(__NR_readlinkat)
case TARGET_NR_readlinkat:
{
void *p2;
p = lock_user_string(arg2);
p2 = lock_user(VERIFY_WRITE, arg3, arg4, 0);
if (!p || !p2)
ret = -TARGET_EFAULT;
else
ret = get_errno(sys_readlinkat(arg1, path(p), p2, arg4));
unlock_user(p2, arg3, ret);
unlock_user(p, arg2, 0);
}
break;
#endif
#ifdef TARGET_NR_uselib
case TARGET_NR_uselib:
goto unimplemented;
#endif
#ifdef TARGET_NR_swapon
case TARGET_NR_swapon:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(swapon(p, arg2));
unlock_user(p, arg1, 0);
break;
#endif
case TARGET_NR_reboot:
goto unimplemented;
#ifdef TARGET_NR_readdir
case TARGET_NR_readdir:
goto unimplemented;
#endif
#ifdef TARGET_NR_mmap
case TARGET_NR_mmap:
#if (defined(TARGET_I386) && defined(TARGET_ABI32)) || defined(TARGET_ARM) || defined(TARGET_M68K) || defined(TARGET_CRIS) || defined(TARGET_MICROBLAZE)
{
abi_ulong *v;
abi_ulong v1, v2, v3, v4, v5, v6;
if (!(v = lock_user(VERIFY_READ, arg1, 6 * sizeof(abi_ulong), 1)))
goto efault;
v1 = tswapl(v[0]);
v2 = tswapl(v[1]);
v3 = tswapl(v[2]);
v4 = tswapl(v[3]);
v5 = tswapl(v[4]);
v6 = tswapl(v[5]);
unlock_user(v, arg1, 0);
ret = get_errno(target_mmap(v1, v2, v3,
target_to_host_bitmask(v4, mmap_flags_tbl),
v5, v6));
}
#else
ret = get_errno(target_mmap(arg1, arg2, arg3,
target_to_host_bitmask(arg4, mmap_flags_tbl),
arg5,
arg6));
#endif
break;
#endif
#ifdef TARGET_NR_mmap2
case TARGET_NR_mmap2:
#ifndef MMAP_SHIFT
#define MMAP_SHIFT 12
#endif
ret = get_errno(target_mmap(arg1, arg2, arg3,
target_to_host_bitmask(arg4, mmap_flags_tbl),
arg5,
arg6 << MMAP_SHIFT));
break;
#endif
case TARGET_NR_munmap:
ret = get_errno(target_munmap(arg1, arg2));
break;
case TARGET_NR_mprotect:
ret = get_errno(target_mprotect(arg1, arg2, arg3));
break;
#ifdef TARGET_NR_mremap
case TARGET_NR_mremap:
ret = get_errno(target_mremap(arg1, arg2, arg3, arg4, arg5));
break;
#endif
/* ??? msync/mlock/munlock are broken for softmmu. */
#ifdef TARGET_NR_msync
case TARGET_NR_msync:
ret = get_errno(msync(g2h(arg1), arg2, arg3));
break;
#endif
#ifdef TARGET_NR_mlock
case TARGET_NR_mlock:
ret = get_errno(mlock(g2h(arg1), arg2));
break;
#endif
#ifdef TARGET_NR_munlock
case TARGET_NR_munlock:
ret = get_errno(munlock(g2h(arg1), arg2));
break;
#endif
#ifdef TARGET_NR_mlockall
case TARGET_NR_mlockall:
ret = get_errno(mlockall(arg1));
break;
#endif
#ifdef TARGET_NR_munlockall
case TARGET_NR_munlockall:
ret = get_errno(munlockall());
break;
#endif
case TARGET_NR_truncate:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(truncate(p, arg2));
unlock_user(p, arg1, 0);
break;
case TARGET_NR_ftruncate:
ret = get_errno(ftruncate(arg1, arg2));
break;
case TARGET_NR_fchmod:
ret = get_errno(fchmod(arg1, arg2));
break;
#if defined(TARGET_NR_fchmodat) && defined(__NR_fchmodat)
case TARGET_NR_fchmodat:
if (!(p = lock_user_string(arg2)))
goto efault;
ret = get_errno(sys_fchmodat(arg1, p, arg3));
unlock_user(p, arg2, 0);
break;
#endif
case TARGET_NR_getpriority:
/* libc does special remapping of the return value of
* sys_getpriority() so it's just easiest to call
* sys_getpriority() directly rather than through libc. */
ret = sys_getpriority(arg1, arg2);
break;
case TARGET_NR_setpriority:
ret = get_errno(setpriority(arg1, arg2, arg3));
break;
#ifdef TARGET_NR_profil
case TARGET_NR_profil:
goto unimplemented;
#endif
case TARGET_NR_statfs:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(statfs(path(p), &stfs));
unlock_user(p, arg1, 0);
convert_statfs:
if (!is_error(ret)) {
struct target_statfs *target_stfs;
if (!lock_user_struct(VERIFY_WRITE, target_stfs, arg2, 0))
goto efault;
__put_user(stfs.f_type, &target_stfs->f_type);
__put_user(stfs.f_bsize, &target_stfs->f_bsize);
__put_user(stfs.f_blocks, &target_stfs->f_blocks);
__put_user(stfs.f_bfree, &target_stfs->f_bfree);
__put_user(stfs.f_bavail, &target_stfs->f_bavail);
__put_user(stfs.f_files, &target_stfs->f_files);
__put_user(stfs.f_ffree, &target_stfs->f_ffree);
__put_user(stfs.f_fsid.__val[0], &target_stfs->f_fsid.val[0]);
__put_user(stfs.f_fsid.__val[1], &target_stfs->f_fsid.val[1]);
__put_user(stfs.f_namelen, &target_stfs->f_namelen);
unlock_user_struct(target_stfs, arg2, 1);
}
break;
case TARGET_NR_fstatfs:
ret = get_errno(fstatfs(arg1, &stfs));
goto convert_statfs;
#ifdef TARGET_NR_statfs64
case TARGET_NR_statfs64:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(statfs(path(p), &stfs));
unlock_user(p, arg1, 0);
convert_statfs64:
if (!is_error(ret)) {
struct target_statfs64 *target_stfs;
if (!lock_user_struct(VERIFY_WRITE, target_stfs, arg3, 0))
goto efault;
__put_user(stfs.f_type, &target_stfs->f_type);
__put_user(stfs.f_bsize, &target_stfs->f_bsize);
__put_user(stfs.f_blocks, &target_stfs->f_blocks);
__put_user(stfs.f_bfree, &target_stfs->f_bfree);
__put_user(stfs.f_bavail, &target_stfs->f_bavail);
__put_user(stfs.f_files, &target_stfs->f_files);
__put_user(stfs.f_ffree, &target_stfs->f_ffree);
__put_user(stfs.f_fsid.__val[0], &target_stfs->f_fsid.val[0]);
__put_user(stfs.f_fsid.__val[1], &target_stfs->f_fsid.val[1]);
__put_user(stfs.f_namelen, &target_stfs->f_namelen);
unlock_user_struct(target_stfs, arg3, 1);
}
break;
case TARGET_NR_fstatfs64:
ret = get_errno(fstatfs(arg1, &stfs));
goto convert_statfs64;
#endif
#ifdef TARGET_NR_ioperm
case TARGET_NR_ioperm:
goto unimplemented;
#endif
#ifdef TARGET_NR_socketcall
case TARGET_NR_socketcall:
ret = do_socketcall(arg1, arg2);
break;
#endif
#ifdef TARGET_NR_accept
case TARGET_NR_accept:
ret = do_accept(arg1, arg2, arg3);
break;
#endif
#ifdef TARGET_NR_bind
case TARGET_NR_bind:
ret = do_bind(arg1, arg2, arg3);
break;
#endif
#ifdef TARGET_NR_connect
case TARGET_NR_connect:
ret = do_connect(arg1, arg2, arg3);
break;
#endif
#ifdef TARGET_NR_getpeername
case TARGET_NR_getpeername:
ret = do_getpeername(arg1, arg2, arg3);
break;
#endif
#ifdef TARGET_NR_getsockname
case TARGET_NR_getsockname:
ret = do_getsockname(arg1, arg2, arg3);
break;
#endif
#ifdef TARGET_NR_getsockopt
case TARGET_NR_getsockopt:
ret = do_getsockopt(arg1, arg2, arg3, arg4, arg5);
break;
#endif
#ifdef TARGET_NR_listen
case TARGET_NR_listen:
ret = get_errno(listen(arg1, arg2));
break;
#endif
#ifdef TARGET_NR_recv
case TARGET_NR_recv:
ret = do_recvfrom(arg1, arg2, arg3, arg4, 0, 0);
break;
#endif
#ifdef TARGET_NR_recvfrom
case TARGET_NR_recvfrom:
ret = do_recvfrom(arg1, arg2, arg3, arg4, arg5, arg6);
break;
#endif
#ifdef TARGET_NR_recvmsg
case TARGET_NR_recvmsg:
ret = do_sendrecvmsg(arg1, arg2, arg3, 0);
break;
#endif
#ifdef TARGET_NR_send
case TARGET_NR_send:
ret = do_sendto(arg1, arg2, arg3, arg4, 0, 0);
break;
#endif
#ifdef TARGET_NR_sendmsg
case TARGET_NR_sendmsg:
ret = do_sendrecvmsg(arg1, arg2, arg3, 1);
break;
#endif
#ifdef TARGET_NR_sendto
case TARGET_NR_sendto:
ret = do_sendto(arg1, arg2, arg3, arg4, arg5, arg6);
break;
#endif
#ifdef TARGET_NR_shutdown
case TARGET_NR_shutdown:
ret = get_errno(shutdown(arg1, arg2));
break;
#endif
#ifdef TARGET_NR_socket
case TARGET_NR_socket:
ret = do_socket(arg1, arg2, arg3);
break;
#endif
#ifdef TARGET_NR_socketpair
case TARGET_NR_socketpair:
ret = do_socketpair(arg1, arg2, arg3, arg4);
break;
#endif
#ifdef TARGET_NR_setsockopt
case TARGET_NR_setsockopt:
ret = do_setsockopt(arg1, arg2, arg3, arg4, (socklen_t) arg5);
break;
#endif
case TARGET_NR_syslog:
if (!(p = lock_user_string(arg2)))
goto efault;
ret = get_errno(sys_syslog((int)arg1, p, (int)arg3));
unlock_user(p, arg2, 0);
break;
case TARGET_NR_setitimer:
{
struct itimerval value, ovalue, *pvalue;
if (arg2) {
pvalue = &value;
if (copy_from_user_timeval(&pvalue->it_interval, arg2)
|| copy_from_user_timeval(&pvalue->it_value,
arg2 + sizeof(struct target_timeval)))
goto efault;
} else {
pvalue = NULL;
}
ret = get_errno(setitimer(arg1, pvalue, &ovalue));
if (!is_error(ret) && arg3) {
if (copy_to_user_timeval(arg3,
&ovalue.it_interval)
|| copy_to_user_timeval(arg3 + sizeof(struct target_timeval),
&ovalue.it_value))
goto efault;
}
}
break;
case TARGET_NR_getitimer:
{
struct itimerval value;
ret = get_errno(getitimer(arg1, &value));
if (!is_error(ret) && arg2) {
if (copy_to_user_timeval(arg2,
&value.it_interval)
|| copy_to_user_timeval(arg2 + sizeof(struct target_timeval),
&value.it_value))
goto efault;
}
}
break;
case TARGET_NR_stat:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(stat(path(p), &st));
unlock_user(p, arg1, 0);
goto do_stat;
case TARGET_NR_lstat:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(lstat(path(p), &st));
unlock_user(p, arg1, 0);
goto do_stat;
case TARGET_NR_fstat:
{
ret = get_errno(fstat(arg1, &st));
do_stat:
if (!is_error(ret)) {
struct target_stat *target_st;
if (!lock_user_struct(VERIFY_WRITE, target_st, arg2, 0))
goto efault;
__put_user(st.st_dev, &target_st->st_dev);
__put_user(st.st_ino, &target_st->st_ino);
__put_user(st.st_mode, &target_st->st_mode);
__put_user(st.st_uid, &target_st->st_uid);
__put_user(st.st_gid, &target_st->st_gid);
__put_user(st.st_nlink, &target_st->st_nlink);
__put_user(st.st_rdev, &target_st->st_rdev);
__put_user(st.st_size, &target_st->st_size);
__put_user(st.st_blksize, &target_st->st_blksize);
__put_user(st.st_blocks, &target_st->st_blocks);
__put_user(st.st_atime, &target_st->target_st_atime);
__put_user(st.st_mtime, &target_st->target_st_mtime);
__put_user(st.st_ctime, &target_st->target_st_ctime);
unlock_user_struct(target_st, arg2, 1);
}
}
break;
#ifdef TARGET_NR_olduname
case TARGET_NR_olduname:
goto unimplemented;
#endif
#ifdef TARGET_NR_iopl
case TARGET_NR_iopl:
goto unimplemented;
#endif
case TARGET_NR_vhangup:
ret = get_errno(vhangup());
break;
#ifdef TARGET_NR_idle
case TARGET_NR_idle:
goto unimplemented;
#endif
#ifdef TARGET_NR_syscall
case TARGET_NR_syscall:
ret = do_syscall(cpu_env,arg1 & 0xffff,arg2,arg3,arg4,arg5,arg6,0);
break;
#endif
case TARGET_NR_wait4:
{
int status;
abi_long status_ptr = arg2;
struct rusage rusage, *rusage_ptr;
abi_ulong target_rusage = arg4;
if (target_rusage)
rusage_ptr = &rusage;
else
rusage_ptr = NULL;
ret = get_errno(wait4(arg1, &status, arg3, rusage_ptr));
if (!is_error(ret)) {
if (status_ptr) {
status = host_to_target_waitstatus(status);
if (put_user_s32(status, status_ptr))
goto efault;
}
if (target_rusage)
host_to_target_rusage(target_rusage, &rusage);
}
}
break;
#ifdef TARGET_NR_swapoff
case TARGET_NR_swapoff:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(swapoff(p));
unlock_user(p, arg1, 0);
break;
#endif
case TARGET_NR_sysinfo:
{
struct target_sysinfo *target_value;
struct sysinfo value;
ret = get_errno(sysinfo(&value));
if (!is_error(ret) && arg1)
{
if (!lock_user_struct(VERIFY_WRITE, target_value, arg1, 0))
goto efault;
__put_user(value.uptime, &target_value->uptime);
__put_user(value.loads[0], &target_value->loads[0]);
__put_user(value.loads[1], &target_value->loads[1]);
__put_user(value.loads[2], &target_value->loads[2]);
__put_user(value.totalram, &target_value->totalram);
__put_user(value.freeram, &target_value->freeram);
__put_user(value.sharedram, &target_value->sharedram);
__put_user(value.bufferram, &target_value->bufferram);
__put_user(value.totalswap, &target_value->totalswap);
__put_user(value.freeswap, &target_value->freeswap);
__put_user(value.procs, &target_value->procs);
__put_user(value.totalhigh, &target_value->totalhigh);
__put_user(value.freehigh, &target_value->freehigh);
__put_user(value.mem_unit, &target_value->mem_unit);
unlock_user_struct(target_value, arg1, 1);
}
}
break;
#ifdef TARGET_NR_ipc
case TARGET_NR_ipc:
ret = do_ipc(arg1, arg2, arg3, arg4, arg5, arg6);
break;
#endif
#ifdef TARGET_NR_semget
case TARGET_NR_semget:
ret = get_errno(semget(arg1, arg2, arg3));
break;
#endif
#ifdef TARGET_NR_semop
case TARGET_NR_semop:
ret = get_errno(do_semop(arg1, arg2, arg3));
break;
#endif
#ifdef TARGET_NR_semctl
case TARGET_NR_semctl:
ret = do_semctl(arg1, arg2, arg3, (union target_semun)(abi_ulong)arg4);
break;
#endif
#ifdef TARGET_NR_msgctl
case TARGET_NR_msgctl:
ret = do_msgctl(arg1, arg2, arg3);
break;
#endif
#ifdef TARGET_NR_msgget
case TARGET_NR_msgget:
ret = get_errno(msgget(arg1, arg2));
break;
#endif
#ifdef TARGET_NR_msgrcv
case TARGET_NR_msgrcv:
ret = do_msgrcv(arg1, arg2, arg3, arg4, arg5);
break;
#endif
#ifdef TARGET_NR_msgsnd
case TARGET_NR_msgsnd:
ret = do_msgsnd(arg1, arg2, arg3, arg4);
break;
#endif
#ifdef TARGET_NR_shmget
case TARGET_NR_shmget:
ret = get_errno(shmget(arg1, arg2, arg3));
break;
#endif
#ifdef TARGET_NR_shmctl
case TARGET_NR_shmctl:
ret = do_shmctl(arg1, arg2, arg3);
break;
#endif
#ifdef TARGET_NR_shmat
case TARGET_NR_shmat:
ret = do_shmat(arg1, arg2, arg3);
break;
#endif
#ifdef TARGET_NR_shmdt
case TARGET_NR_shmdt:
ret = do_shmdt(arg1);
break;
#endif
case TARGET_NR_fsync:
ret = get_errno(fsync(arg1));
break;
case TARGET_NR_clone:
#if defined(TARGET_SH4)
ret = get_errno(do_fork(cpu_env, arg1, arg2, arg3, arg5, arg4));
#elif defined(TARGET_CRIS)
ret = get_errno(do_fork(cpu_env, arg2, arg1, arg3, arg4, arg5));
#else
ret = get_errno(do_fork(cpu_env, arg1, arg2, arg3, arg4, arg5));
#endif
break;
#ifdef __NR_exit_group
/* new thread calls */
case TARGET_NR_exit_group:
#ifdef TARGET_GPROF
_mcleanup();
#endif
gdb_exit(cpu_env, arg1);
ret = get_errno(exit_group(arg1));
break;
#endif
case TARGET_NR_setdomainname:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(setdomainname(p, arg2));
unlock_user(p, arg1, 0);
break;
case TARGET_NR_uname:
/* no need to transcode because we use the linux syscall */
{
struct new_utsname * buf;
if (!lock_user_struct(VERIFY_WRITE, buf, arg1, 0))
goto efault;
ret = get_errno(sys_uname(buf));
if (!is_error(ret)) {
/* Overrite the native machine name with whatever is being
emulated. */
strcpy (buf->machine, UNAME_MACHINE);
/* Allow the user to override the reported release. */
if (qemu_uname_release && *qemu_uname_release)
strcpy (buf->release, qemu_uname_release);
}
unlock_user_struct(buf, arg1, 1);
}
break;
#ifdef TARGET_I386
case TARGET_NR_modify_ldt:
ret = do_modify_ldt(cpu_env, arg1, arg2, arg3);
break;
#if !defined(TARGET_X86_64)
case TARGET_NR_vm86old:
goto unimplemented;
case TARGET_NR_vm86:
ret = do_vm86(cpu_env, arg1, arg2);
break;
#endif
#endif
case TARGET_NR_adjtimex:
goto unimplemented;
#ifdef TARGET_NR_create_module
case TARGET_NR_create_module:
#endif
case TARGET_NR_init_module:
case TARGET_NR_delete_module:
#ifdef TARGET_NR_get_kernel_syms
case TARGET_NR_get_kernel_syms:
#endif
goto unimplemented;
case TARGET_NR_quotactl:
goto unimplemented;
case TARGET_NR_getpgid:
ret = get_errno(getpgid(arg1));
break;
case TARGET_NR_fchdir:
ret = get_errno(fchdir(arg1));
break;
#ifdef TARGET_NR_bdflush /* not on x86_64 */
case TARGET_NR_bdflush:
goto unimplemented;
#endif
#ifdef TARGET_NR_sysfs
case TARGET_NR_sysfs:
goto unimplemented;
#endif
case TARGET_NR_personality:
ret = get_errno(personality(arg1));
break;
#ifdef TARGET_NR_afs_syscall
case TARGET_NR_afs_syscall:
goto unimplemented;
#endif
#ifdef TARGET_NR__llseek /* Not on alpha */
case TARGET_NR__llseek:
{
#if defined (__x86_64__)
ret = get_errno(lseek(arg1, ((uint64_t )arg2 << 32) | arg3, arg5));
if (put_user_s64(ret, arg4))
goto efault;
#else
int64_t res;
ret = get_errno(_llseek(arg1, arg2, arg3, &res, arg5));
if (put_user_s64(res, arg4))
goto efault;
#endif
}
break;
#endif
case TARGET_NR_getdents:
#if TARGET_ABI_BITS == 32 && HOST_LONG_BITS == 64
{
struct target_dirent *target_dirp;
struct linux_dirent *dirp;
abi_long count = arg3;
dirp = malloc(count);
if (!dirp) {
ret = -TARGET_ENOMEM;
goto fail;
}
ret = get_errno(sys_getdents(arg1, dirp, count));
if (!is_error(ret)) {
struct linux_dirent *de;
struct target_dirent *tde;
int len = ret;
int reclen, treclen;
int count1, tnamelen;
count1 = 0;
de = dirp;
if (!(target_dirp = lock_user(VERIFY_WRITE, arg2, count, 0)))
goto efault;
tde = target_dirp;
while (len > 0) {
reclen = de->d_reclen;
treclen = reclen - (2 * (sizeof(long) - sizeof(abi_long)));
tde->d_reclen = tswap16(treclen);
tde->d_ino = tswapl(de->d_ino);
tde->d_off = tswapl(de->d_off);
tnamelen = treclen - (2 * sizeof(abi_long) + 2);
if (tnamelen > 256)
tnamelen = 256;
/* XXX: may not be correct */
pstrcpy(tde->d_name, tnamelen, de->d_name);
de = (struct linux_dirent *)((char *)de + reclen);
len -= reclen;
tde = (struct target_dirent *)((char *)tde + treclen);
count1 += treclen;
}
ret = count1;
unlock_user(target_dirp, arg2, ret);
}
free(dirp);
}
#else
{
struct linux_dirent *dirp;
abi_long count = arg3;
if (!(dirp = lock_user(VERIFY_WRITE, arg2, count, 0)))
goto efault;
ret = get_errno(sys_getdents(arg1, dirp, count));
if (!is_error(ret)) {
struct linux_dirent *de;
int len = ret;
int reclen;
de = dirp;
while (len > 0) {
reclen = de->d_reclen;
if (reclen > len)
break;
de->d_reclen = tswap16(reclen);
tswapls(&de->d_ino);
tswapls(&de->d_off);
de = (struct linux_dirent *)((char *)de + reclen);
len -= reclen;
}
}
unlock_user(dirp, arg2, ret);
}
#endif
break;
#if defined(TARGET_NR_getdents64) && defined(__NR_getdents64)
case TARGET_NR_getdents64:
{
struct linux_dirent64 *dirp;
abi_long count = arg3;
if (!(dirp = lock_user(VERIFY_WRITE, arg2, count, 0)))
goto efault;
ret = get_errno(sys_getdents64(arg1, dirp, count));
if (!is_error(ret)) {
struct linux_dirent64 *de;
int len = ret;
int reclen;
de = dirp;
while (len > 0) {
reclen = de->d_reclen;
if (reclen > len)
break;
de->d_reclen = tswap16(reclen);
tswap64s((uint64_t *)&de->d_ino);
tswap64s((uint64_t *)&de->d_off);
de = (struct linux_dirent64 *)((char *)de + reclen);
len -= reclen;
}
}
unlock_user(dirp, arg2, ret);
}
break;
#endif /* TARGET_NR_getdents64 */
#ifdef TARGET_NR__newselect
case TARGET_NR__newselect:
ret = do_select(arg1, arg2, arg3, arg4, arg5);
break;
#endif
#ifdef TARGET_NR_poll
case TARGET_NR_poll:
{
struct target_pollfd *target_pfd;
unsigned int nfds = arg2;
int timeout = arg3;
struct pollfd *pfd;
unsigned int i;
target_pfd = lock_user(VERIFY_WRITE, arg1, sizeof(struct target_pollfd) * nfds, 1);
if (!target_pfd)
goto efault;
pfd = alloca(sizeof(struct pollfd) * nfds);
for(i = 0; i < nfds; i++) {
pfd[i].fd = tswap32(target_pfd[i].fd);
pfd[i].events = tswap16(target_pfd[i].events);
}
ret = get_errno(poll(pfd, nfds, timeout));
if (!is_error(ret)) {
for(i = 0; i < nfds; i++) {
target_pfd[i].revents = tswap16(pfd[i].revents);
}
ret += nfds * (sizeof(struct target_pollfd)
- sizeof(struct pollfd));
}
unlock_user(target_pfd, arg1, ret);
}
break;
#endif
case TARGET_NR_flock:
/* NOTE: the flock constant seems to be the same for every
Linux platform */
ret = get_errno(flock(arg1, arg2));
break;
case TARGET_NR_readv:
{
int count = arg3;
struct iovec *vec;
vec = alloca(count * sizeof(struct iovec));
if (lock_iovec(VERIFY_WRITE, vec, arg2, count, 0) < 0)
goto efault;
ret = get_errno(readv(arg1, vec, count));
unlock_iovec(vec, arg2, count, 1);
}
break;
case TARGET_NR_writev:
{
int count = arg3;
struct iovec *vec;
vec = alloca(count * sizeof(struct iovec));
if (lock_iovec(VERIFY_READ, vec, arg2, count, 1) < 0)
goto efault;
ret = get_errno(writev(arg1, vec, count));
unlock_iovec(vec, arg2, count, 0);
}
break;
case TARGET_NR_getsid:
ret = get_errno(getsid(arg1));
break;
#if defined(TARGET_NR_fdatasync) /* Not on alpha (osf_datasync ?) */
case TARGET_NR_fdatasync:
ret = get_errno(fdatasync(arg1));
break;
#endif
case TARGET_NR__sysctl:
/* We don't implement this, but ENOTDIR is always a safe
return value. */
ret = -TARGET_ENOTDIR;
break;
case TARGET_NR_sched_setparam:
{
struct sched_param *target_schp;
struct sched_param schp;
if (!lock_user_struct(VERIFY_READ, target_schp, arg2, 1))
goto efault;
schp.sched_priority = tswap32(target_schp->sched_priority);
unlock_user_struct(target_schp, arg2, 0);
ret = get_errno(sched_setparam(arg1, &schp));
}
break;
case TARGET_NR_sched_getparam:
{
struct sched_param *target_schp;
struct sched_param schp;
ret = get_errno(sched_getparam(arg1, &schp));
if (!is_error(ret)) {
if (!lock_user_struct(VERIFY_WRITE, target_schp, arg2, 0))
goto efault;
target_schp->sched_priority = tswap32(schp.sched_priority);
unlock_user_struct(target_schp, arg2, 1);
}
}
break;
case TARGET_NR_sched_setscheduler:
{
struct sched_param *target_schp;
struct sched_param schp;
if (!lock_user_struct(VERIFY_READ, target_schp, arg3, 1))
goto efault;
schp.sched_priority = tswap32(target_schp->sched_priority);
unlock_user_struct(target_schp, arg3, 0);
ret = get_errno(sched_setscheduler(arg1, arg2, &schp));
}
break;
case TARGET_NR_sched_getscheduler:
ret = get_errno(sched_getscheduler(arg1));
break;
case TARGET_NR_sched_yield:
ret = get_errno(sched_yield());
break;
case TARGET_NR_sched_get_priority_max:
ret = get_errno(sched_get_priority_max(arg1));
break;
case TARGET_NR_sched_get_priority_min:
ret = get_errno(sched_get_priority_min(arg1));
break;
case TARGET_NR_sched_rr_get_interval:
{
struct timespec ts;
ret = get_errno(sched_rr_get_interval(arg1, &ts));
if (!is_error(ret)) {
host_to_target_timespec(arg2, &ts);
}
}
break;
case TARGET_NR_nanosleep:
{
struct timespec req, rem;
target_to_host_timespec(&req, arg1);
ret = get_errno(nanosleep(&req, &rem));
if (is_error(ret) && arg2) {
host_to_target_timespec(arg2, &rem);
}
}
break;
#ifdef TARGET_NR_query_module
case TARGET_NR_query_module:
goto unimplemented;
#endif
#ifdef TARGET_NR_nfsservctl
case TARGET_NR_nfsservctl:
goto unimplemented;
#endif
case TARGET_NR_prctl:
switch (arg1)
{
case PR_GET_PDEATHSIG:
{
int deathsig;
ret = get_errno(prctl(arg1, &deathsig, arg3, arg4, arg5));
if (!is_error(ret) && arg2
&& put_user_ual(deathsig, arg2))
goto efault;
}
break;
default:
ret = get_errno(prctl(arg1, arg2, arg3, arg4, arg5));
break;
}
break;
#ifdef TARGET_NR_arch_prctl
case TARGET_NR_arch_prctl:
#if defined(TARGET_I386) && !defined(TARGET_ABI32)
ret = do_arch_prctl(cpu_env, arg1, arg2);
break;
#else
goto unimplemented;
#endif
#endif
#ifdef TARGET_NR_pread
case TARGET_NR_pread:
#ifdef TARGET_ARM
if (((CPUARMState *)cpu_env)->eabi)
arg4 = arg5;
#endif
if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0)))
goto efault;
ret = get_errno(pread(arg1, p, arg3, arg4));
unlock_user(p, arg2, ret);
break;
case TARGET_NR_pwrite:
#ifdef TARGET_ARM
if (((CPUARMState *)cpu_env)->eabi)
arg4 = arg5;
#endif
if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1)))
goto efault;
ret = get_errno(pwrite(arg1, p, arg3, arg4));
unlock_user(p, arg2, 0);
break;
#endif
#ifdef TARGET_NR_pread64
case TARGET_NR_pread64:
if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0)))
goto efault;
ret = get_errno(pread64(arg1, p, arg3, target_offset64(arg4, arg5)));
unlock_user(p, arg2, ret);
break;
case TARGET_NR_pwrite64:
if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1)))
goto efault;
ret = get_errno(pwrite64(arg1, p, arg3, target_offset64(arg4, arg5)));
unlock_user(p, arg2, 0);
break;
#endif
case TARGET_NR_getcwd:
if (!(p = lock_user(VERIFY_WRITE, arg1, arg2, 0)))
goto efault;
ret = get_errno(sys_getcwd1(p, arg2));
unlock_user(p, arg1, ret);
break;
case TARGET_NR_capget:
goto unimplemented;
case TARGET_NR_capset:
goto unimplemented;
case TARGET_NR_sigaltstack:
#if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_MIPS) || \
defined(TARGET_SPARC) || defined(TARGET_PPC) || defined(TARGET_ALPHA) || \
defined(TARGET_M68K)
ret = do_sigaltstack(arg1, arg2, get_sp_from_cpustate((CPUState *)cpu_env));
break;
#else
goto unimplemented;
#endif
case TARGET_NR_sendfile:
goto unimplemented;
#ifdef TARGET_NR_getpmsg
case TARGET_NR_getpmsg:
goto unimplemented;
#endif
#ifdef TARGET_NR_putpmsg
case TARGET_NR_putpmsg:
goto unimplemented;
#endif
#ifdef TARGET_NR_vfork
case TARGET_NR_vfork:
ret = get_errno(do_fork(cpu_env, CLONE_VFORK | CLONE_VM | SIGCHLD,
0, 0, 0, 0));
break;
#endif
#ifdef TARGET_NR_ugetrlimit
case TARGET_NR_ugetrlimit:
{
struct rlimit rlim;
ret = get_errno(getrlimit(arg1, &rlim));
if (!is_error(ret)) {
struct target_rlimit *target_rlim;
if (!lock_user_struct(VERIFY_WRITE, target_rlim, arg2, 0))
goto efault;
target_rlim->rlim_cur = tswapl(rlim.rlim_cur);
target_rlim->rlim_max = tswapl(rlim.rlim_max);
unlock_user_struct(target_rlim, arg2, 1);
}
break;
}
#endif
#ifdef TARGET_NR_truncate64
case TARGET_NR_truncate64:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = target_truncate64(cpu_env, p, arg2, arg3, arg4);
unlock_user(p, arg1, 0);
break;
#endif
#ifdef TARGET_NR_ftruncate64
case TARGET_NR_ftruncate64:
ret = target_ftruncate64(cpu_env, arg1, arg2, arg3, arg4);
break;
#endif
#ifdef TARGET_NR_stat64
case TARGET_NR_stat64:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(stat(path(p), &st));
unlock_user(p, arg1, 0);
if (!is_error(ret))
ret = host_to_target_stat64(cpu_env, arg2, &st);
break;
#endif
#ifdef TARGET_NR_lstat64
case TARGET_NR_lstat64:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(lstat(path(p), &st));
unlock_user(p, arg1, 0);
if (!is_error(ret))
ret = host_to_target_stat64(cpu_env, arg2, &st);
break;
#endif
#ifdef TARGET_NR_fstat64
case TARGET_NR_fstat64:
ret = get_errno(fstat(arg1, &st));
if (!is_error(ret))
ret = host_to_target_stat64(cpu_env, arg2, &st);
break;
#endif
#if (defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)) && \
(defined(__NR_fstatat64) || defined(__NR_newfstatat))
#ifdef TARGET_NR_fstatat64
case TARGET_NR_fstatat64:
#endif
#ifdef TARGET_NR_newfstatat
case TARGET_NR_newfstatat:
#endif
if (!(p = lock_user_string(arg2)))
goto efault;
#ifdef __NR_fstatat64
ret = get_errno(sys_fstatat64(arg1, path(p), &st, arg4));
#else
ret = get_errno(sys_newfstatat(arg1, path(p), &st, arg4));
#endif
if (!is_error(ret))
ret = host_to_target_stat64(cpu_env, arg3, &st);
break;
#endif
#ifdef USE_UID16
case TARGET_NR_lchown:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(lchown(p, low2highuid(arg2), low2highgid(arg3)));
unlock_user(p, arg1, 0);
break;
case TARGET_NR_getuid:
ret = get_errno(high2lowuid(getuid()));
break;
case TARGET_NR_getgid:
ret = get_errno(high2lowgid(getgid()));
break;
case TARGET_NR_geteuid:
ret = get_errno(high2lowuid(geteuid()));
break;
case TARGET_NR_getegid:
ret = get_errno(high2lowgid(getegid()));
break;
case TARGET_NR_setreuid:
ret = get_errno(setreuid(low2highuid(arg1), low2highuid(arg2)));
break;
case TARGET_NR_setregid:
ret = get_errno(setregid(low2highgid(arg1), low2highgid(arg2)));
break;
case TARGET_NR_getgroups:
{
int gidsetsize = arg1;
uint16_t *target_grouplist;
gid_t *grouplist;
int i;
grouplist = alloca(gidsetsize * sizeof(gid_t));
ret = get_errno(getgroups(gidsetsize, grouplist));
if (gidsetsize == 0)
break;
if (!is_error(ret)) {
target_grouplist = lock_user(VERIFY_WRITE, arg2, gidsetsize * 2, 0);
if (!target_grouplist)
goto efault;
for(i = 0;i < ret; i++)
target_grouplist[i] = tswap16(grouplist[i]);
unlock_user(target_grouplist, arg2, gidsetsize * 2);
}
}
break;
case TARGET_NR_setgroups:
{
int gidsetsize = arg1;
uint16_t *target_grouplist;
gid_t *grouplist;
int i;
grouplist = alloca(gidsetsize * sizeof(gid_t));
target_grouplist = lock_user(VERIFY_READ, arg2, gidsetsize * 2, 1);
if (!target_grouplist) {
ret = -TARGET_EFAULT;
goto fail;
}
for(i = 0;i < gidsetsize; i++)
grouplist[i] = tswap16(target_grouplist[i]);
unlock_user(target_grouplist, arg2, 0);
ret = get_errno(setgroups(gidsetsize, grouplist));
}
break;
case TARGET_NR_fchown:
ret = get_errno(fchown(arg1, low2highuid(arg2), low2highgid(arg3)));
break;
#if defined(TARGET_NR_fchownat) && defined(__NR_fchownat)
case TARGET_NR_fchownat:
if (!(p = lock_user_string(arg2)))
goto efault;
ret = get_errno(sys_fchownat(arg1, p, low2highuid(arg3), low2highgid(arg4), arg5));
unlock_user(p, arg2, 0);
break;
#endif
#ifdef TARGET_NR_setresuid
case TARGET_NR_setresuid:
ret = get_errno(setresuid(low2highuid(arg1),
low2highuid(arg2),
low2highuid(arg3)));
break;
#endif
#ifdef TARGET_NR_getresuid
case TARGET_NR_getresuid:
{
uid_t ruid, euid, suid;
ret = get_errno(getresuid(&ruid, &euid, &suid));
if (!is_error(ret)) {
if (put_user_u16(high2lowuid(ruid), arg1)
|| put_user_u16(high2lowuid(euid), arg2)
|| put_user_u16(high2lowuid(suid), arg3))
goto efault;
}
}
break;
#endif
#ifdef TARGET_NR_getresgid
case TARGET_NR_setresgid:
ret = get_errno(setresgid(low2highgid(arg1),
low2highgid(arg2),
low2highgid(arg3)));
break;
#endif
#ifdef TARGET_NR_getresgid
case TARGET_NR_getresgid:
{
gid_t rgid, egid, sgid;
ret = get_errno(getresgid(&rgid, &egid, &sgid));
if (!is_error(ret)) {
if (put_user_u16(high2lowgid(rgid), arg1)
|| put_user_u16(high2lowgid(egid), arg2)
|| put_user_u16(high2lowgid(sgid), arg3))
goto efault;
}
}
break;
#endif
case TARGET_NR_chown:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(chown(p, low2highuid(arg2), low2highgid(arg3)));
unlock_user(p, arg1, 0);
break;
case TARGET_NR_setuid:
ret = get_errno(setuid(low2highuid(arg1)));
break;
case TARGET_NR_setgid:
ret = get_errno(setgid(low2highgid(arg1)));
break;
case TARGET_NR_setfsuid:
ret = get_errno(setfsuid(arg1));
break;
case TARGET_NR_setfsgid:
ret = get_errno(setfsgid(arg1));
break;
#endif /* USE_UID16 */
#ifdef TARGET_NR_lchown32
case TARGET_NR_lchown32:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(lchown(p, arg2, arg3));
unlock_user(p, arg1, 0);
break;
#endif
#ifdef TARGET_NR_getuid32
case TARGET_NR_getuid32:
ret = get_errno(getuid());
break;
#endif
#if defined(TARGET_NR_getxuid) && defined(TARGET_ALPHA)
/* Alpha specific */
case TARGET_NR_getxuid:
{
uid_t euid;
euid=geteuid();
((CPUAlphaState *)cpu_env)->ir[IR_A4]=euid;
}
ret = get_errno(getuid());
break;
#endif
#if defined(TARGET_NR_getxgid) && defined(TARGET_ALPHA)
/* Alpha specific */
case TARGET_NR_getxgid:
{
uid_t egid;
egid=getegid();
((CPUAlphaState *)cpu_env)->ir[IR_A4]=egid;
}
ret = get_errno(getgid());
break;
#endif
#ifdef TARGET_NR_getgid32
case TARGET_NR_getgid32:
ret = get_errno(getgid());
break;
#endif
#ifdef TARGET_NR_geteuid32
case TARGET_NR_geteuid32:
ret = get_errno(geteuid());
break;
#endif
#ifdef TARGET_NR_getegid32
case TARGET_NR_getegid32:
ret = get_errno(getegid());
break;
#endif
#ifdef TARGET_NR_setreuid32
case TARGET_NR_setreuid32:
ret = get_errno(setreuid(arg1, arg2));
break;
#endif
#ifdef TARGET_NR_setregid32
case TARGET_NR_setregid32:
ret = get_errno(setregid(arg1, arg2));
break;
#endif
#ifdef TARGET_NR_getgroups32
case TARGET_NR_getgroups32:
{
int gidsetsize = arg1;
uint32_t *target_grouplist;
gid_t *grouplist;
int i;
grouplist = alloca(gidsetsize * sizeof(gid_t));
ret = get_errno(getgroups(gidsetsize, grouplist));
if (gidsetsize == 0)
break;
if (!is_error(ret)) {
target_grouplist = lock_user(VERIFY_WRITE, arg2, gidsetsize * 4, 0);
if (!target_grouplist) {
ret = -TARGET_EFAULT;
goto fail;
}
for(i = 0;i < ret; i++)
target_grouplist[i] = tswap32(grouplist[i]);
unlock_user(target_grouplist, arg2, gidsetsize * 4);
}
}
break;
#endif
#ifdef TARGET_NR_setgroups32
case TARGET_NR_setgroups32:
{
int gidsetsize = arg1;
uint32_t *target_grouplist;
gid_t *grouplist;
int i;
grouplist = alloca(gidsetsize * sizeof(gid_t));
target_grouplist = lock_user(VERIFY_READ, arg2, gidsetsize * 4, 1);
if (!target_grouplist) {
ret = -TARGET_EFAULT;
goto fail;
}
for(i = 0;i < gidsetsize; i++)
grouplist[i] = tswap32(target_grouplist[i]);
unlock_user(target_grouplist, arg2, 0);
ret = get_errno(setgroups(gidsetsize, grouplist));
}
break;
#endif
#ifdef TARGET_NR_fchown32
case TARGET_NR_fchown32:
ret = get_errno(fchown(arg1, arg2, arg3));
break;
#endif
#ifdef TARGET_NR_setresuid32
case TARGET_NR_setresuid32:
ret = get_errno(setresuid(arg1, arg2, arg3));
break;
#endif
#ifdef TARGET_NR_getresuid32
case TARGET_NR_getresuid32:
{
uid_t ruid, euid, suid;
ret = get_errno(getresuid(&ruid, &euid, &suid));
if (!is_error(ret)) {
if (put_user_u32(ruid, arg1)
|| put_user_u32(euid, arg2)
|| put_user_u32(suid, arg3))
goto efault;
}
}
break;
#endif
#ifdef TARGET_NR_setresgid32
case TARGET_NR_setresgid32:
ret = get_errno(setresgid(arg1, arg2, arg3));
break;
#endif
#ifdef TARGET_NR_getresgid32
case TARGET_NR_getresgid32:
{
gid_t rgid, egid, sgid;
ret = get_errno(getresgid(&rgid, &egid, &sgid));
if (!is_error(ret)) {
if (put_user_u32(rgid, arg1)
|| put_user_u32(egid, arg2)
|| put_user_u32(sgid, arg3))
goto efault;
}
}
break;
#endif
#ifdef TARGET_NR_chown32
case TARGET_NR_chown32:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(chown(p, arg2, arg3));
unlock_user(p, arg1, 0);
break;
#endif
#ifdef TARGET_NR_setuid32
case TARGET_NR_setuid32:
ret = get_errno(setuid(arg1));
break;
#endif
#ifdef TARGET_NR_setgid32
case TARGET_NR_setgid32:
ret = get_errno(setgid(arg1));
break;
#endif
#ifdef TARGET_NR_setfsuid32
case TARGET_NR_setfsuid32:
ret = get_errno(setfsuid(arg1));
break;
#endif
#ifdef TARGET_NR_setfsgid32
case TARGET_NR_setfsgid32:
ret = get_errno(setfsgid(arg1));
break;
#endif
case TARGET_NR_pivot_root:
goto unimplemented;
#ifdef TARGET_NR_mincore
case TARGET_NR_mincore:
{
void *a;
ret = -TARGET_EFAULT;
if (!(a = lock_user(VERIFY_READ, arg1,arg2, 0)))
goto efault;
if (!(p = lock_user_string(arg3)))
goto mincore_fail;
ret = get_errno(mincore(a, arg2, p));
unlock_user(p, arg3, ret);
mincore_fail:
unlock_user(a, arg1, 0);
}
break;
#endif
#ifdef TARGET_NR_arm_fadvise64_64
case TARGET_NR_arm_fadvise64_64:
{
/*
* arm_fadvise64_64 looks like fadvise64_64 but
* with different argument order
*/
abi_long temp;
temp = arg3;
arg3 = arg4;
arg4 = temp;
}
#endif
#if defined(TARGET_NR_fadvise64_64) || defined(TARGET_NR_arm_fadvise64_64) || defined(TARGET_NR_fadvise64)
#ifdef TARGET_NR_fadvise64_64
case TARGET_NR_fadvise64_64:
#endif
#ifdef TARGET_NR_fadvise64
case TARGET_NR_fadvise64:
#endif
#ifdef TARGET_S390X
switch (arg4) {
case 4: arg4 = POSIX_FADV_NOREUSE + 1; break; /* make sure it's an invalid value */
case 5: arg4 = POSIX_FADV_NOREUSE + 2; break; /* ditto */
case 6: arg4 = POSIX_FADV_DONTNEED; break;
case 7: arg4 = POSIX_FADV_NOREUSE; break;
default: break;
}
#endif
ret = -posix_fadvise(arg1, arg2, arg3, arg4);
break;
#endif
#ifdef TARGET_NR_madvise
case TARGET_NR_madvise:
/* A straight passthrough may not be safe because qemu sometimes
turns private flie-backed mappings into anonymous mappings.
This will break MADV_DONTNEED.
This is a hint, so ignoring and returning success is ok. */
ret = get_errno(0);
break;
#endif
#if TARGET_ABI_BITS == 32
case TARGET_NR_fcntl64:
{
int cmd;
struct flock64 fl;
struct target_flock64 *target_fl;
#ifdef TARGET_ARM
struct target_eabi_flock64 *target_efl;
#endif
cmd = target_to_host_fcntl_cmd(arg2);
if (cmd == -TARGET_EINVAL)
return cmd;
switch(arg2) {
case TARGET_F_GETLK64:
#ifdef TARGET_ARM
if (((CPUARMState *)cpu_env)->eabi) {
if (!lock_user_struct(VERIFY_READ, target_efl, arg3, 1))
goto efault;
fl.l_type = tswap16(target_efl->l_type);
fl.l_whence = tswap16(target_efl->l_whence);
fl.l_start = tswap64(target_efl->l_start);
fl.l_len = tswap64(target_efl->l_len);
fl.l_pid = tswap32(target_efl->l_pid);
unlock_user_struct(target_efl, arg3, 0);
} else
#endif
{
if (!lock_user_struct(VERIFY_READ, target_fl, arg3, 1))
goto efault;
fl.l_type = tswap16(target_fl->l_type);
fl.l_whence = tswap16(target_fl->l_whence);
fl.l_start = tswap64(target_fl->l_start);
fl.l_len = tswap64(target_fl->l_len);
fl.l_pid = tswap32(target_fl->l_pid);
unlock_user_struct(target_fl, arg3, 0);
}
ret = get_errno(fcntl(arg1, cmd, &fl));
if (ret == 0) {
#ifdef TARGET_ARM
if (((CPUARMState *)cpu_env)->eabi) {
if (!lock_user_struct(VERIFY_WRITE, target_efl, arg3, 0))
goto efault;
target_efl->l_type = tswap16(fl.l_type);
target_efl->l_whence = tswap16(fl.l_whence);
target_efl->l_start = tswap64(fl.l_start);
target_efl->l_len = tswap64(fl.l_len);
target_efl->l_pid = tswap32(fl.l_pid);
unlock_user_struct(target_efl, arg3, 1);
} else
#endif
{
if (!lock_user_struct(VERIFY_WRITE, target_fl, arg3, 0))
goto efault;
target_fl->l_type = tswap16(fl.l_type);
target_fl->l_whence = tswap16(fl.l_whence);
target_fl->l_start = tswap64(fl.l_start);
target_fl->l_len = tswap64(fl.l_len);
target_fl->l_pid = tswap32(fl.l_pid);
unlock_user_struct(target_fl, arg3, 1);
}
}
break;
case TARGET_F_SETLK64:
case TARGET_F_SETLKW64:
#ifdef TARGET_ARM
if (((CPUARMState *)cpu_env)->eabi) {
if (!lock_user_struct(VERIFY_READ, target_efl, arg3, 1))
goto efault;
fl.l_type = tswap16(target_efl->l_type);
fl.l_whence = tswap16(target_efl->l_whence);
fl.l_start = tswap64(target_efl->l_start);
fl.l_len = tswap64(target_efl->l_len);
fl.l_pid = tswap32(target_efl->l_pid);
unlock_user_struct(target_efl, arg3, 0);
} else
#endif
{
if (!lock_user_struct(VERIFY_READ, target_fl, arg3, 1))
goto efault;
fl.l_type = tswap16(target_fl->l_type);
fl.l_whence = tswap16(target_fl->l_whence);
fl.l_start = tswap64(target_fl->l_start);
fl.l_len = tswap64(target_fl->l_len);
fl.l_pid = tswap32(target_fl->l_pid);
unlock_user_struct(target_fl, arg3, 0);
}
ret = get_errno(fcntl(arg1, cmd, &fl));
break;
default:
ret = do_fcntl(arg1, arg2, arg3);
break;
}
break;
}
#endif
#ifdef TARGET_NR_cacheflush
case TARGET_NR_cacheflush:
/* self-modifying code is handled automatically, so nothing needed */
ret = 0;
break;
#endif
#ifdef TARGET_NR_security
case TARGET_NR_security:
goto unimplemented;
#endif
#ifdef TARGET_NR_getpagesize
case TARGET_NR_getpagesize:
ret = TARGET_PAGE_SIZE;
break;
#endif
case TARGET_NR_gettid:
ret = get_errno(gettid());
break;
#ifdef TARGET_NR_readahead
case TARGET_NR_readahead:
#if TARGET_ABI_BITS == 32
#ifdef TARGET_ARM
if (((CPUARMState *)cpu_env)->eabi)
{
arg2 = arg3;
arg3 = arg4;
arg4 = arg5;
}
#endif
ret = get_errno(readahead(arg1, ((off64_t)arg3 << 32) | arg2, arg4));
#else
ret = get_errno(readahead(arg1, arg2, arg3));
#endif
break;
#endif
#ifdef TARGET_NR_setxattr
case TARGET_NR_setxattr:
case TARGET_NR_lsetxattr:
case TARGET_NR_fsetxattr:
case TARGET_NR_getxattr:
case TARGET_NR_lgetxattr:
case TARGET_NR_fgetxattr:
case TARGET_NR_listxattr:
case TARGET_NR_llistxattr:
case TARGET_NR_flistxattr:
case TARGET_NR_removexattr:
case TARGET_NR_lremovexattr:
case TARGET_NR_fremovexattr:
ret = -TARGET_EOPNOTSUPP;
break;
#endif
#ifdef TARGET_NR_set_thread_area
case TARGET_NR_set_thread_area:
#if defined(TARGET_MIPS)
((CPUMIPSState *) cpu_env)->tls_value = arg1;
ret = 0;
break;
#elif defined(TARGET_CRIS)
if (arg1 & 0xff)
ret = -TARGET_EINVAL;
else {
((CPUCRISState *) cpu_env)->pregs[PR_PID] = arg1;
ret = 0;
}
break;
#elif defined(TARGET_I386) && defined(TARGET_ABI32)
ret = do_set_thread_area(cpu_env, arg1);
break;
#else
goto unimplemented_nowarn;
#endif
#endif
#ifdef TARGET_NR_get_thread_area
case TARGET_NR_get_thread_area:
#if defined(TARGET_I386) && defined(TARGET_ABI32)
ret = do_get_thread_area(cpu_env, arg1);
#else
goto unimplemented_nowarn;
#endif
#endif
#ifdef TARGET_NR_getdomainname
case TARGET_NR_getdomainname:
goto unimplemented_nowarn;
#endif
#ifdef TARGET_NR_clock_gettime
case TARGET_NR_clock_gettime:
{
struct timespec ts;
ret = get_errno(clock_gettime(arg1, &ts));
if (!is_error(ret)) {
host_to_target_timespec(arg2, &ts);
}
break;
}
#endif
#ifdef TARGET_NR_clock_getres
case TARGET_NR_clock_getres:
{
struct timespec ts;
ret = get_errno(clock_getres(arg1, &ts));
if (!is_error(ret)) {
host_to_target_timespec(arg2, &ts);
}
break;
}
#endif
#ifdef TARGET_NR_clock_nanosleep
case TARGET_NR_clock_nanosleep:
{
struct timespec ts;
target_to_host_timespec(&ts, arg3);
ret = get_errno(clock_nanosleep(arg1, arg2, &ts, arg4 ? &ts : NULL));
if (arg4)
host_to_target_timespec(arg4, &ts);
break;
}
#endif
#if defined(TARGET_NR_set_tid_address) && defined(__NR_set_tid_address)
case TARGET_NR_set_tid_address:
ret = get_errno(set_tid_address((int *)g2h(arg1)));
break;
#endif
#if defined(TARGET_NR_tkill) && defined(__NR_tkill)
case TARGET_NR_tkill:
ret = get_errno(sys_tkill((int)arg1, target_to_host_signal(arg2)));
break;
#endif
#if defined(TARGET_NR_tgkill) && defined(__NR_tgkill)
case TARGET_NR_tgkill:
ret = get_errno(sys_tgkill((int)arg1, (int)arg2,
target_to_host_signal(arg3)));
break;
#endif
#ifdef TARGET_NR_set_robust_list
case TARGET_NR_set_robust_list:
goto unimplemented_nowarn;
#endif
#if defined(TARGET_NR_utimensat) && defined(__NR_utimensat)
case TARGET_NR_utimensat:
{
struct timespec *tsp, ts[2];
if (!arg3) {
tsp = NULL;
} else {
target_to_host_timespec(ts, arg3);
target_to_host_timespec(ts+1, arg3+sizeof(struct target_timespec));
tsp = ts;
}
if (!arg2)
ret = get_errno(sys_utimensat(arg1, NULL, tsp, arg4));
else {
if (!(p = lock_user_string(arg2))) {
ret = -TARGET_EFAULT;
goto fail;
}
ret = get_errno(sys_utimensat(arg1, path(p), tsp, arg4));
unlock_user(p, arg2, 0);
}
}
break;
#endif
#if defined(CONFIG_USE_NPTL)
case TARGET_NR_futex:
ret = do_futex(arg1, arg2, arg3, arg4, arg5, arg6);
break;
#endif
#if defined(TARGET_NR_inotify_init) && defined(__NR_inotify_init)
case TARGET_NR_inotify_init:
ret = get_errno(sys_inotify_init());
break;
#endif
#if defined(TARGET_NR_inotify_add_watch) && defined(__NR_inotify_add_watch)
case TARGET_NR_inotify_add_watch:
p = lock_user_string(arg2);
ret = get_errno(sys_inotify_add_watch(arg1, path(p), arg3));
unlock_user(p, arg2, 0);
break;
#endif
#if defined(TARGET_NR_inotify_rm_watch) && defined(__NR_inotify_rm_watch)
case TARGET_NR_inotify_rm_watch:
ret = get_errno(sys_inotify_rm_watch(arg1, arg2));
break;
#endif
#if defined(TARGET_NR_mq_open) && defined(__NR_mq_open)
case TARGET_NR_mq_open:
{
struct mq_attr posix_mq_attr;
p = lock_user_string(arg1 - 1);
if (arg4 != 0)
copy_from_user_mq_attr (&posix_mq_attr, arg4);
ret = get_errno(mq_open(p, arg2, arg3, &posix_mq_attr));
unlock_user (p, arg1, 0);
}
break;
case TARGET_NR_mq_unlink:
p = lock_user_string(arg1 - 1);
ret = get_errno(mq_unlink(p));
unlock_user (p, arg1, 0);
break;
case TARGET_NR_mq_timedsend:
{
struct timespec ts;
p = lock_user (VERIFY_READ, arg2, arg3, 1);
if (arg5 != 0) {
target_to_host_timespec(&ts, arg5);
ret = get_errno(mq_timedsend(arg1, p, arg3, arg4, &ts));
host_to_target_timespec(arg5, &ts);
}
else
ret = get_errno(mq_send(arg1, p, arg3, arg4));
unlock_user (p, arg2, arg3);
}
break;
case TARGET_NR_mq_timedreceive:
{
struct timespec ts;
unsigned int prio;
p = lock_user (VERIFY_READ, arg2, arg3, 1);
if (arg5 != 0) {
target_to_host_timespec(&ts, arg5);
ret = get_errno(mq_timedreceive(arg1, p, arg3, &prio, &ts));
host_to_target_timespec(arg5, &ts);
}
else
ret = get_errno(mq_receive(arg1, p, arg3, &prio));
unlock_user (p, arg2, arg3);
if (arg4 != 0)
put_user_u32(prio, arg4);
}
break;
/* Not implemented for now... */
/* case TARGET_NR_mq_notify: */
/* break; */
case TARGET_NR_mq_getsetattr:
{
struct mq_attr posix_mq_attr_in, posix_mq_attr_out;
ret = 0;
if (arg3 != 0) {
ret = mq_getattr(arg1, &posix_mq_attr_out);
copy_to_user_mq_attr(arg3, &posix_mq_attr_out);
}
if (arg2 != 0) {
copy_from_user_mq_attr(&posix_mq_attr_in, arg2);
ret |= mq_setattr(arg1, &posix_mq_attr_in, &posix_mq_attr_out);
}
}
break;
#endif
#ifdef CONFIG_SPLICE
#ifdef TARGET_NR_tee
case TARGET_NR_tee:
{
ret = get_errno(tee(arg1,arg2,arg3,arg4));
}
break;
#endif
#ifdef TARGET_NR_splice
case TARGET_NR_splice:
{
loff_t loff_in, loff_out;
loff_t *ploff_in = NULL, *ploff_out = NULL;
if(arg2) {
get_user_u64(loff_in, arg2);
ploff_in = &loff_in;
}
if(arg4) {
get_user_u64(loff_out, arg2);
ploff_out = &loff_out;
}
ret = get_errno(splice(arg1, ploff_in, arg3, ploff_out, arg5, arg6));
}
break;
#endif
#ifdef TARGET_NR_vmsplice
case TARGET_NR_vmsplice:
{
int count = arg3;
struct iovec *vec;
vec = alloca(count * sizeof(struct iovec));
if (lock_iovec(VERIFY_READ, vec, arg2, count, 1) < 0)
goto efault;
ret = get_errno(vmsplice(arg1, vec, count, arg4));
unlock_iovec(vec, arg2, count, 0);
}
break;
#endif
#endif /* CONFIG_SPLICE */
#ifdef CONFIG_EVENTFD
#if defined(TARGET_NR_eventfd)
case TARGET_NR_eventfd:
ret = get_errno(eventfd(arg1, 0));
break;
#endif
#if defined(TARGET_NR_eventfd2)
case TARGET_NR_eventfd2:
ret = get_errno(eventfd(arg1, arg2));
break;
#endif
#endif /* CONFIG_EVENTFD */
default:
unimplemented:
gemu_log("qemu: Unsupported syscall: %d\n", num);
#if defined(TARGET_NR_setxattr) || defined(TARGET_NR_get_thread_area) || defined(TARGET_NR_getdomainname) || defined(TARGET_NR_set_robust_list)
unimplemented_nowarn:
#endif
ret = -TARGET_ENOSYS;
break;
}
fail:
#ifdef DEBUG
gemu_log(" = " TARGET_ABI_FMT_ld "\n", ret);
#endif
if(do_strace)
print_syscall_ret(num, ret);
return ret;
efault:
ret = -TARGET_EFAULT;
goto fail;
} | true | qemu | 12727917db45aebb809e4b09c51e883c09a6366f | abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
abi_long arg2, abi_long arg3, abi_long arg4,
abi_long arg5, abi_long arg6)
{
abi_long ret;
struct stat st;
struct statfs stfs;
void *p;
#ifdef DEBUG
gemu_log("syscall %d", num);
#endif
if(do_strace)
print_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6);
switch(num) {
case TARGET_NR_exit:
#ifdef CONFIG_USE_NPTL
if (first_cpu->next_cpu) {
TaskState *ts;
CPUState **lastp;
CPUState *p;
cpu_list_lock();
lastp = &first_cpu;
p = first_cpu;
while (p && p != (CPUState *)cpu_env) {
lastp = &p->next_cpu;
p = p->next_cpu;
}
if (!p)
abort();
*lastp = p->next_cpu;
cpu_list_unlock();
ts = ((CPUState *)cpu_env)->opaque;
if (ts->child_tidptr) {
put_user_u32(0, ts->child_tidptr);
sys_futex(g2h(ts->child_tidptr), FUTEX_WAKE, INT_MAX,
NULL, NULL, 0);
}
pthread_exit(NULL);
}
#endif
#ifdef TARGET_GPROF
_mcleanup();
#endif
gdb_exit(cpu_env, arg1);
_exit(arg1);
ret = 0;
break;
case TARGET_NR_read:
if (arg3 == 0)
ret = 0;
else {
if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0)))
goto efault;
ret = get_errno(read(arg1, p, arg3));
unlock_user(p, arg2, ret);
}
break;
case TARGET_NR_write:
if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1)))
goto efault;
ret = get_errno(write(arg1, p, arg3));
unlock_user(p, arg2, 0);
break;
case TARGET_NR_open:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(open(path(p),
target_to_host_bitmask(arg2, fcntl_flags_tbl),
arg3));
unlock_user(p, arg1, 0);
break;
#if defined(TARGET_NR_openat) && defined(__NR_openat)
case TARGET_NR_openat:
if (!(p = lock_user_string(arg2)))
goto efault;
ret = get_errno(sys_openat(arg1,
path(p),
target_to_host_bitmask(arg3, fcntl_flags_tbl),
arg4));
unlock_user(p, arg2, 0);
break;
#endif
case TARGET_NR_close:
ret = get_errno(close(arg1));
break;
case TARGET_NR_brk:
ret = do_brk(arg1);
break;
case TARGET_NR_fork:
ret = get_errno(do_fork(cpu_env, SIGCHLD, 0, 0, 0, 0));
break;
#ifdef TARGET_NR_waitpid
case TARGET_NR_waitpid:
{
int status;
ret = get_errno(waitpid(arg1, &status, arg3));
if (!is_error(ret) && arg2
&& put_user_s32(host_to_target_waitstatus(status), arg2))
goto efault;
}
break;
#endif
#ifdef TARGET_NR_waitid
case TARGET_NR_waitid:
{
siginfo_t info;
info.si_pid = 0;
ret = get_errno(waitid(arg1, arg2, &info, arg4));
if (!is_error(ret) && arg3 && info.si_pid != 0) {
if (!(p = lock_user(VERIFY_WRITE, arg3, sizeof(target_siginfo_t), 0)))
goto efault;
host_to_target_siginfo(p, &info);
unlock_user(p, arg3, sizeof(target_siginfo_t));
}
}
break;
#endif
#ifdef TARGET_NR_creat
case TARGET_NR_creat:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(creat(p, arg2));
unlock_user(p, arg1, 0);
break;
#endif
case TARGET_NR_link:
{
void * p2;
p = lock_user_string(arg1);
p2 = lock_user_string(arg2);
if (!p || !p2)
ret = -TARGET_EFAULT;
else
ret = get_errno(link(p, p2));
unlock_user(p2, arg2, 0);
unlock_user(p, arg1, 0);
}
break;
#if defined(TARGET_NR_linkat) && defined(__NR_linkat)
case TARGET_NR_linkat:
{
void * p2 = NULL;
if (!arg2 || !arg4)
goto efault;
p = lock_user_string(arg2);
p2 = lock_user_string(arg4);
if (!p || !p2)
ret = -TARGET_EFAULT;
else
ret = get_errno(sys_linkat(arg1, p, arg3, p2, arg5));
unlock_user(p, arg2, 0);
unlock_user(p2, arg4, 0);
}
break;
#endif
case TARGET_NR_unlink:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(unlink(p));
unlock_user(p, arg1, 0);
break;
#if defined(TARGET_NR_unlinkat) && defined(__NR_unlinkat)
case TARGET_NR_unlinkat:
if (!(p = lock_user_string(arg2)))
goto efault;
ret = get_errno(sys_unlinkat(arg1, p, arg3));
unlock_user(p, arg2, 0);
break;
#endif
case TARGET_NR_execve:
{
char **argp, **envp;
int argc, envc;
abi_ulong gp;
abi_ulong guest_argp;
abi_ulong guest_envp;
abi_ulong addr;
char **q;
argc = 0;
guest_argp = arg2;
for (gp = guest_argp; gp; gp += sizeof(abi_ulong)) {
if (get_user_ual(addr, gp))
goto efault;
if (!addr)
break;
argc++;
}
envc = 0;
guest_envp = arg3;
for (gp = guest_envp; gp; gp += sizeof(abi_ulong)) {
if (get_user_ual(addr, gp))
goto efault;
if (!addr)
break;
envc++;
}
argp = alloca((argc + 1) * sizeof(void *));
envp = alloca((envc + 1) * sizeof(void *));
for (gp = guest_argp, q = argp; gp;
gp += sizeof(abi_ulong), q++) {
if (get_user_ual(addr, gp))
goto execve_efault;
if (!addr)
break;
if (!(*q = lock_user_string(addr)))
goto execve_efault;
}
*q = NULL;
for (gp = guest_envp, q = envp; gp;
gp += sizeof(abi_ulong), q++) {
if (get_user_ual(addr, gp))
goto execve_efault;
if (!addr)
break;
if (!(*q = lock_user_string(addr)))
goto execve_efault;
}
*q = NULL;
if (!(p = lock_user_string(arg1)))
goto execve_efault;
ret = get_errno(execve(p, argp, envp));
unlock_user(p, arg1, 0);
goto execve_end;
execve_efault:
ret = -TARGET_EFAULT;
execve_end:
for (gp = guest_argp, q = argp; *q;
gp += sizeof(abi_ulong), q++) {
if (get_user_ual(addr, gp)
|| !addr)
break;
unlock_user(*q, addr, 0);
}
for (gp = guest_envp, q = envp; *q;
gp += sizeof(abi_ulong), q++) {
if (get_user_ual(addr, gp)
|| !addr)
break;
unlock_user(*q, addr, 0);
}
}
break;
case TARGET_NR_chdir:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(chdir(p));
unlock_user(p, arg1, 0);
break;
#ifdef TARGET_NR_time
case TARGET_NR_time:
{
time_t host_time;
ret = get_errno(time(&host_time));
if (!is_error(ret)
&& arg1
&& put_user_sal(host_time, arg1))
goto efault;
}
break;
#endif
case TARGET_NR_mknod:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(mknod(p, arg2, arg3));
unlock_user(p, arg1, 0);
break;
#if defined(TARGET_NR_mknodat) && defined(__NR_mknodat)
case TARGET_NR_mknodat:
if (!(p = lock_user_string(arg2)))
goto efault;
ret = get_errno(sys_mknodat(arg1, p, arg3, arg4));
unlock_user(p, arg2, 0);
break;
#endif
case TARGET_NR_chmod:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(chmod(p, arg2));
unlock_user(p, arg1, 0);
break;
#ifdef TARGET_NR_break
case TARGET_NR_break:
goto unimplemented;
#endif
#ifdef TARGET_NR_oldstat
case TARGET_NR_oldstat:
goto unimplemented;
#endif
case TARGET_NR_lseek:
ret = get_errno(lseek(arg1, arg2, arg3));
break;
#ifdef TARGET_NR_getxpid
case TARGET_NR_getxpid:
#else
case TARGET_NR_getpid:
#endif
ret = get_errno(getpid());
break;
case TARGET_NR_mount:
{
void *p2, *p3;
p = lock_user_string(arg1);
p2 = lock_user_string(arg2);
p3 = lock_user_string(arg3);
if (!p || !p2 || !p3)
ret = -TARGET_EFAULT;
else
ret = get_errno(mount(p, p2, p3, (unsigned long)arg4, g2h(arg5)));
unlock_user(p, arg1, 0);
unlock_user(p2, arg2, 0);
unlock_user(p3, arg3, 0);
break;
}
#ifdef TARGET_NR_umount
case TARGET_NR_umount:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(umount(p));
unlock_user(p, arg1, 0);
break;
#endif
#ifdef TARGET_NR_stime
case TARGET_NR_stime:
{
time_t host_time;
if (get_user_sal(host_time, arg1))
goto efault;
ret = get_errno(stime(&host_time));
}
break;
#endif
case TARGET_NR_ptrace:
goto unimplemented;
#ifdef TARGET_NR_alarm
case TARGET_NR_alarm:
ret = alarm(arg1);
break;
#endif
#ifdef TARGET_NR_oldfstat
case TARGET_NR_oldfstat:
goto unimplemented;
#endif
#ifdef TARGET_NR_pause
case TARGET_NR_pause:
ret = get_errno(pause());
break;
#endif
#ifdef TARGET_NR_utime
case TARGET_NR_utime:
{
struct utimbuf tbuf, *host_tbuf;
struct target_utimbuf *target_tbuf;
if (arg2) {
if (!lock_user_struct(VERIFY_READ, target_tbuf, arg2, 1))
goto efault;
tbuf.actime = tswapl(target_tbuf->actime);
tbuf.modtime = tswapl(target_tbuf->modtime);
unlock_user_struct(target_tbuf, arg2, 0);
host_tbuf = &tbuf;
} else {
host_tbuf = NULL;
}
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(utime(p, host_tbuf));
unlock_user(p, arg1, 0);
}
break;
#endif
case TARGET_NR_utimes:
{
struct timeval *tvp, tv[2];
if (arg2) {
if (copy_from_user_timeval(&tv[0], arg2)
|| copy_from_user_timeval(&tv[1],
arg2 + sizeof(struct target_timeval)))
goto efault;
tvp = tv;
} else {
tvp = NULL;
}
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(utimes(p, tvp));
unlock_user(p, arg1, 0);
}
break;
#if defined(TARGET_NR_futimesat) && defined(__NR_futimesat)
case TARGET_NR_futimesat:
{
struct timeval *tvp, tv[2];
if (arg3) {
if (copy_from_user_timeval(&tv[0], arg3)
|| copy_from_user_timeval(&tv[1],
arg3 + sizeof(struct target_timeval)))
goto efault;
tvp = tv;
} else {
tvp = NULL;
}
if (!(p = lock_user_string(arg2)))
goto efault;
ret = get_errno(sys_futimesat(arg1, path(p), tvp));
unlock_user(p, arg2, 0);
}
break;
#endif
#ifdef TARGET_NR_stty
case TARGET_NR_stty:
goto unimplemented;
#endif
#ifdef TARGET_NR_gtty
case TARGET_NR_gtty:
goto unimplemented;
#endif
case TARGET_NR_access:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(access(path(p), arg2));
unlock_user(p, arg1, 0);
break;
#if defined(TARGET_NR_faccessat) && defined(__NR_faccessat)
case TARGET_NR_faccessat:
if (!(p = lock_user_string(arg2)))
goto efault;
ret = get_errno(sys_faccessat(arg1, p, arg3));
unlock_user(p, arg2, 0);
break;
#endif
#ifdef TARGET_NR_nice
case TARGET_NR_nice:
ret = get_errno(nice(arg1));
break;
#endif
#ifdef TARGET_NR_ftime
case TARGET_NR_ftime:
goto unimplemented;
#endif
case TARGET_NR_sync:
sync();
ret = 0;
break;
case TARGET_NR_kill:
ret = get_errno(kill(arg1, target_to_host_signal(arg2)));
break;
case TARGET_NR_rename:
{
void *p2;
p = lock_user_string(arg1);
p2 = lock_user_string(arg2);
if (!p || !p2)
ret = -TARGET_EFAULT;
else
ret = get_errno(rename(p, p2));
unlock_user(p2, arg2, 0);
unlock_user(p, arg1, 0);
}
break;
#if defined(TARGET_NR_renameat) && defined(__NR_renameat)
case TARGET_NR_renameat:
{
void *p2;
p = lock_user_string(arg2);
p2 = lock_user_string(arg4);
if (!p || !p2)
ret = -TARGET_EFAULT;
else
ret = get_errno(sys_renameat(arg1, p, arg3, p2));
unlock_user(p2, arg4, 0);
unlock_user(p, arg2, 0);
}
break;
#endif
case TARGET_NR_mkdir:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(mkdir(p, arg2));
unlock_user(p, arg1, 0);
break;
#if defined(TARGET_NR_mkdirat) && defined(__NR_mkdirat)
case TARGET_NR_mkdirat:
if (!(p = lock_user_string(arg2)))
goto efault;
ret = get_errno(sys_mkdirat(arg1, p, arg3));
unlock_user(p, arg2, 0);
break;
#endif
case TARGET_NR_rmdir:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(rmdir(p));
unlock_user(p, arg1, 0);
break;
case TARGET_NR_dup:
ret = get_errno(dup(arg1));
break;
case TARGET_NR_pipe:
ret = do_pipe(cpu_env, arg1, 0);
break;
#ifdef TARGET_NR_pipe2
case TARGET_NR_pipe2:
ret = do_pipe(cpu_env, arg1, arg2);
break;
#endif
case TARGET_NR_times:
{
struct target_tms *tmsp;
struct tms tms;
ret = get_errno(times(&tms));
if (arg1) {
tmsp = lock_user(VERIFY_WRITE, arg1, sizeof(struct target_tms), 0);
if (!tmsp)
goto efault;
tmsp->tms_utime = tswapl(host_to_target_clock_t(tms.tms_utime));
tmsp->tms_stime = tswapl(host_to_target_clock_t(tms.tms_stime));
tmsp->tms_cutime = tswapl(host_to_target_clock_t(tms.tms_cutime));
tmsp->tms_cstime = tswapl(host_to_target_clock_t(tms.tms_cstime));
}
if (!is_error(ret))
ret = host_to_target_clock_t(ret);
}
break;
#ifdef TARGET_NR_prof
case TARGET_NR_prof:
goto unimplemented;
#endif
#ifdef TARGET_NR_signal
case TARGET_NR_signal:
goto unimplemented;
#endif
case TARGET_NR_acct:
if (arg1 == 0) {
ret = get_errno(acct(NULL));
} else {
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(acct(path(p)));
unlock_user(p, arg1, 0);
}
break;
#ifdef TARGET_NR_umount2
case TARGET_NR_umount2:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(umount2(p, arg2));
unlock_user(p, arg1, 0);
break;
#endif
#ifdef TARGET_NR_lock
case TARGET_NR_lock:
goto unimplemented;
#endif
case TARGET_NR_ioctl:
ret = do_ioctl(arg1, arg2, arg3);
break;
case TARGET_NR_fcntl:
ret = do_fcntl(arg1, arg2, arg3);
break;
#ifdef TARGET_NR_mpx
case TARGET_NR_mpx:
goto unimplemented;
#endif
case TARGET_NR_setpgid:
ret = get_errno(setpgid(arg1, arg2));
break;
#ifdef TARGET_NR_ulimit
case TARGET_NR_ulimit:
goto unimplemented;
#endif
#ifdef TARGET_NR_oldolduname
case TARGET_NR_oldolduname:
goto unimplemented;
#endif
case TARGET_NR_umask:
ret = get_errno(umask(arg1));
break;
case TARGET_NR_chroot:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(chroot(p));
unlock_user(p, arg1, 0);
break;
case TARGET_NR_ustat:
goto unimplemented;
case TARGET_NR_dup2:
ret = get_errno(dup2(arg1, arg2));
break;
#ifdef TARGET_NR_getppid
case TARGET_NR_getppid:
ret = get_errno(getppid());
break;
#endif
case TARGET_NR_getpgrp:
ret = get_errno(getpgrp());
break;
case TARGET_NR_setsid:
ret = get_errno(setsid());
break;
#ifdef TARGET_NR_sigaction
case TARGET_NR_sigaction:
{
#if !defined(TARGET_MIPS)
struct target_old_sigaction *old_act;
struct target_sigaction act, oact, *pact;
if (arg2) {
if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1))
goto efault;
act._sa_handler = old_act->_sa_handler;
target_siginitset(&act.sa_mask, old_act->sa_mask);
act.sa_flags = old_act->sa_flags;
act.sa_restorer = old_act->sa_restorer;
unlock_user_struct(old_act, arg2, 0);
pact = &act;
} else {
pact = NULL;
}
ret = get_errno(do_sigaction(arg1, pact, &oact));
if (!is_error(ret) && arg3) {
if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0))
goto efault;
old_act->_sa_handler = oact._sa_handler;
old_act->sa_mask = oact.sa_mask.sig[0];
old_act->sa_flags = oact.sa_flags;
old_act->sa_restorer = oact.sa_restorer;
unlock_user_struct(old_act, arg3, 1);
}
#else
struct target_sigaction act, oact, *pact, *old_act;
if (arg2) {
if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1))
goto efault;
act._sa_handler = old_act->_sa_handler;
target_siginitset(&act.sa_mask, old_act->sa_mask.sig[0]);
act.sa_flags = old_act->sa_flags;
unlock_user_struct(old_act, arg2, 0);
pact = &act;
} else {
pact = NULL;
}
ret = get_errno(do_sigaction(arg1, pact, &oact));
if (!is_error(ret) && arg3) {
if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0))
goto efault;
old_act->_sa_handler = oact._sa_handler;
old_act->sa_flags = oact.sa_flags;
old_act->sa_mask.sig[0] = oact.sa_mask.sig[0];
old_act->sa_mask.sig[1] = 0;
old_act->sa_mask.sig[2] = 0;
old_act->sa_mask.sig[3] = 0;
unlock_user_struct(old_act, arg3, 1);
}
#endif
}
break;
#endif
case TARGET_NR_rt_sigaction:
{
struct target_sigaction *act;
struct target_sigaction *oact;
if (arg2) {
if (!lock_user_struct(VERIFY_READ, act, arg2, 1))
goto efault;
} else
act = NULL;
if (arg3) {
if (!lock_user_struct(VERIFY_WRITE, oact, arg3, 0)) {
ret = -TARGET_EFAULT;
goto rt_sigaction_fail;
}
} else
oact = NULL;
ret = get_errno(do_sigaction(arg1, act, oact));
rt_sigaction_fail:
if (act)
unlock_user_struct(act, arg2, 0);
if (oact)
unlock_user_struct(oact, arg3, 1);
}
break;
#ifdef TARGET_NR_sgetmask
case TARGET_NR_sgetmask:
{
sigset_t cur_set;
abi_ulong target_set;
sigprocmask(0, NULL, &cur_set);
host_to_target_old_sigset(&target_set, &cur_set);
ret = target_set;
}
break;
#endif
#ifdef TARGET_NR_ssetmask
case TARGET_NR_ssetmask:
{
sigset_t set, oset, cur_set;
abi_ulong target_set = arg1;
sigprocmask(0, NULL, &cur_set);
target_to_host_old_sigset(&set, &target_set);
sigorset(&set, &set, &cur_set);
sigprocmask(SIG_SETMASK, &set, &oset);
host_to_target_old_sigset(&target_set, &oset);
ret = target_set;
}
break;
#endif
#ifdef TARGET_NR_sigprocmask
case TARGET_NR_sigprocmask:
{
int how = arg1;
sigset_t set, oldset, *set_ptr;
if (arg2) {
switch(how) {
case TARGET_SIG_BLOCK:
how = SIG_BLOCK;
break;
case TARGET_SIG_UNBLOCK:
how = SIG_UNBLOCK;
break;
case TARGET_SIG_SETMASK:
how = SIG_SETMASK;
break;
default:
ret = -TARGET_EINVAL;
goto fail;
}
if (!(p = lock_user(VERIFY_READ, arg2, sizeof(target_sigset_t), 1)))
goto efault;
target_to_host_old_sigset(&set, p);
unlock_user(p, arg2, 0);
set_ptr = &set;
} else {
how = 0;
set_ptr = NULL;
}
ret = get_errno(sigprocmask(arg1, set_ptr, &oldset));
if (!is_error(ret) && arg3) {
if (!(p = lock_user(VERIFY_WRITE, arg3, sizeof(target_sigset_t), 0)))
goto efault;
host_to_target_old_sigset(p, &oldset);
unlock_user(p, arg3, sizeof(target_sigset_t));
}
}
break;
#endif
case TARGET_NR_rt_sigprocmask:
{
int how = arg1;
sigset_t set, oldset, *set_ptr;
if (arg2) {
switch(how) {
case TARGET_SIG_BLOCK:
how = SIG_BLOCK;
break;
case TARGET_SIG_UNBLOCK:
how = SIG_UNBLOCK;
break;
case TARGET_SIG_SETMASK:
how = SIG_SETMASK;
break;
default:
ret = -TARGET_EINVAL;
goto fail;
}
if (!(p = lock_user(VERIFY_READ, arg2, sizeof(target_sigset_t), 1)))
goto efault;
target_to_host_sigset(&set, p);
unlock_user(p, arg2, 0);
set_ptr = &set;
} else {
how = 0;
set_ptr = NULL;
}
ret = get_errno(sigprocmask(how, set_ptr, &oldset));
if (!is_error(ret) && arg3) {
if (!(p = lock_user(VERIFY_WRITE, arg3, sizeof(target_sigset_t), 0)))
goto efault;
host_to_target_sigset(p, &oldset);
unlock_user(p, arg3, sizeof(target_sigset_t));
}
}
break;
#ifdef TARGET_NR_sigpending
case TARGET_NR_sigpending:
{
sigset_t set;
ret = get_errno(sigpending(&set));
if (!is_error(ret)) {
if (!(p = lock_user(VERIFY_WRITE, arg1, sizeof(target_sigset_t), 0)))
goto efault;
host_to_target_old_sigset(p, &set);
unlock_user(p, arg1, sizeof(target_sigset_t));
}
}
break;
#endif
case TARGET_NR_rt_sigpending:
{
sigset_t set;
ret = get_errno(sigpending(&set));
if (!is_error(ret)) {
if (!(p = lock_user(VERIFY_WRITE, arg1, sizeof(target_sigset_t), 0)))
goto efault;
host_to_target_sigset(p, &set);
unlock_user(p, arg1, sizeof(target_sigset_t));
}
}
break;
#ifdef TARGET_NR_sigsuspend
case TARGET_NR_sigsuspend:
{
sigset_t set;
if (!(p = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1)))
goto efault;
target_to_host_old_sigset(&set, p);
unlock_user(p, arg1, 0);
ret = get_errno(sigsuspend(&set));
}
break;
#endif
case TARGET_NR_rt_sigsuspend:
{
sigset_t set;
if (!(p = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1)))
goto efault;
target_to_host_sigset(&set, p);
unlock_user(p, arg1, 0);
ret = get_errno(sigsuspend(&set));
}
break;
case TARGET_NR_rt_sigtimedwait:
{
sigset_t set;
struct timespec uts, *puts;
siginfo_t uinfo;
if (!(p = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1)))
goto efault;
target_to_host_sigset(&set, p);
unlock_user(p, arg1, 0);
if (arg3) {
puts = &uts;
target_to_host_timespec(puts, arg3);
} else {
puts = NULL;
}
ret = get_errno(sigtimedwait(&set, &uinfo, puts));
if (!is_error(ret) && arg2) {
if (!(p = lock_user(VERIFY_WRITE, arg2, sizeof(target_siginfo_t), 0)))
goto efault;
host_to_target_siginfo(p, &uinfo);
unlock_user(p, arg2, sizeof(target_siginfo_t));
}
}
break;
case TARGET_NR_rt_sigqueueinfo:
{
siginfo_t uinfo;
if (!(p = lock_user(VERIFY_READ, arg3, sizeof(target_sigset_t), 1)))
goto efault;
target_to_host_siginfo(&uinfo, p);
unlock_user(p, arg1, 0);
ret = get_errno(sys_rt_sigqueueinfo(arg1, arg2, &uinfo));
}
break;
#ifdef TARGET_NR_sigreturn
case TARGET_NR_sigreturn:
ret = do_sigreturn(cpu_env);
break;
#endif
case TARGET_NR_rt_sigreturn:
ret = do_rt_sigreturn(cpu_env);
break;
case TARGET_NR_sethostname:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(sethostname(p, arg2));
unlock_user(p, arg1, 0);
break;
case TARGET_NR_setrlimit:
{
int resource = arg1;
struct target_rlimit *target_rlim;
struct rlimit rlim;
if (!lock_user_struct(VERIFY_READ, target_rlim, arg2, 1))
goto efault;
rlim.rlim_cur = tswapl(target_rlim->rlim_cur);
rlim.rlim_max = tswapl(target_rlim->rlim_max);
unlock_user_struct(target_rlim, arg2, 0);
ret = get_errno(setrlimit(resource, &rlim));
}
break;
case TARGET_NR_getrlimit:
{
int resource = arg1;
struct target_rlimit *target_rlim;
struct rlimit rlim;
ret = get_errno(getrlimit(resource, &rlim));
if (!is_error(ret)) {
if (!lock_user_struct(VERIFY_WRITE, target_rlim, arg2, 0))
goto efault;
target_rlim->rlim_cur = tswapl(rlim.rlim_cur);
target_rlim->rlim_max = tswapl(rlim.rlim_max);
unlock_user_struct(target_rlim, arg2, 1);
}
}
break;
case TARGET_NR_getrusage:
{
struct rusage rusage;
ret = get_errno(getrusage(arg1, &rusage));
if (!is_error(ret)) {
host_to_target_rusage(arg2, &rusage);
}
}
break;
case TARGET_NR_gettimeofday:
{
struct timeval tv;
ret = get_errno(gettimeofday(&tv, NULL));
if (!is_error(ret)) {
if (copy_to_user_timeval(arg1, &tv))
goto efault;
}
}
break;
case TARGET_NR_settimeofday:
{
struct timeval tv;
if (copy_from_user_timeval(&tv, arg1))
goto efault;
ret = get_errno(settimeofday(&tv, NULL));
}
break;
#ifdef TARGET_NR_select
case TARGET_NR_select:
{
struct target_sel_arg_struct *sel;
abi_ulong inp, outp, exp, tvp;
long nsel;
if (!lock_user_struct(VERIFY_READ, sel, arg1, 1))
goto efault;
nsel = tswapl(sel->n);
inp = tswapl(sel->inp);
outp = tswapl(sel->outp);
exp = tswapl(sel->exp);
tvp = tswapl(sel->tvp);
unlock_user_struct(sel, arg1, 0);
ret = do_select(nsel, inp, outp, exp, tvp);
}
break;
#endif
case TARGET_NR_symlink:
{
void *p2;
p = lock_user_string(arg1);
p2 = lock_user_string(arg2);
if (!p || !p2)
ret = -TARGET_EFAULT;
else
ret = get_errno(symlink(p, p2));
unlock_user(p2, arg2, 0);
unlock_user(p, arg1, 0);
}
break;
#if defined(TARGET_NR_symlinkat) && defined(__NR_symlinkat)
case TARGET_NR_symlinkat:
{
void *p2;
p = lock_user_string(arg1);
p2 = lock_user_string(arg3);
if (!p || !p2)
ret = -TARGET_EFAULT;
else
ret = get_errno(sys_symlinkat(p, arg2, p2));
unlock_user(p2, arg3, 0);
unlock_user(p, arg1, 0);
}
break;
#endif
#ifdef TARGET_NR_oldlstat
case TARGET_NR_oldlstat:
goto unimplemented;
#endif
case TARGET_NR_readlink:
{
void *p2, *temp;
p = lock_user_string(arg1);
p2 = lock_user(VERIFY_WRITE, arg2, arg3, 0);
if (!p || !p2)
ret = -TARGET_EFAULT;
else {
if (strncmp((const char *)p, "/proc/self/exe", 14) == 0) {
char real[PATH_MAX];
temp = realpath(exec_path,real);
ret = (temp==NULL) ? get_errno(-1) : strlen(real) ;
snprintf((char *)p2, arg3, "%s", real);
}
else
ret = get_errno(readlink(path(p), p2, arg3));
}
unlock_user(p2, arg2, ret);
unlock_user(p, arg1, 0);
}
break;
#if defined(TARGET_NR_readlinkat) && defined(__NR_readlinkat)
case TARGET_NR_readlinkat:
{
void *p2;
p = lock_user_string(arg2);
p2 = lock_user(VERIFY_WRITE, arg3, arg4, 0);
if (!p || !p2)
ret = -TARGET_EFAULT;
else
ret = get_errno(sys_readlinkat(arg1, path(p), p2, arg4));
unlock_user(p2, arg3, ret);
unlock_user(p, arg2, 0);
}
break;
#endif
#ifdef TARGET_NR_uselib
case TARGET_NR_uselib:
goto unimplemented;
#endif
#ifdef TARGET_NR_swapon
case TARGET_NR_swapon:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(swapon(p, arg2));
unlock_user(p, arg1, 0);
break;
#endif
case TARGET_NR_reboot:
goto unimplemented;
#ifdef TARGET_NR_readdir
case TARGET_NR_readdir:
goto unimplemented;
#endif
#ifdef TARGET_NR_mmap
case TARGET_NR_mmap:
#if (defined(TARGET_I386) && defined(TARGET_ABI32)) || defined(TARGET_ARM) || defined(TARGET_M68K) || defined(TARGET_CRIS) || defined(TARGET_MICROBLAZE)
{
abi_ulong *v;
abi_ulong v1, v2, v3, v4, v5, v6;
if (!(v = lock_user(VERIFY_READ, arg1, 6 * sizeof(abi_ulong), 1)))
goto efault;
v1 = tswapl(v[0]);
v2 = tswapl(v[1]);
v3 = tswapl(v[2]);
v4 = tswapl(v[3]);
v5 = tswapl(v[4]);
v6 = tswapl(v[5]);
unlock_user(v, arg1, 0);
ret = get_errno(target_mmap(v1, v2, v3,
target_to_host_bitmask(v4, mmap_flags_tbl),
v5, v6));
}
#else
ret = get_errno(target_mmap(arg1, arg2, arg3,
target_to_host_bitmask(arg4, mmap_flags_tbl),
arg5,
arg6));
#endif
break;
#endif
#ifdef TARGET_NR_mmap2
case TARGET_NR_mmap2:
#ifndef MMAP_SHIFT
#define MMAP_SHIFT 12
#endif
ret = get_errno(target_mmap(arg1, arg2, arg3,
target_to_host_bitmask(arg4, mmap_flags_tbl),
arg5,
arg6 << MMAP_SHIFT));
break;
#endif
case TARGET_NR_munmap:
ret = get_errno(target_munmap(arg1, arg2));
break;
case TARGET_NR_mprotect:
ret = get_errno(target_mprotect(arg1, arg2, arg3));
break;
#ifdef TARGET_NR_mremap
case TARGET_NR_mremap:
ret = get_errno(target_mremap(arg1, arg2, arg3, arg4, arg5));
break;
#endif
#ifdef TARGET_NR_msync
case TARGET_NR_msync:
ret = get_errno(msync(g2h(arg1), arg2, arg3));
break;
#endif
#ifdef TARGET_NR_mlock
case TARGET_NR_mlock:
ret = get_errno(mlock(g2h(arg1), arg2));
break;
#endif
#ifdef TARGET_NR_munlock
case TARGET_NR_munlock:
ret = get_errno(munlock(g2h(arg1), arg2));
break;
#endif
#ifdef TARGET_NR_mlockall
case TARGET_NR_mlockall:
ret = get_errno(mlockall(arg1));
break;
#endif
#ifdef TARGET_NR_munlockall
case TARGET_NR_munlockall:
ret = get_errno(munlockall());
break;
#endif
case TARGET_NR_truncate:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(truncate(p, arg2));
unlock_user(p, arg1, 0);
break;
case TARGET_NR_ftruncate:
ret = get_errno(ftruncate(arg1, arg2));
break;
case TARGET_NR_fchmod:
ret = get_errno(fchmod(arg1, arg2));
break;
#if defined(TARGET_NR_fchmodat) && defined(__NR_fchmodat)
case TARGET_NR_fchmodat:
if (!(p = lock_user_string(arg2)))
goto efault;
ret = get_errno(sys_fchmodat(arg1, p, arg3));
unlock_user(p, arg2, 0);
break;
#endif
case TARGET_NR_getpriority:
ret = sys_getpriority(arg1, arg2);
break;
case TARGET_NR_setpriority:
ret = get_errno(setpriority(arg1, arg2, arg3));
break;
#ifdef TARGET_NR_profil
case TARGET_NR_profil:
goto unimplemented;
#endif
case TARGET_NR_statfs:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(statfs(path(p), &stfs));
unlock_user(p, arg1, 0);
convert_statfs:
if (!is_error(ret)) {
struct target_statfs *target_stfs;
if (!lock_user_struct(VERIFY_WRITE, target_stfs, arg2, 0))
goto efault;
__put_user(stfs.f_type, &target_stfs->f_type);
__put_user(stfs.f_bsize, &target_stfs->f_bsize);
__put_user(stfs.f_blocks, &target_stfs->f_blocks);
__put_user(stfs.f_bfree, &target_stfs->f_bfree);
__put_user(stfs.f_bavail, &target_stfs->f_bavail);
__put_user(stfs.f_files, &target_stfs->f_files);
__put_user(stfs.f_ffree, &target_stfs->f_ffree);
__put_user(stfs.f_fsid.__val[0], &target_stfs->f_fsid.val[0]);
__put_user(stfs.f_fsid.__val[1], &target_stfs->f_fsid.val[1]);
__put_user(stfs.f_namelen, &target_stfs->f_namelen);
unlock_user_struct(target_stfs, arg2, 1);
}
break;
case TARGET_NR_fstatfs:
ret = get_errno(fstatfs(arg1, &stfs));
goto convert_statfs;
#ifdef TARGET_NR_statfs64
case TARGET_NR_statfs64:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(statfs(path(p), &stfs));
unlock_user(p, arg1, 0);
convert_statfs64:
if (!is_error(ret)) {
struct target_statfs64 *target_stfs;
if (!lock_user_struct(VERIFY_WRITE, target_stfs, arg3, 0))
goto efault;
__put_user(stfs.f_type, &target_stfs->f_type);
__put_user(stfs.f_bsize, &target_stfs->f_bsize);
__put_user(stfs.f_blocks, &target_stfs->f_blocks);
__put_user(stfs.f_bfree, &target_stfs->f_bfree);
__put_user(stfs.f_bavail, &target_stfs->f_bavail);
__put_user(stfs.f_files, &target_stfs->f_files);
__put_user(stfs.f_ffree, &target_stfs->f_ffree);
__put_user(stfs.f_fsid.__val[0], &target_stfs->f_fsid.val[0]);
__put_user(stfs.f_fsid.__val[1], &target_stfs->f_fsid.val[1]);
__put_user(stfs.f_namelen, &target_stfs->f_namelen);
unlock_user_struct(target_stfs, arg3, 1);
}
break;
case TARGET_NR_fstatfs64:
ret = get_errno(fstatfs(arg1, &stfs));
goto convert_statfs64;
#endif
#ifdef TARGET_NR_ioperm
case TARGET_NR_ioperm:
goto unimplemented;
#endif
#ifdef TARGET_NR_socketcall
case TARGET_NR_socketcall:
ret = do_socketcall(arg1, arg2);
break;
#endif
#ifdef TARGET_NR_accept
case TARGET_NR_accept:
ret = do_accept(arg1, arg2, arg3);
break;
#endif
#ifdef TARGET_NR_bind
case TARGET_NR_bind:
ret = do_bind(arg1, arg2, arg3);
break;
#endif
#ifdef TARGET_NR_connect
case TARGET_NR_connect:
ret = do_connect(arg1, arg2, arg3);
break;
#endif
#ifdef TARGET_NR_getpeername
case TARGET_NR_getpeername:
ret = do_getpeername(arg1, arg2, arg3);
break;
#endif
#ifdef TARGET_NR_getsockname
case TARGET_NR_getsockname:
ret = do_getsockname(arg1, arg2, arg3);
break;
#endif
#ifdef TARGET_NR_getsockopt
case TARGET_NR_getsockopt:
ret = do_getsockopt(arg1, arg2, arg3, arg4, arg5);
break;
#endif
#ifdef TARGET_NR_listen
case TARGET_NR_listen:
ret = get_errno(listen(arg1, arg2));
break;
#endif
#ifdef TARGET_NR_recv
case TARGET_NR_recv:
ret = do_recvfrom(arg1, arg2, arg3, arg4, 0, 0);
break;
#endif
#ifdef TARGET_NR_recvfrom
case TARGET_NR_recvfrom:
ret = do_recvfrom(arg1, arg2, arg3, arg4, arg5, arg6);
break;
#endif
#ifdef TARGET_NR_recvmsg
case TARGET_NR_recvmsg:
ret = do_sendrecvmsg(arg1, arg2, arg3, 0);
break;
#endif
#ifdef TARGET_NR_send
case TARGET_NR_send:
ret = do_sendto(arg1, arg2, arg3, arg4, 0, 0);
break;
#endif
#ifdef TARGET_NR_sendmsg
case TARGET_NR_sendmsg:
ret = do_sendrecvmsg(arg1, arg2, arg3, 1);
break;
#endif
#ifdef TARGET_NR_sendto
case TARGET_NR_sendto:
ret = do_sendto(arg1, arg2, arg3, arg4, arg5, arg6);
break;
#endif
#ifdef TARGET_NR_shutdown
case TARGET_NR_shutdown:
ret = get_errno(shutdown(arg1, arg2));
break;
#endif
#ifdef TARGET_NR_socket
case TARGET_NR_socket:
ret = do_socket(arg1, arg2, arg3);
break;
#endif
#ifdef TARGET_NR_socketpair
case TARGET_NR_socketpair:
ret = do_socketpair(arg1, arg2, arg3, arg4);
break;
#endif
#ifdef TARGET_NR_setsockopt
case TARGET_NR_setsockopt:
ret = do_setsockopt(arg1, arg2, arg3, arg4, (socklen_t) arg5);
break;
#endif
case TARGET_NR_syslog:
if (!(p = lock_user_string(arg2)))
goto efault;
ret = get_errno(sys_syslog((int)arg1, p, (int)arg3));
unlock_user(p, arg2, 0);
break;
case TARGET_NR_setitimer:
{
struct itimerval value, ovalue, *pvalue;
if (arg2) {
pvalue = &value;
if (copy_from_user_timeval(&pvalue->it_interval, arg2)
|| copy_from_user_timeval(&pvalue->it_value,
arg2 + sizeof(struct target_timeval)))
goto efault;
} else {
pvalue = NULL;
}
ret = get_errno(setitimer(arg1, pvalue, &ovalue));
if (!is_error(ret) && arg3) {
if (copy_to_user_timeval(arg3,
&ovalue.it_interval)
|| copy_to_user_timeval(arg3 + sizeof(struct target_timeval),
&ovalue.it_value))
goto efault;
}
}
break;
case TARGET_NR_getitimer:
{
struct itimerval value;
ret = get_errno(getitimer(arg1, &value));
if (!is_error(ret) && arg2) {
if (copy_to_user_timeval(arg2,
&value.it_interval)
|| copy_to_user_timeval(arg2 + sizeof(struct target_timeval),
&value.it_value))
goto efault;
}
}
break;
case TARGET_NR_stat:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(stat(path(p), &st));
unlock_user(p, arg1, 0);
goto do_stat;
case TARGET_NR_lstat:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(lstat(path(p), &st));
unlock_user(p, arg1, 0);
goto do_stat;
case TARGET_NR_fstat:
{
ret = get_errno(fstat(arg1, &st));
do_stat:
if (!is_error(ret)) {
struct target_stat *target_st;
if (!lock_user_struct(VERIFY_WRITE, target_st, arg2, 0))
goto efault;
__put_user(st.st_dev, &target_st->st_dev);
__put_user(st.st_ino, &target_st->st_ino);
__put_user(st.st_mode, &target_st->st_mode);
__put_user(st.st_uid, &target_st->st_uid);
__put_user(st.st_gid, &target_st->st_gid);
__put_user(st.st_nlink, &target_st->st_nlink);
__put_user(st.st_rdev, &target_st->st_rdev);
__put_user(st.st_size, &target_st->st_size);
__put_user(st.st_blksize, &target_st->st_blksize);
__put_user(st.st_blocks, &target_st->st_blocks);
__put_user(st.st_atime, &target_st->target_st_atime);
__put_user(st.st_mtime, &target_st->target_st_mtime);
__put_user(st.st_ctime, &target_st->target_st_ctime);
unlock_user_struct(target_st, arg2, 1);
}
}
break;
#ifdef TARGET_NR_olduname
case TARGET_NR_olduname:
goto unimplemented;
#endif
#ifdef TARGET_NR_iopl
case TARGET_NR_iopl:
goto unimplemented;
#endif
case TARGET_NR_vhangup:
ret = get_errno(vhangup());
break;
#ifdef TARGET_NR_idle
case TARGET_NR_idle:
goto unimplemented;
#endif
#ifdef TARGET_NR_syscall
case TARGET_NR_syscall:
ret = do_syscall(cpu_env,arg1 & 0xffff,arg2,arg3,arg4,arg5,arg6,0);
break;
#endif
case TARGET_NR_wait4:
{
int status;
abi_long status_ptr = arg2;
struct rusage rusage, *rusage_ptr;
abi_ulong target_rusage = arg4;
if (target_rusage)
rusage_ptr = &rusage;
else
rusage_ptr = NULL;
ret = get_errno(wait4(arg1, &status, arg3, rusage_ptr));
if (!is_error(ret)) {
if (status_ptr) {
status = host_to_target_waitstatus(status);
if (put_user_s32(status, status_ptr))
goto efault;
}
if (target_rusage)
host_to_target_rusage(target_rusage, &rusage);
}
}
break;
#ifdef TARGET_NR_swapoff
case TARGET_NR_swapoff:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(swapoff(p));
unlock_user(p, arg1, 0);
break;
#endif
case TARGET_NR_sysinfo:
{
struct target_sysinfo *target_value;
struct sysinfo value;
ret = get_errno(sysinfo(&value));
if (!is_error(ret) && arg1)
{
if (!lock_user_struct(VERIFY_WRITE, target_value, arg1, 0))
goto efault;
__put_user(value.uptime, &target_value->uptime);
__put_user(value.loads[0], &target_value->loads[0]);
__put_user(value.loads[1], &target_value->loads[1]);
__put_user(value.loads[2], &target_value->loads[2]);
__put_user(value.totalram, &target_value->totalram);
__put_user(value.freeram, &target_value->freeram);
__put_user(value.sharedram, &target_value->sharedram);
__put_user(value.bufferram, &target_value->bufferram);
__put_user(value.totalswap, &target_value->totalswap);
__put_user(value.freeswap, &target_value->freeswap);
__put_user(value.procs, &target_value->procs);
__put_user(value.totalhigh, &target_value->totalhigh);
__put_user(value.freehigh, &target_value->freehigh);
__put_user(value.mem_unit, &target_value->mem_unit);
unlock_user_struct(target_value, arg1, 1);
}
}
break;
#ifdef TARGET_NR_ipc
case TARGET_NR_ipc:
ret = do_ipc(arg1, arg2, arg3, arg4, arg5, arg6);
break;
#endif
#ifdef TARGET_NR_semget
case TARGET_NR_semget:
ret = get_errno(semget(arg1, arg2, arg3));
break;
#endif
#ifdef TARGET_NR_semop
case TARGET_NR_semop:
ret = get_errno(do_semop(arg1, arg2, arg3));
break;
#endif
#ifdef TARGET_NR_semctl
case TARGET_NR_semctl:
ret = do_semctl(arg1, arg2, arg3, (union target_semun)(abi_ulong)arg4);
break;
#endif
#ifdef TARGET_NR_msgctl
case TARGET_NR_msgctl:
ret = do_msgctl(arg1, arg2, arg3);
break;
#endif
#ifdef TARGET_NR_msgget
case TARGET_NR_msgget:
ret = get_errno(msgget(arg1, arg2));
break;
#endif
#ifdef TARGET_NR_msgrcv
case TARGET_NR_msgrcv:
ret = do_msgrcv(arg1, arg2, arg3, arg4, arg5);
break;
#endif
#ifdef TARGET_NR_msgsnd
case TARGET_NR_msgsnd:
ret = do_msgsnd(arg1, arg2, arg3, arg4);
break;
#endif
#ifdef TARGET_NR_shmget
case TARGET_NR_shmget:
ret = get_errno(shmget(arg1, arg2, arg3));
break;
#endif
#ifdef TARGET_NR_shmctl
case TARGET_NR_shmctl:
ret = do_shmctl(arg1, arg2, arg3);
break;
#endif
#ifdef TARGET_NR_shmat
case TARGET_NR_shmat:
ret = do_shmat(arg1, arg2, arg3);
break;
#endif
#ifdef TARGET_NR_shmdt
case TARGET_NR_shmdt:
ret = do_shmdt(arg1);
break;
#endif
case TARGET_NR_fsync:
ret = get_errno(fsync(arg1));
break;
case TARGET_NR_clone:
#if defined(TARGET_SH4)
ret = get_errno(do_fork(cpu_env, arg1, arg2, arg3, arg5, arg4));
#elif defined(TARGET_CRIS)
ret = get_errno(do_fork(cpu_env, arg2, arg1, arg3, arg4, arg5));
#else
ret = get_errno(do_fork(cpu_env, arg1, arg2, arg3, arg4, arg5));
#endif
break;
#ifdef __NR_exit_group
case TARGET_NR_exit_group:
#ifdef TARGET_GPROF
_mcleanup();
#endif
gdb_exit(cpu_env, arg1);
ret = get_errno(exit_group(arg1));
break;
#endif
case TARGET_NR_setdomainname:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(setdomainname(p, arg2));
unlock_user(p, arg1, 0);
break;
case TARGET_NR_uname:
{
struct new_utsname * buf;
if (!lock_user_struct(VERIFY_WRITE, buf, arg1, 0))
goto efault;
ret = get_errno(sys_uname(buf));
if (!is_error(ret)) {
strcpy (buf->machine, UNAME_MACHINE);
if (qemu_uname_release && *qemu_uname_release)
strcpy (buf->release, qemu_uname_release);
}
unlock_user_struct(buf, arg1, 1);
}
break;
#ifdef TARGET_I386
case TARGET_NR_modify_ldt:
ret = do_modify_ldt(cpu_env, arg1, arg2, arg3);
break;
#if !defined(TARGET_X86_64)
case TARGET_NR_vm86old:
goto unimplemented;
case TARGET_NR_vm86:
ret = do_vm86(cpu_env, arg1, arg2);
break;
#endif
#endif
case TARGET_NR_adjtimex:
goto unimplemented;
#ifdef TARGET_NR_create_module
case TARGET_NR_create_module:
#endif
case TARGET_NR_init_module:
case TARGET_NR_delete_module:
#ifdef TARGET_NR_get_kernel_syms
case TARGET_NR_get_kernel_syms:
#endif
goto unimplemented;
case TARGET_NR_quotactl:
goto unimplemented;
case TARGET_NR_getpgid:
ret = get_errno(getpgid(arg1));
break;
case TARGET_NR_fchdir:
ret = get_errno(fchdir(arg1));
break;
#ifdef TARGET_NR_bdflush
case TARGET_NR_bdflush:
goto unimplemented;
#endif
#ifdef TARGET_NR_sysfs
case TARGET_NR_sysfs:
goto unimplemented;
#endif
case TARGET_NR_personality:
ret = get_errno(personality(arg1));
break;
#ifdef TARGET_NR_afs_syscall
case TARGET_NR_afs_syscall:
goto unimplemented;
#endif
#ifdef TARGET_NR__llseek
case TARGET_NR__llseek:
{
#if defined (__x86_64__)
ret = get_errno(lseek(arg1, ((uint64_t )arg2 << 32) | arg3, arg5));
if (put_user_s64(ret, arg4))
goto efault;
#else
int64_t res;
ret = get_errno(_llseek(arg1, arg2, arg3, &res, arg5));
if (put_user_s64(res, arg4))
goto efault;
#endif
}
break;
#endif
case TARGET_NR_getdents:
#if TARGET_ABI_BITS == 32 && HOST_LONG_BITS == 64
{
struct target_dirent *target_dirp;
struct linux_dirent *dirp;
abi_long count = arg3;
dirp = malloc(count);
if (!dirp) {
ret = -TARGET_ENOMEM;
goto fail;
}
ret = get_errno(sys_getdents(arg1, dirp, count));
if (!is_error(ret)) {
struct linux_dirent *de;
struct target_dirent *tde;
int len = ret;
int reclen, treclen;
int count1, tnamelen;
count1 = 0;
de = dirp;
if (!(target_dirp = lock_user(VERIFY_WRITE, arg2, count, 0)))
goto efault;
tde = target_dirp;
while (len > 0) {
reclen = de->d_reclen;
treclen = reclen - (2 * (sizeof(long) - sizeof(abi_long)));
tde->d_reclen = tswap16(treclen);
tde->d_ino = tswapl(de->d_ino);
tde->d_off = tswapl(de->d_off);
tnamelen = treclen - (2 * sizeof(abi_long) + 2);
if (tnamelen > 256)
tnamelen = 256;
pstrcpy(tde->d_name, tnamelen, de->d_name);
de = (struct linux_dirent *)((char *)de + reclen);
len -= reclen;
tde = (struct target_dirent *)((char *)tde + treclen);
count1 += treclen;
}
ret = count1;
unlock_user(target_dirp, arg2, ret);
}
free(dirp);
}
#else
{
struct linux_dirent *dirp;
abi_long count = arg3;
if (!(dirp = lock_user(VERIFY_WRITE, arg2, count, 0)))
goto efault;
ret = get_errno(sys_getdents(arg1, dirp, count));
if (!is_error(ret)) {
struct linux_dirent *de;
int len = ret;
int reclen;
de = dirp;
while (len > 0) {
reclen = de->d_reclen;
if (reclen > len)
break;
de->d_reclen = tswap16(reclen);
tswapls(&de->d_ino);
tswapls(&de->d_off);
de = (struct linux_dirent *)((char *)de + reclen);
len -= reclen;
}
}
unlock_user(dirp, arg2, ret);
}
#endif
break;
#if defined(TARGET_NR_getdents64) && defined(__NR_getdents64)
case TARGET_NR_getdents64:
{
struct linux_dirent64 *dirp;
abi_long count = arg3;
if (!(dirp = lock_user(VERIFY_WRITE, arg2, count, 0)))
goto efault;
ret = get_errno(sys_getdents64(arg1, dirp, count));
if (!is_error(ret)) {
struct linux_dirent64 *de;
int len = ret;
int reclen;
de = dirp;
while (len > 0) {
reclen = de->d_reclen;
if (reclen > len)
break;
de->d_reclen = tswap16(reclen);
tswap64s((uint64_t *)&de->d_ino);
tswap64s((uint64_t *)&de->d_off);
de = (struct linux_dirent64 *)((char *)de + reclen);
len -= reclen;
}
}
unlock_user(dirp, arg2, ret);
}
break;
#endif
#ifdef TARGET_NR__newselect
case TARGET_NR__newselect:
ret = do_select(arg1, arg2, arg3, arg4, arg5);
break;
#endif
#ifdef TARGET_NR_poll
case TARGET_NR_poll:
{
struct target_pollfd *target_pfd;
unsigned int nfds = arg2;
int timeout = arg3;
struct pollfd *pfd;
unsigned int i;
target_pfd = lock_user(VERIFY_WRITE, arg1, sizeof(struct target_pollfd) * nfds, 1);
if (!target_pfd)
goto efault;
pfd = alloca(sizeof(struct pollfd) * nfds);
for(i = 0; i < nfds; i++) {
pfd[i].fd = tswap32(target_pfd[i].fd);
pfd[i].events = tswap16(target_pfd[i].events);
}
ret = get_errno(poll(pfd, nfds, timeout));
if (!is_error(ret)) {
for(i = 0; i < nfds; i++) {
target_pfd[i].revents = tswap16(pfd[i].revents);
}
ret += nfds * (sizeof(struct target_pollfd)
- sizeof(struct pollfd));
}
unlock_user(target_pfd, arg1, ret);
}
break;
#endif
case TARGET_NR_flock:
ret = get_errno(flock(arg1, arg2));
break;
case TARGET_NR_readv:
{
int count = arg3;
struct iovec *vec;
vec = alloca(count * sizeof(struct iovec));
if (lock_iovec(VERIFY_WRITE, vec, arg2, count, 0) < 0)
goto efault;
ret = get_errno(readv(arg1, vec, count));
unlock_iovec(vec, arg2, count, 1);
}
break;
case TARGET_NR_writev:
{
int count = arg3;
struct iovec *vec;
vec = alloca(count * sizeof(struct iovec));
if (lock_iovec(VERIFY_READ, vec, arg2, count, 1) < 0)
goto efault;
ret = get_errno(writev(arg1, vec, count));
unlock_iovec(vec, arg2, count, 0);
}
break;
case TARGET_NR_getsid:
ret = get_errno(getsid(arg1));
break;
#if defined(TARGET_NR_fdatasync)
case TARGET_NR_fdatasync:
ret = get_errno(fdatasync(arg1));
break;
#endif
case TARGET_NR__sysctl:
ret = -TARGET_ENOTDIR;
break;
case TARGET_NR_sched_setparam:
{
struct sched_param *target_schp;
struct sched_param schp;
if (!lock_user_struct(VERIFY_READ, target_schp, arg2, 1))
goto efault;
schp.sched_priority = tswap32(target_schp->sched_priority);
unlock_user_struct(target_schp, arg2, 0);
ret = get_errno(sched_setparam(arg1, &schp));
}
break;
case TARGET_NR_sched_getparam:
{
struct sched_param *target_schp;
struct sched_param schp;
ret = get_errno(sched_getparam(arg1, &schp));
if (!is_error(ret)) {
if (!lock_user_struct(VERIFY_WRITE, target_schp, arg2, 0))
goto efault;
target_schp->sched_priority = tswap32(schp.sched_priority);
unlock_user_struct(target_schp, arg2, 1);
}
}
break;
case TARGET_NR_sched_setscheduler:
{
struct sched_param *target_schp;
struct sched_param schp;
if (!lock_user_struct(VERIFY_READ, target_schp, arg3, 1))
goto efault;
schp.sched_priority = tswap32(target_schp->sched_priority);
unlock_user_struct(target_schp, arg3, 0);
ret = get_errno(sched_setscheduler(arg1, arg2, &schp));
}
break;
case TARGET_NR_sched_getscheduler:
ret = get_errno(sched_getscheduler(arg1));
break;
case TARGET_NR_sched_yield:
ret = get_errno(sched_yield());
break;
case TARGET_NR_sched_get_priority_max:
ret = get_errno(sched_get_priority_max(arg1));
break;
case TARGET_NR_sched_get_priority_min:
ret = get_errno(sched_get_priority_min(arg1));
break;
case TARGET_NR_sched_rr_get_interval:
{
struct timespec ts;
ret = get_errno(sched_rr_get_interval(arg1, &ts));
if (!is_error(ret)) {
host_to_target_timespec(arg2, &ts);
}
}
break;
case TARGET_NR_nanosleep:
{
struct timespec req, rem;
target_to_host_timespec(&req, arg1);
ret = get_errno(nanosleep(&req, &rem));
if (is_error(ret) && arg2) {
host_to_target_timespec(arg2, &rem);
}
}
break;
#ifdef TARGET_NR_query_module
case TARGET_NR_query_module:
goto unimplemented;
#endif
#ifdef TARGET_NR_nfsservctl
case TARGET_NR_nfsservctl:
goto unimplemented;
#endif
case TARGET_NR_prctl:
switch (arg1)
{
case PR_GET_PDEATHSIG:
{
int deathsig;
ret = get_errno(prctl(arg1, &deathsig, arg3, arg4, arg5));
if (!is_error(ret) && arg2
&& put_user_ual(deathsig, arg2))
goto efault;
}
break;
default:
ret = get_errno(prctl(arg1, arg2, arg3, arg4, arg5));
break;
}
break;
#ifdef TARGET_NR_arch_prctl
case TARGET_NR_arch_prctl:
#if defined(TARGET_I386) && !defined(TARGET_ABI32)
ret = do_arch_prctl(cpu_env, arg1, arg2);
break;
#else
goto unimplemented;
#endif
#endif
#ifdef TARGET_NR_pread
case TARGET_NR_pread:
#ifdef TARGET_ARM
if (((CPUARMState *)cpu_env)->eabi)
arg4 = arg5;
#endif
if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0)))
goto efault;
ret = get_errno(pread(arg1, p, arg3, arg4));
unlock_user(p, arg2, ret);
break;
case TARGET_NR_pwrite:
#ifdef TARGET_ARM
if (((CPUARMState *)cpu_env)->eabi)
arg4 = arg5;
#endif
if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1)))
goto efault;
ret = get_errno(pwrite(arg1, p, arg3, arg4));
unlock_user(p, arg2, 0);
break;
#endif
#ifdef TARGET_NR_pread64
case TARGET_NR_pread64:
if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0)))
goto efault;
ret = get_errno(pread64(arg1, p, arg3, target_offset64(arg4, arg5)));
unlock_user(p, arg2, ret);
break;
case TARGET_NR_pwrite64:
if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1)))
goto efault;
ret = get_errno(pwrite64(arg1, p, arg3, target_offset64(arg4, arg5)));
unlock_user(p, arg2, 0);
break;
#endif
case TARGET_NR_getcwd:
if (!(p = lock_user(VERIFY_WRITE, arg1, arg2, 0)))
goto efault;
ret = get_errno(sys_getcwd1(p, arg2));
unlock_user(p, arg1, ret);
break;
case TARGET_NR_capget:
goto unimplemented;
case TARGET_NR_capset:
goto unimplemented;
case TARGET_NR_sigaltstack:
#if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_MIPS) || \
defined(TARGET_SPARC) || defined(TARGET_PPC) || defined(TARGET_ALPHA) || \
defined(TARGET_M68K)
ret = do_sigaltstack(arg1, arg2, get_sp_from_cpustate((CPUState *)cpu_env));
break;
#else
goto unimplemented;
#endif
case TARGET_NR_sendfile:
goto unimplemented;
#ifdef TARGET_NR_getpmsg
case TARGET_NR_getpmsg:
goto unimplemented;
#endif
#ifdef TARGET_NR_putpmsg
case TARGET_NR_putpmsg:
goto unimplemented;
#endif
#ifdef TARGET_NR_vfork
case TARGET_NR_vfork:
ret = get_errno(do_fork(cpu_env, CLONE_VFORK | CLONE_VM | SIGCHLD,
0, 0, 0, 0));
break;
#endif
#ifdef TARGET_NR_ugetrlimit
case TARGET_NR_ugetrlimit:
{
struct rlimit rlim;
ret = get_errno(getrlimit(arg1, &rlim));
if (!is_error(ret)) {
struct target_rlimit *target_rlim;
if (!lock_user_struct(VERIFY_WRITE, target_rlim, arg2, 0))
goto efault;
target_rlim->rlim_cur = tswapl(rlim.rlim_cur);
target_rlim->rlim_max = tswapl(rlim.rlim_max);
unlock_user_struct(target_rlim, arg2, 1);
}
break;
}
#endif
#ifdef TARGET_NR_truncate64
case TARGET_NR_truncate64:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = target_truncate64(cpu_env, p, arg2, arg3, arg4);
unlock_user(p, arg1, 0);
break;
#endif
#ifdef TARGET_NR_ftruncate64
case TARGET_NR_ftruncate64:
ret = target_ftruncate64(cpu_env, arg1, arg2, arg3, arg4);
break;
#endif
#ifdef TARGET_NR_stat64
case TARGET_NR_stat64:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(stat(path(p), &st));
unlock_user(p, arg1, 0);
if (!is_error(ret))
ret = host_to_target_stat64(cpu_env, arg2, &st);
break;
#endif
#ifdef TARGET_NR_lstat64
case TARGET_NR_lstat64:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(lstat(path(p), &st));
unlock_user(p, arg1, 0);
if (!is_error(ret))
ret = host_to_target_stat64(cpu_env, arg2, &st);
break;
#endif
#ifdef TARGET_NR_fstat64
case TARGET_NR_fstat64:
ret = get_errno(fstat(arg1, &st));
if (!is_error(ret))
ret = host_to_target_stat64(cpu_env, arg2, &st);
break;
#endif
#if (defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)) && \
(defined(__NR_fstatat64) || defined(__NR_newfstatat))
#ifdef TARGET_NR_fstatat64
case TARGET_NR_fstatat64:
#endif
#ifdef TARGET_NR_newfstatat
case TARGET_NR_newfstatat:
#endif
if (!(p = lock_user_string(arg2)))
goto efault;
#ifdef __NR_fstatat64
ret = get_errno(sys_fstatat64(arg1, path(p), &st, arg4));
#else
ret = get_errno(sys_newfstatat(arg1, path(p), &st, arg4));
#endif
if (!is_error(ret))
ret = host_to_target_stat64(cpu_env, arg3, &st);
break;
#endif
#ifdef USE_UID16
case TARGET_NR_lchown:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(lchown(p, low2highuid(arg2), low2highgid(arg3)));
unlock_user(p, arg1, 0);
break;
case TARGET_NR_getuid:
ret = get_errno(high2lowuid(getuid()));
break;
case TARGET_NR_getgid:
ret = get_errno(high2lowgid(getgid()));
break;
case TARGET_NR_geteuid:
ret = get_errno(high2lowuid(geteuid()));
break;
case TARGET_NR_getegid:
ret = get_errno(high2lowgid(getegid()));
break;
case TARGET_NR_setreuid:
ret = get_errno(setreuid(low2highuid(arg1), low2highuid(arg2)));
break;
case TARGET_NR_setregid:
ret = get_errno(setregid(low2highgid(arg1), low2highgid(arg2)));
break;
case TARGET_NR_getgroups:
{
int gidsetsize = arg1;
uint16_t *target_grouplist;
gid_t *grouplist;
int i;
grouplist = alloca(gidsetsize * sizeof(gid_t));
ret = get_errno(getgroups(gidsetsize, grouplist));
if (gidsetsize == 0)
break;
if (!is_error(ret)) {
target_grouplist = lock_user(VERIFY_WRITE, arg2, gidsetsize * 2, 0);
if (!target_grouplist)
goto efault;
for(i = 0;i < ret; i++)
target_grouplist[i] = tswap16(grouplist[i]);
unlock_user(target_grouplist, arg2, gidsetsize * 2);
}
}
break;
case TARGET_NR_setgroups:
{
int gidsetsize = arg1;
uint16_t *target_grouplist;
gid_t *grouplist;
int i;
grouplist = alloca(gidsetsize * sizeof(gid_t));
target_grouplist = lock_user(VERIFY_READ, arg2, gidsetsize * 2, 1);
if (!target_grouplist) {
ret = -TARGET_EFAULT;
goto fail;
}
for(i = 0;i < gidsetsize; i++)
grouplist[i] = tswap16(target_grouplist[i]);
unlock_user(target_grouplist, arg2, 0);
ret = get_errno(setgroups(gidsetsize, grouplist));
}
break;
case TARGET_NR_fchown:
ret = get_errno(fchown(arg1, low2highuid(arg2), low2highgid(arg3)));
break;
#if defined(TARGET_NR_fchownat) && defined(__NR_fchownat)
case TARGET_NR_fchownat:
if (!(p = lock_user_string(arg2)))
goto efault;
ret = get_errno(sys_fchownat(arg1, p, low2highuid(arg3), low2highgid(arg4), arg5));
unlock_user(p, arg2, 0);
break;
#endif
#ifdef TARGET_NR_setresuid
case TARGET_NR_setresuid:
ret = get_errno(setresuid(low2highuid(arg1),
low2highuid(arg2),
low2highuid(arg3)));
break;
#endif
#ifdef TARGET_NR_getresuid
case TARGET_NR_getresuid:
{
uid_t ruid, euid, suid;
ret = get_errno(getresuid(&ruid, &euid, &suid));
if (!is_error(ret)) {
if (put_user_u16(high2lowuid(ruid), arg1)
|| put_user_u16(high2lowuid(euid), arg2)
|| put_user_u16(high2lowuid(suid), arg3))
goto efault;
}
}
break;
#endif
#ifdef TARGET_NR_getresgid
case TARGET_NR_setresgid:
ret = get_errno(setresgid(low2highgid(arg1),
low2highgid(arg2),
low2highgid(arg3)));
break;
#endif
#ifdef TARGET_NR_getresgid
case TARGET_NR_getresgid:
{
gid_t rgid, egid, sgid;
ret = get_errno(getresgid(&rgid, &egid, &sgid));
if (!is_error(ret)) {
if (put_user_u16(high2lowgid(rgid), arg1)
|| put_user_u16(high2lowgid(egid), arg2)
|| put_user_u16(high2lowgid(sgid), arg3))
goto efault;
}
}
break;
#endif
case TARGET_NR_chown:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(chown(p, low2highuid(arg2), low2highgid(arg3)));
unlock_user(p, arg1, 0);
break;
case TARGET_NR_setuid:
ret = get_errno(setuid(low2highuid(arg1)));
break;
case TARGET_NR_setgid:
ret = get_errno(setgid(low2highgid(arg1)));
break;
case TARGET_NR_setfsuid:
ret = get_errno(setfsuid(arg1));
break;
case TARGET_NR_setfsgid:
ret = get_errno(setfsgid(arg1));
break;
#endif
#ifdef TARGET_NR_lchown32
case TARGET_NR_lchown32:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(lchown(p, arg2, arg3));
unlock_user(p, arg1, 0);
break;
#endif
#ifdef TARGET_NR_getuid32
case TARGET_NR_getuid32:
ret = get_errno(getuid());
break;
#endif
#if defined(TARGET_NR_getxuid) && defined(TARGET_ALPHA)
case TARGET_NR_getxuid:
{
uid_t euid;
euid=geteuid();
((CPUAlphaState *)cpu_env)->ir[IR_A4]=euid;
}
ret = get_errno(getuid());
break;
#endif
#if defined(TARGET_NR_getxgid) && defined(TARGET_ALPHA)
case TARGET_NR_getxgid:
{
uid_t egid;
egid=getegid();
((CPUAlphaState *)cpu_env)->ir[IR_A4]=egid;
}
ret = get_errno(getgid());
break;
#endif
#ifdef TARGET_NR_getgid32
case TARGET_NR_getgid32:
ret = get_errno(getgid());
break;
#endif
#ifdef TARGET_NR_geteuid32
case TARGET_NR_geteuid32:
ret = get_errno(geteuid());
break;
#endif
#ifdef TARGET_NR_getegid32
case TARGET_NR_getegid32:
ret = get_errno(getegid());
break;
#endif
#ifdef TARGET_NR_setreuid32
case TARGET_NR_setreuid32:
ret = get_errno(setreuid(arg1, arg2));
break;
#endif
#ifdef TARGET_NR_setregid32
case TARGET_NR_setregid32:
ret = get_errno(setregid(arg1, arg2));
break;
#endif
#ifdef TARGET_NR_getgroups32
case TARGET_NR_getgroups32:
{
int gidsetsize = arg1;
uint32_t *target_grouplist;
gid_t *grouplist;
int i;
grouplist = alloca(gidsetsize * sizeof(gid_t));
ret = get_errno(getgroups(gidsetsize, grouplist));
if (gidsetsize == 0)
break;
if (!is_error(ret)) {
target_grouplist = lock_user(VERIFY_WRITE, arg2, gidsetsize * 4, 0);
if (!target_grouplist) {
ret = -TARGET_EFAULT;
goto fail;
}
for(i = 0;i < ret; i++)
target_grouplist[i] = tswap32(grouplist[i]);
unlock_user(target_grouplist, arg2, gidsetsize * 4);
}
}
break;
#endif
#ifdef TARGET_NR_setgroups32
case TARGET_NR_setgroups32:
{
int gidsetsize = arg1;
uint32_t *target_grouplist;
gid_t *grouplist;
int i;
grouplist = alloca(gidsetsize * sizeof(gid_t));
target_grouplist = lock_user(VERIFY_READ, arg2, gidsetsize * 4, 1);
if (!target_grouplist) {
ret = -TARGET_EFAULT;
goto fail;
}
for(i = 0;i < gidsetsize; i++)
grouplist[i] = tswap32(target_grouplist[i]);
unlock_user(target_grouplist, arg2, 0);
ret = get_errno(setgroups(gidsetsize, grouplist));
}
break;
#endif
#ifdef TARGET_NR_fchown32
case TARGET_NR_fchown32:
ret = get_errno(fchown(arg1, arg2, arg3));
break;
#endif
#ifdef TARGET_NR_setresuid32
case TARGET_NR_setresuid32:
ret = get_errno(setresuid(arg1, arg2, arg3));
break;
#endif
#ifdef TARGET_NR_getresuid32
case TARGET_NR_getresuid32:
{
uid_t ruid, euid, suid;
ret = get_errno(getresuid(&ruid, &euid, &suid));
if (!is_error(ret)) {
if (put_user_u32(ruid, arg1)
|| put_user_u32(euid, arg2)
|| put_user_u32(suid, arg3))
goto efault;
}
}
break;
#endif
#ifdef TARGET_NR_setresgid32
case TARGET_NR_setresgid32:
ret = get_errno(setresgid(arg1, arg2, arg3));
break;
#endif
#ifdef TARGET_NR_getresgid32
case TARGET_NR_getresgid32:
{
gid_t rgid, egid, sgid;
ret = get_errno(getresgid(&rgid, &egid, &sgid));
if (!is_error(ret)) {
if (put_user_u32(rgid, arg1)
|| put_user_u32(egid, arg2)
|| put_user_u32(sgid, arg3))
goto efault;
}
}
break;
#endif
#ifdef TARGET_NR_chown32
case TARGET_NR_chown32:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(chown(p, arg2, arg3));
unlock_user(p, arg1, 0);
break;
#endif
#ifdef TARGET_NR_setuid32
case TARGET_NR_setuid32:
ret = get_errno(setuid(arg1));
break;
#endif
#ifdef TARGET_NR_setgid32
case TARGET_NR_setgid32:
ret = get_errno(setgid(arg1));
break;
#endif
#ifdef TARGET_NR_setfsuid32
case TARGET_NR_setfsuid32:
ret = get_errno(setfsuid(arg1));
break;
#endif
#ifdef TARGET_NR_setfsgid32
case TARGET_NR_setfsgid32:
ret = get_errno(setfsgid(arg1));
break;
#endif
case TARGET_NR_pivot_root:
goto unimplemented;
#ifdef TARGET_NR_mincore
case TARGET_NR_mincore:
{
void *a;
ret = -TARGET_EFAULT;
if (!(a = lock_user(VERIFY_READ, arg1,arg2, 0)))
goto efault;
if (!(p = lock_user_string(arg3)))
goto mincore_fail;
ret = get_errno(mincore(a, arg2, p));
unlock_user(p, arg3, ret);
mincore_fail:
unlock_user(a, arg1, 0);
}
break;
#endif
#ifdef TARGET_NR_arm_fadvise64_64
case TARGET_NR_arm_fadvise64_64:
{
abi_long temp;
temp = arg3;
arg3 = arg4;
arg4 = temp;
}
#endif
#if defined(TARGET_NR_fadvise64_64) || defined(TARGET_NR_arm_fadvise64_64) || defined(TARGET_NR_fadvise64)
#ifdef TARGET_NR_fadvise64_64
case TARGET_NR_fadvise64_64:
#endif
#ifdef TARGET_NR_fadvise64
case TARGET_NR_fadvise64:
#endif
#ifdef TARGET_S390X
switch (arg4) {
case 4: arg4 = POSIX_FADV_NOREUSE + 1; break;
case 5: arg4 = POSIX_FADV_NOREUSE + 2; break;
case 6: arg4 = POSIX_FADV_DONTNEED; break;
case 7: arg4 = POSIX_FADV_NOREUSE; break;
default: break;
}
#endif
ret = -posix_fadvise(arg1, arg2, arg3, arg4);
break;
#endif
#ifdef TARGET_NR_madvise
case TARGET_NR_madvise:
ret = get_errno(0);
break;
#endif
#if TARGET_ABI_BITS == 32
case TARGET_NR_fcntl64:
{
int cmd;
struct flock64 fl;
struct target_flock64 *target_fl;
#ifdef TARGET_ARM
struct target_eabi_flock64 *target_efl;
#endif
cmd = target_to_host_fcntl_cmd(arg2);
if (cmd == -TARGET_EINVAL)
return cmd;
switch(arg2) {
case TARGET_F_GETLK64:
#ifdef TARGET_ARM
if (((CPUARMState *)cpu_env)->eabi) {
if (!lock_user_struct(VERIFY_READ, target_efl, arg3, 1))
goto efault;
fl.l_type = tswap16(target_efl->l_type);
fl.l_whence = tswap16(target_efl->l_whence);
fl.l_start = tswap64(target_efl->l_start);
fl.l_len = tswap64(target_efl->l_len);
fl.l_pid = tswap32(target_efl->l_pid);
unlock_user_struct(target_efl, arg3, 0);
} else
#endif
{
if (!lock_user_struct(VERIFY_READ, target_fl, arg3, 1))
goto efault;
fl.l_type = tswap16(target_fl->l_type);
fl.l_whence = tswap16(target_fl->l_whence);
fl.l_start = tswap64(target_fl->l_start);
fl.l_len = tswap64(target_fl->l_len);
fl.l_pid = tswap32(target_fl->l_pid);
unlock_user_struct(target_fl, arg3, 0);
}
ret = get_errno(fcntl(arg1, cmd, &fl));
if (ret == 0) {
#ifdef TARGET_ARM
if (((CPUARMState *)cpu_env)->eabi) {
if (!lock_user_struct(VERIFY_WRITE, target_efl, arg3, 0))
goto efault;
target_efl->l_type = tswap16(fl.l_type);
target_efl->l_whence = tswap16(fl.l_whence);
target_efl->l_start = tswap64(fl.l_start);
target_efl->l_len = tswap64(fl.l_len);
target_efl->l_pid = tswap32(fl.l_pid);
unlock_user_struct(target_efl, arg3, 1);
} else
#endif
{
if (!lock_user_struct(VERIFY_WRITE, target_fl, arg3, 0))
goto efault;
target_fl->l_type = tswap16(fl.l_type);
target_fl->l_whence = tswap16(fl.l_whence);
target_fl->l_start = tswap64(fl.l_start);
target_fl->l_len = tswap64(fl.l_len);
target_fl->l_pid = tswap32(fl.l_pid);
unlock_user_struct(target_fl, arg3, 1);
}
}
break;
case TARGET_F_SETLK64:
case TARGET_F_SETLKW64:
#ifdef TARGET_ARM
if (((CPUARMState *)cpu_env)->eabi) {
if (!lock_user_struct(VERIFY_READ, target_efl, arg3, 1))
goto efault;
fl.l_type = tswap16(target_efl->l_type);
fl.l_whence = tswap16(target_efl->l_whence);
fl.l_start = tswap64(target_efl->l_start);
fl.l_len = tswap64(target_efl->l_len);
fl.l_pid = tswap32(target_efl->l_pid);
unlock_user_struct(target_efl, arg3, 0);
} else
#endif
{
if (!lock_user_struct(VERIFY_READ, target_fl, arg3, 1))
goto efault;
fl.l_type = tswap16(target_fl->l_type);
fl.l_whence = tswap16(target_fl->l_whence);
fl.l_start = tswap64(target_fl->l_start);
fl.l_len = tswap64(target_fl->l_len);
fl.l_pid = tswap32(target_fl->l_pid);
unlock_user_struct(target_fl, arg3, 0);
}
ret = get_errno(fcntl(arg1, cmd, &fl));
break;
default:
ret = do_fcntl(arg1, arg2, arg3);
break;
}
break;
}
#endif
#ifdef TARGET_NR_cacheflush
case TARGET_NR_cacheflush:
ret = 0;
break;
#endif
#ifdef TARGET_NR_security
case TARGET_NR_security:
goto unimplemented;
#endif
#ifdef TARGET_NR_getpagesize
case TARGET_NR_getpagesize:
ret = TARGET_PAGE_SIZE;
break;
#endif
case TARGET_NR_gettid:
ret = get_errno(gettid());
break;
#ifdef TARGET_NR_readahead
case TARGET_NR_readahead:
#if TARGET_ABI_BITS == 32
#ifdef TARGET_ARM
if (((CPUARMState *)cpu_env)->eabi)
{
arg2 = arg3;
arg3 = arg4;
arg4 = arg5;
}
#endif
ret = get_errno(readahead(arg1, ((off64_t)arg3 << 32) | arg2, arg4));
#else
ret = get_errno(readahead(arg1, arg2, arg3));
#endif
break;
#endif
#ifdef TARGET_NR_setxattr
case TARGET_NR_setxattr:
case TARGET_NR_lsetxattr:
case TARGET_NR_fsetxattr:
case TARGET_NR_getxattr:
case TARGET_NR_lgetxattr:
case TARGET_NR_fgetxattr:
case TARGET_NR_listxattr:
case TARGET_NR_llistxattr:
case TARGET_NR_flistxattr:
case TARGET_NR_removexattr:
case TARGET_NR_lremovexattr:
case TARGET_NR_fremovexattr:
ret = -TARGET_EOPNOTSUPP;
break;
#endif
#ifdef TARGET_NR_set_thread_area
case TARGET_NR_set_thread_area:
#if defined(TARGET_MIPS)
((CPUMIPSState *) cpu_env)->tls_value = arg1;
ret = 0;
break;
#elif defined(TARGET_CRIS)
if (arg1 & 0xff)
ret = -TARGET_EINVAL;
else {
((CPUCRISState *) cpu_env)->pregs[PR_PID] = arg1;
ret = 0;
}
break;
#elif defined(TARGET_I386) && defined(TARGET_ABI32)
ret = do_set_thread_area(cpu_env, arg1);
break;
#else
goto unimplemented_nowarn;
#endif
#endif
#ifdef TARGET_NR_get_thread_area
case TARGET_NR_get_thread_area:
#if defined(TARGET_I386) && defined(TARGET_ABI32)
ret = do_get_thread_area(cpu_env, arg1);
#else
goto unimplemented_nowarn;
#endif
#endif
#ifdef TARGET_NR_getdomainname
case TARGET_NR_getdomainname:
goto unimplemented_nowarn;
#endif
#ifdef TARGET_NR_clock_gettime
case TARGET_NR_clock_gettime:
{
struct timespec ts;
ret = get_errno(clock_gettime(arg1, &ts));
if (!is_error(ret)) {
host_to_target_timespec(arg2, &ts);
}
break;
}
#endif
#ifdef TARGET_NR_clock_getres
case TARGET_NR_clock_getres:
{
struct timespec ts;
ret = get_errno(clock_getres(arg1, &ts));
if (!is_error(ret)) {
host_to_target_timespec(arg2, &ts);
}
break;
}
#endif
#ifdef TARGET_NR_clock_nanosleep
case TARGET_NR_clock_nanosleep:
{
struct timespec ts;
target_to_host_timespec(&ts, arg3);
ret = get_errno(clock_nanosleep(arg1, arg2, &ts, arg4 ? &ts : NULL));
if (arg4)
host_to_target_timespec(arg4, &ts);
break;
}
#endif
#if defined(TARGET_NR_set_tid_address) && defined(__NR_set_tid_address)
case TARGET_NR_set_tid_address:
ret = get_errno(set_tid_address((int *)g2h(arg1)));
break;
#endif
#if defined(TARGET_NR_tkill) && defined(__NR_tkill)
case TARGET_NR_tkill:
ret = get_errno(sys_tkill((int)arg1, target_to_host_signal(arg2)));
break;
#endif
#if defined(TARGET_NR_tgkill) && defined(__NR_tgkill)
case TARGET_NR_tgkill:
ret = get_errno(sys_tgkill((int)arg1, (int)arg2,
target_to_host_signal(arg3)));
break;
#endif
#ifdef TARGET_NR_set_robust_list
case TARGET_NR_set_robust_list:
goto unimplemented_nowarn;
#endif
#if defined(TARGET_NR_utimensat) && defined(__NR_utimensat)
case TARGET_NR_utimensat:
{
struct timespec *tsp, ts[2];
if (!arg3) {
tsp = NULL;
} else {
target_to_host_timespec(ts, arg3);
target_to_host_timespec(ts+1, arg3+sizeof(struct target_timespec));
tsp = ts;
}
if (!arg2)
ret = get_errno(sys_utimensat(arg1, NULL, tsp, arg4));
else {
if (!(p = lock_user_string(arg2))) {
ret = -TARGET_EFAULT;
goto fail;
}
ret = get_errno(sys_utimensat(arg1, path(p), tsp, arg4));
unlock_user(p, arg2, 0);
}
}
break;
#endif
#if defined(CONFIG_USE_NPTL)
case TARGET_NR_futex:
ret = do_futex(arg1, arg2, arg3, arg4, arg5, arg6);
break;
#endif
#if defined(TARGET_NR_inotify_init) && defined(__NR_inotify_init)
case TARGET_NR_inotify_init:
ret = get_errno(sys_inotify_init());
break;
#endif
#if defined(TARGET_NR_inotify_add_watch) && defined(__NR_inotify_add_watch)
case TARGET_NR_inotify_add_watch:
p = lock_user_string(arg2);
ret = get_errno(sys_inotify_add_watch(arg1, path(p), arg3));
unlock_user(p, arg2, 0);
break;
#endif
#if defined(TARGET_NR_inotify_rm_watch) && defined(__NR_inotify_rm_watch)
case TARGET_NR_inotify_rm_watch:
ret = get_errno(sys_inotify_rm_watch(arg1, arg2));
break;
#endif
#if defined(TARGET_NR_mq_open) && defined(__NR_mq_open)
case TARGET_NR_mq_open:
{
struct mq_attr posix_mq_attr;
p = lock_user_string(arg1 - 1);
if (arg4 != 0)
copy_from_user_mq_attr (&posix_mq_attr, arg4);
ret = get_errno(mq_open(p, arg2, arg3, &posix_mq_attr));
unlock_user (p, arg1, 0);
}
break;
case TARGET_NR_mq_unlink:
p = lock_user_string(arg1 - 1);
ret = get_errno(mq_unlink(p));
unlock_user (p, arg1, 0);
break;
case TARGET_NR_mq_timedsend:
{
struct timespec ts;
p = lock_user (VERIFY_READ, arg2, arg3, 1);
if (arg5 != 0) {
target_to_host_timespec(&ts, arg5);
ret = get_errno(mq_timedsend(arg1, p, arg3, arg4, &ts));
host_to_target_timespec(arg5, &ts);
}
else
ret = get_errno(mq_send(arg1, p, arg3, arg4));
unlock_user (p, arg2, arg3);
}
break;
case TARGET_NR_mq_timedreceive:
{
struct timespec ts;
unsigned int prio;
p = lock_user (VERIFY_READ, arg2, arg3, 1);
if (arg5 != 0) {
target_to_host_timespec(&ts, arg5);
ret = get_errno(mq_timedreceive(arg1, p, arg3, &prio, &ts));
host_to_target_timespec(arg5, &ts);
}
else
ret = get_errno(mq_receive(arg1, p, arg3, &prio));
unlock_user (p, arg2, arg3);
if (arg4 != 0)
put_user_u32(prio, arg4);
}
break;
case TARGET_NR_mq_getsetattr:
{
struct mq_attr posix_mq_attr_in, posix_mq_attr_out;
ret = 0;
if (arg3 != 0) {
ret = mq_getattr(arg1, &posix_mq_attr_out);
copy_to_user_mq_attr(arg3, &posix_mq_attr_out);
}
if (arg2 != 0) {
copy_from_user_mq_attr(&posix_mq_attr_in, arg2);
ret |= mq_setattr(arg1, &posix_mq_attr_in, &posix_mq_attr_out);
}
}
break;
#endif
#ifdef CONFIG_SPLICE
#ifdef TARGET_NR_tee
case TARGET_NR_tee:
{
ret = get_errno(tee(arg1,arg2,arg3,arg4));
}
break;
#endif
#ifdef TARGET_NR_splice
case TARGET_NR_splice:
{
loff_t loff_in, loff_out;
loff_t *ploff_in = NULL, *ploff_out = NULL;
if(arg2) {
get_user_u64(loff_in, arg2);
ploff_in = &loff_in;
}
if(arg4) {
get_user_u64(loff_out, arg2);
ploff_out = &loff_out;
}
ret = get_errno(splice(arg1, ploff_in, arg3, ploff_out, arg5, arg6));
}
break;
#endif
#ifdef TARGET_NR_vmsplice
case TARGET_NR_vmsplice:
{
int count = arg3;
struct iovec *vec;
vec = alloca(count * sizeof(struct iovec));
if (lock_iovec(VERIFY_READ, vec, arg2, count, 1) < 0)
goto efault;
ret = get_errno(vmsplice(arg1, vec, count, arg4));
unlock_iovec(vec, arg2, count, 0);
}
break;
#endif
#endif
#ifdef CONFIG_EVENTFD
#if defined(TARGET_NR_eventfd)
case TARGET_NR_eventfd:
ret = get_errno(eventfd(arg1, 0));
break;
#endif
#if defined(TARGET_NR_eventfd2)
case TARGET_NR_eventfd2:
ret = get_errno(eventfd(arg1, arg2));
break;
#endif
#endif
default:
unimplemented:
gemu_log("qemu: Unsupported syscall: %d\n", num);
#if defined(TARGET_NR_setxattr) || defined(TARGET_NR_get_thread_area) || defined(TARGET_NR_getdomainname) || defined(TARGET_NR_set_robust_list)
unimplemented_nowarn:
#endif
ret = -TARGET_ENOSYS;
break;
}
fail:
#ifdef DEBUG
gemu_log(" = " TARGET_ABI_FMT_ld "\n", ret);
#endif
if(do_strace)
print_syscall_ret(num, ret);
return ret;
efault:
ret = -TARGET_EFAULT;
goto fail;
} | {
"code": [],
"line_no": []
} | abi_long FUNC_0(void *cpu_env, int num, abi_long arg1,
abi_long arg2, abi_long arg3, abi_long arg4,
abi_long arg5, abi_long arg6)
{
abi_long ret;
struct stat VAR_0;
struct statfs VAR_1;
void *VAR_2;
#ifdef DEBUG
gemu_log("syscall %d", num);
#endif
if(do_strace)
print_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6);
switch(num) {
case TARGET_NR_exit:
#ifdef CONFIG_USE_NPTL
if (first_cpu->next_cpu) {
TaskState *VAR_42;
CPUState **lastp;
CPUState *VAR_2;
cpu_list_lock();
lastp = &first_cpu;
VAR_2 = first_cpu;
while (VAR_2 && VAR_2 != (CPUState *)cpu_env) {
lastp = &VAR_2->next_cpu;
VAR_2 = VAR_2->next_cpu;
}
if (!VAR_2)
abort();
*lastp = VAR_2->next_cpu;
cpu_list_unlock();
VAR_42 = ((CPUState *)cpu_env)->opaque;
if (VAR_42->child_tidptr) {
put_user_u32(0, VAR_42->child_tidptr);
sys_futex(g2h(VAR_42->child_tidptr), FUTEX_WAKE, INT_MAX,
NULL, NULL, 0);
}
pthread_exit(NULL);
}
#endif
#ifdef TARGET_GPROF
_mcleanup();
#endif
gdb_exit(cpu_env, arg1);
_exit(arg1);
ret = 0;
break;
case TARGET_NR_read:
if (arg3 == 0)
ret = 0;
else {
if (!(VAR_2 = lock_user(VERIFY_WRITE, arg2, arg3, 0)))
goto efault;
ret = get_errno(read(arg1, VAR_2, arg3));
unlock_user(VAR_2, arg2, ret);
}
break;
case TARGET_NR_write:
if (!(VAR_2 = lock_user(VERIFY_READ, arg2, arg3, 1)))
goto efault;
ret = get_errno(write(arg1, VAR_2, arg3));
unlock_user(VAR_2, arg2, 0);
break;
case TARGET_NR_open:
if (!(VAR_2 = lock_user_string(arg1)))
goto efault;
ret = get_errno(open(path(VAR_2),
target_to_host_bitmask(arg2, fcntl_flags_tbl),
arg3));
unlock_user(VAR_2, arg1, 0);
break;
#if defined(TARGET_NR_openat) && defined(__NR_openat)
case TARGET_NR_openat:
if (!(VAR_2 = lock_user_string(arg2)))
goto efault;
ret = get_errno(sys_openat(arg1,
path(VAR_2),
target_to_host_bitmask(arg3, fcntl_flags_tbl),
arg4));
unlock_user(VAR_2, arg2, 0);
break;
#endif
case TARGET_NR_close:
ret = get_errno(close(arg1));
break;
case TARGET_NR_brk:
ret = do_brk(arg1);
break;
case TARGET_NR_fork:
ret = get_errno(do_fork(cpu_env, SIGCHLD, 0, 0, 0, 0));
break;
#ifdef TARGET_NR_waitpid
case TARGET_NR_waitpid:
{
int VAR_30;
ret = get_errno(waitpid(arg1, &VAR_30, arg3));
if (!is_error(ret) && arg2
&& put_user_s32(host_to_target_waitstatus(VAR_30), arg2))
goto efault;
}
break;
#endif
#ifdef TARGET_NR_waitid
case TARGET_NR_waitid:
{
siginfo_t info;
info.si_pid = 0;
ret = get_errno(waitid(arg1, arg2, &info, arg4));
if (!is_error(ret) && arg3 && info.si_pid != 0) {
if (!(VAR_2 = lock_user(VERIFY_WRITE, arg3, sizeof(target_siginfo_t), 0)))
goto efault;
host_to_target_siginfo(VAR_2, &info);
unlock_user(VAR_2, arg3, sizeof(target_siginfo_t));
}
}
break;
#endif
#ifdef TARGET_NR_creat
case TARGET_NR_creat:
if (!(VAR_2 = lock_user_string(arg1)))
goto efault;
ret = get_errno(creat(VAR_2, arg2));
unlock_user(VAR_2, arg1, 0);
break;
#endif
case TARGET_NR_link:
{
void * VAR_23;
VAR_2 = lock_user_string(arg1);
VAR_23 = lock_user_string(arg2);
if (!VAR_2 || !VAR_23)
ret = -TARGET_EFAULT;
else
ret = get_errno(link(VAR_2, VAR_23));
unlock_user(VAR_23, arg2, 0);
unlock_user(VAR_2, arg1, 0);
}
break;
#if defined(TARGET_NR_linkat) && defined(__NR_linkat)
case TARGET_NR_linkat:
{
void * VAR_23 = NULL;
if (!arg2 || !arg4)
goto efault;
VAR_2 = lock_user_string(arg2);
VAR_23 = lock_user_string(arg4);
if (!VAR_2 || !VAR_23)
ret = -TARGET_EFAULT;
else
ret = get_errno(sys_linkat(arg1, VAR_2, arg3, VAR_23, arg5));
unlock_user(VAR_2, arg2, 0);
unlock_user(VAR_23, arg4, 0);
}
break;
#endif
case TARGET_NR_unlink:
if (!(VAR_2 = lock_user_string(arg1)))
goto efault;
ret = get_errno(unlink(VAR_2));
unlock_user(VAR_2, arg1, 0);
break;
#if defined(TARGET_NR_unlinkat) && defined(__NR_unlinkat)
case TARGET_NR_unlinkat:
if (!(VAR_2 = lock_user_string(arg2)))
goto efault;
ret = get_errno(sys_unlinkat(arg1, VAR_2, arg3));
unlock_user(VAR_2, arg2, 0);
break;
#endif
case TARGET_NR_execve:
{
char **VAR_4, **VAR_5;
int VAR_6, VAR_7;
abi_ulong gp;
abi_ulong guest_argp;
abi_ulong guest_envp;
abi_ulong addr;
char **VAR_8;
VAR_6 = 0;
guest_argp = arg2;
for (gp = guest_argp; gp; gp += sizeof(abi_ulong)) {
if (get_user_ual(addr, gp))
goto efault;
if (!addr)
break;
VAR_6++;
}
VAR_7 = 0;
guest_envp = arg3;
for (gp = guest_envp; gp; gp += sizeof(abi_ulong)) {
if (get_user_ual(addr, gp))
goto efault;
if (!addr)
break;
VAR_7++;
}
VAR_4 = alloca((VAR_6 + 1) * sizeof(void *));
VAR_5 = alloca((VAR_7 + 1) * sizeof(void *));
for (gp = guest_argp, VAR_8 = VAR_4; gp;
gp += sizeof(abi_ulong), VAR_8++) {
if (get_user_ual(addr, gp))
goto execve_efault;
if (!addr)
break;
if (!(*VAR_8 = lock_user_string(addr)))
goto execve_efault;
}
*VAR_8 = NULL;
for (gp = guest_envp, VAR_8 = VAR_5; gp;
gp += sizeof(abi_ulong), VAR_8++) {
if (get_user_ual(addr, gp))
goto execve_efault;
if (!addr)
break;
if (!(*VAR_8 = lock_user_string(addr)))
goto execve_efault;
}
*VAR_8 = NULL;
if (!(VAR_2 = lock_user_string(arg1)))
goto execve_efault;
ret = get_errno(execve(VAR_2, VAR_4, VAR_5));
unlock_user(VAR_2, arg1, 0);
goto execve_end;
execve_efault:
ret = -TARGET_EFAULT;
execve_end:
for (gp = guest_argp, VAR_8 = VAR_4; *VAR_8;
gp += sizeof(abi_ulong), VAR_8++) {
if (get_user_ual(addr, gp)
|| !addr)
break;
unlock_user(*VAR_8, addr, 0);
}
for (gp = guest_envp, VAR_8 = VAR_5; *VAR_8;
gp += sizeof(abi_ulong), VAR_8++) {
if (get_user_ual(addr, gp)
|| !addr)
break;
unlock_user(*VAR_8, addr, 0);
}
}
break;
case TARGET_NR_chdir:
if (!(VAR_2 = lock_user_string(arg1)))
goto efault;
ret = get_errno(chdir(VAR_2));
unlock_user(VAR_2, arg1, 0);
break;
#ifdef TARGET_NR_time
case TARGET_NR_time:
{
time_t host_time;
ret = get_errno(time(&host_time));
if (!is_error(ret)
&& arg1
&& put_user_sal(host_time, arg1))
goto efault;
}
break;
#endif
case TARGET_NR_mknod:
if (!(VAR_2 = lock_user_string(arg1)))
goto efault;
ret = get_errno(mknod(VAR_2, arg2, arg3));
unlock_user(VAR_2, arg1, 0);
break;
#if defined(TARGET_NR_mknodat) && defined(__NR_mknodat)
case TARGET_NR_mknodat:
if (!(VAR_2 = lock_user_string(arg2)))
goto efault;
ret = get_errno(sys_mknodat(arg1, VAR_2, arg3, arg4));
unlock_user(VAR_2, arg2, 0);
break;
#endif
case TARGET_NR_chmod:
if (!(VAR_2 = lock_user_string(arg1)))
goto efault;
ret = get_errno(chmod(VAR_2, arg2));
unlock_user(VAR_2, arg1, 0);
break;
#ifdef TARGET_NR_break
case TARGET_NR_break:
goto unimplemented;
#endif
#ifdef TARGET_NR_oldstat
case TARGET_NR_oldstat:
goto unimplemented;
#endif
case TARGET_NR_lseek:
ret = get_errno(lseek(arg1, arg2, arg3));
break;
#ifdef TARGET_NR_getxpid
case TARGET_NR_getxpid:
#else
case TARGET_NR_getpid:
#endif
ret = get_errno(getpid());
break;
case TARGET_NR_mount:
{
void *VAR_23, *VAR_9;
VAR_2 = lock_user_string(arg1);
VAR_23 = lock_user_string(arg2);
VAR_9 = lock_user_string(arg3);
if (!VAR_2 || !VAR_23 || !VAR_9)
ret = -TARGET_EFAULT;
else
ret = get_errno(mount(VAR_2, VAR_23, VAR_9, (unsigned long)arg4, g2h(arg5)));
unlock_user(VAR_2, arg1, 0);
unlock_user(VAR_23, arg2, 0);
unlock_user(VAR_9, arg3, 0);
break;
}
#ifdef TARGET_NR_umount
case TARGET_NR_umount:
if (!(VAR_2 = lock_user_string(arg1)))
goto efault;
ret = get_errno(umount(VAR_2));
unlock_user(VAR_2, arg1, 0);
break;
#endif
#ifdef TARGET_NR_stime
case TARGET_NR_stime:
{
time_t host_time;
if (get_user_sal(host_time, arg1))
goto efault;
ret = get_errno(stime(&host_time));
}
break;
#endif
case TARGET_NR_ptrace:
goto unimplemented;
#ifdef TARGET_NR_alarm
case TARGET_NR_alarm:
ret = alarm(arg1);
break;
#endif
#ifdef TARGET_NR_oldfstat
case TARGET_NR_oldfstat:
goto unimplemented;
#endif
#ifdef TARGET_NR_pause
case TARGET_NR_pause:
ret = get_errno(pause());
break;
#endif
#ifdef TARGET_NR_utime
case TARGET_NR_utime:
{
struct utimbuf tbuf, *host_tbuf;
struct target_utimbuf *target_tbuf;
if (arg2) {
if (!lock_user_struct(VERIFY_READ, target_tbuf, arg2, 1))
goto efault;
tbuf.actime = tswapl(target_tbuf->actime);
tbuf.modtime = tswapl(target_tbuf->modtime);
unlock_user_struct(target_tbuf, arg2, 0);
host_tbuf = &tbuf;
} else {
host_tbuf = NULL;
}
if (!(VAR_2 = lock_user_string(arg1)))
goto efault;
ret = get_errno(utime(VAR_2, host_tbuf));
unlock_user(VAR_2, arg1, 0);
}
break;
#endif
case TARGET_NR_utimes:
{
struct timeval *VAR_10, VAR_23[2];
if (arg2) {
if (copy_from_user_timeval(&VAR_23[0], arg2)
|| copy_from_user_timeval(&VAR_23[1],
arg2 + sizeof(struct target_timeval)))
goto efault;
VAR_10 = VAR_23;
} else {
VAR_10 = NULL;
}
if (!(VAR_2 = lock_user_string(arg1)))
goto efault;
ret = get_errno(utimes(VAR_2, VAR_10));
unlock_user(VAR_2, arg1, 0);
}
break;
#if defined(TARGET_NR_futimesat) && defined(__NR_futimesat)
case TARGET_NR_futimesat:
{
struct timeval *VAR_10, VAR_23[2];
if (arg3) {
if (copy_from_user_timeval(&VAR_23[0], arg3)
|| copy_from_user_timeval(&VAR_23[1],
arg3 + sizeof(struct target_timeval)))
goto efault;
VAR_10 = VAR_23;
} else {
VAR_10 = NULL;
}
if (!(VAR_2 = lock_user_string(arg2)))
goto efault;
ret = get_errno(sys_futimesat(arg1, path(VAR_2), VAR_10));
unlock_user(VAR_2, arg2, 0);
}
break;
#endif
#ifdef TARGET_NR_stty
case TARGET_NR_stty:
goto unimplemented;
#endif
#ifdef TARGET_NR_gtty
case TARGET_NR_gtty:
goto unimplemented;
#endif
case TARGET_NR_access:
if (!(VAR_2 = lock_user_string(arg1)))
goto efault;
ret = get_errno(access(path(VAR_2), arg2));
unlock_user(VAR_2, arg1, 0);
break;
#if defined(TARGET_NR_faccessat) && defined(__NR_faccessat)
case TARGET_NR_faccessat:
if (!(VAR_2 = lock_user_string(arg2)))
goto efault;
ret = get_errno(sys_faccessat(arg1, VAR_2, arg3));
unlock_user(VAR_2, arg2, 0);
break;
#endif
#ifdef TARGET_NR_nice
case TARGET_NR_nice:
ret = get_errno(nice(arg1));
break;
#endif
#ifdef TARGET_NR_ftime
case TARGET_NR_ftime:
goto unimplemented;
#endif
case TARGET_NR_sync:
sync();
ret = 0;
break;
case TARGET_NR_kill:
ret = get_errno(kill(arg1, target_to_host_signal(arg2)));
break;
case TARGET_NR_rename:
{
void *VAR_23;
VAR_2 = lock_user_string(arg1);
VAR_23 = lock_user_string(arg2);
if (!VAR_2 || !VAR_23)
ret = -TARGET_EFAULT;
else
ret = get_errno(rename(VAR_2, VAR_23));
unlock_user(VAR_23, arg2, 0);
unlock_user(VAR_2, arg1, 0);
}
break;
#if defined(TARGET_NR_renameat) && defined(__NR_renameat)
case TARGET_NR_renameat:
{
void *VAR_23;
VAR_2 = lock_user_string(arg2);
VAR_23 = lock_user_string(arg4);
if (!VAR_2 || !VAR_23)
ret = -TARGET_EFAULT;
else
ret = get_errno(sys_renameat(arg1, VAR_2, arg3, VAR_23));
unlock_user(VAR_23, arg4, 0);
unlock_user(VAR_2, arg2, 0);
}
break;
#endif
case TARGET_NR_mkdir:
if (!(VAR_2 = lock_user_string(arg1)))
goto efault;
ret = get_errno(mkdir(VAR_2, arg2));
unlock_user(VAR_2, arg1, 0);
break;
#if defined(TARGET_NR_mkdirat) && defined(__NR_mkdirat)
case TARGET_NR_mkdirat:
if (!(VAR_2 = lock_user_string(arg2)))
goto efault;
ret = get_errno(sys_mkdirat(arg1, VAR_2, arg3));
unlock_user(VAR_2, arg2, 0);
break;
#endif
case TARGET_NR_rmdir:
if (!(VAR_2 = lock_user_string(arg1)))
goto efault;
ret = get_errno(rmdir(VAR_2));
unlock_user(VAR_2, arg1, 0);
break;
case TARGET_NR_dup:
ret = get_errno(dup(arg1));
break;
case TARGET_NR_pipe:
ret = do_pipe(cpu_env, arg1, 0);
break;
#ifdef TARGET_NR_pipe2
case TARGET_NR_pipe2:
ret = do_pipe(cpu_env, arg1, arg2);
break;
#endif
case TARGET_NR_times:
{
struct target_tms *VAR_12;
struct VAR_13 VAR_13;
ret = get_errno(times(&VAR_13));
if (arg1) {
VAR_12 = lock_user(VERIFY_WRITE, arg1, sizeof(struct target_tms), 0);
if (!VAR_12)
goto efault;
VAR_12->tms_utime = tswapl(host_to_target_clock_t(VAR_13.tms_utime));
VAR_12->tms_stime = tswapl(host_to_target_clock_t(VAR_13.tms_stime));
VAR_12->tms_cutime = tswapl(host_to_target_clock_t(VAR_13.tms_cutime));
VAR_12->tms_cstime = tswapl(host_to_target_clock_t(VAR_13.tms_cstime));
}
if (!is_error(ret))
ret = host_to_target_clock_t(ret);
}
break;
#ifdef TARGET_NR_prof
case TARGET_NR_prof:
goto unimplemented;
#endif
#ifdef TARGET_NR_signal
case TARGET_NR_signal:
goto unimplemented;
#endif
case TARGET_NR_acct:
if (arg1 == 0) {
ret = get_errno(acct(NULL));
} else {
if (!(VAR_2 = lock_user_string(arg1)))
goto efault;
ret = get_errno(acct(path(VAR_2)));
unlock_user(VAR_2, arg1, 0);
}
break;
#ifdef TARGET_NR_umount2
case TARGET_NR_umount2:
if (!(VAR_2 = lock_user_string(arg1)))
goto efault;
ret = get_errno(umount2(VAR_2, arg2));
unlock_user(VAR_2, arg1, 0);
break;
#endif
#ifdef TARGET_NR_lock
case TARGET_NR_lock:
goto unimplemented;
#endif
case TARGET_NR_ioctl:
ret = do_ioctl(arg1, arg2, arg3);
break;
case TARGET_NR_fcntl:
ret = do_fcntl(arg1, arg2, arg3);
break;
#ifdef TARGET_NR_mpx
case TARGET_NR_mpx:
goto unimplemented;
#endif
case TARGET_NR_setpgid:
ret = get_errno(setpgid(arg1, arg2));
break;
#ifdef TARGET_NR_ulimit
case TARGET_NR_ulimit:
goto unimplemented;
#endif
#ifdef TARGET_NR_oldolduname
case TARGET_NR_oldolduname:
goto unimplemented;
#endif
case TARGET_NR_umask:
ret = get_errno(umask(arg1));
break;
case TARGET_NR_chroot:
if (!(VAR_2 = lock_user_string(arg1)))
goto efault;
ret = get_errno(chroot(VAR_2));
unlock_user(VAR_2, arg1, 0);
break;
case TARGET_NR_ustat:
goto unimplemented;
case TARGET_NR_dup2:
ret = get_errno(dup2(arg1, arg2));
break;
#ifdef TARGET_NR_getppid
case TARGET_NR_getppid:
ret = get_errno(getppid());
break;
#endif
case TARGET_NR_getpgrp:
ret = get_errno(getpgrp());
break;
case TARGET_NR_setsid:
ret = get_errno(setsid());
break;
#ifdef TARGET_NR_sigaction
case TARGET_NR_sigaction:
{
#if !defined(TARGET_MIPS)
struct target_old_sigaction *old_act;
struct target_sigaction VAR_14, VAR_15, *pact;
if (arg2) {
if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1))
goto efault;
VAR_14._sa_handler = old_act->_sa_handler;
target_siginitset(&VAR_14.sa_mask, old_act->sa_mask);
VAR_14.sa_flags = old_act->sa_flags;
VAR_14.sa_restorer = old_act->sa_restorer;
unlock_user_struct(old_act, arg2, 0);
pact = &VAR_14;
} else {
pact = NULL;
}
ret = get_errno(do_sigaction(arg1, pact, &VAR_15));
if (!is_error(ret) && arg3) {
if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0))
goto efault;
old_act->_sa_handler = VAR_15._sa_handler;
old_act->sa_mask = VAR_15.sa_mask.sig[0];
old_act->sa_flags = VAR_15.sa_flags;
old_act->sa_restorer = VAR_15.sa_restorer;
unlock_user_struct(old_act, arg3, 1);
}
#else
struct target_sigaction VAR_14, VAR_15, *pact, *old_act;
if (arg2) {
if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1))
goto efault;
VAR_14._sa_handler = old_act->_sa_handler;
target_siginitset(&VAR_14.sa_mask, old_act->sa_mask.sig[0]);
VAR_14.sa_flags = old_act->sa_flags;
unlock_user_struct(old_act, arg2, 0);
pact = &VAR_14;
} else {
pact = NULL;
}
ret = get_errno(do_sigaction(arg1, pact, &VAR_15));
if (!is_error(ret) && arg3) {
if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0))
goto efault;
old_act->_sa_handler = VAR_15._sa_handler;
old_act->sa_flags = VAR_15.sa_flags;
old_act->sa_mask.sig[0] = VAR_15.sa_mask.sig[0];
old_act->sa_mask.sig[1] = 0;
old_act->sa_mask.sig[2] = 0;
old_act->sa_mask.sig[3] = 0;
unlock_user_struct(old_act, arg3, 1);
}
#endif
}
break;
#endif
case TARGET_NR_rt_sigaction:
{
struct target_sigaction *VAR_14;
struct target_sigaction *VAR_15;
if (arg2) {
if (!lock_user_struct(VERIFY_READ, VAR_14, arg2, 1))
goto efault;
} else
VAR_14 = NULL;
if (arg3) {
if (!lock_user_struct(VERIFY_WRITE, VAR_15, arg3, 0)) {
ret = -TARGET_EFAULT;
goto rt_sigaction_fail;
}
} else
VAR_15 = NULL;
ret = get_errno(do_sigaction(arg1, VAR_14, VAR_15));
rt_sigaction_fail:
if (VAR_14)
unlock_user_struct(VAR_14, arg2, 0);
if (VAR_15)
unlock_user_struct(VAR_15, arg3, 1);
}
break;
#ifdef TARGET_NR_sgetmask
case TARGET_NR_sgetmask:
{
sigset_t cur_set;
abi_ulong target_set;
sigprocmask(0, NULL, &cur_set);
host_to_target_old_sigset(&target_set, &cur_set);
ret = target_set;
}
break;
#endif
#ifdef TARGET_NR_ssetmask
case TARGET_NR_ssetmask:
{
sigset_t set, oset, cur_set;
abi_ulong target_set = arg1;
sigprocmask(0, NULL, &cur_set);
target_to_host_old_sigset(&set, &target_set);
sigorset(&set, &set, &cur_set);
sigprocmask(SIG_SETMASK, &set, &oset);
host_to_target_old_sigset(&target_set, &oset);
ret = target_set;
}
break;
#endif
#ifdef TARGET_NR_sigprocmask
case TARGET_NR_sigprocmask:
{
int VAR_16 = arg1;
sigset_t set, oldset, *set_ptr;
if (arg2) {
switch(VAR_16) {
case TARGET_SIG_BLOCK:
VAR_16 = SIG_BLOCK;
break;
case TARGET_SIG_UNBLOCK:
VAR_16 = SIG_UNBLOCK;
break;
case TARGET_SIG_SETMASK:
VAR_16 = SIG_SETMASK;
break;
default:
ret = -TARGET_EINVAL;
goto fail;
}
if (!(VAR_2 = lock_user(VERIFY_READ, arg2, sizeof(target_sigset_t), 1)))
goto efault;
target_to_host_old_sigset(&set, VAR_2);
unlock_user(VAR_2, arg2, 0);
set_ptr = &set;
} else {
VAR_16 = 0;
set_ptr = NULL;
}
ret = get_errno(sigprocmask(arg1, set_ptr, &oldset));
if (!is_error(ret) && arg3) {
if (!(VAR_2 = lock_user(VERIFY_WRITE, arg3, sizeof(target_sigset_t), 0)))
goto efault;
host_to_target_old_sigset(VAR_2, &oldset);
unlock_user(VAR_2, arg3, sizeof(target_sigset_t));
}
}
break;
#endif
case TARGET_NR_rt_sigprocmask:
{
int VAR_16 = arg1;
sigset_t set, oldset, *set_ptr;
if (arg2) {
switch(VAR_16) {
case TARGET_SIG_BLOCK:
VAR_16 = SIG_BLOCK;
break;
case TARGET_SIG_UNBLOCK:
VAR_16 = SIG_UNBLOCK;
break;
case TARGET_SIG_SETMASK:
VAR_16 = SIG_SETMASK;
break;
default:
ret = -TARGET_EINVAL;
goto fail;
}
if (!(VAR_2 = lock_user(VERIFY_READ, arg2, sizeof(target_sigset_t), 1)))
goto efault;
target_to_host_sigset(&set, VAR_2);
unlock_user(VAR_2, arg2, 0);
set_ptr = &set;
} else {
VAR_16 = 0;
set_ptr = NULL;
}
ret = get_errno(sigprocmask(VAR_16, set_ptr, &oldset));
if (!is_error(ret) && arg3) {
if (!(VAR_2 = lock_user(VERIFY_WRITE, arg3, sizeof(target_sigset_t), 0)))
goto efault;
host_to_target_sigset(VAR_2, &oldset);
unlock_user(VAR_2, arg3, sizeof(target_sigset_t));
}
}
break;
#ifdef TARGET_NR_sigpending
case TARGET_NR_sigpending:
{
sigset_t set;
ret = get_errno(sigpending(&set));
if (!is_error(ret)) {
if (!(VAR_2 = lock_user(VERIFY_WRITE, arg1, sizeof(target_sigset_t), 0)))
goto efault;
host_to_target_old_sigset(VAR_2, &set);
unlock_user(VAR_2, arg1, sizeof(target_sigset_t));
}
}
break;
#endif
case TARGET_NR_rt_sigpending:
{
sigset_t set;
ret = get_errno(sigpending(&set));
if (!is_error(ret)) {
if (!(VAR_2 = lock_user(VERIFY_WRITE, arg1, sizeof(target_sigset_t), 0)))
goto efault;
host_to_target_sigset(VAR_2, &set);
unlock_user(VAR_2, arg1, sizeof(target_sigset_t));
}
}
break;
#ifdef TARGET_NR_sigsuspend
case TARGET_NR_sigsuspend:
{
sigset_t set;
if (!(VAR_2 = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1)))
goto efault;
target_to_host_old_sigset(&set, VAR_2);
unlock_user(VAR_2, arg1, 0);
ret = get_errno(sigsuspend(&set));
}
break;
#endif
case TARGET_NR_rt_sigsuspend:
{
sigset_t set;
if (!(VAR_2 = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1)))
goto efault;
target_to_host_sigset(&set, VAR_2);
unlock_user(VAR_2, arg1, 0);
ret = get_errno(sigsuspend(&set));
}
break;
case TARGET_NR_rt_sigtimedwait:
{
sigset_t set;
struct timespec VAR_17, *VAR_18;
siginfo_t uinfo;
if (!(VAR_2 = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1)))
goto efault;
target_to_host_sigset(&set, VAR_2);
unlock_user(VAR_2, arg1, 0);
if (arg3) {
VAR_18 = &VAR_17;
target_to_host_timespec(VAR_18, arg3);
} else {
VAR_18 = NULL;
}
ret = get_errno(sigtimedwait(&set, &uinfo, VAR_18));
if (!is_error(ret) && arg2) {
if (!(VAR_2 = lock_user(VERIFY_WRITE, arg2, sizeof(target_siginfo_t), 0)))
goto efault;
host_to_target_siginfo(VAR_2, &uinfo);
unlock_user(VAR_2, arg2, sizeof(target_siginfo_t));
}
}
break;
case TARGET_NR_rt_sigqueueinfo:
{
siginfo_t uinfo;
if (!(VAR_2 = lock_user(VERIFY_READ, arg3, sizeof(target_sigset_t), 1)))
goto efault;
target_to_host_siginfo(&uinfo, VAR_2);
unlock_user(VAR_2, arg1, 0);
ret = get_errno(sys_rt_sigqueueinfo(arg1, arg2, &uinfo));
}
break;
#ifdef TARGET_NR_sigreturn
case TARGET_NR_sigreturn:
ret = do_sigreturn(cpu_env);
break;
#endif
case TARGET_NR_rt_sigreturn:
ret = do_rt_sigreturn(cpu_env);
break;
case TARGET_NR_sethostname:
if (!(VAR_2 = lock_user_string(arg1)))
goto efault;
ret = get_errno(sethostname(VAR_2, arg2));
unlock_user(VAR_2, arg1, 0);
break;
case TARGET_NR_setrlimit:
{
int VAR_22 = arg1;
struct target_rlimit *VAR_22;
struct rlimit VAR_22;
if (!lock_user_struct(VERIFY_READ, VAR_22, arg2, 1))
goto efault;
VAR_22.rlim_cur = tswapl(VAR_22->rlim_cur);
VAR_22.rlim_max = tswapl(VAR_22->rlim_max);
unlock_user_struct(VAR_22, arg2, 0);
ret = get_errno(setrlimit(VAR_22, &VAR_22));
}
break;
case TARGET_NR_getrlimit:
{
int VAR_22 = arg1;
struct target_rlimit *VAR_22;
struct rlimit VAR_22;
ret = get_errno(getrlimit(VAR_22, &VAR_22));
if (!is_error(ret)) {
if (!lock_user_struct(VERIFY_WRITE, VAR_22, arg2, 0))
goto efault;
VAR_22->rlim_cur = tswapl(VAR_22.rlim_cur);
VAR_22->rlim_max = tswapl(VAR_22.rlim_max);
unlock_user_struct(VAR_22, arg2, 1);
}
}
break;
case TARGET_NR_getrusage:
{
struct VAR_31 VAR_31;
ret = get_errno(getrusage(arg1, &VAR_31));
if (!is_error(ret)) {
host_to_target_rusage(arg2, &VAR_31);
}
}
break;
case TARGET_NR_gettimeofday:
{
struct timeval VAR_23;
ret = get_errno(gettimeofday(&VAR_23, NULL));
if (!is_error(ret)) {
if (copy_to_user_timeval(arg1, &VAR_23))
goto efault;
}
}
break;
case TARGET_NR_settimeofday:
{
struct timeval VAR_23;
if (copy_from_user_timeval(&VAR_23, arg1))
goto efault;
ret = get_errno(settimeofday(&VAR_23, NULL));
}
break;
#ifdef TARGET_NR_select
case TARGET_NR_select:
{
struct target_sel_arg_struct *sel;
abi_ulong inp, outp, exp, VAR_10;
long nsel;
if (!lock_user_struct(VERIFY_READ, sel, arg1, 1))
goto efault;
nsel = tswapl(sel->n);
inp = tswapl(sel->inp);
outp = tswapl(sel->outp);
exp = tswapl(sel->exp);
VAR_10 = tswapl(sel->VAR_10);
unlock_user_struct(sel, arg1, 0);
ret = do_select(nsel, inp, outp, exp, VAR_10);
}
break;
#endif
case TARGET_NR_symlink:
{
void *VAR_23;
VAR_2 = lock_user_string(arg1);
VAR_23 = lock_user_string(arg2);
if (!VAR_2 || !VAR_23)
ret = -TARGET_EFAULT;
else
ret = get_errno(symlink(VAR_2, VAR_23));
unlock_user(VAR_23, arg2, 0);
unlock_user(VAR_2, arg1, 0);
}
break;
#if defined(TARGET_NR_symlinkat) && defined(__NR_symlinkat)
case TARGET_NR_symlinkat:
{
void *VAR_23;
VAR_2 = lock_user_string(arg1);
VAR_23 = lock_user_string(arg3);
if (!VAR_2 || !VAR_23)
ret = -TARGET_EFAULT;
else
ret = get_errno(sys_symlinkat(VAR_2, arg2, VAR_23));
unlock_user(VAR_23, arg3, 0);
unlock_user(VAR_2, arg1, 0);
}
break;
#endif
#ifdef TARGET_NR_oldlstat
case TARGET_NR_oldlstat:
goto unimplemented;
#endif
case TARGET_NR_readlink:
{
void *VAR_23, *VAR_23;
VAR_2 = lock_user_string(arg1);
VAR_23 = lock_user(VERIFY_WRITE, arg2, arg3, 0);
if (!VAR_2 || !VAR_23)
ret = -TARGET_EFAULT;
else {
if (strncmp((const char *)VAR_2, "/proc/self/exe", 14) == 0) {
char VAR_24[PATH_MAX];
VAR_23 = realpath(exec_path,VAR_24);
ret = (VAR_23==NULL) ? get_errno(-1) : strlen(VAR_24) ;
snprintf((char *)VAR_23, arg3, "%s", VAR_24);
}
else
ret = get_errno(readlink(path(VAR_2), VAR_23, arg3));
}
unlock_user(VAR_23, arg2, ret);
unlock_user(VAR_2, arg1, 0);
}
break;
#if defined(TARGET_NR_readlinkat) && defined(__NR_readlinkat)
case TARGET_NR_readlinkat:
{
void *VAR_23;
VAR_2 = lock_user_string(arg2);
VAR_23 = lock_user(VERIFY_WRITE, arg3, arg4, 0);
if (!VAR_2 || !VAR_23)
ret = -TARGET_EFAULT;
else
ret = get_errno(sys_readlinkat(arg1, path(VAR_2), VAR_23, arg4));
unlock_user(VAR_23, arg3, ret);
unlock_user(VAR_2, arg2, 0);
}
break;
#endif
#ifdef TARGET_NR_uselib
case TARGET_NR_uselib:
goto unimplemented;
#endif
#ifdef TARGET_NR_swapon
case TARGET_NR_swapon:
if (!(VAR_2 = lock_user_string(arg1)))
goto efault;
ret = get_errno(swapon(VAR_2, arg2));
unlock_user(VAR_2, arg1, 0);
break;
#endif
case TARGET_NR_reboot:
goto unimplemented;
#ifdef TARGET_NR_readdir
case TARGET_NR_readdir:
goto unimplemented;
#endif
#ifdef TARGET_NR_mmap
case TARGET_NR_mmap:
#if (defined(TARGET_I386) && defined(TARGET_ABI32)) || defined(TARGET_ARM) || defined(TARGET_M68K) || defined(TARGET_CRIS) || defined(TARGET_MICROBLAZE)
{
abi_ulong *v;
abi_ulong v1, v2, v3, v4, v5, v6;
if (!(v = lock_user(VERIFY_READ, arg1, 6 * sizeof(abi_ulong), 1)))
goto efault;
v1 = tswapl(v[0]);
v2 = tswapl(v[1]);
v3 = tswapl(v[2]);
v4 = tswapl(v[3]);
v5 = tswapl(v[4]);
v6 = tswapl(v[5]);
unlock_user(v, arg1, 0);
ret = get_errno(target_mmap(v1, v2, v3,
target_to_host_bitmask(v4, mmap_flags_tbl),
v5, v6));
}
#else
ret = get_errno(target_mmap(arg1, arg2, arg3,
target_to_host_bitmask(arg4, mmap_flags_tbl),
arg5,
arg6));
#endif
break;
#endif
#ifdef TARGET_NR_mmap2
case TARGET_NR_mmap2:
#ifndef MMAP_SHIFT
#define MMAP_SHIFT 12
#endif
ret = get_errno(target_mmap(arg1, arg2, arg3,
target_to_host_bitmask(arg4, mmap_flags_tbl),
arg5,
arg6 << MMAP_SHIFT));
break;
#endif
case TARGET_NR_munmap:
ret = get_errno(target_munmap(arg1, arg2));
break;
case TARGET_NR_mprotect:
ret = get_errno(target_mprotect(arg1, arg2, arg3));
break;
#ifdef TARGET_NR_mremap
case TARGET_NR_mremap:
ret = get_errno(target_mremap(arg1, arg2, arg3, arg4, arg5));
break;
#endif
#ifdef TARGET_NR_msync
case TARGET_NR_msync:
ret = get_errno(msync(g2h(arg1), arg2, arg3));
break;
#endif
#ifdef TARGET_NR_mlock
case TARGET_NR_mlock:
ret = get_errno(mlock(g2h(arg1), arg2));
break;
#endif
#ifdef TARGET_NR_munlock
case TARGET_NR_munlock:
ret = get_errno(munlock(g2h(arg1), arg2));
break;
#endif
#ifdef TARGET_NR_mlockall
case TARGET_NR_mlockall:
ret = get_errno(mlockall(arg1));
break;
#endif
#ifdef TARGET_NR_munlockall
case TARGET_NR_munlockall:
ret = get_errno(munlockall());
break;
#endif
case TARGET_NR_truncate:
if (!(VAR_2 = lock_user_string(arg1)))
goto efault;
ret = get_errno(truncate(VAR_2, arg2));
unlock_user(VAR_2, arg1, 0);
break;
case TARGET_NR_ftruncate:
ret = get_errno(ftruncate(arg1, arg2));
break;
case TARGET_NR_fchmod:
ret = get_errno(fchmod(arg1, arg2));
break;
#if defined(TARGET_NR_fchmodat) && defined(__NR_fchmodat)
case TARGET_NR_fchmodat:
if (!(VAR_2 = lock_user_string(arg2)))
goto efault;
ret = get_errno(sys_fchmodat(arg1, VAR_2, arg3));
unlock_user(VAR_2, arg2, 0);
break;
#endif
case TARGET_NR_getpriority:
ret = sys_getpriority(arg1, arg2);
break;
case TARGET_NR_setpriority:
ret = get_errno(setpriority(arg1, arg2, arg3));
break;
#ifdef TARGET_NR_profil
case TARGET_NR_profil:
goto unimplemented;
#endif
case TARGET_NR_statfs:
if (!(VAR_2 = lock_user_string(arg1)))
goto efault;
ret = get_errno(statfs(path(VAR_2), &VAR_1));
unlock_user(VAR_2, arg1, 0);
convert_statfs:
if (!is_error(ret)) {
struct target_statfs *VAR_25;
if (!lock_user_struct(VERIFY_WRITE, VAR_25, arg2, 0))
goto efault;
__put_user(VAR_1.f_type, &VAR_25->f_type);
__put_user(VAR_1.f_bsize, &VAR_25->f_bsize);
__put_user(VAR_1.f_blocks, &VAR_25->f_blocks);
__put_user(VAR_1.f_bfree, &VAR_25->f_bfree);
__put_user(VAR_1.f_bavail, &VAR_25->f_bavail);
__put_user(VAR_1.f_files, &VAR_25->f_files);
__put_user(VAR_1.f_ffree, &VAR_25->f_ffree);
__put_user(VAR_1.f_fsid.__val[0], &VAR_25->f_fsid.val[0]);
__put_user(VAR_1.f_fsid.__val[1], &VAR_25->f_fsid.val[1]);
__put_user(VAR_1.f_namelen, &VAR_25->f_namelen);
unlock_user_struct(VAR_25, arg2, 1);
}
break;
case TARGET_NR_fstatfs:
ret = get_errno(fstatfs(arg1, &VAR_1));
goto convert_statfs;
#ifdef TARGET_NR_statfs64
case TARGET_NR_statfs64:
if (!(VAR_2 = lock_user_string(arg1)))
goto efault;
ret = get_errno(statfs(path(VAR_2), &VAR_1));
unlock_user(VAR_2, arg1, 0);
convert_statfs64:
if (!is_error(ret)) {
struct target_statfs64 *VAR_25;
if (!lock_user_struct(VERIFY_WRITE, VAR_25, arg3, 0))
goto efault;
__put_user(VAR_1.f_type, &VAR_25->f_type);
__put_user(VAR_1.f_bsize, &VAR_25->f_bsize);
__put_user(VAR_1.f_blocks, &VAR_25->f_blocks);
__put_user(VAR_1.f_bfree, &VAR_25->f_bfree);
__put_user(VAR_1.f_bavail, &VAR_25->f_bavail);
__put_user(VAR_1.f_files, &VAR_25->f_files);
__put_user(VAR_1.f_ffree, &VAR_25->f_ffree);
__put_user(VAR_1.f_fsid.__val[0], &VAR_25->f_fsid.val[0]);
__put_user(VAR_1.f_fsid.__val[1], &VAR_25->f_fsid.val[1]);
__put_user(VAR_1.f_namelen, &VAR_25->f_namelen);
unlock_user_struct(VAR_25, arg3, 1);
}
break;
case TARGET_NR_fstatfs64:
ret = get_errno(fstatfs(arg1, &VAR_1));
goto convert_statfs64;
#endif
#ifdef TARGET_NR_ioperm
case TARGET_NR_ioperm:
goto unimplemented;
#endif
#ifdef TARGET_NR_socketcall
case TARGET_NR_socketcall:
ret = do_socketcall(arg1, arg2);
break;
#endif
#ifdef TARGET_NR_accept
case TARGET_NR_accept:
ret = do_accept(arg1, arg2, arg3);
break;
#endif
#ifdef TARGET_NR_bind
case TARGET_NR_bind:
ret = do_bind(arg1, arg2, arg3);
break;
#endif
#ifdef TARGET_NR_connect
case TARGET_NR_connect:
ret = do_connect(arg1, arg2, arg3);
break;
#endif
#ifdef TARGET_NR_getpeername
case TARGET_NR_getpeername:
ret = do_getpeername(arg1, arg2, arg3);
break;
#endif
#ifdef TARGET_NR_getsockname
case TARGET_NR_getsockname:
ret = do_getsockname(arg1, arg2, arg3);
break;
#endif
#ifdef TARGET_NR_getsockopt
case TARGET_NR_getsockopt:
ret = do_getsockopt(arg1, arg2, arg3, arg4, arg5);
break;
#endif
#ifdef TARGET_NR_listen
case TARGET_NR_listen:
ret = get_errno(listen(arg1, arg2));
break;
#endif
#ifdef TARGET_NR_recv
case TARGET_NR_recv:
ret = do_recvfrom(arg1, arg2, arg3, arg4, 0, 0);
break;
#endif
#ifdef TARGET_NR_recvfrom
case TARGET_NR_recvfrom:
ret = do_recvfrom(arg1, arg2, arg3, arg4, arg5, arg6);
break;
#endif
#ifdef TARGET_NR_recvmsg
case TARGET_NR_recvmsg:
ret = do_sendrecvmsg(arg1, arg2, arg3, 0);
break;
#endif
#ifdef TARGET_NR_send
case TARGET_NR_send:
ret = do_sendto(arg1, arg2, arg3, arg4, 0, 0);
break;
#endif
#ifdef TARGET_NR_sendmsg
case TARGET_NR_sendmsg:
ret = do_sendrecvmsg(arg1, arg2, arg3, 1);
break;
#endif
#ifdef TARGET_NR_sendto
case TARGET_NR_sendto:
ret = do_sendto(arg1, arg2, arg3, arg4, arg5, arg6);
break;
#endif
#ifdef TARGET_NR_shutdown
case TARGET_NR_shutdown:
ret = get_errno(shutdown(arg1, arg2));
break;
#endif
#ifdef TARGET_NR_socket
case TARGET_NR_socket:
ret = do_socket(arg1, arg2, arg3);
break;
#endif
#ifdef TARGET_NR_socketpair
case TARGET_NR_socketpair:
ret = do_socketpair(arg1, arg2, arg3, arg4);
break;
#endif
#ifdef TARGET_NR_setsockopt
case TARGET_NR_setsockopt:
ret = do_setsockopt(arg1, arg2, arg3, arg4, (socklen_t) arg5);
break;
#endif
case TARGET_NR_syslog:
if (!(VAR_2 = lock_user_string(arg2)))
goto efault;
ret = get_errno(sys_syslog((int)arg1, VAR_2, (int)arg3));
unlock_user(VAR_2, arg2, 0);
break;
case TARGET_NR_setitimer:
{
struct itimerval VAR_33, VAR_27, *VAR_28;
if (arg2) {
VAR_28 = &VAR_33;
if (copy_from_user_timeval(&VAR_28->it_interval, arg2)
|| copy_from_user_timeval(&VAR_28->it_value,
arg2 + sizeof(struct target_timeval)))
goto efault;
} else {
VAR_28 = NULL;
}
ret = get_errno(setitimer(arg1, VAR_28, &VAR_27));
if (!is_error(ret) && arg3) {
if (copy_to_user_timeval(arg3,
&VAR_27.it_interval)
|| copy_to_user_timeval(arg3 + sizeof(struct target_timeval),
&VAR_27.it_value))
goto efault;
}
}
break;
case TARGET_NR_getitimer:
{
struct itimerval VAR_33;
ret = get_errno(getitimer(arg1, &VAR_33));
if (!is_error(ret) && arg2) {
if (copy_to_user_timeval(arg2,
&VAR_33.it_interval)
|| copy_to_user_timeval(arg2 + sizeof(struct target_timeval),
&VAR_33.it_value))
goto efault;
}
}
break;
case TARGET_NR_stat:
if (!(VAR_2 = lock_user_string(arg1)))
goto efault;
ret = get_errno(stat(path(VAR_2), &VAR_0));
unlock_user(VAR_2, arg1, 0);
goto do_stat;
case TARGET_NR_lstat:
if (!(VAR_2 = lock_user_string(arg1)))
goto efault;
ret = get_errno(lstat(path(VAR_2), &VAR_0));
unlock_user(VAR_2, arg1, 0);
goto do_stat;
case TARGET_NR_fstat:
{
ret = get_errno(fstat(arg1, &VAR_0));
do_stat:
if (!is_error(ret)) {
struct target_stat *VAR_29;
if (!lock_user_struct(VERIFY_WRITE, VAR_29, arg2, 0))
goto efault;
__put_user(VAR_0.st_dev, &VAR_29->st_dev);
__put_user(VAR_0.st_ino, &VAR_29->st_ino);
__put_user(VAR_0.st_mode, &VAR_29->st_mode);
__put_user(VAR_0.st_uid, &VAR_29->st_uid);
__put_user(VAR_0.st_gid, &VAR_29->st_gid);
__put_user(VAR_0.st_nlink, &VAR_29->st_nlink);
__put_user(VAR_0.st_rdev, &VAR_29->st_rdev);
__put_user(VAR_0.st_size, &VAR_29->st_size);
__put_user(VAR_0.st_blksize, &VAR_29->st_blksize);
__put_user(VAR_0.st_blocks, &VAR_29->st_blocks);
__put_user(VAR_0.st_atime, &VAR_29->target_st_atime);
__put_user(VAR_0.st_mtime, &VAR_29->target_st_mtime);
__put_user(VAR_0.st_ctime, &VAR_29->target_st_ctime);
unlock_user_struct(VAR_29, arg2, 1);
}
}
break;
#ifdef TARGET_NR_olduname
case TARGET_NR_olduname:
goto unimplemented;
#endif
#ifdef TARGET_NR_iopl
case TARGET_NR_iopl:
goto unimplemented;
#endif
case TARGET_NR_vhangup:
ret = get_errno(vhangup());
break;
#ifdef TARGET_NR_idle
case TARGET_NR_idle:
goto unimplemented;
#endif
#ifdef TARGET_NR_syscall
case TARGET_NR_syscall:
ret = FUNC_0(cpu_env,arg1 & 0xffff,arg2,arg3,arg4,arg5,arg6,0);
break;
#endif
case TARGET_NR_wait4:
{
int VAR_30;
abi_long status_ptr = arg2;
struct VAR_31 VAR_31, *VAR_31;
abi_ulong target_rusage = arg4;
if (target_rusage)
VAR_31 = &VAR_31;
else
VAR_31 = NULL;
ret = get_errno(wait4(arg1, &VAR_30, arg3, VAR_31));
if (!is_error(ret)) {
if (status_ptr) {
VAR_30 = host_to_target_waitstatus(VAR_30);
if (put_user_s32(VAR_30, status_ptr))
goto efault;
}
if (target_rusage)
host_to_target_rusage(target_rusage, &VAR_31);
}
}
break;
#ifdef TARGET_NR_swapoff
case TARGET_NR_swapoff:
if (!(VAR_2 = lock_user_string(arg1)))
goto efault;
ret = get_errno(swapoff(VAR_2));
unlock_user(VAR_2, arg1, 0);
break;
#endif
case TARGET_NR_sysinfo:
{
struct target_sysinfo *VAR_32;
struct sysinfo VAR_33;
ret = get_errno(sysinfo(&VAR_33));
if (!is_error(ret) && arg1)
{
if (!lock_user_struct(VERIFY_WRITE, VAR_32, arg1, 0))
goto efault;
__put_user(VAR_33.uptime, &VAR_32->uptime);
__put_user(VAR_33.loads[0], &VAR_32->loads[0]);
__put_user(VAR_33.loads[1], &VAR_32->loads[1]);
__put_user(VAR_33.loads[2], &VAR_32->loads[2]);
__put_user(VAR_33.totalram, &VAR_32->totalram);
__put_user(VAR_33.freeram, &VAR_32->freeram);
__put_user(VAR_33.sharedram, &VAR_32->sharedram);
__put_user(VAR_33.bufferram, &VAR_32->bufferram);
__put_user(VAR_33.totalswap, &VAR_32->totalswap);
__put_user(VAR_33.freeswap, &VAR_32->freeswap);
__put_user(VAR_33.procs, &VAR_32->procs);
__put_user(VAR_33.totalhigh, &VAR_32->totalhigh);
__put_user(VAR_33.freehigh, &VAR_32->freehigh);
__put_user(VAR_33.mem_unit, &VAR_32->mem_unit);
unlock_user_struct(VAR_32, arg1, 1);
}
}
break;
#ifdef TARGET_NR_ipc
case TARGET_NR_ipc:
ret = do_ipc(arg1, arg2, arg3, arg4, arg5, arg6);
break;
#endif
#ifdef TARGET_NR_semget
case TARGET_NR_semget:
ret = get_errno(semget(arg1, arg2, arg3));
break;
#endif
#ifdef TARGET_NR_semop
case TARGET_NR_semop:
ret = get_errno(do_semop(arg1, arg2, arg3));
break;
#endif
#ifdef TARGET_NR_semctl
case TARGET_NR_semctl:
ret = do_semctl(arg1, arg2, arg3, (union target_semun)(abi_ulong)arg4);
break;
#endif
#ifdef TARGET_NR_msgctl
case TARGET_NR_msgctl:
ret = do_msgctl(arg1, arg2, arg3);
break;
#endif
#ifdef TARGET_NR_msgget
case TARGET_NR_msgget:
ret = get_errno(msgget(arg1, arg2));
break;
#endif
#ifdef TARGET_NR_msgrcv
case TARGET_NR_msgrcv:
ret = do_msgrcv(arg1, arg2, arg3, arg4, arg5);
break;
#endif
#ifdef TARGET_NR_msgsnd
case TARGET_NR_msgsnd:
ret = do_msgsnd(arg1, arg2, arg3, arg4);
break;
#endif
#ifdef TARGET_NR_shmget
case TARGET_NR_shmget:
ret = get_errno(shmget(arg1, arg2, arg3));
break;
#endif
#ifdef TARGET_NR_shmctl
case TARGET_NR_shmctl:
ret = do_shmctl(arg1, arg2, arg3);
break;
#endif
#ifdef TARGET_NR_shmat
case TARGET_NR_shmat:
ret = do_shmat(arg1, arg2, arg3);
break;
#endif
#ifdef TARGET_NR_shmdt
case TARGET_NR_shmdt:
ret = do_shmdt(arg1);
break;
#endif
case TARGET_NR_fsync:
ret = get_errno(fsync(arg1));
break;
case TARGET_NR_clone:
#if defined(TARGET_SH4)
ret = get_errno(do_fork(cpu_env, arg1, arg2, arg3, arg5, arg4));
#elif defined(TARGET_CRIS)
ret = get_errno(do_fork(cpu_env, arg2, arg1, arg3, arg4, arg5));
#else
ret = get_errno(do_fork(cpu_env, arg1, arg2, arg3, arg4, arg5));
#endif
break;
#ifdef __NR_exit_group
case TARGET_NR_exit_group:
#ifdef TARGET_GPROF
_mcleanup();
#endif
gdb_exit(cpu_env, arg1);
ret = get_errno(exit_group(arg1));
break;
#endif
case TARGET_NR_setdomainname:
if (!(VAR_2 = lock_user_string(arg1)))
goto efault;
ret = get_errno(setdomainname(VAR_2, arg2));
unlock_user(VAR_2, arg1, 0);
break;
case TARGET_NR_uname:
{
struct new_utsname * VAR_33;
if (!lock_user_struct(VERIFY_WRITE, VAR_33, arg1, 0))
goto efault;
ret = get_errno(sys_uname(VAR_33));
if (!is_error(ret)) {
strcpy (VAR_33->machine, UNAME_MACHINE);
if (qemu_uname_release && *qemu_uname_release)
strcpy (VAR_33->release, qemu_uname_release);
}
unlock_user_struct(VAR_33, arg1, 1);
}
break;
#ifdef TARGET_I386
case TARGET_NR_modify_ldt:
ret = do_modify_ldt(cpu_env, arg1, arg2, arg3);
break;
#if !defined(TARGET_X86_64)
case TARGET_NR_vm86old:
goto unimplemented;
case TARGET_NR_vm86:
ret = do_vm86(cpu_env, arg1, arg2);
break;
#endif
#endif
case TARGET_NR_adjtimex:
goto unimplemented;
#ifdef TARGET_NR_create_module
case TARGET_NR_create_module:
#endif
case TARGET_NR_init_module:
case TARGET_NR_delete_module:
#ifdef TARGET_NR_get_kernel_syms
case TARGET_NR_get_kernel_syms:
#endif
goto unimplemented;
case TARGET_NR_quotactl:
goto unimplemented;
case TARGET_NR_getpgid:
ret = get_errno(getpgid(arg1));
break;
case TARGET_NR_fchdir:
ret = get_errno(fchdir(arg1));
break;
#ifdef TARGET_NR_bdflush
case TARGET_NR_bdflush:
goto unimplemented;
#endif
#ifdef TARGET_NR_sysfs
case TARGET_NR_sysfs:
goto unimplemented;
#endif
case TARGET_NR_personality:
ret = get_errno(personality(arg1));
break;
#ifdef TARGET_NR_afs_syscall
case TARGET_NR_afs_syscall:
goto unimplemented;
#endif
#ifdef TARGET_NR__llseek
case TARGET_NR__llseek:
{
#if defined (__x86_64__)
ret = get_errno(lseek(arg1, ((uint64_t )arg2 << 32) | arg3, arg5));
if (put_user_s64(ret, arg4))
goto efault;
#else
int64_t res;
ret = get_errno(_llseek(arg1, arg2, arg3, &res, arg5));
if (put_user_s64(res, arg4))
goto efault;
#endif
}
break;
#endif
case TARGET_NR_getdents:
#if TARGET_ABI_BITS == 32 && HOST_LONG_BITS == 64
{
struct target_dirent *target_dirp;
struct linux_dirent *VAR_34;
abi_long VAR_40 = arg3;
VAR_34 = malloc(VAR_40);
if (!VAR_34) {
ret = -TARGET_ENOMEM;
goto fail;
}
ret = get_errno(sys_getdents(arg1, VAR_34, VAR_40));
if (!is_error(ret)) {
struct linux_dirent *VAR_35;
struct target_dirent *tde;
int VAR_36 = ret;
int VAR_37, treclen;
int count1, tnamelen;
count1 = 0;
VAR_35 = VAR_34;
if (!(target_dirp = lock_user(VERIFY_WRITE, arg2, VAR_40, 0)))
goto efault;
tde = target_dirp;
while (VAR_36 > 0) {
VAR_37 = VAR_35->d_reclen;
treclen = VAR_37 - (2 * (sizeof(long) - sizeof(abi_long)));
tde->d_reclen = tswap16(treclen);
tde->d_ino = tswapl(VAR_35->d_ino);
tde->d_off = tswapl(VAR_35->d_off);
tnamelen = treclen - (2 * sizeof(abi_long) + 2);
if (tnamelen > 256)
tnamelen = 256;
pstrcpy(tde->d_name, tnamelen, VAR_35->d_name);
VAR_35 = (struct linux_dirent *)((char *)VAR_35 + VAR_37);
VAR_36 -= VAR_37;
tde = (struct target_dirent *)((char *)tde + treclen);
count1 += treclen;
}
ret = count1;
unlock_user(target_dirp, arg2, ret);
}
free(VAR_34);
}
#else
{
struct linux_dirent *VAR_34;
abi_long VAR_40 = arg3;
if (!(VAR_34 = lock_user(VERIFY_WRITE, arg2, VAR_40, 0)))
goto efault;
ret = get_errno(sys_getdents(arg1, VAR_34, VAR_40));
if (!is_error(ret)) {
struct linux_dirent *VAR_35;
int VAR_36 = ret;
int VAR_37;
VAR_35 = VAR_34;
while (VAR_36 > 0) {
VAR_37 = VAR_35->d_reclen;
if (VAR_37 > VAR_36)
break;
VAR_35->d_reclen = tswap16(VAR_37);
tswapls(&VAR_35->d_ino);
tswapls(&VAR_35->d_off);
VAR_35 = (struct linux_dirent *)((char *)VAR_35 + VAR_37);
VAR_36 -= VAR_37;
}
}
unlock_user(VAR_34, arg2, ret);
}
#endif
break;
#if defined(TARGET_NR_getdents64) && defined(__NR_getdents64)
case TARGET_NR_getdents64:
{
struct linux_dirent64 *VAR_34;
abi_long VAR_40 = arg3;
if (!(VAR_34 = lock_user(VERIFY_WRITE, arg2, VAR_40, 0)))
goto efault;
ret = get_errno(sys_getdents64(arg1, VAR_34, VAR_40));
if (!is_error(ret)) {
struct linux_dirent64 *VAR_35;
int VAR_36 = ret;
int VAR_37;
VAR_35 = VAR_34;
while (VAR_36 > 0) {
VAR_37 = VAR_35->d_reclen;
if (VAR_37 > VAR_36)
break;
VAR_35->d_reclen = tswap16(VAR_37);
tswap64s((uint64_t *)&VAR_35->d_ino);
tswap64s((uint64_t *)&VAR_35->d_off);
VAR_35 = (struct linux_dirent64 *)((char *)VAR_35 + VAR_37);
VAR_36 -= VAR_37;
}
}
unlock_user(VAR_34, arg2, ret);
}
break;
#endif
#ifdef TARGET_NR__newselect
case TARGET_NR__newselect:
ret = do_select(arg1, arg2, arg3, arg4, arg5);
break;
#endif
#ifdef TARGET_NR_poll
case TARGET_NR_poll:
{
struct target_pollfd *target_pfd;
unsigned int nfds = arg2;
int timeout = arg3;
struct pollfd *pfd;
unsigned int i;
target_pfd = lock_user(VERIFY_WRITE, arg1, sizeof(struct target_pollfd) * nfds, 1);
if (!target_pfd)
goto efault;
pfd = alloca(sizeof(struct pollfd) * nfds);
for(i = 0; i < nfds; i++) {
pfd[i].fd = tswap32(target_pfd[i].fd);
pfd[i].events = tswap16(target_pfd[i].events);
}
ret = get_errno(poll(pfd, nfds, timeout));
if (!is_error(ret)) {
for(i = 0; i < nfds; i++) {
target_pfd[i].revents = tswap16(pfd[i].revents);
}
ret += nfds * (sizeof(struct target_pollfd)
- sizeof(struct pollfd));
}
unlock_user(target_pfd, arg1, ret);
}
break;
#endif
case TARGET_NR_flock:
ret = get_errno(flock(arg1, arg2));
break;
case TARGET_NR_readv:
{
int VAR_40 = arg3;
struct iovec *VAR_40;
VAR_40 = alloca(VAR_40 * sizeof(struct iovec));
if (lock_iovec(VERIFY_WRITE, VAR_40, arg2, VAR_40, 0) < 0)
goto efault;
ret = get_errno(readv(arg1, VAR_40, VAR_40));
unlock_iovec(VAR_40, arg2, VAR_40, 1);
}
break;
case TARGET_NR_writev:
{
int VAR_40 = arg3;
struct iovec *VAR_40;
VAR_40 = alloca(VAR_40 * sizeof(struct iovec));
if (lock_iovec(VERIFY_READ, VAR_40, arg2, VAR_40, 1) < 0)
goto efault;
ret = get_errno(writev(arg1, VAR_40, VAR_40));
unlock_iovec(VAR_40, arg2, VAR_40, 0);
}
break;
case TARGET_NR_getsid:
ret = get_errno(getsid(arg1));
break;
#if defined(TARGET_NR_fdatasync)
case TARGET_NR_fdatasync:
ret = get_errno(fdatasync(arg1));
break;
#endif
case TARGET_NR__sysctl:
ret = -TARGET_ENOTDIR;
break;
case TARGET_NR_sched_setparam:
{
struct sched_param *VAR_42;
struct sched_param VAR_42;
if (!lock_user_struct(VERIFY_READ, VAR_42, arg2, 1))
goto efault;
VAR_42.sched_priority = tswap32(VAR_42->sched_priority);
unlock_user_struct(VAR_42, arg2, 0);
ret = get_errno(sched_setparam(arg1, &VAR_42));
}
break;
case TARGET_NR_sched_getparam:
{
struct sched_param *VAR_42;
struct sched_param VAR_42;
ret = get_errno(sched_getparam(arg1, &VAR_42));
if (!is_error(ret)) {
if (!lock_user_struct(VERIFY_WRITE, VAR_42, arg2, 0))
goto efault;
VAR_42->sched_priority = tswap32(VAR_42.sched_priority);
unlock_user_struct(VAR_42, arg2, 1);
}
}
break;
case TARGET_NR_sched_setscheduler:
{
struct sched_param *VAR_42;
struct sched_param VAR_42;
if (!lock_user_struct(VERIFY_READ, VAR_42, arg3, 1))
goto efault;
VAR_42.sched_priority = tswap32(VAR_42->sched_priority);
unlock_user_struct(VAR_42, arg3, 0);
ret = get_errno(sched_setscheduler(arg1, arg2, &VAR_42));
}
break;
case TARGET_NR_sched_getscheduler:
ret = get_errno(sched_getscheduler(arg1));
break;
case TARGET_NR_sched_yield:
ret = get_errno(sched_yield());
break;
case TARGET_NR_sched_get_priority_max:
ret = get_errno(sched_get_priority_max(arg1));
break;
case TARGET_NR_sched_get_priority_min:
ret = get_errno(sched_get_priority_min(arg1));
break;
case TARGET_NR_sched_rr_get_interval:
{
struct timespec VAR_42;
ret = get_errno(sched_rr_get_interval(arg1, &VAR_42));
if (!is_error(ret)) {
host_to_target_timespec(arg2, &VAR_42);
}
}
break;
case TARGET_NR_nanosleep:
{
struct timespec VAR_43, VAR_44;
target_to_host_timespec(&VAR_43, arg1);
ret = get_errno(nanosleep(&VAR_43, &VAR_44));
if (is_error(ret) && arg2) {
host_to_target_timespec(arg2, &VAR_44);
}
}
break;
#ifdef TARGET_NR_query_module
case TARGET_NR_query_module:
goto unimplemented;
#endif
#ifdef TARGET_NR_nfsservctl
case TARGET_NR_nfsservctl:
goto unimplemented;
#endif
case TARGET_NR_prctl:
switch (arg1)
{
case PR_GET_PDEATHSIG:
{
int VAR_45;
ret = get_errno(prctl(arg1, &VAR_45, arg3, arg4, arg5));
if (!is_error(ret) && arg2
&& put_user_ual(VAR_45, arg2))
goto efault;
}
break;
default:
ret = get_errno(prctl(arg1, arg2, arg3, arg4, arg5));
break;
}
break;
#ifdef TARGET_NR_arch_prctl
case TARGET_NR_arch_prctl:
#if defined(TARGET_I386) && !defined(TARGET_ABI32)
ret = do_arch_prctl(cpu_env, arg1, arg2);
break;
#else
goto unimplemented;
#endif
#endif
#ifdef TARGET_NR_pread
case TARGET_NR_pread:
#ifdef TARGET_ARM
if (((CPUARMState *)cpu_env)->eabi)
arg4 = arg5;
#endif
if (!(VAR_2 = lock_user(VERIFY_WRITE, arg2, arg3, 0)))
goto efault;
ret = get_errno(pread(arg1, VAR_2, arg3, arg4));
unlock_user(VAR_2, arg2, ret);
break;
case TARGET_NR_pwrite:
#ifdef TARGET_ARM
if (((CPUARMState *)cpu_env)->eabi)
arg4 = arg5;
#endif
if (!(VAR_2 = lock_user(VERIFY_READ, arg2, arg3, 1)))
goto efault;
ret = get_errno(pwrite(arg1, VAR_2, arg3, arg4));
unlock_user(VAR_2, arg2, 0);
break;
#endif
#ifdef TARGET_NR_pread64
case TARGET_NR_pread64:
if (!(VAR_2 = lock_user(VERIFY_WRITE, arg2, arg3, 0)))
goto efault;
ret = get_errno(pread64(arg1, VAR_2, arg3, target_offset64(arg4, arg5)));
unlock_user(VAR_2, arg2, ret);
break;
case TARGET_NR_pwrite64:
if (!(VAR_2 = lock_user(VERIFY_READ, arg2, arg3, 1)))
goto efault;
ret = get_errno(pwrite64(arg1, VAR_2, arg3, target_offset64(arg4, arg5)));
unlock_user(VAR_2, arg2, 0);
break;
#endif
case TARGET_NR_getcwd:
if (!(VAR_2 = lock_user(VERIFY_WRITE, arg1, arg2, 0)))
goto efault;
ret = get_errno(sys_getcwd1(VAR_2, arg2));
unlock_user(VAR_2, arg1, ret);
break;
case TARGET_NR_capget:
goto unimplemented;
case TARGET_NR_capset:
goto unimplemented;
case TARGET_NR_sigaltstack:
#if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_MIPS) || \
defined(TARGET_SPARC) || defined(TARGET_PPC) || defined(TARGET_ALPHA) || \
defined(TARGET_M68K)
ret = do_sigaltstack(arg1, arg2, get_sp_from_cpustate((CPUState *)cpu_env));
break;
#else
goto unimplemented;
#endif
case TARGET_NR_sendfile:
goto unimplemented;
#ifdef TARGET_NR_getpmsg
case TARGET_NR_getpmsg:
goto unimplemented;
#endif
#ifdef TARGET_NR_putpmsg
case TARGET_NR_putpmsg:
goto unimplemented;
#endif
#ifdef TARGET_NR_vfork
case TARGET_NR_vfork:
ret = get_errno(do_fork(cpu_env, CLONE_VFORK | CLONE_VM | SIGCHLD,
0, 0, 0, 0));
break;
#endif
#ifdef TARGET_NR_ugetrlimit
case TARGET_NR_ugetrlimit:
{
struct rlimit VAR_22;
ret = get_errno(getrlimit(arg1, &VAR_22));
if (!is_error(ret)) {
struct target_rlimit *VAR_22;
if (!lock_user_struct(VERIFY_WRITE, VAR_22, arg2, 0))
goto efault;
VAR_22->rlim_cur = tswapl(VAR_22.rlim_cur);
VAR_22->rlim_max = tswapl(VAR_22.rlim_max);
unlock_user_struct(VAR_22, arg2, 1);
}
break;
}
#endif
#ifdef TARGET_NR_truncate64
case TARGET_NR_truncate64:
if (!(VAR_2 = lock_user_string(arg1)))
goto efault;
ret = target_truncate64(cpu_env, VAR_2, arg2, arg3, arg4);
unlock_user(VAR_2, arg1, 0);
break;
#endif
#ifdef TARGET_NR_ftruncate64
case TARGET_NR_ftruncate64:
ret = target_ftruncate64(cpu_env, arg1, arg2, arg3, arg4);
break;
#endif
#ifdef TARGET_NR_stat64
case TARGET_NR_stat64:
if (!(VAR_2 = lock_user_string(arg1)))
goto efault;
ret = get_errno(stat(path(VAR_2), &VAR_0));
unlock_user(VAR_2, arg1, 0);
if (!is_error(ret))
ret = host_to_target_stat64(cpu_env, arg2, &VAR_0);
break;
#endif
#ifdef TARGET_NR_lstat64
case TARGET_NR_lstat64:
if (!(VAR_2 = lock_user_string(arg1)))
goto efault;
ret = get_errno(lstat(path(VAR_2), &VAR_0));
unlock_user(VAR_2, arg1, 0);
if (!is_error(ret))
ret = host_to_target_stat64(cpu_env, arg2, &VAR_0);
break;
#endif
#ifdef TARGET_NR_fstat64
case TARGET_NR_fstat64:
ret = get_errno(fstat(arg1, &VAR_0));
if (!is_error(ret))
ret = host_to_target_stat64(cpu_env, arg2, &VAR_0);
break;
#endif
#if (defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)) && \
(defined(__NR_fstatat64) || defined(__NR_newfstatat))
#ifdef TARGET_NR_fstatat64
case TARGET_NR_fstatat64:
#endif
#ifdef TARGET_NR_newfstatat
case TARGET_NR_newfstatat:
#endif
if (!(VAR_2 = lock_user_string(arg2)))
goto efault;
#ifdef __NR_fstatat64
ret = get_errno(sys_fstatat64(arg1, path(VAR_2), &VAR_0, arg4));
#else
ret = get_errno(sys_newfstatat(arg1, path(VAR_2), &VAR_0, arg4));
#endif
if (!is_error(ret))
ret = host_to_target_stat64(cpu_env, arg3, &VAR_0);
break;
#endif
#ifdef USE_UID16
case TARGET_NR_lchown:
if (!(VAR_2 = lock_user_string(arg1)))
goto efault;
ret = get_errno(lchown(VAR_2, low2highuid(arg2), low2highgid(arg3)));
unlock_user(VAR_2, arg1, 0);
break;
case TARGET_NR_getuid:
ret = get_errno(high2lowuid(getuid()));
break;
case TARGET_NR_getgid:
ret = get_errno(high2lowgid(getgid()));
break;
case TARGET_NR_geteuid:
ret = get_errno(high2lowuid(geteuid()));
break;
case TARGET_NR_getegid:
ret = get_errno(high2lowgid(getegid()));
break;
case TARGET_NR_setreuid:
ret = get_errno(setreuid(low2highuid(arg1), low2highuid(arg2)));
break;
case TARGET_NR_setregid:
ret = get_errno(setregid(low2highgid(arg1), low2highgid(arg2)));
break;
case TARGET_NR_getgroups:
{
int gidsetsize = arg1;
uint16_t *target_grouplist;
gid_t *grouplist;
int i;
grouplist = alloca(gidsetsize * sizeof(gid_t));
ret = get_errno(getgroups(gidsetsize, grouplist));
if (gidsetsize == 0)
break;
if (!is_error(ret)) {
target_grouplist = lock_user(VERIFY_WRITE, arg2, gidsetsize * 2, 0);
if (!target_grouplist)
goto efault;
for(i = 0;i < ret; i++)
target_grouplist[i] = tswap16(grouplist[i]);
unlock_user(target_grouplist, arg2, gidsetsize * 2);
}
}
break;
case TARGET_NR_setgroups:
{
int gidsetsize = arg1;
uint16_t *target_grouplist;
gid_t *grouplist;
int i;
grouplist = alloca(gidsetsize * sizeof(gid_t));
target_grouplist = lock_user(VERIFY_READ, arg2, gidsetsize * 2, 1);
if (!target_grouplist) {
ret = -TARGET_EFAULT;
goto fail;
}
for(i = 0;i < gidsetsize; i++)
grouplist[i] = tswap16(target_grouplist[i]);
unlock_user(target_grouplist, arg2, 0);
ret = get_errno(setgroups(gidsetsize, grouplist));
}
break;
case TARGET_NR_fchown:
ret = get_errno(fchown(arg1, low2highuid(arg2), low2highgid(arg3)));
break;
#if defined(TARGET_NR_fchownat) && defined(__NR_fchownat)
case TARGET_NR_fchownat:
if (!(VAR_2 = lock_user_string(arg2)))
goto efault;
ret = get_errno(sys_fchownat(arg1, VAR_2, low2highuid(arg3), low2highgid(arg4), arg5));
unlock_user(VAR_2, arg2, 0);
break;
#endif
#ifdef TARGET_NR_setresuid
case TARGET_NR_setresuid:
ret = get_errno(setresuid(low2highuid(arg1),
low2highuid(arg2),
low2highuid(arg3)));
break;
#endif
#ifdef TARGET_NR_getresuid
case TARGET_NR_getresuid:
{
uid_t ruid, euid, suid;
ret = get_errno(getresuid(&ruid, &euid, &suid));
if (!is_error(ret)) {
if (put_user_u16(high2lowuid(ruid), arg1)
|| put_user_u16(high2lowuid(euid), arg2)
|| put_user_u16(high2lowuid(suid), arg3))
goto efault;
}
}
break;
#endif
#ifdef TARGET_NR_getresgid
case TARGET_NR_setresgid:
ret = get_errno(setresgid(low2highgid(arg1),
low2highgid(arg2),
low2highgid(arg3)));
break;
#endif
#ifdef TARGET_NR_getresgid
case TARGET_NR_getresgid:
{
gid_t rgid, egid, sgid;
ret = get_errno(getresgid(&rgid, &egid, &sgid));
if (!is_error(ret)) {
if (put_user_u16(high2lowgid(rgid), arg1)
|| put_user_u16(high2lowgid(egid), arg2)
|| put_user_u16(high2lowgid(sgid), arg3))
goto efault;
}
}
break;
#endif
case TARGET_NR_chown:
if (!(VAR_2 = lock_user_string(arg1)))
goto efault;
ret = get_errno(chown(VAR_2, low2highuid(arg2), low2highgid(arg3)));
unlock_user(VAR_2, arg1, 0);
break;
case TARGET_NR_setuid:
ret = get_errno(setuid(low2highuid(arg1)));
break;
case TARGET_NR_setgid:
ret = get_errno(setgid(low2highgid(arg1)));
break;
case TARGET_NR_setfsuid:
ret = get_errno(setfsuid(arg1));
break;
case TARGET_NR_setfsgid:
ret = get_errno(setfsgid(arg1));
break;
#endif
#ifdef TARGET_NR_lchown32
case TARGET_NR_lchown32:
if (!(VAR_2 = lock_user_string(arg1)))
goto efault;
ret = get_errno(lchown(VAR_2, arg2, arg3));
unlock_user(VAR_2, arg1, 0);
break;
#endif
#ifdef TARGET_NR_getuid32
case TARGET_NR_getuid32:
ret = get_errno(getuid());
break;
#endif
#if defined(TARGET_NR_getxuid) && defined(TARGET_ALPHA)
case TARGET_NR_getxuid:
{
uid_t euid;
euid=geteuid();
((CPUAlphaState *)cpu_env)->ir[IR_A4]=euid;
}
ret = get_errno(getuid());
break;
#endif
#if defined(TARGET_NR_getxgid) && defined(TARGET_ALPHA)
case TARGET_NR_getxgid:
{
uid_t egid;
egid=getegid();
((CPUAlphaState *)cpu_env)->ir[IR_A4]=egid;
}
ret = get_errno(getgid());
break;
#endif
#ifdef TARGET_NR_getgid32
case TARGET_NR_getgid32:
ret = get_errno(getgid());
break;
#endif
#ifdef TARGET_NR_geteuid32
case TARGET_NR_geteuid32:
ret = get_errno(geteuid());
break;
#endif
#ifdef TARGET_NR_getegid32
case TARGET_NR_getegid32:
ret = get_errno(getegid());
break;
#endif
#ifdef TARGET_NR_setreuid32
case TARGET_NR_setreuid32:
ret = get_errno(setreuid(arg1, arg2));
break;
#endif
#ifdef TARGET_NR_setregid32
case TARGET_NR_setregid32:
ret = get_errno(setregid(arg1, arg2));
break;
#endif
#ifdef TARGET_NR_getgroups32
case TARGET_NR_getgroups32:
{
int gidsetsize = arg1;
uint32_t *target_grouplist;
gid_t *grouplist;
int i;
grouplist = alloca(gidsetsize * sizeof(gid_t));
ret = get_errno(getgroups(gidsetsize, grouplist));
if (gidsetsize == 0)
break;
if (!is_error(ret)) {
target_grouplist = lock_user(VERIFY_WRITE, arg2, gidsetsize * 4, 0);
if (!target_grouplist) {
ret = -TARGET_EFAULT;
goto fail;
}
for(i = 0;i < ret; i++)
target_grouplist[i] = tswap32(grouplist[i]);
unlock_user(target_grouplist, arg2, gidsetsize * 4);
}
}
break;
#endif
#ifdef TARGET_NR_setgroups32
case TARGET_NR_setgroups32:
{
int gidsetsize = arg1;
uint32_t *target_grouplist;
gid_t *grouplist;
int i;
grouplist = alloca(gidsetsize * sizeof(gid_t));
target_grouplist = lock_user(VERIFY_READ, arg2, gidsetsize * 4, 1);
if (!target_grouplist) {
ret = -TARGET_EFAULT;
goto fail;
}
for(i = 0;i < gidsetsize; i++)
grouplist[i] = tswap32(target_grouplist[i]);
unlock_user(target_grouplist, arg2, 0);
ret = get_errno(setgroups(gidsetsize, grouplist));
}
break;
#endif
#ifdef TARGET_NR_fchown32
case TARGET_NR_fchown32:
ret = get_errno(fchown(arg1, arg2, arg3));
break;
#endif
#ifdef TARGET_NR_setresuid32
case TARGET_NR_setresuid32:
ret = get_errno(setresuid(arg1, arg2, arg3));
break;
#endif
#ifdef TARGET_NR_getresuid32
case TARGET_NR_getresuid32:
{
uid_t ruid, euid, suid;
ret = get_errno(getresuid(&ruid, &euid, &suid));
if (!is_error(ret)) {
if (put_user_u32(ruid, arg1)
|| put_user_u32(euid, arg2)
|| put_user_u32(suid, arg3))
goto efault;
}
}
break;
#endif
#ifdef TARGET_NR_setresgid32
case TARGET_NR_setresgid32:
ret = get_errno(setresgid(arg1, arg2, arg3));
break;
#endif
#ifdef TARGET_NR_getresgid32
case TARGET_NR_getresgid32:
{
gid_t rgid, egid, sgid;
ret = get_errno(getresgid(&rgid, &egid, &sgid));
if (!is_error(ret)) {
if (put_user_u32(rgid, arg1)
|| put_user_u32(egid, arg2)
|| put_user_u32(sgid, arg3))
goto efault;
}
}
break;
#endif
#ifdef TARGET_NR_chown32
case TARGET_NR_chown32:
if (!(VAR_2 = lock_user_string(arg1)))
goto efault;
ret = get_errno(chown(VAR_2, arg2, arg3));
unlock_user(VAR_2, arg1, 0);
break;
#endif
#ifdef TARGET_NR_setuid32
case TARGET_NR_setuid32:
ret = get_errno(setuid(arg1));
break;
#endif
#ifdef TARGET_NR_setgid32
case TARGET_NR_setgid32:
ret = get_errno(setgid(arg1));
break;
#endif
#ifdef TARGET_NR_setfsuid32
case TARGET_NR_setfsuid32:
ret = get_errno(setfsuid(arg1));
break;
#endif
#ifdef TARGET_NR_setfsgid32
case TARGET_NR_setfsgid32:
ret = get_errno(setfsgid(arg1));
break;
#endif
case TARGET_NR_pivot_root:
goto unimplemented;
#ifdef TARGET_NR_mincore
case TARGET_NR_mincore:
{
void *a;
ret = -TARGET_EFAULT;
if (!(a = lock_user(VERIFY_READ, arg1,arg2, 0)))
goto efault;
if (!(VAR_2 = lock_user_string(arg3)))
goto mincore_fail;
ret = get_errno(mincore(a, arg2, VAR_2));
unlock_user(VAR_2, arg3, ret);
mincore_fail:
unlock_user(a, arg1, 0);
}
break;
#endif
#ifdef TARGET_NR_arm_fadvise64_64
case TARGET_NR_arm_fadvise64_64:
{
abi_long VAR_23;
VAR_23 = arg3;
arg3 = arg4;
arg4 = VAR_23;
}
#endif
#if defined(TARGET_NR_fadvise64_64) || defined(TARGET_NR_arm_fadvise64_64) || defined(TARGET_NR_fadvise64)
#ifdef TARGET_NR_fadvise64_64
case TARGET_NR_fadvise64_64:
#endif
#ifdef TARGET_NR_fadvise64
case TARGET_NR_fadvise64:
#endif
#ifdef TARGET_S390X
switch (arg4) {
case 4: arg4 = POSIX_FADV_NOREUSE + 1; break;
case 5: arg4 = POSIX_FADV_NOREUSE + 2; break;
case 6: arg4 = POSIX_FADV_DONTNEED; break;
case 7: arg4 = POSIX_FADV_NOREUSE; break;
default: break;
}
#endif
ret = -posix_fadvise(arg1, arg2, arg3, arg4);
break;
#endif
#ifdef TARGET_NR_madvise
case TARGET_NR_madvise:
ret = get_errno(0);
break;
#endif
#if TARGET_ABI_BITS == 32
case TARGET_NR_fcntl64:
{
int cmd;
struct flock64 fl;
struct target_flock64 *target_fl;
#ifdef TARGET_ARM
struct target_eabi_flock64 *target_efl;
#endif
cmd = target_to_host_fcntl_cmd(arg2);
if (cmd == -TARGET_EINVAL)
return cmd;
switch(arg2) {
case TARGET_F_GETLK64:
#ifdef TARGET_ARM
if (((CPUARMState *)cpu_env)->eabi) {
if (!lock_user_struct(VERIFY_READ, target_efl, arg3, 1))
goto efault;
fl.l_type = tswap16(target_efl->l_type);
fl.l_whence = tswap16(target_efl->l_whence);
fl.l_start = tswap64(target_efl->l_start);
fl.l_len = tswap64(target_efl->l_len);
fl.l_pid = tswap32(target_efl->l_pid);
unlock_user_struct(target_efl, arg3, 0);
} else
#endif
{
if (!lock_user_struct(VERIFY_READ, target_fl, arg3, 1))
goto efault;
fl.l_type = tswap16(target_fl->l_type);
fl.l_whence = tswap16(target_fl->l_whence);
fl.l_start = tswap64(target_fl->l_start);
fl.l_len = tswap64(target_fl->l_len);
fl.l_pid = tswap32(target_fl->l_pid);
unlock_user_struct(target_fl, arg3, 0);
}
ret = get_errno(fcntl(arg1, cmd, &fl));
if (ret == 0) {
#ifdef TARGET_ARM
if (((CPUARMState *)cpu_env)->eabi) {
if (!lock_user_struct(VERIFY_WRITE, target_efl, arg3, 0))
goto efault;
target_efl->l_type = tswap16(fl.l_type);
target_efl->l_whence = tswap16(fl.l_whence);
target_efl->l_start = tswap64(fl.l_start);
target_efl->l_len = tswap64(fl.l_len);
target_efl->l_pid = tswap32(fl.l_pid);
unlock_user_struct(target_efl, arg3, 1);
} else
#endif
{
if (!lock_user_struct(VERIFY_WRITE, target_fl, arg3, 0))
goto efault;
target_fl->l_type = tswap16(fl.l_type);
target_fl->l_whence = tswap16(fl.l_whence);
target_fl->l_start = tswap64(fl.l_start);
target_fl->l_len = tswap64(fl.l_len);
target_fl->l_pid = tswap32(fl.l_pid);
unlock_user_struct(target_fl, arg3, 1);
}
}
break;
case TARGET_F_SETLK64:
case TARGET_F_SETLKW64:
#ifdef TARGET_ARM
if (((CPUARMState *)cpu_env)->eabi) {
if (!lock_user_struct(VERIFY_READ, target_efl, arg3, 1))
goto efault;
fl.l_type = tswap16(target_efl->l_type);
fl.l_whence = tswap16(target_efl->l_whence);
fl.l_start = tswap64(target_efl->l_start);
fl.l_len = tswap64(target_efl->l_len);
fl.l_pid = tswap32(target_efl->l_pid);
unlock_user_struct(target_efl, arg3, 0);
} else
#endif
{
if (!lock_user_struct(VERIFY_READ, target_fl, arg3, 1))
goto efault;
fl.l_type = tswap16(target_fl->l_type);
fl.l_whence = tswap16(target_fl->l_whence);
fl.l_start = tswap64(target_fl->l_start);
fl.l_len = tswap64(target_fl->l_len);
fl.l_pid = tswap32(target_fl->l_pid);
unlock_user_struct(target_fl, arg3, 0);
}
ret = get_errno(fcntl(arg1, cmd, &fl));
break;
default:
ret = do_fcntl(arg1, arg2, arg3);
break;
}
break;
}
#endif
#ifdef TARGET_NR_cacheflush
case TARGET_NR_cacheflush:
ret = 0;
break;
#endif
#ifdef TARGET_NR_security
case TARGET_NR_security:
goto unimplemented;
#endif
#ifdef TARGET_NR_getpagesize
case TARGET_NR_getpagesize:
ret = TARGET_PAGE_SIZE;
break;
#endif
case TARGET_NR_gettid:
ret = get_errno(gettid());
break;
#ifdef TARGET_NR_readahead
case TARGET_NR_readahead:
#if TARGET_ABI_BITS == 32
#ifdef TARGET_ARM
if (((CPUARMState *)cpu_env)->eabi)
{
arg2 = arg3;
arg3 = arg4;
arg4 = arg5;
}
#endif
ret = get_errno(readahead(arg1, ((off64_t)arg3 << 32) | arg2, arg4));
#else
ret = get_errno(readahead(arg1, arg2, arg3));
#endif
break;
#endif
#ifdef TARGET_NR_setxattr
case TARGET_NR_setxattr:
case TARGET_NR_lsetxattr:
case TARGET_NR_fsetxattr:
case TARGET_NR_getxattr:
case TARGET_NR_lgetxattr:
case TARGET_NR_fgetxattr:
case TARGET_NR_listxattr:
case TARGET_NR_llistxattr:
case TARGET_NR_flistxattr:
case TARGET_NR_removexattr:
case TARGET_NR_lremovexattr:
case TARGET_NR_fremovexattr:
ret = -TARGET_EOPNOTSUPP;
break;
#endif
#ifdef TARGET_NR_set_thread_area
case TARGET_NR_set_thread_area:
#if defined(TARGET_MIPS)
((CPUMIPSState *) cpu_env)->tls_value = arg1;
ret = 0;
break;
#elif defined(TARGET_CRIS)
if (arg1 & 0xff)
ret = -TARGET_EINVAL;
else {
((CPUCRISState *) cpu_env)->pregs[PR_PID] = arg1;
ret = 0;
}
break;
#elif defined(TARGET_I386) && defined(TARGET_ABI32)
ret = do_set_thread_area(cpu_env, arg1);
break;
#else
goto unimplemented_nowarn;
#endif
#endif
#ifdef TARGET_NR_get_thread_area
case TARGET_NR_get_thread_area:
#if defined(TARGET_I386) && defined(TARGET_ABI32)
ret = do_get_thread_area(cpu_env, arg1);
#else
goto unimplemented_nowarn;
#endif
#endif
#ifdef TARGET_NR_getdomainname
case TARGET_NR_getdomainname:
goto unimplemented_nowarn;
#endif
#ifdef TARGET_NR_clock_gettime
case TARGET_NR_clock_gettime:
{
struct timespec VAR_42;
ret = get_errno(clock_gettime(arg1, &VAR_42));
if (!is_error(ret)) {
host_to_target_timespec(arg2, &VAR_42);
}
break;
}
#endif
#ifdef TARGET_NR_clock_getres
case TARGET_NR_clock_getres:
{
struct timespec VAR_42;
ret = get_errno(clock_getres(arg1, &VAR_42));
if (!is_error(ret)) {
host_to_target_timespec(arg2, &VAR_42);
}
break;
}
#endif
#ifdef TARGET_NR_clock_nanosleep
case TARGET_NR_clock_nanosleep:
{
struct timespec VAR_42;
target_to_host_timespec(&VAR_42, arg3);
ret = get_errno(clock_nanosleep(arg1, arg2, &VAR_42, arg4 ? &VAR_42 : NULL));
if (arg4)
host_to_target_timespec(arg4, &VAR_42);
break;
}
#endif
#if defined(TARGET_NR_set_tid_address) && defined(__NR_set_tid_address)
case TARGET_NR_set_tid_address:
ret = get_errno(set_tid_address((int *)g2h(arg1)));
break;
#endif
#if defined(TARGET_NR_tkill) && defined(__NR_tkill)
case TARGET_NR_tkill:
ret = get_errno(sys_tkill((int)arg1, target_to_host_signal(arg2)));
break;
#endif
#if defined(TARGET_NR_tgkill) && defined(__NR_tgkill)
case TARGET_NR_tgkill:
ret = get_errno(sys_tgkill((int)arg1, (int)arg2,
target_to_host_signal(arg3)));
break;
#endif
#ifdef TARGET_NR_set_robust_list
case TARGET_NR_set_robust_list:
goto unimplemented_nowarn;
#endif
#if defined(TARGET_NR_utimensat) && defined(__NR_utimensat)
case TARGET_NR_utimensat:
{
struct timespec *tsp, VAR_42[2];
if (!arg3) {
tsp = NULL;
} else {
target_to_host_timespec(VAR_42, arg3);
target_to_host_timespec(VAR_42+1, arg3+sizeof(struct target_timespec));
tsp = VAR_42;
}
if (!arg2)
ret = get_errno(sys_utimensat(arg1, NULL, tsp, arg4));
else {
if (!(VAR_2 = lock_user_string(arg2))) {
ret = -TARGET_EFAULT;
goto fail;
}
ret = get_errno(sys_utimensat(arg1, path(VAR_2), tsp, arg4));
unlock_user(VAR_2, arg2, 0);
}
}
break;
#endif
#if defined(CONFIG_USE_NPTL)
case TARGET_NR_futex:
ret = do_futex(arg1, arg2, arg3, arg4, arg5, arg6);
break;
#endif
#if defined(TARGET_NR_inotify_init) && defined(__NR_inotify_init)
case TARGET_NR_inotify_init:
ret = get_errno(sys_inotify_init());
break;
#endif
#if defined(TARGET_NR_inotify_add_watch) && defined(__NR_inotify_add_watch)
case TARGET_NR_inotify_add_watch:
VAR_2 = lock_user_string(arg2);
ret = get_errno(sys_inotify_add_watch(arg1, path(VAR_2), arg3));
unlock_user(VAR_2, arg2, 0);
break;
#endif
#if defined(TARGET_NR_inotify_rm_watch) && defined(__NR_inotify_rm_watch)
case TARGET_NR_inotify_rm_watch:
ret = get_errno(sys_inotify_rm_watch(arg1, arg2));
break;
#endif
#if defined(TARGET_NR_mq_open) && defined(__NR_mq_open)
case TARGET_NR_mq_open:
{
struct mq_attr posix_mq_attr;
VAR_2 = lock_user_string(arg1 - 1);
if (arg4 != 0)
copy_from_user_mq_attr (&posix_mq_attr, arg4);
ret = get_errno(mq_open(VAR_2, arg2, arg3, &posix_mq_attr));
unlock_user (VAR_2, arg1, 0);
}
break;
case TARGET_NR_mq_unlink:
VAR_2 = lock_user_string(arg1 - 1);
ret = get_errno(mq_unlink(VAR_2));
unlock_user (VAR_2, arg1, 0);
break;
case TARGET_NR_mq_timedsend:
{
struct timespec VAR_42;
VAR_2 = lock_user (VERIFY_READ, arg2, arg3, 1);
if (arg5 != 0) {
target_to_host_timespec(&VAR_42, arg5);
ret = get_errno(mq_timedsend(arg1, VAR_2, arg3, arg4, &VAR_42));
host_to_target_timespec(arg5, &VAR_42);
}
else
ret = get_errno(mq_send(arg1, VAR_2, arg3, arg4));
unlock_user (VAR_2, arg2, arg3);
}
break;
case TARGET_NR_mq_timedreceive:
{
struct timespec VAR_42;
unsigned int prio;
VAR_2 = lock_user (VERIFY_READ, arg2, arg3, 1);
if (arg5 != 0) {
target_to_host_timespec(&VAR_42, arg5);
ret = get_errno(mq_timedreceive(arg1, VAR_2, arg3, &prio, &VAR_42));
host_to_target_timespec(arg5, &VAR_42);
}
else
ret = get_errno(mq_receive(arg1, VAR_2, arg3, &prio));
unlock_user (VAR_2, arg2, arg3);
if (arg4 != 0)
put_user_u32(prio, arg4);
}
break;
case TARGET_NR_mq_getsetattr:
{
struct mq_attr posix_mq_attr_in, posix_mq_attr_out;
ret = 0;
if (arg3 != 0) {
ret = mq_getattr(arg1, &posix_mq_attr_out);
copy_to_user_mq_attr(arg3, &posix_mq_attr_out);
}
if (arg2 != 0) {
copy_from_user_mq_attr(&posix_mq_attr_in, arg2);
ret |= mq_setattr(arg1, &posix_mq_attr_in, &posix_mq_attr_out);
}
}
break;
#endif
#ifdef CONFIG_SPLICE
#ifdef TARGET_NR_tee
case TARGET_NR_tee:
{
ret = get_errno(tee(arg1,arg2,arg3,arg4));
}
break;
#endif
#ifdef TARGET_NR_splice
case TARGET_NR_splice:
{
loff_t loff_in, loff_out;
loff_t *ploff_in = NULL, *ploff_out = NULL;
if(arg2) {
get_user_u64(loff_in, arg2);
ploff_in = &loff_in;
}
if(arg4) {
get_user_u64(loff_out, arg2);
ploff_out = &loff_out;
}
ret = get_errno(splice(arg1, ploff_in, arg3, ploff_out, arg5, arg6));
}
break;
#endif
#ifdef TARGET_NR_vmsplice
case TARGET_NR_vmsplice:
{
int VAR_40 = arg3;
struct iovec *VAR_40;
VAR_40 = alloca(VAR_40 * sizeof(struct iovec));
if (lock_iovec(VERIFY_READ, VAR_40, arg2, VAR_40, 1) < 0)
goto efault;
ret = get_errno(vmsplice(arg1, VAR_40, VAR_40, arg4));
unlock_iovec(VAR_40, arg2, VAR_40, 0);
}
break;
#endif
#endif
#ifdef CONFIG_EVENTFD
#if defined(TARGET_NR_eventfd)
case TARGET_NR_eventfd:
ret = get_errno(eventfd(arg1, 0));
break;
#endif
#if defined(TARGET_NR_eventfd2)
case TARGET_NR_eventfd2:
ret = get_errno(eventfd(arg1, arg2));
break;
#endif
#endif
default:
unimplemented:
gemu_log("qemu: Unsupported syscall: %d\n", num);
#if defined(TARGET_NR_setxattr) || defined(TARGET_NR_get_thread_area) || defined(TARGET_NR_getdomainname) || defined(TARGET_NR_set_robust_list)
unimplemented_nowarn:
#endif
ret = -TARGET_ENOSYS;
break;
}
fail:
#ifdef DEBUG
gemu_log(" = " TARGET_ABI_FMT_ld "\n", ret);
#endif
if(do_strace)
print_syscall_ret(num, ret);
return ret;
efault:
ret = -TARGET_EFAULT;
goto fail;
} | [
"abi_long FUNC_0(void *cpu_env, int num, abi_long arg1,\nabi_long arg2, abi_long arg3, abi_long arg4,\nabi_long arg5, abi_long arg6)\n{",
"abi_long ret;",
"struct stat VAR_0;",
"struct statfs VAR_1;",
"void *VAR_2;",
"#ifdef DEBUG\ngemu_log(\"syscall %d\", num);",
"#endif\nif(do_strace)\nprint_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6);",
"switch(num) {",
"case TARGET_NR_exit:\n#ifdef CONFIG_USE_NPTL\nif (first_cpu->next_cpu) {",
"TaskState *VAR_42;",
"CPUState **lastp;",
"CPUState *VAR_2;",
"cpu_list_lock();",
"lastp = &first_cpu;",
"VAR_2 = first_cpu;",
"while (VAR_2 && VAR_2 != (CPUState *)cpu_env) {",
"lastp = &VAR_2->next_cpu;",
"VAR_2 = VAR_2->next_cpu;",
"}",
"if (!VAR_2)\nabort();",
"*lastp = VAR_2->next_cpu;",
"cpu_list_unlock();",
"VAR_42 = ((CPUState *)cpu_env)->opaque;",
"if (VAR_42->child_tidptr) {",
"put_user_u32(0, VAR_42->child_tidptr);",
"sys_futex(g2h(VAR_42->child_tidptr), FUTEX_WAKE, INT_MAX,\nNULL, NULL, 0);",
"}",
"pthread_exit(NULL);",
"}",
"#endif\n#ifdef TARGET_GPROF\n_mcleanup();",
"#endif\ngdb_exit(cpu_env, arg1);",
"_exit(arg1);",
"ret = 0;",
"break;",
"case TARGET_NR_read:\nif (arg3 == 0)\nret = 0;",
"else {",
"if (!(VAR_2 = lock_user(VERIFY_WRITE, arg2, arg3, 0)))\ngoto efault;",
"ret = get_errno(read(arg1, VAR_2, arg3));",
"unlock_user(VAR_2, arg2, ret);",
"}",
"break;",
"case TARGET_NR_write:\nif (!(VAR_2 = lock_user(VERIFY_READ, arg2, arg3, 1)))\ngoto efault;",
"ret = get_errno(write(arg1, VAR_2, arg3));",
"unlock_user(VAR_2, arg2, 0);",
"break;",
"case TARGET_NR_open:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;",
"ret = get_errno(open(path(VAR_2),\ntarget_to_host_bitmask(arg2, fcntl_flags_tbl),\narg3));",
"unlock_user(VAR_2, arg1, 0);",
"break;",
"#if defined(TARGET_NR_openat) && defined(__NR_openat)\ncase TARGET_NR_openat:\nif (!(VAR_2 = lock_user_string(arg2)))\ngoto efault;",
"ret = get_errno(sys_openat(arg1,\npath(VAR_2),\ntarget_to_host_bitmask(arg3, fcntl_flags_tbl),\narg4));",
"unlock_user(VAR_2, arg2, 0);",
"break;",
"#endif\ncase TARGET_NR_close:\nret = get_errno(close(arg1));",
"break;",
"case TARGET_NR_brk:\nret = do_brk(arg1);",
"break;",
"case TARGET_NR_fork:\nret = get_errno(do_fork(cpu_env, SIGCHLD, 0, 0, 0, 0));",
"break;",
"#ifdef TARGET_NR_waitpid\ncase TARGET_NR_waitpid:\n{",
"int VAR_30;",
"ret = get_errno(waitpid(arg1, &VAR_30, arg3));",
"if (!is_error(ret) && arg2\n&& put_user_s32(host_to_target_waitstatus(VAR_30), arg2))\ngoto efault;",
"}",
"break;",
"#endif\n#ifdef TARGET_NR_waitid\ncase TARGET_NR_waitid:\n{",
"siginfo_t info;",
"info.si_pid = 0;",
"ret = get_errno(waitid(arg1, arg2, &info, arg4));",
"if (!is_error(ret) && arg3 && info.si_pid != 0) {",
"if (!(VAR_2 = lock_user(VERIFY_WRITE, arg3, sizeof(target_siginfo_t), 0)))\ngoto efault;",
"host_to_target_siginfo(VAR_2, &info);",
"unlock_user(VAR_2, arg3, sizeof(target_siginfo_t));",
"}",
"}",
"break;",
"#endif\n#ifdef TARGET_NR_creat\ncase TARGET_NR_creat:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;",
"ret = get_errno(creat(VAR_2, arg2));",
"unlock_user(VAR_2, arg1, 0);",
"break;",
"#endif\ncase TARGET_NR_link:\n{",
"void * VAR_23;",
"VAR_2 = lock_user_string(arg1);",
"VAR_23 = lock_user_string(arg2);",
"if (!VAR_2 || !VAR_23)\nret = -TARGET_EFAULT;",
"else\nret = get_errno(link(VAR_2, VAR_23));",
"unlock_user(VAR_23, arg2, 0);",
"unlock_user(VAR_2, arg1, 0);",
"}",
"break;",
"#if defined(TARGET_NR_linkat) && defined(__NR_linkat)\ncase TARGET_NR_linkat:\n{",
"void * VAR_23 = NULL;",
"if (!arg2 || !arg4)\ngoto efault;",
"VAR_2 = lock_user_string(arg2);",
"VAR_23 = lock_user_string(arg4);",
"if (!VAR_2 || !VAR_23)\nret = -TARGET_EFAULT;",
"else\nret = get_errno(sys_linkat(arg1, VAR_2, arg3, VAR_23, arg5));",
"unlock_user(VAR_2, arg2, 0);",
"unlock_user(VAR_23, arg4, 0);",
"}",
"break;",
"#endif\ncase TARGET_NR_unlink:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;",
"ret = get_errno(unlink(VAR_2));",
"unlock_user(VAR_2, arg1, 0);",
"break;",
"#if defined(TARGET_NR_unlinkat) && defined(__NR_unlinkat)\ncase TARGET_NR_unlinkat:\nif (!(VAR_2 = lock_user_string(arg2)))\ngoto efault;",
"ret = get_errno(sys_unlinkat(arg1, VAR_2, arg3));",
"unlock_user(VAR_2, arg2, 0);",
"break;",
"#endif\ncase TARGET_NR_execve:\n{",
"char **VAR_4, **VAR_5;",
"int VAR_6, VAR_7;",
"abi_ulong gp;",
"abi_ulong guest_argp;",
"abi_ulong guest_envp;",
"abi_ulong addr;",
"char **VAR_8;",
"VAR_6 = 0;",
"guest_argp = arg2;",
"for (gp = guest_argp; gp; gp += sizeof(abi_ulong)) {",
"if (get_user_ual(addr, gp))\ngoto efault;",
"if (!addr)\nbreak;",
"VAR_6++;",
"}",
"VAR_7 = 0;",
"guest_envp = arg3;",
"for (gp = guest_envp; gp; gp += sizeof(abi_ulong)) {",
"if (get_user_ual(addr, gp))\ngoto efault;",
"if (!addr)\nbreak;",
"VAR_7++;",
"}",
"VAR_4 = alloca((VAR_6 + 1) * sizeof(void *));",
"VAR_5 = alloca((VAR_7 + 1) * sizeof(void *));",
"for (gp = guest_argp, VAR_8 = VAR_4; gp;",
"gp += sizeof(abi_ulong), VAR_8++) {",
"if (get_user_ual(addr, gp))\ngoto execve_efault;",
"if (!addr)\nbreak;",
"if (!(*VAR_8 = lock_user_string(addr)))\ngoto execve_efault;",
"}",
"*VAR_8 = NULL;",
"for (gp = guest_envp, VAR_8 = VAR_5; gp;",
"gp += sizeof(abi_ulong), VAR_8++) {",
"if (get_user_ual(addr, gp))\ngoto execve_efault;",
"if (!addr)\nbreak;",
"if (!(*VAR_8 = lock_user_string(addr)))\ngoto execve_efault;",
"}",
"*VAR_8 = NULL;",
"if (!(VAR_2 = lock_user_string(arg1)))\ngoto execve_efault;",
"ret = get_errno(execve(VAR_2, VAR_4, VAR_5));",
"unlock_user(VAR_2, arg1, 0);",
"goto execve_end;",
"execve_efault:\nret = -TARGET_EFAULT;",
"execve_end:\nfor (gp = guest_argp, VAR_8 = VAR_4; *VAR_8;",
"gp += sizeof(abi_ulong), VAR_8++) {",
"if (get_user_ual(addr, gp)\n|| !addr)\nbreak;",
"unlock_user(*VAR_8, addr, 0);",
"}",
"for (gp = guest_envp, VAR_8 = VAR_5; *VAR_8;",
"gp += sizeof(abi_ulong), VAR_8++) {",
"if (get_user_ual(addr, gp)\n|| !addr)\nbreak;",
"unlock_user(*VAR_8, addr, 0);",
"}",
"}",
"break;",
"case TARGET_NR_chdir:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;",
"ret = get_errno(chdir(VAR_2));",
"unlock_user(VAR_2, arg1, 0);",
"break;",
"#ifdef TARGET_NR_time\ncase TARGET_NR_time:\n{",
"time_t host_time;",
"ret = get_errno(time(&host_time));",
"if (!is_error(ret)\n&& arg1\n&& put_user_sal(host_time, arg1))\ngoto efault;",
"}",
"break;",
"#endif\ncase TARGET_NR_mknod:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;",
"ret = get_errno(mknod(VAR_2, arg2, arg3));",
"unlock_user(VAR_2, arg1, 0);",
"break;",
"#if defined(TARGET_NR_mknodat) && defined(__NR_mknodat)\ncase TARGET_NR_mknodat:\nif (!(VAR_2 = lock_user_string(arg2)))\ngoto efault;",
"ret = get_errno(sys_mknodat(arg1, VAR_2, arg3, arg4));",
"unlock_user(VAR_2, arg2, 0);",
"break;",
"#endif\ncase TARGET_NR_chmod:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;",
"ret = get_errno(chmod(VAR_2, arg2));",
"unlock_user(VAR_2, arg1, 0);",
"break;",
"#ifdef TARGET_NR_break\ncase TARGET_NR_break:\ngoto unimplemented;",
"#endif\n#ifdef TARGET_NR_oldstat\ncase TARGET_NR_oldstat:\ngoto unimplemented;",
"#endif\ncase TARGET_NR_lseek:\nret = get_errno(lseek(arg1, arg2, arg3));",
"break;",
"#ifdef TARGET_NR_getxpid\ncase TARGET_NR_getxpid:\n#else\ncase TARGET_NR_getpid:\n#endif\nret = get_errno(getpid());",
"break;",
"case TARGET_NR_mount:\n{",
"void *VAR_23, *VAR_9;",
"VAR_2 = lock_user_string(arg1);",
"VAR_23 = lock_user_string(arg2);",
"VAR_9 = lock_user_string(arg3);",
"if (!VAR_2 || !VAR_23 || !VAR_9)\nret = -TARGET_EFAULT;",
"else\nret = get_errno(mount(VAR_2, VAR_23, VAR_9, (unsigned long)arg4, g2h(arg5)));",
"unlock_user(VAR_2, arg1, 0);",
"unlock_user(VAR_23, arg2, 0);",
"unlock_user(VAR_9, arg3, 0);",
"break;",
"}",
"#ifdef TARGET_NR_umount\ncase TARGET_NR_umount:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;",
"ret = get_errno(umount(VAR_2));",
"unlock_user(VAR_2, arg1, 0);",
"break;",
"#endif\n#ifdef TARGET_NR_stime\ncase TARGET_NR_stime:\n{",
"time_t host_time;",
"if (get_user_sal(host_time, arg1))\ngoto efault;",
"ret = get_errno(stime(&host_time));",
"}",
"break;",
"#endif\ncase TARGET_NR_ptrace:\ngoto unimplemented;",
"#ifdef TARGET_NR_alarm\ncase TARGET_NR_alarm:\nret = alarm(arg1);",
"break;",
"#endif\n#ifdef TARGET_NR_oldfstat\ncase TARGET_NR_oldfstat:\ngoto unimplemented;",
"#endif\n#ifdef TARGET_NR_pause\ncase TARGET_NR_pause:\nret = get_errno(pause());",
"break;",
"#endif\n#ifdef TARGET_NR_utime\ncase TARGET_NR_utime:\n{",
"struct utimbuf tbuf, *host_tbuf;",
"struct target_utimbuf *target_tbuf;",
"if (arg2) {",
"if (!lock_user_struct(VERIFY_READ, target_tbuf, arg2, 1))\ngoto efault;",
"tbuf.actime = tswapl(target_tbuf->actime);",
"tbuf.modtime = tswapl(target_tbuf->modtime);",
"unlock_user_struct(target_tbuf, arg2, 0);",
"host_tbuf = &tbuf;",
"} else {",
"host_tbuf = NULL;",
"}",
"if (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;",
"ret = get_errno(utime(VAR_2, host_tbuf));",
"unlock_user(VAR_2, arg1, 0);",
"}",
"break;",
"#endif\ncase TARGET_NR_utimes:\n{",
"struct timeval *VAR_10, VAR_23[2];",
"if (arg2) {",
"if (copy_from_user_timeval(&VAR_23[0], arg2)\n|| copy_from_user_timeval(&VAR_23[1],\narg2 + sizeof(struct target_timeval)))\ngoto efault;",
"VAR_10 = VAR_23;",
"} else {",
"VAR_10 = NULL;",
"}",
"if (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;",
"ret = get_errno(utimes(VAR_2, VAR_10));",
"unlock_user(VAR_2, arg1, 0);",
"}",
"break;",
"#if defined(TARGET_NR_futimesat) && defined(__NR_futimesat)\ncase TARGET_NR_futimesat:\n{",
"struct timeval *VAR_10, VAR_23[2];",
"if (arg3) {",
"if (copy_from_user_timeval(&VAR_23[0], arg3)\n|| copy_from_user_timeval(&VAR_23[1],\narg3 + sizeof(struct target_timeval)))\ngoto efault;",
"VAR_10 = VAR_23;",
"} else {",
"VAR_10 = NULL;",
"}",
"if (!(VAR_2 = lock_user_string(arg2)))\ngoto efault;",
"ret = get_errno(sys_futimesat(arg1, path(VAR_2), VAR_10));",
"unlock_user(VAR_2, arg2, 0);",
"}",
"break;",
"#endif\n#ifdef TARGET_NR_stty\ncase TARGET_NR_stty:\ngoto unimplemented;",
"#endif\n#ifdef TARGET_NR_gtty\ncase TARGET_NR_gtty:\ngoto unimplemented;",
"#endif\ncase TARGET_NR_access:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;",
"ret = get_errno(access(path(VAR_2), arg2));",
"unlock_user(VAR_2, arg1, 0);",
"break;",
"#if defined(TARGET_NR_faccessat) && defined(__NR_faccessat)\ncase TARGET_NR_faccessat:\nif (!(VAR_2 = lock_user_string(arg2)))\ngoto efault;",
"ret = get_errno(sys_faccessat(arg1, VAR_2, arg3));",
"unlock_user(VAR_2, arg2, 0);",
"break;",
"#endif\n#ifdef TARGET_NR_nice\ncase TARGET_NR_nice:\nret = get_errno(nice(arg1));",
"break;",
"#endif\n#ifdef TARGET_NR_ftime\ncase TARGET_NR_ftime:\ngoto unimplemented;",
"#endif\ncase TARGET_NR_sync:\nsync();",
"ret = 0;",
"break;",
"case TARGET_NR_kill:\nret = get_errno(kill(arg1, target_to_host_signal(arg2)));",
"break;",
"case TARGET_NR_rename:\n{",
"void *VAR_23;",
"VAR_2 = lock_user_string(arg1);",
"VAR_23 = lock_user_string(arg2);",
"if (!VAR_2 || !VAR_23)\nret = -TARGET_EFAULT;",
"else\nret = get_errno(rename(VAR_2, VAR_23));",
"unlock_user(VAR_23, arg2, 0);",
"unlock_user(VAR_2, arg1, 0);",
"}",
"break;",
"#if defined(TARGET_NR_renameat) && defined(__NR_renameat)\ncase TARGET_NR_renameat:\n{",
"void *VAR_23;",
"VAR_2 = lock_user_string(arg2);",
"VAR_23 = lock_user_string(arg4);",
"if (!VAR_2 || !VAR_23)\nret = -TARGET_EFAULT;",
"else\nret = get_errno(sys_renameat(arg1, VAR_2, arg3, VAR_23));",
"unlock_user(VAR_23, arg4, 0);",
"unlock_user(VAR_2, arg2, 0);",
"}",
"break;",
"#endif\ncase TARGET_NR_mkdir:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;",
"ret = get_errno(mkdir(VAR_2, arg2));",
"unlock_user(VAR_2, arg1, 0);",
"break;",
"#if defined(TARGET_NR_mkdirat) && defined(__NR_mkdirat)\ncase TARGET_NR_mkdirat:\nif (!(VAR_2 = lock_user_string(arg2)))\ngoto efault;",
"ret = get_errno(sys_mkdirat(arg1, VAR_2, arg3));",
"unlock_user(VAR_2, arg2, 0);",
"break;",
"#endif\ncase TARGET_NR_rmdir:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;",
"ret = get_errno(rmdir(VAR_2));",
"unlock_user(VAR_2, arg1, 0);",
"break;",
"case TARGET_NR_dup:\nret = get_errno(dup(arg1));",
"break;",
"case TARGET_NR_pipe:\nret = do_pipe(cpu_env, arg1, 0);",
"break;",
"#ifdef TARGET_NR_pipe2\ncase TARGET_NR_pipe2:\nret = do_pipe(cpu_env, arg1, arg2);",
"break;",
"#endif\ncase TARGET_NR_times:\n{",
"struct target_tms *VAR_12;",
"struct VAR_13 VAR_13;",
"ret = get_errno(times(&VAR_13));",
"if (arg1) {",
"VAR_12 = lock_user(VERIFY_WRITE, arg1, sizeof(struct target_tms), 0);",
"if (!VAR_12)\ngoto efault;",
"VAR_12->tms_utime = tswapl(host_to_target_clock_t(VAR_13.tms_utime));",
"VAR_12->tms_stime = tswapl(host_to_target_clock_t(VAR_13.tms_stime));",
"VAR_12->tms_cutime = tswapl(host_to_target_clock_t(VAR_13.tms_cutime));",
"VAR_12->tms_cstime = tswapl(host_to_target_clock_t(VAR_13.tms_cstime));",
"}",
"if (!is_error(ret))\nret = host_to_target_clock_t(ret);",
"}",
"break;",
"#ifdef TARGET_NR_prof\ncase TARGET_NR_prof:\ngoto unimplemented;",
"#endif\n#ifdef TARGET_NR_signal\ncase TARGET_NR_signal:\ngoto unimplemented;",
"#endif\ncase TARGET_NR_acct:\nif (arg1 == 0) {",
"ret = get_errno(acct(NULL));",
"} else {",
"if (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;",
"ret = get_errno(acct(path(VAR_2)));",
"unlock_user(VAR_2, arg1, 0);",
"}",
"break;",
"#ifdef TARGET_NR_umount2\ncase TARGET_NR_umount2:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;",
"ret = get_errno(umount2(VAR_2, arg2));",
"unlock_user(VAR_2, arg1, 0);",
"break;",
"#endif\n#ifdef TARGET_NR_lock\ncase TARGET_NR_lock:\ngoto unimplemented;",
"#endif\ncase TARGET_NR_ioctl:\nret = do_ioctl(arg1, arg2, arg3);",
"break;",
"case TARGET_NR_fcntl:\nret = do_fcntl(arg1, arg2, arg3);",
"break;",
"#ifdef TARGET_NR_mpx\ncase TARGET_NR_mpx:\ngoto unimplemented;",
"#endif\ncase TARGET_NR_setpgid:\nret = get_errno(setpgid(arg1, arg2));",
"break;",
"#ifdef TARGET_NR_ulimit\ncase TARGET_NR_ulimit:\ngoto unimplemented;",
"#endif\n#ifdef TARGET_NR_oldolduname\ncase TARGET_NR_oldolduname:\ngoto unimplemented;",
"#endif\ncase TARGET_NR_umask:\nret = get_errno(umask(arg1));",
"break;",
"case TARGET_NR_chroot:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;",
"ret = get_errno(chroot(VAR_2));",
"unlock_user(VAR_2, arg1, 0);",
"break;",
"case TARGET_NR_ustat:\ngoto unimplemented;",
"case TARGET_NR_dup2:\nret = get_errno(dup2(arg1, arg2));",
"break;",
"#ifdef TARGET_NR_getppid\ncase TARGET_NR_getppid:\nret = get_errno(getppid());",
"break;",
"#endif\ncase TARGET_NR_getpgrp:\nret = get_errno(getpgrp());",
"break;",
"case TARGET_NR_setsid:\nret = get_errno(setsid());",
"break;",
"#ifdef TARGET_NR_sigaction\ncase TARGET_NR_sigaction:\n{",
"#if !defined(TARGET_MIPS)\nstruct target_old_sigaction *old_act;",
"struct target_sigaction VAR_14, VAR_15, *pact;",
"if (arg2) {",
"if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1))\ngoto efault;",
"VAR_14._sa_handler = old_act->_sa_handler;",
"target_siginitset(&VAR_14.sa_mask, old_act->sa_mask);",
"VAR_14.sa_flags = old_act->sa_flags;",
"VAR_14.sa_restorer = old_act->sa_restorer;",
"unlock_user_struct(old_act, arg2, 0);",
"pact = &VAR_14;",
"} else {",
"pact = NULL;",
"}",
"ret = get_errno(do_sigaction(arg1, pact, &VAR_15));",
"if (!is_error(ret) && arg3) {",
"if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0))\ngoto efault;",
"old_act->_sa_handler = VAR_15._sa_handler;",
"old_act->sa_mask = VAR_15.sa_mask.sig[0];",
"old_act->sa_flags = VAR_15.sa_flags;",
"old_act->sa_restorer = VAR_15.sa_restorer;",
"unlock_user_struct(old_act, arg3, 1);",
"}",
"#else\nstruct target_sigaction VAR_14, VAR_15, *pact, *old_act;",
"if (arg2) {",
"if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1))\ngoto efault;",
"VAR_14._sa_handler = old_act->_sa_handler;",
"target_siginitset(&VAR_14.sa_mask, old_act->sa_mask.sig[0]);",
"VAR_14.sa_flags = old_act->sa_flags;",
"unlock_user_struct(old_act, arg2, 0);",
"pact = &VAR_14;",
"} else {",
"pact = NULL;",
"}",
"ret = get_errno(do_sigaction(arg1, pact, &VAR_15));",
"if (!is_error(ret) && arg3) {",
"if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0))\ngoto efault;",
"old_act->_sa_handler = VAR_15._sa_handler;",
"old_act->sa_flags = VAR_15.sa_flags;",
"old_act->sa_mask.sig[0] = VAR_15.sa_mask.sig[0];",
"old_act->sa_mask.sig[1] = 0;",
"old_act->sa_mask.sig[2] = 0;",
"old_act->sa_mask.sig[3] = 0;",
"unlock_user_struct(old_act, arg3, 1);",
"}",
"#endif\n}",
"break;",
"#endif\ncase TARGET_NR_rt_sigaction:\n{",
"struct target_sigaction *VAR_14;",
"struct target_sigaction *VAR_15;",
"if (arg2) {",
"if (!lock_user_struct(VERIFY_READ, VAR_14, arg2, 1))\ngoto efault;",
"} else",
"VAR_14 = NULL;",
"if (arg3) {",
"if (!lock_user_struct(VERIFY_WRITE, VAR_15, arg3, 0)) {",
"ret = -TARGET_EFAULT;",
"goto rt_sigaction_fail;",
"}",
"} else",
"VAR_15 = NULL;",
"ret = get_errno(do_sigaction(arg1, VAR_14, VAR_15));",
"rt_sigaction_fail:\nif (VAR_14)\nunlock_user_struct(VAR_14, arg2, 0);",
"if (VAR_15)\nunlock_user_struct(VAR_15, arg3, 1);",
"}",
"break;",
"#ifdef TARGET_NR_sgetmask\ncase TARGET_NR_sgetmask:\n{",
"sigset_t cur_set;",
"abi_ulong target_set;",
"sigprocmask(0, NULL, &cur_set);",
"host_to_target_old_sigset(&target_set, &cur_set);",
"ret = target_set;",
"}",
"break;",
"#endif\n#ifdef TARGET_NR_ssetmask\ncase TARGET_NR_ssetmask:\n{",
"sigset_t set, oset, cur_set;",
"abi_ulong target_set = arg1;",
"sigprocmask(0, NULL, &cur_set);",
"target_to_host_old_sigset(&set, &target_set);",
"sigorset(&set, &set, &cur_set);",
"sigprocmask(SIG_SETMASK, &set, &oset);",
"host_to_target_old_sigset(&target_set, &oset);",
"ret = target_set;",
"}",
"break;",
"#endif\n#ifdef TARGET_NR_sigprocmask\ncase TARGET_NR_sigprocmask:\n{",
"int VAR_16 = arg1;",
"sigset_t set, oldset, *set_ptr;",
"if (arg2) {",
"switch(VAR_16) {",
"case TARGET_SIG_BLOCK:\nVAR_16 = SIG_BLOCK;",
"break;",
"case TARGET_SIG_UNBLOCK:\nVAR_16 = SIG_UNBLOCK;",
"break;",
"case TARGET_SIG_SETMASK:\nVAR_16 = SIG_SETMASK;",
"break;",
"default:\nret = -TARGET_EINVAL;",
"goto fail;",
"}",
"if (!(VAR_2 = lock_user(VERIFY_READ, arg2, sizeof(target_sigset_t), 1)))\ngoto efault;",
"target_to_host_old_sigset(&set, VAR_2);",
"unlock_user(VAR_2, arg2, 0);",
"set_ptr = &set;",
"} else {",
"VAR_16 = 0;",
"set_ptr = NULL;",
"}",
"ret = get_errno(sigprocmask(arg1, set_ptr, &oldset));",
"if (!is_error(ret) && arg3) {",
"if (!(VAR_2 = lock_user(VERIFY_WRITE, arg3, sizeof(target_sigset_t), 0)))\ngoto efault;",
"host_to_target_old_sigset(VAR_2, &oldset);",
"unlock_user(VAR_2, arg3, sizeof(target_sigset_t));",
"}",
"}",
"break;",
"#endif\ncase TARGET_NR_rt_sigprocmask:\n{",
"int VAR_16 = arg1;",
"sigset_t set, oldset, *set_ptr;",
"if (arg2) {",
"switch(VAR_16) {",
"case TARGET_SIG_BLOCK:\nVAR_16 = SIG_BLOCK;",
"break;",
"case TARGET_SIG_UNBLOCK:\nVAR_16 = SIG_UNBLOCK;",
"break;",
"case TARGET_SIG_SETMASK:\nVAR_16 = SIG_SETMASK;",
"break;",
"default:\nret = -TARGET_EINVAL;",
"goto fail;",
"}",
"if (!(VAR_2 = lock_user(VERIFY_READ, arg2, sizeof(target_sigset_t), 1)))\ngoto efault;",
"target_to_host_sigset(&set, VAR_2);",
"unlock_user(VAR_2, arg2, 0);",
"set_ptr = &set;",
"} else {",
"VAR_16 = 0;",
"set_ptr = NULL;",
"}",
"ret = get_errno(sigprocmask(VAR_16, set_ptr, &oldset));",
"if (!is_error(ret) && arg3) {",
"if (!(VAR_2 = lock_user(VERIFY_WRITE, arg3, sizeof(target_sigset_t), 0)))\ngoto efault;",
"host_to_target_sigset(VAR_2, &oldset);",
"unlock_user(VAR_2, arg3, sizeof(target_sigset_t));",
"}",
"}",
"break;",
"#ifdef TARGET_NR_sigpending\ncase TARGET_NR_sigpending:\n{",
"sigset_t set;",
"ret = get_errno(sigpending(&set));",
"if (!is_error(ret)) {",
"if (!(VAR_2 = lock_user(VERIFY_WRITE, arg1, sizeof(target_sigset_t), 0)))\ngoto efault;",
"host_to_target_old_sigset(VAR_2, &set);",
"unlock_user(VAR_2, arg1, sizeof(target_sigset_t));",
"}",
"}",
"break;",
"#endif\ncase TARGET_NR_rt_sigpending:\n{",
"sigset_t set;",
"ret = get_errno(sigpending(&set));",
"if (!is_error(ret)) {",
"if (!(VAR_2 = lock_user(VERIFY_WRITE, arg1, sizeof(target_sigset_t), 0)))\ngoto efault;",
"host_to_target_sigset(VAR_2, &set);",
"unlock_user(VAR_2, arg1, sizeof(target_sigset_t));",
"}",
"}",
"break;",
"#ifdef TARGET_NR_sigsuspend\ncase TARGET_NR_sigsuspend:\n{",
"sigset_t set;",
"if (!(VAR_2 = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1)))\ngoto efault;",
"target_to_host_old_sigset(&set, VAR_2);",
"unlock_user(VAR_2, arg1, 0);",
"ret = get_errno(sigsuspend(&set));",
"}",
"break;",
"#endif\ncase TARGET_NR_rt_sigsuspend:\n{",
"sigset_t set;",
"if (!(VAR_2 = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1)))\ngoto efault;",
"target_to_host_sigset(&set, VAR_2);",
"unlock_user(VAR_2, arg1, 0);",
"ret = get_errno(sigsuspend(&set));",
"}",
"break;",
"case TARGET_NR_rt_sigtimedwait:\n{",
"sigset_t set;",
"struct timespec VAR_17, *VAR_18;",
"siginfo_t uinfo;",
"if (!(VAR_2 = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1)))\ngoto efault;",
"target_to_host_sigset(&set, VAR_2);",
"unlock_user(VAR_2, arg1, 0);",
"if (arg3) {",
"VAR_18 = &VAR_17;",
"target_to_host_timespec(VAR_18, arg3);",
"} else {",
"VAR_18 = NULL;",
"}",
"ret = get_errno(sigtimedwait(&set, &uinfo, VAR_18));",
"if (!is_error(ret) && arg2) {",
"if (!(VAR_2 = lock_user(VERIFY_WRITE, arg2, sizeof(target_siginfo_t), 0)))\ngoto efault;",
"host_to_target_siginfo(VAR_2, &uinfo);",
"unlock_user(VAR_2, arg2, sizeof(target_siginfo_t));",
"}",
"}",
"break;",
"case TARGET_NR_rt_sigqueueinfo:\n{",
"siginfo_t uinfo;",
"if (!(VAR_2 = lock_user(VERIFY_READ, arg3, sizeof(target_sigset_t), 1)))\ngoto efault;",
"target_to_host_siginfo(&uinfo, VAR_2);",
"unlock_user(VAR_2, arg1, 0);",
"ret = get_errno(sys_rt_sigqueueinfo(arg1, arg2, &uinfo));",
"}",
"break;",
"#ifdef TARGET_NR_sigreturn\ncase TARGET_NR_sigreturn:\nret = do_sigreturn(cpu_env);",
"break;",
"#endif\ncase TARGET_NR_rt_sigreturn:\nret = do_rt_sigreturn(cpu_env);",
"break;",
"case TARGET_NR_sethostname:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;",
"ret = get_errno(sethostname(VAR_2, arg2));",
"unlock_user(VAR_2, arg1, 0);",
"break;",
"case TARGET_NR_setrlimit:\n{",
"int VAR_22 = arg1;",
"struct target_rlimit *VAR_22;",
"struct rlimit VAR_22;",
"if (!lock_user_struct(VERIFY_READ, VAR_22, arg2, 1))\ngoto efault;",
"VAR_22.rlim_cur = tswapl(VAR_22->rlim_cur);",
"VAR_22.rlim_max = tswapl(VAR_22->rlim_max);",
"unlock_user_struct(VAR_22, arg2, 0);",
"ret = get_errno(setrlimit(VAR_22, &VAR_22));",
"}",
"break;",
"case TARGET_NR_getrlimit:\n{",
"int VAR_22 = arg1;",
"struct target_rlimit *VAR_22;",
"struct rlimit VAR_22;",
"ret = get_errno(getrlimit(VAR_22, &VAR_22));",
"if (!is_error(ret)) {",
"if (!lock_user_struct(VERIFY_WRITE, VAR_22, arg2, 0))\ngoto efault;",
"VAR_22->rlim_cur = tswapl(VAR_22.rlim_cur);",
"VAR_22->rlim_max = tswapl(VAR_22.rlim_max);",
"unlock_user_struct(VAR_22, arg2, 1);",
"}",
"}",
"break;",
"case TARGET_NR_getrusage:\n{",
"struct VAR_31 VAR_31;",
"ret = get_errno(getrusage(arg1, &VAR_31));",
"if (!is_error(ret)) {",
"host_to_target_rusage(arg2, &VAR_31);",
"}",
"}",
"break;",
"case TARGET_NR_gettimeofday:\n{",
"struct timeval VAR_23;",
"ret = get_errno(gettimeofday(&VAR_23, NULL));",
"if (!is_error(ret)) {",
"if (copy_to_user_timeval(arg1, &VAR_23))\ngoto efault;",
"}",
"}",
"break;",
"case TARGET_NR_settimeofday:\n{",
"struct timeval VAR_23;",
"if (copy_from_user_timeval(&VAR_23, arg1))\ngoto efault;",
"ret = get_errno(settimeofday(&VAR_23, NULL));",
"}",
"break;",
"#ifdef TARGET_NR_select\ncase TARGET_NR_select:\n{",
"struct target_sel_arg_struct *sel;",
"abi_ulong inp, outp, exp, VAR_10;",
"long nsel;",
"if (!lock_user_struct(VERIFY_READ, sel, arg1, 1))\ngoto efault;",
"nsel = tswapl(sel->n);",
"inp = tswapl(sel->inp);",
"outp = tswapl(sel->outp);",
"exp = tswapl(sel->exp);",
"VAR_10 = tswapl(sel->VAR_10);",
"unlock_user_struct(sel, arg1, 0);",
"ret = do_select(nsel, inp, outp, exp, VAR_10);",
"}",
"break;",
"#endif\ncase TARGET_NR_symlink:\n{",
"void *VAR_23;",
"VAR_2 = lock_user_string(arg1);",
"VAR_23 = lock_user_string(arg2);",
"if (!VAR_2 || !VAR_23)\nret = -TARGET_EFAULT;",
"else\nret = get_errno(symlink(VAR_2, VAR_23));",
"unlock_user(VAR_23, arg2, 0);",
"unlock_user(VAR_2, arg1, 0);",
"}",
"break;",
"#if defined(TARGET_NR_symlinkat) && defined(__NR_symlinkat)\ncase TARGET_NR_symlinkat:\n{",
"void *VAR_23;",
"VAR_2 = lock_user_string(arg1);",
"VAR_23 = lock_user_string(arg3);",
"if (!VAR_2 || !VAR_23)\nret = -TARGET_EFAULT;",
"else\nret = get_errno(sys_symlinkat(VAR_2, arg2, VAR_23));",
"unlock_user(VAR_23, arg3, 0);",
"unlock_user(VAR_2, arg1, 0);",
"}",
"break;",
"#endif\n#ifdef TARGET_NR_oldlstat\ncase TARGET_NR_oldlstat:\ngoto unimplemented;",
"#endif\ncase TARGET_NR_readlink:\n{",
"void *VAR_23, *VAR_23;",
"VAR_2 = lock_user_string(arg1);",
"VAR_23 = lock_user(VERIFY_WRITE, arg2, arg3, 0);",
"if (!VAR_2 || !VAR_23)\nret = -TARGET_EFAULT;",
"else {",
"if (strncmp((const char *)VAR_2, \"/proc/self/exe\", 14) == 0) {",
"char VAR_24[PATH_MAX];",
"VAR_23 = realpath(exec_path,VAR_24);",
"ret = (VAR_23==NULL) ? get_errno(-1) : strlen(VAR_24) ;",
"snprintf((char *)VAR_23, arg3, \"%s\", VAR_24);",
"}",
"else\nret = get_errno(readlink(path(VAR_2), VAR_23, arg3));",
"}",
"unlock_user(VAR_23, arg2, ret);",
"unlock_user(VAR_2, arg1, 0);",
"}",
"break;",
"#if defined(TARGET_NR_readlinkat) && defined(__NR_readlinkat)\ncase TARGET_NR_readlinkat:\n{",
"void *VAR_23;",
"VAR_2 = lock_user_string(arg2);",
"VAR_23 = lock_user(VERIFY_WRITE, arg3, arg4, 0);",
"if (!VAR_2 || !VAR_23)\nret = -TARGET_EFAULT;",
"else\nret = get_errno(sys_readlinkat(arg1, path(VAR_2), VAR_23, arg4));",
"unlock_user(VAR_23, arg3, ret);",
"unlock_user(VAR_2, arg2, 0);",
"}",
"break;",
"#endif\n#ifdef TARGET_NR_uselib\ncase TARGET_NR_uselib:\ngoto unimplemented;",
"#endif\n#ifdef TARGET_NR_swapon\ncase TARGET_NR_swapon:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;",
"ret = get_errno(swapon(VAR_2, arg2));",
"unlock_user(VAR_2, arg1, 0);",
"break;",
"#endif\ncase TARGET_NR_reboot:\ngoto unimplemented;",
"#ifdef TARGET_NR_readdir\ncase TARGET_NR_readdir:\ngoto unimplemented;",
"#endif\n#ifdef TARGET_NR_mmap\ncase TARGET_NR_mmap:\n#if (defined(TARGET_I386) && defined(TARGET_ABI32)) || defined(TARGET_ARM) || defined(TARGET_M68K) || defined(TARGET_CRIS) || defined(TARGET_MICROBLAZE)\n{",
"abi_ulong *v;",
"abi_ulong v1, v2, v3, v4, v5, v6;",
"if (!(v = lock_user(VERIFY_READ, arg1, 6 * sizeof(abi_ulong), 1)))\ngoto efault;",
"v1 = tswapl(v[0]);",
"v2 = tswapl(v[1]);",
"v3 = tswapl(v[2]);",
"v4 = tswapl(v[3]);",
"v5 = tswapl(v[4]);",
"v6 = tswapl(v[5]);",
"unlock_user(v, arg1, 0);",
"ret = get_errno(target_mmap(v1, v2, v3,\ntarget_to_host_bitmask(v4, mmap_flags_tbl),\nv5, v6));",
"}",
"#else\nret = get_errno(target_mmap(arg1, arg2, arg3,\ntarget_to_host_bitmask(arg4, mmap_flags_tbl),\narg5,\narg6));",
"#endif\nbreak;",
"#endif\n#ifdef TARGET_NR_mmap2\ncase TARGET_NR_mmap2:\n#ifndef MMAP_SHIFT\n#define MMAP_SHIFT 12\n#endif\nret = get_errno(target_mmap(arg1, arg2, arg3,\ntarget_to_host_bitmask(arg4, mmap_flags_tbl),\narg5,\narg6 << MMAP_SHIFT));",
"break;",
"#endif\ncase TARGET_NR_munmap:\nret = get_errno(target_munmap(arg1, arg2));",
"break;",
"case TARGET_NR_mprotect:\nret = get_errno(target_mprotect(arg1, arg2, arg3));",
"break;",
"#ifdef TARGET_NR_mremap\ncase TARGET_NR_mremap:\nret = get_errno(target_mremap(arg1, arg2, arg3, arg4, arg5));",
"break;",
"#endif\n#ifdef TARGET_NR_msync\ncase TARGET_NR_msync:\nret = get_errno(msync(g2h(arg1), arg2, arg3));",
"break;",
"#endif\n#ifdef TARGET_NR_mlock\ncase TARGET_NR_mlock:\nret = get_errno(mlock(g2h(arg1), arg2));",
"break;",
"#endif\n#ifdef TARGET_NR_munlock\ncase TARGET_NR_munlock:\nret = get_errno(munlock(g2h(arg1), arg2));",
"break;",
"#endif\n#ifdef TARGET_NR_mlockall\ncase TARGET_NR_mlockall:\nret = get_errno(mlockall(arg1));",
"break;",
"#endif\n#ifdef TARGET_NR_munlockall\ncase TARGET_NR_munlockall:\nret = get_errno(munlockall());",
"break;",
"#endif\ncase TARGET_NR_truncate:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;",
"ret = get_errno(truncate(VAR_2, arg2));",
"unlock_user(VAR_2, arg1, 0);",
"break;",
"case TARGET_NR_ftruncate:\nret = get_errno(ftruncate(arg1, arg2));",
"break;",
"case TARGET_NR_fchmod:\nret = get_errno(fchmod(arg1, arg2));",
"break;",
"#if defined(TARGET_NR_fchmodat) && defined(__NR_fchmodat)\ncase TARGET_NR_fchmodat:\nif (!(VAR_2 = lock_user_string(arg2)))\ngoto efault;",
"ret = get_errno(sys_fchmodat(arg1, VAR_2, arg3));",
"unlock_user(VAR_2, arg2, 0);",
"break;",
"#endif\ncase TARGET_NR_getpriority:\nret = sys_getpriority(arg1, arg2);",
"break;",
"case TARGET_NR_setpriority:\nret = get_errno(setpriority(arg1, arg2, arg3));",
"break;",
"#ifdef TARGET_NR_profil\ncase TARGET_NR_profil:\ngoto unimplemented;",
"#endif\ncase TARGET_NR_statfs:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;",
"ret = get_errno(statfs(path(VAR_2), &VAR_1));",
"unlock_user(VAR_2, arg1, 0);",
"convert_statfs:\nif (!is_error(ret)) {",
"struct target_statfs *VAR_25;",
"if (!lock_user_struct(VERIFY_WRITE, VAR_25, arg2, 0))\ngoto efault;",
"__put_user(VAR_1.f_type, &VAR_25->f_type);",
"__put_user(VAR_1.f_bsize, &VAR_25->f_bsize);",
"__put_user(VAR_1.f_blocks, &VAR_25->f_blocks);",
"__put_user(VAR_1.f_bfree, &VAR_25->f_bfree);",
"__put_user(VAR_1.f_bavail, &VAR_25->f_bavail);",
"__put_user(VAR_1.f_files, &VAR_25->f_files);",
"__put_user(VAR_1.f_ffree, &VAR_25->f_ffree);",
"__put_user(VAR_1.f_fsid.__val[0], &VAR_25->f_fsid.val[0]);",
"__put_user(VAR_1.f_fsid.__val[1], &VAR_25->f_fsid.val[1]);",
"__put_user(VAR_1.f_namelen, &VAR_25->f_namelen);",
"unlock_user_struct(VAR_25, arg2, 1);",
"}",
"break;",
"case TARGET_NR_fstatfs:\nret = get_errno(fstatfs(arg1, &VAR_1));",
"goto convert_statfs;",
"#ifdef TARGET_NR_statfs64\ncase TARGET_NR_statfs64:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;",
"ret = get_errno(statfs(path(VAR_2), &VAR_1));",
"unlock_user(VAR_2, arg1, 0);",
"convert_statfs64:\nif (!is_error(ret)) {",
"struct target_statfs64 *VAR_25;",
"if (!lock_user_struct(VERIFY_WRITE, VAR_25, arg3, 0))\ngoto efault;",
"__put_user(VAR_1.f_type, &VAR_25->f_type);",
"__put_user(VAR_1.f_bsize, &VAR_25->f_bsize);",
"__put_user(VAR_1.f_blocks, &VAR_25->f_blocks);",
"__put_user(VAR_1.f_bfree, &VAR_25->f_bfree);",
"__put_user(VAR_1.f_bavail, &VAR_25->f_bavail);",
"__put_user(VAR_1.f_files, &VAR_25->f_files);",
"__put_user(VAR_1.f_ffree, &VAR_25->f_ffree);",
"__put_user(VAR_1.f_fsid.__val[0], &VAR_25->f_fsid.val[0]);",
"__put_user(VAR_1.f_fsid.__val[1], &VAR_25->f_fsid.val[1]);",
"__put_user(VAR_1.f_namelen, &VAR_25->f_namelen);",
"unlock_user_struct(VAR_25, arg3, 1);",
"}",
"break;",
"case TARGET_NR_fstatfs64:\nret = get_errno(fstatfs(arg1, &VAR_1));",
"goto convert_statfs64;",
"#endif\n#ifdef TARGET_NR_ioperm\ncase TARGET_NR_ioperm:\ngoto unimplemented;",
"#endif\n#ifdef TARGET_NR_socketcall\ncase TARGET_NR_socketcall:\nret = do_socketcall(arg1, arg2);",
"break;",
"#endif\n#ifdef TARGET_NR_accept\ncase TARGET_NR_accept:\nret = do_accept(arg1, arg2, arg3);",
"break;",
"#endif\n#ifdef TARGET_NR_bind\ncase TARGET_NR_bind:\nret = do_bind(arg1, arg2, arg3);",
"break;",
"#endif\n#ifdef TARGET_NR_connect\ncase TARGET_NR_connect:\nret = do_connect(arg1, arg2, arg3);",
"break;",
"#endif\n#ifdef TARGET_NR_getpeername\ncase TARGET_NR_getpeername:\nret = do_getpeername(arg1, arg2, arg3);",
"break;",
"#endif\n#ifdef TARGET_NR_getsockname\ncase TARGET_NR_getsockname:\nret = do_getsockname(arg1, arg2, arg3);",
"break;",
"#endif\n#ifdef TARGET_NR_getsockopt\ncase TARGET_NR_getsockopt:\nret = do_getsockopt(arg1, arg2, arg3, arg4, arg5);",
"break;",
"#endif\n#ifdef TARGET_NR_listen\ncase TARGET_NR_listen:\nret = get_errno(listen(arg1, arg2));",
"break;",
"#endif\n#ifdef TARGET_NR_recv\ncase TARGET_NR_recv:\nret = do_recvfrom(arg1, arg2, arg3, arg4, 0, 0);",
"break;",
"#endif\n#ifdef TARGET_NR_recvfrom\ncase TARGET_NR_recvfrom:\nret = do_recvfrom(arg1, arg2, arg3, arg4, arg5, arg6);",
"break;",
"#endif\n#ifdef TARGET_NR_recvmsg\ncase TARGET_NR_recvmsg:\nret = do_sendrecvmsg(arg1, arg2, arg3, 0);",
"break;",
"#endif\n#ifdef TARGET_NR_send\ncase TARGET_NR_send:\nret = do_sendto(arg1, arg2, arg3, arg4, 0, 0);",
"break;",
"#endif\n#ifdef TARGET_NR_sendmsg\ncase TARGET_NR_sendmsg:\nret = do_sendrecvmsg(arg1, arg2, arg3, 1);",
"break;",
"#endif\n#ifdef TARGET_NR_sendto\ncase TARGET_NR_sendto:\nret = do_sendto(arg1, arg2, arg3, arg4, arg5, arg6);",
"break;",
"#endif\n#ifdef TARGET_NR_shutdown\ncase TARGET_NR_shutdown:\nret = get_errno(shutdown(arg1, arg2));",
"break;",
"#endif\n#ifdef TARGET_NR_socket\ncase TARGET_NR_socket:\nret = do_socket(arg1, arg2, arg3);",
"break;",
"#endif\n#ifdef TARGET_NR_socketpair\ncase TARGET_NR_socketpair:\nret = do_socketpair(arg1, arg2, arg3, arg4);",
"break;",
"#endif\n#ifdef TARGET_NR_setsockopt\ncase TARGET_NR_setsockopt:\nret = do_setsockopt(arg1, arg2, arg3, arg4, (socklen_t) arg5);",
"break;",
"#endif\ncase TARGET_NR_syslog:\nif (!(VAR_2 = lock_user_string(arg2)))\ngoto efault;",
"ret = get_errno(sys_syslog((int)arg1, VAR_2, (int)arg3));",
"unlock_user(VAR_2, arg2, 0);",
"break;",
"case TARGET_NR_setitimer:\n{",
"struct itimerval VAR_33, VAR_27, *VAR_28;",
"if (arg2) {",
"VAR_28 = &VAR_33;",
"if (copy_from_user_timeval(&VAR_28->it_interval, arg2)\n|| copy_from_user_timeval(&VAR_28->it_value,\narg2 + sizeof(struct target_timeval)))\ngoto efault;",
"} else {",
"VAR_28 = NULL;",
"}",
"ret = get_errno(setitimer(arg1, VAR_28, &VAR_27));",
"if (!is_error(ret) && arg3) {",
"if (copy_to_user_timeval(arg3,\n&VAR_27.it_interval)\n|| copy_to_user_timeval(arg3 + sizeof(struct target_timeval),\n&VAR_27.it_value))\ngoto efault;",
"}",
"}",
"break;",
"case TARGET_NR_getitimer:\n{",
"struct itimerval VAR_33;",
"ret = get_errno(getitimer(arg1, &VAR_33));",
"if (!is_error(ret) && arg2) {",
"if (copy_to_user_timeval(arg2,\n&VAR_33.it_interval)\n|| copy_to_user_timeval(arg2 + sizeof(struct target_timeval),\n&VAR_33.it_value))\ngoto efault;",
"}",
"}",
"break;",
"case TARGET_NR_stat:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;",
"ret = get_errno(stat(path(VAR_2), &VAR_0));",
"unlock_user(VAR_2, arg1, 0);",
"goto do_stat;",
"case TARGET_NR_lstat:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;",
"ret = get_errno(lstat(path(VAR_2), &VAR_0));",
"unlock_user(VAR_2, arg1, 0);",
"goto do_stat;",
"case TARGET_NR_fstat:\n{",
"ret = get_errno(fstat(arg1, &VAR_0));",
"do_stat:\nif (!is_error(ret)) {",
"struct target_stat *VAR_29;",
"if (!lock_user_struct(VERIFY_WRITE, VAR_29, arg2, 0))\ngoto efault;",
"__put_user(VAR_0.st_dev, &VAR_29->st_dev);",
"__put_user(VAR_0.st_ino, &VAR_29->st_ino);",
"__put_user(VAR_0.st_mode, &VAR_29->st_mode);",
"__put_user(VAR_0.st_uid, &VAR_29->st_uid);",
"__put_user(VAR_0.st_gid, &VAR_29->st_gid);",
"__put_user(VAR_0.st_nlink, &VAR_29->st_nlink);",
"__put_user(VAR_0.st_rdev, &VAR_29->st_rdev);",
"__put_user(VAR_0.st_size, &VAR_29->st_size);",
"__put_user(VAR_0.st_blksize, &VAR_29->st_blksize);",
"__put_user(VAR_0.st_blocks, &VAR_29->st_blocks);",
"__put_user(VAR_0.st_atime, &VAR_29->target_st_atime);",
"__put_user(VAR_0.st_mtime, &VAR_29->target_st_mtime);",
"__put_user(VAR_0.st_ctime, &VAR_29->target_st_ctime);",
"unlock_user_struct(VAR_29, arg2, 1);",
"}",
"}",
"break;",
"#ifdef TARGET_NR_olduname\ncase TARGET_NR_olduname:\ngoto unimplemented;",
"#endif\n#ifdef TARGET_NR_iopl\ncase TARGET_NR_iopl:\ngoto unimplemented;",
"#endif\ncase TARGET_NR_vhangup:\nret = get_errno(vhangup());",
"break;",
"#ifdef TARGET_NR_idle\ncase TARGET_NR_idle:\ngoto unimplemented;",
"#endif\n#ifdef TARGET_NR_syscall\ncase TARGET_NR_syscall:\nret = FUNC_0(cpu_env,arg1 & 0xffff,arg2,arg3,arg4,arg5,arg6,0);",
"break;",
"#endif\ncase TARGET_NR_wait4:\n{",
"int VAR_30;",
"abi_long status_ptr = arg2;",
"struct VAR_31 VAR_31, *VAR_31;",
"abi_ulong target_rusage = arg4;",
"if (target_rusage)\nVAR_31 = &VAR_31;",
"else\nVAR_31 = NULL;",
"ret = get_errno(wait4(arg1, &VAR_30, arg3, VAR_31));",
"if (!is_error(ret)) {",
"if (status_ptr) {",
"VAR_30 = host_to_target_waitstatus(VAR_30);",
"if (put_user_s32(VAR_30, status_ptr))\ngoto efault;",
"}",
"if (target_rusage)\nhost_to_target_rusage(target_rusage, &VAR_31);",
"}",
"}",
"break;",
"#ifdef TARGET_NR_swapoff\ncase TARGET_NR_swapoff:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;",
"ret = get_errno(swapoff(VAR_2));",
"unlock_user(VAR_2, arg1, 0);",
"break;",
"#endif\ncase TARGET_NR_sysinfo:\n{",
"struct target_sysinfo *VAR_32;",
"struct sysinfo VAR_33;",
"ret = get_errno(sysinfo(&VAR_33));",
"if (!is_error(ret) && arg1)\n{",
"if (!lock_user_struct(VERIFY_WRITE, VAR_32, arg1, 0))\ngoto efault;",
"__put_user(VAR_33.uptime, &VAR_32->uptime);",
"__put_user(VAR_33.loads[0], &VAR_32->loads[0]);",
"__put_user(VAR_33.loads[1], &VAR_32->loads[1]);",
"__put_user(VAR_33.loads[2], &VAR_32->loads[2]);",
"__put_user(VAR_33.totalram, &VAR_32->totalram);",
"__put_user(VAR_33.freeram, &VAR_32->freeram);",
"__put_user(VAR_33.sharedram, &VAR_32->sharedram);",
"__put_user(VAR_33.bufferram, &VAR_32->bufferram);",
"__put_user(VAR_33.totalswap, &VAR_32->totalswap);",
"__put_user(VAR_33.freeswap, &VAR_32->freeswap);",
"__put_user(VAR_33.procs, &VAR_32->procs);",
"__put_user(VAR_33.totalhigh, &VAR_32->totalhigh);",
"__put_user(VAR_33.freehigh, &VAR_32->freehigh);",
"__put_user(VAR_33.mem_unit, &VAR_32->mem_unit);",
"unlock_user_struct(VAR_32, arg1, 1);",
"}",
"}",
"break;",
"#ifdef TARGET_NR_ipc\ncase TARGET_NR_ipc:\nret = do_ipc(arg1, arg2, arg3, arg4, arg5, arg6);",
"break;",
"#endif\n#ifdef TARGET_NR_semget\ncase TARGET_NR_semget:\nret = get_errno(semget(arg1, arg2, arg3));",
"break;",
"#endif\n#ifdef TARGET_NR_semop\ncase TARGET_NR_semop:\nret = get_errno(do_semop(arg1, arg2, arg3));",
"break;",
"#endif\n#ifdef TARGET_NR_semctl\ncase TARGET_NR_semctl:\nret = do_semctl(arg1, arg2, arg3, (union target_semun)(abi_ulong)arg4);",
"break;",
"#endif\n#ifdef TARGET_NR_msgctl\ncase TARGET_NR_msgctl:\nret = do_msgctl(arg1, arg2, arg3);",
"break;",
"#endif\n#ifdef TARGET_NR_msgget\ncase TARGET_NR_msgget:\nret = get_errno(msgget(arg1, arg2));",
"break;",
"#endif\n#ifdef TARGET_NR_msgrcv\ncase TARGET_NR_msgrcv:\nret = do_msgrcv(arg1, arg2, arg3, arg4, arg5);",
"break;",
"#endif\n#ifdef TARGET_NR_msgsnd\ncase TARGET_NR_msgsnd:\nret = do_msgsnd(arg1, arg2, arg3, arg4);",
"break;",
"#endif\n#ifdef TARGET_NR_shmget\ncase TARGET_NR_shmget:\nret = get_errno(shmget(arg1, arg2, arg3));",
"break;",
"#endif\n#ifdef TARGET_NR_shmctl\ncase TARGET_NR_shmctl:\nret = do_shmctl(arg1, arg2, arg3);",
"break;",
"#endif\n#ifdef TARGET_NR_shmat\ncase TARGET_NR_shmat:\nret = do_shmat(arg1, arg2, arg3);",
"break;",
"#endif\n#ifdef TARGET_NR_shmdt\ncase TARGET_NR_shmdt:\nret = do_shmdt(arg1);",
"break;",
"#endif\ncase TARGET_NR_fsync:\nret = get_errno(fsync(arg1));",
"break;",
"case TARGET_NR_clone:\n#if defined(TARGET_SH4)\nret = get_errno(do_fork(cpu_env, arg1, arg2, arg3, arg5, arg4));",
"#elif defined(TARGET_CRIS)\nret = get_errno(do_fork(cpu_env, arg2, arg1, arg3, arg4, arg5));",
"#else\nret = get_errno(do_fork(cpu_env, arg1, arg2, arg3, arg4, arg5));",
"#endif\nbreak;",
"#ifdef __NR_exit_group\ncase TARGET_NR_exit_group:\n#ifdef TARGET_GPROF\n_mcleanup();",
"#endif\ngdb_exit(cpu_env, arg1);",
"ret = get_errno(exit_group(arg1));",
"break;",
"#endif\ncase TARGET_NR_setdomainname:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;",
"ret = get_errno(setdomainname(VAR_2, arg2));",
"unlock_user(VAR_2, arg1, 0);",
"break;",
"case TARGET_NR_uname:\n{",
"struct new_utsname * VAR_33;",
"if (!lock_user_struct(VERIFY_WRITE, VAR_33, arg1, 0))\ngoto efault;",
"ret = get_errno(sys_uname(VAR_33));",
"if (!is_error(ret)) {",
"strcpy (VAR_33->machine, UNAME_MACHINE);",
"if (qemu_uname_release && *qemu_uname_release)\nstrcpy (VAR_33->release, qemu_uname_release);",
"}",
"unlock_user_struct(VAR_33, arg1, 1);",
"}",
"break;",
"#ifdef TARGET_I386\ncase TARGET_NR_modify_ldt:\nret = do_modify_ldt(cpu_env, arg1, arg2, arg3);",
"break;",
"#if !defined(TARGET_X86_64)\ncase TARGET_NR_vm86old:\ngoto unimplemented;",
"case TARGET_NR_vm86:\nret = do_vm86(cpu_env, arg1, arg2);",
"break;",
"#endif\n#endif\ncase TARGET_NR_adjtimex:\ngoto unimplemented;",
"#ifdef TARGET_NR_create_module\ncase TARGET_NR_create_module:\n#endif\ncase TARGET_NR_init_module:\ncase TARGET_NR_delete_module:\n#ifdef TARGET_NR_get_kernel_syms\ncase TARGET_NR_get_kernel_syms:\n#endif\ngoto unimplemented;",
"case TARGET_NR_quotactl:\ngoto unimplemented;",
"case TARGET_NR_getpgid:\nret = get_errno(getpgid(arg1));",
"break;",
"case TARGET_NR_fchdir:\nret = get_errno(fchdir(arg1));",
"break;",
"#ifdef TARGET_NR_bdflush\ncase TARGET_NR_bdflush:\ngoto unimplemented;",
"#endif\n#ifdef TARGET_NR_sysfs\ncase TARGET_NR_sysfs:\ngoto unimplemented;",
"#endif\ncase TARGET_NR_personality:\nret = get_errno(personality(arg1));",
"break;",
"#ifdef TARGET_NR_afs_syscall\ncase TARGET_NR_afs_syscall:\ngoto unimplemented;",
"#endif\n#ifdef TARGET_NR__llseek\ncase TARGET_NR__llseek:\n{",
"#if defined (__x86_64__)\nret = get_errno(lseek(arg1, ((uint64_t )arg2 << 32) | arg3, arg5));",
"if (put_user_s64(ret, arg4))\ngoto efault;",
"#else\nint64_t res;",
"ret = get_errno(_llseek(arg1, arg2, arg3, &res, arg5));",
"if (put_user_s64(res, arg4))\ngoto efault;",
"#endif\n}",
"break;",
"#endif\ncase TARGET_NR_getdents:\n#if TARGET_ABI_BITS == 32 && HOST_LONG_BITS == 64\n{",
"struct target_dirent *target_dirp;",
"struct linux_dirent *VAR_34;",
"abi_long VAR_40 = arg3;",
"VAR_34 = malloc(VAR_40);",
"if (!VAR_34) {",
"ret = -TARGET_ENOMEM;",
"goto fail;",
"}",
"ret = get_errno(sys_getdents(arg1, VAR_34, VAR_40));",
"if (!is_error(ret)) {",
"struct linux_dirent *VAR_35;",
"struct target_dirent *tde;",
"int VAR_36 = ret;",
"int VAR_37, treclen;",
"int count1, tnamelen;",
"count1 = 0;",
"VAR_35 = VAR_34;",
"if (!(target_dirp = lock_user(VERIFY_WRITE, arg2, VAR_40, 0)))\ngoto efault;",
"tde = target_dirp;",
"while (VAR_36 > 0) {",
"VAR_37 = VAR_35->d_reclen;",
"treclen = VAR_37 - (2 * (sizeof(long) - sizeof(abi_long)));",
"tde->d_reclen = tswap16(treclen);",
"tde->d_ino = tswapl(VAR_35->d_ino);",
"tde->d_off = tswapl(VAR_35->d_off);",
"tnamelen = treclen - (2 * sizeof(abi_long) + 2);",
"if (tnamelen > 256)\ntnamelen = 256;",
"pstrcpy(tde->d_name, tnamelen, VAR_35->d_name);",
"VAR_35 = (struct linux_dirent *)((char *)VAR_35 + VAR_37);",
"VAR_36 -= VAR_37;",
"tde = (struct target_dirent *)((char *)tde + treclen);",
"count1 += treclen;",
"}",
"ret = count1;",
"unlock_user(target_dirp, arg2, ret);",
"}",
"free(VAR_34);",
"}",
"#else\n{",
"struct linux_dirent *VAR_34;",
"abi_long VAR_40 = arg3;",
"if (!(VAR_34 = lock_user(VERIFY_WRITE, arg2, VAR_40, 0)))\ngoto efault;",
"ret = get_errno(sys_getdents(arg1, VAR_34, VAR_40));",
"if (!is_error(ret)) {",
"struct linux_dirent *VAR_35;",
"int VAR_36 = ret;",
"int VAR_37;",
"VAR_35 = VAR_34;",
"while (VAR_36 > 0) {",
"VAR_37 = VAR_35->d_reclen;",
"if (VAR_37 > VAR_36)\nbreak;",
"VAR_35->d_reclen = tswap16(VAR_37);",
"tswapls(&VAR_35->d_ino);",
"tswapls(&VAR_35->d_off);",
"VAR_35 = (struct linux_dirent *)((char *)VAR_35 + VAR_37);",
"VAR_36 -= VAR_37;",
"}",
"}",
"unlock_user(VAR_34, arg2, ret);",
"}",
"#endif\nbreak;",
"#if defined(TARGET_NR_getdents64) && defined(__NR_getdents64)\ncase TARGET_NR_getdents64:\n{",
"struct linux_dirent64 *VAR_34;",
"abi_long VAR_40 = arg3;",
"if (!(VAR_34 = lock_user(VERIFY_WRITE, arg2, VAR_40, 0)))\ngoto efault;",
"ret = get_errno(sys_getdents64(arg1, VAR_34, VAR_40));",
"if (!is_error(ret)) {",
"struct linux_dirent64 *VAR_35;",
"int VAR_36 = ret;",
"int VAR_37;",
"VAR_35 = VAR_34;",
"while (VAR_36 > 0) {",
"VAR_37 = VAR_35->d_reclen;",
"if (VAR_37 > VAR_36)\nbreak;",
"VAR_35->d_reclen = tswap16(VAR_37);",
"tswap64s((uint64_t *)&VAR_35->d_ino);",
"tswap64s((uint64_t *)&VAR_35->d_off);",
"VAR_35 = (struct linux_dirent64 *)((char *)VAR_35 + VAR_37);",
"VAR_36 -= VAR_37;",
"}",
"}",
"unlock_user(VAR_34, arg2, ret);",
"}",
"break;",
"#endif\n#ifdef TARGET_NR__newselect\ncase TARGET_NR__newselect:\nret = do_select(arg1, arg2, arg3, arg4, arg5);",
"break;",
"#endif\n#ifdef TARGET_NR_poll\ncase TARGET_NR_poll:\n{",
"struct target_pollfd *target_pfd;",
"unsigned int nfds = arg2;",
"int timeout = arg3;",
"struct pollfd *pfd;",
"unsigned int i;",
"target_pfd = lock_user(VERIFY_WRITE, arg1, sizeof(struct target_pollfd) * nfds, 1);",
"if (!target_pfd)\ngoto efault;",
"pfd = alloca(sizeof(struct pollfd) * nfds);",
"for(i = 0; i < nfds; i++) {",
"pfd[i].fd = tswap32(target_pfd[i].fd);",
"pfd[i].events = tswap16(target_pfd[i].events);",
"}",
"ret = get_errno(poll(pfd, nfds, timeout));",
"if (!is_error(ret)) {",
"for(i = 0; i < nfds; i++) {",
"target_pfd[i].revents = tswap16(pfd[i].revents);",
"}",
"ret += nfds * (sizeof(struct target_pollfd)\n- sizeof(struct pollfd));",
"}",
"unlock_user(target_pfd, arg1, ret);",
"}",
"break;",
"#endif\ncase TARGET_NR_flock:\nret = get_errno(flock(arg1, arg2));",
"break;",
"case TARGET_NR_readv:\n{",
"int VAR_40 = arg3;",
"struct iovec *VAR_40;",
"VAR_40 = alloca(VAR_40 * sizeof(struct iovec));",
"if (lock_iovec(VERIFY_WRITE, VAR_40, arg2, VAR_40, 0) < 0)\ngoto efault;",
"ret = get_errno(readv(arg1, VAR_40, VAR_40));",
"unlock_iovec(VAR_40, arg2, VAR_40, 1);",
"}",
"break;",
"case TARGET_NR_writev:\n{",
"int VAR_40 = arg3;",
"struct iovec *VAR_40;",
"VAR_40 = alloca(VAR_40 * sizeof(struct iovec));",
"if (lock_iovec(VERIFY_READ, VAR_40, arg2, VAR_40, 1) < 0)\ngoto efault;",
"ret = get_errno(writev(arg1, VAR_40, VAR_40));",
"unlock_iovec(VAR_40, arg2, VAR_40, 0);",
"}",
"break;",
"case TARGET_NR_getsid:\nret = get_errno(getsid(arg1));",
"break;",
"#if defined(TARGET_NR_fdatasync)\ncase TARGET_NR_fdatasync:\nret = get_errno(fdatasync(arg1));",
"break;",
"#endif\ncase TARGET_NR__sysctl:\nret = -TARGET_ENOTDIR;",
"break;",
"case TARGET_NR_sched_setparam:\n{",
"struct sched_param *VAR_42;",
"struct sched_param VAR_42;",
"if (!lock_user_struct(VERIFY_READ, VAR_42, arg2, 1))\ngoto efault;",
"VAR_42.sched_priority = tswap32(VAR_42->sched_priority);",
"unlock_user_struct(VAR_42, arg2, 0);",
"ret = get_errno(sched_setparam(arg1, &VAR_42));",
"}",
"break;",
"case TARGET_NR_sched_getparam:\n{",
"struct sched_param *VAR_42;",
"struct sched_param VAR_42;",
"ret = get_errno(sched_getparam(arg1, &VAR_42));",
"if (!is_error(ret)) {",
"if (!lock_user_struct(VERIFY_WRITE, VAR_42, arg2, 0))\ngoto efault;",
"VAR_42->sched_priority = tswap32(VAR_42.sched_priority);",
"unlock_user_struct(VAR_42, arg2, 1);",
"}",
"}",
"break;",
"case TARGET_NR_sched_setscheduler:\n{",
"struct sched_param *VAR_42;",
"struct sched_param VAR_42;",
"if (!lock_user_struct(VERIFY_READ, VAR_42, arg3, 1))\ngoto efault;",
"VAR_42.sched_priority = tswap32(VAR_42->sched_priority);",
"unlock_user_struct(VAR_42, arg3, 0);",
"ret = get_errno(sched_setscheduler(arg1, arg2, &VAR_42));",
"}",
"break;",
"case TARGET_NR_sched_getscheduler:\nret = get_errno(sched_getscheduler(arg1));",
"break;",
"case TARGET_NR_sched_yield:\nret = get_errno(sched_yield());",
"break;",
"case TARGET_NR_sched_get_priority_max:\nret = get_errno(sched_get_priority_max(arg1));",
"break;",
"case TARGET_NR_sched_get_priority_min:\nret = get_errno(sched_get_priority_min(arg1));",
"break;",
"case TARGET_NR_sched_rr_get_interval:\n{",
"struct timespec VAR_42;",
"ret = get_errno(sched_rr_get_interval(arg1, &VAR_42));",
"if (!is_error(ret)) {",
"host_to_target_timespec(arg2, &VAR_42);",
"}",
"}",
"break;",
"case TARGET_NR_nanosleep:\n{",
"struct timespec VAR_43, VAR_44;",
"target_to_host_timespec(&VAR_43, arg1);",
"ret = get_errno(nanosleep(&VAR_43, &VAR_44));",
"if (is_error(ret) && arg2) {",
"host_to_target_timespec(arg2, &VAR_44);",
"}",
"}",
"break;",
"#ifdef TARGET_NR_query_module\ncase TARGET_NR_query_module:\ngoto unimplemented;",
"#endif\n#ifdef TARGET_NR_nfsservctl\ncase TARGET_NR_nfsservctl:\ngoto unimplemented;",
"#endif\ncase TARGET_NR_prctl:\nswitch (arg1)\n{",
"case PR_GET_PDEATHSIG:\n{",
"int VAR_45;",
"ret = get_errno(prctl(arg1, &VAR_45, arg3, arg4, arg5));",
"if (!is_error(ret) && arg2\n&& put_user_ual(VAR_45, arg2))\ngoto efault;",
"}",
"break;",
"default:\nret = get_errno(prctl(arg1, arg2, arg3, arg4, arg5));",
"break;",
"}",
"break;",
"#ifdef TARGET_NR_arch_prctl\ncase TARGET_NR_arch_prctl:\n#if defined(TARGET_I386) && !defined(TARGET_ABI32)\nret = do_arch_prctl(cpu_env, arg1, arg2);",
"break;",
"#else\ngoto unimplemented;",
"#endif\n#endif\n#ifdef TARGET_NR_pread\ncase TARGET_NR_pread:\n#ifdef TARGET_ARM\nif (((CPUARMState *)cpu_env)->eabi)\narg4 = arg5;",
"#endif\nif (!(VAR_2 = lock_user(VERIFY_WRITE, arg2, arg3, 0)))\ngoto efault;",
"ret = get_errno(pread(arg1, VAR_2, arg3, arg4));",
"unlock_user(VAR_2, arg2, ret);",
"break;",
"case TARGET_NR_pwrite:\n#ifdef TARGET_ARM\nif (((CPUARMState *)cpu_env)->eabi)\narg4 = arg5;",
"#endif\nif (!(VAR_2 = lock_user(VERIFY_READ, arg2, arg3, 1)))\ngoto efault;",
"ret = get_errno(pwrite(arg1, VAR_2, arg3, arg4));",
"unlock_user(VAR_2, arg2, 0);",
"break;",
"#endif\n#ifdef TARGET_NR_pread64\ncase TARGET_NR_pread64:\nif (!(VAR_2 = lock_user(VERIFY_WRITE, arg2, arg3, 0)))\ngoto efault;",
"ret = get_errno(pread64(arg1, VAR_2, arg3, target_offset64(arg4, arg5)));",
"unlock_user(VAR_2, arg2, ret);",
"break;",
"case TARGET_NR_pwrite64:\nif (!(VAR_2 = lock_user(VERIFY_READ, arg2, arg3, 1)))\ngoto efault;",
"ret = get_errno(pwrite64(arg1, VAR_2, arg3, target_offset64(arg4, arg5)));",
"unlock_user(VAR_2, arg2, 0);",
"break;",
"#endif\ncase TARGET_NR_getcwd:\nif (!(VAR_2 = lock_user(VERIFY_WRITE, arg1, arg2, 0)))\ngoto efault;",
"ret = get_errno(sys_getcwd1(VAR_2, arg2));",
"unlock_user(VAR_2, arg1, ret);",
"break;",
"case TARGET_NR_capget:\ngoto unimplemented;",
"case TARGET_NR_capset:\ngoto unimplemented;",
"case TARGET_NR_sigaltstack:\n#if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_MIPS) || \\\ndefined(TARGET_SPARC) || defined(TARGET_PPC) || defined(TARGET_ALPHA) || \\\ndefined(TARGET_M68K)\nret = do_sigaltstack(arg1, arg2, get_sp_from_cpustate((CPUState *)cpu_env));",
"break;",
"#else\ngoto unimplemented;",
"#endif\ncase TARGET_NR_sendfile:\ngoto unimplemented;",
"#ifdef TARGET_NR_getpmsg\ncase TARGET_NR_getpmsg:\ngoto unimplemented;",
"#endif\n#ifdef TARGET_NR_putpmsg\ncase TARGET_NR_putpmsg:\ngoto unimplemented;",
"#endif\n#ifdef TARGET_NR_vfork\ncase TARGET_NR_vfork:\nret = get_errno(do_fork(cpu_env, CLONE_VFORK | CLONE_VM | SIGCHLD,\n0, 0, 0, 0));",
"break;",
"#endif\n#ifdef TARGET_NR_ugetrlimit\ncase TARGET_NR_ugetrlimit:\n{",
"struct rlimit VAR_22;",
"ret = get_errno(getrlimit(arg1, &VAR_22));",
"if (!is_error(ret)) {",
"struct target_rlimit *VAR_22;",
"if (!lock_user_struct(VERIFY_WRITE, VAR_22, arg2, 0))\ngoto efault;",
"VAR_22->rlim_cur = tswapl(VAR_22.rlim_cur);",
"VAR_22->rlim_max = tswapl(VAR_22.rlim_max);",
"unlock_user_struct(VAR_22, arg2, 1);",
"}",
"break;",
"}",
"#endif\n#ifdef TARGET_NR_truncate64\ncase TARGET_NR_truncate64:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;",
"ret = target_truncate64(cpu_env, VAR_2, arg2, arg3, arg4);",
"unlock_user(VAR_2, arg1, 0);",
"break;",
"#endif\n#ifdef TARGET_NR_ftruncate64\ncase TARGET_NR_ftruncate64:\nret = target_ftruncate64(cpu_env, arg1, arg2, arg3, arg4);",
"break;",
"#endif\n#ifdef TARGET_NR_stat64\ncase TARGET_NR_stat64:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;",
"ret = get_errno(stat(path(VAR_2), &VAR_0));",
"unlock_user(VAR_2, arg1, 0);",
"if (!is_error(ret))\nret = host_to_target_stat64(cpu_env, arg2, &VAR_0);",
"break;",
"#endif\n#ifdef TARGET_NR_lstat64\ncase TARGET_NR_lstat64:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;",
"ret = get_errno(lstat(path(VAR_2), &VAR_0));",
"unlock_user(VAR_2, arg1, 0);",
"if (!is_error(ret))\nret = host_to_target_stat64(cpu_env, arg2, &VAR_0);",
"break;",
"#endif\n#ifdef TARGET_NR_fstat64\ncase TARGET_NR_fstat64:\nret = get_errno(fstat(arg1, &VAR_0));",
"if (!is_error(ret))\nret = host_to_target_stat64(cpu_env, arg2, &VAR_0);",
"break;",
"#endif\n#if (defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)) && \\\n(defined(__NR_fstatat64) || defined(__NR_newfstatat))\n#ifdef TARGET_NR_fstatat64\ncase TARGET_NR_fstatat64:\n#endif\n#ifdef TARGET_NR_newfstatat\ncase TARGET_NR_newfstatat:\n#endif\nif (!(VAR_2 = lock_user_string(arg2)))\ngoto efault;",
"#ifdef __NR_fstatat64\nret = get_errno(sys_fstatat64(arg1, path(VAR_2), &VAR_0, arg4));",
"#else\nret = get_errno(sys_newfstatat(arg1, path(VAR_2), &VAR_0, arg4));",
"#endif\nif (!is_error(ret))\nret = host_to_target_stat64(cpu_env, arg3, &VAR_0);",
"break;",
"#endif\n#ifdef USE_UID16\ncase TARGET_NR_lchown:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;",
"ret = get_errno(lchown(VAR_2, low2highuid(arg2), low2highgid(arg3)));",
"unlock_user(VAR_2, arg1, 0);",
"break;",
"case TARGET_NR_getuid:\nret = get_errno(high2lowuid(getuid()));",
"break;",
"case TARGET_NR_getgid:\nret = get_errno(high2lowgid(getgid()));",
"break;",
"case TARGET_NR_geteuid:\nret = get_errno(high2lowuid(geteuid()));",
"break;",
"case TARGET_NR_getegid:\nret = get_errno(high2lowgid(getegid()));",
"break;",
"case TARGET_NR_setreuid:\nret = get_errno(setreuid(low2highuid(arg1), low2highuid(arg2)));",
"break;",
"case TARGET_NR_setregid:\nret = get_errno(setregid(low2highgid(arg1), low2highgid(arg2)));",
"break;",
"case TARGET_NR_getgroups:\n{",
"int gidsetsize = arg1;",
"uint16_t *target_grouplist;",
"gid_t *grouplist;",
"int i;",
"grouplist = alloca(gidsetsize * sizeof(gid_t));",
"ret = get_errno(getgroups(gidsetsize, grouplist));",
"if (gidsetsize == 0)\nbreak;",
"if (!is_error(ret)) {",
"target_grouplist = lock_user(VERIFY_WRITE, arg2, gidsetsize * 2, 0);",
"if (!target_grouplist)\ngoto efault;",
"for(i = 0;i < ret; i++)",
"target_grouplist[i] = tswap16(grouplist[i]);",
"unlock_user(target_grouplist, arg2, gidsetsize * 2);",
"}",
"}",
"break;",
"case TARGET_NR_setgroups:\n{",
"int gidsetsize = arg1;",
"uint16_t *target_grouplist;",
"gid_t *grouplist;",
"int i;",
"grouplist = alloca(gidsetsize * sizeof(gid_t));",
"target_grouplist = lock_user(VERIFY_READ, arg2, gidsetsize * 2, 1);",
"if (!target_grouplist) {",
"ret = -TARGET_EFAULT;",
"goto fail;",
"}",
"for(i = 0;i < gidsetsize; i++)",
"grouplist[i] = tswap16(target_grouplist[i]);",
"unlock_user(target_grouplist, arg2, 0);",
"ret = get_errno(setgroups(gidsetsize, grouplist));",
"}",
"break;",
"case TARGET_NR_fchown:\nret = get_errno(fchown(arg1, low2highuid(arg2), low2highgid(arg3)));",
"break;",
"#if defined(TARGET_NR_fchownat) && defined(__NR_fchownat)\ncase TARGET_NR_fchownat:\nif (!(VAR_2 = lock_user_string(arg2)))\ngoto efault;",
"ret = get_errno(sys_fchownat(arg1, VAR_2, low2highuid(arg3), low2highgid(arg4), arg5));",
"unlock_user(VAR_2, arg2, 0);",
"break;",
"#endif\n#ifdef TARGET_NR_setresuid\ncase TARGET_NR_setresuid:\nret = get_errno(setresuid(low2highuid(arg1),\nlow2highuid(arg2),\nlow2highuid(arg3)));",
"break;",
"#endif\n#ifdef TARGET_NR_getresuid\ncase TARGET_NR_getresuid:\n{",
"uid_t ruid, euid, suid;",
"ret = get_errno(getresuid(&ruid, &euid, &suid));",
"if (!is_error(ret)) {",
"if (put_user_u16(high2lowuid(ruid), arg1)\n|| put_user_u16(high2lowuid(euid), arg2)\n|| put_user_u16(high2lowuid(suid), arg3))\ngoto efault;",
"}",
"}",
"break;",
"#endif\n#ifdef TARGET_NR_getresgid\ncase TARGET_NR_setresgid:\nret = get_errno(setresgid(low2highgid(arg1),\nlow2highgid(arg2),\nlow2highgid(arg3)));",
"break;",
"#endif\n#ifdef TARGET_NR_getresgid\ncase TARGET_NR_getresgid:\n{",
"gid_t rgid, egid, sgid;",
"ret = get_errno(getresgid(&rgid, &egid, &sgid));",
"if (!is_error(ret)) {",
"if (put_user_u16(high2lowgid(rgid), arg1)\n|| put_user_u16(high2lowgid(egid), arg2)\n|| put_user_u16(high2lowgid(sgid), arg3))\ngoto efault;",
"}",
"}",
"break;",
"#endif\ncase TARGET_NR_chown:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;",
"ret = get_errno(chown(VAR_2, low2highuid(arg2), low2highgid(arg3)));",
"unlock_user(VAR_2, arg1, 0);",
"break;",
"case TARGET_NR_setuid:\nret = get_errno(setuid(low2highuid(arg1)));",
"break;",
"case TARGET_NR_setgid:\nret = get_errno(setgid(low2highgid(arg1)));",
"break;",
"case TARGET_NR_setfsuid:\nret = get_errno(setfsuid(arg1));",
"break;",
"case TARGET_NR_setfsgid:\nret = get_errno(setfsgid(arg1));",
"break;",
"#endif\n#ifdef TARGET_NR_lchown32\ncase TARGET_NR_lchown32:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;",
"ret = get_errno(lchown(VAR_2, arg2, arg3));",
"unlock_user(VAR_2, arg1, 0);",
"break;",
"#endif\n#ifdef TARGET_NR_getuid32\ncase TARGET_NR_getuid32:\nret = get_errno(getuid());",
"break;",
"#endif\n#if defined(TARGET_NR_getxuid) && defined(TARGET_ALPHA)\ncase TARGET_NR_getxuid:\n{",
"uid_t euid;",
"euid=geteuid();",
"((CPUAlphaState *)cpu_env)->ir[IR_A4]=euid;",
"}",
"ret = get_errno(getuid());",
"break;",
"#endif\n#if defined(TARGET_NR_getxgid) && defined(TARGET_ALPHA)\ncase TARGET_NR_getxgid:\n{",
"uid_t egid;",
"egid=getegid();",
"((CPUAlphaState *)cpu_env)->ir[IR_A4]=egid;",
"}",
"ret = get_errno(getgid());",
"break;",
"#endif\n#ifdef TARGET_NR_getgid32\ncase TARGET_NR_getgid32:\nret = get_errno(getgid());",
"break;",
"#endif\n#ifdef TARGET_NR_geteuid32\ncase TARGET_NR_geteuid32:\nret = get_errno(geteuid());",
"break;",
"#endif\n#ifdef TARGET_NR_getegid32\ncase TARGET_NR_getegid32:\nret = get_errno(getegid());",
"break;",
"#endif\n#ifdef TARGET_NR_setreuid32\ncase TARGET_NR_setreuid32:\nret = get_errno(setreuid(arg1, arg2));",
"break;",
"#endif\n#ifdef TARGET_NR_setregid32\ncase TARGET_NR_setregid32:\nret = get_errno(setregid(arg1, arg2));",
"break;",
"#endif\n#ifdef TARGET_NR_getgroups32\ncase TARGET_NR_getgroups32:\n{",
"int gidsetsize = arg1;",
"uint32_t *target_grouplist;",
"gid_t *grouplist;",
"int i;",
"grouplist = alloca(gidsetsize * sizeof(gid_t));",
"ret = get_errno(getgroups(gidsetsize, grouplist));",
"if (gidsetsize == 0)\nbreak;",
"if (!is_error(ret)) {",
"target_grouplist = lock_user(VERIFY_WRITE, arg2, gidsetsize * 4, 0);",
"if (!target_grouplist) {",
"ret = -TARGET_EFAULT;",
"goto fail;",
"}",
"for(i = 0;i < ret; i++)",
"target_grouplist[i] = tswap32(grouplist[i]);",
"unlock_user(target_grouplist, arg2, gidsetsize * 4);",
"}",
"}",
"break;",
"#endif\n#ifdef TARGET_NR_setgroups32\ncase TARGET_NR_setgroups32:\n{",
"int gidsetsize = arg1;",
"uint32_t *target_grouplist;",
"gid_t *grouplist;",
"int i;",
"grouplist = alloca(gidsetsize * sizeof(gid_t));",
"target_grouplist = lock_user(VERIFY_READ, arg2, gidsetsize * 4, 1);",
"if (!target_grouplist) {",
"ret = -TARGET_EFAULT;",
"goto fail;",
"}",
"for(i = 0;i < gidsetsize; i++)",
"grouplist[i] = tswap32(target_grouplist[i]);",
"unlock_user(target_grouplist, arg2, 0);",
"ret = get_errno(setgroups(gidsetsize, grouplist));",
"}",
"break;",
"#endif\n#ifdef TARGET_NR_fchown32\ncase TARGET_NR_fchown32:\nret = get_errno(fchown(arg1, arg2, arg3));",
"break;",
"#endif\n#ifdef TARGET_NR_setresuid32\ncase TARGET_NR_setresuid32:\nret = get_errno(setresuid(arg1, arg2, arg3));",
"break;",
"#endif\n#ifdef TARGET_NR_getresuid32\ncase TARGET_NR_getresuid32:\n{",
"uid_t ruid, euid, suid;",
"ret = get_errno(getresuid(&ruid, &euid, &suid));",
"if (!is_error(ret)) {",
"if (put_user_u32(ruid, arg1)\n|| put_user_u32(euid, arg2)\n|| put_user_u32(suid, arg3))\ngoto efault;",
"}",
"}",
"break;",
"#endif\n#ifdef TARGET_NR_setresgid32\ncase TARGET_NR_setresgid32:\nret = get_errno(setresgid(arg1, arg2, arg3));",
"break;",
"#endif\n#ifdef TARGET_NR_getresgid32\ncase TARGET_NR_getresgid32:\n{",
"gid_t rgid, egid, sgid;",
"ret = get_errno(getresgid(&rgid, &egid, &sgid));",
"if (!is_error(ret)) {",
"if (put_user_u32(rgid, arg1)\n|| put_user_u32(egid, arg2)\n|| put_user_u32(sgid, arg3))\ngoto efault;",
"}",
"}",
"break;",
"#endif\n#ifdef TARGET_NR_chown32\ncase TARGET_NR_chown32:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;",
"ret = get_errno(chown(VAR_2, arg2, arg3));",
"unlock_user(VAR_2, arg1, 0);",
"break;",
"#endif\n#ifdef TARGET_NR_setuid32\ncase TARGET_NR_setuid32:\nret = get_errno(setuid(arg1));",
"break;",
"#endif\n#ifdef TARGET_NR_setgid32\ncase TARGET_NR_setgid32:\nret = get_errno(setgid(arg1));",
"break;",
"#endif\n#ifdef TARGET_NR_setfsuid32\ncase TARGET_NR_setfsuid32:\nret = get_errno(setfsuid(arg1));",
"break;",
"#endif\n#ifdef TARGET_NR_setfsgid32\ncase TARGET_NR_setfsgid32:\nret = get_errno(setfsgid(arg1));",
"break;",
"#endif\ncase TARGET_NR_pivot_root:\ngoto unimplemented;",
"#ifdef TARGET_NR_mincore\ncase TARGET_NR_mincore:\n{",
"void *a;",
"ret = -TARGET_EFAULT;",
"if (!(a = lock_user(VERIFY_READ, arg1,arg2, 0)))\ngoto efault;",
"if (!(VAR_2 = lock_user_string(arg3)))\ngoto mincore_fail;",
"ret = get_errno(mincore(a, arg2, VAR_2));",
"unlock_user(VAR_2, arg3, ret);",
"mincore_fail:\nunlock_user(a, arg1, 0);",
"}",
"break;",
"#endif\n#ifdef TARGET_NR_arm_fadvise64_64\ncase TARGET_NR_arm_fadvise64_64:\n{",
"abi_long VAR_23;",
"VAR_23 = arg3;",
"arg3 = arg4;",
"arg4 = VAR_23;",
"}",
"#endif\n#if defined(TARGET_NR_fadvise64_64) || defined(TARGET_NR_arm_fadvise64_64) || defined(TARGET_NR_fadvise64)\n#ifdef TARGET_NR_fadvise64_64\ncase TARGET_NR_fadvise64_64:\n#endif\n#ifdef TARGET_NR_fadvise64\ncase TARGET_NR_fadvise64:\n#endif\n#ifdef TARGET_S390X\nswitch (arg4) {",
"case 4: arg4 = POSIX_FADV_NOREUSE + 1; break;",
"case 5: arg4 = POSIX_FADV_NOREUSE + 2; break;",
"case 6: arg4 = POSIX_FADV_DONTNEED; break;",
"case 7: arg4 = POSIX_FADV_NOREUSE; break;",
"default: break;",
"}",
"#endif\nret = -posix_fadvise(arg1, arg2, arg3, arg4);",
"break;",
"#endif\n#ifdef TARGET_NR_madvise\ncase TARGET_NR_madvise:\nret = get_errno(0);",
"break;",
"#endif\n#if TARGET_ABI_BITS == 32\ncase TARGET_NR_fcntl64:\n{",
"int cmd;",
"struct flock64 fl;",
"struct target_flock64 *target_fl;",
"#ifdef TARGET_ARM\nstruct target_eabi_flock64 *target_efl;",
"#endif\ncmd = target_to_host_fcntl_cmd(arg2);",
"if (cmd == -TARGET_EINVAL)\nreturn cmd;",
"switch(arg2) {",
"case TARGET_F_GETLK64:\n#ifdef TARGET_ARM\nif (((CPUARMState *)cpu_env)->eabi) {",
"if (!lock_user_struct(VERIFY_READ, target_efl, arg3, 1))\ngoto efault;",
"fl.l_type = tswap16(target_efl->l_type);",
"fl.l_whence = tswap16(target_efl->l_whence);",
"fl.l_start = tswap64(target_efl->l_start);",
"fl.l_len = tswap64(target_efl->l_len);",
"fl.l_pid = tswap32(target_efl->l_pid);",
"unlock_user_struct(target_efl, arg3, 0);",
"} else",
"#endif\n{",
"if (!lock_user_struct(VERIFY_READ, target_fl, arg3, 1))\ngoto efault;",
"fl.l_type = tswap16(target_fl->l_type);",
"fl.l_whence = tswap16(target_fl->l_whence);",
"fl.l_start = tswap64(target_fl->l_start);",
"fl.l_len = tswap64(target_fl->l_len);",
"fl.l_pid = tswap32(target_fl->l_pid);",
"unlock_user_struct(target_fl, arg3, 0);",
"}",
"ret = get_errno(fcntl(arg1, cmd, &fl));",
"if (ret == 0) {",
"#ifdef TARGET_ARM\nif (((CPUARMState *)cpu_env)->eabi) {",
"if (!lock_user_struct(VERIFY_WRITE, target_efl, arg3, 0))\ngoto efault;",
"target_efl->l_type = tswap16(fl.l_type);",
"target_efl->l_whence = tswap16(fl.l_whence);",
"target_efl->l_start = tswap64(fl.l_start);",
"target_efl->l_len = tswap64(fl.l_len);",
"target_efl->l_pid = tswap32(fl.l_pid);",
"unlock_user_struct(target_efl, arg3, 1);",
"} else",
"#endif\n{",
"if (!lock_user_struct(VERIFY_WRITE, target_fl, arg3, 0))\ngoto efault;",
"target_fl->l_type = tswap16(fl.l_type);",
"target_fl->l_whence = tswap16(fl.l_whence);",
"target_fl->l_start = tswap64(fl.l_start);",
"target_fl->l_len = tswap64(fl.l_len);",
"target_fl->l_pid = tswap32(fl.l_pid);",
"unlock_user_struct(target_fl, arg3, 1);",
"}",
"}",
"break;",
"case TARGET_F_SETLK64:\ncase TARGET_F_SETLKW64:\n#ifdef TARGET_ARM\nif (((CPUARMState *)cpu_env)->eabi) {",
"if (!lock_user_struct(VERIFY_READ, target_efl, arg3, 1))\ngoto efault;",
"fl.l_type = tswap16(target_efl->l_type);",
"fl.l_whence = tswap16(target_efl->l_whence);",
"fl.l_start = tswap64(target_efl->l_start);",
"fl.l_len = tswap64(target_efl->l_len);",
"fl.l_pid = tswap32(target_efl->l_pid);",
"unlock_user_struct(target_efl, arg3, 0);",
"} else",
"#endif\n{",
"if (!lock_user_struct(VERIFY_READ, target_fl, arg3, 1))\ngoto efault;",
"fl.l_type = tswap16(target_fl->l_type);",
"fl.l_whence = tswap16(target_fl->l_whence);",
"fl.l_start = tswap64(target_fl->l_start);",
"fl.l_len = tswap64(target_fl->l_len);",
"fl.l_pid = tswap32(target_fl->l_pid);",
"unlock_user_struct(target_fl, arg3, 0);",
"}",
"ret = get_errno(fcntl(arg1, cmd, &fl));",
"break;",
"default:\nret = do_fcntl(arg1, arg2, arg3);",
"break;",
"}",
"break;",
"}",
"#endif\n#ifdef TARGET_NR_cacheflush\ncase TARGET_NR_cacheflush:\nret = 0;",
"break;",
"#endif\n#ifdef TARGET_NR_security\ncase TARGET_NR_security:\ngoto unimplemented;",
"#endif\n#ifdef TARGET_NR_getpagesize\ncase TARGET_NR_getpagesize:\nret = TARGET_PAGE_SIZE;",
"break;",
"#endif\ncase TARGET_NR_gettid:\nret = get_errno(gettid());",
"break;",
"#ifdef TARGET_NR_readahead\ncase TARGET_NR_readahead:\n#if TARGET_ABI_BITS == 32\n#ifdef TARGET_ARM\nif (((CPUARMState *)cpu_env)->eabi)\n{",
"arg2 = arg3;",
"arg3 = arg4;",
"arg4 = arg5;",
"}",
"#endif\nret = get_errno(readahead(arg1, ((off64_t)arg3 << 32) | arg2, arg4));",
"#else\nret = get_errno(readahead(arg1, arg2, arg3));",
"#endif\nbreak;",
"#endif\n#ifdef TARGET_NR_setxattr\ncase TARGET_NR_setxattr:\ncase TARGET_NR_lsetxattr:\ncase TARGET_NR_fsetxattr:\ncase TARGET_NR_getxattr:\ncase TARGET_NR_lgetxattr:\ncase TARGET_NR_fgetxattr:\ncase TARGET_NR_listxattr:\ncase TARGET_NR_llistxattr:\ncase TARGET_NR_flistxattr:\ncase TARGET_NR_removexattr:\ncase TARGET_NR_lremovexattr:\ncase TARGET_NR_fremovexattr:\nret = -TARGET_EOPNOTSUPP;",
"break;",
"#endif\n#ifdef TARGET_NR_set_thread_area\ncase TARGET_NR_set_thread_area:\n#if defined(TARGET_MIPS)\n((CPUMIPSState *) cpu_env)->tls_value = arg1;",
"ret = 0;",
"break;",
"#elif defined(TARGET_CRIS)\nif (arg1 & 0xff)\nret = -TARGET_EINVAL;",
"else {",
"((CPUCRISState *) cpu_env)->pregs[PR_PID] = arg1;",
"ret = 0;",
"}",
"break;",
"#elif defined(TARGET_I386) && defined(TARGET_ABI32)\nret = do_set_thread_area(cpu_env, arg1);",
"break;",
"#else\ngoto unimplemented_nowarn;",
"#endif\n#endif\n#ifdef TARGET_NR_get_thread_area\ncase TARGET_NR_get_thread_area:\n#if defined(TARGET_I386) && defined(TARGET_ABI32)\nret = do_get_thread_area(cpu_env, arg1);",
"#else\ngoto unimplemented_nowarn;",
"#endif\n#endif\n#ifdef TARGET_NR_getdomainname\ncase TARGET_NR_getdomainname:\ngoto unimplemented_nowarn;",
"#endif\n#ifdef TARGET_NR_clock_gettime\ncase TARGET_NR_clock_gettime:\n{",
"struct timespec VAR_42;",
"ret = get_errno(clock_gettime(arg1, &VAR_42));",
"if (!is_error(ret)) {",
"host_to_target_timespec(arg2, &VAR_42);",
"}",
"break;",
"}",
"#endif\n#ifdef TARGET_NR_clock_getres\ncase TARGET_NR_clock_getres:\n{",
"struct timespec VAR_42;",
"ret = get_errno(clock_getres(arg1, &VAR_42));",
"if (!is_error(ret)) {",
"host_to_target_timespec(arg2, &VAR_42);",
"}",
"break;",
"}",
"#endif\n#ifdef TARGET_NR_clock_nanosleep\ncase TARGET_NR_clock_nanosleep:\n{",
"struct timespec VAR_42;",
"target_to_host_timespec(&VAR_42, arg3);",
"ret = get_errno(clock_nanosleep(arg1, arg2, &VAR_42, arg4 ? &VAR_42 : NULL));",
"if (arg4)\nhost_to_target_timespec(arg4, &VAR_42);",
"break;",
"}",
"#endif\n#if defined(TARGET_NR_set_tid_address) && defined(__NR_set_tid_address)\ncase TARGET_NR_set_tid_address:\nret = get_errno(set_tid_address((int *)g2h(arg1)));",
"break;",
"#endif\n#if defined(TARGET_NR_tkill) && defined(__NR_tkill)\ncase TARGET_NR_tkill:\nret = get_errno(sys_tkill((int)arg1, target_to_host_signal(arg2)));",
"break;",
"#endif\n#if defined(TARGET_NR_tgkill) && defined(__NR_tgkill)\ncase TARGET_NR_tgkill:\nret = get_errno(sys_tgkill((int)arg1, (int)arg2,\ntarget_to_host_signal(arg3)));",
"break;",
"#endif\n#ifdef TARGET_NR_set_robust_list\ncase TARGET_NR_set_robust_list:\ngoto unimplemented_nowarn;",
"#endif\n#if defined(TARGET_NR_utimensat) && defined(__NR_utimensat)\ncase TARGET_NR_utimensat:\n{",
"struct timespec *tsp, VAR_42[2];",
"if (!arg3) {",
"tsp = NULL;",
"} else {",
"target_to_host_timespec(VAR_42, arg3);",
"target_to_host_timespec(VAR_42+1, arg3+sizeof(struct target_timespec));",
"tsp = VAR_42;",
"}",
"if (!arg2)\nret = get_errno(sys_utimensat(arg1, NULL, tsp, arg4));",
"else {",
"if (!(VAR_2 = lock_user_string(arg2))) {",
"ret = -TARGET_EFAULT;",
"goto fail;",
"}",
"ret = get_errno(sys_utimensat(arg1, path(VAR_2), tsp, arg4));",
"unlock_user(VAR_2, arg2, 0);",
"}",
"}",
"break;",
"#endif\n#if defined(CONFIG_USE_NPTL)\ncase TARGET_NR_futex:\nret = do_futex(arg1, arg2, arg3, arg4, arg5, arg6);",
"break;",
"#endif\n#if defined(TARGET_NR_inotify_init) && defined(__NR_inotify_init)\ncase TARGET_NR_inotify_init:\nret = get_errno(sys_inotify_init());",
"break;",
"#endif\n#if defined(TARGET_NR_inotify_add_watch) && defined(__NR_inotify_add_watch)\ncase TARGET_NR_inotify_add_watch:\nVAR_2 = lock_user_string(arg2);",
"ret = get_errno(sys_inotify_add_watch(arg1, path(VAR_2), arg3));",
"unlock_user(VAR_2, arg2, 0);",
"break;",
"#endif\n#if defined(TARGET_NR_inotify_rm_watch) && defined(__NR_inotify_rm_watch)\ncase TARGET_NR_inotify_rm_watch:\nret = get_errno(sys_inotify_rm_watch(arg1, arg2));",
"break;",
"#endif\n#if defined(TARGET_NR_mq_open) && defined(__NR_mq_open)\ncase TARGET_NR_mq_open:\n{",
"struct mq_attr posix_mq_attr;",
"VAR_2 = lock_user_string(arg1 - 1);",
"if (arg4 != 0)\ncopy_from_user_mq_attr (&posix_mq_attr, arg4);",
"ret = get_errno(mq_open(VAR_2, arg2, arg3, &posix_mq_attr));",
"unlock_user (VAR_2, arg1, 0);",
"}",
"break;",
"case TARGET_NR_mq_unlink:\nVAR_2 = lock_user_string(arg1 - 1);",
"ret = get_errno(mq_unlink(VAR_2));",
"unlock_user (VAR_2, arg1, 0);",
"break;",
"case TARGET_NR_mq_timedsend:\n{",
"struct timespec VAR_42;",
"VAR_2 = lock_user (VERIFY_READ, arg2, arg3, 1);",
"if (arg5 != 0) {",
"target_to_host_timespec(&VAR_42, arg5);",
"ret = get_errno(mq_timedsend(arg1, VAR_2, arg3, arg4, &VAR_42));",
"host_to_target_timespec(arg5, &VAR_42);",
"}",
"else\nret = get_errno(mq_send(arg1, VAR_2, arg3, arg4));",
"unlock_user (VAR_2, arg2, arg3);",
"}",
"break;",
"case TARGET_NR_mq_timedreceive:\n{",
"struct timespec VAR_42;",
"unsigned int prio;",
"VAR_2 = lock_user (VERIFY_READ, arg2, arg3, 1);",
"if (arg5 != 0) {",
"target_to_host_timespec(&VAR_42, arg5);",
"ret = get_errno(mq_timedreceive(arg1, VAR_2, arg3, &prio, &VAR_42));",
"host_to_target_timespec(arg5, &VAR_42);",
"}",
"else\nret = get_errno(mq_receive(arg1, VAR_2, arg3, &prio));",
"unlock_user (VAR_2, arg2, arg3);",
"if (arg4 != 0)\nput_user_u32(prio, arg4);",
"}",
"break;",
"case TARGET_NR_mq_getsetattr:\n{",
"struct mq_attr posix_mq_attr_in, posix_mq_attr_out;",
"ret = 0;",
"if (arg3 != 0) {",
"ret = mq_getattr(arg1, &posix_mq_attr_out);",
"copy_to_user_mq_attr(arg3, &posix_mq_attr_out);",
"}",
"if (arg2 != 0) {",
"copy_from_user_mq_attr(&posix_mq_attr_in, arg2);",
"ret |= mq_setattr(arg1, &posix_mq_attr_in, &posix_mq_attr_out);",
"}",
"}",
"break;",
"#endif\n#ifdef CONFIG_SPLICE\n#ifdef TARGET_NR_tee\ncase TARGET_NR_tee:\n{",
"ret = get_errno(tee(arg1,arg2,arg3,arg4));",
"}",
"break;",
"#endif\n#ifdef TARGET_NR_splice\ncase TARGET_NR_splice:\n{",
"loff_t loff_in, loff_out;",
"loff_t *ploff_in = NULL, *ploff_out = NULL;",
"if(arg2) {",
"get_user_u64(loff_in, arg2);",
"ploff_in = &loff_in;",
"}",
"if(arg4) {",
"get_user_u64(loff_out, arg2);",
"ploff_out = &loff_out;",
"}",
"ret = get_errno(splice(arg1, ploff_in, arg3, ploff_out, arg5, arg6));",
"}",
"break;",
"#endif\n#ifdef TARGET_NR_vmsplice\ncase TARGET_NR_vmsplice:\n{",
"int VAR_40 = arg3;",
"struct iovec *VAR_40;",
"VAR_40 = alloca(VAR_40 * sizeof(struct iovec));",
"if (lock_iovec(VERIFY_READ, VAR_40, arg2, VAR_40, 1) < 0)\ngoto efault;",
"ret = get_errno(vmsplice(arg1, VAR_40, VAR_40, arg4));",
"unlock_iovec(VAR_40, arg2, VAR_40, 0);",
"}",
"break;",
"#endif\n#endif\n#ifdef CONFIG_EVENTFD\n#if defined(TARGET_NR_eventfd)\ncase TARGET_NR_eventfd:\nret = get_errno(eventfd(arg1, 0));",
"break;",
"#endif\n#if defined(TARGET_NR_eventfd2)\ncase TARGET_NR_eventfd2:\nret = get_errno(eventfd(arg1, arg2));",
"break;",
"#endif\n#endif\ndefault:\nunimplemented:\ngemu_log(\"qemu: Unsupported syscall: %d\\n\", num);",
"#if defined(TARGET_NR_setxattr) || defined(TARGET_NR_get_thread_area) || defined(TARGET_NR_getdomainname) || defined(TARGET_NR_set_robust_list)\nunimplemented_nowarn:\n#endif\nret = -TARGET_ENOSYS;",
"break;",
"}",
"fail:\n#ifdef DEBUG\ngemu_log(\" = \" TARGET_ABI_FMT_ld \"\\n\", ret);",
"#endif\nif(do_strace)\nprint_syscall_ret(num, ret);",
"return ret;",
"efault:\nret = -TARGET_EFAULT;",
"goto fail;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
27
],
[
31
],
[
33,
35,
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
77,
79
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93,
95
],
[
97
],
[
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,
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
],
[
385
],
[
387
],
[
389
],
[
391,
393
],
[
395,
397
],
[
399
],
[
401
],
[
403
],
[
405
],
[
407
],
[
409,
411
],
[
413,
415
],
[
417
],
[
419
],
[
423
],
[
425
],
[
429
],
[
431
],
[
433,
435
],
[
437,
439
],
[
441,
443
],
[
445
],
[
447
],
[
451
],
[
453
],
[
455,
457
],
[
459,
461
],
[
463,
465
],
[
467
],
[
469
],
[
473,
475
],
[
477
],
[
479
],
[
483
],
[
487,
489
],
[
493,
495
],
[
497
],
[
499,
501,
503
],
[
505
],
[
507
],
[
509
],
[
511
],
[
513,
515,
517
],
[
519
],
[
521
],
[
523
],
[
525
],
[
527,
529,
531
],
[
533
],
[
535
],
[
537
],
[
539,
541,
543
],
[
545
],
[
547
],
[
549,
551,
553,
555
],
[
557
],
[
559
],
[
561,
563,
565,
567
],
[
569
],
[
571
],
[
573
],
[
575,
577,
579,
581
],
[
583
],
[
585
],
[
587
],
[
589,
591,
593,
595
],
[
597
],
[
599
],
[
601
],
[
603,
605,
607
],
[
609,
611,
613,
615
],
[
617,
619,
621
],
[
623
],
[
625,
627,
629,
631,
633,
635
],
[
637
],
[
639,
641
],
[
645
],
[
647
],
[
649
],
[
651
],
[
653,
655
],
[
657,
667
],
[
669
],
[
671
],
[
673
],
[
675
],
[
677
],
[
679,
681,
683,
685
],
[
687
],
[
689
],
[
691
],
[
693,
695,
697,
699
],
[
701
],
[
703,
705
],
[
707
],
[
709
],
[
711
],
[
713,
715,
717
],
[
719,
721,
723
],
[
725
],
[
727,
729,
731,
733
],
[
735,
737,
739,
741
],
[
743
],
[
745,
747,
749,
751
],
[
753
],
[
755
],
[
757
],
[
759,
761
],
[
763
],
[
765
],
[
767
],
[
769
],
[
771
],
[
773
],
[
775
],
[
777,
779
],
[
781
],
[
783
],
[
785
],
[
787
],
[
789,
791,
793
],
[
795
],
[
797
],
[
799,
801,
803,
805
],
[
807
],
[
809
],
[
811
],
[
813
],
[
815,
817
],
[
819
],
[
821
],
[
823
],
[
825
],
[
827,
829,
831
],
[
833
],
[
835
],
[
837,
839,
841,
843
],
[
845
],
[
847
],
[
849
],
[
851
],
[
853,
855
],
[
857
],
[
859
],
[
861
],
[
863
],
[
865,
867,
869,
871
],
[
873,
875,
877,
879
],
[
881,
883,
885,
887
],
[
889
],
[
891
],
[
893
],
[
895,
897,
899,
901
],
[
903
],
[
905
],
[
907
],
[
909,
911,
913,
915
],
[
917
],
[
919,
921,
923,
925
],
[
927,
929,
931
],
[
933
],
[
935
],
[
937,
939
],
[
941
],
[
943,
945
],
[
947
],
[
949
],
[
951
],
[
953,
955
],
[
957,
959
],
[
961
],
[
963
],
[
965
],
[
967
],
[
969,
971,
973
],
[
975
],
[
977
],
[
979
],
[
981,
983
],
[
985,
987
],
[
989
],
[
991
],
[
993
],
[
995
],
[
997,
999,
1001,
1003
],
[
1005
],
[
1007
],
[
1009
],
[
1011,
1013,
1015,
1017
],
[
1019
],
[
1021
],
[
1023
],
[
1025,
1027,
1029,
1031
],
[
1033
],
[
1035
],
[
1037
],
[
1039,
1041
],
[
1043
],
[
1045,
1047
],
[
1049
],
[
1051,
1053,
1055
],
[
1057
],
[
1059,
1061,
1063
],
[
1065
],
[
1067
],
[
1069
],
[
1071
],
[
1073
],
[
1075,
1077
],
[
1079
],
[
1081
],
[
1083
],
[
1085
],
[
1087
],
[
1089,
1091
],
[
1093
],
[
1095
],
[
1097,
1099,
1101
],
[
1103,
1105,
1107,
1109
],
[
1111,
1113,
1115
],
[
1117
],
[
1119
],
[
1121,
1123
],
[
1125
],
[
1127
],
[
1129
],
[
1131
],
[
1133,
1135,
1137,
1139
],
[
1141
],
[
1143
],
[
1145
],
[
1147,
1149,
1151,
1153
],
[
1155,
1157,
1159
],
[
1161
],
[
1163,
1165
],
[
1167
],
[
1169,
1171,
1173
],
[
1175,
1177,
1179
],
[
1181
],
[
1183,
1185,
1187
],
[
1189,
1191,
1193,
1195
],
[
1197,
1199,
1201
],
[
1203
],
[
1205,
1207,
1209
],
[
1211
],
[
1213
],
[
1215
],
[
1217,
1219
],
[
1221,
1223
],
[
1225
],
[
1227,
1229,
1231
],
[
1233
],
[
1235,
1237,
1239
],
[
1241
],
[
1243,
1245
],
[
1247
],
[
1249,
1251,
1253
],
[
1255,
1257
],
[
1259
],
[
1261
],
[
1263,
1265
],
[
1267
],
[
1269
],
[
1271
],
[
1273
],
[
1275
],
[
1277
],
[
1279
],
[
1281
],
[
1283
],
[
1285
],
[
1287
],
[
1289,
1291
],
[
1293
],
[
1295
],
[
1297
],
[
1299
],
[
1301
],
[
1303
],
[
1305,
1307
],
[
1311
],
[
1313,
1315
],
[
1317
],
[
1319
],
[
1321
],
[
1323
],
[
1325
],
[
1327
],
[
1329
],
[
1331
],
[
1335
],
[
1339
],
[
1341,
1343
],
[
1345
],
[
1347
],
[
1349
],
[
1351
],
[
1353
],
[
1355
],
[
1357
],
[
1359
],
[
1361,
1363
],
[
1365
],
[
1367,
1369,
1371
],
[
1373
],
[
1375
],
[
1379
],
[
1381,
1383
],
[
1385
],
[
1387
],
[
1389
],
[
1391
],
[
1393
],
[
1395
],
[
1397
],
[
1399
],
[
1401
],
[
1403
],
[
1405,
1407,
1409
],
[
1411,
1413
],
[
1415
],
[
1417
],
[
1419,
1421,
1423
],
[
1425
],
[
1427
],
[
1429
],
[
1431
],
[
1433
],
[
1435
],
[
1437
],
[
1439,
1441,
1443,
1445
],
[
1447
],
[
1449
],
[
1451
],
[
1453
],
[
1455
],
[
1457
],
[
1459
],
[
1461
],
[
1463
],
[
1465
],
[
1467,
1469,
1471,
1473
],
[
1475
],
[
1477
],
[
1481
],
[
1483
],
[
1485,
1487
],
[
1489
],
[
1491,
1493
],
[
1495
],
[
1497,
1499
],
[
1501
],
[
1503,
1505
],
[
1507
],
[
1509
],
[
1511,
1513
],
[
1515
],
[
1517
],
[
1519
],
[
1521
],
[
1523
],
[
1525
],
[
1527
],
[
1529
],
[
1531
],
[
1533,
1535
],
[
1537
],
[
1539
],
[
1541
],
[
1543
],
[
1545
],
[
1547,
1549,
1551
],
[
1553
],
[
1555
],
[
1559
],
[
1561
],
[
1563,
1565
],
[
1567
],
[
1569,
1571
],
[
1573
],
[
1575,
1577
],
[
1579
],
[
1581,
1583
],
[
1585
],
[
1587
],
[
1589,
1591
],
[
1593
],
[
1595
],
[
1597
],
[
1599
],
[
1601
],
[
1603
],
[
1605
],
[
1607
],
[
1609
],
[
1611,
1613
],
[
1615
],
[
1617
],
[
1619
],
[
1621
],
[
1623
],
[
1625,
1627,
1629
],
[
1631
],
[
1633
],
[
1635
],
[
1637,
1639
],
[
1641
],
[
1643
],
[
1645
],
[
1647
],
[
1649
],
[
1651,
1653,
1655
],
[
1657
],
[
1659
],
[
1661
],
[
1663,
1665
],
[
1667
],
[
1669
],
[
1671
],
[
1673
],
[
1675
],
[
1677,
1679,
1681
],
[
1683
],
[
1685,
1687
],
[
1689
],
[
1691
],
[
1693
],
[
1695
],
[
1697
],
[
1699,
1701,
1703
],
[
1705
],
[
1707,
1709
],
[
1711
],
[
1713
],
[
1715
],
[
1717
],
[
1719
],
[
1721,
1723
],
[
1725
],
[
1727
],
[
1729
],
[
1733,
1735
],
[
1737
],
[
1739
],
[
1741
],
[
1743
],
[
1745
],
[
1747
],
[
1749
],
[
1751
],
[
1753
],
[
1755
],
[
1757,
1759
],
[
1761
],
[
1763
],
[
1765
],
[
1767
],
[
1769
],
[
1771,
1773
],
[
1775
],
[
1777,
1779
],
[
1781
],
[
1783
],
[
1785
],
[
1787
],
[
1789
],
[
1791,
1793,
1797
],
[
1799
],
[
1801,
1803,
1807
],
[
1809
],
[
1811,
1813,
1815
],
[
1817
],
[
1819
],
[
1821
],
[
1823,
1825
],
[
1829
],
[
1831
],
[
1833
],
[
1835,
1837
],
[
1839
],
[
1841
],
[
1843
],
[
1845
],
[
1847
],
[
1849
],
[
1851,
1853
],
[
1857
],
[
1859
],
[
1861
],
[
1865
],
[
1867
],
[
1869,
1871
],
[
1873
],
[
1875
],
[
1877
],
[
1879
],
[
1881
],
[
1883
],
[
1885,
1887
],
[
1889
],
[
1891
],
[
1893
],
[
1895
],
[
1897
],
[
1899
],
[
1901
],
[
1903,
1905
],
[
1907
],
[
1909
],
[
1911
],
[
1913,
1915
],
[
1917
],
[
1919
],
[
1921
],
[
1923,
1925
],
[
1927
],
[
1929,
1931
],
[
1933
],
[
1935
],
[
1937
],
[
1939,
1941,
1943
],
[
1945
],
[
1947
],
[
1949
],
[
1953,
1955
],
[
1957
],
[
1959
],
[
1961
],
[
1963
],
[
1965
],
[
1967
],
[
1969
],
[
1971
],
[
1973
],
[
1975,
1977,
1979
],
[
1981
],
[
1983
],
[
1985
],
[
1987,
1989
],
[
1991,
1993
],
[
1995
],
[
1997
],
[
1999
],
[
2001
],
[
2003,
2005,
2007
],
[
2009
],
[
2011
],
[
2013
],
[
2015,
2017
],
[
2019,
2021
],
[
2023
],
[
2025
],
[
2027
],
[
2029
],
[
2031,
2033,
2035,
2037
],
[
2039,
2041,
2043
],
[
2045
],
[
2047
],
[
2049
],
[
2051,
2053
],
[
2055
],
[
2057
],
[
2059
],
[
2061
],
[
2063
],
[
2065
],
[
2067
],
[
2069,
2071
],
[
2073
],
[
2075
],
[
2077
],
[
2079
],
[
2081
],
[
2083,
2085,
2087
],
[
2089
],
[
2091
],
[
2093
],
[
2095,
2097
],
[
2099,
2101
],
[
2103
],
[
2105
],
[
2107
],
[
2109
],
[
2111,
2113,
2115,
2117
],
[
2119,
2121,
2123,
2125,
2127
],
[
2129
],
[
2131
],
[
2133
],
[
2135,
2137,
2139
],
[
2141,
2143,
2145
],
[
2147,
2149,
2151,
2153,
2155
],
[
2157
],
[
2159
],
[
2161,
2163
],
[
2165
],
[
2167
],
[
2169
],
[
2171
],
[
2173
],
[
2175
],
[
2177
],
[
2179,
2181,
2183
],
[
2185
],
[
2187,
2189,
2191,
2193,
2195
],
[
2197,
2199
],
[
2201,
2203,
2205,
2207,
2209,
2211,
2213,
2215,
2217,
2219
],
[
2221
],
[
2223,
2225,
2227
],
[
2229
],
[
2231,
2233
],
[
2235
],
[
2237,
2239,
2241
],
[
2243
],
[
2245,
2249,
2251,
2253
],
[
2255
],
[
2257,
2259,
2261,
2263
],
[
2265
],
[
2267,
2269,
2271,
2273
],
[
2275
],
[
2277,
2279,
2281,
2283
],
[
2285
],
[
2287,
2289,
2291,
2293
],
[
2295
],
[
2297,
2299,
2301,
2303
],
[
2305
],
[
2307
],
[
2309
],
[
2311,
2313
],
[
2315
],
[
2317,
2319
],
[
2321
],
[
2323,
2325,
2327,
2329
],
[
2331
],
[
2333
],
[
2335
],
[
2337,
2339,
2347
],
[
2349
],
[
2351,
2353
],
[
2355
],
[
2357,
2359,
2361
],
[
2363,
2365,
2367,
2369
],
[
2371
],
[
2373
],
[
2375,
2377
],
[
2379
],
[
2383,
2385
],
[
2387
],
[
2389
],
[
2391
],
[
2393
],
[
2395
],
[
2397
],
[
2399
],
[
2401
],
[
2403
],
[
2405
],
[
2407
],
[
2409
],
[
2411
],
[
2413,
2415
],
[
2417
],
[
2419,
2421,
2423,
2425
],
[
2427
],
[
2429
],
[
2431,
2433
],
[
2435
],
[
2439,
2441
],
[
2443
],
[
2445
],
[
2447
],
[
2449
],
[
2451
],
[
2453
],
[
2455
],
[
2457
],
[
2459
],
[
2461
],
[
2463
],
[
2465
],
[
2467
],
[
2469,
2471
],
[
2473
],
[
2475,
2477,
2479,
2481
],
[
2483,
2485,
2487,
2489
],
[
2491
],
[
2493,
2495,
2497,
2499
],
[
2501
],
[
2503,
2505,
2507,
2509
],
[
2511
],
[
2513,
2515,
2517,
2519
],
[
2521
],
[
2523,
2525,
2527,
2529
],
[
2531
],
[
2533,
2535,
2537,
2539
],
[
2541
],
[
2543,
2545,
2547,
2549
],
[
2551
],
[
2553,
2555,
2557,
2559
],
[
2561
],
[
2563,
2565,
2567,
2569
],
[
2571
],
[
2573,
2575,
2577,
2579
],
[
2581
],
[
2583,
2585,
2587,
2589
],
[
2591
],
[
2593,
2595,
2597,
2599
],
[
2601
],
[
2603,
2605,
2607,
2609
],
[
2611
],
[
2613,
2615,
2617,
2619
],
[
2621
],
[
2623,
2625,
2627,
2629
],
[
2631
],
[
2633,
2635,
2637,
2639
],
[
2641
],
[
2643,
2645,
2647,
2649
],
[
2651
],
[
2653,
2655,
2657,
2659
],
[
2661
],
[
2663,
2667,
2669,
2671
],
[
2673
],
[
2675
],
[
2677
],
[
2681,
2683
],
[
2685
],
[
2689
],
[
2691
],
[
2693,
2695,
2697,
2699
],
[
2701
],
[
2703
],
[
2705
],
[
2707
],
[
2709
],
[
2711,
2713,
2715,
2717,
2719
],
[
2721
],
[
2723
],
[
2725
],
[
2727,
2729
],
[
2731
],
[
2735
],
[
2737
],
[
2739,
2741,
2743,
2745,
2747
],
[
2749
],
[
2751
],
[
2753
],
[
2755,
2757,
2759
],
[
2761
],
[
2763
],
[
2765
],
[
2767,
2769,
2771
],
[
2773
],
[
2775
],
[
2777
],
[
2779,
2781
],
[
2783
],
[
2785,
2787
],
[
2789
],
[
2793,
2795
],
[
2798
],
[
2800
],
[
2802
],
[
2804
],
[
2806
],
[
2808
],
[
2810
],
[
2812
],
[
2814
],
[
2816
],
[
2818
],
[
2820
],
[
2822
],
[
2824
],
[
2826
],
[
2828
],
[
2830
],
[
2832,
2834,
2836
],
[
2838,
2840,
2842,
2844
],
[
2846,
2848,
2850
],
[
2852
],
[
2854,
2856,
2858
],
[
2860,
2862,
2864,
2866
],
[
2868
],
[
2870,
2872,
2874
],
[
2876
],
[
2878
],
[
2880
],
[
2882
],
[
2884,
2886
],
[
2888,
2890
],
[
2892
],
[
2894
],
[
2896
],
[
2898
],
[
2900,
2902
],
[
2904
],
[
2906,
2908
],
[
2910
],
[
2912
],
[
2914
],
[
2916,
2918,
2920,
2922
],
[
2924
],
[
2926
],
[
2928
],
[
2930,
2932,
2934
],
[
2936
],
[
2938
],
[
2940
],
[
2942,
2944
],
[
2946,
2948
],
[
2950
],
[
2952
],
[
2954
],
[
2956
],
[
2958
],
[
2960
],
[
2962
],
[
2964
],
[
2966
],
[
2968
],
[
2970
],
[
2972
],
[
2974
],
[
2976
],
[
2978
],
[
2980
],
[
2982
],
[
2984
],
[
2986,
2988,
2990
],
[
2992
],
[
2994,
2996,
2998,
3000
],
[
3002
],
[
3004,
3006,
3008,
3010
],
[
3012
],
[
3014,
3016,
3018,
3020
],
[
3022
],
[
3024,
3026,
3028,
3030
],
[
3032
],
[
3034,
3036,
3038,
3040
],
[
3042
],
[
3044,
3046,
3048,
3050
],
[
3052
],
[
3054,
3056,
3058,
3060
],
[
3062
],
[
3064,
3066,
3068,
3070
],
[
3072
],
[
3074,
3076,
3078,
3080
],
[
3082
],
[
3084,
3086,
3088,
3090
],
[
3092
],
[
3094,
3096,
3098,
3100
],
[
3102
],
[
3104,
3106,
3108
],
[
3110
],
[
3112,
3114,
3116
],
[
3118,
3120
],
[
3122,
3124
],
[
3126,
3128
],
[
3130,
3134,
3136,
3138
],
[
3140,
3142
],
[
3144
],
[
3146
],
[
3148,
3150,
3152,
3154
],
[
3156
],
[
3158
],
[
3160
],
[
3162,
3166
],
[
3168
],
[
3172,
3174
],
[
3176
],
[
3178
],
[
3184
],
[
3188,
3190
],
[
3192
],
[
3194
],
[
3196
],
[
3198
],
[
3200,
3202,
3204
],
[
3206
],
[
3208,
3210,
3212
],
[
3214,
3216
],
[
3218
],
[
3220,
3222,
3224,
3226
],
[
3228,
3230,
3232,
3234,
3236,
3238,
3240,
3242,
3244
],
[
3246,
3248
],
[
3250,
3252
],
[
3254
],
[
3256,
3258
],
[
3260
],
[
3262,
3264,
3266
],
[
3268,
3270,
3272,
3274
],
[
3276,
3278,
3280
],
[
3282
],
[
3284,
3286,
3288
],
[
3290,
3292,
3294,
3296
],
[
3298,
3300
],
[
3302,
3304
],
[
3306,
3308
],
[
3310
],
[
3312,
3314
],
[
3316,
3318
],
[
3320
],
[
3322,
3324,
3326,
3328
],
[
3330
],
[
3332
],
[
3334
],
[
3338
],
[
3340
],
[
3342
],
[
3344
],
[
3346
],
[
3350
],
[
3352
],
[
3354
],
[
3356
],
[
3358
],
[
3360
],
[
3362
],
[
3366
],
[
3368
],
[
3370,
3372
],
[
3374
],
[
3376
],
[
3378
],
[
3380
],
[
3382
],
[
3384
],
[
3386
],
[
3388
],
[
3390,
3392
],
[
3396
],
[
3398
],
[
3400
],
[
3402
],
[
3404
],
[
3406
],
[
3408
],
[
3410
],
[
3412
],
[
3414
],
[
3416
],
[
3418,
3420
],
[
3422
],
[
3424
],
[
3428,
3430
],
[
3432
],
[
3434
],
[
3436
],
[
3438
],
[
3440
],
[
3442
],
[
3444
],
[
3446
],
[
3448,
3450
],
[
3452
],
[
3454
],
[
3456
],
[
3458
],
[
3460
],
[
3462
],
[
3464
],
[
3466
],
[
3468
],
[
3470,
3472
],
[
3474,
3476,
3478
],
[
3480
],
[
3482
],
[
3484,
3486
],
[
3488
],
[
3490
],
[
3492
],
[
3494
],
[
3496
],
[
3498
],
[
3500
],
[
3502
],
[
3504,
3506
],
[
3508
],
[
3510
],
[
3512
],
[
3514
],
[
3516
],
[
3518
],
[
3520
],
[
3522
],
[
3524
],
[
3526
],
[
3528,
3530,
3532,
3534
],
[
3536
],
[
3538,
3540,
3542,
3544
],
[
3546
],
[
3548
],
[
3550
],
[
3552
],
[
3554
],
[
3558
],
[
3560,
3562
],
[
3564
],
[
3566
],
[
3568
],
[
3570
],
[
3572
],
[
3574
],
[
3576
],
[
3578
],
[
3580
],
[
3582
],
[
3584,
3586
],
[
3588
],
[
3590
],
[
3592
],
[
3594
],
[
3596,
3598,
3604
],
[
3606
],
[
3608,
3610
],
[
3612
],
[
3614
],
[
3618
],
[
3620,
3622
],
[
3624
],
[
3626
],
[
3628
],
[
3630
],
[
3632,
3634
],
[
3636
],
[
3638
],
[
3642
],
[
3644,
3646
],
[
3648
],
[
3650
],
[
3652
],
[
3654
],
[
3656,
3658
],
[
3660
],
[
3662,
3664,
3666
],
[
3668
],
[
3670,
3672,
3678
],
[
3680
],
[
3682,
3684
],
[
3686
],
[
3688
],
[
3692,
3694
],
[
3696
],
[
3698
],
[
3700
],
[
3702
],
[
3704
],
[
3706,
3708
],
[
3710
],
[
3712
],
[
3714
],
[
3716
],
[
3718,
3720
],
[
3722
],
[
3724
],
[
3726
],
[
3728
],
[
3730
],
[
3732,
3734
],
[
3736
],
[
3738
],
[
3740,
3742
],
[
3744
],
[
3746
],
[
3748
],
[
3750
],
[
3752
],
[
3754,
3756
],
[
3758
],
[
3760,
3762
],
[
3764
],
[
3766,
3768
],
[
3770
],
[
3772,
3774
],
[
3776
],
[
3778,
3780
],
[
3782
],
[
3784
],
[
3786
],
[
3788
],
[
3790
],
[
3792
],
[
3794
],
[
3796,
3798
],
[
3800
],
[
3802
],
[
3804
],
[
3806
],
[
3808
],
[
3810
],
[
3812
],
[
3814
],
[
3816,
3818,
3820
],
[
3822,
3824,
3826,
3828
],
[
3830,
3832,
3834,
3836
],
[
3838,
3840
],
[
3842
],
[
3844
],
[
3846,
3848,
3850
],
[
3852
],
[
3854
],
[
3856,
3858
],
[
3860
],
[
3862
],
[
3864
],
[
3866,
3868,
3870,
3872
],
[
3874
],
[
3876,
3878
],
[
3880,
3882,
3884,
3886,
3888,
3890,
3892
],
[
3894,
3896,
3898
],
[
3900
],
[
3902
],
[
3904
],
[
3906,
3908,
3910,
3912
],
[
3914,
3916,
3918
],
[
3920
],
[
3922
],
[
3924
],
[
3926,
3928,
3930,
3932,
3934
],
[
3936
],
[
3938
],
[
3940
],
[
3942,
3944,
3946
],
[
3948
],
[
3950
],
[
3952
],
[
3954,
3956,
3958,
3960
],
[
3962
],
[
3964
],
[
3966
],
[
3968,
3970
],
[
3972,
3974
],
[
3976,
3978,
3980,
3982,
3984
],
[
3986
],
[
3988,
3990
],
[
3992,
3994,
3996
],
[
3998,
4000,
4002
],
[
4004,
4006,
4008,
4010
],
[
4012,
4014,
4016,
4018,
4020
],
[
4022
],
[
4024,
4026,
4028,
4030
],
[
4032
],
[
4034
],
[
4036
],
[
4038
],
[
4040,
4042
],
[
4044
],
[
4046
],
[
4048
],
[
4050
],
[
4052
],
[
4054
],
[
4056,
4058,
4060,
4062,
4064
],
[
4066
],
[
4068
],
[
4070
],
[
4072,
4074,
4076,
4078
],
[
4080
],
[
4082,
4084,
4086,
4088,
4090
],
[
4092
],
[
4094
],
[
4096,
4098
],
[
4100
],
[
4102,
4104,
4106,
4108,
4110
],
[
4112
],
[
4114
],
[
4116,
4118
],
[
4120
],
[
4122,
4124,
4126,
4128
],
[
4130,
4132
],
[
4134
],
[
4136,
4138,
4140,
4142,
4144,
4146,
4148,
4150,
4152,
4154,
4156
],
[
4158,
4160
],
[
4162,
4164
],
[
4166,
4168,
4170
],
[
4172
],
[
4174,
4176,
4178,
4180,
4182
],
[
4184
],
[
4186
],
[
4188
],
[
4190,
4192
],
[
4194
],
[
4196,
4198
],
[
4200
],
[
4202,
4204
],
[
4206
],
[
4208,
4210
],
[
4212
],
[
4214,
4216
],
[
4218
],
[
4220,
4222
],
[
4224
],
[
4226,
4228
],
[
4230
],
[
4232
],
[
4234
],
[
4236
],
[
4240
],
[
4242
],
[
4244,
4246
],
[
4248
],
[
4250
],
[
4252,
4254
],
[
4256
],
[
4258
],
[
4260
],
[
4262
],
[
4264
],
[
4266
],
[
4268,
4270
],
[
4272
],
[
4274
],
[
4276
],
[
4278
],
[
4282
],
[
4284
],
[
4286
],
[
4288
],
[
4290
],
[
4292
],
[
4294
],
[
4296
],
[
4298
],
[
4300
],
[
4302
],
[
4304
],
[
4306,
4308
],
[
4310
],
[
4312,
4314,
4316,
4318
],
[
4320
],
[
4322
],
[
4324
],
[
4326,
4328,
4330,
4332,
4334,
4336
],
[
4338
],
[
4340,
4342,
4344,
4346
],
[
4348
],
[
4350
],
[
4352
],
[
4354,
4356,
4358,
4360
],
[
4362
],
[
4364
],
[
4366
],
[
4368,
4370,
4372,
4374,
4376,
4378
],
[
4380
],
[
4382,
4384,
4386,
4388
],
[
4390
],
[
4392
],
[
4394
],
[
4396,
4398,
4400,
4402
],
[
4404
],
[
4406
],
[
4408
],
[
4410,
4412,
4414,
4416
],
[
4418
],
[
4420
],
[
4422
],
[
4424,
4426
],
[
4428
],
[
4430,
4432
],
[
4434
],
[
4436,
4438
],
[
4440
],
[
4442,
4444
],
[
4446
],
[
4448,
4452,
4454,
4456,
4458
],
[
4460
],
[
4462
],
[
4464
],
[
4466,
4468,
4470,
4472
],
[
4474
],
[
4476,
4480,
4484,
4486
],
[
4488
],
[
4490
],
[
4492
],
[
4494
],
[
4496
],
[
4498
],
[
4500,
4502,
4506,
4508
],
[
4510
],
[
4512
],
[
4514
],
[
4516
],
[
4518
],
[
4520
],
[
4522,
4526,
4528,
4530
],
[
4532
],
[
4534,
4536,
4538,
4540
],
[
4542
],
[
4544,
4546,
4548,
4550
],
[
4552
],
[
4554,
4556,
4558,
4560
],
[
4562
],
[
4564,
4566,
4568,
4570
],
[
4572
],
[
4574,
4576,
4578,
4580
],
[
4582
],
[
4584
],
[
4586
],
[
4588
],
[
4592
],
[
4594
],
[
4596,
4598
],
[
4600
],
[
4602
],
[
4604
],
[
4606
],
[
4608
],
[
4610
],
[
4612
],
[
4614
],
[
4616
],
[
4618
],
[
4620
],
[
4622
],
[
4624,
4626,
4628,
4630
],
[
4632
],
[
4634
],
[
4636
],
[
4638
],
[
4642
],
[
4644
],
[
4646
],
[
4648
],
[
4650
],
[
4652
],
[
4654
],
[
4656
],
[
4658
],
[
4660
],
[
4662
],
[
4664
],
[
4666,
4668,
4670,
4672
],
[
4674
],
[
4676,
4678,
4680,
4682
],
[
4684
],
[
4686,
4688,
4690,
4692
],
[
4694
],
[
4696
],
[
4698
],
[
4700,
4702,
4704,
4706
],
[
4708
],
[
4710
],
[
4712
],
[
4714,
4716,
4718,
4720
],
[
4722
],
[
4724,
4726,
4728,
4730
],
[
4732
],
[
4734
],
[
4736
],
[
4738,
4740,
4742,
4744
],
[
4746
],
[
4748
],
[
4750
],
[
4752,
4754,
4756,
4758,
4760
],
[
4762
],
[
4764
],
[
4766
],
[
4768,
4770,
4772,
4774
],
[
4776
],
[
4778,
4780,
4782,
4784
],
[
4786
],
[
4788,
4790,
4792,
4794
],
[
4796
],
[
4798,
4800,
4802,
4804
],
[
4806
],
[
4808,
4812,
4814
],
[
4816,
4818,
4820
],
[
4822
],
[
4824
],
[
4826,
4828
],
[
4830,
4832
],
[
4834
],
[
4836
],
[
4838,
4840
],
[
4842
],
[
4844
],
[
4846,
4848,
4850,
4852
],
[
4862
],
[
4864
],
[
4866
],
[
4868
],
[
4870
],
[
4872,
4874,
4876,
4878,
4880,
4882,
4884,
4886,
4888,
4890
],
[
4892
],
[
4894
],
[
4896
],
[
4898
],
[
4900
],
[
4902
],
[
4904,
4906
],
[
4908
],
[
4910,
4912,
4914,
4924
],
[
4926
],
[
4928,
4930,
4932,
4934
],
[
4936
],
[
4938
],
[
4940
],
[
4942,
4944
],
[
4946,
4950
],
[
4952,
4954
],
[
4958
],
[
4960,
4962,
4964
],
[
4966,
4968
],
[
4970
],
[
4972
],
[
4974
],
[
4976
],
[
4978
],
[
4980
],
[
4982
],
[
4984,
4986
],
[
4988,
4990
],
[
4992
],
[
4994
],
[
4996
],
[
4998
],
[
5000
],
[
5002
],
[
5004
],
[
5006
],
[
5008
],
[
5010,
5012
],
[
5014,
5016
],
[
5018
],
[
5020
],
[
5022
],
[
5024
],
[
5026
],
[
5028
],
[
5030
],
[
5032,
5034
],
[
5036,
5038
],
[
5040
],
[
5042
],
[
5044
],
[
5046
],
[
5048
],
[
5050
],
[
5052
],
[
5054
],
[
5056
],
[
5060,
5062,
5064,
5066
],
[
5068,
5070
],
[
5072
],
[
5074
],
[
5076
],
[
5078
],
[
5080
],
[
5082
],
[
5084
],
[
5086,
5088
],
[
5090,
5092
],
[
5094
],
[
5096
],
[
5098
],
[
5100
],
[
5102
],
[
5104
],
[
5106
],
[
5108
],
[
5110
],
[
5112,
5114
],
[
5116
],
[
5118
],
[
5120
],
[
5122
],
[
5124,
5126,
5128,
5132
],
[
5134
],
[
5136,
5138,
5140,
5142
],
[
5144,
5146,
5148,
5150
],
[
5152
],
[
5154,
5156,
5158
],
[
5160
],
[
5162,
5164,
5166,
5168,
5170,
5172
],
[
5174
],
[
5176
],
[
5178
],
[
5180
],
[
5182,
5184
],
[
5186,
5188
],
[
5190,
5192
],
[
5194,
5196,
5198,
5200,
5202,
5204,
5206,
5208,
5210,
5212,
5214,
5216,
5218,
5220,
5222
],
[
5224
],
[
5226,
5228,
5230,
5232,
5234
],
[
5236
],
[
5238
],
[
5240,
5242,
5244
],
[
5246
],
[
5248
],
[
5250
],
[
5252
],
[
5254
],
[
5256,
5258
],
[
5260
],
[
5262,
5264
],
[
5266,
5268,
5270,
5272,
5274,
5276
],
[
5278,
5280
],
[
5282,
5284,
5286,
5288,
5290
],
[
5292,
5296,
5298,
5300
],
[
5302
],
[
5304
],
[
5306
],
[
5308
],
[
5310
],
[
5312
],
[
5314
],
[
5316,
5318,
5320,
5322
],
[
5324
],
[
5326
],
[
5328
],
[
5330
],
[
5332
],
[
5334
],
[
5336
],
[
5338,
5340,
5342,
5344
],
[
5346
],
[
5348
],
[
5350
],
[
5352,
5354
],
[
5356
],
[
5358
],
[
5360,
5364,
5366,
5368
],
[
5370
],
[
5372,
5376,
5378,
5380
],
[
5382
],
[
5384,
5388,
5390,
5392,
5394
],
[
5396
],
[
5398,
5402,
5404,
5406
],
[
5408,
5412,
5414,
5416
],
[
5418
],
[
5420
],
[
5422
],
[
5424
],
[
5426
],
[
5428
],
[
5430
],
[
5432
],
[
5434,
5436
],
[
5438
],
[
5440
],
[
5442
],
[
5444
],
[
5446
],
[
5448
],
[
5450
],
[
5452
],
[
5454
],
[
5456
],
[
5458,
5460,
5462,
5464
],
[
5466
],
[
5468,
5470,
5472,
5474
],
[
5476
],
[
5478,
5480,
5482,
5484
],
[
5486
],
[
5488
],
[
5490
],
[
5492,
5494,
5496,
5498
],
[
5500
],
[
5502,
5506,
5508,
5510
],
[
5512
],
[
5516
],
[
5518,
5520
],
[
5522
],
[
5524
],
[
5526
],
[
5528
],
[
5532,
5534
],
[
5536
],
[
5538
],
[
5540
],
[
5544,
5546
],
[
5548
],
[
5552
],
[
5554
],
[
5556
],
[
5558
],
[
5560
],
[
5562
],
[
5564,
5566
],
[
5568
],
[
5570
],
[
5572
],
[
5576,
5578
],
[
5580
],
[
5582
],
[
5586
],
[
5588
],
[
5590
],
[
5592
],
[
5594
],
[
5596
],
[
5598,
5600
],
[
5602
],
[
5604,
5606
],
[
5608
],
[
5610
],
[
5622,
5624
],
[
5626
],
[
5628
],
[
5630
],
[
5632
],
[
5634
],
[
5636
],
[
5638
],
[
5640
],
[
5642
],
[
5644
],
[
5648
],
[
5650
],
[
5652,
5656,
5658,
5660,
5662
],
[
5664
],
[
5666
],
[
5668
],
[
5670,
5672,
5674,
5676
],
[
5678
],
[
5680
],
[
5682
],
[
5684
],
[
5686
],
[
5688
],
[
5690
],
[
5692
],
[
5694
],
[
5696
],
[
5698
],
[
5700
],
[
5702
],
[
5704,
5706,
5708,
5710
],
[
5712
],
[
5714
],
[
5718
],
[
5720,
5722
],
[
5724
],
[
5726
],
[
5728
],
[
5730
],
[
5732,
5734,
5736,
5738,
5740,
5742
],
[
5744
],
[
5746,
5748,
5750,
5752
],
[
5754
],
[
5756,
5758,
5760,
5762,
5764
],
[
5766,
5768,
5770,
5772
],
[
5774
],
[
5776
],
[
5778,
5780,
5782
],
[
5784,
5786,
5788
],
[
5790
],
[
5792,
5794
],
[
5796
],
[
5798
]
] |
21,144 | static void gdb_accept(void)
{
GDBState *s;
struct sockaddr_in sockaddr;
socklen_t len;
int val, fd;
for(;;) {
len = sizeof(sockaddr);
fd = accept(gdbserver_fd, (struct sockaddr *)&sockaddr, &len);
if (fd < 0 && errno != EINTR) {
perror("accept");
return;
} else if (fd >= 0) {
break;
}
}
/* set short latency */
val = 1;
setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char *)&val, sizeof(val));
s = qemu_mallocz(sizeof(GDBState));
s->c_cpu = first_cpu;
s->g_cpu = first_cpu;
s->fd = fd;
gdb_has_xml = 0;
gdbserver_state = s;
fcntl(fd, F_SETFL, O_NONBLOCK);
} | true | qemu | 40ff6d7e8dceca227e7f8a3e8e0d58b2c66d19b4 | static void gdb_accept(void)
{
GDBState *s;
struct sockaddr_in sockaddr;
socklen_t len;
int val, fd;
for(;;) {
len = sizeof(sockaddr);
fd = accept(gdbserver_fd, (struct sockaddr *)&sockaddr, &len);
if (fd < 0 && errno != EINTR) {
perror("accept");
return;
} else if (fd >= 0) {
break;
}
}
val = 1;
setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char *)&val, sizeof(val));
s = qemu_mallocz(sizeof(GDBState));
s->c_cpu = first_cpu;
s->g_cpu = first_cpu;
s->fd = fd;
gdb_has_xml = 0;
gdbserver_state = s;
fcntl(fd, F_SETFL, O_NONBLOCK);
} | {
"code": [],
"line_no": []
} | static void FUNC_0(void)
{
GDBState *s;
struct sockaddr_in VAR_0;
socklen_t len;
int VAR_1, VAR_2;
for(;;) {
len = sizeof(VAR_0);
VAR_2 = accept(gdbserver_fd, (struct VAR_0 *)&VAR_0, &len);
if (VAR_2 < 0 && errno != EINTR) {
perror("accept");
return;
} else if (VAR_2 >= 0) {
break;
}
}
VAR_1 = 1;
setsockopt(VAR_2, IPPROTO_TCP, TCP_NODELAY, (char *)&VAR_1, sizeof(VAR_1));
s = qemu_mallocz(sizeof(GDBState));
s->c_cpu = first_cpu;
s->g_cpu = first_cpu;
s->VAR_2 = VAR_2;
gdb_has_xml = 0;
gdbserver_state = s;
fcntl(VAR_2, F_SETFL, O_NONBLOCK);
} | [
"static void FUNC_0(void)\n{",
"GDBState *s;",
"struct sockaddr_in VAR_0;",
"socklen_t len;",
"int VAR_1, VAR_2;",
"for(;;) {",
"len = sizeof(VAR_0);",
"VAR_2 = accept(gdbserver_fd, (struct VAR_0 *)&VAR_0, &len);",
"if (VAR_2 < 0 && errno != EINTR) {",
"perror(\"accept\");",
"return;",
"} else if (VAR_2 >= 0) {",
"break;",
"}",
"}",
"VAR_1 = 1;",
"setsockopt(VAR_2, IPPROTO_TCP, TCP_NODELAY, (char *)&VAR_1, sizeof(VAR_1));",
"s = qemu_mallocz(sizeof(GDBState));",
"s->c_cpu = first_cpu;",
"s->g_cpu = first_cpu;",
"s->VAR_2 = VAR_2;",
"gdb_has_xml = 0;",
"gdbserver_state = s;",
"fcntl(VAR_2, F_SETFL, O_NONBLOCK);",
"}"
] | [
0,
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
],
[
23
],
[
25
],
[
27
],
[
32
],
[
34
],
[
36
],
[
42
],
[
44
],
[
48
],
[
50
],
[
52
],
[
54
],
[
56
],
[
60
],
[
64
],
[
66
]
] |
21,145 | void init_rl(RLTable *rl)
{
int8_t max_level[MAX_RUN+1], max_run[MAX_LEVEL+1];
uint8_t index_run[MAX_RUN+1];
int last, run, level, start, end, i;
/* compute max_level[], max_run[] and index_run[] */
for(last=0;last<2;last++) {
if (last == 0) {
start = 0;
end = rl->last;
} else {
start = rl->last;
end = rl->n;
}
memset(max_level, 0, MAX_RUN + 1);
memset(max_run, 0, MAX_LEVEL + 1);
memset(index_run, rl->n, MAX_RUN + 1);
for(i=start;i<end;i++) {
run = rl->table_run[i];
level = rl->table_level[i];
if (index_run[run] == rl->n)
index_run[run] = i;
if (level > max_level[run])
max_level[run] = level;
if (run > max_run[level])
max_run[level] = run;
}
rl->max_level[last] = av_malloc(MAX_RUN + 1);
memcpy(rl->max_level[last], max_level, MAX_RUN + 1);
rl->max_run[last] = av_malloc(MAX_LEVEL + 1);
memcpy(rl->max_run[last], max_run, MAX_LEVEL + 1);
rl->index_run[last] = av_malloc(MAX_RUN + 1);
memcpy(rl->index_run[last], index_run, MAX_RUN + 1);
}
}
| true | FFmpeg | 073c2593c9f0aa4445a6fc1b9b24e6e52a8cc2c1 | void init_rl(RLTable *rl)
{
int8_t max_level[MAX_RUN+1], max_run[MAX_LEVEL+1];
uint8_t index_run[MAX_RUN+1];
int last, run, level, start, end, i;
for(last=0;last<2;last++) {
if (last == 0) {
start = 0;
end = rl->last;
} else {
start = rl->last;
end = rl->n;
}
memset(max_level, 0, MAX_RUN + 1);
memset(max_run, 0, MAX_LEVEL + 1);
memset(index_run, rl->n, MAX_RUN + 1);
for(i=start;i<end;i++) {
run = rl->table_run[i];
level = rl->table_level[i];
if (index_run[run] == rl->n)
index_run[run] = i;
if (level > max_level[run])
max_level[run] = level;
if (run > max_run[level])
max_run[level] = run;
}
rl->max_level[last] = av_malloc(MAX_RUN + 1);
memcpy(rl->max_level[last], max_level, MAX_RUN + 1);
rl->max_run[last] = av_malloc(MAX_LEVEL + 1);
memcpy(rl->max_run[last], max_run, MAX_LEVEL + 1);
rl->index_run[last] = av_malloc(MAX_RUN + 1);
memcpy(rl->index_run[last], index_run, MAX_RUN + 1);
}
}
| {
"code": [
"void init_rl(RLTable *rl)",
" rl->max_level[last] = av_malloc(MAX_RUN + 1);",
" rl->max_run[last] = av_malloc(MAX_LEVEL + 1);",
" rl->index_run[last] = av_malloc(MAX_RUN + 1);"
],
"line_no": [
1,
59,
63,
67
]
} | void FUNC_0(RLTable *VAR_0)
{
int8_t max_level[MAX_RUN+1], max_run[MAX_LEVEL+1];
uint8_t index_run[MAX_RUN+1];
int VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6;
for(VAR_1=0;VAR_1<2;VAR_1++) {
if (VAR_1 == 0) {
VAR_4 = 0;
VAR_5 = VAR_0->VAR_1;
} else {
VAR_4 = VAR_0->VAR_1;
VAR_5 = VAR_0->n;
}
memset(max_level, 0, MAX_RUN + 1);
memset(max_run, 0, MAX_LEVEL + 1);
memset(index_run, VAR_0->n, MAX_RUN + 1);
for(VAR_6=VAR_4;VAR_6<VAR_5;VAR_6++) {
VAR_2 = VAR_0->table_run[VAR_6];
VAR_3 = VAR_0->table_level[VAR_6];
if (index_run[VAR_2] == VAR_0->n)
index_run[VAR_2] = VAR_6;
if (VAR_3 > max_level[VAR_2])
max_level[VAR_2] = VAR_3;
if (VAR_2 > max_run[VAR_3])
max_run[VAR_3] = VAR_2;
}
VAR_0->max_level[VAR_1] = av_malloc(MAX_RUN + 1);
memcpy(VAR_0->max_level[VAR_1], max_level, MAX_RUN + 1);
VAR_0->max_run[VAR_1] = av_malloc(MAX_LEVEL + 1);
memcpy(VAR_0->max_run[VAR_1], max_run, MAX_LEVEL + 1);
VAR_0->index_run[VAR_1] = av_malloc(MAX_RUN + 1);
memcpy(VAR_0->index_run[VAR_1], index_run, MAX_RUN + 1);
}
}
| [
"void FUNC_0(RLTable *VAR_0)\n{",
"int8_t max_level[MAX_RUN+1], max_run[MAX_LEVEL+1];",
"uint8_t index_run[MAX_RUN+1];",
"int VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6;",
"for(VAR_1=0;VAR_1<2;VAR_1++) {",
"if (VAR_1 == 0) {",
"VAR_4 = 0;",
"VAR_5 = VAR_0->VAR_1;",
"} else {",
"VAR_4 = VAR_0->VAR_1;",
"VAR_5 = VAR_0->n;",
"}",
"memset(max_level, 0, MAX_RUN + 1);",
"memset(max_run, 0, MAX_LEVEL + 1);",
"memset(index_run, VAR_0->n, MAX_RUN + 1);",
"for(VAR_6=VAR_4;VAR_6<VAR_5;VAR_6++) {",
"VAR_2 = VAR_0->table_run[VAR_6];",
"VAR_3 = VAR_0->table_level[VAR_6];",
"if (index_run[VAR_2] == VAR_0->n)\nindex_run[VAR_2] = VAR_6;",
"if (VAR_3 > max_level[VAR_2])\nmax_level[VAR_2] = VAR_3;",
"if (VAR_2 > max_run[VAR_3])\nmax_run[VAR_3] = VAR_2;",
"}",
"VAR_0->max_level[VAR_1] = av_malloc(MAX_RUN + 1);",
"memcpy(VAR_0->max_level[VAR_1], max_level, MAX_RUN + 1);",
"VAR_0->max_run[VAR_1] = av_malloc(MAX_LEVEL + 1);",
"memcpy(VAR_0->max_run[VAR_1], max_run, MAX_LEVEL + 1);",
"VAR_0->index_run[VAR_1] = av_malloc(MAX_RUN + 1);",
"memcpy(VAR_0->index_run[VAR_1], index_run, MAX_RUN + 1);",
"}",
"}"
] | [
1,
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,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
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
]
] |
21,146 | int load_elf(const char *filename, uint64_t (*translate_fn)(void *, uint64_t),
void *translate_opaque, uint64_t *pentry, uint64_t *lowaddr,
uint64_t *highaddr, int big_endian, int elf_machine, int clear_lsb)
{
int fd, data_order, target_data_order, must_swab, ret;
uint8_t e_ident[EI_NIDENT];
fd = open(filename, O_RDONLY | O_BINARY);
if (fd < 0) {
perror(filename);
return -1;
}
if (read(fd, e_ident, sizeof(e_ident)) != sizeof(e_ident))
goto fail;
if (e_ident[0] != ELFMAG0 ||
e_ident[1] != ELFMAG1 ||
e_ident[2] != ELFMAG2 ||
e_ident[3] != ELFMAG3)
goto fail;
#ifdef HOST_WORDS_BIGENDIAN
data_order = ELFDATA2MSB;
#else
data_order = ELFDATA2LSB;
#endif
must_swab = data_order != e_ident[EI_DATA];
if (big_endian) {
target_data_order = ELFDATA2MSB;
} else {
target_data_order = ELFDATA2LSB;
}
if (target_data_order != e_ident[EI_DATA])
return -1;
lseek(fd, 0, SEEK_SET);
if (e_ident[EI_CLASS] == ELFCLASS64) {
ret = load_elf64(filename, fd, translate_fn, translate_opaque, must_swab,
pentry, lowaddr, highaddr, elf_machine, clear_lsb);
} else {
ret = load_elf32(filename, fd, translate_fn, translate_opaque, must_swab,
pentry, lowaddr, highaddr, elf_machine, clear_lsb);
}
close(fd);
return ret;
fail:
close(fd);
return -1;
}
| true | qemu | cedf9a6f4549900f857954059284a96814e4c7a3 | int load_elf(const char *filename, uint64_t (*translate_fn)(void *, uint64_t),
void *translate_opaque, uint64_t *pentry, uint64_t *lowaddr,
uint64_t *highaddr, int big_endian, int elf_machine, int clear_lsb)
{
int fd, data_order, target_data_order, must_swab, ret;
uint8_t e_ident[EI_NIDENT];
fd = open(filename, O_RDONLY | O_BINARY);
if (fd < 0) {
perror(filename);
return -1;
}
if (read(fd, e_ident, sizeof(e_ident)) != sizeof(e_ident))
goto fail;
if (e_ident[0] != ELFMAG0 ||
e_ident[1] != ELFMAG1 ||
e_ident[2] != ELFMAG2 ||
e_ident[3] != ELFMAG3)
goto fail;
#ifdef HOST_WORDS_BIGENDIAN
data_order = ELFDATA2MSB;
#else
data_order = ELFDATA2LSB;
#endif
must_swab = data_order != e_ident[EI_DATA];
if (big_endian) {
target_data_order = ELFDATA2MSB;
} else {
target_data_order = ELFDATA2LSB;
}
if (target_data_order != e_ident[EI_DATA])
return -1;
lseek(fd, 0, SEEK_SET);
if (e_ident[EI_CLASS] == ELFCLASS64) {
ret = load_elf64(filename, fd, translate_fn, translate_opaque, must_swab,
pentry, lowaddr, highaddr, elf_machine, clear_lsb);
} else {
ret = load_elf32(filename, fd, translate_fn, translate_opaque, must_swab,
pentry, lowaddr, highaddr, elf_machine, clear_lsb);
}
close(fd);
return ret;
fail:
close(fd);
return -1;
}
| {
"code": [
" if (target_data_order != e_ident[EI_DATA])",
" return -1;"
],
"line_no": [
63,
21
]
} | int FUNC_0(const char *VAR_0, VAR_1 (*translate_fn)(void *, VAR_1),
void *VAR_2, VAR_1 *VAR_3, VAR_1 *VAR_4,
VAR_1 *VAR_5, int VAR_6, int VAR_7, int VAR_8)
{
int VAR_9, VAR_10, VAR_11, VAR_12, VAR_13;
uint8_t e_ident[EI_NIDENT];
VAR_9 = open(VAR_0, O_RDONLY | O_BINARY);
if (VAR_9 < 0) {
perror(VAR_0);
return -1;
}
if (read(VAR_9, e_ident, sizeof(e_ident)) != sizeof(e_ident))
goto fail;
if (e_ident[0] != ELFMAG0 ||
e_ident[1] != ELFMAG1 ||
e_ident[2] != ELFMAG2 ||
e_ident[3] != ELFMAG3)
goto fail;
#ifdef HOST_WORDS_BIGENDIAN
VAR_10 = ELFDATA2MSB;
#else
VAR_10 = ELFDATA2LSB;
#endif
VAR_12 = VAR_10 != e_ident[EI_DATA];
if (VAR_6) {
VAR_11 = ELFDATA2MSB;
} else {
VAR_11 = ELFDATA2LSB;
}
if (VAR_11 != e_ident[EI_DATA])
return -1;
lseek(VAR_9, 0, SEEK_SET);
if (e_ident[EI_CLASS] == ELFCLASS64) {
VAR_13 = load_elf64(VAR_0, VAR_9, translate_fn, VAR_2, VAR_12,
VAR_3, VAR_4, VAR_5, VAR_7, VAR_8);
} else {
VAR_13 = load_elf32(VAR_0, VAR_9, translate_fn, VAR_2, VAR_12,
VAR_3, VAR_4, VAR_5, VAR_7, VAR_8);
}
close(VAR_9);
return VAR_13;
fail:
close(VAR_9);
return -1;
}
| [
"int FUNC_0(const char *VAR_0, VAR_1 (*translate_fn)(void *, VAR_1),\nvoid *VAR_2, VAR_1 *VAR_3, VAR_1 *VAR_4,\nVAR_1 *VAR_5, int VAR_6, int VAR_7, int VAR_8)\n{",
"int VAR_9, VAR_10, VAR_11, VAR_12, VAR_13;",
"uint8_t e_ident[EI_NIDENT];",
"VAR_9 = open(VAR_0, O_RDONLY | O_BINARY);",
"if (VAR_9 < 0) {",
"perror(VAR_0);",
"return -1;",
"}",
"if (read(VAR_9, e_ident, sizeof(e_ident)) != sizeof(e_ident))\ngoto fail;",
"if (e_ident[0] != ELFMAG0 ||\ne_ident[1] != ELFMAG1 ||\ne_ident[2] != ELFMAG2 ||\ne_ident[3] != ELFMAG3)\ngoto fail;",
"#ifdef HOST_WORDS_BIGENDIAN\nVAR_10 = ELFDATA2MSB;",
"#else\nVAR_10 = ELFDATA2LSB;",
"#endif\nVAR_12 = VAR_10 != e_ident[EI_DATA];",
"if (VAR_6) {",
"VAR_11 = ELFDATA2MSB;",
"} else {",
"VAR_11 = ELFDATA2LSB;",
"}",
"if (VAR_11 != e_ident[EI_DATA])\nreturn -1;",
"lseek(VAR_9, 0, SEEK_SET);",
"if (e_ident[EI_CLASS] == ELFCLASS64) {",
"VAR_13 = load_elf64(VAR_0, VAR_9, translate_fn, VAR_2, VAR_12,\nVAR_3, VAR_4, VAR_5, VAR_7, VAR_8);",
"} else {",
"VAR_13 = load_elf32(VAR_0, VAR_9, translate_fn, VAR_2, VAR_12,\nVAR_3, VAR_4, VAR_5, VAR_7, VAR_8);",
"}",
"close(VAR_9);",
"return VAR_13;",
"fail:\nclose(VAR_9);",
"return -1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
1,
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
],
[
9
],
[
11
],
[
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
],
[
69
],
[
71
],
[
73,
75
],
[
77
],
[
79,
81
],
[
83
],
[
87
],
[
89
],
[
93,
95
],
[
97
],
[
99
]
] |
21,147 | static void free_buffers(AVCodecContext *avctx)
{
CFHDContext *s = avctx->priv_data;
int i;
for (i = 0; i < 4; i++) {
av_freep(&s->plane[i].idwt_buf);
av_freep(&s->plane[i].idwt_tmp);
}
s->a_height = 0;
s->a_width = 0;
}
| true | FFmpeg | e9a9ca1936ea2853cdfb8913d44711d240eec60d | static void free_buffers(AVCodecContext *avctx)
{
CFHDContext *s = avctx->priv_data;
int i;
for (i = 0; i < 4; i++) {
av_freep(&s->plane[i].idwt_buf);
av_freep(&s->plane[i].idwt_tmp);
}
s->a_height = 0;
s->a_width = 0;
}
| {
"code": [
" int i;"
],
"line_no": [
7
]
} | static void FUNC_0(AVCodecContext *VAR_0)
{
CFHDContext *s = VAR_0->priv_data;
int VAR_1;
for (VAR_1 = 0; VAR_1 < 4; VAR_1++) {
av_freep(&s->plane[VAR_1].idwt_buf);
av_freep(&s->plane[VAR_1].idwt_tmp);
}
s->a_height = 0;
s->a_width = 0;
}
| [
"static void FUNC_0(AVCodecContext *VAR_0)\n{",
"CFHDContext *s = VAR_0->priv_data;",
"int VAR_1;",
"for (VAR_1 = 0; VAR_1 < 4; VAR_1++) {",
"av_freep(&s->plane[VAR_1].idwt_buf);",
"av_freep(&s->plane[VAR_1].idwt_tmp);",
"}",
"s->a_height = 0;",
"s->a_width = 0;",
"}"
] | [
0,
0,
1,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
]
] |
21,149 | av_const int ff_h263_aspect_to_info(AVRational aspect){
int i;
if(aspect.num==0) aspect= (AVRational){1,1};
for(i=1; i<6; i++){
if(av_cmp_q(ff_h263_pixel_aspect[i], aspect) == 0){
return i;
}
}
return FF_ASPECT_EXTENDED;
}
| false | FFmpeg | db0a52d611d7319c8a1186829a50e29b9dfed63b | av_const int ff_h263_aspect_to_info(AVRational aspect){
int i;
if(aspect.num==0) aspect= (AVRational){1,1};
for(i=1; i<6; i++){
if(av_cmp_q(ff_h263_pixel_aspect[i], aspect) == 0){
return i;
}
}
return FF_ASPECT_EXTENDED;
}
| {
"code": [],
"line_no": []
} | av_const int FUNC_0(AVRational aspect){
int VAR_0;
if(aspect.num==0) aspect= (AVRational){1,1};
for(VAR_0=1; VAR_0<6; VAR_0++){
if(av_cmp_q(ff_h263_pixel_aspect[VAR_0], aspect) == 0){
return VAR_0;
}
}
return FF_ASPECT_EXTENDED;
}
| [
"av_const int FUNC_0(AVRational aspect){",
"int VAR_0;",
"if(aspect.num==0) aspect= (AVRational){1,1};",
"for(VAR_0=1; VAR_0<6; VAR_0++){",
"if(av_cmp_q(ff_h263_pixel_aspect[VAR_0], aspect) == 0){",
"return VAR_0;",
"}",
"}",
"return FF_ASPECT_EXTENDED;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1
],
[
3
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
]
] |
21,150 | static int filter_samples(AVFilterLink *inlink, AVFilterBufferRef *samplesref)
{
AVFilterContext *ctx = inlink->dst;
int i, ret = 0;
for (i = 0; i < ctx->nb_outputs; i++) {
ret = ff_filter_samples(inlink->dst->outputs[i],
avfilter_ref_buffer(samplesref, ~AV_PERM_WRITE));
if (ret < 0)
break;
}
avfilter_unref_buffer(samplesref);
return ret;
}
| false | FFmpeg | 1dc42050185d63c1de5d16146fbaee92640af187 | static int filter_samples(AVFilterLink *inlink, AVFilterBufferRef *samplesref)
{
AVFilterContext *ctx = inlink->dst;
int i, ret = 0;
for (i = 0; i < ctx->nb_outputs; i++) {
ret = ff_filter_samples(inlink->dst->outputs[i],
avfilter_ref_buffer(samplesref, ~AV_PERM_WRITE));
if (ret < 0)
break;
}
avfilter_unref_buffer(samplesref);
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFilterLink *VAR_0, AVFilterBufferRef *VAR_1)
{
AVFilterContext *ctx = VAR_0->dst;
int VAR_2, VAR_3 = 0;
for (VAR_2 = 0; VAR_2 < ctx->nb_outputs; VAR_2++) {
VAR_3 = ff_filter_samples(VAR_0->dst->outputs[VAR_2],
avfilter_ref_buffer(VAR_1, ~AV_PERM_WRITE));
if (VAR_3 < 0)
break;
}
avfilter_unref_buffer(VAR_1);
return VAR_3;
}
| [
"static int FUNC_0(AVFilterLink *VAR_0, AVFilterBufferRef *VAR_1)\n{",
"AVFilterContext *ctx = VAR_0->dst;",
"int VAR_2, VAR_3 = 0;",
"for (VAR_2 = 0; VAR_2 < ctx->nb_outputs; VAR_2++) {",
"VAR_3 = ff_filter_samples(VAR_0->dst->outputs[VAR_2],\navfilter_ref_buffer(VAR_1, ~AV_PERM_WRITE));",
"if (VAR_3 < 0)\nbreak;",
"}",
"avfilter_unref_buffer(VAR_1);",
"return VAR_3;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13,
15
],
[
17,
19
],
[
21
],
[
23
],
[
25
],
[
27
]
] |
21,151 | av_cold void ff_huffyuvdsp_init_ppc(HuffYUVDSPContext *c)
{
#if HAVE_ALTIVEC && HAVE_BIGENDIAN
if (!PPC_ALTIVEC(av_get_cpu_flags()))
return;
c->add_bytes = add_bytes_altivec;
#endif /* HAVE_ALTIVEC && HAVE_BIGENDIAN */
}
| false | FFmpeg | b015872c0d0823e70776e98b865509ec1287e2f6 | av_cold void ff_huffyuvdsp_init_ppc(HuffYUVDSPContext *c)
{
#if HAVE_ALTIVEC && HAVE_BIGENDIAN
if (!PPC_ALTIVEC(av_get_cpu_flags()))
return;
c->add_bytes = add_bytes_altivec;
#endif
}
| {
"code": [],
"line_no": []
} | av_cold void FUNC_0(HuffYUVDSPContext *c)
{
#if HAVE_ALTIVEC && HAVE_BIGENDIAN
if (!PPC_ALTIVEC(av_get_cpu_flags()))
return;
c->add_bytes = add_bytes_altivec;
#endif
}
| [
"av_cold void FUNC_0(HuffYUVDSPContext *c)\n{",
"#if HAVE_ALTIVEC && HAVE_BIGENDIAN\nif (!PPC_ALTIVEC(av_get_cpu_flags()))\nreturn;",
"c->add_bytes = add_bytes_altivec;",
"#endif\n}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7,
9
],
[
13
],
[
15,
17
]
] |
21,152 | static void vmsvga_fifo_run(struct vmsvga_state_s *s)
{
uint32_t cmd, colour;
int args, len;
int x, y, dx, dy, width, height;
struct vmsvga_cursor_definition_s cursor;
uint32_t cmd_start;
len = vmsvga_fifo_length(s);
while (len > 0) {
/* May need to go back to the start of the command if incomplete */
cmd_start = s->cmd->stop;
switch (cmd = vmsvga_fifo_read(s)) {
case SVGA_CMD_UPDATE:
case SVGA_CMD_UPDATE_VERBOSE:
len -= 5;
if (len < 0) {
goto rewind;
}
x = vmsvga_fifo_read(s);
y = vmsvga_fifo_read(s);
width = vmsvga_fifo_read(s);
height = vmsvga_fifo_read(s);
vmsvga_update_rect_delayed(s, x, y, width, height);
break;
case SVGA_CMD_RECT_FILL:
len -= 6;
if (len < 0) {
goto rewind;
}
colour = vmsvga_fifo_read(s);
x = vmsvga_fifo_read(s);
y = vmsvga_fifo_read(s);
width = vmsvga_fifo_read(s);
height = vmsvga_fifo_read(s);
#ifdef HW_FILL_ACCEL
vmsvga_fill_rect(s, colour, x, y, width, height);
break;
#else
args = 0;
goto badcmd;
#endif
case SVGA_CMD_RECT_COPY:
len -= 7;
if (len < 0) {
goto rewind;
}
x = vmsvga_fifo_read(s);
y = vmsvga_fifo_read(s);
dx = vmsvga_fifo_read(s);
dy = vmsvga_fifo_read(s);
width = vmsvga_fifo_read(s);
height = vmsvga_fifo_read(s);
#ifdef HW_RECT_ACCEL
if (vmsvga_copy_rect(s, x, y, dx, dy, width, height) == 0) {
break;
}
#endif
args = 0;
goto badcmd;
case SVGA_CMD_DEFINE_CURSOR:
len -= 8;
if (len < 0) {
goto rewind;
}
cursor.id = vmsvga_fifo_read(s);
cursor.hot_x = vmsvga_fifo_read(s);
cursor.hot_y = vmsvga_fifo_read(s);
cursor.width = x = vmsvga_fifo_read(s);
cursor.height = y = vmsvga_fifo_read(s);
vmsvga_fifo_read(s);
cursor.bpp = vmsvga_fifo_read(s);
args = SVGA_BITMAP_SIZE(x, y) + SVGA_PIXMAP_SIZE(x, y, cursor.bpp);
if (SVGA_BITMAP_SIZE(x, y) > sizeof cursor.mask ||
SVGA_PIXMAP_SIZE(x, y, cursor.bpp) > sizeof cursor.image) {
goto badcmd;
}
len -= args;
if (len < 0) {
goto rewind;
}
for (args = 0; args < SVGA_BITMAP_SIZE(x, y); args++) {
cursor.mask[args] = vmsvga_fifo_read_raw(s);
}
for (args = 0; args < SVGA_PIXMAP_SIZE(x, y, cursor.bpp); args++) {
cursor.image[args] = vmsvga_fifo_read_raw(s);
}
#ifdef HW_MOUSE_ACCEL
vmsvga_cursor_define(s, &cursor);
break;
#else
args = 0;
goto badcmd;
#endif
/*
* Other commands that we at least know the number of arguments
* for so we can avoid FIFO desync if driver uses them illegally.
*/
case SVGA_CMD_DEFINE_ALPHA_CURSOR:
len -= 6;
if (len < 0) {
goto rewind;
}
vmsvga_fifo_read(s);
vmsvga_fifo_read(s);
vmsvga_fifo_read(s);
x = vmsvga_fifo_read(s);
y = vmsvga_fifo_read(s);
args = x * y;
goto badcmd;
case SVGA_CMD_RECT_ROP_FILL:
args = 6;
goto badcmd;
case SVGA_CMD_RECT_ROP_COPY:
args = 7;
goto badcmd;
case SVGA_CMD_DRAW_GLYPH_CLIPPED:
len -= 4;
if (len < 0) {
goto rewind;
}
vmsvga_fifo_read(s);
vmsvga_fifo_read(s);
args = 7 + (vmsvga_fifo_read(s) >> 2);
goto badcmd;
case SVGA_CMD_SURFACE_ALPHA_BLEND:
args = 12;
goto badcmd;
/*
* Other commands that are not listed as depending on any
* CAPABILITIES bits, but are not described in the README either.
*/
case SVGA_CMD_SURFACE_FILL:
case SVGA_CMD_SURFACE_COPY:
case SVGA_CMD_FRONT_ROP_FILL:
case SVGA_CMD_FENCE:
case SVGA_CMD_INVALID_CMD:
break; /* Nop */
default:
args = 0;
badcmd:
len -= args;
if (len < 0) {
goto rewind;
}
while (args--) {
vmsvga_fifo_read(s);
}
printf("%s: Unknown command 0x%02x in SVGA command FIFO\n",
__func__, cmd);
break;
rewind:
s->cmd->stop = cmd_start;
break;
}
}
s->syncing = 0;
}
| true | qemu | bd9ccd8517e83b7c33a9167815dbfffb30d70b13 | static void vmsvga_fifo_run(struct vmsvga_state_s *s)
{
uint32_t cmd, colour;
int args, len;
int x, y, dx, dy, width, height;
struct vmsvga_cursor_definition_s cursor;
uint32_t cmd_start;
len = vmsvga_fifo_length(s);
while (len > 0) {
cmd_start = s->cmd->stop;
switch (cmd = vmsvga_fifo_read(s)) {
case SVGA_CMD_UPDATE:
case SVGA_CMD_UPDATE_VERBOSE:
len -= 5;
if (len < 0) {
goto rewind;
}
x = vmsvga_fifo_read(s);
y = vmsvga_fifo_read(s);
width = vmsvga_fifo_read(s);
height = vmsvga_fifo_read(s);
vmsvga_update_rect_delayed(s, x, y, width, height);
break;
case SVGA_CMD_RECT_FILL:
len -= 6;
if (len < 0) {
goto rewind;
}
colour = vmsvga_fifo_read(s);
x = vmsvga_fifo_read(s);
y = vmsvga_fifo_read(s);
width = vmsvga_fifo_read(s);
height = vmsvga_fifo_read(s);
#ifdef HW_FILL_ACCEL
vmsvga_fill_rect(s, colour, x, y, width, height);
break;
#else
args = 0;
goto badcmd;
#endif
case SVGA_CMD_RECT_COPY:
len -= 7;
if (len < 0) {
goto rewind;
}
x = vmsvga_fifo_read(s);
y = vmsvga_fifo_read(s);
dx = vmsvga_fifo_read(s);
dy = vmsvga_fifo_read(s);
width = vmsvga_fifo_read(s);
height = vmsvga_fifo_read(s);
#ifdef HW_RECT_ACCEL
if (vmsvga_copy_rect(s, x, y, dx, dy, width, height) == 0) {
break;
}
#endif
args = 0;
goto badcmd;
case SVGA_CMD_DEFINE_CURSOR:
len -= 8;
if (len < 0) {
goto rewind;
}
cursor.id = vmsvga_fifo_read(s);
cursor.hot_x = vmsvga_fifo_read(s);
cursor.hot_y = vmsvga_fifo_read(s);
cursor.width = x = vmsvga_fifo_read(s);
cursor.height = y = vmsvga_fifo_read(s);
vmsvga_fifo_read(s);
cursor.bpp = vmsvga_fifo_read(s);
args = SVGA_BITMAP_SIZE(x, y) + SVGA_PIXMAP_SIZE(x, y, cursor.bpp);
if (SVGA_BITMAP_SIZE(x, y) > sizeof cursor.mask ||
SVGA_PIXMAP_SIZE(x, y, cursor.bpp) > sizeof cursor.image) {
goto badcmd;
}
len -= args;
if (len < 0) {
goto rewind;
}
for (args = 0; args < SVGA_BITMAP_SIZE(x, y); args++) {
cursor.mask[args] = vmsvga_fifo_read_raw(s);
}
for (args = 0; args < SVGA_PIXMAP_SIZE(x, y, cursor.bpp); args++) {
cursor.image[args] = vmsvga_fifo_read_raw(s);
}
#ifdef HW_MOUSE_ACCEL
vmsvga_cursor_define(s, &cursor);
break;
#else
args = 0;
goto badcmd;
#endif
case SVGA_CMD_DEFINE_ALPHA_CURSOR:
len -= 6;
if (len < 0) {
goto rewind;
}
vmsvga_fifo_read(s);
vmsvga_fifo_read(s);
vmsvga_fifo_read(s);
x = vmsvga_fifo_read(s);
y = vmsvga_fifo_read(s);
args = x * y;
goto badcmd;
case SVGA_CMD_RECT_ROP_FILL:
args = 6;
goto badcmd;
case SVGA_CMD_RECT_ROP_COPY:
args = 7;
goto badcmd;
case SVGA_CMD_DRAW_GLYPH_CLIPPED:
len -= 4;
if (len < 0) {
goto rewind;
}
vmsvga_fifo_read(s);
vmsvga_fifo_read(s);
args = 7 + (vmsvga_fifo_read(s) >> 2);
goto badcmd;
case SVGA_CMD_SURFACE_ALPHA_BLEND:
args = 12;
goto badcmd;
case SVGA_CMD_SURFACE_FILL:
case SVGA_CMD_SURFACE_COPY:
case SVGA_CMD_FRONT_ROP_FILL:
case SVGA_CMD_FENCE:
case SVGA_CMD_INVALID_CMD:
break;
default:
args = 0;
badcmd:
len -= args;
if (len < 0) {
goto rewind;
}
while (args--) {
vmsvga_fifo_read(s);
}
printf("%s: Unknown command 0x%02x in SVGA command FIFO\n",
__func__, cmd);
break;
rewind:
s->cmd->stop = cmd_start;
break;
}
}
s->syncing = 0;
}
| {
"code": [
"#endif",
" vmsvga_fill_rect(s, colour, x, y, width, height);",
" break;",
"#else",
"#endif"
],
"line_no": [
91,
81,
53,
85,
91
]
} | static void FUNC_0(struct vmsvga_state_s *VAR_0)
{
uint32_t cmd, colour;
int VAR_1, VAR_2;
int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8;
struct vmsvga_cursor_definition_s VAR_9;
uint32_t cmd_start;
VAR_2 = vmsvga_fifo_length(VAR_0);
while (VAR_2 > 0) {
cmd_start = VAR_0->cmd->stop;
switch (cmd = vmsvga_fifo_read(VAR_0)) {
case SVGA_CMD_UPDATE:
case SVGA_CMD_UPDATE_VERBOSE:
VAR_2 -= 5;
if (VAR_2 < 0) {
goto rewind;
}
VAR_3 = vmsvga_fifo_read(VAR_0);
VAR_4 = vmsvga_fifo_read(VAR_0);
VAR_7 = vmsvga_fifo_read(VAR_0);
VAR_8 = vmsvga_fifo_read(VAR_0);
vmsvga_update_rect_delayed(VAR_0, VAR_3, VAR_4, VAR_7, VAR_8);
break;
case SVGA_CMD_RECT_FILL:
VAR_2 -= 6;
if (VAR_2 < 0) {
goto rewind;
}
colour = vmsvga_fifo_read(VAR_0);
VAR_3 = vmsvga_fifo_read(VAR_0);
VAR_4 = vmsvga_fifo_read(VAR_0);
VAR_7 = vmsvga_fifo_read(VAR_0);
VAR_8 = vmsvga_fifo_read(VAR_0);
#ifdef HW_FILL_ACCEL
vmsvga_fill_rect(VAR_0, colour, VAR_3, VAR_4, VAR_7, VAR_8);
break;
#else
VAR_1 = 0;
goto badcmd;
#endif
case SVGA_CMD_RECT_COPY:
VAR_2 -= 7;
if (VAR_2 < 0) {
goto rewind;
}
VAR_3 = vmsvga_fifo_read(VAR_0);
VAR_4 = vmsvga_fifo_read(VAR_0);
VAR_5 = vmsvga_fifo_read(VAR_0);
VAR_6 = vmsvga_fifo_read(VAR_0);
VAR_7 = vmsvga_fifo_read(VAR_0);
VAR_8 = vmsvga_fifo_read(VAR_0);
#ifdef HW_RECT_ACCEL
if (vmsvga_copy_rect(VAR_0, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8) == 0) {
break;
}
#endif
VAR_1 = 0;
goto badcmd;
case SVGA_CMD_DEFINE_CURSOR:
VAR_2 -= 8;
if (VAR_2 < 0) {
goto rewind;
}
VAR_9.id = vmsvga_fifo_read(VAR_0);
VAR_9.hot_x = vmsvga_fifo_read(VAR_0);
VAR_9.hot_y = vmsvga_fifo_read(VAR_0);
VAR_9.VAR_7 = VAR_3 = vmsvga_fifo_read(VAR_0);
VAR_9.VAR_8 = VAR_4 = vmsvga_fifo_read(VAR_0);
vmsvga_fifo_read(VAR_0);
VAR_9.bpp = vmsvga_fifo_read(VAR_0);
VAR_1 = SVGA_BITMAP_SIZE(VAR_3, VAR_4) + SVGA_PIXMAP_SIZE(VAR_3, VAR_4, VAR_9.bpp);
if (SVGA_BITMAP_SIZE(VAR_3, VAR_4) > sizeof VAR_9.mask ||
SVGA_PIXMAP_SIZE(VAR_3, VAR_4, VAR_9.bpp) > sizeof VAR_9.image) {
goto badcmd;
}
VAR_2 -= VAR_1;
if (VAR_2 < 0) {
goto rewind;
}
for (VAR_1 = 0; VAR_1 < SVGA_BITMAP_SIZE(VAR_3, VAR_4); VAR_1++) {
VAR_9.mask[VAR_1] = vmsvga_fifo_read_raw(VAR_0);
}
for (VAR_1 = 0; VAR_1 < SVGA_PIXMAP_SIZE(VAR_3, VAR_4, VAR_9.bpp); VAR_1++) {
VAR_9.image[VAR_1] = vmsvga_fifo_read_raw(VAR_0);
}
#ifdef HW_MOUSE_ACCEL
vmsvga_cursor_define(VAR_0, &VAR_9);
break;
#else
VAR_1 = 0;
goto badcmd;
#endif
case SVGA_CMD_DEFINE_ALPHA_CURSOR:
VAR_2 -= 6;
if (VAR_2 < 0) {
goto rewind;
}
vmsvga_fifo_read(VAR_0);
vmsvga_fifo_read(VAR_0);
vmsvga_fifo_read(VAR_0);
VAR_3 = vmsvga_fifo_read(VAR_0);
VAR_4 = vmsvga_fifo_read(VAR_0);
VAR_1 = VAR_3 * VAR_4;
goto badcmd;
case SVGA_CMD_RECT_ROP_FILL:
VAR_1 = 6;
goto badcmd;
case SVGA_CMD_RECT_ROP_COPY:
VAR_1 = 7;
goto badcmd;
case SVGA_CMD_DRAW_GLYPH_CLIPPED:
VAR_2 -= 4;
if (VAR_2 < 0) {
goto rewind;
}
vmsvga_fifo_read(VAR_0);
vmsvga_fifo_read(VAR_0);
VAR_1 = 7 + (vmsvga_fifo_read(VAR_0) >> 2);
goto badcmd;
case SVGA_CMD_SURFACE_ALPHA_BLEND:
VAR_1 = 12;
goto badcmd;
case SVGA_CMD_SURFACE_FILL:
case SVGA_CMD_SURFACE_COPY:
case SVGA_CMD_FRONT_ROP_FILL:
case SVGA_CMD_FENCE:
case SVGA_CMD_INVALID_CMD:
break;
default:
VAR_1 = 0;
badcmd:
VAR_2 -= VAR_1;
if (VAR_2 < 0) {
goto rewind;
}
while (VAR_1--) {
vmsvga_fifo_read(VAR_0);
}
printf("%VAR_0: Unknown command 0x%02x in SVGA command FIFO\n",
__func__, cmd);
break;
rewind:
VAR_0->cmd->stop = cmd_start;
break;
}
}
VAR_0->syncing = 0;
}
| [
"static void FUNC_0(struct vmsvga_state_s *VAR_0)\n{",
"uint32_t cmd, colour;",
"int VAR_1, VAR_2;",
"int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8;",
"struct vmsvga_cursor_definition_s VAR_9;",
"uint32_t cmd_start;",
"VAR_2 = vmsvga_fifo_length(VAR_0);",
"while (VAR_2 > 0) {",
"cmd_start = VAR_0->cmd->stop;",
"switch (cmd = vmsvga_fifo_read(VAR_0)) {",
"case SVGA_CMD_UPDATE:\ncase SVGA_CMD_UPDATE_VERBOSE:\nVAR_2 -= 5;",
"if (VAR_2 < 0) {",
"goto rewind;",
"}",
"VAR_3 = vmsvga_fifo_read(VAR_0);",
"VAR_4 = vmsvga_fifo_read(VAR_0);",
"VAR_7 = vmsvga_fifo_read(VAR_0);",
"VAR_8 = vmsvga_fifo_read(VAR_0);",
"vmsvga_update_rect_delayed(VAR_0, VAR_3, VAR_4, VAR_7, VAR_8);",
"break;",
"case SVGA_CMD_RECT_FILL:\nVAR_2 -= 6;",
"if (VAR_2 < 0) {",
"goto rewind;",
"}",
"colour = vmsvga_fifo_read(VAR_0);",
"VAR_3 = vmsvga_fifo_read(VAR_0);",
"VAR_4 = vmsvga_fifo_read(VAR_0);",
"VAR_7 = vmsvga_fifo_read(VAR_0);",
"VAR_8 = vmsvga_fifo_read(VAR_0);",
"#ifdef HW_FILL_ACCEL\nvmsvga_fill_rect(VAR_0, colour, VAR_3, VAR_4, VAR_7, VAR_8);",
"break;",
"#else\nVAR_1 = 0;",
"goto badcmd;",
"#endif\ncase SVGA_CMD_RECT_COPY:\nVAR_2 -= 7;",
"if (VAR_2 < 0) {",
"goto rewind;",
"}",
"VAR_3 = vmsvga_fifo_read(VAR_0);",
"VAR_4 = vmsvga_fifo_read(VAR_0);",
"VAR_5 = vmsvga_fifo_read(VAR_0);",
"VAR_6 = vmsvga_fifo_read(VAR_0);",
"VAR_7 = vmsvga_fifo_read(VAR_0);",
"VAR_8 = vmsvga_fifo_read(VAR_0);",
"#ifdef HW_RECT_ACCEL\nif (vmsvga_copy_rect(VAR_0, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8) == 0) {",
"break;",
"}",
"#endif\nVAR_1 = 0;",
"goto badcmd;",
"case SVGA_CMD_DEFINE_CURSOR:\nVAR_2 -= 8;",
"if (VAR_2 < 0) {",
"goto rewind;",
"}",
"VAR_9.id = vmsvga_fifo_read(VAR_0);",
"VAR_9.hot_x = vmsvga_fifo_read(VAR_0);",
"VAR_9.hot_y = vmsvga_fifo_read(VAR_0);",
"VAR_9.VAR_7 = VAR_3 = vmsvga_fifo_read(VAR_0);",
"VAR_9.VAR_8 = VAR_4 = vmsvga_fifo_read(VAR_0);",
"vmsvga_fifo_read(VAR_0);",
"VAR_9.bpp = vmsvga_fifo_read(VAR_0);",
"VAR_1 = SVGA_BITMAP_SIZE(VAR_3, VAR_4) + SVGA_PIXMAP_SIZE(VAR_3, VAR_4, VAR_9.bpp);",
"if (SVGA_BITMAP_SIZE(VAR_3, VAR_4) > sizeof VAR_9.mask ||\nSVGA_PIXMAP_SIZE(VAR_3, VAR_4, VAR_9.bpp) > sizeof VAR_9.image) {",
"goto badcmd;",
"}",
"VAR_2 -= VAR_1;",
"if (VAR_2 < 0) {",
"goto rewind;",
"}",
"for (VAR_1 = 0; VAR_1 < SVGA_BITMAP_SIZE(VAR_3, VAR_4); VAR_1++) {",
"VAR_9.mask[VAR_1] = vmsvga_fifo_read_raw(VAR_0);",
"}",
"for (VAR_1 = 0; VAR_1 < SVGA_PIXMAP_SIZE(VAR_3, VAR_4, VAR_9.bpp); VAR_1++) {",
"VAR_9.image[VAR_1] = vmsvga_fifo_read_raw(VAR_0);",
"}",
"#ifdef HW_MOUSE_ACCEL\nvmsvga_cursor_define(VAR_0, &VAR_9);",
"break;",
"#else\nVAR_1 = 0;",
"goto badcmd;",
"#endif\ncase SVGA_CMD_DEFINE_ALPHA_CURSOR:\nVAR_2 -= 6;",
"if (VAR_2 < 0) {",
"goto rewind;",
"}",
"vmsvga_fifo_read(VAR_0);",
"vmsvga_fifo_read(VAR_0);",
"vmsvga_fifo_read(VAR_0);",
"VAR_3 = vmsvga_fifo_read(VAR_0);",
"VAR_4 = vmsvga_fifo_read(VAR_0);",
"VAR_1 = VAR_3 * VAR_4;",
"goto badcmd;",
"case SVGA_CMD_RECT_ROP_FILL:\nVAR_1 = 6;",
"goto badcmd;",
"case SVGA_CMD_RECT_ROP_COPY:\nVAR_1 = 7;",
"goto badcmd;",
"case SVGA_CMD_DRAW_GLYPH_CLIPPED:\nVAR_2 -= 4;",
"if (VAR_2 < 0) {",
"goto rewind;",
"}",
"vmsvga_fifo_read(VAR_0);",
"vmsvga_fifo_read(VAR_0);",
"VAR_1 = 7 + (vmsvga_fifo_read(VAR_0) >> 2);",
"goto badcmd;",
"case SVGA_CMD_SURFACE_ALPHA_BLEND:\nVAR_1 = 12;",
"goto badcmd;",
"case SVGA_CMD_SURFACE_FILL:\ncase SVGA_CMD_SURFACE_COPY:\ncase SVGA_CMD_FRONT_ROP_FILL:\ncase SVGA_CMD_FENCE:\ncase SVGA_CMD_INVALID_CMD:\nbreak;",
"default:\nVAR_1 = 0;",
"badcmd:\nVAR_2 -= VAR_1;",
"if (VAR_2 < 0) {",
"goto rewind;",
"}",
"while (VAR_1--) {",
"vmsvga_fifo_read(VAR_0);",
"}",
"printf(\"%VAR_0: Unknown command 0x%02x in SVGA command FIFO\\n\",\n__func__, cmd);",
"break;",
"rewind:\nVAR_0->cmd->stop = cmd_start;",
"break;",
"}",
"}",
"VAR_0->syncing = 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,
1,
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
23
],
[
27
],
[
29,
31,
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57,
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79,
81
],
[
83
],
[
85,
87
],
[
89
],
[
91,
95,
97
],
[
99
],
[
101
],
[
103
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119,
121
],
[
123
],
[
125
],
[
127,
129
],
[
131
],
[
135,
137
],
[
139
],
[
141
],
[
143
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
163
],
[
165,
167
],
[
169
],
[
171
],
[
175
],
[
177
],
[
179
],
[
181
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197,
199
],
[
201
],
[
203,
205
],
[
207
],
[
209,
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
],
[
291,
293,
295,
297,
299,
301
],
[
305,
307
],
[
309,
311
],
[
313
],
[
315
],
[
317
],
[
319
],
[
321
],
[
323
],
[
325,
327
],
[
329
],
[
333,
335
],
[
337
],
[
339
],
[
341
],
[
345
],
[
347
]
] |
21,153 | static void aw_a10_class_init(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
dc->realize = aw_a10_realize;
} | true | qemu | 4c315c27661502a0813b129e41c0bf640c34a8d6 | static void aw_a10_class_init(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
dc->realize = aw_a10_realize;
} | {
"code": [],
"line_no": []
} | static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)
{
DeviceClass *dc = DEVICE_CLASS(VAR_0);
dc->realize = aw_a10_realize;
} | [
"static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)\n{",
"DeviceClass *dc = DEVICE_CLASS(VAR_0);",
"dc->realize = aw_a10_realize;",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
2
],
[
3
],
[
4
],
[
5
]
] |
21,154 | static void flash_sync_page(Flash *s, int page)
{
QEMUIOVector *iov = g_new(QEMUIOVector, 1);
if (!s->blk || blk_is_read_only(s->blk)) {
return;
}
qemu_iovec_init(iov, 1);
qemu_iovec_add(iov, s->storage + page * s->pi->page_size,
s->pi->page_size);
blk_aio_pwritev(s->blk, page * s->pi->page_size, iov, 0,
blk_sync_complete, iov);
}
| true | qemu | eef9f19eea26cd8b4553459118f87d7150b53c5a | static void flash_sync_page(Flash *s, int page)
{
QEMUIOVector *iov = g_new(QEMUIOVector, 1);
if (!s->blk || blk_is_read_only(s->blk)) {
return;
}
qemu_iovec_init(iov, 1);
qemu_iovec_add(iov, s->storage + page * s->pi->page_size,
s->pi->page_size);
blk_aio_pwritev(s->blk, page * s->pi->page_size, iov, 0,
blk_sync_complete, iov);
}
| {
"code": [
" QEMUIOVector *iov = g_new(QEMUIOVector, 1);",
" QEMUIOVector *iov = g_new(QEMUIOVector, 1);"
],
"line_no": [
5,
5
]
} | static void FUNC_0(Flash *VAR_0, int VAR_1)
{
QEMUIOVector *iov = g_new(QEMUIOVector, 1);
if (!VAR_0->blk || blk_is_read_only(VAR_0->blk)) {
return;
}
qemu_iovec_init(iov, 1);
qemu_iovec_add(iov, VAR_0->storage + VAR_1 * VAR_0->pi->page_size,
VAR_0->pi->page_size);
blk_aio_pwritev(VAR_0->blk, VAR_1 * VAR_0->pi->page_size, iov, 0,
blk_sync_complete, iov);
}
| [
"static void FUNC_0(Flash *VAR_0, int VAR_1)\n{",
"QEMUIOVector *iov = g_new(QEMUIOVector, 1);",
"if (!VAR_0->blk || blk_is_read_only(VAR_0->blk)) {",
"return;",
"}",
"qemu_iovec_init(iov, 1);",
"qemu_iovec_add(iov, VAR_0->storage + VAR_1 * VAR_0->pi->page_size,\nVAR_0->pi->page_size);",
"blk_aio_pwritev(VAR_0->blk, VAR_1 * VAR_0->pi->page_size, iov, 0,\nblk_sync_complete, iov);",
"}"
] | [
0,
1,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19,
21
],
[
23,
25
],
[
27
]
] |
21,156 | static void sr_1d97_float(float *p, int i0, int i1)
{
int i;
if (i1 <= i0 + 1) {
if (i0 == 1)
p[1] *= F_LFTG_K/2;
else
p[0] *= F_LFTG_X/2;
return;
}
extend97_float(p, i0, i1);
for (i = i0 / 2 - 1; i < i1 / 2 + 2; i++)
p[2 * i] -= F_LFTG_DELTA * (p[2 * i - 1] + p[2 * i + 1]);
/* step 4 */
for (i = i0 / 2 - 1; i < i1 / 2 + 1; i++)
p[2 * i + 1] -= F_LFTG_GAMMA * (p[2 * i] + p[2 * i + 2]);
/*step 5*/
for (i = i0 / 2; i < i1 / 2 + 1; i++)
p[2 * i] += F_LFTG_BETA * (p[2 * i - 1] + p[2 * i + 1]);
/* step 6 */
for (i = i0 / 2; i < i1 / 2; i++)
p[2 * i + 1] += F_LFTG_ALPHA * (p[2 * i] + p[2 * i + 2]);
}
| true | FFmpeg | 1c495b0bf690995c45f79f4f19500921e14ec78a | static void sr_1d97_float(float *p, int i0, int i1)
{
int i;
if (i1 <= i0 + 1) {
if (i0 == 1)
p[1] *= F_LFTG_K/2;
else
p[0] *= F_LFTG_X/2;
return;
}
extend97_float(p, i0, i1);
for (i = i0 / 2 - 1; i < i1 / 2 + 2; i++)
p[2 * i] -= F_LFTG_DELTA * (p[2 * i - 1] + p[2 * i + 1]);
for (i = i0 / 2 - 1; i < i1 / 2 + 1; i++)
p[2 * i + 1] -= F_LFTG_GAMMA * (p[2 * i] + p[2 * i + 2]);
for (i = i0 / 2; i < i1 / 2 + 1; i++)
p[2 * i] += F_LFTG_BETA * (p[2 * i - 1] + p[2 * i + 1]);
for (i = i0 / 2; i < i1 / 2; i++)
p[2 * i + 1] += F_LFTG_ALPHA * (p[2 * i] + p[2 * i + 2]);
}
| {
"code": [
" p[0] *= F_LFTG_X/2;"
],
"line_no": [
17
]
} | static void FUNC_0(float *VAR_0, int VAR_1, int VAR_2)
{
int VAR_3;
if (VAR_2 <= VAR_1 + 1) {
if (VAR_1 == 1)
VAR_0[1] *= F_LFTG_K/2;
else
VAR_0[0] *= F_LFTG_X/2;
return;
}
extend97_float(VAR_0, VAR_1, VAR_2);
for (VAR_3 = VAR_1 / 2 - 1; VAR_3 < VAR_2 / 2 + 2; VAR_3++)
VAR_0[2 * VAR_3] -= F_LFTG_DELTA * (VAR_0[2 * VAR_3 - 1] + VAR_0[2 * VAR_3 + 1]);
for (VAR_3 = VAR_1 / 2 - 1; VAR_3 < VAR_2 / 2 + 1; VAR_3++)
VAR_0[2 * VAR_3 + 1] -= F_LFTG_GAMMA * (VAR_0[2 * VAR_3] + VAR_0[2 * VAR_3 + 2]);
for (VAR_3 = VAR_1 / 2; VAR_3 < VAR_2 / 2 + 1; VAR_3++)
VAR_0[2 * VAR_3] += F_LFTG_BETA * (VAR_0[2 * VAR_3 - 1] + VAR_0[2 * VAR_3 + 1]);
for (VAR_3 = VAR_1 / 2; VAR_3 < VAR_2 / 2; VAR_3++)
VAR_0[2 * VAR_3 + 1] += F_LFTG_ALPHA * (VAR_0[2 * VAR_3] + VAR_0[2 * VAR_3 + 2]);
}
| [
"static void FUNC_0(float *VAR_0, int VAR_1, int VAR_2)\n{",
"int VAR_3;",
"if (VAR_2 <= VAR_1 + 1) {",
"if (VAR_1 == 1)\nVAR_0[1] *= F_LFTG_K/2;",
"else\nVAR_0[0] *= F_LFTG_X/2;",
"return;",
"}",
"extend97_float(VAR_0, VAR_1, VAR_2);",
"for (VAR_3 = VAR_1 / 2 - 1; VAR_3 < VAR_2 / 2 + 2; VAR_3++)",
"VAR_0[2 * VAR_3] -= F_LFTG_DELTA * (VAR_0[2 * VAR_3 - 1] + VAR_0[2 * VAR_3 + 1]);",
"for (VAR_3 = VAR_1 / 2 - 1; VAR_3 < VAR_2 / 2 + 1; VAR_3++)",
"VAR_0[2 * VAR_3 + 1] -= F_LFTG_GAMMA * (VAR_0[2 * VAR_3] + VAR_0[2 * VAR_3 + 2]);",
"for (VAR_3 = VAR_1 / 2; VAR_3 < VAR_2 / 2 + 1; VAR_3++)",
"VAR_0[2 * VAR_3] += F_LFTG_BETA * (VAR_0[2 * VAR_3 - 1] + VAR_0[2 * VAR_3 + 1]);",
"for (VAR_3 = VAR_1 / 2; VAR_3 < VAR_2 / 2; VAR_3++)",
"VAR_0[2 * VAR_3 + 1] += F_LFTG_ALPHA * (VAR_0[2 * VAR_3] + VAR_0[2 * VAR_3 + 2]);",
"}"
] | [
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11,
13
],
[
15,
17
],
[
19
],
[
21
],
[
25
],
[
29
],
[
31
],
[
35
],
[
37
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
]
] |
21,157 | static int dca_find_frame_end(DCAParseContext * pc1, const uint8_t * buf,
int buf_size)
{
int start_found, i;
uint32_t state;
ParseContext *pc = &pc1->pc;
start_found = pc->frame_start_found;
state = pc->state;
i = 0;
if (!start_found) {
for (i = 0; i < buf_size; i++) {
state = (state << 8) | buf[i];
if (IS_MARKER(state, i, buf, buf_size)) {
if (!pc1->lastmarker || state == pc1->lastmarker || pc1->lastmarker == DCA_HD_MARKER) {
start_found = 1;
pc1->lastmarker = state;
break;
}
}
}
}
if (start_found) {
for (; i < buf_size; i++) {
pc1->size++;
state = (state << 8) | buf[i];
if (state == DCA_HD_MARKER && !pc1->hd_pos)
pc1->hd_pos = pc1->size;
if (IS_MARKER(state, i, buf, buf_size) && (state == pc1->lastmarker || pc1->lastmarker == DCA_HD_MARKER)) {
if(pc1->framesize > pc1->size)
continue;
if(!pc1->framesize){
pc1->framesize = pc1->hd_pos ? pc1->hd_pos : pc1->size;
}
pc->frame_start_found = 0;
pc->state = -1;
pc1->size = 0;
return i - 3;
}
}
}
pc->frame_start_found = start_found;
pc->state = state;
return END_NOT_FOUND;
}
| true | FFmpeg | 022d22e5810d1c90f618fddd751b1f03502d6021 | static int dca_find_frame_end(DCAParseContext * pc1, const uint8_t * buf,
int buf_size)
{
int start_found, i;
uint32_t state;
ParseContext *pc = &pc1->pc;
start_found = pc->frame_start_found;
state = pc->state;
i = 0;
if (!start_found) {
for (i = 0; i < buf_size; i++) {
state = (state << 8) | buf[i];
if (IS_MARKER(state, i, buf, buf_size)) {
if (!pc1->lastmarker || state == pc1->lastmarker || pc1->lastmarker == DCA_HD_MARKER) {
start_found = 1;
pc1->lastmarker = state;
break;
}
}
}
}
if (start_found) {
for (; i < buf_size; i++) {
pc1->size++;
state = (state << 8) | buf[i];
if (state == DCA_HD_MARKER && !pc1->hd_pos)
pc1->hd_pos = pc1->size;
if (IS_MARKER(state, i, buf, buf_size) && (state == pc1->lastmarker || pc1->lastmarker == DCA_HD_MARKER)) {
if(pc1->framesize > pc1->size)
continue;
if(!pc1->framesize){
pc1->framesize = pc1->hd_pos ? pc1->hd_pos : pc1->size;
}
pc->frame_start_found = 0;
pc->state = -1;
pc1->size = 0;
return i - 3;
}
}
}
pc->frame_start_found = start_found;
pc->state = state;
return END_NOT_FOUND;
}
| {
"code": [
" if(!pc1->framesize){"
],
"line_no": [
65
]
} | static int FUNC_0(DCAParseContext * VAR_0, const uint8_t * VAR_1,
int VAR_2)
{
int VAR_3, VAR_4;
uint32_t state;
ParseContext *pc = &VAR_0->pc;
VAR_3 = pc->frame_start_found;
state = pc->state;
VAR_4 = 0;
if (!VAR_3) {
for (VAR_4 = 0; VAR_4 < VAR_2; VAR_4++) {
state = (state << 8) | VAR_1[VAR_4];
if (IS_MARKER(state, VAR_4, VAR_1, VAR_2)) {
if (!VAR_0->lastmarker || state == VAR_0->lastmarker || VAR_0->lastmarker == DCA_HD_MARKER) {
VAR_3 = 1;
VAR_0->lastmarker = state;
break;
}
}
}
}
if (VAR_3) {
for (; VAR_4 < VAR_2; VAR_4++) {
VAR_0->size++;
state = (state << 8) | VAR_1[VAR_4];
if (state == DCA_HD_MARKER && !VAR_0->hd_pos)
VAR_0->hd_pos = VAR_0->size;
if (IS_MARKER(state, VAR_4, VAR_1, VAR_2) && (state == VAR_0->lastmarker || VAR_0->lastmarker == DCA_HD_MARKER)) {
if(VAR_0->framesize > VAR_0->size)
continue;
if(!VAR_0->framesize){
VAR_0->framesize = VAR_0->hd_pos ? VAR_0->hd_pos : VAR_0->size;
}
pc->frame_start_found = 0;
pc->state = -1;
VAR_0->size = 0;
return VAR_4 - 3;
}
}
}
pc->frame_start_found = VAR_3;
pc->state = state;
return END_NOT_FOUND;
}
| [
"static int FUNC_0(DCAParseContext * VAR_0, const uint8_t * VAR_1,\nint VAR_2)\n{",
"int VAR_3, VAR_4;",
"uint32_t state;",
"ParseContext *pc = &VAR_0->pc;",
"VAR_3 = pc->frame_start_found;",
"state = pc->state;",
"VAR_4 = 0;",
"if (!VAR_3) {",
"for (VAR_4 = 0; VAR_4 < VAR_2; VAR_4++) {",
"state = (state << 8) | VAR_1[VAR_4];",
"if (IS_MARKER(state, VAR_4, VAR_1, VAR_2)) {",
"if (!VAR_0->lastmarker || state == VAR_0->lastmarker || VAR_0->lastmarker == DCA_HD_MARKER) {",
"VAR_3 = 1;",
"VAR_0->lastmarker = state;",
"break;",
"}",
"}",
"}",
"}",
"if (VAR_3) {",
"for (; VAR_4 < VAR_2; VAR_4++) {",
"VAR_0->size++;",
"state = (state << 8) | VAR_1[VAR_4];",
"if (state == DCA_HD_MARKER && !VAR_0->hd_pos)\nVAR_0->hd_pos = VAR_0->size;",
"if (IS_MARKER(state, VAR_4, VAR_1, VAR_2) && (state == VAR_0->lastmarker || VAR_0->lastmarker == DCA_HD_MARKER)) {",
"if(VAR_0->framesize > VAR_0->size)\ncontinue;",
"if(!VAR_0->framesize){",
"VAR_0->framesize = VAR_0->hd_pos ? VAR_0->hd_pos : VAR_0->size;",
"}",
"pc->frame_start_found = 0;",
"pc->state = -1;",
"VAR_0->size = 0;",
"return VAR_4 - 3;",
"}",
"}",
"}",
"pc->frame_start_found = VAR_3;",
"pc->state = state;",
"return END_NOT_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,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
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
],
[
87
],
[
89
],
[
91
]
] |
21,158 | static int mpeg1_decode_picture(AVCodecContext *avctx, const uint8_t *buf,
int buf_size)
{
Mpeg1Context *s1 = avctx->priv_data;
MpegEncContext *s = &s1->mpeg_enc_ctx;
int ref, f_code, vbv_delay;
init_get_bits(&s->gb, buf, buf_size * 8);
ref = get_bits(&s->gb, 10); /* temporal ref */
s->pict_type = get_bits(&s->gb, 3);
if (s->pict_type == 0 || s->pict_type > 3)
return -1;
vbv_delay = get_bits(&s->gb, 16);
if (s->pict_type == AV_PICTURE_TYPE_P ||
s->pict_type == AV_PICTURE_TYPE_B) {
s->full_pel[0] = get_bits1(&s->gb);
f_code = get_bits(&s->gb, 3);
if (f_code == 0 && (avctx->err_recognition & AV_EF_BITSTREAM))
return -1;
s->mpeg_f_code[0][0] = f_code;
s->mpeg_f_code[0][1] = f_code;
}
if (s->pict_type == AV_PICTURE_TYPE_B) {
s->full_pel[1] = get_bits1(&s->gb);
f_code = get_bits(&s->gb, 3);
if (f_code == 0 && (avctx->err_recognition & AV_EF_BITSTREAM))
return -1;
s->mpeg_f_code[1][0] = f_code;
s->mpeg_f_code[1][1] = f_code;
}
s->current_picture.f.pict_type = s->pict_type;
s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;
if (avctx->debug & FF_DEBUG_PICT_INFO)
av_log(avctx, AV_LOG_DEBUG,
"vbv_delay %d, ref %d type:%d\n", vbv_delay, ref, s->pict_type);
s->y_dc_scale = 8;
s->c_dc_scale = 8;
return 0;
}
| true | FFmpeg | f6774f905fb3cfdc319523ac640be30b14c1bc55 | static int mpeg1_decode_picture(AVCodecContext *avctx, const uint8_t *buf,
int buf_size)
{
Mpeg1Context *s1 = avctx->priv_data;
MpegEncContext *s = &s1->mpeg_enc_ctx;
int ref, f_code, vbv_delay;
init_get_bits(&s->gb, buf, buf_size * 8);
ref = get_bits(&s->gb, 10);
s->pict_type = get_bits(&s->gb, 3);
if (s->pict_type == 0 || s->pict_type > 3)
return -1;
vbv_delay = get_bits(&s->gb, 16);
if (s->pict_type == AV_PICTURE_TYPE_P ||
s->pict_type == AV_PICTURE_TYPE_B) {
s->full_pel[0] = get_bits1(&s->gb);
f_code = get_bits(&s->gb, 3);
if (f_code == 0 && (avctx->err_recognition & AV_EF_BITSTREAM))
return -1;
s->mpeg_f_code[0][0] = f_code;
s->mpeg_f_code[0][1] = f_code;
}
if (s->pict_type == AV_PICTURE_TYPE_B) {
s->full_pel[1] = get_bits1(&s->gb);
f_code = get_bits(&s->gb, 3);
if (f_code == 0 && (avctx->err_recognition & AV_EF_BITSTREAM))
return -1;
s->mpeg_f_code[1][0] = f_code;
s->mpeg_f_code[1][1] = f_code;
}
s->current_picture.f.pict_type = s->pict_type;
s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;
if (avctx->debug & FF_DEBUG_PICT_INFO)
av_log(avctx, AV_LOG_DEBUG,
"vbv_delay %d, ref %d type:%d\n", vbv_delay, ref, s->pict_type);
s->y_dc_scale = 8;
s->c_dc_scale = 8;
return 0;
}
| {
"code": [
" s->current_picture.f.pict_type = s->pict_type;",
" s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;",
" s->current_picture.f.pict_type = s->pict_type;",
" s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;",
" s->current_picture.f.pict_type = s->pict_type;",
" s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;",
" s->current_picture.f.pict_type = s->pict_type;",
" s->current_picture.f.pict_type = s->pict_type;",
" s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;"
],
"line_no": [
65,
67,
65,
67,
65,
67,
65,
65,
67
]
} | static int FUNC_0(AVCodecContext *VAR_0, const uint8_t *VAR_1,
int VAR_2)
{
Mpeg1Context *s1 = VAR_0->priv_data;
MpegEncContext *s = &s1->mpeg_enc_ctx;
int VAR_3, VAR_4, VAR_5;
init_get_bits(&s->gb, VAR_1, VAR_2 * 8);
VAR_3 = get_bits(&s->gb, 10);
s->pict_type = get_bits(&s->gb, 3);
if (s->pict_type == 0 || s->pict_type > 3)
return -1;
VAR_5 = get_bits(&s->gb, 16);
if (s->pict_type == AV_PICTURE_TYPE_P ||
s->pict_type == AV_PICTURE_TYPE_B) {
s->full_pel[0] = get_bits1(&s->gb);
VAR_4 = get_bits(&s->gb, 3);
if (VAR_4 == 0 && (VAR_0->err_recognition & AV_EF_BITSTREAM))
return -1;
s->mpeg_f_code[0][0] = VAR_4;
s->mpeg_f_code[0][1] = VAR_4;
}
if (s->pict_type == AV_PICTURE_TYPE_B) {
s->full_pel[1] = get_bits1(&s->gb);
VAR_4 = get_bits(&s->gb, 3);
if (VAR_4 == 0 && (VAR_0->err_recognition & AV_EF_BITSTREAM))
return -1;
s->mpeg_f_code[1][0] = VAR_4;
s->mpeg_f_code[1][1] = VAR_4;
}
s->current_picture.f.pict_type = s->pict_type;
s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;
if (VAR_0->debug & FF_DEBUG_PICT_INFO)
av_log(VAR_0, AV_LOG_DEBUG,
"VAR_5 %d, VAR_3 %d type:%d\n", VAR_5, VAR_3, s->pict_type);
s->y_dc_scale = 8;
s->c_dc_scale = 8;
return 0;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, const uint8_t *VAR_1,\nint VAR_2)\n{",
"Mpeg1Context *s1 = VAR_0->priv_data;",
"MpegEncContext *s = &s1->mpeg_enc_ctx;",
"int VAR_3, VAR_4, VAR_5;",
"init_get_bits(&s->gb, VAR_1, VAR_2 * 8);",
"VAR_3 = get_bits(&s->gb, 10);",
"s->pict_type = get_bits(&s->gb, 3);",
"if (s->pict_type == 0 || s->pict_type > 3)\nreturn -1;",
"VAR_5 = get_bits(&s->gb, 16);",
"if (s->pict_type == AV_PICTURE_TYPE_P ||\ns->pict_type == AV_PICTURE_TYPE_B) {",
"s->full_pel[0] = get_bits1(&s->gb);",
"VAR_4 = get_bits(&s->gb, 3);",
"if (VAR_4 == 0 && (VAR_0->err_recognition & AV_EF_BITSTREAM))\nreturn -1;",
"s->mpeg_f_code[0][0] = VAR_4;",
"s->mpeg_f_code[0][1] = VAR_4;",
"}",
"if (s->pict_type == AV_PICTURE_TYPE_B) {",
"s->full_pel[1] = get_bits1(&s->gb);",
"VAR_4 = get_bits(&s->gb, 3);",
"if (VAR_4 == 0 && (VAR_0->err_recognition & AV_EF_BITSTREAM))\nreturn -1;",
"s->mpeg_f_code[1][0] = VAR_4;",
"s->mpeg_f_code[1][1] = VAR_4;",
"}",
"s->current_picture.f.pict_type = s->pict_type;",
"s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;",
"if (VAR_0->debug & FF_DEBUG_PICT_INFO)\nav_log(VAR_0, AV_LOG_DEBUG,\n\"VAR_5 %d, VAR_3 %d type:%d\\n\", VAR_5, VAR_3, s->pict_type);",
"s->y_dc_scale = 8;",
"s->c_dc_scale = 8;",
"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,
1,
1,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
19
],
[
21
],
[
23,
25
],
[
29
],
[
31,
33
],
[
35
],
[
37
],
[
39,
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71,
73,
75
],
[
79
],
[
81
],
[
83
],
[
85
]
] |
21,159 | static int read_quant_tables(RangeCoder *c,
int16_t quant_table[MAX_CONTEXT_INPUTS][256])
{
int i;
int context_count = 1;
for (i = 0; i < 5; i++) {
context_count *= read_quant_table(c, quant_table[i], context_count);
if (context_count > 32768U) {
return AVERROR_INVALIDDATA;
}
}
return (context_count + 1) / 2;
}
| true | FFmpeg | 10bbf6cf622f8a954c6cc694ca07c24f989c99af | static int read_quant_tables(RangeCoder *c,
int16_t quant_table[MAX_CONTEXT_INPUTS][256])
{
int i;
int context_count = 1;
for (i = 0; i < 5; i++) {
context_count *= read_quant_table(c, quant_table[i], context_count);
if (context_count > 32768U) {
return AVERROR_INVALIDDATA;
}
}
return (context_count + 1) / 2;
}
| {
"code": [
" context_count *= read_quant_table(c, quant_table[i], context_count);"
],
"line_no": [
15
]
} | static int FUNC_0(RangeCoder *VAR_0,
int16_t VAR_1[MAX_CONTEXT_INPUTS][256])
{
int VAR_2;
int VAR_3 = 1;
for (VAR_2 = 0; VAR_2 < 5; VAR_2++) {
VAR_3 *= read_quant_table(VAR_0, VAR_1[VAR_2], VAR_3);
if (VAR_3 > 32768U) {
return AVERROR_INVALIDDATA;
}
}
return (VAR_3 + 1) / 2;
}
| [
"static int FUNC_0(RangeCoder *VAR_0,\nint16_t VAR_1[MAX_CONTEXT_INPUTS][256])\n{",
"int VAR_2;",
"int VAR_3 = 1;",
"for (VAR_2 = 0; VAR_2 < 5; VAR_2++) {",
"VAR_3 *= read_quant_table(VAR_0, VAR_1[VAR_2], VAR_3);",
"if (VAR_3 > 32768U) {",
"return AVERROR_INVALIDDATA;",
"}",
"}",
"return (VAR_3 + 1) / 2;",
"}"
] | [
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
]
] |
21,161 | int av_copy_packet_side_data(AVPacket *pkt, AVPacket *src)
{
if (src->side_data_elems) {
int i;
DUP_DATA(pkt->side_data, src->side_data,
src->side_data_elems * sizeof(*src->side_data), 0, ALLOC_MALLOC);
memset(pkt->side_data, 0,
src->side_data_elems * sizeof(*src->side_data));
for (i = 0; i < src->side_data_elems; i++) {
DUP_DATA(pkt->side_data[i].data, src->side_data[i].data,
src->side_data[i].size, 1, ALLOC_MALLOC);
pkt->side_data[i].size = src->side_data[i].size;
pkt->side_data[i].type = src->side_data[i].type;
}
}
return 0;
failed_alloc:
av_destruct_packet(pkt);
return AVERROR(ENOMEM);
}
| true | FFmpeg | 6e1b1a27a4034c578018d5042b3c8228278c4cd6 | int av_copy_packet_side_data(AVPacket *pkt, AVPacket *src)
{
if (src->side_data_elems) {
int i;
DUP_DATA(pkt->side_data, src->side_data,
src->side_data_elems * sizeof(*src->side_data), 0, ALLOC_MALLOC);
memset(pkt->side_data, 0,
src->side_data_elems * sizeof(*src->side_data));
for (i = 0; i < src->side_data_elems; i++) {
DUP_DATA(pkt->side_data[i].data, src->side_data[i].data,
src->side_data[i].size, 1, ALLOC_MALLOC);
pkt->side_data[i].size = src->side_data[i].size;
pkt->side_data[i].type = src->side_data[i].type;
}
}
return 0;
failed_alloc:
av_destruct_packet(pkt);
return AVERROR(ENOMEM);
}
| {
"code": [
" av_destruct_packet(pkt);",
" av_destruct_packet(pkt);"
],
"line_no": [
37,
37
]
} | int FUNC_0(AVPacket *VAR_0, AVPacket *VAR_1)
{
if (VAR_1->side_data_elems) {
int VAR_2;
DUP_DATA(VAR_0->side_data, VAR_1->side_data,
VAR_1->side_data_elems * sizeof(*VAR_1->side_data), 0, ALLOC_MALLOC);
memset(VAR_0->side_data, 0,
VAR_1->side_data_elems * sizeof(*VAR_1->side_data));
for (VAR_2 = 0; VAR_2 < VAR_1->side_data_elems; VAR_2++) {
DUP_DATA(VAR_0->side_data[VAR_2].data, VAR_1->side_data[VAR_2].data,
VAR_1->side_data[VAR_2].size, 1, ALLOC_MALLOC);
VAR_0->side_data[VAR_2].size = VAR_1->side_data[VAR_2].size;
VAR_0->side_data[VAR_2].type = VAR_1->side_data[VAR_2].type;
}
}
return 0;
failed_alloc:
av_destruct_packet(VAR_0);
return AVERROR(ENOMEM);
}
| [
"int FUNC_0(AVPacket *VAR_0, AVPacket *VAR_1)\n{",
"if (VAR_1->side_data_elems) {",
"int VAR_2;",
"DUP_DATA(VAR_0->side_data, VAR_1->side_data,\nVAR_1->side_data_elems * sizeof(*VAR_1->side_data), 0, ALLOC_MALLOC);",
"memset(VAR_0->side_data, 0,\nVAR_1->side_data_elems * sizeof(*VAR_1->side_data));",
"for (VAR_2 = 0; VAR_2 < VAR_1->side_data_elems; VAR_2++) {",
"DUP_DATA(VAR_0->side_data[VAR_2].data, VAR_1->side_data[VAR_2].data,\nVAR_1->side_data[VAR_2].size, 1, ALLOC_MALLOC);",
"VAR_0->side_data[VAR_2].size = VAR_1->side_data[VAR_2].size;",
"VAR_0->side_data[VAR_2].type = VAR_1->side_data[VAR_2].type;",
"}",
"}",
"return 0;",
"failed_alloc:\nav_destruct_packet(VAR_0);",
"return AVERROR(ENOMEM);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9,
11
],
[
13,
15
],
[
17
],
[
19,
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35,
37
],
[
39
],
[
41
]
] |
21,162 | static inline void RENAME(rgb32tobgr32)(const uint8_t *src, uint8_t *dst, long src_size)
{
#ifdef HAVE_MMX
/* TODO: unroll this loop */
asm volatile (
"xor %%"REG_a", %%"REG_a" \n\t"
ASMALIGN16
"1: \n\t"
PREFETCH" 32(%0, %%"REG_a") \n\t"
"movq (%0, %%"REG_a"), %%mm0 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm0, %%mm2 \n\t"
"pslld $16, %%mm0 \n\t"
"psrld $16, %%mm1 \n\t"
"pand "MANGLE(mask32r)", %%mm0 \n\t"
"pand "MANGLE(mask32g)", %%mm2 \n\t"
"pand "MANGLE(mask32b)", %%mm1 \n\t"
"por %%mm0, %%mm2 \n\t"
"por %%mm1, %%mm2 \n\t"
MOVNTQ" %%mm2, (%1, %%"REG_a") \n\t"
"add $8, %%"REG_a" \n\t"
"cmp %2, %%"REG_a" \n\t"
" jb 1b \n\t"
:: "r" (src), "r"(dst), "r" (src_size-7)
: "%"REG_a
);
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#else
unsigned i;
unsigned num_pixels = src_size >> 2;
for(i=0; i<num_pixels; i++)
{
#ifdef WORDS_BIGENDIAN
dst[4*i + 1] = src[4*i + 3];
dst[4*i + 2] = src[4*i + 2];
dst[4*i + 3] = src[4*i + 1];
#else
dst[4*i + 0] = src[4*i + 2];
dst[4*i + 1] = src[4*i + 1];
dst[4*i + 2] = src[4*i + 0];
#endif
}
#endif
}
| false | FFmpeg | 4bff9ef9d0781c4de228bf1f85634d2706fc589b | static inline void RENAME(rgb32tobgr32)(const uint8_t *src, uint8_t *dst, long src_size)
{
#ifdef HAVE_MMX
asm volatile (
"xor %%"REG_a", %%"REG_a" \n\t"
ASMALIGN16
"1: \n\t"
PREFETCH" 32(%0, %%"REG_a") \n\t"
"movq (%0, %%"REG_a"), %%mm0 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm0, %%mm2 \n\t"
"pslld $16, %%mm0 \n\t"
"psrld $16, %%mm1 \n\t"
"pand "MANGLE(mask32r)", %%mm0 \n\t"
"pand "MANGLE(mask32g)", %%mm2 \n\t"
"pand "MANGLE(mask32b)", %%mm1 \n\t"
"por %%mm0, %%mm2 \n\t"
"por %%mm1, %%mm2 \n\t"
MOVNTQ" %%mm2, (%1, %%"REG_a") \n\t"
"add $8, %%"REG_a" \n\t"
"cmp %2, %%"REG_a" \n\t"
" jb 1b \n\t"
:: "r" (src), "r"(dst), "r" (src_size-7)
: "%"REG_a
);
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#else
unsigned i;
unsigned num_pixels = src_size >> 2;
for(i=0; i<num_pixels; i++)
{
#ifdef WORDS_BIGENDIAN
dst[4*i + 1] = src[4*i + 3];
dst[4*i + 2] = src[4*i + 2];
dst[4*i + 3] = src[4*i + 1];
#else
dst[4*i + 0] = src[4*i + 2];
dst[4*i + 1] = src[4*i + 1];
dst[4*i + 2] = src[4*i + 0];
#endif
}
#endif
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0(rgb32tobgr32)(const uint8_t *src, uint8_t *dst, long src_size)
{
#ifdef HAVE_MMX
asm volatile (
"xor %%"REG_a", %%"REG_a" \n\t"
ASMALIGN16
"1: \n\t"
PREFETCH" 32(%0, %%"REG_a") \n\t"
"movq (%0, %%"REG_a"), %%mm0 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm0, %%mm2 \n\t"
"pslld $16, %%mm0 \n\t"
"psrld $16, %%mm1 \n\t"
"pand "MANGLE(mask32r)", %%mm0 \n\t"
"pand "MANGLE(mask32g)", %%mm2 \n\t"
"pand "MANGLE(mask32b)", %%mm1 \n\t"
"por %%mm0, %%mm2 \n\t"
"por %%mm1, %%mm2 \n\t"
MOVNTQ" %%mm2, (%1, %%"REG_a") \n\t"
"add $8, %%"REG_a" \n\t"
"cmp %2, %%"REG_a" \n\t"
" jb 1b \n\t"
:: "r" (src), "r"(dst), "r" (src_size-7)
: "%"REG_a
);
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#else
unsigned VAR_0;
unsigned VAR_1 = src_size >> 2;
for(VAR_0=0; VAR_0<VAR_1; VAR_0++)
{
#ifdef WORDS_BIGENDIAN
dst[4*VAR_0 + 1] = src[4*VAR_0 + 3];
dst[4*VAR_0 + 2] = src[4*VAR_0 + 2];
dst[4*VAR_0 + 3] = src[4*VAR_0 + 1];
#else
dst[4*VAR_0 + 0] = src[4*VAR_0 + 2];
dst[4*VAR_0 + 1] = src[4*VAR_0 + 1];
dst[4*VAR_0 + 2] = src[4*VAR_0 + 0];
#endif
}
#endif
}
| [
"static inline void FUNC_0(rgb32tobgr32)(const uint8_t *src, uint8_t *dst, long src_size)\n{",
"#ifdef HAVE_MMX\nasm volatile (\n\"xor %%\"REG_a\", %%\"REG_a\"\t\\n\\t\"\nASMALIGN16\n\"1:\t\t\t\t\\n\\t\"\nPREFETCH\" 32(%0, %%\"REG_a\")\t\\n\\t\"\n\"movq (%0, %%\"REG_a\"), %%mm0\t\\n\\t\"\n\"movq %%mm0, %%mm1\t\t\\n\\t\"\n\"movq %%mm0, %%mm2\t\t\\n\\t\"\n\"pslld $16, %%mm0\t\t\\n\\t\"\n\"psrld $16, %%mm1\t\t\\n\\t\"\n\"pand \"MANGLE(mask32r)\", %%mm0\t\\n\\t\"\n\"pand \"MANGLE(mask32g)\", %%mm2\t\\n\\t\"\n\"pand \"MANGLE(mask32b)\", %%mm1\t\\n\\t\"\n\"por %%mm0, %%mm2\t\t\\n\\t\"\n\"por %%mm1, %%mm2\t\t\\n\\t\"\nMOVNTQ\" %%mm2, (%1, %%\"REG_a\")\t\\n\\t\"\n\"add $8, %%\"REG_a\"\t\t\\n\\t\"\n\"cmp %2, %%\"REG_a\"\t\t\\n\\t\"\n\" jb 1b\t\t\t\t\\n\\t\"\n:: \"r\" (src), \"r\"(dst), \"r\" (src_size-7)\n: \"%\"REG_a\n);",
"__asm __volatile(SFENCE:::\"memory\");",
"__asm __volatile(EMMS:::\"memory\");",
"#else\nunsigned VAR_0;",
"unsigned VAR_1 = src_size >> 2;",
"for(VAR_0=0; VAR_0<VAR_1; VAR_0++)",
"{",
"#ifdef WORDS_BIGENDIAN\ndst[4*VAR_0 + 1] = src[4*VAR_0 + 3];",
"dst[4*VAR_0 + 2] = src[4*VAR_0 + 2];",
"dst[4*VAR_0 + 3] = src[4*VAR_0 + 1];",
"#else\ndst[4*VAR_0 + 0] = src[4*VAR_0 + 2];",
"dst[4*VAR_0 + 1] = src[4*VAR_0 + 1];",
"dst[4*VAR_0 + 2] = src[4*VAR_0 + 0];",
"#endif\n}",
"#endif\n}"
] | [
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
]
] |
21,163 | static int read_block(ALSDecContext *ctx, ALSBlockData *bd)
{
GetBitContext *gb = &ctx->gb;
*bd->shift_lsbs = 0;
// read block type flag and read the samples accordingly
if (get_bits1(gb)) {
if (read_var_block_data(ctx, bd))
return -1;
} else {
read_const_block_data(ctx, bd);
}
return 0;
}
| false | FFmpeg | 0ceca269b66ec12a23bf0907bd2c220513cdbf16 | static int read_block(ALSDecContext *ctx, ALSBlockData *bd)
{
GetBitContext *gb = &ctx->gb;
*bd->shift_lsbs = 0;
if (get_bits1(gb)) {
if (read_var_block_data(ctx, bd))
return -1;
} else {
read_const_block_data(ctx, bd);
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(ALSDecContext *VAR_0, ALSBlockData *VAR_1)
{
GetBitContext *gb = &VAR_0->gb;
*VAR_1->shift_lsbs = 0;
if (get_bits1(gb)) {
if (read_var_block_data(VAR_0, VAR_1))
return -1;
} else {
read_const_block_data(VAR_0, VAR_1);
}
return 0;
}
| [
"static int FUNC_0(ALSDecContext *VAR_0, ALSBlockData *VAR_1)\n{",
"GetBitContext *gb = &VAR_0->gb;",
"*VAR_1->shift_lsbs = 0;",
"if (get_bits1(gb)) {",
"if (read_var_block_data(VAR_0, VAR_1))\nreturn -1;",
"} else {",
"read_const_block_data(VAR_0, VAR_1);",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
15,
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
]
] |
21,164 | static int init_input(AVFormatContext *s, const char *filename,
AVDictionary **options)
{
int ret;
AVProbeData pd = { filename, NULL, 0 };
int score = AVPROBE_SCORE_RETRY;
if (s->pb) {
s->flags |= AVFMT_FLAG_CUSTOM_IO;
if (!s->iformat)
return av_probe_input_buffer2(s->pb, &s->iformat, filename,
s, 0, s->format_probesize);
else if (s->iformat->flags & AVFMT_NOFILE)
av_log(s, AV_LOG_WARNING, "Custom AVIOContext makes no sense and "
"will be ignored with AVFMT_NOFILE format.\n");
return 0;
}
if ((s->iformat && s->iformat->flags & AVFMT_NOFILE) ||
(!s->iformat && (s->iformat = av_probe_input_format2(&pd, 0, &score))))
return score;
if ((ret = avio_open2(&s->pb, filename, AVIO_FLAG_READ | s->avio_flags,
&s->interrupt_callback, options)) < 0)
return ret;
if (s->iformat)
return 0;
return av_probe_input_buffer2(s->pb, &s->iformat, filename,
s, 0, s->format_probesize);
}
| false | FFmpeg | 1dba8371d93cf1c83bcd5c432d921905206a60f3 | static int init_input(AVFormatContext *s, const char *filename,
AVDictionary **options)
{
int ret;
AVProbeData pd = { filename, NULL, 0 };
int score = AVPROBE_SCORE_RETRY;
if (s->pb) {
s->flags |= AVFMT_FLAG_CUSTOM_IO;
if (!s->iformat)
return av_probe_input_buffer2(s->pb, &s->iformat, filename,
s, 0, s->format_probesize);
else if (s->iformat->flags & AVFMT_NOFILE)
av_log(s, AV_LOG_WARNING, "Custom AVIOContext makes no sense and "
"will be ignored with AVFMT_NOFILE format.\n");
return 0;
}
if ((s->iformat && s->iformat->flags & AVFMT_NOFILE) ||
(!s->iformat && (s->iformat = av_probe_input_format2(&pd, 0, &score))))
return score;
if ((ret = avio_open2(&s->pb, filename, AVIO_FLAG_READ | s->avio_flags,
&s->interrupt_callback, options)) < 0)
return ret;
if (s->iformat)
return 0;
return av_probe_input_buffer2(s->pb, &s->iformat, filename,
s, 0, s->format_probesize);
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0, const char *VAR_1,
AVDictionary **VAR_2)
{
int VAR_3;
AVProbeData pd = { VAR_1, NULL, 0 };
int VAR_4 = AVPROBE_SCORE_RETRY;
if (VAR_0->pb) {
VAR_0->flags |= AVFMT_FLAG_CUSTOM_IO;
if (!VAR_0->iformat)
return av_probe_input_buffer2(VAR_0->pb, &VAR_0->iformat, VAR_1,
VAR_0, 0, VAR_0->format_probesize);
else if (VAR_0->iformat->flags & AVFMT_NOFILE)
av_log(VAR_0, AV_LOG_WARNING, "Custom AVIOContext makes no sense and "
"will be ignored with AVFMT_NOFILE format.\n");
return 0;
}
if ((VAR_0->iformat && VAR_0->iformat->flags & AVFMT_NOFILE) ||
(!VAR_0->iformat && (VAR_0->iformat = av_probe_input_format2(&pd, 0, &VAR_4))))
return VAR_4;
if ((VAR_3 = avio_open2(&VAR_0->pb, VAR_1, AVIO_FLAG_READ | VAR_0->avio_flags,
&VAR_0->interrupt_callback, VAR_2)) < 0)
return VAR_3;
if (VAR_0->iformat)
return 0;
return av_probe_input_buffer2(VAR_0->pb, &VAR_0->iformat, VAR_1,
VAR_0, 0, VAR_0->format_probesize);
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, const char *VAR_1,\nAVDictionary **VAR_2)\n{",
"int VAR_3;",
"AVProbeData pd = { VAR_1, NULL, 0 };",
"int VAR_4 = AVPROBE_SCORE_RETRY;",
"if (VAR_0->pb) {",
"VAR_0->flags |= AVFMT_FLAG_CUSTOM_IO;",
"if (!VAR_0->iformat)\nreturn av_probe_input_buffer2(VAR_0->pb, &VAR_0->iformat, VAR_1,\nVAR_0, 0, VAR_0->format_probesize);",
"else if (VAR_0->iformat->flags & AVFMT_NOFILE)\nav_log(VAR_0, AV_LOG_WARNING, \"Custom AVIOContext makes no sense and \"\n\"will be ignored with AVFMT_NOFILE format.\\n\");",
"return 0;",
"}",
"if ((VAR_0->iformat && VAR_0->iformat->flags & AVFMT_NOFILE) ||\n(!VAR_0->iformat && (VAR_0->iformat = av_probe_input_format2(&pd, 0, &VAR_4))))\nreturn VAR_4;",
"if ((VAR_3 = avio_open2(&VAR_0->pb, VAR_1, AVIO_FLAG_READ | VAR_0->avio_flags,\n&VAR_0->interrupt_callback, VAR_2)) < 0)\nreturn VAR_3;",
"if (VAR_0->iformat)\nreturn 0;",
"return av_probe_input_buffer2(VAR_0->pb, &VAR_0->iformat, VAR_1,\nVAR_0, 0, VAR_0->format_probesize);",
"}"
] | [
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,
23
],
[
25,
27,
29
],
[
31
],
[
33
],
[
37,
39,
41
],
[
45,
47,
49
],
[
51,
53
],
[
55,
57
],
[
59
]
] |
21,165 | static int inet_aton(const char *str, struct in_addr *add)
{
return inet_aton(str, add);
}
| false | FFmpeg | c693af1951a0074a29ce39b69736ff0cf33b41d2 | static int inet_aton(const char *str, struct in_addr *add)
{
return inet_aton(str, add);
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(const char *VAR_0, struct in_addr *VAR_1)
{
return FUNC_0(VAR_0, VAR_1);
}
| [
"static int FUNC_0(const char *VAR_0, struct in_addr *VAR_1)\n{",
"return FUNC_0(VAR_0, VAR_1);",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
21,167 | MAKE_ACCESSORS(AVVDPAUContext, vdpau_hwaccel, AVVDPAU_Render2, render2)
int ff_vdpau_common_init(AVCodecContext *avctx, VdpDecoderProfile profile,
int level)
{
VDPAUHWContext *hwctx = avctx->hwaccel_context;
VDPAUContext *vdctx = avctx->internal->hwaccel_priv_data;
VdpVideoSurfaceQueryCapabilities *surface_query_caps;
VdpDecoderQueryCapabilities *decoder_query_caps;
VdpDecoderCreate *create;
void *func;
VdpStatus status;
VdpBool supported;
uint32_t max_level, max_mb, max_width, max_height;
/* See vdpau/vdpau.h for alignment constraints. */
uint32_t width = (avctx->coded_width + 1) & ~1;
uint32_t height = (avctx->coded_height + 3) & ~3;
vdctx->width = UINT32_MAX;
vdctx->height = UINT32_MAX;
hwctx->reset = 0;
if (!hwctx) {
vdctx->device = VDP_INVALID_HANDLE;
av_log(avctx, AV_LOG_WARNING, "hwaccel_context has not been setup by the user application, cannot initialize\n");
return 0;
}
if (hwctx->context.decoder != VDP_INVALID_HANDLE) {
vdctx->decoder = hwctx->context.decoder;
vdctx->render = hwctx->context.render;
vdctx->device = VDP_INVALID_HANDLE;
return 0; /* Decoder created by user */
}
vdctx->device = hwctx->device;
vdctx->get_proc_address = hwctx->get_proc_address;
if (level < 0)
return AVERROR(ENOTSUP);
status = vdctx->get_proc_address(vdctx->device,
VDP_FUNC_ID_VIDEO_SURFACE_QUERY_CAPABILITIES,
&func);
if (status != VDP_STATUS_OK)
return vdpau_error(status);
else
surface_query_caps = func;
status = surface_query_caps(vdctx->device, VDP_CHROMA_TYPE_420, &supported,
&max_width, &max_height);
if (status != VDP_STATUS_OK)
return vdpau_error(status);
if (supported != VDP_TRUE ||
max_width < width || max_height < height)
return AVERROR(ENOTSUP);
status = vdctx->get_proc_address(vdctx->device,
VDP_FUNC_ID_DECODER_QUERY_CAPABILITIES,
&func);
if (status != VDP_STATUS_OK)
return vdpau_error(status);
else
decoder_query_caps = func;
status = decoder_query_caps(vdctx->device, profile, &supported, &max_level,
&max_mb, &max_width, &max_height);
if (status != VDP_STATUS_OK)
return vdpau_error(status);
if (supported != VDP_TRUE || max_level < level ||
max_width < width || max_height < height)
return AVERROR(ENOTSUP);
status = vdctx->get_proc_address(vdctx->device, VDP_FUNC_ID_DECODER_CREATE,
&func);
if (status != VDP_STATUS_OK)
return vdpau_error(status);
else
create = func;
status = vdctx->get_proc_address(vdctx->device, VDP_FUNC_ID_DECODER_RENDER,
&func);
if (status != VDP_STATUS_OK)
return vdpau_error(status);
else
vdctx->render = func;
status = create(vdctx->device, profile, width, height, avctx->refs,
&vdctx->decoder);
if (status == VDP_STATUS_OK) {
vdctx->width = avctx->coded_width;
vdctx->height = avctx->coded_height;
}
return vdpau_error(status);
}
| false | FFmpeg | 67ddf21611b904de1ee3eb0206cd2744a135704a | MAKE_ACCESSORS(AVVDPAUContext, vdpau_hwaccel, AVVDPAU_Render2, render2)
int ff_vdpau_common_init(AVCodecContext *avctx, VdpDecoderProfile profile,
int level)
{
VDPAUHWContext *hwctx = avctx->hwaccel_context;
VDPAUContext *vdctx = avctx->internal->hwaccel_priv_data;
VdpVideoSurfaceQueryCapabilities *surface_query_caps;
VdpDecoderQueryCapabilities *decoder_query_caps;
VdpDecoderCreate *create;
void *func;
VdpStatus status;
VdpBool supported;
uint32_t max_level, max_mb, max_width, max_height;
uint32_t width = (avctx->coded_width + 1) & ~1;
uint32_t height = (avctx->coded_height + 3) & ~3;
vdctx->width = UINT32_MAX;
vdctx->height = UINT32_MAX;
hwctx->reset = 0;
if (!hwctx) {
vdctx->device = VDP_INVALID_HANDLE;
av_log(avctx, AV_LOG_WARNING, "hwaccel_context has not been setup by the user application, cannot initialize\n");
return 0;
}
if (hwctx->context.decoder != VDP_INVALID_HANDLE) {
vdctx->decoder = hwctx->context.decoder;
vdctx->render = hwctx->context.render;
vdctx->device = VDP_INVALID_HANDLE;
return 0;
}
vdctx->device = hwctx->device;
vdctx->get_proc_address = hwctx->get_proc_address;
if (level < 0)
return AVERROR(ENOTSUP);
status = vdctx->get_proc_address(vdctx->device,
VDP_FUNC_ID_VIDEO_SURFACE_QUERY_CAPABILITIES,
&func);
if (status != VDP_STATUS_OK)
return vdpau_error(status);
else
surface_query_caps = func;
status = surface_query_caps(vdctx->device, VDP_CHROMA_TYPE_420, &supported,
&max_width, &max_height);
if (status != VDP_STATUS_OK)
return vdpau_error(status);
if (supported != VDP_TRUE ||
max_width < width || max_height < height)
return AVERROR(ENOTSUP);
status = vdctx->get_proc_address(vdctx->device,
VDP_FUNC_ID_DECODER_QUERY_CAPABILITIES,
&func);
if (status != VDP_STATUS_OK)
return vdpau_error(status);
else
decoder_query_caps = func;
status = decoder_query_caps(vdctx->device, profile, &supported, &max_level,
&max_mb, &max_width, &max_height);
if (status != VDP_STATUS_OK)
return vdpau_error(status);
if (supported != VDP_TRUE || max_level < level ||
max_width < width || max_height < height)
return AVERROR(ENOTSUP);
status = vdctx->get_proc_address(vdctx->device, VDP_FUNC_ID_DECODER_CREATE,
&func);
if (status != VDP_STATUS_OK)
return vdpau_error(status);
else
create = func;
status = vdctx->get_proc_address(vdctx->device, VDP_FUNC_ID_DECODER_RENDER,
&func);
if (status != VDP_STATUS_OK)
return vdpau_error(status);
else
vdctx->render = func;
status = create(vdctx->device, profile, width, height, avctx->refs,
&vdctx->decoder);
if (status == VDP_STATUS_OK) {
vdctx->width = avctx->coded_width;
vdctx->height = avctx->coded_height;
}
return vdpau_error(status);
}
| {
"code": [],
"line_no": []
} | FUNC_0(VAR_0, VAR_1, VAR_2, VAR_3)
int ff_vdpau_common_init(AVCodecContext *avctx, VdpDecoderProfile profile,
int level)
{
VDPAUHWContext *hwctx = avctx->hwaccel_context;
VDPAUContext *vdctx = avctx->internal->hwaccel_priv_data;
VdpVideoSurfaceQueryCapabilities *surface_query_caps;
VdpDecoderQueryCapabilities *decoder_query_caps;
VdpDecoderCreate *create;
void *VAR_4;
VdpStatus status;
VdpBool supported;
uint32_t max_level, max_mb, max_width, max_height;
uint32_t width = (avctx->coded_width + 1) & ~1;
uint32_t height = (avctx->coded_height + 3) & ~3;
vdctx->width = UINT32_MAX;
vdctx->height = UINT32_MAX;
hwctx->reset = 0;
if (!hwctx) {
vdctx->device = VDP_INVALID_HANDLE;
av_log(avctx, AV_LOG_WARNING, "hwaccel_context has not been setup by the user application, cannot initialize\n");
return 0;
}
if (hwctx->context.decoder != VDP_INVALID_HANDLE) {
vdctx->decoder = hwctx->context.decoder;
vdctx->render = hwctx->context.render;
vdctx->device = VDP_INVALID_HANDLE;
return 0;
}
vdctx->device = hwctx->device;
vdctx->get_proc_address = hwctx->get_proc_address;
if (level < 0)
return AVERROR(ENOTSUP);
status = vdctx->get_proc_address(vdctx->device,
VDP_FUNC_ID_VIDEO_SURFACE_QUERY_CAPABILITIES,
&VAR_4);
if (status != VDP_STATUS_OK)
return vdpau_error(status);
else
surface_query_caps = VAR_4;
status = surface_query_caps(vdctx->device, VDP_CHROMA_TYPE_420, &supported,
&max_width, &max_height);
if (status != VDP_STATUS_OK)
return vdpau_error(status);
if (supported != VDP_TRUE ||
max_width < width || max_height < height)
return AVERROR(ENOTSUP);
status = vdctx->get_proc_address(vdctx->device,
VDP_FUNC_ID_DECODER_QUERY_CAPABILITIES,
&VAR_4);
if (status != VDP_STATUS_OK)
return vdpau_error(status);
else
decoder_query_caps = VAR_4;
status = decoder_query_caps(vdctx->device, profile, &supported, &max_level,
&max_mb, &max_width, &max_height);
if (status != VDP_STATUS_OK)
return vdpau_error(status);
if (supported != VDP_TRUE || max_level < level ||
max_width < width || max_height < height)
return AVERROR(ENOTSUP);
status = vdctx->get_proc_address(vdctx->device, VDP_FUNC_ID_DECODER_CREATE,
&VAR_4);
if (status != VDP_STATUS_OK)
return vdpau_error(status);
else
create = VAR_4;
status = vdctx->get_proc_address(vdctx->device, VDP_FUNC_ID_DECODER_RENDER,
&VAR_4);
if (status != VDP_STATUS_OK)
return vdpau_error(status);
else
vdctx->render = VAR_4;
status = create(vdctx->device, profile, width, height, avctx->refs,
&vdctx->decoder);
if (status == VDP_STATUS_OK) {
vdctx->width = avctx->coded_width;
vdctx->height = avctx->coded_height;
}
return vdpau_error(status);
}
| [
"FUNC_0(VAR_0, VAR_1, VAR_2, VAR_3)\nint ff_vdpau_common_init(AVCodecContext *avctx, VdpDecoderProfile profile,\nint level)\n{",
"VDPAUHWContext *hwctx = avctx->hwaccel_context;",
"VDPAUContext *vdctx = avctx->internal->hwaccel_priv_data;",
"VdpVideoSurfaceQueryCapabilities *surface_query_caps;",
"VdpDecoderQueryCapabilities *decoder_query_caps;",
"VdpDecoderCreate *create;",
"void *VAR_4;",
"VdpStatus status;",
"VdpBool supported;",
"uint32_t max_level, max_mb, max_width, max_height;",
"uint32_t width = (avctx->coded_width + 1) & ~1;",
"uint32_t height = (avctx->coded_height + 3) & ~3;",
"vdctx->width = UINT32_MAX;",
"vdctx->height = UINT32_MAX;",
"hwctx->reset = 0;",
"if (!hwctx) {",
"vdctx->device = VDP_INVALID_HANDLE;",
"av_log(avctx, AV_LOG_WARNING, \"hwaccel_context has not been setup by the user application, cannot initialize\\n\");",
"return 0;",
"}",
"if (hwctx->context.decoder != VDP_INVALID_HANDLE) {",
"vdctx->decoder = hwctx->context.decoder;",
"vdctx->render = hwctx->context.render;",
"vdctx->device = VDP_INVALID_HANDLE;",
"return 0;",
"}",
"vdctx->device = hwctx->device;",
"vdctx->get_proc_address = hwctx->get_proc_address;",
"if (level < 0)\nreturn AVERROR(ENOTSUP);",
"status = vdctx->get_proc_address(vdctx->device,\nVDP_FUNC_ID_VIDEO_SURFACE_QUERY_CAPABILITIES,\n&VAR_4);",
"if (status != VDP_STATUS_OK)\nreturn vdpau_error(status);",
"else\nsurface_query_caps = VAR_4;",
"status = surface_query_caps(vdctx->device, VDP_CHROMA_TYPE_420, &supported,\n&max_width, &max_height);",
"if (status != VDP_STATUS_OK)\nreturn vdpau_error(status);",
"if (supported != VDP_TRUE ||\nmax_width < width || max_height < height)\nreturn AVERROR(ENOTSUP);",
"status = vdctx->get_proc_address(vdctx->device,\nVDP_FUNC_ID_DECODER_QUERY_CAPABILITIES,\n&VAR_4);",
"if (status != VDP_STATUS_OK)\nreturn vdpau_error(status);",
"else\ndecoder_query_caps = VAR_4;",
"status = decoder_query_caps(vdctx->device, profile, &supported, &max_level,\n&max_mb, &max_width, &max_height);",
"if (status != VDP_STATUS_OK)\nreturn vdpau_error(status);",
"if (supported != VDP_TRUE || max_level < level ||\nmax_width < width || max_height < height)\nreturn AVERROR(ENOTSUP);",
"status = vdctx->get_proc_address(vdctx->device, VDP_FUNC_ID_DECODER_CREATE,\n&VAR_4);",
"if (status != VDP_STATUS_OK)\nreturn vdpau_error(status);",
"else\ncreate = VAR_4;",
"status = vdctx->get_proc_address(vdctx->device, VDP_FUNC_ID_DECODER_RENDER,\n&VAR_4);",
"if (status != VDP_STATUS_OK)\nreturn vdpau_error(status);",
"else\nvdctx->render = VAR_4;",
"status = create(vdctx->device, profile, width, height, avctx->refs,\n&vdctx->decoder);",
"if (status == VDP_STATUS_OK) {",
"vdctx->width = avctx->coded_width;",
"vdctx->height = avctx->coded_height;",
"}",
"return vdpau_error(status);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
77,
79
],
[
83,
85,
87
],
[
89,
91
],
[
93,
95
],
[
99,
101
],
[
103,
105
],
[
107,
109,
111
],
[
115,
117,
119
],
[
121,
123
],
[
125,
127
],
[
131,
133
],
[
135,
137
],
[
141,
143,
145
],
[
149,
151
],
[
153,
155
],
[
157,
159
],
[
163,
165
],
[
167,
169
],
[
171,
173
],
[
177,
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
191
],
[
193
]
] |
21,169 | static qemu_irq *vpb_sic_init(uint32_t base, qemu_irq *parent, int irq)
{
vpb_sic_state *s;
qemu_irq *qi;
int iomemtype;
s = (vpb_sic_state *)qemu_mallocz(sizeof(vpb_sic_state));
if (!s)
return NULL;
qi = qemu_allocate_irqs(vpb_sic_set_irq, s, 32);
s->base = base;
s->parent = parent;
s->irq = irq;
iomemtype = cpu_register_io_memory(0, vpb_sic_readfn,
vpb_sic_writefn, s);
cpu_register_physical_memory(base, 0x00000fff, iomemtype);
/* ??? Save/restore. */
return qi;
}
| true | qemu | 187337f8b0ec0813dd3876d1efe37d415fb81c2e | static qemu_irq *vpb_sic_init(uint32_t base, qemu_irq *parent, int irq)
{
vpb_sic_state *s;
qemu_irq *qi;
int iomemtype;
s = (vpb_sic_state *)qemu_mallocz(sizeof(vpb_sic_state));
if (!s)
return NULL;
qi = qemu_allocate_irqs(vpb_sic_set_irq, s, 32);
s->base = base;
s->parent = parent;
s->irq = irq;
iomemtype = cpu_register_io_memory(0, vpb_sic_readfn,
vpb_sic_writefn, s);
cpu_register_physical_memory(base, 0x00000fff, iomemtype);
return qi;
}
| {
"code": [
" cpu_register_physical_memory(base, 0x00000fff, iomemtype);",
" cpu_register_physical_memory(base, 0x00000fff, iomemtype);",
" cpu_register_physical_memory(base, 0x00000fff, iomemtype);",
" cpu_register_physical_memory(base, 0x00000fff, iomemtype);",
" cpu_register_physical_memory(base, 0x00000fff, iomemtype);",
" cpu_register_physical_memory(base, 0x00000fff, iomemtype);",
" cpu_register_physical_memory(base, 0x00000fff, iomemtype);",
" cpu_register_physical_memory(base, 0x00000fff, iomemtype);",
" cpu_register_physical_memory(base, 0x00000fff, iomemtype);",
" cpu_register_physical_memory(base, 0x00000fff, iomemtype);",
" cpu_register_physical_memory(base, 0x00000fff, iomemtype);",
" cpu_register_physical_memory(base, 0x00000fff, iomemtype);"
],
"line_no": [
31,
31,
31,
31,
31,
31,
31,
31,
31,
31,
31,
31
]
} | static qemu_irq *FUNC_0(uint32_t base, qemu_irq *parent, int irq)
{
vpb_sic_state *s;
qemu_irq *qi;
int VAR_0;
s = (vpb_sic_state *)qemu_mallocz(sizeof(vpb_sic_state));
if (!s)
return NULL;
qi = qemu_allocate_irqs(vpb_sic_set_irq, s, 32);
s->base = base;
s->parent = parent;
s->irq = irq;
VAR_0 = cpu_register_io_memory(0, vpb_sic_readfn,
vpb_sic_writefn, s);
cpu_register_physical_memory(base, 0x00000fff, VAR_0);
return qi;
}
| [
"static qemu_irq *FUNC_0(uint32_t base, qemu_irq *parent, int irq)\n{",
"vpb_sic_state *s;",
"qemu_irq *qi;",
"int VAR_0;",
"s = (vpb_sic_state *)qemu_mallocz(sizeof(vpb_sic_state));",
"if (!s)\nreturn NULL;",
"qi = qemu_allocate_irqs(vpb_sic_set_irq, s, 32);",
"s->base = base;",
"s->parent = parent;",
"s->irq = irq;",
"VAR_0 = cpu_register_io_memory(0, vpb_sic_readfn,\nvpb_sic_writefn, s);",
"cpu_register_physical_memory(base, 0x00000fff, VAR_0);",
"return qi;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15,
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27,
29
],
[
31
],
[
35
],
[
37
]
] |
21,170 | static bool use_exit_tb(DisasContext *s)
{
return (s->singlestep_enabled ||
(s->tb->cflags & CF_LAST_IO) ||
(s->tb->flags & FLAG_MASK_PER));
}
| true | qemu | c5a49c63fa26e8825ad101dfe86339ae4c216539 | static bool use_exit_tb(DisasContext *s)
{
return (s->singlestep_enabled ||
(s->tb->cflags & CF_LAST_IO) ||
(s->tb->flags & FLAG_MASK_PER));
}
| {
"code": [
" (s->tb->cflags & CF_LAST_IO) ||"
],
"line_no": [
7
]
} | static bool FUNC_0(DisasContext *s)
{
return (s->singlestep_enabled ||
(s->tb->cflags & CF_LAST_IO) ||
(s->tb->flags & FLAG_MASK_PER));
}
| [
"static bool FUNC_0(DisasContext *s)\n{",
"return (s->singlestep_enabled ||\n(s->tb->cflags & CF_LAST_IO) ||\n(s->tb->flags & FLAG_MASK_PER));",
"}"
] | [
0,
1,
0
] | [
[
1,
3
],
[
5,
7,
9
],
[
11
]
] |
21,172 | static int opt_show_format_entry(void *optctx, const char *opt, const char *arg)
{
char *buf = av_asprintf("format=%s", arg);
int ret;
av_log(NULL, AV_LOG_WARNING,
"Option '%s' is deprecated, use '-show_entries format=%s' instead\n",
opt, arg);
ret = opt_show_entries(optctx, opt, buf);
av_free(buf);
return ret;
} | true | FFmpeg | a75d22445ecb7adbe3fb8f705cb4fd9aa0d6b5ee | static int opt_show_format_entry(void *optctx, const char *opt, const char *arg)
{
char *buf = av_asprintf("format=%s", arg);
int ret;
av_log(NULL, AV_LOG_WARNING,
"Option '%s' is deprecated, use '-show_entries format=%s' instead\n",
opt, arg);
ret = opt_show_entries(optctx, opt, buf);
av_free(buf);
return ret;
} | {
"code": [],
"line_no": []
} | static int FUNC_0(void *VAR_0, const char *VAR_1, const char *VAR_2)
{
char *VAR_3 = av_asprintf("format=%s", VAR_2);
int VAR_4;
av_log(NULL, AV_LOG_WARNING,
"Option '%s' is deprecated, use '-show_entries format=%s' instead\n",
VAR_1, VAR_2);
VAR_4 = opt_show_entries(VAR_0, VAR_1, VAR_3);
av_free(VAR_3);
return VAR_4;
} | [
"static int FUNC_0(void *VAR_0, const char *VAR_1, const char *VAR_2)\n{",
"char *VAR_3 = av_asprintf(\"format=%s\", VAR_2);",
"int VAR_4;",
"av_log(NULL, AV_LOG_WARNING,\n\"Option '%s' is deprecated, use '-show_entries format=%s' instead\\n\",\nVAR_1, VAR_2);",
"VAR_4 = opt_show_entries(VAR_0, VAR_1, VAR_3);",
"av_free(VAR_3);",
"return VAR_4;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
2
],
[
3
],
[
4
],
[
5,
6,
7
],
[
8
],
[
9
],
[
10
],
[
11
]
] |
21,174 | int ff_set_systematic_pal(uint32_t pal[256], enum PixelFormat pix_fmt){
int i;
for(i=0; i<256; i++){
int r,g,b;
switch(pix_fmt) {
case PIX_FMT_RGB8:
r= (i>>5 )*36;
g= ((i>>2)&7)*36;
b= (i&3 )*85;
break;
case PIX_FMT_BGR8:
b= (i>>6 )*85;
g= ((i>>3)&7)*36;
r= (i&7 )*36;
break;
case PIX_FMT_RGB4_BYTE:
r= (i>>3 )*255;
g= ((i>>1)&3)*85;
b= (i&1 )*255;
break;
case PIX_FMT_BGR4_BYTE:
b= (i>>3 )*255;
g= ((i>>1)&3)*85;
r= (i&1 )*255;
break;
case PIX_FMT_GRAY8:
r=b=g= i;
break;
}
pal[i] = b + (g<<8) + (r<<16);
}
return 0;
} | true | FFmpeg | c7efffcb443fe5a2134833f62987b3a999e0701e | int ff_set_systematic_pal(uint32_t pal[256], enum PixelFormat pix_fmt){
int i;
for(i=0; i<256; i++){
int r,g,b;
switch(pix_fmt) {
case PIX_FMT_RGB8:
r= (i>>5 )*36;
g= ((i>>2)&7)*36;
b= (i&3 )*85;
break;
case PIX_FMT_BGR8:
b= (i>>6 )*85;
g= ((i>>3)&7)*36;
r= (i&7 )*36;
break;
case PIX_FMT_RGB4_BYTE:
r= (i>>3 )*255;
g= ((i>>1)&3)*85;
b= (i&1 )*255;
break;
case PIX_FMT_BGR4_BYTE:
b= (i>>3 )*255;
g= ((i>>1)&3)*85;
r= (i&1 )*255;
break;
case PIX_FMT_GRAY8:
r=b=g= i;
break;
}
pal[i] = b + (g<<8) + (r<<16);
}
return 0;
} | {
"code": [],
"line_no": []
} | int FUNC_0(uint32_t VAR_0[256], enum PixelFormat VAR_1){
int VAR_2;
for(VAR_2=0; VAR_2<256; VAR_2++){
int VAR_3,VAR_4,VAR_5;
switch(VAR_1) {
case PIX_FMT_RGB8:
VAR_3= (VAR_2>>5 )*36;
VAR_4= ((VAR_2>>2)&7)*36;
VAR_5= (VAR_2&3 )*85;
break;
case PIX_FMT_BGR8:
VAR_5= (VAR_2>>6 )*85;
VAR_4= ((VAR_2>>3)&7)*36;
VAR_3= (VAR_2&7 )*36;
break;
case PIX_FMT_RGB4_BYTE:
VAR_3= (VAR_2>>3 )*255;
VAR_4= ((VAR_2>>1)&3)*85;
VAR_5= (VAR_2&1 )*255;
break;
case PIX_FMT_BGR4_BYTE:
VAR_5= (VAR_2>>3 )*255;
VAR_4= ((VAR_2>>1)&3)*85;
VAR_3= (VAR_2&1 )*255;
break;
case PIX_FMT_GRAY8:
VAR_3=VAR_5=VAR_4= VAR_2;
break;
}
VAR_0[VAR_2] = VAR_5 + (VAR_4<<8) + (VAR_3<<16);
}
return 0;
} | [
"int FUNC_0(uint32_t VAR_0[256], enum PixelFormat VAR_1){",
"int VAR_2;",
"for(VAR_2=0; VAR_2<256; VAR_2++){",
"int VAR_3,VAR_4,VAR_5;",
"switch(VAR_1) {",
"case PIX_FMT_RGB8:\nVAR_3= (VAR_2>>5 )*36;",
"VAR_4= ((VAR_2>>2)&7)*36;",
"VAR_5= (VAR_2&3 )*85;",
"break;",
"case PIX_FMT_BGR8:\nVAR_5= (VAR_2>>6 )*85;",
"VAR_4= ((VAR_2>>3)&7)*36;",
"VAR_3= (VAR_2&7 )*36;",
"break;",
"case PIX_FMT_RGB4_BYTE:\nVAR_3= (VAR_2>>3 )*255;",
"VAR_4= ((VAR_2>>1)&3)*85;",
"VAR_5= (VAR_2&1 )*255;",
"break;",
"case PIX_FMT_BGR4_BYTE:\nVAR_5= (VAR_2>>3 )*255;",
"VAR_4= ((VAR_2>>1)&3)*85;",
"VAR_3= (VAR_2&1 )*255;",
"break;",
"case PIX_FMT_GRAY8:\nVAR_3=VAR_5=VAR_4= VAR_2;",
"break;",
"}",
"VAR_0[VAR_2] = VAR_5 + (VAR_4<<8) + (VAR_3<<16);",
"}",
"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
] | [
[
1
],
[
3
],
[
7
],
[
9
],
[
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
],
[
67
],
[
71
],
[
73
]
] |
21,175 | int qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset,
int *num, uint64_t *cluster_offset)
{
BDRVQcowState *s = bs->opaque;
unsigned int l2_index;
uint64_t l1_index, l2_offset, *l2_table;
int l1_bits, c;
unsigned int index_in_cluster, nb_clusters;
uint64_t nb_available, nb_needed;
int ret;
index_in_cluster = (offset >> 9) & (s->cluster_sectors - 1);
nb_needed = *num + index_in_cluster;
l1_bits = s->l2_bits + s->cluster_bits;
/* compute how many bytes there are between the offset and
* the end of the l1 entry
*/
nb_available = (1ULL << l1_bits) - (offset & ((1ULL << l1_bits) - 1));
/* compute the number of available sectors */
nb_available = (nb_available >> 9) + index_in_cluster;
if (nb_needed > nb_available) {
nb_needed = nb_available;
}
*cluster_offset = 0;
/* seek the the l2 offset in the l1 table */
l1_index = offset >> l1_bits;
if (l1_index >= s->l1_size) {
ret = QCOW2_CLUSTER_UNALLOCATED;
goto out;
}
l2_offset = s->l1_table[l1_index] & L1E_OFFSET_MASK;
if (!l2_offset) {
ret = QCOW2_CLUSTER_UNALLOCATED;
goto out;
}
/* load the l2 table in memory */
ret = l2_load(bs, l2_offset, &l2_table);
if (ret < 0) {
return ret;
}
/* find the cluster offset for the given disk offset */
l2_index = (offset >> s->cluster_bits) & (s->l2_size - 1);
*cluster_offset = be64_to_cpu(l2_table[l2_index]);
nb_clusters = size_to_clusters(s, nb_needed << 9);
ret = qcow2_get_cluster_type(*cluster_offset);
switch (ret) {
case QCOW2_CLUSTER_COMPRESSED:
/* Compressed clusters can only be processed one by one */
c = 1;
*cluster_offset &= L2E_COMPRESSED_OFFSET_SIZE_MASK;
break;
case QCOW2_CLUSTER_ZERO:
if (s->qcow_version < 3) {
return -EIO;
}
c = count_contiguous_clusters(nb_clusters, s->cluster_size,
&l2_table[l2_index], QCOW_OFLAG_ZERO);
*cluster_offset = 0;
break;
case QCOW2_CLUSTER_UNALLOCATED:
/* how many empty clusters ? */
c = count_contiguous_free_clusters(nb_clusters, &l2_table[l2_index]);
*cluster_offset = 0;
break;
case QCOW2_CLUSTER_NORMAL:
/* how many allocated clusters ? */
c = count_contiguous_clusters(nb_clusters, s->cluster_size,
&l2_table[l2_index], QCOW_OFLAG_ZERO);
*cluster_offset &= L2E_OFFSET_MASK;
break;
default:
abort();
}
nb_available = (c * s->cluster_sectors);
out:
if (nb_available > nb_needed)
nb_available = nb_needed;
*num = nb_available - index_in_cluster;
return ret;
} | true | qemu | 8885eadedd0ea8b57c1baa367ee2c2d616700bd9 | int qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset,
int *num, uint64_t *cluster_offset)
{
BDRVQcowState *s = bs->opaque;
unsigned int l2_index;
uint64_t l1_index, l2_offset, *l2_table;
int l1_bits, c;
unsigned int index_in_cluster, nb_clusters;
uint64_t nb_available, nb_needed;
int ret;
index_in_cluster = (offset >> 9) & (s->cluster_sectors - 1);
nb_needed = *num + index_in_cluster;
l1_bits = s->l2_bits + s->cluster_bits;
nb_available = (1ULL << l1_bits) - (offset & ((1ULL << l1_bits) - 1));
nb_available = (nb_available >> 9) + index_in_cluster;
if (nb_needed > nb_available) {
nb_needed = nb_available;
}
*cluster_offset = 0;
l1_index = offset >> l1_bits;
if (l1_index >= s->l1_size) {
ret = QCOW2_CLUSTER_UNALLOCATED;
goto out;
}
l2_offset = s->l1_table[l1_index] & L1E_OFFSET_MASK;
if (!l2_offset) {
ret = QCOW2_CLUSTER_UNALLOCATED;
goto out;
}
ret = l2_load(bs, l2_offset, &l2_table);
if (ret < 0) {
return ret;
}
l2_index = (offset >> s->cluster_bits) & (s->l2_size - 1);
*cluster_offset = be64_to_cpu(l2_table[l2_index]);
nb_clusters = size_to_clusters(s, nb_needed << 9);
ret = qcow2_get_cluster_type(*cluster_offset);
switch (ret) {
case QCOW2_CLUSTER_COMPRESSED:
c = 1;
*cluster_offset &= L2E_COMPRESSED_OFFSET_SIZE_MASK;
break;
case QCOW2_CLUSTER_ZERO:
if (s->qcow_version < 3) {
return -EIO;
}
c = count_contiguous_clusters(nb_clusters, s->cluster_size,
&l2_table[l2_index], QCOW_OFLAG_ZERO);
*cluster_offset = 0;
break;
case QCOW2_CLUSTER_UNALLOCATED:
c = count_contiguous_free_clusters(nb_clusters, &l2_table[l2_index]);
*cluster_offset = 0;
break;
case QCOW2_CLUSTER_NORMAL:
c = count_contiguous_clusters(nb_clusters, s->cluster_size,
&l2_table[l2_index], QCOW_OFLAG_ZERO);
*cluster_offset &= L2E_OFFSET_MASK;
break;
default:
abort();
}
nb_available = (c * s->cluster_sectors);
out:
if (nb_available > nb_needed)
nb_available = nb_needed;
*num = nb_available - index_in_cluster;
return ret;
} | {
"code": [],
"line_no": []
} | int FUNC_0(BlockDriverState *VAR_0, uint64_t VAR_1,
int *VAR_2, uint64_t *VAR_3)
{
BDRVQcowState *s = VAR_0->opaque;
unsigned int VAR_4;
uint64_t l1_index, l2_offset, *l2_table;
int VAR_5, VAR_6;
unsigned int VAR_7, VAR_8;
uint64_t nb_available, nb_needed;
int VAR_9;
VAR_7 = (VAR_1 >> 9) & (s->cluster_sectors - 1);
nb_needed = *VAR_2 + VAR_7;
VAR_5 = s->l2_bits + s->cluster_bits;
nb_available = (1ULL << VAR_5) - (VAR_1 & ((1ULL << VAR_5) - 1));
nb_available = (nb_available >> 9) + VAR_7;
if (nb_needed > nb_available) {
nb_needed = nb_available;
}
*VAR_3 = 0;
l1_index = VAR_1 >> VAR_5;
if (l1_index >= s->l1_size) {
VAR_9 = QCOW2_CLUSTER_UNALLOCATED;
goto out;
}
l2_offset = s->l1_table[l1_index] & L1E_OFFSET_MASK;
if (!l2_offset) {
VAR_9 = QCOW2_CLUSTER_UNALLOCATED;
goto out;
}
VAR_9 = l2_load(VAR_0, l2_offset, &l2_table);
if (VAR_9 < 0) {
return VAR_9;
}
VAR_4 = (VAR_1 >> s->cluster_bits) & (s->l2_size - 1);
*VAR_3 = be64_to_cpu(l2_table[VAR_4]);
VAR_8 = size_to_clusters(s, nb_needed << 9);
VAR_9 = qcow2_get_cluster_type(*VAR_3);
switch (VAR_9) {
case QCOW2_CLUSTER_COMPRESSED:
VAR_6 = 1;
*VAR_3 &= L2E_COMPRESSED_OFFSET_SIZE_MASK;
break;
case QCOW2_CLUSTER_ZERO:
if (s->qcow_version < 3) {
return -EIO;
}
VAR_6 = count_contiguous_clusters(VAR_8, s->cluster_size,
&l2_table[VAR_4], QCOW_OFLAG_ZERO);
*VAR_3 = 0;
break;
case QCOW2_CLUSTER_UNALLOCATED:
VAR_6 = count_contiguous_free_clusters(VAR_8, &l2_table[VAR_4]);
*VAR_3 = 0;
break;
case QCOW2_CLUSTER_NORMAL:
VAR_6 = count_contiguous_clusters(VAR_8, s->cluster_size,
&l2_table[VAR_4], QCOW_OFLAG_ZERO);
*VAR_3 &= L2E_OFFSET_MASK;
break;
default:
abort();
}
nb_available = (VAR_6 * s->cluster_sectors);
out:
if (nb_available > nb_needed)
nb_available = nb_needed;
*VAR_2 = nb_available - VAR_7;
return VAR_9;
} | [
"int FUNC_0(BlockDriverState *VAR_0, uint64_t VAR_1,\nint *VAR_2, uint64_t *VAR_3)\n{",
"BDRVQcowState *s = VAR_0->opaque;",
"unsigned int VAR_4;",
"uint64_t l1_index, l2_offset, *l2_table;",
"int VAR_5, VAR_6;",
"unsigned int VAR_7, VAR_8;",
"uint64_t nb_available, nb_needed;",
"int VAR_9;",
"VAR_7 = (VAR_1 >> 9) & (s->cluster_sectors - 1);",
"nb_needed = *VAR_2 + VAR_7;",
"VAR_5 = s->l2_bits + s->cluster_bits;",
"nb_available = (1ULL << VAR_5) - (VAR_1 & ((1ULL << VAR_5) - 1));",
"nb_available = (nb_available >> 9) + VAR_7;",
"if (nb_needed > nb_available) {",
"nb_needed = nb_available;",
"}",
"*VAR_3 = 0;",
"l1_index = VAR_1 >> VAR_5;",
"if (l1_index >= s->l1_size) {",
"VAR_9 = QCOW2_CLUSTER_UNALLOCATED;",
"goto out;",
"}",
"l2_offset = s->l1_table[l1_index] & L1E_OFFSET_MASK;",
"if (!l2_offset) {",
"VAR_9 = QCOW2_CLUSTER_UNALLOCATED;",
"goto out;",
"}",
"VAR_9 = l2_load(VAR_0, l2_offset, &l2_table);",
"if (VAR_9 < 0) {",
"return VAR_9;",
"}",
"VAR_4 = (VAR_1 >> s->cluster_bits) & (s->l2_size - 1);",
"*VAR_3 = be64_to_cpu(l2_table[VAR_4]);",
"VAR_8 = size_to_clusters(s, nb_needed << 9);",
"VAR_9 = qcow2_get_cluster_type(*VAR_3);",
"switch (VAR_9) {",
"case QCOW2_CLUSTER_COMPRESSED:\nVAR_6 = 1;",
"*VAR_3 &= L2E_COMPRESSED_OFFSET_SIZE_MASK;",
"break;",
"case QCOW2_CLUSTER_ZERO:\nif (s->qcow_version < 3) {",
"return -EIO;",
"}",
"VAR_6 = count_contiguous_clusters(VAR_8, s->cluster_size,\n&l2_table[VAR_4], QCOW_OFLAG_ZERO);",
"*VAR_3 = 0;",
"break;",
"case QCOW2_CLUSTER_UNALLOCATED:\nVAR_6 = count_contiguous_free_clusters(VAR_8, &l2_table[VAR_4]);",
"*VAR_3 = 0;",
"break;",
"case QCOW2_CLUSTER_NORMAL:\nVAR_6 = count_contiguous_clusters(VAR_8, s->cluster_size,\n&l2_table[VAR_4], QCOW_OFLAG_ZERO);",
"*VAR_3 &= L2E_OFFSET_MASK;",
"break;",
"default:\nabort();",
"}",
"nb_available = (VAR_6 * s->cluster_sectors);",
"out:\nif (nb_available > nb_needed)\nnb_available = nb_needed;",
"*VAR_2 = nb_available - VAR_7;",
"return VAR_9;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
23
],
[
25
],
[
29
],
[
41
],
[
49
],
[
53
],
[
55
],
[
57
],
[
61
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
97
],
[
99
],
[
101
],
[
103
],
[
111
],
[
113
],
[
115
],
[
119
],
[
121
],
[
123,
127
],
[
129
],
[
131
],
[
133,
135
],
[
138
],
[
140
],
[
142,
144
],
[
146
],
[
148
],
[
150,
154
],
[
156
],
[
158
],
[
160,
164,
166
],
[
168
],
[
170
],
[
172,
174
],
[
176
],
[
183
],
[
187,
189,
191
],
[
195
],
[
199
],
[
201
]
] |
21,177 | static AVFilterContext *create_filter_with_args(const char *filt, void *opaque)
{
AVFilterContext *ret;
char *filter = av_strdup(filt); /* copy - don't mangle the input string */
char *name, *args;
name = filter;
if((args = strchr(filter, '='))) {
/* ensure we at least have a name */
if(args == filter)
goto fail;
*args ++ = 0;
}
av_log(NULL, AV_LOG_INFO, "creating filter \"%s\" with args \"%s\"\n",
name, args ? args : "(none)");
if((ret = avfilter_create_by_name(name, NULL))) {
if(avfilter_init_filter(ret, args, opaque)) {
av_log(NULL, AV_LOG_ERROR, "error initializing filter!\n");
avfilter_destroy(ret);
goto fail;
}
} else av_log(NULL, AV_LOG_ERROR, "error creating filter!\n");
return ret;
fail:
return NULL;
} | true | FFmpeg | 1deec58ba308f66280e388071dbcc223c3728595 | static AVFilterContext *create_filter_with_args(const char *filt, void *opaque)
{
AVFilterContext *ret;
char *filter = av_strdup(filt);
char *name, *args;
name = filter;
if((args = strchr(filter, '='))) {
if(args == filter)
goto fail;
*args ++ = 0;
}
av_log(NULL, AV_LOG_INFO, "creating filter \"%s\" with args \"%s\"\n",
name, args ? args : "(none)");
if((ret = avfilter_create_by_name(name, NULL))) {
if(avfilter_init_filter(ret, args, opaque)) {
av_log(NULL, AV_LOG_ERROR, "error initializing filter!\n");
avfilter_destroy(ret);
goto fail;
}
} else av_log(NULL, AV_LOG_ERROR, "error creating filter!\n");
return ret;
fail:
return NULL;
} | {
"code": [],
"line_no": []
} | static AVFilterContext *FUNC_0(const char *filt, void *opaque)
{
AVFilterContext *ret;
char *VAR_0 = av_strdup(filt);
char *VAR_1, *VAR_2;
VAR_1 = VAR_0;
if((VAR_2 = strchr(VAR_0, '='))) {
if(VAR_2 == VAR_0)
goto fail;
*VAR_2 ++ = 0;
}
av_log(NULL, AV_LOG_INFO, "creating VAR_0 \"%s\" with VAR_2 \"%s\"\n",
VAR_1, VAR_2 ? VAR_2 : "(none)");
if((ret = avfilter_create_by_name(VAR_1, NULL))) {
if(avfilter_init_filter(ret, VAR_2, opaque)) {
av_log(NULL, AV_LOG_ERROR, "error initializing VAR_0!\n");
avfilter_destroy(ret);
goto fail;
}
} else av_log(NULL, AV_LOG_ERROR, "error creating VAR_0!\n");
return ret;
fail:
return NULL;
} | [
"static AVFilterContext *FUNC_0(const char *filt, void *opaque)\n{",
"AVFilterContext *ret;",
"char *VAR_0 = av_strdup(filt);",
"char *VAR_1, *VAR_2;",
"VAR_1 = VAR_0;",
"if((VAR_2 = strchr(VAR_0, '='))) {",
"if(VAR_2 == VAR_0)\ngoto fail;",
"*VAR_2 ++ = 0;",
"}",
"av_log(NULL, AV_LOG_INFO, \"creating VAR_0 \\\"%s\\\" with VAR_2 \\\"%s\\\"\\n\",\nVAR_1, VAR_2 ? VAR_2 : \"(none)\");",
"if((ret = avfilter_create_by_name(VAR_1, NULL))) {",
"if(avfilter_init_filter(ret, VAR_2, opaque)) {",
"av_log(NULL, AV_LOG_ERROR, \"error initializing VAR_0!\\n\");",
"avfilter_destroy(ret);",
"goto fail;",
"}",
"} else av_log(NULL, AV_LOG_ERROR, \"error creating VAR_0!\\n\");",
"return ret;",
"fail:\nreturn NULL;",
"}"
] | [
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
],
[
9,
10
],
[
11
],
[
12
],
[
13,
14
],
[
15
],
[
16
],
[
17
],
[
18
],
[
19
],
[
20
],
[
21
],
[
22
],
[
23,
24
],
[
25
]
] |
21,178 | static int set_string_binary(void *obj, const AVOption *o, const char *val, uint8_t **dst)
{
int *lendst = (int *)(dst + 1);
uint8_t *bin, *ptr;
int len = strlen(val);
av_freep(dst);
*lendst = 0;
if (len & 1)
return AVERROR(EINVAL);
len /= 2;
ptr = bin = av_malloc(len);
while (*val) {
int a = hexchar2int(*val++);
int b = hexchar2int(*val++);
if (a < 0 || b < 0) {
av_free(bin);
return AVERROR(EINVAL);
}
*ptr++ = (a << 4) | b;
}
*dst = bin;
*lendst = len;
return 0;
}
| true | FFmpeg | bb60142f562ef9ca7f34bd69abe059d56ea1cbf1 | static int set_string_binary(void *obj, const AVOption *o, const char *val, uint8_t **dst)
{
int *lendst = (int *)(dst + 1);
uint8_t *bin, *ptr;
int len = strlen(val);
av_freep(dst);
*lendst = 0;
if (len & 1)
return AVERROR(EINVAL);
len /= 2;
ptr = bin = av_malloc(len);
while (*val) {
int a = hexchar2int(*val++);
int b = hexchar2int(*val++);
if (a < 0 || b < 0) {
av_free(bin);
return AVERROR(EINVAL);
}
*ptr++ = (a << 4) | b;
}
*dst = bin;
*lendst = len;
return 0;
}
| {
"code": [
" int len = strlen(val);"
],
"line_no": [
9
]
} | static int FUNC_0(void *VAR_0, const AVOption *VAR_1, const char *VAR_2, uint8_t **VAR_3)
{
int *VAR_4 = (int *)(VAR_3 + 1);
uint8_t *bin, *ptr;
int VAR_5 = strlen(VAR_2);
av_freep(VAR_3);
*VAR_4 = 0;
if (VAR_5 & 1)
return AVERROR(EINVAL);
VAR_5 /= 2;
ptr = bin = av_malloc(VAR_5);
while (*VAR_2) {
int VAR_6 = hexchar2int(*VAR_2++);
int VAR_7 = hexchar2int(*VAR_2++);
if (VAR_6 < 0 || VAR_7 < 0) {
av_free(bin);
return AVERROR(EINVAL);
}
*ptr++ = (VAR_6 << 4) | VAR_7;
}
*VAR_3 = bin;
*VAR_4 = VAR_5;
return 0;
}
| [
"static int FUNC_0(void *VAR_0, const AVOption *VAR_1, const char *VAR_2, uint8_t **VAR_3)\n{",
"int *VAR_4 = (int *)(VAR_3 + 1);",
"uint8_t *bin, *ptr;",
"int VAR_5 = strlen(VAR_2);",
"av_freep(VAR_3);",
"*VAR_4 = 0;",
"if (VAR_5 & 1)\nreturn AVERROR(EINVAL);",
"VAR_5 /= 2;",
"ptr = bin = av_malloc(VAR_5);",
"while (*VAR_2) {",
"int VAR_6 = hexchar2int(*VAR_2++);",
"int VAR_7 = hexchar2int(*VAR_2++);",
"if (VAR_6 < 0 || VAR_7 < 0) {",
"av_free(bin);",
"return AVERROR(EINVAL);",
"}",
"*ptr++ = (VAR_6 << 4) | VAR_7;",
"}",
"*VAR_3 = bin;",
"*VAR_4 = VAR_5;",
"return 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
],
[
9
],
[
13
],
[
15
],
[
19,
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
]
] |
21,179 | static int xen_host_pci_get_resource(XenHostPCIDevice *d)
{
int i, rc, fd;
char path[PATH_MAX];
char buf[XEN_HOST_PCI_RESOURCE_BUFFER_SIZE];
unsigned long long start, end, flags, size;
char *endptr, *s;
uint8_t type;
rc = xen_host_pci_sysfs_path(d, "resource", path, sizeof (path));
if (rc) {
return rc;
}
fd = open(path, O_RDONLY);
if (fd == -1) {
XEN_HOST_PCI_LOG("Error: Can't open %s: %s\n", path, strerror(errno));
return -errno;
}
do {
rc = read(fd, &buf, sizeof (buf) - 1);
if (rc < 0 && errno != EINTR) {
rc = -errno;
goto out;
}
} while (rc < 0);
buf[rc] = 0;
rc = 0;
s = buf;
for (i = 0; i < PCI_NUM_REGIONS; i++) {
type = 0;
start = strtoll(s, &endptr, 16);
if (*endptr != ' ' || s == endptr) {
break;
}
s = endptr + 1;
end = strtoll(s, &endptr, 16);
if (*endptr != ' ' || s == endptr) {
break;
}
s = endptr + 1;
flags = strtoll(s, &endptr, 16);
if (*endptr != '\n' || s == endptr) {
break;
}
s = endptr + 1;
if (start) {
size = end - start + 1;
} else {
size = 0;
}
if (flags & IORESOURCE_IO) {
type |= XEN_HOST_PCI_REGION_TYPE_IO;
}
if (flags & IORESOURCE_MEM) {
type |= XEN_HOST_PCI_REGION_TYPE_MEM;
}
if (flags & IORESOURCE_PREFETCH) {
type |= XEN_HOST_PCI_REGION_TYPE_PREFETCH;
}
if (flags & IORESOURCE_MEM_64) {
type |= XEN_HOST_PCI_REGION_TYPE_MEM_64;
}
if (i < PCI_ROM_SLOT) {
d->io_regions[i].base_addr = start;
d->io_regions[i].size = size;
d->io_regions[i].type = type;
d->io_regions[i].bus_flags = flags & IORESOURCE_BITS;
} else {
d->rom.base_addr = start;
d->rom.size = size;
d->rom.type = type;
d->rom.bus_flags = flags & IORESOURCE_BITS;
}
}
if (i != PCI_NUM_REGIONS) {
/* Invalid format or input to short */
rc = -ENODEV;
}
out:
close(fd);
return rc;
}
| true | qemu | 599d0c45615b7d099d256738a586d0f63bc707e6 | static int xen_host_pci_get_resource(XenHostPCIDevice *d)
{
int i, rc, fd;
char path[PATH_MAX];
char buf[XEN_HOST_PCI_RESOURCE_BUFFER_SIZE];
unsigned long long start, end, flags, size;
char *endptr, *s;
uint8_t type;
rc = xen_host_pci_sysfs_path(d, "resource", path, sizeof (path));
if (rc) {
return rc;
}
fd = open(path, O_RDONLY);
if (fd == -1) {
XEN_HOST_PCI_LOG("Error: Can't open %s: %s\n", path, strerror(errno));
return -errno;
}
do {
rc = read(fd, &buf, sizeof (buf) - 1);
if (rc < 0 && errno != EINTR) {
rc = -errno;
goto out;
}
} while (rc < 0);
buf[rc] = 0;
rc = 0;
s = buf;
for (i = 0; i < PCI_NUM_REGIONS; i++) {
type = 0;
start = strtoll(s, &endptr, 16);
if (*endptr != ' ' || s == endptr) {
break;
}
s = endptr + 1;
end = strtoll(s, &endptr, 16);
if (*endptr != ' ' || s == endptr) {
break;
}
s = endptr + 1;
flags = strtoll(s, &endptr, 16);
if (*endptr != '\n' || s == endptr) {
break;
}
s = endptr + 1;
if (start) {
size = end - start + 1;
} else {
size = 0;
}
if (flags & IORESOURCE_IO) {
type |= XEN_HOST_PCI_REGION_TYPE_IO;
}
if (flags & IORESOURCE_MEM) {
type |= XEN_HOST_PCI_REGION_TYPE_MEM;
}
if (flags & IORESOURCE_PREFETCH) {
type |= XEN_HOST_PCI_REGION_TYPE_PREFETCH;
}
if (flags & IORESOURCE_MEM_64) {
type |= XEN_HOST_PCI_REGION_TYPE_MEM_64;
}
if (i < PCI_ROM_SLOT) {
d->io_regions[i].base_addr = start;
d->io_regions[i].size = size;
d->io_regions[i].type = type;
d->io_regions[i].bus_flags = flags & IORESOURCE_BITS;
} else {
d->rom.base_addr = start;
d->rom.size = size;
d->rom.type = type;
d->rom.bus_flags = flags & IORESOURCE_BITS;
}
}
if (i != PCI_NUM_REGIONS) {
rc = -ENODEV;
}
out:
close(fd);
return rc;
}
| {
"code": [
" rc = xen_host_pci_sysfs_path(d, \"resource\", path, sizeof (path));",
" if (rc) {",
" return rc;",
" if (rc) {",
" return rc;",
" if (rc) {",
" return rc;"
],
"line_no": [
19,
21,
23,
21,
23,
21,
23
]
} | static int FUNC_0(XenHostPCIDevice *VAR_0)
{
int VAR_1, VAR_2, VAR_3;
char VAR_4[PATH_MAX];
char VAR_5[XEN_HOST_PCI_RESOURCE_BUFFER_SIZE];
unsigned long long VAR_6, VAR_7, VAR_8, VAR_9;
char *VAR_10, *VAR_11;
uint8_t type;
VAR_2 = xen_host_pci_sysfs_path(VAR_0, "resource", VAR_4, sizeof (VAR_4));
if (VAR_2) {
return VAR_2;
}
VAR_3 = open(VAR_4, O_RDONLY);
if (VAR_3 == -1) {
XEN_HOST_PCI_LOG("Error: Can't open %VAR_11: %VAR_11\n", VAR_4, strerror(errno));
return -errno;
}
do {
VAR_2 = read(VAR_3, &VAR_5, sizeof (VAR_5) - 1);
if (VAR_2 < 0 && errno != EINTR) {
VAR_2 = -errno;
goto out;
}
} while (VAR_2 < 0);
VAR_5[VAR_2] = 0;
VAR_2 = 0;
VAR_11 = VAR_5;
for (VAR_1 = 0; VAR_1 < PCI_NUM_REGIONS; VAR_1++) {
type = 0;
VAR_6 = strtoll(VAR_11, &VAR_10, 16);
if (*VAR_10 != ' ' || VAR_11 == VAR_10) {
break;
}
VAR_11 = VAR_10 + 1;
VAR_7 = strtoll(VAR_11, &VAR_10, 16);
if (*VAR_10 != ' ' || VAR_11 == VAR_10) {
break;
}
VAR_11 = VAR_10 + 1;
VAR_8 = strtoll(VAR_11, &VAR_10, 16);
if (*VAR_10 != '\n' || VAR_11 == VAR_10) {
break;
}
VAR_11 = VAR_10 + 1;
if (VAR_6) {
VAR_9 = VAR_7 - VAR_6 + 1;
} else {
VAR_9 = 0;
}
if (VAR_8 & IORESOURCE_IO) {
type |= XEN_HOST_PCI_REGION_TYPE_IO;
}
if (VAR_8 & IORESOURCE_MEM) {
type |= XEN_HOST_PCI_REGION_TYPE_MEM;
}
if (VAR_8 & IORESOURCE_PREFETCH) {
type |= XEN_HOST_PCI_REGION_TYPE_PREFETCH;
}
if (VAR_8 & IORESOURCE_MEM_64) {
type |= XEN_HOST_PCI_REGION_TYPE_MEM_64;
}
if (VAR_1 < PCI_ROM_SLOT) {
VAR_0->io_regions[VAR_1].base_addr = VAR_6;
VAR_0->io_regions[VAR_1].VAR_9 = VAR_9;
VAR_0->io_regions[VAR_1].type = type;
VAR_0->io_regions[VAR_1].bus_flags = VAR_8 & IORESOURCE_BITS;
} else {
VAR_0->rom.base_addr = VAR_6;
VAR_0->rom.VAR_9 = VAR_9;
VAR_0->rom.type = type;
VAR_0->rom.bus_flags = VAR_8 & IORESOURCE_BITS;
}
}
if (VAR_1 != PCI_NUM_REGIONS) {
VAR_2 = -ENODEV;
}
out:
close(VAR_3);
return VAR_2;
}
| [
"static int FUNC_0(XenHostPCIDevice *VAR_0)\n{",
"int VAR_1, VAR_2, VAR_3;",
"char VAR_4[PATH_MAX];",
"char VAR_5[XEN_HOST_PCI_RESOURCE_BUFFER_SIZE];",
"unsigned long long VAR_6, VAR_7, VAR_8, VAR_9;",
"char *VAR_10, *VAR_11;",
"uint8_t type;",
"VAR_2 = xen_host_pci_sysfs_path(VAR_0, \"resource\", VAR_4, sizeof (VAR_4));",
"if (VAR_2) {",
"return VAR_2;",
"}",
"VAR_3 = open(VAR_4, O_RDONLY);",
"if (VAR_3 == -1) {",
"XEN_HOST_PCI_LOG(\"Error: Can't open %VAR_11: %VAR_11\\n\", VAR_4, strerror(errno));",
"return -errno;",
"}",
"do {",
"VAR_2 = read(VAR_3, &VAR_5, sizeof (VAR_5) - 1);",
"if (VAR_2 < 0 && errno != EINTR) {",
"VAR_2 = -errno;",
"goto out;",
"}",
"} while (VAR_2 < 0);",
"VAR_5[VAR_2] = 0;",
"VAR_2 = 0;",
"VAR_11 = VAR_5;",
"for (VAR_1 = 0; VAR_1 < PCI_NUM_REGIONS; VAR_1++) {",
"type = 0;",
"VAR_6 = strtoll(VAR_11, &VAR_10, 16);",
"if (*VAR_10 != ' ' || VAR_11 == VAR_10) {",
"break;",
"}",
"VAR_11 = VAR_10 + 1;",
"VAR_7 = strtoll(VAR_11, &VAR_10, 16);",
"if (*VAR_10 != ' ' || VAR_11 == VAR_10) {",
"break;",
"}",
"VAR_11 = VAR_10 + 1;",
"VAR_8 = strtoll(VAR_11, &VAR_10, 16);",
"if (*VAR_10 != '\\n' || VAR_11 == VAR_10) {",
"break;",
"}",
"VAR_11 = VAR_10 + 1;",
"if (VAR_6) {",
"VAR_9 = VAR_7 - VAR_6 + 1;",
"} else {",
"VAR_9 = 0;",
"}",
"if (VAR_8 & IORESOURCE_IO) {",
"type |= XEN_HOST_PCI_REGION_TYPE_IO;",
"}",
"if (VAR_8 & IORESOURCE_MEM) {",
"type |= XEN_HOST_PCI_REGION_TYPE_MEM;",
"}",
"if (VAR_8 & IORESOURCE_PREFETCH) {",
"type |= XEN_HOST_PCI_REGION_TYPE_PREFETCH;",
"}",
"if (VAR_8 & IORESOURCE_MEM_64) {",
"type |= XEN_HOST_PCI_REGION_TYPE_MEM_64;",
"}",
"if (VAR_1 < PCI_ROM_SLOT) {",
"VAR_0->io_regions[VAR_1].base_addr = VAR_6;",
"VAR_0->io_regions[VAR_1].VAR_9 = VAR_9;",
"VAR_0->io_regions[VAR_1].type = type;",
"VAR_0->io_regions[VAR_1].bus_flags = VAR_8 & IORESOURCE_BITS;",
"} else {",
"VAR_0->rom.base_addr = VAR_6;",
"VAR_0->rom.VAR_9 = VAR_9;",
"VAR_0->rom.type = type;",
"VAR_0->rom.bus_flags = VAR_8 & IORESOURCE_BITS;",
"}",
"}",
"if (VAR_1 != PCI_NUM_REGIONS) {",
"VAR_2 = -ENODEV;",
"}",
"out:\nclose(VAR_3);",
"return VAR_2;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
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,
0,
0,
0,
0,
0,
0,
0,
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
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
165
],
[
167
],
[
171,
173
],
[
175
],
[
177
]
] |
21,180 | static int decode_nal_units(H264Context *h, uint8_t *buf, int buf_size){
MpegEncContext * const s = &h->s;
AVCodecContext * const avctx= s->avctx;
int buf_index=0;
#if 0
int i;
for(i=0; i<50; i++){
av_log(NULL, AV_LOG_ERROR,"%02X ", buf[i]);
}
#endif
h->slice_num = 0;
s->current_picture_ptr= NULL;
for(;;){
int consumed;
int dst_length;
int bit_length;
uint8_t *ptr;
int i, nalsize = 0;
if(h->is_avc) {
if(buf_index >= buf_size) break;
nalsize = 0;
for(i = 0; i < h->nal_length_size; i++)
nalsize = (nalsize << 8) | buf[buf_index++];
if(nalsize <= 1){
if(nalsize == 1){
buf_index++;
continue;
}else{
av_log(h->s.avctx, AV_LOG_ERROR, "AVC: nal size %d\n", nalsize);
break;
}
}
} else {
// start code prefix search
for(; buf_index + 3 < buf_size; buf_index++){
// this should allways succeed in the first iteration
if(buf[buf_index] == 0 && buf[buf_index+1] == 0 && buf[buf_index+2] == 1)
break;
}
if(buf_index+3 >= buf_size) break;
buf_index+=3;
}
ptr= decode_nal(h, buf + buf_index, &dst_length, &consumed, h->is_avc ? nalsize : buf_size - buf_index);
while(ptr[dst_length - 1] == 0 && dst_length > 1)
dst_length--;
bit_length= 8*dst_length - decode_rbsp_trailing(ptr + dst_length - 1);
if(s->avctx->debug&FF_DEBUG_STARTCODE){
av_log(h->s.avctx, AV_LOG_DEBUG, "NAL %d at %d/%d length %d\n", h->nal_unit_type, buf_index, buf_size, dst_length);
}
if (h->is_avc && (nalsize != consumed))
av_log(h->s.avctx, AV_LOG_ERROR, "AVC: Consumed only %d bytes instead of %d\n", consumed, nalsize);
buf_index += consumed;
if( (s->hurry_up == 1 && h->nal_ref_idc == 0) //FIXME dont discard SEI id
||(avctx->skip_frame >= AVDISCARD_NONREF && h->nal_ref_idc == 0))
continue;
switch(h->nal_unit_type){
case NAL_IDR_SLICE:
idr(h); //FIXME ensure we don't loose some frames if there is reordering
case NAL_SLICE:
init_get_bits(&s->gb, ptr, bit_length);
h->intra_gb_ptr=
h->inter_gb_ptr= &s->gb;
s->data_partitioning = 0;
if(decode_slice_header(h) < 0){
av_log(h->s.avctx, AV_LOG_ERROR, "decode_slice_header error\n");
break;
}
s->current_picture_ptr->key_frame= (h->nal_unit_type == NAL_IDR_SLICE);
if(h->redundant_pic_count==0 && s->hurry_up < 5
&& (avctx->skip_frame < AVDISCARD_NONREF || h->nal_ref_idc)
&& (avctx->skip_frame < AVDISCARD_BIDIR || h->slice_type!=B_TYPE)
&& (avctx->skip_frame < AVDISCARD_NONKEY || h->slice_type==I_TYPE)
&& avctx->skip_frame < AVDISCARD_ALL)
decode_slice(h);
break;
case NAL_DPA:
init_get_bits(&s->gb, ptr, bit_length);
h->intra_gb_ptr=
h->inter_gb_ptr= NULL;
s->data_partitioning = 1;
if(decode_slice_header(h) < 0){
av_log(h->s.avctx, AV_LOG_ERROR, "decode_slice_header error\n");
}
break;
case NAL_DPB:
init_get_bits(&h->intra_gb, ptr, bit_length);
h->intra_gb_ptr= &h->intra_gb;
break;
case NAL_DPC:
init_get_bits(&h->inter_gb, ptr, bit_length);
h->inter_gb_ptr= &h->inter_gb;
if(h->redundant_pic_count==0 && h->intra_gb_ptr && s->data_partitioning
&& s->context_initialized
&& s->hurry_up < 5
&& (avctx->skip_frame < AVDISCARD_NONREF || h->nal_ref_idc)
&& (avctx->skip_frame < AVDISCARD_BIDIR || h->slice_type!=B_TYPE)
&& (avctx->skip_frame < AVDISCARD_NONKEY || h->slice_type==I_TYPE)
&& avctx->skip_frame < AVDISCARD_ALL)
decode_slice(h);
break;
case NAL_SEI:
init_get_bits(&s->gb, ptr, bit_length);
decode_sei(h);
break;
case NAL_SPS:
init_get_bits(&s->gb, ptr, bit_length);
decode_seq_parameter_set(h);
if(s->flags& CODEC_FLAG_LOW_DELAY)
s->low_delay=1;
if(avctx->has_b_frames < 2)
avctx->has_b_frames= !s->low_delay;
break;
case NAL_PPS:
init_get_bits(&s->gb, ptr, bit_length);
decode_picture_parameter_set(h, bit_length);
break;
case NAL_AUD:
case NAL_END_SEQUENCE:
case NAL_END_STREAM:
case NAL_FILLER_DATA:
case NAL_SPS_EXT:
case NAL_AUXILIARY_SLICE:
break;
default:
av_log(avctx, AV_LOG_ERROR, "Unknown NAL code: %d\n", h->nal_unit_type);
}
}
if(!s->current_picture_ptr) return buf_index; //no frame
s->current_picture_ptr->qscale_type= FF_QSCALE_TYPE_H264;
s->current_picture_ptr->pict_type= s->pict_type;
h->prev_frame_num_offset= h->frame_num_offset;
h->prev_frame_num= h->frame_num;
if(s->current_picture_ptr->reference){
h->prev_poc_msb= h->poc_msb;
h->prev_poc_lsb= h->poc_lsb;
}
if(s->current_picture_ptr->reference)
execute_ref_pic_marking(h, h->mmco, h->mmco_index);
ff_er_frame_end(s);
MPV_frame_end(s);
return buf_index;
}
| true | FFmpeg | ac658be5db5baa01546715994fbd193a855cbc73 | static int decode_nal_units(H264Context *h, uint8_t *buf, int buf_size){
MpegEncContext * const s = &h->s;
AVCodecContext * const avctx= s->avctx;
int buf_index=0;
#if 0
int i;
for(i=0; i<50; i++){
av_log(NULL, AV_LOG_ERROR,"%02X ", buf[i]);
}
#endif
h->slice_num = 0;
s->current_picture_ptr= NULL;
for(;;){
int consumed;
int dst_length;
int bit_length;
uint8_t *ptr;
int i, nalsize = 0;
if(h->is_avc) {
if(buf_index >= buf_size) break;
nalsize = 0;
for(i = 0; i < h->nal_length_size; i++)
nalsize = (nalsize << 8) | buf[buf_index++];
if(nalsize <= 1){
if(nalsize == 1){
buf_index++;
continue;
}else{
av_log(h->s.avctx, AV_LOG_ERROR, "AVC: nal size %d\n", nalsize);
break;
}
}
} else {
for(; buf_index + 3 < buf_size; buf_index++){
if(buf[buf_index] == 0 && buf[buf_index+1] == 0 && buf[buf_index+2] == 1)
break;
}
if(buf_index+3 >= buf_size) break;
buf_index+=3;
}
ptr= decode_nal(h, buf + buf_index, &dst_length, &consumed, h->is_avc ? nalsize : buf_size - buf_index);
while(ptr[dst_length - 1] == 0 && dst_length > 1)
dst_length--;
bit_length= 8*dst_length - decode_rbsp_trailing(ptr + dst_length - 1);
if(s->avctx->debug&FF_DEBUG_STARTCODE){
av_log(h->s.avctx, AV_LOG_DEBUG, "NAL %d at %d/%d length %d\n", h->nal_unit_type, buf_index, buf_size, dst_length);
}
if (h->is_avc && (nalsize != consumed))
av_log(h->s.avctx, AV_LOG_ERROR, "AVC: Consumed only %d bytes instead of %d\n", consumed, nalsize);
buf_index += consumed;
if( (s->hurry_up == 1 && h->nal_ref_idc == 0)
||(avctx->skip_frame >= AVDISCARD_NONREF && h->nal_ref_idc == 0))
continue;
switch(h->nal_unit_type){
case NAL_IDR_SLICE:
idr(h);
case NAL_SLICE:
init_get_bits(&s->gb, ptr, bit_length);
h->intra_gb_ptr=
h->inter_gb_ptr= &s->gb;
s->data_partitioning = 0;
if(decode_slice_header(h) < 0){
av_log(h->s.avctx, AV_LOG_ERROR, "decode_slice_header error\n");
break;
}
s->current_picture_ptr->key_frame= (h->nal_unit_type == NAL_IDR_SLICE);
if(h->redundant_pic_count==0 && s->hurry_up < 5
&& (avctx->skip_frame < AVDISCARD_NONREF || h->nal_ref_idc)
&& (avctx->skip_frame < AVDISCARD_BIDIR || h->slice_type!=B_TYPE)
&& (avctx->skip_frame < AVDISCARD_NONKEY || h->slice_type==I_TYPE)
&& avctx->skip_frame < AVDISCARD_ALL)
decode_slice(h);
break;
case NAL_DPA:
init_get_bits(&s->gb, ptr, bit_length);
h->intra_gb_ptr=
h->inter_gb_ptr= NULL;
s->data_partitioning = 1;
if(decode_slice_header(h) < 0){
av_log(h->s.avctx, AV_LOG_ERROR, "decode_slice_header error\n");
}
break;
case NAL_DPB:
init_get_bits(&h->intra_gb, ptr, bit_length);
h->intra_gb_ptr= &h->intra_gb;
break;
case NAL_DPC:
init_get_bits(&h->inter_gb, ptr, bit_length);
h->inter_gb_ptr= &h->inter_gb;
if(h->redundant_pic_count==0 && h->intra_gb_ptr && s->data_partitioning
&& s->context_initialized
&& s->hurry_up < 5
&& (avctx->skip_frame < AVDISCARD_NONREF || h->nal_ref_idc)
&& (avctx->skip_frame < AVDISCARD_BIDIR || h->slice_type!=B_TYPE)
&& (avctx->skip_frame < AVDISCARD_NONKEY || h->slice_type==I_TYPE)
&& avctx->skip_frame < AVDISCARD_ALL)
decode_slice(h);
break;
case NAL_SEI:
init_get_bits(&s->gb, ptr, bit_length);
decode_sei(h);
break;
case NAL_SPS:
init_get_bits(&s->gb, ptr, bit_length);
decode_seq_parameter_set(h);
if(s->flags& CODEC_FLAG_LOW_DELAY)
s->low_delay=1;
if(avctx->has_b_frames < 2)
avctx->has_b_frames= !s->low_delay;
break;
case NAL_PPS:
init_get_bits(&s->gb, ptr, bit_length);
decode_picture_parameter_set(h, bit_length);
break;
case NAL_AUD:
case NAL_END_SEQUENCE:
case NAL_END_STREAM:
case NAL_FILLER_DATA:
case NAL_SPS_EXT:
case NAL_AUXILIARY_SLICE:
break;
default:
av_log(avctx, AV_LOG_ERROR, "Unknown NAL code: %d\n", h->nal_unit_type);
}
}
if(!s->current_picture_ptr) return buf_index;
s->current_picture_ptr->qscale_type= FF_QSCALE_TYPE_H264;
s->current_picture_ptr->pict_type= s->pict_type;
h->prev_frame_num_offset= h->frame_num_offset;
h->prev_frame_num= h->frame_num;
if(s->current_picture_ptr->reference){
h->prev_poc_msb= h->poc_msb;
h->prev_poc_lsb= h->poc_lsb;
}
if(s->current_picture_ptr->reference)
execute_ref_pic_marking(h, h->mmco, h->mmco_index);
ff_er_frame_end(s);
MPV_frame_end(s);
return buf_index;
}
| {
"code": [
" if(nalsize <= 1){"
],
"line_no": [
49
]
} | static int FUNC_0(H264Context *VAR_0, uint8_t *VAR_1, int VAR_2){
MpegEncContext * const s = &VAR_0->s;
AVCodecContext * const avctx= s->avctx;
int VAR_3=0;
#if 0
int VAR_7;
for(VAR_7=0; VAR_7<50; VAR_7++){
av_log(NULL, AV_LOG_ERROR,"%02X ", VAR_1[VAR_7]);
}
#endif
VAR_0->slice_num = 0;
s->current_picture_ptr= NULL;
for(;;){
int VAR_4;
int VAR_5;
int VAR_6;
uint8_t *ptr;
int VAR_7, VAR_8 = 0;
if(VAR_0->is_avc) {
if(VAR_3 >= VAR_2) break;
VAR_8 = 0;
for(VAR_7 = 0; VAR_7 < VAR_0->nal_length_size; VAR_7++)
VAR_8 = (VAR_8 << 8) | VAR_1[VAR_3++];
if(VAR_8 <= 1){
if(VAR_8 == 1){
VAR_3++;
continue;
}else{
av_log(VAR_0->s.avctx, AV_LOG_ERROR, "AVC: nal size %d\n", VAR_8);
break;
}
}
} else {
for(; VAR_3 + 3 < VAR_2; VAR_3++){
if(VAR_1[VAR_3] == 0 && VAR_1[VAR_3+1] == 0 && VAR_1[VAR_3+2] == 1)
break;
}
if(VAR_3+3 >= VAR_2) break;
VAR_3+=3;
}
ptr= decode_nal(VAR_0, VAR_1 + VAR_3, &VAR_5, &VAR_4, VAR_0->is_avc ? VAR_8 : VAR_2 - VAR_3);
while(ptr[VAR_5 - 1] == 0 && VAR_5 > 1)
VAR_5--;
VAR_6= 8*VAR_5 - decode_rbsp_trailing(ptr + VAR_5 - 1);
if(s->avctx->debug&FF_DEBUG_STARTCODE){
av_log(VAR_0->s.avctx, AV_LOG_DEBUG, "NAL %d at %d/%d length %d\n", VAR_0->nal_unit_type, VAR_3, VAR_2, VAR_5);
}
if (VAR_0->is_avc && (VAR_8 != VAR_4))
av_log(VAR_0->s.avctx, AV_LOG_ERROR, "AVC: Consumed only %d bytes instead of %d\n", VAR_4, VAR_8);
VAR_3 += VAR_4;
if( (s->hurry_up == 1 && VAR_0->nal_ref_idc == 0)
||(avctx->skip_frame >= AVDISCARD_NONREF && VAR_0->nal_ref_idc == 0))
continue;
switch(VAR_0->nal_unit_type){
case NAL_IDR_SLICE:
idr(VAR_0);
case NAL_SLICE:
init_get_bits(&s->gb, ptr, VAR_6);
VAR_0->intra_gb_ptr=
VAR_0->inter_gb_ptr= &s->gb;
s->data_partitioning = 0;
if(decode_slice_header(VAR_0) < 0){
av_log(VAR_0->s.avctx, AV_LOG_ERROR, "decode_slice_header error\n");
break;
}
s->current_picture_ptr->key_frame= (VAR_0->nal_unit_type == NAL_IDR_SLICE);
if(VAR_0->redundant_pic_count==0 && s->hurry_up < 5
&& (avctx->skip_frame < AVDISCARD_NONREF || VAR_0->nal_ref_idc)
&& (avctx->skip_frame < AVDISCARD_BIDIR || VAR_0->slice_type!=B_TYPE)
&& (avctx->skip_frame < AVDISCARD_NONKEY || VAR_0->slice_type==I_TYPE)
&& avctx->skip_frame < AVDISCARD_ALL)
decode_slice(VAR_0);
break;
case NAL_DPA:
init_get_bits(&s->gb, ptr, VAR_6);
VAR_0->intra_gb_ptr=
VAR_0->inter_gb_ptr= NULL;
s->data_partitioning = 1;
if(decode_slice_header(VAR_0) < 0){
av_log(VAR_0->s.avctx, AV_LOG_ERROR, "decode_slice_header error\n");
}
break;
case NAL_DPB:
init_get_bits(&VAR_0->intra_gb, ptr, VAR_6);
VAR_0->intra_gb_ptr= &VAR_0->intra_gb;
break;
case NAL_DPC:
init_get_bits(&VAR_0->inter_gb, ptr, VAR_6);
VAR_0->inter_gb_ptr= &VAR_0->inter_gb;
if(VAR_0->redundant_pic_count==0 && VAR_0->intra_gb_ptr && s->data_partitioning
&& s->context_initialized
&& s->hurry_up < 5
&& (avctx->skip_frame < AVDISCARD_NONREF || VAR_0->nal_ref_idc)
&& (avctx->skip_frame < AVDISCARD_BIDIR || VAR_0->slice_type!=B_TYPE)
&& (avctx->skip_frame < AVDISCARD_NONKEY || VAR_0->slice_type==I_TYPE)
&& avctx->skip_frame < AVDISCARD_ALL)
decode_slice(VAR_0);
break;
case NAL_SEI:
init_get_bits(&s->gb, ptr, VAR_6);
decode_sei(VAR_0);
break;
case NAL_SPS:
init_get_bits(&s->gb, ptr, VAR_6);
decode_seq_parameter_set(VAR_0);
if(s->flags& CODEC_FLAG_LOW_DELAY)
s->low_delay=1;
if(avctx->has_b_frames < 2)
avctx->has_b_frames= !s->low_delay;
break;
case NAL_PPS:
init_get_bits(&s->gb, ptr, VAR_6);
decode_picture_parameter_set(VAR_0, VAR_6);
break;
case NAL_AUD:
case NAL_END_SEQUENCE:
case NAL_END_STREAM:
case NAL_FILLER_DATA:
case NAL_SPS_EXT:
case NAL_AUXILIARY_SLICE:
break;
default:
av_log(avctx, AV_LOG_ERROR, "Unknown NAL code: %d\n", VAR_0->nal_unit_type);
}
}
if(!s->current_picture_ptr) return VAR_3;
s->current_picture_ptr->qscale_type= FF_QSCALE_TYPE_H264;
s->current_picture_ptr->pict_type= s->pict_type;
VAR_0->prev_frame_num_offset= VAR_0->frame_num_offset;
VAR_0->prev_frame_num= VAR_0->frame_num;
if(s->current_picture_ptr->reference){
VAR_0->prev_poc_msb= VAR_0->poc_msb;
VAR_0->prev_poc_lsb= VAR_0->poc_lsb;
}
if(s->current_picture_ptr->reference)
execute_ref_pic_marking(VAR_0, VAR_0->mmco, VAR_0->mmco_index);
ff_er_frame_end(s);
MPV_frame_end(s);
return VAR_3;
}
| [
"static int FUNC_0(H264Context *VAR_0, uint8_t *VAR_1, int VAR_2){",
"MpegEncContext * const s = &VAR_0->s;",
"AVCodecContext * const avctx= s->avctx;",
"int VAR_3=0;",
"#if 0\nint VAR_7;",
"for(VAR_7=0; VAR_7<50; VAR_7++){",
"av_log(NULL, AV_LOG_ERROR,\"%02X \", VAR_1[VAR_7]);",
"}",
"#endif\nVAR_0->slice_num = 0;",
"s->current_picture_ptr= NULL;",
"for(;;){",
"int VAR_4;",
"int VAR_5;",
"int VAR_6;",
"uint8_t *ptr;",
"int VAR_7, VAR_8 = 0;",
"if(VAR_0->is_avc) {",
"if(VAR_3 >= VAR_2) break;",
"VAR_8 = 0;",
"for(VAR_7 = 0; VAR_7 < VAR_0->nal_length_size; VAR_7++)",
"VAR_8 = (VAR_8 << 8) | VAR_1[VAR_3++];",
"if(VAR_8 <= 1){",
"if(VAR_8 == 1){",
"VAR_3++;",
"continue;",
"}else{",
"av_log(VAR_0->s.avctx, AV_LOG_ERROR, \"AVC: nal size %d\\n\", VAR_8);",
"break;",
"}",
"}",
"} else {",
"for(; VAR_3 + 3 < VAR_2; VAR_3++){",
"if(VAR_1[VAR_3] == 0 && VAR_1[VAR_3+1] == 0 && VAR_1[VAR_3+2] == 1)\nbreak;",
"}",
"if(VAR_3+3 >= VAR_2) break;",
"VAR_3+=3;",
"}",
"ptr= decode_nal(VAR_0, VAR_1 + VAR_3, &VAR_5, &VAR_4, VAR_0->is_avc ? VAR_8 : VAR_2 - VAR_3);",
"while(ptr[VAR_5 - 1] == 0 && VAR_5 > 1)\nVAR_5--;",
"VAR_6= 8*VAR_5 - decode_rbsp_trailing(ptr + VAR_5 - 1);",
"if(s->avctx->debug&FF_DEBUG_STARTCODE){",
"av_log(VAR_0->s.avctx, AV_LOG_DEBUG, \"NAL %d at %d/%d length %d\\n\", VAR_0->nal_unit_type, VAR_3, VAR_2, VAR_5);",
"}",
"if (VAR_0->is_avc && (VAR_8 != VAR_4))\nav_log(VAR_0->s.avctx, AV_LOG_ERROR, \"AVC: Consumed only %d bytes instead of %d\\n\", VAR_4, VAR_8);",
"VAR_3 += VAR_4;",
"if( (s->hurry_up == 1 && VAR_0->nal_ref_idc == 0)\n||(avctx->skip_frame >= AVDISCARD_NONREF && VAR_0->nal_ref_idc == 0))\ncontinue;",
"switch(VAR_0->nal_unit_type){",
"case NAL_IDR_SLICE:\nidr(VAR_0);",
"case NAL_SLICE:\ninit_get_bits(&s->gb, ptr, VAR_6);",
"VAR_0->intra_gb_ptr=\nVAR_0->inter_gb_ptr= &s->gb;",
"s->data_partitioning = 0;",
"if(decode_slice_header(VAR_0) < 0){",
"av_log(VAR_0->s.avctx, AV_LOG_ERROR, \"decode_slice_header error\\n\");",
"break;",
"}",
"s->current_picture_ptr->key_frame= (VAR_0->nal_unit_type == NAL_IDR_SLICE);",
"if(VAR_0->redundant_pic_count==0 && s->hurry_up < 5\n&& (avctx->skip_frame < AVDISCARD_NONREF || VAR_0->nal_ref_idc)\n&& (avctx->skip_frame < AVDISCARD_BIDIR || VAR_0->slice_type!=B_TYPE)\n&& (avctx->skip_frame < AVDISCARD_NONKEY || VAR_0->slice_type==I_TYPE)\n&& avctx->skip_frame < AVDISCARD_ALL)\ndecode_slice(VAR_0);",
"break;",
"case NAL_DPA:\ninit_get_bits(&s->gb, ptr, VAR_6);",
"VAR_0->intra_gb_ptr=\nVAR_0->inter_gb_ptr= NULL;",
"s->data_partitioning = 1;",
"if(decode_slice_header(VAR_0) < 0){",
"av_log(VAR_0->s.avctx, AV_LOG_ERROR, \"decode_slice_header error\\n\");",
"}",
"break;",
"case NAL_DPB:\ninit_get_bits(&VAR_0->intra_gb, ptr, VAR_6);",
"VAR_0->intra_gb_ptr= &VAR_0->intra_gb;",
"break;",
"case NAL_DPC:\ninit_get_bits(&VAR_0->inter_gb, ptr, VAR_6);",
"VAR_0->inter_gb_ptr= &VAR_0->inter_gb;",
"if(VAR_0->redundant_pic_count==0 && VAR_0->intra_gb_ptr && s->data_partitioning\n&& s->context_initialized\n&& s->hurry_up < 5\n&& (avctx->skip_frame < AVDISCARD_NONREF || VAR_0->nal_ref_idc)\n&& (avctx->skip_frame < AVDISCARD_BIDIR || VAR_0->slice_type!=B_TYPE)\n&& (avctx->skip_frame < AVDISCARD_NONKEY || VAR_0->slice_type==I_TYPE)\n&& avctx->skip_frame < AVDISCARD_ALL)\ndecode_slice(VAR_0);",
"break;",
"case NAL_SEI:\ninit_get_bits(&s->gb, ptr, VAR_6);",
"decode_sei(VAR_0);",
"break;",
"case NAL_SPS:\ninit_get_bits(&s->gb, ptr, VAR_6);",
"decode_seq_parameter_set(VAR_0);",
"if(s->flags& CODEC_FLAG_LOW_DELAY)\ns->low_delay=1;",
"if(avctx->has_b_frames < 2)\navctx->has_b_frames= !s->low_delay;",
"break;",
"case NAL_PPS:\ninit_get_bits(&s->gb, ptr, VAR_6);",
"decode_picture_parameter_set(VAR_0, VAR_6);",
"break;",
"case NAL_AUD:\ncase NAL_END_SEQUENCE:\ncase NAL_END_STREAM:\ncase NAL_FILLER_DATA:\ncase NAL_SPS_EXT:\ncase NAL_AUXILIARY_SLICE:\nbreak;",
"default:\nav_log(avctx, AV_LOG_ERROR, \"Unknown NAL code: %d\\n\", VAR_0->nal_unit_type);",
"}",
"}",
"if(!s->current_picture_ptr) return VAR_3;",
"s->current_picture_ptr->qscale_type= FF_QSCALE_TYPE_H264;",
"s->current_picture_ptr->pict_type= s->pict_type;",
"VAR_0->prev_frame_num_offset= VAR_0->frame_num_offset;",
"VAR_0->prev_frame_num= VAR_0->frame_num;",
"if(s->current_picture_ptr->reference){",
"VAR_0->prev_poc_msb= VAR_0->poc_msb;",
"VAR_0->prev_poc_lsb= VAR_0->poc_lsb;",
"}",
"if(s->current_picture_ptr->reference)\nexecute_ref_pic_marking(VAR_0, VAR_0->mmco, VAR_0->mmco_index);",
"ff_er_frame_end(s);",
"MPV_frame_end(s);",
"return VAR_3;",
"}"
] | [
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
75,
77
],
[
79
],
[
83
],
[
87
],
[
89
],
[
93
],
[
95,
97
],
[
99
],
[
103
],
[
105
],
[
107
],
[
111,
113
],
[
117
],
[
121,
123,
125
],
[
129
],
[
131,
133
],
[
135,
137
],
[
139,
141
],
[
143
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157,
159,
161,
163,
165,
167
],
[
169
],
[
171,
173
],
[
175,
177
],
[
179
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191,
193
],
[
195
],
[
197
],
[
199,
201
],
[
203
],
[
207,
209,
211,
213,
215,
217,
219,
221
],
[
223
],
[
225,
227
],
[
229
],
[
231
],
[
233,
235
],
[
237
],
[
241,
243
],
[
247,
249
],
[
251
],
[
253,
255
],
[
259
],
[
263
],
[
265,
267,
269,
271,
273,
275,
277
],
[
279,
281
],
[
283
],
[
285
],
[
289
],
[
293
],
[
295
],
[
299
],
[
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
311,
313
],
[
317
],
[
321
],
[
325
],
[
327
]
] |
21,181 | static target_ulong h_put_tce(PowerPCCPU *cpu, sPAPREnvironment *spapr,
target_ulong opcode, target_ulong *args)
{
target_ulong liobn = args[0];
target_ulong ioba = args[1];
target_ulong tce = args[2];
sPAPRTCETable *tcet = spapr_tce_find_by_liobn(liobn);
if (liobn & 0xFFFFFFFF00000000ULL) {
hcall_dprintf("spapr_vio_put_tce on out-of-boundsw LIOBN "
TARGET_FMT_lx "\n", liobn);
return H_PARAMETER;
}
ioba &= ~(SPAPR_TCE_PAGE_SIZE - 1);
if (tcet) {
return put_tce_emu(tcet, ioba, tce);
}
#ifdef DEBUG_TCE
fprintf(stderr, "%s on liobn=" TARGET_FMT_lx /*%s*/
" ioba 0x" TARGET_FMT_lx " TCE 0x" TARGET_FMT_lx "\n",
__func__, liobn, /*dev->qdev.id, */ioba, tce);
#endif
return H_PARAMETER;
}
| true | qemu | d4261662b67b48e52f747ee1e3c31cf873c5c982 | static target_ulong h_put_tce(PowerPCCPU *cpu, sPAPREnvironment *spapr,
target_ulong opcode, target_ulong *args)
{
target_ulong liobn = args[0];
target_ulong ioba = args[1];
target_ulong tce = args[2];
sPAPRTCETable *tcet = spapr_tce_find_by_liobn(liobn);
if (liobn & 0xFFFFFFFF00000000ULL) {
hcall_dprintf("spapr_vio_put_tce on out-of-boundsw LIOBN "
TARGET_FMT_lx "\n", liobn);
return H_PARAMETER;
}
ioba &= ~(SPAPR_TCE_PAGE_SIZE - 1);
if (tcet) {
return put_tce_emu(tcet, ioba, tce);
}
#ifdef DEBUG_TCE
fprintf(stderr, "%s on liobn=" TARGET_FMT_lx
" ioba 0x" TARGET_FMT_lx " TCE 0x" TARGET_FMT_lx "\n",
__func__, liobn, ioba, tce);
#endif
return H_PARAMETER;
}
| {
"code": [
" if (liobn & 0xFFFFFFFF00000000ULL) {",
" hcall_dprintf(\"spapr_vio_put_tce on out-of-boundsw LIOBN \"",
" TARGET_FMT_lx \"\\n\", liobn);",
" return H_PARAMETER;"
],
"line_no": [
17,
19,
21,
23
]
} | static target_ulong FUNC_0(PowerPCCPU *cpu, sPAPREnvironment *spapr,
target_ulong opcode, target_ulong *args)
{
target_ulong liobn = args[0];
target_ulong ioba = args[1];
target_ulong tce = args[2];
sPAPRTCETable *tcet = spapr_tce_find_by_liobn(liobn);
if (liobn & 0xFFFFFFFF00000000ULL) {
hcall_dprintf("spapr_vio_put_tce on out-of-boundsw LIOBN "
TARGET_FMT_lx "\n", liobn);
return H_PARAMETER;
}
ioba &= ~(SPAPR_TCE_PAGE_SIZE - 1);
if (tcet) {
return put_tce_emu(tcet, ioba, tce);
}
#ifdef DEBUG_TCE
fprintf(stderr, "%s on liobn=" TARGET_FMT_lx
" ioba 0x" TARGET_FMT_lx " TCE 0x" TARGET_FMT_lx "\n",
__func__, liobn, ioba, tce);
#endif
return H_PARAMETER;
}
| [
"static target_ulong FUNC_0(PowerPCCPU *cpu, sPAPREnvironment *spapr,\ntarget_ulong opcode, target_ulong *args)\n{",
"target_ulong liobn = args[0];",
"target_ulong ioba = args[1];",
"target_ulong tce = args[2];",
"sPAPRTCETable *tcet = spapr_tce_find_by_liobn(liobn);",
"if (liobn & 0xFFFFFFFF00000000ULL) {",
"hcall_dprintf(\"spapr_vio_put_tce on out-of-boundsw LIOBN \"\nTARGET_FMT_lx \"\\n\", liobn);",
"return H_PARAMETER;",
"}",
"ioba &= ~(SPAPR_TCE_PAGE_SIZE - 1);",
"if (tcet) {",
"return put_tce_emu(tcet, ioba, tce);",
"}",
"#ifdef DEBUG_TCE\nfprintf(stderr, \"%s on liobn=\" TARGET_FMT_lx\n\" ioba 0x\" TARGET_FMT_lx \" TCE 0x\" TARGET_FMT_lx \"\\n\",\n__func__, liobn, ioba, tce);",
"#endif\nreturn H_PARAMETER;",
"}"
] | [
0,
0,
0,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19,
21
],
[
23
],
[
25
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39,
41,
43,
45
],
[
47,
51
],
[
53
]
] |
21,182 | static void ivi_process_empty_tile(AVCodecContext *avctx, IVIBandDesc *band,
IVITile *tile, int32_t mv_scale)
{
int x, y, need_mc, mbn, blk, num_blocks, mv_x, mv_y, mc_type;
int offs, mb_offset, row_offset;
IVIMbInfo *mb, *ref_mb;
const int16_t *src;
int16_t *dst;
void (*mc_no_delta_func)(int16_t *buf, const int16_t *ref_buf, uint32_t pitch,
int mc_type);
offs = tile->ypos * band->pitch + tile->xpos;
mb = tile->mbs;
ref_mb = tile->ref_mbs;
row_offset = band->mb_size * band->pitch;
need_mc = 0; /* reset the mc tracking flag */
for (y = tile->ypos; y < (tile->ypos + tile->height); y += band->mb_size) {
mb_offset = offs;
for (x = tile->xpos; x < (tile->xpos + tile->width); x += band->mb_size) {
mb->xpos = x;
mb->ypos = y;
mb->buf_offs = mb_offset;
mb->type = 1; /* set the macroblocks type = INTER */
mb->cbp = 0; /* all blocks are empty */
if (!band->qdelta_present && !band->plane && !band->band_num) {
mb->q_delta = band->glob_quant;
mb->mv_x = 0;
mb->mv_y = 0;
}
if (band->inherit_qdelta && ref_mb)
mb->q_delta = ref_mb->q_delta;
if (band->inherit_mv) {
/* motion vector inheritance */
if (mv_scale) {
mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
} else {
mb->mv_x = ref_mb->mv_x;
mb->mv_y = ref_mb->mv_y;
}
need_mc |= mb->mv_x || mb->mv_y; /* tracking non-zero motion vectors */
}
mb++;
if (ref_mb)
ref_mb++;
mb_offset += band->mb_size;
} // for x
offs += row_offset;
} // for y
if (band->inherit_mv && need_mc) { /* apply motion compensation if there is at least one non-zero motion vector */
num_blocks = (band->mb_size != band->blk_size) ? 4 : 1; /* number of blocks per mb */
mc_no_delta_func = (band->blk_size == 8) ? ff_ivi_mc_8x8_no_delta
: ff_ivi_mc_4x4_no_delta;
for (mbn = 0, mb = tile->mbs; mbn < tile->num_MBs; mb++, mbn++) {
mv_x = mb->mv_x;
mv_y = mb->mv_y;
if (!band->is_halfpel) {
mc_type = 0; /* we have only fullpel vectors */
} else {
mc_type = ((mv_y & 1) << 1) | (mv_x & 1);
mv_x >>= 1;
mv_y >>= 1; /* convert halfpel vectors into fullpel ones */
}
for (blk = 0; blk < num_blocks; blk++) {
/* adjust block position in the buffer according with its number */
offs = mb->buf_offs + band->blk_size * ((blk & 1) + !!(blk & 2) * band->pitch);
mc_no_delta_func(band->buf + offs,
band->ref_buf + offs + mv_y * band->pitch + mv_x,
band->pitch, mc_type);
}
}
} else {
/* copy data from the reference tile into the current one */
src = band->ref_buf + tile->ypos * band->pitch + tile->xpos;
dst = band->buf + tile->ypos * band->pitch + tile->xpos;
for (y = 0; y < tile->height; y++) {
memcpy(dst, src, tile->width*sizeof(band->buf[0]));
src += band->pitch;
dst += band->pitch;
}
}
}
| true | FFmpeg | ae3da0ae5550053583a6f281ea7fd940497ea0d1 | static void ivi_process_empty_tile(AVCodecContext *avctx, IVIBandDesc *band,
IVITile *tile, int32_t mv_scale)
{
int x, y, need_mc, mbn, blk, num_blocks, mv_x, mv_y, mc_type;
int offs, mb_offset, row_offset;
IVIMbInfo *mb, *ref_mb;
const int16_t *src;
int16_t *dst;
void (*mc_no_delta_func)(int16_t *buf, const int16_t *ref_buf, uint32_t pitch,
int mc_type);
offs = tile->ypos * band->pitch + tile->xpos;
mb = tile->mbs;
ref_mb = tile->ref_mbs;
row_offset = band->mb_size * band->pitch;
need_mc = 0;
for (y = tile->ypos; y < (tile->ypos + tile->height); y += band->mb_size) {
mb_offset = offs;
for (x = tile->xpos; x < (tile->xpos + tile->width); x += band->mb_size) {
mb->xpos = x;
mb->ypos = y;
mb->buf_offs = mb_offset;
mb->type = 1;
mb->cbp = 0;
if (!band->qdelta_present && !band->plane && !band->band_num) {
mb->q_delta = band->glob_quant;
mb->mv_x = 0;
mb->mv_y = 0;
}
if (band->inherit_qdelta && ref_mb)
mb->q_delta = ref_mb->q_delta;
if (band->inherit_mv) {
if (mv_scale) {
mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
} else {
mb->mv_x = ref_mb->mv_x;
mb->mv_y = ref_mb->mv_y;
}
need_mc |= mb->mv_x || mb->mv_y;
}
mb++;
if (ref_mb)
ref_mb++;
mb_offset += band->mb_size;
}
offs += row_offset;
}
if (band->inherit_mv && need_mc) {
num_blocks = (band->mb_size != band->blk_size) ? 4 : 1;
mc_no_delta_func = (band->blk_size == 8) ? ff_ivi_mc_8x8_no_delta
: ff_ivi_mc_4x4_no_delta;
for (mbn = 0, mb = tile->mbs; mbn < tile->num_MBs; mb++, mbn++) {
mv_x = mb->mv_x;
mv_y = mb->mv_y;
if (!band->is_halfpel) {
mc_type = 0;
} else {
mc_type = ((mv_y & 1) << 1) | (mv_x & 1);
mv_x >>= 1;
mv_y >>= 1;
}
for (blk = 0; blk < num_blocks; blk++) {
offs = mb->buf_offs + band->blk_size * ((blk & 1) + !!(blk & 2) * band->pitch);
mc_no_delta_func(band->buf + offs,
band->ref_buf + offs + mv_y * band->pitch + mv_x,
band->pitch, mc_type);
}
}
} else {
src = band->ref_buf + tile->ypos * band->pitch + tile->xpos;
dst = band->buf + tile->ypos * band->pitch + tile->xpos;
for (y = 0; y < tile->height; y++) {
memcpy(dst, src, tile->width*sizeof(band->buf[0]));
src += band->pitch;
dst += band->pitch;
}
}
}
| {
"code": [
"static void ivi_process_empty_tile(AVCodecContext *avctx, IVIBandDesc *band,",
" IVITile *tile, int32_t mv_scale)"
],
"line_no": [
1,
3
]
} | static void FUNC_0(AVCodecContext *VAR_0, IVIBandDesc *VAR_1,
IVITile *VAR_2, int32_t VAR_3)
{
int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_21;
int VAR_13, VAR_14, VAR_15;
IVIMbInfo *mb, *ref_mb;
const int16_t *VAR_16;
int16_t *dst;
void (*VAR_17)(int16_t *VAR_18, const int16_t *VAR_19, uint32_t VAR_20,
int VAR_21);
VAR_13 = VAR_2->ypos * VAR_1->VAR_20 + VAR_2->xpos;
mb = VAR_2->mbs;
ref_mb = VAR_2->ref_mbs;
VAR_15 = VAR_1->mb_size * VAR_1->VAR_20;
VAR_6 = 0;
for (VAR_5 = VAR_2->ypos; VAR_5 < (VAR_2->ypos + VAR_2->height); VAR_5 += VAR_1->mb_size) {
VAR_14 = VAR_13;
for (VAR_4 = VAR_2->xpos; VAR_4 < (VAR_2->xpos + VAR_2->width); VAR_4 += VAR_1->mb_size) {
mb->xpos = VAR_4;
mb->ypos = VAR_5;
mb->buf_offs = VAR_14;
mb->type = 1;
mb->cbp = 0;
if (!VAR_1->qdelta_present && !VAR_1->plane && !VAR_1->band_num) {
mb->q_delta = VAR_1->glob_quant;
mb->VAR_10 = 0;
mb->VAR_11 = 0;
}
if (VAR_1->inherit_qdelta && ref_mb)
mb->q_delta = ref_mb->q_delta;
if (VAR_1->inherit_mv) {
if (VAR_3) {
mb->VAR_10 = ivi_scale_mv(ref_mb->VAR_10, VAR_3);
mb->VAR_11 = ivi_scale_mv(ref_mb->VAR_11, VAR_3);
} else {
mb->VAR_10 = ref_mb->VAR_10;
mb->VAR_11 = ref_mb->VAR_11;
}
VAR_6 |= mb->VAR_10 || mb->VAR_11;
}
mb++;
if (ref_mb)
ref_mb++;
VAR_14 += VAR_1->mb_size;
}
VAR_13 += VAR_15;
}
if (VAR_1->inherit_mv && VAR_6) {
VAR_9 = (VAR_1->mb_size != VAR_1->blk_size) ? 4 : 1;
VAR_17 = (VAR_1->blk_size == 8) ? ff_ivi_mc_8x8_no_delta
: ff_ivi_mc_4x4_no_delta;
for (VAR_7 = 0, mb = VAR_2->mbs; VAR_7 < VAR_2->num_MBs; mb++, VAR_7++) {
VAR_10 = mb->VAR_10;
VAR_11 = mb->VAR_11;
if (!VAR_1->is_halfpel) {
VAR_21 = 0;
} else {
VAR_21 = ((VAR_11 & 1) << 1) | (VAR_10 & 1);
VAR_10 >>= 1;
VAR_11 >>= 1;
}
for (VAR_8 = 0; VAR_8 < VAR_9; VAR_8++) {
VAR_13 = mb->buf_offs + VAR_1->blk_size * ((VAR_8 & 1) + !!(VAR_8 & 2) * VAR_1->VAR_20);
VAR_17(VAR_1->VAR_18 + VAR_13,
VAR_1->VAR_19 + VAR_13 + VAR_11 * VAR_1->VAR_20 + VAR_10,
VAR_1->VAR_20, VAR_21);
}
}
} else {
VAR_16 = VAR_1->VAR_19 + VAR_2->ypos * VAR_1->VAR_20 + VAR_2->xpos;
dst = VAR_1->VAR_18 + VAR_2->ypos * VAR_1->VAR_20 + VAR_2->xpos;
for (VAR_5 = 0; VAR_5 < VAR_2->height; VAR_5++) {
memcpy(dst, VAR_16, VAR_2->width*sizeof(VAR_1->VAR_18[0]));
VAR_16 += VAR_1->VAR_20;
dst += VAR_1->VAR_20;
}
}
}
| [
"static void FUNC_0(AVCodecContext *VAR_0, IVIBandDesc *VAR_1,\nIVITile *VAR_2, int32_t VAR_3)\n{",
"int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_21;",
"int VAR_13, VAR_14, VAR_15;",
"IVIMbInfo *mb, *ref_mb;",
"const int16_t *VAR_16;",
"int16_t *dst;",
"void (*VAR_17)(int16_t *VAR_18, const int16_t *VAR_19, uint32_t VAR_20,\nint VAR_21);",
"VAR_13 = VAR_2->ypos * VAR_1->VAR_20 + VAR_2->xpos;",
"mb = VAR_2->mbs;",
"ref_mb = VAR_2->ref_mbs;",
"VAR_15 = VAR_1->mb_size * VAR_1->VAR_20;",
"VAR_6 = 0;",
"for (VAR_5 = VAR_2->ypos; VAR_5 < (VAR_2->ypos + VAR_2->height); VAR_5 += VAR_1->mb_size) {",
"VAR_14 = VAR_13;",
"for (VAR_4 = VAR_2->xpos; VAR_4 < (VAR_2->xpos + VAR_2->width); VAR_4 += VAR_1->mb_size) {",
"mb->xpos = VAR_4;",
"mb->ypos = VAR_5;",
"mb->buf_offs = VAR_14;",
"mb->type = 1;",
"mb->cbp = 0;",
"if (!VAR_1->qdelta_present && !VAR_1->plane && !VAR_1->band_num) {",
"mb->q_delta = VAR_1->glob_quant;",
"mb->VAR_10 = 0;",
"mb->VAR_11 = 0;",
"}",
"if (VAR_1->inherit_qdelta && ref_mb)\nmb->q_delta = ref_mb->q_delta;",
"if (VAR_1->inherit_mv) {",
"if (VAR_3) {",
"mb->VAR_10 = ivi_scale_mv(ref_mb->VAR_10, VAR_3);",
"mb->VAR_11 = ivi_scale_mv(ref_mb->VAR_11, VAR_3);",
"} else {",
"mb->VAR_10 = ref_mb->VAR_10;",
"mb->VAR_11 = ref_mb->VAR_11;",
"}",
"VAR_6 |= mb->VAR_10 || mb->VAR_11;",
"}",
"mb++;",
"if (ref_mb)\nref_mb++;",
"VAR_14 += VAR_1->mb_size;",
"}",
"VAR_13 += VAR_15;",
"}",
"if (VAR_1->inherit_mv && VAR_6) {",
"VAR_9 = (VAR_1->mb_size != VAR_1->blk_size) ? 4 : 1;",
"VAR_17 = (VAR_1->blk_size == 8) ? ff_ivi_mc_8x8_no_delta\n: ff_ivi_mc_4x4_no_delta;",
"for (VAR_7 = 0, mb = VAR_2->mbs; VAR_7 < VAR_2->num_MBs; mb++, VAR_7++) {",
"VAR_10 = mb->VAR_10;",
"VAR_11 = mb->VAR_11;",
"if (!VAR_1->is_halfpel) {",
"VAR_21 = 0;",
"} else {",
"VAR_21 = ((VAR_11 & 1) << 1) | (VAR_10 & 1);",
"VAR_10 >>= 1;",
"VAR_11 >>= 1;",
"}",
"for (VAR_8 = 0; VAR_8 < VAR_9; VAR_8++) {",
"VAR_13 = mb->buf_offs + VAR_1->blk_size * ((VAR_8 & 1) + !!(VAR_8 & 2) * VAR_1->VAR_20);",
"VAR_17(VAR_1->VAR_18 + VAR_13,\nVAR_1->VAR_19 + VAR_13 + VAR_11 * VAR_1->VAR_20 + VAR_10,\nVAR_1->VAR_20, VAR_21);",
"}",
"}",
"} else {",
"VAR_16 = VAR_1->VAR_19 + VAR_2->ypos * VAR_1->VAR_20 + VAR_2->xpos;",
"dst = VAR_1->VAR_18 + VAR_2->ypos * VAR_1->VAR_20 + VAR_2->xpos;",
"for (VAR_5 = 0; VAR_5 < VAR_2->height; VAR_5++) {",
"memcpy(dst, VAR_16, VAR_2->width*sizeof(VAR_1->VAR_18[0]));",
"VAR_16 += VAR_1->VAR_20;",
"dst += VAR_1->VAR_20;",
"}",
"}",
"}"
] | [
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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17,
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69,
71
],
[
75
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
99
],
[
101,
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
115
],
[
117
],
[
119,
121
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
147
],
[
151
],
[
153,
155,
157
],
[
159
],
[
161
],
[
163
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
]
] |
21,183 | static void handle_rev16(DisasContext *s, unsigned int sf,
unsigned int rn, unsigned int rd)
{
TCGv_i64 tcg_rd = cpu_reg(s, rd);
TCGv_i64 tcg_tmp = tcg_temp_new_i64();
TCGv_i64 tcg_rn = read_cpu_reg(s, rn, sf);
TCGv_i64 mask = tcg_const_i64(sf ? 0x00ff00ff00ff00ffull : 0x00ff00ff);
tcg_gen_shri_i64(tcg_tmp, tcg_rn, 8);
tcg_gen_and_i64(tcg_rd, tcg_rn, mask);
tcg_gen_and_i64(tcg_tmp, tcg_tmp, mask);
tcg_gen_shli_i64(tcg_rd, tcg_rd, 8);
tcg_gen_or_i64(tcg_rd, tcg_rd, tcg_tmp);
tcg_temp_free_i64(tcg_tmp);
} | true | qemu | e4256c3cbf7eefebc0bc6e1f472c47c6dd20b996 | static void handle_rev16(DisasContext *s, unsigned int sf,
unsigned int rn, unsigned int rd)
{
TCGv_i64 tcg_rd = cpu_reg(s, rd);
TCGv_i64 tcg_tmp = tcg_temp_new_i64();
TCGv_i64 tcg_rn = read_cpu_reg(s, rn, sf);
TCGv_i64 mask = tcg_const_i64(sf ? 0x00ff00ff00ff00ffull : 0x00ff00ff);
tcg_gen_shri_i64(tcg_tmp, tcg_rn, 8);
tcg_gen_and_i64(tcg_rd, tcg_rn, mask);
tcg_gen_and_i64(tcg_tmp, tcg_tmp, mask);
tcg_gen_shli_i64(tcg_rd, tcg_rd, 8);
tcg_gen_or_i64(tcg_rd, tcg_rd, tcg_tmp);
tcg_temp_free_i64(tcg_tmp);
} | {
"code": [],
"line_no": []
} | static void FUNC_0(DisasContext *VAR_0, unsigned int VAR_1,
unsigned int VAR_2, unsigned int VAR_3)
{
TCGv_i64 tcg_rd = cpu_reg(VAR_0, VAR_3);
TCGv_i64 tcg_tmp = tcg_temp_new_i64();
TCGv_i64 tcg_rn = read_cpu_reg(VAR_0, VAR_2, VAR_1);
TCGv_i64 mask = tcg_const_i64(VAR_1 ? 0x00ff00ff00ff00ffull : 0x00ff00ff);
tcg_gen_shri_i64(tcg_tmp, tcg_rn, 8);
tcg_gen_and_i64(tcg_rd, tcg_rn, mask);
tcg_gen_and_i64(tcg_tmp, tcg_tmp, mask);
tcg_gen_shli_i64(tcg_rd, tcg_rd, 8);
tcg_gen_or_i64(tcg_rd, tcg_rd, tcg_tmp);
tcg_temp_free_i64(tcg_tmp);
} | [
"static void FUNC_0(DisasContext *VAR_0, unsigned int VAR_1,\nunsigned int VAR_2, unsigned int VAR_3)\n{",
"TCGv_i64 tcg_rd = cpu_reg(VAR_0, VAR_3);",
"TCGv_i64 tcg_tmp = tcg_temp_new_i64();",
"TCGv_i64 tcg_rn = read_cpu_reg(VAR_0, VAR_2, VAR_1);",
"TCGv_i64 mask = tcg_const_i64(VAR_1 ? 0x00ff00ff00ff00ffull : 0x00ff00ff);",
"tcg_gen_shri_i64(tcg_tmp, tcg_rn, 8);",
"tcg_gen_and_i64(tcg_rd, tcg_rn, mask);",
"tcg_gen_and_i64(tcg_tmp, tcg_tmp, mask);",
"tcg_gen_shli_i64(tcg_rd, tcg_rd, 8);",
"tcg_gen_or_i64(tcg_rd, tcg_rd, tcg_tmp);",
"tcg_temp_free_i64(tcg_tmp);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
30
],
[
32
]
] |
21,184 | static void guess_dc(MpegEncContext *s, int16_t *dc, int w,
int h, int stride, int is_luma)
{
int b_x, b_y;
int16_t (*col )[4] = av_malloc(stride*h*sizeof( int16_t)*4);
uint32_t (*dist)[4] = av_malloc(stride*h*sizeof(uint32_t)*4);
if(!col || !dist) {
av_log(s->avctx, AV_LOG_ERROR, "guess_dc() is out of memory\n");
goto fail;
}
for(b_y=0; b_y<h; b_y++){
int color= 1024;
int distance= -1;
for(b_x=0; b_x<w; b_x++){
int mb_index_j= (b_x>>is_luma) + (b_y>>is_luma)*s->mb_stride;
int error_j= s->error_status_table[mb_index_j];
int intra_j = IS_INTRA(s->current_picture.f.mb_type[mb_index_j]);
if(intra_j==0 || !(error_j&ER_DC_ERROR)){
color= dc[b_x + b_y*stride];
distance= b_x;
}
col [b_x + b_y*stride][1]= color;
dist[b_x + b_y*stride][1]= distance >= 0 ? b_x-distance : 9999;
}
color= 1024;
distance= -1;
for(b_x=w-1; b_x>=0; b_x--){
int mb_index_j= (b_x>>is_luma) + (b_y>>is_luma)*s->mb_stride;
int error_j= s->error_status_table[mb_index_j];
int intra_j = IS_INTRA(s->current_picture.f.mb_type[mb_index_j]);
if(intra_j==0 || !(error_j&ER_DC_ERROR)){
color= dc[b_x + b_y*stride];
distance= b_x;
}
col [b_x + b_y*stride][0]= color;
dist[b_x + b_y*stride][0]= distance >= 0 ? distance-b_x : 9999;
}
}
for(b_x=0; b_x<w; b_x++){
int color= 1024;
int distance= -1;
for(b_y=0; b_y<h; b_y++){
int mb_index_j= (b_x>>is_luma) + (b_y>>is_luma)*s->mb_stride;
int error_j= s->error_status_table[mb_index_j];
int intra_j = IS_INTRA(s->current_picture.f.mb_type[mb_index_j]);
if(intra_j==0 || !(error_j&ER_DC_ERROR)){
color= dc[b_x + b_y*stride];
distance= b_y;
}
col [b_x + b_y*stride][3]= color;
dist[b_x + b_y*stride][3]= distance >= 0 ? b_y-distance : 9999;
}
color= 1024;
distance= -1;
for(b_y=h-1; b_y>=0; b_y--){
int mb_index_j= (b_x>>is_luma) + (b_y>>is_luma)*s->mb_stride;
int error_j= s->error_status_table[mb_index_j];
int intra_j = IS_INTRA(s->current_picture.f.mb_type[mb_index_j]);
if(intra_j==0 || !(error_j&ER_DC_ERROR)){
color= dc[b_x + b_y*stride];
distance= b_y;
}
col [b_x + b_y*stride][2]= color;
dist[b_x + b_y*stride][2]= distance >= 0 ? distance-b_y : 9999;
}
}
for (b_y = 0; b_y < h; b_y++) {
for (b_x = 0; b_x < w; b_x++) {
int mb_index, error, j;
int64_t guess, weight_sum;
mb_index = (b_x >> is_luma) + (b_y >> is_luma) * s->mb_stride;
error = s->error_status_table[mb_index];
if (IS_INTER(s->current_picture.f.mb_type[mb_index]))
continue; // inter
if (!(error & ER_DC_ERROR))
continue; // dc-ok
weight_sum = 0;
guess = 0;
for (j = 0; j < 4; j++) {
int64_t weight = 256 * 256 * 256 * 16 / FFMAX(dist[b_x + b_y*stride][j], 1);
guess += weight*(int64_t)col[b_x + b_y*stride][j];
weight_sum += weight;
}
guess = (guess + weight_sum / 2) / weight_sum;
dc[b_x + b_y * stride] = guess;
}
}
av_freep(&col);
av_freep(&dist);
} | true | FFmpeg | 16e52c86ba46e92d4a75e612d69ac97edb88a462 | static void guess_dc(MpegEncContext *s, int16_t *dc, int w,
int h, int stride, int is_luma)
{
int b_x, b_y;
int16_t (*col )[4] = av_malloc(stride*h*sizeof( int16_t)*4);
uint32_t (*dist)[4] = av_malloc(stride*h*sizeof(uint32_t)*4);
if(!col || !dist) {
av_log(s->avctx, AV_LOG_ERROR, "guess_dc() is out of memory\n");
goto fail;
}
for(b_y=0; b_y<h; b_y++){
int color= 1024;
int distance= -1;
for(b_x=0; b_x<w; b_x++){
int mb_index_j= (b_x>>is_luma) + (b_y>>is_luma)*s->mb_stride;
int error_j= s->error_status_table[mb_index_j];
int intra_j = IS_INTRA(s->current_picture.f.mb_type[mb_index_j]);
if(intra_j==0 || !(error_j&ER_DC_ERROR)){
color= dc[b_x + b_y*stride];
distance= b_x;
}
col [b_x + b_y*stride][1]= color;
dist[b_x + b_y*stride][1]= distance >= 0 ? b_x-distance : 9999;
}
color= 1024;
distance= -1;
for(b_x=w-1; b_x>=0; b_x--){
int mb_index_j= (b_x>>is_luma) + (b_y>>is_luma)*s->mb_stride;
int error_j= s->error_status_table[mb_index_j];
int intra_j = IS_INTRA(s->current_picture.f.mb_type[mb_index_j]);
if(intra_j==0 || !(error_j&ER_DC_ERROR)){
color= dc[b_x + b_y*stride];
distance= b_x;
}
col [b_x + b_y*stride][0]= color;
dist[b_x + b_y*stride][0]= distance >= 0 ? distance-b_x : 9999;
}
}
for(b_x=0; b_x<w; b_x++){
int color= 1024;
int distance= -1;
for(b_y=0; b_y<h; b_y++){
int mb_index_j= (b_x>>is_luma) + (b_y>>is_luma)*s->mb_stride;
int error_j= s->error_status_table[mb_index_j];
int intra_j = IS_INTRA(s->current_picture.f.mb_type[mb_index_j]);
if(intra_j==0 || !(error_j&ER_DC_ERROR)){
color= dc[b_x + b_y*stride];
distance= b_y;
}
col [b_x + b_y*stride][3]= color;
dist[b_x + b_y*stride][3]= distance >= 0 ? b_y-distance : 9999;
}
color= 1024;
distance= -1;
for(b_y=h-1; b_y>=0; b_y--){
int mb_index_j= (b_x>>is_luma) + (b_y>>is_luma)*s->mb_stride;
int error_j= s->error_status_table[mb_index_j];
int intra_j = IS_INTRA(s->current_picture.f.mb_type[mb_index_j]);
if(intra_j==0 || !(error_j&ER_DC_ERROR)){
color= dc[b_x + b_y*stride];
distance= b_y;
}
col [b_x + b_y*stride][2]= color;
dist[b_x + b_y*stride][2]= distance >= 0 ? distance-b_y : 9999;
}
}
for (b_y = 0; b_y < h; b_y++) {
for (b_x = 0; b_x < w; b_x++) {
int mb_index, error, j;
int64_t guess, weight_sum;
mb_index = (b_x >> is_luma) + (b_y >> is_luma) * s->mb_stride;
error = s->error_status_table[mb_index];
if (IS_INTER(s->current_picture.f.mb_type[mb_index]))
continue;
if (!(error & ER_DC_ERROR))
continue;
weight_sum = 0;
guess = 0;
for (j = 0; j < 4; j++) {
int64_t weight = 256 * 256 * 256 * 16 / FFMAX(dist[b_x + b_y*stride][j], 1);
guess += weight*(int64_t)col[b_x + b_y*stride][j];
weight_sum += weight;
}
guess = (guess + weight_sum / 2) / weight_sum;
dc[b_x + b_y * stride] = guess;
}
}
av_freep(&col);
av_freep(&dist);
} | {
"code": [],
"line_no": []
} | static void FUNC_0(MpegEncContext *VAR_0, int16_t *VAR_1, int VAR_2,
int VAR_3, int VAR_4, int VAR_5)
{
int VAR_6, VAR_7;
int16_t (*col )[4] = av_malloc(VAR_4*VAR_3*sizeof( int16_t)*4);
uint32_t (*dist)[4] = av_malloc(VAR_4*VAR_3*sizeof(uint32_t)*4);
if(!col || !dist) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "FUNC_0() is out of memory\n");
goto fail;
}
for(VAR_7=0; VAR_7<VAR_3; VAR_7++){
int VAR_13= 1024;
int VAR_13= -1;
for(VAR_6=0; VAR_6<VAR_2; VAR_6++){
int VAR_13= (VAR_6>>VAR_5) + (VAR_7>>VAR_5)*VAR_0->mb_stride;
int VAR_13= VAR_0->error_status_table[VAR_13];
int VAR_13 = IS_INTRA(VAR_0->current_picture.f.mb_type[VAR_13]);
if(VAR_13==0 || !(VAR_13&ER_DC_ERROR)){
VAR_13= VAR_1[VAR_6 + VAR_7*VAR_4];
VAR_13= VAR_6;
}
col [VAR_6 + VAR_7*VAR_4][1]= VAR_13;
dist[VAR_6 + VAR_7*VAR_4][1]= VAR_13 >= 0 ? VAR_6-VAR_13 : 9999;
}
VAR_13= 1024;
VAR_13= -1;
for(VAR_6=VAR_2-1; VAR_6>=0; VAR_6--){
int VAR_13= (VAR_6>>VAR_5) + (VAR_7>>VAR_5)*VAR_0->mb_stride;
int VAR_13= VAR_0->error_status_table[VAR_13];
int VAR_13 = IS_INTRA(VAR_0->current_picture.f.mb_type[VAR_13]);
if(VAR_13==0 || !(VAR_13&ER_DC_ERROR)){
VAR_13= VAR_1[VAR_6 + VAR_7*VAR_4];
VAR_13= VAR_6;
}
col [VAR_6 + VAR_7*VAR_4][0]= VAR_13;
dist[VAR_6 + VAR_7*VAR_4][0]= VAR_13 >= 0 ? VAR_13-VAR_6 : 9999;
}
}
for(VAR_6=0; VAR_6<VAR_2; VAR_6++){
int VAR_13= 1024;
int VAR_13= -1;
for(VAR_7=0; VAR_7<VAR_3; VAR_7++){
int VAR_13= (VAR_6>>VAR_5) + (VAR_7>>VAR_5)*VAR_0->mb_stride;
int VAR_13= VAR_0->error_status_table[VAR_13];
int VAR_13 = IS_INTRA(VAR_0->current_picture.f.mb_type[VAR_13]);
if(VAR_13==0 || !(VAR_13&ER_DC_ERROR)){
VAR_13= VAR_1[VAR_6 + VAR_7*VAR_4];
VAR_13= VAR_7;
}
col [VAR_6 + VAR_7*VAR_4][3]= VAR_13;
dist[VAR_6 + VAR_7*VAR_4][3]= VAR_13 >= 0 ? VAR_7-VAR_13 : 9999;
}
VAR_13= 1024;
VAR_13= -1;
for(VAR_7=VAR_3-1; VAR_7>=0; VAR_7--){
int VAR_13= (VAR_6>>VAR_5) + (VAR_7>>VAR_5)*VAR_0->mb_stride;
int VAR_13= VAR_0->error_status_table[VAR_13];
int VAR_13 = IS_INTRA(VAR_0->current_picture.f.mb_type[VAR_13]);
if(VAR_13==0 || !(VAR_13&ER_DC_ERROR)){
VAR_13= VAR_1[VAR_6 + VAR_7*VAR_4];
VAR_13= VAR_7;
}
col [VAR_6 + VAR_7*VAR_4][2]= VAR_13;
dist[VAR_6 + VAR_7*VAR_4][2]= VAR_13 >= 0 ? VAR_13-VAR_7 : 9999;
}
}
for (VAR_7 = 0; VAR_7 < VAR_3; VAR_7++) {
for (VAR_6 = 0; VAR_6 < VAR_2; VAR_6++) {
int VAR_13, VAR_14, VAR_15;
int64_t guess, weight_sum;
VAR_13 = (VAR_6 >> VAR_5) + (VAR_7 >> VAR_5) * VAR_0->mb_stride;
VAR_14 = VAR_0->error_status_table[VAR_13];
if (IS_INTER(VAR_0->current_picture.f.mb_type[VAR_13]))
continue;
if (!(VAR_14 & ER_DC_ERROR))
continue;
weight_sum = 0;
guess = 0;
for (VAR_15 = 0; VAR_15 < 4; VAR_15++) {
int64_t weight = 256 * 256 * 256 * 16 / FFMAX(dist[VAR_6 + VAR_7*VAR_4][VAR_15], 1);
guess += weight*(int64_t)col[VAR_6 + VAR_7*VAR_4][VAR_15];
weight_sum += weight;
}
guess = (guess + weight_sum / 2) / weight_sum;
VAR_1[VAR_6 + VAR_7 * VAR_4] = guess;
}
}
av_freep(&col);
av_freep(&dist);
} | [
"static void FUNC_0(MpegEncContext *VAR_0, int16_t *VAR_1, int VAR_2,\nint VAR_3, int VAR_4, int VAR_5)\n{",
"int VAR_6, VAR_7;",
"int16_t (*col )[4] = av_malloc(VAR_4*VAR_3*sizeof( int16_t)*4);",
"uint32_t (*dist)[4] = av_malloc(VAR_4*VAR_3*sizeof(uint32_t)*4);",
"if(!col || !dist) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"FUNC_0() is out of memory\\n\");",
"goto fail;",
"}",
"for(VAR_7=0; VAR_7<VAR_3; VAR_7++){",
"int VAR_13= 1024;",
"int VAR_13= -1;",
"for(VAR_6=0; VAR_6<VAR_2; VAR_6++){",
"int VAR_13= (VAR_6>>VAR_5) + (VAR_7>>VAR_5)*VAR_0->mb_stride;",
"int VAR_13= VAR_0->error_status_table[VAR_13];",
"int VAR_13 = IS_INTRA(VAR_0->current_picture.f.mb_type[VAR_13]);",
"if(VAR_13==0 || !(VAR_13&ER_DC_ERROR)){",
"VAR_13= VAR_1[VAR_6 + VAR_7*VAR_4];",
"VAR_13= VAR_6;",
"}",
"col [VAR_6 + VAR_7*VAR_4][1]= VAR_13;",
"dist[VAR_6 + VAR_7*VAR_4][1]= VAR_13 >= 0 ? VAR_6-VAR_13 : 9999;",
"}",
"VAR_13= 1024;",
"VAR_13= -1;",
"for(VAR_6=VAR_2-1; VAR_6>=0; VAR_6--){",
"int VAR_13= (VAR_6>>VAR_5) + (VAR_7>>VAR_5)*VAR_0->mb_stride;",
"int VAR_13= VAR_0->error_status_table[VAR_13];",
"int VAR_13 = IS_INTRA(VAR_0->current_picture.f.mb_type[VAR_13]);",
"if(VAR_13==0 || !(VAR_13&ER_DC_ERROR)){",
"VAR_13= VAR_1[VAR_6 + VAR_7*VAR_4];",
"VAR_13= VAR_6;",
"}",
"col [VAR_6 + VAR_7*VAR_4][0]= VAR_13;",
"dist[VAR_6 + VAR_7*VAR_4][0]= VAR_13 >= 0 ? VAR_13-VAR_6 : 9999;",
"}",
"}",
"for(VAR_6=0; VAR_6<VAR_2; VAR_6++){",
"int VAR_13= 1024;",
"int VAR_13= -1;",
"for(VAR_7=0; VAR_7<VAR_3; VAR_7++){",
"int VAR_13= (VAR_6>>VAR_5) + (VAR_7>>VAR_5)*VAR_0->mb_stride;",
"int VAR_13= VAR_0->error_status_table[VAR_13];",
"int VAR_13 = IS_INTRA(VAR_0->current_picture.f.mb_type[VAR_13]);",
"if(VAR_13==0 || !(VAR_13&ER_DC_ERROR)){",
"VAR_13= VAR_1[VAR_6 + VAR_7*VAR_4];",
"VAR_13= VAR_7;",
"}",
"col [VAR_6 + VAR_7*VAR_4][3]= VAR_13;",
"dist[VAR_6 + VAR_7*VAR_4][3]= VAR_13 >= 0 ? VAR_7-VAR_13 : 9999;",
"}",
"VAR_13= 1024;",
"VAR_13= -1;",
"for(VAR_7=VAR_3-1; VAR_7>=0; VAR_7--){",
"int VAR_13= (VAR_6>>VAR_5) + (VAR_7>>VAR_5)*VAR_0->mb_stride;",
"int VAR_13= VAR_0->error_status_table[VAR_13];",
"int VAR_13 = IS_INTRA(VAR_0->current_picture.f.mb_type[VAR_13]);",
"if(VAR_13==0 || !(VAR_13&ER_DC_ERROR)){",
"VAR_13= VAR_1[VAR_6 + VAR_7*VAR_4];",
"VAR_13= VAR_7;",
"}",
"col [VAR_6 + VAR_7*VAR_4][2]= VAR_13;",
"dist[VAR_6 + VAR_7*VAR_4][2]= VAR_13 >= 0 ? VAR_13-VAR_7 : 9999;",
"}",
"}",
"for (VAR_7 = 0; VAR_7 < VAR_3; VAR_7++) {",
"for (VAR_6 = 0; VAR_6 < VAR_2; VAR_6++) {",
"int VAR_13, VAR_14, VAR_15;",
"int64_t guess, weight_sum;",
"VAR_13 = (VAR_6 >> VAR_5) + (VAR_7 >> VAR_5) * VAR_0->mb_stride;",
"VAR_14 = VAR_0->error_status_table[VAR_13];",
"if (IS_INTER(VAR_0->current_picture.f.mb_type[VAR_13]))\ncontinue;",
"if (!(VAR_14 & ER_DC_ERROR))\ncontinue;",
"weight_sum = 0;",
"guess = 0;",
"for (VAR_15 = 0; VAR_15 < 4; VAR_15++) {",
"int64_t weight = 256 * 256 * 256 * 16 / FFMAX(dist[VAR_6 + VAR_7*VAR_4][VAR_15], 1);",
"guess += weight*(int64_t)col[VAR_6 + VAR_7*VAR_4][VAR_15];",
"weight_sum += weight;",
"}",
"guess = (guess + weight_sum / 2) / weight_sum;",
"VAR_1[VAR_6 + VAR_7 * VAR_4] = guess;",
"}",
"}",
"av_freep(&col);",
"av_freep(&dist);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
39
],
[
40
],
[
41
],
[
42
],
[
43
],
[
44
],
[
45
],
[
46
],
[
47
],
[
48
],
[
49
],
[
50
],
[
51
],
[
52
],
[
53
],
[
54
],
[
55
],
[
56
],
[
57
],
[
58
],
[
59
],
[
60
],
[
61
],
[
62
],
[
63
],
[
64
],
[
65
],
[
66
],
[
67
],
[
68
],
[
69
],
[
70
],
[
71
],
[
72
],
[
73,
74
],
[
75,
76
],
[
77
],
[
78
],
[
79
],
[
80
],
[
81
],
[
82
],
[
83
],
[
84
],
[
85
],
[
86
],
[
87
],
[
88
],
[
89
],
[
90
]
] |
21,185 | int ff_flac_parse_picture(AVFormatContext *s, uint8_t *buf, int buf_size)
{
const CodecMime *mime = ff_id3v2_mime_tags;
enum AVCodecID id = AV_CODEC_ID_NONE;
AVBufferRef *data = NULL;
uint8_t mimetype[64], *desc = NULL;
AVIOContext *pb = NULL;
AVStream *st;
int type, width, height;
int len, ret = 0;
pb = avio_alloc_context(buf, buf_size, 0, NULL, NULL, NULL, NULL);
if (!pb)
return AVERROR(ENOMEM);
/* read the picture type */
type = avio_rb32(pb);
if (type >= FF_ARRAY_ELEMS(ff_id3v2_picture_types) || type < 0) {
av_log(s, AV_LOG_ERROR, "Invalid picture type: %d.\n", type);
if (s->error_recognition & AV_EF_EXPLODE) {
ret = AVERROR_INVALIDDATA;
goto fail;
}
type = 0;
}
/* picture mimetype */
len = avio_rb32(pb);
if (len <= 0 ||
avio_read(pb, mimetype, FFMIN(len, sizeof(mimetype) - 1)) != len) {
av_log(s, AV_LOG_ERROR, "Could not read mimetype from an attached "
"picture.\n");
if (s->error_recognition & AV_EF_EXPLODE)
ret = AVERROR_INVALIDDATA;
goto fail;
}
mimetype[len] = 0;
while (mime->id != AV_CODEC_ID_NONE) {
if (!strncmp(mime->str, mimetype, sizeof(mimetype))) {
id = mime->id;
break;
}
mime++;
}
if (id == AV_CODEC_ID_NONE) {
av_log(s, AV_LOG_ERROR, "Unknown attached picture mimetype: %s.\n",
mimetype);
if (s->error_recognition & AV_EF_EXPLODE)
ret = AVERROR_INVALIDDATA;
goto fail;
}
/* picture description */
len = avio_rb32(pb);
if (len > 0) {
if (!(desc = av_malloc(len + 1))) {
ret = AVERROR(ENOMEM);
goto fail;
}
if (avio_read(pb, desc, len) != len) {
av_log(s, AV_LOG_ERROR, "Error reading attached picture description.\n");
if (s->error_recognition & AV_EF_EXPLODE)
ret = AVERROR(EIO);
goto fail;
}
desc[len] = 0;
}
/* picture metadata */
width = avio_rb32(pb);
height = avio_rb32(pb);
avio_skip(pb, 8);
/* picture data */
len = avio_rb32(pb);
if (len <= 0) {
av_log(s, AV_LOG_ERROR, "Invalid attached picture size: %d.\n", len);
if (s->error_recognition & AV_EF_EXPLODE)
ret = AVERROR_INVALIDDATA;
goto fail;
}
if (!(data = av_buffer_alloc(len))) {
ret = AVERROR(ENOMEM);
goto fail;
}
if (avio_read(pb, data->data, len) != len) {
av_log(s, AV_LOG_ERROR, "Error reading attached picture data.\n");
if (s->error_recognition & AV_EF_EXPLODE)
ret = AVERROR(EIO);
goto fail;
}
st = avformat_new_stream(s, NULL);
if (!st) {
ret = AVERROR(ENOMEM);
goto fail;
}
av_init_packet(&st->attached_pic);
st->attached_pic.buf = data;
st->attached_pic.data = data->data;
st->attached_pic.size = len;
st->attached_pic.stream_index = st->index;
st->attached_pic.flags |= AV_PKT_FLAG_KEY;
st->disposition |= AV_DISPOSITION_ATTACHED_PIC;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = id;
st->codec->width = width;
st->codec->height = height;
av_dict_set(&st->metadata, "comment", ff_id3v2_picture_types[type], 0);
if (desc)
av_dict_set(&st->metadata, "title", desc, AV_DICT_DONT_STRDUP_VAL);
av_freep(&pb);
return 0;
fail:
av_buffer_unref(&data);
av_freep(&desc);
av_freep(&pb);
return ret;
}
| true | FFmpeg | 0b66fb4505e0bb43de3797f63f3290f0188d67cc | int ff_flac_parse_picture(AVFormatContext *s, uint8_t *buf, int buf_size)
{
const CodecMime *mime = ff_id3v2_mime_tags;
enum AVCodecID id = AV_CODEC_ID_NONE;
AVBufferRef *data = NULL;
uint8_t mimetype[64], *desc = NULL;
AVIOContext *pb = NULL;
AVStream *st;
int type, width, height;
int len, ret = 0;
pb = avio_alloc_context(buf, buf_size, 0, NULL, NULL, NULL, NULL);
if (!pb)
return AVERROR(ENOMEM);
type = avio_rb32(pb);
if (type >= FF_ARRAY_ELEMS(ff_id3v2_picture_types) || type < 0) {
av_log(s, AV_LOG_ERROR, "Invalid picture type: %d.\n", type);
if (s->error_recognition & AV_EF_EXPLODE) {
ret = AVERROR_INVALIDDATA;
goto fail;
}
type = 0;
}
len = avio_rb32(pb);
if (len <= 0 ||
avio_read(pb, mimetype, FFMIN(len, sizeof(mimetype) - 1)) != len) {
av_log(s, AV_LOG_ERROR, "Could not read mimetype from an attached "
"picture.\n");
if (s->error_recognition & AV_EF_EXPLODE)
ret = AVERROR_INVALIDDATA;
goto fail;
}
mimetype[len] = 0;
while (mime->id != AV_CODEC_ID_NONE) {
if (!strncmp(mime->str, mimetype, sizeof(mimetype))) {
id = mime->id;
break;
}
mime++;
}
if (id == AV_CODEC_ID_NONE) {
av_log(s, AV_LOG_ERROR, "Unknown attached picture mimetype: %s.\n",
mimetype);
if (s->error_recognition & AV_EF_EXPLODE)
ret = AVERROR_INVALIDDATA;
goto fail;
}
len = avio_rb32(pb);
if (len > 0) {
if (!(desc = av_malloc(len + 1))) {
ret = AVERROR(ENOMEM);
goto fail;
}
if (avio_read(pb, desc, len) != len) {
av_log(s, AV_LOG_ERROR, "Error reading attached picture description.\n");
if (s->error_recognition & AV_EF_EXPLODE)
ret = AVERROR(EIO);
goto fail;
}
desc[len] = 0;
}
width = avio_rb32(pb);
height = avio_rb32(pb);
avio_skip(pb, 8);
len = avio_rb32(pb);
if (len <= 0) {
av_log(s, AV_LOG_ERROR, "Invalid attached picture size: %d.\n", len);
if (s->error_recognition & AV_EF_EXPLODE)
ret = AVERROR_INVALIDDATA;
goto fail;
}
if (!(data = av_buffer_alloc(len))) {
ret = AVERROR(ENOMEM);
goto fail;
}
if (avio_read(pb, data->data, len) != len) {
av_log(s, AV_LOG_ERROR, "Error reading attached picture data.\n");
if (s->error_recognition & AV_EF_EXPLODE)
ret = AVERROR(EIO);
goto fail;
}
st = avformat_new_stream(s, NULL);
if (!st) {
ret = AVERROR(ENOMEM);
goto fail;
}
av_init_packet(&st->attached_pic);
st->attached_pic.buf = data;
st->attached_pic.data = data->data;
st->attached_pic.size = len;
st->attached_pic.stream_index = st->index;
st->attached_pic.flags |= AV_PKT_FLAG_KEY;
st->disposition |= AV_DISPOSITION_ATTACHED_PIC;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = id;
st->codec->width = width;
st->codec->height = height;
av_dict_set(&st->metadata, "comment", ff_id3v2_picture_types[type], 0);
if (desc)
av_dict_set(&st->metadata, "title", desc, AV_DICT_DONT_STRDUP_VAL);
av_freep(&pb);
return 0;
fail:
av_buffer_unref(&data);
av_freep(&desc);
av_freep(&pb);
return ret;
}
| {
"code": [
" int type, width, height;",
" int len, ret = 0;",
" if (type >= FF_ARRAY_ELEMS(ff_id3v2_picture_types) || type < 0) {",
" if (len <= 0 ||",
" if (len <= 0) {"
],
"line_no": [
17,
19,
35,
57,
155
]
} | int FUNC_0(AVFormatContext *VAR_0, uint8_t *VAR_1, int VAR_2)
{
const CodecMime *VAR_3 = ff_id3v2_mime_tags;
enum AVCodecID VAR_4 = AV_CODEC_ID_NONE;
AVBufferRef *data = NULL;
uint8_t mimetype[64], *desc = NULL;
AVIOContext *pb = NULL;
AVStream *st;
int VAR_5, VAR_6, VAR_7;
int VAR_8, VAR_9 = 0;
pb = avio_alloc_context(VAR_1, VAR_2, 0, NULL, NULL, NULL, NULL);
if (!pb)
return AVERROR(ENOMEM);
VAR_5 = avio_rb32(pb);
if (VAR_5 >= FF_ARRAY_ELEMS(ff_id3v2_picture_types) || VAR_5 < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid picture VAR_5: %d.\n", VAR_5);
if (VAR_0->error_recognition & AV_EF_EXPLODE) {
VAR_9 = AVERROR_INVALIDDATA;
goto fail;
}
VAR_5 = 0;
}
VAR_8 = avio_rb32(pb);
if (VAR_8 <= 0 ||
avio_read(pb, mimetype, FFMIN(VAR_8, sizeof(mimetype) - 1)) != VAR_8) {
av_log(VAR_0, AV_LOG_ERROR, "Could not read mimetype from an attached "
"picture.\n");
if (VAR_0->error_recognition & AV_EF_EXPLODE)
VAR_9 = AVERROR_INVALIDDATA;
goto fail;
}
mimetype[VAR_8] = 0;
while (VAR_3->VAR_4 != AV_CODEC_ID_NONE) {
if (!strncmp(VAR_3->str, mimetype, sizeof(mimetype))) {
VAR_4 = VAR_3->VAR_4;
break;
}
VAR_3++;
}
if (VAR_4 == AV_CODEC_ID_NONE) {
av_log(VAR_0, AV_LOG_ERROR, "Unknown attached picture mimetype: %VAR_0.\n",
mimetype);
if (VAR_0->error_recognition & AV_EF_EXPLODE)
VAR_9 = AVERROR_INVALIDDATA;
goto fail;
}
VAR_8 = avio_rb32(pb);
if (VAR_8 > 0) {
if (!(desc = av_malloc(VAR_8 + 1))) {
VAR_9 = AVERROR(ENOMEM);
goto fail;
}
if (avio_read(pb, desc, VAR_8) != VAR_8) {
av_log(VAR_0, AV_LOG_ERROR, "Error reading attached picture description.\n");
if (VAR_0->error_recognition & AV_EF_EXPLODE)
VAR_9 = AVERROR(EIO);
goto fail;
}
desc[VAR_8] = 0;
}
VAR_6 = avio_rb32(pb);
VAR_7 = avio_rb32(pb);
avio_skip(pb, 8);
VAR_8 = avio_rb32(pb);
if (VAR_8 <= 0) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid attached picture size: %d.\n", VAR_8);
if (VAR_0->error_recognition & AV_EF_EXPLODE)
VAR_9 = AVERROR_INVALIDDATA;
goto fail;
}
if (!(data = av_buffer_alloc(VAR_8))) {
VAR_9 = AVERROR(ENOMEM);
goto fail;
}
if (avio_read(pb, data->data, VAR_8) != VAR_8) {
av_log(VAR_0, AV_LOG_ERROR, "Error reading attached picture data.\n");
if (VAR_0->error_recognition & AV_EF_EXPLODE)
VAR_9 = AVERROR(EIO);
goto fail;
}
st = avformat_new_stream(VAR_0, NULL);
if (!st) {
VAR_9 = AVERROR(ENOMEM);
goto fail;
}
av_init_packet(&st->attached_pic);
st->attached_pic.VAR_1 = data;
st->attached_pic.data = data->data;
st->attached_pic.size = VAR_8;
st->attached_pic.stream_index = st->index;
st->attached_pic.flags |= AV_PKT_FLAG_KEY;
st->disposition |= AV_DISPOSITION_ATTACHED_PIC;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = VAR_4;
st->codec->VAR_6 = VAR_6;
st->codec->VAR_7 = VAR_7;
av_dict_set(&st->metadata, "comment", ff_id3v2_picture_types[VAR_5], 0);
if (desc)
av_dict_set(&st->metadata, "title", desc, AV_DICT_DONT_STRDUP_VAL);
av_freep(&pb);
return 0;
fail:
av_buffer_unref(&data);
av_freep(&desc);
av_freep(&pb);
return VAR_9;
}
| [
"int FUNC_0(AVFormatContext *VAR_0, uint8_t *VAR_1, int VAR_2)\n{",
"const CodecMime *VAR_3 = ff_id3v2_mime_tags;",
"enum AVCodecID VAR_4 = AV_CODEC_ID_NONE;",
"AVBufferRef *data = NULL;",
"uint8_t mimetype[64], *desc = NULL;",
"AVIOContext *pb = NULL;",
"AVStream *st;",
"int VAR_5, VAR_6, VAR_7;",
"int VAR_8, VAR_9 = 0;",
"pb = avio_alloc_context(VAR_1, VAR_2, 0, NULL, NULL, NULL, NULL);",
"if (!pb)\nreturn AVERROR(ENOMEM);",
"VAR_5 = avio_rb32(pb);",
"if (VAR_5 >= FF_ARRAY_ELEMS(ff_id3v2_picture_types) || VAR_5 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid picture VAR_5: %d.\\n\", VAR_5);",
"if (VAR_0->error_recognition & AV_EF_EXPLODE) {",
"VAR_9 = AVERROR_INVALIDDATA;",
"goto fail;",
"}",
"VAR_5 = 0;",
"}",
"VAR_8 = avio_rb32(pb);",
"if (VAR_8 <= 0 ||\navio_read(pb, mimetype, FFMIN(VAR_8, sizeof(mimetype) - 1)) != VAR_8) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Could not read mimetype from an attached \"\n\"picture.\\n\");",
"if (VAR_0->error_recognition & AV_EF_EXPLODE)\nVAR_9 = AVERROR_INVALIDDATA;",
"goto fail;",
"}",
"mimetype[VAR_8] = 0;",
"while (VAR_3->VAR_4 != AV_CODEC_ID_NONE) {",
"if (!strncmp(VAR_3->str, mimetype, sizeof(mimetype))) {",
"VAR_4 = VAR_3->VAR_4;",
"break;",
"}",
"VAR_3++;",
"}",
"if (VAR_4 == AV_CODEC_ID_NONE) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Unknown attached picture mimetype: %VAR_0.\\n\",\nmimetype);",
"if (VAR_0->error_recognition & AV_EF_EXPLODE)\nVAR_9 = AVERROR_INVALIDDATA;",
"goto fail;",
"}",
"VAR_8 = avio_rb32(pb);",
"if (VAR_8 > 0) {",
"if (!(desc = av_malloc(VAR_8 + 1))) {",
"VAR_9 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"if (avio_read(pb, desc, VAR_8) != VAR_8) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Error reading attached picture description.\\n\");",
"if (VAR_0->error_recognition & AV_EF_EXPLODE)\nVAR_9 = AVERROR(EIO);",
"goto fail;",
"}",
"desc[VAR_8] = 0;",
"}",
"VAR_6 = avio_rb32(pb);",
"VAR_7 = avio_rb32(pb);",
"avio_skip(pb, 8);",
"VAR_8 = avio_rb32(pb);",
"if (VAR_8 <= 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid attached picture size: %d.\\n\", VAR_8);",
"if (VAR_0->error_recognition & AV_EF_EXPLODE)\nVAR_9 = AVERROR_INVALIDDATA;",
"goto fail;",
"}",
"if (!(data = av_buffer_alloc(VAR_8))) {",
"VAR_9 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"if (avio_read(pb, data->data, VAR_8) != VAR_8) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Error reading attached picture data.\\n\");",
"if (VAR_0->error_recognition & AV_EF_EXPLODE)\nVAR_9 = AVERROR(EIO);",
"goto fail;",
"}",
"st = avformat_new_stream(VAR_0, NULL);",
"if (!st) {",
"VAR_9 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"av_init_packet(&st->attached_pic);",
"st->attached_pic.VAR_1 = data;",
"st->attached_pic.data = data->data;",
"st->attached_pic.size = VAR_8;",
"st->attached_pic.stream_index = st->index;",
"st->attached_pic.flags |= AV_PKT_FLAG_KEY;",
"st->disposition |= AV_DISPOSITION_ATTACHED_PIC;",
"st->codec->codec_type = AVMEDIA_TYPE_VIDEO;",
"st->codec->codec_id = VAR_4;",
"st->codec->VAR_6 = VAR_6;",
"st->codec->VAR_7 = VAR_7;",
"av_dict_set(&st->metadata, \"comment\", ff_id3v2_picture_types[VAR_5], 0);",
"if (desc)\nav_dict_set(&st->metadata, \"title\", desc, AV_DICT_DONT_STRDUP_VAL);",
"av_freep(&pb);",
"return 0;",
"fail:\nav_buffer_unref(&data);",
"av_freep(&desc);",
"av_freep(&pb);",
"return VAR_9;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
1,
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,
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25,
27
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
55
],
[
57,
59
],
[
61,
63
],
[
65,
67
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93,
95
],
[
97,
99
],
[
101
],
[
103
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
123
],
[
125
],
[
127,
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
143
],
[
145
],
[
147
],
[
153
],
[
155
],
[
157
],
[
159,
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179,
181
],
[
183
],
[
185
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227,
229
],
[
233
],
[
237
],
[
241,
243
],
[
245
],
[
247
],
[
251
],
[
253
]
] |
21,186 | int avpriv_mpegaudio_decode_header(MPADecodeHeader *s, uint32_t header)
{
int sample_rate, frame_size, mpeg25, padding;
int sample_rate_index, bitrate_index;
if (header & (1<<20)) {
s->lsf = (header & (1<<19)) ? 0 : 1;
mpeg25 = 0;
} else {
s->lsf = 1;
mpeg25 = 1;
}
s->layer = 4 - ((header >> 17) & 3);
/* extract frequency */
sample_rate_index = (header >> 10) & 3;
sample_rate = avpriv_mpa_freq_tab[sample_rate_index] >> (s->lsf + mpeg25);
sample_rate_index += 3 * (s->lsf + mpeg25);
s->sample_rate_index = sample_rate_index;
s->error_protection = ((header >> 16) & 1) ^ 1;
s->sample_rate = sample_rate;
bitrate_index = (header >> 12) & 0xf;
padding = (header >> 9) & 1;
//extension = (header >> 8) & 1;
s->mode = (header >> 6) & 3;
s->mode_ext = (header >> 4) & 3;
//copyright = (header >> 3) & 1;
//original = (header >> 2) & 1;
//emphasis = header & 3;
if (s->mode == MPA_MONO)
s->nb_channels = 1;
else
s->nb_channels = 2;
if (bitrate_index != 0) {
frame_size = avpriv_mpa_bitrate_tab[s->lsf][s->layer - 1][bitrate_index];
s->bit_rate = frame_size * 1000;
switch(s->layer) {
case 1:
frame_size = (frame_size * 12000) / sample_rate;
frame_size = (frame_size + padding) * 4;
break;
case 2:
frame_size = (frame_size * 144000) / sample_rate;
frame_size += padding;
break;
default:
case 3:
frame_size = (frame_size * 144000) / (sample_rate << s->lsf);
frame_size += padding;
break;
}
s->frame_size = frame_size;
} else {
/* if no frame size computed, signal it */
return 1;
}
#if defined(DEBUG)
av_dlog(NULL, "layer%d, %d Hz, %d kbits/s, ",
s->layer, s->sample_rate, s->bit_rate);
if (s->nb_channels == 2) {
if (s->layer == 3) {
if (s->mode_ext & MODE_EXT_MS_STEREO)
av_dlog(NULL, "ms-");
if (s->mode_ext & MODE_EXT_I_STEREO)
av_dlog(NULL, "i-");
}
av_dlog(NULL, "stereo");
} else {
av_dlog(NULL, "mono");
}
av_dlog(NULL, "\n");
#endif
return 0;
} | true | FFmpeg | 44127546b0a81dc9dd6190739a62d48f0044c6f3 | int avpriv_mpegaudio_decode_header(MPADecodeHeader *s, uint32_t header)
{
int sample_rate, frame_size, mpeg25, padding;
int sample_rate_index, bitrate_index;
if (header & (1<<20)) {
s->lsf = (header & (1<<19)) ? 0 : 1;
mpeg25 = 0;
} else {
s->lsf = 1;
mpeg25 = 1;
}
s->layer = 4 - ((header >> 17) & 3);
sample_rate_index = (header >> 10) & 3;
sample_rate = avpriv_mpa_freq_tab[sample_rate_index] >> (s->lsf + mpeg25);
sample_rate_index += 3 * (s->lsf + mpeg25);
s->sample_rate_index = sample_rate_index;
s->error_protection = ((header >> 16) & 1) ^ 1;
s->sample_rate = sample_rate;
bitrate_index = (header >> 12) & 0xf;
padding = (header >> 9) & 1;
s->mode = (header >> 6) & 3;
s->mode_ext = (header >> 4) & 3;
if (s->mode == MPA_MONO)
s->nb_channels = 1;
else
s->nb_channels = 2;
if (bitrate_index != 0) {
frame_size = avpriv_mpa_bitrate_tab[s->lsf][s->layer - 1][bitrate_index];
s->bit_rate = frame_size * 1000;
switch(s->layer) {
case 1:
frame_size = (frame_size * 12000) / sample_rate;
frame_size = (frame_size + padding) * 4;
break;
case 2:
frame_size = (frame_size * 144000) / sample_rate;
frame_size += padding;
break;
default:
case 3:
frame_size = (frame_size * 144000) / (sample_rate << s->lsf);
frame_size += padding;
break;
}
s->frame_size = frame_size;
} else {
return 1;
}
#if defined(DEBUG)
av_dlog(NULL, "layer%d, %d Hz, %d kbits/s, ",
s->layer, s->sample_rate, s->bit_rate);
if (s->nb_channels == 2) {
if (s->layer == 3) {
if (s->mode_ext & MODE_EXT_MS_STEREO)
av_dlog(NULL, "ms-");
if (s->mode_ext & MODE_EXT_I_STEREO)
av_dlog(NULL, "i-");
}
av_dlog(NULL, "stereo");
} else {
av_dlog(NULL, "mono");
}
av_dlog(NULL, "\n");
#endif
return 0;
} | {
"code": [],
"line_no": []
} | int FUNC_0(MPADecodeHeader *VAR_0, uint32_t VAR_1)
{
int VAR_2, VAR_3, VAR_4, VAR_5;
int VAR_6, VAR_7;
if (VAR_1 & (1<<20)) {
VAR_0->lsf = (VAR_1 & (1<<19)) ? 0 : 1;
VAR_4 = 0;
} else {
VAR_0->lsf = 1;
VAR_4 = 1;
}
VAR_0->layer = 4 - ((VAR_1 >> 17) & 3);
VAR_6 = (VAR_1 >> 10) & 3;
VAR_2 = avpriv_mpa_freq_tab[VAR_6] >> (VAR_0->lsf + VAR_4);
VAR_6 += 3 * (VAR_0->lsf + VAR_4);
VAR_0->VAR_6 = VAR_6;
VAR_0->error_protection = ((VAR_1 >> 16) & 1) ^ 1;
VAR_0->VAR_2 = VAR_2;
VAR_7 = (VAR_1 >> 12) & 0xf;
VAR_5 = (VAR_1 >> 9) & 1;
VAR_0->mode = (VAR_1 >> 6) & 3;
VAR_0->mode_ext = (VAR_1 >> 4) & 3;
if (VAR_0->mode == MPA_MONO)
VAR_0->nb_channels = 1;
else
VAR_0->nb_channels = 2;
if (VAR_7 != 0) {
VAR_3 = avpriv_mpa_bitrate_tab[VAR_0->lsf][VAR_0->layer - 1][VAR_7];
VAR_0->bit_rate = VAR_3 * 1000;
switch(VAR_0->layer) {
case 1:
VAR_3 = (VAR_3 * 12000) / VAR_2;
VAR_3 = (VAR_3 + VAR_5) * 4;
break;
case 2:
VAR_3 = (VAR_3 * 144000) / VAR_2;
VAR_3 += VAR_5;
break;
default:
case 3:
VAR_3 = (VAR_3 * 144000) / (VAR_2 << VAR_0->lsf);
VAR_3 += VAR_5;
break;
}
VAR_0->VAR_3 = VAR_3;
} else {
return 1;
}
#if defined(DEBUG)
av_dlog(NULL, "layer%d, %d Hz, %d kbits/VAR_0, ",
VAR_0->layer, VAR_0->VAR_2, VAR_0->bit_rate);
if (VAR_0->nb_channels == 2) {
if (VAR_0->layer == 3) {
if (VAR_0->mode_ext & MODE_EXT_MS_STEREO)
av_dlog(NULL, "ms-");
if (VAR_0->mode_ext & MODE_EXT_I_STEREO)
av_dlog(NULL, "i-");
}
av_dlog(NULL, "stereo");
} else {
av_dlog(NULL, "mono");
}
av_dlog(NULL, "\n");
#endif
return 0;
} | [
"int FUNC_0(MPADecodeHeader *VAR_0, uint32_t VAR_1)\n{",
"int VAR_2, VAR_3, VAR_4, VAR_5;",
"int VAR_6, VAR_7;",
"if (VAR_1 & (1<<20)) {",
"VAR_0->lsf = (VAR_1 & (1<<19)) ? 0 : 1;",
"VAR_4 = 0;",
"} else {",
"VAR_0->lsf = 1;",
"VAR_4 = 1;",
"}",
"VAR_0->layer = 4 - ((VAR_1 >> 17) & 3);",
"VAR_6 = (VAR_1 >> 10) & 3;",
"VAR_2 = avpriv_mpa_freq_tab[VAR_6] >> (VAR_0->lsf + VAR_4);",
"VAR_6 += 3 * (VAR_0->lsf + VAR_4);",
"VAR_0->VAR_6 = VAR_6;",
"VAR_0->error_protection = ((VAR_1 >> 16) & 1) ^ 1;",
"VAR_0->VAR_2 = VAR_2;",
"VAR_7 = (VAR_1 >> 12) & 0xf;",
"VAR_5 = (VAR_1 >> 9) & 1;",
"VAR_0->mode = (VAR_1 >> 6) & 3;",
"VAR_0->mode_ext = (VAR_1 >> 4) & 3;",
"if (VAR_0->mode == MPA_MONO)\nVAR_0->nb_channels = 1;",
"else\nVAR_0->nb_channels = 2;",
"if (VAR_7 != 0) {",
"VAR_3 = avpriv_mpa_bitrate_tab[VAR_0->lsf][VAR_0->layer - 1][VAR_7];",
"VAR_0->bit_rate = VAR_3 * 1000;",
"switch(VAR_0->layer) {",
"case 1:\nVAR_3 = (VAR_3 * 12000) / VAR_2;",
"VAR_3 = (VAR_3 + VAR_5) * 4;",
"break;",
"case 2:\nVAR_3 = (VAR_3 * 144000) / VAR_2;",
"VAR_3 += VAR_5;",
"break;",
"default:\ncase 3:\nVAR_3 = (VAR_3 * 144000) / (VAR_2 << VAR_0->lsf);",
"VAR_3 += VAR_5;",
"break;",
"}",
"VAR_0->VAR_3 = VAR_3;",
"} else {",
"return 1;",
"}",
"#if defined(DEBUG)\nav_dlog(NULL, \"layer%d, %d Hz, %d kbits/VAR_0, \",\nVAR_0->layer, VAR_0->VAR_2, VAR_0->bit_rate);",
"if (VAR_0->nb_channels == 2) {",
"if (VAR_0->layer == 3) {",
"if (VAR_0->mode_ext & MODE_EXT_MS_STEREO)\nav_dlog(NULL, \"ms-\");",
"if (VAR_0->mode_ext & MODE_EXT_I_STEREO)\nav_dlog(NULL, \"i-\");",
"}",
"av_dlog(NULL, \"stereo\");",
"} else {",
"av_dlog(NULL, \"mono\");",
"}",
"av_dlog(NULL, \"\\n\");",
"#endif\nreturn 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
51
],
[
53
],
[
63,
65
],
[
67,
69
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81,
83
],
[
85
],
[
87
],
[
89,
91
],
[
93
],
[
95
],
[
97,
99,
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
115
],
[
117
],
[
121,
123,
125
],
[
127
],
[
129
],
[
131,
133
],
[
135,
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151,
153
],
[
155
]
] |
21,187 | static int vhost_set_vring(struct vhost_dev *dev,
unsigned long int request,
struct vhost_vring_state *ring)
{
VhostUserMsg msg = {
.request = request,
.flags = VHOST_USER_VERSION,
.state = *ring,
.size = sizeof(*ring),
};
vhost_user_write(dev, &msg, NULL, 0);
return 0;
}
| true | qemu | 7f4a930e64b9e69cd340395a7e4f0494aef4fcdd | static int vhost_set_vring(struct vhost_dev *dev,
unsigned long int request,
struct vhost_vring_state *ring)
{
VhostUserMsg msg = {
.request = request,
.flags = VHOST_USER_VERSION,
.state = *ring,
.size = sizeof(*ring),
};
vhost_user_write(dev, &msg, NULL, 0);
return 0;
}
| {
"code": [
" };",
" .state = *ring,",
" .state = *ring,"
],
"line_no": [
19,
15,
15
]
} | static int FUNC_0(struct vhost_dev *VAR_0,
unsigned long int VAR_1,
struct vhost_vring_state *VAR_2)
{
VhostUserMsg msg = {
.VAR_1 = VAR_1,
.flags = VHOST_USER_VERSION,
.state = *VAR_2,
.size = sizeof(*VAR_2),
};
vhost_user_write(VAR_0, &msg, NULL, 0);
return 0;
}
| [
"static int FUNC_0(struct vhost_dev *VAR_0,\nunsigned long int VAR_1,\nstruct vhost_vring_state *VAR_2)\n{",
"VhostUserMsg msg = {",
".VAR_1 = VAR_1,\n.flags = VHOST_USER_VERSION,\n.state = *VAR_2,\n.size = sizeof(*VAR_2),\n};",
"vhost_user_write(VAR_0, &msg, NULL, 0);",
"return 0;",
"}"
] | [
0,
0,
1,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11,
13,
15,
17,
19
],
[
23
],
[
27
],
[
29
]
] |
21,188 | static int encode_picture_lossless(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *pict, int *got_packet)
{
MpegEncContext * const s = avctx->priv_data;
MJpegContext * const m = s->mjpeg_ctx;
const int width= s->width;
const int height= s->height;
AVFrame * const p = &s->current_picture.f;
const int predictor= avctx->prediction_method+1;
const int mb_width = (width + s->mjpeg_hsample[0] - 1) / s->mjpeg_hsample[0];
const int mb_height = (height + s->mjpeg_vsample[0] - 1) / s->mjpeg_vsample[0];
int ret, max_pkt_size = FF_MIN_BUFFER_SIZE;
if (avctx->pix_fmt == AV_PIX_FMT_BGRA)
max_pkt_size += width * height * 3 * 4;
else {
max_pkt_size += mb_width * mb_height * 3 * 4
* s->mjpeg_hsample[0] * s->mjpeg_vsample[0];
if ((ret = ff_alloc_packet2(avctx, pkt, max_pkt_size)) < 0)
init_put_bits(&s->pb, pkt->data, pkt->size);
*p = *pict;
p->pict_type= AV_PICTURE_TYPE_I;
p->key_frame= 1;
ff_mjpeg_encode_picture_header(s);
s->header_bits= put_bits_count(&s->pb);
if(avctx->pix_fmt == AV_PIX_FMT_BGR0
|| avctx->pix_fmt == AV_PIX_FMT_BGRA
|| avctx->pix_fmt == AV_PIX_FMT_BGR24){
int x, y, i;
const int linesize= p->linesize[0];
uint16_t (*buffer)[4]= (void *) s->rd_scratchpad;
int left[3], top[3], topleft[3];
for(i=0; i<3; i++){
buffer[0][i]= 1 << (9 - 1);
for(y = 0; y < height; y++) {
const int modified_predictor= y ? predictor : 1;
uint8_t *ptr = p->data[0] + (linesize * y);
if(s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < width*3*4){
av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n");
return -1;
for(i=0; i<3; i++){
top[i]= left[i]= topleft[i]= buffer[0][i];
for(x = 0; x < width; x++) {
if(avctx->pix_fmt == AV_PIX_FMT_BGR24){
buffer[x][1] = ptr[3*x+0] - ptr[3*x+1] + 0x100;
buffer[x][2] = ptr[3*x+2] - ptr[3*x+1] + 0x100;
buffer[x][0] = (ptr[3*x+0] + 2*ptr[3*x+1] + ptr[3*x+2])>>2;
}else{
buffer[x][1] = ptr[4*x+0] - ptr[4*x+1] + 0x100;
buffer[x][2] = ptr[4*x+2] - ptr[4*x+1] + 0x100;
buffer[x][0] = (ptr[4*x+0] + 2*ptr[4*x+1] + ptr[4*x+2])>>2;
for(i=0;i<3;i++) {
int pred, diff;
PREDICT(pred, topleft[i], top[i], left[i], modified_predictor);
topleft[i]= top[i];
top[i]= buffer[x+1][i];
left[i]= buffer[x][i];
diff= ((left[i] - pred + 0x100)&0x1FF) - 0x100;
if(i==0)
ff_mjpeg_encode_dc(s, diff, m->huff_size_dc_luminance, m->huff_code_dc_luminance); //FIXME ugly
else
ff_mjpeg_encode_dc(s, diff, m->huff_size_dc_chrominance, m->huff_code_dc_chrominance);
}else{
int mb_x, mb_y, i;
for(mb_y = 0; mb_y < mb_height; mb_y++) {
if(s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < mb_width * 4 * 3 * s->mjpeg_hsample[0] * s->mjpeg_vsample[0]){
av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n");
return -1;
for(mb_x = 0; mb_x < mb_width; mb_x++) {
if(mb_x==0 || mb_y==0){
for(i=0;i<3;i++) {
uint8_t *ptr;
int x, y, h, v, linesize;
h = s->mjpeg_hsample[i];
v = s->mjpeg_vsample[i];
linesize= p->linesize[i];
for(y=0; y<v; y++){
for(x=0; x<h; x++){
int pred;
ptr = p->data[i] + (linesize * (v * mb_y + y)) + (h * mb_x + x); //FIXME optimize this crap
if(y==0 && mb_y==0){
if(x==0 && mb_x==0){
pred= 128;
}else{
pred= ptr[-1];
}else{
if(x==0 && mb_x==0){
pred= ptr[-linesize];
}else{
PREDICT(pred, ptr[-linesize-1], ptr[-linesize], ptr[-1], predictor);
if(i==0)
ff_mjpeg_encode_dc(s, *ptr - pred, m->huff_size_dc_luminance, m->huff_code_dc_luminance); //FIXME ugly
else
ff_mjpeg_encode_dc(s, *ptr - pred, m->huff_size_dc_chrominance, m->huff_code_dc_chrominance);
}else{
for(i=0;i<3;i++) {
uint8_t *ptr;
int x, y, h, v, linesize;
h = s->mjpeg_hsample[i];
v = s->mjpeg_vsample[i];
linesize= p->linesize[i];
for(y=0; y<v; y++){
for(x=0; x<h; x++){
int pred;
ptr = p->data[i] + (linesize * (v * mb_y + y)) + (h * mb_x + x); //FIXME optimize this crap
PREDICT(pred, ptr[-linesize-1], ptr[-linesize], ptr[-1], predictor);
if(i==0)
ff_mjpeg_encode_dc(s, *ptr - pred, m->huff_size_dc_luminance, m->huff_code_dc_luminance); //FIXME ugly
else
ff_mjpeg_encode_dc(s, *ptr - pred, m->huff_size_dc_chrominance, m->huff_code_dc_chrominance);
emms_c();
av_assert0(s->esc_pos == s->header_bits >> 3);
ff_mjpeg_encode_stuffing(s);
ff_mjpeg_encode_picture_trailer(s);
s->picture_number++;
flush_put_bits(&s->pb);
pkt->size = put_bits_ptr(&s->pb) - s->pb.buf;
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
// return (put_bits_count(&f->pb)+7)/8; | true | FFmpeg | c2dd5a18b27bb33d871d41fbed9104f3a68d68fe | static int encode_picture_lossless(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *pict, int *got_packet)
{
MpegEncContext * const s = avctx->priv_data;
MJpegContext * const m = s->mjpeg_ctx;
const int width= s->width;
const int height= s->height;
AVFrame * const p = &s->current_picture.f;
const int predictor= avctx->prediction_method+1;
const int mb_width = (width + s->mjpeg_hsample[0] - 1) / s->mjpeg_hsample[0];
const int mb_height = (height + s->mjpeg_vsample[0] - 1) / s->mjpeg_vsample[0];
int ret, max_pkt_size = FF_MIN_BUFFER_SIZE;
if (avctx->pix_fmt == AV_PIX_FMT_BGRA)
max_pkt_size += width * height * 3 * 4;
else {
max_pkt_size += mb_width * mb_height * 3 * 4
* s->mjpeg_hsample[0] * s->mjpeg_vsample[0];
if ((ret = ff_alloc_packet2(avctx, pkt, max_pkt_size)) < 0)
init_put_bits(&s->pb, pkt->data, pkt->size);
*p = *pict;
p->pict_type= AV_PICTURE_TYPE_I;
p->key_frame= 1;
ff_mjpeg_encode_picture_header(s);
s->header_bits= put_bits_count(&s->pb);
if(avctx->pix_fmt == AV_PIX_FMT_BGR0
|| avctx->pix_fmt == AV_PIX_FMT_BGRA
|| avctx->pix_fmt == AV_PIX_FMT_BGR24){
int x, y, i;
const int linesize= p->linesize[0];
uint16_t (*buffer)[4]= (void *) s->rd_scratchpad;
int left[3], top[3], topleft[3];
for(i=0; i<3; i++){
buffer[0][i]= 1 << (9 - 1);
for(y = 0; y < height; y++) {
const int modified_predictor= y ? predictor : 1;
uint8_t *ptr = p->data[0] + (linesize * y);
if(s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < width*3*4){
av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n");
return -1;
for(i=0; i<3; i++){
top[i]= left[i]= topleft[i]= buffer[0][i];
for(x = 0; x < width; x++) {
if(avctx->pix_fmt == AV_PIX_FMT_BGR24){
buffer[x][1] = ptr[3*x+0] - ptr[3*x+1] + 0x100;
buffer[x][2] = ptr[3*x+2] - ptr[3*x+1] + 0x100;
buffer[x][0] = (ptr[3*x+0] + 2*ptr[3*x+1] + ptr[3*x+2])>>2;
}else{
buffer[x][1] = ptr[4*x+0] - ptr[4*x+1] + 0x100;
buffer[x][2] = ptr[4*x+2] - ptr[4*x+1] + 0x100;
buffer[x][0] = (ptr[4*x+0] + 2*ptr[4*x+1] + ptr[4*x+2])>>2;
for(i=0;i<3;i++) {
int pred, diff;
PREDICT(pred, topleft[i], top[i], left[i], modified_predictor);
topleft[i]= top[i];
top[i]= buffer[x+1][i];
left[i]= buffer[x][i];
diff= ((left[i] - pred + 0x100)&0x1FF) - 0x100;
if(i==0)
ff_mjpeg_encode_dc(s, diff, m->huff_size_dc_luminance, m->huff_code_dc_luminance);
else
ff_mjpeg_encode_dc(s, diff, m->huff_size_dc_chrominance, m->huff_code_dc_chrominance);
}else{
int mb_x, mb_y, i;
for(mb_y = 0; mb_y < mb_height; mb_y++) {
if(s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < mb_width * 4 * 3 * s->mjpeg_hsample[0] * s->mjpeg_vsample[0]){
av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n");
return -1;
for(mb_x = 0; mb_x < mb_width; mb_x++) {
if(mb_x==0 || mb_y==0){
for(i=0;i<3;i++) {
uint8_t *ptr;
int x, y, h, v, linesize;
h = s->mjpeg_hsample[i];
v = s->mjpeg_vsample[i];
linesize= p->linesize[i];
for(y=0; y<v; y++){
for(x=0; x<h; x++){
int pred;
ptr = p->data[i] + (linesize * (v * mb_y + y)) + (h * mb_x + x);
if(y==0 && mb_y==0){
if(x==0 && mb_x==0){
pred= 128;
}else{
pred= ptr[-1];
}else{
if(x==0 && mb_x==0){
pred= ptr[-linesize];
}else{
PREDICT(pred, ptr[-linesize-1], ptr[-linesize], ptr[-1], predictor);
if(i==0)
ff_mjpeg_encode_dc(s, *ptr - pred, m->huff_size_dc_luminance, m->huff_code_dc_luminance);
else
ff_mjpeg_encode_dc(s, *ptr - pred, m->huff_size_dc_chrominance, m->huff_code_dc_chrominance);
}else{
for(i=0;i<3;i++) {
uint8_t *ptr;
int x, y, h, v, linesize;
h = s->mjpeg_hsample[i];
v = s->mjpeg_vsample[i];
linesize= p->linesize[i];
for(y=0; y<v; y++){
for(x=0; x<h; x++){
int pred;
ptr = p->data[i] + (linesize * (v * mb_y + y)) + (h * mb_x + x);
PREDICT(pred, ptr[-linesize-1], ptr[-linesize], ptr[-1], predictor);
if(i==0)
ff_mjpeg_encode_dc(s, *ptr - pred, m->huff_size_dc_luminance, m->huff_code_dc_luminance);
else
ff_mjpeg_encode_dc(s, *ptr - pred, m->huff_size_dc_chrominance, m->huff_code_dc_chrominance);
emms_c();
av_assert0(s->esc_pos == s->header_bits >> 3);
ff_mjpeg_encode_stuffing(s);
ff_mjpeg_encode_picture_trailer(s);
s->picture_number++;
flush_put_bits(&s->pb);
pkt->size = put_bits_ptr(&s->pb) - s->pb.buf;
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,
const AVFrame *VAR_2, int *VAR_3)
{
MpegEncContext * const s = VAR_0->priv_data;
MJpegContext * const m = s->mjpeg_ctx;
const int VAR_4= s->VAR_4;
const int VAR_5= s->VAR_5;
AVFrame * const p = &s->current_picture.f;
const int VAR_6= VAR_0->prediction_method+1;
const int VAR_7 = (VAR_4 + s->mjpeg_hsample[0] - 1) / s->mjpeg_hsample[0];
const int VAR_8 = (VAR_5 + s->mjpeg_vsample[0] - 1) / s->mjpeg_vsample[0];
int VAR_9, VAR_10 = FF_MIN_BUFFER_SIZE;
if (VAR_0->pix_fmt == AV_PIX_FMT_BGRA)
VAR_10 += VAR_4 * VAR_5 * 3 * 4;
else {
VAR_10 += VAR_7 * VAR_8 * 3 * 4
* s->mjpeg_hsample[0] * s->mjpeg_vsample[0];
if ((VAR_9 = ff_alloc_packet2(VAR_0, VAR_1, VAR_10)) < 0)
init_put_bits(&s->pb, VAR_1->data, VAR_1->size);
*p = *VAR_2;
p->pict_type= AV_PICTURE_TYPE_I;
p->key_frame= 1;
ff_mjpeg_encode_picture_header(s);
s->header_bits= put_bits_count(&s->pb);
if(VAR_0->pix_fmt == AV_PIX_FMT_BGR0
|| VAR_0->pix_fmt == AV_PIX_FMT_BGRA
|| VAR_0->pix_fmt == AV_PIX_FMT_BGR24){
int VAR_11, VAR_12, VAR_13;
const int VAR_14= p->VAR_14[0];
uint16_t (*buffer)[4]= (void *) s->rd_scratchpad;
int VAR_15[3], VAR_16[3], VAR_17[3];
for(VAR_13=0; VAR_13<3; VAR_13++){
buffer[0][VAR_13]= 1 << (9 - 1);
for(VAR_12 = 0; VAR_12 < VAR_5; VAR_12++) {
const int VAR_18= VAR_12 ? VAR_6 : 1;
uint8_t *ptr = p->data[0] + (VAR_14 * VAR_12);
if(s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < VAR_4*3*4){
av_log(s->VAR_0, AV_LOG_ERROR, "encoded frame too large\n");
return -1;
for(VAR_13=0; VAR_13<3; VAR_13++){
VAR_16[VAR_13]= VAR_15[VAR_13]= VAR_17[VAR_13]= buffer[0][VAR_13];
for(VAR_11 = 0; VAR_11 < VAR_4; VAR_11++) {
if(VAR_0->pix_fmt == AV_PIX_FMT_BGR24){
buffer[VAR_11][1] = ptr[3*VAR_11+0] - ptr[3*VAR_11+1] + 0x100;
buffer[VAR_11][2] = ptr[3*VAR_11+2] - ptr[3*VAR_11+1] + 0x100;
buffer[VAR_11][0] = (ptr[3*VAR_11+0] + 2*ptr[3*VAR_11+1] + ptr[3*VAR_11+2])>>2;
}else{
buffer[VAR_11][1] = ptr[4*VAR_11+0] - ptr[4*VAR_11+1] + 0x100;
buffer[VAR_11][2] = ptr[4*VAR_11+2] - ptr[4*VAR_11+1] + 0x100;
buffer[VAR_11][0] = (ptr[4*VAR_11+0] + 2*ptr[4*VAR_11+1] + ptr[4*VAR_11+2])>>2;
for(VAR_13=0;VAR_13<3;VAR_13++) {
int VAR_19, VAR_20;
PREDICT(VAR_19, VAR_17[VAR_13], VAR_16[VAR_13], VAR_15[VAR_13], VAR_18);
VAR_17[VAR_13]= VAR_16[VAR_13];
VAR_16[VAR_13]= buffer[VAR_11+1][VAR_13];
VAR_15[VAR_13]= buffer[VAR_11][VAR_13];
VAR_20= ((VAR_15[VAR_13] - VAR_19 + 0x100)&0x1FF) - 0x100;
if(VAR_13==0)
ff_mjpeg_encode_dc(s, VAR_20, m->huff_size_dc_luminance, m->huff_code_dc_luminance);
else
ff_mjpeg_encode_dc(s, VAR_20, m->huff_size_dc_chrominance, m->huff_code_dc_chrominance);
}else{
int mb_x, mb_y, VAR_13;
for(mb_y = 0; mb_y < VAR_8; mb_y++) {
if(s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < VAR_7 * 4 * 3 * s->mjpeg_hsample[0] * s->mjpeg_vsample[0]){
av_log(s->VAR_0, AV_LOG_ERROR, "encoded frame too large\n");
return -1;
for(mb_x = 0; mb_x < VAR_7; mb_x++) {
if(mb_x==0 || mb_y==0){
for(VAR_13=0;VAR_13<3;VAR_13++) {
uint8_t *ptr;
int VAR_11, VAR_12, h, v, VAR_14;
h = s->mjpeg_hsample[VAR_13];
v = s->mjpeg_vsample[VAR_13];
VAR_14= p->VAR_14[VAR_13];
for(VAR_12=0; VAR_12<v; VAR_12++){
for(VAR_11=0; VAR_11<h; VAR_11++){
int VAR_19;
ptr = p->data[VAR_13] + (VAR_14 * (v * mb_y + VAR_12)) + (h * mb_x + VAR_11);
if(VAR_12==0 && mb_y==0){
if(VAR_11==0 && mb_x==0){
VAR_19= 128;
}else{
VAR_19= ptr[-1];
}else{
if(VAR_11==0 && mb_x==0){
VAR_19= ptr[-VAR_14];
}else{
PREDICT(VAR_19, ptr[-VAR_14-1], ptr[-VAR_14], ptr[-1], VAR_6);
if(VAR_13==0)
ff_mjpeg_encode_dc(s, *ptr - VAR_19, m->huff_size_dc_luminance, m->huff_code_dc_luminance);
else
ff_mjpeg_encode_dc(s, *ptr - VAR_19, m->huff_size_dc_chrominance, m->huff_code_dc_chrominance);
}else{
for(VAR_13=0;VAR_13<3;VAR_13++) {
uint8_t *ptr;
int VAR_11, VAR_12, h, v, VAR_14;
h = s->mjpeg_hsample[VAR_13];
v = s->mjpeg_vsample[VAR_13];
VAR_14= p->VAR_14[VAR_13];
for(VAR_12=0; VAR_12<v; VAR_12++){
for(VAR_11=0; VAR_11<h; VAR_11++){
int VAR_19;
ptr = p->data[VAR_13] + (VAR_14 * (v * mb_y + VAR_12)) + (h * mb_x + VAR_11);
PREDICT(VAR_19, ptr[-VAR_14-1], ptr[-VAR_14], ptr[-1], VAR_6);
if(VAR_13==0)
ff_mjpeg_encode_dc(s, *ptr - VAR_19, m->huff_size_dc_luminance, m->huff_code_dc_luminance);
else
ff_mjpeg_encode_dc(s, *ptr - VAR_19, m->huff_size_dc_chrominance, m->huff_code_dc_chrominance);
emms_c();
av_assert0(s->esc_pos == s->header_bits >> 3);
ff_mjpeg_encode_stuffing(s);
ff_mjpeg_encode_picture_trailer(s);
s->picture_number++;
flush_put_bits(&s->pb);
VAR_1->size = put_bits_ptr(&s->pb) - s->pb.buf;
VAR_1->flags |= AV_PKT_FLAG_KEY;
*VAR_3 = 1;
return 0;
| [
"static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,\nconst AVFrame *VAR_2, int *VAR_3)\n{",
"MpegEncContext * const s = VAR_0->priv_data;",
"MJpegContext * const m = s->mjpeg_ctx;",
"const int VAR_4= s->VAR_4;",
"const int VAR_5= s->VAR_5;",
"AVFrame * const p = &s->current_picture.f;",
"const int VAR_6= VAR_0->prediction_method+1;",
"const int VAR_7 = (VAR_4 + s->mjpeg_hsample[0] - 1) / s->mjpeg_hsample[0];",
"const int VAR_8 = (VAR_5 + s->mjpeg_vsample[0] - 1) / s->mjpeg_vsample[0];",
"int VAR_9, VAR_10 = FF_MIN_BUFFER_SIZE;",
"if (VAR_0->pix_fmt == AV_PIX_FMT_BGRA)\nVAR_10 += VAR_4 * VAR_5 * 3 * 4;",
"else {",
"VAR_10 += VAR_7 * VAR_8 * 3 * 4\n* s->mjpeg_hsample[0] * s->mjpeg_vsample[0];",
"if ((VAR_9 = ff_alloc_packet2(VAR_0, VAR_1, VAR_10)) < 0)\ninit_put_bits(&s->pb, VAR_1->data, VAR_1->size);",
"*p = *VAR_2;",
"p->pict_type= AV_PICTURE_TYPE_I;",
"p->key_frame= 1;",
"ff_mjpeg_encode_picture_header(s);",
"s->header_bits= put_bits_count(&s->pb);",
"if(VAR_0->pix_fmt == AV_PIX_FMT_BGR0\n|| VAR_0->pix_fmt == AV_PIX_FMT_BGRA\n|| VAR_0->pix_fmt == AV_PIX_FMT_BGR24){",
"int VAR_11, VAR_12, VAR_13;",
"const int VAR_14= p->VAR_14[0];",
"uint16_t (*buffer)[4]= (void *) s->rd_scratchpad;",
"int VAR_15[3], VAR_16[3], VAR_17[3];",
"for(VAR_13=0; VAR_13<3; VAR_13++){",
"buffer[0][VAR_13]= 1 << (9 - 1);",
"for(VAR_12 = 0; VAR_12 < VAR_5; VAR_12++) {",
"const int VAR_18= VAR_12 ? VAR_6 : 1;",
"uint8_t *ptr = p->data[0] + (VAR_14 * VAR_12);",
"if(s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < VAR_4*3*4){",
"av_log(s->VAR_0, AV_LOG_ERROR, \"encoded frame too large\\n\");",
"return -1;",
"for(VAR_13=0; VAR_13<3; VAR_13++){",
"VAR_16[VAR_13]= VAR_15[VAR_13]= VAR_17[VAR_13]= buffer[0][VAR_13];",
"for(VAR_11 = 0; VAR_11 < VAR_4; VAR_11++) {",
"if(VAR_0->pix_fmt == AV_PIX_FMT_BGR24){",
"buffer[VAR_11][1] = ptr[3*VAR_11+0] - ptr[3*VAR_11+1] + 0x100;",
"buffer[VAR_11][2] = ptr[3*VAR_11+2] - ptr[3*VAR_11+1] + 0x100;",
"buffer[VAR_11][0] = (ptr[3*VAR_11+0] + 2*ptr[3*VAR_11+1] + ptr[3*VAR_11+2])>>2;",
"}else{",
"buffer[VAR_11][1] = ptr[4*VAR_11+0] - ptr[4*VAR_11+1] + 0x100;",
"buffer[VAR_11][2] = ptr[4*VAR_11+2] - ptr[4*VAR_11+1] + 0x100;",
"buffer[VAR_11][0] = (ptr[4*VAR_11+0] + 2*ptr[4*VAR_11+1] + ptr[4*VAR_11+2])>>2;",
"for(VAR_13=0;VAR_13<3;VAR_13++) {",
"int VAR_19, VAR_20;",
"PREDICT(VAR_19, VAR_17[VAR_13], VAR_16[VAR_13], VAR_15[VAR_13], VAR_18);",
"VAR_17[VAR_13]= VAR_16[VAR_13];",
"VAR_16[VAR_13]= buffer[VAR_11+1][VAR_13];",
"VAR_15[VAR_13]= buffer[VAR_11][VAR_13];",
"VAR_20= ((VAR_15[VAR_13] - VAR_19 + 0x100)&0x1FF) - 0x100;",
"if(VAR_13==0)\nff_mjpeg_encode_dc(s, VAR_20, m->huff_size_dc_luminance, m->huff_code_dc_luminance);",
"else\nff_mjpeg_encode_dc(s, VAR_20, m->huff_size_dc_chrominance, m->huff_code_dc_chrominance);",
"}else{",
"int mb_x, mb_y, VAR_13;",
"for(mb_y = 0; mb_y < VAR_8; mb_y++) {",
"if(s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < VAR_7 * 4 * 3 * s->mjpeg_hsample[0] * s->mjpeg_vsample[0]){",
"av_log(s->VAR_0, AV_LOG_ERROR, \"encoded frame too large\\n\");",
"return -1;",
"for(mb_x = 0; mb_x < VAR_7; mb_x++) {",
"if(mb_x==0 || mb_y==0){",
"for(VAR_13=0;VAR_13<3;VAR_13++) {",
"uint8_t *ptr;",
"int VAR_11, VAR_12, h, v, VAR_14;",
"h = s->mjpeg_hsample[VAR_13];",
"v = s->mjpeg_vsample[VAR_13];",
"VAR_14= p->VAR_14[VAR_13];",
"for(VAR_12=0; VAR_12<v; VAR_12++){",
"for(VAR_11=0; VAR_11<h; VAR_11++){",
"int VAR_19;",
"ptr = p->data[VAR_13] + (VAR_14 * (v * mb_y + VAR_12)) + (h * mb_x + VAR_11);",
"if(VAR_12==0 && mb_y==0){",
"if(VAR_11==0 && mb_x==0){",
"VAR_19= 128;",
"}else{",
"VAR_19= ptr[-1];",
"}else{",
"if(VAR_11==0 && mb_x==0){",
"VAR_19= ptr[-VAR_14];",
"}else{",
"PREDICT(VAR_19, ptr[-VAR_14-1], ptr[-VAR_14], ptr[-1], VAR_6);",
"if(VAR_13==0)\nff_mjpeg_encode_dc(s, *ptr - VAR_19, m->huff_size_dc_luminance, m->huff_code_dc_luminance);",
"else\nff_mjpeg_encode_dc(s, *ptr - VAR_19, m->huff_size_dc_chrominance, m->huff_code_dc_chrominance);",
"}else{",
"for(VAR_13=0;VAR_13<3;VAR_13++) {",
"uint8_t *ptr;",
"int VAR_11, VAR_12, h, v, VAR_14;",
"h = s->mjpeg_hsample[VAR_13];",
"v = s->mjpeg_vsample[VAR_13];",
"VAR_14= p->VAR_14[VAR_13];",
"for(VAR_12=0; VAR_12<v; VAR_12++){",
"for(VAR_11=0; VAR_11<h; VAR_11++){",
"int VAR_19;",
"ptr = p->data[VAR_13] + (VAR_14 * (v * mb_y + VAR_12)) + (h * mb_x + VAR_11);",
"PREDICT(VAR_19, ptr[-VAR_14-1], ptr[-VAR_14], ptr[-1], VAR_6);",
"if(VAR_13==0)\nff_mjpeg_encode_dc(s, *ptr - VAR_19, m->huff_size_dc_luminance, m->huff_code_dc_luminance);",
"else\nff_mjpeg_encode_dc(s, *ptr - VAR_19, m->huff_size_dc_chrominance, m->huff_code_dc_chrominance);",
"emms_c();",
"av_assert0(s->esc_pos == s->header_bits >> 3);",
"ff_mjpeg_encode_stuffing(s);",
"ff_mjpeg_encode_picture_trailer(s);",
"s->picture_number++;",
"flush_put_bits(&s->pb);",
"VAR_1->size = put_bits_ptr(&s->pb) - s->pb.buf;",
"VAR_1->flags |= AV_PKT_FLAG_KEY;",
"*VAR_3 = 1;",
"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
] | [
[
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
],
[
39
],
[
40
],
[
41
],
[
42
],
[
43
],
[
44
],
[
45
],
[
46
],
[
47
],
[
48
],
[
49
],
[
50
],
[
51
],
[
52
],
[
53
],
[
54
],
[
55
],
[
56
],
[
57
],
[
58,
59
],
[
60,
61
],
[
62
],
[
63
],
[
64
],
[
65
],
[
66
],
[
67
],
[
68
],
[
69
],
[
70
],
[
71
],
[
72
],
[
73
],
[
74
],
[
75
],
[
76
],
[
77
],
[
78
],
[
79
],
[
80
],
[
81
],
[
82
],
[
83
],
[
84
],
[
85
],
[
86
],
[
87
],
[
88
],
[
89
],
[
90,
91
],
[
92,
93
],
[
94
],
[
95
],
[
96
],
[
97
],
[
98
],
[
99
],
[
100
],
[
101
],
[
102
],
[
103
],
[
104
],
[
105
],
[
106,
107
],
[
108,
109
],
[
110
],
[
111
],
[
112
],
[
113
],
[
114
],
[
115
],
[
116
],
[
117
],
[
118
],
[
119
]
] |
21,190 | static void dump_regs(struct ucontext *uc)
{
}
| true | qemu | 773b93ee0684a9b9d1f0029a936a251411289027 | static void dump_regs(struct ucontext *uc)
{
}
| {
"code": [
"static void dump_regs(struct ucontext *uc)",
"static void dump_regs(struct ucontext *uc)"
],
"line_no": [
1,
1
]
} | static void FUNC_0(struct ucontext *VAR_0)
{
}
| [
"static void FUNC_0(struct ucontext *VAR_0)\n{",
"}"
] | [
1,
0
] | [
[
1,
3
],
[
5
]
] |
21,191 | static void do_wav_capture(Monitor *mon, const QDict *qdict)
{
const char *path = qdict_get_str(qdict, "path");
int has_freq = qdict_haskey(qdict, "freq");
int freq = qdict_get_try_int(qdict, "freq", -1);
int has_bits = qdict_haskey(qdict, "bits");
int bits = qdict_get_try_int(qdict, "bits", -1);
int has_channels = qdict_haskey(qdict, "nchannels");
int nchannels = qdict_get_try_int(qdict, "nchannels", -1);
CaptureState *s;
s = qemu_mallocz (sizeof (*s));
freq = has_freq ? freq : 44100;
bits = has_bits ? bits : 16;
nchannels = has_channels ? nchannels : 2;
if (wav_start_capture (s, path, freq, bits, nchannels)) {
monitor_printf(mon, "Faied to add wave capture\n");
qemu_free (s);
}
LIST_INSERT_HEAD (&capture_head, s, entries);
}
| false | qemu | 72cf2d4f0e181d0d3a3122e04129c58a95da713e | static void do_wav_capture(Monitor *mon, const QDict *qdict)
{
const char *path = qdict_get_str(qdict, "path");
int has_freq = qdict_haskey(qdict, "freq");
int freq = qdict_get_try_int(qdict, "freq", -1);
int has_bits = qdict_haskey(qdict, "bits");
int bits = qdict_get_try_int(qdict, "bits", -1);
int has_channels = qdict_haskey(qdict, "nchannels");
int nchannels = qdict_get_try_int(qdict, "nchannels", -1);
CaptureState *s;
s = qemu_mallocz (sizeof (*s));
freq = has_freq ? freq : 44100;
bits = has_bits ? bits : 16;
nchannels = has_channels ? nchannels : 2;
if (wav_start_capture (s, path, freq, bits, nchannels)) {
monitor_printf(mon, "Faied to add wave capture\n");
qemu_free (s);
}
LIST_INSERT_HEAD (&capture_head, s, entries);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(Monitor *VAR_0, const QDict *VAR_1)
{
const char *VAR_2 = qdict_get_str(VAR_1, "VAR_2");
int VAR_3 = qdict_haskey(VAR_1, "VAR_4");
int VAR_4 = qdict_get_try_int(VAR_1, "VAR_4", -1);
int VAR_5 = qdict_haskey(VAR_1, "VAR_6");
int VAR_6 = qdict_get_try_int(VAR_1, "VAR_6", -1);
int VAR_7 = qdict_haskey(VAR_1, "VAR_8");
int VAR_8 = qdict_get_try_int(VAR_1, "VAR_8", -1);
CaptureState *s;
s = qemu_mallocz (sizeof (*s));
VAR_4 = VAR_3 ? VAR_4 : 44100;
VAR_6 = VAR_5 ? VAR_6 : 16;
VAR_8 = VAR_7 ? VAR_8 : 2;
if (wav_start_capture (s, VAR_2, VAR_4, VAR_6, VAR_8)) {
monitor_printf(VAR_0, "Faied to add wave capture\n");
qemu_free (s);
}
LIST_INSERT_HEAD (&capture_head, s, entries);
}
| [
"static void FUNC_0(Monitor *VAR_0, const QDict *VAR_1)\n{",
"const char *VAR_2 = qdict_get_str(VAR_1, \"VAR_2\");",
"int VAR_3 = qdict_haskey(VAR_1, \"VAR_4\");",
"int VAR_4 = qdict_get_try_int(VAR_1, \"VAR_4\", -1);",
"int VAR_5 = qdict_haskey(VAR_1, \"VAR_6\");",
"int VAR_6 = qdict_get_try_int(VAR_1, \"VAR_6\", -1);",
"int VAR_7 = qdict_haskey(VAR_1, \"VAR_8\");",
"int VAR_8 = qdict_get_try_int(VAR_1, \"VAR_8\", -1);",
"CaptureState *s;",
"s = qemu_mallocz (sizeof (*s));",
"VAR_4 = VAR_3 ? VAR_4 : 44100;",
"VAR_6 = VAR_5 ? VAR_6 : 16;",
"VAR_8 = VAR_7 ? VAR_8 : 2;",
"if (wav_start_capture (s, VAR_2, VAR_4, VAR_6, VAR_8)) {",
"monitor_printf(VAR_0, \"Faied to add wave capture\\n\");",
"qemu_free (s);",
"}",
"LIST_INSERT_HEAD (&capture_head, s, entries);",
"}"
] | [
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
],
[
23
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
]
] |
21,192 | static struct mm_struct *vma_init(void)
{
struct mm_struct *mm;
if ((mm = qemu_malloc(sizeof (*mm))) == NULL)
return (NULL);
mm->mm_count = 0;
TAILQ_INIT(&mm->mm_mmap);
return (mm);
}
| false | qemu | 72cf2d4f0e181d0d3a3122e04129c58a95da713e | static struct mm_struct *vma_init(void)
{
struct mm_struct *mm;
if ((mm = qemu_malloc(sizeof (*mm))) == NULL)
return (NULL);
mm->mm_count = 0;
TAILQ_INIT(&mm->mm_mmap);
return (mm);
}
| {
"code": [],
"line_no": []
} | static struct mm_struct *FUNC_0(void)
{
struct mm_struct *VAR_0;
if ((VAR_0 = qemu_malloc(sizeof (*VAR_0))) == NULL)
return (NULL);
VAR_0->mm_count = 0;
TAILQ_INIT(&VAR_0->mm_mmap);
return (VAR_0);
}
| [
"static struct mm_struct *FUNC_0(void)\n{",
"struct mm_struct *VAR_0;",
"if ((VAR_0 = qemu_malloc(sizeof (*VAR_0))) == NULL)\nreturn (NULL);",
"VAR_0->mm_count = 0;",
"TAILQ_INIT(&VAR_0->mm_mmap);",
"return (VAR_0);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9,
11
],
[
15
],
[
17
],
[
21
],
[
23
]
] |
21,193 | CoroutineAction qemu_coroutine_switch(Coroutine *from_, Coroutine *to_,
CoroutineAction action)
{
CoroutineWin32 *from = DO_UPCAST(CoroutineWin32, base, from_);
CoroutineWin32 *to = DO_UPCAST(CoroutineWin32, base, to_);
current = to_;
to->action = action;
SwitchToFiber(to->fiber);
return from->action;
}
| false | qemu | ff4873cb8c81db89668d8b56e19e57b852edb5f5 | CoroutineAction qemu_coroutine_switch(Coroutine *from_, Coroutine *to_,
CoroutineAction action)
{
CoroutineWin32 *from = DO_UPCAST(CoroutineWin32, base, from_);
CoroutineWin32 *to = DO_UPCAST(CoroutineWin32, base, to_);
current = to_;
to->action = action;
SwitchToFiber(to->fiber);
return from->action;
}
| {
"code": [],
"line_no": []
} | CoroutineAction FUNC_0(Coroutine *from_, Coroutine *to_,
CoroutineAction action)
{
CoroutineWin32 *from = DO_UPCAST(CoroutineWin32, base, from_);
CoroutineWin32 *to = DO_UPCAST(CoroutineWin32, base, to_);
current = to_;
to->action = action;
SwitchToFiber(to->fiber);
return from->action;
}
| [
"CoroutineAction FUNC_0(Coroutine *from_, Coroutine *to_,\nCoroutineAction action)\n{",
"CoroutineWin32 *from = DO_UPCAST(CoroutineWin32, base, from_);",
"CoroutineWin32 *to = DO_UPCAST(CoroutineWin32, base, to_);",
"current = to_;",
"to->action = action;",
"SwitchToFiber(to->fiber);",
"return from->action;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
]
] |
21,194 | av_cold void ff_rv34dsp_init_x86(RV34DSPContext* c, DSPContext *dsp)
{
#if HAVE_YASM
int mm_flags = av_get_cpu_flags();
if (mm_flags & AV_CPU_FLAG_MMX)
c->rv34_idct_dc_add = ff_rv34_idct_dc_add_mmx;
if (mm_flags & AV_CPU_FLAG_MMXEXT) {
c->rv34_inv_transform_dc = ff_rv34_idct_dc_noround_mmx2;
c->rv34_idct_add = ff_rv34_idct_add_mmx2;
}
if (mm_flags & AV_CPU_FLAG_SSE4)
c->rv34_idct_dc_add = ff_rv34_idct_dc_add_sse4;
#endif /* HAVE_YASM */
}
| false | FFmpeg | e0c6cce44729d94e2a5507a4b6d031f23e8bd7b6 | av_cold void ff_rv34dsp_init_x86(RV34DSPContext* c, DSPContext *dsp)
{
#if HAVE_YASM
int mm_flags = av_get_cpu_flags();
if (mm_flags & AV_CPU_FLAG_MMX)
c->rv34_idct_dc_add = ff_rv34_idct_dc_add_mmx;
if (mm_flags & AV_CPU_FLAG_MMXEXT) {
c->rv34_inv_transform_dc = ff_rv34_idct_dc_noround_mmx2;
c->rv34_idct_add = ff_rv34_idct_add_mmx2;
}
if (mm_flags & AV_CPU_FLAG_SSE4)
c->rv34_idct_dc_add = ff_rv34_idct_dc_add_sse4;
#endif
}
| {
"code": [],
"line_no": []
} | av_cold void FUNC_0(RV34DSPContext* c, DSPContext *dsp)
{
#if HAVE_YASM
int mm_flags = av_get_cpu_flags();
if (mm_flags & AV_CPU_FLAG_MMX)
c->rv34_idct_dc_add = ff_rv34_idct_dc_add_mmx;
if (mm_flags & AV_CPU_FLAG_MMXEXT) {
c->rv34_inv_transform_dc = ff_rv34_idct_dc_noround_mmx2;
c->rv34_idct_add = ff_rv34_idct_add_mmx2;
}
if (mm_flags & AV_CPU_FLAG_SSE4)
c->rv34_idct_dc_add = ff_rv34_idct_dc_add_sse4;
#endif
}
| [
"av_cold void FUNC_0(RV34DSPContext* c, DSPContext *dsp)\n{",
"#if HAVE_YASM\nint mm_flags = av_get_cpu_flags();",
"if (mm_flags & AV_CPU_FLAG_MMX)\nc->rv34_idct_dc_add = ff_rv34_idct_dc_add_mmx;",
"if (mm_flags & AV_CPU_FLAG_MMXEXT) {",
"c->rv34_inv_transform_dc = ff_rv34_idct_dc_noround_mmx2;",
"c->rv34_idct_add = ff_rv34_idct_add_mmx2;",
"}",
"if (mm_flags & AV_CPU_FLAG_SSE4)\nc->rv34_idct_dc_add = ff_rv34_idct_dc_add_sse4;",
"#endif\n}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
11,
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23,
25
],
[
27,
29
]
] |
21,195 | int64_t helper_fqtox(CPUSPARCState *env)
{
int64_t ret;
clear_float_exceptions(env);
ret = float128_to_int64_round_to_zero(QT1, &env->fp_status);
check_ieee_exceptions(env);
return ret;
}
| false | qemu | 7385aed20db5d83979f683b9d0048674411e963c | int64_t helper_fqtox(CPUSPARCState *env)
{
int64_t ret;
clear_float_exceptions(env);
ret = float128_to_int64_round_to_zero(QT1, &env->fp_status);
check_ieee_exceptions(env);
return ret;
}
| {
"code": [],
"line_no": []
} | int64_t FUNC_0(CPUSPARCState *env)
{
int64_t ret;
clear_float_exceptions(env);
ret = float128_to_int64_round_to_zero(QT1, &env->fp_status);
check_ieee_exceptions(env);
return ret;
}
| [
"int64_t FUNC_0(CPUSPARCState *env)\n{",
"int64_t ret;",
"clear_float_exceptions(env);",
"ret = float128_to_int64_round_to_zero(QT1, &env->fp_status);",
"check_ieee_exceptions(env);",
"return ret;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
]
] |
21,197 | static void io_region_add(MemoryListener *listener,
MemoryRegionSection *section)
{
MemoryRegionIORange *mrio = g_new(MemoryRegionIORange, 1);
mrio->mr = section->mr;
mrio->offset = section->offset_within_region;
iorange_init(&mrio->iorange, &memory_region_iorange_ops,
section->offset_within_address_space,
int128_get64(section->size));
ioport_register(&mrio->iorange);
}
| false | qemu | b40acf99bef69fa8ab0f9092ff162fde945eec12 | static void io_region_add(MemoryListener *listener,
MemoryRegionSection *section)
{
MemoryRegionIORange *mrio = g_new(MemoryRegionIORange, 1);
mrio->mr = section->mr;
mrio->offset = section->offset_within_region;
iorange_init(&mrio->iorange, &memory_region_iorange_ops,
section->offset_within_address_space,
int128_get64(section->size));
ioport_register(&mrio->iorange);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(MemoryListener *VAR_0,
MemoryRegionSection *VAR_1)
{
MemoryRegionIORange *mrio = g_new(MemoryRegionIORange, 1);
mrio->mr = VAR_1->mr;
mrio->offset = VAR_1->offset_within_region;
iorange_init(&mrio->iorange, &memory_region_iorange_ops,
VAR_1->offset_within_address_space,
int128_get64(VAR_1->size));
ioport_register(&mrio->iorange);
}
| [
"static void FUNC_0(MemoryListener *VAR_0,\nMemoryRegionSection *VAR_1)\n{",
"MemoryRegionIORange *mrio = g_new(MemoryRegionIORange, 1);",
"mrio->mr = VAR_1->mr;",
"mrio->offset = VAR_1->offset_within_region;",
"iorange_init(&mrio->iorange, &memory_region_iorange_ops,\nVAR_1->offset_within_address_space,\nint128_get64(VAR_1->size));",
"ioport_register(&mrio->iorange);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15,
17,
19
],
[
21
],
[
23
]
] |
21,198 | build_mcfg_q35(GArray *table_data, GArray *linker, AcpiMcfgInfo *info)
{
AcpiTableMcfg *mcfg;
const char *sig;
int len = sizeof(*mcfg) + 1 * sizeof(mcfg->allocation[0]);
mcfg = acpi_data_push(table_data, len);
mcfg->allocation[0].address = cpu_to_le64(info->mcfg_base);
/* Only a single allocation so no need to play with segments */
mcfg->allocation[0].pci_segment = cpu_to_le16(0);
mcfg->allocation[0].start_bus_number = 0;
mcfg->allocation[0].end_bus_number = PCIE_MMCFG_BUS(info->mcfg_size - 1);
/* MCFG is used for ECAM which can be enabled or disabled by guest.
* To avoid table size changes (which create migration issues),
* always create the table even if there are no allocations,
* but set the signature to a reserved value in this case.
* ACPI spec requires OSPMs to ignore such tables.
*/
if (info->mcfg_base == PCIE_BASE_ADDR_UNMAPPED) {
/* Reserved signature: ignored by OSPM */
sig = "QEMU";
} else {
sig = "MCFG";
}
build_header(linker, table_data, (void *)mcfg, sig, len, 1, NULL, NULL);
}
| false | qemu | 0e9b9edae7bebfd31fdbead4ccbbce03876a7edd | build_mcfg_q35(GArray *table_data, GArray *linker, AcpiMcfgInfo *info)
{
AcpiTableMcfg *mcfg;
const char *sig;
int len = sizeof(*mcfg) + 1 * sizeof(mcfg->allocation[0]);
mcfg = acpi_data_push(table_data, len);
mcfg->allocation[0].address = cpu_to_le64(info->mcfg_base);
mcfg->allocation[0].pci_segment = cpu_to_le16(0);
mcfg->allocation[0].start_bus_number = 0;
mcfg->allocation[0].end_bus_number = PCIE_MMCFG_BUS(info->mcfg_size - 1);
if (info->mcfg_base == PCIE_BASE_ADDR_UNMAPPED) {
sig = "QEMU";
} else {
sig = "MCFG";
}
build_header(linker, table_data, (void *)mcfg, sig, len, 1, NULL, NULL);
}
| {
"code": [],
"line_no": []
} | FUNC_0(GArray *VAR_0, GArray *VAR_1, AcpiMcfgInfo *VAR_2)
{
AcpiTableMcfg *mcfg;
const char *VAR_3;
int VAR_4 = sizeof(*mcfg) + 1 * sizeof(mcfg->allocation[0]);
mcfg = acpi_data_push(VAR_0, VAR_4);
mcfg->allocation[0].address = cpu_to_le64(VAR_2->mcfg_base);
mcfg->allocation[0].pci_segment = cpu_to_le16(0);
mcfg->allocation[0].start_bus_number = 0;
mcfg->allocation[0].end_bus_number = PCIE_MMCFG_BUS(VAR_2->mcfg_size - 1);
if (VAR_2->mcfg_base == PCIE_BASE_ADDR_UNMAPPED) {
VAR_3 = "QEMU";
} else {
VAR_3 = "MCFG";
}
build_header(VAR_1, VAR_0, (void *)mcfg, VAR_3, VAR_4, 1, NULL, NULL);
}
| [
"FUNC_0(GArray *VAR_0, GArray *VAR_1, AcpiMcfgInfo *VAR_2)\n{",
"AcpiTableMcfg *mcfg;",
"const char *VAR_3;",
"int VAR_4 = sizeof(*mcfg) + 1 * sizeof(mcfg->allocation[0]);",
"mcfg = acpi_data_push(VAR_0, VAR_4);",
"mcfg->allocation[0].address = cpu_to_le64(VAR_2->mcfg_base);",
"mcfg->allocation[0].pci_segment = cpu_to_le16(0);",
"mcfg->allocation[0].start_bus_number = 0;",
"mcfg->allocation[0].end_bus_number = PCIE_MMCFG_BUS(VAR_2->mcfg_size - 1);",
"if (VAR_2->mcfg_base == PCIE_BASE_ADDR_UNMAPPED) {",
"VAR_3 = \"QEMU\";",
"} else {",
"VAR_3 = \"MCFG\";",
"}",
"build_header(VAR_1, VAR_0, (void *)mcfg, VAR_3, VAR_4, 1, NULL, NULL);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
]
] |
21,199 | static void ide_resize_cb(void *opaque)
{
IDEState *s = opaque;
uint64_t nb_sectors;
if (!s->identify_set) {
return;
}
bdrv_get_geometry(s->bs, &nb_sectors);
s->nb_sectors = nb_sectors;
/* Update the identify data buffer. */
if (s->drive_kind == IDE_CFATA) {
ide_cfata_identify_size(s);
} else {
/* IDE_CD uses a different set of callbacks entirely. */
assert(s->drive_kind != IDE_CD);
ide_identify_size(s);
}
}
| false | qemu | 4be746345f13e99e468c60acbd3a355e8183e3ce | static void ide_resize_cb(void *opaque)
{
IDEState *s = opaque;
uint64_t nb_sectors;
if (!s->identify_set) {
return;
}
bdrv_get_geometry(s->bs, &nb_sectors);
s->nb_sectors = nb_sectors;
if (s->drive_kind == IDE_CFATA) {
ide_cfata_identify_size(s);
} else {
assert(s->drive_kind != IDE_CD);
ide_identify_size(s);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0)
{
IDEState *s = VAR_0;
uint64_t nb_sectors;
if (!s->identify_set) {
return;
}
bdrv_get_geometry(s->bs, &nb_sectors);
s->nb_sectors = nb_sectors;
if (s->drive_kind == IDE_CFATA) {
ide_cfata_identify_size(s);
} else {
assert(s->drive_kind != IDE_CD);
ide_identify_size(s);
}
}
| [
"static void FUNC_0(void *VAR_0)\n{",
"IDEState *s = VAR_0;",
"uint64_t nb_sectors;",
"if (!s->identify_set) {",
"return;",
"}",
"bdrv_get_geometry(s->bs, &nb_sectors);",
"s->nb_sectors = nb_sectors;",
"if (s->drive_kind == IDE_CFATA) {",
"ide_cfata_identify_size(s);",
"} else {",
"assert(s->drive_kind != IDE_CD);",
"ide_identify_size(s);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
]
] |
21,201 | static void reset_all_temps(int nb_temps)
{
int i;
for (i = 0; i < nb_temps; i++) {
temps[i].state = TCG_TEMP_UNDEF;
temps[i].mask = -1;
}
}
| false | qemu | 1208d7dd5fddc1fbd98de800d17429b4e5578848 | static void reset_all_temps(int nb_temps)
{
int i;
for (i = 0; i < nb_temps; i++) {
temps[i].state = TCG_TEMP_UNDEF;
temps[i].mask = -1;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(int VAR_0)
{
int VAR_1;
for (VAR_1 = 0; VAR_1 < VAR_0; VAR_1++) {
temps[VAR_1].state = TCG_TEMP_UNDEF;
temps[VAR_1].mask = -1;
}
}
| [
"static void FUNC_0(int VAR_0)\n{",
"int VAR_1;",
"for (VAR_1 = 0; VAR_1 < VAR_0; VAR_1++) {",
"temps[VAR_1].state = TCG_TEMP_UNDEF;",
"temps[VAR_1].mask = -1;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
]
] |
21,203 | static inline void tcg_out_tlb_load(TCGContext *s, TCGReg addrlo, TCGReg addrhi,
int mem_index, TCGMemOp opc,
tcg_insn_unit **label_ptr, int which)
{
const TCGReg r0 = TCG_REG_L0;
const TCGReg r1 = TCG_REG_L1;
TCGType ttype = TCG_TYPE_I32;
TCGType tlbtype = TCG_TYPE_I32;
int trexw = 0, hrexw = 0, tlbrexw = 0;
int s_mask = (1 << (opc & MO_SIZE)) - 1;
bool aligned = (opc & MO_AMASK) == MO_ALIGN || s_mask == 0;
if (TCG_TARGET_REG_BITS == 64) {
if (TARGET_LONG_BITS == 64) {
ttype = TCG_TYPE_I64;
trexw = P_REXW;
}
if (TCG_TYPE_PTR == TCG_TYPE_I64) {
hrexw = P_REXW;
if (TARGET_PAGE_BITS + CPU_TLB_BITS > 32) {
tlbtype = TCG_TYPE_I64;
tlbrexw = P_REXW;
}
}
}
tcg_out_mov(s, tlbtype, r0, addrlo);
if (aligned) {
tcg_out_mov(s, ttype, r1, addrlo);
} else {
/* For unaligned access check that we don't cross pages using
the page address of the last byte. */
tcg_out_modrm_offset(s, OPC_LEA + trexw, r1, addrlo, s_mask);
}
tcg_out_shifti(s, SHIFT_SHR + tlbrexw, r0,
TARGET_PAGE_BITS - CPU_TLB_ENTRY_BITS);
tgen_arithi(s, ARITH_AND + trexw, r1,
TARGET_PAGE_MASK | (aligned ? s_mask : 0), 0);
tgen_arithi(s, ARITH_AND + tlbrexw, r0,
(CPU_TLB_SIZE - 1) << CPU_TLB_ENTRY_BITS, 0);
tcg_out_modrm_sib_offset(s, OPC_LEA + hrexw, r0, TCG_AREG0, r0, 0,
offsetof(CPUArchState, tlb_table[mem_index][0])
+ which);
/* cmp 0(r0), r1 */
tcg_out_modrm_offset(s, OPC_CMP_GvEv + trexw, r1, r0, 0);
/* Prepare for both the fast path add of the tlb addend, and the slow
path function argument setup. There are two cases worth note:
For 32-bit guest and x86_64 host, MOVL zero-extends the guest address
before the fastpath ADDQ below. For 64-bit guest and x32 host, MOVQ
copies the entire guest address for the slow path, while truncation
for the 32-bit host happens with the fastpath ADDL below. */
tcg_out_mov(s, ttype, r1, addrlo);
/* jne slow_path */
tcg_out_opc(s, OPC_JCC_long + JCC_JNE, 0, 0, 0);
label_ptr[0] = s->code_ptr;
s->code_ptr += 4;
if (TARGET_LONG_BITS > TCG_TARGET_REG_BITS) {
/* cmp 4(r0), addrhi */
tcg_out_modrm_offset(s, OPC_CMP_GvEv, addrhi, r0, 4);
/* jne slow_path */
tcg_out_opc(s, OPC_JCC_long + JCC_JNE, 0, 0, 0);
label_ptr[1] = s->code_ptr;
s->code_ptr += 4;
}
/* TLB Hit. */
/* add addend(r0), r1 */
tcg_out_modrm_offset(s, OPC_ADD_GvEv + hrexw, r1, r0,
offsetof(CPUTLBEntry, addend) - which);
}
| false | qemu | 1f00b27f17518a1bcb4cedca49eaec96a4d560bd | static inline void tcg_out_tlb_load(TCGContext *s, TCGReg addrlo, TCGReg addrhi,
int mem_index, TCGMemOp opc,
tcg_insn_unit **label_ptr, int which)
{
const TCGReg r0 = TCG_REG_L0;
const TCGReg r1 = TCG_REG_L1;
TCGType ttype = TCG_TYPE_I32;
TCGType tlbtype = TCG_TYPE_I32;
int trexw = 0, hrexw = 0, tlbrexw = 0;
int s_mask = (1 << (opc & MO_SIZE)) - 1;
bool aligned = (opc & MO_AMASK) == MO_ALIGN || s_mask == 0;
if (TCG_TARGET_REG_BITS == 64) {
if (TARGET_LONG_BITS == 64) {
ttype = TCG_TYPE_I64;
trexw = P_REXW;
}
if (TCG_TYPE_PTR == TCG_TYPE_I64) {
hrexw = P_REXW;
if (TARGET_PAGE_BITS + CPU_TLB_BITS > 32) {
tlbtype = TCG_TYPE_I64;
tlbrexw = P_REXW;
}
}
}
tcg_out_mov(s, tlbtype, r0, addrlo);
if (aligned) {
tcg_out_mov(s, ttype, r1, addrlo);
} else {
tcg_out_modrm_offset(s, OPC_LEA + trexw, r1, addrlo, s_mask);
}
tcg_out_shifti(s, SHIFT_SHR + tlbrexw, r0,
TARGET_PAGE_BITS - CPU_TLB_ENTRY_BITS);
tgen_arithi(s, ARITH_AND + trexw, r1,
TARGET_PAGE_MASK | (aligned ? s_mask : 0), 0);
tgen_arithi(s, ARITH_AND + tlbrexw, r0,
(CPU_TLB_SIZE - 1) << CPU_TLB_ENTRY_BITS, 0);
tcg_out_modrm_sib_offset(s, OPC_LEA + hrexw, r0, TCG_AREG0, r0, 0,
offsetof(CPUArchState, tlb_table[mem_index][0])
+ which);
tcg_out_modrm_offset(s, OPC_CMP_GvEv + trexw, r1, r0, 0);
tcg_out_mov(s, ttype, r1, addrlo);
tcg_out_opc(s, OPC_JCC_long + JCC_JNE, 0, 0, 0);
label_ptr[0] = s->code_ptr;
s->code_ptr += 4;
if (TARGET_LONG_BITS > TCG_TARGET_REG_BITS) {
tcg_out_modrm_offset(s, OPC_CMP_GvEv, addrhi, r0, 4);
tcg_out_opc(s, OPC_JCC_long + JCC_JNE, 0, 0, 0);
label_ptr[1] = s->code_ptr;
s->code_ptr += 4;
}
tcg_out_modrm_offset(s, OPC_ADD_GvEv + hrexw, r1, r0,
offsetof(CPUTLBEntry, addend) - which);
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0(TCGContext *VAR_0, TCGReg VAR_1, TCGReg VAR_2,
int VAR_3, TCGMemOp VAR_4,
tcg_insn_unit **VAR_5, int VAR_6)
{
const TCGReg VAR_7 = TCG_REG_L0;
const TCGReg VAR_8 = TCG_REG_L1;
TCGType ttype = TCG_TYPE_I32;
TCGType tlbtype = TCG_TYPE_I32;
int VAR_9 = 0, VAR_10 = 0, VAR_11 = 0;
int VAR_12 = (1 << (VAR_4 & MO_SIZE)) - 1;
bool aligned = (VAR_4 & MO_AMASK) == MO_ALIGN || VAR_12 == 0;
if (TCG_TARGET_REG_BITS == 64) {
if (TARGET_LONG_BITS == 64) {
ttype = TCG_TYPE_I64;
VAR_9 = P_REXW;
}
if (TCG_TYPE_PTR == TCG_TYPE_I64) {
VAR_10 = P_REXW;
if (TARGET_PAGE_BITS + CPU_TLB_BITS > 32) {
tlbtype = TCG_TYPE_I64;
VAR_11 = P_REXW;
}
}
}
tcg_out_mov(VAR_0, tlbtype, VAR_7, VAR_1);
if (aligned) {
tcg_out_mov(VAR_0, ttype, VAR_8, VAR_1);
} else {
tcg_out_modrm_offset(VAR_0, OPC_LEA + VAR_9, VAR_8, VAR_1, VAR_12);
}
tcg_out_shifti(VAR_0, SHIFT_SHR + VAR_11, VAR_7,
TARGET_PAGE_BITS - CPU_TLB_ENTRY_BITS);
tgen_arithi(VAR_0, ARITH_AND + VAR_9, VAR_8,
TARGET_PAGE_MASK | (aligned ? VAR_12 : 0), 0);
tgen_arithi(VAR_0, ARITH_AND + VAR_11, VAR_7,
(CPU_TLB_SIZE - 1) << CPU_TLB_ENTRY_BITS, 0);
tcg_out_modrm_sib_offset(VAR_0, OPC_LEA + VAR_10, VAR_7, TCG_AREG0, VAR_7, 0,
offsetof(CPUArchState, tlb_table[VAR_3][0])
+ VAR_6);
tcg_out_modrm_offset(VAR_0, OPC_CMP_GvEv + VAR_9, VAR_8, VAR_7, 0);
tcg_out_mov(VAR_0, ttype, VAR_8, VAR_1);
tcg_out_opc(VAR_0, OPC_JCC_long + JCC_JNE, 0, 0, 0);
VAR_5[0] = VAR_0->code_ptr;
VAR_0->code_ptr += 4;
if (TARGET_LONG_BITS > TCG_TARGET_REG_BITS) {
tcg_out_modrm_offset(VAR_0, OPC_CMP_GvEv, VAR_2, VAR_7, 4);
tcg_out_opc(VAR_0, OPC_JCC_long + JCC_JNE, 0, 0, 0);
VAR_5[1] = VAR_0->code_ptr;
VAR_0->code_ptr += 4;
}
tcg_out_modrm_offset(VAR_0, OPC_ADD_GvEv + VAR_10, VAR_8, VAR_7,
offsetof(CPUTLBEntry, addend) - VAR_6);
}
| [
"static inline void FUNC_0(TCGContext *VAR_0, TCGReg VAR_1, TCGReg VAR_2,\nint VAR_3, TCGMemOp VAR_4,\ntcg_insn_unit **VAR_5, int VAR_6)\n{",
"const TCGReg VAR_7 = TCG_REG_L0;",
"const TCGReg VAR_8 = TCG_REG_L1;",
"TCGType ttype = TCG_TYPE_I32;",
"TCGType tlbtype = TCG_TYPE_I32;",
"int VAR_9 = 0, VAR_10 = 0, VAR_11 = 0;",
"int VAR_12 = (1 << (VAR_4 & MO_SIZE)) - 1;",
"bool aligned = (VAR_4 & MO_AMASK) == MO_ALIGN || VAR_12 == 0;",
"if (TCG_TARGET_REG_BITS == 64) {",
"if (TARGET_LONG_BITS == 64) {",
"ttype = TCG_TYPE_I64;",
"VAR_9 = P_REXW;",
"}",
"if (TCG_TYPE_PTR == TCG_TYPE_I64) {",
"VAR_10 = P_REXW;",
"if (TARGET_PAGE_BITS + CPU_TLB_BITS > 32) {",
"tlbtype = TCG_TYPE_I64;",
"VAR_11 = P_REXW;",
"}",
"}",
"}",
"tcg_out_mov(VAR_0, tlbtype, VAR_7, VAR_1);",
"if (aligned) {",
"tcg_out_mov(VAR_0, ttype, VAR_8, VAR_1);",
"} else {",
"tcg_out_modrm_offset(VAR_0, OPC_LEA + VAR_9, VAR_8, VAR_1, VAR_12);",
"}",
"tcg_out_shifti(VAR_0, SHIFT_SHR + VAR_11, VAR_7,\nTARGET_PAGE_BITS - CPU_TLB_ENTRY_BITS);",
"tgen_arithi(VAR_0, ARITH_AND + VAR_9, VAR_8,\nTARGET_PAGE_MASK | (aligned ? VAR_12 : 0), 0);",
"tgen_arithi(VAR_0, ARITH_AND + VAR_11, VAR_7,\n(CPU_TLB_SIZE - 1) << CPU_TLB_ENTRY_BITS, 0);",
"tcg_out_modrm_sib_offset(VAR_0, OPC_LEA + VAR_10, VAR_7, TCG_AREG0, VAR_7, 0,\noffsetof(CPUArchState, tlb_table[VAR_3][0])\n+ VAR_6);",
"tcg_out_modrm_offset(VAR_0, OPC_CMP_GvEv + VAR_9, VAR_8, VAR_7, 0);",
"tcg_out_mov(VAR_0, ttype, VAR_8, VAR_1);",
"tcg_out_opc(VAR_0, OPC_JCC_long + JCC_JNE, 0, 0, 0);",
"VAR_5[0] = VAR_0->code_ptr;",
"VAR_0->code_ptr += 4;",
"if (TARGET_LONG_BITS > TCG_TARGET_REG_BITS) {",
"tcg_out_modrm_offset(VAR_0, OPC_CMP_GvEv, VAR_2, VAR_7, 4);",
"tcg_out_opc(VAR_0, OPC_JCC_long + JCC_JNE, 0, 0, 0);",
"VAR_5[1] = VAR_0->code_ptr;",
"VAR_0->code_ptr += 4;",
"}",
"tcg_out_modrm_offset(VAR_0, OPC_ADD_GvEv + VAR_10, VAR_8, VAR_7,\noffsetof(CPUTLBEntry, addend) - VAR_6);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
65
],
[
67
],
[
71,
73
],
[
77,
79
],
[
81,
83
],
[
87,
89,
91
],
[
97
],
[
113
],
[
119
],
[
121
],
[
123
],
[
127
],
[
131
],
[
137
],
[
139
],
[
141
],
[
143
],
[
153,
155
],
[
157
]
] |
21,204 | uint64_t helper_load_fpcr (void)
{
uint64_t ret = 0;
#ifdef CONFIG_SOFTFLOAT
ret |= env->fp_status.float_exception_flags << 52;
if (env->fp_status.float_exception_flags)
ret |= 1ULL << 63;
env->ipr[IPR_EXC_SUM] &= ~0x3E:
env->ipr[IPR_EXC_SUM] |= env->fp_status.float_exception_flags << 1;
#endif
switch (env->fp_status.float_rounding_mode) {
case float_round_nearest_even:
ret |= 2ULL << 58;
break;
case float_round_down:
ret |= 1ULL << 58;
break;
case float_round_up:
ret |= 3ULL << 58;
break;
case float_round_to_zero:
break;
}
return ret;
}
| false | qemu | ba0e276db4b51bd2255a5d5ff8902c70d32ade40 | uint64_t helper_load_fpcr (void)
{
uint64_t ret = 0;
#ifdef CONFIG_SOFTFLOAT
ret |= env->fp_status.float_exception_flags << 52;
if (env->fp_status.float_exception_flags)
ret |= 1ULL << 63;
env->ipr[IPR_EXC_SUM] &= ~0x3E:
env->ipr[IPR_EXC_SUM] |= env->fp_status.float_exception_flags << 1;
#endif
switch (env->fp_status.float_rounding_mode) {
case float_round_nearest_even:
ret |= 2ULL << 58;
break;
case float_round_down:
ret |= 1ULL << 58;
break;
case float_round_up:
ret |= 3ULL << 58;
break;
case float_round_to_zero:
break;
}
return ret;
}
| {
"code": [],
"line_no": []
} | uint64_t FUNC_0 (void)
{
uint64_t ret = 0;
#ifdef CONFIG_SOFTFLOAT
ret |= env->fp_status.float_exception_flags << 52;
if (env->fp_status.float_exception_flags)
ret |= 1ULL << 63;
env->ipr[IPR_EXC_SUM] &= ~0x3E:
env->ipr[IPR_EXC_SUM] |= env->fp_status.float_exception_flags << 1;
#endif
switch (env->fp_status.float_rounding_mode) {
case float_round_nearest_even:
ret |= 2ULL << 58;
break;
case float_round_down:
ret |= 1ULL << 58;
break;
case float_round_up:
ret |= 3ULL << 58;
break;
case float_round_to_zero:
break;
}
return ret;
}
| [
"uint64_t FUNC_0 (void)\n{",
"uint64_t ret = 0;",
"#ifdef CONFIG_SOFTFLOAT\nret |= env->fp_status.float_exception_flags << 52;",
"if (env->fp_status.float_exception_flags)\nret |= 1ULL << 63;",
"env->ipr[IPR_EXC_SUM] &= ~0x3E:\nenv->ipr[IPR_EXC_SUM] |= env->fp_status.float_exception_flags << 1;",
"#endif\nswitch (env->fp_status.float_rounding_mode) {",
"case float_round_nearest_even:\nret |= 2ULL << 58;",
"break;",
"case float_round_down:\nret |= 1ULL << 58;",
"break;",
"case float_round_up:\nret |= 3ULL << 58;",
"break;",
"case float_round_to_zero:\nbreak;",
"}",
"return ret;",
"}"
] | [
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
]
] |
21,205 | static void common_end(SnowContext *s){
av_freep(&s->spatial_dwt_buffer);
av_freep(&s->mb_band.buf);
av_freep(&s->mv_band[0].buf);
av_freep(&s->mv_band[1].buf);
av_freep(&s->m.me.scratchpad);
av_freep(&s->m.me.map);
av_freep(&s->m.me.score_map);
av_freep(&s->mb_type);
av_freep(&s->mb_mean);
av_freep(&s->dummy);
av_freep(&s->motion_val8);
av_freep(&s->motion_val16);
}
| false | FFmpeg | 155ec6edf82692bcf3a5f87d2bc697404f4e5aaf | static void common_end(SnowContext *s){
av_freep(&s->spatial_dwt_buffer);
av_freep(&s->mb_band.buf);
av_freep(&s->mv_band[0].buf);
av_freep(&s->mv_band[1].buf);
av_freep(&s->m.me.scratchpad);
av_freep(&s->m.me.map);
av_freep(&s->m.me.score_map);
av_freep(&s->mb_type);
av_freep(&s->mb_mean);
av_freep(&s->dummy);
av_freep(&s->motion_val8);
av_freep(&s->motion_val16);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(SnowContext *VAR_0){
av_freep(&VAR_0->spatial_dwt_buffer);
av_freep(&VAR_0->mb_band.buf);
av_freep(&VAR_0->mv_band[0].buf);
av_freep(&VAR_0->mv_band[1].buf);
av_freep(&VAR_0->m.me.scratchpad);
av_freep(&VAR_0->m.me.map);
av_freep(&VAR_0->m.me.score_map);
av_freep(&VAR_0->mb_type);
av_freep(&VAR_0->mb_mean);
av_freep(&VAR_0->dummy);
av_freep(&VAR_0->motion_val8);
av_freep(&VAR_0->motion_val16);
}
| [
"static void FUNC_0(SnowContext *VAR_0){",
"av_freep(&VAR_0->spatial_dwt_buffer);",
"av_freep(&VAR_0->mb_band.buf);",
"av_freep(&VAR_0->mv_band[0].buf);",
"av_freep(&VAR_0->mv_band[1].buf);",
"av_freep(&VAR_0->m.me.scratchpad);",
"av_freep(&VAR_0->m.me.map);",
"av_freep(&VAR_0->m.me.score_map);",
"av_freep(&VAR_0->mb_type);",
"av_freep(&VAR_0->mb_mean);",
"av_freep(&VAR_0->dummy);",
"av_freep(&VAR_0->motion_val8);",
"av_freep(&VAR_0->motion_val16);",
"}"
] | [
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
]
] |
21,206 | static void imx_ccm_write(void *opaque, target_phys_addr_t offset,
uint64_t value, unsigned size)
{
IMXCCMState *s = (IMXCCMState *)opaque;
DPRINTF("write(offset=%x, value = %x)\n",
offset >> 2, (unsigned int)value);
switch (offset >> 2) {
case 0:
s->ccmr = CCMR_FPMF | (value & 0x3b6fdfff);
break;
case 1:
s->pdr0 = value & 0xff9f3fff;
break;
case 2:
s->pdr1 = value;
break;
case 4:
s->mpctl = value & 0xbfff3fff;
break;
case 6:
s->spctl = value & 0xbfff3fff;
break;
case 8:
s->cgr[0] = value;
return;
case 9:
s->cgr[1] = value;
return;
case 10:
s->cgr[2] = value;
return;
default:
return;
}
update_clocks(s);
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static void imx_ccm_write(void *opaque, target_phys_addr_t offset,
uint64_t value, unsigned size)
{
IMXCCMState *s = (IMXCCMState *)opaque;
DPRINTF("write(offset=%x, value = %x)\n",
offset >> 2, (unsigned int)value);
switch (offset >> 2) {
case 0:
s->ccmr = CCMR_FPMF | (value & 0x3b6fdfff);
break;
case 1:
s->pdr0 = value & 0xff9f3fff;
break;
case 2:
s->pdr1 = value;
break;
case 4:
s->mpctl = value & 0xbfff3fff;
break;
case 6:
s->spctl = value & 0xbfff3fff;
break;
case 8:
s->cgr[0] = value;
return;
case 9:
s->cgr[1] = value;
return;
case 10:
s->cgr[2] = value;
return;
default:
return;
}
update_clocks(s);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,
uint64_t VAR_2, unsigned VAR_3)
{
IMXCCMState *s = (IMXCCMState *)VAR_0;
DPRINTF("write(VAR_1=%x, VAR_2 = %x)\n",
VAR_1 >> 2, (unsigned int)VAR_2);
switch (VAR_1 >> 2) {
case 0:
s->ccmr = CCMR_FPMF | (VAR_2 & 0x3b6fdfff);
break;
case 1:
s->pdr0 = VAR_2 & 0xff9f3fff;
break;
case 2:
s->pdr1 = VAR_2;
break;
case 4:
s->mpctl = VAR_2 & 0xbfff3fff;
break;
case 6:
s->spctl = VAR_2 & 0xbfff3fff;
break;
case 8:
s->cgr[0] = VAR_2;
return;
case 9:
s->cgr[1] = VAR_2;
return;
case 10:
s->cgr[2] = VAR_2;
return;
default:
return;
}
update_clocks(s);
}
| [
"static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{",
"IMXCCMState *s = (IMXCCMState *)VAR_0;",
"DPRINTF(\"write(VAR_1=%x, VAR_2 = %x)\\n\",\nVAR_1 >> 2, (unsigned int)VAR_2);",
"switch (VAR_1 >> 2) {",
"case 0:\ns->ccmr = CCMR_FPMF | (VAR_2 & 0x3b6fdfff);",
"break;",
"case 1:\ns->pdr0 = VAR_2 & 0xff9f3fff;",
"break;",
"case 2:\ns->pdr1 = VAR_2;",
"break;",
"case 4:\ns->mpctl = VAR_2 & 0xbfff3fff;",
"break;",
"case 6:\ns->spctl = VAR_2 & 0xbfff3fff;",
"break;",
"case 8:\ns->cgr[0] = VAR_2;",
"return;",
"case 9:\ns->cgr[1] = VAR_2;",
"return;",
"case 10:\ns->cgr[2] = VAR_2;",
"return;",
"default:\nreturn;",
"}",
"update_clocks(s);",
"}"
] | [
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,
37
],
[
39
],
[
41,
43
],
[
45
],
[
47,
49
],
[
51
],
[
53,
55
],
[
57
],
[
59,
61
],
[
63
],
[
67,
69
],
[
71
],
[
73
],
[
75
]
] |
21,207 | static void dump_regs(TCGContext *s)
{
TCGTemp *ts;
int i;
char buf[64];
for(i = 0; i < s->nb_temps; i++) {
ts = &s->temps[i];
printf(" %10s: ", tcg_get_arg_str_idx(s, buf, sizeof(buf), i));
switch(ts->val_type) {
case TEMP_VAL_REG:
printf("%s", tcg_target_reg_names[ts->reg]);
break;
case TEMP_VAL_MEM:
printf("%d(%s)", (int)ts->mem_offset, tcg_target_reg_names[ts->mem_reg]);
break;
case TEMP_VAL_CONST:
printf("$0x%" TCG_PRIlx, ts->val);
break;
case TEMP_VAL_DEAD:
printf("D");
break;
default:
printf("???");
break;
}
printf("\n");
}
for(i = 0; i < TCG_TARGET_NB_REGS; i++) {
if (s->reg_to_temp[i] >= 0) {
printf("%s: %s\n",
tcg_target_reg_names[i],
tcg_get_arg_str_idx(s, buf, sizeof(buf), s->reg_to_temp[i]));
}
}
}
| false | qemu | b3a62939561e07bc34493444fa926b6137cba4e8 | static void dump_regs(TCGContext *s)
{
TCGTemp *ts;
int i;
char buf[64];
for(i = 0; i < s->nb_temps; i++) {
ts = &s->temps[i];
printf(" %10s: ", tcg_get_arg_str_idx(s, buf, sizeof(buf), i));
switch(ts->val_type) {
case TEMP_VAL_REG:
printf("%s", tcg_target_reg_names[ts->reg]);
break;
case TEMP_VAL_MEM:
printf("%d(%s)", (int)ts->mem_offset, tcg_target_reg_names[ts->mem_reg]);
break;
case TEMP_VAL_CONST:
printf("$0x%" TCG_PRIlx, ts->val);
break;
case TEMP_VAL_DEAD:
printf("D");
break;
default:
printf("???");
break;
}
printf("\n");
}
for(i = 0; i < TCG_TARGET_NB_REGS; i++) {
if (s->reg_to_temp[i] >= 0) {
printf("%s: %s\n",
tcg_target_reg_names[i],
tcg_get_arg_str_idx(s, buf, sizeof(buf), s->reg_to_temp[i]));
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(TCGContext *VAR_0)
{
TCGTemp *ts;
int VAR_1;
char VAR_2[64];
for(VAR_1 = 0; VAR_1 < VAR_0->nb_temps; VAR_1++) {
ts = &VAR_0->temps[VAR_1];
printf(" %10s: ", tcg_get_arg_str_idx(VAR_0, VAR_2, sizeof(VAR_2), VAR_1));
switch(ts->val_type) {
case TEMP_VAL_REG:
printf("%VAR_0", tcg_target_reg_names[ts->reg]);
break;
case TEMP_VAL_MEM:
printf("%d(%VAR_0)", (int)ts->mem_offset, tcg_target_reg_names[ts->mem_reg]);
break;
case TEMP_VAL_CONST:
printf("$0x%" TCG_PRIlx, ts->val);
break;
case TEMP_VAL_DEAD:
printf("D");
break;
default:
printf("???");
break;
}
printf("\n");
}
for(VAR_1 = 0; VAR_1 < TCG_TARGET_NB_REGS; VAR_1++) {
if (VAR_0->reg_to_temp[VAR_1] >= 0) {
printf("%VAR_0: %VAR_0\n",
tcg_target_reg_names[VAR_1],
tcg_get_arg_str_idx(VAR_0, VAR_2, sizeof(VAR_2), VAR_0->reg_to_temp[VAR_1]));
}
}
}
| [
"static void FUNC_0(TCGContext *VAR_0)\n{",
"TCGTemp *ts;",
"int VAR_1;",
"char VAR_2[64];",
"for(VAR_1 = 0; VAR_1 < VAR_0->nb_temps; VAR_1++) {",
"ts = &VAR_0->temps[VAR_1];",
"printf(\" %10s: \", tcg_get_arg_str_idx(VAR_0, VAR_2, sizeof(VAR_2), VAR_1));",
"switch(ts->val_type) {",
"case TEMP_VAL_REG:\nprintf(\"%VAR_0\", tcg_target_reg_names[ts->reg]);",
"break;",
"case TEMP_VAL_MEM:\nprintf(\"%d(%VAR_0)\", (int)ts->mem_offset, tcg_target_reg_names[ts->mem_reg]);",
"break;",
"case TEMP_VAL_CONST:\nprintf(\"$0x%\" TCG_PRIlx, ts->val);",
"break;",
"case TEMP_VAL_DEAD:\nprintf(\"D\");",
"break;",
"default:\nprintf(\"???\");",
"break;",
"}",
"printf(\"\\n\");",
"}",
"for(VAR_1 = 0; VAR_1 < TCG_TARGET_NB_REGS; VAR_1++) {",
"if (VAR_0->reg_to_temp[VAR_1] >= 0) {",
"printf(\"%VAR_0: %VAR_0\\n\",\ntcg_target_reg_names[VAR_1],\ntcg_get_arg_str_idx(VAR_0, VAR_2, sizeof(VAR_2), VAR_0->reg_to_temp[VAR_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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
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
],
[
71
],
[
73
]
] |
21,208 | static int pci_piix3_xen_ide_unplug(DeviceState *dev)
{
PCIDevice *pci_dev;
PCIIDEState *pci_ide;
DriveInfo *di;
int i = 0;
pci_dev = DO_UPCAST(PCIDevice, qdev, dev);
pci_ide = DO_UPCAST(PCIIDEState, dev, pci_dev);
for (; i < 3; i++) {
di = drive_get_by_index(IF_IDE, i);
if (di != NULL && di->bdrv != NULL && !di->bdrv->removable) {
DeviceState *ds = bdrv_get_attached(di->bdrv);
if (ds) {
bdrv_detach(di->bdrv, ds);
}
bdrv_close(di->bdrv);
pci_ide->bus[di->bus].ifs[di->unit].bs = NULL;
drive_put_ref(di);
}
}
qdev_reset_all(&(pci_ide->dev.qdev));
return 0;
}
| false | qemu | fa879d62eb51253d00b6920ce1d1d9d261370a49 | static int pci_piix3_xen_ide_unplug(DeviceState *dev)
{
PCIDevice *pci_dev;
PCIIDEState *pci_ide;
DriveInfo *di;
int i = 0;
pci_dev = DO_UPCAST(PCIDevice, qdev, dev);
pci_ide = DO_UPCAST(PCIIDEState, dev, pci_dev);
for (; i < 3; i++) {
di = drive_get_by_index(IF_IDE, i);
if (di != NULL && di->bdrv != NULL && !di->bdrv->removable) {
DeviceState *ds = bdrv_get_attached(di->bdrv);
if (ds) {
bdrv_detach(di->bdrv, ds);
}
bdrv_close(di->bdrv);
pci_ide->bus[di->bus].ifs[di->unit].bs = NULL;
drive_put_ref(di);
}
}
qdev_reset_all(&(pci_ide->dev.qdev));
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(DeviceState *VAR_0)
{
PCIDevice *pci_dev;
PCIIDEState *pci_ide;
DriveInfo *di;
int VAR_1 = 0;
pci_dev = DO_UPCAST(PCIDevice, qdev, VAR_0);
pci_ide = DO_UPCAST(PCIIDEState, VAR_0, pci_dev);
for (; VAR_1 < 3; VAR_1++) {
di = drive_get_by_index(IF_IDE, VAR_1);
if (di != NULL && di->bdrv != NULL && !di->bdrv->removable) {
DeviceState *ds = bdrv_get_attached(di->bdrv);
if (ds) {
bdrv_detach(di->bdrv, ds);
}
bdrv_close(di->bdrv);
pci_ide->bus[di->bus].ifs[di->unit].bs = NULL;
drive_put_ref(di);
}
}
qdev_reset_all(&(pci_ide->VAR_0.qdev));
return 0;
}
| [
"static int FUNC_0(DeviceState *VAR_0)\n{",
"PCIDevice *pci_dev;",
"PCIIDEState *pci_ide;",
"DriveInfo *di;",
"int VAR_1 = 0;",
"pci_dev = DO_UPCAST(PCIDevice, qdev, VAR_0);",
"pci_ide = DO_UPCAST(PCIIDEState, VAR_0, pci_dev);",
"for (; VAR_1 < 3; VAR_1++) {",
"di = drive_get_by_index(IF_IDE, VAR_1);",
"if (di != NULL && di->bdrv != NULL && !di->bdrv->removable) {",
"DeviceState *ds = bdrv_get_attached(di->bdrv);",
"if (ds) {",
"bdrv_detach(di->bdrv, ds);",
"}",
"bdrv_close(di->bdrv);",
"pci_ide->bus[di->bus].ifs[di->unit].bs = NULL;",
"drive_put_ref(di);",
"}",
"}",
"qdev_reset_all(&(pci_ide->VAR_0.qdev));",
"return 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
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
]
] |
21,209 | int get_segment64(CPUPPCState *env, mmu_ctx_t *ctx,
target_ulong eaddr, int rw, int type)
{
hwaddr hash;
target_ulong vsid;
int pr, target_page_bits;
int ret, ret2;
pr = msr_pr;
ctx->eaddr = eaddr;
ppc_slb_t *slb;
target_ulong pageaddr;
int segment_bits;
LOG_MMU("Check SLBs\n");
slb = slb_lookup(env, eaddr);
if (!slb) {
return -5;
}
if (slb->vsid & SLB_VSID_B) {
vsid = (slb->vsid & SLB_VSID_VSID) >> SLB_VSID_SHIFT_1T;
segment_bits = 40;
} else {
vsid = (slb->vsid & SLB_VSID_VSID) >> SLB_VSID_SHIFT;
segment_bits = 28;
}
target_page_bits = (slb->vsid & SLB_VSID_L)
? TARGET_PAGE_BITS_16M : TARGET_PAGE_BITS;
ctx->key = !!(pr ? (slb->vsid & SLB_VSID_KP)
: (slb->vsid & SLB_VSID_KS));
ctx->nx = !!(slb->vsid & SLB_VSID_N);
pageaddr = eaddr & ((1ULL << segment_bits)
- (1ULL << target_page_bits));
if (slb->vsid & SLB_VSID_B) {
hash = vsid ^ (vsid << 25) ^ (pageaddr >> target_page_bits);
} else {
hash = vsid ^ (pageaddr >> target_page_bits);
}
/* Only 5 bits of the page index are used in the AVPN */
ctx->ptem = (slb->vsid & SLB_VSID_PTEM) |
((pageaddr >> 16) & ((1ULL << segment_bits) - 0x80));
LOG_MMU("pte segment: key=%d nx %d vsid " TARGET_FMT_lx "\n",
ctx->key, ctx->nx, vsid);
ret = -1;
/* Check if instruction fetch is allowed, if needed */
if (type != ACCESS_CODE || ctx->nx == 0) {
/* Page address translation */
LOG_MMU("htab_base " TARGET_FMT_plx " htab_mask " TARGET_FMT_plx
" hash " TARGET_FMT_plx "\n",
env->htab_base, env->htab_mask, hash);
ctx->hash[0] = hash;
ctx->hash[1] = ~hash;
/* Initialize real address with an invalid value */
ctx->raddr = (hwaddr)-1ULL;
LOG_MMU("0 htab=" TARGET_FMT_plx "/" TARGET_FMT_plx
" vsid=" TARGET_FMT_lx " ptem=" TARGET_FMT_lx
" hash=" TARGET_FMT_plx "\n",
env->htab_base, env->htab_mask, vsid, ctx->ptem,
ctx->hash[0]);
/* Primary table lookup */
ret = find_pte64(env, ctx, 0, rw, type, target_page_bits);
if (ret < 0) {
/* Secondary table lookup */
LOG_MMU("1 htab=" TARGET_FMT_plx "/" TARGET_FMT_plx
" vsid=" TARGET_FMT_lx " api=" TARGET_FMT_lx
" hash=" TARGET_FMT_plx "\n", env->htab_base,
env->htab_mask, vsid, ctx->ptem, ctx->hash[1]);
ret2 = find_pte64(env, ctx, 1, rw, type, target_page_bits);
if (ret2 != -1) {
ret = ret2;
}
}
} else {
LOG_MMU("No access allowed\n");
ret = -3;
}
return ret;
}
| false | qemu | 629bd516fda67c95ba1c7d1393bacb9e68ea0712 | int get_segment64(CPUPPCState *env, mmu_ctx_t *ctx,
target_ulong eaddr, int rw, int type)
{
hwaddr hash;
target_ulong vsid;
int pr, target_page_bits;
int ret, ret2;
pr = msr_pr;
ctx->eaddr = eaddr;
ppc_slb_t *slb;
target_ulong pageaddr;
int segment_bits;
LOG_MMU("Check SLBs\n");
slb = slb_lookup(env, eaddr);
if (!slb) {
return -5;
}
if (slb->vsid & SLB_VSID_B) {
vsid = (slb->vsid & SLB_VSID_VSID) >> SLB_VSID_SHIFT_1T;
segment_bits = 40;
} else {
vsid = (slb->vsid & SLB_VSID_VSID) >> SLB_VSID_SHIFT;
segment_bits = 28;
}
target_page_bits = (slb->vsid & SLB_VSID_L)
? TARGET_PAGE_BITS_16M : TARGET_PAGE_BITS;
ctx->key = !!(pr ? (slb->vsid & SLB_VSID_KP)
: (slb->vsid & SLB_VSID_KS));
ctx->nx = !!(slb->vsid & SLB_VSID_N);
pageaddr = eaddr & ((1ULL << segment_bits)
- (1ULL << target_page_bits));
if (slb->vsid & SLB_VSID_B) {
hash = vsid ^ (vsid << 25) ^ (pageaddr >> target_page_bits);
} else {
hash = vsid ^ (pageaddr >> target_page_bits);
}
ctx->ptem = (slb->vsid & SLB_VSID_PTEM) |
((pageaddr >> 16) & ((1ULL << segment_bits) - 0x80));
LOG_MMU("pte segment: key=%d nx %d vsid " TARGET_FMT_lx "\n",
ctx->key, ctx->nx, vsid);
ret = -1;
if (type != ACCESS_CODE || ctx->nx == 0) {
LOG_MMU("htab_base " TARGET_FMT_plx " htab_mask " TARGET_FMT_plx
" hash " TARGET_FMT_plx "\n",
env->htab_base, env->htab_mask, hash);
ctx->hash[0] = hash;
ctx->hash[1] = ~hash;
ctx->raddr = (hwaddr)-1ULL;
LOG_MMU("0 htab=" TARGET_FMT_plx "/" TARGET_FMT_plx
" vsid=" TARGET_FMT_lx " ptem=" TARGET_FMT_lx
" hash=" TARGET_FMT_plx "\n",
env->htab_base, env->htab_mask, vsid, ctx->ptem,
ctx->hash[0]);
ret = find_pte64(env, ctx, 0, rw, type, target_page_bits);
if (ret < 0) {
LOG_MMU("1 htab=" TARGET_FMT_plx "/" TARGET_FMT_plx
" vsid=" TARGET_FMT_lx " api=" TARGET_FMT_lx
" hash=" TARGET_FMT_plx "\n", env->htab_base,
env->htab_mask, vsid, ctx->ptem, ctx->hash[1]);
ret2 = find_pte64(env, ctx, 1, rw, type, target_page_bits);
if (ret2 != -1) {
ret = ret2;
}
}
} else {
LOG_MMU("No access allowed\n");
ret = -3;
}
return ret;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(CPUPPCState *VAR_0, mmu_ctx_t *VAR_1,
target_ulong VAR_2, int VAR_3, int VAR_4)
{
hwaddr hash;
target_ulong vsid;
int VAR_5, VAR_6;
int VAR_7, VAR_8;
VAR_5 = msr_pr;
VAR_1->VAR_2 = VAR_2;
ppc_slb_t *slb;
target_ulong pageaddr;
int VAR_9;
LOG_MMU("Check SLBs\n");
slb = slb_lookup(VAR_0, VAR_2);
if (!slb) {
return -5;
}
if (slb->vsid & SLB_VSID_B) {
vsid = (slb->vsid & SLB_VSID_VSID) >> SLB_VSID_SHIFT_1T;
VAR_9 = 40;
} else {
vsid = (slb->vsid & SLB_VSID_VSID) >> SLB_VSID_SHIFT;
VAR_9 = 28;
}
VAR_6 = (slb->vsid & SLB_VSID_L)
? TARGET_PAGE_BITS_16M : TARGET_PAGE_BITS;
VAR_1->key = !!(VAR_5 ? (slb->vsid & SLB_VSID_KP)
: (slb->vsid & SLB_VSID_KS));
VAR_1->nx = !!(slb->vsid & SLB_VSID_N);
pageaddr = VAR_2 & ((1ULL << VAR_9)
- (1ULL << VAR_6));
if (slb->vsid & SLB_VSID_B) {
hash = vsid ^ (vsid << 25) ^ (pageaddr >> VAR_6);
} else {
hash = vsid ^ (pageaddr >> VAR_6);
}
VAR_1->ptem = (slb->vsid & SLB_VSID_PTEM) |
((pageaddr >> 16) & ((1ULL << VAR_9) - 0x80));
LOG_MMU("pte segment: key=%d nx %d vsid " TARGET_FMT_lx "\n",
VAR_1->key, VAR_1->nx, vsid);
VAR_7 = -1;
if (VAR_4 != ACCESS_CODE || VAR_1->nx == 0) {
LOG_MMU("htab_base " TARGET_FMT_plx " htab_mask " TARGET_FMT_plx
" hash " TARGET_FMT_plx "\n",
VAR_0->htab_base, VAR_0->htab_mask, hash);
VAR_1->hash[0] = hash;
VAR_1->hash[1] = ~hash;
VAR_1->raddr = (hwaddr)-1ULL;
LOG_MMU("0 htab=" TARGET_FMT_plx "/" TARGET_FMT_plx
" vsid=" TARGET_FMT_lx " ptem=" TARGET_FMT_lx
" hash=" TARGET_FMT_plx "\n",
VAR_0->htab_base, VAR_0->htab_mask, vsid, VAR_1->ptem,
VAR_1->hash[0]);
VAR_7 = find_pte64(VAR_0, VAR_1, 0, VAR_3, VAR_4, VAR_6);
if (VAR_7 < 0) {
LOG_MMU("1 htab=" TARGET_FMT_plx "/" TARGET_FMT_plx
" vsid=" TARGET_FMT_lx " api=" TARGET_FMT_lx
" hash=" TARGET_FMT_plx "\n", VAR_0->htab_base,
VAR_0->htab_mask, vsid, VAR_1->ptem, VAR_1->hash[1]);
VAR_8 = find_pte64(VAR_0, VAR_1, 1, VAR_3, VAR_4, VAR_6);
if (VAR_8 != -1) {
VAR_7 = VAR_8;
}
}
} else {
LOG_MMU("No access allowed\n");
VAR_7 = -3;
}
return VAR_7;
}
| [
"int FUNC_0(CPUPPCState *VAR_0, mmu_ctx_t *VAR_1,\ntarget_ulong VAR_2, int VAR_3, int VAR_4)\n{",
"hwaddr hash;",
"target_ulong vsid;",
"int VAR_5, VAR_6;",
"int VAR_7, VAR_8;",
"VAR_5 = msr_pr;",
"VAR_1->VAR_2 = VAR_2;",
"ppc_slb_t *slb;",
"target_ulong pageaddr;",
"int VAR_9;",
"LOG_MMU(\"Check SLBs\\n\");",
"slb = slb_lookup(VAR_0, VAR_2);",
"if (!slb) {",
"return -5;",
"}",
"if (slb->vsid & SLB_VSID_B) {",
"vsid = (slb->vsid & SLB_VSID_VSID) >> SLB_VSID_SHIFT_1T;",
"VAR_9 = 40;",
"} else {",
"vsid = (slb->vsid & SLB_VSID_VSID) >> SLB_VSID_SHIFT;",
"VAR_9 = 28;",
"}",
"VAR_6 = (slb->vsid & SLB_VSID_L)\n? TARGET_PAGE_BITS_16M : TARGET_PAGE_BITS;",
"VAR_1->key = !!(VAR_5 ? (slb->vsid & SLB_VSID_KP)\n: (slb->vsid & SLB_VSID_KS));",
"VAR_1->nx = !!(slb->vsid & SLB_VSID_N);",
"pageaddr = VAR_2 & ((1ULL << VAR_9)\n- (1ULL << VAR_6));",
"if (slb->vsid & SLB_VSID_B) {",
"hash = vsid ^ (vsid << 25) ^ (pageaddr >> VAR_6);",
"} else {",
"hash = vsid ^ (pageaddr >> VAR_6);",
"}",
"VAR_1->ptem = (slb->vsid & SLB_VSID_PTEM) |\n((pageaddr >> 16) & ((1ULL << VAR_9) - 0x80));",
"LOG_MMU(\"pte segment: key=%d nx %d vsid \" TARGET_FMT_lx \"\\n\",\nVAR_1->key, VAR_1->nx, vsid);",
"VAR_7 = -1;",
"if (VAR_4 != ACCESS_CODE || VAR_1->nx == 0) {",
"LOG_MMU(\"htab_base \" TARGET_FMT_plx \" htab_mask \" TARGET_FMT_plx\n\" hash \" TARGET_FMT_plx \"\\n\",\nVAR_0->htab_base, VAR_0->htab_mask, hash);",
"VAR_1->hash[0] = hash;",
"VAR_1->hash[1] = ~hash;",
"VAR_1->raddr = (hwaddr)-1ULL;",
"LOG_MMU(\"0 htab=\" TARGET_FMT_plx \"/\" TARGET_FMT_plx\n\" vsid=\" TARGET_FMT_lx \" ptem=\" TARGET_FMT_lx\n\" hash=\" TARGET_FMT_plx \"\\n\",\nVAR_0->htab_base, VAR_0->htab_mask, vsid, VAR_1->ptem,\nVAR_1->hash[0]);",
"VAR_7 = find_pte64(VAR_0, VAR_1, 0, VAR_3, VAR_4, VAR_6);",
"if (VAR_7 < 0) {",
"LOG_MMU(\"1 htab=\" TARGET_FMT_plx \"/\" TARGET_FMT_plx\n\" vsid=\" TARGET_FMT_lx \" api=\" TARGET_FMT_lx\n\" hash=\" TARGET_FMT_plx \"\\n\", VAR_0->htab_base,\nVAR_0->htab_mask, vsid, VAR_1->ptem, VAR_1->hash[1]);",
"VAR_8 = find_pte64(VAR_0, VAR_1, 1, VAR_3, VAR_4, VAR_6);",
"if (VAR_8 != -1) {",
"VAR_7 = VAR_8;",
"}",
"}",
"} else {",
"LOG_MMU(\"No access allowed\\n\");",
"VAR_7 = -3;",
"}",
"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,
0,
0,
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
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57,
59
],
[
61,
63
],
[
65
],
[
69,
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
85,
87
],
[
91,
93
],
[
95
],
[
101
],
[
105,
107,
109
],
[
111
],
[
113
],
[
119
],
[
121,
123,
125,
127,
129
],
[
133
],
[
135
],
[
139,
141,
143,
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
167
],
[
169
]
] |
21,210 | static uint64_t cirrus_vga_mem_read(void *opaque,
target_phys_addr_t addr,
uint32_t size)
{
CirrusVGAState *s = opaque;
unsigned bank_index;
unsigned bank_offset;
uint32_t val;
if ((s->vga.sr[0x07] & 0x01) == 0) {
return vga_mem_readb(&s->vga, addr);
}
if (addr < 0x10000) {
/* XXX handle bitblt */
/* video memory */
bank_index = addr >> 15;
bank_offset = addr & 0x7fff;
if (bank_offset < s->cirrus_bank_limit[bank_index]) {
bank_offset += s->cirrus_bank_base[bank_index];
if ((s->vga.gr[0x0B] & 0x14) == 0x14) {
bank_offset <<= 4;
} else if (s->vga.gr[0x0B] & 0x02) {
bank_offset <<= 3;
}
bank_offset &= s->cirrus_addr_mask;
val = *(s->vga.vram_ptr + bank_offset);
} else
val = 0xff;
} else if (addr >= 0x18000 && addr < 0x18100) {
/* memory-mapped I/O */
val = 0xff;
if ((s->vga.sr[0x17] & 0x44) == 0x04) {
val = cirrus_mmio_blt_read(s, addr & 0xff);
}
} else {
val = 0xff;
#ifdef DEBUG_CIRRUS
printf("cirrus: mem_readb " TARGET_FMT_plx "\n", addr);
#endif
}
return val;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static uint64_t cirrus_vga_mem_read(void *opaque,
target_phys_addr_t addr,
uint32_t size)
{
CirrusVGAState *s = opaque;
unsigned bank_index;
unsigned bank_offset;
uint32_t val;
if ((s->vga.sr[0x07] & 0x01) == 0) {
return vga_mem_readb(&s->vga, addr);
}
if (addr < 0x10000) {
bank_index = addr >> 15;
bank_offset = addr & 0x7fff;
if (bank_offset < s->cirrus_bank_limit[bank_index]) {
bank_offset += s->cirrus_bank_base[bank_index];
if ((s->vga.gr[0x0B] & 0x14) == 0x14) {
bank_offset <<= 4;
} else if (s->vga.gr[0x0B] & 0x02) {
bank_offset <<= 3;
}
bank_offset &= s->cirrus_addr_mask;
val = *(s->vga.vram_ptr + bank_offset);
} else
val = 0xff;
} else if (addr >= 0x18000 && addr < 0x18100) {
val = 0xff;
if ((s->vga.sr[0x17] & 0x44) == 0x04) {
val = cirrus_mmio_blt_read(s, addr & 0xff);
}
} else {
val = 0xff;
#ifdef DEBUG_CIRRUS
printf("cirrus: mem_readb " TARGET_FMT_plx "\n", addr);
#endif
}
return val;
}
| {
"code": [],
"line_no": []
} | static uint64_t FUNC_0(void *opaque,
target_phys_addr_t addr,
uint32_t size)
{
CirrusVGAState *s = opaque;
unsigned VAR_0;
unsigned VAR_1;
uint32_t val;
if ((s->vga.sr[0x07] & 0x01) == 0) {
return vga_mem_readb(&s->vga, addr);
}
if (addr < 0x10000) {
VAR_0 = addr >> 15;
VAR_1 = addr & 0x7fff;
if (VAR_1 < s->cirrus_bank_limit[VAR_0]) {
VAR_1 += s->cirrus_bank_base[VAR_0];
if ((s->vga.gr[0x0B] & 0x14) == 0x14) {
VAR_1 <<= 4;
} else if (s->vga.gr[0x0B] & 0x02) {
VAR_1 <<= 3;
}
VAR_1 &= s->cirrus_addr_mask;
val = *(s->vga.vram_ptr + VAR_1);
} else
val = 0xff;
} else if (addr >= 0x18000 && addr < 0x18100) {
val = 0xff;
if ((s->vga.sr[0x17] & 0x44) == 0x04) {
val = cirrus_mmio_blt_read(s, addr & 0xff);
}
} else {
val = 0xff;
#ifdef DEBUG_CIRRUS
printf("cirrus: mem_readb " TARGET_FMT_plx "\n", addr);
#endif
}
return val;
}
| [
"static uint64_t FUNC_0(void *opaque,\ntarget_phys_addr_t addr,\nuint32_t size)\n{",
"CirrusVGAState *s = opaque;",
"unsigned VAR_0;",
"unsigned VAR_1;",
"uint32_t val;",
"if ((s->vga.sr[0x07] & 0x01) == 0) {",
"return vga_mem_readb(&s->vga, addr);",
"}",
"if (addr < 0x10000) {",
"VAR_0 = addr >> 15;",
"VAR_1 = addr & 0x7fff;",
"if (VAR_1 < s->cirrus_bank_limit[VAR_0]) {",
"VAR_1 += s->cirrus_bank_base[VAR_0];",
"if ((s->vga.gr[0x0B] & 0x14) == 0x14) {",
"VAR_1 <<= 4;",
"} else if (s->vga.gr[0x0B] & 0x02) {",
"VAR_1 <<= 3;",
"}",
"VAR_1 &= s->cirrus_addr_mask;",
"val = *(s->vga.vram_ptr + VAR_1);",
"} else",
"val = 0xff;",
"} else if (addr >= 0x18000 && addr < 0x18100) {",
"val = 0xff;",
"if ((s->vga.sr[0x17] & 0x44) == 0x04) {",
"val = cirrus_mmio_blt_read(s, addr & 0xff);",
"}",
"} else {",
"val = 0xff;",
"#ifdef DEBUG_CIRRUS\nprintf(\"cirrus: mem_readb \" TARGET_FMT_plx \"\\n\", addr);",
"#endif\n}",
"return val;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75,
77
],
[
79,
81
],
[
83
],
[
85
]
] |
21,211 | static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)
{
XlnxZynqMPState *s = XLNX_ZYNQMP(dev);
MemoryRegion *system_memory = get_system_memory();
uint8_t i;
uint64_t ram_size;
const char *boot_cpu = s->boot_cpu ? s->boot_cpu : "apu-cpu[0]";
ram_addr_t ddr_low_size, ddr_high_size;
qemu_irq gic_spi[GIC_NUM_SPI_INTR];
Error *err = NULL;
ram_size = memory_region_size(s->ddr_ram);
/* Create the DDR Memory Regions. User friendly checks should happen at
* the board level
*/
if (ram_size > XLNX_ZYNQMP_MAX_LOW_RAM_SIZE) {
/* The RAM size is above the maximum available for the low DDR.
* Create the high DDR memory region as well.
*/
assert(ram_size <= XLNX_ZYNQMP_MAX_RAM_SIZE);
ddr_low_size = XLNX_ZYNQMP_MAX_LOW_RAM_SIZE;
ddr_high_size = ram_size - XLNX_ZYNQMP_MAX_LOW_RAM_SIZE;
memory_region_init_alias(&s->ddr_ram_high, NULL,
"ddr-ram-high", s->ddr_ram,
ddr_low_size, ddr_high_size);
memory_region_add_subregion(get_system_memory(),
XLNX_ZYNQMP_HIGH_RAM_START,
&s->ddr_ram_high);
} else {
/* RAM must be non-zero */
assert(ram_size);
ddr_low_size = ram_size;
}
memory_region_init_alias(&s->ddr_ram_low, NULL,
"ddr-ram-low", s->ddr_ram,
0, ddr_low_size);
memory_region_add_subregion(get_system_memory(), 0, &s->ddr_ram_low);
/* Create the four OCM banks */
for (i = 0; i < XLNX_ZYNQMP_NUM_OCM_BANKS; i++) {
char *ocm_name = g_strdup_printf("zynqmp.ocm_ram_bank_%d", i);
memory_region_init_ram(&s->ocm_ram[i], NULL, ocm_name,
XLNX_ZYNQMP_OCM_RAM_SIZE, &error_fatal);
vmstate_register_ram_global(&s->ocm_ram[i]);
memory_region_add_subregion(get_system_memory(),
XLNX_ZYNQMP_OCM_RAM_0_ADDRESS +
i * XLNX_ZYNQMP_OCM_RAM_SIZE,
&s->ocm_ram[i]);
g_free(ocm_name);
}
qdev_prop_set_uint32(DEVICE(&s->gic), "num-irq", GIC_NUM_SPI_INTR + 32);
qdev_prop_set_uint32(DEVICE(&s->gic), "revision", 2);
qdev_prop_set_uint32(DEVICE(&s->gic), "num-cpu", XLNX_ZYNQMP_NUM_APU_CPUS);
object_property_set_bool(OBJECT(&s->gic), true, "realized", &err);
if (err) {
error_propagate(errp, err);
return;
}
assert(ARRAY_SIZE(xlnx_zynqmp_gic_regions) == XLNX_ZYNQMP_GIC_REGIONS);
for (i = 0; i < XLNX_ZYNQMP_GIC_REGIONS; i++) {
SysBusDevice *gic = SYS_BUS_DEVICE(&s->gic);
const XlnxZynqMPGICRegion *r = &xlnx_zynqmp_gic_regions[i];
MemoryRegion *mr = sysbus_mmio_get_region(gic, r->region_index);
uint32_t addr = r->address;
int j;
sysbus_mmio_map(gic, r->region_index, addr);
for (j = 0; j < XLNX_ZYNQMP_GIC_ALIASES; j++) {
MemoryRegion *alias = &s->gic_mr[i][j];
addr += XLNX_ZYNQMP_GIC_REGION_SIZE;
memory_region_init_alias(alias, OBJECT(s), "zynqmp-gic-alias", mr,
0, XLNX_ZYNQMP_GIC_REGION_SIZE);
memory_region_add_subregion(system_memory, addr, alias);
}
}
for (i = 0; i < XLNX_ZYNQMP_NUM_APU_CPUS; i++) {
qemu_irq irq;
char *name;
object_property_set_int(OBJECT(&s->apu_cpu[i]), QEMU_PSCI_CONDUIT_SMC,
"psci-conduit", &error_abort);
name = object_get_canonical_path_component(OBJECT(&s->apu_cpu[i]));
if (strcmp(name, boot_cpu)) {
/* Secondary CPUs start in PSCI powered-down state */
object_property_set_bool(OBJECT(&s->apu_cpu[i]), true,
"start-powered-off", &error_abort);
} else {
s->boot_cpu_ptr = &s->apu_cpu[i];
}
g_free(name);
object_property_set_bool(OBJECT(&s->apu_cpu[i]),
s->secure, "has_el3", NULL);
object_property_set_int(OBJECT(&s->apu_cpu[i]), GIC_BASE_ADDR,
"reset-cbar", &error_abort);
object_property_set_bool(OBJECT(&s->apu_cpu[i]), true, "realized",
&err);
if (err) {
error_propagate(errp, err);
return;
}
sysbus_connect_irq(SYS_BUS_DEVICE(&s->gic), i,
qdev_get_gpio_in(DEVICE(&s->apu_cpu[i]),
ARM_CPU_IRQ));
irq = qdev_get_gpio_in(DEVICE(&s->gic),
arm_gic_ppi_index(i, ARM_PHYS_TIMER_PPI));
qdev_connect_gpio_out(DEVICE(&s->apu_cpu[i]), 0, irq);
irq = qdev_get_gpio_in(DEVICE(&s->gic),
arm_gic_ppi_index(i, ARM_VIRT_TIMER_PPI));
qdev_connect_gpio_out(DEVICE(&s->apu_cpu[i]), 1, irq);
}
for (i = 0; i < XLNX_ZYNQMP_NUM_RPU_CPUS; i++) {
char *name;
name = object_get_canonical_path_component(OBJECT(&s->rpu_cpu[i]));
if (strcmp(name, boot_cpu)) {
/* Secondary CPUs start in PSCI powered-down state */
object_property_set_bool(OBJECT(&s->rpu_cpu[i]), true,
"start-powered-off", &error_abort);
} else {
s->boot_cpu_ptr = &s->rpu_cpu[i];
}
g_free(name);
object_property_set_bool(OBJECT(&s->rpu_cpu[i]), true, "reset-hivecs",
&error_abort);
object_property_set_bool(OBJECT(&s->rpu_cpu[i]), true, "realized",
&err);
if (err) {
error_propagate(errp, err);
return;
}
}
if (!s->boot_cpu_ptr) {
error_setg(errp, "ZynqMP Boot cpu %s not found", boot_cpu);
return;
}
for (i = 0; i < GIC_NUM_SPI_INTR; i++) {
gic_spi[i] = qdev_get_gpio_in(DEVICE(&s->gic), i);
}
for (i = 0; i < XLNX_ZYNQMP_NUM_GEMS; i++) {
NICInfo *nd = &nd_table[i];
if (nd->used) {
qemu_check_nic_model(nd, TYPE_CADENCE_GEM);
qdev_set_nic_properties(DEVICE(&s->gem[i]), nd);
}
object_property_set_bool(OBJECT(&s->gem[i]), true, "realized", &err);
if (err) {
error_propagate(errp, err);
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->gem[i]), 0, gem_addr[i]);
sysbus_connect_irq(SYS_BUS_DEVICE(&s->gem[i]), 0,
gic_spi[gem_intr[i]]);
}
for (i = 0; i < XLNX_ZYNQMP_NUM_UARTS; i++) {
object_property_set_bool(OBJECT(&s->uart[i]), true, "realized", &err);
if (err) {
error_propagate(errp, err);
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->uart[i]), 0, uart_addr[i]);
sysbus_connect_irq(SYS_BUS_DEVICE(&s->uart[i]), 0,
gic_spi[uart_intr[i]]);
}
object_property_set_int(OBJECT(&s->sata), SATA_NUM_PORTS, "num-ports",
&error_abort);
object_property_set_bool(OBJECT(&s->sata), true, "realized", &err);
if (err) {
error_propagate(errp, err);
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->sata), 0, SATA_ADDR);
sysbus_connect_irq(SYS_BUS_DEVICE(&s->sata), 0, gic_spi[SATA_INTR]);
for (i = 0; i < XLNX_ZYNQMP_NUM_SDHCI; i++) {
char *bus_name;
object_property_set_bool(OBJECT(&s->sdhci[i]), true,
"realized", &err);
if (err) {
error_propagate(errp, err);
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->sdhci[i]), 0,
sdhci_addr[i]);
sysbus_connect_irq(SYS_BUS_DEVICE(&s->sdhci[i]), 0,
gic_spi[sdhci_intr[i]]);
/* Alias controller SD bus to the SoC itself */
bus_name = g_strdup_printf("sd-bus%d", i);
object_property_add_alias(OBJECT(s), bus_name,
OBJECT(&s->sdhci[i]), "sd-bus",
&error_abort);
g_free(bus_name);
}
for (i = 0; i < XLNX_ZYNQMP_NUM_SPIS; i++) {
gchar *bus_name;
object_property_set_bool(OBJECT(&s->spi[i]), true, "realized", &err);
sysbus_mmio_map(SYS_BUS_DEVICE(&s->spi[i]), 0, spi_addr[i]);
sysbus_connect_irq(SYS_BUS_DEVICE(&s->spi[i]), 0,
gic_spi[spi_intr[i]]);
/* Alias controller SPI bus to the SoC itself */
bus_name = g_strdup_printf("spi%d", i);
object_property_add_alias(OBJECT(s), bus_name,
OBJECT(&s->spi[i]), "spi0",
&error_abort);
g_free(bus_name);
}
}
| false | qemu | 6ed92b14f610c78aea52b087d6bdc59a3f2de72a | static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)
{
XlnxZynqMPState *s = XLNX_ZYNQMP(dev);
MemoryRegion *system_memory = get_system_memory();
uint8_t i;
uint64_t ram_size;
const char *boot_cpu = s->boot_cpu ? s->boot_cpu : "apu-cpu[0]";
ram_addr_t ddr_low_size, ddr_high_size;
qemu_irq gic_spi[GIC_NUM_SPI_INTR];
Error *err = NULL;
ram_size = memory_region_size(s->ddr_ram);
if (ram_size > XLNX_ZYNQMP_MAX_LOW_RAM_SIZE) {
assert(ram_size <= XLNX_ZYNQMP_MAX_RAM_SIZE);
ddr_low_size = XLNX_ZYNQMP_MAX_LOW_RAM_SIZE;
ddr_high_size = ram_size - XLNX_ZYNQMP_MAX_LOW_RAM_SIZE;
memory_region_init_alias(&s->ddr_ram_high, NULL,
"ddr-ram-high", s->ddr_ram,
ddr_low_size, ddr_high_size);
memory_region_add_subregion(get_system_memory(),
XLNX_ZYNQMP_HIGH_RAM_START,
&s->ddr_ram_high);
} else {
assert(ram_size);
ddr_low_size = ram_size;
}
memory_region_init_alias(&s->ddr_ram_low, NULL,
"ddr-ram-low", s->ddr_ram,
0, ddr_low_size);
memory_region_add_subregion(get_system_memory(), 0, &s->ddr_ram_low);
for (i = 0; i < XLNX_ZYNQMP_NUM_OCM_BANKS; i++) {
char *ocm_name = g_strdup_printf("zynqmp.ocm_ram_bank_%d", i);
memory_region_init_ram(&s->ocm_ram[i], NULL, ocm_name,
XLNX_ZYNQMP_OCM_RAM_SIZE, &error_fatal);
vmstate_register_ram_global(&s->ocm_ram[i]);
memory_region_add_subregion(get_system_memory(),
XLNX_ZYNQMP_OCM_RAM_0_ADDRESS +
i * XLNX_ZYNQMP_OCM_RAM_SIZE,
&s->ocm_ram[i]);
g_free(ocm_name);
}
qdev_prop_set_uint32(DEVICE(&s->gic), "num-irq", GIC_NUM_SPI_INTR + 32);
qdev_prop_set_uint32(DEVICE(&s->gic), "revision", 2);
qdev_prop_set_uint32(DEVICE(&s->gic), "num-cpu", XLNX_ZYNQMP_NUM_APU_CPUS);
object_property_set_bool(OBJECT(&s->gic), true, "realized", &err);
if (err) {
error_propagate(errp, err);
return;
}
assert(ARRAY_SIZE(xlnx_zynqmp_gic_regions) == XLNX_ZYNQMP_GIC_REGIONS);
for (i = 0; i < XLNX_ZYNQMP_GIC_REGIONS; i++) {
SysBusDevice *gic = SYS_BUS_DEVICE(&s->gic);
const XlnxZynqMPGICRegion *r = &xlnx_zynqmp_gic_regions[i];
MemoryRegion *mr = sysbus_mmio_get_region(gic, r->region_index);
uint32_t addr = r->address;
int j;
sysbus_mmio_map(gic, r->region_index, addr);
for (j = 0; j < XLNX_ZYNQMP_GIC_ALIASES; j++) {
MemoryRegion *alias = &s->gic_mr[i][j];
addr += XLNX_ZYNQMP_GIC_REGION_SIZE;
memory_region_init_alias(alias, OBJECT(s), "zynqmp-gic-alias", mr,
0, XLNX_ZYNQMP_GIC_REGION_SIZE);
memory_region_add_subregion(system_memory, addr, alias);
}
}
for (i = 0; i < XLNX_ZYNQMP_NUM_APU_CPUS; i++) {
qemu_irq irq;
char *name;
object_property_set_int(OBJECT(&s->apu_cpu[i]), QEMU_PSCI_CONDUIT_SMC,
"psci-conduit", &error_abort);
name = object_get_canonical_path_component(OBJECT(&s->apu_cpu[i]));
if (strcmp(name, boot_cpu)) {
object_property_set_bool(OBJECT(&s->apu_cpu[i]), true,
"start-powered-off", &error_abort);
} else {
s->boot_cpu_ptr = &s->apu_cpu[i];
}
g_free(name);
object_property_set_bool(OBJECT(&s->apu_cpu[i]),
s->secure, "has_el3", NULL);
object_property_set_int(OBJECT(&s->apu_cpu[i]), GIC_BASE_ADDR,
"reset-cbar", &error_abort);
object_property_set_bool(OBJECT(&s->apu_cpu[i]), true, "realized",
&err);
if (err) {
error_propagate(errp, err);
return;
}
sysbus_connect_irq(SYS_BUS_DEVICE(&s->gic), i,
qdev_get_gpio_in(DEVICE(&s->apu_cpu[i]),
ARM_CPU_IRQ));
irq = qdev_get_gpio_in(DEVICE(&s->gic),
arm_gic_ppi_index(i, ARM_PHYS_TIMER_PPI));
qdev_connect_gpio_out(DEVICE(&s->apu_cpu[i]), 0, irq);
irq = qdev_get_gpio_in(DEVICE(&s->gic),
arm_gic_ppi_index(i, ARM_VIRT_TIMER_PPI));
qdev_connect_gpio_out(DEVICE(&s->apu_cpu[i]), 1, irq);
}
for (i = 0; i < XLNX_ZYNQMP_NUM_RPU_CPUS; i++) {
char *name;
name = object_get_canonical_path_component(OBJECT(&s->rpu_cpu[i]));
if (strcmp(name, boot_cpu)) {
object_property_set_bool(OBJECT(&s->rpu_cpu[i]), true,
"start-powered-off", &error_abort);
} else {
s->boot_cpu_ptr = &s->rpu_cpu[i];
}
g_free(name);
object_property_set_bool(OBJECT(&s->rpu_cpu[i]), true, "reset-hivecs",
&error_abort);
object_property_set_bool(OBJECT(&s->rpu_cpu[i]), true, "realized",
&err);
if (err) {
error_propagate(errp, err);
return;
}
}
if (!s->boot_cpu_ptr) {
error_setg(errp, "ZynqMP Boot cpu %s not found", boot_cpu);
return;
}
for (i = 0; i < GIC_NUM_SPI_INTR; i++) {
gic_spi[i] = qdev_get_gpio_in(DEVICE(&s->gic), i);
}
for (i = 0; i < XLNX_ZYNQMP_NUM_GEMS; i++) {
NICInfo *nd = &nd_table[i];
if (nd->used) {
qemu_check_nic_model(nd, TYPE_CADENCE_GEM);
qdev_set_nic_properties(DEVICE(&s->gem[i]), nd);
}
object_property_set_bool(OBJECT(&s->gem[i]), true, "realized", &err);
if (err) {
error_propagate(errp, err);
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->gem[i]), 0, gem_addr[i]);
sysbus_connect_irq(SYS_BUS_DEVICE(&s->gem[i]), 0,
gic_spi[gem_intr[i]]);
}
for (i = 0; i < XLNX_ZYNQMP_NUM_UARTS; i++) {
object_property_set_bool(OBJECT(&s->uart[i]), true, "realized", &err);
if (err) {
error_propagate(errp, err);
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->uart[i]), 0, uart_addr[i]);
sysbus_connect_irq(SYS_BUS_DEVICE(&s->uart[i]), 0,
gic_spi[uart_intr[i]]);
}
object_property_set_int(OBJECT(&s->sata), SATA_NUM_PORTS, "num-ports",
&error_abort);
object_property_set_bool(OBJECT(&s->sata), true, "realized", &err);
if (err) {
error_propagate(errp, err);
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->sata), 0, SATA_ADDR);
sysbus_connect_irq(SYS_BUS_DEVICE(&s->sata), 0, gic_spi[SATA_INTR]);
for (i = 0; i < XLNX_ZYNQMP_NUM_SDHCI; i++) {
char *bus_name;
object_property_set_bool(OBJECT(&s->sdhci[i]), true,
"realized", &err);
if (err) {
error_propagate(errp, err);
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->sdhci[i]), 0,
sdhci_addr[i]);
sysbus_connect_irq(SYS_BUS_DEVICE(&s->sdhci[i]), 0,
gic_spi[sdhci_intr[i]]);
bus_name = g_strdup_printf("sd-bus%d", i);
object_property_add_alias(OBJECT(s), bus_name,
OBJECT(&s->sdhci[i]), "sd-bus",
&error_abort);
g_free(bus_name);
}
for (i = 0; i < XLNX_ZYNQMP_NUM_SPIS; i++) {
gchar *bus_name;
object_property_set_bool(OBJECT(&s->spi[i]), true, "realized", &err);
sysbus_mmio_map(SYS_BUS_DEVICE(&s->spi[i]), 0, spi_addr[i]);
sysbus_connect_irq(SYS_BUS_DEVICE(&s->spi[i]), 0,
gic_spi[spi_intr[i]]);
bus_name = g_strdup_printf("spi%d", i);
object_property_add_alias(OBJECT(s), bus_name,
OBJECT(&s->spi[i]), "spi0",
&error_abort);
g_free(bus_name);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)
{
XlnxZynqMPState *s = XLNX_ZYNQMP(VAR_0);
MemoryRegion *system_memory = get_system_memory();
uint8_t i;
uint64_t ram_size;
const char *VAR_2 = s->VAR_2 ? s->VAR_2 : "apu-cpu[0]";
ram_addr_t ddr_low_size, ddr_high_size;
qemu_irq gic_spi[GIC_NUM_SPI_INTR];
Error *err = NULL;
ram_size = memory_region_size(s->ddr_ram);
if (ram_size > XLNX_ZYNQMP_MAX_LOW_RAM_SIZE) {
assert(ram_size <= XLNX_ZYNQMP_MAX_RAM_SIZE);
ddr_low_size = XLNX_ZYNQMP_MAX_LOW_RAM_SIZE;
ddr_high_size = ram_size - XLNX_ZYNQMP_MAX_LOW_RAM_SIZE;
memory_region_init_alias(&s->ddr_ram_high, NULL,
"ddr-ram-high", s->ddr_ram,
ddr_low_size, ddr_high_size);
memory_region_add_subregion(get_system_memory(),
XLNX_ZYNQMP_HIGH_RAM_START,
&s->ddr_ram_high);
} else {
assert(ram_size);
ddr_low_size = ram_size;
}
memory_region_init_alias(&s->ddr_ram_low, NULL,
"ddr-ram-low", s->ddr_ram,
0, ddr_low_size);
memory_region_add_subregion(get_system_memory(), 0, &s->ddr_ram_low);
for (i = 0; i < XLNX_ZYNQMP_NUM_OCM_BANKS; i++) {
char *ocm_name = g_strdup_printf("zynqmp.ocm_ram_bank_%d", i);
memory_region_init_ram(&s->ocm_ram[i], NULL, ocm_name,
XLNX_ZYNQMP_OCM_RAM_SIZE, &error_fatal);
vmstate_register_ram_global(&s->ocm_ram[i]);
memory_region_add_subregion(get_system_memory(),
XLNX_ZYNQMP_OCM_RAM_0_ADDRESS +
i * XLNX_ZYNQMP_OCM_RAM_SIZE,
&s->ocm_ram[i]);
g_free(ocm_name);
}
qdev_prop_set_uint32(DEVICE(&s->gic), "num-irq", GIC_NUM_SPI_INTR + 32);
qdev_prop_set_uint32(DEVICE(&s->gic), "revision", 2);
qdev_prop_set_uint32(DEVICE(&s->gic), "num-cpu", XLNX_ZYNQMP_NUM_APU_CPUS);
object_property_set_bool(OBJECT(&s->gic), true, "realized", &err);
if (err) {
error_propagate(VAR_1, err);
return;
}
assert(ARRAY_SIZE(xlnx_zynqmp_gic_regions) == XLNX_ZYNQMP_GIC_REGIONS);
for (i = 0; i < XLNX_ZYNQMP_GIC_REGIONS; i++) {
SysBusDevice *gic = SYS_BUS_DEVICE(&s->gic);
const XlnxZynqMPGICRegion *r = &xlnx_zynqmp_gic_regions[i];
MemoryRegion *mr = sysbus_mmio_get_region(gic, r->region_index);
uint32_t addr = r->address;
int j;
sysbus_mmio_map(gic, r->region_index, addr);
for (j = 0; j < XLNX_ZYNQMP_GIC_ALIASES; j++) {
MemoryRegion *alias = &s->gic_mr[i][j];
addr += XLNX_ZYNQMP_GIC_REGION_SIZE;
memory_region_init_alias(alias, OBJECT(s), "zynqmp-gic-alias", mr,
0, XLNX_ZYNQMP_GIC_REGION_SIZE);
memory_region_add_subregion(system_memory, addr, alias);
}
}
for (i = 0; i < XLNX_ZYNQMP_NUM_APU_CPUS; i++) {
qemu_irq irq;
char *name;
object_property_set_int(OBJECT(&s->apu_cpu[i]), QEMU_PSCI_CONDUIT_SMC,
"psci-conduit", &error_abort);
name = object_get_canonical_path_component(OBJECT(&s->apu_cpu[i]));
if (strcmp(name, VAR_2)) {
object_property_set_bool(OBJECT(&s->apu_cpu[i]), true,
"start-powered-off", &error_abort);
} else {
s->boot_cpu_ptr = &s->apu_cpu[i];
}
g_free(name);
object_property_set_bool(OBJECT(&s->apu_cpu[i]),
s->secure, "has_el3", NULL);
object_property_set_int(OBJECT(&s->apu_cpu[i]), GIC_BASE_ADDR,
"reset-cbar", &error_abort);
object_property_set_bool(OBJECT(&s->apu_cpu[i]), true, "realized",
&err);
if (err) {
error_propagate(VAR_1, err);
return;
}
sysbus_connect_irq(SYS_BUS_DEVICE(&s->gic), i,
qdev_get_gpio_in(DEVICE(&s->apu_cpu[i]),
ARM_CPU_IRQ));
irq = qdev_get_gpio_in(DEVICE(&s->gic),
arm_gic_ppi_index(i, ARM_PHYS_TIMER_PPI));
qdev_connect_gpio_out(DEVICE(&s->apu_cpu[i]), 0, irq);
irq = qdev_get_gpio_in(DEVICE(&s->gic),
arm_gic_ppi_index(i, ARM_VIRT_TIMER_PPI));
qdev_connect_gpio_out(DEVICE(&s->apu_cpu[i]), 1, irq);
}
for (i = 0; i < XLNX_ZYNQMP_NUM_RPU_CPUS; i++) {
char *name;
name = object_get_canonical_path_component(OBJECT(&s->rpu_cpu[i]));
if (strcmp(name, VAR_2)) {
object_property_set_bool(OBJECT(&s->rpu_cpu[i]), true,
"start-powered-off", &error_abort);
} else {
s->boot_cpu_ptr = &s->rpu_cpu[i];
}
g_free(name);
object_property_set_bool(OBJECT(&s->rpu_cpu[i]), true, "reset-hivecs",
&error_abort);
object_property_set_bool(OBJECT(&s->rpu_cpu[i]), true, "realized",
&err);
if (err) {
error_propagate(VAR_1, err);
return;
}
}
if (!s->boot_cpu_ptr) {
error_setg(VAR_1, "ZynqMP Boot cpu %s not found", VAR_2);
return;
}
for (i = 0; i < GIC_NUM_SPI_INTR; i++) {
gic_spi[i] = qdev_get_gpio_in(DEVICE(&s->gic), i);
}
for (i = 0; i < XLNX_ZYNQMP_NUM_GEMS; i++) {
NICInfo *nd = &nd_table[i];
if (nd->used) {
qemu_check_nic_model(nd, TYPE_CADENCE_GEM);
qdev_set_nic_properties(DEVICE(&s->gem[i]), nd);
}
object_property_set_bool(OBJECT(&s->gem[i]), true, "realized", &err);
if (err) {
error_propagate(VAR_1, err);
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->gem[i]), 0, gem_addr[i]);
sysbus_connect_irq(SYS_BUS_DEVICE(&s->gem[i]), 0,
gic_spi[gem_intr[i]]);
}
for (i = 0; i < XLNX_ZYNQMP_NUM_UARTS; i++) {
object_property_set_bool(OBJECT(&s->uart[i]), true, "realized", &err);
if (err) {
error_propagate(VAR_1, err);
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->uart[i]), 0, uart_addr[i]);
sysbus_connect_irq(SYS_BUS_DEVICE(&s->uart[i]), 0,
gic_spi[uart_intr[i]]);
}
object_property_set_int(OBJECT(&s->sata), SATA_NUM_PORTS, "num-ports",
&error_abort);
object_property_set_bool(OBJECT(&s->sata), true, "realized", &err);
if (err) {
error_propagate(VAR_1, err);
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->sata), 0, SATA_ADDR);
sysbus_connect_irq(SYS_BUS_DEVICE(&s->sata), 0, gic_spi[SATA_INTR]);
for (i = 0; i < XLNX_ZYNQMP_NUM_SDHCI; i++) {
char *bus_name;
object_property_set_bool(OBJECT(&s->sdhci[i]), true,
"realized", &err);
if (err) {
error_propagate(VAR_1, err);
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->sdhci[i]), 0,
sdhci_addr[i]);
sysbus_connect_irq(SYS_BUS_DEVICE(&s->sdhci[i]), 0,
gic_spi[sdhci_intr[i]]);
bus_name = g_strdup_printf("sd-bus%d", i);
object_property_add_alias(OBJECT(s), bus_name,
OBJECT(&s->sdhci[i]), "sd-bus",
&error_abort);
g_free(bus_name);
}
for (i = 0; i < XLNX_ZYNQMP_NUM_SPIS; i++) {
gchar *bus_name;
object_property_set_bool(OBJECT(&s->spi[i]), true, "realized", &err);
sysbus_mmio_map(SYS_BUS_DEVICE(&s->spi[i]), 0, spi_addr[i]);
sysbus_connect_irq(SYS_BUS_DEVICE(&s->spi[i]), 0,
gic_spi[spi_intr[i]]);
bus_name = g_strdup_printf("spi%d", i);
object_property_add_alias(OBJECT(s), bus_name,
OBJECT(&s->spi[i]), "spi0",
&error_abort);
g_free(bus_name);
}
}
| [
"static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)\n{",
"XlnxZynqMPState *s = XLNX_ZYNQMP(VAR_0);",
"MemoryRegion *system_memory = get_system_memory();",
"uint8_t i;",
"uint64_t ram_size;",
"const char *VAR_2 = s->VAR_2 ? s->VAR_2 : \"apu-cpu[0]\";",
"ram_addr_t ddr_low_size, ddr_high_size;",
"qemu_irq gic_spi[GIC_NUM_SPI_INTR];",
"Error *err = NULL;",
"ram_size = memory_region_size(s->ddr_ram);",
"if (ram_size > XLNX_ZYNQMP_MAX_LOW_RAM_SIZE) {",
"assert(ram_size <= XLNX_ZYNQMP_MAX_RAM_SIZE);",
"ddr_low_size = XLNX_ZYNQMP_MAX_LOW_RAM_SIZE;",
"ddr_high_size = ram_size - XLNX_ZYNQMP_MAX_LOW_RAM_SIZE;",
"memory_region_init_alias(&s->ddr_ram_high, NULL,\n\"ddr-ram-high\", s->ddr_ram,\nddr_low_size, ddr_high_size);",
"memory_region_add_subregion(get_system_memory(),\nXLNX_ZYNQMP_HIGH_RAM_START,\n&s->ddr_ram_high);",
"} else {",
"assert(ram_size);",
"ddr_low_size = ram_size;",
"}",
"memory_region_init_alias(&s->ddr_ram_low, NULL,\n\"ddr-ram-low\", s->ddr_ram,\n0, ddr_low_size);",
"memory_region_add_subregion(get_system_memory(), 0, &s->ddr_ram_low);",
"for (i = 0; i < XLNX_ZYNQMP_NUM_OCM_BANKS; i++) {",
"char *ocm_name = g_strdup_printf(\"zynqmp.ocm_ram_bank_%d\", i);",
"memory_region_init_ram(&s->ocm_ram[i], NULL, ocm_name,\nXLNX_ZYNQMP_OCM_RAM_SIZE, &error_fatal);",
"vmstate_register_ram_global(&s->ocm_ram[i]);",
"memory_region_add_subregion(get_system_memory(),\nXLNX_ZYNQMP_OCM_RAM_0_ADDRESS +\ni * XLNX_ZYNQMP_OCM_RAM_SIZE,\n&s->ocm_ram[i]);",
"g_free(ocm_name);",
"}",
"qdev_prop_set_uint32(DEVICE(&s->gic), \"num-irq\", GIC_NUM_SPI_INTR + 32);",
"qdev_prop_set_uint32(DEVICE(&s->gic), \"revision\", 2);",
"qdev_prop_set_uint32(DEVICE(&s->gic), \"num-cpu\", XLNX_ZYNQMP_NUM_APU_CPUS);",
"object_property_set_bool(OBJECT(&s->gic), true, \"realized\", &err);",
"if (err) {",
"error_propagate(VAR_1, err);",
"return;",
"}",
"assert(ARRAY_SIZE(xlnx_zynqmp_gic_regions) == XLNX_ZYNQMP_GIC_REGIONS);",
"for (i = 0; i < XLNX_ZYNQMP_GIC_REGIONS; i++) {",
"SysBusDevice *gic = SYS_BUS_DEVICE(&s->gic);",
"const XlnxZynqMPGICRegion *r = &xlnx_zynqmp_gic_regions[i];",
"MemoryRegion *mr = sysbus_mmio_get_region(gic, r->region_index);",
"uint32_t addr = r->address;",
"int j;",
"sysbus_mmio_map(gic, r->region_index, addr);",
"for (j = 0; j < XLNX_ZYNQMP_GIC_ALIASES; j++) {",
"MemoryRegion *alias = &s->gic_mr[i][j];",
"addr += XLNX_ZYNQMP_GIC_REGION_SIZE;",
"memory_region_init_alias(alias, OBJECT(s), \"zynqmp-gic-alias\", mr,\n0, XLNX_ZYNQMP_GIC_REGION_SIZE);",
"memory_region_add_subregion(system_memory, addr, alias);",
"}",
"}",
"for (i = 0; i < XLNX_ZYNQMP_NUM_APU_CPUS; i++) {",
"qemu_irq irq;",
"char *name;",
"object_property_set_int(OBJECT(&s->apu_cpu[i]), QEMU_PSCI_CONDUIT_SMC,\n\"psci-conduit\", &error_abort);",
"name = object_get_canonical_path_component(OBJECT(&s->apu_cpu[i]));",
"if (strcmp(name, VAR_2)) {",
"object_property_set_bool(OBJECT(&s->apu_cpu[i]), true,\n\"start-powered-off\", &error_abort);",
"} else {",
"s->boot_cpu_ptr = &s->apu_cpu[i];",
"}",
"g_free(name);",
"object_property_set_bool(OBJECT(&s->apu_cpu[i]),\ns->secure, \"has_el3\", NULL);",
"object_property_set_int(OBJECT(&s->apu_cpu[i]), GIC_BASE_ADDR,\n\"reset-cbar\", &error_abort);",
"object_property_set_bool(OBJECT(&s->apu_cpu[i]), true, \"realized\",\n&err);",
"if (err) {",
"error_propagate(VAR_1, err);",
"return;",
"}",
"sysbus_connect_irq(SYS_BUS_DEVICE(&s->gic), i,\nqdev_get_gpio_in(DEVICE(&s->apu_cpu[i]),\nARM_CPU_IRQ));",
"irq = qdev_get_gpio_in(DEVICE(&s->gic),\narm_gic_ppi_index(i, ARM_PHYS_TIMER_PPI));",
"qdev_connect_gpio_out(DEVICE(&s->apu_cpu[i]), 0, irq);",
"irq = qdev_get_gpio_in(DEVICE(&s->gic),\narm_gic_ppi_index(i, ARM_VIRT_TIMER_PPI));",
"qdev_connect_gpio_out(DEVICE(&s->apu_cpu[i]), 1, irq);",
"}",
"for (i = 0; i < XLNX_ZYNQMP_NUM_RPU_CPUS; i++) {",
"char *name;",
"name = object_get_canonical_path_component(OBJECT(&s->rpu_cpu[i]));",
"if (strcmp(name, VAR_2)) {",
"object_property_set_bool(OBJECT(&s->rpu_cpu[i]), true,\n\"start-powered-off\", &error_abort);",
"} else {",
"s->boot_cpu_ptr = &s->rpu_cpu[i];",
"}",
"g_free(name);",
"object_property_set_bool(OBJECT(&s->rpu_cpu[i]), true, \"reset-hivecs\",\n&error_abort);",
"object_property_set_bool(OBJECT(&s->rpu_cpu[i]), true, \"realized\",\n&err);",
"if (err) {",
"error_propagate(VAR_1, err);",
"return;",
"}",
"}",
"if (!s->boot_cpu_ptr) {",
"error_setg(VAR_1, \"ZynqMP Boot cpu %s not found\", VAR_2);",
"return;",
"}",
"for (i = 0; i < GIC_NUM_SPI_INTR; i++) {",
"gic_spi[i] = qdev_get_gpio_in(DEVICE(&s->gic), i);",
"}",
"for (i = 0; i < XLNX_ZYNQMP_NUM_GEMS; i++) {",
"NICInfo *nd = &nd_table[i];",
"if (nd->used) {",
"qemu_check_nic_model(nd, TYPE_CADENCE_GEM);",
"qdev_set_nic_properties(DEVICE(&s->gem[i]), nd);",
"}",
"object_property_set_bool(OBJECT(&s->gem[i]), true, \"realized\", &err);",
"if (err) {",
"error_propagate(VAR_1, err);",
"return;",
"}",
"sysbus_mmio_map(SYS_BUS_DEVICE(&s->gem[i]), 0, gem_addr[i]);",
"sysbus_connect_irq(SYS_BUS_DEVICE(&s->gem[i]), 0,\ngic_spi[gem_intr[i]]);",
"}",
"for (i = 0; i < XLNX_ZYNQMP_NUM_UARTS; i++) {",
"object_property_set_bool(OBJECT(&s->uart[i]), true, \"realized\", &err);",
"if (err) {",
"error_propagate(VAR_1, err);",
"return;",
"}",
"sysbus_mmio_map(SYS_BUS_DEVICE(&s->uart[i]), 0, uart_addr[i]);",
"sysbus_connect_irq(SYS_BUS_DEVICE(&s->uart[i]), 0,\ngic_spi[uart_intr[i]]);",
"}",
"object_property_set_int(OBJECT(&s->sata), SATA_NUM_PORTS, \"num-ports\",\n&error_abort);",
"object_property_set_bool(OBJECT(&s->sata), true, \"realized\", &err);",
"if (err) {",
"error_propagate(VAR_1, err);",
"return;",
"}",
"sysbus_mmio_map(SYS_BUS_DEVICE(&s->sata), 0, SATA_ADDR);",
"sysbus_connect_irq(SYS_BUS_DEVICE(&s->sata), 0, gic_spi[SATA_INTR]);",
"for (i = 0; i < XLNX_ZYNQMP_NUM_SDHCI; i++) {",
"char *bus_name;",
"object_property_set_bool(OBJECT(&s->sdhci[i]), true,\n\"realized\", &err);",
"if (err) {",
"error_propagate(VAR_1, err);",
"return;",
"}",
"sysbus_mmio_map(SYS_BUS_DEVICE(&s->sdhci[i]), 0,\nsdhci_addr[i]);",
"sysbus_connect_irq(SYS_BUS_DEVICE(&s->sdhci[i]), 0,\ngic_spi[sdhci_intr[i]]);",
"bus_name = g_strdup_printf(\"sd-bus%d\", i);",
"object_property_add_alias(OBJECT(s), bus_name,\nOBJECT(&s->sdhci[i]), \"sd-bus\",\n&error_abort);",
"g_free(bus_name);",
"}",
"for (i = 0; i < XLNX_ZYNQMP_NUM_SPIS; i++) {",
"gchar *bus_name;",
"object_property_set_bool(OBJECT(&s->spi[i]), true, \"realized\", &err);",
"sysbus_mmio_map(SYS_BUS_DEVICE(&s->spi[i]), 0, spi_addr[i]);",
"sysbus_connect_irq(SYS_BUS_DEVICE(&s->spi[i]), 0,\ngic_spi[spi_intr[i]]);",
"bus_name = g_strdup_printf(\"spi%d\", i);",
"object_property_add_alias(OBJECT(s), bus_name,\nOBJECT(&s->spi[i]), \"spi0\",\n&error_abort);",
"g_free(bus_name);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
23
],
[
33
],
[
41
],
[
43
],
[
45
],
[
49,
51,
53
],
[
55,
57,
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
73,
75,
77
],
[
79
],
[
85
],
[
87
],
[
91,
93
],
[
95
],
[
97,
99,
101,
103
],
[
107
],
[
109
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
145
],
[
149
],
[
151
],
[
155
],
[
157,
159
],
[
161
],
[
163
],
[
165
],
[
169
],
[
171
],
[
173
],
[
177,
179
],
[
183
],
[
185
],
[
189,
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
203,
205
],
[
207,
209
],
[
211,
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
225,
227,
229
],
[
231,
233
],
[
235
],
[
237,
239
],
[
241
],
[
243
],
[
247
],
[
249
],
[
253
],
[
255
],
[
259,
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
273,
275
],
[
277,
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
293
],
[
295
],
[
297
],
[
299
],
[
303
],
[
305
],
[
307
],
[
311
],
[
313
],
[
317
],
[
319
],
[
321
],
[
323
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333
],
[
335
],
[
337,
339
],
[
341
],
[
345
],
[
347
],
[
349
],
[
351
],
[
353
],
[
355
],
[
357
],
[
359,
361
],
[
363
],
[
367,
369
],
[
371
],
[
373
],
[
375
],
[
377
],
[
379
],
[
383
],
[
385
],
[
389
],
[
391
],
[
395,
397
],
[
399
],
[
401
],
[
403
],
[
405
],
[
407,
409
],
[
411,
413
],
[
417
],
[
419,
421,
423
],
[
425
],
[
427
],
[
431
],
[
433
],
[
437
],
[
441
],
[
443,
445
],
[
451
],
[
453,
455,
457
],
[
459
],
[
461
],
[
463
]
] |
21,212 | static void virtio_pci_dc_realize(DeviceState *qdev, Error **errp)
{
VirtioPCIClass *vpciklass = VIRTIO_PCI_GET_CLASS(qdev);
VirtIOPCIProxy *proxy = VIRTIO_PCI(qdev);
PCIDevice *pci_dev = &proxy->pci_dev;
if (!(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_PCIE) &&
!(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_MODERN)) {
pci_dev->cap_present |= QEMU_PCI_CAP_EXPRESS;
}
vpciklass->parent_dc_realize(qdev, errp);
}
| false | qemu | 9a4c0e220d8a4f82b5665d0ee95ef94d8e1509d5 | static void virtio_pci_dc_realize(DeviceState *qdev, Error **errp)
{
VirtioPCIClass *vpciklass = VIRTIO_PCI_GET_CLASS(qdev);
VirtIOPCIProxy *proxy = VIRTIO_PCI(qdev);
PCIDevice *pci_dev = &proxy->pci_dev;
if (!(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_PCIE) &&
!(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_MODERN)) {
pci_dev->cap_present |= QEMU_PCI_CAP_EXPRESS;
}
vpciklass->parent_dc_realize(qdev, errp);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)
{
VirtioPCIClass *vpciklass = VIRTIO_PCI_GET_CLASS(VAR_0);
VirtIOPCIProxy *proxy = VIRTIO_PCI(VAR_0);
PCIDevice *pci_dev = &proxy->pci_dev;
if (!(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_PCIE) &&
!(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_MODERN)) {
pci_dev->cap_present |= QEMU_PCI_CAP_EXPRESS;
}
vpciklass->parent_dc_realize(VAR_0, VAR_1);
}
| [
"static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)\n{",
"VirtioPCIClass *vpciklass = VIRTIO_PCI_GET_CLASS(VAR_0);",
"VirtIOPCIProxy *proxy = VIRTIO_PCI(VAR_0);",
"PCIDevice *pci_dev = &proxy->pci_dev;",
"if (!(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_PCIE) &&\n!(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_MODERN)) {",
"pci_dev->cap_present |= QEMU_PCI_CAP_EXPRESS;",
"}",
"vpciklass->parent_dc_realize(VAR_0, VAR_1);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13,
15
],
[
17
],
[
19
],
[
23
],
[
25
]
] |
21,213 | static void v9fs_symlink(void *opaque)
{
V9fsPDU *pdu = opaque;
V9fsString name;
V9fsString symname;
V9fsString fullname;
V9fsFidState *dfidp;
V9fsQID qid;
struct stat stbuf;
int32_t dfid;
int err = 0;
gid_t gid;
size_t offset = 7;
v9fs_string_init(&fullname);
pdu_unmarshal(pdu, offset, "dssd", &dfid, &name, &symname, &gid);
dfidp = get_fid(pdu->s, dfid);
if (dfidp == NULL) {
err = -EINVAL;
goto out_nofid;
}
v9fs_string_sprintf(&fullname, "%s/%s", dfidp->path.data, name.data);
err = v9fs_co_symlink(pdu->s, dfidp, symname.data, fullname.data, gid);
if (err < 0) {
goto out;
}
err = v9fs_co_lstat(pdu->s, &fullname, &stbuf);
if (err < 0) {
goto out;
}
stat_to_qid(&stbuf, &qid);
offset += pdu_marshal(pdu, offset, "Q", &qid);
err = offset;
out:
put_fid(pdu->s, dfidp);
out_nofid:
complete_pdu(pdu->s, pdu, err);
v9fs_string_free(&name);
v9fs_string_free(&symname);
v9fs_string_free(&fullname);
}
| false | qemu | 02cb7f3a256517cbf3136caff2863fbafc57b540 | static void v9fs_symlink(void *opaque)
{
V9fsPDU *pdu = opaque;
V9fsString name;
V9fsString symname;
V9fsString fullname;
V9fsFidState *dfidp;
V9fsQID qid;
struct stat stbuf;
int32_t dfid;
int err = 0;
gid_t gid;
size_t offset = 7;
v9fs_string_init(&fullname);
pdu_unmarshal(pdu, offset, "dssd", &dfid, &name, &symname, &gid);
dfidp = get_fid(pdu->s, dfid);
if (dfidp == NULL) {
err = -EINVAL;
goto out_nofid;
}
v9fs_string_sprintf(&fullname, "%s/%s", dfidp->path.data, name.data);
err = v9fs_co_symlink(pdu->s, dfidp, symname.data, fullname.data, gid);
if (err < 0) {
goto out;
}
err = v9fs_co_lstat(pdu->s, &fullname, &stbuf);
if (err < 0) {
goto out;
}
stat_to_qid(&stbuf, &qid);
offset += pdu_marshal(pdu, offset, "Q", &qid);
err = offset;
out:
put_fid(pdu->s, dfidp);
out_nofid:
complete_pdu(pdu->s, pdu, err);
v9fs_string_free(&name);
v9fs_string_free(&symname);
v9fs_string_free(&fullname);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0)
{
V9fsPDU *pdu = VAR_0;
V9fsString name;
V9fsString symname;
V9fsString fullname;
V9fsFidState *dfidp;
V9fsQID qid;
struct stat VAR_1;
int32_t dfid;
int VAR_2 = 0;
gid_t gid;
size_t offset = 7;
v9fs_string_init(&fullname);
pdu_unmarshal(pdu, offset, "dssd", &dfid, &name, &symname, &gid);
dfidp = get_fid(pdu->s, dfid);
if (dfidp == NULL) {
VAR_2 = -EINVAL;
goto out_nofid;
}
v9fs_string_sprintf(&fullname, "%s/%s", dfidp->path.data, name.data);
VAR_2 = v9fs_co_symlink(pdu->s, dfidp, symname.data, fullname.data, gid);
if (VAR_2 < 0) {
goto out;
}
VAR_2 = v9fs_co_lstat(pdu->s, &fullname, &VAR_1);
if (VAR_2 < 0) {
goto out;
}
stat_to_qid(&VAR_1, &qid);
offset += pdu_marshal(pdu, offset, "Q", &qid);
VAR_2 = offset;
out:
put_fid(pdu->s, dfidp);
out_nofid:
complete_pdu(pdu->s, pdu, VAR_2);
v9fs_string_free(&name);
v9fs_string_free(&symname);
v9fs_string_free(&fullname);
}
| [
"static void FUNC_0(void *VAR_0)\n{",
"V9fsPDU *pdu = VAR_0;",
"V9fsString name;",
"V9fsString symname;",
"V9fsString fullname;",
"V9fsFidState *dfidp;",
"V9fsQID qid;",
"struct stat VAR_1;",
"int32_t dfid;",
"int VAR_2 = 0;",
"gid_t gid;",
"size_t offset = 7;",
"v9fs_string_init(&fullname);",
"pdu_unmarshal(pdu, offset, \"dssd\", &dfid, &name, &symname, &gid);",
"dfidp = get_fid(pdu->s, dfid);",
"if (dfidp == NULL) {",
"VAR_2 = -EINVAL;",
"goto out_nofid;",
"}",
"v9fs_string_sprintf(&fullname, \"%s/%s\", dfidp->path.data, name.data);",
"VAR_2 = v9fs_co_symlink(pdu->s, dfidp, symname.data, fullname.data, gid);",
"if (VAR_2 < 0) {",
"goto out;",
"}",
"VAR_2 = v9fs_co_lstat(pdu->s, &fullname, &VAR_1);",
"if (VAR_2 < 0) {",
"goto out;",
"}",
"stat_to_qid(&VAR_1, &qid);",
"offset += pdu_marshal(pdu, offset, \"Q\", &qid);",
"VAR_2 = offset;",
"out:\nput_fid(pdu->s, dfidp);",
"out_nofid:\ncomplete_pdu(pdu->s, pdu, VAR_2);",
"v9fs_string_free(&name);",
"v9fs_string_free(&symname);",
"v9fs_string_free(&fullname);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71,
73
],
[
75,
77
],
[
79
],
[
81
],
[
83
],
[
85
]
] |
21,214 | static void s390_pci_generate_error_event(uint16_t pec, uint32_t fh,
uint32_t fid, uint64_t faddr,
uint32_t e)
{
s390_pci_generate_event(1, pec, fh, fid, faddr, e);
}
| false | qemu | 5d1abf234462d13bef3617cc2c55b6815703ddf2 | static void s390_pci_generate_error_event(uint16_t pec, uint32_t fh,
uint32_t fid, uint64_t faddr,
uint32_t e)
{
s390_pci_generate_event(1, pec, fh, fid, faddr, e);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(uint16_t VAR_0, uint32_t VAR_1,
uint32_t VAR_2, uint64_t VAR_3,
uint32_t VAR_4)
{
s390_pci_generate_event(1, VAR_0, VAR_1, VAR_2, VAR_3, VAR_4);
}
| [
"static void FUNC_0(uint16_t VAR_0, uint32_t VAR_1,\nuint32_t VAR_2, uint64_t VAR_3,\nuint32_t VAR_4)\n{",
"s390_pci_generate_event(1, VAR_0, VAR_1, VAR_2, VAR_3, VAR_4);",
"}"
] | [
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
]
] |
21,216 | int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx,
AVFrame *frame,
int *got_frame_ptr,
AVPacket *avpkt)
{
AVCodecInternal *avci = avctx->internal;
int planar, channels;
int ret = 0;
*got_frame_ptr = 0;
avctx->pkt = avpkt;
if (!avpkt->data && avpkt->size) {
av_log(avctx, AV_LOG_ERROR, "invalid packet: NULL data, size != 0\n");
return AVERROR(EINVAL);
}
apply_param_change(avctx, avpkt);
avcodec_get_frame_defaults(frame);
if (!avctx->refcounted_frames)
av_frame_unref(&avci->to_free);
if ((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size) {
ret = avctx->codec->decode(avctx, frame, got_frame_ptr, avpkt);
if (ret >= 0 && *got_frame_ptr) {
avctx->frame_number++;
frame->pkt_dts = avpkt->dts;
if (frame->format == AV_SAMPLE_FMT_NONE)
frame->format = avctx->sample_fmt;
if (!avctx->refcounted_frames) {
avci->to_free = *frame;
avci->to_free.extended_data = avci->to_free.data;
memset(frame->buf, 0, sizeof(frame->buf));
frame->extended_buf = NULL;
frame->nb_extended_buf = 0;
}
} else if (frame->data[0])
av_frame_unref(frame);
}
/* many decoders assign whole AVFrames, thus overwriting extended_data;
* make sure it's set correctly; assume decoders that actually use
* extended_data are doing it correctly */
planar = av_sample_fmt_is_planar(frame->format);
channels = av_get_channel_layout_nb_channels(frame->channel_layout);
if (!(planar && channels > AV_NUM_DATA_POINTERS))
frame->extended_data = frame->data;
return ret;
}
| false | FFmpeg | b9589f5a770ec2357ab7920a5fabe8510b8601f9 | int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx,
AVFrame *frame,
int *got_frame_ptr,
AVPacket *avpkt)
{
AVCodecInternal *avci = avctx->internal;
int planar, channels;
int ret = 0;
*got_frame_ptr = 0;
avctx->pkt = avpkt;
if (!avpkt->data && avpkt->size) {
av_log(avctx, AV_LOG_ERROR, "invalid packet: NULL data, size != 0\n");
return AVERROR(EINVAL);
}
apply_param_change(avctx, avpkt);
avcodec_get_frame_defaults(frame);
if (!avctx->refcounted_frames)
av_frame_unref(&avci->to_free);
if ((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size) {
ret = avctx->codec->decode(avctx, frame, got_frame_ptr, avpkt);
if (ret >= 0 && *got_frame_ptr) {
avctx->frame_number++;
frame->pkt_dts = avpkt->dts;
if (frame->format == AV_SAMPLE_FMT_NONE)
frame->format = avctx->sample_fmt;
if (!avctx->refcounted_frames) {
avci->to_free = *frame;
avci->to_free.extended_data = avci->to_free.data;
memset(frame->buf, 0, sizeof(frame->buf));
frame->extended_buf = NULL;
frame->nb_extended_buf = 0;
}
} else if (frame->data[0])
av_frame_unref(frame);
}
planar = av_sample_fmt_is_planar(frame->format);
channels = av_get_channel_layout_nb_channels(frame->channel_layout);
if (!(planar && channels > AV_NUM_DATA_POINTERS))
frame->extended_data = frame->data;
return ret;
}
| {
"code": [],
"line_no": []
} | int VAR_0 avcodec_decode_audio4(AVCodecContext *avctx,
AVFrame *frame,
int *got_frame_ptr,
AVPacket *avpkt)
{
AVCodecInternal *avci = avctx->internal;
int planar, channels;
int ret = 0;
*got_frame_ptr = 0;
avctx->pkt = avpkt;
if (!avpkt->data && avpkt->size) {
av_log(avctx, AV_LOG_ERROR, "invalid packet: NULL data, size != 0\n");
return AVERROR(EINVAL);
}
apply_param_change(avctx, avpkt);
avcodec_get_frame_defaults(frame);
if (!avctx->refcounted_frames)
av_frame_unref(&avci->to_free);
if ((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size) {
ret = avctx->codec->decode(avctx, frame, got_frame_ptr, avpkt);
if (ret >= 0 && *got_frame_ptr) {
avctx->frame_number++;
frame->pkt_dts = avpkt->dts;
if (frame->format == AV_SAMPLE_FMT_NONE)
frame->format = avctx->sample_fmt;
if (!avctx->refcounted_frames) {
avci->to_free = *frame;
avci->to_free.extended_data = avci->to_free.data;
memset(frame->buf, 0, sizeof(frame->buf));
frame->extended_buf = NULL;
frame->nb_extended_buf = 0;
}
} else if (frame->data[0])
av_frame_unref(frame);
}
planar = av_sample_fmt_is_planar(frame->format);
channels = av_get_channel_layout_nb_channels(frame->channel_layout);
if (!(planar && channels > AV_NUM_DATA_POINTERS))
frame->extended_data = frame->data;
return ret;
}
| [
"int VAR_0 avcodec_decode_audio4(AVCodecContext *avctx,\nAVFrame *frame,\nint *got_frame_ptr,\nAVPacket *avpkt)\n{",
"AVCodecInternal *avci = avctx->internal;",
"int planar, channels;",
"int ret = 0;",
"*got_frame_ptr = 0;",
"avctx->pkt = avpkt;",
"if (!avpkt->data && avpkt->size) {",
"av_log(avctx, AV_LOG_ERROR, \"invalid packet: NULL data, size != 0\\n\");",
"return AVERROR(EINVAL);",
"}",
"apply_param_change(avctx, avpkt);",
"avcodec_get_frame_defaults(frame);",
"if (!avctx->refcounted_frames)\nav_frame_unref(&avci->to_free);",
"if ((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size) {",
"ret = avctx->codec->decode(avctx, frame, got_frame_ptr, avpkt);",
"if (ret >= 0 && *got_frame_ptr) {",
"avctx->frame_number++;",
"frame->pkt_dts = avpkt->dts;",
"if (frame->format == AV_SAMPLE_FMT_NONE)\nframe->format = avctx->sample_fmt;",
"if (!avctx->refcounted_frames) {",
"avci->to_free = *frame;",
"avci->to_free.extended_data = avci->to_free.data;",
"memset(frame->buf, 0, sizeof(frame->buf));",
"frame->extended_buf = NULL;",
"frame->nb_extended_buf = 0;",
"}",
"} else if (frame->data[0])",
"av_frame_unref(frame);",
"}",
"planar = av_sample_fmt_is_planar(frame->format);",
"channels = av_get_channel_layout_nb_channels(frame->channel_layout);",
"if (!(planar && channels > AV_NUM_DATA_POINTERS))\nframe->extended_data = frame->data;",
"return ret;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
41
],
[
45,
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61,
63
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
95
],
[
97
],
[
99,
101
],
[
105
],
[
107
]
] |
21,217 | struct HCIInfo *hci_init(const char *str)
{
char *endp;
struct bt_scatternet_s *vlan = 0;
if (!strcmp(str, "null"))
/* null */
return &null_hci;
else if (!strncmp(str, "host", 4) && (str[4] == '\0' || str[4] == ':'))
/* host[:hciN] */
return bt_host_hci(str[4] ? str + 5 : "hci0");
else if (!strncmp(str, "hci", 3)) {
/* hci[,vlan=n] */
if (str[3]) {
if (!strncmp(str + 3, ",vlan=", 6)) {
vlan = qemu_find_bt_vlan(strtol(str + 9, &endp, 0));
if (*endp)
vlan = 0;
}
} else
vlan = qemu_find_bt_vlan(0);
if (vlan)
return bt_new_hci(vlan);
}
fprintf(stderr, "qemu: Unknown bluetooth HCI `%s'.\n", str);
return 0;
}
| false | qemu | bf937a7965c1d1a6dce4f615d0ead2e2ab505004 | struct HCIInfo *hci_init(const char *str)
{
char *endp;
struct bt_scatternet_s *vlan = 0;
if (!strcmp(str, "null"))
return &null_hci;
else if (!strncmp(str, "host", 4) && (str[4] == '\0' || str[4] == ':'))
return bt_host_hci(str[4] ? str + 5 : "hci0");
else if (!strncmp(str, "hci", 3)) {
if (str[3]) {
if (!strncmp(str + 3, ",vlan=", 6)) {
vlan = qemu_find_bt_vlan(strtol(str + 9, &endp, 0));
if (*endp)
vlan = 0;
}
} else
vlan = qemu_find_bt_vlan(0);
if (vlan)
return bt_new_hci(vlan);
}
fprintf(stderr, "qemu: Unknown bluetooth HCI `%s'.\n", str);
return 0;
}
| {
"code": [],
"line_no": []
} | struct HCIInfo *FUNC_0(const char *VAR_0)
{
char *VAR_1;
struct bt_scatternet_s *VAR_2 = 0;
if (!strcmp(VAR_0, "null"))
return &null_hci;
else if (!strncmp(VAR_0, "host", 4) && (VAR_0[4] == '\0' || VAR_0[4] == ':'))
return bt_host_hci(VAR_0[4] ? VAR_0 + 5 : "hci0");
else if (!strncmp(VAR_0, "hci", 3)) {
if (VAR_0[3]) {
if (!strncmp(VAR_0 + 3, ",VAR_2=", 6)) {
VAR_2 = qemu_find_bt_vlan(strtol(VAR_0 + 9, &VAR_1, 0));
if (*VAR_1)
VAR_2 = 0;
}
} else
VAR_2 = qemu_find_bt_vlan(0);
if (VAR_2)
return bt_new_hci(VAR_2);
}
fprintf(stderr, "qemu: Unknown bluetooth HCI `%s'.\n", VAR_0);
return 0;
}
| [
"struct HCIInfo *FUNC_0(const char *VAR_0)\n{",
"char *VAR_1;",
"struct bt_scatternet_s *VAR_2 = 0;",
"if (!strcmp(VAR_0, \"null\"))\nreturn &null_hci;",
"else if (!strncmp(VAR_0, \"host\", 4) && (VAR_0[4] == '\\0' || VAR_0[4] == ':'))\nreturn bt_host_hci(VAR_0[4] ? VAR_0 + 5 : \"hci0\");",
"else if (!strncmp(VAR_0, \"hci\", 3)) {",
"if (VAR_0[3]) {",
"if (!strncmp(VAR_0 + 3, \",VAR_2=\", 6)) {",
"VAR_2 = qemu_find_bt_vlan(strtol(VAR_0 + 9, &VAR_1, 0));",
"if (*VAR_1)\nVAR_2 = 0;",
"}",
"} else",
"VAR_2 = qemu_find_bt_vlan(0);",
"if (VAR_2)\nreturn bt_new_hci(VAR_2);",
"}",
"fprintf(stderr, \"qemu: Unknown bluetooth HCI `%s'.\\n\", VAR_0);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
15
],
[
17,
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33,
35
],
[
37
],
[
39
],
[
41
],
[
43,
45
],
[
47
],
[
51
],
[
55
],
[
57
]
] |
21,220 | static int read_matrix_params(MLPDecodeContext *m, SubStream *s, GetBitContext *gbp)
{
unsigned int mat, ch;
s->num_primitive_matrices = get_bits(gbp, 4);
m->matrix_changed++;
for (mat = 0; mat < s->num_primitive_matrices; mat++) {
int frac_bits, max_chan;
s->matrix_out_ch[mat] = get_bits(gbp, 4);
frac_bits = get_bits(gbp, 4);
s->lsb_bypass [mat] = get_bits1(gbp);
if (s->matrix_out_ch[mat] > s->max_matrix_channel) {
av_log(m->avctx, AV_LOG_ERROR,
"Invalid channel %d specified as output from matrix.\n",
s->matrix_out_ch[mat]);
return -1;
}
if (frac_bits > 14) {
av_log(m->avctx, AV_LOG_ERROR,
"Too many fractional bits specified.\n");
return -1;
}
max_chan = s->max_matrix_channel;
if (!s->noise_type)
max_chan+=2;
for (ch = 0; ch <= max_chan; ch++) {
int coeff_val = 0;
if (get_bits1(gbp))
coeff_val = get_sbits(gbp, frac_bits + 2);
s->matrix_coeff[mat][ch] = coeff_val << (14 - frac_bits);
}
if (s->noise_type)
s->matrix_noise_shift[mat] = get_bits(gbp, 4);
else
s->matrix_noise_shift[mat] = 0;
}
return 0;
}
| false | FFmpeg | 5d9e4eaa6d991718b24c7ce24318ee91419f593a | static int read_matrix_params(MLPDecodeContext *m, SubStream *s, GetBitContext *gbp)
{
unsigned int mat, ch;
s->num_primitive_matrices = get_bits(gbp, 4);
m->matrix_changed++;
for (mat = 0; mat < s->num_primitive_matrices; mat++) {
int frac_bits, max_chan;
s->matrix_out_ch[mat] = get_bits(gbp, 4);
frac_bits = get_bits(gbp, 4);
s->lsb_bypass [mat] = get_bits1(gbp);
if (s->matrix_out_ch[mat] > s->max_matrix_channel) {
av_log(m->avctx, AV_LOG_ERROR,
"Invalid channel %d specified as output from matrix.\n",
s->matrix_out_ch[mat]);
return -1;
}
if (frac_bits > 14) {
av_log(m->avctx, AV_LOG_ERROR,
"Too many fractional bits specified.\n");
return -1;
}
max_chan = s->max_matrix_channel;
if (!s->noise_type)
max_chan+=2;
for (ch = 0; ch <= max_chan; ch++) {
int coeff_val = 0;
if (get_bits1(gbp))
coeff_val = get_sbits(gbp, frac_bits + 2);
s->matrix_coeff[mat][ch] = coeff_val << (14 - frac_bits);
}
if (s->noise_type)
s->matrix_noise_shift[mat] = get_bits(gbp, 4);
else
s->matrix_noise_shift[mat] = 0;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(MLPDecodeContext *VAR_0, SubStream *VAR_1, GetBitContext *VAR_2)
{
unsigned int VAR_3, VAR_4;
VAR_1->num_primitive_matrices = get_bits(VAR_2, 4);
VAR_0->matrix_changed++;
for (VAR_3 = 0; VAR_3 < VAR_1->num_primitive_matrices; VAR_3++) {
int frac_bits, max_chan;
VAR_1->matrix_out_ch[VAR_3] = get_bits(VAR_2, 4);
frac_bits = get_bits(VAR_2, 4);
VAR_1->lsb_bypass [VAR_3] = get_bits1(VAR_2);
if (VAR_1->matrix_out_ch[VAR_3] > VAR_1->max_matrix_channel) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"Invalid channel %d specified as output from matrix.\n",
VAR_1->matrix_out_ch[VAR_3]);
return -1;
}
if (frac_bits > 14) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"Too many fractional bits specified.\n");
return -1;
}
max_chan = VAR_1->max_matrix_channel;
if (!VAR_1->noise_type)
max_chan+=2;
for (VAR_4 = 0; VAR_4 <= max_chan; VAR_4++) {
int coeff_val = 0;
if (get_bits1(VAR_2))
coeff_val = get_sbits(VAR_2, frac_bits + 2);
VAR_1->matrix_coeff[VAR_3][VAR_4] = coeff_val << (14 - frac_bits);
}
if (VAR_1->noise_type)
VAR_1->matrix_noise_shift[VAR_3] = get_bits(VAR_2, 4);
else
VAR_1->matrix_noise_shift[VAR_3] = 0;
}
return 0;
}
| [
"static int FUNC_0(MLPDecodeContext *VAR_0, SubStream *VAR_1, GetBitContext *VAR_2)\n{",
"unsigned int VAR_3, VAR_4;",
"VAR_1->num_primitive_matrices = get_bits(VAR_2, 4);",
"VAR_0->matrix_changed++;",
"for (VAR_3 = 0; VAR_3 < VAR_1->num_primitive_matrices; VAR_3++) {",
"int frac_bits, max_chan;",
"VAR_1->matrix_out_ch[VAR_3] = get_bits(VAR_2, 4);",
"frac_bits = get_bits(VAR_2, 4);",
"VAR_1->lsb_bypass [VAR_3] = get_bits1(VAR_2);",
"if (VAR_1->matrix_out_ch[VAR_3] > VAR_1->max_matrix_channel) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Invalid channel %d specified as output from matrix.\\n\",\nVAR_1->matrix_out_ch[VAR_3]);",
"return -1;",
"}",
"if (frac_bits > 14) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Too many fractional bits specified.\\n\");",
"return -1;",
"}",
"max_chan = VAR_1->max_matrix_channel;",
"if (!VAR_1->noise_type)\nmax_chan+=2;",
"for (VAR_4 = 0; VAR_4 <= max_chan; VAR_4++) {",
"int coeff_val = 0;",
"if (get_bits1(VAR_2))\ncoeff_val = get_sbits(VAR_2, frac_bits + 2);",
"VAR_1->matrix_coeff[VAR_3][VAR_4] = coeff_val << (14 - frac_bits);",
"}",
"if (VAR_1->noise_type)\nVAR_1->matrix_noise_shift[VAR_3] = get_bits(VAR_2, 4);",
"else\nVAR_1->matrix_noise_shift[VAR_3] = 0;",
"}",
"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
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29,
31,
33
],
[
35
],
[
37
],
[
39
],
[
41,
43
],
[
45
],
[
47
],
[
51
],
[
53,
55
],
[
59
],
[
61
],
[
63,
65
],
[
69
],
[
71
],
[
75,
77
],
[
79,
81
],
[
83
],
[
87
],
[
89
]
] |
21,221 | static int libgsm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
const AVFrame *frame, int *got_packet_ptr)
{
int ret;
gsm_signal *samples = (gsm_signal *)frame->data[0];
struct gsm_state *state = avctx->priv_data;
if ((ret = ff_alloc_packet2(avctx, avpkt, avctx->block_align)))
return ret;
switch(avctx->codec_id) {
case AV_CODEC_ID_GSM:
gsm_encode(state, samples, avpkt->data);
break;
case AV_CODEC_ID_GSM_MS:
gsm_encode(state, samples, avpkt->data);
gsm_encode(state, samples + GSM_FRAME_SIZE, avpkt->data + 32);
}
*got_packet_ptr = 1;
return 0;
}
| false | FFmpeg | bcaf64b605442e1622d16da89d4ec0e7730b8a8c | static int libgsm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
const AVFrame *frame, int *got_packet_ptr)
{
int ret;
gsm_signal *samples = (gsm_signal *)frame->data[0];
struct gsm_state *state = avctx->priv_data;
if ((ret = ff_alloc_packet2(avctx, avpkt, avctx->block_align)))
return ret;
switch(avctx->codec_id) {
case AV_CODEC_ID_GSM:
gsm_encode(state, samples, avpkt->data);
break;
case AV_CODEC_ID_GSM_MS:
gsm_encode(state, samples, avpkt->data);
gsm_encode(state, samples + GSM_FRAME_SIZE, avpkt->data + 32);
}
*got_packet_ptr = 1;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,
const AVFrame *VAR_2, int *VAR_3)
{
int VAR_4;
gsm_signal *samples = (gsm_signal *)VAR_2->data[0];
struct gsm_state *VAR_5 = VAR_0->priv_data;
if ((VAR_4 = ff_alloc_packet2(VAR_0, VAR_1, VAR_0->block_align)))
return VAR_4;
switch(VAR_0->codec_id) {
case AV_CODEC_ID_GSM:
gsm_encode(VAR_5, samples, VAR_1->data);
break;
case AV_CODEC_ID_GSM_MS:
gsm_encode(VAR_5, samples, VAR_1->data);
gsm_encode(VAR_5, samples + GSM_FRAME_SIZE, VAR_1->data + 32);
}
*VAR_3 = 1;
return 0;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,\nconst AVFrame *VAR_2, int *VAR_3)\n{",
"int VAR_4;",
"gsm_signal *samples = (gsm_signal *)VAR_2->data[0];",
"struct gsm_state *VAR_5 = VAR_0->priv_data;",
"if ((VAR_4 = ff_alloc_packet2(VAR_0, VAR_1, VAR_0->block_align)))\nreturn VAR_4;",
"switch(VAR_0->codec_id) {",
"case AV_CODEC_ID_GSM:\ngsm_encode(VAR_5, samples, VAR_1->data);",
"break;",
"case AV_CODEC_ID_GSM_MS:\ngsm_encode(VAR_5, samples, VAR_1->data);",
"gsm_encode(VAR_5, samples + GSM_FRAME_SIZE, VAR_1->data + 32);",
"}",
"*VAR_3 = 1;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15,
17
],
[
21
],
[
23,
25
],
[
27
],
[
29,
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
]
] |
21,223 | static void ff_h264_idct_dc_add_mmx2(uint8_t *dst, int16_t *block, int stride)
{
int dc = (block[0] + 32) >> 6;
__asm__ volatile(
"movd %0, %%mm0 \n\t"
"pshufw $0, %%mm0, %%mm0 \n\t"
"pxor %%mm1, %%mm1 \n\t"
"psubw %%mm0, %%mm1 \n\t"
"packuswb %%mm0, %%mm0 \n\t"
"packuswb %%mm1, %%mm1 \n\t"
::"r"(dc)
);
__asm__ volatile(
"movd %0, %%mm2 \n\t"
"movd %1, %%mm3 \n\t"
"movd %2, %%mm4 \n\t"
"movd %3, %%mm5 \n\t"
"paddusb %%mm0, %%mm2 \n\t"
"paddusb %%mm0, %%mm3 \n\t"
"paddusb %%mm0, %%mm4 \n\t"
"paddusb %%mm0, %%mm5 \n\t"
"psubusb %%mm1, %%mm2 \n\t"
"psubusb %%mm1, %%mm3 \n\t"
"psubusb %%mm1, %%mm4 \n\t"
"psubusb %%mm1, %%mm5 \n\t"
"movd %%mm2, %0 \n\t"
"movd %%mm3, %1 \n\t"
"movd %%mm4, %2 \n\t"
"movd %%mm5, %3 \n\t"
:"+m"(*(uint32_t*)(dst+0*stride)),
"+m"(*(uint32_t*)(dst+1*stride)),
"+m"(*(uint32_t*)(dst+2*stride)),
"+m"(*(uint32_t*)(dst+3*stride))
);
}
| false | FFmpeg | 1d16a1cf99488f16492b1bb48e023f4da8377e07 | static void ff_h264_idct_dc_add_mmx2(uint8_t *dst, int16_t *block, int stride)
{
int dc = (block[0] + 32) >> 6;
__asm__ volatile(
"movd %0, %%mm0 \n\t"
"pshufw $0, %%mm0, %%mm0 \n\t"
"pxor %%mm1, %%mm1 \n\t"
"psubw %%mm0, %%mm1 \n\t"
"packuswb %%mm0, %%mm0 \n\t"
"packuswb %%mm1, %%mm1 \n\t"
::"r"(dc)
);
__asm__ volatile(
"movd %0, %%mm2 \n\t"
"movd %1, %%mm3 \n\t"
"movd %2, %%mm4 \n\t"
"movd %3, %%mm5 \n\t"
"paddusb %%mm0, %%mm2 \n\t"
"paddusb %%mm0, %%mm3 \n\t"
"paddusb %%mm0, %%mm4 \n\t"
"paddusb %%mm0, %%mm5 \n\t"
"psubusb %%mm1, %%mm2 \n\t"
"psubusb %%mm1, %%mm3 \n\t"
"psubusb %%mm1, %%mm4 \n\t"
"psubusb %%mm1, %%mm5 \n\t"
"movd %%mm2, %0 \n\t"
"movd %%mm3, %1 \n\t"
"movd %%mm4, %2 \n\t"
"movd %%mm5, %3 \n\t"
:"+m"(*(uint32_t*)(dst+0*stride)),
"+m"(*(uint32_t*)(dst+1*stride)),
"+m"(*(uint32_t*)(dst+2*stride)),
"+m"(*(uint32_t*)(dst+3*stride))
);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(uint8_t *VAR_0, int16_t *VAR_1, int VAR_2)
{
int VAR_3 = (VAR_1[0] + 32) >> 6;
__asm__ volatile(
"movd %0, %%mm0 \n\t"
"pshufw $0, %%mm0, %%mm0 \n\t"
"pxor %%mm1, %%mm1 \n\t"
"psubw %%mm0, %%mm1 \n\t"
"packuswb %%mm0, %%mm0 \n\t"
"packuswb %%mm1, %%mm1 \n\t"
::"r"(VAR_3)
);
__asm__ volatile(
"movd %0, %%mm2 \n\t"
"movd %1, %%mm3 \n\t"
"movd %2, %%mm4 \n\t"
"movd %3, %%mm5 \n\t"
"paddusb %%mm0, %%mm2 \n\t"
"paddusb %%mm0, %%mm3 \n\t"
"paddusb %%mm0, %%mm4 \n\t"
"paddusb %%mm0, %%mm5 \n\t"
"psubusb %%mm1, %%mm2 \n\t"
"psubusb %%mm1, %%mm3 \n\t"
"psubusb %%mm1, %%mm4 \n\t"
"psubusb %%mm1, %%mm5 \n\t"
"movd %%mm2, %0 \n\t"
"movd %%mm3, %1 \n\t"
"movd %%mm4, %2 \n\t"
"movd %%mm5, %3 \n\t"
:"+m"(*(uint32_t*)(VAR_0+0*VAR_2)),
"+m"(*(uint32_t*)(VAR_0+1*VAR_2)),
"+m"(*(uint32_t*)(VAR_0+2*VAR_2)),
"+m"(*(uint32_t*)(VAR_0+3*VAR_2))
);
}
| [
"static void FUNC_0(uint8_t *VAR_0, int16_t *VAR_1, int VAR_2)\n{",
"int VAR_3 = (VAR_1[0] + 32) >> 6;",
"__asm__ volatile(\n\"movd %0, %%mm0 \\n\\t\"\n\"pshufw $0, %%mm0, %%mm0 \\n\\t\"\n\"pxor %%mm1, %%mm1 \\n\\t\"\n\"psubw %%mm0, %%mm1 \\n\\t\"\n\"packuswb %%mm0, %%mm0 \\n\\t\"\n\"packuswb %%mm1, %%mm1 \\n\\t\"\n::\"r\"(VAR_3)\n);",
"__asm__ volatile(\n\"movd %0, %%mm2 \\n\\t\"\n\"movd %1, %%mm3 \\n\\t\"\n\"movd %2, %%mm4 \\n\\t\"\n\"movd %3, %%mm5 \\n\\t\"\n\"paddusb %%mm0, %%mm2 \\n\\t\"\n\"paddusb %%mm0, %%mm3 \\n\\t\"\n\"paddusb %%mm0, %%mm4 \\n\\t\"\n\"paddusb %%mm0, %%mm5 \\n\\t\"\n\"psubusb %%mm1, %%mm2 \\n\\t\"\n\"psubusb %%mm1, %%mm3 \\n\\t\"\n\"psubusb %%mm1, %%mm4 \\n\\t\"\n\"psubusb %%mm1, %%mm5 \\n\\t\"\n\"movd %%mm2, %0 \\n\\t\"\n\"movd %%mm3, %1 \\n\\t\"\n\"movd %%mm4, %2 \\n\\t\"\n\"movd %%mm5, %3 \\n\\t\"\n:\"+m\"(*(uint32_t*)(VAR_0+0*VAR_2)),\n\"+m\"(*(uint32_t*)(VAR_0+1*VAR_2)),\n\"+m\"(*(uint32_t*)(VAR_0+2*VAR_2)),\n\"+m\"(*(uint32_t*)(VAR_0+3*VAR_2))\n);",
"}"
] | [
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
]
] |
21,224 | void ff_xvmc_field_end(MpegEncContext *s)
{
struct xvmc_pix_fmt *render = (struct xvmc_pix_fmt*)s->current_picture.f->data[2];
assert(render);
if (render->filled_mv_blocks_num > 0)
ff_mpeg_draw_horiz_band(s, 0, 0);
}
| false | FFmpeg | dcc39ee10e82833ce24aa57926c00ffeb1948198 | void ff_xvmc_field_end(MpegEncContext *s)
{
struct xvmc_pix_fmt *render = (struct xvmc_pix_fmt*)s->current_picture.f->data[2];
assert(render);
if (render->filled_mv_blocks_num > 0)
ff_mpeg_draw_horiz_band(s, 0, 0);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(MpegEncContext *VAR_0)
{
struct xvmc_pix_fmt *VAR_1 = (struct xvmc_pix_fmt*)VAR_0->current_picture.f->data[2];
assert(VAR_1);
if (VAR_1->filled_mv_blocks_num > 0)
ff_mpeg_draw_horiz_band(VAR_0, 0, 0);
}
| [
"void FUNC_0(MpegEncContext *VAR_0)\n{",
"struct xvmc_pix_fmt *VAR_1 = (struct xvmc_pix_fmt*)VAR_0->current_picture.f->data[2];",
"assert(VAR_1);",
"if (VAR_1->filled_mv_blocks_num > 0)\nff_mpeg_draw_horiz_band(VAR_0, 0, 0);",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
15
]
] |
21,225 | static int kempf_decode_tile(G2MContext *c, int tile_x, int tile_y,
const uint8_t *src, int src_size)
{
int width, height;
int hdr, zsize, npal, tidx = -1, ret;
int i, j;
const uint8_t *src_end = src + src_size;
uint8_t pal[768], transp[3];
uLongf dlen = (c->tile_width + 1) * c->tile_height;
int sub_type;
int nblocks, cblocks, bstride;
int bits, bitbuf, coded;
uint8_t *dst = c->framebuf + tile_x * c->tile_width * 3 +
tile_y * c->tile_height * c->framebuf_stride;
if (src_size < 2)
return AVERROR_INVALIDDATA;
width = FFMIN(c->width - tile_x * c->tile_width, c->tile_width);
height = FFMIN(c->height - tile_y * c->tile_height, c->tile_height);
hdr = *src++;
sub_type = hdr >> 5;
if (sub_type == 0) {
int j;
memcpy(transp, src, 3);
src += 3;
for (j = 0; j < height; j++, dst += c->framebuf_stride)
for (i = 0; i < width; i++)
memcpy(dst + i * 3, transp, 3);
return 0;
} else if (sub_type == 1) {
return jpg_decode_data(&c->jc, width, height, src, src_end - src,
dst, c->framebuf_stride, NULL, 0, 0, 0);
}
if (sub_type != 2) {
memcpy(transp, src, 3);
src += 3;
}
npal = *src++ + 1;
memcpy(pal, src, npal * 3); src += npal * 3;
if (sub_type != 2) {
for (i = 0; i < npal; i++) {
if (!memcmp(pal + i * 3, transp, 3)) {
tidx = i;
break;
}
}
}
if (src_end - src < 2)
return 0;
zsize = (src[0] << 8) | src[1]; src += 2;
if (src_end - src < zsize)
return AVERROR_INVALIDDATA;
ret = uncompress(c->kempf_buf, &dlen, src, zsize);
if (ret)
return AVERROR_INVALIDDATA;
src += zsize;
if (sub_type == 2) {
kempf_restore_buf(c->kempf_buf, dlen, dst, c->framebuf_stride,
NULL, 0, width, height, pal, npal, tidx);
return 0;
}
nblocks = *src++ + 1;
cblocks = 0;
bstride = FFALIGN(width, 16) >> 4;
// blocks are coded LSB and we need normal bitreader for JPEG data
bits = 0;
for (i = 0; i < (FFALIGN(height, 16) >> 4); i++) {
for (j = 0; j < (FFALIGN(width, 16) >> 4); j++) {
if (!bits) {
bitbuf = *src++;
bits = 8;
}
coded = bitbuf & 1;
bits--;
bitbuf >>= 1;
cblocks += coded;
if (cblocks > nblocks)
return AVERROR_INVALIDDATA;
c->kempf_flags[j + i * bstride] = coded;
}
}
memset(c->jpeg_tile, 0, c->tile_stride * height);
jpg_decode_data(&c->jc, width, height, src, src_end - src,
c->jpeg_tile, c->tile_stride,
c->kempf_flags, bstride, nblocks, 0);
kempf_restore_buf(c->kempf_buf, dlen, dst, c->framebuf_stride,
c->jpeg_tile, c->tile_stride,
width, height, pal, npal, tidx);
return 0;
}
| false | FFmpeg | 2960576378d17d71cc8dccc926352ce568b5eec1 | static int kempf_decode_tile(G2MContext *c, int tile_x, int tile_y,
const uint8_t *src, int src_size)
{
int width, height;
int hdr, zsize, npal, tidx = -1, ret;
int i, j;
const uint8_t *src_end = src + src_size;
uint8_t pal[768], transp[3];
uLongf dlen = (c->tile_width + 1) * c->tile_height;
int sub_type;
int nblocks, cblocks, bstride;
int bits, bitbuf, coded;
uint8_t *dst = c->framebuf + tile_x * c->tile_width * 3 +
tile_y * c->tile_height * c->framebuf_stride;
if (src_size < 2)
return AVERROR_INVALIDDATA;
width = FFMIN(c->width - tile_x * c->tile_width, c->tile_width);
height = FFMIN(c->height - tile_y * c->tile_height, c->tile_height);
hdr = *src++;
sub_type = hdr >> 5;
if (sub_type == 0) {
int j;
memcpy(transp, src, 3);
src += 3;
for (j = 0; j < height; j++, dst += c->framebuf_stride)
for (i = 0; i < width; i++)
memcpy(dst + i * 3, transp, 3);
return 0;
} else if (sub_type == 1) {
return jpg_decode_data(&c->jc, width, height, src, src_end - src,
dst, c->framebuf_stride, NULL, 0, 0, 0);
}
if (sub_type != 2) {
memcpy(transp, src, 3);
src += 3;
}
npal = *src++ + 1;
memcpy(pal, src, npal * 3); src += npal * 3;
if (sub_type != 2) {
for (i = 0; i < npal; i++) {
if (!memcmp(pal + i * 3, transp, 3)) {
tidx = i;
break;
}
}
}
if (src_end - src < 2)
return 0;
zsize = (src[0] << 8) | src[1]; src += 2;
if (src_end - src < zsize)
return AVERROR_INVALIDDATA;
ret = uncompress(c->kempf_buf, &dlen, src, zsize);
if (ret)
return AVERROR_INVALIDDATA;
src += zsize;
if (sub_type == 2) {
kempf_restore_buf(c->kempf_buf, dlen, dst, c->framebuf_stride,
NULL, 0, width, height, pal, npal, tidx);
return 0;
}
nblocks = *src++ + 1;
cblocks = 0;
bstride = FFALIGN(width, 16) >> 4;
bits = 0;
for (i = 0; i < (FFALIGN(height, 16) >> 4); i++) {
for (j = 0; j < (FFALIGN(width, 16) >> 4); j++) {
if (!bits) {
bitbuf = *src++;
bits = 8;
}
coded = bitbuf & 1;
bits--;
bitbuf >>= 1;
cblocks += coded;
if (cblocks > nblocks)
return AVERROR_INVALIDDATA;
c->kempf_flags[j + i * bstride] = coded;
}
}
memset(c->jpeg_tile, 0, c->tile_stride * height);
jpg_decode_data(&c->jc, width, height, src, src_end - src,
c->jpeg_tile, c->tile_stride,
c->kempf_flags, bstride, nblocks, 0);
kempf_restore_buf(c->kempf_buf, dlen, dst, c->framebuf_stride,
c->jpeg_tile, c->tile_stride,
width, height, pal, npal, tidx);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(G2MContext *VAR_0, int VAR_1, int VAR_2,
const uint8_t *VAR_3, int VAR_4)
{
int VAR_5, VAR_6;
int VAR_7, VAR_8, VAR_9, VAR_10 = -1, VAR_11;
int VAR_12, VAR_22;
const uint8_t *VAR_14 = VAR_3 + VAR_4;
uint8_t pal[768], transp[3];
uLongf dlen = (VAR_0->tile_width + 1) * VAR_0->tile_height;
int VAR_15;
int VAR_16, VAR_17, VAR_18;
int VAR_19, VAR_20, VAR_21;
uint8_t *dst = VAR_0->framebuf + VAR_1 * VAR_0->tile_width * 3 +
VAR_2 * VAR_0->tile_height * VAR_0->framebuf_stride;
if (VAR_4 < 2)
return AVERROR_INVALIDDATA;
VAR_5 = FFMIN(VAR_0->VAR_5 - VAR_1 * VAR_0->tile_width, VAR_0->tile_width);
VAR_6 = FFMIN(VAR_0->VAR_6 - VAR_2 * VAR_0->tile_height, VAR_0->tile_height);
VAR_7 = *VAR_3++;
VAR_15 = VAR_7 >> 5;
if (VAR_15 == 0) {
int VAR_22;
memcpy(transp, VAR_3, 3);
VAR_3 += 3;
for (VAR_22 = 0; VAR_22 < VAR_6; VAR_22++, dst += VAR_0->framebuf_stride)
for (VAR_12 = 0; VAR_12 < VAR_5; VAR_12++)
memcpy(dst + VAR_12 * 3, transp, 3);
return 0;
} else if (VAR_15 == 1) {
return jpg_decode_data(&VAR_0->jc, VAR_5, VAR_6, VAR_3, VAR_14 - VAR_3,
dst, VAR_0->framebuf_stride, NULL, 0, 0, 0);
}
if (VAR_15 != 2) {
memcpy(transp, VAR_3, 3);
VAR_3 += 3;
}
VAR_9 = *VAR_3++ + 1;
memcpy(pal, VAR_3, VAR_9 * 3); VAR_3 += VAR_9 * 3;
if (VAR_15 != 2) {
for (VAR_12 = 0; VAR_12 < VAR_9; VAR_12++) {
if (!memcmp(pal + VAR_12 * 3, transp, 3)) {
VAR_10 = VAR_12;
break;
}
}
}
if (VAR_14 - VAR_3 < 2)
return 0;
VAR_8 = (VAR_3[0] << 8) | VAR_3[1]; VAR_3 += 2;
if (VAR_14 - VAR_3 < VAR_8)
return AVERROR_INVALIDDATA;
VAR_11 = uncompress(VAR_0->kempf_buf, &dlen, VAR_3, VAR_8);
if (VAR_11)
return AVERROR_INVALIDDATA;
VAR_3 += VAR_8;
if (VAR_15 == 2) {
kempf_restore_buf(VAR_0->kempf_buf, dlen, dst, VAR_0->framebuf_stride,
NULL, 0, VAR_5, VAR_6, pal, VAR_9, VAR_10);
return 0;
}
VAR_16 = *VAR_3++ + 1;
VAR_17 = 0;
VAR_18 = FFALIGN(VAR_5, 16) >> 4;
VAR_19 = 0;
for (VAR_12 = 0; VAR_12 < (FFALIGN(VAR_6, 16) >> 4); VAR_12++) {
for (VAR_22 = 0; VAR_22 < (FFALIGN(VAR_5, 16) >> 4); VAR_22++) {
if (!VAR_19) {
VAR_20 = *VAR_3++;
VAR_19 = 8;
}
VAR_21 = VAR_20 & 1;
VAR_19--;
VAR_20 >>= 1;
VAR_17 += VAR_21;
if (VAR_17 > VAR_16)
return AVERROR_INVALIDDATA;
VAR_0->kempf_flags[VAR_22 + VAR_12 * VAR_18] = VAR_21;
}
}
memset(VAR_0->jpeg_tile, 0, VAR_0->tile_stride * VAR_6);
jpg_decode_data(&VAR_0->jc, VAR_5, VAR_6, VAR_3, VAR_14 - VAR_3,
VAR_0->jpeg_tile, VAR_0->tile_stride,
VAR_0->kempf_flags, VAR_18, VAR_16, 0);
kempf_restore_buf(VAR_0->kempf_buf, dlen, dst, VAR_0->framebuf_stride,
VAR_0->jpeg_tile, VAR_0->tile_stride,
VAR_5, VAR_6, pal, VAR_9, VAR_10);
return 0;
}
| [
"static int FUNC_0(G2MContext *VAR_0, int VAR_1, int VAR_2,\nconst uint8_t *VAR_3, int VAR_4)\n{",
"int VAR_5, VAR_6;",
"int VAR_7, VAR_8, VAR_9, VAR_10 = -1, VAR_11;",
"int VAR_12, VAR_22;",
"const uint8_t *VAR_14 = VAR_3 + VAR_4;",
"uint8_t pal[768], transp[3];",
"uLongf dlen = (VAR_0->tile_width + 1) * VAR_0->tile_height;",
"int VAR_15;",
"int VAR_16, VAR_17, VAR_18;",
"int VAR_19, VAR_20, VAR_21;",
"uint8_t *dst = VAR_0->framebuf + VAR_1 * VAR_0->tile_width * 3 +\nVAR_2 * VAR_0->tile_height * VAR_0->framebuf_stride;",
"if (VAR_4 < 2)\nreturn AVERROR_INVALIDDATA;",
"VAR_5 = FFMIN(VAR_0->VAR_5 - VAR_1 * VAR_0->tile_width, VAR_0->tile_width);",
"VAR_6 = FFMIN(VAR_0->VAR_6 - VAR_2 * VAR_0->tile_height, VAR_0->tile_height);",
"VAR_7 = *VAR_3++;",
"VAR_15 = VAR_7 >> 5;",
"if (VAR_15 == 0) {",
"int VAR_22;",
"memcpy(transp, VAR_3, 3);",
"VAR_3 += 3;",
"for (VAR_22 = 0; VAR_22 < VAR_6; VAR_22++, dst += VAR_0->framebuf_stride)",
"for (VAR_12 = 0; VAR_12 < VAR_5; VAR_12++)",
"memcpy(dst + VAR_12 * 3, transp, 3);",
"return 0;",
"} else if (VAR_15 == 1) {",
"return jpg_decode_data(&VAR_0->jc, VAR_5, VAR_6, VAR_3, VAR_14 - VAR_3,\ndst, VAR_0->framebuf_stride, NULL, 0, 0, 0);",
"}",
"if (VAR_15 != 2) {",
"memcpy(transp, VAR_3, 3);",
"VAR_3 += 3;",
"}",
"VAR_9 = *VAR_3++ + 1;",
"memcpy(pal, VAR_3, VAR_9 * 3); VAR_3 += VAR_9 * 3;",
"if (VAR_15 != 2) {",
"for (VAR_12 = 0; VAR_12 < VAR_9; VAR_12++) {",
"if (!memcmp(pal + VAR_12 * 3, transp, 3)) {",
"VAR_10 = VAR_12;",
"break;",
"}",
"}",
"}",
"if (VAR_14 - VAR_3 < 2)\nreturn 0;",
"VAR_8 = (VAR_3[0] << 8) | VAR_3[1]; VAR_3 += 2;",
"if (VAR_14 - VAR_3 < VAR_8)\nreturn AVERROR_INVALIDDATA;",
"VAR_11 = uncompress(VAR_0->kempf_buf, &dlen, VAR_3, VAR_8);",
"if (VAR_11)\nreturn AVERROR_INVALIDDATA;",
"VAR_3 += VAR_8;",
"if (VAR_15 == 2) {",
"kempf_restore_buf(VAR_0->kempf_buf, dlen, dst, VAR_0->framebuf_stride,\nNULL, 0, VAR_5, VAR_6, pal, VAR_9, VAR_10);",
"return 0;",
"}",
"VAR_16 = *VAR_3++ + 1;",
"VAR_17 = 0;",
"VAR_18 = FFALIGN(VAR_5, 16) >> 4;",
"VAR_19 = 0;",
"for (VAR_12 = 0; VAR_12 < (FFALIGN(VAR_6, 16) >> 4); VAR_12++) {",
"for (VAR_22 = 0; VAR_22 < (FFALIGN(VAR_5, 16) >> 4); VAR_22++) {",
"if (!VAR_19) {",
"VAR_20 = *VAR_3++;",
"VAR_19 = 8;",
"}",
"VAR_21 = VAR_20 & 1;",
"VAR_19--;",
"VAR_20 >>= 1;",
"VAR_17 += VAR_21;",
"if (VAR_17 > VAR_16)\nreturn AVERROR_INVALIDDATA;",
"VAR_0->kempf_flags[VAR_22 + VAR_12 * VAR_18] = VAR_21;",
"}",
"}",
"memset(VAR_0->jpeg_tile, 0, VAR_0->tile_stride * VAR_6);",
"jpg_decode_data(&VAR_0->jc, VAR_5, VAR_6, VAR_3, VAR_14 - VAR_3,\nVAR_0->jpeg_tile, VAR_0->tile_stride,\nVAR_0->kempf_flags, VAR_18, VAR_16, 0);",
"kempf_restore_buf(VAR_0->kempf_buf, dlen, dst, VAR_0->framebuf_stride,\nVAR_0->jpeg_tile, VAR_0->tile_stride,\nVAR_5, VAR_6, pal, VAR_9, 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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25,
27
],
[
31,
33
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65,
67
],
[
69
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
103,
105
],
[
107
],
[
111,
113
],
[
117
],
[
119,
121
],
[
123
],
[
127
],
[
129,
131
],
[
133
],
[
135
],
[
139
],
[
141
],
[
143
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169,
171
],
[
173
],
[
175
],
[
177
],
[
181
],
[
183,
185,
187
],
[
191,
193,
195
],
[
199
],
[
201
]
] |
21,226 | static void vnc_dpy_update(DisplayChangeListener *dcl,
int x, int y, int w, int h)
{
VncDisplay *vd = container_of(dcl, VncDisplay, dcl);
struct VncSurface *s = &vd->guest;
int width = surface_width(vd->ds);
int height = surface_height(vd->ds);
/* this is needed this to ensure we updated all affected
* blocks if x % VNC_DIRTY_PIXELS_PER_BIT != 0 */
w += (x % VNC_DIRTY_PIXELS_PER_BIT);
x -= (x % VNC_DIRTY_PIXELS_PER_BIT);
x = MIN(x, width);
y = MIN(y, height);
w = MIN(x + w, width) - x;
h = MIN(y + h, height);
for (; y < h; y++) {
bitmap_set(s->dirty[y], x / VNC_DIRTY_PIXELS_PER_BIT,
DIV_ROUND_UP(w, VNC_DIRTY_PIXELS_PER_BIT));
}
}
| true | qemu | bea60dd7679364493a0d7f5b54316c767cf894ef | static void vnc_dpy_update(DisplayChangeListener *dcl,
int x, int y, int w, int h)
{
VncDisplay *vd = container_of(dcl, VncDisplay, dcl);
struct VncSurface *s = &vd->guest;
int width = surface_width(vd->ds);
int height = surface_height(vd->ds);
w += (x % VNC_DIRTY_PIXELS_PER_BIT);
x -= (x % VNC_DIRTY_PIXELS_PER_BIT);
x = MIN(x, width);
y = MIN(y, height);
w = MIN(x + w, width) - x;
h = MIN(y + h, height);
for (; y < h; y++) {
bitmap_set(s->dirty[y], x / VNC_DIRTY_PIXELS_PER_BIT,
DIV_ROUND_UP(w, VNC_DIRTY_PIXELS_PER_BIT));
}
}
| {
"code": [
"static void vnc_dpy_update(DisplayChangeListener *dcl,",
" int x, int y, int w, int h)",
" VncDisplay *vd = container_of(dcl, VncDisplay, dcl);",
" struct VncSurface *s = &vd->guest;",
" int width = surface_width(vd->ds);",
" int height = surface_height(vd->ds);",
" bitmap_set(s->dirty[y], x / VNC_DIRTY_PIXELS_PER_BIT,"
],
"line_no": [
1,
3,
7,
9,
11,
13,
39
]
} | static void FUNC_0(DisplayChangeListener *VAR_0,
int VAR_1, int VAR_2, int VAR_3, int VAR_4)
{
VncDisplay *vd = container_of(VAR_0, VncDisplay, VAR_0);
struct VncSurface *VAR_5 = &vd->guest;
int VAR_6 = surface_width(vd->ds);
int VAR_7 = surface_height(vd->ds);
VAR_3 += (VAR_1 % VNC_DIRTY_PIXELS_PER_BIT);
VAR_1 -= (VAR_1 % VNC_DIRTY_PIXELS_PER_BIT);
VAR_1 = MIN(VAR_1, VAR_6);
VAR_2 = MIN(VAR_2, VAR_7);
VAR_3 = MIN(VAR_1 + VAR_3, VAR_6) - VAR_1;
VAR_4 = MIN(VAR_2 + VAR_4, VAR_7);
for (; VAR_2 < VAR_4; VAR_2++) {
bitmap_set(VAR_5->dirty[VAR_2], VAR_1 / VNC_DIRTY_PIXELS_PER_BIT,
DIV_ROUND_UP(VAR_3, VNC_DIRTY_PIXELS_PER_BIT));
}
}
| [
"static void FUNC_0(DisplayChangeListener *VAR_0,\nint VAR_1, int VAR_2, int VAR_3, int VAR_4)\n{",
"VncDisplay *vd = container_of(VAR_0, VncDisplay, VAR_0);",
"struct VncSurface *VAR_5 = &vd->guest;",
"int VAR_6 = surface_width(vd->ds);",
"int VAR_7 = surface_height(vd->ds);",
"VAR_3 += (VAR_1 % VNC_DIRTY_PIXELS_PER_BIT);",
"VAR_1 -= (VAR_1 % VNC_DIRTY_PIXELS_PER_BIT);",
"VAR_1 = MIN(VAR_1, VAR_6);",
"VAR_2 = MIN(VAR_2, VAR_7);",
"VAR_3 = MIN(VAR_1 + VAR_3, VAR_6) - VAR_1;",
"VAR_4 = MIN(VAR_2 + VAR_4, VAR_7);",
"for (; VAR_2 < VAR_4; VAR_2++) {",
"bitmap_set(VAR_5->dirty[VAR_2], VAR_1 / VNC_DIRTY_PIXELS_PER_BIT,\nDIV_ROUND_UP(VAR_3, VNC_DIRTY_PIXELS_PER_BIT));",
"}",
"}"
] | [
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39,
41
],
[
43
],
[
45
]
] |
21,227 | static int channelmap_config_input(AVFilterLink *inlink)
{
AVFilterContext *ctx = inlink->dst;
ChannelMapContext *s = ctx->priv;
int i, err = 0;
const char *channel_name;
char layout_name[256];
if (s->mode == MAP_PAIR_STR_INT || s->mode == MAP_PAIR_STR_STR) {
for (i = 0; i < s->nch; i++) {
s->map[i].in_channel_idx = av_get_channel_layout_channel_index(
inlink->channel_layout, s->map[i].in_channel);
if (s->map[i].in_channel_idx < 0) {
channel_name = av_get_channel_name(s->map[i].in_channel);
av_get_channel_layout_string(layout_name, sizeof(layout_name),
0, inlink->channel_layout);
av_log(ctx, AV_LOG_ERROR,
"input channel '%s' not available from input layout '%s'\n",
channel_name, layout_name);
err = AVERROR(EINVAL);
}
}
}
return err;
}
| true | FFmpeg | aafed1175df76603e94c99a7748968780d6548d2 | static int channelmap_config_input(AVFilterLink *inlink)
{
AVFilterContext *ctx = inlink->dst;
ChannelMapContext *s = ctx->priv;
int i, err = 0;
const char *channel_name;
char layout_name[256];
if (s->mode == MAP_PAIR_STR_INT || s->mode == MAP_PAIR_STR_STR) {
for (i = 0; i < s->nch; i++) {
s->map[i].in_channel_idx = av_get_channel_layout_channel_index(
inlink->channel_layout, s->map[i].in_channel);
if (s->map[i].in_channel_idx < 0) {
channel_name = av_get_channel_name(s->map[i].in_channel);
av_get_channel_layout_string(layout_name, sizeof(layout_name),
0, inlink->channel_layout);
av_log(ctx, AV_LOG_ERROR,
"input channel '%s' not available from input layout '%s'\n",
channel_name, layout_name);
err = AVERROR(EINVAL);
}
}
}
return err;
}
| {
"code": [
" if (s->mode == MAP_PAIR_STR_INT || s->mode == MAP_PAIR_STR_STR) {",
" for (i = 0; i < s->nch; i++) {",
" if (s->map[i].in_channel_idx < 0) {",
" av_get_channel_layout_string(layout_name, sizeof(layout_name),",
" 0, inlink->channel_layout);",
" err = AVERROR(EINVAL);"
],
"line_no": [
17,
19,
25,
29,
31,
39
]
} | static int FUNC_0(AVFilterLink *VAR_0)
{
AVFilterContext *ctx = VAR_0->dst;
ChannelMapContext *s = ctx->priv;
int VAR_1, VAR_2 = 0;
const char *VAR_3;
char VAR_4[256];
if (s->mode == MAP_PAIR_STR_INT || s->mode == MAP_PAIR_STR_STR) {
for (VAR_1 = 0; VAR_1 < s->nch; VAR_1++) {
s->map[VAR_1].in_channel_idx = av_get_channel_layout_channel_index(
VAR_0->channel_layout, s->map[VAR_1].in_channel);
if (s->map[VAR_1].in_channel_idx < 0) {
VAR_3 = av_get_channel_name(s->map[VAR_1].in_channel);
av_get_channel_layout_string(VAR_4, sizeof(VAR_4),
0, VAR_0->channel_layout);
av_log(ctx, AV_LOG_ERROR,
"input channel '%s' not available from input layout '%s'\n",
VAR_3, VAR_4);
VAR_2 = AVERROR(EINVAL);
}
}
}
return VAR_2;
}
| [
"static int FUNC_0(AVFilterLink *VAR_0)\n{",
"AVFilterContext *ctx = VAR_0->dst;",
"ChannelMapContext *s = ctx->priv;",
"int VAR_1, VAR_2 = 0;",
"const char *VAR_3;",
"char VAR_4[256];",
"if (s->mode == MAP_PAIR_STR_INT || s->mode == MAP_PAIR_STR_STR) {",
"for (VAR_1 = 0; VAR_1 < s->nch; VAR_1++) {",
"s->map[VAR_1].in_channel_idx = av_get_channel_layout_channel_index(\nVAR_0->channel_layout, s->map[VAR_1].in_channel);",
"if (s->map[VAR_1].in_channel_idx < 0) {",
"VAR_3 = av_get_channel_name(s->map[VAR_1].in_channel);",
"av_get_channel_layout_string(VAR_4, sizeof(VAR_4),\n0, VAR_0->channel_layout);",
"av_log(ctx, AV_LOG_ERROR,\n\"input channel '%s' not available from input layout '%s'\\n\",\nVAR_3, VAR_4);",
"VAR_2 = AVERROR(EINVAL);",
"}",
"}",
"}",
"return VAR_2;",
"}"
] | [
0,
0,
0,
0,
0,
0,
1,
1,
0,
1,
0,
1,
0,
1,
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
]
] |
21,228 | static void decode_format80(const unsigned char *src, int src_size,
unsigned char *dest, int dest_size, int check_size) {
int src_index = 0;
int dest_index = 0;
int count;
int src_pos;
unsigned char color;
int i;
while (src_index < src_size) {
av_dlog(NULL, " opcode %02X: ", src[src_index]);
/* 0x80 means that frame is finished */
if (src[src_index] == 0x80)
if (dest_index >= dest_size) {
av_log(NULL, AV_LOG_ERROR, " VQA video: decode_format80 problem: dest_index (%d) exceeded dest_size (%d)\n",
dest_index, dest_size);
}
if (src[src_index] == 0xFF) {
src_index++;
count = AV_RL16(&src[src_index]);
src_index += 2;
src_pos = AV_RL16(&src[src_index]);
src_index += 2;
av_dlog(NULL, "(1) copy %X bytes from absolute pos %X\n", count, src_pos);
CHECK_COUNT();
if (src_pos + count > dest_size)
for (i = 0; i < count; i++)
dest[dest_index + i] = dest[src_pos + i];
dest_index += count;
} else if (src[src_index] == 0xFE) {
src_index++;
count = AV_RL16(&src[src_index]);
src_index += 2;
color = src[src_index++];
av_dlog(NULL, "(2) set %X bytes to %02X\n", count, color);
CHECK_COUNT();
memset(&dest[dest_index], color, count);
dest_index += count;
} else if ((src[src_index] & 0xC0) == 0xC0) {
count = (src[src_index++] & 0x3F) + 3;
src_pos = AV_RL16(&src[src_index]);
src_index += 2;
av_dlog(NULL, "(3) copy %X bytes from absolute pos %X\n", count, src_pos);
CHECK_COUNT();
if (src_pos + count > dest_size)
for (i = 0; i < count; i++)
dest[dest_index + i] = dest[src_pos + i];
dest_index += count;
} else if (src[src_index] > 0x80) {
count = src[src_index++] & 0x3F;
av_dlog(NULL, "(4) copy %X bytes from source to dest\n", count);
CHECK_COUNT();
memcpy(&dest[dest_index], &src[src_index], count);
src_index += count;
dest_index += count;
} else {
count = ((src[src_index] & 0x70) >> 4) + 3;
src_pos = AV_RB16(&src[src_index]) & 0x0FFF;
src_index += 2;
av_dlog(NULL, "(5) copy %X bytes from relpos %X\n", count, src_pos);
CHECK_COUNT();
for (i = 0; i < count; i++)
dest[dest_index + i] = dest[dest_index - src_pos + i];
dest_index += count;
}
}
/* validate that the entire destination buffer was filled; this is
* important for decoding frame maps since each vector needs to have a
* codebook entry; it is not important for compressed codebooks because
* not every entry needs to be filled */
if (check_size)
if (dest_index < dest_size)
av_log(NULL, AV_LOG_ERROR, " VQA video: decode_format80 problem: decode finished with dest_index (%d) < dest_size (%d)\n",
dest_index, dest_size);
} | true | FFmpeg | 6d45702f7f257c1cfcd3ce3287bf258854528a4a | static void decode_format80(const unsigned char *src, int src_size,
unsigned char *dest, int dest_size, int check_size) {
int src_index = 0;
int dest_index = 0;
int count;
int src_pos;
unsigned char color;
int i;
while (src_index < src_size) {
av_dlog(NULL, " opcode %02X: ", src[src_index]);
if (src[src_index] == 0x80)
if (dest_index >= dest_size) {
av_log(NULL, AV_LOG_ERROR, " VQA video: decode_format80 problem: dest_index (%d) exceeded dest_size (%d)\n",
dest_index, dest_size);
}
if (src[src_index] == 0xFF) {
src_index++;
count = AV_RL16(&src[src_index]);
src_index += 2;
src_pos = AV_RL16(&src[src_index]);
src_index += 2;
av_dlog(NULL, "(1) copy %X bytes from absolute pos %X\n", count, src_pos);
CHECK_COUNT();
if (src_pos + count > dest_size)
for (i = 0; i < count; i++)
dest[dest_index + i] = dest[src_pos + i];
dest_index += count;
} else if (src[src_index] == 0xFE) {
src_index++;
count = AV_RL16(&src[src_index]);
src_index += 2;
color = src[src_index++];
av_dlog(NULL, "(2) set %X bytes to %02X\n", count, color);
CHECK_COUNT();
memset(&dest[dest_index], color, count);
dest_index += count;
} else if ((src[src_index] & 0xC0) == 0xC0) {
count = (src[src_index++] & 0x3F) + 3;
src_pos = AV_RL16(&src[src_index]);
src_index += 2;
av_dlog(NULL, "(3) copy %X bytes from absolute pos %X\n", count, src_pos);
CHECK_COUNT();
if (src_pos + count > dest_size)
for (i = 0; i < count; i++)
dest[dest_index + i] = dest[src_pos + i];
dest_index += count;
} else if (src[src_index] > 0x80) {
count = src[src_index++] & 0x3F;
av_dlog(NULL, "(4) copy %X bytes from source to dest\n", count);
CHECK_COUNT();
memcpy(&dest[dest_index], &src[src_index], count);
src_index += count;
dest_index += count;
} else {
count = ((src[src_index] & 0x70) >> 4) + 3;
src_pos = AV_RB16(&src[src_index]) & 0x0FFF;
src_index += 2;
av_dlog(NULL, "(5) copy %X bytes from relpos %X\n", count, src_pos);
CHECK_COUNT();
for (i = 0; i < count; i++)
dest[dest_index + i] = dest[dest_index - src_pos + i];
dest_index += count;
}
}
if (check_size)
if (dest_index < dest_size)
av_log(NULL, AV_LOG_ERROR, " VQA video: decode_format80 problem: decode finished with dest_index (%d) < dest_size (%d)\n",
dest_index, dest_size);
} | {
"code": [],
"line_no": []
} | static void FUNC_0(const unsigned char *VAR_0, int VAR_1,
unsigned char *VAR_2, int VAR_3, int VAR_4) {
int VAR_5 = 0;
int VAR_6 = 0;
int VAR_7;
int VAR_8;
unsigned char VAR_9;
int VAR_10;
while (VAR_5 < VAR_1) {
av_dlog(NULL, " opcode %02X: ", VAR_0[VAR_5]);
if (VAR_0[VAR_5] == 0x80)
if (VAR_6 >= VAR_3) {
av_log(NULL, AV_LOG_ERROR, " VQA video: FUNC_0 problem: VAR_6 (%d) exceeded VAR_3 (%d)\n",
VAR_6, VAR_3);
}
if (VAR_0[VAR_5] == 0xFF) {
VAR_5++;
VAR_7 = AV_RL16(&VAR_0[VAR_5]);
VAR_5 += 2;
VAR_8 = AV_RL16(&VAR_0[VAR_5]);
VAR_5 += 2;
av_dlog(NULL, "(1) copy %X bytes from absolute pos %X\n", VAR_7, VAR_8);
CHECK_COUNT();
if (VAR_8 + VAR_7 > VAR_3)
for (VAR_10 = 0; VAR_10 < VAR_7; VAR_10++)
VAR_2[VAR_6 + VAR_10] = VAR_2[VAR_8 + VAR_10];
VAR_6 += VAR_7;
} else if (VAR_0[VAR_5] == 0xFE) {
VAR_5++;
VAR_7 = AV_RL16(&VAR_0[VAR_5]);
VAR_5 += 2;
VAR_9 = VAR_0[VAR_5++];
av_dlog(NULL, "(2) set %X bytes to %02X\n", VAR_7, VAR_9);
CHECK_COUNT();
memset(&VAR_2[VAR_6], VAR_9, VAR_7);
VAR_6 += VAR_7;
} else if ((VAR_0[VAR_5] & 0xC0) == 0xC0) {
VAR_7 = (VAR_0[VAR_5++] & 0x3F) + 3;
VAR_8 = AV_RL16(&VAR_0[VAR_5]);
VAR_5 += 2;
av_dlog(NULL, "(3) copy %X bytes from absolute pos %X\n", VAR_7, VAR_8);
CHECK_COUNT();
if (VAR_8 + VAR_7 > VAR_3)
for (VAR_10 = 0; VAR_10 < VAR_7; VAR_10++)
VAR_2[VAR_6 + VAR_10] = VAR_2[VAR_8 + VAR_10];
VAR_6 += VAR_7;
} else if (VAR_0[VAR_5] > 0x80) {
VAR_7 = VAR_0[VAR_5++] & 0x3F;
av_dlog(NULL, "(4) copy %X bytes from source to VAR_2\n", VAR_7);
CHECK_COUNT();
memcpy(&VAR_2[VAR_6], &VAR_0[VAR_5], VAR_7);
VAR_5 += VAR_7;
VAR_6 += VAR_7;
} else {
VAR_7 = ((VAR_0[VAR_5] & 0x70) >> 4) + 3;
VAR_8 = AV_RB16(&VAR_0[VAR_5]) & 0x0FFF;
VAR_5 += 2;
av_dlog(NULL, "(5) copy %X bytes from relpos %X\n", VAR_7, VAR_8);
CHECK_COUNT();
for (VAR_10 = 0; VAR_10 < VAR_7; VAR_10++)
VAR_2[VAR_6 + VAR_10] = VAR_2[VAR_6 - VAR_8 + VAR_10];
VAR_6 += VAR_7;
}
}
if (VAR_4)
if (VAR_6 < VAR_3)
av_log(NULL, AV_LOG_ERROR, " VQA video: FUNC_0 problem: decode finished with VAR_6 (%d) < VAR_3 (%d)\n",
VAR_6, VAR_3);
} | [
"static void FUNC_0(const unsigned char *VAR_0, int VAR_1,\nunsigned char *VAR_2, int VAR_3, int VAR_4) {",
"int VAR_5 = 0;",
"int VAR_6 = 0;",
"int VAR_7;",
"int VAR_8;",
"unsigned char VAR_9;",
"int VAR_10;",
"while (VAR_5 < VAR_1) {",
"av_dlog(NULL, \" opcode %02X: \", VAR_0[VAR_5]);",
"if (VAR_0[VAR_5] == 0x80)\nif (VAR_6 >= VAR_3) {",
"av_log(NULL, AV_LOG_ERROR, \" VQA video: FUNC_0 problem: VAR_6 (%d) exceeded VAR_3 (%d)\\n\",\nVAR_6, VAR_3);",
"}",
"if (VAR_0[VAR_5] == 0xFF) {",
"VAR_5++;",
"VAR_7 = AV_RL16(&VAR_0[VAR_5]);",
"VAR_5 += 2;",
"VAR_8 = AV_RL16(&VAR_0[VAR_5]);",
"VAR_5 += 2;",
"av_dlog(NULL, \"(1) copy %X bytes from absolute pos %X\\n\", VAR_7, VAR_8);",
"CHECK_COUNT();",
"if (VAR_8 + VAR_7 > VAR_3)\nfor (VAR_10 = 0; VAR_10 < VAR_7; VAR_10++)",
"VAR_2[VAR_6 + VAR_10] = VAR_2[VAR_8 + VAR_10];",
"VAR_6 += VAR_7;",
"} else if (VAR_0[VAR_5] == 0xFE) {",
"VAR_5++;",
"VAR_7 = AV_RL16(&VAR_0[VAR_5]);",
"VAR_5 += 2;",
"VAR_9 = VAR_0[VAR_5++];",
"av_dlog(NULL, \"(2) set %X bytes to %02X\\n\", VAR_7, VAR_9);",
"CHECK_COUNT();",
"memset(&VAR_2[VAR_6], VAR_9, VAR_7);",
"VAR_6 += VAR_7;",
"} else if ((VAR_0[VAR_5] & 0xC0) == 0xC0) {",
"VAR_7 = (VAR_0[VAR_5++] & 0x3F) + 3;",
"VAR_8 = AV_RL16(&VAR_0[VAR_5]);",
"VAR_5 += 2;",
"av_dlog(NULL, \"(3) copy %X bytes from absolute pos %X\\n\", VAR_7, VAR_8);",
"CHECK_COUNT();",
"if (VAR_8 + VAR_7 > VAR_3)\nfor (VAR_10 = 0; VAR_10 < VAR_7; VAR_10++)",
"VAR_2[VAR_6 + VAR_10] = VAR_2[VAR_8 + VAR_10];",
"VAR_6 += VAR_7;",
"} else if (VAR_0[VAR_5] > 0x80) {",
"VAR_7 = VAR_0[VAR_5++] & 0x3F;",
"av_dlog(NULL, \"(4) copy %X bytes from source to VAR_2\\n\", VAR_7);",
"CHECK_COUNT();",
"memcpy(&VAR_2[VAR_6], &VAR_0[VAR_5], VAR_7);",
"VAR_5 += VAR_7;",
"VAR_6 += VAR_7;",
"} else {",
"VAR_7 = ((VAR_0[VAR_5] & 0x70) >> 4) + 3;",
"VAR_8 = AV_RB16(&VAR_0[VAR_5]) & 0x0FFF;",
"VAR_5 += 2;",
"av_dlog(NULL, \"(5) copy %X bytes from relpos %X\\n\", VAR_7, VAR_8);",
"CHECK_COUNT();",
"for (VAR_10 = 0; VAR_10 < VAR_7; VAR_10++)",
"VAR_2[VAR_6 + VAR_10] = VAR_2[VAR_6 - VAR_8 + VAR_10];",
"VAR_6 += VAR_7;",
"}",
"}",
"if (VAR_4)\nif (VAR_6 < VAR_3)\nav_log(NULL, AV_LOG_ERROR, \" VQA video: FUNC_0 problem: decode finished with VAR_6 (%d) < VAR_3 (%d)\\n\",\nVAR_6, 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,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
25
],
[
31,
36
],
[
38,
40
],
[
43
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65,
68
],
[
70
],
[
72
],
[
76
],
[
80
],
[
82
],
[
84
],
[
86
],
[
88
],
[
90
],
[
92
],
[
94
],
[
98
],
[
102
],
[
104
],
[
106
],
[
108
],
[
110
],
[
112,
115
],
[
117
],
[
119
],
[
123
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
141
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
177,
179,
181,
183
],
[
185
]
] |
21,229 | void do_info_roms(Monitor *mon, const QDict *qdict)
{
Rom *rom;
QTAILQ_FOREACH(rom, &roms, next) {
if (!rom->fw_file) {
monitor_printf(mon, "addr=" TARGET_FMT_plx
" size=0x%06zx mem=%s name=\"%s\"\n",
rom->addr, rom->romsize,
rom->isrom ? "rom" : "ram",
rom->name);
} else {
monitor_printf(mon, "fw=%s/%s"
" size=0x%06zx name=\"%s\"\n",
rom->fw_dir,
rom->fw_file,
rom->romsize,
rom->name);
}
}
}
| true | qemu | 04920fc0faa4760f9c4fc0e73b992b768099be70 | void do_info_roms(Monitor *mon, const QDict *qdict)
{
Rom *rom;
QTAILQ_FOREACH(rom, &roms, next) {
if (!rom->fw_file) {
monitor_printf(mon, "addr=" TARGET_FMT_plx
" size=0x%06zx mem=%s name=\"%s\"\n",
rom->addr, rom->romsize,
rom->isrom ? "rom" : "ram",
rom->name);
} else {
monitor_printf(mon, "fw=%s/%s"
" size=0x%06zx name=\"%s\"\n",
rom->fw_dir,
rom->fw_file,
rom->romsize,
rom->name);
}
}
}
| {
"code": [
" if (!rom->fw_file) {"
],
"line_no": [
11
]
} | void FUNC_0(Monitor *VAR_0, const QDict *VAR_1)
{
Rom *rom;
QTAILQ_FOREACH(rom, &roms, next) {
if (!rom->fw_file) {
monitor_printf(VAR_0, "addr=" TARGET_FMT_plx
" size=0x%06zx mem=%s name=\"%s\"\n",
rom->addr, rom->romsize,
rom->isrom ? "rom" : "ram",
rom->name);
} else {
monitor_printf(VAR_0, "fw=%s/%s"
" size=0x%06zx name=\"%s\"\n",
rom->fw_dir,
rom->fw_file,
rom->romsize,
rom->name);
}
}
}
| [
"void FUNC_0(Monitor *VAR_0, const QDict *VAR_1)\n{",
"Rom *rom;",
"QTAILQ_FOREACH(rom, &roms, next) {",
"if (!rom->fw_file) {",
"monitor_printf(VAR_0, \"addr=\" TARGET_FMT_plx\n\" size=0x%06zx mem=%s name=\\\"%s\\\"\\n\",\nrom->addr, rom->romsize,\nrom->isrom ? \"rom\" : \"ram\",\nrom->name);",
"} else {",
"monitor_printf(VAR_0, \"fw=%s/%s\"\n\" size=0x%06zx name=\\\"%s\\\"\\n\",\nrom->fw_dir,\nrom->fw_file,\nrom->romsize,\nrom->name);",
"}",
"}",
"}"
] | [
0,
0,
0,
1,
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
]
] |
21,231 | static void migration_end(void)
{
if (migration_bitmap) {
memory_global_dirty_log_stop();
g_free(migration_bitmap);
migration_bitmap = NULL;
}
if (XBZRLE.cache) {
cache_fini(XBZRLE.cache);
g_free(XBZRLE.cache);
g_free(XBZRLE.encoded_buf);
g_free(XBZRLE.current_buf);
g_free(XBZRLE.decoded_buf);
XBZRLE.cache = NULL;
}
} | true | qemu | f6c6483b259a2395ee44cfa966f622e0f2dbe2ae | static void migration_end(void)
{
if (migration_bitmap) {
memory_global_dirty_log_stop();
g_free(migration_bitmap);
migration_bitmap = NULL;
}
if (XBZRLE.cache) {
cache_fini(XBZRLE.cache);
g_free(XBZRLE.cache);
g_free(XBZRLE.encoded_buf);
g_free(XBZRLE.current_buf);
g_free(XBZRLE.decoded_buf);
XBZRLE.cache = NULL;
}
} | {
"code": [],
"line_no": []
} | static void FUNC_0(void)
{
if (migration_bitmap) {
memory_global_dirty_log_stop();
g_free(migration_bitmap);
migration_bitmap = NULL;
}
if (XBZRLE.cache) {
cache_fini(XBZRLE.cache);
g_free(XBZRLE.cache);
g_free(XBZRLE.encoded_buf);
g_free(XBZRLE.current_buf);
g_free(XBZRLE.decoded_buf);
XBZRLE.cache = NULL;
}
} | [
"static void FUNC_0(void)\n{",
"if (migration_bitmap) {",
"memory_global_dirty_log_stop();",
"g_free(migration_bitmap);",
"migration_bitmap = NULL;",
"}",
"if (XBZRLE.cache) {",
"cache_fini(XBZRLE.cache);",
"g_free(XBZRLE.cache);",
"g_free(XBZRLE.encoded_buf);",
"g_free(XBZRLE.current_buf);",
"g_free(XBZRLE.decoded_buf);",
"XBZRLE.cache = NULL;",
"}",
"}"
] | [
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
],
[
34
],
[
36
]
] |
21,232 | static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
{
AVFilterContext *ctx = inlink->dst;
Stereo3DContext *s = ctx->priv;
AVFilterLink *outlink = ctx->outputs[0];
AVFrame *out, *oleft, *oright, *ileft, *iright;
int out_off_left[4], out_off_right[4];
int i;
if (s->in.format == s->out.format)
return ff_filter_frame(outlink, inpicref);
switch (s->in.format) {
case ALTERNATING_LR:
case ALTERNATING_RL:
if (!s->prev) {
s->prev = inpicref;
return 0;
}
ileft = s->prev;
iright = inpicref;
if (s->in.format == ALTERNATING_RL)
FFSWAP(AVFrame *, ileft, iright);
break;
default:
ileft = iright = inpicref;
};
if ((s->out.format == ALTERNATING_LR ||
s->out.format == ALTERNATING_RL) &&
(s->in.format == SIDE_BY_SIDE_LR ||
s->in.format == SIDE_BY_SIDE_RL ||
s->in.format == SIDE_BY_SIDE_2_LR ||
s->in.format == SIDE_BY_SIDE_2_RL ||
s->in.format == ABOVE_BELOW_LR ||
s->in.format == ABOVE_BELOW_RL ||
s->in.format == ABOVE_BELOW_2_LR ||
s->in.format == ABOVE_BELOW_2_RL)) {
oright = av_frame_clone(inpicref);
oleft = av_frame_clone(inpicref);
if (!oright || !oleft) {
av_frame_free(&oright);
av_frame_free(&oleft);
av_frame_free(&s->prev);
av_frame_free(&inpicref);
return AVERROR(ENOMEM);
}
} else if ((s->out.format == MONO_L ||
s->out.format == MONO_R) &&
(s->in.format == SIDE_BY_SIDE_LR ||
s->in.format == SIDE_BY_SIDE_RL ||
s->in.format == SIDE_BY_SIDE_2_LR ||
s->in.format == SIDE_BY_SIDE_2_RL ||
s->in.format == ABOVE_BELOW_LR ||
s->in.format == ABOVE_BELOW_RL ||
s->in.format == ABOVE_BELOW_2_LR ||
s->in.format == ABOVE_BELOW_2_RL)) {
out = oleft = oright = av_frame_clone(inpicref);
if (!out) {
av_frame_free(&s->prev);
av_frame_free(&inpicref);
return AVERROR(ENOMEM);
}
} else {
out = oleft = oright = ff_get_video_buffer(outlink, outlink->w, outlink->h);
if (!out) {
av_frame_free(&s->prev);
av_frame_free(&inpicref);
return AVERROR(ENOMEM);
}
av_frame_copy_props(out, inpicref);
if (s->out.format == ALTERNATING_LR ||
s->out.format == ALTERNATING_RL) {
oright = ff_get_video_buffer(outlink, outlink->w, outlink->h);
if (!oright) {
av_frame_free(&oleft);
av_frame_free(&s->prev);
av_frame_free(&inpicref);
return AVERROR(ENOMEM);
}
av_frame_copy_props(oright, inpicref);
}
}
for (i = 0; i < 4; i++) {
int hsub = i == 1 || i == 2 ? s->hsub : 0;
int vsub = i == 1 || i == 2 ? s->vsub : 0;
s->in_off_left[i] = (FF_CEIL_RSHIFT(s->in.row_left, vsub) + s->in.off_lstep) * ileft->linesize[i] + FF_CEIL_RSHIFT(s->in.off_left * s->pixstep[i], hsub);
s->in_off_right[i] = (FF_CEIL_RSHIFT(s->in.row_right, vsub) + s->in.off_rstep) * iright->linesize[i] + FF_CEIL_RSHIFT(s->in.off_right * s->pixstep[i], hsub);
out_off_left[i] = (FF_CEIL_RSHIFT(s->out.row_left, vsub) + s->out.off_lstep) * oleft->linesize[i] + FF_CEIL_RSHIFT(s->out.off_left * s->pixstep[i], hsub);
out_off_right[i] = (FF_CEIL_RSHIFT(s->out.row_right, vsub) + s->out.off_rstep) * oright->linesize[i] + FF_CEIL_RSHIFT(s->out.off_right * s->pixstep[i], hsub);
}
switch (s->out.format) {
case ALTERNATING_LR:
case ALTERNATING_RL:
switch (s->in.format) {
case ABOVE_BELOW_LR:
case ABOVE_BELOW_RL:
case ABOVE_BELOW_2_LR:
case ABOVE_BELOW_2_RL:
case SIDE_BY_SIDE_LR:
case SIDE_BY_SIDE_RL:
case SIDE_BY_SIDE_2_LR:
case SIDE_BY_SIDE_2_RL:
oleft->width = outlink->w;
oright->width = outlink->w;
oleft->height = outlink->h;
oright->height = outlink->h;
for (i = 0; i < s->nb_planes; i++) {
oleft->data[i] += s->in_off_left[i];
oright->data[i] += s->in_off_right[i];
}
break;
default:
goto copy;
break;
}
break;
case HDMI:
for (i = 0; i < s->nb_planes; i++) {
int j, h = s->height >> ((i == 1 || i == 2) ? s->vsub : 0);
int b = (s->blanks) >> ((i == 1 || i == 2) ? s->vsub : 0);
for (j = h; j < h + b; j++)
memset(oleft->data[i] + j * s->linesize[i], 0, s->linesize[i]);
}
case SIDE_BY_SIDE_LR:
case SIDE_BY_SIDE_RL:
case SIDE_BY_SIDE_2_LR:
case SIDE_BY_SIDE_2_RL:
case ABOVE_BELOW_LR:
case ABOVE_BELOW_RL:
case ABOVE_BELOW_2_LR:
case ABOVE_BELOW_2_RL:
case INTERLEAVE_ROWS_LR:
case INTERLEAVE_ROWS_RL:
copy:
for (i = 0; i < s->nb_planes; i++) {
av_image_copy_plane(oleft->data[i] + out_off_left[i],
oleft->linesize[i] * s->out.row_step,
ileft->data[i] + s->in_off_left[i],
ileft->linesize[i] * s->in.row_step,
s->linesize[i], s->pheight[i]);
av_image_copy_plane(oright->data[i] + out_off_right[i],
oright->linesize[i] * s->out.row_step,
iright->data[i] + s->in_off_right[i],
iright->linesize[i] * s->in.row_step,
s->linesize[i], s->pheight[i]);
}
break;
case MONO_L:
iright = ileft;
case MONO_R:
switch (s->in.format) {
case ABOVE_BELOW_LR:
case ABOVE_BELOW_RL:
case ABOVE_BELOW_2_LR:
case ABOVE_BELOW_2_RL:
case SIDE_BY_SIDE_LR:
case SIDE_BY_SIDE_RL:
case SIDE_BY_SIDE_2_LR:
case SIDE_BY_SIDE_2_RL:
out->width = outlink->w;
out->height = outlink->h;
for (i = 0; i < s->nb_planes; i++) {
out->data[i] += s->in_off_left[i];
}
break;
default:
for (i = 0; i < s->nb_planes; i++) {
av_image_copy_plane(out->data[i], out->linesize[i],
iright->data[i] + s->in_off_left[i],
iright->linesize[i] * s->in.row_step,
s->linesize[i], s->pheight[i]);
}
break;
}
break;
case ANAGLYPH_RB_GRAY:
case ANAGLYPH_RG_GRAY:
case ANAGLYPH_RC_GRAY:
case ANAGLYPH_RC_HALF:
case ANAGLYPH_RC_COLOR:
case ANAGLYPH_RC_DUBOIS:
case ANAGLYPH_GM_GRAY:
case ANAGLYPH_GM_HALF:
case ANAGLYPH_GM_COLOR:
case ANAGLYPH_GM_DUBOIS:
case ANAGLYPH_YB_GRAY:
case ANAGLYPH_YB_HALF:
case ANAGLYPH_YB_COLOR:
case ANAGLYPH_YB_DUBOIS: {
ThreadData td;
td.ileft = ileft; td.iright = iright; td.out = out;
ctx->internal->execute(ctx, filter_slice, &td, NULL,
FFMIN(s->out.height, ctx->graph->nb_threads));
break;
}
case CHECKERBOARD_RL:
case CHECKERBOARD_LR:
for (i = 0; i < s->nb_planes; i++) {
int x, y;
for (y = 0; y < s->pheight[i]; y++) {
uint8_t *dst = out->data[i] + out->linesize[i] * y;
uint8_t *left = ileft->data[i] + ileft->linesize[i] * y + s->in_off_left[i];
uint8_t *right = iright->data[i] + iright->linesize[i] * y + s->in_off_right[i];
int p, b;
if (s->out.format == CHECKERBOARD_RL)
FFSWAP(uint8_t*, left, right);
switch (s->pixstep[i]) {
case 1:
for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=2, p++, b++) {
dst[x ] = (b&1) == (y&1) ? left[p] : right[p];
dst[x+1] = (b&1) != (y&1) ? left[p] : right[p];
}
break;
case 2:
for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=4, p+=2, b++) {
AV_WN16(&dst[x ], (b&1) == (y&1) ? AV_RN16(&left[p]) : AV_RN16(&right[p]));
AV_WN16(&dst[x+2], (b&1) != (y&1) ? AV_RN16(&left[p]) : AV_RN16(&right[p]));
}
break;
case 3:
for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=6, p+=3, b++) {
AV_WB24(&dst[x ], (b&1) == (y&1) ? AV_RB24(&left[p]) : AV_RB24(&right[p]));
AV_WB24(&dst[x+3], (b&1) != (y&1) ? AV_RB24(&left[p]) : AV_RB24(&right[p]));
}
break;
case 4:
for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=8, p+=4, b++) {
AV_WN32(&dst[x ], (b&1) == (y&1) ? AV_RN32(&left[p]) : AV_RN32(&right[p]));
AV_WN32(&dst[x+4], (b&1) != (y&1) ? AV_RN32(&left[p]) : AV_RN32(&right[p]));
}
break;
case 6:
for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=12, p+=6, b++) {
AV_WB48(&dst[x ], (b&1) == (y&1) ? AV_RB48(&left[p]) : AV_RB48(&right[p]));
AV_WB48(&dst[x+6], (b&1) != (y&1) ? AV_RB48(&left[p]) : AV_RB48(&right[p]));
}
break;
case 8:
for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=16, p+=8, b++) {
AV_WN64(&dst[x ], (b&1) == (y&1) ? AV_RN64(&left[p]) : AV_RN64(&right[p]));
AV_WN64(&dst[x+8], (b&1) != (y&1) ? AV_RN64(&left[p]) : AV_RN64(&right[p]));
}
break;
}
}
}
break;
case INTERLEAVE_COLS_LR:
case INTERLEAVE_COLS_RL:
for (i = 0; i < s->nb_planes; i++) {
int x, y;
for (y = 0; y < s->pheight[i]; y++) {
uint8_t *dst = out->data[i] + out->linesize[i] * y;
uint8_t *left = ileft->data[i] + ileft->linesize[i] * y * s->in.row_step + s->in_off_left[i];
uint8_t *right = iright->data[i] + iright->linesize[i] * y * s->in.row_step + s->in_off_right[i];
int p, b;
if (s->out.format == INTERLEAVE_COLS_LR)
FFSWAP(uint8_t*, left, right);
switch (s->pixstep[i]) {
case 1:
for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=2, p++, b++) {
dst[x ] = b&1 ? left[p] : right[p];
dst[x+1] = !(b&1) ? left[p] : right[p];
}
break;
case 2:
for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=4, p+=2, b++) {
AV_WN16(&dst[x ], b&1 ? AV_RN16(&left[p]) : AV_RN16(&right[p]));
AV_WN16(&dst[x+2], !(b&1) ? AV_RN16(&left[p]) : AV_RN16(&right[p]));
}
break;
case 3:
for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=6, p+=3, b++) {
AV_WB24(&dst[x ], b&1 ? AV_RB24(&left[p]) : AV_RB24(&right[p]));
AV_WB24(&dst[x+3], !(b&1) ? AV_RB24(&left[p]) : AV_RB24(&right[p]));
}
break;
case 4:
for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=8, p+=4, b++) {
AV_WN32(&dst[x ], b&1 ? AV_RN32(&left[p]) : AV_RN32(&right[p]));
AV_WN32(&dst[x+4], !(b&1) ? AV_RN32(&left[p]) : AV_RN32(&right[p]));
}
break;
case 6:
for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=12, p+=6, b++) {
AV_WB48(&dst[x ], b&1 ? AV_RB48(&left[p]) : AV_RB48(&right[p]));
AV_WB48(&dst[x+6], !(b&1) ? AV_RB48(&left[p]) : AV_RB48(&right[p]));
}
break;
case 8:
for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=16, p+=8, b++) {
AV_WN64(&dst[x ], b&1 ? AV_RN64(&left[p]) : AV_RN64(&right[p]));
AV_WN64(&dst[x+8], !(b&1) ? AV_RN64(&left[p]) : AV_RN64(&right[p]));
}
break;
}
}
}
break;
default:
av_assert0(0);
}
av_frame_free(&inpicref);
av_frame_free(&s->prev);
if (oright != oleft) {
if (s->out.format == ALTERNATING_LR)
FFSWAP(AVFrame *, oleft, oright);
oright->pts = outlink->frame_count * s->ts_unit;
ff_filter_frame(outlink, oright);
out = oleft;
oleft->pts = outlink->frame_count * s->ts_unit;
} else if (s->in.format == ALTERNATING_LR ||
s->in.format == ALTERNATING_RL) {
out->pts = outlink->frame_count * s->ts_unit;
}
return ff_filter_frame(outlink, out);
}
| false | FFmpeg | 10b16aee1bde611b8dd3dada970258f9d2aa1f1c | static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
{
AVFilterContext *ctx = inlink->dst;
Stereo3DContext *s = ctx->priv;
AVFilterLink *outlink = ctx->outputs[0];
AVFrame *out, *oleft, *oright, *ileft, *iright;
int out_off_left[4], out_off_right[4];
int i;
if (s->in.format == s->out.format)
return ff_filter_frame(outlink, inpicref);
switch (s->in.format) {
case ALTERNATING_LR:
case ALTERNATING_RL:
if (!s->prev) {
s->prev = inpicref;
return 0;
}
ileft = s->prev;
iright = inpicref;
if (s->in.format == ALTERNATING_RL)
FFSWAP(AVFrame *, ileft, iright);
break;
default:
ileft = iright = inpicref;
};
if ((s->out.format == ALTERNATING_LR ||
s->out.format == ALTERNATING_RL) &&
(s->in.format == SIDE_BY_SIDE_LR ||
s->in.format == SIDE_BY_SIDE_RL ||
s->in.format == SIDE_BY_SIDE_2_LR ||
s->in.format == SIDE_BY_SIDE_2_RL ||
s->in.format == ABOVE_BELOW_LR ||
s->in.format == ABOVE_BELOW_RL ||
s->in.format == ABOVE_BELOW_2_LR ||
s->in.format == ABOVE_BELOW_2_RL)) {
oright = av_frame_clone(inpicref);
oleft = av_frame_clone(inpicref);
if (!oright || !oleft) {
av_frame_free(&oright);
av_frame_free(&oleft);
av_frame_free(&s->prev);
av_frame_free(&inpicref);
return AVERROR(ENOMEM);
}
} else if ((s->out.format == MONO_L ||
s->out.format == MONO_R) &&
(s->in.format == SIDE_BY_SIDE_LR ||
s->in.format == SIDE_BY_SIDE_RL ||
s->in.format == SIDE_BY_SIDE_2_LR ||
s->in.format == SIDE_BY_SIDE_2_RL ||
s->in.format == ABOVE_BELOW_LR ||
s->in.format == ABOVE_BELOW_RL ||
s->in.format == ABOVE_BELOW_2_LR ||
s->in.format == ABOVE_BELOW_2_RL)) {
out = oleft = oright = av_frame_clone(inpicref);
if (!out) {
av_frame_free(&s->prev);
av_frame_free(&inpicref);
return AVERROR(ENOMEM);
}
} else {
out = oleft = oright = ff_get_video_buffer(outlink, outlink->w, outlink->h);
if (!out) {
av_frame_free(&s->prev);
av_frame_free(&inpicref);
return AVERROR(ENOMEM);
}
av_frame_copy_props(out, inpicref);
if (s->out.format == ALTERNATING_LR ||
s->out.format == ALTERNATING_RL) {
oright = ff_get_video_buffer(outlink, outlink->w, outlink->h);
if (!oright) {
av_frame_free(&oleft);
av_frame_free(&s->prev);
av_frame_free(&inpicref);
return AVERROR(ENOMEM);
}
av_frame_copy_props(oright, inpicref);
}
}
for (i = 0; i < 4; i++) {
int hsub = i == 1 || i == 2 ? s->hsub : 0;
int vsub = i == 1 || i == 2 ? s->vsub : 0;
s->in_off_left[i] = (FF_CEIL_RSHIFT(s->in.row_left, vsub) + s->in.off_lstep) * ileft->linesize[i] + FF_CEIL_RSHIFT(s->in.off_left * s->pixstep[i], hsub);
s->in_off_right[i] = (FF_CEIL_RSHIFT(s->in.row_right, vsub) + s->in.off_rstep) * iright->linesize[i] + FF_CEIL_RSHIFT(s->in.off_right * s->pixstep[i], hsub);
out_off_left[i] = (FF_CEIL_RSHIFT(s->out.row_left, vsub) + s->out.off_lstep) * oleft->linesize[i] + FF_CEIL_RSHIFT(s->out.off_left * s->pixstep[i], hsub);
out_off_right[i] = (FF_CEIL_RSHIFT(s->out.row_right, vsub) + s->out.off_rstep) * oright->linesize[i] + FF_CEIL_RSHIFT(s->out.off_right * s->pixstep[i], hsub);
}
switch (s->out.format) {
case ALTERNATING_LR:
case ALTERNATING_RL:
switch (s->in.format) {
case ABOVE_BELOW_LR:
case ABOVE_BELOW_RL:
case ABOVE_BELOW_2_LR:
case ABOVE_BELOW_2_RL:
case SIDE_BY_SIDE_LR:
case SIDE_BY_SIDE_RL:
case SIDE_BY_SIDE_2_LR:
case SIDE_BY_SIDE_2_RL:
oleft->width = outlink->w;
oright->width = outlink->w;
oleft->height = outlink->h;
oright->height = outlink->h;
for (i = 0; i < s->nb_planes; i++) {
oleft->data[i] += s->in_off_left[i];
oright->data[i] += s->in_off_right[i];
}
break;
default:
goto copy;
break;
}
break;
case HDMI:
for (i = 0; i < s->nb_planes; i++) {
int j, h = s->height >> ((i == 1 || i == 2) ? s->vsub : 0);
int b = (s->blanks) >> ((i == 1 || i == 2) ? s->vsub : 0);
for (j = h; j < h + b; j++)
memset(oleft->data[i] + j * s->linesize[i], 0, s->linesize[i]);
}
case SIDE_BY_SIDE_LR:
case SIDE_BY_SIDE_RL:
case SIDE_BY_SIDE_2_LR:
case SIDE_BY_SIDE_2_RL:
case ABOVE_BELOW_LR:
case ABOVE_BELOW_RL:
case ABOVE_BELOW_2_LR:
case ABOVE_BELOW_2_RL:
case INTERLEAVE_ROWS_LR:
case INTERLEAVE_ROWS_RL:
copy:
for (i = 0; i < s->nb_planes; i++) {
av_image_copy_plane(oleft->data[i] + out_off_left[i],
oleft->linesize[i] * s->out.row_step,
ileft->data[i] + s->in_off_left[i],
ileft->linesize[i] * s->in.row_step,
s->linesize[i], s->pheight[i]);
av_image_copy_plane(oright->data[i] + out_off_right[i],
oright->linesize[i] * s->out.row_step,
iright->data[i] + s->in_off_right[i],
iright->linesize[i] * s->in.row_step,
s->linesize[i], s->pheight[i]);
}
break;
case MONO_L:
iright = ileft;
case MONO_R:
switch (s->in.format) {
case ABOVE_BELOW_LR:
case ABOVE_BELOW_RL:
case ABOVE_BELOW_2_LR:
case ABOVE_BELOW_2_RL:
case SIDE_BY_SIDE_LR:
case SIDE_BY_SIDE_RL:
case SIDE_BY_SIDE_2_LR:
case SIDE_BY_SIDE_2_RL:
out->width = outlink->w;
out->height = outlink->h;
for (i = 0; i < s->nb_planes; i++) {
out->data[i] += s->in_off_left[i];
}
break;
default:
for (i = 0; i < s->nb_planes; i++) {
av_image_copy_plane(out->data[i], out->linesize[i],
iright->data[i] + s->in_off_left[i],
iright->linesize[i] * s->in.row_step,
s->linesize[i], s->pheight[i]);
}
break;
}
break;
case ANAGLYPH_RB_GRAY:
case ANAGLYPH_RG_GRAY:
case ANAGLYPH_RC_GRAY:
case ANAGLYPH_RC_HALF:
case ANAGLYPH_RC_COLOR:
case ANAGLYPH_RC_DUBOIS:
case ANAGLYPH_GM_GRAY:
case ANAGLYPH_GM_HALF:
case ANAGLYPH_GM_COLOR:
case ANAGLYPH_GM_DUBOIS:
case ANAGLYPH_YB_GRAY:
case ANAGLYPH_YB_HALF:
case ANAGLYPH_YB_COLOR:
case ANAGLYPH_YB_DUBOIS: {
ThreadData td;
td.ileft = ileft; td.iright = iright; td.out = out;
ctx->internal->execute(ctx, filter_slice, &td, NULL,
FFMIN(s->out.height, ctx->graph->nb_threads));
break;
}
case CHECKERBOARD_RL:
case CHECKERBOARD_LR:
for (i = 0; i < s->nb_planes; i++) {
int x, y;
for (y = 0; y < s->pheight[i]; y++) {
uint8_t *dst = out->data[i] + out->linesize[i] * y;
uint8_t *left = ileft->data[i] + ileft->linesize[i] * y + s->in_off_left[i];
uint8_t *right = iright->data[i] + iright->linesize[i] * y + s->in_off_right[i];
int p, b;
if (s->out.format == CHECKERBOARD_RL)
FFSWAP(uint8_t*, left, right);
switch (s->pixstep[i]) {
case 1:
for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=2, p++, b++) {
dst[x ] = (b&1) == (y&1) ? left[p] : right[p];
dst[x+1] = (b&1) != (y&1) ? left[p] : right[p];
}
break;
case 2:
for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=4, p+=2, b++) {
AV_WN16(&dst[x ], (b&1) == (y&1) ? AV_RN16(&left[p]) : AV_RN16(&right[p]));
AV_WN16(&dst[x+2], (b&1) != (y&1) ? AV_RN16(&left[p]) : AV_RN16(&right[p]));
}
break;
case 3:
for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=6, p+=3, b++) {
AV_WB24(&dst[x ], (b&1) == (y&1) ? AV_RB24(&left[p]) : AV_RB24(&right[p]));
AV_WB24(&dst[x+3], (b&1) != (y&1) ? AV_RB24(&left[p]) : AV_RB24(&right[p]));
}
break;
case 4:
for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=8, p+=4, b++) {
AV_WN32(&dst[x ], (b&1) == (y&1) ? AV_RN32(&left[p]) : AV_RN32(&right[p]));
AV_WN32(&dst[x+4], (b&1) != (y&1) ? AV_RN32(&left[p]) : AV_RN32(&right[p]));
}
break;
case 6:
for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=12, p+=6, b++) {
AV_WB48(&dst[x ], (b&1) == (y&1) ? AV_RB48(&left[p]) : AV_RB48(&right[p]));
AV_WB48(&dst[x+6], (b&1) != (y&1) ? AV_RB48(&left[p]) : AV_RB48(&right[p]));
}
break;
case 8:
for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=16, p+=8, b++) {
AV_WN64(&dst[x ], (b&1) == (y&1) ? AV_RN64(&left[p]) : AV_RN64(&right[p]));
AV_WN64(&dst[x+8], (b&1) != (y&1) ? AV_RN64(&left[p]) : AV_RN64(&right[p]));
}
break;
}
}
}
break;
case INTERLEAVE_COLS_LR:
case INTERLEAVE_COLS_RL:
for (i = 0; i < s->nb_planes; i++) {
int x, y;
for (y = 0; y < s->pheight[i]; y++) {
uint8_t *dst = out->data[i] + out->linesize[i] * y;
uint8_t *left = ileft->data[i] + ileft->linesize[i] * y * s->in.row_step + s->in_off_left[i];
uint8_t *right = iright->data[i] + iright->linesize[i] * y * s->in.row_step + s->in_off_right[i];
int p, b;
if (s->out.format == INTERLEAVE_COLS_LR)
FFSWAP(uint8_t*, left, right);
switch (s->pixstep[i]) {
case 1:
for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=2, p++, b++) {
dst[x ] = b&1 ? left[p] : right[p];
dst[x+1] = !(b&1) ? left[p] : right[p];
}
break;
case 2:
for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=4, p+=2, b++) {
AV_WN16(&dst[x ], b&1 ? AV_RN16(&left[p]) : AV_RN16(&right[p]));
AV_WN16(&dst[x+2], !(b&1) ? AV_RN16(&left[p]) : AV_RN16(&right[p]));
}
break;
case 3:
for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=6, p+=3, b++) {
AV_WB24(&dst[x ], b&1 ? AV_RB24(&left[p]) : AV_RB24(&right[p]));
AV_WB24(&dst[x+3], !(b&1) ? AV_RB24(&left[p]) : AV_RB24(&right[p]));
}
break;
case 4:
for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=8, p+=4, b++) {
AV_WN32(&dst[x ], b&1 ? AV_RN32(&left[p]) : AV_RN32(&right[p]));
AV_WN32(&dst[x+4], !(b&1) ? AV_RN32(&left[p]) : AV_RN32(&right[p]));
}
break;
case 6:
for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=12, p+=6, b++) {
AV_WB48(&dst[x ], b&1 ? AV_RB48(&left[p]) : AV_RB48(&right[p]));
AV_WB48(&dst[x+6], !(b&1) ? AV_RB48(&left[p]) : AV_RB48(&right[p]));
}
break;
case 8:
for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=16, p+=8, b++) {
AV_WN64(&dst[x ], b&1 ? AV_RN64(&left[p]) : AV_RN64(&right[p]));
AV_WN64(&dst[x+8], !(b&1) ? AV_RN64(&left[p]) : AV_RN64(&right[p]));
}
break;
}
}
}
break;
default:
av_assert0(0);
}
av_frame_free(&inpicref);
av_frame_free(&s->prev);
if (oright != oleft) {
if (s->out.format == ALTERNATING_LR)
FFSWAP(AVFrame *, oleft, oright);
oright->pts = outlink->frame_count * s->ts_unit;
ff_filter_frame(outlink, oright);
out = oleft;
oleft->pts = outlink->frame_count * s->ts_unit;
} else if (s->in.format == ALTERNATING_LR ||
s->in.format == ALTERNATING_RL) {
out->pts = outlink->frame_count * s->ts_unit;
}
return ff_filter_frame(outlink, out);
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFilterLink *VAR_0, AVFrame *VAR_1)
{
AVFilterContext *ctx = VAR_0->dst;
Stereo3DContext *s = ctx->priv;
AVFilterLink *outlink = ctx->outputs[0];
AVFrame *out, *oleft, *oright, *ileft, *iright;
int VAR_2[4], VAR_3[4];
int VAR_4;
if (s->in.format == s->out.format)
return ff_filter_frame(outlink, VAR_1);
switch (s->in.format) {
case ALTERNATING_LR:
case ALTERNATING_RL:
if (!s->prev) {
s->prev = VAR_1;
return 0;
}
ileft = s->prev;
iright = VAR_1;
if (s->in.format == ALTERNATING_RL)
FFSWAP(AVFrame *, ileft, iright);
break;
default:
ileft = iright = VAR_1;
};
if ((s->out.format == ALTERNATING_LR ||
s->out.format == ALTERNATING_RL) &&
(s->in.format == SIDE_BY_SIDE_LR ||
s->in.format == SIDE_BY_SIDE_RL ||
s->in.format == SIDE_BY_SIDE_2_LR ||
s->in.format == SIDE_BY_SIDE_2_RL ||
s->in.format == ABOVE_BELOW_LR ||
s->in.format == ABOVE_BELOW_RL ||
s->in.format == ABOVE_BELOW_2_LR ||
s->in.format == ABOVE_BELOW_2_RL)) {
oright = av_frame_clone(VAR_1);
oleft = av_frame_clone(VAR_1);
if (!oright || !oleft) {
av_frame_free(&oright);
av_frame_free(&oleft);
av_frame_free(&s->prev);
av_frame_free(&VAR_1);
return AVERROR(ENOMEM);
}
} else if ((s->out.format == MONO_L ||
s->out.format == MONO_R) &&
(s->in.format == SIDE_BY_SIDE_LR ||
s->in.format == SIDE_BY_SIDE_RL ||
s->in.format == SIDE_BY_SIDE_2_LR ||
s->in.format == SIDE_BY_SIDE_2_RL ||
s->in.format == ABOVE_BELOW_LR ||
s->in.format == ABOVE_BELOW_RL ||
s->in.format == ABOVE_BELOW_2_LR ||
s->in.format == ABOVE_BELOW_2_RL)) {
out = oleft = oright = av_frame_clone(VAR_1);
if (!out) {
av_frame_free(&s->prev);
av_frame_free(&VAR_1);
return AVERROR(ENOMEM);
}
} else {
out = oleft = oright = ff_get_video_buffer(outlink, outlink->w, outlink->h);
if (!out) {
av_frame_free(&s->prev);
av_frame_free(&VAR_1);
return AVERROR(ENOMEM);
}
av_frame_copy_props(out, VAR_1);
if (s->out.format == ALTERNATING_LR ||
s->out.format == ALTERNATING_RL) {
oright = ff_get_video_buffer(outlink, outlink->w, outlink->h);
if (!oright) {
av_frame_free(&oleft);
av_frame_free(&s->prev);
av_frame_free(&VAR_1);
return AVERROR(ENOMEM);
}
av_frame_copy_props(oright, VAR_1);
}
}
for (VAR_4 = 0; VAR_4 < 4; VAR_4++) {
int VAR_5 = VAR_4 == 1 || VAR_4 == 2 ? s->VAR_5 : 0;
int VAR_6 = VAR_4 == 1 || VAR_4 == 2 ? s->VAR_6 : 0;
s->in_off_left[VAR_4] = (FF_CEIL_RSHIFT(s->in.row_left, VAR_6) + s->in.off_lstep) * ileft->linesize[VAR_4] + FF_CEIL_RSHIFT(s->in.off_left * s->pixstep[VAR_4], VAR_5);
s->in_off_right[VAR_4] = (FF_CEIL_RSHIFT(s->in.row_right, VAR_6) + s->in.off_rstep) * iright->linesize[VAR_4] + FF_CEIL_RSHIFT(s->in.off_right * s->pixstep[VAR_4], VAR_5);
VAR_2[VAR_4] = (FF_CEIL_RSHIFT(s->out.row_left, VAR_6) + s->out.off_lstep) * oleft->linesize[VAR_4] + FF_CEIL_RSHIFT(s->out.off_left * s->pixstep[VAR_4], VAR_5);
VAR_3[VAR_4] = (FF_CEIL_RSHIFT(s->out.row_right, VAR_6) + s->out.off_rstep) * oright->linesize[VAR_4] + FF_CEIL_RSHIFT(s->out.off_right * s->pixstep[VAR_4], VAR_5);
}
switch (s->out.format) {
case ALTERNATING_LR:
case ALTERNATING_RL:
switch (s->in.format) {
case ABOVE_BELOW_LR:
case ABOVE_BELOW_RL:
case ABOVE_BELOW_2_LR:
case ABOVE_BELOW_2_RL:
case SIDE_BY_SIDE_LR:
case SIDE_BY_SIDE_RL:
case SIDE_BY_SIDE_2_LR:
case SIDE_BY_SIDE_2_RL:
oleft->width = outlink->w;
oright->width = outlink->w;
oleft->height = outlink->h;
oright->height = outlink->h;
for (VAR_4 = 0; VAR_4 < s->nb_planes; VAR_4++) {
oleft->data[VAR_4] += s->in_off_left[VAR_4];
oright->data[VAR_4] += s->in_off_right[VAR_4];
}
break;
default:
goto copy;
break;
}
break;
case HDMI:
for (VAR_4 = 0; VAR_4 < s->nb_planes; VAR_4++) {
int j, h = s->height >> ((VAR_4 == 1 || VAR_4 == 2) ? s->VAR_6 : 0);
int b = (s->blanks) >> ((VAR_4 == 1 || VAR_4 == 2) ? s->VAR_6 : 0);
for (j = h; j < h + b; j++)
memset(oleft->data[VAR_4] + j * s->linesize[VAR_4], 0, s->linesize[VAR_4]);
}
case SIDE_BY_SIDE_LR:
case SIDE_BY_SIDE_RL:
case SIDE_BY_SIDE_2_LR:
case SIDE_BY_SIDE_2_RL:
case ABOVE_BELOW_LR:
case ABOVE_BELOW_RL:
case ABOVE_BELOW_2_LR:
case ABOVE_BELOW_2_RL:
case INTERLEAVE_ROWS_LR:
case INTERLEAVE_ROWS_RL:
copy:
for (VAR_4 = 0; VAR_4 < s->nb_planes; VAR_4++) {
av_image_copy_plane(oleft->data[VAR_4] + VAR_2[VAR_4],
oleft->linesize[VAR_4] * s->out.row_step,
ileft->data[VAR_4] + s->in_off_left[VAR_4],
ileft->linesize[VAR_4] * s->in.row_step,
s->linesize[VAR_4], s->pheight[VAR_4]);
av_image_copy_plane(oright->data[VAR_4] + VAR_3[VAR_4],
oright->linesize[VAR_4] * s->out.row_step,
iright->data[VAR_4] + s->in_off_right[VAR_4],
iright->linesize[VAR_4] * s->in.row_step,
s->linesize[VAR_4], s->pheight[VAR_4]);
}
break;
case MONO_L:
iright = ileft;
case MONO_R:
switch (s->in.format) {
case ABOVE_BELOW_LR:
case ABOVE_BELOW_RL:
case ABOVE_BELOW_2_LR:
case ABOVE_BELOW_2_RL:
case SIDE_BY_SIDE_LR:
case SIDE_BY_SIDE_RL:
case SIDE_BY_SIDE_2_LR:
case SIDE_BY_SIDE_2_RL:
out->width = outlink->w;
out->height = outlink->h;
for (VAR_4 = 0; VAR_4 < s->nb_planes; VAR_4++) {
out->data[VAR_4] += s->in_off_left[VAR_4];
}
break;
default:
for (VAR_4 = 0; VAR_4 < s->nb_planes; VAR_4++) {
av_image_copy_plane(out->data[VAR_4], out->linesize[VAR_4],
iright->data[VAR_4] + s->in_off_left[VAR_4],
iright->linesize[VAR_4] * s->in.row_step,
s->linesize[VAR_4], s->pheight[VAR_4]);
}
break;
}
break;
case ANAGLYPH_RB_GRAY:
case ANAGLYPH_RG_GRAY:
case ANAGLYPH_RC_GRAY:
case ANAGLYPH_RC_HALF:
case ANAGLYPH_RC_COLOR:
case ANAGLYPH_RC_DUBOIS:
case ANAGLYPH_GM_GRAY:
case ANAGLYPH_GM_HALF:
case ANAGLYPH_GM_COLOR:
case ANAGLYPH_GM_DUBOIS:
case ANAGLYPH_YB_GRAY:
case ANAGLYPH_YB_HALF:
case ANAGLYPH_YB_COLOR:
case ANAGLYPH_YB_DUBOIS: {
ThreadData td;
td.ileft = ileft; td.iright = iright; td.out = out;
ctx->internal->execute(ctx, filter_slice, &td, NULL,
FFMIN(s->out.height, ctx->graph->nb_threads));
break;
}
case CHECKERBOARD_RL:
case CHECKERBOARD_LR:
for (VAR_4 = 0; VAR_4 < s->nb_planes; VAR_4++) {
int x, y;
for (y = 0; y < s->pheight[VAR_4]; y++) {
uint8_t *dst = out->data[VAR_4] + out->linesize[VAR_4] * y;
uint8_t *left = ileft->data[VAR_4] + ileft->linesize[VAR_4] * y + s->in_off_left[VAR_4];
uint8_t *right = iright->data[VAR_4] + iright->linesize[VAR_4] * y + s->in_off_right[VAR_4];
int p, b;
if (s->out.format == CHECKERBOARD_RL)
FFSWAP(uint8_t*, left, right);
switch (s->pixstep[VAR_4]) {
case 1:
for (x = 0, b = 0, p = 0; x < s->linesize[VAR_4] * 2; x+=2, p++, b++) {
dst[x ] = (b&1) == (y&1) ? left[p] : right[p];
dst[x+1] = (b&1) != (y&1) ? left[p] : right[p];
}
break;
case 2:
for (x = 0, b = 0, p = 0; x < s->linesize[VAR_4] * 2; x+=4, p+=2, b++) {
AV_WN16(&dst[x ], (b&1) == (y&1) ? AV_RN16(&left[p]) : AV_RN16(&right[p]));
AV_WN16(&dst[x+2], (b&1) != (y&1) ? AV_RN16(&left[p]) : AV_RN16(&right[p]));
}
break;
case 3:
for (x = 0, b = 0, p = 0; x < s->linesize[VAR_4] * 2; x+=6, p+=3, b++) {
AV_WB24(&dst[x ], (b&1) == (y&1) ? AV_RB24(&left[p]) : AV_RB24(&right[p]));
AV_WB24(&dst[x+3], (b&1) != (y&1) ? AV_RB24(&left[p]) : AV_RB24(&right[p]));
}
break;
case 4:
for (x = 0, b = 0, p = 0; x < s->linesize[VAR_4] * 2; x+=8, p+=4, b++) {
AV_WN32(&dst[x ], (b&1) == (y&1) ? AV_RN32(&left[p]) : AV_RN32(&right[p]));
AV_WN32(&dst[x+4], (b&1) != (y&1) ? AV_RN32(&left[p]) : AV_RN32(&right[p]));
}
break;
case 6:
for (x = 0, b = 0, p = 0; x < s->linesize[VAR_4] * 2; x+=12, p+=6, b++) {
AV_WB48(&dst[x ], (b&1) == (y&1) ? AV_RB48(&left[p]) : AV_RB48(&right[p]));
AV_WB48(&dst[x+6], (b&1) != (y&1) ? AV_RB48(&left[p]) : AV_RB48(&right[p]));
}
break;
case 8:
for (x = 0, b = 0, p = 0; x < s->linesize[VAR_4] * 2; x+=16, p+=8, b++) {
AV_WN64(&dst[x ], (b&1) == (y&1) ? AV_RN64(&left[p]) : AV_RN64(&right[p]));
AV_WN64(&dst[x+8], (b&1) != (y&1) ? AV_RN64(&left[p]) : AV_RN64(&right[p]));
}
break;
}
}
}
break;
case INTERLEAVE_COLS_LR:
case INTERLEAVE_COLS_RL:
for (VAR_4 = 0; VAR_4 < s->nb_planes; VAR_4++) {
int x, y;
for (y = 0; y < s->pheight[VAR_4]; y++) {
uint8_t *dst = out->data[VAR_4] + out->linesize[VAR_4] * y;
uint8_t *left = ileft->data[VAR_4] + ileft->linesize[VAR_4] * y * s->in.row_step + s->in_off_left[VAR_4];
uint8_t *right = iright->data[VAR_4] + iright->linesize[VAR_4] * y * s->in.row_step + s->in_off_right[VAR_4];
int p, b;
if (s->out.format == INTERLEAVE_COLS_LR)
FFSWAP(uint8_t*, left, right);
switch (s->pixstep[VAR_4]) {
case 1:
for (x = 0, b = 0, p = 0; x < s->linesize[VAR_4] * 2; x+=2, p++, b++) {
dst[x ] = b&1 ? left[p] : right[p];
dst[x+1] = !(b&1) ? left[p] : right[p];
}
break;
case 2:
for (x = 0, b = 0, p = 0; x < s->linesize[VAR_4] * 2; x+=4, p+=2, b++) {
AV_WN16(&dst[x ], b&1 ? AV_RN16(&left[p]) : AV_RN16(&right[p]));
AV_WN16(&dst[x+2], !(b&1) ? AV_RN16(&left[p]) : AV_RN16(&right[p]));
}
break;
case 3:
for (x = 0, b = 0, p = 0; x < s->linesize[VAR_4] * 2; x+=6, p+=3, b++) {
AV_WB24(&dst[x ], b&1 ? AV_RB24(&left[p]) : AV_RB24(&right[p]));
AV_WB24(&dst[x+3], !(b&1) ? AV_RB24(&left[p]) : AV_RB24(&right[p]));
}
break;
case 4:
for (x = 0, b = 0, p = 0; x < s->linesize[VAR_4] * 2; x+=8, p+=4, b++) {
AV_WN32(&dst[x ], b&1 ? AV_RN32(&left[p]) : AV_RN32(&right[p]));
AV_WN32(&dst[x+4], !(b&1) ? AV_RN32(&left[p]) : AV_RN32(&right[p]));
}
break;
case 6:
for (x = 0, b = 0, p = 0; x < s->linesize[VAR_4] * 2; x+=12, p+=6, b++) {
AV_WB48(&dst[x ], b&1 ? AV_RB48(&left[p]) : AV_RB48(&right[p]));
AV_WB48(&dst[x+6], !(b&1) ? AV_RB48(&left[p]) : AV_RB48(&right[p]));
}
break;
case 8:
for (x = 0, b = 0, p = 0; x < s->linesize[VAR_4] * 2; x+=16, p+=8, b++) {
AV_WN64(&dst[x ], b&1 ? AV_RN64(&left[p]) : AV_RN64(&right[p]));
AV_WN64(&dst[x+8], !(b&1) ? AV_RN64(&left[p]) : AV_RN64(&right[p]));
}
break;
}
}
}
break;
default:
av_assert0(0);
}
av_frame_free(&VAR_1);
av_frame_free(&s->prev);
if (oright != oleft) {
if (s->out.format == ALTERNATING_LR)
FFSWAP(AVFrame *, oleft, oright);
oright->pts = outlink->frame_count * s->ts_unit;
ff_filter_frame(outlink, oright);
out = oleft;
oleft->pts = outlink->frame_count * s->ts_unit;
} else if (s->in.format == ALTERNATING_LR ||
s->in.format == ALTERNATING_RL) {
out->pts = outlink->frame_count * s->ts_unit;
}
return ff_filter_frame(outlink, out);
}
| [
"static int FUNC_0(AVFilterLink *VAR_0, AVFrame *VAR_1)\n{",
"AVFilterContext *ctx = VAR_0->dst;",
"Stereo3DContext *s = ctx->priv;",
"AVFilterLink *outlink = ctx->outputs[0];",
"AVFrame *out, *oleft, *oright, *ileft, *iright;",
"int VAR_2[4], VAR_3[4];",
"int VAR_4;",
"if (s->in.format == s->out.format)\nreturn ff_filter_frame(outlink, VAR_1);",
"switch (s->in.format) {",
"case ALTERNATING_LR:\ncase ALTERNATING_RL:\nif (!s->prev) {",
"s->prev = VAR_1;",
"return 0;",
"}",
"ileft = s->prev;",
"iright = VAR_1;",
"if (s->in.format == ALTERNATING_RL)\nFFSWAP(AVFrame *, ileft, iright);",
"break;",
"default:\nileft = iright = VAR_1;",
"};",
"if ((s->out.format == ALTERNATING_LR ||\ns->out.format == ALTERNATING_RL) &&\n(s->in.format == SIDE_BY_SIDE_LR ||\ns->in.format == SIDE_BY_SIDE_RL ||\ns->in.format == SIDE_BY_SIDE_2_LR ||\ns->in.format == SIDE_BY_SIDE_2_RL ||\ns->in.format == ABOVE_BELOW_LR ||\ns->in.format == ABOVE_BELOW_RL ||\ns->in.format == ABOVE_BELOW_2_LR ||\ns->in.format == ABOVE_BELOW_2_RL)) {",
"oright = av_frame_clone(VAR_1);",
"oleft = av_frame_clone(VAR_1);",
"if (!oright || !oleft) {",
"av_frame_free(&oright);",
"av_frame_free(&oleft);",
"av_frame_free(&s->prev);",
"av_frame_free(&VAR_1);",
"return AVERROR(ENOMEM);",
"}",
"} else if ((s->out.format == MONO_L ||",
"s->out.format == MONO_R) &&\n(s->in.format == SIDE_BY_SIDE_LR ||\ns->in.format == SIDE_BY_SIDE_RL ||\ns->in.format == SIDE_BY_SIDE_2_LR ||\ns->in.format == SIDE_BY_SIDE_2_RL ||\ns->in.format == ABOVE_BELOW_LR ||\ns->in.format == ABOVE_BELOW_RL ||\ns->in.format == ABOVE_BELOW_2_LR ||\ns->in.format == ABOVE_BELOW_2_RL)) {",
"out = oleft = oright = av_frame_clone(VAR_1);",
"if (!out) {",
"av_frame_free(&s->prev);",
"av_frame_free(&VAR_1);",
"return AVERROR(ENOMEM);",
"}",
"} else {",
"out = oleft = oright = ff_get_video_buffer(outlink, outlink->w, outlink->h);",
"if (!out) {",
"av_frame_free(&s->prev);",
"av_frame_free(&VAR_1);",
"return AVERROR(ENOMEM);",
"}",
"av_frame_copy_props(out, VAR_1);",
"if (s->out.format == ALTERNATING_LR ||\ns->out.format == ALTERNATING_RL) {",
"oright = ff_get_video_buffer(outlink, outlink->w, outlink->h);",
"if (!oright) {",
"av_frame_free(&oleft);",
"av_frame_free(&s->prev);",
"av_frame_free(&VAR_1);",
"return AVERROR(ENOMEM);",
"}",
"av_frame_copy_props(oright, VAR_1);",
"}",
"}",
"for (VAR_4 = 0; VAR_4 < 4; VAR_4++) {",
"int VAR_5 = VAR_4 == 1 || VAR_4 == 2 ? s->VAR_5 : 0;",
"int VAR_6 = VAR_4 == 1 || VAR_4 == 2 ? s->VAR_6 : 0;",
"s->in_off_left[VAR_4] = (FF_CEIL_RSHIFT(s->in.row_left, VAR_6) + s->in.off_lstep) * ileft->linesize[VAR_4] + FF_CEIL_RSHIFT(s->in.off_left * s->pixstep[VAR_4], VAR_5);",
"s->in_off_right[VAR_4] = (FF_CEIL_RSHIFT(s->in.row_right, VAR_6) + s->in.off_rstep) * iright->linesize[VAR_4] + FF_CEIL_RSHIFT(s->in.off_right * s->pixstep[VAR_4], VAR_5);",
"VAR_2[VAR_4] = (FF_CEIL_RSHIFT(s->out.row_left, VAR_6) + s->out.off_lstep) * oleft->linesize[VAR_4] + FF_CEIL_RSHIFT(s->out.off_left * s->pixstep[VAR_4], VAR_5);",
"VAR_3[VAR_4] = (FF_CEIL_RSHIFT(s->out.row_right, VAR_6) + s->out.off_rstep) * oright->linesize[VAR_4] + FF_CEIL_RSHIFT(s->out.off_right * s->pixstep[VAR_4], VAR_5);",
"}",
"switch (s->out.format) {",
"case ALTERNATING_LR:\ncase ALTERNATING_RL:\nswitch (s->in.format) {",
"case ABOVE_BELOW_LR:\ncase ABOVE_BELOW_RL:\ncase ABOVE_BELOW_2_LR:\ncase ABOVE_BELOW_2_RL:\ncase SIDE_BY_SIDE_LR:\ncase SIDE_BY_SIDE_RL:\ncase SIDE_BY_SIDE_2_LR:\ncase SIDE_BY_SIDE_2_RL:\noleft->width = outlink->w;",
"oright->width = outlink->w;",
"oleft->height = outlink->h;",
"oright->height = outlink->h;",
"for (VAR_4 = 0; VAR_4 < s->nb_planes; VAR_4++) {",
"oleft->data[VAR_4] += s->in_off_left[VAR_4];",
"oright->data[VAR_4] += s->in_off_right[VAR_4];",
"}",
"break;",
"default:\ngoto copy;",
"break;",
"}",
"break;",
"case HDMI:\nfor (VAR_4 = 0; VAR_4 < s->nb_planes; VAR_4++) {",
"int j, h = s->height >> ((VAR_4 == 1 || VAR_4 == 2) ? s->VAR_6 : 0);",
"int b = (s->blanks) >> ((VAR_4 == 1 || VAR_4 == 2) ? s->VAR_6 : 0);",
"for (j = h; j < h + b; j++)",
"memset(oleft->data[VAR_4] + j * s->linesize[VAR_4], 0, s->linesize[VAR_4]);",
"}",
"case SIDE_BY_SIDE_LR:\ncase SIDE_BY_SIDE_RL:\ncase SIDE_BY_SIDE_2_LR:\ncase SIDE_BY_SIDE_2_RL:\ncase ABOVE_BELOW_LR:\ncase ABOVE_BELOW_RL:\ncase ABOVE_BELOW_2_LR:\ncase ABOVE_BELOW_2_RL:\ncase INTERLEAVE_ROWS_LR:\ncase INTERLEAVE_ROWS_RL:\ncopy:\nfor (VAR_4 = 0; VAR_4 < s->nb_planes; VAR_4++) {",
"av_image_copy_plane(oleft->data[VAR_4] + VAR_2[VAR_4],\noleft->linesize[VAR_4] * s->out.row_step,\nileft->data[VAR_4] + s->in_off_left[VAR_4],\nileft->linesize[VAR_4] * s->in.row_step,\ns->linesize[VAR_4], s->pheight[VAR_4]);",
"av_image_copy_plane(oright->data[VAR_4] + VAR_3[VAR_4],\noright->linesize[VAR_4] * s->out.row_step,\niright->data[VAR_4] + s->in_off_right[VAR_4],\niright->linesize[VAR_4] * s->in.row_step,\ns->linesize[VAR_4], s->pheight[VAR_4]);",
"}",
"break;",
"case MONO_L:\niright = ileft;",
"case MONO_R:\nswitch (s->in.format) {",
"case ABOVE_BELOW_LR:\ncase ABOVE_BELOW_RL:\ncase ABOVE_BELOW_2_LR:\ncase ABOVE_BELOW_2_RL:\ncase SIDE_BY_SIDE_LR:\ncase SIDE_BY_SIDE_RL:\ncase SIDE_BY_SIDE_2_LR:\ncase SIDE_BY_SIDE_2_RL:\nout->width = outlink->w;",
"out->height = outlink->h;",
"for (VAR_4 = 0; VAR_4 < s->nb_planes; VAR_4++) {",
"out->data[VAR_4] += s->in_off_left[VAR_4];",
"}",
"break;",
"default:\nfor (VAR_4 = 0; VAR_4 < s->nb_planes; VAR_4++) {",
"av_image_copy_plane(out->data[VAR_4], out->linesize[VAR_4],\niright->data[VAR_4] + s->in_off_left[VAR_4],\niright->linesize[VAR_4] * s->in.row_step,\ns->linesize[VAR_4], s->pheight[VAR_4]);",
"}",
"break;",
"}",
"break;",
"case ANAGLYPH_RB_GRAY:\ncase ANAGLYPH_RG_GRAY:\ncase ANAGLYPH_RC_GRAY:\ncase ANAGLYPH_RC_HALF:\ncase ANAGLYPH_RC_COLOR:\ncase ANAGLYPH_RC_DUBOIS:\ncase ANAGLYPH_GM_GRAY:\ncase ANAGLYPH_GM_HALF:\ncase ANAGLYPH_GM_COLOR:\ncase ANAGLYPH_GM_DUBOIS:\ncase ANAGLYPH_YB_GRAY:\ncase ANAGLYPH_YB_HALF:\ncase ANAGLYPH_YB_COLOR:\ncase ANAGLYPH_YB_DUBOIS: {",
"ThreadData td;",
"td.ileft = ileft; td.iright = iright; td.out = out;",
"ctx->internal->execute(ctx, filter_slice, &td, NULL,\nFFMIN(s->out.height, ctx->graph->nb_threads));",
"break;",
"}",
"case CHECKERBOARD_RL:\ncase CHECKERBOARD_LR:\nfor (VAR_4 = 0; VAR_4 < s->nb_planes; VAR_4++) {",
"int x, y;",
"for (y = 0; y < s->pheight[VAR_4]; y++) {",
"uint8_t *dst = out->data[VAR_4] + out->linesize[VAR_4] * y;",
"uint8_t *left = ileft->data[VAR_4] + ileft->linesize[VAR_4] * y + s->in_off_left[VAR_4];",
"uint8_t *right = iright->data[VAR_4] + iright->linesize[VAR_4] * y + s->in_off_right[VAR_4];",
"int p, b;",
"if (s->out.format == CHECKERBOARD_RL)\nFFSWAP(uint8_t*, left, right);",
"switch (s->pixstep[VAR_4]) {",
"case 1:\nfor (x = 0, b = 0, p = 0; x < s->linesize[VAR_4] * 2; x+=2, p++, b++) {",
"dst[x ] = (b&1) == (y&1) ? left[p] : right[p];",
"dst[x+1] = (b&1) != (y&1) ? left[p] : right[p];",
"}",
"break;",
"case 2:\nfor (x = 0, b = 0, p = 0; x < s->linesize[VAR_4] * 2; x+=4, p+=2, b++) {",
"AV_WN16(&dst[x ], (b&1) == (y&1) ? AV_RN16(&left[p]) : AV_RN16(&right[p]));",
"AV_WN16(&dst[x+2], (b&1) != (y&1) ? AV_RN16(&left[p]) : AV_RN16(&right[p]));",
"}",
"break;",
"case 3:\nfor (x = 0, b = 0, p = 0; x < s->linesize[VAR_4] * 2; x+=6, p+=3, b++) {",
"AV_WB24(&dst[x ], (b&1) == (y&1) ? AV_RB24(&left[p]) : AV_RB24(&right[p]));",
"AV_WB24(&dst[x+3], (b&1) != (y&1) ? AV_RB24(&left[p]) : AV_RB24(&right[p]));",
"}",
"break;",
"case 4:\nfor (x = 0, b = 0, p = 0; x < s->linesize[VAR_4] * 2; x+=8, p+=4, b++) {",
"AV_WN32(&dst[x ], (b&1) == (y&1) ? AV_RN32(&left[p]) : AV_RN32(&right[p]));",
"AV_WN32(&dst[x+4], (b&1) != (y&1) ? AV_RN32(&left[p]) : AV_RN32(&right[p]));",
"}",
"break;",
"case 6:\nfor (x = 0, b = 0, p = 0; x < s->linesize[VAR_4] * 2; x+=12, p+=6, b++) {",
"AV_WB48(&dst[x ], (b&1) == (y&1) ? AV_RB48(&left[p]) : AV_RB48(&right[p]));",
"AV_WB48(&dst[x+6], (b&1) != (y&1) ? AV_RB48(&left[p]) : AV_RB48(&right[p]));",
"}",
"break;",
"case 8:\nfor (x = 0, b = 0, p = 0; x < s->linesize[VAR_4] * 2; x+=16, p+=8, b++) {",
"AV_WN64(&dst[x ], (b&1) == (y&1) ? AV_RN64(&left[p]) : AV_RN64(&right[p]));",
"AV_WN64(&dst[x+8], (b&1) != (y&1) ? AV_RN64(&left[p]) : AV_RN64(&right[p]));",
"}",
"break;",
"}",
"}",
"}",
"break;",
"case INTERLEAVE_COLS_LR:\ncase INTERLEAVE_COLS_RL:\nfor (VAR_4 = 0; VAR_4 < s->nb_planes; VAR_4++) {",
"int x, y;",
"for (y = 0; y < s->pheight[VAR_4]; y++) {",
"uint8_t *dst = out->data[VAR_4] + out->linesize[VAR_4] * y;",
"uint8_t *left = ileft->data[VAR_4] + ileft->linesize[VAR_4] * y * s->in.row_step + s->in_off_left[VAR_4];",
"uint8_t *right = iright->data[VAR_4] + iright->linesize[VAR_4] * y * s->in.row_step + s->in_off_right[VAR_4];",
"int p, b;",
"if (s->out.format == INTERLEAVE_COLS_LR)\nFFSWAP(uint8_t*, left, right);",
"switch (s->pixstep[VAR_4]) {",
"case 1:\nfor (x = 0, b = 0, p = 0; x < s->linesize[VAR_4] * 2; x+=2, p++, b++) {",
"dst[x ] = b&1 ? left[p] : right[p];",
"dst[x+1] = !(b&1) ? left[p] : right[p];",
"}",
"break;",
"case 2:\nfor (x = 0, b = 0, p = 0; x < s->linesize[VAR_4] * 2; x+=4, p+=2, b++) {",
"AV_WN16(&dst[x ], b&1 ? AV_RN16(&left[p]) : AV_RN16(&right[p]));",
"AV_WN16(&dst[x+2], !(b&1) ? AV_RN16(&left[p]) : AV_RN16(&right[p]));",
"}",
"break;",
"case 3:\nfor (x = 0, b = 0, p = 0; x < s->linesize[VAR_4] * 2; x+=6, p+=3, b++) {",
"AV_WB24(&dst[x ], b&1 ? AV_RB24(&left[p]) : AV_RB24(&right[p]));",
"AV_WB24(&dst[x+3], !(b&1) ? AV_RB24(&left[p]) : AV_RB24(&right[p]));",
"}",
"break;",
"case 4:\nfor (x = 0, b = 0, p = 0; x < s->linesize[VAR_4] * 2; x+=8, p+=4, b++) {",
"AV_WN32(&dst[x ], b&1 ? AV_RN32(&left[p]) : AV_RN32(&right[p]));",
"AV_WN32(&dst[x+4], !(b&1) ? AV_RN32(&left[p]) : AV_RN32(&right[p]));",
"}",
"break;",
"case 6:\nfor (x = 0, b = 0, p = 0; x < s->linesize[VAR_4] * 2; x+=12, p+=6, b++) {",
"AV_WB48(&dst[x ], b&1 ? AV_RB48(&left[p]) : AV_RB48(&right[p]));",
"AV_WB48(&dst[x+6], !(b&1) ? AV_RB48(&left[p]) : AV_RB48(&right[p]));",
"}",
"break;",
"case 8:\nfor (x = 0, b = 0, p = 0; x < s->linesize[VAR_4] * 2; x+=16, p+=8, b++) {",
"AV_WN64(&dst[x ], b&1 ? AV_RN64(&left[p]) : AV_RN64(&right[p]));",
"AV_WN64(&dst[x+8], !(b&1) ? AV_RN64(&left[p]) : AV_RN64(&right[p]));",
"}",
"break;",
"}",
"}",
"}",
"break;",
"default:\nav_assert0(0);",
"}",
"av_frame_free(&VAR_1);",
"av_frame_free(&s->prev);",
"if (oright != oleft) {",
"if (s->out.format == ALTERNATING_LR)\nFFSWAP(AVFrame *, oleft, oright);",
"oright->pts = outlink->frame_count * s->ts_unit;",
"ff_filter_frame(outlink, oright);",
"out = oleft;",
"oleft->pts = outlink->frame_count * s->ts_unit;",
"} else if (s->in.format == ALTERNATING_LR ||",
"s->in.format == ALTERNATING_RL) {",
"out->pts = outlink->frame_count * s->ts_unit;",
"}",
"return ff_filter_frame(outlink, out);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
25
],
[
27,
29,
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43,
45
],
[
47
],
[
49,
51
],
[
53
],
[
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
],
[
145,
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
189
],
[
191,
193,
195
],
[
197,
199,
201,
203,
205,
207,
209,
211,
213
],
[
215
],
[
217
],
[
219
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233,
235
],
[
237
],
[
239
],
[
241
],
[
243,
245
],
[
247
],
[
249
],
[
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
],
[
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
],
[
397
],
[
399,
401
],
[
403
],
[
405
],
[
407,
409,
411
],
[
413
],
[
417
],
[
419
],
[
421
],
[
423
],
[
425
],
[
429,
431
],
[
433
],
[
435,
437
],
[
439
],
[
441
],
[
443
],
[
445
],
[
447,
449
],
[
451
],
[
453
],
[
455
],
[
457
],
[
459,
461
],
[
463
],
[
465
],
[
467
],
[
469
],
[
471,
473
],
[
475
],
[
477
],
[
479
],
[
481
],
[
483,
485
],
[
487
],
[
489
],
[
491
],
[
493
],
[
495,
497
],
[
499
],
[
501
],
[
503
],
[
505
],
[
507
],
[
509
],
[
511
],
[
513
],
[
515,
517,
519
],
[
521
],
[
525
],
[
527
],
[
529
],
[
531
],
[
533
],
[
537,
539
],
[
543
],
[
545,
547
],
[
549
],
[
551
],
[
553
],
[
555
],
[
557,
559
],
[
561
],
[
563
],
[
565
],
[
567
],
[
569,
571
],
[
573
],
[
575
],
[
577
],
[
579
],
[
581,
583
],
[
585
],
[
587
],
[
589
],
[
591
],
[
593,
595
],
[
597
],
[
599
],
[
601
],
[
603
],
[
605,
607
],
[
609
],
[
611
],
[
613
],
[
615
],
[
617
],
[
619
],
[
621
],
[
623
],
[
625,
627
],
[
629
],
[
633
],
[
635
],
[
637
],
[
639,
641
],
[
643
],
[
645
],
[
647
],
[
649
],
[
651
],
[
653
],
[
655
],
[
657
],
[
659
],
[
661
]
] |
21,233 | static int unpack_parse_unit(DiracParseUnit *pu, DiracParseContext *pc,
int offset)
{
int8_t *start;
if (offset < 0 || pc->index - 13 < offset)
return 0;
start = pc->buffer + offset;
pu->pu_type = start[4];
pu->next_pu_offset = AV_RB32(start + 5);
pu->prev_pu_offset = AV_RB32(start + 9);
if (pu->pu_type == 0x10 && pu->next_pu_offset == 0)
pu->next_pu_offset = 13;
if (pu->next_pu_offset && pu->next_pu_offset < 13) {
av_log(NULL, AV_LOG_ERROR, "next_pu_offset %d is invalid\n", pu->next_pu_offset);
return 0;
}
if (pu->prev_pu_offset && pu->prev_pu_offset < 13) {
av_log(NULL, AV_LOG_ERROR, "prev_pu_offset %d is invalid\n", pu->prev_pu_offset);
return 0;
}
return 1;
}
| false | FFmpeg | a849ebb54e187a70eabc69cbd1b1a342e6587ec3 | static int unpack_parse_unit(DiracParseUnit *pu, DiracParseContext *pc,
int offset)
{
int8_t *start;
if (offset < 0 || pc->index - 13 < offset)
return 0;
start = pc->buffer + offset;
pu->pu_type = start[4];
pu->next_pu_offset = AV_RB32(start + 5);
pu->prev_pu_offset = AV_RB32(start + 9);
if (pu->pu_type == 0x10 && pu->next_pu_offset == 0)
pu->next_pu_offset = 13;
if (pu->next_pu_offset && pu->next_pu_offset < 13) {
av_log(NULL, AV_LOG_ERROR, "next_pu_offset %d is invalid\n", pu->next_pu_offset);
return 0;
}
if (pu->prev_pu_offset && pu->prev_pu_offset < 13) {
av_log(NULL, AV_LOG_ERROR, "prev_pu_offset %d is invalid\n", pu->prev_pu_offset);
return 0;
}
return 1;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(DiracParseUnit *VAR_0, DiracParseContext *VAR_1,
int VAR_2)
{
int8_t *start;
if (VAR_2 < 0 || VAR_1->index - 13 < VAR_2)
return 0;
start = VAR_1->buffer + VAR_2;
VAR_0->pu_type = start[4];
VAR_0->next_pu_offset = AV_RB32(start + 5);
VAR_0->prev_pu_offset = AV_RB32(start + 9);
if (VAR_0->pu_type == 0x10 && VAR_0->next_pu_offset == 0)
VAR_0->next_pu_offset = 13;
if (VAR_0->next_pu_offset && VAR_0->next_pu_offset < 13) {
av_log(NULL, AV_LOG_ERROR, "next_pu_offset %d is invalid\n", VAR_0->next_pu_offset);
return 0;
}
if (VAR_0->prev_pu_offset && VAR_0->prev_pu_offset < 13) {
av_log(NULL, AV_LOG_ERROR, "prev_pu_offset %d is invalid\n", VAR_0->prev_pu_offset);
return 0;
}
return 1;
}
| [
"static int FUNC_0(DiracParseUnit *VAR_0, DiracParseContext *VAR_1,\nint VAR_2)\n{",
"int8_t *start;",
"if (VAR_2 < 0 || VAR_1->index - 13 < VAR_2)\nreturn 0;",
"start = VAR_1->buffer + VAR_2;",
"VAR_0->pu_type = start[4];",
"VAR_0->next_pu_offset = AV_RB32(start + 5);",
"VAR_0->prev_pu_offset = AV_RB32(start + 9);",
"if (VAR_0->pu_type == 0x10 && VAR_0->next_pu_offset == 0)\nVAR_0->next_pu_offset = 13;",
"if (VAR_0->next_pu_offset && VAR_0->next_pu_offset < 13) {",
"av_log(NULL, AV_LOG_ERROR, \"next_pu_offset %d is invalid\\n\", VAR_0->next_pu_offset);",
"return 0;",
"}",
"if (VAR_0->prev_pu_offset && VAR_0->prev_pu_offset < 13) {",
"av_log(NULL, AV_LOG_ERROR, \"prev_pu_offset %d is invalid\\n\", VAR_0->prev_pu_offset);",
"return 0;",
"}",
"return 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
],
[
17
],
[
19
],
[
23
],
[
25
],
[
29,
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
]
] |
21,234 | static void quantize_all(DCAEncContext *c)
{
int sample, band, ch;
for (sample = 0; sample < SUBBAND_SAMPLES; sample++)
for (band = 0; band < 32; band++)
for (ch = 0; ch < c->fullband_channels; ch++)
c->quantized[sample][band][ch] = quantize_value(c->subband[sample][band][ch], c->quant[band][ch]);
}
| false | FFmpeg | a6191d098a03f94685ae4c072bfdf10afcd86223 | static void quantize_all(DCAEncContext *c)
{
int sample, band, ch;
for (sample = 0; sample < SUBBAND_SAMPLES; sample++)
for (band = 0; band < 32; band++)
for (ch = 0; ch < c->fullband_channels; ch++)
c->quantized[sample][band][ch] = quantize_value(c->subband[sample][band][ch], c->quant[band][ch]);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DCAEncContext *VAR_0)
{
int VAR_1, VAR_2, VAR_3;
for (VAR_1 = 0; VAR_1 < SUBBAND_SAMPLES; VAR_1++)
for (VAR_2 = 0; VAR_2 < 32; VAR_2++)
for (VAR_3 = 0; VAR_3 < VAR_0->fullband_channels; VAR_3++)
VAR_0->quantized[VAR_1][VAR_2][VAR_3] = quantize_value(VAR_0->subband[VAR_1][VAR_2][VAR_3], VAR_0->quant[VAR_2][VAR_3]);
}
| [
"static void FUNC_0(DCAEncContext *VAR_0)\n{",
"int VAR_1, VAR_2, VAR_3;",
"for (VAR_1 = 0; VAR_1 < SUBBAND_SAMPLES; VAR_1++)",
"for (VAR_2 = 0; VAR_2 < 32; VAR_2++)",
"for (VAR_3 = 0; VAR_3 < VAR_0->fullband_channels; VAR_3++)",
"VAR_0->quantized[VAR_1][VAR_2][VAR_3] = quantize_value(VAR_0->subband[VAR_1][VAR_2][VAR_3], VAR_0->quant[VAR_2][VAR_3]);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
21,235 | static int video_thread(void *arg)
{
VideoState *is = arg;
AVPacket pkt1, *pkt = &pkt1;
int len1, got_picture;
AVFrame *frame= avcodec_alloc_frame();
double pts;
for(;;) {
while (is->paused && !is->videoq.abort_request) {
SDL_Delay(10);
}
if (packet_queue_get(&is->videoq, pkt, 1) < 0)
break;
if(pkt->data == flush_pkt.data){
avcodec_flush_buffers(is->video_st->codec);
is->last_dts_for_fault_detection=
is->last_pts_for_fault_detection= INT64_MIN;
continue;
}
/* NOTE: ipts is the PTS of the _first_ picture beginning in
this packet, if any */
is->video_st->codec->reordered_opaque= pkt->pts;
len1 = avcodec_decode_video2(is->video_st->codec,
frame, &got_picture,
pkt);
if(pkt->dts != AV_NOPTS_VALUE){
is->faulty_dts += pkt->dts <= is->last_dts_for_fault_detection;
is->last_dts_for_fault_detection= pkt->dts;
}
if(frame->reordered_opaque != AV_NOPTS_VALUE){
is->faulty_pts += frame->reordered_opaque <= is->last_pts_for_fault_detection;
is->last_pts_for_fault_detection= frame->reordered_opaque;
}
if( ( decoder_reorder_pts==1
|| decoder_reorder_pts && is->faulty_pts<is->faulty_dts
|| pkt->dts == AV_NOPTS_VALUE)
&& frame->reordered_opaque != AV_NOPTS_VALUE)
pts= frame->reordered_opaque;
else if(pkt->dts != AV_NOPTS_VALUE)
pts= pkt->dts;
else
pts= 0;
pts *= av_q2d(is->video_st->time_base);
// if (len1 < 0)
// break;
if (got_picture) {
if (output_picture2(is, frame, pts) < 0)
goto the_end;
}
av_free_packet(pkt);
if (step)
if (cur_stream)
stream_pause(cur_stream);
}
the_end:
av_free(frame);
return 0;
}
| false | FFmpeg | 6c7d3ead79af2de091ff74cb2e29770882cbae99 | static int video_thread(void *arg)
{
VideoState *is = arg;
AVPacket pkt1, *pkt = &pkt1;
int len1, got_picture;
AVFrame *frame= avcodec_alloc_frame();
double pts;
for(;;) {
while (is->paused && !is->videoq.abort_request) {
SDL_Delay(10);
}
if (packet_queue_get(&is->videoq, pkt, 1) < 0)
break;
if(pkt->data == flush_pkt.data){
avcodec_flush_buffers(is->video_st->codec);
is->last_dts_for_fault_detection=
is->last_pts_for_fault_detection= INT64_MIN;
continue;
}
is->video_st->codec->reordered_opaque= pkt->pts;
len1 = avcodec_decode_video2(is->video_st->codec,
frame, &got_picture,
pkt);
if(pkt->dts != AV_NOPTS_VALUE){
is->faulty_dts += pkt->dts <= is->last_dts_for_fault_detection;
is->last_dts_for_fault_detection= pkt->dts;
}
if(frame->reordered_opaque != AV_NOPTS_VALUE){
is->faulty_pts += frame->reordered_opaque <= is->last_pts_for_fault_detection;
is->last_pts_for_fault_detection= frame->reordered_opaque;
}
if( ( decoder_reorder_pts==1
|| decoder_reorder_pts && is->faulty_pts<is->faulty_dts
|| pkt->dts == AV_NOPTS_VALUE)
&& frame->reordered_opaque != AV_NOPTS_VALUE)
pts= frame->reordered_opaque;
else if(pkt->dts != AV_NOPTS_VALUE)
pts= pkt->dts;
else
pts= 0;
pts *= av_q2d(is->video_st->time_base);
if (got_picture) {
if (output_picture2(is, frame, pts) < 0)
goto the_end;
}
av_free_packet(pkt);
if (step)
if (cur_stream)
stream_pause(cur_stream);
}
the_end:
av_free(frame);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(void *VAR_0)
{
VideoState *is = VAR_0;
AVPacket pkt1, *pkt = &pkt1;
int VAR_1, VAR_2;
AVFrame *frame= avcodec_alloc_frame();
double VAR_3;
for(;;) {
while (is->paused && !is->videoq.abort_request) {
SDL_Delay(10);
}
if (packet_queue_get(&is->videoq, pkt, 1) < 0)
break;
if(pkt->data == flush_pkt.data){
avcodec_flush_buffers(is->video_st->codec);
is->last_dts_for_fault_detection=
is->last_pts_for_fault_detection= INT64_MIN;
continue;
}
is->video_st->codec->reordered_opaque= pkt->VAR_3;
VAR_1 = avcodec_decode_video2(is->video_st->codec,
frame, &VAR_2,
pkt);
if(pkt->dts != AV_NOPTS_VALUE){
is->faulty_dts += pkt->dts <= is->last_dts_for_fault_detection;
is->last_dts_for_fault_detection= pkt->dts;
}
if(frame->reordered_opaque != AV_NOPTS_VALUE){
is->faulty_pts += frame->reordered_opaque <= is->last_pts_for_fault_detection;
is->last_pts_for_fault_detection= frame->reordered_opaque;
}
if( ( decoder_reorder_pts==1
|| decoder_reorder_pts && is->faulty_pts<is->faulty_dts
|| pkt->dts == AV_NOPTS_VALUE)
&& frame->reordered_opaque != AV_NOPTS_VALUE)
VAR_3= frame->reordered_opaque;
else if(pkt->dts != AV_NOPTS_VALUE)
VAR_3= pkt->dts;
else
VAR_3= 0;
VAR_3 *= av_q2d(is->video_st->time_base);
if (VAR_2) {
if (output_picture2(is, frame, VAR_3) < 0)
goto the_end;
}
av_free_packet(pkt);
if (step)
if (cur_stream)
stream_pause(cur_stream);
}
the_end:
av_free(frame);
return 0;
}
| [
"static int FUNC_0(void *VAR_0)\n{",
"VideoState *is = VAR_0;",
"AVPacket pkt1, *pkt = &pkt1;",
"int VAR_1, VAR_2;",
"AVFrame *frame= avcodec_alloc_frame();",
"double VAR_3;",
"for(;;) {",
"while (is->paused && !is->videoq.abort_request) {",
"SDL_Delay(10);",
"}",
"if (packet_queue_get(&is->videoq, pkt, 1) < 0)\nbreak;",
"if(pkt->data == flush_pkt.data){",
"avcodec_flush_buffers(is->video_st->codec);",
"is->last_dts_for_fault_detection=\nis->last_pts_for_fault_detection= INT64_MIN;",
"continue;",
"}",
"is->video_st->codec->reordered_opaque= pkt->VAR_3;",
"VAR_1 = avcodec_decode_video2(is->video_st->codec,\nframe, &VAR_2,\npkt);",
"if(pkt->dts != AV_NOPTS_VALUE){",
"is->faulty_dts += pkt->dts <= is->last_dts_for_fault_detection;",
"is->last_dts_for_fault_detection= pkt->dts;",
"}",
"if(frame->reordered_opaque != AV_NOPTS_VALUE){",
"is->faulty_pts += frame->reordered_opaque <= is->last_pts_for_fault_detection;",
"is->last_pts_for_fault_detection= frame->reordered_opaque;",
"}",
"if( ( decoder_reorder_pts==1\n|| decoder_reorder_pts && is->faulty_pts<is->faulty_dts\n|| pkt->dts == AV_NOPTS_VALUE)\n&& frame->reordered_opaque != AV_NOPTS_VALUE)\nVAR_3= frame->reordered_opaque;",
"else if(pkt->dts != AV_NOPTS_VALUE)\nVAR_3= pkt->dts;",
"else\nVAR_3= 0;",
"VAR_3 *= av_q2d(is->video_st->time_base);",
"if (VAR_2) {",
"if (output_picture2(is, frame, VAR_3) < 0)\ngoto the_end;",
"}",
"av_free_packet(pkt);",
"if (step)\nif (cur_stream)\nstream_pause(cur_stream);",
"}",
"the_end:\nav_free(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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25,
27
],
[
31
],
[
33
],
[
35,
37
],
[
39
],
[
41
],
[
49
],
[
51,
53,
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77,
79,
81,
83,
85
],
[
87,
89
],
[
91,
93
],
[
95
],
[
103
],
[
105,
107
],
[
109
],
[
111
],
[
113,
115,
117
],
[
119
],
[
121,
123
],
[
125
],
[
127
]
] |
21,237 | static int nut_write_header(AVFormatContext *s)
{
NUTContext *nut = s->priv_data;
AVIOContext *bc = s->pb;
int i, j, ret;
nut->avf = s;
nut->version = FFMAX(NUT_STABLE_VERSION, 3 + !!nut->flags);
if (nut->flags && s->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
av_log(s, AV_LOG_ERROR,
"The additional syncpoint modes require version %d, "
"that is currently not finalized, "
"please set -f_strict experimental in order to enable it.\n",
nut->version);
return AVERROR_EXPERIMENTAL;
}
nut->stream = av_calloc(s->nb_streams, sizeof(*nut->stream ));
nut->chapter = av_calloc(s->nb_chapters, sizeof(*nut->chapter));
nut->time_base= av_calloc(s->nb_streams +
s->nb_chapters, sizeof(*nut->time_base));
if (!nut->stream || !nut->chapter || !nut->time_base) {
av_freep(&nut->stream);
av_freep(&nut->chapter);
av_freep(&nut->time_base);
return AVERROR(ENOMEM);
}
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
int ssize;
AVRational time_base;
ff_parse_specific_params(st->codec, &time_base.den, &ssize, &time_base.num);
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && st->codec->sample_rate) {
time_base = (AVRational) {1, st->codec->sample_rate};
} else {
time_base = ff_choose_timebase(s, st, 48000);
}
avpriv_set_pts_info(st, 64, time_base.num, time_base.den);
for (j = 0; j < nut->time_base_count; j++)
if (!memcmp(&time_base, &nut->time_base[j], sizeof(AVRational))) {
break;
}
nut->time_base[j] = time_base;
nut->stream[i].time_base = &nut->time_base[j];
if (j == nut->time_base_count)
nut->time_base_count++;
if (INT64_C(1000) * time_base.num >= time_base.den)
nut->stream[i].msb_pts_shift = 7;
else
nut->stream[i].msb_pts_shift = 14;
nut->stream[i].max_pts_distance =
FFMAX(time_base.den, time_base.num) / time_base.num;
}
for (i = 0; i < s->nb_chapters; i++) {
AVChapter *ch = s->chapters[i];
for (j = 0; j < nut->time_base_count; j++)
if (!memcmp(&ch->time_base, &nut->time_base[j], sizeof(AVRational)))
break;
nut->time_base[j] = ch->time_base;
nut->chapter[i].time_base = &nut->time_base[j];
if (j == nut->time_base_count)
nut->time_base_count++;
}
nut->max_distance = MAX_DISTANCE;
build_elision_headers(s);
build_frame_code(s);
av_assert0(nut->frame_code['N'].flags == FLAG_INVALID);
avio_write(bc, ID_STRING, strlen(ID_STRING));
avio_w8(bc, 0);
if ((ret = write_headers(s, bc)) < 0)
return ret;
if (s->avoid_negative_ts < 0)
s->avoid_negative_ts = 1;
avio_flush(bc);
return 0;
}
| false | FFmpeg | 3a76d7f73d495c5af0968e83d96c075c27af3b5c | static int nut_write_header(AVFormatContext *s)
{
NUTContext *nut = s->priv_data;
AVIOContext *bc = s->pb;
int i, j, ret;
nut->avf = s;
nut->version = FFMAX(NUT_STABLE_VERSION, 3 + !!nut->flags);
if (nut->flags && s->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
av_log(s, AV_LOG_ERROR,
"The additional syncpoint modes require version %d, "
"that is currently not finalized, "
"please set -f_strict experimental in order to enable it.\n",
nut->version);
return AVERROR_EXPERIMENTAL;
}
nut->stream = av_calloc(s->nb_streams, sizeof(*nut->stream ));
nut->chapter = av_calloc(s->nb_chapters, sizeof(*nut->chapter));
nut->time_base= av_calloc(s->nb_streams +
s->nb_chapters, sizeof(*nut->time_base));
if (!nut->stream || !nut->chapter || !nut->time_base) {
av_freep(&nut->stream);
av_freep(&nut->chapter);
av_freep(&nut->time_base);
return AVERROR(ENOMEM);
}
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
int ssize;
AVRational time_base;
ff_parse_specific_params(st->codec, &time_base.den, &ssize, &time_base.num);
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && st->codec->sample_rate) {
time_base = (AVRational) {1, st->codec->sample_rate};
} else {
time_base = ff_choose_timebase(s, st, 48000);
}
avpriv_set_pts_info(st, 64, time_base.num, time_base.den);
for (j = 0; j < nut->time_base_count; j++)
if (!memcmp(&time_base, &nut->time_base[j], sizeof(AVRational))) {
break;
}
nut->time_base[j] = time_base;
nut->stream[i].time_base = &nut->time_base[j];
if (j == nut->time_base_count)
nut->time_base_count++;
if (INT64_C(1000) * time_base.num >= time_base.den)
nut->stream[i].msb_pts_shift = 7;
else
nut->stream[i].msb_pts_shift = 14;
nut->stream[i].max_pts_distance =
FFMAX(time_base.den, time_base.num) / time_base.num;
}
for (i = 0; i < s->nb_chapters; i++) {
AVChapter *ch = s->chapters[i];
for (j = 0; j < nut->time_base_count; j++)
if (!memcmp(&ch->time_base, &nut->time_base[j], sizeof(AVRational)))
break;
nut->time_base[j] = ch->time_base;
nut->chapter[i].time_base = &nut->time_base[j];
if (j == nut->time_base_count)
nut->time_base_count++;
}
nut->max_distance = MAX_DISTANCE;
build_elision_headers(s);
build_frame_code(s);
av_assert0(nut->frame_code['N'].flags == FLAG_INVALID);
avio_write(bc, ID_STRING, strlen(ID_STRING));
avio_w8(bc, 0);
if ((ret = write_headers(s, bc)) < 0)
return ret;
if (s->avoid_negative_ts < 0)
s->avoid_negative_ts = 1;
avio_flush(bc);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0)
{
NUTContext *nut = VAR_0->priv_data;
AVIOContext *bc = VAR_0->pb;
int VAR_1, VAR_2, VAR_3;
nut->avf = VAR_0;
nut->version = FFMAX(NUT_STABLE_VERSION, 3 + !!nut->flags);
if (nut->flags && VAR_0->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
av_log(VAR_0, AV_LOG_ERROR,
"The additional syncpoint modes require version %d, "
"that is currently not finalized, "
"please set -f_strict experimental in order to enable it.\n",
nut->version);
return AVERROR_EXPERIMENTAL;
}
nut->stream = av_calloc(VAR_0->nb_streams, sizeof(*nut->stream ));
nut->chapter = av_calloc(VAR_0->nb_chapters, sizeof(*nut->chapter));
nut->time_base= av_calloc(VAR_0->nb_streams +
VAR_0->nb_chapters, sizeof(*nut->time_base));
if (!nut->stream || !nut->chapter || !nut->time_base) {
av_freep(&nut->stream);
av_freep(&nut->chapter);
av_freep(&nut->time_base);
return AVERROR(ENOMEM);
}
for (VAR_1 = 0; VAR_1 < VAR_0->nb_streams; VAR_1++) {
AVStream *st = VAR_0->streams[VAR_1];
int ssize;
AVRational time_base;
ff_parse_specific_params(st->codec, &time_base.den, &ssize, &time_base.num);
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && st->codec->sample_rate) {
time_base = (AVRational) {1, st->codec->sample_rate};
} else {
time_base = ff_choose_timebase(VAR_0, st, 48000);
}
avpriv_set_pts_info(st, 64, time_base.num, time_base.den);
for (VAR_2 = 0; VAR_2 < nut->time_base_count; VAR_2++)
if (!memcmp(&time_base, &nut->time_base[VAR_2], sizeof(AVRational))) {
break;
}
nut->time_base[VAR_2] = time_base;
nut->stream[VAR_1].time_base = &nut->time_base[VAR_2];
if (VAR_2 == nut->time_base_count)
nut->time_base_count++;
if (INT64_C(1000) * time_base.num >= time_base.den)
nut->stream[VAR_1].msb_pts_shift = 7;
else
nut->stream[VAR_1].msb_pts_shift = 14;
nut->stream[VAR_1].max_pts_distance =
FFMAX(time_base.den, time_base.num) / time_base.num;
}
for (VAR_1 = 0; VAR_1 < VAR_0->nb_chapters; VAR_1++) {
AVChapter *ch = VAR_0->chapters[VAR_1];
for (VAR_2 = 0; VAR_2 < nut->time_base_count; VAR_2++)
if (!memcmp(&ch->time_base, &nut->time_base[VAR_2], sizeof(AVRational)))
break;
nut->time_base[VAR_2] = ch->time_base;
nut->chapter[VAR_1].time_base = &nut->time_base[VAR_2];
if (VAR_2 == nut->time_base_count)
nut->time_base_count++;
}
nut->max_distance = MAX_DISTANCE;
build_elision_headers(VAR_0);
build_frame_code(VAR_0);
av_assert0(nut->frame_code['N'].flags == FLAG_INVALID);
avio_write(bc, ID_STRING, strlen(ID_STRING));
avio_w8(bc, 0);
if ((VAR_3 = write_headers(VAR_0, bc)) < 0)
return VAR_3;
if (VAR_0->avoid_negative_ts < 0)
VAR_0->avoid_negative_ts = 1;
avio_flush(bc);
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0)\n{",
"NUTContext *nut = VAR_0->priv_data;",
"AVIOContext *bc = VAR_0->pb;",
"int VAR_1, VAR_2, VAR_3;",
"nut->avf = VAR_0;",
"nut->version = FFMAX(NUT_STABLE_VERSION, 3 + !!nut->flags);",
"if (nut->flags && VAR_0->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"The additional syncpoint modes require version %d, \"\n\"that is currently not finalized, \"\n\"please set -f_strict experimental in order to enable it.\\n\",\nnut->version);",
"return AVERROR_EXPERIMENTAL;",
"}",
"nut->stream = av_calloc(VAR_0->nb_streams, sizeof(*nut->stream ));",
"nut->chapter = av_calloc(VAR_0->nb_chapters, sizeof(*nut->chapter));",
"nut->time_base= av_calloc(VAR_0->nb_streams +\nVAR_0->nb_chapters, sizeof(*nut->time_base));",
"if (!nut->stream || !nut->chapter || !nut->time_base) {",
"av_freep(&nut->stream);",
"av_freep(&nut->chapter);",
"av_freep(&nut->time_base);",
"return AVERROR(ENOMEM);",
"}",
"for (VAR_1 = 0; VAR_1 < VAR_0->nb_streams; VAR_1++) {",
"AVStream *st = VAR_0->streams[VAR_1];",
"int ssize;",
"AVRational time_base;",
"ff_parse_specific_params(st->codec, &time_base.den, &ssize, &time_base.num);",
"if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && st->codec->sample_rate) {",
"time_base = (AVRational) {1, st->codec->sample_rate};",
"} else {",
"time_base = ff_choose_timebase(VAR_0, st, 48000);",
"}",
"avpriv_set_pts_info(st, 64, time_base.num, time_base.den);",
"for (VAR_2 = 0; VAR_2 < nut->time_base_count; VAR_2++)",
"if (!memcmp(&time_base, &nut->time_base[VAR_2], sizeof(AVRational))) {",
"break;",
"}",
"nut->time_base[VAR_2] = time_base;",
"nut->stream[VAR_1].time_base = &nut->time_base[VAR_2];",
"if (VAR_2 == nut->time_base_count)\nnut->time_base_count++;",
"if (INT64_C(1000) * time_base.num >= time_base.den)\nnut->stream[VAR_1].msb_pts_shift = 7;",
"else\nnut->stream[VAR_1].msb_pts_shift = 14;",
"nut->stream[VAR_1].max_pts_distance =\nFFMAX(time_base.den, time_base.num) / time_base.num;",
"}",
"for (VAR_1 = 0; VAR_1 < VAR_0->nb_chapters; VAR_1++) {",
"AVChapter *ch = VAR_0->chapters[VAR_1];",
"for (VAR_2 = 0; VAR_2 < nut->time_base_count; VAR_2++)",
"if (!memcmp(&ch->time_base, &nut->time_base[VAR_2], sizeof(AVRational)))\nbreak;",
"nut->time_base[VAR_2] = ch->time_base;",
"nut->chapter[VAR_1].time_base = &nut->time_base[VAR_2];",
"if (VAR_2 == nut->time_base_count)\nnut->time_base_count++;",
"}",
"nut->max_distance = MAX_DISTANCE;",
"build_elision_headers(VAR_0);",
"build_frame_code(VAR_0);",
"av_assert0(nut->frame_code['N'].flags == FLAG_INVALID);",
"avio_write(bc, ID_STRING, strlen(ID_STRING));",
"avio_w8(bc, 0);",
"if ((VAR_3 = write_headers(VAR_0, bc)) < 0)\nreturn VAR_3;",
"if (VAR_0->avoid_negative_ts < 0)\nVAR_0->avoid_negative_ts = 1;",
"avio_flush(bc);",
"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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
21,
23,
25,
27,
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41,
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99,
101
],
[
105,
107
],
[
109,
111
],
[
113,
115
],
[
117
],
[
121
],
[
123
],
[
127
],
[
129,
131
],
[
135
],
[
137
],
[
139,
141
],
[
143
],
[
147
],
[
149
],
[
151
],
[
153
],
[
157
],
[
159
],
[
163,
165
],
[
169,
171
],
[
175
],
[
179
],
[
181
]
] |
21,239 | static void skip_input(DBEContext *s, int nb_words)
{
s->input += nb_words * s->word_bytes;
s->input_size -= nb_words;
}
| true | FFmpeg | 5e715b583dab85735660b15a8d217a69164675fe | static void skip_input(DBEContext *s, int nb_words)
{
s->input += nb_words * s->word_bytes;
s->input_size -= nb_words;
}
| {
"code": [
"static void skip_input(DBEContext *s, int nb_words)"
],
"line_no": [
1
]
} | static void FUNC_0(DBEContext *VAR_0, int VAR_1)
{
VAR_0->input += VAR_1 * VAR_0->word_bytes;
VAR_0->input_size -= VAR_1;
}
| [
"static void FUNC_0(DBEContext *VAR_0, int VAR_1)\n{",
"VAR_0->input += VAR_1 * VAR_0->word_bytes;",
"VAR_0->input_size -= VAR_1;",
"}"
] | [
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
21,240 | static void g364fb_screen_dump(void *opaque, const char *filename)
{
G364State *s = opaque;
int y, x;
uint8_t index;
uint8_t *data_buffer;
FILE *f;
if (s->depth != 8) {
error_report("g364: unknown guest depth %d", s->depth);
return;
}
f = fopen(filename, "wb");
if (!f)
return;
if (s->ctla & CTLA_FORCE_BLANK) {
/* blank screen */
fprintf(f, "P4\n%d %d\n",
s->width, s->height);
for (y = 0; y < s->height; y++)
for (x = 0; x < s->width; x++)
fputc(0, f);
} else {
data_buffer = s->vram + s->top_of_screen;
fprintf(f, "P6\n%d %d\n%d\n",
s->width, s->height, 255);
for (y = 0; y < s->height; y++)
for (x = 0; x < s->width; x++, data_buffer++) {
index = *data_buffer;
fputc(s->color_palette[index][0], f);
fputc(s->color_palette[index][1], f);
fputc(s->color_palette[index][2], f);
}
}
fclose(f);
} | true | qemu | e9a07334fb6ee08ddd61787c102d36e7e781efef | static void g364fb_screen_dump(void *opaque, const char *filename)
{
G364State *s = opaque;
int y, x;
uint8_t index;
uint8_t *data_buffer;
FILE *f;
if (s->depth != 8) {
error_report("g364: unknown guest depth %d", s->depth);
return;
}
f = fopen(filename, "wb");
if (!f)
return;
if (s->ctla & CTLA_FORCE_BLANK) {
fprintf(f, "P4\n%d %d\n",
s->width, s->height);
for (y = 0; y < s->height; y++)
for (x = 0; x < s->width; x++)
fputc(0, f);
} else {
data_buffer = s->vram + s->top_of_screen;
fprintf(f, "P6\n%d %d\n%d\n",
s->width, s->height, 255);
for (y = 0; y < s->height; y++)
for (x = 0; x < s->width; x++, data_buffer++) {
index = *data_buffer;
fputc(s->color_palette[index][0], f);
fputc(s->color_palette[index][1], f);
fputc(s->color_palette[index][2], f);
}
}
fclose(f);
} | {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, const char *VAR_1)
{
G364State *s = VAR_0;
int VAR_2, VAR_3;
uint8_t index;
uint8_t *data_buffer;
FILE *f;
if (s->depth != 8) {
error_report("g364: unknown guest depth %d", s->depth);
return;
}
f = fopen(VAR_1, "wb");
if (!f)
return;
if (s->ctla & CTLA_FORCE_BLANK) {
fprintf(f, "P4\n%d %d\n",
s->width, s->height);
for (VAR_2 = 0; VAR_2 < s->height; VAR_2++)
for (VAR_3 = 0; VAR_3 < s->width; VAR_3++)
fputc(0, f);
} else {
data_buffer = s->vram + s->top_of_screen;
fprintf(f, "P6\n%d %d\n%d\n",
s->width, s->height, 255);
for (VAR_2 = 0; VAR_2 < s->height; VAR_2++)
for (VAR_3 = 0; VAR_3 < s->width; VAR_3++, data_buffer++) {
index = *data_buffer;
fputc(s->color_palette[index][0], f);
fputc(s->color_palette[index][1], f);
fputc(s->color_palette[index][2], f);
}
}
fclose(f);
} | [
"static void FUNC_0(void *VAR_0, const char *VAR_1)\n{",
"G364State *s = VAR_0;",
"int VAR_2, VAR_3;",
"uint8_t index;",
"uint8_t *data_buffer;",
"FILE *f;",
"if (s->depth != 8) {",
"error_report(\"g364: unknown guest depth %d\", s->depth);",
"return;",
"}",
"f = fopen(VAR_1, \"wb\");",
"if (!f)\nreturn;",
"if (s->ctla & CTLA_FORCE_BLANK) {",
"fprintf(f, \"P4\\n%d %d\\n\",\ns->width, s->height);",
"for (VAR_2 = 0; VAR_2 < s->height; VAR_2++)",
"for (VAR_3 = 0; VAR_3 < s->width; VAR_3++)",
"fputc(0, f);",
"} else {",
"data_buffer = s->vram + s->top_of_screen;",
"fprintf(f, \"P6\\n%d %d\\n%d\\n\",\ns->width, s->height, 255);",
"for (VAR_2 = 0; VAR_2 < s->height; VAR_2++)",
"for (VAR_3 = 0; VAR_3 < s->width; VAR_3++, data_buffer++) {",
"index = *data_buffer;",
"fputc(s->color_palette[index][0], f);",
"fputc(s->color_palette[index][1], f);",
"fputc(s->color_palette[index][2], f);",
"}",
"}",
"fclose(f);",
"}"
] | [
0,
0,
0,
0,
0,
0,
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
],
[
17,
18
],
[
19
],
[
20
],
[
21
],
[
22
],
[
23
],
[
24,
25
],
[
26
],
[
27
],
[
28
],
[
29
],
[
30
],
[
31
],
[
32
],
[
33
],
[
34
],
[
35
]
] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.