id
int32 0
27.3k
| func
stringlengths 26
142k
| target
bool 2
classes | project
stringclasses 2
values | commit_id
stringlengths 40
40
| func_clean
stringlengths 26
131k
| vul_lines
dict | normalized_func
stringlengths 24
132k
| lines
sequencelengths 1
2.8k
| label
sequencelengths 1
2.8k
| line_no
sequencelengths 1
2.8k
|
---|---|---|---|---|---|---|---|---|---|---|
18,874 | static unsigned int dec_addu_r(DisasContext *dc)
{
TCGv t0;
int size = memsize_z(dc);
DIS(fprintf (logfile, "addu.%c $r%u, $r%u\n",
memsize_char(size),
dc->op1, dc->op2));
cris_cc_mask(dc, CC_MASK_NZVC);
t0 = tcg_temp_new(TCG_TYPE_TL);
/* Size can only be qi or hi. */
t_gen_zext(t0, cpu_R[dc->op1], size);
cris_alu(dc, CC_OP_ADD,
cpu_R[dc->op2], cpu_R[dc->op2], t0, 4);
tcg_temp_free(t0);
return 2;
}
| false | qemu | a7812ae412311d7d47f8aa85656faadac9d64b56 | static unsigned int dec_addu_r(DisasContext *dc)
{
TCGv t0;
int size = memsize_z(dc);
DIS(fprintf (logfile, "addu.%c $r%u, $r%u\n",
memsize_char(size),
dc->op1, dc->op2));
cris_cc_mask(dc, CC_MASK_NZVC);
t0 = tcg_temp_new(TCG_TYPE_TL);
t_gen_zext(t0, cpu_R[dc->op1], size);
cris_alu(dc, CC_OP_ADD,
cpu_R[dc->op2], cpu_R[dc->op2], t0, 4);
tcg_temp_free(t0);
return 2;
}
| {
"code": [],
"line_no": []
} | static unsigned int FUNC_0(DisasContext *VAR_0)
{
TCGv t0;
int VAR_1 = memsize_z(VAR_0);
DIS(fprintf (logfile, "addu.%c $r%u, $r%u\n",
memsize_char(VAR_1),
VAR_0->op1, VAR_0->op2));
cris_cc_mask(VAR_0, CC_MASK_NZVC);
t0 = tcg_temp_new(TCG_TYPE_TL);
t_gen_zext(t0, cpu_R[VAR_0->op1], VAR_1);
cris_alu(VAR_0, CC_OP_ADD,
cpu_R[VAR_0->op2], cpu_R[VAR_0->op2], t0, 4);
tcg_temp_free(t0);
return 2;
}
| [
"static unsigned int FUNC_0(DisasContext *VAR_0)\n{",
"TCGv t0;",
"int VAR_1 = memsize_z(VAR_0);",
"DIS(fprintf (logfile, \"addu.%c $r%u, $r%u\\n\",\nmemsize_char(VAR_1),\nVAR_0->op1, VAR_0->op2));",
"cris_cc_mask(VAR_0, CC_MASK_NZVC);",
"t0 = tcg_temp_new(TCG_TYPE_TL);",
"t_gen_zext(t0, cpu_R[VAR_0->op1], VAR_1);",
"cris_alu(VAR_0, CC_OP_ADD,\ncpu_R[VAR_0->op2], cpu_R[VAR_0->op2], t0, 4);",
"tcg_temp_free(t0);",
"return 2;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9,
11,
13
],
[
17
],
[
19
],
[
23
],
[
25,
27
],
[
29
],
[
31
],
[
33
]
] |
18,875 | static void net_rx_packet(void *opaque, const uint8_t *buf, size_t size)
{
struct XenNetDev *netdev = opaque;
netif_rx_request_t rxreq;
RING_IDX rc, rp;
void *page;
if (netdev->xendev.be_state != XenbusStateConnected)
return;
rc = netdev->rx_ring.req_cons;
rp = netdev->rx_ring.sring->req_prod;
xen_rmb(); /* Ensure we see queued requests up to 'rp'. */
if (rc == rp || RING_REQUEST_CONS_OVERFLOW(&netdev->rx_ring, rc)) {
xen_be_printf(&netdev->xendev, 2, "no buffer, drop packet\n");
return;
}
if (size > XC_PAGE_SIZE - NET_IP_ALIGN) {
xen_be_printf(&netdev->xendev, 0, "packet too big (%lu > %ld)",
(unsigned long)size, XC_PAGE_SIZE - NET_IP_ALIGN);
return;
}
memcpy(&rxreq, RING_GET_REQUEST(&netdev->rx_ring, rc), sizeof(rxreq));
netdev->rx_ring.req_cons = ++rc;
page = xc_gnttab_map_grant_ref(netdev->xendev.gnttabdev,
netdev->xendev.dom,
rxreq.gref, PROT_WRITE);
if (page == NULL) {
xen_be_printf(&netdev->xendev, 0, "error: rx gref dereference failed (%d)\n",
rxreq.gref);
net_rx_response(netdev, &rxreq, NETIF_RSP_ERROR, 0, 0, 0);
return;
}
memcpy(page + NET_IP_ALIGN, buf, size);
xc_gnttab_munmap(netdev->xendev.gnttabdev, page, 1);
net_rx_response(netdev, &rxreq, NETIF_RSP_OKAY, NET_IP_ALIGN, size, 0);
}
| false | qemu | e3f5ec2b5e92706e3b807059f79b1fb5d936e567 | static void net_rx_packet(void *opaque, const uint8_t *buf, size_t size)
{
struct XenNetDev *netdev = opaque;
netif_rx_request_t rxreq;
RING_IDX rc, rp;
void *page;
if (netdev->xendev.be_state != XenbusStateConnected)
return;
rc = netdev->rx_ring.req_cons;
rp = netdev->rx_ring.sring->req_prod;
xen_rmb();
if (rc == rp || RING_REQUEST_CONS_OVERFLOW(&netdev->rx_ring, rc)) {
xen_be_printf(&netdev->xendev, 2, "no buffer, drop packet\n");
return;
}
if (size > XC_PAGE_SIZE - NET_IP_ALIGN) {
xen_be_printf(&netdev->xendev, 0, "packet too big (%lu > %ld)",
(unsigned long)size, XC_PAGE_SIZE - NET_IP_ALIGN);
return;
}
memcpy(&rxreq, RING_GET_REQUEST(&netdev->rx_ring, rc), sizeof(rxreq));
netdev->rx_ring.req_cons = ++rc;
page = xc_gnttab_map_grant_ref(netdev->xendev.gnttabdev,
netdev->xendev.dom,
rxreq.gref, PROT_WRITE);
if (page == NULL) {
xen_be_printf(&netdev->xendev, 0, "error: rx gref dereference failed (%d)\n",
rxreq.gref);
net_rx_response(netdev, &rxreq, NETIF_RSP_ERROR, 0, 0, 0);
return;
}
memcpy(page + NET_IP_ALIGN, buf, size);
xc_gnttab_munmap(netdev->xendev.gnttabdev, page, 1);
net_rx_response(netdev, &rxreq, NETIF_RSP_OKAY, NET_IP_ALIGN, size, 0);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, const uint8_t *VAR_1, size_t VAR_2)
{
struct XenNetDev *VAR_3 = VAR_0;
netif_rx_request_t rxreq;
RING_IDX rc, rp;
void *VAR_4;
if (VAR_3->xendev.be_state != XenbusStateConnected)
return;
rc = VAR_3->rx_ring.req_cons;
rp = VAR_3->rx_ring.sring->req_prod;
xen_rmb();
if (rc == rp || RING_REQUEST_CONS_OVERFLOW(&VAR_3->rx_ring, rc)) {
xen_be_printf(&VAR_3->xendev, 2, "no buffer, drop packet\n");
return;
}
if (VAR_2 > XC_PAGE_SIZE - NET_IP_ALIGN) {
xen_be_printf(&VAR_3->xendev, 0, "packet too big (%lu > %ld)",
(unsigned long)VAR_2, XC_PAGE_SIZE - NET_IP_ALIGN);
return;
}
memcpy(&rxreq, RING_GET_REQUEST(&VAR_3->rx_ring, rc), sizeof(rxreq));
VAR_3->rx_ring.req_cons = ++rc;
VAR_4 = xc_gnttab_map_grant_ref(VAR_3->xendev.gnttabdev,
VAR_3->xendev.dom,
rxreq.gref, PROT_WRITE);
if (VAR_4 == NULL) {
xen_be_printf(&VAR_3->xendev, 0, "error: rx gref dereference failed (%d)\n",
rxreq.gref);
net_rx_response(VAR_3, &rxreq, NETIF_RSP_ERROR, 0, 0, 0);
return;
}
memcpy(VAR_4 + NET_IP_ALIGN, VAR_1, VAR_2);
xc_gnttab_munmap(VAR_3->xendev.gnttabdev, VAR_4, 1);
net_rx_response(VAR_3, &rxreq, NETIF_RSP_OKAY, NET_IP_ALIGN, VAR_2, 0);
}
| [
"static void FUNC_0(void *VAR_0, const uint8_t *VAR_1, size_t VAR_2)\n{",
"struct XenNetDev *VAR_3 = VAR_0;",
"netif_rx_request_t rxreq;",
"RING_IDX rc, rp;",
"void *VAR_4;",
"if (VAR_3->xendev.be_state != XenbusStateConnected)\nreturn;",
"rc = VAR_3->rx_ring.req_cons;",
"rp = VAR_3->rx_ring.sring->req_prod;",
"xen_rmb();",
"if (rc == rp || RING_REQUEST_CONS_OVERFLOW(&VAR_3->rx_ring, rc)) {",
"xen_be_printf(&VAR_3->xendev, 2, \"no buffer, drop packet\\n\");",
"return;",
"}",
"if (VAR_2 > XC_PAGE_SIZE - NET_IP_ALIGN) {",
"xen_be_printf(&VAR_3->xendev, 0, \"packet too big (%lu > %ld)\",\n(unsigned long)VAR_2, XC_PAGE_SIZE - NET_IP_ALIGN);",
"return;",
"}",
"memcpy(&rxreq, RING_GET_REQUEST(&VAR_3->rx_ring, rc), sizeof(rxreq));",
"VAR_3->rx_ring.req_cons = ++rc;",
"VAR_4 = xc_gnttab_map_grant_ref(VAR_3->xendev.gnttabdev,\nVAR_3->xendev.dom,\nrxreq.gref, PROT_WRITE);",
"if (VAR_4 == NULL) {",
"xen_be_printf(&VAR_3->xendev, 0, \"error: rx gref dereference failed (%d)\\n\",\nrxreq.gref);",
"net_rx_response(VAR_3, &rxreq, NETIF_RSP_ERROR, 0, 0, 0);",
"return;",
"}",
"memcpy(VAR_4 + NET_IP_ALIGN, VAR_1, VAR_2);",
"xc_gnttab_munmap(VAR_3->xendev.gnttabdev, VAR_4, 1);",
"net_rx_response(VAR_3, &rxreq, NETIF_RSP_OKAY, NET_IP_ALIGN, VAR_2, 0);",
"}"
] | [
0,
0,
0,
0,
0,
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
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39,
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
55,
57,
59
],
[
61
],
[
63,
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
]
] |
18,876 | static void mcf_fec_receive(void *opaque, const uint8_t *buf, size_t size)
{
mcf_fec_state *s = (mcf_fec_state *)opaque;
mcf_fec_bd bd;
uint32_t flags = 0;
uint32_t addr;
uint32_t crc;
uint32_t buf_addr;
uint8_t *crc_ptr;
unsigned int buf_len;
DPRINTF("do_rx len %d\n", size);
if (!s->rx_enabled) {
fprintf(stderr, "mcf_fec_receive: Unexpected packet\n");
}
/* 4 bytes for the CRC. */
size += 4;
crc = cpu_to_be32(crc32(~0, buf, size));
crc_ptr = (uint8_t *)&crc;
/* Huge frames are truncted. */
if (size > FEC_MAX_FRAME_SIZE) {
size = FEC_MAX_FRAME_SIZE;
flags |= FEC_BD_TR | FEC_BD_LG;
}
/* Frames larger than the user limit just set error flags. */
if (size > (s->rcr >> 16)) {
flags |= FEC_BD_LG;
}
addr = s->rx_descriptor;
while (size > 0) {
mcf_fec_read_bd(&bd, addr);
if ((bd.flags & FEC_BD_E) == 0) {
/* No descriptors available. Bail out. */
/* FIXME: This is wrong. We should probably either save the
remainder for when more RX buffers are available, or
flag an error. */
fprintf(stderr, "mcf_fec: Lost end of frame\n");
break;
}
buf_len = (size <= s->emrbr) ? size: s->emrbr;
bd.length = buf_len;
size -= buf_len;
DPRINTF("rx_bd %x length %d\n", addr, bd.length);
/* The last 4 bytes are the CRC. */
if (size < 4)
buf_len += size - 4;
buf_addr = bd.data;
cpu_physical_memory_write(buf_addr, buf, buf_len);
buf += buf_len;
if (size < 4) {
cpu_physical_memory_write(buf_addr + buf_len, crc_ptr, 4 - size);
crc_ptr += 4 - size;
}
bd.flags &= ~FEC_BD_E;
if (size == 0) {
/* Last buffer in frame. */
bd.flags |= flags | FEC_BD_L;
DPRINTF("rx frame flags %04x\n", bd.flags);
s->eir |= FEC_INT_RXF;
} else {
s->eir |= FEC_INT_RXB;
}
mcf_fec_write_bd(&bd, addr);
/* Advance to the next descriptor. */
if ((bd.flags & FEC_BD_W) != 0) {
addr = s->erdsr;
} else {
addr += 8;
}
}
s->rx_descriptor = addr;
mcf_fec_enable_rx(s);
mcf_fec_update(s);
}
| false | qemu | e3f5ec2b5e92706e3b807059f79b1fb5d936e567 | static void mcf_fec_receive(void *opaque, const uint8_t *buf, size_t size)
{
mcf_fec_state *s = (mcf_fec_state *)opaque;
mcf_fec_bd bd;
uint32_t flags = 0;
uint32_t addr;
uint32_t crc;
uint32_t buf_addr;
uint8_t *crc_ptr;
unsigned int buf_len;
DPRINTF("do_rx len %d\n", size);
if (!s->rx_enabled) {
fprintf(stderr, "mcf_fec_receive: Unexpected packet\n");
}
size += 4;
crc = cpu_to_be32(crc32(~0, buf, size));
crc_ptr = (uint8_t *)&crc;
if (size > FEC_MAX_FRAME_SIZE) {
size = FEC_MAX_FRAME_SIZE;
flags |= FEC_BD_TR | FEC_BD_LG;
}
if (size > (s->rcr >> 16)) {
flags |= FEC_BD_LG;
}
addr = s->rx_descriptor;
while (size > 0) {
mcf_fec_read_bd(&bd, addr);
if ((bd.flags & FEC_BD_E) == 0) {
fprintf(stderr, "mcf_fec: Lost end of frame\n");
break;
}
buf_len = (size <= s->emrbr) ? size: s->emrbr;
bd.length = buf_len;
size -= buf_len;
DPRINTF("rx_bd %x length %d\n", addr, bd.length);
if (size < 4)
buf_len += size - 4;
buf_addr = bd.data;
cpu_physical_memory_write(buf_addr, buf, buf_len);
buf += buf_len;
if (size < 4) {
cpu_physical_memory_write(buf_addr + buf_len, crc_ptr, 4 - size);
crc_ptr += 4 - size;
}
bd.flags &= ~FEC_BD_E;
if (size == 0) {
bd.flags |= flags | FEC_BD_L;
DPRINTF("rx frame flags %04x\n", bd.flags);
s->eir |= FEC_INT_RXF;
} else {
s->eir |= FEC_INT_RXB;
}
mcf_fec_write_bd(&bd, addr);
if ((bd.flags & FEC_BD_W) != 0) {
addr = s->erdsr;
} else {
addr += 8;
}
}
s->rx_descriptor = addr;
mcf_fec_enable_rx(s);
mcf_fec_update(s);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, const uint8_t *VAR_1, size_t VAR_2)
{
mcf_fec_state *s = (mcf_fec_state *)VAR_0;
mcf_fec_bd bd;
uint32_t flags = 0;
uint32_t addr;
uint32_t crc;
uint32_t buf_addr;
uint8_t *crc_ptr;
unsigned int VAR_3;
DPRINTF("do_rx len %d\n", VAR_2);
if (!s->rx_enabled) {
fprintf(stderr, "FUNC_0: Unexpected packet\n");
}
VAR_2 += 4;
crc = cpu_to_be32(crc32(~0, VAR_1, VAR_2));
crc_ptr = (uint8_t *)&crc;
if (VAR_2 > FEC_MAX_FRAME_SIZE) {
VAR_2 = FEC_MAX_FRAME_SIZE;
flags |= FEC_BD_TR | FEC_BD_LG;
}
if (VAR_2 > (s->rcr >> 16)) {
flags |= FEC_BD_LG;
}
addr = s->rx_descriptor;
while (VAR_2 > 0) {
mcf_fec_read_bd(&bd, addr);
if ((bd.flags & FEC_BD_E) == 0) {
fprintf(stderr, "mcf_fec: Lost end of frame\n");
break;
}
VAR_3 = (VAR_2 <= s->emrbr) ? VAR_2: s->emrbr;
bd.length = VAR_3;
VAR_2 -= VAR_3;
DPRINTF("rx_bd %x length %d\n", addr, bd.length);
if (VAR_2 < 4)
VAR_3 += VAR_2 - 4;
buf_addr = bd.data;
cpu_physical_memory_write(buf_addr, VAR_1, VAR_3);
VAR_1 += VAR_3;
if (VAR_2 < 4) {
cpu_physical_memory_write(buf_addr + VAR_3, crc_ptr, 4 - VAR_2);
crc_ptr += 4 - VAR_2;
}
bd.flags &= ~FEC_BD_E;
if (VAR_2 == 0) {
bd.flags |= flags | FEC_BD_L;
DPRINTF("rx frame flags %04x\n", bd.flags);
s->eir |= FEC_INT_RXF;
} else {
s->eir |= FEC_INT_RXB;
}
mcf_fec_write_bd(&bd, addr);
if ((bd.flags & FEC_BD_W) != 0) {
addr = s->erdsr;
} else {
addr += 8;
}
}
s->rx_descriptor = addr;
mcf_fec_enable_rx(s);
mcf_fec_update(s);
}
| [
"static void FUNC_0(void *VAR_0, const uint8_t *VAR_1, size_t VAR_2)\n{",
"mcf_fec_state *s = (mcf_fec_state *)VAR_0;",
"mcf_fec_bd bd;",
"uint32_t flags = 0;",
"uint32_t addr;",
"uint32_t crc;",
"uint32_t buf_addr;",
"uint8_t *crc_ptr;",
"unsigned int VAR_3;",
"DPRINTF(\"do_rx len %d\\n\", VAR_2);",
"if (!s->rx_enabled) {",
"fprintf(stderr, \"FUNC_0: Unexpected packet\\n\");",
"}",
"VAR_2 += 4;",
"crc = cpu_to_be32(crc32(~0, VAR_1, VAR_2));",
"crc_ptr = (uint8_t *)&crc;",
"if (VAR_2 > FEC_MAX_FRAME_SIZE) {",
"VAR_2 = FEC_MAX_FRAME_SIZE;",
"flags |= FEC_BD_TR | FEC_BD_LG;",
"}",
"if (VAR_2 > (s->rcr >> 16)) {",
"flags |= FEC_BD_LG;",
"}",
"addr = s->rx_descriptor;",
"while (VAR_2 > 0) {",
"mcf_fec_read_bd(&bd, addr);",
"if ((bd.flags & FEC_BD_E) == 0) {",
"fprintf(stderr, \"mcf_fec: Lost end of frame\\n\");",
"break;",
"}",
"VAR_3 = (VAR_2 <= s->emrbr) ? VAR_2: s->emrbr;",
"bd.length = VAR_3;",
"VAR_2 -= VAR_3;",
"DPRINTF(\"rx_bd %x length %d\\n\", addr, bd.length);",
"if (VAR_2 < 4)\nVAR_3 += VAR_2 - 4;",
"buf_addr = bd.data;",
"cpu_physical_memory_write(buf_addr, VAR_1, VAR_3);",
"VAR_1 += VAR_3;",
"if (VAR_2 < 4) {",
"cpu_physical_memory_write(buf_addr + VAR_3, crc_ptr, 4 - VAR_2);",
"crc_ptr += 4 - VAR_2;",
"}",
"bd.flags &= ~FEC_BD_E;",
"if (VAR_2 == 0) {",
"bd.flags |= flags | FEC_BD_L;",
"DPRINTF(\"rx frame flags %04x\\n\", bd.flags);",
"s->eir |= FEC_INT_RXF;",
"} else {",
"s->eir |= FEC_INT_RXB;",
"}",
"mcf_fec_write_bd(&bd, addr);",
"if ((bd.flags & FEC_BD_W) != 0) {",
"addr = s->erdsr;",
"} else {",
"addr += 8;",
"}",
"}",
"s->rx_descriptor = addr;",
"mcf_fec_enable_rx(s);",
"mcf_fec_update(s);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89,
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
]
] |
18,877 | static BlockDriverAIOCB *paio_submit(BlockDriverState *bs, int fd,
int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
BlockDriverCompletionFunc *cb, void *opaque, int type)
{
RawPosixAIOData *acb = g_slice_new(RawPosixAIOData);
acb->bs = bs;
acb->aio_type = type;
acb->aio_fildes = fd;
if (qiov) {
acb->aio_iov = qiov->iov;
acb->aio_niov = qiov->niov;
}
acb->aio_nbytes = nb_sectors * 512;
acb->aio_offset = sector_num * 512;
trace_paio_submit(acb, opaque, sector_num, nb_sectors, type);
return thread_pool_submit_aio(aio_worker, acb, cb, opaque);
}
| false | qemu | c4d9d19645a484298a67e9021060bc7c2b081d0f | static BlockDriverAIOCB *paio_submit(BlockDriverState *bs, int fd,
int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
BlockDriverCompletionFunc *cb, void *opaque, int type)
{
RawPosixAIOData *acb = g_slice_new(RawPosixAIOData);
acb->bs = bs;
acb->aio_type = type;
acb->aio_fildes = fd;
if (qiov) {
acb->aio_iov = qiov->iov;
acb->aio_niov = qiov->niov;
}
acb->aio_nbytes = nb_sectors * 512;
acb->aio_offset = sector_num * 512;
trace_paio_submit(acb, opaque, sector_num, nb_sectors, type);
return thread_pool_submit_aio(aio_worker, acb, cb, opaque);
}
| {
"code": [],
"line_no": []
} | static BlockDriverAIOCB *FUNC_0(BlockDriverState *bs, int fd,
int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
BlockDriverCompletionFunc *cb, void *opaque, int type)
{
RawPosixAIOData *acb = g_slice_new(RawPosixAIOData);
acb->bs = bs;
acb->aio_type = type;
acb->aio_fildes = fd;
if (qiov) {
acb->aio_iov = qiov->iov;
acb->aio_niov = qiov->niov;
}
acb->aio_nbytes = nb_sectors * 512;
acb->aio_offset = sector_num * 512;
trace_paio_submit(acb, opaque, sector_num, nb_sectors, type);
return thread_pool_submit_aio(aio_worker, acb, cb, opaque);
}
| [
"static BlockDriverAIOCB *FUNC_0(BlockDriverState *bs, int fd,\nint64_t sector_num, QEMUIOVector *qiov, int nb_sectors,\nBlockDriverCompletionFunc *cb, void *opaque, int type)\n{",
"RawPosixAIOData *acb = g_slice_new(RawPosixAIOData);",
"acb->bs = bs;",
"acb->aio_type = type;",
"acb->aio_fildes = fd;",
"if (qiov) {",
"acb->aio_iov = qiov->iov;",
"acb->aio_niov = qiov->niov;",
"}",
"acb->aio_nbytes = nb_sectors * 512;",
"acb->aio_offset = sector_num * 512;",
"trace_paio_submit(acb, opaque, sector_num, nb_sectors, type);",
"return thread_pool_submit_aio(aio_worker, acb, cb, opaque);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
]
] |
18,878 | static void fdt_add_pmu_nodes(const VirtMachineState *vms)
{
CPUState *cpu;
ARMCPU *armcpu;
uint32_t irqflags = GIC_FDT_IRQ_FLAGS_LEVEL_HI;
CPU_FOREACH(cpu) {
armcpu = ARM_CPU(cpu);
if (!arm_feature(&armcpu->env, ARM_FEATURE_PMU) ||
!kvm_arm_pmu_create(cpu, PPI(VIRTUAL_PMU_IRQ))) {
return;
}
}
if (vms->gic_version == 2) {
irqflags = deposit32(irqflags, GIC_FDT_IRQ_PPI_CPU_START,
GIC_FDT_IRQ_PPI_CPU_WIDTH,
(1 << vms->smp_cpus) - 1);
}
armcpu = ARM_CPU(qemu_get_cpu(0));
qemu_fdt_add_subnode(vms->fdt, "/pmu");
if (arm_feature(&armcpu->env, ARM_FEATURE_V8)) {
const char compat[] = "arm,armv8-pmuv3";
qemu_fdt_setprop(vms->fdt, "/pmu", "compatible",
compat, sizeof(compat));
qemu_fdt_setprop_cells(vms->fdt, "/pmu", "interrupts",
GIC_FDT_IRQ_TYPE_PPI, VIRTUAL_PMU_IRQ, irqflags);
}
}
| false | qemu | d6f02ce3b8a43ddd8f83553fe754a34b26fb273f | static void fdt_add_pmu_nodes(const VirtMachineState *vms)
{
CPUState *cpu;
ARMCPU *armcpu;
uint32_t irqflags = GIC_FDT_IRQ_FLAGS_LEVEL_HI;
CPU_FOREACH(cpu) {
armcpu = ARM_CPU(cpu);
if (!arm_feature(&armcpu->env, ARM_FEATURE_PMU) ||
!kvm_arm_pmu_create(cpu, PPI(VIRTUAL_PMU_IRQ))) {
return;
}
}
if (vms->gic_version == 2) {
irqflags = deposit32(irqflags, GIC_FDT_IRQ_PPI_CPU_START,
GIC_FDT_IRQ_PPI_CPU_WIDTH,
(1 << vms->smp_cpus) - 1);
}
armcpu = ARM_CPU(qemu_get_cpu(0));
qemu_fdt_add_subnode(vms->fdt, "/pmu");
if (arm_feature(&armcpu->env, ARM_FEATURE_V8)) {
const char compat[] = "arm,armv8-pmuv3";
qemu_fdt_setprop(vms->fdt, "/pmu", "compatible",
compat, sizeof(compat));
qemu_fdt_setprop_cells(vms->fdt, "/pmu", "interrupts",
GIC_FDT_IRQ_TYPE_PPI, VIRTUAL_PMU_IRQ, irqflags);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(const VirtMachineState *VAR_0)
{
CPUState *cpu;
ARMCPU *armcpu;
uint32_t irqflags = GIC_FDT_IRQ_FLAGS_LEVEL_HI;
CPU_FOREACH(cpu) {
armcpu = ARM_CPU(cpu);
if (!arm_feature(&armcpu->env, ARM_FEATURE_PMU) ||
!kvm_arm_pmu_create(cpu, PPI(VIRTUAL_PMU_IRQ))) {
return;
}
}
if (VAR_0->gic_version == 2) {
irqflags = deposit32(irqflags, GIC_FDT_IRQ_PPI_CPU_START,
GIC_FDT_IRQ_PPI_CPU_WIDTH,
(1 << VAR_0->smp_cpus) - 1);
}
armcpu = ARM_CPU(qemu_get_cpu(0));
qemu_fdt_add_subnode(VAR_0->fdt, "/pmu");
if (arm_feature(&armcpu->env, ARM_FEATURE_V8)) {
const char VAR_1[] = "arm,armv8-pmuv3";
qemu_fdt_setprop(VAR_0->fdt, "/pmu", "compatible",
VAR_1, sizeof(VAR_1));
qemu_fdt_setprop_cells(VAR_0->fdt, "/pmu", "interrupts",
GIC_FDT_IRQ_TYPE_PPI, VIRTUAL_PMU_IRQ, irqflags);
}
}
| [
"static void FUNC_0(const VirtMachineState *VAR_0)\n{",
"CPUState *cpu;",
"ARMCPU *armcpu;",
"uint32_t irqflags = GIC_FDT_IRQ_FLAGS_LEVEL_HI;",
"CPU_FOREACH(cpu) {",
"armcpu = ARM_CPU(cpu);",
"if (!arm_feature(&armcpu->env, ARM_FEATURE_PMU) ||\n!kvm_arm_pmu_create(cpu, PPI(VIRTUAL_PMU_IRQ))) {",
"return;",
"}",
"}",
"if (VAR_0->gic_version == 2) {",
"irqflags = deposit32(irqflags, GIC_FDT_IRQ_PPI_CPU_START,\nGIC_FDT_IRQ_PPI_CPU_WIDTH,\n(1 << VAR_0->smp_cpus) - 1);",
"}",
"armcpu = ARM_CPU(qemu_get_cpu(0));",
"qemu_fdt_add_subnode(VAR_0->fdt, \"/pmu\");",
"if (arm_feature(&armcpu->env, ARM_FEATURE_V8)) {",
"const char VAR_1[] = \"arm,armv8-pmuv3\";",
"qemu_fdt_setprop(VAR_0->fdt, \"/pmu\", \"compatible\",\nVAR_1, sizeof(VAR_1));",
"qemu_fdt_setprop_cells(VAR_0->fdt, \"/pmu\", \"interrupts\",\nGIC_FDT_IRQ_TYPE_PPI, VIRTUAL_PMU_IRQ, irqflags);",
"}",
"}"
] | [
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
],
[
29
],
[
31,
33,
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49,
51
],
[
53,
55
],
[
57
],
[
59
]
] |
18,879 | static int usb_ohci_initfn_pci(struct PCIDevice *dev)
{
OHCIPCIState *ohci = DO_UPCAST(OHCIPCIState, pci_dev, dev);
int num_ports = 3;
pci_config_set_vendor_id(ohci->pci_dev.config, PCI_VENDOR_ID_APPLE);
pci_config_set_device_id(ohci->pci_dev.config,
PCI_DEVICE_ID_APPLE_IPID_USB);
ohci->pci_dev.config[PCI_CLASS_PROG] = 0x10; /* OHCI */
pci_config_set_class(ohci->pci_dev.config, PCI_CLASS_SERIAL_USB);
/* TODO: RST# value should be 0. */
ohci->pci_dev.config[PCI_INTERRUPT_PIN] = 0x01; /* interrupt pin 1 */
usb_ohci_init(&ohci->state, &dev->qdev, num_ports, 0);
ohci->state.irq = ohci->pci_dev.irq[0];
/* TODO: avoid cast below by using dev */
pci_register_bar_simple(&ohci->pci_dev, 0, 256, 0, ohci->state.mem);
return 0;
}
| false | qemu | a8eae58556c7dc693d757a9144045fbee7434c6c | static int usb_ohci_initfn_pci(struct PCIDevice *dev)
{
OHCIPCIState *ohci = DO_UPCAST(OHCIPCIState, pci_dev, dev);
int num_ports = 3;
pci_config_set_vendor_id(ohci->pci_dev.config, PCI_VENDOR_ID_APPLE);
pci_config_set_device_id(ohci->pci_dev.config,
PCI_DEVICE_ID_APPLE_IPID_USB);
ohci->pci_dev.config[PCI_CLASS_PROG] = 0x10;
pci_config_set_class(ohci->pci_dev.config, PCI_CLASS_SERIAL_USB);
ohci->pci_dev.config[PCI_INTERRUPT_PIN] = 0x01;
usb_ohci_init(&ohci->state, &dev->qdev, num_ports, 0);
ohci->state.irq = ohci->pci_dev.irq[0];
pci_register_bar_simple(&ohci->pci_dev, 0, 256, 0, ohci->state.mem);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(struct PCIDevice *VAR_0)
{
OHCIPCIState *ohci = DO_UPCAST(OHCIPCIState, pci_dev, VAR_0);
int VAR_1 = 3;
pci_config_set_vendor_id(ohci->pci_dev.config, PCI_VENDOR_ID_APPLE);
pci_config_set_device_id(ohci->pci_dev.config,
PCI_DEVICE_ID_APPLE_IPID_USB);
ohci->pci_dev.config[PCI_CLASS_PROG] = 0x10;
pci_config_set_class(ohci->pci_dev.config, PCI_CLASS_SERIAL_USB);
ohci->pci_dev.config[PCI_INTERRUPT_PIN] = 0x01;
usb_ohci_init(&ohci->state, &VAR_0->qdev, VAR_1, 0);
ohci->state.irq = ohci->pci_dev.irq[0];
pci_register_bar_simple(&ohci->pci_dev, 0, 256, 0, ohci->state.mem);
return 0;
}
| [
"static int FUNC_0(struct PCIDevice *VAR_0)\n{",
"OHCIPCIState *ohci = DO_UPCAST(OHCIPCIState, pci_dev, VAR_0);",
"int VAR_1 = 3;",
"pci_config_set_vendor_id(ohci->pci_dev.config, PCI_VENDOR_ID_APPLE);",
"pci_config_set_device_id(ohci->pci_dev.config,\nPCI_DEVICE_ID_APPLE_IPID_USB);",
"ohci->pci_dev.config[PCI_CLASS_PROG] = 0x10;",
"pci_config_set_class(ohci->pci_dev.config, PCI_CLASS_SERIAL_USB);",
"ohci->pci_dev.config[PCI_INTERRUPT_PIN] = 0x01;",
"usb_ohci_init(&ohci->state, &VAR_0->qdev, VAR_1, 0);",
"ohci->state.irq = ohci->pci_dev.irq[0];",
"pci_register_bar_simple(&ohci->pci_dev, 0, 256, 0, ohci->state.mem);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13,
15
],
[
17
],
[
19
],
[
23
],
[
27
],
[
29
],
[
35
],
[
37
],
[
39
]
] |
18,880 | static int nbd_negotiate_read(QIOChannel *ioc, void *buffer, size_t size)
{
ssize_t ret;
guint watch;
assert(qemu_in_coroutine());
/* Negotiation are always in main loop. */
watch = qio_channel_add_watch(ioc,
G_IO_IN,
nbd_negotiate_continue,
qemu_coroutine_self(),
NULL);
ret = read_sync(ioc, buffer, size, NULL);
g_source_remove(watch);
return ret;
}
| false | qemu | d1fdf257d52822695f5ace6c586e059aa17d4b79 | static int nbd_negotiate_read(QIOChannel *ioc, void *buffer, size_t size)
{
ssize_t ret;
guint watch;
assert(qemu_in_coroutine());
watch = qio_channel_add_watch(ioc,
G_IO_IN,
nbd_negotiate_continue,
qemu_coroutine_self(),
NULL);
ret = read_sync(ioc, buffer, size, NULL);
g_source_remove(watch);
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(QIOChannel *VAR_0, void *VAR_1, size_t VAR_2)
{
ssize_t ret;
guint watch;
assert(qemu_in_coroutine());
watch = qio_channel_add_watch(VAR_0,
G_IO_IN,
nbd_negotiate_continue,
qemu_coroutine_self(),
NULL);
ret = read_sync(VAR_0, VAR_1, VAR_2, NULL);
g_source_remove(watch);
return ret;
}
| [
"static int FUNC_0(QIOChannel *VAR_0, void *VAR_1, size_t VAR_2)\n{",
"ssize_t ret;",
"guint watch;",
"assert(qemu_in_coroutine());",
"watch = qio_channel_add_watch(VAR_0,\nG_IO_IN,\nnbd_negotiate_continue,\nqemu_coroutine_self(),\nNULL);",
"ret = read_sync(VAR_0, VAR_1, VAR_2, NULL);",
"g_source_remove(watch);",
"return ret;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15,
17,
19,
21,
23
],
[
25
],
[
27
],
[
29
],
[
33
]
] |
18,881 | static inline void sdhci_reset_write(SDHCIState *s, uint8_t value)
{
switch (value) {
case SDHC_RESET_ALL:
DEVICE_GET_CLASS(s)->reset(DEVICE(s));
break;
case SDHC_RESET_CMD:
s->prnsts &= ~SDHC_CMD_INHIBIT;
s->norintsts &= ~SDHC_NIS_CMDCMP;
break;
case SDHC_RESET_DATA:
s->data_count = 0;
s->prnsts &= ~(SDHC_SPACE_AVAILABLE | SDHC_DATA_AVAILABLE |
SDHC_DOING_READ | SDHC_DOING_WRITE |
SDHC_DATA_INHIBIT | SDHC_DAT_LINE_ACTIVE);
s->blkgap &= ~(SDHC_STOP_AT_GAP_REQ | SDHC_CONTINUE_REQ);
s->stopped_state = sdhc_not_stopped;
s->norintsts &= ~(SDHC_NIS_WBUFRDY | SDHC_NIS_RBUFRDY |
SDHC_NIS_DMA | SDHC_NIS_TRSCMP | SDHC_NIS_BLKGAP);
break;
}
}
| false | qemu | d368ba4376b2c1c24175c74b3733b8fe64dbe8a6 | static inline void sdhci_reset_write(SDHCIState *s, uint8_t value)
{
switch (value) {
case SDHC_RESET_ALL:
DEVICE_GET_CLASS(s)->reset(DEVICE(s));
break;
case SDHC_RESET_CMD:
s->prnsts &= ~SDHC_CMD_INHIBIT;
s->norintsts &= ~SDHC_NIS_CMDCMP;
break;
case SDHC_RESET_DATA:
s->data_count = 0;
s->prnsts &= ~(SDHC_SPACE_AVAILABLE | SDHC_DATA_AVAILABLE |
SDHC_DOING_READ | SDHC_DOING_WRITE |
SDHC_DATA_INHIBIT | SDHC_DAT_LINE_ACTIVE);
s->blkgap &= ~(SDHC_STOP_AT_GAP_REQ | SDHC_CONTINUE_REQ);
s->stopped_state = sdhc_not_stopped;
s->norintsts &= ~(SDHC_NIS_WBUFRDY | SDHC_NIS_RBUFRDY |
SDHC_NIS_DMA | SDHC_NIS_TRSCMP | SDHC_NIS_BLKGAP);
break;
}
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0(SDHCIState *VAR_0, uint8_t VAR_1)
{
switch (VAR_1) {
case SDHC_RESET_ALL:
DEVICE_GET_CLASS(VAR_0)->reset(DEVICE(VAR_0));
break;
case SDHC_RESET_CMD:
VAR_0->prnsts &= ~SDHC_CMD_INHIBIT;
VAR_0->norintsts &= ~SDHC_NIS_CMDCMP;
break;
case SDHC_RESET_DATA:
VAR_0->data_count = 0;
VAR_0->prnsts &= ~(SDHC_SPACE_AVAILABLE | SDHC_DATA_AVAILABLE |
SDHC_DOING_READ | SDHC_DOING_WRITE |
SDHC_DATA_INHIBIT | SDHC_DAT_LINE_ACTIVE);
VAR_0->blkgap &= ~(SDHC_STOP_AT_GAP_REQ | SDHC_CONTINUE_REQ);
VAR_0->stopped_state = sdhc_not_stopped;
VAR_0->norintsts &= ~(SDHC_NIS_WBUFRDY | SDHC_NIS_RBUFRDY |
SDHC_NIS_DMA | SDHC_NIS_TRSCMP | SDHC_NIS_BLKGAP);
break;
}
}
| [
"static inline void FUNC_0(SDHCIState *VAR_0, uint8_t VAR_1)\n{",
"switch (VAR_1) {",
"case SDHC_RESET_ALL:\nDEVICE_GET_CLASS(VAR_0)->reset(DEVICE(VAR_0));",
"break;",
"case SDHC_RESET_CMD:\nVAR_0->prnsts &= ~SDHC_CMD_INHIBIT;",
"VAR_0->norintsts &= ~SDHC_NIS_CMDCMP;",
"break;",
"case SDHC_RESET_DATA:\nVAR_0->data_count = 0;",
"VAR_0->prnsts &= ~(SDHC_SPACE_AVAILABLE | SDHC_DATA_AVAILABLE |\nSDHC_DOING_READ | SDHC_DOING_WRITE |\nSDHC_DATA_INHIBIT | SDHC_DAT_LINE_ACTIVE);",
"VAR_0->blkgap &= ~(SDHC_STOP_AT_GAP_REQ | SDHC_CONTINUE_REQ);",
"VAR_0->stopped_state = sdhc_not_stopped;",
"VAR_0->norintsts &= ~(SDHC_NIS_WBUFRDY | SDHC_NIS_RBUFRDY |\nSDHC_NIS_DMA | SDHC_NIS_TRSCMP | SDHC_NIS_BLKGAP);",
"break;",
"}",
"}"
] | [
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
]
] |
18,882 | static void print_report(OutputFile *output_files,
OutputStream *ost_table, int nb_ostreams,
int is_last_report, int64_t timer_start)
{
char buf[1024];
OutputStream *ost;
AVFormatContext *oc;
int64_t total_size;
AVCodecContext *enc;
int frame_number, vid, i;
double bitrate;
int64_t pts = INT64_MAX;
static int64_t last_time = -1;
static int qp_histogram[52];
int hours, mins, secs, us;
if (!is_last_report) {
int64_t cur_time;
/* display the report every 0.5 seconds */
cur_time = av_gettime();
if (last_time == -1) {
last_time = cur_time;
return;
}
if ((cur_time - last_time) < 500000)
return;
last_time = cur_time;
}
oc = output_files[0].ctx;
total_size = avio_size(oc->pb);
if(total_size<0) // FIXME improve avio_size() so it works with non seekable output too
total_size= avio_tell(oc->pb);
buf[0] = '\0';
vid = 0;
for(i=0;i<nb_ostreams;i++) {
float q = -1;
ost = &ost_table[i];
enc = ost->st->codec;
if (!ost->st->stream_copy && enc->coded_frame)
q = enc->coded_frame->quality/(float)FF_QP2LAMBDA;
if (vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) {
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "q=%2.1f ", q);
}
if (!vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) {
float t = (av_gettime()-timer_start) / 1000000.0;
frame_number = ost->frame_number;
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "frame=%5d fps=%3d q=%3.1f ",
frame_number, (t>1)?(int)(frame_number/t+0.5) : 0, q);
if(is_last_report)
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "L");
if(qp_hist){
int j;
int qp = lrintf(q);
if(qp>=0 && qp<FF_ARRAY_ELEMS(qp_histogram))
qp_histogram[qp]++;
for(j=0; j<32; j++)
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "%X", (int)lrintf(log(qp_histogram[j]+1)/log(2)));
}
if (enc->flags&CODEC_FLAG_PSNR){
int j;
double error, error_sum=0;
double scale, scale_sum=0;
char type[3]= {'Y','U','V'};
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "PSNR=");
for(j=0; j<3; j++){
if(is_last_report){
error= enc->error[j];
scale= enc->width*enc->height*255.0*255.0*frame_number;
}else{
error= enc->coded_frame->error[j];
scale= enc->width*enc->height*255.0*255.0;
}
if(j) scale/=4;
error_sum += error;
scale_sum += scale;
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "%c:%2.2f ", type[j], psnr(error/scale));
}
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "*:%2.2f ", psnr(error_sum/scale_sum));
}
vid = 1;
}
/* compute min output value */
pts = FFMIN(pts, av_rescale_q(ost->st->pts.val,
ost->st->time_base, AV_TIME_BASE_Q));
}
secs = pts / AV_TIME_BASE;
us = pts % AV_TIME_BASE;
mins = secs / 60;
secs %= 60;
hours = mins / 60;
mins %= 60;
bitrate = pts ? total_size * 8 / (pts / 1000.0) : 0;
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
"size=%8.0fkB time=", total_size / 1024.0);
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
"%02d:%02d:%02d.%02d ", hours, mins, secs,
(100 * us) / AV_TIME_BASE);
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
"bitrate=%6.1fkbits/s", bitrate);
if (nb_frames_dup || nb_frames_drop)
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " dup=%d drop=%d",
nb_frames_dup, nb_frames_drop);
av_log(NULL, is_last_report ? AV_LOG_WARNING : AV_LOG_INFO, "%s \r", buf);
fflush(stderr);
if (is_last_report) {
int64_t raw= audio_size + video_size + extra_size;
av_log(NULL, AV_LOG_INFO, "\n");
av_log(NULL, AV_LOG_INFO, "video:%1.0fkB audio:%1.0fkB global headers:%1.0fkB muxing overhead %f%%\n",
video_size/1024.0,
audio_size/1024.0,
extra_size/1024.0,
100.0*(total_size - raw)/raw
);
}
}
| false | FFmpeg | c09abba1d9e0c30c8720199af3e17bf69ed0ed78 | static void print_report(OutputFile *output_files,
OutputStream *ost_table, int nb_ostreams,
int is_last_report, int64_t timer_start)
{
char buf[1024];
OutputStream *ost;
AVFormatContext *oc;
int64_t total_size;
AVCodecContext *enc;
int frame_number, vid, i;
double bitrate;
int64_t pts = INT64_MAX;
static int64_t last_time = -1;
static int qp_histogram[52];
int hours, mins, secs, us;
if (!is_last_report) {
int64_t cur_time;
cur_time = av_gettime();
if (last_time == -1) {
last_time = cur_time;
return;
}
if ((cur_time - last_time) < 500000)
return;
last_time = cur_time;
}
oc = output_files[0].ctx;
total_size = avio_size(oc->pb);
if(total_size<0)
total_size= avio_tell(oc->pb);
buf[0] = '\0';
vid = 0;
for(i=0;i<nb_ostreams;i++) {
float q = -1;
ost = &ost_table[i];
enc = ost->st->codec;
if (!ost->st->stream_copy && enc->coded_frame)
q = enc->coded_frame->quality/(float)FF_QP2LAMBDA;
if (vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) {
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "q=%2.1f ", q);
}
if (!vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) {
float t = (av_gettime()-timer_start) / 1000000.0;
frame_number = ost->frame_number;
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "frame=%5d fps=%3d q=%3.1f ",
frame_number, (t>1)?(int)(frame_number/t+0.5) : 0, q);
if(is_last_report)
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "L");
if(qp_hist){
int j;
int qp = lrintf(q);
if(qp>=0 && qp<FF_ARRAY_ELEMS(qp_histogram))
qp_histogram[qp]++;
for(j=0; j<32; j++)
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "%X", (int)lrintf(log(qp_histogram[j]+1)/log(2)));
}
if (enc->flags&CODEC_FLAG_PSNR){
int j;
double error, error_sum=0;
double scale, scale_sum=0;
char type[3]= {'Y','U','V'};
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "PSNR=");
for(j=0; j<3; j++){
if(is_last_report){
error= enc->error[j];
scale= enc->width*enc->height*255.0*255.0*frame_number;
}else{
error= enc->coded_frame->error[j];
scale= enc->width*enc->height*255.0*255.0;
}
if(j) scale/=4;
error_sum += error;
scale_sum += scale;
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "%c:%2.2f ", type[j], psnr(error/scale));
}
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "*:%2.2f ", psnr(error_sum/scale_sum));
}
vid = 1;
}
pts = FFMIN(pts, av_rescale_q(ost->st->pts.val,
ost->st->time_base, AV_TIME_BASE_Q));
}
secs = pts / AV_TIME_BASE;
us = pts % AV_TIME_BASE;
mins = secs / 60;
secs %= 60;
hours = mins / 60;
mins %= 60;
bitrate = pts ? total_size * 8 / (pts / 1000.0) : 0;
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
"size=%8.0fkB time=", total_size / 1024.0);
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
"%02d:%02d:%02d.%02d ", hours, mins, secs,
(100 * us) / AV_TIME_BASE);
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
"bitrate=%6.1fkbits/s", bitrate);
if (nb_frames_dup || nb_frames_drop)
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " dup=%d drop=%d",
nb_frames_dup, nb_frames_drop);
av_log(NULL, is_last_report ? AV_LOG_WARNING : AV_LOG_INFO, "%s \r", buf);
fflush(stderr);
if (is_last_report) {
int64_t raw= audio_size + video_size + extra_size;
av_log(NULL, AV_LOG_INFO, "\n");
av_log(NULL, AV_LOG_INFO, "video:%1.0fkB audio:%1.0fkB global headers:%1.0fkB muxing overhead %f%%\n",
video_size/1024.0,
audio_size/1024.0,
extra_size/1024.0,
100.0*(total_size - raw)/raw
);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(OutputFile *VAR_0,
OutputStream *VAR_1, int VAR_2,
int VAR_3, int64_t VAR_4)
{
char VAR_5[1024];
OutputStream *ost;
AVFormatContext *oc;
int64_t total_size;
AVCodecContext *enc;
int VAR_6, VAR_7, VAR_8;
double VAR_9;
int64_t pts = INT64_MAX;
static int64_t VAR_10 = -1;
static int VAR_11[52];
int VAR_12, VAR_13, VAR_14, VAR_15;
if (!VAR_3) {
int64_t cur_time;
cur_time = av_gettime();
if (VAR_10 == -1) {
VAR_10 = cur_time;
return;
}
if ((cur_time - VAR_10) < 500000)
return;
VAR_10 = cur_time;
}
oc = VAR_0[0].ctx;
total_size = avio_size(oc->pb);
if(total_size<0)
total_size= avio_tell(oc->pb);
VAR_5[0] = '\0';
VAR_7 = 0;
for(VAR_8=0;VAR_8<VAR_2;VAR_8++) {
float VAR_16 = -1;
ost = &VAR_1[VAR_8];
enc = ost->st->codec;
if (!ost->st->stream_copy && enc->coded_frame)
VAR_16 = enc->coded_frame->quality/(float)FF_QP2LAMBDA;
if (VAR_7 && enc->codec_type == AVMEDIA_TYPE_VIDEO) {
snprintf(VAR_5 + strlen(VAR_5), sizeof(VAR_5) - strlen(VAR_5), "VAR_16=%2.1f ", VAR_16);
}
if (!VAR_7 && enc->codec_type == AVMEDIA_TYPE_VIDEO) {
float VAR_17 = (av_gettime()-VAR_4) / 1000000.0;
VAR_6 = ost->VAR_6;
snprintf(VAR_5 + strlen(VAR_5), sizeof(VAR_5) - strlen(VAR_5), "frame=%5d fps=%3d VAR_16=%3.1f ",
VAR_6, (VAR_17>1)?(int)(VAR_6/VAR_17+0.5) : 0, VAR_16);
if(VAR_3)
snprintf(VAR_5 + strlen(VAR_5), sizeof(VAR_5) - strlen(VAR_5), "L");
if(qp_hist){
int VAR_20;
int VAR_19 = lrintf(VAR_16);
if(VAR_19>=0 && VAR_19<FF_ARRAY_ELEMS(VAR_11))
VAR_11[VAR_19]++;
for(VAR_20=0; VAR_20<32; VAR_20++)
snprintf(VAR_5 + strlen(VAR_5), sizeof(VAR_5) - strlen(VAR_5), "%X", (int)lrintf(log(VAR_11[VAR_20]+1)/log(2)));
}
if (enc->flags&CODEC_FLAG_PSNR){
int VAR_20;
double VAR_20, VAR_21=0;
double VAR_22, VAR_23=0;
char VAR_24[3]= {'Y','U','V'};
snprintf(VAR_5 + strlen(VAR_5), sizeof(VAR_5) - strlen(VAR_5), "PSNR=");
for(VAR_20=0; VAR_20<3; VAR_20++){
if(VAR_3){
VAR_20= enc->VAR_20[VAR_20];
VAR_22= enc->width*enc->height*255.0*255.0*VAR_6;
}else{
VAR_20= enc->coded_frame->VAR_20[VAR_20];
VAR_22= enc->width*enc->height*255.0*255.0;
}
if(VAR_20) VAR_22/=4;
VAR_21 += VAR_20;
VAR_23 += VAR_22;
snprintf(VAR_5 + strlen(VAR_5), sizeof(VAR_5) - strlen(VAR_5), "%c:%2.2f ", VAR_24[VAR_20], psnr(VAR_20/VAR_22));
}
snprintf(VAR_5 + strlen(VAR_5), sizeof(VAR_5) - strlen(VAR_5), "*:%2.2f ", psnr(VAR_21/VAR_23));
}
VAR_7 = 1;
}
pts = FFMIN(pts, av_rescale_q(ost->st->pts.val,
ost->st->time_base, AV_TIME_BASE_Q));
}
VAR_14 = pts / AV_TIME_BASE;
VAR_15 = pts % AV_TIME_BASE;
VAR_13 = VAR_14 / 60;
VAR_14 %= 60;
VAR_12 = VAR_13 / 60;
VAR_13 %= 60;
VAR_9 = pts ? total_size * 8 / (pts / 1000.0) : 0;
snprintf(VAR_5 + strlen(VAR_5), sizeof(VAR_5) - strlen(VAR_5),
"size=%8.0fkB time=", total_size / 1024.0);
snprintf(VAR_5 + strlen(VAR_5), sizeof(VAR_5) - strlen(VAR_5),
"%02d:%02d:%02d.%02d ", VAR_12, VAR_13, VAR_14,
(100 * VAR_15) / AV_TIME_BASE);
snprintf(VAR_5 + strlen(VAR_5), sizeof(VAR_5) - strlen(VAR_5),
"VAR_9=%6.1fkbits/s", VAR_9);
if (nb_frames_dup || nb_frames_drop)
snprintf(VAR_5 + strlen(VAR_5), sizeof(VAR_5) - strlen(VAR_5), " dup=%d drop=%d",
nb_frames_dup, nb_frames_drop);
av_log(NULL, VAR_3 ? AV_LOG_WARNING : AV_LOG_INFO, "%s \r", VAR_5);
fflush(stderr);
if (VAR_3) {
int64_t raw= audio_size + video_size + extra_size;
av_log(NULL, AV_LOG_INFO, "\n");
av_log(NULL, AV_LOG_INFO, "video:%1.0fkB audio:%1.0fkB global headers:%1.0fkB muxing overhead %f%%\n",
video_size/1024.0,
audio_size/1024.0,
extra_size/1024.0,
100.0*(total_size - raw)/raw
);
}
}
| [
"static void FUNC_0(OutputFile *VAR_0,\nOutputStream *VAR_1, int VAR_2,\nint VAR_3, int64_t VAR_4)\n{",
"char VAR_5[1024];",
"OutputStream *ost;",
"AVFormatContext *oc;",
"int64_t total_size;",
"AVCodecContext *enc;",
"int VAR_6, VAR_7, VAR_8;",
"double VAR_9;",
"int64_t pts = INT64_MAX;",
"static int64_t VAR_10 = -1;",
"static int VAR_11[52];",
"int VAR_12, VAR_13, VAR_14, VAR_15;",
"if (!VAR_3) {",
"int64_t cur_time;",
"cur_time = av_gettime();",
"if (VAR_10 == -1) {",
"VAR_10 = cur_time;",
"return;",
"}",
"if ((cur_time - VAR_10) < 500000)\nreturn;",
"VAR_10 = cur_time;",
"}",
"oc = VAR_0[0].ctx;",
"total_size = avio_size(oc->pb);",
"if(total_size<0)\ntotal_size= avio_tell(oc->pb);",
"VAR_5[0] = '\\0';",
"VAR_7 = 0;",
"for(VAR_8=0;VAR_8<VAR_2;VAR_8++) {",
"float VAR_16 = -1;",
"ost = &VAR_1[VAR_8];",
"enc = ost->st->codec;",
"if (!ost->st->stream_copy && enc->coded_frame)\nVAR_16 = enc->coded_frame->quality/(float)FF_QP2LAMBDA;",
"if (VAR_7 && enc->codec_type == AVMEDIA_TYPE_VIDEO) {",
"snprintf(VAR_5 + strlen(VAR_5), sizeof(VAR_5) - strlen(VAR_5), \"VAR_16=%2.1f \", VAR_16);",
"}",
"if (!VAR_7 && enc->codec_type == AVMEDIA_TYPE_VIDEO) {",
"float VAR_17 = (av_gettime()-VAR_4) / 1000000.0;",
"VAR_6 = ost->VAR_6;",
"snprintf(VAR_5 + strlen(VAR_5), sizeof(VAR_5) - strlen(VAR_5), \"frame=%5d fps=%3d VAR_16=%3.1f \",\nVAR_6, (VAR_17>1)?(int)(VAR_6/VAR_17+0.5) : 0, VAR_16);",
"if(VAR_3)\nsnprintf(VAR_5 + strlen(VAR_5), sizeof(VAR_5) - strlen(VAR_5), \"L\");",
"if(qp_hist){",
"int VAR_20;",
"int VAR_19 = lrintf(VAR_16);",
"if(VAR_19>=0 && VAR_19<FF_ARRAY_ELEMS(VAR_11))\nVAR_11[VAR_19]++;",
"for(VAR_20=0; VAR_20<32; VAR_20++)",
"snprintf(VAR_5 + strlen(VAR_5), sizeof(VAR_5) - strlen(VAR_5), \"%X\", (int)lrintf(log(VAR_11[VAR_20]+1)/log(2)));",
"}",
"if (enc->flags&CODEC_FLAG_PSNR){",
"int VAR_20;",
"double VAR_20, VAR_21=0;",
"double VAR_22, VAR_23=0;",
"char VAR_24[3]= {'Y','U','V'};",
"snprintf(VAR_5 + strlen(VAR_5), sizeof(VAR_5) - strlen(VAR_5), \"PSNR=\");",
"for(VAR_20=0; VAR_20<3; VAR_20++){",
"if(VAR_3){",
"VAR_20= enc->VAR_20[VAR_20];",
"VAR_22= enc->width*enc->height*255.0*255.0*VAR_6;",
"}else{",
"VAR_20= enc->coded_frame->VAR_20[VAR_20];",
"VAR_22= enc->width*enc->height*255.0*255.0;",
"}",
"if(VAR_20) VAR_22/=4;",
"VAR_21 += VAR_20;",
"VAR_23 += VAR_22;",
"snprintf(VAR_5 + strlen(VAR_5), sizeof(VAR_5) - strlen(VAR_5), \"%c:%2.2f \", VAR_24[VAR_20], psnr(VAR_20/VAR_22));",
"}",
"snprintf(VAR_5 + strlen(VAR_5), sizeof(VAR_5) - strlen(VAR_5), \"*:%2.2f \", psnr(VAR_21/VAR_23));",
"}",
"VAR_7 = 1;",
"}",
"pts = FFMIN(pts, av_rescale_q(ost->st->pts.val,\nost->st->time_base, AV_TIME_BASE_Q));",
"}",
"VAR_14 = pts / AV_TIME_BASE;",
"VAR_15 = pts % AV_TIME_BASE;",
"VAR_13 = VAR_14 / 60;",
"VAR_14 %= 60;",
"VAR_12 = VAR_13 / 60;",
"VAR_13 %= 60;",
"VAR_9 = pts ? total_size * 8 / (pts / 1000.0) : 0;",
"snprintf(VAR_5 + strlen(VAR_5), sizeof(VAR_5) - strlen(VAR_5),\n\"size=%8.0fkB time=\", total_size / 1024.0);",
"snprintf(VAR_5 + strlen(VAR_5), sizeof(VAR_5) - strlen(VAR_5),\n\"%02d:%02d:%02d.%02d \", VAR_12, VAR_13, VAR_14,\n(100 * VAR_15) / AV_TIME_BASE);",
"snprintf(VAR_5 + strlen(VAR_5), sizeof(VAR_5) - strlen(VAR_5),\n\"VAR_9=%6.1fkbits/s\", VAR_9);",
"if (nb_frames_dup || nb_frames_drop)\nsnprintf(VAR_5 + strlen(VAR_5), sizeof(VAR_5) - strlen(VAR_5), \" dup=%d drop=%d\",\nnb_frames_dup, nb_frames_drop);",
"av_log(NULL, VAR_3 ? AV_LOG_WARNING : AV_LOG_INFO, \"%s \\r\", VAR_5);",
"fflush(stderr);",
"if (VAR_3) {",
"int64_t raw= audio_size + video_size + extra_size;",
"av_log(NULL, AV_LOG_INFO, \"\\n\");",
"av_log(NULL, AV_LOG_INFO, \"video:%1.0fkB audio:%1.0fkB global headers:%1.0fkB muxing overhead %f%%\\n\",\nvideo_size/1024.0,\naudio_size/1024.0,\nextra_size/1024.0,\n100.0*(total_size - raw)/raw\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,
0,
0,
0,
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
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49,
51
],
[
53
],
[
55
],
[
61
],
[
65
],
[
67,
69
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85,
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101
],
[
103,
105
],
[
107,
109
],
[
111
],
[
113
],
[
115
],
[
117,
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
175,
177
],
[
179
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
197
],
[
201,
203
],
[
205,
207,
209
],
[
211,
213
],
[
217,
219,
221
],
[
225
],
[
229
],
[
233
],
[
235
],
[
237
],
[
239,
241,
243,
245,
247,
249
],
[
251
],
[
253
]
] |
18,884 | static int ohci_bus_start(OHCIState *ohci)
{
ohci->eof_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL,
ohci_frame_boundary,
ohci);
if (ohci->eof_timer == NULL) {
trace_usb_ohci_bus_eof_timer_failed(ohci->name);
ohci_die(ohci);
return 0;
}
trace_usb_ohci_start(ohci->name);
ohci_sof(ohci);
return 1;
}
| false | qemu | fd0a10cd20a1c5ae829be32f3364dae88f435c4e | static int ohci_bus_start(OHCIState *ohci)
{
ohci->eof_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL,
ohci_frame_boundary,
ohci);
if (ohci->eof_timer == NULL) {
trace_usb_ohci_bus_eof_timer_failed(ohci->name);
ohci_die(ohci);
return 0;
}
trace_usb_ohci_start(ohci->name);
ohci_sof(ohci);
return 1;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(OHCIState *VAR_0)
{
VAR_0->eof_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL,
ohci_frame_boundary,
VAR_0);
if (VAR_0->eof_timer == NULL) {
trace_usb_ohci_bus_eof_timer_failed(VAR_0->name);
ohci_die(VAR_0);
return 0;
}
trace_usb_ohci_start(VAR_0->name);
ohci_sof(VAR_0);
return 1;
}
| [
"static int FUNC_0(OHCIState *VAR_0)\n{",
"VAR_0->eof_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL,\nohci_frame_boundary,\nVAR_0);",
"if (VAR_0->eof_timer == NULL) {",
"trace_usb_ohci_bus_eof_timer_failed(VAR_0->name);",
"ohci_die(VAR_0);",
"return 0;",
"}",
"trace_usb_ohci_start(VAR_0->name);",
"ohci_sof(VAR_0);",
"return 1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7,
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
29
],
[
33
],
[
35
]
] |
18,885 | static void arm_thistimer_write(void *opaque, target_phys_addr_t addr,
uint64_t value, unsigned size)
{
arm_mptimer_state *s = (arm_mptimer_state *)opaque;
int id = get_current_cpu(s);
timerblock_write(&s->timerblock[id * 2], addr, value, size);
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static void arm_thistimer_write(void *opaque, target_phys_addr_t addr,
uint64_t value, unsigned size)
{
arm_mptimer_state *s = (arm_mptimer_state *)opaque;
int id = get_current_cpu(s);
timerblock_write(&s->timerblock[id * 2], addr, value, size);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,
uint64_t VAR_2, unsigned VAR_3)
{
arm_mptimer_state *s = (arm_mptimer_state *)VAR_0;
int VAR_4 = get_current_cpu(s);
timerblock_write(&s->timerblock[VAR_4 * 2], VAR_1, VAR_2, VAR_3);
}
| [
"static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{",
"arm_mptimer_state *s = (arm_mptimer_state *)VAR_0;",
"int VAR_4 = get_current_cpu(s);",
"timerblock_write(&s->timerblock[VAR_4 * 2], VAR_1, VAR_2, VAR_3);",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
]
] |
18,886 | long do_rt_sigreturn(CPUX86State *env)
{
abi_ulong frame_addr;
struct rt_sigframe *frame;
sigset_t set;
int eax;
frame_addr = env->regs[R_ESP] - 4;
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1))
goto badframe;
target_to_host_sigset(&set, &frame->uc.tuc_sigmask);
sigprocmask(SIG_SETMASK, &set, NULL);
if (restore_sigcontext(env, &frame->uc.tuc_mcontext, &eax))
goto badframe;
if (do_sigaltstack(frame_addr + offsetof(struct rt_sigframe, uc.tuc_stack), 0,
get_sp_from_cpustate(env)) == -EFAULT)
goto badframe;
unlock_user_struct(frame, frame_addr, 0);
return eax;
badframe:
unlock_user_struct(frame, frame_addr, 0);
force_sig(TARGET_SIGSEGV);
return 0;
}
| false | qemu | 1c275925bfbbc2de84a8f0e09d1dd70bbefb6da3 | long do_rt_sigreturn(CPUX86State *env)
{
abi_ulong frame_addr;
struct rt_sigframe *frame;
sigset_t set;
int eax;
frame_addr = env->regs[R_ESP] - 4;
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1))
goto badframe;
target_to_host_sigset(&set, &frame->uc.tuc_sigmask);
sigprocmask(SIG_SETMASK, &set, NULL);
if (restore_sigcontext(env, &frame->uc.tuc_mcontext, &eax))
goto badframe;
if (do_sigaltstack(frame_addr + offsetof(struct rt_sigframe, uc.tuc_stack), 0,
get_sp_from_cpustate(env)) == -EFAULT)
goto badframe;
unlock_user_struct(frame, frame_addr, 0);
return eax;
badframe:
unlock_user_struct(frame, frame_addr, 0);
force_sig(TARGET_SIGSEGV);
return 0;
}
| {
"code": [],
"line_no": []
} | long FUNC_0(CPUX86State *VAR_0)
{
abi_ulong frame_addr;
struct rt_sigframe *VAR_1;
sigset_t set;
int VAR_2;
frame_addr = VAR_0->regs[R_ESP] - 4;
if (!lock_user_struct(VERIFY_READ, VAR_1, frame_addr, 1))
goto badframe;
target_to_host_sigset(&set, &VAR_1->uc.tuc_sigmask);
sigprocmask(SIG_SETMASK, &set, NULL);
if (restore_sigcontext(VAR_0, &VAR_1->uc.tuc_mcontext, &VAR_2))
goto badframe;
if (do_sigaltstack(frame_addr + offsetof(struct rt_sigframe, uc.tuc_stack), 0,
get_sp_from_cpustate(VAR_0)) == -EFAULT)
goto badframe;
unlock_user_struct(VAR_1, frame_addr, 0);
return VAR_2;
badframe:
unlock_user_struct(VAR_1, frame_addr, 0);
force_sig(TARGET_SIGSEGV);
return 0;
}
| [
"long FUNC_0(CPUX86State *VAR_0)\n{",
"abi_ulong frame_addr;",
"struct rt_sigframe *VAR_1;",
"sigset_t set;",
"int VAR_2;",
"frame_addr = VAR_0->regs[R_ESP] - 4;",
"if (!lock_user_struct(VERIFY_READ, VAR_1, frame_addr, 1))\ngoto badframe;",
"target_to_host_sigset(&set, &VAR_1->uc.tuc_sigmask);",
"sigprocmask(SIG_SETMASK, &set, NULL);",
"if (restore_sigcontext(VAR_0, &VAR_1->uc.tuc_mcontext, &VAR_2))\ngoto badframe;",
"if (do_sigaltstack(frame_addr + offsetof(struct rt_sigframe, uc.tuc_stack), 0,\nget_sp_from_cpustate(VAR_0)) == -EFAULT)\ngoto badframe;",
"unlock_user_struct(VAR_1, frame_addr, 0);",
"return VAR_2;",
"badframe:\nunlock_user_struct(VAR_1, frame_addr, 0);",
"force_sig(TARGET_SIGSEGV);",
"return 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
],
[
41
],
[
43
],
[
47,
49
],
[
51
],
[
53
],
[
55
]
] |
18,887 | int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src)
{
const AVCodec *orig_codec = dest->codec;
uint8_t *orig_priv_data = dest->priv_data;
if (avcodec_is_open(dest)) { // check that the dest context is uninitialized
av_log(dest, AV_LOG_ERROR,
"Tried to copy AVCodecContext %p into already-initialized %p\n",
src, dest);
return AVERROR(EINVAL);
}
av_opt_free(dest);
av_free(dest->priv_data);
memcpy(dest, src, sizeof(*dest));
dest->priv_data = orig_priv_data;
dest->codec = orig_codec;
/* set values specific to opened codecs back to their default state */
dest->slice_offset = NULL;
dest->hwaccel = NULL;
dest->internal = NULL;
/* reallocate values that should be allocated separately */
dest->rc_eq = NULL;
dest->extradata = NULL;
dest->intra_matrix = NULL;
dest->inter_matrix = NULL;
dest->rc_override = NULL;
dest->subtitle_header = NULL;
if (src->rc_eq) {
dest->rc_eq = av_strdup(src->rc_eq);
if (!dest->rc_eq)
return AVERROR(ENOMEM);
}
#define alloc_and_copy_or_fail(obj, size, pad) \
if (src->obj && size > 0) { \
dest->obj = av_malloc(size + pad); \
if (!dest->obj) \
goto fail; \
memcpy(dest->obj, src->obj, size); \
if (pad) \
memset(((uint8_t *) dest->obj) + size, 0, pad); \
}
alloc_and_copy_or_fail(extradata, src->extradata_size,
FF_INPUT_BUFFER_PADDING_SIZE);
alloc_and_copy_or_fail(intra_matrix, 64 * sizeof(int16_t), 0);
alloc_and_copy_or_fail(inter_matrix, 64 * sizeof(int16_t), 0);
alloc_and_copy_or_fail(rc_override, src->rc_override_count * sizeof(*src->rc_override), 0);
alloc_and_copy_or_fail(subtitle_header, src->subtitle_header_size, 1);
dest->subtitle_header_size = src->subtitle_header_size;
#undef alloc_and_copy_or_fail
return 0;
fail:
av_freep(&dest->rc_override);
av_freep(&dest->intra_matrix);
av_freep(&dest->inter_matrix);
av_freep(&dest->extradata);
av_freep(&dest->rc_eq);
return AVERROR(ENOMEM);
}
| false | FFmpeg | 97f856a4c27129f99f2c7a41f7eb33a0d86917f8 | int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src)
{
const AVCodec *orig_codec = dest->codec;
uint8_t *orig_priv_data = dest->priv_data;
if (avcodec_is_open(dest)) {
av_log(dest, AV_LOG_ERROR,
"Tried to copy AVCodecContext %p into already-initialized %p\n",
src, dest);
return AVERROR(EINVAL);
}
av_opt_free(dest);
av_free(dest->priv_data);
memcpy(dest, src, sizeof(*dest));
dest->priv_data = orig_priv_data;
dest->codec = orig_codec;
dest->slice_offset = NULL;
dest->hwaccel = NULL;
dest->internal = NULL;
dest->rc_eq = NULL;
dest->extradata = NULL;
dest->intra_matrix = NULL;
dest->inter_matrix = NULL;
dest->rc_override = NULL;
dest->subtitle_header = NULL;
if (src->rc_eq) {
dest->rc_eq = av_strdup(src->rc_eq);
if (!dest->rc_eq)
return AVERROR(ENOMEM);
}
#define alloc_and_copy_or_fail(obj, size, pad) \
if (src->obj && size > 0) { \
dest->obj = av_malloc(size + pad); \
if (!dest->obj) \
goto fail; \
memcpy(dest->obj, src->obj, size); \
if (pad) \
memset(((uint8_t *) dest->obj) + size, 0, pad); \
}
alloc_and_copy_or_fail(extradata, src->extradata_size,
FF_INPUT_BUFFER_PADDING_SIZE);
alloc_and_copy_or_fail(intra_matrix, 64 * sizeof(int16_t), 0);
alloc_and_copy_or_fail(inter_matrix, 64 * sizeof(int16_t), 0);
alloc_and_copy_or_fail(rc_override, src->rc_override_count * sizeof(*src->rc_override), 0);
alloc_and_copy_or_fail(subtitle_header, src->subtitle_header_size, 1);
dest->subtitle_header_size = src->subtitle_header_size;
#undef alloc_and_copy_or_fail
return 0;
fail:
av_freep(&dest->rc_override);
av_freep(&dest->intra_matrix);
av_freep(&dest->inter_matrix);
av_freep(&dest->extradata);
av_freep(&dest->rc_eq);
return AVERROR(ENOMEM);
}
| {
"code": [],
"line_no": []
} | int FUNC_0(AVCodecContext *VAR_0, const AVCodecContext *VAR_1)
{
const AVCodec *VAR_2 = VAR_0->codec;
uint8_t *orig_priv_data = VAR_0->priv_data;
if (avcodec_is_open(VAR_0)) {
av_log(VAR_0, AV_LOG_ERROR,
"Tried to copy AVCodecContext %p into already-initialized %p\n",
VAR_1, VAR_0);
return AVERROR(EINVAL);
}
av_opt_free(VAR_0);
av_free(VAR_0->priv_data);
memcpy(VAR_0, VAR_1, sizeof(*VAR_0));
VAR_0->priv_data = orig_priv_data;
VAR_0->codec = VAR_2;
VAR_0->slice_offset = NULL;
VAR_0->hwaccel = NULL;
VAR_0->internal = NULL;
VAR_0->rc_eq = NULL;
VAR_0->extradata = NULL;
VAR_0->intra_matrix = NULL;
VAR_0->inter_matrix = NULL;
VAR_0->rc_override = NULL;
VAR_0->subtitle_header = NULL;
if (VAR_1->rc_eq) {
VAR_0->rc_eq = av_strdup(VAR_1->rc_eq);
if (!VAR_0->rc_eq)
return AVERROR(ENOMEM);
}
#define alloc_and_copy_or_fail(obj, size, pad) \
if (VAR_1->obj && size > 0) { \
VAR_0->obj = av_malloc(size + pad); \
if (!VAR_0->obj) \
goto fail; \
memcpy(VAR_0->obj, VAR_1->obj, size); \
if (pad) \
memset(((uint8_t *) VAR_0->obj) + size, 0, pad); \
}
alloc_and_copy_or_fail(extradata, VAR_1->extradata_size,
FF_INPUT_BUFFER_PADDING_SIZE);
alloc_and_copy_or_fail(intra_matrix, 64 * sizeof(int16_t), 0);
alloc_and_copy_or_fail(inter_matrix, 64 * sizeof(int16_t), 0);
alloc_and_copy_or_fail(rc_override, VAR_1->rc_override_count * sizeof(*VAR_1->rc_override), 0);
alloc_and_copy_or_fail(subtitle_header, VAR_1->subtitle_header_size, 1);
VAR_0->subtitle_header_size = VAR_1->subtitle_header_size;
#undef alloc_and_copy_or_fail
return 0;
fail:
av_freep(&VAR_0->rc_override);
av_freep(&VAR_0->intra_matrix);
av_freep(&VAR_0->inter_matrix);
av_freep(&VAR_0->extradata);
av_freep(&VAR_0->rc_eq);
return AVERROR(ENOMEM);
}
| [
"int FUNC_0(AVCodecContext *VAR_0, const AVCodecContext *VAR_1)\n{",
"const AVCodec *VAR_2 = VAR_0->codec;",
"uint8_t *orig_priv_data = VAR_0->priv_data;",
"if (avcodec_is_open(VAR_0)) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Tried to copy AVCodecContext %p into already-initialized %p\\n\",\nVAR_1, VAR_0);",
"return AVERROR(EINVAL);",
"}",
"av_opt_free(VAR_0);",
"av_free(VAR_0->priv_data);",
"memcpy(VAR_0, VAR_1, sizeof(*VAR_0));",
"VAR_0->priv_data = orig_priv_data;",
"VAR_0->codec = VAR_2;",
"VAR_0->slice_offset = NULL;",
"VAR_0->hwaccel = NULL;",
"VAR_0->internal = NULL;",
"VAR_0->rc_eq = NULL;",
"VAR_0->extradata = NULL;",
"VAR_0->intra_matrix = NULL;",
"VAR_0->inter_matrix = NULL;",
"VAR_0->rc_override = NULL;",
"VAR_0->subtitle_header = NULL;",
"if (VAR_1->rc_eq) {",
"VAR_0->rc_eq = av_strdup(VAR_1->rc_eq);",
"if (!VAR_0->rc_eq)\nreturn AVERROR(ENOMEM);",
"}",
"#define alloc_and_copy_or_fail(obj, size, pad) \\\nif (VAR_1->obj && size > 0) { \\",
"VAR_0->obj = av_malloc(size + pad); \\",
"if (!VAR_0->obj) \\\ngoto fail; \\",
"memcpy(VAR_0->obj, VAR_1->obj, size); \\",
"if (pad) \\\nmemset(((uint8_t *) VAR_0->obj) + size, 0, pad); \\",
"}",
"alloc_and_copy_or_fail(extradata, VAR_1->extradata_size,\nFF_INPUT_BUFFER_PADDING_SIZE);",
"alloc_and_copy_or_fail(intra_matrix, 64 * sizeof(int16_t), 0);",
"alloc_and_copy_or_fail(inter_matrix, 64 * sizeof(int16_t), 0);",
"alloc_and_copy_or_fail(rc_override, VAR_1->rc_override_count * sizeof(*VAR_1->rc_override), 0);",
"alloc_and_copy_or_fail(subtitle_header, VAR_1->subtitle_header_size, 1);",
"VAR_0->subtitle_header_size = VAR_1->subtitle_header_size;",
"#undef alloc_and_copy_or_fail\nreturn 0;",
"fail:\nav_freep(&VAR_0->rc_override);",
"av_freep(&VAR_0->intra_matrix);",
"av_freep(&VAR_0->inter_matrix);",
"av_freep(&VAR_0->extradata);",
"av_freep(&VAR_0->rc_eq);",
"return AVERROR(ENOMEM);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
25
],
[
27
],
[
31
],
[
35
],
[
37
],
[
43
],
[
45
],
[
47
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69,
71
],
[
73
],
[
77,
79
],
[
81
],
[
83,
85
],
[
87
],
[
89,
91
],
[
93
],
[
95,
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109,
113
],
[
117,
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
]
] |
18,888 | target_ulong helper_rdhwr_synci_step(CPUMIPSState *env)
{
if ((env->hflags & MIPS_HFLAG_CP0) ||
(env->CP0_HWREna & (1 << 1)))
return env->SYNCI_Step;
else
do_raise_exception(env, EXCP_RI, GETPC());
return 0;
}
| false | qemu | b00c72180c36510bf9b124e190bd520e3b7e1358 | target_ulong helper_rdhwr_synci_step(CPUMIPSState *env)
{
if ((env->hflags & MIPS_HFLAG_CP0) ||
(env->CP0_HWREna & (1 << 1)))
return env->SYNCI_Step;
else
do_raise_exception(env, EXCP_RI, GETPC());
return 0;
}
| {
"code": [],
"line_no": []
} | target_ulong FUNC_0(CPUMIPSState *env)
{
if ((env->hflags & MIPS_HFLAG_CP0) ||
(env->CP0_HWREna & (1 << 1)))
return env->SYNCI_Step;
else
do_raise_exception(env, EXCP_RI, GETPC());
return 0;
}
| [
"target_ulong FUNC_0(CPUMIPSState *env)\n{",
"if ((env->hflags & MIPS_HFLAG_CP0) ||\n(env->CP0_HWREna & (1 << 1)))\nreturn env->SYNCI_Step;",
"else\ndo_raise_exception(env, EXCP_RI, GETPC());",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7,
9
],
[
11,
13
],
[
17
],
[
19
]
] |
18,889 | static void coroutine_fn bdrv_aio_discard_co_entry(void *opaque)
{
BlockDriverAIOCBCoroutine *acb = opaque;
BlockDriverState *bs = acb->common.bs;
acb->req.error = bdrv_co_discard(bs, acb->req.sector, acb->req.nb_sectors);
acb->bh = qemu_bh_new(bdrv_co_em_bh, acb);
qemu_bh_schedule(acb->bh);
}
| false | qemu | 2572b37a4751cc967582d7d04f21d9bf97187ae5 | static void coroutine_fn bdrv_aio_discard_co_entry(void *opaque)
{
BlockDriverAIOCBCoroutine *acb = opaque;
BlockDriverState *bs = acb->common.bs;
acb->req.error = bdrv_co_discard(bs, acb->req.sector, acb->req.nb_sectors);
acb->bh = qemu_bh_new(bdrv_co_em_bh, acb);
qemu_bh_schedule(acb->bh);
}
| {
"code": [],
"line_no": []
} | static void VAR_0 bdrv_aio_discard_co_entry(void *opaque)
{
BlockDriverAIOCBCoroutine *acb = opaque;
BlockDriverState *bs = acb->common.bs;
acb->req.error = bdrv_co_discard(bs, acb->req.sector, acb->req.nb_sectors);
acb->bh = qemu_bh_new(bdrv_co_em_bh, acb);
qemu_bh_schedule(acb->bh);
}
| [
"static void VAR_0 bdrv_aio_discard_co_entry(void *opaque)\n{",
"BlockDriverAIOCBCoroutine *acb = opaque;",
"BlockDriverState *bs = acb->common.bs;",
"acb->req.error = bdrv_co_discard(bs, acb->req.sector, acb->req.nb_sectors);",
"acb->bh = qemu_bh_new(bdrv_co_em_bh, acb);",
"qemu_bh_schedule(acb->bh);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
18,890 | POWERPC_FAMILY(POWER7)(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc);
dc->fw_name = "PowerPC,POWER7";
dc->desc = "POWER7";
dc->props = powerpc_servercpu_properties;
pcc->pvr_match = ppc_pvr_match_power7;
pcc->pcr_mask = PCR_COMPAT_2_05 | PCR_COMPAT_2_06;
pcc->init_proc = init_proc_POWER7;
pcc->check_pow = check_pow_nocheck;
pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | PPC_STRING | PPC_MFTB |
PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES |
PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE |
PPC_FLOAT_FRSQRTES |
PPC_FLOAT_STFIWX |
PPC_FLOAT_EXT |
PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ |
PPC_MEM_SYNC | PPC_MEM_EIEIO |
PPC_MEM_TLBIE | PPC_MEM_TLBSYNC |
PPC_64B | PPC_64H | PPC_64BX | PPC_ALTIVEC |
PPC_SEGMENT_64B | PPC_SLBI |
PPC_POPCNTB | PPC_POPCNTWD;
pcc->insns_flags2 = PPC2_VSX | PPC2_DFP | PPC2_DBRX | PPC2_ISA205 |
PPC2_PERM_ISA206 | PPC2_DIVE_ISA206 |
PPC2_ATOMIC_ISA206 | PPC2_FP_CVT_ISA206 |
PPC2_FP_TST_ISA206 | PPC2_FP_CVT_S64;
pcc->msr_mask = (1ull << MSR_SF) |
(1ull << MSR_VR) |
(1ull << MSR_VSX) |
(1ull << MSR_EE) |
(1ull << MSR_PR) |
(1ull << MSR_FP) |
(1ull << MSR_ME) |
(1ull << MSR_FE0) |
(1ull << MSR_SE) |
(1ull << MSR_DE) |
(1ull << MSR_FE1) |
(1ull << MSR_IR) |
(1ull << MSR_DR) |
(1ull << MSR_PMM) |
(1ull << MSR_RI) |
(1ull << MSR_LE);
pcc->mmu_model = POWERPC_MMU_2_06;
#if defined(CONFIG_SOFTMMU)
pcc->handle_mmu_fault = ppc_hash64_handle_mmu_fault;
pcc->sps = &POWER7_POWER8_sps;
#endif
pcc->excp_model = POWERPC_EXCP_POWER7;
pcc->bus_model = PPC_FLAGS_INPUT_POWER7;
pcc->bfd_mach = bfd_mach_ppc64;
pcc->flags = POWERPC_FLAG_VRE | POWERPC_FLAG_SE |
POWERPC_FLAG_BE | POWERPC_FLAG_PMM |
POWERPC_FLAG_BUS_CLK | POWERPC_FLAG_CFAR |
POWERPC_FLAG_VSX;
pcc->l1_dcache_size = 0x8000;
pcc->l1_icache_size = 0x8000;
pcc->interrupts_big_endian = ppc_cpu_interrupts_big_endian_lpcr;
}
| false | qemu | 8cd2ce7aaa3c3fadc561f40045d4d53ff72e94ef | POWERPC_FAMILY(POWER7)(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc);
dc->fw_name = "PowerPC,POWER7";
dc->desc = "POWER7";
dc->props = powerpc_servercpu_properties;
pcc->pvr_match = ppc_pvr_match_power7;
pcc->pcr_mask = PCR_COMPAT_2_05 | PCR_COMPAT_2_06;
pcc->init_proc = init_proc_POWER7;
pcc->check_pow = check_pow_nocheck;
pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | PPC_STRING | PPC_MFTB |
PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES |
PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE |
PPC_FLOAT_FRSQRTES |
PPC_FLOAT_STFIWX |
PPC_FLOAT_EXT |
PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ |
PPC_MEM_SYNC | PPC_MEM_EIEIO |
PPC_MEM_TLBIE | PPC_MEM_TLBSYNC |
PPC_64B | PPC_64H | PPC_64BX | PPC_ALTIVEC |
PPC_SEGMENT_64B | PPC_SLBI |
PPC_POPCNTB | PPC_POPCNTWD;
pcc->insns_flags2 = PPC2_VSX | PPC2_DFP | PPC2_DBRX | PPC2_ISA205 |
PPC2_PERM_ISA206 | PPC2_DIVE_ISA206 |
PPC2_ATOMIC_ISA206 | PPC2_FP_CVT_ISA206 |
PPC2_FP_TST_ISA206 | PPC2_FP_CVT_S64;
pcc->msr_mask = (1ull << MSR_SF) |
(1ull << MSR_VR) |
(1ull << MSR_VSX) |
(1ull << MSR_EE) |
(1ull << MSR_PR) |
(1ull << MSR_FP) |
(1ull << MSR_ME) |
(1ull << MSR_FE0) |
(1ull << MSR_SE) |
(1ull << MSR_DE) |
(1ull << MSR_FE1) |
(1ull << MSR_IR) |
(1ull << MSR_DR) |
(1ull << MSR_PMM) |
(1ull << MSR_RI) |
(1ull << MSR_LE);
pcc->mmu_model = POWERPC_MMU_2_06;
#if defined(CONFIG_SOFTMMU)
pcc->handle_mmu_fault = ppc_hash64_handle_mmu_fault;
pcc->sps = &POWER7_POWER8_sps;
#endif
pcc->excp_model = POWERPC_EXCP_POWER7;
pcc->bus_model = PPC_FLAGS_INPUT_POWER7;
pcc->bfd_mach = bfd_mach_ppc64;
pcc->flags = POWERPC_FLAG_VRE | POWERPC_FLAG_SE |
POWERPC_FLAG_BE | POWERPC_FLAG_PMM |
POWERPC_FLAG_BUS_CLK | POWERPC_FLAG_CFAR |
POWERPC_FLAG_VSX;
pcc->l1_dcache_size = 0x8000;
pcc->l1_icache_size = 0x8000;
pcc->interrupts_big_endian = ppc_cpu_interrupts_big_endian_lpcr;
}
| {
"code": [],
"line_no": []
} | FUNC_0(POWER7)(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc);
dc->fw_name = "PowerPC,POWER7";
dc->desc = "POWER7";
dc->props = powerpc_servercpu_properties;
pcc->pvr_match = ppc_pvr_match_power7;
pcc->pcr_mask = PCR_COMPAT_2_05 | PCR_COMPAT_2_06;
pcc->init_proc = init_proc_POWER7;
pcc->check_pow = check_pow_nocheck;
pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | PPC_STRING | PPC_MFTB |
PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES |
PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE |
PPC_FLOAT_FRSQRTES |
PPC_FLOAT_STFIWX |
PPC_FLOAT_EXT |
PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ |
PPC_MEM_SYNC | PPC_MEM_EIEIO |
PPC_MEM_TLBIE | PPC_MEM_TLBSYNC |
PPC_64B | PPC_64H | PPC_64BX | PPC_ALTIVEC |
PPC_SEGMENT_64B | PPC_SLBI |
PPC_POPCNTB | PPC_POPCNTWD;
pcc->insns_flags2 = PPC2_VSX | PPC2_DFP | PPC2_DBRX | PPC2_ISA205 |
PPC2_PERM_ISA206 | PPC2_DIVE_ISA206 |
PPC2_ATOMIC_ISA206 | PPC2_FP_CVT_ISA206 |
PPC2_FP_TST_ISA206 | PPC2_FP_CVT_S64;
pcc->msr_mask = (1ull << MSR_SF) |
(1ull << MSR_VR) |
(1ull << MSR_VSX) |
(1ull << MSR_EE) |
(1ull << MSR_PR) |
(1ull << MSR_FP) |
(1ull << MSR_ME) |
(1ull << MSR_FE0) |
(1ull << MSR_SE) |
(1ull << MSR_DE) |
(1ull << MSR_FE1) |
(1ull << MSR_IR) |
(1ull << MSR_DR) |
(1ull << MSR_PMM) |
(1ull << MSR_RI) |
(1ull << MSR_LE);
pcc->mmu_model = POWERPC_MMU_2_06;
#if defined(CONFIG_SOFTMMU)
pcc->handle_mmu_fault = ppc_hash64_handle_mmu_fault;
pcc->sps = &POWER7_POWER8_sps;
#endif
pcc->excp_model = POWERPC_EXCP_POWER7;
pcc->bus_model = PPC_FLAGS_INPUT_POWER7;
pcc->bfd_mach = bfd_mach_ppc64;
pcc->flags = POWERPC_FLAG_VRE | POWERPC_FLAG_SE |
POWERPC_FLAG_BE | POWERPC_FLAG_PMM |
POWERPC_FLAG_BUS_CLK | POWERPC_FLAG_CFAR |
POWERPC_FLAG_VSX;
pcc->l1_dcache_size = 0x8000;
pcc->l1_icache_size = 0x8000;
pcc->interrupts_big_endian = ppc_cpu_interrupts_big_endian_lpcr;
}
| [
"FUNC_0(POWER7)(ObjectClass *oc, void *data)\n{",
"DeviceClass *dc = DEVICE_CLASS(oc);",
"PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc);",
"dc->fw_name = \"PowerPC,POWER7\";",
"dc->desc = \"POWER7\";",
"dc->props = powerpc_servercpu_properties;",
"pcc->pvr_match = ppc_pvr_match_power7;",
"pcc->pcr_mask = PCR_COMPAT_2_05 | PCR_COMPAT_2_06;",
"pcc->init_proc = init_proc_POWER7;",
"pcc->check_pow = check_pow_nocheck;",
"pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | PPC_STRING | PPC_MFTB |\nPPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES |\nPPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE |\nPPC_FLOAT_FRSQRTES |\nPPC_FLOAT_STFIWX |\nPPC_FLOAT_EXT |\nPPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ |\nPPC_MEM_SYNC | PPC_MEM_EIEIO |\nPPC_MEM_TLBIE | PPC_MEM_TLBSYNC |\nPPC_64B | PPC_64H | PPC_64BX | PPC_ALTIVEC |\nPPC_SEGMENT_64B | PPC_SLBI |\nPPC_POPCNTB | PPC_POPCNTWD;",
"pcc->insns_flags2 = PPC2_VSX | PPC2_DFP | PPC2_DBRX | PPC2_ISA205 |\nPPC2_PERM_ISA206 | PPC2_DIVE_ISA206 |\nPPC2_ATOMIC_ISA206 | PPC2_FP_CVT_ISA206 |\nPPC2_FP_TST_ISA206 | PPC2_FP_CVT_S64;",
"pcc->msr_mask = (1ull << MSR_SF) |\n(1ull << MSR_VR) |\n(1ull << MSR_VSX) |\n(1ull << MSR_EE) |\n(1ull << MSR_PR) |\n(1ull << MSR_FP) |\n(1ull << MSR_ME) |\n(1ull << MSR_FE0) |\n(1ull << MSR_SE) |\n(1ull << MSR_DE) |\n(1ull << MSR_FE1) |\n(1ull << MSR_IR) |\n(1ull << MSR_DR) |\n(1ull << MSR_PMM) |\n(1ull << MSR_RI) |\n(1ull << MSR_LE);",
"pcc->mmu_model = POWERPC_MMU_2_06;",
"#if defined(CONFIG_SOFTMMU)\npcc->handle_mmu_fault = ppc_hash64_handle_mmu_fault;",
"pcc->sps = &POWER7_POWER8_sps;",
"#endif\npcc->excp_model = POWERPC_EXCP_POWER7;",
"pcc->bus_model = PPC_FLAGS_INPUT_POWER7;",
"pcc->bfd_mach = bfd_mach_ppc64;",
"pcc->flags = POWERPC_FLAG_VRE | POWERPC_FLAG_SE |\nPOWERPC_FLAG_BE | POWERPC_FLAG_PMM |\nPOWERPC_FLAG_BUS_CLK | POWERPC_FLAG_CFAR |\nPOWERPC_FLAG_VSX;",
"pcc->l1_dcache_size = 0x8000;",
"pcc->l1_icache_size = 0x8000;",
"pcc->interrupts_big_endian = ppc_cpu_interrupts_big_endian_lpcr;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25,
27,
29,
31,
33,
35,
37,
39,
41,
43,
45,
47
],
[
49,
51,
53,
55
],
[
57,
59,
61,
63,
65,
67,
69,
71,
73,
75,
77,
79,
81,
83,
85,
87
],
[
89
],
[
91,
93
],
[
95
],
[
97,
99
],
[
101
],
[
103
],
[
105,
107,
109,
111
],
[
113
],
[
115
],
[
117
],
[
119
]
] |
18,894 | static void configure_rtc(QemuOpts *opts)
{
const char *value;
value = qemu_opt_get(opts, "base");
if (value) {
if (!strcmp(value, "utc")) {
rtc_utc = 1;
} else if (!strcmp(value, "localtime")) {
rtc_utc = 0;
} else {
configure_rtc_date_offset(value, 0);
}
}
value = qemu_opt_get(opts, "clock");
if (value) {
if (!strcmp(value, "host")) {
rtc_clock = QEMU_CLOCK_HOST;
} else if (!strcmp(value, "rt")) {
rtc_clock = QEMU_CLOCK_REALTIME;
} else if (!strcmp(value, "vm")) {
rtc_clock = QEMU_CLOCK_VIRTUAL;
} else {
fprintf(stderr, "qemu: invalid option value '%s'\n", value);
exit(1);
}
}
value = qemu_opt_get(opts, "driftfix");
if (value) {
if (!strcmp(value, "slew")) {
static GlobalProperty slew_lost_ticks[] = {
{
.driver = "mc146818rtc",
.property = "lost_tick_policy",
.value = "slew",
},
{ /* end of list */ }
};
qdev_prop_register_global_list(slew_lost_ticks);
} else if (!strcmp(value, "none")) {
/* discard is default */
} else {
fprintf(stderr, "qemu: invalid option value '%s'\n", value);
exit(1);
}
}
}
| false | qemu | f61eddcb2bb5cbbdd1d911b7e937db9affc29028 | static void configure_rtc(QemuOpts *opts)
{
const char *value;
value = qemu_opt_get(opts, "base");
if (value) {
if (!strcmp(value, "utc")) {
rtc_utc = 1;
} else if (!strcmp(value, "localtime")) {
rtc_utc = 0;
} else {
configure_rtc_date_offset(value, 0);
}
}
value = qemu_opt_get(opts, "clock");
if (value) {
if (!strcmp(value, "host")) {
rtc_clock = QEMU_CLOCK_HOST;
} else if (!strcmp(value, "rt")) {
rtc_clock = QEMU_CLOCK_REALTIME;
} else if (!strcmp(value, "vm")) {
rtc_clock = QEMU_CLOCK_VIRTUAL;
} else {
fprintf(stderr, "qemu: invalid option value '%s'\n", value);
exit(1);
}
}
value = qemu_opt_get(opts, "driftfix");
if (value) {
if (!strcmp(value, "slew")) {
static GlobalProperty slew_lost_ticks[] = {
{
.driver = "mc146818rtc",
.property = "lost_tick_policy",
.value = "slew",
},
{ }
};
qdev_prop_register_global_list(slew_lost_ticks);
} else if (!strcmp(value, "none")) {
} else {
fprintf(stderr, "qemu: invalid option value '%s'\n", value);
exit(1);
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(QemuOpts *VAR_0)
{
const char *VAR_1;
VAR_1 = qemu_opt_get(VAR_0, "base");
if (VAR_1) {
if (!strcmp(VAR_1, "utc")) {
rtc_utc = 1;
} else if (!strcmp(VAR_1, "localtime")) {
rtc_utc = 0;
} else {
configure_rtc_date_offset(VAR_1, 0);
}
}
VAR_1 = qemu_opt_get(VAR_0, "clock");
if (VAR_1) {
if (!strcmp(VAR_1, "host")) {
rtc_clock = QEMU_CLOCK_HOST;
} else if (!strcmp(VAR_1, "rt")) {
rtc_clock = QEMU_CLOCK_REALTIME;
} else if (!strcmp(VAR_1, "vm")) {
rtc_clock = QEMU_CLOCK_VIRTUAL;
} else {
fprintf(stderr, "qemu: invalid option VAR_1 '%s'\n", VAR_1);
exit(1);
}
}
VAR_1 = qemu_opt_get(VAR_0, "driftfix");
if (VAR_1) {
if (!strcmp(VAR_1, "slew")) {
static GlobalProperty VAR_2[] = {
{
.driver = "mc146818rtc",
.property = "lost_tick_policy",
.VAR_1 = "slew",
},
{ }
};
qdev_prop_register_global_list(VAR_2);
} else if (!strcmp(VAR_1, "none")) {
} else {
fprintf(stderr, "qemu: invalid option VAR_1 '%s'\n", VAR_1);
exit(1);
}
}
}
| [
"static void FUNC_0(QemuOpts *VAR_0)\n{",
"const char *VAR_1;",
"VAR_1 = qemu_opt_get(VAR_0, \"base\");",
"if (VAR_1) {",
"if (!strcmp(VAR_1, \"utc\")) {",
"rtc_utc = 1;",
"} else if (!strcmp(VAR_1, \"localtime\")) {",
"rtc_utc = 0;",
"} else {",
"configure_rtc_date_offset(VAR_1, 0);",
"}",
"}",
"VAR_1 = qemu_opt_get(VAR_0, \"clock\");",
"if (VAR_1) {",
"if (!strcmp(VAR_1, \"host\")) {",
"rtc_clock = QEMU_CLOCK_HOST;",
"} else if (!strcmp(VAR_1, \"rt\")) {",
"rtc_clock = QEMU_CLOCK_REALTIME;",
"} else if (!strcmp(VAR_1, \"vm\")) {",
"rtc_clock = QEMU_CLOCK_VIRTUAL;",
"} else {",
"fprintf(stderr, \"qemu: invalid option VAR_1 '%s'\\n\", VAR_1);",
"exit(1);",
"}",
"}",
"VAR_1 = qemu_opt_get(VAR_0, \"driftfix\");",
"if (VAR_1) {",
"if (!strcmp(VAR_1, \"slew\")) {",
"static GlobalProperty VAR_2[] = {",
"{",
".driver = \"mc146818rtc\",\n.property = \"lost_tick_policy\",\n.VAR_1 = \"slew\",\n},",
"{ }",
"};",
"qdev_prop_register_global_list(VAR_2);",
"} else if (!strcmp(VAR_1, \"none\")) {",
"} else {",
"fprintf(stderr, \"qemu: invalid option VAR_1 '%s'\\n\", VAR_1);",
"exit(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
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65,
67,
69,
71
],
[
73
],
[
75
],
[
79
],
[
81
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
]
] |
18,895 | static inline void t_gen_zext(TCGv d, TCGv s, int size)
{
if (size == 1)
tcg_gen_ext8u_i32(d, s);
else if (size == 2)
tcg_gen_ext16u_i32(d, s);
else if (GET_TCGV(d) != GET_TCGV(s))
tcg_gen_mov_tl(d, s);
}
| false | qemu | a7812ae412311d7d47f8aa85656faadac9d64b56 | static inline void t_gen_zext(TCGv d, TCGv s, int size)
{
if (size == 1)
tcg_gen_ext8u_i32(d, s);
else if (size == 2)
tcg_gen_ext16u_i32(d, s);
else if (GET_TCGV(d) != GET_TCGV(s))
tcg_gen_mov_tl(d, s);
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0(TCGv VAR_0, TCGv VAR_1, int VAR_2)
{
if (VAR_2 == 1)
tcg_gen_ext8u_i32(VAR_0, VAR_1);
else if (VAR_2 == 2)
tcg_gen_ext16u_i32(VAR_0, VAR_1);
else if (GET_TCGV(VAR_0) != GET_TCGV(VAR_1))
tcg_gen_mov_tl(VAR_0, VAR_1);
}
| [
"static inline void FUNC_0(TCGv VAR_0, TCGv VAR_1, int VAR_2)\n{",
"if (VAR_2 == 1)\ntcg_gen_ext8u_i32(VAR_0, VAR_1);",
"else if (VAR_2 == 2)\ntcg_gen_ext16u_i32(VAR_0, VAR_1);",
"else if (GET_TCGV(VAR_0) != GET_TCGV(VAR_1))\ntcg_gen_mov_tl(VAR_0, VAR_1);",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
9,
11
],
[
13,
15
],
[
17
]
] |
18,896 | static ssize_t virtio_net_receive(VLANClientState *nc, const uint8_t *buf, size_t size)
{
VirtIONet *n = DO_UPCAST(NICState, nc, nc)->opaque;
struct virtio_net_hdr_mrg_rxbuf *mhdr = NULL;
size_t hdr_len, offset, i;
if (!virtio_net_can_receive(&n->nic->nc))
return -1;
/* hdr_len refers to the header we supply to the guest */
hdr_len = n->mergeable_rx_bufs ?
sizeof(struct virtio_net_hdr_mrg_rxbuf) : sizeof(struct virtio_net_hdr);
if (!virtio_net_has_buffers(n, size + hdr_len))
return 0;
if (!receive_filter(n, buf, size))
return size;
offset = i = 0;
while (offset < size) {
VirtQueueElement elem;
int len, total;
struct iovec sg[VIRTQUEUE_MAX_SIZE];
total = 0;
if ((i != 0 && !n->mergeable_rx_bufs) ||
virtqueue_pop(n->rx_vq, &elem) == 0) {
if (i == 0)
return -1;
fprintf(stderr, "virtio-net truncating packet: "
"offset %zd, size %zd, hdr_len %zd\n",
offset, size, hdr_len);
exit(1);
}
if (elem.in_num < 1) {
fprintf(stderr, "virtio-net receive queue contains no in buffers\n");
exit(1);
}
if (!n->mergeable_rx_bufs && elem.in_sg[0].iov_len != hdr_len) {
fprintf(stderr, "virtio-net header not in first element\n");
exit(1);
}
memcpy(&sg, &elem.in_sg[0], sizeof(sg[0]) * elem.in_num);
if (i == 0) {
if (n->mergeable_rx_bufs)
mhdr = (struct virtio_net_hdr_mrg_rxbuf *)sg[0].iov_base;
offset += receive_header(n, sg, elem.in_num,
buf + offset, size - offset, hdr_len);
total += hdr_len;
}
/* copy in packet. ugh */
len = iov_from_buf(sg, elem.in_num,
buf + offset, size - offset);
total += len;
/* signal other side */
virtqueue_fill(n->rx_vq, &elem, total, i++);
offset += len;
}
if (mhdr)
mhdr->num_buffers = i;
virtqueue_flush(n->rx_vq, i);
virtio_notify(&n->vdev, n->rx_vq);
return size;
}
| false | qemu | 279a42535dc977c495bdbda8c8831016e05a0a5d | static ssize_t virtio_net_receive(VLANClientState *nc, const uint8_t *buf, size_t size)
{
VirtIONet *n = DO_UPCAST(NICState, nc, nc)->opaque;
struct virtio_net_hdr_mrg_rxbuf *mhdr = NULL;
size_t hdr_len, offset, i;
if (!virtio_net_can_receive(&n->nic->nc))
return -1;
hdr_len = n->mergeable_rx_bufs ?
sizeof(struct virtio_net_hdr_mrg_rxbuf) : sizeof(struct virtio_net_hdr);
if (!virtio_net_has_buffers(n, size + hdr_len))
return 0;
if (!receive_filter(n, buf, size))
return size;
offset = i = 0;
while (offset < size) {
VirtQueueElement elem;
int len, total;
struct iovec sg[VIRTQUEUE_MAX_SIZE];
total = 0;
if ((i != 0 && !n->mergeable_rx_bufs) ||
virtqueue_pop(n->rx_vq, &elem) == 0) {
if (i == 0)
return -1;
fprintf(stderr, "virtio-net truncating packet: "
"offset %zd, size %zd, hdr_len %zd\n",
offset, size, hdr_len);
exit(1);
}
if (elem.in_num < 1) {
fprintf(stderr, "virtio-net receive queue contains no in buffers\n");
exit(1);
}
if (!n->mergeable_rx_bufs && elem.in_sg[0].iov_len != hdr_len) {
fprintf(stderr, "virtio-net header not in first element\n");
exit(1);
}
memcpy(&sg, &elem.in_sg[0], sizeof(sg[0]) * elem.in_num);
if (i == 0) {
if (n->mergeable_rx_bufs)
mhdr = (struct virtio_net_hdr_mrg_rxbuf *)sg[0].iov_base;
offset += receive_header(n, sg, elem.in_num,
buf + offset, size - offset, hdr_len);
total += hdr_len;
}
len = iov_from_buf(sg, elem.in_num,
buf + offset, size - offset);
total += len;
virtqueue_fill(n->rx_vq, &elem, total, i++);
offset += len;
}
if (mhdr)
mhdr->num_buffers = i;
virtqueue_flush(n->rx_vq, i);
virtio_notify(&n->vdev, n->rx_vq);
return size;
}
| {
"code": [],
"line_no": []
} | static ssize_t FUNC_0(VLANClientState *nc, const uint8_t *buf, size_t size)
{
VirtIONet *n = DO_UPCAST(NICState, nc, nc)->opaque;
struct virtio_net_hdr_mrg_rxbuf *VAR_0 = NULL;
size_t hdr_len, offset, i;
if (!virtio_net_can_receive(&n->nic->nc))
return -1;
hdr_len = n->mergeable_rx_bufs ?
sizeof(struct virtio_net_hdr_mrg_rxbuf) : sizeof(struct virtio_net_hdr);
if (!virtio_net_has_buffers(n, size + hdr_len))
return 0;
if (!receive_filter(n, buf, size))
return size;
offset = i = 0;
while (offset < size) {
VirtQueueElement elem;
int VAR_1, VAR_2;
struct iovec VAR_3[VIRTQUEUE_MAX_SIZE];
VAR_2 = 0;
if ((i != 0 && !n->mergeable_rx_bufs) ||
virtqueue_pop(n->rx_vq, &elem) == 0) {
if (i == 0)
return -1;
fprintf(stderr, "virtio-net truncating packet: "
"offset %zd, size %zd, hdr_len %zd\n",
offset, size, hdr_len);
exit(1);
}
if (elem.in_num < 1) {
fprintf(stderr, "virtio-net receive queue contains no in buffers\n");
exit(1);
}
if (!n->mergeable_rx_bufs && elem.in_sg[0].iov_len != hdr_len) {
fprintf(stderr, "virtio-net header not in first element\n");
exit(1);
}
memcpy(&VAR_3, &elem.in_sg[0], sizeof(VAR_3[0]) * elem.in_num);
if (i == 0) {
if (n->mergeable_rx_bufs)
VAR_0 = (struct virtio_net_hdr_mrg_rxbuf *)VAR_3[0].iov_base;
offset += receive_header(n, VAR_3, elem.in_num,
buf + offset, size - offset, hdr_len);
VAR_2 += hdr_len;
}
VAR_1 = iov_from_buf(VAR_3, elem.in_num,
buf + offset, size - offset);
VAR_2 += VAR_1;
virtqueue_fill(n->rx_vq, &elem, VAR_2, i++);
offset += VAR_1;
}
if (VAR_0)
VAR_0->num_buffers = i;
virtqueue_flush(n->rx_vq, i);
virtio_notify(&n->vdev, n->rx_vq);
return size;
}
| [
"static ssize_t FUNC_0(VLANClientState *nc, const uint8_t *buf, size_t size)\n{",
"VirtIONet *n = DO_UPCAST(NICState, nc, nc)->opaque;",
"struct virtio_net_hdr_mrg_rxbuf *VAR_0 = NULL;",
"size_t hdr_len, offset, i;",
"if (!virtio_net_can_receive(&n->nic->nc))\nreturn -1;",
"hdr_len = n->mergeable_rx_bufs ?\nsizeof(struct virtio_net_hdr_mrg_rxbuf) : sizeof(struct virtio_net_hdr);",
"if (!virtio_net_has_buffers(n, size + hdr_len))\nreturn 0;",
"if (!receive_filter(n, buf, size))\nreturn size;",
"offset = i = 0;",
"while (offset < size) {",
"VirtQueueElement elem;",
"int VAR_1, VAR_2;",
"struct iovec VAR_3[VIRTQUEUE_MAX_SIZE];",
"VAR_2 = 0;",
"if ((i != 0 && !n->mergeable_rx_bufs) ||\nvirtqueue_pop(n->rx_vq, &elem) == 0) {",
"if (i == 0)\nreturn -1;",
"fprintf(stderr, \"virtio-net truncating packet: \"\n\"offset %zd, size %zd, hdr_len %zd\\n\",\noffset, size, hdr_len);",
"exit(1);",
"}",
"if (elem.in_num < 1) {",
"fprintf(stderr, \"virtio-net receive queue contains no in buffers\\n\");",
"exit(1);",
"}",
"if (!n->mergeable_rx_bufs && elem.in_sg[0].iov_len != hdr_len) {",
"fprintf(stderr, \"virtio-net header not in first element\\n\");",
"exit(1);",
"}",
"memcpy(&VAR_3, &elem.in_sg[0], sizeof(VAR_3[0]) * elem.in_num);",
"if (i == 0) {",
"if (n->mergeable_rx_bufs)\nVAR_0 = (struct virtio_net_hdr_mrg_rxbuf *)VAR_3[0].iov_base;",
"offset += receive_header(n, VAR_3, elem.in_num,\nbuf + offset, size - offset, hdr_len);",
"VAR_2 += hdr_len;",
"}",
"VAR_1 = iov_from_buf(VAR_3, elem.in_num,\nbuf + offset, size - offset);",
"VAR_2 += VAR_1;",
"virtqueue_fill(n->rx_vq, &elem, VAR_2, i++);",
"offset += VAR_1;",
"}",
"if (VAR_0)\nVAR_0->num_buffers = i;",
"virtqueue_flush(n->rx_vq, i);",
"virtio_notify(&n->vdev, n->rx_vq);",
"return size;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13,
15
],
[
21,
23
],
[
29,
31
],
[
35,
37
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
59,
61
],
[
63,
65
],
[
67,
69,
71
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91
],
[
93
],
[
95
],
[
99
],
[
103
],
[
105,
107
],
[
111,
113
],
[
115
],
[
117
],
[
123,
125
],
[
127
],
[
133
],
[
137
],
[
139
],
[
143,
145
],
[
149
],
[
151
],
[
155
],
[
157
]
] |
18,897 | static InputEvent *qapi_clone_InputEvent(InputEvent *src)
{
QmpOutputVisitor *qov;
QmpInputVisitor *qiv;
Visitor *ov, *iv;
QObject *obj;
InputEvent *dst = NULL;
qov = qmp_output_visitor_new();
ov = qmp_output_get_visitor(qov);
visit_type_InputEvent(ov, NULL, &src, &error_abort);
obj = qmp_output_get_qobject(qov);
qmp_output_visitor_cleanup(qov);
if (!obj) {
return NULL;
}
qiv = qmp_input_visitor_new(obj, false);
iv = qmp_input_get_visitor(qiv);
visit_type_InputEvent(iv, NULL, &dst, &error_abort);
qmp_input_visitor_cleanup(qiv);
qobject_decref(obj);
return dst;
}
| false | qemu | 240f64b6dc3346d044d7beb7cc3a53668ce47384 | static InputEvent *qapi_clone_InputEvent(InputEvent *src)
{
QmpOutputVisitor *qov;
QmpInputVisitor *qiv;
Visitor *ov, *iv;
QObject *obj;
InputEvent *dst = NULL;
qov = qmp_output_visitor_new();
ov = qmp_output_get_visitor(qov);
visit_type_InputEvent(ov, NULL, &src, &error_abort);
obj = qmp_output_get_qobject(qov);
qmp_output_visitor_cleanup(qov);
if (!obj) {
return NULL;
}
qiv = qmp_input_visitor_new(obj, false);
iv = qmp_input_get_visitor(qiv);
visit_type_InputEvent(iv, NULL, &dst, &error_abort);
qmp_input_visitor_cleanup(qiv);
qobject_decref(obj);
return dst;
}
| {
"code": [],
"line_no": []
} | static InputEvent *FUNC_0(InputEvent *src)
{
QmpOutputVisitor *qov;
QmpInputVisitor *qiv;
Visitor *ov, *iv;
QObject *obj;
InputEvent *dst = NULL;
qov = qmp_output_visitor_new();
ov = qmp_output_get_visitor(qov);
visit_type_InputEvent(ov, NULL, &src, &error_abort);
obj = qmp_output_get_qobject(qov);
qmp_output_visitor_cleanup(qov);
if (!obj) {
return NULL;
}
qiv = qmp_input_visitor_new(obj, false);
iv = qmp_input_get_visitor(qiv);
visit_type_InputEvent(iv, NULL, &dst, &error_abort);
qmp_input_visitor_cleanup(qiv);
qobject_decref(obj);
return dst;
}
| [
"static InputEvent *FUNC_0(InputEvent *src)\n{",
"QmpOutputVisitor *qov;",
"QmpInputVisitor *qiv;",
"Visitor *ov, *iv;",
"QObject *obj;",
"InputEvent *dst = NULL;",
"qov = qmp_output_visitor_new();",
"ov = qmp_output_get_visitor(qov);",
"visit_type_InputEvent(ov, NULL, &src, &error_abort);",
"obj = qmp_output_get_qobject(qov);",
"qmp_output_visitor_cleanup(qov);",
"if (!obj) {",
"return NULL;",
"}",
"qiv = qmp_input_visitor_new(obj, false);",
"iv = qmp_input_get_visitor(qiv);",
"visit_type_InputEvent(iv, NULL, &dst, &error_abort);",
"qmp_input_visitor_cleanup(qiv);",
"qobject_decref(obj);",
"return dst;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
]
] |
18,899 | static void stop(DBDMA_channel *ch)
{
ch->regs[DBDMA_STATUS] &= cpu_to_be32(~(ACTIVE|DEAD|FLUSH));
/* the stop command does not increment command pointer */
}
| false | qemu | ad674e53b5cce265fadafbde2c6a4f190345cd00 | static void stop(DBDMA_channel *ch)
{
ch->regs[DBDMA_STATUS] &= cpu_to_be32(~(ACTIVE|DEAD|FLUSH));
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DBDMA_channel *VAR_0)
{
VAR_0->regs[DBDMA_STATUS] &= cpu_to_be32(~(ACTIVE|DEAD|FLUSH));
}
| [
"static void FUNC_0(DBDMA_channel *VAR_0)\n{",
"VAR_0->regs[DBDMA_STATUS] &= cpu_to_be32(~(ACTIVE|DEAD|FLUSH));",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
11
]
] |
18,900 | void qmp_drive_mirror(const char *device, const char *target,
bool has_format, const char *format,
enum MirrorSyncMode sync,
bool has_mode, enum NewImageMode mode,
bool has_speed, int64_t speed,
bool has_granularity, uint32_t granularity,
bool has_buf_size, int64_t buf_size,
bool has_on_source_error, BlockdevOnError on_source_error,
bool has_on_target_error, BlockdevOnError on_target_error,
Error **errp)
{
BlockDriverState *bs;
BlockDriverState *source, *target_bs;
BlockDriver *proto_drv;
BlockDriver *drv = NULL;
Error *local_err = NULL;
int flags;
uint64_t size;
int ret;
if (!has_speed) {
speed = 0;
}
if (!has_on_source_error) {
on_source_error = BLOCKDEV_ON_ERROR_REPORT;
}
if (!has_on_target_error) {
on_target_error = BLOCKDEV_ON_ERROR_REPORT;
}
if (!has_mode) {
mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS;
}
if (!has_granularity) {
granularity = 0;
}
if (!has_buf_size) {
buf_size = DEFAULT_MIRROR_BUF_SIZE;
}
if (granularity != 0 && (granularity < 512 || granularity > 1048576 * 64)) {
error_set(errp, QERR_INVALID_PARAMETER, device);
return;
}
if (granularity & (granularity - 1)) {
error_set(errp, QERR_INVALID_PARAMETER, device);
return;
}
bs = bdrv_find(device);
if (!bs) {
error_set(errp, QERR_DEVICE_NOT_FOUND, device);
return;
}
if (!bdrv_is_inserted(bs)) {
error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
return;
}
if (!has_format) {
format = mode == NEW_IMAGE_MODE_EXISTING ? NULL : bs->drv->format_name;
}
if (format) {
drv = bdrv_find_format(format);
if (!drv) {
error_set(errp, QERR_INVALID_BLOCK_FORMAT, format);
return;
}
}
if (bdrv_in_use(bs)) {
error_set(errp, QERR_DEVICE_IN_USE, device);
return;
}
flags = bs->open_flags | BDRV_O_RDWR;
source = bs->backing_hd;
if (!source && sync == MIRROR_SYNC_MODE_TOP) {
sync = MIRROR_SYNC_MODE_FULL;
}
proto_drv = bdrv_find_protocol(target);
if (!proto_drv) {
error_set(errp, QERR_INVALID_BLOCK_FORMAT, format);
return;
}
bdrv_get_geometry(bs, &size);
size *= 512;
if (sync == MIRROR_SYNC_MODE_FULL && mode != NEW_IMAGE_MODE_EXISTING) {
/* create new image w/o backing file */
assert(format && drv);
bdrv_img_create(target, format,
NULL, NULL, NULL, size, flags, &local_err, false);
} else {
switch (mode) {
case NEW_IMAGE_MODE_EXISTING:
ret = 0;
break;
case NEW_IMAGE_MODE_ABSOLUTE_PATHS:
/* create new image with backing file */
bdrv_img_create(target, format,
source->filename,
source->drv->format_name,
NULL, size, flags, &local_err, false);
break;
default:
abort();
}
}
if (error_is_set(&local_err)) {
error_propagate(errp, local_err);
return;
}
/* Mirroring takes care of copy-on-write using the source's backing
* file.
*/
target_bs = bdrv_new("");
ret = bdrv_open(target_bs, target, NULL, flags | BDRV_O_NO_BACKING, drv);
if (ret < 0) {
bdrv_delete(target_bs);
error_setg_file_open(errp, -ret, target);
return;
}
mirror_start(bs, target_bs, speed, granularity, buf_size, sync,
on_source_error, on_target_error,
block_job_cb, bs, &local_err);
if (local_err != NULL) {
bdrv_delete(target_bs);
error_propagate(errp, local_err);
return;
}
/* Grab a reference so hotplug does not delete the BlockDriverState from
* underneath us.
*/
drive_get_ref(drive_get_by_blockdev(bs));
}
| false | qemu | cb78466ef60ccf707a6f38a1294c435b65a828e0 | void qmp_drive_mirror(const char *device, const char *target,
bool has_format, const char *format,
enum MirrorSyncMode sync,
bool has_mode, enum NewImageMode mode,
bool has_speed, int64_t speed,
bool has_granularity, uint32_t granularity,
bool has_buf_size, int64_t buf_size,
bool has_on_source_error, BlockdevOnError on_source_error,
bool has_on_target_error, BlockdevOnError on_target_error,
Error **errp)
{
BlockDriverState *bs;
BlockDriverState *source, *target_bs;
BlockDriver *proto_drv;
BlockDriver *drv = NULL;
Error *local_err = NULL;
int flags;
uint64_t size;
int ret;
if (!has_speed) {
speed = 0;
}
if (!has_on_source_error) {
on_source_error = BLOCKDEV_ON_ERROR_REPORT;
}
if (!has_on_target_error) {
on_target_error = BLOCKDEV_ON_ERROR_REPORT;
}
if (!has_mode) {
mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS;
}
if (!has_granularity) {
granularity = 0;
}
if (!has_buf_size) {
buf_size = DEFAULT_MIRROR_BUF_SIZE;
}
if (granularity != 0 && (granularity < 512 || granularity > 1048576 * 64)) {
error_set(errp, QERR_INVALID_PARAMETER, device);
return;
}
if (granularity & (granularity - 1)) {
error_set(errp, QERR_INVALID_PARAMETER, device);
return;
}
bs = bdrv_find(device);
if (!bs) {
error_set(errp, QERR_DEVICE_NOT_FOUND, device);
return;
}
if (!bdrv_is_inserted(bs)) {
error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
return;
}
if (!has_format) {
format = mode == NEW_IMAGE_MODE_EXISTING ? NULL : bs->drv->format_name;
}
if (format) {
drv = bdrv_find_format(format);
if (!drv) {
error_set(errp, QERR_INVALID_BLOCK_FORMAT, format);
return;
}
}
if (bdrv_in_use(bs)) {
error_set(errp, QERR_DEVICE_IN_USE, device);
return;
}
flags = bs->open_flags | BDRV_O_RDWR;
source = bs->backing_hd;
if (!source && sync == MIRROR_SYNC_MODE_TOP) {
sync = MIRROR_SYNC_MODE_FULL;
}
proto_drv = bdrv_find_protocol(target);
if (!proto_drv) {
error_set(errp, QERR_INVALID_BLOCK_FORMAT, format);
return;
}
bdrv_get_geometry(bs, &size);
size *= 512;
if (sync == MIRROR_SYNC_MODE_FULL && mode != NEW_IMAGE_MODE_EXISTING) {
assert(format && drv);
bdrv_img_create(target, format,
NULL, NULL, NULL, size, flags, &local_err, false);
} else {
switch (mode) {
case NEW_IMAGE_MODE_EXISTING:
ret = 0;
break;
case NEW_IMAGE_MODE_ABSOLUTE_PATHS:
bdrv_img_create(target, format,
source->filename,
source->drv->format_name,
NULL, size, flags, &local_err, false);
break;
default:
abort();
}
}
if (error_is_set(&local_err)) {
error_propagate(errp, local_err);
return;
}
target_bs = bdrv_new("");
ret = bdrv_open(target_bs, target, NULL, flags | BDRV_O_NO_BACKING, drv);
if (ret < 0) {
bdrv_delete(target_bs);
error_setg_file_open(errp, -ret, target);
return;
}
mirror_start(bs, target_bs, speed, granularity, buf_size, sync,
on_source_error, on_target_error,
block_job_cb, bs, &local_err);
if (local_err != NULL) {
bdrv_delete(target_bs);
error_propagate(errp, local_err);
return;
}
drive_get_ref(drive_get_by_blockdev(bs));
}
| {
"code": [],
"line_no": []
} | void FUNC_0(const char *VAR_0, const char *VAR_1,
bool VAR_2, const char *VAR_3,
enum MirrorSyncMode VAR_4,
bool VAR_5, enum NewImageMode VAR_6,
bool VAR_7, int64_t VAR_8,
bool VAR_9, uint32_t VAR_10,
bool VAR_11, int64_t VAR_12,
bool VAR_13, BlockdevOnError VAR_14,
bool VAR_15, BlockdevOnError VAR_16,
Error **VAR_17)
{
BlockDriverState *bs;
BlockDriverState *source, *target_bs;
BlockDriver *proto_drv;
BlockDriver *drv = NULL;
Error *local_err = NULL;
int VAR_18;
uint64_t size;
int VAR_19;
if (!VAR_7) {
VAR_8 = 0;
}
if (!VAR_13) {
VAR_14 = BLOCKDEV_ON_ERROR_REPORT;
}
if (!VAR_15) {
VAR_16 = BLOCKDEV_ON_ERROR_REPORT;
}
if (!VAR_5) {
VAR_6 = NEW_IMAGE_MODE_ABSOLUTE_PATHS;
}
if (!VAR_9) {
VAR_10 = 0;
}
if (!VAR_11) {
VAR_12 = DEFAULT_MIRROR_BUF_SIZE;
}
if (VAR_10 != 0 && (VAR_10 < 512 || VAR_10 > 1048576 * 64)) {
error_set(VAR_17, QERR_INVALID_PARAMETER, VAR_0);
return;
}
if (VAR_10 & (VAR_10 - 1)) {
error_set(VAR_17, QERR_INVALID_PARAMETER, VAR_0);
return;
}
bs = bdrv_find(VAR_0);
if (!bs) {
error_set(VAR_17, QERR_DEVICE_NOT_FOUND, VAR_0);
return;
}
if (!bdrv_is_inserted(bs)) {
error_set(VAR_17, QERR_DEVICE_HAS_NO_MEDIUM, VAR_0);
return;
}
if (!VAR_2) {
VAR_3 = VAR_6 == NEW_IMAGE_MODE_EXISTING ? NULL : bs->drv->format_name;
}
if (VAR_3) {
drv = bdrv_find_format(VAR_3);
if (!drv) {
error_set(VAR_17, QERR_INVALID_BLOCK_FORMAT, VAR_3);
return;
}
}
if (bdrv_in_use(bs)) {
error_set(VAR_17, QERR_DEVICE_IN_USE, VAR_0);
return;
}
VAR_18 = bs->open_flags | BDRV_O_RDWR;
source = bs->backing_hd;
if (!source && VAR_4 == MIRROR_SYNC_MODE_TOP) {
VAR_4 = MIRROR_SYNC_MODE_FULL;
}
proto_drv = bdrv_find_protocol(VAR_1);
if (!proto_drv) {
error_set(VAR_17, QERR_INVALID_BLOCK_FORMAT, VAR_3);
return;
}
bdrv_get_geometry(bs, &size);
size *= 512;
if (VAR_4 == MIRROR_SYNC_MODE_FULL && VAR_6 != NEW_IMAGE_MODE_EXISTING) {
assert(VAR_3 && drv);
bdrv_img_create(VAR_1, VAR_3,
NULL, NULL, NULL, size, VAR_18, &local_err, false);
} else {
switch (VAR_6) {
case NEW_IMAGE_MODE_EXISTING:
VAR_19 = 0;
break;
case NEW_IMAGE_MODE_ABSOLUTE_PATHS:
bdrv_img_create(VAR_1, VAR_3,
source->filename,
source->drv->format_name,
NULL, size, VAR_18, &local_err, false);
break;
default:
abort();
}
}
if (error_is_set(&local_err)) {
error_propagate(VAR_17, local_err);
return;
}
target_bs = bdrv_new("");
VAR_19 = bdrv_open(target_bs, VAR_1, NULL, VAR_18 | BDRV_O_NO_BACKING, drv);
if (VAR_19 < 0) {
bdrv_delete(target_bs);
error_setg_file_open(VAR_17, -VAR_19, VAR_1);
return;
}
mirror_start(bs, target_bs, VAR_8, VAR_10, VAR_12, VAR_4,
VAR_14, VAR_16,
block_job_cb, bs, &local_err);
if (local_err != NULL) {
bdrv_delete(target_bs);
error_propagate(VAR_17, local_err);
return;
}
drive_get_ref(drive_get_by_blockdev(bs));
}
| [
"void FUNC_0(const char *VAR_0, const char *VAR_1,\nbool VAR_2, const char *VAR_3,\nenum MirrorSyncMode VAR_4,\nbool VAR_5, enum NewImageMode VAR_6,\nbool VAR_7, int64_t VAR_8,\nbool VAR_9, uint32_t VAR_10,\nbool VAR_11, int64_t VAR_12,\nbool VAR_13, BlockdevOnError VAR_14,\nbool VAR_15, BlockdevOnError VAR_16,\nError **VAR_17)\n{",
"BlockDriverState *bs;",
"BlockDriverState *source, *target_bs;",
"BlockDriver *proto_drv;",
"BlockDriver *drv = NULL;",
"Error *local_err = NULL;",
"int VAR_18;",
"uint64_t size;",
"int VAR_19;",
"if (!VAR_7) {",
"VAR_8 = 0;",
"}",
"if (!VAR_13) {",
"VAR_14 = BLOCKDEV_ON_ERROR_REPORT;",
"}",
"if (!VAR_15) {",
"VAR_16 = BLOCKDEV_ON_ERROR_REPORT;",
"}",
"if (!VAR_5) {",
"VAR_6 = NEW_IMAGE_MODE_ABSOLUTE_PATHS;",
"}",
"if (!VAR_9) {",
"VAR_10 = 0;",
"}",
"if (!VAR_11) {",
"VAR_12 = DEFAULT_MIRROR_BUF_SIZE;",
"}",
"if (VAR_10 != 0 && (VAR_10 < 512 || VAR_10 > 1048576 * 64)) {",
"error_set(VAR_17, QERR_INVALID_PARAMETER, VAR_0);",
"return;",
"}",
"if (VAR_10 & (VAR_10 - 1)) {",
"error_set(VAR_17, QERR_INVALID_PARAMETER, VAR_0);",
"return;",
"}",
"bs = bdrv_find(VAR_0);",
"if (!bs) {",
"error_set(VAR_17, QERR_DEVICE_NOT_FOUND, VAR_0);",
"return;",
"}",
"if (!bdrv_is_inserted(bs)) {",
"error_set(VAR_17, QERR_DEVICE_HAS_NO_MEDIUM, VAR_0);",
"return;",
"}",
"if (!VAR_2) {",
"VAR_3 = VAR_6 == NEW_IMAGE_MODE_EXISTING ? NULL : bs->drv->format_name;",
"}",
"if (VAR_3) {",
"drv = bdrv_find_format(VAR_3);",
"if (!drv) {",
"error_set(VAR_17, QERR_INVALID_BLOCK_FORMAT, VAR_3);",
"return;",
"}",
"}",
"if (bdrv_in_use(bs)) {",
"error_set(VAR_17, QERR_DEVICE_IN_USE, VAR_0);",
"return;",
"}",
"VAR_18 = bs->open_flags | BDRV_O_RDWR;",
"source = bs->backing_hd;",
"if (!source && VAR_4 == MIRROR_SYNC_MODE_TOP) {",
"VAR_4 = MIRROR_SYNC_MODE_FULL;",
"}",
"proto_drv = bdrv_find_protocol(VAR_1);",
"if (!proto_drv) {",
"error_set(VAR_17, QERR_INVALID_BLOCK_FORMAT, VAR_3);",
"return;",
"}",
"bdrv_get_geometry(bs, &size);",
"size *= 512;",
"if (VAR_4 == MIRROR_SYNC_MODE_FULL && VAR_6 != NEW_IMAGE_MODE_EXISTING) {",
"assert(VAR_3 && drv);",
"bdrv_img_create(VAR_1, VAR_3,\nNULL, NULL, NULL, size, VAR_18, &local_err, false);",
"} else {",
"switch (VAR_6) {",
"case NEW_IMAGE_MODE_EXISTING:\nVAR_19 = 0;",
"break;",
"case NEW_IMAGE_MODE_ABSOLUTE_PATHS:\nbdrv_img_create(VAR_1, VAR_3,\nsource->filename,\nsource->drv->format_name,\nNULL, size, VAR_18, &local_err, false);",
"break;",
"default:\nabort();",
"}",
"}",
"if (error_is_set(&local_err)) {",
"error_propagate(VAR_17, local_err);",
"return;",
"}",
"target_bs = bdrv_new(\"\");",
"VAR_19 = bdrv_open(target_bs, VAR_1, NULL, VAR_18 | BDRV_O_NO_BACKING, drv);",
"if (VAR_19 < 0) {",
"bdrv_delete(target_bs);",
"error_setg_file_open(VAR_17, -VAR_19, VAR_1);",
"return;",
"}",
"mirror_start(bs, target_bs, VAR_8, VAR_10, VAR_12, VAR_4,\nVAR_14, VAR_16,\nblock_job_cb, bs, &local_err);",
"if (local_err != NULL) {",
"bdrv_delete(target_bs);",
"error_propagate(VAR_17, local_err);",
"return;",
"}",
"drive_get_ref(drive_get_by_blockdev(bs));",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
11,
13,
15,
17,
19,
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
109
],
[
111
],
[
113
],
[
115
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
141
],
[
143
],
[
145
],
[
147
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
175
],
[
177
],
[
179
],
[
183
],
[
185,
187
],
[
189
],
[
191
],
[
193,
195
],
[
197
],
[
199,
203,
205,
207,
209
],
[
211
],
[
213,
215
],
[
217
],
[
219
],
[
223
],
[
225
],
[
227
],
[
229
],
[
239
],
[
241
],
[
245
],
[
247
],
[
249
],
[
251
],
[
253
],
[
257,
259,
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
281
],
[
283
]
] |
18,901 | static void gen_delayed_conditional_jump(DisasContext * ctx)
{
int l1;
TCGv ds;
l1 = gen_new_label();
ds = tcg_temp_new();
tcg_gen_andi_i32(ds, cpu_flags, DELAY_SLOT_TRUE);
tcg_gen_brcondi_i32(TCG_COND_NE, ds, 0, l1);
gen_goto_tb(ctx, 1, ctx->pc + 2);
gen_set_label(l1);
tcg_gen_andi_i32(cpu_flags, cpu_flags, ~DELAY_SLOT_TRUE);
gen_jump(ctx);
}
| false | qemu | 42a268c241183877192c376d03bd9b6d527407c7 | static void gen_delayed_conditional_jump(DisasContext * ctx)
{
int l1;
TCGv ds;
l1 = gen_new_label();
ds = tcg_temp_new();
tcg_gen_andi_i32(ds, cpu_flags, DELAY_SLOT_TRUE);
tcg_gen_brcondi_i32(TCG_COND_NE, ds, 0, l1);
gen_goto_tb(ctx, 1, ctx->pc + 2);
gen_set_label(l1);
tcg_gen_andi_i32(cpu_flags, cpu_flags, ~DELAY_SLOT_TRUE);
gen_jump(ctx);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DisasContext * VAR_0)
{
int VAR_1;
TCGv ds;
VAR_1 = gen_new_label();
ds = tcg_temp_new();
tcg_gen_andi_i32(ds, cpu_flags, DELAY_SLOT_TRUE);
tcg_gen_brcondi_i32(TCG_COND_NE, ds, 0, VAR_1);
gen_goto_tb(VAR_0, 1, VAR_0->pc + 2);
gen_set_label(VAR_1);
tcg_gen_andi_i32(cpu_flags, cpu_flags, ~DELAY_SLOT_TRUE);
gen_jump(VAR_0);
}
| [
"static void FUNC_0(DisasContext * VAR_0)\n{",
"int VAR_1;",
"TCGv ds;",
"VAR_1 = gen_new_label();",
"ds = tcg_temp_new();",
"tcg_gen_andi_i32(ds, cpu_flags, DELAY_SLOT_TRUE);",
"tcg_gen_brcondi_i32(TCG_COND_NE, ds, 0, VAR_1);",
"gen_goto_tb(VAR_0, 1, VAR_0->pc + 2);",
"gen_set_label(VAR_1);",
"tcg_gen_andi_i32(cpu_flags, cpu_flags, ~DELAY_SLOT_TRUE);",
"gen_jump(VAR_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
]
] |
18,902 | static void qmp_input_type_number(Visitor *v, const char *name, double *obj,
Error **errp)
{
QmpInputVisitor *qiv = to_qiv(v);
QObject *qobj = qmp_input_get_object(qiv, name, true, errp);
QInt *qint;
QFloat *qfloat;
if (!qobj) {
return;
}
qint = qobject_to_qint(qobj);
if (qint) {
*obj = qint_get_int(qobject_to_qint(qobj));
return;
}
qfloat = qobject_to_qfloat(qobj);
if (qfloat) {
*obj = qfloat_get_double(qobject_to_qfloat(qobj));
return;
}
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
"number");
}
| false | qemu | 09e68369a88d7de0f988972bf28eec1b80cc47f9 | static void qmp_input_type_number(Visitor *v, const char *name, double *obj,
Error **errp)
{
QmpInputVisitor *qiv = to_qiv(v);
QObject *qobj = qmp_input_get_object(qiv, name, true, errp);
QInt *qint;
QFloat *qfloat;
if (!qobj) {
return;
}
qint = qobject_to_qint(qobj);
if (qint) {
*obj = qint_get_int(qobject_to_qint(qobj));
return;
}
qfloat = qobject_to_qfloat(qobj);
if (qfloat) {
*obj = qfloat_get_double(qobject_to_qfloat(qobj));
return;
}
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
"number");
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(Visitor *VAR_0, const char *VAR_1, double *VAR_2,
Error **VAR_3)
{
QmpInputVisitor *qiv = to_qiv(VAR_0);
QObject *qobj = qmp_input_get_object(qiv, VAR_1, true, VAR_3);
QInt *qint;
QFloat *qfloat;
if (!qobj) {
return;
}
qint = qobject_to_qint(qobj);
if (qint) {
*VAR_2 = qint_get_int(qobject_to_qint(qobj));
return;
}
qfloat = qobject_to_qfloat(qobj);
if (qfloat) {
*VAR_2 = qfloat_get_double(qobject_to_qfloat(qobj));
return;
}
error_setg(VAR_3, QERR_INVALID_PARAMETER_TYPE, VAR_1 ? VAR_1 : "null",
"number");
}
| [
"static void FUNC_0(Visitor *VAR_0, const char *VAR_1, double *VAR_2,\nError **VAR_3)\n{",
"QmpInputVisitor *qiv = to_qiv(VAR_0);",
"QObject *qobj = qmp_input_get_object(qiv, VAR_1, true, VAR_3);",
"QInt *qint;",
"QFloat *qfloat;",
"if (!qobj) {",
"return;",
"}",
"qint = qobject_to_qint(qobj);",
"if (qint) {",
"*VAR_2 = qint_get_int(qobject_to_qint(qobj));",
"return;",
"}",
"qfloat = qobject_to_qfloat(qobj);",
"if (qfloat) {",
"*VAR_2 = qfloat_get_double(qobject_to_qfloat(qobj));",
"return;",
"}",
"error_setg(VAR_3, QERR_INVALID_PARAMETER_TYPE, VAR_1 ? VAR_1 : \"null\",\n\"number\");",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47,
49
],
[
51
]
] |
18,903 | static void test_dynamic_globalprop(void)
{
g_test_trap_subprocess("/qdev/properties/dynamic/global/subprocess", 0, 0);
g_test_trap_assert_passed();
g_test_trap_assert_stderr_unmatched("*prop1*");
g_test_trap_assert_stderr_unmatched("*prop2*");
g_test_trap_assert_stderr("*Warning: \"-global dynamic-prop-type-bad.prop3=103\" not used\n*");
g_test_trap_assert_stderr_unmatched("*prop4*");
g_test_trap_assert_stderr("*Warning: \"-global nohotplug-type.prop5=105\" not used\n*");
g_test_trap_assert_stderr("*Warning: \"-global nondevice-type.prop6=106\" not used\n*");
g_test_trap_assert_stdout("");
}
| false | qemu | b3ce84fea466f3bca2ff85d158744f00c0f429bd | static void test_dynamic_globalprop(void)
{
g_test_trap_subprocess("/qdev/properties/dynamic/global/subprocess", 0, 0);
g_test_trap_assert_passed();
g_test_trap_assert_stderr_unmatched("*prop1*");
g_test_trap_assert_stderr_unmatched("*prop2*");
g_test_trap_assert_stderr("*Warning: \"-global dynamic-prop-type-bad.prop3=103\" not used\n*");
g_test_trap_assert_stderr_unmatched("*prop4*");
g_test_trap_assert_stderr("*Warning: \"-global nohotplug-type.prop5=105\" not used\n*");
g_test_trap_assert_stderr("*Warning: \"-global nondevice-type.prop6=106\" not used\n*");
g_test_trap_assert_stdout("");
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void)
{
g_test_trap_subprocess("/qdev/properties/dynamic/global/subprocess", 0, 0);
g_test_trap_assert_passed();
g_test_trap_assert_stderr_unmatched("*prop1*");
g_test_trap_assert_stderr_unmatched("*prop2*");
g_test_trap_assert_stderr("*Warning: \"-global dynamic-prop-type-bad.prop3=103\" not used\n*");
g_test_trap_assert_stderr_unmatched("*prop4*");
g_test_trap_assert_stderr("*Warning: \"-global nohotplug-type.prop5=105\" not used\n*");
g_test_trap_assert_stderr("*Warning: \"-global nondevice-type.prop6=106\" not used\n*");
g_test_trap_assert_stdout("");
}
| [
"static void FUNC_0(void)\n{",
"g_test_trap_subprocess(\"/qdev/properties/dynamic/global/subprocess\", 0, 0);",
"g_test_trap_assert_passed();",
"g_test_trap_assert_stderr_unmatched(\"*prop1*\");",
"g_test_trap_assert_stderr_unmatched(\"*prop2*\");",
"g_test_trap_assert_stderr(\"*Warning: \\\"-global dynamic-prop-type-bad.prop3=103\\\" not used\\n*\");",
"g_test_trap_assert_stderr_unmatched(\"*prop4*\");",
"g_test_trap_assert_stderr(\"*Warning: \\\"-global nohotplug-type.prop5=105\\\" not used\\n*\");",
"g_test_trap_assert_stderr(\"*Warning: \\\"-global nondevice-type.prop6=106\\\" not used\\n*\");",
"g_test_trap_assert_stdout(\"\");",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
]
] |
18,904 | static void audio_init (void)
{
size_t i;
int done = 0;
const char *drvname;
VMChangeStateEntry *e;
AudioState *s = &glob_audio_state;
if (s->drv) {
return;
}
QLIST_INIT (&s->hw_head_out);
QLIST_INIT (&s->hw_head_in);
QLIST_INIT (&s->cap_head);
atexit (audio_atexit);
s->ts = qemu_new_timer (vm_clock, audio_timer, s);
if (!s->ts) {
hw_error("Could not create audio timer\n");
}
audio_process_options ("AUDIO", audio_options);
s->nb_hw_voices_out = conf.fixed_out.nb_voices;
s->nb_hw_voices_in = conf.fixed_in.nb_voices;
if (s->nb_hw_voices_out <= 0) {
dolog ("Bogus number of playback voices %d, setting to 1\n",
s->nb_hw_voices_out);
s->nb_hw_voices_out = 1;
}
if (s->nb_hw_voices_in <= 0) {
dolog ("Bogus number of capture voices %d, setting to 0\n",
s->nb_hw_voices_in);
s->nb_hw_voices_in = 0;
}
{
int def;
drvname = audio_get_conf_str ("QEMU_AUDIO_DRV", NULL, &def);
}
if (drvname) {
int found = 0;
for (i = 0; i < ARRAY_SIZE (drvtab); i++) {
if (!strcmp (drvname, drvtab[i]->name)) {
done = !audio_driver_init (s, drvtab[i]);
found = 1;
break;
}
}
if (!found) {
dolog ("Unknown audio driver `%s'\n", drvname);
dolog ("Run with -audio-help to list available drivers\n");
}
}
if (!done) {
for (i = 0; !done && i < ARRAY_SIZE (drvtab); i++) {
if (drvtab[i]->can_be_default) {
done = !audio_driver_init (s, drvtab[i]);
}
}
}
if (!done) {
done = !audio_driver_init (s, &no_audio_driver);
if (!done) {
hw_error("Could not initialize audio subsystem\n");
}
else {
dolog ("warning: Using timer based audio emulation\n");
}
}
if (conf.period.hertz <= 0) {
if (conf.period.hertz < 0) {
dolog ("warning: Timer period is negative - %d "
"treating as zero\n",
conf.period.hertz);
}
conf.period.ticks = 1;
} else {
conf.period.ticks =
muldiv64 (1, get_ticks_per_sec (), conf.period.hertz);
}
e = qemu_add_vm_change_state_handler (audio_vm_change_state_handler, s);
if (!e) {
dolog ("warning: Could not register change state handler\n"
"(Audio can continue looping even after stopping the VM)\n");
}
QLIST_INIT (&s->card_head);
vmstate_register (NULL, 0, &vmstate_audio, s);
}
| false | qemu | 74475455442398a64355428b37422d14ccc293cb | static void audio_init (void)
{
size_t i;
int done = 0;
const char *drvname;
VMChangeStateEntry *e;
AudioState *s = &glob_audio_state;
if (s->drv) {
return;
}
QLIST_INIT (&s->hw_head_out);
QLIST_INIT (&s->hw_head_in);
QLIST_INIT (&s->cap_head);
atexit (audio_atexit);
s->ts = qemu_new_timer (vm_clock, audio_timer, s);
if (!s->ts) {
hw_error("Could not create audio timer\n");
}
audio_process_options ("AUDIO", audio_options);
s->nb_hw_voices_out = conf.fixed_out.nb_voices;
s->nb_hw_voices_in = conf.fixed_in.nb_voices;
if (s->nb_hw_voices_out <= 0) {
dolog ("Bogus number of playback voices %d, setting to 1\n",
s->nb_hw_voices_out);
s->nb_hw_voices_out = 1;
}
if (s->nb_hw_voices_in <= 0) {
dolog ("Bogus number of capture voices %d, setting to 0\n",
s->nb_hw_voices_in);
s->nb_hw_voices_in = 0;
}
{
int def;
drvname = audio_get_conf_str ("QEMU_AUDIO_DRV", NULL, &def);
}
if (drvname) {
int found = 0;
for (i = 0; i < ARRAY_SIZE (drvtab); i++) {
if (!strcmp (drvname, drvtab[i]->name)) {
done = !audio_driver_init (s, drvtab[i]);
found = 1;
break;
}
}
if (!found) {
dolog ("Unknown audio driver `%s'\n", drvname);
dolog ("Run with -audio-help to list available drivers\n");
}
}
if (!done) {
for (i = 0; !done && i < ARRAY_SIZE (drvtab); i++) {
if (drvtab[i]->can_be_default) {
done = !audio_driver_init (s, drvtab[i]);
}
}
}
if (!done) {
done = !audio_driver_init (s, &no_audio_driver);
if (!done) {
hw_error("Could not initialize audio subsystem\n");
}
else {
dolog ("warning: Using timer based audio emulation\n");
}
}
if (conf.period.hertz <= 0) {
if (conf.period.hertz < 0) {
dolog ("warning: Timer period is negative - %d "
"treating as zero\n",
conf.period.hertz);
}
conf.period.ticks = 1;
} else {
conf.period.ticks =
muldiv64 (1, get_ticks_per_sec (), conf.period.hertz);
}
e = qemu_add_vm_change_state_handler (audio_vm_change_state_handler, s);
if (!e) {
dolog ("warning: Could not register change state handler\n"
"(Audio can continue looping even after stopping the VM)\n");
}
QLIST_INIT (&s->card_head);
vmstate_register (NULL, 0, &vmstate_audio, s);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0 (void)
{
size_t i;
int VAR_0 = 0;
const char *VAR_1;
VMChangeStateEntry *e;
AudioState *s = &glob_audio_state;
if (s->drv) {
return;
}
QLIST_INIT (&s->hw_head_out);
QLIST_INIT (&s->hw_head_in);
QLIST_INIT (&s->cap_head);
atexit (audio_atexit);
s->ts = qemu_new_timer (vm_clock, audio_timer, s);
if (!s->ts) {
hw_error("Could not create audio timer\n");
}
audio_process_options ("AUDIO", audio_options);
s->nb_hw_voices_out = conf.fixed_out.nb_voices;
s->nb_hw_voices_in = conf.fixed_in.nb_voices;
if (s->nb_hw_voices_out <= 0) {
dolog ("Bogus number of playback voices %d, setting to 1\n",
s->nb_hw_voices_out);
s->nb_hw_voices_out = 1;
}
if (s->nb_hw_voices_in <= 0) {
dolog ("Bogus number of capture voices %d, setting to 0\n",
s->nb_hw_voices_in);
s->nb_hw_voices_in = 0;
}
{
int VAR_2;
VAR_1 = audio_get_conf_str ("QEMU_AUDIO_DRV", NULL, &VAR_2);
}
if (VAR_1) {
int VAR_3 = 0;
for (i = 0; i < ARRAY_SIZE (drvtab); i++) {
if (!strcmp (VAR_1, drvtab[i]->name)) {
VAR_0 = !audio_driver_init (s, drvtab[i]);
VAR_3 = 1;
break;
}
}
if (!VAR_3) {
dolog ("Unknown audio driver `%s'\n", VAR_1);
dolog ("Run with -audio-help to list available drivers\n");
}
}
if (!VAR_0) {
for (i = 0; !VAR_0 && i < ARRAY_SIZE (drvtab); i++) {
if (drvtab[i]->can_be_default) {
VAR_0 = !audio_driver_init (s, drvtab[i]);
}
}
}
if (!VAR_0) {
VAR_0 = !audio_driver_init (s, &no_audio_driver);
if (!VAR_0) {
hw_error("Could not initialize audio subsystem\n");
}
else {
dolog ("warning: Using timer based audio emulation\n");
}
}
if (conf.period.hertz <= 0) {
if (conf.period.hertz < 0) {
dolog ("warning: Timer period is negative - %d "
"treating as zero\n",
conf.period.hertz);
}
conf.period.ticks = 1;
} else {
conf.period.ticks =
muldiv64 (1, get_ticks_per_sec (), conf.period.hertz);
}
e = qemu_add_vm_change_state_handler (audio_vm_change_state_handler, s);
if (!e) {
dolog ("warning: Could not register change state handler\n"
"(Audio can continue looping even after stopping the VM)\n");
}
QLIST_INIT (&s->card_head);
vmstate_register (NULL, 0, &vmstate_audio, s);
}
| [
"static void FUNC_0 (void)\n{",
"size_t i;",
"int VAR_0 = 0;",
"const char *VAR_1;",
"VMChangeStateEntry *e;",
"AudioState *s = &glob_audio_state;",
"if (s->drv) {",
"return;",
"}",
"QLIST_INIT (&s->hw_head_out);",
"QLIST_INIT (&s->hw_head_in);",
"QLIST_INIT (&s->cap_head);",
"atexit (audio_atexit);",
"s->ts = qemu_new_timer (vm_clock, audio_timer, s);",
"if (!s->ts) {",
"hw_error(\"Could not create audio timer\\n\");",
"}",
"audio_process_options (\"AUDIO\", audio_options);",
"s->nb_hw_voices_out = conf.fixed_out.nb_voices;",
"s->nb_hw_voices_in = conf.fixed_in.nb_voices;",
"if (s->nb_hw_voices_out <= 0) {",
"dolog (\"Bogus number of playback voices %d, setting to 1\\n\",\ns->nb_hw_voices_out);",
"s->nb_hw_voices_out = 1;",
"}",
"if (s->nb_hw_voices_in <= 0) {",
"dolog (\"Bogus number of capture voices %d, setting to 0\\n\",\ns->nb_hw_voices_in);",
"s->nb_hw_voices_in = 0;",
"}",
"{",
"int VAR_2;",
"VAR_1 = audio_get_conf_str (\"QEMU_AUDIO_DRV\", NULL, &VAR_2);",
"}",
"if (VAR_1) {",
"int VAR_3 = 0;",
"for (i = 0; i < ARRAY_SIZE (drvtab); i++) {",
"if (!strcmp (VAR_1, drvtab[i]->name)) {",
"VAR_0 = !audio_driver_init (s, drvtab[i]);",
"VAR_3 = 1;",
"break;",
"}",
"}",
"if (!VAR_3) {",
"dolog (\"Unknown audio driver `%s'\\n\", VAR_1);",
"dolog (\"Run with -audio-help to list available drivers\\n\");",
"}",
"}",
"if (!VAR_0) {",
"for (i = 0; !VAR_0 && i < ARRAY_SIZE (drvtab); i++) {",
"if (drvtab[i]->can_be_default) {",
"VAR_0 = !audio_driver_init (s, drvtab[i]);",
"}",
"}",
"}",
"if (!VAR_0) {",
"VAR_0 = !audio_driver_init (s, &no_audio_driver);",
"if (!VAR_0) {",
"hw_error(\"Could not initialize audio subsystem\\n\");",
"}",
"else {",
"dolog (\"warning: Using timer based audio emulation\\n\");",
"}",
"}",
"if (conf.period.hertz <= 0) {",
"if (conf.period.hertz < 0) {",
"dolog (\"warning: Timer period is negative - %d \"\n\"treating as zero\\n\",\nconf.period.hertz);",
"}",
"conf.period.ticks = 1;",
"} else {",
"conf.period.ticks =\nmuldiv64 (1, get_ticks_per_sec (), conf.period.hertz);",
"}",
"e = qemu_add_vm_change_state_handler (audio_vm_change_state_handler, s);",
"if (!e) {",
"dolog (\"warning: Could not register change state handler\\n\"\n\"(Audio can continue looping even after stopping the VM)\\n\");",
"}",
"QLIST_INIT (&s->card_head);",
"vmstate_register (NULL, 0, &vmstate_audio, s);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
49
],
[
51
],
[
55
],
[
57,
59
],
[
61
],
[
63
],
[
67
],
[
69,
71
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
159
],
[
161
],
[
163,
165,
167
],
[
169
],
[
171
],
[
173
],
[
175,
177
],
[
179
],
[
183
],
[
185
],
[
187,
189
],
[
191
],
[
195
],
[
197
],
[
199
]
] |
18,906 | void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
uint16_t io_base, uint16_t io_len,
const char *res_root,
const char *event_handler_method)
{
int i;
Aml *ifctx;
Aml *method;
Aml *sb_scope;
Aml *mem_ctrl_dev;
char *scan_path;
char *mhp_res_path = g_strdup_printf("%s." MEMORY_HOTPLUG_DEVICE, res_root);
mem_ctrl_dev = aml_device("%s", mhp_res_path);
{
Aml *crs;
Aml *field;
Aml *one = aml_int(1);
Aml *zero = aml_int(0);
Aml *ret_val = aml_local(0);
Aml *slot_arg0 = aml_arg(0);
Aml *slots_nr = aml_name(MEMORY_SLOTS_NUMBER);
Aml *ctrl_lock = aml_name(MEMORY_SLOT_LOCK);
Aml *slot_selector = aml_name(MEMORY_SLOT_SLECTOR);
aml_append(mem_ctrl_dev, aml_name_decl("_HID", aml_string("PNP0A06")));
aml_append(mem_ctrl_dev,
aml_name_decl("_UID", aml_string("Memory hotplug resources")));
assert(nr_mem <= ACPI_MAX_RAM_SLOTS);
aml_append(mem_ctrl_dev,
aml_name_decl(MEMORY_SLOTS_NUMBER, aml_int(nr_mem))
);
crs = aml_resource_template();
aml_append(crs,
aml_io(AML_DECODE16, io_base, io_base, 0, io_len)
);
aml_append(mem_ctrl_dev, aml_name_decl("_CRS", crs));
aml_append(mem_ctrl_dev, aml_operation_region(
MEMORY_HOTPLUG_IO_REGION, AML_SYSTEM_IO,
aml_int(io_base), io_len)
);
field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,
AML_NOLOCK, AML_PRESERVE);
aml_append(field, /* read only */
aml_named_field(MEMORY_SLOT_ADDR_LOW, 32));
aml_append(field, /* read only */
aml_named_field(MEMORY_SLOT_ADDR_HIGH, 32));
aml_append(field, /* read only */
aml_named_field(MEMORY_SLOT_SIZE_LOW, 32));
aml_append(field, /* read only */
aml_named_field(MEMORY_SLOT_SIZE_HIGH, 32));
aml_append(field, /* read only */
aml_named_field(MEMORY_SLOT_PROXIMITY, 32));
aml_append(mem_ctrl_dev, field);
field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_BYTE_ACC,
AML_NOLOCK, AML_WRITE_AS_ZEROS);
aml_append(field, aml_reserved_field(160 /* bits, Offset(20) */));
aml_append(field, /* 1 if enabled, read only */
aml_named_field(MEMORY_SLOT_ENABLED, 1));
aml_append(field,
/*(read) 1 if has a insert event. (write) 1 to clear event */
aml_named_field(MEMORY_SLOT_INSERT_EVENT, 1));
aml_append(field,
/* (read) 1 if has a remove event. (write) 1 to clear event */
aml_named_field(MEMORY_SLOT_REMOVE_EVENT, 1));
aml_append(field,
/* initiates device eject, write only */
aml_named_field(MEMORY_SLOT_EJECT, 1));
aml_append(mem_ctrl_dev, field);
field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,
AML_NOLOCK, AML_PRESERVE);
aml_append(field, /* DIMM selector, write only */
aml_named_field(MEMORY_SLOT_SLECTOR, 32));
aml_append(field, /* _OST event code, write only */
aml_named_field(MEMORY_SLOT_OST_EVENT, 32));
aml_append(field, /* _OST status code, write only */
aml_named_field(MEMORY_SLOT_OST_STATUS, 32));
aml_append(mem_ctrl_dev, field);
method = aml_method("_STA", 0, AML_NOTSERIALIZED);
ifctx = aml_if(aml_equal(slots_nr, zero));
{
aml_append(ifctx, aml_return(zero));
}
aml_append(method, ifctx);
/* present, functioning, decoding, not shown in UI */
aml_append(method, aml_return(aml_int(0xB)));
aml_append(mem_ctrl_dev, method);
aml_append(mem_ctrl_dev, aml_mutex(MEMORY_SLOT_LOCK, 0));
method = aml_method(MEMORY_SLOT_SCAN_METHOD, 0, AML_NOTSERIALIZED);
{
Aml *else_ctx;
Aml *while_ctx;
Aml *idx = aml_local(0);
Aml *eject_req = aml_int(3);
Aml *dev_chk = aml_int(1);
ifctx = aml_if(aml_equal(slots_nr, zero));
{
aml_append(ifctx, aml_return(zero));
}
aml_append(method, ifctx);
aml_append(method, aml_store(zero, idx));
aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));
/* build AML that:
* loops over all slots and Notifies DIMMs with
* Device Check or Eject Request notifications if
* slot has corresponding status bit set and clears
* slot status.
*/
while_ctx = aml_while(aml_lless(idx, slots_nr));
{
Aml *ins_evt = aml_name(MEMORY_SLOT_INSERT_EVENT);
Aml *rm_evt = aml_name(MEMORY_SLOT_REMOVE_EVENT);
aml_append(while_ctx, aml_store(idx, slot_selector));
ifctx = aml_if(aml_equal(ins_evt, one));
{
aml_append(ifctx,
aml_call2(MEMORY_SLOT_NOTIFY_METHOD,
idx, dev_chk));
aml_append(ifctx, aml_store(one, ins_evt));
}
aml_append(while_ctx, ifctx);
else_ctx = aml_else();
ifctx = aml_if(aml_equal(rm_evt, one));
{
aml_append(ifctx,
aml_call2(MEMORY_SLOT_NOTIFY_METHOD,
idx, eject_req));
aml_append(ifctx, aml_store(one, rm_evt));
}
aml_append(else_ctx, ifctx);
aml_append(while_ctx, else_ctx);
aml_append(while_ctx, aml_add(idx, one, idx));
}
aml_append(method, while_ctx);
aml_append(method, aml_release(ctrl_lock));
aml_append(method, aml_return(one));
}
aml_append(mem_ctrl_dev, method);
method = aml_method(MEMORY_SLOT_STATUS_METHOD, 1, AML_NOTSERIALIZED);
{
Aml *slot_enabled = aml_name(MEMORY_SLOT_ENABLED);
aml_append(method, aml_store(zero, ret_val));
aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));
aml_append(method,
aml_store(aml_to_integer(slot_arg0), slot_selector));
ifctx = aml_if(aml_equal(slot_enabled, one));
{
aml_append(ifctx, aml_store(aml_int(0xF), ret_val));
}
aml_append(method, ifctx);
aml_append(method, aml_release(ctrl_lock));
aml_append(method, aml_return(ret_val));
}
aml_append(mem_ctrl_dev, method);
method = aml_method(MEMORY_SLOT_CRS_METHOD, 1, AML_SERIALIZED);
{
Aml *mr64 = aml_name("MR64");
Aml *mr32 = aml_name("MR32");
Aml *crs_tmpl = aml_resource_template();
Aml *minl = aml_name("MINL");
Aml *minh = aml_name("MINH");
Aml *maxl = aml_name("MAXL");
Aml *maxh = aml_name("MAXH");
Aml *lenl = aml_name("LENL");
Aml *lenh = aml_name("LENH");
aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));
aml_append(method, aml_store(aml_to_integer(slot_arg0),
slot_selector));
aml_append(crs_tmpl,
aml_qword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED,
AML_CACHEABLE, AML_READ_WRITE,
0, 0x0, 0xFFFFFFFFFFFFFFFEULL, 0,
0xFFFFFFFFFFFFFFFFULL));
aml_append(method, aml_name_decl("MR64", crs_tmpl));
aml_append(method,
aml_create_dword_field(mr64, aml_int(14), "MINL"));
aml_append(method,
aml_create_dword_field(mr64, aml_int(18), "MINH"));
aml_append(method,
aml_create_dword_field(mr64, aml_int(38), "LENL"));
aml_append(method,
aml_create_dword_field(mr64, aml_int(42), "LENH"));
aml_append(method,
aml_create_dword_field(mr64, aml_int(22), "MAXL"));
aml_append(method,
aml_create_dword_field(mr64, aml_int(26), "MAXH"));
aml_append(method,
aml_store(aml_name(MEMORY_SLOT_ADDR_HIGH), minh));
aml_append(method,
aml_store(aml_name(MEMORY_SLOT_ADDR_LOW), minl));
aml_append(method,
aml_store(aml_name(MEMORY_SLOT_SIZE_HIGH), lenh));
aml_append(method,
aml_store(aml_name(MEMORY_SLOT_SIZE_LOW), lenl));
/* 64-bit math: MAX = MIN + LEN - 1 */
aml_append(method, aml_add(minl, lenl, maxl));
aml_append(method, aml_add(minh, lenh, maxh));
ifctx = aml_if(aml_lless(maxl, minl));
{
aml_append(ifctx, aml_add(maxh, one, maxh));
}
aml_append(method, ifctx);
ifctx = aml_if(aml_lless(maxl, one));
{
aml_append(ifctx, aml_subtract(maxh, one, maxh));
}
aml_append(method, ifctx);
aml_append(method, aml_subtract(maxl, one, maxl));
/* return 32-bit _CRS if addr/size is in low mem */
/* TODO: remove it since all hotplugged DIMMs are in high mem */
ifctx = aml_if(aml_equal(maxh, zero));
{
crs_tmpl = aml_resource_template();
aml_append(crs_tmpl,
aml_dword_memory(AML_POS_DECODE, AML_MIN_FIXED,
AML_MAX_FIXED, AML_CACHEABLE,
AML_READ_WRITE,
0, 0x0, 0xFFFFFFFE, 0,
0xFFFFFFFF));
aml_append(ifctx, aml_name_decl("MR32", crs_tmpl));
aml_append(ifctx,
aml_create_dword_field(mr32, aml_int(10), "MIN"));
aml_append(ifctx,
aml_create_dword_field(mr32, aml_int(14), "MAX"));
aml_append(ifctx,
aml_create_dword_field(mr32, aml_int(22), "LEN"));
aml_append(ifctx, aml_store(minl, aml_name("MIN")));
aml_append(ifctx, aml_store(maxl, aml_name("MAX")));
aml_append(ifctx, aml_store(lenl, aml_name("LEN")));
aml_append(ifctx, aml_release(ctrl_lock));
aml_append(ifctx, aml_return(mr32));
}
aml_append(method, ifctx);
aml_append(method, aml_release(ctrl_lock));
aml_append(method, aml_return(mr64));
}
aml_append(mem_ctrl_dev, method);
method = aml_method(MEMORY_SLOT_PROXIMITY_METHOD, 1,
AML_NOTSERIALIZED);
{
Aml *proximity = aml_name(MEMORY_SLOT_PROXIMITY);
aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));
aml_append(method, aml_store(aml_to_integer(slot_arg0),
slot_selector));
aml_append(method, aml_store(proximity, ret_val));
aml_append(method, aml_release(ctrl_lock));
aml_append(method, aml_return(ret_val));
}
aml_append(mem_ctrl_dev, method);
method = aml_method(MEMORY_SLOT_OST_METHOD, 4, AML_NOTSERIALIZED);
{
Aml *ost_evt = aml_name(MEMORY_SLOT_OST_EVENT);
Aml *ost_status = aml_name(MEMORY_SLOT_OST_STATUS);
aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));
aml_append(method, aml_store(aml_to_integer(slot_arg0),
slot_selector));
aml_append(method, aml_store(aml_arg(1), ost_evt));
aml_append(method, aml_store(aml_arg(2), ost_status));
aml_append(method, aml_release(ctrl_lock));
}
aml_append(mem_ctrl_dev, method);
method = aml_method(MEMORY_SLOT_EJECT_METHOD, 2, AML_NOTSERIALIZED);
{
Aml *eject = aml_name(MEMORY_SLOT_EJECT);
aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));
aml_append(method, aml_store(aml_to_integer(slot_arg0),
slot_selector));
aml_append(method, aml_store(one, eject));
aml_append(method, aml_release(ctrl_lock));
}
aml_append(mem_ctrl_dev, method);
}
aml_append(table, mem_ctrl_dev);
sb_scope = aml_scope("_SB");
/* build memory devices */
for (i = 0; i < nr_mem; i++) {
Aml *dev;
char *s;
dev = aml_device("MP%02X", i);
aml_append(dev, aml_name_decl("_UID", aml_string("0x%02X", i)));
aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C80")));
method = aml_method("_CRS", 0, AML_NOTSERIALIZED);
s = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_CRS_METHOD);
aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
g_free(s);
aml_append(dev, method);
method = aml_method("_STA", 0, AML_NOTSERIALIZED);
s = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_STATUS_METHOD);
aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
g_free(s);
aml_append(dev, method);
method = aml_method("_PXM", 0, AML_NOTSERIALIZED);
s = g_strdup_printf("%s.%s", mhp_res_path,
MEMORY_SLOT_PROXIMITY_METHOD);
aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
g_free(s);
aml_append(dev, method);
method = aml_method("_OST", 3, AML_NOTSERIALIZED);
s = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_OST_METHOD);
aml_append(method, aml_return(aml_call4(
s, aml_name("_UID"), aml_arg(0), aml_arg(1), aml_arg(2)
)));
g_free(s);
aml_append(dev, method);
method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
s = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_EJECT_METHOD);
aml_append(method, aml_return(aml_call2(
s, aml_name("_UID"), aml_arg(0))));
g_free(s);
aml_append(dev, method);
aml_append(sb_scope, dev);
}
/* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) {
* If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... }
*/
method = aml_method(MEMORY_SLOT_NOTIFY_METHOD, 2, AML_NOTSERIALIZED);
for (i = 0; i < nr_mem; i++) {
ifctx = aml_if(aml_equal(aml_arg(0), aml_int(i)));
aml_append(ifctx,
aml_notify(aml_name("MP%.02X", i), aml_arg(1))
);
aml_append(method, ifctx);
}
aml_append(sb_scope, method);
aml_append(table, sb_scope);
method = aml_method(event_handler_method, 0, AML_NOTSERIALIZED);
scan_path = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_SCAN_METHOD);
aml_append(method, aml_call0(scan_path));
g_free(scan_path);
aml_append(table, method);
g_free(mhp_res_path);
}
| false | qemu | 80db0e7822962554c91bef05d784c898e8ab1c3c | void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
uint16_t io_base, uint16_t io_len,
const char *res_root,
const char *event_handler_method)
{
int i;
Aml *ifctx;
Aml *method;
Aml *sb_scope;
Aml *mem_ctrl_dev;
char *scan_path;
char *mhp_res_path = g_strdup_printf("%s." MEMORY_HOTPLUG_DEVICE, res_root);
mem_ctrl_dev = aml_device("%s", mhp_res_path);
{
Aml *crs;
Aml *field;
Aml *one = aml_int(1);
Aml *zero = aml_int(0);
Aml *ret_val = aml_local(0);
Aml *slot_arg0 = aml_arg(0);
Aml *slots_nr = aml_name(MEMORY_SLOTS_NUMBER);
Aml *ctrl_lock = aml_name(MEMORY_SLOT_LOCK);
Aml *slot_selector = aml_name(MEMORY_SLOT_SLECTOR);
aml_append(mem_ctrl_dev, aml_name_decl("_HID", aml_string("PNP0A06")));
aml_append(mem_ctrl_dev,
aml_name_decl("_UID", aml_string("Memory hotplug resources")));
assert(nr_mem <= ACPI_MAX_RAM_SLOTS);
aml_append(mem_ctrl_dev,
aml_name_decl(MEMORY_SLOTS_NUMBER, aml_int(nr_mem))
);
crs = aml_resource_template();
aml_append(crs,
aml_io(AML_DECODE16, io_base, io_base, 0, io_len)
);
aml_append(mem_ctrl_dev, aml_name_decl("_CRS", crs));
aml_append(mem_ctrl_dev, aml_operation_region(
MEMORY_HOTPLUG_IO_REGION, AML_SYSTEM_IO,
aml_int(io_base), io_len)
);
field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,
AML_NOLOCK, AML_PRESERVE);
aml_append(field,
aml_named_field(MEMORY_SLOT_ADDR_LOW, 32));
aml_append(field,
aml_named_field(MEMORY_SLOT_ADDR_HIGH, 32));
aml_append(field,
aml_named_field(MEMORY_SLOT_SIZE_LOW, 32));
aml_append(field,
aml_named_field(MEMORY_SLOT_SIZE_HIGH, 32));
aml_append(field,
aml_named_field(MEMORY_SLOT_PROXIMITY, 32));
aml_append(mem_ctrl_dev, field);
field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_BYTE_ACC,
AML_NOLOCK, AML_WRITE_AS_ZEROS);
aml_append(field, aml_reserved_field(160 ));
aml_append(field,
aml_named_field(MEMORY_SLOT_ENABLED, 1));
aml_append(field,
aml_named_field(MEMORY_SLOT_INSERT_EVENT, 1));
aml_append(field,
aml_named_field(MEMORY_SLOT_REMOVE_EVENT, 1));
aml_append(field,
aml_named_field(MEMORY_SLOT_EJECT, 1));
aml_append(mem_ctrl_dev, field);
field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,
AML_NOLOCK, AML_PRESERVE);
aml_append(field,
aml_named_field(MEMORY_SLOT_SLECTOR, 32));
aml_append(field,
aml_named_field(MEMORY_SLOT_OST_EVENT, 32));
aml_append(field,
aml_named_field(MEMORY_SLOT_OST_STATUS, 32));
aml_append(mem_ctrl_dev, field);
method = aml_method("_STA", 0, AML_NOTSERIALIZED);
ifctx = aml_if(aml_equal(slots_nr, zero));
{
aml_append(ifctx, aml_return(zero));
}
aml_append(method, ifctx);
aml_append(method, aml_return(aml_int(0xB)));
aml_append(mem_ctrl_dev, method);
aml_append(mem_ctrl_dev, aml_mutex(MEMORY_SLOT_LOCK, 0));
method = aml_method(MEMORY_SLOT_SCAN_METHOD, 0, AML_NOTSERIALIZED);
{
Aml *else_ctx;
Aml *while_ctx;
Aml *idx = aml_local(0);
Aml *eject_req = aml_int(3);
Aml *dev_chk = aml_int(1);
ifctx = aml_if(aml_equal(slots_nr, zero));
{
aml_append(ifctx, aml_return(zero));
}
aml_append(method, ifctx);
aml_append(method, aml_store(zero, idx));
aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));
while_ctx = aml_while(aml_lless(idx, slots_nr));
{
Aml *ins_evt = aml_name(MEMORY_SLOT_INSERT_EVENT);
Aml *rm_evt = aml_name(MEMORY_SLOT_REMOVE_EVENT);
aml_append(while_ctx, aml_store(idx, slot_selector));
ifctx = aml_if(aml_equal(ins_evt, one));
{
aml_append(ifctx,
aml_call2(MEMORY_SLOT_NOTIFY_METHOD,
idx, dev_chk));
aml_append(ifctx, aml_store(one, ins_evt));
}
aml_append(while_ctx, ifctx);
else_ctx = aml_else();
ifctx = aml_if(aml_equal(rm_evt, one));
{
aml_append(ifctx,
aml_call2(MEMORY_SLOT_NOTIFY_METHOD,
idx, eject_req));
aml_append(ifctx, aml_store(one, rm_evt));
}
aml_append(else_ctx, ifctx);
aml_append(while_ctx, else_ctx);
aml_append(while_ctx, aml_add(idx, one, idx));
}
aml_append(method, while_ctx);
aml_append(method, aml_release(ctrl_lock));
aml_append(method, aml_return(one));
}
aml_append(mem_ctrl_dev, method);
method = aml_method(MEMORY_SLOT_STATUS_METHOD, 1, AML_NOTSERIALIZED);
{
Aml *slot_enabled = aml_name(MEMORY_SLOT_ENABLED);
aml_append(method, aml_store(zero, ret_val));
aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));
aml_append(method,
aml_store(aml_to_integer(slot_arg0), slot_selector));
ifctx = aml_if(aml_equal(slot_enabled, one));
{
aml_append(ifctx, aml_store(aml_int(0xF), ret_val));
}
aml_append(method, ifctx);
aml_append(method, aml_release(ctrl_lock));
aml_append(method, aml_return(ret_val));
}
aml_append(mem_ctrl_dev, method);
method = aml_method(MEMORY_SLOT_CRS_METHOD, 1, AML_SERIALIZED);
{
Aml *mr64 = aml_name("MR64");
Aml *mr32 = aml_name("MR32");
Aml *crs_tmpl = aml_resource_template();
Aml *minl = aml_name("MINL");
Aml *minh = aml_name("MINH");
Aml *maxl = aml_name("MAXL");
Aml *maxh = aml_name("MAXH");
Aml *lenl = aml_name("LENL");
Aml *lenh = aml_name("LENH");
aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));
aml_append(method, aml_store(aml_to_integer(slot_arg0),
slot_selector));
aml_append(crs_tmpl,
aml_qword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED,
AML_CACHEABLE, AML_READ_WRITE,
0, 0x0, 0xFFFFFFFFFFFFFFFEULL, 0,
0xFFFFFFFFFFFFFFFFULL));
aml_append(method, aml_name_decl("MR64", crs_tmpl));
aml_append(method,
aml_create_dword_field(mr64, aml_int(14), "MINL"));
aml_append(method,
aml_create_dword_field(mr64, aml_int(18), "MINH"));
aml_append(method,
aml_create_dword_field(mr64, aml_int(38), "LENL"));
aml_append(method,
aml_create_dword_field(mr64, aml_int(42), "LENH"));
aml_append(method,
aml_create_dword_field(mr64, aml_int(22), "MAXL"));
aml_append(method,
aml_create_dword_field(mr64, aml_int(26), "MAXH"));
aml_append(method,
aml_store(aml_name(MEMORY_SLOT_ADDR_HIGH), minh));
aml_append(method,
aml_store(aml_name(MEMORY_SLOT_ADDR_LOW), minl));
aml_append(method,
aml_store(aml_name(MEMORY_SLOT_SIZE_HIGH), lenh));
aml_append(method,
aml_store(aml_name(MEMORY_SLOT_SIZE_LOW), lenl));
aml_append(method, aml_add(minl, lenl, maxl));
aml_append(method, aml_add(minh, lenh, maxh));
ifctx = aml_if(aml_lless(maxl, minl));
{
aml_append(ifctx, aml_add(maxh, one, maxh));
}
aml_append(method, ifctx);
ifctx = aml_if(aml_lless(maxl, one));
{
aml_append(ifctx, aml_subtract(maxh, one, maxh));
}
aml_append(method, ifctx);
aml_append(method, aml_subtract(maxl, one, maxl));
ifctx = aml_if(aml_equal(maxh, zero));
{
crs_tmpl = aml_resource_template();
aml_append(crs_tmpl,
aml_dword_memory(AML_POS_DECODE, AML_MIN_FIXED,
AML_MAX_FIXED, AML_CACHEABLE,
AML_READ_WRITE,
0, 0x0, 0xFFFFFFFE, 0,
0xFFFFFFFF));
aml_append(ifctx, aml_name_decl("MR32", crs_tmpl));
aml_append(ifctx,
aml_create_dword_field(mr32, aml_int(10), "MIN"));
aml_append(ifctx,
aml_create_dword_field(mr32, aml_int(14), "MAX"));
aml_append(ifctx,
aml_create_dword_field(mr32, aml_int(22), "LEN"));
aml_append(ifctx, aml_store(minl, aml_name("MIN")));
aml_append(ifctx, aml_store(maxl, aml_name("MAX")));
aml_append(ifctx, aml_store(lenl, aml_name("LEN")));
aml_append(ifctx, aml_release(ctrl_lock));
aml_append(ifctx, aml_return(mr32));
}
aml_append(method, ifctx);
aml_append(method, aml_release(ctrl_lock));
aml_append(method, aml_return(mr64));
}
aml_append(mem_ctrl_dev, method);
method = aml_method(MEMORY_SLOT_PROXIMITY_METHOD, 1,
AML_NOTSERIALIZED);
{
Aml *proximity = aml_name(MEMORY_SLOT_PROXIMITY);
aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));
aml_append(method, aml_store(aml_to_integer(slot_arg0),
slot_selector));
aml_append(method, aml_store(proximity, ret_val));
aml_append(method, aml_release(ctrl_lock));
aml_append(method, aml_return(ret_val));
}
aml_append(mem_ctrl_dev, method);
method = aml_method(MEMORY_SLOT_OST_METHOD, 4, AML_NOTSERIALIZED);
{
Aml *ost_evt = aml_name(MEMORY_SLOT_OST_EVENT);
Aml *ost_status = aml_name(MEMORY_SLOT_OST_STATUS);
aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));
aml_append(method, aml_store(aml_to_integer(slot_arg0),
slot_selector));
aml_append(method, aml_store(aml_arg(1), ost_evt));
aml_append(method, aml_store(aml_arg(2), ost_status));
aml_append(method, aml_release(ctrl_lock));
}
aml_append(mem_ctrl_dev, method);
method = aml_method(MEMORY_SLOT_EJECT_METHOD, 2, AML_NOTSERIALIZED);
{
Aml *eject = aml_name(MEMORY_SLOT_EJECT);
aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));
aml_append(method, aml_store(aml_to_integer(slot_arg0),
slot_selector));
aml_append(method, aml_store(one, eject));
aml_append(method, aml_release(ctrl_lock));
}
aml_append(mem_ctrl_dev, method);
}
aml_append(table, mem_ctrl_dev);
sb_scope = aml_scope("_SB");
for (i = 0; i < nr_mem; i++) {
Aml *dev;
char *s;
dev = aml_device("MP%02X", i);
aml_append(dev, aml_name_decl("_UID", aml_string("0x%02X", i)));
aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C80")));
method = aml_method("_CRS", 0, AML_NOTSERIALIZED);
s = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_CRS_METHOD);
aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
g_free(s);
aml_append(dev, method);
method = aml_method("_STA", 0, AML_NOTSERIALIZED);
s = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_STATUS_METHOD);
aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
g_free(s);
aml_append(dev, method);
method = aml_method("_PXM", 0, AML_NOTSERIALIZED);
s = g_strdup_printf("%s.%s", mhp_res_path,
MEMORY_SLOT_PROXIMITY_METHOD);
aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
g_free(s);
aml_append(dev, method);
method = aml_method("_OST", 3, AML_NOTSERIALIZED);
s = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_OST_METHOD);
aml_append(method, aml_return(aml_call4(
s, aml_name("_UID"), aml_arg(0), aml_arg(1), aml_arg(2)
)));
g_free(s);
aml_append(dev, method);
method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
s = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_EJECT_METHOD);
aml_append(method, aml_return(aml_call2(
s, aml_name("_UID"), aml_arg(0))));
g_free(s);
aml_append(dev, method);
aml_append(sb_scope, dev);
}
method = aml_method(MEMORY_SLOT_NOTIFY_METHOD, 2, AML_NOTSERIALIZED);
for (i = 0; i < nr_mem; i++) {
ifctx = aml_if(aml_equal(aml_arg(0), aml_int(i)));
aml_append(ifctx,
aml_notify(aml_name("MP%.02X", i), aml_arg(1))
);
aml_append(method, ifctx);
}
aml_append(sb_scope, method);
aml_append(table, sb_scope);
method = aml_method(event_handler_method, 0, AML_NOTSERIALIZED);
scan_path = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_SCAN_METHOD);
aml_append(method, aml_call0(scan_path));
g_free(scan_path);
aml_append(table, method);
g_free(mhp_res_path);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(Aml *VAR_0, uint32_t VAR_1,
uint16_t VAR_2, uint16_t VAR_3,
const char *VAR_4,
const char *VAR_5)
{
int VAR_6;
Aml *ifctx;
Aml *method;
Aml *sb_scope;
Aml *mem_ctrl_dev;
char *VAR_7;
char *VAR_8 = g_strdup_printf("%s." MEMORY_HOTPLUG_DEVICE, VAR_4);
mem_ctrl_dev = aml_device("%s", VAR_8);
{
Aml *crs;
Aml *field;
Aml *one = aml_int(1);
Aml *zero = aml_int(0);
Aml *ret_val = aml_local(0);
Aml *slot_arg0 = aml_arg(0);
Aml *slots_nr = aml_name(MEMORY_SLOTS_NUMBER);
Aml *ctrl_lock = aml_name(MEMORY_SLOT_LOCK);
Aml *slot_selector = aml_name(MEMORY_SLOT_SLECTOR);
aml_append(mem_ctrl_dev, aml_name_decl("_HID", aml_string("PNP0A06")));
aml_append(mem_ctrl_dev,
aml_name_decl("_UID", aml_string("Memory hotplug resources")));
assert(VAR_1 <= ACPI_MAX_RAM_SLOTS);
aml_append(mem_ctrl_dev,
aml_name_decl(MEMORY_SLOTS_NUMBER, aml_int(VAR_1))
);
crs = aml_resource_template();
aml_append(crs,
aml_io(AML_DECODE16, VAR_2, VAR_2, 0, VAR_3)
);
aml_append(mem_ctrl_dev, aml_name_decl("_CRS", crs));
aml_append(mem_ctrl_dev, aml_operation_region(
MEMORY_HOTPLUG_IO_REGION, AML_SYSTEM_IO,
aml_int(VAR_2), VAR_3)
);
field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,
AML_NOLOCK, AML_PRESERVE);
aml_append(field,
aml_named_field(MEMORY_SLOT_ADDR_LOW, 32));
aml_append(field,
aml_named_field(MEMORY_SLOT_ADDR_HIGH, 32));
aml_append(field,
aml_named_field(MEMORY_SLOT_SIZE_LOW, 32));
aml_append(field,
aml_named_field(MEMORY_SLOT_SIZE_HIGH, 32));
aml_append(field,
aml_named_field(MEMORY_SLOT_PROXIMITY, 32));
aml_append(mem_ctrl_dev, field);
field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_BYTE_ACC,
AML_NOLOCK, AML_WRITE_AS_ZEROS);
aml_append(field, aml_reserved_field(160 ));
aml_append(field,
aml_named_field(MEMORY_SLOT_ENABLED, 1));
aml_append(field,
aml_named_field(MEMORY_SLOT_INSERT_EVENT, 1));
aml_append(field,
aml_named_field(MEMORY_SLOT_REMOVE_EVENT, 1));
aml_append(field,
aml_named_field(MEMORY_SLOT_EJECT, 1));
aml_append(mem_ctrl_dev, field);
field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,
AML_NOLOCK, AML_PRESERVE);
aml_append(field,
aml_named_field(MEMORY_SLOT_SLECTOR, 32));
aml_append(field,
aml_named_field(MEMORY_SLOT_OST_EVENT, 32));
aml_append(field,
aml_named_field(MEMORY_SLOT_OST_STATUS, 32));
aml_append(mem_ctrl_dev, field);
method = aml_method("_STA", 0, AML_NOTSERIALIZED);
ifctx = aml_if(aml_equal(slots_nr, zero));
{
aml_append(ifctx, aml_return(zero));
}
aml_append(method, ifctx);
aml_append(method, aml_return(aml_int(0xB)));
aml_append(mem_ctrl_dev, method);
aml_append(mem_ctrl_dev, aml_mutex(MEMORY_SLOT_LOCK, 0));
method = aml_method(MEMORY_SLOT_SCAN_METHOD, 0, AML_NOTSERIALIZED);
{
Aml *else_ctx;
Aml *while_ctx;
Aml *idx = aml_local(0);
Aml *eject_req = aml_int(3);
Aml *dev_chk = aml_int(1);
ifctx = aml_if(aml_equal(slots_nr, zero));
{
aml_append(ifctx, aml_return(zero));
}
aml_append(method, ifctx);
aml_append(method, aml_store(zero, idx));
aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));
while_ctx = aml_while(aml_lless(idx, slots_nr));
{
Aml *ins_evt = aml_name(MEMORY_SLOT_INSERT_EVENT);
Aml *rm_evt = aml_name(MEMORY_SLOT_REMOVE_EVENT);
aml_append(while_ctx, aml_store(idx, slot_selector));
ifctx = aml_if(aml_equal(ins_evt, one));
{
aml_append(ifctx,
aml_call2(MEMORY_SLOT_NOTIFY_METHOD,
idx, dev_chk));
aml_append(ifctx, aml_store(one, ins_evt));
}
aml_append(while_ctx, ifctx);
else_ctx = aml_else();
ifctx = aml_if(aml_equal(rm_evt, one));
{
aml_append(ifctx,
aml_call2(MEMORY_SLOT_NOTIFY_METHOD,
idx, eject_req));
aml_append(ifctx, aml_store(one, rm_evt));
}
aml_append(else_ctx, ifctx);
aml_append(while_ctx, else_ctx);
aml_append(while_ctx, aml_add(idx, one, idx));
}
aml_append(method, while_ctx);
aml_append(method, aml_release(ctrl_lock));
aml_append(method, aml_return(one));
}
aml_append(mem_ctrl_dev, method);
method = aml_method(MEMORY_SLOT_STATUS_METHOD, 1, AML_NOTSERIALIZED);
{
Aml *slot_enabled = aml_name(MEMORY_SLOT_ENABLED);
aml_append(method, aml_store(zero, ret_val));
aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));
aml_append(method,
aml_store(aml_to_integer(slot_arg0), slot_selector));
ifctx = aml_if(aml_equal(slot_enabled, one));
{
aml_append(ifctx, aml_store(aml_int(0xF), ret_val));
}
aml_append(method, ifctx);
aml_append(method, aml_release(ctrl_lock));
aml_append(method, aml_return(ret_val));
}
aml_append(mem_ctrl_dev, method);
method = aml_method(MEMORY_SLOT_CRS_METHOD, 1, AML_SERIALIZED);
{
Aml *mr64 = aml_name("MR64");
Aml *mr32 = aml_name("MR32");
Aml *crs_tmpl = aml_resource_template();
Aml *minl = aml_name("MINL");
Aml *minh = aml_name("MINH");
Aml *maxl = aml_name("MAXL");
Aml *maxh = aml_name("MAXH");
Aml *lenl = aml_name("LENL");
Aml *lenh = aml_name("LENH");
aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));
aml_append(method, aml_store(aml_to_integer(slot_arg0),
slot_selector));
aml_append(crs_tmpl,
aml_qword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED,
AML_CACHEABLE, AML_READ_WRITE,
0, 0x0, 0xFFFFFFFFFFFFFFFEULL, 0,
0xFFFFFFFFFFFFFFFFULL));
aml_append(method, aml_name_decl("MR64", crs_tmpl));
aml_append(method,
aml_create_dword_field(mr64, aml_int(14), "MINL"));
aml_append(method,
aml_create_dword_field(mr64, aml_int(18), "MINH"));
aml_append(method,
aml_create_dword_field(mr64, aml_int(38), "LENL"));
aml_append(method,
aml_create_dword_field(mr64, aml_int(42), "LENH"));
aml_append(method,
aml_create_dword_field(mr64, aml_int(22), "MAXL"));
aml_append(method,
aml_create_dword_field(mr64, aml_int(26), "MAXH"));
aml_append(method,
aml_store(aml_name(MEMORY_SLOT_ADDR_HIGH), minh));
aml_append(method,
aml_store(aml_name(MEMORY_SLOT_ADDR_LOW), minl));
aml_append(method,
aml_store(aml_name(MEMORY_SLOT_SIZE_HIGH), lenh));
aml_append(method,
aml_store(aml_name(MEMORY_SLOT_SIZE_LOW), lenl));
aml_append(method, aml_add(minl, lenl, maxl));
aml_append(method, aml_add(minh, lenh, maxh));
ifctx = aml_if(aml_lless(maxl, minl));
{
aml_append(ifctx, aml_add(maxh, one, maxh));
}
aml_append(method, ifctx);
ifctx = aml_if(aml_lless(maxl, one));
{
aml_append(ifctx, aml_subtract(maxh, one, maxh));
}
aml_append(method, ifctx);
aml_append(method, aml_subtract(maxl, one, maxl));
ifctx = aml_if(aml_equal(maxh, zero));
{
crs_tmpl = aml_resource_template();
aml_append(crs_tmpl,
aml_dword_memory(AML_POS_DECODE, AML_MIN_FIXED,
AML_MAX_FIXED, AML_CACHEABLE,
AML_READ_WRITE,
0, 0x0, 0xFFFFFFFE, 0,
0xFFFFFFFF));
aml_append(ifctx, aml_name_decl("MR32", crs_tmpl));
aml_append(ifctx,
aml_create_dword_field(mr32, aml_int(10), "MIN"));
aml_append(ifctx,
aml_create_dword_field(mr32, aml_int(14), "MAX"));
aml_append(ifctx,
aml_create_dword_field(mr32, aml_int(22), "LEN"));
aml_append(ifctx, aml_store(minl, aml_name("MIN")));
aml_append(ifctx, aml_store(maxl, aml_name("MAX")));
aml_append(ifctx, aml_store(lenl, aml_name("LEN")));
aml_append(ifctx, aml_release(ctrl_lock));
aml_append(ifctx, aml_return(mr32));
}
aml_append(method, ifctx);
aml_append(method, aml_release(ctrl_lock));
aml_append(method, aml_return(mr64));
}
aml_append(mem_ctrl_dev, method);
method = aml_method(MEMORY_SLOT_PROXIMITY_METHOD, 1,
AML_NOTSERIALIZED);
{
Aml *proximity = aml_name(MEMORY_SLOT_PROXIMITY);
aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));
aml_append(method, aml_store(aml_to_integer(slot_arg0),
slot_selector));
aml_append(method, aml_store(proximity, ret_val));
aml_append(method, aml_release(ctrl_lock));
aml_append(method, aml_return(ret_val));
}
aml_append(mem_ctrl_dev, method);
method = aml_method(MEMORY_SLOT_OST_METHOD, 4, AML_NOTSERIALIZED);
{
Aml *ost_evt = aml_name(MEMORY_SLOT_OST_EVENT);
Aml *ost_status = aml_name(MEMORY_SLOT_OST_STATUS);
aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));
aml_append(method, aml_store(aml_to_integer(slot_arg0),
slot_selector));
aml_append(method, aml_store(aml_arg(1), ost_evt));
aml_append(method, aml_store(aml_arg(2), ost_status));
aml_append(method, aml_release(ctrl_lock));
}
aml_append(mem_ctrl_dev, method);
method = aml_method(MEMORY_SLOT_EJECT_METHOD, 2, AML_NOTSERIALIZED);
{
Aml *eject = aml_name(MEMORY_SLOT_EJECT);
aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));
aml_append(method, aml_store(aml_to_integer(slot_arg0),
slot_selector));
aml_append(method, aml_store(one, eject));
aml_append(method, aml_release(ctrl_lock));
}
aml_append(mem_ctrl_dev, method);
}
aml_append(VAR_0, mem_ctrl_dev);
sb_scope = aml_scope("_SB");
for (VAR_6 = 0; VAR_6 < VAR_1; VAR_6++) {
Aml *dev;
char *s;
dev = aml_device("MP%02X", VAR_6);
aml_append(dev, aml_name_decl("_UID", aml_string("0x%02X", VAR_6)));
aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C80")));
method = aml_method("_CRS", 0, AML_NOTSERIALIZED);
s = g_strdup_printf("%s.%s", VAR_8, MEMORY_SLOT_CRS_METHOD);
aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
g_free(s);
aml_append(dev, method);
method = aml_method("_STA", 0, AML_NOTSERIALIZED);
s = g_strdup_printf("%s.%s", VAR_8, MEMORY_SLOT_STATUS_METHOD);
aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
g_free(s);
aml_append(dev, method);
method = aml_method("_PXM", 0, AML_NOTSERIALIZED);
s = g_strdup_printf("%s.%s", VAR_8,
MEMORY_SLOT_PROXIMITY_METHOD);
aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
g_free(s);
aml_append(dev, method);
method = aml_method("_OST", 3, AML_NOTSERIALIZED);
s = g_strdup_printf("%s.%s", VAR_8, MEMORY_SLOT_OST_METHOD);
aml_append(method, aml_return(aml_call4(
s, aml_name("_UID"), aml_arg(0), aml_arg(1), aml_arg(2)
)));
g_free(s);
aml_append(dev, method);
method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
s = g_strdup_printf("%s.%s", VAR_8, MEMORY_SLOT_EJECT_METHOD);
aml_append(method, aml_return(aml_call2(
s, aml_name("_UID"), aml_arg(0))));
g_free(s);
aml_append(dev, method);
aml_append(sb_scope, dev);
}
method = aml_method(MEMORY_SLOT_NOTIFY_METHOD, 2, AML_NOTSERIALIZED);
for (VAR_6 = 0; VAR_6 < VAR_1; VAR_6++) {
ifctx = aml_if(aml_equal(aml_arg(0), aml_int(VAR_6)));
aml_append(ifctx,
aml_notify(aml_name("MP%.02X", VAR_6), aml_arg(1))
);
aml_append(method, ifctx);
}
aml_append(sb_scope, method);
aml_append(VAR_0, sb_scope);
method = aml_method(VAR_5, 0, AML_NOTSERIALIZED);
VAR_7 = g_strdup_printf("%s.%s", VAR_8, MEMORY_SLOT_SCAN_METHOD);
aml_append(method, aml_call0(VAR_7));
g_free(VAR_7);
aml_append(VAR_0, method);
g_free(VAR_8);
}
| [
"void FUNC_0(Aml *VAR_0, uint32_t VAR_1,\nuint16_t VAR_2, uint16_t VAR_3,\nconst char *VAR_4,\nconst char *VAR_5)\n{",
"int VAR_6;",
"Aml *ifctx;",
"Aml *method;",
"Aml *sb_scope;",
"Aml *mem_ctrl_dev;",
"char *VAR_7;",
"char *VAR_8 = g_strdup_printf(\"%s.\" MEMORY_HOTPLUG_DEVICE, VAR_4);",
"mem_ctrl_dev = aml_device(\"%s\", VAR_8);",
"{",
"Aml *crs;",
"Aml *field;",
"Aml *one = aml_int(1);",
"Aml *zero = aml_int(0);",
"Aml *ret_val = aml_local(0);",
"Aml *slot_arg0 = aml_arg(0);",
"Aml *slots_nr = aml_name(MEMORY_SLOTS_NUMBER);",
"Aml *ctrl_lock = aml_name(MEMORY_SLOT_LOCK);",
"Aml *slot_selector = aml_name(MEMORY_SLOT_SLECTOR);",
"aml_append(mem_ctrl_dev, aml_name_decl(\"_HID\", aml_string(\"PNP0A06\")));",
"aml_append(mem_ctrl_dev,\naml_name_decl(\"_UID\", aml_string(\"Memory hotplug resources\")));",
"assert(VAR_1 <= ACPI_MAX_RAM_SLOTS);",
"aml_append(mem_ctrl_dev,\naml_name_decl(MEMORY_SLOTS_NUMBER, aml_int(VAR_1))\n);",
"crs = aml_resource_template();",
"aml_append(crs,\naml_io(AML_DECODE16, VAR_2, VAR_2, 0, VAR_3)\n);",
"aml_append(mem_ctrl_dev, aml_name_decl(\"_CRS\", crs));",
"aml_append(mem_ctrl_dev, aml_operation_region(\nMEMORY_HOTPLUG_IO_REGION, AML_SYSTEM_IO,\naml_int(VAR_2), VAR_3)\n);",
"field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,\nAML_NOLOCK, AML_PRESERVE);",
"aml_append(field,\naml_named_field(MEMORY_SLOT_ADDR_LOW, 32));",
"aml_append(field,\naml_named_field(MEMORY_SLOT_ADDR_HIGH, 32));",
"aml_append(field,\naml_named_field(MEMORY_SLOT_SIZE_LOW, 32));",
"aml_append(field,\naml_named_field(MEMORY_SLOT_SIZE_HIGH, 32));",
"aml_append(field,\naml_named_field(MEMORY_SLOT_PROXIMITY, 32));",
"aml_append(mem_ctrl_dev, field);",
"field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_BYTE_ACC,\nAML_NOLOCK, AML_WRITE_AS_ZEROS);",
"aml_append(field, aml_reserved_field(160 ));",
"aml_append(field,\naml_named_field(MEMORY_SLOT_ENABLED, 1));",
"aml_append(field,\naml_named_field(MEMORY_SLOT_INSERT_EVENT, 1));",
"aml_append(field,\naml_named_field(MEMORY_SLOT_REMOVE_EVENT, 1));",
"aml_append(field,\naml_named_field(MEMORY_SLOT_EJECT, 1));",
"aml_append(mem_ctrl_dev, field);",
"field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,\nAML_NOLOCK, AML_PRESERVE);",
"aml_append(field,\naml_named_field(MEMORY_SLOT_SLECTOR, 32));",
"aml_append(field,\naml_named_field(MEMORY_SLOT_OST_EVENT, 32));",
"aml_append(field,\naml_named_field(MEMORY_SLOT_OST_STATUS, 32));",
"aml_append(mem_ctrl_dev, field);",
"method = aml_method(\"_STA\", 0, AML_NOTSERIALIZED);",
"ifctx = aml_if(aml_equal(slots_nr, zero));",
"{",
"aml_append(ifctx, aml_return(zero));",
"}",
"aml_append(method, ifctx);",
"aml_append(method, aml_return(aml_int(0xB)));",
"aml_append(mem_ctrl_dev, method);",
"aml_append(mem_ctrl_dev, aml_mutex(MEMORY_SLOT_LOCK, 0));",
"method = aml_method(MEMORY_SLOT_SCAN_METHOD, 0, AML_NOTSERIALIZED);",
"{",
"Aml *else_ctx;",
"Aml *while_ctx;",
"Aml *idx = aml_local(0);",
"Aml *eject_req = aml_int(3);",
"Aml *dev_chk = aml_int(1);",
"ifctx = aml_if(aml_equal(slots_nr, zero));",
"{",
"aml_append(ifctx, aml_return(zero));",
"}",
"aml_append(method, ifctx);",
"aml_append(method, aml_store(zero, idx));",
"aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));",
"while_ctx = aml_while(aml_lless(idx, slots_nr));",
"{",
"Aml *ins_evt = aml_name(MEMORY_SLOT_INSERT_EVENT);",
"Aml *rm_evt = aml_name(MEMORY_SLOT_REMOVE_EVENT);",
"aml_append(while_ctx, aml_store(idx, slot_selector));",
"ifctx = aml_if(aml_equal(ins_evt, one));",
"{",
"aml_append(ifctx,\naml_call2(MEMORY_SLOT_NOTIFY_METHOD,\nidx, dev_chk));",
"aml_append(ifctx, aml_store(one, ins_evt));",
"}",
"aml_append(while_ctx, ifctx);",
"else_ctx = aml_else();",
"ifctx = aml_if(aml_equal(rm_evt, one));",
"{",
"aml_append(ifctx,\naml_call2(MEMORY_SLOT_NOTIFY_METHOD,\nidx, eject_req));",
"aml_append(ifctx, aml_store(one, rm_evt));",
"}",
"aml_append(else_ctx, ifctx);",
"aml_append(while_ctx, else_ctx);",
"aml_append(while_ctx, aml_add(idx, one, idx));",
"}",
"aml_append(method, while_ctx);",
"aml_append(method, aml_release(ctrl_lock));",
"aml_append(method, aml_return(one));",
"}",
"aml_append(mem_ctrl_dev, method);",
"method = aml_method(MEMORY_SLOT_STATUS_METHOD, 1, AML_NOTSERIALIZED);",
"{",
"Aml *slot_enabled = aml_name(MEMORY_SLOT_ENABLED);",
"aml_append(method, aml_store(zero, ret_val));",
"aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));",
"aml_append(method,\naml_store(aml_to_integer(slot_arg0), slot_selector));",
"ifctx = aml_if(aml_equal(slot_enabled, one));",
"{",
"aml_append(ifctx, aml_store(aml_int(0xF), ret_val));",
"}",
"aml_append(method, ifctx);",
"aml_append(method, aml_release(ctrl_lock));",
"aml_append(method, aml_return(ret_val));",
"}",
"aml_append(mem_ctrl_dev, method);",
"method = aml_method(MEMORY_SLOT_CRS_METHOD, 1, AML_SERIALIZED);",
"{",
"Aml *mr64 = aml_name(\"MR64\");",
"Aml *mr32 = aml_name(\"MR32\");",
"Aml *crs_tmpl = aml_resource_template();",
"Aml *minl = aml_name(\"MINL\");",
"Aml *minh = aml_name(\"MINH\");",
"Aml *maxl = aml_name(\"MAXL\");",
"Aml *maxh = aml_name(\"MAXH\");",
"Aml *lenl = aml_name(\"LENL\");",
"Aml *lenh = aml_name(\"LENH\");",
"aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));",
"aml_append(method, aml_store(aml_to_integer(slot_arg0),\nslot_selector));",
"aml_append(crs_tmpl,\naml_qword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED,\nAML_CACHEABLE, AML_READ_WRITE,\n0, 0x0, 0xFFFFFFFFFFFFFFFEULL, 0,\n0xFFFFFFFFFFFFFFFFULL));",
"aml_append(method, aml_name_decl(\"MR64\", crs_tmpl));",
"aml_append(method,\naml_create_dword_field(mr64, aml_int(14), \"MINL\"));",
"aml_append(method,\naml_create_dword_field(mr64, aml_int(18), \"MINH\"));",
"aml_append(method,\naml_create_dword_field(mr64, aml_int(38), \"LENL\"));",
"aml_append(method,\naml_create_dword_field(mr64, aml_int(42), \"LENH\"));",
"aml_append(method,\naml_create_dword_field(mr64, aml_int(22), \"MAXL\"));",
"aml_append(method,\naml_create_dword_field(mr64, aml_int(26), \"MAXH\"));",
"aml_append(method,\naml_store(aml_name(MEMORY_SLOT_ADDR_HIGH), minh));",
"aml_append(method,\naml_store(aml_name(MEMORY_SLOT_ADDR_LOW), minl));",
"aml_append(method,\naml_store(aml_name(MEMORY_SLOT_SIZE_HIGH), lenh));",
"aml_append(method,\naml_store(aml_name(MEMORY_SLOT_SIZE_LOW), lenl));",
"aml_append(method, aml_add(minl, lenl, maxl));",
"aml_append(method, aml_add(minh, lenh, maxh));",
"ifctx = aml_if(aml_lless(maxl, minl));",
"{",
"aml_append(ifctx, aml_add(maxh, one, maxh));",
"}",
"aml_append(method, ifctx);",
"ifctx = aml_if(aml_lless(maxl, one));",
"{",
"aml_append(ifctx, aml_subtract(maxh, one, maxh));",
"}",
"aml_append(method, ifctx);",
"aml_append(method, aml_subtract(maxl, one, maxl));",
"ifctx = aml_if(aml_equal(maxh, zero));",
"{",
"crs_tmpl = aml_resource_template();",
"aml_append(crs_tmpl,\naml_dword_memory(AML_POS_DECODE, AML_MIN_FIXED,\nAML_MAX_FIXED, AML_CACHEABLE,\nAML_READ_WRITE,\n0, 0x0, 0xFFFFFFFE, 0,\n0xFFFFFFFF));",
"aml_append(ifctx, aml_name_decl(\"MR32\", crs_tmpl));",
"aml_append(ifctx,\naml_create_dword_field(mr32, aml_int(10), \"MIN\"));",
"aml_append(ifctx,\naml_create_dword_field(mr32, aml_int(14), \"MAX\"));",
"aml_append(ifctx,\naml_create_dword_field(mr32, aml_int(22), \"LEN\"));",
"aml_append(ifctx, aml_store(minl, aml_name(\"MIN\")));",
"aml_append(ifctx, aml_store(maxl, aml_name(\"MAX\")));",
"aml_append(ifctx, aml_store(lenl, aml_name(\"LEN\")));",
"aml_append(ifctx, aml_release(ctrl_lock));",
"aml_append(ifctx, aml_return(mr32));",
"}",
"aml_append(method, ifctx);",
"aml_append(method, aml_release(ctrl_lock));",
"aml_append(method, aml_return(mr64));",
"}",
"aml_append(mem_ctrl_dev, method);",
"method = aml_method(MEMORY_SLOT_PROXIMITY_METHOD, 1,\nAML_NOTSERIALIZED);",
"{",
"Aml *proximity = aml_name(MEMORY_SLOT_PROXIMITY);",
"aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));",
"aml_append(method, aml_store(aml_to_integer(slot_arg0),\nslot_selector));",
"aml_append(method, aml_store(proximity, ret_val));",
"aml_append(method, aml_release(ctrl_lock));",
"aml_append(method, aml_return(ret_val));",
"}",
"aml_append(mem_ctrl_dev, method);",
"method = aml_method(MEMORY_SLOT_OST_METHOD, 4, AML_NOTSERIALIZED);",
"{",
"Aml *ost_evt = aml_name(MEMORY_SLOT_OST_EVENT);",
"Aml *ost_status = aml_name(MEMORY_SLOT_OST_STATUS);",
"aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));",
"aml_append(method, aml_store(aml_to_integer(slot_arg0),\nslot_selector));",
"aml_append(method, aml_store(aml_arg(1), ost_evt));",
"aml_append(method, aml_store(aml_arg(2), ost_status));",
"aml_append(method, aml_release(ctrl_lock));",
"}",
"aml_append(mem_ctrl_dev, method);",
"method = aml_method(MEMORY_SLOT_EJECT_METHOD, 2, AML_NOTSERIALIZED);",
"{",
"Aml *eject = aml_name(MEMORY_SLOT_EJECT);",
"aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));",
"aml_append(method, aml_store(aml_to_integer(slot_arg0),\nslot_selector));",
"aml_append(method, aml_store(one, eject));",
"aml_append(method, aml_release(ctrl_lock));",
"}",
"aml_append(mem_ctrl_dev, method);",
"}",
"aml_append(VAR_0, mem_ctrl_dev);",
"sb_scope = aml_scope(\"_SB\");",
"for (VAR_6 = 0; VAR_6 < VAR_1; VAR_6++) {",
"Aml *dev;",
"char *s;",
"dev = aml_device(\"MP%02X\", VAR_6);",
"aml_append(dev, aml_name_decl(\"_UID\", aml_string(\"0x%02X\", VAR_6)));",
"aml_append(dev, aml_name_decl(\"_HID\", aml_eisaid(\"PNP0C80\")));",
"method = aml_method(\"_CRS\", 0, AML_NOTSERIALIZED);",
"s = g_strdup_printf(\"%s.%s\", VAR_8, MEMORY_SLOT_CRS_METHOD);",
"aml_append(method, aml_return(aml_call1(s, aml_name(\"_UID\"))));",
"g_free(s);",
"aml_append(dev, method);",
"method = aml_method(\"_STA\", 0, AML_NOTSERIALIZED);",
"s = g_strdup_printf(\"%s.%s\", VAR_8, MEMORY_SLOT_STATUS_METHOD);",
"aml_append(method, aml_return(aml_call1(s, aml_name(\"_UID\"))));",
"g_free(s);",
"aml_append(dev, method);",
"method = aml_method(\"_PXM\", 0, AML_NOTSERIALIZED);",
"s = g_strdup_printf(\"%s.%s\", VAR_8,\nMEMORY_SLOT_PROXIMITY_METHOD);",
"aml_append(method, aml_return(aml_call1(s, aml_name(\"_UID\"))));",
"g_free(s);",
"aml_append(dev, method);",
"method = aml_method(\"_OST\", 3, AML_NOTSERIALIZED);",
"s = g_strdup_printf(\"%s.%s\", VAR_8, MEMORY_SLOT_OST_METHOD);",
"aml_append(method, aml_return(aml_call4(\ns, aml_name(\"_UID\"), aml_arg(0), aml_arg(1), aml_arg(2)\n)));",
"g_free(s);",
"aml_append(dev, method);",
"method = aml_method(\"_EJ0\", 1, AML_NOTSERIALIZED);",
"s = g_strdup_printf(\"%s.%s\", VAR_8, MEMORY_SLOT_EJECT_METHOD);",
"aml_append(method, aml_return(aml_call2(\ns, aml_name(\"_UID\"), aml_arg(0))));",
"g_free(s);",
"aml_append(dev, method);",
"aml_append(sb_scope, dev);",
"}",
"method = aml_method(MEMORY_SLOT_NOTIFY_METHOD, 2, AML_NOTSERIALIZED);",
"for (VAR_6 = 0; VAR_6 < VAR_1; VAR_6++) {",
"ifctx = aml_if(aml_equal(aml_arg(0), aml_int(VAR_6)));",
"aml_append(ifctx,\naml_notify(aml_name(\"MP%.02X\", VAR_6), aml_arg(1))\n);",
"aml_append(method, ifctx);",
"}",
"aml_append(sb_scope, method);",
"aml_append(VAR_0, sb_scope);",
"method = aml_method(VAR_5, 0, AML_NOTSERIALIZED);",
"VAR_7 = g_strdup_printf(\"%s.%s\", VAR_8, MEMORY_SLOT_SCAN_METHOD);",
"aml_append(method, aml_call0(VAR_7));",
"g_free(VAR_7);",
"aml_append(VAR_0, method);",
"g_free(VAR_8);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53,
55
],
[
59
],
[
61,
63,
65
],
[
69
],
[
71,
73,
75
],
[
77
],
[
81,
83,
85,
87
],
[
91,
93
],
[
95,
97
],
[
99,
101
],
[
103,
105
],
[
107,
109
],
[
111,
113
],
[
115
],
[
119,
121
],
[
123
],
[
125,
127
],
[
129,
133
],
[
135,
139
],
[
141,
145
],
[
147
],
[
151,
153
],
[
155,
157
],
[
159,
161
],
[
163,
165
],
[
167
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
185
],
[
187
],
[
191
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
223
],
[
225
],
[
239
],
[
241
],
[
243
],
[
245
],
[
249
],
[
251
],
[
253
],
[
255,
257,
259
],
[
261
],
[
263
],
[
265
],
[
269
],
[
271
],
[
273
],
[
275,
277,
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
307
],
[
309
],
[
311
],
[
315
],
[
317
],
[
319,
321
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333
],
[
337
],
[
339
],
[
341
],
[
343
],
[
347
],
[
349
],
[
351
],
[
353
],
[
355
],
[
357
],
[
359
],
[
361
],
[
363
],
[
365
],
[
367
],
[
371
],
[
373,
375
],
[
379,
381,
383,
385,
387
],
[
389
],
[
391,
393
],
[
395,
397
],
[
399,
401
],
[
403,
405
],
[
407,
409
],
[
411,
413
],
[
417,
419
],
[
421,
423
],
[
425,
427
],
[
429,
431
],
[
437
],
[
439
],
[
441
],
[
443
],
[
445
],
[
447
],
[
449
],
[
451
],
[
453
],
[
455
],
[
457
],
[
459
],
[
461
],
[
469
],
[
471
],
[
473
],
[
475,
477,
479,
481,
483,
485
],
[
487
],
[
489,
491
],
[
493,
495
],
[
497,
499
],
[
501
],
[
503
],
[
505
],
[
509
],
[
511
],
[
513
],
[
515
],
[
519
],
[
521
],
[
523
],
[
525
],
[
529,
531
],
[
533
],
[
535
],
[
539
],
[
541,
543
],
[
545
],
[
547
],
[
549
],
[
551
],
[
553
],
[
557
],
[
559
],
[
561
],
[
563
],
[
567
],
[
569,
571
],
[
573
],
[
575
],
[
577
],
[
579
],
[
581
],
[
585
],
[
587
],
[
589
],
[
593
],
[
595,
597
],
[
599
],
[
601
],
[
603
],
[
605
],
[
607
],
[
609
],
[
613
],
[
617
],
[
619
],
[
621
],
[
625
],
[
627
],
[
629
],
[
633
],
[
635
],
[
637
],
[
639
],
[
641
],
[
645
],
[
647
],
[
649
],
[
651
],
[
653
],
[
657
],
[
659,
661
],
[
663
],
[
665
],
[
667
],
[
671
],
[
673
],
[
675,
677,
679
],
[
681
],
[
683
],
[
687
],
[
689
],
[
691,
693
],
[
695
],
[
697
],
[
701
],
[
703
],
[
713
],
[
715
],
[
717
],
[
719,
721,
723
],
[
725
],
[
727
],
[
729
],
[
731
],
[
735
],
[
737
],
[
739
],
[
741
],
[
743
],
[
747
],
[
749
]
] |
18,907 | char *g_strdup_printf(const char *format, ...)
{
char ch, *s;
size_t len;
__coverity_string_null_sink__(format);
__coverity_string_size_sink__(format);
ch = *format;
s = __coverity_alloc_nosize__();
__coverity_writeall__(s);
__coverity_mark_as_afm_allocated__(s, AFM_free);
return s;
}
| false | qemu | 7ad4c7200111d20eb97eed4f46b6026e3f0b0eef | char *g_strdup_printf(const char *format, ...)
{
char ch, *s;
size_t len;
__coverity_string_null_sink__(format);
__coverity_string_size_sink__(format);
ch = *format;
s = __coverity_alloc_nosize__();
__coverity_writeall__(s);
__coverity_mark_as_afm_allocated__(s, AFM_free);
return s;
}
| {
"code": [],
"line_no": []
} | char *FUNC_0(const char *VAR_0, ...)
{
char VAR_1, *VAR_2;
size_t len;
__coverity_string_null_sink__(VAR_0);
__coverity_string_size_sink__(VAR_0);
VAR_1 = *VAR_0;
VAR_2 = __coverity_alloc_nosize__();
__coverity_writeall__(VAR_2);
__coverity_mark_as_afm_allocated__(VAR_2, AFM_free);
return VAR_2;
}
| [
"char *FUNC_0(const char *VAR_0, ...)\n{",
"char VAR_1, *VAR_2;",
"size_t len;",
"__coverity_string_null_sink__(VAR_0);",
"__coverity_string_size_sink__(VAR_0);",
"VAR_1 = *VAR_0;",
"VAR_2 = __coverity_alloc_nosize__();",
"__coverity_writeall__(VAR_2);",
"__coverity_mark_as_afm_allocated__(VAR_2, AFM_free);",
"return VAR_2;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
]
] |
18,908 | static int check_features_against_host(x86_def_t *guest_def)
{
x86_def_t host_def;
uint32_t mask;
int rv, i;
struct model_features_t ft[] = {
{&guest_def->features, &host_def.features,
~0, feature_name, 0x00000000},
{&guest_def->ext_features, &host_def.ext_features,
~CPUID_EXT_HYPERVISOR, ext_feature_name, 0x00000001},
{&guest_def->ext2_features, &host_def.ext2_features,
~PPRO_FEATURES, ext2_feature_name, 0x80000000},
{&guest_def->ext3_features, &host_def.ext3_features,
~CPUID_EXT3_SVM, ext3_feature_name, 0x80000001}};
cpu_x86_fill_host(&host_def);
for (rv = 0, i = 0; i < ARRAY_SIZE(ft); ++i)
for (mask = 1; mask; mask <<= 1)
if (ft[i].check_feat & mask && *ft[i].guest_feat & mask &&
!(*ft[i].host_feat & mask)) {
unavailable_host_feature(&ft[i], mask);
rv = 1;
}
return rv;
}
| false | qemu | 6e746f30558cb1331598575918c2a8808be2a75b | static int check_features_against_host(x86_def_t *guest_def)
{
x86_def_t host_def;
uint32_t mask;
int rv, i;
struct model_features_t ft[] = {
{&guest_def->features, &host_def.features,
~0, feature_name, 0x00000000},
{&guest_def->ext_features, &host_def.ext_features,
~CPUID_EXT_HYPERVISOR, ext_feature_name, 0x00000001},
{&guest_def->ext2_features, &host_def.ext2_features,
~PPRO_FEATURES, ext2_feature_name, 0x80000000},
{&guest_def->ext3_features, &host_def.ext3_features,
~CPUID_EXT3_SVM, ext3_feature_name, 0x80000001}};
cpu_x86_fill_host(&host_def);
for (rv = 0, i = 0; i < ARRAY_SIZE(ft); ++i)
for (mask = 1; mask; mask <<= 1)
if (ft[i].check_feat & mask && *ft[i].guest_feat & mask &&
!(*ft[i].host_feat & mask)) {
unavailable_host_feature(&ft[i], mask);
rv = 1;
}
return rv;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(x86_def_t *VAR_0)
{
x86_def_t host_def;
uint32_t mask;
int VAR_1, VAR_2;
struct model_features_t VAR_3[] = {
{&VAR_0->features, &host_def.features,
~0, feature_name, 0x00000000},
{&VAR_0->ext_features, &host_def.ext_features,
~CPUID_EXT_HYPERVISOR, ext_feature_name, 0x00000001},
{&VAR_0->ext2_features, &host_def.ext2_features,
~PPRO_FEATURES, ext2_feature_name, 0x80000000},
{&VAR_0->ext3_features, &host_def.ext3_features,
~CPUID_EXT3_SVM, ext3_feature_name, 0x80000001}};
cpu_x86_fill_host(&host_def);
for (VAR_1 = 0, VAR_2 = 0; VAR_2 < ARRAY_SIZE(VAR_3); ++VAR_2)
for (mask = 1; mask; mask <<= 1)
if (VAR_3[VAR_2].check_feat & mask && *VAR_3[VAR_2].guest_feat & mask &&
!(*VAR_3[VAR_2].host_feat & mask)) {
unavailable_host_feature(&VAR_3[VAR_2], mask);
VAR_1 = 1;
}
return VAR_1;
}
| [
"static int FUNC_0(x86_def_t *VAR_0)\n{",
"x86_def_t host_def;",
"uint32_t mask;",
"int VAR_1, VAR_2;",
"struct model_features_t VAR_3[] = {",
"{&VAR_0->features, &host_def.features,",
"~0, feature_name, 0x00000000},",
"{&VAR_0->ext_features, &host_def.ext_features,",
"~CPUID_EXT_HYPERVISOR, ext_feature_name, 0x00000001},",
"{&VAR_0->ext2_features, &host_def.ext2_features,",
"~PPRO_FEATURES, ext2_feature_name, 0x80000000},",
"{&VAR_0->ext3_features, &host_def.ext3_features,",
"~CPUID_EXT3_SVM, ext3_feature_name, 0x80000001}};",
"cpu_x86_fill_host(&host_def);",
"for (VAR_1 = 0, VAR_2 = 0; VAR_2 < ARRAY_SIZE(VAR_3); ++VAR_2)",
"for (mask = 1; mask; mask <<= 1)",
"if (VAR_3[VAR_2].check_feat & mask && *VAR_3[VAR_2].guest_feat & mask &&\n!(*VAR_3[VAR_2].host_feat & mask)) {",
"unavailable_host_feature(&VAR_3[VAR_2], mask);",
"VAR_1 = 1;",
"}",
"return 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
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37,
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
]
] |
18,909 | static int rkmpp_retrieve_frame(AVCodecContext *avctx, AVFrame *frame)
{
RKMPPDecodeContext *rk_context = avctx->priv_data;
RKMPPDecoder *decoder = (RKMPPDecoder *)rk_context->decoder_ref->data;
RKMPPFrameContext *framecontext = NULL;
AVBufferRef *framecontextref = NULL;
int ret;
MppFrame mppframe = NULL;
MppBuffer buffer = NULL;
AVDRMFrameDescriptor *desc = NULL;
AVDRMLayerDescriptor *layer = NULL;
int retrycount = 0;
int mode;
MppFrameFormat mppformat;
uint32_t drmformat;
// on start of decoding, MPP can return -1, which is supposed to be expected
// this is due to some internal MPP init which is not completed, that will
// only happen in the first few frames queries, but should not be interpreted
// as an error, Therefore we need to retry a couple times when we get -1
// in order to let it time to complete it's init, then we sleep a bit between retries.
retry_get_frame:
ret = decoder->mpi->decode_get_frame(decoder->ctx, &mppframe);
if (ret != MPP_OK && ret != MPP_ERR_TIMEOUT && !decoder->first_frame) {
if (retrycount < 5) {
av_log(avctx, AV_LOG_DEBUG, "Failed to get a frame, retrying (code = %d, retrycount = %d)\n", ret, retrycount);
usleep(10000);
retrycount++;
goto retry_get_frame;
} else {
av_log(avctx, AV_LOG_ERROR, "Failed to get a frame from MPP (code = %d)\n", ret);
goto fail;
}
}
if (mppframe) {
// Check wether we have a special frame or not
if (mpp_frame_get_info_change(mppframe)) {
AVHWFramesContext *hwframes;
av_log(avctx, AV_LOG_INFO, "Decoder noticed an info change (%dx%d), format=%d\n",
(int)mpp_frame_get_width(mppframe), (int)mpp_frame_get_height(mppframe),
(int)mpp_frame_get_fmt(mppframe));
avctx->width = mpp_frame_get_width(mppframe);
avctx->height = mpp_frame_get_height(mppframe);
decoder->mpi->control(decoder->ctx, MPP_DEC_SET_INFO_CHANGE_READY, NULL);
decoder->first_frame = 1;
av_buffer_unref(&decoder->frames_ref);
decoder->frames_ref = av_hwframe_ctx_alloc(decoder->device_ref);
if (!decoder->frames_ref) {
ret = AVERROR(ENOMEM);
goto fail;
}
mppformat = mpp_frame_get_fmt(mppframe);
drmformat = rkmpp_get_frameformat(mppformat);
hwframes = (AVHWFramesContext*)decoder->frames_ref->data;
hwframes->format = AV_PIX_FMT_DRM_PRIME;
hwframes->sw_format = drmformat == DRM_FORMAT_NV12 ? AV_PIX_FMT_NV12 : AV_PIX_FMT_NONE;
hwframes->width = avctx->width;
hwframes->height = avctx->height;
ret = av_hwframe_ctx_init(decoder->frames_ref);
if (ret < 0)
goto fail;
// here decoder is fully initialized, we need to feed it again with data
ret = AVERROR(EAGAIN);
goto fail;
} else if (mpp_frame_get_eos(mppframe)) {
av_log(avctx, AV_LOG_DEBUG, "Received a EOS frame.\n");
decoder->eos_reached = 1;
ret = AVERROR_EOF;
goto fail;
} else if (mpp_frame_get_discard(mppframe)) {
av_log(avctx, AV_LOG_DEBUG, "Received a discard frame.\n");
ret = AVERROR(EAGAIN);
goto fail;
} else if (mpp_frame_get_errinfo(mppframe)) {
av_log(avctx, AV_LOG_ERROR, "Received a errinfo frame.\n");
ret = AVERROR_UNKNOWN;
goto fail;
}
// here we should have a valid frame
av_log(avctx, AV_LOG_DEBUG, "Received a frame.\n");
// setup general frame fields
frame->format = AV_PIX_FMT_DRM_PRIME;
frame->width = mpp_frame_get_width(mppframe);
frame->height = mpp_frame_get_height(mppframe);
frame->pts = mpp_frame_get_pts(mppframe);
frame->color_range = mpp_frame_get_color_range(mppframe);
frame->color_primaries = mpp_frame_get_color_primaries(mppframe);
frame->color_trc = mpp_frame_get_color_trc(mppframe);
frame->colorspace = mpp_frame_get_colorspace(mppframe);
mode = mpp_frame_get_mode(mppframe);
frame->interlaced_frame = ((mode & MPP_FRAME_FLAG_FIELD_ORDER_MASK) == MPP_FRAME_FLAG_DEINTERLACED);
frame->top_field_first = ((mode & MPP_FRAME_FLAG_FIELD_ORDER_MASK) == MPP_FRAME_FLAG_TOP_FIRST);
mppformat = mpp_frame_get_fmt(mppframe);
drmformat = rkmpp_get_frameformat(mppformat);
// now setup the frame buffer info
buffer = mpp_frame_get_buffer(mppframe);
if (buffer) {
desc = av_mallocz(sizeof(AVDRMFrameDescriptor));
if (!desc) {
ret = AVERROR(ENOMEM);
goto fail;
}
desc->nb_objects = 1;
desc->objects[0].fd = mpp_buffer_get_fd(buffer);
desc->objects[0].size = mpp_buffer_get_size(buffer);
desc->nb_layers = 1;
layer = &desc->layers[0];
layer->format = drmformat;
layer->nb_planes = 2;
layer->planes[0].object_index = 0;
layer->planes[0].offset = 0;
layer->planes[0].pitch = mpp_frame_get_hor_stride(mppframe);
layer->planes[1].object_index = 0;
layer->planes[1].offset = layer->planes[0].pitch * mpp_frame_get_ver_stride(mppframe);
layer->planes[1].pitch = layer->planes[0].pitch;
// we also allocate a struct in buf[0] that will allow to hold additionnal information
// for releasing properly MPP frames and decoder
framecontextref = av_buffer_allocz(sizeof(*framecontext));
if (!framecontextref) {
ret = AVERROR(ENOMEM);
goto fail;
}
// MPP decoder needs to be closed only when all frames have been released.
framecontext = (RKMPPFrameContext *)framecontextref->data;
framecontext->decoder_ref = av_buffer_ref(rk_context->decoder_ref);
framecontext->frame = mppframe;
frame->data[0] = (uint8_t *)desc;
frame->buf[0] = av_buffer_create((uint8_t *)desc, sizeof(*desc), rkmpp_release_frame,
framecontextref, AV_BUFFER_FLAG_READONLY);
if (!frame->buf[0]) {
ret = AVERROR(ENOMEM);
goto fail;
}
frame->hw_frames_ctx = av_buffer_ref(decoder->frames_ref);
if (!frame->hw_frames_ctx) {
ret = AVERROR(ENOMEM);
goto fail;
}
decoder->first_frame = 0;
return 0;
} else {
av_log(avctx, AV_LOG_ERROR, "Failed to retrieve the frame buffer, frame is dropped (code = %d)\n", ret);
mpp_frame_deinit(&mppframe);
}
} else if (decoder->eos_reached) {
return AVERROR_EOF;
} else if (ret == MPP_ERR_TIMEOUT) {
av_log(avctx, AV_LOG_DEBUG, "Timeout when trying to get a frame from MPP\n");
}
return AVERROR(EAGAIN);
fail:
if (mppframe)
mpp_frame_deinit(&mppframe);
if (framecontext)
av_buffer_unref(&framecontext->decoder_ref);
if (framecontextref)
av_buffer_unref(&framecontextref);
if (desc)
av_free(desc);
return ret;
}
| false | FFmpeg | 7bec3f78da2533968b7246ff222770582ab4aafb | static int rkmpp_retrieve_frame(AVCodecContext *avctx, AVFrame *frame)
{
RKMPPDecodeContext *rk_context = avctx->priv_data;
RKMPPDecoder *decoder = (RKMPPDecoder *)rk_context->decoder_ref->data;
RKMPPFrameContext *framecontext = NULL;
AVBufferRef *framecontextref = NULL;
int ret;
MppFrame mppframe = NULL;
MppBuffer buffer = NULL;
AVDRMFrameDescriptor *desc = NULL;
AVDRMLayerDescriptor *layer = NULL;
int retrycount = 0;
int mode;
MppFrameFormat mppformat;
uint32_t drmformat;
retry_get_frame:
ret = decoder->mpi->decode_get_frame(decoder->ctx, &mppframe);
if (ret != MPP_OK && ret != MPP_ERR_TIMEOUT && !decoder->first_frame) {
if (retrycount < 5) {
av_log(avctx, AV_LOG_DEBUG, "Failed to get a frame, retrying (code = %d, retrycount = %d)\n", ret, retrycount);
usleep(10000);
retrycount++;
goto retry_get_frame;
} else {
av_log(avctx, AV_LOG_ERROR, "Failed to get a frame from MPP (code = %d)\n", ret);
goto fail;
}
}
if (mppframe) {
if (mpp_frame_get_info_change(mppframe)) {
AVHWFramesContext *hwframes;
av_log(avctx, AV_LOG_INFO, "Decoder noticed an info change (%dx%d), format=%d\n",
(int)mpp_frame_get_width(mppframe), (int)mpp_frame_get_height(mppframe),
(int)mpp_frame_get_fmt(mppframe));
avctx->width = mpp_frame_get_width(mppframe);
avctx->height = mpp_frame_get_height(mppframe);
decoder->mpi->control(decoder->ctx, MPP_DEC_SET_INFO_CHANGE_READY, NULL);
decoder->first_frame = 1;
av_buffer_unref(&decoder->frames_ref);
decoder->frames_ref = av_hwframe_ctx_alloc(decoder->device_ref);
if (!decoder->frames_ref) {
ret = AVERROR(ENOMEM);
goto fail;
}
mppformat = mpp_frame_get_fmt(mppframe);
drmformat = rkmpp_get_frameformat(mppformat);
hwframes = (AVHWFramesContext*)decoder->frames_ref->data;
hwframes->format = AV_PIX_FMT_DRM_PRIME;
hwframes->sw_format = drmformat == DRM_FORMAT_NV12 ? AV_PIX_FMT_NV12 : AV_PIX_FMT_NONE;
hwframes->width = avctx->width;
hwframes->height = avctx->height;
ret = av_hwframe_ctx_init(decoder->frames_ref);
if (ret < 0)
goto fail;
ret = AVERROR(EAGAIN);
goto fail;
} else if (mpp_frame_get_eos(mppframe)) {
av_log(avctx, AV_LOG_DEBUG, "Received a EOS frame.\n");
decoder->eos_reached = 1;
ret = AVERROR_EOF;
goto fail;
} else if (mpp_frame_get_discard(mppframe)) {
av_log(avctx, AV_LOG_DEBUG, "Received a discard frame.\n");
ret = AVERROR(EAGAIN);
goto fail;
} else if (mpp_frame_get_errinfo(mppframe)) {
av_log(avctx, AV_LOG_ERROR, "Received a errinfo frame.\n");
ret = AVERROR_UNKNOWN;
goto fail;
}
av_log(avctx, AV_LOG_DEBUG, "Received a frame.\n");
frame->format = AV_PIX_FMT_DRM_PRIME;
frame->width = mpp_frame_get_width(mppframe);
frame->height = mpp_frame_get_height(mppframe);
frame->pts = mpp_frame_get_pts(mppframe);
frame->color_range = mpp_frame_get_color_range(mppframe);
frame->color_primaries = mpp_frame_get_color_primaries(mppframe);
frame->color_trc = mpp_frame_get_color_trc(mppframe);
frame->colorspace = mpp_frame_get_colorspace(mppframe);
mode = mpp_frame_get_mode(mppframe);
frame->interlaced_frame = ((mode & MPP_FRAME_FLAG_FIELD_ORDER_MASK) == MPP_FRAME_FLAG_DEINTERLACED);
frame->top_field_first = ((mode & MPP_FRAME_FLAG_FIELD_ORDER_MASK) == MPP_FRAME_FLAG_TOP_FIRST);
mppformat = mpp_frame_get_fmt(mppframe);
drmformat = rkmpp_get_frameformat(mppformat);
buffer = mpp_frame_get_buffer(mppframe);
if (buffer) {
desc = av_mallocz(sizeof(AVDRMFrameDescriptor));
if (!desc) {
ret = AVERROR(ENOMEM);
goto fail;
}
desc->nb_objects = 1;
desc->objects[0].fd = mpp_buffer_get_fd(buffer);
desc->objects[0].size = mpp_buffer_get_size(buffer);
desc->nb_layers = 1;
layer = &desc->layers[0];
layer->format = drmformat;
layer->nb_planes = 2;
layer->planes[0].object_index = 0;
layer->planes[0].offset = 0;
layer->planes[0].pitch = mpp_frame_get_hor_stride(mppframe);
layer->planes[1].object_index = 0;
layer->planes[1].offset = layer->planes[0].pitch * mpp_frame_get_ver_stride(mppframe);
layer->planes[1].pitch = layer->planes[0].pitch;
framecontextref = av_buffer_allocz(sizeof(*framecontext));
if (!framecontextref) {
ret = AVERROR(ENOMEM);
goto fail;
}
framecontext = (RKMPPFrameContext *)framecontextref->data;
framecontext->decoder_ref = av_buffer_ref(rk_context->decoder_ref);
framecontext->frame = mppframe;
frame->data[0] = (uint8_t *)desc;
frame->buf[0] = av_buffer_create((uint8_t *)desc, sizeof(*desc), rkmpp_release_frame,
framecontextref, AV_BUFFER_FLAG_READONLY);
if (!frame->buf[0]) {
ret = AVERROR(ENOMEM);
goto fail;
}
frame->hw_frames_ctx = av_buffer_ref(decoder->frames_ref);
if (!frame->hw_frames_ctx) {
ret = AVERROR(ENOMEM);
goto fail;
}
decoder->first_frame = 0;
return 0;
} else {
av_log(avctx, AV_LOG_ERROR, "Failed to retrieve the frame buffer, frame is dropped (code = %d)\n", ret);
mpp_frame_deinit(&mppframe);
}
} else if (decoder->eos_reached) {
return AVERROR_EOF;
} else if (ret == MPP_ERR_TIMEOUT) {
av_log(avctx, AV_LOG_DEBUG, "Timeout when trying to get a frame from MPP\n");
}
return AVERROR(EAGAIN);
fail:
if (mppframe)
mpp_frame_deinit(&mppframe);
if (framecontext)
av_buffer_unref(&framecontext->decoder_ref);
if (framecontextref)
av_buffer_unref(&framecontextref);
if (desc)
av_free(desc);
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, AVFrame *VAR_1)
{
RKMPPDecodeContext *rk_context = VAR_0->priv_data;
RKMPPDecoder *decoder = (RKMPPDecoder *)rk_context->decoder_ref->data;
RKMPPFrameContext *framecontext = NULL;
AVBufferRef *framecontextref = NULL;
int VAR_2;
MppFrame mppframe = NULL;
MppBuffer buffer = NULL;
AVDRMFrameDescriptor *desc = NULL;
AVDRMLayerDescriptor *layer = NULL;
int VAR_3 = 0;
int VAR_4;
MppFrameFormat mppformat;
uint32_t drmformat;
retry_get_frame:
VAR_2 = decoder->mpi->decode_get_frame(decoder->ctx, &mppframe);
if (VAR_2 != MPP_OK && VAR_2 != MPP_ERR_TIMEOUT && !decoder->first_frame) {
if (VAR_3 < 5) {
av_log(VAR_0, AV_LOG_DEBUG, "Failed to get a VAR_1, retrying (code = %d, VAR_3 = %d)\n", VAR_2, VAR_3);
usleep(10000);
VAR_3++;
goto retry_get_frame;
} else {
av_log(VAR_0, AV_LOG_ERROR, "Failed to get a VAR_1 from MPP (code = %d)\n", VAR_2);
goto fail;
}
}
if (mppframe) {
if (mpp_frame_get_info_change(mppframe)) {
AVHWFramesContext *hwframes;
av_log(VAR_0, AV_LOG_INFO, "Decoder noticed an info change (%dx%d), format=%d\n",
(int)mpp_frame_get_width(mppframe), (int)mpp_frame_get_height(mppframe),
(int)mpp_frame_get_fmt(mppframe));
VAR_0->width = mpp_frame_get_width(mppframe);
VAR_0->height = mpp_frame_get_height(mppframe);
decoder->mpi->control(decoder->ctx, MPP_DEC_SET_INFO_CHANGE_READY, NULL);
decoder->first_frame = 1;
av_buffer_unref(&decoder->frames_ref);
decoder->frames_ref = av_hwframe_ctx_alloc(decoder->device_ref);
if (!decoder->frames_ref) {
VAR_2 = AVERROR(ENOMEM);
goto fail;
}
mppformat = mpp_frame_get_fmt(mppframe);
drmformat = rkmpp_get_frameformat(mppformat);
hwframes = (AVHWFramesContext*)decoder->frames_ref->data;
hwframes->format = AV_PIX_FMT_DRM_PRIME;
hwframes->sw_format = drmformat == DRM_FORMAT_NV12 ? AV_PIX_FMT_NV12 : AV_PIX_FMT_NONE;
hwframes->width = VAR_0->width;
hwframes->height = VAR_0->height;
VAR_2 = av_hwframe_ctx_init(decoder->frames_ref);
if (VAR_2 < 0)
goto fail;
VAR_2 = AVERROR(EAGAIN);
goto fail;
} else if (mpp_frame_get_eos(mppframe)) {
av_log(VAR_0, AV_LOG_DEBUG, "Received a EOS VAR_1.\n");
decoder->eos_reached = 1;
VAR_2 = AVERROR_EOF;
goto fail;
} else if (mpp_frame_get_discard(mppframe)) {
av_log(VAR_0, AV_LOG_DEBUG, "Received a discard VAR_1.\n");
VAR_2 = AVERROR(EAGAIN);
goto fail;
} else if (mpp_frame_get_errinfo(mppframe)) {
av_log(VAR_0, AV_LOG_ERROR, "Received a errinfo VAR_1.\n");
VAR_2 = AVERROR_UNKNOWN;
goto fail;
}
av_log(VAR_0, AV_LOG_DEBUG, "Received a VAR_1.\n");
VAR_1->format = AV_PIX_FMT_DRM_PRIME;
VAR_1->width = mpp_frame_get_width(mppframe);
VAR_1->height = mpp_frame_get_height(mppframe);
VAR_1->pts = mpp_frame_get_pts(mppframe);
VAR_1->color_range = mpp_frame_get_color_range(mppframe);
VAR_1->color_primaries = mpp_frame_get_color_primaries(mppframe);
VAR_1->color_trc = mpp_frame_get_color_trc(mppframe);
VAR_1->colorspace = mpp_frame_get_colorspace(mppframe);
VAR_4 = mpp_frame_get_mode(mppframe);
VAR_1->interlaced_frame = ((VAR_4 & MPP_FRAME_FLAG_FIELD_ORDER_MASK) == MPP_FRAME_FLAG_DEINTERLACED);
VAR_1->top_field_first = ((VAR_4 & MPP_FRAME_FLAG_FIELD_ORDER_MASK) == MPP_FRAME_FLAG_TOP_FIRST);
mppformat = mpp_frame_get_fmt(mppframe);
drmformat = rkmpp_get_frameformat(mppformat);
buffer = mpp_frame_get_buffer(mppframe);
if (buffer) {
desc = av_mallocz(sizeof(AVDRMFrameDescriptor));
if (!desc) {
VAR_2 = AVERROR(ENOMEM);
goto fail;
}
desc->nb_objects = 1;
desc->objects[0].fd = mpp_buffer_get_fd(buffer);
desc->objects[0].size = mpp_buffer_get_size(buffer);
desc->nb_layers = 1;
layer = &desc->layers[0];
layer->format = drmformat;
layer->nb_planes = 2;
layer->planes[0].object_index = 0;
layer->planes[0].offset = 0;
layer->planes[0].pitch = mpp_frame_get_hor_stride(mppframe);
layer->planes[1].object_index = 0;
layer->planes[1].offset = layer->planes[0].pitch * mpp_frame_get_ver_stride(mppframe);
layer->planes[1].pitch = layer->planes[0].pitch;
framecontextref = av_buffer_allocz(sizeof(*framecontext));
if (!framecontextref) {
VAR_2 = AVERROR(ENOMEM);
goto fail;
}
framecontext = (RKMPPFrameContext *)framecontextref->data;
framecontext->decoder_ref = av_buffer_ref(rk_context->decoder_ref);
framecontext->VAR_1 = mppframe;
VAR_1->data[0] = (uint8_t *)desc;
VAR_1->buf[0] = av_buffer_create((uint8_t *)desc, sizeof(*desc), rkmpp_release_frame,
framecontextref, AV_BUFFER_FLAG_READONLY);
if (!VAR_1->buf[0]) {
VAR_2 = AVERROR(ENOMEM);
goto fail;
}
VAR_1->hw_frames_ctx = av_buffer_ref(decoder->frames_ref);
if (!VAR_1->hw_frames_ctx) {
VAR_2 = AVERROR(ENOMEM);
goto fail;
}
decoder->first_frame = 0;
return 0;
} else {
av_log(VAR_0, AV_LOG_ERROR, "Failed to retrieve the VAR_1 buffer, VAR_1 is dropped (code = %d)\n", VAR_2);
mpp_frame_deinit(&mppframe);
}
} else if (decoder->eos_reached) {
return AVERROR_EOF;
} else if (VAR_2 == MPP_ERR_TIMEOUT) {
av_log(VAR_0, AV_LOG_DEBUG, "Timeout when trying to get a VAR_1 from MPP\n");
}
return AVERROR(EAGAIN);
fail:
if (mppframe)
mpp_frame_deinit(&mppframe);
if (framecontext)
av_buffer_unref(&framecontext->decoder_ref);
if (framecontextref)
av_buffer_unref(&framecontextref);
if (desc)
av_free(desc);
return VAR_2;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, AVFrame *VAR_1)\n{",
"RKMPPDecodeContext *rk_context = VAR_0->priv_data;",
"RKMPPDecoder *decoder = (RKMPPDecoder *)rk_context->decoder_ref->data;",
"RKMPPFrameContext *framecontext = NULL;",
"AVBufferRef *framecontextref = NULL;",
"int VAR_2;",
"MppFrame mppframe = NULL;",
"MppBuffer buffer = NULL;",
"AVDRMFrameDescriptor *desc = NULL;",
"AVDRMLayerDescriptor *layer = NULL;",
"int VAR_3 = 0;",
"int VAR_4;",
"MppFrameFormat mppformat;",
"uint32_t drmformat;",
"retry_get_frame:\nVAR_2 = decoder->mpi->decode_get_frame(decoder->ctx, &mppframe);",
"if (VAR_2 != MPP_OK && VAR_2 != MPP_ERR_TIMEOUT && !decoder->first_frame) {",
"if (VAR_3 < 5) {",
"av_log(VAR_0, AV_LOG_DEBUG, \"Failed to get a VAR_1, retrying (code = %d, VAR_3 = %d)\\n\", VAR_2, VAR_3);",
"usleep(10000);",
"VAR_3++;",
"goto retry_get_frame;",
"} else {",
"av_log(VAR_0, AV_LOG_ERROR, \"Failed to get a VAR_1 from MPP (code = %d)\\n\", VAR_2);",
"goto fail;",
"}",
"}",
"if (mppframe) {",
"if (mpp_frame_get_info_change(mppframe)) {",
"AVHWFramesContext *hwframes;",
"av_log(VAR_0, AV_LOG_INFO, \"Decoder noticed an info change (%dx%d), format=%d\\n\",\n(int)mpp_frame_get_width(mppframe), (int)mpp_frame_get_height(mppframe),\n(int)mpp_frame_get_fmt(mppframe));",
"VAR_0->width = mpp_frame_get_width(mppframe);",
"VAR_0->height = mpp_frame_get_height(mppframe);",
"decoder->mpi->control(decoder->ctx, MPP_DEC_SET_INFO_CHANGE_READY, NULL);",
"decoder->first_frame = 1;",
"av_buffer_unref(&decoder->frames_ref);",
"decoder->frames_ref = av_hwframe_ctx_alloc(decoder->device_ref);",
"if (!decoder->frames_ref) {",
"VAR_2 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"mppformat = mpp_frame_get_fmt(mppframe);",
"drmformat = rkmpp_get_frameformat(mppformat);",
"hwframes = (AVHWFramesContext*)decoder->frames_ref->data;",
"hwframes->format = AV_PIX_FMT_DRM_PRIME;",
"hwframes->sw_format = drmformat == DRM_FORMAT_NV12 ? AV_PIX_FMT_NV12 : AV_PIX_FMT_NONE;",
"hwframes->width = VAR_0->width;",
"hwframes->height = VAR_0->height;",
"VAR_2 = av_hwframe_ctx_init(decoder->frames_ref);",
"if (VAR_2 < 0)\ngoto fail;",
"VAR_2 = AVERROR(EAGAIN);",
"goto fail;",
"} else if (mpp_frame_get_eos(mppframe)) {",
"av_log(VAR_0, AV_LOG_DEBUG, \"Received a EOS VAR_1.\\n\");",
"decoder->eos_reached = 1;",
"VAR_2 = AVERROR_EOF;",
"goto fail;",
"} else if (mpp_frame_get_discard(mppframe)) {",
"av_log(VAR_0, AV_LOG_DEBUG, \"Received a discard VAR_1.\\n\");",
"VAR_2 = AVERROR(EAGAIN);",
"goto fail;",
"} else if (mpp_frame_get_errinfo(mppframe)) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Received a errinfo VAR_1.\\n\");",
"VAR_2 = AVERROR_UNKNOWN;",
"goto fail;",
"}",
"av_log(VAR_0, AV_LOG_DEBUG, \"Received a VAR_1.\\n\");",
"VAR_1->format = AV_PIX_FMT_DRM_PRIME;",
"VAR_1->width = mpp_frame_get_width(mppframe);",
"VAR_1->height = mpp_frame_get_height(mppframe);",
"VAR_1->pts = mpp_frame_get_pts(mppframe);",
"VAR_1->color_range = mpp_frame_get_color_range(mppframe);",
"VAR_1->color_primaries = mpp_frame_get_color_primaries(mppframe);",
"VAR_1->color_trc = mpp_frame_get_color_trc(mppframe);",
"VAR_1->colorspace = mpp_frame_get_colorspace(mppframe);",
"VAR_4 = mpp_frame_get_mode(mppframe);",
"VAR_1->interlaced_frame = ((VAR_4 & MPP_FRAME_FLAG_FIELD_ORDER_MASK) == MPP_FRAME_FLAG_DEINTERLACED);",
"VAR_1->top_field_first = ((VAR_4 & MPP_FRAME_FLAG_FIELD_ORDER_MASK) == MPP_FRAME_FLAG_TOP_FIRST);",
"mppformat = mpp_frame_get_fmt(mppframe);",
"drmformat = rkmpp_get_frameformat(mppformat);",
"buffer = mpp_frame_get_buffer(mppframe);",
"if (buffer) {",
"desc = av_mallocz(sizeof(AVDRMFrameDescriptor));",
"if (!desc) {",
"VAR_2 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"desc->nb_objects = 1;",
"desc->objects[0].fd = mpp_buffer_get_fd(buffer);",
"desc->objects[0].size = mpp_buffer_get_size(buffer);",
"desc->nb_layers = 1;",
"layer = &desc->layers[0];",
"layer->format = drmformat;",
"layer->nb_planes = 2;",
"layer->planes[0].object_index = 0;",
"layer->planes[0].offset = 0;",
"layer->planes[0].pitch = mpp_frame_get_hor_stride(mppframe);",
"layer->planes[1].object_index = 0;",
"layer->planes[1].offset = layer->planes[0].pitch * mpp_frame_get_ver_stride(mppframe);",
"layer->planes[1].pitch = layer->planes[0].pitch;",
"framecontextref = av_buffer_allocz(sizeof(*framecontext));",
"if (!framecontextref) {",
"VAR_2 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"framecontext = (RKMPPFrameContext *)framecontextref->data;",
"framecontext->decoder_ref = av_buffer_ref(rk_context->decoder_ref);",
"framecontext->VAR_1 = mppframe;",
"VAR_1->data[0] = (uint8_t *)desc;",
"VAR_1->buf[0] = av_buffer_create((uint8_t *)desc, sizeof(*desc), rkmpp_release_frame,\nframecontextref, AV_BUFFER_FLAG_READONLY);",
"if (!VAR_1->buf[0]) {",
"VAR_2 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"VAR_1->hw_frames_ctx = av_buffer_ref(decoder->frames_ref);",
"if (!VAR_1->hw_frames_ctx) {",
"VAR_2 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"decoder->first_frame = 0;",
"return 0;",
"} else {",
"av_log(VAR_0, AV_LOG_ERROR, \"Failed to retrieve the VAR_1 buffer, VAR_1 is dropped (code = %d)\\n\", VAR_2);",
"mpp_frame_deinit(&mppframe);",
"}",
"} else if (decoder->eos_reached) {",
"return AVERROR_EOF;",
"} else if (VAR_2 == MPP_ERR_TIMEOUT) {",
"av_log(VAR_0, AV_LOG_DEBUG, \"Timeout when trying to get a VAR_1 from MPP\\n\");",
"}",
"return AVERROR(EAGAIN);",
"fail:\nif (mppframe)\nmpp_frame_deinit(&mppframe);",
"if (framecontext)\nav_buffer_unref(&framecontext->decoder_ref);",
"if (framecontextref)\nav_buffer_unref(&framecontextref);",
"if (desc)\nav_free(desc);",
"return VAR_2;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
43,
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
75
],
[
77
],
[
81,
83,
85
],
[
89
],
[
91
],
[
95
],
[
97
],
[
101
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
117
],
[
119
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135,
137
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
179
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
203
],
[
205
],
[
207
],
[
211
],
[
213
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
235
],
[
237
],
[
239
],
[
243
],
[
245
],
[
247
],
[
249
],
[
253
],
[
255
],
[
257
],
[
261
],
[
263
],
[
265
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
287
],
[
289
],
[
291
],
[
295
],
[
297,
299
],
[
303
],
[
305
],
[
307
],
[
309
],
[
313
],
[
315
],
[
317
],
[
319
],
[
321
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333
],
[
335
],
[
337
],
[
339
],
[
341
],
[
343
],
[
345
],
[
349
],
[
353,
355,
357
],
[
361,
363
],
[
367,
369
],
[
373,
375
],
[
379
],
[
381
]
] |
18,910 | START_TEST(qfloat_from_double_test)
{
QFloat *qf;
const double value = -42.23423;
qf = qfloat_from_double(value);
fail_unless(qf != NULL);
fail_unless(qf->value == value);
fail_unless(qf->base.refcnt == 1);
fail_unless(qobject_type(QOBJECT(qf)) == QTYPE_QFLOAT);
// destroy doesn't exit yet
g_free(qf);
}
| false | qemu | a9e1c28ddaae5a48415fec1f336b5560eb85d3e1 | START_TEST(qfloat_from_double_test)
{
QFloat *qf;
const double value = -42.23423;
qf = qfloat_from_double(value);
fail_unless(qf != NULL);
fail_unless(qf->value == value);
fail_unless(qf->base.refcnt == 1);
fail_unless(qobject_type(QOBJECT(qf)) == QTYPE_QFLOAT);
g_free(qf);
}
| {
"code": [],
"line_no": []
} | FUNC_0(VAR_0)
{
QFloat *qf;
const double VAR_1 = -42.23423;
qf = qfloat_from_double(VAR_1);
fail_unless(qf != NULL);
fail_unless(qf->VAR_1 == VAR_1);
fail_unless(qf->base.refcnt == 1);
fail_unless(qobject_type(QOBJECT(qf)) == QTYPE_QFLOAT);
g_free(qf);
}
| [
"FUNC_0(VAR_0)\n{",
"QFloat *qf;",
"const double VAR_1 = -42.23423;",
"qf = qfloat_from_double(VAR_1);",
"fail_unless(qf != NULL);",
"fail_unless(qf->VAR_1 == VAR_1);",
"fail_unless(qf->base.refcnt == 1);",
"fail_unless(qobject_type(QOBJECT(qf)) == QTYPE_QFLOAT);",
"g_free(qf);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
25
],
[
27
]
] |
18,911 | static int vnc_start_vencrypt_handshake(struct VncState *vs) {
int ret;
if ((ret = gnutls_handshake(vs->tls.session)) < 0) {
if (!gnutls_error_is_fatal(ret)) {
VNC_DEBUG("Handshake interrupted (blocking)\n");
if (!gnutls_record_get_direction(vs->tls.session))
qemu_set_fd_handler(vs->csock, vnc_tls_handshake_io, NULL, vs);
else
qemu_set_fd_handler(vs->csock, NULL, vnc_tls_handshake_io, vs);
return 0;
}
VNC_DEBUG("Handshake failed %s\n", gnutls_strerror(ret));
vnc_client_error(vs);
return -1;
}
if (vs->vd->tls.x509verify) {
if (vnc_tls_validate_certificate(vs) < 0) {
VNC_DEBUG("Client verification failed\n");
vnc_client_error(vs);
return -1;
} else {
VNC_DEBUG("Client verification passed\n");
}
}
VNC_DEBUG("Handshake done, switching to TLS data mode\n");
qemu_set_fd_handler2(vs->csock, NULL, vnc_client_read, vnc_client_write, vs);
start_auth_vencrypt_subauth(vs);
return 0;
}
| false | qemu | 494cb81741f867319f11ecfa0949168baf9f01d7 | static int vnc_start_vencrypt_handshake(struct VncState *vs) {
int ret;
if ((ret = gnutls_handshake(vs->tls.session)) < 0) {
if (!gnutls_error_is_fatal(ret)) {
VNC_DEBUG("Handshake interrupted (blocking)\n");
if (!gnutls_record_get_direction(vs->tls.session))
qemu_set_fd_handler(vs->csock, vnc_tls_handshake_io, NULL, vs);
else
qemu_set_fd_handler(vs->csock, NULL, vnc_tls_handshake_io, vs);
return 0;
}
VNC_DEBUG("Handshake failed %s\n", gnutls_strerror(ret));
vnc_client_error(vs);
return -1;
}
if (vs->vd->tls.x509verify) {
if (vnc_tls_validate_certificate(vs) < 0) {
VNC_DEBUG("Client verification failed\n");
vnc_client_error(vs);
return -1;
} else {
VNC_DEBUG("Client verification passed\n");
}
}
VNC_DEBUG("Handshake done, switching to TLS data mode\n");
qemu_set_fd_handler2(vs->csock, NULL, vnc_client_read, vnc_client_write, vs);
start_auth_vencrypt_subauth(vs);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(struct VncState *VAR_0) {
int VAR_1;
if ((VAR_1 = gnutls_handshake(VAR_0->tls.session)) < 0) {
if (!gnutls_error_is_fatal(VAR_1)) {
VNC_DEBUG("Handshake interrupted (blocking)\n");
if (!gnutls_record_get_direction(VAR_0->tls.session))
qemu_set_fd_handler(VAR_0->csock, vnc_tls_handshake_io, NULL, VAR_0);
else
qemu_set_fd_handler(VAR_0->csock, NULL, vnc_tls_handshake_io, VAR_0);
return 0;
}
VNC_DEBUG("Handshake failed %s\n", gnutls_strerror(VAR_1));
vnc_client_error(VAR_0);
return -1;
}
if (VAR_0->vd->tls.x509verify) {
if (vnc_tls_validate_certificate(VAR_0) < 0) {
VNC_DEBUG("Client verification failed\n");
vnc_client_error(VAR_0);
return -1;
} else {
VNC_DEBUG("Client verification passed\n");
}
}
VNC_DEBUG("Handshake done, switching to TLS data mode\n");
qemu_set_fd_handler2(VAR_0->csock, NULL, vnc_client_read, vnc_client_write, VAR_0);
start_auth_vencrypt_subauth(VAR_0);
return 0;
}
| [
"static int FUNC_0(struct VncState *VAR_0) {",
"int VAR_1;",
"if ((VAR_1 = gnutls_handshake(VAR_0->tls.session)) < 0) {",
"if (!gnutls_error_is_fatal(VAR_1)) {",
"VNC_DEBUG(\"Handshake interrupted (blocking)\\n\");",
"if (!gnutls_record_get_direction(VAR_0->tls.session))\nqemu_set_fd_handler(VAR_0->csock, vnc_tls_handshake_io, NULL, VAR_0);",
"else\nqemu_set_fd_handler(VAR_0->csock, NULL, vnc_tls_handshake_io, VAR_0);",
"return 0;",
"}",
"VNC_DEBUG(\"Handshake failed %s\\n\", gnutls_strerror(VAR_1));",
"vnc_client_error(VAR_0);",
"return -1;",
"}",
"if (VAR_0->vd->tls.x509verify) {",
"if (vnc_tls_validate_certificate(VAR_0) < 0) {",
"VNC_DEBUG(\"Client verification failed\\n\");",
"vnc_client_error(VAR_0);",
"return -1;",
"} else {",
"VNC_DEBUG(\"Client verification passed\\n\");",
"}",
"}",
"VNC_DEBUG(\"Handshake done, switching to TLS data mode\\n\");",
"qemu_set_fd_handler2(VAR_0->csock, NULL, vnc_client_read, vnc_client_write, VAR_0);",
"start_auth_vencrypt_subauth(VAR_0);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1
],
[
3
],
[
7
],
[
9
],
[
11
],
[
13,
15
],
[
17,
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
61
],
[
65
],
[
67
]
] |
18,912 | static void spapr_powerdown_req(Notifier *n, void *opaque)
{
sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
struct rtas_error_log *hdr;
struct rtas_event_log_v6 *v6hdr;
struct rtas_event_log_v6_maina *maina;
struct rtas_event_log_v6_mainb *mainb;
struct rtas_event_log_v6_epow *epow;
struct epow_log_full *new_epow;
new_epow = g_malloc0(sizeof(*new_epow));
hdr = &new_epow->hdr;
v6hdr = &new_epow->v6hdr;
maina = &new_epow->maina;
mainb = &new_epow->mainb;
epow = &new_epow->epow;
hdr->summary = cpu_to_be32(RTAS_LOG_VERSION_6
| RTAS_LOG_SEVERITY_EVENT
| RTAS_LOG_DISPOSITION_NOT_RECOVERED
| RTAS_LOG_OPTIONAL_PART_PRESENT
| RTAS_LOG_TYPE_EPOW);
hdr->extended_length = cpu_to_be32(sizeof(*new_epow)
- sizeof(new_epow->hdr));
spapr_init_v6hdr(v6hdr);
spapr_init_maina(maina, 3 /* Main-A, Main-B and EPOW */);
mainb->hdr.section_id = cpu_to_be16(RTAS_LOG_V6_SECTION_ID_MAINB);
mainb->hdr.section_length = cpu_to_be16(sizeof(*mainb));
/* FIXME: section version, subtype and creator id? */
mainb->subsystem_id = 0xa0; /* External environment */
mainb->event_severity = 0x00; /* Informational / non-error */
mainb->event_subtype = 0xd0; /* Normal shutdown */
epow->hdr.section_id = cpu_to_be16(RTAS_LOG_V6_SECTION_ID_EPOW);
epow->hdr.section_length = cpu_to_be16(sizeof(*epow));
epow->hdr.section_version = 2; /* includes extended modifier */
/* FIXME: section subtype and creator id? */
epow->sensor_value = RTAS_LOG_V6_EPOW_ACTION_SYSTEM_SHUTDOWN;
epow->event_modifier = RTAS_LOG_V6_EPOW_MODIFIER_NORMAL;
epow->extended_modifier = RTAS_LOG_V6_EPOW_XMODIFIER_PARTITION_SPECIFIC;
rtas_event_log_queue(RTAS_LOG_TYPE_EPOW, new_epow);
qemu_irq_pulse(xics_get_qirq(XICS_FABRIC(spapr),
rtas_event_log_to_irq(spapr,
RTAS_LOG_TYPE_EPOW)));
}
| false | qemu | fd38804b388fdd5f3abd108f260d3e9d625ff7ad | static void spapr_powerdown_req(Notifier *n, void *opaque)
{
sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
struct rtas_error_log *hdr;
struct rtas_event_log_v6 *v6hdr;
struct rtas_event_log_v6_maina *maina;
struct rtas_event_log_v6_mainb *mainb;
struct rtas_event_log_v6_epow *epow;
struct epow_log_full *new_epow;
new_epow = g_malloc0(sizeof(*new_epow));
hdr = &new_epow->hdr;
v6hdr = &new_epow->v6hdr;
maina = &new_epow->maina;
mainb = &new_epow->mainb;
epow = &new_epow->epow;
hdr->summary = cpu_to_be32(RTAS_LOG_VERSION_6
| RTAS_LOG_SEVERITY_EVENT
| RTAS_LOG_DISPOSITION_NOT_RECOVERED
| RTAS_LOG_OPTIONAL_PART_PRESENT
| RTAS_LOG_TYPE_EPOW);
hdr->extended_length = cpu_to_be32(sizeof(*new_epow)
- sizeof(new_epow->hdr));
spapr_init_v6hdr(v6hdr);
spapr_init_maina(maina, 3 );
mainb->hdr.section_id = cpu_to_be16(RTAS_LOG_V6_SECTION_ID_MAINB);
mainb->hdr.section_length = cpu_to_be16(sizeof(*mainb));
mainb->subsystem_id = 0xa0;
mainb->event_severity = 0x00;
mainb->event_subtype = 0xd0;
epow->hdr.section_id = cpu_to_be16(RTAS_LOG_V6_SECTION_ID_EPOW);
epow->hdr.section_length = cpu_to_be16(sizeof(*epow));
epow->hdr.section_version = 2;
epow->sensor_value = RTAS_LOG_V6_EPOW_ACTION_SYSTEM_SHUTDOWN;
epow->event_modifier = RTAS_LOG_V6_EPOW_MODIFIER_NORMAL;
epow->extended_modifier = RTAS_LOG_V6_EPOW_XMODIFIER_PARTITION_SPECIFIC;
rtas_event_log_queue(RTAS_LOG_TYPE_EPOW, new_epow);
qemu_irq_pulse(xics_get_qirq(XICS_FABRIC(spapr),
rtas_event_log_to_irq(spapr,
RTAS_LOG_TYPE_EPOW)));
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(Notifier *VAR_0, void *VAR_1)
{
sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
struct rtas_error_log *VAR_2;
struct rtas_event_log_v6 *VAR_3;
struct rtas_event_log_v6_maina *VAR_4;
struct rtas_event_log_v6_mainb *VAR_5;
struct rtas_event_log_v6_epow *VAR_6;
struct epow_log_full *VAR_7;
VAR_7 = g_malloc0(sizeof(*VAR_7));
VAR_2 = &VAR_7->VAR_2;
VAR_3 = &VAR_7->VAR_3;
VAR_4 = &VAR_7->VAR_4;
VAR_5 = &VAR_7->VAR_5;
VAR_6 = &VAR_7->VAR_6;
VAR_2->summary = cpu_to_be32(RTAS_LOG_VERSION_6
| RTAS_LOG_SEVERITY_EVENT
| RTAS_LOG_DISPOSITION_NOT_RECOVERED
| RTAS_LOG_OPTIONAL_PART_PRESENT
| RTAS_LOG_TYPE_EPOW);
VAR_2->extended_length = cpu_to_be32(sizeof(*VAR_7)
- sizeof(VAR_7->VAR_2));
spapr_init_v6hdr(VAR_3);
spapr_init_maina(VAR_4, 3 );
VAR_5->VAR_2.section_id = cpu_to_be16(RTAS_LOG_V6_SECTION_ID_MAINB);
VAR_5->VAR_2.section_length = cpu_to_be16(sizeof(*VAR_5));
VAR_5->subsystem_id = 0xa0;
VAR_5->event_severity = 0x00;
VAR_5->event_subtype = 0xd0;
VAR_6->VAR_2.section_id = cpu_to_be16(RTAS_LOG_V6_SECTION_ID_EPOW);
VAR_6->VAR_2.section_length = cpu_to_be16(sizeof(*VAR_6));
VAR_6->VAR_2.section_version = 2;
VAR_6->sensor_value = RTAS_LOG_V6_EPOW_ACTION_SYSTEM_SHUTDOWN;
VAR_6->event_modifier = RTAS_LOG_V6_EPOW_MODIFIER_NORMAL;
VAR_6->extended_modifier = RTAS_LOG_V6_EPOW_XMODIFIER_PARTITION_SPECIFIC;
rtas_event_log_queue(RTAS_LOG_TYPE_EPOW, VAR_7);
qemu_irq_pulse(xics_get_qirq(XICS_FABRIC(spapr),
rtas_event_log_to_irq(spapr,
RTAS_LOG_TYPE_EPOW)));
}
| [
"static void FUNC_0(Notifier *VAR_0, void *VAR_1)\n{",
"sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());",
"struct rtas_error_log *VAR_2;",
"struct rtas_event_log_v6 *VAR_3;",
"struct rtas_event_log_v6_maina *VAR_4;",
"struct rtas_event_log_v6_mainb *VAR_5;",
"struct rtas_event_log_v6_epow *VAR_6;",
"struct epow_log_full *VAR_7;",
"VAR_7 = g_malloc0(sizeof(*VAR_7));",
"VAR_2 = &VAR_7->VAR_2;",
"VAR_3 = &VAR_7->VAR_3;",
"VAR_4 = &VAR_7->VAR_4;",
"VAR_5 = &VAR_7->VAR_5;",
"VAR_6 = &VAR_7->VAR_6;",
"VAR_2->summary = cpu_to_be32(RTAS_LOG_VERSION_6\n| RTAS_LOG_SEVERITY_EVENT\n| RTAS_LOG_DISPOSITION_NOT_RECOVERED\n| RTAS_LOG_OPTIONAL_PART_PRESENT\n| RTAS_LOG_TYPE_EPOW);",
"VAR_2->extended_length = cpu_to_be32(sizeof(*VAR_7)\n- sizeof(VAR_7->VAR_2));",
"spapr_init_v6hdr(VAR_3);",
"spapr_init_maina(VAR_4, 3 );",
"VAR_5->VAR_2.section_id = cpu_to_be16(RTAS_LOG_V6_SECTION_ID_MAINB);",
"VAR_5->VAR_2.section_length = cpu_to_be16(sizeof(*VAR_5));",
"VAR_5->subsystem_id = 0xa0;",
"VAR_5->event_severity = 0x00;",
"VAR_5->event_subtype = 0xd0;",
"VAR_6->VAR_2.section_id = cpu_to_be16(RTAS_LOG_V6_SECTION_ID_EPOW);",
"VAR_6->VAR_2.section_length = cpu_to_be16(sizeof(*VAR_6));",
"VAR_6->VAR_2.section_version = 2;",
"VAR_6->sensor_value = RTAS_LOG_V6_EPOW_ACTION_SYSTEM_SHUTDOWN;",
"VAR_6->event_modifier = RTAS_LOG_V6_EPOW_MODIFIER_NORMAL;",
"VAR_6->extended_modifier = RTAS_LOG_V6_EPOW_XMODIFIER_PARTITION_SPECIFIC;",
"rtas_event_log_queue(RTAS_LOG_TYPE_EPOW, VAR_7);",
"qemu_irq_pulse(xics_get_qirq(XICS_FABRIC(spapr),\nrtas_event_log_to_irq(spapr,\nRTAS_LOG_TYPE_EPOW)));",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35,
37,
39,
41,
43
],
[
45,
47
],
[
51
],
[
53
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83
],
[
87
],
[
91,
93,
95
],
[
97
]
] |
18,913 | static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file,
QDict *options, int flags, BlockDriver *drv, Error **errp)
{
int ret, open_flags;
const char *filename;
const char *node_name = NULL;
Error *local_err = NULL;
assert(drv != NULL);
assert(bs->file == NULL);
assert(options != NULL && bs->options != options);
if (file != NULL) {
filename = file->filename;
} else {
filename = qdict_get_try_str(options, "filename");
}
if (drv->bdrv_needs_filename && !filename) {
error_setg(errp, "The '%s' block driver requires a file name",
drv->format_name);
return -EINVAL;
}
trace_bdrv_open_common(bs, filename ?: "", flags, drv->format_name);
node_name = qdict_get_try_str(options, "node-name");
bdrv_assign_node_name(bs, node_name, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return -EINVAL;
}
qdict_del(options, "node-name");
/* bdrv_open() with directly using a protocol as drv. This layer is already
* opened, so assign it to bs (while file becomes a closed BlockDriverState)
* and return immediately. */
if (file != NULL && drv->bdrv_file_open) {
bdrv_swap(file, bs);
return 0;
}
bs->open_flags = flags;
bs->guest_block_size = 512;
bs->request_alignment = 512;
bs->zero_beyond_eof = true;
open_flags = bdrv_open_flags(bs, flags);
bs->read_only = !(open_flags & BDRV_O_RDWR);
if (use_bdrv_whitelist && !bdrv_is_whitelisted(drv, bs->read_only)) {
error_setg(errp,
!bs->read_only && bdrv_is_whitelisted(drv, true)
? "Driver '%s' can only be used for read-only devices"
: "Driver '%s' is not whitelisted",
drv->format_name);
return -ENOTSUP;
}
assert(bs->copy_on_read == 0); /* bdrv_new() and bdrv_close() make it so */
if (flags & BDRV_O_COPY_ON_READ) {
if (!bs->read_only) {
bdrv_enable_copy_on_read(bs);
} else {
error_setg(errp, "Can't use copy-on-read on read-only device");
return -EINVAL;
}
}
if (filename != NULL) {
pstrcpy(bs->filename, sizeof(bs->filename), filename);
} else {
bs->filename[0] = '\0';
}
pstrcpy(bs->exact_filename, sizeof(bs->exact_filename), bs->filename);
bs->drv = drv;
bs->opaque = g_malloc0(drv->instance_size);
bs->enable_write_cache = !!(flags & BDRV_O_CACHE_WB);
/* Open the image, either directly or using a protocol */
if (drv->bdrv_file_open) {
assert(file == NULL);
assert(!drv->bdrv_needs_filename || filename != NULL);
ret = drv->bdrv_file_open(bs, options, open_flags, &local_err);
} else {
if (file == NULL) {
error_setg(errp, "Can't use '%s' as a block driver for the "
"protocol level", drv->format_name);
ret = -EINVAL;
goto free_and_fail;
}
bs->file = file;
ret = drv->bdrv_open(bs, options, open_flags, &local_err);
}
if (ret < 0) {
if (local_err) {
error_propagate(errp, local_err);
} else if (bs->filename[0]) {
error_setg_errno(errp, -ret, "Could not open '%s'", bs->filename);
} else {
error_setg_errno(errp, -ret, "Could not open image");
}
goto free_and_fail;
}
if (bs->encrypted) {
error_report("Encrypted images are deprecated");
error_printf("Support for them will be removed in a future release.\n"
"You can use 'qemu-img convert' to convert your image"
" to an unencrypted one.\n");
}
ret = refresh_total_sectors(bs, bs->total_sectors);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not refresh total sector count");
goto free_and_fail;
}
bdrv_refresh_limits(bs, &local_err);
if (local_err) {
error_propagate(errp, local_err);
ret = -EINVAL;
goto free_and_fail;
}
assert(bdrv_opt_mem_align(bs) != 0);
assert(bdrv_min_mem_align(bs) != 0);
assert((bs->request_alignment != 0) || bs->sg);
return 0;
free_and_fail:
bs->file = NULL;
g_free(bs->opaque);
bs->opaque = NULL;
bs->drv = NULL;
return ret;
}
| false | qemu | 53a295131274c87914c97053e2ca00f19a9c2efa | static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file,
QDict *options, int flags, BlockDriver *drv, Error **errp)
{
int ret, open_flags;
const char *filename;
const char *node_name = NULL;
Error *local_err = NULL;
assert(drv != NULL);
assert(bs->file == NULL);
assert(options != NULL && bs->options != options);
if (file != NULL) {
filename = file->filename;
} else {
filename = qdict_get_try_str(options, "filename");
}
if (drv->bdrv_needs_filename && !filename) {
error_setg(errp, "The '%s' block driver requires a file name",
drv->format_name);
return -EINVAL;
}
trace_bdrv_open_common(bs, filename ?: "", flags, drv->format_name);
node_name = qdict_get_try_str(options, "node-name");
bdrv_assign_node_name(bs, node_name, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return -EINVAL;
}
qdict_del(options, "node-name");
if (file != NULL && drv->bdrv_file_open) {
bdrv_swap(file, bs);
return 0;
}
bs->open_flags = flags;
bs->guest_block_size = 512;
bs->request_alignment = 512;
bs->zero_beyond_eof = true;
open_flags = bdrv_open_flags(bs, flags);
bs->read_only = !(open_flags & BDRV_O_RDWR);
if (use_bdrv_whitelist && !bdrv_is_whitelisted(drv, bs->read_only)) {
error_setg(errp,
!bs->read_only && bdrv_is_whitelisted(drv, true)
? "Driver '%s' can only be used for read-only devices"
: "Driver '%s' is not whitelisted",
drv->format_name);
return -ENOTSUP;
}
assert(bs->copy_on_read == 0);
if (flags & BDRV_O_COPY_ON_READ) {
if (!bs->read_only) {
bdrv_enable_copy_on_read(bs);
} else {
error_setg(errp, "Can't use copy-on-read on read-only device");
return -EINVAL;
}
}
if (filename != NULL) {
pstrcpy(bs->filename, sizeof(bs->filename), filename);
} else {
bs->filename[0] = '\0';
}
pstrcpy(bs->exact_filename, sizeof(bs->exact_filename), bs->filename);
bs->drv = drv;
bs->opaque = g_malloc0(drv->instance_size);
bs->enable_write_cache = !!(flags & BDRV_O_CACHE_WB);
if (drv->bdrv_file_open) {
assert(file == NULL);
assert(!drv->bdrv_needs_filename || filename != NULL);
ret = drv->bdrv_file_open(bs, options, open_flags, &local_err);
} else {
if (file == NULL) {
error_setg(errp, "Can't use '%s' as a block driver for the "
"protocol level", drv->format_name);
ret = -EINVAL;
goto free_and_fail;
}
bs->file = file;
ret = drv->bdrv_open(bs, options, open_flags, &local_err);
}
if (ret < 0) {
if (local_err) {
error_propagate(errp, local_err);
} else if (bs->filename[0]) {
error_setg_errno(errp, -ret, "Could not open '%s'", bs->filename);
} else {
error_setg_errno(errp, -ret, "Could not open image");
}
goto free_and_fail;
}
if (bs->encrypted) {
error_report("Encrypted images are deprecated");
error_printf("Support for them will be removed in a future release.\n"
"You can use 'qemu-img convert' to convert your image"
" to an unencrypted one.\n");
}
ret = refresh_total_sectors(bs, bs->total_sectors);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not refresh total sector count");
goto free_and_fail;
}
bdrv_refresh_limits(bs, &local_err);
if (local_err) {
error_propagate(errp, local_err);
ret = -EINVAL;
goto free_and_fail;
}
assert(bdrv_opt_mem_align(bs) != 0);
assert(bdrv_min_mem_align(bs) != 0);
assert((bs->request_alignment != 0) || bs->sg);
return 0;
free_and_fail:
bs->file = NULL;
g_free(bs->opaque);
bs->opaque = NULL;
bs->drv = NULL;
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(BlockDriverState *VAR_0, BlockDriverState *VAR_1,
QDict *VAR_2, int VAR_3, BlockDriver *VAR_4, Error **VAR_5)
{
int VAR_6, VAR_7;
const char *VAR_8;
const char *VAR_9 = NULL;
Error *local_err = NULL;
assert(VAR_4 != NULL);
assert(VAR_0->VAR_1 == NULL);
assert(VAR_2 != NULL && VAR_0->VAR_2 != VAR_2);
if (VAR_1 != NULL) {
VAR_8 = VAR_1->VAR_8;
} else {
VAR_8 = qdict_get_try_str(VAR_2, "VAR_8");
}
if (VAR_4->bdrv_needs_filename && !VAR_8) {
error_setg(VAR_5, "The '%s' block driver requires a VAR_1 name",
VAR_4->format_name);
return -EINVAL;
}
trace_bdrv_open_common(VAR_0, VAR_8 ?: "", VAR_3, VAR_4->format_name);
VAR_9 = qdict_get_try_str(VAR_2, "node-name");
bdrv_assign_node_name(VAR_0, VAR_9, &local_err);
if (local_err) {
error_propagate(VAR_5, local_err);
return -EINVAL;
}
qdict_del(VAR_2, "node-name");
if (VAR_1 != NULL && VAR_4->bdrv_file_open) {
bdrv_swap(VAR_1, VAR_0);
return 0;
}
VAR_0->VAR_7 = VAR_3;
VAR_0->guest_block_size = 512;
VAR_0->request_alignment = 512;
VAR_0->zero_beyond_eof = true;
VAR_7 = bdrv_open_flags(VAR_0, VAR_3);
VAR_0->read_only = !(VAR_7 & BDRV_O_RDWR);
if (use_bdrv_whitelist && !bdrv_is_whitelisted(VAR_4, VAR_0->read_only)) {
error_setg(VAR_5,
!VAR_0->read_only && bdrv_is_whitelisted(VAR_4, true)
? "Driver '%s' can only be used for read-only devices"
: "Driver '%s' is not whitelisted",
VAR_4->format_name);
return -ENOTSUP;
}
assert(VAR_0->copy_on_read == 0);
if (VAR_3 & BDRV_O_COPY_ON_READ) {
if (!VAR_0->read_only) {
bdrv_enable_copy_on_read(VAR_0);
} else {
error_setg(VAR_5, "Can't use copy-on-read on read-only device");
return -EINVAL;
}
}
if (VAR_8 != NULL) {
pstrcpy(VAR_0->VAR_8, sizeof(VAR_0->VAR_8), VAR_8);
} else {
VAR_0->VAR_8[0] = '\0';
}
pstrcpy(VAR_0->exact_filename, sizeof(VAR_0->exact_filename), VAR_0->VAR_8);
VAR_0->VAR_4 = VAR_4;
VAR_0->opaque = g_malloc0(VAR_4->instance_size);
VAR_0->enable_write_cache = !!(VAR_3 & BDRV_O_CACHE_WB);
if (VAR_4->bdrv_file_open) {
assert(VAR_1 == NULL);
assert(!VAR_4->bdrv_needs_filename || VAR_8 != NULL);
VAR_6 = VAR_4->bdrv_file_open(VAR_0, VAR_2, VAR_7, &local_err);
} else {
if (VAR_1 == NULL) {
error_setg(VAR_5, "Can't use '%s' as a block driver for the "
"protocol level", VAR_4->format_name);
VAR_6 = -EINVAL;
goto free_and_fail;
}
VAR_0->VAR_1 = VAR_1;
VAR_6 = VAR_4->bdrv_open(VAR_0, VAR_2, VAR_7, &local_err);
}
if (VAR_6 < 0) {
if (local_err) {
error_propagate(VAR_5, local_err);
} else if (VAR_0->VAR_8[0]) {
error_setg_errno(VAR_5, -VAR_6, "Could not open '%s'", VAR_0->VAR_8);
} else {
error_setg_errno(VAR_5, -VAR_6, "Could not open image");
}
goto free_and_fail;
}
if (VAR_0->encrypted) {
error_report("Encrypted images are deprecated");
error_printf("Support for them will be removed in a future release.\n"
"You can use 'qemu-img convert' to convert your image"
" to an unencrypted one.\n");
}
VAR_6 = refresh_total_sectors(VAR_0, VAR_0->total_sectors);
if (VAR_6 < 0) {
error_setg_errno(VAR_5, -VAR_6, "Could not refresh total sector count");
goto free_and_fail;
}
bdrv_refresh_limits(VAR_0, &local_err);
if (local_err) {
error_propagate(VAR_5, local_err);
VAR_6 = -EINVAL;
goto free_and_fail;
}
assert(bdrv_opt_mem_align(VAR_0) != 0);
assert(bdrv_min_mem_align(VAR_0) != 0);
assert((VAR_0->request_alignment != 0) || VAR_0->sg);
return 0;
free_and_fail:
VAR_0->VAR_1 = NULL;
g_free(VAR_0->opaque);
VAR_0->opaque = NULL;
VAR_0->VAR_4 = NULL;
return VAR_6;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, BlockDriverState *VAR_1,\nQDict *VAR_2, int VAR_3, BlockDriver *VAR_4, Error **VAR_5)\n{",
"int VAR_6, VAR_7;",
"const char *VAR_8;",
"const char *VAR_9 = NULL;",
"Error *local_err = NULL;",
"assert(VAR_4 != NULL);",
"assert(VAR_0->VAR_1 == NULL);",
"assert(VAR_2 != NULL && VAR_0->VAR_2 != VAR_2);",
"if (VAR_1 != NULL) {",
"VAR_8 = VAR_1->VAR_8;",
"} else {",
"VAR_8 = qdict_get_try_str(VAR_2, \"VAR_8\");",
"}",
"if (VAR_4->bdrv_needs_filename && !VAR_8) {",
"error_setg(VAR_5, \"The '%s' block driver requires a VAR_1 name\",\nVAR_4->format_name);",
"return -EINVAL;",
"}",
"trace_bdrv_open_common(VAR_0, VAR_8 ?: \"\", VAR_3, VAR_4->format_name);",
"VAR_9 = qdict_get_try_str(VAR_2, \"node-name\");",
"bdrv_assign_node_name(VAR_0, VAR_9, &local_err);",
"if (local_err) {",
"error_propagate(VAR_5, local_err);",
"return -EINVAL;",
"}",
"qdict_del(VAR_2, \"node-name\");",
"if (VAR_1 != NULL && VAR_4->bdrv_file_open) {",
"bdrv_swap(VAR_1, VAR_0);",
"return 0;",
"}",
"VAR_0->VAR_7 = VAR_3;",
"VAR_0->guest_block_size = 512;",
"VAR_0->request_alignment = 512;",
"VAR_0->zero_beyond_eof = true;",
"VAR_7 = bdrv_open_flags(VAR_0, VAR_3);",
"VAR_0->read_only = !(VAR_7 & BDRV_O_RDWR);",
"if (use_bdrv_whitelist && !bdrv_is_whitelisted(VAR_4, VAR_0->read_only)) {",
"error_setg(VAR_5,\n!VAR_0->read_only && bdrv_is_whitelisted(VAR_4, true)\n? \"Driver '%s' can only be used for read-only devices\"\n: \"Driver '%s' is not whitelisted\",\nVAR_4->format_name);",
"return -ENOTSUP;",
"}",
"assert(VAR_0->copy_on_read == 0);",
"if (VAR_3 & BDRV_O_COPY_ON_READ) {",
"if (!VAR_0->read_only) {",
"bdrv_enable_copy_on_read(VAR_0);",
"} else {",
"error_setg(VAR_5, \"Can't use copy-on-read on read-only device\");",
"return -EINVAL;",
"}",
"}",
"if (VAR_8 != NULL) {",
"pstrcpy(VAR_0->VAR_8, sizeof(VAR_0->VAR_8), VAR_8);",
"} else {",
"VAR_0->VAR_8[0] = '\\0';",
"}",
"pstrcpy(VAR_0->exact_filename, sizeof(VAR_0->exact_filename), VAR_0->VAR_8);",
"VAR_0->VAR_4 = VAR_4;",
"VAR_0->opaque = g_malloc0(VAR_4->instance_size);",
"VAR_0->enable_write_cache = !!(VAR_3 & BDRV_O_CACHE_WB);",
"if (VAR_4->bdrv_file_open) {",
"assert(VAR_1 == NULL);",
"assert(!VAR_4->bdrv_needs_filename || VAR_8 != NULL);",
"VAR_6 = VAR_4->bdrv_file_open(VAR_0, VAR_2, VAR_7, &local_err);",
"} else {",
"if (VAR_1 == NULL) {",
"error_setg(VAR_5, \"Can't use '%s' as a block driver for the \"\n\"protocol level\", VAR_4->format_name);",
"VAR_6 = -EINVAL;",
"goto free_and_fail;",
"}",
"VAR_0->VAR_1 = VAR_1;",
"VAR_6 = VAR_4->bdrv_open(VAR_0, VAR_2, VAR_7, &local_err);",
"}",
"if (VAR_6 < 0) {",
"if (local_err) {",
"error_propagate(VAR_5, local_err);",
"} else if (VAR_0->VAR_8[0]) {",
"error_setg_errno(VAR_5, -VAR_6, \"Could not open '%s'\", VAR_0->VAR_8);",
"} else {",
"error_setg_errno(VAR_5, -VAR_6, \"Could not open image\");",
"}",
"goto free_and_fail;",
"}",
"if (VAR_0->encrypted) {",
"error_report(\"Encrypted images are deprecated\");",
"error_printf(\"Support for them will be removed in a future release.\\n\"\n\"You can use 'qemu-img convert' to convert your image\"\n\" to an unencrypted one.\\n\");",
"}",
"VAR_6 = refresh_total_sectors(VAR_0, VAR_0->total_sectors);",
"if (VAR_6 < 0) {",
"error_setg_errno(VAR_5, -VAR_6, \"Could not refresh total sector count\");",
"goto free_and_fail;",
"}",
"bdrv_refresh_limits(VAR_0, &local_err);",
"if (local_err) {",
"error_propagate(VAR_5, local_err);",
"VAR_6 = -EINVAL;",
"goto free_and_fail;",
"}",
"assert(bdrv_opt_mem_align(VAR_0) != 0);",
"assert(bdrv_min_mem_align(VAR_0) != 0);",
"assert((VAR_0->request_alignment != 0) || VAR_0->sg);",
"return 0;",
"free_and_fail:\nVAR_0->VAR_1 = NULL;",
"g_free(VAR_0->opaque);",
"VAR_0->opaque = NULL;",
"VAR_0->VAR_4 = NULL;",
"return VAR_6;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39,
41
],
[
43
],
[
45
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
75
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
99
],
[
101,
103,
105,
107,
109
],
[
111
],
[
113
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
151
],
[
153
],
[
157
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175,
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
215
],
[
217
],
[
219,
221,
223
],
[
225
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251
],
[
255
],
[
257
],
[
259
],
[
261
],
[
265,
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
]
] |
18,914 | static uint32_t bonito_spciconf_readl(void *opaque, target_phys_addr_t addr)
{
PCIBonitoState *s = opaque;
PCIDevice *d = PCI_DEVICE(s);
PCIHostState *phb = PCI_HOST_BRIDGE(s->pcihost);
uint32_t pciaddr;
uint16_t status;
DPRINTF("bonito_spciconf_readl "TARGET_FMT_plx"\n", addr);
assert((addr & 0x3) == 0);
pciaddr = bonito_sbridge_pciaddr(s, addr);
if (pciaddr == 0xffffffff) {
return 0xffffffff;
}
/* set the pci address in s->config_reg */
phb->config_reg = (pciaddr) | (1u << 31);
/* clear PCI_STATUS_REC_MASTER_ABORT and PCI_STATUS_REC_TARGET_ABORT */
status = pci_get_word(d->config + PCI_STATUS);
status &= ~(PCI_STATUS_REC_MASTER_ABORT | PCI_STATUS_REC_TARGET_ABORT);
pci_set_word(d->config + PCI_STATUS, status);
return pci_data_read(phb->bus, phb->config_reg, 4);
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static uint32_t bonito_spciconf_readl(void *opaque, target_phys_addr_t addr)
{
PCIBonitoState *s = opaque;
PCIDevice *d = PCI_DEVICE(s);
PCIHostState *phb = PCI_HOST_BRIDGE(s->pcihost);
uint32_t pciaddr;
uint16_t status;
DPRINTF("bonito_spciconf_readl "TARGET_FMT_plx"\n", addr);
assert((addr & 0x3) == 0);
pciaddr = bonito_sbridge_pciaddr(s, addr);
if (pciaddr == 0xffffffff) {
return 0xffffffff;
}
phb->config_reg = (pciaddr) | (1u << 31);
status = pci_get_word(d->config + PCI_STATUS);
status &= ~(PCI_STATUS_REC_MASTER_ABORT | PCI_STATUS_REC_TARGET_ABORT);
pci_set_word(d->config + PCI_STATUS, status);
return pci_data_read(phb->bus, phb->config_reg, 4);
}
| {
"code": [],
"line_no": []
} | static uint32_t FUNC_0(void *opaque, target_phys_addr_t addr)
{
PCIBonitoState *s = opaque;
PCIDevice *d = PCI_DEVICE(s);
PCIHostState *phb = PCI_HOST_BRIDGE(s->pcihost);
uint32_t pciaddr;
uint16_t status;
DPRINTF("FUNC_0 "TARGET_FMT_plx"\n", addr);
assert((addr & 0x3) == 0);
pciaddr = bonito_sbridge_pciaddr(s, addr);
if (pciaddr == 0xffffffff) {
return 0xffffffff;
}
phb->config_reg = (pciaddr) | (1u << 31);
status = pci_get_word(d->config + PCI_STATUS);
status &= ~(PCI_STATUS_REC_MASTER_ABORT | PCI_STATUS_REC_TARGET_ABORT);
pci_set_word(d->config + PCI_STATUS, status);
return pci_data_read(phb->bus, phb->config_reg, 4);
}
| [
"static uint32_t FUNC_0(void *opaque, target_phys_addr_t addr)\n{",
"PCIBonitoState *s = opaque;",
"PCIDevice *d = PCI_DEVICE(s);",
"PCIHostState *phb = PCI_HOST_BRIDGE(s->pcihost);",
"uint32_t pciaddr;",
"uint16_t status;",
"DPRINTF(\"FUNC_0 \"TARGET_FMT_plx\"\\n\", addr);",
"assert((addr & 0x3) == 0);",
"pciaddr = bonito_sbridge_pciaddr(s, addr);",
"if (pciaddr == 0xffffffff) {",
"return 0xffffffff;",
"}",
"phb->config_reg = (pciaddr) | (1u << 31);",
"status = pci_get_word(d->config + PCI_STATUS);",
"status &= ~(PCI_STATUS_REC_MASTER_ABORT | PCI_STATUS_REC_TARGET_ABORT);",
"pci_set_word(d->config + PCI_STATUS, status);",
"return pci_data_read(phb->bus, phb->config_reg, 4);",
"}"
] | [
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
],
[
37
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
]
] |
18,917 | static VirtIOSerialPort *find_port_by_name(char *name)
{
VirtIOSerial *vser;
QLIST_FOREACH(vser, &vserdevices.devices, next) {
VirtIOSerialPort *port;
QTAILQ_FOREACH(port, &vser->ports, next) {
if (!strcmp(port->name, name)) {
return port;
}
}
}
return NULL;
}
| false | qemu | b18a755c4266a340a25ab4118525bd57c3dfc3fa | static VirtIOSerialPort *find_port_by_name(char *name)
{
VirtIOSerial *vser;
QLIST_FOREACH(vser, &vserdevices.devices, next) {
VirtIOSerialPort *port;
QTAILQ_FOREACH(port, &vser->ports, next) {
if (!strcmp(port->name, name)) {
return port;
}
}
}
return NULL;
}
| {
"code": [],
"line_no": []
} | static VirtIOSerialPort *FUNC_0(char *name)
{
VirtIOSerial *vser;
QLIST_FOREACH(vser, &vserdevices.devices, next) {
VirtIOSerialPort *port;
QTAILQ_FOREACH(port, &vser->ports, next) {
if (!strcmp(port->name, name)) {
return port;
}
}
}
return NULL;
}
| [
"static VirtIOSerialPort *FUNC_0(char *name)\n{",
"VirtIOSerial *vser;",
"QLIST_FOREACH(vser, &vserdevices.devices, next) {",
"VirtIOSerialPort *port;",
"QTAILQ_FOREACH(port, &vser->ports, next) {",
"if (!strcmp(port->name, name)) {",
"return port;",
"}",
"}",
"}",
"return NULL;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
]
] |
18,918 | void op_mtc0_status (void)
{
uint32_t val, old;
uint32_t mask = env->Status_rw_bitmask;
/* No reverse endianness, no MDMX/DSP, no 64bit ops
implemented. */
val = T0 & mask;
old = env->CP0_Status;
if (!(val & (1 << CP0St_EXL)) &&
!(val & (1 << CP0St_ERL)) &&
!(env->hflags & MIPS_HFLAG_DM) &&
(val & (1 << CP0St_UM)))
env->hflags |= MIPS_HFLAG_UM;
#ifdef TARGET_MIPS64
if ((env->hflags & MIPS_HFLAG_UM) &&
!(val & (1 << CP0St_PX)) &&
!(val & (1 << CP0St_UX)))
env->hflags &= ~MIPS_HFLAG_64;
#endif
env->CP0_Status = (env->CP0_Status & ~mask) | val;
if (loglevel & CPU_LOG_EXEC)
CALL_FROM_TB2(do_mtc0_status_debug, old, val);
CALL_FROM_TB1(cpu_mips_update_irq, env);
RETURN();
}
| false | qemu | 5e755519ac9d867f7da13f58a9d0c262db82e14c | void op_mtc0_status (void)
{
uint32_t val, old;
uint32_t mask = env->Status_rw_bitmask;
val = T0 & mask;
old = env->CP0_Status;
if (!(val & (1 << CP0St_EXL)) &&
!(val & (1 << CP0St_ERL)) &&
!(env->hflags & MIPS_HFLAG_DM) &&
(val & (1 << CP0St_UM)))
env->hflags |= MIPS_HFLAG_UM;
#ifdef TARGET_MIPS64
if ((env->hflags & MIPS_HFLAG_UM) &&
!(val & (1 << CP0St_PX)) &&
!(val & (1 << CP0St_UX)))
env->hflags &= ~MIPS_HFLAG_64;
#endif
env->CP0_Status = (env->CP0_Status & ~mask) | val;
if (loglevel & CPU_LOG_EXEC)
CALL_FROM_TB2(do_mtc0_status_debug, old, val);
CALL_FROM_TB1(cpu_mips_update_irq, env);
RETURN();
}
| {
"code": [],
"line_no": []
} | void FUNC_0 (void)
{
uint32_t val, old;
uint32_t mask = env->Status_rw_bitmask;
val = T0 & mask;
old = env->CP0_Status;
if (!(val & (1 << CP0St_EXL)) &&
!(val & (1 << CP0St_ERL)) &&
!(env->hflags & MIPS_HFLAG_DM) &&
(val & (1 << CP0St_UM)))
env->hflags |= MIPS_HFLAG_UM;
#ifdef TARGET_MIPS64
if ((env->hflags & MIPS_HFLAG_UM) &&
!(val & (1 << CP0St_PX)) &&
!(val & (1 << CP0St_UX)))
env->hflags &= ~MIPS_HFLAG_64;
#endif
env->CP0_Status = (env->CP0_Status & ~mask) | val;
if (loglevel & CPU_LOG_EXEC)
CALL_FROM_TB2(do_mtc0_status_debug, old, val);
CALL_FROM_TB1(cpu_mips_update_irq, env);
RETURN();
}
| [
"void FUNC_0 (void)\n{",
"uint32_t val, old;",
"uint32_t mask = env->Status_rw_bitmask;",
"val = T0 & mask;",
"old = env->CP0_Status;",
"if (!(val & (1 << CP0St_EXL)) &&\n!(val & (1 << CP0St_ERL)) &&\n!(env->hflags & MIPS_HFLAG_DM) &&\n(val & (1 << CP0St_UM)))\nenv->hflags |= MIPS_HFLAG_UM;",
"#ifdef TARGET_MIPS64\nif ((env->hflags & MIPS_HFLAG_UM) &&\n!(val & (1 << CP0St_PX)) &&\n!(val & (1 << CP0St_UX)))\nenv->hflags &= ~MIPS_HFLAG_64;",
"#endif\nenv->CP0_Status = (env->CP0_Status & ~mask) | val;",
"if (loglevel & CPU_LOG_EXEC)\nCALL_FROM_TB2(do_mtc0_status_debug, old, val);",
"CALL_FROM_TB1(cpu_mips_update_irq, env);",
"RETURN();",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
15
],
[
17
],
[
19,
21,
23,
25,
27
],
[
29,
31,
33,
35,
37
],
[
39,
41
],
[
43,
45
],
[
47
],
[
49
],
[
51
]
] |
18,919 | static inline uint32_t ldl_phys_internal(target_phys_addr_t addr,
enum device_endian endian)
{
uint8_t *ptr;
uint32_t val;
MemoryRegionSection *section;
section = phys_page_find(address_space_memory.dispatch, addr >> TARGET_PAGE_BITS);
if (!(memory_region_is_ram(section->mr) ||
memory_region_is_romd(section->mr))) {
/* I/O case */
addr = memory_region_section_addr(section, addr);
val = io_mem_read(section->mr, addr, 4);
#if defined(TARGET_WORDS_BIGENDIAN)
if (endian == DEVICE_LITTLE_ENDIAN) {
val = bswap32(val);
}
#else
if (endian == DEVICE_BIG_ENDIAN) {
val = bswap32(val);
}
#endif
} else {
/* RAM case */
ptr = qemu_get_ram_ptr((memory_region_get_ram_addr(section->mr)
& TARGET_PAGE_MASK)
+ memory_region_section_addr(section, addr));
switch (endian) {
case DEVICE_LITTLE_ENDIAN:
val = ldl_le_p(ptr);
break;
case DEVICE_BIG_ENDIAN:
val = ldl_be_p(ptr);
break;
default:
val = ldl_p(ptr);
break;
}
}
return val;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static inline uint32_t ldl_phys_internal(target_phys_addr_t addr,
enum device_endian endian)
{
uint8_t *ptr;
uint32_t val;
MemoryRegionSection *section;
section = phys_page_find(address_space_memory.dispatch, addr >> TARGET_PAGE_BITS);
if (!(memory_region_is_ram(section->mr) ||
memory_region_is_romd(section->mr))) {
addr = memory_region_section_addr(section, addr);
val = io_mem_read(section->mr, addr, 4);
#if defined(TARGET_WORDS_BIGENDIAN)
if (endian == DEVICE_LITTLE_ENDIAN) {
val = bswap32(val);
}
#else
if (endian == DEVICE_BIG_ENDIAN) {
val = bswap32(val);
}
#endif
} else {
ptr = qemu_get_ram_ptr((memory_region_get_ram_addr(section->mr)
& TARGET_PAGE_MASK)
+ memory_region_section_addr(section, addr));
switch (endian) {
case DEVICE_LITTLE_ENDIAN:
val = ldl_le_p(ptr);
break;
case DEVICE_BIG_ENDIAN:
val = ldl_be_p(ptr);
break;
default:
val = ldl_p(ptr);
break;
}
}
return val;
}
| {
"code": [],
"line_no": []
} | static inline uint32_t FUNC_0(target_phys_addr_t addr,
enum device_endian endian)
{
uint8_t *ptr;
uint32_t val;
MemoryRegionSection *section;
section = phys_page_find(address_space_memory.dispatch, addr >> TARGET_PAGE_BITS);
if (!(memory_region_is_ram(section->mr) ||
memory_region_is_romd(section->mr))) {
addr = memory_region_section_addr(section, addr);
val = io_mem_read(section->mr, addr, 4);
#if defined(TARGET_WORDS_BIGENDIAN)
if (endian == DEVICE_LITTLE_ENDIAN) {
val = bswap32(val);
}
#else
if (endian == DEVICE_BIG_ENDIAN) {
val = bswap32(val);
}
#endif
} else {
ptr = qemu_get_ram_ptr((memory_region_get_ram_addr(section->mr)
& TARGET_PAGE_MASK)
+ memory_region_section_addr(section, addr));
switch (endian) {
case DEVICE_LITTLE_ENDIAN:
val = ldl_le_p(ptr);
break;
case DEVICE_BIG_ENDIAN:
val = ldl_be_p(ptr);
break;
default:
val = ldl_p(ptr);
break;
}
}
return val;
}
| [
"static inline uint32_t FUNC_0(target_phys_addr_t addr,\nenum device_endian endian)\n{",
"uint8_t *ptr;",
"uint32_t val;",
"MemoryRegionSection *section;",
"section = phys_page_find(address_space_memory.dispatch, addr >> TARGET_PAGE_BITS);",
"if (!(memory_region_is_ram(section->mr) ||\nmemory_region_is_romd(section->mr))) {",
"addr = memory_region_section_addr(section, addr);",
"val = io_mem_read(section->mr, addr, 4);",
"#if defined(TARGET_WORDS_BIGENDIAN)\nif (endian == DEVICE_LITTLE_ENDIAN) {",
"val = bswap32(val);",
"}",
"#else\nif (endian == DEVICE_BIG_ENDIAN) {",
"val = bswap32(val);",
"}",
"#endif\n} else {",
"ptr = qemu_get_ram_ptr((memory_region_get_ram_addr(section->mr)\n& TARGET_PAGE_MASK)\n+ memory_region_section_addr(section, addr));",
"switch (endian) {",
"case DEVICE_LITTLE_ENDIAN:\nval = ldl_le_p(ptr);",
"break;",
"case DEVICE_BIG_ENDIAN:\nval = ldl_be_p(ptr);",
"break;",
"default:\nval = ldl_p(ptr);",
"break;",
"}",
"}",
"return val;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
19,
21
],
[
25
],
[
27
],
[
29,
31
],
[
33
],
[
35
],
[
37,
39
],
[
41
],
[
43
],
[
45,
47
],
[
51,
53,
55
],
[
57
],
[
59,
61
],
[
63
],
[
65,
67
],
[
69
],
[
71,
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
]
] |
18,920 | static int vtd_irte_get(IntelIOMMUState *iommu, uint16_t index,
VTD_IRTE *entry)
{
dma_addr_t addr = 0x00;
addr = iommu->intr_root + index * sizeof(*entry);
if (dma_memory_read(&address_space_memory, addr, entry,
sizeof(*entry))) {
VTD_DPRINTF(GENERAL, "error: fail to access IR root at 0x%"PRIx64
" + %"PRIu16, iommu->intr_root, index);
return -VTD_FR_IR_ROOT_INVAL;
}
if (!entry->present) {
VTD_DPRINTF(GENERAL, "error: present flag not set in IRTE"
" entry index %u value 0x%"PRIx64 " 0x%"PRIx64,
index, le64_to_cpu(entry->data[1]),
le64_to_cpu(entry->data[0]));
return -VTD_FR_IR_ENTRY_P;
}
if (entry->__reserved_0 || entry->__reserved_1 || \
entry->__reserved_2) {
VTD_DPRINTF(GENERAL, "error: IRTE entry index %"PRIu16
" reserved fields non-zero: 0x%"PRIx64 " 0x%"PRIx64,
index, le64_to_cpu(entry->data[1]),
le64_to_cpu(entry->data[0]));
return -VTD_FR_IR_IRTE_RSVD;
}
/*
* TODO: Check Source-ID corresponds to SVT (Source Validation
* Type) bits
*/
return 0;
}
| false | qemu | ede9c94acf6cd1968de4188c0228b714ab871a86 | static int vtd_irte_get(IntelIOMMUState *iommu, uint16_t index,
VTD_IRTE *entry)
{
dma_addr_t addr = 0x00;
addr = iommu->intr_root + index * sizeof(*entry);
if (dma_memory_read(&address_space_memory, addr, entry,
sizeof(*entry))) {
VTD_DPRINTF(GENERAL, "error: fail to access IR root at 0x%"PRIx64
" + %"PRIu16, iommu->intr_root, index);
return -VTD_FR_IR_ROOT_INVAL;
}
if (!entry->present) {
VTD_DPRINTF(GENERAL, "error: present flag not set in IRTE"
" entry index %u value 0x%"PRIx64 " 0x%"PRIx64,
index, le64_to_cpu(entry->data[1]),
le64_to_cpu(entry->data[0]));
return -VTD_FR_IR_ENTRY_P;
}
if (entry->__reserved_0 || entry->__reserved_1 || \
entry->__reserved_2) {
VTD_DPRINTF(GENERAL, "error: IRTE entry index %"PRIu16
" reserved fields non-zero: 0x%"PRIx64 " 0x%"PRIx64,
index, le64_to_cpu(entry->data[1]),
le64_to_cpu(entry->data[0]));
return -VTD_FR_IR_IRTE_RSVD;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(IntelIOMMUState *VAR_0, uint16_t VAR_1,
VTD_IRTE *VAR_2)
{
dma_addr_t addr = 0x00;
addr = VAR_0->intr_root + VAR_1 * sizeof(*VAR_2);
if (dma_memory_read(&address_space_memory, addr, VAR_2,
sizeof(*VAR_2))) {
VTD_DPRINTF(GENERAL, "error: fail to access IR root at 0x%"PRIx64
" + %"PRIu16, VAR_0->intr_root, VAR_1);
return -VTD_FR_IR_ROOT_INVAL;
}
if (!VAR_2->present) {
VTD_DPRINTF(GENERAL, "error: present flag not set in IRTE"
" VAR_2 VAR_1 %u value 0x%"PRIx64 " 0x%"PRIx64,
VAR_1, le64_to_cpu(VAR_2->data[1]),
le64_to_cpu(VAR_2->data[0]));
return -VTD_FR_IR_ENTRY_P;
}
if (VAR_2->__reserved_0 || VAR_2->__reserved_1 || \
VAR_2->__reserved_2) {
VTD_DPRINTF(GENERAL, "error: IRTE VAR_2 VAR_1 %"PRIu16
" reserved fields non-zero: 0x%"PRIx64 " 0x%"PRIx64,
VAR_1, le64_to_cpu(VAR_2->data[1]),
le64_to_cpu(VAR_2->data[0]));
return -VTD_FR_IR_IRTE_RSVD;
}
return 0;
}
| [
"static int FUNC_0(IntelIOMMUState *VAR_0, uint16_t VAR_1,\nVTD_IRTE *VAR_2)\n{",
"dma_addr_t addr = 0x00;",
"addr = VAR_0->intr_root + VAR_1 * sizeof(*VAR_2);",
"if (dma_memory_read(&address_space_memory, addr, VAR_2,\nsizeof(*VAR_2))) {",
"VTD_DPRINTF(GENERAL, \"error: fail to access IR root at 0x%\"PRIx64\n\" + %\"PRIu16, VAR_0->intr_root, VAR_1);",
"return -VTD_FR_IR_ROOT_INVAL;",
"}",
"if (!VAR_2->present) {",
"VTD_DPRINTF(GENERAL, \"error: present flag not set in IRTE\"\n\" VAR_2 VAR_1 %u value 0x%\"PRIx64 \" 0x%\"PRIx64,\nVAR_1, le64_to_cpu(VAR_2->data[1]),\nle64_to_cpu(VAR_2->data[0]));",
"return -VTD_FR_IR_ENTRY_P;",
"}",
"if (VAR_2->__reserved_0 || VAR_2->__reserved_1 || \\\nVAR_2->__reserved_2) {",
"VTD_DPRINTF(GENERAL, \"error: IRTE VAR_2 VAR_1 %\"PRIu16\n\" reserved fields non-zero: 0x%\"PRIx64 \" 0x%\"PRIx64,\nVAR_1, le64_to_cpu(VAR_2->data[1]),\nle64_to_cpu(VAR_2->data[0]));",
"return -VTD_FR_IR_IRTE_RSVD;",
"}",
"return 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
],
[
27
],
[
29,
31,
33,
35
],
[
37
],
[
39
],
[
43,
45
],
[
47,
49,
51,
53
],
[
55
],
[
57
],
[
71
],
[
73
]
] |
18,921 | static CharDriverState *qemu_chr_open_pty(void)
{
struct termios tty;
int master_fd, slave_fd;
if (openpty(&master_fd, &slave_fd, NULL, NULL, NULL) < 0) {
return NULL;
}
/* Set raw attributes on the pty. */
cfmakeraw(&tty);
tcsetattr(slave_fd, TCSAFLUSH, &tty);
fprintf(stderr, "char device redirected to %s\n", ptsname(master_fd));
return qemu_chr_open_fd(master_fd, master_fd);
}
| false | qemu | 279e694bc7bae106dc1178e7fbb60dfb832396e7 | static CharDriverState *qemu_chr_open_pty(void)
{
struct termios tty;
int master_fd, slave_fd;
if (openpty(&master_fd, &slave_fd, NULL, NULL, NULL) < 0) {
return NULL;
}
cfmakeraw(&tty);
tcsetattr(slave_fd, TCSAFLUSH, &tty);
fprintf(stderr, "char device redirected to %s\n", ptsname(master_fd));
return qemu_chr_open_fd(master_fd, master_fd);
}
| {
"code": [],
"line_no": []
} | static CharDriverState *FUNC_0(void)
{
struct termios VAR_0;
int VAR_1, VAR_2;
if (openpty(&VAR_1, &VAR_2, NULL, NULL, NULL) < 0) {
return NULL;
}
cfmakeraw(&VAR_0);
tcsetattr(VAR_2, TCSAFLUSH, &VAR_0);
fprintf(stderr, "char device redirected to %s\n", ptsname(VAR_1));
return qemu_chr_open_fd(VAR_1, VAR_1);
}
| [
"static CharDriverState *FUNC_0(void)\n{",
"struct termios VAR_0;",
"int VAR_1, VAR_2;",
"if (openpty(&VAR_1, &VAR_2, NULL, NULL, NULL) < 0) {",
"return NULL;",
"}",
"cfmakeraw(&VAR_0);",
"tcsetattr(VAR_2, TCSAFLUSH, &VAR_0);",
"fprintf(stderr, \"char device redirected to %s\\n\", ptsname(VAR_1));",
"return qemu_chr_open_fd(VAR_1, VAR_1);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
]
] |
18,922 | static int xen_pt_long_reg_read(XenPCIPassthroughState *s, XenPTReg *cfg_entry,
uint32_t *value, uint32_t valid_mask)
{
XenPTRegInfo *reg = cfg_entry->reg;
uint32_t valid_emu_mask = 0;
/* emulate long register */
valid_emu_mask = reg->emu_mask & valid_mask;
*value = XEN_PT_MERGE_VALUE(*value, cfg_entry->data, ~valid_emu_mask);
return 0;
}
| false | qemu | e2779de053b64f023de382fd87b3596613d47d1e | static int xen_pt_long_reg_read(XenPCIPassthroughState *s, XenPTReg *cfg_entry,
uint32_t *value, uint32_t valid_mask)
{
XenPTRegInfo *reg = cfg_entry->reg;
uint32_t valid_emu_mask = 0;
valid_emu_mask = reg->emu_mask & valid_mask;
*value = XEN_PT_MERGE_VALUE(*value, cfg_entry->data, ~valid_emu_mask);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(XenPCIPassthroughState *VAR_0, XenPTReg *VAR_1,
uint32_t *VAR_2, uint32_t VAR_3)
{
XenPTRegInfo *reg = VAR_1->reg;
uint32_t valid_emu_mask = 0;
valid_emu_mask = reg->emu_mask & VAR_3;
*VAR_2 = XEN_PT_MERGE_VALUE(*VAR_2, VAR_1->data, ~valid_emu_mask);
return 0;
}
| [
"static int FUNC_0(XenPCIPassthroughState *VAR_0, XenPTReg *VAR_1,\nuint32_t *VAR_2, uint32_t VAR_3)\n{",
"XenPTRegInfo *reg = VAR_1->reg;",
"uint32_t valid_emu_mask = 0;",
"valid_emu_mask = reg->emu_mask & VAR_3;",
"*VAR_2 = XEN_PT_MERGE_VALUE(*VAR_2, VAR_1->data, ~valid_emu_mask);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
15
],
[
17
],
[
21
],
[
23
]
] |
18,923 | static void tgen_setcond(TCGContext *s, TCGType type, TCGCond cond,
TCGReg dest, TCGReg c1, TCGArg c2, int c2const)
{
int cc;
switch (cond) {
case TCG_COND_GTU:
case TCG_COND_GT:
do_greater:
/* The result of a compare has CC=2 for GT and CC=3 unused.
ADD LOGICAL WITH CARRY considers (CC & 2) the carry bit. */
tgen_cmp(s, type, cond, c1, c2, c2const, true);
tcg_out_movi(s, type, dest, 0);
tcg_out_insn(s, RRE, ALCGR, dest, dest);
return;
case TCG_COND_GEU:
do_geu:
/* We need "real" carry semantics, so use SUBTRACT LOGICAL
instead of COMPARE LOGICAL. This needs an extra move. */
tcg_out_mov(s, type, TCG_TMP0, c1);
if (c2const) {
tcg_out_movi(s, TCG_TYPE_I64, dest, 0);
if (type == TCG_TYPE_I32) {
tcg_out_insn(s, RIL, SLFI, TCG_TMP0, c2);
} else {
tcg_out_insn(s, RIL, SLGFI, TCG_TMP0, c2);
}
} else {
if (type == TCG_TYPE_I32) {
tcg_out_insn(s, RR, SLR, TCG_TMP0, c2);
} else {
tcg_out_insn(s, RRE, SLGR, TCG_TMP0, c2);
}
tcg_out_movi(s, TCG_TYPE_I64, dest, 0);
}
tcg_out_insn(s, RRE, ALCGR, dest, dest);
return;
case TCG_COND_LEU:
case TCG_COND_LTU:
case TCG_COND_LT:
/* Swap operands so that we can use GEU/GTU/GT. */
if (c2const) {
tcg_out_movi(s, type, TCG_TMP0, c2);
c2 = c1;
c2const = 0;
c1 = TCG_TMP0;
} else {
TCGReg t = c1;
c1 = c2;
c2 = t;
}
if (cond == TCG_COND_LEU) {
goto do_geu;
}
cond = tcg_swap_cond(cond);
goto do_greater;
case TCG_COND_NE:
/* X != 0 is X > 0. */
if (c2const && c2 == 0) {
cond = TCG_COND_GTU;
goto do_greater;
}
break;
case TCG_COND_EQ:
/* X == 0 is X <= 0 is 0 >= X. */
if (c2const && c2 == 0) {
tcg_out_movi(s, TCG_TYPE_I64, TCG_TMP0, 0);
c2 = c1;
c2const = 0;
c1 = TCG_TMP0;
goto do_geu;
}
break;
default:
break;
}
cc = tgen_cmp(s, type, cond, c1, c2, c2const, false);
if (facilities & FACILITY_LOAD_ON_COND) {
/* Emit: d = 0, t = 1, d = (cc ? t : d). */
tcg_out_movi(s, TCG_TYPE_I64, dest, 0);
tcg_out_movi(s, TCG_TYPE_I64, TCG_TMP0, 1);
tcg_out_insn(s, RRF, LOCGR, dest, TCG_TMP0, cc);
} else {
/* Emit: d = 1; if (cc) goto over; d = 0; over: */
tcg_out_movi(s, type, dest, 1);
tcg_out_insn(s, RI, BRC, cc, (4 + 4) >> 1);
tcg_out_movi(s, type, dest, 0);
}
}
| false | qemu | b2c98d9d392c87c9b9e975d30f79924719d9cbbe | static void tgen_setcond(TCGContext *s, TCGType type, TCGCond cond,
TCGReg dest, TCGReg c1, TCGArg c2, int c2const)
{
int cc;
switch (cond) {
case TCG_COND_GTU:
case TCG_COND_GT:
do_greater:
tgen_cmp(s, type, cond, c1, c2, c2const, true);
tcg_out_movi(s, type, dest, 0);
tcg_out_insn(s, RRE, ALCGR, dest, dest);
return;
case TCG_COND_GEU:
do_geu:
tcg_out_mov(s, type, TCG_TMP0, c1);
if (c2const) {
tcg_out_movi(s, TCG_TYPE_I64, dest, 0);
if (type == TCG_TYPE_I32) {
tcg_out_insn(s, RIL, SLFI, TCG_TMP0, c2);
} else {
tcg_out_insn(s, RIL, SLGFI, TCG_TMP0, c2);
}
} else {
if (type == TCG_TYPE_I32) {
tcg_out_insn(s, RR, SLR, TCG_TMP0, c2);
} else {
tcg_out_insn(s, RRE, SLGR, TCG_TMP0, c2);
}
tcg_out_movi(s, TCG_TYPE_I64, dest, 0);
}
tcg_out_insn(s, RRE, ALCGR, dest, dest);
return;
case TCG_COND_LEU:
case TCG_COND_LTU:
case TCG_COND_LT:
if (c2const) {
tcg_out_movi(s, type, TCG_TMP0, c2);
c2 = c1;
c2const = 0;
c1 = TCG_TMP0;
} else {
TCGReg t = c1;
c1 = c2;
c2 = t;
}
if (cond == TCG_COND_LEU) {
goto do_geu;
}
cond = tcg_swap_cond(cond);
goto do_greater;
case TCG_COND_NE:
if (c2const && c2 == 0) {
cond = TCG_COND_GTU;
goto do_greater;
}
break;
case TCG_COND_EQ:
if (c2const && c2 == 0) {
tcg_out_movi(s, TCG_TYPE_I64, TCG_TMP0, 0);
c2 = c1;
c2const = 0;
c1 = TCG_TMP0;
goto do_geu;
}
break;
default:
break;
}
cc = tgen_cmp(s, type, cond, c1, c2, c2const, false);
if (facilities & FACILITY_LOAD_ON_COND) {
tcg_out_movi(s, TCG_TYPE_I64, dest, 0);
tcg_out_movi(s, TCG_TYPE_I64, TCG_TMP0, 1);
tcg_out_insn(s, RRF, LOCGR, dest, TCG_TMP0, cc);
} else {
tcg_out_movi(s, type, dest, 1);
tcg_out_insn(s, RI, BRC, cc, (4 + 4) >> 1);
tcg_out_movi(s, type, dest, 0);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(TCGContext *VAR_0, TCGType VAR_1, TCGCond VAR_2,
TCGReg VAR_3, TCGReg VAR_4, TCGArg VAR_5, int VAR_6)
{
int VAR_7;
switch (VAR_2) {
case TCG_COND_GTU:
case TCG_COND_GT:
do_greater:
tgen_cmp(VAR_0, VAR_1, VAR_2, VAR_4, VAR_5, VAR_6, true);
tcg_out_movi(VAR_0, VAR_1, VAR_3, 0);
tcg_out_insn(VAR_0, RRE, ALCGR, VAR_3, VAR_3);
return;
case TCG_COND_GEU:
do_geu:
tcg_out_mov(VAR_0, VAR_1, TCG_TMP0, VAR_4);
if (VAR_6) {
tcg_out_movi(VAR_0, TCG_TYPE_I64, VAR_3, 0);
if (VAR_1 == TCG_TYPE_I32) {
tcg_out_insn(VAR_0, RIL, SLFI, TCG_TMP0, VAR_5);
} else {
tcg_out_insn(VAR_0, RIL, SLGFI, TCG_TMP0, VAR_5);
}
} else {
if (VAR_1 == TCG_TYPE_I32) {
tcg_out_insn(VAR_0, RR, SLR, TCG_TMP0, VAR_5);
} else {
tcg_out_insn(VAR_0, RRE, SLGR, TCG_TMP0, VAR_5);
}
tcg_out_movi(VAR_0, TCG_TYPE_I64, VAR_3, 0);
}
tcg_out_insn(VAR_0, RRE, ALCGR, VAR_3, VAR_3);
return;
case TCG_COND_LEU:
case TCG_COND_LTU:
case TCG_COND_LT:
if (VAR_6) {
tcg_out_movi(VAR_0, VAR_1, TCG_TMP0, VAR_5);
VAR_5 = VAR_4;
VAR_6 = 0;
VAR_4 = TCG_TMP0;
} else {
TCGReg t = VAR_4;
VAR_4 = VAR_5;
VAR_5 = t;
}
if (VAR_2 == TCG_COND_LEU) {
goto do_geu;
}
VAR_2 = tcg_swap_cond(VAR_2);
goto do_greater;
case TCG_COND_NE:
if (VAR_6 && VAR_5 == 0) {
VAR_2 = TCG_COND_GTU;
goto do_greater;
}
break;
case TCG_COND_EQ:
if (VAR_6 && VAR_5 == 0) {
tcg_out_movi(VAR_0, TCG_TYPE_I64, TCG_TMP0, 0);
VAR_5 = VAR_4;
VAR_6 = 0;
VAR_4 = TCG_TMP0;
goto do_geu;
}
break;
default:
break;
}
VAR_7 = tgen_cmp(VAR_0, VAR_1, VAR_2, VAR_4, VAR_5, VAR_6, false);
if (facilities & FACILITY_LOAD_ON_COND) {
tcg_out_movi(VAR_0, TCG_TYPE_I64, VAR_3, 0);
tcg_out_movi(VAR_0, TCG_TYPE_I64, TCG_TMP0, 1);
tcg_out_insn(VAR_0, RRF, LOCGR, VAR_3, TCG_TMP0, VAR_7);
} else {
tcg_out_movi(VAR_0, VAR_1, VAR_3, 1);
tcg_out_insn(VAR_0, RI, BRC, VAR_7, (4 + 4) >> 1);
tcg_out_movi(VAR_0, VAR_1, VAR_3, 0);
}
}
| [
"static void FUNC_0(TCGContext *VAR_0, TCGType VAR_1, TCGCond VAR_2,\nTCGReg VAR_3, TCGReg VAR_4, TCGArg VAR_5, int VAR_6)\n{",
"int VAR_7;",
"switch (VAR_2) {",
"case TCG_COND_GTU:\ncase TCG_COND_GT:\ndo_greater:\ntgen_cmp(VAR_0, VAR_1, VAR_2, VAR_4, VAR_5, VAR_6, true);",
"tcg_out_movi(VAR_0, VAR_1, VAR_3, 0);",
"tcg_out_insn(VAR_0, RRE, ALCGR, VAR_3, VAR_3);",
"return;",
"case TCG_COND_GEU:\ndo_geu:\ntcg_out_mov(VAR_0, VAR_1, TCG_TMP0, VAR_4);",
"if (VAR_6) {",
"tcg_out_movi(VAR_0, TCG_TYPE_I64, VAR_3, 0);",
"if (VAR_1 == TCG_TYPE_I32) {",
"tcg_out_insn(VAR_0, RIL, SLFI, TCG_TMP0, VAR_5);",
"} else {",
"tcg_out_insn(VAR_0, RIL, SLGFI, TCG_TMP0, VAR_5);",
"}",
"} else {",
"if (VAR_1 == TCG_TYPE_I32) {",
"tcg_out_insn(VAR_0, RR, SLR, TCG_TMP0, VAR_5);",
"} else {",
"tcg_out_insn(VAR_0, RRE, SLGR, TCG_TMP0, VAR_5);",
"}",
"tcg_out_movi(VAR_0, TCG_TYPE_I64, VAR_3, 0);",
"}",
"tcg_out_insn(VAR_0, RRE, ALCGR, VAR_3, VAR_3);",
"return;",
"case TCG_COND_LEU:\ncase TCG_COND_LTU:\ncase TCG_COND_LT:\nif (VAR_6) {",
"tcg_out_movi(VAR_0, VAR_1, TCG_TMP0, VAR_5);",
"VAR_5 = VAR_4;",
"VAR_6 = 0;",
"VAR_4 = TCG_TMP0;",
"} else {",
"TCGReg t = VAR_4;",
"VAR_4 = VAR_5;",
"VAR_5 = t;",
"}",
"if (VAR_2 == TCG_COND_LEU) {",
"goto do_geu;",
"}",
"VAR_2 = tcg_swap_cond(VAR_2);",
"goto do_greater;",
"case TCG_COND_NE:\nif (VAR_6 && VAR_5 == 0) {",
"VAR_2 = TCG_COND_GTU;",
"goto do_greater;",
"}",
"break;",
"case TCG_COND_EQ:\nif (VAR_6 && VAR_5 == 0) {",
"tcg_out_movi(VAR_0, TCG_TYPE_I64, TCG_TMP0, 0);",
"VAR_5 = VAR_4;",
"VAR_6 = 0;",
"VAR_4 = TCG_TMP0;",
"goto do_geu;",
"}",
"break;",
"default:\nbreak;",
"}",
"VAR_7 = tgen_cmp(VAR_0, VAR_1, VAR_2, VAR_4, VAR_5, VAR_6, false);",
"if (facilities & FACILITY_LOAD_ON_COND) {",
"tcg_out_movi(VAR_0, TCG_TYPE_I64, VAR_3, 0);",
"tcg_out_movi(VAR_0, TCG_TYPE_I64, TCG_TMP0, 1);",
"tcg_out_insn(VAR_0, RRF, LOCGR, VAR_3, TCG_TMP0, VAR_7);",
"} else {",
"tcg_out_movi(VAR_0, VAR_1, VAR_3, 1);",
"tcg_out_insn(VAR_0, RI, BRC, VAR_7, (4 + 4) >> 1);",
"tcg_out_movi(VAR_0, VAR_1, VAR_3, 0);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13,
15,
17,
23
],
[
25
],
[
27
],
[
29
],
[
33,
35,
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79,
81,
83,
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
119,
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
135,
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
157,
159
],
[
161
],
[
165
],
[
167
],
[
171
],
[
173
],
[
175
],
[
177
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
]
] |
18,924 | static CharDriverState *qemu_chr_open_pty(const char *id,
ChardevReturn *ret)
{
CharDriverState *chr;
PtyCharDriver *s;
int master_fd, slave_fd;
char pty_name[PATH_MAX];
master_fd = qemu_openpty_raw(&slave_fd, pty_name);
if (master_fd < 0) {
return NULL;
}
close(slave_fd);
chr = g_malloc0(sizeof(CharDriverState));
chr->filename = g_strdup_printf("pty:%s", pty_name);
ret->pty = g_strdup(pty_name);
ret->has_pty = true;
fprintf(stderr, "char device redirected to %s (label %s)\n",
pty_name, id);
s = g_malloc0(sizeof(PtyCharDriver));
chr->opaque = s;
chr->chr_write = pty_chr_write;
chr->chr_update_read_handler = pty_chr_update_read_handler;
chr->chr_close = pty_chr_close;
chr->chr_add_watch = pty_chr_add_watch;
chr->explicit_be_open = true;
s->fd = io_channel_from_fd(master_fd);
s->timer_tag = 0;
return chr;
}
| false | qemu | db39fcf1f690b02d612e2bfc00980700887abe03 | static CharDriverState *qemu_chr_open_pty(const char *id,
ChardevReturn *ret)
{
CharDriverState *chr;
PtyCharDriver *s;
int master_fd, slave_fd;
char pty_name[PATH_MAX];
master_fd = qemu_openpty_raw(&slave_fd, pty_name);
if (master_fd < 0) {
return NULL;
}
close(slave_fd);
chr = g_malloc0(sizeof(CharDriverState));
chr->filename = g_strdup_printf("pty:%s", pty_name);
ret->pty = g_strdup(pty_name);
ret->has_pty = true;
fprintf(stderr, "char device redirected to %s (label %s)\n",
pty_name, id);
s = g_malloc0(sizeof(PtyCharDriver));
chr->opaque = s;
chr->chr_write = pty_chr_write;
chr->chr_update_read_handler = pty_chr_update_read_handler;
chr->chr_close = pty_chr_close;
chr->chr_add_watch = pty_chr_add_watch;
chr->explicit_be_open = true;
s->fd = io_channel_from_fd(master_fd);
s->timer_tag = 0;
return chr;
}
| {
"code": [],
"line_no": []
} | static CharDriverState *FUNC_0(const char *id,
ChardevReturn *ret)
{
CharDriverState *chr;
PtyCharDriver *s;
int VAR_0, VAR_1;
char VAR_2[PATH_MAX];
VAR_0 = qemu_openpty_raw(&VAR_1, VAR_2);
if (VAR_0 < 0) {
return NULL;
}
close(VAR_1);
chr = g_malloc0(sizeof(CharDriverState));
chr->filename = g_strdup_printf("pty:%s", VAR_2);
ret->pty = g_strdup(VAR_2);
ret->has_pty = true;
fprintf(stderr, "char device redirected to %s (label %s)\n",
VAR_2, id);
s = g_malloc0(sizeof(PtyCharDriver));
chr->opaque = s;
chr->chr_write = pty_chr_write;
chr->chr_update_read_handler = pty_chr_update_read_handler;
chr->chr_close = pty_chr_close;
chr->chr_add_watch = pty_chr_add_watch;
chr->explicit_be_open = true;
s->fd = io_channel_from_fd(VAR_0);
s->timer_tag = 0;
return chr;
}
| [
"static CharDriverState *FUNC_0(const char *id,\nChardevReturn *ret)\n{",
"CharDriverState *chr;",
"PtyCharDriver *s;",
"int VAR_0, VAR_1;",
"char VAR_2[PATH_MAX];",
"VAR_0 = qemu_openpty_raw(&VAR_1, VAR_2);",
"if (VAR_0 < 0) {",
"return NULL;",
"}",
"close(VAR_1);",
"chr = g_malloc0(sizeof(CharDriverState));",
"chr->filename = g_strdup_printf(\"pty:%s\", VAR_2);",
"ret->pty = g_strdup(VAR_2);",
"ret->has_pty = true;",
"fprintf(stderr, \"char device redirected to %s (label %s)\\n\",\nVAR_2, id);",
"s = g_malloc0(sizeof(PtyCharDriver));",
"chr->opaque = s;",
"chr->chr_write = pty_chr_write;",
"chr->chr_update_read_handler = pty_chr_update_read_handler;",
"chr->chr_close = pty_chr_close;",
"chr->chr_add_watch = pty_chr_add_watch;",
"chr->explicit_be_open = true;",
"s->fd = io_channel_from_fd(VAR_0);",
"s->timer_tag = 0;",
"return chr;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
31
],
[
35
],
[
37
],
[
39
],
[
43,
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
71
],
[
73
]
] |
18,925 | static target_ulong h_set_dabr(PowerPCCPU *cpu, sPAPRMachineState *spapr,
target_ulong opcode, target_ulong *args)
{
/* FIXME: actually implement this */
return H_HARDWARE;
}
| false | qemu | af08a58f0ca338eafee855921859a8c1ace0175b | static target_ulong h_set_dabr(PowerPCCPU *cpu, sPAPRMachineState *spapr,
target_ulong opcode, target_ulong *args)
{
return H_HARDWARE;
}
| {
"code": [],
"line_no": []
} | static target_ulong FUNC_0(PowerPCCPU *cpu, sPAPRMachineState *spapr,
target_ulong opcode, target_ulong *args)
{
return H_HARDWARE;
}
| [
"static target_ulong FUNC_0(PowerPCCPU *cpu, sPAPRMachineState *spapr,\ntarget_ulong opcode, target_ulong *args)\n{",
"return H_HARDWARE;",
"}"
] | [
0,
0,
0
] | [
[
1,
3,
5
],
[
9
],
[
11
]
] |
18,926 | static uint32_t arm_timer_read(void *opaque, target_phys_addr_t offset)
{
arm_timer_state *s = (arm_timer_state *)opaque;
switch (offset >> 2) {
case 0: /* TimerLoad */
case 6: /* TimerBGLoad */
return s->limit;
case 1: /* TimerValue */
return ptimer_get_count(s->timer);
case 2: /* TimerControl */
return s->control;
case 4: /* TimerRIS */
return s->int_level;
case 5: /* TimerMIS */
if ((s->control & TIMER_CTRL_IE) == 0)
return 0;
return s->int_level;
default:
hw_error("%s: Bad offset %x\n", __func__, (int)offset);
return 0;
}
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static uint32_t arm_timer_read(void *opaque, target_phys_addr_t offset)
{
arm_timer_state *s = (arm_timer_state *)opaque;
switch (offset >> 2) {
case 0:
case 6:
return s->limit;
case 1:
return ptimer_get_count(s->timer);
case 2:
return s->control;
case 4:
return s->int_level;
case 5:
if ((s->control & TIMER_CTRL_IE) == 0)
return 0;
return s->int_level;
default:
hw_error("%s: Bad offset %x\n", __func__, (int)offset);
return 0;
}
}
| {
"code": [],
"line_no": []
} | static uint32_t FUNC_0(void *opaque, target_phys_addr_t offset)
{
arm_timer_state *s = (arm_timer_state *)opaque;
switch (offset >> 2) {
case 0:
case 6:
return s->limit;
case 1:
return ptimer_get_count(s->timer);
case 2:
return s->control;
case 4:
return s->int_level;
case 5:
if ((s->control & TIMER_CTRL_IE) == 0)
return 0;
return s->int_level;
default:
hw_error("%s: Bad offset %x\n", __func__, (int)offset);
return 0;
}
}
| [
"static uint32_t FUNC_0(void *opaque, target_phys_addr_t offset)\n{",
"arm_timer_state *s = (arm_timer_state *)opaque;",
"switch (offset >> 2) {",
"case 0:\ncase 6:\nreturn s->limit;",
"case 1:\nreturn ptimer_get_count(s->timer);",
"case 2:\nreturn s->control;",
"case 4:\nreturn s->int_level;",
"case 5:\nif ((s->control & TIMER_CTRL_IE) == 0)\nreturn 0;",
"return s->int_level;",
"default:\nhw_error(\"%s: Bad offset %x\\n\", __func__, (int)offset);",
"return 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
]
] |
18,927 | char *string_output_get_string(StringOutputVisitor *sov)
{
char *string = g_string_free(sov->string, false);
sov->string = NULL;
return string;
}
| false | qemu | 3b098d56979d2f7fd707c5be85555d114353a28d | char *string_output_get_string(StringOutputVisitor *sov)
{
char *string = g_string_free(sov->string, false);
sov->string = NULL;
return string;
}
| {
"code": [],
"line_no": []
} | char *FUNC_0(StringOutputVisitor *VAR_0)
{
char *VAR_1 = g_string_free(VAR_0->VAR_1, false);
VAR_0->VAR_1 = NULL;
return VAR_1;
}
| [
"char *FUNC_0(StringOutputVisitor *VAR_0)\n{",
"char *VAR_1 = g_string_free(VAR_0->VAR_1, false);",
"VAR_0->VAR_1 = NULL;",
"return VAR_1;",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
]
] |
18,928 | static void css_init(void)
{
QTAILQ_INIT(&channel_subsys.pending_crws);
channel_subsys.sei_pending = false;
channel_subsys.do_crw_mchk = true;
channel_subsys.crws_lost = false;
channel_subsys.chnmon_active = false;
QTAILQ_INIT(&channel_subsys.io_adapters);
QTAILQ_INIT(&channel_subsys.indicator_addresses);
}
| false | qemu | bc994b74ea38579e18f9d9144021c6f8de597a34 | static void css_init(void)
{
QTAILQ_INIT(&channel_subsys.pending_crws);
channel_subsys.sei_pending = false;
channel_subsys.do_crw_mchk = true;
channel_subsys.crws_lost = false;
channel_subsys.chnmon_active = false;
QTAILQ_INIT(&channel_subsys.io_adapters);
QTAILQ_INIT(&channel_subsys.indicator_addresses);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void)
{
QTAILQ_INIT(&channel_subsys.pending_crws);
channel_subsys.sei_pending = false;
channel_subsys.do_crw_mchk = true;
channel_subsys.crws_lost = false;
channel_subsys.chnmon_active = false;
QTAILQ_INIT(&channel_subsys.io_adapters);
QTAILQ_INIT(&channel_subsys.indicator_addresses);
}
| [
"static void FUNC_0(void)\n{",
"QTAILQ_INIT(&channel_subsys.pending_crws);",
"channel_subsys.sei_pending = false;",
"channel_subsys.do_crw_mchk = true;",
"channel_subsys.crws_lost = false;",
"channel_subsys.chnmon_active = false;",
"QTAILQ_INIT(&channel_subsys.io_adapters);",
"QTAILQ_INIT(&channel_subsys.indicator_addresses);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
]
] |
18,929 | static void test_validate_struct(TestInputVisitorData *data,
const void *unused)
{
TestStruct *p = NULL;
Visitor *v;
v = validate_test_init(data, "{ 'integer': -42, 'boolean': true, 'string': 'foo' }");
visit_type_TestStruct(v, NULL, &p, &error_abort);
g_free(p->string);
g_free(p);
}
| false | qemu | b3db211f3c80bb996a704d665fe275619f728bd4 | static void test_validate_struct(TestInputVisitorData *data,
const void *unused)
{
TestStruct *p = NULL;
Visitor *v;
v = validate_test_init(data, "{ 'integer': -42, 'boolean': true, 'string': 'foo' }");
visit_type_TestStruct(v, NULL, &p, &error_abort);
g_free(p->string);
g_free(p);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(TestInputVisitorData *VAR_0,
const void *VAR_1)
{
TestStruct *p = NULL;
Visitor *v;
v = validate_test_init(VAR_0, "{ 'integer': -42, 'boolean': true, 'string': 'foo' }");
visit_type_TestStruct(v, NULL, &p, &error_abort);
g_free(p->string);
g_free(p);
}
| [
"static void FUNC_0(TestInputVisitorData *VAR_0,\nconst void *VAR_1)\n{",
"TestStruct *p = NULL;",
"Visitor *v;",
"v = validate_test_init(VAR_0, \"{ 'integer': -42, 'boolean': true, 'string': 'foo' }\");",
"visit_type_TestStruct(v, NULL, &p, &error_abort);",
"g_free(p->string);",
"g_free(p);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
]
] |
18,932 | static uint32_t ecc_mem_readw(void *opaque, target_phys_addr_t addr)
{
printf("ECC: Unsupported read 0x" TARGET_FMT_plx " 0000\n", addr);
return 0;
}
| false | qemu | 7c560456707bfe53eb1728fcde759be7d9418b62 | static uint32_t ecc_mem_readw(void *opaque, target_phys_addr_t addr)
{
printf("ECC: Unsupported read 0x" TARGET_FMT_plx " 0000\n", addr);
return 0;
}
| {
"code": [],
"line_no": []
} | static uint32_t FUNC_0(void *opaque, target_phys_addr_t addr)
{
printf("ECC: Unsupported read 0x" TARGET_FMT_plx " 0000\n", addr);
return 0;
}
| [
"static uint32_t FUNC_0(void *opaque, target_phys_addr_t addr)\n{",
"printf(\"ECC: Unsupported read 0x\" TARGET_FMT_plx \" 0000\\n\", addr);",
"return 0;",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
18,933 | static av_cold int libssh_authentication(LIBSSHContext *libssh, const char *user, const char *password)
{
int authorized = 0;
int auth_methods;
if (user)
ssh_options_set(libssh->session, SSH_OPTIONS_USER, user);
if (ssh_userauth_none(libssh->session, NULL) == SSH_AUTH_SUCCESS)
return 0;
auth_methods = ssh_userauth_list(libssh->session, NULL);
if (auth_methods & SSH_AUTH_METHOD_PUBLICKEY) {
if (libssh->priv_key) {
ssh_string pub_key;
ssh_private_key priv_key;
int type;
if (!ssh_try_publickey_from_file(libssh->session, libssh->priv_key, &pub_key, &type)) {
priv_key = privatekey_from_file(libssh->session, libssh->priv_key, type, password);
if (ssh_userauth_pubkey(libssh->session, NULL, pub_key, priv_key) == SSH_AUTH_SUCCESS) {
av_log(libssh, AV_LOG_DEBUG, "Authentication successful with selected private key.\n");
authorized = 1;
}
} else {
av_log(libssh, AV_LOG_DEBUG, "Invalid key is provided.\n");
return AVERROR(EACCES);
}
} else if (ssh_userauth_autopubkey(libssh->session, password) == SSH_AUTH_SUCCESS) {
av_log(libssh, AV_LOG_DEBUG, "Authentication successful with auto selected key.\n");
authorized = 1;
}
}
if (!authorized && (auth_methods & SSH_AUTH_METHOD_PASSWORD)) {
if (ssh_userauth_password(libssh->session, NULL, password) == SSH_AUTH_SUCCESS) {
av_log(libssh, AV_LOG_DEBUG, "Authentication successful with password.\n");
authorized = 1;
}
}
if (!authorized) {
av_log(libssh, AV_LOG_ERROR, "Authentication failed.\n");
return AVERROR(EACCES);
}
return 0;
}
| false | FFmpeg | 8ddb6820bd52df6ed616abc3d8be200b126aa8c1 | static av_cold int libssh_authentication(LIBSSHContext *libssh, const char *user, const char *password)
{
int authorized = 0;
int auth_methods;
if (user)
ssh_options_set(libssh->session, SSH_OPTIONS_USER, user);
if (ssh_userauth_none(libssh->session, NULL) == SSH_AUTH_SUCCESS)
return 0;
auth_methods = ssh_userauth_list(libssh->session, NULL);
if (auth_methods & SSH_AUTH_METHOD_PUBLICKEY) {
if (libssh->priv_key) {
ssh_string pub_key;
ssh_private_key priv_key;
int type;
if (!ssh_try_publickey_from_file(libssh->session, libssh->priv_key, &pub_key, &type)) {
priv_key = privatekey_from_file(libssh->session, libssh->priv_key, type, password);
if (ssh_userauth_pubkey(libssh->session, NULL, pub_key, priv_key) == SSH_AUTH_SUCCESS) {
av_log(libssh, AV_LOG_DEBUG, "Authentication successful with selected private key.\n");
authorized = 1;
}
} else {
av_log(libssh, AV_LOG_DEBUG, "Invalid key is provided.\n");
return AVERROR(EACCES);
}
} else if (ssh_userauth_autopubkey(libssh->session, password) == SSH_AUTH_SUCCESS) {
av_log(libssh, AV_LOG_DEBUG, "Authentication successful with auto selected key.\n");
authorized = 1;
}
}
if (!authorized && (auth_methods & SSH_AUTH_METHOD_PASSWORD)) {
if (ssh_userauth_password(libssh->session, NULL, password) == SSH_AUTH_SUCCESS) {
av_log(libssh, AV_LOG_DEBUG, "Authentication successful with password.\n");
authorized = 1;
}
}
if (!authorized) {
av_log(libssh, AV_LOG_ERROR, "Authentication failed.\n");
return AVERROR(EACCES);
}
return 0;
}
| {
"code": [],
"line_no": []
} | static av_cold int FUNC_0(LIBSSHContext *libssh, const char *user, const char *password)
{
int VAR_0 = 0;
int VAR_1;
if (user)
ssh_options_set(libssh->session, SSH_OPTIONS_USER, user);
if (ssh_userauth_none(libssh->session, NULL) == SSH_AUTH_SUCCESS)
return 0;
VAR_1 = ssh_userauth_list(libssh->session, NULL);
if (VAR_1 & SSH_AUTH_METHOD_PUBLICKEY) {
if (libssh->priv_key) {
ssh_string pub_key;
ssh_private_key priv_key;
int VAR_2;
if (!ssh_try_publickey_from_file(libssh->session, libssh->priv_key, &pub_key, &VAR_2)) {
priv_key = privatekey_from_file(libssh->session, libssh->priv_key, VAR_2, password);
if (ssh_userauth_pubkey(libssh->session, NULL, pub_key, priv_key) == SSH_AUTH_SUCCESS) {
av_log(libssh, AV_LOG_DEBUG, "Authentication successful with selected private key.\n");
VAR_0 = 1;
}
} else {
av_log(libssh, AV_LOG_DEBUG, "Invalid key is provided.\n");
return AVERROR(EACCES);
}
} else if (ssh_userauth_autopubkey(libssh->session, password) == SSH_AUTH_SUCCESS) {
av_log(libssh, AV_LOG_DEBUG, "Authentication successful with auto selected key.\n");
VAR_0 = 1;
}
}
if (!VAR_0 && (VAR_1 & SSH_AUTH_METHOD_PASSWORD)) {
if (ssh_userauth_password(libssh->session, NULL, password) == SSH_AUTH_SUCCESS) {
av_log(libssh, AV_LOG_DEBUG, "Authentication successful with password.\n");
VAR_0 = 1;
}
}
if (!VAR_0) {
av_log(libssh, AV_LOG_ERROR, "Authentication failed.\n");
return AVERROR(EACCES);
}
return 0;
}
| [
"static av_cold int FUNC_0(LIBSSHContext *libssh, const char *user, const char *password)\n{",
"int VAR_0 = 0;",
"int VAR_1;",
"if (user)\nssh_options_set(libssh->session, SSH_OPTIONS_USER, user);",
"if (ssh_userauth_none(libssh->session, NULL) == SSH_AUTH_SUCCESS)\nreturn 0;",
"VAR_1 = ssh_userauth_list(libssh->session, NULL);",
"if (VAR_1 & SSH_AUTH_METHOD_PUBLICKEY) {",
"if (libssh->priv_key) {",
"ssh_string pub_key;",
"ssh_private_key priv_key;",
"int VAR_2;",
"if (!ssh_try_publickey_from_file(libssh->session, libssh->priv_key, &pub_key, &VAR_2)) {",
"priv_key = privatekey_from_file(libssh->session, libssh->priv_key, VAR_2, password);",
"if (ssh_userauth_pubkey(libssh->session, NULL, pub_key, priv_key) == SSH_AUTH_SUCCESS) {",
"av_log(libssh, AV_LOG_DEBUG, \"Authentication successful with selected private key.\\n\");",
"VAR_0 = 1;",
"}",
"} else {",
"av_log(libssh, AV_LOG_DEBUG, \"Invalid key is provided.\\n\");",
"return AVERROR(EACCES);",
"}",
"} else if (ssh_userauth_autopubkey(libssh->session, password) == SSH_AUTH_SUCCESS) {",
"av_log(libssh, AV_LOG_DEBUG, \"Authentication successful with auto selected key.\\n\");",
"VAR_0 = 1;",
"}",
"}",
"if (!VAR_0 && (VAR_1 & SSH_AUTH_METHOD_PASSWORD)) {",
"if (ssh_userauth_password(libssh->session, NULL, password) == SSH_AUTH_SUCCESS) {",
"av_log(libssh, AV_LOG_DEBUG, \"Authentication successful with password.\\n\");",
"VAR_0 = 1;",
"}",
"}",
"if (!VAR_0) {",
"av_log(libssh, AV_LOG_ERROR, \"Authentication failed.\\n\");",
"return AVERROR(EACCES);",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
17,
19
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93
],
[
95
]
] |
18,934 | int gif_write(ByteIOContext *pb, AVImageInfo *info)
{
gif_image_write_header(pb, info->width, info->height,
(uint32_t *)info->pict.data[1]);
gif_image_write_image(pb, 0, 0, info->width, info->height,
info->pict.data[0], info->pict.linesize[0],
PIX_FMT_PAL8);
put_byte(pb, 0x3b);
put_flush_packet(pb);
return 0;
}
| false | FFmpeg | 8108551a5c4c4c9696582c73d000f94b12cd95a5 | int gif_write(ByteIOContext *pb, AVImageInfo *info)
{
gif_image_write_header(pb, info->width, info->height,
(uint32_t *)info->pict.data[1]);
gif_image_write_image(pb, 0, 0, info->width, info->height,
info->pict.data[0], info->pict.linesize[0],
PIX_FMT_PAL8);
put_byte(pb, 0x3b);
put_flush_packet(pb);
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(ByteIOContext *VAR_0, AVImageInfo *VAR_1)
{
gif_image_write_header(VAR_0, VAR_1->width, VAR_1->height,
(uint32_t *)VAR_1->pict.data[1]);
gif_image_write_image(VAR_0, 0, 0, VAR_1->width, VAR_1->height,
VAR_1->pict.data[0], VAR_1->pict.linesize[0],
PIX_FMT_PAL8);
put_byte(VAR_0, 0x3b);
put_flush_packet(VAR_0);
return 0;
}
| [
"int FUNC_0(ByteIOContext *VAR_0, AVImageInfo *VAR_1)\n{",
"gif_image_write_header(VAR_0, VAR_1->width, VAR_1->height,\n(uint32_t *)VAR_1->pict.data[1]);",
"gif_image_write_image(VAR_0, 0, 0, VAR_1->width, VAR_1->height,\nVAR_1->pict.data[0], VAR_1->pict.linesize[0],\nPIX_FMT_PAL8);",
"put_byte(VAR_0, 0x3b);",
"put_flush_packet(VAR_0);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
9,
11,
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
18,935 | void monitor_init(CharDriverState *chr, int flags)
{
static int is_first_init = 1;
Monitor *mon;
if (is_first_init) {
key_timer = qemu_new_timer(vm_clock, release_keys, NULL);
is_first_init = 0;
}
mon = qemu_mallocz(sizeof(*mon));
mon->chr = chr;
mon->flags = flags;
if (flags & MONITOR_USE_READLINE) {
mon->rs = readline_init(mon, monitor_find_completion);
monitor_read_command(mon, 0);
}
qemu_chr_add_handlers(chr, monitor_can_read, monitor_read, monitor_event,
mon);
LIST_INSERT_HEAD(&mon_list, mon, entry);
if (!cur_mon || (flags & MONITOR_IS_DEFAULT))
cur_mon = mon;
}
| false | qemu | 72cf2d4f0e181d0d3a3122e04129c58a95da713e | void monitor_init(CharDriverState *chr, int flags)
{
static int is_first_init = 1;
Monitor *mon;
if (is_first_init) {
key_timer = qemu_new_timer(vm_clock, release_keys, NULL);
is_first_init = 0;
}
mon = qemu_mallocz(sizeof(*mon));
mon->chr = chr;
mon->flags = flags;
if (flags & MONITOR_USE_READLINE) {
mon->rs = readline_init(mon, monitor_find_completion);
monitor_read_command(mon, 0);
}
qemu_chr_add_handlers(chr, monitor_can_read, monitor_read, monitor_event,
mon);
LIST_INSERT_HEAD(&mon_list, mon, entry);
if (!cur_mon || (flags & MONITOR_IS_DEFAULT))
cur_mon = mon;
}
| {
"code": [],
"line_no": []
} | void FUNC_0(CharDriverState *VAR_0, int VAR_1)
{
static int VAR_2 = 1;
Monitor *mon;
if (VAR_2) {
key_timer = qemu_new_timer(vm_clock, release_keys, NULL);
VAR_2 = 0;
}
mon = qemu_mallocz(sizeof(*mon));
mon->VAR_0 = VAR_0;
mon->VAR_1 = VAR_1;
if (VAR_1 & MONITOR_USE_READLINE) {
mon->rs = readline_init(mon, monitor_find_completion);
monitor_read_command(mon, 0);
}
qemu_chr_add_handlers(VAR_0, monitor_can_read, monitor_read, monitor_event,
mon);
LIST_INSERT_HEAD(&mon_list, mon, entry);
if (!cur_mon || (VAR_1 & MONITOR_IS_DEFAULT))
cur_mon = mon;
}
| [
"void FUNC_0(CharDriverState *VAR_0, int VAR_1)\n{",
"static int VAR_2 = 1;",
"Monitor *mon;",
"if (VAR_2) {",
"key_timer = qemu_new_timer(vm_clock, release_keys, NULL);",
"VAR_2 = 0;",
"}",
"mon = qemu_mallocz(sizeof(*mon));",
"mon->VAR_0 = VAR_0;",
"mon->VAR_1 = VAR_1;",
"if (VAR_1 & MONITOR_USE_READLINE) {",
"mon->rs = readline_init(mon, monitor_find_completion);",
"monitor_read_command(mon, 0);",
"}",
"qemu_chr_add_handlers(VAR_0, monitor_can_read, monitor_read, monitor_event,\nmon);",
"LIST_INSERT_HEAD(&mon_list, mon, entry);",
"if (!cur_mon || (VAR_1 & MONITOR_IS_DEFAULT))\ncur_mon = mon;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39,
41
],
[
45
],
[
47,
49
],
[
51
]
] |
18,936 | static void dsound_write_sample (HWVoiceOut *hw, uint8_t *dst, int dst_len)
{
int src_len1 = dst_len;
int src_len2 = 0;
int pos = hw->rpos + dst_len;
st_sample_t *src1 = hw->mix_buf + hw->rpos;
st_sample_t *src2 = NULL;
if (pos > hw->samples) {
src_len1 = hw->samples - hw->rpos;
src2 = hw->mix_buf;
src_len2 = dst_len - src_len1;
pos = src_len2;
}
if (src_len1) {
hw->clip (dst, src1, src_len1);
}
if (src_len2) {
dst = advance (dst, src_len1 << hw->info.shift);
hw->clip (dst, src2, src_len2);
}
hw->rpos = pos % hw->samples;
}
| false | qemu | 1ea879e5580f63414693655fcf0328559cdce138 | static void dsound_write_sample (HWVoiceOut *hw, uint8_t *dst, int dst_len)
{
int src_len1 = dst_len;
int src_len2 = 0;
int pos = hw->rpos + dst_len;
st_sample_t *src1 = hw->mix_buf + hw->rpos;
st_sample_t *src2 = NULL;
if (pos > hw->samples) {
src_len1 = hw->samples - hw->rpos;
src2 = hw->mix_buf;
src_len2 = dst_len - src_len1;
pos = src_len2;
}
if (src_len1) {
hw->clip (dst, src1, src_len1);
}
if (src_len2) {
dst = advance (dst, src_len1 << hw->info.shift);
hw->clip (dst, src2, src_len2);
}
hw->rpos = pos % hw->samples;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0 (HWVoiceOut *VAR_0, uint8_t *VAR_1, int VAR_2)
{
int VAR_3 = VAR_2;
int VAR_4 = 0;
int VAR_5 = VAR_0->rpos + VAR_2;
st_sample_t *src1 = VAR_0->mix_buf + VAR_0->rpos;
st_sample_t *src2 = NULL;
if (VAR_5 > VAR_0->samples) {
VAR_3 = VAR_0->samples - VAR_0->rpos;
src2 = VAR_0->mix_buf;
VAR_4 = VAR_2 - VAR_3;
VAR_5 = VAR_4;
}
if (VAR_3) {
VAR_0->clip (VAR_1, src1, VAR_3);
}
if (VAR_4) {
VAR_1 = advance (VAR_1, VAR_3 << VAR_0->info.shift);
VAR_0->clip (VAR_1, src2, VAR_4);
}
VAR_0->rpos = VAR_5 % VAR_0->samples;
}
| [
"static void FUNC_0 (HWVoiceOut *VAR_0, uint8_t *VAR_1, int VAR_2)\n{",
"int VAR_3 = VAR_2;",
"int VAR_4 = 0;",
"int VAR_5 = VAR_0->rpos + VAR_2;",
"st_sample_t *src1 = VAR_0->mix_buf + VAR_0->rpos;",
"st_sample_t *src2 = NULL;",
"if (VAR_5 > VAR_0->samples) {",
"VAR_3 = VAR_0->samples - VAR_0->rpos;",
"src2 = VAR_0->mix_buf;",
"VAR_4 = VAR_2 - VAR_3;",
"VAR_5 = VAR_4;",
"}",
"if (VAR_3) {",
"VAR_0->clip (VAR_1, src1, VAR_3);",
"}",
"if (VAR_4) {",
"VAR_1 = advance (VAR_1, VAR_3 << VAR_0->info.shift);",
"VAR_0->clip (VAR_1, src2, VAR_4);",
"}",
"VAR_0->rpos = VAR_5 % VAR_0->samples;",
"}"
] | [
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
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
]
] |
18,937 | static void n8x0_init(QEMUMachineInitArgs *args,
struct arm_boot_info *binfo, int model)
{
MemoryRegion *sysmem = get_system_memory();
struct n800_s *s = (struct n800_s *) g_malloc0(sizeof(*s));
int sdram_size = binfo->ram_size;
s->mpu = omap2420_mpu_init(sysmem, sdram_size, args->cpu_model);
/* Setup peripherals
*
* Believed external peripherals layout in the N810:
* (spi bus 1)
* tsc2005
* lcd_mipid
* (spi bus 2)
* Conexant cx3110x (WLAN)
* optional: pc2400m (WiMAX)
* (i2c bus 0)
* TLV320AIC33 (audio codec)
* TCM825x (camera by Toshiba)
* lp5521 (clever LEDs)
* tsl2563 (light sensor, hwmon, model 7, rev. 0)
* lm8323 (keypad, manf 00, rev 04)
* (i2c bus 1)
* tmp105 (temperature sensor, hwmon)
* menelaus (pm)
* (somewhere on i2c - maybe N800-only)
* tea5761 (FM tuner)
* (serial 0)
* GPS
* (some serial port)
* csr41814 (Bluetooth)
*/
n8x0_gpio_setup(s);
n8x0_nand_setup(s);
n8x0_i2c_setup(s);
if (model == 800)
n800_tsc_kbd_setup(s);
else if (model == 810) {
n810_tsc_setup(s);
n810_kbd_setup(s);
}
n8x0_spi_setup(s);
n8x0_dss_setup(s);
n8x0_cbus_setup(s);
n8x0_uart_setup(s);
if (usb_enabled(false)) {
n8x0_usb_setup(s);
}
if (args->kernel_filename) {
/* Or at the linux loader. */
binfo->kernel_filename = args->kernel_filename;
binfo->kernel_cmdline = args->kernel_cmdline;
binfo->initrd_filename = args->initrd_filename;
arm_load_kernel(s->mpu->cpu, binfo);
qemu_register_reset(n8x0_boot_init, s);
}
if (option_rom[0].name &&
(args->boot_device[0] == 'n' || !args->kernel_filename)) {
uint8_t nolo_tags[0x10000];
/* No, wait, better start at the ROM. */
s->mpu->cpu->env.regs[15] = OMAP2_Q2_BASE + 0x400000;
/* This is intended for loading the `secondary.bin' program from
* Nokia images (the NOLO bootloader). The entry point seems
* to be at OMAP2_Q2_BASE + 0x400000.
*
* The `2nd.bin' files contain some kind of earlier boot code and
* for them the entry point needs to be set to OMAP2_SRAM_BASE.
*
* The code above is for loading the `zImage' file from Nokia
* images. */
load_image_targphys(option_rom[0].name,
OMAP2_Q2_BASE + 0x400000,
sdram_size - 0x400000);
n800_setup_nolo_tags(nolo_tags);
cpu_physical_memory_write(OMAP2_SRAM_BASE, nolo_tags, 0x10000);
}
}
| false | qemu | c16547326988cc321c9bff43ed91cbe753e52892 | static void n8x0_init(QEMUMachineInitArgs *args,
struct arm_boot_info *binfo, int model)
{
MemoryRegion *sysmem = get_system_memory();
struct n800_s *s = (struct n800_s *) g_malloc0(sizeof(*s));
int sdram_size = binfo->ram_size;
s->mpu = omap2420_mpu_init(sysmem, sdram_size, args->cpu_model);
n8x0_gpio_setup(s);
n8x0_nand_setup(s);
n8x0_i2c_setup(s);
if (model == 800)
n800_tsc_kbd_setup(s);
else if (model == 810) {
n810_tsc_setup(s);
n810_kbd_setup(s);
}
n8x0_spi_setup(s);
n8x0_dss_setup(s);
n8x0_cbus_setup(s);
n8x0_uart_setup(s);
if (usb_enabled(false)) {
n8x0_usb_setup(s);
}
if (args->kernel_filename) {
binfo->kernel_filename = args->kernel_filename;
binfo->kernel_cmdline = args->kernel_cmdline;
binfo->initrd_filename = args->initrd_filename;
arm_load_kernel(s->mpu->cpu, binfo);
qemu_register_reset(n8x0_boot_init, s);
}
if (option_rom[0].name &&
(args->boot_device[0] == 'n' || !args->kernel_filename)) {
uint8_t nolo_tags[0x10000];
s->mpu->cpu->env.regs[15] = OMAP2_Q2_BASE + 0x400000;
load_image_targphys(option_rom[0].name,
OMAP2_Q2_BASE + 0x400000,
sdram_size - 0x400000);
n800_setup_nolo_tags(nolo_tags);
cpu_physical_memory_write(OMAP2_SRAM_BASE, nolo_tags, 0x10000);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(QEMUMachineInitArgs *VAR_0,
struct arm_boot_info *VAR_1, int VAR_2)
{
MemoryRegion *sysmem = get_system_memory();
struct n800_s *VAR_3 = (struct n800_s *) g_malloc0(sizeof(*VAR_3));
int VAR_4 = VAR_1->ram_size;
VAR_3->mpu = omap2420_mpu_init(sysmem, VAR_4, VAR_0->cpu_model);
n8x0_gpio_setup(VAR_3);
n8x0_nand_setup(VAR_3);
n8x0_i2c_setup(VAR_3);
if (VAR_2 == 800)
n800_tsc_kbd_setup(VAR_3);
else if (VAR_2 == 810) {
n810_tsc_setup(VAR_3);
n810_kbd_setup(VAR_3);
}
n8x0_spi_setup(VAR_3);
n8x0_dss_setup(VAR_3);
n8x0_cbus_setup(VAR_3);
n8x0_uart_setup(VAR_3);
if (usb_enabled(false)) {
n8x0_usb_setup(VAR_3);
}
if (VAR_0->kernel_filename) {
VAR_1->kernel_filename = VAR_0->kernel_filename;
VAR_1->kernel_cmdline = VAR_0->kernel_cmdline;
VAR_1->initrd_filename = VAR_0->initrd_filename;
arm_load_kernel(VAR_3->mpu->cpu, VAR_1);
qemu_register_reset(n8x0_boot_init, VAR_3);
}
if (option_rom[0].name &&
(VAR_0->boot_device[0] == 'n' || !VAR_0->kernel_filename)) {
uint8_t nolo_tags[0x10000];
VAR_3->mpu->cpu->env.regs[15] = OMAP2_Q2_BASE + 0x400000;
load_image_targphys(option_rom[0].name,
OMAP2_Q2_BASE + 0x400000,
VAR_4 - 0x400000);
n800_setup_nolo_tags(nolo_tags);
cpu_physical_memory_write(OMAP2_SRAM_BASE, nolo_tags, 0x10000);
}
}
| [
"static void FUNC_0(QEMUMachineInitArgs *VAR_0,\nstruct arm_boot_info *VAR_1, int VAR_2)\n{",
"MemoryRegion *sysmem = get_system_memory();",
"struct n800_s *VAR_3 = (struct n800_s *) g_malloc0(sizeof(*VAR_3));",
"int VAR_4 = VAR_1->ram_size;",
"VAR_3->mpu = omap2420_mpu_init(sysmem, VAR_4, VAR_0->cpu_model);",
"n8x0_gpio_setup(VAR_3);",
"n8x0_nand_setup(VAR_3);",
"n8x0_i2c_setup(VAR_3);",
"if (VAR_2 == 800)\nn800_tsc_kbd_setup(VAR_3);",
"else if (VAR_2 == 810) {",
"n810_tsc_setup(VAR_3);",
"n810_kbd_setup(VAR_3);",
"}",
"n8x0_spi_setup(VAR_3);",
"n8x0_dss_setup(VAR_3);",
"n8x0_cbus_setup(VAR_3);",
"n8x0_uart_setup(VAR_3);",
"if (usb_enabled(false)) {",
"n8x0_usb_setup(VAR_3);",
"}",
"if (VAR_0->kernel_filename) {",
"VAR_1->kernel_filename = VAR_0->kernel_filename;",
"VAR_1->kernel_cmdline = VAR_0->kernel_cmdline;",
"VAR_1->initrd_filename = VAR_0->initrd_filename;",
"arm_load_kernel(VAR_3->mpu->cpu, VAR_1);",
"qemu_register_reset(n8x0_boot_init, VAR_3);",
"}",
"if (option_rom[0].name &&\n(VAR_0->boot_device[0] == 'n' || !VAR_0->kernel_filename)) {",
"uint8_t nolo_tags[0x10000];",
"VAR_3->mpu->cpu->env.regs[15] = OMAP2_Q2_BASE + 0x400000;",
"load_image_targphys(option_rom[0].name,\nOMAP2_Q2_BASE + 0x400000,\nVAR_4 - 0x400000);",
"n800_setup_nolo_tags(nolo_tags);",
"cpu_physical_memory_write(OMAP2_SRAM_BASE, nolo_tags, 0x10000);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
69
],
[
71
],
[
73
],
[
75,
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
103
],
[
107
],
[
109
],
[
111
],
[
113
],
[
117
],
[
119
],
[
123,
125
],
[
127
],
[
131
],
[
153,
155,
157
],
[
161
],
[
163
],
[
165
],
[
167
]
] |
18,938 | build_fadt(GArray *table_data, GArray *linker, unsigned dsdt)
{
AcpiFadtDescriptorRev5_1 *fadt = acpi_data_push(table_data, sizeof(*fadt));
/* Hardware Reduced = 1 and use PSCI 0.2+ and with HVC */
fadt->flags = cpu_to_le32(1 << ACPI_FADT_F_HW_REDUCED_ACPI);
fadt->arm_boot_flags = cpu_to_le16((1 << ACPI_FADT_ARM_USE_PSCI_G_0_2) |
(1 << ACPI_FADT_ARM_PSCI_USE_HVC));
/* ACPI v5.1 (fadt->revision.fadt->minor_revision) */
fadt->minor_revision = 0x1;
fadt->dsdt = cpu_to_le32(dsdt);
/* DSDT address to be filled by Guest linker */
bios_linker_loader_add_pointer(linker, ACPI_BUILD_TABLE_FILE,
ACPI_BUILD_TABLE_FILE,
table_data, &fadt->dsdt,
sizeof fadt->dsdt);
build_header(linker, table_data,
(void *)fadt, "FACP", sizeof(*fadt), 5, NULL, NULL);
}
| false | qemu | 0e9b9edae7bebfd31fdbead4ccbbce03876a7edd | build_fadt(GArray *table_data, GArray *linker, unsigned dsdt)
{
AcpiFadtDescriptorRev5_1 *fadt = acpi_data_push(table_data, sizeof(*fadt));
fadt->flags = cpu_to_le32(1 << ACPI_FADT_F_HW_REDUCED_ACPI);
fadt->arm_boot_flags = cpu_to_le16((1 << ACPI_FADT_ARM_USE_PSCI_G_0_2) |
(1 << ACPI_FADT_ARM_PSCI_USE_HVC));
fadt->minor_revision = 0x1;
fadt->dsdt = cpu_to_le32(dsdt);
bios_linker_loader_add_pointer(linker, ACPI_BUILD_TABLE_FILE,
ACPI_BUILD_TABLE_FILE,
table_data, &fadt->dsdt,
sizeof fadt->dsdt);
build_header(linker, table_data,
(void *)fadt, "FACP", sizeof(*fadt), 5, NULL, NULL);
}
| {
"code": [],
"line_no": []
} | FUNC_0(GArray *VAR_0, GArray *VAR_1, unsigned VAR_2)
{
AcpiFadtDescriptorRev5_1 *fadt = acpi_data_push(VAR_0, sizeof(*fadt));
fadt->flags = cpu_to_le32(1 << ACPI_FADT_F_HW_REDUCED_ACPI);
fadt->arm_boot_flags = cpu_to_le16((1 << ACPI_FADT_ARM_USE_PSCI_G_0_2) |
(1 << ACPI_FADT_ARM_PSCI_USE_HVC));
fadt->minor_revision = 0x1;
fadt->VAR_2 = cpu_to_le32(VAR_2);
bios_linker_loader_add_pointer(VAR_1, ACPI_BUILD_TABLE_FILE,
ACPI_BUILD_TABLE_FILE,
VAR_0, &fadt->VAR_2,
sizeof fadt->VAR_2);
build_header(VAR_1, VAR_0,
(void *)fadt, "FACP", sizeof(*fadt), 5, NULL, NULL);
}
| [
"FUNC_0(GArray *VAR_0, GArray *VAR_1, unsigned VAR_2)\n{",
"AcpiFadtDescriptorRev5_1 *fadt = acpi_data_push(VAR_0, sizeof(*fadt));",
"fadt->flags = cpu_to_le32(1 << ACPI_FADT_F_HW_REDUCED_ACPI);",
"fadt->arm_boot_flags = cpu_to_le16((1 << ACPI_FADT_ARM_USE_PSCI_G_0_2) |\n(1 << ACPI_FADT_ARM_PSCI_USE_HVC));",
"fadt->minor_revision = 0x1;",
"fadt->VAR_2 = cpu_to_le32(VAR_2);",
"bios_linker_loader_add_pointer(VAR_1, ACPI_BUILD_TABLE_FILE,\nACPI_BUILD_TABLE_FILE,\nVAR_0, &fadt->VAR_2,\nsizeof fadt->VAR_2);",
"build_header(VAR_1, VAR_0,\n(void *)fadt, \"FACP\", sizeof(*fadt), 5, NULL, NULL);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
11
],
[
13,
15
],
[
21
],
[
25
],
[
29,
31,
33,
35
],
[
39,
41
],
[
43
]
] |
18,939 | static int config_input_overlay(AVFilterLink *inlink)
{
AVFilterContext *ctx = inlink->dst;
OverlayContext *over = inlink->dst->priv;
char *expr;
double var_values[VAR_VARS_NB], res;
int ret;
const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(inlink->format);
av_image_fill_max_pixsteps(over->overlay_pix_step, NULL, pix_desc);
/* Finish the configuration by evaluating the expressions
now when both inputs are configured. */
var_values[VAR_MAIN_W ] = var_values[VAR_MW] = ctx->inputs[MAIN ]->w;
var_values[VAR_MAIN_H ] = var_values[VAR_MH] = ctx->inputs[MAIN ]->h;
var_values[VAR_OVERLAY_W] = var_values[VAR_OW] = ctx->inputs[OVERLAY]->w;
var_values[VAR_OVERLAY_H] = var_values[VAR_OH] = ctx->inputs[OVERLAY]->h;
if ((ret = av_expr_parse_and_eval(&res, (expr = over->x_expr), var_names, var_values,
NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
goto fail;
over->x = res;
if ((ret = av_expr_parse_and_eval(&res, (expr = over->y_expr), var_names, var_values,
NULL, NULL, NULL, NULL, NULL, 0, ctx)))
goto fail;
over->y = res;
/* x may depend on y */
if ((ret = av_expr_parse_and_eval(&res, (expr = over->x_expr), var_names, var_values,
NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
goto fail;
over->x = res;
over->overlay_is_packed_rgb =
ff_fill_rgba_map(over->overlay_rgba_map, inlink->format) >= 0;
over->overlay_has_alpha = ff_fmt_is_in(inlink->format, alpha_pix_fmts);
av_log(ctx, AV_LOG_VERBOSE,
"main w:%d h:%d fmt:%s overlay x:%d y:%d w:%d h:%d fmt:%s\n",
ctx->inputs[MAIN]->w, ctx->inputs[MAIN]->h,
av_get_pix_fmt_name(ctx->inputs[MAIN]->format),
over->x, over->y,
ctx->inputs[OVERLAY]->w, ctx->inputs[OVERLAY]->h,
av_get_pix_fmt_name(ctx->inputs[OVERLAY]->format));
if (over->x < 0 || over->y < 0 ||
over->x + var_values[VAR_OVERLAY_W] > var_values[VAR_MAIN_W] ||
over->y + var_values[VAR_OVERLAY_H] > var_values[VAR_MAIN_H]) {
av_log(ctx, AV_LOG_ERROR,
"Overlay area (%d,%d)<->(%d,%d) not within the main area (0,0)<->(%d,%d) or zero-sized\n",
over->x, over->y,
(int)(over->x + var_values[VAR_OVERLAY_W]),
(int)(over->y + var_values[VAR_OVERLAY_H]),
(int)var_values[VAR_MAIN_W], (int)var_values[VAR_MAIN_H]);
return AVERROR(EINVAL);
}
return 0;
fail:
av_log(NULL, AV_LOG_ERROR,
"Error when evaluating the expression '%s'\n", expr);
return ret;
}
| false | FFmpeg | f164228fd793766187ed3e68cb6d6e2fe3e77c04 | static int config_input_overlay(AVFilterLink *inlink)
{
AVFilterContext *ctx = inlink->dst;
OverlayContext *over = inlink->dst->priv;
char *expr;
double var_values[VAR_VARS_NB], res;
int ret;
const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(inlink->format);
av_image_fill_max_pixsteps(over->overlay_pix_step, NULL, pix_desc);
var_values[VAR_MAIN_W ] = var_values[VAR_MW] = ctx->inputs[MAIN ]->w;
var_values[VAR_MAIN_H ] = var_values[VAR_MH] = ctx->inputs[MAIN ]->h;
var_values[VAR_OVERLAY_W] = var_values[VAR_OW] = ctx->inputs[OVERLAY]->w;
var_values[VAR_OVERLAY_H] = var_values[VAR_OH] = ctx->inputs[OVERLAY]->h;
if ((ret = av_expr_parse_and_eval(&res, (expr = over->x_expr), var_names, var_values,
NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
goto fail;
over->x = res;
if ((ret = av_expr_parse_and_eval(&res, (expr = over->y_expr), var_names, var_values,
NULL, NULL, NULL, NULL, NULL, 0, ctx)))
goto fail;
over->y = res;
if ((ret = av_expr_parse_and_eval(&res, (expr = over->x_expr), var_names, var_values,
NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
goto fail;
over->x = res;
over->overlay_is_packed_rgb =
ff_fill_rgba_map(over->overlay_rgba_map, inlink->format) >= 0;
over->overlay_has_alpha = ff_fmt_is_in(inlink->format, alpha_pix_fmts);
av_log(ctx, AV_LOG_VERBOSE,
"main w:%d h:%d fmt:%s overlay x:%d y:%d w:%d h:%d fmt:%s\n",
ctx->inputs[MAIN]->w, ctx->inputs[MAIN]->h,
av_get_pix_fmt_name(ctx->inputs[MAIN]->format),
over->x, over->y,
ctx->inputs[OVERLAY]->w, ctx->inputs[OVERLAY]->h,
av_get_pix_fmt_name(ctx->inputs[OVERLAY]->format));
if (over->x < 0 || over->y < 0 ||
over->x + var_values[VAR_OVERLAY_W] > var_values[VAR_MAIN_W] ||
over->y + var_values[VAR_OVERLAY_H] > var_values[VAR_MAIN_H]) {
av_log(ctx, AV_LOG_ERROR,
"Overlay area (%d,%d)<->(%d,%d) not within the main area (0,0)<->(%d,%d) or zero-sized\n",
over->x, over->y,
(int)(over->x + var_values[VAR_OVERLAY_W]),
(int)(over->y + var_values[VAR_OVERLAY_H]),
(int)var_values[VAR_MAIN_W], (int)var_values[VAR_MAIN_H]);
return AVERROR(EINVAL);
}
return 0;
fail:
av_log(NULL, AV_LOG_ERROR,
"Error when evaluating the expression '%s'\n", expr);
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFilterLink *VAR_0)
{
AVFilterContext *ctx = VAR_0->dst;
OverlayContext *over = VAR_0->dst->priv;
char *VAR_1;
double VAR_2[VAR_VARS_NB], res;
int VAR_3;
const AVPixFmtDescriptor *VAR_4 = av_pix_fmt_desc_get(VAR_0->format);
av_image_fill_max_pixsteps(over->overlay_pix_step, NULL, VAR_4);
VAR_2[VAR_MAIN_W ] = VAR_2[VAR_MW] = ctx->inputs[MAIN ]->w;
VAR_2[VAR_MAIN_H ] = VAR_2[VAR_MH] = ctx->inputs[MAIN ]->h;
VAR_2[VAR_OVERLAY_W] = VAR_2[VAR_OW] = ctx->inputs[OVERLAY]->w;
VAR_2[VAR_OVERLAY_H] = VAR_2[VAR_OH] = ctx->inputs[OVERLAY]->h;
if ((VAR_3 = av_expr_parse_and_eval(&res, (VAR_1 = over->x_expr), var_names, VAR_2,
NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
goto fail;
over->x = res;
if ((VAR_3 = av_expr_parse_and_eval(&res, (VAR_1 = over->y_expr), var_names, VAR_2,
NULL, NULL, NULL, NULL, NULL, 0, ctx)))
goto fail;
over->y = res;
if ((VAR_3 = av_expr_parse_and_eval(&res, (VAR_1 = over->x_expr), var_names, VAR_2,
NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
goto fail;
over->x = res;
over->overlay_is_packed_rgb =
ff_fill_rgba_map(over->overlay_rgba_map, VAR_0->format) >= 0;
over->overlay_has_alpha = ff_fmt_is_in(VAR_0->format, alpha_pix_fmts);
av_log(ctx, AV_LOG_VERBOSE,
"main w:%d h:%d fmt:%s overlay x:%d y:%d w:%d h:%d fmt:%s\n",
ctx->inputs[MAIN]->w, ctx->inputs[MAIN]->h,
av_get_pix_fmt_name(ctx->inputs[MAIN]->format),
over->x, over->y,
ctx->inputs[OVERLAY]->w, ctx->inputs[OVERLAY]->h,
av_get_pix_fmt_name(ctx->inputs[OVERLAY]->format));
if (over->x < 0 || over->y < 0 ||
over->x + VAR_2[VAR_OVERLAY_W] > VAR_2[VAR_MAIN_W] ||
over->y + VAR_2[VAR_OVERLAY_H] > VAR_2[VAR_MAIN_H]) {
av_log(ctx, AV_LOG_ERROR,
"Overlay area (%d,%d)<->(%d,%d) not within the main area (0,0)<->(%d,%d) or zero-sized\n",
over->x, over->y,
(int)(over->x + VAR_2[VAR_OVERLAY_W]),
(int)(over->y + VAR_2[VAR_OVERLAY_H]),
(int)VAR_2[VAR_MAIN_W], (int)VAR_2[VAR_MAIN_H]);
return AVERROR(EINVAL);
}
return 0;
fail:
av_log(NULL, AV_LOG_ERROR,
"Error when evaluating the expression '%s'\n", VAR_1);
return VAR_3;
}
| [
"static int FUNC_0(AVFilterLink *VAR_0)\n{",
"AVFilterContext *ctx = VAR_0->dst;",
"OverlayContext *over = VAR_0->dst->priv;",
"char *VAR_1;",
"double VAR_2[VAR_VARS_NB], res;",
"int VAR_3;",
"const AVPixFmtDescriptor *VAR_4 = av_pix_fmt_desc_get(VAR_0->format);",
"av_image_fill_max_pixsteps(over->overlay_pix_step, NULL, VAR_4);",
"VAR_2[VAR_MAIN_W ] = VAR_2[VAR_MW] = ctx->inputs[MAIN ]->w;",
"VAR_2[VAR_MAIN_H ] = VAR_2[VAR_MH] = ctx->inputs[MAIN ]->h;",
"VAR_2[VAR_OVERLAY_W] = VAR_2[VAR_OW] = ctx->inputs[OVERLAY]->w;",
"VAR_2[VAR_OVERLAY_H] = VAR_2[VAR_OH] = ctx->inputs[OVERLAY]->h;",
"if ((VAR_3 = av_expr_parse_and_eval(&res, (VAR_1 = over->x_expr), var_names, VAR_2,\nNULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)\ngoto fail;",
"over->x = res;",
"if ((VAR_3 = av_expr_parse_and_eval(&res, (VAR_1 = over->y_expr), var_names, VAR_2,\nNULL, NULL, NULL, NULL, NULL, 0, ctx)))\ngoto fail;",
"over->y = res;",
"if ((VAR_3 = av_expr_parse_and_eval(&res, (VAR_1 = over->x_expr), var_names, VAR_2,\nNULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)\ngoto fail;",
"over->x = res;",
"over->overlay_is_packed_rgb =\nff_fill_rgba_map(over->overlay_rgba_map, VAR_0->format) >= 0;",
"over->overlay_has_alpha = ff_fmt_is_in(VAR_0->format, alpha_pix_fmts);",
"av_log(ctx, AV_LOG_VERBOSE,\n\"main w:%d h:%d fmt:%s overlay x:%d y:%d w:%d h:%d fmt:%s\\n\",\nctx->inputs[MAIN]->w, ctx->inputs[MAIN]->h,\nav_get_pix_fmt_name(ctx->inputs[MAIN]->format),\nover->x, over->y,\nctx->inputs[OVERLAY]->w, ctx->inputs[OVERLAY]->h,\nav_get_pix_fmt_name(ctx->inputs[OVERLAY]->format));",
"if (over->x < 0 || over->y < 0 ||\nover->x + VAR_2[VAR_OVERLAY_W] > VAR_2[VAR_MAIN_W] ||\nover->y + VAR_2[VAR_OVERLAY_H] > VAR_2[VAR_MAIN_H]) {",
"av_log(ctx, AV_LOG_ERROR,\n\"Overlay area (%d,%d)<->(%d,%d) not within the main area (0,0)<->(%d,%d) or zero-sized\\n\",\nover->x, over->y,\n(int)(over->x + VAR_2[VAR_OVERLAY_W]),\n(int)(over->y + VAR_2[VAR_OVERLAY_H]),\n(int)VAR_2[VAR_MAIN_W], (int)VAR_2[VAR_MAIN_H]);",
"return AVERROR(EINVAL);",
"}",
"return 0;",
"fail:\nav_log(NULL, AV_LOG_ERROR,\n\"Error when evaluating the expression '%s'\\n\", VAR_1);",
"return VAR_3;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37,
39,
41
],
[
43
],
[
45,
47,
49
],
[
51
],
[
55,
57,
59
],
[
61
],
[
65,
67
],
[
69
],
[
73,
75,
77,
79,
81,
83,
85
],
[
89,
91,
93
],
[
95,
97,
99,
101,
103,
105
],
[
107
],
[
109
],
[
111
],
[
115,
117,
119
],
[
121
],
[
123
]
] |
18,940 | static int dvdsub_decode(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
DVDSubContext *ctx = avctx->priv_data;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
AVSubtitle *sub = data;
int is_menu;
if (ctx->buf_size) {
int ret = append_to_cached_buf(avctx, buf, buf_size);
if (ret < 0) {
*data_size = 0;
return ret;
}
buf = ctx->buf;
buf_size = ctx->buf_size;
}
is_menu = decode_dvd_subtitles(ctx, sub, buf, buf_size);
if (is_menu == AVERROR(EAGAIN)) {
*data_size = 0;
return append_to_cached_buf(avctx, buf, buf_size);
}
if (is_menu < 0) {
no_subtitle:
reset_rects(sub);
*data_size = 0;
return buf_size;
}
if (!is_menu && find_smallest_bounding_rectangle(sub) == 0)
goto no_subtitle;
if (ctx->forced_subs_only && !(sub->rects[0]->flags & AV_SUBTITLE_FLAG_FORCED))
goto no_subtitle;
#if defined(DEBUG)
{
char ppm_name[32];
snprintf(ppm_name, sizeof(ppm_name), "/tmp/%05d.ppm", ctx->sub_id++);
ff_dlog(NULL, "start=%d ms end =%d ms\n",
sub->start_display_time,
sub->end_display_time);
ppm_save(ppm_name, sub->rects[0]->pict.data[0],
sub->rects[0]->w, sub->rects[0]->h, (uint32_t*) sub->rects[0]->pict.data[1]);
}
#endif
ctx->buf_size = 0;
*data_size = 1;
return buf_size;
}
| false | FFmpeg | f874e2728b0925b2ec30dd7ec64815f15078c06f | static int dvdsub_decode(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
DVDSubContext *ctx = avctx->priv_data;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
AVSubtitle *sub = data;
int is_menu;
if (ctx->buf_size) {
int ret = append_to_cached_buf(avctx, buf, buf_size);
if (ret < 0) {
*data_size = 0;
return ret;
}
buf = ctx->buf;
buf_size = ctx->buf_size;
}
is_menu = decode_dvd_subtitles(ctx, sub, buf, buf_size);
if (is_menu == AVERROR(EAGAIN)) {
*data_size = 0;
return append_to_cached_buf(avctx, buf, buf_size);
}
if (is_menu < 0) {
no_subtitle:
reset_rects(sub);
*data_size = 0;
return buf_size;
}
if (!is_menu && find_smallest_bounding_rectangle(sub) == 0)
goto no_subtitle;
if (ctx->forced_subs_only && !(sub->rects[0]->flags & AV_SUBTITLE_FLAG_FORCED))
goto no_subtitle;
#if defined(DEBUG)
{
char ppm_name[32];
snprintf(ppm_name, sizeof(ppm_name), "/tmp/%05d.ppm", ctx->sub_id++);
ff_dlog(NULL, "start=%d ms end =%d ms\n",
sub->start_display_time,
sub->end_display_time);
ppm_save(ppm_name, sub->rects[0]->pict.data[0],
sub->rects[0]->w, sub->rects[0]->h, (uint32_t*) sub->rects[0]->pict.data[1]);
}
#endif
ctx->buf_size = 0;
*data_size = 1;
return buf_size;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0,
void *VAR_1, int *VAR_2,
AVPacket *VAR_3)
{
DVDSubContext *ctx = VAR_0->priv_data;
const uint8_t *VAR_4 = VAR_3->VAR_1;
int VAR_5 = VAR_3->size;
AVSubtitle *sub = VAR_1;
int VAR_6;
if (ctx->VAR_5) {
int VAR_7 = append_to_cached_buf(VAR_0, VAR_4, VAR_5);
if (VAR_7 < 0) {
*VAR_2 = 0;
return VAR_7;
}
VAR_4 = ctx->VAR_4;
VAR_5 = ctx->VAR_5;
}
VAR_6 = decode_dvd_subtitles(ctx, sub, VAR_4, VAR_5);
if (VAR_6 == AVERROR(EAGAIN)) {
*VAR_2 = 0;
return append_to_cached_buf(VAR_0, VAR_4, VAR_5);
}
if (VAR_6 < 0) {
no_subtitle:
reset_rects(sub);
*VAR_2 = 0;
return VAR_5;
}
if (!VAR_6 && find_smallest_bounding_rectangle(sub) == 0)
goto no_subtitle;
if (ctx->forced_subs_only && !(sub->rects[0]->flags & AV_SUBTITLE_FLAG_FORCED))
goto no_subtitle;
#if defined(DEBUG)
{
char ppm_name[32];
snprintf(ppm_name, sizeof(ppm_name), "/tmp/%05d.ppm", ctx->sub_id++);
ff_dlog(NULL, "start=%d ms end =%d ms\n",
sub->start_display_time,
sub->end_display_time);
ppm_save(ppm_name, sub->rects[0]->pict.VAR_1[0],
sub->rects[0]->w, sub->rects[0]->h, (uint32_t*) sub->rects[0]->pict.VAR_1[1]);
}
#endif
ctx->VAR_5 = 0;
*VAR_2 = 1;
return VAR_5;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0,\nvoid *VAR_1, int *VAR_2,\nAVPacket *VAR_3)\n{",
"DVDSubContext *ctx = VAR_0->priv_data;",
"const uint8_t *VAR_4 = VAR_3->VAR_1;",
"int VAR_5 = VAR_3->size;",
"AVSubtitle *sub = VAR_1;",
"int VAR_6;",
"if (ctx->VAR_5) {",
"int VAR_7 = append_to_cached_buf(VAR_0, VAR_4, VAR_5);",
"if (VAR_7 < 0) {",
"*VAR_2 = 0;",
"return VAR_7;",
"}",
"VAR_4 = ctx->VAR_4;",
"VAR_5 = ctx->VAR_5;",
"}",
"VAR_6 = decode_dvd_subtitles(ctx, sub, VAR_4, VAR_5);",
"if (VAR_6 == AVERROR(EAGAIN)) {",
"*VAR_2 = 0;",
"return append_to_cached_buf(VAR_0, VAR_4, VAR_5);",
"}",
"if (VAR_6 < 0) {",
"no_subtitle:\nreset_rects(sub);",
"*VAR_2 = 0;",
"return VAR_5;",
"}",
"if (!VAR_6 && find_smallest_bounding_rectangle(sub) == 0)\ngoto no_subtitle;",
"if (ctx->forced_subs_only && !(sub->rects[0]->flags & AV_SUBTITLE_FLAG_FORCED))\ngoto no_subtitle;",
"#if defined(DEBUG)\n{",
"char ppm_name[32];",
"snprintf(ppm_name, sizeof(ppm_name), \"/tmp/%05d.ppm\", ctx->sub_id++);",
"ff_dlog(NULL, \"start=%d ms end =%d ms\\n\",\nsub->start_display_time,\nsub->end_display_time);",
"ppm_save(ppm_name, sub->rects[0]->pict.VAR_1[0],\nsub->rects[0]->w, sub->rects[0]->h, (uint32_t*) sub->rects[0]->pict.VAR_1[1]);",
"}",
"#endif\nctx->VAR_5 = 0;",
"*VAR_2 = 1;",
"return VAR_5;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55,
57
],
[
59
],
[
63
],
[
65
],
[
67,
69
],
[
73,
75
],
[
79,
81
],
[
83
],
[
87
],
[
89,
91,
93
],
[
95,
97
],
[
99
],
[
101,
105
],
[
107
],
[
109
],
[
111
]
] |
18,941 | static int mov_write_moov_tag(ByteIOContext *pb, MOVContext *mov,
AVFormatContext *s)
{
int i;
offset_t pos = url_ftell(pb);
put_be32(pb, 0); /* size placeholder*/
put_tag(pb, "moov");
mov->timescale = globalTimescale;
for (i=0; i<MAX_STREAMS; i++) {
if(mov->tracks[i].entry <= 0) continue;
if(mov->tracks[i].enc->codec_type == CODEC_TYPE_VIDEO) {
mov->tracks[i].timescale = mov->tracks[i].enc->time_base.den;
mov->tracks[i].sampleDuration = mov->tracks[i].enc->time_base.num;
} else if(mov->tracks[i].enc->codec_type == CODEC_TYPE_AUDIO) {
mov->tracks[i].timescale = mov->tracks[i].enc->sample_rate;
mov->tracks[i].sampleDuration = mov->tracks[i].enc->frame_size;
}
mov->tracks[i].trackDuration =
(int64_t)mov->tracks[i].sampleCount * mov->tracks[i].sampleDuration;
mov->tracks[i].time = mov->time;
mov->tracks[i].trackID = i+1;
}
mov_write_mvhd_tag(pb, mov);
//mov_write_iods_tag(pb, mov);
for (i=0; i<MAX_STREAMS; i++) {
if(mov->tracks[i].entry > 0) {
mov_write_trak_tag(pb, &(mov->tracks[i]));
}
}
if (mov->mode == MODE_PSP)
mov_write_uuidusmt_tag(pb, s);
else
mov_write_udta_tag(pb, mov, s);
return updateSize(pb, pos);
}
| false | FFmpeg | 42fb414804419c3fc269c73ad049f218f8813ed0 | static int mov_write_moov_tag(ByteIOContext *pb, MOVContext *mov,
AVFormatContext *s)
{
int i;
offset_t pos = url_ftell(pb);
put_be32(pb, 0);
put_tag(pb, "moov");
mov->timescale = globalTimescale;
for (i=0; i<MAX_STREAMS; i++) {
if(mov->tracks[i].entry <= 0) continue;
if(mov->tracks[i].enc->codec_type == CODEC_TYPE_VIDEO) {
mov->tracks[i].timescale = mov->tracks[i].enc->time_base.den;
mov->tracks[i].sampleDuration = mov->tracks[i].enc->time_base.num;
} else if(mov->tracks[i].enc->codec_type == CODEC_TYPE_AUDIO) {
mov->tracks[i].timescale = mov->tracks[i].enc->sample_rate;
mov->tracks[i].sampleDuration = mov->tracks[i].enc->frame_size;
}
mov->tracks[i].trackDuration =
(int64_t)mov->tracks[i].sampleCount * mov->tracks[i].sampleDuration;
mov->tracks[i].time = mov->time;
mov->tracks[i].trackID = i+1;
}
mov_write_mvhd_tag(pb, mov);
for (i=0; i<MAX_STREAMS; i++) {
if(mov->tracks[i].entry > 0) {
mov_write_trak_tag(pb, &(mov->tracks[i]));
}
}
if (mov->mode == MODE_PSP)
mov_write_uuidusmt_tag(pb, s);
else
mov_write_udta_tag(pb, mov, s);
return updateSize(pb, pos);
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(ByteIOContext *VAR_0, MOVContext *VAR_1,
AVFormatContext *VAR_2)
{
int VAR_3;
offset_t pos = url_ftell(VAR_0);
put_be32(VAR_0, 0);
put_tag(VAR_0, "moov");
VAR_1->timescale = globalTimescale;
for (VAR_3=0; VAR_3<MAX_STREAMS; VAR_3++) {
if(VAR_1->tracks[VAR_3].entry <= 0) continue;
if(VAR_1->tracks[VAR_3].enc->codec_type == CODEC_TYPE_VIDEO) {
VAR_1->tracks[VAR_3].timescale = VAR_1->tracks[VAR_3].enc->time_base.den;
VAR_1->tracks[VAR_3].sampleDuration = VAR_1->tracks[VAR_3].enc->time_base.num;
} else if(VAR_1->tracks[VAR_3].enc->codec_type == CODEC_TYPE_AUDIO) {
VAR_1->tracks[VAR_3].timescale = VAR_1->tracks[VAR_3].enc->sample_rate;
VAR_1->tracks[VAR_3].sampleDuration = VAR_1->tracks[VAR_3].enc->frame_size;
}
VAR_1->tracks[VAR_3].trackDuration =
(int64_t)VAR_1->tracks[VAR_3].sampleCount * VAR_1->tracks[VAR_3].sampleDuration;
VAR_1->tracks[VAR_3].time = VAR_1->time;
VAR_1->tracks[VAR_3].trackID = VAR_3+1;
}
mov_write_mvhd_tag(VAR_0, VAR_1);
for (VAR_3=0; VAR_3<MAX_STREAMS; VAR_3++) {
if(VAR_1->tracks[VAR_3].entry > 0) {
mov_write_trak_tag(VAR_0, &(VAR_1->tracks[VAR_3]));
}
}
if (VAR_1->mode == MODE_PSP)
mov_write_uuidusmt_tag(VAR_0, VAR_2);
else
mov_write_udta_tag(VAR_0, VAR_1, VAR_2);
return updateSize(VAR_0, pos);
}
| [
"static int FUNC_0(ByteIOContext *VAR_0, MOVContext *VAR_1,\nAVFormatContext *VAR_2)\n{",
"int VAR_3;",
"offset_t pos = url_ftell(VAR_0);",
"put_be32(VAR_0, 0);",
"put_tag(VAR_0, \"moov\");",
"VAR_1->timescale = globalTimescale;",
"for (VAR_3=0; VAR_3<MAX_STREAMS; VAR_3++) {",
"if(VAR_1->tracks[VAR_3].entry <= 0) continue;",
"if(VAR_1->tracks[VAR_3].enc->codec_type == CODEC_TYPE_VIDEO) {",
"VAR_1->tracks[VAR_3].timescale = VAR_1->tracks[VAR_3].enc->time_base.den;",
"VAR_1->tracks[VAR_3].sampleDuration = VAR_1->tracks[VAR_3].enc->time_base.num;",
"} else if(VAR_1->tracks[VAR_3].enc->codec_type == CODEC_TYPE_AUDIO) {",
"VAR_1->tracks[VAR_3].timescale = VAR_1->tracks[VAR_3].enc->sample_rate;",
"VAR_1->tracks[VAR_3].sampleDuration = VAR_1->tracks[VAR_3].enc->frame_size;",
"}",
"VAR_1->tracks[VAR_3].trackDuration =\n(int64_t)VAR_1->tracks[VAR_3].sampleCount * VAR_1->tracks[VAR_3].sampleDuration;",
"VAR_1->tracks[VAR_3].time = VAR_1->time;",
"VAR_1->tracks[VAR_3].trackID = VAR_3+1;",
"}",
"mov_write_mvhd_tag(VAR_0, VAR_1);",
"for (VAR_3=0; VAR_3<MAX_STREAMS; VAR_3++) {",
"if(VAR_1->tracks[VAR_3].entry > 0) {",
"mov_write_trak_tag(VAR_0, &(VAR_1->tracks[VAR_3]));",
"}",
"}",
"if (VAR_1->mode == MODE_PSP)\nmov_write_uuidusmt_tag(VAR_0, VAR_2);",
"else\nmov_write_udta_tag(VAR_0, VAR_1, VAR_2);",
"return updateSize(VAR_0, pos);",
"}"
] | [
0,
0,
0,
0,
0,
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
],
[
41,
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69,
71
],
[
73,
75
],
[
79
],
[
81
]
] |
18,944 | int vncws_decode_frame(Buffer *input, uint8_t **payload,
size_t *payload_size, size_t *frame_size)
{
unsigned char opcode = 0, fin = 0, has_mask = 0;
size_t header_size = 0;
uint32_t *payload32;
WsHeader *header = (WsHeader *)input->buffer;
WsMask mask;
int i;
if (input->offset < WS_HEAD_MIN_LEN + 4) {
/* header not complete */
return 0;
}
fin = (header->b0 & 0x80) >> 7;
opcode = header->b0 & 0x0f;
has_mask = (header->b1 & 0x80) >> 7;
*payload_size = header->b1 & 0x7f;
if (opcode == WS_OPCODE_CLOSE) {
/* disconnect */
return -1;
}
/* Websocket frame sanity check:
* * Websocket fragmentation is not supported.
* * All websockets frames sent by a client have to be masked.
* * Only binary encoding is supported.
*/
if (!fin || !has_mask || opcode != WS_OPCODE_BINARY_FRAME) {
VNC_DEBUG("Received faulty/unsupported Websocket frame\n");
return -2;
}
if (*payload_size < 126) {
header_size = 6;
mask = header->u.m;
} else if (*payload_size == 126 && input->offset >= 8) {
*payload_size = be16_to_cpu(header->u.s16.l16);
header_size = 8;
mask = header->u.s16.m16;
} else if (*payload_size == 127 && input->offset >= 14) {
*payload_size = be64_to_cpu(header->u.s64.l64);
header_size = 14;
mask = header->u.s64.m64;
} else {
/* header not complete */
return 0;
}
*frame_size = header_size + *payload_size;
if (input->offset < *frame_size) {
/* frame not complete */
return 0;
}
*payload = input->buffer + header_size;
/* unmask frame */
/* process 1 frame (32 bit op) */
payload32 = (uint32_t *)(*payload);
for (i = 0; i < *payload_size / 4; i++) {
payload32[i] ^= mask.u;
}
/* process the remaining bytes (if any) */
for (i *= 4; i < *payload_size; i++) {
(*payload)[i] ^= mask.c[i % 4];
}
return 1;
}
| true | qemu | a2bebfd6e09d285aa793cae3fb0fc3a39a9fee6e | int vncws_decode_frame(Buffer *input, uint8_t **payload,
size_t *payload_size, size_t *frame_size)
{
unsigned char opcode = 0, fin = 0, has_mask = 0;
size_t header_size = 0;
uint32_t *payload32;
WsHeader *header = (WsHeader *)input->buffer;
WsMask mask;
int i;
if (input->offset < WS_HEAD_MIN_LEN + 4) {
return 0;
}
fin = (header->b0 & 0x80) >> 7;
opcode = header->b0 & 0x0f;
has_mask = (header->b1 & 0x80) >> 7;
*payload_size = header->b1 & 0x7f;
if (opcode == WS_OPCODE_CLOSE) {
return -1;
}
if (!fin || !has_mask || opcode != WS_OPCODE_BINARY_FRAME) {
VNC_DEBUG("Received faulty/unsupported Websocket frame\n");
return -2;
}
if (*payload_size < 126) {
header_size = 6;
mask = header->u.m;
} else if (*payload_size == 126 && input->offset >= 8) {
*payload_size = be16_to_cpu(header->u.s16.l16);
header_size = 8;
mask = header->u.s16.m16;
} else if (*payload_size == 127 && input->offset >= 14) {
*payload_size = be64_to_cpu(header->u.s64.l64);
header_size = 14;
mask = header->u.s64.m64;
} else {
return 0;
}
*frame_size = header_size + *payload_size;
if (input->offset < *frame_size) {
return 0;
}
*payload = input->buffer + header_size;
payload32 = (uint32_t *)(*payload);
for (i = 0; i < *payload_size / 4; i++) {
payload32[i] ^= mask.u;
}
for (i *= 4; i < *payload_size; i++) {
(*payload)[i] ^= mask.c[i % 4];
}
return 1;
}
| {
"code": [
"int vncws_decode_frame(Buffer *input, uint8_t **payload,",
" size_t *payload_size, size_t *frame_size)",
" size_t header_size = 0;",
" uint32_t *payload32;",
" WsMask mask;",
" int i;",
" *payload_size = header->b1 & 0x7f;",
" if (*payload_size < 126) {",
" header_size = 6;",
" mask = header->u.m;",
" } else if (*payload_size == 126 && input->offset >= 8) {",
" *payload_size = be16_to_cpu(header->u.s16.l16);",
" header_size = 8;",
" mask = header->u.s16.m16;",
" } else if (*payload_size == 127 && input->offset >= 14) {",
" *payload_size = be64_to_cpu(header->u.s64.l64);",
" header_size = 14;",
" mask = header->u.s64.m64;",
" *frame_size = header_size + *payload_size;",
" if (input->offset < *frame_size) {",
" *payload = input->buffer + header_size;",
" payload32[i] ^= mask.u;",
" (*payload)[i] ^= mask.c[i % 4];",
"int vncws_decode_frame(Buffer *input, uint8_t **payload,"
],
"line_no": [
1,
3,
9,
11,
15,
17,
37,
71,
73,
75,
77,
79,
81,
83,
85,
87,
89,
91,
103,
107,
117,
129,
137,
1
]
} | int FUNC_0(Buffer *VAR_0, uint8_t **VAR_1,
size_t *VAR_2, size_t *VAR_3)
{
unsigned char VAR_4 = 0, VAR_5 = 0, VAR_6 = 0;
size_t header_size = 0;
uint32_t *payload32;
WsHeader *header = (WsHeader *)VAR_0->buffer;
WsMask mask;
int VAR_7;
if (VAR_0->offset < WS_HEAD_MIN_LEN + 4) {
return 0;
}
VAR_5 = (header->b0 & 0x80) >> 7;
VAR_4 = header->b0 & 0x0f;
VAR_6 = (header->b1 & 0x80) >> 7;
*VAR_2 = header->b1 & 0x7f;
if (VAR_4 == WS_OPCODE_CLOSE) {
return -1;
}
if (!VAR_5 || !VAR_6 || VAR_4 != WS_OPCODE_BINARY_FRAME) {
VNC_DEBUG("Received faulty/unsupported Websocket frame\n");
return -2;
}
if (*VAR_2 < 126) {
header_size = 6;
mask = header->u.m;
} else if (*VAR_2 == 126 && VAR_0->offset >= 8) {
*VAR_2 = be16_to_cpu(header->u.s16.l16);
header_size = 8;
mask = header->u.s16.m16;
} else if (*VAR_2 == 127 && VAR_0->offset >= 14) {
*VAR_2 = be64_to_cpu(header->u.s64.l64);
header_size = 14;
mask = header->u.s64.m64;
} else {
return 0;
}
*VAR_3 = header_size + *VAR_2;
if (VAR_0->offset < *VAR_3) {
return 0;
}
*VAR_1 = VAR_0->buffer + header_size;
payload32 = (uint32_t *)(*VAR_1);
for (VAR_7 = 0; VAR_7 < *VAR_2 / 4; VAR_7++) {
payload32[VAR_7] ^= mask.u;
}
for (VAR_7 *= 4; VAR_7 < *VAR_2; VAR_7++) {
(*VAR_1)[VAR_7] ^= mask.c[VAR_7 % 4];
}
return 1;
}
| [
"int FUNC_0(Buffer *VAR_0, uint8_t **VAR_1,\nsize_t *VAR_2, size_t *VAR_3)\n{",
"unsigned char VAR_4 = 0, VAR_5 = 0, VAR_6 = 0;",
"size_t header_size = 0;",
"uint32_t *payload32;",
"WsHeader *header = (WsHeader *)VAR_0->buffer;",
"WsMask mask;",
"int VAR_7;",
"if (VAR_0->offset < WS_HEAD_MIN_LEN + 4) {",
"return 0;",
"}",
"VAR_5 = (header->b0 & 0x80) >> 7;",
"VAR_4 = header->b0 & 0x0f;",
"VAR_6 = (header->b1 & 0x80) >> 7;",
"*VAR_2 = header->b1 & 0x7f;",
"if (VAR_4 == WS_OPCODE_CLOSE) {",
"return -1;",
"}",
"if (!VAR_5 || !VAR_6 || VAR_4 != WS_OPCODE_BINARY_FRAME) {",
"VNC_DEBUG(\"Received faulty/unsupported Websocket frame\\n\");",
"return -2;",
"}",
"if (*VAR_2 < 126) {",
"header_size = 6;",
"mask = header->u.m;",
"} else if (*VAR_2 == 126 && VAR_0->offset >= 8) {",
"*VAR_2 = be16_to_cpu(header->u.s16.l16);",
"header_size = 8;",
"mask = header->u.s16.m16;",
"} else if (*VAR_2 == 127 && VAR_0->offset >= 14) {",
"*VAR_2 = be64_to_cpu(header->u.s64.l64);",
"header_size = 14;",
"mask = header->u.s64.m64;",
"} else {",
"return 0;",
"}",
"*VAR_3 = header_size + *VAR_2;",
"if (VAR_0->offset < *VAR_3) {",
"return 0;",
"}",
"*VAR_1 = VAR_0->buffer + header_size;",
"payload32 = (uint32_t *)(*VAR_1);",
"for (VAR_7 = 0; VAR_7 < *VAR_2 / 4; VAR_7++) {",
"payload32[VAR_7] ^= mask.u;",
"}",
"for (VAR_7 *= 4; VAR_7 < *VAR_2; VAR_7++) {",
"(*VAR_1)[VAR_7] ^= mask.c[VAR_7 % 4];",
"}",
"return 1;",
"}"
] | [
1,
0,
1,
1,
0,
1,
1,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
1,
1,
0,
0,
1,
0,
0,
1,
0,
0,
1,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
45
],
[
47
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
97
],
[
99
],
[
103
],
[
107
],
[
111
],
[
113
],
[
117
],
[
125
],
[
127
],
[
129
],
[
131
],
[
135
],
[
137
],
[
139
],
[
143
],
[
145
]
] |
18,945 | static void send_framebuffer_update_raw(VncState *vs, int x, int y, int w, int h)
{
int i;
uint8_t *row;
row = ds_get_data(vs->ds) + y * ds_get_linesize(vs->ds) + x * ds_get_bytes_per_pixel(vs->ds);
for (i = 0; i < h; i++) {
vs->write_pixels(vs, row, w * ds_get_bytes_per_pixel(vs->ds));
row += ds_get_linesize(vs->ds);
}
}
| true | qemu | 6baebed7698a37a0ac5168faf26023426b0ac940 | static void send_framebuffer_update_raw(VncState *vs, int x, int y, int w, int h)
{
int i;
uint8_t *row;
row = ds_get_data(vs->ds) + y * ds_get_linesize(vs->ds) + x * ds_get_bytes_per_pixel(vs->ds);
for (i = 0; i < h; i++) {
vs->write_pixels(vs, row, w * ds_get_bytes_per_pixel(vs->ds));
row += ds_get_linesize(vs->ds);
}
}
| {
"code": [
" row = ds_get_data(vs->ds) + y * ds_get_linesize(vs->ds) + x * ds_get_bytes_per_pixel(vs->ds);"
],
"line_no": [
11
]
} | static void FUNC_0(VncState *VAR_0, int VAR_1, int VAR_2, int VAR_3, int VAR_4)
{
int VAR_5;
uint8_t *row;
row = ds_get_data(VAR_0->ds) + VAR_2 * ds_get_linesize(VAR_0->ds) + VAR_1 * ds_get_bytes_per_pixel(VAR_0->ds);
for (VAR_5 = 0; VAR_5 < VAR_4; VAR_5++) {
VAR_0->write_pixels(VAR_0, row, VAR_3 * ds_get_bytes_per_pixel(VAR_0->ds));
row += ds_get_linesize(VAR_0->ds);
}
}
| [
"static void FUNC_0(VncState *VAR_0, int VAR_1, int VAR_2, int VAR_3, int VAR_4)\n{",
"int VAR_5;",
"uint8_t *row;",
"row = ds_get_data(VAR_0->ds) + VAR_2 * ds_get_linesize(VAR_0->ds) + VAR_1 * ds_get_bytes_per_pixel(VAR_0->ds);",
"for (VAR_5 = 0; VAR_5 < VAR_4; VAR_5++) {",
"VAR_0->write_pixels(VAR_0, row, VAR_3 * ds_get_bytes_per_pixel(VAR_0->ds));",
"row += ds_get_linesize(VAR_0->ds);",
"}",
"}"
] | [
0,
0,
0,
1,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
18,947 | static int alloc_frame_buffer(MpegEncContext *s, Picture *pic)
{
int r;
if (s->avctx->hwaccel) {
assert(!pic->f.hwaccel_picture_private);
if (s->avctx->hwaccel->priv_data_size) {
pic->f.hwaccel_picture_private = av_mallocz(s->avctx->hwaccel->priv_data_size);
if (!pic->f.hwaccel_picture_private) {
av_log(s->avctx, AV_LOG_ERROR, "alloc_frame_buffer() failed (hwaccel private data allocation)\n");
return -1;
}
}
}
if (s->codec_id != AV_CODEC_ID_WMV3IMAGE &&
s->codec_id != AV_CODEC_ID_VC1IMAGE &&
s->codec_id != AV_CODEC_ID_MSS2)
r = ff_thread_get_buffer(s->avctx, &pic->f);
else
r = avcodec_default_get_buffer(s->avctx, &pic->f);
if (r < 0 || !pic->f.type || !pic->f.data[0]) {
av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (%d %d %p)\n",
r, pic->f.type, pic->f.data[0]);
av_freep(&pic->f.hwaccel_picture_private);
return -1;
}
if (s->linesize && (s->linesize != pic->f.linesize[0] ||
s->uvlinesize != pic->f.linesize[1])) {
av_log(s->avctx, AV_LOG_ERROR,
"get_buffer() failed (stride changed)\n");
free_frame_buffer(s, pic);
return -1;
}
if (pic->f.linesize[1] != pic->f.linesize[2]) {
av_log(s->avctx, AV_LOG_ERROR,
"get_buffer() failed (uv stride mismatch)\n");
free_frame_buffer(s, pic);
return -1;
}
return 0;
}
| true | FFmpeg | f1d8763a02b5fce9a7d9789e049d74a45b15e1e8 | static int alloc_frame_buffer(MpegEncContext *s, Picture *pic)
{
int r;
if (s->avctx->hwaccel) {
assert(!pic->f.hwaccel_picture_private);
if (s->avctx->hwaccel->priv_data_size) {
pic->f.hwaccel_picture_private = av_mallocz(s->avctx->hwaccel->priv_data_size);
if (!pic->f.hwaccel_picture_private) {
av_log(s->avctx, AV_LOG_ERROR, "alloc_frame_buffer() failed (hwaccel private data allocation)\n");
return -1;
}
}
}
if (s->codec_id != AV_CODEC_ID_WMV3IMAGE &&
s->codec_id != AV_CODEC_ID_VC1IMAGE &&
s->codec_id != AV_CODEC_ID_MSS2)
r = ff_thread_get_buffer(s->avctx, &pic->f);
else
r = avcodec_default_get_buffer(s->avctx, &pic->f);
if (r < 0 || !pic->f.type || !pic->f.data[0]) {
av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (%d %d %p)\n",
r, pic->f.type, pic->f.data[0]);
av_freep(&pic->f.hwaccel_picture_private);
return -1;
}
if (s->linesize && (s->linesize != pic->f.linesize[0] ||
s->uvlinesize != pic->f.linesize[1])) {
av_log(s->avctx, AV_LOG_ERROR,
"get_buffer() failed (stride changed)\n");
free_frame_buffer(s, pic);
return -1;
}
if (pic->f.linesize[1] != pic->f.linesize[2]) {
av_log(s->avctx, AV_LOG_ERROR,
"get_buffer() failed (uv stride mismatch)\n");
free_frame_buffer(s, pic);
return -1;
}
return 0;
}
| {
"code": [
" int r;"
],
"line_no": [
5
]
} | static int FUNC_0(MpegEncContext *VAR_0, Picture *VAR_1)
{
int VAR_2;
if (VAR_0->avctx->hwaccel) {
assert(!VAR_1->f.hwaccel_picture_private);
if (VAR_0->avctx->hwaccel->priv_data_size) {
VAR_1->f.hwaccel_picture_private = av_mallocz(VAR_0->avctx->hwaccel->priv_data_size);
if (!VAR_1->f.hwaccel_picture_private) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "FUNC_0() failed (hwaccel private data allocation)\n");
return -1;
}
}
}
if (VAR_0->codec_id != AV_CODEC_ID_WMV3IMAGE &&
VAR_0->codec_id != AV_CODEC_ID_VC1IMAGE &&
VAR_0->codec_id != AV_CODEC_ID_MSS2)
VAR_2 = ff_thread_get_buffer(VAR_0->avctx, &VAR_1->f);
else
VAR_2 = avcodec_default_get_buffer(VAR_0->avctx, &VAR_1->f);
if (VAR_2 < 0 || !VAR_1->f.type || !VAR_1->f.data[0]) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "get_buffer() failed (%d %d %p)\n",
VAR_2, VAR_1->f.type, VAR_1->f.data[0]);
av_freep(&VAR_1->f.hwaccel_picture_private);
return -1;
}
if (VAR_0->linesize && (VAR_0->linesize != VAR_1->f.linesize[0] ||
VAR_0->uvlinesize != VAR_1->f.linesize[1])) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"get_buffer() failed (stride changed)\n");
free_frame_buffer(VAR_0, VAR_1);
return -1;
}
if (VAR_1->f.linesize[1] != VAR_1->f.linesize[2]) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"get_buffer() failed (uv stride mismatch)\n");
free_frame_buffer(VAR_0, VAR_1);
return -1;
}
return 0;
}
| [
"static int FUNC_0(MpegEncContext *VAR_0, Picture *VAR_1)\n{",
"int VAR_2;",
"if (VAR_0->avctx->hwaccel) {",
"assert(!VAR_1->f.hwaccel_picture_private);",
"if (VAR_0->avctx->hwaccel->priv_data_size) {",
"VAR_1->f.hwaccel_picture_private = av_mallocz(VAR_0->avctx->hwaccel->priv_data_size);",
"if (!VAR_1->f.hwaccel_picture_private) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"FUNC_0() failed (hwaccel private data allocation)\\n\");",
"return -1;",
"}",
"}",
"}",
"if (VAR_0->codec_id != AV_CODEC_ID_WMV3IMAGE &&\nVAR_0->codec_id != AV_CODEC_ID_VC1IMAGE &&\nVAR_0->codec_id != AV_CODEC_ID_MSS2)\nVAR_2 = ff_thread_get_buffer(VAR_0->avctx, &VAR_1->f);",
"else\nVAR_2 = avcodec_default_get_buffer(VAR_0->avctx, &VAR_1->f);",
"if (VAR_2 < 0 || !VAR_1->f.type || !VAR_1->f.data[0]) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"get_buffer() failed (%d %d %p)\\n\",\nVAR_2, VAR_1->f.type, VAR_1->f.data[0]);",
"av_freep(&VAR_1->f.hwaccel_picture_private);",
"return -1;",
"}",
"if (VAR_0->linesize && (VAR_0->linesize != VAR_1->f.linesize[0] ||\nVAR_0->uvlinesize != VAR_1->f.linesize[1])) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"get_buffer() failed (stride changed)\\n\");",
"free_frame_buffer(VAR_0, VAR_1);",
"return -1;",
"}",
"if (VAR_1->f.linesize[1] != VAR_1->f.linesize[2]) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"get_buffer() failed (uv stride mismatch)\\n\");",
"free_frame_buffer(VAR_0, VAR_1);",
"return -1;",
"}",
"return 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
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31,
33,
35,
37
],
[
39,
41
],
[
45
],
[
47,
49
],
[
51
],
[
53
],
[
55
],
[
59,
61
],
[
63,
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77,
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91
]
] |
18,948 | static void pflash_write (pflash_t *pfl, target_ulong offset, uint32_t value,
int width)
{
target_ulong boff;
uint8_t *p;
uint8_t cmd;
/* WARNING: when the memory area is in ROMD mode, the offset is a
ram offset, not a physical address */
if (pfl->wcycle == 0)
offset -= (target_ulong)(long)pfl->storage;
else
offset -= pfl->base;
cmd = value;
DPRINTF("%s: offset " TARGET_FMT_lx " %08x %d\n", __func__,
offset, value, width);
if (pfl->cmd != 0xA0 && cmd == 0xF0) {
DPRINTF("%s: flash reset asked (%02x %02x)\n",
__func__, pfl->cmd, cmd);
goto reset_flash;
}
/* Set the device in I/O access mode */
cpu_register_physical_memory(pfl->base, pfl->total_len, pfl->fl_mem);
boff = offset & (pfl->sector_len - 1);
if (pfl->width == 2)
boff = boff >> 1;
else if (pfl->width == 4)
boff = boff >> 2;
switch (pfl->wcycle) {
case 0:
/* We're in read mode */
check_unlock0:
if (boff == 0x55 && cmd == 0x98) {
enter_CFI_mode:
/* Enter CFI query mode */
pfl->wcycle = 7;
pfl->cmd = 0x98;
return;
}
if (boff != 0x555 || cmd != 0xAA) {
DPRINTF("%s: unlock0 failed " TARGET_FMT_lx " %02x %04x\n",
__func__, boff, cmd, 0x555);
goto reset_flash;
}
DPRINTF("%s: unlock sequence started\n", __func__);
break;
case 1:
/* We started an unlock sequence */
check_unlock1:
if (boff != 0x2AA || cmd != 0x55) {
DPRINTF("%s: unlock1 failed " TARGET_FMT_lx " %02x\n", __func__,
boff, cmd);
goto reset_flash;
}
DPRINTF("%s: unlock sequence done\n", __func__);
break;
case 2:
/* We finished an unlock sequence */
if (!pfl->bypass && boff != 0x555) {
DPRINTF("%s: command failed " TARGET_FMT_lx " %02x\n", __func__,
boff, cmd);
goto reset_flash;
}
switch (cmd) {
case 0x20:
pfl->bypass = 1;
goto do_bypass;
case 0x80:
case 0x90:
case 0xA0:
pfl->cmd = cmd;
DPRINTF("%s: starting command %02x\n", __func__, cmd);
break;
default:
DPRINTF("%s: unknown command %02x\n", __func__, cmd);
goto reset_flash;
}
break;
case 3:
switch (pfl->cmd) {
case 0x80:
/* We need another unlock sequence */
goto check_unlock0;
case 0xA0:
DPRINTF("%s: write data offset " TARGET_FMT_lx " %08x %d\n",
__func__, offset, value, width);
p = pfl->storage;
switch (width) {
case 1:
p[offset] &= value;
pflash_update(pfl, offset, 1);
break;
case 2:
#if defined(TARGET_WORDS_BIGENDIAN)
p[offset] &= value >> 8;
p[offset + 1] &= value;
#else
p[offset] &= value;
p[offset + 1] &= value >> 8;
#endif
pflash_update(pfl, offset, 2);
break;
case 4:
#if defined(TARGET_WORDS_BIGENDIAN)
p[offset] &= value >> 24;
p[offset + 1] &= value >> 16;
p[offset + 2] &= value >> 8;
p[offset + 3] &= value;
#else
p[offset] &= value;
p[offset + 1] &= value >> 8;
p[offset + 2] &= value >> 16;
p[offset + 3] &= value >> 24;
#endif
pflash_update(pfl, offset, 4);
break;
}
pfl->status = 0x00 | ~(value & 0x80);
/* Let's pretend write is immediate */
if (pfl->bypass)
goto do_bypass;
goto reset_flash;
case 0x90:
if (pfl->bypass && cmd == 0x00) {
/* Unlock bypass reset */
goto reset_flash;
}
/* We can enter CFI query mode from autoselect mode */
if (boff == 0x55 && cmd == 0x98)
goto enter_CFI_mode;
/* No break here */
default:
DPRINTF("%s: invalid write for command %02x\n",
__func__, pfl->cmd);
goto reset_flash;
}
case 4:
switch (pfl->cmd) {
case 0xA0:
/* Ignore writes while flash data write is occuring */
/* As we suppose write is immediate, this should never happen */
return;
case 0x80:
goto check_unlock1;
default:
/* Should never happen */
DPRINTF("%s: invalid command state %02x (wc 4)\n",
__func__, pfl->cmd);
goto reset_flash;
}
break;
case 5:
switch (cmd) {
case 0x10:
if (boff != 0x555) {
DPRINTF("%s: chip erase: invalid address " TARGET_FMT_lx "\n",
__func__, offset);
goto reset_flash;
}
/* Chip erase */
DPRINTF("%s: start chip erase\n", __func__);
memset(pfl->storage, 0xFF, pfl->total_len);
pfl->status = 0x00;
pflash_update(pfl, 0, pfl->total_len);
/* Let's wait 5 seconds before chip erase is done */
qemu_mod_timer(pfl->timer,
qemu_get_clock(vm_clock) + (ticks_per_sec * 5));
break;
case 0x30:
/* Sector erase */
p = pfl->storage;
offset &= ~(pfl->sector_len - 1);
DPRINTF("%s: start sector erase at " TARGET_FMT_lx "\n", __func__,
offset);
memset(p + offset, 0xFF, pfl->sector_len);
pflash_update(pfl, offset, pfl->sector_len);
pfl->status = 0x00;
/* Let's wait 1/2 second before sector erase is done */
qemu_mod_timer(pfl->timer,
qemu_get_clock(vm_clock) + (ticks_per_sec / 2));
break;
default:
DPRINTF("%s: invalid command %02x (wc 5)\n", __func__, cmd);
goto reset_flash;
}
pfl->cmd = cmd;
break;
case 6:
switch (pfl->cmd) {
case 0x10:
/* Ignore writes during chip erase */
return;
case 0x30:
/* Ignore writes during sector erase */
return;
default:
/* Should never happen */
DPRINTF("%s: invalid command state %02x (wc 6)\n",
__func__, pfl->cmd);
goto reset_flash;
}
break;
case 7: /* Special value for CFI queries */
DPRINTF("%s: invalid write in CFI query mode\n", __func__);
goto reset_flash;
default:
/* Should never happen */
DPRINTF("%s: invalid write state (wc 7)\n", __func__);
goto reset_flash;
}
pfl->wcycle++;
return;
/* Reset flash */
reset_flash:
if (pfl->wcycle != 0) {
cpu_register_physical_memory(pfl->base, pfl->total_len,
pfl->off | IO_MEM_ROMD | pfl->fl_mem);
}
pfl->bypass = 0;
pfl->wcycle = 0;
pfl->cmd = 0;
return;
do_bypass:
pfl->wcycle = 2;
pfl->cmd = 0;
return;
}
| true | qemu | 95d1f3edd5ecebcf8d1b8efe1a0b4533e3629e39 | static void pflash_write (pflash_t *pfl, target_ulong offset, uint32_t value,
int width)
{
target_ulong boff;
uint8_t *p;
uint8_t cmd;
if (pfl->wcycle == 0)
offset -= (target_ulong)(long)pfl->storage;
else
offset -= pfl->base;
cmd = value;
DPRINTF("%s: offset " TARGET_FMT_lx " %08x %d\n", __func__,
offset, value, width);
if (pfl->cmd != 0xA0 && cmd == 0xF0) {
DPRINTF("%s: flash reset asked (%02x %02x)\n",
__func__, pfl->cmd, cmd);
goto reset_flash;
}
cpu_register_physical_memory(pfl->base, pfl->total_len, pfl->fl_mem);
boff = offset & (pfl->sector_len - 1);
if (pfl->width == 2)
boff = boff >> 1;
else if (pfl->width == 4)
boff = boff >> 2;
switch (pfl->wcycle) {
case 0:
check_unlock0:
if (boff == 0x55 && cmd == 0x98) {
enter_CFI_mode:
pfl->wcycle = 7;
pfl->cmd = 0x98;
return;
}
if (boff != 0x555 || cmd != 0xAA) {
DPRINTF("%s: unlock0 failed " TARGET_FMT_lx " %02x %04x\n",
__func__, boff, cmd, 0x555);
goto reset_flash;
}
DPRINTF("%s: unlock sequence started\n", __func__);
break;
case 1:
check_unlock1:
if (boff != 0x2AA || cmd != 0x55) {
DPRINTF("%s: unlock1 failed " TARGET_FMT_lx " %02x\n", __func__,
boff, cmd);
goto reset_flash;
}
DPRINTF("%s: unlock sequence done\n", __func__);
break;
case 2:
if (!pfl->bypass && boff != 0x555) {
DPRINTF("%s: command failed " TARGET_FMT_lx " %02x\n", __func__,
boff, cmd);
goto reset_flash;
}
switch (cmd) {
case 0x20:
pfl->bypass = 1;
goto do_bypass;
case 0x80:
case 0x90:
case 0xA0:
pfl->cmd = cmd;
DPRINTF("%s: starting command %02x\n", __func__, cmd);
break;
default:
DPRINTF("%s: unknown command %02x\n", __func__, cmd);
goto reset_flash;
}
break;
case 3:
switch (pfl->cmd) {
case 0x80:
goto check_unlock0;
case 0xA0:
DPRINTF("%s: write data offset " TARGET_FMT_lx " %08x %d\n",
__func__, offset, value, width);
p = pfl->storage;
switch (width) {
case 1:
p[offset] &= value;
pflash_update(pfl, offset, 1);
break;
case 2:
#if defined(TARGET_WORDS_BIGENDIAN)
p[offset] &= value >> 8;
p[offset + 1] &= value;
#else
p[offset] &= value;
p[offset + 1] &= value >> 8;
#endif
pflash_update(pfl, offset, 2);
break;
case 4:
#if defined(TARGET_WORDS_BIGENDIAN)
p[offset] &= value >> 24;
p[offset + 1] &= value >> 16;
p[offset + 2] &= value >> 8;
p[offset + 3] &= value;
#else
p[offset] &= value;
p[offset + 1] &= value >> 8;
p[offset + 2] &= value >> 16;
p[offset + 3] &= value >> 24;
#endif
pflash_update(pfl, offset, 4);
break;
}
pfl->status = 0x00 | ~(value & 0x80);
if (pfl->bypass)
goto do_bypass;
goto reset_flash;
case 0x90:
if (pfl->bypass && cmd == 0x00) {
goto reset_flash;
}
if (boff == 0x55 && cmd == 0x98)
goto enter_CFI_mode;
default:
DPRINTF("%s: invalid write for command %02x\n",
__func__, pfl->cmd);
goto reset_flash;
}
case 4:
switch (pfl->cmd) {
case 0xA0:
return;
case 0x80:
goto check_unlock1;
default:
DPRINTF("%s: invalid command state %02x (wc 4)\n",
__func__, pfl->cmd);
goto reset_flash;
}
break;
case 5:
switch (cmd) {
case 0x10:
if (boff != 0x555) {
DPRINTF("%s: chip erase: invalid address " TARGET_FMT_lx "\n",
__func__, offset);
goto reset_flash;
}
DPRINTF("%s: start chip erase\n", __func__);
memset(pfl->storage, 0xFF, pfl->total_len);
pfl->status = 0x00;
pflash_update(pfl, 0, pfl->total_len);
qemu_mod_timer(pfl->timer,
qemu_get_clock(vm_clock) + (ticks_per_sec * 5));
break;
case 0x30:
p = pfl->storage;
offset &= ~(pfl->sector_len - 1);
DPRINTF("%s: start sector erase at " TARGET_FMT_lx "\n", __func__,
offset);
memset(p + offset, 0xFF, pfl->sector_len);
pflash_update(pfl, offset, pfl->sector_len);
pfl->status = 0x00;
qemu_mod_timer(pfl->timer,
qemu_get_clock(vm_clock) + (ticks_per_sec / 2));
break;
default:
DPRINTF("%s: invalid command %02x (wc 5)\n", __func__, cmd);
goto reset_flash;
}
pfl->cmd = cmd;
break;
case 6:
switch (pfl->cmd) {
case 0x10:
return;
case 0x30:
return;
default:
DPRINTF("%s: invalid command state %02x (wc 6)\n",
__func__, pfl->cmd);
goto reset_flash;
}
break;
case 7:
DPRINTF("%s: invalid write in CFI query mode\n", __func__);
goto reset_flash;
default:
DPRINTF("%s: invalid write state (wc 7)\n", __func__);
goto reset_flash;
}
pfl->wcycle++;
return;
reset_flash:
if (pfl->wcycle != 0) {
cpu_register_physical_memory(pfl->base, pfl->total_len,
pfl->off | IO_MEM_ROMD | pfl->fl_mem);
}
pfl->bypass = 0;
pfl->wcycle = 0;
pfl->cmd = 0;
return;
do_bypass:
pfl->wcycle = 2;
pfl->cmd = 0;
return;
}
| {
"code": [
" cmd = value;",
" if (pfl->cmd != 0xA0 && cmd == 0xF0) {",
" DPRINTF(\"%s: flash reset asked (%02x %02x)\\n\",",
" __func__, pfl->cmd, cmd);",
" goto reset_flash;",
" if (pfl->wcycle != 0) {",
" cpu_register_physical_memory(pfl->base, pfl->total_len,",
" pfl->off | IO_MEM_ROMD | pfl->fl_mem);"
],
"line_no": [
29,
35,
37,
39,
41,
435,
437,
439
]
} | static void FUNC_0 (pflash_t *VAR_0, target_ulong VAR_1, uint32_t VAR_2,
int VAR_3)
{
target_ulong boff;
uint8_t *p;
uint8_t cmd;
if (VAR_0->wcycle == 0)
VAR_1 -= (target_ulong)(long)VAR_0->storage;
else
VAR_1 -= VAR_0->base;
cmd = VAR_2;
DPRINTF("%s: VAR_1 " TARGET_FMT_lx " %08x %d\n", __func__,
VAR_1, VAR_2, VAR_3);
if (VAR_0->cmd != 0xA0 && cmd == 0xF0) {
DPRINTF("%s: flash reset asked (%02x %02x)\n",
__func__, VAR_0->cmd, cmd);
goto reset_flash;
}
cpu_register_physical_memory(VAR_0->base, VAR_0->total_len, VAR_0->fl_mem);
boff = VAR_1 & (VAR_0->sector_len - 1);
if (VAR_0->VAR_3 == 2)
boff = boff >> 1;
else if (VAR_0->VAR_3 == 4)
boff = boff >> 2;
switch (VAR_0->wcycle) {
case 0:
check_unlock0:
if (boff == 0x55 && cmd == 0x98) {
enter_CFI_mode:
VAR_0->wcycle = 7;
VAR_0->cmd = 0x98;
return;
}
if (boff != 0x555 || cmd != 0xAA) {
DPRINTF("%s: unlock0 failed " TARGET_FMT_lx " %02x %04x\n",
__func__, boff, cmd, 0x555);
goto reset_flash;
}
DPRINTF("%s: unlock sequence started\n", __func__);
break;
case 1:
check_unlock1:
if (boff != 0x2AA || cmd != 0x55) {
DPRINTF("%s: unlock1 failed " TARGET_FMT_lx " %02x\n", __func__,
boff, cmd);
goto reset_flash;
}
DPRINTF("%s: unlock sequence done\n", __func__);
break;
case 2:
if (!VAR_0->bypass && boff != 0x555) {
DPRINTF("%s: command failed " TARGET_FMT_lx " %02x\n", __func__,
boff, cmd);
goto reset_flash;
}
switch (cmd) {
case 0x20:
VAR_0->bypass = 1;
goto do_bypass;
case 0x80:
case 0x90:
case 0xA0:
VAR_0->cmd = cmd;
DPRINTF("%s: starting command %02x\n", __func__, cmd);
break;
default:
DPRINTF("%s: unknown command %02x\n", __func__, cmd);
goto reset_flash;
}
break;
case 3:
switch (VAR_0->cmd) {
case 0x80:
goto check_unlock0;
case 0xA0:
DPRINTF("%s: write data VAR_1 " TARGET_FMT_lx " %08x %d\n",
__func__, VAR_1, VAR_2, VAR_3);
p = VAR_0->storage;
switch (VAR_3) {
case 1:
p[VAR_1] &= VAR_2;
pflash_update(VAR_0, VAR_1, 1);
break;
case 2:
#if defined(TARGET_WORDS_BIGENDIAN)
p[VAR_1] &= VAR_2 >> 8;
p[VAR_1 + 1] &= VAR_2;
#else
p[VAR_1] &= VAR_2;
p[VAR_1 + 1] &= VAR_2 >> 8;
#endif
pflash_update(VAR_0, VAR_1, 2);
break;
case 4:
#if defined(TARGET_WORDS_BIGENDIAN)
p[VAR_1] &= VAR_2 >> 24;
p[VAR_1 + 1] &= VAR_2 >> 16;
p[VAR_1 + 2] &= VAR_2 >> 8;
p[VAR_1 + 3] &= VAR_2;
#else
p[VAR_1] &= VAR_2;
p[VAR_1 + 1] &= VAR_2 >> 8;
p[VAR_1 + 2] &= VAR_2 >> 16;
p[VAR_1 + 3] &= VAR_2 >> 24;
#endif
pflash_update(VAR_0, VAR_1, 4);
break;
}
VAR_0->status = 0x00 | ~(VAR_2 & 0x80);
if (VAR_0->bypass)
goto do_bypass;
goto reset_flash;
case 0x90:
if (VAR_0->bypass && cmd == 0x00) {
goto reset_flash;
}
if (boff == 0x55 && cmd == 0x98)
goto enter_CFI_mode;
default:
DPRINTF("%s: invalid write for command %02x\n",
__func__, VAR_0->cmd);
goto reset_flash;
}
case 4:
switch (VAR_0->cmd) {
case 0xA0:
return;
case 0x80:
goto check_unlock1;
default:
DPRINTF("%s: invalid command state %02x (wc 4)\n",
__func__, VAR_0->cmd);
goto reset_flash;
}
break;
case 5:
switch (cmd) {
case 0x10:
if (boff != 0x555) {
DPRINTF("%s: chip erase: invalid address " TARGET_FMT_lx "\n",
__func__, VAR_1);
goto reset_flash;
}
DPRINTF("%s: start chip erase\n", __func__);
memset(VAR_0->storage, 0xFF, VAR_0->total_len);
VAR_0->status = 0x00;
pflash_update(VAR_0, 0, VAR_0->total_len);
qemu_mod_timer(VAR_0->timer,
qemu_get_clock(vm_clock) + (ticks_per_sec * 5));
break;
case 0x30:
p = VAR_0->storage;
VAR_1 &= ~(VAR_0->sector_len - 1);
DPRINTF("%s: start sector erase at " TARGET_FMT_lx "\n", __func__,
VAR_1);
memset(p + VAR_1, 0xFF, VAR_0->sector_len);
pflash_update(VAR_0, VAR_1, VAR_0->sector_len);
VAR_0->status = 0x00;
qemu_mod_timer(VAR_0->timer,
qemu_get_clock(vm_clock) + (ticks_per_sec / 2));
break;
default:
DPRINTF("%s: invalid command %02x (wc 5)\n", __func__, cmd);
goto reset_flash;
}
VAR_0->cmd = cmd;
break;
case 6:
switch (VAR_0->cmd) {
case 0x10:
return;
case 0x30:
return;
default:
DPRINTF("%s: invalid command state %02x (wc 6)\n",
__func__, VAR_0->cmd);
goto reset_flash;
}
break;
case 7:
DPRINTF("%s: invalid write in CFI query mode\n", __func__);
goto reset_flash;
default:
DPRINTF("%s: invalid write state (wc 7)\n", __func__);
goto reset_flash;
}
VAR_0->wcycle++;
return;
reset_flash:
if (VAR_0->wcycle != 0) {
cpu_register_physical_memory(VAR_0->base, VAR_0->total_len,
VAR_0->off | IO_MEM_ROMD | VAR_0->fl_mem);
}
VAR_0->bypass = 0;
VAR_0->wcycle = 0;
VAR_0->cmd = 0;
return;
do_bypass:
VAR_0->wcycle = 2;
VAR_0->cmd = 0;
return;
}
| [
"static void FUNC_0 (pflash_t *VAR_0, target_ulong VAR_1, uint32_t VAR_2,\nint VAR_3)\n{",
"target_ulong boff;",
"uint8_t *p;",
"uint8_t cmd;",
"if (VAR_0->wcycle == 0)\nVAR_1 -= (target_ulong)(long)VAR_0->storage;",
"else\nVAR_1 -= VAR_0->base;",
"cmd = VAR_2;",
"DPRINTF(\"%s: VAR_1 \" TARGET_FMT_lx \" %08x %d\\n\", __func__,\nVAR_1, VAR_2, VAR_3);",
"if (VAR_0->cmd != 0xA0 && cmd == 0xF0) {",
"DPRINTF(\"%s: flash reset asked (%02x %02x)\\n\",\n__func__, VAR_0->cmd, cmd);",
"goto reset_flash;",
"}",
"cpu_register_physical_memory(VAR_0->base, VAR_0->total_len, VAR_0->fl_mem);",
"boff = VAR_1 & (VAR_0->sector_len - 1);",
"if (VAR_0->VAR_3 == 2)\nboff = boff >> 1;",
"else if (VAR_0->VAR_3 == 4)\nboff = boff >> 2;",
"switch (VAR_0->wcycle) {",
"case 0:\ncheck_unlock0:\nif (boff == 0x55 && cmd == 0x98) {",
"enter_CFI_mode:\nVAR_0->wcycle = 7;",
"VAR_0->cmd = 0x98;",
"return;",
"}",
"if (boff != 0x555 || cmd != 0xAA) {",
"DPRINTF(\"%s: unlock0 failed \" TARGET_FMT_lx \" %02x %04x\\n\",\n__func__, boff, cmd, 0x555);",
"goto reset_flash;",
"}",
"DPRINTF(\"%s: unlock sequence started\\n\", __func__);",
"break;",
"case 1:\ncheck_unlock1:\nif (boff != 0x2AA || cmd != 0x55) {",
"DPRINTF(\"%s: unlock1 failed \" TARGET_FMT_lx \" %02x\\n\", __func__,\nboff, cmd);",
"goto reset_flash;",
"}",
"DPRINTF(\"%s: unlock sequence done\\n\", __func__);",
"break;",
"case 2:\nif (!VAR_0->bypass && boff != 0x555) {",
"DPRINTF(\"%s: command failed \" TARGET_FMT_lx \" %02x\\n\", __func__,\nboff, cmd);",
"goto reset_flash;",
"}",
"switch (cmd) {",
"case 0x20:\nVAR_0->bypass = 1;",
"goto do_bypass;",
"case 0x80:\ncase 0x90:\ncase 0xA0:\nVAR_0->cmd = cmd;",
"DPRINTF(\"%s: starting command %02x\\n\", __func__, cmd);",
"break;",
"default:\nDPRINTF(\"%s: unknown command %02x\\n\", __func__, cmd);",
"goto reset_flash;",
"}",
"break;",
"case 3:\nswitch (VAR_0->cmd) {",
"case 0x80:\ngoto check_unlock0;",
"case 0xA0:\nDPRINTF(\"%s: write data VAR_1 \" TARGET_FMT_lx \" %08x %d\\n\",\n__func__, VAR_1, VAR_2, VAR_3);",
"p = VAR_0->storage;",
"switch (VAR_3) {",
"case 1:\np[VAR_1] &= VAR_2;",
"pflash_update(VAR_0, VAR_1, 1);",
"break;",
"case 2:\n#if defined(TARGET_WORDS_BIGENDIAN)\np[VAR_1] &= VAR_2 >> 8;",
"p[VAR_1 + 1] &= VAR_2;",
"#else\np[VAR_1] &= VAR_2;",
"p[VAR_1 + 1] &= VAR_2 >> 8;",
"#endif\npflash_update(VAR_0, VAR_1, 2);",
"break;",
"case 4:\n#if defined(TARGET_WORDS_BIGENDIAN)\np[VAR_1] &= VAR_2 >> 24;",
"p[VAR_1 + 1] &= VAR_2 >> 16;",
"p[VAR_1 + 2] &= VAR_2 >> 8;",
"p[VAR_1 + 3] &= VAR_2;",
"#else\np[VAR_1] &= VAR_2;",
"p[VAR_1 + 1] &= VAR_2 >> 8;",
"p[VAR_1 + 2] &= VAR_2 >> 16;",
"p[VAR_1 + 3] &= VAR_2 >> 24;",
"#endif\npflash_update(VAR_0, VAR_1, 4);",
"break;",
"}",
"VAR_0->status = 0x00 | ~(VAR_2 & 0x80);",
"if (VAR_0->bypass)\ngoto do_bypass;",
"goto reset_flash;",
"case 0x90:\nif (VAR_0->bypass && cmd == 0x00) {",
"goto reset_flash;",
"}",
"if (boff == 0x55 && cmd == 0x98)\ngoto enter_CFI_mode;",
"default:\nDPRINTF(\"%s: invalid write for command %02x\\n\",\n__func__, VAR_0->cmd);",
"goto reset_flash;",
"}",
"case 4:\nswitch (VAR_0->cmd) {",
"case 0xA0:\nreturn;",
"case 0x80:\ngoto check_unlock1;",
"default:\nDPRINTF(\"%s: invalid command state %02x (wc 4)\\n\",\n__func__, VAR_0->cmd);",
"goto reset_flash;",
"}",
"break;",
"case 5:\nswitch (cmd) {",
"case 0x10:\nif (boff != 0x555) {",
"DPRINTF(\"%s: chip erase: invalid address \" TARGET_FMT_lx \"\\n\",\n__func__, VAR_1);",
"goto reset_flash;",
"}",
"DPRINTF(\"%s: start chip erase\\n\", __func__);",
"memset(VAR_0->storage, 0xFF, VAR_0->total_len);",
"VAR_0->status = 0x00;",
"pflash_update(VAR_0, 0, VAR_0->total_len);",
"qemu_mod_timer(VAR_0->timer,\nqemu_get_clock(vm_clock) + (ticks_per_sec * 5));",
"break;",
"case 0x30:\np = VAR_0->storage;",
"VAR_1 &= ~(VAR_0->sector_len - 1);",
"DPRINTF(\"%s: start sector erase at \" TARGET_FMT_lx \"\\n\", __func__,\nVAR_1);",
"memset(p + VAR_1, 0xFF, VAR_0->sector_len);",
"pflash_update(VAR_0, VAR_1, VAR_0->sector_len);",
"VAR_0->status = 0x00;",
"qemu_mod_timer(VAR_0->timer,\nqemu_get_clock(vm_clock) + (ticks_per_sec / 2));",
"break;",
"default:\nDPRINTF(\"%s: invalid command %02x (wc 5)\\n\", __func__, cmd);",
"goto reset_flash;",
"}",
"VAR_0->cmd = cmd;",
"break;",
"case 6:\nswitch (VAR_0->cmd) {",
"case 0x10:\nreturn;",
"case 0x30:\nreturn;",
"default:\nDPRINTF(\"%s: invalid command state %02x (wc 6)\\n\",\n__func__, VAR_0->cmd);",
"goto reset_flash;",
"}",
"break;",
"case 7:\nDPRINTF(\"%s: invalid write in CFI query mode\\n\", __func__);",
"goto reset_flash;",
"default:\nDPRINTF(\"%s: invalid write state (wc 7)\\n\", __func__);",
"goto reset_flash;",
"}",
"VAR_0->wcycle++;",
"return;",
"reset_flash:\nif (VAR_0->wcycle != 0) {",
"cpu_register_physical_memory(VAR_0->base, VAR_0->total_len,\nVAR_0->off | IO_MEM_ROMD | VAR_0->fl_mem);",
"}",
"VAR_0->bypass = 0;",
"VAR_0->wcycle = 0;",
"VAR_0->cmd = 0;",
"return;",
"do_bypass:\nVAR_0->wcycle = 2;",
"VAR_0->cmd = 0;",
"return;",
"}"
] | [
0,
0,
0,
0,
0,
0,
1,
0,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
19,
21
],
[
23,
25
],
[
29
],
[
31,
33
],
[
35
],
[
37,
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51,
53
],
[
55,
57
],
[
59
],
[
61,
65,
67
],
[
69,
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83,
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95,
99,
101
],
[
103,
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115,
119
],
[
121,
123
],
[
125
],
[
127
],
[
129
],
[
131,
133
],
[
135
],
[
137,
139,
141,
143
],
[
145
],
[
147
],
[
149,
151
],
[
153
],
[
155
],
[
157
],
[
159,
161
],
[
163,
167
],
[
169,
171,
173
],
[
175
],
[
177
],
[
179,
181
],
[
183
],
[
185
],
[
187,
189,
191
],
[
193
],
[
195,
197
],
[
199
],
[
201,
203
],
[
205
],
[
207,
209,
211
],
[
213
],
[
215
],
[
217
],
[
219,
221
],
[
223
],
[
225
],
[
227
],
[
229,
231
],
[
233
],
[
235
],
[
237
],
[
241,
243
],
[
245
],
[
247,
249
],
[
253
],
[
255
],
[
259,
261
],
[
265,
267,
269
],
[
271
],
[
273
],
[
275,
277
],
[
279,
285
],
[
287,
289
],
[
291,
295,
297
],
[
299
],
[
301
],
[
303
],
[
305,
307
],
[
309,
311
],
[
313,
315
],
[
317
],
[
319
],
[
323
],
[
325
],
[
327
],
[
329
],
[
333,
335
],
[
337
],
[
339,
343
],
[
345
],
[
347,
349
],
[
351
],
[
353
],
[
355
],
[
359,
361
],
[
363
],
[
365,
367
],
[
369
],
[
371
],
[
373
],
[
375
],
[
377,
379
],
[
381,
385
],
[
387,
391
],
[
393,
397,
399
],
[
401
],
[
403
],
[
405
],
[
407,
409
],
[
411
],
[
413,
417
],
[
419
],
[
421
],
[
423
],
[
427
],
[
433,
435
],
[
437,
439
],
[
441
],
[
443
],
[
445
],
[
447
],
[
449
],
[
453,
455
],
[
457
],
[
459
],
[
461
]
] |
18,949 | void cpu_loop(CPUPPCState *env)
{
CPUState *cs = CPU(ppc_env_get_cpu(env));
target_siginfo_t info;
int trapnr;
target_ulong ret;
for(;;) {
cpu_exec_start(cs);
trapnr = cpu_ppc_exec(cs);
cpu_exec_end(cs);
switch(trapnr) {
case POWERPC_EXCP_NONE:
/* Just go on */
break;
case POWERPC_EXCP_CRITICAL: /* Critical input */
cpu_abort(cs, "Critical interrupt while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_MCHECK: /* Machine check exception */
cpu_abort(cs, "Machine check exception while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_DSI: /* Data storage exception */
EXCP_DUMP(env, "Invalid data memory access: 0x" TARGET_FMT_lx "\n",
env->spr[SPR_DAR]);
/* XXX: check this. Seems bugged */
switch (env->error_code & 0xFF000000) {
case 0x40000000:
info.si_signo = TARGET_SIGSEGV;
info.si_errno = 0;
info.si_code = TARGET_SEGV_MAPERR;
break;
case 0x04000000:
info.si_signo = TARGET_SIGILL;
info.si_errno = 0;
info.si_code = TARGET_ILL_ILLADR;
break;
case 0x08000000:
info.si_signo = TARGET_SIGSEGV;
info.si_errno = 0;
info.si_code = TARGET_SEGV_ACCERR;
break;
default:
/* Let's send a regular segfault... */
EXCP_DUMP(env, "Invalid segfault errno (%02x)\n",
env->error_code);
info.si_signo = TARGET_SIGSEGV;
info.si_errno = 0;
info.si_code = TARGET_SEGV_MAPERR;
break;
}
info._sifields._sigfault._addr = env->nip;
queue_signal(env, info.si_signo, &info);
break;
case POWERPC_EXCP_ISI: /* Instruction storage exception */
EXCP_DUMP(env, "Invalid instruction fetch: 0x\n" TARGET_FMT_lx
"\n", env->spr[SPR_SRR0]);
/* XXX: check this */
switch (env->error_code & 0xFF000000) {
case 0x40000000:
info.si_signo = TARGET_SIGSEGV;
info.si_errno = 0;
info.si_code = TARGET_SEGV_MAPERR;
break;
case 0x10000000:
case 0x08000000:
info.si_signo = TARGET_SIGSEGV;
info.si_errno = 0;
info.si_code = TARGET_SEGV_ACCERR;
break;
default:
/* Let's send a regular segfault... */
EXCP_DUMP(env, "Invalid segfault errno (%02x)\n",
env->error_code);
info.si_signo = TARGET_SIGSEGV;
info.si_errno = 0;
info.si_code = TARGET_SEGV_MAPERR;
break;
}
info._sifields._sigfault._addr = env->nip - 4;
queue_signal(env, info.si_signo, &info);
break;
case POWERPC_EXCP_EXTERNAL: /* External input */
cpu_abort(cs, "External interrupt while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_ALIGN: /* Alignment exception */
EXCP_DUMP(env, "Unaligned memory access\n");
/* XXX: check this */
info.si_signo = TARGET_SIGBUS;
info.si_errno = 0;
info.si_code = TARGET_BUS_ADRALN;
info._sifields._sigfault._addr = env->nip;
queue_signal(env, info.si_signo, &info);
break;
case POWERPC_EXCP_PROGRAM: /* Program exception */
/* XXX: check this */
switch (env->error_code & ~0xF) {
case POWERPC_EXCP_FP:
EXCP_DUMP(env, "Floating point program exception\n");
info.si_signo = TARGET_SIGFPE;
info.si_errno = 0;
switch (env->error_code & 0xF) {
case POWERPC_EXCP_FP_OX:
info.si_code = TARGET_FPE_FLTOVF;
break;
case POWERPC_EXCP_FP_UX:
info.si_code = TARGET_FPE_FLTUND;
break;
case POWERPC_EXCP_FP_ZX:
case POWERPC_EXCP_FP_VXZDZ:
info.si_code = TARGET_FPE_FLTDIV;
break;
case POWERPC_EXCP_FP_XX:
info.si_code = TARGET_FPE_FLTRES;
break;
case POWERPC_EXCP_FP_VXSOFT:
info.si_code = TARGET_FPE_FLTINV;
break;
case POWERPC_EXCP_FP_VXSNAN:
case POWERPC_EXCP_FP_VXISI:
case POWERPC_EXCP_FP_VXIDI:
case POWERPC_EXCP_FP_VXIMZ:
case POWERPC_EXCP_FP_VXVC:
case POWERPC_EXCP_FP_VXSQRT:
case POWERPC_EXCP_FP_VXCVI:
info.si_code = TARGET_FPE_FLTSUB;
break;
default:
EXCP_DUMP(env, "Unknown floating point exception (%02x)\n",
env->error_code);
break;
}
break;
case POWERPC_EXCP_INVAL:
EXCP_DUMP(env, "Invalid instruction\n");
info.si_signo = TARGET_SIGILL;
info.si_errno = 0;
switch (env->error_code & 0xF) {
case POWERPC_EXCP_INVAL_INVAL:
info.si_code = TARGET_ILL_ILLOPC;
break;
case POWERPC_EXCP_INVAL_LSWX:
info.si_code = TARGET_ILL_ILLOPN;
break;
case POWERPC_EXCP_INVAL_SPR:
info.si_code = TARGET_ILL_PRVREG;
break;
case POWERPC_EXCP_INVAL_FP:
info.si_code = TARGET_ILL_COPROC;
break;
default:
EXCP_DUMP(env, "Unknown invalid operation (%02x)\n",
env->error_code & 0xF);
info.si_code = TARGET_ILL_ILLADR;
break;
}
break;
case POWERPC_EXCP_PRIV:
EXCP_DUMP(env, "Privilege violation\n");
info.si_signo = TARGET_SIGILL;
info.si_errno = 0;
switch (env->error_code & 0xF) {
case POWERPC_EXCP_PRIV_OPC:
info.si_code = TARGET_ILL_PRVOPC;
break;
case POWERPC_EXCP_PRIV_REG:
info.si_code = TARGET_ILL_PRVREG;
break;
default:
EXCP_DUMP(env, "Unknown privilege violation (%02x)\n",
env->error_code & 0xF);
info.si_code = TARGET_ILL_PRVOPC;
break;
}
break;
case POWERPC_EXCP_TRAP:
cpu_abort(cs, "Tried to call a TRAP\n");
break;
default:
/* Should not happen ! */
cpu_abort(cs, "Unknown program exception (%02x)\n",
env->error_code);
break;
}
info._sifields._sigfault._addr = env->nip - 4;
queue_signal(env, info.si_signo, &info);
break;
case POWERPC_EXCP_FPU: /* Floating-point unavailable exception */
EXCP_DUMP(env, "No floating point allowed\n");
info.si_signo = TARGET_SIGILL;
info.si_errno = 0;
info.si_code = TARGET_ILL_COPROC;
info._sifields._sigfault._addr = env->nip - 4;
queue_signal(env, info.si_signo, &info);
break;
case POWERPC_EXCP_SYSCALL: /* System call exception */
cpu_abort(cs, "Syscall exception while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_APU: /* Auxiliary processor unavailable */
EXCP_DUMP(env, "No APU instruction allowed\n");
info.si_signo = TARGET_SIGILL;
info.si_errno = 0;
info.si_code = TARGET_ILL_COPROC;
info._sifields._sigfault._addr = env->nip - 4;
queue_signal(env, info.si_signo, &info);
break;
case POWERPC_EXCP_DECR: /* Decrementer exception */
cpu_abort(cs, "Decrementer interrupt while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_FIT: /* Fixed-interval timer interrupt */
cpu_abort(cs, "Fix interval timer interrupt while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_WDT: /* Watchdog timer interrupt */
cpu_abort(cs, "Watchdog timer interrupt while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_DTLB: /* Data TLB error */
cpu_abort(cs, "Data TLB exception while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_ITLB: /* Instruction TLB error */
cpu_abort(cs, "Instruction TLB exception while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_SPEU: /* SPE/embedded floating-point unavail. */
EXCP_DUMP(env, "No SPE/floating-point instruction allowed\n");
info.si_signo = TARGET_SIGILL;
info.si_errno = 0;
info.si_code = TARGET_ILL_COPROC;
info._sifields._sigfault._addr = env->nip - 4;
queue_signal(env, info.si_signo, &info);
break;
case POWERPC_EXCP_EFPDI: /* Embedded floating-point data IRQ */
cpu_abort(cs, "Embedded floating-point data IRQ not handled\n");
break;
case POWERPC_EXCP_EFPRI: /* Embedded floating-point round IRQ */
cpu_abort(cs, "Embedded floating-point round IRQ not handled\n");
break;
case POWERPC_EXCP_EPERFM: /* Embedded performance monitor IRQ */
cpu_abort(cs, "Performance monitor exception not handled\n");
break;
case POWERPC_EXCP_DOORI: /* Embedded doorbell interrupt */
cpu_abort(cs, "Doorbell interrupt while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_DOORCI: /* Embedded doorbell critical interrupt */
cpu_abort(cs, "Doorbell critical interrupt while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_RESET: /* System reset exception */
cpu_abort(cs, "Reset interrupt while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_DSEG: /* Data segment exception */
cpu_abort(cs, "Data segment exception while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_ISEG: /* Instruction segment exception */
cpu_abort(cs, "Instruction segment exception "
"while in user mode. Aborting\n");
break;
/* PowerPC 64 with hypervisor mode support */
case POWERPC_EXCP_HDECR: /* Hypervisor decrementer exception */
cpu_abort(cs, "Hypervisor decrementer interrupt "
"while in user mode. Aborting\n");
break;
case POWERPC_EXCP_TRACE: /* Trace exception */
/* Nothing to do:
* we use this exception to emulate step-by-step execution mode.
*/
break;
/* PowerPC 64 with hypervisor mode support */
case POWERPC_EXCP_HDSI: /* Hypervisor data storage exception */
cpu_abort(cs, "Hypervisor data storage exception "
"while in user mode. Aborting\n");
break;
case POWERPC_EXCP_HISI: /* Hypervisor instruction storage excp */
cpu_abort(cs, "Hypervisor instruction storage exception "
"while in user mode. Aborting\n");
break;
case POWERPC_EXCP_HDSEG: /* Hypervisor data segment exception */
cpu_abort(cs, "Hypervisor data segment exception "
"while in user mode. Aborting\n");
break;
case POWERPC_EXCP_HISEG: /* Hypervisor instruction segment excp */
cpu_abort(cs, "Hypervisor instruction segment exception "
"while in user mode. Aborting\n");
break;
case POWERPC_EXCP_VPU: /* Vector unavailable exception */
EXCP_DUMP(env, "No Altivec instructions allowed\n");
info.si_signo = TARGET_SIGILL;
info.si_errno = 0;
info.si_code = TARGET_ILL_COPROC;
info._sifields._sigfault._addr = env->nip - 4;
queue_signal(env, info.si_signo, &info);
break;
case POWERPC_EXCP_PIT: /* Programmable interval timer IRQ */
cpu_abort(cs, "Programmable interval timer interrupt "
"while in user mode. Aborting\n");
break;
case POWERPC_EXCP_IO: /* IO error exception */
cpu_abort(cs, "IO error exception while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_RUNM: /* Run mode exception */
cpu_abort(cs, "Run mode exception while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_EMUL: /* Emulation trap exception */
cpu_abort(cs, "Emulation trap exception not handled\n");
break;
case POWERPC_EXCP_IFTLB: /* Instruction fetch TLB error */
cpu_abort(cs, "Instruction fetch TLB exception "
"while in user-mode. Aborting");
break;
case POWERPC_EXCP_DLTLB: /* Data load TLB miss */
cpu_abort(cs, "Data load TLB exception while in user-mode. "
"Aborting");
break;
case POWERPC_EXCP_DSTLB: /* Data store TLB miss */
cpu_abort(cs, "Data store TLB exception while in user-mode. "
"Aborting");
break;
case POWERPC_EXCP_FPA: /* Floating-point assist exception */
cpu_abort(cs, "Floating-point assist exception not handled\n");
break;
case POWERPC_EXCP_IABR: /* Instruction address breakpoint */
cpu_abort(cs, "Instruction address breakpoint exception "
"not handled\n");
break;
case POWERPC_EXCP_SMI: /* System management interrupt */
cpu_abort(cs, "System management interrupt while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_THERM: /* Thermal interrupt */
cpu_abort(cs, "Thermal interrupt interrupt while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_PERFM: /* Embedded performance monitor IRQ */
cpu_abort(cs, "Performance monitor exception not handled\n");
break;
case POWERPC_EXCP_VPUA: /* Vector assist exception */
cpu_abort(cs, "Vector assist exception not handled\n");
break;
case POWERPC_EXCP_SOFTP: /* Soft patch exception */
cpu_abort(cs, "Soft patch exception not handled\n");
break;
case POWERPC_EXCP_MAINT: /* Maintenance exception */
cpu_abort(cs, "Maintenance exception while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_STOP: /* stop translation */
/* We did invalidate the instruction cache. Go on */
break;
case POWERPC_EXCP_BRANCH: /* branch instruction: */
/* We just stopped because of a branch. Go on */
break;
case POWERPC_EXCP_SYSCALL_USER:
/* system call in user-mode emulation */
/* WARNING:
* PPC ABI uses overflow flag in cr0 to signal an error
* in syscalls.
*/
env->crf[0] &= ~0x1;
ret = do_syscall(env, env->gpr[0], env->gpr[3], env->gpr[4],
env->gpr[5], env->gpr[6], env->gpr[7],
env->gpr[8], 0, 0);
if (ret == -TARGET_ERESTARTSYS) {
env->nip -= 4;
break;
}
if (ret == (target_ulong)(-TARGET_QEMU_ESIGRETURN)) {
/* Returning from a successful sigreturn syscall.
Avoid corrupting register state. */
break;
}
if (ret > (target_ulong)(-515)) {
env->crf[0] |= 0x1;
ret = -ret;
}
env->gpr[3] = ret;
break;
case POWERPC_EXCP_STCX:
if (do_store_exclusive(env)) {
info.si_signo = TARGET_SIGSEGV;
info.si_errno = 0;
info.si_code = TARGET_SEGV_MAPERR;
info._sifields._sigfault._addr = env->nip;
queue_signal(env, info.si_signo, &info);
}
break;
case EXCP_DEBUG:
{
int sig;
sig = gdb_handlesig(cs, TARGET_SIGTRAP);
if (sig) {
info.si_signo = sig;
info.si_errno = 0;
info.si_code = TARGET_TRAP_BRKPT;
queue_signal(env, info.si_signo, &info);
}
}
break;
case EXCP_INTERRUPT:
/* just indicate that signals should be handled asap */
break;
default:
cpu_abort(cs, "Unknown exception 0x%d. Aborting\n", trapnr);
break;
}
process_pending_signals(env);
}
} | true | qemu | 9b2fadda3e0196ffd485adde4fe9cdd6fae35300 | void cpu_loop(CPUPPCState *env)
{
CPUState *cs = CPU(ppc_env_get_cpu(env));
target_siginfo_t info;
int trapnr;
target_ulong ret;
for(;;) {
cpu_exec_start(cs);
trapnr = cpu_ppc_exec(cs);
cpu_exec_end(cs);
switch(trapnr) {
case POWERPC_EXCP_NONE:
break;
case POWERPC_EXCP_CRITICAL:
cpu_abort(cs, "Critical interrupt while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_MCHECK:
cpu_abort(cs, "Machine check exception while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_DSI:
EXCP_DUMP(env, "Invalid data memory access: 0x" TARGET_FMT_lx "\n",
env->spr[SPR_DAR]);
switch (env->error_code & 0xFF000000) {
case 0x40000000:
info.si_signo = TARGET_SIGSEGV;
info.si_errno = 0;
info.si_code = TARGET_SEGV_MAPERR;
break;
case 0x04000000:
info.si_signo = TARGET_SIGILL;
info.si_errno = 0;
info.si_code = TARGET_ILL_ILLADR;
break;
case 0x08000000:
info.si_signo = TARGET_SIGSEGV;
info.si_errno = 0;
info.si_code = TARGET_SEGV_ACCERR;
break;
default:
EXCP_DUMP(env, "Invalid segfault errno (%02x)\n",
env->error_code);
info.si_signo = TARGET_SIGSEGV;
info.si_errno = 0;
info.si_code = TARGET_SEGV_MAPERR;
break;
}
info._sifields._sigfault._addr = env->nip;
queue_signal(env, info.si_signo, &info);
break;
case POWERPC_EXCP_ISI:
EXCP_DUMP(env, "Invalid instruction fetch: 0x\n" TARGET_FMT_lx
"\n", env->spr[SPR_SRR0]);
switch (env->error_code & 0xFF000000) {
case 0x40000000:
info.si_signo = TARGET_SIGSEGV;
info.si_errno = 0;
info.si_code = TARGET_SEGV_MAPERR;
break;
case 0x10000000:
case 0x08000000:
info.si_signo = TARGET_SIGSEGV;
info.si_errno = 0;
info.si_code = TARGET_SEGV_ACCERR;
break;
default:
EXCP_DUMP(env, "Invalid segfault errno (%02x)\n",
env->error_code);
info.si_signo = TARGET_SIGSEGV;
info.si_errno = 0;
info.si_code = TARGET_SEGV_MAPERR;
break;
}
info._sifields._sigfault._addr = env->nip - 4;
queue_signal(env, info.si_signo, &info);
break;
case POWERPC_EXCP_EXTERNAL:
cpu_abort(cs, "External interrupt while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_ALIGN:
EXCP_DUMP(env, "Unaligned memory access\n");
info.si_signo = TARGET_SIGBUS;
info.si_errno = 0;
info.si_code = TARGET_BUS_ADRALN;
info._sifields._sigfault._addr = env->nip;
queue_signal(env, info.si_signo, &info);
break;
case POWERPC_EXCP_PROGRAM:
switch (env->error_code & ~0xF) {
case POWERPC_EXCP_FP:
EXCP_DUMP(env, "Floating point program exception\n");
info.si_signo = TARGET_SIGFPE;
info.si_errno = 0;
switch (env->error_code & 0xF) {
case POWERPC_EXCP_FP_OX:
info.si_code = TARGET_FPE_FLTOVF;
break;
case POWERPC_EXCP_FP_UX:
info.si_code = TARGET_FPE_FLTUND;
break;
case POWERPC_EXCP_FP_ZX:
case POWERPC_EXCP_FP_VXZDZ:
info.si_code = TARGET_FPE_FLTDIV;
break;
case POWERPC_EXCP_FP_XX:
info.si_code = TARGET_FPE_FLTRES;
break;
case POWERPC_EXCP_FP_VXSOFT:
info.si_code = TARGET_FPE_FLTINV;
break;
case POWERPC_EXCP_FP_VXSNAN:
case POWERPC_EXCP_FP_VXISI:
case POWERPC_EXCP_FP_VXIDI:
case POWERPC_EXCP_FP_VXIMZ:
case POWERPC_EXCP_FP_VXVC:
case POWERPC_EXCP_FP_VXSQRT:
case POWERPC_EXCP_FP_VXCVI:
info.si_code = TARGET_FPE_FLTSUB;
break;
default:
EXCP_DUMP(env, "Unknown floating point exception (%02x)\n",
env->error_code);
break;
}
break;
case POWERPC_EXCP_INVAL:
EXCP_DUMP(env, "Invalid instruction\n");
info.si_signo = TARGET_SIGILL;
info.si_errno = 0;
switch (env->error_code & 0xF) {
case POWERPC_EXCP_INVAL_INVAL:
info.si_code = TARGET_ILL_ILLOPC;
break;
case POWERPC_EXCP_INVAL_LSWX:
info.si_code = TARGET_ILL_ILLOPN;
break;
case POWERPC_EXCP_INVAL_SPR:
info.si_code = TARGET_ILL_PRVREG;
break;
case POWERPC_EXCP_INVAL_FP:
info.si_code = TARGET_ILL_COPROC;
break;
default:
EXCP_DUMP(env, "Unknown invalid operation (%02x)\n",
env->error_code & 0xF);
info.si_code = TARGET_ILL_ILLADR;
break;
}
break;
case POWERPC_EXCP_PRIV:
EXCP_DUMP(env, "Privilege violation\n");
info.si_signo = TARGET_SIGILL;
info.si_errno = 0;
switch (env->error_code & 0xF) {
case POWERPC_EXCP_PRIV_OPC:
info.si_code = TARGET_ILL_PRVOPC;
break;
case POWERPC_EXCP_PRIV_REG:
info.si_code = TARGET_ILL_PRVREG;
break;
default:
EXCP_DUMP(env, "Unknown privilege violation (%02x)\n",
env->error_code & 0xF);
info.si_code = TARGET_ILL_PRVOPC;
break;
}
break;
case POWERPC_EXCP_TRAP:
cpu_abort(cs, "Tried to call a TRAP\n");
break;
default:
cpu_abort(cs, "Unknown program exception (%02x)\n",
env->error_code);
break;
}
info._sifields._sigfault._addr = env->nip - 4;
queue_signal(env, info.si_signo, &info);
break;
case POWERPC_EXCP_FPU:
EXCP_DUMP(env, "No floating point allowed\n");
info.si_signo = TARGET_SIGILL;
info.si_errno = 0;
info.si_code = TARGET_ILL_COPROC;
info._sifields._sigfault._addr = env->nip - 4;
queue_signal(env, info.si_signo, &info);
break;
case POWERPC_EXCP_SYSCALL:
cpu_abort(cs, "Syscall exception while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_APU:
EXCP_DUMP(env, "No APU instruction allowed\n");
info.si_signo = TARGET_SIGILL;
info.si_errno = 0;
info.si_code = TARGET_ILL_COPROC;
info._sifields._sigfault._addr = env->nip - 4;
queue_signal(env, info.si_signo, &info);
break;
case POWERPC_EXCP_DECR:
cpu_abort(cs, "Decrementer interrupt while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_FIT:
cpu_abort(cs, "Fix interval timer interrupt while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_WDT:
cpu_abort(cs, "Watchdog timer interrupt while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_DTLB:
cpu_abort(cs, "Data TLB exception while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_ITLB:
cpu_abort(cs, "Instruction TLB exception while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_SPEU:
EXCP_DUMP(env, "No SPE/floating-point instruction allowed\n");
info.si_signo = TARGET_SIGILL;
info.si_errno = 0;
info.si_code = TARGET_ILL_COPROC;
info._sifields._sigfault._addr = env->nip - 4;
queue_signal(env, info.si_signo, &info);
break;
case POWERPC_EXCP_EFPDI:
cpu_abort(cs, "Embedded floating-point data IRQ not handled\n");
break;
case POWERPC_EXCP_EFPRI:
cpu_abort(cs, "Embedded floating-point round IRQ not handled\n");
break;
case POWERPC_EXCP_EPERFM:
cpu_abort(cs, "Performance monitor exception not handled\n");
break;
case POWERPC_EXCP_DOORI:
cpu_abort(cs, "Doorbell interrupt while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_DOORCI:
cpu_abort(cs, "Doorbell critical interrupt while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_RESET:
cpu_abort(cs, "Reset interrupt while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_DSEG:
cpu_abort(cs, "Data segment exception while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_ISEG:
cpu_abort(cs, "Instruction segment exception "
"while in user mode. Aborting\n");
break;
case POWERPC_EXCP_HDECR:
cpu_abort(cs, "Hypervisor decrementer interrupt "
"while in user mode. Aborting\n");
break;
case POWERPC_EXCP_TRACE:
break;
case POWERPC_EXCP_HDSI:
cpu_abort(cs, "Hypervisor data storage exception "
"while in user mode. Aborting\n");
break;
case POWERPC_EXCP_HISI:
cpu_abort(cs, "Hypervisor instruction storage exception "
"while in user mode. Aborting\n");
break;
case POWERPC_EXCP_HDSEG:
cpu_abort(cs, "Hypervisor data segment exception "
"while in user mode. Aborting\n");
break;
case POWERPC_EXCP_HISEG:
cpu_abort(cs, "Hypervisor instruction segment exception "
"while in user mode. Aborting\n");
break;
case POWERPC_EXCP_VPU:
EXCP_DUMP(env, "No Altivec instructions allowed\n");
info.si_signo = TARGET_SIGILL;
info.si_errno = 0;
info.si_code = TARGET_ILL_COPROC;
info._sifields._sigfault._addr = env->nip - 4;
queue_signal(env, info.si_signo, &info);
break;
case POWERPC_EXCP_PIT:
cpu_abort(cs, "Programmable interval timer interrupt "
"while in user mode. Aborting\n");
break;
case POWERPC_EXCP_IO:
cpu_abort(cs, "IO error exception while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_RUNM:
cpu_abort(cs, "Run mode exception while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_EMUL:
cpu_abort(cs, "Emulation trap exception not handled\n");
break;
case POWERPC_EXCP_IFTLB:
cpu_abort(cs, "Instruction fetch TLB exception "
"while in user-mode. Aborting");
break;
case POWERPC_EXCP_DLTLB:
cpu_abort(cs, "Data load TLB exception while in user-mode. "
"Aborting");
break;
case POWERPC_EXCP_DSTLB:
cpu_abort(cs, "Data store TLB exception while in user-mode. "
"Aborting");
break;
case POWERPC_EXCP_FPA:
cpu_abort(cs, "Floating-point assist exception not handled\n");
break;
case POWERPC_EXCP_IABR:
cpu_abort(cs, "Instruction address breakpoint exception "
"not handled\n");
break;
case POWERPC_EXCP_SMI:
cpu_abort(cs, "System management interrupt while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_THERM:
cpu_abort(cs, "Thermal interrupt interrupt while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_PERFM:
cpu_abort(cs, "Performance monitor exception not handled\n");
break;
case POWERPC_EXCP_VPUA:
cpu_abort(cs, "Vector assist exception not handled\n");
break;
case POWERPC_EXCP_SOFTP:
cpu_abort(cs, "Soft patch exception not handled\n");
break;
case POWERPC_EXCP_MAINT:
cpu_abort(cs, "Maintenance exception while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_STOP:
break;
case POWERPC_EXCP_BRANCH:
break;
case POWERPC_EXCP_SYSCALL_USER:
env->crf[0] &= ~0x1;
ret = do_syscall(env, env->gpr[0], env->gpr[3], env->gpr[4],
env->gpr[5], env->gpr[6], env->gpr[7],
env->gpr[8], 0, 0);
if (ret == -TARGET_ERESTARTSYS) {
env->nip -= 4;
break;
}
if (ret == (target_ulong)(-TARGET_QEMU_ESIGRETURN)) {
break;
}
if (ret > (target_ulong)(-515)) {
env->crf[0] |= 0x1;
ret = -ret;
}
env->gpr[3] = ret;
break;
case POWERPC_EXCP_STCX:
if (do_store_exclusive(env)) {
info.si_signo = TARGET_SIGSEGV;
info.si_errno = 0;
info.si_code = TARGET_SEGV_MAPERR;
info._sifields._sigfault._addr = env->nip;
queue_signal(env, info.si_signo, &info);
}
break;
case EXCP_DEBUG:
{
int sig;
sig = gdb_handlesig(cs, TARGET_SIGTRAP);
if (sig) {
info.si_signo = sig;
info.si_errno = 0;
info.si_code = TARGET_TRAP_BRKPT;
queue_signal(env, info.si_signo, &info);
}
}
break;
case EXCP_INTERRUPT:
break;
default:
cpu_abort(cs, "Unknown exception 0x%d. Aborting\n", trapnr);
break;
}
process_pending_signals(env);
}
} | {
"code": [],
"line_no": []
} | void FUNC_0(CPUPPCState *VAR_0)
{
CPUState *cs = CPU(ppc_env_get_cpu(VAR_0));
target_siginfo_t info;
int VAR_1;
target_ulong ret;
for(;;) {
cpu_exec_start(cs);
VAR_1 = cpu_ppc_exec(cs);
cpu_exec_end(cs);
switch(VAR_1) {
case POWERPC_EXCP_NONE:
break;
case POWERPC_EXCP_CRITICAL:
cpu_abort(cs, "Critical interrupt while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_MCHECK:
cpu_abort(cs, "Machine check exception while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_DSI:
EXCP_DUMP(VAR_0, "Invalid data memory access: 0x" TARGET_FMT_lx "\n",
VAR_0->spr[SPR_DAR]);
switch (VAR_0->error_code & 0xFF000000) {
case 0x40000000:
info.si_signo = TARGET_SIGSEGV;
info.si_errno = 0;
info.si_code = TARGET_SEGV_MAPERR;
break;
case 0x04000000:
info.si_signo = TARGET_SIGILL;
info.si_errno = 0;
info.si_code = TARGET_ILL_ILLADR;
break;
case 0x08000000:
info.si_signo = TARGET_SIGSEGV;
info.si_errno = 0;
info.si_code = TARGET_SEGV_ACCERR;
break;
default:
EXCP_DUMP(VAR_0, "Invalid segfault errno (%02x)\n",
VAR_0->error_code);
info.si_signo = TARGET_SIGSEGV;
info.si_errno = 0;
info.si_code = TARGET_SEGV_MAPERR;
break;
}
info._sifields._sigfault._addr = VAR_0->nip;
queue_signal(VAR_0, info.si_signo, &info);
break;
case POWERPC_EXCP_ISI:
EXCP_DUMP(VAR_0, "Invalid instruction fetch: 0x\n" TARGET_FMT_lx
"\n", VAR_0->spr[SPR_SRR0]);
switch (VAR_0->error_code & 0xFF000000) {
case 0x40000000:
info.si_signo = TARGET_SIGSEGV;
info.si_errno = 0;
info.si_code = TARGET_SEGV_MAPERR;
break;
case 0x10000000:
case 0x08000000:
info.si_signo = TARGET_SIGSEGV;
info.si_errno = 0;
info.si_code = TARGET_SEGV_ACCERR;
break;
default:
EXCP_DUMP(VAR_0, "Invalid segfault errno (%02x)\n",
VAR_0->error_code);
info.si_signo = TARGET_SIGSEGV;
info.si_errno = 0;
info.si_code = TARGET_SEGV_MAPERR;
break;
}
info._sifields._sigfault._addr = VAR_0->nip - 4;
queue_signal(VAR_0, info.si_signo, &info);
break;
case POWERPC_EXCP_EXTERNAL:
cpu_abort(cs, "External interrupt while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_ALIGN:
EXCP_DUMP(VAR_0, "Unaligned memory access\n");
info.si_signo = TARGET_SIGBUS;
info.si_errno = 0;
info.si_code = TARGET_BUS_ADRALN;
info._sifields._sigfault._addr = VAR_0->nip;
queue_signal(VAR_0, info.si_signo, &info);
break;
case POWERPC_EXCP_PROGRAM:
switch (VAR_0->error_code & ~0xF) {
case POWERPC_EXCP_FP:
EXCP_DUMP(VAR_0, "Floating point program exception\n");
info.si_signo = TARGET_SIGFPE;
info.si_errno = 0;
switch (VAR_0->error_code & 0xF) {
case POWERPC_EXCP_FP_OX:
info.si_code = TARGET_FPE_FLTOVF;
break;
case POWERPC_EXCP_FP_UX:
info.si_code = TARGET_FPE_FLTUND;
break;
case POWERPC_EXCP_FP_ZX:
case POWERPC_EXCP_FP_VXZDZ:
info.si_code = TARGET_FPE_FLTDIV;
break;
case POWERPC_EXCP_FP_XX:
info.si_code = TARGET_FPE_FLTRES;
break;
case POWERPC_EXCP_FP_VXSOFT:
info.si_code = TARGET_FPE_FLTINV;
break;
case POWERPC_EXCP_FP_VXSNAN:
case POWERPC_EXCP_FP_VXISI:
case POWERPC_EXCP_FP_VXIDI:
case POWERPC_EXCP_FP_VXIMZ:
case POWERPC_EXCP_FP_VXVC:
case POWERPC_EXCP_FP_VXSQRT:
case POWERPC_EXCP_FP_VXCVI:
info.si_code = TARGET_FPE_FLTSUB;
break;
default:
EXCP_DUMP(VAR_0, "Unknown floating point exception (%02x)\n",
VAR_0->error_code);
break;
}
break;
case POWERPC_EXCP_INVAL:
EXCP_DUMP(VAR_0, "Invalid instruction\n");
info.si_signo = TARGET_SIGILL;
info.si_errno = 0;
switch (VAR_0->error_code & 0xF) {
case POWERPC_EXCP_INVAL_INVAL:
info.si_code = TARGET_ILL_ILLOPC;
break;
case POWERPC_EXCP_INVAL_LSWX:
info.si_code = TARGET_ILL_ILLOPN;
break;
case POWERPC_EXCP_INVAL_SPR:
info.si_code = TARGET_ILL_PRVREG;
break;
case POWERPC_EXCP_INVAL_FP:
info.si_code = TARGET_ILL_COPROC;
break;
default:
EXCP_DUMP(VAR_0, "Unknown invalid operation (%02x)\n",
VAR_0->error_code & 0xF);
info.si_code = TARGET_ILL_ILLADR;
break;
}
break;
case POWERPC_EXCP_PRIV:
EXCP_DUMP(VAR_0, "Privilege violation\n");
info.si_signo = TARGET_SIGILL;
info.si_errno = 0;
switch (VAR_0->error_code & 0xF) {
case POWERPC_EXCP_PRIV_OPC:
info.si_code = TARGET_ILL_PRVOPC;
break;
case POWERPC_EXCP_PRIV_REG:
info.si_code = TARGET_ILL_PRVREG;
break;
default:
EXCP_DUMP(VAR_0, "Unknown privilege violation (%02x)\n",
VAR_0->error_code & 0xF);
info.si_code = TARGET_ILL_PRVOPC;
break;
}
break;
case POWERPC_EXCP_TRAP:
cpu_abort(cs, "Tried to call a TRAP\n");
break;
default:
cpu_abort(cs, "Unknown program exception (%02x)\n",
VAR_0->error_code);
break;
}
info._sifields._sigfault._addr = VAR_0->nip - 4;
queue_signal(VAR_0, info.si_signo, &info);
break;
case POWERPC_EXCP_FPU:
EXCP_DUMP(VAR_0, "No floating point allowed\n");
info.si_signo = TARGET_SIGILL;
info.si_errno = 0;
info.si_code = TARGET_ILL_COPROC;
info._sifields._sigfault._addr = VAR_0->nip - 4;
queue_signal(VAR_0, info.si_signo, &info);
break;
case POWERPC_EXCP_SYSCALL:
cpu_abort(cs, "Syscall exception while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_APU:
EXCP_DUMP(VAR_0, "No APU instruction allowed\n");
info.si_signo = TARGET_SIGILL;
info.si_errno = 0;
info.si_code = TARGET_ILL_COPROC;
info._sifields._sigfault._addr = VAR_0->nip - 4;
queue_signal(VAR_0, info.si_signo, &info);
break;
case POWERPC_EXCP_DECR:
cpu_abort(cs, "Decrementer interrupt while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_FIT:
cpu_abort(cs, "Fix interval timer interrupt while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_WDT:
cpu_abort(cs, "Watchdog timer interrupt while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_DTLB:
cpu_abort(cs, "Data TLB exception while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_ITLB:
cpu_abort(cs, "Instruction TLB exception while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_SPEU:
EXCP_DUMP(VAR_0, "No SPE/floating-point instruction allowed\n");
info.si_signo = TARGET_SIGILL;
info.si_errno = 0;
info.si_code = TARGET_ILL_COPROC;
info._sifields._sigfault._addr = VAR_0->nip - 4;
queue_signal(VAR_0, info.si_signo, &info);
break;
case POWERPC_EXCP_EFPDI:
cpu_abort(cs, "Embedded floating-point data IRQ not handled\n");
break;
case POWERPC_EXCP_EFPRI:
cpu_abort(cs, "Embedded floating-point round IRQ not handled\n");
break;
case POWERPC_EXCP_EPERFM:
cpu_abort(cs, "Performance monitor exception not handled\n");
break;
case POWERPC_EXCP_DOORI:
cpu_abort(cs, "Doorbell interrupt while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_DOORCI:
cpu_abort(cs, "Doorbell critical interrupt while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_RESET:
cpu_abort(cs, "Reset interrupt while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_DSEG:
cpu_abort(cs, "Data segment exception while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_ISEG:
cpu_abort(cs, "Instruction segment exception "
"while in user mode. Aborting\n");
break;
case POWERPC_EXCP_HDECR:
cpu_abort(cs, "Hypervisor decrementer interrupt "
"while in user mode. Aborting\n");
break;
case POWERPC_EXCP_TRACE:
break;
case POWERPC_EXCP_HDSI:
cpu_abort(cs, "Hypervisor data storage exception "
"while in user mode. Aborting\n");
break;
case POWERPC_EXCP_HISI:
cpu_abort(cs, "Hypervisor instruction storage exception "
"while in user mode. Aborting\n");
break;
case POWERPC_EXCP_HDSEG:
cpu_abort(cs, "Hypervisor data segment exception "
"while in user mode. Aborting\n");
break;
case POWERPC_EXCP_HISEG:
cpu_abort(cs, "Hypervisor instruction segment exception "
"while in user mode. Aborting\n");
break;
case POWERPC_EXCP_VPU:
EXCP_DUMP(VAR_0, "No Altivec instructions allowed\n");
info.si_signo = TARGET_SIGILL;
info.si_errno = 0;
info.si_code = TARGET_ILL_COPROC;
info._sifields._sigfault._addr = VAR_0->nip - 4;
queue_signal(VAR_0, info.si_signo, &info);
break;
case POWERPC_EXCP_PIT:
cpu_abort(cs, "Programmable interval timer interrupt "
"while in user mode. Aborting\n");
break;
case POWERPC_EXCP_IO:
cpu_abort(cs, "IO error exception while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_RUNM:
cpu_abort(cs, "Run mode exception while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_EMUL:
cpu_abort(cs, "Emulation trap exception not handled\n");
break;
case POWERPC_EXCP_IFTLB:
cpu_abort(cs, "Instruction fetch TLB exception "
"while in user-mode. Aborting");
break;
case POWERPC_EXCP_DLTLB:
cpu_abort(cs, "Data load TLB exception while in user-mode. "
"Aborting");
break;
case POWERPC_EXCP_DSTLB:
cpu_abort(cs, "Data store TLB exception while in user-mode. "
"Aborting");
break;
case POWERPC_EXCP_FPA:
cpu_abort(cs, "Floating-point assist exception not handled\n");
break;
case POWERPC_EXCP_IABR:
cpu_abort(cs, "Instruction address breakpoint exception "
"not handled\n");
break;
case POWERPC_EXCP_SMI:
cpu_abort(cs, "System management interrupt while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_THERM:
cpu_abort(cs, "Thermal interrupt interrupt while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_PERFM:
cpu_abort(cs, "Performance monitor exception not handled\n");
break;
case POWERPC_EXCP_VPUA:
cpu_abort(cs, "Vector assist exception not handled\n");
break;
case POWERPC_EXCP_SOFTP:
cpu_abort(cs, "Soft patch exception not handled\n");
break;
case POWERPC_EXCP_MAINT:
cpu_abort(cs, "Maintenance exception while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_STOP:
break;
case POWERPC_EXCP_BRANCH:
break;
case POWERPC_EXCP_SYSCALL_USER:
VAR_0->crf[0] &= ~0x1;
ret = do_syscall(VAR_0, VAR_0->gpr[0], VAR_0->gpr[3], VAR_0->gpr[4],
VAR_0->gpr[5], VAR_0->gpr[6], VAR_0->gpr[7],
VAR_0->gpr[8], 0, 0);
if (ret == -TARGET_ERESTARTSYS) {
VAR_0->nip -= 4;
break;
}
if (ret == (target_ulong)(-TARGET_QEMU_ESIGRETURN)) {
break;
}
if (ret > (target_ulong)(-515)) {
VAR_0->crf[0] |= 0x1;
ret = -ret;
}
VAR_0->gpr[3] = ret;
break;
case POWERPC_EXCP_STCX:
if (do_store_exclusive(VAR_0)) {
info.si_signo = TARGET_SIGSEGV;
info.si_errno = 0;
info.si_code = TARGET_SEGV_MAPERR;
info._sifields._sigfault._addr = VAR_0->nip;
queue_signal(VAR_0, info.si_signo, &info);
}
break;
case EXCP_DEBUG:
{
int VAR_2;
VAR_2 = gdb_handlesig(cs, TARGET_SIGTRAP);
if (VAR_2) {
info.si_signo = VAR_2;
info.si_errno = 0;
info.si_code = TARGET_TRAP_BRKPT;
queue_signal(VAR_0, info.si_signo, &info);
}
}
break;
case EXCP_INTERRUPT:
break;
default:
cpu_abort(cs, "Unknown exception 0x%d. Aborting\n", VAR_1);
break;
}
process_pending_signals(VAR_0);
}
} | [
"void FUNC_0(CPUPPCState *VAR_0)\n{",
"CPUState *cs = CPU(ppc_env_get_cpu(VAR_0));",
"target_siginfo_t info;",
"int VAR_1;",
"target_ulong ret;",
"for(;;) {",
"cpu_exec_start(cs);",
"VAR_1 = cpu_ppc_exec(cs);",
"cpu_exec_end(cs);",
"switch(VAR_1) {",
"case POWERPC_EXCP_NONE:\nbreak;",
"case POWERPC_EXCP_CRITICAL:\ncpu_abort(cs, \"Critical interrupt while in user mode. \"\n\"Aborting\\n\");",
"break;",
"case POWERPC_EXCP_MCHECK:\ncpu_abort(cs, \"Machine check exception while in user mode. \"\n\"Aborting\\n\");",
"break;",
"case POWERPC_EXCP_DSI:\nEXCP_DUMP(VAR_0, \"Invalid data memory access: 0x\" TARGET_FMT_lx \"\\n\",\nVAR_0->spr[SPR_DAR]);",
"switch (VAR_0->error_code & 0xFF000000) {",
"case 0x40000000:\ninfo.si_signo = TARGET_SIGSEGV;",
"info.si_errno = 0;",
"info.si_code = TARGET_SEGV_MAPERR;",
"break;",
"case 0x04000000:\ninfo.si_signo = TARGET_SIGILL;",
"info.si_errno = 0;",
"info.si_code = TARGET_ILL_ILLADR;",
"break;",
"case 0x08000000:\ninfo.si_signo = TARGET_SIGSEGV;",
"info.si_errno = 0;",
"info.si_code = TARGET_SEGV_ACCERR;",
"break;",
"default:\nEXCP_DUMP(VAR_0, \"Invalid segfault errno (%02x)\\n\",\nVAR_0->error_code);",
"info.si_signo = TARGET_SIGSEGV;",
"info.si_errno = 0;",
"info.si_code = TARGET_SEGV_MAPERR;",
"break;",
"}",
"info._sifields._sigfault._addr = VAR_0->nip;",
"queue_signal(VAR_0, info.si_signo, &info);",
"break;",
"case POWERPC_EXCP_ISI:\nEXCP_DUMP(VAR_0, \"Invalid instruction fetch: 0x\\n\" TARGET_FMT_lx\n\"\\n\", VAR_0->spr[SPR_SRR0]);",
"switch (VAR_0->error_code & 0xFF000000) {",
"case 0x40000000:\ninfo.si_signo = TARGET_SIGSEGV;",
"info.si_errno = 0;",
"info.si_code = TARGET_SEGV_MAPERR;",
"break;",
"case 0x10000000:\ncase 0x08000000:\ninfo.si_signo = TARGET_SIGSEGV;",
"info.si_errno = 0;",
"info.si_code = TARGET_SEGV_ACCERR;",
"break;",
"default:\nEXCP_DUMP(VAR_0, \"Invalid segfault errno (%02x)\\n\",\nVAR_0->error_code);",
"info.si_signo = TARGET_SIGSEGV;",
"info.si_errno = 0;",
"info.si_code = TARGET_SEGV_MAPERR;",
"break;",
"}",
"info._sifields._sigfault._addr = VAR_0->nip - 4;",
"queue_signal(VAR_0, info.si_signo, &info);",
"break;",
"case POWERPC_EXCP_EXTERNAL:\ncpu_abort(cs, \"External interrupt while in user mode. \"\n\"Aborting\\n\");",
"break;",
"case POWERPC_EXCP_ALIGN:\nEXCP_DUMP(VAR_0, \"Unaligned memory access\\n\");",
"info.si_signo = TARGET_SIGBUS;",
"info.si_errno = 0;",
"info.si_code = TARGET_BUS_ADRALN;",
"info._sifields._sigfault._addr = VAR_0->nip;",
"queue_signal(VAR_0, info.si_signo, &info);",
"break;",
"case POWERPC_EXCP_PROGRAM:\nswitch (VAR_0->error_code & ~0xF) {",
"case POWERPC_EXCP_FP:\nEXCP_DUMP(VAR_0, \"Floating point program exception\\n\");",
"info.si_signo = TARGET_SIGFPE;",
"info.si_errno = 0;",
"switch (VAR_0->error_code & 0xF) {",
"case POWERPC_EXCP_FP_OX:\ninfo.si_code = TARGET_FPE_FLTOVF;",
"break;",
"case POWERPC_EXCP_FP_UX:\ninfo.si_code = TARGET_FPE_FLTUND;",
"break;",
"case POWERPC_EXCP_FP_ZX:\ncase POWERPC_EXCP_FP_VXZDZ:\ninfo.si_code = TARGET_FPE_FLTDIV;",
"break;",
"case POWERPC_EXCP_FP_XX:\ninfo.si_code = TARGET_FPE_FLTRES;",
"break;",
"case POWERPC_EXCP_FP_VXSOFT:\ninfo.si_code = TARGET_FPE_FLTINV;",
"break;",
"case POWERPC_EXCP_FP_VXSNAN:\ncase POWERPC_EXCP_FP_VXISI:\ncase POWERPC_EXCP_FP_VXIDI:\ncase POWERPC_EXCP_FP_VXIMZ:\ncase POWERPC_EXCP_FP_VXVC:\ncase POWERPC_EXCP_FP_VXSQRT:\ncase POWERPC_EXCP_FP_VXCVI:\ninfo.si_code = TARGET_FPE_FLTSUB;",
"break;",
"default:\nEXCP_DUMP(VAR_0, \"Unknown floating point exception (%02x)\\n\",\nVAR_0->error_code);",
"break;",
"}",
"break;",
"case POWERPC_EXCP_INVAL:\nEXCP_DUMP(VAR_0, \"Invalid instruction\\n\");",
"info.si_signo = TARGET_SIGILL;",
"info.si_errno = 0;",
"switch (VAR_0->error_code & 0xF) {",
"case POWERPC_EXCP_INVAL_INVAL:\ninfo.si_code = TARGET_ILL_ILLOPC;",
"break;",
"case POWERPC_EXCP_INVAL_LSWX:\ninfo.si_code = TARGET_ILL_ILLOPN;",
"break;",
"case POWERPC_EXCP_INVAL_SPR:\ninfo.si_code = TARGET_ILL_PRVREG;",
"break;",
"case POWERPC_EXCP_INVAL_FP:\ninfo.si_code = TARGET_ILL_COPROC;",
"break;",
"default:\nEXCP_DUMP(VAR_0, \"Unknown invalid operation (%02x)\\n\",\nVAR_0->error_code & 0xF);",
"info.si_code = TARGET_ILL_ILLADR;",
"break;",
"}",
"break;",
"case POWERPC_EXCP_PRIV:\nEXCP_DUMP(VAR_0, \"Privilege violation\\n\");",
"info.si_signo = TARGET_SIGILL;",
"info.si_errno = 0;",
"switch (VAR_0->error_code & 0xF) {",
"case POWERPC_EXCP_PRIV_OPC:\ninfo.si_code = TARGET_ILL_PRVOPC;",
"break;",
"case POWERPC_EXCP_PRIV_REG:\ninfo.si_code = TARGET_ILL_PRVREG;",
"break;",
"default:\nEXCP_DUMP(VAR_0, \"Unknown privilege violation (%02x)\\n\",\nVAR_0->error_code & 0xF);",
"info.si_code = TARGET_ILL_PRVOPC;",
"break;",
"}",
"break;",
"case POWERPC_EXCP_TRAP:\ncpu_abort(cs, \"Tried to call a TRAP\\n\");",
"break;",
"default:\ncpu_abort(cs, \"Unknown program exception (%02x)\\n\",\nVAR_0->error_code);",
"break;",
"}",
"info._sifields._sigfault._addr = VAR_0->nip - 4;",
"queue_signal(VAR_0, info.si_signo, &info);",
"break;",
"case POWERPC_EXCP_FPU:\nEXCP_DUMP(VAR_0, \"No floating point allowed\\n\");",
"info.si_signo = TARGET_SIGILL;",
"info.si_errno = 0;",
"info.si_code = TARGET_ILL_COPROC;",
"info._sifields._sigfault._addr = VAR_0->nip - 4;",
"queue_signal(VAR_0, info.si_signo, &info);",
"break;",
"case POWERPC_EXCP_SYSCALL:\ncpu_abort(cs, \"Syscall exception while in user mode. \"\n\"Aborting\\n\");",
"break;",
"case POWERPC_EXCP_APU:\nEXCP_DUMP(VAR_0, \"No APU instruction allowed\\n\");",
"info.si_signo = TARGET_SIGILL;",
"info.si_errno = 0;",
"info.si_code = TARGET_ILL_COPROC;",
"info._sifields._sigfault._addr = VAR_0->nip - 4;",
"queue_signal(VAR_0, info.si_signo, &info);",
"break;",
"case POWERPC_EXCP_DECR:\ncpu_abort(cs, \"Decrementer interrupt while in user mode. \"\n\"Aborting\\n\");",
"break;",
"case POWERPC_EXCP_FIT:\ncpu_abort(cs, \"Fix interval timer interrupt while in user mode. \"\n\"Aborting\\n\");",
"break;",
"case POWERPC_EXCP_WDT:\ncpu_abort(cs, \"Watchdog timer interrupt while in user mode. \"\n\"Aborting\\n\");",
"break;",
"case POWERPC_EXCP_DTLB:\ncpu_abort(cs, \"Data TLB exception while in user mode. \"\n\"Aborting\\n\");",
"break;",
"case POWERPC_EXCP_ITLB:\ncpu_abort(cs, \"Instruction TLB exception while in user mode. \"\n\"Aborting\\n\");",
"break;",
"case POWERPC_EXCP_SPEU:\nEXCP_DUMP(VAR_0, \"No SPE/floating-point instruction allowed\\n\");",
"info.si_signo = TARGET_SIGILL;",
"info.si_errno = 0;",
"info.si_code = TARGET_ILL_COPROC;",
"info._sifields._sigfault._addr = VAR_0->nip - 4;",
"queue_signal(VAR_0, info.si_signo, &info);",
"break;",
"case POWERPC_EXCP_EFPDI:\ncpu_abort(cs, \"Embedded floating-point data IRQ not handled\\n\");",
"break;",
"case POWERPC_EXCP_EFPRI:\ncpu_abort(cs, \"Embedded floating-point round IRQ not handled\\n\");",
"break;",
"case POWERPC_EXCP_EPERFM:\ncpu_abort(cs, \"Performance monitor exception not handled\\n\");",
"break;",
"case POWERPC_EXCP_DOORI:\ncpu_abort(cs, \"Doorbell interrupt while in user mode. \"\n\"Aborting\\n\");",
"break;",
"case POWERPC_EXCP_DOORCI:\ncpu_abort(cs, \"Doorbell critical interrupt while in user mode. \"\n\"Aborting\\n\");",
"break;",
"case POWERPC_EXCP_RESET:\ncpu_abort(cs, \"Reset interrupt while in user mode. \"\n\"Aborting\\n\");",
"break;",
"case POWERPC_EXCP_DSEG:\ncpu_abort(cs, \"Data segment exception while in user mode. \"\n\"Aborting\\n\");",
"break;",
"case POWERPC_EXCP_ISEG:\ncpu_abort(cs, \"Instruction segment exception \"\n\"while in user mode. Aborting\\n\");",
"break;",
"case POWERPC_EXCP_HDECR:\ncpu_abort(cs, \"Hypervisor decrementer interrupt \"\n\"while in user mode. Aborting\\n\");",
"break;",
"case POWERPC_EXCP_TRACE:\nbreak;",
"case POWERPC_EXCP_HDSI:\ncpu_abort(cs, \"Hypervisor data storage exception \"\n\"while in user mode. Aborting\\n\");",
"break;",
"case POWERPC_EXCP_HISI:\ncpu_abort(cs, \"Hypervisor instruction storage exception \"\n\"while in user mode. Aborting\\n\");",
"break;",
"case POWERPC_EXCP_HDSEG:\ncpu_abort(cs, \"Hypervisor data segment exception \"\n\"while in user mode. Aborting\\n\");",
"break;",
"case POWERPC_EXCP_HISEG:\ncpu_abort(cs, \"Hypervisor instruction segment exception \"\n\"while in user mode. Aborting\\n\");",
"break;",
"case POWERPC_EXCP_VPU:\nEXCP_DUMP(VAR_0, \"No Altivec instructions allowed\\n\");",
"info.si_signo = TARGET_SIGILL;",
"info.si_errno = 0;",
"info.si_code = TARGET_ILL_COPROC;",
"info._sifields._sigfault._addr = VAR_0->nip - 4;",
"queue_signal(VAR_0, info.si_signo, &info);",
"break;",
"case POWERPC_EXCP_PIT:\ncpu_abort(cs, \"Programmable interval timer interrupt \"\n\"while in user mode. Aborting\\n\");",
"break;",
"case POWERPC_EXCP_IO:\ncpu_abort(cs, \"IO error exception while in user mode. \"\n\"Aborting\\n\");",
"break;",
"case POWERPC_EXCP_RUNM:\ncpu_abort(cs, \"Run mode exception while in user mode. \"\n\"Aborting\\n\");",
"break;",
"case POWERPC_EXCP_EMUL:\ncpu_abort(cs, \"Emulation trap exception not handled\\n\");",
"break;",
"case POWERPC_EXCP_IFTLB:\ncpu_abort(cs, \"Instruction fetch TLB exception \"\n\"while in user-mode. Aborting\");",
"break;",
"case POWERPC_EXCP_DLTLB:\ncpu_abort(cs, \"Data load TLB exception while in user-mode. \"\n\"Aborting\");",
"break;",
"case POWERPC_EXCP_DSTLB:\ncpu_abort(cs, \"Data store TLB exception while in user-mode. \"\n\"Aborting\");",
"break;",
"case POWERPC_EXCP_FPA:\ncpu_abort(cs, \"Floating-point assist exception not handled\\n\");",
"break;",
"case POWERPC_EXCP_IABR:\ncpu_abort(cs, \"Instruction address breakpoint exception \"\n\"not handled\\n\");",
"break;",
"case POWERPC_EXCP_SMI:\ncpu_abort(cs, \"System management interrupt while in user mode. \"\n\"Aborting\\n\");",
"break;",
"case POWERPC_EXCP_THERM:\ncpu_abort(cs, \"Thermal interrupt interrupt while in user mode. \"\n\"Aborting\\n\");",
"break;",
"case POWERPC_EXCP_PERFM:\ncpu_abort(cs, \"Performance monitor exception not handled\\n\");",
"break;",
"case POWERPC_EXCP_VPUA:\ncpu_abort(cs, \"Vector assist exception not handled\\n\");",
"break;",
"case POWERPC_EXCP_SOFTP:\ncpu_abort(cs, \"Soft patch exception not handled\\n\");",
"break;",
"case POWERPC_EXCP_MAINT:\ncpu_abort(cs, \"Maintenance exception while in user mode. \"\n\"Aborting\\n\");",
"break;",
"case POWERPC_EXCP_STOP:\nbreak;",
"case POWERPC_EXCP_BRANCH:\nbreak;",
"case POWERPC_EXCP_SYSCALL_USER:\nVAR_0->crf[0] &= ~0x1;",
"ret = do_syscall(VAR_0, VAR_0->gpr[0], VAR_0->gpr[3], VAR_0->gpr[4],\nVAR_0->gpr[5], VAR_0->gpr[6], VAR_0->gpr[7],\nVAR_0->gpr[8], 0, 0);",
"if (ret == -TARGET_ERESTARTSYS) {",
"VAR_0->nip -= 4;",
"break;",
"}",
"if (ret == (target_ulong)(-TARGET_QEMU_ESIGRETURN)) {",
"break;",
"}",
"if (ret > (target_ulong)(-515)) {",
"VAR_0->crf[0] |= 0x1;",
"ret = -ret;",
"}",
"VAR_0->gpr[3] = ret;",
"break;",
"case POWERPC_EXCP_STCX:\nif (do_store_exclusive(VAR_0)) {",
"info.si_signo = TARGET_SIGSEGV;",
"info.si_errno = 0;",
"info.si_code = TARGET_SEGV_MAPERR;",
"info._sifields._sigfault._addr = VAR_0->nip;",
"queue_signal(VAR_0, info.si_signo, &info);",
"}",
"break;",
"case EXCP_DEBUG:\n{",
"int VAR_2;",
"VAR_2 = gdb_handlesig(cs, TARGET_SIGTRAP);",
"if (VAR_2) {",
"info.si_signo = VAR_2;",
"info.si_errno = 0;",
"info.si_code = TARGET_TRAP_BRKPT;",
"queue_signal(VAR_0, info.si_signo, &info);",
"}",
"}",
"break;",
"case EXCP_INTERRUPT:\nbreak;",
"default:\ncpu_abort(cs, \"Unknown exception 0x%d. Aborting\\n\", VAR_1);",
"break;",
"}",
"process_pending_signals(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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
29
],
[
31,
33,
35
],
[
37
],
[
39,
41,
43
],
[
45
],
[
47,
49,
51
],
[
55
],
[
57,
59
],
[
61
],
[
63
],
[
65
],
[
67,
69
],
[
71
],
[
73
],
[
75
],
[
77,
79
],
[
81
],
[
83
],
[
85
],
[
87,
91,
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111,
113,
115
],
[
119
],
[
121,
123
],
[
125
],
[
127
],
[
129
],
[
131,
133,
135
],
[
137
],
[
139
],
[
141
],
[
143,
147,
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167,
169,
171
],
[
173
],
[
175,
177
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193,
198
],
[
200,
202
],
[
204
],
[
206
],
[
208
],
[
210,
212
],
[
214
],
[
216,
218
],
[
220
],
[
222,
224,
226
],
[
228
],
[
230,
232
],
[
234
],
[
236,
238
],
[
240
],
[
242,
244,
246,
248,
250,
252,
254,
256
],
[
258
],
[
260,
262,
264
],
[
266
],
[
268
],
[
270
],
[
272,
274
],
[
276
],
[
278
],
[
280
],
[
282,
284
],
[
286
],
[
288,
290
],
[
292
],
[
294,
296
],
[
298
],
[
300,
302
],
[
304
],
[
306,
308,
310
],
[
312
],
[
314
],
[
316
],
[
318
],
[
320,
322
],
[
324
],
[
326
],
[
328
],
[
330,
332
],
[
334
],
[
336,
338
],
[
340
],
[
342,
344,
346
],
[
348
],
[
350
],
[
352
],
[
354
],
[
356,
358
],
[
360
],
[
362,
366,
368
],
[
370
],
[
372
],
[
374
],
[
376
],
[
378
],
[
380,
382
],
[
384
],
[
386
],
[
388
],
[
390
],
[
392
],
[
394
],
[
396,
398,
400
],
[
402
],
[
404,
406
],
[
408
],
[
410
],
[
412
],
[
414
],
[
416
],
[
418
],
[
420,
422,
424
],
[
426
],
[
428,
430,
432
],
[
434
],
[
436,
438,
440
],
[
442
],
[
444,
446,
448
],
[
450
],
[
452,
454,
456
],
[
458
],
[
460,
462
],
[
464
],
[
466
],
[
468
],
[
470
],
[
472
],
[
474
],
[
476,
478
],
[
480
],
[
482,
484
],
[
486
],
[
488,
490
],
[
492
],
[
494,
496,
498
],
[
500
],
[
502,
504,
506
],
[
508
],
[
510,
512,
514
],
[
516
],
[
518,
520,
522
],
[
524
],
[
526,
528,
530
],
[
532
],
[
536,
538,
540
],
[
542
],
[
544,
552
],
[
556,
558,
560
],
[
562
],
[
564,
566,
568
],
[
570
],
[
572,
574,
576
],
[
578
],
[
580,
582,
584
],
[
586
],
[
588,
590
],
[
592
],
[
594
],
[
596
],
[
598
],
[
600
],
[
602
],
[
604,
606,
608
],
[
610
],
[
612,
614,
616
],
[
618
],
[
620,
622,
624
],
[
626
],
[
628,
630
],
[
632
],
[
634,
636,
638
],
[
640
],
[
642,
644,
646
],
[
648
],
[
650,
652,
654
],
[
656
],
[
658,
660
],
[
662
],
[
664,
666,
668
],
[
670
],
[
672,
674,
676
],
[
678
],
[
680,
682,
684
],
[
686
],
[
688,
690
],
[
692
],
[
694,
696
],
[
698
],
[
700,
702
],
[
704
],
[
706,
708,
710
],
[
712
],
[
714,
718
],
[
720,
724
],
[
726,
738
],
[
740,
742,
744
],
[
746
],
[
748
],
[
750
],
[
752
],
[
754
],
[
760
],
[
762
],
[
764
],
[
766
],
[
768
],
[
770
],
[
772
],
[
774
],
[
776,
778
],
[
780
],
[
782
],
[
784
],
[
786
],
[
788
],
[
790
],
[
792
],
[
794,
796
],
[
798
],
[
802
],
[
804
],
[
806
],
[
808
],
[
810
],
[
812
],
[
814
],
[
816
],
[
818
],
[
820,
824
],
[
826,
828
],
[
830
],
[
832
],
[
834
],
[
836
],
[
838
]
] |
18,950 | static int check_video_codec_tag(int codec_tag) {
if (codec_tag <= 0 || codec_tag > 15) {
return AVERROR(ENOSYS);
} else
return 0;
}
| true | FFmpeg | 14bc7aaa860e4d71f4966d4679b3fab547f5e0af | static int check_video_codec_tag(int codec_tag) {
if (codec_tag <= 0 || codec_tag > 15) {
return AVERROR(ENOSYS);
} else
return 0;
}
| {
"code": [
"static int check_video_codec_tag(int codec_tag) {",
" if (codec_tag <= 0 || codec_tag > 15) {",
" return AVERROR(ENOSYS);",
" } else",
" return 0;"
],
"line_no": [
1,
3,
5,
7,
9
]
} | static int FUNC_0(int VAR_0) {
if (VAR_0 <= 0 || VAR_0 > 15) {
return AVERROR(ENOSYS);
} else
return 0;
}
| [
"static int FUNC_0(int VAR_0) {",
"if (VAR_0 <= 0 || VAR_0 > 15) {",
"return AVERROR(ENOSYS);",
"} else",
"return 0;",
"}"
] | [
1,
1,
1,
0,
1,
0
] | [
[
1
],
[
3
],
[
5
],
[
7
],
[
9
],
[
11
]
] |
18,951 | static int announce_self_create(uint8_t *buf,
uint8_t *mac_addr)
{
uint32_t magic = EXPERIMENTAL_MAGIC;
uint16_t proto = htons(ETH_P_EXPERIMENTAL);
/* FIXME: should we send a different packet (arp/rarp/ping)? */
memset(buf, 0, 64);
memset(buf, 0xff, 6); /* h_dst */
memcpy(buf + 6, mac_addr, 6); /* h_src */
memcpy(buf + 12, &proto, 2); /* h_proto */
memcpy(buf + 14, &magic, 4); /* magic */
return 64; /* len */
}
| true | qemu | 18995b9808dc48897bda6ed93ce3e978191f7251 | static int announce_self_create(uint8_t *buf,
uint8_t *mac_addr)
{
uint32_t magic = EXPERIMENTAL_MAGIC;
uint16_t proto = htons(ETH_P_EXPERIMENTAL);
memset(buf, 0, 64);
memset(buf, 0xff, 6);
memcpy(buf + 6, mac_addr, 6);
memcpy(buf + 12, &proto, 2);
memcpy(buf + 14, &magic, 4);
return 64;
}
| {
"code": [
"static int announce_self_create(uint8_t *buf, ",
" uint32_t magic = EXPERIMENTAL_MAGIC;",
" uint16_t proto = htons(ETH_P_EXPERIMENTAL);",
" memset(buf, 0, 64);"
],
"line_no": [
1,
7,
9,
17
]
} | static int FUNC_0(uint8_t *VAR_0,
uint8_t *VAR_1)
{
uint32_t magic = EXPERIMENTAL_MAGIC;
uint16_t proto = htons(ETH_P_EXPERIMENTAL);
memset(VAR_0, 0, 64);
memset(VAR_0, 0xff, 6);
memcpy(VAR_0 + 6, VAR_1, 6);
memcpy(VAR_0 + 12, &proto, 2);
memcpy(VAR_0 + 14, &magic, 4);
return 64;
}
| [
"static int FUNC_0(uint8_t *VAR_0,\nuint8_t *VAR_1)\n{",
"uint32_t magic = EXPERIMENTAL_MAGIC;",
"uint16_t proto = htons(ETH_P_EXPERIMENTAL);",
"memset(VAR_0, 0, 64);",
"memset(VAR_0, 0xff, 6);",
"memcpy(VAR_0 + 6, VAR_1, 6);",
"memcpy(VAR_0 + 12, &proto, 2);",
"memcpy(VAR_0 + 14, &magic, 4);",
"return 64;",
"}"
] | [
1,
1,
1,
1,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
]
] |
18,952 | static int slirp_hostfwd(SlirpState *s, const char *redir_str,
int legacy_format, Error **errp)
{
struct in_addr host_addr = { .s_addr = INADDR_ANY };
struct in_addr guest_addr = { .s_addr = 0 };
int host_port, guest_port;
const char *p;
char buf[256];
int is_udp;
char *end;
p = redir_str;
if (!p || get_str_sep(buf, sizeof(buf), &p, ':') < 0) {
goto fail_syntax;
}
if (!strcmp(buf, "tcp") || buf[0] == '\0') {
is_udp = 0;
} else if (!strcmp(buf, "udp")) {
is_udp = 1;
} else {
goto fail_syntax;
}
if (!legacy_format) {
if (get_str_sep(buf, sizeof(buf), &p, ':') < 0) {
goto fail_syntax;
}
if (buf[0] != '\0' && !inet_aton(buf, &host_addr)) {
goto fail_syntax;
}
}
if (get_str_sep(buf, sizeof(buf), &p, legacy_format ? ':' : '-') < 0) {
goto fail_syntax;
}
host_port = strtol(buf, &end, 0);
if (*end != '\0' || host_port < 0 || host_port > 65535) {
goto fail_syntax;
}
if (get_str_sep(buf, sizeof(buf), &p, ':') < 0) {
goto fail_syntax;
}
if (buf[0] != '\0' && !inet_aton(buf, &guest_addr)) {
goto fail_syntax;
}
guest_port = strtol(p, &end, 0);
if (*end != '\0' || guest_port < 1 || guest_port > 65535) {
goto fail_syntax;
}
if (slirp_add_hostfwd(s->slirp, is_udp, host_addr, host_port, guest_addr,
guest_port) < 0) {
error_setg(errp, "Could not set up host forwarding rule '%s'",
redir_str);
return -1;
}
return 0;
fail_syntax:
error_setg(errp, "Invalid host forwarding rule '%s'", redir_str);
return -1;
}
| true | qemu | 0e7e4fb0a6b8f1043182dcccc91a7b984587d1ae | static int slirp_hostfwd(SlirpState *s, const char *redir_str,
int legacy_format, Error **errp)
{
struct in_addr host_addr = { .s_addr = INADDR_ANY };
struct in_addr guest_addr = { .s_addr = 0 };
int host_port, guest_port;
const char *p;
char buf[256];
int is_udp;
char *end;
p = redir_str;
if (!p || get_str_sep(buf, sizeof(buf), &p, ':') < 0) {
goto fail_syntax;
}
if (!strcmp(buf, "tcp") || buf[0] == '\0') {
is_udp = 0;
} else if (!strcmp(buf, "udp")) {
is_udp = 1;
} else {
goto fail_syntax;
}
if (!legacy_format) {
if (get_str_sep(buf, sizeof(buf), &p, ':') < 0) {
goto fail_syntax;
}
if (buf[0] != '\0' && !inet_aton(buf, &host_addr)) {
goto fail_syntax;
}
}
if (get_str_sep(buf, sizeof(buf), &p, legacy_format ? ':' : '-') < 0) {
goto fail_syntax;
}
host_port = strtol(buf, &end, 0);
if (*end != '\0' || host_port < 0 || host_port > 65535) {
goto fail_syntax;
}
if (get_str_sep(buf, sizeof(buf), &p, ':') < 0) {
goto fail_syntax;
}
if (buf[0] != '\0' && !inet_aton(buf, &guest_addr)) {
goto fail_syntax;
}
guest_port = strtol(p, &end, 0);
if (*end != '\0' || guest_port < 1 || guest_port > 65535) {
goto fail_syntax;
}
if (slirp_add_hostfwd(s->slirp, is_udp, host_addr, host_port, guest_addr,
guest_port) < 0) {
error_setg(errp, "Could not set up host forwarding rule '%s'",
redir_str);
return -1;
}
return 0;
fail_syntax:
error_setg(errp, "Invalid host forwarding rule '%s'", redir_str);
return -1;
}
| {
"code": [
" error_setg(errp, \"Invalid host forwarding rule '%s'\", redir_str);"
],
"line_no": [
123
]
} | static int FUNC_0(SlirpState *VAR_0, const char *VAR_1,
int VAR_2, Error **VAR_3)
{
struct in_addr VAR_4 = { .s_addr = INADDR_ANY };
struct in_addr VAR_5 = { .s_addr = 0 };
int VAR_6, VAR_7;
const char *VAR_8;
char VAR_9[256];
int VAR_10;
char *VAR_11;
VAR_8 = VAR_1;
if (!VAR_8 || get_str_sep(VAR_9, sizeof(VAR_9), &VAR_8, ':') < 0) {
goto fail_syntax;
}
if (!strcmp(VAR_9, "tcp") || VAR_9[0] == '\0') {
VAR_10 = 0;
} else if (!strcmp(VAR_9, "udp")) {
VAR_10 = 1;
} else {
goto fail_syntax;
}
if (!VAR_2) {
if (get_str_sep(VAR_9, sizeof(VAR_9), &VAR_8, ':') < 0) {
goto fail_syntax;
}
if (VAR_9[0] != '\0' && !inet_aton(VAR_9, &VAR_4)) {
goto fail_syntax;
}
}
if (get_str_sep(VAR_9, sizeof(VAR_9), &VAR_8, VAR_2 ? ':' : '-') < 0) {
goto fail_syntax;
}
VAR_6 = strtol(VAR_9, &VAR_11, 0);
if (*VAR_11 != '\0' || VAR_6 < 0 || VAR_6 > 65535) {
goto fail_syntax;
}
if (get_str_sep(VAR_9, sizeof(VAR_9), &VAR_8, ':') < 0) {
goto fail_syntax;
}
if (VAR_9[0] != '\0' && !inet_aton(VAR_9, &VAR_5)) {
goto fail_syntax;
}
VAR_7 = strtol(VAR_8, &VAR_11, 0);
if (*VAR_11 != '\0' || VAR_7 < 1 || VAR_7 > 65535) {
goto fail_syntax;
}
if (slirp_add_hostfwd(VAR_0->slirp, VAR_10, VAR_4, VAR_6, VAR_5,
VAR_7) < 0) {
error_setg(VAR_3, "Could not set up host forwarding rule '%VAR_0'",
VAR_1);
return -1;
}
return 0;
fail_syntax:
error_setg(VAR_3, "Invalid host forwarding rule '%VAR_0'", VAR_1);
return -1;
}
| [
"static int FUNC_0(SlirpState *VAR_0, const char *VAR_1,\nint VAR_2, Error **VAR_3)\n{",
"struct in_addr VAR_4 = { .s_addr = INADDR_ANY };",
"struct in_addr VAR_5 = { .s_addr = 0 };",
"int VAR_6, VAR_7;",
"const char *VAR_8;",
"char VAR_9[256];",
"int VAR_10;",
"char *VAR_11;",
"VAR_8 = VAR_1;",
"if (!VAR_8 || get_str_sep(VAR_9, sizeof(VAR_9), &VAR_8, ':') < 0) {",
"goto fail_syntax;",
"}",
"if (!strcmp(VAR_9, \"tcp\") || VAR_9[0] == '\\0') {",
"VAR_10 = 0;",
"} else if (!strcmp(VAR_9, \"udp\")) {",
"VAR_10 = 1;",
"} else {",
"goto fail_syntax;",
"}",
"if (!VAR_2) {",
"if (get_str_sep(VAR_9, sizeof(VAR_9), &VAR_8, ':') < 0) {",
"goto fail_syntax;",
"}",
"if (VAR_9[0] != '\\0' && !inet_aton(VAR_9, &VAR_4)) {",
"goto fail_syntax;",
"}",
"}",
"if (get_str_sep(VAR_9, sizeof(VAR_9), &VAR_8, VAR_2 ? ':' : '-') < 0) {",
"goto fail_syntax;",
"}",
"VAR_6 = strtol(VAR_9, &VAR_11, 0);",
"if (*VAR_11 != '\\0' || VAR_6 < 0 || VAR_6 > 65535) {",
"goto fail_syntax;",
"}",
"if (get_str_sep(VAR_9, sizeof(VAR_9), &VAR_8, ':') < 0) {",
"goto fail_syntax;",
"}",
"if (VAR_9[0] != '\\0' && !inet_aton(VAR_9, &VAR_5)) {",
"goto fail_syntax;",
"}",
"VAR_7 = strtol(VAR_8, &VAR_11, 0);",
"if (*VAR_11 != '\\0' || VAR_7 < 1 || VAR_7 > 65535) {",
"goto fail_syntax;",
"}",
"if (slirp_add_hostfwd(VAR_0->slirp, VAR_10, VAR_4, VAR_6, VAR_5,\nVAR_7) < 0) {",
"error_setg(VAR_3, \"Could not set up host forwarding rule '%VAR_0'\",\nVAR_1);",
"return -1;",
"}",
"return 0;",
"fail_syntax:\nerror_setg(VAR_3, \"Invalid host forwarding rule '%VAR_0'\", VAR_1);",
"return -1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
95
],
[
97
],
[
99
],
[
101
],
[
105,
107
],
[
109,
111
],
[
113
],
[
115
],
[
117
],
[
121,
123
],
[
125
],
[
127
]
] |
18,953 | void RENAME(interleaveBytes)(uint8_t *src1, uint8_t *src2, uint8_t *dest,
long width, long height, long src1Stride,
long src2Stride, long dstStride){
long h;
for(h=0; h < height; h++)
{
long w;
#ifdef HAVE_MMX
#ifdef HAVE_SSE2
asm(
"xor %%"REG_a", %%"REG_a" \n\t"
"1: \n\t"
PREFETCH" 64(%1, %%"REG_a") \n\t"
PREFETCH" 64(%2, %%"REG_a") \n\t"
"movdqa (%1, %%"REG_a"), %%xmm0 \n\t"
"movdqa (%1, %%"REG_a"), %%xmm1 \n\t"
"movdqa (%2, %%"REG_a"), %%xmm2 \n\t"
"punpcklbw %%xmm2, %%xmm0 \n\t"
"punpckhbw %%xmm2, %%xmm1 \n\t"
"movntdq %%xmm0, (%0, %%"REG_a", 2)\n\t"
"movntdq %%xmm1, 16(%0, %%"REG_a", 2)\n\t"
"add $16, %%"REG_a" \n\t"
"cmp %3, %%"REG_a" \n\t"
" jb 1b \n\t"
::"r"(dest), "r"(src1), "r"(src2), "r" (width-15)
: "memory", "%"REG_a""
);
#else
asm(
"xor %%"REG_a", %%"REG_a" \n\t"
"1: \n\t"
PREFETCH" 64(%1, %%"REG_a") \n\t"
PREFETCH" 64(%2, %%"REG_a") \n\t"
"movq (%1, %%"REG_a"), %%mm0 \n\t"
"movq 8(%1, %%"REG_a"), %%mm2 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm2, %%mm3 \n\t"
"movq (%2, %%"REG_a"), %%mm4 \n\t"
"movq 8(%2, %%"REG_a"), %%mm5 \n\t"
"punpcklbw %%mm4, %%mm0 \n\t"
"punpckhbw %%mm4, %%mm1 \n\t"
"punpcklbw %%mm5, %%mm2 \n\t"
"punpckhbw %%mm5, %%mm3 \n\t"
MOVNTQ" %%mm0, (%0, %%"REG_a", 2)\n\t"
MOVNTQ" %%mm1, 8(%0, %%"REG_a", 2)\n\t"
MOVNTQ" %%mm2, 16(%0, %%"REG_a", 2)\n\t"
MOVNTQ" %%mm3, 24(%0, %%"REG_a", 2)\n\t"
"add $16, %%"REG_a" \n\t"
"cmp %3, %%"REG_a" \n\t"
" jb 1b \n\t"
::"r"(dest), "r"(src1), "r"(src2), "r" (width-15)
: "memory", "%"REG_a
);
#endif
for(w= (width&(~15)); w < width; w++)
{
dest[2*w+0] = src1[w];
dest[2*w+1] = src2[w];
}
#else
for(w=0; w < width; w++)
{
dest[2*w+0] = src1[w];
dest[2*w+1] = src2[w];
}
#endif
dest += dstStride;
src1 += src1Stride;
src2 += src2Stride;
}
#ifdef HAVE_MMX
asm(
EMMS" \n\t"
SFENCE" \n\t"
::: "memory"
);
#endif
}
| true | FFmpeg | 6e42e6c4b410dbef8b593c2d796a5dad95f89ee4 | void RENAME(interleaveBytes)(uint8_t *src1, uint8_t *src2, uint8_t *dest,
long width, long height, long src1Stride,
long src2Stride, long dstStride){
long h;
for(h=0; h < height; h++)
{
long w;
#ifdef HAVE_MMX
#ifdef HAVE_SSE2
asm(
"xor %%"REG_a", %%"REG_a" \n\t"
"1: \n\t"
PREFETCH" 64(%1, %%"REG_a") \n\t"
PREFETCH" 64(%2, %%"REG_a") \n\t"
"movdqa (%1, %%"REG_a"), %%xmm0 \n\t"
"movdqa (%1, %%"REG_a"), %%xmm1 \n\t"
"movdqa (%2, %%"REG_a"), %%xmm2 \n\t"
"punpcklbw %%xmm2, %%xmm0 \n\t"
"punpckhbw %%xmm2, %%xmm1 \n\t"
"movntdq %%xmm0, (%0, %%"REG_a", 2)\n\t"
"movntdq %%xmm1, 16(%0, %%"REG_a", 2)\n\t"
"add $16, %%"REG_a" \n\t"
"cmp %3, %%"REG_a" \n\t"
" jb 1b \n\t"
::"r"(dest), "r"(src1), "r"(src2), "r" (width-15)
: "memory", "%"REG_a""
);
#else
asm(
"xor %%"REG_a", %%"REG_a" \n\t"
"1: \n\t"
PREFETCH" 64(%1, %%"REG_a") \n\t"
PREFETCH" 64(%2, %%"REG_a") \n\t"
"movq (%1, %%"REG_a"), %%mm0 \n\t"
"movq 8(%1, %%"REG_a"), %%mm2 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm2, %%mm3 \n\t"
"movq (%2, %%"REG_a"), %%mm4 \n\t"
"movq 8(%2, %%"REG_a"), %%mm5 \n\t"
"punpcklbw %%mm4, %%mm0 \n\t"
"punpckhbw %%mm4, %%mm1 \n\t"
"punpcklbw %%mm5, %%mm2 \n\t"
"punpckhbw %%mm5, %%mm3 \n\t"
MOVNTQ" %%mm0, (%0, %%"REG_a", 2)\n\t"
MOVNTQ" %%mm1, 8(%0, %%"REG_a", 2)\n\t"
MOVNTQ" %%mm2, 16(%0, %%"REG_a", 2)\n\t"
MOVNTQ" %%mm3, 24(%0, %%"REG_a", 2)\n\t"
"add $16, %%"REG_a" \n\t"
"cmp %3, %%"REG_a" \n\t"
" jb 1b \n\t"
::"r"(dest), "r"(src1), "r"(src2), "r" (width-15)
: "memory", "%"REG_a
);
#endif
for(w= (width&(~15)); w < width; w++)
{
dest[2*w+0] = src1[w];
dest[2*w+1] = src2[w];
}
#else
for(w=0; w < width; w++)
{
dest[2*w+0] = src1[w];
dest[2*w+1] = src2[w];
}
#endif
dest += dstStride;
src1 += src1Stride;
src2 += src2Stride;
}
#ifdef HAVE_MMX
asm(
EMMS" \n\t"
SFENCE" \n\t"
::: "memory"
);
#endif
}
| {
"code": [
"\t\t\t long width, long height, long src1Stride,",
"\t\t\t long width, long height, long src1Stride,",
"#ifdef HAVE_MMX",
"#endif",
"#ifdef HAVE_MMX",
"#endif",
"#else",
"#endif",
"#endif",
"\t\t);",
"\t\t);",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"\t\t\t\"xor %%\"REG_a\", %%\"REG_a\"\t\\n\\t\"",
"\t\t\t\"1:\t\t\t\t\\n\\t\"",
"\t\t\t\" jb 1b\t\t\t\t\\n\\t\"",
"\t\t);",
"#endif",
"#endif",
"#endif",
"\t\t\t\"xor %%\"REG_a\", %%\"REG_a\"\t\\n\\t\"",
"\t\t\t\"1:\t\t\t\t\\n\\t\"",
"\t\t\t\" jb 1b\t\t\t\t\\n\\t\"",
"\t\t);",
"#endif",
"#endif",
"#endif",
"\t\t\t\"xor %%\"REG_a\", %%\"REG_a\"\t\\n\\t\"",
"\t\t\t\"1:\t\t\t\t\\n\\t\"",
"\t\t\t\" jb 1b\t\t\t\t\\n\\t\"",
"\t\t\t: \"memory\", \"%\"REG_a",
"\t\t);",
"\t\t\t\"xor %%\"REG_a\", %%\"REG_a\"\t\\n\\t\"",
"\t\t\t\"1:\t\t\t\t\\n\\t\"",
"\t\t\t\" jb 1b\t\t\t\t\\n\\t\"",
"\t\t\t: \"memory\", \"%\"REG_a",
"\t\t);",
"#endif",
"\t\t\t\"1:\t\t\t\t\\n\\t\"",
"#endif",
"\t\t);",
"#endif",
"\t\t\t\"1:\t\t\t\t\\n\\t\"",
"\t\t\t\" jb 1b\t\t\t\t\\n\\t\"",
"\t\t);",
"\t\t\t\"1:\t\t\t\t\\n\\t\"",
"\t\t\t\" jb 1b\t\t\t\t\\n\\t\"",
"\t\t);",
"#endif",
"#endif",
"#endif",
"\t\t\t\"1:\t\t\t\t\\n\\t\"",
"\t\t\t\"movq %%mm0, %%mm1\t\t\\n\\t\"",
"\t\t\t\"movq %%mm2, %%mm3\t\t\\n\\t\"",
"#endif",
"#endif",
"\t\t\t\"movq %%mm2, %%mm3\t\t\\n\\t\"",
"#endif",
"#endif",
"\t\t\t\"movq %%mm0, %%mm1\t\t\\n\\t\"",
"\t\t);",
"#endif",
"\t\t\t long width, long height, long src1Stride,",
"\t\t\t long src2Stride, long dstStride){",
"\tlong h;",
"\tfor(h=0; h < height; h++)",
"\t\tlong w;",
"\t\tasm(",
"\t\t\t\"xor %%\"REG_a\", %%\"REG_a\"\t\\n\\t\"",
"\t\t\t\"1:\t\t\t\t\\n\\t\"",
"\t\t\tPREFETCH\" 64(%1, %%\"REG_a\")\t\\n\\t\"",
"\t\t\tPREFETCH\" 64(%2, %%\"REG_a\")\t\\n\\t\"",
"\t\t\t\"movdqa (%1, %%\"REG_a\"), %%xmm0\t\\n\\t\"",
"\t\t\t\"movdqa (%1, %%\"REG_a\"), %%xmm1\t\\n\\t\"",
"\t\t\t\"movdqa (%2, %%\"REG_a\"), %%xmm2\t\\n\\t\"",
"\t\t\t\"punpcklbw %%xmm2, %%xmm0\t\\n\\t\"",
"\t\t\t\"punpckhbw %%xmm2, %%xmm1\t\\n\\t\"",
"\t\t\t\"movntdq %%xmm0, (%0, %%\"REG_a\", 2)\\n\\t\"",
"\t\t\t\"movntdq %%xmm1, 16(%0, %%\"REG_a\", 2)\\n\\t\"",
"\t\t\t\"add $16, %%\"REG_a\"\t\t\\n\\t\"",
"\t\t\t\"cmp %3, %%\"REG_a\"\t\t\\n\\t\"",
"\t\t\t\" jb 1b\t\t\t\t\\n\\t\"",
"\t\t\t::\"r\"(dest), \"r\"(src1), \"r\"(src2), \"r\" (width-15)",
"\t\t\t: \"memory\", \"%\"REG_a\"\"",
"\t\t);",
"\t\tasm(",
"\t\t\t\"xor %%\"REG_a\", %%\"REG_a\"\t\\n\\t\"",
"\t\t\t\"1:\t\t\t\t\\n\\t\"",
"\t\t\tPREFETCH\" 64(%1, %%\"REG_a\")\t\\n\\t\"",
"\t\t\tPREFETCH\" 64(%2, %%\"REG_a\")\t\\n\\t\"",
"\t\t\t\"movq (%1, %%\"REG_a\"), %%mm0\t\\n\\t\"",
"\t\t\t\"movq 8(%1, %%\"REG_a\"), %%mm2\t\\n\\t\"",
"\t\t\t\"movq %%mm0, %%mm1\t\t\\n\\t\"",
"\t\t\t\"movq %%mm2, %%mm3\t\t\\n\\t\"",
"\t\t\t\"movq (%2, %%\"REG_a\"), %%mm4\t\\n\\t\"",
"\t\t\t\"movq 8(%2, %%\"REG_a\"), %%mm5\t\\n\\t\"",
"\t\t\t\"punpcklbw %%mm4, %%mm0\t\t\\n\\t\"",
"\t\t\t\"punpckhbw %%mm4, %%mm1\t\t\\n\\t\"",
"\t\t\t\"punpcklbw %%mm5, %%mm2\t\t\\n\\t\"",
"\t\t\t\"punpckhbw %%mm5, %%mm3\t\t\\n\\t\"",
"\t\t\tMOVNTQ\" %%mm0, (%0, %%\"REG_a\", 2)\\n\\t\"",
"\t\t\tMOVNTQ\" %%mm1, 8(%0, %%\"REG_a\", 2)\\n\\t\"",
"\t\t\tMOVNTQ\" %%mm2, 16(%0, %%\"REG_a\", 2)\\n\\t\"",
"\t\t\tMOVNTQ\" %%mm3, 24(%0, %%\"REG_a\", 2)\\n\\t\"",
"\t\t\t\"add $16, %%\"REG_a\"\t\t\\n\\t\"",
"\t\t\t\"cmp %3, %%\"REG_a\"\t\t\\n\\t\"",
"\t\t\t\" jb 1b\t\t\t\t\\n\\t\"",
"\t\t\t::\"r\"(dest), \"r\"(src1), \"r\"(src2), \"r\" (width-15)",
"\t\t\t: \"memory\", \"%\"REG_a",
"\t\t);",
"#endif",
"\t\tfor(w= (width&(~15)); w < width; w++)",
"\t\t\tdest[2*w+0] = src1[w];",
"\t\t\tdest[2*w+1] = src2[w];",
"\t\tfor(w=0; w < width; w++)",
"\t\t\tdest[2*w+0] = src1[w];",
"\t\t\tdest[2*w+1] = src2[w];",
"\t\tdest += dstStride;",
"\tasm(",
"\t\tEMMS\" \\n\\t\"",
"\t\tSFENCE\" \\n\\t\"",
"\t\t::: \"memory\"",
"\t\t);",
"#endif",
"#endif",
"#endif",
"\tasm(",
"\t\tEMMS\" \\n\\t\"",
"\t\tSFENCE\" \\n\\t\"",
"\t\t::: \"memory\"",
"\t\t);",
"#endif",
"\tasm(",
"\t\tEMMS\" \\n\\t\"",
"\t\tSFENCE\" \\n\\t\"",
"\t\t::: \"memory\"",
"\t\t);"
],
"line_no": [
3,
3,
19,
111,
19,
111,
59,
111,
111,
57,
57,
111,
111,
111,
111,
111,
111,
111,
111,
111,
111,
111,
111,
111,
111,
111,
111,
25,
27,
51,
57,
111,
111,
111,
25,
27,
51,
57,
111,
111,
111,
25,
27,
51,
107,
57,
25,
27,
51,
107,
57,
111,
27,
111,
57,
111,
27,
51,
57,
27,
51,
57,
111,
111,
111,
27,
75,
77,
111,
111,
77,
111,
111,
75,
57,
111,
3,
5,
7,
11,
15,
23,
25,
27,
29,
31,
33,
35,
37,
39,
41,
43,
45,
47,
49,
51,
53,
55,
57,
23,
25,
27,
29,
31,
71,
73,
75,
77,
79,
81,
83,
85,
87,
89,
91,
93,
95,
97,
47,
49,
51,
53,
107,
57,
111,
113,
117,
119,
125,
117,
119,
137,
147,
149,
151,
153,
57,
111,
111,
111,
147,
149,
151,
153,
57,
111,
147,
149,
151,
153,
57
]
} | void FUNC_0(interleaveBytes)(uint8_t *src1, uint8_t *src2, uint8_t *dest,
long width, long height, long src1Stride,
long src2Stride, long dstStride){
long VAR_0;
for(VAR_0=0; VAR_0 < height; VAR_0++)
{
long w;
#ifdef HAVE_MMX
#ifdef HAVE_SSE2
asm(
"xor %%"REG_a", %%"REG_a" \n\t"
"1: \n\t"
PREFETCH" 64(%1, %%"REG_a") \n\t"
PREFETCH" 64(%2, %%"REG_a") \n\t"
"movdqa (%1, %%"REG_a"), %%xmm0 \n\t"
"movdqa (%1, %%"REG_a"), %%xmm1 \n\t"
"movdqa (%2, %%"REG_a"), %%xmm2 \n\t"
"punpcklbw %%xmm2, %%xmm0 \n\t"
"punpckhbw %%xmm2, %%xmm1 \n\t"
"movntdq %%xmm0, (%0, %%"REG_a", 2)\n\t"
"movntdq %%xmm1, 16(%0, %%"REG_a", 2)\n\t"
"add $16, %%"REG_a" \n\t"
"cmp %3, %%"REG_a" \n\t"
" jb 1b \n\t"
::"r"(dest), "r"(src1), "r"(src2), "r" (width-15)
: "memory", "%"REG_a""
);
#else
asm(
"xor %%"REG_a", %%"REG_a" \n\t"
"1: \n\t"
PREFETCH" 64(%1, %%"REG_a") \n\t"
PREFETCH" 64(%2, %%"REG_a") \n\t"
"movq (%1, %%"REG_a"), %%mm0 \n\t"
"movq 8(%1, %%"REG_a"), %%mm2 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm2, %%mm3 \n\t"
"movq (%2, %%"REG_a"), %%mm4 \n\t"
"movq 8(%2, %%"REG_a"), %%mm5 \n\t"
"punpcklbw %%mm4, %%mm0 \n\t"
"punpckhbw %%mm4, %%mm1 \n\t"
"punpcklbw %%mm5, %%mm2 \n\t"
"punpckhbw %%mm5, %%mm3 \n\t"
MOVNTQ" %%mm0, (%0, %%"REG_a", 2)\n\t"
MOVNTQ" %%mm1, 8(%0, %%"REG_a", 2)\n\t"
MOVNTQ" %%mm2, 16(%0, %%"REG_a", 2)\n\t"
MOVNTQ" %%mm3, 24(%0, %%"REG_a", 2)\n\t"
"add $16, %%"REG_a" \n\t"
"cmp %3, %%"REG_a" \n\t"
" jb 1b \n\t"
::"r"(dest), "r"(src1), "r"(src2), "r" (width-15)
: "memory", "%"REG_a
);
#endif
for(w= (width&(~15)); w < width; w++)
{
dest[2*w+0] = src1[w];
dest[2*w+1] = src2[w];
}
#else
for(w=0; w < width; w++)
{
dest[2*w+0] = src1[w];
dest[2*w+1] = src2[w];
}
#endif
dest += dstStride;
src1 += src1Stride;
src2 += src2Stride;
}
#ifdef HAVE_MMX
asm(
EMMS" \n\t"
SFENCE" \n\t"
::: "memory"
);
#endif
}
| [
"void FUNC_0(interleaveBytes)(uint8_t *src1, uint8_t *src2, uint8_t *dest,\nlong width, long height, long src1Stride,\nlong src2Stride, long dstStride){",
"long VAR_0;",
"for(VAR_0=0; VAR_0 < height; VAR_0++)",
"{",
"long w;",
"#ifdef HAVE_MMX\n#ifdef HAVE_SSE2\nasm(\n\"xor %%\"REG_a\", %%\"REG_a\"\t\\n\\t\"\n\"1:\t\t\t\t\\n\\t\"\nPREFETCH\" 64(%1, %%\"REG_a\")\t\\n\\t\"\nPREFETCH\" 64(%2, %%\"REG_a\")\t\\n\\t\"\n\"movdqa (%1, %%\"REG_a\"), %%xmm0\t\\n\\t\"\n\"movdqa (%1, %%\"REG_a\"), %%xmm1\t\\n\\t\"\n\"movdqa (%2, %%\"REG_a\"), %%xmm2\t\\n\\t\"\n\"punpcklbw %%xmm2, %%xmm0\t\\n\\t\"\n\"punpckhbw %%xmm2, %%xmm1\t\\n\\t\"\n\"movntdq %%xmm0, (%0, %%\"REG_a\", 2)\\n\\t\"\n\"movntdq %%xmm1, 16(%0, %%\"REG_a\", 2)\\n\\t\"\n\"add $16, %%\"REG_a\"\t\t\\n\\t\"\n\"cmp %3, %%\"REG_a\"\t\t\\n\\t\"\n\" jb 1b\t\t\t\t\\n\\t\"\n::\"r\"(dest), \"r\"(src1), \"r\"(src2), \"r\" (width-15)\n: \"memory\", \"%\"REG_a\"\"\n);",
"#else\nasm(\n\"xor %%\"REG_a\", %%\"REG_a\"\t\\n\\t\"\n\"1:\t\t\t\t\\n\\t\"\nPREFETCH\" 64(%1, %%\"REG_a\")\t\\n\\t\"\nPREFETCH\" 64(%2, %%\"REG_a\")\t\\n\\t\"\n\"movq (%1, %%\"REG_a\"), %%mm0\t\\n\\t\"\n\"movq 8(%1, %%\"REG_a\"), %%mm2\t\\n\\t\"\n\"movq %%mm0, %%mm1\t\t\\n\\t\"\n\"movq %%mm2, %%mm3\t\t\\n\\t\"\n\"movq (%2, %%\"REG_a\"), %%mm4\t\\n\\t\"\n\"movq 8(%2, %%\"REG_a\"), %%mm5\t\\n\\t\"\n\"punpcklbw %%mm4, %%mm0\t\t\\n\\t\"\n\"punpckhbw %%mm4, %%mm1\t\t\\n\\t\"\n\"punpcklbw %%mm5, %%mm2\t\t\\n\\t\"\n\"punpckhbw %%mm5, %%mm3\t\t\\n\\t\"\nMOVNTQ\" %%mm0, (%0, %%\"REG_a\", 2)\\n\\t\"\nMOVNTQ\" %%mm1, 8(%0, %%\"REG_a\", 2)\\n\\t\"\nMOVNTQ\" %%mm2, 16(%0, %%\"REG_a\", 2)\\n\\t\"\nMOVNTQ\" %%mm3, 24(%0, %%\"REG_a\", 2)\\n\\t\"\n\"add $16, %%\"REG_a\"\t\t\\n\\t\"\n\"cmp %3, %%\"REG_a\"\t\t\\n\\t\"\n\" jb 1b\t\t\t\t\\n\\t\"\n::\"r\"(dest), \"r\"(src1), \"r\"(src2), \"r\" (width-15)\n: \"memory\", \"%\"REG_a\n);",
"#endif\nfor(w= (width&(~15)); w < width; w++)",
"{",
"dest[2*w+0] = src1[w];",
"dest[2*w+1] = src2[w];",
"}",
"#else\nfor(w=0; w < width; w++)",
"{",
"dest[2*w+0] = src1[w];",
"dest[2*w+1] = src2[w];",
"}",
"#endif\ndest += dstStride;",
"src1 += src1Stride;",
"src2 += src2Stride;",
"}",
"#ifdef HAVE_MMX\nasm(\nEMMS\" \\n\\t\"\nSFENCE\" \\n\\t\"\n::: \"memory\"\n);",
"#endif\n}"
] | [
1,
1,
1,
0,
1,
1,
1,
1,
0,
1,
1,
0,
1,
0,
0,
0,
0,
1,
0,
0,
0,
1,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
19,
21,
23,
25,
27,
29,
31,
33,
35,
37,
39,
41,
43,
45,
47,
49,
51,
53,
55,
57
],
[
59,
61,
63,
65,
67,
69,
71,
73,
75,
77,
79,
81,
83,
85,
87,
89,
91,
93,
95,
97,
99,
101,
103,
105,
107,
109
],
[
111,
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123,
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135,
137
],
[
139
],
[
141
],
[
143
],
[
145,
147,
149,
151,
153,
155
],
[
157,
159
]
] |
18,954 | static inline void RENAME(yuv2rgb555_1)(SwsContext *c, const uint16_t *buf0,
const uint16_t *ubuf0, const uint16_t *ubuf1,
const uint16_t *vbuf0, const uint16_t *vbuf1,
const uint16_t *abuf0, uint8_t *dest,
int dstW, int uvalpha, enum PixelFormat dstFormat,
int flags, int y)
{
x86_reg uv_off = c->uv_off << 1;
const uint16_t *buf1= buf0; //FIXME needed for RGB1/BGR1
if (uvalpha < 2048) { // note this is not correct (shifts chrominance by 0.5 pixels) but it is a bit faster
__asm__ volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB1(%%REGBP, %5, %6)
"pxor %%mm7, %%mm7 \n\t"
/* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
#ifdef DITHER1XBPP
"paddusb "BLUE_DITHER"(%5), %%mm2 \n\t"
"paddusb "GREEN_DITHER"(%5), %%mm4 \n\t"
"paddusb "RED_DITHER"(%5), %%mm5 \n\t"
#endif
WRITERGB15(%%REGb, 8280(%5), %%REGBP)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
"a" (&c->redDither), "m"(uv_off)
);
} else {
__asm__ volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB1b(%%REGBP, %5, %6)
"pxor %%mm7, %%mm7 \n\t"
/* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
#ifdef DITHER1XBPP
"paddusb "BLUE_DITHER"(%5), %%mm2 \n\t"
"paddusb "GREEN_DITHER"(%5), %%mm4 \n\t"
"paddusb "RED_DITHER"(%5), %%mm5 \n\t"
#endif
WRITERGB15(%%REGb, 8280(%5), %%REGBP)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
"a" (&c->redDither), "m"(uv_off)
);
}
}
| true | FFmpeg | 009f829dde811af654af7110326aea3a72c05d5e | static inline void RENAME(yuv2rgb555_1)(SwsContext *c, const uint16_t *buf0,
const uint16_t *ubuf0, const uint16_t *ubuf1,
const uint16_t *vbuf0, const uint16_t *vbuf1,
const uint16_t *abuf0, uint8_t *dest,
int dstW, int uvalpha, enum PixelFormat dstFormat,
int flags, int y)
{
x86_reg uv_off = c->uv_off << 1;
const uint16_t *buf1= buf0;
if (uvalpha < 2048) {
__asm__ volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB1(%%REGBP, %5, %6)
"pxor %%mm7, %%mm7 \n\t"
#ifdef DITHER1XBPP
"paddusb "BLUE_DITHER"(%5), %%mm2 \n\t"
"paddusb "GREEN_DITHER"(%5), %%mm4 \n\t"
"paddusb "RED_DITHER"(%5), %%mm5 \n\t"
#endif
WRITERGB15(%%REGb, 8280(%5), %%REGBP)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
"a" (&c->redDither), "m"(uv_off)
);
} else {
__asm__ volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB1b(%%REGBP, %5, %6)
"pxor %%mm7, %%mm7 \n\t"
#ifdef DITHER1XBPP
"paddusb "BLUE_DITHER"(%5), %%mm2 \n\t"
"paddusb "GREEN_DITHER"(%5), %%mm4 \n\t"
"paddusb "RED_DITHER"(%5), %%mm5 \n\t"
#endif
WRITERGB15(%%REGb, 8280(%5), %%REGBP)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
"a" (&c->redDither), "m"(uv_off)
);
}
}
| {
"code": [
" x86_reg uv_off = c->uv_off << 1;",
" \"a\" (&c->redDither), \"m\"(uv_off)",
" \"a\" (&c->redDither), \"m\"(uv_off)",
" x86_reg uv_off = c->uv_off << 1;",
" x86_reg uv_off = c->uv_off << 1;",
" x86_reg uv_off = c->uv_off << 1;",
" x86_reg uv_off = c->uv_off << 1;",
" x86_reg uv_off = c->uv_off << 1;",
" x86_reg uv_off = c->uv_off << 1;",
" YSCALEYUV2RGB1(%%REGBP, %5, %6)",
" \"a\" (&c->redDither), \"m\"(uv_off)",
" YSCALEYUV2RGB1b(%%REGBP, %5, %6)",
" \"a\" (&c->redDither), \"m\"(uv_off)",
" x86_reg uv_off = c->uv_off << 1;",
" YSCALEYUV2RGB1(%%REGBP, %5, %6)",
" \"a\" (&c->redDither), \"m\"(uv_off)",
" YSCALEYUV2RGB1b(%%REGBP, %5, %6)",
" \"a\" (&c->redDither), \"m\"(uv_off)",
" x86_reg uv_off = c->uv_off << 1;",
" YSCALEYUV2RGB1(%%REGBP, %5, %6)",
" \"a\" (&c->redDither), \"m\"(uv_off)",
" YSCALEYUV2RGB1b(%%REGBP, %5, %6)",
" \"a\" (&c->redDither), \"m\"(uv_off)",
" x86_reg uv_off = c->uv_off << 1;",
" \"a\" (&c->redDither), \"m\"(uv_off)",
" \"a\" (&c->redDither), \"m\"(uv_off)"
],
"line_no": [
15,
55,
55,
15,
15,
15,
15,
15,
15,
31,
55,
69,
55,
15,
31,
55,
69,
55,
15,
31,
55,
69,
55,
15,
55,
55
]
} | static inline void FUNC_0(yuv2rgb555_1)(SwsContext *c, const uint16_t *buf0,
const uint16_t *ubuf0, const uint16_t *ubuf1,
const uint16_t *vbuf0, const uint16_t *vbuf1,
const uint16_t *abuf0, uint8_t *dest,
int dstW, int uvalpha, enum PixelFormat dstFormat,
int flags, int y)
{
x86_reg uv_off = c->uv_off << 1;
const uint16_t *VAR_0= buf0;
if (uvalpha < 2048) {
__asm__ volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB1(%%REGBP, %5, %6)
"pxor %%mm7, %%mm7 \n\t"
#ifdef DITHER1XBPP
"paddusb "BLUE_DITHER"(%5), %%mm2 \n\t"
"paddusb "GREEN_DITHER"(%5), %%mm4 \n\t"
"paddusb "RED_DITHER"(%5), %%mm5 \n\t"
#endif
WRITERGB15(%%REGb, 8280(%5), %%REGBP)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (VAR_0), "S" (ubuf0), "D" (ubuf1), "m" (dest),
"a" (&c->redDither), "m"(uv_off)
);
} else {
__asm__ volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB1b(%%REGBP, %5, %6)
"pxor %%mm7, %%mm7 \n\t"
#ifdef DITHER1XBPP
"paddusb "BLUE_DITHER"(%5), %%mm2 \n\t"
"paddusb "GREEN_DITHER"(%5), %%mm4 \n\t"
"paddusb "RED_DITHER"(%5), %%mm5 \n\t"
#endif
WRITERGB15(%%REGb, 8280(%5), %%REGBP)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (VAR_0), "S" (ubuf0), "D" (ubuf1), "m" (dest),
"a" (&c->redDither), "m"(uv_off)
);
}
}
| [
"static inline void FUNC_0(yuv2rgb555_1)(SwsContext *c, const uint16_t *buf0,\nconst uint16_t *ubuf0, const uint16_t *ubuf1,\nconst uint16_t *vbuf0, const uint16_t *vbuf1,\nconst uint16_t *abuf0, uint8_t *dest,\nint dstW, int uvalpha, enum PixelFormat dstFormat,\nint flags, int y)\n{",
"x86_reg uv_off = c->uv_off << 1;",
"const uint16_t *VAR_0= buf0;",
"if (uvalpha < 2048) {",
"__asm__ volatile(\n\"mov %%\"REG_b\", \"ESP_OFFSET\"(%5) \\n\\t\"\n\"mov %4, %%\"REG_b\" \\n\\t\"\n\"push %%\"REG_BP\" \\n\\t\"\nYSCALEYUV2RGB1(%%REGBP, %5, %6)\n\"pxor %%mm7, %%mm7 \\n\\t\"\n#ifdef DITHER1XBPP\n\"paddusb \"BLUE_DITHER\"(%5), %%mm2 \\n\\t\"\n\"paddusb \"GREEN_DITHER\"(%5), %%mm4 \\n\\t\"\n\"paddusb \"RED_DITHER\"(%5), %%mm5 \\n\\t\"\n#endif\nWRITERGB15(%%REGb, 8280(%5), %%REGBP)\n\"pop %%\"REG_BP\" \\n\\t\"\n\"mov \"ESP_OFFSET\"(%5), %%\"REG_b\" \\n\\t\"\n:: \"c\" (buf0), \"d\" (VAR_0), \"S\" (ubuf0), \"D\" (ubuf1), \"m\" (dest),\n\"a\" (&c->redDither), \"m\"(uv_off)\n);",
"} else {",
"__asm__ volatile(\n\"mov %%\"REG_b\", \"ESP_OFFSET\"(%5) \\n\\t\"\n\"mov %4, %%\"REG_b\" \\n\\t\"\n\"push %%\"REG_BP\" \\n\\t\"\nYSCALEYUV2RGB1b(%%REGBP, %5, %6)\n\"pxor %%mm7, %%mm7 \\n\\t\"\n#ifdef DITHER1XBPP\n\"paddusb \"BLUE_DITHER\"(%5), %%mm2 \\n\\t\"\n\"paddusb \"GREEN_DITHER\"(%5), %%mm4 \\n\\t\"\n\"paddusb \"RED_DITHER\"(%5), %%mm5 \\n\\t\"\n#endif\nWRITERGB15(%%REGb, 8280(%5), %%REGBP)\n\"pop %%\"REG_BP\" \\n\\t\"\n\"mov \"ESP_OFFSET\"(%5), %%\"REG_b\" \\n\\t\"\n:: \"c\" (buf0), \"d\" (VAR_0), \"S\" (ubuf0), \"D\" (ubuf1), \"m\" (dest),\n\"a\" (&c->redDither), \"m\"(uv_off)\n);",
"}",
"}"
] | [
0,
1,
0,
0,
1,
0,
1,
0,
0
] | [
[
1,
3,
5,
7,
9,
11,
13
],
[
15
],
[
17
],
[
21
],
[
23,
25,
27,
29,
31,
33,
37,
39,
41,
43,
45,
47,
49,
51,
53,
55,
57
],
[
59
],
[
61,
63,
65,
67,
69,
71,
75,
77,
79,
81,
83,
85,
87,
89,
91,
93,
95
],
[
97
],
[
99
]
] |
18,956 | static int vhdx_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
BDRVVHDXState *s = bs->opaque;
int ret = 0;
uint32_t i;
uint64_t signature;
bool log_flushed = false;
s->bat = NULL;
s->first_visible_write = true;
qemu_co_mutex_init(&s->lock);
QLIST_INIT(&s->regions);
/* validate the file signature */
ret = bdrv_pread(bs->file, 0, &signature, sizeof(uint64_t));
if (ret < 0) {
goto fail;
}
if (memcmp(&signature, "vhdxfile", 8)) {
ret = -EINVAL;
goto fail;
}
/* This is used for any header updates, for the file_write_guid.
* The spec dictates that a new value should be used for the first
* header update */
vhdx_guid_generate(&s->session_guid);
ret = vhdx_parse_header(bs, s);
if (ret < 0) {
goto fail;
}
ret = vhdx_parse_log(bs, s, &log_flushed);
if (ret < 0) {
goto fail;
}
ret = vhdx_open_region_tables(bs, s);
if (ret < 0) {
goto fail;
}
ret = vhdx_parse_metadata(bs, s);
if (ret < 0) {
goto fail;
}
s->block_size = s->params.block_size;
/* the VHDX spec dictates that virtual_disk_size is always a multiple of
* logical_sector_size */
bs->total_sectors = s->virtual_disk_size >> s->logical_sector_size_bits;
vhdx_calc_bat_entries(s);
s->bat_offset = s->bat_rt.file_offset;
if (s->bat_entries > s->bat_rt.length / sizeof(VHDXBatEntry)) {
/* BAT allocation is not large enough for all entries */
ret = -EINVAL;
goto fail;
}
/* s->bat is freed in vhdx_close() */
s->bat = qemu_blockalign(bs, s->bat_rt.length);
ret = bdrv_pread(bs->file, s->bat_offset, s->bat, s->bat_rt.length);
if (ret < 0) {
goto fail;
}
uint64_t payblocks = s->chunk_ratio;
/* endian convert, and verify populated BAT field file offsets against
* region table and log entries */
for (i = 0; i < s->bat_entries; i++) {
le64_to_cpus(&s->bat[i]);
if (payblocks--) {
/* payload bat entries */
if ((s->bat[i] & VHDX_BAT_STATE_BIT_MASK) ==
PAYLOAD_BLOCK_FULLY_PRESENT) {
ret = vhdx_region_check(s, s->bat[i] & VHDX_BAT_FILE_OFF_MASK,
s->block_size);
if (ret < 0) {
goto fail;
}
}
} else {
payblocks = s->chunk_ratio;
/* Once differencing files are supported, verify sector bitmap
* blocks here */
}
}
if (flags & BDRV_O_RDWR) {
ret = vhdx_update_headers(bs, s, false, NULL);
if (ret < 0) {
goto fail;
}
}
/* TODO: differencing files */
/* Disable migration when VHDX images are used */
error_set(&s->migration_blocker,
QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED,
"vhdx", bs->device_name, "live migration");
migrate_add_blocker(s->migration_blocker);
return 0;
fail:
vhdx_close(bs);
return ret;
}
| true | qemu | 7e30e6a6746b417c7e0dbc9af009560fbb63f336 | static int vhdx_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
BDRVVHDXState *s = bs->opaque;
int ret = 0;
uint32_t i;
uint64_t signature;
bool log_flushed = false;
s->bat = NULL;
s->first_visible_write = true;
qemu_co_mutex_init(&s->lock);
QLIST_INIT(&s->regions);
ret = bdrv_pread(bs->file, 0, &signature, sizeof(uint64_t));
if (ret < 0) {
goto fail;
}
if (memcmp(&signature, "vhdxfile", 8)) {
ret = -EINVAL;
goto fail;
}
vhdx_guid_generate(&s->session_guid);
ret = vhdx_parse_header(bs, s);
if (ret < 0) {
goto fail;
}
ret = vhdx_parse_log(bs, s, &log_flushed);
if (ret < 0) {
goto fail;
}
ret = vhdx_open_region_tables(bs, s);
if (ret < 0) {
goto fail;
}
ret = vhdx_parse_metadata(bs, s);
if (ret < 0) {
goto fail;
}
s->block_size = s->params.block_size;
bs->total_sectors = s->virtual_disk_size >> s->logical_sector_size_bits;
vhdx_calc_bat_entries(s);
s->bat_offset = s->bat_rt.file_offset;
if (s->bat_entries > s->bat_rt.length / sizeof(VHDXBatEntry)) {
ret = -EINVAL;
goto fail;
}
s->bat = qemu_blockalign(bs, s->bat_rt.length);
ret = bdrv_pread(bs->file, s->bat_offset, s->bat, s->bat_rt.length);
if (ret < 0) {
goto fail;
}
uint64_t payblocks = s->chunk_ratio;
for (i = 0; i < s->bat_entries; i++) {
le64_to_cpus(&s->bat[i]);
if (payblocks--) {
if ((s->bat[i] & VHDX_BAT_STATE_BIT_MASK) ==
PAYLOAD_BLOCK_FULLY_PRESENT) {
ret = vhdx_region_check(s, s->bat[i] & VHDX_BAT_FILE_OFF_MASK,
s->block_size);
if (ret < 0) {
goto fail;
}
}
} else {
payblocks = s->chunk_ratio;
}
}
if (flags & BDRV_O_RDWR) {
ret = vhdx_update_headers(bs, s, false, NULL);
if (ret < 0) {
goto fail;
}
}
error_set(&s->migration_blocker,
QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED,
"vhdx", bs->device_name, "live migration");
migrate_add_blocker(s->migration_blocker);
return 0;
fail:
vhdx_close(bs);
return ret;
}
| {
"code": [
" bool log_flushed = false;",
" ret = vhdx_parse_log(bs, s, &log_flushed);"
],
"line_no": [
15,
73
]
} | static int FUNC_0(BlockDriverState *VAR_0, QDict *VAR_1, int VAR_2,
Error **VAR_3)
{
BDRVVHDXState *s = VAR_0->opaque;
int VAR_4 = 0;
uint32_t i;
uint64_t signature;
bool log_flushed = false;
s->bat = NULL;
s->first_visible_write = true;
qemu_co_mutex_init(&s->lock);
QLIST_INIT(&s->regions);
VAR_4 = bdrv_pread(VAR_0->file, 0, &signature, sizeof(uint64_t));
if (VAR_4 < 0) {
goto fail;
}
if (memcmp(&signature, "vhdxfile", 8)) {
VAR_4 = -EINVAL;
goto fail;
}
vhdx_guid_generate(&s->session_guid);
VAR_4 = vhdx_parse_header(VAR_0, s);
if (VAR_4 < 0) {
goto fail;
}
VAR_4 = vhdx_parse_log(VAR_0, s, &log_flushed);
if (VAR_4 < 0) {
goto fail;
}
VAR_4 = vhdx_open_region_tables(VAR_0, s);
if (VAR_4 < 0) {
goto fail;
}
VAR_4 = vhdx_parse_metadata(VAR_0, s);
if (VAR_4 < 0) {
goto fail;
}
s->block_size = s->params.block_size;
VAR_0->total_sectors = s->virtual_disk_size >> s->logical_sector_size_bits;
vhdx_calc_bat_entries(s);
s->bat_offset = s->bat_rt.file_offset;
if (s->bat_entries > s->bat_rt.length / sizeof(VHDXBatEntry)) {
VAR_4 = -EINVAL;
goto fail;
}
s->bat = qemu_blockalign(VAR_0, s->bat_rt.length);
VAR_4 = bdrv_pread(VAR_0->file, s->bat_offset, s->bat, s->bat_rt.length);
if (VAR_4 < 0) {
goto fail;
}
uint64_t payblocks = s->chunk_ratio;
for (i = 0; i < s->bat_entries; i++) {
le64_to_cpus(&s->bat[i]);
if (payblocks--) {
if ((s->bat[i] & VHDX_BAT_STATE_BIT_MASK) ==
PAYLOAD_BLOCK_FULLY_PRESENT) {
VAR_4 = vhdx_region_check(s, s->bat[i] & VHDX_BAT_FILE_OFF_MASK,
s->block_size);
if (VAR_4 < 0) {
goto fail;
}
}
} else {
payblocks = s->chunk_ratio;
}
}
if (VAR_2 & BDRV_O_RDWR) {
VAR_4 = vhdx_update_headers(VAR_0, s, false, NULL);
if (VAR_4 < 0) {
goto fail;
}
}
error_set(&s->migration_blocker,
QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED,
"vhdx", VAR_0->device_name, "live migration");
migrate_add_blocker(s->migration_blocker);
return 0;
fail:
vhdx_close(VAR_0);
return VAR_4;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, QDict *VAR_1, int VAR_2,\nError **VAR_3)\n{",
"BDRVVHDXState *s = VAR_0->opaque;",
"int VAR_4 = 0;",
"uint32_t i;",
"uint64_t signature;",
"bool log_flushed = false;",
"s->bat = NULL;",
"s->first_visible_write = true;",
"qemu_co_mutex_init(&s->lock);",
"QLIST_INIT(&s->regions);",
"VAR_4 = bdrv_pread(VAR_0->file, 0, &signature, sizeof(uint64_t));",
"if (VAR_4 < 0) {",
"goto fail;",
"}",
"if (memcmp(&signature, \"vhdxfile\", 8)) {",
"VAR_4 = -EINVAL;",
"goto fail;",
"}",
"vhdx_guid_generate(&s->session_guid);",
"VAR_4 = vhdx_parse_header(VAR_0, s);",
"if (VAR_4 < 0) {",
"goto fail;",
"}",
"VAR_4 = vhdx_parse_log(VAR_0, s, &log_flushed);",
"if (VAR_4 < 0) {",
"goto fail;",
"}",
"VAR_4 = vhdx_open_region_tables(VAR_0, s);",
"if (VAR_4 < 0) {",
"goto fail;",
"}",
"VAR_4 = vhdx_parse_metadata(VAR_0, s);",
"if (VAR_4 < 0) {",
"goto fail;",
"}",
"s->block_size = s->params.block_size;",
"VAR_0->total_sectors = s->virtual_disk_size >> s->logical_sector_size_bits;",
"vhdx_calc_bat_entries(s);",
"s->bat_offset = s->bat_rt.file_offset;",
"if (s->bat_entries > s->bat_rt.length / sizeof(VHDXBatEntry)) {",
"VAR_4 = -EINVAL;",
"goto fail;",
"}",
"s->bat = qemu_blockalign(VAR_0, s->bat_rt.length);",
"VAR_4 = bdrv_pread(VAR_0->file, s->bat_offset, s->bat, s->bat_rt.length);",
"if (VAR_4 < 0) {",
"goto fail;",
"}",
"uint64_t payblocks = s->chunk_ratio;",
"for (i = 0; i < s->bat_entries; i++) {",
"le64_to_cpus(&s->bat[i]);",
"if (payblocks--) {",
"if ((s->bat[i] & VHDX_BAT_STATE_BIT_MASK) ==\nPAYLOAD_BLOCK_FULLY_PRESENT) {",
"VAR_4 = vhdx_region_check(s, s->bat[i] & VHDX_BAT_FILE_OFF_MASK,\ns->block_size);",
"if (VAR_4 < 0) {",
"goto fail;",
"}",
"}",
"} else {",
"payblocks = s->chunk_ratio;",
"}",
"}",
"if (VAR_2 & BDRV_O_RDWR) {",
"VAR_4 = vhdx_update_headers(VAR_0, s, false, NULL);",
"if (VAR_4 < 0) {",
"goto fail;",
"}",
"}",
"error_set(&s->migration_blocker,\nQERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED,\n\"vhdx\", VAR_0->device_name, \"live migration\");",
"migrate_add_blocker(s->migration_blocker);",
"return 0;",
"fail:\nvhdx_close(VAR_0);",
"return VAR_4;",
"}"
] | [
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
27
],
[
29
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93
],
[
95
],
[
97
],
[
99
],
[
103
],
[
111
],
[
115
],
[
119
],
[
123
],
[
127
],
[
129
],
[
131
],
[
137
],
[
141
],
[
143
],
[
145
],
[
147
],
[
151
],
[
157
],
[
159
],
[
161
],
[
165,
167
],
[
169,
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
189
],
[
191
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
215,
217,
219
],
[
221
],
[
225
],
[
227,
229
],
[
231
],
[
233
]
] |
18,957 | FFAMediaCodec* ff_AMediaCodec_createEncoderByType(const char *mime)
{
JNIEnv *env = NULL;
FFAMediaCodec *codec = NULL;
jstring mime_type = NULL;
codec = av_mallocz(sizeof(FFAMediaCodec));
if (!codec) {
return NULL;
}
codec->class = &amediacodec_class;
env = ff_jni_get_env(codec);
if (!env) {
av_freep(&codec);
return NULL;
}
if (ff_jni_init_jfields(env, &codec->jfields, jni_amediacodec_mapping, 1, codec) < 0) {
goto fail;
}
mime_type = ff_jni_utf_chars_to_jstring(env, mime, codec);
if (!mime_type) {
goto fail;
}
codec->object = (*env)->CallStaticObjectMethod(env, codec->jfields.mediacodec_class, codec->jfields.create_encoder_by_type_id, mime_type);
if (ff_jni_exception_check(env, 1, codec) < 0) {
goto fail;
}
codec->object = (*env)->NewGlobalRef(env, codec->object);
if (!codec->object) {
goto fail;
}
if (codec_init_static_fields(codec) < 0) {
goto fail;
}
if (codec->jfields.get_input_buffer_id && codec->jfields.get_output_buffer_id) {
codec->has_get_i_o_buffer = 1;
}
return codec;
fail:
ff_jni_reset_jfields(env, &codec->jfields, jni_amediacodec_mapping, 1, codec);
if (mime_type) {
(*env)->DeleteLocalRef(env, mime_type);
}
av_freep(&codec);
return NULL;
}
| true | FFmpeg | 1795dccde0ad22fc8201142f92fb8d58c234f3e4 | FFAMediaCodec* ff_AMediaCodec_createEncoderByType(const char *mime)
{
JNIEnv *env = NULL;
FFAMediaCodec *codec = NULL;
jstring mime_type = NULL;
codec = av_mallocz(sizeof(FFAMediaCodec));
if (!codec) {
return NULL;
}
codec->class = &amediacodec_class;
env = ff_jni_get_env(codec);
if (!env) {
av_freep(&codec);
return NULL;
}
if (ff_jni_init_jfields(env, &codec->jfields, jni_amediacodec_mapping, 1, codec) < 0) {
goto fail;
}
mime_type = ff_jni_utf_chars_to_jstring(env, mime, codec);
if (!mime_type) {
goto fail;
}
codec->object = (*env)->CallStaticObjectMethod(env, codec->jfields.mediacodec_class, codec->jfields.create_encoder_by_type_id, mime_type);
if (ff_jni_exception_check(env, 1, codec) < 0) {
goto fail;
}
codec->object = (*env)->NewGlobalRef(env, codec->object);
if (!codec->object) {
goto fail;
}
if (codec_init_static_fields(codec) < 0) {
goto fail;
}
if (codec->jfields.get_input_buffer_id && codec->jfields.get_output_buffer_id) {
codec->has_get_i_o_buffer = 1;
}
return codec;
fail:
ff_jni_reset_jfields(env, &codec->jfields, jni_amediacodec_mapping, 1, codec);
if (mime_type) {
(*env)->DeleteLocalRef(env, mime_type);
}
av_freep(&codec);
return NULL;
}
| {
"code": [
" codec->object = (*env)->NewGlobalRef(env, codec->object);",
" return codec;",
" ff_jni_reset_jfields(env, &codec->jfields, jni_amediacodec_mapping, 1, codec);",
" av_freep(&codec);",
" return NULL;",
" codec->object = (*env)->NewGlobalRef(env, codec->object);",
" return codec;",
" ff_jni_reset_jfields(env, &codec->jfields, jni_amediacodec_mapping, 1, codec);",
" av_freep(&codec);",
" return NULL;",
" codec->object = (*env)->CallStaticObjectMethod(env, codec->jfields.mediacodec_class, codec->jfields.create_encoder_by_type_id, mime_type);",
" codec->object = (*env)->NewGlobalRef(env, codec->object);",
" return codec;",
" ff_jni_reset_jfields(env, &codec->jfields, jni_amediacodec_mapping, 1, codec);",
" av_freep(&codec);",
" return NULL;"
],
"line_no": [
65,
91,
95,
107,
111,
65,
91,
95,
107,
111,
55,
65,
91,
95,
107,
111
]
} | FFAMediaCodec* FUNC_0(const char *mime)
{
JNIEnv *env = NULL;
FFAMediaCodec *codec = NULL;
jstring mime_type = NULL;
codec = av_mallocz(sizeof(FFAMediaCodec));
if (!codec) {
return NULL;
}
codec->class = &amediacodec_class;
env = ff_jni_get_env(codec);
if (!env) {
av_freep(&codec);
return NULL;
}
if (ff_jni_init_jfields(env, &codec->jfields, jni_amediacodec_mapping, 1, codec) < 0) {
goto fail;
}
mime_type = ff_jni_utf_chars_to_jstring(env, mime, codec);
if (!mime_type) {
goto fail;
}
codec->object = (*env)->CallStaticObjectMethod(env, codec->jfields.mediacodec_class, codec->jfields.create_encoder_by_type_id, mime_type);
if (ff_jni_exception_check(env, 1, codec) < 0) {
goto fail;
}
codec->object = (*env)->NewGlobalRef(env, codec->object);
if (!codec->object) {
goto fail;
}
if (codec_init_static_fields(codec) < 0) {
goto fail;
}
if (codec->jfields.get_input_buffer_id && codec->jfields.get_output_buffer_id) {
codec->has_get_i_o_buffer = 1;
}
return codec;
fail:
ff_jni_reset_jfields(env, &codec->jfields, jni_amediacodec_mapping, 1, codec);
if (mime_type) {
(*env)->DeleteLocalRef(env, mime_type);
}
av_freep(&codec);
return NULL;
}
| [
"FFAMediaCodec* FUNC_0(const char *mime)\n{",
"JNIEnv *env = NULL;",
"FFAMediaCodec *codec = NULL;",
"jstring mime_type = NULL;",
"codec = av_mallocz(sizeof(FFAMediaCodec));",
"if (!codec) {",
"return NULL;",
"}",
"codec->class = &amediacodec_class;",
"env = ff_jni_get_env(codec);",
"if (!env) {",
"av_freep(&codec);",
"return NULL;",
"}",
"if (ff_jni_init_jfields(env, &codec->jfields, jni_amediacodec_mapping, 1, codec) < 0) {",
"goto fail;",
"}",
"mime_type = ff_jni_utf_chars_to_jstring(env, mime, codec);",
"if (!mime_type) {",
"goto fail;",
"}",
"codec->object = (*env)->CallStaticObjectMethod(env, codec->jfields.mediacodec_class, codec->jfields.create_encoder_by_type_id, mime_type);",
"if (ff_jni_exception_check(env, 1, codec) < 0) {",
"goto fail;",
"}",
"codec->object = (*env)->NewGlobalRef(env, codec->object);",
"if (!codec->object) {",
"goto fail;",
"}",
"if (codec_init_static_fields(codec) < 0) {",
"goto fail;",
"}",
"if (codec->jfields.get_input_buffer_id && codec->jfields.get_output_buffer_id) {",
"codec->has_get_i_o_buffer = 1;",
"}",
"return codec;",
"fail:\nff_jni_reset_jfields(env, &codec->jfields, jni_amediacodec_mapping, 1, codec);",
"if (mime_type) {",
"(*env)->DeleteLocalRef(env, mime_type);",
"}",
"av_freep(&codec);",
"return NULL;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
],
[
87
],
[
91
],
[
93,
95
],
[
99
],
[
101
],
[
103
],
[
107
],
[
111
],
[
113
]
] |
18,958 | static int mov_write_uuidprof_tag(AVIOContext *pb, AVFormatContext *s)
{
AVStream *video_st = s->streams[0];
AVCodecParameters *video_par = s->streams[0]->codecpar;
AVCodecParameters *audio_par = s->streams[1]->codecpar;
int audio_rate = audio_par->sample_rate;
int64_t frame_rate = (video_st->avg_frame_rate.num * 0x10000LL) / video_st->avg_frame_rate.den;
int audio_kbitrate = audio_par->bit_rate / 1000;
int video_kbitrate = FFMIN(video_par->bit_rate / 1000, 800 - audio_kbitrate);
if (frame_rate < 0 || frame_rate > INT32_MAX) {
av_log(s, AV_LOG_ERROR, "Frame rate %f outside supported range\n", frame_rate / (double)0x10000);
return AVERROR(EINVAL);
}
avio_wb32(pb, 0x94); /* size */
ffio_wfourcc(pb, "uuid");
ffio_wfourcc(pb, "PROF");
avio_wb32(pb, 0x21d24fce); /* 96 bit UUID */
avio_wb32(pb, 0xbb88695c);
avio_wb32(pb, 0xfac9c740);
avio_wb32(pb, 0x0); /* ? */
avio_wb32(pb, 0x3); /* 3 sections ? */
avio_wb32(pb, 0x14); /* size */
ffio_wfourcc(pb, "FPRF");
avio_wb32(pb, 0x0); /* ? */
avio_wb32(pb, 0x0); /* ? */
avio_wb32(pb, 0x0); /* ? */
avio_wb32(pb, 0x2c); /* size */
ffio_wfourcc(pb, "APRF"); /* audio */
avio_wb32(pb, 0x0);
avio_wb32(pb, 0x2); /* TrackID */
ffio_wfourcc(pb, "mp4a");
avio_wb32(pb, 0x20f);
avio_wb32(pb, 0x0);
avio_wb32(pb, audio_kbitrate);
avio_wb32(pb, audio_kbitrate);
avio_wb32(pb, audio_rate);
avio_wb32(pb, audio_par->channels);
avio_wb32(pb, 0x34); /* size */
ffio_wfourcc(pb, "VPRF"); /* video */
avio_wb32(pb, 0x0);
avio_wb32(pb, 0x1); /* TrackID */
if (video_par->codec_id == AV_CODEC_ID_H264) {
ffio_wfourcc(pb, "avc1");
avio_wb16(pb, 0x014D);
avio_wb16(pb, 0x0015);
} else {
ffio_wfourcc(pb, "mp4v");
avio_wb16(pb, 0x0000);
avio_wb16(pb, 0x0103);
}
avio_wb32(pb, 0x0);
avio_wb32(pb, video_kbitrate);
avio_wb32(pb, video_kbitrate);
avio_wb32(pb, frame_rate);
avio_wb32(pb, frame_rate);
avio_wb16(pb, video_par->width);
avio_wb16(pb, video_par->height);
avio_wb32(pb, 0x010001); /* ? */
return 0;
}
| true | FFmpeg | 709c87109dc856abff9c905dfda3ca954453828a | static int mov_write_uuidprof_tag(AVIOContext *pb, AVFormatContext *s)
{
AVStream *video_st = s->streams[0];
AVCodecParameters *video_par = s->streams[0]->codecpar;
AVCodecParameters *audio_par = s->streams[1]->codecpar;
int audio_rate = audio_par->sample_rate;
int64_t frame_rate = (video_st->avg_frame_rate.num * 0x10000LL) / video_st->avg_frame_rate.den;
int audio_kbitrate = audio_par->bit_rate / 1000;
int video_kbitrate = FFMIN(video_par->bit_rate / 1000, 800 - audio_kbitrate);
if (frame_rate < 0 || frame_rate > INT32_MAX) {
av_log(s, AV_LOG_ERROR, "Frame rate %f outside supported range\n", frame_rate / (double)0x10000);
return AVERROR(EINVAL);
}
avio_wb32(pb, 0x94);
ffio_wfourcc(pb, "uuid");
ffio_wfourcc(pb, "PROF");
avio_wb32(pb, 0x21d24fce);
avio_wb32(pb, 0xbb88695c);
avio_wb32(pb, 0xfac9c740);
avio_wb32(pb, 0x0);
avio_wb32(pb, 0x3);
avio_wb32(pb, 0x14);
ffio_wfourcc(pb, "FPRF");
avio_wb32(pb, 0x0);
avio_wb32(pb, 0x0);
avio_wb32(pb, 0x0);
avio_wb32(pb, 0x2c);
ffio_wfourcc(pb, "APRF");
avio_wb32(pb, 0x0);
avio_wb32(pb, 0x2);
ffio_wfourcc(pb, "mp4a");
avio_wb32(pb, 0x20f);
avio_wb32(pb, 0x0);
avio_wb32(pb, audio_kbitrate);
avio_wb32(pb, audio_kbitrate);
avio_wb32(pb, audio_rate);
avio_wb32(pb, audio_par->channels);
avio_wb32(pb, 0x34);
ffio_wfourcc(pb, "VPRF");
avio_wb32(pb, 0x0);
avio_wb32(pb, 0x1);
if (video_par->codec_id == AV_CODEC_ID_H264) {
ffio_wfourcc(pb, "avc1");
avio_wb16(pb, 0x014D);
avio_wb16(pb, 0x0015);
} else {
ffio_wfourcc(pb, "mp4v");
avio_wb16(pb, 0x0000);
avio_wb16(pb, 0x0103);
}
avio_wb32(pb, 0x0);
avio_wb32(pb, video_kbitrate);
avio_wb32(pb, video_kbitrate);
avio_wb32(pb, frame_rate);
avio_wb32(pb, frame_rate);
avio_wb16(pb, video_par->width);
avio_wb16(pb, video_par->height);
avio_wb32(pb, 0x010001);
return 0;
}
| {
"code": [
" int64_t frame_rate = (video_st->avg_frame_rate.num * 0x10000LL) / video_st->avg_frame_rate.den;"
],
"line_no": [
13
]
} | static int FUNC_0(AVIOContext *VAR_0, AVFormatContext *VAR_1)
{
AVStream *video_st = VAR_1->streams[0];
AVCodecParameters *video_par = VAR_1->streams[0]->codecpar;
AVCodecParameters *audio_par = VAR_1->streams[1]->codecpar;
int VAR_2 = audio_par->sample_rate;
int64_t frame_rate = (video_st->avg_frame_rate.num * 0x10000LL) / video_st->avg_frame_rate.den;
int VAR_3 = audio_par->bit_rate / 1000;
int VAR_4 = FFMIN(video_par->bit_rate / 1000, 800 - VAR_3);
if (frame_rate < 0 || frame_rate > INT32_MAX) {
av_log(VAR_1, AV_LOG_ERROR, "Frame rate %f outside supported range\n", frame_rate / (double)0x10000);
return AVERROR(EINVAL);
}
avio_wb32(VAR_0, 0x94);
ffio_wfourcc(VAR_0, "uuid");
ffio_wfourcc(VAR_0, "PROF");
avio_wb32(VAR_0, 0x21d24fce);
avio_wb32(VAR_0, 0xbb88695c);
avio_wb32(VAR_0, 0xfac9c740);
avio_wb32(VAR_0, 0x0);
avio_wb32(VAR_0, 0x3);
avio_wb32(VAR_0, 0x14);
ffio_wfourcc(VAR_0, "FPRF");
avio_wb32(VAR_0, 0x0);
avio_wb32(VAR_0, 0x0);
avio_wb32(VAR_0, 0x0);
avio_wb32(VAR_0, 0x2c);
ffio_wfourcc(VAR_0, "APRF");
avio_wb32(VAR_0, 0x0);
avio_wb32(VAR_0, 0x2);
ffio_wfourcc(VAR_0, "mp4a");
avio_wb32(VAR_0, 0x20f);
avio_wb32(VAR_0, 0x0);
avio_wb32(VAR_0, VAR_3);
avio_wb32(VAR_0, VAR_3);
avio_wb32(VAR_0, VAR_2);
avio_wb32(VAR_0, audio_par->channels);
avio_wb32(VAR_0, 0x34);
ffio_wfourcc(VAR_0, "VPRF");
avio_wb32(VAR_0, 0x0);
avio_wb32(VAR_0, 0x1);
if (video_par->codec_id == AV_CODEC_ID_H264) {
ffio_wfourcc(VAR_0, "avc1");
avio_wb16(VAR_0, 0x014D);
avio_wb16(VAR_0, 0x0015);
} else {
ffio_wfourcc(VAR_0, "mp4v");
avio_wb16(VAR_0, 0x0000);
avio_wb16(VAR_0, 0x0103);
}
avio_wb32(VAR_0, 0x0);
avio_wb32(VAR_0, VAR_4);
avio_wb32(VAR_0, VAR_4);
avio_wb32(VAR_0, frame_rate);
avio_wb32(VAR_0, frame_rate);
avio_wb16(VAR_0, video_par->width);
avio_wb16(VAR_0, video_par->height);
avio_wb32(VAR_0, 0x010001);
return 0;
}
| [
"static int FUNC_0(AVIOContext *VAR_0, AVFormatContext *VAR_1)\n{",
"AVStream *video_st = VAR_1->streams[0];",
"AVCodecParameters *video_par = VAR_1->streams[0]->codecpar;",
"AVCodecParameters *audio_par = VAR_1->streams[1]->codecpar;",
"int VAR_2 = audio_par->sample_rate;",
"int64_t frame_rate = (video_st->avg_frame_rate.num * 0x10000LL) / video_st->avg_frame_rate.den;",
"int VAR_3 = audio_par->bit_rate / 1000;",
"int VAR_4 = FFMIN(video_par->bit_rate / 1000, 800 - VAR_3);",
"if (frame_rate < 0 || frame_rate > INT32_MAX) {",
"av_log(VAR_1, AV_LOG_ERROR, \"Frame rate %f outside supported range\\n\", frame_rate / (double)0x10000);",
"return AVERROR(EINVAL);",
"}",
"avio_wb32(VAR_0, 0x94);",
"ffio_wfourcc(VAR_0, \"uuid\");",
"ffio_wfourcc(VAR_0, \"PROF\");",
"avio_wb32(VAR_0, 0x21d24fce);",
"avio_wb32(VAR_0, 0xbb88695c);",
"avio_wb32(VAR_0, 0xfac9c740);",
"avio_wb32(VAR_0, 0x0);",
"avio_wb32(VAR_0, 0x3);",
"avio_wb32(VAR_0, 0x14);",
"ffio_wfourcc(VAR_0, \"FPRF\");",
"avio_wb32(VAR_0, 0x0);",
"avio_wb32(VAR_0, 0x0);",
"avio_wb32(VAR_0, 0x0);",
"avio_wb32(VAR_0, 0x2c);",
"ffio_wfourcc(VAR_0, \"APRF\");",
"avio_wb32(VAR_0, 0x0);",
"avio_wb32(VAR_0, 0x2);",
"ffio_wfourcc(VAR_0, \"mp4a\");",
"avio_wb32(VAR_0, 0x20f);",
"avio_wb32(VAR_0, 0x0);",
"avio_wb32(VAR_0, VAR_3);",
"avio_wb32(VAR_0, VAR_3);",
"avio_wb32(VAR_0, VAR_2);",
"avio_wb32(VAR_0, audio_par->channels);",
"avio_wb32(VAR_0, 0x34);",
"ffio_wfourcc(VAR_0, \"VPRF\");",
"avio_wb32(VAR_0, 0x0);",
"avio_wb32(VAR_0, 0x1);",
"if (video_par->codec_id == AV_CODEC_ID_H264) {",
"ffio_wfourcc(VAR_0, \"avc1\");",
"avio_wb16(VAR_0, 0x014D);",
"avio_wb16(VAR_0, 0x0015);",
"} else {",
"ffio_wfourcc(VAR_0, \"mp4v\");",
"avio_wb16(VAR_0, 0x0000);",
"avio_wb16(VAR_0, 0x0103);",
"}",
"avio_wb32(VAR_0, 0x0);",
"avio_wb32(VAR_0, VAR_4);",
"avio_wb32(VAR_0, VAR_4);",
"avio_wb32(VAR_0, frame_rate);",
"avio_wb32(VAR_0, frame_rate);",
"avio_wb16(VAR_0, video_par->width);",
"avio_wb16(VAR_0, video_par->height);",
"avio_wb32(VAR_0, 0x010001);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
133
],
[
135
]
] |
18,960 | void av_thread_message_queue_free(AVThreadMessageQueue **mq)
{
#if HAVE_THREADS
if (*mq) {
av_thread_message_flush(*mq);
av_fifo_freep(&(*mq)->fifo);
pthread_cond_destroy(&(*mq)->cond);
pthread_mutex_destroy(&(*mq)->lock);
av_freep(mq);
}
#endif
}
| true | FFmpeg | bd5c860fdbc33d19d2ff0f6d1f06de07c17560dd | void av_thread_message_queue_free(AVThreadMessageQueue **mq)
{
#if HAVE_THREADS
if (*mq) {
av_thread_message_flush(*mq);
av_fifo_freep(&(*mq)->fifo);
pthread_cond_destroy(&(*mq)->cond);
pthread_mutex_destroy(&(*mq)->lock);
av_freep(mq);
}
#endif
}
| {
"code": [
" pthread_cond_destroy(&(*mq)->cond);"
],
"line_no": [
13
]
} | void FUNC_0(AVThreadMessageQueue **VAR_0)
{
#if HAVE_THREADS
if (*VAR_0) {
av_thread_message_flush(*VAR_0);
av_fifo_freep(&(*VAR_0)->fifo);
pthread_cond_destroy(&(*VAR_0)->cond);
pthread_mutex_destroy(&(*VAR_0)->lock);
av_freep(VAR_0);
}
#endif
}
| [
"void FUNC_0(AVThreadMessageQueue **VAR_0)\n{",
"#if HAVE_THREADS\nif (*VAR_0) {",
"av_thread_message_flush(*VAR_0);",
"av_fifo_freep(&(*VAR_0)->fifo);",
"pthread_cond_destroy(&(*VAR_0)->cond);",
"pthread_mutex_destroy(&(*VAR_0)->lock);",
"av_freep(VAR_0);",
"}",
"#endif\n}"
] | [
0,
0,
0,
0,
1,
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21,
23
]
] |
18,961 | static void vhdx_parse_header(BlockDriverState *bs, BDRVVHDXState *s,
Error **errp)
{
int ret;
VHDXHeader *header1;
VHDXHeader *header2;
bool h1_valid = false;
bool h2_valid = false;
uint64_t h1_seq = 0;
uint64_t h2_seq = 0;
uint8_t *buffer;
/* header1 & header2 are freed in vhdx_close() */
header1 = qemu_blockalign(bs, sizeof(VHDXHeader));
header2 = qemu_blockalign(bs, sizeof(VHDXHeader));
buffer = qemu_blockalign(bs, VHDX_HEADER_SIZE);
s->headers[0] = header1;
s->headers[1] = header2;
/* We have to read the whole VHDX_HEADER_SIZE instead of
* sizeof(VHDXHeader), because the checksum is over the whole
* region */
ret = bdrv_pread(bs->file, VHDX_HEADER1_OFFSET, buffer, VHDX_HEADER_SIZE);
if (ret < 0) {
goto fail;
}
/* copy over just the relevant portion that we need */
memcpy(header1, buffer, sizeof(VHDXHeader));
vhdx_header_le_import(header1);
if (vhdx_checksum_is_valid(buffer, VHDX_HEADER_SIZE, 4) &&
!memcmp(&header1->signature, "head", 4) &&
header1->version == 1) {
h1_seq = header1->sequence_number;
h1_valid = true;
}
ret = bdrv_pread(bs->file, VHDX_HEADER2_OFFSET, buffer, VHDX_HEADER_SIZE);
if (ret < 0) {
goto fail;
}
/* copy over just the relevant portion that we need */
memcpy(header2, buffer, sizeof(VHDXHeader));
vhdx_header_le_import(header2);
if (vhdx_checksum_is_valid(buffer, VHDX_HEADER_SIZE, 4) &&
!memcmp(&header2->signature, "head", 4) &&
header2->version == 1) {
h2_seq = header2->sequence_number;
h2_valid = true;
}
/* If there is only 1 valid header (or no valid headers), we
* don't care what the sequence numbers are */
if (h1_valid && !h2_valid) {
s->curr_header = 0;
} else if (!h1_valid && h2_valid) {
s->curr_header = 1;
} else if (!h1_valid && !h2_valid) {
goto fail;
} else {
/* If both headers are valid, then we choose the active one by the
* highest sequence number. If the sequence numbers are equal, that is
* invalid */
if (h1_seq > h2_seq) {
s->curr_header = 0;
} else if (h2_seq > h1_seq) {
s->curr_header = 1;
} else {
goto fail;
}
}
vhdx_region_register(s, s->headers[s->curr_header]->log_offset,
s->headers[s->curr_header]->log_length);
goto exit;
fail:
error_setg_errno(errp, -ret, "No valid VHDX header found");
qemu_vfree(header1);
qemu_vfree(header2);
s->headers[0] = NULL;
s->headers[1] = NULL;
exit:
qemu_vfree(buffer);
}
| true | qemu | 6906046169ffa9d829beeeaafe1fadeba51669fb | static void vhdx_parse_header(BlockDriverState *bs, BDRVVHDXState *s,
Error **errp)
{
int ret;
VHDXHeader *header1;
VHDXHeader *header2;
bool h1_valid = false;
bool h2_valid = false;
uint64_t h1_seq = 0;
uint64_t h2_seq = 0;
uint8_t *buffer;
header1 = qemu_blockalign(bs, sizeof(VHDXHeader));
header2 = qemu_blockalign(bs, sizeof(VHDXHeader));
buffer = qemu_blockalign(bs, VHDX_HEADER_SIZE);
s->headers[0] = header1;
s->headers[1] = header2;
ret = bdrv_pread(bs->file, VHDX_HEADER1_OFFSET, buffer, VHDX_HEADER_SIZE);
if (ret < 0) {
goto fail;
}
memcpy(header1, buffer, sizeof(VHDXHeader));
vhdx_header_le_import(header1);
if (vhdx_checksum_is_valid(buffer, VHDX_HEADER_SIZE, 4) &&
!memcmp(&header1->signature, "head", 4) &&
header1->version == 1) {
h1_seq = header1->sequence_number;
h1_valid = true;
}
ret = bdrv_pread(bs->file, VHDX_HEADER2_OFFSET, buffer, VHDX_HEADER_SIZE);
if (ret < 0) {
goto fail;
}
memcpy(header2, buffer, sizeof(VHDXHeader));
vhdx_header_le_import(header2);
if (vhdx_checksum_is_valid(buffer, VHDX_HEADER_SIZE, 4) &&
!memcmp(&header2->signature, "head", 4) &&
header2->version == 1) {
h2_seq = header2->sequence_number;
h2_valid = true;
}
if (h1_valid && !h2_valid) {
s->curr_header = 0;
} else if (!h1_valid && h2_valid) {
s->curr_header = 1;
} else if (!h1_valid && !h2_valid) {
goto fail;
} else {
if (h1_seq > h2_seq) {
s->curr_header = 0;
} else if (h2_seq > h1_seq) {
s->curr_header = 1;
} else {
goto fail;
}
}
vhdx_region_register(s, s->headers[s->curr_header]->log_offset,
s->headers[s->curr_header]->log_length);
goto exit;
fail:
error_setg_errno(errp, -ret, "No valid VHDX header found");
qemu_vfree(header1);
qemu_vfree(header2);
s->headers[0] = NULL;
s->headers[1] = NULL;
exit:
qemu_vfree(buffer);
}
| {
"code": [
" goto fail;"
],
"line_no": [
143
]
} | static void FUNC_0(BlockDriverState *VAR_0, BDRVVHDXState *VAR_1,
Error **VAR_2)
{
int VAR_3;
VHDXHeader *header1;
VHDXHeader *header2;
bool h1_valid = false;
bool h2_valid = false;
uint64_t h1_seq = 0;
uint64_t h2_seq = 0;
uint8_t *buffer;
header1 = qemu_blockalign(VAR_0, sizeof(VHDXHeader));
header2 = qemu_blockalign(VAR_0, sizeof(VHDXHeader));
buffer = qemu_blockalign(VAR_0, VHDX_HEADER_SIZE);
VAR_1->headers[0] = header1;
VAR_1->headers[1] = header2;
VAR_3 = bdrv_pread(VAR_0->file, VHDX_HEADER1_OFFSET, buffer, VHDX_HEADER_SIZE);
if (VAR_3 < 0) {
goto fail;
}
memcpy(header1, buffer, sizeof(VHDXHeader));
vhdx_header_le_import(header1);
if (vhdx_checksum_is_valid(buffer, VHDX_HEADER_SIZE, 4) &&
!memcmp(&header1->signature, "head", 4) &&
header1->version == 1) {
h1_seq = header1->sequence_number;
h1_valid = true;
}
VAR_3 = bdrv_pread(VAR_0->file, VHDX_HEADER2_OFFSET, buffer, VHDX_HEADER_SIZE);
if (VAR_3 < 0) {
goto fail;
}
memcpy(header2, buffer, sizeof(VHDXHeader));
vhdx_header_le_import(header2);
if (vhdx_checksum_is_valid(buffer, VHDX_HEADER_SIZE, 4) &&
!memcmp(&header2->signature, "head", 4) &&
header2->version == 1) {
h2_seq = header2->sequence_number;
h2_valid = true;
}
if (h1_valid && !h2_valid) {
VAR_1->curr_header = 0;
} else if (!h1_valid && h2_valid) {
VAR_1->curr_header = 1;
} else if (!h1_valid && !h2_valid) {
goto fail;
} else {
if (h1_seq > h2_seq) {
VAR_1->curr_header = 0;
} else if (h2_seq > h1_seq) {
VAR_1->curr_header = 1;
} else {
goto fail;
}
}
vhdx_region_register(VAR_1, VAR_1->headers[VAR_1->curr_header]->log_offset,
VAR_1->headers[VAR_1->curr_header]->log_length);
goto exit;
fail:
error_setg_errno(VAR_2, -VAR_3, "No valid VHDX header found");
qemu_vfree(header1);
qemu_vfree(header2);
VAR_1->headers[0] = NULL;
VAR_1->headers[1] = NULL;
exit:
qemu_vfree(buffer);
}
| [
"static void FUNC_0(BlockDriverState *VAR_0, BDRVVHDXState *VAR_1,\nError **VAR_2)\n{",
"int VAR_3;",
"VHDXHeader *header1;",
"VHDXHeader *header2;",
"bool h1_valid = false;",
"bool h2_valid = false;",
"uint64_t h1_seq = 0;",
"uint64_t h2_seq = 0;",
"uint8_t *buffer;",
"header1 = qemu_blockalign(VAR_0, sizeof(VHDXHeader));",
"header2 = qemu_blockalign(VAR_0, sizeof(VHDXHeader));",
"buffer = qemu_blockalign(VAR_0, VHDX_HEADER_SIZE);",
"VAR_1->headers[0] = header1;",
"VAR_1->headers[1] = header2;",
"VAR_3 = bdrv_pread(VAR_0->file, VHDX_HEADER1_OFFSET, buffer, VHDX_HEADER_SIZE);",
"if (VAR_3 < 0) {",
"goto fail;",
"}",
"memcpy(header1, buffer, sizeof(VHDXHeader));",
"vhdx_header_le_import(header1);",
"if (vhdx_checksum_is_valid(buffer, VHDX_HEADER_SIZE, 4) &&\n!memcmp(&header1->signature, \"head\", 4) &&\nheader1->version == 1) {",
"h1_seq = header1->sequence_number;",
"h1_valid = true;",
"}",
"VAR_3 = bdrv_pread(VAR_0->file, VHDX_HEADER2_OFFSET, buffer, VHDX_HEADER_SIZE);",
"if (VAR_3 < 0) {",
"goto fail;",
"}",
"memcpy(header2, buffer, sizeof(VHDXHeader));",
"vhdx_header_le_import(header2);",
"if (vhdx_checksum_is_valid(buffer, VHDX_HEADER_SIZE, 4) &&\n!memcmp(&header2->signature, \"head\", 4) &&\nheader2->version == 1) {",
"h2_seq = header2->sequence_number;",
"h2_valid = true;",
"}",
"if (h1_valid && !h2_valid) {",
"VAR_1->curr_header = 0;",
"} else if (!h1_valid && h2_valid) {",
"VAR_1->curr_header = 1;",
"} else if (!h1_valid && !h2_valid) {",
"goto fail;",
"} else {",
"if (h1_seq > h2_seq) {",
"VAR_1->curr_header = 0;",
"} else if (h2_seq > h1_seq) {",
"VAR_1->curr_header = 1;",
"} else {",
"goto fail;",
"}",
"}",
"vhdx_region_register(VAR_1, VAR_1->headers[VAR_1->curr_header]->log_offset,\nVAR_1->headers[VAR_1->curr_header]->log_length);",
"goto exit;",
"fail:\nerror_setg_errno(VAR_2, -VAR_3, \"No valid VHDX header found\");",
"qemu_vfree(header1);",
"qemu_vfree(header2);",
"VAR_1->headers[0] = NULL;",
"VAR_1->headers[1] = NULL;",
"exit:\nqemu_vfree(buffer);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
27
],
[
29
],
[
33
],
[
37
],
[
39
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
65,
67,
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91
],
[
95,
97,
99
],
[
101
],
[
103
],
[
105
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
151,
153
],
[
155
],
[
159,
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171,
173
],
[
175
]
] |
18,962 | int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt,
int (*compare)(AVFormatContext *, AVPacket *, AVPacket *))
{
int ret;
AVPacketList **next_point, *this_pktl;
AVStream *st = s->streams[pkt->stream_index];
int chunked = s->max_chunk_size || s->max_chunk_duration;
this_pktl = av_mallocz(sizeof(AVPacketList));
if (!this_pktl)
return AVERROR(ENOMEM);
if ((pkt->flags & AV_PKT_FLAG_UNCODED_FRAME)) {
av_assert0(pkt->size == UNCODED_FRAME_PACKET_SIZE);
av_assert0(((AVFrame *)pkt->data)->buf);
}
if ((ret = av_packet_ref(&this_pktl->pkt, pkt)) < 0) {
av_free(this_pktl);
return ret;
}
if (s->streams[pkt->stream_index]->last_in_packet_buffer) {
next_point = &(st->last_in_packet_buffer->next);
} else {
next_point = &s->internal->packet_buffer;
}
if (chunked) {
uint64_t max= av_rescale_q_rnd(s->max_chunk_duration, AV_TIME_BASE_Q, st->time_base, AV_ROUND_UP);
st->interleaver_chunk_size += pkt->size;
st->interleaver_chunk_duration += pkt->duration;
if ( (s->max_chunk_size && st->interleaver_chunk_size > s->max_chunk_size)
|| (max && st->interleaver_chunk_duration > max)) {
st->interleaver_chunk_size = 0;
this_pktl->pkt.flags |= CHUNK_START;
if (max && st->interleaver_chunk_duration > max) {
int64_t syncoffset = (st->codec->codec_type == AVMEDIA_TYPE_VIDEO)*max/2;
int64_t syncto = av_rescale(pkt->dts + syncoffset, 1, max)*max - syncoffset;
st->interleaver_chunk_duration += (pkt->dts - syncto)/8 - max;
} else
st->interleaver_chunk_duration = 0;
}
}
if (*next_point) {
if (chunked && !(this_pktl->pkt.flags & CHUNK_START))
goto next_non_null;
if (compare(s, &s->internal->packet_buffer_end->pkt, pkt)) {
while ( *next_point
&& ((chunked && !((*next_point)->pkt.flags&CHUNK_START))
|| !compare(s, &(*next_point)->pkt, pkt)))
next_point = &(*next_point)->next;
if (*next_point)
goto next_non_null;
} else {
next_point = &(s->internal->packet_buffer_end->next);
}
}
av_assert1(!*next_point);
s->internal->packet_buffer_end = this_pktl;
next_non_null:
this_pktl->next = *next_point;
s->streams[pkt->stream_index]->last_in_packet_buffer =
*next_point = this_pktl;
av_packet_unref(pkt);
return 0;
}
| true | FFmpeg | b66ac803fac2394309797193cc3fdd265a285b03 | int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt,
int (*compare)(AVFormatContext *, AVPacket *, AVPacket *))
{
int ret;
AVPacketList **next_point, *this_pktl;
AVStream *st = s->streams[pkt->stream_index];
int chunked = s->max_chunk_size || s->max_chunk_duration;
this_pktl = av_mallocz(sizeof(AVPacketList));
if (!this_pktl)
return AVERROR(ENOMEM);
if ((pkt->flags & AV_PKT_FLAG_UNCODED_FRAME)) {
av_assert0(pkt->size == UNCODED_FRAME_PACKET_SIZE);
av_assert0(((AVFrame *)pkt->data)->buf);
}
if ((ret = av_packet_ref(&this_pktl->pkt, pkt)) < 0) {
av_free(this_pktl);
return ret;
}
if (s->streams[pkt->stream_index]->last_in_packet_buffer) {
next_point = &(st->last_in_packet_buffer->next);
} else {
next_point = &s->internal->packet_buffer;
}
if (chunked) {
uint64_t max= av_rescale_q_rnd(s->max_chunk_duration, AV_TIME_BASE_Q, st->time_base, AV_ROUND_UP);
st->interleaver_chunk_size += pkt->size;
st->interleaver_chunk_duration += pkt->duration;
if ( (s->max_chunk_size && st->interleaver_chunk_size > s->max_chunk_size)
|| (max && st->interleaver_chunk_duration > max)) {
st->interleaver_chunk_size = 0;
this_pktl->pkt.flags |= CHUNK_START;
if (max && st->interleaver_chunk_duration > max) {
int64_t syncoffset = (st->codec->codec_type == AVMEDIA_TYPE_VIDEO)*max/2;
int64_t syncto = av_rescale(pkt->dts + syncoffset, 1, max)*max - syncoffset;
st->interleaver_chunk_duration += (pkt->dts - syncto)/8 - max;
} else
st->interleaver_chunk_duration = 0;
}
}
if (*next_point) {
if (chunked && !(this_pktl->pkt.flags & CHUNK_START))
goto next_non_null;
if (compare(s, &s->internal->packet_buffer_end->pkt, pkt)) {
while ( *next_point
&& ((chunked && !((*next_point)->pkt.flags&CHUNK_START))
|| !compare(s, &(*next_point)->pkt, pkt)))
next_point = &(*next_point)->next;
if (*next_point)
goto next_non_null;
} else {
next_point = &(s->internal->packet_buffer_end->next);
}
}
av_assert1(!*next_point);
s->internal->packet_buffer_end = this_pktl;
next_non_null:
this_pktl->next = *next_point;
s->streams[pkt->stream_index]->last_in_packet_buffer =
*next_point = this_pktl;
av_packet_unref(pkt);
return 0;
}
| {
"code": [
" if ((ret = av_packet_ref(&this_pktl->pkt, pkt)) < 0) {",
" av_free(this_pktl);",
" return ret;"
],
"line_no": [
33,
35,
37
]
} | VAR_4intVAR_4 VAR_4ff_interleave_add_packetVAR_4(VAR_4AVFormatContextVAR_4 *VAR_4VAR_0VAR_4, VAR_4AVPacketVAR_4 *VAR_4VAR_1VAR_4,
VAR_4intVAR_4 (*VAR_4VAR_2VAR_4)(VAR_4AVFormatContextVAR_4 *, VAR_4AVPacketVAR_4 *, VAR_4AVPacketVAR_4 *))
{
VAR_4intVAR_4 VAR_4retVAR_4;
VAR_4AVPacketListVAR_4 **VAR_4next_pointVAR_4, *VAR_4this_pktlVAR_4;
VAR_4AVStreamVAR_4 *VAR_4stVAR_4 = VAR_4VAR_0VAR_4->VAR_4streamsVAR_4[VAR_4VAR_1VAR_4->VAR_4stream_indexVAR_4];
VAR_4intVAR_4 VAR_4chunkedVAR_4 = VAR_4VAR_0VAR_4->VAR_4max_chunk_sizeVAR_4 || VAR_4VAR_0VAR_4->VAR_4max_chunk_durationVAR_4;
VAR_4this_pktlVAR_4 = VAR_4av_malloczVAR_4(VAR_4sizeofVAR_4(VAR_4AVPacketListVAR_4));
VAR_4ifVAR_4 (!VAR_4this_pktlVAR_4)
VAR_4returnVAR_4 VAR_4AVERRORVAR_4(VAR_4ENOMEMVAR_4);
VAR_4ifVAR_4 ((VAR_4VAR_1VAR_4->VAR_4flagsVAR_4 & VAR_4AV_PKT_FLAG_UNCODED_FRAMEVAR_4)) {
VAR_4av_assert0VAR_4(VAR_4VAR_1VAR_4->VAR_4sizeVAR_4 == VAR_4UNCODED_FRAME_PACKET_SIZEVAR_4);
VAR_4av_assert0VAR_4(((VAR_4AVFrameVAR_4 *)VAR_4VAR_1VAR_4->VAR_4dataVAR_4)->VAR_4bufVAR_4);
}
VAR_4ifVAR_4 ((VAR_4retVAR_4 = VAR_4av_packet_refVAR_4(&VAR_4this_pktlVAR_4->VAR_4VAR_1VAR_4, VAR_4VAR_1VAR_4)) < VAR_40VAR_4) {
VAR_4av_freeVAR_4(VAR_4this_pktlVAR_4);
VAR_4returnVAR_4 VAR_4retVAR_4;
}
VAR_4ifVAR_4 (VAR_4VAR_0VAR_4->VAR_4streamsVAR_4[VAR_4VAR_1VAR_4->VAR_4stream_indexVAR_4]->VAR_4last_in_packet_bufferVAR_4) {
VAR_4next_pointVAR_4 = &(VAR_4stVAR_4->VAR_4last_in_packet_bufferVAR_4->VAR_4nextVAR_4);
} VAR_4elseVAR_4 {
VAR_4next_pointVAR_4 = &VAR_4VAR_0VAR_4->VAR_4internalVAR_4->VAR_4packet_bufferVAR_4;
}
VAR_4ifVAR_4 (VAR_4chunkedVAR_4) {
VAR_4uint64_tVAR_4 VAR_4maxVAR_4= VAR_4av_rescale_q_rndVAR_4(VAR_4VAR_0VAR_4->VAR_4max_chunk_durationVAR_4, VAR_4AV_TIME_BASE_QVAR_4, VAR_4stVAR_4->VAR_4time_baseVAR_4, VAR_4AV_ROUND_UPVAR_4);
VAR_4stVAR_4->VAR_4interleaver_chunk_sizeVAR_4 += VAR_4VAR_1VAR_4->VAR_4sizeVAR_4;
VAR_4stVAR_4->VAR_4interleaver_chunk_durationVAR_4 += VAR_4VAR_1VAR_4->VAR_4durationVAR_4;
VAR_4ifVAR_4 ( (VAR_4VAR_0VAR_4->VAR_4max_chunk_sizeVAR_4 && VAR_4stVAR_4->VAR_4interleaver_chunk_sizeVAR_4 > VAR_4VAR_0VAR_4->VAR_4max_chunk_sizeVAR_4)
|| (VAR_4maxVAR_4 && VAR_4stVAR_4->VAR_4interleaver_chunk_durationVAR_4 > VAR_4maxVAR_4)) {
VAR_4stVAR_4->VAR_4interleaver_chunk_sizeVAR_4 = VAR_40VAR_4;
VAR_4this_pktlVAR_4->VAR_4VAR_1VAR_4.VAR_4flagsVAR_4 |= VAR_4CHUNK_STARTVAR_4;
VAR_4ifVAR_4 (VAR_4maxVAR_4 && VAR_4stVAR_4->VAR_4interleaver_chunk_durationVAR_4 > VAR_4maxVAR_4) {
VAR_4int64_tVAR_4 VAR_4syncoffsetVAR_4 = (VAR_4stVAR_4->VAR_4codecVAR_4->VAR_4codec_typeVAR_4 == VAR_4AVMEDIA_TYPE_VIDEOVAR_4)*VAR_4maxVAR_4/VAR_42VAR_4;
VAR_4int64_tVAR_4 VAR_4synctoVAR_4 = VAR_4av_rescaleVAR_4(VAR_4VAR_1VAR_4->VAR_4dtsVAR_4 + VAR_4syncoffsetVAR_4, VAR_41VAR_4, VAR_4maxVAR_4)*VAR_4maxVAR_4 - VAR_4syncoffsetVAR_4;
VAR_4stVAR_4->VAR_4interleaver_chunk_durationVAR_4 += (VAR_4VAR_1VAR_4->VAR_4dtsVAR_4 - VAR_4synctoVAR_4)/VAR_48VAR_4 - VAR_4maxVAR_4;
} VAR_4elseVAR_4
VAR_4stVAR_4->VAR_4interleaver_chunk_durationVAR_4 = VAR_40VAR_4;
}
}
VAR_4ifVAR_4 (*VAR_4next_pointVAR_4) {
VAR_4ifVAR_4 (VAR_4chunkedVAR_4 && !(VAR_4this_pktlVAR_4->VAR_4VAR_1VAR_4.VAR_4flagsVAR_4 & VAR_4CHUNK_STARTVAR_4))
VAR_4gotoVAR_4 VAR_4next_non_nullVAR_4;
VAR_4ifVAR_4 (VAR_4VAR_2VAR_4(VAR_4VAR_0VAR_4, &VAR_4VAR_0VAR_4->VAR_4internalVAR_4->VAR_4packet_buffer_endVAR_4->VAR_4VAR_1VAR_4, VAR_4VAR_1VAR_4)) {
VAR_4whileVAR_4 ( *VAR_4next_pointVAR_4
&& ((VAR_4chunkedVAR_4 && !((*VAR_4next_pointVAR_4)->VAR_4VAR_1VAR_4.VAR_4flagsVAR_4&VAR_4CHUNK_STARTVAR_4))
|| !VAR_4VAR_2VAR_4(VAR_4VAR_0VAR_4, &(*VAR_4next_pointVAR_4)->VAR_4VAR_1VAR_4, VAR_4VAR_1VAR_4)))
VAR_4next_pointVAR_4 = &(*VAR_4next_pointVAR_4)->VAR_4nextVAR_4;
VAR_4ifVAR_4 (*VAR_4next_pointVAR_4)
VAR_4gotoVAR_4 VAR_4next_non_nullVAR_4;
} VAR_4elseVAR_4 {
VAR_4next_pointVAR_4 = &(VAR_4VAR_0VAR_4->VAR_4internalVAR_4->VAR_4packet_buffer_endVAR_4->VAR_4nextVAR_4);
}
}
VAR_4av_assert1VAR_4(!*VAR_4next_pointVAR_4);
VAR_4VAR_0VAR_4->VAR_4internalVAR_4->VAR_4packet_buffer_endVAR_4 = VAR_4this_pktlVAR_4;
VAR_4next_non_nullVAR_4:
VAR_4this_pktlVAR_4->VAR_4nextVAR_4 = *VAR_4next_pointVAR_4;
VAR_4VAR_0VAR_4->VAR_4streamsVAR_4[VAR_4VAR_1VAR_4->VAR_4stream_indexVAR_4]->VAR_4last_in_packet_bufferVAR_4 =
*VAR_4next_pointVAR_4 = VAR_4this_pktlVAR_4;
VAR_4av_packet_unrefVAR_4(VAR_4VAR_1VAR_4);
VAR_4returnVAR_4 VAR_40VAR_4;
}
| [
"VAR_4intVAR_4 VAR_4ff_interleave_add_packetVAR_4(VAR_4AVFormatContextVAR_4 *VAR_4VAR_0VAR_4, VAR_4AVPacketVAR_4 *VAR_4VAR_1VAR_4,\nVAR_4intVAR_4 (*VAR_4VAR_2VAR_4)(VAR_4AVFormatContextVAR_4 *, VAR_4AVPacketVAR_4 *, VAR_4AVPacketVAR_4 *))\n{",
"VAR_4intVAR_4 VAR_4retVAR_4;",
"VAR_4AVPacketListVAR_4 **VAR_4next_pointVAR_4, *VAR_4this_pktlVAR_4;",
"VAR_4AVStreamVAR_4 *VAR_4stVAR_4 = VAR_4VAR_0VAR_4->VAR_4streamsVAR_4[VAR_4VAR_1VAR_4->VAR_4stream_indexVAR_4];",
"VAR_4intVAR_4 VAR_4chunkedVAR_4 = VAR_4VAR_0VAR_4->VAR_4max_chunk_sizeVAR_4 || VAR_4VAR_0VAR_4->VAR_4max_chunk_durationVAR_4;",
"VAR_4this_pktlVAR_4 = VAR_4av_malloczVAR_4(VAR_4sizeofVAR_4(VAR_4AVPacketListVAR_4));",
"VAR_4ifVAR_4 (!VAR_4this_pktlVAR_4)\nVAR_4returnVAR_4 VAR_4AVERRORVAR_4(VAR_4ENOMEMVAR_4);",
"VAR_4ifVAR_4 ((VAR_4VAR_1VAR_4->VAR_4flagsVAR_4 & VAR_4AV_PKT_FLAG_UNCODED_FRAMEVAR_4)) {",
"VAR_4av_assert0VAR_4(VAR_4VAR_1VAR_4->VAR_4sizeVAR_4 == VAR_4UNCODED_FRAME_PACKET_SIZEVAR_4);",
"VAR_4av_assert0VAR_4(((VAR_4AVFrameVAR_4 *)VAR_4VAR_1VAR_4->VAR_4dataVAR_4)->VAR_4bufVAR_4);",
"}",
"VAR_4ifVAR_4 ((VAR_4retVAR_4 = VAR_4av_packet_refVAR_4(&VAR_4this_pktlVAR_4->VAR_4VAR_1VAR_4, VAR_4VAR_1VAR_4)) < VAR_40VAR_4) {",
"VAR_4av_freeVAR_4(VAR_4this_pktlVAR_4);",
"VAR_4returnVAR_4 VAR_4retVAR_4;",
"}",
"VAR_4ifVAR_4 (VAR_4VAR_0VAR_4->VAR_4streamsVAR_4[VAR_4VAR_1VAR_4->VAR_4stream_indexVAR_4]->VAR_4last_in_packet_bufferVAR_4) {",
"VAR_4next_pointVAR_4 = &(VAR_4stVAR_4->VAR_4last_in_packet_bufferVAR_4->VAR_4nextVAR_4);",
"} VAR_4elseVAR_4 {",
"VAR_4next_pointVAR_4 = &VAR_4VAR_0VAR_4->VAR_4internalVAR_4->VAR_4packet_bufferVAR_4;",
"}",
"VAR_4ifVAR_4 (VAR_4chunkedVAR_4) {",
"VAR_4uint64_tVAR_4 VAR_4maxVAR_4= VAR_4av_rescale_q_rndVAR_4(VAR_4VAR_0VAR_4->VAR_4max_chunk_durationVAR_4, VAR_4AV_TIME_BASE_QVAR_4, VAR_4stVAR_4->VAR_4time_baseVAR_4, VAR_4AV_ROUND_UPVAR_4);",
"VAR_4stVAR_4->VAR_4interleaver_chunk_sizeVAR_4 += VAR_4VAR_1VAR_4->VAR_4sizeVAR_4;",
"VAR_4stVAR_4->VAR_4interleaver_chunk_durationVAR_4 += VAR_4VAR_1VAR_4->VAR_4durationVAR_4;",
"VAR_4ifVAR_4 ( (VAR_4VAR_0VAR_4->VAR_4max_chunk_sizeVAR_4 && VAR_4stVAR_4->VAR_4interleaver_chunk_sizeVAR_4 > VAR_4VAR_0VAR_4->VAR_4max_chunk_sizeVAR_4)\n|| (VAR_4maxVAR_4 && VAR_4stVAR_4->VAR_4interleaver_chunk_durationVAR_4 > VAR_4maxVAR_4)) {",
"VAR_4stVAR_4->VAR_4interleaver_chunk_sizeVAR_4 = VAR_40VAR_4;",
"VAR_4this_pktlVAR_4->VAR_4VAR_1VAR_4.VAR_4flagsVAR_4 |= VAR_4CHUNK_STARTVAR_4;",
"VAR_4ifVAR_4 (VAR_4maxVAR_4 && VAR_4stVAR_4->VAR_4interleaver_chunk_durationVAR_4 > VAR_4maxVAR_4) {",
"VAR_4int64_tVAR_4 VAR_4syncoffsetVAR_4 = (VAR_4stVAR_4->VAR_4codecVAR_4->VAR_4codec_typeVAR_4 == VAR_4AVMEDIA_TYPE_VIDEOVAR_4)*VAR_4maxVAR_4/VAR_42VAR_4;",
"VAR_4int64_tVAR_4 VAR_4synctoVAR_4 = VAR_4av_rescaleVAR_4(VAR_4VAR_1VAR_4->VAR_4dtsVAR_4 + VAR_4syncoffsetVAR_4, VAR_41VAR_4, VAR_4maxVAR_4)*VAR_4maxVAR_4 - VAR_4syncoffsetVAR_4;",
"VAR_4stVAR_4->VAR_4interleaver_chunk_durationVAR_4 += (VAR_4VAR_1VAR_4->VAR_4dtsVAR_4 - VAR_4synctoVAR_4)/VAR_48VAR_4 - VAR_4maxVAR_4;",
"} VAR_4elseVAR_4",
"VAR_4stVAR_4->VAR_4interleaver_chunk_durationVAR_4 = VAR_40VAR_4;",
"}",
"}",
"VAR_4ifVAR_4 (*VAR_4next_pointVAR_4) {",
"VAR_4ifVAR_4 (VAR_4chunkedVAR_4 && !(VAR_4this_pktlVAR_4->VAR_4VAR_1VAR_4.VAR_4flagsVAR_4 & VAR_4CHUNK_STARTVAR_4))\nVAR_4gotoVAR_4 VAR_4next_non_nullVAR_4;",
"VAR_4ifVAR_4 (VAR_4VAR_2VAR_4(VAR_4VAR_0VAR_4, &VAR_4VAR_0VAR_4->VAR_4internalVAR_4->VAR_4packet_buffer_endVAR_4->VAR_4VAR_1VAR_4, VAR_4VAR_1VAR_4)) {",
"VAR_4whileVAR_4 ( *VAR_4next_pointVAR_4\n&& ((VAR_4chunkedVAR_4 && !((*VAR_4next_pointVAR_4)->VAR_4VAR_1VAR_4.VAR_4flagsVAR_4&VAR_4CHUNK_STARTVAR_4))\n|| !VAR_4VAR_2VAR_4(VAR_4VAR_0VAR_4, &(*VAR_4next_pointVAR_4)->VAR_4VAR_1VAR_4, VAR_4VAR_1VAR_4)))\nVAR_4next_pointVAR_4 = &(*VAR_4next_pointVAR_4)->VAR_4nextVAR_4;",
"VAR_4ifVAR_4 (*VAR_4next_pointVAR_4)\nVAR_4gotoVAR_4 VAR_4next_non_nullVAR_4;",
"} VAR_4elseVAR_4 {",
"VAR_4next_pointVAR_4 = &(VAR_4VAR_0VAR_4->VAR_4internalVAR_4->VAR_4packet_buffer_endVAR_4->VAR_4nextVAR_4);",
"}",
"}",
"VAR_4av_assert1VAR_4(!*VAR_4next_pointVAR_4);",
"VAR_4VAR_0VAR_4->VAR_4internalVAR_4->VAR_4packet_buffer_endVAR_4 = VAR_4this_pktlVAR_4;",
"VAR_4next_non_nullVAR_4:\nVAR_4this_pktlVAR_4->VAR_4nextVAR_4 = *VAR_4next_pointVAR_4;",
"VAR_4VAR_0VAR_4->VAR_4streamsVAR_4[VAR_4VAR_1VAR_4->VAR_4stream_indexVAR_4]->VAR_4last_in_packet_bufferVAR_4 =\n*VAR_4next_pointVAR_4 = VAR_4this_pktlVAR_4;",
"VAR_4av_packet_unrefVAR_4(VAR_4VAR_1VAR_4);",
"VAR_4returnVAR_4 VAR_40VAR_4;",
"}"
] | [
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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19,
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63,
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91,
93
],
[
97
],
[
99,
101,
103,
105
],
[
107,
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
123
],
[
125,
129
],
[
133,
135
],
[
139
],
[
143
],
[
145
]
] |
18,964 | static void x8_init_block_index(MpegEncContext *s){ //FIXME maybe merge with ff_*
//not s->linesize as this would be wrong for field pics
//not that IntraX8 has interlacing support ;)
const int linesize = s->current_picture.f.linesize[0];
const int uvlinesize = s->current_picture.f.linesize[1];
s->dest[0] = s->current_picture.f.data[0];
s->dest[1] = s->current_picture.f.data[1];
s->dest[2] = s->current_picture.f.data[2];
s->dest[0] += s->mb_y * linesize << 3;
s->dest[1] += ( s->mb_y&(~1) ) * uvlinesize << 2;//chroma blocks are on add rows
s->dest[2] += ( s->mb_y&(~1) ) * uvlinesize << 2;
}
| true | FFmpeg | f6774f905fb3cfdc319523ac640be30b14c1bc55 | static void x8_init_block_index(MpegEncContext *s){
const int linesize = s->current_picture.f.linesize[0];
const int uvlinesize = s->current_picture.f.linesize[1];
s->dest[0] = s->current_picture.f.data[0];
s->dest[1] = s->current_picture.f.data[1];
s->dest[2] = s->current_picture.f.data[2];
s->dest[0] += s->mb_y * linesize << 3;
s->dest[1] += ( s->mb_y&(~1) ) * uvlinesize << 2;
s->dest[2] += ( s->mb_y&(~1) ) * uvlinesize << 2;
}
| {
"code": [
" const int linesize = s->current_picture.f.linesize[0];",
" const int uvlinesize = s->current_picture.f.linesize[1];",
" s->dest[0] = s->current_picture.f.data[0];",
" s->dest[1] = s->current_picture.f.data[1];",
" s->dest[2] = s->current_picture.f.data[2];",
" const int uvlinesize = s->current_picture.f.linesize[1];"
],
"line_no": [
7,
9,
13,
15,
17,
9
]
} | static void FUNC_0(MpegEncContext *VAR_0){
const int VAR_1 = VAR_0->current_picture.f.VAR_1[0];
const int VAR_2 = VAR_0->current_picture.f.VAR_1[1];
VAR_0->dest[0] = VAR_0->current_picture.f.data[0];
VAR_0->dest[1] = VAR_0->current_picture.f.data[1];
VAR_0->dest[2] = VAR_0->current_picture.f.data[2];
VAR_0->dest[0] += VAR_0->mb_y * VAR_1 << 3;
VAR_0->dest[1] += ( VAR_0->mb_y&(~1) ) * VAR_2 << 2;
VAR_0->dest[2] += ( VAR_0->mb_y&(~1) ) * VAR_2 << 2;
}
| [
"static void FUNC_0(MpegEncContext *VAR_0){",
"const int VAR_1 = VAR_0->current_picture.f.VAR_1[0];",
"const int VAR_2 = VAR_0->current_picture.f.VAR_1[1];",
"VAR_0->dest[0] = VAR_0->current_picture.f.data[0];",
"VAR_0->dest[1] = VAR_0->current_picture.f.data[1];",
"VAR_0->dest[2] = VAR_0->current_picture.f.data[2];",
"VAR_0->dest[0] += VAR_0->mb_y * VAR_1 << 3;",
"VAR_0->dest[1] += ( VAR_0->mb_y&(~1) ) * VAR_2 << 2;",
"VAR_0->dest[2] += ( VAR_0->mb_y&(~1) ) * VAR_2 << 2;",
"}"
] | [
0,
1,
1,
1,
1,
1,
0,
0,
0,
0
] | [
[
1
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
]
] |
18,966 | static int qemu_rdma_search_ram_block(RDMAContext *rdma,
uint64_t block_offset,
uint64_t offset,
uint64_t length,
uint64_t *block_index,
uint64_t *chunk_index)
{
uint64_t current_addr = block_offset + offset;
RDMALocalBlock *block = g_hash_table_lookup(rdma->blockmap,
(void *) block_offset);
assert(block);
assert(current_addr >= block->offset);
assert((current_addr + length) <= (block->offset + block->length));
*block_index = block->index;
*chunk_index = ram_chunk_index(block->local_host_addr,
block->local_host_addr + (current_addr - block->offset));
return 0;
}
| true | qemu | 60fe637bf0e4d7989e21e50f52526444765c63b4 | static int qemu_rdma_search_ram_block(RDMAContext *rdma,
uint64_t block_offset,
uint64_t offset,
uint64_t length,
uint64_t *block_index,
uint64_t *chunk_index)
{
uint64_t current_addr = block_offset + offset;
RDMALocalBlock *block = g_hash_table_lookup(rdma->blockmap,
(void *) block_offset);
assert(block);
assert(current_addr >= block->offset);
assert((current_addr + length) <= (block->offset + block->length));
*block_index = block->index;
*chunk_index = ram_chunk_index(block->local_host_addr,
block->local_host_addr + (current_addr - block->offset));
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(RDMAContext *VAR_0,
uint64_t VAR_1,
uint64_t VAR_2,
uint64_t VAR_3,
uint64_t *VAR_4,
uint64_t *VAR_5)
{
uint64_t current_addr = VAR_1 + VAR_2;
RDMALocalBlock *block = g_hash_table_lookup(VAR_0->blockmap,
(void *) VAR_1);
assert(block);
assert(current_addr >= block->VAR_2);
assert((current_addr + VAR_3) <= (block->VAR_2 + block->VAR_3));
*VAR_4 = block->index;
*VAR_5 = ram_chunk_index(block->local_host_addr,
block->local_host_addr + (current_addr - block->VAR_2));
return 0;
}
| [
"static int FUNC_0(RDMAContext *VAR_0,\nuint64_t VAR_1,\nuint64_t VAR_2,\nuint64_t VAR_3,\nuint64_t *VAR_4,\nuint64_t *VAR_5)\n{",
"uint64_t current_addr = VAR_1 + VAR_2;",
"RDMALocalBlock *block = g_hash_table_lookup(VAR_0->blockmap,\n(void *) VAR_1);",
"assert(block);",
"assert(current_addr >= block->VAR_2);",
"assert((current_addr + VAR_3) <= (block->VAR_2 + block->VAR_3));",
"*VAR_4 = block->index;",
"*VAR_5 = ram_chunk_index(block->local_host_addr,\nblock->local_host_addr + (current_addr - block->VAR_2));",
"return 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,
33
],
[
37
],
[
39
]
] |
18,967 | static int decode_update_thread_context(AVCodecContext *dst,
const AVCodecContext *src)
{
H264Context *h = dst->priv_data, *h1 = src->priv_data;
int inited = h->context_initialized, err = 0;
int context_reinitialized = 0;
int i, ret;
if (dst == src)
return 0;
if (inited &&
(h->width != h1->width ||
h->height != h1->height ||
h->mb_width != h1->mb_width ||
h->mb_height != h1->mb_height ||
h->sps.bit_depth_luma != h1->sps.bit_depth_luma ||
h->sps.chroma_format_idc != h1->sps.chroma_format_idc ||
h->sps.colorspace != h1->sps.colorspace)) {
/* set bits_per_raw_sample to the previous value. the check for changed
* bit depth in h264_set_parameter_from_sps() uses it and sets it to
* the current value */
h->avctx->bits_per_raw_sample = h->sps.bit_depth_luma;
av_freep(&h->bipred_scratchpad);
h->width = h1->width;
h->height = h1->height;
h->mb_height = h1->mb_height;
h->mb_width = h1->mb_width;
h->mb_num = h1->mb_num;
h->mb_stride = h1->mb_stride;
h->b_stride = h1->b_stride;
// SPS/PPS
copy_parameter_set((void **)h->sps_buffers, (void **)h1->sps_buffers,
MAX_SPS_COUNT, sizeof(SPS));
h->sps = h1->sps;
copy_parameter_set((void **)h->pps_buffers, (void **)h1->pps_buffers,
MAX_PPS_COUNT, sizeof(PPS));
h->pps = h1->pps;
if ((err = h264_slice_header_init(h, 1)) < 0) {
av_log(h->avctx, AV_LOG_ERROR, "h264_slice_header_init() failed");
return err;
}
context_reinitialized = 1;
#if 0
h264_set_parameter_from_sps(h);
//Note we set context_reinitialized which will cause h264_set_parameter_from_sps to be reexecuted
h->cur_chroma_format_idc = h1->cur_chroma_format_idc;
#endif
}
/* update linesize on resize for h264. The h264 decoder doesn't
* necessarily call ff_MPV_frame_start in the new thread */
h->linesize = h1->linesize;
h->uvlinesize = h1->uvlinesize;
/* copy block_offset since frame_start may not be called */
memcpy(h->block_offset, h1->block_offset, sizeof(h->block_offset));
if (!inited) {
for (i = 0; i < MAX_SPS_COUNT; i++)
av_freep(h->sps_buffers + i);
for (i = 0; i < MAX_PPS_COUNT; i++)
av_freep(h->pps_buffers + i);
memcpy(h, h1, offsetof(H264Context, intra_pcm_ptr));
memcpy(&h->cabac, &h1->cabac,
sizeof(H264Context) - offsetof(H264Context, cabac));
av_assert0((void*)&h->cabac == &h->mb_padding + 1);
memset(h->sps_buffers, 0, sizeof(h->sps_buffers));
memset(h->pps_buffers, 0, sizeof(h->pps_buffers));
memset(&h->er, 0, sizeof(h->er));
memset(&h->me, 0, sizeof(h->me));
memset(&h->mb, 0, sizeof(h->mb));
memset(&h->mb_luma_dc, 0, sizeof(h->mb_luma_dc));
memset(&h->mb_padding, 0, sizeof(h->mb_padding));
h->avctx = dst;
h->DPB = NULL;
h->qscale_table_pool = NULL;
h->mb_type_pool = NULL;
h->ref_index_pool = NULL;
h->motion_val_pool = NULL;
if (h1->context_initialized) {
h->context_initialized = 0;
memset(&h->cur_pic, 0, sizeof(h->cur_pic));
avcodec_get_frame_defaults(&h->cur_pic.f);
h->cur_pic.tf.f = &h->cur_pic.f;
ret = ff_h264_alloc_tables(h);
if (ret < 0) {
av_log(dst, AV_LOG_ERROR, "Could not allocate memory for h264\n");
return ret;
}
ret = context_init(h);
if (ret < 0) {
av_log(dst, AV_LOG_ERROR, "context_init() failed.\n");
return ret;
}
}
for (i = 0; i < 2; i++) {
h->rbsp_buffer[i] = NULL;
h->rbsp_buffer_size[i] = 0;
}
h->bipred_scratchpad = NULL;
h->edge_emu_buffer = NULL;
h->thread_context[0] = h;
h->context_initialized = h1->context_initialized;
}
h->avctx->coded_height = h1->avctx->coded_height;
h->avctx->coded_width = h1->avctx->coded_width;
h->avctx->width = h1->avctx->width;
h->avctx->height = h1->avctx->height;
h->coded_picture_number = h1->coded_picture_number;
h->first_field = h1->first_field;
h->picture_structure = h1->picture_structure;
h->qscale = h1->qscale;
h->droppable = h1->droppable;
h->data_partitioning = h1->data_partitioning;
h->low_delay = h1->low_delay;
for (i = 0; h->DPB && i < MAX_PICTURE_COUNT; i++) {
unref_picture(h, &h->DPB[i]);
if (h1->DPB[i].f.data[0] &&
(ret = ref_picture(h, &h->DPB[i], &h1->DPB[i])) < 0)
return ret;
}
h->cur_pic_ptr = REBASE_PICTURE(h1->cur_pic_ptr, h, h1);
unref_picture(h, &h->cur_pic);
if (h1->cur_pic.f.buf[0] && (ret = ref_picture(h, &h->cur_pic, &h1->cur_pic)) < 0)
return ret;
h->workaround_bugs = h1->workaround_bugs;
h->low_delay = h1->low_delay;
h->droppable = h1->droppable;
// extradata/NAL handling
h->is_avc = h1->is_avc;
// SPS/PPS
copy_parameter_set((void **)h->sps_buffers, (void **)h1->sps_buffers,
MAX_SPS_COUNT, sizeof(SPS));
h->sps = h1->sps;
copy_parameter_set((void **)h->pps_buffers, (void **)h1->pps_buffers,
MAX_PPS_COUNT, sizeof(PPS));
h->pps = h1->pps;
// Dequantization matrices
// FIXME these are big - can they be only copied when PPS changes?
copy_fields(h, h1, dequant4_buffer, dequant4_coeff);
for (i = 0; i < 6; i++)
h->dequant4_coeff[i] = h->dequant4_buffer[0] +
(h1->dequant4_coeff[i] - h1->dequant4_buffer[0]);
for (i = 0; i < 6; i++)
h->dequant8_coeff[i] = h->dequant8_buffer[0] +
(h1->dequant8_coeff[i] - h1->dequant8_buffer[0]);
h->dequant_coeff_pps = h1->dequant_coeff_pps;
// POC timing
copy_fields(h, h1, poc_lsb, redundant_pic_count);
// reference lists
copy_fields(h, h1, short_ref, cabac_init_idc);
copy_picture_range(h->short_ref, h1->short_ref, 32, h, h1);
copy_picture_range(h->long_ref, h1->long_ref, 32, h, h1);
copy_picture_range(h->delayed_pic, h1->delayed_pic,
MAX_DELAYED_PIC_COUNT + 2, h, h1);
h->sync = h1->sync;
if (context_reinitialized)
h264_set_parameter_from_sps(h);
if (!h->cur_pic_ptr)
return 0;
if (!h->droppable) {
err = ff_h264_execute_ref_pic_marking(h, h->mmco, h->mmco_index);
h->prev_poc_msb = h->poc_msb;
h->prev_poc_lsb = h->poc_lsb;
}
h->prev_frame_num_offset = h->frame_num_offset;
h->prev_frame_num = h->frame_num;
h->outputed_poc = h->next_outputed_poc;
return err;
}
| true | FFmpeg | be30e44dd929c2557494b1b71084d48d3c002f15 | static int decode_update_thread_context(AVCodecContext *dst,
const AVCodecContext *src)
{
H264Context *h = dst->priv_data, *h1 = src->priv_data;
int inited = h->context_initialized, err = 0;
int context_reinitialized = 0;
int i, ret;
if (dst == src)
return 0;
if (inited &&
(h->width != h1->width ||
h->height != h1->height ||
h->mb_width != h1->mb_width ||
h->mb_height != h1->mb_height ||
h->sps.bit_depth_luma != h1->sps.bit_depth_luma ||
h->sps.chroma_format_idc != h1->sps.chroma_format_idc ||
h->sps.colorspace != h1->sps.colorspace)) {
h->avctx->bits_per_raw_sample = h->sps.bit_depth_luma;
av_freep(&h->bipred_scratchpad);
h->width = h1->width;
h->height = h1->height;
h->mb_height = h1->mb_height;
h->mb_width = h1->mb_width;
h->mb_num = h1->mb_num;
h->mb_stride = h1->mb_stride;
h->b_stride = h1->b_stride;
copy_parameter_set((void **)h->sps_buffers, (void **)h1->sps_buffers,
MAX_SPS_COUNT, sizeof(SPS));
h->sps = h1->sps;
copy_parameter_set((void **)h->pps_buffers, (void **)h1->pps_buffers,
MAX_PPS_COUNT, sizeof(PPS));
h->pps = h1->pps;
if ((err = h264_slice_header_init(h, 1)) < 0) {
av_log(h->avctx, AV_LOG_ERROR, "h264_slice_header_init() failed");
return err;
}
context_reinitialized = 1;
#if 0
h264_set_parameter_from_sps(h);
h->cur_chroma_format_idc = h1->cur_chroma_format_idc;
#endif
}
h->linesize = h1->linesize;
h->uvlinesize = h1->uvlinesize;
memcpy(h->block_offset, h1->block_offset, sizeof(h->block_offset));
if (!inited) {
for (i = 0; i < MAX_SPS_COUNT; i++)
av_freep(h->sps_buffers + i);
for (i = 0; i < MAX_PPS_COUNT; i++)
av_freep(h->pps_buffers + i);
memcpy(h, h1, offsetof(H264Context, intra_pcm_ptr));
memcpy(&h->cabac, &h1->cabac,
sizeof(H264Context) - offsetof(H264Context, cabac));
av_assert0((void*)&h->cabac == &h->mb_padding + 1);
memset(h->sps_buffers, 0, sizeof(h->sps_buffers));
memset(h->pps_buffers, 0, sizeof(h->pps_buffers));
memset(&h->er, 0, sizeof(h->er));
memset(&h->me, 0, sizeof(h->me));
memset(&h->mb, 0, sizeof(h->mb));
memset(&h->mb_luma_dc, 0, sizeof(h->mb_luma_dc));
memset(&h->mb_padding, 0, sizeof(h->mb_padding));
h->avctx = dst;
h->DPB = NULL;
h->qscale_table_pool = NULL;
h->mb_type_pool = NULL;
h->ref_index_pool = NULL;
h->motion_val_pool = NULL;
if (h1->context_initialized) {
h->context_initialized = 0;
memset(&h->cur_pic, 0, sizeof(h->cur_pic));
avcodec_get_frame_defaults(&h->cur_pic.f);
h->cur_pic.tf.f = &h->cur_pic.f;
ret = ff_h264_alloc_tables(h);
if (ret < 0) {
av_log(dst, AV_LOG_ERROR, "Could not allocate memory for h264\n");
return ret;
}
ret = context_init(h);
if (ret < 0) {
av_log(dst, AV_LOG_ERROR, "context_init() failed.\n");
return ret;
}
}
for (i = 0; i < 2; i++) {
h->rbsp_buffer[i] = NULL;
h->rbsp_buffer_size[i] = 0;
}
h->bipred_scratchpad = NULL;
h->edge_emu_buffer = NULL;
h->thread_context[0] = h;
h->context_initialized = h1->context_initialized;
}
h->avctx->coded_height = h1->avctx->coded_height;
h->avctx->coded_width = h1->avctx->coded_width;
h->avctx->width = h1->avctx->width;
h->avctx->height = h1->avctx->height;
h->coded_picture_number = h1->coded_picture_number;
h->first_field = h1->first_field;
h->picture_structure = h1->picture_structure;
h->qscale = h1->qscale;
h->droppable = h1->droppable;
h->data_partitioning = h1->data_partitioning;
h->low_delay = h1->low_delay;
for (i = 0; h->DPB && i < MAX_PICTURE_COUNT; i++) {
unref_picture(h, &h->DPB[i]);
if (h1->DPB[i].f.data[0] &&
(ret = ref_picture(h, &h->DPB[i], &h1->DPB[i])) < 0)
return ret;
}
h->cur_pic_ptr = REBASE_PICTURE(h1->cur_pic_ptr, h, h1);
unref_picture(h, &h->cur_pic);
if (h1->cur_pic.f.buf[0] && (ret = ref_picture(h, &h->cur_pic, &h1->cur_pic)) < 0)
return ret;
h->workaround_bugs = h1->workaround_bugs;
h->low_delay = h1->low_delay;
h->droppable = h1->droppable;
h->is_avc = h1->is_avc;
copy_parameter_set((void **)h->sps_buffers, (void **)h1->sps_buffers,
MAX_SPS_COUNT, sizeof(SPS));
h->sps = h1->sps;
copy_parameter_set((void **)h->pps_buffers, (void **)h1->pps_buffers,
MAX_PPS_COUNT, sizeof(PPS));
h->pps = h1->pps;
copy_fields(h, h1, dequant4_buffer, dequant4_coeff);
for (i = 0; i < 6; i++)
h->dequant4_coeff[i] = h->dequant4_buffer[0] +
(h1->dequant4_coeff[i] - h1->dequant4_buffer[0]);
for (i = 0; i < 6; i++)
h->dequant8_coeff[i] = h->dequant8_buffer[0] +
(h1->dequant8_coeff[i] - h1->dequant8_buffer[0]);
h->dequant_coeff_pps = h1->dequant_coeff_pps;
copy_fields(h, h1, poc_lsb, redundant_pic_count);
copy_fields(h, h1, short_ref, cabac_init_idc);
copy_picture_range(h->short_ref, h1->short_ref, 32, h, h1);
copy_picture_range(h->long_ref, h1->long_ref, 32, h, h1);
copy_picture_range(h->delayed_pic, h1->delayed_pic,
MAX_DELAYED_PIC_COUNT + 2, h, h1);
h->sync = h1->sync;
if (context_reinitialized)
h264_set_parameter_from_sps(h);
if (!h->cur_pic_ptr)
return 0;
if (!h->droppable) {
err = ff_h264_execute_ref_pic_marking(h, h->mmco, h->mmco_index);
h->prev_poc_msb = h->poc_msb;
h->prev_poc_lsb = h->poc_lsb;
}
h->prev_frame_num_offset = h->frame_num_offset;
h->prev_frame_num = h->frame_num;
h->outputed_poc = h->next_outputed_poc;
return err;
}
| {
"code": [
" for (i = 0; i < 2; i++) {",
" h->rbsp_buffer[i] = NULL;",
" h->rbsp_buffer_size[i] = 0;"
],
"line_no": [
219,
221,
223
]
} | static int FUNC_0(AVCodecContext *VAR_0,
const AVCodecContext *VAR_1)
{
H264Context *h = VAR_0->priv_data, *h1 = VAR_1->priv_data;
int VAR_2 = h->context_initialized, VAR_3 = 0;
int VAR_4 = 0;
int VAR_5, VAR_6;
if (VAR_0 == VAR_1)
return 0;
if (VAR_2 &&
(h->width != h1->width ||
h->height != h1->height ||
h->mb_width != h1->mb_width ||
h->mb_height != h1->mb_height ||
h->sps.bit_depth_luma != h1->sps.bit_depth_luma ||
h->sps.chroma_format_idc != h1->sps.chroma_format_idc ||
h->sps.colorspace != h1->sps.colorspace)) {
h->avctx->bits_per_raw_sample = h->sps.bit_depth_luma;
av_freep(&h->bipred_scratchpad);
h->width = h1->width;
h->height = h1->height;
h->mb_height = h1->mb_height;
h->mb_width = h1->mb_width;
h->mb_num = h1->mb_num;
h->mb_stride = h1->mb_stride;
h->b_stride = h1->b_stride;
copy_parameter_set((void **)h->sps_buffers, (void **)h1->sps_buffers,
MAX_SPS_COUNT, sizeof(SPS));
h->sps = h1->sps;
copy_parameter_set((void **)h->pps_buffers, (void **)h1->pps_buffers,
MAX_PPS_COUNT, sizeof(PPS));
h->pps = h1->pps;
if ((VAR_3 = h264_slice_header_init(h, 1)) < 0) {
av_log(h->avctx, AV_LOG_ERROR, "h264_slice_header_init() failed");
return VAR_3;
}
VAR_4 = 1;
#if 0
h264_set_parameter_from_sps(h);
h->cur_chroma_format_idc = h1->cur_chroma_format_idc;
#endif
}
h->linesize = h1->linesize;
h->uvlinesize = h1->uvlinesize;
memcpy(h->block_offset, h1->block_offset, sizeof(h->block_offset));
if (!VAR_2) {
for (VAR_5 = 0; VAR_5 < MAX_SPS_COUNT; VAR_5++)
av_freep(h->sps_buffers + VAR_5);
for (VAR_5 = 0; VAR_5 < MAX_PPS_COUNT; VAR_5++)
av_freep(h->pps_buffers + VAR_5);
memcpy(h, h1, offsetof(H264Context, intra_pcm_ptr));
memcpy(&h->cabac, &h1->cabac,
sizeof(H264Context) - offsetof(H264Context, cabac));
av_assert0((void*)&h->cabac == &h->mb_padding + 1);
memset(h->sps_buffers, 0, sizeof(h->sps_buffers));
memset(h->pps_buffers, 0, sizeof(h->pps_buffers));
memset(&h->er, 0, sizeof(h->er));
memset(&h->me, 0, sizeof(h->me));
memset(&h->mb, 0, sizeof(h->mb));
memset(&h->mb_luma_dc, 0, sizeof(h->mb_luma_dc));
memset(&h->mb_padding, 0, sizeof(h->mb_padding));
h->avctx = VAR_0;
h->DPB = NULL;
h->qscale_table_pool = NULL;
h->mb_type_pool = NULL;
h->ref_index_pool = NULL;
h->motion_val_pool = NULL;
if (h1->context_initialized) {
h->context_initialized = 0;
memset(&h->cur_pic, 0, sizeof(h->cur_pic));
avcodec_get_frame_defaults(&h->cur_pic.f);
h->cur_pic.tf.f = &h->cur_pic.f;
VAR_6 = ff_h264_alloc_tables(h);
if (VAR_6 < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Could not allocate memory for h264\n");
return VAR_6;
}
VAR_6 = context_init(h);
if (VAR_6 < 0) {
av_log(VAR_0, AV_LOG_ERROR, "context_init() failed.\n");
return VAR_6;
}
}
for (VAR_5 = 0; VAR_5 < 2; VAR_5++) {
h->rbsp_buffer[VAR_5] = NULL;
h->rbsp_buffer_size[VAR_5] = 0;
}
h->bipred_scratchpad = NULL;
h->edge_emu_buffer = NULL;
h->thread_context[0] = h;
h->context_initialized = h1->context_initialized;
}
h->avctx->coded_height = h1->avctx->coded_height;
h->avctx->coded_width = h1->avctx->coded_width;
h->avctx->width = h1->avctx->width;
h->avctx->height = h1->avctx->height;
h->coded_picture_number = h1->coded_picture_number;
h->first_field = h1->first_field;
h->picture_structure = h1->picture_structure;
h->qscale = h1->qscale;
h->droppable = h1->droppable;
h->data_partitioning = h1->data_partitioning;
h->low_delay = h1->low_delay;
for (VAR_5 = 0; h->DPB && VAR_5 < MAX_PICTURE_COUNT; VAR_5++) {
unref_picture(h, &h->DPB[VAR_5]);
if (h1->DPB[VAR_5].f.data[0] &&
(VAR_6 = ref_picture(h, &h->DPB[VAR_5], &h1->DPB[VAR_5])) < 0)
return VAR_6;
}
h->cur_pic_ptr = REBASE_PICTURE(h1->cur_pic_ptr, h, h1);
unref_picture(h, &h->cur_pic);
if (h1->cur_pic.f.buf[0] && (VAR_6 = ref_picture(h, &h->cur_pic, &h1->cur_pic)) < 0)
return VAR_6;
h->workaround_bugs = h1->workaround_bugs;
h->low_delay = h1->low_delay;
h->droppable = h1->droppable;
h->is_avc = h1->is_avc;
copy_parameter_set((void **)h->sps_buffers, (void **)h1->sps_buffers,
MAX_SPS_COUNT, sizeof(SPS));
h->sps = h1->sps;
copy_parameter_set((void **)h->pps_buffers, (void **)h1->pps_buffers,
MAX_PPS_COUNT, sizeof(PPS));
h->pps = h1->pps;
copy_fields(h, h1, dequant4_buffer, dequant4_coeff);
for (VAR_5 = 0; VAR_5 < 6; VAR_5++)
h->dequant4_coeff[VAR_5] = h->dequant4_buffer[0] +
(h1->dequant4_coeff[VAR_5] - h1->dequant4_buffer[0]);
for (VAR_5 = 0; VAR_5 < 6; VAR_5++)
h->dequant8_coeff[VAR_5] = h->dequant8_buffer[0] +
(h1->dequant8_coeff[VAR_5] - h1->dequant8_buffer[0]);
h->dequant_coeff_pps = h1->dequant_coeff_pps;
copy_fields(h, h1, poc_lsb, redundant_pic_count);
copy_fields(h, h1, short_ref, cabac_init_idc);
copy_picture_range(h->short_ref, h1->short_ref, 32, h, h1);
copy_picture_range(h->long_ref, h1->long_ref, 32, h, h1);
copy_picture_range(h->delayed_pic, h1->delayed_pic,
MAX_DELAYED_PIC_COUNT + 2, h, h1);
h->sync = h1->sync;
if (VAR_4)
h264_set_parameter_from_sps(h);
if (!h->cur_pic_ptr)
return 0;
if (!h->droppable) {
VAR_3 = ff_h264_execute_ref_pic_marking(h, h->mmco, h->mmco_index);
h->prev_poc_msb = h->poc_msb;
h->prev_poc_lsb = h->poc_lsb;
}
h->prev_frame_num_offset = h->frame_num_offset;
h->prev_frame_num = h->frame_num;
h->outputed_poc = h->next_outputed_poc;
return VAR_3;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0,\nconst AVCodecContext *VAR_1)\n{",
"H264Context *h = VAR_0->priv_data, *h1 = VAR_1->priv_data;",
"int VAR_2 = h->context_initialized, VAR_3 = 0;",
"int VAR_4 = 0;",
"int VAR_5, VAR_6;",
"if (VAR_0 == VAR_1)\nreturn 0;",
"if (VAR_2 &&\n(h->width != h1->width ||\nh->height != h1->height ||\nh->mb_width != h1->mb_width ||\nh->mb_height != h1->mb_height ||\nh->sps.bit_depth_luma != h1->sps.bit_depth_luma ||\nh->sps.chroma_format_idc != h1->sps.chroma_format_idc ||\nh->sps.colorspace != h1->sps.colorspace)) {",
"h->avctx->bits_per_raw_sample = h->sps.bit_depth_luma;",
"av_freep(&h->bipred_scratchpad);",
"h->width = h1->width;",
"h->height = h1->height;",
"h->mb_height = h1->mb_height;",
"h->mb_width = h1->mb_width;",
"h->mb_num = h1->mb_num;",
"h->mb_stride = h1->mb_stride;",
"h->b_stride = h1->b_stride;",
"copy_parameter_set((void **)h->sps_buffers, (void **)h1->sps_buffers,\nMAX_SPS_COUNT, sizeof(SPS));",
"h->sps = h1->sps;",
"copy_parameter_set((void **)h->pps_buffers, (void **)h1->pps_buffers,\nMAX_PPS_COUNT, sizeof(PPS));",
"h->pps = h1->pps;",
"if ((VAR_3 = h264_slice_header_init(h, 1)) < 0) {",
"av_log(h->avctx, AV_LOG_ERROR, \"h264_slice_header_init() failed\");",
"return VAR_3;",
"}",
"VAR_4 = 1;",
"#if 0\nh264_set_parameter_from_sps(h);",
"h->cur_chroma_format_idc = h1->cur_chroma_format_idc;",
"#endif\n}",
"h->linesize = h1->linesize;",
"h->uvlinesize = h1->uvlinesize;",
"memcpy(h->block_offset, h1->block_offset, sizeof(h->block_offset));",
"if (!VAR_2) {",
"for (VAR_5 = 0; VAR_5 < MAX_SPS_COUNT; VAR_5++)",
"av_freep(h->sps_buffers + VAR_5);",
"for (VAR_5 = 0; VAR_5 < MAX_PPS_COUNT; VAR_5++)",
"av_freep(h->pps_buffers + VAR_5);",
"memcpy(h, h1, offsetof(H264Context, intra_pcm_ptr));",
"memcpy(&h->cabac, &h1->cabac,\nsizeof(H264Context) - offsetof(H264Context, cabac));",
"av_assert0((void*)&h->cabac == &h->mb_padding + 1);",
"memset(h->sps_buffers, 0, sizeof(h->sps_buffers));",
"memset(h->pps_buffers, 0, sizeof(h->pps_buffers));",
"memset(&h->er, 0, sizeof(h->er));",
"memset(&h->me, 0, sizeof(h->me));",
"memset(&h->mb, 0, sizeof(h->mb));",
"memset(&h->mb_luma_dc, 0, sizeof(h->mb_luma_dc));",
"memset(&h->mb_padding, 0, sizeof(h->mb_padding));",
"h->avctx = VAR_0;",
"h->DPB = NULL;",
"h->qscale_table_pool = NULL;",
"h->mb_type_pool = NULL;",
"h->ref_index_pool = NULL;",
"h->motion_val_pool = NULL;",
"if (h1->context_initialized) {",
"h->context_initialized = 0;",
"memset(&h->cur_pic, 0, sizeof(h->cur_pic));",
"avcodec_get_frame_defaults(&h->cur_pic.f);",
"h->cur_pic.tf.f = &h->cur_pic.f;",
"VAR_6 = ff_h264_alloc_tables(h);",
"if (VAR_6 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Could not allocate memory for h264\\n\");",
"return VAR_6;",
"}",
"VAR_6 = context_init(h);",
"if (VAR_6 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"context_init() failed.\\n\");",
"return VAR_6;",
"}",
"}",
"for (VAR_5 = 0; VAR_5 < 2; VAR_5++) {",
"h->rbsp_buffer[VAR_5] = NULL;",
"h->rbsp_buffer_size[VAR_5] = 0;",
"}",
"h->bipred_scratchpad = NULL;",
"h->edge_emu_buffer = NULL;",
"h->thread_context[0] = h;",
"h->context_initialized = h1->context_initialized;",
"}",
"h->avctx->coded_height = h1->avctx->coded_height;",
"h->avctx->coded_width = h1->avctx->coded_width;",
"h->avctx->width = h1->avctx->width;",
"h->avctx->height = h1->avctx->height;",
"h->coded_picture_number = h1->coded_picture_number;",
"h->first_field = h1->first_field;",
"h->picture_structure = h1->picture_structure;",
"h->qscale = h1->qscale;",
"h->droppable = h1->droppable;",
"h->data_partitioning = h1->data_partitioning;",
"h->low_delay = h1->low_delay;",
"for (VAR_5 = 0; h->DPB && VAR_5 < MAX_PICTURE_COUNT; VAR_5++) {",
"unref_picture(h, &h->DPB[VAR_5]);",
"if (h1->DPB[VAR_5].f.data[0] &&\n(VAR_6 = ref_picture(h, &h->DPB[VAR_5], &h1->DPB[VAR_5])) < 0)\nreturn VAR_6;",
"}",
"h->cur_pic_ptr = REBASE_PICTURE(h1->cur_pic_ptr, h, h1);",
"unref_picture(h, &h->cur_pic);",
"if (h1->cur_pic.f.buf[0] && (VAR_6 = ref_picture(h, &h->cur_pic, &h1->cur_pic)) < 0)\nreturn VAR_6;",
"h->workaround_bugs = h1->workaround_bugs;",
"h->low_delay = h1->low_delay;",
"h->droppable = h1->droppable;",
"h->is_avc = h1->is_avc;",
"copy_parameter_set((void **)h->sps_buffers, (void **)h1->sps_buffers,\nMAX_SPS_COUNT, sizeof(SPS));",
"h->sps = h1->sps;",
"copy_parameter_set((void **)h->pps_buffers, (void **)h1->pps_buffers,\nMAX_PPS_COUNT, sizeof(PPS));",
"h->pps = h1->pps;",
"copy_fields(h, h1, dequant4_buffer, dequant4_coeff);",
"for (VAR_5 = 0; VAR_5 < 6; VAR_5++)",
"h->dequant4_coeff[VAR_5] = h->dequant4_buffer[0] +\n(h1->dequant4_coeff[VAR_5] - h1->dequant4_buffer[0]);",
"for (VAR_5 = 0; VAR_5 < 6; VAR_5++)",
"h->dequant8_coeff[VAR_5] = h->dequant8_buffer[0] +\n(h1->dequant8_coeff[VAR_5] - h1->dequant8_buffer[0]);",
"h->dequant_coeff_pps = h1->dequant_coeff_pps;",
"copy_fields(h, h1, poc_lsb, redundant_pic_count);",
"copy_fields(h, h1, short_ref, cabac_init_idc);",
"copy_picture_range(h->short_ref, h1->short_ref, 32, h, h1);",
"copy_picture_range(h->long_ref, h1->long_ref, 32, h, h1);",
"copy_picture_range(h->delayed_pic, h1->delayed_pic,\nMAX_DELAYED_PIC_COUNT + 2, h, h1);",
"h->sync = h1->sync;",
"if (VAR_4)\nh264_set_parameter_from_sps(h);",
"if (!h->cur_pic_ptr)\nreturn 0;",
"if (!h->droppable) {",
"VAR_3 = ff_h264_execute_ref_pic_marking(h, h->mmco, h->mmco_index);",
"h->prev_poc_msb = h->poc_msb;",
"h->prev_poc_lsb = h->poc_lsb;",
"}",
"h->prev_frame_num_offset = h->frame_num_offset;",
"h->prev_frame_num = h->frame_num;",
"h->outputed_poc = h->next_outputed_poc;",
"return VAR_3;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17,
19
],
[
23,
25,
27,
29,
31,
33,
35,
37
],
[
47
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71,
73
],
[
75
],
[
77,
79
],
[
81
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
97,
99
],
[
103
],
[
105,
107
],
[
113
],
[
115
],
[
121
],
[
125
],
[
127
],
[
129
],
[
133
],
[
135
],
[
139
],
[
141,
143
],
[
145
],
[
149
],
[
151
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
181
],
[
183
],
[
187
],
[
189
],
[
191
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
233
],
[
235
],
[
237
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
265
],
[
267
],
[
269,
271,
273
],
[
275
],
[
279
],
[
281
],
[
283,
285
],
[
289
],
[
291
],
[
293
],
[
299
],
[
305,
307
],
[
309
],
[
311,
313
],
[
315
],
[
323
],
[
327
],
[
329,
331
],
[
335
],
[
337,
339
],
[
343
],
[
349
],
[
355
],
[
359
],
[
361
],
[
363,
365
],
[
369
],
[
373,
375
],
[
379,
381
],
[
385
],
[
387
],
[
389
],
[
391
],
[
393
],
[
395
],
[
397
],
[
399
],
[
403
],
[
405
]
] |
18,968 | static bool use_exit_tb(DisasContext *ctx)
{
return ((ctx->base.tb->cflags & CF_LAST_IO)
|| ctx->base.singlestep_enabled
|| singlestep);
}
| true | qemu | c5a49c63fa26e8825ad101dfe86339ae4c216539 | static bool use_exit_tb(DisasContext *ctx)
{
return ((ctx->base.tb->cflags & CF_LAST_IO)
|| ctx->base.singlestep_enabled
|| singlestep);
}
| {
"code": [
" return ((ctx->base.tb->cflags & CF_LAST_IO)"
],
"line_no": [
5
]
} | static bool FUNC_0(DisasContext *ctx)
{
return ((ctx->base.tb->cflags & CF_LAST_IO)
|| ctx->base.singlestep_enabled
|| singlestep);
}
| [
"static bool FUNC_0(DisasContext *ctx)\n{",
"return ((ctx->base.tb->cflags & CF_LAST_IO)\n|| ctx->base.singlestep_enabled\n|| singlestep);",
"}"
] | [
0,
1,
0
] | [
[
1,
3
],
[
5,
7,
9
],
[
11
]
] |
18,970 | static int register_insn (opc_handler_t **ppc_opcodes, opcode_t *insn)
{
if (insn->opc2 != 0xFF) {
if (insn->opc3 != 0xFF) {
if (register_dblind_insn(ppc_opcodes, insn->opc1, insn->opc2,
insn->opc3, &insn->handler) < 0)
return -1;
} else {
if (register_ind_insn(ppc_opcodes, insn->opc1,
insn->opc2, &insn->handler) < 0)
return -1;
}
} else {
if (register_direct_insn(ppc_opcodes, insn->opc1, &insn->handler) < 0)
return -1;
}
return 0;
}
| true | qemu | 323ad19bcc601d3ec9cb6f0f5b4d67b602fc519e | static int register_insn (opc_handler_t **ppc_opcodes, opcode_t *insn)
{
if (insn->opc2 != 0xFF) {
if (insn->opc3 != 0xFF) {
if (register_dblind_insn(ppc_opcodes, insn->opc1, insn->opc2,
insn->opc3, &insn->handler) < 0)
return -1;
} else {
if (register_ind_insn(ppc_opcodes, insn->opc1,
insn->opc2, &insn->handler) < 0)
return -1;
}
} else {
if (register_direct_insn(ppc_opcodes, insn->opc1, &insn->handler) < 0)
return -1;
}
return 0;
}
| {
"code": [
" if (register_dblind_insn(ppc_opcodes, insn->opc1, insn->opc2,",
" insn->opc3, &insn->handler) < 0)",
" return -1;"
],
"line_no": [
9,
11,
13
]
} | static int FUNC_0 (opc_handler_t **VAR_0, opcode_t *VAR_1)
{
if (VAR_1->opc2 != 0xFF) {
if (VAR_1->opc3 != 0xFF) {
if (register_dblind_insn(VAR_0, VAR_1->opc1, VAR_1->opc2,
VAR_1->opc3, &VAR_1->handler) < 0)
return -1;
} else {
if (register_ind_insn(VAR_0, VAR_1->opc1,
VAR_1->opc2, &VAR_1->handler) < 0)
return -1;
}
} else {
if (register_direct_insn(VAR_0, VAR_1->opc1, &VAR_1->handler) < 0)
return -1;
}
return 0;
}
| [
"static int FUNC_0 (opc_handler_t **VAR_0, opcode_t *VAR_1)\n{",
"if (VAR_1->opc2 != 0xFF) {",
"if (VAR_1->opc3 != 0xFF) {",
"if (register_dblind_insn(VAR_0, VAR_1->opc1, VAR_1->opc2,\nVAR_1->opc3, &VAR_1->handler) < 0)\nreturn -1;",
"} else {",
"if (register_ind_insn(VAR_0, VAR_1->opc1,\nVAR_1->opc2, &VAR_1->handler) < 0)\nreturn -1;",
"}",
"} else {",
"if (register_direct_insn(VAR_0, VAR_1->opc1, &VAR_1->handler) < 0)\nreturn -1;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9,
11,
13
],
[
15
],
[
17,
19,
21
],
[
23
],
[
25
],
[
27,
29
],
[
31
],
[
35
],
[
37
]
] |
18,971 | static ssize_t stellaris_enet_receive(NetClientState *nc, const uint8_t *buf, size_t size)
{
stellaris_enet_state *s = qemu_get_nic_opaque(nc);
int n;
uint8_t *p;
uint32_t crc;
if ((s->rctl & SE_RCTL_RXEN) == 0)
return -1;
if (s->np >= 31) {
return 0;
}
DPRINTF("Received packet len=%zu\n", size);
n = s->next_packet + s->np;
if (n >= 31)
n -= 31;
s->np++;
s->rx[n].len = size + 6;
p = s->rx[n].data;
*(p++) = (size + 6);
*(p++) = (size + 6) >> 8;
memcpy (p, buf, size);
p += size;
crc = crc32(~0, buf, size);
*(p++) = crc;
*(p++) = crc >> 8;
*(p++) = crc >> 16;
*(p++) = crc >> 24;
/* Clear the remaining bytes in the last word. */
if ((size & 3) != 2) {
memset(p, 0, (6 - size) & 3);
}
s->ris |= SE_INT_RX;
stellaris_enet_update(s);
return size;
}
| true | qemu | 3a15cc0e1ee7168db0782133d2607a6bfa422d66 | static ssize_t stellaris_enet_receive(NetClientState *nc, const uint8_t *buf, size_t size)
{
stellaris_enet_state *s = qemu_get_nic_opaque(nc);
int n;
uint8_t *p;
uint32_t crc;
if ((s->rctl & SE_RCTL_RXEN) == 0)
return -1;
if (s->np >= 31) {
return 0;
}
DPRINTF("Received packet len=%zu\n", size);
n = s->next_packet + s->np;
if (n >= 31)
n -= 31;
s->np++;
s->rx[n].len = size + 6;
p = s->rx[n].data;
*(p++) = (size + 6);
*(p++) = (size + 6) >> 8;
memcpy (p, buf, size);
p += size;
crc = crc32(~0, buf, size);
*(p++) = crc;
*(p++) = crc >> 8;
*(p++) = crc >> 16;
*(p++) = crc >> 24;
if ((size & 3) != 2) {
memset(p, 0, (6 - size) & 3);
}
s->ris |= SE_INT_RX;
stellaris_enet_update(s);
return size;
}
| {
"code": [
" s->np++;"
],
"line_no": [
35
]
} | static ssize_t FUNC_0(NetClientState *nc, const uint8_t *buf, size_t size)
{
stellaris_enet_state *s = qemu_get_nic_opaque(nc);
int VAR_0;
uint8_t *p;
uint32_t crc;
if ((s->rctl & SE_RCTL_RXEN) == 0)
return -1;
if (s->np >= 31) {
return 0;
}
DPRINTF("Received packet len=%zu\VAR_0", size);
VAR_0 = s->next_packet + s->np;
if (VAR_0 >= 31)
VAR_0 -= 31;
s->np++;
s->rx[VAR_0].len = size + 6;
p = s->rx[VAR_0].data;
*(p++) = (size + 6);
*(p++) = (size + 6) >> 8;
memcpy (p, buf, size);
p += size;
crc = crc32(~0, buf, size);
*(p++) = crc;
*(p++) = crc >> 8;
*(p++) = crc >> 16;
*(p++) = crc >> 24;
if ((size & 3) != 2) {
memset(p, 0, (6 - size) & 3);
}
s->ris |= SE_INT_RX;
stellaris_enet_update(s);
return size;
}
| [
"static ssize_t FUNC_0(NetClientState *nc, const uint8_t *buf, size_t size)\n{",
"stellaris_enet_state *s = qemu_get_nic_opaque(nc);",
"int VAR_0;",
"uint8_t *p;",
"uint32_t crc;",
"if ((s->rctl & SE_RCTL_RXEN) == 0)\nreturn -1;",
"if (s->np >= 31) {",
"return 0;",
"}",
"DPRINTF(\"Received packet len=%zu\\VAR_0\", size);",
"VAR_0 = s->next_packet + s->np;",
"if (VAR_0 >= 31)\nVAR_0 -= 31;",
"s->np++;",
"s->rx[VAR_0].len = size + 6;",
"p = s->rx[VAR_0].data;",
"*(p++) = (size + 6);",
"*(p++) = (size + 6) >> 8;",
"memcpy (p, buf, size);",
"p += size;",
"crc = crc32(~0, buf, size);",
"*(p++) = crc;",
"*(p++) = crc >> 8;",
"*(p++) = crc >> 16;",
"*(p++) = crc >> 24;",
"if ((size & 3) != 2) {",
"memset(p, 0, (6 - size) & 3);",
"}",
"s->ris |= SE_INT_RX;",
"stellaris_enet_update(s);",
"return size;",
"}"
] | [
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15,
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31,
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
77
],
[
79
]
] |
18,972 | int ff_mp4_read_dec_config_descr(AVFormatContext *fc, AVStream *st, AVIOContext *pb)
{
int len, tag;
int object_type_id = avio_r8(pb);
avio_r8(pb); /* stream type */
avio_rb24(pb); /* buffer size db */
avio_rb32(pb); /* max bitrate */
avio_rb32(pb); /* avg bitrate */
if(avcodec_is_open(st->codec)) {
av_log(fc, AV_LOG_DEBUG, "codec open in read_dec_config_descr\n");
return -1;
}
st->codec->codec_id= ff_codec_get_id(ff_mp4_obj_type, object_type_id);
av_dlog(fc, "esds object type id 0x%02x\n", object_type_id);
len = ff_mp4_read_descr(fc, pb, &tag);
if (tag == MP4DecSpecificDescrTag) {
av_dlog(fc, "Specific MPEG4 header len=%d\n", len);
if (!len || (uint64_t)len > (1<<30))
return -1;
av_free(st->codec->extradata);
if (ff_alloc_extradata(st->codec, len))
return AVERROR(ENOMEM);
avio_read(pb, st->codec->extradata, len);
if (st->codec->codec_id == AV_CODEC_ID_AAC) {
MPEG4AudioConfig cfg = {0};
avpriv_mpeg4audio_get_config(&cfg, st->codec->extradata,
st->codec->extradata_size * 8, 1);
st->codec->channels = cfg.channels;
if (cfg.object_type == 29 && cfg.sampling_index < 3) // old mp3on4
st->codec->sample_rate = avpriv_mpa_freq_tab[cfg.sampling_index];
else if (cfg.ext_sample_rate)
st->codec->sample_rate = cfg.ext_sample_rate;
else
st->codec->sample_rate = cfg.sample_rate;
av_dlog(fc, "mp4a config channels %d obj %d ext obj %d "
"sample rate %d ext sample rate %d\n", st->codec->channels,
cfg.object_type, cfg.ext_object_type,
cfg.sample_rate, cfg.ext_sample_rate);
if (!(st->codec->codec_id = ff_codec_get_id(mp4_audio_types,
cfg.object_type)))
st->codec->codec_id = AV_CODEC_ID_AAC;
}
}
return 0;
}
| true | FFmpeg | 2c635fabbf7ec8ed4f30d9b3c04d5c24cb7a081d | int ff_mp4_read_dec_config_descr(AVFormatContext *fc, AVStream *st, AVIOContext *pb)
{
int len, tag;
int object_type_id = avio_r8(pb);
avio_r8(pb);
avio_rb24(pb);
avio_rb32(pb);
avio_rb32(pb);
if(avcodec_is_open(st->codec)) {
av_log(fc, AV_LOG_DEBUG, "codec open in read_dec_config_descr\n");
return -1;
}
st->codec->codec_id= ff_codec_get_id(ff_mp4_obj_type, object_type_id);
av_dlog(fc, "esds object type id 0x%02x\n", object_type_id);
len = ff_mp4_read_descr(fc, pb, &tag);
if (tag == MP4DecSpecificDescrTag) {
av_dlog(fc, "Specific MPEG4 header len=%d\n", len);
if (!len || (uint64_t)len > (1<<30))
return -1;
av_free(st->codec->extradata);
if (ff_alloc_extradata(st->codec, len))
return AVERROR(ENOMEM);
avio_read(pb, st->codec->extradata, len);
if (st->codec->codec_id == AV_CODEC_ID_AAC) {
MPEG4AudioConfig cfg = {0};
avpriv_mpeg4audio_get_config(&cfg, st->codec->extradata,
st->codec->extradata_size * 8, 1);
st->codec->channels = cfg.channels;
if (cfg.object_type == 29 && cfg.sampling_index < 3)
st->codec->sample_rate = avpriv_mpa_freq_tab[cfg.sampling_index];
else if (cfg.ext_sample_rate)
st->codec->sample_rate = cfg.ext_sample_rate;
else
st->codec->sample_rate = cfg.sample_rate;
av_dlog(fc, "mp4a config channels %d obj %d ext obj %d "
"sample rate %d ext sample rate %d\n", st->codec->channels,
cfg.object_type, cfg.ext_object_type,
cfg.sample_rate, cfg.ext_sample_rate);
if (!(st->codec->codec_id = ff_codec_get_id(mp4_audio_types,
cfg.object_type)))
st->codec->codec_id = AV_CODEC_ID_AAC;
}
}
return 0;
}
| {
"code": [
" avio_read(pb, st->codec->extradata, len);"
],
"line_no": [
49
]
} | int FUNC_0(AVFormatContext *VAR_0, AVStream *VAR_1, AVIOContext *VAR_2)
{
int VAR_3, VAR_4;
int VAR_5 = avio_r8(VAR_2);
avio_r8(VAR_2);
avio_rb24(VAR_2);
avio_rb32(VAR_2);
avio_rb32(VAR_2);
if(avcodec_is_open(VAR_1->codec)) {
av_log(VAR_0, AV_LOG_DEBUG, "codec open in read_dec_config_descr\n");
return -1;
}
VAR_1->codec->codec_id= ff_codec_get_id(ff_mp4_obj_type, VAR_5);
av_dlog(VAR_0, "esds object type id 0x%02x\n", VAR_5);
VAR_3 = ff_mp4_read_descr(VAR_0, VAR_2, &VAR_4);
if (VAR_4 == MP4DecSpecificDescrTag) {
av_dlog(VAR_0, "Specific MPEG4 header VAR_3=%d\n", VAR_3);
if (!VAR_3 || (uint64_t)VAR_3 > (1<<30))
return -1;
av_free(VAR_1->codec->extradata);
if (ff_alloc_extradata(VAR_1->codec, VAR_3))
return AVERROR(ENOMEM);
avio_read(VAR_2, VAR_1->codec->extradata, VAR_3);
if (VAR_1->codec->codec_id == AV_CODEC_ID_AAC) {
MPEG4AudioConfig cfg = {0};
avpriv_mpeg4audio_get_config(&cfg, VAR_1->codec->extradata,
VAR_1->codec->extradata_size * 8, 1);
VAR_1->codec->channels = cfg.channels;
if (cfg.object_type == 29 && cfg.sampling_index < 3)
VAR_1->codec->sample_rate = avpriv_mpa_freq_tab[cfg.sampling_index];
else if (cfg.ext_sample_rate)
VAR_1->codec->sample_rate = cfg.ext_sample_rate;
else
VAR_1->codec->sample_rate = cfg.sample_rate;
av_dlog(VAR_0, "mp4a config channels %d obj %d ext obj %d "
"sample rate %d ext sample rate %d\n", VAR_1->codec->channels,
cfg.object_type, cfg.ext_object_type,
cfg.sample_rate, cfg.ext_sample_rate);
if (!(VAR_1->codec->codec_id = ff_codec_get_id(mp4_audio_types,
cfg.object_type)))
VAR_1->codec->codec_id = AV_CODEC_ID_AAC;
}
}
return 0;
}
| [
"int FUNC_0(AVFormatContext *VAR_0, AVStream *VAR_1, AVIOContext *VAR_2)\n{",
"int VAR_3, VAR_4;",
"int VAR_5 = avio_r8(VAR_2);",
"avio_r8(VAR_2);",
"avio_rb24(VAR_2);",
"avio_rb32(VAR_2);",
"avio_rb32(VAR_2);",
"if(avcodec_is_open(VAR_1->codec)) {",
"av_log(VAR_0, AV_LOG_DEBUG, \"codec open in read_dec_config_descr\\n\");",
"return -1;",
"}",
"VAR_1->codec->codec_id= ff_codec_get_id(ff_mp4_obj_type, VAR_5);",
"av_dlog(VAR_0, \"esds object type id 0x%02x\\n\", VAR_5);",
"VAR_3 = ff_mp4_read_descr(VAR_0, VAR_2, &VAR_4);",
"if (VAR_4 == MP4DecSpecificDescrTag) {",
"av_dlog(VAR_0, \"Specific MPEG4 header VAR_3=%d\\n\", VAR_3);",
"if (!VAR_3 || (uint64_t)VAR_3 > (1<<30))\nreturn -1;",
"av_free(VAR_1->codec->extradata);",
"if (ff_alloc_extradata(VAR_1->codec, VAR_3))\nreturn AVERROR(ENOMEM);",
"avio_read(VAR_2, VAR_1->codec->extradata, VAR_3);",
"if (VAR_1->codec->codec_id == AV_CODEC_ID_AAC) {",
"MPEG4AudioConfig cfg = {0};",
"avpriv_mpeg4audio_get_config(&cfg, VAR_1->codec->extradata,\nVAR_1->codec->extradata_size * 8, 1);",
"VAR_1->codec->channels = cfg.channels;",
"if (cfg.object_type == 29 && cfg.sampling_index < 3)\nVAR_1->codec->sample_rate = avpriv_mpa_freq_tab[cfg.sampling_index];",
"else if (cfg.ext_sample_rate)\nVAR_1->codec->sample_rate = cfg.ext_sample_rate;",
"else\nVAR_1->codec->sample_rate = cfg.sample_rate;",
"av_dlog(VAR_0, \"mp4a config channels %d obj %d ext obj %d \"\n\"sample rate %d ext sample rate %d\\n\", VAR_1->codec->channels,\ncfg.object_type, cfg.ext_object_type,\ncfg.sample_rate, cfg.ext_sample_rate);",
"if (!(VAR_1->codec->codec_id = ff_codec_get_id(mp4_audio_types,\ncfg.object_type)))\nVAR_1->codec->codec_id = AV_CODEC_ID_AAC;",
"}",
"}",
"return 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
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39,
41
],
[
43
],
[
45,
47
],
[
49
],
[
51
],
[
53
],
[
55,
57
],
[
59
],
[
61,
63
],
[
65,
67
],
[
69,
71
],
[
73,
75,
77,
79
],
[
81,
83,
85
],
[
87
],
[
89
],
[
91
],
[
93
]
] |
18,973 | static int swr_convert_internal(struct SwrContext *s, AudioData *out, int out_count,
AudioData *in , int in_count){
AudioData *postin, *midbuf, *preout;
int ret/*, in_max*/;
AudioData preout_tmp, midbuf_tmp;
if(s->full_convert){
av_assert0(!s->resample);
swri_audio_convert(s->full_convert, out, in, in_count);
return out_count;
}
// in_max= out_count*(int64_t)s->in_sample_rate / s->out_sample_rate + resample_filter_taps;
// in_count= FFMIN(in_count, in_in + 2 - s->hist_buffer_count);
if((ret=swri_realloc_audio(&s->postin, in_count))<0)
return ret;
if(s->resample_first){
av_assert0(s->midbuf.ch_count == s->used_ch_count);
if((ret=swri_realloc_audio(&s->midbuf, out_count))<0)
return ret;
}else{
av_assert0(s->midbuf.ch_count == s->out.ch_count);
if((ret=swri_realloc_audio(&s->midbuf, in_count))<0)
return ret;
}
if((ret=swri_realloc_audio(&s->preout, out_count))<0)
return ret;
postin= &s->postin;
midbuf_tmp= s->midbuf;
midbuf= &midbuf_tmp;
preout_tmp= s->preout;
preout= &preout_tmp;
if(s->int_sample_fmt == s-> in_sample_fmt && s->in.planar && !s->channel_map)
postin= in;
if(s->resample_first ? !s->resample : !s->rematrix)
midbuf= postin;
if(s->resample_first ? !s->rematrix : !s->resample)
preout= midbuf;
if(s->int_sample_fmt == s->out_sample_fmt && s->out.planar
&& !(s->out_sample_fmt==AV_SAMPLE_FMT_S32P && (s->dither.output_sample_bits&31))){
if(preout==in){
out_count= FFMIN(out_count, in_count); //TODO check at the end if this is needed or redundant
av_assert0(s->in.planar); //we only support planar internally so it has to be, we support copying non planar though
copy(out, in, out_count);
return out_count;
}
else if(preout==postin) preout= midbuf= postin= out;
else if(preout==midbuf) preout= midbuf= out;
else preout= out;
}
if(in != postin){
swri_audio_convert(s->in_convert, postin, in, in_count);
}
if(s->resample_first){
if(postin != midbuf)
out_count= resample(s, midbuf, out_count, postin, in_count);
if(midbuf != preout)
swri_rematrix(s, preout, midbuf, out_count, preout==out);
}else{
if(postin != midbuf)
swri_rematrix(s, midbuf, postin, in_count, midbuf==out);
if(midbuf != preout)
out_count= resample(s, preout, out_count, midbuf, in_count);
}
if(preout != out && out_count){
AudioData *conv_src = preout;
if(s->dither.method){
int ch;
int dither_count= FFMAX(out_count, 1<<16);
if (preout == in) {
conv_src = &s->dither.temp;
if((ret=swri_realloc_audio(&s->dither.temp, dither_count))<0)
return ret;
}
if((ret=swri_realloc_audio(&s->dither.noise, dither_count))<0)
return ret;
if(ret)
for(ch=0; ch<s->dither.noise.ch_count; ch++)
if((ret=swri_get_dither(s, s->dither.noise.ch[ch], s->dither.noise.count, 12345678913579<<ch, s->dither.noise.fmt))<0)
return ret;
av_assert0(s->dither.noise.ch_count == preout->ch_count);
if(s->dither.noise_pos + out_count > s->dither.noise.count)
s->dither.noise_pos = 0;
if (s->dither.method < SWR_DITHER_NS){
if (s->mix_2_1_simd) {
int len1= out_count&~15;
int off = len1 * preout->bps;
if(len1)
for(ch=0; ch<preout->ch_count; ch++)
s->mix_2_1_simd(conv_src->ch[ch], preout->ch[ch], s->dither.noise.ch[ch] + s->dither.noise.bps * s->dither.noise_pos, s->native_simd_one, 0, 0, len1);
if(out_count != len1)
for(ch=0; ch<preout->ch_count; ch++)
s->mix_2_1_f(conv_src->ch[ch] + off, preout->ch[ch] + off, s->dither.noise.ch[ch] + s->dither.noise.bps * s->dither.noise_pos + off + len1, s->native_one, 0, 0, out_count - len1);
} else {
for(ch=0; ch<preout->ch_count; ch++)
s->mix_2_1_f(conv_src->ch[ch], preout->ch[ch], s->dither.noise.ch[ch] + s->dither.noise.bps * s->dither.noise_pos, s->native_one, 0, 0, out_count);
}
} else {
switch(s->int_sample_fmt) {
case AV_SAMPLE_FMT_S16P :swri_noise_shaping_int16(s, conv_src, preout, &s->dither.noise, out_count); break;
case AV_SAMPLE_FMT_S32P :swri_noise_shaping_int32(s, conv_src, preout, &s->dither.noise, out_count); break;
case AV_SAMPLE_FMT_FLTP :swri_noise_shaping_float(s, conv_src, preout, &s->dither.noise, out_count); break;
case AV_SAMPLE_FMT_DBLP :swri_noise_shaping_double(s,conv_src, preout, &s->dither.noise, out_count); break;
}
}
s->dither.noise_pos += out_count;
}
//FIXME packed doesn't need more than 1 chan here!
swri_audio_convert(s->out_convert, out, conv_src, out_count);
}
return out_count;
}
| true | FFmpeg | 32f53958b8f6ed4c3c2a7447c1e47d012796fae2 | static int swr_convert_internal(struct SwrContext *s, AudioData *out, int out_count,
AudioData *in , int in_count){
AudioData *postin, *midbuf, *preout;
int ret;
AudioData preout_tmp, midbuf_tmp;
if(s->full_convert){
av_assert0(!s->resample);
swri_audio_convert(s->full_convert, out, in, in_count);
return out_count;
}
if((ret=swri_realloc_audio(&s->postin, in_count))<0)
return ret;
if(s->resample_first){
av_assert0(s->midbuf.ch_count == s->used_ch_count);
if((ret=swri_realloc_audio(&s->midbuf, out_count))<0)
return ret;
}else{
av_assert0(s->midbuf.ch_count == s->out.ch_count);
if((ret=swri_realloc_audio(&s->midbuf, in_count))<0)
return ret;
}
if((ret=swri_realloc_audio(&s->preout, out_count))<0)
return ret;
postin= &s->postin;
midbuf_tmp= s->midbuf;
midbuf= &midbuf_tmp;
preout_tmp= s->preout;
preout= &preout_tmp;
if(s->int_sample_fmt == s-> in_sample_fmt && s->in.planar && !s->channel_map)
postin= in;
if(s->resample_first ? !s->resample : !s->rematrix)
midbuf= postin;
if(s->resample_first ? !s->rematrix : !s->resample)
preout= midbuf;
if(s->int_sample_fmt == s->out_sample_fmt && s->out.planar
&& !(s->out_sample_fmt==AV_SAMPLE_FMT_S32P && (s->dither.output_sample_bits&31))){
if(preout==in){
out_count= FFMIN(out_count, in_count);
av_assert0(s->in.planar);
copy(out, in, out_count);
return out_count;
}
else if(preout==postin) preout= midbuf= postin= out;
else if(preout==midbuf) preout= midbuf= out;
else preout= out;
}
if(in != postin){
swri_audio_convert(s->in_convert, postin, in, in_count);
}
if(s->resample_first){
if(postin != midbuf)
out_count= resample(s, midbuf, out_count, postin, in_count);
if(midbuf != preout)
swri_rematrix(s, preout, midbuf, out_count, preout==out);
}else{
if(postin != midbuf)
swri_rematrix(s, midbuf, postin, in_count, midbuf==out);
if(midbuf != preout)
out_count= resample(s, preout, out_count, midbuf, in_count);
}
if(preout != out && out_count){
AudioData *conv_src = preout;
if(s->dither.method){
int ch;
int dither_count= FFMAX(out_count, 1<<16);
if (preout == in) {
conv_src = &s->dither.temp;
if((ret=swri_realloc_audio(&s->dither.temp, dither_count))<0)
return ret;
}
if((ret=swri_realloc_audio(&s->dither.noise, dither_count))<0)
return ret;
if(ret)
for(ch=0; ch<s->dither.noise.ch_count; ch++)
if((ret=swri_get_dither(s, s->dither.noise.ch[ch], s->dither.noise.count, 12345678913579<<ch, s->dither.noise.fmt))<0)
return ret;
av_assert0(s->dither.noise.ch_count == preout->ch_count);
if(s->dither.noise_pos + out_count > s->dither.noise.count)
s->dither.noise_pos = 0;
if (s->dither.method < SWR_DITHER_NS){
if (s->mix_2_1_simd) {
int len1= out_count&~15;
int off = len1 * preout->bps;
if(len1)
for(ch=0; ch<preout->ch_count; ch++)
s->mix_2_1_simd(conv_src->ch[ch], preout->ch[ch], s->dither.noise.ch[ch] + s->dither.noise.bps * s->dither.noise_pos, s->native_simd_one, 0, 0, len1);
if(out_count != len1)
for(ch=0; ch<preout->ch_count; ch++)
s->mix_2_1_f(conv_src->ch[ch] + off, preout->ch[ch] + off, s->dither.noise.ch[ch] + s->dither.noise.bps * s->dither.noise_pos + off + len1, s->native_one, 0, 0, out_count - len1);
} else {
for(ch=0; ch<preout->ch_count; ch++)
s->mix_2_1_f(conv_src->ch[ch], preout->ch[ch], s->dither.noise.ch[ch] + s->dither.noise.bps * s->dither.noise_pos, s->native_one, 0, 0, out_count);
}
} else {
switch(s->int_sample_fmt) {
case AV_SAMPLE_FMT_S16P :swri_noise_shaping_int16(s, conv_src, preout, &s->dither.noise, out_count); break;
case AV_SAMPLE_FMT_S32P :swri_noise_shaping_int32(s, conv_src, preout, &s->dither.noise, out_count); break;
case AV_SAMPLE_FMT_FLTP :swri_noise_shaping_float(s, conv_src, preout, &s->dither.noise, out_count); break;
case AV_SAMPLE_FMT_DBLP :swri_noise_shaping_double(s,conv_src, preout, &s->dither.noise, out_count); break;
}
}
s->dither.noise_pos += out_count;
}
swri_audio_convert(s->out_convert, out, conv_src, out_count);
}
return out_count;
}
| {
"code": [
" if((ret=swri_get_dither(s, s->dither.noise.ch[ch], s->dither.noise.count, 12345678913579<<ch, s->dither.noise.fmt))<0)"
],
"line_no": [
181
]
} | static int FUNC_0(struct SwrContext *VAR_0, AudioData *VAR_1, int VAR_2,
AudioData *VAR_3 , int VAR_4){
AudioData *postin, *midbuf, *preout;
int VAR_5;
AudioData preout_tmp, midbuf_tmp;
if(VAR_0->full_convert){
av_assert0(!VAR_0->resample);
swri_audio_convert(VAR_0->full_convert, VAR_1, VAR_3, VAR_4);
return VAR_2;
}
if((VAR_5=swri_realloc_audio(&VAR_0->postin, VAR_4))<0)
return VAR_5;
if(VAR_0->resample_first){
av_assert0(VAR_0->midbuf.ch_count == VAR_0->used_ch_count);
if((VAR_5=swri_realloc_audio(&VAR_0->midbuf, VAR_2))<0)
return VAR_5;
}else{
av_assert0(VAR_0->midbuf.ch_count == VAR_0->VAR_1.ch_count);
if((VAR_5=swri_realloc_audio(&VAR_0->midbuf, VAR_4))<0)
return VAR_5;
}
if((VAR_5=swri_realloc_audio(&VAR_0->preout, VAR_2))<0)
return VAR_5;
postin= &VAR_0->postin;
midbuf_tmp= VAR_0->midbuf;
midbuf= &midbuf_tmp;
preout_tmp= VAR_0->preout;
preout= &preout_tmp;
if(VAR_0->int_sample_fmt == VAR_0-> in_sample_fmt && VAR_0->VAR_3.planar && !VAR_0->channel_map)
postin= VAR_3;
if(VAR_0->resample_first ? !VAR_0->resample : !VAR_0->rematrix)
midbuf= postin;
if(VAR_0->resample_first ? !VAR_0->rematrix : !VAR_0->resample)
preout= midbuf;
if(VAR_0->int_sample_fmt == VAR_0->out_sample_fmt && VAR_0->VAR_1.planar
&& !(VAR_0->out_sample_fmt==AV_SAMPLE_FMT_S32P && (VAR_0->dither.output_sample_bits&31))){
if(preout==VAR_3){
VAR_2= FFMIN(VAR_2, VAR_4);
av_assert0(VAR_0->VAR_3.planar);
copy(VAR_1, VAR_3, VAR_2);
return VAR_2;
}
else if(preout==postin) preout= midbuf= postin= VAR_1;
else if(preout==midbuf) preout= midbuf= VAR_1;
else preout= VAR_1;
}
if(VAR_3 != postin){
swri_audio_convert(VAR_0->in_convert, postin, VAR_3, VAR_4);
}
if(VAR_0->resample_first){
if(postin != midbuf)
VAR_2= resample(VAR_0, midbuf, VAR_2, postin, VAR_4);
if(midbuf != preout)
swri_rematrix(VAR_0, preout, midbuf, VAR_2, preout==VAR_1);
}else{
if(postin != midbuf)
swri_rematrix(VAR_0, midbuf, postin, VAR_4, midbuf==VAR_1);
if(midbuf != preout)
VAR_2= resample(VAR_0, preout, VAR_2, midbuf, VAR_4);
}
if(preout != VAR_1 && VAR_2){
AudioData *conv_src = preout;
if(VAR_0->dither.method){
int VAR_6;
int VAR_7= FFMAX(VAR_2, 1<<16);
if (preout == VAR_3) {
conv_src = &VAR_0->dither.temp;
if((VAR_5=swri_realloc_audio(&VAR_0->dither.temp, VAR_7))<0)
return VAR_5;
}
if((VAR_5=swri_realloc_audio(&VAR_0->dither.noise, VAR_7))<0)
return VAR_5;
if(VAR_5)
for(VAR_6=0; VAR_6<VAR_0->dither.noise.ch_count; VAR_6++)
if((VAR_5=swri_get_dither(VAR_0, VAR_0->dither.noise.VAR_6[VAR_6], VAR_0->dither.noise.count, 12345678913579<<VAR_6, VAR_0->dither.noise.fmt))<0)
return VAR_5;
av_assert0(VAR_0->dither.noise.ch_count == preout->ch_count);
if(VAR_0->dither.noise_pos + VAR_2 > VAR_0->dither.noise.count)
VAR_0->dither.noise_pos = 0;
if (VAR_0->dither.method < SWR_DITHER_NS){
if (VAR_0->mix_2_1_simd) {
int VAR_8= VAR_2&~15;
int VAR_9 = VAR_8 * preout->bps;
if(VAR_8)
for(VAR_6=0; VAR_6<preout->ch_count; VAR_6++)
VAR_0->mix_2_1_simd(conv_src->VAR_6[VAR_6], preout->VAR_6[VAR_6], VAR_0->dither.noise.VAR_6[VAR_6] + VAR_0->dither.noise.bps * VAR_0->dither.noise_pos, VAR_0->native_simd_one, 0, 0, VAR_8);
if(VAR_2 != VAR_8)
for(VAR_6=0; VAR_6<preout->ch_count; VAR_6++)
VAR_0->mix_2_1_f(conv_src->VAR_6[VAR_6] + VAR_9, preout->VAR_6[VAR_6] + VAR_9, VAR_0->dither.noise.VAR_6[VAR_6] + VAR_0->dither.noise.bps * VAR_0->dither.noise_pos + VAR_9 + VAR_8, VAR_0->native_one, 0, 0, VAR_2 - VAR_8);
} else {
for(VAR_6=0; VAR_6<preout->ch_count; VAR_6++)
VAR_0->mix_2_1_f(conv_src->VAR_6[VAR_6], preout->VAR_6[VAR_6], VAR_0->dither.noise.VAR_6[VAR_6] + VAR_0->dither.noise.bps * VAR_0->dither.noise_pos, VAR_0->native_one, 0, 0, VAR_2);
}
} else {
switch(VAR_0->int_sample_fmt) {
case AV_SAMPLE_FMT_S16P :swri_noise_shaping_int16(VAR_0, conv_src, preout, &VAR_0->dither.noise, VAR_2); break;
case AV_SAMPLE_FMT_S32P :swri_noise_shaping_int32(VAR_0, conv_src, preout, &VAR_0->dither.noise, VAR_2); break;
case AV_SAMPLE_FMT_FLTP :swri_noise_shaping_float(VAR_0, conv_src, preout, &VAR_0->dither.noise, VAR_2); break;
case AV_SAMPLE_FMT_DBLP :swri_noise_shaping_double(VAR_0,conv_src, preout, &VAR_0->dither.noise, VAR_2); break;
}
}
VAR_0->dither.noise_pos += VAR_2;
}
swri_audio_convert(VAR_0->out_convert, VAR_1, conv_src, VAR_2);
}
return VAR_2;
}
| [
"static int FUNC_0(struct SwrContext *VAR_0, AudioData *VAR_1, int VAR_2,\nAudioData *VAR_3 , int VAR_4){",
"AudioData *postin, *midbuf, *preout;",
"int VAR_5;",
"AudioData preout_tmp, midbuf_tmp;",
"if(VAR_0->full_convert){",
"av_assert0(!VAR_0->resample);",
"swri_audio_convert(VAR_0->full_convert, VAR_1, VAR_3, VAR_4);",
"return VAR_2;",
"}",
"if((VAR_5=swri_realloc_audio(&VAR_0->postin, VAR_4))<0)\nreturn VAR_5;",
"if(VAR_0->resample_first){",
"av_assert0(VAR_0->midbuf.ch_count == VAR_0->used_ch_count);",
"if((VAR_5=swri_realloc_audio(&VAR_0->midbuf, VAR_2))<0)\nreturn VAR_5;",
"}else{",
"av_assert0(VAR_0->midbuf.ch_count == VAR_0->VAR_1.ch_count);",
"if((VAR_5=swri_realloc_audio(&VAR_0->midbuf, VAR_4))<0)\nreturn VAR_5;",
"}",
"if((VAR_5=swri_realloc_audio(&VAR_0->preout, VAR_2))<0)\nreturn VAR_5;",
"postin= &VAR_0->postin;",
"midbuf_tmp= VAR_0->midbuf;",
"midbuf= &midbuf_tmp;",
"preout_tmp= VAR_0->preout;",
"preout= &preout_tmp;",
"if(VAR_0->int_sample_fmt == VAR_0-> in_sample_fmt && VAR_0->VAR_3.planar && !VAR_0->channel_map)\npostin= VAR_3;",
"if(VAR_0->resample_first ? !VAR_0->resample : !VAR_0->rematrix)\nmidbuf= postin;",
"if(VAR_0->resample_first ? !VAR_0->rematrix : !VAR_0->resample)\npreout= midbuf;",
"if(VAR_0->int_sample_fmt == VAR_0->out_sample_fmt && VAR_0->VAR_1.planar\n&& !(VAR_0->out_sample_fmt==AV_SAMPLE_FMT_S32P && (VAR_0->dither.output_sample_bits&31))){",
"if(preout==VAR_3){",
"VAR_2= FFMIN(VAR_2, VAR_4);",
"av_assert0(VAR_0->VAR_3.planar);",
"copy(VAR_1, VAR_3, VAR_2);",
"return VAR_2;",
"}",
"else if(preout==postin) preout= midbuf= postin= VAR_1;",
"else if(preout==midbuf) preout= midbuf= VAR_1;",
"else preout= VAR_1;",
"}",
"if(VAR_3 != postin){",
"swri_audio_convert(VAR_0->in_convert, postin, VAR_3, VAR_4);",
"}",
"if(VAR_0->resample_first){",
"if(postin != midbuf)\nVAR_2= resample(VAR_0, midbuf, VAR_2, postin, VAR_4);",
"if(midbuf != preout)\nswri_rematrix(VAR_0, preout, midbuf, VAR_2, preout==VAR_1);",
"}else{",
"if(postin != midbuf)\nswri_rematrix(VAR_0, midbuf, postin, VAR_4, midbuf==VAR_1);",
"if(midbuf != preout)\nVAR_2= resample(VAR_0, preout, VAR_2, midbuf, VAR_4);",
"}",
"if(preout != VAR_1 && VAR_2){",
"AudioData *conv_src = preout;",
"if(VAR_0->dither.method){",
"int VAR_6;",
"int VAR_7= FFMAX(VAR_2, 1<<16);",
"if (preout == VAR_3) {",
"conv_src = &VAR_0->dither.temp;",
"if((VAR_5=swri_realloc_audio(&VAR_0->dither.temp, VAR_7))<0)\nreturn VAR_5;",
"}",
"if((VAR_5=swri_realloc_audio(&VAR_0->dither.noise, VAR_7))<0)\nreturn VAR_5;",
"if(VAR_5)\nfor(VAR_6=0; VAR_6<VAR_0->dither.noise.ch_count; VAR_6++)",
"if((VAR_5=swri_get_dither(VAR_0, VAR_0->dither.noise.VAR_6[VAR_6], VAR_0->dither.noise.count, 12345678913579<<VAR_6, VAR_0->dither.noise.fmt))<0)\nreturn VAR_5;",
"av_assert0(VAR_0->dither.noise.ch_count == preout->ch_count);",
"if(VAR_0->dither.noise_pos + VAR_2 > VAR_0->dither.noise.count)\nVAR_0->dither.noise_pos = 0;",
"if (VAR_0->dither.method < SWR_DITHER_NS){",
"if (VAR_0->mix_2_1_simd) {",
"int VAR_8= VAR_2&~15;",
"int VAR_9 = VAR_8 * preout->bps;",
"if(VAR_8)\nfor(VAR_6=0; VAR_6<preout->ch_count; VAR_6++)",
"VAR_0->mix_2_1_simd(conv_src->VAR_6[VAR_6], preout->VAR_6[VAR_6], VAR_0->dither.noise.VAR_6[VAR_6] + VAR_0->dither.noise.bps * VAR_0->dither.noise_pos, VAR_0->native_simd_one, 0, 0, VAR_8);",
"if(VAR_2 != VAR_8)\nfor(VAR_6=0; VAR_6<preout->ch_count; VAR_6++)",
"VAR_0->mix_2_1_f(conv_src->VAR_6[VAR_6] + VAR_9, preout->VAR_6[VAR_6] + VAR_9, VAR_0->dither.noise.VAR_6[VAR_6] + VAR_0->dither.noise.bps * VAR_0->dither.noise_pos + VAR_9 + VAR_8, VAR_0->native_one, 0, 0, VAR_2 - VAR_8);",
"} else {",
"for(VAR_6=0; VAR_6<preout->ch_count; VAR_6++)",
"VAR_0->mix_2_1_f(conv_src->VAR_6[VAR_6], preout->VAR_6[VAR_6], VAR_0->dither.noise.VAR_6[VAR_6] + VAR_0->dither.noise.bps * VAR_0->dither.noise_pos, VAR_0->native_one, 0, 0, VAR_2);",
"}",
"} else {",
"switch(VAR_0->int_sample_fmt) {",
"case AV_SAMPLE_FMT_S16P :swri_noise_shaping_int16(VAR_0, conv_src, preout, &VAR_0->dither.noise, VAR_2); break;",
"case AV_SAMPLE_FMT_S32P :swri_noise_shaping_int32(VAR_0, conv_src, preout, &VAR_0->dither.noise, VAR_2); break;",
"case AV_SAMPLE_FMT_FLTP :swri_noise_shaping_float(VAR_0, conv_src, preout, &VAR_0->dither.noise, VAR_2); break;",
"case AV_SAMPLE_FMT_DBLP :swri_noise_shaping_double(VAR_0,conv_src, preout, &VAR_0->dither.noise, VAR_2); break;",
"}",
"}",
"VAR_0->dither.noise_pos += VAR_2;",
"}",
"swri_audio_convert(VAR_0->out_convert, VAR_1, conv_src, VAR_2);",
"}",
"return VAR_2;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
31,
33
],
[
35
],
[
37
],
[
39,
41
],
[
43
],
[
45
],
[
47,
49
],
[
51
],
[
53,
55
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73,
75
],
[
79,
81
],
[
85,
87
],
[
91,
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
117
],
[
119
],
[
121
],
[
125
],
[
127,
129
],
[
131,
133
],
[
135
],
[
137,
139
],
[
141,
143
],
[
145
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
161
],
[
163
],
[
165,
167
],
[
169
],
[
173,
175
],
[
177,
179
],
[
181,
183
],
[
185
],
[
189,
191
],
[
195
],
[
197
],
[
199
],
[
201
],
[
205,
207
],
[
209
],
[
211,
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
247
],
[
249
],
[
251
],
[
253
]
] |
18,974 | int ff_probe_input_buffer(ByteIOContext **pb, AVInputFormat **fmt,
const char *filename, void *logctx,
unsigned int offset, unsigned int max_probe_size)
{
AVProbeData pd = { filename ? filename : "", NULL, -offset };
unsigned char *buf = NULL;
int ret = 0, probe_size;
if (!max_probe_size) {
max_probe_size = PROBE_BUF_MAX;
} else if (max_probe_size > PROBE_BUF_MAX) {
max_probe_size = PROBE_BUF_MAX;
} else if (max_probe_size < PROBE_BUF_MIN) {
return AVERROR(EINVAL);
}
if (offset >= max_probe_size) {
return AVERROR(EINVAL);
}
for(probe_size= PROBE_BUF_MIN; probe_size<=max_probe_size && !*fmt && ret >= 0; probe_size<<=1){
int ret, score = probe_size < max_probe_size ? AVPROBE_SCORE_MAX/4 : 0;
int buf_offset = (probe_size == PROBE_BUF_MIN) ? 0 : probe_size>>1;
if (probe_size < offset) {
continue;
}
/* read probe data */
buf = av_realloc(buf, probe_size + AVPROBE_PADDING_SIZE);
if ((ret = get_buffer(*pb, buf + buf_offset, probe_size - buf_offset)) < 0) {
/* fail if error was not end of file, otherwise, lower score */
if (ret != AVERROR_EOF) {
av_free(buf);
return ret;
}
score = 0;
ret = 0; /* error was end of file, nothing read */
}
pd.buf_size += ret;
pd.buf = &buf[offset];
memset(pd.buf + pd.buf_size, 0, AVPROBE_PADDING_SIZE);
/* guess file format */
*fmt = av_probe_input_format2(&pd, 1, &score);
if(*fmt){
if(score <= AVPROBE_SCORE_MAX/4){ //this can only be true in the last iteration
av_log(logctx, AV_LOG_WARNING, "Format detected only with low score of %d, misdetection possible!\n", score);
}else
av_log(logctx, AV_LOG_DEBUG, "Probed with size=%d and score=%d\n", probe_size, score);
}
}
av_free(buf);
if (url_fseek(*pb, 0, SEEK_SET) < 0) {
url_fclose(*pb);
if (url_fopen(pb, filename, URL_RDONLY) < 0)
return AVERROR(EIO);
}
return 0;
}
| false | FFmpeg | 532aa889ebfea486c0d1898a8ed672e001a30598 | int ff_probe_input_buffer(ByteIOContext **pb, AVInputFormat **fmt,
const char *filename, void *logctx,
unsigned int offset, unsigned int max_probe_size)
{
AVProbeData pd = { filename ? filename : "", NULL, -offset };
unsigned char *buf = NULL;
int ret = 0, probe_size;
if (!max_probe_size) {
max_probe_size = PROBE_BUF_MAX;
} else if (max_probe_size > PROBE_BUF_MAX) {
max_probe_size = PROBE_BUF_MAX;
} else if (max_probe_size < PROBE_BUF_MIN) {
return AVERROR(EINVAL);
}
if (offset >= max_probe_size) {
return AVERROR(EINVAL);
}
for(probe_size= PROBE_BUF_MIN; probe_size<=max_probe_size && !*fmt && ret >= 0; probe_size<<=1){
int ret, score = probe_size < max_probe_size ? AVPROBE_SCORE_MAX/4 : 0;
int buf_offset = (probe_size == PROBE_BUF_MIN) ? 0 : probe_size>>1;
if (probe_size < offset) {
continue;
}
buf = av_realloc(buf, probe_size + AVPROBE_PADDING_SIZE);
if ((ret = get_buffer(*pb, buf + buf_offset, probe_size - buf_offset)) < 0) {
if (ret != AVERROR_EOF) {
av_free(buf);
return ret;
}
score = 0;
ret = 0;
}
pd.buf_size += ret;
pd.buf = &buf[offset];
memset(pd.buf + pd.buf_size, 0, AVPROBE_PADDING_SIZE);
*fmt = av_probe_input_format2(&pd, 1, &score);
if(*fmt){
if(score <= AVPROBE_SCORE_MAX/4){
av_log(logctx, AV_LOG_WARNING, "Format detected only with low score of %d, misdetection possible!\n", score);
}else
av_log(logctx, AV_LOG_DEBUG, "Probed with size=%d and score=%d\n", probe_size, score);
}
}
av_free(buf);
if (url_fseek(*pb, 0, SEEK_SET) < 0) {
url_fclose(*pb);
if (url_fopen(pb, filename, URL_RDONLY) < 0)
return AVERROR(EIO);
}
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(ByteIOContext **VAR_0, AVInputFormat **VAR_1,
const char *VAR_2, void *VAR_3,
unsigned int VAR_4, unsigned int VAR_5)
{
AVProbeData pd = { VAR_2 ? VAR_2 : "", NULL, -VAR_4 };
unsigned char *VAR_6 = NULL;
int VAR_7 = 0, VAR_8;
if (!VAR_5) {
VAR_5 = PROBE_BUF_MAX;
} else if (VAR_5 > PROBE_BUF_MAX) {
VAR_5 = PROBE_BUF_MAX;
} else if (VAR_5 < PROBE_BUF_MIN) {
return AVERROR(EINVAL);
}
if (VAR_4 >= VAR_5) {
return AVERROR(EINVAL);
}
for(VAR_8= PROBE_BUF_MIN; VAR_8<=VAR_5 && !*VAR_1 && VAR_7 >= 0; VAR_8<<=1){
int VAR_7, score = VAR_8 < VAR_5 ? AVPROBE_SCORE_MAX/4 : 0;
int buf_offset = (VAR_8 == PROBE_BUF_MIN) ? 0 : VAR_8>>1;
if (VAR_8 < VAR_4) {
continue;
}
VAR_6 = av_realloc(VAR_6, VAR_8 + AVPROBE_PADDING_SIZE);
if ((VAR_7 = get_buffer(*VAR_0, VAR_6 + buf_offset, VAR_8 - buf_offset)) < 0) {
if (VAR_7 != AVERROR_EOF) {
av_free(VAR_6);
return VAR_7;
}
score = 0;
VAR_7 = 0;
}
pd.buf_size += VAR_7;
pd.VAR_6 = &VAR_6[VAR_4];
memset(pd.VAR_6 + pd.buf_size, 0, AVPROBE_PADDING_SIZE);
*VAR_1 = av_probe_input_format2(&pd, 1, &score);
if(*VAR_1){
if(score <= AVPROBE_SCORE_MAX/4){
av_log(VAR_3, AV_LOG_WARNING, "Format detected only with low score of %d, misdetection possible!\n", score);
}else
av_log(VAR_3, AV_LOG_DEBUG, "Probed with size=%d and score=%d\n", VAR_8, score);
}
}
av_free(VAR_6);
if (url_fseek(*VAR_0, 0, SEEK_SET) < 0) {
url_fclose(*VAR_0);
if (url_fopen(VAR_0, VAR_2, URL_RDONLY) < 0)
return AVERROR(EIO);
}
return 0;
}
| [
"int FUNC_0(ByteIOContext **VAR_0, AVInputFormat **VAR_1,\nconst char *VAR_2, void *VAR_3,\nunsigned int VAR_4, unsigned int VAR_5)\n{",
"AVProbeData pd = { VAR_2 ? VAR_2 : \"\", NULL, -VAR_4 };",
"unsigned char *VAR_6 = NULL;",
"int VAR_7 = 0, VAR_8;",
"if (!VAR_5) {",
"VAR_5 = PROBE_BUF_MAX;",
"} else if (VAR_5 > PROBE_BUF_MAX) {",
"VAR_5 = PROBE_BUF_MAX;",
"} else if (VAR_5 < PROBE_BUF_MIN) {",
"return AVERROR(EINVAL);",
"}",
"if (VAR_4 >= VAR_5) {",
"return AVERROR(EINVAL);",
"}",
"for(VAR_8= PROBE_BUF_MIN; VAR_8<=VAR_5 && !*VAR_1 && VAR_7 >= 0; VAR_8<<=1){",
"int VAR_7, score = VAR_8 < VAR_5 ? AVPROBE_SCORE_MAX/4 : 0;",
"int buf_offset = (VAR_8 == PROBE_BUF_MIN) ? 0 : VAR_8>>1;",
"if (VAR_8 < VAR_4) {",
"continue;",
"}",
"VAR_6 = av_realloc(VAR_6, VAR_8 + AVPROBE_PADDING_SIZE);",
"if ((VAR_7 = get_buffer(*VAR_0, VAR_6 + buf_offset, VAR_8 - buf_offset)) < 0) {",
"if (VAR_7 != AVERROR_EOF) {",
"av_free(VAR_6);",
"return VAR_7;",
"}",
"score = 0;",
"VAR_7 = 0;",
"}",
"pd.buf_size += VAR_7;",
"pd.VAR_6 = &VAR_6[VAR_4];",
"memset(pd.VAR_6 + pd.buf_size, 0, AVPROBE_PADDING_SIZE);",
"*VAR_1 = av_probe_input_format2(&pd, 1, &score);",
"if(*VAR_1){",
"if(score <= AVPROBE_SCORE_MAX/4){",
"av_log(VAR_3, AV_LOG_WARNING, \"Format detected only with low score of %d, misdetection possible!\\n\", score);",
"}else",
"av_log(VAR_3, AV_LOG_DEBUG, \"Probed with size=%d and score=%d\\n\", VAR_8, score);",
"}",
"}",
"av_free(VAR_6);",
"if (url_fseek(*VAR_0, 0, SEEK_SET) < 0) {",
"url_fclose(*VAR_0);",
"if (url_fopen(VAR_0, VAR_2, URL_RDONLY) < 0)\nreturn AVERROR(EIO);",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
85
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
109
],
[
111
],
[
113
],
[
115,
117
],
[
119
],
[
123
],
[
125
]
] |
18,975 | static int metasound_read_bitstream(AVCodecContext *avctx, TwinVQContext *tctx,
const uint8_t *buf, int buf_size)
{
TwinVQFrameData *bits = &tctx->bits;
const TwinVQModeTab *mtab = tctx->mtab;
int channels = tctx->avctx->channels;
int sub;
GetBitContext gb;
int i, j, k;
if (buf_size * 8 < avctx->bit_rate * mtab->size / avctx->sample_rate) {
av_log(avctx, AV_LOG_ERROR,
"Frame too small (%d bytes). Truncated file?\n", buf_size);
return AVERROR(EINVAL);
}
init_get_bits(&gb, buf, buf_size * 8);
bits->window_type = get_bits(&gb, TWINVQ_WINDOW_TYPE_BITS);
if (bits->window_type > 8) {
av_log(avctx, AV_LOG_ERROR, "Invalid window type, broken sample?\n");
return AVERROR_INVALIDDATA;
}
bits->ftype = ff_twinvq_wtype_to_ftype_table[tctx->bits.window_type];
sub = mtab->fmode[bits->ftype].sub;
if (bits->ftype != TWINVQ_FT_SHORT)
get_bits(&gb, 2);
read_cb_data(tctx, &gb, bits->main_coeffs, bits->ftype);
for (i = 0; i < channels; i++)
for (j = 0; j < sub; j++)
for (k = 0; k < mtab->fmode[bits->ftype].bark_n_coef; k++)
bits->bark1[i][j][k] =
get_bits(&gb, mtab->fmode[bits->ftype].bark_n_bit);
for (i = 0; i < channels; i++)
for (j = 0; j < sub; j++)
bits->bark_use_hist[i][j] = get_bits1(&gb);
if (bits->ftype == TWINVQ_FT_LONG) {
for (i = 0; i < channels; i++)
bits->gain_bits[i] = get_bits(&gb, TWINVQ_GAIN_BITS);
} else {
for (i = 0; i < channels; i++) {
bits->gain_bits[i] = get_bits(&gb, TWINVQ_GAIN_BITS);
for (j = 0; j < sub; j++)
bits->sub_gain_bits[i * sub + j] =
get_bits(&gb, TWINVQ_SUB_GAIN_BITS);
}
}
for (i = 0; i < channels; i++) {
bits->lpc_hist_idx[i] = get_bits(&gb, mtab->lsp_bit0);
bits->lpc_idx1[i] = get_bits(&gb, mtab->lsp_bit1);
for (j = 0; j < mtab->lsp_split; j++)
bits->lpc_idx2[i][j] = get_bits(&gb, mtab->lsp_bit2);
}
if (bits->ftype == TWINVQ_FT_LONG) {
read_cb_data(tctx, &gb, bits->ppc_coeffs, 3);
for (i = 0; i < channels; i++) {
bits->p_coef[i] = get_bits(&gb, mtab->ppc_period_bit);
bits->g_coef[i] = get_bits(&gb, mtab->pgain_bit);
}
}
return 0;
}
| false | FFmpeg | 9e7b62f0fb7462a902330fcc82cf596388f0187b | static int metasound_read_bitstream(AVCodecContext *avctx, TwinVQContext *tctx,
const uint8_t *buf, int buf_size)
{
TwinVQFrameData *bits = &tctx->bits;
const TwinVQModeTab *mtab = tctx->mtab;
int channels = tctx->avctx->channels;
int sub;
GetBitContext gb;
int i, j, k;
if (buf_size * 8 < avctx->bit_rate * mtab->size / avctx->sample_rate) {
av_log(avctx, AV_LOG_ERROR,
"Frame too small (%d bytes). Truncated file?\n", buf_size);
return AVERROR(EINVAL);
}
init_get_bits(&gb, buf, buf_size * 8);
bits->window_type = get_bits(&gb, TWINVQ_WINDOW_TYPE_BITS);
if (bits->window_type > 8) {
av_log(avctx, AV_LOG_ERROR, "Invalid window type, broken sample?\n");
return AVERROR_INVALIDDATA;
}
bits->ftype = ff_twinvq_wtype_to_ftype_table[tctx->bits.window_type];
sub = mtab->fmode[bits->ftype].sub;
if (bits->ftype != TWINVQ_FT_SHORT)
get_bits(&gb, 2);
read_cb_data(tctx, &gb, bits->main_coeffs, bits->ftype);
for (i = 0; i < channels; i++)
for (j = 0; j < sub; j++)
for (k = 0; k < mtab->fmode[bits->ftype].bark_n_coef; k++)
bits->bark1[i][j][k] =
get_bits(&gb, mtab->fmode[bits->ftype].bark_n_bit);
for (i = 0; i < channels; i++)
for (j = 0; j < sub; j++)
bits->bark_use_hist[i][j] = get_bits1(&gb);
if (bits->ftype == TWINVQ_FT_LONG) {
for (i = 0; i < channels; i++)
bits->gain_bits[i] = get_bits(&gb, TWINVQ_GAIN_BITS);
} else {
for (i = 0; i < channels; i++) {
bits->gain_bits[i] = get_bits(&gb, TWINVQ_GAIN_BITS);
for (j = 0; j < sub; j++)
bits->sub_gain_bits[i * sub + j] =
get_bits(&gb, TWINVQ_SUB_GAIN_BITS);
}
}
for (i = 0; i < channels; i++) {
bits->lpc_hist_idx[i] = get_bits(&gb, mtab->lsp_bit0);
bits->lpc_idx1[i] = get_bits(&gb, mtab->lsp_bit1);
for (j = 0; j < mtab->lsp_split; j++)
bits->lpc_idx2[i][j] = get_bits(&gb, mtab->lsp_bit2);
}
if (bits->ftype == TWINVQ_FT_LONG) {
read_cb_data(tctx, &gb, bits->ppc_coeffs, 3);
for (i = 0; i < channels; i++) {
bits->p_coef[i] = get_bits(&gb, mtab->ppc_period_bit);
bits->g_coef[i] = get_bits(&gb, mtab->pgain_bit);
}
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, TwinVQContext *VAR_1,
const uint8_t *VAR_2, int VAR_3)
{
TwinVQFrameData *bits = &VAR_1->bits;
const TwinVQModeTab *VAR_4 = VAR_1->VAR_4;
int VAR_5 = VAR_1->VAR_0->VAR_5;
int VAR_6;
GetBitContext gb;
int VAR_7, VAR_8, VAR_9;
if (VAR_3 * 8 < VAR_0->bit_rate * VAR_4->size / VAR_0->sample_rate) {
av_log(VAR_0, AV_LOG_ERROR,
"Frame too small (%d bytes). Truncated file?\n", VAR_3);
return AVERROR(EINVAL);
}
init_get_bits(&gb, VAR_2, VAR_3 * 8);
bits->window_type = get_bits(&gb, TWINVQ_WINDOW_TYPE_BITS);
if (bits->window_type > 8) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid window type, broken sample?\n");
return AVERROR_INVALIDDATA;
}
bits->ftype = ff_twinvq_wtype_to_ftype_table[VAR_1->bits.window_type];
VAR_6 = VAR_4->fmode[bits->ftype].VAR_6;
if (bits->ftype != TWINVQ_FT_SHORT)
get_bits(&gb, 2);
read_cb_data(VAR_1, &gb, bits->main_coeffs, bits->ftype);
for (VAR_7 = 0; VAR_7 < VAR_5; VAR_7++)
for (VAR_8 = 0; VAR_8 < VAR_6; VAR_8++)
for (VAR_9 = 0; VAR_9 < VAR_4->fmode[bits->ftype].bark_n_coef; VAR_9++)
bits->bark1[VAR_7][VAR_8][VAR_9] =
get_bits(&gb, VAR_4->fmode[bits->ftype].bark_n_bit);
for (VAR_7 = 0; VAR_7 < VAR_5; VAR_7++)
for (VAR_8 = 0; VAR_8 < VAR_6; VAR_8++)
bits->bark_use_hist[VAR_7][VAR_8] = get_bits1(&gb);
if (bits->ftype == TWINVQ_FT_LONG) {
for (VAR_7 = 0; VAR_7 < VAR_5; VAR_7++)
bits->gain_bits[VAR_7] = get_bits(&gb, TWINVQ_GAIN_BITS);
} else {
for (VAR_7 = 0; VAR_7 < VAR_5; VAR_7++) {
bits->gain_bits[VAR_7] = get_bits(&gb, TWINVQ_GAIN_BITS);
for (VAR_8 = 0; VAR_8 < VAR_6; VAR_8++)
bits->sub_gain_bits[VAR_7 * VAR_6 + VAR_8] =
get_bits(&gb, TWINVQ_SUB_GAIN_BITS);
}
}
for (VAR_7 = 0; VAR_7 < VAR_5; VAR_7++) {
bits->lpc_hist_idx[VAR_7] = get_bits(&gb, VAR_4->lsp_bit0);
bits->lpc_idx1[VAR_7] = get_bits(&gb, VAR_4->lsp_bit1);
for (VAR_8 = 0; VAR_8 < VAR_4->lsp_split; VAR_8++)
bits->lpc_idx2[VAR_7][VAR_8] = get_bits(&gb, VAR_4->lsp_bit2);
}
if (bits->ftype == TWINVQ_FT_LONG) {
read_cb_data(VAR_1, &gb, bits->ppc_coeffs, 3);
for (VAR_7 = 0; VAR_7 < VAR_5; VAR_7++) {
bits->p_coef[VAR_7] = get_bits(&gb, VAR_4->ppc_period_bit);
bits->g_coef[VAR_7] = get_bits(&gb, VAR_4->pgain_bit);
}
}
return 0;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, TwinVQContext *VAR_1,\nconst uint8_t *VAR_2, int VAR_3)\n{",
"TwinVQFrameData *bits = &VAR_1->bits;",
"const TwinVQModeTab *VAR_4 = VAR_1->VAR_4;",
"int VAR_5 = VAR_1->VAR_0->VAR_5;",
"int VAR_6;",
"GetBitContext gb;",
"int VAR_7, VAR_8, VAR_9;",
"if (VAR_3 * 8 < VAR_0->bit_rate * VAR_4->size / VAR_0->sample_rate) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Frame too small (%d bytes). Truncated file?\\n\", VAR_3);",
"return AVERROR(EINVAL);",
"}",
"init_get_bits(&gb, VAR_2, VAR_3 * 8);",
"bits->window_type = get_bits(&gb, TWINVQ_WINDOW_TYPE_BITS);",
"if (bits->window_type > 8) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid window type, broken sample?\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"bits->ftype = ff_twinvq_wtype_to_ftype_table[VAR_1->bits.window_type];",
"VAR_6 = VAR_4->fmode[bits->ftype].VAR_6;",
"if (bits->ftype != TWINVQ_FT_SHORT)\nget_bits(&gb, 2);",
"read_cb_data(VAR_1, &gb, bits->main_coeffs, bits->ftype);",
"for (VAR_7 = 0; VAR_7 < VAR_5; VAR_7++)",
"for (VAR_8 = 0; VAR_8 < VAR_6; VAR_8++)",
"for (VAR_9 = 0; VAR_9 < VAR_4->fmode[bits->ftype].bark_n_coef; VAR_9++)",
"bits->bark1[VAR_7][VAR_8][VAR_9] =\nget_bits(&gb, VAR_4->fmode[bits->ftype].bark_n_bit);",
"for (VAR_7 = 0; VAR_7 < VAR_5; VAR_7++)",
"for (VAR_8 = 0; VAR_8 < VAR_6; VAR_8++)",
"bits->bark_use_hist[VAR_7][VAR_8] = get_bits1(&gb);",
"if (bits->ftype == TWINVQ_FT_LONG) {",
"for (VAR_7 = 0; VAR_7 < VAR_5; VAR_7++)",
"bits->gain_bits[VAR_7] = get_bits(&gb, TWINVQ_GAIN_BITS);",
"} else {",
"for (VAR_7 = 0; VAR_7 < VAR_5; VAR_7++) {",
"bits->gain_bits[VAR_7] = get_bits(&gb, TWINVQ_GAIN_BITS);",
"for (VAR_8 = 0; VAR_8 < VAR_6; VAR_8++)",
"bits->sub_gain_bits[VAR_7 * VAR_6 + VAR_8] =\nget_bits(&gb, TWINVQ_SUB_GAIN_BITS);",
"}",
"}",
"for (VAR_7 = 0; VAR_7 < VAR_5; VAR_7++) {",
"bits->lpc_hist_idx[VAR_7] = get_bits(&gb, VAR_4->lsp_bit0);",
"bits->lpc_idx1[VAR_7] = get_bits(&gb, VAR_4->lsp_bit1);",
"for (VAR_8 = 0; VAR_8 < VAR_4->lsp_split; VAR_8++)",
"bits->lpc_idx2[VAR_7][VAR_8] = get_bits(&gb, VAR_4->lsp_bit2);",
"}",
"if (bits->ftype == TWINVQ_FT_LONG) {",
"read_cb_data(VAR_1, &gb, bits->ppc_coeffs, 3);",
"for (VAR_7 = 0; VAR_7 < VAR_5; VAR_7++) {",
"bits->p_coef[VAR_7] = get_bits(&gb, VAR_4->ppc_period_bit);",
"bits->g_coef[VAR_7] = get_bits(&gb, VAR_4->pgain_bit);",
"}",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23,
25
],
[
27
],
[
29
],
[
33
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
55
],
[
59,
61
],
[
65
],
[
69
],
[
71
],
[
73
],
[
75,
77
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103,
105
],
[
107
],
[
109
],
[
113
],
[
115
],
[
117
],
[
121
],
[
123
],
[
125
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
145
],
[
147
]
] |
18,976 | static inline void yuv2packedXinC(SwsContext *c, int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,
int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
uint8_t *dest, int dstW, int y)
{
int i;
switch(c->dstFormat)
{
case IMGFMT_RGB32:
case IMGFMT_BGR32:
YSCALE_YUV_2_RGBX_C(uint32_t)
((uint32_t*)dest)[i2+0]= r[Y1] + g[Y1] + b[Y1];
((uint32_t*)dest)[i2+1]= r[Y2] + g[Y2] + b[Y2];
}
break;
case IMGFMT_RGB24:
YSCALE_YUV_2_RGBX_C(uint8_t)
((uint8_t*)dest)[0]= r[Y1];
((uint8_t*)dest)[1]= g[Y1];
((uint8_t*)dest)[2]= b[Y1];
((uint8_t*)dest)[3]= r[Y2];
((uint8_t*)dest)[4]= g[Y2];
((uint8_t*)dest)[5]= b[Y2];
((uint8_t*)dest)+=6;
}
| false | FFmpeg | ae4cffd9fc5bc495692920d646d7d1462315cfa6 | static inline void yuv2packedXinC(SwsContext *c, int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,
int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
uint8_t *dest, int dstW, int y)
{
int i;
switch(c->dstFormat)
{
case IMGFMT_RGB32:
case IMGFMT_BGR32:
YSCALE_YUV_2_RGBX_C(uint32_t)
((uint32_t*)dest)[i2+0]= r[Y1] + g[Y1] + b[Y1];
((uint32_t*)dest)[i2+1]= r[Y2] + g[Y2] + b[Y2];
}
break;
case IMGFMT_RGB24:
YSCALE_YUV_2_RGBX_C(uint8_t)
((uint8_t*)dest)[0]= r[Y1];
((uint8_t*)dest)[1]= g[Y1];
((uint8_t*)dest)[2]= b[Y1];
((uint8_t*)dest)[3]= r[Y2];
((uint8_t*)dest)[4]= g[Y2];
((uint8_t*)dest)[5]= b[Y2];
((uint8_t*)dest)+=6;
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0(SwsContext *VAR_0, int16_t *VAR_1, int16_t **VAR_2, int VAR_3,
int16_t *VAR_4, int16_t **VAR_5, int VAR_6,
uint8_t *VAR_7, int VAR_8, int VAR_9)
{
int VAR_10;
switch(VAR_0->dstFormat)
{
case IMGFMT_RGB32:
case IMGFMT_BGR32:
YSCALE_YUV_2_RGBX_C(uint32_t)
((uint32_t*)VAR_7)[i2+0]= r[Y1] + g[Y1] + b[Y1];
((uint32_t*)VAR_7)[i2+1]= r[Y2] + g[Y2] + b[Y2];
}
break;
case IMGFMT_RGB24:
YSCALE_YUV_2_RGBX_C(uint8_t)
((uint8_t*)VAR_7)[0]= r[Y1];
((uint8_t*)VAR_7)[1]= g[Y1];
((uint8_t*)VAR_7)[2]= b[Y1];
((uint8_t*)VAR_7)[3]= r[Y2];
((uint8_t*)VAR_7)[4]= g[Y2];
((uint8_t*)VAR_7)[5]= b[Y2];
((uint8_t*)VAR_7)+=6;
}
| [
"static inline void FUNC_0(SwsContext *VAR_0, int16_t *VAR_1, int16_t **VAR_2, int VAR_3,\nint16_t *VAR_4, int16_t **VAR_5, int VAR_6,\nuint8_t *VAR_7, int VAR_8, int VAR_9)\n{",
"int VAR_10;",
"switch(VAR_0->dstFormat)\n{",
"case IMGFMT_RGB32:\ncase IMGFMT_BGR32:\nYSCALE_YUV_2_RGBX_C(uint32_t)\n((uint32_t*)VAR_7)[i2+0]= r[Y1] + g[Y1] + b[Y1];",
"((uint32_t*)VAR_7)[i2+1]= r[Y2] + g[Y2] + b[Y2];",
"}",
"break;",
"case IMGFMT_RGB24:\nYSCALE_YUV_2_RGBX_C(uint8_t)\n((uint8_t*)VAR_7)[0]= r[Y1];",
"((uint8_t*)VAR_7)[1]= g[Y1];",
"((uint8_t*)VAR_7)[2]= b[Y1];",
"((uint8_t*)VAR_7)[3]= r[Y2];",
"((uint8_t*)VAR_7)[4]= g[Y2];",
"((uint8_t*)VAR_7)[5]= b[Y2];",
"((uint8_t*)VAR_7)+=6;",
"}"
] | [
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
]
] |
18,977 | static int protocol_client_vencrypt_init(VncState *vs, uint8_t *data, size_t len)
{
if (data[0] != 0 ||
data[1] != 2) {
VNC_DEBUG("Unsupported VeNCrypt protocol %d.%d\n", (int)data[0], (int)data[1]);
vnc_write_u8(vs, 1); /* Reject version */
vnc_flush(vs);
vnc_client_error(vs);
} else {
VNC_DEBUG("Sending allowed auth %d\n", vs->vd->subauth);
vnc_write_u8(vs, 0); /* Accept version */
vnc_write_u8(vs, 1); /* Number of sub-auths */
vnc_write_u32(vs, vs->vd->subauth); /* The supported auth */
vnc_flush(vs);
vnc_read_when(vs, protocol_client_vencrypt_auth, 4);
}
return 0;
}
| false | qemu | 7e7e2ebc942da8285931ceabf12823e165dced8b | static int protocol_client_vencrypt_init(VncState *vs, uint8_t *data, size_t len)
{
if (data[0] != 0 ||
data[1] != 2) {
VNC_DEBUG("Unsupported VeNCrypt protocol %d.%d\n", (int)data[0], (int)data[1]);
vnc_write_u8(vs, 1);
vnc_flush(vs);
vnc_client_error(vs);
} else {
VNC_DEBUG("Sending allowed auth %d\n", vs->vd->subauth);
vnc_write_u8(vs, 0);
vnc_write_u8(vs, 1);
vnc_write_u32(vs, vs->vd->subauth);
vnc_flush(vs);
vnc_read_when(vs, protocol_client_vencrypt_auth, 4);
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(VncState *VAR_0, uint8_t *VAR_1, size_t VAR_2)
{
if (VAR_1[0] != 0 ||
VAR_1[1] != 2) {
VNC_DEBUG("Unsupported VeNCrypt protocol %d.%d\n", (int)VAR_1[0], (int)VAR_1[1]);
vnc_write_u8(VAR_0, 1);
vnc_flush(VAR_0);
vnc_client_error(VAR_0);
} else {
VNC_DEBUG("Sending allowed auth %d\n", VAR_0->vd->subauth);
vnc_write_u8(VAR_0, 0);
vnc_write_u8(VAR_0, 1);
vnc_write_u32(VAR_0, VAR_0->vd->subauth);
vnc_flush(VAR_0);
vnc_read_when(VAR_0, protocol_client_vencrypt_auth, 4);
}
return 0;
}
| [
"static int FUNC_0(VncState *VAR_0, uint8_t *VAR_1, size_t VAR_2)\n{",
"if (VAR_1[0] != 0 ||\nVAR_1[1] != 2) {",
"VNC_DEBUG(\"Unsupported VeNCrypt protocol %d.%d\\n\", (int)VAR_1[0], (int)VAR_1[1]);",
"vnc_write_u8(VAR_0, 1);",
"vnc_flush(VAR_0);",
"vnc_client_error(VAR_0);",
"} else {",
"VNC_DEBUG(\"Sending allowed auth %d\\n\", VAR_0->vd->subauth);",
"vnc_write_u8(VAR_0, 0);",
"vnc_write_u8(VAR_0, 1);",
"vnc_write_u32(VAR_0, VAR_0->vd->subauth);",
"vnc_flush(VAR_0);",
"vnc_read_when(VAR_0, protocol_client_vencrypt_auth, 4);",
"}",
"return 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
]
] |
18,978 | static int qemu_rdma_exchange_send(RDMAContext *rdma, RDMAControlHeader *head,
uint8_t *data, RDMAControlHeader *resp,
int *resp_idx,
int (*callback)(RDMAContext *rdma))
{
int ret = 0;
/*
* Wait until the dest is ready before attempting to deliver the message
* by waiting for a READY message.
*/
if (rdma->control_ready_expected) {
RDMAControlHeader resp;
ret = qemu_rdma_exchange_get_response(rdma,
&resp, RDMA_CONTROL_READY, RDMA_WRID_READY);
if (ret < 0) {
return ret;
}
}
/*
* If the user is expecting a response, post a WR in anticipation of it.
*/
if (resp) {
ret = qemu_rdma_post_recv_control(rdma, RDMA_WRID_DATA);
if (ret) {
error_report("rdma migration: error posting"
" extra control recv for anticipated result!");
return ret;
}
}
/*
* Post a WR to replace the one we just consumed for the READY message.
*/
ret = qemu_rdma_post_recv_control(rdma, RDMA_WRID_READY);
if (ret) {
error_report("rdma migration: error posting first control recv!");
return ret;
}
/*
* Deliver the control message that was requested.
*/
ret = qemu_rdma_post_send_control(rdma, data, head);
if (ret < 0) {
error_report("Failed to send control buffer!");
return ret;
}
/*
* If we're expecting a response, block and wait for it.
*/
if (resp) {
if (callback) {
trace_qemu_rdma_exchange_send_issue_callback();
ret = callback(rdma);
if (ret < 0) {
return ret;
}
}
trace_qemu_rdma_exchange_send_waiting(control_desc[resp->type]);
ret = qemu_rdma_exchange_get_response(rdma, resp,
resp->type, RDMA_WRID_DATA);
if (ret < 0) {
return ret;
}
qemu_rdma_move_header(rdma, RDMA_WRID_DATA, resp);
if (resp_idx) {
*resp_idx = RDMA_WRID_DATA;
}
trace_qemu_rdma_exchange_send_received(control_desc[resp->type]);
}
rdma->control_ready_expected = 1;
return 0;
}
| false | qemu | 482a33c53cbc9d2b0c47d4df03b659bf50258c21 | static int qemu_rdma_exchange_send(RDMAContext *rdma, RDMAControlHeader *head,
uint8_t *data, RDMAControlHeader *resp,
int *resp_idx,
int (*callback)(RDMAContext *rdma))
{
int ret = 0;
if (rdma->control_ready_expected) {
RDMAControlHeader resp;
ret = qemu_rdma_exchange_get_response(rdma,
&resp, RDMA_CONTROL_READY, RDMA_WRID_READY);
if (ret < 0) {
return ret;
}
}
if (resp) {
ret = qemu_rdma_post_recv_control(rdma, RDMA_WRID_DATA);
if (ret) {
error_report("rdma migration: error posting"
" extra control recv for anticipated result!");
return ret;
}
}
ret = qemu_rdma_post_recv_control(rdma, RDMA_WRID_READY);
if (ret) {
error_report("rdma migration: error posting first control recv!");
return ret;
}
ret = qemu_rdma_post_send_control(rdma, data, head);
if (ret < 0) {
error_report("Failed to send control buffer!");
return ret;
}
if (resp) {
if (callback) {
trace_qemu_rdma_exchange_send_issue_callback();
ret = callback(rdma);
if (ret < 0) {
return ret;
}
}
trace_qemu_rdma_exchange_send_waiting(control_desc[resp->type]);
ret = qemu_rdma_exchange_get_response(rdma, resp,
resp->type, RDMA_WRID_DATA);
if (ret < 0) {
return ret;
}
qemu_rdma_move_header(rdma, RDMA_WRID_DATA, resp);
if (resp_idx) {
*resp_idx = RDMA_WRID_DATA;
}
trace_qemu_rdma_exchange_send_received(control_desc[resp->type]);
}
rdma->control_ready_expected = 1;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(RDMAContext *VAR_6, RDMAControlHeader *VAR_1,
uint8_t *VAR_2, RDMAControlHeader *VAR_3,
int *VAR_4,
int (*VAR_5)(RDMAContext *VAR_6))
{
int VAR_6 = 0;
if (VAR_6->control_ready_expected) {
RDMAControlHeader VAR_3;
VAR_6 = qemu_rdma_exchange_get_response(VAR_6,
&VAR_3, RDMA_CONTROL_READY, RDMA_WRID_READY);
if (VAR_6 < 0) {
return VAR_6;
}
}
if (VAR_3) {
VAR_6 = qemu_rdma_post_recv_control(VAR_6, RDMA_WRID_DATA);
if (VAR_6) {
error_report("VAR_6 migration: error posting"
" extra control recv for anticipated result!");
return VAR_6;
}
}
VAR_6 = qemu_rdma_post_recv_control(VAR_6, RDMA_WRID_READY);
if (VAR_6) {
error_report("VAR_6 migration: error posting first control recv!");
return VAR_6;
}
VAR_6 = qemu_rdma_post_send_control(VAR_6, VAR_2, VAR_1);
if (VAR_6 < 0) {
error_report("Failed to send control buffer!");
return VAR_6;
}
if (VAR_3) {
if (VAR_5) {
trace_qemu_rdma_exchange_send_issue_callback();
VAR_6 = VAR_5(VAR_6);
if (VAR_6 < 0) {
return VAR_6;
}
}
trace_qemu_rdma_exchange_send_waiting(control_desc[VAR_3->type]);
VAR_6 = qemu_rdma_exchange_get_response(VAR_6, VAR_3,
VAR_3->type, RDMA_WRID_DATA);
if (VAR_6 < 0) {
return VAR_6;
}
qemu_rdma_move_header(VAR_6, RDMA_WRID_DATA, VAR_3);
if (VAR_4) {
*VAR_4 = RDMA_WRID_DATA;
}
trace_qemu_rdma_exchange_send_received(control_desc[VAR_3->type]);
}
VAR_6->control_ready_expected = 1;
return 0;
}
| [
"static int FUNC_0(RDMAContext *VAR_6, RDMAControlHeader *VAR_1,\nuint8_t *VAR_2, RDMAControlHeader *VAR_3,\nint *VAR_4,\nint (*VAR_5)(RDMAContext *VAR_6))\n{",
"int VAR_6 = 0;",
"if (VAR_6->control_ready_expected) {",
"RDMAControlHeader VAR_3;",
"VAR_6 = qemu_rdma_exchange_get_response(VAR_6,\n&VAR_3, RDMA_CONTROL_READY, RDMA_WRID_READY);",
"if (VAR_6 < 0) {",
"return VAR_6;",
"}",
"}",
"if (VAR_3) {",
"VAR_6 = qemu_rdma_post_recv_control(VAR_6, RDMA_WRID_DATA);",
"if (VAR_6) {",
"error_report(\"VAR_6 migration: error posting\"\n\" extra control recv for anticipated result!\");",
"return VAR_6;",
"}",
"}",
"VAR_6 = qemu_rdma_post_recv_control(VAR_6, RDMA_WRID_READY);",
"if (VAR_6) {",
"error_report(\"VAR_6 migration: error posting first control recv!\");",
"return VAR_6;",
"}",
"VAR_6 = qemu_rdma_post_send_control(VAR_6, VAR_2, VAR_1);",
"if (VAR_6 < 0) {",
"error_report(\"Failed to send control buffer!\");",
"return VAR_6;",
"}",
"if (VAR_3) {",
"if (VAR_5) {",
"trace_qemu_rdma_exchange_send_issue_callback();",
"VAR_6 = VAR_5(VAR_6);",
"if (VAR_6 < 0) {",
"return VAR_6;",
"}",
"}",
"trace_qemu_rdma_exchange_send_waiting(control_desc[VAR_3->type]);",
"VAR_6 = qemu_rdma_exchange_get_response(VAR_6, VAR_3,\nVAR_3->type, RDMA_WRID_DATA);",
"if (VAR_6 < 0) {",
"return VAR_6;",
"}",
"qemu_rdma_move_header(VAR_6, RDMA_WRID_DATA, VAR_3);",
"if (VAR_4) {",
"*VAR_4 = RDMA_WRID_DATA;",
"}",
"trace_qemu_rdma_exchange_send_received(control_desc[VAR_3->type]);",
"}",
"VAR_6->control_ready_expected = 1;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
23
],
[
25
],
[
27,
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
47
],
[
49
],
[
51
],
[
53,
55
],
[
57
],
[
59
],
[
61
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
89
],
[
93
],
[
95
],
[
97
],
[
99
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
127
],
[
129,
131
],
[
135
],
[
137
],
[
139
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
157
],
[
161
],
[
163
]
] |
18,979 | static void isa_ne2000_set_bootindex(Object *obj, Visitor *v,
const char *name, void *opaque,
Error **errp)
{
ISANE2000State *isa = ISA_NE2000(obj);
NE2000State *s = &isa->ne2000;
int32_t boot_index;
Error *local_err = NULL;
visit_type_int32(v, name, &boot_index, &local_err);
if (local_err) {
goto out;
}
/* check whether bootindex is present in fw_boot_order list */
check_boot_index(boot_index, &local_err);
if (local_err) {
goto out;
}
/* change bootindex to a new one */
s->c.bootindex = boot_index;
out:
if (local_err) {
error_propagate(errp, local_err);
}
}
| false | qemu | 621ff94d5074d88253a5818c6b9c4db718fbfc65 | static void isa_ne2000_set_bootindex(Object *obj, Visitor *v,
const char *name, void *opaque,
Error **errp)
{
ISANE2000State *isa = ISA_NE2000(obj);
NE2000State *s = &isa->ne2000;
int32_t boot_index;
Error *local_err = NULL;
visit_type_int32(v, name, &boot_index, &local_err);
if (local_err) {
goto out;
}
check_boot_index(boot_index, &local_err);
if (local_err) {
goto out;
}
s->c.bootindex = boot_index;
out:
if (local_err) {
error_propagate(errp, local_err);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(Object *VAR_0, Visitor *VAR_1,
const char *VAR_2, void *VAR_3,
Error **VAR_4)
{
ISANE2000State *isa = ISA_NE2000(VAR_0);
NE2000State *s = &isa->ne2000;
int32_t boot_index;
Error *local_err = NULL;
visit_type_int32(VAR_1, VAR_2, &boot_index, &local_err);
if (local_err) {
goto out;
}
check_boot_index(boot_index, &local_err);
if (local_err) {
goto out;
}
s->c.bootindex = boot_index;
out:
if (local_err) {
error_propagate(VAR_4, local_err);
}
}
| [
"static void FUNC_0(Object *VAR_0, Visitor *VAR_1,\nconst char *VAR_2, void *VAR_3,\nError **VAR_4)\n{",
"ISANE2000State *isa = ISA_NE2000(VAR_0);",
"NE2000State *s = &isa->ne2000;",
"int32_t boot_index;",
"Error *local_err = NULL;",
"visit_type_int32(VAR_1, VAR_2, &boot_index, &local_err);",
"if (local_err) {",
"goto out;",
"}",
"check_boot_index(boot_index, &local_err);",
"if (local_err) {",
"goto out;",
"}",
"s->c.bootindex = boot_index;",
"out:\nif (local_err) {",
"error_propagate(VAR_4, local_err);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
43,
45
],
[
47
],
[
49
],
[
51
]
] |
18,980 | static void dynticks_rearm_timer(struct qemu_alarm_timer *t)
{
timer_t host_timer = (timer_t)(long)t->priv;
struct itimerspec timeout;
int64_t nearest_delta_us = INT64_MAX;
int64_t current_us;
if (!active_timers[QEMU_TIMER_REALTIME] &&
!active_timers[QEMU_TIMER_VIRTUAL])
return;
nearest_delta_us = qemu_next_deadline_dyntick();
/* check whether a timer is already running */
if (timer_gettime(host_timer, &timeout)) {
perror("gettime");
fprintf(stderr, "Internal timer error: aborting\n");
exit(1);
}
current_us = timeout.it_value.tv_sec * 1000000 + timeout.it_value.tv_nsec/1000;
if (current_us && current_us <= nearest_delta_us)
return;
timeout.it_interval.tv_sec = 0;
timeout.it_interval.tv_nsec = 0; /* 0 for one-shot timer */
timeout.it_value.tv_sec = nearest_delta_us / 1000000;
timeout.it_value.tv_nsec = (nearest_delta_us % 1000000) * 1000;
if (timer_settime(host_timer, 0 /* RELATIVE */, &timeout, NULL)) {
perror("settime");
fprintf(stderr, "Internal timer error: aborting\n");
exit(1);
}
}
| false | qemu | 0fdddf80a88ac2efe068990d1878f472bb6b95d9 | static void dynticks_rearm_timer(struct qemu_alarm_timer *t)
{
timer_t host_timer = (timer_t)(long)t->priv;
struct itimerspec timeout;
int64_t nearest_delta_us = INT64_MAX;
int64_t current_us;
if (!active_timers[QEMU_TIMER_REALTIME] &&
!active_timers[QEMU_TIMER_VIRTUAL])
return;
nearest_delta_us = qemu_next_deadline_dyntick();
if (timer_gettime(host_timer, &timeout)) {
perror("gettime");
fprintf(stderr, "Internal timer error: aborting\n");
exit(1);
}
current_us = timeout.it_value.tv_sec * 1000000 + timeout.it_value.tv_nsec/1000;
if (current_us && current_us <= nearest_delta_us)
return;
timeout.it_interval.tv_sec = 0;
timeout.it_interval.tv_nsec = 0;
timeout.it_value.tv_sec = nearest_delta_us / 1000000;
timeout.it_value.tv_nsec = (nearest_delta_us % 1000000) * 1000;
if (timer_settime(host_timer, 0 , &timeout, NULL)) {
perror("settime");
fprintf(stderr, "Internal timer error: aborting\n");
exit(1);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(struct qemu_alarm_timer *VAR_0)
{
timer_t host_timer = (timer_t)(long)VAR_0->priv;
struct itimerspec VAR_1;
int64_t nearest_delta_us = INT64_MAX;
int64_t current_us;
if (!active_timers[QEMU_TIMER_REALTIME] &&
!active_timers[QEMU_TIMER_VIRTUAL])
return;
nearest_delta_us = qemu_next_deadline_dyntick();
if (timer_gettime(host_timer, &VAR_1)) {
perror("gettime");
fprintf(stderr, "Internal timer error: aborting\n");
exit(1);
}
current_us = VAR_1.it_value.tv_sec * 1000000 + VAR_1.it_value.tv_nsec/1000;
if (current_us && current_us <= nearest_delta_us)
return;
VAR_1.it_interval.tv_sec = 0;
VAR_1.it_interval.tv_nsec = 0;
VAR_1.it_value.tv_sec = nearest_delta_us / 1000000;
VAR_1.it_value.tv_nsec = (nearest_delta_us % 1000000) * 1000;
if (timer_settime(host_timer, 0 , &VAR_1, NULL)) {
perror("settime");
fprintf(stderr, "Internal timer error: aborting\n");
exit(1);
}
}
| [
"static void FUNC_0(struct qemu_alarm_timer *VAR_0)\n{",
"timer_t host_timer = (timer_t)(long)VAR_0->priv;",
"struct itimerspec VAR_1;",
"int64_t nearest_delta_us = INT64_MAX;",
"int64_t current_us;",
"if (!active_timers[QEMU_TIMER_REALTIME] &&\n!active_timers[QEMU_TIMER_VIRTUAL])\nreturn;",
"nearest_delta_us = qemu_next_deadline_dyntick();",
"if (timer_gettime(host_timer, &VAR_1)) {",
"perror(\"gettime\");",
"fprintf(stderr, \"Internal timer error: aborting\\n\");",
"exit(1);",
"}",
"current_us = VAR_1.it_value.tv_sec * 1000000 + VAR_1.it_value.tv_nsec/1000;",
"if (current_us && current_us <= nearest_delta_us)\nreturn;",
"VAR_1.it_interval.tv_sec = 0;",
"VAR_1.it_interval.tv_nsec = 0;",
"VAR_1.it_value.tv_sec = nearest_delta_us / 1000000;",
"VAR_1.it_value.tv_nsec = (nearest_delta_us % 1000000) * 1000;",
"if (timer_settime(host_timer, 0 , &VAR_1, NULL)) {",
"perror(\"settime\");",
"fprintf(stderr, \"Internal timer error: aborting\\n\");",
"exit(1);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15,
17,
19
],
[
23
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41,
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
]
] |
18,981 | static int64_t coroutine_fn bdrv_co_get_block_status_above(BlockDriverState *bs,
BlockDriverState *base,
int64_t sector_num,
int nb_sectors,
int *pnum)
{
BlockDriverState *p;
int64_t ret = 0;
assert(bs != base);
for (p = bs; p != base; p = backing_bs(p)) {
ret = bdrv_co_get_block_status(p, sector_num, nb_sectors, pnum);
if (ret < 0 || ret & BDRV_BLOCK_ALLOCATED) {
break;
}
/* [sector_num, pnum] unallocated on this layer, which could be only
* the first part of [sector_num, nb_sectors]. */
nb_sectors = MIN(nb_sectors, *pnum);
}
return ret;
}
| false | qemu | 67a0fd2a9bca204d2b39f910a97c7137636a0715 | static int64_t coroutine_fn bdrv_co_get_block_status_above(BlockDriverState *bs,
BlockDriverState *base,
int64_t sector_num,
int nb_sectors,
int *pnum)
{
BlockDriverState *p;
int64_t ret = 0;
assert(bs != base);
for (p = bs; p != base; p = backing_bs(p)) {
ret = bdrv_co_get_block_status(p, sector_num, nb_sectors, pnum);
if (ret < 0 || ret & BDRV_BLOCK_ALLOCATED) {
break;
}
nb_sectors = MIN(nb_sectors, *pnum);
}
return ret;
}
| {
"code": [],
"line_no": []
} | static int64_t VAR_0 bdrv_co_get_block_status_above(BlockDriverState *bs,
BlockDriverState *base,
int64_t sector_num,
int nb_sectors,
int *pnum)
{
BlockDriverState *p;
int64_t ret = 0;
assert(bs != base);
for (p = bs; p != base; p = backing_bs(p)) {
ret = bdrv_co_get_block_status(p, sector_num, nb_sectors, pnum);
if (ret < 0 || ret & BDRV_BLOCK_ALLOCATED) {
break;
}
nb_sectors = MIN(nb_sectors, *pnum);
}
return ret;
}
| [
"static int64_t VAR_0 bdrv_co_get_block_status_above(BlockDriverState *bs,\nBlockDriverState *base,\nint64_t sector_num,\nint nb_sectors,\nint *pnum)\n{",
"BlockDriverState *p;",
"int64_t ret = 0;",
"assert(bs != base);",
"for (p = bs; p != base; p = backing_bs(p)) {",
"ret = bdrv_co_get_block_status(p, sector_num, nb_sectors, pnum);",
"if (ret < 0 || ret & BDRV_BLOCK_ALLOCATED) {",
"break;",
"}",
"nb_sectors = MIN(nb_sectors, *pnum);",
"}",
"return ret;",
"}"
] | [
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
],
[
35
],
[
37
],
[
39
],
[
41
]
] |
18,982 | timer_write(void *opaque, hwaddr addr,
uint64_t val64, unsigned int size)
{
struct timerblock *t = opaque;
struct xlx_timer *xt;
unsigned int timer;
uint32_t value = val64;
addr >>= 2;
timer = timer_from_addr(addr);
xt = &t->timers[timer];
D(fprintf(stderr, "%s addr=%x val=%x (timer=%d off=%d)\n",
__func__, addr * 4, value, timer, addr & 3));
/* Further decoding to address a specific timers reg. */
addr &= 3;
switch (addr)
{
case R_TCSR:
if (value & TCSR_TINT)
value &= ~TCSR_TINT;
xt->regs[addr] = value;
if (value & TCSR_ENT)
timer_enable(xt);
break;
default:
if (addr < ARRAY_SIZE(xt->regs))
xt->regs[addr] = value;
break;
}
timer_update_irq(t);
}
| false | qemu | 7dfba6dfbf805cf99c4ae89f6194bc9205dfbefe | timer_write(void *opaque, hwaddr addr,
uint64_t val64, unsigned int size)
{
struct timerblock *t = opaque;
struct xlx_timer *xt;
unsigned int timer;
uint32_t value = val64;
addr >>= 2;
timer = timer_from_addr(addr);
xt = &t->timers[timer];
D(fprintf(stderr, "%s addr=%x val=%x (timer=%d off=%d)\n",
__func__, addr * 4, value, timer, addr & 3));
addr &= 3;
switch (addr)
{
case R_TCSR:
if (value & TCSR_TINT)
value &= ~TCSR_TINT;
xt->regs[addr] = value;
if (value & TCSR_ENT)
timer_enable(xt);
break;
default:
if (addr < ARRAY_SIZE(xt->regs))
xt->regs[addr] = value;
break;
}
timer_update_irq(t);
}
| {
"code": [],
"line_no": []
} | FUNC_0(void *VAR_0, hwaddr VAR_1,
uint64_t VAR_2, unsigned int VAR_3)
{
struct timerblock *VAR_4 = VAR_0;
struct xlx_timer *VAR_5;
unsigned int VAR_6;
uint32_t value = VAR_2;
VAR_1 >>= 2;
VAR_6 = timer_from_addr(VAR_1);
VAR_5 = &VAR_4->timers[VAR_6];
D(fprintf(stderr, "%s VAR_1=%x val=%x (VAR_6=%d off=%d)\n",
__func__, VAR_1 * 4, value, VAR_6, VAR_1 & 3));
VAR_1 &= 3;
switch (VAR_1)
{
case R_TCSR:
if (value & TCSR_TINT)
value &= ~TCSR_TINT;
VAR_5->regs[VAR_1] = value;
if (value & TCSR_ENT)
timer_enable(VAR_5);
break;
default:
if (VAR_1 < ARRAY_SIZE(VAR_5->regs))
VAR_5->regs[VAR_1] = value;
break;
}
timer_update_irq(VAR_4);
}
| [
"FUNC_0(void *VAR_0, hwaddr VAR_1,\nuint64_t VAR_2, unsigned int VAR_3)\n{",
"struct timerblock *VAR_4 = VAR_0;",
"struct xlx_timer *VAR_5;",
"unsigned int VAR_6;",
"uint32_t value = VAR_2;",
"VAR_1 >>= 2;",
"VAR_6 = timer_from_addr(VAR_1);",
"VAR_5 = &VAR_4->timers[VAR_6];",
"D(fprintf(stderr, \"%s VAR_1=%x val=%x (VAR_6=%d off=%d)\\n\",\n__func__, VAR_1 * 4, value, VAR_6, VAR_1 & 3));",
"VAR_1 &= 3;",
"switch (VAR_1)\n{",
"case R_TCSR:\nif (value & TCSR_TINT)\nvalue &= ~TCSR_TINT;",
"VAR_5->regs[VAR_1] = value;",
"if (value & TCSR_ENT)\ntimer_enable(VAR_5);",
"break;",
"default:\nif (VAR_1 < ARRAY_SIZE(VAR_5->regs))\nVAR_5->regs[VAR_1] = value;",
"break;",
"}",
"timer_update_irq(VAR_4);",
"}"
] | [
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,
39
],
[
43
],
[
45,
47
],
[
49
],
[
53,
55,
57
],
[
59
],
[
61
],
[
63
],
[
65
]
] |
18,983 | int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
{
int i, count, ret, read_size, j;
AVStream *st;
AVPacket pkt1, *pkt;
int64_t old_offset = avio_tell(ic->pb);
int orig_nb_streams = ic->nb_streams; // new streams might appear, no options for those
for(i=0;i<ic->nb_streams;i++) {
AVCodec *codec;
AVDictionary *thread_opt = NULL;
st = ic->streams[i];
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO ||
st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
/* if(!st->time_base.num)
st->time_base= */
if(!st->codec->time_base.num)
st->codec->time_base= st->time_base;
}
//only for the split stuff
if (!st->parser && !(ic->flags & AVFMT_FLAG_NOPARSE)) {
st->parser = av_parser_init(st->codec->codec_id);
if(st->need_parsing == AVSTREAM_PARSE_HEADERS && st->parser){
st->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES;
}
}
assert(!st->codec->codec);
codec = avcodec_find_decoder(st->codec->codec_id);
/* force thread count to 1 since the h264 decoder will not extract SPS
* and PPS to extradata during multi-threaded decoding */
av_dict_set(options ? &options[i] : &thread_opt, "threads", "1", 0);
/* Ensure that subtitle_header is properly set. */
if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE
&& codec && !st->codec->codec)
avcodec_open2(st->codec, codec, options ? &options[i]
: &thread_opt);
//try to just open decoders, in case this is enough to get parameters
if(!has_codec_parameters(st->codec)){
if (codec && !st->codec->codec)
avcodec_open2(st->codec, codec, options ? &options[i]
: &thread_opt);
}
if (!options)
av_dict_free(&thread_opt);
}
for (i=0; i<ic->nb_streams; i++) {
ic->streams[i]->info->last_dts = AV_NOPTS_VALUE;
}
count = 0;
read_size = 0;
for(;;) {
if (ff_check_interrupt(&ic->interrupt_callback)){
ret= AVERROR_EXIT;
av_log(ic, AV_LOG_DEBUG, "interrupted\n");
break;
}
/* check if one codec still needs to be handled */
for(i=0;i<ic->nb_streams;i++) {
int fps_analyze_framecount = 20;
st = ic->streams[i];
if (!has_codec_parameters(st->codec))
break;
/* if the timebase is coarse (like the usual millisecond precision
of mkv), we need to analyze more frames to reliably arrive at
the correct fps */
if (av_q2d(st->time_base) > 0.0005)
fps_analyze_framecount *= 2;
if (ic->fps_probe_size >= 0)
fps_analyze_framecount = ic->fps_probe_size;
/* variable fps and no guess at the real fps */
if( tb_unreliable(st->codec) && !(st->r_frame_rate.num && st->avg_frame_rate.num)
&& st->info->duration_count < fps_analyze_framecount
&& st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
break;
if(st->parser && st->parser->parser->split && !st->codec->extradata)
break;
if(st->first_dts == AV_NOPTS_VALUE)
break;
}
if (i == ic->nb_streams) {
/* NOTE: if the format has no header, then we need to read
some packets to get most of the streams, so we cannot
stop here */
if (!(ic->ctx_flags & AVFMTCTX_NOHEADER)) {
/* if we found the info for all the codecs, we can stop */
ret = count;
av_log(ic, AV_LOG_DEBUG, "All info found\n");
break;
}
}
/* we did not get all the codec info, but we read too much data */
if (read_size >= ic->probesize) {
ret = count;
av_log(ic, AV_LOG_DEBUG, "Probe buffer size limit %d reached\n", ic->probesize);
break;
}
/* NOTE: a new stream can be added there if no header in file
(AVFMTCTX_NOHEADER) */
ret = read_frame_internal(ic, &pkt1);
if (ret == AVERROR(EAGAIN))
continue;
if (ret < 0) {
/* EOF or error*/
AVPacket empty_pkt = { 0 };
int err;
av_init_packet(&empty_pkt);
ret = -1; /* we could not have all the codec parameters before EOF */
for(i=0;i<ic->nb_streams;i++) {
st = ic->streams[i];
/* flush the decoders */
do {
err = try_decode_frame(st, &empty_pkt,
(options && i < orig_nb_streams) ?
&options[i] : NULL);
} while (err > 0 && !has_codec_parameters(st->codec));
if (err < 0) {
av_log(ic, AV_LOG_WARNING,
"decoding for stream %d failed\n", st->index);
} else if (!has_codec_parameters(st->codec)){
char buf[256];
avcodec_string(buf, sizeof(buf), st->codec, 0);
av_log(ic, AV_LOG_WARNING,
"Could not find codec parameters (%s)\n", buf);
} else {
ret = 0;
}
}
break;
}
pkt= add_to_pktbuf(&ic->packet_buffer, &pkt1, &ic->packet_buffer_end);
if ((ret = av_dup_packet(pkt)) < 0)
goto find_stream_info_err;
read_size += pkt->size;
st = ic->streams[pkt->stream_index];
if (st->codec_info_nb_frames>1) {
if (st->time_base.den > 0 && av_rescale_q(st->info->codec_info_duration, st->time_base, AV_TIME_BASE_Q) >= ic->max_analyze_duration) {
av_log(ic, AV_LOG_WARNING, "max_analyze_duration reached\n");
break;
}
st->info->codec_info_duration += pkt->duration;
}
{
int64_t last = st->info->last_dts;
if(pkt->dts != AV_NOPTS_VALUE && last != AV_NOPTS_VALUE && pkt->dts > last){
int64_t duration= pkt->dts - last;
double dur= duration * av_q2d(st->time_base);
// if(st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
// av_log(NULL, AV_LOG_ERROR, "%f\n", dur);
if (st->info->duration_count < 2)
memset(st->info->duration_error, 0, sizeof(st->info->duration_error));
for (i=1; i<FF_ARRAY_ELEMS(st->info->duration_error); i++) {
int framerate= get_std_framerate(i);
int ticks= lrintf(dur*framerate/(1001*12));
double error = dur - (double)ticks*1001*12 / framerate;
st->info->duration_error[i] += error*error;
}
st->info->duration_count++;
// ignore the first 4 values, they might have some random jitter
if (st->info->duration_count > 3)
st->info->duration_gcd = av_gcd(st->info->duration_gcd, duration);
}
if (last == AV_NOPTS_VALUE || st->info->duration_count <= 1)
st->info->last_dts = pkt->dts;
}
if(st->parser && st->parser->parser->split && !st->codec->extradata){
int i= st->parser->parser->split(st->codec, pkt->data, pkt->size);
if (i > 0 && i < FF_MAX_EXTRADATA_SIZE) {
st->codec->extradata_size= i;
st->codec->extradata= av_malloc(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
return AVERROR(ENOMEM);
memcpy(st->codec->extradata, pkt->data, st->codec->extradata_size);
memset(st->codec->extradata + i, 0, FF_INPUT_BUFFER_PADDING_SIZE);
}
}
/* if still no information, we try to open the codec and to
decompress the frame. We try to avoid that in most cases as
it takes longer and uses more memory. For MPEG-4, we need to
decompress for QuickTime.
If CODEC_CAP_CHANNEL_CONF is set this will force decoding of at
least one frame of codec data, this makes sure the codec initializes
the channel configuration and does not only trust the values from the container.
*/
try_decode_frame(st, pkt, (options && i < orig_nb_streams ) ? &options[i] : NULL);
st->codec_info_nb_frames++;
count++;
}
// close codecs which were opened in try_decode_frame()
for(i=0;i<ic->nb_streams;i++) {
st = ic->streams[i];
if(st->codec->codec)
avcodec_close(st->codec);
}
for(i=0;i<ic->nb_streams;i++) {
st = ic->streams[i];
if (st->codec_info_nb_frames>2 && !st->avg_frame_rate.num && st->info->codec_info_duration)
av_reduce(&st->avg_frame_rate.num, &st->avg_frame_rate.den,
(st->codec_info_nb_frames-2)*(int64_t)st->time_base.den,
st->info->codec_info_duration*(int64_t)st->time_base.num, 60000);
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
// the check for tb_unreliable() is not completely correct, since this is not about handling
// a unreliable/inexact time base, but a time base that is finer than necessary, as e.g.
// ipmovie.c produces.
if (tb_unreliable(st->codec) && st->info->duration_count > 15 && st->info->duration_gcd > 1 && !st->r_frame_rate.num)
av_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den, st->time_base.den, st->time_base.num * st->info->duration_gcd, INT_MAX);
if (st->info->duration_count && !st->r_frame_rate.num
&& tb_unreliable(st->codec) /*&&
//FIXME we should not special-case MPEG-2, but this needs testing with non-MPEG-2 ...
st->time_base.num*duration_sum[i]/st->info->duration_count*101LL > st->time_base.den*/){
int num = 0;
double best_error= 2*av_q2d(st->time_base);
best_error = best_error*best_error*st->info->duration_count*1000*12*30;
for (j=1; j<FF_ARRAY_ELEMS(st->info->duration_error); j++) {
double error = st->info->duration_error[j] * get_std_framerate(j);
// if(st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
// av_log(NULL, AV_LOG_ERROR, "%f %f\n", get_std_framerate(j) / 12.0/1001, error);
if(error < best_error){
best_error= error;
num = get_std_framerate(j);
}
}
// do not increase frame rate by more than 1 % in order to match a standard rate.
if (num && (!st->r_frame_rate.num || (double)num/(12*1001) < 1.01 * av_q2d(st->r_frame_rate)))
av_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den, num, 12*1001, INT_MAX);
}
if (!st->r_frame_rate.num){
if( st->codec->time_base.den * (int64_t)st->time_base.num
<= st->codec->time_base.num * st->codec->ticks_per_frame * (int64_t)st->time_base.den){
st->r_frame_rate.num = st->codec->time_base.den;
st->r_frame_rate.den = st->codec->time_base.num * st->codec->ticks_per_frame;
}else{
st->r_frame_rate.num = st->time_base.den;
st->r_frame_rate.den = st->time_base.num;
}
}
}else if(st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
if(!st->codec->bits_per_coded_sample)
st->codec->bits_per_coded_sample= av_get_bits_per_sample(st->codec->codec_id);
// set stream disposition based on audio service type
switch (st->codec->audio_service_type) {
case AV_AUDIO_SERVICE_TYPE_EFFECTS:
st->disposition = AV_DISPOSITION_CLEAN_EFFECTS; break;
case AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED:
st->disposition = AV_DISPOSITION_VISUAL_IMPAIRED; break;
case AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED:
st->disposition = AV_DISPOSITION_HEARING_IMPAIRED; break;
case AV_AUDIO_SERVICE_TYPE_COMMENTARY:
st->disposition = AV_DISPOSITION_COMMENT; break;
case AV_AUDIO_SERVICE_TYPE_KARAOKE:
st->disposition = AV_DISPOSITION_KARAOKE; break;
}
}
}
estimate_timings(ic, old_offset);
compute_chapters_end(ic);
#if 0
/* correct DTS for B-frame streams with no timestamps */
for(i=0;i<ic->nb_streams;i++) {
st = ic->streams[i];
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
if(b-frames){
ppktl = &ic->packet_buffer;
while(ppkt1){
if(ppkt1->stream_index != i)
continue;
if(ppkt1->pkt->dts < 0)
break;
if(ppkt1->pkt->pts != AV_NOPTS_VALUE)
break;
ppkt1->pkt->dts -= delta;
ppkt1= ppkt1->next;
}
if(ppkt1)
continue;
st->cur_dts -= delta;
}
}
}
#endif
find_stream_info_err:
for (i=0; i < ic->nb_streams; i++) {
if (ic->streams[i]->codec)
ic->streams[i]->codec->thread_count = 0;
av_freep(&ic->streams[i]->info);
}
return ret;
}
| false | FFmpeg | af08d9aeea870de017139f7b1c44b7d816cf8e56 | int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
{
int i, count, ret, read_size, j;
AVStream *st;
AVPacket pkt1, *pkt;
int64_t old_offset = avio_tell(ic->pb);
int orig_nb_streams = ic->nb_streams;
for(i=0;i<ic->nb_streams;i++) {
AVCodec *codec;
AVDictionary *thread_opt = NULL;
st = ic->streams[i];
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO ||
st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
if(!st->codec->time_base.num)
st->codec->time_base= st->time_base;
}
if (!st->parser && !(ic->flags & AVFMT_FLAG_NOPARSE)) {
st->parser = av_parser_init(st->codec->codec_id);
if(st->need_parsing == AVSTREAM_PARSE_HEADERS && st->parser){
st->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES;
}
}
assert(!st->codec->codec);
codec = avcodec_find_decoder(st->codec->codec_id);
av_dict_set(options ? &options[i] : &thread_opt, "threads", "1", 0);
if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE
&& codec && !st->codec->codec)
avcodec_open2(st->codec, codec, options ? &options[i]
: &thread_opt);
if(!has_codec_parameters(st->codec)){
if (codec && !st->codec->codec)
avcodec_open2(st->codec, codec, options ? &options[i]
: &thread_opt);
}
if (!options)
av_dict_free(&thread_opt);
}
for (i=0; i<ic->nb_streams; i++) {
ic->streams[i]->info->last_dts = AV_NOPTS_VALUE;
}
count = 0;
read_size = 0;
for(;;) {
if (ff_check_interrupt(&ic->interrupt_callback)){
ret= AVERROR_EXIT;
av_log(ic, AV_LOG_DEBUG, "interrupted\n");
break;
}
for(i=0;i<ic->nb_streams;i++) {
int fps_analyze_framecount = 20;
st = ic->streams[i];
if (!has_codec_parameters(st->codec))
break;
if (av_q2d(st->time_base) > 0.0005)
fps_analyze_framecount *= 2;
if (ic->fps_probe_size >= 0)
fps_analyze_framecount = ic->fps_probe_size;
if( tb_unreliable(st->codec) && !(st->r_frame_rate.num && st->avg_frame_rate.num)
&& st->info->duration_count < fps_analyze_framecount
&& st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
break;
if(st->parser && st->parser->parser->split && !st->codec->extradata)
break;
if(st->first_dts == AV_NOPTS_VALUE)
break;
}
if (i == ic->nb_streams) {
if (!(ic->ctx_flags & AVFMTCTX_NOHEADER)) {
ret = count;
av_log(ic, AV_LOG_DEBUG, "All info found\n");
break;
}
}
if (read_size >= ic->probesize) {
ret = count;
av_log(ic, AV_LOG_DEBUG, "Probe buffer size limit %d reached\n", ic->probesize);
break;
}
ret = read_frame_internal(ic, &pkt1);
if (ret == AVERROR(EAGAIN))
continue;
if (ret < 0) {
AVPacket empty_pkt = { 0 };
int err;
av_init_packet(&empty_pkt);
ret = -1;
for(i=0;i<ic->nb_streams;i++) {
st = ic->streams[i];
do {
err = try_decode_frame(st, &empty_pkt,
(options && i < orig_nb_streams) ?
&options[i] : NULL);
} while (err > 0 && !has_codec_parameters(st->codec));
if (err < 0) {
av_log(ic, AV_LOG_WARNING,
"decoding for stream %d failed\n", st->index);
} else if (!has_codec_parameters(st->codec)){
char buf[256];
avcodec_string(buf, sizeof(buf), st->codec, 0);
av_log(ic, AV_LOG_WARNING,
"Could not find codec parameters (%s)\n", buf);
} else {
ret = 0;
}
}
break;
}
pkt= add_to_pktbuf(&ic->packet_buffer, &pkt1, &ic->packet_buffer_end);
if ((ret = av_dup_packet(pkt)) < 0)
goto find_stream_info_err;
read_size += pkt->size;
st = ic->streams[pkt->stream_index];
if (st->codec_info_nb_frames>1) {
if (st->time_base.den > 0 && av_rescale_q(st->info->codec_info_duration, st->time_base, AV_TIME_BASE_Q) >= ic->max_analyze_duration) {
av_log(ic, AV_LOG_WARNING, "max_analyze_duration reached\n");
break;
}
st->info->codec_info_duration += pkt->duration;
}
{
int64_t last = st->info->last_dts;
if(pkt->dts != AV_NOPTS_VALUE && last != AV_NOPTS_VALUE && pkt->dts > last){
int64_t duration= pkt->dts - last;
double dur= duration * av_q2d(st->time_base);
if (st->info->duration_count < 2)
memset(st->info->duration_error, 0, sizeof(st->info->duration_error));
for (i=1; i<FF_ARRAY_ELEMS(st->info->duration_error); i++) {
int framerate= get_std_framerate(i);
int ticks= lrintf(dur*framerate/(1001*12));
double error = dur - (double)ticks*1001*12 / framerate;
st->info->duration_error[i] += error*error;
}
st->info->duration_count++;
if (st->info->duration_count > 3)
st->info->duration_gcd = av_gcd(st->info->duration_gcd, duration);
}
if (last == AV_NOPTS_VALUE || st->info->duration_count <= 1)
st->info->last_dts = pkt->dts;
}
if(st->parser && st->parser->parser->split && !st->codec->extradata){
int i= st->parser->parser->split(st->codec, pkt->data, pkt->size);
if (i > 0 && i < FF_MAX_EXTRADATA_SIZE) {
st->codec->extradata_size= i;
st->codec->extradata= av_malloc(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
return AVERROR(ENOMEM);
memcpy(st->codec->extradata, pkt->data, st->codec->extradata_size);
memset(st->codec->extradata + i, 0, FF_INPUT_BUFFER_PADDING_SIZE);
}
}
try_decode_frame(st, pkt, (options && i < orig_nb_streams ) ? &options[i] : NULL);
st->codec_info_nb_frames++;
count++;
}
for(i=0;i<ic->nb_streams;i++) {
st = ic->streams[i];
if(st->codec->codec)
avcodec_close(st->codec);
}
for(i=0;i<ic->nb_streams;i++) {
st = ic->streams[i];
if (st->codec_info_nb_frames>2 && !st->avg_frame_rate.num && st->info->codec_info_duration)
av_reduce(&st->avg_frame_rate.num, &st->avg_frame_rate.den,
(st->codec_info_nb_frames-2)*(int64_t)st->time_base.den,
st->info->codec_info_duration*(int64_t)st->time_base.num, 60000);
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
if (tb_unreliable(st->codec) && st->info->duration_count > 15 && st->info->duration_gcd > 1 && !st->r_frame_rate.num)
av_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den, st->time_base.den, st->time_base.num * st->info->duration_gcd, INT_MAX);
if (st->info->duration_count && !st->r_frame_rate.num
&& tb_unreliable(st->codec)
){
int num = 0;
double best_error= 2*av_q2d(st->time_base);
best_error = best_error*best_error*st->info->duration_count*1000*12*30;
for (j=1; j<FF_ARRAY_ELEMS(st->info->duration_error); j++) {
double error = st->info->duration_error[j] * get_std_framerate(j);
if(error < best_error){
best_error= error;
num = get_std_framerate(j);
}
}
if (num && (!st->r_frame_rate.num || (double)num/(12*1001) < 1.01 * av_q2d(st->r_frame_rate)))
av_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den, num, 12*1001, INT_MAX);
}
if (!st->r_frame_rate.num){
if( st->codec->time_base.den * (int64_t)st->time_base.num
<= st->codec->time_base.num * st->codec->ticks_per_frame * (int64_t)st->time_base.den){
st->r_frame_rate.num = st->codec->time_base.den;
st->r_frame_rate.den = st->codec->time_base.num * st->codec->ticks_per_frame;
}else{
st->r_frame_rate.num = st->time_base.den;
st->r_frame_rate.den = st->time_base.num;
}
}
}else if(st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
if(!st->codec->bits_per_coded_sample)
st->codec->bits_per_coded_sample= av_get_bits_per_sample(st->codec->codec_id);
switch (st->codec->audio_service_type) {
case AV_AUDIO_SERVICE_TYPE_EFFECTS:
st->disposition = AV_DISPOSITION_CLEAN_EFFECTS; break;
case AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED:
st->disposition = AV_DISPOSITION_VISUAL_IMPAIRED; break;
case AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED:
st->disposition = AV_DISPOSITION_HEARING_IMPAIRED; break;
case AV_AUDIO_SERVICE_TYPE_COMMENTARY:
st->disposition = AV_DISPOSITION_COMMENT; break;
case AV_AUDIO_SERVICE_TYPE_KARAOKE:
st->disposition = AV_DISPOSITION_KARAOKE; break;
}
}
}
estimate_timings(ic, old_offset);
compute_chapters_end(ic);
#if 0
for(i=0;i<ic->nb_streams;i++) {
st = ic->streams[i];
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
if(b-frames){
ppktl = &ic->packet_buffer;
while(ppkt1){
if(ppkt1->stream_index != i)
continue;
if(ppkt1->pkt->dts < 0)
break;
if(ppkt1->pkt->pts != AV_NOPTS_VALUE)
break;
ppkt1->pkt->dts -= delta;
ppkt1= ppkt1->next;
}
if(ppkt1)
continue;
st->cur_dts -= delta;
}
}
}
#endif
find_stream_info_err:
for (i=0; i < ic->nb_streams; i++) {
if (ic->streams[i]->codec)
ic->streams[i]->codec->thread_count = 0;
av_freep(&ic->streams[i]->info);
}
return ret;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(AVFormatContext *VAR_0, AVDictionary **VAR_1)
{
int VAR_10, VAR_3, VAR_4, VAR_5, VAR_6;
AVStream *st;
AVPacket pkt1, *pkt;
int64_t old_offset = avio_tell(VAR_0->pb);
int VAR_7 = VAR_0->nb_streams;
for(VAR_10=0;VAR_10<VAR_0->nb_streams;VAR_10++) {
AVCodec *codec;
AVDictionary *thread_opt = NULL;
st = VAR_0->streams[VAR_10];
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO ||
st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
if(!st->codec->time_base.num)
st->codec->time_base= st->time_base;
}
if (!st->parser && !(VAR_0->flags & AVFMT_FLAG_NOPARSE)) {
st->parser = av_parser_init(st->codec->codec_id);
if(st->need_parsing == AVSTREAM_PARSE_HEADERS && st->parser){
st->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES;
}
}
assert(!st->codec->codec);
codec = avcodec_find_decoder(st->codec->codec_id);
av_dict_set(VAR_1 ? &VAR_1[VAR_10] : &thread_opt, "threads", "1", 0);
if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE
&& codec && !st->codec->codec)
avcodec_open2(st->codec, codec, VAR_1 ? &VAR_1[VAR_10]
: &thread_opt);
if(!has_codec_parameters(st->codec)){
if (codec && !st->codec->codec)
avcodec_open2(st->codec, codec, VAR_1 ? &VAR_1[VAR_10]
: &thread_opt);
}
if (!VAR_1)
av_dict_free(&thread_opt);
}
for (VAR_10=0; VAR_10<VAR_0->nb_streams; VAR_10++) {
VAR_0->streams[VAR_10]->info->last_dts = AV_NOPTS_VALUE;
}
VAR_3 = 0;
VAR_5 = 0;
for(;;) {
if (ff_check_interrupt(&VAR_0->interrupt_callback)){
VAR_4= AVERROR_EXIT;
av_log(VAR_0, AV_LOG_DEBUG, "interrupted\n");
break;
}
for(VAR_10=0;VAR_10<VAR_0->nb_streams;VAR_10++) {
int fps_analyze_framecount = 20;
st = VAR_0->streams[VAR_10];
if (!has_codec_parameters(st->codec))
break;
if (av_q2d(st->time_base) > 0.0005)
fps_analyze_framecount *= 2;
if (VAR_0->fps_probe_size >= 0)
fps_analyze_framecount = VAR_0->fps_probe_size;
if( tb_unreliable(st->codec) && !(st->r_frame_rate.num && st->avg_frame_rate.num)
&& st->info->duration_count < fps_analyze_framecount
&& st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
break;
if(st->parser && st->parser->parser->split && !st->codec->extradata)
break;
if(st->first_dts == AV_NOPTS_VALUE)
break;
}
if (VAR_10 == VAR_0->nb_streams) {
if (!(VAR_0->ctx_flags & AVFMTCTX_NOHEADER)) {
VAR_4 = VAR_3;
av_log(VAR_0, AV_LOG_DEBUG, "All info found\n");
break;
}
}
if (VAR_5 >= VAR_0->probesize) {
VAR_4 = VAR_3;
av_log(VAR_0, AV_LOG_DEBUG, "Probe buffer size limit %d reached\n", VAR_0->probesize);
break;
}
VAR_4 = read_frame_internal(VAR_0, &pkt1);
if (VAR_4 == AVERROR(EAGAIN))
continue;
if (VAR_4 < 0) {
AVPacket empty_pkt = { 0 };
int VAR_8;
av_init_packet(&empty_pkt);
VAR_4 = -1;
for(VAR_10=0;VAR_10<VAR_0->nb_streams;VAR_10++) {
st = VAR_0->streams[VAR_10];
do {
VAR_8 = try_decode_frame(st, &empty_pkt,
(VAR_1 && VAR_10 < VAR_7) ?
&VAR_1[VAR_10] : NULL);
} while (VAR_8 > 0 && !has_codec_parameters(st->codec));
if (VAR_8 < 0) {
av_log(VAR_0, AV_LOG_WARNING,
"decoding for stream %d failed\n", st->index);
} else if (!has_codec_parameters(st->codec)){
char buf[256];
avcodec_string(buf, sizeof(buf), st->codec, 0);
av_log(VAR_0, AV_LOG_WARNING,
"Could not find codec parameters (%s)\n", buf);
} else {
VAR_4 = 0;
}
}
break;
}
pkt= add_to_pktbuf(&VAR_0->packet_buffer, &pkt1, &VAR_0->packet_buffer_end);
if ((VAR_4 = av_dup_packet(pkt)) < 0)
goto find_stream_info_err;
VAR_5 += pkt->size;
st = VAR_0->streams[pkt->stream_index];
if (st->codec_info_nb_frames>1) {
if (st->time_base.den > 0 && av_rescale_q(st->info->codec_info_duration, st->time_base, AV_TIME_BASE_Q) >= VAR_0->max_analyze_duration) {
av_log(VAR_0, AV_LOG_WARNING, "max_analyze_duration reached\n");
break;
}
st->info->codec_info_duration += pkt->duration;
}
{
int64_t last = st->info->last_dts;
if(pkt->dts != AV_NOPTS_VALUE && last != AV_NOPTS_VALUE && pkt->dts > last){
int64_t duration= pkt->dts - last;
double VAR_9= duration * av_q2d(st->time_base);
if (st->info->duration_count < 2)
memset(st->info->duration_error, 0, sizeof(st->info->duration_error));
for (VAR_10=1; VAR_10<FF_ARRAY_ELEMS(st->info->duration_error); VAR_10++) {
int framerate= get_std_framerate(VAR_10);
int ticks= lrintf(VAR_9*framerate/(1001*12));
double error = VAR_9 - (double)ticks*1001*12 / framerate;
st->info->duration_error[VAR_10] += error*error;
}
st->info->duration_count++;
if (st->info->duration_count > 3)
st->info->duration_gcd = av_gcd(st->info->duration_gcd, duration);
}
if (last == AV_NOPTS_VALUE || st->info->duration_count <= 1)
st->info->last_dts = pkt->dts;
}
if(st->parser && st->parser->parser->split && !st->codec->extradata){
int VAR_10= st->parser->parser->split(st->codec, pkt->data, pkt->size);
if (VAR_10 > 0 && VAR_10 < FF_MAX_EXTRADATA_SIZE) {
st->codec->extradata_size= VAR_10;
st->codec->extradata= av_malloc(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
return AVERROR(ENOMEM);
memcpy(st->codec->extradata, pkt->data, st->codec->extradata_size);
memset(st->codec->extradata + VAR_10, 0, FF_INPUT_BUFFER_PADDING_SIZE);
}
}
try_decode_frame(st, pkt, (VAR_1 && VAR_10 < VAR_7 ) ? &VAR_1[VAR_10] : NULL);
st->codec_info_nb_frames++;
VAR_3++;
}
for(VAR_10=0;VAR_10<VAR_0->nb_streams;VAR_10++) {
st = VAR_0->streams[VAR_10];
if(st->codec->codec)
avcodec_close(st->codec);
}
for(VAR_10=0;VAR_10<VAR_0->nb_streams;VAR_10++) {
st = VAR_0->streams[VAR_10];
if (st->codec_info_nb_frames>2 && !st->avg_frame_rate.num && st->info->codec_info_duration)
av_reduce(&st->avg_frame_rate.num, &st->avg_frame_rate.den,
(st->codec_info_nb_frames-2)*(int64_t)st->time_base.den,
st->info->codec_info_duration*(int64_t)st->time_base.num, 60000);
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
if (tb_unreliable(st->codec) && st->info->duration_count > 15 && st->info->duration_gcd > 1 && !st->r_frame_rate.num)
av_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den, st->time_base.den, st->time_base.num * st->info->duration_gcd, INT_MAX);
if (st->info->duration_count && !st->r_frame_rate.num
&& tb_unreliable(st->codec)
){
int num = 0;
double best_error= 2*av_q2d(st->time_base);
best_error = best_error*best_error*st->info->duration_count*1000*12*30;
for (VAR_6=1; VAR_6<FF_ARRAY_ELEMS(st->info->duration_error); VAR_6++) {
double error = st->info->duration_error[VAR_6] * get_std_framerate(VAR_6);
if(error < best_error){
best_error= error;
num = get_std_framerate(VAR_6);
}
}
if (num && (!st->r_frame_rate.num || (double)num/(12*1001) < 1.01 * av_q2d(st->r_frame_rate)))
av_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den, num, 12*1001, INT_MAX);
}
if (!st->r_frame_rate.num){
if( st->codec->time_base.den * (int64_t)st->time_base.num
<= st->codec->time_base.num * st->codec->ticks_per_frame * (int64_t)st->time_base.den){
st->r_frame_rate.num = st->codec->time_base.den;
st->r_frame_rate.den = st->codec->time_base.num * st->codec->ticks_per_frame;
}else{
st->r_frame_rate.num = st->time_base.den;
st->r_frame_rate.den = st->time_base.num;
}
}
}else if(st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
if(!st->codec->bits_per_coded_sample)
st->codec->bits_per_coded_sample= av_get_bits_per_sample(st->codec->codec_id);
switch (st->codec->audio_service_type) {
case AV_AUDIO_SERVICE_TYPE_EFFECTS:
st->disposition = AV_DISPOSITION_CLEAN_EFFECTS; break;
case AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED:
st->disposition = AV_DISPOSITION_VISUAL_IMPAIRED; break;
case AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED:
st->disposition = AV_DISPOSITION_HEARING_IMPAIRED; break;
case AV_AUDIO_SERVICE_TYPE_COMMENTARY:
st->disposition = AV_DISPOSITION_COMMENT; break;
case AV_AUDIO_SERVICE_TYPE_KARAOKE:
st->disposition = AV_DISPOSITION_KARAOKE; break;
}
}
}
estimate_timings(VAR_0, old_offset);
compute_chapters_end(VAR_0);
#if 0
for(VAR_10=0;VAR_10<VAR_0->nb_streams;VAR_10++) {
st = VAR_0->streams[VAR_10];
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
if(b-frames){
ppktl = &VAR_0->packet_buffer;
while(ppkt1){
if(ppkt1->stream_index != VAR_10)
continue;
if(ppkt1->pkt->dts < 0)
break;
if(ppkt1->pkt->pts != AV_NOPTS_VALUE)
break;
ppkt1->pkt->dts -= delta;
ppkt1= ppkt1->next;
}
if(ppkt1)
continue;
st->cur_dts -= delta;
}
}
}
#endif
find_stream_info_err:
for (VAR_10=0; VAR_10 < VAR_0->nb_streams; VAR_10++) {
if (VAR_0->streams[VAR_10]->codec)
VAR_0->streams[VAR_10]->codec->thread_count = 0;
av_freep(&VAR_0->streams[VAR_10]->info);
}
return VAR_4;
}
| [
"int FUNC_0(AVFormatContext *VAR_0, AVDictionary **VAR_1)\n{",
"int VAR_10, VAR_3, VAR_4, VAR_5, VAR_6;",
"AVStream *st;",
"AVPacket pkt1, *pkt;",
"int64_t old_offset = avio_tell(VAR_0->pb);",
"int VAR_7 = VAR_0->nb_streams;",
"for(VAR_10=0;VAR_10<VAR_0->nb_streams;VAR_10++) {",
"AVCodec *codec;",
"AVDictionary *thread_opt = NULL;",
"st = VAR_0->streams[VAR_10];",
"if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO ||\nst->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {",
"if(!st->codec->time_base.num)\nst->codec->time_base= st->time_base;",
"}",
"if (!st->parser && !(VAR_0->flags & AVFMT_FLAG_NOPARSE)) {",
"st->parser = av_parser_init(st->codec->codec_id);",
"if(st->need_parsing == AVSTREAM_PARSE_HEADERS && st->parser){",
"st->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES;",
"}",
"}",
"assert(!st->codec->codec);",
"codec = avcodec_find_decoder(st->codec->codec_id);",
"av_dict_set(VAR_1 ? &VAR_1[VAR_10] : &thread_opt, \"threads\", \"1\", 0);",
"if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE\n&& codec && !st->codec->codec)\navcodec_open2(st->codec, codec, VAR_1 ? &VAR_1[VAR_10]\n: &thread_opt);",
"if(!has_codec_parameters(st->codec)){",
"if (codec && !st->codec->codec)\navcodec_open2(st->codec, codec, VAR_1 ? &VAR_1[VAR_10]\n: &thread_opt);",
"}",
"if (!VAR_1)\nav_dict_free(&thread_opt);",
"}",
"for (VAR_10=0; VAR_10<VAR_0->nb_streams; VAR_10++) {",
"VAR_0->streams[VAR_10]->info->last_dts = AV_NOPTS_VALUE;",
"}",
"VAR_3 = 0;",
"VAR_5 = 0;",
"for(;;) {",
"if (ff_check_interrupt(&VAR_0->interrupt_callback)){",
"VAR_4= AVERROR_EXIT;",
"av_log(VAR_0, AV_LOG_DEBUG, \"interrupted\\n\");",
"break;",
"}",
"for(VAR_10=0;VAR_10<VAR_0->nb_streams;VAR_10++) {",
"int fps_analyze_framecount = 20;",
"st = VAR_0->streams[VAR_10];",
"if (!has_codec_parameters(st->codec))\nbreak;",
"if (av_q2d(st->time_base) > 0.0005)\nfps_analyze_framecount *= 2;",
"if (VAR_0->fps_probe_size >= 0)\nfps_analyze_framecount = VAR_0->fps_probe_size;",
"if( tb_unreliable(st->codec) && !(st->r_frame_rate.num && st->avg_frame_rate.num)\n&& st->info->duration_count < fps_analyze_framecount\n&& st->codec->codec_type == AVMEDIA_TYPE_VIDEO)\nbreak;",
"if(st->parser && st->parser->parser->split && !st->codec->extradata)\nbreak;",
"if(st->first_dts == AV_NOPTS_VALUE)\nbreak;",
"}",
"if (VAR_10 == VAR_0->nb_streams) {",
"if (!(VAR_0->ctx_flags & AVFMTCTX_NOHEADER)) {",
"VAR_4 = VAR_3;",
"av_log(VAR_0, AV_LOG_DEBUG, \"All info found\\n\");",
"break;",
"}",
"}",
"if (VAR_5 >= VAR_0->probesize) {",
"VAR_4 = VAR_3;",
"av_log(VAR_0, AV_LOG_DEBUG, \"Probe buffer size limit %d reached\\n\", VAR_0->probesize);",
"break;",
"}",
"VAR_4 = read_frame_internal(VAR_0, &pkt1);",
"if (VAR_4 == AVERROR(EAGAIN))\ncontinue;",
"if (VAR_4 < 0) {",
"AVPacket empty_pkt = { 0 };",
"int VAR_8;",
"av_init_packet(&empty_pkt);",
"VAR_4 = -1;",
"for(VAR_10=0;VAR_10<VAR_0->nb_streams;VAR_10++) {",
"st = VAR_0->streams[VAR_10];",
"do {",
"VAR_8 = try_decode_frame(st, &empty_pkt,\n(VAR_1 && VAR_10 < VAR_7) ?\n&VAR_1[VAR_10] : NULL);",
"} while (VAR_8 > 0 && !has_codec_parameters(st->codec));",
"if (VAR_8 < 0) {",
"av_log(VAR_0, AV_LOG_WARNING,\n\"decoding for stream %d failed\\n\", st->index);",
"} else if (!has_codec_parameters(st->codec)){",
"char buf[256];",
"avcodec_string(buf, sizeof(buf), st->codec, 0);",
"av_log(VAR_0, AV_LOG_WARNING,\n\"Could not find codec parameters (%s)\\n\", buf);",
"} else {",
"VAR_4 = 0;",
"}",
"}",
"break;",
"}",
"pkt= add_to_pktbuf(&VAR_0->packet_buffer, &pkt1, &VAR_0->packet_buffer_end);",
"if ((VAR_4 = av_dup_packet(pkt)) < 0)\ngoto find_stream_info_err;",
"VAR_5 += pkt->size;",
"st = VAR_0->streams[pkt->stream_index];",
"if (st->codec_info_nb_frames>1) {",
"if (st->time_base.den > 0 && av_rescale_q(st->info->codec_info_duration, st->time_base, AV_TIME_BASE_Q) >= VAR_0->max_analyze_duration) {",
"av_log(VAR_0, AV_LOG_WARNING, \"max_analyze_duration reached\\n\");",
"break;",
"}",
"st->info->codec_info_duration += pkt->duration;",
"}",
"{",
"int64_t last = st->info->last_dts;",
"if(pkt->dts != AV_NOPTS_VALUE && last != AV_NOPTS_VALUE && pkt->dts > last){",
"int64_t duration= pkt->dts - last;",
"double VAR_9= duration * av_q2d(st->time_base);",
"if (st->info->duration_count < 2)\nmemset(st->info->duration_error, 0, sizeof(st->info->duration_error));",
"for (VAR_10=1; VAR_10<FF_ARRAY_ELEMS(st->info->duration_error); VAR_10++) {",
"int framerate= get_std_framerate(VAR_10);",
"int ticks= lrintf(VAR_9*framerate/(1001*12));",
"double error = VAR_9 - (double)ticks*1001*12 / framerate;",
"st->info->duration_error[VAR_10] += error*error;",
"}",
"st->info->duration_count++;",
"if (st->info->duration_count > 3)\nst->info->duration_gcd = av_gcd(st->info->duration_gcd, duration);",
"}",
"if (last == AV_NOPTS_VALUE || st->info->duration_count <= 1)\nst->info->last_dts = pkt->dts;",
"}",
"if(st->parser && st->parser->parser->split && !st->codec->extradata){",
"int VAR_10= st->parser->parser->split(st->codec, pkt->data, pkt->size);",
"if (VAR_10 > 0 && VAR_10 < FF_MAX_EXTRADATA_SIZE) {",
"st->codec->extradata_size= VAR_10;",
"st->codec->extradata= av_malloc(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);",
"if (!st->codec->extradata)\nreturn AVERROR(ENOMEM);",
"memcpy(st->codec->extradata, pkt->data, st->codec->extradata_size);",
"memset(st->codec->extradata + VAR_10, 0, FF_INPUT_BUFFER_PADDING_SIZE);",
"}",
"}",
"try_decode_frame(st, pkt, (VAR_1 && VAR_10 < VAR_7 ) ? &VAR_1[VAR_10] : NULL);",
"st->codec_info_nb_frames++;",
"VAR_3++;",
"}",
"for(VAR_10=0;VAR_10<VAR_0->nb_streams;VAR_10++) {",
"st = VAR_0->streams[VAR_10];",
"if(st->codec->codec)\navcodec_close(st->codec);",
"}",
"for(VAR_10=0;VAR_10<VAR_0->nb_streams;VAR_10++) {",
"st = VAR_0->streams[VAR_10];",
"if (st->codec_info_nb_frames>2 && !st->avg_frame_rate.num && st->info->codec_info_duration)\nav_reduce(&st->avg_frame_rate.num, &st->avg_frame_rate.den,\n(st->codec_info_nb_frames-2)*(int64_t)st->time_base.den,\nst->info->codec_info_duration*(int64_t)st->time_base.num, 60000);",
"if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {",
"if (tb_unreliable(st->codec) && st->info->duration_count > 15 && st->info->duration_gcd > 1 && !st->r_frame_rate.num)\nav_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den, st->time_base.den, st->time_base.num * st->info->duration_gcd, INT_MAX);",
"if (st->info->duration_count && !st->r_frame_rate.num\n&& tb_unreliable(st->codec)\n){",
"int num = 0;",
"double best_error= 2*av_q2d(st->time_base);",
"best_error = best_error*best_error*st->info->duration_count*1000*12*30;",
"for (VAR_6=1; VAR_6<FF_ARRAY_ELEMS(st->info->duration_error); VAR_6++) {",
"double error = st->info->duration_error[VAR_6] * get_std_framerate(VAR_6);",
"if(error < best_error){",
"best_error= error;",
"num = get_std_framerate(VAR_6);",
"}",
"}",
"if (num && (!st->r_frame_rate.num || (double)num/(12*1001) < 1.01 * av_q2d(st->r_frame_rate)))\nav_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den, num, 12*1001, INT_MAX);",
"}",
"if (!st->r_frame_rate.num){",
"if( st->codec->time_base.den * (int64_t)st->time_base.num\n<= st->codec->time_base.num * st->codec->ticks_per_frame * (int64_t)st->time_base.den){",
"st->r_frame_rate.num = st->codec->time_base.den;",
"st->r_frame_rate.den = st->codec->time_base.num * st->codec->ticks_per_frame;",
"}else{",
"st->r_frame_rate.num = st->time_base.den;",
"st->r_frame_rate.den = st->time_base.num;",
"}",
"}",
"}else if(st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {",
"if(!st->codec->bits_per_coded_sample)\nst->codec->bits_per_coded_sample= av_get_bits_per_sample(st->codec->codec_id);",
"switch (st->codec->audio_service_type) {",
"case AV_AUDIO_SERVICE_TYPE_EFFECTS:\nst->disposition = AV_DISPOSITION_CLEAN_EFFECTS; break;",
"case AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED:\nst->disposition = AV_DISPOSITION_VISUAL_IMPAIRED; break;",
"case AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED:\nst->disposition = AV_DISPOSITION_HEARING_IMPAIRED; break;",
"case AV_AUDIO_SERVICE_TYPE_COMMENTARY:\nst->disposition = AV_DISPOSITION_COMMENT; break;",
"case AV_AUDIO_SERVICE_TYPE_KARAOKE:\nst->disposition = AV_DISPOSITION_KARAOKE; break;",
"}",
"}",
"}",
"estimate_timings(VAR_0, old_offset);",
"compute_chapters_end(VAR_0);",
"#if 0\nfor(VAR_10=0;VAR_10<VAR_0->nb_streams;VAR_10++) {",
"st = VAR_0->streams[VAR_10];",
"if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {",
"if(b-frames){",
"ppktl = &VAR_0->packet_buffer;",
"while(ppkt1){",
"if(ppkt1->stream_index != VAR_10)\ncontinue;",
"if(ppkt1->pkt->dts < 0)\nbreak;",
"if(ppkt1->pkt->pts != AV_NOPTS_VALUE)\nbreak;",
"ppkt1->pkt->dts -= delta;",
"ppkt1= ppkt1->next;",
"}",
"if(ppkt1)\ncontinue;",
"st->cur_dts -= delta;",
"}",
"}",
"}",
"#endif\nfind_stream_info_err:\nfor (VAR_10=0; VAR_10 < VAR_0->nb_streams; VAR_10++) {",
"if (VAR_0->streams[VAR_10]->codec)\nVAR_0->streams[VAR_10]->codec->thread_count = 0;",
"av_freep(&VAR_0->streams[VAR_10]->info);",
"}",
"return VAR_4;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27,
29
],
[
35,
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
65
],
[
71,
73,
75,
77
],
[
83
],
[
85,
87,
89
],
[
91
],
[
93,
95
],
[
97
],
[
101
],
[
103
],
[
105
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
129
],
[
131
],
[
135
],
[
137,
139
],
[
147,
149
],
[
151,
153
],
[
157,
159,
161,
163
],
[
165,
167
],
[
169,
171
],
[
173
],
[
175
],
[
183
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
215
],
[
217,
219
],
[
223
],
[
227
],
[
229
],
[
231
],
[
235
],
[
237
],
[
239
],
[
245
],
[
247,
249,
251
],
[
253
],
[
257
],
[
259,
261
],
[
263
],
[
265
],
[
267
],
[
269,
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
287
],
[
289,
291
],
[
295
],
[
299
],
[
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
311
],
[
313
],
[
315
],
[
317
],
[
321
],
[
323
],
[
325
],
[
333,
335
],
[
337
],
[
339
],
[
341
],
[
343
],
[
345
],
[
347
],
[
349
],
[
353,
355
],
[
357
],
[
359,
361
],
[
363
],
[
365
],
[
367
],
[
369
],
[
371
],
[
373
],
[
375,
377
],
[
379
],
[
381
],
[
383
],
[
385
],
[
407
],
[
411
],
[
413
],
[
415
],
[
421
],
[
423
],
[
425,
427
],
[
429
],
[
431
],
[
433
],
[
435,
437,
439,
441
],
[
443
],
[
451,
453
],
[
455,
457,
461
],
[
463
],
[
465
],
[
467
],
[
471
],
[
473
],
[
479
],
[
481
],
[
483
],
[
485
],
[
487
],
[
491,
493
],
[
495
],
[
499
],
[
501,
503
],
[
505
],
[
507
],
[
509
],
[
511
],
[
513
],
[
515
],
[
517
],
[
519
],
[
521,
523
],
[
527
],
[
529,
531
],
[
533,
535
],
[
537,
539
],
[
541,
543
],
[
545,
547
],
[
549
],
[
551
],
[
553
],
[
557
],
[
561
],
[
565,
569
],
[
571
],
[
573
],
[
575
],
[
577
],
[
579
],
[
581,
583
],
[
585,
587
],
[
589,
591
],
[
593
],
[
595
],
[
597
],
[
599,
601
],
[
603
],
[
605
],
[
607
],
[
609
],
[
611,
615,
617
],
[
619,
621
],
[
623
],
[
625
],
[
627
],
[
629
]
] |
18,984 | static void dcr_write_sdram (void *opaque, int dcrn, uint32_t val)
{
ppc4xx_sdram_t *sdram;
sdram = opaque;
switch (dcrn) {
case SDRAM0_CFGADDR:
sdram->addr = val;
break;
case SDRAM0_CFGDATA:
switch (sdram->addr) {
case 0x00: /* SDRAM_BESR0 */
sdram->besr0 &= ~val;
break;
case 0x08: /* SDRAM_BESR1 */
sdram->besr1 &= ~val;
break;
case 0x10: /* SDRAM_BEAR */
sdram->bear = val;
break;
case 0x20: /* SDRAM_CFG */
val &= 0xFFE00000;
if (!(sdram->cfg & 0x80000000) && (val & 0x80000000)) {
#ifdef DEBUG_SDRAM
printf("%s: enable SDRAM controller\n", __func__);
#endif
/* validate all RAM mappings */
sdram_map_bcr(sdram);
sdram->status &= ~0x80000000;
} else if ((sdram->cfg & 0x80000000) && !(val & 0x80000000)) {
#ifdef DEBUG_SDRAM
printf("%s: disable SDRAM controller\n", __func__);
#endif
/* invalidate all RAM mappings */
sdram_unmap_bcr(sdram);
sdram->status |= 0x80000000;
}
if (!(sdram->cfg & 0x40000000) && (val & 0x40000000))
sdram->status |= 0x40000000;
else if ((sdram->cfg & 0x40000000) && !(val & 0x40000000))
sdram->status &= ~0x40000000;
sdram->cfg = val;
break;
case 0x24: /* SDRAM_STATUS */
/* Read-only register */
break;
case 0x30: /* SDRAM_RTR */
sdram->rtr = val & 0x3FF80000;
break;
case 0x34: /* SDRAM_PMIT */
sdram->pmit = (val & 0xF8000000) | 0x07C00000;
break;
case 0x40: /* SDRAM_B0CR */
sdram_set_bcr(&sdram->bcr[0], val, sdram->cfg & 0x80000000);
break;
case 0x44: /* SDRAM_B1CR */
sdram_set_bcr(&sdram->bcr[1], val, sdram->cfg & 0x80000000);
break;
case 0x48: /* SDRAM_B2CR */
sdram_set_bcr(&sdram->bcr[2], val, sdram->cfg & 0x80000000);
break;
case 0x4C: /* SDRAM_B3CR */
sdram_set_bcr(&sdram->bcr[3], val, sdram->cfg & 0x80000000);
break;
case 0x80: /* SDRAM_TR */
sdram->tr = val & 0x018FC01F;
break;
case 0x94: /* SDRAM_ECCCFG */
sdram->ecccfg = val & 0x00F00000;
break;
case 0x98: /* SDRAM_ECCESR */
val &= 0xFFF0F000;
if (sdram->eccesr == 0 && val != 0)
qemu_irq_raise(sdram->irq);
else if (sdram->eccesr != 0 && val == 0)
qemu_irq_lower(sdram->irq);
sdram->eccesr = val;
break;
default: /* Error */
break;
}
break;
}
}
| false | qemu | b6dcbe086c77ec683f5ff0b693593cda1d61f3a1 | static void dcr_write_sdram (void *opaque, int dcrn, uint32_t val)
{
ppc4xx_sdram_t *sdram;
sdram = opaque;
switch (dcrn) {
case SDRAM0_CFGADDR:
sdram->addr = val;
break;
case SDRAM0_CFGDATA:
switch (sdram->addr) {
case 0x00:
sdram->besr0 &= ~val;
break;
case 0x08:
sdram->besr1 &= ~val;
break;
case 0x10:
sdram->bear = val;
break;
case 0x20:
val &= 0xFFE00000;
if (!(sdram->cfg & 0x80000000) && (val & 0x80000000)) {
#ifdef DEBUG_SDRAM
printf("%s: enable SDRAM controller\n", __func__);
#endif
sdram_map_bcr(sdram);
sdram->status &= ~0x80000000;
} else if ((sdram->cfg & 0x80000000) && !(val & 0x80000000)) {
#ifdef DEBUG_SDRAM
printf("%s: disable SDRAM controller\n", __func__);
#endif
sdram_unmap_bcr(sdram);
sdram->status |= 0x80000000;
}
if (!(sdram->cfg & 0x40000000) && (val & 0x40000000))
sdram->status |= 0x40000000;
else if ((sdram->cfg & 0x40000000) && !(val & 0x40000000))
sdram->status &= ~0x40000000;
sdram->cfg = val;
break;
case 0x24:
break;
case 0x30:
sdram->rtr = val & 0x3FF80000;
break;
case 0x34:
sdram->pmit = (val & 0xF8000000) | 0x07C00000;
break;
case 0x40:
sdram_set_bcr(&sdram->bcr[0], val, sdram->cfg & 0x80000000);
break;
case 0x44:
sdram_set_bcr(&sdram->bcr[1], val, sdram->cfg & 0x80000000);
break;
case 0x48:
sdram_set_bcr(&sdram->bcr[2], val, sdram->cfg & 0x80000000);
break;
case 0x4C:
sdram_set_bcr(&sdram->bcr[3], val, sdram->cfg & 0x80000000);
break;
case 0x80:
sdram->tr = val & 0x018FC01F;
break;
case 0x94:
sdram->ecccfg = val & 0x00F00000;
break;
case 0x98:
val &= 0xFFF0F000;
if (sdram->eccesr == 0 && val != 0)
qemu_irq_raise(sdram->irq);
else if (sdram->eccesr != 0 && val == 0)
qemu_irq_lower(sdram->irq);
sdram->eccesr = val;
break;
default:
break;
}
break;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0 (void *VAR_0, int VAR_1, uint32_t VAR_2)
{
ppc4xx_sdram_t *sdram;
sdram = VAR_0;
switch (VAR_1) {
case SDRAM0_CFGADDR:
sdram->addr = VAR_2;
break;
case SDRAM0_CFGDATA:
switch (sdram->addr) {
case 0x00:
sdram->besr0 &= ~VAR_2;
break;
case 0x08:
sdram->besr1 &= ~VAR_2;
break;
case 0x10:
sdram->bear = VAR_2;
break;
case 0x20:
VAR_2 &= 0xFFE00000;
if (!(sdram->cfg & 0x80000000) && (VAR_2 & 0x80000000)) {
#ifdef DEBUG_SDRAM
printf("%s: enable SDRAM controller\n", __func__);
#endif
sdram_map_bcr(sdram);
sdram->status &= ~0x80000000;
} else if ((sdram->cfg & 0x80000000) && !(VAR_2 & 0x80000000)) {
#ifdef DEBUG_SDRAM
printf("%s: disable SDRAM controller\n", __func__);
#endif
sdram_unmap_bcr(sdram);
sdram->status |= 0x80000000;
}
if (!(sdram->cfg & 0x40000000) && (VAR_2 & 0x40000000))
sdram->status |= 0x40000000;
else if ((sdram->cfg & 0x40000000) && !(VAR_2 & 0x40000000))
sdram->status &= ~0x40000000;
sdram->cfg = VAR_2;
break;
case 0x24:
break;
case 0x30:
sdram->rtr = VAR_2 & 0x3FF80000;
break;
case 0x34:
sdram->pmit = (VAR_2 & 0xF8000000) | 0x07C00000;
break;
case 0x40:
sdram_set_bcr(&sdram->bcr[0], VAR_2, sdram->cfg & 0x80000000);
break;
case 0x44:
sdram_set_bcr(&sdram->bcr[1], VAR_2, sdram->cfg & 0x80000000);
break;
case 0x48:
sdram_set_bcr(&sdram->bcr[2], VAR_2, sdram->cfg & 0x80000000);
break;
case 0x4C:
sdram_set_bcr(&sdram->bcr[3], VAR_2, sdram->cfg & 0x80000000);
break;
case 0x80:
sdram->tr = VAR_2 & 0x018FC01F;
break;
case 0x94:
sdram->ecccfg = VAR_2 & 0x00F00000;
break;
case 0x98:
VAR_2 &= 0xFFF0F000;
if (sdram->eccesr == 0 && VAR_2 != 0)
qemu_irq_raise(sdram->irq);
else if (sdram->eccesr != 0 && VAR_2 == 0)
qemu_irq_lower(sdram->irq);
sdram->eccesr = VAR_2;
break;
default:
break;
}
break;
}
}
| [
"static void FUNC_0 (void *VAR_0, int VAR_1, uint32_t VAR_2)\n{",
"ppc4xx_sdram_t *sdram;",
"sdram = VAR_0;",
"switch (VAR_1) {",
"case SDRAM0_CFGADDR:\nsdram->addr = VAR_2;",
"break;",
"case SDRAM0_CFGDATA:\nswitch (sdram->addr) {",
"case 0x00:\nsdram->besr0 &= ~VAR_2;",
"break;",
"case 0x08:\nsdram->besr1 &= ~VAR_2;",
"break;",
"case 0x10:\nsdram->bear = VAR_2;",
"break;",
"case 0x20:\nVAR_2 &= 0xFFE00000;",
"if (!(sdram->cfg & 0x80000000) && (VAR_2 & 0x80000000)) {",
"#ifdef DEBUG_SDRAM\nprintf(\"%s: enable SDRAM controller\\n\", __func__);",
"#endif\nsdram_map_bcr(sdram);",
"sdram->status &= ~0x80000000;",
"} else if ((sdram->cfg & 0x80000000) && !(VAR_2 & 0x80000000)) {",
"#ifdef DEBUG_SDRAM\nprintf(\"%s: disable SDRAM controller\\n\", __func__);",
"#endif\nsdram_unmap_bcr(sdram);",
"sdram->status |= 0x80000000;",
"}",
"if (!(sdram->cfg & 0x40000000) && (VAR_2 & 0x40000000))\nsdram->status |= 0x40000000;",
"else if ((sdram->cfg & 0x40000000) && !(VAR_2 & 0x40000000))\nsdram->status &= ~0x40000000;",
"sdram->cfg = VAR_2;",
"break;",
"case 0x24:\nbreak;",
"case 0x30:\nsdram->rtr = VAR_2 & 0x3FF80000;",
"break;",
"case 0x34:\nsdram->pmit = (VAR_2 & 0xF8000000) | 0x07C00000;",
"break;",
"case 0x40:\nsdram_set_bcr(&sdram->bcr[0], VAR_2, sdram->cfg & 0x80000000);",
"break;",
"case 0x44:\nsdram_set_bcr(&sdram->bcr[1], VAR_2, sdram->cfg & 0x80000000);",
"break;",
"case 0x48:\nsdram_set_bcr(&sdram->bcr[2], VAR_2, sdram->cfg & 0x80000000);",
"break;",
"case 0x4C:\nsdram_set_bcr(&sdram->bcr[3], VAR_2, sdram->cfg & 0x80000000);",
"break;",
"case 0x80:\nsdram->tr = VAR_2 & 0x018FC01F;",
"break;",
"case 0x94:\nsdram->ecccfg = VAR_2 & 0x00F00000;",
"break;",
"case 0x98:\nVAR_2 &= 0xFFF0F000;",
"if (sdram->eccesr == 0 && VAR_2 != 0)\nqemu_irq_raise(sdram->irq);",
"else if (sdram->eccesr != 0 && VAR_2 == 0)\nqemu_irq_lower(sdram->irq);",
"sdram->eccesr = VAR_2;",
"break;",
"default:\nbreak;",
"}",
"break;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
69
],
[
71
],
[
73
],
[
75,
77
],
[
79,
81
],
[
83
],
[
85
],
[
87,
91
],
[
93,
95
],
[
97
],
[
99,
101
],
[
103
],
[
105,
107
],
[
109
],
[
111,
113
],
[
115
],
[
117,
119
],
[
121
],
[
123,
125
],
[
127
],
[
129,
131
],
[
133
],
[
135,
137
],
[
139
],
[
141,
143
],
[
145,
147
],
[
149,
151
],
[
153
],
[
155
],
[
157,
159
],
[
161
],
[
163
],
[
165
],
[
167
]
] |
18,985 | void object_property_add_alias(Object *obj, const char *name,
Object *target_obj, const char *target_name,
Error **errp)
{
AliasProperty *prop;
ObjectProperty *target_prop;
target_prop = object_property_find(target_obj, target_name, errp);
if (!target_prop) {
return;
}
prop = g_malloc(sizeof(*prop));
prop->target_obj = target_obj;
prop->target_name = target_name;
object_property_add(obj, name, target_prop->type,
property_get_alias,
property_set_alias,
property_release_alias,
prop, errp);
}
| false | qemu | 64607d088132abdb25bf30d93e97d0c8df7b364c | void object_property_add_alias(Object *obj, const char *name,
Object *target_obj, const char *target_name,
Error **errp)
{
AliasProperty *prop;
ObjectProperty *target_prop;
target_prop = object_property_find(target_obj, target_name, errp);
if (!target_prop) {
return;
}
prop = g_malloc(sizeof(*prop));
prop->target_obj = target_obj;
prop->target_name = target_name;
object_property_add(obj, name, target_prop->type,
property_get_alias,
property_set_alias,
property_release_alias,
prop, errp);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(Object *VAR_0, const char *VAR_1,
Object *VAR_2, const char *VAR_3,
Error **VAR_4)
{
AliasProperty *prop;
ObjectProperty *target_prop;
target_prop = object_property_find(VAR_2, VAR_3, VAR_4);
if (!target_prop) {
return;
}
prop = g_malloc(sizeof(*prop));
prop->VAR_2 = VAR_2;
prop->VAR_3 = VAR_3;
object_property_add(VAR_0, VAR_1, target_prop->type,
property_get_alias,
property_set_alias,
property_release_alias,
prop, VAR_4);
}
| [
"void FUNC_0(Object *VAR_0, const char *VAR_1,\nObject *VAR_2, const char *VAR_3,\nError **VAR_4)\n{",
"AliasProperty *prop;",
"ObjectProperty *target_prop;",
"target_prop = object_property_find(VAR_2, VAR_3, VAR_4);",
"if (!target_prop) {",
"return;",
"}",
"prop = g_malloc(sizeof(*prop));",
"prop->VAR_2 = VAR_2;",
"prop->VAR_3 = VAR_3;",
"object_property_add(VAR_0, VAR_1, target_prop->type,\nproperty_get_alias,\nproperty_set_alias,\nproperty_release_alias,\nprop, VAR_4);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
33,
35,
37,
39,
41
],
[
43
]
] |
18,986 | static inline int tcg_global_reg_new_internal(TCGType type, int reg,
const char *name)
{
TCGContext *s = &tcg_ctx;
TCGTemp *ts;
int idx;
#if TCG_TARGET_REG_BITS == 32
if (type != TCG_TYPE_I32)
tcg_abort();
#endif
if (tcg_regset_test_reg(s->reserved_regs, reg))
tcg_abort();
idx = s->nb_globals;
tcg_temp_alloc(s, s->nb_globals + 1);
ts = &s->temps[s->nb_globals];
ts->base_type = type;
ts->type = type;
ts->fixed_reg = 1;
ts->reg = reg;
ts->name = name;
s->nb_globals++;
tcg_regset_set_reg(s->reserved_regs, reg);
return idx;
}
| false | qemu | b3a62939561e07bc34493444fa926b6137cba4e8 | static inline int tcg_global_reg_new_internal(TCGType type, int reg,
const char *name)
{
TCGContext *s = &tcg_ctx;
TCGTemp *ts;
int idx;
#if TCG_TARGET_REG_BITS == 32
if (type != TCG_TYPE_I32)
tcg_abort();
#endif
if (tcg_regset_test_reg(s->reserved_regs, reg))
tcg_abort();
idx = s->nb_globals;
tcg_temp_alloc(s, s->nb_globals + 1);
ts = &s->temps[s->nb_globals];
ts->base_type = type;
ts->type = type;
ts->fixed_reg = 1;
ts->reg = reg;
ts->name = name;
s->nb_globals++;
tcg_regset_set_reg(s->reserved_regs, reg);
return idx;
}
| {
"code": [],
"line_no": []
} | static inline int FUNC_0(TCGType VAR_0, int VAR_1,
const char *VAR_2)
{
TCGContext *s = &tcg_ctx;
TCGTemp *ts;
int VAR_3;
#if TCG_TARGET_REG_BITS == 32
if (VAR_0 != TCG_TYPE_I32)
tcg_abort();
#endif
if (tcg_regset_test_reg(s->reserved_regs, VAR_1))
tcg_abort();
VAR_3 = s->nb_globals;
tcg_temp_alloc(s, s->nb_globals + 1);
ts = &s->temps[s->nb_globals];
ts->base_type = VAR_0;
ts->VAR_0 = VAR_0;
ts->fixed_reg = 1;
ts->VAR_1 = VAR_1;
ts->VAR_2 = VAR_2;
s->nb_globals++;
tcg_regset_set_reg(s->reserved_regs, VAR_1);
return VAR_3;
}
| [
"static inline int FUNC_0(TCGType VAR_0, int VAR_1,\nconst char *VAR_2)\n{",
"TCGContext *s = &tcg_ctx;",
"TCGTemp *ts;",
"int VAR_3;",
"#if TCG_TARGET_REG_BITS == 32\nif (VAR_0 != TCG_TYPE_I32)\ntcg_abort();",
"#endif\nif (tcg_regset_test_reg(s->reserved_regs, VAR_1))\ntcg_abort();",
"VAR_3 = s->nb_globals;",
"tcg_temp_alloc(s, s->nb_globals + 1);",
"ts = &s->temps[s->nb_globals];",
"ts->base_type = VAR_0;",
"ts->VAR_0 = VAR_0;",
"ts->fixed_reg = 1;",
"ts->VAR_1 = VAR_1;",
"ts->VAR_2 = VAR_2;",
"s->nb_globals++;",
"tcg_regset_set_reg(s->reserved_regs, VAR_1);",
"return VAR_3;",
"}"
] | [
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
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
]
] |
18,987 | static SocketAddressLegacy *sd_socket_address(const char *path,
const char *host, const char *port)
{
SocketAddressLegacy *addr = g_new0(SocketAddressLegacy, 1);
if (path) {
addr->type = SOCKET_ADDRESS_LEGACY_KIND_UNIX;
addr->u.q_unix.data = g_new0(UnixSocketAddress, 1);
addr->u.q_unix.data->path = g_strdup(path);
} else {
addr->type = SOCKET_ADDRESS_LEGACY_KIND_INET;
addr->u.inet.data = g_new0(InetSocketAddress, 1);
addr->u.inet.data->host = g_strdup(host ?: SD_DEFAULT_ADDR);
addr->u.inet.data->port = g_strdup(port ?: stringify(SD_DEFAULT_PORT));
}
return addr;
}
| false | qemu | bd269ebc82fbaa5fe7ce5bc7c1770ac8acecd884 | static SocketAddressLegacy *sd_socket_address(const char *path,
const char *host, const char *port)
{
SocketAddressLegacy *addr = g_new0(SocketAddressLegacy, 1);
if (path) {
addr->type = SOCKET_ADDRESS_LEGACY_KIND_UNIX;
addr->u.q_unix.data = g_new0(UnixSocketAddress, 1);
addr->u.q_unix.data->path = g_strdup(path);
} else {
addr->type = SOCKET_ADDRESS_LEGACY_KIND_INET;
addr->u.inet.data = g_new0(InetSocketAddress, 1);
addr->u.inet.data->host = g_strdup(host ?: SD_DEFAULT_ADDR);
addr->u.inet.data->port = g_strdup(port ?: stringify(SD_DEFAULT_PORT));
}
return addr;
}
| {
"code": [],
"line_no": []
} | static SocketAddressLegacy *FUNC_0(const char *path,
const char *host, const char *port)
{
SocketAddressLegacy *addr = g_new0(SocketAddressLegacy, 1);
if (path) {
addr->type = SOCKET_ADDRESS_LEGACY_KIND_UNIX;
addr->u.q_unix.data = g_new0(UnixSocketAddress, 1);
addr->u.q_unix.data->path = g_strdup(path);
} else {
addr->type = SOCKET_ADDRESS_LEGACY_KIND_INET;
addr->u.inet.data = g_new0(InetSocketAddress, 1);
addr->u.inet.data->host = g_strdup(host ?: SD_DEFAULT_ADDR);
addr->u.inet.data->port = g_strdup(port ?: stringify(SD_DEFAULT_PORT));
}
return addr;
}
| [
"static SocketAddressLegacy *FUNC_0(const char *path,\nconst char *host, const char *port)\n{",
"SocketAddressLegacy *addr = g_new0(SocketAddressLegacy, 1);",
"if (path) {",
"addr->type = SOCKET_ADDRESS_LEGACY_KIND_UNIX;",
"addr->u.q_unix.data = g_new0(UnixSocketAddress, 1);",
"addr->u.q_unix.data->path = g_strdup(path);",
"} else {",
"addr->type = SOCKET_ADDRESS_LEGACY_KIND_INET;",
"addr->u.inet.data = g_new0(InetSocketAddress, 1);",
"addr->u.inet.data->host = g_strdup(host ?: SD_DEFAULT_ADDR);",
"addr->u.inet.data->port = g_strdup(port ?: stringify(SD_DEFAULT_PORT));",
"}",
"return addr;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
]
] |
18,989 | void tcg_target_init(TCGContext *s)
{
tcg_regset_set32(tcg_target_available_regs[TCG_TYPE_I32], 0, 0xffffffff);
#if defined(__sparc_v9__) && !defined(__sparc_v8plus__)
tcg_regset_set32(tcg_target_available_regs[TCG_TYPE_I64], 0, 0xffffffff);
#endif
tcg_regset_set32(tcg_target_call_clobber_regs, 0,
(1 << TCG_REG_G1) |
(1 << TCG_REG_G2) |
(1 << TCG_REG_G3) |
(1 << TCG_REG_G4) |
(1 << TCG_REG_G5) |
(1 << TCG_REG_G6) |
(1 << TCG_REG_G7) |
(1 << TCG_REG_O0) |
(1 << TCG_REG_O1) |
(1 << TCG_REG_O2) |
(1 << TCG_REG_O3) |
(1 << TCG_REG_O4) |
(1 << TCG_REG_O5) |
(1 << TCG_REG_O7));
tcg_regset_clear(s->reserved_regs);
tcg_regset_set_reg(s->reserved_regs, TCG_REG_G0);
#if defined(__sparc_v9__) && !defined(__sparc_v8plus__)
tcg_regset_set_reg(s->reserved_regs, TCG_REG_I4); // for internal use
#endif
tcg_regset_set_reg(s->reserved_regs, TCG_REG_I5); // for internal use
tcg_regset_set_reg(s->reserved_regs, TCG_REG_I6);
tcg_regset_set_reg(s->reserved_regs, TCG_REG_I7);
tcg_regset_set_reg(s->reserved_regs, TCG_REG_O6);
tcg_regset_set_reg(s->reserved_regs, TCG_REG_O7);
tcg_add_target_add_op_defs(sparc_op_defs);
}
| false | qemu | a212ea75534aebe98c03451b58c5fdf754cf8978 | void tcg_target_init(TCGContext *s)
{
tcg_regset_set32(tcg_target_available_regs[TCG_TYPE_I32], 0, 0xffffffff);
#if defined(__sparc_v9__) && !defined(__sparc_v8plus__)
tcg_regset_set32(tcg_target_available_regs[TCG_TYPE_I64], 0, 0xffffffff);
#endif
tcg_regset_set32(tcg_target_call_clobber_regs, 0,
(1 << TCG_REG_G1) |
(1 << TCG_REG_G2) |
(1 << TCG_REG_G3) |
(1 << TCG_REG_G4) |
(1 << TCG_REG_G5) |
(1 << TCG_REG_G6) |
(1 << TCG_REG_G7) |
(1 << TCG_REG_O0) |
(1 << TCG_REG_O1) |
(1 << TCG_REG_O2) |
(1 << TCG_REG_O3) |
(1 << TCG_REG_O4) |
(1 << TCG_REG_O5) |
(1 << TCG_REG_O7));
tcg_regset_clear(s->reserved_regs);
tcg_regset_set_reg(s->reserved_regs, TCG_REG_G0);
#if defined(__sparc_v9__) && !defined(__sparc_v8plus__)
tcg_regset_set_reg(s->reserved_regs, TCG_REG_I4);
#endif
tcg_regset_set_reg(s->reserved_regs, TCG_REG_I5);
tcg_regset_set_reg(s->reserved_regs, TCG_REG_I6);
tcg_regset_set_reg(s->reserved_regs, TCG_REG_I7);
tcg_regset_set_reg(s->reserved_regs, TCG_REG_O6);
tcg_regset_set_reg(s->reserved_regs, TCG_REG_O7);
tcg_add_target_add_op_defs(sparc_op_defs);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(TCGContext *VAR_0)
{
tcg_regset_set32(tcg_target_available_regs[TCG_TYPE_I32], 0, 0xffffffff);
#if defined(__sparc_v9__) && !defined(__sparc_v8plus__)
tcg_regset_set32(tcg_target_available_regs[TCG_TYPE_I64], 0, 0xffffffff);
#endif
tcg_regset_set32(tcg_target_call_clobber_regs, 0,
(1 << TCG_REG_G1) |
(1 << TCG_REG_G2) |
(1 << TCG_REG_G3) |
(1 << TCG_REG_G4) |
(1 << TCG_REG_G5) |
(1 << TCG_REG_G6) |
(1 << TCG_REG_G7) |
(1 << TCG_REG_O0) |
(1 << TCG_REG_O1) |
(1 << TCG_REG_O2) |
(1 << TCG_REG_O3) |
(1 << TCG_REG_O4) |
(1 << TCG_REG_O5) |
(1 << TCG_REG_O7));
tcg_regset_clear(VAR_0->reserved_regs);
tcg_regset_set_reg(VAR_0->reserved_regs, TCG_REG_G0);
#if defined(__sparc_v9__) && !defined(__sparc_v8plus__)
tcg_regset_set_reg(VAR_0->reserved_regs, TCG_REG_I4);
#endif
tcg_regset_set_reg(VAR_0->reserved_regs, TCG_REG_I5);
tcg_regset_set_reg(VAR_0->reserved_regs, TCG_REG_I6);
tcg_regset_set_reg(VAR_0->reserved_regs, TCG_REG_I7);
tcg_regset_set_reg(VAR_0->reserved_regs, TCG_REG_O6);
tcg_regset_set_reg(VAR_0->reserved_regs, TCG_REG_O7);
tcg_add_target_add_op_defs(sparc_op_defs);
}
| [
"void FUNC_0(TCGContext *VAR_0)\n{",
"tcg_regset_set32(tcg_target_available_regs[TCG_TYPE_I32], 0, 0xffffffff);",
"#if defined(__sparc_v9__) && !defined(__sparc_v8plus__)\ntcg_regset_set32(tcg_target_available_regs[TCG_TYPE_I64], 0, 0xffffffff);",
"#endif\ntcg_regset_set32(tcg_target_call_clobber_regs, 0,\n(1 << TCG_REG_G1) |\n(1 << TCG_REG_G2) |\n(1 << TCG_REG_G3) |\n(1 << TCG_REG_G4) |\n(1 << TCG_REG_G5) |\n(1 << TCG_REG_G6) |\n(1 << TCG_REG_G7) |\n(1 << TCG_REG_O0) |\n(1 << TCG_REG_O1) |\n(1 << TCG_REG_O2) |\n(1 << TCG_REG_O3) |\n(1 << TCG_REG_O4) |\n(1 << TCG_REG_O5) |\n(1 << TCG_REG_O7));",
"tcg_regset_clear(VAR_0->reserved_regs);",
"tcg_regset_set_reg(VAR_0->reserved_regs, TCG_REG_G0);",
"#if defined(__sparc_v9__) && !defined(__sparc_v8plus__)\ntcg_regset_set_reg(VAR_0->reserved_regs, TCG_REG_I4);",
"#endif\ntcg_regset_set_reg(VAR_0->reserved_regs, TCG_REG_I5);",
"tcg_regset_set_reg(VAR_0->reserved_regs, TCG_REG_I6);",
"tcg_regset_set_reg(VAR_0->reserved_regs, TCG_REG_I7);",
"tcg_regset_set_reg(VAR_0->reserved_regs, TCG_REG_O6);",
"tcg_regset_set_reg(VAR_0->reserved_regs, TCG_REG_O7);",
"tcg_add_target_add_op_defs(sparc_op_defs);",
"}"
] | [
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
],
[
45
],
[
47
],
[
49,
51
],
[
53,
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
]
] |
18,991 | int kvm_has_sync_mmu(void)
{
return kvm_check_extension(kvm_state, KVM_CAP_SYNC_MMU);
}
| false | qemu | 62dd4edaaf859b60f74a51f2a526d4d3d85d0248 | int kvm_has_sync_mmu(void)
{
return kvm_check_extension(kvm_state, KVM_CAP_SYNC_MMU);
}
| {
"code": [],
"line_no": []
} | int FUNC_0(void)
{
return kvm_check_extension(kvm_state, KVM_CAP_SYNC_MMU);
}
| [
"int FUNC_0(void)\n{",
"return kvm_check_extension(kvm_state, KVM_CAP_SYNC_MMU);",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
18,992 | static void cirrus_do_copy(CirrusVGAState *s, int dst, int src, int w, int h)
{
int sx = 0, sy = 0;
int dx = 0, dy = 0;
int depth = 0;
int notify = 0;
/* make sure to only copy if it's a plain copy ROP */
if (*s->cirrus_rop == cirrus_bitblt_rop_fwd_src ||
*s->cirrus_rop == cirrus_bitblt_rop_bkwd_src) {
int width, height;
depth = s->vga.get_bpp(&s->vga) / 8;
s->vga.get_resolution(&s->vga, &width, &height);
/* extra x, y */
sx = (src % ABS(s->cirrus_blt_srcpitch)) / depth;
sy = (src / ABS(s->cirrus_blt_srcpitch));
dx = (dst % ABS(s->cirrus_blt_dstpitch)) / depth;
dy = (dst / ABS(s->cirrus_blt_dstpitch));
/* normalize width */
w /= depth;
/* if we're doing a backward copy, we have to adjust
our x/y to be the upper left corner (instead of the lower
right corner) */
if (s->cirrus_blt_dstpitch < 0) {
sx -= (s->cirrus_blt_width / depth) - 1;
dx -= (s->cirrus_blt_width / depth) - 1;
sy -= s->cirrus_blt_height - 1;
dy -= s->cirrus_blt_height - 1;
}
/* are we in the visible portion of memory? */
if (sx >= 0 && sy >= 0 && dx >= 0 && dy >= 0 &&
(sx + w) <= width && (sy + h) <= height &&
(dx + w) <= width && (dy + h) <= height) {
notify = 1;
}
}
/* we have to flush all pending changes so that the copy
is generated at the appropriate moment in time */
if (notify)
graphic_hw_update(s->vga.con);
(*s->cirrus_rop) (s, s->vga.vram_ptr +
(s->cirrus_blt_dstaddr & s->cirrus_addr_mask),
s->vga.vram_ptr +
(s->cirrus_blt_srcaddr & s->cirrus_addr_mask),
s->cirrus_blt_dstpitch, s->cirrus_blt_srcpitch,
s->cirrus_blt_width, s->cirrus_blt_height);
if (notify) {
qemu_console_copy(s->vga.con,
sx, sy, dx, dy,
s->cirrus_blt_width / depth,
s->cirrus_blt_height);
}
/* we don't have to notify the display that this portion has
changed since qemu_console_copy implies this */
cirrus_invalidate_region(s, s->cirrus_blt_dstaddr,
s->cirrus_blt_dstpitch, s->cirrus_blt_width,
s->cirrus_blt_height);
}
| false | qemu | 4299b90e9ba9ce5ca9024572804ba751aa1a7e70 | static void cirrus_do_copy(CirrusVGAState *s, int dst, int src, int w, int h)
{
int sx = 0, sy = 0;
int dx = 0, dy = 0;
int depth = 0;
int notify = 0;
if (*s->cirrus_rop == cirrus_bitblt_rop_fwd_src ||
*s->cirrus_rop == cirrus_bitblt_rop_bkwd_src) {
int width, height;
depth = s->vga.get_bpp(&s->vga) / 8;
s->vga.get_resolution(&s->vga, &width, &height);
sx = (src % ABS(s->cirrus_blt_srcpitch)) / depth;
sy = (src / ABS(s->cirrus_blt_srcpitch));
dx = (dst % ABS(s->cirrus_blt_dstpitch)) / depth;
dy = (dst / ABS(s->cirrus_blt_dstpitch));
w /= depth;
if (s->cirrus_blt_dstpitch < 0) {
sx -= (s->cirrus_blt_width / depth) - 1;
dx -= (s->cirrus_blt_width / depth) - 1;
sy -= s->cirrus_blt_height - 1;
dy -= s->cirrus_blt_height - 1;
}
if (sx >= 0 && sy >= 0 && dx >= 0 && dy >= 0 &&
(sx + w) <= width && (sy + h) <= height &&
(dx + w) <= width && (dy + h) <= height) {
notify = 1;
}
}
if (notify)
graphic_hw_update(s->vga.con);
(*s->cirrus_rop) (s, s->vga.vram_ptr +
(s->cirrus_blt_dstaddr & s->cirrus_addr_mask),
s->vga.vram_ptr +
(s->cirrus_blt_srcaddr & s->cirrus_addr_mask),
s->cirrus_blt_dstpitch, s->cirrus_blt_srcpitch,
s->cirrus_blt_width, s->cirrus_blt_height);
if (notify) {
qemu_console_copy(s->vga.con,
sx, sy, dx, dy,
s->cirrus_blt_width / depth,
s->cirrus_blt_height);
}
cirrus_invalidate_region(s, s->cirrus_blt_dstaddr,
s->cirrus_blt_dstpitch, s->cirrus_blt_width,
s->cirrus_blt_height);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(CirrusVGAState *VAR_0, int VAR_1, int VAR_2, int VAR_3, int VAR_4)
{
int VAR_5 = 0, VAR_6 = 0;
int VAR_7 = 0, VAR_8 = 0;
int VAR_9 = 0;
int VAR_10 = 0;
if (*VAR_0->cirrus_rop == cirrus_bitblt_rop_fwd_src ||
*VAR_0->cirrus_rop == cirrus_bitblt_rop_bkwd_src) {
int VAR_11, VAR_12;
VAR_9 = VAR_0->vga.get_bpp(&VAR_0->vga) / 8;
VAR_0->vga.get_resolution(&VAR_0->vga, &VAR_11, &VAR_12);
VAR_5 = (VAR_2 % ABS(VAR_0->cirrus_blt_srcpitch)) / VAR_9;
VAR_6 = (VAR_2 / ABS(VAR_0->cirrus_blt_srcpitch));
VAR_7 = (VAR_1 % ABS(VAR_0->cirrus_blt_dstpitch)) / VAR_9;
VAR_8 = (VAR_1 / ABS(VAR_0->cirrus_blt_dstpitch));
VAR_3 /= VAR_9;
if (VAR_0->cirrus_blt_dstpitch < 0) {
VAR_5 -= (VAR_0->cirrus_blt_width / VAR_9) - 1;
VAR_7 -= (VAR_0->cirrus_blt_width / VAR_9) - 1;
VAR_6 -= VAR_0->cirrus_blt_height - 1;
VAR_8 -= VAR_0->cirrus_blt_height - 1;
}
if (VAR_5 >= 0 && VAR_6 >= 0 && VAR_7 >= 0 && VAR_8 >= 0 &&
(VAR_5 + VAR_3) <= VAR_11 && (VAR_6 + VAR_4) <= VAR_12 &&
(VAR_7 + VAR_3) <= VAR_11 && (VAR_8 + VAR_4) <= VAR_12) {
VAR_10 = 1;
}
}
if (VAR_10)
graphic_hw_update(VAR_0->vga.con);
(*VAR_0->cirrus_rop) (VAR_0, VAR_0->vga.vram_ptr +
(VAR_0->cirrus_blt_dstaddr & VAR_0->cirrus_addr_mask),
VAR_0->vga.vram_ptr +
(VAR_0->cirrus_blt_srcaddr & VAR_0->cirrus_addr_mask),
VAR_0->cirrus_blt_dstpitch, VAR_0->cirrus_blt_srcpitch,
VAR_0->cirrus_blt_width, VAR_0->cirrus_blt_height);
if (VAR_10) {
qemu_console_copy(VAR_0->vga.con,
VAR_5, VAR_6, VAR_7, VAR_8,
VAR_0->cirrus_blt_width / VAR_9,
VAR_0->cirrus_blt_height);
}
cirrus_invalidate_region(VAR_0, VAR_0->cirrus_blt_dstaddr,
VAR_0->cirrus_blt_dstpitch, VAR_0->cirrus_blt_width,
VAR_0->cirrus_blt_height);
}
| [
"static void FUNC_0(CirrusVGAState *VAR_0, int VAR_1, int VAR_2, int VAR_3, int VAR_4)\n{",
"int VAR_5 = 0, VAR_6 = 0;",
"int VAR_7 = 0, VAR_8 = 0;",
"int VAR_9 = 0;",
"int VAR_10 = 0;",
"if (*VAR_0->cirrus_rop == cirrus_bitblt_rop_fwd_src ||\n*VAR_0->cirrus_rop == cirrus_bitblt_rop_bkwd_src) {",
"int VAR_11, VAR_12;",
"VAR_9 = VAR_0->vga.get_bpp(&VAR_0->vga) / 8;",
"VAR_0->vga.get_resolution(&VAR_0->vga, &VAR_11, &VAR_12);",
"VAR_5 = (VAR_2 % ABS(VAR_0->cirrus_blt_srcpitch)) / VAR_9;",
"VAR_6 = (VAR_2 / ABS(VAR_0->cirrus_blt_srcpitch));",
"VAR_7 = (VAR_1 % ABS(VAR_0->cirrus_blt_dstpitch)) / VAR_9;",
"VAR_8 = (VAR_1 / ABS(VAR_0->cirrus_blt_dstpitch));",
"VAR_3 /= VAR_9;",
"if (VAR_0->cirrus_blt_dstpitch < 0) {",
"VAR_5 -= (VAR_0->cirrus_blt_width / VAR_9) - 1;",
"VAR_7 -= (VAR_0->cirrus_blt_width / VAR_9) - 1;",
"VAR_6 -= VAR_0->cirrus_blt_height - 1;",
"VAR_8 -= VAR_0->cirrus_blt_height - 1;",
"}",
"if (VAR_5 >= 0 && VAR_6 >= 0 && VAR_7 >= 0 && VAR_8 >= 0 &&\n(VAR_5 + VAR_3) <= VAR_11 && (VAR_6 + VAR_4) <= VAR_12 &&\n(VAR_7 + VAR_3) <= VAR_11 && (VAR_8 + VAR_4) <= VAR_12) {",
"VAR_10 = 1;",
"}",
"}",
"if (VAR_10)\ngraphic_hw_update(VAR_0->vga.con);",
"(*VAR_0->cirrus_rop) (VAR_0, VAR_0->vga.vram_ptr +\n(VAR_0->cirrus_blt_dstaddr & VAR_0->cirrus_addr_mask),\nVAR_0->vga.vram_ptr +\n(VAR_0->cirrus_blt_srcaddr & VAR_0->cirrus_addr_mask),\nVAR_0->cirrus_blt_dstpitch, VAR_0->cirrus_blt_srcpitch,\nVAR_0->cirrus_blt_width, VAR_0->cirrus_blt_height);",
"if (VAR_10) {",
"qemu_console_copy(VAR_0->vga.con,\nVAR_5, VAR_6, VAR_7, VAR_8,\nVAR_0->cirrus_blt_width / VAR_9,\nVAR_0->cirrus_blt_height);",
"}",
"cirrus_invalidate_region(VAR_0, VAR_0->cirrus_blt_dstaddr,\nVAR_0->cirrus_blt_dstpitch, VAR_0->cirrus_blt_width,\nVAR_0->cirrus_blt_height);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
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
],
[
17,
19
],
[
23
],
[
27
],
[
29
],
[
35
],
[
37
],
[
39
],
[
41
],
[
47
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
73,
75,
77
],
[
79
],
[
81
],
[
83
],
[
91,
93
],
[
97,
99,
101,
103,
105,
107
],
[
111
],
[
113,
115,
117,
119
],
[
121
],
[
131,
133,
135
],
[
137
]
] |
18,993 | static uint64_t pic_ioport_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
PICCommonState *s = opaque;
int ret;
if (s->poll) {
ret = pic_get_irq(s);
if (ret >= 0) {
pic_intack(s, ret);
ret |= 0x80;
} else {
ret = 0;
}
s->poll = 0;
} else {
if (addr == 0) {
if (s->read_reg_select) {
ret = s->isr;
} else {
ret = s->irr;
}
} else {
ret = s->imr;
}
}
DPRINTF("read: addr=0x%02x val=0x%02x\n", addr, ret);
return ret;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static uint64_t pic_ioport_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
PICCommonState *s = opaque;
int ret;
if (s->poll) {
ret = pic_get_irq(s);
if (ret >= 0) {
pic_intack(s, ret);
ret |= 0x80;
} else {
ret = 0;
}
s->poll = 0;
} else {
if (addr == 0) {
if (s->read_reg_select) {
ret = s->isr;
} else {
ret = s->irr;
}
} else {
ret = s->imr;
}
}
DPRINTF("read: addr=0x%02x val=0x%02x\n", addr, ret);
return ret;
}
| {
"code": [],
"line_no": []
} | static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr,
unsigned size)
{
PICCommonState *s = opaque;
int VAR_0;
if (s->poll) {
VAR_0 = pic_get_irq(s);
if (VAR_0 >= 0) {
pic_intack(s, VAR_0);
VAR_0 |= 0x80;
} else {
VAR_0 = 0;
}
s->poll = 0;
} else {
if (addr == 0) {
if (s->read_reg_select) {
VAR_0 = s->isr;
} else {
VAR_0 = s->irr;
}
} else {
VAR_0 = s->imr;
}
}
DPRINTF("read: addr=0x%02x val=0x%02x\n", addr, VAR_0);
return VAR_0;
}
| [
"static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr,\nunsigned size)\n{",
"PICCommonState *s = opaque;",
"int VAR_0;",
"if (s->poll) {",
"VAR_0 = pic_get_irq(s);",
"if (VAR_0 >= 0) {",
"pic_intack(s, VAR_0);",
"VAR_0 |= 0x80;",
"} else {",
"VAR_0 = 0;",
"}",
"s->poll = 0;",
"} else {",
"if (addr == 0) {",
"if (s->read_reg_select) {",
"VAR_0 = s->isr;",
"} else {",
"VAR_0 = s->irr;",
"}",
"} else {",
"VAR_0 = s->imr;",
"}",
"}",
"DPRINTF(\"read: addr=0x%02x val=0x%02x\\n\", addr, VAR_0);",
"return 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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
]
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.