id
int32
0
27.3k
func
stringlengths
26
142k
target
bool
2 classes
project
stringclasses
2 values
commit_id
stringlengths
40
40
func_clean
stringlengths
26
131k
vul_lines
dict
normalized_func
stringlengths
24
132k
lines
listlengths
1
2.8k
label
listlengths
1
2.8k
line_no
listlengths
1
2.8k
9,838
static void initMMX2HScaler(int dstW, int xInc, uint8_t *funnyCode) { uint8_t *fragment; int imm8OfPShufW1; int imm8OfPShufW2; int fragmentLength; int xpos, i; // create an optimized horizontal scaling routine //code fragment asm volatile( "jmp 9f \n\t" // Begin "0: \n\t" "movq (%%esi), %%mm0 \n\t" //FIXME Alignment "movq %%mm0, %%mm1 \n\t" "psrlq $8, %%mm0 \n\t" "punpcklbw %%mm7, %%mm1 \n\t" "movq %%mm2, %%mm3 \n\t" "punpcklbw %%mm7, %%mm0 \n\t" "addw %%bx, %%cx \n\t" //2*xalpha += (4*lumXInc)&0xFFFF "pshufw $0xFF, %%mm1, %%mm1 \n\t" "1: \n\t" "adcl %%edx, %%esi \n\t" //xx+= (4*lumXInc)>>16 + carry "pshufw $0xFF, %%mm0, %%mm0 \n\t" "2: \n\t" "psrlw $9, %%mm3 \n\t" "psubw %%mm1, %%mm0 \n\t" "pmullw %%mm3, %%mm0 \n\t" "paddw %%mm6, %%mm2 \n\t" // 2*alpha += xpos&0xFFFF "psllw $7, %%mm1 \n\t" "paddw %%mm1, %%mm0 \n\t" "movq %%mm0, (%%edi, %%eax) \n\t" "addl $8, %%eax \n\t" // End "9: \n\t" // "int $3\n\t" "leal 0b, %0 \n\t" "leal 1b, %1 \n\t" "leal 2b, %2 \n\t" "decl %1 \n\t" "decl %2 \n\t" "subl %0, %1 \n\t" "subl %0, %2 \n\t" "leal 9b, %3 \n\t" "subl %0, %3 \n\t" :"=r" (fragment), "=r" (imm8OfPShufW1), "=r" (imm8OfPShufW2), "=r" (fragmentLength) ); xpos= 0; //lumXInc/2 - 0x8000; // difference between pixel centers for(i=0; i<dstW/8; i++) { int xx=xpos>>16; if((i&3) == 0) { int a=0; int b=((xpos+xInc)>>16) - xx; int c=((xpos+xInc*2)>>16) - xx; int d=((xpos+xInc*3)>>16) - xx; memcpy(funnyCode + fragmentLength*i/4, fragment, fragmentLength); funnyCode[fragmentLength*i/4 + imm8OfPShufW1]= funnyCode[fragmentLength*i/4 + imm8OfPShufW2]= a | (b<<2) | (c<<4) | (d<<6); // if we dont need to read 8 bytes than dont :), reduces the chance of // crossing a cache line if(d<3) funnyCode[fragmentLength*i/4 + 1]= 0x6E; funnyCode[fragmentLength*(i+4)/4]= RET; } xpos+=xInc; } }
true
FFmpeg
b7dc6f662868fbdad779c61c233b1d19d8b89d3c
static void initMMX2HScaler(int dstW, int xInc, uint8_t *funnyCode) { uint8_t *fragment; int imm8OfPShufW1; int imm8OfPShufW2; int fragmentLength; int xpos, i; asm volatile( "jmp 9f \n\t" "0: \n\t" "movq (%%esi), %%mm0 \n\t" "movq %%mm0, %%mm1 \n\t" "psrlq $8, %%mm0 \n\t" "punpcklbw %%mm7, %%mm1 \n\t" "movq %%mm2, %%mm3 \n\t" "punpcklbw %%mm7, %%mm0 \n\t" "addw %%bx, %%cx \n\t" "pshufw $0xFF, %%mm1, %%mm1 \n\t" "1: \n\t" "adcl %%edx, %%esi \n\t" "pshufw $0xFF, %%mm0, %%mm0 \n\t" "2: \n\t" "psrlw $9, %%mm3 \n\t" "psubw %%mm1, %%mm0 \n\t" "pmullw %%mm3, %%mm0 \n\t" "paddw %%mm6, %%mm2 \n\t" "psllw $7, %%mm1 \n\t" "paddw %%mm1, %%mm0 \n\t" "movq %%mm0, (%%edi, %%eax) \n\t" "addl $8, %%eax \n\t" "9: \n\t" "leal 0b, %0 \n\t" "leal 1b, %1 \n\t" "leal 2b, %2 \n\t" "decl %1 \n\t" "decl %2 \n\t" "subl %0, %1 \n\t" "subl %0, %2 \n\t" "leal 9b, %3 \n\t" "subl %0, %3 \n\t" :"=r" (fragment), "=r" (imm8OfPShufW1), "=r" (imm8OfPShufW2), "=r" (fragmentLength) ); xpos= 0; for(i=0; i<dstW/8; i++) { int xx=xpos>>16; if((i&3) == 0) { int a=0; int b=((xpos+xInc)>>16) - xx; int c=((xpos+xInc*2)>>16) - xx; int d=((xpos+xInc*3)>>16) - xx; memcpy(funnyCode + fragmentLength*i/4, fragment, fragmentLength); funnyCode[fragmentLength*i/4 + imm8OfPShufW1]= funnyCode[fragmentLength*i/4 + imm8OfPShufW2]= a | (b<<2) | (c<<4) | (d<<6); if(d<3) funnyCode[fragmentLength*i/4 + 1]= 0x6E; funnyCode[fragmentLength*(i+4)/4]= RET; } xpos+=xInc; } }
{ "code": [ "static void initMMX2HScaler(int dstW, int xInc, uint8_t *funnyCode)", "\tuint8_t *fragment;", "\tint imm8OfPShufW1;", "\tint imm8OfPShufW2;", "\tint fragmentLength;", "\t\t\"movq %%mm0, %%mm1\t\t\\n\\t\"", "\t\t\"psrlq $8, %%mm0\t\t\\n\\t\"", "\t\t\"punpcklbw %%mm7, %%mm1\t\\n\\t\"", "\t\t\"movq %%mm2, %%mm3\t\t\\n\\t\"", "\t\t\"punpcklbw %%mm7, %%mm0\t\\n\\t\"", "\t\t\"psrlw $9, %%mm3\t\t\\n\\t\"", "\t\t:\"=r\" (fragment), \"=r\" (imm8OfPShufW1), \"=r\" (imm8OfPShufW2),", "\t\t\"=r\" (fragmentLength)", "\tfor(i=0; i<dstW/8; i++)", "\t\t\tmemcpy(funnyCode + fragmentLength*i/4, fragment, fragmentLength);", "\t\t\tfunnyCode[fragmentLength*i/4 + imm8OfPShufW1]=", "\t\t\tfunnyCode[fragmentLength*i/4 + imm8OfPShufW2]=", "\t\t\t\ta | (b<<2) | (c<<4) | (d<<6);", "\t\t\tif(d<3) funnyCode[fragmentLength*i/4 + 1]= 0x6E;", "\t\t\tfunnyCode[fragmentLength*(i+4)/4]= RET;", "\t);" ], "line_no": [ 1, 5, 7, 9, 11, 37, 39, 41, 43, 45, 59, 103, 105, 115, 137, 141, 143, 145, 153, 157, 107 ] }
static void FUNC_0(int VAR_0, int VAR_1, uint8_t *VAR_2) { uint8_t *fragment; int VAR_3; int VAR_4; int VAR_5; int VAR_6, VAR_7; asm volatile( "jmp 9f \n\t" "0: \n\t" "movq (%%esi), %%mm0 \n\t" "movq %%mm0, %%mm1 \n\t" "psrlq $8, %%mm0 \n\t" "punpcklbw %%mm7, %%mm1 \n\t" "movq %%mm2, %%mm3 \n\t" "punpcklbw %%mm7, %%mm0 \n\t" "addw %%bx, %%cx \n\t" "pshufw $0xFF, %%mm1, %%mm1 \n\t" "1: \n\t" "adcl %%edx, %%esi \n\t" "pshufw $0xFF, %%mm0, %%mm0 \n\t" "2: \n\t" "psrlw $9, %%mm3 \n\t" "psubw %%mm1, %%mm0 \n\t" "pmullw %%mm3, %%mm0 \n\t" "paddw %%mm6, %%mm2 \n\t" "psllw $7, %%mm1 \n\t" "paddw %%mm1, %%mm0 \n\t" "movq %%mm0, (%%edi, %%eax) \n\t" "addl $8, %%eax \n\t" "9: \n\t" "leal 0b, %0 \n\t" "leal 1b, %1 \n\t" "leal 2b, %2 \n\t" "decl %1 \n\t" "decl %2 \n\t" "subl %0, %1 \n\t" "subl %0, %2 \n\t" "leal 9b, %3 \n\t" "subl %0, %3 \n\t" :"=r" (fragment), "=r" (VAR_3), "=r" (VAR_4), "=r" (VAR_5) ); VAR_6= 0; for(VAR_7=0; VAR_7<VAR_0/8; VAR_7++) { int VAR_8=VAR_6>>16; if((VAR_7&3) == 0) { int VAR_9=0; int VAR_10=((VAR_6+VAR_1)>>16) - VAR_8; int VAR_11=((VAR_6+VAR_1*2)>>16) - VAR_8; int VAR_12=((VAR_6+VAR_1*3)>>16) - VAR_8; memcpy(VAR_2 + VAR_5*VAR_7/4, fragment, VAR_5); VAR_2[VAR_5*VAR_7/4 + VAR_3]= VAR_2[VAR_5*VAR_7/4 + VAR_4]= VAR_9 | (VAR_10<<2) | (VAR_11<<4) | (VAR_12<<6); if(VAR_12<3) VAR_2[VAR_5*VAR_7/4 + 1]= 0x6E; VAR_2[VAR_5*(VAR_7+4)/4]= RET; } VAR_6+=VAR_1; } }
[ "static void FUNC_0(int VAR_0, int VAR_1, uint8_t *VAR_2)\n{", "uint8_t *fragment;", "int VAR_3;", "int VAR_4;", "int VAR_5;", "int VAR_6, VAR_7;", "asm volatile(\n\"jmp 9f\t\t\t\t\\n\\t\"\n\"0:\t\t\t\t\\n\\t\"\n\"movq (%%esi), %%mm0\t\t\\n\\t\"\n\"movq %%mm0, %%mm1\t\t\\n\\t\"\n\"psrlq $8, %%mm0\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm1\t\\n\\t\"\n\"movq %%mm2, %%mm3\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm0\t\\n\\t\"\n\"addw %%bx, %%cx\t\t\\n\\t\"\n\"pshufw $0xFF, %%mm1, %%mm1\t\\n\\t\"\n\"1:\t\t\t\t\\n\\t\"\n\"adcl %%edx, %%esi\t\t\\n\\t\"\n\"pshufw $0xFF, %%mm0, %%mm0\t\\n\\t\"\n\"2:\t\t\t\t\\n\\t\"\n\"psrlw $9, %%mm3\t\t\\n\\t\"\n\"psubw %%mm1, %%mm0\t\t\\n\\t\"\n\"pmullw %%mm3, %%mm0\t\t\\n\\t\"\n\"paddw %%mm6, %%mm2\t\t\\n\\t\"\n\"psllw $7, %%mm1\t\t\\n\\t\"\n\"paddw %%mm1, %%mm0\t\t\\n\\t\"\n\"movq %%mm0, (%%edi, %%eax)\t\\n\\t\"\n\"addl $8, %%eax\t\t\t\\n\\t\"\n\"9:\t\t\t\t\\n\\t\"\n\"leal 0b, %0\t\t\t\\n\\t\"\n\"leal 1b, %1\t\t\t\\n\\t\"\n\"leal 2b, %2\t\t\t\\n\\t\"\n\"decl %1\t\t\t\\n\\t\"\n\"decl %2\t\t\t\\n\\t\"\n\"subl %0, %1\t\t\t\\n\\t\"\n\"subl %0, %2\t\t\t\\n\\t\"\n\"leal 9b, %3\t\t\t\\n\\t\"\n\"subl %0, %3\t\t\t\\n\\t\"\n:\"=r\" (fragment), \"=r\" (VAR_3), \"=r\" (VAR_4),\n\"=r\" (VAR_5)\n);", "VAR_6= 0;", "for(VAR_7=0; VAR_7<VAR_0/8; VAR_7++)", "{", "int VAR_8=VAR_6>>16;", "if((VAR_7&3) == 0)\n{", "int VAR_9=0;", "int VAR_10=((VAR_6+VAR_1)>>16) - VAR_8;", "int VAR_11=((VAR_6+VAR_1*2)>>16) - VAR_8;", "int VAR_12=((VAR_6+VAR_1*3)>>16) - VAR_8;", "memcpy(VAR_2 + VAR_5*VAR_7/4, fragment, VAR_5);", "VAR_2[VAR_5*VAR_7/4 + VAR_3]=\nVAR_2[VAR_5*VAR_7/4 + VAR_4]=\nVAR_9 | (VAR_10<<2) | (VAR_11<<4) | (VAR_12<<6);", "if(VAR_12<3) VAR_2[VAR_5*VAR_7/4 + 1]= 0x6E;", "VAR_2[VAR_5*(VAR_7+4)/4]= RET;", "}", "VAR_6+=VAR_1;", "}", "}" ]
[ 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 27, 29, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 73, 77, 81, 85, 87, 89, 91, 93, 95, 97, 99, 101, 103, 105, 107 ], [ 111 ], [ 115 ], [ 117 ], [ 119 ], [ 123, 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 137 ], [ 141, 143, 145 ], [ 153 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ] ]
9,839
static void *acpi_add_rom_blob(AcpiBuildState *build_state, GArray *blob, const char *name) { return rom_add_blob(name, blob->data, acpi_data_len(blob), -1, name, acpi_build_update, build_state); }
true
qemu
ad5b88b1f198182642b6cbf3dacb4cade0c80fb9
static void *acpi_add_rom_blob(AcpiBuildState *build_state, GArray *blob, const char *name) { return rom_add_blob(name, blob->data, acpi_data_len(blob), -1, name, acpi_build_update, build_state); }
{ "code": [ "static void *acpi_add_rom_blob(AcpiBuildState *build_state, GArray *blob," ], "line_no": [ 1 ] }
static void *FUNC_0(AcpiBuildState *VAR_0, GArray *VAR_1, const char *VAR_2) { return rom_add_blob(VAR_2, VAR_1->data, acpi_data_len(VAR_1), -1, VAR_2, acpi_build_update, VAR_0); }
[ "static void *FUNC_0(AcpiBuildState *VAR_0, GArray *VAR_1,\nconst char *VAR_2)\n{", "return rom_add_blob(VAR_2, VAR_1->data, acpi_data_len(VAR_1), -1, VAR_2,\nacpi_build_update, VAR_0);", "}" ]
[ 1, 0, 0 ]
[ [ 1, 3, 5 ], [ 7, 9 ], [ 11 ] ]
9,840
static void reclaim_ramblock(RAMBlock *block) { if (block->flags & RAM_PREALLOC) { ; } else if (xen_enabled()) { xen_invalidate_map_cache_entry(block->host); #ifndef _WIN32 } else if (block->fd >= 0) { munmap(block->host, block->max_length); close(block->fd); #endif } else { qemu_anon_ram_free(block->host, block->max_length); } g_free(block); }
true
qemu
8561c9244ddf1122dfe7ccac9b23f506062f1499
static void reclaim_ramblock(RAMBlock *block) { if (block->flags & RAM_PREALLOC) { ; } else if (xen_enabled()) { xen_invalidate_map_cache_entry(block->host); #ifndef _WIN32 } else if (block->fd >= 0) { munmap(block->host, block->max_length); close(block->fd); #endif } else { qemu_anon_ram_free(block->host, block->max_length); } g_free(block); }
{ "code": [ " munmap(block->host, block->max_length);" ], "line_no": [ 17 ] }
static void FUNC_0(RAMBlock *VAR_0) { if (VAR_0->flags & RAM_PREALLOC) { ; } else if (xen_enabled()) { xen_invalidate_map_cache_entry(VAR_0->host); #ifndef _WIN32 } else if (VAR_0->fd >= 0) { munmap(VAR_0->host, VAR_0->max_length); close(VAR_0->fd); #endif } else { qemu_anon_ram_free(VAR_0->host, VAR_0->max_length); } g_free(VAR_0); }
[ "static void FUNC_0(RAMBlock *VAR_0)\n{", "if (VAR_0->flags & RAM_PREALLOC) {", ";", "} else if (xen_enabled()) {", "xen_invalidate_map_cache_entry(VAR_0->host);", "#ifndef _WIN32\n} else if (VAR_0->fd >= 0) {", "munmap(VAR_0->host, VAR_0->max_length);", "close(VAR_0->fd);", "#endif\n} else {", "qemu_anon_ram_free(VAR_0->host, VAR_0->max_length);", "}", "g_free(VAR_0);", "}" ]
[ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13, 15 ], [ 17 ], [ 19 ], [ 21, 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ] ]
9,841
static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet) { const AVFrame *const p = pict; const int near = avctx->prediction_method; PutBitContext pb, pb2; GetBitContext gb; uint8_t *buf2, *zero, *cur, *last; JLSState *state; int i, size, ret; int comps; if (avctx->pix_fmt == AV_PIX_FMT_GRAY8 || avctx->pix_fmt == AV_PIX_FMT_GRAY16) comps = 1; else comps = 3; if ((ret = ff_alloc_packet(pkt, avctx->width * avctx->height * comps * 4 + FF_MIN_BUFFER_SIZE)) < 0) { av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n"); return ret; } buf2 = av_malloc(pkt->size); init_put_bits(&pb, pkt->data, pkt->size); init_put_bits(&pb2, buf2, pkt->size); /* write our own JPEG header, can't use mjpeg_picture_header */ put_marker(&pb, SOI); put_marker(&pb, SOF48); put_bits(&pb, 16, 8 + comps * 3); // header size depends on components put_bits(&pb, 8, (avctx->pix_fmt == AV_PIX_FMT_GRAY16) ? 16 : 8); // bpp put_bits(&pb, 16, avctx->height); put_bits(&pb, 16, avctx->width); put_bits(&pb, 8, comps); // components for (i = 1; i <= comps; i++) { put_bits(&pb, 8, i); // component ID put_bits(&pb, 8, 0x11); // subsampling: none put_bits(&pb, 8, 0); // Tiq, used by JPEG-LS ext } put_marker(&pb, SOS); put_bits(&pb, 16, 6 + comps * 2); put_bits(&pb, 8, comps); for (i = 1; i <= comps; i++) { put_bits(&pb, 8, i); // component ID put_bits(&pb, 8, 0); // mapping index: none } put_bits(&pb, 8, near); put_bits(&pb, 8, (comps > 1) ? 1 : 0); // interleaving: 0 - plane, 1 - line put_bits(&pb, 8, 0); // point transform: none state = av_mallocz(sizeof(JLSState)); /* initialize JPEG-LS state from JPEG parameters */ state->near = near; state->bpp = (avctx->pix_fmt == AV_PIX_FMT_GRAY16) ? 16 : 8; ff_jpegls_reset_coding_parameters(state, 0); ff_jpegls_init_state(state); ls_store_lse(state, &pb); zero = av_mallocz(p->linesize[0]); last = zero; cur = p->data[0]; if (avctx->pix_fmt == AV_PIX_FMT_GRAY8) { int t = 0; for (i = 0; i < avctx->height; i++) { ls_encode_line(state, &pb2, last, cur, t, avctx->width, 1, 0, 8); t = last[0]; last = cur; cur += p->linesize[0]; } } else if (avctx->pix_fmt == AV_PIX_FMT_GRAY16) { int t = 0; for (i = 0; i < avctx->height; i++) { ls_encode_line(state, &pb2, last, cur, t, avctx->width, 1, 0, 16); t = *((uint16_t *)last); last = cur; cur += p->linesize[0]; } } else if (avctx->pix_fmt == AV_PIX_FMT_RGB24) { int j, width; int Rc[3] = { 0, 0, 0 }; width = avctx->width * 3; for (i = 0; i < avctx->height; i++) { for (j = 0; j < 3; j++) { ls_encode_line(state, &pb2, last + j, cur + j, Rc[j], width, 3, j, 8); Rc[j] = last[j]; } last = cur; cur += p->linesize[0]; } } else if (avctx->pix_fmt == AV_PIX_FMT_BGR24) { int j, width; int Rc[3] = { 0, 0, 0 }; width = avctx->width * 3; for (i = 0; i < avctx->height; i++) { for (j = 2; j >= 0; j--) { ls_encode_line(state, &pb2, last + j, cur + j, Rc[j], width, 3, j, 8); Rc[j] = last[j]; } last = cur; cur += p->linesize[0]; } } av_free(zero); av_free(state); /* the specification says that after doing 0xff escaping unused bits in * the last byte must be set to 0, so just append 7 "optional" zero-bits * to avoid special-casing. */ put_bits(&pb2, 7, 0); size = put_bits_count(&pb2); flush_put_bits(&pb2); /* do escape coding */ init_get_bits(&gb, buf2, size); size -= 7; while (get_bits_count(&gb) < size) { int v; v = get_bits(&gb, 8); put_bits(&pb, 8, v); if (v == 0xFF) { v = get_bits(&gb, 7); put_bits(&pb, 8, v); } } avpriv_align_put_bits(&pb); av_free(buf2); /* End of image */ put_marker(&pb, EOI); flush_put_bits(&pb); emms_c(); pkt->size = put_bits_count(&pb) >> 3; pkt->flags |= AV_PKT_FLAG_KEY; *got_packet = 1; return 0; }
true
FFmpeg
3919a4572690894d0a7ad4170d699c52b4748194
static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet) { const AVFrame *const p = pict; const int near = avctx->prediction_method; PutBitContext pb, pb2; GetBitContext gb; uint8_t *buf2, *zero, *cur, *last; JLSState *state; int i, size, ret; int comps; if (avctx->pix_fmt == AV_PIX_FMT_GRAY8 || avctx->pix_fmt == AV_PIX_FMT_GRAY16) comps = 1; else comps = 3; if ((ret = ff_alloc_packet(pkt, avctx->width * avctx->height * comps * 4 + FF_MIN_BUFFER_SIZE)) < 0) { av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n"); return ret; } buf2 = av_malloc(pkt->size); init_put_bits(&pb, pkt->data, pkt->size); init_put_bits(&pb2, buf2, pkt->size); put_marker(&pb, SOI); put_marker(&pb, SOF48); put_bits(&pb, 16, 8 + comps * 3); put_bits(&pb, 8, (avctx->pix_fmt == AV_PIX_FMT_GRAY16) ? 16 : 8); put_bits(&pb, 16, avctx->height); put_bits(&pb, 16, avctx->width); put_bits(&pb, 8, comps); for (i = 1; i <= comps; i++) { put_bits(&pb, 8, i); put_bits(&pb, 8, 0x11); put_bits(&pb, 8, 0); } put_marker(&pb, SOS); put_bits(&pb, 16, 6 + comps * 2); put_bits(&pb, 8, comps); for (i = 1; i <= comps; i++) { put_bits(&pb, 8, i); put_bits(&pb, 8, 0); } put_bits(&pb, 8, near); put_bits(&pb, 8, (comps > 1) ? 1 : 0); put_bits(&pb, 8, 0); state = av_mallocz(sizeof(JLSState)); state->near = near; state->bpp = (avctx->pix_fmt == AV_PIX_FMT_GRAY16) ? 16 : 8; ff_jpegls_reset_coding_parameters(state, 0); ff_jpegls_init_state(state); ls_store_lse(state, &pb); zero = av_mallocz(p->linesize[0]); last = zero; cur = p->data[0]; if (avctx->pix_fmt == AV_PIX_FMT_GRAY8) { int t = 0; for (i = 0; i < avctx->height; i++) { ls_encode_line(state, &pb2, last, cur, t, avctx->width, 1, 0, 8); t = last[0]; last = cur; cur += p->linesize[0]; } } else if (avctx->pix_fmt == AV_PIX_FMT_GRAY16) { int t = 0; for (i = 0; i < avctx->height; i++) { ls_encode_line(state, &pb2, last, cur, t, avctx->width, 1, 0, 16); t = *((uint16_t *)last); last = cur; cur += p->linesize[0]; } } else if (avctx->pix_fmt == AV_PIX_FMT_RGB24) { int j, width; int Rc[3] = { 0, 0, 0 }; width = avctx->width * 3; for (i = 0; i < avctx->height; i++) { for (j = 0; j < 3; j++) { ls_encode_line(state, &pb2, last + j, cur + j, Rc[j], width, 3, j, 8); Rc[j] = last[j]; } last = cur; cur += p->linesize[0]; } } else if (avctx->pix_fmt == AV_PIX_FMT_BGR24) { int j, width; int Rc[3] = { 0, 0, 0 }; width = avctx->width * 3; for (i = 0; i < avctx->height; i++) { for (j = 2; j >= 0; j--) { ls_encode_line(state, &pb2, last + j, cur + j, Rc[j], width, 3, j, 8); Rc[j] = last[j]; } last = cur; cur += p->linesize[0]; } } av_free(zero); av_free(state); put_bits(&pb2, 7, 0); size = put_bits_count(&pb2); flush_put_bits(&pb2); init_get_bits(&gb, buf2, size); size -= 7; while (get_bits_count(&gb) < size) { int v; v = get_bits(&gb, 8); put_bits(&pb, 8, v); if (v == 0xFF) { v = get_bits(&gb, 7); put_bits(&pb, 8, v); } } avpriv_align_put_bits(&pb); av_free(buf2); put_marker(&pb, EOI); flush_put_bits(&pb); emms_c(); pkt->size = put_bits_count(&pb) >> 3; pkt->flags |= AV_PKT_FLAG_KEY; *got_packet = 1; return 0; }
{ "code": [ " uint8_t *buf2, *zero, *cur, *last;", " zero = av_mallocz(p->linesize[0]);", " last = zero;", " av_free(zero);", " av_free(state);", " av_free(buf2);" ], "line_no": [ 15, 127, 129, 229, 231, 273 ] }
static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1, const AVFrame *VAR_2, int *VAR_3) { const AVFrame *const VAR_4 = VAR_2; const int VAR_5 = VAR_0->prediction_method; PutBitContext pb, pb2; GetBitContext gb; uint8_t *buf2, *zero, *cur, *last; JLSState *state; int VAR_6, VAR_7, VAR_8; int VAR_9; if (VAR_0->pix_fmt == AV_PIX_FMT_GRAY8 || VAR_0->pix_fmt == AV_PIX_FMT_GRAY16) VAR_9 = 1; else VAR_9 = 3; if ((VAR_8 = ff_alloc_packet(VAR_1, VAR_0->VAR_14 * VAR_0->height * VAR_9 * 4 + FF_MIN_BUFFER_SIZE)) < 0) { av_log(VAR_0, AV_LOG_ERROR, "Error getting output packet.\n"); return VAR_8; } buf2 = av_malloc(VAR_1->VAR_7); init_put_bits(&pb, VAR_1->data, VAR_1->VAR_7); init_put_bits(&pb2, buf2, VAR_1->VAR_7); put_marker(&pb, SOI); put_marker(&pb, SOF48); put_bits(&pb, 16, 8 + VAR_9 * 3); put_bits(&pb, 8, (VAR_0->pix_fmt == AV_PIX_FMT_GRAY16) ? 16 : 8); put_bits(&pb, 16, VAR_0->height); put_bits(&pb, 16, VAR_0->VAR_14); put_bits(&pb, 8, VAR_9); for (VAR_6 = 1; VAR_6 <= VAR_9; VAR_6++) { put_bits(&pb, 8, VAR_6); put_bits(&pb, 8, 0x11); put_bits(&pb, 8, 0); } put_marker(&pb, SOS); put_bits(&pb, 16, 6 + VAR_9 * 2); put_bits(&pb, 8, VAR_9); for (VAR_6 = 1; VAR_6 <= VAR_9; VAR_6++) { put_bits(&pb, 8, VAR_6); put_bits(&pb, 8, 0); } put_bits(&pb, 8, VAR_5); put_bits(&pb, 8, (VAR_9 > 1) ? 1 : 0); put_bits(&pb, 8, 0); state = av_mallocz(sizeof(JLSState)); state->VAR_5 = VAR_5; state->bpp = (VAR_0->pix_fmt == AV_PIX_FMT_GRAY16) ? 16 : 8; ff_jpegls_reset_coding_parameters(state, 0); ff_jpegls_init_state(state); ls_store_lse(state, &pb); zero = av_mallocz(VAR_4->linesize[0]); last = zero; cur = VAR_4->data[0]; if (VAR_0->pix_fmt == AV_PIX_FMT_GRAY8) { int VAR_11 = 0; for (VAR_6 = 0; VAR_6 < VAR_0->height; VAR_6++) { ls_encode_line(state, &pb2, last, cur, VAR_11, VAR_0->VAR_14, 1, 0, 8); VAR_11 = last[0]; last = cur; cur += VAR_4->linesize[0]; } } else if (VAR_0->pix_fmt == AV_PIX_FMT_GRAY16) { int VAR_11 = 0; for (VAR_6 = 0; VAR_6 < VAR_0->height; VAR_6++) { ls_encode_line(state, &pb2, last, cur, VAR_11, VAR_0->VAR_14, 1, 0, 16); VAR_11 = *((uint16_t *)last); last = cur; cur += VAR_4->linesize[0]; } } else if (VAR_0->pix_fmt == AV_PIX_FMT_RGB24) { int VAR_14, VAR_14; int VAR_14[3] = { 0, 0, 0 }; VAR_14 = VAR_0->VAR_14 * 3; for (VAR_6 = 0; VAR_6 < VAR_0->height; VAR_6++) { for (VAR_14 = 0; VAR_14 < 3; VAR_14++) { ls_encode_line(state, &pb2, last + VAR_14, cur + VAR_14, VAR_14[VAR_14], VAR_14, 3, VAR_14, 8); VAR_14[VAR_14] = last[VAR_14]; } last = cur; cur += VAR_4->linesize[0]; } } else if (VAR_0->pix_fmt == AV_PIX_FMT_BGR24) { int VAR_14, VAR_14; int VAR_14[3] = { 0, 0, 0 }; VAR_14 = VAR_0->VAR_14 * 3; for (VAR_6 = 0; VAR_6 < VAR_0->height; VAR_6++) { for (VAR_14 = 2; VAR_14 >= 0; VAR_14--) { ls_encode_line(state, &pb2, last + VAR_14, cur + VAR_14, VAR_14[VAR_14], VAR_14, 3, VAR_14, 8); VAR_14[VAR_14] = last[VAR_14]; } last = cur; cur += VAR_4->linesize[0]; } } av_free(zero); av_free(state); put_bits(&pb2, 7, 0); VAR_7 = put_bits_count(&pb2); flush_put_bits(&pb2); init_get_bits(&gb, buf2, VAR_7); VAR_7 -= 7; while (get_bits_count(&gb) < VAR_7) { int VAR_14; VAR_14 = get_bits(&gb, 8); put_bits(&pb, 8, VAR_14); if (VAR_14 == 0xFF) { VAR_14 = get_bits(&gb, 7); put_bits(&pb, 8, VAR_14); } } avpriv_align_put_bits(&pb); av_free(buf2); put_marker(&pb, EOI); flush_put_bits(&pb); emms_c(); VAR_1->VAR_7 = put_bits_count(&pb) >> 3; VAR_1->flags |= AV_PKT_FLAG_KEY; *VAR_3 = 1; return 0; }
[ "static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,\nconst AVFrame *VAR_2, int *VAR_3)\n{", "const AVFrame *const VAR_4 = VAR_2;", "const int VAR_5 = VAR_0->prediction_method;", "PutBitContext pb, pb2;", "GetBitContext gb;", "uint8_t *buf2, *zero, *cur, *last;", "JLSState *state;", "int VAR_6, VAR_7, VAR_8;", "int VAR_9;", "if (VAR_0->pix_fmt == AV_PIX_FMT_GRAY8 ||\nVAR_0->pix_fmt == AV_PIX_FMT_GRAY16)\nVAR_9 = 1;", "else\nVAR_9 = 3;", "if ((VAR_8 = ff_alloc_packet(VAR_1, VAR_0->VAR_14 * VAR_0->height * VAR_9 * 4 +\nFF_MIN_BUFFER_SIZE)) < 0) {", "av_log(VAR_0, AV_LOG_ERROR, \"Error getting output packet.\\n\");", "return VAR_8;", "}", "buf2 = av_malloc(VAR_1->VAR_7);", "init_put_bits(&pb, VAR_1->data, VAR_1->VAR_7);", "init_put_bits(&pb2, buf2, VAR_1->VAR_7);", "put_marker(&pb, SOI);", "put_marker(&pb, SOF48);", "put_bits(&pb, 16, 8 + VAR_9 * 3);", "put_bits(&pb, 8, (VAR_0->pix_fmt == AV_PIX_FMT_GRAY16) ? 16 : 8);", "put_bits(&pb, 16, VAR_0->height);", "put_bits(&pb, 16, VAR_0->VAR_14);", "put_bits(&pb, 8, VAR_9);", "for (VAR_6 = 1; VAR_6 <= VAR_9; VAR_6++) {", "put_bits(&pb, 8, VAR_6);", "put_bits(&pb, 8, 0x11);", "put_bits(&pb, 8, 0);", "}", "put_marker(&pb, SOS);", "put_bits(&pb, 16, 6 + VAR_9 * 2);", "put_bits(&pb, 8, VAR_9);", "for (VAR_6 = 1; VAR_6 <= VAR_9; VAR_6++) {", "put_bits(&pb, 8, VAR_6);", "put_bits(&pb, 8, 0);", "}", "put_bits(&pb, 8, VAR_5);", "put_bits(&pb, 8, (VAR_9 > 1) ? 1 : 0);", "put_bits(&pb, 8, 0);", "state = av_mallocz(sizeof(JLSState));", "state->VAR_5 = VAR_5;", "state->bpp = (VAR_0->pix_fmt == AV_PIX_FMT_GRAY16) ? 16 : 8;", "ff_jpegls_reset_coding_parameters(state, 0);", "ff_jpegls_init_state(state);", "ls_store_lse(state, &pb);", "zero = av_mallocz(VAR_4->linesize[0]);", "last = zero;", "cur = VAR_4->data[0];", "if (VAR_0->pix_fmt == AV_PIX_FMT_GRAY8) {", "int VAR_11 = 0;", "for (VAR_6 = 0; VAR_6 < VAR_0->height; VAR_6++) {", "ls_encode_line(state, &pb2, last, cur, VAR_11, VAR_0->VAR_14, 1, 0, 8);", "VAR_11 = last[0];", "last = cur;", "cur += VAR_4->linesize[0];", "}", "} else if (VAR_0->pix_fmt == AV_PIX_FMT_GRAY16) {", "int VAR_11 = 0;", "for (VAR_6 = 0; VAR_6 < VAR_0->height; VAR_6++) {", "ls_encode_line(state, &pb2, last, cur, VAR_11, VAR_0->VAR_14, 1, 0, 16);", "VAR_11 = *((uint16_t *)last);", "last = cur;", "cur += VAR_4->linesize[0];", "}", "} else if (VAR_0->pix_fmt == AV_PIX_FMT_RGB24) {", "int VAR_14, VAR_14;", "int VAR_14[3] = { 0, 0, 0 };", "VAR_14 = VAR_0->VAR_14 * 3;", "for (VAR_6 = 0; VAR_6 < VAR_0->height; VAR_6++) {", "for (VAR_14 = 0; VAR_14 < 3; VAR_14++) {", "ls_encode_line(state, &pb2, last + VAR_14, cur + VAR_14, VAR_14[VAR_14],\nVAR_14, 3, VAR_14, 8);", "VAR_14[VAR_14] = last[VAR_14];", "}", "last = cur;", "cur += VAR_4->linesize[0];", "}", "} else if (VAR_0->pix_fmt == AV_PIX_FMT_BGR24) {", "int VAR_14, VAR_14;", "int VAR_14[3] = { 0, 0, 0 };", "VAR_14 = VAR_0->VAR_14 * 3;", "for (VAR_6 = 0; VAR_6 < VAR_0->height; VAR_6++) {", "for (VAR_14 = 2; VAR_14 >= 0; VAR_14--) {", "ls_encode_line(state, &pb2, last + VAR_14, cur + VAR_14, VAR_14[VAR_14],\nVAR_14, 3, VAR_14, 8);", "VAR_14[VAR_14] = last[VAR_14];", "}", "last = cur;", "cur += VAR_4->linesize[0];", "}", "}", "av_free(zero);", "av_free(state);", "put_bits(&pb2, 7, 0);", "VAR_7 = put_bits_count(&pb2);", "flush_put_bits(&pb2);", "init_get_bits(&gb, buf2, VAR_7);", "VAR_7 -= 7;", "while (get_bits_count(&gb) < VAR_7) {", "int VAR_14;", "VAR_14 = get_bits(&gb, 8);", "put_bits(&pb, 8, VAR_14);", "if (VAR_14 == 0xFF) {", "VAR_14 = get_bits(&gb, 7);", "put_bits(&pb, 8, VAR_14);", "}", "}", "avpriv_align_put_bits(&pb);", "av_free(buf2);", "put_marker(&pb, EOI);", "flush_put_bits(&pb);", "emms_c();", "VAR_1->VAR_7 = put_bits_count(&pb) >> 3;", "VAR_1->flags |= AV_PKT_FLAG_KEY;", "*VAR_3 = 1;", "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, 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, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 25, 27, 29 ], [ 31, 33 ], [ 37, 39 ], [ 41 ], [ 43 ], [ 45 ], [ 49 ], [ 53 ], [ 55 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 109 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 123 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 153 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 177 ], [ 179 ], [ 181 ], [ 183, 185 ], [ 187 ], [ 189 ], [ 191 ], [ 193 ], [ 195 ], [ 197 ], [ 199 ], [ 201 ], [ 205 ], [ 207 ], [ 209 ], [ 211, 213 ], [ 215 ], [ 217 ], [ 219 ], [ 221 ], [ 223 ], [ 225 ], [ 229 ], [ 231 ], [ 241 ], [ 243 ], [ 245 ], [ 249 ], [ 251 ], [ 253 ], [ 255 ], [ 257 ], [ 259 ], [ 261 ], [ 263 ], [ 265 ], [ 267 ], [ 269 ], [ 271 ], [ 273 ], [ 279 ], [ 281 ], [ 285 ], [ 289 ], [ 291 ], [ 293 ], [ 295 ], [ 297 ] ]
9,843
static int bmp_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; BMPContext *s = avctx->priv_data; AVFrame *picture = data; AVFrame *p = &s->picture; unsigned int fsize, hsize; int width, height; unsigned int depth; BiCompression comp; unsigned int ihsize; int i, j, n, linesize; uint32_t rgb[3]; uint32_t alpha = 0; uint8_t *ptr; int dsize; const uint8_t *buf0 = buf; GetByteContext gb; if(buf_size < 14){ av_log(avctx, AV_LOG_ERROR, "buf size too small (%d)\n", buf_size); return -1; } if(bytestream_get_byte(&buf) != 'B' || bytestream_get_byte(&buf) != 'M') { av_log(avctx, AV_LOG_ERROR, "bad magic number\n"); return -1; } fsize = bytestream_get_le32(&buf); if(buf_size < fsize){ av_log(avctx, AV_LOG_ERROR, "not enough data (%d < %d), trying to decode anyway\n", buf_size, fsize); fsize = buf_size; } buf += 2; /* reserved1 */ buf += 2; /* reserved2 */ hsize = bytestream_get_le32(&buf); /* header size */ ihsize = bytestream_get_le32(&buf); /* more header size */ if(ihsize + 14 > hsize){ av_log(avctx, AV_LOG_ERROR, "invalid header size %d\n", hsize); return -1; } /* sometimes file size is set to some headers size, set a real size in that case */ if(fsize == 14 || fsize == ihsize + 14) fsize = buf_size - 2; if(fsize <= hsize){ av_log(avctx, AV_LOG_ERROR, "declared file size is less than header size (%d < %d)\n", fsize, hsize); return -1; } switch(ihsize){ case 40: // windib case 56: // windib v3 case 64: // OS/2 v2 case 108: // windib v4 case 124: // windib v5 width = bytestream_get_le32(&buf); height = bytestream_get_le32(&buf); break; case 12: // OS/2 v1 width = bytestream_get_le16(&buf); height = bytestream_get_le16(&buf); break; default: av_log(avctx, AV_LOG_ERROR, "unsupported BMP file, patch welcome\n"); return -1; } if(bytestream_get_le16(&buf) != 1){ /* planes */ av_log(avctx, AV_LOG_ERROR, "invalid BMP header\n"); return -1; } depth = bytestream_get_le16(&buf); if (ihsize >= 40) comp = bytestream_get_le32(&buf); else comp = BMP_RGB; if(comp != BMP_RGB && comp != BMP_BITFIELDS && comp != BMP_RLE4 && comp != BMP_RLE8){ av_log(avctx, AV_LOG_ERROR, "BMP coding %d not supported\n", comp); return -1; } if(comp == BMP_BITFIELDS){ buf += 20; rgb[0] = bytestream_get_le32(&buf); rgb[1] = bytestream_get_le32(&buf); rgb[2] = bytestream_get_le32(&buf); alpha = bytestream_get_le32(&buf); } avctx->width = width; avctx->height = height > 0? height: -height; avctx->pix_fmt = AV_PIX_FMT_NONE; switch(depth){ case 32: if(comp == BMP_BITFIELDS){ if (rgb[0] == 0xFF000000 && rgb[1] == 0x00FF0000 && rgb[2] == 0x0000FF00) avctx->pix_fmt = alpha ? AV_PIX_FMT_ABGR : AV_PIX_FMT_0BGR; else if (rgb[0] == 0x00FF0000 && rgb[1] == 0x0000FF00 && rgb[2] == 0x000000FF) avctx->pix_fmt = alpha ? AV_PIX_FMT_BGRA : AV_PIX_FMT_BGR0; else if (rgb[0] == 0x0000FF00 && rgb[1] == 0x00FF0000 && rgb[2] == 0xFF000000) avctx->pix_fmt = alpha ? AV_PIX_FMT_ARGB : AV_PIX_FMT_0RGB; else if (rgb[0] == 0x000000FF && rgb[1] == 0x0000FF00 && rgb[2] == 0x00FF0000) avctx->pix_fmt = alpha ? AV_PIX_FMT_RGBA : AV_PIX_FMT_RGB0; else { av_log(avctx, AV_LOG_ERROR, "Unknown bitfields %0X %0X %0X\n", rgb[0], rgb[1], rgb[2]); return AVERROR(EINVAL); } } else { avctx->pix_fmt = AV_PIX_FMT_BGRA; } break; case 24: avctx->pix_fmt = AV_PIX_FMT_BGR24; break; case 16: if(comp == BMP_RGB) avctx->pix_fmt = AV_PIX_FMT_RGB555; else if (comp == BMP_BITFIELDS) { if (rgb[0] == 0xF800 && rgb[1] == 0x07E0 && rgb[2] == 0x001F) avctx->pix_fmt = AV_PIX_FMT_RGB565; else if (rgb[0] == 0x7C00 && rgb[1] == 0x03E0 && rgb[2] == 0x001F) avctx->pix_fmt = AV_PIX_FMT_RGB555; else if (rgb[0] == 0x0F00 && rgb[1] == 0x00F0 && rgb[2] == 0x000F) avctx->pix_fmt = AV_PIX_FMT_RGB444; else { av_log(avctx, AV_LOG_ERROR, "Unknown bitfields %0X %0X %0X\n", rgb[0], rgb[1], rgb[2]); return AVERROR(EINVAL); } } break; case 8: if(hsize - ihsize - 14 > 0) avctx->pix_fmt = AV_PIX_FMT_PAL8; else avctx->pix_fmt = AV_PIX_FMT_GRAY8; break; case 1: case 4: if(hsize - ihsize - 14 > 0){ avctx->pix_fmt = AV_PIX_FMT_PAL8; }else{ av_log(avctx, AV_LOG_ERROR, "Unknown palette for %d-colour BMP\n", 1<<depth); return -1; } break; default: av_log(avctx, AV_LOG_ERROR, "depth %d not supported\n", depth); return -1; } if(avctx->pix_fmt == AV_PIX_FMT_NONE){ av_log(avctx, AV_LOG_ERROR, "unsupported pixel format\n"); return -1; } if(p->data[0]) avctx->release_buffer(avctx, p); p->reference = 0; if(avctx->get_buffer(avctx, p) < 0){ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return -1; } p->pict_type = AV_PICTURE_TYPE_I; p->key_frame = 1; buf = buf0 + hsize; dsize = buf_size - hsize; /* Line size in file multiple of 4 */ n = ((avctx->width * depth + 31) / 8) & ~3; if(n * avctx->height > dsize && comp != BMP_RLE4 && comp != BMP_RLE8){ av_log(avctx, AV_LOG_ERROR, "not enough data (%d < %d)\n", dsize, n * avctx->height); return -1; } // RLE may skip decoding some picture areas, so blank picture before decoding if(comp == BMP_RLE4 || comp == BMP_RLE8) memset(p->data[0], 0, avctx->height * p->linesize[0]); if(height > 0){ ptr = p->data[0] + (avctx->height - 1) * p->linesize[0]; linesize = -p->linesize[0]; } else { ptr = p->data[0]; linesize = p->linesize[0]; } if(avctx->pix_fmt == AV_PIX_FMT_PAL8){ int colors = 1 << depth; memset(p->data[1], 0, 1024); if(ihsize >= 36){ int t; buf = buf0 + 46; t = bytestream_get_le32(&buf); if(t < 0 || t > (1 << depth)){ av_log(avctx, AV_LOG_ERROR, "Incorrect number of colors - %X for bitdepth %d\n", t, depth); }else if(t){ colors = t; } } buf = buf0 + 14 + ihsize; //palette location if((hsize-ihsize-14) < (colors << 2)){ // OS/2 bitmap, 3 bytes per palette entry for(i = 0; i < colors; i++) ((uint32_t*)p->data[1])[i] = (0xff<<24) | bytestream_get_le24(&buf); }else{ for(i = 0; i < colors; i++) ((uint32_t*)p->data[1])[i] = 0xFFU << 24 | bytestream_get_le32(&buf); } buf = buf0 + hsize; } if(comp == BMP_RLE4 || comp == BMP_RLE8){ if(height < 0){ p->data[0] += p->linesize[0] * (avctx->height - 1); p->linesize[0] = -p->linesize[0]; } bytestream2_init(&gb, buf, dsize); ff_msrle_decode(avctx, (AVPicture*)p, depth, &gb); if(height < 0){ p->data[0] += p->linesize[0] * (avctx->height - 1); p->linesize[0] = -p->linesize[0]; } }else{ switch(depth){ case 1: for (i = 0; i < avctx->height; i++) { int j; for (j = 0; j < n; j++) { ptr[j*8+0] = buf[j] >> 7; ptr[j*8+1] = (buf[j] >> 6) & 1; ptr[j*8+2] = (buf[j] >> 5) & 1; ptr[j*8+3] = (buf[j] >> 4) & 1; ptr[j*8+4] = (buf[j] >> 3) & 1; ptr[j*8+5] = (buf[j] >> 2) & 1; ptr[j*8+6] = (buf[j] >> 1) & 1; ptr[j*8+7] = buf[j] & 1; } buf += n; ptr += linesize; } break; case 8: case 24: case 32: for(i = 0; i < avctx->height; i++){ memcpy(ptr, buf, n); buf += n; ptr += linesize; } break; case 4: for(i = 0; i < avctx->height; i++){ int j; for(j = 0; j < n; j++){ ptr[j*2+0] = (buf[j] >> 4) & 0xF; ptr[j*2+1] = buf[j] & 0xF; } buf += n; ptr += linesize; } break; case 16: for(i = 0; i < avctx->height; i++){ const uint16_t *src = (const uint16_t *) buf; uint16_t *dst = (uint16_t *) ptr; for(j = 0; j < avctx->width; j++) *dst++ = av_le2ne16(*src++); buf += n; ptr += linesize; } break; default: av_log(avctx, AV_LOG_ERROR, "BMP decoder is broken\n"); return -1; } } *picture = s->picture; *data_size = sizeof(AVPicture); return buf_size; }
true
FFmpeg
2fed05f53a881b64a02de7a324d67d8c029c6cf1
static int bmp_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; BMPContext *s = avctx->priv_data; AVFrame *picture = data; AVFrame *p = &s->picture; unsigned int fsize, hsize; int width, height; unsigned int depth; BiCompression comp; unsigned int ihsize; int i, j, n, linesize; uint32_t rgb[3]; uint32_t alpha = 0; uint8_t *ptr; int dsize; const uint8_t *buf0 = buf; GetByteContext gb; if(buf_size < 14){ av_log(avctx, AV_LOG_ERROR, "buf size too small (%d)\n", buf_size); return -1; } if(bytestream_get_byte(&buf) != 'B' || bytestream_get_byte(&buf) != 'M') { av_log(avctx, AV_LOG_ERROR, "bad magic number\n"); return -1; } fsize = bytestream_get_le32(&buf); if(buf_size < fsize){ av_log(avctx, AV_LOG_ERROR, "not enough data (%d < %d), trying to decode anyway\n", buf_size, fsize); fsize = buf_size; } buf += 2; buf += 2; hsize = bytestream_get_le32(&buf); ihsize = bytestream_get_le32(&buf); if(ihsize + 14 > hsize){ av_log(avctx, AV_LOG_ERROR, "invalid header size %d\n", hsize); return -1; } if(fsize == 14 || fsize == ihsize + 14) fsize = buf_size - 2; if(fsize <= hsize){ av_log(avctx, AV_LOG_ERROR, "declared file size is less than header size (%d < %d)\n", fsize, hsize); return -1; } switch(ihsize){ case 40: case 56: v3 case 64: case 108: v4 case 124: v5 width = bytestream_get_le32(&buf); height = bytestream_get_le32(&buf); break; case 12: width = bytestream_get_le16(&buf); height = bytestream_get_le16(&buf); break; default: av_log(avctx, AV_LOG_ERROR, "unsupported BMP file, patch welcome\n"); return -1; } if(bytestream_get_le16(&buf) != 1){ av_log(avctx, AV_LOG_ERROR, "invalid BMP header\n"); return -1; } depth = bytestream_get_le16(&buf); if (ihsize >= 40) comp = bytestream_get_le32(&buf); else comp = BMP_RGB; if(comp != BMP_RGB && comp != BMP_BITFIELDS && comp != BMP_RLE4 && comp != BMP_RLE8){ av_log(avctx, AV_LOG_ERROR, "BMP coding %d not supported\n", comp); return -1; } if(comp == BMP_BITFIELDS){ buf += 20; rgb[0] = bytestream_get_le32(&buf); rgb[1] = bytestream_get_le32(&buf); rgb[2] = bytestream_get_le32(&buf); alpha = bytestream_get_le32(&buf); } avctx->width = width; avctx->height = height > 0? height: -height; avctx->pix_fmt = AV_PIX_FMT_NONE; switch(depth){ case 32: if(comp == BMP_BITFIELDS){ if (rgb[0] == 0xFF000000 && rgb[1] == 0x00FF0000 && rgb[2] == 0x0000FF00) avctx->pix_fmt = alpha ? AV_PIX_FMT_ABGR : AV_PIX_FMT_0BGR; else if (rgb[0] == 0x00FF0000 && rgb[1] == 0x0000FF00 && rgb[2] == 0x000000FF) avctx->pix_fmt = alpha ? AV_PIX_FMT_BGRA : AV_PIX_FMT_BGR0; else if (rgb[0] == 0x0000FF00 && rgb[1] == 0x00FF0000 && rgb[2] == 0xFF000000) avctx->pix_fmt = alpha ? AV_PIX_FMT_ARGB : AV_PIX_FMT_0RGB; else if (rgb[0] == 0x000000FF && rgb[1] == 0x0000FF00 && rgb[2] == 0x00FF0000) avctx->pix_fmt = alpha ? AV_PIX_FMT_RGBA : AV_PIX_FMT_RGB0; else { av_log(avctx, AV_LOG_ERROR, "Unknown bitfields %0X %0X %0X\n", rgb[0], rgb[1], rgb[2]); return AVERROR(EINVAL); } } else { avctx->pix_fmt = AV_PIX_FMT_BGRA; } break; case 24: avctx->pix_fmt = AV_PIX_FMT_BGR24; break; case 16: if(comp == BMP_RGB) avctx->pix_fmt = AV_PIX_FMT_RGB555; else if (comp == BMP_BITFIELDS) { if (rgb[0] == 0xF800 && rgb[1] == 0x07E0 && rgb[2] == 0x001F) avctx->pix_fmt = AV_PIX_FMT_RGB565; else if (rgb[0] == 0x7C00 && rgb[1] == 0x03E0 && rgb[2] == 0x001F) avctx->pix_fmt = AV_PIX_FMT_RGB555; else if (rgb[0] == 0x0F00 && rgb[1] == 0x00F0 && rgb[2] == 0x000F) avctx->pix_fmt = AV_PIX_FMT_RGB444; else { av_log(avctx, AV_LOG_ERROR, "Unknown bitfields %0X %0X %0X\n", rgb[0], rgb[1], rgb[2]); return AVERROR(EINVAL); } } break; case 8: if(hsize - ihsize - 14 > 0) avctx->pix_fmt = AV_PIX_FMT_PAL8; else avctx->pix_fmt = AV_PIX_FMT_GRAY8; break; case 1: case 4: if(hsize - ihsize - 14 > 0){ avctx->pix_fmt = AV_PIX_FMT_PAL8; }else{ av_log(avctx, AV_LOG_ERROR, "Unknown palette for %d-colour BMP\n", 1<<depth); return -1; } break; default: av_log(avctx, AV_LOG_ERROR, "depth %d not supported\n", depth); return -1; } if(avctx->pix_fmt == AV_PIX_FMT_NONE){ av_log(avctx, AV_LOG_ERROR, "unsupported pixel format\n"); return -1; } if(p->data[0]) avctx->release_buffer(avctx, p); p->reference = 0; if(avctx->get_buffer(avctx, p) < 0){ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return -1; } p->pict_type = AV_PICTURE_TYPE_I; p->key_frame = 1; buf = buf0 + hsize; dsize = buf_size - hsize; n = ((avctx->width * depth + 31) / 8) & ~3; if(n * avctx->height > dsize && comp != BMP_RLE4 && comp != BMP_RLE8){ av_log(avctx, AV_LOG_ERROR, "not enough data (%d < %d)\n", dsize, n * avctx->height); return -1; } if(comp == BMP_RLE4 || comp == BMP_RLE8) memset(p->data[0], 0, avctx->height * p->linesize[0]); if(height > 0){ ptr = p->data[0] + (avctx->height - 1) * p->linesize[0]; linesize = -p->linesize[0]; } else { ptr = p->data[0]; linesize = p->linesize[0]; } if(avctx->pix_fmt == AV_PIX_FMT_PAL8){ int colors = 1 << depth; memset(p->data[1], 0, 1024); if(ihsize >= 36){ int t; buf = buf0 + 46; t = bytestream_get_le32(&buf); if(t < 0 || t > (1 << depth)){ av_log(avctx, AV_LOG_ERROR, "Incorrect number of colors - %X for bitdepth %d\n", t, depth); }else if(t){ colors = t; } } buf = buf0 + 14 + ihsize; if((hsize-ihsize-14) < (colors << 2)){ for(i = 0; i < colors; i++) ((uint32_t*)p->data[1])[i] = (0xff<<24) | bytestream_get_le24(&buf); }else{ for(i = 0; i < colors; i++) ((uint32_t*)p->data[1])[i] = 0xFFU << 24 | bytestream_get_le32(&buf); } buf = buf0 + hsize; } if(comp == BMP_RLE4 || comp == BMP_RLE8){ if(height < 0){ p->data[0] += p->linesize[0] * (avctx->height - 1); p->linesize[0] = -p->linesize[0]; } bytestream2_init(&gb, buf, dsize); ff_msrle_decode(avctx, (AVPicture*)p, depth, &gb); if(height < 0){ p->data[0] += p->linesize[0] * (avctx->height - 1); p->linesize[0] = -p->linesize[0]; } }else{ switch(depth){ case 1: for (i = 0; i < avctx->height; i++) { int j; for (j = 0; j < n; j++) { ptr[j*8+0] = buf[j] >> 7; ptr[j*8+1] = (buf[j] >> 6) & 1; ptr[j*8+2] = (buf[j] >> 5) & 1; ptr[j*8+3] = (buf[j] >> 4) & 1; ptr[j*8+4] = (buf[j] >> 3) & 1; ptr[j*8+5] = (buf[j] >> 2) & 1; ptr[j*8+6] = (buf[j] >> 1) & 1; ptr[j*8+7] = buf[j] & 1; } buf += n; ptr += linesize; } break; case 8: case 24: case 32: for(i = 0; i < avctx->height; i++){ memcpy(ptr, buf, n); buf += n; ptr += linesize; } break; case 4: for(i = 0; i < avctx->height; i++){ int j; for(j = 0; j < n; j++){ ptr[j*2+0] = (buf[j] >> 4) & 0xF; ptr[j*2+1] = buf[j] & 0xF; } buf += n; ptr += linesize; } break; case 16: for(i = 0; i < avctx->height; i++){ const uint16_t *src = (const uint16_t *) buf; uint16_t *dst = (uint16_t *) ptr; for(j = 0; j < avctx->width; j++) *dst++ = av_le2ne16(*src++); buf += n; ptr += linesize; } break; default: av_log(avctx, AV_LOG_ERROR, "BMP decoder is broken\n"); return -1; } } *picture = s->picture; *data_size = sizeof(AVPicture); return buf_size; }
{ "code": [ " ((uint32_t*)p->data[1])[i] = (0xff<<24) | bytestream_get_le24(&buf);" ], "line_no": [ 449 ] }
static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2, AVPacket *VAR_3) { const uint8_t *VAR_4 = VAR_3->VAR_1; int VAR_5 = VAR_3->size; BMPContext *s = VAR_0->priv_data; AVFrame *picture = VAR_1; AVFrame *p = &s->picture; unsigned int VAR_6, VAR_7; int VAR_8, VAR_9; unsigned int VAR_10; BiCompression comp; unsigned int VAR_11; int VAR_12, VAR_13, VAR_14, VAR_15; uint32_t rgb[3]; uint32_t alpha = 0; uint8_t *ptr; int VAR_16; const uint8_t *VAR_17 = VAR_4; GetByteContext gb; if(VAR_5 < 14){ av_log(VAR_0, AV_LOG_ERROR, "VAR_4 size too small (%d)\VAR_14", VAR_5); return -1; } if(bytestream_get_byte(&VAR_4) != 'B' || bytestream_get_byte(&VAR_4) != 'M') { av_log(VAR_0, AV_LOG_ERROR, "bad magic number\VAR_14"); return -1; } VAR_6 = bytestream_get_le32(&VAR_4); if(VAR_5 < VAR_6){ av_log(VAR_0, AV_LOG_ERROR, "not enough VAR_1 (%d < %d), trying to decode anyway\VAR_14", VAR_5, VAR_6); VAR_6 = VAR_5; } VAR_4 += 2; VAR_4 += 2; VAR_7 = bytestream_get_le32(&VAR_4); VAR_11 = bytestream_get_le32(&VAR_4); if(VAR_11 + 14 > VAR_7){ av_log(VAR_0, AV_LOG_ERROR, "invalid header size %d\VAR_14", VAR_7); return -1; } if(VAR_6 == 14 || VAR_6 == VAR_11 + 14) VAR_6 = VAR_5 - 2; if(VAR_6 <= VAR_7){ av_log(VAR_0, AV_LOG_ERROR, "declared file size is less than header size (%d < %d)\VAR_14", VAR_6, VAR_7); return -1; } switch(VAR_11){ case 40: case 56: v3 case 64: case 108: v4 case 124: v5 VAR_8 = bytestream_get_le32(&VAR_4); VAR_9 = bytestream_get_le32(&VAR_4); break; case 12: VAR_8 = bytestream_get_le16(&VAR_4); VAR_9 = bytestream_get_le16(&VAR_4); break; default: av_log(VAR_0, AV_LOG_ERROR, "unsupported BMP file, patch welcome\VAR_14"); return -1; } if(bytestream_get_le16(&VAR_4) != 1){ av_log(VAR_0, AV_LOG_ERROR, "invalid BMP header\VAR_14"); return -1; } VAR_10 = bytestream_get_le16(&VAR_4); if (VAR_11 >= 40) comp = bytestream_get_le32(&VAR_4); else comp = BMP_RGB; if(comp != BMP_RGB && comp != BMP_BITFIELDS && comp != BMP_RLE4 && comp != BMP_RLE8){ av_log(VAR_0, AV_LOG_ERROR, "BMP coding %d not supported\VAR_14", comp); return -1; } if(comp == BMP_BITFIELDS){ VAR_4 += 20; rgb[0] = bytestream_get_le32(&VAR_4); rgb[1] = bytestream_get_le32(&VAR_4); rgb[2] = bytestream_get_le32(&VAR_4); alpha = bytestream_get_le32(&VAR_4); } VAR_0->VAR_8 = VAR_8; VAR_0->VAR_9 = VAR_9 > 0? VAR_9: -VAR_9; VAR_0->pix_fmt = AV_PIX_FMT_NONE; switch(VAR_10){ case 32: if(comp == BMP_BITFIELDS){ if (rgb[0] == 0xFF000000 && rgb[1] == 0x00FF0000 && rgb[2] == 0x0000FF00) VAR_0->pix_fmt = alpha ? AV_PIX_FMT_ABGR : AV_PIX_FMT_0BGR; else if (rgb[0] == 0x00FF0000 && rgb[1] == 0x0000FF00 && rgb[2] == 0x000000FF) VAR_0->pix_fmt = alpha ? AV_PIX_FMT_BGRA : AV_PIX_FMT_BGR0; else if (rgb[0] == 0x0000FF00 && rgb[1] == 0x00FF0000 && rgb[2] == 0xFF000000) VAR_0->pix_fmt = alpha ? AV_PIX_FMT_ARGB : AV_PIX_FMT_0RGB; else if (rgb[0] == 0x000000FF && rgb[1] == 0x0000FF00 && rgb[2] == 0x00FF0000) VAR_0->pix_fmt = alpha ? AV_PIX_FMT_RGBA : AV_PIX_FMT_RGB0; else { av_log(VAR_0, AV_LOG_ERROR, "Unknown bitfields %0X %0X %0X\VAR_14", rgb[0], rgb[1], rgb[2]); return AVERROR(EINVAL); } } else { VAR_0->pix_fmt = AV_PIX_FMT_BGRA; } break; case 24: VAR_0->pix_fmt = AV_PIX_FMT_BGR24; break; case 16: if(comp == BMP_RGB) VAR_0->pix_fmt = AV_PIX_FMT_RGB555; else if (comp == BMP_BITFIELDS) { if (rgb[0] == 0xF800 && rgb[1] == 0x07E0 && rgb[2] == 0x001F) VAR_0->pix_fmt = AV_PIX_FMT_RGB565; else if (rgb[0] == 0x7C00 && rgb[1] == 0x03E0 && rgb[2] == 0x001F) VAR_0->pix_fmt = AV_PIX_FMT_RGB555; else if (rgb[0] == 0x0F00 && rgb[1] == 0x00F0 && rgb[2] == 0x000F) VAR_0->pix_fmt = AV_PIX_FMT_RGB444; else { av_log(VAR_0, AV_LOG_ERROR, "Unknown bitfields %0X %0X %0X\VAR_14", rgb[0], rgb[1], rgb[2]); return AVERROR(EINVAL); } } break; case 8: if(VAR_7 - VAR_11 - 14 > 0) VAR_0->pix_fmt = AV_PIX_FMT_PAL8; else VAR_0->pix_fmt = AV_PIX_FMT_GRAY8; break; case 1: case 4: if(VAR_7 - VAR_11 - 14 > 0){ VAR_0->pix_fmt = AV_PIX_FMT_PAL8; }else{ av_log(VAR_0, AV_LOG_ERROR, "Unknown palette for %d-colour BMP\VAR_14", 1<<VAR_10); return -1; } break; default: av_log(VAR_0, AV_LOG_ERROR, "VAR_10 %d not supported\VAR_14", VAR_10); return -1; } if(VAR_0->pix_fmt == AV_PIX_FMT_NONE){ av_log(VAR_0, AV_LOG_ERROR, "unsupported pixel format\VAR_14"); return -1; } if(p->VAR_1[0]) VAR_0->release_buffer(VAR_0, p); p->reference = 0; if(VAR_0->get_buffer(VAR_0, p) < 0){ av_log(VAR_0, AV_LOG_ERROR, "get_buffer() failed\VAR_14"); return -1; } p->pict_type = AV_PICTURE_TYPE_I; p->key_frame = 1; VAR_4 = VAR_17 + VAR_7; VAR_16 = VAR_5 - VAR_7; VAR_14 = ((VAR_0->VAR_8 * VAR_10 + 31) / 8) & ~3; if(VAR_14 * VAR_0->VAR_9 > VAR_16 && comp != BMP_RLE4 && comp != BMP_RLE8){ av_log(VAR_0, AV_LOG_ERROR, "not enough VAR_1 (%d < %d)\VAR_14", VAR_16, VAR_14 * VAR_0->VAR_9); return -1; } if(comp == BMP_RLE4 || comp == BMP_RLE8) memset(p->VAR_1[0], 0, VAR_0->VAR_9 * p->VAR_15[0]); if(VAR_9 > 0){ ptr = p->VAR_1[0] + (VAR_0->VAR_9 - 1) * p->VAR_15[0]; VAR_15 = -p->VAR_15[0]; } else { ptr = p->VAR_1[0]; VAR_15 = p->VAR_15[0]; } if(VAR_0->pix_fmt == AV_PIX_FMT_PAL8){ int VAR_18 = 1 << VAR_10; memset(p->VAR_1[1], 0, 1024); if(VAR_11 >= 36){ int VAR_19; VAR_4 = VAR_17 + 46; VAR_19 = bytestream_get_le32(&VAR_4); if(VAR_19 < 0 || VAR_19 > (1 << VAR_10)){ av_log(VAR_0, AV_LOG_ERROR, "Incorrect number of VAR_18 - %X for bitdepth %d\VAR_14", VAR_19, VAR_10); }else if(VAR_19){ VAR_18 = VAR_19; } } VAR_4 = VAR_17 + 14 + VAR_11; if((VAR_7-VAR_11-14) < (VAR_18 << 2)){ for(VAR_12 = 0; VAR_12 < VAR_18; VAR_12++) ((uint32_t*)p->VAR_1[1])[VAR_12] = (0xff<<24) | bytestream_get_le24(&VAR_4); }else{ for(VAR_12 = 0; VAR_12 < VAR_18; VAR_12++) ((uint32_t*)p->VAR_1[1])[VAR_12] = 0xFFU << 24 | bytestream_get_le32(&VAR_4); } VAR_4 = VAR_17 + VAR_7; } if(comp == BMP_RLE4 || comp == BMP_RLE8){ if(VAR_9 < 0){ p->VAR_1[0] += p->VAR_15[0] * (VAR_0->VAR_9 - 1); p->VAR_15[0] = -p->VAR_15[0]; } bytestream2_init(&gb, VAR_4, VAR_16); ff_msrle_decode(VAR_0, (AVPicture*)p, VAR_10, &gb); if(VAR_9 < 0){ p->VAR_1[0] += p->VAR_15[0] * (VAR_0->VAR_9 - 1); p->VAR_15[0] = -p->VAR_15[0]; } }else{ switch(VAR_10){ case 1: for (VAR_12 = 0; VAR_12 < VAR_0->VAR_9; VAR_12++) { int VAR_13; for (VAR_13 = 0; VAR_13 < VAR_14; VAR_13++) { ptr[VAR_13*8+0] = VAR_4[VAR_13] >> 7; ptr[VAR_13*8+1] = (VAR_4[VAR_13] >> 6) & 1; ptr[VAR_13*8+2] = (VAR_4[VAR_13] >> 5) & 1; ptr[VAR_13*8+3] = (VAR_4[VAR_13] >> 4) & 1; ptr[VAR_13*8+4] = (VAR_4[VAR_13] >> 3) & 1; ptr[VAR_13*8+5] = (VAR_4[VAR_13] >> 2) & 1; ptr[VAR_13*8+6] = (VAR_4[VAR_13] >> 1) & 1; ptr[VAR_13*8+7] = VAR_4[VAR_13] & 1; } VAR_4 += VAR_14; ptr += VAR_15; } break; case 8: case 24: case 32: for(VAR_12 = 0; VAR_12 < VAR_0->VAR_9; VAR_12++){ memcpy(ptr, VAR_4, VAR_14); VAR_4 += VAR_14; ptr += VAR_15; } break; case 4: for(VAR_12 = 0; VAR_12 < VAR_0->VAR_9; VAR_12++){ int VAR_13; for(VAR_13 = 0; VAR_13 < VAR_14; VAR_13++){ ptr[VAR_13*2+0] = (VAR_4[VAR_13] >> 4) & 0xF; ptr[VAR_13*2+1] = VAR_4[VAR_13] & 0xF; } VAR_4 += VAR_14; ptr += VAR_15; } break; case 16: for(VAR_12 = 0; VAR_12 < VAR_0->VAR_9; VAR_12++){ const uint16_t *src = (const uint16_t *) VAR_4; uint16_t *dst = (uint16_t *) ptr; for(VAR_13 = 0; VAR_13 < VAR_0->VAR_8; VAR_13++) *dst++ = av_le2ne16(*src++); VAR_4 += VAR_14; ptr += VAR_15; } break; default: av_log(VAR_0, AV_LOG_ERROR, "BMP decoder is broken\VAR_14"); return -1; } } *picture = s->picture; *VAR_2 = sizeof(AVPicture); return VAR_5; }
[ "static int FUNC_0(AVCodecContext *VAR_0,\nvoid *VAR_1, int *VAR_2,\nAVPacket *VAR_3)\n{", "const uint8_t *VAR_4 = VAR_3->VAR_1;", "int VAR_5 = VAR_3->size;", "BMPContext *s = VAR_0->priv_data;", "AVFrame *picture = VAR_1;", "AVFrame *p = &s->picture;", "unsigned int VAR_6, VAR_7;", "int VAR_8, VAR_9;", "unsigned int VAR_10;", "BiCompression comp;", "unsigned int VAR_11;", "int VAR_12, VAR_13, VAR_14, VAR_15;", "uint32_t rgb[3];", "uint32_t alpha = 0;", "uint8_t *ptr;", "int VAR_16;", "const uint8_t *VAR_17 = VAR_4;", "GetByteContext gb;", "if(VAR_5 < 14){", "av_log(VAR_0, AV_LOG_ERROR, \"VAR_4 size too small (%d)\\VAR_14\", VAR_5);", "return -1;", "}", "if(bytestream_get_byte(&VAR_4) != 'B' ||\nbytestream_get_byte(&VAR_4) != 'M') {", "av_log(VAR_0, AV_LOG_ERROR, \"bad magic number\\VAR_14\");", "return -1;", "}", "VAR_6 = bytestream_get_le32(&VAR_4);", "if(VAR_5 < VAR_6){", "av_log(VAR_0, AV_LOG_ERROR, \"not enough VAR_1 (%d < %d), trying to decode anyway\\VAR_14\",\nVAR_5, VAR_6);", "VAR_6 = VAR_5;", "}", "VAR_4 += 2;", "VAR_4 += 2;", "VAR_7 = bytestream_get_le32(&VAR_4);", "VAR_11 = bytestream_get_le32(&VAR_4);", "if(VAR_11 + 14 > VAR_7){", "av_log(VAR_0, AV_LOG_ERROR, \"invalid header size %d\\VAR_14\", VAR_7);", "return -1;", "}", "if(VAR_6 == 14 || VAR_6 == VAR_11 + 14)\nVAR_6 = VAR_5 - 2;", "if(VAR_6 <= VAR_7){", "av_log(VAR_0, AV_LOG_ERROR, \"declared file size is less than header size (%d < %d)\\VAR_14\",\nVAR_6, VAR_7);", "return -1;", "}", "switch(VAR_11){", "case 40:\ncase 56: v3\ncase 64:\ncase 108: v4\ncase 124: v5\nVAR_8 = bytestream_get_le32(&VAR_4);", "VAR_9 = bytestream_get_le32(&VAR_4);", "break;", "case 12:\nVAR_8 = bytestream_get_le16(&VAR_4);", "VAR_9 = bytestream_get_le16(&VAR_4);", "break;", "default:\nav_log(VAR_0, AV_LOG_ERROR, \"unsupported BMP file, patch welcome\\VAR_14\");", "return -1;", "}", "if(bytestream_get_le16(&VAR_4) != 1){", "av_log(VAR_0, AV_LOG_ERROR, \"invalid BMP header\\VAR_14\");", "return -1;", "}", "VAR_10 = bytestream_get_le16(&VAR_4);", "if (VAR_11 >= 40)\ncomp = bytestream_get_le32(&VAR_4);", "else\ncomp = BMP_RGB;", "if(comp != BMP_RGB && comp != BMP_BITFIELDS && comp != BMP_RLE4 && comp != BMP_RLE8){", "av_log(VAR_0, AV_LOG_ERROR, \"BMP coding %d not supported\\VAR_14\", comp);", "return -1;", "}", "if(comp == BMP_BITFIELDS){", "VAR_4 += 20;", "rgb[0] = bytestream_get_le32(&VAR_4);", "rgb[1] = bytestream_get_le32(&VAR_4);", "rgb[2] = bytestream_get_le32(&VAR_4);", "alpha = bytestream_get_le32(&VAR_4);", "}", "VAR_0->VAR_8 = VAR_8;", "VAR_0->VAR_9 = VAR_9 > 0? VAR_9: -VAR_9;", "VAR_0->pix_fmt = AV_PIX_FMT_NONE;", "switch(VAR_10){", "case 32:\nif(comp == BMP_BITFIELDS){", "if (rgb[0] == 0xFF000000 && rgb[1] == 0x00FF0000 && rgb[2] == 0x0000FF00)\nVAR_0->pix_fmt = alpha ? AV_PIX_FMT_ABGR : AV_PIX_FMT_0BGR;", "else if (rgb[0] == 0x00FF0000 && rgb[1] == 0x0000FF00 && rgb[2] == 0x000000FF)\nVAR_0->pix_fmt = alpha ? AV_PIX_FMT_BGRA : AV_PIX_FMT_BGR0;", "else if (rgb[0] == 0x0000FF00 && rgb[1] == 0x00FF0000 && rgb[2] == 0xFF000000)\nVAR_0->pix_fmt = alpha ? AV_PIX_FMT_ARGB : AV_PIX_FMT_0RGB;", "else if (rgb[0] == 0x000000FF && rgb[1] == 0x0000FF00 && rgb[2] == 0x00FF0000)\nVAR_0->pix_fmt = alpha ? AV_PIX_FMT_RGBA : AV_PIX_FMT_RGB0;", "else {", "av_log(VAR_0, AV_LOG_ERROR, \"Unknown bitfields %0X %0X %0X\\VAR_14\", rgb[0], rgb[1], rgb[2]);", "return AVERROR(EINVAL);", "}", "} else {", "VAR_0->pix_fmt = AV_PIX_FMT_BGRA;", "}", "break;", "case 24:\nVAR_0->pix_fmt = AV_PIX_FMT_BGR24;", "break;", "case 16:\nif(comp == BMP_RGB)\nVAR_0->pix_fmt = AV_PIX_FMT_RGB555;", "else if (comp == BMP_BITFIELDS) {", "if (rgb[0] == 0xF800 && rgb[1] == 0x07E0 && rgb[2] == 0x001F)\nVAR_0->pix_fmt = AV_PIX_FMT_RGB565;", "else if (rgb[0] == 0x7C00 && rgb[1] == 0x03E0 && rgb[2] == 0x001F)\nVAR_0->pix_fmt = AV_PIX_FMT_RGB555;", "else if (rgb[0] == 0x0F00 && rgb[1] == 0x00F0 && rgb[2] == 0x000F)\nVAR_0->pix_fmt = AV_PIX_FMT_RGB444;", "else {", "av_log(VAR_0, AV_LOG_ERROR, \"Unknown bitfields %0X %0X %0X\\VAR_14\", rgb[0], rgb[1], rgb[2]);", "return AVERROR(EINVAL);", "}", "}", "break;", "case 8:\nif(VAR_7 - VAR_11 - 14 > 0)\nVAR_0->pix_fmt = AV_PIX_FMT_PAL8;", "else\nVAR_0->pix_fmt = AV_PIX_FMT_GRAY8;", "break;", "case 1:\ncase 4:\nif(VAR_7 - VAR_11 - 14 > 0){", "VAR_0->pix_fmt = AV_PIX_FMT_PAL8;", "}else{", "av_log(VAR_0, AV_LOG_ERROR, \"Unknown palette for %d-colour BMP\\VAR_14\", 1<<VAR_10);", "return -1;", "}", "break;", "default:\nav_log(VAR_0, AV_LOG_ERROR, \"VAR_10 %d not supported\\VAR_14\", VAR_10);", "return -1;", "}", "if(VAR_0->pix_fmt == AV_PIX_FMT_NONE){", "av_log(VAR_0, AV_LOG_ERROR, \"unsupported pixel format\\VAR_14\");", "return -1;", "}", "if(p->VAR_1[0])\nVAR_0->release_buffer(VAR_0, p);", "p->reference = 0;", "if(VAR_0->get_buffer(VAR_0, p) < 0){", "av_log(VAR_0, AV_LOG_ERROR, \"get_buffer() failed\\VAR_14\");", "return -1;", "}", "p->pict_type = AV_PICTURE_TYPE_I;", "p->key_frame = 1;", "VAR_4 = VAR_17 + VAR_7;", "VAR_16 = VAR_5 - VAR_7;", "VAR_14 = ((VAR_0->VAR_8 * VAR_10 + 31) / 8) & ~3;", "if(VAR_14 * VAR_0->VAR_9 > VAR_16 && comp != BMP_RLE4 && comp != BMP_RLE8){", "av_log(VAR_0, AV_LOG_ERROR, \"not enough VAR_1 (%d < %d)\\VAR_14\",\nVAR_16, VAR_14 * VAR_0->VAR_9);", "return -1;", "}", "if(comp == BMP_RLE4 || comp == BMP_RLE8)\nmemset(p->VAR_1[0], 0, VAR_0->VAR_9 * p->VAR_15[0]);", "if(VAR_9 > 0){", "ptr = p->VAR_1[0] + (VAR_0->VAR_9 - 1) * p->VAR_15[0];", "VAR_15 = -p->VAR_15[0];", "} else {", "ptr = p->VAR_1[0];", "VAR_15 = p->VAR_15[0];", "}", "if(VAR_0->pix_fmt == AV_PIX_FMT_PAL8){", "int VAR_18 = 1 << VAR_10;", "memset(p->VAR_1[1], 0, 1024);", "if(VAR_11 >= 36){", "int VAR_19;", "VAR_4 = VAR_17 + 46;", "VAR_19 = bytestream_get_le32(&VAR_4);", "if(VAR_19 < 0 || VAR_19 > (1 << VAR_10)){", "av_log(VAR_0, AV_LOG_ERROR, \"Incorrect number of VAR_18 - %X for bitdepth %d\\VAR_14\", VAR_19, VAR_10);", "}else if(VAR_19){", "VAR_18 = VAR_19;", "}", "}", "VAR_4 = VAR_17 + 14 + VAR_11;", "if((VAR_7-VAR_11-14) < (VAR_18 << 2)){", "for(VAR_12 = 0; VAR_12 < VAR_18; VAR_12++)", "((uint32_t*)p->VAR_1[1])[VAR_12] = (0xff<<24) | bytestream_get_le24(&VAR_4);", "}else{", "for(VAR_12 = 0; VAR_12 < VAR_18; VAR_12++)", "((uint32_t*)p->VAR_1[1])[VAR_12] = 0xFFU << 24 | bytestream_get_le32(&VAR_4);", "}", "VAR_4 = VAR_17 + VAR_7;", "}", "if(comp == BMP_RLE4 || comp == BMP_RLE8){", "if(VAR_9 < 0){", "p->VAR_1[0] += p->VAR_15[0] * (VAR_0->VAR_9 - 1);", "p->VAR_15[0] = -p->VAR_15[0];", "}", "bytestream2_init(&gb, VAR_4, VAR_16);", "ff_msrle_decode(VAR_0, (AVPicture*)p, VAR_10, &gb);", "if(VAR_9 < 0){", "p->VAR_1[0] += p->VAR_15[0] * (VAR_0->VAR_9 - 1);", "p->VAR_15[0] = -p->VAR_15[0];", "}", "}else{", "switch(VAR_10){", "case 1:\nfor (VAR_12 = 0; VAR_12 < VAR_0->VAR_9; VAR_12++) {", "int VAR_13;", "for (VAR_13 = 0; VAR_13 < VAR_14; VAR_13++) {", "ptr[VAR_13*8+0] = VAR_4[VAR_13] >> 7;", "ptr[VAR_13*8+1] = (VAR_4[VAR_13] >> 6) & 1;", "ptr[VAR_13*8+2] = (VAR_4[VAR_13] >> 5) & 1;", "ptr[VAR_13*8+3] = (VAR_4[VAR_13] >> 4) & 1;", "ptr[VAR_13*8+4] = (VAR_4[VAR_13] >> 3) & 1;", "ptr[VAR_13*8+5] = (VAR_4[VAR_13] >> 2) & 1;", "ptr[VAR_13*8+6] = (VAR_4[VAR_13] >> 1) & 1;", "ptr[VAR_13*8+7] = VAR_4[VAR_13] & 1;", "}", "VAR_4 += VAR_14;", "ptr += VAR_15;", "}", "break;", "case 8:\ncase 24:\ncase 32:\nfor(VAR_12 = 0; VAR_12 < VAR_0->VAR_9; VAR_12++){", "memcpy(ptr, VAR_4, VAR_14);", "VAR_4 += VAR_14;", "ptr += VAR_15;", "}", "break;", "case 4:\nfor(VAR_12 = 0; VAR_12 < VAR_0->VAR_9; VAR_12++){", "int VAR_13;", "for(VAR_13 = 0; VAR_13 < VAR_14; VAR_13++){", "ptr[VAR_13*2+0] = (VAR_4[VAR_13] >> 4) & 0xF;", "ptr[VAR_13*2+1] = VAR_4[VAR_13] & 0xF;", "}", "VAR_4 += VAR_14;", "ptr += VAR_15;", "}", "break;", "case 16:\nfor(VAR_12 = 0; VAR_12 < VAR_0->VAR_9; VAR_12++){", "const uint16_t *src = (const uint16_t *) VAR_4;", "uint16_t *dst = (uint16_t *) ptr;", "for(VAR_13 = 0; VAR_13 < VAR_0->VAR_8; VAR_13++)", "*dst++ = av_le2ne16(*src++);", "VAR_4 += VAR_14;", "ptr += VAR_15;", "}", "break;", "default:\nav_log(VAR_0, AV_LOG_ERROR, \"BMP decoder is broken\\VAR_14\");", "return -1;", "}", "}", "*picture = s->picture;", "*VAR_2 = sizeof(AVPicture);", "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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 55, 57 ], [ 59 ], [ 61 ], [ 63 ], [ 67 ], [ 69 ], [ 71, 73 ], [ 75 ], [ 77 ], [ 81 ], [ 83 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 103, 105 ], [ 109 ], [ 111, 113 ], [ 115 ], [ 117 ], [ 121 ], [ 123, 125, 127, 129, 131, 133 ], [ 135 ], [ 137 ], [ 139, 141 ], [ 143 ], [ 145 ], [ 147, 149 ], [ 151 ], [ 153 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ], [ 167 ], [ 171, 173 ], [ 175, 177 ], [ 181 ], [ 183 ], [ 185 ], [ 187 ], [ 191 ], [ 193 ], [ 195 ], [ 197 ], [ 199 ], [ 201 ], [ 203 ], [ 207 ], [ 209 ], [ 213 ], [ 217 ], [ 219, 221 ], [ 223, 225 ], [ 227, 229 ], [ 231, 233 ], [ 235, 237 ], [ 239 ], [ 241 ], [ 243 ], [ 245 ], [ 247 ], [ 249 ], [ 251 ], [ 253 ], [ 255, 257 ], [ 259 ], [ 261, 263, 265 ], [ 267 ], [ 269, 271 ], [ 273, 275 ], [ 277, 279 ], [ 281 ], [ 283 ], [ 285 ], [ 287 ], [ 289 ], [ 291 ], [ 293, 295, 297 ], [ 299, 301 ], [ 303 ], [ 305, 307, 309 ], [ 311 ], [ 313 ], [ 315 ], [ 317 ], [ 319 ], [ 321 ], [ 323, 325 ], [ 327 ], [ 329 ], [ 333 ], [ 335 ], [ 337 ], [ 339 ], [ 343, 345 ], [ 349 ], [ 351 ], [ 353 ], [ 355 ], [ 357 ], [ 359 ], [ 361 ], [ 365 ], [ 367 ], [ 373 ], [ 377 ], [ 379, 381 ], [ 383 ], [ 385 ], [ 391, 393 ], [ 397 ], [ 399 ], [ 401 ], [ 403 ], [ 405 ], [ 407 ], [ 409 ], [ 413 ], [ 415 ], [ 419 ], [ 423 ], [ 425 ], [ 427 ], [ 429 ], [ 431 ], [ 433 ], [ 435 ], [ 437 ], [ 439 ], [ 441 ], [ 443 ], [ 445 ], [ 447 ], [ 449 ], [ 451 ], [ 453 ], [ 455 ], [ 457 ], [ 459 ], [ 461 ], [ 463 ], [ 465 ], [ 467 ], [ 469 ], [ 471 ], [ 473 ], [ 475 ], [ 477 ], [ 479 ], [ 481 ], [ 483 ], [ 485 ], [ 487 ], [ 489, 491 ], [ 493 ], [ 495 ], [ 497 ], [ 499 ], [ 501 ], [ 503 ], [ 505 ], [ 507 ], [ 509 ], [ 511 ], [ 513 ], [ 515 ], [ 517 ], [ 519 ], [ 521 ], [ 523, 525, 527, 529 ], [ 531 ], [ 533 ], [ 535 ], [ 537 ], [ 539 ], [ 541, 543 ], [ 545 ], [ 547 ], [ 549 ], [ 551 ], [ 553 ], [ 555 ], [ 557 ], [ 559 ], [ 561 ], [ 563, 565 ], [ 567 ], [ 569 ], [ 573 ], [ 575 ], [ 579 ], [ 581 ], [ 583 ], [ 585 ], [ 587, 589 ], [ 591 ], [ 593 ], [ 595 ], [ 599 ], [ 601 ], [ 605 ], [ 607 ] ]
9,844
static void raven_realize(PCIDevice *d, Error **errp) { RavenPCIState *s = RAVEN_PCI_DEVICE(d); char *filename; int bios_size = -1; d->config[0x0C] = 0x08; // cache_line_size d->config[0x0D] = 0x10; // latency_timer d->config[0x34] = 0x00; // capabilities_pointer memory_region_init_ram(&s->bios, OBJECT(s), "bios", BIOS_SIZE, &error_abort); memory_region_set_readonly(&s->bios, true); memory_region_add_subregion(get_system_memory(), (uint32_t)(-BIOS_SIZE), &s->bios); vmstate_register_ram_global(&s->bios); if (s->bios_name) { filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, s->bios_name); if (filename) { if (s->elf_machine != EM_NONE) { bios_size = load_elf(filename, NULL, NULL, NULL, NULL, NULL, 1, s->elf_machine, 0); } if (bios_size < 0) { bios_size = get_image_size(filename); if (bios_size > 0 && bios_size <= BIOS_SIZE) { hwaddr bios_addr; bios_size = (bios_size + 0xfff) & ~0xfff; bios_addr = (uint32_t)(-BIOS_SIZE); bios_size = load_image_targphys(filename, bios_addr, bios_size); } } } if (bios_size < 0 || bios_size > BIOS_SIZE) { hw_error("qemu: could not load bios image '%s'\n", s->bios_name); } g_free(filename); } }
true
qemu
f8ed85ac992c48814d916d5df4d44f9a971c5de4
static void raven_realize(PCIDevice *d, Error **errp) { RavenPCIState *s = RAVEN_PCI_DEVICE(d); char *filename; int bios_size = -1; d->config[0x0C] = 0x08; d->config[0x0D] = 0x10; d->config[0x34] = 0x00; memory_region_init_ram(&s->bios, OBJECT(s), "bios", BIOS_SIZE, &error_abort); memory_region_set_readonly(&s->bios, true); memory_region_add_subregion(get_system_memory(), (uint32_t)(-BIOS_SIZE), &s->bios); vmstate_register_ram_global(&s->bios); if (s->bios_name) { filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, s->bios_name); if (filename) { if (s->elf_machine != EM_NONE) { bios_size = load_elf(filename, NULL, NULL, NULL, NULL, NULL, 1, s->elf_machine, 0); } if (bios_size < 0) { bios_size = get_image_size(filename); if (bios_size > 0 && bios_size <= BIOS_SIZE) { hwaddr bios_addr; bios_size = (bios_size + 0xfff) & ~0xfff; bios_addr = (uint32_t)(-BIOS_SIZE); bios_size = load_image_targphys(filename, bios_addr, bios_size); } } } if (bios_size < 0 || bios_size > BIOS_SIZE) { hw_error("qemu: could not load bios image '%s'\n", s->bios_name); } g_free(filename); } }
{ "code": [ " &error_abort);", " &error_abort);", " &error_abort);", " &error_abort);", " &error_abort);", " &error_abort);", " &error_abort);", " &error_abort);", " &error_abort);", " &error_abort);", " &error_abort);", " &error_abort);", " &error_abort);", " &error_abort);", " &error_abort);", " &error_abort);", " &error_abort);", " &error_abort);", " &error_abort);", " &error_abort);", " &error_abort);", " &error_abort);", " &error_abort);", " &error_abort);", " &error_abort);", " &error_abort);", " &error_abort);", " &error_abort);", " &error_abort);", " &error_abort);", " &error_abort);", " &error_abort);", " &error_abort);", " &error_abort);", " &error_abort);", " &error_abort);", " &error_abort);", " &error_abort);", " &error_abort);", " &error_abort);", " &error_abort);", " &error_abort);", " &error_abort);", " &error_abort);", " &error_abort);", " &error_abort);", " &error_abort);", " &error_abort);", " &error_abort);" ], "line_no": [ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23 ] }
static void FUNC_0(PCIDevice *VAR_0, Error **VAR_1) { RavenPCIState *s = RAVEN_PCI_DEVICE(VAR_0); char *VAR_2; int VAR_3 = -1; VAR_0->config[0x0C] = 0x08; VAR_0->config[0x0D] = 0x10; VAR_0->config[0x34] = 0x00; memory_region_init_ram(&s->bios, OBJECT(s), "bios", BIOS_SIZE, &error_abort); memory_region_set_readonly(&s->bios, true); memory_region_add_subregion(get_system_memory(), (uint32_t)(-BIOS_SIZE), &s->bios); vmstate_register_ram_global(&s->bios); if (s->bios_name) { VAR_2 = qemu_find_file(QEMU_FILE_TYPE_BIOS, s->bios_name); if (VAR_2) { if (s->elf_machine != EM_NONE) { VAR_3 = load_elf(VAR_2, NULL, NULL, NULL, NULL, NULL, 1, s->elf_machine, 0); } if (VAR_3 < 0) { VAR_3 = get_image_size(VAR_2); if (VAR_3 > 0 && VAR_3 <= BIOS_SIZE) { hwaddr bios_addr; VAR_3 = (VAR_3 + 0xfff) & ~0xfff; bios_addr = (uint32_t)(-BIOS_SIZE); VAR_3 = load_image_targphys(VAR_2, bios_addr, VAR_3); } } } if (VAR_3 < 0 || VAR_3 > BIOS_SIZE) { hw_error("qemu: could not load bios image '%s'\n", s->bios_name); } g_free(VAR_2); } }
[ "static void FUNC_0(PCIDevice *VAR_0, Error **VAR_1)\n{", "RavenPCIState *s = RAVEN_PCI_DEVICE(VAR_0);", "char *VAR_2;", "int VAR_3 = -1;", "VAR_0->config[0x0C] = 0x08;", "VAR_0->config[0x0D] = 0x10;", "VAR_0->config[0x34] = 0x00;", "memory_region_init_ram(&s->bios, OBJECT(s), \"bios\", BIOS_SIZE,\n&error_abort);", "memory_region_set_readonly(&s->bios, true);", "memory_region_add_subregion(get_system_memory(), (uint32_t)(-BIOS_SIZE),\n&s->bios);", "vmstate_register_ram_global(&s->bios);", "if (s->bios_name) {", "VAR_2 = qemu_find_file(QEMU_FILE_TYPE_BIOS, s->bios_name);", "if (VAR_2) {", "if (s->elf_machine != EM_NONE) {", "VAR_3 = load_elf(VAR_2, NULL, NULL, NULL,\nNULL, NULL, 1, s->elf_machine, 0);", "}", "if (VAR_3 < 0) {", "VAR_3 = get_image_size(VAR_2);", "if (VAR_3 > 0 && VAR_3 <= BIOS_SIZE) {", "hwaddr bios_addr;", "VAR_3 = (VAR_3 + 0xfff) & ~0xfff;", "bios_addr = (uint32_t)(-BIOS_SIZE);", "VAR_3 = load_image_targphys(VAR_2, bios_addr,\nVAR_3);", "}", "}", "}", "if (VAR_3 < 0 || VAR_3 > BIOS_SIZE) {", "hw_error(\"qemu: could not load bios image '%s'\\n\", s->bios_name);", "}", "g_free(VAR_2);", "}", "}" ]
[ 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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 21, 23 ], [ 25 ], [ 27, 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41, 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59, 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ] ]
9,847
minimac2_write(void *opaque, target_phys_addr_t addr, uint64_t value, unsigned size) { MilkymistMinimac2State *s = opaque; trace_milkymist_minimac2_memory_read(addr, value); addr >>= 2; switch (addr) { case R_MDIO: { /* MDIO_DI is read only */ int mdio_di = (s->regs[R_MDIO] & MDIO_DI); s->regs[R_MDIO] = value; if (mdio_di) { s->regs[R_MDIO] |= mdio_di; } else { s->regs[R_MDIO] &= ~mdio_di; } minimac2_update_mdio(s); } break; case R_TXCOUNT: s->regs[addr] = value; if (value > 0) { minimac2_tx(s); } break; case R_STATE0: case R_STATE1: s->regs[addr] = value; update_rx_interrupt(s); break; case R_SETUP: case R_COUNT0: case R_COUNT1: s->regs[addr] = value; break; default: error_report("milkymist_minimac2: write access to unknown register 0x" TARGET_FMT_plx, addr << 2); break; } }
false
qemu
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
minimac2_write(void *opaque, target_phys_addr_t addr, uint64_t value, unsigned size) { MilkymistMinimac2State *s = opaque; trace_milkymist_minimac2_memory_read(addr, value); addr >>= 2; switch (addr) { case R_MDIO: { int mdio_di = (s->regs[R_MDIO] & MDIO_DI); s->regs[R_MDIO] = value; if (mdio_di) { s->regs[R_MDIO] |= mdio_di; } else { s->regs[R_MDIO] &= ~mdio_di; } minimac2_update_mdio(s); } break; case R_TXCOUNT: s->regs[addr] = value; if (value > 0) { minimac2_tx(s); } break; case R_STATE0: case R_STATE1: s->regs[addr] = value; update_rx_interrupt(s); break; case R_SETUP: case R_COUNT0: case R_COUNT1: s->regs[addr] = value; break; default: error_report("milkymist_minimac2: write access to unknown register 0x" TARGET_FMT_plx, addr << 2); break; } }
{ "code": [], "line_no": [] }
FUNC_0(void *VAR_0, target_phys_addr_t VAR_1, uint64_t VAR_2, unsigned VAR_3) { MilkymistMinimac2State *s = VAR_0; trace_milkymist_minimac2_memory_read(VAR_1, VAR_2); VAR_1 >>= 2; switch (VAR_1) { case R_MDIO: { int VAR_4 = (s->regs[R_MDIO] & MDIO_DI); s->regs[R_MDIO] = VAR_2; if (VAR_4) { s->regs[R_MDIO] |= VAR_4; } else { s->regs[R_MDIO] &= ~VAR_4; } minimac2_update_mdio(s); } break; case R_TXCOUNT: s->regs[VAR_1] = VAR_2; if (VAR_2 > 0) { minimac2_tx(s); } break; case R_STATE0: case R_STATE1: s->regs[VAR_1] = VAR_2; update_rx_interrupt(s); break; case R_SETUP: case R_COUNT0: case R_COUNT1: s->regs[VAR_1] = VAR_2; break; default: error_report("milkymist_minimac2: write access to unknown register 0x" TARGET_FMT_plx, VAR_1 << 2); break; } }
[ "FUNC_0(void *VAR_0, target_phys_addr_t VAR_1, uint64_t VAR_2,\nunsigned VAR_3)\n{", "MilkymistMinimac2State *s = VAR_0;", "trace_milkymist_minimac2_memory_read(VAR_1, VAR_2);", "VAR_1 >>= 2;", "switch (VAR_1) {", "case R_MDIO:\n{", "int VAR_4 = (s->regs[R_MDIO] & MDIO_DI);", "s->regs[R_MDIO] = VAR_2;", "if (VAR_4) {", "s->regs[R_MDIO] |= VAR_4;", "} else {", "s->regs[R_MDIO] &= ~VAR_4;", "}", "minimac2_update_mdio(s);", "} break;", "case R_TXCOUNT:\ns->regs[VAR_1] = VAR_2;", "if (VAR_2 > 0) {", "minimac2_tx(s);", "}", "break;", "case R_STATE0:\ncase R_STATE1:\ns->regs[VAR_1] = VAR_2;", "update_rx_interrupt(s);", "break;", "case R_SETUP:\ncase R_COUNT0:\ncase R_COUNT1:\ns->regs[VAR_1] = VAR_2;", "break;", "default:\nerror_report(\"milkymist_minimac2: write access to unknown register 0x\"\nTARGET_FMT_plx, VAR_1 << 2);", "break;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 11 ], [ 15 ], [ 17 ], [ 19, 21 ], [ 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 ] ]
9,848
int bdrv_in_use(BlockDriverState *bs) { return bs->in_use; }
false
qemu
3718d8ab65f68de2acccbe6a315907805f54e3cc
int bdrv_in_use(BlockDriverState *bs) { return bs->in_use; }
{ "code": [], "line_no": [] }
int FUNC_0(BlockDriverState *VAR_0) { return VAR_0->in_use; }
[ "int FUNC_0(BlockDriverState *VAR_0)\n{", "return VAR_0->in_use;", "}" ]
[ 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ] ]
9,849
static void vhost_log_start(MemoryListener *listener, MemoryRegionSection *section) { /* FIXME: implement */ }
false
qemu
b2dfd71c4843a762f2befe702adb249cf55baf66
static void vhost_log_start(MemoryListener *listener, MemoryRegionSection *section) { }
{ "code": [], "line_no": [] }
static void FUNC_0(MemoryListener *VAR_0, MemoryRegionSection *VAR_1) { }
[ "static void FUNC_0(MemoryListener *VAR_0,\nMemoryRegionSection *VAR_1)\n{", "}" ]
[ 0, 0 ]
[ [ 1, 3, 5 ], [ 9 ] ]
9,850
static inline void tcg_out_addi(TCGContext *s, int reg, tcg_target_long val) { if (val != 0) { if (val == (val & 0xfff)) tcg_out_arithi(s, reg, reg, val, ARITH_ADD); else fprintf(stderr, "unimplemented addi %ld\n", (long)val); } }
false
qemu
f02ca5cbeaf86038834c1953247a1579d7921927
static inline void tcg_out_addi(TCGContext *s, int reg, tcg_target_long val) { if (val != 0) { if (val == (val & 0xfff)) tcg_out_arithi(s, reg, reg, val, ARITH_ADD); else fprintf(stderr, "unimplemented addi %ld\n", (long)val); } }
{ "code": [], "line_no": [] }
static inline void FUNC_0(TCGContext *VAR_0, int VAR_1, tcg_target_long VAR_2) { if (VAR_2 != 0) { if (VAR_2 == (VAR_2 & 0xfff)) tcg_out_arithi(VAR_0, VAR_1, VAR_1, VAR_2, ARITH_ADD); else fprintf(stderr, "unimplemented addi %ld\n", (long)VAR_2); } }
[ "static inline void FUNC_0(TCGContext *VAR_0, int VAR_1, tcg_target_long VAR_2)\n{", "if (VAR_2 != 0) {", "if (VAR_2 == (VAR_2 & 0xfff))\ntcg_out_arithi(VAR_0, VAR_1, VAR_1, VAR_2, ARITH_ADD);", "else\nfprintf(stderr, \"unimplemented addi %ld\\n\", (long)VAR_2);", "}", "}" ]
[ 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7, 9 ], [ 11, 13 ], [ 15 ], [ 17 ] ]
9,851
static void pl110_update_display(void *opaque) { PL110State *s = (PL110State *)opaque; SysBusDevice *sbd; DisplaySurface *surface = qemu_console_surface(s->con); drawfn* fntable; drawfn fn; int dest_width; int src_width; int bpp_offset; int first; int last; if (!pl110_enabled(s)) { return; } sbd = SYS_BUS_DEVICE(s); switch (surface_bits_per_pixel(surface)) { case 0: return; case 8: fntable = pl110_draw_fn_8; dest_width = 1; break; case 15: fntable = pl110_draw_fn_15; dest_width = 2; break; case 16: fntable = pl110_draw_fn_16; dest_width = 2; break; case 24: fntable = pl110_draw_fn_24; dest_width = 3; break; case 32: fntable = pl110_draw_fn_32; dest_width = 4; break; default: fprintf(stderr, "pl110: Bad color depth\n"); exit(1); } if (s->cr & PL110_CR_BGR) bpp_offset = 0; else bpp_offset = 24; if ((s->version != PL111) && (s->bpp == BPP_16)) { /* The PL110's native 16 bit mode is 5551; however * most boards with a PL110 implement an external * mux which allows bits to be reshuffled to give * 565 format. The mux is typically controlled by * an external system register. * This is controlled by a GPIO input pin * so boards can wire it up to their register. * * The PL111 straightforwardly implements both * 5551 and 565 under control of the bpp field * in the LCDControl register. */ switch (s->mux_ctrl) { case 3: /* 565 BGR */ bpp_offset = (BPP_16_565 - BPP_16); break; case 1: /* 5551 */ break; case 0: /* 888; also if we have loaded vmstate from an old version */ case 2: /* 565 RGB */ default: /* treat as 565 but honour BGR bit */ bpp_offset += (BPP_16_565 - BPP_16); break; } } if (s->cr & PL110_CR_BEBO) fn = fntable[s->bpp + 8 + bpp_offset]; else if (s->cr & PL110_CR_BEPO) fn = fntable[s->bpp + 16 + bpp_offset]; else fn = fntable[s->bpp + bpp_offset]; src_width = s->cols; switch (s->bpp) { case BPP_1: src_width >>= 3; break; case BPP_2: src_width >>= 2; break; case BPP_4: src_width >>= 1; break; case BPP_8: break; case BPP_16: case BPP_16_565: case BPP_12: src_width <<= 1; break; case BPP_32: src_width <<= 2; break; } dest_width *= s->cols; first = 0; framebuffer_update_display(surface, sysbus_address_space(sbd), s->upbase, s->cols, s->rows, src_width, dest_width, 0, s->invalidate, fn, s->palette, &first, &last); if (first >= 0) { dpy_gfx_update(s->con, 0, first, s->cols, last - first + 1); } s->invalidate = 0; }
false
qemu
c1076c3e13a86140cc2ba29866512df8460cc7c2
static void pl110_update_display(void *opaque) { PL110State *s = (PL110State *)opaque; SysBusDevice *sbd; DisplaySurface *surface = qemu_console_surface(s->con); drawfn* fntable; drawfn fn; int dest_width; int src_width; int bpp_offset; int first; int last; if (!pl110_enabled(s)) { return; } sbd = SYS_BUS_DEVICE(s); switch (surface_bits_per_pixel(surface)) { case 0: return; case 8: fntable = pl110_draw_fn_8; dest_width = 1; break; case 15: fntable = pl110_draw_fn_15; dest_width = 2; break; case 16: fntable = pl110_draw_fn_16; dest_width = 2; break; case 24: fntable = pl110_draw_fn_24; dest_width = 3; break; case 32: fntable = pl110_draw_fn_32; dest_width = 4; break; default: fprintf(stderr, "pl110: Bad color depth\n"); exit(1); } if (s->cr & PL110_CR_BGR) bpp_offset = 0; else bpp_offset = 24; if ((s->version != PL111) && (s->bpp == BPP_16)) { switch (s->mux_ctrl) { case 3: bpp_offset = (BPP_16_565 - BPP_16); break; case 1: break; case 0: case 2: default: bpp_offset += (BPP_16_565 - BPP_16); break; } } if (s->cr & PL110_CR_BEBO) fn = fntable[s->bpp + 8 + bpp_offset]; else if (s->cr & PL110_CR_BEPO) fn = fntable[s->bpp + 16 + bpp_offset]; else fn = fntable[s->bpp + bpp_offset]; src_width = s->cols; switch (s->bpp) { case BPP_1: src_width >>= 3; break; case BPP_2: src_width >>= 2; break; case BPP_4: src_width >>= 1; break; case BPP_8: break; case BPP_16: case BPP_16_565: case BPP_12: src_width <<= 1; break; case BPP_32: src_width <<= 2; break; } dest_width *= s->cols; first = 0; framebuffer_update_display(surface, sysbus_address_space(sbd), s->upbase, s->cols, s->rows, src_width, dest_width, 0, s->invalidate, fn, s->palette, &first, &last); if (first >= 0) { dpy_gfx_update(s->con, 0, first, s->cols, last - first + 1); } s->invalidate = 0; }
{ "code": [], "line_no": [] }
static void FUNC_0(void *VAR_0) { PL110State *s = (PL110State *)VAR_0; SysBusDevice *sbd; DisplaySurface *surface = qemu_console_surface(s->con); drawfn* fntable; drawfn fn; int VAR_1; int VAR_2; int VAR_3; int VAR_4; int VAR_5; if (!pl110_enabled(s)) { return; } sbd = SYS_BUS_DEVICE(s); switch (surface_bits_per_pixel(surface)) { case 0: return; case 8: fntable = pl110_draw_fn_8; VAR_1 = 1; break; case 15: fntable = pl110_draw_fn_15; VAR_1 = 2; break; case 16: fntable = pl110_draw_fn_16; VAR_1 = 2; break; case 24: fntable = pl110_draw_fn_24; VAR_1 = 3; break; case 32: fntable = pl110_draw_fn_32; VAR_1 = 4; break; default: fprintf(stderr, "pl110: Bad color depth\n"); exit(1); } if (s->cr & PL110_CR_BGR) VAR_3 = 0; else VAR_3 = 24; if ((s->version != PL111) && (s->bpp == BPP_16)) { switch (s->mux_ctrl) { case 3: VAR_3 = (BPP_16_565 - BPP_16); break; case 1: break; case 0: case 2: default: VAR_3 += (BPP_16_565 - BPP_16); break; } } if (s->cr & PL110_CR_BEBO) fn = fntable[s->bpp + 8 + VAR_3]; else if (s->cr & PL110_CR_BEPO) fn = fntable[s->bpp + 16 + VAR_3]; else fn = fntable[s->bpp + VAR_3]; VAR_2 = s->cols; switch (s->bpp) { case BPP_1: VAR_2 >>= 3; break; case BPP_2: VAR_2 >>= 2; break; case BPP_4: VAR_2 >>= 1; break; case BPP_8: break; case BPP_16: case BPP_16_565: case BPP_12: VAR_2 <<= 1; break; case BPP_32: VAR_2 <<= 2; break; } VAR_1 *= s->cols; VAR_4 = 0; framebuffer_update_display(surface, sysbus_address_space(sbd), s->upbase, s->cols, s->rows, VAR_2, VAR_1, 0, s->invalidate, fn, s->palette, &VAR_4, &VAR_5); if (VAR_4 >= 0) { dpy_gfx_update(s->con, 0, VAR_4, s->cols, VAR_5 - VAR_4 + 1); } s->invalidate = 0; }
[ "static void FUNC_0(void *VAR_0)\n{", "PL110State *s = (PL110State *)VAR_0;", "SysBusDevice *sbd;", "DisplaySurface *surface = qemu_console_surface(s->con);", "drawfn* fntable;", "drawfn fn;", "int VAR_1;", "int VAR_2;", "int VAR_3;", "int VAR_4;", "int VAR_5;", "if (!pl110_enabled(s)) {", "return;", "}", "sbd = SYS_BUS_DEVICE(s);", "switch (surface_bits_per_pixel(surface)) {", "case 0:\nreturn;", "case 8:\nfntable = pl110_draw_fn_8;", "VAR_1 = 1;", "break;", "case 15:\nfntable = pl110_draw_fn_15;", "VAR_1 = 2;", "break;", "case 16:\nfntable = pl110_draw_fn_16;", "VAR_1 = 2;", "break;", "case 24:\nfntable = pl110_draw_fn_24;", "VAR_1 = 3;", "break;", "case 32:\nfntable = pl110_draw_fn_32;", "VAR_1 = 4;", "break;", "default:\nfprintf(stderr, \"pl110: Bad color depth\\n\");", "exit(1);", "}", "if (s->cr & PL110_CR_BGR)\nVAR_3 = 0;", "else\nVAR_3 = 24;", "if ((s->version != PL111) && (s->bpp == BPP_16)) {", "switch (s->mux_ctrl) {", "case 3:\nVAR_3 = (BPP_16_565 - BPP_16);", "break;", "case 1:\nbreak;", "case 0:\ncase 2:\ndefault:\nVAR_3 += (BPP_16_565 - BPP_16);", "break;", "}", "}", "if (s->cr & PL110_CR_BEBO)\nfn = fntable[s->bpp + 8 + VAR_3];", "else if (s->cr & PL110_CR_BEPO)\nfn = fntable[s->bpp + 16 + VAR_3];", "else\nfn = fntable[s->bpp + VAR_3];", "VAR_2 = s->cols;", "switch (s->bpp) {", "case BPP_1:\nVAR_2 >>= 3;", "break;", "case BPP_2:\nVAR_2 >>= 2;", "break;", "case BPP_4:\nVAR_2 >>= 1;", "break;", "case BPP_8:\nbreak;", "case BPP_16:\ncase BPP_16_565:\ncase BPP_12:\nVAR_2 <<= 1;", "break;", "case BPP_32:\nVAR_2 <<= 2;", "break;", "}", "VAR_1 *= s->cols;", "VAR_4 = 0;", "framebuffer_update_display(surface, sysbus_address_space(sbd),\ns->upbase, s->cols, s->rows,\nVAR_2, VAR_1, 0,\ns->invalidate,\nfn, s->palette,\n&VAR_4, &VAR_5);", "if (VAR_4 >= 0) {", "dpy_gfx_update(s->con, 0, VAR_4, s->cols, VAR_5 - VAR_4 + 1);", "}", "s->invalidate = 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 35 ], [ 39 ], [ 41, 43 ], [ 45, 47 ], [ 49 ], [ 51 ], [ 53, 55 ], [ 57 ], [ 59 ], [ 61, 63 ], [ 65 ], [ 67 ], [ 69, 71 ], [ 73 ], [ 75 ], [ 77, 79 ], [ 81 ], [ 83 ], [ 85, 87 ], [ 89 ], [ 91 ], [ 93, 95 ], [ 97, 99 ], [ 103 ], [ 129 ], [ 131, 133 ], [ 135 ], [ 137, 139 ], [ 141, 143, 145, 149 ], [ 151 ], [ 153 ], [ 155 ], [ 159, 161 ], [ 163, 165 ], [ 167, 169 ], [ 173 ], [ 175 ], [ 177, 179 ], [ 181 ], [ 183, 185 ], [ 187 ], [ 189, 191 ], [ 193 ], [ 195, 197 ], [ 199, 201, 203, 205 ], [ 207 ], [ 209, 211 ], [ 213 ], [ 215 ], [ 217 ], [ 219 ], [ 221, 223, 225, 227, 229, 231 ], [ 233 ], [ 235 ], [ 237 ], [ 239 ], [ 241 ] ]
9,852
static void nvdimm_build_nvdimm_devices(GSList *device_list, Aml *root_dev) { for (; device_list; device_list = device_list->next) { DeviceState *dev = device_list->data; int slot = object_property_get_int(OBJECT(dev), PC_DIMM_SLOT_PROP, NULL); uint32_t handle = nvdimm_slot_to_handle(slot); Aml *nvdimm_dev; nvdimm_dev = aml_device("NV%02X", slot); /* * ACPI 6.0: 9.20 NVDIMM Devices: * * _ADR object that is used to supply OSPM with unique address * of the NVDIMM device. This is done by returning the NFIT Device * handle that is used to identify the associated entries in ACPI * table NFIT or _FIT. */ aml_append(nvdimm_dev, aml_name_decl("_ADR", aml_int(handle))); nvdimm_build_device_dsm(nvdimm_dev); aml_append(root_dev, nvdimm_dev); } }
false
qemu
732b530c1bd064bdcc29975c0b78fc6de8c47e7f
static void nvdimm_build_nvdimm_devices(GSList *device_list, Aml *root_dev) { for (; device_list; device_list = device_list->next) { DeviceState *dev = device_list->data; int slot = object_property_get_int(OBJECT(dev), PC_DIMM_SLOT_PROP, NULL); uint32_t handle = nvdimm_slot_to_handle(slot); Aml *nvdimm_dev; nvdimm_dev = aml_device("NV%02X", slot); aml_append(nvdimm_dev, aml_name_decl("_ADR", aml_int(handle))); nvdimm_build_device_dsm(nvdimm_dev); aml_append(root_dev, nvdimm_dev); } }
{ "code": [], "line_no": [] }
static void FUNC_0(GSList *VAR_0, Aml *VAR_1) { for (; VAR_0; VAR_0 = VAR_0->next) { DeviceState *dev = VAR_0->data; int slot = object_property_get_int(OBJECT(dev), PC_DIMM_SLOT_PROP, NULL); uint32_t handle = nvdimm_slot_to_handle(slot); Aml *nvdimm_dev; nvdimm_dev = aml_device("NV%02X", slot); aml_append(nvdimm_dev, aml_name_decl("_ADR", aml_int(handle))); nvdimm_build_device_dsm(nvdimm_dev); aml_append(VAR_1, nvdimm_dev); } }
[ "static void FUNC_0(GSList *VAR_0, Aml *VAR_1)\n{", "for (; VAR_0; VAR_0 = VAR_0->next) {", "DeviceState *dev = VAR_0->data;", "int slot = object_property_get_int(OBJECT(dev), PC_DIMM_SLOT_PROP,\nNULL);", "uint32_t handle = nvdimm_slot_to_handle(slot);", "Aml *nvdimm_dev;", "nvdimm_dev = aml_device(\"NV%02X\", slot);", "aml_append(nvdimm_dev, aml_name_decl(\"_ADR\", aml_int(handle)));", "nvdimm_build_device_dsm(nvdimm_dev);", "aml_append(VAR_1, nvdimm_dev);", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9, 11 ], [ 13 ], [ 15 ], [ 19 ], [ 39 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ] ]
9,853
int coroutine_fn bdrv_co_readv(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov) { trace_bdrv_co_readv(bs, sector_num, nb_sectors); return bdrv_co_do_readv(bs, sector_num, nb_sectors, qiov, 0); }
false
qemu
61007b316cd71ee7333ff7a0a749a8949527575f
int coroutine_fn bdrv_co_readv(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov) { trace_bdrv_co_readv(bs, sector_num, nb_sectors); return bdrv_co_do_readv(bs, sector_num, nb_sectors, qiov, 0); }
{ "code": [], "line_no": [] }
int VAR_0 bdrv_co_readv(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov) { trace_bdrv_co_readv(bs, sector_num, nb_sectors); return bdrv_co_do_readv(bs, sector_num, nb_sectors, qiov, 0); }
[ "int VAR_0 bdrv_co_readv(BlockDriverState *bs, int64_t sector_num,\nint nb_sectors, QEMUIOVector *qiov)\n{", "trace_bdrv_co_readv(bs, sector_num, nb_sectors);", "return bdrv_co_do_readv(bs, sector_num, nb_sectors, qiov, 0);", "}" ]
[ 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 11 ], [ 13 ] ]
9,854
static void test_qemu_strtosz_float(void) { const char *str = "12.345M"; char *endptr = NULL; int64_t res; res = qemu_strtosz(str, &endptr); g_assert_cmpint(res, ==, 12.345 * M_BYTE); g_assert(endptr == str + 7); }
false
qemu
f17fd4fdf0df3d2f3444399d04c38d22b9a3e1b7
static void test_qemu_strtosz_float(void) { const char *str = "12.345M"; char *endptr = NULL; int64_t res; res = qemu_strtosz(str, &endptr); g_assert_cmpint(res, ==, 12.345 * M_BYTE); g_assert(endptr == str + 7); }
{ "code": [], "line_no": [] }
static void FUNC_0(void) { const char *VAR_0 = "12.345M"; char *VAR_1 = NULL; int64_t res; res = qemu_strtosz(VAR_0, &VAR_1); g_assert_cmpint(res, ==, 12.345 * M_BYTE); g_assert(VAR_1 == VAR_0 + 7); }
[ "static void FUNC_0(void)\n{", "const char *VAR_0 = \"12.345M\";", "char *VAR_1 = NULL;", "int64_t res;", "res = qemu_strtosz(VAR_0, &VAR_1);", "g_assert_cmpint(res, ==, 12.345 * M_BYTE);", "g_assert(VAR_1 == VAR_0 + 7);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ] ]
9,855
int i2c_start_transfer(I2CBus *bus, uint8_t address, int recv) { BusChild *kid; I2CSlaveClass *sc; I2CNode *node; if (address == I2C_BROADCAST) { /* * This is a broadcast, the current_devs will be all the devices of the * bus. */ bus->broadcast = true; } QTAILQ_FOREACH(kid, &bus->qbus.children, sibling) { DeviceState *qdev = kid->child; I2CSlave *candidate = I2C_SLAVE(qdev); if ((candidate->address == address) || (bus->broadcast)) { node = g_malloc(sizeof(struct I2CNode)); node->elt = candidate; QLIST_INSERT_HEAD(&bus->current_devs, node, next); if (!bus->broadcast) { break; } } } if (QLIST_EMPTY(&bus->current_devs)) { return 1; } QLIST_FOREACH(node, &bus->current_devs, next) { sc = I2C_SLAVE_GET_CLASS(node->elt); /* If the bus is already busy, assume this is a repeated start condition. */ if (sc->event) { sc->event(node->elt, recv ? I2C_START_RECV : I2C_START_SEND); } } return 0; }
false
qemu
0fa758c3a069bc59a0d903d69028971c46d1a119
int i2c_start_transfer(I2CBus *bus, uint8_t address, int recv) { BusChild *kid; I2CSlaveClass *sc; I2CNode *node; if (address == I2C_BROADCAST) { bus->broadcast = true; } QTAILQ_FOREACH(kid, &bus->qbus.children, sibling) { DeviceState *qdev = kid->child; I2CSlave *candidate = I2C_SLAVE(qdev); if ((candidate->address == address) || (bus->broadcast)) { node = g_malloc(sizeof(struct I2CNode)); node->elt = candidate; QLIST_INSERT_HEAD(&bus->current_devs, node, next); if (!bus->broadcast) { break; } } } if (QLIST_EMPTY(&bus->current_devs)) { return 1; } QLIST_FOREACH(node, &bus->current_devs, next) { sc = I2C_SLAVE_GET_CLASS(node->elt); if (sc->event) { sc->event(node->elt, recv ? I2C_START_RECV : I2C_START_SEND); } } return 0; }
{ "code": [], "line_no": [] }
int FUNC_0(I2CBus *VAR_0, uint8_t VAR_1, int VAR_2) { BusChild *kid; I2CSlaveClass *sc; I2CNode *node; if (VAR_1 == I2C_BROADCAST) { VAR_0->broadcast = true; } QTAILQ_FOREACH(kid, &VAR_0->qbus.children, sibling) { DeviceState *qdev = kid->child; I2CSlave *candidate = I2C_SLAVE(qdev); if ((candidate->VAR_1 == VAR_1) || (VAR_0->broadcast)) { node = g_malloc(sizeof(struct I2CNode)); node->elt = candidate; QLIST_INSERT_HEAD(&VAR_0->current_devs, node, next); if (!VAR_0->broadcast) { break; } } } if (QLIST_EMPTY(&VAR_0->current_devs)) { return 1; } QLIST_FOREACH(node, &VAR_0->current_devs, next) { sc = I2C_SLAVE_GET_CLASS(node->elt); if (sc->event) { sc->event(node->elt, VAR_2 ? I2C_START_RECV : I2C_START_SEND); } } return 0; }
[ "int FUNC_0(I2CBus *VAR_0, uint8_t VAR_1, int VAR_2)\n{", "BusChild *kid;", "I2CSlaveClass *sc;", "I2CNode *node;", "if (VAR_1 == I2C_BROADCAST) {", "VAR_0->broadcast = true;", "}", "QTAILQ_FOREACH(kid, &VAR_0->qbus.children, sibling) {", "DeviceState *qdev = kid->child;", "I2CSlave *candidate = I2C_SLAVE(qdev);", "if ((candidate->VAR_1 == VAR_1) || (VAR_0->broadcast)) {", "node = g_malloc(sizeof(struct I2CNode));", "node->elt = candidate;", "QLIST_INSERT_HEAD(&VAR_0->current_devs, node, next);", "if (!VAR_0->broadcast) {", "break;", "}", "}", "}", "if (QLIST_EMPTY(&VAR_0->current_devs)) {", "return 1;", "}", "QLIST_FOREACH(node, &VAR_0->current_devs, next) {", "sc = I2C_SLAVE_GET_CLASS(node->elt);", "if (sc->event) {", "sc->event(node->elt, VAR_2 ? I2C_START_RECV : I2C_START_SEND);", "}", "}", "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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 23 ], [ 25 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 55 ], [ 57 ], [ 59 ], [ 63 ], [ 65 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ] ]
9,856
static BlockAIOCB *raw_aio_submit(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, BlockCompletionFunc *cb, void *opaque, int type) { BDRVRawState *s = bs->opaque; if (fd_open(bs) < 0) return NULL; /* * Check if the underlying device requires requests to be aligned, * and if the request we are trying to submit is aligned or not. * If this is the case tell the low-level driver that it needs * to copy the buffer. */ if (s->needs_alignment) { if (!bdrv_qiov_is_aligned(bs, qiov)) { type |= QEMU_AIO_MISALIGNED; #ifdef CONFIG_LINUX_AIO } else if (s->use_aio) { return laio_submit(bs, s->aio_ctx, s->fd, sector_num, qiov, nb_sectors, cb, opaque, type); #endif } } return paio_submit(bs, s->fd, sector_num, qiov, nb_sectors, cb, opaque, type); }
false
qemu
2174f12bdeb3974141784e14bbb7ad8c53178cd9
static BlockAIOCB *raw_aio_submit(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, BlockCompletionFunc *cb, void *opaque, int type) { BDRVRawState *s = bs->opaque; if (fd_open(bs) < 0) return NULL; if (s->needs_alignment) { if (!bdrv_qiov_is_aligned(bs, qiov)) { type |= QEMU_AIO_MISALIGNED; #ifdef CONFIG_LINUX_AIO } else if (s->use_aio) { return laio_submit(bs, s->aio_ctx, s->fd, sector_num, qiov, nb_sectors, cb, opaque, type); #endif } } return paio_submit(bs, s->fd, sector_num, qiov, nb_sectors, cb, opaque, type); }
{ "code": [], "line_no": [] }
static BlockAIOCB *FUNC_0(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, BlockCompletionFunc *cb, void *opaque, int type) { BDRVRawState *s = bs->opaque; if (fd_open(bs) < 0) return NULL; if (s->needs_alignment) { if (!bdrv_qiov_is_aligned(bs, qiov)) { type |= QEMU_AIO_MISALIGNED; #ifdef CONFIG_LINUX_AIO } else if (s->use_aio) { return laio_submit(bs, s->aio_ctx, s->fd, sector_num, qiov, nb_sectors, cb, opaque, type); #endif } } return paio_submit(bs, s->fd, sector_num, qiov, nb_sectors, cb, opaque, type); }
[ "static BlockAIOCB *FUNC_0(BlockDriverState *bs,\nint64_t sector_num, QEMUIOVector *qiov, int nb_sectors,\nBlockCompletionFunc *cb, void *opaque, int type)\n{", "BDRVRawState *s = bs->opaque;", "if (fd_open(bs) < 0)\nreturn NULL;", "if (s->needs_alignment) {", "if (!bdrv_qiov_is_aligned(bs, qiov)) {", "type |= QEMU_AIO_MISALIGNED;", "#ifdef CONFIG_LINUX_AIO\n} else if (s->use_aio) {", "return laio_submit(bs, s->aio_ctx, s->fd, sector_num, qiov,\nnb_sectors, cb, opaque, type);", "#endif\n}", "}", "return paio_submit(bs, s->fd, sector_num, qiov, nb_sectors,\ncb, opaque, type);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 13, 15 ], [ 31 ], [ 33 ], [ 35 ], [ 37, 39 ], [ 41, 43 ], [ 45, 47 ], [ 49 ], [ 53, 55 ], [ 57 ] ]
9,857
static int v4l2_set_parameters(AVFormatContext *s1) { struct video_data *s = s1->priv_data; struct v4l2_standard standard = { 0 }; struct v4l2_streamparm streamparm = { 0 }; struct v4l2_fract *tpf = &streamparm.parm.capture.timeperframe; AVRational framerate_q = { 0 }; int i, ret; streamparm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; if (s->framerate && (ret = av_parse_video_rate(&framerate_q, s->framerate)) < 0) { av_log(s1, AV_LOG_ERROR, "Could not parse framerate '%s'.\n", s->framerate); return ret; } if (s->standard) { av_log(s1, AV_LOG_DEBUG, "The V4L2 driver set standard: %s\n", s->standard); /* set tv standard */ for(i=0;;i++) { standard.index = i; ret = v4l2_ioctl(s->fd, VIDIOC_ENUMSTD, &standard); if (ret < 0 || !av_strcasecmp(standard.name, s->standard)) break; } if (ret < 0) { av_log(s1, AV_LOG_ERROR, "Unknown standard '%s'\n", s->standard); return ret; } av_log(s1, AV_LOG_DEBUG, "The V4L2 driver set standard: %s, id: %"PRIu64"\n", s->standard, (uint64_t)standard.id); if (v4l2_ioctl(s->fd, VIDIOC_S_STD, &standard.id) < 0) { av_log(s1, AV_LOG_ERROR, "The V4L2 driver ioctl set standard(%s) failed\n", s->standard); return AVERROR(EIO); } } if (framerate_q.num && framerate_q.den) { av_log(s1, AV_LOG_DEBUG, "Setting time per frame to %d/%d\n", framerate_q.den, framerate_q.num); tpf->numerator = framerate_q.den; tpf->denominator = framerate_q.num; if (v4l2_ioctl(s->fd, VIDIOC_S_PARM, &streamparm) != 0) { av_log(s1, AV_LOG_ERROR, "ioctl set time per frame(%d/%d) failed\n", framerate_q.den, framerate_q.num); return AVERROR(EIO); } if (framerate_q.num != tpf->denominator || framerate_q.den != tpf->numerator) { av_log(s1, AV_LOG_INFO, "The driver changed the time per frame from " "%d/%d to %d/%d\n", framerate_q.den, framerate_q.num, tpf->numerator, tpf->denominator); } } else { if (v4l2_ioctl(s->fd, VIDIOC_G_PARM, &streamparm) != 0) { av_log(s1, AV_LOG_ERROR, "ioctl(VIDIOC_G_PARM): %s\n", strerror(errno)); return AVERROR(errno); } } s1->streams[0]->avg_frame_rate.num = tpf->denominator; s1->streams[0]->avg_frame_rate.den = tpf->numerator; return 0; }
false
FFmpeg
514216d8a928cf80980ca8dc5daea46e9d41cad9
static int v4l2_set_parameters(AVFormatContext *s1) { struct video_data *s = s1->priv_data; struct v4l2_standard standard = { 0 }; struct v4l2_streamparm streamparm = { 0 }; struct v4l2_fract *tpf = &streamparm.parm.capture.timeperframe; AVRational framerate_q = { 0 }; int i, ret; streamparm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; if (s->framerate && (ret = av_parse_video_rate(&framerate_q, s->framerate)) < 0) { av_log(s1, AV_LOG_ERROR, "Could not parse framerate '%s'.\n", s->framerate); return ret; } if (s->standard) { av_log(s1, AV_LOG_DEBUG, "The V4L2 driver set standard: %s\n", s->standard); for(i=0;;i++) { standard.index = i; ret = v4l2_ioctl(s->fd, VIDIOC_ENUMSTD, &standard); if (ret < 0 || !av_strcasecmp(standard.name, s->standard)) break; } if (ret < 0) { av_log(s1, AV_LOG_ERROR, "Unknown standard '%s'\n", s->standard); return ret; } av_log(s1, AV_LOG_DEBUG, "The V4L2 driver set standard: %s, id: %"PRIu64"\n", s->standard, (uint64_t)standard.id); if (v4l2_ioctl(s->fd, VIDIOC_S_STD, &standard.id) < 0) { av_log(s1, AV_LOG_ERROR, "The V4L2 driver ioctl set standard(%s) failed\n", s->standard); return AVERROR(EIO); } } if (framerate_q.num && framerate_q.den) { av_log(s1, AV_LOG_DEBUG, "Setting time per frame to %d/%d\n", framerate_q.den, framerate_q.num); tpf->numerator = framerate_q.den; tpf->denominator = framerate_q.num; if (v4l2_ioctl(s->fd, VIDIOC_S_PARM, &streamparm) != 0) { av_log(s1, AV_LOG_ERROR, "ioctl set time per frame(%d/%d) failed\n", framerate_q.den, framerate_q.num); return AVERROR(EIO); } if (framerate_q.num != tpf->denominator || framerate_q.den != tpf->numerator) { av_log(s1, AV_LOG_INFO, "The driver changed the time per frame from " "%d/%d to %d/%d\n", framerate_q.den, framerate_q.num, tpf->numerator, tpf->denominator); } } else { if (v4l2_ioctl(s->fd, VIDIOC_G_PARM, &streamparm) != 0) { av_log(s1, AV_LOG_ERROR, "ioctl(VIDIOC_G_PARM): %s\n", strerror(errno)); return AVERROR(errno); } } s1->streams[0]->avg_frame_rate.num = tpf->denominator; s1->streams[0]->avg_frame_rate.den = tpf->numerator; return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(AVFormatContext *VAR_0) { struct video_data *VAR_1 = VAR_0->priv_data; struct v4l2_standard VAR_2 = { 0 }; struct v4l2_streamparm VAR_3 = { 0 }; struct v4l2_fract *VAR_4 = &VAR_3.parm.capture.timeperframe; AVRational framerate_q = { 0 }; int VAR_5, VAR_6; VAR_3.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; if (VAR_1->framerate && (VAR_6 = av_parse_video_rate(&framerate_q, VAR_1->framerate)) < 0) { av_log(VAR_0, AV_LOG_ERROR, "Could not parse framerate '%VAR_1'.\n", VAR_1->framerate); return VAR_6; } if (VAR_1->VAR_2) { av_log(VAR_0, AV_LOG_DEBUG, "The V4L2 driver set VAR_2: %VAR_1\n", VAR_1->VAR_2); for(VAR_5=0;;VAR_5++) { VAR_2.index = VAR_5; VAR_6 = v4l2_ioctl(VAR_1->fd, VIDIOC_ENUMSTD, &VAR_2); if (VAR_6 < 0 || !av_strcasecmp(VAR_2.name, VAR_1->VAR_2)) break; } if (VAR_6 < 0) { av_log(VAR_0, AV_LOG_ERROR, "Unknown VAR_2 '%VAR_1'\n", VAR_1->VAR_2); return VAR_6; } av_log(VAR_0, AV_LOG_DEBUG, "The V4L2 driver set VAR_2: %VAR_1, id: %"PRIu64"\n", VAR_1->VAR_2, (uint64_t)VAR_2.id); if (v4l2_ioctl(VAR_1->fd, VIDIOC_S_STD, &VAR_2.id) < 0) { av_log(VAR_0, AV_LOG_ERROR, "The V4L2 driver ioctl set VAR_2(%VAR_1) failed\n", VAR_1->VAR_2); return AVERROR(EIO); } } if (framerate_q.num && framerate_q.den) { av_log(VAR_0, AV_LOG_DEBUG, "Setting time per frame to %d/%d\n", framerate_q.den, framerate_q.num); VAR_4->numerator = framerate_q.den; VAR_4->denominator = framerate_q.num; if (v4l2_ioctl(VAR_1->fd, VIDIOC_S_PARM, &VAR_3) != 0) { av_log(VAR_0, AV_LOG_ERROR, "ioctl set time per frame(%d/%d) failed\n", framerate_q.den, framerate_q.num); return AVERROR(EIO); } if (framerate_q.num != VAR_4->denominator || framerate_q.den != VAR_4->numerator) { av_log(VAR_0, AV_LOG_INFO, "The driver changed the time per frame from " "%d/%d to %d/%d\n", framerate_q.den, framerate_q.num, VAR_4->numerator, VAR_4->denominator); } } else { if (v4l2_ioctl(VAR_1->fd, VIDIOC_G_PARM, &VAR_3) != 0) { av_log(VAR_0, AV_LOG_ERROR, "ioctl(VIDIOC_G_PARM): %VAR_1\n", strerror(errno)); return AVERROR(errno); } } VAR_0->streams[0]->avg_frame_rate.num = VAR_4->denominator; VAR_0->streams[0]->avg_frame_rate.den = VAR_4->numerator; return 0; }
[ "static int FUNC_0(AVFormatContext *VAR_0)\n{", "struct video_data *VAR_1 = VAR_0->priv_data;", "struct v4l2_standard VAR_2 = { 0 };", "struct v4l2_streamparm VAR_3 = { 0 };", "struct v4l2_fract *VAR_4 = &VAR_3.parm.capture.timeperframe;", "AVRational framerate_q = { 0 };", "int VAR_5, VAR_6;", "VAR_3.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;", "if (VAR_1->framerate &&\n(VAR_6 = av_parse_video_rate(&framerate_q, VAR_1->framerate)) < 0) {", "av_log(VAR_0, AV_LOG_ERROR, \"Could not parse framerate '%VAR_1'.\\n\",\nVAR_1->framerate);", "return VAR_6;", "}", "if (VAR_1->VAR_2) {", "av_log(VAR_0, AV_LOG_DEBUG, \"The V4L2 driver set VAR_2: %VAR_1\\n\",\nVAR_1->VAR_2);", "for(VAR_5=0;;VAR_5++) {", "VAR_2.index = VAR_5;", "VAR_6 = v4l2_ioctl(VAR_1->fd, VIDIOC_ENUMSTD, &VAR_2);", "if (VAR_6 < 0 || !av_strcasecmp(VAR_2.name, VAR_1->VAR_2))\nbreak;", "}", "if (VAR_6 < 0) {", "av_log(VAR_0, AV_LOG_ERROR, \"Unknown VAR_2 '%VAR_1'\\n\", VAR_1->VAR_2);", "return VAR_6;", "}", "av_log(VAR_0, AV_LOG_DEBUG,\n\"The V4L2 driver set VAR_2: %VAR_1, id: %\"PRIu64\"\\n\",\nVAR_1->VAR_2, (uint64_t)VAR_2.id);", "if (v4l2_ioctl(VAR_1->fd, VIDIOC_S_STD, &VAR_2.id) < 0) {", "av_log(VAR_0, AV_LOG_ERROR,\n\"The V4L2 driver ioctl set VAR_2(%VAR_1) failed\\n\",\nVAR_1->VAR_2);", "return AVERROR(EIO);", "}", "}", "if (framerate_q.num && framerate_q.den) {", "av_log(VAR_0, AV_LOG_DEBUG, \"Setting time per frame to %d/%d\\n\",\nframerate_q.den, framerate_q.num);", "VAR_4->numerator = framerate_q.den;", "VAR_4->denominator = framerate_q.num;", "if (v4l2_ioctl(VAR_1->fd, VIDIOC_S_PARM, &VAR_3) != 0) {", "av_log(VAR_0, AV_LOG_ERROR,\n\"ioctl set time per frame(%d/%d) failed\\n\",\nframerate_q.den, framerate_q.num);", "return AVERROR(EIO);", "}", "if (framerate_q.num != VAR_4->denominator ||\nframerate_q.den != VAR_4->numerator) {", "av_log(VAR_0, AV_LOG_INFO,\n\"The driver changed the time per frame from \"\n\"%d/%d to %d/%d\\n\",\nframerate_q.den, framerate_q.num,\nVAR_4->numerator, VAR_4->denominator);", "}", "} else {", "if (v4l2_ioctl(VAR_1->fd, VIDIOC_G_PARM, &VAR_3) != 0) {", "av_log(VAR_0, AV_LOG_ERROR, \"ioctl(VIDIOC_G_PARM): %VAR_1\\n\",\nstrerror(errno));", "return AVERROR(errno);", "}", "}", "VAR_0->streams[0]->avg_frame_rate.num = VAR_4->denominator;", "VAR_0->streams[0]->avg_frame_rate.den = VAR_4->numerator;", "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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 23, 25 ], [ 27, 29 ], [ 31 ], [ 33 ], [ 37 ], [ 39, 41 ], [ 45 ], [ 47 ], [ 49 ], [ 51, 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 67, 69, 71 ], [ 73 ], [ 75, 77, 79 ], [ 81 ], [ 83 ], [ 85 ], [ 89 ], [ 91, 93 ], [ 95 ], [ 97 ], [ 101 ], [ 103, 105, 107 ], [ 109 ], [ 111 ], [ 115, 117 ], [ 119, 121, 123, 125, 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135, 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 151 ], [ 153 ] ]
9,858
static int vpc_create(const char *filename, QEMUOptionParameter *options) { uint8_t buf[1024]; struct vhd_footer *footer = (struct vhd_footer *) buf; QEMUOptionParameter *disk_type_param; int fd, i; uint16_t cyls = 0; uint8_t heads = 0; uint8_t secs_per_cyl = 0; int64_t total_sectors; int64_t total_size; int disk_type; int ret = -EIO; /* Read out options */ total_size = get_option_parameter(options, BLOCK_OPT_SIZE)->value.n; disk_type_param = get_option_parameter(options, BLOCK_OPT_SUBFMT); if (disk_type_param && disk_type_param->value.s) { if (!strcmp(disk_type_param->value.s, "dynamic")) { disk_type = VHD_DYNAMIC; } else if (!strcmp(disk_type_param->value.s, "fixed")) { disk_type = VHD_FIXED; } else { return -EINVAL; } } else { disk_type = VHD_DYNAMIC; } /* Create the file */ fd = qemu_open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644); if (fd < 0) { return -EIO; } /* * Calculate matching total_size and geometry. Increase the number of * sectors requested until we get enough (or fail). This ensures that * qemu-img convert doesn't truncate images, but rather rounds up. */ total_sectors = total_size / BDRV_SECTOR_SIZE; for (i = 0; total_sectors > (int64_t)cyls * heads * secs_per_cyl; i++) { if (calculate_geometry(total_sectors + i, &cyls, &heads, &secs_per_cyl)) { ret = -EFBIG; goto fail; } } total_sectors = (int64_t) cyls * heads * secs_per_cyl; /* Prepare the Hard Disk Footer */ memset(buf, 0, 1024); memcpy(footer->creator, "conectix", 8); /* TODO Check if "qemu" creator_app is ok for VPC */ memcpy(footer->creator_app, "qemu", 4); memcpy(footer->creator_os, "Wi2k", 4); footer->features = be32_to_cpu(0x02); footer->version = be32_to_cpu(0x00010000); if (disk_type == VHD_DYNAMIC) { footer->data_offset = be64_to_cpu(HEADER_SIZE); } else { footer->data_offset = be64_to_cpu(0xFFFFFFFFFFFFFFFFULL); } footer->timestamp = be32_to_cpu(time(NULL) - VHD_TIMESTAMP_BASE); /* Version of Virtual PC 2007 */ footer->major = be16_to_cpu(0x0005); footer->minor = be16_to_cpu(0x0003); if (disk_type == VHD_DYNAMIC) { footer->orig_size = be64_to_cpu(total_sectors * 512); footer->size = be64_to_cpu(total_sectors * 512); } else { footer->orig_size = be64_to_cpu(total_size); footer->size = be64_to_cpu(total_size); } footer->cyls = be16_to_cpu(cyls); footer->heads = heads; footer->secs_per_cyl = secs_per_cyl; footer->type = be32_to_cpu(disk_type); /* TODO uuid is missing */ footer->checksum = be32_to_cpu(vpc_checksum(buf, HEADER_SIZE)); if (disk_type == VHD_DYNAMIC) { ret = create_dynamic_disk(fd, buf, total_sectors); } else { ret = create_fixed_disk(fd, buf, total_size); } fail: qemu_close(fd); return ret; }
false
qemu
1fe1fa510aa3d4eb1fb4246d4951ef48e4c949c2
static int vpc_create(const char *filename, QEMUOptionParameter *options) { uint8_t buf[1024]; struct vhd_footer *footer = (struct vhd_footer *) buf; QEMUOptionParameter *disk_type_param; int fd, i; uint16_t cyls = 0; uint8_t heads = 0; uint8_t secs_per_cyl = 0; int64_t total_sectors; int64_t total_size; int disk_type; int ret = -EIO; total_size = get_option_parameter(options, BLOCK_OPT_SIZE)->value.n; disk_type_param = get_option_parameter(options, BLOCK_OPT_SUBFMT); if (disk_type_param && disk_type_param->value.s) { if (!strcmp(disk_type_param->value.s, "dynamic")) { disk_type = VHD_DYNAMIC; } else if (!strcmp(disk_type_param->value.s, "fixed")) { disk_type = VHD_FIXED; } else { return -EINVAL; } } else { disk_type = VHD_DYNAMIC; } fd = qemu_open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644); if (fd < 0) { return -EIO; } total_sectors = total_size / BDRV_SECTOR_SIZE; for (i = 0; total_sectors > (int64_t)cyls * heads * secs_per_cyl; i++) { if (calculate_geometry(total_sectors + i, &cyls, &heads, &secs_per_cyl)) { ret = -EFBIG; goto fail; } } total_sectors = (int64_t) cyls * heads * secs_per_cyl; memset(buf, 0, 1024); memcpy(footer->creator, "conectix", 8); memcpy(footer->creator_app, "qemu", 4); memcpy(footer->creator_os, "Wi2k", 4); footer->features = be32_to_cpu(0x02); footer->version = be32_to_cpu(0x00010000); if (disk_type == VHD_DYNAMIC) { footer->data_offset = be64_to_cpu(HEADER_SIZE); } else { footer->data_offset = be64_to_cpu(0xFFFFFFFFFFFFFFFFULL); } footer->timestamp = be32_to_cpu(time(NULL) - VHD_TIMESTAMP_BASE); footer->major = be16_to_cpu(0x0005); footer->minor = be16_to_cpu(0x0003); if (disk_type == VHD_DYNAMIC) { footer->orig_size = be64_to_cpu(total_sectors * 512); footer->size = be64_to_cpu(total_sectors * 512); } else { footer->orig_size = be64_to_cpu(total_size); footer->size = be64_to_cpu(total_size); } footer->cyls = be16_to_cpu(cyls); footer->heads = heads; footer->secs_per_cyl = secs_per_cyl; footer->type = be32_to_cpu(disk_type); footer->checksum = be32_to_cpu(vpc_checksum(buf, HEADER_SIZE)); if (disk_type == VHD_DYNAMIC) { ret = create_dynamic_disk(fd, buf, total_sectors); } else { ret = create_fixed_disk(fd, buf, total_size); } fail: qemu_close(fd); return ret; }
{ "code": [], "line_no": [] }
static int FUNC_0(const char *VAR_0, QEMUOptionParameter *VAR_1) { uint8_t buf[1024]; struct vhd_footer *VAR_2 = (struct vhd_footer *) buf; QEMUOptionParameter *disk_type_param; int VAR_3, VAR_4; uint16_t cyls = 0; uint8_t heads = 0; uint8_t secs_per_cyl = 0; int64_t total_sectors; int64_t total_size; int VAR_5; int VAR_6 = -EIO; total_size = get_option_parameter(VAR_1, BLOCK_OPT_SIZE)->value.n; disk_type_param = get_option_parameter(VAR_1, BLOCK_OPT_SUBFMT); if (disk_type_param && disk_type_param->value.s) { if (!strcmp(disk_type_param->value.s, "dynamic")) { VAR_5 = VHD_DYNAMIC; } else if (!strcmp(disk_type_param->value.s, "fixed")) { VAR_5 = VHD_FIXED; } else { return -EINVAL; } } else { VAR_5 = VHD_DYNAMIC; } VAR_3 = qemu_open(VAR_0, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644); if (VAR_3 < 0) { return -EIO; } total_sectors = total_size / BDRV_SECTOR_SIZE; for (VAR_4 = 0; total_sectors > (int64_t)cyls * heads * secs_per_cyl; VAR_4++) { if (calculate_geometry(total_sectors + VAR_4, &cyls, &heads, &secs_per_cyl)) { VAR_6 = -EFBIG; goto fail; } } total_sectors = (int64_t) cyls * heads * secs_per_cyl; memset(buf, 0, 1024); memcpy(VAR_2->creator, "conectix", 8); memcpy(VAR_2->creator_app, "qemu", 4); memcpy(VAR_2->creator_os, "Wi2k", 4); VAR_2->features = be32_to_cpu(0x02); VAR_2->version = be32_to_cpu(0x00010000); if (VAR_5 == VHD_DYNAMIC) { VAR_2->data_offset = be64_to_cpu(HEADER_SIZE); } else { VAR_2->data_offset = be64_to_cpu(0xFFFFFFFFFFFFFFFFULL); } VAR_2->timestamp = be32_to_cpu(time(NULL) - VHD_TIMESTAMP_BASE); VAR_2->major = be16_to_cpu(0x0005); VAR_2->minor = be16_to_cpu(0x0003); if (VAR_5 == VHD_DYNAMIC) { VAR_2->orig_size = be64_to_cpu(total_sectors * 512); VAR_2->size = be64_to_cpu(total_sectors * 512); } else { VAR_2->orig_size = be64_to_cpu(total_size); VAR_2->size = be64_to_cpu(total_size); } VAR_2->cyls = be16_to_cpu(cyls); VAR_2->heads = heads; VAR_2->secs_per_cyl = secs_per_cyl; VAR_2->type = be32_to_cpu(VAR_5); VAR_2->checksum = be32_to_cpu(vpc_checksum(buf, HEADER_SIZE)); if (VAR_5 == VHD_DYNAMIC) { VAR_6 = create_dynamic_disk(VAR_3, buf, total_sectors); } else { VAR_6 = create_fixed_disk(VAR_3, buf, total_size); } fail: qemu_close(VAR_3); return VAR_6; }
[ "static int FUNC_0(const char *VAR_0, QEMUOptionParameter *VAR_1)\n{", "uint8_t buf[1024];", "struct vhd_footer *VAR_2 = (struct vhd_footer *) buf;", "QEMUOptionParameter *disk_type_param;", "int VAR_3, VAR_4;", "uint16_t cyls = 0;", "uint8_t heads = 0;", "uint8_t secs_per_cyl = 0;", "int64_t total_sectors;", "int64_t total_size;", "int VAR_5;", "int VAR_6 = -EIO;", "total_size = get_option_parameter(VAR_1, BLOCK_OPT_SIZE)->value.n;", "disk_type_param = get_option_parameter(VAR_1, BLOCK_OPT_SUBFMT);", "if (disk_type_param && disk_type_param->value.s) {", "if (!strcmp(disk_type_param->value.s, \"dynamic\")) {", "VAR_5 = VHD_DYNAMIC;", "} else if (!strcmp(disk_type_param->value.s, \"fixed\")) {", "VAR_5 = VHD_FIXED;", "} else {", "return -EINVAL;", "}", "} else {", "VAR_5 = VHD_DYNAMIC;", "}", "VAR_3 = qemu_open(VAR_0, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644);", "if (VAR_3 < 0) {", "return -EIO;", "}", "total_sectors = total_size / BDRV_SECTOR_SIZE;", "for (VAR_4 = 0; total_sectors > (int64_t)cyls * heads * secs_per_cyl; VAR_4++) {", "if (calculate_geometry(total_sectors + VAR_4, &cyls, &heads,\n&secs_per_cyl))\n{", "VAR_6 = -EFBIG;", "goto fail;", "}", "}", "total_sectors = (int64_t) cyls * heads * secs_per_cyl;", "memset(buf, 0, 1024);", "memcpy(VAR_2->creator, \"conectix\", 8);", "memcpy(VAR_2->creator_app, \"qemu\", 4);", "memcpy(VAR_2->creator_os, \"Wi2k\", 4);", "VAR_2->features = be32_to_cpu(0x02);", "VAR_2->version = be32_to_cpu(0x00010000);", "if (VAR_5 == VHD_DYNAMIC) {", "VAR_2->data_offset = be64_to_cpu(HEADER_SIZE);", "} else {", "VAR_2->data_offset = be64_to_cpu(0xFFFFFFFFFFFFFFFFULL);", "}", "VAR_2->timestamp = be32_to_cpu(time(NULL) - VHD_TIMESTAMP_BASE);", "VAR_2->major = be16_to_cpu(0x0005);", "VAR_2->minor = be16_to_cpu(0x0003);", "if (VAR_5 == VHD_DYNAMIC) {", "VAR_2->orig_size = be64_to_cpu(total_sectors * 512);", "VAR_2->size = be64_to_cpu(total_sectors * 512);", "} else {", "VAR_2->orig_size = be64_to_cpu(total_size);", "VAR_2->size = be64_to_cpu(total_size);", "}", "VAR_2->cyls = be16_to_cpu(cyls);", "VAR_2->heads = heads;", "VAR_2->secs_per_cyl = secs_per_cyl;", "VAR_2->type = be32_to_cpu(VAR_5);", "VAR_2->checksum = be32_to_cpu(vpc_checksum(buf, HEADER_SIZE));", "if (VAR_5 == VHD_DYNAMIC) {", "VAR_6 = create_dynamic_disk(VAR_3, buf, total_sectors);", "} else {", "VAR_6 = create_fixed_disk(VAR_3, buf, total_size);", "}", "fail:\nqemu_close(VAR_3);", "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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 31 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 83 ], [ 85 ], [ 87, 89, 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 103 ], [ 109 ], [ 113 ], [ 117 ], [ 119 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 143 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 169 ], [ 177 ], [ 181 ], [ 183 ], [ 185 ], [ 187 ], [ 189 ], [ 193, 195 ], [ 197 ], [ 199 ] ]
9,859
void kvm_s390_interrupt_internal(S390CPU *cpu, int type, uint32_t parm, uint64_t parm64, int vm) { CPUState *cs = CPU(cpu); struct kvm_s390_interrupt kvmint; int r; if (!cs->kvm_state) { return; } kvmint.type = type; kvmint.parm = parm; kvmint.parm64 = parm64; if (vm) { r = kvm_vm_ioctl(cs->kvm_state, KVM_S390_INTERRUPT, &kvmint); } else { r = kvm_vcpu_ioctl(cs, KVM_S390_INTERRUPT, &kvmint); } if (r < 0) { fprintf(stderr, "KVM failed to inject interrupt\n"); exit(1); } }
false
qemu
de13d2161473d02ae97ec0f8e4503147554892dd
void kvm_s390_interrupt_internal(S390CPU *cpu, int type, uint32_t parm, uint64_t parm64, int vm) { CPUState *cs = CPU(cpu); struct kvm_s390_interrupt kvmint; int r; if (!cs->kvm_state) { return; } kvmint.type = type; kvmint.parm = parm; kvmint.parm64 = parm64; if (vm) { r = kvm_vm_ioctl(cs->kvm_state, KVM_S390_INTERRUPT, &kvmint); } else { r = kvm_vcpu_ioctl(cs, KVM_S390_INTERRUPT, &kvmint); } if (r < 0) { fprintf(stderr, "KVM failed to inject interrupt\n"); exit(1); } }
{ "code": [], "line_no": [] }
void FUNC_0(S390CPU *VAR_0, int VAR_1, uint32_t VAR_2, uint64_t VAR_3, int VAR_4) { CPUState *cs = CPU(VAR_0); struct kvm_s390_interrupt VAR_5; int VAR_6; if (!cs->kvm_state) { return; } VAR_5.VAR_1 = VAR_1; VAR_5.VAR_2 = VAR_2; VAR_5.VAR_3 = VAR_3; if (VAR_4) { VAR_6 = kvm_vm_ioctl(cs->kvm_state, KVM_S390_INTERRUPT, &VAR_5); } else { VAR_6 = kvm_vcpu_ioctl(cs, KVM_S390_INTERRUPT, &VAR_5); } if (VAR_6 < 0) { fprintf(stderr, "KVM failed to inject interrupt\n"); exit(1); } }
[ "void FUNC_0(S390CPU *VAR_0, int VAR_1, uint32_t VAR_2,\nuint64_t VAR_3, int VAR_4)\n{", "CPUState *cs = CPU(VAR_0);", "struct kvm_s390_interrupt VAR_5;", "int VAR_6;", "if (!cs->kvm_state) {", "return;", "}", "VAR_5.VAR_1 = VAR_1;", "VAR_5.VAR_2 = VAR_2;", "VAR_5.VAR_3 = VAR_3;", "if (VAR_4) {", "VAR_6 = kvm_vm_ioctl(cs->kvm_state, KVM_S390_INTERRUPT, &VAR_5);", "} else {", "VAR_6 = kvm_vcpu_ioctl(cs, KVM_S390_INTERRUPT, &VAR_5);", "}", "if (VAR_6 < 0) {", "fprintf(stderr, \"KVM failed to inject interrupt\\n\");", "exit(1);", "}", "}" ]
[ 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 ], [ 25 ], [ 27 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ] ]
9,862
static void *build_pci_bus_begin(PCIBus *bus, void *parent_state) { AcpiBuildPciBusHotplugState *parent = parent_state; AcpiBuildPciBusHotplugState *child = g_malloc(sizeof *child); build_pci_bus_state_init(child, parent, parent->pcihp_bridge_en); return child; }
false
qemu
b23046abe78f48498a423b802d6d86ba0172d57f
static void *build_pci_bus_begin(PCIBus *bus, void *parent_state) { AcpiBuildPciBusHotplugState *parent = parent_state; AcpiBuildPciBusHotplugState *child = g_malloc(sizeof *child); build_pci_bus_state_init(child, parent, parent->pcihp_bridge_en); return child; }
{ "code": [], "line_no": [] }
static void *FUNC_0(PCIBus *VAR_0, void *VAR_1) { AcpiBuildPciBusHotplugState *parent = VAR_1; AcpiBuildPciBusHotplugState *child = g_malloc(sizeof *child); build_pci_bus_state_init(child, parent, parent->pcihp_bridge_en); return child; }
[ "static void *FUNC_0(PCIBus *VAR_0, void *VAR_1)\n{", "AcpiBuildPciBusHotplugState *parent = VAR_1;", "AcpiBuildPciBusHotplugState *child = g_malloc(sizeof *child);", "build_pci_bus_state_init(child, parent, parent->pcihp_bridge_en);", "return child;", "}" ]
[ 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 15 ], [ 17 ] ]
9,863
static unsigned long copy_strings(int argc,char ** argv,unsigned long *page, unsigned long p) { char *tmp, *tmp1, *pag = NULL; int len, offset = 0; if (!p) { return 0; /* bullet-proofing */ } while (argc-- > 0) { if (!(tmp1 = tmp = get_user(argv+argc))) { fprintf(stderr, "VFS: argc is wrong"); exit(-1); } while (get_user(tmp++)); len = tmp - tmp1; if (p < len) { /* this shouldn't happen - 128kB */ return 0; } while (len) { --p; --tmp; --len; if (--offset < 0) { offset = p % TARGET_PAGE_SIZE; pag = (char *) page[p/TARGET_PAGE_SIZE]; if (!pag) { pag = (char *)get_free_page(); page[p/TARGET_PAGE_SIZE] = (unsigned long)pag; if (!pag) return 0; } } if (len == 0 || offset == 0) { *(pag + offset) = get_user(tmp); } else { int bytes_to_copy = (len > offset) ? offset : len; tmp -= bytes_to_copy; p -= bytes_to_copy; offset -= bytes_to_copy; len -= bytes_to_copy; memcpy_fromfs(pag + offset, tmp, bytes_to_copy + 1); } } } return p; }
false
qemu
edf779ffccc836661a7b654d320571a6c220caea
static unsigned long copy_strings(int argc,char ** argv,unsigned long *page, unsigned long p) { char *tmp, *tmp1, *pag = NULL; int len, offset = 0; if (!p) { return 0; } while (argc-- > 0) { if (!(tmp1 = tmp = get_user(argv+argc))) { fprintf(stderr, "VFS: argc is wrong"); exit(-1); } while (get_user(tmp++)); len = tmp - tmp1; if (p < len) { return 0; } while (len) { --p; --tmp; --len; if (--offset < 0) { offset = p % TARGET_PAGE_SIZE; pag = (char *) page[p/TARGET_PAGE_SIZE]; if (!pag) { pag = (char *)get_free_page(); page[p/TARGET_PAGE_SIZE] = (unsigned long)pag; if (!pag) return 0; } } if (len == 0 || offset == 0) { *(pag + offset) = get_user(tmp); } else { int bytes_to_copy = (len > offset) ? offset : len; tmp -= bytes_to_copy; p -= bytes_to_copy; offset -= bytes_to_copy; len -= bytes_to_copy; memcpy_fromfs(pag + offset, tmp, bytes_to_copy + 1); } } } return p; }
{ "code": [], "line_no": [] }
static unsigned long FUNC_0(int VAR_0,char ** VAR_1,unsigned long *VAR_2, unsigned long VAR_3) { char *VAR_4, *VAR_5, *VAR_6 = NULL; int VAR_7, VAR_8 = 0; if (!VAR_3) { return 0; } while (VAR_0-- > 0) { if (!(VAR_5 = VAR_4 = get_user(VAR_1+VAR_0))) { fprintf(stderr, "VFS: VAR_0 is wrong"); exit(-1); } while (get_user(VAR_4++)); VAR_7 = VAR_4 - VAR_5; if (VAR_3 < VAR_7) { return 0; } while (VAR_7) { --VAR_3; --VAR_4; --VAR_7; if (--VAR_8 < 0) { VAR_8 = VAR_3 % TARGET_PAGE_SIZE; VAR_6 = (char *) VAR_2[VAR_3/TARGET_PAGE_SIZE]; if (!VAR_6) { VAR_6 = (char *)get_free_page(); VAR_2[VAR_3/TARGET_PAGE_SIZE] = (unsigned long)VAR_6; if (!VAR_6) return 0; } } if (VAR_7 == 0 || VAR_8 == 0) { *(VAR_6 + VAR_8) = get_user(VAR_4); } else { int VAR_9 = (VAR_7 > VAR_8) ? VAR_8 : VAR_7; VAR_4 -= VAR_9; VAR_3 -= VAR_9; VAR_8 -= VAR_9; VAR_7 -= VAR_9; memcpy_fromfs(VAR_6 + VAR_8, VAR_4, VAR_9 + 1); } } } return VAR_3; }
[ "static unsigned long FUNC_0(int VAR_0,char ** VAR_1,unsigned long *VAR_2,\nunsigned long VAR_3)\n{", "char *VAR_4, *VAR_5, *VAR_6 = NULL;", "int VAR_7, VAR_8 = 0;", "if (!VAR_3) {", "return 0;", "}", "while (VAR_0-- > 0) {", "if (!(VAR_5 = VAR_4 = get_user(VAR_1+VAR_0))) {", "fprintf(stderr, \"VFS: VAR_0 is wrong\");", "exit(-1);", "}", "while (get_user(VAR_4++));", "VAR_7 = VAR_4 - VAR_5;", "if (VAR_3 < VAR_7) {", "return 0;", "}", "while (VAR_7) {", "--VAR_3; --VAR_4; --VAR_7;", "if (--VAR_8 < 0) {", "VAR_8 = VAR_3 % TARGET_PAGE_SIZE;", "VAR_6 = (char *) VAR_2[VAR_3/TARGET_PAGE_SIZE];", "if (!VAR_6) {", "VAR_6 = (char *)get_free_page();", "VAR_2[VAR_3/TARGET_PAGE_SIZE] = (unsigned long)VAR_6;", "if (!VAR_6)\nreturn 0;", "}", "}", "if (VAR_7 == 0 || VAR_8 == 0) {", "*(VAR_6 + VAR_8) = get_user(VAR_4);", "}", "else {", "int VAR_9 = (VAR_7 > VAR_8) ? VAR_8 : VAR_7;", "VAR_4 -= VAR_9;", "VAR_3 -= VAR_9;", "VAR_8 -= VAR_9;", "VAR_7 -= VAR_9;", "memcpy_fromfs(VAR_6 + VAR_8, VAR_4, VAR_9 + 1);", "}", "}", "}", "return VAR_3;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 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 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ] ]
9,865
void tb_set_jmp_target1(uintptr_t jmp_addr, uintptr_t addr) { uint32_t *ptr = (uint32_t *)jmp_addr; uintptr_t disp = addr - jmp_addr; /* We can reach the entire address space for 32-bit. For 64-bit the code_gen_buffer can't be larger than 2GB. */ assert(disp == (int32_t)disp); *ptr = CALL | (uint32_t)disp >> 2; flush_icache_range(jmp_addr, jmp_addr + 4); }
false
qemu
eabb7b91b36b202b4dac2df2d59d698e3aff197a
void tb_set_jmp_target1(uintptr_t jmp_addr, uintptr_t addr) { uint32_t *ptr = (uint32_t *)jmp_addr; uintptr_t disp = addr - jmp_addr; assert(disp == (int32_t)disp); *ptr = CALL | (uint32_t)disp >> 2; flush_icache_range(jmp_addr, jmp_addr + 4); }
{ "code": [], "line_no": [] }
void FUNC_0(uintptr_t VAR_0, uintptr_t VAR_1) { uint32_t *ptr = (uint32_t *)VAR_0; uintptr_t disp = VAR_1 - VAR_0; assert(disp == (int32_t)disp); *ptr = CALL | (uint32_t)disp >> 2; flush_icache_range(VAR_0, VAR_0 + 4); }
[ "void FUNC_0(uintptr_t VAR_0, uintptr_t VAR_1)\n{", "uint32_t *ptr = (uint32_t *)VAR_0;", "uintptr_t disp = VAR_1 - VAR_0;", "assert(disp == (int32_t)disp);", "*ptr = CALL | (uint32_t)disp >> 2;", "flush_icache_range(VAR_0, VAR_0 + 4);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ] ]
9,867
void mmio_ide_init (target_phys_addr_t membase, target_phys_addr_t membase2, MemoryRegion *address_space, qemu_irq irq, int shift, DriveInfo *hd0, DriveInfo *hd1) { MMIOState *s = g_malloc0(sizeof(MMIOState)); ide_init2_with_non_qdev_drives(&s->bus, hd0, hd1, irq); s->shift = shift; memory_region_init_io(&s->iomem1, &mmio_ide_ops, s, "ide-mmio.1", 16 << shift); memory_region_init_io(&s->iomem2, &mmio_ide_cs_ops, s, "ide-mmio.2", 2 << shift); memory_region_add_subregion(address_space, membase, &s->iomem1); memory_region_add_subregion(address_space, membase2, &s->iomem2); vmstate_register(NULL, 0, &vmstate_ide_mmio, s); qemu_register_reset(mmio_ide_reset, s); }
false
qemu
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
void mmio_ide_init (target_phys_addr_t membase, target_phys_addr_t membase2, MemoryRegion *address_space, qemu_irq irq, int shift, DriveInfo *hd0, DriveInfo *hd1) { MMIOState *s = g_malloc0(sizeof(MMIOState)); ide_init2_with_non_qdev_drives(&s->bus, hd0, hd1, irq); s->shift = shift; memory_region_init_io(&s->iomem1, &mmio_ide_ops, s, "ide-mmio.1", 16 << shift); memory_region_init_io(&s->iomem2, &mmio_ide_cs_ops, s, "ide-mmio.2", 2 << shift); memory_region_add_subregion(address_space, membase, &s->iomem1); memory_region_add_subregion(address_space, membase2, &s->iomem2); vmstate_register(NULL, 0, &vmstate_ide_mmio, s); qemu_register_reset(mmio_ide_reset, s); }
{ "code": [], "line_no": [] }
void FUNC_0 (target_phys_addr_t VAR_0, target_phys_addr_t VAR_1, MemoryRegion *VAR_2, qemu_irq VAR_3, int VAR_4, DriveInfo *VAR_5, DriveInfo *VAR_6) { MMIOState *s = g_malloc0(sizeof(MMIOState)); ide_init2_with_non_qdev_drives(&s->bus, VAR_5, VAR_6, VAR_3); s->VAR_4 = VAR_4; memory_region_init_io(&s->iomem1, &mmio_ide_ops, s, "ide-mmio.1", 16 << VAR_4); memory_region_init_io(&s->iomem2, &mmio_ide_cs_ops, s, "ide-mmio.2", 2 << VAR_4); memory_region_add_subregion(VAR_2, VAR_0, &s->iomem1); memory_region_add_subregion(VAR_2, VAR_1, &s->iomem2); vmstate_register(NULL, 0, &vmstate_ide_mmio, s); qemu_register_reset(mmio_ide_reset, s); }
[ "void FUNC_0 (target_phys_addr_t VAR_0, target_phys_addr_t VAR_1,\nMemoryRegion *VAR_2,\nqemu_irq VAR_3, int VAR_4,\nDriveInfo *VAR_5, DriveInfo *VAR_6)\n{", "MMIOState *s = g_malloc0(sizeof(MMIOState));", "ide_init2_with_non_qdev_drives(&s->bus, VAR_5, VAR_6, VAR_3);", "s->VAR_4 = VAR_4;", "memory_region_init_io(&s->iomem1, &mmio_ide_ops, s,\n\"ide-mmio.1\", 16 << VAR_4);", "memory_region_init_io(&s->iomem2, &mmio_ide_cs_ops, s,\n\"ide-mmio.2\", 2 << VAR_4);", "memory_region_add_subregion(VAR_2, VAR_0, &s->iomem1);", "memory_region_add_subregion(VAR_2, VAR_1, &s->iomem2);", "vmstate_register(NULL, 0, &vmstate_ide_mmio, s);", "qemu_register_reset(mmio_ide_reset, s);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9 ], [ 11 ], [ 15 ], [ 19 ], [ 23, 25 ], [ 27, 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ] ]
9,868
void ff_mpc_dequantize_and_synth(MPCContext * c, int maxband, void *data, int channels) { int i, j, ch; Band *bands = c->bands; int off; float mul; /* dequantize */ memset(c->sb_samples, 0, sizeof(c->sb_samples)); off = 0; for(i = 0; i <= maxband; i++, off += SAMPLES_PER_BAND){ for(ch = 0; ch < 2; ch++){ if(bands[i].res[ch]){ j = 0; mul = mpc_CC[bands[i].res[ch]] * mpc_SCF[bands[i].scf_idx[ch][0] & 0xFF]; for(; j < 12; j++) c->sb_samples[ch][j][i] = mul * c->Q[ch][j + off]; mul = mpc_CC[bands[i].res[ch]] * mpc_SCF[bands[i].scf_idx[ch][1] & 0xFF]; for(; j < 24; j++) c->sb_samples[ch][j][i] = mul * c->Q[ch][j + off]; mul = mpc_CC[bands[i].res[ch]] * mpc_SCF[bands[i].scf_idx[ch][2] & 0xFF]; for(; j < 36; j++) c->sb_samples[ch][j][i] = mul * c->Q[ch][j + off]; } } if(bands[i].msf){ int t1, t2; for(j = 0; j < SAMPLES_PER_BAND; j++){ t1 = c->sb_samples[0][j][i]; t2 = c->sb_samples[1][j][i]; c->sb_samples[0][j][i] = t1 + t2; c->sb_samples[1][j][i] = t1 - t2; } } } mpc_synth(c, data, channels); }
false
FFmpeg
b2a7c017336b19afc045e8a7385999c1896d4b45
void ff_mpc_dequantize_and_synth(MPCContext * c, int maxband, void *data, int channels) { int i, j, ch; Band *bands = c->bands; int off; float mul; memset(c->sb_samples, 0, sizeof(c->sb_samples)); off = 0; for(i = 0; i <= maxband; i++, off += SAMPLES_PER_BAND){ for(ch = 0; ch < 2; ch++){ if(bands[i].res[ch]){ j = 0; mul = mpc_CC[bands[i].res[ch]] * mpc_SCF[bands[i].scf_idx[ch][0] & 0xFF]; for(; j < 12; j++) c->sb_samples[ch][j][i] = mul * c->Q[ch][j + off]; mul = mpc_CC[bands[i].res[ch]] * mpc_SCF[bands[i].scf_idx[ch][1] & 0xFF]; for(; j < 24; j++) c->sb_samples[ch][j][i] = mul * c->Q[ch][j + off]; mul = mpc_CC[bands[i].res[ch]] * mpc_SCF[bands[i].scf_idx[ch][2] & 0xFF]; for(; j < 36; j++) c->sb_samples[ch][j][i] = mul * c->Q[ch][j + off]; } } if(bands[i].msf){ int t1, t2; for(j = 0; j < SAMPLES_PER_BAND; j++){ t1 = c->sb_samples[0][j][i]; t2 = c->sb_samples[1][j][i]; c->sb_samples[0][j][i] = t1 + t2; c->sb_samples[1][j][i] = t1 - t2; } } } mpc_synth(c, data, channels); }
{ "code": [], "line_no": [] }
void FUNC_0(MPCContext * VAR_0, int VAR_1, void *VAR_2, int VAR_3) { int VAR_4, VAR_5, VAR_6; Band *bands = VAR_0->bands; int VAR_7; float VAR_8; memset(VAR_0->sb_samples, 0, sizeof(VAR_0->sb_samples)); VAR_7 = 0; for(VAR_4 = 0; VAR_4 <= VAR_1; VAR_4++, VAR_7 += SAMPLES_PER_BAND){ for(VAR_6 = 0; VAR_6 < 2; VAR_6++){ if(bands[VAR_4].res[VAR_6]){ VAR_5 = 0; VAR_8 = mpc_CC[bands[VAR_4].res[VAR_6]] * mpc_SCF[bands[VAR_4].scf_idx[VAR_6][0] & 0xFF]; for(; VAR_5 < 12; VAR_5++) VAR_0->sb_samples[VAR_6][VAR_5][VAR_4] = VAR_8 * VAR_0->Q[VAR_6][VAR_5 + VAR_7]; VAR_8 = mpc_CC[bands[VAR_4].res[VAR_6]] * mpc_SCF[bands[VAR_4].scf_idx[VAR_6][1] & 0xFF]; for(; VAR_5 < 24; VAR_5++) VAR_0->sb_samples[VAR_6][VAR_5][VAR_4] = VAR_8 * VAR_0->Q[VAR_6][VAR_5 + VAR_7]; VAR_8 = mpc_CC[bands[VAR_4].res[VAR_6]] * mpc_SCF[bands[VAR_4].scf_idx[VAR_6][2] & 0xFF]; for(; VAR_5 < 36; VAR_5++) VAR_0->sb_samples[VAR_6][VAR_5][VAR_4] = VAR_8 * VAR_0->Q[VAR_6][VAR_5 + VAR_7]; } } if(bands[VAR_4].msf){ int VAR_9, VAR_10; for(VAR_5 = 0; VAR_5 < SAMPLES_PER_BAND; VAR_5++){ VAR_9 = VAR_0->sb_samples[0][VAR_5][VAR_4]; VAR_10 = VAR_0->sb_samples[1][VAR_5][VAR_4]; VAR_0->sb_samples[0][VAR_5][VAR_4] = VAR_9 + VAR_10; VAR_0->sb_samples[1][VAR_5][VAR_4] = VAR_9 - VAR_10; } } } mpc_synth(VAR_0, VAR_2, VAR_3); }
[ "void FUNC_0(MPCContext * VAR_0, int VAR_1, void *VAR_2, int VAR_3)\n{", "int VAR_4, VAR_5, VAR_6;", "Band *bands = VAR_0->bands;", "int VAR_7;", "float VAR_8;", "memset(VAR_0->sb_samples, 0, sizeof(VAR_0->sb_samples));", "VAR_7 = 0;", "for(VAR_4 = 0; VAR_4 <= VAR_1; VAR_4++, VAR_7 += SAMPLES_PER_BAND){", "for(VAR_6 = 0; VAR_6 < 2; VAR_6++){", "if(bands[VAR_4].res[VAR_6]){", "VAR_5 = 0;", "VAR_8 = mpc_CC[bands[VAR_4].res[VAR_6]] * mpc_SCF[bands[VAR_4].scf_idx[VAR_6][0] & 0xFF];", "for(; VAR_5 < 12; VAR_5++)", "VAR_0->sb_samples[VAR_6][VAR_5][VAR_4] = VAR_8 * VAR_0->Q[VAR_6][VAR_5 + VAR_7];", "VAR_8 = mpc_CC[bands[VAR_4].res[VAR_6]] * mpc_SCF[bands[VAR_4].scf_idx[VAR_6][1] & 0xFF];", "for(; VAR_5 < 24; VAR_5++)", "VAR_0->sb_samples[VAR_6][VAR_5][VAR_4] = VAR_8 * VAR_0->Q[VAR_6][VAR_5 + VAR_7];", "VAR_8 = mpc_CC[bands[VAR_4].res[VAR_6]] * mpc_SCF[bands[VAR_4].scf_idx[VAR_6][2] & 0xFF];", "for(; VAR_5 < 36; VAR_5++)", "VAR_0->sb_samples[VAR_6][VAR_5][VAR_4] = VAR_8 * VAR_0->Q[VAR_6][VAR_5 + VAR_7];", "}", "}", "if(bands[VAR_4].msf){", "int VAR_9, VAR_10;", "for(VAR_5 = 0; VAR_5 < SAMPLES_PER_BAND; VAR_5++){", "VAR_9 = VAR_0->sb_samples[0][VAR_5][VAR_4];", "VAR_10 = VAR_0->sb_samples[1][VAR_5][VAR_4];", "VAR_0->sb_samples[0][VAR_5][VAR_4] = VAR_9 + VAR_10;", "VAR_0->sb_samples[1][VAR_5][VAR_4] = VAR_9 - VAR_10;", "}", "}", "}", "mpc_synth(VAR_0, VAR_2, VAR_3);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 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 ], [ 73 ], [ 75 ] ]
9,869
static int raw_probe_blocksizes(BlockDriverState *bs, BlockSizes *bsz) { BDRVRawState *s = bs->opaque; int ret; ret = bdrv_probe_blocksizes(bs->file->bs, bsz); if (ret < 0) { return ret; } if (!QEMU_IS_ALIGNED(s->offset, MAX(bsz->log, bsz->phys))) { return -ENOTSUP; } return 0; }
false
qemu
2e6fc7eb1a4af1b127df5f07b8bb28af891946fa
static int raw_probe_blocksizes(BlockDriverState *bs, BlockSizes *bsz) { BDRVRawState *s = bs->opaque; int ret; ret = bdrv_probe_blocksizes(bs->file->bs, bsz); if (ret < 0) { return ret; } if (!QEMU_IS_ALIGNED(s->offset, MAX(bsz->log, bsz->phys))) { return -ENOTSUP; } return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(BlockDriverState *VAR_0, BlockSizes *VAR_1) { BDRVRawState *s = VAR_0->opaque; int VAR_2; VAR_2 = bdrv_probe_blocksizes(VAR_0->file->VAR_0, VAR_1); if (VAR_2 < 0) { return VAR_2; } if (!QEMU_IS_ALIGNED(s->offset, MAX(VAR_1->log, VAR_1->phys))) { return -ENOTSUP; } return 0; }
[ "static int FUNC_0(BlockDriverState *VAR_0, BlockSizes *VAR_1)\n{", "BDRVRawState *s = VAR_0->opaque;", "int VAR_2;", "VAR_2 = bdrv_probe_blocksizes(VAR_0->file->VAR_0, VAR_1);", "if (VAR_2 < 0) {", "return VAR_2;", "}", "if (!QEMU_IS_ALIGNED(s->offset, MAX(VAR_1->log, VAR_1->phys))) {", "return -ENOTSUP;", "}", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 23 ], [ 25 ], [ 29 ], [ 31 ] ]
9,871
BlockJobInfo *block_job_query(BlockJob *job) { BlockJobInfo *info = g_new0(BlockJobInfo, 1); info->type = g_strdup(BlockJobType_lookup[job->driver->job_type]); info->device = g_strdup(bdrv_get_device_name(job->bs)); info->len = job->len; info->busy = job->busy; info->paused = job->paused; info->offset = job->offset; info->speed = job->speed; info->io_status = job->iostatus; info->ready = job->ready; return info; }
false
qemu
751ebd76e654bd1e65da08ecf694325282b4cfcc
BlockJobInfo *block_job_query(BlockJob *job) { BlockJobInfo *info = g_new0(BlockJobInfo, 1); info->type = g_strdup(BlockJobType_lookup[job->driver->job_type]); info->device = g_strdup(bdrv_get_device_name(job->bs)); info->len = job->len; info->busy = job->busy; info->paused = job->paused; info->offset = job->offset; info->speed = job->speed; info->io_status = job->iostatus; info->ready = job->ready; return info; }
{ "code": [], "line_no": [] }
BlockJobInfo *FUNC_0(BlockJob *job) { BlockJobInfo *info = g_new0(BlockJobInfo, 1); info->type = g_strdup(BlockJobType_lookup[job->driver->job_type]); info->device = g_strdup(bdrv_get_device_name(job->bs)); info->len = job->len; info->busy = job->busy; info->paused = job->paused; info->offset = job->offset; info->speed = job->speed; info->io_status = job->iostatus; info->ready = job->ready; return info; }
[ "BlockJobInfo *FUNC_0(BlockJob *job)\n{", "BlockJobInfo *info = g_new0(BlockJobInfo, 1);", "info->type = g_strdup(BlockJobType_lookup[job->driver->job_type]);", "info->device = g_strdup(bdrv_get_device_name(job->bs));", "info->len = job->len;", "info->busy = job->busy;", "info->paused = job->paused;", "info->offset = job->offset;", "info->speed = job->speed;", "info->io_status = job->iostatus;", "info->ready = job->ready;", "return info;", "}" ]
[ 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 ] ]
9,873
vcard_emul_options(const char *args) { int reader_count = 0; VCardEmulOptions *opts; /* Allow the future use of allocating the options structure on the fly */ memcpy(&options, &default_options, sizeof(options)); opts = &options; do { args = strip(args); /* strip off the leading spaces */ if (*args == ',') { continue; } /* soft=(slot_name,virt_name,emul_type,emul_flags,cert_1, (no eol) * cert_2,cert_3...) */ if (strncmp(args, "soft=", 5) == 0) { const char *name; size_t name_length; const char *vname; size_t vname_length; const char *type_params; size_t type_params_length; char type_str[100]; VCardEmulType type; int count, i; VirtualReaderOptions *vreaderOpt = NULL; args = strip(args + 5); if (*args != '(') { continue; } args = strip(args+1); NEXT_TOKEN(name) NEXT_TOKEN(vname) NEXT_TOKEN(type_params) type_params_length = MIN(type_params_length, sizeof(type_str)-1); memcpy(type_str, type_params, type_params_length); type_str[type_params_length] = '\0'; type = vcard_emul_type_from_string(type_str); NEXT_TOKEN(type_params) if (*args == 0) { break; } if (opts->vreader_count >= reader_count) { reader_count += READER_STEP; vreaderOpt = g_renew(VirtualReaderOptions, opts->vreader, reader_count); } opts->vreader = vreaderOpt; vreaderOpt = &vreaderOpt[opts->vreader_count]; vreaderOpt->name = g_strndup(name, name_length); vreaderOpt->vname = g_strndup(vname, vname_length); vreaderOpt->card_type = type; vreaderOpt->type_params = g_strndup(type_params, type_params_length); count = count_tokens(args, ',', ')') + 1; vreaderOpt->cert_count = count; vreaderOpt->cert_name = g_new(char *, count); for (i = 0; i < count; i++) { const char *cert = args; args = strpbrk(args, ",)"); vreaderOpt->cert_name[i] = g_strndup(cert, args - cert); args = strip(args+1); } if (*args == ')') { args++; } opts->vreader_count++; /* use_hw= */ } else if (strncmp(args, "use_hw=", 7) == 0) { args = strip(args+7); if (*args == '0' || *args == 'N' || *args == 'n' || *args == 'F') { opts->use_hw = PR_FALSE; } else { opts->use_hw = PR_TRUE; } args = find_blank(args); /* hw_type= */ } else if (strncmp(args, "hw_type=", 8) == 0) { args = strip(args+8); opts->hw_card_type = vcard_emul_type_from_string(args); args = find_blank(args); /* hw_params= */ } else if (strncmp(args, "hw_params=", 10) == 0) { const char *params; args = strip(args+10); params = args; args = find_blank(args); opts->hw_type_params = g_strndup(params, args-params); /* db="/data/base/path" */ } else if (strncmp(args, "db=", 3) == 0) { const char *db; args = strip(args+3); if (*args != '"') { continue; } args++; db = args; args = strpbrk(args, "\"\n"); opts->nss_db = g_strndup(db, args-db); if (*args != 0) { args++; } } else { args = find_blank(args); } } while (*args != 0); return opts; }
true
qemu
d09b8fa161ed6a61339d4d0870f76f13c033b2a3
vcard_emul_options(const char *args) { int reader_count = 0; VCardEmulOptions *opts; memcpy(&options, &default_options, sizeof(options)); opts = &options; do { args = strip(args); if (*args == ',') { continue; } if (strncmp(args, "soft=", 5) == 0) { const char *name; size_t name_length; const char *vname; size_t vname_length; const char *type_params; size_t type_params_length; char type_str[100]; VCardEmulType type; int count, i; VirtualReaderOptions *vreaderOpt = NULL; args = strip(args + 5); if (*args != '(') { continue; } args = strip(args+1); NEXT_TOKEN(name) NEXT_TOKEN(vname) NEXT_TOKEN(type_params) type_params_length = MIN(type_params_length, sizeof(type_str)-1); memcpy(type_str, type_params, type_params_length); type_str[type_params_length] = '\0'; type = vcard_emul_type_from_string(type_str); NEXT_TOKEN(type_params) if (*args == 0) { break; } if (opts->vreader_count >= reader_count) { reader_count += READER_STEP; vreaderOpt = g_renew(VirtualReaderOptions, opts->vreader, reader_count); } opts->vreader = vreaderOpt; vreaderOpt = &vreaderOpt[opts->vreader_count]; vreaderOpt->name = g_strndup(name, name_length); vreaderOpt->vname = g_strndup(vname, vname_length); vreaderOpt->card_type = type; vreaderOpt->type_params = g_strndup(type_params, type_params_length); count = count_tokens(args, ',', ')') + 1; vreaderOpt->cert_count = count; vreaderOpt->cert_name = g_new(char *, count); for (i = 0; i < count; i++) { const char *cert = args; args = strpbrk(args, ",)"); vreaderOpt->cert_name[i] = g_strndup(cert, args - cert); args = strip(args+1); } if (*args == ')') { args++; } opts->vreader_count++; } else if (strncmp(args, "use_hw=", 7) == 0) { args = strip(args+7); if (*args == '0' || *args == 'N' || *args == 'n' || *args == 'F') { opts->use_hw = PR_FALSE; } else { opts->use_hw = PR_TRUE; } args = find_blank(args); } else if (strncmp(args, "hw_type=", 8) == 0) { args = strip(args+8); opts->hw_card_type = vcard_emul_type_from_string(args); args = find_blank(args); } else if (strncmp(args, "hw_params=", 10) == 0) { const char *params; args = strip(args+10); params = args; args = find_blank(args); opts->hw_type_params = g_strndup(params, args-params); } else if (strncmp(args, "db=", 3) == 0) { const char *db; args = strip(args+3); if (*args != '"') { continue; } args++; db = args; args = strpbrk(args, "\"\n"); opts->nss_db = g_strndup(db, args-db); if (*args != 0) { args++; } } else { args = find_blank(args); } } while (*args != 0); return opts; }
{ "code": [ " VirtualReaderOptions *vreaderOpt = NULL;", " vreaderOpt = g_renew(VirtualReaderOptions, opts->vreader,", " reader_count);", " opts->vreader = vreaderOpt;", " vreaderOpt = &vreaderOpt[opts->vreader_count];" ], "line_no": [ 53, 101, 103, 107, 109 ] }
FUNC_0(const char *VAR_0) { int VAR_1 = 0; VCardEmulOptions *opts; memcpy(&options, &default_options, sizeof(options)); opts = &options; do { VAR_0 = strip(VAR_0); if (*VAR_0 == ',') { continue; } if (strncmp(VAR_0, "soft=", 5) == 0) { const char *VAR_2; size_t name_length; const char *VAR_3; size_t vname_length; const char *VAR_4; size_t type_params_length; char VAR_5[100]; VCardEmulType type; int VAR_6, VAR_7; VirtualReaderOptions *vreaderOpt = NULL; VAR_0 = strip(VAR_0 + 5); if (*VAR_0 != '(') { continue; } VAR_0 = strip(VAR_0+1); NEXT_TOKEN(VAR_2) NEXT_TOKEN(VAR_3) NEXT_TOKEN(VAR_4) type_params_length = MIN(type_params_length, sizeof(VAR_5)-1); memcpy(VAR_5, VAR_4, type_params_length); VAR_5[type_params_length] = '\0'; type = vcard_emul_type_from_string(VAR_5); NEXT_TOKEN(VAR_4) if (*VAR_0 == 0) { break; } if (opts->vreader_count >= VAR_1) { VAR_1 += READER_STEP; vreaderOpt = g_renew(VirtualReaderOptions, opts->vreader, VAR_1); } opts->vreader = vreaderOpt; vreaderOpt = &vreaderOpt[opts->vreader_count]; vreaderOpt->VAR_2 = g_strndup(VAR_2, name_length); vreaderOpt->VAR_3 = g_strndup(VAR_3, vname_length); vreaderOpt->card_type = type; vreaderOpt->VAR_4 = g_strndup(VAR_4, type_params_length); VAR_6 = count_tokens(VAR_0, ',', ')') + 1; vreaderOpt->cert_count = VAR_6; vreaderOpt->cert_name = g_new(char *, VAR_6); for (VAR_7 = 0; VAR_7 < VAR_6; VAR_7++) { const char *VAR_8 = VAR_0; VAR_0 = strpbrk(VAR_0, ",)"); vreaderOpt->cert_name[VAR_7] = g_strndup(VAR_8, VAR_0 - VAR_8); VAR_0 = strip(VAR_0+1); } if (*VAR_0 == ')') { VAR_0++; } opts->vreader_count++; } else if (strncmp(VAR_0, "use_hw=", 7) == 0) { VAR_0 = strip(VAR_0+7); if (*VAR_0 == '0' || *VAR_0 == 'N' || *VAR_0 == 'n' || *VAR_0 == 'F') { opts->use_hw = PR_FALSE; } else { opts->use_hw = PR_TRUE; } VAR_0 = find_blank(VAR_0); } else if (strncmp(VAR_0, "hw_type=", 8) == 0) { VAR_0 = strip(VAR_0+8); opts->hw_card_type = vcard_emul_type_from_string(VAR_0); VAR_0 = find_blank(VAR_0); } else if (strncmp(VAR_0, "hw_params=", 10) == 0) { const char *VAR_9; VAR_0 = strip(VAR_0+10); VAR_9 = VAR_0; VAR_0 = find_blank(VAR_0); opts->hw_type_params = g_strndup(VAR_9, VAR_0-VAR_9); } else if (strncmp(VAR_0, "VAR_10=", 3) == 0) { const char *VAR_10; VAR_0 = strip(VAR_0+3); if (*VAR_0 != '"') { continue; } VAR_0++; VAR_10 = VAR_0; VAR_0 = strpbrk(VAR_0, "\"\n"); opts->nss_db = g_strndup(VAR_10, VAR_0-VAR_10); if (*VAR_0 != 0) { VAR_0++; } } else { VAR_0 = find_blank(VAR_0); } } while (*VAR_0 != 0); return opts; }
[ "FUNC_0(const char *VAR_0)\n{", "int VAR_1 = 0;", "VCardEmulOptions *opts;", "memcpy(&options, &default_options, sizeof(options));", "opts = &options;", "do {", "VAR_0 = strip(VAR_0);", "if (*VAR_0 == ',') {", "continue;", "}", "if (strncmp(VAR_0, \"soft=\", 5) == 0) {", "const char *VAR_2;", "size_t name_length;", "const char *VAR_3;", "size_t vname_length;", "const char *VAR_4;", "size_t type_params_length;", "char VAR_5[100];", "VCardEmulType type;", "int VAR_6, VAR_7;", "VirtualReaderOptions *vreaderOpt = NULL;", "VAR_0 = strip(VAR_0 + 5);", "if (*VAR_0 != '(') {", "continue;", "}", "VAR_0 = strip(VAR_0+1);", "NEXT_TOKEN(VAR_2)\nNEXT_TOKEN(VAR_3)\nNEXT_TOKEN(VAR_4)\ntype_params_length = MIN(type_params_length, sizeof(VAR_5)-1);", "memcpy(VAR_5, VAR_4, type_params_length);", "VAR_5[type_params_length] = '\\0';", "type = vcard_emul_type_from_string(VAR_5);", "NEXT_TOKEN(VAR_4)\nif (*VAR_0 == 0) {", "break;", "}", "if (opts->vreader_count >= VAR_1) {", "VAR_1 += READER_STEP;", "vreaderOpt = g_renew(VirtualReaderOptions, opts->vreader,\nVAR_1);", "}", "opts->vreader = vreaderOpt;", "vreaderOpt = &vreaderOpt[opts->vreader_count];", "vreaderOpt->VAR_2 = g_strndup(VAR_2, name_length);", "vreaderOpt->VAR_3 = g_strndup(VAR_3, vname_length);", "vreaderOpt->card_type = type;", "vreaderOpt->VAR_4 =\ng_strndup(VAR_4, type_params_length);", "VAR_6 = count_tokens(VAR_0, ',', ')') + 1;", "vreaderOpt->cert_count = VAR_6;", "vreaderOpt->cert_name = g_new(char *, VAR_6);", "for (VAR_7 = 0; VAR_7 < VAR_6; VAR_7++) {", "const char *VAR_8 = VAR_0;", "VAR_0 = strpbrk(VAR_0, \",)\");", "vreaderOpt->cert_name[VAR_7] = g_strndup(VAR_8, VAR_0 - VAR_8);", "VAR_0 = strip(VAR_0+1);", "}", "if (*VAR_0 == ')') {", "VAR_0++;", "}", "opts->vreader_count++;", "} else if (strncmp(VAR_0, \"use_hw=\", 7) == 0) {", "VAR_0 = strip(VAR_0+7);", "if (*VAR_0 == '0' || *VAR_0 == 'N' || *VAR_0 == 'n' || *VAR_0 == 'F') {", "opts->use_hw = PR_FALSE;", "} else {", "opts->use_hw = PR_TRUE;", "}", "VAR_0 = find_blank(VAR_0);", "} else if (strncmp(VAR_0, \"hw_type=\", 8) == 0) {", "VAR_0 = strip(VAR_0+8);", "opts->hw_card_type = vcard_emul_type_from_string(VAR_0);", "VAR_0 = find_blank(VAR_0);", "} else if (strncmp(VAR_0, \"hw_params=\", 10) == 0) {", "const char *VAR_9;", "VAR_0 = strip(VAR_0+10);", "VAR_9 = VAR_0;", "VAR_0 = find_blank(VAR_0);", "opts->hw_type_params = g_strndup(VAR_9, VAR_0-VAR_9);", "} else if (strncmp(VAR_0, \"VAR_10=\", 3) == 0) {", "const char *VAR_10;", "VAR_0 = strip(VAR_0+3);", "if (*VAR_0 != '\"') {", "continue;", "}", "VAR_0++;", "VAR_10 = VAR_0;", "VAR_0 = strpbrk(VAR_0, \"\\\"\\n\");", "opts->nss_db = g_strndup(VAR_10, VAR_0-VAR_10);", "if (*VAR_0 != 0) {", "VAR_0++;", "}", "} else {", "VAR_0 = find_blank(VAR_0);", "}", "} while (*VAR_0 != 0);", "return opts;", "}" ]
[ 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, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 69, 71, 73, 75 ], [ 77 ], [ 79 ], [ 81 ], [ 85, 89 ], [ 91 ], [ 93 ], [ 97 ], [ 99 ], [ 101, 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117, 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 177 ], [ 179 ], [ 181 ], [ 183 ], [ 185 ], [ 187 ], [ 191 ], [ 193 ], [ 195 ], [ 197 ], [ 199 ], [ 201 ], [ 203 ], [ 205 ], [ 207 ], [ 209 ], [ 211 ], [ 213 ], [ 215 ], [ 217 ], [ 219 ], [ 221 ], [ 223 ], [ 227 ], [ 229 ] ]
9,874
static int pci_qdev_init(DeviceState *qdev) { PCIDevice *pci_dev = (PCIDevice *)qdev; PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(pci_dev); PCIBus *bus; int rc; bool is_default_rom; /* initialize cap_present for pci_is_express() and pci_config_size() */ if (pc->is_express) { pci_dev->cap_present |= QEMU_PCI_CAP_EXPRESS; } bus = PCI_BUS(qdev_get_parent_bus(qdev)); pci_dev = do_pci_register_device(pci_dev, bus, object_get_typename(OBJECT(qdev)), pci_dev->devfn); if (pci_dev == NULL) return -1; if (pc->init) { rc = pc->init(pci_dev); if (rc != 0) { do_pci_unregister_device(pci_dev); return rc; } } /* rom loading */ is_default_rom = false; if (pci_dev->romfile == NULL && pc->romfile != NULL) { pci_dev->romfile = g_strdup(pc->romfile); is_default_rom = true; } pci_add_option_rom(pci_dev, is_default_rom); return 0; }
true
qemu
178e785fb4507ec3462dc772bbe08303416ece47
static int pci_qdev_init(DeviceState *qdev) { PCIDevice *pci_dev = (PCIDevice *)qdev; PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(pci_dev); PCIBus *bus; int rc; bool is_default_rom; if (pc->is_express) { pci_dev->cap_present |= QEMU_PCI_CAP_EXPRESS; } bus = PCI_BUS(qdev_get_parent_bus(qdev)); pci_dev = do_pci_register_device(pci_dev, bus, object_get_typename(OBJECT(qdev)), pci_dev->devfn); if (pci_dev == NULL) return -1; if (pc->init) { rc = pc->init(pci_dev); if (rc != 0) { do_pci_unregister_device(pci_dev); return rc; } } is_default_rom = false; if (pci_dev->romfile == NULL && pc->romfile != NULL) { pci_dev->romfile = g_strdup(pc->romfile); is_default_rom = true; } pci_add_option_rom(pci_dev, is_default_rom); return 0; }
{ "code": [ " pci_add_option_rom(pci_dev, is_default_rom);" ], "line_no": [ 69 ] }
static int FUNC_0(DeviceState *VAR_0) { PCIDevice *pci_dev = (PCIDevice *)VAR_0; PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(pci_dev); PCIBus *bus; int VAR_1; bool is_default_rom; if (pc->is_express) { pci_dev->cap_present |= QEMU_PCI_CAP_EXPRESS; } bus = PCI_BUS(qdev_get_parent_bus(VAR_0)); pci_dev = do_pci_register_device(pci_dev, bus, object_get_typename(OBJECT(VAR_0)), pci_dev->devfn); if (pci_dev == NULL) return -1; if (pc->init) { VAR_1 = pc->init(pci_dev); if (VAR_1 != 0) { do_pci_unregister_device(pci_dev); return VAR_1; } } is_default_rom = false; if (pci_dev->romfile == NULL && pc->romfile != NULL) { pci_dev->romfile = g_strdup(pc->romfile); is_default_rom = true; } pci_add_option_rom(pci_dev, is_default_rom); return 0; }
[ "static int FUNC_0(DeviceState *VAR_0)\n{", "PCIDevice *pci_dev = (PCIDevice *)VAR_0;", "PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(pci_dev);", "PCIBus *bus;", "int VAR_1;", "bool is_default_rom;", "if (pc->is_express) {", "pci_dev->cap_present |= QEMU_PCI_CAP_EXPRESS;", "}", "bus = PCI_BUS(qdev_get_parent_bus(VAR_0));", "pci_dev = do_pci_register_device(pci_dev, bus,\nobject_get_typename(OBJECT(VAR_0)),\npci_dev->devfn);", "if (pci_dev == NULL)\nreturn -1;", "if (pc->init) {", "VAR_1 = pc->init(pci_dev);", "if (VAR_1 != 0) {", "do_pci_unregister_device(pci_dev);", "return VAR_1;", "}", "}", "is_default_rom = false;", "if (pci_dev->romfile == NULL && pc->romfile != NULL) {", "pci_dev->romfile = g_strdup(pc->romfile);", "is_default_rom = true;", "}", "pci_add_option_rom(pci_dev, is_default_rom);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 19 ], [ 21 ], [ 23 ], [ 27 ], [ 29, 31, 33 ], [ 35, 37 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 73 ], [ 75 ] ]
9,875
static void report_unavailable_features(FeatureWord w, uint32_t mask) { FeatureWordInfo *f = &feature_word_info[w]; int i; for (i = 0; i < 32; ++i) { if (1 << i & mask) { const char *reg = get_register_name_32(f->cpuid_reg); assert(reg); fprintf(stderr, "warning: %s doesn't support requested feature: " "CPUID.%02XH:%s%s%s [bit %d]\n", kvm_enabled() ? "host" : "TCG", f->cpuid_eax, reg, f->feat_names[i] ? "." : "", f->feat_names[i] ? f->feat_names[i] : "", i); } } }
true
qemu
72370dc1149d7c90d2c2218e0d0658bee23a5bf7
static void report_unavailable_features(FeatureWord w, uint32_t mask) { FeatureWordInfo *f = &feature_word_info[w]; int i; for (i = 0; i < 32; ++i) { if (1 << i & mask) { const char *reg = get_register_name_32(f->cpuid_reg); assert(reg); fprintf(stderr, "warning: %s doesn't support requested feature: " "CPUID.%02XH:%s%s%s [bit %d]\n", kvm_enabled() ? "host" : "TCG", f->cpuid_eax, reg, f->feat_names[i] ? "." : "", f->feat_names[i] ? f->feat_names[i] : "", i); } } }
{ "code": [ " if (1 << i & mask) {" ], "line_no": [ 13 ] }
static void FUNC_0(FeatureWord VAR_0, uint32_t VAR_1) { FeatureWordInfo *f = &feature_word_info[VAR_0]; int VAR_2; for (VAR_2 = 0; VAR_2 < 32; ++VAR_2) { if (1 << VAR_2 & VAR_1) { const char *VAR_3 = get_register_name_32(f->cpuid_reg); assert(VAR_3); fprintf(stderr, "warning: %s doesn't support requested feature: " "CPUID.%02XH:%s%s%s [bit %d]\n", kvm_enabled() ? "host" : "TCG", f->cpuid_eax, VAR_3, f->feat_names[VAR_2] ? "." : "", f->feat_names[VAR_2] ? f->feat_names[VAR_2] : "", VAR_2); } } }
[ "static void FUNC_0(FeatureWord VAR_0, uint32_t VAR_1)\n{", "FeatureWordInfo *f = &feature_word_info[VAR_0];", "int VAR_2;", "for (VAR_2 = 0; VAR_2 < 32; ++VAR_2) {", "if (1 << VAR_2 & VAR_1) {", "const char *VAR_3 = get_register_name_32(f->cpuid_reg);", "assert(VAR_3);", "fprintf(stderr, \"warning: %s doesn't support requested feature: \"\n\"CPUID.%02XH:%s%s%s [bit %d]\\n\",\nkvm_enabled() ? \"host\" : \"TCG\",\nf->cpuid_eax, VAR_3,\nf->feat_names[VAR_2] ? \".\" : \"\",\nf->feat_names[VAR_2] ? f->feat_names[VAR_2] : \"\", VAR_2);", "}", "}", "}" ]
[ 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19, 21, 23, 25, 27, 29 ], [ 31 ], [ 33 ], [ 35 ] ]
9,876
ISADevice *isa_create(ISABus *bus, const char *name) { DeviceState *dev; if (!bus) { hw_error("Tried to create isa device %s with no isa bus present.", name); } dev = qdev_create(BUS(bus), name); return ISA_DEVICE(dev); }
true
qemu
675463d9b6b2c2b65a713a6d906aeebe9e6750ae
ISADevice *isa_create(ISABus *bus, const char *name) { DeviceState *dev; if (!bus) { hw_error("Tried to create isa device %s with no isa bus present.", name); } dev = qdev_create(BUS(bus), name); return ISA_DEVICE(dev); }
{ "code": [ " if (!bus) {", " if (!bus) {", " hw_error(\"Tried to create isa device %s with no isa bus present.\",", " name);", " if (!bus) {", " hw_error(\"Tried to create isa device %s with no isa bus present.\",", " name);" ], "line_no": [ 9, 9, 11, 13, 9, 11, 13 ] }
ISADevice *FUNC_0(ISABus *bus, const char *name) { DeviceState *dev; if (!bus) { hw_error("Tried to create isa device %s with no isa bus present.", name); } dev = qdev_create(BUS(bus), name); return ISA_DEVICE(dev); }
[ "ISADevice *FUNC_0(ISABus *bus, const char *name)\n{", "DeviceState *dev;", "if (!bus) {", "hw_error(\"Tried to create isa device %s with no isa bus present.\",\nname);", "}", "dev = qdev_create(BUS(bus), name);", "return ISA_DEVICE(dev);", "}" ]
[ 0, 0, 1, 1, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11, 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ] ]
9,877
static int decode_slice_luma(AVCodecContext *avctx, SliceContext *slice, uint16_t *dst, int dst_stride, const uint8_t *buf, unsigned buf_size, const int16_t *qmat) { ProresContext *ctx = avctx->priv_data; LOCAL_ALIGNED_16(int16_t, blocks, [8*4*64]); int16_t *block; GetBitContext gb; int i, blocks_per_slice = slice->mb_count<<2; int ret; for (i = 0; i < blocks_per_slice; i++) ctx->bdsp.clear_block(blocks+(i<<6)); init_get_bits(&gb, buf, buf_size << 3); decode_dc_coeffs(&gb, blocks, blocks_per_slice); if ((ret = decode_ac_coeffs(avctx, &gb, blocks, blocks_per_slice)) < 0) return ret; block = blocks; for (i = 0; i < slice->mb_count; i++) { ctx->prodsp.idct_put(dst, dst_stride, block+(0<<6), qmat); ctx->prodsp.idct_put(dst +8, dst_stride, block+(1<<6), qmat); ctx->prodsp.idct_put(dst+4*dst_stride , dst_stride, block+(2<<6), qmat); ctx->prodsp.idct_put(dst+4*dst_stride+8, dst_stride, block+(3<<6), qmat); block += 4*64; dst += 16; } return 0; }
true
FFmpeg
4f5eaf0b5956e492ee5023929669b1d09aaf6299
static int decode_slice_luma(AVCodecContext *avctx, SliceContext *slice, uint16_t *dst, int dst_stride, const uint8_t *buf, unsigned buf_size, const int16_t *qmat) { ProresContext *ctx = avctx->priv_data; LOCAL_ALIGNED_16(int16_t, blocks, [8*4*64]); int16_t *block; GetBitContext gb; int i, blocks_per_slice = slice->mb_count<<2; int ret; for (i = 0; i < blocks_per_slice; i++) ctx->bdsp.clear_block(blocks+(i<<6)); init_get_bits(&gb, buf, buf_size << 3); decode_dc_coeffs(&gb, blocks, blocks_per_slice); if ((ret = decode_ac_coeffs(avctx, &gb, blocks, blocks_per_slice)) < 0) return ret; block = blocks; for (i = 0; i < slice->mb_count; i++) { ctx->prodsp.idct_put(dst, dst_stride, block+(0<<6), qmat); ctx->prodsp.idct_put(dst +8, dst_stride, block+(1<<6), qmat); ctx->prodsp.idct_put(dst+4*dst_stride , dst_stride, block+(2<<6), qmat); ctx->prodsp.idct_put(dst+4*dst_stride+8, dst_stride, block+(3<<6), qmat); block += 4*64; dst += 16; } return 0; }
{ "code": [ " decode_dc_coeffs(&gb, blocks, blocks_per_slice);", " decode_dc_coeffs(&gb, blocks, blocks_per_slice);" ], "line_no": [ 35, 35 ] }
static int FUNC_0(AVCodecContext *VAR_0, SliceContext *VAR_1, uint16_t *VAR_2, int VAR_3, const uint8_t *VAR_4, unsigned VAR_5, const int16_t *VAR_6) { ProresContext *ctx = VAR_0->priv_data; LOCAL_ALIGNED_16(int16_t, blocks, [8*4*64]); int16_t *block; GetBitContext gb; int VAR_7, VAR_8 = VAR_1->mb_count<<2; int VAR_9; for (VAR_7 = 0; VAR_7 < VAR_8; VAR_7++) ctx->bdsp.clear_block(blocks+(VAR_7<<6)); init_get_bits(&gb, VAR_4, VAR_5 << 3); decode_dc_coeffs(&gb, blocks, VAR_8); if ((VAR_9 = decode_ac_coeffs(VAR_0, &gb, blocks, VAR_8)) < 0) return VAR_9; block = blocks; for (VAR_7 = 0; VAR_7 < VAR_1->mb_count; VAR_7++) { ctx->prodsp.idct_put(VAR_2, VAR_3, block+(0<<6), VAR_6); ctx->prodsp.idct_put(VAR_2 +8, VAR_3, block+(1<<6), VAR_6); ctx->prodsp.idct_put(VAR_2+4*VAR_3 , VAR_3, block+(2<<6), VAR_6); ctx->prodsp.idct_put(VAR_2+4*VAR_3+8, VAR_3, block+(3<<6), VAR_6); block += 4*64; VAR_2 += 16; } return 0; }
[ "static int FUNC_0(AVCodecContext *VAR_0, SliceContext *VAR_1,\nuint16_t *VAR_2, int VAR_3,\nconst uint8_t *VAR_4, unsigned VAR_5,\nconst int16_t *VAR_6)\n{", "ProresContext *ctx = VAR_0->priv_data;", "LOCAL_ALIGNED_16(int16_t, blocks, [8*4*64]);", "int16_t *block;", "GetBitContext gb;", "int VAR_7, VAR_8 = VAR_1->mb_count<<2;", "int VAR_9;", "for (VAR_7 = 0; VAR_7 < VAR_8; VAR_7++)", "ctx->bdsp.clear_block(blocks+(VAR_7<<6));", "init_get_bits(&gb, VAR_4, VAR_5 << 3);", "decode_dc_coeffs(&gb, blocks, VAR_8);", "if ((VAR_9 = decode_ac_coeffs(VAR_0, &gb, blocks, VAR_8)) < 0)\nreturn VAR_9;", "block = blocks;", "for (VAR_7 = 0; VAR_7 < VAR_1->mb_count; VAR_7++) {", "ctx->prodsp.idct_put(VAR_2, VAR_3, block+(0<<6), VAR_6);", "ctx->prodsp.idct_put(VAR_2 +8, VAR_3, block+(1<<6), VAR_6);", "ctx->prodsp.idct_put(VAR_2+4*VAR_3 , VAR_3, block+(2<<6), VAR_6);", "ctx->prodsp.idct_put(VAR_2+4*VAR_3+8, VAR_3, block+(3<<6), VAR_6);", "block += 4*64;", "VAR_2 += 16;", "}", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 25 ], [ 27 ], [ 31 ], [ 35 ], [ 37, 39 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ] ]
9,878
static int read_uncompressed_sgi(const SGIInfo *si, AVPicture *pict, ByteIOContext *f) { int x, y, z, chan_offset, ret = 0; uint8_t *dest_row, *tmp_row = NULL; tmp_row = av_malloc(si->xsize); /* skip header */ url_fseek(f, SGI_HEADER_SIZE, SEEK_SET); pict->linesize[0] = si->xsize; for (z = 0; z < si->zsize; z++) { #ifndef WORDS_BIGENDIAN /* rgba -> bgra for rgba32 on little endian cpus */ if (si->zsize == 4 && z != 3) chan_offset = 2 - z; else #endif chan_offset = z; for (y = si->ysize - 1; y >= 0; y--) { dest_row = pict->data[0] + (y * si->xsize * si->zsize); if (!get_buffer(f, tmp_row, si->xsize)) { ret = -1; goto cleanup; } for (x = 0; x < si->xsize; x++) { dest_row[chan_offset] = tmp_row[x]; dest_row += si->zsize; } } } cleanup: av_free(tmp_row); return ret; }
true
FFmpeg
44f110f509d0ab4fc73b9f2363a97c6577d3850f
static int read_uncompressed_sgi(const SGIInfo *si, AVPicture *pict, ByteIOContext *f) { int x, y, z, chan_offset, ret = 0; uint8_t *dest_row, *tmp_row = NULL; tmp_row = av_malloc(si->xsize); url_fseek(f, SGI_HEADER_SIZE, SEEK_SET); pict->linesize[0] = si->xsize; for (z = 0; z < si->zsize; z++) { #ifndef WORDS_BIGENDIAN if (si->zsize == 4 && z != 3) chan_offset = 2 - z; else #endif chan_offset = z; for (y = si->ysize - 1; y >= 0; y--) { dest_row = pict->data[0] + (y * si->xsize * si->zsize); if (!get_buffer(f, tmp_row, si->xsize)) { ret = -1; goto cleanup; } for (x = 0; x < si->xsize; x++) { dest_row[chan_offset] = tmp_row[x]; dest_row += si->zsize; } } } cleanup: av_free(tmp_row); return ret; }
{ "code": [ " uint8_t *dest_row, *tmp_row = NULL;", " tmp_row = av_malloc(si->xsize);", " if (!get_buffer(f, tmp_row, si->xsize)) {", " ret = -1;", " goto cleanup;", " dest_row[chan_offset] = tmp_row[x]; ", "cleanup:", " av_free(tmp_row);" ], "line_no": [ 9, 13, 53, 55, 57, 63, 75, 77 ] }
static int FUNC_0(const SGIInfo *VAR_0, AVPicture *VAR_1, ByteIOContext *VAR_2) { int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7 = 0; uint8_t *dest_row, *tmp_row = NULL; tmp_row = av_malloc(VAR_0->xsize); url_fseek(VAR_2, SGI_HEADER_SIZE, SEEK_SET); VAR_1->linesize[0] = VAR_0->xsize; for (VAR_5 = 0; VAR_5 < VAR_0->zsize; VAR_5++) { #ifndef WORDS_BIGENDIAN if (VAR_0->zsize == 4 && VAR_5 != 3) VAR_6 = 2 - VAR_5; else #endif VAR_6 = VAR_5; for (VAR_4 = VAR_0->ysize - 1; VAR_4 >= 0; VAR_4--) { dest_row = VAR_1->data[0] + (VAR_4 * VAR_0->xsize * VAR_0->zsize); if (!get_buffer(VAR_2, tmp_row, VAR_0->xsize)) { VAR_7 = -1; goto cleanup; } for (VAR_3 = 0; VAR_3 < VAR_0->xsize; VAR_3++) { dest_row[VAR_6] = tmp_row[VAR_3]; dest_row += VAR_0->zsize; } } } cleanup: av_free(tmp_row); return VAR_7; }
[ "static int FUNC_0(const SGIInfo *VAR_0,\nAVPicture *VAR_1, ByteIOContext *VAR_2)\n{", "int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7 = 0;", "uint8_t *dest_row, *tmp_row = NULL;", "tmp_row = av_malloc(VAR_0->xsize);", "url_fseek(VAR_2, SGI_HEADER_SIZE, SEEK_SET);", "VAR_1->linesize[0] = VAR_0->xsize;", "for (VAR_5 = 0; VAR_5 < VAR_0->zsize; VAR_5++) {", "#ifndef WORDS_BIGENDIAN\nif (VAR_0->zsize == 4 && VAR_5 != 3)\nVAR_6 = 2 - VAR_5;", "else\n#endif\nVAR_6 = VAR_5;", "for (VAR_4 = VAR_0->ysize - 1; VAR_4 >= 0; VAR_4--) {", "dest_row = VAR_1->data[0] + (VAR_4 * VAR_0->xsize * VAR_0->zsize);", "if (!get_buffer(VAR_2, tmp_row, VAR_0->xsize)) {", "VAR_7 = -1;", "goto cleanup;", "}", "for (VAR_3 = 0; VAR_3 < VAR_0->xsize; VAR_3++) {", "dest_row[VAR_6] = tmp_row[VAR_3];", "dest_row += VAR_0->zsize;", "}", "}", "}", "cleanup:\nav_free(tmp_row);", "return VAR_7;", "}" ]
[ 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13 ], [ 19 ], [ 23 ], [ 27 ], [ 31, 35, 37 ], [ 39, 41, 43 ], [ 47 ], [ 49 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 75, 77 ], [ 79 ], [ 81 ] ]
9,879
static int coroutine_fn bdrv_driver_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags) { BlockDriver *drv = bs->drv; int64_t sector_num; unsigned int nb_sectors; int ret; if (drv->bdrv_co_pwritev) { ret = drv->bdrv_co_pwritev(bs, offset, bytes, qiov, flags & bs->supported_write_flags); flags &= ~bs->supported_write_flags; goto emulate_flags; } sector_num = offset >> BDRV_SECTOR_BITS; nb_sectors = bytes >> BDRV_SECTOR_BITS; assert((offset & (BDRV_SECTOR_SIZE - 1)) == 0); assert((bytes & (BDRV_SECTOR_SIZE - 1)) == 0); assert((bytes >> BDRV_SECTOR_BITS) <= BDRV_REQUEST_MAX_SECTORS); if (drv->bdrv_co_writev_flags) { ret = drv->bdrv_co_writev_flags(bs, sector_num, nb_sectors, qiov, flags & bs->supported_write_flags); flags &= ~bs->supported_write_flags; } else if (drv->bdrv_co_writev) { assert(!bs->supported_write_flags); ret = drv->bdrv_co_writev(bs, sector_num, nb_sectors, qiov); } else { BlockAIOCB *acb; CoroutineIOCompletion co = { .coroutine = qemu_coroutine_self(), }; acb = bs->drv->bdrv_aio_writev(bs, sector_num, qiov, nb_sectors, bdrv_co_io_em_complete, &co); if (acb == NULL) { ret = -EIO; } else { qemu_coroutine_yield(); ret = co.ret; } } emulate_flags: if (ret == 0 && (flags & BDRV_REQ_FUA)) { ret = bdrv_co_flush(bs); } return ret; }
true
qemu
fa166538743d4e28de7374c41332c3e448826f4b
static int coroutine_fn bdrv_driver_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags) { BlockDriver *drv = bs->drv; int64_t sector_num; unsigned int nb_sectors; int ret; if (drv->bdrv_co_pwritev) { ret = drv->bdrv_co_pwritev(bs, offset, bytes, qiov, flags & bs->supported_write_flags); flags &= ~bs->supported_write_flags; goto emulate_flags; } sector_num = offset >> BDRV_SECTOR_BITS; nb_sectors = bytes >> BDRV_SECTOR_BITS; assert((offset & (BDRV_SECTOR_SIZE - 1)) == 0); assert((bytes & (BDRV_SECTOR_SIZE - 1)) == 0); assert((bytes >> BDRV_SECTOR_BITS) <= BDRV_REQUEST_MAX_SECTORS); if (drv->bdrv_co_writev_flags) { ret = drv->bdrv_co_writev_flags(bs, sector_num, nb_sectors, qiov, flags & bs->supported_write_flags); flags &= ~bs->supported_write_flags; } else if (drv->bdrv_co_writev) { assert(!bs->supported_write_flags); ret = drv->bdrv_co_writev(bs, sector_num, nb_sectors, qiov); } else { BlockAIOCB *acb; CoroutineIOCompletion co = { .coroutine = qemu_coroutine_self(), }; acb = bs->drv->bdrv_aio_writev(bs, sector_num, qiov, nb_sectors, bdrv_co_io_em_complete, &co); if (acb == NULL) { ret = -EIO; } else { qemu_coroutine_yield(); ret = co.ret; } } emulate_flags: if (ret == 0 && (flags & BDRV_REQ_FUA)) { ret = bdrv_co_flush(bs); } return ret; }
{ "code": [], "line_no": [] }
static int VAR_0 bdrv_driver_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags) { BlockDriver *drv = bs->drv; int64_t sector_num; unsigned int nb_sectors; int ret; if (drv->bdrv_co_pwritev) { ret = drv->bdrv_co_pwritev(bs, offset, bytes, qiov, flags & bs->supported_write_flags); flags &= ~bs->supported_write_flags; goto emulate_flags; } sector_num = offset >> BDRV_SECTOR_BITS; nb_sectors = bytes >> BDRV_SECTOR_BITS; assert((offset & (BDRV_SECTOR_SIZE - 1)) == 0); assert((bytes & (BDRV_SECTOR_SIZE - 1)) == 0); assert((bytes >> BDRV_SECTOR_BITS) <= BDRV_REQUEST_MAX_SECTORS); if (drv->bdrv_co_writev_flags) { ret = drv->bdrv_co_writev_flags(bs, sector_num, nb_sectors, qiov, flags & bs->supported_write_flags); flags &= ~bs->supported_write_flags; } else if (drv->bdrv_co_writev) { assert(!bs->supported_write_flags); ret = drv->bdrv_co_writev(bs, sector_num, nb_sectors, qiov); } else { BlockAIOCB *acb; CoroutineIOCompletion co = { .coroutine = qemu_coroutine_self(), }; acb = bs->drv->bdrv_aio_writev(bs, sector_num, qiov, nb_sectors, bdrv_co_io_em_complete, &co); if (acb == NULL) { ret = -EIO; } else { qemu_coroutine_yield(); ret = co.ret; } } emulate_flags: if (ret == 0 && (flags & BDRV_REQ_FUA)) { ret = bdrv_co_flush(bs); } return ret; }
[ "static int VAR_0 bdrv_driver_pwritev(BlockDriverState *bs,\nuint64_t offset, uint64_t bytes,\nQEMUIOVector *qiov, int flags)\n{", "BlockDriver *drv = bs->drv;", "int64_t sector_num;", "unsigned int nb_sectors;", "int ret;", "if (drv->bdrv_co_pwritev) {", "ret = drv->bdrv_co_pwritev(bs, offset, bytes, qiov,\nflags & bs->supported_write_flags);", "flags &= ~bs->supported_write_flags;", "goto emulate_flags;", "}", "sector_num = offset >> BDRV_SECTOR_BITS;", "nb_sectors = bytes >> BDRV_SECTOR_BITS;", "assert((offset & (BDRV_SECTOR_SIZE - 1)) == 0);", "assert((bytes & (BDRV_SECTOR_SIZE - 1)) == 0);", "assert((bytes >> BDRV_SECTOR_BITS) <= BDRV_REQUEST_MAX_SECTORS);", "if (drv->bdrv_co_writev_flags) {", "ret = drv->bdrv_co_writev_flags(bs, sector_num, nb_sectors, qiov,\nflags & bs->supported_write_flags);", "flags &= ~bs->supported_write_flags;", "} else if (drv->bdrv_co_writev) {", "assert(!bs->supported_write_flags);", "ret = drv->bdrv_co_writev(bs, sector_num, nb_sectors, qiov);", "} else {", "BlockAIOCB *acb;", "CoroutineIOCompletion co = {", ".coroutine = qemu_coroutine_self(),\n};", "acb = bs->drv->bdrv_aio_writev(bs, sector_num, qiov, nb_sectors,\nbdrv_co_io_em_complete, &co);", "if (acb == NULL) {", "ret = -EIO;", "} else {", "qemu_coroutine_yield();", "ret = co.ret;", "}", "}", "emulate_flags:\nif (ret == 0 && (flags & BDRV_REQ_FUA)) {", "ret = bdrv_co_flush(bs);", "}", "return ret;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 2, 3, 4 ], [ 5 ], [ 6 ], [ 7 ], [ 8 ], [ 9 ], [ 10, 11 ], [ 12 ], [ 13 ], [ 14 ], [ 15 ], [ 16 ], [ 17 ], [ 18 ], [ 19 ], [ 20 ], [ 21, 22 ], [ 23 ], [ 24 ], [ 25 ], [ 26 ], [ 27 ], [ 28 ], [ 29 ], [ 30, 31 ], [ 32, 33 ], [ 34 ], [ 35 ], [ 36 ], [ 37 ], [ 38 ], [ 39 ], [ 40 ], [ 41, 42 ], [ 43 ], [ 44 ], [ 45 ], [ 46 ] ]
9,881
static void host_signal_handler(int host_signum, siginfo_t *info, void *puc) { CPUArchState *env = thread_cpu->env_ptr; CPUState *cpu = ENV_GET_CPU(env); TaskState *ts = cpu->opaque; int sig; target_siginfo_t tinfo; ucontext_t *uc = puc; struct emulated_sigtable *k; /* the CPU emulator uses some host signals to detect exceptions, we forward to it some signals */ if ((host_signum == SIGSEGV || host_signum == SIGBUS) && info->si_code > 0) { if (cpu_signal_handler(host_signum, info, puc)) return; } /* get target signal number */ sig = host_to_target_signal(host_signum); if (sig < 1 || sig > TARGET_NSIG) return; trace_user_host_signal(env, host_signum, sig); rewind_if_in_safe_syscall(puc); host_to_target_siginfo_noswap(&tinfo, info); k = &ts->sigtab[sig - 1]; k->info = tinfo; k->pending = sig; ts->signal_pending = 1; /* Block host signals until target signal handler entered. We * can't block SIGSEGV or SIGBUS while we're executing guest * code in case the guest code provokes one in the window between * now and it getting out to the main loop. Signals will be * unblocked again in process_pending_signals(). */ sigfillset(&uc->uc_sigmask); sigdelset(&uc->uc_sigmask, SIGSEGV); sigdelset(&uc->uc_sigmask, SIGBUS); /* interrupt the virtual CPU as soon as possible */ cpu_exit(thread_cpu); }
true
qemu
1d48fdd9d84aab1bd32c1f70947932f5d90f92aa
static void host_signal_handler(int host_signum, siginfo_t *info, void *puc) { CPUArchState *env = thread_cpu->env_ptr; CPUState *cpu = ENV_GET_CPU(env); TaskState *ts = cpu->opaque; int sig; target_siginfo_t tinfo; ucontext_t *uc = puc; struct emulated_sigtable *k; if ((host_signum == SIGSEGV || host_signum == SIGBUS) && info->si_code > 0) { if (cpu_signal_handler(host_signum, info, puc)) return; } sig = host_to_target_signal(host_signum); if (sig < 1 || sig > TARGET_NSIG) return; trace_user_host_signal(env, host_signum, sig); rewind_if_in_safe_syscall(puc); host_to_target_siginfo_noswap(&tinfo, info); k = &ts->sigtab[sig - 1]; k->info = tinfo; k->pending = sig; ts->signal_pending = 1; sigfillset(&uc->uc_sigmask); sigdelset(&uc->uc_sigmask, SIGSEGV); sigdelset(&uc->uc_sigmask, SIGBUS); cpu_exit(thread_cpu); }
{ "code": [ " sigfillset(&uc->uc_sigmask);" ], "line_no": [ 81 ] }
static void FUNC_0(int VAR_0, siginfo_t *VAR_1, void *VAR_2) { CPUArchState *env = thread_cpu->env_ptr; CPUState *cpu = ENV_GET_CPU(env); TaskState *ts = cpu->opaque; int VAR_3; target_siginfo_t tinfo; ucontext_t *uc = VAR_2; struct emulated_sigtable *VAR_4; if ((VAR_0 == SIGSEGV || VAR_0 == SIGBUS) && VAR_1->si_code > 0) { if (cpu_signal_handler(VAR_0, VAR_1, VAR_2)) return; } VAR_3 = host_to_target_signal(VAR_0); if (VAR_3 < 1 || VAR_3 > TARGET_NSIG) return; trace_user_host_signal(env, VAR_0, VAR_3); rewind_if_in_safe_syscall(VAR_2); host_to_target_siginfo_noswap(&tinfo, VAR_1); VAR_4 = &ts->sigtab[VAR_3 - 1]; VAR_4->VAR_1 = tinfo; VAR_4->pending = VAR_3; ts->signal_pending = 1; sigfillset(&uc->uc_sigmask); sigdelset(&uc->uc_sigmask, SIGSEGV); sigdelset(&uc->uc_sigmask, SIGBUS); cpu_exit(thread_cpu); }
[ "static void FUNC_0(int VAR_0, siginfo_t *VAR_1,\nvoid *VAR_2)\n{", "CPUArchState *env = thread_cpu->env_ptr;", "CPUState *cpu = ENV_GET_CPU(env);", "TaskState *ts = cpu->opaque;", "int VAR_3;", "target_siginfo_t tinfo;", "ucontext_t *uc = VAR_2;", "struct emulated_sigtable *VAR_4;", "if ((VAR_0 == SIGSEGV || VAR_0 == SIGBUS)\n&& VAR_1->si_code > 0) {", "if (cpu_signal_handler(VAR_0, VAR_1, VAR_2))\nreturn;", "}", "VAR_3 = host_to_target_signal(VAR_0);", "if (VAR_3 < 1 || VAR_3 > TARGET_NSIG)\nreturn;", "trace_user_host_signal(env, VAR_0, VAR_3);", "rewind_if_in_safe_syscall(VAR_2);", "host_to_target_siginfo_noswap(&tinfo, VAR_1);", "VAR_4 = &ts->sigtab[VAR_3 - 1];", "VAR_4->VAR_1 = tinfo;", "VAR_4->pending = VAR_3;", "ts->signal_pending = 1;", "sigfillset(&uc->uc_sigmask);", "sigdelset(&uc->uc_sigmask, SIGSEGV);", "sigdelset(&uc->uc_sigmask, SIGBUS);", "cpu_exit(thread_cpu);", "}" ]
[ 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 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 29, 31 ], [ 33, 35 ], [ 37 ], [ 43 ], [ 45, 47 ], [ 49 ], [ 53 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 81 ], [ 83 ], [ 85 ], [ 91 ], [ 93 ] ]
9,882
static int nbd_co_send_request(BlockDriverState *bs, struct nbd_request *request, QEMUIOVector *qiov, int offset) { NbdClientSession *s = nbd_get_client_session(bs); AioContext *aio_context; int rc, ret; qemu_co_mutex_lock(&s->send_mutex); s->send_coroutine = qemu_coroutine_self(); aio_context = bdrv_get_aio_context(bs); aio_set_fd_handler(aio_context, s->sock, nbd_reply_ready, nbd_restart_write, bs); if (qiov) { if (!s->is_unix) { socket_set_cork(s->sock, 1); } rc = nbd_send_request(s->sock, request); if (rc >= 0) { ret = qemu_co_sendv(s->sock, qiov->iov, qiov->niov, offset, request->len); if (ret != request->len) { rc = -EIO; } } if (!s->is_unix) { socket_set_cork(s->sock, 0); } } else { rc = nbd_send_request(s->sock, request); } aio_set_fd_handler(aio_context, s->sock, nbd_reply_ready, NULL, bs); s->send_coroutine = NULL; qemu_co_mutex_unlock(&s->send_mutex); return rc; }
true
qemu
141cabe6f144a1acb128186caf686f8fbde0a7e4
static int nbd_co_send_request(BlockDriverState *bs, struct nbd_request *request, QEMUIOVector *qiov, int offset) { NbdClientSession *s = nbd_get_client_session(bs); AioContext *aio_context; int rc, ret; qemu_co_mutex_lock(&s->send_mutex); s->send_coroutine = qemu_coroutine_self(); aio_context = bdrv_get_aio_context(bs); aio_set_fd_handler(aio_context, s->sock, nbd_reply_ready, nbd_restart_write, bs); if (qiov) { if (!s->is_unix) { socket_set_cork(s->sock, 1); } rc = nbd_send_request(s->sock, request); if (rc >= 0) { ret = qemu_co_sendv(s->sock, qiov->iov, qiov->niov, offset, request->len); if (ret != request->len) { rc = -EIO; } } if (!s->is_unix) { socket_set_cork(s->sock, 0); } } else { rc = nbd_send_request(s->sock, request); } aio_set_fd_handler(aio_context, s->sock, nbd_reply_ready, NULL, bs); s->send_coroutine = NULL; qemu_co_mutex_unlock(&s->send_mutex); return rc; }
{ "code": [ " int rc, ret;" ], "line_no": [ 13 ] }
static int FUNC_0(BlockDriverState *VAR_0, struct nbd_request *VAR_1, QEMUIOVector *VAR_2, int VAR_3) { NbdClientSession *s = nbd_get_client_session(VAR_0); AioContext *aio_context; int VAR_4, VAR_5; qemu_co_mutex_lock(&s->send_mutex); s->send_coroutine = qemu_coroutine_self(); aio_context = bdrv_get_aio_context(VAR_0); aio_set_fd_handler(aio_context, s->sock, nbd_reply_ready, nbd_restart_write, VAR_0); if (VAR_2) { if (!s->is_unix) { socket_set_cork(s->sock, 1); } VAR_4 = nbd_send_request(s->sock, VAR_1); if (VAR_4 >= 0) { VAR_5 = qemu_co_sendv(s->sock, VAR_2->iov, VAR_2->niov, VAR_3, VAR_1->len); if (VAR_5 != VAR_1->len) { VAR_4 = -EIO; } } if (!s->is_unix) { socket_set_cork(s->sock, 0); } } else { VAR_4 = nbd_send_request(s->sock, VAR_1); } aio_set_fd_handler(aio_context, s->sock, nbd_reply_ready, NULL, VAR_0); s->send_coroutine = NULL; qemu_co_mutex_unlock(&s->send_mutex); return VAR_4; }
[ "static int FUNC_0(BlockDriverState *VAR_0,\nstruct nbd_request *VAR_1,\nQEMUIOVector *VAR_2, int VAR_3)\n{", "NbdClientSession *s = nbd_get_client_session(VAR_0);", "AioContext *aio_context;", "int VAR_4, VAR_5;", "qemu_co_mutex_lock(&s->send_mutex);", "s->send_coroutine = qemu_coroutine_self();", "aio_context = bdrv_get_aio_context(VAR_0);", "aio_set_fd_handler(aio_context, s->sock,\nnbd_reply_ready, nbd_restart_write, VAR_0);", "if (VAR_2) {", "if (!s->is_unix) {", "socket_set_cork(s->sock, 1);", "}", "VAR_4 = nbd_send_request(s->sock, VAR_1);", "if (VAR_4 >= 0) {", "VAR_5 = qemu_co_sendv(s->sock, VAR_2->iov, VAR_2->niov,\nVAR_3, VAR_1->len);", "if (VAR_5 != VAR_1->len) {", "VAR_4 = -EIO;", "}", "}", "if (!s->is_unix) {", "socket_set_cork(s->sock, 0);", "}", "} else {", "VAR_4 = nbd_send_request(s->sock, VAR_1);", "}", "aio_set_fd_handler(aio_context, s->sock, nbd_reply_ready, NULL, VAR_0);", "s->send_coroutine = NULL;", "qemu_co_mutex_unlock(&s->send_mutex);", "return VAR_4;", "}" ]
[ 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13 ], [ 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 ] ]
9,883
qio_channel_socket_accept(QIOChannelSocket *ioc, Error **errp) { QIOChannelSocket *cioc; cioc = qio_channel_socket_new(); cioc->remoteAddrLen = sizeof(ioc->remoteAddr); cioc->localAddrLen = sizeof(ioc->localAddr); retry: trace_qio_channel_socket_accept(ioc); cioc->fd = qemu_accept(ioc->fd, (struct sockaddr *)&cioc->remoteAddr, &cioc->remoteAddrLen); if (cioc->fd < 0) { trace_qio_channel_socket_accept_fail(ioc); if (errno == EINTR) { goto retry; } goto error; } if (getsockname(cioc->fd, (struct sockaddr *)&cioc->localAddr, &cioc->localAddrLen) < 0) { error_setg_errno(errp, errno, "Unable to query local socket address"); goto error; } #ifndef WIN32 if (cioc->localAddr.ss_family == AF_UNIX) { QIOChannel *ioc_local = QIO_CHANNEL(cioc); qio_channel_set_feature(ioc_local, QIO_CHANNEL_FEATURE_FD_PASS); } #endif /* WIN32 */ trace_qio_channel_socket_accept_complete(ioc, cioc, cioc->fd); return cioc; error: object_unref(OBJECT(cioc)); return NULL; }
true
qemu
8bd9c4e6c565c566a6cba3470cb2d4ea63994143
qio_channel_socket_accept(QIOChannelSocket *ioc, Error **errp) { QIOChannelSocket *cioc; cioc = qio_channel_socket_new(); cioc->remoteAddrLen = sizeof(ioc->remoteAddr); cioc->localAddrLen = sizeof(ioc->localAddr); retry: trace_qio_channel_socket_accept(ioc); cioc->fd = qemu_accept(ioc->fd, (struct sockaddr *)&cioc->remoteAddr, &cioc->remoteAddrLen); if (cioc->fd < 0) { trace_qio_channel_socket_accept_fail(ioc); if (errno == EINTR) { goto retry; } goto error; } if (getsockname(cioc->fd, (struct sockaddr *)&cioc->localAddr, &cioc->localAddrLen) < 0) { error_setg_errno(errp, errno, "Unable to query local socket address"); goto error; } #ifndef WIN32 if (cioc->localAddr.ss_family == AF_UNIX) { QIOChannel *ioc_local = QIO_CHANNEL(cioc); qio_channel_set_feature(ioc_local, QIO_CHANNEL_FEATURE_FD_PASS); } #endif trace_qio_channel_socket_accept_complete(ioc, cioc, cioc->fd); return cioc; error: object_unref(OBJECT(cioc)); return NULL; }
{ "code": [ " trace_qio_channel_socket_accept_fail(ioc);" ], "line_no": [ 29 ] }
FUNC_0(QIOChannelSocket *VAR_0, Error **VAR_1) { QIOChannelSocket *cioc; cioc = qio_channel_socket_new(); cioc->remoteAddrLen = sizeof(VAR_0->remoteAddr); cioc->localAddrLen = sizeof(VAR_0->localAddr); retry: trace_qio_channel_socket_accept(VAR_0); cioc->fd = qemu_accept(VAR_0->fd, (struct sockaddr *)&cioc->remoteAddr, &cioc->remoteAddrLen); if (cioc->fd < 0) { trace_qio_channel_socket_accept_fail(VAR_0); if (errno == EINTR) { goto retry; } goto error; } if (getsockname(cioc->fd, (struct sockaddr *)&cioc->localAddr, &cioc->localAddrLen) < 0) { error_setg_errno(VAR_1, errno, "Unable to query local socket address"); goto error; } #ifndef WIN32 if (cioc->localAddr.ss_family == AF_UNIX) { QIOChannel *ioc_local = QIO_CHANNEL(cioc); qio_channel_set_feature(ioc_local, QIO_CHANNEL_FEATURE_FD_PASS); } #endif trace_qio_channel_socket_accept_complete(VAR_0, cioc, cioc->fd); return cioc; error: object_unref(OBJECT(cioc)); return NULL; }
[ "FUNC_0(QIOChannelSocket *VAR_0,\nError **VAR_1)\n{", "QIOChannelSocket *cioc;", "cioc = qio_channel_socket_new();", "cioc->remoteAddrLen = sizeof(VAR_0->remoteAddr);", "cioc->localAddrLen = sizeof(VAR_0->localAddr);", "retry:\ntrace_qio_channel_socket_accept(VAR_0);", "cioc->fd = qemu_accept(VAR_0->fd, (struct sockaddr *)&cioc->remoteAddr,\n&cioc->remoteAddrLen);", "if (cioc->fd < 0) {", "trace_qio_channel_socket_accept_fail(VAR_0);", "if (errno == EINTR) {", "goto retry;", "}", "goto error;", "}", "if (getsockname(cioc->fd, (struct sockaddr *)&cioc->localAddr,\n&cioc->localAddrLen) < 0) {", "error_setg_errno(VAR_1, errno,\n\"Unable to query local socket address\");", "goto error;", "}", "#ifndef WIN32\nif (cioc->localAddr.ss_family == AF_UNIX) {", "QIOChannel *ioc_local = QIO_CHANNEL(cioc);", "qio_channel_set_feature(ioc_local, QIO_CHANNEL_FEATURE_FD_PASS);", "}", "#endif\ntrace_qio_channel_socket_accept_complete(VAR_0, cioc, cioc->fd);", "return cioc;", "error:\nobject_unref(OBJECT(cioc));", "return NULL;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 19, 21 ], [ 23, 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 43, 45 ], [ 47, 49 ], [ 51 ], [ 53 ], [ 57, 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67, 71 ], [ 73 ], [ 77, 79 ], [ 81 ], [ 83 ] ]
9,884
static void io_write(IPackDevice *ip, uint8_t addr, uint16_t val) { IPOctalState *dev = IPOCTAL(ip); unsigned reg = val & 0xFF; /* addr[7:6]: block (A-D) addr[7:5]: channel (a-h) addr[5:0]: register */ unsigned block = addr >> 5; unsigned channel = addr >> 4; /* Big endian, accessed using 8-bit bytes at odd locations */ unsigned offset = (addr & 0x1F) ^ 1; SCC2698Channel *ch = &dev->ch[channel]; SCC2698Block *blk = &dev->blk[block]; uint8_t old_isr = blk->isr; uint8_t old_imr = blk->imr; switch (offset) { case REG_MRa: case REG_MRb: ch->mr[ch->mr_idx] = reg; DPRINTF("Write MR%u%c 0x%x\n", ch->mr_idx + 1, channel + 'a', reg); ch->mr_idx = 1; break; /* Not implemented */ case REG_CSRa: case REG_CSRb: DPRINTF("Write CSR%c: 0x%x\n", channel + 'a', reg); break; case REG_CRa: case REG_CRb: write_cr(dev, channel, reg); break; case REG_THRa: case REG_THRb: if (ch->sr & SR_TXRDY) { DPRINTF("Write THR%c (0x%x)\n", channel + 'a', reg); if (ch->dev) { uint8_t thr = reg; qemu_chr_fe_write(ch->dev, &thr, 1); } } else { DPRINTF("Write THR%c (0x%x), Tx disabled\n", channel + 'a', reg); } break; /* Not implemented */ case REG_ACR: DPRINTF("Write ACR%c 0x%x\n", block + 'A', val); break; case REG_IMR: DPRINTF("Write IMR%c 0x%x\n", block + 'A', val); blk->imr = reg; break; /* Not implemented */ case REG_OPCR: DPRINTF("Write OPCR%c 0x%x\n", block + 'A', val); break; default: DPRINTF("Write unknown/unsupported register 0x%02x %u\n", offset, val); } if (old_isr != blk->isr || old_imr != blk->imr) { update_irq(dev, block); } }
true
qemu
6ab3fc32ea640026726bc5f9f4db622d0954fb8a
static void io_write(IPackDevice *ip, uint8_t addr, uint16_t val) { IPOctalState *dev = IPOCTAL(ip); unsigned reg = val & 0xFF; unsigned block = addr >> 5; unsigned channel = addr >> 4; unsigned offset = (addr & 0x1F) ^ 1; SCC2698Channel *ch = &dev->ch[channel]; SCC2698Block *blk = &dev->blk[block]; uint8_t old_isr = blk->isr; uint8_t old_imr = blk->imr; switch (offset) { case REG_MRa: case REG_MRb: ch->mr[ch->mr_idx] = reg; DPRINTF("Write MR%u%c 0x%x\n", ch->mr_idx + 1, channel + 'a', reg); ch->mr_idx = 1; break; case REG_CSRa: case REG_CSRb: DPRINTF("Write CSR%c: 0x%x\n", channel + 'a', reg); break; case REG_CRa: case REG_CRb: write_cr(dev, channel, reg); break; case REG_THRa: case REG_THRb: if (ch->sr & SR_TXRDY) { DPRINTF("Write THR%c (0x%x)\n", channel + 'a', reg); if (ch->dev) { uint8_t thr = reg; qemu_chr_fe_write(ch->dev, &thr, 1); } } else { DPRINTF("Write THR%c (0x%x), Tx disabled\n", channel + 'a', reg); } break; case REG_ACR: DPRINTF("Write ACR%c 0x%x\n", block + 'A', val); break; case REG_IMR: DPRINTF("Write IMR%c 0x%x\n", block + 'A', val); blk->imr = reg; break; case REG_OPCR: DPRINTF("Write OPCR%c 0x%x\n", block + 'A', val); break; default: DPRINTF("Write unknown/unsupported register 0x%02x %u\n", offset, val); } if (old_isr != blk->isr || old_imr != blk->imr) { update_irq(dev, block); } }
{ "code": [ " qemu_chr_fe_write(ch->dev, &thr, 1);" ], "line_no": [ 85 ] }
static void FUNC_0(IPackDevice *VAR_0, uint8_t VAR_1, uint16_t VAR_2) { IPOctalState *dev = IPOCTAL(VAR_0); unsigned VAR_3 = VAR_2 & 0xFF; unsigned VAR_4 = VAR_1 >> 5; unsigned VAR_5 = VAR_1 >> 4; unsigned VAR_6 = (VAR_1 & 0x1F) ^ 1; SCC2698Channel *ch = &dev->ch[VAR_5]; SCC2698Block *blk = &dev->blk[VAR_4]; uint8_t old_isr = blk->isr; uint8_t old_imr = blk->imr; switch (VAR_6) { case REG_MRa: case REG_MRb: ch->mr[ch->mr_idx] = VAR_3; DPRINTF("Write MR%u%c 0x%x\n", ch->mr_idx + 1, VAR_5 + 'a', VAR_3); ch->mr_idx = 1; break; case REG_CSRa: case REG_CSRb: DPRINTF("Write CSR%c: 0x%x\n", VAR_5 + 'a', VAR_3); break; case REG_CRa: case REG_CRb: write_cr(dev, VAR_5, VAR_3); break; case REG_THRa: case REG_THRb: if (ch->sr & SR_TXRDY) { DPRINTF("Write THR%c (0x%x)\n", VAR_5 + 'a', VAR_3); if (ch->dev) { uint8_t thr = VAR_3; qemu_chr_fe_write(ch->dev, &thr, 1); } } else { DPRINTF("Write THR%c (0x%x), Tx disabled\n", VAR_5 + 'a', VAR_3); } break; case REG_ACR: DPRINTF("Write ACR%c 0x%x\n", VAR_4 + 'A', VAR_2); break; case REG_IMR: DPRINTF("Write IMR%c 0x%x\n", VAR_4 + 'A', VAR_2); blk->imr = VAR_3; break; case REG_OPCR: DPRINTF("Write OPCR%c 0x%x\n", VAR_4 + 'A', VAR_2); break; default: DPRINTF("Write unknown/unsupported register 0x%02x %u\n", VAR_6, VAR_2); } if (old_isr != blk->isr || old_imr != blk->imr) { update_irq(dev, VAR_4); } }
[ "static void FUNC_0(IPackDevice *VAR_0, uint8_t VAR_1, uint16_t VAR_2)\n{", "IPOctalState *dev = IPOCTAL(VAR_0);", "unsigned VAR_3 = VAR_2 & 0xFF;", "unsigned VAR_4 = VAR_1 >> 5;", "unsigned VAR_5 = VAR_1 >> 4;", "unsigned VAR_6 = (VAR_1 & 0x1F) ^ 1;", "SCC2698Channel *ch = &dev->ch[VAR_5];", "SCC2698Block *blk = &dev->blk[VAR_4];", "uint8_t old_isr = blk->isr;", "uint8_t old_imr = blk->imr;", "switch (VAR_6) {", "case REG_MRa:\ncase REG_MRb:\nch->mr[ch->mr_idx] = VAR_3;", "DPRINTF(\"Write MR%u%c 0x%x\\n\", ch->mr_idx + 1, VAR_5 + 'a', VAR_3);", "ch->mr_idx = 1;", "break;", "case REG_CSRa:\ncase REG_CSRb:\nDPRINTF(\"Write CSR%c: 0x%x\\n\", VAR_5 + 'a', VAR_3);", "break;", "case REG_CRa:\ncase REG_CRb:\nwrite_cr(dev, VAR_5, VAR_3);", "break;", "case REG_THRa:\ncase REG_THRb:\nif (ch->sr & SR_TXRDY) {", "DPRINTF(\"Write THR%c (0x%x)\\n\", VAR_5 + 'a', VAR_3);", "if (ch->dev) {", "uint8_t thr = VAR_3;", "qemu_chr_fe_write(ch->dev, &thr, 1);", "}", "} else {", "DPRINTF(\"Write THR%c (0x%x), Tx disabled\\n\", VAR_5 + 'a', VAR_3);", "}", "break;", "case REG_ACR:\nDPRINTF(\"Write ACR%c 0x%x\\n\", VAR_4 + 'A', VAR_2);", "break;", "case REG_IMR:\nDPRINTF(\"Write IMR%c 0x%x\\n\", VAR_4 + 'A', VAR_2);", "blk->imr = VAR_3;", "break;", "case REG_OPCR:\nDPRINTF(\"Write OPCR%c 0x%x\\n\", VAR_4 + 'A', VAR_2);", "break;", "default:\nDPRINTF(\"Write unknown/unsupported register 0x%02x %u\\n\", VAR_6, VAR_2);", "}", "if (old_isr != blk->isr || old_imr != blk->imr) {", "update_irq(dev, 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, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 15 ], [ 17 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 33 ], [ 37, 39, 41 ], [ 43 ], [ 45 ], [ 47 ], [ 53, 55, 57 ], [ 59 ], [ 63, 65, 67 ], [ 69 ], [ 73, 75, 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 101, 103 ], [ 105 ], [ 109, 111 ], [ 113 ], [ 115 ], [ 121, 123 ], [ 125 ], [ 129, 131 ], [ 133 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ] ]
9,885
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags) { AVDictionary *m = *pm; AVDictionaryEntry *tag = av_dict_get(m, key, NULL, flags); char *oldval = NULL, *copy_key = NULL, *copy_value = NULL; if (flags & AV_DICT_DONT_STRDUP_KEY) copy_key = (void *)key; else copy_key = av_strdup(key); if (flags & AV_DICT_DONT_STRDUP_VAL) copy_value = (void *)value; else if (copy_key) copy_value = av_strdup(value); if (!m) m = *pm = av_mallocz(sizeof(*m)); if (!m || (key && !copy_key) || (value && !copy_value)) goto err_out; if (tag) { if (flags & AV_DICT_DONT_OVERWRITE) { av_free(copy_key); av_free(copy_value); return 0; } if (flags & AV_DICT_APPEND) oldval = tag->value; else av_free(tag->value); av_free(tag->key); *tag = m->elems[--m->count]; } else { AVDictionaryEntry *tmp = av_realloc(m->elems, (m->count + 1) * sizeof(*m->elems)); if (!tmp) goto err_out; m->elems = tmp; } if (copy_value) { m->elems[m->count].key = copy_key; m->elems[m->count].value = copy_value; if (oldval && flags & AV_DICT_APPEND) { size_t len = strlen(oldval) + strlen(copy_value) + 1; char *newval = av_mallocz(len); if (!newval) goto err_out; av_strlcat(newval, oldval, len); av_freep(&oldval); av_strlcat(newval, copy_value, len); m->elems[m->count].value = newval; av_freep(&copy_value); } m->count++; } else { av_freep(&copy_key); } if (!m->count) { av_freep(&m->elems); av_freep(pm); } return 0; err_out: if (m && !m->count) { av_freep(&m->elems); av_freep(pm); } av_free(copy_key); av_free(copy_value); return AVERROR(ENOMEM); }
false
FFmpeg
a740263d7e7be5bb909ae83a44b21cc8cf8c9274
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags) { AVDictionary *m = *pm; AVDictionaryEntry *tag = av_dict_get(m, key, NULL, flags); char *oldval = NULL, *copy_key = NULL, *copy_value = NULL; if (flags & AV_DICT_DONT_STRDUP_KEY) copy_key = (void *)key; else copy_key = av_strdup(key); if (flags & AV_DICT_DONT_STRDUP_VAL) copy_value = (void *)value; else if (copy_key) copy_value = av_strdup(value); if (!m) m = *pm = av_mallocz(sizeof(*m)); if (!m || (key && !copy_key) || (value && !copy_value)) goto err_out; if (tag) { if (flags & AV_DICT_DONT_OVERWRITE) { av_free(copy_key); av_free(copy_value); return 0; } if (flags & AV_DICT_APPEND) oldval = tag->value; else av_free(tag->value); av_free(tag->key); *tag = m->elems[--m->count]; } else { AVDictionaryEntry *tmp = av_realloc(m->elems, (m->count + 1) * sizeof(*m->elems)); if (!tmp) goto err_out; m->elems = tmp; } if (copy_value) { m->elems[m->count].key = copy_key; m->elems[m->count].value = copy_value; if (oldval && flags & AV_DICT_APPEND) { size_t len = strlen(oldval) + strlen(copy_value) + 1; char *newval = av_mallocz(len); if (!newval) goto err_out; av_strlcat(newval, oldval, len); av_freep(&oldval); av_strlcat(newval, copy_value, len); m->elems[m->count].value = newval; av_freep(&copy_value); } m->count++; } else { av_freep(&copy_key); } if (!m->count) { av_freep(&m->elems); av_freep(pm); } return 0; err_out: if (m && !m->count) { av_freep(&m->elems); av_freep(pm); } av_free(copy_key); av_free(copy_value); return AVERROR(ENOMEM); }
{ "code": [], "line_no": [] }
int FUNC_0(AVDictionary **VAR_0, const char *VAR_1, const char *VAR_2, int VAR_3) { AVDictionary *m = *VAR_0; AVDictionaryEntry *tag = av_dict_get(m, VAR_1, NULL, VAR_3); char *VAR_4 = NULL, *VAR_5 = NULL, *VAR_6 = NULL; if (VAR_3 & AV_DICT_DONT_STRDUP_KEY) VAR_5 = (void *)VAR_1; else VAR_5 = av_strdup(VAR_1); if (VAR_3 & AV_DICT_DONT_STRDUP_VAL) VAR_6 = (void *)VAR_2; else if (VAR_5) VAR_6 = av_strdup(VAR_2); if (!m) m = *VAR_0 = av_mallocz(sizeof(*m)); if (!m || (VAR_1 && !VAR_5) || (VAR_2 && !VAR_6)) goto err_out; if (tag) { if (VAR_3 & AV_DICT_DONT_OVERWRITE) { av_free(VAR_5); av_free(VAR_6); return 0; } if (VAR_3 & AV_DICT_APPEND) VAR_4 = tag->VAR_2; else av_free(tag->VAR_2); av_free(tag->VAR_1); *tag = m->elems[--m->count]; } else { AVDictionaryEntry *tmp = av_realloc(m->elems, (m->count + 1) * sizeof(*m->elems)); if (!tmp) goto err_out; m->elems = tmp; } if (VAR_6) { m->elems[m->count].VAR_1 = VAR_5; m->elems[m->count].VAR_2 = VAR_6; if (VAR_4 && VAR_3 & AV_DICT_APPEND) { size_t len = strlen(VAR_4) + strlen(VAR_6) + 1; char *VAR_7 = av_mallocz(len); if (!VAR_7) goto err_out; av_strlcat(VAR_7, VAR_4, len); av_freep(&VAR_4); av_strlcat(VAR_7, VAR_6, len); m->elems[m->count].VAR_2 = VAR_7; av_freep(&VAR_6); } m->count++; } else { av_freep(&VAR_5); } if (!m->count) { av_freep(&m->elems); av_freep(VAR_0); } return 0; err_out: if (m && !m->count) { av_freep(&m->elems); av_freep(VAR_0); } av_free(VAR_5); av_free(VAR_6); return AVERROR(ENOMEM); }
[ "int FUNC_0(AVDictionary **VAR_0, const char *VAR_1, const char *VAR_2,\nint VAR_3)\n{", "AVDictionary *m = *VAR_0;", "AVDictionaryEntry *tag = av_dict_get(m, VAR_1, NULL, VAR_3);", "char *VAR_4 = NULL, *VAR_5 = NULL, *VAR_6 = NULL;", "if (VAR_3 & AV_DICT_DONT_STRDUP_KEY)\nVAR_5 = (void *)VAR_1;", "else\nVAR_5 = av_strdup(VAR_1);", "if (VAR_3 & AV_DICT_DONT_STRDUP_VAL)\nVAR_6 = (void *)VAR_2;", "else if (VAR_5)\nVAR_6 = av_strdup(VAR_2);", "if (!m)\nm = *VAR_0 = av_mallocz(sizeof(*m));", "if (!m || (VAR_1 && !VAR_5) || (VAR_2 && !VAR_6))\ngoto err_out;", "if (tag) {", "if (VAR_3 & AV_DICT_DONT_OVERWRITE) {", "av_free(VAR_5);", "av_free(VAR_6);", "return 0;", "}", "if (VAR_3 & AV_DICT_APPEND)\nVAR_4 = tag->VAR_2;", "else\nav_free(tag->VAR_2);", "av_free(tag->VAR_1);", "*tag = m->elems[--m->count];", "} else {", "AVDictionaryEntry *tmp = av_realloc(m->elems,\n(m->count + 1) * sizeof(*m->elems));", "if (!tmp)\ngoto err_out;", "m->elems = tmp;", "}", "if (VAR_6) {", "m->elems[m->count].VAR_1 = VAR_5;", "m->elems[m->count].VAR_2 = VAR_6;", "if (VAR_4 && VAR_3 & AV_DICT_APPEND) {", "size_t len = strlen(VAR_4) + strlen(VAR_6) + 1;", "char *VAR_7 = av_mallocz(len);", "if (!VAR_7)\ngoto err_out;", "av_strlcat(VAR_7, VAR_4, len);", "av_freep(&VAR_4);", "av_strlcat(VAR_7, VAR_6, len);", "m->elems[m->count].VAR_2 = VAR_7;", "av_freep(&VAR_6);", "}", "m->count++;", "} else {", "av_freep(&VAR_5);", "}", "if (!m->count) {", "av_freep(&m->elems);", "av_freep(VAR_0);", "}", "return 0;", "err_out:\nif (m && !m->count) {", "av_freep(&m->elems);", "av_freep(VAR_0);", "}", "av_free(VAR_5);", "av_free(VAR_6);", "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, 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 ], [ 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 ], [ 125 ], [ 129, 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ] ]
9,886
static av_cold int dfa_decode_init(AVCodecContext *avctx) { DfaContext *s = avctx->priv_data; avctx->pix_fmt = PIX_FMT_PAL8; s->frame_buf = av_mallocz(avctx->width * avctx->height + AV_LZO_OUTPUT_PADDING); if (!s->frame_buf) return AVERROR(ENOMEM); return 0; }
true
FFmpeg
ee715f49a06bf3898246d01b056284a9bb1bcbb9
static av_cold int dfa_decode_init(AVCodecContext *avctx) { DfaContext *s = avctx->priv_data; avctx->pix_fmt = PIX_FMT_PAL8; s->frame_buf = av_mallocz(avctx->width * avctx->height + AV_LZO_OUTPUT_PADDING); if (!s->frame_buf) return AVERROR(ENOMEM); return 0; }
{ "code": [], "line_no": [] }
static av_cold int FUNC_0(AVCodecContext *avctx) { DfaContext *s = avctx->priv_data; avctx->pix_fmt = PIX_FMT_PAL8; s->frame_buf = av_mallocz(avctx->width * avctx->height + AV_LZO_OUTPUT_PADDING); if (!s->frame_buf) return AVERROR(ENOMEM); return 0; }
[ "static av_cold int FUNC_0(AVCodecContext *avctx)\n{", "DfaContext *s = avctx->priv_data;", "avctx->pix_fmt = PIX_FMT_PAL8;", "s->frame_buf = av_mallocz(avctx->width * avctx->height + AV_LZO_OUTPUT_PADDING);", "if (!s->frame_buf)\nreturn AVERROR(ENOMEM);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 2 ], [ 3 ], [ 4 ], [ 5 ], [ 6, 7 ], [ 8 ], [ 9 ] ]
9,887
static int vnc_tls_initialize(void) { static int tlsinitialized = 0; if (tlsinitialized) return 1; if (gnutls_global_init () < 0) return 0; /* XXX ought to re-generate diffie-hellman params periodically */ if (gnutls_dh_params_init (&dh_params) < 0) return 0; if (gnutls_dh_params_generate2 (dh_params, DH_BITS) < 0) return 0; #if defined(_VNC_DEBUG) && _VNC_DEBUG >= 2 gnutls_global_set_log_level(10); gnutls_global_set_log_function(vnc_debug_gnutls_log); #endif tlsinitialized = 1; return 1; }
true
qemu
3e305e4a4752f70c0b5c3cf5b43ec957881714f7
static int vnc_tls_initialize(void) { static int tlsinitialized = 0; if (tlsinitialized) return 1; if (gnutls_global_init () < 0) return 0; if (gnutls_dh_params_init (&dh_params) < 0) return 0; if (gnutls_dh_params_generate2 (dh_params, DH_BITS) < 0) return 0; #if defined(_VNC_DEBUG) && _VNC_DEBUG >= 2 gnutls_global_set_log_level(10); gnutls_global_set_log_function(vnc_debug_gnutls_log); #endif tlsinitialized = 1; return 1; }
{ "code": [ "#if defined(_VNC_DEBUG) && _VNC_DEBUG >= 2", "static int vnc_tls_initialize(void)", " static int tlsinitialized = 0;", " if (tlsinitialized)", " return 1;", " if (gnutls_global_init () < 0)", " return 0;", " if (gnutls_dh_params_init (&dh_params) < 0)", " return 0;", " if (gnutls_dh_params_generate2 (dh_params, DH_BITS) < 0)", " return 0;", "#if defined(_VNC_DEBUG) && _VNC_DEBUG >= 2", " gnutls_global_set_log_level(10);", " gnutls_global_set_log_function(vnc_debug_gnutls_log);", "#endif", " tlsinitialized = 1;", " return 1;", "#endif", "#endif", "#endif", "#endif", "#endif", "#endif", "#endif", "#endif", "#endif", "#endif", "#endif", "#endif", "#endif" ], "line_no": [ 33, 1, 5, 9, 11, 15, 17, 23, 17, 27, 17, 33, 35, 37, 39, 43, 47, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39 ] }
static int FUNC_0(void) { static int VAR_0 = 0; if (VAR_0) return 1; if (gnutls_global_init () < 0) return 0; if (gnutls_dh_params_init (&dh_params) < 0) return 0; if (gnutls_dh_params_generate2 (dh_params, DH_BITS) < 0) return 0; #if defined(_VNC_DEBUG) && _VNC_DEBUG >= 2 gnutls_global_set_log_level(10); gnutls_global_set_log_function(vnc_debug_gnutls_log); #endif VAR_0 = 1; return 1; }
[ "static int FUNC_0(void)\n{", "static int VAR_0 = 0;", "if (VAR_0)\nreturn 1;", "if (gnutls_global_init () < 0)\nreturn 0;", "if (gnutls_dh_params_init (&dh_params) < 0)\nreturn 0;", "if (gnutls_dh_params_generate2 (dh_params, DH_BITS) < 0)\nreturn 0;", "#if defined(_VNC_DEBUG) && _VNC_DEBUG >= 2\ngnutls_global_set_log_level(10);", "gnutls_global_set_log_function(vnc_debug_gnutls_log);", "#endif\nVAR_0 = 1;", "return 1;", "}" ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9, 11 ], [ 15, 17 ], [ 23, 25 ], [ 27, 29 ], [ 33, 35 ], [ 37 ], [ 39, 43 ], [ 47 ], [ 49 ] ]
9,888
char *socket_address_to_string(struct SocketAddress *addr, Error **errp) { char *buf; InetSocketAddress *inet; char host_port[INET6_ADDRSTRLEN + 5 + 4]; switch (addr->type) { case SOCKET_ADDRESS_KIND_INET: inet = addr->u.inet.data; if (strchr(inet->host, ':') == NULL) { snprintf(host_port, sizeof(host_port), "%s:%s", inet->host, inet->port); buf = g_strdup(host_port); } else { snprintf(host_port, sizeof(host_port), "[%s]:%s", inet->host, inet->port); buf = g_strdup(host_port); } break; case SOCKET_ADDRESS_KIND_UNIX: buf = g_strdup(addr->u.q_unix.data->path); break; case SOCKET_ADDRESS_KIND_FD: buf = g_strdup(addr->u.fd.data->str); break; case SOCKET_ADDRESS_KIND_VSOCK: buf = g_strdup_printf("%s:%s", addr->u.vsock.data->cid, addr->u.vsock.data->port); break; default: error_setg(errp, "socket family %d unsupported", addr->type); return NULL; } return buf; }
true
qemu
44fdc764550e048a2810955da7cabbfaf636231a
char *socket_address_to_string(struct SocketAddress *addr, Error **errp) { char *buf; InetSocketAddress *inet; char host_port[INET6_ADDRSTRLEN + 5 + 4]; switch (addr->type) { case SOCKET_ADDRESS_KIND_INET: inet = addr->u.inet.data; if (strchr(inet->host, ':') == NULL) { snprintf(host_port, sizeof(host_port), "%s:%s", inet->host, inet->port); buf = g_strdup(host_port); } else { snprintf(host_port, sizeof(host_port), "[%s]:%s", inet->host, inet->port); buf = g_strdup(host_port); } break; case SOCKET_ADDRESS_KIND_UNIX: buf = g_strdup(addr->u.q_unix.data->path); break; case SOCKET_ADDRESS_KIND_FD: buf = g_strdup(addr->u.fd.data->str); break; case SOCKET_ADDRESS_KIND_VSOCK: buf = g_strdup_printf("%s:%s", addr->u.vsock.data->cid, addr->u.vsock.data->port); break; default: error_setg(errp, "socket family %d unsupported", addr->type); return NULL; } return buf; }
{ "code": [ " char host_port[INET6_ADDRSTRLEN + 5 + 4];", " snprintf(host_port, sizeof(host_port), \"%s:%s\", inet->host,", " inet->port);", " buf = g_strdup(host_port);", " snprintf(host_port, sizeof(host_port), \"[%s]:%s\", inet->host,", " inet->port);", " buf = g_strdup(host_port);" ], "line_no": [ 9, 21, 23, 25, 29, 23, 25 ] }
char *FUNC_0(struct SocketAddress *VAR_0, Error **VAR_1) { char *VAR_2; InetSocketAddress *inet; char VAR_3[INET6_ADDRSTRLEN + 5 + 4]; switch (VAR_0->type) { case SOCKET_ADDRESS_KIND_INET: inet = VAR_0->u.inet.data; if (strchr(inet->host, ':') == NULL) { snprintf(VAR_3, sizeof(VAR_3), "%s:%s", inet->host, inet->port); VAR_2 = g_strdup(VAR_3); } else { snprintf(VAR_3, sizeof(VAR_3), "[%s]:%s", inet->host, inet->port); VAR_2 = g_strdup(VAR_3); } break; case SOCKET_ADDRESS_KIND_UNIX: VAR_2 = g_strdup(VAR_0->u.q_unix.data->path); break; case SOCKET_ADDRESS_KIND_FD: VAR_2 = g_strdup(VAR_0->u.fd.data->str); break; case SOCKET_ADDRESS_KIND_VSOCK: VAR_2 = g_strdup_printf("%s:%s", VAR_0->u.vsock.data->cid, VAR_0->u.vsock.data->port); break; default: error_setg(VAR_1, "socket family %d unsupported", VAR_0->type); return NULL; } return VAR_2; }
[ "char *FUNC_0(struct SocketAddress *VAR_0, Error **VAR_1)\n{", "char *VAR_2;", "InetSocketAddress *inet;", "char VAR_3[INET6_ADDRSTRLEN + 5 + 4];", "switch (VAR_0->type) {", "case SOCKET_ADDRESS_KIND_INET:\ninet = VAR_0->u.inet.data;", "if (strchr(inet->host, ':') == NULL) {", "snprintf(VAR_3, sizeof(VAR_3), \"%s:%s\", inet->host,\ninet->port);", "VAR_2 = g_strdup(VAR_3);", "} else {", "snprintf(VAR_3, sizeof(VAR_3), \"[%s]:%s\", inet->host,\ninet->port);", "VAR_2 = g_strdup(VAR_3);", "}", "break;", "case SOCKET_ADDRESS_KIND_UNIX:\nVAR_2 = g_strdup(VAR_0->u.q_unix.data->path);", "break;", "case SOCKET_ADDRESS_KIND_FD:\nVAR_2 = g_strdup(VAR_0->u.fd.data->str);", "break;", "case SOCKET_ADDRESS_KIND_VSOCK:\nVAR_2 = g_strdup_printf(\"%s:%s\",\nVAR_0->u.vsock.data->cid,\nVAR_0->u.vsock.data->port);", "break;", "default:\nerror_setg(VAR_1, \"socket family %d unsupported\",\nVAR_0->type);", "return NULL;", "}", "return VAR_2;", "}" ]
[ 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 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 ], [ 41, 43 ], [ 45 ], [ 49, 51 ], [ 53 ], [ 57, 59, 61, 63 ], [ 65 ], [ 69, 71, 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ] ]
9,891
aio_write_done(void *opaque, int ret) { struct aio_ctx *ctx = opaque; struct timeval t2; gettimeofday(&t2, NULL); if (ret < 0) { printf("aio_write failed: %s\n", strerror(-ret)); return; } if (ctx->qflag) { return; } /* Finally, report back -- -C gives a parsable format */ t2 = tsub(t2, ctx->t1); print_report("wrote", &t2, ctx->offset, ctx->qiov.size, ctx->qiov.size, 1, ctx->Cflag); qemu_io_free(ctx->buf); free(ctx); }
true
qemu
7d8abfcb50a33aed369bbd267852cf04009c49e9
aio_write_done(void *opaque, int ret) { struct aio_ctx *ctx = opaque; struct timeval t2; gettimeofday(&t2, NULL); if (ret < 0) { printf("aio_write failed: %s\n", strerror(-ret)); return; } if (ctx->qflag) { return; } t2 = tsub(t2, ctx->t1); print_report("wrote", &t2, ctx->offset, ctx->qiov.size, ctx->qiov.size, 1, ctx->Cflag); qemu_io_free(ctx->buf); free(ctx); }
{ "code": [], "line_no": [] }
FUNC_0(void *VAR_0, int VAR_1) { struct aio_ctx *VAR_2 = VAR_0; struct timeval VAR_3; gettimeofday(&VAR_3, NULL); if (VAR_1 < 0) { printf("aio_write failed: %s\n", strerror(-VAR_1)); return; } if (VAR_2->qflag) { return; } VAR_3 = tsub(VAR_3, VAR_2->t1); print_report("wrote", &VAR_3, VAR_2->offset, VAR_2->qiov.size, VAR_2->qiov.size, 1, VAR_2->Cflag); qemu_io_free(VAR_2->buf); free(VAR_2); }
[ "FUNC_0(void *VAR_0, int VAR_1)\n{", "struct aio_ctx *VAR_2 = VAR_0;", "struct timeval VAR_3;", "gettimeofday(&VAR_3, NULL);", "if (VAR_1 < 0) {", "printf(\"aio_write failed: %s\\n\", strerror(-VAR_1));", "return;", "}", "if (VAR_2->qflag) {", "return;", "}", "VAR_3 = tsub(VAR_3, VAR_2->t1);", "print_report(\"wrote\", &VAR_3, VAR_2->offset, VAR_2->qiov.size,\nVAR_2->qiov.size, 1, VAR_2->Cflag);", "qemu_io_free(VAR_2->buf);", "free(VAR_2);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 27 ], [ 29 ], [ 31 ], [ 37 ], [ 39, 41 ], [ 45 ], [ 47 ], [ 49 ] ]
9,892
static void usb_msd_realize_storage(USBDevice *dev, Error **errp) { MSDState *s = DO_UPCAST(MSDState, dev, dev); BlockDriverState *bs = s->conf.bs; SCSIDevice *scsi_dev; Error *err = NULL; if (!bs) { error_setg(errp, "drive property not set"); return; } blkconf_serial(&s->conf, &dev->serial); /* * Hack alert: this pretends to be a block device, but it's really * a SCSI bus that can serve only a single device, which it * creates automatically. But first it needs to detach from its * blockdev, or else scsi_bus_legacy_add_drive() dies when it * attaches again. * * The hack is probably a bad idea. */ bdrv_detach_dev(bs, &s->dev.qdev); s->conf.bs = NULL; usb_desc_create_serial(dev); usb_desc_init(dev); scsi_bus_new(&s->bus, sizeof(s->bus), DEVICE(dev), &usb_msd_scsi_info_storage, NULL); scsi_dev = scsi_bus_legacy_add_drive(&s->bus, bs, 0, !!s->removable, s->conf.bootindex, dev->serial, &err); if (!scsi_dev) { error_propagate(errp, err); return; } s->bus.qbus.allow_hotplug = 0; usb_msd_handle_reset(dev); if (bdrv_key_required(bs)) { if (cur_mon) { monitor_read_bdrv_key_start(cur_mon, bs, usb_msd_password_cb, s); s->dev.auto_attach = 0; } else { autostart = 0; } } }
true
qemu
77de4a09c6d3d1e4fabcc0eb6cfdb9ea5a1616d5
static void usb_msd_realize_storage(USBDevice *dev, Error **errp) { MSDState *s = DO_UPCAST(MSDState, dev, dev); BlockDriverState *bs = s->conf.bs; SCSIDevice *scsi_dev; Error *err = NULL; if (!bs) { error_setg(errp, "drive property not set"); return; } blkconf_serial(&s->conf, &dev->serial); bdrv_detach_dev(bs, &s->dev.qdev); s->conf.bs = NULL; usb_desc_create_serial(dev); usb_desc_init(dev); scsi_bus_new(&s->bus, sizeof(s->bus), DEVICE(dev), &usb_msd_scsi_info_storage, NULL); scsi_dev = scsi_bus_legacy_add_drive(&s->bus, bs, 0, !!s->removable, s->conf.bootindex, dev->serial, &err); if (!scsi_dev) { error_propagate(errp, err); return; } s->bus.qbus.allow_hotplug = 0; usb_msd_handle_reset(dev); if (bdrv_key_required(bs)) { if (cur_mon) { monitor_read_bdrv_key_start(cur_mon, bs, usb_msd_password_cb, s); s->dev.auto_attach = 0; } else { autostart = 0; } } }
{ "code": [ " s->bus.qbus.allow_hotplug = 0;" ], "line_no": [ 75 ] }
static void FUNC_0(USBDevice *VAR_0, Error **VAR_1) { MSDState *s = DO_UPCAST(MSDState, VAR_0, VAR_0); BlockDriverState *bs = s->conf.bs; SCSIDevice *scsi_dev; Error *err = NULL; if (!bs) { error_setg(VAR_1, "drive property not set"); return; } blkconf_serial(&s->conf, &VAR_0->serial); bdrv_detach_dev(bs, &s->VAR_0.qdev); s->conf.bs = NULL; usb_desc_create_serial(VAR_0); usb_desc_init(VAR_0); scsi_bus_new(&s->bus, sizeof(s->bus), DEVICE(VAR_0), &usb_msd_scsi_info_storage, NULL); scsi_dev = scsi_bus_legacy_add_drive(&s->bus, bs, 0, !!s->removable, s->conf.bootindex, VAR_0->serial, &err); if (!scsi_dev) { error_propagate(VAR_1, err); return; } s->bus.qbus.allow_hotplug = 0; usb_msd_handle_reset(VAR_0); if (bdrv_key_required(bs)) { if (cur_mon) { monitor_read_bdrv_key_start(cur_mon, bs, usb_msd_password_cb, s); s->VAR_0.auto_attach = 0; } else { autostart = 0; } } }
[ "static void FUNC_0(USBDevice *VAR_0, Error **VAR_1)\n{", "MSDState *s = DO_UPCAST(MSDState, VAR_0, VAR_0);", "BlockDriverState *bs = s->conf.bs;", "SCSIDevice *scsi_dev;", "Error *err = NULL;", "if (!bs) {", "error_setg(VAR_1, \"drive property not set\");", "return;", "}", "blkconf_serial(&s->conf, &VAR_0->serial);", "bdrv_detach_dev(bs, &s->VAR_0.qdev);", "s->conf.bs = NULL;", "usb_desc_create_serial(VAR_0);", "usb_desc_init(VAR_0);", "scsi_bus_new(&s->bus, sizeof(s->bus), DEVICE(VAR_0),\n&usb_msd_scsi_info_storage, NULL);", "scsi_dev = scsi_bus_legacy_add_drive(&s->bus, bs, 0, !!s->removable,\ns->conf.bootindex, VAR_0->serial,\n&err);", "if (!scsi_dev) {", "error_propagate(VAR_1, err);", "return;", "}", "s->bus.qbus.allow_hotplug = 0;", "usb_msd_handle_reset(VAR_0);", "if (bdrv_key_required(bs)) {", "if (cur_mon) {", "monitor_read_bdrv_key_start(cur_mon, bs, usb_msd_password_cb, s);", "s->VAR_0.auto_attach = 0;", "} else {", "autostart = 0;", "}", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 25 ], [ 47 ], [ 49 ], [ 53 ], [ 55 ], [ 57, 59 ], [ 61, 63, 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ] ]
9,895
static int local_chown(FsContext *fs_ctx, V9fsPath *fs_path, FsCred *credp) { char *buffer; int ret = -1; char *path = fs_path->data; if ((credp->fc_uid == -1 && credp->fc_gid == -1) || (fs_ctx->export_flags & V9FS_SM_PASSTHROUGH) || (fs_ctx->export_flags & V9FS_SM_NONE)) { buffer = rpath(fs_ctx, path); ret = lchown(buffer, credp->fc_uid, credp->fc_gid); g_free(buffer); } else if (fs_ctx->export_flags & V9FS_SM_MAPPED) { buffer = rpath(fs_ctx, path); ret = local_set_xattr(buffer, credp); g_free(buffer); } else if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) { return local_set_mapped_file_attr(fs_ctx, path, credp); } return ret; }
true
qemu
d369f20763a857eac544a5289a046d0285a91df8
static int local_chown(FsContext *fs_ctx, V9fsPath *fs_path, FsCred *credp) { char *buffer; int ret = -1; char *path = fs_path->data; if ((credp->fc_uid == -1 && credp->fc_gid == -1) || (fs_ctx->export_flags & V9FS_SM_PASSTHROUGH) || (fs_ctx->export_flags & V9FS_SM_NONE)) { buffer = rpath(fs_ctx, path); ret = lchown(buffer, credp->fc_uid, credp->fc_gid); g_free(buffer); } else if (fs_ctx->export_flags & V9FS_SM_MAPPED) { buffer = rpath(fs_ctx, path); ret = local_set_xattr(buffer, credp); g_free(buffer); } else if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) { return local_set_mapped_file_attr(fs_ctx, path, credp); } return ret; }
{ "code": [ " char *buffer;", " char *path = fs_path->data;", " buffer = rpath(fs_ctx, path);", " ret = lchown(buffer, credp->fc_uid, credp->fc_gid);", " g_free(buffer);", " buffer = rpath(fs_ctx, path);", " ret = local_set_xattr(buffer, credp);", " g_free(buffer);", " return local_set_mapped_file_attr(fs_ctx, path, credp);" ], "line_no": [ 5, 9, 19, 21, 23, 19, 29, 23, 35 ] }
static int FUNC_0(FsContext *VAR_0, V9fsPath *VAR_1, FsCred *VAR_2) { char *VAR_3; int VAR_4 = -1; char *VAR_5 = VAR_1->data; if ((VAR_2->fc_uid == -1 && VAR_2->fc_gid == -1) || (VAR_0->export_flags & V9FS_SM_PASSTHROUGH) || (VAR_0->export_flags & V9FS_SM_NONE)) { VAR_3 = rpath(VAR_0, VAR_5); VAR_4 = lchown(VAR_3, VAR_2->fc_uid, VAR_2->fc_gid); g_free(VAR_3); } else if (VAR_0->export_flags & V9FS_SM_MAPPED) { VAR_3 = rpath(VAR_0, VAR_5); VAR_4 = local_set_xattr(VAR_3, VAR_2); g_free(VAR_3); } else if (VAR_0->export_flags & V9FS_SM_MAPPED_FILE) { return local_set_mapped_file_attr(VAR_0, VAR_5, VAR_2); } return VAR_4; }
[ "static int FUNC_0(FsContext *VAR_0, V9fsPath *VAR_1, FsCred *VAR_2)\n{", "char *VAR_3;", "int VAR_4 = -1;", "char *VAR_5 = VAR_1->data;", "if ((VAR_2->fc_uid == -1 && VAR_2->fc_gid == -1) ||\n(VAR_0->export_flags & V9FS_SM_PASSTHROUGH) ||\n(VAR_0->export_flags & V9FS_SM_NONE)) {", "VAR_3 = rpath(VAR_0, VAR_5);", "VAR_4 = lchown(VAR_3, VAR_2->fc_uid, VAR_2->fc_gid);", "g_free(VAR_3);", "} else if (VAR_0->export_flags & V9FS_SM_MAPPED) {", "VAR_3 = rpath(VAR_0, VAR_5);", "VAR_4 = local_set_xattr(VAR_3, VAR_2);", "g_free(VAR_3);", "} else if (VAR_0->export_flags & V9FS_SM_MAPPED_FILE) {", "return local_set_mapped_file_attr(VAR_0, VAR_5, VAR_2);", "}", "return VAR_4;", "}" ]
[ 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13, 15, 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ] ]
9,897
static void gen_mtsrin_64b(DisasContext *ctx) { #if defined(CONFIG_USER_ONLY) gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG); #else TCGv t0; if (unlikely(ctx->pr)) { gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG); return; } t0 = tcg_temp_new(); tcg_gen_shri_tl(t0, cpu_gpr[rB(ctx->opcode)], 28); tcg_gen_andi_tl(t0, t0, 0xF); gen_helper_store_sr(cpu_env, t0, cpu_gpr[rS(ctx->opcode)]); tcg_temp_free(t0); #endif }
true
qemu
9b2fadda3e0196ffd485adde4fe9cdd6fae35300
static void gen_mtsrin_64b(DisasContext *ctx) { #if defined(CONFIG_USER_ONLY) gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG); #else TCGv t0; if (unlikely(ctx->pr)) { gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG); return; } t0 = tcg_temp_new(); tcg_gen_shri_tl(t0, cpu_gpr[rB(ctx->opcode)], 28); tcg_gen_andi_tl(t0, t0, 0xF); gen_helper_store_sr(cpu_env, t0, cpu_gpr[rS(ctx->opcode)]); tcg_temp_free(t0); #endif }
{ "code": [ " if (unlikely(ctx->pr)) {", " if (unlikely(ctx->pr)) {", "#if defined(CONFIG_USER_ONLY)", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);", "#else", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);", "#endif", "#if defined(CONFIG_USER_ONLY)", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);", "#else", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);", "#endif", "#endif", "#if defined(CONFIG_USER_ONLY)", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);", "#else", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);", " if (unlikely(ctx->pr)) {", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);", "#endif", "#endif", " if (unlikely(ctx->pr)) {", "#endif", "#endif", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);", "#endif", "#if defined(CONFIG_USER_ONLY)", "#else", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", "#if defined(CONFIG_USER_ONLY)", "#else", " if (unlikely(ctx->pr)) {", "#endif", "#if defined(CONFIG_USER_ONLY)", "#else", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", "#if defined(CONFIG_USER_ONLY)", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif" ], "line_no": [ 13, 13, 5, 7, 9, 13, 15, 31, 5, 7, 9, 13, 15, 31, 31, 5, 7, 9, 13, 15, 13, 31, 7, 13, 15, 31, 7, 13, 15, 31, 7, 13, 15, 31, 7, 13, 15, 31, 7, 13, 15, 31, 7, 13, 15, 31, 7, 13, 15, 31, 7, 13, 15, 31, 7, 13, 15, 31, 7, 13, 15, 31, 7, 13, 15, 31, 31, 13, 31, 31, 31, 13, 31, 13, 31, 31, 13, 31, 13, 31, 13, 31, 13, 31, 13, 31, 13, 31, 13, 31, 13, 31, 13, 31, 13, 31, 7, 13, 15, 31, 7, 13, 15, 31, 7, 13, 15, 31, 7, 13, 15, 31, 5, 9, 13, 31, 13, 31, 5, 9, 13, 31, 5, 9, 13, 31, 13, 31, 13, 31, 13, 31, 13, 31, 13, 31, 13, 31, 13, 31, 13, 31, 13, 31, 13, 31, 5, 13, 31, 13, 31, 13, 31, 13, 31, 13, 31, 13, 31, 13, 31, 13, 31, 13, 31 ] }
static void FUNC_0(DisasContext *VAR_0) { #if defined(CONFIG_USER_ONLY) gen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_REG); #else TCGv t0; if (unlikely(VAR_0->pr)) { gen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_REG); return; } t0 = tcg_temp_new(); tcg_gen_shri_tl(t0, cpu_gpr[rB(VAR_0->opcode)], 28); tcg_gen_andi_tl(t0, t0, 0xF); gen_helper_store_sr(cpu_env, t0, cpu_gpr[rS(VAR_0->opcode)]); tcg_temp_free(t0); #endif }
[ "static void FUNC_0(DisasContext *VAR_0)\n{", "#if defined(CONFIG_USER_ONLY)\ngen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_REG);", "#else\nTCGv t0;", "if (unlikely(VAR_0->pr)) {", "gen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_REG);", "return;", "}", "t0 = tcg_temp_new();", "tcg_gen_shri_tl(t0, cpu_gpr[rB(VAR_0->opcode)], 28);", "tcg_gen_andi_tl(t0, t0, 0xF);", "gen_helper_store_sr(cpu_env, t0, cpu_gpr[rS(VAR_0->opcode)]);", "tcg_temp_free(t0);", "#endif\n}" ]
[ 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1 ]
[ [ 1, 3 ], [ 5, 7 ], [ 9, 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31, 33 ] ]
9,898
static pid_t qtest_qemu_pid(QTestState *s) { FILE *f; char buffer[1024]; pid_t pid = -1; f = fopen(s->pid_file, "r"); if (f) { if (fgets(buffer, sizeof(buffer), f)) { pid = atoi(buffer); } fclose(f); } return pid; }
true
qemu
1ad3c6abc0d67e00b84abaa5527bc64b70ca2205
static pid_t qtest_qemu_pid(QTestState *s) { FILE *f; char buffer[1024]; pid_t pid = -1; f = fopen(s->pid_file, "r"); if (f) { if (fgets(buffer, sizeof(buffer), f)) { pid = atoi(buffer); } fclose(f); } return pid; }
{ "code": [ "static pid_t qtest_qemu_pid(QTestState *s)", " f = fopen(s->pid_file, \"r\");" ], "line_no": [ 1, 13 ] }
static pid_t FUNC_0(QTestState *s) { FILE *f; char VAR_0[1024]; pid_t pid = -1; f = fopen(s->pid_file, "r"); if (f) { if (fgets(VAR_0, sizeof(VAR_0), f)) { pid = atoi(VAR_0); } fclose(f); } return pid; }
[ "static pid_t FUNC_0(QTestState *s)\n{", "FILE *f;", "char VAR_0[1024];", "pid_t pid = -1;", "f = fopen(s->pid_file, \"r\");", "if (f) {", "if (fgets(VAR_0, sizeof(VAR_0), f)) {", "pid = atoi(VAR_0);", "}", "fclose(f);", "}", "return pid;", "}" ]
[ 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ] ]
9,899
ssize_t pt_getxattr(FsContext *ctx, const char *path, const char *name, void *value, size_t size) { char *buffer; ssize_t ret; buffer = rpath(ctx, path); ret = lgetxattr(buffer, name, value, size); g_free(buffer); return ret; }
true
qemu
56ad3e54dad6cdcee8668d170df161d89581846f
ssize_t pt_getxattr(FsContext *ctx, const char *path, const char *name, void *value, size_t size) { char *buffer; ssize_t ret; buffer = rpath(ctx, path); ret = lgetxattr(buffer, name, value, size); g_free(buffer); return ret; }
{ "code": [ " char *buffer;", " ssize_t ret;", " buffer = rpath(ctx, path);", " g_free(buffer);", " return ret;", " char *buffer;", " ssize_t ret;", " buffer = rpath(ctx, path);", " g_free(buffer);", " return ret;", " char *buffer;", " ssize_t ret;", " buffer = rpath(ctx, path);", " ret = lgetxattr(buffer, name, value, size);", " g_free(buffer);", " return ret;", "ssize_t pt_getxattr(FsContext *ctx, const char *path, const char *name,", " void *value, size_t size)", " char *buffer;", " ssize_t ret;", " buffer = rpath(ctx, path);", " ret = lgetxattr(buffer, name, value, size);", " g_free(buffer);" ], "line_no": [ 7, 9, 13, 17, 19, 7, 9, 13, 17, 19, 7, 9, 13, 15, 17, 19, 1, 3, 7, 9, 13, 15, 17 ] }
ssize_t FUNC_0(FsContext *ctx, const char *path, const char *name, void *value, size_t size) { char *VAR_0; ssize_t ret; VAR_0 = rpath(ctx, path); ret = lgetxattr(VAR_0, name, value, size); g_free(VAR_0); return ret; }
[ "ssize_t FUNC_0(FsContext *ctx, const char *path, const char *name,\nvoid *value, size_t size)\n{", "char *VAR_0;", "ssize_t ret;", "VAR_0 = rpath(ctx, path);", "ret = lgetxattr(VAR_0, name, value, size);", "g_free(VAR_0);", "return ret;", "}" ]
[ 1, 1, 1, 1, 1, 1, 1, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ] ]
9,902
int qdev_device_help(QemuOpts *opts) { Error *local_err = NULL; const char *driver; DevicePropertyInfoList *prop_list; DevicePropertyInfoList *prop; driver = qemu_opt_get(opts, "driver"); if (driver && is_help_option(driver)) { qdev_print_devinfos(false); return 1; } if (!driver || !qemu_opt_has_help_opt(opts)) { return 0; } qdev_get_device_class(&driver, &local_err); if (local_err) { goto error; } prop_list = qmp_device_list_properties(driver, &local_err); if (local_err) { goto error; } for (prop = prop_list; prop; prop = prop->next) { error_printf("%s.%s=%s", driver, prop->value->name, prop->value->type); if (prop->value->has_description) { error_printf(" (%s)\n", prop->value->description); } else { error_printf("\n"); } } qapi_free_DevicePropertyInfoList(prop_list); return 1; error: error_printf("%s\n", error_get_pretty(local_err)); error_free(local_err); return 1; }
true
qemu
33fe96833015cf15f4c0aa5bf8d34f60526e0732
int qdev_device_help(QemuOpts *opts) { Error *local_err = NULL; const char *driver; DevicePropertyInfoList *prop_list; DevicePropertyInfoList *prop; driver = qemu_opt_get(opts, "driver"); if (driver && is_help_option(driver)) { qdev_print_devinfos(false); return 1; } if (!driver || !qemu_opt_has_help_opt(opts)) { return 0; } qdev_get_device_class(&driver, &local_err); if (local_err) { goto error; } prop_list = qmp_device_list_properties(driver, &local_err); if (local_err) { goto error; } for (prop = prop_list; prop; prop = prop->next) { error_printf("%s.%s=%s", driver, prop->value->name, prop->value->type); if (prop->value->has_description) { error_printf(" (%s)\n", prop->value->description); } else { error_printf("\n"); } } qapi_free_DevicePropertyInfoList(prop_list); return 1; error: error_printf("%s\n", error_get_pretty(local_err)); error_free(local_err); return 1; }
{ "code": [ " qdev_get_device_class(&driver, &local_err);", " if (local_err) {", " goto error;" ], "line_no": [ 35, 37, 39 ] }
int FUNC_0(QemuOpts *VAR_0) { Error *local_err = NULL; const char *VAR_1; DevicePropertyInfoList *prop_list; DevicePropertyInfoList *prop; VAR_1 = qemu_opt_get(VAR_0, "VAR_1"); if (VAR_1 && is_help_option(VAR_1)) { qdev_print_devinfos(false); return 1; } if (!VAR_1 || !qemu_opt_has_help_opt(VAR_0)) { return 0; } qdev_get_device_class(&VAR_1, &local_err); if (local_err) { goto error; } prop_list = qmp_device_list_properties(VAR_1, &local_err); if (local_err) { goto error; } for (prop = prop_list; prop; prop = prop->next) { error_printf("%s.%s=%s", VAR_1, prop->value->name, prop->value->type); if (prop->value->has_description) { error_printf(" (%s)\n", prop->value->description); } else { error_printf("\n"); } } qapi_free_DevicePropertyInfoList(prop_list); return 1; error: error_printf("%s\n", error_get_pretty(local_err)); error_free(local_err); return 1; }
[ "int FUNC_0(QemuOpts *VAR_0)\n{", "Error *local_err = NULL;", "const char *VAR_1;", "DevicePropertyInfoList *prop_list;", "DevicePropertyInfoList *prop;", "VAR_1 = qemu_opt_get(VAR_0, \"VAR_1\");", "if (VAR_1 && is_help_option(VAR_1)) {", "qdev_print_devinfos(false);", "return 1;", "}", "if (!VAR_1 || !qemu_opt_has_help_opt(VAR_0)) {", "return 0;", "}", "qdev_get_device_class(&VAR_1, &local_err);", "if (local_err) {", "goto error;", "}", "prop_list = qmp_device_list_properties(VAR_1, &local_err);", "if (local_err) {", "goto error;", "}", "for (prop = prop_list; prop; prop = prop->next) {", "error_printf(\"%s.%s=%s\", VAR_1,\nprop->value->name,\nprop->value->type);", "if (prop->value->has_description) {", "error_printf(\" (%s)\\n\", prop->value->description);", "} else {", "error_printf(\"\\n\");", "}", "}", "qapi_free_DevicePropertyInfoList(prop_list);", "return 1;", "error:\nerror_printf(\"%s\\n\", error_get_pretty(local_err));", "error_free(local_err);", "return 1;", "}" ]
[ 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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 27 ], [ 29 ], [ 31 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 55 ], [ 57, 59, 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 77 ], [ 79 ], [ 83, 85 ], [ 87 ], [ 89 ], [ 91 ] ]
9,903
static void free_stream(AVStream **pst) { AVStream *st = *pst; int i; if (!st) return; for (i = 0; i < st->nb_side_data; i++) av_freep(&st->side_data[i].data); av_freep(&st->side_data); if (st->parser) av_parser_close(st->parser); if (st->attached_pic.data) av_packet_unref(&st->attached_pic); if (st->internal) { avcodec_free_context(&st->internal->avctx); for (i = 0; i < st->internal->nb_bsfcs; i++) { av_bsf_free(&st->internal->bsfcs[i]); av_freep(&st->internal->bsfcs); } av_bsf_free(&st->internal->extract_extradata.bsf); av_packet_free(&st->internal->extract_extradata.pkt); } av_freep(&st->internal); av_dict_free(&st->metadata); avcodec_parameters_free(&st->codecpar); av_freep(&st->probe_data.buf); av_freep(&st->index_entries); #if FF_API_LAVF_AVCTX FF_DISABLE_DEPRECATION_WARNINGS av_freep(&st->codec->extradata); av_freep(&st->codec->subtitle_header); av_freep(&st->codec); FF_ENABLE_DEPRECATION_WARNINGS #endif av_freep(&st->priv_data); if (st->info) av_freep(&st->info->duration_error); av_freep(&st->info); av_freep(&st->recommended_encoder_configuration); av_freep(&st->priv_pts); av_freep(pst); }
true
FFmpeg
b9d2005ea5d6837917a69bc2b8e98f5695f54e39
static void free_stream(AVStream **pst) { AVStream *st = *pst; int i; if (!st) return; for (i = 0; i < st->nb_side_data; i++) av_freep(&st->side_data[i].data); av_freep(&st->side_data); if (st->parser) av_parser_close(st->parser); if (st->attached_pic.data) av_packet_unref(&st->attached_pic); if (st->internal) { avcodec_free_context(&st->internal->avctx); for (i = 0; i < st->internal->nb_bsfcs; i++) { av_bsf_free(&st->internal->bsfcs[i]); av_freep(&st->internal->bsfcs); } av_bsf_free(&st->internal->extract_extradata.bsf); av_packet_free(&st->internal->extract_extradata.pkt); } av_freep(&st->internal); av_dict_free(&st->metadata); avcodec_parameters_free(&st->codecpar); av_freep(&st->probe_data.buf); av_freep(&st->index_entries); #if FF_API_LAVF_AVCTX FF_DISABLE_DEPRECATION_WARNINGS av_freep(&st->codec->extradata); av_freep(&st->codec->subtitle_header); av_freep(&st->codec); FF_ENABLE_DEPRECATION_WARNINGS #endif av_freep(&st->priv_data); if (st->info) av_freep(&st->info->duration_error); av_freep(&st->info); av_freep(&st->recommended_encoder_configuration); av_freep(&st->priv_pts); av_freep(pst); }
{ "code": [ " av_freep(&st->codec->extradata);", " av_freep(&st->codec->subtitle_header);", " av_freep(&st->codec);" ], "line_no": [ 71, 73, 75 ] }
static void FUNC_0(AVStream **VAR_0) { AVStream *st = *VAR_0; int VAR_1; if (!st) return; for (VAR_1 = 0; VAR_1 < st->nb_side_data; VAR_1++) av_freep(&st->side_data[VAR_1].data); av_freep(&st->side_data); if (st->parser) av_parser_close(st->parser); if (st->attached_pic.data) av_packet_unref(&st->attached_pic); if (st->internal) { avcodec_free_context(&st->internal->avctx); for (VAR_1 = 0; VAR_1 < st->internal->nb_bsfcs; VAR_1++) { av_bsf_free(&st->internal->bsfcs[VAR_1]); av_freep(&st->internal->bsfcs); } av_bsf_free(&st->internal->extract_extradata.bsf); av_packet_free(&st->internal->extract_extradata.pkt); } av_freep(&st->internal); av_dict_free(&st->metadata); avcodec_parameters_free(&st->codecpar); av_freep(&st->probe_data.buf); av_freep(&st->index_entries); #if FF_API_LAVF_AVCTX FF_DISABLE_DEPRECATION_WARNINGS av_freep(&st->codec->extradata); av_freep(&st->codec->subtitle_header); av_freep(&st->codec); FF_ENABLE_DEPRECATION_WARNINGS #endif av_freep(&st->priv_data); if (st->info) av_freep(&st->info->duration_error); av_freep(&st->info); av_freep(&st->recommended_encoder_configuration); av_freep(&st->priv_pts); av_freep(VAR_0); }
[ "static void FUNC_0(AVStream **VAR_0)\n{", "AVStream *st = *VAR_0;", "int VAR_1;", "if (!st)\nreturn;", "for (VAR_1 = 0; VAR_1 < st->nb_side_data; VAR_1++)", "av_freep(&st->side_data[VAR_1].data);", "av_freep(&st->side_data);", "if (st->parser)\nav_parser_close(st->parser);", "if (st->attached_pic.data)\nav_packet_unref(&st->attached_pic);", "if (st->internal) {", "avcodec_free_context(&st->internal->avctx);", "for (VAR_1 = 0; VAR_1 < st->internal->nb_bsfcs; VAR_1++) {", "av_bsf_free(&st->internal->bsfcs[VAR_1]);", "av_freep(&st->internal->bsfcs);", "}", "av_bsf_free(&st->internal->extract_extradata.bsf);", "av_packet_free(&st->internal->extract_extradata.pkt);", "}", "av_freep(&st->internal);", "av_dict_free(&st->metadata);", "avcodec_parameters_free(&st->codecpar);", "av_freep(&st->probe_data.buf);", "av_freep(&st->index_entries);", "#if FF_API_LAVF_AVCTX\nFF_DISABLE_DEPRECATION_WARNINGS\nav_freep(&st->codec->extradata);", "av_freep(&st->codec->subtitle_header);", "av_freep(&st->codec);", "FF_ENABLE_DEPRECATION_WARNINGS\n#endif\nav_freep(&st->priv_data);", "if (st->info)\nav_freep(&st->info->duration_error);", "av_freep(&st->info);", "av_freep(&st->recommended_encoder_configuration);", "av_freep(&st->priv_pts);", "av_freep(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, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11, 13 ], [ 17 ], [ 19 ], [ 21 ], [ 25, 27 ], [ 31, 33 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67, 69, 71 ], [ 73 ], [ 75 ], [ 77, 79, 81 ], [ 83, 85 ], [ 87 ], [ 89 ], [ 91 ], [ 95 ], [ 97 ] ]
9,905
static void FUNCC(pred16x16_horizontal)(uint8_t *_src, int stride){ int i; pixel *src = (pixel*)_src; stride /= sizeof(pixel); for(i=0; i<16; i++){ ((pixel4*)(src+i*stride))[0] = ((pixel4*)(src+i*stride))[1] = ((pixel4*)(src+i*stride))[2] = ((pixel4*)(src+i*stride))[3] = PIXEL_SPLAT_X4(src[-1+i*stride]); } }
true
FFmpeg
2caf19e90f270abe1e80a3e85acaf0eb5c9d0aac
static void FUNCC(pred16x16_horizontal)(uint8_t *_src, int stride){ int i; pixel *src = (pixel*)_src; stride /= sizeof(pixel); for(i=0; i<16; i++){ ((pixel4*)(src+i*stride))[0] = ((pixel4*)(src+i*stride))[1] = ((pixel4*)(src+i*stride))[2] = ((pixel4*)(src+i*stride))[3] = PIXEL_SPLAT_X4(src[-1+i*stride]); } }
{ "code": [ " ((pixel4*)(src+i*stride))[0] =", " ((pixel4*)(src+i*stride))[1] =", " ((pixel4*)(src+i*stride))[2] =", " ((pixel4*)(src+i*stride))[3] = PIXEL_SPLAT_X4(src[-1+i*stride]);" ], "line_no": [ 13, 15, 17, 19 ] }
static void FUNC_0(pred16x16_horizontal)(uint8_t *_src, int stride){ int VAR_0; pixel *src = (pixel*)_src; stride /= sizeof(pixel); for(VAR_0=0; VAR_0<16; VAR_0++){ ((pixel4*)(src+VAR_0*stride))[0] = ((pixel4*)(src+VAR_0*stride))[1] = ((pixel4*)(src+VAR_0*stride))[2] = ((pixel4*)(src+VAR_0*stride))[3] = PIXEL_SPLAT_X4(src[-1+VAR_0*stride]); } }
[ "static void FUNC_0(pred16x16_horizontal)(uint8_t *_src, int stride){", "int VAR_0;", "pixel *src = (pixel*)_src;", "stride /= sizeof(pixel);", "for(VAR_0=0; VAR_0<16; VAR_0++){", "((pixel4*)(src+VAR_0*stride))[0] =\n((pixel4*)(src+VAR_0*stride))[1] =\n((pixel4*)(src+VAR_0*stride))[2] =\n((pixel4*)(src+VAR_0*stride))[3] = PIXEL_SPLAT_X4(src[-1+VAR_0*stride]);", "}", "}" ]
[ 0, 0, 0, 0, 0, 1, 0, 0 ]
[ [ 1 ], [ 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13, 15, 17, 19 ], [ 21 ], [ 23 ] ]
9,906
static void virtio_queue_host_notifier_read(EventNotifier *n) { VirtQueue *vq = container_of(n, VirtQueue, host_notifier); if (event_notifier_test_and_clear(n)) { virtio_queue_notify_vq(vq); } }
true
qemu
344dc16fae0cb6a011aa5befffc8e7d520b11d5d
static void virtio_queue_host_notifier_read(EventNotifier *n) { VirtQueue *vq = container_of(n, VirtQueue, host_notifier); if (event_notifier_test_and_clear(n)) { virtio_queue_notify_vq(vq); } }
{ "code": [ "static void virtio_queue_host_notifier_read(EventNotifier *n)", " virtio_queue_notify_vq(vq);" ], "line_no": [ 1, 9 ] }
static void FUNC_0(EventNotifier *VAR_0) { VirtQueue *vq = container_of(VAR_0, VirtQueue, host_notifier); if (event_notifier_test_and_clear(VAR_0)) { virtio_queue_notify_vq(vq); } }
[ "static void FUNC_0(EventNotifier *VAR_0)\n{", "VirtQueue *vq = container_of(VAR_0, VirtQueue, host_notifier);", "if (event_notifier_test_and_clear(VAR_0)) {", "virtio_queue_notify_vq(vq);", "}", "}" ]
[ 1, 0, 0, 1, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ] ]
9,907
static int get_uint16_equal(QEMUFile *f, void *pv, size_t size, VMStateField *field) { uint16_t *v = pv; uint16_t v2; qemu_get_be16s(f, &v2); if (*v == v2) { return 0; error_report("%x != %x", *v, v2); return -EINVAL;
true
qemu
d2164ad35c411d97abd2aa5c6f160283d215e214
static int get_uint16_equal(QEMUFile *f, void *pv, size_t size, VMStateField *field) { uint16_t *v = pv; uint16_t v2; qemu_get_be16s(f, &v2); if (*v == v2) { return 0; error_report("%x != %x", *v, v2); return -EINVAL;
{ "code": [], "line_no": [] }
static int FUNC_0(QEMUFile *VAR_0, void *VAR_1, size_t VAR_2, VMStateField *VAR_3) { uint16_t *v = VAR_1; uint16_t v2; qemu_get_be16s(VAR_0, &v2); if (*v == v2) { return 0; error_report("%x != %x", *v, v2); return -EINVAL;
[ "static int FUNC_0(QEMUFile *VAR_0, void *VAR_1, size_t VAR_2,\nVMStateField *VAR_3)\n{", "uint16_t *v = VAR_1;", "uint16_t v2;", "qemu_get_be16s(VAR_0, &v2);", "if (*v == v2) {", "return 0;", "error_report(\"%x != %x\", *v, v2);", "return -EINVAL;" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ], [ 20 ], [ 25 ] ]
9,908
static struct scoop_info_s *spitz_scoop_init(struct pxa2xx_state_s *cpu, int count) { int iomemtype; struct scoop_info_s *s; s = (struct scoop_info_s *) qemu_mallocz(sizeof(struct scoop_info_s) * 2); memset(s, 0, sizeof(struct scoop_info_s) * count); s[0].target_base = 0x10800000; s[1].target_base = 0x08800040; /* Ready */ s[0].status = 0x02; s[1].status = 0x02; iomemtype = cpu_register_io_memory(0, scoop_readfn, scoop_writefn, &s[0]); cpu_register_physical_memory(s[0].target_base, 0xfff, iomemtype); register_savevm("scoop", 0, 0, scoop_save, scoop_load, &s[0]); if (count < 2) return s; iomemtype = cpu_register_io_memory(0, scoop_readfn, scoop_writefn, &s[1]); cpu_register_physical_memory(s[1].target_base, 0xfff, iomemtype); register_savevm("scoop", 1, 0, scoop_save, scoop_load, &s[1]); return s; }
true
qemu
187337f8b0ec0813dd3876d1efe37d415fb81c2e
static struct scoop_info_s *spitz_scoop_init(struct pxa2xx_state_s *cpu, int count) { int iomemtype; struct scoop_info_s *s; s = (struct scoop_info_s *) qemu_mallocz(sizeof(struct scoop_info_s) * 2); memset(s, 0, sizeof(struct scoop_info_s) * count); s[0].target_base = 0x10800000; s[1].target_base = 0x08800040; s[0].status = 0x02; s[1].status = 0x02; iomemtype = cpu_register_io_memory(0, scoop_readfn, scoop_writefn, &s[0]); cpu_register_physical_memory(s[0].target_base, 0xfff, iomemtype); register_savevm("scoop", 0, 0, scoop_save, scoop_load, &s[0]); if (count < 2) return s; iomemtype = cpu_register_io_memory(0, scoop_readfn, scoop_writefn, &s[1]); cpu_register_physical_memory(s[1].target_base, 0xfff, iomemtype); register_savevm("scoop", 1, 0, scoop_save, scoop_load, &s[1]); return s; }
{ "code": [ " cpu_register_physical_memory(s[0].target_base, 0xfff, iomemtype);", " cpu_register_physical_memory(s[1].target_base, 0xfff, iomemtype);" ], "line_no": [ 35, 51 ] }
static struct scoop_info_s *FUNC_0(struct pxa2xx_state_s *VAR_0, int VAR_1) { int VAR_2; struct scoop_info_s *VAR_3; VAR_3 = (struct scoop_info_s *) qemu_mallocz(sizeof(struct scoop_info_s) * 2); memset(VAR_3, 0, sizeof(struct scoop_info_s) * VAR_1); VAR_3[0].target_base = 0x10800000; VAR_3[1].target_base = 0x08800040; VAR_3[0].status = 0x02; VAR_3[1].status = 0x02; VAR_2 = cpu_register_io_memory(0, scoop_readfn, scoop_writefn, &VAR_3[0]); cpu_register_physical_memory(VAR_3[0].target_base, 0xfff, VAR_2); register_savevm("scoop", 0, 0, scoop_save, scoop_load, &VAR_3[0]); if (VAR_1 < 2) return VAR_3; VAR_2 = cpu_register_io_memory(0, scoop_readfn, scoop_writefn, &VAR_3[1]); cpu_register_physical_memory(VAR_3[1].target_base, 0xfff, VAR_2); register_savevm("scoop", 1, 0, scoop_save, scoop_load, &VAR_3[1]); return VAR_3; }
[ "static struct scoop_info_s *FUNC_0(struct pxa2xx_state_s *VAR_0,\nint VAR_1) {", "int VAR_2;", "struct scoop_info_s *VAR_3;", "VAR_3 = (struct scoop_info_s *)\nqemu_mallocz(sizeof(struct scoop_info_s) * 2);", "memset(VAR_3, 0, sizeof(struct scoop_info_s) * VAR_1);", "VAR_3[0].target_base = 0x10800000;", "VAR_3[1].target_base = 0x08800040;", "VAR_3[0].status = 0x02;", "VAR_3[1].status = 0x02;", "VAR_2 = cpu_register_io_memory(0, scoop_readfn,\nscoop_writefn, &VAR_3[0]);", "cpu_register_physical_memory(VAR_3[0].target_base, 0xfff, VAR_2);", "register_savevm(\"scoop\", 0, 0, scoop_save, scoop_load, &VAR_3[0]);", "if (VAR_1 < 2)\nreturn VAR_3;", "VAR_2 = cpu_register_io_memory(0, scoop_readfn,\nscoop_writefn, &VAR_3[1]);", "cpu_register_physical_memory(VAR_3[1].target_base, 0xfff, VAR_2);", "register_savevm(\"scoop\", 1, 0, scoop_save, scoop_load, &VAR_3[1]);", "return VAR_3;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11, 13 ], [ 15 ], [ 17 ], [ 19 ], [ 25 ], [ 27 ], [ 31, 33 ], [ 35 ], [ 37 ], [ 41, 43 ], [ 47, 49 ], [ 51 ], [ 53 ], [ 57 ], [ 59 ] ]
9,909
static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) { AVFilterContext *ctx = inlink->dst; AVFilterLink *outlink = ctx->outputs[0]; ShowCQTContext *s = ctx->priv; int remaining, step, ret, x, i, j, m; float *audio_data; AVFrame *out = NULL; if (!insamples) { while (s->remaining_fill < s->fft_len / 2) { memset(&s->fft_data[s->fft_len - s->remaining_fill], 0, sizeof(*s->fft_data) * s->remaining_fill); ret = plot_cqt(ctx, &out); if (ret < 0) return ret; step = s->step + (s->step_frac.num + s->remaining_frac) / s->step_frac.den; s->remaining_frac = (s->step_frac.num + s->remaining_frac) % s->step_frac.den; for (x = 0; x < (s->fft_len-step); x++) s->fft_data[x] = s->fft_data[x+step]; s->remaining_fill += step; if (out) return ff_filter_frame(outlink, out); } return AVERROR_EOF; } remaining = insamples->nb_samples; audio_data = (float*) insamples->data[0]; while (remaining) { i = insamples->nb_samples - remaining; j = s->fft_len - s->remaining_fill; if (remaining >= s->remaining_fill) { for (m = 0; m < s->remaining_fill; m++) { s->fft_data[j+m].re = audio_data[2*(i+m)]; s->fft_data[j+m].im = audio_data[2*(i+m)+1]; } ret = plot_cqt(ctx, &out); if (ret < 0) { av_frame_free(&insamples); return ret; } remaining -= s->remaining_fill; if (out) { int64_t pts = av_rescale_q(insamples->pts, inlink->time_base, av_make_q(1, inlink->sample_rate)); pts += insamples->nb_samples - remaining - s->fft_len/2; pts = av_rescale_q(pts, av_make_q(1, inlink->sample_rate), outlink->time_base); if (FFABS(pts - out->pts) > PTS_TOLERANCE) { av_log(ctx, AV_LOG_DEBUG, "changing pts from %"PRId64" (%.3f) to %"PRId64" (%.3f).\n", out->pts, out->pts * av_q2d(outlink->time_base), pts, pts * av_q2d(outlink->time_base)); out->pts = pts; s->next_pts = pts + PTS_STEP; } ret = ff_filter_frame(outlink, out); if (ret < 0) { av_frame_free(&insamples); return ret; } out = NULL; } step = s->step + (s->step_frac.num + s->remaining_frac) / s->step_frac.den; s->remaining_frac = (s->step_frac.num + s->remaining_frac) % s->step_frac.den; for (m = 0; m < s->fft_len-step; m++) s->fft_data[m] = s->fft_data[m+step]; s->remaining_fill = step; } else { for (m = 0; m < remaining; m++) { s->fft_data[j+m].re = audio_data[2*(i+m)]; s->fft_data[j+m].im = audio_data[2*(i+m)+1]; } s->remaining_fill -= remaining; remaining = 0; } } av_frame_free(&insamples); return 0; }
true
FFmpeg
3408f4669427f5e950774d135c007f77d0d08d61
static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) { AVFilterContext *ctx = inlink->dst; AVFilterLink *outlink = ctx->outputs[0]; ShowCQTContext *s = ctx->priv; int remaining, step, ret, x, i, j, m; float *audio_data; AVFrame *out = NULL; if (!insamples) { while (s->remaining_fill < s->fft_len / 2) { memset(&s->fft_data[s->fft_len - s->remaining_fill], 0, sizeof(*s->fft_data) * s->remaining_fill); ret = plot_cqt(ctx, &out); if (ret < 0) return ret; step = s->step + (s->step_frac.num + s->remaining_frac) / s->step_frac.den; s->remaining_frac = (s->step_frac.num + s->remaining_frac) % s->step_frac.den; for (x = 0; x < (s->fft_len-step); x++) s->fft_data[x] = s->fft_data[x+step]; s->remaining_fill += step; if (out) return ff_filter_frame(outlink, out); } return AVERROR_EOF; } remaining = insamples->nb_samples; audio_data = (float*) insamples->data[0]; while (remaining) { i = insamples->nb_samples - remaining; j = s->fft_len - s->remaining_fill; if (remaining >= s->remaining_fill) { for (m = 0; m < s->remaining_fill; m++) { s->fft_data[j+m].re = audio_data[2*(i+m)]; s->fft_data[j+m].im = audio_data[2*(i+m)+1]; } ret = plot_cqt(ctx, &out); if (ret < 0) { av_frame_free(&insamples); return ret; } remaining -= s->remaining_fill; if (out) { int64_t pts = av_rescale_q(insamples->pts, inlink->time_base, av_make_q(1, inlink->sample_rate)); pts += insamples->nb_samples - remaining - s->fft_len/2; pts = av_rescale_q(pts, av_make_q(1, inlink->sample_rate), outlink->time_base); if (FFABS(pts - out->pts) > PTS_TOLERANCE) { av_log(ctx, AV_LOG_DEBUG, "changing pts from %"PRId64" (%.3f) to %"PRId64" (%.3f).\n", out->pts, out->pts * av_q2d(outlink->time_base), pts, pts * av_q2d(outlink->time_base)); out->pts = pts; s->next_pts = pts + PTS_STEP; } ret = ff_filter_frame(outlink, out); if (ret < 0) { av_frame_free(&insamples); return ret; } out = NULL; } step = s->step + (s->step_frac.num + s->remaining_frac) / s->step_frac.den; s->remaining_frac = (s->step_frac.num + s->remaining_frac) % s->step_frac.den; for (m = 0; m < s->fft_len-step; m++) s->fft_data[m] = s->fft_data[m+step]; s->remaining_fill = step; } else { for (m = 0; m < remaining; m++) { s->fft_data[j+m].re = audio_data[2*(i+m)]; s->fft_data[j+m].im = audio_data[2*(i+m)+1]; } s->remaining_fill -= remaining; remaining = 0; } } av_frame_free(&insamples); return 0; }
{ "code": [ " while (s->remaining_fill < s->fft_len / 2) {", " memset(&s->fft_data[s->fft_len - s->remaining_fill], 0, sizeof(*s->fft_data) * s->remaining_fill);", " for (x = 0; x < (s->fft_len-step); x++)", " j = s->fft_len - s->remaining_fill;", " pts += insamples->nb_samples - remaining - s->fft_len/2;", " for (m = 0; m < s->fft_len-step; m++)" ], "line_no": [ 21, 23, 37, 67, 95, 131 ] }
static int FUNC_0(AVFilterLink *VAR_0, AVFrame *VAR_1) { AVFilterContext *ctx = VAR_0->dst; AVFilterLink *outlink = ctx->outputs[0]; ShowCQTContext *s = ctx->priv; int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8; float *VAR_9; AVFrame *out = NULL; if (!VAR_1) { while (s->remaining_fill < s->fft_len / 2) { memset(&s->fft_data[s->fft_len - s->remaining_fill], 0, sizeof(*s->fft_data) * s->remaining_fill); VAR_4 = plot_cqt(ctx, &out); if (VAR_4 < 0) return VAR_4; VAR_3 = s->VAR_3 + (s->step_frac.num + s->remaining_frac) / s->step_frac.den; s->remaining_frac = (s->step_frac.num + s->remaining_frac) % s->step_frac.den; for (VAR_5 = 0; VAR_5 < (s->fft_len-VAR_3); VAR_5++) s->fft_data[VAR_5] = s->fft_data[VAR_5+VAR_3]; s->remaining_fill += VAR_3; if (out) return ff_filter_frame(outlink, out); } return AVERROR_EOF; } VAR_2 = VAR_1->nb_samples; VAR_9 = (float*) VAR_1->data[0]; while (VAR_2) { VAR_6 = VAR_1->nb_samples - VAR_2; VAR_7 = s->fft_len - s->remaining_fill; if (VAR_2 >= s->remaining_fill) { for (VAR_8 = 0; VAR_8 < s->remaining_fill; VAR_8++) { s->fft_data[VAR_7+VAR_8].re = VAR_9[2*(VAR_6+VAR_8)]; s->fft_data[VAR_7+VAR_8].im = VAR_9[2*(VAR_6+VAR_8)+1]; } VAR_4 = plot_cqt(ctx, &out); if (VAR_4 < 0) { av_frame_free(&VAR_1); return VAR_4; } VAR_2 -= s->remaining_fill; if (out) { int64_t pts = av_rescale_q(VAR_1->pts, VAR_0->time_base, av_make_q(1, VAR_0->sample_rate)); pts += VAR_1->nb_samples - VAR_2 - s->fft_len/2; pts = av_rescale_q(pts, av_make_q(1, VAR_0->sample_rate), outlink->time_base); if (FFABS(pts - out->pts) > PTS_TOLERANCE) { av_log(ctx, AV_LOG_DEBUG, "changing pts from %"PRId64" (%.3f) to %"PRId64" (%.3f).\n", out->pts, out->pts * av_q2d(outlink->time_base), pts, pts * av_q2d(outlink->time_base)); out->pts = pts; s->next_pts = pts + PTS_STEP; } VAR_4 = ff_filter_frame(outlink, out); if (VAR_4 < 0) { av_frame_free(&VAR_1); return VAR_4; } out = NULL; } VAR_3 = s->VAR_3 + (s->step_frac.num + s->remaining_frac) / s->step_frac.den; s->remaining_frac = (s->step_frac.num + s->remaining_frac) % s->step_frac.den; for (VAR_8 = 0; VAR_8 < s->fft_len-VAR_3; VAR_8++) s->fft_data[VAR_8] = s->fft_data[VAR_8+VAR_3]; s->remaining_fill = VAR_3; } else { for (VAR_8 = 0; VAR_8 < VAR_2; VAR_8++) { s->fft_data[VAR_7+VAR_8].re = VAR_9[2*(VAR_6+VAR_8)]; s->fft_data[VAR_7+VAR_8].im = VAR_9[2*(VAR_6+VAR_8)+1]; } s->remaining_fill -= VAR_2; VAR_2 = 0; } } av_frame_free(&VAR_1); return 0; }
[ "static int FUNC_0(AVFilterLink *VAR_0, AVFrame *VAR_1)\n{", "AVFilterContext *ctx = VAR_0->dst;", "AVFilterLink *outlink = ctx->outputs[0];", "ShowCQTContext *s = ctx->priv;", "int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8;", "float *VAR_9;", "AVFrame *out = NULL;", "if (!VAR_1) {", "while (s->remaining_fill < s->fft_len / 2) {", "memset(&s->fft_data[s->fft_len - s->remaining_fill], 0, sizeof(*s->fft_data) * s->remaining_fill);", "VAR_4 = plot_cqt(ctx, &out);", "if (VAR_4 < 0)\nreturn VAR_4;", "VAR_3 = s->VAR_3 + (s->step_frac.num + s->remaining_frac) / s->step_frac.den;", "s->remaining_frac = (s->step_frac.num + s->remaining_frac) % s->step_frac.den;", "for (VAR_5 = 0; VAR_5 < (s->fft_len-VAR_3); VAR_5++)", "s->fft_data[VAR_5] = s->fft_data[VAR_5+VAR_3];", "s->remaining_fill += VAR_3;", "if (out)\nreturn ff_filter_frame(outlink, out);", "}", "return AVERROR_EOF;", "}", "VAR_2 = VAR_1->nb_samples;", "VAR_9 = (float*) VAR_1->data[0];", "while (VAR_2) {", "VAR_6 = VAR_1->nb_samples - VAR_2;", "VAR_7 = s->fft_len - s->remaining_fill;", "if (VAR_2 >= s->remaining_fill) {", "for (VAR_8 = 0; VAR_8 < s->remaining_fill; VAR_8++) {", "s->fft_data[VAR_7+VAR_8].re = VAR_9[2*(VAR_6+VAR_8)];", "s->fft_data[VAR_7+VAR_8].im = VAR_9[2*(VAR_6+VAR_8)+1];", "}", "VAR_4 = plot_cqt(ctx, &out);", "if (VAR_4 < 0) {", "av_frame_free(&VAR_1);", "return VAR_4;", "}", "VAR_2 -= s->remaining_fill;", "if (out) {", "int64_t pts = av_rescale_q(VAR_1->pts, VAR_0->time_base, av_make_q(1, VAR_0->sample_rate));", "pts += VAR_1->nb_samples - VAR_2 - s->fft_len/2;", "pts = av_rescale_q(pts, av_make_q(1, VAR_0->sample_rate), outlink->time_base);", "if (FFABS(pts - out->pts) > PTS_TOLERANCE) {", "av_log(ctx, AV_LOG_DEBUG, \"changing pts from %\"PRId64\" (%.3f) to %\"PRId64\" (%.3f).\\n\",\nout->pts, out->pts * av_q2d(outlink->time_base),\npts, pts * av_q2d(outlink->time_base));", "out->pts = pts;", "s->next_pts = pts + PTS_STEP;", "}", "VAR_4 = ff_filter_frame(outlink, out);", "if (VAR_4 < 0) {", "av_frame_free(&VAR_1);", "return VAR_4;", "}", "out = NULL;", "}", "VAR_3 = s->VAR_3 + (s->step_frac.num + s->remaining_frac) / s->step_frac.den;", "s->remaining_frac = (s->step_frac.num + s->remaining_frac) % s->step_frac.den;", "for (VAR_8 = 0; VAR_8 < s->fft_len-VAR_3; VAR_8++)", "s->fft_data[VAR_8] = s->fft_data[VAR_8+VAR_3];", "s->remaining_fill = VAR_3;", "} else {", "for (VAR_8 = 0; VAR_8 < VAR_2; VAR_8++) {", "s->fft_data[VAR_7+VAR_8].re = VAR_9[2*(VAR_6+VAR_8)];", "s->fft_data[VAR_7+VAR_8].im = VAR_9[2*(VAR_6+VAR_8)+1];", "}", "s->remaining_fill -= VAR_2;", "VAR_2 = 0;", "}", "}", "av_frame_free(&VAR_1);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27, 29 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 45, 47 ], [ 49 ], [ 51 ], [ 53 ], [ 57 ], [ 59 ], [ 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 ] ]
9,910
static void rearm_sensor_evts(IPMIBmcSim *ibs, uint8_t *cmd, unsigned int cmd_len, uint8_t *rsp, unsigned int *rsp_len, unsigned int max_rsp_len) { IPMISensor *sens; IPMI_CHECK_CMD_LEN(4); if ((cmd[2] >= MAX_SENSORS) || !IPMI_SENSOR_GET_PRESENT(ibs->sensors + cmd[2])) { rsp[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT; return; } sens = ibs->sensors + cmd[2]; if ((cmd[3] & 0x80) == 0) { /* Just clear everything */ sens->states = 0; return; } }
true
qemu
4f298a4b2957b7833bc607c951ca27c458d98d88
static void rearm_sensor_evts(IPMIBmcSim *ibs, uint8_t *cmd, unsigned int cmd_len, uint8_t *rsp, unsigned int *rsp_len, unsigned int max_rsp_len) { IPMISensor *sens; IPMI_CHECK_CMD_LEN(4); if ((cmd[2] >= MAX_SENSORS) || !IPMI_SENSOR_GET_PRESENT(ibs->sensors + cmd[2])) { rsp[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT; return; } sens = ibs->sensors + cmd[2]; if ((cmd[3] & 0x80) == 0) { sens->states = 0; return; } }
{ "code": [ " IPMI_CHECK_CMD_LEN(4);", " IPMI_CHECK_CMD_LEN(4);", " IPMI_CHECK_CMD_LEN(4);" ], "line_no": [ 15, 15, 15 ] }
static void FUNC_0(IPMIBmcSim *VAR_0, uint8_t *VAR_1, unsigned int VAR_2, uint8_t *VAR_3, unsigned int *VAR_4, unsigned int VAR_5) { IPMISensor *sens; IPMI_CHECK_CMD_LEN(4); if ((VAR_1[2] >= MAX_SENSORS) || !IPMI_SENSOR_GET_PRESENT(VAR_0->sensors + VAR_1[2])) { VAR_3[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT; return; } sens = VAR_0->sensors + VAR_1[2]; if ((VAR_1[3] & 0x80) == 0) { sens->states = 0; return; } }
[ "static void FUNC_0(IPMIBmcSim *VAR_0,\nuint8_t *VAR_1, unsigned int VAR_2,\nuint8_t *VAR_3, unsigned int *VAR_4,\nunsigned int VAR_5)\n{", "IPMISensor *sens;", "IPMI_CHECK_CMD_LEN(4);", "if ((VAR_1[2] >= MAX_SENSORS) ||\n!IPMI_SENSOR_GET_PRESENT(VAR_0->sensors + VAR_1[2])) {", "VAR_3[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT;", "return;", "}", "sens = VAR_0->sensors + VAR_1[2];", "if ((VAR_1[3] & 0x80) == 0) {", "sens->states = 0;", "return;", "}", "}" ]
[ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9 ], [ 11 ], [ 15 ], [ 17, 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 31 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ] ]
9,912
CharDriverState *qemu_chr_open_opts(QemuOpts *opts, void (*init)(struct CharDriverState *s)) { CharDriverState *chr; int i; if (qemu_opts_id(opts) == NULL) { fprintf(stderr, "chardev: no id specified\n"); for (i = 0; i < ARRAY_SIZE(backend_table); i++) { if (strcmp(backend_table[i].name, qemu_opt_get(opts, "backend")) == 0) break; if (i == ARRAY_SIZE(backend_table)) { fprintf(stderr, "chardev: backend \"%s\" not found\n", qemu_opt_get(opts, "backend")); chr = backend_table[i].open(opts); if (!chr) { fprintf(stderr, "chardev: opening backend \"%s\" failed\n", qemu_opt_get(opts, "backend")); if (!chr->filename) chr->filename = qemu_strdup(qemu_opt_get(opts, "backend")); chr->init = init; QTAILQ_INSERT_TAIL(&chardevs, chr, next); if (qemu_opt_get_bool(opts, "mux", 0)) { CharDriverState *base = chr; int len = strlen(qemu_opts_id(opts)) + 6; base->label = qemu_malloc(len); snprintf(base->label, len, "%s-base", qemu_opts_id(opts)); chr = qemu_chr_open_mux(base); chr->filename = base->filename; QTAILQ_INSERT_TAIL(&chardevs, chr, next); chr->label = qemu_strdup(qemu_opts_id(opts)); return chr;
true
qemu
1bbd185fa826a2da7c6089b968f9f7d08438c2c8
CharDriverState *qemu_chr_open_opts(QemuOpts *opts, void (*init)(struct CharDriverState *s)) { CharDriverState *chr; int i; if (qemu_opts_id(opts) == NULL) { fprintf(stderr, "chardev: no id specified\n"); for (i = 0; i < ARRAY_SIZE(backend_table); i++) { if (strcmp(backend_table[i].name, qemu_opt_get(opts, "backend")) == 0) break; if (i == ARRAY_SIZE(backend_table)) { fprintf(stderr, "chardev: backend \"%s\" not found\n", qemu_opt_get(opts, "backend")); chr = backend_table[i].open(opts); if (!chr) { fprintf(stderr, "chardev: opening backend \"%s\" failed\n", qemu_opt_get(opts, "backend")); if (!chr->filename) chr->filename = qemu_strdup(qemu_opt_get(opts, "backend")); chr->init = init; QTAILQ_INSERT_TAIL(&chardevs, chr, next); if (qemu_opt_get_bool(opts, "mux", 0)) { CharDriverState *base = chr; int len = strlen(qemu_opts_id(opts)) + 6; base->label = qemu_malloc(len); snprintf(base->label, len, "%s-base", qemu_opts_id(opts)); chr = qemu_chr_open_mux(base); chr->filename = base->filename; QTAILQ_INSERT_TAIL(&chardevs, chr, next); chr->label = qemu_strdup(qemu_opts_id(opts)); return chr;
{ "code": [], "line_no": [] }
CharDriverState *FUNC_0(QemuOpts *opts, void (*init)(struct CharDriverState *s)) { CharDriverState *chr; int VAR_0; if (qemu_opts_id(opts) == NULL) { fprintf(stderr, "chardev: no id specified\n"); for (VAR_0 = 0; VAR_0 < ARRAY_SIZE(backend_table); VAR_0++) { if (strcmp(backend_table[VAR_0].name, qemu_opt_get(opts, "backend")) == 0) break; if (VAR_0 == ARRAY_SIZE(backend_table)) { fprintf(stderr, "chardev: backend \"%s\" not found\n", qemu_opt_get(opts, "backend")); chr = backend_table[VAR_0].open(opts); if (!chr) { fprintf(stderr, "chardev: opening backend \"%s\" failed\n", qemu_opt_get(opts, "backend")); if (!chr->filename) chr->filename = qemu_strdup(qemu_opt_get(opts, "backend")); chr->init = init; QTAILQ_INSERT_TAIL(&chardevs, chr, next); if (qemu_opt_get_bool(opts, "mux", 0)) { CharDriverState *base = chr; int len = strlen(qemu_opts_id(opts)) + 6; base->label = qemu_malloc(len); snprintf(base->label, len, "%s-base", qemu_opts_id(opts)); chr = qemu_chr_open_mux(base); chr->filename = base->filename; QTAILQ_INSERT_TAIL(&chardevs, chr, next); chr->label = qemu_strdup(qemu_opts_id(opts)); return chr;
[ "CharDriverState *FUNC_0(QemuOpts *opts,\nvoid (*init)(struct CharDriverState *s))\n{", "CharDriverState *chr;", "int VAR_0;", "if (qemu_opts_id(opts) == NULL) {", "fprintf(stderr, \"chardev: no id specified\\n\");", "for (VAR_0 = 0; VAR_0 < ARRAY_SIZE(backend_table); VAR_0++) {", "if (strcmp(backend_table[VAR_0].name, qemu_opt_get(opts, \"backend\")) == 0)\nbreak;", "if (VAR_0 == ARRAY_SIZE(backend_table)) {", "fprintf(stderr, \"chardev: backend \\\"%s\\\" not found\\n\",\nqemu_opt_get(opts, \"backend\"));", "chr = backend_table[VAR_0].open(opts);", "if (!chr) {", "fprintf(stderr, \"chardev: opening backend \\\"%s\\\" failed\\n\",\nqemu_opt_get(opts, \"backend\"));", "if (!chr->filename)\nchr->filename = qemu_strdup(qemu_opt_get(opts, \"backend\"));", "chr->init = init;", "QTAILQ_INSERT_TAIL(&chardevs, chr, next);", "if (qemu_opt_get_bool(opts, \"mux\", 0)) {", "CharDriverState *base = chr;", "int len = strlen(qemu_opts_id(opts)) + 6;", "base->label = qemu_malloc(len);", "snprintf(base->label, len, \"%s-base\", qemu_opts_id(opts));", "chr = qemu_chr_open_mux(base);", "chr->filename = base->filename;", "QTAILQ_INSERT_TAIL(&chardevs, chr, next);", "chr->label = qemu_strdup(qemu_opts_id(opts));", "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 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 26 ], [ 28, 30 ], [ 33 ], [ 35, 37 ], [ 43 ], [ 45 ], [ 47, 49 ], [ 55, 57 ], [ 59 ], [ 61 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 82 ], [ 84 ] ]
9,914
QVirtioPCIDevice *qvirtio_pci_device_find(QPCIBus *bus, uint16_t device_type) { QVirtioPCIDevice *dev = NULL; qvirtio_pci_foreach(bus, device_type, qvirtio_pci_assign_device, &dev); dev->vdev.bus = &qvirtio_pci; return dev; }
true
qemu
c4523aae0664aecaa366d45e3d0f3d810ca33062
QVirtioPCIDevice *qvirtio_pci_device_find(QPCIBus *bus, uint16_t device_type) { QVirtioPCIDevice *dev = NULL; qvirtio_pci_foreach(bus, device_type, qvirtio_pci_assign_device, &dev); dev->vdev.bus = &qvirtio_pci; return dev; }
{ "code": [ " qvirtio_pci_foreach(bus, device_type, qvirtio_pci_assign_device, &dev);" ], "line_no": [ 7 ] }
QVirtioPCIDevice *FUNC_0(QPCIBus *bus, uint16_t device_type) { QVirtioPCIDevice *dev = NULL; qvirtio_pci_foreach(bus, device_type, qvirtio_pci_assign_device, &dev); dev->vdev.bus = &qvirtio_pci; return dev; }
[ "QVirtioPCIDevice *FUNC_0(QPCIBus *bus, uint16_t device_type)\n{", "QVirtioPCIDevice *dev = NULL;", "qvirtio_pci_foreach(bus, device_type, qvirtio_pci_assign_device, &dev);", "dev->vdev.bus = &qvirtio_pci;", "return dev;", "}" ]
[ 0, 0, 1, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 15 ], [ 17 ] ]
9,915
static int get_dimension(GetBitContext *gb, const int *dim) { int t = get_bits(gb, 3); int val = dim[t]; if(val < 0) val = dim[get_bits1(gb) - val]; if(!val){ do{ t = get_bits(gb, 8); val += t << 2; }while(t == 0xFF); } return val; }
true
FFmpeg
1546d487cf12da37d90a080813f8d57ac33036bf
static int get_dimension(GetBitContext *gb, const int *dim) { int t = get_bits(gb, 3); int val = dim[t]; if(val < 0) val = dim[get_bits1(gb) - val]; if(!val){ do{ t = get_bits(gb, 8); val += t << 2; }while(t == 0xFF); } return val; }
{ "code": [], "line_no": [] }
static int FUNC_0(GetBitContext *VAR_0, const int *VAR_1) { int VAR_2 = get_bits(VAR_0, 3); int VAR_3 = VAR_1[VAR_2]; if(VAR_3 < 0) VAR_3 = VAR_1[get_bits1(VAR_0) - VAR_3]; if(!VAR_3){ do{ VAR_2 = get_bits(VAR_0, 8); VAR_3 += VAR_2 << 2; }while(VAR_2 == 0xFF); } return VAR_3; }
[ "static int FUNC_0(GetBitContext *VAR_0, const int *VAR_1)\n{", "int VAR_2 = get_bits(VAR_0, 3);", "int VAR_3 = VAR_1[VAR_2];", "if(VAR_3 < 0)\nVAR_3 = VAR_1[get_bits1(VAR_0) - VAR_3];", "if(!VAR_3){", "do{", "VAR_2 = get_bits(VAR_0, 8);", "VAR_3 += VAR_2 << 2;", "}while(VAR_2 == 0xFF);", "}", "return VAR_3;", "}" ]
[ 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 ] ]
9,916
static int slirp_smb(SlirpState* s, const char *exported_dir, struct in_addr vserver_addr) { static int instance; char smb_conf[128]; char smb_cmdline[128]; struct passwd *passwd; FILE *f; passwd = getpwuid(geteuid()); if (!passwd) { error_report("failed to retrieve user name"); snprintf(s->smb_dir, sizeof(s->smb_dir), "/tmp/qemu-smb.%ld-%d", (long)getpid(), instance++); if (mkdir(s->smb_dir, 0700) < 0) { error_report("could not create samba server dir '%s'", s->smb_dir); snprintf(smb_conf, sizeof(smb_conf), "%s/%s", s->smb_dir, "smb.conf"); f = fopen(smb_conf, "w"); if (!f) { slirp_smb_cleanup(s); error_report("could not create samba server configuration file '%s'", smb_conf); fprintf(f, "[global]\n" "private dir=%s\n" "socket address=127.0.0.1\n" "pid directory=%s\n" "lock directory=%s\n" "state directory=%s\n" "log file=%s/log.smbd\n" "smb passwd file=%s/smbpasswd\n" "security = share\n" "[qemu]\n" "path=%s\n" "read only=no\n" "guest ok=yes\n" "force user=%s\n", s->smb_dir, s->smb_dir, s->smb_dir, s->smb_dir, s->smb_dir, s->smb_dir, exported_dir, passwd->pw_name ); fclose(f); snprintf(smb_cmdline, sizeof(smb_cmdline), "%s -s %s", CONFIG_SMBD_COMMAND, smb_conf); if (slirp_add_exec(s->slirp, 0, smb_cmdline, &vserver_addr, 139) < 0) { slirp_smb_cleanup(s); error_report("conflicting/invalid smbserver address"); return 0;
true
qemu
927d811b282ffdf5386bd63f435c1507634ba49a
static int slirp_smb(SlirpState* s, const char *exported_dir, struct in_addr vserver_addr) { static int instance; char smb_conf[128]; char smb_cmdline[128]; struct passwd *passwd; FILE *f; passwd = getpwuid(geteuid()); if (!passwd) { error_report("failed to retrieve user name"); snprintf(s->smb_dir, sizeof(s->smb_dir), "/tmp/qemu-smb.%ld-%d", (long)getpid(), instance++); if (mkdir(s->smb_dir, 0700) < 0) { error_report("could not create samba server dir '%s'", s->smb_dir); snprintf(smb_conf, sizeof(smb_conf), "%s/%s", s->smb_dir, "smb.conf"); f = fopen(smb_conf, "w"); if (!f) { slirp_smb_cleanup(s); error_report("could not create samba server configuration file '%s'", smb_conf); fprintf(f, "[global]\n" "private dir=%s\n" "socket address=127.0.0.1\n" "pid directory=%s\n" "lock directory=%s\n" "state directory=%s\n" "log file=%s/log.smbd\n" "smb passwd file=%s/smbpasswd\n" "security = share\n" "[qemu]\n" "path=%s\n" "read only=no\n" "guest ok=yes\n" "force user=%s\n", s->smb_dir, s->smb_dir, s->smb_dir, s->smb_dir, s->smb_dir, s->smb_dir, exported_dir, passwd->pw_name ); fclose(f); snprintf(smb_cmdline, sizeof(smb_cmdline), "%s -s %s", CONFIG_SMBD_COMMAND, smb_conf); if (slirp_add_exec(s->slirp, 0, smb_cmdline, &vserver_addr, 139) < 0) { slirp_smb_cleanup(s); error_report("conflicting/invalid smbserver address"); return 0;
{ "code": [], "line_no": [] }
static int FUNC_0(SlirpState* VAR_0, const char *VAR_1, struct in_addr VAR_2) { static int VAR_3; char VAR_4[128]; char VAR_5[128]; struct VAR_6 *VAR_6; FILE *f; VAR_6 = getpwuid(geteuid()); if (!VAR_6) { error_report("failed to retrieve user name"); snprintf(VAR_0->smb_dir, sizeof(VAR_0->smb_dir), "/tmp/qemu-smb.%ld-%d", (long)getpid(), VAR_3++); if (mkdir(VAR_0->smb_dir, 0700) < 0) { error_report("could not create samba server dir '%VAR_0'", VAR_0->smb_dir); snprintf(VAR_4, sizeof(VAR_4), "%VAR_0/%VAR_0", VAR_0->smb_dir, "smb.conf"); f = fopen(VAR_4, "w"); if (!f) { slirp_smb_cleanup(VAR_0); error_report("could not create samba server configuration file '%VAR_0'", VAR_4); fprintf(f, "[global]\n" "private dir=%VAR_0\n" "socket address=127.0.0.1\n" "pid directory=%VAR_0\n" "lock directory=%VAR_0\n" "state directory=%VAR_0\n" "log file=%VAR_0/log.smbd\n" "smb VAR_6 file=%VAR_0/smbpasswd\n" "security = share\n" "[qemu]\n" "path=%VAR_0\n" "read only=no\n" "guest ok=yes\n" "force user=%VAR_0\n", VAR_0->smb_dir, VAR_0->smb_dir, VAR_0->smb_dir, VAR_0->smb_dir, VAR_0->smb_dir, VAR_0->smb_dir, VAR_1, VAR_6->pw_name ); fclose(f); snprintf(VAR_5, sizeof(VAR_5), "%VAR_0 -VAR_0 %VAR_0", CONFIG_SMBD_COMMAND, VAR_4); if (slirp_add_exec(VAR_0->slirp, 0, VAR_5, &VAR_2, 139) < 0) { slirp_smb_cleanup(VAR_0); error_report("conflicting/invalid smbserver address"); return 0;
[ "static int FUNC_0(SlirpState* VAR_0, const char *VAR_1,\nstruct in_addr VAR_2)\n{", "static int VAR_3;", "char VAR_4[128];", "char VAR_5[128];", "struct VAR_6 *VAR_6;", "FILE *f;", "VAR_6 = getpwuid(geteuid());", "if (!VAR_6) {", "error_report(\"failed to retrieve user name\");", "snprintf(VAR_0->smb_dir, sizeof(VAR_0->smb_dir), \"/tmp/qemu-smb.%ld-%d\",\n(long)getpid(), VAR_3++);", "if (mkdir(VAR_0->smb_dir, 0700) < 0) {", "error_report(\"could not create samba server dir '%VAR_0'\", VAR_0->smb_dir);", "snprintf(VAR_4, sizeof(VAR_4), \"%VAR_0/%VAR_0\", VAR_0->smb_dir, \"smb.conf\");", "f = fopen(VAR_4, \"w\");", "if (!f) {", "slirp_smb_cleanup(VAR_0);", "error_report(\"could not create samba server configuration file '%VAR_0'\",\nVAR_4);", "fprintf(f,\n\"[global]\\n\"\n\"private dir=%VAR_0\\n\"\n\"socket address=127.0.0.1\\n\"\n\"pid directory=%VAR_0\\n\"\n\"lock directory=%VAR_0\\n\"\n\"state directory=%VAR_0\\n\"\n\"log file=%VAR_0/log.smbd\\n\"\n\"smb VAR_6 file=%VAR_0/smbpasswd\\n\"\n\"security = share\\n\"\n\"[qemu]\\n\"\n\"path=%VAR_0\\n\"\n\"read only=no\\n\"\n\"guest ok=yes\\n\"\n\"force user=%VAR_0\\n\",\nVAR_0->smb_dir,\nVAR_0->smb_dir,\nVAR_0->smb_dir,\nVAR_0->smb_dir,\nVAR_0->smb_dir,\nVAR_0->smb_dir,\nVAR_1,\nVAR_6->pw_name\n);", "fclose(f);", "snprintf(VAR_5, sizeof(VAR_5), \"%VAR_0 -VAR_0 %VAR_0\",\nCONFIG_SMBD_COMMAND, VAR_4);", "if (slirp_add_exec(VAR_0->slirp, 0, VAR_5, &VAR_2, 139) < 0) {", "slirp_smb_cleanup(VAR_0);", "error_report(\"conflicting/invalid smbserver address\");", "return 0;" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 2, 3 ], [ 4 ], [ 5 ], [ 6 ], [ 7 ], [ 8 ], [ 9 ], [ 10 ], [ 11 ], [ 12, 13 ], [ 14 ], [ 15 ], [ 16 ], [ 17 ], [ 18 ], [ 19 ], [ 20, 21 ], [ 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45 ], [ 46 ], [ 47, 48 ], [ 49 ], [ 50 ], [ 51 ], [ 52 ] ]
9,917
static always_inline void gen_op_arith_compute_ca(DisasContext *ctx, TCGv arg1, TCGv arg2, int sub) { int l1 = gen_new_label(); #if defined(TARGET_PPC64) if (!(ctx->sf_mode)) { TCGv t0, t1; t0 = tcg_temp_new(TCG_TYPE_TL); t1 = tcg_temp_new(TCG_TYPE_TL); tcg_gen_ext32u_tl(t0, arg1); tcg_gen_ext32u_tl(t1, arg2); if (sub) { tcg_gen_brcond_tl(TCG_COND_GTU, t0, t1, l1); } else { tcg_gen_brcond_tl(TCG_COND_GEU, t0, t1, l1); } } else #endif if (sub) { tcg_gen_brcond_tl(TCG_COND_GTU, arg1, arg2, l1); } else { tcg_gen_brcond_tl(TCG_COND_GEU, arg1, arg2, l1); } tcg_gen_ori_tl(cpu_xer, cpu_xer, 1 << XER_CA); gen_set_label(l1); }
true
qemu
a973001797221b0fd7be55cb6513c72a01f4b639
static always_inline void gen_op_arith_compute_ca(DisasContext *ctx, TCGv arg1, TCGv arg2, int sub) { int l1 = gen_new_label(); #if defined(TARGET_PPC64) if (!(ctx->sf_mode)) { TCGv t0, t1; t0 = tcg_temp_new(TCG_TYPE_TL); t1 = tcg_temp_new(TCG_TYPE_TL); tcg_gen_ext32u_tl(t0, arg1); tcg_gen_ext32u_tl(t1, arg2); if (sub) { tcg_gen_brcond_tl(TCG_COND_GTU, t0, t1, l1); } else { tcg_gen_brcond_tl(TCG_COND_GEU, t0, t1, l1); } } else #endif if (sub) { tcg_gen_brcond_tl(TCG_COND_GTU, arg1, arg2, l1); } else { tcg_gen_brcond_tl(TCG_COND_GEU, arg1, arg2, l1); } tcg_gen_ori_tl(cpu_xer, cpu_xer, 1 << XER_CA); gen_set_label(l1); }
{ "code": [ " if (sub) {", " tcg_gen_brcond_tl(TCG_COND_GTU, arg1, arg2, l1);", " } else {", " tcg_gen_brcond_tl(TCG_COND_GEU, arg1, arg2, l1);", " tcg_gen_ori_tl(cpu_xer, cpu_xer, 1 << XER_CA);", " gen_set_label(l1);", " t0 = tcg_temp_new(TCG_TYPE_TL);" ], "line_no": [ 39, 41, 43, 45, 49, 51, 15 ] }
static always_inline void FUNC_0(DisasContext *ctx, TCGv arg1, TCGv arg2, int sub) { int VAR_0 = gen_new_label(); #if defined(TARGET_PPC64) if (!(ctx->sf_mode)) { TCGv t0, t1; t0 = tcg_temp_new(TCG_TYPE_TL); t1 = tcg_temp_new(TCG_TYPE_TL); tcg_gen_ext32u_tl(t0, arg1); tcg_gen_ext32u_tl(t1, arg2); if (sub) { tcg_gen_brcond_tl(TCG_COND_GTU, t0, t1, VAR_0); } else { tcg_gen_brcond_tl(TCG_COND_GEU, t0, t1, VAR_0); } } else #endif if (sub) { tcg_gen_brcond_tl(TCG_COND_GTU, arg1, arg2, VAR_0); } else { tcg_gen_brcond_tl(TCG_COND_GEU, arg1, arg2, VAR_0); } tcg_gen_ori_tl(cpu_xer, cpu_xer, 1 << XER_CA); gen_set_label(VAR_0); }
[ "static always_inline void FUNC_0(DisasContext *ctx, TCGv arg1, TCGv arg2, int sub)\n{", "int VAR_0 = gen_new_label();", "#if defined(TARGET_PPC64)\nif (!(ctx->sf_mode)) {", "TCGv t0, t1;", "t0 = tcg_temp_new(TCG_TYPE_TL);", "t1 = tcg_temp_new(TCG_TYPE_TL);", "tcg_gen_ext32u_tl(t0, arg1);", "tcg_gen_ext32u_tl(t1, arg2);", "if (sub) {", "tcg_gen_brcond_tl(TCG_COND_GTU, t0, t1, VAR_0);", "} else {", "tcg_gen_brcond_tl(TCG_COND_GEU, t0, t1, VAR_0);", "}", "} else", "#endif\nif (sub) {", "tcg_gen_brcond_tl(TCG_COND_GTU, arg1, arg2, VAR_0);", "} else {", "tcg_gen_brcond_tl(TCG_COND_GEU, arg1, arg2, VAR_0);", "}", "tcg_gen_ori_tl(cpu_xer, cpu_xer, 1 << XER_CA);", "gen_set_label(VAR_0);", "}" ]
[ 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9, 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37, 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ] ]
9,918
const char *avformat_configuration(void) { return FFMPEG_CONFIGURATION; }
false
FFmpeg
29ba091136a5e04574f7bfc1b17536c923958f6f
const char *avformat_configuration(void) { return FFMPEG_CONFIGURATION; }
{ "code": [], "line_no": [] }
const char *FUNC_0(void) { return FFMPEG_CONFIGURATION; }
[ "const char *FUNC_0(void)\n{", "return FFMPEG_CONFIGURATION;", "}" ]
[ 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ] ]
9,920
int ff_framesync_dualinput_get_writable(FFFrameSync *fs, AVFrame **f0, AVFrame **f1) { int ret; ret = ff_framesync_dualinput_get(fs, f0, f1); if (ret < 0) return ret; ret = ff_inlink_make_frame_writable(fs->parent->inputs[0], f0); if (ret < 0) { av_frame_free(f0); av_frame_free(f1); return ret; } return 0; }
false
FFmpeg
29b5f3115d9f217758bebd1d00e541aa3e739d2a
int ff_framesync_dualinput_get_writable(FFFrameSync *fs, AVFrame **f0, AVFrame **f1) { int ret; ret = ff_framesync_dualinput_get(fs, f0, f1); if (ret < 0) return ret; ret = ff_inlink_make_frame_writable(fs->parent->inputs[0], f0); if (ret < 0) { av_frame_free(f0); av_frame_free(f1); return ret; } return 0; }
{ "code": [], "line_no": [] }
int FUNC_0(FFFrameSync *VAR_0, AVFrame **VAR_1, AVFrame **VAR_2) { int VAR_3; VAR_3 = ff_framesync_dualinput_get(VAR_0, VAR_1, VAR_2); if (VAR_3 < 0) return VAR_3; VAR_3 = ff_inlink_make_frame_writable(VAR_0->parent->inputs[0], VAR_1); if (VAR_3 < 0) { av_frame_free(VAR_1); av_frame_free(VAR_2); return VAR_3; } return 0; }
[ "int FUNC_0(FFFrameSync *VAR_0, AVFrame **VAR_1, AVFrame **VAR_2)\n{", "int VAR_3;", "VAR_3 = ff_framesync_dualinput_get(VAR_0, VAR_1, VAR_2);", "if (VAR_3 < 0)\nreturn VAR_3;", "VAR_3 = ff_inlink_make_frame_writable(VAR_0->parent->inputs[0], VAR_1);", "if (VAR_3 < 0) {", "av_frame_free(VAR_1);", "av_frame_free(VAR_2);", "return VAR_3;", "}", "return 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 ] ]
9,921
static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data, int size, int64_t pos, uint64_t cluster_time, uint64_t duration, int is_keyframe, int64_t cluster_pos) { uint64_t timecode = AV_NOPTS_VALUE; MatroskaTrack *track; int res = 0; AVStream *st; AVPacket *pkt; int16_t block_time; uint32_t *lace_size = NULL; int n, flags, laces = 0; uint64_t num; if ((n = matroska_ebmlnum_uint(matroska, data, size, &num)) < 0) { av_log(matroska->ctx, AV_LOG_ERROR, "EBML block data error\n"); return res; data += n; size -= n; track = matroska_find_track_by_num(matroska, num); if (size <= 3 || !track || !track->stream) { av_log(matroska->ctx, AV_LOG_INFO, "Invalid stream %"PRIu64" or size %u\n", num, size); return res; st = track->stream; if (st->discard >= AVDISCARD_ALL) return res; if (duration == AV_NOPTS_VALUE) duration = track->default_duration / matroska->time_scale; block_time = AV_RB16(data); data += 2; flags = *data++; size -= 3; if (is_keyframe == -1) is_keyframe = flags & 0x80 ? PKT_FLAG_KEY : 0; if (cluster_time != (uint64_t)-1 && (block_time >= 0 || cluster_time >= -block_time)) { timecode = cluster_time + block_time; if (track->type == MATROSKA_TRACK_TYPE_SUBTITLE && timecode < track->end_timecode) is_keyframe = 0; /* overlapping subtitles are not key frame */ if (is_keyframe) av_add_index_entry(st, cluster_pos, timecode, 0,0,AVINDEX_KEYFRAME); track->end_timecode = FFMAX(track->end_timecode, timecode+duration); if (matroska->skip_to_keyframe && track->type != MATROSKA_TRACK_TYPE_SUBTITLE) { if (!is_keyframe || timecode < matroska->skip_to_timecode) return res; matroska->skip_to_keyframe = 0; switch ((flags & 0x06) >> 1) { case 0x0: /* no lacing */ laces = 1; lace_size = av_mallocz(sizeof(int)); lace_size[0] = size; case 0x1: /* Xiph lacing */ case 0x2: /* fixed-size lacing */ case 0x3: /* EBML lacing */ assert(size>0); // size <=3 is checked before size-=3 above laces = (*data) + 1; data += 1; size -= 1; lace_size = av_mallocz(laces * sizeof(int)); switch ((flags & 0x06) >> 1) { case 0x1: /* Xiph lacing */ { uint8_t temp; uint32_t total = 0; for (n = 0; res == 0 && n < laces - 1; n++) { while (1) { if (size == 0) { res = -1; temp = *data; lace_size[n] += temp; data += 1; size -= 1; if (temp != 0xff) total += lace_size[n]; lace_size[n] = size - total; case 0x2: /* fixed-size lacing */ for (n = 0; n < laces; n++) lace_size[n] = size / laces; case 0x3: /* EBML lacing */ { uint32_t total; n = matroska_ebmlnum_uint(matroska, data, size, &num); if (n < 0) { av_log(matroska->ctx, AV_LOG_INFO, "EBML block data error\n"); data += n; size -= n; total = lace_size[0] = num; for (n = 1; res == 0 && n < laces - 1; n++) { int64_t snum; int r; r = matroska_ebmlnum_sint(matroska, data, size, &snum); if (r < 0) { av_log(matroska->ctx, AV_LOG_INFO, "EBML block data error\n"); data += r; size -= r; lace_size[n] = lace_size[n - 1] + snum; total += lace_size[n]; lace_size[n] = size - total; if (res == 0) { for (n = 0; n < laces; n++) { if ((st->codec->codec_id == CODEC_ID_RA_288 || st->codec->codec_id == CODEC_ID_COOK || st->codec->codec_id == CODEC_ID_ATRAC3) && st->codec->block_align && track->audio.sub_packet_size) { int a = st->codec->block_align; int sps = track->audio.sub_packet_size; int cfs = track->audio.coded_framesize; int h = track->audio.sub_packet_h; int y = track->audio.sub_packet_cnt; int w = track->audio.frame_size; int x; if (!track->audio.pkt_cnt) { if (st->codec->codec_id == CODEC_ID_RA_288) for (x=0; x<h/2; x++) memcpy(track->audio.buf+x*2*w+y*cfs, data+x*cfs, cfs); else for (x=0; x<w/sps; x++) memcpy(track->audio.buf+sps*(h*x+((h+1)/2)*(y&1)+(y>>1)), data+x*sps, sps); if (++track->audio.sub_packet_cnt >= h) { track->audio.sub_packet_cnt = 0; track->audio.pkt_cnt = h*w / a; while (track->audio.pkt_cnt) { pkt = av_mallocz(sizeof(AVPacket)); av_new_packet(pkt, a); memcpy(pkt->data, track->audio.buf + a * (h*w / a - track->audio.pkt_cnt--), a); pkt->pos = pos; pkt->stream_index = st->index; dynarray_add(&matroska->packets,&matroska->num_packets,pkt); } else { MatroskaTrackEncoding *encodings = track->encodings.elem; int offset = 0, pkt_size = lace_size[n]; uint8_t *pkt_data = data; if (encodings && encodings->scope & 1) { offset = matroska_decode_buffer(&pkt_data,&pkt_size, track); if (offset < 0) continue; pkt = av_mallocz(sizeof(AVPacket)); /* XXX: prevent data copy... */ if (av_new_packet(pkt, pkt_size+offset) < 0) { av_free(pkt); res = AVERROR(ENOMEM); if (offset) memcpy (pkt->data, encodings->compression.settings.data, offset); memcpy (pkt->data+offset, pkt_data, pkt_size); if (pkt_data != data) av_free(pkt_data); if (n == 0) pkt->flags = is_keyframe; pkt->stream_index = st->index; if (track->ms_compat) pkt->dts = timecode; else pkt->pts = timecode; pkt->pos = pos; if (st->codec->codec_id == CODEC_ID_TEXT) pkt->convergence_duration = duration; else if (track->type != MATROSKA_TRACK_TYPE_SUBTITLE) pkt->duration = duration; if (st->codec->codec_id == CODEC_ID_SSA) matroska_fix_ass_packet(matroska, pkt, duration); if (matroska->prev_pkt && timecode != AV_NOPTS_VALUE && matroska->prev_pkt->pts == timecode && matroska->prev_pkt->stream_index == st->index) matroska_merge_packets(matroska->prev_pkt, pkt); else { dynarray_add(&matroska->packets,&matroska->num_packets,pkt); matroska->prev_pkt = pkt; if (timecode != AV_NOPTS_VALUE) timecode = duration ? timecode + duration : AV_NOPTS_VALUE; data += lace_size[n]; size -= lace_size[n]; av_free(lace_size); return res;
true
FFmpeg
e48f7ff3cb73fbaba0f5b8d442dc5909f705c863
static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data, int size, int64_t pos, uint64_t cluster_time, uint64_t duration, int is_keyframe, int64_t cluster_pos) { uint64_t timecode = AV_NOPTS_VALUE; MatroskaTrack *track; int res = 0; AVStream *st; AVPacket *pkt; int16_t block_time; uint32_t *lace_size = NULL; int n, flags, laces = 0; uint64_t num; if ((n = matroska_ebmlnum_uint(matroska, data, size, &num)) < 0) { av_log(matroska->ctx, AV_LOG_ERROR, "EBML block data error\n"); return res; data += n; size -= n; track = matroska_find_track_by_num(matroska, num); if (size <= 3 || !track || !track->stream) { av_log(matroska->ctx, AV_LOG_INFO, "Invalid stream %"PRIu64" or size %u\n", num, size); return res; st = track->stream; if (st->discard >= AVDISCARD_ALL) return res; if (duration == AV_NOPTS_VALUE) duration = track->default_duration / matroska->time_scale; block_time = AV_RB16(data); data += 2; flags = *data++; size -= 3; if (is_keyframe == -1) is_keyframe = flags & 0x80 ? PKT_FLAG_KEY : 0; if (cluster_time != (uint64_t)-1 && (block_time >= 0 || cluster_time >= -block_time)) { timecode = cluster_time + block_time; if (track->type == MATROSKA_TRACK_TYPE_SUBTITLE && timecode < track->end_timecode) is_keyframe = 0; if (is_keyframe) av_add_index_entry(st, cluster_pos, timecode, 0,0,AVINDEX_KEYFRAME); track->end_timecode = FFMAX(track->end_timecode, timecode+duration); if (matroska->skip_to_keyframe && track->type != MATROSKA_TRACK_TYPE_SUBTITLE) { if (!is_keyframe || timecode < matroska->skip_to_timecode) return res; matroska->skip_to_keyframe = 0; switch ((flags & 0x06) >> 1) { case 0x0: laces = 1; lace_size = av_mallocz(sizeof(int)); lace_size[0] = size; case 0x1: case 0x2: case 0x3: assert(size>0); laces = (*data) + 1; data += 1; size -= 1; lace_size = av_mallocz(laces * sizeof(int)); switch ((flags & 0x06) >> 1) { case 0x1: { uint8_t temp; uint32_t total = 0; for (n = 0; res == 0 && n < laces - 1; n++) { while (1) { if (size == 0) { res = -1; temp = *data; lace_size[n] += temp; data += 1; size -= 1; if (temp != 0xff) total += lace_size[n]; lace_size[n] = size - total; case 0x2: for (n = 0; n < laces; n++) lace_size[n] = size / laces; case 0x3: { uint32_t total; n = matroska_ebmlnum_uint(matroska, data, size, &num); if (n < 0) { av_log(matroska->ctx, AV_LOG_INFO, "EBML block data error\n"); data += n; size -= n; total = lace_size[0] = num; for (n = 1; res == 0 && n < laces - 1; n++) { int64_t snum; int r; r = matroska_ebmlnum_sint(matroska, data, size, &snum); if (r < 0) { av_log(matroska->ctx, AV_LOG_INFO, "EBML block data error\n"); data += r; size -= r; lace_size[n] = lace_size[n - 1] + snum; total += lace_size[n]; lace_size[n] = size - total; if (res == 0) { for (n = 0; n < laces; n++) { if ((st->codec->codec_id == CODEC_ID_RA_288 || st->codec->codec_id == CODEC_ID_COOK || st->codec->codec_id == CODEC_ID_ATRAC3) && st->codec->block_align && track->audio.sub_packet_size) { int a = st->codec->block_align; int sps = track->audio.sub_packet_size; int cfs = track->audio.coded_framesize; int h = track->audio.sub_packet_h; int y = track->audio.sub_packet_cnt; int w = track->audio.frame_size; int x; if (!track->audio.pkt_cnt) { if (st->codec->codec_id == CODEC_ID_RA_288) for (x=0; x<h/2; x++) memcpy(track->audio.buf+x*2*w+y*cfs, data+x*cfs, cfs); else for (x=0; x<w/sps; x++) memcpy(track->audio.buf+sps*(h*x+((h+1)/2)*(y&1)+(y>>1)), data+x*sps, sps); if (++track->audio.sub_packet_cnt >= h) { track->audio.sub_packet_cnt = 0; track->audio.pkt_cnt = h*w / a; while (track->audio.pkt_cnt) { pkt = av_mallocz(sizeof(AVPacket)); av_new_packet(pkt, a); memcpy(pkt->data, track->audio.buf + a * (h*w / a - track->audio.pkt_cnt--), a); pkt->pos = pos; pkt->stream_index = st->index; dynarray_add(&matroska->packets,&matroska->num_packets,pkt); } else { MatroskaTrackEncoding *encodings = track->encodings.elem; int offset = 0, pkt_size = lace_size[n]; uint8_t *pkt_data = data; if (encodings && encodings->scope & 1) { offset = matroska_decode_buffer(&pkt_data,&pkt_size, track); if (offset < 0) continue; pkt = av_mallocz(sizeof(AVPacket)); if (av_new_packet(pkt, pkt_size+offset) < 0) { av_free(pkt); res = AVERROR(ENOMEM); if (offset) memcpy (pkt->data, encodings->compression.settings.data, offset); memcpy (pkt->data+offset, pkt_data, pkt_size); if (pkt_data != data) av_free(pkt_data); if (n == 0) pkt->flags = is_keyframe; pkt->stream_index = st->index; if (track->ms_compat) pkt->dts = timecode; else pkt->pts = timecode; pkt->pos = pos; if (st->codec->codec_id == CODEC_ID_TEXT) pkt->convergence_duration = duration; else if (track->type != MATROSKA_TRACK_TYPE_SUBTITLE) pkt->duration = duration; if (st->codec->codec_id == CODEC_ID_SSA) matroska_fix_ass_packet(matroska, pkt, duration); if (matroska->prev_pkt && timecode != AV_NOPTS_VALUE && matroska->prev_pkt->pts == timecode && matroska->prev_pkt->stream_index == st->index) matroska_merge_packets(matroska->prev_pkt, pkt); else { dynarray_add(&matroska->packets,&matroska->num_packets,pkt); matroska->prev_pkt = pkt; if (timecode != AV_NOPTS_VALUE) timecode = duration ? timecode + duration : AV_NOPTS_VALUE; data += lace_size[n]; size -= lace_size[n]; av_free(lace_size); return res;
{ "code": [], "line_no": [] }
static int FUNC_0(MatroskaDemuxContext *VAR_0, uint8_t *VAR_1, int VAR_2, int64_t VAR_3, uint64_t VAR_4, uint64_t VAR_5, int VAR_6, int64_t VAR_7) { uint64_t timecode = AV_NOPTS_VALUE; MatroskaTrack *track; int VAR_8 = 0; AVStream *st; AVPacket *pkt; int16_t block_time; uint32_t *lace_size = NULL; int VAR_9, VAR_10, VAR_11 = 0; uint64_t num; if ((VAR_9 = matroska_ebmlnum_uint(VAR_0, VAR_1, VAR_2, &num)) < 0) { av_log(VAR_0->ctx, AV_LOG_ERROR, "EBML block VAR_1 error\VAR_9"); return VAR_8; VAR_1 += VAR_9; VAR_2 -= VAR_9; track = matroska_find_track_by_num(VAR_0, num); if (VAR_2 <= 3 || !track || !track->stream) { av_log(VAR_0->ctx, AV_LOG_INFO, "Invalid stream %"PRIu64" or VAR_2 %u\VAR_9", num, VAR_2); return VAR_8; st = track->stream; if (st->discard >= AVDISCARD_ALL) return VAR_8; if (VAR_5 == AV_NOPTS_VALUE) VAR_5 = track->default_duration / VAR_0->time_scale; block_time = AV_RB16(VAR_1); VAR_1 += 2; VAR_10 = *VAR_1++; VAR_2 -= 3; if (VAR_6 == -1) VAR_6 = VAR_10 & 0x80 ? PKT_FLAG_KEY : 0; if (VAR_4 != (uint64_t)-1 && (block_time >= 0 || VAR_4 >= -block_time)) { timecode = VAR_4 + block_time; if (track->type == MATROSKA_TRACK_TYPE_SUBTITLE && timecode < track->end_timecode) VAR_6 = 0; if (VAR_6) av_add_index_entry(st, VAR_7, timecode, 0,0,AVINDEX_KEYFRAME); track->end_timecode = FFMAX(track->end_timecode, timecode+VAR_5); if (VAR_0->skip_to_keyframe && track->type != MATROSKA_TRACK_TYPE_SUBTITLE) { if (!VAR_6 || timecode < VAR_0->skip_to_timecode) return VAR_8; VAR_0->skip_to_keyframe = 0; switch ((VAR_10 & 0x06) >> 1) { case 0x0: VAR_11 = 1; lace_size = av_mallocz(sizeof(int)); lace_size[0] = VAR_2; case 0x1: case 0x2: case 0x3: assert(VAR_2>0); VAR_11 = (*VAR_1) + 1; VAR_1 += 1; VAR_2 -= 1; lace_size = av_mallocz(VAR_11 * sizeof(int)); switch ((VAR_10 & 0x06) >> 1) { case 0x1: { uint8_t temp; uint32_t total = 0; for (VAR_9 = 0; VAR_8 == 0 && VAR_9 < VAR_11 - 1; VAR_9++) { while (1) { if (VAR_2 == 0) { VAR_8 = -1; temp = *VAR_1; lace_size[VAR_9] += temp; VAR_1 += 1; VAR_2 -= 1; if (temp != 0xff) total += lace_size[VAR_9]; lace_size[VAR_9] = VAR_2 - total; case 0x2: for (VAR_9 = 0; VAR_9 < VAR_11; VAR_9++) lace_size[VAR_9] = VAR_2 / VAR_11; case 0x3: { uint32_t total; VAR_9 = matroska_ebmlnum_uint(VAR_0, VAR_1, VAR_2, &num); if (VAR_9 < 0) { av_log(VAR_0->ctx, AV_LOG_INFO, "EBML block VAR_1 error\VAR_9"); VAR_1 += VAR_9; VAR_2 -= VAR_9; total = lace_size[0] = num; for (VAR_9 = 1; VAR_8 == 0 && VAR_9 < VAR_11 - 1; VAR_9++) { int64_t snum; int VAR_12; VAR_12 = matroska_ebmlnum_sint(VAR_0, VAR_1, VAR_2, &snum); if (VAR_12 < 0) { av_log(VAR_0->ctx, AV_LOG_INFO, "EBML block VAR_1 error\VAR_9"); VAR_1 += VAR_12; VAR_2 -= VAR_12; lace_size[VAR_9] = lace_size[VAR_9 - 1] + snum; total += lace_size[VAR_9]; lace_size[VAR_9] = VAR_2 - total; if (VAR_8 == 0) { for (VAR_9 = 0; VAR_9 < VAR_11; VAR_9++) { if ((st->codec->codec_id == CODEC_ID_RA_288 || st->codec->codec_id == CODEC_ID_COOK || st->codec->codec_id == CODEC_ID_ATRAC3) && st->codec->block_align && track->audio.sub_packet_size) { int VAR_13 = st->codec->block_align; int VAR_14 = track->audio.sub_packet_size; int VAR_15 = track->audio.coded_framesize; int VAR_16 = track->audio.sub_packet_h; int VAR_17 = track->audio.sub_packet_cnt; int VAR_18 = track->audio.frame_size; int VAR_19; if (!track->audio.pkt_cnt) { if (st->codec->codec_id == CODEC_ID_RA_288) for (VAR_19=0; VAR_19<VAR_16/2; VAR_19++) memcpy(track->audio.buf+VAR_19*2*VAR_18+VAR_17*VAR_15, VAR_1+VAR_19*VAR_15, VAR_15); else for (VAR_19=0; VAR_19<VAR_18/VAR_14; VAR_19++) memcpy(track->audio.buf+VAR_14*(VAR_16*VAR_19+((VAR_16+1)/2)*(VAR_17&1)+(VAR_17>>1)), VAR_1+VAR_19*VAR_14, VAR_14); if (++track->audio.sub_packet_cnt >= VAR_16) { track->audio.sub_packet_cnt = 0; track->audio.pkt_cnt = VAR_16*VAR_18 / VAR_13; while (track->audio.pkt_cnt) { pkt = av_mallocz(sizeof(AVPacket)); av_new_packet(pkt, VAR_13); memcpy(pkt->VAR_1, track->audio.buf + VAR_13 * (VAR_16*VAR_18 / VAR_13 - track->audio.pkt_cnt--), VAR_13); pkt->VAR_3 = VAR_3; pkt->stream_index = st->index; dynarray_add(&VAR_0->packets,&VAR_0->num_packets,pkt); } else { MatroskaTrackEncoding *encodings = track->encodings.elem; int offset = 0, pkt_size = lace_size[VAR_9]; uint8_t *pkt_data = VAR_1; if (encodings && encodings->scope & 1) { offset = matroska_decode_buffer(&pkt_data,&pkt_size, track); if (offset < 0) continue; pkt = av_mallocz(sizeof(AVPacket)); if (av_new_packet(pkt, pkt_size+offset) < 0) { av_free(pkt); VAR_8 = AVERROR(ENOMEM); if (offset) memcpy (pkt->VAR_1, encodings->compression.settings.VAR_1, offset); memcpy (pkt->VAR_1+offset, pkt_data, pkt_size); if (pkt_data != VAR_1) av_free(pkt_data); if (VAR_9 == 0) pkt->VAR_10 = VAR_6; pkt->stream_index = st->index; if (track->ms_compat) pkt->dts = timecode; else pkt->pts = timecode; pkt->VAR_3 = VAR_3; if (st->codec->codec_id == CODEC_ID_TEXT) pkt->convergence_duration = VAR_5; else if (track->type != MATROSKA_TRACK_TYPE_SUBTITLE) pkt->VAR_5 = VAR_5; if (st->codec->codec_id == CODEC_ID_SSA) matroska_fix_ass_packet(VAR_0, pkt, VAR_5); if (VAR_0->prev_pkt && timecode != AV_NOPTS_VALUE && VAR_0->prev_pkt->pts == timecode && VAR_0->prev_pkt->stream_index == st->index) matroska_merge_packets(VAR_0->prev_pkt, pkt); else { dynarray_add(&VAR_0->packets,&VAR_0->num_packets,pkt); VAR_0->prev_pkt = pkt; if (timecode != AV_NOPTS_VALUE) timecode = VAR_5 ? timecode + VAR_5 : AV_NOPTS_VALUE; VAR_1 += lace_size[VAR_9]; VAR_2 -= lace_size[VAR_9]; av_free(lace_size); return VAR_8;
[ "static int FUNC_0(MatroskaDemuxContext *VAR_0, uint8_t *VAR_1,\nint VAR_2, int64_t VAR_3, uint64_t VAR_4,\nuint64_t VAR_5, int VAR_6,\nint64_t VAR_7)\n{", "uint64_t timecode = AV_NOPTS_VALUE;", "MatroskaTrack *track;", "int VAR_8 = 0;", "AVStream *st;", "AVPacket *pkt;", "int16_t block_time;", "uint32_t *lace_size = NULL;", "int VAR_9, VAR_10, VAR_11 = 0;", "uint64_t num;", "if ((VAR_9 = matroska_ebmlnum_uint(VAR_0, VAR_1, VAR_2, &num)) < 0) {", "av_log(VAR_0->ctx, AV_LOG_ERROR, \"EBML block VAR_1 error\\VAR_9\");", "return VAR_8;", "VAR_1 += VAR_9;", "VAR_2 -= VAR_9;", "track = matroska_find_track_by_num(VAR_0, num);", "if (VAR_2 <= 3 || !track || !track->stream) {", "av_log(VAR_0->ctx, AV_LOG_INFO,\n\"Invalid stream %\"PRIu64\" or VAR_2 %u\\VAR_9\", num, VAR_2);", "return VAR_8;", "st = track->stream;", "if (st->discard >= AVDISCARD_ALL)\nreturn VAR_8;", "if (VAR_5 == AV_NOPTS_VALUE)\nVAR_5 = track->default_duration / VAR_0->time_scale;", "block_time = AV_RB16(VAR_1);", "VAR_1 += 2;", "VAR_10 = *VAR_1++;", "VAR_2 -= 3;", "if (VAR_6 == -1)\nVAR_6 = VAR_10 & 0x80 ? PKT_FLAG_KEY : 0;", "if (VAR_4 != (uint64_t)-1\n&& (block_time >= 0 || VAR_4 >= -block_time)) {", "timecode = VAR_4 + block_time;", "if (track->type == MATROSKA_TRACK_TYPE_SUBTITLE\n&& timecode < track->end_timecode)\nVAR_6 = 0;", "if (VAR_6)\nav_add_index_entry(st, VAR_7, timecode, 0,0,AVINDEX_KEYFRAME);", "track->end_timecode = FFMAX(track->end_timecode, timecode+VAR_5);", "if (VAR_0->skip_to_keyframe && track->type != MATROSKA_TRACK_TYPE_SUBTITLE) {", "if (!VAR_6 || timecode < VAR_0->skip_to_timecode)\nreturn VAR_8;", "VAR_0->skip_to_keyframe = 0;", "switch ((VAR_10 & 0x06) >> 1) {", "case 0x0:\nVAR_11 = 1;", "lace_size = av_mallocz(sizeof(int));", "lace_size[0] = VAR_2;", "case 0x1:\ncase 0x2:\ncase 0x3:\nassert(VAR_2>0);", "VAR_11 = (*VAR_1) + 1;", "VAR_1 += 1;", "VAR_2 -= 1;", "lace_size = av_mallocz(VAR_11 * sizeof(int));", "switch ((VAR_10 & 0x06) >> 1) {", "case 0x1: {", "uint8_t temp;", "uint32_t total = 0;", "for (VAR_9 = 0; VAR_8 == 0 && VAR_9 < VAR_11 - 1; VAR_9++) {", "while (1) {", "if (VAR_2 == 0) {", "VAR_8 = -1;", "temp = *VAR_1;", "lace_size[VAR_9] += temp;", "VAR_1 += 1;", "VAR_2 -= 1;", "if (temp != 0xff)\ntotal += lace_size[VAR_9];", "lace_size[VAR_9] = VAR_2 - total;", "case 0x2:\nfor (VAR_9 = 0; VAR_9 < VAR_11; VAR_9++)", "lace_size[VAR_9] = VAR_2 / VAR_11;", "case 0x3: {", "uint32_t total;", "VAR_9 = matroska_ebmlnum_uint(VAR_0, VAR_1, VAR_2, &num);", "if (VAR_9 < 0) {", "av_log(VAR_0->ctx, AV_LOG_INFO,\n\"EBML block VAR_1 error\\VAR_9\");", "VAR_1 += VAR_9;", "VAR_2 -= VAR_9;", "total = lace_size[0] = num;", "for (VAR_9 = 1; VAR_8 == 0 && VAR_9 < VAR_11 - 1; VAR_9++) {", "int64_t snum;", "int VAR_12;", "VAR_12 = matroska_ebmlnum_sint(VAR_0, VAR_1, VAR_2, &snum);", "if (VAR_12 < 0) {", "av_log(VAR_0->ctx, AV_LOG_INFO,\n\"EBML block VAR_1 error\\VAR_9\");", "VAR_1 += VAR_12;", "VAR_2 -= VAR_12;", "lace_size[VAR_9] = lace_size[VAR_9 - 1] + snum;", "total += lace_size[VAR_9];", "lace_size[VAR_9] = VAR_2 - total;", "if (VAR_8 == 0) {", "for (VAR_9 = 0; VAR_9 < VAR_11; VAR_9++) {", "if ((st->codec->codec_id == CODEC_ID_RA_288 ||\nst->codec->codec_id == CODEC_ID_COOK ||\nst->codec->codec_id == CODEC_ID_ATRAC3) &&\nst->codec->block_align && track->audio.sub_packet_size) {", "int VAR_13 = st->codec->block_align;", "int VAR_14 = track->audio.sub_packet_size;", "int VAR_15 = track->audio.coded_framesize;", "int VAR_16 = track->audio.sub_packet_h;", "int VAR_17 = track->audio.sub_packet_cnt;", "int VAR_18 = track->audio.frame_size;", "int VAR_19;", "if (!track->audio.pkt_cnt) {", "if (st->codec->codec_id == CODEC_ID_RA_288)\nfor (VAR_19=0; VAR_19<VAR_16/2; VAR_19++)", "memcpy(track->audio.buf+VAR_19*2*VAR_18+VAR_17*VAR_15,\nVAR_1+VAR_19*VAR_15, VAR_15);", "else\nfor (VAR_19=0; VAR_19<VAR_18/VAR_14; VAR_19++)", "memcpy(track->audio.buf+VAR_14*(VAR_16*VAR_19+((VAR_16+1)/2)*(VAR_17&1)+(VAR_17>>1)), VAR_1+VAR_19*VAR_14, VAR_14);", "if (++track->audio.sub_packet_cnt >= VAR_16) {", "track->audio.sub_packet_cnt = 0;", "track->audio.pkt_cnt = VAR_16*VAR_18 / VAR_13;", "while (track->audio.pkt_cnt) {", "pkt = av_mallocz(sizeof(AVPacket));", "av_new_packet(pkt, VAR_13);", "memcpy(pkt->VAR_1, track->audio.buf\n+ VAR_13 * (VAR_16*VAR_18 / VAR_13 - track->audio.pkt_cnt--), VAR_13);", "pkt->VAR_3 = VAR_3;", "pkt->stream_index = st->index;", "dynarray_add(&VAR_0->packets,&VAR_0->num_packets,pkt);", "} else {", "MatroskaTrackEncoding *encodings = track->encodings.elem;", "int offset = 0, pkt_size = lace_size[VAR_9];", "uint8_t *pkt_data = VAR_1;", "if (encodings && encodings->scope & 1) {", "offset = matroska_decode_buffer(&pkt_data,&pkt_size, track);", "if (offset < 0)\ncontinue;", "pkt = av_mallocz(sizeof(AVPacket));", "if (av_new_packet(pkt, pkt_size+offset) < 0) {", "av_free(pkt);", "VAR_8 = AVERROR(ENOMEM);", "if (offset)\nmemcpy (pkt->VAR_1, encodings->compression.settings.VAR_1, offset);", "memcpy (pkt->VAR_1+offset, pkt_data, pkt_size);", "if (pkt_data != VAR_1)\nav_free(pkt_data);", "if (VAR_9 == 0)\npkt->VAR_10 = VAR_6;", "pkt->stream_index = st->index;", "if (track->ms_compat)\npkt->dts = timecode;", "else\npkt->pts = timecode;", "pkt->VAR_3 = VAR_3;", "if (st->codec->codec_id == CODEC_ID_TEXT)\npkt->convergence_duration = VAR_5;", "else if (track->type != MATROSKA_TRACK_TYPE_SUBTITLE)\npkt->VAR_5 = VAR_5;", "if (st->codec->codec_id == CODEC_ID_SSA)\nmatroska_fix_ass_packet(VAR_0, pkt, VAR_5);", "if (VAR_0->prev_pkt &&\ntimecode != AV_NOPTS_VALUE &&\nVAR_0->prev_pkt->pts == timecode &&\nVAR_0->prev_pkt->stream_index == st->index)\nmatroska_merge_packets(VAR_0->prev_pkt, pkt);", "else {", "dynarray_add(&VAR_0->packets,&VAR_0->num_packets,pkt);", "VAR_0->prev_pkt = pkt;", "if (timecode != AV_NOPTS_VALUE)\ntimecode = VAR_5 ? timecode + VAR_5 : AV_NOPTS_VALUE;", "VAR_1 += lace_size[VAR_9];", "VAR_2 -= lace_size[VAR_9];", "av_free(lace_size);", "return 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 ]
[ [ 1, 2, 3, 4, 5 ], [ 6 ], [ 7 ], [ 8 ], [ 9 ], [ 10 ], [ 11 ], [ 12 ], [ 13 ], [ 14 ], [ 15 ], [ 16 ], [ 17 ], [ 18 ], [ 19 ], [ 20 ], [ 21 ], [ 22, 23 ], [ 24 ], [ 25 ], [ 26, 27 ], [ 28, 29 ], [ 30 ], [ 31 ], [ 32 ], [ 33 ], [ 34, 35 ], [ 36, 37 ], [ 38 ], [ 39, 40, 41 ], [ 42, 43 ], [ 44 ], [ 45 ], [ 46, 47 ], [ 48 ], [ 49 ], [ 50, 51 ], [ 52 ], [ 53 ], [ 54, 55, 56, 57 ], [ 58 ], [ 59 ], [ 60 ], [ 61 ], [ 62 ], [ 63 ], [ 64 ], [ 65 ], [ 66 ], [ 67 ], [ 68 ], [ 69 ], [ 70 ], [ 71 ], [ 72 ], [ 73 ], [ 74, 75 ], [ 76 ], [ 77, 78 ], [ 79 ], [ 80 ], [ 81 ], [ 82 ], [ 83 ], [ 84, 85 ], [ 86 ], [ 87 ], [ 88 ], [ 89 ], [ 90 ], [ 91 ], [ 92 ], [ 93 ], [ 94, 95 ], [ 96 ], [ 97 ], [ 98 ], [ 99 ], [ 100 ], [ 101 ], [ 102 ], [ 103, 104, 105, 106 ], [ 107 ], [ 108 ], [ 109 ], [ 110 ], [ 111 ], [ 112 ], [ 113 ], [ 114 ], [ 115, 116 ], [ 117, 118 ], [ 119, 120 ], [ 121 ], [ 122 ], [ 123 ], [ 124 ], [ 125 ], [ 126 ], [ 127 ], [ 128, 129 ], [ 130 ], [ 131 ], [ 132 ], [ 133 ], [ 134 ], [ 135 ], [ 136 ], [ 137 ], [ 138 ], [ 139, 140 ], [ 141 ], [ 143 ], [ 144 ], [ 145 ], [ 146, 147 ], [ 148 ], [ 149, 150 ], [ 151, 152 ], [ 153 ], [ 154, 155 ], [ 156, 157 ], [ 158 ], [ 159, 160 ], [ 161, 162 ], [ 163, 164 ], [ 165, 166, 167, 168, 169 ], [ 170 ], [ 171 ], [ 172 ], [ 173, 174 ], [ 175 ], [ 176 ], [ 177 ], [ 178 ] ]
9,923
void tcg_optimize(TCGContext *s) { int oi, oi_next, nb_temps, nb_globals; TCGOp *prev_mb = NULL; struct tcg_temp_info *infos; TCGTempSet temps_used; /* Array VALS has an element for each temp. If this temp holds a constant then its value is kept in VALS' element. If this temp is a copy of other ones then the other copies are available through the doubly linked circular list. */ nb_temps = s->nb_temps; nb_globals = s->nb_globals; bitmap_zero(temps_used.l, nb_temps); infos = tcg_malloc(sizeof(struct tcg_temp_info) * nb_temps); for (oi = s->gen_op_buf[0].next; oi != 0; oi = oi_next) { tcg_target_ulong mask, partmask, affected; int nb_oargs, nb_iargs, i; TCGArg tmp; TCGOp * const op = &s->gen_op_buf[oi]; TCGOpcode opc = op->opc; const TCGOpDef *def = &tcg_op_defs[opc]; oi_next = op->next; /* Count the arguments, and initialize the temps that are going to be used */ if (opc == INDEX_op_call) { nb_oargs = op->callo; nb_iargs = op->calli; for (i = 0; i < nb_oargs + nb_iargs; i++) { TCGTemp *ts = arg_temp(op->args[i]); if (ts) { init_ts_info(infos, &temps_used, ts); } } } else { nb_oargs = def->nb_oargs; nb_iargs = def->nb_iargs; for (i = 0; i < nb_oargs + nb_iargs; i++) { init_arg_info(infos, &temps_used, op->args[i]); } } /* Do copy propagation */ for (i = nb_oargs; i < nb_oargs + nb_iargs; i++) { TCGTemp *ts = arg_temp(op->args[i]); if (ts && ts_is_copy(ts)) { op->args[i] = temp_arg(find_better_copy(s, ts)); } } /* For commutative operations make constant second argument */ switch (opc) { CASE_OP_32_64(add): CASE_OP_32_64(mul): CASE_OP_32_64(and): CASE_OP_32_64(or): CASE_OP_32_64(xor): CASE_OP_32_64(eqv): CASE_OP_32_64(nand): CASE_OP_32_64(nor): CASE_OP_32_64(muluh): CASE_OP_32_64(mulsh): swap_commutative(op->args[0], &op->args[1], &op->args[2]); break; CASE_OP_32_64(brcond): if (swap_commutative(-1, &op->args[0], &op->args[1])) { op->args[2] = tcg_swap_cond(op->args[2]); } break; CASE_OP_32_64(setcond): if (swap_commutative(op->args[0], &op->args[1], &op->args[2])) { op->args[3] = tcg_swap_cond(op->args[3]); } break; CASE_OP_32_64(movcond): if (swap_commutative(-1, &op->args[1], &op->args[2])) { op->args[5] = tcg_swap_cond(op->args[5]); } /* For movcond, we canonicalize the "false" input reg to match the destination reg so that the tcg backend can implement a "move if true" operation. */ if (swap_commutative(op->args[0], &op->args[4], &op->args[3])) { op->args[5] = tcg_invert_cond(op->args[5]); } break; CASE_OP_32_64(add2): swap_commutative(op->args[0], &op->args[2], &op->args[4]); swap_commutative(op->args[1], &op->args[3], &op->args[5]); break; CASE_OP_32_64(mulu2): CASE_OP_32_64(muls2): swap_commutative(op->args[0], &op->args[2], &op->args[3]); break; case INDEX_op_brcond2_i32: if (swap_commutative2(&op->args[0], &op->args[2])) { op->args[4] = tcg_swap_cond(op->args[4]); } break; case INDEX_op_setcond2_i32: if (swap_commutative2(&op->args[1], &op->args[3])) { op->args[5] = tcg_swap_cond(op->args[5]); } break; default: break; } /* Simplify expressions for "shift/rot r, 0, a => movi r, 0", and "sub r, 0, a => neg r, a" case. */ switch (opc) { CASE_OP_32_64(shl): CASE_OP_32_64(shr): CASE_OP_32_64(sar): CASE_OP_32_64(rotl): CASE_OP_32_64(rotr): if (arg_is_const(op->args[1]) && arg_info(op->args[1])->val == 0) { tcg_opt_gen_movi(s, op, op->args[0], 0); continue; } break; CASE_OP_32_64(sub): { TCGOpcode neg_op; bool have_neg; if (arg_is_const(op->args[2])) { /* Proceed with possible constant folding. */ break; } if (opc == INDEX_op_sub_i32) { neg_op = INDEX_op_neg_i32; have_neg = TCG_TARGET_HAS_neg_i32; } else { neg_op = INDEX_op_neg_i64; have_neg = TCG_TARGET_HAS_neg_i64; } if (!have_neg) { break; } if (arg_is_const(op->args[1]) && arg_info(op->args[1])->val == 0) { op->opc = neg_op; reset_temp(op->args[0]); op->args[1] = op->args[2]; continue; } } break; CASE_OP_32_64(xor): CASE_OP_32_64(nand): if (!arg_is_const(op->args[1]) && arg_is_const(op->args[2]) && arg_info(op->args[2])->val == -1) { i = 1; goto try_not; } break; CASE_OP_32_64(nor): if (!arg_is_const(op->args[1]) && arg_is_const(op->args[2]) && arg_info(op->args[2])->val == 0) { i = 1; goto try_not; } break; CASE_OP_32_64(andc): if (!arg_is_const(op->args[2]) && arg_is_const(op->args[1]) && arg_info(op->args[1])->val == -1) { i = 2; goto try_not; } break; CASE_OP_32_64(orc): CASE_OP_32_64(eqv): if (!arg_is_const(op->args[2]) && arg_is_const(op->args[1]) && arg_info(op->args[1])->val == 0) { i = 2; goto try_not; } break; try_not: { TCGOpcode not_op; bool have_not; if (def->flags & TCG_OPF_64BIT) { not_op = INDEX_op_not_i64; have_not = TCG_TARGET_HAS_not_i64; } else { not_op = INDEX_op_not_i32; have_not = TCG_TARGET_HAS_not_i32; } if (!have_not) { break; } op->opc = not_op; reset_temp(op->args[0]); op->args[1] = op->args[i]; continue; } default: break; } /* Simplify expression for "op r, a, const => mov r, a" cases */ switch (opc) { CASE_OP_32_64(add): CASE_OP_32_64(sub): CASE_OP_32_64(shl): CASE_OP_32_64(shr): CASE_OP_32_64(sar): CASE_OP_32_64(rotl): CASE_OP_32_64(rotr): CASE_OP_32_64(or): CASE_OP_32_64(xor): CASE_OP_32_64(andc): if (!arg_is_const(op->args[1]) && arg_is_const(op->args[2]) && arg_info(op->args[2])->val == 0) { tcg_opt_gen_mov(s, op, op->args[0], op->args[1]); continue; } break; CASE_OP_32_64(and): CASE_OP_32_64(orc): CASE_OP_32_64(eqv): if (!arg_is_const(op->args[1]) && arg_is_const(op->args[2]) && arg_info(op->args[2])->val == -1) { tcg_opt_gen_mov(s, op, op->args[0], op->args[1]); continue; } break; default: break; } /* Simplify using known-zero bits. Currently only ops with a single output argument is supported. */ mask = -1; affected = -1; switch (opc) { CASE_OP_32_64(ext8s): if ((arg_info(op->args[1])->mask & 0x80) != 0) { break; } CASE_OP_32_64(ext8u): mask = 0xff; goto and_const; CASE_OP_32_64(ext16s): if ((arg_info(op->args[1])->mask & 0x8000) != 0) { break; } CASE_OP_32_64(ext16u): mask = 0xffff; goto and_const; case INDEX_op_ext32s_i64: if ((arg_info(op->args[1])->mask & 0x80000000) != 0) { break; } case INDEX_op_ext32u_i64: mask = 0xffffffffU; goto and_const; CASE_OP_32_64(and): mask = arg_info(op->args[2])->mask; if (arg_is_const(op->args[2])) { and_const: affected = arg_info(op->args[1])->mask & ~mask; } mask = arg_info(op->args[1])->mask & mask; break; case INDEX_op_ext_i32_i64: if ((arg_info(op->args[1])->mask & 0x80000000) != 0) { break; } case INDEX_op_extu_i32_i64: /* We do not compute affected as it is a size changing op. */ mask = (uint32_t)arg_info(op->args[1])->mask; break; CASE_OP_32_64(andc): /* Known-zeros does not imply known-ones. Therefore unless op->args[2] is constant, we can't infer anything from it. */ if (arg_is_const(op->args[2])) { mask = ~arg_info(op->args[2])->mask; goto and_const; } /* But we certainly know nothing outside args[1] may be set. */ mask = arg_info(op->args[1])->mask; break; case INDEX_op_sar_i32: if (arg_is_const(op->args[2])) { tmp = arg_info(op->args[2])->val & 31; mask = (int32_t)arg_info(op->args[1])->mask >> tmp; } break; case INDEX_op_sar_i64: if (arg_is_const(op->args[2])) { tmp = arg_info(op->args[2])->val & 63; mask = (int64_t)arg_info(op->args[1])->mask >> tmp; } break; case INDEX_op_shr_i32: if (arg_is_const(op->args[2])) { tmp = arg_info(op->args[2])->val & 31; mask = (uint32_t)arg_info(op->args[1])->mask >> tmp; } break; case INDEX_op_shr_i64: if (arg_is_const(op->args[2])) { tmp = arg_info(op->args[2])->val & 63; mask = (uint64_t)arg_info(op->args[1])->mask >> tmp; } break; case INDEX_op_extrl_i64_i32: mask = (uint32_t)arg_info(op->args[1])->mask; break; case INDEX_op_extrh_i64_i32: mask = (uint64_t)arg_info(op->args[1])->mask >> 32; break; CASE_OP_32_64(shl): if (arg_is_const(op->args[2])) { tmp = arg_info(op->args[2])->val & (TCG_TARGET_REG_BITS - 1); mask = arg_info(op->args[1])->mask << tmp; } break; CASE_OP_32_64(neg): /* Set to 1 all bits to the left of the rightmost. */ mask = -(arg_info(op->args[1])->mask & -arg_info(op->args[1])->mask); break; CASE_OP_32_64(deposit): mask = deposit64(arg_info(op->args[1])->mask, op->args[3], op->args[4], arg_info(op->args[2])->mask); break; CASE_OP_32_64(extract): mask = extract64(arg_info(op->args[1])->mask, op->args[2], op->args[3]); if (op->args[2] == 0) { affected = arg_info(op->args[1])->mask & ~mask; } break; CASE_OP_32_64(sextract): mask = sextract64(arg_info(op->args[1])->mask, op->args[2], op->args[3]); if (op->args[2] == 0 && (tcg_target_long)mask >= 0) { affected = arg_info(op->args[1])->mask & ~mask; } break; CASE_OP_32_64(or): CASE_OP_32_64(xor): mask = arg_info(op->args[1])->mask | arg_info(op->args[2])->mask; break; case INDEX_op_clz_i32: case INDEX_op_ctz_i32: mask = arg_info(op->args[2])->mask | 31; break; case INDEX_op_clz_i64: case INDEX_op_ctz_i64: mask = arg_info(op->args[2])->mask | 63; break; case INDEX_op_ctpop_i32: mask = 32 | 31; break; case INDEX_op_ctpop_i64: mask = 64 | 63; break; CASE_OP_32_64(setcond): case INDEX_op_setcond2_i32: mask = 1; break; CASE_OP_32_64(movcond): mask = arg_info(op->args[3])->mask | arg_info(op->args[4])->mask; break; CASE_OP_32_64(ld8u): mask = 0xff; break; CASE_OP_32_64(ld16u): mask = 0xffff; break; case INDEX_op_ld32u_i64: mask = 0xffffffffu; break; CASE_OP_32_64(qemu_ld): { TCGMemOpIdx oi = op->args[nb_oargs + nb_iargs]; TCGMemOp mop = get_memop(oi); if (!(mop & MO_SIGN)) { mask = (2ULL << ((8 << (mop & MO_SIZE)) - 1)) - 1; } } break; default: break; } /* 32-bit ops generate 32-bit results. For the result is zero test below, we can ignore high bits, but for further optimizations we need to record that the high bits contain garbage. */ partmask = mask; if (!(def->flags & TCG_OPF_64BIT)) { mask |= ~(tcg_target_ulong)0xffffffffu; partmask &= 0xffffffffu; affected &= 0xffffffffu; } if (partmask == 0) { tcg_debug_assert(nb_oargs == 1); tcg_opt_gen_movi(s, op, op->args[0], 0); continue; } if (affected == 0) { tcg_debug_assert(nb_oargs == 1); tcg_opt_gen_mov(s, op, op->args[0], op->args[1]); continue; } /* Simplify expression for "op r, a, 0 => movi r, 0" cases */ switch (opc) { CASE_OP_32_64(and): CASE_OP_32_64(mul): CASE_OP_32_64(muluh): CASE_OP_32_64(mulsh): if (arg_is_const(op->args[2]) && arg_info(op->args[2])->val == 0) { tcg_opt_gen_movi(s, op, op->args[0], 0); continue; } break; default: break; } /* Simplify expression for "op r, a, a => mov r, a" cases */ switch (opc) { CASE_OP_32_64(or): CASE_OP_32_64(and): if (args_are_copies(op->args[1], op->args[2])) { tcg_opt_gen_mov(s, op, op->args[0], op->args[1]); continue; } break; default: break; } /* Simplify expression for "op r, a, a => movi r, 0" cases */ switch (opc) { CASE_OP_32_64(andc): CASE_OP_32_64(sub): CASE_OP_32_64(xor): if (args_are_copies(op->args[1], op->args[2])) { tcg_opt_gen_movi(s, op, op->args[0], 0); continue; } break; default: break; } /* Propagate constants through copy operations and do constant folding. Constants will be substituted to arguments by register allocator where needed and possible. Also detect copies. */ switch (opc) { CASE_OP_32_64(mov): tcg_opt_gen_mov(s, op, op->args[0], op->args[1]); break; CASE_OP_32_64(movi): tcg_opt_gen_movi(s, op, op->args[0], op->args[1]); break; CASE_OP_32_64(not): CASE_OP_32_64(neg): CASE_OP_32_64(ext8s): CASE_OP_32_64(ext8u): CASE_OP_32_64(ext16s): CASE_OP_32_64(ext16u): CASE_OP_32_64(ctpop): case INDEX_op_ext32s_i64: case INDEX_op_ext32u_i64: case INDEX_op_ext_i32_i64: case INDEX_op_extu_i32_i64: case INDEX_op_extrl_i64_i32: case INDEX_op_extrh_i64_i32: if (arg_is_const(op->args[1])) { tmp = do_constant_folding(opc, arg_info(op->args[1])->val, 0); tcg_opt_gen_movi(s, op, op->args[0], tmp); break; } goto do_default; CASE_OP_32_64(add): CASE_OP_32_64(sub): CASE_OP_32_64(mul): CASE_OP_32_64(or): CASE_OP_32_64(and): CASE_OP_32_64(xor): CASE_OP_32_64(shl): CASE_OP_32_64(shr): CASE_OP_32_64(sar): CASE_OP_32_64(rotl): CASE_OP_32_64(rotr): CASE_OP_32_64(andc): CASE_OP_32_64(orc): CASE_OP_32_64(eqv): CASE_OP_32_64(nand): CASE_OP_32_64(nor): CASE_OP_32_64(muluh): CASE_OP_32_64(mulsh): CASE_OP_32_64(div): CASE_OP_32_64(divu): CASE_OP_32_64(rem): CASE_OP_32_64(remu): if (arg_is_const(op->args[1]) && arg_is_const(op->args[2])) { tmp = do_constant_folding(opc, arg_info(op->args[1])->val, arg_info(op->args[2])->val); tcg_opt_gen_movi(s, op, op->args[0], tmp); break; } goto do_default; CASE_OP_32_64(clz): CASE_OP_32_64(ctz): if (arg_is_const(op->args[1])) { TCGArg v = arg_info(op->args[1])->val; if (v != 0) { tmp = do_constant_folding(opc, v, 0); tcg_opt_gen_movi(s, op, op->args[0], tmp); } else { tcg_opt_gen_mov(s, op, op->args[0], op->args[2]); } break; } goto do_default; CASE_OP_32_64(deposit): if (arg_is_const(op->args[1]) && arg_is_const(op->args[2])) { tmp = deposit64(arg_info(op->args[1])->val, op->args[3], op->args[4], arg_info(op->args[2])->val); tcg_opt_gen_movi(s, op, op->args[0], tmp); break; } goto do_default; CASE_OP_32_64(extract): if (arg_is_const(op->args[1])) { tmp = extract64(arg_info(op->args[1])->val, op->args[2], op->args[3]); tcg_opt_gen_movi(s, op, op->args[0], tmp); break; } goto do_default; CASE_OP_32_64(sextract): if (arg_is_const(op->args[1])) { tmp = sextract64(arg_info(op->args[1])->val, op->args[2], op->args[3]); tcg_opt_gen_movi(s, op, op->args[0], tmp); break; } goto do_default; CASE_OP_32_64(setcond): tmp = do_constant_folding_cond(opc, op->args[1], op->args[2], op->args[3]); if (tmp != 2) { tcg_opt_gen_movi(s, op, op->args[0], tmp); break; } goto do_default; CASE_OP_32_64(brcond): tmp = do_constant_folding_cond(opc, op->args[0], op->args[1], op->args[2]); if (tmp != 2) { if (tmp) { bitmap_zero(temps_used.l, nb_temps); op->opc = INDEX_op_br; op->args[0] = op->args[3]; } else { tcg_op_remove(s, op); } break; } goto do_default; CASE_OP_32_64(movcond): tmp = do_constant_folding_cond(opc, op->args[1], op->args[2], op->args[5]); if (tmp != 2) { tcg_opt_gen_mov(s, op, op->args[0], op->args[4-tmp]); break; } if (arg_is_const(op->args[3]) && arg_is_const(op->args[4])) { tcg_target_ulong tv = arg_info(op->args[3])->val; tcg_target_ulong fv = arg_info(op->args[4])->val; TCGCond cond = op->args[5]; if (fv == 1 && tv == 0) { cond = tcg_invert_cond(cond); } else if (!(tv == 1 && fv == 0)) { goto do_default; } op->args[3] = cond; op->opc = opc = (opc == INDEX_op_movcond_i32 ? INDEX_op_setcond_i32 : INDEX_op_setcond_i64); nb_iargs = 2; } goto do_default; case INDEX_op_add2_i32: case INDEX_op_sub2_i32: if (arg_is_const(op->args[2]) && arg_is_const(op->args[3]) && arg_is_const(op->args[4]) && arg_is_const(op->args[5])) { uint32_t al = arg_info(op->args[2])->val; uint32_t ah = arg_info(op->args[3])->val; uint32_t bl = arg_info(op->args[4])->val; uint32_t bh = arg_info(op->args[5])->val; uint64_t a = ((uint64_t)ah << 32) | al; uint64_t b = ((uint64_t)bh << 32) | bl; TCGArg rl, rh; TCGOp *op2 = tcg_op_insert_before(s, op, INDEX_op_movi_i32, 2); if (opc == INDEX_op_add2_i32) { a += b; } else { a -= b; } rl = op->args[0]; rh = op->args[1]; tcg_opt_gen_movi(s, op, rl, (int32_t)a); tcg_opt_gen_movi(s, op2, rh, (int32_t)(a >> 32)); /* We've done all we need to do with the movi. Skip it. */ oi_next = op2->next; break; } goto do_default; case INDEX_op_mulu2_i32: if (arg_is_const(op->args[2]) && arg_is_const(op->args[3])) { uint32_t a = arg_info(op->args[2])->val; uint32_t b = arg_info(op->args[3])->val; uint64_t r = (uint64_t)a * b; TCGArg rl, rh; TCGOp *op2 = tcg_op_insert_before(s, op, INDEX_op_movi_i32, 2); rl = op->args[0]; rh = op->args[1]; tcg_opt_gen_movi(s, op, rl, (int32_t)r); tcg_opt_gen_movi(s, op2, rh, (int32_t)(r >> 32)); /* We've done all we need to do with the movi. Skip it. */ oi_next = op2->next; break; } goto do_default; case INDEX_op_brcond2_i32: tmp = do_constant_folding_cond2(&op->args[0], &op->args[2], op->args[4]); if (tmp != 2) { if (tmp) { do_brcond_true: bitmap_zero(temps_used.l, nb_temps); op->opc = INDEX_op_br; op->args[0] = op->args[5]; } else { do_brcond_false: tcg_op_remove(s, op); } } else if ((op->args[4] == TCG_COND_LT || op->args[4] == TCG_COND_GE) && arg_is_const(op->args[2]) && arg_info(op->args[2])->val == 0 && arg_is_const(op->args[3]) && arg_info(op->args[3])->val == 0) { /* Simplify LT/GE comparisons vs zero to a single compare vs the high word of the input. */ do_brcond_high: bitmap_zero(temps_used.l, nb_temps); op->opc = INDEX_op_brcond_i32; op->args[0] = op->args[1]; op->args[1] = op->args[3]; op->args[2] = op->args[4]; op->args[3] = op->args[5]; } else if (op->args[4] == TCG_COND_EQ) { /* Simplify EQ comparisons where one of the pairs can be simplified. */ tmp = do_constant_folding_cond(INDEX_op_brcond_i32, op->args[0], op->args[2], TCG_COND_EQ); if (tmp == 0) { goto do_brcond_false; } else if (tmp == 1) { goto do_brcond_high; } tmp = do_constant_folding_cond(INDEX_op_brcond_i32, op->args[1], op->args[3], TCG_COND_EQ); if (tmp == 0) { goto do_brcond_false; } else if (tmp != 1) { goto do_default; } do_brcond_low: bitmap_zero(temps_used.l, nb_temps); op->opc = INDEX_op_brcond_i32; op->args[1] = op->args[2]; op->args[2] = op->args[4]; op->args[3] = op->args[5]; } else if (op->args[4] == TCG_COND_NE) { /* Simplify NE comparisons where one of the pairs can be simplified. */ tmp = do_constant_folding_cond(INDEX_op_brcond_i32, op->args[0], op->args[2], TCG_COND_NE); if (tmp == 0) { goto do_brcond_high; } else if (tmp == 1) { goto do_brcond_true; } tmp = do_constant_folding_cond(INDEX_op_brcond_i32, op->args[1], op->args[3], TCG_COND_NE); if (tmp == 0) { goto do_brcond_low; } else if (tmp == 1) { goto do_brcond_true; } goto do_default; } else { goto do_default; } break; case INDEX_op_setcond2_i32: tmp = do_constant_folding_cond2(&op->args[1], &op->args[3], op->args[5]); if (tmp != 2) { do_setcond_const: tcg_opt_gen_movi(s, op, op->args[0], tmp); } else if ((op->args[5] == TCG_COND_LT || op->args[5] == TCG_COND_GE) && arg_is_const(op->args[3]) && arg_info(op->args[3])->val == 0 && arg_is_const(op->args[4]) && arg_info(op->args[4])->val == 0) { /* Simplify LT/GE comparisons vs zero to a single compare vs the high word of the input. */ do_setcond_high: reset_temp(op->args[0]); arg_info(op->args[0])->mask = 1; op->opc = INDEX_op_setcond_i32; op->args[1] = op->args[2]; op->args[2] = op->args[4]; op->args[3] = op->args[5]; } else if (op->args[5] == TCG_COND_EQ) { /* Simplify EQ comparisons where one of the pairs can be simplified. */ tmp = do_constant_folding_cond(INDEX_op_setcond_i32, op->args[1], op->args[3], TCG_COND_EQ); if (tmp == 0) { goto do_setcond_const; } else if (tmp == 1) { goto do_setcond_high; } tmp = do_constant_folding_cond(INDEX_op_setcond_i32, op->args[2], op->args[4], TCG_COND_EQ); if (tmp == 0) { goto do_setcond_high; } else if (tmp != 1) { goto do_default; } do_setcond_low: reset_temp(op->args[0]); arg_info(op->args[0])->mask = 1; op->opc = INDEX_op_setcond_i32; op->args[2] = op->args[3]; op->args[3] = op->args[5]; } else if (op->args[5] == TCG_COND_NE) { /* Simplify NE comparisons where one of the pairs can be simplified. */ tmp = do_constant_folding_cond(INDEX_op_setcond_i32, op->args[1], op->args[3], TCG_COND_NE); if (tmp == 0) { goto do_setcond_high; } else if (tmp == 1) { goto do_setcond_const; } tmp = do_constant_folding_cond(INDEX_op_setcond_i32, op->args[2], op->args[4], TCG_COND_NE); if (tmp == 0) { goto do_setcond_low; } else if (tmp == 1) { goto do_setcond_const; } goto do_default; } else { goto do_default; } break; case INDEX_op_call: if (!(op->args[nb_oargs + nb_iargs + 1] & (TCG_CALL_NO_READ_GLOBALS | TCG_CALL_NO_WRITE_GLOBALS))) { for (i = 0; i < nb_globals; i++) { if (test_bit(i, temps_used.l)) { reset_ts(&s->temps[i]); } } } goto do_reset_output; default: do_default: /* Default case: we know nothing about operation (or were unable to compute the operation result) so no propagation is done. We trash everything if the operation is the end of a basic block, otherwise we only trash the output args. "mask" is the non-zero bits mask for the first output arg. */ if (def->flags & TCG_OPF_BB_END) { bitmap_zero(temps_used.l, nb_temps); } else { do_reset_output: for (i = 0; i < nb_oargs; i++) { reset_temp(op->args[i]); /* Save the corresponding known-zero bits mask for the first output argument (only one supported so far). */ if (i == 0) { arg_info(op->args[i])->mask = mask; } } } break; } /* Eliminate duplicate and redundant fence instructions. */ if (prev_mb) { switch (opc) { case INDEX_op_mb: /* Merge two barriers of the same type into one, * or a weaker barrier into a stronger one, * or two weaker barriers into a stronger one. * mb X; mb Y => mb X|Y * mb; strl => mb; st * ldaq; mb => ld; mb * ldaq; strl => ld; mb; st * Other combinations are also merged into a strong * barrier. This is stricter than specified but for * the purposes of TCG is better than not optimizing. */ prev_mb->args[0] |= op->args[0]; tcg_op_remove(s, op); break; default: /* Opcodes that end the block stop the optimization. */ if ((def->flags & TCG_OPF_BB_END) == 0) { break; } /* fallthru */ case INDEX_op_qemu_ld_i32: case INDEX_op_qemu_ld_i64: case INDEX_op_qemu_st_i32: case INDEX_op_qemu_st_i64: case INDEX_op_call: /* Opcodes that touch guest memory stop the optimization. */ prev_mb = NULL; break; } } else if (opc == INDEX_op_mb) { prev_mb = op; } } }
true
qemu
15fa08f8451babc88d733bd411d4c94976f9d0f8
void tcg_optimize(TCGContext *s) { int oi, oi_next, nb_temps, nb_globals; TCGOp *prev_mb = NULL; struct tcg_temp_info *infos; TCGTempSet temps_used; nb_temps = s->nb_temps; nb_globals = s->nb_globals; bitmap_zero(temps_used.l, nb_temps); infos = tcg_malloc(sizeof(struct tcg_temp_info) * nb_temps); for (oi = s->gen_op_buf[0].next; oi != 0; oi = oi_next) { tcg_target_ulong mask, partmask, affected; int nb_oargs, nb_iargs, i; TCGArg tmp; TCGOp * const op = &s->gen_op_buf[oi]; TCGOpcode opc = op->opc; const TCGOpDef *def = &tcg_op_defs[opc]; oi_next = op->next; if (opc == INDEX_op_call) { nb_oargs = op->callo; nb_iargs = op->calli; for (i = 0; i < nb_oargs + nb_iargs; i++) { TCGTemp *ts = arg_temp(op->args[i]); if (ts) { init_ts_info(infos, &temps_used, ts); } } } else { nb_oargs = def->nb_oargs; nb_iargs = def->nb_iargs; for (i = 0; i < nb_oargs + nb_iargs; i++) { init_arg_info(infos, &temps_used, op->args[i]); } } for (i = nb_oargs; i < nb_oargs + nb_iargs; i++) { TCGTemp *ts = arg_temp(op->args[i]); if (ts && ts_is_copy(ts)) { op->args[i] = temp_arg(find_better_copy(s, ts)); } } switch (opc) { CASE_OP_32_64(add): CASE_OP_32_64(mul): CASE_OP_32_64(and): CASE_OP_32_64(or): CASE_OP_32_64(xor): CASE_OP_32_64(eqv): CASE_OP_32_64(nand): CASE_OP_32_64(nor): CASE_OP_32_64(muluh): CASE_OP_32_64(mulsh): swap_commutative(op->args[0], &op->args[1], &op->args[2]); break; CASE_OP_32_64(brcond): if (swap_commutative(-1, &op->args[0], &op->args[1])) { op->args[2] = tcg_swap_cond(op->args[2]); } break; CASE_OP_32_64(setcond): if (swap_commutative(op->args[0], &op->args[1], &op->args[2])) { op->args[3] = tcg_swap_cond(op->args[3]); } break; CASE_OP_32_64(movcond): if (swap_commutative(-1, &op->args[1], &op->args[2])) { op->args[5] = tcg_swap_cond(op->args[5]); } if (swap_commutative(op->args[0], &op->args[4], &op->args[3])) { op->args[5] = tcg_invert_cond(op->args[5]); } break; CASE_OP_32_64(add2): swap_commutative(op->args[0], &op->args[2], &op->args[4]); swap_commutative(op->args[1], &op->args[3], &op->args[5]); break; CASE_OP_32_64(mulu2): CASE_OP_32_64(muls2): swap_commutative(op->args[0], &op->args[2], &op->args[3]); break; case INDEX_op_brcond2_i32: if (swap_commutative2(&op->args[0], &op->args[2])) { op->args[4] = tcg_swap_cond(op->args[4]); } break; case INDEX_op_setcond2_i32: if (swap_commutative2(&op->args[1], &op->args[3])) { op->args[5] = tcg_swap_cond(op->args[5]); } break; default: break; } switch (opc) { CASE_OP_32_64(shl): CASE_OP_32_64(shr): CASE_OP_32_64(sar): CASE_OP_32_64(rotl): CASE_OP_32_64(rotr): if (arg_is_const(op->args[1]) && arg_info(op->args[1])->val == 0) { tcg_opt_gen_movi(s, op, op->args[0], 0); continue; } break; CASE_OP_32_64(sub): { TCGOpcode neg_op; bool have_neg; if (arg_is_const(op->args[2])) { break; } if (opc == INDEX_op_sub_i32) { neg_op = INDEX_op_neg_i32; have_neg = TCG_TARGET_HAS_neg_i32; } else { neg_op = INDEX_op_neg_i64; have_neg = TCG_TARGET_HAS_neg_i64; } if (!have_neg) { break; } if (arg_is_const(op->args[1]) && arg_info(op->args[1])->val == 0) { op->opc = neg_op; reset_temp(op->args[0]); op->args[1] = op->args[2]; continue; } } break; CASE_OP_32_64(xor): CASE_OP_32_64(nand): if (!arg_is_const(op->args[1]) && arg_is_const(op->args[2]) && arg_info(op->args[2])->val == -1) { i = 1; goto try_not; } break; CASE_OP_32_64(nor): if (!arg_is_const(op->args[1]) && arg_is_const(op->args[2]) && arg_info(op->args[2])->val == 0) { i = 1; goto try_not; } break; CASE_OP_32_64(andc): if (!arg_is_const(op->args[2]) && arg_is_const(op->args[1]) && arg_info(op->args[1])->val == -1) { i = 2; goto try_not; } break; CASE_OP_32_64(orc): CASE_OP_32_64(eqv): if (!arg_is_const(op->args[2]) && arg_is_const(op->args[1]) && arg_info(op->args[1])->val == 0) { i = 2; goto try_not; } break; try_not: { TCGOpcode not_op; bool have_not; if (def->flags & TCG_OPF_64BIT) { not_op = INDEX_op_not_i64; have_not = TCG_TARGET_HAS_not_i64; } else { not_op = INDEX_op_not_i32; have_not = TCG_TARGET_HAS_not_i32; } if (!have_not) { break; } op->opc = not_op; reset_temp(op->args[0]); op->args[1] = op->args[i]; continue; } default: break; } switch (opc) { CASE_OP_32_64(add): CASE_OP_32_64(sub): CASE_OP_32_64(shl): CASE_OP_32_64(shr): CASE_OP_32_64(sar): CASE_OP_32_64(rotl): CASE_OP_32_64(rotr): CASE_OP_32_64(or): CASE_OP_32_64(xor): CASE_OP_32_64(andc): if (!arg_is_const(op->args[1]) && arg_is_const(op->args[2]) && arg_info(op->args[2])->val == 0) { tcg_opt_gen_mov(s, op, op->args[0], op->args[1]); continue; } break; CASE_OP_32_64(and): CASE_OP_32_64(orc): CASE_OP_32_64(eqv): if (!arg_is_const(op->args[1]) && arg_is_const(op->args[2]) && arg_info(op->args[2])->val == -1) { tcg_opt_gen_mov(s, op, op->args[0], op->args[1]); continue; } break; default: break; } mask = -1; affected = -1; switch (opc) { CASE_OP_32_64(ext8s): if ((arg_info(op->args[1])->mask & 0x80) != 0) { break; } CASE_OP_32_64(ext8u): mask = 0xff; goto and_const; CASE_OP_32_64(ext16s): if ((arg_info(op->args[1])->mask & 0x8000) != 0) { break; } CASE_OP_32_64(ext16u): mask = 0xffff; goto and_const; case INDEX_op_ext32s_i64: if ((arg_info(op->args[1])->mask & 0x80000000) != 0) { break; } case INDEX_op_ext32u_i64: mask = 0xffffffffU; goto and_const; CASE_OP_32_64(and): mask = arg_info(op->args[2])->mask; if (arg_is_const(op->args[2])) { and_const: affected = arg_info(op->args[1])->mask & ~mask; } mask = arg_info(op->args[1])->mask & mask; break; case INDEX_op_ext_i32_i64: if ((arg_info(op->args[1])->mask & 0x80000000) != 0) { break; } case INDEX_op_extu_i32_i64: mask = (uint32_t)arg_info(op->args[1])->mask; break; CASE_OP_32_64(andc): if (arg_is_const(op->args[2])) { mask = ~arg_info(op->args[2])->mask; goto and_const; } mask = arg_info(op->args[1])->mask; break; case INDEX_op_sar_i32: if (arg_is_const(op->args[2])) { tmp = arg_info(op->args[2])->val & 31; mask = (int32_t)arg_info(op->args[1])->mask >> tmp; } break; case INDEX_op_sar_i64: if (arg_is_const(op->args[2])) { tmp = arg_info(op->args[2])->val & 63; mask = (int64_t)arg_info(op->args[1])->mask >> tmp; } break; case INDEX_op_shr_i32: if (arg_is_const(op->args[2])) { tmp = arg_info(op->args[2])->val & 31; mask = (uint32_t)arg_info(op->args[1])->mask >> tmp; } break; case INDEX_op_shr_i64: if (arg_is_const(op->args[2])) { tmp = arg_info(op->args[2])->val & 63; mask = (uint64_t)arg_info(op->args[1])->mask >> tmp; } break; case INDEX_op_extrl_i64_i32: mask = (uint32_t)arg_info(op->args[1])->mask; break; case INDEX_op_extrh_i64_i32: mask = (uint64_t)arg_info(op->args[1])->mask >> 32; break; CASE_OP_32_64(shl): if (arg_is_const(op->args[2])) { tmp = arg_info(op->args[2])->val & (TCG_TARGET_REG_BITS - 1); mask = arg_info(op->args[1])->mask << tmp; } break; CASE_OP_32_64(neg): mask = -(arg_info(op->args[1])->mask & -arg_info(op->args[1])->mask); break; CASE_OP_32_64(deposit): mask = deposit64(arg_info(op->args[1])->mask, op->args[3], op->args[4], arg_info(op->args[2])->mask); break; CASE_OP_32_64(extract): mask = extract64(arg_info(op->args[1])->mask, op->args[2], op->args[3]); if (op->args[2] == 0) { affected = arg_info(op->args[1])->mask & ~mask; } break; CASE_OP_32_64(sextract): mask = sextract64(arg_info(op->args[1])->mask, op->args[2], op->args[3]); if (op->args[2] == 0 && (tcg_target_long)mask >= 0) { affected = arg_info(op->args[1])->mask & ~mask; } break; CASE_OP_32_64(or): CASE_OP_32_64(xor): mask = arg_info(op->args[1])->mask | arg_info(op->args[2])->mask; break; case INDEX_op_clz_i32: case INDEX_op_ctz_i32: mask = arg_info(op->args[2])->mask | 31; break; case INDEX_op_clz_i64: case INDEX_op_ctz_i64: mask = arg_info(op->args[2])->mask | 63; break; case INDEX_op_ctpop_i32: mask = 32 | 31; break; case INDEX_op_ctpop_i64: mask = 64 | 63; break; CASE_OP_32_64(setcond): case INDEX_op_setcond2_i32: mask = 1; break; CASE_OP_32_64(movcond): mask = arg_info(op->args[3])->mask | arg_info(op->args[4])->mask; break; CASE_OP_32_64(ld8u): mask = 0xff; break; CASE_OP_32_64(ld16u): mask = 0xffff; break; case INDEX_op_ld32u_i64: mask = 0xffffffffu; break; CASE_OP_32_64(qemu_ld): { TCGMemOpIdx oi = op->args[nb_oargs + nb_iargs]; TCGMemOp mop = get_memop(oi); if (!(mop & MO_SIGN)) { mask = (2ULL << ((8 << (mop & MO_SIZE)) - 1)) - 1; } } break; default: break; } partmask = mask; if (!(def->flags & TCG_OPF_64BIT)) { mask |= ~(tcg_target_ulong)0xffffffffu; partmask &= 0xffffffffu; affected &= 0xffffffffu; } if (partmask == 0) { tcg_debug_assert(nb_oargs == 1); tcg_opt_gen_movi(s, op, op->args[0], 0); continue; } if (affected == 0) { tcg_debug_assert(nb_oargs == 1); tcg_opt_gen_mov(s, op, op->args[0], op->args[1]); continue; } switch (opc) { CASE_OP_32_64(and): CASE_OP_32_64(mul): CASE_OP_32_64(muluh): CASE_OP_32_64(mulsh): if (arg_is_const(op->args[2]) && arg_info(op->args[2])->val == 0) { tcg_opt_gen_movi(s, op, op->args[0], 0); continue; } break; default: break; } switch (opc) { CASE_OP_32_64(or): CASE_OP_32_64(and): if (args_are_copies(op->args[1], op->args[2])) { tcg_opt_gen_mov(s, op, op->args[0], op->args[1]); continue; } break; default: break; } switch (opc) { CASE_OP_32_64(andc): CASE_OP_32_64(sub): CASE_OP_32_64(xor): if (args_are_copies(op->args[1], op->args[2])) { tcg_opt_gen_movi(s, op, op->args[0], 0); continue; } break; default: break; } switch (opc) { CASE_OP_32_64(mov): tcg_opt_gen_mov(s, op, op->args[0], op->args[1]); break; CASE_OP_32_64(movi): tcg_opt_gen_movi(s, op, op->args[0], op->args[1]); break; CASE_OP_32_64(not): CASE_OP_32_64(neg): CASE_OP_32_64(ext8s): CASE_OP_32_64(ext8u): CASE_OP_32_64(ext16s): CASE_OP_32_64(ext16u): CASE_OP_32_64(ctpop): case INDEX_op_ext32s_i64: case INDEX_op_ext32u_i64: case INDEX_op_ext_i32_i64: case INDEX_op_extu_i32_i64: case INDEX_op_extrl_i64_i32: case INDEX_op_extrh_i64_i32: if (arg_is_const(op->args[1])) { tmp = do_constant_folding(opc, arg_info(op->args[1])->val, 0); tcg_opt_gen_movi(s, op, op->args[0], tmp); break; } goto do_default; CASE_OP_32_64(add): CASE_OP_32_64(sub): CASE_OP_32_64(mul): CASE_OP_32_64(or): CASE_OP_32_64(and): CASE_OP_32_64(xor): CASE_OP_32_64(shl): CASE_OP_32_64(shr): CASE_OP_32_64(sar): CASE_OP_32_64(rotl): CASE_OP_32_64(rotr): CASE_OP_32_64(andc): CASE_OP_32_64(orc): CASE_OP_32_64(eqv): CASE_OP_32_64(nand): CASE_OP_32_64(nor): CASE_OP_32_64(muluh): CASE_OP_32_64(mulsh): CASE_OP_32_64(div): CASE_OP_32_64(divu): CASE_OP_32_64(rem): CASE_OP_32_64(remu): if (arg_is_const(op->args[1]) && arg_is_const(op->args[2])) { tmp = do_constant_folding(opc, arg_info(op->args[1])->val, arg_info(op->args[2])->val); tcg_opt_gen_movi(s, op, op->args[0], tmp); break; } goto do_default; CASE_OP_32_64(clz): CASE_OP_32_64(ctz): if (arg_is_const(op->args[1])) { TCGArg v = arg_info(op->args[1])->val; if (v != 0) { tmp = do_constant_folding(opc, v, 0); tcg_opt_gen_movi(s, op, op->args[0], tmp); } else { tcg_opt_gen_mov(s, op, op->args[0], op->args[2]); } break; } goto do_default; CASE_OP_32_64(deposit): if (arg_is_const(op->args[1]) && arg_is_const(op->args[2])) { tmp = deposit64(arg_info(op->args[1])->val, op->args[3], op->args[4], arg_info(op->args[2])->val); tcg_opt_gen_movi(s, op, op->args[0], tmp); break; } goto do_default; CASE_OP_32_64(extract): if (arg_is_const(op->args[1])) { tmp = extract64(arg_info(op->args[1])->val, op->args[2], op->args[3]); tcg_opt_gen_movi(s, op, op->args[0], tmp); break; } goto do_default; CASE_OP_32_64(sextract): if (arg_is_const(op->args[1])) { tmp = sextract64(arg_info(op->args[1])->val, op->args[2], op->args[3]); tcg_opt_gen_movi(s, op, op->args[0], tmp); break; } goto do_default; CASE_OP_32_64(setcond): tmp = do_constant_folding_cond(opc, op->args[1], op->args[2], op->args[3]); if (tmp != 2) { tcg_opt_gen_movi(s, op, op->args[0], tmp); break; } goto do_default; CASE_OP_32_64(brcond): tmp = do_constant_folding_cond(opc, op->args[0], op->args[1], op->args[2]); if (tmp != 2) { if (tmp) { bitmap_zero(temps_used.l, nb_temps); op->opc = INDEX_op_br; op->args[0] = op->args[3]; } else { tcg_op_remove(s, op); } break; } goto do_default; CASE_OP_32_64(movcond): tmp = do_constant_folding_cond(opc, op->args[1], op->args[2], op->args[5]); if (tmp != 2) { tcg_opt_gen_mov(s, op, op->args[0], op->args[4-tmp]); break; } if (arg_is_const(op->args[3]) && arg_is_const(op->args[4])) { tcg_target_ulong tv = arg_info(op->args[3])->val; tcg_target_ulong fv = arg_info(op->args[4])->val; TCGCond cond = op->args[5]; if (fv == 1 && tv == 0) { cond = tcg_invert_cond(cond); } else if (!(tv == 1 && fv == 0)) { goto do_default; } op->args[3] = cond; op->opc = opc = (opc == INDEX_op_movcond_i32 ? INDEX_op_setcond_i32 : INDEX_op_setcond_i64); nb_iargs = 2; } goto do_default; case INDEX_op_add2_i32: case INDEX_op_sub2_i32: if (arg_is_const(op->args[2]) && arg_is_const(op->args[3]) && arg_is_const(op->args[4]) && arg_is_const(op->args[5])) { uint32_t al = arg_info(op->args[2])->val; uint32_t ah = arg_info(op->args[3])->val; uint32_t bl = arg_info(op->args[4])->val; uint32_t bh = arg_info(op->args[5])->val; uint64_t a = ((uint64_t)ah << 32) | al; uint64_t b = ((uint64_t)bh << 32) | bl; TCGArg rl, rh; TCGOp *op2 = tcg_op_insert_before(s, op, INDEX_op_movi_i32, 2); if (opc == INDEX_op_add2_i32) { a += b; } else { a -= b; } rl = op->args[0]; rh = op->args[1]; tcg_opt_gen_movi(s, op, rl, (int32_t)a); tcg_opt_gen_movi(s, op2, rh, (int32_t)(a >> 32)); oi_next = op2->next; break; } goto do_default; case INDEX_op_mulu2_i32: if (arg_is_const(op->args[2]) && arg_is_const(op->args[3])) { uint32_t a = arg_info(op->args[2])->val; uint32_t b = arg_info(op->args[3])->val; uint64_t r = (uint64_t)a * b; TCGArg rl, rh; TCGOp *op2 = tcg_op_insert_before(s, op, INDEX_op_movi_i32, 2); rl = op->args[0]; rh = op->args[1]; tcg_opt_gen_movi(s, op, rl, (int32_t)r); tcg_opt_gen_movi(s, op2, rh, (int32_t)(r >> 32)); oi_next = op2->next; break; } goto do_default; case INDEX_op_brcond2_i32: tmp = do_constant_folding_cond2(&op->args[0], &op->args[2], op->args[4]); if (tmp != 2) { if (tmp) { do_brcond_true: bitmap_zero(temps_used.l, nb_temps); op->opc = INDEX_op_br; op->args[0] = op->args[5]; } else { do_brcond_false: tcg_op_remove(s, op); } } else if ((op->args[4] == TCG_COND_LT || op->args[4] == TCG_COND_GE) && arg_is_const(op->args[2]) && arg_info(op->args[2])->val == 0 && arg_is_const(op->args[3]) && arg_info(op->args[3])->val == 0) { do_brcond_high: bitmap_zero(temps_used.l, nb_temps); op->opc = INDEX_op_brcond_i32; op->args[0] = op->args[1]; op->args[1] = op->args[3]; op->args[2] = op->args[4]; op->args[3] = op->args[5]; } else if (op->args[4] == TCG_COND_EQ) { tmp = do_constant_folding_cond(INDEX_op_brcond_i32, op->args[0], op->args[2], TCG_COND_EQ); if (tmp == 0) { goto do_brcond_false; } else if (tmp == 1) { goto do_brcond_high; } tmp = do_constant_folding_cond(INDEX_op_brcond_i32, op->args[1], op->args[3], TCG_COND_EQ); if (tmp == 0) { goto do_brcond_false; } else if (tmp != 1) { goto do_default; } do_brcond_low: bitmap_zero(temps_used.l, nb_temps); op->opc = INDEX_op_brcond_i32; op->args[1] = op->args[2]; op->args[2] = op->args[4]; op->args[3] = op->args[5]; } else if (op->args[4] == TCG_COND_NE) { tmp = do_constant_folding_cond(INDEX_op_brcond_i32, op->args[0], op->args[2], TCG_COND_NE); if (tmp == 0) { goto do_brcond_high; } else if (tmp == 1) { goto do_brcond_true; } tmp = do_constant_folding_cond(INDEX_op_brcond_i32, op->args[1], op->args[3], TCG_COND_NE); if (tmp == 0) { goto do_brcond_low; } else if (tmp == 1) { goto do_brcond_true; } goto do_default; } else { goto do_default; } break; case INDEX_op_setcond2_i32: tmp = do_constant_folding_cond2(&op->args[1], &op->args[3], op->args[5]); if (tmp != 2) { do_setcond_const: tcg_opt_gen_movi(s, op, op->args[0], tmp); } else if ((op->args[5] == TCG_COND_LT || op->args[5] == TCG_COND_GE) && arg_is_const(op->args[3]) && arg_info(op->args[3])->val == 0 && arg_is_const(op->args[4]) && arg_info(op->args[4])->val == 0) { do_setcond_high: reset_temp(op->args[0]); arg_info(op->args[0])->mask = 1; op->opc = INDEX_op_setcond_i32; op->args[1] = op->args[2]; op->args[2] = op->args[4]; op->args[3] = op->args[5]; } else if (op->args[5] == TCG_COND_EQ) { tmp = do_constant_folding_cond(INDEX_op_setcond_i32, op->args[1], op->args[3], TCG_COND_EQ); if (tmp == 0) { goto do_setcond_const; } else if (tmp == 1) { goto do_setcond_high; } tmp = do_constant_folding_cond(INDEX_op_setcond_i32, op->args[2], op->args[4], TCG_COND_EQ); if (tmp == 0) { goto do_setcond_high; } else if (tmp != 1) { goto do_default; } do_setcond_low: reset_temp(op->args[0]); arg_info(op->args[0])->mask = 1; op->opc = INDEX_op_setcond_i32; op->args[2] = op->args[3]; op->args[3] = op->args[5]; } else if (op->args[5] == TCG_COND_NE) { tmp = do_constant_folding_cond(INDEX_op_setcond_i32, op->args[1], op->args[3], TCG_COND_NE); if (tmp == 0) { goto do_setcond_high; } else if (tmp == 1) { goto do_setcond_const; } tmp = do_constant_folding_cond(INDEX_op_setcond_i32, op->args[2], op->args[4], TCG_COND_NE); if (tmp == 0) { goto do_setcond_low; } else if (tmp == 1) { goto do_setcond_const; } goto do_default; } else { goto do_default; } break; case INDEX_op_call: if (!(op->args[nb_oargs + nb_iargs + 1] & (TCG_CALL_NO_READ_GLOBALS | TCG_CALL_NO_WRITE_GLOBALS))) { for (i = 0; i < nb_globals; i++) { if (test_bit(i, temps_used.l)) { reset_ts(&s->temps[i]); } } } goto do_reset_output; default: do_default: if (def->flags & TCG_OPF_BB_END) { bitmap_zero(temps_used.l, nb_temps); } else { do_reset_output: for (i = 0; i < nb_oargs; i++) { reset_temp(op->args[i]); if (i == 0) { arg_info(op->args[i])->mask = mask; } } } break; } if (prev_mb) { switch (opc) { case INDEX_op_mb: prev_mb->args[0] |= op->args[0]; tcg_op_remove(s, op); break; default: if ((def->flags & TCG_OPF_BB_END) == 0) { break; } case INDEX_op_qemu_ld_i32: case INDEX_op_qemu_ld_i64: case INDEX_op_qemu_st_i32: case INDEX_op_qemu_st_i64: case INDEX_op_call: prev_mb = NULL; break; } } else if (opc == INDEX_op_mb) { prev_mb = op; } } }
{ "code": [ " int oi, oi_next, nb_temps, nb_globals;", " TCGOp *prev_mb = NULL;", " for (oi = s->gen_op_buf[0].next; oi != 0; oi = oi_next) {", " TCGOp * const op = &s->gen_op_buf[oi];", " oi_next = op->next;", " oi_next = op2->next;", " oi_next = op2->next;", " TCGOp * const op = &s->gen_op_buf[oi];", " for (oi = s->gen_op_buf[0].next; oi != 0; oi = oi_next) {", " oi_next = op->next;", " for (oi = s->gen_op_buf[0].next; oi != 0; oi = oi_next) {", " TCGOp * const op = &s->gen_op_buf[oi];", " oi_next = op->next;" ], "line_no": [ 5, 7, 35, 45, 53, 1327, 1327, 45, 35, 53, 35, 45, 53 ] }
void FUNC_0(TCGContext *VAR_0) { int VAR_1, VAR_2, VAR_3, VAR_4; TCGOp *prev_mb = NULL; struct tcg_temp_info *VAR_5; TCGTempSet temps_used; VAR_3 = VAR_0->VAR_3; VAR_4 = VAR_0->VAR_4; bitmap_zero(temps_used.l, VAR_3); VAR_5 = tcg_malloc(sizeof(struct tcg_temp_info) * VAR_3); for (VAR_1 = VAR_0->gen_op_buf[0].next; VAR_1 != 0; VAR_1 = VAR_2) { tcg_target_ulong mask, partmask, affected; int VAR_6, VAR_7, VAR_8; TCGArg tmp; TCGOp * const op = &VAR_0->gen_op_buf[VAR_1]; TCGOpcode opc = op->opc; const TCGOpDef *VAR_9 = &tcg_op_defs[opc]; VAR_2 = op->next; if (opc == INDEX_op_call) { VAR_6 = op->callo; VAR_7 = op->calli; for (VAR_8 = 0; VAR_8 < VAR_6 + VAR_7; VAR_8++) { TCGTemp *ts = arg_temp(op->args[VAR_8]); if (ts) { init_ts_info(VAR_5, &temps_used, ts); } } } else { VAR_6 = VAR_9->VAR_6; VAR_7 = VAR_9->VAR_7; for (VAR_8 = 0; VAR_8 < VAR_6 + VAR_7; VAR_8++) { init_arg_info(VAR_5, &temps_used, op->args[VAR_8]); } } for (VAR_8 = VAR_6; VAR_8 < VAR_6 + VAR_7; VAR_8++) { TCGTemp *ts = arg_temp(op->args[VAR_8]); if (ts && ts_is_copy(ts)) { op->args[VAR_8] = temp_arg(find_better_copy(VAR_0, ts)); } } switch (opc) { CASE_OP_32_64(add): CASE_OP_32_64(mul): CASE_OP_32_64(and): CASE_OP_32_64(or): CASE_OP_32_64(xor): CASE_OP_32_64(eqv): CASE_OP_32_64(nand): CASE_OP_32_64(nor): CASE_OP_32_64(muluh): CASE_OP_32_64(mulsh): swap_commutative(op->args[0], &op->args[1], &op->args[2]); break; CASE_OP_32_64(brcond): if (swap_commutative(-1, &op->args[0], &op->args[1])) { op->args[2] = tcg_swap_cond(op->args[2]); } break; CASE_OP_32_64(setcond): if (swap_commutative(op->args[0], &op->args[1], &op->args[2])) { op->args[3] = tcg_swap_cond(op->args[3]); } break; CASE_OP_32_64(movcond): if (swap_commutative(-1, &op->args[1], &op->args[2])) { op->args[5] = tcg_swap_cond(op->args[5]); } if (swap_commutative(op->args[0], &op->args[4], &op->args[3])) { op->args[5] = tcg_invert_cond(op->args[5]); } break; CASE_OP_32_64(add2): swap_commutative(op->args[0], &op->args[2], &op->args[4]); swap_commutative(op->args[1], &op->args[3], &op->args[5]); break; CASE_OP_32_64(mulu2): CASE_OP_32_64(muls2): swap_commutative(op->args[0], &op->args[2], &op->args[3]); break; case INDEX_op_brcond2_i32: if (swap_commutative2(&op->args[0], &op->args[2])) { op->args[4] = tcg_swap_cond(op->args[4]); } break; case INDEX_op_setcond2_i32: if (swap_commutative2(&op->args[1], &op->args[3])) { op->args[5] = tcg_swap_cond(op->args[5]); } break; default: break; } switch (opc) { CASE_OP_32_64(shl): CASE_OP_32_64(shr): CASE_OP_32_64(sar): CASE_OP_32_64(rotl): CASE_OP_32_64(rotr): if (arg_is_const(op->args[1]) && arg_info(op->args[1])->val == 0) { tcg_opt_gen_movi(VAR_0, op, op->args[0], 0); continue; } break; CASE_OP_32_64(sub): { TCGOpcode neg_op; bool have_neg; if (arg_is_const(op->args[2])) { break; } if (opc == INDEX_op_sub_i32) { neg_op = INDEX_op_neg_i32; have_neg = TCG_TARGET_HAS_neg_i32; } else { neg_op = INDEX_op_neg_i64; have_neg = TCG_TARGET_HAS_neg_i64; } if (!have_neg) { break; } if (arg_is_const(op->args[1]) && arg_info(op->args[1])->val == 0) { op->opc = neg_op; reset_temp(op->args[0]); op->args[1] = op->args[2]; continue; } } break; CASE_OP_32_64(xor): CASE_OP_32_64(nand): if (!arg_is_const(op->args[1]) && arg_is_const(op->args[2]) && arg_info(op->args[2])->val == -1) { VAR_8 = 1; goto try_not; } break; CASE_OP_32_64(nor): if (!arg_is_const(op->args[1]) && arg_is_const(op->args[2]) && arg_info(op->args[2])->val == 0) { VAR_8 = 1; goto try_not; } break; CASE_OP_32_64(andc): if (!arg_is_const(op->args[2]) && arg_is_const(op->args[1]) && arg_info(op->args[1])->val == -1) { VAR_8 = 2; goto try_not; } break; CASE_OP_32_64(orc): CASE_OP_32_64(eqv): if (!arg_is_const(op->args[2]) && arg_is_const(op->args[1]) && arg_info(op->args[1])->val == 0) { VAR_8 = 2; goto try_not; } break; try_not: { TCGOpcode not_op; bool have_not; if (VAR_9->flags & TCG_OPF_64BIT) { not_op = INDEX_op_not_i64; have_not = TCG_TARGET_HAS_not_i64; } else { not_op = INDEX_op_not_i32; have_not = TCG_TARGET_HAS_not_i32; } if (!have_not) { break; } op->opc = not_op; reset_temp(op->args[0]); op->args[1] = op->args[VAR_8]; continue; } default: break; } switch (opc) { CASE_OP_32_64(add): CASE_OP_32_64(sub): CASE_OP_32_64(shl): CASE_OP_32_64(shr): CASE_OP_32_64(sar): CASE_OP_32_64(rotl): CASE_OP_32_64(rotr): CASE_OP_32_64(or): CASE_OP_32_64(xor): CASE_OP_32_64(andc): if (!arg_is_const(op->args[1]) && arg_is_const(op->args[2]) && arg_info(op->args[2])->val == 0) { tcg_opt_gen_mov(VAR_0, op, op->args[0], op->args[1]); continue; } break; CASE_OP_32_64(and): CASE_OP_32_64(orc): CASE_OP_32_64(eqv): if (!arg_is_const(op->args[1]) && arg_is_const(op->args[2]) && arg_info(op->args[2])->val == -1) { tcg_opt_gen_mov(VAR_0, op, op->args[0], op->args[1]); continue; } break; default: break; } mask = -1; affected = -1; switch (opc) { CASE_OP_32_64(ext8s): if ((arg_info(op->args[1])->mask & 0x80) != 0) { break; } CASE_OP_32_64(ext8u): mask = 0xff; goto and_const; CASE_OP_32_64(ext16s): if ((arg_info(op->args[1])->mask & 0x8000) != 0) { break; } CASE_OP_32_64(ext16u): mask = 0xffff; goto and_const; case INDEX_op_ext32s_i64: if ((arg_info(op->args[1])->mask & 0x80000000) != 0) { break; } case INDEX_op_ext32u_i64: mask = 0xffffffffU; goto and_const; CASE_OP_32_64(and): mask = arg_info(op->args[2])->mask; if (arg_is_const(op->args[2])) { and_const: affected = arg_info(op->args[1])->mask & ~mask; } mask = arg_info(op->args[1])->mask & mask; break; case INDEX_op_ext_i32_i64: if ((arg_info(op->args[1])->mask & 0x80000000) != 0) { break; } case INDEX_op_extu_i32_i64: mask = (uint32_t)arg_info(op->args[1])->mask; break; CASE_OP_32_64(andc): if (arg_is_const(op->args[2])) { mask = ~arg_info(op->args[2])->mask; goto and_const; } mask = arg_info(op->args[1])->mask; break; case INDEX_op_sar_i32: if (arg_is_const(op->args[2])) { tmp = arg_info(op->args[2])->val & 31; mask = (int32_t)arg_info(op->args[1])->mask >> tmp; } break; case INDEX_op_sar_i64: if (arg_is_const(op->args[2])) { tmp = arg_info(op->args[2])->val & 63; mask = (int64_t)arg_info(op->args[1])->mask >> tmp; } break; case INDEX_op_shr_i32: if (arg_is_const(op->args[2])) { tmp = arg_info(op->args[2])->val & 31; mask = (uint32_t)arg_info(op->args[1])->mask >> tmp; } break; case INDEX_op_shr_i64: if (arg_is_const(op->args[2])) { tmp = arg_info(op->args[2])->val & 63; mask = (uint64_t)arg_info(op->args[1])->mask >> tmp; } break; case INDEX_op_extrl_i64_i32: mask = (uint32_t)arg_info(op->args[1])->mask; break; case INDEX_op_extrh_i64_i32: mask = (uint64_t)arg_info(op->args[1])->mask >> 32; break; CASE_OP_32_64(shl): if (arg_is_const(op->args[2])) { tmp = arg_info(op->args[2])->val & (TCG_TARGET_REG_BITS - 1); mask = arg_info(op->args[1])->mask << tmp; } break; CASE_OP_32_64(neg): mask = -(arg_info(op->args[1])->mask & -arg_info(op->args[1])->mask); break; CASE_OP_32_64(deposit): mask = deposit64(arg_info(op->args[1])->mask, op->args[3], op->args[4], arg_info(op->args[2])->mask); break; CASE_OP_32_64(extract): mask = extract64(arg_info(op->args[1])->mask, op->args[2], op->args[3]); if (op->args[2] == 0) { affected = arg_info(op->args[1])->mask & ~mask; } break; CASE_OP_32_64(sextract): mask = sextract64(arg_info(op->args[1])->mask, op->args[2], op->args[3]); if (op->args[2] == 0 && (tcg_target_long)mask >= 0) { affected = arg_info(op->args[1])->mask & ~mask; } break; CASE_OP_32_64(or): CASE_OP_32_64(xor): mask = arg_info(op->args[1])->mask | arg_info(op->args[2])->mask; break; case INDEX_op_clz_i32: case INDEX_op_ctz_i32: mask = arg_info(op->args[2])->mask | 31; break; case INDEX_op_clz_i64: case INDEX_op_ctz_i64: mask = arg_info(op->args[2])->mask | 63; break; case INDEX_op_ctpop_i32: mask = 32 | 31; break; case INDEX_op_ctpop_i64: mask = 64 | 63; break; CASE_OP_32_64(setcond): case INDEX_op_setcond2_i32: mask = 1; break; CASE_OP_32_64(movcond): mask = arg_info(op->args[3])->mask | arg_info(op->args[4])->mask; break; CASE_OP_32_64(ld8u): mask = 0xff; break; CASE_OP_32_64(ld16u): mask = 0xffff; break; case INDEX_op_ld32u_i64: mask = 0xffffffffu; break; CASE_OP_32_64(qemu_ld): { TCGMemOpIdx VAR_1 = op->args[VAR_6 + VAR_7]; TCGMemOp mop = get_memop(VAR_1); if (!(mop & MO_SIGN)) { mask = (2ULL << ((8 << (mop & MO_SIZE)) - 1)) - 1; } } break; default: break; } partmask = mask; if (!(VAR_9->flags & TCG_OPF_64BIT)) { mask |= ~(tcg_target_ulong)0xffffffffu; partmask &= 0xffffffffu; affected &= 0xffffffffu; } if (partmask == 0) { tcg_debug_assert(VAR_6 == 1); tcg_opt_gen_movi(VAR_0, op, op->args[0], 0); continue; } if (affected == 0) { tcg_debug_assert(VAR_6 == 1); tcg_opt_gen_mov(VAR_0, op, op->args[0], op->args[1]); continue; } switch (opc) { CASE_OP_32_64(and): CASE_OP_32_64(mul): CASE_OP_32_64(muluh): CASE_OP_32_64(mulsh): if (arg_is_const(op->args[2]) && arg_info(op->args[2])->val == 0) { tcg_opt_gen_movi(VAR_0, op, op->args[0], 0); continue; } break; default: break; } switch (opc) { CASE_OP_32_64(or): CASE_OP_32_64(and): if (args_are_copies(op->args[1], op->args[2])) { tcg_opt_gen_mov(VAR_0, op, op->args[0], op->args[1]); continue; } break; default: break; } switch (opc) { CASE_OP_32_64(andc): CASE_OP_32_64(sub): CASE_OP_32_64(xor): if (args_are_copies(op->args[1], op->args[2])) { tcg_opt_gen_movi(VAR_0, op, op->args[0], 0); continue; } break; default: break; } switch (opc) { CASE_OP_32_64(mov): tcg_opt_gen_mov(VAR_0, op, op->args[0], op->args[1]); break; CASE_OP_32_64(movi): tcg_opt_gen_movi(VAR_0, op, op->args[0], op->args[1]); break; CASE_OP_32_64(not): CASE_OP_32_64(neg): CASE_OP_32_64(ext8s): CASE_OP_32_64(ext8u): CASE_OP_32_64(ext16s): CASE_OP_32_64(ext16u): CASE_OP_32_64(ctpop): case INDEX_op_ext32s_i64: case INDEX_op_ext32u_i64: case INDEX_op_ext_i32_i64: case INDEX_op_extu_i32_i64: case INDEX_op_extrl_i64_i32: case INDEX_op_extrh_i64_i32: if (arg_is_const(op->args[1])) { tmp = do_constant_folding(opc, arg_info(op->args[1])->val, 0); tcg_opt_gen_movi(VAR_0, op, op->args[0], tmp); break; } goto do_default; CASE_OP_32_64(add): CASE_OP_32_64(sub): CASE_OP_32_64(mul): CASE_OP_32_64(or): CASE_OP_32_64(and): CASE_OP_32_64(xor): CASE_OP_32_64(shl): CASE_OP_32_64(shr): CASE_OP_32_64(sar): CASE_OP_32_64(rotl): CASE_OP_32_64(rotr): CASE_OP_32_64(andc): CASE_OP_32_64(orc): CASE_OP_32_64(eqv): CASE_OP_32_64(nand): CASE_OP_32_64(nor): CASE_OP_32_64(muluh): CASE_OP_32_64(mulsh): CASE_OP_32_64(div): CASE_OP_32_64(divu): CASE_OP_32_64(rem): CASE_OP_32_64(remu): if (arg_is_const(op->args[1]) && arg_is_const(op->args[2])) { tmp = do_constant_folding(opc, arg_info(op->args[1])->val, arg_info(op->args[2])->val); tcg_opt_gen_movi(VAR_0, op, op->args[0], tmp); break; } goto do_default; CASE_OP_32_64(clz): CASE_OP_32_64(ctz): if (arg_is_const(op->args[1])) { TCGArg v = arg_info(op->args[1])->val; if (v != 0) { tmp = do_constant_folding(opc, v, 0); tcg_opt_gen_movi(VAR_0, op, op->args[0], tmp); } else { tcg_opt_gen_mov(VAR_0, op, op->args[0], op->args[2]); } break; } goto do_default; CASE_OP_32_64(deposit): if (arg_is_const(op->args[1]) && arg_is_const(op->args[2])) { tmp = deposit64(arg_info(op->args[1])->val, op->args[3], op->args[4], arg_info(op->args[2])->val); tcg_opt_gen_movi(VAR_0, op, op->args[0], tmp); break; } goto do_default; CASE_OP_32_64(extract): if (arg_is_const(op->args[1])) { tmp = extract64(arg_info(op->args[1])->val, op->args[2], op->args[3]); tcg_opt_gen_movi(VAR_0, op, op->args[0], tmp); break; } goto do_default; CASE_OP_32_64(sextract): if (arg_is_const(op->args[1])) { tmp = sextract64(arg_info(op->args[1])->val, op->args[2], op->args[3]); tcg_opt_gen_movi(VAR_0, op, op->args[0], tmp); break; } goto do_default; CASE_OP_32_64(setcond): tmp = do_constant_folding_cond(opc, op->args[1], op->args[2], op->args[3]); if (tmp != 2) { tcg_opt_gen_movi(VAR_0, op, op->args[0], tmp); break; } goto do_default; CASE_OP_32_64(brcond): tmp = do_constant_folding_cond(opc, op->args[0], op->args[1], op->args[2]); if (tmp != 2) { if (tmp) { bitmap_zero(temps_used.l, VAR_3); op->opc = INDEX_op_br; op->args[0] = op->args[3]; } else { tcg_op_remove(VAR_0, op); } break; } goto do_default; CASE_OP_32_64(movcond): tmp = do_constant_folding_cond(opc, op->args[1], op->args[2], op->args[5]); if (tmp != 2) { tcg_opt_gen_mov(VAR_0, op, op->args[0], op->args[4-tmp]); break; } if (arg_is_const(op->args[3]) && arg_is_const(op->args[4])) { tcg_target_ulong tv = arg_info(op->args[3])->val; tcg_target_ulong fv = arg_info(op->args[4])->val; TCGCond cond = op->args[5]; if (fv == 1 && tv == 0) { cond = tcg_invert_cond(cond); } else if (!(tv == 1 && fv == 0)) { goto do_default; } op->args[3] = cond; op->opc = opc = (opc == INDEX_op_movcond_i32 ? INDEX_op_setcond_i32 : INDEX_op_setcond_i64); VAR_7 = 2; } goto do_default; case INDEX_op_add2_i32: case INDEX_op_sub2_i32: if (arg_is_const(op->args[2]) && arg_is_const(op->args[3]) && arg_is_const(op->args[4]) && arg_is_const(op->args[5])) { uint32_t al = arg_info(op->args[2])->val; uint32_t ah = arg_info(op->args[3])->val; uint32_t bl = arg_info(op->args[4])->val; uint32_t bh = arg_info(op->args[5])->val; uint64_t a = ((uint64_t)ah << 32) | al; uint64_t b = ((uint64_t)bh << 32) | bl; TCGArg rl, rh; TCGOp *op2 = tcg_op_insert_before(VAR_0, op, INDEX_op_movi_i32, 2); if (opc == INDEX_op_add2_i32) { a += b; } else { a -= b; } rl = op->args[0]; rh = op->args[1]; tcg_opt_gen_movi(VAR_0, op, rl, (int32_t)a); tcg_opt_gen_movi(VAR_0, op2, rh, (int32_t)(a >> 32)); VAR_2 = op2->next; break; } goto do_default; case INDEX_op_mulu2_i32: if (arg_is_const(op->args[2]) && arg_is_const(op->args[3])) { uint32_t a = arg_info(op->args[2])->val; uint32_t b = arg_info(op->args[3])->val; uint64_t r = (uint64_t)a * b; TCGArg rl, rh; TCGOp *op2 = tcg_op_insert_before(VAR_0, op, INDEX_op_movi_i32, 2); rl = op->args[0]; rh = op->args[1]; tcg_opt_gen_movi(VAR_0, op, rl, (int32_t)r); tcg_opt_gen_movi(VAR_0, op2, rh, (int32_t)(r >> 32)); VAR_2 = op2->next; break; } goto do_default; case INDEX_op_brcond2_i32: tmp = do_constant_folding_cond2(&op->args[0], &op->args[2], op->args[4]); if (tmp != 2) { if (tmp) { do_brcond_true: bitmap_zero(temps_used.l, VAR_3); op->opc = INDEX_op_br; op->args[0] = op->args[5]; } else { do_brcond_false: tcg_op_remove(VAR_0, op); } } else if ((op->args[4] == TCG_COND_LT || op->args[4] == TCG_COND_GE) && arg_is_const(op->args[2]) && arg_info(op->args[2])->val == 0 && arg_is_const(op->args[3]) && arg_info(op->args[3])->val == 0) { do_brcond_high: bitmap_zero(temps_used.l, VAR_3); op->opc = INDEX_op_brcond_i32; op->args[0] = op->args[1]; op->args[1] = op->args[3]; op->args[2] = op->args[4]; op->args[3] = op->args[5]; } else if (op->args[4] == TCG_COND_EQ) { tmp = do_constant_folding_cond(INDEX_op_brcond_i32, op->args[0], op->args[2], TCG_COND_EQ); if (tmp == 0) { goto do_brcond_false; } else if (tmp == 1) { goto do_brcond_high; } tmp = do_constant_folding_cond(INDEX_op_brcond_i32, op->args[1], op->args[3], TCG_COND_EQ); if (tmp == 0) { goto do_brcond_false; } else if (tmp != 1) { goto do_default; } do_brcond_low: bitmap_zero(temps_used.l, VAR_3); op->opc = INDEX_op_brcond_i32; op->args[1] = op->args[2]; op->args[2] = op->args[4]; op->args[3] = op->args[5]; } else if (op->args[4] == TCG_COND_NE) { tmp = do_constant_folding_cond(INDEX_op_brcond_i32, op->args[0], op->args[2], TCG_COND_NE); if (tmp == 0) { goto do_brcond_high; } else if (tmp == 1) { goto do_brcond_true; } tmp = do_constant_folding_cond(INDEX_op_brcond_i32, op->args[1], op->args[3], TCG_COND_NE); if (tmp == 0) { goto do_brcond_low; } else if (tmp == 1) { goto do_brcond_true; } goto do_default; } else { goto do_default; } break; case INDEX_op_setcond2_i32: tmp = do_constant_folding_cond2(&op->args[1], &op->args[3], op->args[5]); if (tmp != 2) { do_setcond_const: tcg_opt_gen_movi(VAR_0, op, op->args[0], tmp); } else if ((op->args[5] == TCG_COND_LT || op->args[5] == TCG_COND_GE) && arg_is_const(op->args[3]) && arg_info(op->args[3])->val == 0 && arg_is_const(op->args[4]) && arg_info(op->args[4])->val == 0) { do_setcond_high: reset_temp(op->args[0]); arg_info(op->args[0])->mask = 1; op->opc = INDEX_op_setcond_i32; op->args[1] = op->args[2]; op->args[2] = op->args[4]; op->args[3] = op->args[5]; } else if (op->args[5] == TCG_COND_EQ) { tmp = do_constant_folding_cond(INDEX_op_setcond_i32, op->args[1], op->args[3], TCG_COND_EQ); if (tmp == 0) { goto do_setcond_const; } else if (tmp == 1) { goto do_setcond_high; } tmp = do_constant_folding_cond(INDEX_op_setcond_i32, op->args[2], op->args[4], TCG_COND_EQ); if (tmp == 0) { goto do_setcond_high; } else if (tmp != 1) { goto do_default; } do_setcond_low: reset_temp(op->args[0]); arg_info(op->args[0])->mask = 1; op->opc = INDEX_op_setcond_i32; op->args[2] = op->args[3]; op->args[3] = op->args[5]; } else if (op->args[5] == TCG_COND_NE) { tmp = do_constant_folding_cond(INDEX_op_setcond_i32, op->args[1], op->args[3], TCG_COND_NE); if (tmp == 0) { goto do_setcond_high; } else if (tmp == 1) { goto do_setcond_const; } tmp = do_constant_folding_cond(INDEX_op_setcond_i32, op->args[2], op->args[4], TCG_COND_NE); if (tmp == 0) { goto do_setcond_low; } else if (tmp == 1) { goto do_setcond_const; } goto do_default; } else { goto do_default; } break; case INDEX_op_call: if (!(op->args[VAR_6 + VAR_7 + 1] & (TCG_CALL_NO_READ_GLOBALS | TCG_CALL_NO_WRITE_GLOBALS))) { for (VAR_8 = 0; VAR_8 < VAR_4; VAR_8++) { if (test_bit(VAR_8, temps_used.l)) { reset_ts(&VAR_0->temps[VAR_8]); } } } goto do_reset_output; default: do_default: if (VAR_9->flags & TCG_OPF_BB_END) { bitmap_zero(temps_used.l, VAR_3); } else { do_reset_output: for (VAR_8 = 0; VAR_8 < VAR_6; VAR_8++) { reset_temp(op->args[VAR_8]); if (VAR_8 == 0) { arg_info(op->args[VAR_8])->mask = mask; } } } break; } if (prev_mb) { switch (opc) { case INDEX_op_mb: prev_mb->args[0] |= op->args[0]; tcg_op_remove(VAR_0, op); break; default: if ((VAR_9->flags & TCG_OPF_BB_END) == 0) { break; } case INDEX_op_qemu_ld_i32: case INDEX_op_qemu_ld_i64: case INDEX_op_qemu_st_i32: case INDEX_op_qemu_st_i64: case INDEX_op_call: prev_mb = NULL; break; } } else if (opc == INDEX_op_mb) { prev_mb = op; } } }
[ "void FUNC_0(TCGContext *VAR_0)\n{", "int VAR_1, VAR_2, VAR_3, VAR_4;", "TCGOp *prev_mb = NULL;", "struct tcg_temp_info *VAR_5;", "TCGTempSet temps_used;", "VAR_3 = VAR_0->VAR_3;", "VAR_4 = VAR_0->VAR_4;", "bitmap_zero(temps_used.l, VAR_3);", "VAR_5 = tcg_malloc(sizeof(struct tcg_temp_info) * VAR_3);", "for (VAR_1 = VAR_0->gen_op_buf[0].next; VAR_1 != 0; VAR_1 = VAR_2) {", "tcg_target_ulong mask, partmask, affected;", "int VAR_6, VAR_7, VAR_8;", "TCGArg tmp;", "TCGOp * const op = &VAR_0->gen_op_buf[VAR_1];", "TCGOpcode opc = op->opc;", "const TCGOpDef *VAR_9 = &tcg_op_defs[opc];", "VAR_2 = op->next;", "if (opc == INDEX_op_call) {", "VAR_6 = op->callo;", "VAR_7 = op->calli;", "for (VAR_8 = 0; VAR_8 < VAR_6 + VAR_7; VAR_8++) {", "TCGTemp *ts = arg_temp(op->args[VAR_8]);", "if (ts) {", "init_ts_info(VAR_5, &temps_used, ts);", "}", "}", "} else {", "VAR_6 = VAR_9->VAR_6;", "VAR_7 = VAR_9->VAR_7;", "for (VAR_8 = 0; VAR_8 < VAR_6 + VAR_7; VAR_8++) {", "init_arg_info(VAR_5, &temps_used, op->args[VAR_8]);", "}", "}", "for (VAR_8 = VAR_6; VAR_8 < VAR_6 + VAR_7; VAR_8++) {", "TCGTemp *ts = arg_temp(op->args[VAR_8]);", "if (ts && ts_is_copy(ts)) {", "op->args[VAR_8] = temp_arg(find_better_copy(VAR_0, ts));", "}", "}", "switch (opc) {", "CASE_OP_32_64(add):\nCASE_OP_32_64(mul):\nCASE_OP_32_64(and):\nCASE_OP_32_64(or):\nCASE_OP_32_64(xor):\nCASE_OP_32_64(eqv):\nCASE_OP_32_64(nand):\nCASE_OP_32_64(nor):\nCASE_OP_32_64(muluh):\nCASE_OP_32_64(mulsh):\nswap_commutative(op->args[0], &op->args[1], &op->args[2]);", "break;", "CASE_OP_32_64(brcond):\nif (swap_commutative(-1, &op->args[0], &op->args[1])) {", "op->args[2] = tcg_swap_cond(op->args[2]);", "}", "break;", "CASE_OP_32_64(setcond):\nif (swap_commutative(op->args[0], &op->args[1], &op->args[2])) {", "op->args[3] = tcg_swap_cond(op->args[3]);", "}", "break;", "CASE_OP_32_64(movcond):\nif (swap_commutative(-1, &op->args[1], &op->args[2])) {", "op->args[5] = tcg_swap_cond(op->args[5]);", "}", "if (swap_commutative(op->args[0], &op->args[4], &op->args[3])) {", "op->args[5] = tcg_invert_cond(op->args[5]);", "}", "break;", "CASE_OP_32_64(add2):\nswap_commutative(op->args[0], &op->args[2], &op->args[4]);", "swap_commutative(op->args[1], &op->args[3], &op->args[5]);", "break;", "CASE_OP_32_64(mulu2):\nCASE_OP_32_64(muls2):\nswap_commutative(op->args[0], &op->args[2], &op->args[3]);", "break;", "case INDEX_op_brcond2_i32:\nif (swap_commutative2(&op->args[0], &op->args[2])) {", "op->args[4] = tcg_swap_cond(op->args[4]);", "}", "break;", "case INDEX_op_setcond2_i32:\nif (swap_commutative2(&op->args[1], &op->args[3])) {", "op->args[5] = tcg_swap_cond(op->args[5]);", "}", "break;", "default:\nbreak;", "}", "switch (opc) {", "CASE_OP_32_64(shl):\nCASE_OP_32_64(shr):\nCASE_OP_32_64(sar):\nCASE_OP_32_64(rotl):\nCASE_OP_32_64(rotr):\nif (arg_is_const(op->args[1])\n&& arg_info(op->args[1])->val == 0) {", "tcg_opt_gen_movi(VAR_0, op, op->args[0], 0);", "continue;", "}", "break;", "CASE_OP_32_64(sub):\n{", "TCGOpcode neg_op;", "bool have_neg;", "if (arg_is_const(op->args[2])) {", "break;", "}", "if (opc == INDEX_op_sub_i32) {", "neg_op = INDEX_op_neg_i32;", "have_neg = TCG_TARGET_HAS_neg_i32;", "} else {", "neg_op = INDEX_op_neg_i64;", "have_neg = TCG_TARGET_HAS_neg_i64;", "}", "if (!have_neg) {", "break;", "}", "if (arg_is_const(op->args[1])\n&& arg_info(op->args[1])->val == 0) {", "op->opc = neg_op;", "reset_temp(op->args[0]);", "op->args[1] = op->args[2];", "continue;", "}", "}", "break;", "CASE_OP_32_64(xor):\nCASE_OP_32_64(nand):\nif (!arg_is_const(op->args[1])\n&& arg_is_const(op->args[2])\n&& arg_info(op->args[2])->val == -1) {", "VAR_8 = 1;", "goto try_not;", "}", "break;", "CASE_OP_32_64(nor):\nif (!arg_is_const(op->args[1])\n&& arg_is_const(op->args[2])\n&& arg_info(op->args[2])->val == 0) {", "VAR_8 = 1;", "goto try_not;", "}", "break;", "CASE_OP_32_64(andc):\nif (!arg_is_const(op->args[2])\n&& arg_is_const(op->args[1])\n&& arg_info(op->args[1])->val == -1) {", "VAR_8 = 2;", "goto try_not;", "}", "break;", "CASE_OP_32_64(orc):\nCASE_OP_32_64(eqv):\nif (!arg_is_const(op->args[2])\n&& arg_is_const(op->args[1])\n&& arg_info(op->args[1])->val == 0) {", "VAR_8 = 2;", "goto try_not;", "}", "break;", "try_not:\n{", "TCGOpcode not_op;", "bool have_not;", "if (VAR_9->flags & TCG_OPF_64BIT) {", "not_op = INDEX_op_not_i64;", "have_not = TCG_TARGET_HAS_not_i64;", "} else {", "not_op = INDEX_op_not_i32;", "have_not = TCG_TARGET_HAS_not_i32;", "}", "if (!have_not) {", "break;", "}", "op->opc = not_op;", "reset_temp(op->args[0]);", "op->args[1] = op->args[VAR_8];", "continue;", "}", "default:\nbreak;", "}", "switch (opc) {", "CASE_OP_32_64(add):\nCASE_OP_32_64(sub):\nCASE_OP_32_64(shl):\nCASE_OP_32_64(shr):\nCASE_OP_32_64(sar):\nCASE_OP_32_64(rotl):\nCASE_OP_32_64(rotr):\nCASE_OP_32_64(or):\nCASE_OP_32_64(xor):\nCASE_OP_32_64(andc):\nif (!arg_is_const(op->args[1])\n&& arg_is_const(op->args[2])\n&& arg_info(op->args[2])->val == 0) {", "tcg_opt_gen_mov(VAR_0, op, op->args[0], op->args[1]);", "continue;", "}", "break;", "CASE_OP_32_64(and):\nCASE_OP_32_64(orc):\nCASE_OP_32_64(eqv):\nif (!arg_is_const(op->args[1])\n&& arg_is_const(op->args[2])\n&& arg_info(op->args[2])->val == -1) {", "tcg_opt_gen_mov(VAR_0, op, op->args[0], op->args[1]);", "continue;", "}", "break;", "default:\nbreak;", "}", "mask = -1;", "affected = -1;", "switch (opc) {", "CASE_OP_32_64(ext8s):\nif ((arg_info(op->args[1])->mask & 0x80) != 0) {", "break;", "}", "CASE_OP_32_64(ext8u):\nmask = 0xff;", "goto and_const;", "CASE_OP_32_64(ext16s):\nif ((arg_info(op->args[1])->mask & 0x8000) != 0) {", "break;", "}", "CASE_OP_32_64(ext16u):\nmask = 0xffff;", "goto and_const;", "case INDEX_op_ext32s_i64:\nif ((arg_info(op->args[1])->mask & 0x80000000) != 0) {", "break;", "}", "case INDEX_op_ext32u_i64:\nmask = 0xffffffffU;", "goto and_const;", "CASE_OP_32_64(and):\nmask = arg_info(op->args[2])->mask;", "if (arg_is_const(op->args[2])) {", "and_const:\naffected = arg_info(op->args[1])->mask & ~mask;", "}", "mask = arg_info(op->args[1])->mask & mask;", "break;", "case INDEX_op_ext_i32_i64:\nif ((arg_info(op->args[1])->mask & 0x80000000) != 0) {", "break;", "}", "case INDEX_op_extu_i32_i64:\nmask = (uint32_t)arg_info(op->args[1])->mask;", "break;", "CASE_OP_32_64(andc):\nif (arg_is_const(op->args[2])) {", "mask = ~arg_info(op->args[2])->mask;", "goto and_const;", "}", "mask = arg_info(op->args[1])->mask;", "break;", "case INDEX_op_sar_i32:\nif (arg_is_const(op->args[2])) {", "tmp = arg_info(op->args[2])->val & 31;", "mask = (int32_t)arg_info(op->args[1])->mask >> tmp;", "}", "break;", "case INDEX_op_sar_i64:\nif (arg_is_const(op->args[2])) {", "tmp = arg_info(op->args[2])->val & 63;", "mask = (int64_t)arg_info(op->args[1])->mask >> tmp;", "}", "break;", "case INDEX_op_shr_i32:\nif (arg_is_const(op->args[2])) {", "tmp = arg_info(op->args[2])->val & 31;", "mask = (uint32_t)arg_info(op->args[1])->mask >> tmp;", "}", "break;", "case INDEX_op_shr_i64:\nif (arg_is_const(op->args[2])) {", "tmp = arg_info(op->args[2])->val & 63;", "mask = (uint64_t)arg_info(op->args[1])->mask >> tmp;", "}", "break;", "case INDEX_op_extrl_i64_i32:\nmask = (uint32_t)arg_info(op->args[1])->mask;", "break;", "case INDEX_op_extrh_i64_i32:\nmask = (uint64_t)arg_info(op->args[1])->mask >> 32;", "break;", "CASE_OP_32_64(shl):\nif (arg_is_const(op->args[2])) {", "tmp = arg_info(op->args[2])->val & (TCG_TARGET_REG_BITS - 1);", "mask = arg_info(op->args[1])->mask << tmp;", "}", "break;", "CASE_OP_32_64(neg):\nmask = -(arg_info(op->args[1])->mask\n& -arg_info(op->args[1])->mask);", "break;", "CASE_OP_32_64(deposit):\nmask = deposit64(arg_info(op->args[1])->mask,\nop->args[3], op->args[4],\narg_info(op->args[2])->mask);", "break;", "CASE_OP_32_64(extract):\nmask = extract64(arg_info(op->args[1])->mask,\nop->args[2], op->args[3]);", "if (op->args[2] == 0) {", "affected = arg_info(op->args[1])->mask & ~mask;", "}", "break;", "CASE_OP_32_64(sextract):\nmask = sextract64(arg_info(op->args[1])->mask,\nop->args[2], op->args[3]);", "if (op->args[2] == 0 && (tcg_target_long)mask >= 0) {", "affected = arg_info(op->args[1])->mask & ~mask;", "}", "break;", "CASE_OP_32_64(or):\nCASE_OP_32_64(xor):\nmask = arg_info(op->args[1])->mask | arg_info(op->args[2])->mask;", "break;", "case INDEX_op_clz_i32:\ncase INDEX_op_ctz_i32:\nmask = arg_info(op->args[2])->mask | 31;", "break;", "case INDEX_op_clz_i64:\ncase INDEX_op_ctz_i64:\nmask = arg_info(op->args[2])->mask | 63;", "break;", "case INDEX_op_ctpop_i32:\nmask = 32 | 31;", "break;", "case INDEX_op_ctpop_i64:\nmask = 64 | 63;", "break;", "CASE_OP_32_64(setcond):\ncase INDEX_op_setcond2_i32:\nmask = 1;", "break;", "CASE_OP_32_64(movcond):\nmask = arg_info(op->args[3])->mask | arg_info(op->args[4])->mask;", "break;", "CASE_OP_32_64(ld8u):\nmask = 0xff;", "break;", "CASE_OP_32_64(ld16u):\nmask = 0xffff;", "break;", "case INDEX_op_ld32u_i64:\nmask = 0xffffffffu;", "break;", "CASE_OP_32_64(qemu_ld):\n{", "TCGMemOpIdx VAR_1 = op->args[VAR_6 + VAR_7];", "TCGMemOp mop = get_memop(VAR_1);", "if (!(mop & MO_SIGN)) {", "mask = (2ULL << ((8 << (mop & MO_SIZE)) - 1)) - 1;", "}", "}", "break;", "default:\nbreak;", "}", "partmask = mask;", "if (!(VAR_9->flags & TCG_OPF_64BIT)) {", "mask |= ~(tcg_target_ulong)0xffffffffu;", "partmask &= 0xffffffffu;", "affected &= 0xffffffffu;", "}", "if (partmask == 0) {", "tcg_debug_assert(VAR_6 == 1);", "tcg_opt_gen_movi(VAR_0, op, op->args[0], 0);", "continue;", "}", "if (affected == 0) {", "tcg_debug_assert(VAR_6 == 1);", "tcg_opt_gen_mov(VAR_0, op, op->args[0], op->args[1]);", "continue;", "}", "switch (opc) {", "CASE_OP_32_64(and):\nCASE_OP_32_64(mul):\nCASE_OP_32_64(muluh):\nCASE_OP_32_64(mulsh):\nif (arg_is_const(op->args[2])\n&& arg_info(op->args[2])->val == 0) {", "tcg_opt_gen_movi(VAR_0, op, op->args[0], 0);", "continue;", "}", "break;", "default:\nbreak;", "}", "switch (opc) {", "CASE_OP_32_64(or):\nCASE_OP_32_64(and):\nif (args_are_copies(op->args[1], op->args[2])) {", "tcg_opt_gen_mov(VAR_0, op, op->args[0], op->args[1]);", "continue;", "}", "break;", "default:\nbreak;", "}", "switch (opc) {", "CASE_OP_32_64(andc):\nCASE_OP_32_64(sub):\nCASE_OP_32_64(xor):\nif (args_are_copies(op->args[1], op->args[2])) {", "tcg_opt_gen_movi(VAR_0, op, op->args[0], 0);", "continue;", "}", "break;", "default:\nbreak;", "}", "switch (opc) {", "CASE_OP_32_64(mov):\ntcg_opt_gen_mov(VAR_0, op, op->args[0], op->args[1]);", "break;", "CASE_OP_32_64(movi):\ntcg_opt_gen_movi(VAR_0, op, op->args[0], op->args[1]);", "break;", "CASE_OP_32_64(not):\nCASE_OP_32_64(neg):\nCASE_OP_32_64(ext8s):\nCASE_OP_32_64(ext8u):\nCASE_OP_32_64(ext16s):\nCASE_OP_32_64(ext16u):\nCASE_OP_32_64(ctpop):\ncase INDEX_op_ext32s_i64:\ncase INDEX_op_ext32u_i64:\ncase INDEX_op_ext_i32_i64:\ncase INDEX_op_extu_i32_i64:\ncase INDEX_op_extrl_i64_i32:\ncase INDEX_op_extrh_i64_i32:\nif (arg_is_const(op->args[1])) {", "tmp = do_constant_folding(opc, arg_info(op->args[1])->val, 0);", "tcg_opt_gen_movi(VAR_0, op, op->args[0], tmp);", "break;", "}", "goto do_default;", "CASE_OP_32_64(add):\nCASE_OP_32_64(sub):\nCASE_OP_32_64(mul):\nCASE_OP_32_64(or):\nCASE_OP_32_64(and):\nCASE_OP_32_64(xor):\nCASE_OP_32_64(shl):\nCASE_OP_32_64(shr):\nCASE_OP_32_64(sar):\nCASE_OP_32_64(rotl):\nCASE_OP_32_64(rotr):\nCASE_OP_32_64(andc):\nCASE_OP_32_64(orc):\nCASE_OP_32_64(eqv):\nCASE_OP_32_64(nand):\nCASE_OP_32_64(nor):\nCASE_OP_32_64(muluh):\nCASE_OP_32_64(mulsh):\nCASE_OP_32_64(div):\nCASE_OP_32_64(divu):\nCASE_OP_32_64(rem):\nCASE_OP_32_64(remu):\nif (arg_is_const(op->args[1]) && arg_is_const(op->args[2])) {", "tmp = do_constant_folding(opc, arg_info(op->args[1])->val,\narg_info(op->args[2])->val);", "tcg_opt_gen_movi(VAR_0, op, op->args[0], tmp);", "break;", "}", "goto do_default;", "CASE_OP_32_64(clz):\nCASE_OP_32_64(ctz):\nif (arg_is_const(op->args[1])) {", "TCGArg v = arg_info(op->args[1])->val;", "if (v != 0) {", "tmp = do_constant_folding(opc, v, 0);", "tcg_opt_gen_movi(VAR_0, op, op->args[0], tmp);", "} else {", "tcg_opt_gen_mov(VAR_0, op, op->args[0], op->args[2]);", "}", "break;", "}", "goto do_default;", "CASE_OP_32_64(deposit):\nif (arg_is_const(op->args[1]) && arg_is_const(op->args[2])) {", "tmp = deposit64(arg_info(op->args[1])->val,\nop->args[3], op->args[4],\narg_info(op->args[2])->val);", "tcg_opt_gen_movi(VAR_0, op, op->args[0], tmp);", "break;", "}", "goto do_default;", "CASE_OP_32_64(extract):\nif (arg_is_const(op->args[1])) {", "tmp = extract64(arg_info(op->args[1])->val,\nop->args[2], op->args[3]);", "tcg_opt_gen_movi(VAR_0, op, op->args[0], tmp);", "break;", "}", "goto do_default;", "CASE_OP_32_64(sextract):\nif (arg_is_const(op->args[1])) {", "tmp = sextract64(arg_info(op->args[1])->val,\nop->args[2], op->args[3]);", "tcg_opt_gen_movi(VAR_0, op, op->args[0], tmp);", "break;", "}", "goto do_default;", "CASE_OP_32_64(setcond):\ntmp = do_constant_folding_cond(opc, op->args[1],\nop->args[2], op->args[3]);", "if (tmp != 2) {", "tcg_opt_gen_movi(VAR_0, op, op->args[0], tmp);", "break;", "}", "goto do_default;", "CASE_OP_32_64(brcond):\ntmp = do_constant_folding_cond(opc, op->args[0],\nop->args[1], op->args[2]);", "if (tmp != 2) {", "if (tmp) {", "bitmap_zero(temps_used.l, VAR_3);", "op->opc = INDEX_op_br;", "op->args[0] = op->args[3];", "} else {", "tcg_op_remove(VAR_0, op);", "}", "break;", "}", "goto do_default;", "CASE_OP_32_64(movcond):\ntmp = do_constant_folding_cond(opc, op->args[1],\nop->args[2], op->args[5]);", "if (tmp != 2) {", "tcg_opt_gen_mov(VAR_0, op, op->args[0], op->args[4-tmp]);", "break;", "}", "if (arg_is_const(op->args[3]) && arg_is_const(op->args[4])) {", "tcg_target_ulong tv = arg_info(op->args[3])->val;", "tcg_target_ulong fv = arg_info(op->args[4])->val;", "TCGCond cond = op->args[5];", "if (fv == 1 && tv == 0) {", "cond = tcg_invert_cond(cond);", "} else if (!(tv == 1 && fv == 0)) {", "goto do_default;", "}", "op->args[3] = cond;", "op->opc = opc = (opc == INDEX_op_movcond_i32\n? INDEX_op_setcond_i32\n: INDEX_op_setcond_i64);", "VAR_7 = 2;", "}", "goto do_default;", "case INDEX_op_add2_i32:\ncase INDEX_op_sub2_i32:\nif (arg_is_const(op->args[2]) && arg_is_const(op->args[3])\n&& arg_is_const(op->args[4]) && arg_is_const(op->args[5])) {", "uint32_t al = arg_info(op->args[2])->val;", "uint32_t ah = arg_info(op->args[3])->val;", "uint32_t bl = arg_info(op->args[4])->val;", "uint32_t bh = arg_info(op->args[5])->val;", "uint64_t a = ((uint64_t)ah << 32) | al;", "uint64_t b = ((uint64_t)bh << 32) | bl;", "TCGArg rl, rh;", "TCGOp *op2 = tcg_op_insert_before(VAR_0, op, INDEX_op_movi_i32, 2);", "if (opc == INDEX_op_add2_i32) {", "a += b;", "} else {", "a -= b;", "}", "rl = op->args[0];", "rh = op->args[1];", "tcg_opt_gen_movi(VAR_0, op, rl, (int32_t)a);", "tcg_opt_gen_movi(VAR_0, op2, rh, (int32_t)(a >> 32));", "VAR_2 = op2->next;", "break;", "}", "goto do_default;", "case INDEX_op_mulu2_i32:\nif (arg_is_const(op->args[2]) && arg_is_const(op->args[3])) {", "uint32_t a = arg_info(op->args[2])->val;", "uint32_t b = arg_info(op->args[3])->val;", "uint64_t r = (uint64_t)a * b;", "TCGArg rl, rh;", "TCGOp *op2 = tcg_op_insert_before(VAR_0, op, INDEX_op_movi_i32, 2);", "rl = op->args[0];", "rh = op->args[1];", "tcg_opt_gen_movi(VAR_0, op, rl, (int32_t)r);", "tcg_opt_gen_movi(VAR_0, op2, rh, (int32_t)(r >> 32));", "VAR_2 = op2->next;", "break;", "}", "goto do_default;", "case INDEX_op_brcond2_i32:\ntmp = do_constant_folding_cond2(&op->args[0], &op->args[2],\nop->args[4]);", "if (tmp != 2) {", "if (tmp) {", "do_brcond_true:\nbitmap_zero(temps_used.l, VAR_3);", "op->opc = INDEX_op_br;", "op->args[0] = op->args[5];", "} else {", "do_brcond_false:\ntcg_op_remove(VAR_0, op);", "}", "} else if ((op->args[4] == TCG_COND_LT", "|| op->args[4] == TCG_COND_GE)\n&& arg_is_const(op->args[2])\n&& arg_info(op->args[2])->val == 0\n&& arg_is_const(op->args[3])\n&& arg_info(op->args[3])->val == 0) {", "do_brcond_high:\nbitmap_zero(temps_used.l, VAR_3);", "op->opc = INDEX_op_brcond_i32;", "op->args[0] = op->args[1];", "op->args[1] = op->args[3];", "op->args[2] = op->args[4];", "op->args[3] = op->args[5];", "} else if (op->args[4] == TCG_COND_EQ) {", "tmp = do_constant_folding_cond(INDEX_op_brcond_i32,\nop->args[0], op->args[2],\nTCG_COND_EQ);", "if (tmp == 0) {", "goto do_brcond_false;", "} else if (tmp == 1) {", "goto do_brcond_high;", "}", "tmp = do_constant_folding_cond(INDEX_op_brcond_i32,\nop->args[1], op->args[3],\nTCG_COND_EQ);", "if (tmp == 0) {", "goto do_brcond_false;", "} else if (tmp != 1) {", "goto do_default;", "}", "do_brcond_low:\nbitmap_zero(temps_used.l, VAR_3);", "op->opc = INDEX_op_brcond_i32;", "op->args[1] = op->args[2];", "op->args[2] = op->args[4];", "op->args[3] = op->args[5];", "} else if (op->args[4] == TCG_COND_NE) {", "tmp = do_constant_folding_cond(INDEX_op_brcond_i32,\nop->args[0], op->args[2],\nTCG_COND_NE);", "if (tmp == 0) {", "goto do_brcond_high;", "} else if (tmp == 1) {", "goto do_brcond_true;", "}", "tmp = do_constant_folding_cond(INDEX_op_brcond_i32,\nop->args[1], op->args[3],\nTCG_COND_NE);", "if (tmp == 0) {", "goto do_brcond_low;", "} else if (tmp == 1) {", "goto do_brcond_true;", "}", "goto do_default;", "} else {", "goto do_default;", "}", "break;", "case INDEX_op_setcond2_i32:\ntmp = do_constant_folding_cond2(&op->args[1], &op->args[3],\nop->args[5]);", "if (tmp != 2) {", "do_setcond_const:\ntcg_opt_gen_movi(VAR_0, op, op->args[0], tmp);", "} else if ((op->args[5] == TCG_COND_LT", "|| op->args[5] == TCG_COND_GE)\n&& arg_is_const(op->args[3])\n&& arg_info(op->args[3])->val == 0\n&& arg_is_const(op->args[4])\n&& arg_info(op->args[4])->val == 0) {", "do_setcond_high:\nreset_temp(op->args[0]);", "arg_info(op->args[0])->mask = 1;", "op->opc = INDEX_op_setcond_i32;", "op->args[1] = op->args[2];", "op->args[2] = op->args[4];", "op->args[3] = op->args[5];", "} else if (op->args[5] == TCG_COND_EQ) {", "tmp = do_constant_folding_cond(INDEX_op_setcond_i32,\nop->args[1], op->args[3],\nTCG_COND_EQ);", "if (tmp == 0) {", "goto do_setcond_const;", "} else if (tmp == 1) {", "goto do_setcond_high;", "}", "tmp = do_constant_folding_cond(INDEX_op_setcond_i32,\nop->args[2], op->args[4],\nTCG_COND_EQ);", "if (tmp == 0) {", "goto do_setcond_high;", "} else if (tmp != 1) {", "goto do_default;", "}", "do_setcond_low:\nreset_temp(op->args[0]);", "arg_info(op->args[0])->mask = 1;", "op->opc = INDEX_op_setcond_i32;", "op->args[2] = op->args[3];", "op->args[3] = op->args[5];", "} else if (op->args[5] == TCG_COND_NE) {", "tmp = do_constant_folding_cond(INDEX_op_setcond_i32,\nop->args[1], op->args[3],\nTCG_COND_NE);", "if (tmp == 0) {", "goto do_setcond_high;", "} else if (tmp == 1) {", "goto do_setcond_const;", "}", "tmp = do_constant_folding_cond(INDEX_op_setcond_i32,\nop->args[2], op->args[4],\nTCG_COND_NE);", "if (tmp == 0) {", "goto do_setcond_low;", "} else if (tmp == 1) {", "goto do_setcond_const;", "}", "goto do_default;", "} else {", "goto do_default;", "}", "break;", "case INDEX_op_call:\nif (!(op->args[VAR_6 + VAR_7 + 1]\n& (TCG_CALL_NO_READ_GLOBALS | TCG_CALL_NO_WRITE_GLOBALS))) {", "for (VAR_8 = 0; VAR_8 < VAR_4; VAR_8++) {", "if (test_bit(VAR_8, temps_used.l)) {", "reset_ts(&VAR_0->temps[VAR_8]);", "}", "}", "}", "goto do_reset_output;", "default:\ndo_default:\nif (VAR_9->flags & TCG_OPF_BB_END) {", "bitmap_zero(temps_used.l, VAR_3);", "} else {", "do_reset_output:\nfor (VAR_8 = 0; VAR_8 < VAR_6; VAR_8++) {", "reset_temp(op->args[VAR_8]);", "if (VAR_8 == 0) {", "arg_info(op->args[VAR_8])->mask = mask;", "}", "}", "}", "break;", "}", "if (prev_mb) {", "switch (opc) {", "case INDEX_op_mb:\nprev_mb->args[0] |= op->args[0];", "tcg_op_remove(VAR_0, op);", "break;", "default:\nif ((VAR_9->flags & TCG_OPF_BB_END) == 0) {", "break;", "}", "case INDEX_op_qemu_ld_i32:\ncase INDEX_op_qemu_ld_i64:\ncase INDEX_op_qemu_st_i32:\ncase INDEX_op_qemu_st_i64:\ncase INDEX_op_call:\nprev_mb = NULL;", "break;", "}", "} else if (opc == INDEX_op_mb) {", "prev_mb = op;", "}", "}", "}" ]
[ 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 45 ], [ 47 ], [ 49 ], [ 53 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 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 ], [ 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 ], [ 229 ], [ 231, 233, 235, 237, 239, 241, 243 ], [ 245 ], [ 247 ], [ 249 ], [ 251 ], [ 253, 255 ], [ 257 ], [ 259 ], [ 263 ], [ 267 ], [ 269 ], [ 271 ], [ 273 ], [ 275 ], [ 277 ], [ 279 ], [ 281 ], [ 283 ], [ 285 ], [ 287 ], [ 289 ], [ 291, 293 ], [ 295 ], [ 297 ], [ 299 ], [ 301 ], [ 303 ], [ 305 ], [ 307 ], [ 309, 311, 313, 315, 317 ], [ 319 ], [ 321 ], [ 323 ], [ 325 ], [ 327, 329, 331, 333 ], [ 335 ], [ 337 ], [ 339 ], [ 341 ], [ 343, 345, 347, 349 ], [ 351 ], [ 353 ], [ 355 ], [ 357 ], [ 359, 361, 363, 365, 367 ], [ 369 ], [ 371 ], [ 373 ], [ 375 ], [ 377, 379 ], [ 381 ], [ 383 ], [ 387 ], [ 389 ], [ 391 ], [ 393 ], [ 395 ], [ 397 ], [ 399 ], [ 401 ], [ 403 ], [ 405 ], [ 407 ], [ 409 ], [ 411 ], [ 413 ], [ 415 ], [ 417, 419 ], [ 421 ], [ 427 ], [ 429, 431, 433, 435, 437, 439, 441, 443, 445, 447, 449, 451, 453 ], [ 455 ], [ 457 ], [ 459 ], [ 461 ], [ 463, 465, 467, 469, 471, 473 ], [ 475 ], [ 477 ], [ 479 ], [ 481 ], [ 483, 485 ], [ 487 ], [ 495 ], [ 497 ], [ 499 ], [ 501, 503 ], [ 505 ], [ 507 ], [ 509, 511 ], [ 513 ], [ 515, 517 ], [ 519 ], [ 521 ], [ 523, 525 ], [ 527 ], [ 529, 531 ], [ 533 ], [ 535 ], [ 537, 539 ], [ 541 ], [ 545, 547 ], [ 549 ], [ 551, 553 ], [ 555 ], [ 557 ], [ 559 ], [ 563, 565 ], [ 567 ], [ 569 ], [ 571, 575 ], [ 577 ], [ 581, 587 ], [ 589 ], [ 591 ], [ 593 ], [ 597 ], [ 599 ], [ 603, 605 ], [ 607 ], [ 609 ], [ 611 ], [ 613 ], [ 615, 617 ], [ 619 ], [ 621 ], [ 623 ], [ 625 ], [ 629, 631 ], [ 633 ], [ 635 ], [ 637 ], [ 639 ], [ 641, 643 ], [ 645 ], [ 647 ], [ 649 ], [ 651 ], [ 655, 657 ], [ 659 ], [ 661, 663 ], [ 665 ], [ 669, 671 ], [ 673 ], [ 675 ], [ 677 ], [ 679 ], [ 683, 687, 689 ], [ 691 ], [ 695, 697, 699, 701 ], [ 703 ], [ 707, 709, 711 ], [ 713 ], [ 715 ], [ 717 ], [ 719 ], [ 721, 723, 725 ], [ 727 ], [ 729 ], [ 731 ], [ 733 ], [ 737, 739, 741 ], [ 743 ], [ 747, 749, 751 ], [ 753 ], [ 757, 759, 761 ], [ 763 ], [ 767, 769 ], [ 771 ], [ 773, 775 ], [ 777 ], [ 781, 783, 785 ], [ 787 ], [ 791, 793 ], [ 795 ], [ 799, 801 ], [ 803 ], [ 805, 807 ], [ 809 ], [ 811, 813 ], [ 815 ], [ 819, 821 ], [ 823 ], [ 825 ], [ 827 ], [ 829 ], [ 831 ], [ 833 ], [ 835 ], [ 839, 841 ], [ 843 ], [ 853 ], [ 855 ], [ 857 ], [ 859 ], [ 861 ], [ 863 ], [ 867 ], [ 869 ], [ 871 ], [ 873 ], [ 875 ], [ 877 ], [ 879 ], [ 881 ], [ 883 ], [ 885 ], [ 891 ], [ 893, 895, 897, 899, 901, 903 ], [ 905 ], [ 907 ], [ 909 ], [ 911 ], [ 913, 915 ], [ 917 ], [ 923 ], [ 925, 927, 929 ], [ 931 ], [ 933 ], [ 935 ], [ 937 ], [ 939, 941 ], [ 943 ], [ 949 ], [ 951, 953, 955, 957 ], [ 959 ], [ 961 ], [ 963 ], [ 965 ], [ 967, 969 ], [ 971 ], [ 981 ], [ 983, 985 ], [ 987 ], [ 989, 991 ], [ 993 ], [ 997, 999, 1001, 1003, 1005, 1007, 1009, 1011, 1013, 1015, 1017, 1019, 1021, 1023 ], [ 1025 ], [ 1027 ], [ 1029 ], [ 1031 ], [ 1033 ], [ 1037, 1039, 1041, 1043, 1045, 1047, 1049, 1051, 1053, 1055, 1057, 1059, 1061, 1063, 1065, 1067, 1069, 1071, 1073, 1075, 1077, 1079, 1081 ], [ 1083, 1085 ], [ 1087 ], [ 1089 ], [ 1091 ], [ 1093 ], [ 1097, 1099, 1101 ], [ 1103 ], [ 1105 ], [ 1107 ], [ 1109 ], [ 1111 ], [ 1113 ], [ 1115 ], [ 1117 ], [ 1119 ], [ 1121 ], [ 1125, 1127 ], [ 1129, 1131, 1133 ], [ 1135 ], [ 1137 ], [ 1139 ], [ 1141 ], [ 1145, 1147 ], [ 1149, 1151 ], [ 1153 ], [ 1155 ], [ 1157 ], [ 1159 ], [ 1163, 1165 ], [ 1167, 1169 ], [ 1171 ], [ 1173 ], [ 1175 ], [ 1177 ], [ 1181, 1183, 1185 ], [ 1187 ], [ 1189 ], [ 1191 ], [ 1193 ], [ 1195 ], [ 1199, 1201, 1203 ], [ 1205 ], [ 1207 ], [ 1209 ], [ 1211 ], [ 1213 ], [ 1215 ], [ 1217 ], [ 1219 ], [ 1221 ], [ 1223 ], [ 1225 ], [ 1229, 1231, 1233 ], [ 1235 ], [ 1237 ], [ 1239 ], [ 1241 ], [ 1243 ], [ 1245 ], [ 1247 ], [ 1249 ], [ 1251 ], [ 1253 ], [ 1255 ], [ 1257 ], [ 1259 ], [ 1261 ], [ 1263, 1265, 1267 ], [ 1269 ], [ 1271 ], [ 1273 ], [ 1277, 1279, 1281, 1283 ], [ 1285 ], [ 1287 ], [ 1289 ], [ 1291 ], [ 1293 ], [ 1295 ], [ 1297 ], [ 1299 ], [ 1303 ], [ 1305 ], [ 1307 ], [ 1309 ], [ 1311 ], [ 1315 ], [ 1317 ], [ 1319 ], [ 1321 ], [ 1327 ], [ 1329 ], [ 1331 ], [ 1333 ], [ 1337, 1339 ], [ 1341 ], [ 1343 ], [ 1345 ], [ 1347 ], [ 1349 ], [ 1353 ], [ 1355 ], [ 1357 ], [ 1359 ], [ 1365 ], [ 1367 ], [ 1369 ], [ 1371 ], [ 1375, 1377, 1379 ], [ 1381 ], [ 1383 ], [ 1385, 1387 ], [ 1389 ], [ 1391 ], [ 1393 ], [ 1395, 1397 ], [ 1399 ], [ 1401 ], [ 1403, 1405, 1407, 1409, 1411 ], [ 1417, 1419 ], [ 1421 ], [ 1423 ], [ 1425 ], [ 1427 ], [ 1429 ], [ 1431 ], [ 1437, 1439, 1441 ], [ 1443 ], [ 1445 ], [ 1447 ], [ 1449 ], [ 1451 ], [ 1453, 1455, 1457 ], [ 1459 ], [ 1461 ], [ 1463 ], [ 1465 ], [ 1467 ], [ 1469, 1471 ], [ 1473 ], [ 1475 ], [ 1477 ], [ 1479 ], [ 1481 ], [ 1487, 1489, 1491 ], [ 1493 ], [ 1495 ], [ 1497 ], [ 1499 ], [ 1501 ], [ 1503, 1505, 1507 ], [ 1509 ], [ 1511 ], [ 1513 ], [ 1515 ], [ 1517 ], [ 1519 ], [ 1521 ], [ 1523 ], [ 1525 ], [ 1527 ], [ 1531, 1533, 1535 ], [ 1537 ], [ 1539, 1541 ], [ 1543 ], [ 1545, 1547, 1549, 1551, 1553 ], [ 1559, 1561 ], [ 1563 ], [ 1565 ], [ 1567 ], [ 1569 ], [ 1571 ], [ 1573 ], [ 1579, 1581, 1583 ], [ 1585 ], [ 1587 ], [ 1589 ], [ 1591 ], [ 1593 ], [ 1595, 1597, 1599 ], [ 1601 ], [ 1603 ], [ 1605 ], [ 1607 ], [ 1609 ], [ 1611, 1613 ], [ 1615 ], [ 1617 ], [ 1619 ], [ 1621 ], [ 1623 ], [ 1629, 1631, 1633 ], [ 1635 ], [ 1637 ], [ 1639 ], [ 1641 ], [ 1643 ], [ 1645, 1647, 1649 ], [ 1651 ], [ 1653 ], [ 1655 ], [ 1657 ], [ 1659 ], [ 1661 ], [ 1663 ], [ 1665 ], [ 1667 ], [ 1669 ], [ 1673, 1675, 1677 ], [ 1679 ], [ 1681 ], [ 1683 ], [ 1685 ], [ 1687 ], [ 1689 ], [ 1691 ], [ 1695, 1697, 1709 ], [ 1711 ], [ 1713 ], [ 1715, 1717 ], [ 1719 ], [ 1725 ], [ 1727 ], [ 1729 ], [ 1731 ], [ 1733 ], [ 1735 ], [ 1737 ], [ 1743 ], [ 1745 ], [ 1747, 1771 ], [ 1773 ], [ 1775 ], [ 1779, 1783 ], [ 1785 ], [ 1787 ], [ 1791, 1793, 1795, 1797, 1799, 1803 ], [ 1805 ], [ 1807 ], [ 1809 ], [ 1811 ], [ 1813 ], [ 1815 ], [ 1817 ] ]
9,924
void ff_mpeg_set_erpic(ERPicture *dst, Picture *src) { int i; if (!src) return; dst->f = &src->f; dst->tf = &src->tf; for (i = 0; i < 2; i++) { dst->motion_val[i] = src->motion_val[i]; dst->ref_index[i] = src->ref_index[i]; } dst->mb_type = src->mb_type; dst->field_picture = src->field_picture; }
true
FFmpeg
8ef9dcf1d74aea55bf39f1e479fe67e98d973954
void ff_mpeg_set_erpic(ERPicture *dst, Picture *src) { int i; if (!src) return; dst->f = &src->f; dst->tf = &src->tf; for (i = 0; i < 2; i++) { dst->motion_val[i] = src->motion_val[i]; dst->ref_index[i] = src->ref_index[i]; } dst->mb_type = src->mb_type; dst->field_picture = src->field_picture; }
{ "code": [], "line_no": [] }
void FUNC_0(ERPicture *VAR_0, Picture *VAR_1) { int VAR_2; if (!VAR_1) return; VAR_0->f = &VAR_1->f; VAR_0->tf = &VAR_1->tf; for (VAR_2 = 0; VAR_2 < 2; VAR_2++) { VAR_0->motion_val[VAR_2] = VAR_1->motion_val[VAR_2]; VAR_0->ref_index[VAR_2] = VAR_1->ref_index[VAR_2]; } VAR_0->mb_type = VAR_1->mb_type; VAR_0->field_picture = VAR_1->field_picture; }
[ "void FUNC_0(ERPicture *VAR_0, Picture *VAR_1)\n{", "int VAR_2;", "if (!VAR_1)\nreturn;", "VAR_0->f = &VAR_1->f;", "VAR_0->tf = &VAR_1->tf;", "for (VAR_2 = 0; VAR_2 < 2; VAR_2++) {", "VAR_0->motion_val[VAR_2] = VAR_1->motion_val[VAR_2];", "VAR_0->ref_index[VAR_2] = VAR_1->ref_index[VAR_2];", "}", "VAR_0->mb_type = VAR_1->mb_type;", "VAR_0->field_picture = VAR_1->field_picture;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 10, 12 ], [ 16 ], [ 18 ], [ 22 ], [ 24 ], [ 26 ], [ 28 ], [ 32 ], [ 34 ], [ 36 ] ]
9,925
static uint8_t qvirtio_pci_get_status(QVirtioDevice *d) { QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d; return qpci_io_readb(dev->pdev, dev->addr + VIRTIO_PCI_STATUS); }
true
qemu
b4ba67d9a702507793c2724e56f98e9b0f7be02b
static uint8_t qvirtio_pci_get_status(QVirtioDevice *d) { QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d; return qpci_io_readb(dev->pdev, dev->addr + VIRTIO_PCI_STATUS); }
{ "code": [ " return qpci_io_readb(dev->pdev, dev->addr + VIRTIO_PCI_STATUS);" ], "line_no": [ 7 ] }
static uint8_t FUNC_0(QVirtioDevice *d) { QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d; return qpci_io_readb(dev->pdev, dev->addr + VIRTIO_PCI_STATUS); }
[ "static uint8_t FUNC_0(QVirtioDevice *d)\n{", "QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d;", "return qpci_io_readb(dev->pdev, dev->addr + VIRTIO_PCI_STATUS);", "}" ]
[ 0, 0, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ] ]
9,926
static void synthfilt_build_sb_samples (QDM2Context *q, GetBitContext *gb, int length, int sb_min, int sb_max) { int sb, j, k, n, ch, run, channels; int joined_stereo, zero_encoding, chs; int type34_first; float type34_div = 0; float type34_predictor; float samples[10], sign_bits[16]; if (length == 0) { // If no data use noise for (sb=sb_min; sb < sb_max; sb++) build_sb_samples_from_noise (q, sb); return; } for (sb = sb_min; sb < sb_max; sb++) { FIX_NOISE_IDX(q->noise_idx); channels = q->nb_channels; if (q->nb_channels <= 1 || sb < 12) joined_stereo = 0; else if (sb >= 24) joined_stereo = 1; else joined_stereo = (get_bits_left(gb) >= 1) ? get_bits1 (gb) : 0; if (joined_stereo) { if (get_bits_left(gb) >= 16) for (j = 0; j < 16; j++) sign_bits[j] = get_bits1 (gb); for (j = 0; j < 64; j++) if (q->coding_method[1][sb][j] > q->coding_method[0][sb][j]) q->coding_method[0][sb][j] = q->coding_method[1][sb][j]; fix_coding_method_array(sb, q->nb_channels, q->coding_method); channels = 1; } for (ch = 0; ch < channels; ch++) { zero_encoding = (get_bits_left(gb) >= 1) ? get_bits1(gb) : 0; type34_predictor = 0.0; type34_first = 1; for (j = 0; j < 128; ) { switch (q->coding_method[ch][sb][j / 2]) { case 8: if (get_bits_left(gb) >= 10) { if (zero_encoding) { for (k = 0; k < 5; k++) { if ((j + 2 * k) >= 128) break; samples[2 * k] = get_bits1(gb) ? dequant_1bit[joined_stereo][2 * get_bits1(gb)] : 0; } } else { n = get_bits(gb, 8); for (k = 0; k < 5; k++) samples[2 * k] = dequant_1bit[joined_stereo][random_dequant_index[n][k]]; } for (k = 0; k < 5; k++) samples[2 * k + 1] = SB_DITHERING_NOISE(sb,q->noise_idx); } else { for (k = 0; k < 10; k++) samples[k] = SB_DITHERING_NOISE(sb,q->noise_idx); } run = 10; break; case 10: if (get_bits_left(gb) >= 1) { float f = 0.81; if (get_bits1(gb)) f = -f; f -= noise_samples[((sb + 1) * (j +5 * ch + 1)) & 127] * 9.0 / 40.0; samples[0] = f; } else { samples[0] = SB_DITHERING_NOISE(sb,q->noise_idx); } run = 1; break; case 16: if (get_bits_left(gb) >= 10) { if (zero_encoding) { for (k = 0; k < 5; k++) { if ((j + k) >= 128) break; samples[k] = (get_bits1(gb) == 0) ? 0 : dequant_1bit[joined_stereo][2 * get_bits1(gb)]; } } else { n = get_bits (gb, 8); for (k = 0; k < 5; k++) samples[k] = dequant_1bit[joined_stereo][random_dequant_index[n][k]]; } } else { for (k = 0; k < 5; k++) samples[k] = SB_DITHERING_NOISE(sb,q->noise_idx); } run = 5; break; case 24: if (get_bits_left(gb) >= 7) { n = get_bits(gb, 7); for (k = 0; k < 3; k++) samples[k] = (random_dequant_type24[n][k] - 2.0) * 0.5; } else { for (k = 0; k < 3; k++) samples[k] = SB_DITHERING_NOISE(sb,q->noise_idx); } run = 3; break; case 30: if (get_bits_left(gb) >= 4) samples[0] = type30_dequant[qdm2_get_vlc(gb, &vlc_tab_type30, 0, 1)]; else samples[0] = SB_DITHERING_NOISE(sb,q->noise_idx); run = 1; break; case 34: if (get_bits_left(gb) >= 7) { if (type34_first) { type34_div = (float)(1 << get_bits(gb, 2)); samples[0] = ((float)get_bits(gb, 5) - 16.0) / 15.0; type34_predictor = samples[0]; type34_first = 0; } else { samples[0] = type34_delta[qdm2_get_vlc(gb, &vlc_tab_type34, 0, 1)] / type34_div + type34_predictor; type34_predictor = samples[0]; } } else { samples[0] = SB_DITHERING_NOISE(sb,q->noise_idx); } run = 1; break; default: samples[0] = SB_DITHERING_NOISE(sb,q->noise_idx); run = 1; break; } if (joined_stereo) { float tmp[10][MPA_MAX_CHANNELS]; for (k = 0; k < run; k++) { tmp[k][0] = samples[k]; tmp[k][1] = (sign_bits[(j + k) / 8]) ? -samples[k] : samples[k]; } for (chs = 0; chs < q->nb_channels; chs++) for (k = 0; k < run; k++) if ((j + k) < 128) q->sb_samples[chs][j + k][sb] = q->tone_level[chs][sb][((j + k)/2)] * tmp[k][chs]; } else { for (k = 0; k < run; k++) if ((j + k) < 128) q->sb_samples[ch][j + k][sb] = q->tone_level[ch][sb][(j + k)/2] * samples[k]; } j += run; } // j loop } // channel loop } // subband loop }
true
FFmpeg
64953f67f98da2e787aeb45cc7f504390fa32a69
static void synthfilt_build_sb_samples (QDM2Context *q, GetBitContext *gb, int length, int sb_min, int sb_max) { int sb, j, k, n, ch, run, channels; int joined_stereo, zero_encoding, chs; int type34_first; float type34_div = 0; float type34_predictor; float samples[10], sign_bits[16]; if (length == 0) { for (sb=sb_min; sb < sb_max; sb++) build_sb_samples_from_noise (q, sb); return; } for (sb = sb_min; sb < sb_max; sb++) { FIX_NOISE_IDX(q->noise_idx); channels = q->nb_channels; if (q->nb_channels <= 1 || sb < 12) joined_stereo = 0; else if (sb >= 24) joined_stereo = 1; else joined_stereo = (get_bits_left(gb) >= 1) ? get_bits1 (gb) : 0; if (joined_stereo) { if (get_bits_left(gb) >= 16) for (j = 0; j < 16; j++) sign_bits[j] = get_bits1 (gb); for (j = 0; j < 64; j++) if (q->coding_method[1][sb][j] > q->coding_method[0][sb][j]) q->coding_method[0][sb][j] = q->coding_method[1][sb][j]; fix_coding_method_array(sb, q->nb_channels, q->coding_method); channels = 1; } for (ch = 0; ch < channels; ch++) { zero_encoding = (get_bits_left(gb) >= 1) ? get_bits1(gb) : 0; type34_predictor = 0.0; type34_first = 1; for (j = 0; j < 128; ) { switch (q->coding_method[ch][sb][j / 2]) { case 8: if (get_bits_left(gb) >= 10) { if (zero_encoding) { for (k = 0; k < 5; k++) { if ((j + 2 * k) >= 128) break; samples[2 * k] = get_bits1(gb) ? dequant_1bit[joined_stereo][2 * get_bits1(gb)] : 0; } } else { n = get_bits(gb, 8); for (k = 0; k < 5; k++) samples[2 * k] = dequant_1bit[joined_stereo][random_dequant_index[n][k]]; } for (k = 0; k < 5; k++) samples[2 * k + 1] = SB_DITHERING_NOISE(sb,q->noise_idx); } else { for (k = 0; k < 10; k++) samples[k] = SB_DITHERING_NOISE(sb,q->noise_idx); } run = 10; break; case 10: if (get_bits_left(gb) >= 1) { float f = 0.81; if (get_bits1(gb)) f = -f; f -= noise_samples[((sb + 1) * (j +5 * ch + 1)) & 127] * 9.0 / 40.0; samples[0] = f; } else { samples[0] = SB_DITHERING_NOISE(sb,q->noise_idx); } run = 1; break; case 16: if (get_bits_left(gb) >= 10) { if (zero_encoding) { for (k = 0; k < 5; k++) { if ((j + k) >= 128) break; samples[k] = (get_bits1(gb) == 0) ? 0 : dequant_1bit[joined_stereo][2 * get_bits1(gb)]; } } else { n = get_bits (gb, 8); for (k = 0; k < 5; k++) samples[k] = dequant_1bit[joined_stereo][random_dequant_index[n][k]]; } } else { for (k = 0; k < 5; k++) samples[k] = SB_DITHERING_NOISE(sb,q->noise_idx); } run = 5; break; case 24: if (get_bits_left(gb) >= 7) { n = get_bits(gb, 7); for (k = 0; k < 3; k++) samples[k] = (random_dequant_type24[n][k] - 2.0) * 0.5; } else { for (k = 0; k < 3; k++) samples[k] = SB_DITHERING_NOISE(sb,q->noise_idx); } run = 3; break; case 30: if (get_bits_left(gb) >= 4) samples[0] = type30_dequant[qdm2_get_vlc(gb, &vlc_tab_type30, 0, 1)]; else samples[0] = SB_DITHERING_NOISE(sb,q->noise_idx); run = 1; break; case 34: if (get_bits_left(gb) >= 7) { if (type34_first) { type34_div = (float)(1 << get_bits(gb, 2)); samples[0] = ((float)get_bits(gb, 5) - 16.0) / 15.0; type34_predictor = samples[0]; type34_first = 0; } else { samples[0] = type34_delta[qdm2_get_vlc(gb, &vlc_tab_type34, 0, 1)] / type34_div + type34_predictor; type34_predictor = samples[0]; } } else { samples[0] = SB_DITHERING_NOISE(sb,q->noise_idx); } run = 1; break; default: samples[0] = SB_DITHERING_NOISE(sb,q->noise_idx); run = 1; break; } if (joined_stereo) { float tmp[10][MPA_MAX_CHANNELS]; for (k = 0; k < run; k++) { tmp[k][0] = samples[k]; tmp[k][1] = (sign_bits[(j + k) / 8]) ? -samples[k] : samples[k]; } for (chs = 0; chs < q->nb_channels; chs++) for (k = 0; k < run; k++) if ((j + k) < 128) q->sb_samples[chs][j + k][sb] = q->tone_level[chs][sb][((j + k)/2)] * tmp[k][chs]; } else { for (k = 0; k < run; k++) if ((j + k) < 128) q->sb_samples[ch][j + k][sb] = q->tone_level[ch][sb][(j + k)/2] * samples[k]; } j += run; } } } }
{ "code": [ " if (get_bits_left(gb) >= 4)", " samples[0] = type30_dequant[qdm2_get_vlc(gb, &vlc_tab_type30, 0, 1)];", " samples[0] = type34_delta[qdm2_get_vlc(gb, &vlc_tab_type34, 0, 1)] / type34_div + type34_predictor;", " type34_predictor = samples[0];" ], "line_no": [ 237, 239, 269, 263 ] }
static void FUNC_0 (QDM2Context *VAR_0, GetBitContext *VAR_1, int VAR_2, int VAR_3, int VAR_4) { int VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11; int VAR_12, VAR_13, VAR_14; int VAR_15; float VAR_16 = 0; float VAR_17; float VAR_18[10], VAR_19[16]; if (VAR_2 == 0) { for (VAR_5=VAR_3; VAR_5 < VAR_4; VAR_5++) build_sb_samples_from_noise (VAR_0, VAR_5); return; } for (VAR_5 = VAR_3; VAR_5 < VAR_4; VAR_5++) { FIX_NOISE_IDX(VAR_0->noise_idx); VAR_11 = VAR_0->nb_channels; if (VAR_0->nb_channels <= 1 || VAR_5 < 12) VAR_12 = 0; else if (VAR_5 >= 24) VAR_12 = 1; else VAR_12 = (get_bits_left(VAR_1) >= 1) ? get_bits1 (VAR_1) : 0; if (VAR_12) { if (get_bits_left(VAR_1) >= 16) for (VAR_6 = 0; VAR_6 < 16; VAR_6++) VAR_19[VAR_6] = get_bits1 (VAR_1); for (VAR_6 = 0; VAR_6 < 64; VAR_6++) if (VAR_0->coding_method[1][VAR_5][VAR_6] > VAR_0->coding_method[0][VAR_5][VAR_6]) VAR_0->coding_method[0][VAR_5][VAR_6] = VAR_0->coding_method[1][VAR_5][VAR_6]; fix_coding_method_array(VAR_5, VAR_0->nb_channels, VAR_0->coding_method); VAR_11 = 1; } for (VAR_9 = 0; VAR_9 < VAR_11; VAR_9++) { VAR_13 = (get_bits_left(VAR_1) >= 1) ? get_bits1(VAR_1) : 0; VAR_17 = 0.0; VAR_15 = 1; for (VAR_6 = 0; VAR_6 < 128; ) { switch (VAR_0->coding_method[VAR_9][VAR_5][VAR_6 / 2]) { case 8: if (get_bits_left(VAR_1) >= 10) { if (VAR_13) { for (VAR_7 = 0; VAR_7 < 5; VAR_7++) { if ((VAR_6 + 2 * VAR_7) >= 128) break; VAR_18[2 * VAR_7] = get_bits1(VAR_1) ? dequant_1bit[VAR_12][2 * get_bits1(VAR_1)] : 0; } } else { VAR_8 = get_bits(VAR_1, 8); for (VAR_7 = 0; VAR_7 < 5; VAR_7++) VAR_18[2 * VAR_7] = dequant_1bit[VAR_12][random_dequant_index[VAR_8][VAR_7]]; } for (VAR_7 = 0; VAR_7 < 5; VAR_7++) VAR_18[2 * VAR_7 + 1] = SB_DITHERING_NOISE(VAR_5,VAR_0->noise_idx); } else { for (VAR_7 = 0; VAR_7 < 10; VAR_7++) VAR_18[VAR_7] = SB_DITHERING_NOISE(VAR_5,VAR_0->noise_idx); } VAR_10 = 10; break; case 10: if (get_bits_left(VAR_1) >= 1) { float VAR_20 = 0.81; if (get_bits1(VAR_1)) VAR_20 = -VAR_20; VAR_20 -= noise_samples[((VAR_5 + 1) * (VAR_6 +5 * VAR_9 + 1)) & 127] * 9.0 / 40.0; VAR_18[0] = VAR_20; } else { VAR_18[0] = SB_DITHERING_NOISE(VAR_5,VAR_0->noise_idx); } VAR_10 = 1; break; case 16: if (get_bits_left(VAR_1) >= 10) { if (VAR_13) { for (VAR_7 = 0; VAR_7 < 5; VAR_7++) { if ((VAR_6 + VAR_7) >= 128) break; VAR_18[VAR_7] = (get_bits1(VAR_1) == 0) ? 0 : dequant_1bit[VAR_12][2 * get_bits1(VAR_1)]; } } else { VAR_8 = get_bits (VAR_1, 8); for (VAR_7 = 0; VAR_7 < 5; VAR_7++) VAR_18[VAR_7] = dequant_1bit[VAR_12][random_dequant_index[VAR_8][VAR_7]]; } } else { for (VAR_7 = 0; VAR_7 < 5; VAR_7++) VAR_18[VAR_7] = SB_DITHERING_NOISE(VAR_5,VAR_0->noise_idx); } VAR_10 = 5; break; case 24: if (get_bits_left(VAR_1) >= 7) { VAR_8 = get_bits(VAR_1, 7); for (VAR_7 = 0; VAR_7 < 3; VAR_7++) VAR_18[VAR_7] = (random_dequant_type24[VAR_8][VAR_7] - 2.0) * 0.5; } else { for (VAR_7 = 0; VAR_7 < 3; VAR_7++) VAR_18[VAR_7] = SB_DITHERING_NOISE(VAR_5,VAR_0->noise_idx); } VAR_10 = 3; break; case 30: if (get_bits_left(VAR_1) >= 4) VAR_18[0] = type30_dequant[qdm2_get_vlc(VAR_1, &vlc_tab_type30, 0, 1)]; else VAR_18[0] = SB_DITHERING_NOISE(VAR_5,VAR_0->noise_idx); VAR_10 = 1; break; case 34: if (get_bits_left(VAR_1) >= 7) { if (VAR_15) { VAR_16 = (float)(1 << get_bits(VAR_1, 2)); VAR_18[0] = ((float)get_bits(VAR_1, 5) - 16.0) / 15.0; VAR_17 = VAR_18[0]; VAR_15 = 0; } else { VAR_18[0] = type34_delta[qdm2_get_vlc(VAR_1, &vlc_tab_type34, 0, 1)] / VAR_16 + VAR_17; VAR_17 = VAR_18[0]; } } else { VAR_18[0] = SB_DITHERING_NOISE(VAR_5,VAR_0->noise_idx); } VAR_10 = 1; break; default: VAR_18[0] = SB_DITHERING_NOISE(VAR_5,VAR_0->noise_idx); VAR_10 = 1; break; } if (VAR_12) { float VAR_21[10][MPA_MAX_CHANNELS]; for (VAR_7 = 0; VAR_7 < VAR_10; VAR_7++) { VAR_21[VAR_7][0] = VAR_18[VAR_7]; VAR_21[VAR_7][1] = (VAR_19[(VAR_6 + VAR_7) / 8]) ? -VAR_18[VAR_7] : VAR_18[VAR_7]; } for (VAR_14 = 0; VAR_14 < VAR_0->nb_channels; VAR_14++) for (VAR_7 = 0; VAR_7 < VAR_10; VAR_7++) if ((VAR_6 + VAR_7) < 128) VAR_0->sb_samples[VAR_14][VAR_6 + VAR_7][VAR_5] = VAR_0->tone_level[VAR_14][VAR_5][((VAR_6 + VAR_7)/2)] * VAR_21[VAR_7][VAR_14]; } else { for (VAR_7 = 0; VAR_7 < VAR_10; VAR_7++) if ((VAR_6 + VAR_7) < 128) VAR_0->sb_samples[VAR_9][VAR_6 + VAR_7][VAR_5] = VAR_0->tone_level[VAR_9][VAR_5][(VAR_6 + VAR_7)/2] * VAR_18[VAR_7]; } VAR_6 += VAR_10; } } } }
[ "static void FUNC_0 (QDM2Context *VAR_0, GetBitContext *VAR_1, int VAR_2, int VAR_3, int VAR_4)\n{", "int VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11;", "int VAR_12, VAR_13, VAR_14;", "int VAR_15;", "float VAR_16 = 0;", "float VAR_17;", "float VAR_18[10], VAR_19[16];", "if (VAR_2 == 0) {", "for (VAR_5=VAR_3; VAR_5 < VAR_4; VAR_5++)", "build_sb_samples_from_noise (VAR_0, VAR_5);", "return;", "}", "for (VAR_5 = VAR_3; VAR_5 < VAR_4; VAR_5++) {", "FIX_NOISE_IDX(VAR_0->noise_idx);", "VAR_11 = VAR_0->nb_channels;", "if (VAR_0->nb_channels <= 1 || VAR_5 < 12)\nVAR_12 = 0;", "else if (VAR_5 >= 24)\nVAR_12 = 1;", "else\nVAR_12 = (get_bits_left(VAR_1) >= 1) ? get_bits1 (VAR_1) : 0;", "if (VAR_12) {", "if (get_bits_left(VAR_1) >= 16)\nfor (VAR_6 = 0; VAR_6 < 16; VAR_6++)", "VAR_19[VAR_6] = get_bits1 (VAR_1);", "for (VAR_6 = 0; VAR_6 < 64; VAR_6++)", "if (VAR_0->coding_method[1][VAR_5][VAR_6] > VAR_0->coding_method[0][VAR_5][VAR_6])\nVAR_0->coding_method[0][VAR_5][VAR_6] = VAR_0->coding_method[1][VAR_5][VAR_6];", "fix_coding_method_array(VAR_5, VAR_0->nb_channels, VAR_0->coding_method);", "VAR_11 = 1;", "}", "for (VAR_9 = 0; VAR_9 < VAR_11; VAR_9++) {", "VAR_13 = (get_bits_left(VAR_1) >= 1) ? get_bits1(VAR_1) : 0;", "VAR_17 = 0.0;", "VAR_15 = 1;", "for (VAR_6 = 0; VAR_6 < 128; ) {", "switch (VAR_0->coding_method[VAR_9][VAR_5][VAR_6 / 2]) {", "case 8:\nif (get_bits_left(VAR_1) >= 10) {", "if (VAR_13) {", "for (VAR_7 = 0; VAR_7 < 5; VAR_7++) {", "if ((VAR_6 + 2 * VAR_7) >= 128)\nbreak;", "VAR_18[2 * VAR_7] = get_bits1(VAR_1) ? dequant_1bit[VAR_12][2 * get_bits1(VAR_1)] : 0;", "}", "} else {", "VAR_8 = get_bits(VAR_1, 8);", "for (VAR_7 = 0; VAR_7 < 5; VAR_7++)", "VAR_18[2 * VAR_7] = dequant_1bit[VAR_12][random_dequant_index[VAR_8][VAR_7]];", "}", "for (VAR_7 = 0; VAR_7 < 5; VAR_7++)", "VAR_18[2 * VAR_7 + 1] = SB_DITHERING_NOISE(VAR_5,VAR_0->noise_idx);", "} else {", "for (VAR_7 = 0; VAR_7 < 10; VAR_7++)", "VAR_18[VAR_7] = SB_DITHERING_NOISE(VAR_5,VAR_0->noise_idx);", "}", "VAR_10 = 10;", "break;", "case 10:\nif (get_bits_left(VAR_1) >= 1) {", "float VAR_20 = 0.81;", "if (get_bits1(VAR_1))\nVAR_20 = -VAR_20;", "VAR_20 -= noise_samples[((VAR_5 + 1) * (VAR_6 +5 * VAR_9 + 1)) & 127] * 9.0 / 40.0;", "VAR_18[0] = VAR_20;", "} else {", "VAR_18[0] = SB_DITHERING_NOISE(VAR_5,VAR_0->noise_idx);", "}", "VAR_10 = 1;", "break;", "case 16:\nif (get_bits_left(VAR_1) >= 10) {", "if (VAR_13) {", "for (VAR_7 = 0; VAR_7 < 5; VAR_7++) {", "if ((VAR_6 + VAR_7) >= 128)\nbreak;", "VAR_18[VAR_7] = (get_bits1(VAR_1) == 0) ? 0 : dequant_1bit[VAR_12][2 * get_bits1(VAR_1)];", "}", "} else {", "VAR_8 = get_bits (VAR_1, 8);", "for (VAR_7 = 0; VAR_7 < 5; VAR_7++)", "VAR_18[VAR_7] = dequant_1bit[VAR_12][random_dequant_index[VAR_8][VAR_7]];", "}", "} else {", "for (VAR_7 = 0; VAR_7 < 5; VAR_7++)", "VAR_18[VAR_7] = SB_DITHERING_NOISE(VAR_5,VAR_0->noise_idx);", "}", "VAR_10 = 5;", "break;", "case 24:\nif (get_bits_left(VAR_1) >= 7) {", "VAR_8 = get_bits(VAR_1, 7);", "for (VAR_7 = 0; VAR_7 < 3; VAR_7++)", "VAR_18[VAR_7] = (random_dequant_type24[VAR_8][VAR_7] - 2.0) * 0.5;", "} else {", "for (VAR_7 = 0; VAR_7 < 3; VAR_7++)", "VAR_18[VAR_7] = SB_DITHERING_NOISE(VAR_5,VAR_0->noise_idx);", "}", "VAR_10 = 3;", "break;", "case 30:\nif (get_bits_left(VAR_1) >= 4)\nVAR_18[0] = type30_dequant[qdm2_get_vlc(VAR_1, &vlc_tab_type30, 0, 1)];", "else\nVAR_18[0] = SB_DITHERING_NOISE(VAR_5,VAR_0->noise_idx);", "VAR_10 = 1;", "break;", "case 34:\nif (get_bits_left(VAR_1) >= 7) {", "if (VAR_15) {", "VAR_16 = (float)(1 << get_bits(VAR_1, 2));", "VAR_18[0] = ((float)get_bits(VAR_1, 5) - 16.0) / 15.0;", "VAR_17 = VAR_18[0];", "VAR_15 = 0;", "} else {", "VAR_18[0] = type34_delta[qdm2_get_vlc(VAR_1, &vlc_tab_type34, 0, 1)] / VAR_16 + VAR_17;", "VAR_17 = VAR_18[0];", "}", "} else {", "VAR_18[0] = SB_DITHERING_NOISE(VAR_5,VAR_0->noise_idx);", "}", "VAR_10 = 1;", "break;", "default:\nVAR_18[0] = SB_DITHERING_NOISE(VAR_5,VAR_0->noise_idx);", "VAR_10 = 1;", "break;", "}", "if (VAR_12) {", "float VAR_21[10][MPA_MAX_CHANNELS];", "for (VAR_7 = 0; VAR_7 < VAR_10; VAR_7++) {", "VAR_21[VAR_7][0] = VAR_18[VAR_7];", "VAR_21[VAR_7][1] = (VAR_19[(VAR_6 + VAR_7) / 8]) ? -VAR_18[VAR_7] : VAR_18[VAR_7];", "}", "for (VAR_14 = 0; VAR_14 < VAR_0->nb_channels; VAR_14++)", "for (VAR_7 = 0; VAR_7 < VAR_10; VAR_7++)", "if ((VAR_6 + VAR_7) < 128)\nVAR_0->sb_samples[VAR_14][VAR_6 + VAR_7][VAR_5] = VAR_0->tone_level[VAR_14][VAR_5][((VAR_6 + VAR_7)/2)] * VAR_21[VAR_7][VAR_14];", "} else {", "for (VAR_7 = 0; VAR_7 < VAR_10; VAR_7++)", "if ((VAR_6 + VAR_7) < 128)\nVAR_0->sb_samples[VAR_9][VAR_6 + VAR_7][VAR_5] = VAR_0->tone_level[VAR_9][VAR_5][(VAR_6 + VAR_7)/2] * VAR_18[VAR_7];", "}", "VAR_6 += VAR_10;", "}", "}", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 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 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 23 ], [ 25 ], [ 29 ], [ 31 ], [ 35 ], [ 37 ], [ 41 ], [ 45, 47 ], [ 49, 51 ], [ 53, 55 ], [ 59 ], [ 61, 63 ], [ 65 ], [ 69 ], [ 71, 73 ], [ 77 ], [ 79 ], [ 81 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 95 ], [ 97 ], [ 99, 101 ], [ 103 ], [ 105 ], [ 107, 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 143, 145 ], [ 147 ], [ 151, 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 167 ], [ 171, 173 ], [ 175 ], [ 177 ], [ 179, 181 ], [ 183 ], [ 185 ], [ 187 ], [ 189 ], [ 191 ], [ 193 ], [ 195 ], [ 197 ], [ 199 ], [ 201 ], [ 203 ], [ 205 ], [ 207 ], [ 211, 213 ], [ 215 ], [ 217 ], [ 219 ], [ 221 ], [ 223 ], [ 225 ], [ 227 ], [ 229 ], [ 231 ], [ 235, 237, 239 ], [ 241, 243 ], [ 247 ], [ 249 ], [ 253, 255 ], [ 257 ], [ 259 ], [ 261 ], [ 263 ], [ 265 ], [ 267 ], [ 269 ], [ 271 ], [ 273 ], [ 275 ], [ 277 ], [ 279 ], [ 281 ], [ 283 ], [ 287, 289 ], [ 291 ], [ 293 ], [ 295 ], [ 299 ], [ 301 ], [ 305 ], [ 307 ], [ 309 ], [ 311 ], [ 313 ], [ 315 ], [ 317, 319 ], [ 321 ], [ 323 ], [ 325, 327 ], [ 329 ], [ 333 ], [ 335 ], [ 337 ], [ 339 ], [ 341 ] ]
9,927
static void test_keyval_visit_alternate(void) { Error *err = NULL; Visitor *v; QDict *qdict; AltNumStr *ans; AltNumInt *ani; /* * Can't do scalar alternate variants other than string. You get * the string variant if there is one, else an error. */ qdict = keyval_parse("a=1,b=2", NULL, &error_abort); v = qobject_input_visitor_new_keyval(QOBJECT(qdict)); QDECREF(qdict); visit_start_struct(v, NULL, NULL, 0, &error_abort); visit_type_AltNumStr(v, "a", &ans, &error_abort); g_assert_cmpint(ans->type, ==, QTYPE_QSTRING); g_assert_cmpstr(ans->u.s, ==, "1"); qapi_free_AltNumStr(ans); visit_type_AltNumInt(v, "a", &ani, &err); error_free_or_abort(&err); visit_end_struct(v, NULL); visit_free(v); }
true
qemu
c0644771ebedbd8f47f3c24816445e30111d226b
static void test_keyval_visit_alternate(void) { Error *err = NULL; Visitor *v; QDict *qdict; AltNumStr *ans; AltNumInt *ani; qdict = keyval_parse("a=1,b=2", NULL, &error_abort); v = qobject_input_visitor_new_keyval(QOBJECT(qdict)); QDECREF(qdict); visit_start_struct(v, NULL, NULL, 0, &error_abort); visit_type_AltNumStr(v, "a", &ans, &error_abort); g_assert_cmpint(ans->type, ==, QTYPE_QSTRING); g_assert_cmpstr(ans->u.s, ==, "1"); qapi_free_AltNumStr(ans); visit_type_AltNumInt(v, "a", &ani, &err); error_free_or_abort(&err); visit_end_struct(v, NULL); visit_free(v); }
{ "code": [ " AltNumStr *ans;", " qdict = keyval_parse(\"a=1,b=2\", NULL, &error_abort);", " visit_type_AltNumStr(v, \"a\", &ans, &error_abort);", " g_assert_cmpint(ans->type, ==, QTYPE_QSTRING);", " g_assert_cmpstr(ans->u.s, ==, \"1\");", " qapi_free_AltNumStr(ans);", " visit_type_AltNumInt(v, \"a\", &ani, &err);" ], "line_no": [ 11, 25, 33, 35, 37, 39, 41 ] }
static void FUNC_0(void) { Error *err = NULL; Visitor *v; QDict *qdict; AltNumStr *ans; AltNumInt *ani; qdict = keyval_parse("a=1,b=2", NULL, &error_abort); v = qobject_input_visitor_new_keyval(QOBJECT(qdict)); QDECREF(qdict); visit_start_struct(v, NULL, NULL, 0, &error_abort); visit_type_AltNumStr(v, "a", &ans, &error_abort); g_assert_cmpint(ans->type, ==, QTYPE_QSTRING); g_assert_cmpstr(ans->u.s, ==, "1"); qapi_free_AltNumStr(ans); visit_type_AltNumInt(v, "a", &ani, &err); error_free_or_abort(&err); visit_end_struct(v, NULL); visit_free(v); }
[ "static void FUNC_0(void)\n{", "Error *err = NULL;", "Visitor *v;", "QDict *qdict;", "AltNumStr *ans;", "AltNumInt *ani;", "qdict = keyval_parse(\"a=1,b=2\", NULL, &error_abort);", "v = qobject_input_visitor_new_keyval(QOBJECT(qdict));", "QDECREF(qdict);", "visit_start_struct(v, NULL, NULL, 0, &error_abort);", "visit_type_AltNumStr(v, \"a\", &ans, &error_abort);", "g_assert_cmpint(ans->type, ==, QTYPE_QSTRING);", "g_assert_cmpstr(ans->u.s, ==, \"1\");", "qapi_free_AltNumStr(ans);", "visit_type_AltNumInt(v, \"a\", &ani, &err);", "error_free_or_abort(&err);", "visit_end_struct(v, NULL);", "visit_free(v);", "}" ]
[ 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ] ]
9,928
static int svq3_decode_slice_header(AVCodecContext *avctx) { SVQ3Context *svq3 = avctx->priv_data; H264Context *h = &svq3->h; MpegEncContext *s = &h->s; const int mb_xy = h->mb_xy; int i, header; header = get_bits(&s->gb, 8); if (((header & 0x9F) != 1 && (header & 0x9F) != 2) || (header & 0x60) == 0) { /* TODO: what? */ av_log(avctx, AV_LOG_ERROR, "unsupported slice header (%02X)\n", header); return -1; } else { int length = (header >> 5) & 3; svq3->next_slice_index = get_bits_count(&s->gb) + 8*show_bits(&s->gb, 8*length) + 8*length; if (svq3->next_slice_index > s->gb.size_in_bits) { av_log(avctx, AV_LOG_ERROR, "slice after bitstream end\n"); return -1; } s->gb.size_in_bits = svq3->next_slice_index - 8*(length - 1); skip_bits(&s->gb, 8); if (svq3->watermark_key) { uint32_t header = AV_RL32(&s->gb.buffer[(get_bits_count(&s->gb)>>3)+1]); AV_WL32(&s->gb.buffer[(get_bits_count(&s->gb)>>3)+1], header ^ svq3->watermark_key); } if (length > 0) { memcpy((uint8_t *) &s->gb.buffer[get_bits_count(&s->gb) >> 3], &s->gb.buffer[s->gb.size_in_bits >> 3], (length - 1)); } skip_bits_long(&s->gb, 0); } if ((i = svq3_get_ue_golomb(&s->gb)) == INVALID_VLC || i >= 3){ av_log(h->s.avctx, AV_LOG_ERROR, "illegal slice type %d \n", i); return -1; } h->slice_type = golomb_to_pict_type[i]; if ((header & 0x9F) == 2) { i = (s->mb_num < 64) ? 6 : (1 + av_log2 (s->mb_num - 1)); s->mb_skip_run = get_bits(&s->gb, i) - (s->mb_x + (s->mb_y * s->mb_width)); } else { skip_bits1(&s->gb); s->mb_skip_run = 0; } h->slice_num = get_bits(&s->gb, 8); s->qscale = get_bits(&s->gb, 5); s->adaptive_quant = get_bits1(&s->gb); /* unknown fields */ skip_bits1(&s->gb); if (svq3->unknown_flag) { skip_bits1(&s->gb); } skip_bits1(&s->gb); skip_bits(&s->gb, 2); while (get_bits1(&s->gb)) { skip_bits(&s->gb, 8); } /* reset intra predictors and invalidate motion vector references */ if (s->mb_x > 0) { memset(h->intra4x4_pred_mode+h->mb2br_xy[mb_xy - 1 ]+3, -1, 4*sizeof(int8_t)); memset(h->intra4x4_pred_mode+h->mb2br_xy[mb_xy - s->mb_x] , -1, 8*sizeof(int8_t)*s->mb_x); } if (s->mb_y > 0) { memset(h->intra4x4_pred_mode+h->mb2br_xy[mb_xy - s->mb_stride], -1, 8*sizeof(int8_t)*(s->mb_width - s->mb_x)); if (s->mb_x > 0) { h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride - 1]+3] = -1; } } return 0; }
false
FFmpeg
979bea13003ef489d95d2538ac2fb1c26c6f103b
static int svq3_decode_slice_header(AVCodecContext *avctx) { SVQ3Context *svq3 = avctx->priv_data; H264Context *h = &svq3->h; MpegEncContext *s = &h->s; const int mb_xy = h->mb_xy; int i, header; header = get_bits(&s->gb, 8); if (((header & 0x9F) != 1 && (header & 0x9F) != 2) || (header & 0x60) == 0) { av_log(avctx, AV_LOG_ERROR, "unsupported slice header (%02X)\n", header); return -1; } else { int length = (header >> 5) & 3; svq3->next_slice_index = get_bits_count(&s->gb) + 8*show_bits(&s->gb, 8*length) + 8*length; if (svq3->next_slice_index > s->gb.size_in_bits) { av_log(avctx, AV_LOG_ERROR, "slice after bitstream end\n"); return -1; } s->gb.size_in_bits = svq3->next_slice_index - 8*(length - 1); skip_bits(&s->gb, 8); if (svq3->watermark_key) { uint32_t header = AV_RL32(&s->gb.buffer[(get_bits_count(&s->gb)>>3)+1]); AV_WL32(&s->gb.buffer[(get_bits_count(&s->gb)>>3)+1], header ^ svq3->watermark_key); } if (length > 0) { memcpy((uint8_t *) &s->gb.buffer[get_bits_count(&s->gb) >> 3], &s->gb.buffer[s->gb.size_in_bits >> 3], (length - 1)); } skip_bits_long(&s->gb, 0); } if ((i = svq3_get_ue_golomb(&s->gb)) == INVALID_VLC || i >= 3){ av_log(h->s.avctx, AV_LOG_ERROR, "illegal slice type %d \n", i); return -1; } h->slice_type = golomb_to_pict_type[i]; if ((header & 0x9F) == 2) { i = (s->mb_num < 64) ? 6 : (1 + av_log2 (s->mb_num - 1)); s->mb_skip_run = get_bits(&s->gb, i) - (s->mb_x + (s->mb_y * s->mb_width)); } else { skip_bits1(&s->gb); s->mb_skip_run = 0; } h->slice_num = get_bits(&s->gb, 8); s->qscale = get_bits(&s->gb, 5); s->adaptive_quant = get_bits1(&s->gb); skip_bits1(&s->gb); if (svq3->unknown_flag) { skip_bits1(&s->gb); } skip_bits1(&s->gb); skip_bits(&s->gb, 2); while (get_bits1(&s->gb)) { skip_bits(&s->gb, 8); } if (s->mb_x > 0) { memset(h->intra4x4_pred_mode+h->mb2br_xy[mb_xy - 1 ]+3, -1, 4*sizeof(int8_t)); memset(h->intra4x4_pred_mode+h->mb2br_xy[mb_xy - s->mb_x] , -1, 8*sizeof(int8_t)*s->mb_x); } if (s->mb_y > 0) { memset(h->intra4x4_pred_mode+h->mb2br_xy[mb_xy - s->mb_stride], -1, 8*sizeof(int8_t)*(s->mb_width - s->mb_x)); if (s->mb_x > 0) { h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride - 1]+3] = -1; } } return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(AVCodecContext *VAR_0) { SVQ3Context *svq3 = VAR_0->priv_data; H264Context *h = &svq3->h; MpegEncContext *s = &h->s; const int VAR_1 = h->VAR_1; int VAR_2, VAR_3; VAR_3 = get_bits(&s->gb, 8); if (((VAR_3 & 0x9F) != 1 && (VAR_3 & 0x9F) != 2) || (VAR_3 & 0x60) == 0) { av_log(VAR_0, AV_LOG_ERROR, "unsupported slice VAR_3 (%02X)\n", VAR_3); return -1; } else { int VAR_4 = (VAR_3 >> 5) & 3; svq3->next_slice_index = get_bits_count(&s->gb) + 8*show_bits(&s->gb, 8*VAR_4) + 8*VAR_4; if (svq3->next_slice_index > s->gb.size_in_bits) { av_log(VAR_0, AV_LOG_ERROR, "slice after bitstream end\n"); return -1; } s->gb.size_in_bits = svq3->next_slice_index - 8*(VAR_4 - 1); skip_bits(&s->gb, 8); if (svq3->watermark_key) { uint32_t VAR_3 = AV_RL32(&s->gb.buffer[(get_bits_count(&s->gb)>>3)+1]); AV_WL32(&s->gb.buffer[(get_bits_count(&s->gb)>>3)+1], VAR_3 ^ svq3->watermark_key); } if (VAR_4 > 0) { memcpy((uint8_t *) &s->gb.buffer[get_bits_count(&s->gb) >> 3], &s->gb.buffer[s->gb.size_in_bits >> 3], (VAR_4 - 1)); } skip_bits_long(&s->gb, 0); } if ((VAR_2 = svq3_get_ue_golomb(&s->gb)) == INVALID_VLC || VAR_2 >= 3){ av_log(h->s.VAR_0, AV_LOG_ERROR, "illegal slice type %d \n", VAR_2); return -1; } h->slice_type = golomb_to_pict_type[VAR_2]; if ((VAR_3 & 0x9F) == 2) { VAR_2 = (s->mb_num < 64) ? 6 : (1 + av_log2 (s->mb_num - 1)); s->mb_skip_run = get_bits(&s->gb, VAR_2) - (s->mb_x + (s->mb_y * s->mb_width)); } else { skip_bits1(&s->gb); s->mb_skip_run = 0; } h->slice_num = get_bits(&s->gb, 8); s->qscale = get_bits(&s->gb, 5); s->adaptive_quant = get_bits1(&s->gb); skip_bits1(&s->gb); if (svq3->unknown_flag) { skip_bits1(&s->gb); } skip_bits1(&s->gb); skip_bits(&s->gb, 2); while (get_bits1(&s->gb)) { skip_bits(&s->gb, 8); } if (s->mb_x > 0) { memset(h->intra4x4_pred_mode+h->mb2br_xy[VAR_1 - 1 ]+3, -1, 4*sizeof(int8_t)); memset(h->intra4x4_pred_mode+h->mb2br_xy[VAR_1 - s->mb_x] , -1, 8*sizeof(int8_t)*s->mb_x); } if (s->mb_y > 0) { memset(h->intra4x4_pred_mode+h->mb2br_xy[VAR_1 - s->mb_stride], -1, 8*sizeof(int8_t)*(s->mb_width - s->mb_x)); if (s->mb_x > 0) { h->intra4x4_pred_mode[h->mb2br_xy[VAR_1 - s->mb_stride - 1]+3] = -1; } } return 0; }
[ "static int FUNC_0(AVCodecContext *VAR_0)\n{", "SVQ3Context *svq3 = VAR_0->priv_data;", "H264Context *h = &svq3->h;", "MpegEncContext *s = &h->s;", "const int VAR_1 = h->VAR_1;", "int VAR_2, VAR_3;", "VAR_3 = get_bits(&s->gb, 8);", "if (((VAR_3 & 0x9F) != 1 && (VAR_3 & 0x9F) != 2) || (VAR_3 & 0x60) == 0) {", "av_log(VAR_0, AV_LOG_ERROR, \"unsupported slice VAR_3 (%02X)\\n\", VAR_3);", "return -1;", "} else {", "int VAR_4 = (VAR_3 >> 5) & 3;", "svq3->next_slice_index = get_bits_count(&s->gb) + 8*show_bits(&s->gb, 8*VAR_4) + 8*VAR_4;", "if (svq3->next_slice_index > s->gb.size_in_bits) {", "av_log(VAR_0, AV_LOG_ERROR, \"slice after bitstream end\\n\");", "return -1;", "}", "s->gb.size_in_bits = svq3->next_slice_index - 8*(VAR_4 - 1);", "skip_bits(&s->gb, 8);", "if (svq3->watermark_key) {", "uint32_t VAR_3 = AV_RL32(&s->gb.buffer[(get_bits_count(&s->gb)>>3)+1]);", "AV_WL32(&s->gb.buffer[(get_bits_count(&s->gb)>>3)+1], VAR_3 ^ svq3->watermark_key);", "}", "if (VAR_4 > 0) {", "memcpy((uint8_t *) &s->gb.buffer[get_bits_count(&s->gb) >> 3],\n&s->gb.buffer[s->gb.size_in_bits >> 3], (VAR_4 - 1));", "}", "skip_bits_long(&s->gb, 0);", "}", "if ((VAR_2 = svq3_get_ue_golomb(&s->gb)) == INVALID_VLC || VAR_2 >= 3){", "av_log(h->s.VAR_0, AV_LOG_ERROR, \"illegal slice type %d \\n\", VAR_2);", "return -1;", "}", "h->slice_type = golomb_to_pict_type[VAR_2];", "if ((VAR_3 & 0x9F) == 2) {", "VAR_2 = (s->mb_num < 64) ? 6 : (1 + av_log2 (s->mb_num - 1));", "s->mb_skip_run = get_bits(&s->gb, VAR_2) - (s->mb_x + (s->mb_y * s->mb_width));", "} else {", "skip_bits1(&s->gb);", "s->mb_skip_run = 0;", "}", "h->slice_num = get_bits(&s->gb, 8);", "s->qscale = get_bits(&s->gb, 5);", "s->adaptive_quant = get_bits1(&s->gb);", "skip_bits1(&s->gb);", "if (svq3->unknown_flag) {", "skip_bits1(&s->gb);", "}", "skip_bits1(&s->gb);", "skip_bits(&s->gb, 2);", "while (get_bits1(&s->gb)) {", "skip_bits(&s->gb, 8);", "}", "if (s->mb_x > 0) {", "memset(h->intra4x4_pred_mode+h->mb2br_xy[VAR_1 - 1 ]+3, -1, 4*sizeof(int8_t));", "memset(h->intra4x4_pred_mode+h->mb2br_xy[VAR_1 - s->mb_x] , -1, 8*sizeof(int8_t)*s->mb_x);", "}", "if (s->mb_y > 0) {", "memset(h->intra4x4_pred_mode+h->mb2br_xy[VAR_1 - s->mb_stride], -1, 8*sizeof(int8_t)*(s->mb_width - s->mb_x));", "if (s->mb_x > 0) {", "h->intra4x4_pred_mode[h->mb2br_xy[VAR_1 - s->mb_stride - 1]+3] = -1;", "}", "}", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 21 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 35 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 49 ], [ 51 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65, 67 ], [ 69 ], [ 71 ], [ 73 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 87 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 107 ], [ 109 ], [ 111 ], [ 117 ], [ 121 ], [ 123 ], [ 125 ], [ 129 ], [ 131 ], [ 135 ], [ 137 ], [ 139 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 169 ], [ 171 ] ]
9,930
void avfilter_default_start_frame(AVFilterLink *link, AVFilterPicRef *picref) { AVFilterLink *out = NULL; if(link->dst->output_count) out = link->dst->outputs[0]; if(out) { out->outpic = avfilter_get_video_buffer(out, AV_PERM_WRITE, link->w, link->h); out->outpic->pts = picref->pts; avfilter_start_frame(out, avfilter_ref_pic(out->outpic, ~0)); } }
true
FFmpeg
b5eab66e9fe6c93056e414b0b4a70a34948843e1
void avfilter_default_start_frame(AVFilterLink *link, AVFilterPicRef *picref) { AVFilterLink *out = NULL; if(link->dst->output_count) out = link->dst->outputs[0]; if(out) { out->outpic = avfilter_get_video_buffer(out, AV_PERM_WRITE, link->w, link->h); out->outpic->pts = picref->pts; avfilter_start_frame(out, avfilter_ref_pic(out->outpic, ~0)); } }
{ "code": [ " out->outpic = avfilter_get_video_buffer(out, AV_PERM_WRITE, link->w, link->h);" ], "line_no": [ 17 ] }
void FUNC_0(AVFilterLink *VAR_0, AVFilterPicRef *VAR_1) { AVFilterLink *out = NULL; if(VAR_0->dst->output_count) out = VAR_0->dst->outputs[0]; if(out) { out->outpic = avfilter_get_video_buffer(out, AV_PERM_WRITE, VAR_0->w, VAR_0->h); out->outpic->pts = VAR_1->pts; avfilter_start_frame(out, avfilter_ref_pic(out->outpic, ~0)); } }
[ "void FUNC_0(AVFilterLink *VAR_0, AVFilterPicRef *VAR_1)\n{", "AVFilterLink *out = NULL;", "if(VAR_0->dst->output_count)\nout = VAR_0->dst->outputs[0];", "if(out) {", "out->outpic = avfilter_get_video_buffer(out, AV_PERM_WRITE, VAR_0->w, VAR_0->h);", "out->outpic->pts = VAR_1->pts;", "avfilter_start_frame(out, avfilter_ref_pic(out->outpic, ~0));", "}", "}" ]
[ 0, 0, 0, 0, 1, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9, 11 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ] ]
9,931
int load_aout(const char *filename, target_phys_addr_t addr, int max_sz, int bswap_needed, target_phys_addr_t target_page_size) { int fd, size, ret; struct exec e; uint32_t magic; fd = open(filename, O_RDONLY | O_BINARY); if (fd < 0) return -1; size = read(fd, &e, sizeof(e)); if (size < 0) goto fail; if (bswap_needed) { bswap_ahdr(&e); } magic = N_MAGIC(e); switch (magic) { case ZMAGIC: case QMAGIC: case OMAGIC: if (e.a_text + e.a_data > max_sz) goto fail; lseek(fd, N_TXTOFF(e), SEEK_SET); size = read_targphys(filename, fd, addr, e.a_text + e.a_data); if (size < 0) goto fail; break; case NMAGIC: if (N_DATADDR(e, target_page_size) + e.a_data > max_sz) goto fail; lseek(fd, N_TXTOFF(e), SEEK_SET); size = read_targphys(filename, fd, addr, e.a_text); if (size < 0) goto fail; ret = read_targphys(filename, fd, addr + N_DATADDR(e, target_page_size), e.a_data); if (ret < 0) goto fail; size += ret; break; default: goto fail; } close(fd); return size; fail: close(fd); return -1; }
true
qemu
725e14e91f80b6b2c07b75b66b7b042a9fa9340c
int load_aout(const char *filename, target_phys_addr_t addr, int max_sz, int bswap_needed, target_phys_addr_t target_page_size) { int fd, size, ret; struct exec e; uint32_t magic; fd = open(filename, O_RDONLY | O_BINARY); if (fd < 0) return -1; size = read(fd, &e, sizeof(e)); if (size < 0) goto fail; if (bswap_needed) { bswap_ahdr(&e); } magic = N_MAGIC(e); switch (magic) { case ZMAGIC: case QMAGIC: case OMAGIC: if (e.a_text + e.a_data > max_sz) goto fail; lseek(fd, N_TXTOFF(e), SEEK_SET); size = read_targphys(filename, fd, addr, e.a_text + e.a_data); if (size < 0) goto fail; break; case NMAGIC: if (N_DATADDR(e, target_page_size) + e.a_data > max_sz) goto fail; lseek(fd, N_TXTOFF(e), SEEK_SET); size = read_targphys(filename, fd, addr, e.a_text); if (size < 0) goto fail; ret = read_targphys(filename, fd, addr + N_DATADDR(e, target_page_size), e.a_data); if (ret < 0) goto fail; size += ret; break; default: goto fail; } close(fd); return size; fail: close(fd); return -1; }
{ "code": [ " int fd, size, ret;" ], "line_no": [ 7 ] }
int FUNC_0(const char *VAR_0, target_phys_addr_t VAR_1, int VAR_2, int VAR_3, target_phys_addr_t VAR_4) { int VAR_5, VAR_6, VAR_7; struct exec VAR_8; uint32_t magic; VAR_5 = open(VAR_0, O_RDONLY | O_BINARY); if (VAR_5 < 0) return -1; VAR_6 = read(VAR_5, &VAR_8, sizeof(VAR_8)); if (VAR_6 < 0) goto fail; if (VAR_3) { bswap_ahdr(&VAR_8); } magic = N_MAGIC(VAR_8); switch (magic) { case ZMAGIC: case QMAGIC: case OMAGIC: if (VAR_8.a_text + VAR_8.a_data > VAR_2) goto fail; lseek(VAR_5, N_TXTOFF(VAR_8), SEEK_SET); VAR_6 = read_targphys(VAR_0, VAR_5, VAR_1, VAR_8.a_text + VAR_8.a_data); if (VAR_6 < 0) goto fail; break; case NMAGIC: if (N_DATADDR(VAR_8, VAR_4) + VAR_8.a_data > VAR_2) goto fail; lseek(VAR_5, N_TXTOFF(VAR_8), SEEK_SET); VAR_6 = read_targphys(VAR_0, VAR_5, VAR_1, VAR_8.a_text); if (VAR_6 < 0) goto fail; VAR_7 = read_targphys(VAR_0, VAR_5, VAR_1 + N_DATADDR(VAR_8, VAR_4), VAR_8.a_data); if (VAR_7 < 0) goto fail; VAR_6 += VAR_7; break; default: goto fail; } close(VAR_5); return VAR_6; fail: close(VAR_5); return -1; }
[ "int FUNC_0(const char *VAR_0, target_phys_addr_t VAR_1, int VAR_2,\nint VAR_3, target_phys_addr_t VAR_4)\n{", "int VAR_5, VAR_6, VAR_7;", "struct exec VAR_8;", "uint32_t magic;", "VAR_5 = open(VAR_0, O_RDONLY | O_BINARY);", "if (VAR_5 < 0)\nreturn -1;", "VAR_6 = read(VAR_5, &VAR_8, sizeof(VAR_8));", "if (VAR_6 < 0)\ngoto fail;", "if (VAR_3) {", "bswap_ahdr(&VAR_8);", "}", "magic = N_MAGIC(VAR_8);", "switch (magic) {", "case ZMAGIC:\ncase QMAGIC:\ncase OMAGIC:\nif (VAR_8.a_text + VAR_8.a_data > VAR_2)\ngoto fail;", "lseek(VAR_5, N_TXTOFF(VAR_8), SEEK_SET);", "VAR_6 = read_targphys(VAR_0, VAR_5, VAR_1, VAR_8.a_text + VAR_8.a_data);", "if (VAR_6 < 0)\ngoto fail;", "break;", "case NMAGIC:\nif (N_DATADDR(VAR_8, VAR_4) + VAR_8.a_data > VAR_2)\ngoto fail;", "lseek(VAR_5, N_TXTOFF(VAR_8), SEEK_SET);", "VAR_6 = read_targphys(VAR_0, VAR_5, VAR_1, VAR_8.a_text);", "if (VAR_6 < 0)\ngoto fail;", "VAR_7 = read_targphys(VAR_0, VAR_5, VAR_1 + N_DATADDR(VAR_8, VAR_4),\nVAR_8.a_data);", "if (VAR_7 < 0)\ngoto fail;", "VAR_6 += VAR_7;", "break;", "default:\ngoto fail;", "}", "close(VAR_5);", "return VAR_6;", "fail:\nclose(VAR_5);", "return -1;", "}" ]
[ 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17, 19 ], [ 23 ], [ 25, 27 ], [ 31 ], [ 33 ], [ 35 ], [ 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 ] ]
9,932
int64_t cache_resize(PageCache *cache, int64_t new_num_pages) { PageCache *new_cache; int64_t i; CacheItem *old_it, *new_it; g_assert(cache); /* cache was not inited */ if (cache->page_cache == NULL) { return -1; } /* same size */ if (pow2floor(new_num_pages) == cache->max_num_items) { return cache->max_num_items; } new_cache = cache_init(new_num_pages, cache->page_size); if (!(new_cache)) { DPRINTF("Error creating new cache\n"); return -1; } /* move all data from old cache */ for (i = 0; i < cache->max_num_items; i++) { old_it = &cache->page_cache[i]; if (old_it->it_addr != -1) { /* check for collision, if there is, keep MRU page */ new_it = cache_get_by_addr(new_cache, old_it->it_addr); if (new_it->it_data) { /* keep the MRU page */ if (new_it->it_age >= old_it->it_age) { g_free(old_it->it_data); } else { g_free(new_it->it_data); new_it->it_data = old_it->it_data; new_it->it_age = old_it->it_age; new_it->it_addr = old_it->it_addr; } } else { cache_insert(new_cache, old_it->it_addr, old_it->it_data); } } } cache->page_cache = new_cache->page_cache; cache->max_num_items = new_cache->max_num_items; cache->num_items = new_cache->num_items; g_free(new_cache); return cache->max_num_items; }
true
qemu
0db65d624e0211a43c011579d6607a50d8f06082
int64_t cache_resize(PageCache *cache, int64_t new_num_pages) { PageCache *new_cache; int64_t i; CacheItem *old_it, *new_it; g_assert(cache); if (cache->page_cache == NULL) { return -1; } if (pow2floor(new_num_pages) == cache->max_num_items) { return cache->max_num_items; } new_cache = cache_init(new_num_pages, cache->page_size); if (!(new_cache)) { DPRINTF("Error creating new cache\n"); return -1; } for (i = 0; i < cache->max_num_items; i++) { old_it = &cache->page_cache[i]; if (old_it->it_addr != -1) { new_it = cache_get_by_addr(new_cache, old_it->it_addr); if (new_it->it_data) { if (new_it->it_age >= old_it->it_age) { g_free(old_it->it_data); } else { g_free(new_it->it_data); new_it->it_data = old_it->it_data; new_it->it_age = old_it->it_age; new_it->it_addr = old_it->it_addr; } } else { cache_insert(new_cache, old_it->it_addr, old_it->it_data); } } } cache->page_cache = new_cache->page_cache; cache->max_num_items = new_cache->max_num_items; cache->num_items = new_cache->num_items; g_free(new_cache); return cache->max_num_items; }
{ "code": [], "line_no": [] }
int64_t FUNC_0(PageCache *cache, int64_t new_num_pages) { PageCache *new_cache; int64_t i; CacheItem *old_it, *new_it; g_assert(cache); if (cache->page_cache == NULL) { return -1; } if (pow2floor(new_num_pages) == cache->max_num_items) { return cache->max_num_items; } new_cache = cache_init(new_num_pages, cache->page_size); if (!(new_cache)) { DPRINTF("Error creating new cache\n"); return -1; } for (i = 0; i < cache->max_num_items; i++) { old_it = &cache->page_cache[i]; if (old_it->it_addr != -1) { new_it = cache_get_by_addr(new_cache, old_it->it_addr); if (new_it->it_data) { if (new_it->it_age >= old_it->it_age) { g_free(old_it->it_data); } else { g_free(new_it->it_data); new_it->it_data = old_it->it_data; new_it->it_age = old_it->it_age; new_it->it_addr = old_it->it_addr; } } else { cache_insert(new_cache, old_it->it_addr, old_it->it_data); } } } cache->page_cache = new_cache->page_cache; cache->max_num_items = new_cache->max_num_items; cache->num_items = new_cache->num_items; g_free(new_cache); return cache->max_num_items; }
[ "int64_t FUNC_0(PageCache *cache, int64_t new_num_pages)\n{", "PageCache *new_cache;", "int64_t i;", "CacheItem *old_it, *new_it;", "g_assert(cache);", "if (cache->page_cache == NULL) {", "return -1;", "}", "if (pow2floor(new_num_pages) == cache->max_num_items) {", "return cache->max_num_items;", "}", "new_cache = cache_init(new_num_pages, cache->page_size);", "if (!(new_cache)) {", "DPRINTF(\"Error creating new cache\\n\");", "return -1;", "}", "for (i = 0; i < cache->max_num_items; i++) {", "old_it = &cache->page_cache[i];", "if (old_it->it_addr != -1) {", "new_it = cache_get_by_addr(new_cache, old_it->it_addr);", "if (new_it->it_data) {", "if (new_it->it_age >= old_it->it_age) {", "g_free(old_it->it_data);", "} else {", "g_free(new_it->it_data);", "new_it->it_data = old_it->it_data;", "new_it->it_age = old_it->it_age;", "new_it->it_addr = old_it->it_addr;", "}", "} else {", "cache_insert(new_cache, old_it->it_addr, old_it->it_data);", "}", "}", "}", "cache->page_cache = new_cache->page_cache;", "cache->max_num_items = new_cache->max_num_items;", "cache->num_items = new_cache->num_items;", "g_free(new_cache);", "return cache->max_num_items;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 15 ], [ 21 ], [ 23 ], [ 25 ], [ 31 ], [ 33 ], [ 35 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 53 ], [ 55 ], [ 57 ], [ 61 ], [ 63 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 96 ], [ 98 ], [ 100 ], [ 104 ], [ 108 ], [ 110 ] ]
9,933
static void choose_sample_fmt(AVStream *st, AVCodec *codec) { if (codec && codec->sample_fmts) { const enum AVSampleFormat *p = codec->sample_fmts; for (; *p != -1; p++) { if (*p == st->codec->sample_fmt) break; } if (*p == -1) { av_log(NULL, AV_LOG_WARNING, "Incompatible sample format '%s' for codec '%s', auto-selecting format '%s'\n", av_get_sample_fmt_name(st->codec->sample_fmt), codec->name, av_get_sample_fmt_name(codec->sample_fmts[0])); st->codec->sample_fmt = codec->sample_fmts[0]; } } }
true
FFmpeg
369cb092ecbbaff20bb0a2a1d60536c3bc04a8f0
static void choose_sample_fmt(AVStream *st, AVCodec *codec) { if (codec && codec->sample_fmts) { const enum AVSampleFormat *p = codec->sample_fmts; for (; *p != -1; p++) { if (*p == st->codec->sample_fmt) break; } if (*p == -1) { av_log(NULL, AV_LOG_WARNING, "Incompatible sample format '%s' for codec '%s', auto-selecting format '%s'\n", av_get_sample_fmt_name(st->codec->sample_fmt), codec->name, av_get_sample_fmt_name(codec->sample_fmts[0])); st->codec->sample_fmt = codec->sample_fmts[0]; } } }
{ "code": [ "static void choose_sample_fmt(AVStream *st, AVCodec *codec)", " if (codec && codec->sample_fmts) {", " const enum AVSampleFormat *p = codec->sample_fmts;", " for (; *p != -1; p++) {", " if (*p == st->codec->sample_fmt)", " break;", " if (*p == -1) {", " av_log(NULL, AV_LOG_WARNING,", " \"Incompatible sample format '%s' for codec '%s', auto-selecting format '%s'\\n\",", " av_get_sample_fmt_name(st->codec->sample_fmt),", " codec->name,", " av_get_sample_fmt_name(codec->sample_fmts[0]));", " st->codec->sample_fmt = codec->sample_fmts[0];", " break;", " break;" ], "line_no": [ 1, 5, 7, 9, 11, 13, 17, 19, 21, 23, 25, 27, 29, 13, 13 ] }
static void FUNC_0(AVStream *VAR_0, AVCodec *VAR_1) { if (VAR_1 && VAR_1->sample_fmts) { const enum AVSampleFormat *VAR_2 = VAR_1->sample_fmts; for (; *VAR_2 != -1; VAR_2++) { if (*VAR_2 == VAR_0->VAR_1->sample_fmt) break; } if (*VAR_2 == -1) { av_log(NULL, AV_LOG_WARNING, "Incompatible sample format '%s' for VAR_1 '%s', auto-selecting format '%s'\n", av_get_sample_fmt_name(VAR_0->VAR_1->sample_fmt), VAR_1->name, av_get_sample_fmt_name(VAR_1->sample_fmts[0])); VAR_0->VAR_1->sample_fmt = VAR_1->sample_fmts[0]; } } }
[ "static void FUNC_0(AVStream *VAR_0, AVCodec *VAR_1)\n{", "if (VAR_1 && VAR_1->sample_fmts) {", "const enum AVSampleFormat *VAR_2 = VAR_1->sample_fmts;", "for (; *VAR_2 != -1; VAR_2++) {", "if (*VAR_2 == VAR_0->VAR_1->sample_fmt)\nbreak;", "}", "if (*VAR_2 == -1) {", "av_log(NULL, AV_LOG_WARNING,\n\"Incompatible sample format '%s' for VAR_1 '%s', auto-selecting format '%s'\\n\",\nav_get_sample_fmt_name(VAR_0->VAR_1->sample_fmt),\nVAR_1->name,\nav_get_sample_fmt_name(VAR_1->sample_fmts[0]));", "VAR_0->VAR_1->sample_fmt = VAR_1->sample_fmts[0];", "}", "}", "}" ]
[ 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11, 13 ], [ 15 ], [ 17 ], [ 19, 21, 23, 25, 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ] ]
9,935
static void unin_data_write(void *opaque, hwaddr addr, uint64_t val, unsigned len) { UNINState *s = opaque; PCIHostState *phb = PCI_HOST_BRIDGE(s); UNIN_DPRINTF("write addr %" TARGET_FMT_plx " len %d val %"PRIx64"\n", addr, len, val); pci_data_write(phb->bus, unin_get_config_reg(phb->config_reg, addr), val, len); }
true
qemu
2f448e415f364d0ec4c5556993e44ca183e31c5c
static void unin_data_write(void *opaque, hwaddr addr, uint64_t val, unsigned len) { UNINState *s = opaque; PCIHostState *phb = PCI_HOST_BRIDGE(s); UNIN_DPRINTF("write addr %" TARGET_FMT_plx " len %d val %"PRIx64"\n", addr, len, val); pci_data_write(phb->bus, unin_get_config_reg(phb->config_reg, addr), val, len); }
{ "code": [ " UNIN_DPRINTF(\"write addr %\" TARGET_FMT_plx \" len %d val %\"PRIx64\"\\n\"," ], "line_no": [ 11 ] }
static void FUNC_0(void *VAR_0, hwaddr VAR_1, uint64_t VAR_2, unsigned VAR_3) { UNINState *s = VAR_0; PCIHostState *phb = PCI_HOST_BRIDGE(s); UNIN_DPRINTF("write VAR_1 %" TARGET_FMT_plx " VAR_3 %d VAR_2 %"PRIx64"\n", VAR_1, VAR_3, VAR_2); pci_data_write(phb->bus, unin_get_config_reg(phb->config_reg, VAR_1), VAR_2, VAR_3); }
[ "static void FUNC_0(void *VAR_0, hwaddr VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{", "UNINState *s = VAR_0;", "PCIHostState *phb = PCI_HOST_BRIDGE(s);", "UNIN_DPRINTF(\"write VAR_1 %\" TARGET_FMT_plx \" VAR_3 %d VAR_2 %\"PRIx64\"\\n\",\nVAR_1, VAR_3, VAR_2);", "pci_data_write(phb->bus,\nunin_get_config_reg(phb->config_reg, VAR_1),\nVAR_2, VAR_3);", "}" ]
[ 0, 0, 0, 1, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11, 13 ], [ 15, 17, 19 ], [ 21 ] ]
9,936
static bool vhost_section(MemoryRegionSection *section) { return memory_region_is_ram(section->mr); }
true
qemu
af60314291af3cabda18d27f928b0e0ff899cc76
static bool vhost_section(MemoryRegionSection *section) { return memory_region_is_ram(section->mr); }
{ "code": [ "static bool vhost_section(MemoryRegionSection *section)", " return memory_region_is_ram(section->mr);" ], "line_no": [ 1, 5 ] }
static bool FUNC_0(MemoryRegionSection *section) { return memory_region_is_ram(section->mr); }
[ "static bool FUNC_0(MemoryRegionSection *section)\n{", "return memory_region_is_ram(section->mr);", "}" ]
[ 1, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ] ]
9,937
void do_subfzeo (void) { T1 = T0; T0 = ~T0 + xer_ca; if (likely(!((~T1 ^ (-1)) & ((~T1) ^ T0) & (1 << 31)))) { xer_ov = 0; } else { xer_ov = 1; xer_so = 1; } if (likely(T0 >= ~T1)) { xer_ca = 0; } else { xer_ca = 1; } }
true
qemu
d9bce9d99f4656ae0b0127f7472db9067b8f84ab
void do_subfzeo (void) { T1 = T0; T0 = ~T0 + xer_ca; if (likely(!((~T1 ^ (-1)) & ((~T1) ^ T0) & (1 << 31)))) { xer_ov = 0; } else { xer_ov = 1; xer_so = 1; } if (likely(T0 >= ~T1)) { xer_ca = 0; } else { xer_ca = 1; } }
{ "code": [ " xer_ca = 1;", " T1 = T0;", " } else {", " xer_ca = 0;", " T1 = T0;", " T1 = T0;", " xer_ca = 1;", " } else {", " xer_ca = 0;", " xer_ca = 1;", " } else {", " T1 = T0;", " xer_ov = 0;", " } else {", " xer_so = 1;", " xer_ov = 1;", " xer_ca = 0;", " } else {", " xer_ca = 1;", " xer_ov = 0;", " } else {", " xer_so = 1;", " xer_ov = 1;", " xer_ov = 0;", " } else {", " xer_so = 1;", " xer_ov = 1;", " xer_ca = 0;", " } else {", " xer_so = 1;", " xer_ca = 0;", " } else {", " xer_ca = 1;", " xer_so = 1;", " xer_ca = 0;", " } else {", " if (likely(!((~T1 ^ (-1)) & ((~T1) ^ T0) & (1 << 31)))) {", " if (likely(T0 >= ~T1)) {" ], "line_no": [ 27, 5, 13, 23, 5, 5, 27, 13, 23, 27, 13, 5, 11, 13, 17, 15, 23, 13, 27, 11, 13, 17, 15, 11, 13, 17, 15, 23, 13, 17, 23, 13, 27, 17, 23, 13, 9, 21 ] }
void FUNC_0 (void) { T1 = T0; T0 = ~T0 + xer_ca; if (likely(!((~T1 ^ (-1)) & ((~T1) ^ T0) & (1 << 31)))) { xer_ov = 0; } else { xer_ov = 1; xer_so = 1; } if (likely(T0 >= ~T1)) { xer_ca = 0; } else { xer_ca = 1; } }
[ "void FUNC_0 (void)\n{", "T1 = T0;", "T0 = ~T0 + xer_ca;", "if (likely(!((~T1 ^ (-1)) & ((~T1) ^ T0) & (1 << 31)))) {", "xer_ov = 0;", "} else {", "xer_ov = 1;", "xer_so = 1;", "}", "if (likely(T0 >= ~T1)) {", "xer_ca = 0;", "} else {", "xer_ca = 1;", "}", "}" ]
[ 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ] ]
9,938
static void test_visitor_out_native_list_int(TestOutputVisitorData *data, const void *unused) { test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_INTEGER); }
false
qemu
b3db211f3c80bb996a704d665fe275619f728bd4
static void test_visitor_out_native_list_int(TestOutputVisitorData *data, const void *unused) { test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_INTEGER); }
{ "code": [], "line_no": [] }
static void FUNC_0(TestOutputVisitorData *VAR_0, const void *VAR_1) { test_native_list(VAR_0, VAR_1, USER_DEF_NATIVE_LIST_UNION_KIND_INTEGER); }
[ "static void FUNC_0(TestOutputVisitorData *VAR_0,\nconst void *VAR_1)\n{", "test_native_list(VAR_0, VAR_1, USER_DEF_NATIVE_LIST_UNION_KIND_INTEGER);", "}" ]
[ 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ] ]
9,939
QList *qlist_new(void) { QList *qlist; qlist = g_malloc(sizeof(*qlist)); QTAILQ_INIT(&qlist->head); QOBJECT_INIT(qlist, &qlist_type); return qlist; }
false
qemu
55e1819c509b3d9c10a54678b9c585bbda13889e
QList *qlist_new(void) { QList *qlist; qlist = g_malloc(sizeof(*qlist)); QTAILQ_INIT(&qlist->head); QOBJECT_INIT(qlist, &qlist_type); return qlist; }
{ "code": [], "line_no": [] }
QList *FUNC_0(void) { QList *qlist; qlist = g_malloc(sizeof(*qlist)); QTAILQ_INIT(&qlist->head); QOBJECT_INIT(qlist, &qlist_type); return qlist; }
[ "QList *FUNC_0(void)\n{", "QList *qlist;", "qlist = g_malloc(sizeof(*qlist));", "QTAILQ_INIT(&qlist->head);", "QOBJECT_INIT(qlist, &qlist_type);", "return qlist;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ] ]
9,940
static int decode_wdlt(GetByteContext *gb, uint8_t *frame, int width, int height) { const uint8_t *frame_end = frame + width * height; uint8_t *line_ptr; int count, i, v, lines, segments; lines = bytestream2_get_le16(gb); if (lines > height) return -1; while (lines--) { if (bytestream2_get_bytes_left(gb) < 2) return -1; segments = bytestream2_get_le16u(gb); while ((segments & 0xC000) == 0xC000) { unsigned delta = -((int16_t)segments * width); if (frame_end - frame <= delta) return -1; frame += delta; segments = bytestream2_get_le16(gb); } if (segments & 0x8000) { frame[width - 1] = segments & 0xFF; segments = bytestream2_get_le16(gb); } line_ptr = frame; frame += width; while (segments--) { if (frame - line_ptr <= bytestream2_peek_byte(gb)) return -1; line_ptr += bytestream2_get_byte(gb); count = (int8_t)bytestream2_get_byte(gb); if (count >= 0) { if (frame - line_ptr < count * 2) return -1; if (bytestream2_get_buffer(gb, line_ptr, count * 2) != count * 2) return -1; line_ptr += count * 2; } else { count = -count; if (frame - line_ptr < count * 2) return -1; v = bytestream2_get_le16(gb); for (i = 0; i < count; i++) bytestream_put_le16(&line_ptr, v); } } } return 0; }
false
FFmpeg
8099187e897ddc90cb3902332c76fb2542dac308
static int decode_wdlt(GetByteContext *gb, uint8_t *frame, int width, int height) { const uint8_t *frame_end = frame + width * height; uint8_t *line_ptr; int count, i, v, lines, segments; lines = bytestream2_get_le16(gb); if (lines > height) return -1; while (lines--) { if (bytestream2_get_bytes_left(gb) < 2) return -1; segments = bytestream2_get_le16u(gb); while ((segments & 0xC000) == 0xC000) { unsigned delta = -((int16_t)segments * width); if (frame_end - frame <= delta) return -1; frame += delta; segments = bytestream2_get_le16(gb); } if (segments & 0x8000) { frame[width - 1] = segments & 0xFF; segments = bytestream2_get_le16(gb); } line_ptr = frame; frame += width; while (segments--) { if (frame - line_ptr <= bytestream2_peek_byte(gb)) return -1; line_ptr += bytestream2_get_byte(gb); count = (int8_t)bytestream2_get_byte(gb); if (count >= 0) { if (frame - line_ptr < count * 2) return -1; if (bytestream2_get_buffer(gb, line_ptr, count * 2) != count * 2) return -1; line_ptr += count * 2; } else { count = -count; if (frame - line_ptr < count * 2) return -1; v = bytestream2_get_le16(gb); for (i = 0; i < count; i++) bytestream_put_le16(&line_ptr, v); } } } return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(GetByteContext *VAR_0, uint8_t *VAR_1, int VAR_2, int VAR_3) { const uint8_t *VAR_4 = VAR_1 + VAR_2 * VAR_3; uint8_t *line_ptr; int VAR_5, VAR_6, VAR_7, VAR_8, VAR_9; VAR_8 = bytestream2_get_le16(VAR_0); if (VAR_8 > VAR_3) return -1; while (VAR_8--) { if (bytestream2_get_bytes_left(VAR_0) < 2) return -1; VAR_9 = bytestream2_get_le16u(VAR_0); while ((VAR_9 & 0xC000) == 0xC000) { unsigned VAR_10 = -((int16_t)VAR_9 * VAR_2); if (VAR_4 - VAR_1 <= VAR_10) return -1; VAR_1 += VAR_10; VAR_9 = bytestream2_get_le16(VAR_0); } if (VAR_9 & 0x8000) { VAR_1[VAR_2 - 1] = VAR_9 & 0xFF; VAR_9 = bytestream2_get_le16(VAR_0); } line_ptr = VAR_1; VAR_1 += VAR_2; while (VAR_9--) { if (VAR_1 - line_ptr <= bytestream2_peek_byte(VAR_0)) return -1; line_ptr += bytestream2_get_byte(VAR_0); VAR_5 = (int8_t)bytestream2_get_byte(VAR_0); if (VAR_5 >= 0) { if (VAR_1 - line_ptr < VAR_5 * 2) return -1; if (bytestream2_get_buffer(VAR_0, line_ptr, VAR_5 * 2) != VAR_5 * 2) return -1; line_ptr += VAR_5 * 2; } else { VAR_5 = -VAR_5; if (VAR_1 - line_ptr < VAR_5 * 2) return -1; VAR_7 = bytestream2_get_le16(VAR_0); for (VAR_6 = 0; VAR_6 < VAR_5; VAR_6++) bytestream_put_le16(&line_ptr, VAR_7); } } } return 0; }
[ "static int FUNC_0(GetByteContext *VAR_0, uint8_t *VAR_1, int VAR_2, int VAR_3)\n{", "const uint8_t *VAR_4 = VAR_1 + VAR_2 * VAR_3;", "uint8_t *line_ptr;", "int VAR_5, VAR_6, VAR_7, VAR_8, VAR_9;", "VAR_8 = bytestream2_get_le16(VAR_0);", "if (VAR_8 > VAR_3)\nreturn -1;", "while (VAR_8--) {", "if (bytestream2_get_bytes_left(VAR_0) < 2)\nreturn -1;", "VAR_9 = bytestream2_get_le16u(VAR_0);", "while ((VAR_9 & 0xC000) == 0xC000) {", "unsigned VAR_10 = -((int16_t)VAR_9 * VAR_2);", "if (VAR_4 - VAR_1 <= VAR_10)\nreturn -1;", "VAR_1 += VAR_10;", "VAR_9 = bytestream2_get_le16(VAR_0);", "}", "if (VAR_9 & 0x8000) {", "VAR_1[VAR_2 - 1] = VAR_9 & 0xFF;", "VAR_9 = bytestream2_get_le16(VAR_0);", "}", "line_ptr = VAR_1;", "VAR_1 += VAR_2;", "while (VAR_9--) {", "if (VAR_1 - line_ptr <= bytestream2_peek_byte(VAR_0))\nreturn -1;", "line_ptr += bytestream2_get_byte(VAR_0);", "VAR_5 = (int8_t)bytestream2_get_byte(VAR_0);", "if (VAR_5 >= 0) {", "if (VAR_1 - line_ptr < VAR_5 * 2)\nreturn -1;", "if (bytestream2_get_buffer(VAR_0, line_ptr, VAR_5 * 2) != VAR_5 * 2)\nreturn -1;", "line_ptr += VAR_5 * 2;", "} else {", "VAR_5 = -VAR_5;", "if (VAR_1 - line_ptr < VAR_5 * 2)\nreturn -1;", "VAR_7 = bytestream2_get_le16(VAR_0);", "for (VAR_6 = 0; VAR_6 < VAR_5; VAR_6++)", "bytestream_put_le16(&line_ptr, VAR_7);", "}", "}", "}", "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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15, 17 ], [ 21 ], [ 23, 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33, 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57, 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67, 69 ], [ 71, 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81, 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 99 ], [ 101 ] ]
9,941
static void fw_cfg_comb_write(void *opaque, target_phys_addr_t addr, uint64_t value, unsigned size) { switch (size) { case 1: fw_cfg_write(opaque, (uint8_t)value); break; case 2: fw_cfg_select(opaque, (uint16_t)value); break; } }
false
qemu
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
static void fw_cfg_comb_write(void *opaque, target_phys_addr_t addr, uint64_t value, unsigned size) { switch (size) { case 1: fw_cfg_write(opaque, (uint8_t)value); break; case 2: fw_cfg_select(opaque, (uint16_t)value); break; } }
{ "code": [], "line_no": [] }
static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1, uint64_t VAR_2, unsigned VAR_3) { switch (VAR_3) { case 1: fw_cfg_write(VAR_0, (uint8_t)VAR_2); break; case 2: fw_cfg_select(VAR_0, (uint16_t)VAR_2); break; } }
[ "static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{", "switch (VAR_3) {", "case 1:\nfw_cfg_write(VAR_0, (uint8_t)VAR_2);", "break;", "case 2:\nfw_cfg_select(VAR_0, (uint16_t)VAR_2);", "break;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9, 11 ], [ 13 ], [ 15, 17 ], [ 19 ], [ 21 ], [ 23 ] ]
9,942
void virtio_queue_notify(VirtIODevice *vdev, int n) { if (n < VIRTIO_PCI_QUEUE_MAX && vdev->vq[n].vring.desc) { trace_virtio_queue_notify(vdev, n, &vdev->vq[n]); vdev->vq[n].handle_output(vdev, &vdev->vq[n]); } }
false
qemu
25db9ebe15125deb32958c6df74996f745edf1f9
void virtio_queue_notify(VirtIODevice *vdev, int n) { if (n < VIRTIO_PCI_QUEUE_MAX && vdev->vq[n].vring.desc) { trace_virtio_queue_notify(vdev, n, &vdev->vq[n]); vdev->vq[n].handle_output(vdev, &vdev->vq[n]); } }
{ "code": [], "line_no": [] }
void FUNC_0(VirtIODevice *VAR_0, int VAR_1) { if (VAR_1 < VIRTIO_PCI_QUEUE_MAX && VAR_0->vq[VAR_1].vring.desc) { trace_virtio_queue_notify(VAR_0, VAR_1, &VAR_0->vq[VAR_1]); VAR_0->vq[VAR_1].handle_output(VAR_0, &VAR_0->vq[VAR_1]); } }
[ "void FUNC_0(VirtIODevice *VAR_0, int VAR_1)\n{", "if (VAR_1 < VIRTIO_PCI_QUEUE_MAX && VAR_0->vq[VAR_1].vring.desc) {", "trace_virtio_queue_notify(VAR_0, VAR_1, &VAR_0->vq[VAR_1]);", "VAR_0->vq[VAR_1].handle_output(VAR_0, &VAR_0->vq[VAR_1]);", "}", "}" ]
[ 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ] ]
9,944
void ioinst_handle_stcrw(S390CPU *cpu, uint32_t ipb) { CRW *crw; uint64_t addr; int cc; hwaddr len = sizeof(*crw); CPUS390XState *env = &cpu->env; addr = decode_basedisp_s(env, ipb); if (addr & 3) { program_interrupt(env, PGM_SPECIFICATION, 2); return; } crw = s390_cpu_physical_memory_map(env, addr, &len, 1); if (!crw || len != sizeof(*crw)) { program_interrupt(env, PGM_ADDRESSING, 2); goto out; } cc = css_do_stcrw(crw); /* 0 - crw stored, 1 - zeroes stored */ setcc(cpu, cc); out: s390_cpu_physical_memory_unmap(env, crw, len, 1); }
false
qemu
7f74f0aa74a01698ef24459f7bc2a23f3880a2b8
void ioinst_handle_stcrw(S390CPU *cpu, uint32_t ipb) { CRW *crw; uint64_t addr; int cc; hwaddr len = sizeof(*crw); CPUS390XState *env = &cpu->env; addr = decode_basedisp_s(env, ipb); if (addr & 3) { program_interrupt(env, PGM_SPECIFICATION, 2); return; } crw = s390_cpu_physical_memory_map(env, addr, &len, 1); if (!crw || len != sizeof(*crw)) { program_interrupt(env, PGM_ADDRESSING, 2); goto out; } cc = css_do_stcrw(crw); setcc(cpu, cc); out: s390_cpu_physical_memory_unmap(env, crw, len, 1); }
{ "code": [], "line_no": [] }
void FUNC_0(S390CPU *VAR_0, uint32_t VAR_1) { CRW *crw; uint64_t addr; int VAR_2; hwaddr len = sizeof(*crw); CPUS390XState *env = &VAR_0->env; addr = decode_basedisp_s(env, VAR_1); if (addr & 3) { program_interrupt(env, PGM_SPECIFICATION, 2); return; } crw = s390_cpu_physical_memory_map(env, addr, &len, 1); if (!crw || len != sizeof(*crw)) { program_interrupt(env, PGM_ADDRESSING, 2); goto out; } VAR_2 = css_do_stcrw(crw); setcc(VAR_0, VAR_2); out: s390_cpu_physical_memory_unmap(env, crw, len, 1); }
[ "void FUNC_0(S390CPU *VAR_0, uint32_t VAR_1)\n{", "CRW *crw;", "uint64_t addr;", "int VAR_2;", "hwaddr len = sizeof(*crw);", "CPUS390XState *env = &VAR_0->env;", "addr = decode_basedisp_s(env, VAR_1);", "if (addr & 3) {", "program_interrupt(env, PGM_SPECIFICATION, 2);", "return;", "}", "crw = s390_cpu_physical_memory_map(env, addr, &len, 1);", "if (!crw || len != sizeof(*crw)) {", "program_interrupt(env, PGM_ADDRESSING, 2);", "goto out;", "}", "VAR_2 = css_do_stcrw(crw);", "setcc(VAR_0, VAR_2);", "out:\ns390_cpu_physical_memory_unmap(env, crw, len, 1);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 41 ], [ 45, 47 ], [ 49 ] ]
9,945
void sysbus_mmio_map_overlap(SysBusDevice *dev, int n, hwaddr addr, unsigned priority) { sysbus_mmio_map_common(dev, n, addr, true, priority); }
false
qemu
a1ff8ae0666ffcbe78ae7e28812dd30db6bb7131
void sysbus_mmio_map_overlap(SysBusDevice *dev, int n, hwaddr addr, unsigned priority) { sysbus_mmio_map_common(dev, n, addr, true, priority); }
{ "code": [], "line_no": [] }
void FUNC_0(SysBusDevice *VAR_0, int VAR_1, hwaddr VAR_2, unsigned VAR_3) { sysbus_mmio_map_common(VAR_0, VAR_1, VAR_2, true, VAR_3); }
[ "void FUNC_0(SysBusDevice *VAR_0, int VAR_1, hwaddr VAR_2,\nunsigned VAR_3)\n{", "sysbus_mmio_map_common(VAR_0, VAR_1, VAR_2, true, VAR_3);", "}" ]
[ 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ] ]
9,946
static int tpm_passthrough_test_tpmdev(int fd) { struct tpm_req_hdr req = { .tag = cpu_to_be16(TPM_TAG_RQU_COMMAND), .len = cpu_to_be32(sizeof(req)), .ordinal = cpu_to_be32(TPM_ORD_GetTicks), }; struct tpm_resp_hdr *resp; fd_set readfds; int n; struct timeval tv = { .tv_sec = 1, .tv_usec = 0, }; unsigned char buf[1024]; n = write(fd, &req, sizeof(req)); if (n < 0) { return errno; } if (n != sizeof(req)) { return EFAULT; } FD_ZERO(&readfds); FD_SET(fd, &readfds); /* wait for a second */ n = select(fd + 1, &readfds, NULL, NULL, &tv); if (n != 1) { return errno; } n = read(fd, &buf, sizeof(buf)); if (n < sizeof(struct tpm_resp_hdr)) { return EFAULT; } resp = (struct tpm_resp_hdr *)buf; /* check the header */ if (be16_to_cpu(resp->tag) != TPM_TAG_RSP_COMMAND || be32_to_cpu(resp->len) != n) { return EBADMSG; } return 0; }
false
qemu
56a3c24ffc11955ddc7bb21362ca8069a3fc8c55
static int tpm_passthrough_test_tpmdev(int fd) { struct tpm_req_hdr req = { .tag = cpu_to_be16(TPM_TAG_RQU_COMMAND), .len = cpu_to_be32(sizeof(req)), .ordinal = cpu_to_be32(TPM_ORD_GetTicks), }; struct tpm_resp_hdr *resp; fd_set readfds; int n; struct timeval tv = { .tv_sec = 1, .tv_usec = 0, }; unsigned char buf[1024]; n = write(fd, &req, sizeof(req)); if (n < 0) { return errno; } if (n != sizeof(req)) { return EFAULT; } FD_ZERO(&readfds); FD_SET(fd, &readfds); n = select(fd + 1, &readfds, NULL, NULL, &tv); if (n != 1) { return errno; } n = read(fd, &buf, sizeof(buf)); if (n < sizeof(struct tpm_resp_hdr)) { return EFAULT; } resp = (struct tpm_resp_hdr *)buf; if (be16_to_cpu(resp->tag) != TPM_TAG_RSP_COMMAND || be32_to_cpu(resp->len) != n) { return EBADMSG; } return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(int VAR_0) { struct tpm_req_hdr VAR_1 = { .tag = cpu_to_be16(TPM_TAG_RQU_COMMAND), .len = cpu_to_be32(sizeof(VAR_1)), .ordinal = cpu_to_be32(TPM_ORD_GetTicks), }; struct tpm_resp_hdr *VAR_2; fd_set readfds; int VAR_3; struct timeval VAR_4 = { .tv_sec = 1, .tv_usec = 0, }; unsigned char VAR_5[1024]; VAR_3 = write(VAR_0, &VAR_1, sizeof(VAR_1)); if (VAR_3 < 0) { return errno; } if (VAR_3 != sizeof(VAR_1)) { return EFAULT; } FD_ZERO(&readfds); FD_SET(VAR_0, &readfds); VAR_3 = select(VAR_0 + 1, &readfds, NULL, NULL, &VAR_4); if (VAR_3 != 1) { return errno; } VAR_3 = read(VAR_0, &VAR_5, sizeof(VAR_5)); if (VAR_3 < sizeof(struct tpm_resp_hdr)) { return EFAULT; } VAR_2 = (struct tpm_resp_hdr *)VAR_5; if (be16_to_cpu(VAR_2->tag) != TPM_TAG_RSP_COMMAND || be32_to_cpu(VAR_2->len) != VAR_3) { return EBADMSG; } return 0; }
[ "static int FUNC_0(int VAR_0)\n{", "struct tpm_req_hdr VAR_1 = {", ".tag = cpu_to_be16(TPM_TAG_RQU_COMMAND),\n.len = cpu_to_be32(sizeof(VAR_1)),\n.ordinal = cpu_to_be32(TPM_ORD_GetTicks),\n};", "struct tpm_resp_hdr *VAR_2;", "fd_set readfds;", "int VAR_3;", "struct timeval VAR_4 = {", ".tv_sec = 1,\n.tv_usec = 0,\n};", "unsigned char VAR_5[1024];", "VAR_3 = write(VAR_0, &VAR_1, sizeof(VAR_1));", "if (VAR_3 < 0) {", "return errno;", "}", "if (VAR_3 != sizeof(VAR_1)) {", "return EFAULT;", "}", "FD_ZERO(&readfds);", "FD_SET(VAR_0, &readfds);", "VAR_3 = select(VAR_0 + 1, &readfds, NULL, NULL, &VAR_4);", "if (VAR_3 != 1) {", "return errno;", "}", "VAR_3 = read(VAR_0, &VAR_5, sizeof(VAR_5));", "if (VAR_3 < sizeof(struct tpm_resp_hdr)) {", "return EFAULT;", "}", "VAR_2 = (struct tpm_resp_hdr *)VAR_5;", "if (be16_to_cpu(VAR_2->tag) != TPM_TAG_RSP_COMMAND ||\nbe32_to_cpu(VAR_2->len) != VAR_3) {", "return EBADMSG;", "}", "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 ]
[ [ 1, 3 ], [ 5 ], [ 7, 9, 11, 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23, 25, 27 ], [ 29 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 49 ], [ 51 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 77 ], [ 81, 83 ], [ 85 ], [ 87 ], [ 91 ], [ 93 ] ]
9,947
static int tight_palette_insert(QDict *palette, uint32_t rgb, int bpp, int max) { uint8_t key[6]; int idx = qdict_size(palette); bool present; tight_palette_rgb2buf(rgb, bpp, key); present = qdict_haskey(palette, (char *)key); if (idx >= max && !present) { return 0; } if (!present) { qdict_put(palette, (char *)key, qint_from_int(idx)); } return qdict_size(palette); }
false
qemu
245f7b51c0ea04fb2224b1127430a096c91aee70
static int tight_palette_insert(QDict *palette, uint32_t rgb, int bpp, int max) { uint8_t key[6]; int idx = qdict_size(palette); bool present; tight_palette_rgb2buf(rgb, bpp, key); present = qdict_haskey(palette, (char *)key); if (idx >= max && !present) { return 0; } if (!present) { qdict_put(palette, (char *)key, qint_from_int(idx)); } return qdict_size(palette); }
{ "code": [], "line_no": [] }
static int FUNC_0(QDict *VAR_0, uint32_t VAR_1, int VAR_2, int VAR_3) { uint8_t key[6]; int VAR_4 = qdict_size(VAR_0); bool present; tight_palette_rgb2buf(VAR_1, VAR_2, key); present = qdict_haskey(VAR_0, (char *)key); if (VAR_4 >= VAR_3 && !present) { return 0; } if (!present) { qdict_put(VAR_0, (char *)key, qint_from_int(VAR_4)); } return qdict_size(VAR_0); }
[ "static int FUNC_0(QDict *VAR_0, uint32_t VAR_1, int VAR_2, int VAR_3)\n{", "uint8_t key[6];", "int VAR_4 = qdict_size(VAR_0);", "bool present;", "tight_palette_rgb2buf(VAR_1, VAR_2, key);", "present = qdict_haskey(VAR_0, (char *)key);", "if (VAR_4 >= VAR_3 && !present) {", "return 0;", "}", "if (!present) {", "qdict_put(VAR_0, (char *)key, qint_from_int(VAR_4));", "}", "return qdict_size(VAR_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 ] ]
9,948
static void vnc_connect(VncDisplay *vd, int csock, bool skipauth, bool websocket) { VncState *vs = g_malloc0(sizeof(VncState)); int i; vs->csock = csock; vs->vd = vd; if (skipauth) { vs->auth = VNC_AUTH_NONE; vs->subauth = VNC_AUTH_INVALID; } else { if (websocket) { vs->auth = vd->ws_auth; vs->subauth = VNC_AUTH_INVALID; } else { vs->auth = vd->auth; vs->subauth = vd->subauth; } } VNC_DEBUG("Client sock=%d ws=%d auth=%d subauth=%d\n", csock, websocket, vs->auth, vs->subauth); vs->lossy_rect = g_malloc0(VNC_STAT_ROWS * sizeof (*vs->lossy_rect)); for (i = 0; i < VNC_STAT_ROWS; ++i) { vs->lossy_rect[i] = g_malloc0(VNC_STAT_COLS * sizeof (uint8_t)); } VNC_DEBUG("New client on socket %d\n", csock); update_displaychangelistener(&vd->dcl, VNC_REFRESH_INTERVAL_BASE); qemu_set_nonblock(vs->csock); #ifdef CONFIG_VNC_WS if (websocket) { vs->websocket = 1; #ifdef CONFIG_VNC_TLS if (vd->ws_tls) { qemu_set_fd_handler(vs->csock, vncws_tls_handshake_io, NULL, vs); } else #endif /* CONFIG_VNC_TLS */ { qemu_set_fd_handler(vs->csock, vncws_handshake_read, NULL, vs); } } else #endif /* CONFIG_VNC_WS */ { qemu_set_fd_handler(vs->csock, vnc_client_read, NULL, vs); } vnc_client_cache_addr(vs); vnc_qmp_event(vs, QAPI_EVENT_VNC_CONNECTED); vnc_set_share_mode(vs, VNC_SHARE_MODE_CONNECTING); #ifdef CONFIG_VNC_WS if (!vs->websocket) #endif { vnc_init_state(vs); } if (vd->num_connecting > vd->connections_limit) { QTAILQ_FOREACH(vs, &vd->clients, next) { if (vs->share_mode == VNC_SHARE_MODE_CONNECTING) { vnc_disconnect_start(vs); return; } } } }
false
qemu
8e9b0d24fb986d4241ae3b77752eca5dab4cb486
static void vnc_connect(VncDisplay *vd, int csock, bool skipauth, bool websocket) { VncState *vs = g_malloc0(sizeof(VncState)); int i; vs->csock = csock; vs->vd = vd; if (skipauth) { vs->auth = VNC_AUTH_NONE; vs->subauth = VNC_AUTH_INVALID; } else { if (websocket) { vs->auth = vd->ws_auth; vs->subauth = VNC_AUTH_INVALID; } else { vs->auth = vd->auth; vs->subauth = vd->subauth; } } VNC_DEBUG("Client sock=%d ws=%d auth=%d subauth=%d\n", csock, websocket, vs->auth, vs->subauth); vs->lossy_rect = g_malloc0(VNC_STAT_ROWS * sizeof (*vs->lossy_rect)); for (i = 0; i < VNC_STAT_ROWS; ++i) { vs->lossy_rect[i] = g_malloc0(VNC_STAT_COLS * sizeof (uint8_t)); } VNC_DEBUG("New client on socket %d\n", csock); update_displaychangelistener(&vd->dcl, VNC_REFRESH_INTERVAL_BASE); qemu_set_nonblock(vs->csock); #ifdef CONFIG_VNC_WS if (websocket) { vs->websocket = 1; #ifdef CONFIG_VNC_TLS if (vd->ws_tls) { qemu_set_fd_handler(vs->csock, vncws_tls_handshake_io, NULL, vs); } else #endif { qemu_set_fd_handler(vs->csock, vncws_handshake_read, NULL, vs); } } else #endif { qemu_set_fd_handler(vs->csock, vnc_client_read, NULL, vs); } vnc_client_cache_addr(vs); vnc_qmp_event(vs, QAPI_EVENT_VNC_CONNECTED); vnc_set_share_mode(vs, VNC_SHARE_MODE_CONNECTING); #ifdef CONFIG_VNC_WS if (!vs->websocket) #endif { vnc_init_state(vs); } if (vd->num_connecting > vd->connections_limit) { QTAILQ_FOREACH(vs, &vd->clients, next) { if (vs->share_mode == VNC_SHARE_MODE_CONNECTING) { vnc_disconnect_start(vs); return; } } } }
{ "code": [], "line_no": [] }
static void FUNC_0(VncDisplay *VAR_0, int VAR_1, bool VAR_2, bool VAR_3) { VncState *vs = g_malloc0(sizeof(VncState)); int VAR_4; vs->VAR_1 = VAR_1; vs->VAR_0 = VAR_0; if (VAR_2) { vs->auth = VNC_AUTH_NONE; vs->subauth = VNC_AUTH_INVALID; } else { if (VAR_3) { vs->auth = VAR_0->ws_auth; vs->subauth = VNC_AUTH_INVALID; } else { vs->auth = VAR_0->auth; vs->subauth = VAR_0->subauth; } } VNC_DEBUG("Client sock=%d ws=%d auth=%d subauth=%d\n", VAR_1, VAR_3, vs->auth, vs->subauth); vs->lossy_rect = g_malloc0(VNC_STAT_ROWS * sizeof (*vs->lossy_rect)); for (VAR_4 = 0; VAR_4 < VNC_STAT_ROWS; ++VAR_4) { vs->lossy_rect[VAR_4] = g_malloc0(VNC_STAT_COLS * sizeof (uint8_t)); } VNC_DEBUG("New client on socket %d\n", VAR_1); update_displaychangelistener(&VAR_0->dcl, VNC_REFRESH_INTERVAL_BASE); qemu_set_nonblock(vs->VAR_1); #ifdef CONFIG_VNC_WS if (VAR_3) { vs->VAR_3 = 1; #ifdef CONFIG_VNC_TLS if (VAR_0->ws_tls) { qemu_set_fd_handler(vs->VAR_1, vncws_tls_handshake_io, NULL, vs); } else #endif { qemu_set_fd_handler(vs->VAR_1, vncws_handshake_read, NULL, vs); } } else #endif { qemu_set_fd_handler(vs->VAR_1, vnc_client_read, NULL, vs); } vnc_client_cache_addr(vs); vnc_qmp_event(vs, QAPI_EVENT_VNC_CONNECTED); vnc_set_share_mode(vs, VNC_SHARE_MODE_CONNECTING); #ifdef CONFIG_VNC_WS if (!vs->VAR_3) #endif { vnc_init_state(vs); } if (VAR_0->num_connecting > VAR_0->connections_limit) { QTAILQ_FOREACH(vs, &VAR_0->clients, next) { if (vs->share_mode == VNC_SHARE_MODE_CONNECTING) { vnc_disconnect_start(vs); return; } } } }
[ "static void FUNC_0(VncDisplay *VAR_0, int VAR_1,\nbool VAR_2, bool VAR_3)\n{", "VncState *vs = g_malloc0(sizeof(VncState));", "int VAR_4;", "vs->VAR_1 = VAR_1;", "vs->VAR_0 = VAR_0;", "if (VAR_2) {", "vs->auth = VNC_AUTH_NONE;", "vs->subauth = VNC_AUTH_INVALID;", "} else {", "if (VAR_3) {", "vs->auth = VAR_0->ws_auth;", "vs->subauth = VNC_AUTH_INVALID;", "} else {", "vs->auth = VAR_0->auth;", "vs->subauth = VAR_0->subauth;", "}", "}", "VNC_DEBUG(\"Client sock=%d ws=%d auth=%d subauth=%d\\n\",\nVAR_1, VAR_3, vs->auth, vs->subauth);", "vs->lossy_rect = g_malloc0(VNC_STAT_ROWS * sizeof (*vs->lossy_rect));", "for (VAR_4 = 0; VAR_4 < VNC_STAT_ROWS; ++VAR_4) {", "vs->lossy_rect[VAR_4] = g_malloc0(VNC_STAT_COLS * sizeof (uint8_t));", "}", "VNC_DEBUG(\"New client on socket %d\\n\", VAR_1);", "update_displaychangelistener(&VAR_0->dcl, VNC_REFRESH_INTERVAL_BASE);", "qemu_set_nonblock(vs->VAR_1);", "#ifdef CONFIG_VNC_WS\nif (VAR_3) {", "vs->VAR_3 = 1;", "#ifdef CONFIG_VNC_TLS\nif (VAR_0->ws_tls) {", "qemu_set_fd_handler(vs->VAR_1, vncws_tls_handshake_io, NULL, vs);", "} else", "#endif\n{", "qemu_set_fd_handler(vs->VAR_1, vncws_handshake_read, NULL, vs);", "}", "} else", "#endif\n{", "qemu_set_fd_handler(vs->VAR_1, vnc_client_read, NULL, vs);", "}", "vnc_client_cache_addr(vs);", "vnc_qmp_event(vs, QAPI_EVENT_VNC_CONNECTED);", "vnc_set_share_mode(vs, VNC_SHARE_MODE_CONNECTING);", "#ifdef CONFIG_VNC_WS\nif (!vs->VAR_3)\n#endif\n{", "vnc_init_state(vs);", "}", "if (VAR_0->num_connecting > VAR_0->connections_limit) {", "QTAILQ_FOREACH(vs, &VAR_0->clients, next) {", "if (vs->share_mode == VNC_SHARE_MODE_CONNECTING) {", "vnc_disconnect_start(vs);", "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 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43, 45 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 59 ], [ 61 ], [ 63 ], [ 65, 67 ], [ 69 ], [ 71, 73 ], [ 75 ], [ 77 ], [ 79, 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89, 91 ], [ 93 ], [ 95 ], [ 99 ], [ 101 ], [ 103 ], [ 107, 109, 111, 113 ], [ 115 ], [ 117 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ] ]
9,949
static void lsi_command_complete(SCSIRequest *req, uint32_t status, size_t resid) { LSIState *s = DO_UPCAST(LSIState, dev.qdev, req->bus->qbus.parent); int out; out = (s->sstat1 & PHASE_MASK) == PHASE_DO; DPRINTF("Command complete status=%d\n", (int)status); s->status = status; s->command_complete = 2; if (s->waiting && s->dbc != 0) { /* Raise phase mismatch for short transfers. */ lsi_bad_phase(s, out, PHASE_ST); } else { lsi_set_phase(s, PHASE_ST); } if (s->current && req == s->current->req) { req->hba_private = NULL; lsi_request_free(s, s->current); scsi_req_unref(req); } lsi_resume_script(s); }
false
qemu
8f6e699ddbcad32480fa64796ccf44cbaf5b4b91
static void lsi_command_complete(SCSIRequest *req, uint32_t status, size_t resid) { LSIState *s = DO_UPCAST(LSIState, dev.qdev, req->bus->qbus.parent); int out; out = (s->sstat1 & PHASE_MASK) == PHASE_DO; DPRINTF("Command complete status=%d\n", (int)status); s->status = status; s->command_complete = 2; if (s->waiting && s->dbc != 0) { lsi_bad_phase(s, out, PHASE_ST); } else { lsi_set_phase(s, PHASE_ST); } if (s->current && req == s->current->req) { req->hba_private = NULL; lsi_request_free(s, s->current); scsi_req_unref(req); } lsi_resume_script(s); }
{ "code": [], "line_no": [] }
static void FUNC_0(SCSIRequest *VAR_0, uint32_t VAR_1, size_t VAR_2) { LSIState *s = DO_UPCAST(LSIState, dev.qdev, VAR_0->bus->qbus.parent); int VAR_3; VAR_3 = (s->sstat1 & PHASE_MASK) == PHASE_DO; DPRINTF("Command complete VAR_1=%d\n", (int)VAR_1); s->VAR_1 = VAR_1; s->command_complete = 2; if (s->waiting && s->dbc != 0) { lsi_bad_phase(s, VAR_3, PHASE_ST); } else { lsi_set_phase(s, PHASE_ST); } if (s->current && VAR_0 == s->current->VAR_0) { VAR_0->hba_private = NULL; lsi_request_free(s, s->current); scsi_req_unref(VAR_0); } lsi_resume_script(s); }
[ "static void FUNC_0(SCSIRequest *VAR_0, uint32_t VAR_1, size_t VAR_2)\n{", "LSIState *s = DO_UPCAST(LSIState, dev.qdev, VAR_0->bus->qbus.parent);", "int VAR_3;", "VAR_3 = (s->sstat1 & PHASE_MASK) == PHASE_DO;", "DPRINTF(\"Command complete VAR_1=%d\\n\", (int)VAR_1);", "s->VAR_1 = VAR_1;", "s->command_complete = 2;", "if (s->waiting && s->dbc != 0) {", "lsi_bad_phase(s, VAR_3, PHASE_ST);", "} else {", "lsi_set_phase(s, PHASE_ST);", "}", "if (s->current && VAR_0 == s->current->VAR_0) {", "VAR_0->hba_private = NULL;", "lsi_request_free(s, s->current);", "scsi_req_unref(VAR_0);", "}", "lsi_resume_script(s);", "}" ]
[ 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 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ] ]
9,950
static ssize_t test_block_init_func(QCryptoBlock *block, void *opaque, size_t headerlen, Error **errp) { Buffer *header = opaque; g_assert_cmpint(header->capacity, ==, 0); buffer_reserve(header, headerlen); return headerlen; }
false
qemu
e4a3507e86a1ef1453d603031bca27d5ac4cff3c
static ssize_t test_block_init_func(QCryptoBlock *block, void *opaque, size_t headerlen, Error **errp) { Buffer *header = opaque; g_assert_cmpint(header->capacity, ==, 0); buffer_reserve(header, headerlen); return headerlen; }
{ "code": [], "line_no": [] }
static ssize_t FUNC_0(QCryptoBlock *block, void *opaque, size_t headerlen, Error **errp) { Buffer *header = opaque; g_assert_cmpint(header->capacity, ==, 0); buffer_reserve(header, headerlen); return headerlen; }
[ "static ssize_t FUNC_0(QCryptoBlock *block,\nvoid *opaque,\nsize_t headerlen,\nError **errp)\n{", "Buffer *header = opaque;", "g_assert_cmpint(header->capacity, ==, 0);", "buffer_reserve(header, headerlen);", "return headerlen;", "}" ]
[ 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9 ], [ 11 ], [ 15 ], [ 19 ], [ 23 ], [ 25 ] ]
9,951
static inline void decode_hrd_parameters(H264Context *h, SPS *sps){ MpegEncContext * const s = &h->s; int cpb_count, i; cpb_count = get_ue_golomb(&s->gb) + 1; get_bits(&s->gb, 4); /* bit_rate_scale */ get_bits(&s->gb, 4); /* cpb_size_scale */ for(i=0; i<cpb_count; i++){ get_ue_golomb(&s->gb); /* bit_rate_value_minus1 */ get_ue_golomb(&s->gb); /* cpb_size_value_minus1 */ get_bits1(&s->gb); /* cbr_flag */ } get_bits(&s->gb, 5); /* initial_cpb_removal_delay_length_minus1 */ sps->cpb_removal_delay_length = get_bits(&s->gb, 5) + 1; sps->dpb_output_delay_length = get_bits(&s->gb, 5) + 1; sps->time_offset_length = get_bits(&s->gb, 5); }
false
FFmpeg
d23b28c78b56f53f3f0e74edb0f15a3b451207ad
static inline void decode_hrd_parameters(H264Context *h, SPS *sps){ MpegEncContext * const s = &h->s; int cpb_count, i; cpb_count = get_ue_golomb(&s->gb) + 1; get_bits(&s->gb, 4); get_bits(&s->gb, 4); for(i=0; i<cpb_count; i++){ get_ue_golomb(&s->gb); get_ue_golomb(&s->gb); get_bits1(&s->gb); } get_bits(&s->gb, 5); sps->cpb_removal_delay_length = get_bits(&s->gb, 5) + 1; sps->dpb_output_delay_length = get_bits(&s->gb, 5) + 1; sps->time_offset_length = get_bits(&s->gb, 5); }
{ "code": [], "line_no": [] }
static inline void FUNC_0(H264Context *VAR_0, SPS *VAR_1){ MpegEncContext * const s = &VAR_0->s; int VAR_2, VAR_3; VAR_2 = get_ue_golomb(&s->gb) + 1; get_bits(&s->gb, 4); get_bits(&s->gb, 4); for(VAR_3=0; VAR_3<VAR_2; VAR_3++){ get_ue_golomb(&s->gb); get_ue_golomb(&s->gb); get_bits1(&s->gb); } get_bits(&s->gb, 5); VAR_1->cpb_removal_delay_length = get_bits(&s->gb, 5) + 1; VAR_1->dpb_output_delay_length = get_bits(&s->gb, 5) + 1; VAR_1->time_offset_length = get_bits(&s->gb, 5); }
[ "static inline void FUNC_0(H264Context *VAR_0, SPS *VAR_1){", "MpegEncContext * const s = &VAR_0->s;", "int VAR_2, VAR_3;", "VAR_2 = get_ue_golomb(&s->gb) + 1;", "get_bits(&s->gb, 4);", "get_bits(&s->gb, 4);", "for(VAR_3=0; VAR_3<VAR_2; VAR_3++){", "get_ue_golomb(&s->gb);", "get_ue_golomb(&s->gb);", "get_bits1(&s->gb);", "}", "get_bits(&s->gb, 5);", "VAR_1->cpb_removal_delay_length = get_bits(&s->gb, 5) + 1;", "VAR_1->dpb_output_delay_length = get_bits(&s->gb, 5) + 1;", "VAR_1->time_offset_length = get_bits(&s->gb, 5);", "}" ]
[ 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 ] ]
9,952
void OPPROTO op_addw_ESI_T0(void) { ESI = (ESI & ~0xffff) | ((ESI + T0) & 0xffff); }
false
qemu
6e0d8677cb443e7408c0b7a25a93c6596d7fa380
void OPPROTO op_addw_ESI_T0(void) { ESI = (ESI & ~0xffff) | ((ESI + T0) & 0xffff); }
{ "code": [], "line_no": [] }
void VAR_0 op_addw_ESI_T0(void) { ESI = (ESI & ~0xffff) | ((ESI + T0) & 0xffff); }
[ "void VAR_0 op_addw_ESI_T0(void)\n{", "ESI = (ESI & ~0xffff) | ((ESI + T0) & 0xffff);", "}" ]
[ 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ] ]
9,953
uint8_t *xen_map_cache(target_phys_addr_t phys_addr, target_phys_addr_t size, uint8_t lock) { MapCacheEntry *entry, *pentry = NULL; target_phys_addr_t address_index = phys_addr >> MCACHE_BUCKET_SHIFT; target_phys_addr_t address_offset = phys_addr & (MCACHE_BUCKET_SIZE - 1); target_phys_addr_t __size = size; trace_xen_map_cache(phys_addr); if (address_index == mapcache->last_address_index && !lock && !__size) { trace_xen_map_cache_return(mapcache->last_address_vaddr + address_offset); return mapcache->last_address_vaddr + address_offset; } /* size is always a multiple of MCACHE_BUCKET_SIZE */ if ((address_offset + (__size % MCACHE_BUCKET_SIZE)) > MCACHE_BUCKET_SIZE) __size += MCACHE_BUCKET_SIZE; if (__size % MCACHE_BUCKET_SIZE) __size += MCACHE_BUCKET_SIZE - (__size % MCACHE_BUCKET_SIZE); if (!__size) __size = MCACHE_BUCKET_SIZE; entry = &mapcache->entry[address_index % mapcache->nr_buckets]; while (entry && entry->lock && entry->vaddr_base && (entry->paddr_index != address_index || entry->size != __size || !test_bits(address_offset >> XC_PAGE_SHIFT, size >> XC_PAGE_SHIFT, entry->valid_mapping))) { pentry = entry; entry = entry->next; } if (!entry) { entry = g_malloc0(sizeof (MapCacheEntry)); pentry->next = entry; xen_remap_bucket(entry, __size, address_index); } else if (!entry->lock) { if (!entry->vaddr_base || entry->paddr_index != address_index || entry->size != __size || !test_bits(address_offset >> XC_PAGE_SHIFT, size >> XC_PAGE_SHIFT, entry->valid_mapping)) { xen_remap_bucket(entry, __size, address_index); } } if(!test_bits(address_offset >> XC_PAGE_SHIFT, size >> XC_PAGE_SHIFT, entry->valid_mapping)) { mapcache->last_address_index = -1; trace_xen_map_cache_return(NULL); return NULL; } mapcache->last_address_index = address_index; mapcache->last_address_vaddr = entry->vaddr_base; if (lock) { MapCacheRev *reventry = g_malloc0(sizeof(MapCacheRev)); entry->lock++; reventry->vaddr_req = mapcache->last_address_vaddr + address_offset; reventry->paddr_index = mapcache->last_address_index; reventry->size = entry->size; QTAILQ_INSERT_HEAD(&mapcache->locked_entries, reventry, next); } trace_xen_map_cache_return(mapcache->last_address_vaddr + address_offset); return mapcache->last_address_vaddr + address_offset; }
false
qemu
cd1ba7de230b3a85fb4dba53bb681b7ea626b4eb
uint8_t *xen_map_cache(target_phys_addr_t phys_addr, target_phys_addr_t size, uint8_t lock) { MapCacheEntry *entry, *pentry = NULL; target_phys_addr_t address_index = phys_addr >> MCACHE_BUCKET_SHIFT; target_phys_addr_t address_offset = phys_addr & (MCACHE_BUCKET_SIZE - 1); target_phys_addr_t __size = size; trace_xen_map_cache(phys_addr); if (address_index == mapcache->last_address_index && !lock && !__size) { trace_xen_map_cache_return(mapcache->last_address_vaddr + address_offset); return mapcache->last_address_vaddr + address_offset; } if ((address_offset + (__size % MCACHE_BUCKET_SIZE)) > MCACHE_BUCKET_SIZE) __size += MCACHE_BUCKET_SIZE; if (__size % MCACHE_BUCKET_SIZE) __size += MCACHE_BUCKET_SIZE - (__size % MCACHE_BUCKET_SIZE); if (!__size) __size = MCACHE_BUCKET_SIZE; entry = &mapcache->entry[address_index % mapcache->nr_buckets]; while (entry && entry->lock && entry->vaddr_base && (entry->paddr_index != address_index || entry->size != __size || !test_bits(address_offset >> XC_PAGE_SHIFT, size >> XC_PAGE_SHIFT, entry->valid_mapping))) { pentry = entry; entry = entry->next; } if (!entry) { entry = g_malloc0(sizeof (MapCacheEntry)); pentry->next = entry; xen_remap_bucket(entry, __size, address_index); } else if (!entry->lock) { if (!entry->vaddr_base || entry->paddr_index != address_index || entry->size != __size || !test_bits(address_offset >> XC_PAGE_SHIFT, size >> XC_PAGE_SHIFT, entry->valid_mapping)) { xen_remap_bucket(entry, __size, address_index); } } if(!test_bits(address_offset >> XC_PAGE_SHIFT, size >> XC_PAGE_SHIFT, entry->valid_mapping)) { mapcache->last_address_index = -1; trace_xen_map_cache_return(NULL); return NULL; } mapcache->last_address_index = address_index; mapcache->last_address_vaddr = entry->vaddr_base; if (lock) { MapCacheRev *reventry = g_malloc0(sizeof(MapCacheRev)); entry->lock++; reventry->vaddr_req = mapcache->last_address_vaddr + address_offset; reventry->paddr_index = mapcache->last_address_index; reventry->size = entry->size; QTAILQ_INSERT_HEAD(&mapcache->locked_entries, reventry, next); } trace_xen_map_cache_return(mapcache->last_address_vaddr + address_offset); return mapcache->last_address_vaddr + address_offset; }
{ "code": [], "line_no": [] }
uint8_t *FUNC_0(target_phys_addr_t phys_addr, target_phys_addr_t size, uint8_t lock) { MapCacheEntry *entry, *pentry = NULL; target_phys_addr_t address_index = phys_addr >> MCACHE_BUCKET_SHIFT; target_phys_addr_t address_offset = phys_addr & (MCACHE_BUCKET_SIZE - 1); target_phys_addr_t __size = size; trace_xen_map_cache(phys_addr); if (address_index == mapcache->last_address_index && !lock && !__size) { trace_xen_map_cache_return(mapcache->last_address_vaddr + address_offset); return mapcache->last_address_vaddr + address_offset; } if ((address_offset + (__size % MCACHE_BUCKET_SIZE)) > MCACHE_BUCKET_SIZE) __size += MCACHE_BUCKET_SIZE; if (__size % MCACHE_BUCKET_SIZE) __size += MCACHE_BUCKET_SIZE - (__size % MCACHE_BUCKET_SIZE); if (!__size) __size = MCACHE_BUCKET_SIZE; entry = &mapcache->entry[address_index % mapcache->nr_buckets]; while (entry && entry->lock && entry->vaddr_base && (entry->paddr_index != address_index || entry->size != __size || !test_bits(address_offset >> XC_PAGE_SHIFT, size >> XC_PAGE_SHIFT, entry->valid_mapping))) { pentry = entry; entry = entry->next; } if (!entry) { entry = g_malloc0(sizeof (MapCacheEntry)); pentry->next = entry; xen_remap_bucket(entry, __size, address_index); } else if (!entry->lock) { if (!entry->vaddr_base || entry->paddr_index != address_index || entry->size != __size || !test_bits(address_offset >> XC_PAGE_SHIFT, size >> XC_PAGE_SHIFT, entry->valid_mapping)) { xen_remap_bucket(entry, __size, address_index); } } if(!test_bits(address_offset >> XC_PAGE_SHIFT, size >> XC_PAGE_SHIFT, entry->valid_mapping)) { mapcache->last_address_index = -1; trace_xen_map_cache_return(NULL); return NULL; } mapcache->last_address_index = address_index; mapcache->last_address_vaddr = entry->vaddr_base; if (lock) { MapCacheRev *reventry = g_malloc0(sizeof(MapCacheRev)); entry->lock++; reventry->vaddr_req = mapcache->last_address_vaddr + address_offset; reventry->paddr_index = mapcache->last_address_index; reventry->size = entry->size; QTAILQ_INSERT_HEAD(&mapcache->locked_entries, reventry, next); } trace_xen_map_cache_return(mapcache->last_address_vaddr + address_offset); return mapcache->last_address_vaddr + address_offset; }
[ "uint8_t *FUNC_0(target_phys_addr_t phys_addr, target_phys_addr_t size,\nuint8_t lock)\n{", "MapCacheEntry *entry, *pentry = NULL;", "target_phys_addr_t address_index = phys_addr >> MCACHE_BUCKET_SHIFT;", "target_phys_addr_t address_offset = phys_addr & (MCACHE_BUCKET_SIZE - 1);", "target_phys_addr_t __size = size;", "trace_xen_map_cache(phys_addr);", "if (address_index == mapcache->last_address_index && !lock && !__size) {", "trace_xen_map_cache_return(mapcache->last_address_vaddr + address_offset);", "return mapcache->last_address_vaddr + address_offset;", "}", "if ((address_offset + (__size % MCACHE_BUCKET_SIZE)) > MCACHE_BUCKET_SIZE)\n__size += MCACHE_BUCKET_SIZE;", "if (__size % MCACHE_BUCKET_SIZE)\n__size += MCACHE_BUCKET_SIZE - (__size % MCACHE_BUCKET_SIZE);", "if (!__size)\n__size = MCACHE_BUCKET_SIZE;", "entry = &mapcache->entry[address_index % mapcache->nr_buckets];", "while (entry && entry->lock && entry->vaddr_base &&\n(entry->paddr_index != address_index || entry->size != __size ||\n!test_bits(address_offset >> XC_PAGE_SHIFT, size >> XC_PAGE_SHIFT,\nentry->valid_mapping))) {", "pentry = entry;", "entry = entry->next;", "}", "if (!entry) {", "entry = g_malloc0(sizeof (MapCacheEntry));", "pentry->next = entry;", "xen_remap_bucket(entry, __size, address_index);", "} else if (!entry->lock) {", "if (!entry->vaddr_base || entry->paddr_index != address_index ||\nentry->size != __size ||\n!test_bits(address_offset >> XC_PAGE_SHIFT, size >> XC_PAGE_SHIFT,\nentry->valid_mapping)) {", "xen_remap_bucket(entry, __size, address_index);", "}", "}", "if(!test_bits(address_offset >> XC_PAGE_SHIFT, size >> XC_PAGE_SHIFT,\nentry->valid_mapping)) {", "mapcache->last_address_index = -1;", "trace_xen_map_cache_return(NULL);", "return NULL;", "}", "mapcache->last_address_index = address_index;", "mapcache->last_address_vaddr = entry->vaddr_base;", "if (lock) {", "MapCacheRev *reventry = g_malloc0(sizeof(MapCacheRev));", "entry->lock++;", "reventry->vaddr_req = mapcache->last_address_vaddr + address_offset;", "reventry->paddr_index = mapcache->last_address_index;", "reventry->size = entry->size;", "QTAILQ_INSERT_HEAD(&mapcache->locked_entries, reventry, next);", "}", "trace_xen_map_cache_return(mapcache->last_address_vaddr + address_offset);", "return mapcache->last_address_vaddr + address_offset;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 33, 35 ], [ 37, 39 ], [ 41, 43 ], [ 47 ], [ 51, 53, 55, 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75, 77, 79, 81 ], [ 83 ], [ 85 ], [ 87 ], [ 91, 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 127 ], [ 129 ], [ 131 ] ]
9,954
static unsigned int dec_move_pm(DisasContext *dc) { TCGv t0; int memsize; memsize = preg_sizes[dc->op2]; DIS(fprintf (logfile, "move.%c $p%u, [$r%u%s\n", memsize_char(memsize), dc->op2, dc->op1, dc->postinc ? "+]" : "]")); /* prepare store. Address in T0, value in T1. */ if (dc->op2 == PR_CCS) cris_evaluate_flags(dc); t0 = tcg_temp_new(TCG_TYPE_TL); t_gen_mov_TN_preg(t0, dc->op2); cris_flush_cc_state(dc); gen_store(dc, cpu_R[dc->op1], t0, memsize); tcg_temp_free(t0); cris_cc_mask(dc, 0); if (dc->postinc) tcg_gen_addi_tl(cpu_R[dc->op1], cpu_R[dc->op1], memsize); return 2; }
false
qemu
a7812ae412311d7d47f8aa85656faadac9d64b56
static unsigned int dec_move_pm(DisasContext *dc) { TCGv t0; int memsize; memsize = preg_sizes[dc->op2]; DIS(fprintf (logfile, "move.%c $p%u, [$r%u%s\n", memsize_char(memsize), dc->op2, dc->op1, dc->postinc ? "+]" : "]")); if (dc->op2 == PR_CCS) cris_evaluate_flags(dc); t0 = tcg_temp_new(TCG_TYPE_TL); t_gen_mov_TN_preg(t0, dc->op2); cris_flush_cc_state(dc); gen_store(dc, cpu_R[dc->op1], t0, memsize); tcg_temp_free(t0); cris_cc_mask(dc, 0); if (dc->postinc) tcg_gen_addi_tl(cpu_R[dc->op1], cpu_R[dc->op1], memsize); return 2; }
{ "code": [], "line_no": [] }
static unsigned int FUNC_0(DisasContext *VAR_0) { TCGv t0; int VAR_1; VAR_1 = preg_sizes[VAR_0->op2]; DIS(fprintf (logfile, "move.%c $p%u, [$r%u%s\n", memsize_char(VAR_1), VAR_0->op2, VAR_0->op1, VAR_0->postinc ? "+]" : "]")); if (VAR_0->op2 == PR_CCS) cris_evaluate_flags(VAR_0); t0 = tcg_temp_new(TCG_TYPE_TL); t_gen_mov_TN_preg(t0, VAR_0->op2); cris_flush_cc_state(VAR_0); gen_store(VAR_0, cpu_R[VAR_0->op1], t0, VAR_1); tcg_temp_free(t0); cris_cc_mask(VAR_0, 0); if (VAR_0->postinc) tcg_gen_addi_tl(cpu_R[VAR_0->op1], cpu_R[VAR_0->op1], VAR_1); return 2; }
[ "static unsigned int FUNC_0(DisasContext *VAR_0)\n{", "TCGv t0;", "int VAR_1;", "VAR_1 = preg_sizes[VAR_0->op2];", "DIS(fprintf (logfile, \"move.%c $p%u, [$r%u%s\\n\",\nmemsize_char(VAR_1),\nVAR_0->op2, VAR_0->op1, VAR_0->postinc ? \"+]\" : \"]\"));", "if (VAR_0->op2 == PR_CCS)\ncris_evaluate_flags(VAR_0);", "t0 = tcg_temp_new(TCG_TYPE_TL);", "t_gen_mov_TN_preg(t0, VAR_0->op2);", "cris_flush_cc_state(VAR_0);", "gen_store(VAR_0, cpu_R[VAR_0->op1], t0, VAR_1);", "tcg_temp_free(t0);", "cris_cc_mask(VAR_0, 0);", "if (VAR_0->postinc)\ntcg_gen_addi_tl(cpu_R[VAR_0->op1], cpu_R[VAR_0->op1], VAR_1);", "return 2;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 15, 17, 19 ], [ 25, 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 41 ], [ 43, 45 ], [ 47 ], [ 49 ] ]
9,955
static void test_event_d(TestEventData *data, const void *unused) { UserDefOne struct1; EventStructOne a; UserDefZero z; QDict *d, *d_data, *d_a, *d_struct1; z.integer = 2; struct1.base = &z; struct1.string = g_strdup("test1"); struct1.has_enum1 = true; struct1.enum1 = ENUM_ONE_VALUE1; a.struct1 = &struct1; a.string = g_strdup("test2"); a.has_enum2 = true; a.enum2 = ENUM_ONE_VALUE2; d_struct1 = qdict_new(); qdict_put(d_struct1, "integer", qint_from_int(2)); qdict_put(d_struct1, "string", qstring_from_str("test1")); qdict_put(d_struct1, "enum1", qstring_from_str("value1")); d_a = qdict_new(); qdict_put(d_a, "struct1", d_struct1); qdict_put(d_a, "string", qstring_from_str("test2")); qdict_put(d_a, "enum2", qstring_from_str("value2")); d_data = qdict_new(); qdict_put(d_data, "a", d_a); qdict_put(d_data, "b", qstring_from_str("test3")); qdict_put(d_data, "enum3", qstring_from_str("value3")); d = data->expect; qdict_put(d, "event", qstring_from_str("EVENT_D")); qdict_put(d, "data", d_data); qapi_event_send_event_d(&a, "test3", false, NULL, true, ENUM_ONE_VALUE3, &error_abort); g_free(struct1.string); g_free(a.string); }
false
qemu
ddf21908961073199f3d186204da4810f2ea150b
static void test_event_d(TestEventData *data, const void *unused) { UserDefOne struct1; EventStructOne a; UserDefZero z; QDict *d, *d_data, *d_a, *d_struct1; z.integer = 2; struct1.base = &z; struct1.string = g_strdup("test1"); struct1.has_enum1 = true; struct1.enum1 = ENUM_ONE_VALUE1; a.struct1 = &struct1; a.string = g_strdup("test2"); a.has_enum2 = true; a.enum2 = ENUM_ONE_VALUE2; d_struct1 = qdict_new(); qdict_put(d_struct1, "integer", qint_from_int(2)); qdict_put(d_struct1, "string", qstring_from_str("test1")); qdict_put(d_struct1, "enum1", qstring_from_str("value1")); d_a = qdict_new(); qdict_put(d_a, "struct1", d_struct1); qdict_put(d_a, "string", qstring_from_str("test2")); qdict_put(d_a, "enum2", qstring_from_str("value2")); d_data = qdict_new(); qdict_put(d_data, "a", d_a); qdict_put(d_data, "b", qstring_from_str("test3")); qdict_put(d_data, "enum3", qstring_from_str("value3")); d = data->expect; qdict_put(d, "event", qstring_from_str("EVENT_D")); qdict_put(d, "data", d_data); qapi_event_send_event_d(&a, "test3", false, NULL, true, ENUM_ONE_VALUE3, &error_abort); g_free(struct1.string); g_free(a.string); }
{ "code": [], "line_no": [] }
static void FUNC_0(TestEventData *VAR_0, const void *VAR_1) { UserDefOne struct1; EventStructOne a; UserDefZero z; QDict *d, *d_data, *d_a, *d_struct1; z.integer = 2; struct1.base = &z; struct1.string = g_strdup("test1"); struct1.has_enum1 = true; struct1.enum1 = ENUM_ONE_VALUE1; a.struct1 = &struct1; a.string = g_strdup("test2"); a.has_enum2 = true; a.enum2 = ENUM_ONE_VALUE2; d_struct1 = qdict_new(); qdict_put(d_struct1, "integer", qint_from_int(2)); qdict_put(d_struct1, "string", qstring_from_str("test1")); qdict_put(d_struct1, "enum1", qstring_from_str("value1")); d_a = qdict_new(); qdict_put(d_a, "struct1", d_struct1); qdict_put(d_a, "string", qstring_from_str("test2")); qdict_put(d_a, "enum2", qstring_from_str("value2")); d_data = qdict_new(); qdict_put(d_data, "a", d_a); qdict_put(d_data, "b", qstring_from_str("test3")); qdict_put(d_data, "enum3", qstring_from_str("value3")); d = VAR_0->expect; qdict_put(d, "event", qstring_from_str("EVENT_D")); qdict_put(d, "VAR_0", d_data); qapi_event_send_event_d(&a, "test3", false, NULL, true, ENUM_ONE_VALUE3, &error_abort); g_free(struct1.string); g_free(a.string); }
[ "static void FUNC_0(TestEventData *VAR_0,\nconst void *VAR_1)\n{", "UserDefOne struct1;", "EventStructOne a;", "UserDefZero z;", "QDict *d, *d_data, *d_a, *d_struct1;", "z.integer = 2;", "struct1.base = &z;", "struct1.string = g_strdup(\"test1\");", "struct1.has_enum1 = true;", "struct1.enum1 = ENUM_ONE_VALUE1;", "a.struct1 = &struct1;", "a.string = g_strdup(\"test2\");", "a.has_enum2 = true;", "a.enum2 = ENUM_ONE_VALUE2;", "d_struct1 = qdict_new();", "qdict_put(d_struct1, \"integer\", qint_from_int(2));", "qdict_put(d_struct1, \"string\", qstring_from_str(\"test1\"));", "qdict_put(d_struct1, \"enum1\", qstring_from_str(\"value1\"));", "d_a = qdict_new();", "qdict_put(d_a, \"struct1\", d_struct1);", "qdict_put(d_a, \"string\", qstring_from_str(\"test2\"));", "qdict_put(d_a, \"enum2\", qstring_from_str(\"value2\"));", "d_data = qdict_new();", "qdict_put(d_data, \"a\", d_a);", "qdict_put(d_data, \"b\", qstring_from_str(\"test3\"));", "qdict_put(d_data, \"enum3\", qstring_from_str(\"value3\"));", "d = VAR_0->expect;", "qdict_put(d, \"event\", qstring_from_str(\"EVENT_D\"));", "qdict_put(d, \"VAR_0\", d_data);", "qapi_event_send_event_d(&a, \"test3\", false, NULL, true, ENUM_ONE_VALUE3,\n&error_abort);", "g_free(struct1.string);", "g_free(a.string);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 69 ], [ 71 ], [ 73 ], [ 77, 79 ], [ 83 ], [ 85 ], [ 87 ] ]
9,957
void ide_init2(IDEBus *bus, DriveInfo *hd0, DriveInfo *hd1, qemu_irq irq) { IDEState *s; static int drive_serial = 1; int i, cylinders, heads, secs; uint64_t nb_sectors; for(i = 0; i < 2; i++) { s = bus->ifs + i; s->bus = bus; s->unit = i; if (i == 0 && hd0) s->bs = hd0->bdrv; if (i == 1 && hd1) s->bs = hd1->bdrv; s->io_buffer = qemu_blockalign(s->bs, IDE_DMA_BUF_SECTORS*512 + 4); if (s->bs) { bdrv_get_geometry(s->bs, &nb_sectors); bdrv_guess_geometry(s->bs, &cylinders, &heads, &secs); s->cylinders = cylinders; s->heads = heads; s->sectors = secs; s->nb_sectors = nb_sectors; /* The SMART values should be preserved across power cycles but they aren't. */ s->smart_enabled = 1; s->smart_autosave = 1; s->smart_errors = 0; s->smart_selftest_count = 0; s->smart_selftest_data = qemu_blockalign(s->bs, 512); if (bdrv_get_type_hint(s->bs) == BDRV_TYPE_CDROM) { s->is_cdrom = 1; bdrv_set_change_cb(s->bs, cdrom_change_cb, s); } } s->drive_serial = drive_serial++; strncpy(s->drive_serial_str, drive_get_serial(s->bs), sizeof(s->drive_serial_str)); if (strlen(s->drive_serial_str) == 0) snprintf(s->drive_serial_str, sizeof(s->drive_serial_str), "QM%05d", s->drive_serial); s->sector_write_timer = qemu_new_timer(vm_clock, ide_sector_write_timer_cb, s); ide_reset(s); } bus->irq = irq; }
false
qemu
88804180fd705d3c4f3dd50e0b9bd7b70c5db0ef
void ide_init2(IDEBus *bus, DriveInfo *hd0, DriveInfo *hd1, qemu_irq irq) { IDEState *s; static int drive_serial = 1; int i, cylinders, heads, secs; uint64_t nb_sectors; for(i = 0; i < 2; i++) { s = bus->ifs + i; s->bus = bus; s->unit = i; if (i == 0 && hd0) s->bs = hd0->bdrv; if (i == 1 && hd1) s->bs = hd1->bdrv; s->io_buffer = qemu_blockalign(s->bs, IDE_DMA_BUF_SECTORS*512 + 4); if (s->bs) { bdrv_get_geometry(s->bs, &nb_sectors); bdrv_guess_geometry(s->bs, &cylinders, &heads, &secs); s->cylinders = cylinders; s->heads = heads; s->sectors = secs; s->nb_sectors = nb_sectors; s->smart_enabled = 1; s->smart_autosave = 1; s->smart_errors = 0; s->smart_selftest_count = 0; s->smart_selftest_data = qemu_blockalign(s->bs, 512); if (bdrv_get_type_hint(s->bs) == BDRV_TYPE_CDROM) { s->is_cdrom = 1; bdrv_set_change_cb(s->bs, cdrom_change_cb, s); } } s->drive_serial = drive_serial++; strncpy(s->drive_serial_str, drive_get_serial(s->bs), sizeof(s->drive_serial_str)); if (strlen(s->drive_serial_str) == 0) snprintf(s->drive_serial_str, sizeof(s->drive_serial_str), "QM%05d", s->drive_serial); s->sector_write_timer = qemu_new_timer(vm_clock, ide_sector_write_timer_cb, s); ide_reset(s); } bus->irq = irq; }
{ "code": [], "line_no": [] }
void FUNC_0(IDEBus *VAR_0, DriveInfo *VAR_1, DriveInfo *VAR_2, qemu_irq VAR_3) { IDEState *s; static int VAR_4 = 1; int VAR_5, VAR_6, VAR_7, VAR_8; uint64_t nb_sectors; for(VAR_5 = 0; VAR_5 < 2; VAR_5++) { s = VAR_0->ifs + VAR_5; s->VAR_0 = VAR_0; s->unit = VAR_5; if (VAR_5 == 0 && VAR_1) s->bs = VAR_1->bdrv; if (VAR_5 == 1 && VAR_2) s->bs = VAR_2->bdrv; s->io_buffer = qemu_blockalign(s->bs, IDE_DMA_BUF_SECTORS*512 + 4); if (s->bs) { bdrv_get_geometry(s->bs, &nb_sectors); bdrv_guess_geometry(s->bs, &VAR_6, &VAR_7, &VAR_8); s->VAR_6 = VAR_6; s->VAR_7 = VAR_7; s->sectors = VAR_8; s->nb_sectors = nb_sectors; s->smart_enabled = 1; s->smart_autosave = 1; s->smart_errors = 0; s->smart_selftest_count = 0; s->smart_selftest_data = qemu_blockalign(s->bs, 512); if (bdrv_get_type_hint(s->bs) == BDRV_TYPE_CDROM) { s->is_cdrom = 1; bdrv_set_change_cb(s->bs, cdrom_change_cb, s); } } s->VAR_4 = VAR_4++; strncpy(s->drive_serial_str, drive_get_serial(s->bs), sizeof(s->drive_serial_str)); if (strlen(s->drive_serial_str) == 0) snprintf(s->drive_serial_str, sizeof(s->drive_serial_str), "QM%05d", s->VAR_4); s->sector_write_timer = qemu_new_timer(vm_clock, ide_sector_write_timer_cb, s); ide_reset(s); } VAR_0->VAR_3 = VAR_3; }
[ "void FUNC_0(IDEBus *VAR_0, DriveInfo *VAR_1, DriveInfo *VAR_2,\nqemu_irq VAR_3)\n{", "IDEState *s;", "static int VAR_4 = 1;", "int VAR_5, VAR_6, VAR_7, VAR_8;", "uint64_t nb_sectors;", "for(VAR_5 = 0; VAR_5 < 2; VAR_5++) {", "s = VAR_0->ifs + VAR_5;", "s->VAR_0 = VAR_0;", "s->unit = VAR_5;", "if (VAR_5 == 0 && VAR_1)\ns->bs = VAR_1->bdrv;", "if (VAR_5 == 1 && VAR_2)\ns->bs = VAR_2->bdrv;", "s->io_buffer = qemu_blockalign(s->bs, IDE_DMA_BUF_SECTORS*512 + 4);", "if (s->bs) {", "bdrv_get_geometry(s->bs, &nb_sectors);", "bdrv_guess_geometry(s->bs, &VAR_6, &VAR_7, &VAR_8);", "s->VAR_6 = VAR_6;", "s->VAR_7 = VAR_7;", "s->sectors = VAR_8;", "s->nb_sectors = nb_sectors;", "s->smart_enabled = 1;", "s->smart_autosave = 1;", "s->smart_errors = 0;", "s->smart_selftest_count = 0;", "s->smart_selftest_data = qemu_blockalign(s->bs, 512);", "if (bdrv_get_type_hint(s->bs) == BDRV_TYPE_CDROM) {", "s->is_cdrom = 1;", "bdrv_set_change_cb(s->bs, cdrom_change_cb, s);", "}", "}", "s->VAR_4 = VAR_4++;", "strncpy(s->drive_serial_str, drive_get_serial(s->bs),\nsizeof(s->drive_serial_str));", "if (strlen(s->drive_serial_str) == 0)\nsnprintf(s->drive_serial_str, sizeof(s->drive_serial_str),\n\"QM%05d\", s->VAR_4);", "s->sector_write_timer = qemu_new_timer(vm_clock,\nide_sector_write_timer_cb, s);", "ide_reset(s);", "}", "VAR_0->VAR_3 = 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 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25, 27 ], [ 29, 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75, 77 ], [ 79, 81, 83 ], [ 85, 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ] ]
9,958
BdrvChild *bdrv_root_attach_child(BlockDriverState *child_bs, const char *child_name, const BdrvChildRole *child_role, uint64_t perm, uint64_t shared_perm, void *opaque, Error **errp) { BdrvChild *child; int ret; ret = bdrv_check_update_perm(child_bs, perm, shared_perm, NULL, errp); if (ret < 0) { return NULL; } child = g_new(BdrvChild, 1); *child = (BdrvChild) { .bs = NULL, .name = g_strdup(child_name), .role = child_role, .perm = perm, .shared_perm = shared_perm, .opaque = opaque, }; bdrv_replace_child(child, child_bs); return child; }
false
qemu
33a610c398603efafd954c706ba07850835a5098
BdrvChild *bdrv_root_attach_child(BlockDriverState *child_bs, const char *child_name, const BdrvChildRole *child_role, uint64_t perm, uint64_t shared_perm, void *opaque, Error **errp) { BdrvChild *child; int ret; ret = bdrv_check_update_perm(child_bs, perm, shared_perm, NULL, errp); if (ret < 0) { return NULL; } child = g_new(BdrvChild, 1); *child = (BdrvChild) { .bs = NULL, .name = g_strdup(child_name), .role = child_role, .perm = perm, .shared_perm = shared_perm, .opaque = opaque, }; bdrv_replace_child(child, child_bs); return child; }
{ "code": [], "line_no": [] }
BdrvChild *FUNC_0(BlockDriverState *child_bs, const char *child_name, const BdrvChildRole *child_role, uint64_t perm, uint64_t shared_perm, void *opaque, Error **errp) { BdrvChild *child; int VAR_0; VAR_0 = bdrv_check_update_perm(child_bs, perm, shared_perm, NULL, errp); if (VAR_0 < 0) { return NULL; } child = g_new(BdrvChild, 1); *child = (BdrvChild) { .bs = NULL, .name = g_strdup(child_name), .role = child_role, .perm = perm, .shared_perm = shared_perm, .opaque = opaque, }; bdrv_replace_child(child, child_bs); return child; }
[ "BdrvChild *FUNC_0(BlockDriverState *child_bs,\nconst char *child_name,\nconst BdrvChildRole *child_role,\nuint64_t perm, uint64_t shared_perm,\nvoid *opaque, Error **errp)\n{", "BdrvChild *child;", "int VAR_0;", "VAR_0 = bdrv_check_update_perm(child_bs, perm, shared_perm, NULL, errp);", "if (VAR_0 < 0) {", "return NULL;", "}", "child = g_new(BdrvChild, 1);", "*child = (BdrvChild) {", ".bs = NULL,\n.name = g_strdup(child_name),\n.role = child_role,\n.perm = perm,\n.shared_perm = shared_perm,\n.opaque = opaque,\n};", "bdrv_replace_child(child, child_bs);", "return child;", "}" ]
[ 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 ], [ 49 ], [ 53 ], [ 55 ] ]
9,959
static void do_eject(int argc, const char **argv) { BlockDriverState *bs; const char **parg; int force; parg = argv + 1; if (!*parg) { fail: help_cmd(argv[0]); return; } force = 0; if (!strcmp(*parg, "-f")) { force = 1; parg++; } if (!*parg) goto fail; bs = bdrv_find(*parg); if (!bs) { term_printf("device not found\n"); return; } eject_device(bs, force); }
false
qemu
9307c4c1d93939db9b04117b654253af5113dc21
static void do_eject(int argc, const char **argv) { BlockDriverState *bs; const char **parg; int force; parg = argv + 1; if (!*parg) { fail: help_cmd(argv[0]); return; } force = 0; if (!strcmp(*parg, "-f")) { force = 1; parg++; } if (!*parg) goto fail; bs = bdrv_find(*parg); if (!bs) { term_printf("device not found\n"); return; } eject_device(bs, force); }
{ "code": [], "line_no": [] }
static void FUNC_0(int VAR_0, const char **VAR_1) { BlockDriverState *bs; const char **VAR_2; int VAR_3; VAR_2 = VAR_1 + 1; if (!*VAR_2) { fail: help_cmd(VAR_1[0]); return; } VAR_3 = 0; if (!strcmp(*VAR_2, "-f")) { VAR_3 = 1; VAR_2++; } if (!*VAR_2) goto fail; bs = bdrv_find(*VAR_2); if (!bs) { term_printf("device not found\n"); return; } eject_device(bs, VAR_3); }
[ "static void FUNC_0(int VAR_0, const char **VAR_1)\n{", "BlockDriverState *bs;", "const char **VAR_2;", "int VAR_3;", "VAR_2 = VAR_1 + 1;", "if (!*VAR_2) {", "fail:\nhelp_cmd(VAR_1[0]);", "return;", "}", "VAR_3 = 0;", "if (!strcmp(*VAR_2, \"-f\")) {", "VAR_3 = 1;", "VAR_2++;", "}", "if (!*VAR_2)\ngoto fail;", "bs = bdrv_find(*VAR_2);", "if (!bs) {", "term_printf(\"device not found\\n\");", "return;", "}", "eject_device(bs, VAR_3);", "}" ]
[ 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 ] ]
9,960
long do_sigreturn(CPUSH4State *regs) { struct target_sigframe *frame; abi_ulong frame_addr; sigset_t blocked; target_sigset_t target_set; target_ulong r0; int i; int err = 0; #if defined(DEBUG_SIGNAL) fprintf(stderr, "do_sigreturn\n"); #endif frame_addr = regs->gregs[15]; if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) goto badframe; err |= __get_user(target_set.sig[0], &frame->sc.oldmask); for(i = 1; i < TARGET_NSIG_WORDS; i++) { err |= (__get_user(target_set.sig[i], &frame->extramask[i - 1])); } if (err) goto badframe; target_to_host_sigset_internal(&blocked, &target_set); sigprocmask(SIG_SETMASK, &blocked, NULL); if (restore_sigcontext(regs, &frame->sc, &r0)) goto badframe; unlock_user_struct(frame, frame_addr, 0); return r0; badframe: unlock_user_struct(frame, frame_addr, 0); force_sig(TARGET_SIGSEGV); return 0; }
false
qemu
1c275925bfbbc2de84a8f0e09d1dd70bbefb6da3
long do_sigreturn(CPUSH4State *regs) { struct target_sigframe *frame; abi_ulong frame_addr; sigset_t blocked; target_sigset_t target_set; target_ulong r0; int i; int err = 0; #if defined(DEBUG_SIGNAL) fprintf(stderr, "do_sigreturn\n"); #endif frame_addr = regs->gregs[15]; if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) goto badframe; err |= __get_user(target_set.sig[0], &frame->sc.oldmask); for(i = 1; i < TARGET_NSIG_WORDS; i++) { err |= (__get_user(target_set.sig[i], &frame->extramask[i - 1])); } if (err) goto badframe; target_to_host_sigset_internal(&blocked, &target_set); sigprocmask(SIG_SETMASK, &blocked, NULL); if (restore_sigcontext(regs, &frame->sc, &r0)) goto badframe; unlock_user_struct(frame, frame_addr, 0); return r0; badframe: unlock_user_struct(frame, frame_addr, 0); force_sig(TARGET_SIGSEGV); return 0; }
{ "code": [], "line_no": [] }
long FUNC_0(CPUSH4State *VAR_0) { struct target_sigframe *VAR_1; abi_ulong frame_addr; sigset_t blocked; target_sigset_t target_set; target_ulong r0; int VAR_2; int VAR_3 = 0; #if defined(DEBUG_SIGNAL) fprintf(stderr, "FUNC_0\n"); #endif frame_addr = VAR_0->gregs[15]; if (!lock_user_struct(VERIFY_READ, VAR_1, frame_addr, 1)) goto badframe; VAR_3 |= __get_user(target_set.sig[0], &VAR_1->sc.oldmask); for(VAR_2 = 1; VAR_2 < TARGET_NSIG_WORDS; VAR_2++) { VAR_3 |= (__get_user(target_set.sig[VAR_2], &VAR_1->extramask[VAR_2 - 1])); } if (VAR_3) goto badframe; target_to_host_sigset_internal(&blocked, &target_set); sigprocmask(SIG_SETMASK, &blocked, NULL); if (restore_sigcontext(VAR_0, &VAR_1->sc, &r0)) goto badframe; unlock_user_struct(VAR_1, frame_addr, 0); return r0; badframe: unlock_user_struct(VAR_1, frame_addr, 0); force_sig(TARGET_SIGSEGV); return 0; }
[ "long FUNC_0(CPUSH4State *VAR_0)\n{", "struct target_sigframe *VAR_1;", "abi_ulong frame_addr;", "sigset_t blocked;", "target_sigset_t target_set;", "target_ulong r0;", "int VAR_2;", "int VAR_3 = 0;", "#if defined(DEBUG_SIGNAL)\nfprintf(stderr, \"FUNC_0\\n\");", "#endif\nframe_addr = VAR_0->gregs[15];", "if (!lock_user_struct(VERIFY_READ, VAR_1, frame_addr, 1))\ngoto badframe;", "VAR_3 |= __get_user(target_set.sig[0], &VAR_1->sc.oldmask);", "for(VAR_2 = 1; VAR_2 < TARGET_NSIG_WORDS; VAR_2++) {", "VAR_3 |= (__get_user(target_set.sig[VAR_2], &VAR_1->extramask[VAR_2 - 1]));", "}", "if (VAR_3)\ngoto badframe;", "target_to_host_sigset_internal(&blocked, &target_set);", "sigprocmask(SIG_SETMASK, &blocked, NULL);", "if (restore_sigcontext(VAR_0, &VAR_1->sc, &r0))\ngoto badframe;", "unlock_user_struct(VAR_1, frame_addr, 0);", "return r0;", "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, 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 ], [ 45, 47 ], [ 51 ], [ 53 ], [ 57, 59 ], [ 63 ], [ 65 ], [ 69, 71 ], [ 73 ], [ 75 ], [ 77 ] ]
9,962
static uint64_t pcnet_ioport_read(void *opaque, target_phys_addr_t addr, unsigned size) { PCNetState *d = opaque; if (addr < 16 && size == 1) { return pcnet_aprom_readb(d, addr); } else if (addr >= 0x10 && addr < 0x20 && size == 2) { return pcnet_ioport_readw(d, addr); } else if (addr >= 0x10 && addr < 0x20 && size == 4) { return pcnet_ioport_readl(d, addr); } return ((uint64_t)1 << (size * 8)) - 1; }
false
qemu
7ba7974197090285fdb413c6e1c41aaacd44b9c4
static uint64_t pcnet_ioport_read(void *opaque, target_phys_addr_t addr, unsigned size) { PCNetState *d = opaque; if (addr < 16 && size == 1) { return pcnet_aprom_readb(d, addr); } else if (addr >= 0x10 && addr < 0x20 && size == 2) { return pcnet_ioport_readw(d, addr); } else if (addr >= 0x10 && addr < 0x20 && size == 4) { return pcnet_ioport_readl(d, addr); } return ((uint64_t)1 << (size * 8)) - 1; }
{ "code": [], "line_no": [] }
static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr, unsigned size) { PCNetState *d = opaque; if (addr < 16 && size == 1) { return pcnet_aprom_readb(d, addr); } else if (addr >= 0x10 && addr < 0x20 && size == 2) { return pcnet_ioport_readw(d, addr); } else if (addr >= 0x10 && addr < 0x20 && size == 4) { return pcnet_ioport_readl(d, addr); } return ((uint64_t)1 << (size * 8)) - 1; }
[ "static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr,\nunsigned size)\n{", "PCNetState *d = opaque;", "if (addr < 16 && size == 1) {", "return pcnet_aprom_readb(d, addr);", "} else if (addr >= 0x10 && addr < 0x20 && size == 2) {", "return pcnet_ioport_readw(d, addr);", "} else if (addr >= 0x10 && addr < 0x20 && size == 4) {", "return pcnet_ioport_readl(d, addr);", "}", "return ((uint64_t)1 << (size * 8)) - 1;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ] ]
9,963
int cpu_x86_gen_code(uint8_t *gen_code_buf, int max_code_size, int *gen_code_size_ptr, uint8_t *pc_start, uint8_t *cs_base, int flags) { DisasContext dc1, *dc = &dc1; uint8_t *pc_ptr; uint16_t *gen_opc_end; int gen_code_size; long ret; #ifdef DEBUG_DISAS struct disassemble_info disasm_info; #endif /* generate intermediate code */ dc->code32 = (flags >> GEN_FLAG_CODE32_SHIFT) & 1; dc->ss32 = (flags >> GEN_FLAG_SS32_SHIFT) & 1; dc->addseg = (flags >> GEN_FLAG_ADDSEG_SHIFT) & 1; dc->f_st = (flags >> GEN_FLAG_ST_SHIFT) & 7; dc->cc_op = CC_OP_DYNAMIC; dc->cs_base = cs_base; gen_opc_ptr = gen_opc_buf; gen_opc_end = gen_opc_buf + OPC_MAX_SIZE; gen_opparam_ptr = gen_opparam_buf; dc->is_jmp = 0; pc_ptr = pc_start; do { ret = disas_insn(dc, pc_ptr); if (ret == -1) { /* we trigger an illegal instruction operation only if it is the first instruction. Otherwise, we simply stop generating the code just before it */ if (pc_ptr == pc_start) return -1; else break; } pc_ptr = (void *)ret; } while (!dc->is_jmp && gen_opc_ptr < gen_opc_end); /* we must store the eflags state if it is not already done */ if (dc->cc_op != CC_OP_DYNAMIC) gen_op_set_cc_op(dc->cc_op); if (dc->is_jmp != 1) { /* we add an additionnal jmp to update the simulated PC */ gen_op_jmp_im(ret - (unsigned long)dc->cs_base); } *gen_opc_ptr = INDEX_op_end; /* optimize flag computations */ #ifdef DEBUG_DISAS if (loglevel) { uint8_t *pc; int count; INIT_DISASSEMBLE_INFO(disasm_info, logfile, fprintf); #if 0 disasm_info.flavour = bfd_get_flavour (abfd); disasm_info.arch = bfd_get_arch (abfd); disasm_info.mach = bfd_get_mach (abfd); #endif disasm_info.endian = BFD_ENDIAN_LITTLE; if (dc->code32) disasm_info.mach = bfd_mach_i386_i386; else disasm_info.mach = bfd_mach_i386_i8086; fprintf(logfile, "----------------\n"); fprintf(logfile, "IN:\n"); disasm_info.buffer = pc_start; disasm_info.buffer_vma = (unsigned long)pc_start; disasm_info.buffer_length = pc_ptr - pc_start; pc = pc_start; while (pc < pc_ptr) { fprintf(logfile, "0x%08lx: ", (long)pc); count = print_insn_i386((unsigned long)pc, &disasm_info); fprintf(logfile, "\n"); pc += count; } fprintf(logfile, "\n"); fprintf(logfile, "OP:\n"); dump_ops(gen_opc_buf); fprintf(logfile, "\n"); } #endif /* optimize flag computations */ optimize_flags(gen_opc_buf, gen_opc_ptr - gen_opc_buf); #ifdef DEBUG_DISAS if (loglevel) { fprintf(logfile, "AFTER FLAGS OPT:\n"); dump_ops(gen_opc_buf); fprintf(logfile, "\n"); } #endif /* generate machine code */ gen_code_size = dyngen_code(gen_code_buf, gen_opc_buf, gen_opparam_buf); flush_icache_range((unsigned long)gen_code_buf, (unsigned long)(gen_code_buf + gen_code_size)); *gen_code_size_ptr = gen_code_size; #ifdef DEBUG_DISAS if (loglevel) { uint8_t *pc; int count; INIT_DISASSEMBLE_INFO(disasm_info, logfile, fprintf); #if 0 disasm_info.flavour = bfd_get_flavour (abfd); disasm_info.arch = bfd_get_arch (abfd); disasm_info.mach = bfd_get_mach (abfd); #endif #ifdef WORDS_BIGENDIAN disasm_info.endian = BFD_ENDIAN_BIG; #else disasm_info.endian = BFD_ENDIAN_LITTLE; #endif disasm_info.mach = bfd_mach_i386_i386; pc = gen_code_buf; disasm_info.buffer = pc; disasm_info.buffer_vma = (unsigned long)pc; disasm_info.buffer_length = *gen_code_size_ptr; fprintf(logfile, "OUT: [size=%d]\n", *gen_code_size_ptr); while (pc < gen_code_buf + *gen_code_size_ptr) { fprintf(logfile, "0x%08lx: ", (long)pc); count = print_insn_i386((unsigned long)pc, &disasm_info); fprintf(logfile, "\n"); pc += count; } fprintf(logfile, "\n"); fflush(logfile); } #endif return 0; }
false
qemu
9c605cb13547a5faa5cb1092e3e44ac8b0d0b841
int cpu_x86_gen_code(uint8_t *gen_code_buf, int max_code_size, int *gen_code_size_ptr, uint8_t *pc_start, uint8_t *cs_base, int flags) { DisasContext dc1, *dc = &dc1; uint8_t *pc_ptr; uint16_t *gen_opc_end; int gen_code_size; long ret; #ifdef DEBUG_DISAS struct disassemble_info disasm_info; #endif dc->code32 = (flags >> GEN_FLAG_CODE32_SHIFT) & 1; dc->ss32 = (flags >> GEN_FLAG_SS32_SHIFT) & 1; dc->addseg = (flags >> GEN_FLAG_ADDSEG_SHIFT) & 1; dc->f_st = (flags >> GEN_FLAG_ST_SHIFT) & 7; dc->cc_op = CC_OP_DYNAMIC; dc->cs_base = cs_base; gen_opc_ptr = gen_opc_buf; gen_opc_end = gen_opc_buf + OPC_MAX_SIZE; gen_opparam_ptr = gen_opparam_buf; dc->is_jmp = 0; pc_ptr = pc_start; do { ret = disas_insn(dc, pc_ptr); if (ret == -1) { if (pc_ptr == pc_start) return -1; else break; } pc_ptr = (void *)ret; } while (!dc->is_jmp && gen_opc_ptr < gen_opc_end); if (dc->cc_op != CC_OP_DYNAMIC) gen_op_set_cc_op(dc->cc_op); if (dc->is_jmp != 1) { gen_op_jmp_im(ret - (unsigned long)dc->cs_base); } *gen_opc_ptr = INDEX_op_end; #ifdef DEBUG_DISAS if (loglevel) { uint8_t *pc; int count; INIT_DISASSEMBLE_INFO(disasm_info, logfile, fprintf); #if 0 disasm_info.flavour = bfd_get_flavour (abfd); disasm_info.arch = bfd_get_arch (abfd); disasm_info.mach = bfd_get_mach (abfd); #endif disasm_info.endian = BFD_ENDIAN_LITTLE; if (dc->code32) disasm_info.mach = bfd_mach_i386_i386; else disasm_info.mach = bfd_mach_i386_i8086; fprintf(logfile, "----------------\n"); fprintf(logfile, "IN:\n"); disasm_info.buffer = pc_start; disasm_info.buffer_vma = (unsigned long)pc_start; disasm_info.buffer_length = pc_ptr - pc_start; pc = pc_start; while (pc < pc_ptr) { fprintf(logfile, "0x%08lx: ", (long)pc); count = print_insn_i386((unsigned long)pc, &disasm_info); fprintf(logfile, "\n"); pc += count; } fprintf(logfile, "\n"); fprintf(logfile, "OP:\n"); dump_ops(gen_opc_buf); fprintf(logfile, "\n"); } #endif optimize_flags(gen_opc_buf, gen_opc_ptr - gen_opc_buf); #ifdef DEBUG_DISAS if (loglevel) { fprintf(logfile, "AFTER FLAGS OPT:\n"); dump_ops(gen_opc_buf); fprintf(logfile, "\n"); } #endif gen_code_size = dyngen_code(gen_code_buf, gen_opc_buf, gen_opparam_buf); flush_icache_range((unsigned long)gen_code_buf, (unsigned long)(gen_code_buf + gen_code_size)); *gen_code_size_ptr = gen_code_size; #ifdef DEBUG_DISAS if (loglevel) { uint8_t *pc; int count; INIT_DISASSEMBLE_INFO(disasm_info, logfile, fprintf); #if 0 disasm_info.flavour = bfd_get_flavour (abfd); disasm_info.arch = bfd_get_arch (abfd); disasm_info.mach = bfd_get_mach (abfd); #endif #ifdef WORDS_BIGENDIAN disasm_info.endian = BFD_ENDIAN_BIG; #else disasm_info.endian = BFD_ENDIAN_LITTLE; #endif disasm_info.mach = bfd_mach_i386_i386; pc = gen_code_buf; disasm_info.buffer = pc; disasm_info.buffer_vma = (unsigned long)pc; disasm_info.buffer_length = *gen_code_size_ptr; fprintf(logfile, "OUT: [size=%d]\n", *gen_code_size_ptr); while (pc < gen_code_buf + *gen_code_size_ptr) { fprintf(logfile, "0x%08lx: ", (long)pc); count = print_insn_i386((unsigned long)pc, &disasm_info); fprintf(logfile, "\n"); pc += count; } fprintf(logfile, "\n"); fflush(logfile); } #endif return 0; }
{ "code": [], "line_no": [] }
int FUNC_0(uint8_t *VAR_0, int VAR_1, int *VAR_2, uint8_t *VAR_3, uint8_t *VAR_4, int VAR_5) { DisasContext dc1, *dc = &dc1; uint8_t *pc_ptr; uint16_t *gen_opc_end; int VAR_6; long VAR_7; #ifdef DEBUG_DISAS struct disassemble_info disasm_info; #endif dc->code32 = (VAR_5 >> GEN_FLAG_CODE32_SHIFT) & 1; dc->ss32 = (VAR_5 >> GEN_FLAG_SS32_SHIFT) & 1; dc->addseg = (VAR_5 >> GEN_FLAG_ADDSEG_SHIFT) & 1; dc->f_st = (VAR_5 >> GEN_FLAG_ST_SHIFT) & 7; dc->cc_op = CC_OP_DYNAMIC; dc->VAR_4 = VAR_4; gen_opc_ptr = gen_opc_buf; gen_opc_end = gen_opc_buf + OPC_MAX_SIZE; gen_opparam_ptr = gen_opparam_buf; dc->is_jmp = 0; pc_ptr = VAR_3; do { VAR_7 = disas_insn(dc, pc_ptr); if (VAR_7 == -1) { if (pc_ptr == VAR_3) return -1; else break; } pc_ptr = (void *)VAR_7; } while (!dc->is_jmp && gen_opc_ptr < gen_opc_end); if (dc->cc_op != CC_OP_DYNAMIC) gen_op_set_cc_op(dc->cc_op); if (dc->is_jmp != 1) { gen_op_jmp_im(VAR_7 - (unsigned long)dc->VAR_4); } *gen_opc_ptr = INDEX_op_end; #ifdef DEBUG_DISAS if (loglevel) { uint8_t *pc; int count; INIT_DISASSEMBLE_INFO(disasm_info, logfile, fprintf); #if 0 disasm_info.flavour = bfd_get_flavour (abfd); disasm_info.arch = bfd_get_arch (abfd); disasm_info.mach = bfd_get_mach (abfd); #endif disasm_info.endian = BFD_ENDIAN_LITTLE; if (dc->code32) disasm_info.mach = bfd_mach_i386_i386; else disasm_info.mach = bfd_mach_i386_i8086; fprintf(logfile, "----------------\n"); fprintf(logfile, "IN:\n"); disasm_info.buffer = VAR_3; disasm_info.buffer_vma = (unsigned long)VAR_3; disasm_info.buffer_length = pc_ptr - VAR_3; pc = VAR_3; while (pc < pc_ptr) { fprintf(logfile, "0x%08lx: ", (long)pc); count = print_insn_i386((unsigned long)pc, &disasm_info); fprintf(logfile, "\n"); pc += count; } fprintf(logfile, "\n"); fprintf(logfile, "OP:\n"); dump_ops(gen_opc_buf); fprintf(logfile, "\n"); } #endif optimize_flags(gen_opc_buf, gen_opc_ptr - gen_opc_buf); #ifdef DEBUG_DISAS if (loglevel) { fprintf(logfile, "AFTER FLAGS OPT:\n"); dump_ops(gen_opc_buf); fprintf(logfile, "\n"); } #endif VAR_6 = dyngen_code(VAR_0, gen_opc_buf, gen_opparam_buf); flush_icache_range((unsigned long)VAR_0, (unsigned long)(VAR_0 + VAR_6)); *VAR_2 = VAR_6; #ifdef DEBUG_DISAS if (loglevel) { uint8_t *pc; int count; INIT_DISASSEMBLE_INFO(disasm_info, logfile, fprintf); #if 0 disasm_info.flavour = bfd_get_flavour (abfd); disasm_info.arch = bfd_get_arch (abfd); disasm_info.mach = bfd_get_mach (abfd); #endif #ifdef WORDS_BIGENDIAN disasm_info.endian = BFD_ENDIAN_BIG; #else disasm_info.endian = BFD_ENDIAN_LITTLE; #endif disasm_info.mach = bfd_mach_i386_i386; pc = VAR_0; disasm_info.buffer = pc; disasm_info.buffer_vma = (unsigned long)pc; disasm_info.buffer_length = *VAR_2; fprintf(logfile, "OUT: [size=%d]\n", *VAR_2); while (pc < VAR_0 + *VAR_2) { fprintf(logfile, "0x%08lx: ", (long)pc); count = print_insn_i386((unsigned long)pc, &disasm_info); fprintf(logfile, "\n"); pc += count; } fprintf(logfile, "\n"); fflush(logfile); } #endif return 0; }
[ "int FUNC_0(uint8_t *VAR_0, int VAR_1,\nint *VAR_2,\nuint8_t *VAR_3, uint8_t *VAR_4, int VAR_5)\n{", "DisasContext dc1, *dc = &dc1;", "uint8_t *pc_ptr;", "uint16_t *gen_opc_end;", "int VAR_6;", "long VAR_7;", "#ifdef DEBUG_DISAS\nstruct disassemble_info disasm_info;", "#endif\ndc->code32 = (VAR_5 >> GEN_FLAG_CODE32_SHIFT) & 1;", "dc->ss32 = (VAR_5 >> GEN_FLAG_SS32_SHIFT) & 1;", "dc->addseg = (VAR_5 >> GEN_FLAG_ADDSEG_SHIFT) & 1;", "dc->f_st = (VAR_5 >> GEN_FLAG_ST_SHIFT) & 7;", "dc->cc_op = CC_OP_DYNAMIC;", "dc->VAR_4 = VAR_4;", "gen_opc_ptr = gen_opc_buf;", "gen_opc_end = gen_opc_buf + OPC_MAX_SIZE;", "gen_opparam_ptr = gen_opparam_buf;", "dc->is_jmp = 0;", "pc_ptr = VAR_3;", "do {", "VAR_7 = disas_insn(dc, pc_ptr);", "if (VAR_7 == -1) {", "if (pc_ptr == VAR_3)\nreturn -1;", "else\nbreak;", "}", "pc_ptr = (void *)VAR_7;", "} while (!dc->is_jmp && gen_opc_ptr < gen_opc_end);", "if (dc->cc_op != CC_OP_DYNAMIC)\ngen_op_set_cc_op(dc->cc_op);", "if (dc->is_jmp != 1) {", "gen_op_jmp_im(VAR_7 - (unsigned long)dc->VAR_4);", "}", "*gen_opc_ptr = INDEX_op_end;", "#ifdef DEBUG_DISAS\nif (loglevel) {", "uint8_t *pc;", "int count;", "INIT_DISASSEMBLE_INFO(disasm_info, logfile, fprintf);", "#if 0\ndisasm_info.flavour = bfd_get_flavour (abfd);", "disasm_info.arch = bfd_get_arch (abfd);", "disasm_info.mach = bfd_get_mach (abfd);", "#endif\ndisasm_info.endian = BFD_ENDIAN_LITTLE;", "if (dc->code32)\ndisasm_info.mach = bfd_mach_i386_i386;", "else\ndisasm_info.mach = bfd_mach_i386_i8086;", "fprintf(logfile, \"----------------\\n\");", "fprintf(logfile, \"IN:\\n\");", "disasm_info.buffer = VAR_3;", "disasm_info.buffer_vma = (unsigned long)VAR_3;", "disasm_info.buffer_length = pc_ptr - VAR_3;", "pc = VAR_3;", "while (pc < pc_ptr) {", "fprintf(logfile, \"0x%08lx: \", (long)pc);", "count = print_insn_i386((unsigned long)pc, &disasm_info);", "fprintf(logfile, \"\\n\");", "pc += count;", "}", "fprintf(logfile, \"\\n\");", "fprintf(logfile, \"OP:\\n\");", "dump_ops(gen_opc_buf);", "fprintf(logfile, \"\\n\");", "}", "#endif\noptimize_flags(gen_opc_buf, gen_opc_ptr - gen_opc_buf);", "#ifdef DEBUG_DISAS\nif (loglevel) {", "fprintf(logfile, \"AFTER FLAGS OPT:\\n\");", "dump_ops(gen_opc_buf);", "fprintf(logfile, \"\\n\");", "}", "#endif\nVAR_6 = dyngen_code(VAR_0, gen_opc_buf, gen_opparam_buf);", "flush_icache_range((unsigned long)VAR_0, (unsigned long)(VAR_0 + VAR_6));", "*VAR_2 = VAR_6;", "#ifdef DEBUG_DISAS\nif (loglevel) {", "uint8_t *pc;", "int count;", "INIT_DISASSEMBLE_INFO(disasm_info, logfile, fprintf);", "#if 0\ndisasm_info.flavour = bfd_get_flavour (abfd);", "disasm_info.arch = bfd_get_arch (abfd);", "disasm_info.mach = bfd_get_mach (abfd);", "#endif\n#ifdef WORDS_BIGENDIAN\ndisasm_info.endian = BFD_ENDIAN_BIG;", "#else\ndisasm_info.endian = BFD_ENDIAN_LITTLE;", "#endif\ndisasm_info.mach = bfd_mach_i386_i386;", "pc = VAR_0;", "disasm_info.buffer = pc;", "disasm_info.buffer_vma = (unsigned long)pc;", "disasm_info.buffer_length = *VAR_2;", "fprintf(logfile, \"OUT: [size=%d]\\n\", *VAR_2);", "while (pc < VAR_0 + *VAR_2) {", "fprintf(logfile, \"0x%08lx: \", (long)pc);", "count = print_insn_i386((unsigned long)pc, &disasm_info);", "fprintf(logfile, \"\\n\");", "pc += count;", "}", "fprintf(logfile, \"\\n\");", "fflush(logfile);", "}", "#endif\nreturn 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 45 ], [ 47 ], [ 49 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 69, 71 ], [ 73, 75 ], [ 77 ], [ 79 ], [ 81 ], [ 85, 87 ], [ 89 ], [ 93 ], [ 95 ], [ 97 ], [ 103, 105 ], [ 107 ], [ 109 ], [ 113 ], [ 115, 117 ], [ 119 ], [ 121 ], [ 123, 125 ], [ 127, 129 ], [ 131, 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ], [ 171, 177 ], [ 181, 183 ], [ 185 ], [ 187 ], [ 189 ], [ 191 ], [ 193, 199 ], [ 201 ], [ 203 ], [ 207, 209 ], [ 211 ], [ 213 ], [ 217 ], [ 219, 221 ], [ 223 ], [ 225 ], [ 227, 229, 231 ], [ 233, 235 ], [ 237, 239 ], [ 243 ], [ 245 ], [ 247 ], [ 249 ], [ 251 ], [ 253 ], [ 255 ], [ 257 ], [ 259 ], [ 261 ], [ 263 ], [ 265 ], [ 267 ], [ 269 ], [ 271, 273 ], [ 275 ] ]
9,965
static void parse_type_int64(Visitor *v, const char *name, int64_t *obj, Error **errp) { StringInputVisitor *siv = to_siv(v); if (!siv->string) { error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null", "integer"); return; } if (parse_str(siv, name, errp) < 0) { return; } if (!siv->ranges) { goto error; } if (!siv->cur_range) { Range *r; siv->cur_range = g_list_first(siv->ranges); if (!siv->cur_range) { goto error; } r = siv->cur_range->data; if (!r) { goto error; } siv->cur = r->begin; } *obj = siv->cur; siv->cur++; return; error: error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null", "an int64 value or range"); }
false
qemu
a0efbf16604770b9d805bcf210ec29942321134f
static void parse_type_int64(Visitor *v, const char *name, int64_t *obj, Error **errp) { StringInputVisitor *siv = to_siv(v); if (!siv->string) { error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null", "integer"); return; } if (parse_str(siv, name, errp) < 0) { return; } if (!siv->ranges) { goto error; } if (!siv->cur_range) { Range *r; siv->cur_range = g_list_first(siv->ranges); if (!siv->cur_range) { goto error; } r = siv->cur_range->data; if (!r) { goto error; } siv->cur = r->begin; } *obj = siv->cur; siv->cur++; return; error: error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null", "an int64 value or range"); }
{ "code": [], "line_no": [] }
static void FUNC_0(Visitor *VAR_0, const char *VAR_1, int64_t *VAR_2, Error **VAR_3) { StringInputVisitor *siv = to_siv(VAR_0); if (!siv->string) { error_setg(VAR_3, QERR_INVALID_PARAMETER_TYPE, VAR_1 ? VAR_1 : "null", "integer"); return; } if (parse_str(siv, VAR_1, VAR_3) < 0) { return; } if (!siv->ranges) { goto error; } if (!siv->cur_range) { Range *r; siv->cur_range = g_list_first(siv->ranges); if (!siv->cur_range) { goto error; } r = siv->cur_range->data; if (!r) { goto error; } siv->cur = r->begin; } *VAR_2 = siv->cur; siv->cur++; return; error: error_setg(VAR_3, QERR_INVALID_PARAMETER_VALUE, VAR_1 ? VAR_1 : "null", "an int64 value or range"); }
[ "static void FUNC_0(Visitor *VAR_0, const char *VAR_1, int64_t *VAR_2,\nError **VAR_3)\n{", "StringInputVisitor *siv = to_siv(VAR_0);", "if (!siv->string) {", "error_setg(VAR_3, QERR_INVALID_PARAMETER_TYPE, VAR_1 ? VAR_1 : \"null\",\n\"integer\");", "return;", "}", "if (parse_str(siv, VAR_1, VAR_3) < 0) {", "return;", "}", "if (!siv->ranges) {", "goto error;", "}", "if (!siv->cur_range) {", "Range *r;", "siv->cur_range = g_list_first(siv->ranges);", "if (!siv->cur_range) {", "goto error;", "}", "r = siv->cur_range->data;", "if (!r) {", "goto error;", "}", "siv->cur = r->begin;", "}", "*VAR_2 = siv->cur;", "siv->cur++;", "return;", "error:\nerror_setg(VAR_3, QERR_INVALID_PARAMETER_VALUE, VAR_1 ? VAR_1 : \"null\",\n\"an int64 value or range\");", "}" ]
[ 0, 0, 0, 0, 0, 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 ], [ 23 ], [ 25 ], [ 27 ], [ 31 ], [ 33 ], [ 35 ], [ 39 ], [ 41 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 65 ], [ 67 ], [ 71 ], [ 73 ], [ 75 ], [ 79, 81, 83 ], [ 85 ] ]