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 listlengths 1 2.8k | label listlengths 1 2.8k | line_no listlengths 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;",
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],... |
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++ )",
"ds... | [
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... | [
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 ... | [
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
],
[... |
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,... | [
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 =... | [
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
],
... |
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);",
"#e... | [
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 >= ... | [
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... | [
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... | [
[
1
],
[
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
21
],
[
23
],
[
31
],
[
33
],
[
35
],
[
37,
39,
41
],
[
43
],
[
45
],
[
47
],
[
51,
55,
59,
63
],
[
71
... |
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_ST... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[... |
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;",
... | [
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
],
[... |
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_dat... | [
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);",
... | [
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;",
"#ifd... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21,
23
],
[
25,
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45,
49
],
[
51
],
[... |
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:\n... | [
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
... |
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\";",
... | [
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
],
[... |
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, wi... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[... |
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) {",
"... | [
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(n... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[... |
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... | [
0,
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
... |
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;... | [
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
],
[... |
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) {",
... | [
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
... |
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... | [
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->cm... | [
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... | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
23
],
[
27
],
[
29,
31,
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
... |
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_pwri... | [
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++)",
... | [
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 =... | [
0,
0,
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
],
[... |
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)... | [
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
... |
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 + ... | [
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... | [
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\... | [
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
],
... |
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,... | [
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
],
[... |
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;",
"VdpDecode... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
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... | [
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... | [
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_... | [
0,
0,
0,
0,
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
],
... |
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... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[... |
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, \"crea... | [
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,
... |
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... | [
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
],
[... |
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... | [
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... | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
... |
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... | [
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... | [
[
1
],
[
3
],
[
5
],
[
7
],
[
9,
11
],
[
13
],
[
15
],
[
17
],
[
19,
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[... |
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) ... | [
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 ... | [
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... | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17,
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
... |
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 ? 0x00ff00ff00ff00fful... | [
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->av... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
... |
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;",
... | [
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... | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25,
27
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[... |
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_... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
... |
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 in... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],... |
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, \... | [
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->act... | [
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... | [
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,\ni... | [
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_s... | [
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->d... | [
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
... |
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\... | [
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);",
"a... | [
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);",
"bre... | [
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... |
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_... | [
0,
0,
0,
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
],
[... |
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)... | [
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
... |
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(\"Chec... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[... |
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 >> ... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
... |
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;",
"qem... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
... |
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_MODE... | [
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);... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
... |
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, A... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
... |
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 (!str... | [
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_... | [
0,
0,
0,
0,
0,
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
],
... |
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... | [
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\"packu... | [
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)... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[... |
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_DIRT... | [
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++) {",
... | [
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
... |
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... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
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 {... | [
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);",
... | [
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.for... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,... |
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... | [
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... | [
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->vide... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
... |
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_EXPERIMEN... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[... |
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 (!... | [
0,
0,
0,
0,
0,
0,
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
],... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.