id
int32
0
27.3k
func
stringlengths
26
142k
target
bool
2 classes
project
stringclasses
2 values
commit_id
stringlengths
40
40
func_clean
stringlengths
26
131k
vul_lines
dict
normalized_func
stringlengths
24
132k
lines
sequencelengths
1
2.8k
label
sequencelengths
1
2.8k
line_no
sequencelengths
1
2.8k
22,118
static BlockStats *bdrv_query_stats(BlockBackend *blk, const BlockDriverState *bs, bool query_backing) { BlockStats *s; s = bdrv_query_bds_stats(bs, query_backing); if (blk) { s->has_device = true; s->device = g_strdup(blk_name(blk)); bdrv_query_blk_stats(s->stats, blk); } return s; }
false
qemu
a6baa60807f88ba7d97b1787797fb58882ccbfb9
static BlockStats *bdrv_query_stats(BlockBackend *blk, const BlockDriverState *bs, bool query_backing) { BlockStats *s; s = bdrv_query_bds_stats(bs, query_backing); if (blk) { s->has_device = true; s->device = g_strdup(blk_name(blk)); bdrv_query_blk_stats(s->stats, blk); } return s; }
{ "code": [], "line_no": [] }
static BlockStats *FUNC_0(BlockBackend *blk, const BlockDriverState *bs, bool query_backing) { BlockStats *s; s = bdrv_query_bds_stats(bs, query_backing); if (blk) { s->has_device = true; s->device = g_strdup(blk_name(blk)); bdrv_query_blk_stats(s->stats, blk); } return s; }
[ "static BlockStats *FUNC_0(BlockBackend *blk,\nconst BlockDriverState *bs,\nbool query_backing)\n{", "BlockStats *s;", "s = bdrv_query_bds_stats(bs, query_backing);", "if (blk) {", "s->has_device = true;", "s->device = g_strdup(blk_name(blk));", "bdrv_query_blk_stats(s->stats, blk);", "}", "return s;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 29 ], [ 31 ] ]
22,120
ip_init(void) { ipq.ip_link.next = ipq.ip_link.prev = &ipq.ip_link; ip_id = tt.tv_sec & 0xffff; udp_init(); tcp_init(); }
false
qemu
285f7a62e464eac97e472ba6803ddede1e6c459e
ip_init(void) { ipq.ip_link.next = ipq.ip_link.prev = &ipq.ip_link; ip_id = tt.tv_sec & 0xffff; udp_init(); tcp_init(); }
{ "code": [], "line_no": [] }
FUNC_0(void) { ipq.ip_link.next = ipq.ip_link.prev = &ipq.ip_link; ip_id = tt.tv_sec & 0xffff; udp_init(); tcp_init(); }
[ "FUNC_0(void)\n{", "ipq.ip_link.next = ipq.ip_link.prev = &ipq.ip_link;", "ip_id = tt.tv_sec & 0xffff;", "udp_init();", "tcp_init();", "}" ]
[ 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ] ]
22,121
static IOMMUTLBEntry typhoon_translate_iommu(MemoryRegion *iommu, hwaddr addr, bool is_write) { TyphoonPchip *pchip = container_of(iommu, TyphoonPchip, iommu); IOMMUTLBEntry ret; int i; if (addr <= 0xffffffffu) { /* Single-address cycle. */ /* Check for the Window Hole, inhibiting matching. */ if ((pchip->ctl & 0x20) && addr >= 0x80000 && addr <= 0xfffff) { goto failure; } /* Check the first three windows. */ for (i = 0; i < 3; ++i) { if (window_translate(&pchip->win[i], addr, &ret)) { goto success; } } /* Check the fourth window for DAC disable. */ if ((pchip->win[3].wba & 0x80000000000ull) == 0 && window_translate(&pchip->win[3], addr, &ret)) { goto success; } } else { /* Double-address cycle. */ if (addr >= 0x10000000000ull && addr < 0x20000000000ull) { /* Check for the DMA monster window. */ if (pchip->ctl & 0x40) { /* See 10.1.4.4; in particular <39:35> is ignored. */ make_iommu_tlbe(0, 0x007ffffffffull, &ret); goto success; } } if (addr >= 0x80000000000ull && addr <= 0xfffffffffffull) { /* Check the fourth window for DAC enable and window enable. */ if ((pchip->win[3].wba & 0x80000000001ull) == 0x80000000001ull) { uint64_t pte_addr; pte_addr = pchip->win[3].tba & 0x7ffc00000ull; pte_addr |= (addr & 0xffffe000u) >> 10; if (pte_translate(pte_addr, &ret)) { goto success; } } } } failure: ret = (IOMMUTLBEntry) { .perm = IOMMU_NONE }; success: return ret; }
false
qemu
bf55b7afce53718ef96f4e6616da62c0ccac37dd
static IOMMUTLBEntry typhoon_translate_iommu(MemoryRegion *iommu, hwaddr addr, bool is_write) { TyphoonPchip *pchip = container_of(iommu, TyphoonPchip, iommu); IOMMUTLBEntry ret; int i; if (addr <= 0xffffffffu) { if ((pchip->ctl & 0x20) && addr >= 0x80000 && addr <= 0xfffff) { goto failure; } for (i = 0; i < 3; ++i) { if (window_translate(&pchip->win[i], addr, &ret)) { goto success; } } if ((pchip->win[3].wba & 0x80000000000ull) == 0 && window_translate(&pchip->win[3], addr, &ret)) { goto success; } } else { if (addr >= 0x10000000000ull && addr < 0x20000000000ull) { if (pchip->ctl & 0x40) { make_iommu_tlbe(0, 0x007ffffffffull, &ret); goto success; } } if (addr >= 0x80000000000ull && addr <= 0xfffffffffffull) { if ((pchip->win[3].wba & 0x80000000001ull) == 0x80000000001ull) { uint64_t pte_addr; pte_addr = pchip->win[3].tba & 0x7ffc00000ull; pte_addr |= (addr & 0xffffe000u) >> 10; if (pte_translate(pte_addr, &ret)) { goto success; } } } } failure: ret = (IOMMUTLBEntry) { .perm = IOMMU_NONE }; success: return ret; }
{ "code": [], "line_no": [] }
static IOMMUTLBEntry FUNC_0(MemoryRegion *iommu, hwaddr addr, bool is_write) { TyphoonPchip *pchip = container_of(iommu, TyphoonPchip, iommu); IOMMUTLBEntry ret; int VAR_0; if (addr <= 0xffffffffu) { if ((pchip->ctl & 0x20) && addr >= 0x80000 && addr <= 0xfffff) { goto failure; } for (VAR_0 = 0; VAR_0 < 3; ++VAR_0) { if (window_translate(&pchip->win[VAR_0], addr, &ret)) { goto success; } } if ((pchip->win[3].wba & 0x80000000000ull) == 0 && window_translate(&pchip->win[3], addr, &ret)) { goto success; } } else { if (addr >= 0x10000000000ull && addr < 0x20000000000ull) { if (pchip->ctl & 0x40) { make_iommu_tlbe(0, 0x007ffffffffull, &ret); goto success; } } if (addr >= 0x80000000000ull && addr <= 0xfffffffffffull) { if ((pchip->win[3].wba & 0x80000000001ull) == 0x80000000001ull) { uint64_t pte_addr; pte_addr = pchip->win[3].tba & 0x7ffc00000ull; pte_addr |= (addr & 0xffffe000u) >> 10; if (pte_translate(pte_addr, &ret)) { goto success; } } } } failure: ret = (IOMMUTLBEntry) { .perm = IOMMU_NONE }; success: return ret; }
[ "static IOMMUTLBEntry FUNC_0(MemoryRegion *iommu, hwaddr addr,\nbool is_write)\n{", "TyphoonPchip *pchip = container_of(iommu, TyphoonPchip, iommu);", "IOMMUTLBEntry ret;", "int VAR_0;", "if (addr <= 0xffffffffu) {", "if ((pchip->ctl & 0x20)\n&& addr >= 0x80000\n&& addr <= 0xfffff) {", "goto failure;", "}", "for (VAR_0 = 0; VAR_0 < 3; ++VAR_0) {", "if (window_translate(&pchip->win[VAR_0], addr, &ret)) {", "goto success;", "}", "}", "if ((pchip->win[3].wba & 0x80000000000ull) == 0\n&& window_translate(&pchip->win[3], addr, &ret)) {", "goto success;", "}", "} else {", "if (addr >= 0x10000000000ull && addr < 0x20000000000ull) {", "if (pchip->ctl & 0x40) {", "make_iommu_tlbe(0, 0x007ffffffffull, &ret);", "goto success;", "}", "}", "if (addr >= 0x80000000000ull && addr <= 0xfffffffffffull) {", "if ((pchip->win[3].wba & 0x80000000001ull) == 0x80000000001ull) {", "uint64_t pte_addr;", "pte_addr = pchip->win[3].tba & 0x7ffc00000ull;", "pte_addr |= (addr & 0xffffe000u) >> 10;", "if (pte_translate(pte_addr, &ret)) {", "goto success;", "}", "}", "}", "}", "failure:\nret = (IOMMUTLBEntry) { .perm = IOMMU_NONE };", "success:\nreturn 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 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 23, 25, 27 ], [ 29 ], [ 31 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 51, 53 ], [ 55 ], [ 57 ], [ 59 ], [ 65 ], [ 69 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 83 ], [ 87 ], [ 89 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 111, 113 ], [ 115, 117 ], [ 119 ] ]
22,122
void json_prop_str(QJSON *json, const char *name, const char *str) { json_emit_element(json, name); qstring_append_chr(json->str, '"'); qstring_append(json->str, str); qstring_append_chr(json->str, '"'); }
false
qemu
17b74b98676aee5bc470b173b1e528d2fce2cf18
void json_prop_str(QJSON *json, const char *name, const char *str) { json_emit_element(json, name); qstring_append_chr(json->str, '"'); qstring_append(json->str, str); qstring_append_chr(json->str, '"'); }
{ "code": [], "line_no": [] }
void FUNC_0(QJSON *VAR_0, const char *VAR_1, const char *VAR_2) { json_emit_element(VAR_0, VAR_1); qstring_append_chr(VAR_0->VAR_2, '"'); qstring_append(VAR_0->VAR_2, VAR_2); qstring_append_chr(VAR_0->VAR_2, '"'); }
[ "void FUNC_0(QJSON *VAR_0, const char *VAR_1, const char *VAR_2)\n{", "json_emit_element(VAR_0, VAR_1);", "qstring_append_chr(VAR_0->VAR_2, '\"');", "qstring_append(VAR_0->VAR_2, VAR_2);", "qstring_append_chr(VAR_0->VAR_2, '\"');", "}" ]
[ 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ] ]
22,123
static void encode_signal_range(VC2EncContext *s) { int idx; AVCodecContext *avctx = s->avctx; const AVPixFmtDescriptor *fmt = av_pix_fmt_desc_get(avctx->pix_fmt); const int depth = fmt->comp[0].depth; if (depth == 8 && avctx->color_range == AVCOL_RANGE_JPEG) { idx = 1; s->bpp = 1; s->diff_offset = 128; } else if (depth == 8 && (avctx->color_range == AVCOL_RANGE_MPEG || avctx->color_range == AVCOL_RANGE_UNSPECIFIED)) { idx = 2; s->bpp = 1; s->diff_offset = 128; } else if (depth == 10) { idx = 3; s->bpp = 2; s->diff_offset = 512; } else { idx = 4; s->bpp = 2; s->diff_offset = 2048; } put_bits(&s->pb, 1, !s->strict_compliance); if (!s->strict_compliance) put_vc2_ue_uint(&s->pb, idx); }
true
FFmpeg
b88be742fac7a77a8095e8155ba8790db4b77568
static void encode_signal_range(VC2EncContext *s) { int idx; AVCodecContext *avctx = s->avctx; const AVPixFmtDescriptor *fmt = av_pix_fmt_desc_get(avctx->pix_fmt); const int depth = fmt->comp[0].depth; if (depth == 8 && avctx->color_range == AVCOL_RANGE_JPEG) { idx = 1; s->bpp = 1; s->diff_offset = 128; } else if (depth == 8 && (avctx->color_range == AVCOL_RANGE_MPEG || avctx->color_range == AVCOL_RANGE_UNSPECIFIED)) { idx = 2; s->bpp = 1; s->diff_offset = 128; } else if (depth == 10) { idx = 3; s->bpp = 2; s->diff_offset = 512; } else { idx = 4; s->bpp = 2; s->diff_offset = 2048; } put_bits(&s->pb, 1, !s->strict_compliance); if (!s->strict_compliance) put_vc2_ue_uint(&s->pb, idx); }
{ "code": [ " int idx;", " AVCodecContext *avctx = s->avctx;", " const AVPixFmtDescriptor *fmt = av_pix_fmt_desc_get(avctx->pix_fmt);", " const int depth = fmt->comp[0].depth;", " if (depth == 8 && avctx->color_range == AVCOL_RANGE_JPEG) {", " idx = 1;", " s->bpp = 1;", " s->diff_offset = 128;", " } else if (depth == 8 && (avctx->color_range == AVCOL_RANGE_MPEG ||", " avctx->color_range == AVCOL_RANGE_UNSPECIFIED)) {", " idx = 2;", " s->bpp = 1;", " s->diff_offset = 128;", " } else if (depth == 10) {", " idx = 3;", " s->bpp = 2;", " s->diff_offset = 512;", " } else {", " idx = 4;", " s->bpp = 2;", " s->diff_offset = 2048;", " put_vc2_ue_uint(&s->pb, idx);", " } else {", " } else {" ], "line_no": [ 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 17, 19, 31, 33, 35, 37, 39, 41, 35, 45, 53, 39, 39 ] }
static void FUNC_0(VC2EncContext *VAR_0) { int VAR_1; AVCodecContext *avctx = VAR_0->avctx; const AVPixFmtDescriptor *VAR_2 = av_pix_fmt_desc_get(avctx->pix_fmt); const int VAR_3 = VAR_2->comp[0].VAR_3; if (VAR_3 == 8 && avctx->color_range == AVCOL_RANGE_JPEG) { VAR_1 = 1; VAR_0->bpp = 1; VAR_0->diff_offset = 128; } else if (VAR_3 == 8 && (avctx->color_range == AVCOL_RANGE_MPEG || avctx->color_range == AVCOL_RANGE_UNSPECIFIED)) { VAR_1 = 2; VAR_0->bpp = 1; VAR_0->diff_offset = 128; } else if (VAR_3 == 10) { VAR_1 = 3; VAR_0->bpp = 2; VAR_0->diff_offset = 512; } else { VAR_1 = 4; VAR_0->bpp = 2; VAR_0->diff_offset = 2048; } put_bits(&VAR_0->pb, 1, !VAR_0->strict_compliance); if (!VAR_0->strict_compliance) put_vc2_ue_uint(&VAR_0->pb, VAR_1); }
[ "static void FUNC_0(VC2EncContext *VAR_0)\n{", "int VAR_1;", "AVCodecContext *avctx = VAR_0->avctx;", "const AVPixFmtDescriptor *VAR_2 = av_pix_fmt_desc_get(avctx->pix_fmt);", "const int VAR_3 = VAR_2->comp[0].VAR_3;", "if (VAR_3 == 8 && avctx->color_range == AVCOL_RANGE_JPEG) {", "VAR_1 = 1;", "VAR_0->bpp = 1;", "VAR_0->diff_offset = 128;", "} else if (VAR_3 == 8 && (avctx->color_range == AVCOL_RANGE_MPEG ||", "avctx->color_range == AVCOL_RANGE_UNSPECIFIED)) {", "VAR_1 = 2;", "VAR_0->bpp = 1;", "VAR_0->diff_offset = 128;", "} else if (VAR_3 == 10) {", "VAR_1 = 3;", "VAR_0->bpp = 2;", "VAR_0->diff_offset = 512;", "} else {", "VAR_1 = 4;", "VAR_0->bpp = 2;", "VAR_0->diff_offset = 2048;", "}", "put_bits(&VAR_0->pb, 1, !VAR_0->strict_compliance);", "if (!VAR_0->strict_compliance)\nput_vc2_ue_uint(&VAR_0->pb, VAR_1);", "}" ]
[ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51, 53 ], [ 55 ] ]
22,125
static av_cold int tta_decode_init(AVCodecContext * avctx) { TTAContext *s = avctx->priv_data; int i; s->avctx = avctx; // 30bytes includes a seektable with one frame if (avctx->extradata_size < 30) return -1; init_get_bits(&s->gb, avctx->extradata, avctx->extradata_size * 8); if (show_bits_long(&s->gb, 32) == AV_RL32("TTA1")) { /* signature */ skip_bits(&s->gb, 32); s->format = get_bits(&s->gb, 16); if (s->format > 2) { av_log(s->avctx, AV_LOG_ERROR, "Invalid format\n"); return -1; if (s->format == FORMAT_ENCRYPTED) { av_log_missing_feature(s->avctx, "Encrypted TTA", 0); return AVERROR(EINVAL); avctx->channels = s->channels = get_bits(&s->gb, 16); avctx->bits_per_coded_sample = get_bits(&s->gb, 16); s->bps = (avctx->bits_per_coded_sample + 7) / 8; avctx->sample_rate = get_bits_long(&s->gb, 32); s->data_length = get_bits_long(&s->gb, 32); skip_bits(&s->gb, 32); // CRC32 of header switch(s->bps) { case 2: avctx->sample_fmt = AV_SAMPLE_FMT_S16; avctx->bits_per_raw_sample = 16; break; case 3: avctx->sample_fmt = AV_SAMPLE_FMT_S32; avctx->bits_per_raw_sample = 24; break; default: av_log(avctx, AV_LOG_ERROR, "Invalid/unsupported sample format.\n"); // prevent overflow if (avctx->sample_rate > 0x7FFFFF) { av_log(avctx, AV_LOG_ERROR, "sample_rate too large\n"); return AVERROR(EINVAL); s->frame_length = 256 * avctx->sample_rate / 245; s->last_frame_length = s->data_length % s->frame_length; s->total_frames = s->data_length / s->frame_length + (s->last_frame_length ? 1 : 0); av_log(s->avctx, AV_LOG_DEBUG, "format: %d chans: %d bps: %d rate: %d block: %d\n", s->format, avctx->channels, avctx->bits_per_coded_sample, avctx->sample_rate, avctx->block_align); av_log(s->avctx, AV_LOG_DEBUG, "data_length: %d frame_length: %d last: %d total: %d\n", s->data_length, s->frame_length, s->last_frame_length, s->total_frames); // FIXME: seek table for (i = 0; i < s->total_frames; i++) skip_bits(&s->gb, 32); skip_bits(&s->gb, 32); // CRC32 of seektable if(s->frame_length >= UINT_MAX / (s->channels * sizeof(int32_t))){ av_log(avctx, AV_LOG_ERROR, "frame_length too large\n"); return -1; if (s->bps == 2) { s->decode_buffer = av_mallocz(sizeof(int32_t)*s->frame_length*s->channels); if (!s->decode_buffer) return AVERROR(ENOMEM); s->ch_ctx = av_malloc(avctx->channels * sizeof(*s->ch_ctx)); if (!s->ch_ctx) { av_freep(&s->decode_buffer); return AVERROR(ENOMEM); } else { av_log(avctx, AV_LOG_ERROR, "Wrong extradata present\n"); return -1; avcodec_get_frame_defaults(&s->frame); avctx->coded_frame = &s->frame; return 0;
true
FFmpeg
8bd1f1a4c8e591e92e7f4933a89fe5de72e5563f
static av_cold int tta_decode_init(AVCodecContext * avctx) { TTAContext *s = avctx->priv_data; int i; s->avctx = avctx; if (avctx->extradata_size < 30) return -1; init_get_bits(&s->gb, avctx->extradata, avctx->extradata_size * 8); if (show_bits_long(&s->gb, 32) == AV_RL32("TTA1")) { skip_bits(&s->gb, 32); s->format = get_bits(&s->gb, 16); if (s->format > 2) { av_log(s->avctx, AV_LOG_ERROR, "Invalid format\n"); return -1; if (s->format == FORMAT_ENCRYPTED) { av_log_missing_feature(s->avctx, "Encrypted TTA", 0); return AVERROR(EINVAL); avctx->channels = s->channels = get_bits(&s->gb, 16); avctx->bits_per_coded_sample = get_bits(&s->gb, 16); s->bps = (avctx->bits_per_coded_sample + 7) / 8; avctx->sample_rate = get_bits_long(&s->gb, 32); s->data_length = get_bits_long(&s->gb, 32); skip_bits(&s->gb, 32); switch(s->bps) { case 2: avctx->sample_fmt = AV_SAMPLE_FMT_S16; avctx->bits_per_raw_sample = 16; break; case 3: avctx->sample_fmt = AV_SAMPLE_FMT_S32; avctx->bits_per_raw_sample = 24; break; default: av_log(avctx, AV_LOG_ERROR, "Invalid/unsupported sample format.\n"); if (avctx->sample_rate > 0x7FFFFF) { av_log(avctx, AV_LOG_ERROR, "sample_rate too large\n"); return AVERROR(EINVAL); s->frame_length = 256 * avctx->sample_rate / 245; s->last_frame_length = s->data_length % s->frame_length; s->total_frames = s->data_length / s->frame_length + (s->last_frame_length ? 1 : 0); av_log(s->avctx, AV_LOG_DEBUG, "format: %d chans: %d bps: %d rate: %d block: %d\n", s->format, avctx->channels, avctx->bits_per_coded_sample, avctx->sample_rate, avctx->block_align); av_log(s->avctx, AV_LOG_DEBUG, "data_length: %d frame_length: %d last: %d total: %d\n", s->data_length, s->frame_length, s->last_frame_length, s->total_frames); for (i = 0; i < s->total_frames; i++) skip_bits(&s->gb, 32); skip_bits(&s->gb, 32); if(s->frame_length >= UINT_MAX / (s->channels * sizeof(int32_t))){ av_log(avctx, AV_LOG_ERROR, "frame_length too large\n"); return -1; if (s->bps == 2) { s->decode_buffer = av_mallocz(sizeof(int32_t)*s->frame_length*s->channels); if (!s->decode_buffer) return AVERROR(ENOMEM); s->ch_ctx = av_malloc(avctx->channels * sizeof(*s->ch_ctx)); if (!s->ch_ctx) { av_freep(&s->decode_buffer); return AVERROR(ENOMEM); } else { av_log(avctx, AV_LOG_ERROR, "Wrong extradata present\n"); return -1; avcodec_get_frame_defaults(&s->frame); avctx->coded_frame = &s->frame; return 0;
{ "code": [], "line_no": [] }
static av_cold int FUNC_0(AVCodecContext * avctx) { TTAContext *s = avctx->priv_data; int VAR_0; s->avctx = avctx; if (avctx->extradata_size < 30) return -1; init_get_bits(&s->gb, avctx->extradata, avctx->extradata_size * 8); if (show_bits_long(&s->gb, 32) == AV_RL32("TTA1")) { skip_bits(&s->gb, 32); s->format = get_bits(&s->gb, 16); if (s->format > 2) { av_log(s->avctx, AV_LOG_ERROR, "Invalid format\n"); return -1; if (s->format == FORMAT_ENCRYPTED) { av_log_missing_feature(s->avctx, "Encrypted TTA", 0); return AVERROR(EINVAL); avctx->channels = s->channels = get_bits(&s->gb, 16); avctx->bits_per_coded_sample = get_bits(&s->gb, 16); s->bps = (avctx->bits_per_coded_sample + 7) / 8; avctx->sample_rate = get_bits_long(&s->gb, 32); s->data_length = get_bits_long(&s->gb, 32); skip_bits(&s->gb, 32); switch(s->bps) { case 2: avctx->sample_fmt = AV_SAMPLE_FMT_S16; avctx->bits_per_raw_sample = 16; break; case 3: avctx->sample_fmt = AV_SAMPLE_FMT_S32; avctx->bits_per_raw_sample = 24; break; default: av_log(avctx, AV_LOG_ERROR, "Invalid/unsupported sample format.\n"); if (avctx->sample_rate > 0x7FFFFF) { av_log(avctx, AV_LOG_ERROR, "sample_rate too large\n"); return AVERROR(EINVAL); s->frame_length = 256 * avctx->sample_rate / 245; s->last_frame_length = s->data_length % s->frame_length; s->total_frames = s->data_length / s->frame_length + (s->last_frame_length ? 1 : 0); av_log(s->avctx, AV_LOG_DEBUG, "format: %d chans: %d bps: %d rate: %d block: %d\n", s->format, avctx->channels, avctx->bits_per_coded_sample, avctx->sample_rate, avctx->block_align); av_log(s->avctx, AV_LOG_DEBUG, "data_length: %d frame_length: %d last: %d total: %d\n", s->data_length, s->frame_length, s->last_frame_length, s->total_frames); for (VAR_0 = 0; VAR_0 < s->total_frames; VAR_0++) skip_bits(&s->gb, 32); skip_bits(&s->gb, 32); if(s->frame_length >= UINT_MAX / (s->channels * sizeof(int32_t))){ av_log(avctx, AV_LOG_ERROR, "frame_length too large\n"); return -1; if (s->bps == 2) { s->decode_buffer = av_mallocz(sizeof(int32_t)*s->frame_length*s->channels); if (!s->decode_buffer) return AVERROR(ENOMEM); s->ch_ctx = av_malloc(avctx->channels * sizeof(*s->ch_ctx)); if (!s->ch_ctx) { av_freep(&s->decode_buffer); return AVERROR(ENOMEM); } else { av_log(avctx, AV_LOG_ERROR, "Wrong extradata present\n"); return -1; avcodec_get_frame_defaults(&s->frame); avctx->coded_frame = &s->frame; return 0;
[ "static av_cold int FUNC_0(AVCodecContext * avctx)\n{", "TTAContext *s = avctx->priv_data;", "int VAR_0;", "s->avctx = avctx;", "if (avctx->extradata_size < 30)\nreturn -1;", "init_get_bits(&s->gb, avctx->extradata, avctx->extradata_size * 8);", "if (show_bits_long(&s->gb, 32) == AV_RL32(\"TTA1\"))\n{", "skip_bits(&s->gb, 32);", "s->format = get_bits(&s->gb, 16);", "if (s->format > 2) {", "av_log(s->avctx, AV_LOG_ERROR, \"Invalid format\\n\");", "return -1;", "if (s->format == FORMAT_ENCRYPTED) {", "av_log_missing_feature(s->avctx, \"Encrypted TTA\", 0);", "return AVERROR(EINVAL);", "avctx->channels = s->channels = get_bits(&s->gb, 16);", "avctx->bits_per_coded_sample = get_bits(&s->gb, 16);", "s->bps = (avctx->bits_per_coded_sample + 7) / 8;", "avctx->sample_rate = get_bits_long(&s->gb, 32);", "s->data_length = get_bits_long(&s->gb, 32);", "skip_bits(&s->gb, 32);", "switch(s->bps) {", "case 2:\navctx->sample_fmt = AV_SAMPLE_FMT_S16;", "avctx->bits_per_raw_sample = 16;", "break;", "case 3:\navctx->sample_fmt = AV_SAMPLE_FMT_S32;", "avctx->bits_per_raw_sample = 24;", "break;", "default:\nav_log(avctx, AV_LOG_ERROR, \"Invalid/unsupported sample format.\\n\");", "if (avctx->sample_rate > 0x7FFFFF) {", "av_log(avctx, AV_LOG_ERROR, \"sample_rate too large\\n\");", "return AVERROR(EINVAL);", "s->frame_length = 256 * avctx->sample_rate / 245;", "s->last_frame_length = s->data_length % s->frame_length;", "s->total_frames = s->data_length / s->frame_length +\n(s->last_frame_length ? 1 : 0);", "av_log(s->avctx, AV_LOG_DEBUG, \"format: %d chans: %d bps: %d rate: %d block: %d\\n\",\ns->format, avctx->channels, avctx->bits_per_coded_sample, avctx->sample_rate,\navctx->block_align);", "av_log(s->avctx, AV_LOG_DEBUG, \"data_length: %d frame_length: %d last: %d total: %d\\n\",\ns->data_length, s->frame_length, s->last_frame_length, s->total_frames);", "for (VAR_0 = 0; VAR_0 < s->total_frames; VAR_0++)", "skip_bits(&s->gb, 32);", "skip_bits(&s->gb, 32);", "if(s->frame_length >= UINT_MAX / (s->channels * sizeof(int32_t))){", "av_log(avctx, AV_LOG_ERROR, \"frame_length too large\\n\");", "return -1;", "if (s->bps == 2) {", "s->decode_buffer = av_mallocz(sizeof(int32_t)*s->frame_length*s->channels);", "if (!s->decode_buffer)\nreturn AVERROR(ENOMEM);", "s->ch_ctx = av_malloc(avctx->channels * sizeof(*s->ch_ctx));", "if (!s->ch_ctx) {", "av_freep(&s->decode_buffer);", "return AVERROR(ENOMEM);", "} else {", "av_log(avctx, AV_LOG_ERROR, \"Wrong extradata present\\n\");", "return -1;", "avcodec_get_frame_defaults(&s->frame);", "avctx->coded_frame = &s->frame;", "return 0;" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 2 ], [ 3 ], [ 4 ], [ 5 ], [ 7, 8 ], [ 9 ], [ 10, 11 ], [ 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 ], [ 39 ], [ 40 ], [ 41 ], [ 42 ], [ 43 ], [ 44, 45 ], [ 46, 47, 48 ], [ 49, 50 ], [ 52 ], [ 53 ], [ 54 ], [ 55 ], [ 56 ], [ 57 ], [ 58 ], [ 59 ], [ 60, 61 ], [ 62 ], [ 63 ], [ 64 ], [ 65 ], [ 66 ], [ 67 ], [ 68 ], [ 69 ], [ 70 ], [ 71 ] ]
22,126
static void memory_region_write_accessor(MemoryRegion *mr, hwaddr addr, uint64_t *value, unsigned size, unsigned shift, uint64_t mask) { uint64_t tmp; if (mr->flush_coalesced_mmio) { qemu_flush_coalesced_mmio_buffer(); } tmp = (*value >> shift) & mask; trace_memory_region_ops_write(mr, addr, tmp, size); mr->ops->write(mr->opaque, addr, tmp, size); }
true
qemu
cc05c43ad942165ecc6ffd39e41991bee43af044
static void memory_region_write_accessor(MemoryRegion *mr, hwaddr addr, uint64_t *value, unsigned size, unsigned shift, uint64_t mask) { uint64_t tmp; if (mr->flush_coalesced_mmio) { qemu_flush_coalesced_mmio_buffer(); } tmp = (*value >> shift) & mask; trace_memory_region_ops_write(mr, addr, tmp, size); mr->ops->write(mr->opaque, addr, tmp, size); }
{ "code": [ " uint64_t tmp;", "static void memory_region_write_accessor(MemoryRegion *mr,", " hwaddr addr,", " uint64_t *value,", " unsigned size,", " unsigned shift,", " uint64_t mask)", " hwaddr addr," ], "line_no": [ 15, 1, 3, 5, 7, 9, 11, 3 ] }
static void FUNC_0(MemoryRegion *VAR_0, hwaddr VAR_1, uint64_t *VAR_2, unsigned VAR_3, unsigned VAR_4, uint64_t VAR_5) { uint64_t tmp; if (VAR_0->flush_coalesced_mmio) { qemu_flush_coalesced_mmio_buffer(); } tmp = (*VAR_2 >> VAR_4) & VAR_5; trace_memory_region_ops_write(VAR_0, VAR_1, tmp, VAR_3); VAR_0->ops->write(VAR_0->opaque, VAR_1, tmp, VAR_3); }
[ "static void FUNC_0(MemoryRegion *VAR_0,\nhwaddr VAR_1,\nuint64_t *VAR_2,\nunsigned VAR_3,\nunsigned VAR_4,\nuint64_t VAR_5)\n{", "uint64_t tmp;", "if (VAR_0->flush_coalesced_mmio) {", "qemu_flush_coalesced_mmio_buffer();", "}", "tmp = (*VAR_2 >> VAR_4) & VAR_5;", "trace_memory_region_ops_write(VAR_0, VAR_1, tmp, VAR_3);", "VAR_0->ops->write(VAR_0->opaque, VAR_1, tmp, VAR_3);", "}" ]
[ 1, 1, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9, 11, 13 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ] ]
22,127
static void kvm_ioapic_class_init(ObjectClass *klass, void *data) { IOAPICCommonClass *k = IOAPIC_COMMON_CLASS(klass); DeviceClass *dc = DEVICE_CLASS(klass); k->realize = kvm_ioapic_realize; k->pre_save = kvm_ioapic_get; k->post_load = kvm_ioapic_put; dc->reset = kvm_ioapic_reset; dc->props = kvm_ioapic_properties; }
true
qemu
e4f4fb1eca795e36f363b4647724221e774523c1
static void kvm_ioapic_class_init(ObjectClass *klass, void *data) { IOAPICCommonClass *k = IOAPIC_COMMON_CLASS(klass); DeviceClass *dc = DEVICE_CLASS(klass); k->realize = kvm_ioapic_realize; k->pre_save = kvm_ioapic_get; k->post_load = kvm_ioapic_put; dc->reset = kvm_ioapic_reset; dc->props = kvm_ioapic_properties; }
{ "code": [], "line_no": [] }
static void FUNC_0(ObjectClass *VAR_0, void *VAR_1) { IOAPICCommonClass *k = IOAPIC_COMMON_CLASS(VAR_0); DeviceClass *dc = DEVICE_CLASS(VAR_0); k->realize = kvm_ioapic_realize; k->pre_save = kvm_ioapic_get; k->post_load = kvm_ioapic_put; dc->reset = kvm_ioapic_reset; dc->props = kvm_ioapic_properties; }
[ "static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)\n{", "IOAPICCommonClass *k = IOAPIC_COMMON_CLASS(VAR_0);", "DeviceClass *dc = DEVICE_CLASS(VAR_0);", "k->realize = kvm_ioapic_realize;", "k->pre_save = kvm_ioapic_get;", "k->post_load = kvm_ioapic_put;", "dc->reset = kvm_ioapic_reset;", "dc->props = kvm_ioapic_properties;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 26 ] ]
22,128
void qemu_bh_cancel(QEMUBH *bh) { QEMUBH **pbh; if (bh->scheduled) { pbh = &first_bh; while (*pbh != bh) pbh = &(*pbh)->next; *pbh = bh->next; bh->scheduled = 0; } }
true
qemu
1b435b10324fe9937f254bb00718f78d5e50837a
void qemu_bh_cancel(QEMUBH *bh) { QEMUBH **pbh; if (bh->scheduled) { pbh = &first_bh; while (*pbh != bh) pbh = &(*pbh)->next; *pbh = bh->next; bh->scheduled = 0; } }
{ "code": [ " pbh = &first_bh;", " *pbh = bh->next;", " bh->scheduled = 0;", " QEMUBH **pbh;", " if (bh->scheduled) {", " pbh = &first_bh;", " while (*pbh != bh)", " pbh = &(*pbh)->next;", " *pbh = bh->next;", " bh->scheduled = 0;" ], "line_no": [ 9, 15, 17, 5, 7, 9, 11, 13, 15, 17 ] }
void FUNC_0(QEMUBH *VAR_0) { QEMUBH **pbh; if (VAR_0->scheduled) { pbh = &first_bh; while (*pbh != VAR_0) pbh = &(*pbh)->next; *pbh = VAR_0->next; VAR_0->scheduled = 0; } }
[ "void FUNC_0(QEMUBH *VAR_0)\n{", "QEMUBH **pbh;", "if (VAR_0->scheduled) {", "pbh = &first_bh;", "while (*pbh != VAR_0)\npbh = &(*pbh)->next;", "*pbh = VAR_0->next;", "VAR_0->scheduled = 0;", "}", "}" ]
[ 0, 1, 1, 1, 1, 1, 1, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11, 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ] ]
22,129
static int parse_ffconfig(const char *filename) { FILE *f; char line[1024]; char cmd[64]; char arg[1024]; const char *p; int val, errors, line_num; FFStream **last_stream, *stream, *redirect; FFStream **last_feed, *feed, *s; AVCodecContext audio_enc, video_enc; enum AVCodecID audio_id, video_id; f = fopen(filename, "r"); if (!f) { perror(filename); return -1; } errors = 0; line_num = 0; first_stream = NULL; last_stream = &first_stream; first_feed = NULL; last_feed = &first_feed; stream = NULL; feed = NULL; redirect = NULL; audio_id = AV_CODEC_ID_NONE; video_id = AV_CODEC_ID_NONE; #define ERROR(...) report_config_error(filename, line_num, &errors, __VA_ARGS__) for(;;) { if (fgets(line, sizeof(line), f) == NULL) break; line_num++; p = line; while (av_isspace(*p)) p++; if (*p == '\0' || *p == '#') continue; get_arg(cmd, sizeof(cmd), &p); if (!av_strcasecmp(cmd, "Port")) { get_arg(arg, sizeof(arg), &p); val = atoi(arg); if (val < 1 || val > 65536) { ERROR("Invalid_port: %s\n", arg); } my_http_addr.sin_port = htons(val); } else if (!av_strcasecmp(cmd, "BindAddress")) { get_arg(arg, sizeof(arg), &p); if (resolve_host(&my_http_addr.sin_addr, arg) != 0) { ERROR("%s:%d: Invalid host/IP address: %s\n", arg); } } else if (!av_strcasecmp(cmd, "NoDaemon")) { // do nothing here, its the default now } else if (!av_strcasecmp(cmd, "RTSPPort")) { get_arg(arg, sizeof(arg), &p); val = atoi(arg); if (val < 1 || val > 65536) { ERROR("%s:%d: Invalid port: %s\n", arg); } my_rtsp_addr.sin_port = htons(atoi(arg)); } else if (!av_strcasecmp(cmd, "RTSPBindAddress")) { get_arg(arg, sizeof(arg), &p); if (resolve_host(&my_rtsp_addr.sin_addr, arg) != 0) { ERROR("Invalid host/IP address: %s\n", arg); } } else if (!av_strcasecmp(cmd, "MaxHTTPConnections")) { get_arg(arg, sizeof(arg), &p); val = atoi(arg); if (val < 1 || val > 65536) { ERROR("Invalid MaxHTTPConnections: %s\n", arg); } nb_max_http_connections = val; } else if (!av_strcasecmp(cmd, "MaxClients")) { get_arg(arg, sizeof(arg), &p); val = atoi(arg); if (val < 1 || val > nb_max_http_connections) { ERROR("Invalid MaxClients: %s\n", arg); } else { nb_max_connections = val; } } else if (!av_strcasecmp(cmd, "MaxBandwidth")) { int64_t llval; get_arg(arg, sizeof(arg), &p); llval = strtoll(arg, NULL, 10); if (llval < 10 || llval > 10000000) { ERROR("Invalid MaxBandwidth: %s\n", arg); } else max_bandwidth = llval; } else if (!av_strcasecmp(cmd, "CustomLog")) { if (!ffserver_debug) get_arg(logfilename, sizeof(logfilename), &p); } else if (!av_strcasecmp(cmd, "<Feed")) { /*********************************************/ /* Feed related options */ char *q; if (stream || feed) { ERROR("Already in a tag\n"); } else { feed = av_mallocz(sizeof(FFStream)); get_arg(feed->filename, sizeof(feed->filename), &p); q = strrchr(feed->filename, '>'); if (*q) *q = '\0'; for (s = first_feed; s; s = s->next) { if (!strcmp(feed->filename, s->filename)) { ERROR("Feed '%s' already registered\n", s->filename); } } feed->fmt = av_guess_format("ffm", NULL, NULL); /* defaut feed file */ snprintf(feed->feed_filename, sizeof(feed->feed_filename), "/tmp/%s.ffm", feed->filename); feed->feed_max_size = 5 * 1024 * 1024; feed->is_feed = 1; feed->feed = feed; /* self feeding :-) */ /* add in stream list */ *last_stream = feed; last_stream = &feed->next; /* add in feed list */ *last_feed = feed; last_feed = &feed->next_feed; } } else if (!av_strcasecmp(cmd, "Launch")) { if (feed) { int i; feed->child_argv = av_mallocz(64 * sizeof(char *)); for (i = 0; i < 62; i++) { get_arg(arg, sizeof(arg), &p); if (!arg[0]) break; feed->child_argv[i] = av_strdup(arg); } feed->child_argv[i] = av_asprintf("http://%s:%d/%s", (my_http_addr.sin_addr.s_addr == INADDR_ANY) ? "127.0.0.1" : inet_ntoa(my_http_addr.sin_addr), ntohs(my_http_addr.sin_port), feed->filename); } } else if (!av_strcasecmp(cmd, "ReadOnlyFile")) { if (feed) { get_arg(feed->feed_filename, sizeof(feed->feed_filename), &p); feed->readonly = 1; } else if (stream) { get_arg(stream->feed_filename, sizeof(stream->feed_filename), &p); } } else if (!av_strcasecmp(cmd, "File")) { if (feed) { get_arg(feed->feed_filename, sizeof(feed->feed_filename), &p); } else if (stream) get_arg(stream->feed_filename, sizeof(stream->feed_filename), &p); } else if (!av_strcasecmp(cmd, "Truncate")) { if (feed) { get_arg(arg, sizeof(arg), &p); feed->truncate = strtod(arg, NULL); } } else if (!av_strcasecmp(cmd, "FileMaxSize")) { if (feed) { char *p1; double fsize; get_arg(arg, sizeof(arg), &p); p1 = arg; fsize = strtod(p1, &p1); switch(av_toupper(*p1)) { case 'K': fsize *= 1024; break; case 'M': fsize *= 1024 * 1024; break; case 'G': fsize *= 1024 * 1024 * 1024; break; } feed->feed_max_size = (int64_t)fsize; if (feed->feed_max_size < FFM_PACKET_SIZE*4) { ERROR("Feed max file size is too small, must be at least %d\n", FFM_PACKET_SIZE*4); } } } else if (!av_strcasecmp(cmd, "</Feed>")) { if (!feed) { ERROR("No corresponding <Feed> for </Feed>\n"); } feed = NULL; } else if (!av_strcasecmp(cmd, "<Stream")) { /*********************************************/ /* Stream related options */ char *q; if (stream || feed) { ERROR("Already in a tag\n"); } else { FFStream *s; stream = av_mallocz(sizeof(FFStream)); get_arg(stream->filename, sizeof(stream->filename), &p); q = strrchr(stream->filename, '>'); if (q) *q = '\0'; for (s = first_stream; s; s = s->next) { if (!strcmp(stream->filename, s->filename)) { ERROR("Stream '%s' already registered\n", s->filename); } } stream->fmt = ffserver_guess_format(NULL, stream->filename, NULL); avcodec_get_context_defaults3(&video_enc, NULL); avcodec_get_context_defaults3(&audio_enc, NULL); audio_id = AV_CODEC_ID_NONE; video_id = AV_CODEC_ID_NONE; if (stream->fmt) { audio_id = stream->fmt->audio_codec; video_id = stream->fmt->video_codec; } *last_stream = stream; last_stream = &stream->next; } } else if (!av_strcasecmp(cmd, "Feed")) { get_arg(arg, sizeof(arg), &p); if (stream) { FFStream *sfeed; sfeed = first_feed; while (sfeed != NULL) { if (!strcmp(sfeed->filename, arg)) break; sfeed = sfeed->next_feed; } if (!sfeed) ERROR("feed '%s' not defined\n", arg); else stream->feed = sfeed; } } else if (!av_strcasecmp(cmd, "Format")) { get_arg(arg, sizeof(arg), &p); if (stream) { if (!strcmp(arg, "status")) { stream->stream_type = STREAM_TYPE_STATUS; stream->fmt = NULL; } else { stream->stream_type = STREAM_TYPE_LIVE; /* jpeg cannot be used here, so use single frame jpeg */ if (!strcmp(arg, "jpeg")) strcpy(arg, "mjpeg"); stream->fmt = ffserver_guess_format(arg, NULL, NULL); if (!stream->fmt) { ERROR("Unknown Format: %s\n", arg); } } if (stream->fmt) { audio_id = stream->fmt->audio_codec; video_id = stream->fmt->video_codec; } } } else if (!av_strcasecmp(cmd, "InputFormat")) { get_arg(arg, sizeof(arg), &p); if (stream) { stream->ifmt = av_find_input_format(arg); if (!stream->ifmt) { ERROR("Unknown input format: %s\n", arg); } } } else if (!av_strcasecmp(cmd, "FaviconURL")) { if (stream && stream->stream_type == STREAM_TYPE_STATUS) { get_arg(stream->feed_filename, sizeof(stream->feed_filename), &p); } else { ERROR("FaviconURL only permitted for status streams\n"); } } else if (!av_strcasecmp(cmd, "Author")) { if (stream) get_arg(stream->author, sizeof(stream->author), &p); } else if (!av_strcasecmp(cmd, "Comment")) { if (stream) get_arg(stream->comment, sizeof(stream->comment), &p); } else if (!av_strcasecmp(cmd, "Copyright")) { if (stream) get_arg(stream->copyright, sizeof(stream->copyright), &p); } else if (!av_strcasecmp(cmd, "Title")) { if (stream) get_arg(stream->title, sizeof(stream->title), &p); } else if (!av_strcasecmp(cmd, "Preroll")) { get_arg(arg, sizeof(arg), &p); if (stream) stream->prebuffer = atof(arg) * 1000; } else if (!av_strcasecmp(cmd, "StartSendOnKey")) { if (stream) stream->send_on_key = 1; } else if (!av_strcasecmp(cmd, "AudioCodec")) { get_arg(arg, sizeof(arg), &p); audio_id = opt_codec(arg, AVMEDIA_TYPE_AUDIO); if (audio_id == AV_CODEC_ID_NONE) { ERROR("Unknown AudioCodec: %s\n", arg); } } else if (!av_strcasecmp(cmd, "VideoCodec")) { get_arg(arg, sizeof(arg), &p); video_id = opt_codec(arg, AVMEDIA_TYPE_VIDEO); if (video_id == AV_CODEC_ID_NONE) { ERROR("Unknown VideoCodec: %s\n", arg); } } else if (!av_strcasecmp(cmd, "MaxTime")) { get_arg(arg, sizeof(arg), &p); if (stream) stream->max_time = atof(arg) * 1000; } else if (!av_strcasecmp(cmd, "AudioBitRate")) { get_arg(arg, sizeof(arg), &p); if (stream) audio_enc.bit_rate = lrintf(atof(arg) * 1000); } else if (!av_strcasecmp(cmd, "AudioChannels")) { get_arg(arg, sizeof(arg), &p); if (stream) audio_enc.channels = atoi(arg); } else if (!av_strcasecmp(cmd, "AudioSampleRate")) { get_arg(arg, sizeof(arg), &p); if (stream) audio_enc.sample_rate = atoi(arg); } else if (!av_strcasecmp(cmd, "AudioQuality")) { get_arg(arg, sizeof(arg), &p); if (stream) { // audio_enc.quality = atof(arg) * 1000; } } else if (!av_strcasecmp(cmd, "VideoBitRateRange")) { if (stream) { int minrate, maxrate; get_arg(arg, sizeof(arg), &p); if (sscanf(arg, "%d-%d", &minrate, &maxrate) == 2) { video_enc.rc_min_rate = minrate * 1000; video_enc.rc_max_rate = maxrate * 1000; } else { ERROR("Incorrect format for VideoBitRateRange -- should be <min>-<max>: %s\n", arg); } } } else if (!av_strcasecmp(cmd, "Debug")) { if (stream) { get_arg(arg, sizeof(arg), &p); video_enc.debug = strtol(arg,0,0); } } else if (!av_strcasecmp(cmd, "Strict")) { if (stream) { get_arg(arg, sizeof(arg), &p); video_enc.strict_std_compliance = atoi(arg); } } else if (!av_strcasecmp(cmd, "VideoBufferSize")) { if (stream) { get_arg(arg, sizeof(arg), &p); video_enc.rc_buffer_size = atoi(arg) * 8*1024; } } else if (!av_strcasecmp(cmd, "VideoBitRateTolerance")) { if (stream) { get_arg(arg, sizeof(arg), &p); video_enc.bit_rate_tolerance = atoi(arg) * 1000; } } else if (!av_strcasecmp(cmd, "VideoBitRate")) { get_arg(arg, sizeof(arg), &p); if (stream) { video_enc.bit_rate = atoi(arg) * 1000; } } else if (!av_strcasecmp(cmd, "VideoSize")) { get_arg(arg, sizeof(arg), &p); if (stream) { av_parse_video_size(&video_enc.width, &video_enc.height, arg); if ((video_enc.width % 16) != 0 || (video_enc.height % 16) != 0) { ERROR("Image size must be a multiple of 16\n"); } } } else if (!av_strcasecmp(cmd, "VideoFrameRate")) { get_arg(arg, sizeof(arg), &p); if (stream) { AVRational frame_rate; if (av_parse_video_rate(&frame_rate, arg) < 0) { ERROR("Incorrect frame rate: %s\n", arg); } else { video_enc.time_base.num = frame_rate.den; video_enc.time_base.den = frame_rate.num; } } } else if (!av_strcasecmp(cmd, "PixelFormat")) { get_arg(arg, sizeof(arg), &p); if (stream) { video_enc.pix_fmt = av_get_pix_fmt(arg); if (video_enc.pix_fmt == AV_PIX_FMT_NONE) { ERROR("Unknown pixel format: %s\n", arg); } } } else if (!av_strcasecmp(cmd, "VideoGopSize")) { get_arg(arg, sizeof(arg), &p); if (stream) video_enc.gop_size = atoi(arg); } else if (!av_strcasecmp(cmd, "VideoIntraOnly")) { if (stream) video_enc.gop_size = 1; } else if (!av_strcasecmp(cmd, "VideoHighQuality")) { if (stream) video_enc.mb_decision = FF_MB_DECISION_BITS; } else if (!av_strcasecmp(cmd, "Video4MotionVector")) { if (stream) { video_enc.mb_decision = FF_MB_DECISION_BITS; //FIXME remove video_enc.flags |= CODEC_FLAG_4MV; } } else if (!av_strcasecmp(cmd, "AVOptionVideo") || !av_strcasecmp(cmd, "AVOptionAudio")) { char arg2[1024]; AVCodecContext *avctx; int type; get_arg(arg, sizeof(arg), &p); get_arg(arg2, sizeof(arg2), &p); if (!av_strcasecmp(cmd, "AVOptionVideo")) { avctx = &video_enc; type = AV_OPT_FLAG_VIDEO_PARAM; } else { avctx = &audio_enc; type = AV_OPT_FLAG_AUDIO_PARAM; } if (ffserver_opt_default(arg, arg2, avctx, type|AV_OPT_FLAG_ENCODING_PARAM)) { ERROR("Error setting %s option to %s %s\n", cmd, arg, arg2); } } else if (!av_strcasecmp(cmd, "AVPresetVideo") || !av_strcasecmp(cmd, "AVPresetAudio")) { AVCodecContext *avctx; int type; get_arg(arg, sizeof(arg), &p); if (!av_strcasecmp(cmd, "AVPresetVideo")) { avctx = &video_enc; video_enc.codec_id = video_id; type = AV_OPT_FLAG_VIDEO_PARAM; } else { avctx = &audio_enc; audio_enc.codec_id = audio_id; type = AV_OPT_FLAG_AUDIO_PARAM; } if (ffserver_opt_preset(arg, avctx, type|AV_OPT_FLAG_ENCODING_PARAM, &audio_id, &video_id)) { ERROR("AVPreset error: %s\n", arg); } } else if (!av_strcasecmp(cmd, "VideoTag")) { get_arg(arg, sizeof(arg), &p); if ((strlen(arg) == 4) && stream) video_enc.codec_tag = MKTAG(arg[0], arg[1], arg[2], arg[3]); } else if (!av_strcasecmp(cmd, "BitExact")) { if (stream) video_enc.flags |= CODEC_FLAG_BITEXACT; } else if (!av_strcasecmp(cmd, "DctFastint")) { if (stream) video_enc.dct_algo = FF_DCT_FASTINT; } else if (!av_strcasecmp(cmd, "IdctSimple")) { if (stream) video_enc.idct_algo = FF_IDCT_SIMPLE; } else if (!av_strcasecmp(cmd, "Qscale")) { get_arg(arg, sizeof(arg), &p); if (stream) { video_enc.flags |= CODEC_FLAG_QSCALE; video_enc.global_quality = FF_QP2LAMBDA * atoi(arg); } } else if (!av_strcasecmp(cmd, "VideoQDiff")) { get_arg(arg, sizeof(arg), &p); if (stream) { video_enc.max_qdiff = atoi(arg); if (video_enc.max_qdiff < 1 || video_enc.max_qdiff > 31) { ERROR("VideoQDiff out of range\n"); } } } else if (!av_strcasecmp(cmd, "VideoQMax")) { get_arg(arg, sizeof(arg), &p); if (stream) { video_enc.qmax = atoi(arg); if (video_enc.qmax < 1 || video_enc.qmax > 31) { ERROR("VideoQMax out of range\n"); } } } else if (!av_strcasecmp(cmd, "VideoQMin")) { get_arg(arg, sizeof(arg), &p); if (stream) { video_enc.qmin = atoi(arg); if (video_enc.qmin < 1 || video_enc.qmin > 31) { ERROR("VideoQMin out of range\n"); } } } else if (!av_strcasecmp(cmd, "LumiMask")) { get_arg(arg, sizeof(arg), &p); if (stream) video_enc.lumi_masking = atof(arg); } else if (!av_strcasecmp(cmd, "DarkMask")) { get_arg(arg, sizeof(arg), &p); if (stream) video_enc.dark_masking = atof(arg); } else if (!av_strcasecmp(cmd, "NoVideo")) { video_id = AV_CODEC_ID_NONE; } else if (!av_strcasecmp(cmd, "NoAudio")) { audio_id = AV_CODEC_ID_NONE; } else if (!av_strcasecmp(cmd, "ACL")) { parse_acl_row(stream, feed, NULL, p, filename, line_num); } else if (!av_strcasecmp(cmd, "DynamicACL")) { if (stream) { get_arg(stream->dynamic_acl, sizeof(stream->dynamic_acl), &p); } } else if (!av_strcasecmp(cmd, "RTSPOption")) { get_arg(arg, sizeof(arg), &p); if (stream) { av_freep(&stream->rtsp_option); stream->rtsp_option = av_strdup(arg); } } else if (!av_strcasecmp(cmd, "MulticastAddress")) { get_arg(arg, sizeof(arg), &p); if (stream) { if (resolve_host(&stream->multicast_ip, arg) != 0) { ERROR("Invalid host/IP address: %s\n", arg); } stream->is_multicast = 1; stream->loop = 1; /* default is looping */ } } else if (!av_strcasecmp(cmd, "MulticastPort")) { get_arg(arg, sizeof(arg), &p); if (stream) stream->multicast_port = atoi(arg); } else if (!av_strcasecmp(cmd, "MulticastTTL")) { get_arg(arg, sizeof(arg), &p); if (stream) stream->multicast_ttl = atoi(arg); } else if (!av_strcasecmp(cmd, "NoLoop")) { if (stream) stream->loop = 0; } else if (!av_strcasecmp(cmd, "</Stream>")) { if (!stream) { ERROR("No corresponding <Stream> for </Stream>\n"); } else { if (stream->feed && stream->fmt && strcmp(stream->fmt->name, "ffm") != 0) { if (audio_id != AV_CODEC_ID_NONE) { audio_enc.codec_type = AVMEDIA_TYPE_AUDIO; audio_enc.codec_id = audio_id; add_codec(stream, &audio_enc); } if (video_id != AV_CODEC_ID_NONE) { video_enc.codec_type = AVMEDIA_TYPE_VIDEO; video_enc.codec_id = video_id; add_codec(stream, &video_enc); } } stream = NULL; } } else if (!av_strcasecmp(cmd, "<Redirect")) { /*********************************************/ char *q; if (stream || feed || redirect) { ERROR("Already in a tag\n"); } else { redirect = av_mallocz(sizeof(FFStream)); *last_stream = redirect; last_stream = &redirect->next; get_arg(redirect->filename, sizeof(redirect->filename), &p); q = strrchr(redirect->filename, '>'); if (*q) *q = '\0'; redirect->stream_type = STREAM_TYPE_REDIRECT; } } else if (!av_strcasecmp(cmd, "URL")) { if (redirect) get_arg(redirect->feed_filename, sizeof(redirect->feed_filename), &p); } else if (!av_strcasecmp(cmd, "</Redirect>")) { if (!redirect) { ERROR("No corresponding <Redirect> for </Redirect>\n"); } else { if (!redirect->feed_filename[0]) { ERROR("No URL found for <Redirect>\n"); } redirect = NULL; } } else if (!av_strcasecmp(cmd, "LoadModule")) { ERROR("Loadable modules no longer supported\n"); } else { ERROR("Incorrect keyword: '%s'\n", cmd); } } #undef ERROR fclose(f); if (errors) return -1; else return 0; }
true
FFmpeg
7cbbc4f7e7ffdb874a25e269ac92f7bb161c5b83
static int parse_ffconfig(const char *filename) { FILE *f; char line[1024]; char cmd[64]; char arg[1024]; const char *p; int val, errors, line_num; FFStream **last_stream, *stream, *redirect; FFStream **last_feed, *feed, *s; AVCodecContext audio_enc, video_enc; enum AVCodecID audio_id, video_id; f = fopen(filename, "r"); if (!f) { perror(filename); return -1; } errors = 0; line_num = 0; first_stream = NULL; last_stream = &first_stream; first_feed = NULL; last_feed = &first_feed; stream = NULL; feed = NULL; redirect = NULL; audio_id = AV_CODEC_ID_NONE; video_id = AV_CODEC_ID_NONE; #define ERROR(...) report_config_error(filename, line_num, &errors, __VA_ARGS__) for(;;) { if (fgets(line, sizeof(line), f) == NULL) break; line_num++; p = line; while (av_isspace(*p)) p++; if (*p == '\0' || *p == '#') continue; get_arg(cmd, sizeof(cmd), &p); if (!av_strcasecmp(cmd, "Port")) { get_arg(arg, sizeof(arg), &p); val = atoi(arg); if (val < 1 || val > 65536) { ERROR("Invalid_port: %s\n", arg); } my_http_addr.sin_port = htons(val); } else if (!av_strcasecmp(cmd, "BindAddress")) { get_arg(arg, sizeof(arg), &p); if (resolve_host(&my_http_addr.sin_addr, arg) != 0) { ERROR("%s:%d: Invalid host/IP address: %s\n", arg); } } else if (!av_strcasecmp(cmd, "NoDaemon")) { } else if (!av_strcasecmp(cmd, "RTSPPort")) { get_arg(arg, sizeof(arg), &p); val = atoi(arg); if (val < 1 || val > 65536) { ERROR("%s:%d: Invalid port: %s\n", arg); } my_rtsp_addr.sin_port = htons(atoi(arg)); } else if (!av_strcasecmp(cmd, "RTSPBindAddress")) { get_arg(arg, sizeof(arg), &p); if (resolve_host(&my_rtsp_addr.sin_addr, arg) != 0) { ERROR("Invalid host/IP address: %s\n", arg); } } else if (!av_strcasecmp(cmd, "MaxHTTPConnections")) { get_arg(arg, sizeof(arg), &p); val = atoi(arg); if (val < 1 || val > 65536) { ERROR("Invalid MaxHTTPConnections: %s\n", arg); } nb_max_http_connections = val; } else if (!av_strcasecmp(cmd, "MaxClients")) { get_arg(arg, sizeof(arg), &p); val = atoi(arg); if (val < 1 || val > nb_max_http_connections) { ERROR("Invalid MaxClients: %s\n", arg); } else { nb_max_connections = val; } } else if (!av_strcasecmp(cmd, "MaxBandwidth")) { int64_t llval; get_arg(arg, sizeof(arg), &p); llval = strtoll(arg, NULL, 10); if (llval < 10 || llval > 10000000) { ERROR("Invalid MaxBandwidth: %s\n", arg); } else max_bandwidth = llval; } else if (!av_strcasecmp(cmd, "CustomLog")) { if (!ffserver_debug) get_arg(logfilename, sizeof(logfilename), &p); } else if (!av_strcasecmp(cmd, "<Feed")) { char *q; if (stream || feed) { ERROR("Already in a tag\n"); } else { feed = av_mallocz(sizeof(FFStream)); get_arg(feed->filename, sizeof(feed->filename), &p); q = strrchr(feed->filename, '>'); if (*q) *q = '\0'; for (s = first_feed; s; s = s->next) { if (!strcmp(feed->filename, s->filename)) { ERROR("Feed '%s' already registered\n", s->filename); } } feed->fmt = av_guess_format("ffm", NULL, NULL); snprintf(feed->feed_filename, sizeof(feed->feed_filename), "/tmp/%s.ffm", feed->filename); feed->feed_max_size = 5 * 1024 * 1024; feed->is_feed = 1; feed->feed = feed; *last_stream = feed; last_stream = &feed->next; *last_feed = feed; last_feed = &feed->next_feed; } } else if (!av_strcasecmp(cmd, "Launch")) { if (feed) { int i; feed->child_argv = av_mallocz(64 * sizeof(char *)); for (i = 0; i < 62; i++) { get_arg(arg, sizeof(arg), &p); if (!arg[0]) break; feed->child_argv[i] = av_strdup(arg); } feed->child_argv[i] = av_asprintf("http: (my_http_addr.sin_addr.s_addr == INADDR_ANY) ? "127.0.0.1" : inet_ntoa(my_http_addr.sin_addr), ntohs(my_http_addr.sin_port), feed->filename); } } else if (!av_strcasecmp(cmd, "ReadOnlyFile")) { if (feed) { get_arg(feed->feed_filename, sizeof(feed->feed_filename), &p); feed->readonly = 1; } else if (stream) { get_arg(stream->feed_filename, sizeof(stream->feed_filename), &p); } } else if (!av_strcasecmp(cmd, "File")) { if (feed) { get_arg(feed->feed_filename, sizeof(feed->feed_filename), &p); } else if (stream) get_arg(stream->feed_filename, sizeof(stream->feed_filename), &p); } else if (!av_strcasecmp(cmd, "Truncate")) { if (feed) { get_arg(arg, sizeof(arg), &p); feed->truncate = strtod(arg, NULL); } } else if (!av_strcasecmp(cmd, "FileMaxSize")) { if (feed) { char *p1; double fsize; get_arg(arg, sizeof(arg), &p); p1 = arg; fsize = strtod(p1, &p1); switch(av_toupper(*p1)) { case 'K': fsize *= 1024; break; case 'M': fsize *= 1024 * 1024; break; case 'G': fsize *= 1024 * 1024 * 1024; break; } feed->feed_max_size = (int64_t)fsize; if (feed->feed_max_size < FFM_PACKET_SIZE*4) { ERROR("Feed max file size is too small, must be at least %d\n", FFM_PACKET_SIZE*4); } } } else if (!av_strcasecmp(cmd, "</Feed>")) { if (!feed) { ERROR("No corresponding <Feed> for </Feed>\n"); } feed = NULL; } else if (!av_strcasecmp(cmd, "<Stream")) { char *q; if (stream || feed) { ERROR("Already in a tag\n"); } else { FFStream *s; stream = av_mallocz(sizeof(FFStream)); get_arg(stream->filename, sizeof(stream->filename), &p); q = strrchr(stream->filename, '>'); if (q) *q = '\0'; for (s = first_stream; s; s = s->next) { if (!strcmp(stream->filename, s->filename)) { ERROR("Stream '%s' already registered\n", s->filename); } } stream->fmt = ffserver_guess_format(NULL, stream->filename, NULL); avcodec_get_context_defaults3(&video_enc, NULL); avcodec_get_context_defaults3(&audio_enc, NULL); audio_id = AV_CODEC_ID_NONE; video_id = AV_CODEC_ID_NONE; if (stream->fmt) { audio_id = stream->fmt->audio_codec; video_id = stream->fmt->video_codec; } *last_stream = stream; last_stream = &stream->next; } } else if (!av_strcasecmp(cmd, "Feed")) { get_arg(arg, sizeof(arg), &p); if (stream) { FFStream *sfeed; sfeed = first_feed; while (sfeed != NULL) { if (!strcmp(sfeed->filename, arg)) break; sfeed = sfeed->next_feed; } if (!sfeed) ERROR("feed '%s' not defined\n", arg); else stream->feed = sfeed; } } else if (!av_strcasecmp(cmd, "Format")) { get_arg(arg, sizeof(arg), &p); if (stream) { if (!strcmp(arg, "status")) { stream->stream_type = STREAM_TYPE_STATUS; stream->fmt = NULL; } else { stream->stream_type = STREAM_TYPE_LIVE; if (!strcmp(arg, "jpeg")) strcpy(arg, "mjpeg"); stream->fmt = ffserver_guess_format(arg, NULL, NULL); if (!stream->fmt) { ERROR("Unknown Format: %s\n", arg); } } if (stream->fmt) { audio_id = stream->fmt->audio_codec; video_id = stream->fmt->video_codec; } } } else if (!av_strcasecmp(cmd, "InputFormat")) { get_arg(arg, sizeof(arg), &p); if (stream) { stream->ifmt = av_find_input_format(arg); if (!stream->ifmt) { ERROR("Unknown input format: %s\n", arg); } } } else if (!av_strcasecmp(cmd, "FaviconURL")) { if (stream && stream->stream_type == STREAM_TYPE_STATUS) { get_arg(stream->feed_filename, sizeof(stream->feed_filename), &p); } else { ERROR("FaviconURL only permitted for status streams\n"); } } else if (!av_strcasecmp(cmd, "Author")) { if (stream) get_arg(stream->author, sizeof(stream->author), &p); } else if (!av_strcasecmp(cmd, "Comment")) { if (stream) get_arg(stream->comment, sizeof(stream->comment), &p); } else if (!av_strcasecmp(cmd, "Copyright")) { if (stream) get_arg(stream->copyright, sizeof(stream->copyright), &p); } else if (!av_strcasecmp(cmd, "Title")) { if (stream) get_arg(stream->title, sizeof(stream->title), &p); } else if (!av_strcasecmp(cmd, "Preroll")) { get_arg(arg, sizeof(arg), &p); if (stream) stream->prebuffer = atof(arg) * 1000; } else if (!av_strcasecmp(cmd, "StartSendOnKey")) { if (stream) stream->send_on_key = 1; } else if (!av_strcasecmp(cmd, "AudioCodec")) { get_arg(arg, sizeof(arg), &p); audio_id = opt_codec(arg, AVMEDIA_TYPE_AUDIO); if (audio_id == AV_CODEC_ID_NONE) { ERROR("Unknown AudioCodec: %s\n", arg); } } else if (!av_strcasecmp(cmd, "VideoCodec")) { get_arg(arg, sizeof(arg), &p); video_id = opt_codec(arg, AVMEDIA_TYPE_VIDEO); if (video_id == AV_CODEC_ID_NONE) { ERROR("Unknown VideoCodec: %s\n", arg); } } else if (!av_strcasecmp(cmd, "MaxTime")) { get_arg(arg, sizeof(arg), &p); if (stream) stream->max_time = atof(arg) * 1000; } else if (!av_strcasecmp(cmd, "AudioBitRate")) { get_arg(arg, sizeof(arg), &p); if (stream) audio_enc.bit_rate = lrintf(atof(arg) * 1000); } else if (!av_strcasecmp(cmd, "AudioChannels")) { get_arg(arg, sizeof(arg), &p); if (stream) audio_enc.channels = atoi(arg); } else if (!av_strcasecmp(cmd, "AudioSampleRate")) { get_arg(arg, sizeof(arg), &p); if (stream) audio_enc.sample_rate = atoi(arg); } else if (!av_strcasecmp(cmd, "AudioQuality")) { get_arg(arg, sizeof(arg), &p); if (stream) { } } else if (!av_strcasecmp(cmd, "VideoBitRateRange")) { if (stream) { int minrate, maxrate; get_arg(arg, sizeof(arg), &p); if (sscanf(arg, "%d-%d", &minrate, &maxrate) == 2) { video_enc.rc_min_rate = minrate * 1000; video_enc.rc_max_rate = maxrate * 1000; } else { ERROR("Incorrect format for VideoBitRateRange -- should be <min>-<max>: %s\n", arg); } } } else if (!av_strcasecmp(cmd, "Debug")) { if (stream) { get_arg(arg, sizeof(arg), &p); video_enc.debug = strtol(arg,0,0); } } else if (!av_strcasecmp(cmd, "Strict")) { if (stream) { get_arg(arg, sizeof(arg), &p); video_enc.strict_std_compliance = atoi(arg); } } else if (!av_strcasecmp(cmd, "VideoBufferSize")) { if (stream) { get_arg(arg, sizeof(arg), &p); video_enc.rc_buffer_size = atoi(arg) * 8*1024; } } else if (!av_strcasecmp(cmd, "VideoBitRateTolerance")) { if (stream) { get_arg(arg, sizeof(arg), &p); video_enc.bit_rate_tolerance = atoi(arg) * 1000; } } else if (!av_strcasecmp(cmd, "VideoBitRate")) { get_arg(arg, sizeof(arg), &p); if (stream) { video_enc.bit_rate = atoi(arg) * 1000; } } else if (!av_strcasecmp(cmd, "VideoSize")) { get_arg(arg, sizeof(arg), &p); if (stream) { av_parse_video_size(&video_enc.width, &video_enc.height, arg); if ((video_enc.width % 16) != 0 || (video_enc.height % 16) != 0) { ERROR("Image size must be a multiple of 16\n"); } } } else if (!av_strcasecmp(cmd, "VideoFrameRate")) { get_arg(arg, sizeof(arg), &p); if (stream) { AVRational frame_rate; if (av_parse_video_rate(&frame_rate, arg) < 0) { ERROR("Incorrect frame rate: %s\n", arg); } else { video_enc.time_base.num = frame_rate.den; video_enc.time_base.den = frame_rate.num; } } } else if (!av_strcasecmp(cmd, "PixelFormat")) { get_arg(arg, sizeof(arg), &p); if (stream) { video_enc.pix_fmt = av_get_pix_fmt(arg); if (video_enc.pix_fmt == AV_PIX_FMT_NONE) { ERROR("Unknown pixel format: %s\n", arg); } } } else if (!av_strcasecmp(cmd, "VideoGopSize")) { get_arg(arg, sizeof(arg), &p); if (stream) video_enc.gop_size = atoi(arg); } else if (!av_strcasecmp(cmd, "VideoIntraOnly")) { if (stream) video_enc.gop_size = 1; } else if (!av_strcasecmp(cmd, "VideoHighQuality")) { if (stream) video_enc.mb_decision = FF_MB_DECISION_BITS; } else if (!av_strcasecmp(cmd, "Video4MotionVector")) { if (stream) { video_enc.mb_decision = FF_MB_DECISION_BITS; video_enc.flags |= CODEC_FLAG_4MV; } } else if (!av_strcasecmp(cmd, "AVOptionVideo") || !av_strcasecmp(cmd, "AVOptionAudio")) { char arg2[1024]; AVCodecContext *avctx; int type; get_arg(arg, sizeof(arg), &p); get_arg(arg2, sizeof(arg2), &p); if (!av_strcasecmp(cmd, "AVOptionVideo")) { avctx = &video_enc; type = AV_OPT_FLAG_VIDEO_PARAM; } else { avctx = &audio_enc; type = AV_OPT_FLAG_AUDIO_PARAM; } if (ffserver_opt_default(arg, arg2, avctx, type|AV_OPT_FLAG_ENCODING_PARAM)) { ERROR("Error setting %s option to %s %s\n", cmd, arg, arg2); } } else if (!av_strcasecmp(cmd, "AVPresetVideo") || !av_strcasecmp(cmd, "AVPresetAudio")) { AVCodecContext *avctx; int type; get_arg(arg, sizeof(arg), &p); if (!av_strcasecmp(cmd, "AVPresetVideo")) { avctx = &video_enc; video_enc.codec_id = video_id; type = AV_OPT_FLAG_VIDEO_PARAM; } else { avctx = &audio_enc; audio_enc.codec_id = audio_id; type = AV_OPT_FLAG_AUDIO_PARAM; } if (ffserver_opt_preset(arg, avctx, type|AV_OPT_FLAG_ENCODING_PARAM, &audio_id, &video_id)) { ERROR("AVPreset error: %s\n", arg); } } else if (!av_strcasecmp(cmd, "VideoTag")) { get_arg(arg, sizeof(arg), &p); if ((strlen(arg) == 4) && stream) video_enc.codec_tag = MKTAG(arg[0], arg[1], arg[2], arg[3]); } else if (!av_strcasecmp(cmd, "BitExact")) { if (stream) video_enc.flags |= CODEC_FLAG_BITEXACT; } else if (!av_strcasecmp(cmd, "DctFastint")) { if (stream) video_enc.dct_algo = FF_DCT_FASTINT; } else if (!av_strcasecmp(cmd, "IdctSimple")) { if (stream) video_enc.idct_algo = FF_IDCT_SIMPLE; } else if (!av_strcasecmp(cmd, "Qscale")) { get_arg(arg, sizeof(arg), &p); if (stream) { video_enc.flags |= CODEC_FLAG_QSCALE; video_enc.global_quality = FF_QP2LAMBDA * atoi(arg); } } else if (!av_strcasecmp(cmd, "VideoQDiff")) { get_arg(arg, sizeof(arg), &p); if (stream) { video_enc.max_qdiff = atoi(arg); if (video_enc.max_qdiff < 1 || video_enc.max_qdiff > 31) { ERROR("VideoQDiff out of range\n"); } } } else if (!av_strcasecmp(cmd, "VideoQMax")) { get_arg(arg, sizeof(arg), &p); if (stream) { video_enc.qmax = atoi(arg); if (video_enc.qmax < 1 || video_enc.qmax > 31) { ERROR("VideoQMax out of range\n"); } } } else if (!av_strcasecmp(cmd, "VideoQMin")) { get_arg(arg, sizeof(arg), &p); if (stream) { video_enc.qmin = atoi(arg); if (video_enc.qmin < 1 || video_enc.qmin > 31) { ERROR("VideoQMin out of range\n"); } } } else if (!av_strcasecmp(cmd, "LumiMask")) { get_arg(arg, sizeof(arg), &p); if (stream) video_enc.lumi_masking = atof(arg); } else if (!av_strcasecmp(cmd, "DarkMask")) { get_arg(arg, sizeof(arg), &p); if (stream) video_enc.dark_masking = atof(arg); } else if (!av_strcasecmp(cmd, "NoVideo")) { video_id = AV_CODEC_ID_NONE; } else if (!av_strcasecmp(cmd, "NoAudio")) { audio_id = AV_CODEC_ID_NONE; } else if (!av_strcasecmp(cmd, "ACL")) { parse_acl_row(stream, feed, NULL, p, filename, line_num); } else if (!av_strcasecmp(cmd, "DynamicACL")) { if (stream) { get_arg(stream->dynamic_acl, sizeof(stream->dynamic_acl), &p); } } else if (!av_strcasecmp(cmd, "RTSPOption")) { get_arg(arg, sizeof(arg), &p); if (stream) { av_freep(&stream->rtsp_option); stream->rtsp_option = av_strdup(arg); } } else if (!av_strcasecmp(cmd, "MulticastAddress")) { get_arg(arg, sizeof(arg), &p); if (stream) { if (resolve_host(&stream->multicast_ip, arg) != 0) { ERROR("Invalid host/IP address: %s\n", arg); } stream->is_multicast = 1; stream->loop = 1; } } else if (!av_strcasecmp(cmd, "MulticastPort")) { get_arg(arg, sizeof(arg), &p); if (stream) stream->multicast_port = atoi(arg); } else if (!av_strcasecmp(cmd, "MulticastTTL")) { get_arg(arg, sizeof(arg), &p); if (stream) stream->multicast_ttl = atoi(arg); } else if (!av_strcasecmp(cmd, "NoLoop")) { if (stream) stream->loop = 0; } else if (!av_strcasecmp(cmd, "</Stream>")) { if (!stream) { ERROR("No corresponding <Stream> for </Stream>\n"); } else { if (stream->feed && stream->fmt && strcmp(stream->fmt->name, "ffm") != 0) { if (audio_id != AV_CODEC_ID_NONE) { audio_enc.codec_type = AVMEDIA_TYPE_AUDIO; audio_enc.codec_id = audio_id; add_codec(stream, &audio_enc); } if (video_id != AV_CODEC_ID_NONE) { video_enc.codec_type = AVMEDIA_TYPE_VIDEO; video_enc.codec_id = video_id; add_codec(stream, &video_enc); } } stream = NULL; } } else if (!av_strcasecmp(cmd, "<Redirect")) { char *q; if (stream || feed || redirect) { ERROR("Already in a tag\n"); } else { redirect = av_mallocz(sizeof(FFStream)); *last_stream = redirect; last_stream = &redirect->next; get_arg(redirect->filename, sizeof(redirect->filename), &p); q = strrchr(redirect->filename, '>'); if (*q) *q = '\0'; redirect->stream_type = STREAM_TYPE_REDIRECT; } } else if (!av_strcasecmp(cmd, "URL")) { if (redirect) get_arg(redirect->feed_filename, sizeof(redirect->feed_filename), &p); } else if (!av_strcasecmp(cmd, "</Redirect>")) { if (!redirect) { ERROR("No corresponding <Redirect> for </Redirect>\n"); } else { if (!redirect->feed_filename[0]) { ERROR("No URL found for <Redirect>\n"); } redirect = NULL; } } else if (!av_strcasecmp(cmd, "LoadModule")) { ERROR("Loadable modules no longer supported\n"); } else { ERROR("Incorrect keyword: '%s'\n", cmd); } } #undef ERROR fclose(f); if (errors) return -1; else return 0; }
{ "code": [ " perror(filename);", " return -1;", " (my_http_addr.sin_addr.s_addr == INADDR_ANY) ? \"127.0.0.1\" :", " inet_ntoa(my_http_addr.sin_addr),", " ntohs(my_http_addr.sin_port), feed->filename);", " av_parse_video_size(&video_enc.width, &video_enc.height, arg);", " if ((video_enc.width % 16) != 0 ||", " (video_enc.height % 16) != 0) {", " ERROR(\"Image size must be a multiple of 16\\n\");", " return -1;" ], "line_no": [ 31, 33, 291, 293, 295, 747, 749, 751, 753, 33 ] }
static int FUNC_0(const char *VAR_0) { FILE *f; char VAR_1[1024]; char VAR_2[64]; char VAR_3[1024]; const char *VAR_4; int VAR_5, VAR_6, VAR_7; FFStream **last_stream, *stream, *redirect; FFStream **last_feed, *feed, *s; AVCodecContext audio_enc, video_enc; enum AVCodecID VAR_8, VAR_9; f = fopen(VAR_0, "r"); if (!f) { perror(VAR_0); return -1; } VAR_6 = 0; VAR_7 = 0; first_stream = NULL; last_stream = &first_stream; first_feed = NULL; last_feed = &first_feed; stream = NULL; feed = NULL; redirect = NULL; VAR_8 = AV_CODEC_ID_NONE; VAR_9 = AV_CODEC_ID_NONE; #define ERROR(...) report_config_error(VAR_0, VAR_7, &VAR_6, __VA_ARGS__) for(;;) { if (fgets(VAR_1, sizeof(VAR_1), f) == NULL) break; VAR_7++; VAR_4 = VAR_1; while (av_isspace(*VAR_4)) VAR_4++; if (*VAR_4 == '\0' || *VAR_4 == '#') continue; get_arg(VAR_2, sizeof(VAR_2), &VAR_4); if (!av_strcasecmp(VAR_2, "Port")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); VAR_5 = atoi(VAR_3); if (VAR_5 < 1 || VAR_5 > 65536) { ERROR("Invalid_port: %s\n", VAR_3); } my_http_addr.sin_port = htons(VAR_5); } else if (!av_strcasecmp(VAR_2, "BindAddress")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (resolve_host(&my_http_addr.sin_addr, VAR_3) != 0) { ERROR("%s:%d: Invalid host/IP address: %s\n", VAR_3); } } else if (!av_strcasecmp(VAR_2, "NoDaemon")) { } else if (!av_strcasecmp(VAR_2, "RTSPPort")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); VAR_5 = atoi(VAR_3); if (VAR_5 < 1 || VAR_5 > 65536) { ERROR("%s:%d: Invalid port: %s\n", VAR_3); } my_rtsp_addr.sin_port = htons(atoi(VAR_3)); } else if (!av_strcasecmp(VAR_2, "RTSPBindAddress")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (resolve_host(&my_rtsp_addr.sin_addr, VAR_3) != 0) { ERROR("Invalid host/IP address: %s\n", VAR_3); } } else if (!av_strcasecmp(VAR_2, "MaxHTTPConnections")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); VAR_5 = atoi(VAR_3); if (VAR_5 < 1 || VAR_5 > 65536) { ERROR("Invalid MaxHTTPConnections: %s\n", VAR_3); } nb_max_http_connections = VAR_5; } else if (!av_strcasecmp(VAR_2, "MaxClients")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); VAR_5 = atoi(VAR_3); if (VAR_5 < 1 || VAR_5 > nb_max_http_connections) { ERROR("Invalid MaxClients: %s\n", VAR_3); } else { nb_max_connections = VAR_5; } } else if (!av_strcasecmp(VAR_2, "MaxBandwidth")) { int64_t llval; get_arg(VAR_3, sizeof(VAR_3), &VAR_4); llval = strtoll(VAR_3, NULL, 10); if (llval < 10 || llval > 10000000) { ERROR("Invalid MaxBandwidth: %s\n", VAR_3); } else max_bandwidth = llval; } else if (!av_strcasecmp(VAR_2, "CustomLog")) { if (!ffserver_debug) get_arg(logfilename, sizeof(logfilename), &VAR_4); } else if (!av_strcasecmp(VAR_2, "<Feed")) { char *VAR_18; if (stream || feed) { ERROR("Already in a tag\n"); } else { feed = av_mallocz(sizeof(FFStream)); get_arg(feed->VAR_0, sizeof(feed->VAR_0), &VAR_4); VAR_18 = strrchr(feed->VAR_0, '>'); if (*VAR_18) *VAR_18 = '\0'; for (s = first_feed; s; s = s->next) { if (!strcmp(feed->VAR_0, s->VAR_0)) { ERROR("Feed '%s' already registered\n", s->VAR_0); } } feed->fmt = av_guess_format("ffm", NULL, NULL); snprintf(feed->feed_filename, sizeof(feed->feed_filename), "/tmp/%s.ffm", feed->VAR_0); feed->feed_max_size = 5 * 1024 * 1024; feed->is_feed = 1; feed->feed = feed; *last_stream = feed; last_stream = &feed->next; *last_feed = feed; last_feed = &feed->next_feed; } } else if (!av_strcasecmp(VAR_2, "Launch")) { if (feed) { int VAR_11; feed->child_argv = av_mallocz(64 * sizeof(char *)); for (VAR_11 = 0; VAR_11 < 62; VAR_11++) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (!VAR_3[0]) break; feed->child_argv[VAR_11] = av_strdup(VAR_3); } feed->child_argv[VAR_11] = av_asprintf("http: (my_http_addr.sin_addr.s_addr == INADDR_ANY) ? "127.0.0.1" : inet_ntoa(my_http_addr.sin_addr), ntohs(my_http_addr.sin_port), feed->VAR_0); } } else if (!av_strcasecmp(VAR_2, "ReadOnlyFile")) { if (feed) { get_arg(feed->feed_filename, sizeof(feed->feed_filename), &VAR_4); feed->readonly = 1; } else if (stream) { get_arg(stream->feed_filename, sizeof(stream->feed_filename), &VAR_4); } } else if (!av_strcasecmp(VAR_2, "File")) { if (feed) { get_arg(feed->feed_filename, sizeof(feed->feed_filename), &VAR_4); } else if (stream) get_arg(stream->feed_filename, sizeof(stream->feed_filename), &VAR_4); } else if (!av_strcasecmp(VAR_2, "Truncate")) { if (feed) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); feed->truncate = strtod(VAR_3, NULL); } } else if (!av_strcasecmp(VAR_2, "FileMaxSize")) { if (feed) { char *VAR_12; double VAR_13; get_arg(VAR_3, sizeof(VAR_3), &VAR_4); VAR_12 = VAR_3; VAR_13 = strtod(VAR_12, &VAR_12); switch(av_toupper(*VAR_12)) { case 'K': VAR_13 *= 1024; break; case 'M': VAR_13 *= 1024 * 1024; break; case 'G': VAR_13 *= 1024 * 1024 * 1024; break; } feed->feed_max_size = (int64_t)VAR_13; if (feed->feed_max_size < FFM_PACKET_SIZE*4) { ERROR("Feed max file size is too small, must be at least %d\n", FFM_PACKET_SIZE*4); } } } else if (!av_strcasecmp(VAR_2, "</Feed>")) { if (!feed) { ERROR("No corresponding <Feed> for </Feed>\n"); } feed = NULL; } else if (!av_strcasecmp(VAR_2, "<Stream")) { char *VAR_18; if (stream || feed) { ERROR("Already in a tag\n"); } else { FFStream *s; stream = av_mallocz(sizeof(FFStream)); get_arg(stream->VAR_0, sizeof(stream->VAR_0), &VAR_4); VAR_18 = strrchr(stream->VAR_0, '>'); if (VAR_18) *VAR_18 = '\0'; for (s = first_stream; s; s = s->next) { if (!strcmp(stream->VAR_0, s->VAR_0)) { ERROR("Stream '%s' already registered\n", s->VAR_0); } } stream->fmt = ffserver_guess_format(NULL, stream->VAR_0, NULL); avcodec_get_context_defaults3(&video_enc, NULL); avcodec_get_context_defaults3(&audio_enc, NULL); VAR_8 = AV_CODEC_ID_NONE; VAR_9 = AV_CODEC_ID_NONE; if (stream->fmt) { VAR_8 = stream->fmt->audio_codec; VAR_9 = stream->fmt->video_codec; } *last_stream = stream; last_stream = &stream->next; } } else if (!av_strcasecmp(VAR_2, "Feed")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) { FFStream *sfeed; sfeed = first_feed; while (sfeed != NULL) { if (!strcmp(sfeed->VAR_0, VAR_3)) break; sfeed = sfeed->next_feed; } if (!sfeed) ERROR("feed '%s' not defined\n", VAR_3); else stream->feed = sfeed; } } else if (!av_strcasecmp(VAR_2, "Format")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) { if (!strcmp(VAR_3, "status")) { stream->stream_type = STREAM_TYPE_STATUS; stream->fmt = NULL; } else { stream->stream_type = STREAM_TYPE_LIVE; if (!strcmp(VAR_3, "jpeg")) strcpy(VAR_3, "mjpeg"); stream->fmt = ffserver_guess_format(VAR_3, NULL, NULL); if (!stream->fmt) { ERROR("Unknown Format: %s\n", VAR_3); } } if (stream->fmt) { VAR_8 = stream->fmt->audio_codec; VAR_9 = stream->fmt->video_codec; } } } else if (!av_strcasecmp(VAR_2, "InputFormat")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) { stream->ifmt = av_find_input_format(VAR_3); if (!stream->ifmt) { ERROR("Unknown input format: %s\n", VAR_3); } } } else if (!av_strcasecmp(VAR_2, "FaviconURL")) { if (stream && stream->stream_type == STREAM_TYPE_STATUS) { get_arg(stream->feed_filename, sizeof(stream->feed_filename), &VAR_4); } else { ERROR("FaviconURL only permitted for status streams\n"); } } else if (!av_strcasecmp(VAR_2, "Author")) { if (stream) get_arg(stream->author, sizeof(stream->author), &VAR_4); } else if (!av_strcasecmp(VAR_2, "Comment")) { if (stream) get_arg(stream->comment, sizeof(stream->comment), &VAR_4); } else if (!av_strcasecmp(VAR_2, "Copyright")) { if (stream) get_arg(stream->copyright, sizeof(stream->copyright), &VAR_4); } else if (!av_strcasecmp(VAR_2, "Title")) { if (stream) get_arg(stream->title, sizeof(stream->title), &VAR_4); } else if (!av_strcasecmp(VAR_2, "Preroll")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) stream->prebuffer = atof(VAR_3) * 1000; } else if (!av_strcasecmp(VAR_2, "StartSendOnKey")) { if (stream) stream->send_on_key = 1; } else if (!av_strcasecmp(VAR_2, "AudioCodec")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); VAR_8 = opt_codec(VAR_3, AVMEDIA_TYPE_AUDIO); if (VAR_8 == AV_CODEC_ID_NONE) { ERROR("Unknown AudioCodec: %s\n", VAR_3); } } else if (!av_strcasecmp(VAR_2, "VideoCodec")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); VAR_9 = opt_codec(VAR_3, AVMEDIA_TYPE_VIDEO); if (VAR_9 == AV_CODEC_ID_NONE) { ERROR("Unknown VideoCodec: %s\n", VAR_3); } } else if (!av_strcasecmp(VAR_2, "MaxTime")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) stream->max_time = atof(VAR_3) * 1000; } else if (!av_strcasecmp(VAR_2, "AudioBitRate")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) audio_enc.bit_rate = lrintf(atof(VAR_3) * 1000); } else if (!av_strcasecmp(VAR_2, "AudioChannels")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) audio_enc.channels = atoi(VAR_3); } else if (!av_strcasecmp(VAR_2, "AudioSampleRate")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) audio_enc.sample_rate = atoi(VAR_3); } else if (!av_strcasecmp(VAR_2, "AudioQuality")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) { } } else if (!av_strcasecmp(VAR_2, "VideoBitRateRange")) { if (stream) { int VAR_14, VAR_15; get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (sscanf(VAR_3, "%d-%d", &VAR_14, &VAR_15) == 2) { video_enc.rc_min_rate = VAR_14 * 1000; video_enc.rc_max_rate = VAR_15 * 1000; } else { ERROR("Incorrect format for VideoBitRateRange -- should be <min>-<max>: %s\n", VAR_3); } } } else if (!av_strcasecmp(VAR_2, "Debug")) { if (stream) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); video_enc.debug = strtol(VAR_3,0,0); } } else if (!av_strcasecmp(VAR_2, "Strict")) { if (stream) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); video_enc.strict_std_compliance = atoi(VAR_3); } } else if (!av_strcasecmp(VAR_2, "VideoBufferSize")) { if (stream) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); video_enc.rc_buffer_size = atoi(VAR_3) * 8*1024; } } else if (!av_strcasecmp(VAR_2, "VideoBitRateTolerance")) { if (stream) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); video_enc.bit_rate_tolerance = atoi(VAR_3) * 1000; } } else if (!av_strcasecmp(VAR_2, "VideoBitRate")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) { video_enc.bit_rate = atoi(VAR_3) * 1000; } } else if (!av_strcasecmp(VAR_2, "VideoSize")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) { av_parse_video_size(&video_enc.width, &video_enc.height, VAR_3); if ((video_enc.width % 16) != 0 || (video_enc.height % 16) != 0) { ERROR("Image size must be a multiple of 16\n"); } } } else if (!av_strcasecmp(VAR_2, "VideoFrameRate")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) { AVRational frame_rate; if (av_parse_video_rate(&frame_rate, VAR_3) < 0) { ERROR("Incorrect frame rate: %s\n", VAR_3); } else { video_enc.time_base.num = frame_rate.den; video_enc.time_base.den = frame_rate.num; } } } else if (!av_strcasecmp(VAR_2, "PixelFormat")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) { video_enc.pix_fmt = av_get_pix_fmt(VAR_3); if (video_enc.pix_fmt == AV_PIX_FMT_NONE) { ERROR("Unknown pixel format: %s\n", VAR_3); } } } else if (!av_strcasecmp(VAR_2, "VideoGopSize")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) video_enc.gop_size = atoi(VAR_3); } else if (!av_strcasecmp(VAR_2, "VideoIntraOnly")) { if (stream) video_enc.gop_size = 1; } else if (!av_strcasecmp(VAR_2, "VideoHighQuality")) { if (stream) video_enc.mb_decision = FF_MB_DECISION_BITS; } else if (!av_strcasecmp(VAR_2, "Video4MotionVector")) { if (stream) { video_enc.mb_decision = FF_MB_DECISION_BITS; video_enc.flags |= CODEC_FLAG_4MV; } } else if (!av_strcasecmp(VAR_2, "AVOptionVideo") || !av_strcasecmp(VAR_2, "AVOptionAudio")) { char VAR_16[1024]; AVCodecContext *avctx; int VAR_18; get_arg(VAR_3, sizeof(VAR_3), &VAR_4); get_arg(VAR_16, sizeof(VAR_16), &VAR_4); if (!av_strcasecmp(VAR_2, "AVOptionVideo")) { avctx = &video_enc; VAR_18 = AV_OPT_FLAG_VIDEO_PARAM; } else { avctx = &audio_enc; VAR_18 = AV_OPT_FLAG_AUDIO_PARAM; } if (ffserver_opt_default(VAR_3, VAR_16, avctx, VAR_18|AV_OPT_FLAG_ENCODING_PARAM)) { ERROR("Error setting %s option to %s %s\n", VAR_2, VAR_3, VAR_16); } } else if (!av_strcasecmp(VAR_2, "AVPresetVideo") || !av_strcasecmp(VAR_2, "AVPresetAudio")) { AVCodecContext *avctx; int VAR_18; get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (!av_strcasecmp(VAR_2, "AVPresetVideo")) { avctx = &video_enc; video_enc.codec_id = VAR_9; VAR_18 = AV_OPT_FLAG_VIDEO_PARAM; } else { avctx = &audio_enc; audio_enc.codec_id = VAR_8; VAR_18 = AV_OPT_FLAG_AUDIO_PARAM; } if (ffserver_opt_preset(VAR_3, avctx, VAR_18|AV_OPT_FLAG_ENCODING_PARAM, &VAR_8, &VAR_9)) { ERROR("AVPreset error: %s\n", VAR_3); } } else if (!av_strcasecmp(VAR_2, "VideoTag")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if ((strlen(VAR_3) == 4) && stream) video_enc.codec_tag = MKTAG(VAR_3[0], VAR_3[1], VAR_3[2], VAR_3[3]); } else if (!av_strcasecmp(VAR_2, "BitExact")) { if (stream) video_enc.flags |= CODEC_FLAG_BITEXACT; } else if (!av_strcasecmp(VAR_2, "DctFastint")) { if (stream) video_enc.dct_algo = FF_DCT_FASTINT; } else if (!av_strcasecmp(VAR_2, "IdctSimple")) { if (stream) video_enc.idct_algo = FF_IDCT_SIMPLE; } else if (!av_strcasecmp(VAR_2, "Qscale")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) { video_enc.flags |= CODEC_FLAG_QSCALE; video_enc.global_quality = FF_QP2LAMBDA * atoi(VAR_3); } } else if (!av_strcasecmp(VAR_2, "VideoQDiff")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) { video_enc.max_qdiff = atoi(VAR_3); if (video_enc.max_qdiff < 1 || video_enc.max_qdiff > 31) { ERROR("VideoQDiff out of range\n"); } } } else if (!av_strcasecmp(VAR_2, "VideoQMax")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) { video_enc.qmax = atoi(VAR_3); if (video_enc.qmax < 1 || video_enc.qmax > 31) { ERROR("VideoQMax out of range\n"); } } } else if (!av_strcasecmp(VAR_2, "VideoQMin")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) { video_enc.qmin = atoi(VAR_3); if (video_enc.qmin < 1 || video_enc.qmin > 31) { ERROR("VideoQMin out of range\n"); } } } else if (!av_strcasecmp(VAR_2, "LumiMask")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) video_enc.lumi_masking = atof(VAR_3); } else if (!av_strcasecmp(VAR_2, "DarkMask")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) video_enc.dark_masking = atof(VAR_3); } else if (!av_strcasecmp(VAR_2, "NoVideo")) { VAR_9 = AV_CODEC_ID_NONE; } else if (!av_strcasecmp(VAR_2, "NoAudio")) { VAR_8 = AV_CODEC_ID_NONE; } else if (!av_strcasecmp(VAR_2, "ACL")) { parse_acl_row(stream, feed, NULL, VAR_4, VAR_0, VAR_7); } else if (!av_strcasecmp(VAR_2, "DynamicACL")) { if (stream) { get_arg(stream->dynamic_acl, sizeof(stream->dynamic_acl), &VAR_4); } } else if (!av_strcasecmp(VAR_2, "RTSPOption")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) { av_freep(&stream->rtsp_option); stream->rtsp_option = av_strdup(VAR_3); } } else if (!av_strcasecmp(VAR_2, "MulticastAddress")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) { if (resolve_host(&stream->multicast_ip, VAR_3) != 0) { ERROR("Invalid host/IP address: %s\n", VAR_3); } stream->is_multicast = 1; stream->loop = 1; } } else if (!av_strcasecmp(VAR_2, "MulticastPort")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) stream->multicast_port = atoi(VAR_3); } else if (!av_strcasecmp(VAR_2, "MulticastTTL")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) stream->multicast_ttl = atoi(VAR_3); } else if (!av_strcasecmp(VAR_2, "NoLoop")) { if (stream) stream->loop = 0; } else if (!av_strcasecmp(VAR_2, "</Stream>")) { if (!stream) { ERROR("No corresponding <Stream> for </Stream>\n"); } else { if (stream->feed && stream->fmt && strcmp(stream->fmt->name, "ffm") != 0) { if (VAR_8 != AV_CODEC_ID_NONE) { audio_enc.codec_type = AVMEDIA_TYPE_AUDIO; audio_enc.codec_id = VAR_8; add_codec(stream, &audio_enc); } if (VAR_9 != AV_CODEC_ID_NONE) { video_enc.codec_type = AVMEDIA_TYPE_VIDEO; video_enc.codec_id = VAR_9; add_codec(stream, &video_enc); } } stream = NULL; } } else if (!av_strcasecmp(VAR_2, "<Redirect")) { char *VAR_18; if (stream || feed || redirect) { ERROR("Already in a tag\n"); } else { redirect = av_mallocz(sizeof(FFStream)); *last_stream = redirect; last_stream = &redirect->next; get_arg(redirect->VAR_0, sizeof(redirect->VAR_0), &VAR_4); VAR_18 = strrchr(redirect->VAR_0, '>'); if (*VAR_18) *VAR_18 = '\0'; redirect->stream_type = STREAM_TYPE_REDIRECT; } } else if (!av_strcasecmp(VAR_2, "URL")) { if (redirect) get_arg(redirect->feed_filename, sizeof(redirect->feed_filename), &VAR_4); } else if (!av_strcasecmp(VAR_2, "</Redirect>")) { if (!redirect) { ERROR("No corresponding <Redirect> for </Redirect>\n"); } else { if (!redirect->feed_filename[0]) { ERROR("No URL found for <Redirect>\n"); } redirect = NULL; } } else if (!av_strcasecmp(VAR_2, "LoadModule")) { ERROR("Loadable modules no longer supported\n"); } else { ERROR("Incorrect keyword: '%s'\n", VAR_2); } } #undef ERROR fclose(f); if (VAR_6) return -1; else return 0; }
[ "static int FUNC_0(const char *VAR_0)\n{", "FILE *f;", "char VAR_1[1024];", "char VAR_2[64];", "char VAR_3[1024];", "const char *VAR_4;", "int VAR_5, VAR_6, VAR_7;", "FFStream **last_stream, *stream, *redirect;", "FFStream **last_feed, *feed, *s;", "AVCodecContext audio_enc, video_enc;", "enum AVCodecID VAR_8, VAR_9;", "f = fopen(VAR_0, \"r\");", "if (!f) {", "perror(VAR_0);", "return -1;", "}", "VAR_6 = 0;", "VAR_7 = 0;", "first_stream = NULL;", "last_stream = &first_stream;", "first_feed = NULL;", "last_feed = &first_feed;", "stream = NULL;", "feed = NULL;", "redirect = NULL;", "VAR_8 = AV_CODEC_ID_NONE;", "VAR_9 = AV_CODEC_ID_NONE;", "#define ERROR(...) report_config_error(VAR_0, VAR_7, &VAR_6, __VA_ARGS__)\nfor(;;) {", "if (fgets(VAR_1, sizeof(VAR_1), f) == NULL)\nbreak;", "VAR_7++;", "VAR_4 = VAR_1;", "while (av_isspace(*VAR_4))\nVAR_4++;", "if (*VAR_4 == '\\0' || *VAR_4 == '#')\ncontinue;", "get_arg(VAR_2, sizeof(VAR_2), &VAR_4);", "if (!av_strcasecmp(VAR_2, \"Port\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "VAR_5 = atoi(VAR_3);", "if (VAR_5 < 1 || VAR_5 > 65536) {", "ERROR(\"Invalid_port: %s\\n\", VAR_3);", "}", "my_http_addr.sin_port = htons(VAR_5);", "} else if (!av_strcasecmp(VAR_2, \"BindAddress\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (resolve_host(&my_http_addr.sin_addr, VAR_3) != 0) {", "ERROR(\"%s:%d: Invalid host/IP address: %s\\n\", VAR_3);", "}", "} else if (!av_strcasecmp(VAR_2, \"NoDaemon\")) {", "} else if (!av_strcasecmp(VAR_2, \"RTSPPort\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "VAR_5 = atoi(VAR_3);", "if (VAR_5 < 1 || VAR_5 > 65536) {", "ERROR(\"%s:%d: Invalid port: %s\\n\", VAR_3);", "}", "my_rtsp_addr.sin_port = htons(atoi(VAR_3));", "} else if (!av_strcasecmp(VAR_2, \"RTSPBindAddress\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (resolve_host(&my_rtsp_addr.sin_addr, VAR_3) != 0) {", "ERROR(\"Invalid host/IP address: %s\\n\", VAR_3);", "}", "} else if (!av_strcasecmp(VAR_2, \"MaxHTTPConnections\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "VAR_5 = atoi(VAR_3);", "if (VAR_5 < 1 || VAR_5 > 65536) {", "ERROR(\"Invalid MaxHTTPConnections: %s\\n\", VAR_3);", "}", "nb_max_http_connections = VAR_5;", "} else if (!av_strcasecmp(VAR_2, \"MaxClients\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "VAR_5 = atoi(VAR_3);", "if (VAR_5 < 1 || VAR_5 > nb_max_http_connections) {", "ERROR(\"Invalid MaxClients: %s\\n\", VAR_3);", "} else {", "nb_max_connections = VAR_5;", "}", "} else if (!av_strcasecmp(VAR_2, \"MaxBandwidth\")) {", "int64_t llval;", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "llval = strtoll(VAR_3, NULL, 10);", "if (llval < 10 || llval > 10000000) {", "ERROR(\"Invalid MaxBandwidth: %s\\n\", VAR_3);", "} else", "max_bandwidth = llval;", "} else if (!av_strcasecmp(VAR_2, \"CustomLog\")) {", "if (!ffserver_debug)\nget_arg(logfilename, sizeof(logfilename), &VAR_4);", "} else if (!av_strcasecmp(VAR_2, \"<Feed\")) {", "char *VAR_18;", "if (stream || feed) {", "ERROR(\"Already in a tag\\n\");", "} else {", "feed = av_mallocz(sizeof(FFStream));", "get_arg(feed->VAR_0, sizeof(feed->VAR_0), &VAR_4);", "VAR_18 = strrchr(feed->VAR_0, '>');", "if (*VAR_18)\n*VAR_18 = '\\0';", "for (s = first_feed; s; s = s->next) {", "if (!strcmp(feed->VAR_0, s->VAR_0)) {", "ERROR(\"Feed '%s' already registered\\n\", s->VAR_0);", "}", "}", "feed->fmt = av_guess_format(\"ffm\", NULL, NULL);", "snprintf(feed->feed_filename, sizeof(feed->feed_filename),\n\"/tmp/%s.ffm\", feed->VAR_0);", "feed->feed_max_size = 5 * 1024 * 1024;", "feed->is_feed = 1;", "feed->feed = feed;", "*last_stream = feed;", "last_stream = &feed->next;", "*last_feed = feed;", "last_feed = &feed->next_feed;", "}", "} else if (!av_strcasecmp(VAR_2, \"Launch\")) {", "if (feed) {", "int VAR_11;", "feed->child_argv = av_mallocz(64 * sizeof(char *));", "for (VAR_11 = 0; VAR_11 < 62; VAR_11++) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (!VAR_3[0])\nbreak;", "feed->child_argv[VAR_11] = av_strdup(VAR_3);", "}", "feed->child_argv[VAR_11] = av_asprintf(\"http:\n(my_http_addr.sin_addr.s_addr == INADDR_ANY) ? \"127.0.0.1\" :\ninet_ntoa(my_http_addr.sin_addr),\nntohs(my_http_addr.sin_port), feed->VAR_0);", "}", "} else if (!av_strcasecmp(VAR_2, \"ReadOnlyFile\")) {", "if (feed) {", "get_arg(feed->feed_filename, sizeof(feed->feed_filename), &VAR_4);", "feed->readonly = 1;", "} else if (stream) {", "get_arg(stream->feed_filename, sizeof(stream->feed_filename), &VAR_4);", "}", "} else if (!av_strcasecmp(VAR_2, \"File\")) {", "if (feed) {", "get_arg(feed->feed_filename, sizeof(feed->feed_filename), &VAR_4);", "} else if (stream)", "get_arg(stream->feed_filename, sizeof(stream->feed_filename), &VAR_4);", "} else if (!av_strcasecmp(VAR_2, \"Truncate\")) {", "if (feed) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "feed->truncate = strtod(VAR_3, NULL);", "}", "} else if (!av_strcasecmp(VAR_2, \"FileMaxSize\")) {", "if (feed) {", "char *VAR_12;", "double VAR_13;", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "VAR_12 = VAR_3;", "VAR_13 = strtod(VAR_12, &VAR_12);", "switch(av_toupper(*VAR_12)) {", "case 'K':\nVAR_13 *= 1024;", "break;", "case 'M':\nVAR_13 *= 1024 * 1024;", "break;", "case 'G':\nVAR_13 *= 1024 * 1024 * 1024;", "break;", "}", "feed->feed_max_size = (int64_t)VAR_13;", "if (feed->feed_max_size < FFM_PACKET_SIZE*4) {", "ERROR(\"Feed max file size is too small, must be at least %d\\n\", FFM_PACKET_SIZE*4);", "}", "}", "} else if (!av_strcasecmp(VAR_2, \"</Feed>\")) {", "if (!feed) {", "ERROR(\"No corresponding <Feed> for </Feed>\\n\");", "}", "feed = NULL;", "} else if (!av_strcasecmp(VAR_2, \"<Stream\")) {", "char *VAR_18;", "if (stream || feed) {", "ERROR(\"Already in a tag\\n\");", "} else {", "FFStream *s;", "stream = av_mallocz(sizeof(FFStream));", "get_arg(stream->VAR_0, sizeof(stream->VAR_0), &VAR_4);", "VAR_18 = strrchr(stream->VAR_0, '>');", "if (VAR_18)\n*VAR_18 = '\\0';", "for (s = first_stream; s; s = s->next) {", "if (!strcmp(stream->VAR_0, s->VAR_0)) {", "ERROR(\"Stream '%s' already registered\\n\", s->VAR_0);", "}", "}", "stream->fmt = ffserver_guess_format(NULL, stream->VAR_0, NULL);", "avcodec_get_context_defaults3(&video_enc, NULL);", "avcodec_get_context_defaults3(&audio_enc, NULL);", "VAR_8 = AV_CODEC_ID_NONE;", "VAR_9 = AV_CODEC_ID_NONE;", "if (stream->fmt) {", "VAR_8 = stream->fmt->audio_codec;", "VAR_9 = stream->fmt->video_codec;", "}", "*last_stream = stream;", "last_stream = &stream->next;", "}", "} else if (!av_strcasecmp(VAR_2, \"Feed\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream) {", "FFStream *sfeed;", "sfeed = first_feed;", "while (sfeed != NULL) {", "if (!strcmp(sfeed->VAR_0, VAR_3))\nbreak;", "sfeed = sfeed->next_feed;", "}", "if (!sfeed)\nERROR(\"feed '%s' not defined\\n\", VAR_3);", "else\nstream->feed = sfeed;", "}", "} else if (!av_strcasecmp(VAR_2, \"Format\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream) {", "if (!strcmp(VAR_3, \"status\")) {", "stream->stream_type = STREAM_TYPE_STATUS;", "stream->fmt = NULL;", "} else {", "stream->stream_type = STREAM_TYPE_LIVE;", "if (!strcmp(VAR_3, \"jpeg\"))\nstrcpy(VAR_3, \"mjpeg\");", "stream->fmt = ffserver_guess_format(VAR_3, NULL, NULL);", "if (!stream->fmt) {", "ERROR(\"Unknown Format: %s\\n\", VAR_3);", "}", "}", "if (stream->fmt) {", "VAR_8 = stream->fmt->audio_codec;", "VAR_9 = stream->fmt->video_codec;", "}", "}", "} else if (!av_strcasecmp(VAR_2, \"InputFormat\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream) {", "stream->ifmt = av_find_input_format(VAR_3);", "if (!stream->ifmt) {", "ERROR(\"Unknown input format: %s\\n\", VAR_3);", "}", "}", "} else if (!av_strcasecmp(VAR_2, \"FaviconURL\")) {", "if (stream && stream->stream_type == STREAM_TYPE_STATUS) {", "get_arg(stream->feed_filename, sizeof(stream->feed_filename), &VAR_4);", "} else {", "ERROR(\"FaviconURL only permitted for status streams\\n\");", "}", "} else if (!av_strcasecmp(VAR_2, \"Author\")) {", "if (stream)\nget_arg(stream->author, sizeof(stream->author), &VAR_4);", "} else if (!av_strcasecmp(VAR_2, \"Comment\")) {", "if (stream)\nget_arg(stream->comment, sizeof(stream->comment), &VAR_4);", "} else if (!av_strcasecmp(VAR_2, \"Copyright\")) {", "if (stream)\nget_arg(stream->copyright, sizeof(stream->copyright), &VAR_4);", "} else if (!av_strcasecmp(VAR_2, \"Title\")) {", "if (stream)\nget_arg(stream->title, sizeof(stream->title), &VAR_4);", "} else if (!av_strcasecmp(VAR_2, \"Preroll\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream)\nstream->prebuffer = atof(VAR_3) * 1000;", "} else if (!av_strcasecmp(VAR_2, \"StartSendOnKey\")) {", "if (stream)\nstream->send_on_key = 1;", "} else if (!av_strcasecmp(VAR_2, \"AudioCodec\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "VAR_8 = opt_codec(VAR_3, AVMEDIA_TYPE_AUDIO);", "if (VAR_8 == AV_CODEC_ID_NONE) {", "ERROR(\"Unknown AudioCodec: %s\\n\", VAR_3);", "}", "} else if (!av_strcasecmp(VAR_2, \"VideoCodec\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "VAR_9 = opt_codec(VAR_3, AVMEDIA_TYPE_VIDEO);", "if (VAR_9 == AV_CODEC_ID_NONE) {", "ERROR(\"Unknown VideoCodec: %s\\n\", VAR_3);", "}", "} else if (!av_strcasecmp(VAR_2, \"MaxTime\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream)\nstream->max_time = atof(VAR_3) * 1000;", "} else if (!av_strcasecmp(VAR_2, \"AudioBitRate\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream)\naudio_enc.bit_rate = lrintf(atof(VAR_3) * 1000);", "} else if (!av_strcasecmp(VAR_2, \"AudioChannels\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream)\naudio_enc.channels = atoi(VAR_3);", "} else if (!av_strcasecmp(VAR_2, \"AudioSampleRate\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream)\naudio_enc.sample_rate = atoi(VAR_3);", "} else if (!av_strcasecmp(VAR_2, \"AudioQuality\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream) {", "}", "} else if (!av_strcasecmp(VAR_2, \"VideoBitRateRange\")) {", "if (stream) {", "int VAR_14, VAR_15;", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (sscanf(VAR_3, \"%d-%d\", &VAR_14, &VAR_15) == 2) {", "video_enc.rc_min_rate = VAR_14 * 1000;", "video_enc.rc_max_rate = VAR_15 * 1000;", "} else {", "ERROR(\"Incorrect format for VideoBitRateRange -- should be <min>-<max>: %s\\n\", VAR_3);", "}", "}", "} else if (!av_strcasecmp(VAR_2, \"Debug\")) {", "if (stream) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "video_enc.debug = strtol(VAR_3,0,0);", "}", "} else if (!av_strcasecmp(VAR_2, \"Strict\")) {", "if (stream) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "video_enc.strict_std_compliance = atoi(VAR_3);", "}", "} else if (!av_strcasecmp(VAR_2, \"VideoBufferSize\")) {", "if (stream) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "video_enc.rc_buffer_size = atoi(VAR_3) * 8*1024;", "}", "} else if (!av_strcasecmp(VAR_2, \"VideoBitRateTolerance\")) {", "if (stream) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "video_enc.bit_rate_tolerance = atoi(VAR_3) * 1000;", "}", "} else if (!av_strcasecmp(VAR_2, \"VideoBitRate\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream) {", "video_enc.bit_rate = atoi(VAR_3) * 1000;", "}", "} else if (!av_strcasecmp(VAR_2, \"VideoSize\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream) {", "av_parse_video_size(&video_enc.width, &video_enc.height, VAR_3);", "if ((video_enc.width % 16) != 0 ||\n(video_enc.height % 16) != 0) {", "ERROR(\"Image size must be a multiple of 16\\n\");", "}", "}", "} else if (!av_strcasecmp(VAR_2, \"VideoFrameRate\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream) {", "AVRational frame_rate;", "if (av_parse_video_rate(&frame_rate, VAR_3) < 0) {", "ERROR(\"Incorrect frame rate: %s\\n\", VAR_3);", "} else {", "video_enc.time_base.num = frame_rate.den;", "video_enc.time_base.den = frame_rate.num;", "}", "}", "} else if (!av_strcasecmp(VAR_2, \"PixelFormat\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream) {", "video_enc.pix_fmt = av_get_pix_fmt(VAR_3);", "if (video_enc.pix_fmt == AV_PIX_FMT_NONE) {", "ERROR(\"Unknown pixel format: %s\\n\", VAR_3);", "}", "}", "} else if (!av_strcasecmp(VAR_2, \"VideoGopSize\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream)\nvideo_enc.gop_size = atoi(VAR_3);", "} else if (!av_strcasecmp(VAR_2, \"VideoIntraOnly\")) {", "if (stream)\nvideo_enc.gop_size = 1;", "} else if (!av_strcasecmp(VAR_2, \"VideoHighQuality\")) {", "if (stream)\nvideo_enc.mb_decision = FF_MB_DECISION_BITS;", "} else if (!av_strcasecmp(VAR_2, \"Video4MotionVector\")) {", "if (stream) {", "video_enc.mb_decision = FF_MB_DECISION_BITS;", "video_enc.flags |= CODEC_FLAG_4MV;", "}", "} else if (!av_strcasecmp(VAR_2, \"AVOptionVideo\") ||", "!av_strcasecmp(VAR_2, \"AVOptionAudio\")) {", "char VAR_16[1024];", "AVCodecContext *avctx;", "int VAR_18;", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "get_arg(VAR_16, sizeof(VAR_16), &VAR_4);", "if (!av_strcasecmp(VAR_2, \"AVOptionVideo\")) {", "avctx = &video_enc;", "VAR_18 = AV_OPT_FLAG_VIDEO_PARAM;", "} else {", "avctx = &audio_enc;", "VAR_18 = AV_OPT_FLAG_AUDIO_PARAM;", "}", "if (ffserver_opt_default(VAR_3, VAR_16, avctx, VAR_18|AV_OPT_FLAG_ENCODING_PARAM)) {", "ERROR(\"Error setting %s option to %s %s\\n\", VAR_2, VAR_3, VAR_16);", "}", "} else if (!av_strcasecmp(VAR_2, \"AVPresetVideo\") ||", "!av_strcasecmp(VAR_2, \"AVPresetAudio\")) {", "AVCodecContext *avctx;", "int VAR_18;", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (!av_strcasecmp(VAR_2, \"AVPresetVideo\")) {", "avctx = &video_enc;", "video_enc.codec_id = VAR_9;", "VAR_18 = AV_OPT_FLAG_VIDEO_PARAM;", "} else {", "avctx = &audio_enc;", "audio_enc.codec_id = VAR_8;", "VAR_18 = AV_OPT_FLAG_AUDIO_PARAM;", "}", "if (ffserver_opt_preset(VAR_3, avctx, VAR_18|AV_OPT_FLAG_ENCODING_PARAM, &VAR_8, &VAR_9)) {", "ERROR(\"AVPreset error: %s\\n\", VAR_3);", "}", "} else if (!av_strcasecmp(VAR_2, \"VideoTag\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if ((strlen(VAR_3) == 4) && stream)\nvideo_enc.codec_tag = MKTAG(VAR_3[0], VAR_3[1], VAR_3[2], VAR_3[3]);", "} else if (!av_strcasecmp(VAR_2, \"BitExact\")) {", "if (stream)\nvideo_enc.flags |= CODEC_FLAG_BITEXACT;", "} else if (!av_strcasecmp(VAR_2, \"DctFastint\")) {", "if (stream)\nvideo_enc.dct_algo = FF_DCT_FASTINT;", "} else if (!av_strcasecmp(VAR_2, \"IdctSimple\")) {", "if (stream)\nvideo_enc.idct_algo = FF_IDCT_SIMPLE;", "} else if (!av_strcasecmp(VAR_2, \"Qscale\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream) {", "video_enc.flags |= CODEC_FLAG_QSCALE;", "video_enc.global_quality = FF_QP2LAMBDA * atoi(VAR_3);", "}", "} else if (!av_strcasecmp(VAR_2, \"VideoQDiff\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream) {", "video_enc.max_qdiff = atoi(VAR_3);", "if (video_enc.max_qdiff < 1 || video_enc.max_qdiff > 31) {", "ERROR(\"VideoQDiff out of range\\n\");", "}", "}", "} else if (!av_strcasecmp(VAR_2, \"VideoQMax\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream) {", "video_enc.qmax = atoi(VAR_3);", "if (video_enc.qmax < 1 || video_enc.qmax > 31) {", "ERROR(\"VideoQMax out of range\\n\");", "}", "}", "} else if (!av_strcasecmp(VAR_2, \"VideoQMin\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream) {", "video_enc.qmin = atoi(VAR_3);", "if (video_enc.qmin < 1 || video_enc.qmin > 31) {", "ERROR(\"VideoQMin out of range\\n\");", "}", "}", "} else if (!av_strcasecmp(VAR_2, \"LumiMask\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream)\nvideo_enc.lumi_masking = atof(VAR_3);", "} else if (!av_strcasecmp(VAR_2, \"DarkMask\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream)\nvideo_enc.dark_masking = atof(VAR_3);", "} else if (!av_strcasecmp(VAR_2, \"NoVideo\")) {", "VAR_9 = AV_CODEC_ID_NONE;", "} else if (!av_strcasecmp(VAR_2, \"NoAudio\")) {", "VAR_8 = AV_CODEC_ID_NONE;", "} else if (!av_strcasecmp(VAR_2, \"ACL\")) {", "parse_acl_row(stream, feed, NULL, VAR_4, VAR_0, VAR_7);", "} else if (!av_strcasecmp(VAR_2, \"DynamicACL\")) {", "if (stream) {", "get_arg(stream->dynamic_acl, sizeof(stream->dynamic_acl), &VAR_4);", "}", "} else if (!av_strcasecmp(VAR_2, \"RTSPOption\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream) {", "av_freep(&stream->rtsp_option);", "stream->rtsp_option = av_strdup(VAR_3);", "}", "} else if (!av_strcasecmp(VAR_2, \"MulticastAddress\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream) {", "if (resolve_host(&stream->multicast_ip, VAR_3) != 0) {", "ERROR(\"Invalid host/IP address: %s\\n\", VAR_3);", "}", "stream->is_multicast = 1;", "stream->loop = 1;", "}", "} else if (!av_strcasecmp(VAR_2, \"MulticastPort\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream)\nstream->multicast_port = atoi(VAR_3);", "} else if (!av_strcasecmp(VAR_2, \"MulticastTTL\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream)\nstream->multicast_ttl = atoi(VAR_3);", "} else if (!av_strcasecmp(VAR_2, \"NoLoop\")) {", "if (stream)\nstream->loop = 0;", "} else if (!av_strcasecmp(VAR_2, \"</Stream>\")) {", "if (!stream) {", "ERROR(\"No corresponding <Stream> for </Stream>\\n\");", "} else {", "if (stream->feed && stream->fmt && strcmp(stream->fmt->name, \"ffm\") != 0) {", "if (VAR_8 != AV_CODEC_ID_NONE) {", "audio_enc.codec_type = AVMEDIA_TYPE_AUDIO;", "audio_enc.codec_id = VAR_8;", "add_codec(stream, &audio_enc);", "}", "if (VAR_9 != AV_CODEC_ID_NONE) {", "video_enc.codec_type = AVMEDIA_TYPE_VIDEO;", "video_enc.codec_id = VAR_9;", "add_codec(stream, &video_enc);", "}", "}", "stream = NULL;", "}", "} else if (!av_strcasecmp(VAR_2, \"<Redirect\")) {", "char *VAR_18;", "if (stream || feed || redirect) {", "ERROR(\"Already in a tag\\n\");", "} else {", "redirect = av_mallocz(sizeof(FFStream));", "*last_stream = redirect;", "last_stream = &redirect->next;", "get_arg(redirect->VAR_0, sizeof(redirect->VAR_0), &VAR_4);", "VAR_18 = strrchr(redirect->VAR_0, '>');", "if (*VAR_18)\n*VAR_18 = '\\0';", "redirect->stream_type = STREAM_TYPE_REDIRECT;", "}", "} else if (!av_strcasecmp(VAR_2, \"URL\")) {", "if (redirect)\nget_arg(redirect->feed_filename, sizeof(redirect->feed_filename), &VAR_4);", "} else if (!av_strcasecmp(VAR_2, \"</Redirect>\")) {", "if (!redirect) {", "ERROR(\"No corresponding <Redirect> for </Redirect>\\n\");", "} else {", "if (!redirect->feed_filename[0]) {", "ERROR(\"No URL found for <Redirect>\\n\");", "}", "redirect = NULL;", "}", "} else if (!av_strcasecmp(VAR_2, \"LoadModule\")) {", "ERROR(\"Loadable modules no longer supported\\n\");", "} else {", "ERROR(\"Incorrect keyword: '%s'\\n\", VAR_2);", "}", "}", "#undef ERROR\nfclose(f);", "if (VAR_6)\nreturn -1;", "else\nreturn 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 63, 65 ], [ 67, 69 ], [ 71 ], [ 73 ], [ 75, 77 ], [ 79, 81 ], [ 85 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 175 ], [ 177 ], [ 179 ], [ 181 ], [ 183 ], [ 185 ], [ 187 ], [ 189, 191 ], [ 193 ], [ 199 ], [ 201 ], [ 203 ], [ 205 ], [ 207 ], [ 209 ], [ 211 ], [ 213, 215 ], [ 219 ], [ 221 ], [ 223 ], [ 225 ], [ 227 ], [ 231 ], [ 235, 237 ], [ 239 ], [ 241 ], [ 243 ], [ 249 ], [ 251 ], [ 255 ], [ 257 ], [ 259 ], [ 261 ], [ 263 ], [ 265 ], [ 269 ], [ 273 ], [ 275 ], [ 277, 279 ], [ 283 ], [ 285 ], [ 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 ], [ 343 ], [ 345 ], [ 347 ], [ 349 ], [ 351, 353 ], [ 355 ], [ 357, 359 ], [ 361 ], [ 363, 365 ], [ 367 ], [ 369 ], [ 371 ], [ 373 ], [ 375 ], [ 377 ], [ 379 ], [ 381 ], [ 383 ], [ 385 ], [ 387 ], [ 389 ], [ 391 ], [ 397 ], [ 399 ], [ 401 ], [ 403 ], [ 405 ], [ 407 ], [ 409 ], [ 411 ], [ 413, 415 ], [ 419 ], [ 421 ], [ 423 ], [ 425 ], [ 427 ], [ 431 ], [ 433 ], [ 435 ], [ 439 ], [ 441 ], [ 443 ], [ 445 ], [ 447 ], [ 449 ], [ 453 ], [ 455 ], [ 457 ], [ 459 ], [ 461 ], [ 463 ], [ 465 ], [ 469 ], [ 471 ], [ 473, 475 ], [ 477 ], [ 479 ], [ 481, 483 ], [ 485, 487 ], [ 489 ], [ 491 ], [ 493 ], [ 495 ], [ 497 ], [ 499 ], [ 501 ], [ 503 ], [ 505 ], [ 509, 511 ], [ 513 ], [ 515 ], [ 517 ], [ 519 ], [ 521 ], [ 523 ], [ 525 ], [ 527 ], [ 529 ], [ 531 ], [ 533 ], [ 535 ], [ 537 ], [ 539 ], [ 541 ], [ 543 ], [ 545 ], [ 547 ], [ 549 ], [ 551 ], [ 553 ], [ 555 ], [ 557 ], [ 559 ], [ 561 ], [ 563, 565 ], [ 567 ], [ 569, 571 ], [ 573 ], [ 575, 577 ], [ 579 ], [ 581, 583 ], [ 585 ], [ 587 ], [ 589, 591 ], [ 593 ], [ 595, 597 ], [ 599 ], [ 601 ], [ 603 ], [ 605 ], [ 607 ], [ 609 ], [ 611 ], [ 613 ], [ 615 ], [ 617 ], [ 619 ], [ 621 ], [ 623 ], [ 625 ], [ 627, 629 ], [ 631 ], [ 633 ], [ 635, 637 ], [ 639 ], [ 641 ], [ 643, 645 ], [ 647 ], [ 649 ], [ 651, 653 ], [ 655 ], [ 657 ], [ 659 ], [ 663 ], [ 665 ], [ 667 ], [ 669 ], [ 673 ], [ 677 ], [ 679 ], [ 681 ], [ 683 ], [ 685 ], [ 687 ], [ 689 ], [ 691 ], [ 693 ], [ 695 ], [ 697 ], [ 699 ], [ 701 ], [ 703 ], [ 705 ], [ 707 ], [ 709 ], [ 711 ], [ 713 ], [ 715 ], [ 717 ], [ 719 ], [ 721 ], [ 723 ], [ 725 ], [ 727 ], [ 729 ], [ 731 ], [ 733 ], [ 735 ], [ 737 ], [ 739 ], [ 741 ], [ 743 ], [ 745 ], [ 747 ], [ 749, 751 ], [ 753 ], [ 755 ], [ 757 ], [ 759 ], [ 761 ], [ 763 ], [ 765 ], [ 767 ], [ 769 ], [ 771 ], [ 773 ], [ 775 ], [ 777 ], [ 779 ], [ 781 ], [ 783 ], [ 785 ], [ 787 ], [ 789 ], [ 791 ], [ 793 ], [ 795 ], [ 797 ], [ 799 ], [ 801, 803 ], [ 805 ], [ 807, 809 ], [ 811 ], [ 813, 815 ], [ 817 ], [ 819 ], [ 821 ], [ 823 ], [ 825 ], [ 827 ], [ 829 ], [ 831 ], [ 833 ], [ 835 ], [ 837 ], [ 839 ], [ 841 ], [ 843 ], [ 845 ], [ 847 ], [ 849 ], [ 851 ], [ 853 ], [ 855 ], [ 857 ], [ 859 ], [ 861 ], [ 863 ], [ 865 ], [ 867 ], [ 869 ], [ 871 ], [ 873 ], [ 875 ], [ 877 ], [ 879 ], [ 881 ], [ 883 ], [ 885 ], [ 887 ], [ 889 ], [ 891 ], [ 893 ], [ 895 ], [ 897 ], [ 899, 901 ], [ 903 ], [ 905, 907 ], [ 909 ], [ 911, 913 ], [ 915 ], [ 917, 919 ], [ 921 ], [ 923 ], [ 925 ], [ 927 ], [ 929 ], [ 931 ], [ 933 ], [ 935 ], [ 937 ], [ 939 ], [ 941 ], [ 943 ], [ 945 ], [ 947 ], [ 949 ], [ 951 ], [ 953 ], [ 955 ], [ 957 ], [ 959 ], [ 961 ], [ 963 ], [ 965 ], [ 967 ], [ 969 ], [ 971 ], [ 973 ], [ 975 ], [ 977 ], [ 979 ], [ 981 ], [ 983 ], [ 985, 987 ], [ 989 ], [ 991 ], [ 993, 995 ], [ 997 ], [ 999 ], [ 1001 ], [ 1003 ], [ 1005 ], [ 1007 ], [ 1009 ], [ 1011 ], [ 1013 ], [ 1015 ], [ 1017 ], [ 1019 ], [ 1021 ], [ 1023 ], [ 1025 ], [ 1027 ], [ 1029 ], [ 1031 ], [ 1033 ], [ 1035 ], [ 1037 ], [ 1039 ], [ 1041 ], [ 1043 ], [ 1045 ], [ 1047 ], [ 1049 ], [ 1051, 1053 ], [ 1055 ], [ 1057 ], [ 1059, 1061 ], [ 1063 ], [ 1065, 1067 ], [ 1069 ], [ 1071 ], [ 1073 ], [ 1075 ], [ 1077 ], [ 1079 ], [ 1081 ], [ 1083 ], [ 1085 ], [ 1087 ], [ 1089 ], [ 1091 ], [ 1093 ], [ 1095 ], [ 1097 ], [ 1099 ], [ 1101 ], [ 1103 ], [ 1105 ], [ 1109 ], [ 1111 ], [ 1113 ], [ 1115 ], [ 1117 ], [ 1119 ], [ 1121 ], [ 1125 ], [ 1127 ], [ 1129, 1131 ], [ 1133 ], [ 1135 ], [ 1137 ], [ 1139, 1141 ], [ 1143 ], [ 1145 ], [ 1147 ], [ 1149 ], [ 1151 ], [ 1153 ], [ 1155 ], [ 1157 ], [ 1159 ], [ 1161 ], [ 1163 ], [ 1165 ], [ 1167 ], [ 1169 ], [ 1171 ], [ 1173, 1177 ], [ 1179, 1181 ], [ 1183, 1185 ], [ 1187 ] ]
22,130
static void updateMMXDitherTables(SwsContext *c, int dstY, int lumBufIndex, int chrBufIndex, int lastInLumBuf, int lastInChrBuf) { const int dstH= c->dstH; const int flags= c->flags; int16_t **lumPixBuf= c->lumPixBuf; int16_t **chrUPixBuf= c->chrUPixBuf; int16_t **chrVPixBuf= c->chrVPixBuf; int16_t **alpPixBuf= c->alpPixBuf; const int vLumBufSize= c->vLumBufSize; const int vChrBufSize= c->vChrBufSize; int16_t *vLumFilterPos= c->vLumFilterPos; int16_t *vChrFilterPos= c->vChrFilterPos; int16_t *vLumFilter= c->vLumFilter; int16_t *vChrFilter= c->vChrFilter; int32_t *lumMmxFilter= c->lumMmxFilter; int32_t *chrMmxFilter= c->chrMmxFilter; int32_t av_unused *alpMmxFilter= c->alpMmxFilter; const int vLumFilterSize= c->vLumFilterSize; const int vChrFilterSize= c->vChrFilterSize; const int chrDstY= dstY>>c->chrDstVSubSample; const int firstLumSrcY= vLumFilterPos[dstY]; //First line needed as input const int firstChrSrcY= vChrFilterPos[chrDstY]; //First line needed as input c->blueDither= ff_dither8[dstY&1]; if (c->dstFormat == PIX_FMT_RGB555 || c->dstFormat == PIX_FMT_BGR555) c->greenDither= ff_dither8[dstY&1]; else c->greenDither= ff_dither4[dstY&1]; c->redDither= ff_dither8[(dstY+1)&1]; if (dstY < dstH - 2) { const int16_t **lumSrcPtr= (const int16_t **) lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize; const int16_t **chrUSrcPtr= (const int16_t **) chrUPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize; const int16_t **chrVSrcPtr= (const int16_t **) chrVPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize; const int16_t **alpSrcPtr= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? (const int16_t **) alpPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize : NULL; int i; if (flags & SWS_ACCURATE_RND) { int s= APCK_SIZE / 8; for (i=0; i<vLumFilterSize; i+=2) { *(const void**)&lumMmxFilter[s*i ]= lumSrcPtr[i ]; *(const void**)&lumMmxFilter[s*i+APCK_PTR2/4 ]= lumSrcPtr[i+(vLumFilterSize>1)]; lumMmxFilter[s*i+APCK_COEF/4 ]= lumMmxFilter[s*i+APCK_COEF/4+1]= vLumFilter[dstY*vLumFilterSize + i ] + (vLumFilterSize>1 ? vLumFilter[dstY*vLumFilterSize + i + 1]<<16 : 0); if (CONFIG_SWSCALE_ALPHA && alpPixBuf) { *(const void**)&alpMmxFilter[s*i ]= alpSrcPtr[i ]; *(const void**)&alpMmxFilter[s*i+APCK_PTR2/4 ]= alpSrcPtr[i+(vLumFilterSize>1)]; alpMmxFilter[s*i+APCK_COEF/4 ]= alpMmxFilter[s*i+APCK_COEF/4+1]= lumMmxFilter[s*i+APCK_COEF/4 ]; } } for (i=0; i<vChrFilterSize; i+=2) { *(const void**)&chrMmxFilter[s*i ]= chrUSrcPtr[i ]; *(const void**)&chrMmxFilter[s*i+APCK_PTR2/4 ]= chrUSrcPtr[i+(vChrFilterSize>1)]; chrMmxFilter[s*i+APCK_COEF/4 ]= chrMmxFilter[s*i+APCK_COEF/4+1]= vChrFilter[chrDstY*vChrFilterSize + i ] + (vChrFilterSize>1 ? vChrFilter[chrDstY*vChrFilterSize + i + 1]<<16 : 0); } } else { for (i=0; i<vLumFilterSize; i++) { *(const void**)&lumMmxFilter[4*i+0]= lumSrcPtr[i]; lumMmxFilter[4*i+2]= lumMmxFilter[4*i+3]= ((uint16_t)vLumFilter[dstY*vLumFilterSize + i])*0x10001; if (CONFIG_SWSCALE_ALPHA && alpPixBuf) { *(const void**)&alpMmxFilter[4*i+0]= alpSrcPtr[i]; alpMmxFilter[4*i+2]= alpMmxFilter[4*i+3]= lumMmxFilter[4*i+2]; } } for (i=0; i<vChrFilterSize; i++) { *(const void**)&chrMmxFilter[4*i+0]= chrUSrcPtr[i]; chrMmxFilter[4*i+2]= chrMmxFilter[4*i+3]= ((uint16_t)vChrFilter[chrDstY*vChrFilterSize + i])*0x10001; } } } }
true
FFmpeg
39d607e5bbc25ad9629683702b510e865434ef21
static void updateMMXDitherTables(SwsContext *c, int dstY, int lumBufIndex, int chrBufIndex, int lastInLumBuf, int lastInChrBuf) { const int dstH= c->dstH; const int flags= c->flags; int16_t **lumPixBuf= c->lumPixBuf; int16_t **chrUPixBuf= c->chrUPixBuf; int16_t **chrVPixBuf= c->chrVPixBuf; int16_t **alpPixBuf= c->alpPixBuf; const int vLumBufSize= c->vLumBufSize; const int vChrBufSize= c->vChrBufSize; int16_t *vLumFilterPos= c->vLumFilterPos; int16_t *vChrFilterPos= c->vChrFilterPos; int16_t *vLumFilter= c->vLumFilter; int16_t *vChrFilter= c->vChrFilter; int32_t *lumMmxFilter= c->lumMmxFilter; int32_t *chrMmxFilter= c->chrMmxFilter; int32_t av_unused *alpMmxFilter= c->alpMmxFilter; const int vLumFilterSize= c->vLumFilterSize; const int vChrFilterSize= c->vChrFilterSize; const int chrDstY= dstY>>c->chrDstVSubSample; const int firstLumSrcY= vLumFilterPos[dstY]; const int firstChrSrcY= vChrFilterPos[chrDstY]; c->blueDither= ff_dither8[dstY&1]; if (c->dstFormat == PIX_FMT_RGB555 || c->dstFormat == PIX_FMT_BGR555) c->greenDither= ff_dither8[dstY&1]; else c->greenDither= ff_dither4[dstY&1]; c->redDither= ff_dither8[(dstY+1)&1]; if (dstY < dstH - 2) { const int16_t **lumSrcPtr= (const int16_t **) lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize; const int16_t **chrUSrcPtr= (const int16_t **) chrUPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize; const int16_t **chrVSrcPtr= (const int16_t **) chrVPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize; const int16_t **alpSrcPtr= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? (const int16_t **) alpPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize : NULL; int i; if (flags & SWS_ACCURATE_RND) { int s= APCK_SIZE / 8; for (i=0; i<vLumFilterSize; i+=2) { *(const void**)&lumMmxFilter[s*i ]= lumSrcPtr[i ]; *(const void**)&lumMmxFilter[s*i+APCK_PTR2/4 ]= lumSrcPtr[i+(vLumFilterSize>1)]; lumMmxFilter[s*i+APCK_COEF/4 ]= lumMmxFilter[s*i+APCK_COEF/4+1]= vLumFilter[dstY*vLumFilterSize + i ] + (vLumFilterSize>1 ? vLumFilter[dstY*vLumFilterSize + i + 1]<<16 : 0); if (CONFIG_SWSCALE_ALPHA && alpPixBuf) { *(const void**)&alpMmxFilter[s*i ]= alpSrcPtr[i ]; *(const void**)&alpMmxFilter[s*i+APCK_PTR2/4 ]= alpSrcPtr[i+(vLumFilterSize>1)]; alpMmxFilter[s*i+APCK_COEF/4 ]= alpMmxFilter[s*i+APCK_COEF/4+1]= lumMmxFilter[s*i+APCK_COEF/4 ]; } } for (i=0; i<vChrFilterSize; i+=2) { *(const void**)&chrMmxFilter[s*i ]= chrUSrcPtr[i ]; *(const void**)&chrMmxFilter[s*i+APCK_PTR2/4 ]= chrUSrcPtr[i+(vChrFilterSize>1)]; chrMmxFilter[s*i+APCK_COEF/4 ]= chrMmxFilter[s*i+APCK_COEF/4+1]= vChrFilter[chrDstY*vChrFilterSize + i ] + (vChrFilterSize>1 ? vChrFilter[chrDstY*vChrFilterSize + i + 1]<<16 : 0); } } else { for (i=0; i<vLumFilterSize; i++) { *(const void**)&lumMmxFilter[4*i+0]= lumSrcPtr[i]; lumMmxFilter[4*i+2]= lumMmxFilter[4*i+3]= ((uint16_t)vLumFilter[dstY*vLumFilterSize + i])*0x10001; if (CONFIG_SWSCALE_ALPHA && alpPixBuf) { *(const void**)&alpMmxFilter[4*i+0]= alpSrcPtr[i]; alpMmxFilter[4*i+2]= alpMmxFilter[4*i+3]= lumMmxFilter[4*i+2]; } } for (i=0; i<vChrFilterSize; i++) { *(const void**)&chrMmxFilter[4*i+0]= chrUSrcPtr[i]; chrMmxFilter[4*i+2]= chrMmxFilter[4*i+3]= ((uint16_t)vChrFilter[chrDstY*vChrFilterSize + i])*0x10001; } } } }
{ "code": [ " int16_t **chrVPixBuf= c->chrVPixBuf;", " const int16_t **chrVSrcPtr= (const int16_t **) chrVPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;" ], "line_no": [ 15, 67 ] }
static void FUNC_0(SwsContext *VAR_0, int VAR_1, int VAR_2, int VAR_3, int VAR_4, int VAR_5) { const int VAR_6= VAR_0->VAR_6; const int VAR_7= VAR_0->VAR_7; int16_t **lumPixBuf= VAR_0->lumPixBuf; int16_t **chrUPixBuf= VAR_0->chrUPixBuf; int16_t **chrVPixBuf= VAR_0->chrVPixBuf; int16_t **alpPixBuf= VAR_0->alpPixBuf; const int VAR_8= VAR_0->VAR_8; const int VAR_9= VAR_0->VAR_9; int16_t *vLumFilterPos= VAR_0->vLumFilterPos; int16_t *vChrFilterPos= VAR_0->vChrFilterPos; int16_t *vLumFilter= VAR_0->vLumFilter; int16_t *vChrFilter= VAR_0->vChrFilter; int32_t *lumMmxFilter= VAR_0->lumMmxFilter; int32_t *chrMmxFilter= VAR_0->chrMmxFilter; int32_t av_unused *alpMmxFilter= VAR_0->alpMmxFilter; const int VAR_10= VAR_0->VAR_10; const int VAR_11= VAR_0->VAR_11; const int VAR_12= VAR_1>>VAR_0->chrDstVSubSample; const int VAR_13= vLumFilterPos[VAR_1]; const int VAR_14= vChrFilterPos[VAR_12]; VAR_0->blueDither= ff_dither8[VAR_1&1]; if (VAR_0->dstFormat == PIX_FMT_RGB555 || VAR_0->dstFormat == PIX_FMT_BGR555) VAR_0->greenDither= ff_dither8[VAR_1&1]; else VAR_0->greenDither= ff_dither4[VAR_1&1]; VAR_0->redDither= ff_dither8[(VAR_1+1)&1]; if (VAR_1 < VAR_6 - 2) { const int16_t **VAR_15= (const int16_t **) lumPixBuf + VAR_2 + VAR_13 - VAR_4 + VAR_8; const int16_t **VAR_16= (const int16_t **) chrUPixBuf + VAR_3 + VAR_14 - VAR_5 + VAR_9; const int16_t **VAR_17= (const int16_t **) chrVPixBuf + VAR_3 + VAR_14 - VAR_5 + VAR_9; const int16_t **VAR_18= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? (const int16_t **) alpPixBuf + VAR_2 + VAR_13 - VAR_4 + VAR_8 : NULL; int VAR_19; if (VAR_7 & SWS_ACCURATE_RND) { int VAR_20= APCK_SIZE / 8; for (VAR_19=0; VAR_19<VAR_10; VAR_19+=2) { *(const void**)&lumMmxFilter[VAR_20*VAR_19 ]= VAR_15[VAR_19 ]; *(const void**)&lumMmxFilter[VAR_20*VAR_19+APCK_PTR2/4 ]= VAR_15[VAR_19+(VAR_10>1)]; lumMmxFilter[VAR_20*VAR_19+APCK_COEF/4 ]= lumMmxFilter[VAR_20*VAR_19+APCK_COEF/4+1]= vLumFilter[VAR_1*VAR_10 + VAR_19 ] + (VAR_10>1 ? vLumFilter[VAR_1*VAR_10 + VAR_19 + 1]<<16 : 0); if (CONFIG_SWSCALE_ALPHA && alpPixBuf) { *(const void**)&alpMmxFilter[VAR_20*VAR_19 ]= VAR_18[VAR_19 ]; *(const void**)&alpMmxFilter[VAR_20*VAR_19+APCK_PTR2/4 ]= VAR_18[VAR_19+(VAR_10>1)]; alpMmxFilter[VAR_20*VAR_19+APCK_COEF/4 ]= alpMmxFilter[VAR_20*VAR_19+APCK_COEF/4+1]= lumMmxFilter[VAR_20*VAR_19+APCK_COEF/4 ]; } } for (VAR_19=0; VAR_19<VAR_11; VAR_19+=2) { *(const void**)&chrMmxFilter[VAR_20*VAR_19 ]= VAR_16[VAR_19 ]; *(const void**)&chrMmxFilter[VAR_20*VAR_19+APCK_PTR2/4 ]= VAR_16[VAR_19+(VAR_11>1)]; chrMmxFilter[VAR_20*VAR_19+APCK_COEF/4 ]= chrMmxFilter[VAR_20*VAR_19+APCK_COEF/4+1]= vChrFilter[VAR_12*VAR_11 + VAR_19 ] + (VAR_11>1 ? vChrFilter[VAR_12*VAR_11 + VAR_19 + 1]<<16 : 0); } } else { for (VAR_19=0; VAR_19<VAR_10; VAR_19++) { *(const void**)&lumMmxFilter[4*VAR_19+0]= VAR_15[VAR_19]; lumMmxFilter[4*VAR_19+2]= lumMmxFilter[4*VAR_19+3]= ((uint16_t)vLumFilter[VAR_1*VAR_10 + VAR_19])*0x10001; if (CONFIG_SWSCALE_ALPHA && alpPixBuf) { *(const void**)&alpMmxFilter[4*VAR_19+0]= VAR_18[VAR_19]; alpMmxFilter[4*VAR_19+2]= alpMmxFilter[4*VAR_19+3]= lumMmxFilter[4*VAR_19+2]; } } for (VAR_19=0; VAR_19<VAR_11; VAR_19++) { *(const void**)&chrMmxFilter[4*VAR_19+0]= VAR_16[VAR_19]; chrMmxFilter[4*VAR_19+2]= chrMmxFilter[4*VAR_19+3]= ((uint16_t)vChrFilter[VAR_12*VAR_11 + VAR_19])*0x10001; } } } }
[ "static void FUNC_0(SwsContext *VAR_0, int VAR_1, int VAR_2, int VAR_3,\nint VAR_4, int VAR_5)\n{", "const int VAR_6= VAR_0->VAR_6;", "const int VAR_7= VAR_0->VAR_7;", "int16_t **lumPixBuf= VAR_0->lumPixBuf;", "int16_t **chrUPixBuf= VAR_0->chrUPixBuf;", "int16_t **chrVPixBuf= VAR_0->chrVPixBuf;", "int16_t **alpPixBuf= VAR_0->alpPixBuf;", "const int VAR_8= VAR_0->VAR_8;", "const int VAR_9= VAR_0->VAR_9;", "int16_t *vLumFilterPos= VAR_0->vLumFilterPos;", "int16_t *vChrFilterPos= VAR_0->vChrFilterPos;", "int16_t *vLumFilter= VAR_0->vLumFilter;", "int16_t *vChrFilter= VAR_0->vChrFilter;", "int32_t *lumMmxFilter= VAR_0->lumMmxFilter;", "int32_t *chrMmxFilter= VAR_0->chrMmxFilter;", "int32_t av_unused *alpMmxFilter= VAR_0->alpMmxFilter;", "const int VAR_10= VAR_0->VAR_10;", "const int VAR_11= VAR_0->VAR_11;", "const int VAR_12= VAR_1>>VAR_0->chrDstVSubSample;", "const int VAR_13= vLumFilterPos[VAR_1];", "const int VAR_14= vChrFilterPos[VAR_12];", "VAR_0->blueDither= ff_dither8[VAR_1&1];", "if (VAR_0->dstFormat == PIX_FMT_RGB555 || VAR_0->dstFormat == PIX_FMT_BGR555)\nVAR_0->greenDither= ff_dither8[VAR_1&1];", "else\nVAR_0->greenDither= ff_dither4[VAR_1&1];", "VAR_0->redDither= ff_dither8[(VAR_1+1)&1];", "if (VAR_1 < VAR_6 - 2) {", "const int16_t **VAR_15= (const int16_t **) lumPixBuf + VAR_2 + VAR_13 - VAR_4 + VAR_8;", "const int16_t **VAR_16= (const int16_t **) chrUPixBuf + VAR_3 + VAR_14 - VAR_5 + VAR_9;", "const int16_t **VAR_17= (const int16_t **) chrVPixBuf + VAR_3 + VAR_14 - VAR_5 + VAR_9;", "const int16_t **VAR_18= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? (const int16_t **) alpPixBuf + VAR_2 + VAR_13 - VAR_4 + VAR_8 : NULL;", "int VAR_19;", "if (VAR_7 & SWS_ACCURATE_RND) {", "int VAR_20= APCK_SIZE / 8;", "for (VAR_19=0; VAR_19<VAR_10; VAR_19+=2) {", "*(const void**)&lumMmxFilter[VAR_20*VAR_19 ]= VAR_15[VAR_19 ];", "*(const void**)&lumMmxFilter[VAR_20*VAR_19+APCK_PTR2/4 ]= VAR_15[VAR_19+(VAR_10>1)];", "lumMmxFilter[VAR_20*VAR_19+APCK_COEF/4 ]=\nlumMmxFilter[VAR_20*VAR_19+APCK_COEF/4+1]= vLumFilter[VAR_1*VAR_10 + VAR_19 ]\n+ (VAR_10>1 ? vLumFilter[VAR_1*VAR_10 + VAR_19 + 1]<<16 : 0);", "if (CONFIG_SWSCALE_ALPHA && alpPixBuf) {", "*(const void**)&alpMmxFilter[VAR_20*VAR_19 ]= VAR_18[VAR_19 ];", "*(const void**)&alpMmxFilter[VAR_20*VAR_19+APCK_PTR2/4 ]= VAR_18[VAR_19+(VAR_10>1)];", "alpMmxFilter[VAR_20*VAR_19+APCK_COEF/4 ]=\nalpMmxFilter[VAR_20*VAR_19+APCK_COEF/4+1]= lumMmxFilter[VAR_20*VAR_19+APCK_COEF/4 ];", "}", "}", "for (VAR_19=0; VAR_19<VAR_11; VAR_19+=2) {", "*(const void**)&chrMmxFilter[VAR_20*VAR_19 ]= VAR_16[VAR_19 ];", "*(const void**)&chrMmxFilter[VAR_20*VAR_19+APCK_PTR2/4 ]= VAR_16[VAR_19+(VAR_11>1)];", "chrMmxFilter[VAR_20*VAR_19+APCK_COEF/4 ]=\nchrMmxFilter[VAR_20*VAR_19+APCK_COEF/4+1]= vChrFilter[VAR_12*VAR_11 + VAR_19 ]\n+ (VAR_11>1 ? vChrFilter[VAR_12*VAR_11 + VAR_19 + 1]<<16 : 0);", "}", "} else {", "for (VAR_19=0; VAR_19<VAR_10; VAR_19++) {", "*(const void**)&lumMmxFilter[4*VAR_19+0]= VAR_15[VAR_19];", "lumMmxFilter[4*VAR_19+2]=\nlumMmxFilter[4*VAR_19+3]=\n((uint16_t)vLumFilter[VAR_1*VAR_10 + VAR_19])*0x10001;", "if (CONFIG_SWSCALE_ALPHA && alpPixBuf) {", "*(const void**)&alpMmxFilter[4*VAR_19+0]= VAR_18[VAR_19];", "alpMmxFilter[4*VAR_19+2]=\nalpMmxFilter[4*VAR_19+3]= lumMmxFilter[4*VAR_19+2];", "}", "}", "for (VAR_19=0; VAR_19<VAR_11; VAR_19++) {", "*(const void**)&chrMmxFilter[4*VAR_19+0]= VAR_16[VAR_19];", "chrMmxFilter[4*VAR_19+2]=\nchrMmxFilter[4*VAR_19+3]=\n((uint16_t)vChrFilter[VAR_12*VAR_11 + VAR_19])*0x10001;", "}", "}", "}", "}" ]
[ 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, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 49 ], [ 51, 53 ], [ 55, 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83, 85, 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95, 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109, 111, 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123, 125, 127 ], [ 129 ], [ 131 ], [ 133, 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145, 147, 149 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ] ]
22,131
static inline int decode_alpha_block(const SHQContext *s, GetBitContext *gb, uint8_t last_alpha[16], uint8_t *dest, int linesize) { uint8_t block[128]; int i = 0, x, y; memset(block, 0, sizeof(block)); { OPEN_READER(re, gb); for ( ;; ) { int run, level; UPDATE_CACHE_LE(re, gb); GET_VLC(run, re, gb, ff_dc_alpha_run_vlc_le.table, ALPHA_VLC_BITS, 2); if (run == 128) break; i += run; if (i >= 128) return AVERROR_INVALIDDATA; UPDATE_CACHE_LE(re, gb); GET_VLC(level, re, gb, ff_dc_alpha_level_vlc_le.table, ALPHA_VLC_BITS, 2); block[i++] = level; } CLOSE_READER(re, gb); } for (y = 0; y < 8; y++) { for (x = 0; x < 16; x++) { last_alpha[x] -= block[y * 16 + x]; } memcpy(dest, last_alpha, 16); dest += linesize; } return 0; }
true
FFmpeg
08b098169be079c4f124a351fda6764fbcd10e79
static inline int decode_alpha_block(const SHQContext *s, GetBitContext *gb, uint8_t last_alpha[16], uint8_t *dest, int linesize) { uint8_t block[128]; int i = 0, x, y; memset(block, 0, sizeof(block)); { OPEN_READER(re, gb); for ( ;; ) { int run, level; UPDATE_CACHE_LE(re, gb); GET_VLC(run, re, gb, ff_dc_alpha_run_vlc_le.table, ALPHA_VLC_BITS, 2); if (run == 128) break; i += run; if (i >= 128) return AVERROR_INVALIDDATA; UPDATE_CACHE_LE(re, gb); GET_VLC(level, re, gb, ff_dc_alpha_level_vlc_le.table, ALPHA_VLC_BITS, 2); block[i++] = level; } CLOSE_READER(re, gb); } for (y = 0; y < 8; y++) { for (x = 0; x < 16; x++) { last_alpha[x] -= block[y * 16 + x]; } memcpy(dest, last_alpha, 16); dest += linesize; } return 0; }
{ "code": [ " if (run == 128) break;" ], "line_no": [ 33 ] }
static inline int FUNC_0(const SHQContext *VAR_0, GetBitContext *VAR_1, uint8_t VAR_2[16], uint8_t *VAR_3, int VAR_4) { uint8_t block[128]; int VAR_5 = 0, VAR_6, VAR_7; memset(block, 0, sizeof(block)); { OPEN_READER(re, VAR_1); for ( ;; ) { int VAR_8, VAR_9; UPDATE_CACHE_LE(re, VAR_1); GET_VLC(VAR_8, re, VAR_1, ff_dc_alpha_run_vlc_le.table, ALPHA_VLC_BITS, 2); if (VAR_8 == 128) break; VAR_5 += VAR_8; if (VAR_5 >= 128) return AVERROR_INVALIDDATA; UPDATE_CACHE_LE(re, VAR_1); GET_VLC(VAR_9, re, VAR_1, ff_dc_alpha_level_vlc_le.table, ALPHA_VLC_BITS, 2); block[VAR_5++] = VAR_9; } CLOSE_READER(re, VAR_1); } for (VAR_7 = 0; VAR_7 < 8; VAR_7++) { for (VAR_6 = 0; VAR_6 < 16; VAR_6++) { VAR_2[VAR_6] -= block[VAR_7 * 16 + VAR_6]; } memcpy(VAR_3, VAR_2, 16); VAR_3 += VAR_4; } return 0; }
[ "static inline int FUNC_0(const SHQContext *VAR_0, GetBitContext *VAR_1, uint8_t VAR_2[16], uint8_t *VAR_3, int VAR_4)\n{", "uint8_t block[128];", "int VAR_5 = 0, VAR_6, VAR_7;", "memset(block, 0, sizeof(block));", "{", "OPEN_READER(re, VAR_1);", "for ( ;; ) {", "int VAR_8, VAR_9;", "UPDATE_CACHE_LE(re, VAR_1);", "GET_VLC(VAR_8, re, VAR_1, ff_dc_alpha_run_vlc_le.table, ALPHA_VLC_BITS, 2);", "if (VAR_8 == 128) break;", "VAR_5 += VAR_8;", "if (VAR_5 >= 128)\nreturn AVERROR_INVALIDDATA;", "UPDATE_CACHE_LE(re, VAR_1);", "GET_VLC(VAR_9, re, VAR_1, ff_dc_alpha_level_vlc_le.table, ALPHA_VLC_BITS, 2);", "block[VAR_5++] = VAR_9;", "}", "CLOSE_READER(re, VAR_1);", "}", "for (VAR_7 = 0; VAR_7 < 8; VAR_7++) {", "for (VAR_6 = 0; VAR_6 < 16; VAR_6++) {", "VAR_2[VAR_6] -= block[VAR_7 * 16 + VAR_6];", "}", "memcpy(VAR_3, VAR_2, 16);", "VAR_3 += VAR_4;", "}", "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, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 15 ], [ 17 ], [ 21 ], [ 23 ], [ 27 ], [ 29 ], [ 33 ], [ 35 ], [ 37, 39 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 53 ], [ 55 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 75 ], [ 77 ] ]
22,133
static int dvbsub_read_4bit_string(uint8_t *destbuf, int dbuf_len, const uint8_t **srcbuf, int buf_size, int non_mod, uint8_t *map_table) { GetBitContext gb; int bits; int run_length; int pixels_read = 0; init_get_bits(&gb, *srcbuf, buf_size << 3); while (get_bits_count(&gb) < buf_size << 3 && pixels_read < dbuf_len) { bits = get_bits(&gb, 4); if (bits) { if (non_mod != 1 || bits != 1) { if (map_table) *destbuf++ = map_table[bits]; else *destbuf++ = bits; } pixels_read++; } else { bits = get_bits1(&gb); if (bits == 0) { run_length = get_bits(&gb, 3); if (run_length == 0) { (*srcbuf) += (get_bits_count(&gb) + 7) >> 3; return pixels_read; } run_length += 2; if (map_table) bits = map_table[0]; else bits = 0; while (run_length-- > 0 && pixels_read < dbuf_len) { *destbuf++ = bits; pixels_read++; } } else { bits = get_bits1(&gb); if (bits == 0) { run_length = get_bits(&gb, 2) + 4; bits = get_bits(&gb, 4); if (non_mod == 1 && bits == 1) pixels_read += run_length; else { if (map_table) bits = map_table[bits]; while (run_length-- > 0 && pixels_read < dbuf_len) { *destbuf++ = bits; pixels_read++; } } } else { bits = get_bits(&gb, 2); if (bits == 2) { run_length = get_bits(&gb, 4) + 9; bits = get_bits(&gb, 4); if (non_mod == 1 && bits == 1) pixels_read += run_length; else { if (map_table) bits = map_table[bits]; while (run_length-- > 0 && pixels_read < dbuf_len) { *destbuf++ = bits; pixels_read++; } } } else if (bits == 3) { run_length = get_bits(&gb, 8) + 25; bits = get_bits(&gb, 4); if (non_mod == 1 && bits == 1) pixels_read += run_length; else { if (map_table) bits = map_table[bits]; while (run_length-- > 0 && pixels_read < dbuf_len) { *destbuf++ = bits; pixels_read++; } } } else if (bits == 1) { pixels_read += 2; if (map_table) bits = map_table[0]; else bits = 0; if (pixels_read <= dbuf_len) { *destbuf++ = bits; *destbuf++ = bits; } } else { if (map_table) bits = map_table[0]; else bits = 0; *destbuf++ = bits; pixels_read ++; } } } } } if (get_bits(&gb, 8)) av_log(0, AV_LOG_ERROR, "DVBSub error: line overflow\n"); (*srcbuf) += (get_bits_count(&gb) + 7) >> 3; return pixels_read; }
false
FFmpeg
eea064aea610ea41b5bda0b62dac56be536af9aa
static int dvbsub_read_4bit_string(uint8_t *destbuf, int dbuf_len, const uint8_t **srcbuf, int buf_size, int non_mod, uint8_t *map_table) { GetBitContext gb; int bits; int run_length; int pixels_read = 0; init_get_bits(&gb, *srcbuf, buf_size << 3); while (get_bits_count(&gb) < buf_size << 3 && pixels_read < dbuf_len) { bits = get_bits(&gb, 4); if (bits) { if (non_mod != 1 || bits != 1) { if (map_table) *destbuf++ = map_table[bits]; else *destbuf++ = bits; } pixels_read++; } else { bits = get_bits1(&gb); if (bits == 0) { run_length = get_bits(&gb, 3); if (run_length == 0) { (*srcbuf) += (get_bits_count(&gb) + 7) >> 3; return pixels_read; } run_length += 2; if (map_table) bits = map_table[0]; else bits = 0; while (run_length-- > 0 && pixels_read < dbuf_len) { *destbuf++ = bits; pixels_read++; } } else { bits = get_bits1(&gb); if (bits == 0) { run_length = get_bits(&gb, 2) + 4; bits = get_bits(&gb, 4); if (non_mod == 1 && bits == 1) pixels_read += run_length; else { if (map_table) bits = map_table[bits]; while (run_length-- > 0 && pixels_read < dbuf_len) { *destbuf++ = bits; pixels_read++; } } } else { bits = get_bits(&gb, 2); if (bits == 2) { run_length = get_bits(&gb, 4) + 9; bits = get_bits(&gb, 4); if (non_mod == 1 && bits == 1) pixels_read += run_length; else { if (map_table) bits = map_table[bits]; while (run_length-- > 0 && pixels_read < dbuf_len) { *destbuf++ = bits; pixels_read++; } } } else if (bits == 3) { run_length = get_bits(&gb, 8) + 25; bits = get_bits(&gb, 4); if (non_mod == 1 && bits == 1) pixels_read += run_length; else { if (map_table) bits = map_table[bits]; while (run_length-- > 0 && pixels_read < dbuf_len) { *destbuf++ = bits; pixels_read++; } } } else if (bits == 1) { pixels_read += 2; if (map_table) bits = map_table[0]; else bits = 0; if (pixels_read <= dbuf_len) { *destbuf++ = bits; *destbuf++ = bits; } } else { if (map_table) bits = map_table[0]; else bits = 0; *destbuf++ = bits; pixels_read ++; } } } } } if (get_bits(&gb, 8)) av_log(0, AV_LOG_ERROR, "DVBSub error: line overflow\n"); (*srcbuf) += (get_bits_count(&gb) + 7) >> 3; return pixels_read; }
{ "code": [], "line_no": [] }
static int FUNC_0(uint8_t *VAR_0, int VAR_1, const uint8_t **VAR_2, int VAR_3, int VAR_4, uint8_t *VAR_5) { GetBitContext gb; int VAR_6; int VAR_7; int VAR_8 = 0; init_get_bits(&gb, *VAR_2, VAR_3 << 3); while (get_bits_count(&gb) < VAR_3 << 3 && VAR_8 < VAR_1) { VAR_6 = get_bits(&gb, 4); if (VAR_6) { if (VAR_4 != 1 || VAR_6 != 1) { if (VAR_5) *VAR_0++ = VAR_5[VAR_6]; else *VAR_0++ = VAR_6; } VAR_8++; } else { VAR_6 = get_bits1(&gb); if (VAR_6 == 0) { VAR_7 = get_bits(&gb, 3); if (VAR_7 == 0) { (*VAR_2) += (get_bits_count(&gb) + 7) >> 3; return VAR_8; } VAR_7 += 2; if (VAR_5) VAR_6 = VAR_5[0]; else VAR_6 = 0; while (VAR_7-- > 0 && VAR_8 < VAR_1) { *VAR_0++ = VAR_6; VAR_8++; } } else { VAR_6 = get_bits1(&gb); if (VAR_6 == 0) { VAR_7 = get_bits(&gb, 2) + 4; VAR_6 = get_bits(&gb, 4); if (VAR_4 == 1 && VAR_6 == 1) VAR_8 += VAR_7; else { if (VAR_5) VAR_6 = VAR_5[VAR_6]; while (VAR_7-- > 0 && VAR_8 < VAR_1) { *VAR_0++ = VAR_6; VAR_8++; } } } else { VAR_6 = get_bits(&gb, 2); if (VAR_6 == 2) { VAR_7 = get_bits(&gb, 4) + 9; VAR_6 = get_bits(&gb, 4); if (VAR_4 == 1 && VAR_6 == 1) VAR_8 += VAR_7; else { if (VAR_5) VAR_6 = VAR_5[VAR_6]; while (VAR_7-- > 0 && VAR_8 < VAR_1) { *VAR_0++ = VAR_6; VAR_8++; } } } else if (VAR_6 == 3) { VAR_7 = get_bits(&gb, 8) + 25; VAR_6 = get_bits(&gb, 4); if (VAR_4 == 1 && VAR_6 == 1) VAR_8 += VAR_7; else { if (VAR_5) VAR_6 = VAR_5[VAR_6]; while (VAR_7-- > 0 && VAR_8 < VAR_1) { *VAR_0++ = VAR_6; VAR_8++; } } } else if (VAR_6 == 1) { VAR_8 += 2; if (VAR_5) VAR_6 = VAR_5[0]; else VAR_6 = 0; if (VAR_8 <= VAR_1) { *VAR_0++ = VAR_6; *VAR_0++ = VAR_6; } } else { if (VAR_5) VAR_6 = VAR_5[0]; else VAR_6 = 0; *VAR_0++ = VAR_6; VAR_8 ++; } } } } } if (get_bits(&gb, 8)) av_log(0, AV_LOG_ERROR, "DVBSub error: line overflow\n"); (*VAR_2) += (get_bits_count(&gb) + 7) >> 3; return VAR_8; }
[ "static int FUNC_0(uint8_t *VAR_0, int VAR_1,\nconst uint8_t **VAR_2, int VAR_3,\nint VAR_4, uint8_t *VAR_5)\n{", "GetBitContext gb;", "int VAR_6;", "int VAR_7;", "int VAR_8 = 0;", "init_get_bits(&gb, *VAR_2, VAR_3 << 3);", "while (get_bits_count(&gb) < VAR_3 << 3 && VAR_8 < VAR_1) {", "VAR_6 = get_bits(&gb, 4);", "if (VAR_6) {", "if (VAR_4 != 1 || VAR_6 != 1) {", "if (VAR_5)\n*VAR_0++ = VAR_5[VAR_6];", "else\n*VAR_0++ = VAR_6;", "}", "VAR_8++;", "} else {", "VAR_6 = get_bits1(&gb);", "if (VAR_6 == 0) {", "VAR_7 = get_bits(&gb, 3);", "if (VAR_7 == 0) {", "(*VAR_2) += (get_bits_count(&gb) + 7) >> 3;", "return VAR_8;", "}", "VAR_7 += 2;", "if (VAR_5)\nVAR_6 = VAR_5[0];", "else\nVAR_6 = 0;", "while (VAR_7-- > 0 && VAR_8 < VAR_1) {", "*VAR_0++ = VAR_6;", "VAR_8++;", "}", "} else {", "VAR_6 = get_bits1(&gb);", "if (VAR_6 == 0) {", "VAR_7 = get_bits(&gb, 2) + 4;", "VAR_6 = get_bits(&gb, 4);", "if (VAR_4 == 1 && VAR_6 == 1)\nVAR_8 += VAR_7;", "else {", "if (VAR_5)\nVAR_6 = VAR_5[VAR_6];", "while (VAR_7-- > 0 && VAR_8 < VAR_1) {", "*VAR_0++ = VAR_6;", "VAR_8++;", "}", "}", "} else {", "VAR_6 = get_bits(&gb, 2);", "if (VAR_6 == 2) {", "VAR_7 = get_bits(&gb, 4) + 9;", "VAR_6 = get_bits(&gb, 4);", "if (VAR_4 == 1 && VAR_6 == 1)\nVAR_8 += VAR_7;", "else {", "if (VAR_5)\nVAR_6 = VAR_5[VAR_6];", "while (VAR_7-- > 0 && VAR_8 < VAR_1) {", "*VAR_0++ = VAR_6;", "VAR_8++;", "}", "}", "} else if (VAR_6 == 3) {", "VAR_7 = get_bits(&gb, 8) + 25;", "VAR_6 = get_bits(&gb, 4);", "if (VAR_4 == 1 && VAR_6 == 1)\nVAR_8 += VAR_7;", "else {", "if (VAR_5)\nVAR_6 = VAR_5[VAR_6];", "while (VAR_7-- > 0 && VAR_8 < VAR_1) {", "*VAR_0++ = VAR_6;", "VAR_8++;", "}", "}", "} else if (VAR_6 == 1) {", "VAR_8 += 2;", "if (VAR_5)\nVAR_6 = VAR_5[0];", "else\nVAR_6 = 0;", "if (VAR_8 <= VAR_1) {", "*VAR_0++ = VAR_6;", "*VAR_0++ = VAR_6;", "}", "} else {", "if (VAR_5)\nVAR_6 = VAR_5[0];", "else\nVAR_6 = 0;", "*VAR_0++ = VAR_6;", "VAR_8 ++;", "}", "}", "}", "}", "}", "if (get_bits(&gb, 8))\nav_log(0, AV_LOG_ERROR, \"DVBSub error: line overflow\\n\");", "(*VAR_2) += (get_bits_count(&gb) + 7) >> 3;", "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 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 25 ], [ 27 ], [ 31 ], [ 33 ], [ 35, 37 ], [ 39, 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 67 ], [ 71, 73 ], [ 75, 77 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 101, 103 ], [ 105 ], [ 107, 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 133, 135 ], [ 137 ], [ 139, 141 ], [ 143 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 161, 163 ], [ 165 ], [ 167, 169 ], [ 171 ], [ 173 ], [ 175 ], [ 177 ], [ 179 ], [ 181 ], [ 183 ], [ 185, 187 ], [ 189, 191 ], [ 193 ], [ 195 ], [ 197 ], [ 199 ], [ 201 ], [ 203, 205 ], [ 207, 209 ], [ 211 ], [ 213 ], [ 215 ], [ 217 ], [ 219 ], [ 221 ], [ 223 ], [ 227, 229 ], [ 233 ], [ 237 ], [ 239 ] ]
22,134
static void copy_block(uint16_t *pdest, uint16_t *psrc, int block_size, int pitch) { int y; for (y = 0; y != block_size; y++, pdest += pitch, psrc += pitch) memcpy(pdest, psrc, block_size * sizeof(pdest[0])); }
false
FFmpeg
3b9dd906d18f4cd801ceedd20d800a7e53074be9
static void copy_block(uint16_t *pdest, uint16_t *psrc, int block_size, int pitch) { int y; for (y = 0; y != block_size; y++, pdest += pitch, psrc += pitch) memcpy(pdest, psrc, block_size * sizeof(pdest[0])); }
{ "code": [], "line_no": [] }
static void FUNC_0(uint16_t *VAR_0, uint16_t *VAR_1, int VAR_2, int VAR_3) { int VAR_4; for (VAR_4 = 0; VAR_4 != VAR_2; VAR_4++, VAR_0 += VAR_3, VAR_1 += VAR_3) memcpy(VAR_0, VAR_1, VAR_2 * sizeof(VAR_0[0])); }
[ "static void FUNC_0(uint16_t *VAR_0, uint16_t *VAR_1, int VAR_2, int VAR_3)\n{", "int VAR_4;", "for (VAR_4 = 0; VAR_4 != VAR_2; VAR_4++, VAR_0 += VAR_3, VAR_1 += VAR_3)", "memcpy(VAR_0, VAR_1, VAR_2 * sizeof(VAR_0[0]));", "}" ]
[ 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ] ]
22,135
static int ffm2_read_header(AVFormatContext *s) { FFMContext *ffm = s->priv_data; AVStream *st; AVIOContext *pb = s->pb; AVCodecContext *codec, *dummy_codec = NULL; AVCodecParameters *codecpar; const AVCodecDescriptor *codec_desc; int ret; int f_main = 0, f_cprv = -1, f_stvi = -1, f_stau = -1; AVCodec *enc; char *buffer; ffm->packet_size = avio_rb32(pb); if (ffm->packet_size != FFM_PACKET_SIZE) { av_log(s, AV_LOG_ERROR, "Invalid packet size %d, expected size was %d\n", ffm->packet_size, FFM_PACKET_SIZE); ret = AVERROR_INVALIDDATA; goto fail; } ffm->write_index = avio_rb64(pb); /* get also filesize */ if (pb->seekable) { ffm->file_size = avio_size(pb); if (ffm->write_index && 0) adjust_write_index(s); } else { ffm->file_size = (UINT64_C(1) << 63) - 1; } dummy_codec = avcodec_alloc_context3(NULL); while(!avio_feof(pb)) { unsigned id = avio_rb32(pb); unsigned size = avio_rb32(pb); int64_t next = avio_tell(pb) + size; char rc_eq_buf[128]; if(!id) break; switch(id) { case MKBETAG('M', 'A', 'I', 'N'): if (f_main++) { ret = AVERROR(EINVAL); goto fail; } avio_rb32(pb); /* nb_streams */ avio_rb32(pb); /* total bitrate */ break; case MKBETAG('C', 'O', 'M', 'M'): f_cprv = f_stvi = f_stau = 0; st = avformat_new_stream(s, NULL); if (!st) { ret = AVERROR(ENOMEM); goto fail; } avpriv_set_pts_info(st, 64, 1, 1000000); codec = st->codec; codecpar = st->codecpar; /* generic info */ codecpar->codec_id = avio_rb32(pb); codec_desc = avcodec_descriptor_get(codecpar->codec_id); if (!codec_desc) { av_log(s, AV_LOG_ERROR, "Invalid codec id: %d\n", codecpar->codec_id); codecpar->codec_id = AV_CODEC_ID_NONE; ret = AVERROR_INVALIDDATA; goto fail; } codecpar->codec_type = avio_r8(pb); if (codecpar->codec_type != codec_desc->type) { av_log(s, AV_LOG_ERROR, "Codec type mismatch: expected %d, found %d\n", codec_desc->type, codecpar->codec_type); codecpar->codec_id = AV_CODEC_ID_NONE; codecpar->codec_type = AVMEDIA_TYPE_UNKNOWN; ret = AVERROR_INVALIDDATA; goto fail; } codecpar->bit_rate = avio_rb32(pb); if (codecpar->bit_rate < 0) { av_log(codec, AV_LOG_ERROR, "Invalid bit rate %"PRId64"\n", codecpar->bit_rate); ret = AVERROR_INVALIDDATA; goto fail; } codec->flags = avio_rb32(pb); codec->flags2 = avio_rb32(pb); codec->debug = avio_rb32(pb); if (codec->flags & AV_CODEC_FLAG_GLOBAL_HEADER) { int size = avio_rb32(pb); if (size < 0 || size >= FF_MAX_EXTRADATA_SIZE) { av_log(s, AV_LOG_ERROR, "Invalid extradata size %d\n", size); ret = AVERROR_INVALIDDATA; goto fail; } codecpar->extradata = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE); if (!codecpar->extradata) return AVERROR(ENOMEM); codecpar->extradata_size = size; avio_read(pb, codecpar->extradata, size); } break; case MKBETAG('S', 'T', 'V', 'I'): if (f_stvi++) { ret = AVERROR(EINVAL); goto fail; } codec->time_base.num = avio_rb32(pb); codec->time_base.den = avio_rb32(pb); if (codec->time_base.num <= 0 || codec->time_base.den <= 0) { av_log(s, AV_LOG_ERROR, "Invalid time base %d/%d\n", codec->time_base.num, codec->time_base.den); ret = AVERROR_INVALIDDATA; goto fail; } codecpar->width = avio_rb16(pb); codecpar->height = avio_rb16(pb); ret = av_image_check_size(codecpar->width, codecpar->height, 0, s); if (ret < 0) goto fail; avio_rb16(pb); // gop_size codecpar->format = avio_rb32(pb); if (!av_pix_fmt_desc_get(codecpar->format)) { av_log(s, AV_LOG_ERROR, "Invalid pix fmt id: %d\n", codecpar->format); codecpar->format = AV_PIX_FMT_NONE; goto fail; } avio_r8(pb); // qmin avio_r8(pb); // qmax avio_r8(pb); // max_qdiff avio_rb16(pb); // qcompress / 10000.0 avio_rb16(pb); // qblur / 10000.0 avio_rb32(pb); // bit_rate_tolerance avio_get_str(pb, INT_MAX, rc_eq_buf, sizeof(rc_eq_buf)); avio_rb32(pb); // rc_max_rate avio_rb32(pb); // rc_min_rate avio_rb32(pb); // rc_buffer_size avio_rb64(pb); // i_quant_factor avio_rb64(pb); // b_quant_factor avio_rb64(pb); // i_quant_offset avio_rb64(pb); // b_quant_offset avio_rb32(pb); // dct_algo avio_rb32(pb); // strict_std_compliance avio_rb32(pb); // max_b_frames avio_rb32(pb); // mpeg_quant avio_rb32(pb); // intra_dc_precision avio_rb32(pb); // me_method avio_rb32(pb); // mb_decision avio_rb32(pb); // nsse_weight avio_rb32(pb); // frame_skip_cmp avio_rb64(pb); // rc_buffer_aggressivity codecpar->codec_tag = avio_rb32(pb); avio_r8(pb); // thread_count avio_rb32(pb); // coder_type avio_rb32(pb); // me_cmp avio_rb32(pb); // me_subpel_quality avio_rb32(pb); // me_range avio_rb32(pb); // keyint_min avio_rb32(pb); // scenechange_threshold avio_rb32(pb); // b_frame_strategy avio_rb64(pb); // qcompress avio_rb64(pb); // qblur avio_rb32(pb); // max_qdiff avio_rb32(pb); // refs break; case MKBETAG('S', 'T', 'A', 'U'): if (f_stau++) { ret = AVERROR(EINVAL); goto fail; } codecpar->sample_rate = avio_rb32(pb); VALIDATE_PARAMETER(sample_rate, "sample rate", codecpar->sample_rate < 0) codecpar->channels = avio_rl16(pb); VALIDATE_PARAMETER(channels, "number of channels", codecpar->channels < 0) codecpar->frame_size = avio_rl16(pb); VALIDATE_PARAMETER(frame_size, "frame size", codecpar->frame_size < 0) break; case MKBETAG('C', 'P', 'R', 'V'): if (f_cprv++) { ret = AVERROR(EINVAL); goto fail; } enc = avcodec_find_encoder(codecpar->codec_id); if (enc && enc->priv_data_size && enc->priv_class) { buffer = av_malloc(size + 1); if (!buffer) { ret = AVERROR(ENOMEM); goto fail; } avio_get_str(pb, size, buffer, size + 1); if ((ret = ffm_append_recommended_configuration(st, &buffer)) < 0) goto fail; } break; case MKBETAG('S', '2', 'V', 'I'): if (f_stvi++ || !size) { ret = AVERROR(EINVAL); goto fail; } buffer = av_malloc(size); if (!buffer) { ret = AVERROR(ENOMEM); goto fail; } avio_get_str(pb, INT_MAX, buffer, size); // The lack of AVOptions support in AVCodecParameters makes this back and forth copying needed avcodec_parameters_to_context(dummy_codec, codecpar); av_set_options_string(dummy_codec, buffer, "=", ","); avcodec_parameters_from_context(codecpar, dummy_codec); if ((ret = ffm_append_recommended_configuration(st, &buffer)) < 0) goto fail; break; case MKBETAG('S', '2', 'A', 'U'): if (f_stau++ || !size) { ret = AVERROR(EINVAL); goto fail; } buffer = av_malloc(size); if (!buffer) { ret = AVERROR(ENOMEM); goto fail; } avio_get_str(pb, INT_MAX, buffer, size); // The lack of AVOptions support in AVCodecParameters makes this back and forth copying needed avcodec_parameters_to_context(dummy_codec, codecpar); av_set_options_string(dummy_codec, buffer, "=", ","); avcodec_parameters_from_context(codecpar, dummy_codec); if ((ret = ffm_append_recommended_configuration(st, &buffer)) < 0) goto fail; break; } avio_seek(pb, next, SEEK_SET); } /* get until end of block reached */ while ((avio_tell(pb) % ffm->packet_size) != 0 && !pb->eof_reached) avio_r8(pb); /* init packet demux */ ffm->packet_ptr = ffm->packet; ffm->packet_end = ffm->packet; ffm->frame_offset = 0; ffm->dts = 0; ffm->read_state = READ_HEADER; ffm->first_packet = 1; avcodec_free_context(&dummy_codec); return 0; fail: avcodec_free_context(&dummy_codec); return ret; }
false
FFmpeg
e706e2e775730db5dfa9103628cd70704dd13cef
static int ffm2_read_header(AVFormatContext *s) { FFMContext *ffm = s->priv_data; AVStream *st; AVIOContext *pb = s->pb; AVCodecContext *codec, *dummy_codec = NULL; AVCodecParameters *codecpar; const AVCodecDescriptor *codec_desc; int ret; int f_main = 0, f_cprv = -1, f_stvi = -1, f_stau = -1; AVCodec *enc; char *buffer; ffm->packet_size = avio_rb32(pb); if (ffm->packet_size != FFM_PACKET_SIZE) { av_log(s, AV_LOG_ERROR, "Invalid packet size %d, expected size was %d\n", ffm->packet_size, FFM_PACKET_SIZE); ret = AVERROR_INVALIDDATA; goto fail; } ffm->write_index = avio_rb64(pb); if (pb->seekable) { ffm->file_size = avio_size(pb); if (ffm->write_index && 0) adjust_write_index(s); } else { ffm->file_size = (UINT64_C(1) << 63) - 1; } dummy_codec = avcodec_alloc_context3(NULL); while(!avio_feof(pb)) { unsigned id = avio_rb32(pb); unsigned size = avio_rb32(pb); int64_t next = avio_tell(pb) + size; char rc_eq_buf[128]; if(!id) break; switch(id) { case MKBETAG('M', 'A', 'I', 'N'): if (f_main++) { ret = AVERROR(EINVAL); goto fail; } avio_rb32(pb); avio_rb32(pb); break; case MKBETAG('C', 'O', 'M', 'M'): f_cprv = f_stvi = f_stau = 0; st = avformat_new_stream(s, NULL); if (!st) { ret = AVERROR(ENOMEM); goto fail; } avpriv_set_pts_info(st, 64, 1, 1000000); codec = st->codec; codecpar = st->codecpar; codecpar->codec_id = avio_rb32(pb); codec_desc = avcodec_descriptor_get(codecpar->codec_id); if (!codec_desc) { av_log(s, AV_LOG_ERROR, "Invalid codec id: %d\n", codecpar->codec_id); codecpar->codec_id = AV_CODEC_ID_NONE; ret = AVERROR_INVALIDDATA; goto fail; } codecpar->codec_type = avio_r8(pb); if (codecpar->codec_type != codec_desc->type) { av_log(s, AV_LOG_ERROR, "Codec type mismatch: expected %d, found %d\n", codec_desc->type, codecpar->codec_type); codecpar->codec_id = AV_CODEC_ID_NONE; codecpar->codec_type = AVMEDIA_TYPE_UNKNOWN; ret = AVERROR_INVALIDDATA; goto fail; } codecpar->bit_rate = avio_rb32(pb); if (codecpar->bit_rate < 0) { av_log(codec, AV_LOG_ERROR, "Invalid bit rate %"PRId64"\n", codecpar->bit_rate); ret = AVERROR_INVALIDDATA; goto fail; } codec->flags = avio_rb32(pb); codec->flags2 = avio_rb32(pb); codec->debug = avio_rb32(pb); if (codec->flags & AV_CODEC_FLAG_GLOBAL_HEADER) { int size = avio_rb32(pb); if (size < 0 || size >= FF_MAX_EXTRADATA_SIZE) { av_log(s, AV_LOG_ERROR, "Invalid extradata size %d\n", size); ret = AVERROR_INVALIDDATA; goto fail; } codecpar->extradata = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE); if (!codecpar->extradata) return AVERROR(ENOMEM); codecpar->extradata_size = size; avio_read(pb, codecpar->extradata, size); } break; case MKBETAG('S', 'T', 'V', 'I'): if (f_stvi++) { ret = AVERROR(EINVAL); goto fail; } codec->time_base.num = avio_rb32(pb); codec->time_base.den = avio_rb32(pb); if (codec->time_base.num <= 0 || codec->time_base.den <= 0) { av_log(s, AV_LOG_ERROR, "Invalid time base %d/%d\n", codec->time_base.num, codec->time_base.den); ret = AVERROR_INVALIDDATA; goto fail; } codecpar->width = avio_rb16(pb); codecpar->height = avio_rb16(pb); ret = av_image_check_size(codecpar->width, codecpar->height, 0, s); if (ret < 0) goto fail; avio_rb16(pb); codecpar->format = avio_rb32(pb); if (!av_pix_fmt_desc_get(codecpar->format)) { av_log(s, AV_LOG_ERROR, "Invalid pix fmt id: %d\n", codecpar->format); codecpar->format = AV_PIX_FMT_NONE; goto fail; } avio_r8(pb); avio_r8(pb); avio_r8(pb); avio_rb16(pb); avio_rb16(pb); avio_rb32(pb); avio_get_str(pb, INT_MAX, rc_eq_buf, sizeof(rc_eq_buf)); avio_rb32(pb); avio_rb32(pb); avio_rb32(pb); avio_rb64(pb); avio_rb64(pb); avio_rb64(pb); avio_rb64(pb); avio_rb32(pb); avio_rb32(pb); avio_rb32(pb); avio_rb32(pb); avio_rb32(pb); avio_rb32(pb); avio_rb32(pb); avio_rb32(pb); avio_rb32(pb); avio_rb64(pb); codecpar->codec_tag = avio_rb32(pb); avio_r8(pb); avio_rb32(pb); avio_rb32(pb); avio_rb32(pb); avio_rb32(pb); avio_rb32(pb); avio_rb32(pb); avio_rb32(pb); avio_rb64(pb); avio_rb64(pb); avio_rb32(pb); avio_rb32(pb); break; case MKBETAG('S', 'T', 'A', 'U'): if (f_stau++) { ret = AVERROR(EINVAL); goto fail; } codecpar->sample_rate = avio_rb32(pb); VALIDATE_PARAMETER(sample_rate, "sample rate", codecpar->sample_rate < 0) codecpar->channels = avio_rl16(pb); VALIDATE_PARAMETER(channels, "number of channels", codecpar->channels < 0) codecpar->frame_size = avio_rl16(pb); VALIDATE_PARAMETER(frame_size, "frame size", codecpar->frame_size < 0) break; case MKBETAG('C', 'P', 'R', 'V'): if (f_cprv++) { ret = AVERROR(EINVAL); goto fail; } enc = avcodec_find_encoder(codecpar->codec_id); if (enc && enc->priv_data_size && enc->priv_class) { buffer = av_malloc(size + 1); if (!buffer) { ret = AVERROR(ENOMEM); goto fail; } avio_get_str(pb, size, buffer, size + 1); if ((ret = ffm_append_recommended_configuration(st, &buffer)) < 0) goto fail; } break; case MKBETAG('S', '2', 'V', 'I'): if (f_stvi++ || !size) { ret = AVERROR(EINVAL); goto fail; } buffer = av_malloc(size); if (!buffer) { ret = AVERROR(ENOMEM); goto fail; } avio_get_str(pb, INT_MAX, buffer, size); avcodec_parameters_to_context(dummy_codec, codecpar); av_set_options_string(dummy_codec, buffer, "=", ","); avcodec_parameters_from_context(codecpar, dummy_codec); if ((ret = ffm_append_recommended_configuration(st, &buffer)) < 0) goto fail; break; case MKBETAG('S', '2', 'A', 'U'): if (f_stau++ || !size) { ret = AVERROR(EINVAL); goto fail; } buffer = av_malloc(size); if (!buffer) { ret = AVERROR(ENOMEM); goto fail; } avio_get_str(pb, INT_MAX, buffer, size); avcodec_parameters_to_context(dummy_codec, codecpar); av_set_options_string(dummy_codec, buffer, "=", ","); avcodec_parameters_from_context(codecpar, dummy_codec); if ((ret = ffm_append_recommended_configuration(st, &buffer)) < 0) goto fail; break; } avio_seek(pb, next, SEEK_SET); } while ((avio_tell(pb) % ffm->packet_size) != 0 && !pb->eof_reached) avio_r8(pb); ffm->packet_ptr = ffm->packet; ffm->packet_end = ffm->packet; ffm->frame_offset = 0; ffm->dts = 0; ffm->read_state = READ_HEADER; ffm->first_packet = 1; avcodec_free_context(&dummy_codec); return 0; fail: avcodec_free_context(&dummy_codec); return ret; }
{ "code": [], "line_no": [] }
static int FUNC_0(AVFormatContext *VAR_0) { FFMContext *ffm = VAR_0->priv_data; AVStream *st; AVIOContext *pb = VAR_0->pb; AVCodecContext *codec, *dummy_codec = NULL; AVCodecParameters *codecpar; const AVCodecDescriptor *VAR_1; int VAR_2; int VAR_3 = 0, VAR_4 = -1, VAR_5 = -1, VAR_6 = -1; AVCodec *enc; char *VAR_7; ffm->packet_size = avio_rb32(pb); if (ffm->packet_size != FFM_PACKET_SIZE) { av_log(VAR_0, AV_LOG_ERROR, "Invalid packet VAR_11 %d, expected VAR_11 was %d\n", ffm->packet_size, FFM_PACKET_SIZE); VAR_2 = AVERROR_INVALIDDATA; goto fail; } ffm->write_index = avio_rb64(pb); if (pb->seekable) { ffm->file_size = avio_size(pb); if (ffm->write_index && 0) adjust_write_index(VAR_0); } else { ffm->file_size = (UINT64_C(1) << 63) - 1; } dummy_codec = avcodec_alloc_context3(NULL); while(!avio_feof(pb)) { unsigned VAR_8 = avio_rb32(pb); unsigned VAR_11 = avio_rb32(pb); int64_t next = avio_tell(pb) + VAR_11; char VAR_10[128]; if(!VAR_8) break; switch(VAR_8) { case MKBETAG('M', 'A', 'I', 'N'): if (VAR_3++) { VAR_2 = AVERROR(EINVAL); goto fail; } avio_rb32(pb); avio_rb32(pb); break; case MKBETAG('C', 'O', 'M', 'M'): VAR_4 = VAR_5 = VAR_6 = 0; st = avformat_new_stream(VAR_0, NULL); if (!st) { VAR_2 = AVERROR(ENOMEM); goto fail; } avpriv_set_pts_info(st, 64, 1, 1000000); codec = st->codec; codecpar = st->codecpar; codecpar->codec_id = avio_rb32(pb); VAR_1 = avcodec_descriptor_get(codecpar->codec_id); if (!VAR_1) { av_log(VAR_0, AV_LOG_ERROR, "Invalid codec VAR_8: %d\n", codecpar->codec_id); codecpar->codec_id = AV_CODEC_ID_NONE; VAR_2 = AVERROR_INVALIDDATA; goto fail; } codecpar->codec_type = avio_r8(pb); if (codecpar->codec_type != VAR_1->type) { av_log(VAR_0, AV_LOG_ERROR, "Codec type mismatch: expected %d, found %d\n", VAR_1->type, codecpar->codec_type); codecpar->codec_id = AV_CODEC_ID_NONE; codecpar->codec_type = AVMEDIA_TYPE_UNKNOWN; VAR_2 = AVERROR_INVALIDDATA; goto fail; } codecpar->bit_rate = avio_rb32(pb); if (codecpar->bit_rate < 0) { av_log(codec, AV_LOG_ERROR, "Invalid bit rate %"PRId64"\n", codecpar->bit_rate); VAR_2 = AVERROR_INVALIDDATA; goto fail; } codec->flags = avio_rb32(pb); codec->flags2 = avio_rb32(pb); codec->debug = avio_rb32(pb); if (codec->flags & AV_CODEC_FLAG_GLOBAL_HEADER) { int VAR_11 = avio_rb32(pb); if (VAR_11 < 0 || VAR_11 >= FF_MAX_EXTRADATA_SIZE) { av_log(VAR_0, AV_LOG_ERROR, "Invalid extradata VAR_11 %d\n", VAR_11); VAR_2 = AVERROR_INVALIDDATA; goto fail; } codecpar->extradata = av_mallocz(VAR_11 + AV_INPUT_BUFFER_PADDING_SIZE); if (!codecpar->extradata) return AVERROR(ENOMEM); codecpar->extradata_size = VAR_11; avio_read(pb, codecpar->extradata, VAR_11); } break; case MKBETAG('S', 'T', 'V', 'I'): if (VAR_5++) { VAR_2 = AVERROR(EINVAL); goto fail; } codec->time_base.num = avio_rb32(pb); codec->time_base.den = avio_rb32(pb); if (codec->time_base.num <= 0 || codec->time_base.den <= 0) { av_log(VAR_0, AV_LOG_ERROR, "Invalid time base %d/%d\n", codec->time_base.num, codec->time_base.den); VAR_2 = AVERROR_INVALIDDATA; goto fail; } codecpar->width = avio_rb16(pb); codecpar->height = avio_rb16(pb); VAR_2 = av_image_check_size(codecpar->width, codecpar->height, 0, VAR_0); if (VAR_2 < 0) goto fail; avio_rb16(pb); codecpar->format = avio_rb32(pb); if (!av_pix_fmt_desc_get(codecpar->format)) { av_log(VAR_0, AV_LOG_ERROR, "Invalid pix fmt VAR_8: %d\n", codecpar->format); codecpar->format = AV_PIX_FMT_NONE; goto fail; } avio_r8(pb); avio_r8(pb); avio_r8(pb); avio_rb16(pb); avio_rb16(pb); avio_rb32(pb); avio_get_str(pb, INT_MAX, VAR_10, sizeof(VAR_10)); avio_rb32(pb); avio_rb32(pb); avio_rb32(pb); avio_rb64(pb); avio_rb64(pb); avio_rb64(pb); avio_rb64(pb); avio_rb32(pb); avio_rb32(pb); avio_rb32(pb); avio_rb32(pb); avio_rb32(pb); avio_rb32(pb); avio_rb32(pb); avio_rb32(pb); avio_rb32(pb); avio_rb64(pb); codecpar->codec_tag = avio_rb32(pb); avio_r8(pb); avio_rb32(pb); avio_rb32(pb); avio_rb32(pb); avio_rb32(pb); avio_rb32(pb); avio_rb32(pb); avio_rb32(pb); avio_rb64(pb); avio_rb64(pb); avio_rb32(pb); avio_rb32(pb); break; case MKBETAG('S', 'T', 'A', 'U'): if (VAR_6++) { VAR_2 = AVERROR(EINVAL); goto fail; } codecpar->sample_rate = avio_rb32(pb); VALIDATE_PARAMETER(sample_rate, "sample rate", codecpar->sample_rate < 0) codecpar->channels = avio_rl16(pb); VALIDATE_PARAMETER(channels, "number of channels", codecpar->channels < 0) codecpar->frame_size = avio_rl16(pb); VALIDATE_PARAMETER(frame_size, "frame VAR_11", codecpar->frame_size < 0) break; case MKBETAG('C', 'P', 'R', 'V'): if (VAR_4++) { VAR_2 = AVERROR(EINVAL); goto fail; } enc = avcodec_find_encoder(codecpar->codec_id); if (enc && enc->priv_data_size && enc->priv_class) { VAR_7 = av_malloc(VAR_11 + 1); if (!VAR_7) { VAR_2 = AVERROR(ENOMEM); goto fail; } avio_get_str(pb, VAR_11, VAR_7, VAR_11 + 1); if ((VAR_2 = ffm_append_recommended_configuration(st, &VAR_7)) < 0) goto fail; } break; case MKBETAG('S', '2', 'V', 'I'): if (VAR_5++ || !VAR_11) { VAR_2 = AVERROR(EINVAL); goto fail; } VAR_7 = av_malloc(VAR_11); if (!VAR_7) { VAR_2 = AVERROR(ENOMEM); goto fail; } avio_get_str(pb, INT_MAX, VAR_7, VAR_11); avcodec_parameters_to_context(dummy_codec, codecpar); av_set_options_string(dummy_codec, VAR_7, "=", ","); avcodec_parameters_from_context(codecpar, dummy_codec); if ((VAR_2 = ffm_append_recommended_configuration(st, &VAR_7)) < 0) goto fail; break; case MKBETAG('S', '2', 'A', 'U'): if (VAR_6++ || !VAR_11) { VAR_2 = AVERROR(EINVAL); goto fail; } VAR_7 = av_malloc(VAR_11); if (!VAR_7) { VAR_2 = AVERROR(ENOMEM); goto fail; } avio_get_str(pb, INT_MAX, VAR_7, VAR_11); avcodec_parameters_to_context(dummy_codec, codecpar); av_set_options_string(dummy_codec, VAR_7, "=", ","); avcodec_parameters_from_context(codecpar, dummy_codec); if ((VAR_2 = ffm_append_recommended_configuration(st, &VAR_7)) < 0) goto fail; break; } avio_seek(pb, next, SEEK_SET); } while ((avio_tell(pb) % ffm->packet_size) != 0 && !pb->eof_reached) avio_r8(pb); ffm->packet_ptr = ffm->packet; ffm->packet_end = ffm->packet; ffm->frame_offset = 0; ffm->dts = 0; ffm->read_state = READ_HEADER; ffm->first_packet = 1; avcodec_free_context(&dummy_codec); return 0; fail: avcodec_free_context(&dummy_codec); return VAR_2; }
[ "static int FUNC_0(AVFormatContext *VAR_0)\n{", "FFMContext *ffm = VAR_0->priv_data;", "AVStream *st;", "AVIOContext *pb = VAR_0->pb;", "AVCodecContext *codec, *dummy_codec = NULL;", "AVCodecParameters *codecpar;", "const AVCodecDescriptor *VAR_1;", "int VAR_2;", "int VAR_3 = 0, VAR_4 = -1, VAR_5 = -1, VAR_6 = -1;", "AVCodec *enc;", "char *VAR_7;", "ffm->packet_size = avio_rb32(pb);", "if (ffm->packet_size != FFM_PACKET_SIZE) {", "av_log(VAR_0, AV_LOG_ERROR, \"Invalid packet VAR_11 %d, expected VAR_11 was %d\\n\",\nffm->packet_size, FFM_PACKET_SIZE);", "VAR_2 = AVERROR_INVALIDDATA;", "goto fail;", "}", "ffm->write_index = avio_rb64(pb);", "if (pb->seekable) {", "ffm->file_size = avio_size(pb);", "if (ffm->write_index && 0)\nadjust_write_index(VAR_0);", "} else {", "ffm->file_size = (UINT64_C(1) << 63) - 1;", "}", "dummy_codec = avcodec_alloc_context3(NULL);", "while(!avio_feof(pb)) {", "unsigned VAR_8 = avio_rb32(pb);", "unsigned VAR_11 = avio_rb32(pb);", "int64_t next = avio_tell(pb) + VAR_11;", "char VAR_10[128];", "if(!VAR_8)\nbreak;", "switch(VAR_8) {", "case MKBETAG('M', 'A', 'I', 'N'):\nif (VAR_3++) {", "VAR_2 = AVERROR(EINVAL);", "goto fail;", "}", "avio_rb32(pb);", "avio_rb32(pb);", "break;", "case MKBETAG('C', 'O', 'M', 'M'):\nVAR_4 = VAR_5 = VAR_6 = 0;", "st = avformat_new_stream(VAR_0, NULL);", "if (!st) {", "VAR_2 = AVERROR(ENOMEM);", "goto fail;", "}", "avpriv_set_pts_info(st, 64, 1, 1000000);", "codec = st->codec;", "codecpar = st->codecpar;", "codecpar->codec_id = avio_rb32(pb);", "VAR_1 = avcodec_descriptor_get(codecpar->codec_id);", "if (!VAR_1) {", "av_log(VAR_0, AV_LOG_ERROR, \"Invalid codec VAR_8: %d\\n\", codecpar->codec_id);", "codecpar->codec_id = AV_CODEC_ID_NONE;", "VAR_2 = AVERROR_INVALIDDATA;", "goto fail;", "}", "codecpar->codec_type = avio_r8(pb);", "if (codecpar->codec_type != VAR_1->type) {", "av_log(VAR_0, AV_LOG_ERROR, \"Codec type mismatch: expected %d, found %d\\n\",\nVAR_1->type, codecpar->codec_type);", "codecpar->codec_id = AV_CODEC_ID_NONE;", "codecpar->codec_type = AVMEDIA_TYPE_UNKNOWN;", "VAR_2 = AVERROR_INVALIDDATA;", "goto fail;", "}", "codecpar->bit_rate = avio_rb32(pb);", "if (codecpar->bit_rate < 0) {", "av_log(codec, AV_LOG_ERROR, \"Invalid bit rate %\"PRId64\"\\n\", codecpar->bit_rate);", "VAR_2 = AVERROR_INVALIDDATA;", "goto fail;", "}", "codec->flags = avio_rb32(pb);", "codec->flags2 = avio_rb32(pb);", "codec->debug = avio_rb32(pb);", "if (codec->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {", "int VAR_11 = avio_rb32(pb);", "if (VAR_11 < 0 || VAR_11 >= FF_MAX_EXTRADATA_SIZE) {", "av_log(VAR_0, AV_LOG_ERROR, \"Invalid extradata VAR_11 %d\\n\", VAR_11);", "VAR_2 = AVERROR_INVALIDDATA;", "goto fail;", "}", "codecpar->extradata = av_mallocz(VAR_11 + AV_INPUT_BUFFER_PADDING_SIZE);", "if (!codecpar->extradata)\nreturn AVERROR(ENOMEM);", "codecpar->extradata_size = VAR_11;", "avio_read(pb, codecpar->extradata, VAR_11);", "}", "break;", "case MKBETAG('S', 'T', 'V', 'I'):\nif (VAR_5++) {", "VAR_2 = AVERROR(EINVAL);", "goto fail;", "}", "codec->time_base.num = avio_rb32(pb);", "codec->time_base.den = avio_rb32(pb);", "if (codec->time_base.num <= 0 || codec->time_base.den <= 0) {", "av_log(VAR_0, AV_LOG_ERROR, \"Invalid time base %d/%d\\n\",\ncodec->time_base.num, codec->time_base.den);", "VAR_2 = AVERROR_INVALIDDATA;", "goto fail;", "}", "codecpar->width = avio_rb16(pb);", "codecpar->height = avio_rb16(pb);", "VAR_2 = av_image_check_size(codecpar->width, codecpar->height, 0, VAR_0);", "if (VAR_2 < 0)\ngoto fail;", "avio_rb16(pb);", "codecpar->format = avio_rb32(pb);", "if (!av_pix_fmt_desc_get(codecpar->format)) {", "av_log(VAR_0, AV_LOG_ERROR, \"Invalid pix fmt VAR_8: %d\\n\", codecpar->format);", "codecpar->format = AV_PIX_FMT_NONE;", "goto fail;", "}", "avio_r8(pb);", "avio_r8(pb);", "avio_r8(pb);", "avio_rb16(pb);", "avio_rb16(pb);", "avio_rb32(pb);", "avio_get_str(pb, INT_MAX, VAR_10, sizeof(VAR_10));", "avio_rb32(pb);", "avio_rb32(pb);", "avio_rb32(pb);", "avio_rb64(pb);", "avio_rb64(pb);", "avio_rb64(pb);", "avio_rb64(pb);", "avio_rb32(pb);", "avio_rb32(pb);", "avio_rb32(pb);", "avio_rb32(pb);", "avio_rb32(pb);", "avio_rb32(pb);", "avio_rb32(pb);", "avio_rb32(pb);", "avio_rb32(pb);", "avio_rb64(pb);", "codecpar->codec_tag = avio_rb32(pb);", "avio_r8(pb);", "avio_rb32(pb);", "avio_rb32(pb);", "avio_rb32(pb);", "avio_rb32(pb);", "avio_rb32(pb);", "avio_rb32(pb);", "avio_rb32(pb);", "avio_rb64(pb);", "avio_rb64(pb);", "avio_rb32(pb);", "avio_rb32(pb);", "break;", "case MKBETAG('S', 'T', 'A', 'U'):\nif (VAR_6++) {", "VAR_2 = AVERROR(EINVAL);", "goto fail;", "}", "codecpar->sample_rate = avio_rb32(pb);", "VALIDATE_PARAMETER(sample_rate, \"sample rate\", codecpar->sample_rate < 0)\ncodecpar->channels = avio_rl16(pb);", "VALIDATE_PARAMETER(channels, \"number of channels\", codecpar->channels < 0)\ncodecpar->frame_size = avio_rl16(pb);", "VALIDATE_PARAMETER(frame_size, \"frame VAR_11\", codecpar->frame_size < 0)\nbreak;", "case MKBETAG('C', 'P', 'R', 'V'):\nif (VAR_4++) {", "VAR_2 = AVERROR(EINVAL);", "goto fail;", "}", "enc = avcodec_find_encoder(codecpar->codec_id);", "if (enc && enc->priv_data_size && enc->priv_class) {", "VAR_7 = av_malloc(VAR_11 + 1);", "if (!VAR_7) {", "VAR_2 = AVERROR(ENOMEM);", "goto fail;", "}", "avio_get_str(pb, VAR_11, VAR_7, VAR_11 + 1);", "if ((VAR_2 = ffm_append_recommended_configuration(st, &VAR_7)) < 0)\ngoto fail;", "}", "break;", "case MKBETAG('S', '2', 'V', 'I'):\nif (VAR_5++ || !VAR_11) {", "VAR_2 = AVERROR(EINVAL);", "goto fail;", "}", "VAR_7 = av_malloc(VAR_11);", "if (!VAR_7) {", "VAR_2 = AVERROR(ENOMEM);", "goto fail;", "}", "avio_get_str(pb, INT_MAX, VAR_7, VAR_11);", "avcodec_parameters_to_context(dummy_codec, codecpar);", "av_set_options_string(dummy_codec, VAR_7, \"=\", \",\");", "avcodec_parameters_from_context(codecpar, dummy_codec);", "if ((VAR_2 = ffm_append_recommended_configuration(st, &VAR_7)) < 0)\ngoto fail;", "break;", "case MKBETAG('S', '2', 'A', 'U'):\nif (VAR_6++ || !VAR_11) {", "VAR_2 = AVERROR(EINVAL);", "goto fail;", "}", "VAR_7 = av_malloc(VAR_11);", "if (!VAR_7) {", "VAR_2 = AVERROR(ENOMEM);", "goto fail;", "}", "avio_get_str(pb, INT_MAX, VAR_7, VAR_11);", "avcodec_parameters_to_context(dummy_codec, codecpar);", "av_set_options_string(dummy_codec, VAR_7, \"=\", \",\");", "avcodec_parameters_from_context(codecpar, dummy_codec);", "if ((VAR_2 = ffm_append_recommended_configuration(st, &VAR_7)) < 0)\ngoto fail;", "break;", "}", "avio_seek(pb, next, SEEK_SET);", "}", "while ((avio_tell(pb) % ffm->packet_size) != 0 && !pb->eof_reached)\navio_r8(pb);", "ffm->packet_ptr = ffm->packet;", "ffm->packet_end = ffm->packet;", "ffm->frame_offset = 0;", "ffm->dts = 0;", "ffm->read_state = READ_HEADER;", "ffm->first_packet = 1;", "avcodec_free_context(&dummy_codec);", "return 0;", "fail:\navcodec_free_context(&dummy_codec);", "return VAR_2;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 27 ], [ 29 ], [ 31, 33 ], [ 35 ], [ 37 ], [ 39 ], [ 43 ], [ 47 ], [ 49 ], [ 51, 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 77, 79 ], [ 83 ], [ 85, 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101, 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 117 ], [ 121 ], [ 123 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147, 149 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 175 ], [ 177 ], [ 179 ], [ 181 ], [ 183 ], [ 185 ], [ 187 ], [ 189 ], [ 191 ], [ 193 ], [ 195, 197 ], [ 199 ], [ 201 ], [ 203 ], [ 205 ], [ 207, 209 ], [ 211 ], [ 213 ], [ 215 ], [ 217 ], [ 219 ], [ 221 ], [ 223, 225 ], [ 227 ], [ 229 ], [ 231 ], [ 233 ], [ 235 ], [ 237 ], [ 239, 241 ], [ 243 ], [ 245 ], [ 247 ], [ 249 ], [ 251 ], [ 253 ], [ 255 ], [ 257 ], [ 259 ], [ 261 ], [ 263 ], [ 265 ], [ 267 ], [ 269 ], [ 273 ], [ 275 ], [ 277 ], [ 279 ], [ 281 ], [ 283 ], [ 285 ], [ 287 ], [ 289 ], [ 291 ], [ 293 ], [ 295 ], [ 297 ], [ 299 ], [ 301 ], [ 303 ], [ 305 ], [ 307 ], [ 309 ], [ 311 ], [ 313 ], [ 315 ], [ 317 ], [ 319 ], [ 321 ], [ 323 ], [ 325 ], [ 327 ], [ 329 ], [ 331 ], [ 333 ], [ 335, 337 ], [ 339 ], [ 341 ], [ 343 ], [ 345 ], [ 347, 349 ], [ 351, 353 ], [ 355, 357 ], [ 359, 361 ], [ 363 ], [ 365 ], [ 367 ], [ 369 ], [ 371 ], [ 373 ], [ 375 ], [ 377 ], [ 379 ], [ 381 ], [ 383 ], [ 385, 387 ], [ 389 ], [ 391 ], [ 393, 395 ], [ 397 ], [ 399 ], [ 401 ], [ 403 ], [ 405 ], [ 407 ], [ 409 ], [ 411 ], [ 413 ], [ 417 ], [ 419 ], [ 421 ], [ 423, 425 ], [ 427 ], [ 429, 431 ], [ 433 ], [ 435 ], [ 437 ], [ 439 ], [ 441 ], [ 443 ], [ 445 ], [ 447 ], [ 449 ], [ 453 ], [ 455 ], [ 457 ], [ 459, 461 ], [ 463 ], [ 465 ], [ 467 ], [ 469 ], [ 475, 477 ], [ 483 ], [ 485 ], [ 487 ], [ 489 ], [ 491 ], [ 493 ], [ 495 ], [ 497 ], [ 499, 501 ], [ 503 ], [ 505 ] ]
22,136
static double get_audio_clock(VideoState *is) { double pts; int hw_buf_size, bytes_per_sec; pts = is->audio_clock; hw_buf_size = audio_write_get_buf_size(is); bytes_per_sec = 0; if (is->audio_st) { bytes_per_sec = is->audio_st->codec->sample_rate * 2 * is->audio_st->codec->channels; } if (bytes_per_sec) pts -= (double)hw_buf_size / bytes_per_sec; return pts; }
false
FFmpeg
f1ffb01ee9fd3a15c395c3cf6ff362ac5cd668d0
static double get_audio_clock(VideoState *is) { double pts; int hw_buf_size, bytes_per_sec; pts = is->audio_clock; hw_buf_size = audio_write_get_buf_size(is); bytes_per_sec = 0; if (is->audio_st) { bytes_per_sec = is->audio_st->codec->sample_rate * 2 * is->audio_st->codec->channels; } if (bytes_per_sec) pts -= (double)hw_buf_size / bytes_per_sec; return pts; }
{ "code": [], "line_no": [] }
static double FUNC_0(VideoState *VAR_0) { double VAR_1; int VAR_2, VAR_3; VAR_1 = VAR_0->audio_clock; VAR_2 = audio_write_get_buf_size(VAR_0); VAR_3 = 0; if (VAR_0->audio_st) { VAR_3 = VAR_0->audio_st->codec->sample_rate * 2 * VAR_0->audio_st->codec->channels; } if (VAR_3) VAR_1 -= (double)VAR_2 / VAR_3; return VAR_1; }
[ "static double FUNC_0(VideoState *VAR_0)\n{", "double VAR_1;", "int VAR_2, VAR_3;", "VAR_1 = VAR_0->audio_clock;", "VAR_2 = audio_write_get_buf_size(VAR_0);", "VAR_3 = 0;", "if (VAR_0->audio_st) {", "VAR_3 = VAR_0->audio_st->codec->sample_rate *\n2 * VAR_0->audio_st->codec->channels;", "}", "if (VAR_3)\nVAR_1 -= (double)VAR_2 / VAR_3;", "return VAR_1;", "}" ]
[ 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 ] ]
22,138
uint8_t *ff_stream_new_side_data(AVStream *st, enum AVPacketSideDataType type, int size) { AVPacketSideData *sd, *tmp; int i; uint8_t *data = av_malloc(size); if (!data) return NULL; for (i = 0; i < st->nb_side_data; i++) { sd = &st->side_data[i]; if (sd->type == type) { av_freep(&sd->data); sd->data = data; sd->size = size; return sd->data; } } tmp = av_realloc_array(st->side_data, st->nb_side_data + 1, sizeof(*tmp)); if (!tmp) { av_freep(&data); return NULL; } st->side_data = tmp; st->nb_side_data++; sd = &st->side_data[st->nb_side_data - 1]; sd->type = type; sd->data = data; sd->size = size; return data; }
false
FFmpeg
7f4ec4364bc4a73036660c1c6a3c4801db524e9e
uint8_t *ff_stream_new_side_data(AVStream *st, enum AVPacketSideDataType type, int size) { AVPacketSideData *sd, *tmp; int i; uint8_t *data = av_malloc(size); if (!data) return NULL; for (i = 0; i < st->nb_side_data; i++) { sd = &st->side_data[i]; if (sd->type == type) { av_freep(&sd->data); sd->data = data; sd->size = size; return sd->data; } } tmp = av_realloc_array(st->side_data, st->nb_side_data + 1, sizeof(*tmp)); if (!tmp) { av_freep(&data); return NULL; } st->side_data = tmp; st->nb_side_data++; sd = &st->side_data[st->nb_side_data - 1]; sd->type = type; sd->data = data; sd->size = size; return data; }
{ "code": [], "line_no": [] }
uint8_t *FUNC_0(AVStream *st, enum AVPacketSideDataType type, int size) { AVPacketSideData *sd, *tmp; int VAR_0; uint8_t *data = av_malloc(size); if (!data) return NULL; for (VAR_0 = 0; VAR_0 < st->nb_side_data; VAR_0++) { sd = &st->side_data[VAR_0]; if (sd->type == type) { av_freep(&sd->data); sd->data = data; sd->size = size; return sd->data; } } tmp = av_realloc_array(st->side_data, st->nb_side_data + 1, sizeof(*tmp)); if (!tmp) { av_freep(&data); return NULL; } st->side_data = tmp; st->nb_side_data++; sd = &st->side_data[st->nb_side_data - 1]; sd->type = type; sd->data = data; sd->size = size; return data; }
[ "uint8_t *FUNC_0(AVStream *st, enum AVPacketSideDataType type,\nint size)\n{", "AVPacketSideData *sd, *tmp;", "int VAR_0;", "uint8_t *data = av_malloc(size);", "if (!data)\nreturn NULL;", "for (VAR_0 = 0; VAR_0 < st->nb_side_data; VAR_0++) {", "sd = &st->side_data[VAR_0];", "if (sd->type == type) {", "av_freep(&sd->data);", "sd->data = data;", "sd->size = size;", "return sd->data;", "}", "}", "tmp = av_realloc_array(st->side_data, st->nb_side_data + 1, sizeof(*tmp));", "if (!tmp) {", "av_freep(&data);", "return NULL;", "}", "st->side_data = tmp;", "st->nb_side_data++;", "sd = &st->side_data[st->nb_side_data - 1];", "sd->type = type;", "sd->data = data;", "sd->size = size;", "return data;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15, 17 ], [ 21 ], [ 23 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 55 ], [ 57 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ] ]
22,139
static void tcg_out_movcond32(TCGContext *s, TCGCond cond, TCGArg dest, TCGArg c1, TCGArg c2, int const_c2, TCGArg v1) { tcg_out_cmp(s, c1, c2, const_c2, 0); if (have_cmov) { tcg_out_modrm(s, OPC_CMOVCC | tcg_cond_to_jcc[cond], dest, v1); } else { int over = gen_new_label(); tcg_out_jxx(s, tcg_cond_to_jcc[tcg_invert_cond(cond)], over, 1); tcg_out_mov(s, TCG_TYPE_I32, dest, v1); tcg_out_label(s, over, s->code_ptr); } }
false
qemu
42a268c241183877192c376d03bd9b6d527407c7
static void tcg_out_movcond32(TCGContext *s, TCGCond cond, TCGArg dest, TCGArg c1, TCGArg c2, int const_c2, TCGArg v1) { tcg_out_cmp(s, c1, c2, const_c2, 0); if (have_cmov) { tcg_out_modrm(s, OPC_CMOVCC | tcg_cond_to_jcc[cond], dest, v1); } else { int over = gen_new_label(); tcg_out_jxx(s, tcg_cond_to_jcc[tcg_invert_cond(cond)], over, 1); tcg_out_mov(s, TCG_TYPE_I32, dest, v1); tcg_out_label(s, over, s->code_ptr); } }
{ "code": [], "line_no": [] }
static void FUNC_0(TCGContext *VAR_0, TCGCond VAR_1, TCGArg VAR_2, TCGArg VAR_3, TCGArg VAR_4, int VAR_5, TCGArg VAR_6) { tcg_out_cmp(VAR_0, VAR_3, VAR_4, VAR_5, 0); if (have_cmov) { tcg_out_modrm(VAR_0, OPC_CMOVCC | tcg_cond_to_jcc[VAR_1], VAR_2, VAR_6); } else { int VAR_7 = gen_new_label(); tcg_out_jxx(VAR_0, tcg_cond_to_jcc[tcg_invert_cond(VAR_1)], VAR_7, 1); tcg_out_mov(VAR_0, TCG_TYPE_I32, VAR_2, VAR_6); tcg_out_label(VAR_0, VAR_7, VAR_0->code_ptr); } }
[ "static void FUNC_0(TCGContext *VAR_0, TCGCond VAR_1, TCGArg VAR_2,\nTCGArg VAR_3, TCGArg VAR_4, int VAR_5,\nTCGArg VAR_6)\n{", "tcg_out_cmp(VAR_0, VAR_3, VAR_4, VAR_5, 0);", "if (have_cmov) {", "tcg_out_modrm(VAR_0, OPC_CMOVCC | tcg_cond_to_jcc[VAR_1], VAR_2, VAR_6);", "} else {", "int VAR_7 = gen_new_label();", "tcg_out_jxx(VAR_0, tcg_cond_to_jcc[tcg_invert_cond(VAR_1)], VAR_7, 1);", "tcg_out_mov(VAR_0, TCG_TYPE_I32, VAR_2, VAR_6);", "tcg_out_label(VAR_0, VAR_7, VAR_0->code_ptr);", "}", "}" ]
[ 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 ] ]
22,141
qcrypto_block_luks_open(QCryptoBlock *block, QCryptoBlockOpenOptions *options, const char *optprefix, QCryptoBlockReadFunc readfunc, void *opaque, unsigned int flags, Error **errp) { QCryptoBlockLUKS *luks; Error *local_err = NULL; int ret = 0; size_t i; ssize_t rv; uint8_t *masterkey = NULL; size_t masterkeylen; char *ivgen_name, *ivhash_name; QCryptoCipherMode ciphermode; QCryptoCipherAlgorithm cipheralg; QCryptoIVGenAlgorithm ivalg; QCryptoCipherAlgorithm ivcipheralg; QCryptoHashAlgorithm hash; QCryptoHashAlgorithm ivhash; char *password = NULL; if (!(flags & QCRYPTO_BLOCK_OPEN_NO_IO)) { if (!options->u.luks.key_secret) { error_setg(errp, "Parameter '%skey-secret' is required for cipher", optprefix ? optprefix : ""); return -1; } password = qcrypto_secret_lookup_as_utf8( options->u.luks.key_secret, errp); if (!password) { return -1; } } luks = g_new0(QCryptoBlockLUKS, 1); block->opaque = luks; /* Read the entire LUKS header, minus the key material from * the underlying device */ rv = readfunc(block, 0, (uint8_t *)&luks->header, sizeof(luks->header), opaque, errp); if (rv < 0) { ret = rv; goto fail; } /* The header is always stored in big-endian format, so * convert everything to native */ be16_to_cpus(&luks->header.version); be32_to_cpus(&luks->header.payload_offset); be32_to_cpus(&luks->header.key_bytes); be32_to_cpus(&luks->header.master_key_iterations); for (i = 0; i < QCRYPTO_BLOCK_LUKS_NUM_KEY_SLOTS; i++) { be32_to_cpus(&luks->header.key_slots[i].active); be32_to_cpus(&luks->header.key_slots[i].iterations); be32_to_cpus(&luks->header.key_slots[i].key_offset); be32_to_cpus(&luks->header.key_slots[i].stripes); } if (memcmp(luks->header.magic, qcrypto_block_luks_magic, QCRYPTO_BLOCK_LUKS_MAGIC_LEN) != 0) { error_setg(errp, "Volume is not in LUKS format"); ret = -EINVAL; goto fail; } if (luks->header.version != QCRYPTO_BLOCK_LUKS_VERSION) { error_setg(errp, "LUKS version %" PRIu32 " is not supported", luks->header.version); ret = -ENOTSUP; goto fail; } /* * The cipher_mode header contains a string that we have * to further parse, of the format * * <cipher-mode>-<iv-generator>[:<iv-hash>] * * eg cbc-essiv:sha256, cbc-plain64 */ ivgen_name = strchr(luks->header.cipher_mode, '-'); if (!ivgen_name) { ret = -EINVAL; error_setg(errp, "Unexpected cipher mode string format %s", luks->header.cipher_mode); goto fail; } *ivgen_name = '\0'; ivgen_name++; ivhash_name = strchr(ivgen_name, ':'); if (!ivhash_name) { ivhash = 0; } else { *ivhash_name = '\0'; ivhash_name++; ivhash = qcrypto_block_luks_hash_name_lookup(ivhash_name, &local_err); if (local_err) { ret = -ENOTSUP; error_propagate(errp, local_err); goto fail; } } ciphermode = qcrypto_block_luks_cipher_mode_lookup(luks->header.cipher_mode, &local_err); if (local_err) { ret = -ENOTSUP; error_propagate(errp, local_err); goto fail; } cipheralg = qcrypto_block_luks_cipher_name_lookup(luks->header.cipher_name, ciphermode, luks->header.key_bytes, &local_err); if (local_err) { ret = -ENOTSUP; error_propagate(errp, local_err); goto fail; } hash = qcrypto_block_luks_hash_name_lookup(luks->header.hash_spec, &local_err); if (local_err) { ret = -ENOTSUP; error_propagate(errp, local_err); goto fail; } ivalg = qcrypto_block_luks_ivgen_name_lookup(ivgen_name, &local_err); if (local_err) { ret = -ENOTSUP; error_propagate(errp, local_err); goto fail; } if (ivalg == QCRYPTO_IVGEN_ALG_ESSIV) { if (!ivhash_name) { ret = -EINVAL; error_setg(errp, "Missing IV generator hash specification"); goto fail; } ivcipheralg = qcrypto_block_luks_essiv_cipher(cipheralg, ivhash, &local_err); if (local_err) { ret = -ENOTSUP; error_propagate(errp, local_err); goto fail; } } else { /* Note we parsed the ivhash_name earlier in the cipher_mode * spec string even with plain/plain64 ivgens, but we * will ignore it, since it is irrelevant for these ivgens. * This is for compat with dm-crypt which will silently * ignore hash names with these ivgens rather than report * an error about the invalid usage */ ivcipheralg = cipheralg; } if (!(flags & QCRYPTO_BLOCK_OPEN_NO_IO)) { /* Try to find which key slot our password is valid for * and unlock the master key from that slot. */ if (qcrypto_block_luks_find_key(block, password, cipheralg, ciphermode, hash, ivalg, ivcipheralg, ivhash, &masterkey, &masterkeylen, readfunc, opaque, errp) < 0) { ret = -EACCES; goto fail; } /* We have a valid master key now, so can setup the * block device payload decryption objects */ block->kdfhash = hash; block->niv = qcrypto_cipher_get_iv_len(cipheralg, ciphermode); block->ivgen = qcrypto_ivgen_new(ivalg, ivcipheralg, ivhash, masterkey, masterkeylen, errp); if (!block->ivgen) { ret = -ENOTSUP; goto fail; } block->cipher = qcrypto_cipher_new(cipheralg, ciphermode, masterkey, masterkeylen, errp); if (!block->cipher) { ret = -ENOTSUP; goto fail; } } block->payload_offset = luks->header.payload_offset * QCRYPTO_BLOCK_LUKS_SECTOR_SIZE; luks->cipher_alg = cipheralg; luks->cipher_mode = ciphermode; luks->ivgen_alg = ivalg; luks->ivgen_hash_alg = ivhash; luks->hash_alg = hash; g_free(masterkey); g_free(password); return 0; fail: g_free(masterkey); qcrypto_cipher_free(block->cipher); qcrypto_ivgen_free(block->ivgen); g_free(luks); g_free(password); return ret; }
false
qemu
850f49de9b57511dcaf2cd7e45059f8f38fadf3b
qcrypto_block_luks_open(QCryptoBlock *block, QCryptoBlockOpenOptions *options, const char *optprefix, QCryptoBlockReadFunc readfunc, void *opaque, unsigned int flags, Error **errp) { QCryptoBlockLUKS *luks; Error *local_err = NULL; int ret = 0; size_t i; ssize_t rv; uint8_t *masterkey = NULL; size_t masterkeylen; char *ivgen_name, *ivhash_name; QCryptoCipherMode ciphermode; QCryptoCipherAlgorithm cipheralg; QCryptoIVGenAlgorithm ivalg; QCryptoCipherAlgorithm ivcipheralg; QCryptoHashAlgorithm hash; QCryptoHashAlgorithm ivhash; char *password = NULL; if (!(flags & QCRYPTO_BLOCK_OPEN_NO_IO)) { if (!options->u.luks.key_secret) { error_setg(errp, "Parameter '%skey-secret' is required for cipher", optprefix ? optprefix : ""); return -1; } password = qcrypto_secret_lookup_as_utf8( options->u.luks.key_secret, errp); if (!password) { return -1; } } luks = g_new0(QCryptoBlockLUKS, 1); block->opaque = luks; rv = readfunc(block, 0, (uint8_t *)&luks->header, sizeof(luks->header), opaque, errp); if (rv < 0) { ret = rv; goto fail; } be16_to_cpus(&luks->header.version); be32_to_cpus(&luks->header.payload_offset); be32_to_cpus(&luks->header.key_bytes); be32_to_cpus(&luks->header.master_key_iterations); for (i = 0; i < QCRYPTO_BLOCK_LUKS_NUM_KEY_SLOTS; i++) { be32_to_cpus(&luks->header.key_slots[i].active); be32_to_cpus(&luks->header.key_slots[i].iterations); be32_to_cpus(&luks->header.key_slots[i].key_offset); be32_to_cpus(&luks->header.key_slots[i].stripes); } if (memcmp(luks->header.magic, qcrypto_block_luks_magic, QCRYPTO_BLOCK_LUKS_MAGIC_LEN) != 0) { error_setg(errp, "Volume is not in LUKS format"); ret = -EINVAL; goto fail; } if (luks->header.version != QCRYPTO_BLOCK_LUKS_VERSION) { error_setg(errp, "LUKS version %" PRIu32 " is not supported", luks->header.version); ret = -ENOTSUP; goto fail; } ivgen_name = strchr(luks->header.cipher_mode, '-'); if (!ivgen_name) { ret = -EINVAL; error_setg(errp, "Unexpected cipher mode string format %s", luks->header.cipher_mode); goto fail; } *ivgen_name = '\0'; ivgen_name++; ivhash_name = strchr(ivgen_name, ':'); if (!ivhash_name) { ivhash = 0; } else { *ivhash_name = '\0'; ivhash_name++; ivhash = qcrypto_block_luks_hash_name_lookup(ivhash_name, &local_err); if (local_err) { ret = -ENOTSUP; error_propagate(errp, local_err); goto fail; } } ciphermode = qcrypto_block_luks_cipher_mode_lookup(luks->header.cipher_mode, &local_err); if (local_err) { ret = -ENOTSUP; error_propagate(errp, local_err); goto fail; } cipheralg = qcrypto_block_luks_cipher_name_lookup(luks->header.cipher_name, ciphermode, luks->header.key_bytes, &local_err); if (local_err) { ret = -ENOTSUP; error_propagate(errp, local_err); goto fail; } hash = qcrypto_block_luks_hash_name_lookup(luks->header.hash_spec, &local_err); if (local_err) { ret = -ENOTSUP; error_propagate(errp, local_err); goto fail; } ivalg = qcrypto_block_luks_ivgen_name_lookup(ivgen_name, &local_err); if (local_err) { ret = -ENOTSUP; error_propagate(errp, local_err); goto fail; } if (ivalg == QCRYPTO_IVGEN_ALG_ESSIV) { if (!ivhash_name) { ret = -EINVAL; error_setg(errp, "Missing IV generator hash specification"); goto fail; } ivcipheralg = qcrypto_block_luks_essiv_cipher(cipheralg, ivhash, &local_err); if (local_err) { ret = -ENOTSUP; error_propagate(errp, local_err); goto fail; } } else { ivcipheralg = cipheralg; } if (!(flags & QCRYPTO_BLOCK_OPEN_NO_IO)) { if (qcrypto_block_luks_find_key(block, password, cipheralg, ciphermode, hash, ivalg, ivcipheralg, ivhash, &masterkey, &masterkeylen, readfunc, opaque, errp) < 0) { ret = -EACCES; goto fail; } block->kdfhash = hash; block->niv = qcrypto_cipher_get_iv_len(cipheralg, ciphermode); block->ivgen = qcrypto_ivgen_new(ivalg, ivcipheralg, ivhash, masterkey, masterkeylen, errp); if (!block->ivgen) { ret = -ENOTSUP; goto fail; } block->cipher = qcrypto_cipher_new(cipheralg, ciphermode, masterkey, masterkeylen, errp); if (!block->cipher) { ret = -ENOTSUP; goto fail; } } block->payload_offset = luks->header.payload_offset * QCRYPTO_BLOCK_LUKS_SECTOR_SIZE; luks->cipher_alg = cipheralg; luks->cipher_mode = ciphermode; luks->ivgen_alg = ivalg; luks->ivgen_hash_alg = ivhash; luks->hash_alg = hash; g_free(masterkey); g_free(password); return 0; fail: g_free(masterkey); qcrypto_cipher_free(block->cipher); qcrypto_ivgen_free(block->ivgen); g_free(luks); g_free(password); return ret; }
{ "code": [], "line_no": [] }
FUNC_0(QCryptoBlock *VAR_0, QCryptoBlockOpenOptions *VAR_1, const char *VAR_2, QCryptoBlockReadFunc VAR_3, void *VAR_4, unsigned int VAR_5, Error **VAR_6) { QCryptoBlockLUKS *luks; Error *local_err = NULL; int VAR_7 = 0; size_t i; ssize_t rv; uint8_t *masterkey = NULL; size_t masterkeylen; char *VAR_8, *VAR_9; QCryptoCipherMode ciphermode; QCryptoCipherAlgorithm cipheralg; QCryptoIVGenAlgorithm ivalg; QCryptoCipherAlgorithm ivcipheralg; QCryptoHashAlgorithm hash; QCryptoHashAlgorithm ivhash; char *VAR_10 = NULL; if (!(VAR_5 & QCRYPTO_BLOCK_OPEN_NO_IO)) { if (!VAR_1->u.luks.key_secret) { error_setg(VAR_6, "Parameter '%skey-secret' is required for cipher", VAR_2 ? VAR_2 : ""); return -1; } VAR_10 = qcrypto_secret_lookup_as_utf8( VAR_1->u.luks.key_secret, VAR_6); if (!VAR_10) { return -1; } } luks = g_new0(QCryptoBlockLUKS, 1); VAR_0->VAR_4 = luks; rv = VAR_3(VAR_0, 0, (uint8_t *)&luks->header, sizeof(luks->header), VAR_4, VAR_6); if (rv < 0) { VAR_7 = rv; goto fail; } be16_to_cpus(&luks->header.version); be32_to_cpus(&luks->header.payload_offset); be32_to_cpus(&luks->header.key_bytes); be32_to_cpus(&luks->header.master_key_iterations); for (i = 0; i < QCRYPTO_BLOCK_LUKS_NUM_KEY_SLOTS; i++) { be32_to_cpus(&luks->header.key_slots[i].active); be32_to_cpus(&luks->header.key_slots[i].iterations); be32_to_cpus(&luks->header.key_slots[i].key_offset); be32_to_cpus(&luks->header.key_slots[i].stripes); } if (memcmp(luks->header.magic, qcrypto_block_luks_magic, QCRYPTO_BLOCK_LUKS_MAGIC_LEN) != 0) { error_setg(VAR_6, "Volume is not in LUKS format"); VAR_7 = -EINVAL; goto fail; } if (luks->header.version != QCRYPTO_BLOCK_LUKS_VERSION) { error_setg(VAR_6, "LUKS version %" PRIu32 " is not supported", luks->header.version); VAR_7 = -ENOTSUP; goto fail; } VAR_8 = strchr(luks->header.cipher_mode, '-'); if (!VAR_8) { VAR_7 = -EINVAL; error_setg(VAR_6, "Unexpected cipher mode string format %s", luks->header.cipher_mode); goto fail; } *VAR_8 = '\0'; VAR_8++; VAR_9 = strchr(VAR_8, ':'); if (!VAR_9) { ivhash = 0; } else { *VAR_9 = '\0'; VAR_9++; ivhash = qcrypto_block_luks_hash_name_lookup(VAR_9, &local_err); if (local_err) { VAR_7 = -ENOTSUP; error_propagate(VAR_6, local_err); goto fail; } } ciphermode = qcrypto_block_luks_cipher_mode_lookup(luks->header.cipher_mode, &local_err); if (local_err) { VAR_7 = -ENOTSUP; error_propagate(VAR_6, local_err); goto fail; } cipheralg = qcrypto_block_luks_cipher_name_lookup(luks->header.cipher_name, ciphermode, luks->header.key_bytes, &local_err); if (local_err) { VAR_7 = -ENOTSUP; error_propagate(VAR_6, local_err); goto fail; } hash = qcrypto_block_luks_hash_name_lookup(luks->header.hash_spec, &local_err); if (local_err) { VAR_7 = -ENOTSUP; error_propagate(VAR_6, local_err); goto fail; } ivalg = qcrypto_block_luks_ivgen_name_lookup(VAR_8, &local_err); if (local_err) { VAR_7 = -ENOTSUP; error_propagate(VAR_6, local_err); goto fail; } if (ivalg == QCRYPTO_IVGEN_ALG_ESSIV) { if (!VAR_9) { VAR_7 = -EINVAL; error_setg(VAR_6, "Missing IV generator hash specification"); goto fail; } ivcipheralg = qcrypto_block_luks_essiv_cipher(cipheralg, ivhash, &local_err); if (local_err) { VAR_7 = -ENOTSUP; error_propagate(VAR_6, local_err); goto fail; } } else { ivcipheralg = cipheralg; } if (!(VAR_5 & QCRYPTO_BLOCK_OPEN_NO_IO)) { if (qcrypto_block_luks_find_key(VAR_0, VAR_10, cipheralg, ciphermode, hash, ivalg, ivcipheralg, ivhash, &masterkey, &masterkeylen, VAR_3, VAR_4, VAR_6) < 0) { VAR_7 = -EACCES; goto fail; } VAR_0->kdfhash = hash; VAR_0->niv = qcrypto_cipher_get_iv_len(cipheralg, ciphermode); VAR_0->ivgen = qcrypto_ivgen_new(ivalg, ivcipheralg, ivhash, masterkey, masterkeylen, VAR_6); if (!VAR_0->ivgen) { VAR_7 = -ENOTSUP; goto fail; } VAR_0->cipher = qcrypto_cipher_new(cipheralg, ciphermode, masterkey, masterkeylen, VAR_6); if (!VAR_0->cipher) { VAR_7 = -ENOTSUP; goto fail; } } VAR_0->payload_offset = luks->header.payload_offset * QCRYPTO_BLOCK_LUKS_SECTOR_SIZE; luks->cipher_alg = cipheralg; luks->cipher_mode = ciphermode; luks->ivgen_alg = ivalg; luks->ivgen_hash_alg = ivhash; luks->hash_alg = hash; g_free(masterkey); g_free(VAR_10); return 0; fail: g_free(masterkey); qcrypto_cipher_free(VAR_0->cipher); qcrypto_ivgen_free(VAR_0->ivgen); g_free(luks); g_free(VAR_10); return VAR_7; }
[ "FUNC_0(QCryptoBlock *VAR_0,\nQCryptoBlockOpenOptions *VAR_1,\nconst char *VAR_2,\nQCryptoBlockReadFunc VAR_3,\nvoid *VAR_4,\nunsigned int VAR_5,\nError **VAR_6)\n{", "QCryptoBlockLUKS *luks;", "Error *local_err = NULL;", "int VAR_7 = 0;", "size_t i;", "ssize_t rv;", "uint8_t *masterkey = NULL;", "size_t masterkeylen;", "char *VAR_8, *VAR_9;", "QCryptoCipherMode ciphermode;", "QCryptoCipherAlgorithm cipheralg;", "QCryptoIVGenAlgorithm ivalg;", "QCryptoCipherAlgorithm ivcipheralg;", "QCryptoHashAlgorithm hash;", "QCryptoHashAlgorithm ivhash;", "char *VAR_10 = NULL;", "if (!(VAR_5 & QCRYPTO_BLOCK_OPEN_NO_IO)) {", "if (!VAR_1->u.luks.key_secret) {", "error_setg(VAR_6, \"Parameter '%skey-secret' is required for cipher\",\nVAR_2 ? VAR_2 : \"\");", "return -1;", "}", "VAR_10 = qcrypto_secret_lookup_as_utf8(\nVAR_1->u.luks.key_secret, VAR_6);", "if (!VAR_10) {", "return -1;", "}", "}", "luks = g_new0(QCryptoBlockLUKS, 1);", "VAR_0->VAR_4 = luks;", "rv = VAR_3(VAR_0, 0,\n(uint8_t *)&luks->header,\nsizeof(luks->header),\nVAR_4,\nVAR_6);", "if (rv < 0) {", "VAR_7 = rv;", "goto fail;", "}", "be16_to_cpus(&luks->header.version);", "be32_to_cpus(&luks->header.payload_offset);", "be32_to_cpus(&luks->header.key_bytes);", "be32_to_cpus(&luks->header.master_key_iterations);", "for (i = 0; i < QCRYPTO_BLOCK_LUKS_NUM_KEY_SLOTS; i++) {", "be32_to_cpus(&luks->header.key_slots[i].active);", "be32_to_cpus(&luks->header.key_slots[i].iterations);", "be32_to_cpus(&luks->header.key_slots[i].key_offset);", "be32_to_cpus(&luks->header.key_slots[i].stripes);", "}", "if (memcmp(luks->header.magic, qcrypto_block_luks_magic,\nQCRYPTO_BLOCK_LUKS_MAGIC_LEN) != 0) {", "error_setg(VAR_6, \"Volume is not in LUKS format\");", "VAR_7 = -EINVAL;", "goto fail;", "}", "if (luks->header.version != QCRYPTO_BLOCK_LUKS_VERSION) {", "error_setg(VAR_6, \"LUKS version %\" PRIu32 \" is not supported\",\nluks->header.version);", "VAR_7 = -ENOTSUP;", "goto fail;", "}", "VAR_8 = strchr(luks->header.cipher_mode, '-');", "if (!VAR_8) {", "VAR_7 = -EINVAL;", "error_setg(VAR_6, \"Unexpected cipher mode string format %s\",\nluks->header.cipher_mode);", "goto fail;", "}", "*VAR_8 = '\\0';", "VAR_8++;", "VAR_9 = strchr(VAR_8, ':');", "if (!VAR_9) {", "ivhash = 0;", "} else {", "*VAR_9 = '\\0';", "VAR_9++;", "ivhash = qcrypto_block_luks_hash_name_lookup(VAR_9,\n&local_err);", "if (local_err) {", "VAR_7 = -ENOTSUP;", "error_propagate(VAR_6, local_err);", "goto fail;", "}", "}", "ciphermode = qcrypto_block_luks_cipher_mode_lookup(luks->header.cipher_mode,\n&local_err);", "if (local_err) {", "VAR_7 = -ENOTSUP;", "error_propagate(VAR_6, local_err);", "goto fail;", "}", "cipheralg = qcrypto_block_luks_cipher_name_lookup(luks->header.cipher_name,\nciphermode,\nluks->header.key_bytes,\n&local_err);", "if (local_err) {", "VAR_7 = -ENOTSUP;", "error_propagate(VAR_6, local_err);", "goto fail;", "}", "hash = qcrypto_block_luks_hash_name_lookup(luks->header.hash_spec,\n&local_err);", "if (local_err) {", "VAR_7 = -ENOTSUP;", "error_propagate(VAR_6, local_err);", "goto fail;", "}", "ivalg = qcrypto_block_luks_ivgen_name_lookup(VAR_8,\n&local_err);", "if (local_err) {", "VAR_7 = -ENOTSUP;", "error_propagate(VAR_6, local_err);", "goto fail;", "}", "if (ivalg == QCRYPTO_IVGEN_ALG_ESSIV) {", "if (!VAR_9) {", "VAR_7 = -EINVAL;", "error_setg(VAR_6, \"Missing IV generator hash specification\");", "goto fail;", "}", "ivcipheralg = qcrypto_block_luks_essiv_cipher(cipheralg,\nivhash,\n&local_err);", "if (local_err) {", "VAR_7 = -ENOTSUP;", "error_propagate(VAR_6, local_err);", "goto fail;", "}", "} else {", "ivcipheralg = cipheralg;", "}", "if (!(VAR_5 & QCRYPTO_BLOCK_OPEN_NO_IO)) {", "if (qcrypto_block_luks_find_key(VAR_0,\nVAR_10,\ncipheralg, ciphermode,\nhash,\nivalg,\nivcipheralg,\nivhash,\n&masterkey, &masterkeylen,\nVAR_3, VAR_4,\nVAR_6) < 0) {", "VAR_7 = -EACCES;", "goto fail;", "}", "VAR_0->kdfhash = hash;", "VAR_0->niv = qcrypto_cipher_get_iv_len(cipheralg,\nciphermode);", "VAR_0->ivgen = qcrypto_ivgen_new(ivalg,\nivcipheralg,\nivhash,\nmasterkey, masterkeylen,\nVAR_6);", "if (!VAR_0->ivgen) {", "VAR_7 = -ENOTSUP;", "goto fail;", "}", "VAR_0->cipher = qcrypto_cipher_new(cipheralg,\nciphermode,\nmasterkey, masterkeylen,\nVAR_6);", "if (!VAR_0->cipher) {", "VAR_7 = -ENOTSUP;", "goto fail;", "}", "}", "VAR_0->payload_offset = luks->header.payload_offset *\nQCRYPTO_BLOCK_LUKS_SECTOR_SIZE;", "luks->cipher_alg = cipheralg;", "luks->cipher_mode = ciphermode;", "luks->ivgen_alg = ivalg;", "luks->ivgen_hash_alg = ivhash;", "luks->hash_alg = hash;", "g_free(masterkey);", "g_free(VAR_10);", "return 0;", "fail:\ng_free(masterkey);", "qcrypto_cipher_free(VAR_0->cipher);", "qcrypto_ivgen_free(VAR_0->ivgen);", "g_free(luks);", "g_free(VAR_10);", "return VAR_7;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9, 11, 13, 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 49 ], [ 51 ], [ 53, 55 ], [ 57 ], [ 59 ], [ 61, 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 75 ], [ 77 ], [ 85, 87, 89, 91, 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 133, 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147, 149 ], [ 151 ], [ 153 ], [ 155 ], [ 175 ], [ 177 ], [ 179 ], [ 181, 183 ], [ 185 ], [ 187 ], [ 189 ], [ 191 ], [ 195 ], [ 197 ], [ 199 ], [ 201 ], [ 203 ], [ 205 ], [ 209, 211 ], [ 213 ], [ 215 ], [ 217 ], [ 219 ], [ 221 ], [ 223 ], [ 227, 229 ], [ 231 ], [ 233 ], [ 235 ], [ 237 ], [ 239 ], [ 243, 245, 247, 249 ], [ 251 ], [ 253 ], [ 255 ], [ 257 ], [ 259 ], [ 263, 265 ], [ 267 ], [ 269 ], [ 271 ], [ 273 ], [ 275 ], [ 279, 281 ], [ 283 ], [ 285 ], [ 287 ], [ 289 ], [ 291 ], [ 295 ], [ 297 ], [ 299 ], [ 301 ], [ 303 ], [ 305 ], [ 307, 309, 311 ], [ 313 ], [ 315 ], [ 317 ], [ 319 ], [ 321 ], [ 323 ], [ 339 ], [ 341 ], [ 345 ], [ 353, 355, 357, 359, 361, 363, 365, 367, 369, 371 ], [ 373 ], [ 375 ], [ 377 ], [ 387 ], [ 389, 391 ], [ 393, 395, 397, 399, 401 ], [ 403 ], [ 405 ], [ 407 ], [ 409 ], [ 413, 415, 417, 419 ], [ 421 ], [ 423 ], [ 425 ], [ 427 ], [ 429 ], [ 433, 435 ], [ 439 ], [ 441 ], [ 443 ], [ 445 ], [ 447 ], [ 451 ], [ 453 ], [ 457 ], [ 461, 463 ], [ 465 ], [ 467 ], [ 469 ], [ 471 ], [ 473 ], [ 475 ] ]
22,144
static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is64) { TCGReg datalo, datahi, addrlo; TCGReg addrhi __attribute__((unused)); TCGMemOpIdx oi; TCGMemOp opc; #if defined(CONFIG_SOFTMMU) int mem_index; TCGMemOp s_bits; tcg_insn_unit *label_ptr[2]; #endif datalo = *args++; datahi = (TCG_TARGET_REG_BITS == 32 && is64 ? *args++ : 0); addrlo = *args++; addrhi = (TARGET_LONG_BITS > TCG_TARGET_REG_BITS ? *args++ : 0); oi = *args++; opc = get_memop(oi); #if defined(CONFIG_SOFTMMU) mem_index = get_mmuidx(oi); s_bits = opc & MO_SIZE; tcg_out_tlb_load(s, addrlo, addrhi, mem_index, s_bits, label_ptr, offsetof(CPUTLBEntry, addr_read)); /* TLB Hit. */ tcg_out_qemu_ld_direct(s, datalo, datahi, TCG_REG_L1, -1, 0, 0, opc); /* Record the current context of a load into ldst label */ add_qemu_ldst_label(s, true, oi, datalo, datahi, addrlo, addrhi, s->code_ptr, label_ptr); #else { int32_t offset = GUEST_BASE; TCGReg base = addrlo; int index = -1; int seg = 0; /* For a 32-bit guest, the high 32 bits may contain garbage. We can do this with the ADDR32 prefix if we're not using a guest base, or when using segmentation. Otherwise we need to zero-extend manually. */ if (GUEST_BASE == 0 || guest_base_flags) { seg = guest_base_flags; offset = 0; if (TCG_TARGET_REG_BITS > TARGET_LONG_BITS) { seg |= P_ADDR32; } } else if (TCG_TARGET_REG_BITS == 64) { if (TARGET_LONG_BITS == 32) { tcg_out_ext32u(s, TCG_REG_L0, base); base = TCG_REG_L0; } if (offset != GUEST_BASE) { tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_L1, GUEST_BASE); index = TCG_REG_L1; offset = 0; } } tcg_out_qemu_ld_direct(s, datalo, datahi, base, index, offset, seg, opc); } #endif }
false
qemu
8cc580f6a0d8c0e2f590c1472cf5cd8e51761760
static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is64) { TCGReg datalo, datahi, addrlo; TCGReg addrhi __attribute__((unused)); TCGMemOpIdx oi; TCGMemOp opc; #if defined(CONFIG_SOFTMMU) int mem_index; TCGMemOp s_bits; tcg_insn_unit *label_ptr[2]; #endif datalo = *args++; datahi = (TCG_TARGET_REG_BITS == 32 && is64 ? *args++ : 0); addrlo = *args++; addrhi = (TARGET_LONG_BITS > TCG_TARGET_REG_BITS ? *args++ : 0); oi = *args++; opc = get_memop(oi); #if defined(CONFIG_SOFTMMU) mem_index = get_mmuidx(oi); s_bits = opc & MO_SIZE; tcg_out_tlb_load(s, addrlo, addrhi, mem_index, s_bits, label_ptr, offsetof(CPUTLBEntry, addr_read)); tcg_out_qemu_ld_direct(s, datalo, datahi, TCG_REG_L1, -1, 0, 0, opc); add_qemu_ldst_label(s, true, oi, datalo, datahi, addrlo, addrhi, s->code_ptr, label_ptr); #else { int32_t offset = GUEST_BASE; TCGReg base = addrlo; int index = -1; int seg = 0; if (GUEST_BASE == 0 || guest_base_flags) { seg = guest_base_flags; offset = 0; if (TCG_TARGET_REG_BITS > TARGET_LONG_BITS) { seg |= P_ADDR32; } } else if (TCG_TARGET_REG_BITS == 64) { if (TARGET_LONG_BITS == 32) { tcg_out_ext32u(s, TCG_REG_L0, base); base = TCG_REG_L0; } if (offset != GUEST_BASE) { tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_L1, GUEST_BASE); index = TCG_REG_L1; offset = 0; } } tcg_out_qemu_ld_direct(s, datalo, datahi, base, index, offset, seg, opc); } #endif }
{ "code": [], "line_no": [] }
static void FUNC_0(TCGContext *VAR_0, const TCGArg *VAR_1, bool VAR_2) { TCGReg datalo, datahi, addrlo; TCGReg addrhi __attribute__((unused)); TCGMemOpIdx oi; TCGMemOp opc; #if defined(CONFIG_SOFTMMU) int mem_index; TCGMemOp s_bits; tcg_insn_unit *label_ptr[2]; #endif datalo = *VAR_1++; datahi = (TCG_TARGET_REG_BITS == 32 && VAR_2 ? *VAR_1++ : 0); addrlo = *VAR_1++; addrhi = (TARGET_LONG_BITS > TCG_TARGET_REG_BITS ? *VAR_1++ : 0); oi = *VAR_1++; opc = get_memop(oi); #if defined(CONFIG_SOFTMMU) mem_index = get_mmuidx(oi); s_bits = opc & MO_SIZE; tcg_out_tlb_load(VAR_0, addrlo, addrhi, mem_index, s_bits, label_ptr, offsetof(CPUTLBEntry, addr_read)); tcg_out_qemu_ld_direct(VAR_0, datalo, datahi, TCG_REG_L1, -1, 0, 0, opc); add_qemu_ldst_label(VAR_0, true, oi, datalo, datahi, addrlo, addrhi, VAR_0->code_ptr, label_ptr); #else { int32_t offset = GUEST_BASE; TCGReg base = addrlo; int VAR_3 = -1; int VAR_4 = 0; if (GUEST_BASE == 0 || guest_base_flags) { VAR_4 = guest_base_flags; offset = 0; if (TCG_TARGET_REG_BITS > TARGET_LONG_BITS) { VAR_4 |= P_ADDR32; } } else if (TCG_TARGET_REG_BITS == 64) { if (TARGET_LONG_BITS == 32) { tcg_out_ext32u(VAR_0, TCG_REG_L0, base); base = TCG_REG_L0; } if (offset != GUEST_BASE) { tcg_out_movi(VAR_0, TCG_TYPE_I64, TCG_REG_L1, GUEST_BASE); VAR_3 = TCG_REG_L1; offset = 0; } } tcg_out_qemu_ld_direct(VAR_0, datalo, datahi, base, VAR_3, offset, VAR_4, opc); } #endif }
[ "static void FUNC_0(TCGContext *VAR_0, const TCGArg *VAR_1, bool VAR_2)\n{", "TCGReg datalo, datahi, addrlo;", "TCGReg addrhi __attribute__((unused));", "TCGMemOpIdx oi;", "TCGMemOp opc;", "#if defined(CONFIG_SOFTMMU)\nint mem_index;", "TCGMemOp s_bits;", "tcg_insn_unit *label_ptr[2];", "#endif\ndatalo = *VAR_1++;", "datahi = (TCG_TARGET_REG_BITS == 32 && VAR_2 ? *VAR_1++ : 0);", "addrlo = *VAR_1++;", "addrhi = (TARGET_LONG_BITS > TCG_TARGET_REG_BITS ? *VAR_1++ : 0);", "oi = *VAR_1++;", "opc = get_memop(oi);", "#if defined(CONFIG_SOFTMMU)\nmem_index = get_mmuidx(oi);", "s_bits = opc & MO_SIZE;", "tcg_out_tlb_load(VAR_0, addrlo, addrhi, mem_index, s_bits,\nlabel_ptr, offsetof(CPUTLBEntry, addr_read));", "tcg_out_qemu_ld_direct(VAR_0, datalo, datahi, TCG_REG_L1, -1, 0, 0, opc);", "add_qemu_ldst_label(VAR_0, true, oi, datalo, datahi, addrlo, addrhi,\nVAR_0->code_ptr, label_ptr);", "#else\n{", "int32_t offset = GUEST_BASE;", "TCGReg base = addrlo;", "int VAR_3 = -1;", "int VAR_4 = 0;", "if (GUEST_BASE == 0 || guest_base_flags) {", "VAR_4 = guest_base_flags;", "offset = 0;", "if (TCG_TARGET_REG_BITS > TARGET_LONG_BITS) {", "VAR_4 |= P_ADDR32;", "}", "} else if (TCG_TARGET_REG_BITS == 64) {", "if (TARGET_LONG_BITS == 32) {", "tcg_out_ext32u(VAR_0, TCG_REG_L0, base);", "base = TCG_REG_L0;", "}", "if (offset != GUEST_BASE) {", "tcg_out_movi(VAR_0, TCG_TYPE_I64, TCG_REG_L1, GUEST_BASE);", "VAR_3 = TCG_REG_L1;", "offset = 0;", "}", "}", "tcg_out_qemu_ld_direct(VAR_0, datalo, datahi,\nbase, VAR_3, offset, VAR_4, opc);", "}", "#endif\n}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13, 15 ], [ 17 ], [ 19 ], [ 21, 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 39, 41 ], [ 43 ], [ 47, 49 ], [ 55 ], [ 61, 63 ], [ 65, 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 123, 125 ], [ 127 ], [ 129, 131 ] ]
22,145
void memory_region_init_io(MemoryRegion *mr, const MemoryRegionOps *ops, void *opaque, const char *name, uint64_t size) { memory_region_init(mr, name, size); mr->ops = ops; mr->opaque = opaque; mr->terminates = true; mr->backend_registered = false; }
false
qemu
26a83ad0e793465b74a8b06a65f2f6fdc5615413
void memory_region_init_io(MemoryRegion *mr, const MemoryRegionOps *ops, void *opaque, const char *name, uint64_t size) { memory_region_init(mr, name, size); mr->ops = ops; mr->opaque = opaque; mr->terminates = true; mr->backend_registered = false; }
{ "code": [], "line_no": [] }
void FUNC_0(MemoryRegion *VAR_0, const MemoryRegionOps *VAR_1, void *VAR_2, const char *VAR_3, uint64_t VAR_4) { memory_region_init(VAR_0, VAR_3, VAR_4); VAR_0->VAR_1 = VAR_1; VAR_0->VAR_2 = VAR_2; VAR_0->terminates = true; VAR_0->backend_registered = false; }
[ "void FUNC_0(MemoryRegion *VAR_0,\nconst MemoryRegionOps *VAR_1,\nvoid *VAR_2,\nconst char *VAR_3,\nuint64_t VAR_4)\n{", "memory_region_init(VAR_0, VAR_3, VAR_4);", "VAR_0->VAR_1 = VAR_1;", "VAR_0->VAR_2 = VAR_2;", "VAR_0->terminates = true;", "VAR_0->backend_registered = false;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9, 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ] ]
22,146
static uint32_t bonito_spciconf_readw(void *opaque, target_phys_addr_t addr) { PCIBonitoState *s = opaque; uint32_t pciaddr; uint16_t status; DPRINTF("bonito_spciconf_readw "TARGET_FMT_plx" \n", addr); assert((addr&0x1)==0); pciaddr = bonito_sbridge_pciaddr(s, addr); if (pciaddr == 0xffffffff) { return 0xffff; } /* set the pci address in s->config_reg */ s->pcihost->config_reg = (pciaddr) | (1u << 31); /* clear PCI_STATUS_REC_MASTER_ABORT and PCI_STATUS_REC_TARGET_ABORT */ status = pci_get_word(s->dev.config + PCI_STATUS); status &= ~(PCI_STATUS_REC_MASTER_ABORT | PCI_STATUS_REC_TARGET_ABORT); pci_set_word(s->dev.config + PCI_STATUS, status); return pci_data_read(s->pcihost->bus, s->pcihost->config_reg, 2); }
false
qemu
b2bedb214469af55179d907a60cd67fed6b0779e
static uint32_t bonito_spciconf_readw(void *opaque, target_phys_addr_t addr) { PCIBonitoState *s = opaque; uint32_t pciaddr; uint16_t status; DPRINTF("bonito_spciconf_readw "TARGET_FMT_plx" \n", addr); assert((addr&0x1)==0); pciaddr = bonito_sbridge_pciaddr(s, addr); if (pciaddr == 0xffffffff) { return 0xffff; } s->pcihost->config_reg = (pciaddr) | (1u << 31); status = pci_get_word(s->dev.config + PCI_STATUS); status &= ~(PCI_STATUS_REC_MASTER_ABORT | PCI_STATUS_REC_TARGET_ABORT); pci_set_word(s->dev.config + PCI_STATUS, status); return pci_data_read(s->pcihost->bus, s->pcihost->config_reg, 2); }
{ "code": [], "line_no": [] }
static uint32_t FUNC_0(void *opaque, target_phys_addr_t addr) { PCIBonitoState *s = opaque; uint32_t pciaddr; uint16_t status; DPRINTF("FUNC_0 "TARGET_FMT_plx" \n", addr); assert((addr&0x1)==0); pciaddr = bonito_sbridge_pciaddr(s, addr); if (pciaddr == 0xffffffff) { return 0xffff; } s->pcihost->config_reg = (pciaddr) | (1u << 31); status = pci_get_word(s->dev.config + PCI_STATUS); status &= ~(PCI_STATUS_REC_MASTER_ABORT | PCI_STATUS_REC_TARGET_ABORT); pci_set_word(s->dev.config + PCI_STATUS, status); return pci_data_read(s->pcihost->bus, s->pcihost->config_reg, 2); }
[ "static uint32_t FUNC_0(void *opaque, target_phys_addr_t addr)\n{", "PCIBonitoState *s = opaque;", "uint32_t pciaddr;", "uint16_t status;", "DPRINTF(\"FUNC_0 \"TARGET_FMT_plx\" \\n\", addr);", "assert((addr&0x1)==0);", "pciaddr = bonito_sbridge_pciaddr(s, addr);", "if (pciaddr == 0xffffffff) {", "return 0xffff;", "}", "s->pcihost->config_reg = (pciaddr) | (1u << 31);", "status = pci_get_word(s->dev.config + PCI_STATUS);", "status &= ~(PCI_STATUS_REC_MASTER_ABORT | PCI_STATUS_REC_TARGET_ABORT);", "pci_set_word(s->dev.config + PCI_STATUS, status);", "return pci_data_read(s->pcihost->bus, s->pcihost->config_reg, 2);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 19 ], [ 23 ], [ 25 ], [ 27 ], [ 33 ], [ 39 ], [ 41 ], [ 43 ], [ 47 ], [ 49 ] ]
22,147
static uint64_t uart_read(void *opaque, target_phys_addr_t offset, unsigned size) { UartState *s = (UartState *)opaque; uint32_t c = 0; offset >>= 2; if (offset >= R_MAX) { return 0; } else if (offset == R_TX_RX) { uart_read_rx_fifo(s, &c); return c; } return s->r[offset]; }
false
qemu
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
static uint64_t uart_read(void *opaque, target_phys_addr_t offset, unsigned size) { UartState *s = (UartState *)opaque; uint32_t c = 0; offset >>= 2; if (offset >= R_MAX) { return 0; } else if (offset == R_TX_RX) { uart_read_rx_fifo(s, &c); return c; } return s->r[offset]; }
{ "code": [], "line_no": [] }
static uint64_t FUNC_0(void *opaque, target_phys_addr_t offset, unsigned size) { UartState *s = (UartState *)opaque; uint32_t c = 0; offset >>= 2; if (offset >= R_MAX) { return 0; } else if (offset == R_TX_RX) { uart_read_rx_fifo(s, &c); return c; } return s->r[offset]; }
[ "static uint64_t FUNC_0(void *opaque, target_phys_addr_t offset,\nunsigned size)\n{", "UartState *s = (UartState *)opaque;", "uint32_t c = 0;", "offset >>= 2;", "if (offset >= R_MAX) {", "return 0;", "} else if (offset == R_TX_RX) {", "uart_read_rx_fifo(s, &c);", "return c;", "}", "return s->r[offset];", "}" ]
[ 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 ] ]
22,148
static int adts_write_packet(AVFormatContext *s, AVPacket *pkt) { ADTSContext *adts = s->priv_data; AVIOContext *pb = s->pb; uint8_t buf[ADTS_HEADER_SIZE]; if (!pkt->size) return 0; if (adts->write_adts) { ff_adts_write_frame_header(adts, buf, pkt->size, adts->pce_size); avio_write(pb, buf, ADTS_HEADER_SIZE); if (adts->pce_size) { avio_write(pb, adts->pce_data, adts->pce_size); adts->pce_size = 0; } } avio_write(pb, pkt->data, pkt->size); avio_flush(pb); return 0; }
false
FFmpeg
ac47e014bbaf5163871a8beb7522015e0bc27615
static int adts_write_packet(AVFormatContext *s, AVPacket *pkt) { ADTSContext *adts = s->priv_data; AVIOContext *pb = s->pb; uint8_t buf[ADTS_HEADER_SIZE]; if (!pkt->size) return 0; if (adts->write_adts) { ff_adts_write_frame_header(adts, buf, pkt->size, adts->pce_size); avio_write(pb, buf, ADTS_HEADER_SIZE); if (adts->pce_size) { avio_write(pb, adts->pce_data, adts->pce_size); adts->pce_size = 0; } } avio_write(pb, pkt->data, pkt->size); avio_flush(pb); return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1) { ADTSContext *adts = VAR_0->priv_data; AVIOContext *pb = VAR_0->pb; uint8_t buf[ADTS_HEADER_SIZE]; if (!VAR_1->size) return 0; if (adts->write_adts) { ff_adts_write_frame_header(adts, buf, VAR_1->size, adts->pce_size); avio_write(pb, buf, ADTS_HEADER_SIZE); if (adts->pce_size) { avio_write(pb, adts->pce_data, adts->pce_size); adts->pce_size = 0; } } avio_write(pb, VAR_1->data, VAR_1->size); avio_flush(pb); return 0; }
[ "static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)\n{", "ADTSContext *adts = VAR_0->priv_data;", "AVIOContext *pb = VAR_0->pb;", "uint8_t buf[ADTS_HEADER_SIZE];", "if (!VAR_1->size)\nreturn 0;", "if (adts->write_adts) {", "ff_adts_write_frame_header(adts, buf, VAR_1->size, adts->pce_size);", "avio_write(pb, buf, ADTS_HEADER_SIZE);", "if (adts->pce_size) {", "avio_write(pb, adts->pce_data, adts->pce_size);", "adts->pce_size = 0;", "}", "}", "avio_write(pb, VAR_1->data, VAR_1->size);", "avio_flush(pb);", "return 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 ], [ 39 ], [ 41 ] ]
22,149
static int check_opts(QemuOptsList *opts_list, QDict *args) { assert(!opts_list->desc->name); return 0; }
false
qemu
f6b4fc8b23b1154577c72937b70e565716bb0a60
static int check_opts(QemuOptsList *opts_list, QDict *args) { assert(!opts_list->desc->name); return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(QemuOptsList *VAR_0, QDict *VAR_1) { assert(!VAR_0->desc->name); return 0; }
[ "static int FUNC_0(QemuOptsList *VAR_0, QDict *VAR_1)\n{", "assert(!VAR_0->desc->name);", "return 0;", "}" ]
[ 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ] ]
22,150
static int qdev_add_one_global(QemuOpts *opts, void *opaque) { GlobalProperty *g; ObjectClass *oc; g = g_malloc0(sizeof(*g)); g->driver = qemu_opt_get(opts, "driver"); g->property = qemu_opt_get(opts, "property"); g->value = qemu_opt_get(opts, "value"); oc = object_class_dynamic_cast(object_class_by_name(g->driver), TYPE_DEVICE); if (oc) { DeviceClass *dc = DEVICE_CLASS(oc); if (dc->hotpluggable) { /* If hotpluggable then skip not_used checking. */ g->not_used = false; } else { /* Maybe a typo. */ g->not_used = true; } } else { /* Maybe a typo. */ g->not_used = true; } qdev_prop_register_global(g); return 0; }
false
qemu
b3ce84fea466f3bca2ff85d158744f00c0f429bd
static int qdev_add_one_global(QemuOpts *opts, void *opaque) { GlobalProperty *g; ObjectClass *oc; g = g_malloc0(sizeof(*g)); g->driver = qemu_opt_get(opts, "driver"); g->property = qemu_opt_get(opts, "property"); g->value = qemu_opt_get(opts, "value"); oc = object_class_dynamic_cast(object_class_by_name(g->driver), TYPE_DEVICE); if (oc) { DeviceClass *dc = DEVICE_CLASS(oc); if (dc->hotpluggable) { g->not_used = false; } else { g->not_used = true; } } else { g->not_used = true; } qdev_prop_register_global(g); return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(QemuOpts *VAR_0, void *VAR_1) { GlobalProperty *g; ObjectClass *oc; g = g_malloc0(sizeof(*g)); g->driver = qemu_opt_get(VAR_0, "driver"); g->property = qemu_opt_get(VAR_0, "property"); g->value = qemu_opt_get(VAR_0, "value"); oc = object_class_dynamic_cast(object_class_by_name(g->driver), TYPE_DEVICE); if (oc) { DeviceClass *dc = DEVICE_CLASS(oc); if (dc->hotpluggable) { g->not_used = false; } else { g->not_used = true; } } else { g->not_used = true; } qdev_prop_register_global(g); return 0; }
[ "static int FUNC_0(QemuOpts *VAR_0, void *VAR_1)\n{", "GlobalProperty *g;", "ObjectClass *oc;", "g = g_malloc0(sizeof(*g));", "g->driver = qemu_opt_get(VAR_0, \"driver\");", "g->property = qemu_opt_get(VAR_0, \"property\");", "g->value = qemu_opt_get(VAR_0, \"value\");", "oc = object_class_dynamic_cast(object_class_by_name(g->driver),\nTYPE_DEVICE);", "if (oc) {", "DeviceClass *dc = DEVICE_CLASS(oc);", "if (dc->hotpluggable) {", "g->not_used = false;", "} else {", "g->not_used = true;", "}", "} else {", "g->not_used = true;", "}", "qdev_prop_register_global(g);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19, 21 ], [ 23 ], [ 25 ], [ 29 ], [ 33 ], [ 35 ], [ 39 ], [ 41 ], [ 43 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ] ]
22,152
static QObject *parse_array(JSONParserContext *ctxt, QList **tokens, va_list *ap) { QList *list = NULL; QObject *token, *peek; QList *working = qlist_copy(*tokens); token = qlist_pop(working); if (token == NULL) { goto out; } if (!token_is_operator(token, '[')) { goto out; } qobject_decref(token); token = NULL; list = qlist_new(); peek = qlist_peek(working); if (peek == NULL) { parse_error(ctxt, NULL, "premature EOI"); goto out; } if (!token_is_operator(peek, ']')) { QObject *obj; obj = parse_value(ctxt, &working, ap); if (obj == NULL) { parse_error(ctxt, token, "expecting value"); goto out; } qlist_append_obj(list, obj); token = qlist_pop(working); if (token == NULL) { parse_error(ctxt, NULL, "premature EOI"); goto out; } while (!token_is_operator(token, ']')) { if (!token_is_operator(token, ',')) { parse_error(ctxt, token, "expected separator in list"); goto out; } qobject_decref(token); token = NULL; obj = parse_value(ctxt, &working, ap); if (obj == NULL) { parse_error(ctxt, token, "expecting value"); goto out; } qlist_append_obj(list, obj); token = qlist_pop(working); if (token == NULL) { parse_error(ctxt, NULL, "premature EOI"); goto out; } } qobject_decref(token); token = NULL; } else { token = qlist_pop(working); qobject_decref(token); token = NULL; } QDECREF(*tokens); *tokens = working; return QOBJECT(list); out: qobject_decref(token); QDECREF(working); QDECREF(list); return NULL; }
false
qemu
65c0f1e9558c7c762cdb333406243fff1d687117
static QObject *parse_array(JSONParserContext *ctxt, QList **tokens, va_list *ap) { QList *list = NULL; QObject *token, *peek; QList *working = qlist_copy(*tokens); token = qlist_pop(working); if (token == NULL) { goto out; } if (!token_is_operator(token, '[')) { goto out; } qobject_decref(token); token = NULL; list = qlist_new(); peek = qlist_peek(working); if (peek == NULL) { parse_error(ctxt, NULL, "premature EOI"); goto out; } if (!token_is_operator(peek, ']')) { QObject *obj; obj = parse_value(ctxt, &working, ap); if (obj == NULL) { parse_error(ctxt, token, "expecting value"); goto out; } qlist_append_obj(list, obj); token = qlist_pop(working); if (token == NULL) { parse_error(ctxt, NULL, "premature EOI"); goto out; } while (!token_is_operator(token, ']')) { if (!token_is_operator(token, ',')) { parse_error(ctxt, token, "expected separator in list"); goto out; } qobject_decref(token); token = NULL; obj = parse_value(ctxt, &working, ap); if (obj == NULL) { parse_error(ctxt, token, "expecting value"); goto out; } qlist_append_obj(list, obj); token = qlist_pop(working); if (token == NULL) { parse_error(ctxt, NULL, "premature EOI"); goto out; } } qobject_decref(token); token = NULL; } else { token = qlist_pop(working); qobject_decref(token); token = NULL; } QDECREF(*tokens); *tokens = working; return QOBJECT(list); out: qobject_decref(token); QDECREF(working); QDECREF(list); return NULL; }
{ "code": [], "line_no": [] }
static QObject *FUNC_0(JSONParserContext *ctxt, QList **tokens, va_list *ap) { QList *list = NULL; QObject *token, *peek; QList *working = qlist_copy(*tokens); token = qlist_pop(working); if (token == NULL) { goto out; } if (!token_is_operator(token, '[')) { goto out; } qobject_decref(token); token = NULL; list = qlist_new(); peek = qlist_peek(working); if (peek == NULL) { parse_error(ctxt, NULL, "premature EOI"); goto out; } if (!token_is_operator(peek, ']')) { QObject *obj; obj = parse_value(ctxt, &working, ap); if (obj == NULL) { parse_error(ctxt, token, "expecting value"); goto out; } qlist_append_obj(list, obj); token = qlist_pop(working); if (token == NULL) { parse_error(ctxt, NULL, "premature EOI"); goto out; } while (!token_is_operator(token, ']')) { if (!token_is_operator(token, ',')) { parse_error(ctxt, token, "expected separator in list"); goto out; } qobject_decref(token); token = NULL; obj = parse_value(ctxt, &working, ap); if (obj == NULL) { parse_error(ctxt, token, "expecting value"); goto out; } qlist_append_obj(list, obj); token = qlist_pop(working); if (token == NULL) { parse_error(ctxt, NULL, "premature EOI"); goto out; } } qobject_decref(token); token = NULL; } else { token = qlist_pop(working); qobject_decref(token); token = NULL; } QDECREF(*tokens); *tokens = working; return QOBJECT(list); out: qobject_decref(token); QDECREF(working); QDECREF(list); return NULL; }
[ "static QObject *FUNC_0(JSONParserContext *ctxt, QList **tokens, va_list *ap)\n{", "QList *list = NULL;", "QObject *token, *peek;", "QList *working = qlist_copy(*tokens);", "token = qlist_pop(working);", "if (token == NULL) {", "goto out;", "}", "if (!token_is_operator(token, '[')) {", "goto out;", "}", "qobject_decref(token);", "token = NULL;", "list = qlist_new();", "peek = qlist_peek(working);", "if (peek == NULL) {", "parse_error(ctxt, NULL, \"premature EOI\");", "goto out;", "}", "if (!token_is_operator(peek, ']')) {", "QObject *obj;", "obj = parse_value(ctxt, &working, ap);", "if (obj == NULL) {", "parse_error(ctxt, token, \"expecting value\");", "goto out;", "}", "qlist_append_obj(list, obj);", "token = qlist_pop(working);", "if (token == NULL) {", "parse_error(ctxt, NULL, \"premature EOI\");", "goto out;", "}", "while (!token_is_operator(token, ']')) {", "if (!token_is_operator(token, ',')) {", "parse_error(ctxt, token, \"expected separator in list\");", "goto out;", "}", "qobject_decref(token);", "token = NULL;", "obj = parse_value(ctxt, &working, ap);", "if (obj == NULL) {", "parse_error(ctxt, token, \"expecting value\");", "goto out;", "}", "qlist_append_obj(list, obj);", "token = qlist_pop(working);", "if (token == NULL) {", "parse_error(ctxt, NULL, \"premature EOI\");", "goto out;", "}", "}", "qobject_decref(token);", "token = NULL;", "} else {", "token = qlist_pop(working);", "qobject_decref(token);", "token = NULL;", "}", "QDECREF(*tokens);", "*tokens = working;", "return QOBJECT(list);", "out:\nqobject_decref(token);", "QDECREF(working);", "QDECREF(list);", "return NULL;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 35 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 51 ], [ 53 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 69 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 97 ], [ 99 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 115 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 149 ], [ 151 ], [ 155 ], [ 159, 161 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ] ]
22,153
static int scsi_disk_emulate_command(SCSIDiskReq *r) { SCSIRequest *req = &r->req; SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, req->dev); uint64_t nb_sectors; uint8_t *outbuf; int buflen = 0; if (!r->iov.iov_base) { /* * FIXME: we shouldn't return anything bigger than 4k, but the code * requires the buffer to be as big as req->cmd.xfer in several * places. So, do not allow CDBs with a very large ALLOCATION * LENGTH. The real fix would be to modify scsi_read_data and * dma_buf_read, so that they return data beyond the buflen * as all zeros. */ if (req->cmd.xfer > 65536) { goto illegal_request; } r->buflen = MAX(4096, req->cmd.xfer); r->iov.iov_base = qemu_blockalign(s->qdev.conf.bs, r->buflen); } outbuf = r->iov.iov_base; switch (req->cmd.buf[0]) { case TEST_UNIT_READY: assert(!s->tray_open && bdrv_is_inserted(s->qdev.conf.bs)); break; case INQUIRY: buflen = scsi_disk_emulate_inquiry(req, outbuf); if (buflen < 0) { goto illegal_request; } break; case MODE_SENSE: case MODE_SENSE_10: buflen = scsi_disk_emulate_mode_sense(r, outbuf); if (buflen < 0) { goto illegal_request; } break; case READ_TOC: buflen = scsi_disk_emulate_read_toc(req, outbuf); if (buflen < 0) { goto illegal_request; } break; case RESERVE: if (req->cmd.buf[1] & 1) { goto illegal_request; } break; case RESERVE_10: if (req->cmd.buf[1] & 3) { goto illegal_request; } break; case RELEASE: if (req->cmd.buf[1] & 1) { goto illegal_request; } break; case RELEASE_10: if (req->cmd.buf[1] & 3) { goto illegal_request; } break; case START_STOP: if (scsi_disk_emulate_start_stop(r) < 0) { return -1; } break; case ALLOW_MEDIUM_REMOVAL: s->tray_locked = req->cmd.buf[4] & 1; bdrv_lock_medium(s->qdev.conf.bs, req->cmd.buf[4] & 1); break; case READ_CAPACITY_10: /* The normal LEN field for this command is zero. */ memset(outbuf, 0, 8); bdrv_get_geometry(s->qdev.conf.bs, &nb_sectors); if (!nb_sectors) { scsi_check_condition(r, SENSE_CODE(LUN_NOT_READY)); return -1; } if ((req->cmd.buf[8] & 1) == 0 && req->cmd.lba) { goto illegal_request; } nb_sectors /= s->qdev.blocksize / 512; /* Returned value is the address of the last sector. */ nb_sectors--; /* Remember the new size for read/write sanity checking. */ s->qdev.max_lba = nb_sectors; /* Clip to 2TB, instead of returning capacity modulo 2TB. */ if (nb_sectors > UINT32_MAX) { nb_sectors = UINT32_MAX; } outbuf[0] = (nb_sectors >> 24) & 0xff; outbuf[1] = (nb_sectors >> 16) & 0xff; outbuf[2] = (nb_sectors >> 8) & 0xff; outbuf[3] = nb_sectors & 0xff; outbuf[4] = 0; outbuf[5] = 0; outbuf[6] = s->qdev.blocksize >> 8; outbuf[7] = 0; buflen = 8; break; case REQUEST_SENSE: /* Just return "NO SENSE". */ buflen = scsi_build_sense(NULL, 0, outbuf, r->buflen, (req->cmd.buf[1] & 1) == 0); break; case MECHANISM_STATUS: buflen = scsi_emulate_mechanism_status(s, outbuf); if (buflen < 0) { goto illegal_request; } break; case GET_CONFIGURATION: buflen = scsi_get_configuration(s, outbuf); if (buflen < 0) { goto illegal_request; } break; case GET_EVENT_STATUS_NOTIFICATION: buflen = scsi_get_event_status_notification(s, r, outbuf); if (buflen < 0) { goto illegal_request; } break; case READ_DISC_INFORMATION: buflen = scsi_read_disc_information(s, r, outbuf); if (buflen < 0) { goto illegal_request; } break; case READ_DVD_STRUCTURE: buflen = scsi_read_dvd_structure(s, r, outbuf); if (buflen < 0) { goto illegal_request; } break; case SERVICE_ACTION_IN_16: /* Service Action In subcommands. */ if ((req->cmd.buf[1] & 31) == SAI_READ_CAPACITY_16) { DPRINTF("SAI READ CAPACITY(16)\n"); memset(outbuf, 0, req->cmd.xfer); bdrv_get_geometry(s->qdev.conf.bs, &nb_sectors); if (!nb_sectors) { scsi_check_condition(r, SENSE_CODE(LUN_NOT_READY)); return -1; } if ((req->cmd.buf[14] & 1) == 0 && req->cmd.lba) { goto illegal_request; } nb_sectors /= s->qdev.blocksize / 512; /* Returned value is the address of the last sector. */ nb_sectors--; /* Remember the new size for read/write sanity checking. */ s->qdev.max_lba = nb_sectors; outbuf[0] = (nb_sectors >> 56) & 0xff; outbuf[1] = (nb_sectors >> 48) & 0xff; outbuf[2] = (nb_sectors >> 40) & 0xff; outbuf[3] = (nb_sectors >> 32) & 0xff; outbuf[4] = (nb_sectors >> 24) & 0xff; outbuf[5] = (nb_sectors >> 16) & 0xff; outbuf[6] = (nb_sectors >> 8) & 0xff; outbuf[7] = nb_sectors & 0xff; outbuf[8] = 0; outbuf[9] = 0; outbuf[10] = s->qdev.blocksize >> 8; outbuf[11] = 0; outbuf[12] = 0; outbuf[13] = get_physical_block_exp(&s->qdev.conf); /* set TPE bit if the format supports discard */ if (s->qdev.conf.discard_granularity) { outbuf[14] = 0x80; } /* Protection, exponent and lowest lba field left blank. */ buflen = req->cmd.xfer; break; } DPRINTF("Unsupported Service Action In\n"); goto illegal_request; case SYNCHRONIZE_CACHE: /* The request is used as the AIO opaque value, so add a ref. */ scsi_req_ref(&r->req); bdrv_acct_start(s->qdev.conf.bs, &r->acct, 0, BDRV_ACCT_FLUSH); r->req.aiocb = bdrv_aio_flush(s->qdev.conf.bs, scsi_aio_complete, r); return 0; case SEEK_10: DPRINTF("Seek(10) (sector %" PRId64 ")\n", r->req.cmd.lba); if (r->req.cmd.lba > s->qdev.max_lba) { goto illegal_lba; } break; #if 0 case MODE_SELECT: DPRINTF("Mode Select(6) (len %lu)\n", (long)r->req.cmd.xfer); /* We don't support mode parameter changes. Allow the mode parameter header + block descriptors only. */ if (r->req.cmd.xfer > 12) { goto illegal_request; } break; case MODE_SELECT_10: DPRINTF("Mode Select(10) (len %lu)\n", (long)r->req.cmd.xfer); /* We don't support mode parameter changes. Allow the mode parameter header + block descriptors only. */ if (r->req.cmd.xfer > 16) { goto illegal_request; } break; #endif case WRITE_SAME_10: nb_sectors = lduw_be_p(&req->cmd.buf[7]); goto write_same; case WRITE_SAME_16: nb_sectors = ldl_be_p(&req->cmd.buf[10]) & 0xffffffffULL; write_same: if (r->req.cmd.lba > s->qdev.max_lba) { goto illegal_lba; } /* * We only support WRITE SAME with the unmap bit set for now. */ if (!(req->cmd.buf[1] & 0x8)) { goto illegal_request; } /* The request is used as the AIO opaque value, so add a ref. */ scsi_req_ref(&r->req); r->req.aiocb = bdrv_aio_discard(s->qdev.conf.bs, r->req.cmd.lba * (s->qdev.blocksize / 512), nb_sectors * (s->qdev.blocksize / 512), scsi_aio_complete, r); return 0; default: scsi_check_condition(r, SENSE_CODE(INVALID_OPCODE)); return -1; } assert(r->sector_count == 0); buflen = MIN(buflen, req->cmd.xfer); return buflen; illegal_request: if (r->req.status == -1) { scsi_check_condition(r, SENSE_CODE(INVALID_FIELD)); } return -1; illegal_lba: scsi_check_condition(r, SENSE_CODE(LBA_OUT_OF_RANGE)); return 0; }
false
qemu
b08d0ea0446aa91f373c9df4254ba3bc4ee84098
static int scsi_disk_emulate_command(SCSIDiskReq *r) { SCSIRequest *req = &r->req; SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, req->dev); uint64_t nb_sectors; uint8_t *outbuf; int buflen = 0; if (!r->iov.iov_base) { if (req->cmd.xfer > 65536) { goto illegal_request; } r->buflen = MAX(4096, req->cmd.xfer); r->iov.iov_base = qemu_blockalign(s->qdev.conf.bs, r->buflen); } outbuf = r->iov.iov_base; switch (req->cmd.buf[0]) { case TEST_UNIT_READY: assert(!s->tray_open && bdrv_is_inserted(s->qdev.conf.bs)); break; case INQUIRY: buflen = scsi_disk_emulate_inquiry(req, outbuf); if (buflen < 0) { goto illegal_request; } break; case MODE_SENSE: case MODE_SENSE_10: buflen = scsi_disk_emulate_mode_sense(r, outbuf); if (buflen < 0) { goto illegal_request; } break; case READ_TOC: buflen = scsi_disk_emulate_read_toc(req, outbuf); if (buflen < 0) { goto illegal_request; } break; case RESERVE: if (req->cmd.buf[1] & 1) { goto illegal_request; } break; case RESERVE_10: if (req->cmd.buf[1] & 3) { goto illegal_request; } break; case RELEASE: if (req->cmd.buf[1] & 1) { goto illegal_request; } break; case RELEASE_10: if (req->cmd.buf[1] & 3) { goto illegal_request; } break; case START_STOP: if (scsi_disk_emulate_start_stop(r) < 0) { return -1; } break; case ALLOW_MEDIUM_REMOVAL: s->tray_locked = req->cmd.buf[4] & 1; bdrv_lock_medium(s->qdev.conf.bs, req->cmd.buf[4] & 1); break; case READ_CAPACITY_10: memset(outbuf, 0, 8); bdrv_get_geometry(s->qdev.conf.bs, &nb_sectors); if (!nb_sectors) { scsi_check_condition(r, SENSE_CODE(LUN_NOT_READY)); return -1; } if ((req->cmd.buf[8] & 1) == 0 && req->cmd.lba) { goto illegal_request; } nb_sectors /= s->qdev.blocksize / 512; nb_sectors--; s->qdev.max_lba = nb_sectors; if (nb_sectors > UINT32_MAX) { nb_sectors = UINT32_MAX; } outbuf[0] = (nb_sectors >> 24) & 0xff; outbuf[1] = (nb_sectors >> 16) & 0xff; outbuf[2] = (nb_sectors >> 8) & 0xff; outbuf[3] = nb_sectors & 0xff; outbuf[4] = 0; outbuf[5] = 0; outbuf[6] = s->qdev.blocksize >> 8; outbuf[7] = 0; buflen = 8; break; case REQUEST_SENSE: buflen = scsi_build_sense(NULL, 0, outbuf, r->buflen, (req->cmd.buf[1] & 1) == 0); break; case MECHANISM_STATUS: buflen = scsi_emulate_mechanism_status(s, outbuf); if (buflen < 0) { goto illegal_request; } break; case GET_CONFIGURATION: buflen = scsi_get_configuration(s, outbuf); if (buflen < 0) { goto illegal_request; } break; case GET_EVENT_STATUS_NOTIFICATION: buflen = scsi_get_event_status_notification(s, r, outbuf); if (buflen < 0) { goto illegal_request; } break; case READ_DISC_INFORMATION: buflen = scsi_read_disc_information(s, r, outbuf); if (buflen < 0) { goto illegal_request; } break; case READ_DVD_STRUCTURE: buflen = scsi_read_dvd_structure(s, r, outbuf); if (buflen < 0) { goto illegal_request; } break; case SERVICE_ACTION_IN_16: if ((req->cmd.buf[1] & 31) == SAI_READ_CAPACITY_16) { DPRINTF("SAI READ CAPACITY(16)\n"); memset(outbuf, 0, req->cmd.xfer); bdrv_get_geometry(s->qdev.conf.bs, &nb_sectors); if (!nb_sectors) { scsi_check_condition(r, SENSE_CODE(LUN_NOT_READY)); return -1; } if ((req->cmd.buf[14] & 1) == 0 && req->cmd.lba) { goto illegal_request; } nb_sectors /= s->qdev.blocksize / 512; nb_sectors--; s->qdev.max_lba = nb_sectors; outbuf[0] = (nb_sectors >> 56) & 0xff; outbuf[1] = (nb_sectors >> 48) & 0xff; outbuf[2] = (nb_sectors >> 40) & 0xff; outbuf[3] = (nb_sectors >> 32) & 0xff; outbuf[4] = (nb_sectors >> 24) & 0xff; outbuf[5] = (nb_sectors >> 16) & 0xff; outbuf[6] = (nb_sectors >> 8) & 0xff; outbuf[7] = nb_sectors & 0xff; outbuf[8] = 0; outbuf[9] = 0; outbuf[10] = s->qdev.blocksize >> 8; outbuf[11] = 0; outbuf[12] = 0; outbuf[13] = get_physical_block_exp(&s->qdev.conf); if (s->qdev.conf.discard_granularity) { outbuf[14] = 0x80; } buflen = req->cmd.xfer; break; } DPRINTF("Unsupported Service Action In\n"); goto illegal_request; case SYNCHRONIZE_CACHE: scsi_req_ref(&r->req); bdrv_acct_start(s->qdev.conf.bs, &r->acct, 0, BDRV_ACCT_FLUSH); r->req.aiocb = bdrv_aio_flush(s->qdev.conf.bs, scsi_aio_complete, r); return 0; case SEEK_10: DPRINTF("Seek(10) (sector %" PRId64 ")\n", r->req.cmd.lba); if (r->req.cmd.lba > s->qdev.max_lba) { goto illegal_lba; } break; #if 0 case MODE_SELECT: DPRINTF("Mode Select(6) (len %lu)\n", (long)r->req.cmd.xfer); if (r->req.cmd.xfer > 12) { goto illegal_request; } break; case MODE_SELECT_10: DPRINTF("Mode Select(10) (len %lu)\n", (long)r->req.cmd.xfer); if (r->req.cmd.xfer > 16) { goto illegal_request; } break; #endif case WRITE_SAME_10: nb_sectors = lduw_be_p(&req->cmd.buf[7]); goto write_same; case WRITE_SAME_16: nb_sectors = ldl_be_p(&req->cmd.buf[10]) & 0xffffffffULL; write_same: if (r->req.cmd.lba > s->qdev.max_lba) { goto illegal_lba; } if (!(req->cmd.buf[1] & 0x8)) { goto illegal_request; } scsi_req_ref(&r->req); r->req.aiocb = bdrv_aio_discard(s->qdev.conf.bs, r->req.cmd.lba * (s->qdev.blocksize / 512), nb_sectors * (s->qdev.blocksize / 512), scsi_aio_complete, r); return 0; default: scsi_check_condition(r, SENSE_CODE(INVALID_OPCODE)); return -1; } assert(r->sector_count == 0); buflen = MIN(buflen, req->cmd.xfer); return buflen; illegal_request: if (r->req.status == -1) { scsi_check_condition(r, SENSE_CODE(INVALID_FIELD)); } return -1; illegal_lba: scsi_check_condition(r, SENSE_CODE(LBA_OUT_OF_RANGE)); return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(SCSIDiskReq *VAR_0) { SCSIRequest *req = &VAR_0->req; SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, req->dev); uint64_t nb_sectors; uint8_t *outbuf; int VAR_1 = 0; if (!VAR_0->iov.iov_base) { if (req->cmd.xfer > 65536) { goto illegal_request; } VAR_0->VAR_1 = MAX(4096, req->cmd.xfer); VAR_0->iov.iov_base = qemu_blockalign(s->qdev.conf.bs, VAR_0->VAR_1); } outbuf = VAR_0->iov.iov_base; switch (req->cmd.buf[0]) { case TEST_UNIT_READY: assert(!s->tray_open && bdrv_is_inserted(s->qdev.conf.bs)); break; case INQUIRY: VAR_1 = scsi_disk_emulate_inquiry(req, outbuf); if (VAR_1 < 0) { goto illegal_request; } break; case MODE_SENSE: case MODE_SENSE_10: VAR_1 = scsi_disk_emulate_mode_sense(VAR_0, outbuf); if (VAR_1 < 0) { goto illegal_request; } break; case READ_TOC: VAR_1 = scsi_disk_emulate_read_toc(req, outbuf); if (VAR_1 < 0) { goto illegal_request; } break; case RESERVE: if (req->cmd.buf[1] & 1) { goto illegal_request; } break; case RESERVE_10: if (req->cmd.buf[1] & 3) { goto illegal_request; } break; case RELEASE: if (req->cmd.buf[1] & 1) { goto illegal_request; } break; case RELEASE_10: if (req->cmd.buf[1] & 3) { goto illegal_request; } break; case START_STOP: if (scsi_disk_emulate_start_stop(VAR_0) < 0) { return -1; } break; case ALLOW_MEDIUM_REMOVAL: s->tray_locked = req->cmd.buf[4] & 1; bdrv_lock_medium(s->qdev.conf.bs, req->cmd.buf[4] & 1); break; case READ_CAPACITY_10: memset(outbuf, 0, 8); bdrv_get_geometry(s->qdev.conf.bs, &nb_sectors); if (!nb_sectors) { scsi_check_condition(VAR_0, SENSE_CODE(LUN_NOT_READY)); return -1; } if ((req->cmd.buf[8] & 1) == 0 && req->cmd.lba) { goto illegal_request; } nb_sectors /= s->qdev.blocksize / 512; nb_sectors--; s->qdev.max_lba = nb_sectors; if (nb_sectors > UINT32_MAX) { nb_sectors = UINT32_MAX; } outbuf[0] = (nb_sectors >> 24) & 0xff; outbuf[1] = (nb_sectors >> 16) & 0xff; outbuf[2] = (nb_sectors >> 8) & 0xff; outbuf[3] = nb_sectors & 0xff; outbuf[4] = 0; outbuf[5] = 0; outbuf[6] = s->qdev.blocksize >> 8; outbuf[7] = 0; VAR_1 = 8; break; case REQUEST_SENSE: VAR_1 = scsi_build_sense(NULL, 0, outbuf, VAR_0->VAR_1, (req->cmd.buf[1] & 1) == 0); break; case MECHANISM_STATUS: VAR_1 = scsi_emulate_mechanism_status(s, outbuf); if (VAR_1 < 0) { goto illegal_request; } break; case GET_CONFIGURATION: VAR_1 = scsi_get_configuration(s, outbuf); if (VAR_1 < 0) { goto illegal_request; } break; case GET_EVENT_STATUS_NOTIFICATION: VAR_1 = scsi_get_event_status_notification(s, VAR_0, outbuf); if (VAR_1 < 0) { goto illegal_request; } break; case READ_DISC_INFORMATION: VAR_1 = scsi_read_disc_information(s, VAR_0, outbuf); if (VAR_1 < 0) { goto illegal_request; } break; case READ_DVD_STRUCTURE: VAR_1 = scsi_read_dvd_structure(s, VAR_0, outbuf); if (VAR_1 < 0) { goto illegal_request; } break; case SERVICE_ACTION_IN_16: if ((req->cmd.buf[1] & 31) == SAI_READ_CAPACITY_16) { DPRINTF("SAI READ CAPACITY(16)\n"); memset(outbuf, 0, req->cmd.xfer); bdrv_get_geometry(s->qdev.conf.bs, &nb_sectors); if (!nb_sectors) { scsi_check_condition(VAR_0, SENSE_CODE(LUN_NOT_READY)); return -1; } if ((req->cmd.buf[14] & 1) == 0 && req->cmd.lba) { goto illegal_request; } nb_sectors /= s->qdev.blocksize / 512; nb_sectors--; s->qdev.max_lba = nb_sectors; outbuf[0] = (nb_sectors >> 56) & 0xff; outbuf[1] = (nb_sectors >> 48) & 0xff; outbuf[2] = (nb_sectors >> 40) & 0xff; outbuf[3] = (nb_sectors >> 32) & 0xff; outbuf[4] = (nb_sectors >> 24) & 0xff; outbuf[5] = (nb_sectors >> 16) & 0xff; outbuf[6] = (nb_sectors >> 8) & 0xff; outbuf[7] = nb_sectors & 0xff; outbuf[8] = 0; outbuf[9] = 0; outbuf[10] = s->qdev.blocksize >> 8; outbuf[11] = 0; outbuf[12] = 0; outbuf[13] = get_physical_block_exp(&s->qdev.conf); if (s->qdev.conf.discard_granularity) { outbuf[14] = 0x80; } VAR_1 = req->cmd.xfer; break; } DPRINTF("Unsupported Service Action In\n"); goto illegal_request; case SYNCHRONIZE_CACHE: scsi_req_ref(&VAR_0->req); bdrv_acct_start(s->qdev.conf.bs, &VAR_0->acct, 0, BDRV_ACCT_FLUSH); VAR_0->req.aiocb = bdrv_aio_flush(s->qdev.conf.bs, scsi_aio_complete, VAR_0); return 0; case SEEK_10: DPRINTF("Seek(10) (sector %" PRId64 ")\n", VAR_0->req.cmd.lba); if (VAR_0->req.cmd.lba > s->qdev.max_lba) { goto illegal_lba; } break; #if 0 case MODE_SELECT: DPRINTF("Mode Select(6) (len %lu)\n", (long)VAR_0->req.cmd.xfer); if (VAR_0->req.cmd.xfer > 12) { goto illegal_request; } break; case MODE_SELECT_10: DPRINTF("Mode Select(10) (len %lu)\n", (long)VAR_0->req.cmd.xfer); if (VAR_0->req.cmd.xfer > 16) { goto illegal_request; } break; #endif case WRITE_SAME_10: nb_sectors = lduw_be_p(&req->cmd.buf[7]); goto write_same; case WRITE_SAME_16: nb_sectors = ldl_be_p(&req->cmd.buf[10]) & 0xffffffffULL; write_same: if (VAR_0->req.cmd.lba > s->qdev.max_lba) { goto illegal_lba; } if (!(req->cmd.buf[1] & 0x8)) { goto illegal_request; } scsi_req_ref(&VAR_0->req); VAR_0->req.aiocb = bdrv_aio_discard(s->qdev.conf.bs, VAR_0->req.cmd.lba * (s->qdev.blocksize / 512), nb_sectors * (s->qdev.blocksize / 512), scsi_aio_complete, VAR_0); return 0; default: scsi_check_condition(VAR_0, SENSE_CODE(INVALID_OPCODE)); return -1; } assert(VAR_0->sector_count == 0); VAR_1 = MIN(VAR_1, req->cmd.xfer); return VAR_1; illegal_request: if (VAR_0->req.status == -1) { scsi_check_condition(VAR_0, SENSE_CODE(INVALID_FIELD)); } return -1; illegal_lba: scsi_check_condition(VAR_0, SENSE_CODE(LBA_OUT_OF_RANGE)); return 0; }
[ "static int FUNC_0(SCSIDiskReq *VAR_0)\n{", "SCSIRequest *req = &VAR_0->req;", "SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, req->dev);", "uint64_t nb_sectors;", "uint8_t *outbuf;", "int VAR_1 = 0;", "if (!VAR_0->iov.iov_base) {", "if (req->cmd.xfer > 65536) {", "goto illegal_request;", "}", "VAR_0->VAR_1 = MAX(4096, req->cmd.xfer);", "VAR_0->iov.iov_base = qemu_blockalign(s->qdev.conf.bs, VAR_0->VAR_1);", "}", "outbuf = VAR_0->iov.iov_base;", "switch (req->cmd.buf[0]) {", "case TEST_UNIT_READY:\nassert(!s->tray_open && bdrv_is_inserted(s->qdev.conf.bs));", "break;", "case INQUIRY:\nVAR_1 = scsi_disk_emulate_inquiry(req, outbuf);", "if (VAR_1 < 0) {", "goto illegal_request;", "}", "break;", "case MODE_SENSE:\ncase MODE_SENSE_10:\nVAR_1 = scsi_disk_emulate_mode_sense(VAR_0, outbuf);", "if (VAR_1 < 0) {", "goto illegal_request;", "}", "break;", "case READ_TOC:\nVAR_1 = scsi_disk_emulate_read_toc(req, outbuf);", "if (VAR_1 < 0) {", "goto illegal_request;", "}", "break;", "case RESERVE:\nif (req->cmd.buf[1] & 1) {", "goto illegal_request;", "}", "break;", "case RESERVE_10:\nif (req->cmd.buf[1] & 3) {", "goto illegal_request;", "}", "break;", "case RELEASE:\nif (req->cmd.buf[1] & 1) {", "goto illegal_request;", "}", "break;", "case RELEASE_10:\nif (req->cmd.buf[1] & 3) {", "goto illegal_request;", "}", "break;", "case START_STOP:\nif (scsi_disk_emulate_start_stop(VAR_0) < 0) {", "return -1;", "}", "break;", "case ALLOW_MEDIUM_REMOVAL:\ns->tray_locked = req->cmd.buf[4] & 1;", "bdrv_lock_medium(s->qdev.conf.bs, req->cmd.buf[4] & 1);", "break;", "case READ_CAPACITY_10:\nmemset(outbuf, 0, 8);", "bdrv_get_geometry(s->qdev.conf.bs, &nb_sectors);", "if (!nb_sectors) {", "scsi_check_condition(VAR_0, SENSE_CODE(LUN_NOT_READY));", "return -1;", "}", "if ((req->cmd.buf[8] & 1) == 0 && req->cmd.lba) {", "goto illegal_request;", "}", "nb_sectors /= s->qdev.blocksize / 512;", "nb_sectors--;", "s->qdev.max_lba = nb_sectors;", "if (nb_sectors > UINT32_MAX) {", "nb_sectors = UINT32_MAX;", "}", "outbuf[0] = (nb_sectors >> 24) & 0xff;", "outbuf[1] = (nb_sectors >> 16) & 0xff;", "outbuf[2] = (nb_sectors >> 8) & 0xff;", "outbuf[3] = nb_sectors & 0xff;", "outbuf[4] = 0;", "outbuf[5] = 0;", "outbuf[6] = s->qdev.blocksize >> 8;", "outbuf[7] = 0;", "VAR_1 = 8;", "break;", "case REQUEST_SENSE:\nVAR_1 = scsi_build_sense(NULL, 0, outbuf, VAR_0->VAR_1,\n(req->cmd.buf[1] & 1) == 0);", "break;", "case MECHANISM_STATUS:\nVAR_1 = scsi_emulate_mechanism_status(s, outbuf);", "if (VAR_1 < 0) {", "goto illegal_request;", "}", "break;", "case GET_CONFIGURATION:\nVAR_1 = scsi_get_configuration(s, outbuf);", "if (VAR_1 < 0) {", "goto illegal_request;", "}", "break;", "case GET_EVENT_STATUS_NOTIFICATION:\nVAR_1 = scsi_get_event_status_notification(s, VAR_0, outbuf);", "if (VAR_1 < 0) {", "goto illegal_request;", "}", "break;", "case READ_DISC_INFORMATION:\nVAR_1 = scsi_read_disc_information(s, VAR_0, outbuf);", "if (VAR_1 < 0) {", "goto illegal_request;", "}", "break;", "case READ_DVD_STRUCTURE:\nVAR_1 = scsi_read_dvd_structure(s, VAR_0, outbuf);", "if (VAR_1 < 0) {", "goto illegal_request;", "}", "break;", "case SERVICE_ACTION_IN_16:\nif ((req->cmd.buf[1] & 31) == SAI_READ_CAPACITY_16) {", "DPRINTF(\"SAI READ CAPACITY(16)\\n\");", "memset(outbuf, 0, req->cmd.xfer);", "bdrv_get_geometry(s->qdev.conf.bs, &nb_sectors);", "if (!nb_sectors) {", "scsi_check_condition(VAR_0, SENSE_CODE(LUN_NOT_READY));", "return -1;", "}", "if ((req->cmd.buf[14] & 1) == 0 && req->cmd.lba) {", "goto illegal_request;", "}", "nb_sectors /= s->qdev.blocksize / 512;", "nb_sectors--;", "s->qdev.max_lba = nb_sectors;", "outbuf[0] = (nb_sectors >> 56) & 0xff;", "outbuf[1] = (nb_sectors >> 48) & 0xff;", "outbuf[2] = (nb_sectors >> 40) & 0xff;", "outbuf[3] = (nb_sectors >> 32) & 0xff;", "outbuf[4] = (nb_sectors >> 24) & 0xff;", "outbuf[5] = (nb_sectors >> 16) & 0xff;", "outbuf[6] = (nb_sectors >> 8) & 0xff;", "outbuf[7] = nb_sectors & 0xff;", "outbuf[8] = 0;", "outbuf[9] = 0;", "outbuf[10] = s->qdev.blocksize >> 8;", "outbuf[11] = 0;", "outbuf[12] = 0;", "outbuf[13] = get_physical_block_exp(&s->qdev.conf);", "if (s->qdev.conf.discard_granularity) {", "outbuf[14] = 0x80;", "}", "VAR_1 = req->cmd.xfer;", "break;", "}", "DPRINTF(\"Unsupported Service Action In\\n\");", "goto illegal_request;", "case SYNCHRONIZE_CACHE:\nscsi_req_ref(&VAR_0->req);", "bdrv_acct_start(s->qdev.conf.bs, &VAR_0->acct, 0, BDRV_ACCT_FLUSH);", "VAR_0->req.aiocb = bdrv_aio_flush(s->qdev.conf.bs, scsi_aio_complete, VAR_0);", "return 0;", "case SEEK_10:\nDPRINTF(\"Seek(10) (sector %\" PRId64 \")\\n\", VAR_0->req.cmd.lba);", "if (VAR_0->req.cmd.lba > s->qdev.max_lba) {", "goto illegal_lba;", "}", "break;", "#if 0\ncase MODE_SELECT:\nDPRINTF(\"Mode Select(6) (len %lu)\\n\", (long)VAR_0->req.cmd.xfer);", "if (VAR_0->req.cmd.xfer > 12) {", "goto illegal_request;", "}", "break;", "case MODE_SELECT_10:\nDPRINTF(\"Mode Select(10) (len %lu)\\n\", (long)VAR_0->req.cmd.xfer);", "if (VAR_0->req.cmd.xfer > 16) {", "goto illegal_request;", "}", "break;", "#endif\ncase WRITE_SAME_10:\nnb_sectors = lduw_be_p(&req->cmd.buf[7]);", "goto write_same;", "case WRITE_SAME_16:\nnb_sectors = ldl_be_p(&req->cmd.buf[10]) & 0xffffffffULL;", "write_same:\nif (VAR_0->req.cmd.lba > s->qdev.max_lba) {", "goto illegal_lba;", "}", "if (!(req->cmd.buf[1] & 0x8)) {", "goto illegal_request;", "}", "scsi_req_ref(&VAR_0->req);", "VAR_0->req.aiocb = bdrv_aio_discard(s->qdev.conf.bs,\nVAR_0->req.cmd.lba * (s->qdev.blocksize / 512),\nnb_sectors * (s->qdev.blocksize / 512),\nscsi_aio_complete, VAR_0);", "return 0;", "default:\nscsi_check_condition(VAR_0, SENSE_CODE(INVALID_OPCODE));", "return -1;", "}", "assert(VAR_0->sector_count == 0);", "VAR_1 = MIN(VAR_1, req->cmd.xfer);", "return VAR_1;", "illegal_request:\nif (VAR_0->req.status == -1) {", "scsi_check_condition(VAR_0, SENSE_CODE(INVALID_FIELD));", "}", "return -1;", "illegal_lba:\nscsi_check_condition(VAR_0, SENSE_CODE(LBA_OUT_OF_RANGE));", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 49 ], [ 51 ], [ 53, 55 ], [ 57 ], [ 59, 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71, 73, 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85, 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97, 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107, 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117, 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127, 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137, 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147, 149 ], [ 151 ], [ 153 ], [ 155, 159 ], [ 161 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 175 ], [ 177 ], [ 181 ], [ 185 ], [ 189 ], [ 191 ], [ 193 ], [ 195 ], [ 197 ], [ 199 ], [ 201 ], [ 203 ], [ 205 ], [ 207 ], [ 209 ], [ 211 ], [ 213 ], [ 215, 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, 289 ], [ 291 ], [ 293 ], [ 295 ], [ 297 ], [ 299 ], [ 301 ], [ 303 ], [ 305 ], [ 307 ], [ 309 ], [ 311 ], [ 315 ], [ 319 ], [ 321 ], [ 323 ], [ 325 ], [ 327 ], [ 329 ], [ 331 ], [ 333 ], [ 335 ], [ 337 ], [ 339 ], [ 341 ], [ 343 ], [ 345 ], [ 347 ], [ 353 ], [ 355 ], [ 357 ], [ 363 ], [ 365 ], [ 367 ], [ 369 ], [ 371 ], [ 373, 377 ], [ 379 ], [ 381 ], [ 383 ], [ 385, 387 ], [ 389 ], [ 391 ], [ 393 ], [ 395 ], [ 397, 399, 401 ], [ 407 ], [ 409 ], [ 411 ], [ 413 ], [ 415, 417 ], [ 423 ], [ 425 ], [ 427 ], [ 429 ], [ 431, 433, 435 ], [ 437 ], [ 439, 441 ], [ 443, 445 ], [ 447 ], [ 449 ], [ 459 ], [ 461 ], [ 463 ], [ 469 ], [ 471, 473, 475, 477 ], [ 479 ], [ 481, 483 ], [ 485 ], [ 487 ], [ 489 ], [ 491 ], [ 493 ], [ 497, 499 ], [ 501 ], [ 503 ], [ 505 ], [ 509, 511 ], [ 513 ], [ 515 ] ]
22,154
void qbus_create_inplace(BusState *bus, BusInfo *info, DeviceState *parent, const char *name) { char *buf; int i,len; bus->info = info; bus->parent = parent; if (name) { /* use supplied name */ bus->name = qemu_strdup(name); } else if (parent && parent->id) { /* parent device has id -> use it for bus name */ len = strlen(parent->id) + 16; buf = qemu_malloc(len); snprintf(buf, len, "%s.%d", parent->id, parent->num_child_bus); bus->name = buf; } else { /* no id -> use lowercase bus type for bus name */ len = strlen(info->name) + 16; buf = qemu_malloc(len); len = snprintf(buf, len, "%s.%d", info->name, parent ? parent->num_child_bus : 0); for (i = 0; i < len; i++) buf[i] = qemu_tolower(buf[i]); bus->name = buf; } QLIST_INIT(&bus->children); if (parent) { QLIST_INSERT_HEAD(&parent->child_bus, bus, sibling); parent->num_child_bus++; } }
false
qemu
80376c3fc2c38fdd45354e4b0eb45031f35587ed
void qbus_create_inplace(BusState *bus, BusInfo *info, DeviceState *parent, const char *name) { char *buf; int i,len; bus->info = info; bus->parent = parent; if (name) { bus->name = qemu_strdup(name); } else if (parent && parent->id) { len = strlen(parent->id) + 16; buf = qemu_malloc(len); snprintf(buf, len, "%s.%d", parent->id, parent->num_child_bus); bus->name = buf; } else { len = strlen(info->name) + 16; buf = qemu_malloc(len); len = snprintf(buf, len, "%s.%d", info->name, parent ? parent->num_child_bus : 0); for (i = 0; i < len; i++) buf[i] = qemu_tolower(buf[i]); bus->name = buf; } QLIST_INIT(&bus->children); if (parent) { QLIST_INSERT_HEAD(&parent->child_bus, bus, sibling); parent->num_child_bus++; } }
{ "code": [], "line_no": [] }
void FUNC_0(BusState *VAR_0, BusInfo *VAR_1, DeviceState *VAR_2, const char *VAR_3) { char *VAR_4; int VAR_5,VAR_6; VAR_0->VAR_1 = VAR_1; VAR_0->VAR_2 = VAR_2; if (VAR_3) { VAR_0->VAR_3 = qemu_strdup(VAR_3); } else if (VAR_2 && VAR_2->id) { VAR_6 = strlen(VAR_2->id) + 16; VAR_4 = qemu_malloc(VAR_6); snprintf(VAR_4, VAR_6, "%s.%d", VAR_2->id, VAR_2->num_child_bus); VAR_0->VAR_3 = VAR_4; } else { VAR_6 = strlen(VAR_1->VAR_3) + 16; VAR_4 = qemu_malloc(VAR_6); VAR_6 = snprintf(VAR_4, VAR_6, "%s.%d", VAR_1->VAR_3, VAR_2 ? VAR_2->num_child_bus : 0); for (VAR_5 = 0; VAR_5 < VAR_6; VAR_5++) VAR_4[VAR_5] = qemu_tolower(VAR_4[VAR_5]); VAR_0->VAR_3 = VAR_4; } QLIST_INIT(&VAR_0->children); if (VAR_2) { QLIST_INSERT_HEAD(&VAR_2->child_bus, VAR_0, sibling); VAR_2->num_child_bus++; } }
[ "void FUNC_0(BusState *VAR_0, BusInfo *VAR_1,\nDeviceState *VAR_2, const char *VAR_3)\n{", "char *VAR_4;", "int VAR_5,VAR_6;", "VAR_0->VAR_1 = VAR_1;", "VAR_0->VAR_2 = VAR_2;", "if (VAR_3) {", "VAR_0->VAR_3 = qemu_strdup(VAR_3);", "} else if (VAR_2 && VAR_2->id) {", "VAR_6 = strlen(VAR_2->id) + 16;", "VAR_4 = qemu_malloc(VAR_6);", "snprintf(VAR_4, VAR_6, \"%s.%d\", VAR_2->id, VAR_2->num_child_bus);", "VAR_0->VAR_3 = VAR_4;", "} else {", "VAR_6 = strlen(VAR_1->VAR_3) + 16;", "VAR_4 = qemu_malloc(VAR_6);", "VAR_6 = snprintf(VAR_4, VAR_6, \"%s.%d\", VAR_1->VAR_3,\nVAR_2 ? VAR_2->num_child_bus : 0);", "for (VAR_5 = 0; VAR_5 < VAR_6; VAR_5++)", "VAR_4[VAR_5] = qemu_tolower(VAR_4[VAR_5]);", "VAR_0->VAR_3 = VAR_4;", "}", "QLIST_INIT(&VAR_0->children);", "if (VAR_2) {", "QLIST_INSERT_HEAD(&VAR_2->child_bus, VAR_0, sibling);", "VAR_2->num_child_bus++;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 19 ], [ 23 ], [ 25 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 41 ], [ 43 ], [ 45, 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 71 ] ]
22,156
int qcow2_cache_put(BlockDriverState *bs, Qcow2Cache *c, void **table) { int i = qcow2_cache_get_table_idx(bs, c, *table); if (c->entries[i].offset == 0) { return -ENOENT; } c->entries[i].ref--; *table = NULL; if (c->entries[i].ref == 0) { c->entries[i].lru_counter = ++c->lru_counter; } assert(c->entries[i].ref >= 0); return 0; }
false
qemu
a3f1afb43a09e4577571c044c48f2ba9e6e4ad06
int qcow2_cache_put(BlockDriverState *bs, Qcow2Cache *c, void **table) { int i = qcow2_cache_get_table_idx(bs, c, *table); if (c->entries[i].offset == 0) { return -ENOENT; } c->entries[i].ref--; *table = NULL; if (c->entries[i].ref == 0) { c->entries[i].lru_counter = ++c->lru_counter; } assert(c->entries[i].ref >= 0); return 0; }
{ "code": [], "line_no": [] }
int FUNC_0(BlockDriverState *VAR_0, Qcow2Cache *VAR_1, void **VAR_2) { int VAR_3 = qcow2_cache_get_table_idx(VAR_0, VAR_1, *VAR_2); if (VAR_1->entries[VAR_3].offset == 0) { return -ENOENT; } VAR_1->entries[VAR_3].ref--; *VAR_2 = NULL; if (VAR_1->entries[VAR_3].ref == 0) { VAR_1->entries[VAR_3].lru_counter = ++VAR_1->lru_counter; } assert(VAR_1->entries[VAR_3].ref >= 0); return 0; }
[ "int FUNC_0(BlockDriverState *VAR_0, Qcow2Cache *VAR_1, void **VAR_2)\n{", "int VAR_3 = qcow2_cache_get_table_idx(VAR_0, VAR_1, *VAR_2);", "if (VAR_1->entries[VAR_3].offset == 0) {", "return -ENOENT;", "}", "VAR_1->entries[VAR_3].ref--;", "*VAR_2 = NULL;", "if (VAR_1->entries[VAR_3].ref == 0) {", "VAR_1->entries[VAR_3].lru_counter = ++VAR_1->lru_counter;", "}", "assert(VAR_1->entries[VAR_3].ref >= 0);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ], [ 27 ], [ 31 ], [ 33 ], [ 35 ] ]
22,157
void gen_intermediate_code_internal(LM32CPU *cpu, TranslationBlock *tb, bool search_pc) { CPUState *cs = CPU(cpu); CPULM32State *env = &cpu->env; struct DisasContext ctx, *dc = &ctx; uint16_t *gen_opc_end; uint32_t pc_start; int j, lj; uint32_t next_page_start; int num_insns; int max_insns; pc_start = tb->pc; dc->features = cpu->features; dc->num_breakpoints = cpu->num_breakpoints; dc->num_watchpoints = cpu->num_watchpoints; dc->tb = tb; gen_opc_end = tcg_ctx.gen_opc_buf + OPC_MAX_SIZE; dc->is_jmp = DISAS_NEXT; dc->pc = pc_start; dc->singlestep_enabled = cs->singlestep_enabled; if (pc_start & 3) { qemu_log_mask(LOG_GUEST_ERROR, "unaligned PC=%x. Ignoring lowest bits.\n", pc_start); pc_start &= ~3; } next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; lj = -1; num_insns = 0; max_insns = tb->cflags & CF_COUNT_MASK; if (max_insns == 0) { max_insns = CF_COUNT_MASK; } gen_tb_start(); do { check_breakpoint(env, dc); if (search_pc) { j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf; if (lj < j) { lj++; while (lj < j) { tcg_ctx.gen_opc_instr_start[lj++] = 0; } } tcg_ctx.gen_opc_pc[lj] = dc->pc; tcg_ctx.gen_opc_instr_start[lj] = 1; tcg_ctx.gen_opc_icount[lj] = num_insns; } /* Pretty disas. */ LOG_DIS("%8.8x:\t", dc->pc); if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO)) { gen_io_start(); } decode(dc, cpu_ldl_code(env, dc->pc)); dc->pc += 4; num_insns++; } while (!dc->is_jmp && tcg_ctx.gen_opc_ptr < gen_opc_end && !cs->singlestep_enabled && !singlestep && (dc->pc < next_page_start) && num_insns < max_insns); if (tb->cflags & CF_LAST_IO) { gen_io_end(); } if (unlikely(cs->singlestep_enabled)) { if (dc->is_jmp == DISAS_NEXT) { tcg_gen_movi_tl(cpu_pc, dc->pc); } t_gen_raise_exception(dc, EXCP_DEBUG); } else { switch (dc->is_jmp) { case DISAS_NEXT: gen_goto_tb(dc, 1, dc->pc); break; default: case DISAS_JUMP: case DISAS_UPDATE: /* indicate that the hash table must be used to find the next TB */ tcg_gen_exit_tb(0); break; case DISAS_TB_JUMP: /* nothing more to generate */ break; } } gen_tb_end(tb, num_insns); *tcg_ctx.gen_opc_ptr = INDEX_op_end; if (search_pc) { j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf; lj++; while (lj <= j) { tcg_ctx.gen_opc_instr_start[lj++] = 0; } } else { tb->size = dc->pc - pc_start; tb->icount = num_insns; } #ifdef DEBUG_DISAS if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) { qemu_log("\n"); log_target_disas(env, pc_start, dc->pc - pc_start, 0); qemu_log("\nisize=%d osize=%td\n", dc->pc - pc_start, tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf); } #endif }
false
qemu
cd42d5b23691ad73edfd6dbcfc935a960a9c5a65
void gen_intermediate_code_internal(LM32CPU *cpu, TranslationBlock *tb, bool search_pc) { CPUState *cs = CPU(cpu); CPULM32State *env = &cpu->env; struct DisasContext ctx, *dc = &ctx; uint16_t *gen_opc_end; uint32_t pc_start; int j, lj; uint32_t next_page_start; int num_insns; int max_insns; pc_start = tb->pc; dc->features = cpu->features; dc->num_breakpoints = cpu->num_breakpoints; dc->num_watchpoints = cpu->num_watchpoints; dc->tb = tb; gen_opc_end = tcg_ctx.gen_opc_buf + OPC_MAX_SIZE; dc->is_jmp = DISAS_NEXT; dc->pc = pc_start; dc->singlestep_enabled = cs->singlestep_enabled; if (pc_start & 3) { qemu_log_mask(LOG_GUEST_ERROR, "unaligned PC=%x. Ignoring lowest bits.\n", pc_start); pc_start &= ~3; } next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; lj = -1; num_insns = 0; max_insns = tb->cflags & CF_COUNT_MASK; if (max_insns == 0) { max_insns = CF_COUNT_MASK; } gen_tb_start(); do { check_breakpoint(env, dc); if (search_pc) { j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf; if (lj < j) { lj++; while (lj < j) { tcg_ctx.gen_opc_instr_start[lj++] = 0; } } tcg_ctx.gen_opc_pc[lj] = dc->pc; tcg_ctx.gen_opc_instr_start[lj] = 1; tcg_ctx.gen_opc_icount[lj] = num_insns; } LOG_DIS("%8.8x:\t", dc->pc); if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO)) { gen_io_start(); } decode(dc, cpu_ldl_code(env, dc->pc)); dc->pc += 4; num_insns++; } while (!dc->is_jmp && tcg_ctx.gen_opc_ptr < gen_opc_end && !cs->singlestep_enabled && !singlestep && (dc->pc < next_page_start) && num_insns < max_insns); if (tb->cflags & CF_LAST_IO) { gen_io_end(); } if (unlikely(cs->singlestep_enabled)) { if (dc->is_jmp == DISAS_NEXT) { tcg_gen_movi_tl(cpu_pc, dc->pc); } t_gen_raise_exception(dc, EXCP_DEBUG); } else { switch (dc->is_jmp) { case DISAS_NEXT: gen_goto_tb(dc, 1, dc->pc); break; default: case DISAS_JUMP: case DISAS_UPDATE: tcg_gen_exit_tb(0); break; case DISAS_TB_JUMP: break; } } gen_tb_end(tb, num_insns); *tcg_ctx.gen_opc_ptr = INDEX_op_end; if (search_pc) { j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf; lj++; while (lj <= j) { tcg_ctx.gen_opc_instr_start[lj++] = 0; } } else { tb->size = dc->pc - pc_start; tb->icount = num_insns; } #ifdef DEBUG_DISAS if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) { qemu_log("\n"); log_target_disas(env, pc_start, dc->pc - pc_start, 0); qemu_log("\nisize=%d osize=%td\n", dc->pc - pc_start, tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf); } #endif }
{ "code": [], "line_no": [] }
void FUNC_0(LM32CPU *VAR_0, TranslationBlock *VAR_1, bool VAR_2) { CPUState *cs = CPU(VAR_0); CPULM32State *env = &VAR_0->env; struct DisasContext VAR_3, *VAR_4 = &VAR_3; uint16_t *gen_opc_end; uint32_t pc_start; int VAR_5, VAR_6; uint32_t next_page_start; int VAR_7; int VAR_8; pc_start = VAR_1->pc; VAR_4->features = VAR_0->features; VAR_4->num_breakpoints = VAR_0->num_breakpoints; VAR_4->num_watchpoints = VAR_0->num_watchpoints; VAR_4->VAR_1 = VAR_1; gen_opc_end = tcg_ctx.gen_opc_buf + OPC_MAX_SIZE; VAR_4->is_jmp = DISAS_NEXT; VAR_4->pc = pc_start; VAR_4->singlestep_enabled = cs->singlestep_enabled; if (pc_start & 3) { qemu_log_mask(LOG_GUEST_ERROR, "unaligned PC=%x. Ignoring lowest bits.\n", pc_start); pc_start &= ~3; } next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; VAR_6 = -1; VAR_7 = 0; VAR_8 = VAR_1->cflags & CF_COUNT_MASK; if (VAR_8 == 0) { VAR_8 = CF_COUNT_MASK; } gen_tb_start(); do { check_breakpoint(env, VAR_4); if (VAR_2) { VAR_5 = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf; if (VAR_6 < VAR_5) { VAR_6++; while (VAR_6 < VAR_5) { tcg_ctx.gen_opc_instr_start[VAR_6++] = 0; } } tcg_ctx.gen_opc_pc[VAR_6] = VAR_4->pc; tcg_ctx.gen_opc_instr_start[VAR_6] = 1; tcg_ctx.gen_opc_icount[VAR_6] = VAR_7; } LOG_DIS("%8.8x:\t", VAR_4->pc); if (VAR_7 + 1 == VAR_8 && (VAR_1->cflags & CF_LAST_IO)) { gen_io_start(); } decode(VAR_4, cpu_ldl_code(env, VAR_4->pc)); VAR_4->pc += 4; VAR_7++; } while (!VAR_4->is_jmp && tcg_ctx.gen_opc_ptr < gen_opc_end && !cs->singlestep_enabled && !singlestep && (VAR_4->pc < next_page_start) && VAR_7 < VAR_8); if (VAR_1->cflags & CF_LAST_IO) { gen_io_end(); } if (unlikely(cs->singlestep_enabled)) { if (VAR_4->is_jmp == DISAS_NEXT) { tcg_gen_movi_tl(cpu_pc, VAR_4->pc); } t_gen_raise_exception(VAR_4, EXCP_DEBUG); } else { switch (VAR_4->is_jmp) { case DISAS_NEXT: gen_goto_tb(VAR_4, 1, VAR_4->pc); break; default: case DISAS_JUMP: case DISAS_UPDATE: tcg_gen_exit_tb(0); break; case DISAS_TB_JUMP: break; } } gen_tb_end(VAR_1, VAR_7); *tcg_ctx.gen_opc_ptr = INDEX_op_end; if (VAR_2) { VAR_5 = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf; VAR_6++; while (VAR_6 <= VAR_5) { tcg_ctx.gen_opc_instr_start[VAR_6++] = 0; } } else { VAR_1->size = VAR_4->pc - pc_start; VAR_1->icount = VAR_7; } #ifdef DEBUG_DISAS if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) { qemu_log("\n"); log_target_disas(env, pc_start, VAR_4->pc - pc_start, 0); qemu_log("\nisize=%d osize=%td\n", VAR_4->pc - pc_start, tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf); } #endif }
[ "void FUNC_0(LM32CPU *VAR_0,\nTranslationBlock *VAR_1, bool VAR_2)\n{", "CPUState *cs = CPU(VAR_0);", "CPULM32State *env = &VAR_0->env;", "struct DisasContext VAR_3, *VAR_4 = &VAR_3;", "uint16_t *gen_opc_end;", "uint32_t pc_start;", "int VAR_5, VAR_6;", "uint32_t next_page_start;", "int VAR_7;", "int VAR_8;", "pc_start = VAR_1->pc;", "VAR_4->features = VAR_0->features;", "VAR_4->num_breakpoints = VAR_0->num_breakpoints;", "VAR_4->num_watchpoints = VAR_0->num_watchpoints;", "VAR_4->VAR_1 = VAR_1;", "gen_opc_end = tcg_ctx.gen_opc_buf + OPC_MAX_SIZE;", "VAR_4->is_jmp = DISAS_NEXT;", "VAR_4->pc = pc_start;", "VAR_4->singlestep_enabled = cs->singlestep_enabled;", "if (pc_start & 3) {", "qemu_log_mask(LOG_GUEST_ERROR,\n\"unaligned PC=%x. Ignoring lowest bits.\\n\", pc_start);", "pc_start &= ~3;", "}", "next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE;", "VAR_6 = -1;", "VAR_7 = 0;", "VAR_8 = VAR_1->cflags & CF_COUNT_MASK;", "if (VAR_8 == 0) {", "VAR_8 = CF_COUNT_MASK;", "}", "gen_tb_start();", "do {", "check_breakpoint(env, VAR_4);", "if (VAR_2) {", "VAR_5 = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;", "if (VAR_6 < VAR_5) {", "VAR_6++;", "while (VAR_6 < VAR_5) {", "tcg_ctx.gen_opc_instr_start[VAR_6++] = 0;", "}", "}", "tcg_ctx.gen_opc_pc[VAR_6] = VAR_4->pc;", "tcg_ctx.gen_opc_instr_start[VAR_6] = 1;", "tcg_ctx.gen_opc_icount[VAR_6] = VAR_7;", "}", "LOG_DIS(\"%8.8x:\\t\", VAR_4->pc);", "if (VAR_7 + 1 == VAR_8 && (VAR_1->cflags & CF_LAST_IO)) {", "gen_io_start();", "}", "decode(VAR_4, cpu_ldl_code(env, VAR_4->pc));", "VAR_4->pc += 4;", "VAR_7++;", "} while (!VAR_4->is_jmp", "&& tcg_ctx.gen_opc_ptr < gen_opc_end\n&& !cs->singlestep_enabled\n&& !singlestep\n&& (VAR_4->pc < next_page_start)\n&& VAR_7 < VAR_8);", "if (VAR_1->cflags & CF_LAST_IO) {", "gen_io_end();", "}", "if (unlikely(cs->singlestep_enabled)) {", "if (VAR_4->is_jmp == DISAS_NEXT) {", "tcg_gen_movi_tl(cpu_pc, VAR_4->pc);", "}", "t_gen_raise_exception(VAR_4, EXCP_DEBUG);", "} else {", "switch (VAR_4->is_jmp) {", "case DISAS_NEXT:\ngen_goto_tb(VAR_4, 1, VAR_4->pc);", "break;", "default:\ncase DISAS_JUMP:\ncase DISAS_UPDATE:\ntcg_gen_exit_tb(0);", "break;", "case DISAS_TB_JUMP:\nbreak;", "}", "}", "gen_tb_end(VAR_1, VAR_7);", "*tcg_ctx.gen_opc_ptr = INDEX_op_end;", "if (VAR_2) {", "VAR_5 = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;", "VAR_6++;", "while (VAR_6 <= VAR_5) {", "tcg_ctx.gen_opc_instr_start[VAR_6++] = 0;", "}", "} else {", "VAR_1->size = VAR_4->pc - pc_start;", "VAR_1->icount = VAR_7;", "}", "#ifdef DEBUG_DISAS\nif (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {", "qemu_log(\"\\n\");", "log_target_disas(env, pc_start, VAR_4->pc - pc_start, 0);", "qemu_log(\"\\nisize=%d osize=%td\\n\",\nVAR_4->pc - pc_start, tcg_ctx.gen_opc_ptr -\ntcg_ctx.gen_opc_buf);", "}", "#endif\n}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 39 ], [ 43 ], [ 45 ], [ 47 ], [ 51 ], [ 53, 55 ], [ 57 ], [ 59 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 79 ], [ 81 ], [ 83 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 115 ], [ 119 ], [ 121 ], [ 123 ], [ 127 ], [ 129 ], [ 131 ], [ 135 ], [ 137, 139, 141, 143, 145 ], [ 149 ], [ 151 ], [ 153 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ], [ 171, 173 ], [ 175 ], [ 177, 179, 181, 187 ], [ 189 ], [ 191, 195 ], [ 197 ], [ 199 ], [ 203 ], [ 205 ], [ 207 ], [ 209 ], [ 211 ], [ 213 ], [ 215 ], [ 217 ], [ 219 ], [ 221 ], [ 223 ], [ 225 ], [ 229, 231 ], [ 233 ], [ 235 ], [ 237, 239, 241 ], [ 243 ], [ 245, 247 ] ]
22,158
void helper_lsl(void) { unsigned int selector, limit; uint32_t e1, e2; CC_SRC = cc_table[CC_OP].compute_all() & ~CC_Z; selector = T0 & 0xffff; if (load_segment(&e1, &e2, selector) != 0) return; limit = (e1 & 0xffff) | (e2 & 0x000f0000); if (e2 & (1 << 23)) limit = (limit << 12) | 0xfff; T1 = limit; CC_SRC |= CC_Z; }
false
qemu
3ab493de4c524926bb75b04765b644f9189ccf01
void helper_lsl(void) { unsigned int selector, limit; uint32_t e1, e2; CC_SRC = cc_table[CC_OP].compute_all() & ~CC_Z; selector = T0 & 0xffff; if (load_segment(&e1, &e2, selector) != 0) return; limit = (e1 & 0xffff) | (e2 & 0x000f0000); if (e2 & (1 << 23)) limit = (limit << 12) | 0xfff; T1 = limit; CC_SRC |= CC_Z; }
{ "code": [], "line_no": [] }
void FUNC_0(void) { unsigned int VAR_0, VAR_1; uint32_t e1, e2; CC_SRC = cc_table[CC_OP].compute_all() & ~CC_Z; VAR_0 = T0 & 0xffff; if (load_segment(&e1, &e2, VAR_0) != 0) return; VAR_1 = (e1 & 0xffff) | (e2 & 0x000f0000); if (e2 & (1 << 23)) VAR_1 = (VAR_1 << 12) | 0xfff; T1 = VAR_1; CC_SRC |= CC_Z; }
[ "void FUNC_0(void)\n{", "unsigned int VAR_0, VAR_1;", "uint32_t e1, e2;", "CC_SRC = cc_table[CC_OP].compute_all() & ~CC_Z;", "VAR_0 = T0 & 0xffff;", "if (load_segment(&e1, &e2, VAR_0) != 0)\nreturn;", "VAR_1 = (e1 & 0xffff) | (e2 & 0x000f0000);", "if (e2 & (1 << 23))\nVAR_1 = (VAR_1 << 12) | 0xfff;", "T1 = VAR_1;", "CC_SRC |= CC_Z;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15, 17 ], [ 19 ], [ 21, 23 ], [ 25 ], [ 27 ], [ 29 ] ]
22,159
static int parse_optional_info(DCACoreDecoder *s) { DCAContext *dca = s->avctx->priv_data; int ret = -1; // Time code stamp if (s->ts_present) skip_bits_long(&s->gb, 32); // Auxiliary data if (s->aux_present && (ret = parse_aux_data(s)) < 0 && (s->avctx->err_recognition & AV_EF_EXPLODE)) return ret; if (ret < 0) s->prim_dmix_embedded = 0; // Core extensions if (s->ext_audio_present && !dca->core_only) { int sync_pos = FFMIN(s->frame_size / 4, s->gb.size_in_bits / 32) - 1; int last_pos = get_bits_count(&s->gb) / 32; int size, dist; // Search for extension sync words aligned on 4-byte boundary. Search // must be done backwards from the end of core frame to work around // sync word aliasing issues. switch (s->ext_audio_type) { case EXT_AUDIO_XCH: if (dca->request_channel_layout) break; // The distance between XCH sync word and end of the core frame // must be equal to XCH frame size. Off by one error is allowed for // compatibility with legacy bitstreams. Minimum XCH frame size is // 96 bytes. AMODE and PCHS are further checked to reduce // probability of alias sync detection. for (; sync_pos >= last_pos; sync_pos--) { if (AV_RB32(s->gb.buffer + sync_pos * 4) == DCA_SYNCWORD_XCH) { s->gb.index = (sync_pos + 1) * 32; size = get_bits(&s->gb, 10) + 1; dist = s->frame_size - sync_pos * 4; if (size >= 96 && (size == dist || size - 1 == dist) && get_bits(&s->gb, 7) == 0x08) { s->xch_pos = get_bits_count(&s->gb); break; } } } if (s->avctx->err_recognition & AV_EF_EXPLODE) { av_log(s->avctx, AV_LOG_ERROR, "XCH sync word not found\n"); return AVERROR_INVALIDDATA; } break; case EXT_AUDIO_X96: // The distance between X96 sync word and end of the core frame // must be equal to X96 frame size. Minimum X96 frame size is 96 // bytes. for (; sync_pos >= last_pos; sync_pos--) { if (AV_RB32(s->gb.buffer + sync_pos * 4) == DCA_SYNCWORD_X96) { s->gb.index = (sync_pos + 1) * 32; size = get_bits(&s->gb, 12) + 1; dist = s->frame_size - sync_pos * 4; if (size >= 96 && size == dist) { s->x96_pos = get_bits_count(&s->gb); break; } } } if (s->avctx->err_recognition & AV_EF_EXPLODE) { av_log(s->avctx, AV_LOG_ERROR, "X96 sync word not found\n"); return AVERROR_INVALIDDATA; } break; case EXT_AUDIO_XXCH: if (dca->request_channel_layout) break; // XXCH frame header CRC must be valid. Minimum XXCH frame header // size is 11 bytes. for (; sync_pos >= last_pos; sync_pos--) { if (AV_RB32(s->gb.buffer + sync_pos * 4) == DCA_SYNCWORD_XXCH) { s->gb.index = (sync_pos + 1) * 32; size = get_bits(&s->gb, 6) + 1; if (size >= 11 && !ff_dca_check_crc(&s->gb, (sync_pos + 1) * 32, sync_pos * 32 + size * 8)) { s->xxch_pos = sync_pos * 32; break; } } } if (s->avctx->err_recognition & AV_EF_EXPLODE) { av_log(s->avctx, AV_LOG_ERROR, "XXCH sync word not found\n"); return AVERROR_INVALIDDATA; } break; } } return 0; }
false
FFmpeg
ce2f9fdb0a92956aedfa2c564d1374a2f1eebfbd
static int parse_optional_info(DCACoreDecoder *s) { DCAContext *dca = s->avctx->priv_data; int ret = -1; if (s->ts_present) skip_bits_long(&s->gb, 32); if (s->aux_present && (ret = parse_aux_data(s)) < 0 && (s->avctx->err_recognition & AV_EF_EXPLODE)) return ret; if (ret < 0) s->prim_dmix_embedded = 0; if (s->ext_audio_present && !dca->core_only) { int sync_pos = FFMIN(s->frame_size / 4, s->gb.size_in_bits / 32) - 1; int last_pos = get_bits_count(&s->gb) / 32; int size, dist; switch (s->ext_audio_type) { case EXT_AUDIO_XCH: if (dca->request_channel_layout) break; for (; sync_pos >= last_pos; sync_pos--) { if (AV_RB32(s->gb.buffer + sync_pos * 4) == DCA_SYNCWORD_XCH) { s->gb.index = (sync_pos + 1) * 32; size = get_bits(&s->gb, 10) + 1; dist = s->frame_size - sync_pos * 4; if (size >= 96 && (size == dist || size - 1 == dist) && get_bits(&s->gb, 7) == 0x08) { s->xch_pos = get_bits_count(&s->gb); break; } } } if (s->avctx->err_recognition & AV_EF_EXPLODE) { av_log(s->avctx, AV_LOG_ERROR, "XCH sync word not found\n"); return AVERROR_INVALIDDATA; } break; case EXT_AUDIO_X96: for (; sync_pos >= last_pos; sync_pos--) { if (AV_RB32(s->gb.buffer + sync_pos * 4) == DCA_SYNCWORD_X96) { s->gb.index = (sync_pos + 1) * 32; size = get_bits(&s->gb, 12) + 1; dist = s->frame_size - sync_pos * 4; if (size >= 96 && size == dist) { s->x96_pos = get_bits_count(&s->gb); break; } } } if (s->avctx->err_recognition & AV_EF_EXPLODE) { av_log(s->avctx, AV_LOG_ERROR, "X96 sync word not found\n"); return AVERROR_INVALIDDATA; } break; case EXT_AUDIO_XXCH: if (dca->request_channel_layout) break; for (; sync_pos >= last_pos; sync_pos--) { if (AV_RB32(s->gb.buffer + sync_pos * 4) == DCA_SYNCWORD_XXCH) { s->gb.index = (sync_pos + 1) * 32; size = get_bits(&s->gb, 6) + 1; if (size >= 11 && !ff_dca_check_crc(&s->gb, (sync_pos + 1) * 32, sync_pos * 32 + size * 8)) { s->xxch_pos = sync_pos * 32; break; } } } if (s->avctx->err_recognition & AV_EF_EXPLODE) { av_log(s->avctx, AV_LOG_ERROR, "XXCH sync word not found\n"); return AVERROR_INVALIDDATA; } break; } } return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(DCACoreDecoder *VAR_0) { DCAContext *dca = VAR_0->avctx->priv_data; int VAR_1 = -1; if (VAR_0->ts_present) skip_bits_long(&VAR_0->gb, 32); if (VAR_0->aux_present && (VAR_1 = parse_aux_data(VAR_0)) < 0 && (VAR_0->avctx->err_recognition & AV_EF_EXPLODE)) return VAR_1; if (VAR_1 < 0) VAR_0->prim_dmix_embedded = 0; if (VAR_0->ext_audio_present && !dca->core_only) { int VAR_2 = FFMIN(VAR_0->frame_size / 4, VAR_0->gb.size_in_bits / 32) - 1; int VAR_3 = get_bits_count(&VAR_0->gb) / 32; int VAR_4, VAR_5; switch (VAR_0->ext_audio_type) { case EXT_AUDIO_XCH: if (dca->request_channel_layout) break; for (; VAR_2 >= VAR_3; VAR_2--) { if (AV_RB32(VAR_0->gb.buffer + VAR_2 * 4) == DCA_SYNCWORD_XCH) { VAR_0->gb.index = (VAR_2 + 1) * 32; VAR_4 = get_bits(&VAR_0->gb, 10) + 1; VAR_5 = VAR_0->frame_size - VAR_2 * 4; if (VAR_4 >= 96 && (VAR_4 == VAR_5 || VAR_4 - 1 == VAR_5) && get_bits(&VAR_0->gb, 7) == 0x08) { VAR_0->xch_pos = get_bits_count(&VAR_0->gb); break; } } } if (VAR_0->avctx->err_recognition & AV_EF_EXPLODE) { av_log(VAR_0->avctx, AV_LOG_ERROR, "XCH sync word not found\n"); return AVERROR_INVALIDDATA; } break; case EXT_AUDIO_X96: for (; VAR_2 >= VAR_3; VAR_2--) { if (AV_RB32(VAR_0->gb.buffer + VAR_2 * 4) == DCA_SYNCWORD_X96) { VAR_0->gb.index = (VAR_2 + 1) * 32; VAR_4 = get_bits(&VAR_0->gb, 12) + 1; VAR_5 = VAR_0->frame_size - VAR_2 * 4; if (VAR_4 >= 96 && VAR_4 == VAR_5) { VAR_0->x96_pos = get_bits_count(&VAR_0->gb); break; } } } if (VAR_0->avctx->err_recognition & AV_EF_EXPLODE) { av_log(VAR_0->avctx, AV_LOG_ERROR, "X96 sync word not found\n"); return AVERROR_INVALIDDATA; } break; case EXT_AUDIO_XXCH: if (dca->request_channel_layout) break; for (; VAR_2 >= VAR_3; VAR_2--) { if (AV_RB32(VAR_0->gb.buffer + VAR_2 * 4) == DCA_SYNCWORD_XXCH) { VAR_0->gb.index = (VAR_2 + 1) * 32; VAR_4 = get_bits(&VAR_0->gb, 6) + 1; if (VAR_4 >= 11 && !ff_dca_check_crc(&VAR_0->gb, (VAR_2 + 1) * 32, VAR_2 * 32 + VAR_4 * 8)) { VAR_0->xxch_pos = VAR_2 * 32; break; } } } if (VAR_0->avctx->err_recognition & AV_EF_EXPLODE) { av_log(VAR_0->avctx, AV_LOG_ERROR, "XXCH sync word not found\n"); return AVERROR_INVALIDDATA; } break; } } return 0; }
[ "static int FUNC_0(DCACoreDecoder *VAR_0)\n{", "DCAContext *dca = VAR_0->avctx->priv_data;", "int VAR_1 = -1;", "if (VAR_0->ts_present)\nskip_bits_long(&VAR_0->gb, 32);", "if (VAR_0->aux_present && (VAR_1 = parse_aux_data(VAR_0)) < 0\n&& (VAR_0->avctx->err_recognition & AV_EF_EXPLODE))\nreturn VAR_1;", "if (VAR_1 < 0)\nVAR_0->prim_dmix_embedded = 0;", "if (VAR_0->ext_audio_present && !dca->core_only) {", "int VAR_2 = FFMIN(VAR_0->frame_size / 4, VAR_0->gb.size_in_bits / 32) - 1;", "int VAR_3 = get_bits_count(&VAR_0->gb) / 32;", "int VAR_4, VAR_5;", "switch (VAR_0->ext_audio_type) {", "case EXT_AUDIO_XCH:\nif (dca->request_channel_layout)\nbreak;", "for (; VAR_2 >= VAR_3; VAR_2--) {", "if (AV_RB32(VAR_0->gb.buffer + VAR_2 * 4) == DCA_SYNCWORD_XCH) {", "VAR_0->gb.index = (VAR_2 + 1) * 32;", "VAR_4 = get_bits(&VAR_0->gb, 10) + 1;", "VAR_5 = VAR_0->frame_size - VAR_2 * 4;", "if (VAR_4 >= 96\n&& (VAR_4 == VAR_5 || VAR_4 - 1 == VAR_5)\n&& get_bits(&VAR_0->gb, 7) == 0x08) {", "VAR_0->xch_pos = get_bits_count(&VAR_0->gb);", "break;", "}", "}", "}", "if (VAR_0->avctx->err_recognition & AV_EF_EXPLODE) {", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"XCH sync word not found\\n\");", "return AVERROR_INVALIDDATA;", "}", "break;", "case EXT_AUDIO_X96:\nfor (; VAR_2 >= VAR_3; VAR_2--) {", "if (AV_RB32(VAR_0->gb.buffer + VAR_2 * 4) == DCA_SYNCWORD_X96) {", "VAR_0->gb.index = (VAR_2 + 1) * 32;", "VAR_4 = get_bits(&VAR_0->gb, 12) + 1;", "VAR_5 = VAR_0->frame_size - VAR_2 * 4;", "if (VAR_4 >= 96 && VAR_4 == VAR_5) {", "VAR_0->x96_pos = get_bits_count(&VAR_0->gb);", "break;", "}", "}", "}", "if (VAR_0->avctx->err_recognition & AV_EF_EXPLODE) {", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"X96 sync word not found\\n\");", "return AVERROR_INVALIDDATA;", "}", "break;", "case EXT_AUDIO_XXCH:\nif (dca->request_channel_layout)\nbreak;", "for (; VAR_2 >= VAR_3; VAR_2--) {", "if (AV_RB32(VAR_0->gb.buffer + VAR_2 * 4) == DCA_SYNCWORD_XXCH) {", "VAR_0->gb.index = (VAR_2 + 1) * 32;", "VAR_4 = get_bits(&VAR_0->gb, 6) + 1;", "if (VAR_4 >= 11 &&\n!ff_dca_check_crc(&VAR_0->gb, (VAR_2 + 1) * 32,\nVAR_2 * 32 + VAR_4 * 8)) {", "VAR_0->xxch_pos = VAR_2 * 32;", "break;", "}", "}", "}", "if (VAR_0->avctx->err_recognition & AV_EF_EXPLODE) {", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"XXCH sync word not found\\n\");", "return AVERROR_INVALIDDATA;", "}", "break;", "}", "}", "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 ], [ 13, 15 ], [ 21, 23, 25 ], [ 29, 31 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 53 ], [ 55, 57, 59 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83, 85, 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 113, 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 153 ], [ 157, 159, 161 ], [ 169 ], [ 171 ], [ 173 ], [ 175 ], [ 177, 179, 181 ], [ 183 ], [ 185 ], [ 187 ], [ 189 ], [ 191 ], [ 195 ], [ 197 ], [ 199 ], [ 201 ], [ 203 ], [ 205 ], [ 207 ], [ 211 ], [ 213 ] ]
22,160
static void apic_reset_common(DeviceState *d) { APICCommonState *s = DO_UPCAST(APICCommonState, busdev.qdev, d); APICCommonClass *info = APIC_COMMON_GET_CLASS(s); bool bsp; bsp = cpu_is_bsp(s->cpu_env); s->apicbase = 0xfee00000 | (bsp ? MSR_IA32_APICBASE_BSP : 0) | MSR_IA32_APICBASE_ENABLE; s->vapic_paddr = 0; info->vapic_base_update(s); apic_init_reset(d); if (bsp) { /* * LINT0 delivery mode on CPU #0 is set to ExtInt at initialization * time typically by BIOS, so PIC interrupt can be delivered to the * processor when local APIC is enabled. */ s->lvt[APIC_LVT_LINT0] = 0x700; } }
false
qemu
dd673288a8ff73ad77fcc1c255486d2466a772e1
static void apic_reset_common(DeviceState *d) { APICCommonState *s = DO_UPCAST(APICCommonState, busdev.qdev, d); APICCommonClass *info = APIC_COMMON_GET_CLASS(s); bool bsp; bsp = cpu_is_bsp(s->cpu_env); s->apicbase = 0xfee00000 | (bsp ? MSR_IA32_APICBASE_BSP : 0) | MSR_IA32_APICBASE_ENABLE; s->vapic_paddr = 0; info->vapic_base_update(s); apic_init_reset(d); if (bsp) { s->lvt[APIC_LVT_LINT0] = 0x700; } }
{ "code": [], "line_no": [] }
static void FUNC_0(DeviceState *VAR_0) { APICCommonState *s = DO_UPCAST(APICCommonState, busdev.qdev, VAR_0); APICCommonClass *info = APIC_COMMON_GET_CLASS(s); bool bsp; bsp = cpu_is_bsp(s->cpu_env); s->apicbase = 0xfee00000 | (bsp ? MSR_IA32_APICBASE_BSP : 0) | MSR_IA32_APICBASE_ENABLE; s->vapic_paddr = 0; info->vapic_base_update(s); apic_init_reset(VAR_0); if (bsp) { s->lvt[APIC_LVT_LINT0] = 0x700; } }
[ "static void FUNC_0(DeviceState *VAR_0)\n{", "APICCommonState *s = DO_UPCAST(APICCommonState, busdev.qdev, VAR_0);", "APICCommonClass *info = APIC_COMMON_GET_CLASS(s);", "bool bsp;", "bsp = cpu_is_bsp(s->cpu_env);", "s->apicbase = 0xfee00000 |\n(bsp ? MSR_IA32_APICBASE_BSP : 0) | MSR_IA32_APICBASE_ENABLE;", "s->vapic_paddr = 0;", "info->vapic_base_update(s);", "apic_init_reset(VAR_0);", "if (bsp) {", "s->lvt[APIC_LVT_LINT0] = 0x700;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15, 17 ], [ 21 ], [ 23 ], [ 27 ], [ 31 ], [ 43 ], [ 45 ], [ 47 ] ]
22,161
uint32_t HELPER(neon_max_f32)(uint32_t a, uint32_t b) { float32 f0 = make_float32(a); float32 f1 = make_float32(b); return (float32_compare_quiet(f0, f1, NFS) == 1) ? a : b; }
false
qemu
4a9f9cb24de52e93aae7539a004dd20314ca1c0c
uint32_t HELPER(neon_max_f32)(uint32_t a, uint32_t b) { float32 f0 = make_float32(a); float32 f1 = make_float32(b); return (float32_compare_quiet(f0, f1, NFS) == 1) ? a : b; }
{ "code": [], "line_no": [] }
uint32_t FUNC_0(neon_max_f32)(uint32_t a, uint32_t b) { float32 f0 = make_float32(a); float32 f1 = make_float32(b); return (float32_compare_quiet(f0, f1, NFS) == 1) ? a : b; }
[ "uint32_t FUNC_0(neon_max_f32)(uint32_t a, uint32_t b)\n{", "float32 f0 = make_float32(a);", "float32 f1 = make_float32(b);", "return (float32_compare_quiet(f0, f1, NFS) == 1) ? a : b;", "}" ]
[ 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ] ]
22,162
static void virtqueue_map_desc(unsigned int *p_num_sg, hwaddr *addr, struct iovec *iov, unsigned int max_num_sg, bool is_write, hwaddr pa, size_t sz) { unsigned num_sg = *p_num_sg; assert(num_sg <= max_num_sg); if (!sz) { error_report("virtio: zero sized buffers are not allowed"); while (sz) { hwaddr len = sz; if (num_sg == max_num_sg) { error_report("virtio: too many write descriptors in indirect table"); iov[num_sg].iov_base = cpu_physical_memory_map(pa, &len, is_write); iov[num_sg].iov_len = len; addr[num_sg] = pa; sz -= len; pa += len; num_sg++; *p_num_sg = num_sg;
true
qemu
973e7170dddefb491a48df5cba33b2ae151013a0
static void virtqueue_map_desc(unsigned int *p_num_sg, hwaddr *addr, struct iovec *iov, unsigned int max_num_sg, bool is_write, hwaddr pa, size_t sz) { unsigned num_sg = *p_num_sg; assert(num_sg <= max_num_sg); if (!sz) { error_report("virtio: zero sized buffers are not allowed"); while (sz) { hwaddr len = sz; if (num_sg == max_num_sg) { error_report("virtio: too many write descriptors in indirect table"); iov[num_sg].iov_base = cpu_physical_memory_map(pa, &len, is_write); iov[num_sg].iov_len = len; addr[num_sg] = pa; sz -= len; pa += len; num_sg++; *p_num_sg = num_sg;
{ "code": [], "line_no": [] }
static void FUNC_0(unsigned int *VAR_0, hwaddr *VAR_1, struct iovec *VAR_2, unsigned int VAR_3, bool VAR_4, hwaddr VAR_5, size_t VAR_6) { unsigned VAR_7 = *VAR_0; assert(VAR_7 <= VAR_3); if (!VAR_6) { error_report("virtio: zero sized buffers are not allowed"); while (VAR_6) { hwaddr len = VAR_6; if (VAR_7 == VAR_3) { error_report("virtio: too many write descriptors in indirect table"); VAR_2[VAR_7].iov_base = cpu_physical_memory_map(VAR_5, &len, VAR_4); VAR_2[VAR_7].iov_len = len; VAR_1[VAR_7] = VAR_5; VAR_6 -= len; VAR_5 += len; VAR_7++; *VAR_0 = VAR_7;
[ "static void FUNC_0(unsigned int *VAR_0, hwaddr *VAR_1, struct iovec *VAR_2,\nunsigned int VAR_3, bool VAR_4,\nhwaddr VAR_5, size_t VAR_6)\n{", "unsigned VAR_7 = *VAR_0;", "assert(VAR_7 <= VAR_3);", "if (!VAR_6) {", "error_report(\"virtio: zero sized buffers are not allowed\");", "while (VAR_6) {", "hwaddr len = VAR_6;", "if (VAR_7 == VAR_3) {", "error_report(\"virtio: too many write descriptors in indirect table\");", "VAR_2[VAR_7].iov_base = cpu_physical_memory_map(VAR_5, &len, VAR_4);", "VAR_2[VAR_7].iov_len = len;", "VAR_1[VAR_7] = VAR_5;", "VAR_6 -= len;", "VAR_5 += len;", "VAR_7++;", "*VAR_0 = VAR_7;" ]
[ 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 ] ]
22,163
void tcp_start_outgoing_migration(MigrationState *s, const char *host_port, Error **errp) { inet_nonblocking_connect(host_port, tcp_wait_for_connect, s, errp); }
true
qemu
60fe637bf0e4d7989e21e50f52526444765c63b4
void tcp_start_outgoing_migration(MigrationState *s, const char *host_port, Error **errp) { inet_nonblocking_connect(host_port, tcp_wait_for_connect, s, errp); }
{ "code": [], "line_no": [] }
void FUNC_0(MigrationState *VAR_0, const char *VAR_1, Error **VAR_2) { inet_nonblocking_connect(VAR_1, tcp_wait_for_connect, VAR_0, VAR_2); }
[ "void FUNC_0(MigrationState *VAR_0, const char *VAR_1, Error **VAR_2)\n{", "inet_nonblocking_connect(VAR_1, tcp_wait_for_connect, VAR_0, VAR_2);", "}" ]
[ 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ] ]
22,164
static void generate_silence(uint8_t* buf, enum AVSampleFormat sample_fmt, size_t size) { int fill_char = 0x00; if (sample_fmt == AV_SAMPLE_FMT_U8) fill_char = 0x80; memset(buf, fill_char, size); }
true
FFmpeg
369cb092ecbbaff20bb0a2a1d60536c3bc04a8f0
static void generate_silence(uint8_t* buf, enum AVSampleFormat sample_fmt, size_t size) { int fill_char = 0x00; if (sample_fmt == AV_SAMPLE_FMT_U8) fill_char = 0x80; memset(buf, fill_char, size); }
{ "code": [ "static void generate_silence(uint8_t* buf, enum AVSampleFormat sample_fmt, size_t size)", " int fill_char = 0x00;", " if (sample_fmt == AV_SAMPLE_FMT_U8)", " fill_char = 0x80;", " memset(buf, fill_char, size);" ], "line_no": [ 1, 5, 7, 9, 11 ] }
static void FUNC_0(uint8_t* VAR_0, enum AVSampleFormat VAR_1, size_t VAR_2) { int VAR_3 = 0x00; if (VAR_1 == AV_SAMPLE_FMT_U8) VAR_3 = 0x80; memset(VAR_0, VAR_3, VAR_2); }
[ "static void FUNC_0(uint8_t* VAR_0, enum AVSampleFormat VAR_1, size_t VAR_2)\n{", "int VAR_3 = 0x00;", "if (VAR_1 == AV_SAMPLE_FMT_U8)\nVAR_3 = 0x80;", "memset(VAR_0, VAR_3, VAR_2);", "}" ]
[ 1, 1, 1, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7, 9 ], [ 11 ], [ 13 ] ]
22,165
static void gen_check_sr(DisasContext *dc, uint32_t sr) { if (!xtensa_option_bits_enabled(dc->config, sregnames[sr].opt_bits)) { if (sregnames[sr].name) { qemu_log("SR %s is not configured\n", sregnames[sr].name); } else { qemu_log("SR %d is not implemented\n", sr); } gen_exception_cause(dc, ILLEGAL_INSTRUCTION_CAUSE); } }
true
qemu
53593e90d13264dc88b3281ddf75ceaa641df05a
static void gen_check_sr(DisasContext *dc, uint32_t sr) { if (!xtensa_option_bits_enabled(dc->config, sregnames[sr].opt_bits)) { if (sregnames[sr].name) { qemu_log("SR %s is not configured\n", sregnames[sr].name); } else { qemu_log("SR %d is not implemented\n", sr); } gen_exception_cause(dc, ILLEGAL_INSTRUCTION_CAUSE); } }
{ "code": [ "static void gen_check_sr(DisasContext *dc, uint32_t sr)" ], "line_no": [ 1 ] }
static void FUNC_0(DisasContext *VAR_0, uint32_t VAR_1) { if (!xtensa_option_bits_enabled(VAR_0->config, sregnames[VAR_1].opt_bits)) { if (sregnames[VAR_1].name) { qemu_log("SR %s is not configured\n", sregnames[VAR_1].name); } else { qemu_log("SR %d is not implemented\n", VAR_1); } gen_exception_cause(VAR_0, ILLEGAL_INSTRUCTION_CAUSE); } }
[ "static void FUNC_0(DisasContext *VAR_0, uint32_t VAR_1)\n{", "if (!xtensa_option_bits_enabled(VAR_0->config, sregnames[VAR_1].opt_bits)) {", "if (sregnames[VAR_1].name) {", "qemu_log(\"SR %s is not configured\\n\", sregnames[VAR_1].name);", "} else {", "qemu_log(\"SR %d is not implemented\\n\", VAR_1);", "}", "gen_exception_cause(VAR_0, ILLEGAL_INSTRUCTION_CAUSE);", "}", "}" ]
[ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ] ]
22,166
static int bt_hid_out(struct bt_hid_device_s *s) { USBPacket p; if (s->data_type == BT_DATA_OUTPUT) { p.pid = USB_TOKEN_OUT; p.devep = 1; p.data = s->dataout.buffer; p.len = s->dataout.len; s->dataout.len = s->usbdev->info->handle_data(s->usbdev, &p); return s->dataout.len; } if (s->data_type == BT_DATA_FEATURE) { /* XXX: * does this send a USB_REQ_CLEAR_FEATURE/USB_REQ_SET_FEATURE * or a SET_REPORT? */ p.devep = 0; } return -1; }
true
qemu
4f4321c11ff6e98583846bfd6f0e81954924b003
static int bt_hid_out(struct bt_hid_device_s *s) { USBPacket p; if (s->data_type == BT_DATA_OUTPUT) { p.pid = USB_TOKEN_OUT; p.devep = 1; p.data = s->dataout.buffer; p.len = s->dataout.len; s->dataout.len = s->usbdev->info->handle_data(s->usbdev, &p); return s->dataout.len; } if (s->data_type == BT_DATA_FEATURE) { p.devep = 0; } return -1; }
{ "code": [ " p.pid = USB_TOKEN_OUT;", " p.devep = 1;", " p.data = s->dataout.buffer;", " p.len = s->dataout.len;" ], "line_no": [ 11, 13, 15, 17 ] }
static int FUNC_0(struct bt_hid_device_s *VAR_0) { USBPacket p; if (VAR_0->data_type == BT_DATA_OUTPUT) { p.pid = USB_TOKEN_OUT; p.devep = 1; p.data = VAR_0->dataout.buffer; p.len = VAR_0->dataout.len; VAR_0->dataout.len = VAR_0->usbdev->info->handle_data(VAR_0->usbdev, &p); return VAR_0->dataout.len; } if (VAR_0->data_type == BT_DATA_FEATURE) { p.devep = 0; } return -1; }
[ "static int FUNC_0(struct bt_hid_device_s *VAR_0)\n{", "USBPacket p;", "if (VAR_0->data_type == BT_DATA_OUTPUT) {", "p.pid = USB_TOKEN_OUT;", "p.devep = 1;", "p.data = VAR_0->dataout.buffer;", "p.len = VAR_0->dataout.len;", "VAR_0->dataout.len = VAR_0->usbdev->info->handle_data(VAR_0->usbdev, &p);", "return VAR_0->dataout.len;", "}", "if (VAR_0->data_type == BT_DATA_FEATURE) {", "p.devep = 0;", "}", "return -1;", "}" ]
[ 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ], [ 29 ], [ 37 ], [ 39 ], [ 43 ], [ 45 ] ]
22,168
size_t mptsas_config_manufacturing_1(MPTSASState *s, uint8_t **data, int address) { /* VPD - all zeros */ return MPTSAS_CONFIG_PACK(1, MPI_CONFIG_PAGETYPE_MANUFACTURING, 0x00, "s256"); }
true
qemu
65a8e1f6413a0f6f79894da710b5d6d43361d27d
size_t mptsas_config_manufacturing_1(MPTSASState *s, uint8_t **data, int address) { return MPTSAS_CONFIG_PACK(1, MPI_CONFIG_PAGETYPE_MANUFACTURING, 0x00, "s256"); }
{ "code": [ " \"s256\");" ], "line_no": [ 9 ] }
size_t FUNC_0(MPTSASState *s, uint8_t **data, int address) { return MPTSAS_CONFIG_PACK(1, MPI_CONFIG_PAGETYPE_MANUFACTURING, 0x00, "s256"); }
[ "size_t FUNC_0(MPTSASState *s, uint8_t **data, int address)\n{", "return MPTSAS_CONFIG_PACK(1, MPI_CONFIG_PAGETYPE_MANUFACTURING, 0x00,\n\"s256\");", "}" ]
[ 0, 1, 0 ]
[ [ 1, 3 ], [ 7, 9 ], [ 11 ] ]
22,169
static void init_proc_620 (CPUPPCState *env) { gen_spr_ne_601(env); gen_spr_620(env); /* Time base */ gen_tbl(env); /* Hardware implementation registers */ /* XXX : not implemented */ spr_register(env, SPR_HID0, "HID0", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); /* Memory management */ gen_low_BATs(env); gen_high_BATs(env); init_excp_620(env); env->dcache_line_size = 64; env->icache_line_size = 64; /* Allocate hardware IRQ controller */ ppc6xx_irq_init(env); }
false
qemu
082c6681b6c4af0035d9dad34a4a784be8c21dbe
static void init_proc_620 (CPUPPCState *env) { gen_spr_ne_601(env); gen_spr_620(env); gen_tbl(env); spr_register(env, SPR_HID0, "HID0", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); gen_low_BATs(env); gen_high_BATs(env); init_excp_620(env); env->dcache_line_size = 64; env->icache_line_size = 64; ppc6xx_irq_init(env); }
{ "code": [], "line_no": [] }
static void FUNC_0 (CPUPPCState *VAR_0) { gen_spr_ne_601(VAR_0); gen_spr_620(VAR_0); gen_tbl(VAR_0); spr_register(VAR_0, SPR_HID0, "HID0", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); gen_low_BATs(VAR_0); gen_high_BATs(VAR_0); init_excp_620(VAR_0); VAR_0->dcache_line_size = 64; VAR_0->icache_line_size = 64; ppc6xx_irq_init(VAR_0); }
[ "static void FUNC_0 (CPUPPCState *VAR_0)\n{", "gen_spr_ne_601(VAR_0);", "gen_spr_620(VAR_0);", "gen_tbl(VAR_0);", "spr_register(VAR_0, SPR_HID0, \"HID0\",\nSPR_NOACCESS, SPR_NOACCESS,\n&spr_read_generic, &spr_write_generic,\n0x00000000);", "gen_low_BATs(VAR_0);", "gen_high_BATs(VAR_0);", "init_excp_620(VAR_0);", "VAR_0->dcache_line_size = 64;", "VAR_0->icache_line_size = 64;", "ppc6xx_irq_init(VAR_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 ], [ 33 ], [ 35 ], [ 39 ], [ 41 ] ]
22,170
static void kvm_set_phys_mem(MemoryRegionSection *section, bool add) { KVMState *s = kvm_state; KVMSlot *mem, old; int err; MemoryRegion *mr = section->mr; bool log_dirty = memory_region_is_logging(mr); bool writeable = !mr->readonly && !mr->rom_device; bool readonly_flag = mr->readonly || memory_region_is_romd(mr); hwaddr start_addr = section->offset_within_address_space; ram_addr_t size = int128_get64(section->size); void *ram = NULL; unsigned delta; /* kvm works in page size chunks, but the function may be called with sub-page size and unaligned start address. Pad the start address to next and truncate size to previous page boundary. */ delta = (TARGET_PAGE_SIZE - (start_addr & ~TARGET_PAGE_MASK)); delta &= ~TARGET_PAGE_MASK; if (delta > size) { return; } start_addr += delta; size -= delta; size &= TARGET_PAGE_MASK; if (!size || (start_addr & ~TARGET_PAGE_MASK)) { return; } if (!memory_region_is_ram(mr)) { if (writeable || !kvm_readonly_mem_allowed) { return; } else if (!mr->romd_mode) { /* If the memory device is not in romd_mode, then we actually want * to remove the kvm memory slot so all accesses will trap. */ add = false; } } ram = memory_region_get_ram_ptr(mr) + section->offset_within_region + delta; while (1) { mem = kvm_lookup_overlapping_slot(s, start_addr, start_addr + size); if (!mem) { break; } if (add && start_addr >= mem->start_addr && (start_addr + size <= mem->start_addr + mem->memory_size) && (ram - start_addr == mem->ram - mem->start_addr)) { /* The new slot fits into the existing one and comes with * identical parameters - update flags and done. */ kvm_slot_dirty_pages_log_change(mem, log_dirty); return; } old = *mem; if ((mem->flags & KVM_MEM_LOG_DIRTY_PAGES) || s->migration_log) { kvm_physical_sync_dirty_bitmap(section); } /* unregister the overlapping slot */ mem->memory_size = 0; err = kvm_set_user_memory_region(s, mem); if (err) { fprintf(stderr, "%s: error unregistering overlapping slot: %s\n", __func__, strerror(-err)); abort(); } /* Workaround for older KVM versions: we can't join slots, even not by * unregistering the previous ones and then registering the larger * slot. We have to maintain the existing fragmentation. Sigh. * * This workaround assumes that the new slot starts at the same * address as the first existing one. If not or if some overlapping * slot comes around later, we will fail (not seen in practice so far) * - and actually require a recent KVM version. */ if (s->broken_set_mem_region && old.start_addr == start_addr && old.memory_size < size && add) { mem = kvm_alloc_slot(s); mem->memory_size = old.memory_size; mem->start_addr = old.start_addr; mem->ram = old.ram; mem->flags = kvm_mem_flags(s, log_dirty, readonly_flag); err = kvm_set_user_memory_region(s, mem); if (err) { fprintf(stderr, "%s: error updating slot: %s\n", __func__, strerror(-err)); abort(); } start_addr += old.memory_size; ram += old.memory_size; size -= old.memory_size; continue; } /* register prefix slot */ if (old.start_addr < start_addr) { mem = kvm_alloc_slot(s); mem->memory_size = start_addr - old.start_addr; mem->start_addr = old.start_addr; mem->ram = old.ram; mem->flags = kvm_mem_flags(s, log_dirty, readonly_flag); err = kvm_set_user_memory_region(s, mem); if (err) { fprintf(stderr, "%s: error registering prefix slot: %s\n", __func__, strerror(-err)); #ifdef TARGET_PPC fprintf(stderr, "%s: This is probably because your kernel's " \ "PAGE_SIZE is too big. Please try to use 4k " \ "PAGE_SIZE!\n", __func__); #endif abort(); } } /* register suffix slot */ if (old.start_addr + old.memory_size > start_addr + size) { ram_addr_t size_delta; mem = kvm_alloc_slot(s); mem->start_addr = start_addr + size; size_delta = mem->start_addr - old.start_addr; mem->memory_size = old.memory_size - size_delta; mem->ram = old.ram + size_delta; mem->flags = kvm_mem_flags(s, log_dirty, readonly_flag); err = kvm_set_user_memory_region(s, mem); if (err) { fprintf(stderr, "%s: error registering suffix slot: %s\n", __func__, strerror(-err)); abort(); } } } /* in case the KVM bug workaround already "consumed" the new slot */ if (!size) { return; } if (!add) { return; } mem = kvm_alloc_slot(s); mem->memory_size = size; mem->start_addr = start_addr; mem->ram = ram; mem->flags = kvm_mem_flags(s, log_dirty, readonly_flag); err = kvm_set_user_memory_region(s, mem); if (err) { fprintf(stderr, "%s: error registering slot: %s\n", __func__, strerror(-err)); abort(); } }
false
qemu
2d1a35bef0ed96b3f23535e459c552414ccdbafd
static void kvm_set_phys_mem(MemoryRegionSection *section, bool add) { KVMState *s = kvm_state; KVMSlot *mem, old; int err; MemoryRegion *mr = section->mr; bool log_dirty = memory_region_is_logging(mr); bool writeable = !mr->readonly && !mr->rom_device; bool readonly_flag = mr->readonly || memory_region_is_romd(mr); hwaddr start_addr = section->offset_within_address_space; ram_addr_t size = int128_get64(section->size); void *ram = NULL; unsigned delta; delta = (TARGET_PAGE_SIZE - (start_addr & ~TARGET_PAGE_MASK)); delta &= ~TARGET_PAGE_MASK; if (delta > size) { return; } start_addr += delta; size -= delta; size &= TARGET_PAGE_MASK; if (!size || (start_addr & ~TARGET_PAGE_MASK)) { return; } if (!memory_region_is_ram(mr)) { if (writeable || !kvm_readonly_mem_allowed) { return; } else if (!mr->romd_mode) { add = false; } } ram = memory_region_get_ram_ptr(mr) + section->offset_within_region + delta; while (1) { mem = kvm_lookup_overlapping_slot(s, start_addr, start_addr + size); if (!mem) { break; } if (add && start_addr >= mem->start_addr && (start_addr + size <= mem->start_addr + mem->memory_size) && (ram - start_addr == mem->ram - mem->start_addr)) { kvm_slot_dirty_pages_log_change(mem, log_dirty); return; } old = *mem; if ((mem->flags & KVM_MEM_LOG_DIRTY_PAGES) || s->migration_log) { kvm_physical_sync_dirty_bitmap(section); } mem->memory_size = 0; err = kvm_set_user_memory_region(s, mem); if (err) { fprintf(stderr, "%s: error unregistering overlapping slot: %s\n", __func__, strerror(-err)); abort(); } if (s->broken_set_mem_region && old.start_addr == start_addr && old.memory_size < size && add) { mem = kvm_alloc_slot(s); mem->memory_size = old.memory_size; mem->start_addr = old.start_addr; mem->ram = old.ram; mem->flags = kvm_mem_flags(s, log_dirty, readonly_flag); err = kvm_set_user_memory_region(s, mem); if (err) { fprintf(stderr, "%s: error updating slot: %s\n", __func__, strerror(-err)); abort(); } start_addr += old.memory_size; ram += old.memory_size; size -= old.memory_size; continue; } if (old.start_addr < start_addr) { mem = kvm_alloc_slot(s); mem->memory_size = start_addr - old.start_addr; mem->start_addr = old.start_addr; mem->ram = old.ram; mem->flags = kvm_mem_flags(s, log_dirty, readonly_flag); err = kvm_set_user_memory_region(s, mem); if (err) { fprintf(stderr, "%s: error registering prefix slot: %s\n", __func__, strerror(-err)); #ifdef TARGET_PPC fprintf(stderr, "%s: This is probably because your kernel's " \ "PAGE_SIZE is too big. Please try to use 4k " \ "PAGE_SIZE!\n", __func__); #endif abort(); } } if (old.start_addr + old.memory_size > start_addr + size) { ram_addr_t size_delta; mem = kvm_alloc_slot(s); mem->start_addr = start_addr + size; size_delta = mem->start_addr - old.start_addr; mem->memory_size = old.memory_size - size_delta; mem->ram = old.ram + size_delta; mem->flags = kvm_mem_flags(s, log_dirty, readonly_flag); err = kvm_set_user_memory_region(s, mem); if (err) { fprintf(stderr, "%s: error registering suffix slot: %s\n", __func__, strerror(-err)); abort(); } } } if (!size) { return; } if (!add) { return; } mem = kvm_alloc_slot(s); mem->memory_size = size; mem->start_addr = start_addr; mem->ram = ram; mem->flags = kvm_mem_flags(s, log_dirty, readonly_flag); err = kvm_set_user_memory_region(s, mem); if (err) { fprintf(stderr, "%s: error registering slot: %s\n", __func__, strerror(-err)); abort(); } }
{ "code": [], "line_no": [] }
static void FUNC_0(MemoryRegionSection *VAR_0, bool VAR_1) { KVMState *s = kvm_state; KVMSlot *mem, old; int VAR_2; MemoryRegion *mr = VAR_0->mr; bool log_dirty = memory_region_is_logging(mr); bool writeable = !mr->readonly && !mr->rom_device; bool readonly_flag = mr->readonly || memory_region_is_romd(mr); hwaddr start_addr = VAR_0->offset_within_address_space; ram_addr_t size = int128_get64(VAR_0->size); void *VAR_3 = NULL; unsigned VAR_4; VAR_4 = (TARGET_PAGE_SIZE - (start_addr & ~TARGET_PAGE_MASK)); VAR_4 &= ~TARGET_PAGE_MASK; if (VAR_4 > size) { return; } start_addr += VAR_4; size -= VAR_4; size &= TARGET_PAGE_MASK; if (!size || (start_addr & ~TARGET_PAGE_MASK)) { return; } if (!memory_region_is_ram(mr)) { if (writeable || !kvm_readonly_mem_allowed) { return; } else if (!mr->romd_mode) { VAR_1 = false; } } VAR_3 = memory_region_get_ram_ptr(mr) + VAR_0->offset_within_region + VAR_4; while (1) { mem = kvm_lookup_overlapping_slot(s, start_addr, start_addr + size); if (!mem) { break; } if (VAR_1 && start_addr >= mem->start_addr && (start_addr + size <= mem->start_addr + mem->memory_size) && (VAR_3 - start_addr == mem->VAR_3 - mem->start_addr)) { kvm_slot_dirty_pages_log_change(mem, log_dirty); return; } old = *mem; if ((mem->flags & KVM_MEM_LOG_DIRTY_PAGES) || s->migration_log) { kvm_physical_sync_dirty_bitmap(VAR_0); } mem->memory_size = 0; VAR_2 = kvm_set_user_memory_region(s, mem); if (VAR_2) { fprintf(stderr, "%s: error unregistering overlapping slot: %s\n", __func__, strerror(-VAR_2)); abort(); } if (s->broken_set_mem_region && old.start_addr == start_addr && old.memory_size < size && VAR_1) { mem = kvm_alloc_slot(s); mem->memory_size = old.memory_size; mem->start_addr = old.start_addr; mem->VAR_3 = old.VAR_3; mem->flags = kvm_mem_flags(s, log_dirty, readonly_flag); VAR_2 = kvm_set_user_memory_region(s, mem); if (VAR_2) { fprintf(stderr, "%s: error updating slot: %s\n", __func__, strerror(-VAR_2)); abort(); } start_addr += old.memory_size; VAR_3 += old.memory_size; size -= old.memory_size; continue; } if (old.start_addr < start_addr) { mem = kvm_alloc_slot(s); mem->memory_size = start_addr - old.start_addr; mem->start_addr = old.start_addr; mem->VAR_3 = old.VAR_3; mem->flags = kvm_mem_flags(s, log_dirty, readonly_flag); VAR_2 = kvm_set_user_memory_region(s, mem); if (VAR_2) { fprintf(stderr, "%s: error registering prefix slot: %s\n", __func__, strerror(-VAR_2)); #ifdef TARGET_PPC fprintf(stderr, "%s: This is probably because your kernel's " \ "PAGE_SIZE is too big. Please try to use 4k " \ "PAGE_SIZE!\n", __func__); #endif abort(); } } if (old.start_addr + old.memory_size > start_addr + size) { ram_addr_t size_delta; mem = kvm_alloc_slot(s); mem->start_addr = start_addr + size; size_delta = mem->start_addr - old.start_addr; mem->memory_size = old.memory_size - size_delta; mem->VAR_3 = old.VAR_3 + size_delta; mem->flags = kvm_mem_flags(s, log_dirty, readonly_flag); VAR_2 = kvm_set_user_memory_region(s, mem); if (VAR_2) { fprintf(stderr, "%s: error registering suffix slot: %s\n", __func__, strerror(-VAR_2)); abort(); } } } if (!size) { return; } if (!VAR_1) { return; } mem = kvm_alloc_slot(s); mem->memory_size = size; mem->start_addr = start_addr; mem->VAR_3 = VAR_3; mem->flags = kvm_mem_flags(s, log_dirty, readonly_flag); VAR_2 = kvm_set_user_memory_region(s, mem); if (VAR_2) { fprintf(stderr, "%s: error registering slot: %s\n", __func__, strerror(-VAR_2)); abort(); } }
[ "static void FUNC_0(MemoryRegionSection *VAR_0, bool VAR_1)\n{", "KVMState *s = kvm_state;", "KVMSlot *mem, old;", "int VAR_2;", "MemoryRegion *mr = VAR_0->mr;", "bool log_dirty = memory_region_is_logging(mr);", "bool writeable = !mr->readonly && !mr->rom_device;", "bool readonly_flag = mr->readonly || memory_region_is_romd(mr);", "hwaddr start_addr = VAR_0->offset_within_address_space;", "ram_addr_t size = int128_get64(VAR_0->size);", "void *VAR_3 = NULL;", "unsigned VAR_4;", "VAR_4 = (TARGET_PAGE_SIZE - (start_addr & ~TARGET_PAGE_MASK));", "VAR_4 &= ~TARGET_PAGE_MASK;", "if (VAR_4 > size) {", "return;", "}", "start_addr += VAR_4;", "size -= VAR_4;", "size &= TARGET_PAGE_MASK;", "if (!size || (start_addr & ~TARGET_PAGE_MASK)) {", "return;", "}", "if (!memory_region_is_ram(mr)) {", "if (writeable || !kvm_readonly_mem_allowed) {", "return;", "} else if (!mr->romd_mode) {", "VAR_1 = false;", "}", "}", "VAR_3 = memory_region_get_ram_ptr(mr) + VAR_0->offset_within_region + VAR_4;", "while (1) {", "mem = kvm_lookup_overlapping_slot(s, start_addr, start_addr + size);", "if (!mem) {", "break;", "}", "if (VAR_1 && start_addr >= mem->start_addr &&\n(start_addr + size <= mem->start_addr + mem->memory_size) &&\n(VAR_3 - start_addr == mem->VAR_3 - mem->start_addr)) {", "kvm_slot_dirty_pages_log_change(mem, log_dirty);", "return;", "}", "old = *mem;", "if ((mem->flags & KVM_MEM_LOG_DIRTY_PAGES) || s->migration_log) {", "kvm_physical_sync_dirty_bitmap(VAR_0);", "}", "mem->memory_size = 0;", "VAR_2 = kvm_set_user_memory_region(s, mem);", "if (VAR_2) {", "fprintf(stderr, \"%s: error unregistering overlapping slot: %s\\n\",\n__func__, strerror(-VAR_2));", "abort();", "}", "if (s->broken_set_mem_region &&\nold.start_addr == start_addr && old.memory_size < size && VAR_1) {", "mem = kvm_alloc_slot(s);", "mem->memory_size = old.memory_size;", "mem->start_addr = old.start_addr;", "mem->VAR_3 = old.VAR_3;", "mem->flags = kvm_mem_flags(s, log_dirty, readonly_flag);", "VAR_2 = kvm_set_user_memory_region(s, mem);", "if (VAR_2) {", "fprintf(stderr, \"%s: error updating slot: %s\\n\", __func__,\nstrerror(-VAR_2));", "abort();", "}", "start_addr += old.memory_size;", "VAR_3 += old.memory_size;", "size -= old.memory_size;", "continue;", "}", "if (old.start_addr < start_addr) {", "mem = kvm_alloc_slot(s);", "mem->memory_size = start_addr - old.start_addr;", "mem->start_addr = old.start_addr;", "mem->VAR_3 = old.VAR_3;", "mem->flags = kvm_mem_flags(s, log_dirty, readonly_flag);", "VAR_2 = kvm_set_user_memory_region(s, mem);", "if (VAR_2) {", "fprintf(stderr, \"%s: error registering prefix slot: %s\\n\",\n__func__, strerror(-VAR_2));", "#ifdef TARGET_PPC\nfprintf(stderr, \"%s: This is probably because your kernel's \" \\\n\"PAGE_SIZE is too big. Please try to use 4k \" \\\n\"PAGE_SIZE!\\n\", __func__);", "#endif\nabort();", "}", "}", "if (old.start_addr + old.memory_size > start_addr + size) {", "ram_addr_t size_delta;", "mem = kvm_alloc_slot(s);", "mem->start_addr = start_addr + size;", "size_delta = mem->start_addr - old.start_addr;", "mem->memory_size = old.memory_size - size_delta;", "mem->VAR_3 = old.VAR_3 + size_delta;", "mem->flags = kvm_mem_flags(s, log_dirty, readonly_flag);", "VAR_2 = kvm_set_user_memory_region(s, mem);", "if (VAR_2) {", "fprintf(stderr, \"%s: error registering suffix slot: %s\\n\",\n__func__, strerror(-VAR_2));", "abort();", "}", "}", "}", "if (!size) {", "return;", "}", "if (!VAR_1) {", "return;", "}", "mem = kvm_alloc_slot(s);", "mem->memory_size = size;", "mem->start_addr = start_addr;", "mem->VAR_3 = VAR_3;", "mem->flags = kvm_mem_flags(s, log_dirty, readonly_flag);", "VAR_2 = kvm_set_user_memory_region(s, mem);", "if (VAR_2) {", "fprintf(stderr, \"%s: error registering slot: %s\\n\", __func__,\nstrerror(-VAR_2));", "abort();", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 71 ], [ 73 ], [ 75 ], [ 79 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 95, 97, 99 ], [ 105 ], [ 107 ], [ 109 ], [ 113 ], [ 117 ], [ 119 ], [ 121 ], [ 127 ], [ 129 ], [ 131 ], [ 133, 135 ], [ 137 ], [ 139 ], [ 159, 161 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ], [ 171 ], [ 175 ], [ 177 ], [ 179, 181 ], [ 183 ], [ 185 ], [ 189 ], [ 191 ], [ 193 ], [ 195 ], [ 197 ], [ 203 ], [ 205 ], [ 207 ], [ 209 ], [ 211 ], [ 213 ], [ 217 ], [ 219 ], [ 221, 223 ], [ 225, 227, 229, 231 ], [ 233, 235 ], [ 237 ], [ 239 ], [ 245 ], [ 247 ], [ 251 ], [ 253 ], [ 255 ], [ 257 ], [ 259 ], [ 261 ], [ 265 ], [ 267 ], [ 269, 271 ], [ 273 ], [ 275 ], [ 277 ], [ 279 ], [ 285 ], [ 287 ], [ 289 ], [ 291 ], [ 293 ], [ 295 ], [ 297 ], [ 299 ], [ 301 ], [ 303 ], [ 305 ], [ 309 ], [ 311 ], [ 313, 315 ], [ 317 ], [ 319 ], [ 321 ] ]
22,171
void ff_ac3_bit_alloc_calc_psd(int8_t *exp, int start, int end, int16_t *psd, int16_t *band_psd) { int bin, j, k, end1, v; /* exponent mapping to PSD */ for(bin=start;bin<end;bin++) { psd[bin]=(3072 - (exp[bin] << 7)); } /* PSD integration */ j=start; k=bin_to_band_tab[start]; do { v = psd[j++]; end1 = FFMIN(band_start_tab[k+1], end); for (; j < end1; j++) { /* logadd */ int adr = FFMIN(FFABS(v - psd[j]) >> 1, 255); v = FFMAX(v, psd[j]) + ff_ac3_log_add_tab[adr]; } band_psd[k]=v; k++; } while (end > band_start_tab[k]); }
false
FFmpeg
a7e7417c41c2c85495b74074b96989c5d68bae22
void ff_ac3_bit_alloc_calc_psd(int8_t *exp, int start, int end, int16_t *psd, int16_t *band_psd) { int bin, j, k, end1, v; for(bin=start;bin<end;bin++) { psd[bin]=(3072 - (exp[bin] << 7)); } j=start; k=bin_to_band_tab[start]; do { v = psd[j++]; end1 = FFMIN(band_start_tab[k+1], end); for (; j < end1; j++) { int adr = FFMIN(FFABS(v - psd[j]) >> 1, 255); v = FFMAX(v, psd[j]) + ff_ac3_log_add_tab[adr]; } band_psd[k]=v; k++; } while (end > band_start_tab[k]); }
{ "code": [], "line_no": [] }
void FUNC_0(int8_t *VAR_0, int VAR_1, int VAR_2, int16_t *VAR_3, int16_t *VAR_4) { int VAR_5, VAR_6, VAR_7, VAR_8, VAR_9; for(VAR_5=VAR_1;VAR_5<VAR_2;VAR_5++) { VAR_3[VAR_5]=(3072 - (VAR_0[VAR_5] << 7)); } VAR_6=VAR_1; VAR_7=bin_to_band_tab[VAR_1]; do { VAR_9 = VAR_3[VAR_6++]; VAR_8 = FFMIN(band_start_tab[VAR_7+1], VAR_2); for (; VAR_6 < VAR_8; VAR_6++) { int VAR_10 = FFMIN(FFABS(VAR_9 - VAR_3[VAR_6]) >> 1, 255); VAR_9 = FFMAX(VAR_9, VAR_3[VAR_6]) + ff_ac3_log_add_tab[VAR_10]; } VAR_4[VAR_7]=VAR_9; VAR_7++; } while (VAR_2 > band_start_tab[VAR_7]); }
[ "void FUNC_0(int8_t *VAR_0, int VAR_1, int VAR_2, int16_t *VAR_3,\nint16_t *VAR_4)\n{", "int VAR_5, VAR_6, VAR_7, VAR_8, VAR_9;", "for(VAR_5=VAR_1;VAR_5<VAR_2;VAR_5++) {", "VAR_3[VAR_5]=(3072 - (VAR_0[VAR_5] << 7));", "}", "VAR_6=VAR_1;", "VAR_7=bin_to_band_tab[VAR_1];", "do {", "VAR_9 = VAR_3[VAR_6++];", "VAR_8 = FFMIN(band_start_tab[VAR_7+1], VAR_2);", "for (; VAR_6 < VAR_8; VAR_6++) {", "int VAR_10 = FFMIN(FFABS(VAR_9 - VAR_3[VAR_6]) >> 1, 255);", "VAR_9 = FFMAX(VAR_9, VAR_3[VAR_6]) + ff_ac3_log_add_tab[VAR_10];", "}", "VAR_4[VAR_7]=VAR_9;", "VAR_7++;", "} while (VAR_2 > band_start_tab[VAR_7]);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 13 ], [ 15 ], [ 17 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ] ]
22,172
static void gen_flt3_ldst (DisasContext *ctx, uint32_t opc, int fd, int fs, int base, int index) { const char *opn = "extended float load/store"; int store = 0; /* All of those work only on 64bit FPUs. */ gen_op_cp1_64bitmode(); if (base == 0) { if (index == 0) gen_op_reset_T0(); else GEN_LOAD_REG_TN(T0, index); } else if (index == 0) { GEN_LOAD_REG_TN(T0, base); } else { GEN_LOAD_REG_TN(T0, base); GEN_LOAD_REG_TN(T1, index); gen_op_addr_add(); } /* Don't do NOP if destination is zero: we must perform the actual * memory access */ switch (opc) { case OPC_LWXC1: op_ldst(lwc1); GEN_STORE_FTN_FREG(fd, WT0); opn = "lwxc1"; break; case OPC_LDXC1: op_ldst(ldc1); GEN_STORE_FTN_FREG(fd, DT0); opn = "ldxc1"; break; case OPC_LUXC1: op_ldst(luxc1); GEN_STORE_FTN_FREG(fd, DT0); opn = "luxc1"; break; case OPC_SWXC1: GEN_LOAD_FREG_FTN(WT0, fs); op_ldst(swc1); opn = "swxc1"; store = 1; break; case OPC_SDXC1: GEN_LOAD_FREG_FTN(DT0, fs); op_ldst(sdc1); opn = "sdxc1"; store = 1; break; case OPC_SUXC1: GEN_LOAD_FREG_FTN(DT0, fs); op_ldst(suxc1); opn = "suxc1"; store = 1; break; default: MIPS_INVAL(opn); generate_exception(ctx, EXCP_RI); return; } MIPS_DEBUG("%s %s, %s(%s)", opn, fregnames[store ? fs : fd], regnames[index], regnames[base]); }
false
qemu
5e755519ac9d867f7da13f58a9d0c262db82e14c
static void gen_flt3_ldst (DisasContext *ctx, uint32_t opc, int fd, int fs, int base, int index) { const char *opn = "extended float load/store"; int store = 0; gen_op_cp1_64bitmode(); if (base == 0) { if (index == 0) gen_op_reset_T0(); else GEN_LOAD_REG_TN(T0, index); } else if (index == 0) { GEN_LOAD_REG_TN(T0, base); } else { GEN_LOAD_REG_TN(T0, base); GEN_LOAD_REG_TN(T1, index); gen_op_addr_add(); } switch (opc) { case OPC_LWXC1: op_ldst(lwc1); GEN_STORE_FTN_FREG(fd, WT0); opn = "lwxc1"; break; case OPC_LDXC1: op_ldst(ldc1); GEN_STORE_FTN_FREG(fd, DT0); opn = "ldxc1"; break; case OPC_LUXC1: op_ldst(luxc1); GEN_STORE_FTN_FREG(fd, DT0); opn = "luxc1"; break; case OPC_SWXC1: GEN_LOAD_FREG_FTN(WT0, fs); op_ldst(swc1); opn = "swxc1"; store = 1; break; case OPC_SDXC1: GEN_LOAD_FREG_FTN(DT0, fs); op_ldst(sdc1); opn = "sdxc1"; store = 1; break; case OPC_SUXC1: GEN_LOAD_FREG_FTN(DT0, fs); op_ldst(suxc1); opn = "suxc1"; store = 1; break; default: MIPS_INVAL(opn); generate_exception(ctx, EXCP_RI); return; } MIPS_DEBUG("%s %s, %s(%s)", opn, fregnames[store ? fs : fd], regnames[index], regnames[base]); }
{ "code": [], "line_no": [] }
static void FUNC_0 (DisasContext *VAR_0, uint32_t VAR_1, int VAR_2, int VAR_3, int VAR_4, int VAR_5) { const char *VAR_6 = "extended float load/VAR_7"; int VAR_7 = 0; gen_op_cp1_64bitmode(); if (VAR_4 == 0) { if (VAR_5 == 0) gen_op_reset_T0(); else GEN_LOAD_REG_TN(T0, VAR_5); } else if (VAR_5 == 0) { GEN_LOAD_REG_TN(T0, VAR_4); } else { GEN_LOAD_REG_TN(T0, VAR_4); GEN_LOAD_REG_TN(T1, VAR_5); gen_op_addr_add(); } switch (VAR_1) { case OPC_LWXC1: op_ldst(lwc1); GEN_STORE_FTN_FREG(VAR_2, WT0); VAR_6 = "lwxc1"; break; case OPC_LDXC1: op_ldst(ldc1); GEN_STORE_FTN_FREG(VAR_2, DT0); VAR_6 = "ldxc1"; break; case OPC_LUXC1: op_ldst(luxc1); GEN_STORE_FTN_FREG(VAR_2, DT0); VAR_6 = "luxc1"; break; case OPC_SWXC1: GEN_LOAD_FREG_FTN(WT0, VAR_3); op_ldst(swc1); VAR_6 = "swxc1"; VAR_7 = 1; break; case OPC_SDXC1: GEN_LOAD_FREG_FTN(DT0, VAR_3); op_ldst(sdc1); VAR_6 = "sdxc1"; VAR_7 = 1; break; case OPC_SUXC1: GEN_LOAD_FREG_FTN(DT0, VAR_3); op_ldst(suxc1); VAR_6 = "suxc1"; VAR_7 = 1; break; default: MIPS_INVAL(VAR_6); generate_exception(VAR_0, EXCP_RI); return; } MIPS_DEBUG("%s %s, %s(%s)", VAR_6, fregnames[VAR_7 ? VAR_3 : VAR_2], regnames[VAR_5], regnames[VAR_4]); }
[ "static void FUNC_0 (DisasContext *VAR_0, uint32_t VAR_1, int VAR_2,\nint VAR_3, int VAR_4, int VAR_5)\n{", "const char *VAR_6 = \"extended float load/VAR_7\";", "int VAR_7 = 0;", "gen_op_cp1_64bitmode();", "if (VAR_4 == 0) {", "if (VAR_5 == 0)\ngen_op_reset_T0();", "else\nGEN_LOAD_REG_TN(T0, VAR_5);", "} else if (VAR_5 == 0) {", "GEN_LOAD_REG_TN(T0, VAR_4);", "} else {", "GEN_LOAD_REG_TN(T0, VAR_4);", "GEN_LOAD_REG_TN(T1, VAR_5);", "gen_op_addr_add();", "}", "switch (VAR_1) {", "case OPC_LWXC1:\nop_ldst(lwc1);", "GEN_STORE_FTN_FREG(VAR_2, WT0);", "VAR_6 = \"lwxc1\";", "break;", "case OPC_LDXC1:\nop_ldst(ldc1);", "GEN_STORE_FTN_FREG(VAR_2, DT0);", "VAR_6 = \"ldxc1\";", "break;", "case OPC_LUXC1:\nop_ldst(luxc1);", "GEN_STORE_FTN_FREG(VAR_2, DT0);", "VAR_6 = \"luxc1\";", "break;", "case OPC_SWXC1:\nGEN_LOAD_FREG_FTN(WT0, VAR_3);", "op_ldst(swc1);", "VAR_6 = \"swxc1\";", "VAR_7 = 1;", "break;", "case OPC_SDXC1:\nGEN_LOAD_FREG_FTN(DT0, VAR_3);", "op_ldst(sdc1);", "VAR_6 = \"sdxc1\";", "VAR_7 = 1;", "break;", "case OPC_SUXC1:\nGEN_LOAD_FREG_FTN(DT0, VAR_3);", "op_ldst(suxc1);", "VAR_6 = \"suxc1\";", "VAR_7 = 1;", "break;", "default:\nMIPS_INVAL(VAR_6);", "generate_exception(VAR_0, EXCP_RI);", "return;", "}", "MIPS_DEBUG(\"%s %s, %s(%s)\", VAR_6, fregnames[VAR_7 ? VAR_3 : VAR_2],\nregnames[VAR_5], regnames[VAR_4]);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 15 ], [ 17 ], [ 19, 21 ], [ 23, 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 47 ], [ 49, 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59, 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69, 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79, 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91, 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103, 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115, 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125, 127 ], [ 129 ] ]
22,173
static DeviceState *apic_init(void *env, uint8_t apic_id) { DeviceState *dev; SysBusDevice *d; static int apic_mapped; dev = qdev_create(NULL, "apic"); qdev_prop_set_uint8(dev, "id", apic_id); qdev_prop_set_ptr(dev, "cpu_env", env); qdev_init_nofail(dev); d = sysbus_from_qdev(dev); /* XXX: mapping more APICs at the same memory location */ if (apic_mapped == 0) { /* NOTE: the APIC is directly connected to the CPU - it is not on the global memory bus. */ /* XXX: what if the base changes? */ sysbus_mmio_map(d, 0, MSI_ADDR_BASE); apic_mapped = 1; } msi_supported = true; return dev; }
false
qemu
680c1c6fd73c0cb3971938944936f18bbb7bad1b
static DeviceState *apic_init(void *env, uint8_t apic_id) { DeviceState *dev; SysBusDevice *d; static int apic_mapped; dev = qdev_create(NULL, "apic"); qdev_prop_set_uint8(dev, "id", apic_id); qdev_prop_set_ptr(dev, "cpu_env", env); qdev_init_nofail(dev); d = sysbus_from_qdev(dev); if (apic_mapped == 0) { sysbus_mmio_map(d, 0, MSI_ADDR_BASE); apic_mapped = 1; } msi_supported = true; return dev; }
{ "code": [], "line_no": [] }
static DeviceState *FUNC_0(void *env, uint8_t apic_id) { DeviceState *dev; SysBusDevice *d; static int VAR_0; dev = qdev_create(NULL, "apic"); qdev_prop_set_uint8(dev, "id", apic_id); qdev_prop_set_ptr(dev, "cpu_env", env); qdev_init_nofail(dev); d = sysbus_from_qdev(dev); if (VAR_0 == 0) { sysbus_mmio_map(d, 0, MSI_ADDR_BASE); VAR_0 = 1; } msi_supported = true; return dev; }
[ "static DeviceState *FUNC_0(void *env, uint8_t apic_id)\n{", "DeviceState *dev;", "SysBusDevice *d;", "static int VAR_0;", "dev = qdev_create(NULL, \"apic\");", "qdev_prop_set_uint8(dev, \"id\", apic_id);", "qdev_prop_set_ptr(dev, \"cpu_env\", env);", "qdev_init_nofail(dev);", "d = sysbus_from_qdev(dev);", "if (VAR_0 == 0) {", "sysbus_mmio_map(d, 0, MSI_ADDR_BASE);", "VAR_0 = 1;", "}", "msi_supported = true;", "return dev;", "}" ]
[ 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 ], [ 27 ], [ 35 ], [ 37 ], [ 39 ], [ 43 ], [ 47 ], [ 49 ] ]
22,174
abi_long do_syscall(void *cpu_env, int num, abi_long arg1, abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6, abi_long arg7, abi_long arg8) { abi_long ret; struct stat st; struct statfs stfs; void *p; #ifdef DEBUG gemu_log("syscall %d", num); #endif if(do_strace) print_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6); switch(num) { case TARGET_NR_exit: #ifdef CONFIG_USE_NPTL /* In old applications this may be used to implement _exit(2). However in threaded applictions it is used for thread termination, and _exit_group is used for application termination. Do thread termination if we have more then one thread. */ /* FIXME: This probably breaks if a signal arrives. We should probably be disabling signals. */ if (first_cpu->next_cpu) { TaskState *ts; CPUArchState **lastp; CPUArchState *p; cpu_list_lock(); lastp = &first_cpu; p = first_cpu; while (p && p != (CPUArchState *)cpu_env) { lastp = &p->next_cpu; p = p->next_cpu; } /* If we didn't find the CPU for this thread then something is horribly wrong. */ if (!p) abort(); /* Remove the CPU from the list. */ *lastp = p->next_cpu; cpu_list_unlock(); ts = ((CPUArchState *)cpu_env)->opaque; if (ts->child_tidptr) { put_user_u32(0, ts->child_tidptr); sys_futex(g2h(ts->child_tidptr), FUTEX_WAKE, INT_MAX, NULL, NULL, 0); } thread_env = NULL; object_delete(OBJECT(ENV_GET_CPU(cpu_env))); g_free(ts); pthread_exit(NULL); } #endif #ifdef TARGET_GPROF _mcleanup(); #endif gdb_exit(cpu_env, arg1); _exit(arg1); ret = 0; /* avoid warning */ break; case TARGET_NR_read: if (arg3 == 0) ret = 0; else { if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0))) goto efault; ret = get_errno(read(arg1, p, arg3)); unlock_user(p, arg2, ret); } break; case TARGET_NR_write: if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1))) goto efault; ret = get_errno(write(arg1, p, arg3)); unlock_user(p, arg2, 0); break; case TARGET_NR_open: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(do_open(cpu_env, p, target_to_host_bitmask(arg2, fcntl_flags_tbl), arg3)); unlock_user(p, arg1, 0); break; #if defined(TARGET_NR_openat) && defined(__NR_openat) case TARGET_NR_openat: if (!(p = lock_user_string(arg2))) goto efault; ret = get_errno(sys_openat(arg1, path(p), target_to_host_bitmask(arg3, fcntl_flags_tbl), arg4)); unlock_user(p, arg2, 0); break; #endif case TARGET_NR_close: ret = get_errno(close(arg1)); break; case TARGET_NR_brk: ret = do_brk(arg1); break; case TARGET_NR_fork: ret = get_errno(do_fork(cpu_env, SIGCHLD, 0, 0, 0, 0)); break; #ifdef TARGET_NR_waitpid case TARGET_NR_waitpid: { int status; ret = get_errno(waitpid(arg1, &status, arg3)); if (!is_error(ret) && arg2 && ret && put_user_s32(host_to_target_waitstatus(status), arg2)) goto efault; } break; #endif #ifdef TARGET_NR_waitid case TARGET_NR_waitid: { siginfo_t info; info.si_pid = 0; ret = get_errno(waitid(arg1, arg2, &info, arg4)); if (!is_error(ret) && arg3 && info.si_pid != 0) { if (!(p = lock_user(VERIFY_WRITE, arg3, sizeof(target_siginfo_t), 0))) goto efault; host_to_target_siginfo(p, &info); unlock_user(p, arg3, sizeof(target_siginfo_t)); } } break; #endif #ifdef TARGET_NR_creat /* not on alpha */ case TARGET_NR_creat: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(creat(p, arg2)); unlock_user(p, arg1, 0); break; #endif case TARGET_NR_link: { void * p2; p = lock_user_string(arg1); p2 = lock_user_string(arg2); if (!p || !p2) ret = -TARGET_EFAULT; else ret = get_errno(link(p, p2)); unlock_user(p2, arg2, 0); unlock_user(p, arg1, 0); } break; #if defined(TARGET_NR_linkat) && defined(__NR_linkat) case TARGET_NR_linkat: { void * p2 = NULL; if (!arg2 || !arg4) goto efault; p = lock_user_string(arg2); p2 = lock_user_string(arg4); if (!p || !p2) ret = -TARGET_EFAULT; else ret = get_errno(sys_linkat(arg1, p, arg3, p2, arg5)); unlock_user(p, arg2, 0); unlock_user(p2, arg4, 0); } break; #endif case TARGET_NR_unlink: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(unlink(p)); unlock_user(p, arg1, 0); break; #if defined(TARGET_NR_unlinkat) && defined(__NR_unlinkat) case TARGET_NR_unlinkat: if (!(p = lock_user_string(arg2))) goto efault; ret = get_errno(sys_unlinkat(arg1, p, arg3)); unlock_user(p, arg2, 0); break; #endif case TARGET_NR_execve: { char **argp, **envp; int argc, envc; abi_ulong gp; abi_ulong guest_argp; abi_ulong guest_envp; abi_ulong addr; char **q; int total_size = 0; argc = 0; guest_argp = arg2; for (gp = guest_argp; gp; gp += sizeof(abi_ulong)) { if (get_user_ual(addr, gp)) goto efault; if (!addr) break; argc++; } envc = 0; guest_envp = arg3; for (gp = guest_envp; gp; gp += sizeof(abi_ulong)) { if (get_user_ual(addr, gp)) goto efault; if (!addr) break; envc++; } argp = alloca((argc + 1) * sizeof(void *)); envp = alloca((envc + 1) * sizeof(void *)); for (gp = guest_argp, q = argp; gp; gp += sizeof(abi_ulong), q++) { if (get_user_ual(addr, gp)) goto execve_efault; if (!addr) break; if (!(*q = lock_user_string(addr))) goto execve_efault; total_size += strlen(*q) + 1; } *q = NULL; for (gp = guest_envp, q = envp; gp; gp += sizeof(abi_ulong), q++) { if (get_user_ual(addr, gp)) goto execve_efault; if (!addr) break; if (!(*q = lock_user_string(addr))) goto execve_efault; total_size += strlen(*q) + 1; } *q = NULL; /* This case will not be caught by the host's execve() if its page size is bigger than the target's. */ if (total_size > MAX_ARG_PAGES * TARGET_PAGE_SIZE) { ret = -TARGET_E2BIG; goto execve_end; } if (!(p = lock_user_string(arg1))) goto execve_efault; ret = get_errno(execve(p, argp, envp)); unlock_user(p, arg1, 0); goto execve_end; execve_efault: ret = -TARGET_EFAULT; execve_end: for (gp = guest_argp, q = argp; *q; gp += sizeof(abi_ulong), q++) { if (get_user_ual(addr, gp) || !addr) break; unlock_user(*q, addr, 0); } for (gp = guest_envp, q = envp; *q; gp += sizeof(abi_ulong), q++) { if (get_user_ual(addr, gp) || !addr) break; unlock_user(*q, addr, 0); } } break; case TARGET_NR_chdir: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(chdir(p)); unlock_user(p, arg1, 0); break; #ifdef TARGET_NR_time case TARGET_NR_time: { time_t host_time; ret = get_errno(time(&host_time)); if (!is_error(ret) && arg1 && put_user_sal(host_time, arg1)) goto efault; } break; #endif case TARGET_NR_mknod: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(mknod(p, arg2, arg3)); unlock_user(p, arg1, 0); break; #if defined(TARGET_NR_mknodat) && defined(__NR_mknodat) case TARGET_NR_mknodat: if (!(p = lock_user_string(arg2))) goto efault; ret = get_errno(sys_mknodat(arg1, p, arg3, arg4)); unlock_user(p, arg2, 0); break; #endif case TARGET_NR_chmod: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(chmod(p, arg2)); unlock_user(p, arg1, 0); break; #ifdef TARGET_NR_break case TARGET_NR_break: goto unimplemented; #endif #ifdef TARGET_NR_oldstat case TARGET_NR_oldstat: goto unimplemented; #endif case TARGET_NR_lseek: ret = get_errno(lseek(arg1, arg2, arg3)); break; #if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA) /* Alpha specific */ case TARGET_NR_getxpid: ((CPUAlphaState *)cpu_env)->ir[IR_A4] = getppid(); ret = get_errno(getpid()); break; #endif #ifdef TARGET_NR_getpid case TARGET_NR_getpid: ret = get_errno(getpid()); break; #endif case TARGET_NR_mount: { /* need to look at the data field */ void *p2, *p3; p = lock_user_string(arg1); p2 = lock_user_string(arg2); p3 = lock_user_string(arg3); if (!p || !p2 || !p3) ret = -TARGET_EFAULT; else { /* FIXME - arg5 should be locked, but it isn't clear how to * do that since it's not guaranteed to be a NULL-terminated * string. */ if ( ! arg5 ) ret = get_errno(mount(p, p2, p3, (unsigned long)arg4, NULL)); else ret = get_errno(mount(p, p2, p3, (unsigned long)arg4, g2h(arg5))); } unlock_user(p, arg1, 0); unlock_user(p2, arg2, 0); unlock_user(p3, arg3, 0); break; } #ifdef TARGET_NR_umount case TARGET_NR_umount: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(umount(p)); unlock_user(p, arg1, 0); break; #endif #ifdef TARGET_NR_stime /* not on alpha */ case TARGET_NR_stime: { time_t host_time; if (get_user_sal(host_time, arg1)) goto efault; ret = get_errno(stime(&host_time)); } break; #endif case TARGET_NR_ptrace: goto unimplemented; #ifdef TARGET_NR_alarm /* not on alpha */ case TARGET_NR_alarm: ret = alarm(arg1); break; #endif #ifdef TARGET_NR_oldfstat case TARGET_NR_oldfstat: goto unimplemented; #endif #ifdef TARGET_NR_pause /* not on alpha */ case TARGET_NR_pause: ret = get_errno(pause()); break; #endif #ifdef TARGET_NR_utime case TARGET_NR_utime: { struct utimbuf tbuf, *host_tbuf; struct target_utimbuf *target_tbuf; if (arg2) { if (!lock_user_struct(VERIFY_READ, target_tbuf, arg2, 1)) goto efault; tbuf.actime = tswapal(target_tbuf->actime); tbuf.modtime = tswapal(target_tbuf->modtime); unlock_user_struct(target_tbuf, arg2, 0); host_tbuf = &tbuf; } else { host_tbuf = NULL; } if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(utime(p, host_tbuf)); unlock_user(p, arg1, 0); } break; #endif case TARGET_NR_utimes: { struct timeval *tvp, tv[2]; if (arg2) { if (copy_from_user_timeval(&tv[0], arg2) || copy_from_user_timeval(&tv[1], arg2 + sizeof(struct target_timeval))) goto efault; tvp = tv; } else { tvp = NULL; } if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(utimes(p, tvp)); unlock_user(p, arg1, 0); } break; #if defined(TARGET_NR_futimesat) && defined(__NR_futimesat) case TARGET_NR_futimesat: { struct timeval *tvp, tv[2]; if (arg3) { if (copy_from_user_timeval(&tv[0], arg3) || copy_from_user_timeval(&tv[1], arg3 + sizeof(struct target_timeval))) goto efault; tvp = tv; } else { tvp = NULL; } if (!(p = lock_user_string(arg2))) goto efault; ret = get_errno(sys_futimesat(arg1, path(p), tvp)); unlock_user(p, arg2, 0); } break; #endif #ifdef TARGET_NR_stty case TARGET_NR_stty: goto unimplemented; #endif #ifdef TARGET_NR_gtty case TARGET_NR_gtty: goto unimplemented; #endif case TARGET_NR_access: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(access(path(p), arg2)); unlock_user(p, arg1, 0); break; #if defined(TARGET_NR_faccessat) && defined(__NR_faccessat) case TARGET_NR_faccessat: if (!(p = lock_user_string(arg2))) goto efault; ret = get_errno(sys_faccessat(arg1, p, arg3)); unlock_user(p, arg2, 0); break; #endif #ifdef TARGET_NR_nice /* not on alpha */ case TARGET_NR_nice: ret = get_errno(nice(arg1)); break; #endif #ifdef TARGET_NR_ftime case TARGET_NR_ftime: goto unimplemented; #endif case TARGET_NR_sync: sync(); ret = 0; break; case TARGET_NR_kill: ret = get_errno(kill(arg1, target_to_host_signal(arg2))); break; case TARGET_NR_rename: { void *p2; p = lock_user_string(arg1); p2 = lock_user_string(arg2); if (!p || !p2) ret = -TARGET_EFAULT; else ret = get_errno(rename(p, p2)); unlock_user(p2, arg2, 0); unlock_user(p, arg1, 0); } break; #if defined(TARGET_NR_renameat) && defined(__NR_renameat) case TARGET_NR_renameat: { void *p2; p = lock_user_string(arg2); p2 = lock_user_string(arg4); if (!p || !p2) ret = -TARGET_EFAULT; else ret = get_errno(sys_renameat(arg1, p, arg3, p2)); unlock_user(p2, arg4, 0); unlock_user(p, arg2, 0); } break; #endif case TARGET_NR_mkdir: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(mkdir(p, arg2)); unlock_user(p, arg1, 0); break; #if defined(TARGET_NR_mkdirat) && defined(__NR_mkdirat) case TARGET_NR_mkdirat: if (!(p = lock_user_string(arg2))) goto efault; ret = get_errno(sys_mkdirat(arg1, p, arg3)); unlock_user(p, arg2, 0); break; #endif case TARGET_NR_rmdir: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(rmdir(p)); unlock_user(p, arg1, 0); break; case TARGET_NR_dup: ret = get_errno(dup(arg1)); break; case TARGET_NR_pipe: ret = do_pipe(cpu_env, arg1, 0, 0); break; #ifdef TARGET_NR_pipe2 case TARGET_NR_pipe2: ret = do_pipe(cpu_env, arg1, target_to_host_bitmask(arg2, fcntl_flags_tbl), 1); break; #endif case TARGET_NR_times: { struct target_tms *tmsp; struct tms tms; ret = get_errno(times(&tms)); if (arg1) { tmsp = lock_user(VERIFY_WRITE, arg1, sizeof(struct target_tms), 0); if (!tmsp) goto efault; tmsp->tms_utime = tswapal(host_to_target_clock_t(tms.tms_utime)); tmsp->tms_stime = tswapal(host_to_target_clock_t(tms.tms_stime)); tmsp->tms_cutime = tswapal(host_to_target_clock_t(tms.tms_cutime)); tmsp->tms_cstime = tswapal(host_to_target_clock_t(tms.tms_cstime)); } if (!is_error(ret)) ret = host_to_target_clock_t(ret); } break; #ifdef TARGET_NR_prof case TARGET_NR_prof: goto unimplemented; #endif #ifdef TARGET_NR_signal case TARGET_NR_signal: goto unimplemented; #endif case TARGET_NR_acct: if (arg1 == 0) { ret = get_errno(acct(NULL)); } else { if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(acct(path(p))); unlock_user(p, arg1, 0); } break; #ifdef TARGET_NR_umount2 /* not on alpha */ case TARGET_NR_umount2: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(umount2(p, arg2)); unlock_user(p, arg1, 0); break; #endif #ifdef TARGET_NR_lock case TARGET_NR_lock: goto unimplemented; #endif case TARGET_NR_ioctl: ret = do_ioctl(arg1, arg2, arg3); break; case TARGET_NR_fcntl: ret = do_fcntl(arg1, arg2, arg3); break; #ifdef TARGET_NR_mpx case TARGET_NR_mpx: goto unimplemented; #endif case TARGET_NR_setpgid: ret = get_errno(setpgid(arg1, arg2)); break; #ifdef TARGET_NR_ulimit case TARGET_NR_ulimit: goto unimplemented; #endif #ifdef TARGET_NR_oldolduname case TARGET_NR_oldolduname: goto unimplemented; #endif case TARGET_NR_umask: ret = get_errno(umask(arg1)); break; case TARGET_NR_chroot: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(chroot(p)); unlock_user(p, arg1, 0); break; case TARGET_NR_ustat: goto unimplemented; case TARGET_NR_dup2: ret = get_errno(dup2(arg1, arg2)); break; #if defined(CONFIG_DUP3) && defined(TARGET_NR_dup3) case TARGET_NR_dup3: ret = get_errno(dup3(arg1, arg2, arg3)); break; #endif #ifdef TARGET_NR_getppid /* not on alpha */ case TARGET_NR_getppid: ret = get_errno(getppid()); break; #endif case TARGET_NR_getpgrp: ret = get_errno(getpgrp()); break; case TARGET_NR_setsid: ret = get_errno(setsid()); break; #ifdef TARGET_NR_sigaction case TARGET_NR_sigaction: { #if defined(TARGET_ALPHA) struct target_sigaction act, oact, *pact = 0; struct target_old_sigaction *old_act; if (arg2) { if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1)) goto efault; act._sa_handler = old_act->_sa_handler; target_siginitset(&act.sa_mask, old_act->sa_mask); act.sa_flags = old_act->sa_flags; act.sa_restorer = 0; unlock_user_struct(old_act, arg2, 0); pact = &act; } ret = get_errno(do_sigaction(arg1, pact, &oact)); if (!is_error(ret) && arg3) { if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0)) goto efault; old_act->_sa_handler = oact._sa_handler; old_act->sa_mask = oact.sa_mask.sig[0]; old_act->sa_flags = oact.sa_flags; unlock_user_struct(old_act, arg3, 1); } #elif defined(TARGET_MIPS) struct target_sigaction act, oact, *pact, *old_act; if (arg2) { if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1)) goto efault; act._sa_handler = old_act->_sa_handler; target_siginitset(&act.sa_mask, old_act->sa_mask.sig[0]); act.sa_flags = old_act->sa_flags; unlock_user_struct(old_act, arg2, 0); pact = &act; } else { pact = NULL; } ret = get_errno(do_sigaction(arg1, pact, &oact)); if (!is_error(ret) && arg3) { if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0)) goto efault; old_act->_sa_handler = oact._sa_handler; old_act->sa_flags = oact.sa_flags; old_act->sa_mask.sig[0] = oact.sa_mask.sig[0]; old_act->sa_mask.sig[1] = 0; old_act->sa_mask.sig[2] = 0; old_act->sa_mask.sig[3] = 0; unlock_user_struct(old_act, arg3, 1); } #else struct target_old_sigaction *old_act; struct target_sigaction act, oact, *pact; if (arg2) { if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1)) goto efault; act._sa_handler = old_act->_sa_handler; target_siginitset(&act.sa_mask, old_act->sa_mask); act.sa_flags = old_act->sa_flags; act.sa_restorer = old_act->sa_restorer; unlock_user_struct(old_act, arg2, 0); pact = &act; } else { pact = NULL; } ret = get_errno(do_sigaction(arg1, pact, &oact)); if (!is_error(ret) && arg3) { if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0)) goto efault; old_act->_sa_handler = oact._sa_handler; old_act->sa_mask = oact.sa_mask.sig[0]; old_act->sa_flags = oact.sa_flags; old_act->sa_restorer = oact.sa_restorer; unlock_user_struct(old_act, arg3, 1); } #endif } break; #endif case TARGET_NR_rt_sigaction: { #if defined(TARGET_ALPHA) struct target_sigaction act, oact, *pact = 0; struct target_rt_sigaction *rt_act; /* ??? arg4 == sizeof(sigset_t). */ if (arg2) { if (!lock_user_struct(VERIFY_READ, rt_act, arg2, 1)) goto efault; act._sa_handler = rt_act->_sa_handler; act.sa_mask = rt_act->sa_mask; act.sa_flags = rt_act->sa_flags; act.sa_restorer = arg5; unlock_user_struct(rt_act, arg2, 0); pact = &act; } ret = get_errno(do_sigaction(arg1, pact, &oact)); if (!is_error(ret) && arg3) { if (!lock_user_struct(VERIFY_WRITE, rt_act, arg3, 0)) goto efault; rt_act->_sa_handler = oact._sa_handler; rt_act->sa_mask = oact.sa_mask; rt_act->sa_flags = oact.sa_flags; unlock_user_struct(rt_act, arg3, 1); } #else struct target_sigaction *act; struct target_sigaction *oact; if (arg2) { if (!lock_user_struct(VERIFY_READ, act, arg2, 1)) goto efault; } else act = NULL; if (arg3) { if (!lock_user_struct(VERIFY_WRITE, oact, arg3, 0)) { ret = -TARGET_EFAULT; goto rt_sigaction_fail; } } else oact = NULL; ret = get_errno(do_sigaction(arg1, act, oact)); rt_sigaction_fail: if (act) unlock_user_struct(act, arg2, 0); if (oact) unlock_user_struct(oact, arg3, 1); #endif } break; #ifdef TARGET_NR_sgetmask /* not on alpha */ case TARGET_NR_sgetmask: { sigset_t cur_set; abi_ulong target_set; sigprocmask(0, NULL, &cur_set); host_to_target_old_sigset(&target_set, &cur_set); ret = target_set; } break; #endif #ifdef TARGET_NR_ssetmask /* not on alpha */ case TARGET_NR_ssetmask: { sigset_t set, oset, cur_set; abi_ulong target_set = arg1; sigprocmask(0, NULL, &cur_set); target_to_host_old_sigset(&set, &target_set); sigorset(&set, &set, &cur_set); sigprocmask(SIG_SETMASK, &set, &oset); host_to_target_old_sigset(&target_set, &oset); ret = target_set; } break; #endif #ifdef TARGET_NR_sigprocmask case TARGET_NR_sigprocmask: { #if defined(TARGET_ALPHA) sigset_t set, oldset; abi_ulong mask; int how; switch (arg1) { case TARGET_SIG_BLOCK: how = SIG_BLOCK; break; case TARGET_SIG_UNBLOCK: how = SIG_UNBLOCK; break; case TARGET_SIG_SETMASK: how = SIG_SETMASK; break; default: ret = -TARGET_EINVAL; goto fail; } mask = arg2; target_to_host_old_sigset(&set, &mask); ret = get_errno(sigprocmask(how, &set, &oldset)); if (!is_error(ret)) { host_to_target_old_sigset(&mask, &oldset); ret = mask; ((CPUAlphaState *)cpu_env)->ir[IR_V0] = 0; /* force no error */ } #else sigset_t set, oldset, *set_ptr; int how; if (arg2) { switch (arg1) { case TARGET_SIG_BLOCK: how = SIG_BLOCK; break; case TARGET_SIG_UNBLOCK: how = SIG_UNBLOCK; break; case TARGET_SIG_SETMASK: how = SIG_SETMASK; break; default: ret = -TARGET_EINVAL; goto fail; } if (!(p = lock_user(VERIFY_READ, arg2, sizeof(target_sigset_t), 1))) goto efault; target_to_host_old_sigset(&set, p); unlock_user(p, arg2, 0); set_ptr = &set; } else { how = 0; set_ptr = NULL; } ret = get_errno(sigprocmask(how, set_ptr, &oldset)); if (!is_error(ret) && arg3) { if (!(p = lock_user(VERIFY_WRITE, arg3, sizeof(target_sigset_t), 0))) goto efault; host_to_target_old_sigset(p, &oldset); unlock_user(p, arg3, sizeof(target_sigset_t)); } #endif } break; #endif case TARGET_NR_rt_sigprocmask: { int how = arg1; sigset_t set, oldset, *set_ptr; if (arg2) { switch(how) { case TARGET_SIG_BLOCK: how = SIG_BLOCK; break; case TARGET_SIG_UNBLOCK: how = SIG_UNBLOCK; break; case TARGET_SIG_SETMASK: how = SIG_SETMASK; break; default: ret = -TARGET_EINVAL; goto fail; } if (!(p = lock_user(VERIFY_READ, arg2, sizeof(target_sigset_t), 1))) goto efault; target_to_host_sigset(&set, p); unlock_user(p, arg2, 0); set_ptr = &set; } else { how = 0; set_ptr = NULL; } ret = get_errno(sigprocmask(how, set_ptr, &oldset)); if (!is_error(ret) && arg3) { if (!(p = lock_user(VERIFY_WRITE, arg3, sizeof(target_sigset_t), 0))) goto efault; host_to_target_sigset(p, &oldset); unlock_user(p, arg3, sizeof(target_sigset_t)); } } break; #ifdef TARGET_NR_sigpending case TARGET_NR_sigpending: { sigset_t set; ret = get_errno(sigpending(&set)); if (!is_error(ret)) { if (!(p = lock_user(VERIFY_WRITE, arg1, sizeof(target_sigset_t), 0))) goto efault; host_to_target_old_sigset(p, &set); unlock_user(p, arg1, sizeof(target_sigset_t)); } } break; #endif case TARGET_NR_rt_sigpending: { sigset_t set; ret = get_errno(sigpending(&set)); if (!is_error(ret)) { if (!(p = lock_user(VERIFY_WRITE, arg1, sizeof(target_sigset_t), 0))) goto efault; host_to_target_sigset(p, &set); unlock_user(p, arg1, sizeof(target_sigset_t)); } } break; #ifdef TARGET_NR_sigsuspend case TARGET_NR_sigsuspend: { sigset_t set; #if defined(TARGET_ALPHA) abi_ulong mask = arg1; target_to_host_old_sigset(&set, &mask); #else if (!(p = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1))) goto efault; target_to_host_old_sigset(&set, p); unlock_user(p, arg1, 0); #endif ret = get_errno(sigsuspend(&set)); } break; #endif case TARGET_NR_rt_sigsuspend: { sigset_t set; if (!(p = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1))) goto efault; target_to_host_sigset(&set, p); unlock_user(p, arg1, 0); ret = get_errno(sigsuspend(&set)); } break; case TARGET_NR_rt_sigtimedwait: { sigset_t set; struct timespec uts, *puts; siginfo_t uinfo; if (!(p = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1))) goto efault; target_to_host_sigset(&set, p); unlock_user(p, arg1, 0); if (arg3) { puts = &uts; target_to_host_timespec(puts, arg3); } else { puts = NULL; } ret = get_errno(sigtimedwait(&set, &uinfo, puts)); if (!is_error(ret) && arg2) { if (!(p = lock_user(VERIFY_WRITE, arg2, sizeof(target_siginfo_t), 0))) goto efault; host_to_target_siginfo(p, &uinfo); unlock_user(p, arg2, sizeof(target_siginfo_t)); } } break; case TARGET_NR_rt_sigqueueinfo: { siginfo_t uinfo; if (!(p = lock_user(VERIFY_READ, arg3, sizeof(target_sigset_t), 1))) goto efault; target_to_host_siginfo(&uinfo, p); unlock_user(p, arg1, 0); ret = get_errno(sys_rt_sigqueueinfo(arg1, arg2, &uinfo)); } break; #ifdef TARGET_NR_sigreturn case TARGET_NR_sigreturn: /* NOTE: ret is eax, so not transcoding must be done */ ret = do_sigreturn(cpu_env); break; #endif case TARGET_NR_rt_sigreturn: /* NOTE: ret is eax, so not transcoding must be done */ ret = do_rt_sigreturn(cpu_env); break; case TARGET_NR_sethostname: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(sethostname(p, arg2)); unlock_user(p, arg1, 0); break; case TARGET_NR_setrlimit: { int resource = target_to_host_resource(arg1); struct target_rlimit *target_rlim; struct rlimit rlim; if (!lock_user_struct(VERIFY_READ, target_rlim, arg2, 1)) goto efault; rlim.rlim_cur = target_to_host_rlim(target_rlim->rlim_cur); rlim.rlim_max = target_to_host_rlim(target_rlim->rlim_max); unlock_user_struct(target_rlim, arg2, 0); ret = get_errno(setrlimit(resource, &rlim)); } break; case TARGET_NR_getrlimit: { int resource = target_to_host_resource(arg1); struct target_rlimit *target_rlim; struct rlimit rlim; ret = get_errno(getrlimit(resource, &rlim)); if (!is_error(ret)) { if (!lock_user_struct(VERIFY_WRITE, target_rlim, arg2, 0)) goto efault; target_rlim->rlim_cur = host_to_target_rlim(rlim.rlim_cur); target_rlim->rlim_max = host_to_target_rlim(rlim.rlim_max); unlock_user_struct(target_rlim, arg2, 1); } } break; case TARGET_NR_getrusage: { struct rusage rusage; ret = get_errno(getrusage(arg1, &rusage)); if (!is_error(ret)) { host_to_target_rusage(arg2, &rusage); } } break; case TARGET_NR_gettimeofday: { struct timeval tv; ret = get_errno(gettimeofday(&tv, NULL)); if (!is_error(ret)) { if (copy_to_user_timeval(arg1, &tv)) goto efault; } } break; case TARGET_NR_settimeofday: { struct timeval tv; if (copy_from_user_timeval(&tv, arg1)) goto efault; ret = get_errno(settimeofday(&tv, NULL)); } break; #if defined(TARGET_NR_select) && !defined(TARGET_S390X) && !defined(TARGET_S390) case TARGET_NR_select: { struct target_sel_arg_struct *sel; abi_ulong inp, outp, exp, tvp; long nsel; if (!lock_user_struct(VERIFY_READ, sel, arg1, 1)) goto efault; nsel = tswapal(sel->n); inp = tswapal(sel->inp); outp = tswapal(sel->outp); exp = tswapal(sel->exp); tvp = tswapal(sel->tvp); unlock_user_struct(sel, arg1, 0); ret = do_select(nsel, inp, outp, exp, tvp); } break; #endif #ifdef TARGET_NR_pselect6 case TARGET_NR_pselect6: { abi_long rfd_addr, wfd_addr, efd_addr, n, ts_addr; fd_set rfds, wfds, efds; fd_set *rfds_ptr, *wfds_ptr, *efds_ptr; struct timespec ts, *ts_ptr; /* * The 6th arg is actually two args smashed together, * so we cannot use the C library. */ sigset_t set; struct { sigset_t *set; size_t size; } sig, *sig_ptr; abi_ulong arg_sigset, arg_sigsize, *arg7; target_sigset_t *target_sigset; n = arg1; rfd_addr = arg2; wfd_addr = arg3; efd_addr = arg4; ts_addr = arg5; ret = copy_from_user_fdset_ptr(&rfds, &rfds_ptr, rfd_addr, n); if (ret) { goto fail; } ret = copy_from_user_fdset_ptr(&wfds, &wfds_ptr, wfd_addr, n); if (ret) { goto fail; } ret = copy_from_user_fdset_ptr(&efds, &efds_ptr, efd_addr, n); if (ret) { goto fail; } /* * This takes a timespec, and not a timeval, so we cannot * use the do_select() helper ... */ if (ts_addr) { if (target_to_host_timespec(&ts, ts_addr)) { goto efault; } ts_ptr = &ts; } else { ts_ptr = NULL; } /* Extract the two packed args for the sigset */ if (arg6) { sig_ptr = &sig; sig.size = _NSIG / 8; arg7 = lock_user(VERIFY_READ, arg6, sizeof(*arg7) * 2, 1); if (!arg7) { goto efault; } arg_sigset = tswapal(arg7[0]); arg_sigsize = tswapal(arg7[1]); unlock_user(arg7, arg6, 0); if (arg_sigset) { sig.set = &set; if (arg_sigsize != sizeof(*target_sigset)) { /* Like the kernel, we enforce correct size sigsets */ ret = -TARGET_EINVAL; goto fail; } target_sigset = lock_user(VERIFY_READ, arg_sigset, sizeof(*target_sigset), 1); if (!target_sigset) { goto efault; } target_to_host_sigset(&set, target_sigset); unlock_user(target_sigset, arg_sigset, 0); } else { sig.set = NULL; } } else { sig_ptr = NULL; } ret = get_errno(sys_pselect6(n, rfds_ptr, wfds_ptr, efds_ptr, ts_ptr, sig_ptr)); if (!is_error(ret)) { if (rfd_addr && copy_to_user_fdset(rfd_addr, &rfds, n)) goto efault; if (wfd_addr && copy_to_user_fdset(wfd_addr, &wfds, n)) goto efault; if (efd_addr && copy_to_user_fdset(efd_addr, &efds, n)) goto efault; if (ts_addr && host_to_target_timespec(ts_addr, &ts)) goto efault; } } break; #endif case TARGET_NR_symlink: { void *p2; p = lock_user_string(arg1); p2 = lock_user_string(arg2); if (!p || !p2) ret = -TARGET_EFAULT; else ret = get_errno(symlink(p, p2)); unlock_user(p2, arg2, 0); unlock_user(p, arg1, 0); } break; #if defined(TARGET_NR_symlinkat) && defined(__NR_symlinkat) case TARGET_NR_symlinkat: { void *p2; p = lock_user_string(arg1); p2 = lock_user_string(arg3); if (!p || !p2) ret = -TARGET_EFAULT; else ret = get_errno(sys_symlinkat(p, arg2, p2)); unlock_user(p2, arg3, 0); unlock_user(p, arg1, 0); } break; #endif #ifdef TARGET_NR_oldlstat case TARGET_NR_oldlstat: goto unimplemented; #endif case TARGET_NR_readlink: { void *p2, *temp; p = lock_user_string(arg1); p2 = lock_user(VERIFY_WRITE, arg2, arg3, 0); if (!p || !p2) ret = -TARGET_EFAULT; else { if (strncmp((const char *)p, "/proc/self/exe", 14) == 0) { char real[PATH_MAX]; temp = realpath(exec_path,real); ret = (temp==NULL) ? get_errno(-1) : strlen(real) ; snprintf((char *)p2, arg3, "%s", real); } else ret = get_errno(readlink(path(p), p2, arg3)); } unlock_user(p2, arg2, ret); unlock_user(p, arg1, 0); } break; #if defined(TARGET_NR_readlinkat) && defined(__NR_readlinkat) case TARGET_NR_readlinkat: { void *p2; p = lock_user_string(arg2); p2 = lock_user(VERIFY_WRITE, arg3, arg4, 0); if (!p || !p2) ret = -TARGET_EFAULT; else ret = get_errno(sys_readlinkat(arg1, path(p), p2, arg4)); unlock_user(p2, arg3, ret); unlock_user(p, arg2, 0); } break; #endif #ifdef TARGET_NR_uselib case TARGET_NR_uselib: goto unimplemented; #endif #ifdef TARGET_NR_swapon case TARGET_NR_swapon: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(swapon(p, arg2)); unlock_user(p, arg1, 0); break; #endif case TARGET_NR_reboot: if (!(p = lock_user_string(arg4))) goto efault; ret = reboot(arg1, arg2, arg3, p); unlock_user(p, arg4, 0); break; #ifdef TARGET_NR_readdir case TARGET_NR_readdir: goto unimplemented; #endif #ifdef TARGET_NR_mmap case TARGET_NR_mmap: #if (defined(TARGET_I386) && defined(TARGET_ABI32)) || defined(TARGET_ARM) || \ defined(TARGET_M68K) || defined(TARGET_CRIS) || defined(TARGET_MICROBLAZE) \ || defined(TARGET_S390X) { abi_ulong *v; abi_ulong v1, v2, v3, v4, v5, v6; if (!(v = lock_user(VERIFY_READ, arg1, 6 * sizeof(abi_ulong), 1))) goto efault; v1 = tswapal(v[0]); v2 = tswapal(v[1]); v3 = tswapal(v[2]); v4 = tswapal(v[3]); v5 = tswapal(v[4]); v6 = tswapal(v[5]); unlock_user(v, arg1, 0); ret = get_errno(target_mmap(v1, v2, v3, target_to_host_bitmask(v4, mmap_flags_tbl), v5, v6)); } #else ret = get_errno(target_mmap(arg1, arg2, arg3, target_to_host_bitmask(arg4, mmap_flags_tbl), arg5, arg6)); #endif break; #endif #ifdef TARGET_NR_mmap2 case TARGET_NR_mmap2: #ifndef MMAP_SHIFT #define MMAP_SHIFT 12 #endif ret = get_errno(target_mmap(arg1, arg2, arg3, target_to_host_bitmask(arg4, mmap_flags_tbl), arg5, arg6 << MMAP_SHIFT)); break; #endif case TARGET_NR_munmap: ret = get_errno(target_munmap(arg1, arg2)); break; case TARGET_NR_mprotect: { TaskState *ts = ((CPUArchState *)cpu_env)->opaque; /* Special hack to detect libc making the stack executable. */ if ((arg3 & PROT_GROWSDOWN) && arg1 >= ts->info->stack_limit && arg1 <= ts->info->start_stack) { arg3 &= ~PROT_GROWSDOWN; arg2 = arg2 + arg1 - ts->info->stack_limit; arg1 = ts->info->stack_limit; } } ret = get_errno(target_mprotect(arg1, arg2, arg3)); break; #ifdef TARGET_NR_mremap case TARGET_NR_mremap: ret = get_errno(target_mremap(arg1, arg2, arg3, arg4, arg5)); break; #endif /* ??? msync/mlock/munlock are broken for softmmu. */ #ifdef TARGET_NR_msync case TARGET_NR_msync: ret = get_errno(msync(g2h(arg1), arg2, arg3)); break; #endif #ifdef TARGET_NR_mlock case TARGET_NR_mlock: ret = get_errno(mlock(g2h(arg1), arg2)); break; #endif #ifdef TARGET_NR_munlock case TARGET_NR_munlock: ret = get_errno(munlock(g2h(arg1), arg2)); break; #endif #ifdef TARGET_NR_mlockall case TARGET_NR_mlockall: ret = get_errno(mlockall(arg1)); break; #endif #ifdef TARGET_NR_munlockall case TARGET_NR_munlockall: ret = get_errno(munlockall()); break; #endif case TARGET_NR_truncate: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(truncate(p, arg2)); unlock_user(p, arg1, 0); break; case TARGET_NR_ftruncate: ret = get_errno(ftruncate(arg1, arg2)); break; case TARGET_NR_fchmod: ret = get_errno(fchmod(arg1, arg2)); break; #if defined(TARGET_NR_fchmodat) && defined(__NR_fchmodat) case TARGET_NR_fchmodat: if (!(p = lock_user_string(arg2))) goto efault; ret = get_errno(sys_fchmodat(arg1, p, arg3)); unlock_user(p, arg2, 0); break; #endif case TARGET_NR_getpriority: /* Note that negative values are valid for getpriority, so we must differentiate based on errno settings. */ errno = 0; ret = getpriority(arg1, arg2); if (ret == -1 && errno != 0) { ret = -host_to_target_errno(errno); break; } #ifdef TARGET_ALPHA /* Return value is the unbiased priority. Signal no error. */ ((CPUAlphaState *)cpu_env)->ir[IR_V0] = 0; #else /* Return value is a biased priority to avoid negative numbers. */ ret = 20 - ret; #endif break; case TARGET_NR_setpriority: ret = get_errno(setpriority(arg1, arg2, arg3)); break; #ifdef TARGET_NR_profil case TARGET_NR_profil: goto unimplemented; #endif case TARGET_NR_statfs: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(statfs(path(p), &stfs)); unlock_user(p, arg1, 0); convert_statfs: if (!is_error(ret)) { struct target_statfs *target_stfs; if (!lock_user_struct(VERIFY_WRITE, target_stfs, arg2, 0)) goto efault; __put_user(stfs.f_type, &target_stfs->f_type); __put_user(stfs.f_bsize, &target_stfs->f_bsize); __put_user(stfs.f_blocks, &target_stfs->f_blocks); __put_user(stfs.f_bfree, &target_stfs->f_bfree); __put_user(stfs.f_bavail, &target_stfs->f_bavail); __put_user(stfs.f_files, &target_stfs->f_files); __put_user(stfs.f_ffree, &target_stfs->f_ffree); __put_user(stfs.f_fsid.__val[0], &target_stfs->f_fsid.val[0]); __put_user(stfs.f_fsid.__val[1], &target_stfs->f_fsid.val[1]); __put_user(stfs.f_namelen, &target_stfs->f_namelen); __put_user(stfs.f_frsize, &target_stfs->f_frsize); memset(target_stfs->f_spare, 0, sizeof(target_stfs->f_spare)); unlock_user_struct(target_stfs, arg2, 1); } break; case TARGET_NR_fstatfs: ret = get_errno(fstatfs(arg1, &stfs)); goto convert_statfs; #ifdef TARGET_NR_statfs64 case TARGET_NR_statfs64: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(statfs(path(p), &stfs)); unlock_user(p, arg1, 0); convert_statfs64: if (!is_error(ret)) { struct target_statfs64 *target_stfs; if (!lock_user_struct(VERIFY_WRITE, target_stfs, arg3, 0)) goto efault; __put_user(stfs.f_type, &target_stfs->f_type); __put_user(stfs.f_bsize, &target_stfs->f_bsize); __put_user(stfs.f_blocks, &target_stfs->f_blocks); __put_user(stfs.f_bfree, &target_stfs->f_bfree); __put_user(stfs.f_bavail, &target_stfs->f_bavail); __put_user(stfs.f_files, &target_stfs->f_files); __put_user(stfs.f_ffree, &target_stfs->f_ffree); __put_user(stfs.f_fsid.__val[0], &target_stfs->f_fsid.val[0]); __put_user(stfs.f_fsid.__val[1], &target_stfs->f_fsid.val[1]); __put_user(stfs.f_namelen, &target_stfs->f_namelen); __put_user(stfs.f_frsize, &target_stfs->f_frsize); memset(target_stfs->f_spare, 0, sizeof(target_stfs->f_spare)); unlock_user_struct(target_stfs, arg3, 1); } break; case TARGET_NR_fstatfs64: ret = get_errno(fstatfs(arg1, &stfs)); goto convert_statfs64; #endif #ifdef TARGET_NR_ioperm case TARGET_NR_ioperm: goto unimplemented; #endif #ifdef TARGET_NR_socketcall case TARGET_NR_socketcall: ret = do_socketcall(arg1, arg2); break; #endif #ifdef TARGET_NR_accept case TARGET_NR_accept: ret = do_accept(arg1, arg2, arg3); break; #endif #ifdef TARGET_NR_bind case TARGET_NR_bind: ret = do_bind(arg1, arg2, arg3); break; #endif #ifdef TARGET_NR_connect case TARGET_NR_connect: ret = do_connect(arg1, arg2, arg3); break; #endif #ifdef TARGET_NR_getpeername case TARGET_NR_getpeername: ret = do_getpeername(arg1, arg2, arg3); break; #endif #ifdef TARGET_NR_getsockname case TARGET_NR_getsockname: ret = do_getsockname(arg1, arg2, arg3); break; #endif #ifdef TARGET_NR_getsockopt case TARGET_NR_getsockopt: ret = do_getsockopt(arg1, arg2, arg3, arg4, arg5); break; #endif #ifdef TARGET_NR_listen case TARGET_NR_listen: ret = get_errno(listen(arg1, arg2)); break; #endif #ifdef TARGET_NR_recv case TARGET_NR_recv: ret = do_recvfrom(arg1, arg2, arg3, arg4, 0, 0); break; #endif #ifdef TARGET_NR_recvfrom case TARGET_NR_recvfrom: ret = do_recvfrom(arg1, arg2, arg3, arg4, arg5, arg6); break; #endif #ifdef TARGET_NR_recvmsg case TARGET_NR_recvmsg: ret = do_sendrecvmsg(arg1, arg2, arg3, 0); break; #endif #ifdef TARGET_NR_send case TARGET_NR_send: ret = do_sendto(arg1, arg2, arg3, arg4, 0, 0); break; #endif #ifdef TARGET_NR_sendmsg case TARGET_NR_sendmsg: ret = do_sendrecvmsg(arg1, arg2, arg3, 1); break; #endif #ifdef TARGET_NR_sendto case TARGET_NR_sendto: ret = do_sendto(arg1, arg2, arg3, arg4, arg5, arg6); break; #endif #ifdef TARGET_NR_shutdown case TARGET_NR_shutdown: ret = get_errno(shutdown(arg1, arg2)); break; #endif #ifdef TARGET_NR_socket case TARGET_NR_socket: ret = do_socket(arg1, arg2, arg3); break; #endif #ifdef TARGET_NR_socketpair case TARGET_NR_socketpair: ret = do_socketpair(arg1, arg2, arg3, arg4); break; #endif #ifdef TARGET_NR_setsockopt case TARGET_NR_setsockopt: ret = do_setsockopt(arg1, arg2, arg3, arg4, (socklen_t) arg5); break; #endif case TARGET_NR_syslog: if (!(p = lock_user_string(arg2))) goto efault; ret = get_errno(sys_syslog((int)arg1, p, (int)arg3)); unlock_user(p, arg2, 0); break; case TARGET_NR_setitimer: { struct itimerval value, ovalue, *pvalue; if (arg2) { pvalue = &value; if (copy_from_user_timeval(&pvalue->it_interval, arg2) || copy_from_user_timeval(&pvalue->it_value, arg2 + sizeof(struct target_timeval))) goto efault; } else { pvalue = NULL; } ret = get_errno(setitimer(arg1, pvalue, &ovalue)); if (!is_error(ret) && arg3) { if (copy_to_user_timeval(arg3, &ovalue.it_interval) || copy_to_user_timeval(arg3 + sizeof(struct target_timeval), &ovalue.it_value)) goto efault; } } break; case TARGET_NR_getitimer: { struct itimerval value; ret = get_errno(getitimer(arg1, &value)); if (!is_error(ret) && arg2) { if (copy_to_user_timeval(arg2, &value.it_interval) || copy_to_user_timeval(arg2 + sizeof(struct target_timeval), &value.it_value)) goto efault; } } break; case TARGET_NR_stat: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(stat(path(p), &st)); unlock_user(p, arg1, 0); goto do_stat; case TARGET_NR_lstat: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(lstat(path(p), &st)); unlock_user(p, arg1, 0); goto do_stat; case TARGET_NR_fstat: { ret = get_errno(fstat(arg1, &st)); do_stat: if (!is_error(ret)) { struct target_stat *target_st; if (!lock_user_struct(VERIFY_WRITE, target_st, arg2, 0)) goto efault; memset(target_st, 0, sizeof(*target_st)); __put_user(st.st_dev, &target_st->st_dev); __put_user(st.st_ino, &target_st->st_ino); __put_user(st.st_mode, &target_st->st_mode); __put_user(st.st_uid, &target_st->st_uid); __put_user(st.st_gid, &target_st->st_gid); __put_user(st.st_nlink, &target_st->st_nlink); __put_user(st.st_rdev, &target_st->st_rdev); __put_user(st.st_size, &target_st->st_size); __put_user(st.st_blksize, &target_st->st_blksize); __put_user(st.st_blocks, &target_st->st_blocks); __put_user(st.st_atime, &target_st->target_st_atime); __put_user(st.st_mtime, &target_st->target_st_mtime); __put_user(st.st_ctime, &target_st->target_st_ctime); unlock_user_struct(target_st, arg2, 1); } } break; #ifdef TARGET_NR_olduname case TARGET_NR_olduname: goto unimplemented; #endif #ifdef TARGET_NR_iopl case TARGET_NR_iopl: goto unimplemented; #endif case TARGET_NR_vhangup: ret = get_errno(vhangup()); break; #ifdef TARGET_NR_idle case TARGET_NR_idle: goto unimplemented; #endif #ifdef TARGET_NR_syscall case TARGET_NR_syscall: ret = do_syscall(cpu_env, arg1 & 0xffff, arg2, arg3, arg4, arg5, arg6, arg7, arg8, 0); break; #endif case TARGET_NR_wait4: { int status; abi_long status_ptr = arg2; struct rusage rusage, *rusage_ptr; abi_ulong target_rusage = arg4; if (target_rusage) rusage_ptr = &rusage; else rusage_ptr = NULL; ret = get_errno(wait4(arg1, &status, arg3, rusage_ptr)); if (!is_error(ret)) { if (status_ptr && ret) { status = host_to_target_waitstatus(status); if (put_user_s32(status, status_ptr)) goto efault; } if (target_rusage) host_to_target_rusage(target_rusage, &rusage); } } break; #ifdef TARGET_NR_swapoff case TARGET_NR_swapoff: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(swapoff(p)); unlock_user(p, arg1, 0); break; #endif case TARGET_NR_sysinfo: { struct target_sysinfo *target_value; struct sysinfo value; ret = get_errno(sysinfo(&value)); if (!is_error(ret) && arg1) { if (!lock_user_struct(VERIFY_WRITE, target_value, arg1, 0)) goto efault; __put_user(value.uptime, &target_value->uptime); __put_user(value.loads[0], &target_value->loads[0]); __put_user(value.loads[1], &target_value->loads[1]); __put_user(value.loads[2], &target_value->loads[2]); __put_user(value.totalram, &target_value->totalram); __put_user(value.freeram, &target_value->freeram); __put_user(value.sharedram, &target_value->sharedram); __put_user(value.bufferram, &target_value->bufferram); __put_user(value.totalswap, &target_value->totalswap); __put_user(value.freeswap, &target_value->freeswap); __put_user(value.procs, &target_value->procs); __put_user(value.totalhigh, &target_value->totalhigh); __put_user(value.freehigh, &target_value->freehigh); __put_user(value.mem_unit, &target_value->mem_unit); unlock_user_struct(target_value, arg1, 1); } } break; #ifdef TARGET_NR_ipc case TARGET_NR_ipc: ret = do_ipc(arg1, arg2, arg3, arg4, arg5, arg6); break; #endif #ifdef TARGET_NR_semget case TARGET_NR_semget: ret = get_errno(semget(arg1, arg2, arg3)); break; #endif #ifdef TARGET_NR_semop case TARGET_NR_semop: ret = get_errno(do_semop(arg1, arg2, arg3)); break; #endif #ifdef TARGET_NR_semctl case TARGET_NR_semctl: ret = do_semctl(arg1, arg2, arg3, (union target_semun)(abi_ulong)arg4); break; #endif #ifdef TARGET_NR_msgctl case TARGET_NR_msgctl: ret = do_msgctl(arg1, arg2, arg3); break; #endif #ifdef TARGET_NR_msgget case TARGET_NR_msgget: ret = get_errno(msgget(arg1, arg2)); break; #endif #ifdef TARGET_NR_msgrcv case TARGET_NR_msgrcv: ret = do_msgrcv(arg1, arg2, arg3, arg4, arg5); break; #endif #ifdef TARGET_NR_msgsnd case TARGET_NR_msgsnd: ret = do_msgsnd(arg1, arg2, arg3, arg4); break; #endif #ifdef TARGET_NR_shmget case TARGET_NR_shmget: ret = get_errno(shmget(arg1, arg2, arg3)); break; #endif #ifdef TARGET_NR_shmctl case TARGET_NR_shmctl: ret = do_shmctl(arg1, arg2, arg3); break; #endif #ifdef TARGET_NR_shmat case TARGET_NR_shmat: ret = do_shmat(arg1, arg2, arg3); break; #endif #ifdef TARGET_NR_shmdt case TARGET_NR_shmdt: ret = do_shmdt(arg1); break; #endif case TARGET_NR_fsync: ret = get_errno(fsync(arg1)); break; case TARGET_NR_clone: #if defined(TARGET_SH4) || defined(TARGET_ALPHA) ret = get_errno(do_fork(cpu_env, arg1, arg2, arg3, arg5, arg4)); #elif defined(TARGET_CRIS) ret = get_errno(do_fork(cpu_env, arg2, arg1, arg3, arg4, arg5)); #elif defined(TARGET_S390X) ret = get_errno(do_fork(cpu_env, arg2, arg1, arg3, arg5, arg4)); #else ret = get_errno(do_fork(cpu_env, arg1, arg2, arg3, arg4, arg5)); #endif break; #ifdef __NR_exit_group /* new thread calls */ case TARGET_NR_exit_group: #ifdef TARGET_GPROF _mcleanup(); #endif gdb_exit(cpu_env, arg1); ret = get_errno(exit_group(arg1)); break; #endif case TARGET_NR_setdomainname: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(setdomainname(p, arg2)); unlock_user(p, arg1, 0); break; case TARGET_NR_uname: /* no need to transcode because we use the linux syscall */ { struct new_utsname * buf; if (!lock_user_struct(VERIFY_WRITE, buf, arg1, 0)) goto efault; ret = get_errno(sys_uname(buf)); if (!is_error(ret)) { /* Overrite the native machine name with whatever is being emulated. */ strcpy (buf->machine, cpu_to_uname_machine(cpu_env)); /* Allow the user to override the reported release. */ if (qemu_uname_release && *qemu_uname_release) strcpy (buf->release, qemu_uname_release); } unlock_user_struct(buf, arg1, 1); } break; #ifdef TARGET_I386 case TARGET_NR_modify_ldt: ret = do_modify_ldt(cpu_env, arg1, arg2, arg3); break; #if !defined(TARGET_X86_64) case TARGET_NR_vm86old: goto unimplemented; case TARGET_NR_vm86: ret = do_vm86(cpu_env, arg1, arg2); break; #endif #endif case TARGET_NR_adjtimex: goto unimplemented; #ifdef TARGET_NR_create_module case TARGET_NR_create_module: #endif case TARGET_NR_init_module: case TARGET_NR_delete_module: #ifdef TARGET_NR_get_kernel_syms case TARGET_NR_get_kernel_syms: #endif goto unimplemented; case TARGET_NR_quotactl: goto unimplemented; case TARGET_NR_getpgid: ret = get_errno(getpgid(arg1)); break; case TARGET_NR_fchdir: ret = get_errno(fchdir(arg1)); break; #ifdef TARGET_NR_bdflush /* not on x86_64 */ case TARGET_NR_bdflush: goto unimplemented; #endif #ifdef TARGET_NR_sysfs case TARGET_NR_sysfs: goto unimplemented; #endif case TARGET_NR_personality: ret = get_errno(personality(arg1)); break; #ifdef TARGET_NR_afs_syscall case TARGET_NR_afs_syscall: goto unimplemented; #endif #ifdef TARGET_NR__llseek /* Not on alpha */ case TARGET_NR__llseek: { int64_t res; #if !defined(__NR_llseek) res = lseek(arg1, ((uint64_t)arg2 << 32) | arg3, arg5); if (res == -1) { ret = get_errno(res); } else { ret = 0; } #else ret = get_errno(_llseek(arg1, arg2, arg3, &res, arg5)); #endif if ((ret == 0) && put_user_s64(res, arg4)) { goto efault; } } break; #endif case TARGET_NR_getdents: #if TARGET_ABI_BITS == 32 && HOST_LONG_BITS == 64 { struct target_dirent *target_dirp; struct linux_dirent *dirp; abi_long count = arg3; dirp = malloc(count); if (!dirp) { ret = -TARGET_ENOMEM; goto fail; } ret = get_errno(sys_getdents(arg1, dirp, count)); if (!is_error(ret)) { struct linux_dirent *de; struct target_dirent *tde; int len = ret; int reclen, treclen; int count1, tnamelen; count1 = 0; de = dirp; if (!(target_dirp = lock_user(VERIFY_WRITE, arg2, count, 0))) goto efault; tde = target_dirp; while (len > 0) { reclen = de->d_reclen; tnamelen = reclen - offsetof(struct linux_dirent, d_name); assert(tnamelen >= 0); treclen = tnamelen + offsetof(struct target_dirent, d_name); assert(count1 + treclen <= count); tde->d_reclen = tswap16(treclen); tde->d_ino = tswapal(de->d_ino); tde->d_off = tswapal(de->d_off); memcpy(tde->d_name, de->d_name, tnamelen); de = (struct linux_dirent *)((char *)de + reclen); len -= reclen; tde = (struct target_dirent *)((char *)tde + treclen); count1 += treclen; } ret = count1; unlock_user(target_dirp, arg2, ret); } free(dirp); } #else { struct linux_dirent *dirp; abi_long count = arg3; if (!(dirp = lock_user(VERIFY_WRITE, arg2, count, 0))) goto efault; ret = get_errno(sys_getdents(arg1, dirp, count)); if (!is_error(ret)) { struct linux_dirent *de; int len = ret; int reclen; de = dirp; while (len > 0) { reclen = de->d_reclen; if (reclen > len) break; de->d_reclen = tswap16(reclen); tswapls(&de->d_ino); tswapls(&de->d_off); de = (struct linux_dirent *)((char *)de + reclen); len -= reclen; } } unlock_user(dirp, arg2, ret); } #endif break; #if defined(TARGET_NR_getdents64) && defined(__NR_getdents64) case TARGET_NR_getdents64: { struct linux_dirent64 *dirp; abi_long count = arg3; if (!(dirp = lock_user(VERIFY_WRITE, arg2, count, 0))) goto efault; ret = get_errno(sys_getdents64(arg1, dirp, count)); if (!is_error(ret)) { struct linux_dirent64 *de; int len = ret; int reclen; de = dirp; while (len > 0) { reclen = de->d_reclen; if (reclen > len) break; de->d_reclen = tswap16(reclen); tswap64s((uint64_t *)&de->d_ino); tswap64s((uint64_t *)&de->d_off); de = (struct linux_dirent64 *)((char *)de + reclen); len -= reclen; } } unlock_user(dirp, arg2, ret); } break; #endif /* TARGET_NR_getdents64 */ #if defined(TARGET_NR__newselect) || defined(TARGET_S390X) #ifdef TARGET_S390X case TARGET_NR_select: #else case TARGET_NR__newselect: #endif ret = do_select(arg1, arg2, arg3, arg4, arg5); break; #endif #if defined(TARGET_NR_poll) || defined(TARGET_NR_ppoll) # ifdef TARGET_NR_poll case TARGET_NR_poll: # endif # ifdef TARGET_NR_ppoll case TARGET_NR_ppoll: # endif { struct target_pollfd *target_pfd; unsigned int nfds = arg2; int timeout = arg3; struct pollfd *pfd; unsigned int i; target_pfd = lock_user(VERIFY_WRITE, arg1, sizeof(struct target_pollfd) * nfds, 1); if (!target_pfd) goto efault; pfd = alloca(sizeof(struct pollfd) * nfds); for(i = 0; i < nfds; i++) { pfd[i].fd = tswap32(target_pfd[i].fd); pfd[i].events = tswap16(target_pfd[i].events); } # ifdef TARGET_NR_ppoll if (num == TARGET_NR_ppoll) { struct timespec _timeout_ts, *timeout_ts = &_timeout_ts; target_sigset_t *target_set; sigset_t _set, *set = &_set; if (arg3) { if (target_to_host_timespec(timeout_ts, arg3)) { unlock_user(target_pfd, arg1, 0); goto efault; } } else { timeout_ts = NULL; } if (arg4) { target_set = lock_user(VERIFY_READ, arg4, sizeof(target_sigset_t), 1); if (!target_set) { unlock_user(target_pfd, arg1, 0); goto efault; } target_to_host_sigset(set, target_set); } else { set = NULL; } ret = get_errno(sys_ppoll(pfd, nfds, timeout_ts, set, _NSIG/8)); if (!is_error(ret) && arg3) { host_to_target_timespec(arg3, timeout_ts); } if (arg4) { unlock_user(target_set, arg4, 0); } } else # endif ret = get_errno(poll(pfd, nfds, timeout)); if (!is_error(ret)) { for(i = 0; i < nfds; i++) { target_pfd[i].revents = tswap16(pfd[i].revents); } } unlock_user(target_pfd, arg1, sizeof(struct target_pollfd) * nfds); } break; #endif case TARGET_NR_flock: /* NOTE: the flock constant seems to be the same for every Linux platform */ ret = get_errno(flock(arg1, arg2)); break; case TARGET_NR_readv: { int count = arg3; struct iovec *vec; vec = alloca(count * sizeof(struct iovec)); if (lock_iovec(VERIFY_WRITE, vec, arg2, count, 0) < 0) goto efault; ret = get_errno(readv(arg1, vec, count)); unlock_iovec(vec, arg2, count, 1); } break; case TARGET_NR_writev: { int count = arg3; struct iovec *vec; vec = alloca(count * sizeof(struct iovec)); if (lock_iovec(VERIFY_READ, vec, arg2, count, 1) < 0) goto efault; ret = get_errno(writev(arg1, vec, count)); unlock_iovec(vec, arg2, count, 0); } break; case TARGET_NR_getsid: ret = get_errno(getsid(arg1)); break; #if defined(TARGET_NR_fdatasync) /* Not on alpha (osf_datasync ?) */ case TARGET_NR_fdatasync: ret = get_errno(fdatasync(arg1)); break; #endif case TARGET_NR__sysctl: /* We don't implement this, but ENOTDIR is always a safe return value. */ ret = -TARGET_ENOTDIR; break; case TARGET_NR_sched_getaffinity: { unsigned int mask_size; unsigned long *mask; /* * sched_getaffinity needs multiples of ulong, so need to take * care of mismatches between target ulong and host ulong sizes. */ if (arg2 & (sizeof(abi_ulong) - 1)) { ret = -TARGET_EINVAL; break; } mask_size = (arg2 + (sizeof(*mask) - 1)) & ~(sizeof(*mask) - 1); mask = alloca(mask_size); ret = get_errno(sys_sched_getaffinity(arg1, mask_size, mask)); if (!is_error(ret)) { if (copy_to_user(arg3, mask, ret)) { goto efault; } } } break; case TARGET_NR_sched_setaffinity: { unsigned int mask_size; unsigned long *mask; /* * sched_setaffinity needs multiples of ulong, so need to take * care of mismatches between target ulong and host ulong sizes. */ if (arg2 & (sizeof(abi_ulong) - 1)) { ret = -TARGET_EINVAL; break; } mask_size = (arg2 + (sizeof(*mask) - 1)) & ~(sizeof(*mask) - 1); mask = alloca(mask_size); if (!lock_user_struct(VERIFY_READ, p, arg3, 1)) { goto efault; } memcpy(mask, p, arg2); unlock_user_struct(p, arg2, 0); ret = get_errno(sys_sched_setaffinity(arg1, mask_size, mask)); } break; case TARGET_NR_sched_setparam: { struct sched_param *target_schp; struct sched_param schp; if (!lock_user_struct(VERIFY_READ, target_schp, arg2, 1)) goto efault; schp.sched_priority = tswap32(target_schp->sched_priority); unlock_user_struct(target_schp, arg2, 0); ret = get_errno(sched_setparam(arg1, &schp)); } break; case TARGET_NR_sched_getparam: { struct sched_param *target_schp; struct sched_param schp; ret = get_errno(sched_getparam(arg1, &schp)); if (!is_error(ret)) { if (!lock_user_struct(VERIFY_WRITE, target_schp, arg2, 0)) goto efault; target_schp->sched_priority = tswap32(schp.sched_priority); unlock_user_struct(target_schp, arg2, 1); } } break; case TARGET_NR_sched_setscheduler: { struct sched_param *target_schp; struct sched_param schp; if (!lock_user_struct(VERIFY_READ, target_schp, arg3, 1)) goto efault; schp.sched_priority = tswap32(target_schp->sched_priority); unlock_user_struct(target_schp, arg3, 0); ret = get_errno(sched_setscheduler(arg1, arg2, &schp)); } break; case TARGET_NR_sched_getscheduler: ret = get_errno(sched_getscheduler(arg1)); break; case TARGET_NR_sched_yield: ret = get_errno(sched_yield()); break; case TARGET_NR_sched_get_priority_max: ret = get_errno(sched_get_priority_max(arg1)); break; case TARGET_NR_sched_get_priority_min: ret = get_errno(sched_get_priority_min(arg1)); break; case TARGET_NR_sched_rr_get_interval: { struct timespec ts; ret = get_errno(sched_rr_get_interval(arg1, &ts)); if (!is_error(ret)) { host_to_target_timespec(arg2, &ts); } } break; case TARGET_NR_nanosleep: { struct timespec req, rem; target_to_host_timespec(&req, arg1); ret = get_errno(nanosleep(&req, &rem)); if (is_error(ret) && arg2) { host_to_target_timespec(arg2, &rem); } } break; #ifdef TARGET_NR_query_module case TARGET_NR_query_module: goto unimplemented; #endif #ifdef TARGET_NR_nfsservctl case TARGET_NR_nfsservctl: goto unimplemented; #endif case TARGET_NR_prctl: switch (arg1) { case PR_GET_PDEATHSIG: { int deathsig; ret = get_errno(prctl(arg1, &deathsig, arg3, arg4, arg5)); if (!is_error(ret) && arg2 && put_user_ual(deathsig, arg2)) { goto efault; } break; } #ifdef PR_GET_NAME case PR_GET_NAME: { void *name = lock_user(VERIFY_WRITE, arg2, 16, 1); if (!name) { goto efault; } ret = get_errno(prctl(arg1, (unsigned long)name, arg3, arg4, arg5)); unlock_user(name, arg2, 16); break; } case PR_SET_NAME: { void *name = lock_user(VERIFY_READ, arg2, 16, 1); if (!name) { goto efault; } ret = get_errno(prctl(arg1, (unsigned long)name, arg3, arg4, arg5)); unlock_user(name, arg2, 0); break; } #endif default: /* Most prctl options have no pointer arguments */ ret = get_errno(prctl(arg1, arg2, arg3, arg4, arg5)); break; } break; #ifdef TARGET_NR_arch_prctl case TARGET_NR_arch_prctl: #if defined(TARGET_I386) && !defined(TARGET_ABI32) ret = do_arch_prctl(cpu_env, arg1, arg2); break; #else goto unimplemented; #endif #endif #ifdef TARGET_NR_pread case TARGET_NR_pread: if (regpairs_aligned(cpu_env)) arg4 = arg5; if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0))) goto efault; ret = get_errno(pread(arg1, p, arg3, arg4)); unlock_user(p, arg2, ret); break; case TARGET_NR_pwrite: if (regpairs_aligned(cpu_env)) arg4 = arg5; if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1))) goto efault; ret = get_errno(pwrite(arg1, p, arg3, arg4)); unlock_user(p, arg2, 0); break; #endif #ifdef TARGET_NR_pread64 case TARGET_NR_pread64: if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0))) goto efault; ret = get_errno(pread64(arg1, p, arg3, target_offset64(arg4, arg5))); unlock_user(p, arg2, ret); break; case TARGET_NR_pwrite64: if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1))) goto efault; ret = get_errno(pwrite64(arg1, p, arg3, target_offset64(arg4, arg5))); unlock_user(p, arg2, 0); break; #endif case TARGET_NR_getcwd: if (!(p = lock_user(VERIFY_WRITE, arg1, arg2, 0))) goto efault; ret = get_errno(sys_getcwd1(p, arg2)); unlock_user(p, arg1, ret); break; case TARGET_NR_capget: goto unimplemented; case TARGET_NR_capset: goto unimplemented; case TARGET_NR_sigaltstack: #if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_MIPS) || \ defined(TARGET_SPARC) || defined(TARGET_PPC) || defined(TARGET_ALPHA) || \ defined(TARGET_M68K) || defined(TARGET_S390X) || defined(TARGET_OPENRISC) ret = do_sigaltstack(arg1, arg2, get_sp_from_cpustate((CPUArchState *)cpu_env)); break; #else goto unimplemented; #endif case TARGET_NR_sendfile: goto unimplemented; #ifdef TARGET_NR_getpmsg case TARGET_NR_getpmsg: goto unimplemented; #endif #ifdef TARGET_NR_putpmsg case TARGET_NR_putpmsg: goto unimplemented; #endif #ifdef TARGET_NR_vfork case TARGET_NR_vfork: ret = get_errno(do_fork(cpu_env, CLONE_VFORK | CLONE_VM | SIGCHLD, 0, 0, 0, 0)); break; #endif #ifdef TARGET_NR_ugetrlimit case TARGET_NR_ugetrlimit: { struct rlimit rlim; int resource = target_to_host_resource(arg1); ret = get_errno(getrlimit(resource, &rlim)); if (!is_error(ret)) { struct target_rlimit *target_rlim; if (!lock_user_struct(VERIFY_WRITE, target_rlim, arg2, 0)) goto efault; target_rlim->rlim_cur = host_to_target_rlim(rlim.rlim_cur); target_rlim->rlim_max = host_to_target_rlim(rlim.rlim_max); unlock_user_struct(target_rlim, arg2, 1); } break; } #endif #ifdef TARGET_NR_truncate64 case TARGET_NR_truncate64: if (!(p = lock_user_string(arg1))) goto efault; ret = target_truncate64(cpu_env, p, arg2, arg3, arg4); unlock_user(p, arg1, 0); break; #endif #ifdef TARGET_NR_ftruncate64 case TARGET_NR_ftruncate64: ret = target_ftruncate64(cpu_env, arg1, arg2, arg3, arg4); break; #endif #ifdef TARGET_NR_stat64 case TARGET_NR_stat64: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(stat(path(p), &st)); unlock_user(p, arg1, 0); if (!is_error(ret)) ret = host_to_target_stat64(cpu_env, arg2, &st); break; #endif #ifdef TARGET_NR_lstat64 case TARGET_NR_lstat64: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(lstat(path(p), &st)); unlock_user(p, arg1, 0); if (!is_error(ret)) ret = host_to_target_stat64(cpu_env, arg2, &st); break; #endif #ifdef TARGET_NR_fstat64 case TARGET_NR_fstat64: ret = get_errno(fstat(arg1, &st)); if (!is_error(ret)) ret = host_to_target_stat64(cpu_env, arg2, &st); break; #endif #if (defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)) && \ (defined(__NR_fstatat64) || defined(__NR_newfstatat)) #ifdef TARGET_NR_fstatat64 case TARGET_NR_fstatat64: #endif #ifdef TARGET_NR_newfstatat case TARGET_NR_newfstatat: #endif if (!(p = lock_user_string(arg2))) goto efault; #ifdef __NR_fstatat64 ret = get_errno(sys_fstatat64(arg1, path(p), &st, arg4)); #else ret = get_errno(sys_newfstatat(arg1, path(p), &st, arg4)); #endif if (!is_error(ret)) ret = host_to_target_stat64(cpu_env, arg3, &st); break; #endif case TARGET_NR_lchown: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(lchown(p, low2highuid(arg2), low2highgid(arg3))); unlock_user(p, arg1, 0); break; #ifdef TARGET_NR_getuid case TARGET_NR_getuid: ret = get_errno(high2lowuid(getuid())); break; #endif #ifdef TARGET_NR_getgid case TARGET_NR_getgid: ret = get_errno(high2lowgid(getgid())); break; #endif #ifdef TARGET_NR_geteuid case TARGET_NR_geteuid: ret = get_errno(high2lowuid(geteuid())); break; #endif #ifdef TARGET_NR_getegid case TARGET_NR_getegid: ret = get_errno(high2lowgid(getegid())); break; #endif case TARGET_NR_setreuid: ret = get_errno(setreuid(low2highuid(arg1), low2highuid(arg2))); break; case TARGET_NR_setregid: ret = get_errno(setregid(low2highgid(arg1), low2highgid(arg2))); break; case TARGET_NR_getgroups: { int gidsetsize = arg1; target_id *target_grouplist; gid_t *grouplist; int i; grouplist = alloca(gidsetsize * sizeof(gid_t)); ret = get_errno(getgroups(gidsetsize, grouplist)); if (gidsetsize == 0) break; if (!is_error(ret)) { target_grouplist = lock_user(VERIFY_WRITE, arg2, gidsetsize * 2, 0); if (!target_grouplist) goto efault; for(i = 0;i < ret; i++) target_grouplist[i] = tswapid(high2lowgid(grouplist[i])); unlock_user(target_grouplist, arg2, gidsetsize * 2); } } break; case TARGET_NR_setgroups: { int gidsetsize = arg1; target_id *target_grouplist; gid_t *grouplist; int i; grouplist = alloca(gidsetsize * sizeof(gid_t)); target_grouplist = lock_user(VERIFY_READ, arg2, gidsetsize * 2, 1); if (!target_grouplist) { ret = -TARGET_EFAULT; goto fail; } for(i = 0;i < gidsetsize; i++) grouplist[i] = low2highgid(tswapid(target_grouplist[i])); unlock_user(target_grouplist, arg2, 0); ret = get_errno(setgroups(gidsetsize, grouplist)); } break; case TARGET_NR_fchown: ret = get_errno(fchown(arg1, low2highuid(arg2), low2highgid(arg3))); break; #if defined(TARGET_NR_fchownat) && defined(__NR_fchownat) case TARGET_NR_fchownat: if (!(p = lock_user_string(arg2))) goto efault; ret = get_errno(sys_fchownat(arg1, p, low2highuid(arg3), low2highgid(arg4), arg5)); unlock_user(p, arg2, 0); break; #endif #ifdef TARGET_NR_setresuid case TARGET_NR_setresuid: ret = get_errno(setresuid(low2highuid(arg1), low2highuid(arg2), low2highuid(arg3))); break; #endif #ifdef TARGET_NR_getresuid case TARGET_NR_getresuid: { uid_t ruid, euid, suid; ret = get_errno(getresuid(&ruid, &euid, &suid)); if (!is_error(ret)) { if (put_user_u16(high2lowuid(ruid), arg1) || put_user_u16(high2lowuid(euid), arg2) || put_user_u16(high2lowuid(suid), arg3)) goto efault; } } break; #endif #ifdef TARGET_NR_getresgid case TARGET_NR_setresgid: ret = get_errno(setresgid(low2highgid(arg1), low2highgid(arg2), low2highgid(arg3))); break; #endif #ifdef TARGET_NR_getresgid case TARGET_NR_getresgid: { gid_t rgid, egid, sgid; ret = get_errno(getresgid(&rgid, &egid, &sgid)); if (!is_error(ret)) { if (put_user_u16(high2lowgid(rgid), arg1) || put_user_u16(high2lowgid(egid), arg2) || put_user_u16(high2lowgid(sgid), arg3)) goto efault; } } break; #endif case TARGET_NR_chown: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(chown(p, low2highuid(arg2), low2highgid(arg3))); unlock_user(p, arg1, 0); break; case TARGET_NR_setuid: ret = get_errno(setuid(low2highuid(arg1))); break; case TARGET_NR_setgid: ret = get_errno(setgid(low2highgid(arg1))); break; case TARGET_NR_setfsuid: ret = get_errno(setfsuid(arg1)); break; case TARGET_NR_setfsgid: ret = get_errno(setfsgid(arg1)); break; #ifdef TARGET_NR_lchown32 case TARGET_NR_lchown32: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(lchown(p, arg2, arg3)); unlock_user(p, arg1, 0); break; #endif #ifdef TARGET_NR_getuid32 case TARGET_NR_getuid32: ret = get_errno(getuid()); break; #endif #if defined(TARGET_NR_getxuid) && defined(TARGET_ALPHA) /* Alpha specific */ case TARGET_NR_getxuid: { uid_t euid; euid=geteuid(); ((CPUAlphaState *)cpu_env)->ir[IR_A4]=euid; } ret = get_errno(getuid()); break; #endif #if defined(TARGET_NR_getxgid) && defined(TARGET_ALPHA) /* Alpha specific */ case TARGET_NR_getxgid: { uid_t egid; egid=getegid(); ((CPUAlphaState *)cpu_env)->ir[IR_A4]=egid; } ret = get_errno(getgid()); break; #endif #if defined(TARGET_NR_osf_getsysinfo) && defined(TARGET_ALPHA) /* Alpha specific */ case TARGET_NR_osf_getsysinfo: ret = -TARGET_EOPNOTSUPP; switch (arg1) { case TARGET_GSI_IEEE_FP_CONTROL: { uint64_t swcr, fpcr = cpu_alpha_load_fpcr (cpu_env); /* Copied from linux ieee_fpcr_to_swcr. */ swcr = (fpcr >> 35) & SWCR_STATUS_MASK; swcr |= (fpcr >> 36) & SWCR_MAP_DMZ; swcr |= (~fpcr >> 48) & (SWCR_TRAP_ENABLE_INV | SWCR_TRAP_ENABLE_DZE | SWCR_TRAP_ENABLE_OVF); swcr |= (~fpcr >> 57) & (SWCR_TRAP_ENABLE_UNF | SWCR_TRAP_ENABLE_INE); swcr |= (fpcr >> 47) & SWCR_MAP_UMZ; swcr |= (~fpcr >> 41) & SWCR_TRAP_ENABLE_DNO; if (put_user_u64 (swcr, arg2)) goto efault; ret = 0; } break; /* case GSI_IEEE_STATE_AT_SIGNAL: -- Not implemented in linux kernel. case GSI_UACPROC: -- Retrieves current unaligned access state; not much used. case GSI_PROC_TYPE: -- Retrieves implver information; surely not used. case GSI_GET_HWRPB: -- Grabs a copy of the HWRPB; surely not used. */ } break; #endif #if defined(TARGET_NR_osf_setsysinfo) && defined(TARGET_ALPHA) /* Alpha specific */ case TARGET_NR_osf_setsysinfo: ret = -TARGET_EOPNOTSUPP; switch (arg1) { case TARGET_SSI_IEEE_FP_CONTROL: { uint64_t swcr, fpcr, orig_fpcr; if (get_user_u64 (swcr, arg2)) { goto efault; } orig_fpcr = cpu_alpha_load_fpcr(cpu_env); fpcr = orig_fpcr & FPCR_DYN_MASK; /* Copied from linux ieee_swcr_to_fpcr. */ fpcr |= (swcr & SWCR_STATUS_MASK) << 35; fpcr |= (swcr & SWCR_MAP_DMZ) << 36; fpcr |= (~swcr & (SWCR_TRAP_ENABLE_INV | SWCR_TRAP_ENABLE_DZE | SWCR_TRAP_ENABLE_OVF)) << 48; fpcr |= (~swcr & (SWCR_TRAP_ENABLE_UNF | SWCR_TRAP_ENABLE_INE)) << 57; fpcr |= (swcr & SWCR_MAP_UMZ ? FPCR_UNDZ | FPCR_UNFD : 0); fpcr |= (~swcr & SWCR_TRAP_ENABLE_DNO) << 41; cpu_alpha_store_fpcr(cpu_env, fpcr); ret = 0; } break; case TARGET_SSI_IEEE_RAISE_EXCEPTION: { uint64_t exc, fpcr, orig_fpcr; int si_code; if (get_user_u64(exc, arg2)) { goto efault; } orig_fpcr = cpu_alpha_load_fpcr(cpu_env); /* We only add to the exception status here. */ fpcr = orig_fpcr | ((exc & SWCR_STATUS_MASK) << 35); cpu_alpha_store_fpcr(cpu_env, fpcr); ret = 0; /* Old exceptions are not signaled. */ fpcr &= ~(orig_fpcr & FPCR_STATUS_MASK); /* If any exceptions set by this call, and are unmasked, send a signal. */ si_code = 0; if ((fpcr & (FPCR_INE | FPCR_INED)) == FPCR_INE) { si_code = TARGET_FPE_FLTRES; } if ((fpcr & (FPCR_UNF | FPCR_UNFD)) == FPCR_UNF) { si_code = TARGET_FPE_FLTUND; } if ((fpcr & (FPCR_OVF | FPCR_OVFD)) == FPCR_OVF) { si_code = TARGET_FPE_FLTOVF; } if ((fpcr & (FPCR_DZE | FPCR_DZED)) == FPCR_DZE) { si_code = TARGET_FPE_FLTDIV; } if ((fpcr & (FPCR_INV | FPCR_INVD)) == FPCR_INV) { si_code = TARGET_FPE_FLTINV; } if (si_code != 0) { target_siginfo_t info; info.si_signo = SIGFPE; info.si_errno = 0; info.si_code = si_code; info._sifields._sigfault._addr = ((CPUArchState *)cpu_env)->pc; queue_signal((CPUArchState *)cpu_env, info.si_signo, &info); } } break; /* case SSI_NVPAIRS: -- Used with SSIN_UACPROC to enable unaligned accesses. case SSI_IEEE_STATE_AT_SIGNAL: case SSI_IEEE_IGNORE_STATE_AT_SIGNAL: -- Not implemented in linux kernel */ } break; #endif #ifdef TARGET_NR_osf_sigprocmask /* Alpha specific. */ case TARGET_NR_osf_sigprocmask: { abi_ulong mask; int how; sigset_t set, oldset; switch(arg1) { case TARGET_SIG_BLOCK: how = SIG_BLOCK; break; case TARGET_SIG_UNBLOCK: how = SIG_UNBLOCK; break; case TARGET_SIG_SETMASK: how = SIG_SETMASK; break; default: ret = -TARGET_EINVAL; goto fail; } mask = arg2; target_to_host_old_sigset(&set, &mask); sigprocmask(how, &set, &oldset); host_to_target_old_sigset(&mask, &oldset); ret = mask; } break; #endif #ifdef TARGET_NR_getgid32 case TARGET_NR_getgid32: ret = get_errno(getgid()); break; #endif #ifdef TARGET_NR_geteuid32 case TARGET_NR_geteuid32: ret = get_errno(geteuid()); break; #endif #ifdef TARGET_NR_getegid32 case TARGET_NR_getegid32: ret = get_errno(getegid()); break; #endif #ifdef TARGET_NR_setreuid32 case TARGET_NR_setreuid32: ret = get_errno(setreuid(arg1, arg2)); break; #endif #ifdef TARGET_NR_setregid32 case TARGET_NR_setregid32: ret = get_errno(setregid(arg1, arg2)); break; #endif #ifdef TARGET_NR_getgroups32 case TARGET_NR_getgroups32: { int gidsetsize = arg1; uint32_t *target_grouplist; gid_t *grouplist; int i; grouplist = alloca(gidsetsize * sizeof(gid_t)); ret = get_errno(getgroups(gidsetsize, grouplist)); if (gidsetsize == 0) break; if (!is_error(ret)) { target_grouplist = lock_user(VERIFY_WRITE, arg2, gidsetsize * 4, 0); if (!target_grouplist) { ret = -TARGET_EFAULT; goto fail; } for(i = 0;i < ret; i++) target_grouplist[i] = tswap32(grouplist[i]); unlock_user(target_grouplist, arg2, gidsetsize * 4); } } break; #endif #ifdef TARGET_NR_setgroups32 case TARGET_NR_setgroups32: { int gidsetsize = arg1; uint32_t *target_grouplist; gid_t *grouplist; int i; grouplist = alloca(gidsetsize * sizeof(gid_t)); target_grouplist = lock_user(VERIFY_READ, arg2, gidsetsize * 4, 1); if (!target_grouplist) { ret = -TARGET_EFAULT; goto fail; } for(i = 0;i < gidsetsize; i++) grouplist[i] = tswap32(target_grouplist[i]); unlock_user(target_grouplist, arg2, 0); ret = get_errno(setgroups(gidsetsize, grouplist)); } break; #endif #ifdef TARGET_NR_fchown32 case TARGET_NR_fchown32: ret = get_errno(fchown(arg1, arg2, arg3)); break; #endif #ifdef TARGET_NR_setresuid32 case TARGET_NR_setresuid32: ret = get_errno(setresuid(arg1, arg2, arg3)); break; #endif #ifdef TARGET_NR_getresuid32 case TARGET_NR_getresuid32: { uid_t ruid, euid, suid; ret = get_errno(getresuid(&ruid, &euid, &suid)); if (!is_error(ret)) { if (put_user_u32(ruid, arg1) || put_user_u32(euid, arg2) || put_user_u32(suid, arg3)) goto efault; } } break; #endif #ifdef TARGET_NR_setresgid32 case TARGET_NR_setresgid32: ret = get_errno(setresgid(arg1, arg2, arg3)); break; #endif #ifdef TARGET_NR_getresgid32 case TARGET_NR_getresgid32: { gid_t rgid, egid, sgid; ret = get_errno(getresgid(&rgid, &egid, &sgid)); if (!is_error(ret)) { if (put_user_u32(rgid, arg1) || put_user_u32(egid, arg2) || put_user_u32(sgid, arg3)) goto efault; } } break; #endif #ifdef TARGET_NR_chown32 case TARGET_NR_chown32: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(chown(p, arg2, arg3)); unlock_user(p, arg1, 0); break; #endif #ifdef TARGET_NR_setuid32 case TARGET_NR_setuid32: ret = get_errno(setuid(arg1)); break; #endif #ifdef TARGET_NR_setgid32 case TARGET_NR_setgid32: ret = get_errno(setgid(arg1)); break; #endif #ifdef TARGET_NR_setfsuid32 case TARGET_NR_setfsuid32: ret = get_errno(setfsuid(arg1)); break; #endif #ifdef TARGET_NR_setfsgid32 case TARGET_NR_setfsgid32: ret = get_errno(setfsgid(arg1)); break; #endif case TARGET_NR_pivot_root: goto unimplemented; #ifdef TARGET_NR_mincore case TARGET_NR_mincore: { void *a; ret = -TARGET_EFAULT; if (!(a = lock_user(VERIFY_READ, arg1,arg2, 0))) goto efault; if (!(p = lock_user_string(arg3))) goto mincore_fail; ret = get_errno(mincore(a, arg2, p)); unlock_user(p, arg3, ret); mincore_fail: unlock_user(a, arg1, 0); } break; #endif #ifdef TARGET_NR_arm_fadvise64_64 case TARGET_NR_arm_fadvise64_64: { /* * arm_fadvise64_64 looks like fadvise64_64 but * with different argument order */ abi_long temp; temp = arg3; arg3 = arg4; arg4 = temp; } #endif #if defined(TARGET_NR_fadvise64_64) || defined(TARGET_NR_arm_fadvise64_64) || defined(TARGET_NR_fadvise64) #ifdef TARGET_NR_fadvise64_64 case TARGET_NR_fadvise64_64: #endif #ifdef TARGET_NR_fadvise64 case TARGET_NR_fadvise64: #endif #ifdef TARGET_S390X switch (arg4) { case 4: arg4 = POSIX_FADV_NOREUSE + 1; break; /* make sure it's an invalid value */ case 5: arg4 = POSIX_FADV_NOREUSE + 2; break; /* ditto */ case 6: arg4 = POSIX_FADV_DONTNEED; break; case 7: arg4 = POSIX_FADV_NOREUSE; break; default: break; } #endif ret = -posix_fadvise(arg1, arg2, arg3, arg4); break; #endif #ifdef TARGET_NR_madvise case TARGET_NR_madvise: /* A straight passthrough may not be safe because qemu sometimes turns private flie-backed mappings into anonymous mappings. This will break MADV_DONTNEED. This is a hint, so ignoring and returning success is ok. */ ret = get_errno(0); break; #endif #if TARGET_ABI_BITS == 32 case TARGET_NR_fcntl64: { int cmd; struct flock64 fl; struct target_flock64 *target_fl; #ifdef TARGET_ARM struct target_eabi_flock64 *target_efl; #endif cmd = target_to_host_fcntl_cmd(arg2); if (cmd == -TARGET_EINVAL) { ret = cmd; break; } switch(arg2) { case TARGET_F_GETLK64: #ifdef TARGET_ARM if (((CPUARMState *)cpu_env)->eabi) { if (!lock_user_struct(VERIFY_READ, target_efl, arg3, 1)) goto efault; fl.l_type = tswap16(target_efl->l_type); fl.l_whence = tswap16(target_efl->l_whence); fl.l_start = tswap64(target_efl->l_start); fl.l_len = tswap64(target_efl->l_len); fl.l_pid = tswap32(target_efl->l_pid); unlock_user_struct(target_efl, arg3, 0); } else #endif { if (!lock_user_struct(VERIFY_READ, target_fl, arg3, 1)) goto efault; fl.l_type = tswap16(target_fl->l_type); fl.l_whence = tswap16(target_fl->l_whence); fl.l_start = tswap64(target_fl->l_start); fl.l_len = tswap64(target_fl->l_len); fl.l_pid = tswap32(target_fl->l_pid); unlock_user_struct(target_fl, arg3, 0); } ret = get_errno(fcntl(arg1, cmd, &fl)); if (ret == 0) { #ifdef TARGET_ARM if (((CPUARMState *)cpu_env)->eabi) { if (!lock_user_struct(VERIFY_WRITE, target_efl, arg3, 0)) goto efault; target_efl->l_type = tswap16(fl.l_type); target_efl->l_whence = tswap16(fl.l_whence); target_efl->l_start = tswap64(fl.l_start); target_efl->l_len = tswap64(fl.l_len); target_efl->l_pid = tswap32(fl.l_pid); unlock_user_struct(target_efl, arg3, 1); } else #endif { if (!lock_user_struct(VERIFY_WRITE, target_fl, arg3, 0)) goto efault; target_fl->l_type = tswap16(fl.l_type); target_fl->l_whence = tswap16(fl.l_whence); target_fl->l_start = tswap64(fl.l_start); target_fl->l_len = tswap64(fl.l_len); target_fl->l_pid = tswap32(fl.l_pid); unlock_user_struct(target_fl, arg3, 1); } } break; case TARGET_F_SETLK64: case TARGET_F_SETLKW64: #ifdef TARGET_ARM if (((CPUARMState *)cpu_env)->eabi) { if (!lock_user_struct(VERIFY_READ, target_efl, arg3, 1)) goto efault; fl.l_type = tswap16(target_efl->l_type); fl.l_whence = tswap16(target_efl->l_whence); fl.l_start = tswap64(target_efl->l_start); fl.l_len = tswap64(target_efl->l_len); fl.l_pid = tswap32(target_efl->l_pid); unlock_user_struct(target_efl, arg3, 0); } else #endif { if (!lock_user_struct(VERIFY_READ, target_fl, arg3, 1)) goto efault; fl.l_type = tswap16(target_fl->l_type); fl.l_whence = tswap16(target_fl->l_whence); fl.l_start = tswap64(target_fl->l_start); fl.l_len = tswap64(target_fl->l_len); fl.l_pid = tswap32(target_fl->l_pid); unlock_user_struct(target_fl, arg3, 0); } ret = get_errno(fcntl(arg1, cmd, &fl)); break; default: ret = do_fcntl(arg1, arg2, arg3); break; } break; } #endif #ifdef TARGET_NR_cacheflush case TARGET_NR_cacheflush: /* self-modifying code is handled automatically, so nothing needed */ ret = 0; break; #endif #ifdef TARGET_NR_security case TARGET_NR_security: goto unimplemented; #endif #ifdef TARGET_NR_getpagesize case TARGET_NR_getpagesize: ret = TARGET_PAGE_SIZE; break; #endif case TARGET_NR_gettid: ret = get_errno(gettid()); break; #ifdef TARGET_NR_readahead case TARGET_NR_readahead: #if TARGET_ABI_BITS == 32 if (regpairs_aligned(cpu_env)) { arg2 = arg3; arg3 = arg4; arg4 = arg5; } ret = get_errno(readahead(arg1, ((off64_t)arg3 << 32) | arg2, arg4)); #else ret = get_errno(readahead(arg1, arg2, arg3)); #endif break; #endif #ifdef CONFIG_ATTR #ifdef TARGET_NR_setxattr case TARGET_NR_listxattr: case TARGET_NR_llistxattr: { void *p, *b = 0; if (arg2) { b = lock_user(VERIFY_WRITE, arg2, arg3, 0); if (!b) { ret = -TARGET_EFAULT; break; } } p = lock_user_string(arg1); if (p) { if (num == TARGET_NR_listxattr) { ret = get_errno(listxattr(p, b, arg3)); } else { ret = get_errno(llistxattr(p, b, arg3)); } } else { ret = -TARGET_EFAULT; } unlock_user(p, arg1, 0); unlock_user(b, arg2, arg3); break; } case TARGET_NR_flistxattr: { void *b = 0; if (arg2) { b = lock_user(VERIFY_WRITE, arg2, arg3, 0); if (!b) { ret = -TARGET_EFAULT; break; } } ret = get_errno(flistxattr(arg1, b, arg3)); unlock_user(b, arg2, arg3); break; } case TARGET_NR_setxattr: case TARGET_NR_lsetxattr: { void *p, *n, *v = 0; if (arg3) { v = lock_user(VERIFY_READ, arg3, arg4, 1); if (!v) { ret = -TARGET_EFAULT; break; } } p = lock_user_string(arg1); n = lock_user_string(arg2); if (p && n) { if (num == TARGET_NR_setxattr) { ret = get_errno(setxattr(p, n, v, arg4, arg5)); } else { ret = get_errno(lsetxattr(p, n, v, arg4, arg5)); } } else { ret = -TARGET_EFAULT; } unlock_user(p, arg1, 0); unlock_user(n, arg2, 0); unlock_user(v, arg3, 0); } break; case TARGET_NR_fsetxattr: { void *n, *v = 0; if (arg3) { v = lock_user(VERIFY_READ, arg3, arg4, 1); if (!v) { ret = -TARGET_EFAULT; break; } } n = lock_user_string(arg2); if (n) { ret = get_errno(fsetxattr(arg1, n, v, arg4, arg5)); } else { ret = -TARGET_EFAULT; } unlock_user(n, arg2, 0); unlock_user(v, arg3, 0); } break; case TARGET_NR_getxattr: case TARGET_NR_lgetxattr: { void *p, *n, *v = 0; if (arg3) { v = lock_user(VERIFY_WRITE, arg3, arg4, 0); if (!v) { ret = -TARGET_EFAULT; break; } } p = lock_user_string(arg1); n = lock_user_string(arg2); if (p && n) { if (num == TARGET_NR_getxattr) { ret = get_errno(getxattr(p, n, v, arg4)); } else { ret = get_errno(lgetxattr(p, n, v, arg4)); } } else { ret = -TARGET_EFAULT; } unlock_user(p, arg1, 0); unlock_user(n, arg2, 0); unlock_user(v, arg3, arg4); } break; case TARGET_NR_fgetxattr: { void *n, *v = 0; if (arg3) { v = lock_user(VERIFY_WRITE, arg3, arg4, 0); if (!v) { ret = -TARGET_EFAULT; break; } } n = lock_user_string(arg2); if (n) { ret = get_errno(fgetxattr(arg1, n, v, arg4)); } else { ret = -TARGET_EFAULT; } unlock_user(n, arg2, 0); unlock_user(v, arg3, arg4); } break; case TARGET_NR_removexattr: case TARGET_NR_lremovexattr: { void *p, *n; p = lock_user_string(arg1); n = lock_user_string(arg2); if (p && n) { if (num == TARGET_NR_removexattr) { ret = get_errno(removexattr(p, n)); } else { ret = get_errno(lremovexattr(p, n)); } } else { ret = -TARGET_EFAULT; } unlock_user(p, arg1, 0); unlock_user(n, arg2, 0); } break; case TARGET_NR_fremovexattr: { void *n; n = lock_user_string(arg2); if (n) { ret = get_errno(fremovexattr(arg1, n)); } else { ret = -TARGET_EFAULT; } unlock_user(n, arg2, 0); } break; #endif #endif /* CONFIG_ATTR */ #ifdef TARGET_NR_set_thread_area case TARGET_NR_set_thread_area: #if defined(TARGET_MIPS) ((CPUMIPSState *) cpu_env)->tls_value = arg1; ret = 0; break; #elif defined(TARGET_CRIS) if (arg1 & 0xff) ret = -TARGET_EINVAL; else { ((CPUCRISState *) cpu_env)->pregs[PR_PID] = arg1; ret = 0; } break; #elif defined(TARGET_I386) && defined(TARGET_ABI32) ret = do_set_thread_area(cpu_env, arg1); break; #else goto unimplemented_nowarn; #endif #endif #ifdef TARGET_NR_get_thread_area case TARGET_NR_get_thread_area: #if defined(TARGET_I386) && defined(TARGET_ABI32) ret = do_get_thread_area(cpu_env, arg1); #else goto unimplemented_nowarn; #endif #endif #ifdef TARGET_NR_getdomainname case TARGET_NR_getdomainname: goto unimplemented_nowarn; #endif #ifdef TARGET_NR_clock_gettime case TARGET_NR_clock_gettime: { struct timespec ts; ret = get_errno(clock_gettime(arg1, &ts)); if (!is_error(ret)) { host_to_target_timespec(arg2, &ts); } break; } #endif #ifdef TARGET_NR_clock_getres case TARGET_NR_clock_getres: { struct timespec ts; ret = get_errno(clock_getres(arg1, &ts)); if (!is_error(ret)) { host_to_target_timespec(arg2, &ts); } break; } #endif #ifdef TARGET_NR_clock_nanosleep case TARGET_NR_clock_nanosleep: { struct timespec ts; target_to_host_timespec(&ts, arg3); ret = get_errno(clock_nanosleep(arg1, arg2, &ts, arg4 ? &ts : NULL)); if (arg4) host_to_target_timespec(arg4, &ts); break; } #endif #if defined(TARGET_NR_set_tid_address) && defined(__NR_set_tid_address) case TARGET_NR_set_tid_address: ret = get_errno(set_tid_address((int *)g2h(arg1))); break; #endif #if defined(TARGET_NR_tkill) && defined(__NR_tkill) case TARGET_NR_tkill: ret = get_errno(sys_tkill((int)arg1, target_to_host_signal(arg2))); break; #endif #if defined(TARGET_NR_tgkill) && defined(__NR_tgkill) case TARGET_NR_tgkill: ret = get_errno(sys_tgkill((int)arg1, (int)arg2, target_to_host_signal(arg3))); break; #endif #ifdef TARGET_NR_set_robust_list case TARGET_NR_set_robust_list: goto unimplemented_nowarn; #endif #if defined(TARGET_NR_utimensat) && defined(__NR_utimensat) case TARGET_NR_utimensat: { struct timespec *tsp, ts[2]; if (!arg3) { tsp = NULL; } else { target_to_host_timespec(ts, arg3); target_to_host_timespec(ts+1, arg3+sizeof(struct target_timespec)); tsp = ts; } if (!arg2) ret = get_errno(sys_utimensat(arg1, NULL, tsp, arg4)); else { if (!(p = lock_user_string(arg2))) { ret = -TARGET_EFAULT; goto fail; } ret = get_errno(sys_utimensat(arg1, path(p), tsp, arg4)); unlock_user(p, arg2, 0); } } break; #endif #if defined(CONFIG_USE_NPTL) case TARGET_NR_futex: ret = do_futex(arg1, arg2, arg3, arg4, arg5, arg6); break; #endif #if defined(TARGET_NR_inotify_init) && defined(__NR_inotify_init) case TARGET_NR_inotify_init: ret = get_errno(sys_inotify_init()); break; #endif #ifdef CONFIG_INOTIFY1 #if defined(TARGET_NR_inotify_init1) && defined(__NR_inotify_init1) case TARGET_NR_inotify_init1: ret = get_errno(sys_inotify_init1(arg1)); break; #endif #endif #if defined(TARGET_NR_inotify_add_watch) && defined(__NR_inotify_add_watch) case TARGET_NR_inotify_add_watch: p = lock_user_string(arg2); ret = get_errno(sys_inotify_add_watch(arg1, path(p), arg3)); unlock_user(p, arg2, 0); break; #endif #if defined(TARGET_NR_inotify_rm_watch) && defined(__NR_inotify_rm_watch) case TARGET_NR_inotify_rm_watch: ret = get_errno(sys_inotify_rm_watch(arg1, arg2)); break; #endif #if defined(TARGET_NR_mq_open) && defined(__NR_mq_open) case TARGET_NR_mq_open: { struct mq_attr posix_mq_attr; p = lock_user_string(arg1 - 1); if (arg4 != 0) copy_from_user_mq_attr (&posix_mq_attr, arg4); ret = get_errno(mq_open(p, arg2, arg3, &posix_mq_attr)); unlock_user (p, arg1, 0); } break; case TARGET_NR_mq_unlink: p = lock_user_string(arg1 - 1); ret = get_errno(mq_unlink(p)); unlock_user (p, arg1, 0); break; case TARGET_NR_mq_timedsend: { struct timespec ts; p = lock_user (VERIFY_READ, arg2, arg3, 1); if (arg5 != 0) { target_to_host_timespec(&ts, arg5); ret = get_errno(mq_timedsend(arg1, p, arg3, arg4, &ts)); host_to_target_timespec(arg5, &ts); } else ret = get_errno(mq_send(arg1, p, arg3, arg4)); unlock_user (p, arg2, arg3); } break; case TARGET_NR_mq_timedreceive: { struct timespec ts; unsigned int prio; p = lock_user (VERIFY_READ, arg2, arg3, 1); if (arg5 != 0) { target_to_host_timespec(&ts, arg5); ret = get_errno(mq_timedreceive(arg1, p, arg3, &prio, &ts)); host_to_target_timespec(arg5, &ts); } else ret = get_errno(mq_receive(arg1, p, arg3, &prio)); unlock_user (p, arg2, arg3); if (arg4 != 0) put_user_u32(prio, arg4); } break; /* Not implemented for now... */ /* case TARGET_NR_mq_notify: */ /* break; */ case TARGET_NR_mq_getsetattr: { struct mq_attr posix_mq_attr_in, posix_mq_attr_out; ret = 0; if (arg3 != 0) { ret = mq_getattr(arg1, &posix_mq_attr_out); copy_to_user_mq_attr(arg3, &posix_mq_attr_out); } if (arg2 != 0) { copy_from_user_mq_attr(&posix_mq_attr_in, arg2); ret |= mq_setattr(arg1, &posix_mq_attr_in, &posix_mq_attr_out); } } break; #endif #ifdef CONFIG_SPLICE #ifdef TARGET_NR_tee case TARGET_NR_tee: { ret = get_errno(tee(arg1,arg2,arg3,arg4)); } break; #endif #ifdef TARGET_NR_splice case TARGET_NR_splice: { loff_t loff_in, loff_out; loff_t *ploff_in = NULL, *ploff_out = NULL; if(arg2) { get_user_u64(loff_in, arg2); ploff_in = &loff_in; } if(arg4) { get_user_u64(loff_out, arg2); ploff_out = &loff_out; } ret = get_errno(splice(arg1, ploff_in, arg3, ploff_out, arg5, arg6)); } break; #endif #ifdef TARGET_NR_vmsplice case TARGET_NR_vmsplice: { int count = arg3; struct iovec *vec; vec = alloca(count * sizeof(struct iovec)); if (lock_iovec(VERIFY_READ, vec, arg2, count, 1) < 0) goto efault; ret = get_errno(vmsplice(arg1, vec, count, arg4)); unlock_iovec(vec, arg2, count, 0); } break; #endif #endif /* CONFIG_SPLICE */ #ifdef CONFIG_EVENTFD #if defined(TARGET_NR_eventfd) case TARGET_NR_eventfd: ret = get_errno(eventfd(arg1, 0)); break; #endif #if defined(TARGET_NR_eventfd2) case TARGET_NR_eventfd2: ret = get_errno(eventfd(arg1, arg2)); break; #endif #endif /* CONFIG_EVENTFD */ #if defined(CONFIG_FALLOCATE) && defined(TARGET_NR_fallocate) case TARGET_NR_fallocate: #if TARGET_ABI_BITS == 32 ret = get_errno(fallocate(arg1, arg2, target_offset64(arg3, arg4), target_offset64(arg5, arg6))); #else ret = get_errno(fallocate(arg1, arg2, arg3, arg4)); #endif break; #endif #if defined(CONFIG_SYNC_FILE_RANGE) #if defined(TARGET_NR_sync_file_range) case TARGET_NR_sync_file_range: #if TARGET_ABI_BITS == 32 #if defined(TARGET_MIPS) ret = get_errno(sync_file_range(arg1, target_offset64(arg3, arg4), target_offset64(arg5, arg6), arg7)); #else ret = get_errno(sync_file_range(arg1, target_offset64(arg2, arg3), target_offset64(arg4, arg5), arg6)); #endif /* !TARGET_MIPS */ #else ret = get_errno(sync_file_range(arg1, arg2, arg3, arg4)); #endif break; #endif #if defined(TARGET_NR_sync_file_range2) case TARGET_NR_sync_file_range2: /* This is like sync_file_range but the arguments are reordered */ #if TARGET_ABI_BITS == 32 ret = get_errno(sync_file_range(arg1, target_offset64(arg3, arg4), target_offset64(arg5, arg6), arg2)); #else ret = get_errno(sync_file_range(arg1, arg3, arg4, arg2)); #endif break; #endif #endif #if defined(CONFIG_EPOLL) #if defined(TARGET_NR_epoll_create) case TARGET_NR_epoll_create: ret = get_errno(epoll_create(arg1)); break; #endif #if defined(TARGET_NR_epoll_create1) && defined(CONFIG_EPOLL_CREATE1) case TARGET_NR_epoll_create1: ret = get_errno(epoll_create1(arg1)); break; #endif #if defined(TARGET_NR_epoll_ctl) case TARGET_NR_epoll_ctl: { struct epoll_event ep; struct epoll_event *epp = 0; if (arg4) { struct target_epoll_event *target_ep; if (!lock_user_struct(VERIFY_READ, target_ep, arg4, 1)) { goto efault; } ep.events = tswap32(target_ep->events); /* The epoll_data_t union is just opaque data to the kernel, * so we transfer all 64 bits across and need not worry what * actual data type it is. */ ep.data.u64 = tswap64(target_ep->data.u64); unlock_user_struct(target_ep, arg4, 0); epp = &ep; } ret = get_errno(epoll_ctl(arg1, arg2, arg3, epp)); break; } #endif #if defined(TARGET_NR_epoll_pwait) && defined(CONFIG_EPOLL_PWAIT) #define IMPLEMENT_EPOLL_PWAIT #endif #if defined(TARGET_NR_epoll_wait) || defined(IMPLEMENT_EPOLL_PWAIT) #if defined(TARGET_NR_epoll_wait) case TARGET_NR_epoll_wait: #endif #if defined(IMPLEMENT_EPOLL_PWAIT) case TARGET_NR_epoll_pwait: #endif { struct target_epoll_event *target_ep; struct epoll_event *ep; int epfd = arg1; int maxevents = arg3; int timeout = arg4; target_ep = lock_user(VERIFY_WRITE, arg2, maxevents * sizeof(struct target_epoll_event), 1); if (!target_ep) { goto efault; } ep = alloca(maxevents * sizeof(struct epoll_event)); switch (num) { #if defined(IMPLEMENT_EPOLL_PWAIT) case TARGET_NR_epoll_pwait: { target_sigset_t *target_set; sigset_t _set, *set = &_set; if (arg5) { target_set = lock_user(VERIFY_READ, arg5, sizeof(target_sigset_t), 1); if (!target_set) { unlock_user(target_ep, arg2, 0); goto efault; } target_to_host_sigset(set, target_set); unlock_user(target_set, arg5, 0); } else { set = NULL; } ret = get_errno(epoll_pwait(epfd, ep, maxevents, timeout, set)); break; } #endif #if defined(TARGET_NR_epoll_wait) case TARGET_NR_epoll_wait: ret = get_errno(epoll_wait(epfd, ep, maxevents, timeout)); break; #endif default: ret = -TARGET_ENOSYS; } if (!is_error(ret)) { int i; for (i = 0; i < ret; i++) { target_ep[i].events = tswap32(ep[i].events); target_ep[i].data.u64 = tswap64(ep[i].data.u64); } } unlock_user(target_ep, arg2, ret * sizeof(struct target_epoll_event)); break; } #endif #endif #ifdef TARGET_NR_prlimit64 case TARGET_NR_prlimit64: { /* args: pid, resource number, ptr to new rlimit, ptr to old rlimit */ struct target_rlimit64 *target_rnew, *target_rold; struct host_rlimit64 rnew, rold, *rnewp = 0; if (arg3) { if (!lock_user_struct(VERIFY_READ, target_rnew, arg3, 1)) { goto efault; } rnew.rlim_cur = tswap64(target_rnew->rlim_cur); rnew.rlim_max = tswap64(target_rnew->rlim_max); unlock_user_struct(target_rnew, arg3, 0); rnewp = &rnew; } ret = get_errno(sys_prlimit64(arg1, arg2, rnewp, arg4 ? &rold : 0)); if (!is_error(ret) && arg4) { if (!lock_user_struct(VERIFY_WRITE, target_rold, arg4, 1)) { goto efault; } target_rold->rlim_cur = tswap64(rold.rlim_cur); target_rold->rlim_max = tswap64(rold.rlim_max); unlock_user_struct(target_rold, arg4, 1); } break; } #endif default: unimplemented: gemu_log("qemu: Unsupported syscall: %d\n", num); #if defined(TARGET_NR_setxattr) || defined(TARGET_NR_get_thread_area) || defined(TARGET_NR_getdomainname) || defined(TARGET_NR_set_robust_list) unimplemented_nowarn: #endif ret = -TARGET_ENOSYS; break; } fail: #ifdef DEBUG gemu_log(" = " TARGET_ABI_FMT_ld "\n", ret); #endif if(do_strace) print_syscall_ret(num, ret); return ret; efault: ret = -TARGET_EFAULT; goto fail; }
false
qemu
f287b2c2d4d20d35880ab6dca44bda0476e67dce
abi_long do_syscall(void *cpu_env, int num, abi_long arg1, abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6, abi_long arg7, abi_long arg8) { abi_long ret; struct stat st; struct statfs stfs; void *p; #ifdef DEBUG gemu_log("syscall %d", num); #endif if(do_strace) print_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6); switch(num) { case TARGET_NR_exit: #ifdef CONFIG_USE_NPTL if (first_cpu->next_cpu) { TaskState *ts; CPUArchState **lastp; CPUArchState *p; cpu_list_lock(); lastp = &first_cpu; p = first_cpu; while (p && p != (CPUArchState *)cpu_env) { lastp = &p->next_cpu; p = p->next_cpu; } if (!p) abort(); *lastp = p->next_cpu; cpu_list_unlock(); ts = ((CPUArchState *)cpu_env)->opaque; if (ts->child_tidptr) { put_user_u32(0, ts->child_tidptr); sys_futex(g2h(ts->child_tidptr), FUTEX_WAKE, INT_MAX, NULL, NULL, 0); } thread_env = NULL; object_delete(OBJECT(ENV_GET_CPU(cpu_env))); g_free(ts); pthread_exit(NULL); } #endif #ifdef TARGET_GPROF _mcleanup(); #endif gdb_exit(cpu_env, arg1); _exit(arg1); ret = 0; break; case TARGET_NR_read: if (arg3 == 0) ret = 0; else { if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0))) goto efault; ret = get_errno(read(arg1, p, arg3)); unlock_user(p, arg2, ret); } break; case TARGET_NR_write: if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1))) goto efault; ret = get_errno(write(arg1, p, arg3)); unlock_user(p, arg2, 0); break; case TARGET_NR_open: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(do_open(cpu_env, p, target_to_host_bitmask(arg2, fcntl_flags_tbl), arg3)); unlock_user(p, arg1, 0); break; #if defined(TARGET_NR_openat) && defined(__NR_openat) case TARGET_NR_openat: if (!(p = lock_user_string(arg2))) goto efault; ret = get_errno(sys_openat(arg1, path(p), target_to_host_bitmask(arg3, fcntl_flags_tbl), arg4)); unlock_user(p, arg2, 0); break; #endif case TARGET_NR_close: ret = get_errno(close(arg1)); break; case TARGET_NR_brk: ret = do_brk(arg1); break; case TARGET_NR_fork: ret = get_errno(do_fork(cpu_env, SIGCHLD, 0, 0, 0, 0)); break; #ifdef TARGET_NR_waitpid case TARGET_NR_waitpid: { int status; ret = get_errno(waitpid(arg1, &status, arg3)); if (!is_error(ret) && arg2 && ret && put_user_s32(host_to_target_waitstatus(status), arg2)) goto efault; } break; #endif #ifdef TARGET_NR_waitid case TARGET_NR_waitid: { siginfo_t info; info.si_pid = 0; ret = get_errno(waitid(arg1, arg2, &info, arg4)); if (!is_error(ret) && arg3 && info.si_pid != 0) { if (!(p = lock_user(VERIFY_WRITE, arg3, sizeof(target_siginfo_t), 0))) goto efault; host_to_target_siginfo(p, &info); unlock_user(p, arg3, sizeof(target_siginfo_t)); } } break; #endif #ifdef TARGET_NR_creat case TARGET_NR_creat: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(creat(p, arg2)); unlock_user(p, arg1, 0); break; #endif case TARGET_NR_link: { void * p2; p = lock_user_string(arg1); p2 = lock_user_string(arg2); if (!p || !p2) ret = -TARGET_EFAULT; else ret = get_errno(link(p, p2)); unlock_user(p2, arg2, 0); unlock_user(p, arg1, 0); } break; #if defined(TARGET_NR_linkat) && defined(__NR_linkat) case TARGET_NR_linkat: { void * p2 = NULL; if (!arg2 || !arg4) goto efault; p = lock_user_string(arg2); p2 = lock_user_string(arg4); if (!p || !p2) ret = -TARGET_EFAULT; else ret = get_errno(sys_linkat(arg1, p, arg3, p2, arg5)); unlock_user(p, arg2, 0); unlock_user(p2, arg4, 0); } break; #endif case TARGET_NR_unlink: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(unlink(p)); unlock_user(p, arg1, 0); break; #if defined(TARGET_NR_unlinkat) && defined(__NR_unlinkat) case TARGET_NR_unlinkat: if (!(p = lock_user_string(arg2))) goto efault; ret = get_errno(sys_unlinkat(arg1, p, arg3)); unlock_user(p, arg2, 0); break; #endif case TARGET_NR_execve: { char **argp, **envp; int argc, envc; abi_ulong gp; abi_ulong guest_argp; abi_ulong guest_envp; abi_ulong addr; char **q; int total_size = 0; argc = 0; guest_argp = arg2; for (gp = guest_argp; gp; gp += sizeof(abi_ulong)) { if (get_user_ual(addr, gp)) goto efault; if (!addr) break; argc++; } envc = 0; guest_envp = arg3; for (gp = guest_envp; gp; gp += sizeof(abi_ulong)) { if (get_user_ual(addr, gp)) goto efault; if (!addr) break; envc++; } argp = alloca((argc + 1) * sizeof(void *)); envp = alloca((envc + 1) * sizeof(void *)); for (gp = guest_argp, q = argp; gp; gp += sizeof(abi_ulong), q++) { if (get_user_ual(addr, gp)) goto execve_efault; if (!addr) break; if (!(*q = lock_user_string(addr))) goto execve_efault; total_size += strlen(*q) + 1; } *q = NULL; for (gp = guest_envp, q = envp; gp; gp += sizeof(abi_ulong), q++) { if (get_user_ual(addr, gp)) goto execve_efault; if (!addr) break; if (!(*q = lock_user_string(addr))) goto execve_efault; total_size += strlen(*q) + 1; } *q = NULL; if (total_size > MAX_ARG_PAGES * TARGET_PAGE_SIZE) { ret = -TARGET_E2BIG; goto execve_end; } if (!(p = lock_user_string(arg1))) goto execve_efault; ret = get_errno(execve(p, argp, envp)); unlock_user(p, arg1, 0); goto execve_end; execve_efault: ret = -TARGET_EFAULT; execve_end: for (gp = guest_argp, q = argp; *q; gp += sizeof(abi_ulong), q++) { if (get_user_ual(addr, gp) || !addr) break; unlock_user(*q, addr, 0); } for (gp = guest_envp, q = envp; *q; gp += sizeof(abi_ulong), q++) { if (get_user_ual(addr, gp) || !addr) break; unlock_user(*q, addr, 0); } } break; case TARGET_NR_chdir: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(chdir(p)); unlock_user(p, arg1, 0); break; #ifdef TARGET_NR_time case TARGET_NR_time: { time_t host_time; ret = get_errno(time(&host_time)); if (!is_error(ret) && arg1 && put_user_sal(host_time, arg1)) goto efault; } break; #endif case TARGET_NR_mknod: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(mknod(p, arg2, arg3)); unlock_user(p, arg1, 0); break; #if defined(TARGET_NR_mknodat) && defined(__NR_mknodat) case TARGET_NR_mknodat: if (!(p = lock_user_string(arg2))) goto efault; ret = get_errno(sys_mknodat(arg1, p, arg3, arg4)); unlock_user(p, arg2, 0); break; #endif case TARGET_NR_chmod: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(chmod(p, arg2)); unlock_user(p, arg1, 0); break; #ifdef TARGET_NR_break case TARGET_NR_break: goto unimplemented; #endif #ifdef TARGET_NR_oldstat case TARGET_NR_oldstat: goto unimplemented; #endif case TARGET_NR_lseek: ret = get_errno(lseek(arg1, arg2, arg3)); break; #if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA) case TARGET_NR_getxpid: ((CPUAlphaState *)cpu_env)->ir[IR_A4] = getppid(); ret = get_errno(getpid()); break; #endif #ifdef TARGET_NR_getpid case TARGET_NR_getpid: ret = get_errno(getpid()); break; #endif case TARGET_NR_mount: { void *p2, *p3; p = lock_user_string(arg1); p2 = lock_user_string(arg2); p3 = lock_user_string(arg3); if (!p || !p2 || !p3) ret = -TARGET_EFAULT; else { if ( ! arg5 ) ret = get_errno(mount(p, p2, p3, (unsigned long)arg4, NULL)); else ret = get_errno(mount(p, p2, p3, (unsigned long)arg4, g2h(arg5))); } unlock_user(p, arg1, 0); unlock_user(p2, arg2, 0); unlock_user(p3, arg3, 0); break; } #ifdef TARGET_NR_umount case TARGET_NR_umount: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(umount(p)); unlock_user(p, arg1, 0); break; #endif #ifdef TARGET_NR_stime case TARGET_NR_stime: { time_t host_time; if (get_user_sal(host_time, arg1)) goto efault; ret = get_errno(stime(&host_time)); } break; #endif case TARGET_NR_ptrace: goto unimplemented; #ifdef TARGET_NR_alarm case TARGET_NR_alarm: ret = alarm(arg1); break; #endif #ifdef TARGET_NR_oldfstat case TARGET_NR_oldfstat: goto unimplemented; #endif #ifdef TARGET_NR_pause case TARGET_NR_pause: ret = get_errno(pause()); break; #endif #ifdef TARGET_NR_utime case TARGET_NR_utime: { struct utimbuf tbuf, *host_tbuf; struct target_utimbuf *target_tbuf; if (arg2) { if (!lock_user_struct(VERIFY_READ, target_tbuf, arg2, 1)) goto efault; tbuf.actime = tswapal(target_tbuf->actime); tbuf.modtime = tswapal(target_tbuf->modtime); unlock_user_struct(target_tbuf, arg2, 0); host_tbuf = &tbuf; } else { host_tbuf = NULL; } if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(utime(p, host_tbuf)); unlock_user(p, arg1, 0); } break; #endif case TARGET_NR_utimes: { struct timeval *tvp, tv[2]; if (arg2) { if (copy_from_user_timeval(&tv[0], arg2) || copy_from_user_timeval(&tv[1], arg2 + sizeof(struct target_timeval))) goto efault; tvp = tv; } else { tvp = NULL; } if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(utimes(p, tvp)); unlock_user(p, arg1, 0); } break; #if defined(TARGET_NR_futimesat) && defined(__NR_futimesat) case TARGET_NR_futimesat: { struct timeval *tvp, tv[2]; if (arg3) { if (copy_from_user_timeval(&tv[0], arg3) || copy_from_user_timeval(&tv[1], arg3 + sizeof(struct target_timeval))) goto efault; tvp = tv; } else { tvp = NULL; } if (!(p = lock_user_string(arg2))) goto efault; ret = get_errno(sys_futimesat(arg1, path(p), tvp)); unlock_user(p, arg2, 0); } break; #endif #ifdef TARGET_NR_stty case TARGET_NR_stty: goto unimplemented; #endif #ifdef TARGET_NR_gtty case TARGET_NR_gtty: goto unimplemented; #endif case TARGET_NR_access: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(access(path(p), arg2)); unlock_user(p, arg1, 0); break; #if defined(TARGET_NR_faccessat) && defined(__NR_faccessat) case TARGET_NR_faccessat: if (!(p = lock_user_string(arg2))) goto efault; ret = get_errno(sys_faccessat(arg1, p, arg3)); unlock_user(p, arg2, 0); break; #endif #ifdef TARGET_NR_nice case TARGET_NR_nice: ret = get_errno(nice(arg1)); break; #endif #ifdef TARGET_NR_ftime case TARGET_NR_ftime: goto unimplemented; #endif case TARGET_NR_sync: sync(); ret = 0; break; case TARGET_NR_kill: ret = get_errno(kill(arg1, target_to_host_signal(arg2))); break; case TARGET_NR_rename: { void *p2; p = lock_user_string(arg1); p2 = lock_user_string(arg2); if (!p || !p2) ret = -TARGET_EFAULT; else ret = get_errno(rename(p, p2)); unlock_user(p2, arg2, 0); unlock_user(p, arg1, 0); } break; #if defined(TARGET_NR_renameat) && defined(__NR_renameat) case TARGET_NR_renameat: { void *p2; p = lock_user_string(arg2); p2 = lock_user_string(arg4); if (!p || !p2) ret = -TARGET_EFAULT; else ret = get_errno(sys_renameat(arg1, p, arg3, p2)); unlock_user(p2, arg4, 0); unlock_user(p, arg2, 0); } break; #endif case TARGET_NR_mkdir: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(mkdir(p, arg2)); unlock_user(p, arg1, 0); break; #if defined(TARGET_NR_mkdirat) && defined(__NR_mkdirat) case TARGET_NR_mkdirat: if (!(p = lock_user_string(arg2))) goto efault; ret = get_errno(sys_mkdirat(arg1, p, arg3)); unlock_user(p, arg2, 0); break; #endif case TARGET_NR_rmdir: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(rmdir(p)); unlock_user(p, arg1, 0); break; case TARGET_NR_dup: ret = get_errno(dup(arg1)); break; case TARGET_NR_pipe: ret = do_pipe(cpu_env, arg1, 0, 0); break; #ifdef TARGET_NR_pipe2 case TARGET_NR_pipe2: ret = do_pipe(cpu_env, arg1, target_to_host_bitmask(arg2, fcntl_flags_tbl), 1); break; #endif case TARGET_NR_times: { struct target_tms *tmsp; struct tms tms; ret = get_errno(times(&tms)); if (arg1) { tmsp = lock_user(VERIFY_WRITE, arg1, sizeof(struct target_tms), 0); if (!tmsp) goto efault; tmsp->tms_utime = tswapal(host_to_target_clock_t(tms.tms_utime)); tmsp->tms_stime = tswapal(host_to_target_clock_t(tms.tms_stime)); tmsp->tms_cutime = tswapal(host_to_target_clock_t(tms.tms_cutime)); tmsp->tms_cstime = tswapal(host_to_target_clock_t(tms.tms_cstime)); } if (!is_error(ret)) ret = host_to_target_clock_t(ret); } break; #ifdef TARGET_NR_prof case TARGET_NR_prof: goto unimplemented; #endif #ifdef TARGET_NR_signal case TARGET_NR_signal: goto unimplemented; #endif case TARGET_NR_acct: if (arg1 == 0) { ret = get_errno(acct(NULL)); } else { if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(acct(path(p))); unlock_user(p, arg1, 0); } break; #ifdef TARGET_NR_umount2 case TARGET_NR_umount2: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(umount2(p, arg2)); unlock_user(p, arg1, 0); break; #endif #ifdef TARGET_NR_lock case TARGET_NR_lock: goto unimplemented; #endif case TARGET_NR_ioctl: ret = do_ioctl(arg1, arg2, arg3); break; case TARGET_NR_fcntl: ret = do_fcntl(arg1, arg2, arg3); break; #ifdef TARGET_NR_mpx case TARGET_NR_mpx: goto unimplemented; #endif case TARGET_NR_setpgid: ret = get_errno(setpgid(arg1, arg2)); break; #ifdef TARGET_NR_ulimit case TARGET_NR_ulimit: goto unimplemented; #endif #ifdef TARGET_NR_oldolduname case TARGET_NR_oldolduname: goto unimplemented; #endif case TARGET_NR_umask: ret = get_errno(umask(arg1)); break; case TARGET_NR_chroot: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(chroot(p)); unlock_user(p, arg1, 0); break; case TARGET_NR_ustat: goto unimplemented; case TARGET_NR_dup2: ret = get_errno(dup2(arg1, arg2)); break; #if defined(CONFIG_DUP3) && defined(TARGET_NR_dup3) case TARGET_NR_dup3: ret = get_errno(dup3(arg1, arg2, arg3)); break; #endif #ifdef TARGET_NR_getppid case TARGET_NR_getppid: ret = get_errno(getppid()); break; #endif case TARGET_NR_getpgrp: ret = get_errno(getpgrp()); break; case TARGET_NR_setsid: ret = get_errno(setsid()); break; #ifdef TARGET_NR_sigaction case TARGET_NR_sigaction: { #if defined(TARGET_ALPHA) struct target_sigaction act, oact, *pact = 0; struct target_old_sigaction *old_act; if (arg2) { if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1)) goto efault; act._sa_handler = old_act->_sa_handler; target_siginitset(&act.sa_mask, old_act->sa_mask); act.sa_flags = old_act->sa_flags; act.sa_restorer = 0; unlock_user_struct(old_act, arg2, 0); pact = &act; } ret = get_errno(do_sigaction(arg1, pact, &oact)); if (!is_error(ret) && arg3) { if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0)) goto efault; old_act->_sa_handler = oact._sa_handler; old_act->sa_mask = oact.sa_mask.sig[0]; old_act->sa_flags = oact.sa_flags; unlock_user_struct(old_act, arg3, 1); } #elif defined(TARGET_MIPS) struct target_sigaction act, oact, *pact, *old_act; if (arg2) { if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1)) goto efault; act._sa_handler = old_act->_sa_handler; target_siginitset(&act.sa_mask, old_act->sa_mask.sig[0]); act.sa_flags = old_act->sa_flags; unlock_user_struct(old_act, arg2, 0); pact = &act; } else { pact = NULL; } ret = get_errno(do_sigaction(arg1, pact, &oact)); if (!is_error(ret) && arg3) { if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0)) goto efault; old_act->_sa_handler = oact._sa_handler; old_act->sa_flags = oact.sa_flags; old_act->sa_mask.sig[0] = oact.sa_mask.sig[0]; old_act->sa_mask.sig[1] = 0; old_act->sa_mask.sig[2] = 0; old_act->sa_mask.sig[3] = 0; unlock_user_struct(old_act, arg3, 1); } #else struct target_old_sigaction *old_act; struct target_sigaction act, oact, *pact; if (arg2) { if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1)) goto efault; act._sa_handler = old_act->_sa_handler; target_siginitset(&act.sa_mask, old_act->sa_mask); act.sa_flags = old_act->sa_flags; act.sa_restorer = old_act->sa_restorer; unlock_user_struct(old_act, arg2, 0); pact = &act; } else { pact = NULL; } ret = get_errno(do_sigaction(arg1, pact, &oact)); if (!is_error(ret) && arg3) { if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0)) goto efault; old_act->_sa_handler = oact._sa_handler; old_act->sa_mask = oact.sa_mask.sig[0]; old_act->sa_flags = oact.sa_flags; old_act->sa_restorer = oact.sa_restorer; unlock_user_struct(old_act, arg3, 1); } #endif } break; #endif case TARGET_NR_rt_sigaction: { #if defined(TARGET_ALPHA) struct target_sigaction act, oact, *pact = 0; struct target_rt_sigaction *rt_act; if (arg2) { if (!lock_user_struct(VERIFY_READ, rt_act, arg2, 1)) goto efault; act._sa_handler = rt_act->_sa_handler; act.sa_mask = rt_act->sa_mask; act.sa_flags = rt_act->sa_flags; act.sa_restorer = arg5; unlock_user_struct(rt_act, arg2, 0); pact = &act; } ret = get_errno(do_sigaction(arg1, pact, &oact)); if (!is_error(ret) && arg3) { if (!lock_user_struct(VERIFY_WRITE, rt_act, arg3, 0)) goto efault; rt_act->_sa_handler = oact._sa_handler; rt_act->sa_mask = oact.sa_mask; rt_act->sa_flags = oact.sa_flags; unlock_user_struct(rt_act, arg3, 1); } #else struct target_sigaction *act; struct target_sigaction *oact; if (arg2) { if (!lock_user_struct(VERIFY_READ, act, arg2, 1)) goto efault; } else act = NULL; if (arg3) { if (!lock_user_struct(VERIFY_WRITE, oact, arg3, 0)) { ret = -TARGET_EFAULT; goto rt_sigaction_fail; } } else oact = NULL; ret = get_errno(do_sigaction(arg1, act, oact)); rt_sigaction_fail: if (act) unlock_user_struct(act, arg2, 0); if (oact) unlock_user_struct(oact, arg3, 1); #endif } break; #ifdef TARGET_NR_sgetmask case TARGET_NR_sgetmask: { sigset_t cur_set; abi_ulong target_set; sigprocmask(0, NULL, &cur_set); host_to_target_old_sigset(&target_set, &cur_set); ret = target_set; } break; #endif #ifdef TARGET_NR_ssetmask case TARGET_NR_ssetmask: { sigset_t set, oset, cur_set; abi_ulong target_set = arg1; sigprocmask(0, NULL, &cur_set); target_to_host_old_sigset(&set, &target_set); sigorset(&set, &set, &cur_set); sigprocmask(SIG_SETMASK, &set, &oset); host_to_target_old_sigset(&target_set, &oset); ret = target_set; } break; #endif #ifdef TARGET_NR_sigprocmask case TARGET_NR_sigprocmask: { #if defined(TARGET_ALPHA) sigset_t set, oldset; abi_ulong mask; int how; switch (arg1) { case TARGET_SIG_BLOCK: how = SIG_BLOCK; break; case TARGET_SIG_UNBLOCK: how = SIG_UNBLOCK; break; case TARGET_SIG_SETMASK: how = SIG_SETMASK; break; default: ret = -TARGET_EINVAL; goto fail; } mask = arg2; target_to_host_old_sigset(&set, &mask); ret = get_errno(sigprocmask(how, &set, &oldset)); if (!is_error(ret)) { host_to_target_old_sigset(&mask, &oldset); ret = mask; ((CPUAlphaState *)cpu_env)->ir[IR_V0] = 0; } #else sigset_t set, oldset, *set_ptr; int how; if (arg2) { switch (arg1) { case TARGET_SIG_BLOCK: how = SIG_BLOCK; break; case TARGET_SIG_UNBLOCK: how = SIG_UNBLOCK; break; case TARGET_SIG_SETMASK: how = SIG_SETMASK; break; default: ret = -TARGET_EINVAL; goto fail; } if (!(p = lock_user(VERIFY_READ, arg2, sizeof(target_sigset_t), 1))) goto efault; target_to_host_old_sigset(&set, p); unlock_user(p, arg2, 0); set_ptr = &set; } else { how = 0; set_ptr = NULL; } ret = get_errno(sigprocmask(how, set_ptr, &oldset)); if (!is_error(ret) && arg3) { if (!(p = lock_user(VERIFY_WRITE, arg3, sizeof(target_sigset_t), 0))) goto efault; host_to_target_old_sigset(p, &oldset); unlock_user(p, arg3, sizeof(target_sigset_t)); } #endif } break; #endif case TARGET_NR_rt_sigprocmask: { int how = arg1; sigset_t set, oldset, *set_ptr; if (arg2) { switch(how) { case TARGET_SIG_BLOCK: how = SIG_BLOCK; break; case TARGET_SIG_UNBLOCK: how = SIG_UNBLOCK; break; case TARGET_SIG_SETMASK: how = SIG_SETMASK; break; default: ret = -TARGET_EINVAL; goto fail; } if (!(p = lock_user(VERIFY_READ, arg2, sizeof(target_sigset_t), 1))) goto efault; target_to_host_sigset(&set, p); unlock_user(p, arg2, 0); set_ptr = &set; } else { how = 0; set_ptr = NULL; } ret = get_errno(sigprocmask(how, set_ptr, &oldset)); if (!is_error(ret) && arg3) { if (!(p = lock_user(VERIFY_WRITE, arg3, sizeof(target_sigset_t), 0))) goto efault; host_to_target_sigset(p, &oldset); unlock_user(p, arg3, sizeof(target_sigset_t)); } } break; #ifdef TARGET_NR_sigpending case TARGET_NR_sigpending: { sigset_t set; ret = get_errno(sigpending(&set)); if (!is_error(ret)) { if (!(p = lock_user(VERIFY_WRITE, arg1, sizeof(target_sigset_t), 0))) goto efault; host_to_target_old_sigset(p, &set); unlock_user(p, arg1, sizeof(target_sigset_t)); } } break; #endif case TARGET_NR_rt_sigpending: { sigset_t set; ret = get_errno(sigpending(&set)); if (!is_error(ret)) { if (!(p = lock_user(VERIFY_WRITE, arg1, sizeof(target_sigset_t), 0))) goto efault; host_to_target_sigset(p, &set); unlock_user(p, arg1, sizeof(target_sigset_t)); } } break; #ifdef TARGET_NR_sigsuspend case TARGET_NR_sigsuspend: { sigset_t set; #if defined(TARGET_ALPHA) abi_ulong mask = arg1; target_to_host_old_sigset(&set, &mask); #else if (!(p = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1))) goto efault; target_to_host_old_sigset(&set, p); unlock_user(p, arg1, 0); #endif ret = get_errno(sigsuspend(&set)); } break; #endif case TARGET_NR_rt_sigsuspend: { sigset_t set; if (!(p = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1))) goto efault; target_to_host_sigset(&set, p); unlock_user(p, arg1, 0); ret = get_errno(sigsuspend(&set)); } break; case TARGET_NR_rt_sigtimedwait: { sigset_t set; struct timespec uts, *puts; siginfo_t uinfo; if (!(p = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1))) goto efault; target_to_host_sigset(&set, p); unlock_user(p, arg1, 0); if (arg3) { puts = &uts; target_to_host_timespec(puts, arg3); } else { puts = NULL; } ret = get_errno(sigtimedwait(&set, &uinfo, puts)); if (!is_error(ret) && arg2) { if (!(p = lock_user(VERIFY_WRITE, arg2, sizeof(target_siginfo_t), 0))) goto efault; host_to_target_siginfo(p, &uinfo); unlock_user(p, arg2, sizeof(target_siginfo_t)); } } break; case TARGET_NR_rt_sigqueueinfo: { siginfo_t uinfo; if (!(p = lock_user(VERIFY_READ, arg3, sizeof(target_sigset_t), 1))) goto efault; target_to_host_siginfo(&uinfo, p); unlock_user(p, arg1, 0); ret = get_errno(sys_rt_sigqueueinfo(arg1, arg2, &uinfo)); } break; #ifdef TARGET_NR_sigreturn case TARGET_NR_sigreturn: ret = do_sigreturn(cpu_env); break; #endif case TARGET_NR_rt_sigreturn: ret = do_rt_sigreturn(cpu_env); break; case TARGET_NR_sethostname: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(sethostname(p, arg2)); unlock_user(p, arg1, 0); break; case TARGET_NR_setrlimit: { int resource = target_to_host_resource(arg1); struct target_rlimit *target_rlim; struct rlimit rlim; if (!lock_user_struct(VERIFY_READ, target_rlim, arg2, 1)) goto efault; rlim.rlim_cur = target_to_host_rlim(target_rlim->rlim_cur); rlim.rlim_max = target_to_host_rlim(target_rlim->rlim_max); unlock_user_struct(target_rlim, arg2, 0); ret = get_errno(setrlimit(resource, &rlim)); } break; case TARGET_NR_getrlimit: { int resource = target_to_host_resource(arg1); struct target_rlimit *target_rlim; struct rlimit rlim; ret = get_errno(getrlimit(resource, &rlim)); if (!is_error(ret)) { if (!lock_user_struct(VERIFY_WRITE, target_rlim, arg2, 0)) goto efault; target_rlim->rlim_cur = host_to_target_rlim(rlim.rlim_cur); target_rlim->rlim_max = host_to_target_rlim(rlim.rlim_max); unlock_user_struct(target_rlim, arg2, 1); } } break; case TARGET_NR_getrusage: { struct rusage rusage; ret = get_errno(getrusage(arg1, &rusage)); if (!is_error(ret)) { host_to_target_rusage(arg2, &rusage); } } break; case TARGET_NR_gettimeofday: { struct timeval tv; ret = get_errno(gettimeofday(&tv, NULL)); if (!is_error(ret)) { if (copy_to_user_timeval(arg1, &tv)) goto efault; } } break; case TARGET_NR_settimeofday: { struct timeval tv; if (copy_from_user_timeval(&tv, arg1)) goto efault; ret = get_errno(settimeofday(&tv, NULL)); } break; #if defined(TARGET_NR_select) && !defined(TARGET_S390X) && !defined(TARGET_S390) case TARGET_NR_select: { struct target_sel_arg_struct *sel; abi_ulong inp, outp, exp, tvp; long nsel; if (!lock_user_struct(VERIFY_READ, sel, arg1, 1)) goto efault; nsel = tswapal(sel->n); inp = tswapal(sel->inp); outp = tswapal(sel->outp); exp = tswapal(sel->exp); tvp = tswapal(sel->tvp); unlock_user_struct(sel, arg1, 0); ret = do_select(nsel, inp, outp, exp, tvp); } break; #endif #ifdef TARGET_NR_pselect6 case TARGET_NR_pselect6: { abi_long rfd_addr, wfd_addr, efd_addr, n, ts_addr; fd_set rfds, wfds, efds; fd_set *rfds_ptr, *wfds_ptr, *efds_ptr; struct timespec ts, *ts_ptr; sigset_t set; struct { sigset_t *set; size_t size; } sig, *sig_ptr; abi_ulong arg_sigset, arg_sigsize, *arg7; target_sigset_t *target_sigset; n = arg1; rfd_addr = arg2; wfd_addr = arg3; efd_addr = arg4; ts_addr = arg5; ret = copy_from_user_fdset_ptr(&rfds, &rfds_ptr, rfd_addr, n); if (ret) { goto fail; } ret = copy_from_user_fdset_ptr(&wfds, &wfds_ptr, wfd_addr, n); if (ret) { goto fail; } ret = copy_from_user_fdset_ptr(&efds, &efds_ptr, efd_addr, n); if (ret) { goto fail; } if (ts_addr) { if (target_to_host_timespec(&ts, ts_addr)) { goto efault; } ts_ptr = &ts; } else { ts_ptr = NULL; } if (arg6) { sig_ptr = &sig; sig.size = _NSIG / 8; arg7 = lock_user(VERIFY_READ, arg6, sizeof(*arg7) * 2, 1); if (!arg7) { goto efault; } arg_sigset = tswapal(arg7[0]); arg_sigsize = tswapal(arg7[1]); unlock_user(arg7, arg6, 0); if (arg_sigset) { sig.set = &set; if (arg_sigsize != sizeof(*target_sigset)) { ret = -TARGET_EINVAL; goto fail; } target_sigset = lock_user(VERIFY_READ, arg_sigset, sizeof(*target_sigset), 1); if (!target_sigset) { goto efault; } target_to_host_sigset(&set, target_sigset); unlock_user(target_sigset, arg_sigset, 0); } else { sig.set = NULL; } } else { sig_ptr = NULL; } ret = get_errno(sys_pselect6(n, rfds_ptr, wfds_ptr, efds_ptr, ts_ptr, sig_ptr)); if (!is_error(ret)) { if (rfd_addr && copy_to_user_fdset(rfd_addr, &rfds, n)) goto efault; if (wfd_addr && copy_to_user_fdset(wfd_addr, &wfds, n)) goto efault; if (efd_addr && copy_to_user_fdset(efd_addr, &efds, n)) goto efault; if (ts_addr && host_to_target_timespec(ts_addr, &ts)) goto efault; } } break; #endif case TARGET_NR_symlink: { void *p2; p = lock_user_string(arg1); p2 = lock_user_string(arg2); if (!p || !p2) ret = -TARGET_EFAULT; else ret = get_errno(symlink(p, p2)); unlock_user(p2, arg2, 0); unlock_user(p, arg1, 0); } break; #if defined(TARGET_NR_symlinkat) && defined(__NR_symlinkat) case TARGET_NR_symlinkat: { void *p2; p = lock_user_string(arg1); p2 = lock_user_string(arg3); if (!p || !p2) ret = -TARGET_EFAULT; else ret = get_errno(sys_symlinkat(p, arg2, p2)); unlock_user(p2, arg3, 0); unlock_user(p, arg1, 0); } break; #endif #ifdef TARGET_NR_oldlstat case TARGET_NR_oldlstat: goto unimplemented; #endif case TARGET_NR_readlink: { void *p2, *temp; p = lock_user_string(arg1); p2 = lock_user(VERIFY_WRITE, arg2, arg3, 0); if (!p || !p2) ret = -TARGET_EFAULT; else { if (strncmp((const char *)p, "/proc/self/exe", 14) == 0) { char real[PATH_MAX]; temp = realpath(exec_path,real); ret = (temp==NULL) ? get_errno(-1) : strlen(real) ; snprintf((char *)p2, arg3, "%s", real); } else ret = get_errno(readlink(path(p), p2, arg3)); } unlock_user(p2, arg2, ret); unlock_user(p, arg1, 0); } break; #if defined(TARGET_NR_readlinkat) && defined(__NR_readlinkat) case TARGET_NR_readlinkat: { void *p2; p = lock_user_string(arg2); p2 = lock_user(VERIFY_WRITE, arg3, arg4, 0); if (!p || !p2) ret = -TARGET_EFAULT; else ret = get_errno(sys_readlinkat(arg1, path(p), p2, arg4)); unlock_user(p2, arg3, ret); unlock_user(p, arg2, 0); } break; #endif #ifdef TARGET_NR_uselib case TARGET_NR_uselib: goto unimplemented; #endif #ifdef TARGET_NR_swapon case TARGET_NR_swapon: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(swapon(p, arg2)); unlock_user(p, arg1, 0); break; #endif case TARGET_NR_reboot: if (!(p = lock_user_string(arg4))) goto efault; ret = reboot(arg1, arg2, arg3, p); unlock_user(p, arg4, 0); break; #ifdef TARGET_NR_readdir case TARGET_NR_readdir: goto unimplemented; #endif #ifdef TARGET_NR_mmap case TARGET_NR_mmap: #if (defined(TARGET_I386) && defined(TARGET_ABI32)) || defined(TARGET_ARM) || \ defined(TARGET_M68K) || defined(TARGET_CRIS) || defined(TARGET_MICROBLAZE) \ || defined(TARGET_S390X) { abi_ulong *v; abi_ulong v1, v2, v3, v4, v5, v6; if (!(v = lock_user(VERIFY_READ, arg1, 6 * sizeof(abi_ulong), 1))) goto efault; v1 = tswapal(v[0]); v2 = tswapal(v[1]); v3 = tswapal(v[2]); v4 = tswapal(v[3]); v5 = tswapal(v[4]); v6 = tswapal(v[5]); unlock_user(v, arg1, 0); ret = get_errno(target_mmap(v1, v2, v3, target_to_host_bitmask(v4, mmap_flags_tbl), v5, v6)); } #else ret = get_errno(target_mmap(arg1, arg2, arg3, target_to_host_bitmask(arg4, mmap_flags_tbl), arg5, arg6)); #endif break; #endif #ifdef TARGET_NR_mmap2 case TARGET_NR_mmap2: #ifndef MMAP_SHIFT #define MMAP_SHIFT 12 #endif ret = get_errno(target_mmap(arg1, arg2, arg3, target_to_host_bitmask(arg4, mmap_flags_tbl), arg5, arg6 << MMAP_SHIFT)); break; #endif case TARGET_NR_munmap: ret = get_errno(target_munmap(arg1, arg2)); break; case TARGET_NR_mprotect: { TaskState *ts = ((CPUArchState *)cpu_env)->opaque; if ((arg3 & PROT_GROWSDOWN) && arg1 >= ts->info->stack_limit && arg1 <= ts->info->start_stack) { arg3 &= ~PROT_GROWSDOWN; arg2 = arg2 + arg1 - ts->info->stack_limit; arg1 = ts->info->stack_limit; } } ret = get_errno(target_mprotect(arg1, arg2, arg3)); break; #ifdef TARGET_NR_mremap case TARGET_NR_mremap: ret = get_errno(target_mremap(arg1, arg2, arg3, arg4, arg5)); break; #endif #ifdef TARGET_NR_msync case TARGET_NR_msync: ret = get_errno(msync(g2h(arg1), arg2, arg3)); break; #endif #ifdef TARGET_NR_mlock case TARGET_NR_mlock: ret = get_errno(mlock(g2h(arg1), arg2)); break; #endif #ifdef TARGET_NR_munlock case TARGET_NR_munlock: ret = get_errno(munlock(g2h(arg1), arg2)); break; #endif #ifdef TARGET_NR_mlockall case TARGET_NR_mlockall: ret = get_errno(mlockall(arg1)); break; #endif #ifdef TARGET_NR_munlockall case TARGET_NR_munlockall: ret = get_errno(munlockall()); break; #endif case TARGET_NR_truncate: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(truncate(p, arg2)); unlock_user(p, arg1, 0); break; case TARGET_NR_ftruncate: ret = get_errno(ftruncate(arg1, arg2)); break; case TARGET_NR_fchmod: ret = get_errno(fchmod(arg1, arg2)); break; #if defined(TARGET_NR_fchmodat) && defined(__NR_fchmodat) case TARGET_NR_fchmodat: if (!(p = lock_user_string(arg2))) goto efault; ret = get_errno(sys_fchmodat(arg1, p, arg3)); unlock_user(p, arg2, 0); break; #endif case TARGET_NR_getpriority: errno = 0; ret = getpriority(arg1, arg2); if (ret == -1 && errno != 0) { ret = -host_to_target_errno(errno); break; } #ifdef TARGET_ALPHA ((CPUAlphaState *)cpu_env)->ir[IR_V0] = 0; #else ret = 20 - ret; #endif break; case TARGET_NR_setpriority: ret = get_errno(setpriority(arg1, arg2, arg3)); break; #ifdef TARGET_NR_profil case TARGET_NR_profil: goto unimplemented; #endif case TARGET_NR_statfs: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(statfs(path(p), &stfs)); unlock_user(p, arg1, 0); convert_statfs: if (!is_error(ret)) { struct target_statfs *target_stfs; if (!lock_user_struct(VERIFY_WRITE, target_stfs, arg2, 0)) goto efault; __put_user(stfs.f_type, &target_stfs->f_type); __put_user(stfs.f_bsize, &target_stfs->f_bsize); __put_user(stfs.f_blocks, &target_stfs->f_blocks); __put_user(stfs.f_bfree, &target_stfs->f_bfree); __put_user(stfs.f_bavail, &target_stfs->f_bavail); __put_user(stfs.f_files, &target_stfs->f_files); __put_user(stfs.f_ffree, &target_stfs->f_ffree); __put_user(stfs.f_fsid.__val[0], &target_stfs->f_fsid.val[0]); __put_user(stfs.f_fsid.__val[1], &target_stfs->f_fsid.val[1]); __put_user(stfs.f_namelen, &target_stfs->f_namelen); __put_user(stfs.f_frsize, &target_stfs->f_frsize); memset(target_stfs->f_spare, 0, sizeof(target_stfs->f_spare)); unlock_user_struct(target_stfs, arg2, 1); } break; case TARGET_NR_fstatfs: ret = get_errno(fstatfs(arg1, &stfs)); goto convert_statfs; #ifdef TARGET_NR_statfs64 case TARGET_NR_statfs64: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(statfs(path(p), &stfs)); unlock_user(p, arg1, 0); convert_statfs64: if (!is_error(ret)) { struct target_statfs64 *target_stfs; if (!lock_user_struct(VERIFY_WRITE, target_stfs, arg3, 0)) goto efault; __put_user(stfs.f_type, &target_stfs->f_type); __put_user(stfs.f_bsize, &target_stfs->f_bsize); __put_user(stfs.f_blocks, &target_stfs->f_blocks); __put_user(stfs.f_bfree, &target_stfs->f_bfree); __put_user(stfs.f_bavail, &target_stfs->f_bavail); __put_user(stfs.f_files, &target_stfs->f_files); __put_user(stfs.f_ffree, &target_stfs->f_ffree); __put_user(stfs.f_fsid.__val[0], &target_stfs->f_fsid.val[0]); __put_user(stfs.f_fsid.__val[1], &target_stfs->f_fsid.val[1]); __put_user(stfs.f_namelen, &target_stfs->f_namelen); __put_user(stfs.f_frsize, &target_stfs->f_frsize); memset(target_stfs->f_spare, 0, sizeof(target_stfs->f_spare)); unlock_user_struct(target_stfs, arg3, 1); } break; case TARGET_NR_fstatfs64: ret = get_errno(fstatfs(arg1, &stfs)); goto convert_statfs64; #endif #ifdef TARGET_NR_ioperm case TARGET_NR_ioperm: goto unimplemented; #endif #ifdef TARGET_NR_socketcall case TARGET_NR_socketcall: ret = do_socketcall(arg1, arg2); break; #endif #ifdef TARGET_NR_accept case TARGET_NR_accept: ret = do_accept(arg1, arg2, arg3); break; #endif #ifdef TARGET_NR_bind case TARGET_NR_bind: ret = do_bind(arg1, arg2, arg3); break; #endif #ifdef TARGET_NR_connect case TARGET_NR_connect: ret = do_connect(arg1, arg2, arg3); break; #endif #ifdef TARGET_NR_getpeername case TARGET_NR_getpeername: ret = do_getpeername(arg1, arg2, arg3); break; #endif #ifdef TARGET_NR_getsockname case TARGET_NR_getsockname: ret = do_getsockname(arg1, arg2, arg3); break; #endif #ifdef TARGET_NR_getsockopt case TARGET_NR_getsockopt: ret = do_getsockopt(arg1, arg2, arg3, arg4, arg5); break; #endif #ifdef TARGET_NR_listen case TARGET_NR_listen: ret = get_errno(listen(arg1, arg2)); break; #endif #ifdef TARGET_NR_recv case TARGET_NR_recv: ret = do_recvfrom(arg1, arg2, arg3, arg4, 0, 0); break; #endif #ifdef TARGET_NR_recvfrom case TARGET_NR_recvfrom: ret = do_recvfrom(arg1, arg2, arg3, arg4, arg5, arg6); break; #endif #ifdef TARGET_NR_recvmsg case TARGET_NR_recvmsg: ret = do_sendrecvmsg(arg1, arg2, arg3, 0); break; #endif #ifdef TARGET_NR_send case TARGET_NR_send: ret = do_sendto(arg1, arg2, arg3, arg4, 0, 0); break; #endif #ifdef TARGET_NR_sendmsg case TARGET_NR_sendmsg: ret = do_sendrecvmsg(arg1, arg2, arg3, 1); break; #endif #ifdef TARGET_NR_sendto case TARGET_NR_sendto: ret = do_sendto(arg1, arg2, arg3, arg4, arg5, arg6); break; #endif #ifdef TARGET_NR_shutdown case TARGET_NR_shutdown: ret = get_errno(shutdown(arg1, arg2)); break; #endif #ifdef TARGET_NR_socket case TARGET_NR_socket: ret = do_socket(arg1, arg2, arg3); break; #endif #ifdef TARGET_NR_socketpair case TARGET_NR_socketpair: ret = do_socketpair(arg1, arg2, arg3, arg4); break; #endif #ifdef TARGET_NR_setsockopt case TARGET_NR_setsockopt: ret = do_setsockopt(arg1, arg2, arg3, arg4, (socklen_t) arg5); break; #endif case TARGET_NR_syslog: if (!(p = lock_user_string(arg2))) goto efault; ret = get_errno(sys_syslog((int)arg1, p, (int)arg3)); unlock_user(p, arg2, 0); break; case TARGET_NR_setitimer: { struct itimerval value, ovalue, *pvalue; if (arg2) { pvalue = &value; if (copy_from_user_timeval(&pvalue->it_interval, arg2) || copy_from_user_timeval(&pvalue->it_value, arg2 + sizeof(struct target_timeval))) goto efault; } else { pvalue = NULL; } ret = get_errno(setitimer(arg1, pvalue, &ovalue)); if (!is_error(ret) && arg3) { if (copy_to_user_timeval(arg3, &ovalue.it_interval) || copy_to_user_timeval(arg3 + sizeof(struct target_timeval), &ovalue.it_value)) goto efault; } } break; case TARGET_NR_getitimer: { struct itimerval value; ret = get_errno(getitimer(arg1, &value)); if (!is_error(ret) && arg2) { if (copy_to_user_timeval(arg2, &value.it_interval) || copy_to_user_timeval(arg2 + sizeof(struct target_timeval), &value.it_value)) goto efault; } } break; case TARGET_NR_stat: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(stat(path(p), &st)); unlock_user(p, arg1, 0); goto do_stat; case TARGET_NR_lstat: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(lstat(path(p), &st)); unlock_user(p, arg1, 0); goto do_stat; case TARGET_NR_fstat: { ret = get_errno(fstat(arg1, &st)); do_stat: if (!is_error(ret)) { struct target_stat *target_st; if (!lock_user_struct(VERIFY_WRITE, target_st, arg2, 0)) goto efault; memset(target_st, 0, sizeof(*target_st)); __put_user(st.st_dev, &target_st->st_dev); __put_user(st.st_ino, &target_st->st_ino); __put_user(st.st_mode, &target_st->st_mode); __put_user(st.st_uid, &target_st->st_uid); __put_user(st.st_gid, &target_st->st_gid); __put_user(st.st_nlink, &target_st->st_nlink); __put_user(st.st_rdev, &target_st->st_rdev); __put_user(st.st_size, &target_st->st_size); __put_user(st.st_blksize, &target_st->st_blksize); __put_user(st.st_blocks, &target_st->st_blocks); __put_user(st.st_atime, &target_st->target_st_atime); __put_user(st.st_mtime, &target_st->target_st_mtime); __put_user(st.st_ctime, &target_st->target_st_ctime); unlock_user_struct(target_st, arg2, 1); } } break; #ifdef TARGET_NR_olduname case TARGET_NR_olduname: goto unimplemented; #endif #ifdef TARGET_NR_iopl case TARGET_NR_iopl: goto unimplemented; #endif case TARGET_NR_vhangup: ret = get_errno(vhangup()); break; #ifdef TARGET_NR_idle case TARGET_NR_idle: goto unimplemented; #endif #ifdef TARGET_NR_syscall case TARGET_NR_syscall: ret = do_syscall(cpu_env, arg1 & 0xffff, arg2, arg3, arg4, arg5, arg6, arg7, arg8, 0); break; #endif case TARGET_NR_wait4: { int status; abi_long status_ptr = arg2; struct rusage rusage, *rusage_ptr; abi_ulong target_rusage = arg4; if (target_rusage) rusage_ptr = &rusage; else rusage_ptr = NULL; ret = get_errno(wait4(arg1, &status, arg3, rusage_ptr)); if (!is_error(ret)) { if (status_ptr && ret) { status = host_to_target_waitstatus(status); if (put_user_s32(status, status_ptr)) goto efault; } if (target_rusage) host_to_target_rusage(target_rusage, &rusage); } } break; #ifdef TARGET_NR_swapoff case TARGET_NR_swapoff: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(swapoff(p)); unlock_user(p, arg1, 0); break; #endif case TARGET_NR_sysinfo: { struct target_sysinfo *target_value; struct sysinfo value; ret = get_errno(sysinfo(&value)); if (!is_error(ret) && arg1) { if (!lock_user_struct(VERIFY_WRITE, target_value, arg1, 0)) goto efault; __put_user(value.uptime, &target_value->uptime); __put_user(value.loads[0], &target_value->loads[0]); __put_user(value.loads[1], &target_value->loads[1]); __put_user(value.loads[2], &target_value->loads[2]); __put_user(value.totalram, &target_value->totalram); __put_user(value.freeram, &target_value->freeram); __put_user(value.sharedram, &target_value->sharedram); __put_user(value.bufferram, &target_value->bufferram); __put_user(value.totalswap, &target_value->totalswap); __put_user(value.freeswap, &target_value->freeswap); __put_user(value.procs, &target_value->procs); __put_user(value.totalhigh, &target_value->totalhigh); __put_user(value.freehigh, &target_value->freehigh); __put_user(value.mem_unit, &target_value->mem_unit); unlock_user_struct(target_value, arg1, 1); } } break; #ifdef TARGET_NR_ipc case TARGET_NR_ipc: ret = do_ipc(arg1, arg2, arg3, arg4, arg5, arg6); break; #endif #ifdef TARGET_NR_semget case TARGET_NR_semget: ret = get_errno(semget(arg1, arg2, arg3)); break; #endif #ifdef TARGET_NR_semop case TARGET_NR_semop: ret = get_errno(do_semop(arg1, arg2, arg3)); break; #endif #ifdef TARGET_NR_semctl case TARGET_NR_semctl: ret = do_semctl(arg1, arg2, arg3, (union target_semun)(abi_ulong)arg4); break; #endif #ifdef TARGET_NR_msgctl case TARGET_NR_msgctl: ret = do_msgctl(arg1, arg2, arg3); break; #endif #ifdef TARGET_NR_msgget case TARGET_NR_msgget: ret = get_errno(msgget(arg1, arg2)); break; #endif #ifdef TARGET_NR_msgrcv case TARGET_NR_msgrcv: ret = do_msgrcv(arg1, arg2, arg3, arg4, arg5); break; #endif #ifdef TARGET_NR_msgsnd case TARGET_NR_msgsnd: ret = do_msgsnd(arg1, arg2, arg3, arg4); break; #endif #ifdef TARGET_NR_shmget case TARGET_NR_shmget: ret = get_errno(shmget(arg1, arg2, arg3)); break; #endif #ifdef TARGET_NR_shmctl case TARGET_NR_shmctl: ret = do_shmctl(arg1, arg2, arg3); break; #endif #ifdef TARGET_NR_shmat case TARGET_NR_shmat: ret = do_shmat(arg1, arg2, arg3); break; #endif #ifdef TARGET_NR_shmdt case TARGET_NR_shmdt: ret = do_shmdt(arg1); break; #endif case TARGET_NR_fsync: ret = get_errno(fsync(arg1)); break; case TARGET_NR_clone: #if defined(TARGET_SH4) || defined(TARGET_ALPHA) ret = get_errno(do_fork(cpu_env, arg1, arg2, arg3, arg5, arg4)); #elif defined(TARGET_CRIS) ret = get_errno(do_fork(cpu_env, arg2, arg1, arg3, arg4, arg5)); #elif defined(TARGET_S390X) ret = get_errno(do_fork(cpu_env, arg2, arg1, arg3, arg5, arg4)); #else ret = get_errno(do_fork(cpu_env, arg1, arg2, arg3, arg4, arg5)); #endif break; #ifdef __NR_exit_group case TARGET_NR_exit_group: #ifdef TARGET_GPROF _mcleanup(); #endif gdb_exit(cpu_env, arg1); ret = get_errno(exit_group(arg1)); break; #endif case TARGET_NR_setdomainname: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(setdomainname(p, arg2)); unlock_user(p, arg1, 0); break; case TARGET_NR_uname: { struct new_utsname * buf; if (!lock_user_struct(VERIFY_WRITE, buf, arg1, 0)) goto efault; ret = get_errno(sys_uname(buf)); if (!is_error(ret)) { strcpy (buf->machine, cpu_to_uname_machine(cpu_env)); if (qemu_uname_release && *qemu_uname_release) strcpy (buf->release, qemu_uname_release); } unlock_user_struct(buf, arg1, 1); } break; #ifdef TARGET_I386 case TARGET_NR_modify_ldt: ret = do_modify_ldt(cpu_env, arg1, arg2, arg3); break; #if !defined(TARGET_X86_64) case TARGET_NR_vm86old: goto unimplemented; case TARGET_NR_vm86: ret = do_vm86(cpu_env, arg1, arg2); break; #endif #endif case TARGET_NR_adjtimex: goto unimplemented; #ifdef TARGET_NR_create_module case TARGET_NR_create_module: #endif case TARGET_NR_init_module: case TARGET_NR_delete_module: #ifdef TARGET_NR_get_kernel_syms case TARGET_NR_get_kernel_syms: #endif goto unimplemented; case TARGET_NR_quotactl: goto unimplemented; case TARGET_NR_getpgid: ret = get_errno(getpgid(arg1)); break; case TARGET_NR_fchdir: ret = get_errno(fchdir(arg1)); break; #ifdef TARGET_NR_bdflush case TARGET_NR_bdflush: goto unimplemented; #endif #ifdef TARGET_NR_sysfs case TARGET_NR_sysfs: goto unimplemented; #endif case TARGET_NR_personality: ret = get_errno(personality(arg1)); break; #ifdef TARGET_NR_afs_syscall case TARGET_NR_afs_syscall: goto unimplemented; #endif #ifdef TARGET_NR__llseek case TARGET_NR__llseek: { int64_t res; #if !defined(__NR_llseek) res = lseek(arg1, ((uint64_t)arg2 << 32) | arg3, arg5); if (res == -1) { ret = get_errno(res); } else { ret = 0; } #else ret = get_errno(_llseek(arg1, arg2, arg3, &res, arg5)); #endif if ((ret == 0) && put_user_s64(res, arg4)) { goto efault; } } break; #endif case TARGET_NR_getdents: #if TARGET_ABI_BITS == 32 && HOST_LONG_BITS == 64 { struct target_dirent *target_dirp; struct linux_dirent *dirp; abi_long count = arg3; dirp = malloc(count); if (!dirp) { ret = -TARGET_ENOMEM; goto fail; } ret = get_errno(sys_getdents(arg1, dirp, count)); if (!is_error(ret)) { struct linux_dirent *de; struct target_dirent *tde; int len = ret; int reclen, treclen; int count1, tnamelen; count1 = 0; de = dirp; if (!(target_dirp = lock_user(VERIFY_WRITE, arg2, count, 0))) goto efault; tde = target_dirp; while (len > 0) { reclen = de->d_reclen; tnamelen = reclen - offsetof(struct linux_dirent, d_name); assert(tnamelen >= 0); treclen = tnamelen + offsetof(struct target_dirent, d_name); assert(count1 + treclen <= count); tde->d_reclen = tswap16(treclen); tde->d_ino = tswapal(de->d_ino); tde->d_off = tswapal(de->d_off); memcpy(tde->d_name, de->d_name, tnamelen); de = (struct linux_dirent *)((char *)de + reclen); len -= reclen; tde = (struct target_dirent *)((char *)tde + treclen); count1 += treclen; } ret = count1; unlock_user(target_dirp, arg2, ret); } free(dirp); } #else { struct linux_dirent *dirp; abi_long count = arg3; if (!(dirp = lock_user(VERIFY_WRITE, arg2, count, 0))) goto efault; ret = get_errno(sys_getdents(arg1, dirp, count)); if (!is_error(ret)) { struct linux_dirent *de; int len = ret; int reclen; de = dirp; while (len > 0) { reclen = de->d_reclen; if (reclen > len) break; de->d_reclen = tswap16(reclen); tswapls(&de->d_ino); tswapls(&de->d_off); de = (struct linux_dirent *)((char *)de + reclen); len -= reclen; } } unlock_user(dirp, arg2, ret); } #endif break; #if defined(TARGET_NR_getdents64) && defined(__NR_getdents64) case TARGET_NR_getdents64: { struct linux_dirent64 *dirp; abi_long count = arg3; if (!(dirp = lock_user(VERIFY_WRITE, arg2, count, 0))) goto efault; ret = get_errno(sys_getdents64(arg1, dirp, count)); if (!is_error(ret)) { struct linux_dirent64 *de; int len = ret; int reclen; de = dirp; while (len > 0) { reclen = de->d_reclen; if (reclen > len) break; de->d_reclen = tswap16(reclen); tswap64s((uint64_t *)&de->d_ino); tswap64s((uint64_t *)&de->d_off); de = (struct linux_dirent64 *)((char *)de + reclen); len -= reclen; } } unlock_user(dirp, arg2, ret); } break; #endif #if defined(TARGET_NR__newselect) || defined(TARGET_S390X) #ifdef TARGET_S390X case TARGET_NR_select: #else case TARGET_NR__newselect: #endif ret = do_select(arg1, arg2, arg3, arg4, arg5); break; #endif #if defined(TARGET_NR_poll) || defined(TARGET_NR_ppoll) # ifdef TARGET_NR_poll case TARGET_NR_poll: # endif # ifdef TARGET_NR_ppoll case TARGET_NR_ppoll: # endif { struct target_pollfd *target_pfd; unsigned int nfds = arg2; int timeout = arg3; struct pollfd *pfd; unsigned int i; target_pfd = lock_user(VERIFY_WRITE, arg1, sizeof(struct target_pollfd) * nfds, 1); if (!target_pfd) goto efault; pfd = alloca(sizeof(struct pollfd) * nfds); for(i = 0; i < nfds; i++) { pfd[i].fd = tswap32(target_pfd[i].fd); pfd[i].events = tswap16(target_pfd[i].events); } # ifdef TARGET_NR_ppoll if (num == TARGET_NR_ppoll) { struct timespec _timeout_ts, *timeout_ts = &_timeout_ts; target_sigset_t *target_set; sigset_t _set, *set = &_set; if (arg3) { if (target_to_host_timespec(timeout_ts, arg3)) { unlock_user(target_pfd, arg1, 0); goto efault; } } else { timeout_ts = NULL; } if (arg4) { target_set = lock_user(VERIFY_READ, arg4, sizeof(target_sigset_t), 1); if (!target_set) { unlock_user(target_pfd, arg1, 0); goto efault; } target_to_host_sigset(set, target_set); } else { set = NULL; } ret = get_errno(sys_ppoll(pfd, nfds, timeout_ts, set, _NSIG/8)); if (!is_error(ret) && arg3) { host_to_target_timespec(arg3, timeout_ts); } if (arg4) { unlock_user(target_set, arg4, 0); } } else # endif ret = get_errno(poll(pfd, nfds, timeout)); if (!is_error(ret)) { for(i = 0; i < nfds; i++) { target_pfd[i].revents = tswap16(pfd[i].revents); } } unlock_user(target_pfd, arg1, sizeof(struct target_pollfd) * nfds); } break; #endif case TARGET_NR_flock: ret = get_errno(flock(arg1, arg2)); break; case TARGET_NR_readv: { int count = arg3; struct iovec *vec; vec = alloca(count * sizeof(struct iovec)); if (lock_iovec(VERIFY_WRITE, vec, arg2, count, 0) < 0) goto efault; ret = get_errno(readv(arg1, vec, count)); unlock_iovec(vec, arg2, count, 1); } break; case TARGET_NR_writev: { int count = arg3; struct iovec *vec; vec = alloca(count * sizeof(struct iovec)); if (lock_iovec(VERIFY_READ, vec, arg2, count, 1) < 0) goto efault; ret = get_errno(writev(arg1, vec, count)); unlock_iovec(vec, arg2, count, 0); } break; case TARGET_NR_getsid: ret = get_errno(getsid(arg1)); break; #if defined(TARGET_NR_fdatasync) case TARGET_NR_fdatasync: ret = get_errno(fdatasync(arg1)); break; #endif case TARGET_NR__sysctl: ret = -TARGET_ENOTDIR; break; case TARGET_NR_sched_getaffinity: { unsigned int mask_size; unsigned long *mask; if (arg2 & (sizeof(abi_ulong) - 1)) { ret = -TARGET_EINVAL; break; } mask_size = (arg2 + (sizeof(*mask) - 1)) & ~(sizeof(*mask) - 1); mask = alloca(mask_size); ret = get_errno(sys_sched_getaffinity(arg1, mask_size, mask)); if (!is_error(ret)) { if (copy_to_user(arg3, mask, ret)) { goto efault; } } } break; case TARGET_NR_sched_setaffinity: { unsigned int mask_size; unsigned long *mask; if (arg2 & (sizeof(abi_ulong) - 1)) { ret = -TARGET_EINVAL; break; } mask_size = (arg2 + (sizeof(*mask) - 1)) & ~(sizeof(*mask) - 1); mask = alloca(mask_size); if (!lock_user_struct(VERIFY_READ, p, arg3, 1)) { goto efault; } memcpy(mask, p, arg2); unlock_user_struct(p, arg2, 0); ret = get_errno(sys_sched_setaffinity(arg1, mask_size, mask)); } break; case TARGET_NR_sched_setparam: { struct sched_param *target_schp; struct sched_param schp; if (!lock_user_struct(VERIFY_READ, target_schp, arg2, 1)) goto efault; schp.sched_priority = tswap32(target_schp->sched_priority); unlock_user_struct(target_schp, arg2, 0); ret = get_errno(sched_setparam(arg1, &schp)); } break; case TARGET_NR_sched_getparam: { struct sched_param *target_schp; struct sched_param schp; ret = get_errno(sched_getparam(arg1, &schp)); if (!is_error(ret)) { if (!lock_user_struct(VERIFY_WRITE, target_schp, arg2, 0)) goto efault; target_schp->sched_priority = tswap32(schp.sched_priority); unlock_user_struct(target_schp, arg2, 1); } } break; case TARGET_NR_sched_setscheduler: { struct sched_param *target_schp; struct sched_param schp; if (!lock_user_struct(VERIFY_READ, target_schp, arg3, 1)) goto efault; schp.sched_priority = tswap32(target_schp->sched_priority); unlock_user_struct(target_schp, arg3, 0); ret = get_errno(sched_setscheduler(arg1, arg2, &schp)); } break; case TARGET_NR_sched_getscheduler: ret = get_errno(sched_getscheduler(arg1)); break; case TARGET_NR_sched_yield: ret = get_errno(sched_yield()); break; case TARGET_NR_sched_get_priority_max: ret = get_errno(sched_get_priority_max(arg1)); break; case TARGET_NR_sched_get_priority_min: ret = get_errno(sched_get_priority_min(arg1)); break; case TARGET_NR_sched_rr_get_interval: { struct timespec ts; ret = get_errno(sched_rr_get_interval(arg1, &ts)); if (!is_error(ret)) { host_to_target_timespec(arg2, &ts); } } break; case TARGET_NR_nanosleep: { struct timespec req, rem; target_to_host_timespec(&req, arg1); ret = get_errno(nanosleep(&req, &rem)); if (is_error(ret) && arg2) { host_to_target_timespec(arg2, &rem); } } break; #ifdef TARGET_NR_query_module case TARGET_NR_query_module: goto unimplemented; #endif #ifdef TARGET_NR_nfsservctl case TARGET_NR_nfsservctl: goto unimplemented; #endif case TARGET_NR_prctl: switch (arg1) { case PR_GET_PDEATHSIG: { int deathsig; ret = get_errno(prctl(arg1, &deathsig, arg3, arg4, arg5)); if (!is_error(ret) && arg2 && put_user_ual(deathsig, arg2)) { goto efault; } break; } #ifdef PR_GET_NAME case PR_GET_NAME: { void *name = lock_user(VERIFY_WRITE, arg2, 16, 1); if (!name) { goto efault; } ret = get_errno(prctl(arg1, (unsigned long)name, arg3, arg4, arg5)); unlock_user(name, arg2, 16); break; } case PR_SET_NAME: { void *name = lock_user(VERIFY_READ, arg2, 16, 1); if (!name) { goto efault; } ret = get_errno(prctl(arg1, (unsigned long)name, arg3, arg4, arg5)); unlock_user(name, arg2, 0); break; } #endif default: ret = get_errno(prctl(arg1, arg2, arg3, arg4, arg5)); break; } break; #ifdef TARGET_NR_arch_prctl case TARGET_NR_arch_prctl: #if defined(TARGET_I386) && !defined(TARGET_ABI32) ret = do_arch_prctl(cpu_env, arg1, arg2); break; #else goto unimplemented; #endif #endif #ifdef TARGET_NR_pread case TARGET_NR_pread: if (regpairs_aligned(cpu_env)) arg4 = arg5; if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0))) goto efault; ret = get_errno(pread(arg1, p, arg3, arg4)); unlock_user(p, arg2, ret); break; case TARGET_NR_pwrite: if (regpairs_aligned(cpu_env)) arg4 = arg5; if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1))) goto efault; ret = get_errno(pwrite(arg1, p, arg3, arg4)); unlock_user(p, arg2, 0); break; #endif #ifdef TARGET_NR_pread64 case TARGET_NR_pread64: if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0))) goto efault; ret = get_errno(pread64(arg1, p, arg3, target_offset64(arg4, arg5))); unlock_user(p, arg2, ret); break; case TARGET_NR_pwrite64: if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1))) goto efault; ret = get_errno(pwrite64(arg1, p, arg3, target_offset64(arg4, arg5))); unlock_user(p, arg2, 0); break; #endif case TARGET_NR_getcwd: if (!(p = lock_user(VERIFY_WRITE, arg1, arg2, 0))) goto efault; ret = get_errno(sys_getcwd1(p, arg2)); unlock_user(p, arg1, ret); break; case TARGET_NR_capget: goto unimplemented; case TARGET_NR_capset: goto unimplemented; case TARGET_NR_sigaltstack: #if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_MIPS) || \ defined(TARGET_SPARC) || defined(TARGET_PPC) || defined(TARGET_ALPHA) || \ defined(TARGET_M68K) || defined(TARGET_S390X) || defined(TARGET_OPENRISC) ret = do_sigaltstack(arg1, arg2, get_sp_from_cpustate((CPUArchState *)cpu_env)); break; #else goto unimplemented; #endif case TARGET_NR_sendfile: goto unimplemented; #ifdef TARGET_NR_getpmsg case TARGET_NR_getpmsg: goto unimplemented; #endif #ifdef TARGET_NR_putpmsg case TARGET_NR_putpmsg: goto unimplemented; #endif #ifdef TARGET_NR_vfork case TARGET_NR_vfork: ret = get_errno(do_fork(cpu_env, CLONE_VFORK | CLONE_VM | SIGCHLD, 0, 0, 0, 0)); break; #endif #ifdef TARGET_NR_ugetrlimit case TARGET_NR_ugetrlimit: { struct rlimit rlim; int resource = target_to_host_resource(arg1); ret = get_errno(getrlimit(resource, &rlim)); if (!is_error(ret)) { struct target_rlimit *target_rlim; if (!lock_user_struct(VERIFY_WRITE, target_rlim, arg2, 0)) goto efault; target_rlim->rlim_cur = host_to_target_rlim(rlim.rlim_cur); target_rlim->rlim_max = host_to_target_rlim(rlim.rlim_max); unlock_user_struct(target_rlim, arg2, 1); } break; } #endif #ifdef TARGET_NR_truncate64 case TARGET_NR_truncate64: if (!(p = lock_user_string(arg1))) goto efault; ret = target_truncate64(cpu_env, p, arg2, arg3, arg4); unlock_user(p, arg1, 0); break; #endif #ifdef TARGET_NR_ftruncate64 case TARGET_NR_ftruncate64: ret = target_ftruncate64(cpu_env, arg1, arg2, arg3, arg4); break; #endif #ifdef TARGET_NR_stat64 case TARGET_NR_stat64: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(stat(path(p), &st)); unlock_user(p, arg1, 0); if (!is_error(ret)) ret = host_to_target_stat64(cpu_env, arg2, &st); break; #endif #ifdef TARGET_NR_lstat64 case TARGET_NR_lstat64: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(lstat(path(p), &st)); unlock_user(p, arg1, 0); if (!is_error(ret)) ret = host_to_target_stat64(cpu_env, arg2, &st); break; #endif #ifdef TARGET_NR_fstat64 case TARGET_NR_fstat64: ret = get_errno(fstat(arg1, &st)); if (!is_error(ret)) ret = host_to_target_stat64(cpu_env, arg2, &st); break; #endif #if (defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)) && \ (defined(__NR_fstatat64) || defined(__NR_newfstatat)) #ifdef TARGET_NR_fstatat64 case TARGET_NR_fstatat64: #endif #ifdef TARGET_NR_newfstatat case TARGET_NR_newfstatat: #endif if (!(p = lock_user_string(arg2))) goto efault; #ifdef __NR_fstatat64 ret = get_errno(sys_fstatat64(arg1, path(p), &st, arg4)); #else ret = get_errno(sys_newfstatat(arg1, path(p), &st, arg4)); #endif if (!is_error(ret)) ret = host_to_target_stat64(cpu_env, arg3, &st); break; #endif case TARGET_NR_lchown: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(lchown(p, low2highuid(arg2), low2highgid(arg3))); unlock_user(p, arg1, 0); break; #ifdef TARGET_NR_getuid case TARGET_NR_getuid: ret = get_errno(high2lowuid(getuid())); break; #endif #ifdef TARGET_NR_getgid case TARGET_NR_getgid: ret = get_errno(high2lowgid(getgid())); break; #endif #ifdef TARGET_NR_geteuid case TARGET_NR_geteuid: ret = get_errno(high2lowuid(geteuid())); break; #endif #ifdef TARGET_NR_getegid case TARGET_NR_getegid: ret = get_errno(high2lowgid(getegid())); break; #endif case TARGET_NR_setreuid: ret = get_errno(setreuid(low2highuid(arg1), low2highuid(arg2))); break; case TARGET_NR_setregid: ret = get_errno(setregid(low2highgid(arg1), low2highgid(arg2))); break; case TARGET_NR_getgroups: { int gidsetsize = arg1; target_id *target_grouplist; gid_t *grouplist; int i; grouplist = alloca(gidsetsize * sizeof(gid_t)); ret = get_errno(getgroups(gidsetsize, grouplist)); if (gidsetsize == 0) break; if (!is_error(ret)) { target_grouplist = lock_user(VERIFY_WRITE, arg2, gidsetsize * 2, 0); if (!target_grouplist) goto efault; for(i = 0;i < ret; i++) target_grouplist[i] = tswapid(high2lowgid(grouplist[i])); unlock_user(target_grouplist, arg2, gidsetsize * 2); } } break; case TARGET_NR_setgroups: { int gidsetsize = arg1; target_id *target_grouplist; gid_t *grouplist; int i; grouplist = alloca(gidsetsize * sizeof(gid_t)); target_grouplist = lock_user(VERIFY_READ, arg2, gidsetsize * 2, 1); if (!target_grouplist) { ret = -TARGET_EFAULT; goto fail; } for(i = 0;i < gidsetsize; i++) grouplist[i] = low2highgid(tswapid(target_grouplist[i])); unlock_user(target_grouplist, arg2, 0); ret = get_errno(setgroups(gidsetsize, grouplist)); } break; case TARGET_NR_fchown: ret = get_errno(fchown(arg1, low2highuid(arg2), low2highgid(arg3))); break; #if defined(TARGET_NR_fchownat) && defined(__NR_fchownat) case TARGET_NR_fchownat: if (!(p = lock_user_string(arg2))) goto efault; ret = get_errno(sys_fchownat(arg1, p, low2highuid(arg3), low2highgid(arg4), arg5)); unlock_user(p, arg2, 0); break; #endif #ifdef TARGET_NR_setresuid case TARGET_NR_setresuid: ret = get_errno(setresuid(low2highuid(arg1), low2highuid(arg2), low2highuid(arg3))); break; #endif #ifdef TARGET_NR_getresuid case TARGET_NR_getresuid: { uid_t ruid, euid, suid; ret = get_errno(getresuid(&ruid, &euid, &suid)); if (!is_error(ret)) { if (put_user_u16(high2lowuid(ruid), arg1) || put_user_u16(high2lowuid(euid), arg2) || put_user_u16(high2lowuid(suid), arg3)) goto efault; } } break; #endif #ifdef TARGET_NR_getresgid case TARGET_NR_setresgid: ret = get_errno(setresgid(low2highgid(arg1), low2highgid(arg2), low2highgid(arg3))); break; #endif #ifdef TARGET_NR_getresgid case TARGET_NR_getresgid: { gid_t rgid, egid, sgid; ret = get_errno(getresgid(&rgid, &egid, &sgid)); if (!is_error(ret)) { if (put_user_u16(high2lowgid(rgid), arg1) || put_user_u16(high2lowgid(egid), arg2) || put_user_u16(high2lowgid(sgid), arg3)) goto efault; } } break; #endif case TARGET_NR_chown: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(chown(p, low2highuid(arg2), low2highgid(arg3))); unlock_user(p, arg1, 0); break; case TARGET_NR_setuid: ret = get_errno(setuid(low2highuid(arg1))); break; case TARGET_NR_setgid: ret = get_errno(setgid(low2highgid(arg1))); break; case TARGET_NR_setfsuid: ret = get_errno(setfsuid(arg1)); break; case TARGET_NR_setfsgid: ret = get_errno(setfsgid(arg1)); break; #ifdef TARGET_NR_lchown32 case TARGET_NR_lchown32: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(lchown(p, arg2, arg3)); unlock_user(p, arg1, 0); break; #endif #ifdef TARGET_NR_getuid32 case TARGET_NR_getuid32: ret = get_errno(getuid()); break; #endif #if defined(TARGET_NR_getxuid) && defined(TARGET_ALPHA) case TARGET_NR_getxuid: { uid_t euid; euid=geteuid(); ((CPUAlphaState *)cpu_env)->ir[IR_A4]=euid; } ret = get_errno(getuid()); break; #endif #if defined(TARGET_NR_getxgid) && defined(TARGET_ALPHA) case TARGET_NR_getxgid: { uid_t egid; egid=getegid(); ((CPUAlphaState *)cpu_env)->ir[IR_A4]=egid; } ret = get_errno(getgid()); break; #endif #if defined(TARGET_NR_osf_getsysinfo) && defined(TARGET_ALPHA) case TARGET_NR_osf_getsysinfo: ret = -TARGET_EOPNOTSUPP; switch (arg1) { case TARGET_GSI_IEEE_FP_CONTROL: { uint64_t swcr, fpcr = cpu_alpha_load_fpcr (cpu_env); swcr = (fpcr >> 35) & SWCR_STATUS_MASK; swcr |= (fpcr >> 36) & SWCR_MAP_DMZ; swcr |= (~fpcr >> 48) & (SWCR_TRAP_ENABLE_INV | SWCR_TRAP_ENABLE_DZE | SWCR_TRAP_ENABLE_OVF); swcr |= (~fpcr >> 57) & (SWCR_TRAP_ENABLE_UNF | SWCR_TRAP_ENABLE_INE); swcr |= (fpcr >> 47) & SWCR_MAP_UMZ; swcr |= (~fpcr >> 41) & SWCR_TRAP_ENABLE_DNO; if (put_user_u64 (swcr, arg2)) goto efault; ret = 0; } break; } break; #endif #if defined(TARGET_NR_osf_setsysinfo) && defined(TARGET_ALPHA) case TARGET_NR_osf_setsysinfo: ret = -TARGET_EOPNOTSUPP; switch (arg1) { case TARGET_SSI_IEEE_FP_CONTROL: { uint64_t swcr, fpcr, orig_fpcr; if (get_user_u64 (swcr, arg2)) { goto efault; } orig_fpcr = cpu_alpha_load_fpcr(cpu_env); fpcr = orig_fpcr & FPCR_DYN_MASK; fpcr |= (swcr & SWCR_STATUS_MASK) << 35; fpcr |= (swcr & SWCR_MAP_DMZ) << 36; fpcr |= (~swcr & (SWCR_TRAP_ENABLE_INV | SWCR_TRAP_ENABLE_DZE | SWCR_TRAP_ENABLE_OVF)) << 48; fpcr |= (~swcr & (SWCR_TRAP_ENABLE_UNF | SWCR_TRAP_ENABLE_INE)) << 57; fpcr |= (swcr & SWCR_MAP_UMZ ? FPCR_UNDZ | FPCR_UNFD : 0); fpcr |= (~swcr & SWCR_TRAP_ENABLE_DNO) << 41; cpu_alpha_store_fpcr(cpu_env, fpcr); ret = 0; } break; case TARGET_SSI_IEEE_RAISE_EXCEPTION: { uint64_t exc, fpcr, orig_fpcr; int si_code; if (get_user_u64(exc, arg2)) { goto efault; } orig_fpcr = cpu_alpha_load_fpcr(cpu_env); fpcr = orig_fpcr | ((exc & SWCR_STATUS_MASK) << 35); cpu_alpha_store_fpcr(cpu_env, fpcr); ret = 0; fpcr &= ~(orig_fpcr & FPCR_STATUS_MASK); si_code = 0; if ((fpcr & (FPCR_INE | FPCR_INED)) == FPCR_INE) { si_code = TARGET_FPE_FLTRES; } if ((fpcr & (FPCR_UNF | FPCR_UNFD)) == FPCR_UNF) { si_code = TARGET_FPE_FLTUND; } if ((fpcr & (FPCR_OVF | FPCR_OVFD)) == FPCR_OVF) { si_code = TARGET_FPE_FLTOVF; } if ((fpcr & (FPCR_DZE | FPCR_DZED)) == FPCR_DZE) { si_code = TARGET_FPE_FLTDIV; } if ((fpcr & (FPCR_INV | FPCR_INVD)) == FPCR_INV) { si_code = TARGET_FPE_FLTINV; } if (si_code != 0) { target_siginfo_t info; info.si_signo = SIGFPE; info.si_errno = 0; info.si_code = si_code; info._sifields._sigfault._addr = ((CPUArchState *)cpu_env)->pc; queue_signal((CPUArchState *)cpu_env, info.si_signo, &info); } } break; } break; #endif #ifdef TARGET_NR_osf_sigprocmask case TARGET_NR_osf_sigprocmask: { abi_ulong mask; int how; sigset_t set, oldset; switch(arg1) { case TARGET_SIG_BLOCK: how = SIG_BLOCK; break; case TARGET_SIG_UNBLOCK: how = SIG_UNBLOCK; break; case TARGET_SIG_SETMASK: how = SIG_SETMASK; break; default: ret = -TARGET_EINVAL; goto fail; } mask = arg2; target_to_host_old_sigset(&set, &mask); sigprocmask(how, &set, &oldset); host_to_target_old_sigset(&mask, &oldset); ret = mask; } break; #endif #ifdef TARGET_NR_getgid32 case TARGET_NR_getgid32: ret = get_errno(getgid()); break; #endif #ifdef TARGET_NR_geteuid32 case TARGET_NR_geteuid32: ret = get_errno(geteuid()); break; #endif #ifdef TARGET_NR_getegid32 case TARGET_NR_getegid32: ret = get_errno(getegid()); break; #endif #ifdef TARGET_NR_setreuid32 case TARGET_NR_setreuid32: ret = get_errno(setreuid(arg1, arg2)); break; #endif #ifdef TARGET_NR_setregid32 case TARGET_NR_setregid32: ret = get_errno(setregid(arg1, arg2)); break; #endif #ifdef TARGET_NR_getgroups32 case TARGET_NR_getgroups32: { int gidsetsize = arg1; uint32_t *target_grouplist; gid_t *grouplist; int i; grouplist = alloca(gidsetsize * sizeof(gid_t)); ret = get_errno(getgroups(gidsetsize, grouplist)); if (gidsetsize == 0) break; if (!is_error(ret)) { target_grouplist = lock_user(VERIFY_WRITE, arg2, gidsetsize * 4, 0); if (!target_grouplist) { ret = -TARGET_EFAULT; goto fail; } for(i = 0;i < ret; i++) target_grouplist[i] = tswap32(grouplist[i]); unlock_user(target_grouplist, arg2, gidsetsize * 4); } } break; #endif #ifdef TARGET_NR_setgroups32 case TARGET_NR_setgroups32: { int gidsetsize = arg1; uint32_t *target_grouplist; gid_t *grouplist; int i; grouplist = alloca(gidsetsize * sizeof(gid_t)); target_grouplist = lock_user(VERIFY_READ, arg2, gidsetsize * 4, 1); if (!target_grouplist) { ret = -TARGET_EFAULT; goto fail; } for(i = 0;i < gidsetsize; i++) grouplist[i] = tswap32(target_grouplist[i]); unlock_user(target_grouplist, arg2, 0); ret = get_errno(setgroups(gidsetsize, grouplist)); } break; #endif #ifdef TARGET_NR_fchown32 case TARGET_NR_fchown32: ret = get_errno(fchown(arg1, arg2, arg3)); break; #endif #ifdef TARGET_NR_setresuid32 case TARGET_NR_setresuid32: ret = get_errno(setresuid(arg1, arg2, arg3)); break; #endif #ifdef TARGET_NR_getresuid32 case TARGET_NR_getresuid32: { uid_t ruid, euid, suid; ret = get_errno(getresuid(&ruid, &euid, &suid)); if (!is_error(ret)) { if (put_user_u32(ruid, arg1) || put_user_u32(euid, arg2) || put_user_u32(suid, arg3)) goto efault; } } break; #endif #ifdef TARGET_NR_setresgid32 case TARGET_NR_setresgid32: ret = get_errno(setresgid(arg1, arg2, arg3)); break; #endif #ifdef TARGET_NR_getresgid32 case TARGET_NR_getresgid32: { gid_t rgid, egid, sgid; ret = get_errno(getresgid(&rgid, &egid, &sgid)); if (!is_error(ret)) { if (put_user_u32(rgid, arg1) || put_user_u32(egid, arg2) || put_user_u32(sgid, arg3)) goto efault; } } break; #endif #ifdef TARGET_NR_chown32 case TARGET_NR_chown32: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(chown(p, arg2, arg3)); unlock_user(p, arg1, 0); break; #endif #ifdef TARGET_NR_setuid32 case TARGET_NR_setuid32: ret = get_errno(setuid(arg1)); break; #endif #ifdef TARGET_NR_setgid32 case TARGET_NR_setgid32: ret = get_errno(setgid(arg1)); break; #endif #ifdef TARGET_NR_setfsuid32 case TARGET_NR_setfsuid32: ret = get_errno(setfsuid(arg1)); break; #endif #ifdef TARGET_NR_setfsgid32 case TARGET_NR_setfsgid32: ret = get_errno(setfsgid(arg1)); break; #endif case TARGET_NR_pivot_root: goto unimplemented; #ifdef TARGET_NR_mincore case TARGET_NR_mincore: { void *a; ret = -TARGET_EFAULT; if (!(a = lock_user(VERIFY_READ, arg1,arg2, 0))) goto efault; if (!(p = lock_user_string(arg3))) goto mincore_fail; ret = get_errno(mincore(a, arg2, p)); unlock_user(p, arg3, ret); mincore_fail: unlock_user(a, arg1, 0); } break; #endif #ifdef TARGET_NR_arm_fadvise64_64 case TARGET_NR_arm_fadvise64_64: { abi_long temp; temp = arg3; arg3 = arg4; arg4 = temp; } #endif #if defined(TARGET_NR_fadvise64_64) || defined(TARGET_NR_arm_fadvise64_64) || defined(TARGET_NR_fadvise64) #ifdef TARGET_NR_fadvise64_64 case TARGET_NR_fadvise64_64: #endif #ifdef TARGET_NR_fadvise64 case TARGET_NR_fadvise64: #endif #ifdef TARGET_S390X switch (arg4) { case 4: arg4 = POSIX_FADV_NOREUSE + 1; break; case 5: arg4 = POSIX_FADV_NOREUSE + 2; break; case 6: arg4 = POSIX_FADV_DONTNEED; break; case 7: arg4 = POSIX_FADV_NOREUSE; break; default: break; } #endif ret = -posix_fadvise(arg1, arg2, arg3, arg4); break; #endif #ifdef TARGET_NR_madvise case TARGET_NR_madvise: ret = get_errno(0); break; #endif #if TARGET_ABI_BITS == 32 case TARGET_NR_fcntl64: { int cmd; struct flock64 fl; struct target_flock64 *target_fl; #ifdef TARGET_ARM struct target_eabi_flock64 *target_efl; #endif cmd = target_to_host_fcntl_cmd(arg2); if (cmd == -TARGET_EINVAL) { ret = cmd; break; } switch(arg2) { case TARGET_F_GETLK64: #ifdef TARGET_ARM if (((CPUARMState *)cpu_env)->eabi) { if (!lock_user_struct(VERIFY_READ, target_efl, arg3, 1)) goto efault; fl.l_type = tswap16(target_efl->l_type); fl.l_whence = tswap16(target_efl->l_whence); fl.l_start = tswap64(target_efl->l_start); fl.l_len = tswap64(target_efl->l_len); fl.l_pid = tswap32(target_efl->l_pid); unlock_user_struct(target_efl, arg3, 0); } else #endif { if (!lock_user_struct(VERIFY_READ, target_fl, arg3, 1)) goto efault; fl.l_type = tswap16(target_fl->l_type); fl.l_whence = tswap16(target_fl->l_whence); fl.l_start = tswap64(target_fl->l_start); fl.l_len = tswap64(target_fl->l_len); fl.l_pid = tswap32(target_fl->l_pid); unlock_user_struct(target_fl, arg3, 0); } ret = get_errno(fcntl(arg1, cmd, &fl)); if (ret == 0) { #ifdef TARGET_ARM if (((CPUARMState *)cpu_env)->eabi) { if (!lock_user_struct(VERIFY_WRITE, target_efl, arg3, 0)) goto efault; target_efl->l_type = tswap16(fl.l_type); target_efl->l_whence = tswap16(fl.l_whence); target_efl->l_start = tswap64(fl.l_start); target_efl->l_len = tswap64(fl.l_len); target_efl->l_pid = tswap32(fl.l_pid); unlock_user_struct(target_efl, arg3, 1); } else #endif { if (!lock_user_struct(VERIFY_WRITE, target_fl, arg3, 0)) goto efault; target_fl->l_type = tswap16(fl.l_type); target_fl->l_whence = tswap16(fl.l_whence); target_fl->l_start = tswap64(fl.l_start); target_fl->l_len = tswap64(fl.l_len); target_fl->l_pid = tswap32(fl.l_pid); unlock_user_struct(target_fl, arg3, 1); } } break; case TARGET_F_SETLK64: case TARGET_F_SETLKW64: #ifdef TARGET_ARM if (((CPUARMState *)cpu_env)->eabi) { if (!lock_user_struct(VERIFY_READ, target_efl, arg3, 1)) goto efault; fl.l_type = tswap16(target_efl->l_type); fl.l_whence = tswap16(target_efl->l_whence); fl.l_start = tswap64(target_efl->l_start); fl.l_len = tswap64(target_efl->l_len); fl.l_pid = tswap32(target_efl->l_pid); unlock_user_struct(target_efl, arg3, 0); } else #endif { if (!lock_user_struct(VERIFY_READ, target_fl, arg3, 1)) goto efault; fl.l_type = tswap16(target_fl->l_type); fl.l_whence = tswap16(target_fl->l_whence); fl.l_start = tswap64(target_fl->l_start); fl.l_len = tswap64(target_fl->l_len); fl.l_pid = tswap32(target_fl->l_pid); unlock_user_struct(target_fl, arg3, 0); } ret = get_errno(fcntl(arg1, cmd, &fl)); break; default: ret = do_fcntl(arg1, arg2, arg3); break; } break; } #endif #ifdef TARGET_NR_cacheflush case TARGET_NR_cacheflush: ret = 0; break; #endif #ifdef TARGET_NR_security case TARGET_NR_security: goto unimplemented; #endif #ifdef TARGET_NR_getpagesize case TARGET_NR_getpagesize: ret = TARGET_PAGE_SIZE; break; #endif case TARGET_NR_gettid: ret = get_errno(gettid()); break; #ifdef TARGET_NR_readahead case TARGET_NR_readahead: #if TARGET_ABI_BITS == 32 if (regpairs_aligned(cpu_env)) { arg2 = arg3; arg3 = arg4; arg4 = arg5; } ret = get_errno(readahead(arg1, ((off64_t)arg3 << 32) | arg2, arg4)); #else ret = get_errno(readahead(arg1, arg2, arg3)); #endif break; #endif #ifdef CONFIG_ATTR #ifdef TARGET_NR_setxattr case TARGET_NR_listxattr: case TARGET_NR_llistxattr: { void *p, *b = 0; if (arg2) { b = lock_user(VERIFY_WRITE, arg2, arg3, 0); if (!b) { ret = -TARGET_EFAULT; break; } } p = lock_user_string(arg1); if (p) { if (num == TARGET_NR_listxattr) { ret = get_errno(listxattr(p, b, arg3)); } else { ret = get_errno(llistxattr(p, b, arg3)); } } else { ret = -TARGET_EFAULT; } unlock_user(p, arg1, 0); unlock_user(b, arg2, arg3); break; } case TARGET_NR_flistxattr: { void *b = 0; if (arg2) { b = lock_user(VERIFY_WRITE, arg2, arg3, 0); if (!b) { ret = -TARGET_EFAULT; break; } } ret = get_errno(flistxattr(arg1, b, arg3)); unlock_user(b, arg2, arg3); break; } case TARGET_NR_setxattr: case TARGET_NR_lsetxattr: { void *p, *n, *v = 0; if (arg3) { v = lock_user(VERIFY_READ, arg3, arg4, 1); if (!v) { ret = -TARGET_EFAULT; break; } } p = lock_user_string(arg1); n = lock_user_string(arg2); if (p && n) { if (num == TARGET_NR_setxattr) { ret = get_errno(setxattr(p, n, v, arg4, arg5)); } else { ret = get_errno(lsetxattr(p, n, v, arg4, arg5)); } } else { ret = -TARGET_EFAULT; } unlock_user(p, arg1, 0); unlock_user(n, arg2, 0); unlock_user(v, arg3, 0); } break; case TARGET_NR_fsetxattr: { void *n, *v = 0; if (arg3) { v = lock_user(VERIFY_READ, arg3, arg4, 1); if (!v) { ret = -TARGET_EFAULT; break; } } n = lock_user_string(arg2); if (n) { ret = get_errno(fsetxattr(arg1, n, v, arg4, arg5)); } else { ret = -TARGET_EFAULT; } unlock_user(n, arg2, 0); unlock_user(v, arg3, 0); } break; case TARGET_NR_getxattr: case TARGET_NR_lgetxattr: { void *p, *n, *v = 0; if (arg3) { v = lock_user(VERIFY_WRITE, arg3, arg4, 0); if (!v) { ret = -TARGET_EFAULT; break; } } p = lock_user_string(arg1); n = lock_user_string(arg2); if (p && n) { if (num == TARGET_NR_getxattr) { ret = get_errno(getxattr(p, n, v, arg4)); } else { ret = get_errno(lgetxattr(p, n, v, arg4)); } } else { ret = -TARGET_EFAULT; } unlock_user(p, arg1, 0); unlock_user(n, arg2, 0); unlock_user(v, arg3, arg4); } break; case TARGET_NR_fgetxattr: { void *n, *v = 0; if (arg3) { v = lock_user(VERIFY_WRITE, arg3, arg4, 0); if (!v) { ret = -TARGET_EFAULT; break; } } n = lock_user_string(arg2); if (n) { ret = get_errno(fgetxattr(arg1, n, v, arg4)); } else { ret = -TARGET_EFAULT; } unlock_user(n, arg2, 0); unlock_user(v, arg3, arg4); } break; case TARGET_NR_removexattr: case TARGET_NR_lremovexattr: { void *p, *n; p = lock_user_string(arg1); n = lock_user_string(arg2); if (p && n) { if (num == TARGET_NR_removexattr) { ret = get_errno(removexattr(p, n)); } else { ret = get_errno(lremovexattr(p, n)); } } else { ret = -TARGET_EFAULT; } unlock_user(p, arg1, 0); unlock_user(n, arg2, 0); } break; case TARGET_NR_fremovexattr: { void *n; n = lock_user_string(arg2); if (n) { ret = get_errno(fremovexattr(arg1, n)); } else { ret = -TARGET_EFAULT; } unlock_user(n, arg2, 0); } break; #endif #endif #ifdef TARGET_NR_set_thread_area case TARGET_NR_set_thread_area: #if defined(TARGET_MIPS) ((CPUMIPSState *) cpu_env)->tls_value = arg1; ret = 0; break; #elif defined(TARGET_CRIS) if (arg1 & 0xff) ret = -TARGET_EINVAL; else { ((CPUCRISState *) cpu_env)->pregs[PR_PID] = arg1; ret = 0; } break; #elif defined(TARGET_I386) && defined(TARGET_ABI32) ret = do_set_thread_area(cpu_env, arg1); break; #else goto unimplemented_nowarn; #endif #endif #ifdef TARGET_NR_get_thread_area case TARGET_NR_get_thread_area: #if defined(TARGET_I386) && defined(TARGET_ABI32) ret = do_get_thread_area(cpu_env, arg1); #else goto unimplemented_nowarn; #endif #endif #ifdef TARGET_NR_getdomainname case TARGET_NR_getdomainname: goto unimplemented_nowarn; #endif #ifdef TARGET_NR_clock_gettime case TARGET_NR_clock_gettime: { struct timespec ts; ret = get_errno(clock_gettime(arg1, &ts)); if (!is_error(ret)) { host_to_target_timespec(arg2, &ts); } break; } #endif #ifdef TARGET_NR_clock_getres case TARGET_NR_clock_getres: { struct timespec ts; ret = get_errno(clock_getres(arg1, &ts)); if (!is_error(ret)) { host_to_target_timespec(arg2, &ts); } break; } #endif #ifdef TARGET_NR_clock_nanosleep case TARGET_NR_clock_nanosleep: { struct timespec ts; target_to_host_timespec(&ts, arg3); ret = get_errno(clock_nanosleep(arg1, arg2, &ts, arg4 ? &ts : NULL)); if (arg4) host_to_target_timespec(arg4, &ts); break; } #endif #if defined(TARGET_NR_set_tid_address) && defined(__NR_set_tid_address) case TARGET_NR_set_tid_address: ret = get_errno(set_tid_address((int *)g2h(arg1))); break; #endif #if defined(TARGET_NR_tkill) && defined(__NR_tkill) case TARGET_NR_tkill: ret = get_errno(sys_tkill((int)arg1, target_to_host_signal(arg2))); break; #endif #if defined(TARGET_NR_tgkill) && defined(__NR_tgkill) case TARGET_NR_tgkill: ret = get_errno(sys_tgkill((int)arg1, (int)arg2, target_to_host_signal(arg3))); break; #endif #ifdef TARGET_NR_set_robust_list case TARGET_NR_set_robust_list: goto unimplemented_nowarn; #endif #if defined(TARGET_NR_utimensat) && defined(__NR_utimensat) case TARGET_NR_utimensat: { struct timespec *tsp, ts[2]; if (!arg3) { tsp = NULL; } else { target_to_host_timespec(ts, arg3); target_to_host_timespec(ts+1, arg3+sizeof(struct target_timespec)); tsp = ts; } if (!arg2) ret = get_errno(sys_utimensat(arg1, NULL, tsp, arg4)); else { if (!(p = lock_user_string(arg2))) { ret = -TARGET_EFAULT; goto fail; } ret = get_errno(sys_utimensat(arg1, path(p), tsp, arg4)); unlock_user(p, arg2, 0); } } break; #endif #if defined(CONFIG_USE_NPTL) case TARGET_NR_futex: ret = do_futex(arg1, arg2, arg3, arg4, arg5, arg6); break; #endif #if defined(TARGET_NR_inotify_init) && defined(__NR_inotify_init) case TARGET_NR_inotify_init: ret = get_errno(sys_inotify_init()); break; #endif #ifdef CONFIG_INOTIFY1 #if defined(TARGET_NR_inotify_init1) && defined(__NR_inotify_init1) case TARGET_NR_inotify_init1: ret = get_errno(sys_inotify_init1(arg1)); break; #endif #endif #if defined(TARGET_NR_inotify_add_watch) && defined(__NR_inotify_add_watch) case TARGET_NR_inotify_add_watch: p = lock_user_string(arg2); ret = get_errno(sys_inotify_add_watch(arg1, path(p), arg3)); unlock_user(p, arg2, 0); break; #endif #if defined(TARGET_NR_inotify_rm_watch) && defined(__NR_inotify_rm_watch) case TARGET_NR_inotify_rm_watch: ret = get_errno(sys_inotify_rm_watch(arg1, arg2)); break; #endif #if defined(TARGET_NR_mq_open) && defined(__NR_mq_open) case TARGET_NR_mq_open: { struct mq_attr posix_mq_attr; p = lock_user_string(arg1 - 1); if (arg4 != 0) copy_from_user_mq_attr (&posix_mq_attr, arg4); ret = get_errno(mq_open(p, arg2, arg3, &posix_mq_attr)); unlock_user (p, arg1, 0); } break; case TARGET_NR_mq_unlink: p = lock_user_string(arg1 - 1); ret = get_errno(mq_unlink(p)); unlock_user (p, arg1, 0); break; case TARGET_NR_mq_timedsend: { struct timespec ts; p = lock_user (VERIFY_READ, arg2, arg3, 1); if (arg5 != 0) { target_to_host_timespec(&ts, arg5); ret = get_errno(mq_timedsend(arg1, p, arg3, arg4, &ts)); host_to_target_timespec(arg5, &ts); } else ret = get_errno(mq_send(arg1, p, arg3, arg4)); unlock_user (p, arg2, arg3); } break; case TARGET_NR_mq_timedreceive: { struct timespec ts; unsigned int prio; p = lock_user (VERIFY_READ, arg2, arg3, 1); if (arg5 != 0) { target_to_host_timespec(&ts, arg5); ret = get_errno(mq_timedreceive(arg1, p, arg3, &prio, &ts)); host_to_target_timespec(arg5, &ts); } else ret = get_errno(mq_receive(arg1, p, arg3, &prio)); unlock_user (p, arg2, arg3); if (arg4 != 0) put_user_u32(prio, arg4); } break; case TARGET_NR_mq_getsetattr: { struct mq_attr posix_mq_attr_in, posix_mq_attr_out; ret = 0; if (arg3 != 0) { ret = mq_getattr(arg1, &posix_mq_attr_out); copy_to_user_mq_attr(arg3, &posix_mq_attr_out); } if (arg2 != 0) { copy_from_user_mq_attr(&posix_mq_attr_in, arg2); ret |= mq_setattr(arg1, &posix_mq_attr_in, &posix_mq_attr_out); } } break; #endif #ifdef CONFIG_SPLICE #ifdef TARGET_NR_tee case TARGET_NR_tee: { ret = get_errno(tee(arg1,arg2,arg3,arg4)); } break; #endif #ifdef TARGET_NR_splice case TARGET_NR_splice: { loff_t loff_in, loff_out; loff_t *ploff_in = NULL, *ploff_out = NULL; if(arg2) { get_user_u64(loff_in, arg2); ploff_in = &loff_in; } if(arg4) { get_user_u64(loff_out, arg2); ploff_out = &loff_out; } ret = get_errno(splice(arg1, ploff_in, arg3, ploff_out, arg5, arg6)); } break; #endif #ifdef TARGET_NR_vmsplice case TARGET_NR_vmsplice: { int count = arg3; struct iovec *vec; vec = alloca(count * sizeof(struct iovec)); if (lock_iovec(VERIFY_READ, vec, arg2, count, 1) < 0) goto efault; ret = get_errno(vmsplice(arg1, vec, count, arg4)); unlock_iovec(vec, arg2, count, 0); } break; #endif #endif #ifdef CONFIG_EVENTFD #if defined(TARGET_NR_eventfd) case TARGET_NR_eventfd: ret = get_errno(eventfd(arg1, 0)); break; #endif #if defined(TARGET_NR_eventfd2) case TARGET_NR_eventfd2: ret = get_errno(eventfd(arg1, arg2)); break; #endif #endif #if defined(CONFIG_FALLOCATE) && defined(TARGET_NR_fallocate) case TARGET_NR_fallocate: #if TARGET_ABI_BITS == 32 ret = get_errno(fallocate(arg1, arg2, target_offset64(arg3, arg4), target_offset64(arg5, arg6))); #else ret = get_errno(fallocate(arg1, arg2, arg3, arg4)); #endif break; #endif #if defined(CONFIG_SYNC_FILE_RANGE) #if defined(TARGET_NR_sync_file_range) case TARGET_NR_sync_file_range: #if TARGET_ABI_BITS == 32 #if defined(TARGET_MIPS) ret = get_errno(sync_file_range(arg1, target_offset64(arg3, arg4), target_offset64(arg5, arg6), arg7)); #else ret = get_errno(sync_file_range(arg1, target_offset64(arg2, arg3), target_offset64(arg4, arg5), arg6)); #endif #else ret = get_errno(sync_file_range(arg1, arg2, arg3, arg4)); #endif break; #endif #if defined(TARGET_NR_sync_file_range2) case TARGET_NR_sync_file_range2: #if TARGET_ABI_BITS == 32 ret = get_errno(sync_file_range(arg1, target_offset64(arg3, arg4), target_offset64(arg5, arg6), arg2)); #else ret = get_errno(sync_file_range(arg1, arg3, arg4, arg2)); #endif break; #endif #endif #if defined(CONFIG_EPOLL) #if defined(TARGET_NR_epoll_create) case TARGET_NR_epoll_create: ret = get_errno(epoll_create(arg1)); break; #endif #if defined(TARGET_NR_epoll_create1) && defined(CONFIG_EPOLL_CREATE1) case TARGET_NR_epoll_create1: ret = get_errno(epoll_create1(arg1)); break; #endif #if defined(TARGET_NR_epoll_ctl) case TARGET_NR_epoll_ctl: { struct epoll_event ep; struct epoll_event *epp = 0; if (arg4) { struct target_epoll_event *target_ep; if (!lock_user_struct(VERIFY_READ, target_ep, arg4, 1)) { goto efault; } ep.events = tswap32(target_ep->events); ep.data.u64 = tswap64(target_ep->data.u64); unlock_user_struct(target_ep, arg4, 0); epp = &ep; } ret = get_errno(epoll_ctl(arg1, arg2, arg3, epp)); break; } #endif #if defined(TARGET_NR_epoll_pwait) && defined(CONFIG_EPOLL_PWAIT) #define IMPLEMENT_EPOLL_PWAIT #endif #if defined(TARGET_NR_epoll_wait) || defined(IMPLEMENT_EPOLL_PWAIT) #if defined(TARGET_NR_epoll_wait) case TARGET_NR_epoll_wait: #endif #if defined(IMPLEMENT_EPOLL_PWAIT) case TARGET_NR_epoll_pwait: #endif { struct target_epoll_event *target_ep; struct epoll_event *ep; int epfd = arg1; int maxevents = arg3; int timeout = arg4; target_ep = lock_user(VERIFY_WRITE, arg2, maxevents * sizeof(struct target_epoll_event), 1); if (!target_ep) { goto efault; } ep = alloca(maxevents * sizeof(struct epoll_event)); switch (num) { #if defined(IMPLEMENT_EPOLL_PWAIT) case TARGET_NR_epoll_pwait: { target_sigset_t *target_set; sigset_t _set, *set = &_set; if (arg5) { target_set = lock_user(VERIFY_READ, arg5, sizeof(target_sigset_t), 1); if (!target_set) { unlock_user(target_ep, arg2, 0); goto efault; } target_to_host_sigset(set, target_set); unlock_user(target_set, arg5, 0); } else { set = NULL; } ret = get_errno(epoll_pwait(epfd, ep, maxevents, timeout, set)); break; } #endif #if defined(TARGET_NR_epoll_wait) case TARGET_NR_epoll_wait: ret = get_errno(epoll_wait(epfd, ep, maxevents, timeout)); break; #endif default: ret = -TARGET_ENOSYS; } if (!is_error(ret)) { int i; for (i = 0; i < ret; i++) { target_ep[i].events = tswap32(ep[i].events); target_ep[i].data.u64 = tswap64(ep[i].data.u64); } } unlock_user(target_ep, arg2, ret * sizeof(struct target_epoll_event)); break; } #endif #endif #ifdef TARGET_NR_prlimit64 case TARGET_NR_prlimit64: { struct target_rlimit64 *target_rnew, *target_rold; struct host_rlimit64 rnew, rold, *rnewp = 0; if (arg3) { if (!lock_user_struct(VERIFY_READ, target_rnew, arg3, 1)) { goto efault; } rnew.rlim_cur = tswap64(target_rnew->rlim_cur); rnew.rlim_max = tswap64(target_rnew->rlim_max); unlock_user_struct(target_rnew, arg3, 0); rnewp = &rnew; } ret = get_errno(sys_prlimit64(arg1, arg2, rnewp, arg4 ? &rold : 0)); if (!is_error(ret) && arg4) { if (!lock_user_struct(VERIFY_WRITE, target_rold, arg4, 1)) { goto efault; } target_rold->rlim_cur = tswap64(rold.rlim_cur); target_rold->rlim_max = tswap64(rold.rlim_max); unlock_user_struct(target_rold, arg4, 1); } break; } #endif default: unimplemented: gemu_log("qemu: Unsupported syscall: %d\n", num); #if defined(TARGET_NR_setxattr) || defined(TARGET_NR_get_thread_area) || defined(TARGET_NR_getdomainname) || defined(TARGET_NR_set_robust_list) unimplemented_nowarn: #endif ret = -TARGET_ENOSYS; break; } fail: #ifdef DEBUG gemu_log(" = " TARGET_ABI_FMT_ld "\n", ret); #endif if(do_strace) print_syscall_ret(num, ret); return ret; efault: ret = -TARGET_EFAULT; goto fail; }
{ "code": [], "line_no": [] }
abi_long FUNC_0(void *cpu_env, int num, abi_long arg1, abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6, abi_long arg7, abi_long arg8) { abi_long ret; struct stat VAR_0; struct statfs VAR_1; void *VAR_2; #ifdef DEBUG gemu_log("syscall %d", num); #endif if(do_strace) print_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6); switch(num) { case TARGET_NR_exit: #ifdef CONFIG_USE_NPTL if (first_cpu->next_cpu) { TaskState *VAR_45; CPUArchState **lastp; CPUArchState *VAR_2; cpu_list_lock(); lastp = &first_cpu; VAR_2 = first_cpu; while (VAR_2 && VAR_2 != (CPUArchState *)cpu_env) { lastp = &VAR_2->next_cpu; VAR_2 = VAR_2->next_cpu; } if (!VAR_2) abort(); *lastp = VAR_2->next_cpu; cpu_list_unlock(); VAR_45 = ((CPUArchState *)cpu_env)->opaque; if (VAR_45->child_tidptr) { put_user_u32(0, VAR_45->child_tidptr); sys_futex(g2h(VAR_45->child_tidptr), FUTEX_WAKE, INT_MAX, NULL, NULL, 0); } thread_env = NULL; object_delete(OBJECT(ENV_GET_CPU(cpu_env))); g_free(VAR_45); pthread_exit(NULL); } #endif #ifdef TARGET_GPROF _mcleanup(); #endif gdb_exit(cpu_env, arg1); _exit(arg1); ret = 0; break; case TARGET_NR_read: if (arg3 == 0) ret = 0; else { if (!(VAR_2 = lock_user(VERIFY_WRITE, arg2, arg3, 0))) goto efault; ret = get_errno(read(arg1, VAR_2, arg3)); unlock_user(VAR_2, arg2, ret); } break; case TARGET_NR_write: if (!(VAR_2 = lock_user(VERIFY_READ, arg2, arg3, 1))) goto efault; ret = get_errno(write(arg1, VAR_2, arg3)); unlock_user(VAR_2, arg2, 0); break; case TARGET_NR_open: if (!(VAR_2 = lock_user_string(arg1))) goto efault; ret = get_errno(do_open(cpu_env, VAR_2, target_to_host_bitmask(arg2, fcntl_flags_tbl), arg3)); unlock_user(VAR_2, arg1, 0); break; #if defined(TARGET_NR_openat) && defined(__NR_openat) case TARGET_NR_openat: if (!(VAR_2 = lock_user_string(arg2))) goto efault; ret = get_errno(sys_openat(arg1, path(VAR_2), target_to_host_bitmask(arg3, fcntl_flags_tbl), arg4)); unlock_user(VAR_2, arg2, 0); break; #endif case TARGET_NR_close: ret = get_errno(close(arg1)); break; case TARGET_NR_brk: ret = do_brk(arg1); break; case TARGET_NR_fork: ret = get_errno(do_fork(cpu_env, SIGCHLD, 0, 0, 0, 0)); break; #ifdef TARGET_NR_waitpid case TARGET_NR_waitpid: { int VAR_31; ret = get_errno(waitpid(arg1, &VAR_31, arg3)); if (!is_error(ret) && arg2 && ret && put_user_s32(host_to_target_waitstatus(VAR_31), arg2)) goto efault; } break; #endif #ifdef TARGET_NR_waitid case TARGET_NR_waitid: { siginfo_t info; info.si_pid = 0; ret = get_errno(waitid(arg1, arg2, &info, arg4)); if (!is_error(ret) && arg3 && info.si_pid != 0) { if (!(VAR_2 = lock_user(VERIFY_WRITE, arg3, sizeof(target_siginfo_t), 0))) goto efault; host_to_target_siginfo(VAR_2, &info); unlock_user(VAR_2, arg3, sizeof(target_siginfo_t)); } } break; #endif #ifdef TARGET_NR_creat case TARGET_NR_creat: if (!(VAR_2 = lock_user_string(arg1))) goto efault; ret = get_errno(creat(VAR_2, arg2)); unlock_user(VAR_2, arg1, 0); break; #endif case TARGET_NR_link: { void * VAR_24; VAR_2 = lock_user_string(arg1); VAR_24 = lock_user_string(arg2); if (!VAR_2 || !VAR_24) ret = -TARGET_EFAULT; else ret = get_errno(link(VAR_2, VAR_24)); unlock_user(VAR_24, arg2, 0); unlock_user(VAR_2, arg1, 0); } break; #if defined(TARGET_NR_linkat) && defined(__NR_linkat) case TARGET_NR_linkat: { void * VAR_24 = NULL; if (!arg2 || !arg4) goto efault; VAR_2 = lock_user_string(arg2); VAR_24 = lock_user_string(arg4); if (!VAR_2 || !VAR_24) ret = -TARGET_EFAULT; else ret = get_errno(sys_linkat(arg1, VAR_2, arg3, VAR_24, arg5)); unlock_user(VAR_2, arg2, 0); unlock_user(VAR_24, arg4, 0); } break; #endif case TARGET_NR_unlink: if (!(VAR_2 = lock_user_string(arg1))) goto efault; ret = get_errno(unlink(VAR_2)); unlock_user(VAR_2, arg1, 0); break; #if defined(TARGET_NR_unlinkat) && defined(__NR_unlinkat) case TARGET_NR_unlinkat: if (!(VAR_2 = lock_user_string(arg2))) goto efault; ret = get_errno(sys_unlinkat(arg1, VAR_2, arg3)); unlock_user(VAR_2, arg2, 0); break; #endif case TARGET_NR_execve: { char **VAR_4, **VAR_5; int VAR_6, VAR_7; abi_ulong gp; abi_ulong guest_argp; abi_ulong guest_envp; abi_ulong addr; char **VAR_8; int VAR_9 = 0; VAR_6 = 0; guest_argp = arg2; for (gp = guest_argp; gp; gp += sizeof(abi_ulong)) { if (get_user_ual(addr, gp)) goto efault; if (!addr) break; VAR_6++; } VAR_7 = 0; guest_envp = arg3; for (gp = guest_envp; gp; gp += sizeof(abi_ulong)) { if (get_user_ual(addr, gp)) goto efault; if (!addr) break; VAR_7++; } VAR_4 = alloca((VAR_6 + 1) * sizeof(void *)); VAR_5 = alloca((VAR_7 + 1) * sizeof(void *)); for (gp = guest_argp, VAR_8 = VAR_4; gp; gp += sizeof(abi_ulong), VAR_8++) { if (get_user_ual(addr, gp)) goto execve_efault; if (!addr) break; if (!(*VAR_8 = lock_user_string(addr))) goto execve_efault; VAR_9 += strlen(*VAR_8) + 1; } *VAR_8 = NULL; for (gp = guest_envp, VAR_8 = VAR_5; gp; gp += sizeof(abi_ulong), VAR_8++) { if (get_user_ual(addr, gp)) goto execve_efault; if (!addr) break; if (!(*VAR_8 = lock_user_string(addr))) goto execve_efault; VAR_9 += strlen(*VAR_8) + 1; } *VAR_8 = NULL; if (VAR_9 > MAX_ARG_PAGES * TARGET_PAGE_SIZE) { ret = -TARGET_E2BIG; goto execve_end; } if (!(VAR_2 = lock_user_string(arg1))) goto execve_efault; ret = get_errno(execve(VAR_2, VAR_4, VAR_5)); unlock_user(VAR_2, arg1, 0); goto execve_end; execve_efault: ret = -TARGET_EFAULT; execve_end: for (gp = guest_argp, VAR_8 = VAR_4; *VAR_8; gp += sizeof(abi_ulong), VAR_8++) { if (get_user_ual(addr, gp) || !addr) break; unlock_user(*VAR_8, addr, 0); } for (gp = guest_envp, VAR_8 = VAR_5; *VAR_8; gp += sizeof(abi_ulong), VAR_8++) { if (get_user_ual(addr, gp) || !addr) break; unlock_user(*VAR_8, addr, 0); } } break; case TARGET_NR_chdir: if (!(VAR_2 = lock_user_string(arg1))) goto efault; ret = get_errno(chdir(VAR_2)); unlock_user(VAR_2, arg1, 0); break; #ifdef TARGET_NR_time case TARGET_NR_time: { time_t host_time; ret = get_errno(time(&host_time)); if (!is_error(ret) && arg1 && put_user_sal(host_time, arg1)) goto efault; } break; #endif case TARGET_NR_mknod: if (!(VAR_2 = lock_user_string(arg1))) goto efault; ret = get_errno(mknod(VAR_2, arg2, arg3)); unlock_user(VAR_2, arg1, 0); break; #if defined(TARGET_NR_mknodat) && defined(__NR_mknodat) case TARGET_NR_mknodat: if (!(VAR_2 = lock_user_string(arg2))) goto efault; ret = get_errno(sys_mknodat(arg1, VAR_2, arg3, arg4)); unlock_user(VAR_2, arg2, 0); break; #endif case TARGET_NR_chmod: if (!(VAR_2 = lock_user_string(arg1))) goto efault; ret = get_errno(chmod(VAR_2, arg2)); unlock_user(VAR_2, arg1, 0); break; #ifdef TARGET_NR_break case TARGET_NR_break: goto unimplemented; #endif #ifdef TARGET_NR_oldstat case TARGET_NR_oldstat: goto unimplemented; #endif case TARGET_NR_lseek: ret = get_errno(lseek(arg1, arg2, arg3)); break; #if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA) case TARGET_NR_getxpid: ((CPUAlphaState *)cpu_env)->ir[IR_A4] = getppid(); ret = get_errno(getpid()); break; #endif #ifdef TARGET_NR_getpid case TARGET_NR_getpid: ret = get_errno(getpid()); break; #endif case TARGET_NR_mount: { void *VAR_24, *VAR_10; VAR_2 = lock_user_string(arg1); VAR_24 = lock_user_string(arg2); VAR_10 = lock_user_string(arg3); if (!VAR_2 || !VAR_24 || !VAR_10) ret = -TARGET_EFAULT; else { if ( ! arg5 ) ret = get_errno(mount(VAR_2, VAR_24, VAR_10, (unsigned long)arg4, NULL)); else ret = get_errno(mount(VAR_2, VAR_24, VAR_10, (unsigned long)arg4, g2h(arg5))); } unlock_user(VAR_2, arg1, 0); unlock_user(VAR_24, arg2, 0); unlock_user(VAR_10, arg3, 0); break; } #ifdef TARGET_NR_umount case TARGET_NR_umount: if (!(VAR_2 = lock_user_string(arg1))) goto efault; ret = get_errno(umount(VAR_2)); unlock_user(VAR_2, arg1, 0); break; #endif #ifdef TARGET_NR_stime case TARGET_NR_stime: { time_t host_time; if (get_user_sal(host_time, arg1)) goto efault; ret = get_errno(stime(&host_time)); } break; #endif case TARGET_NR_ptrace: goto unimplemented; #ifdef TARGET_NR_alarm case TARGET_NR_alarm: ret = alarm(arg1); break; #endif #ifdef TARGET_NR_oldfstat case TARGET_NR_oldfstat: goto unimplemented; #endif #ifdef TARGET_NR_pause case TARGET_NR_pause: ret = get_errno(pause()); break; #endif #ifdef TARGET_NR_utime case TARGET_NR_utime: { struct utimbuf tbuf, *host_tbuf; struct target_utimbuf *target_tbuf; if (arg2) { if (!lock_user_struct(VERIFY_READ, target_tbuf, arg2, 1)) goto efault; tbuf.actime = tswapal(target_tbuf->actime); tbuf.modtime = tswapal(target_tbuf->modtime); unlock_user_struct(target_tbuf, arg2, 0); host_tbuf = &tbuf; } else { host_tbuf = NULL; } if (!(VAR_2 = lock_user_string(arg1))) goto efault; ret = get_errno(utime(VAR_2, host_tbuf)); unlock_user(VAR_2, arg1, 0); } break; #endif case TARGET_NR_utimes: { struct timeval *VAR_11, VAR_24[2]; if (arg2) { if (copy_from_user_timeval(&VAR_24[0], arg2) || copy_from_user_timeval(&VAR_24[1], arg2 + sizeof(struct target_timeval))) goto efault; VAR_11 = VAR_24; } else { VAR_11 = NULL; } if (!(VAR_2 = lock_user_string(arg1))) goto efault; ret = get_errno(utimes(VAR_2, VAR_11)); unlock_user(VAR_2, arg1, 0); } break; #if defined(TARGET_NR_futimesat) && defined(__NR_futimesat) case TARGET_NR_futimesat: { struct timeval *VAR_11, VAR_24[2]; if (arg3) { if (copy_from_user_timeval(&VAR_24[0], arg3) || copy_from_user_timeval(&VAR_24[1], arg3 + sizeof(struct target_timeval))) goto efault; VAR_11 = VAR_24; } else { VAR_11 = NULL; } if (!(VAR_2 = lock_user_string(arg2))) goto efault; ret = get_errno(sys_futimesat(arg1, path(VAR_2), VAR_11)); unlock_user(VAR_2, arg2, 0); } break; #endif #ifdef TARGET_NR_stty case TARGET_NR_stty: goto unimplemented; #endif #ifdef TARGET_NR_gtty case TARGET_NR_gtty: goto unimplemented; #endif case TARGET_NR_access: if (!(VAR_2 = lock_user_string(arg1))) goto efault; ret = get_errno(access(path(VAR_2), arg2)); unlock_user(VAR_2, arg1, 0); break; #if defined(TARGET_NR_faccessat) && defined(__NR_faccessat) case TARGET_NR_faccessat: if (!(VAR_2 = lock_user_string(arg2))) goto efault; ret = get_errno(sys_faccessat(arg1, VAR_2, arg3)); unlock_user(VAR_2, arg2, 0); break; #endif #ifdef TARGET_NR_nice case TARGET_NR_nice: ret = get_errno(nice(arg1)); break; #endif #ifdef TARGET_NR_ftime case TARGET_NR_ftime: goto unimplemented; #endif case TARGET_NR_sync: sync(); ret = 0; break; case TARGET_NR_kill: ret = get_errno(kill(arg1, target_to_host_signal(arg2))); break; case TARGET_NR_rename: { void *VAR_24; VAR_2 = lock_user_string(arg1); VAR_24 = lock_user_string(arg2); if (!VAR_2 || !VAR_24) ret = -TARGET_EFAULT; else ret = get_errno(rename(VAR_2, VAR_24)); unlock_user(VAR_24, arg2, 0); unlock_user(VAR_2, arg1, 0); } break; #if defined(TARGET_NR_renameat) && defined(__NR_renameat) case TARGET_NR_renameat: { void *VAR_24; VAR_2 = lock_user_string(arg2); VAR_24 = lock_user_string(arg4); if (!VAR_2 || !VAR_24) ret = -TARGET_EFAULT; else ret = get_errno(sys_renameat(arg1, VAR_2, arg3, VAR_24)); unlock_user(VAR_24, arg4, 0); unlock_user(VAR_2, arg2, 0); } break; #endif case TARGET_NR_mkdir: if (!(VAR_2 = lock_user_string(arg1))) goto efault; ret = get_errno(mkdir(VAR_2, arg2)); unlock_user(VAR_2, arg1, 0); break; #if defined(TARGET_NR_mkdirat) && defined(__NR_mkdirat) case TARGET_NR_mkdirat: if (!(VAR_2 = lock_user_string(arg2))) goto efault; ret = get_errno(sys_mkdirat(arg1, VAR_2, arg3)); unlock_user(VAR_2, arg2, 0); break; #endif case TARGET_NR_rmdir: if (!(VAR_2 = lock_user_string(arg1))) goto efault; ret = get_errno(rmdir(VAR_2)); unlock_user(VAR_2, arg1, 0); break; case TARGET_NR_dup: ret = get_errno(dup(arg1)); break; case TARGET_NR_pipe: ret = do_pipe(cpu_env, arg1, 0, 0); break; #ifdef TARGET_NR_pipe2 case TARGET_NR_pipe2: ret = do_pipe(cpu_env, arg1, target_to_host_bitmask(arg2, fcntl_flags_tbl), 1); break; #endif case TARGET_NR_times: { struct target_tms *VAR_13; struct VAR_14 VAR_14; ret = get_errno(times(&VAR_14)); if (arg1) { VAR_13 = lock_user(VERIFY_WRITE, arg1, sizeof(struct target_tms), 0); if (!VAR_13) goto efault; VAR_13->tms_utime = tswapal(host_to_target_clock_t(VAR_14.tms_utime)); VAR_13->tms_stime = tswapal(host_to_target_clock_t(VAR_14.tms_stime)); VAR_13->tms_cutime = tswapal(host_to_target_clock_t(VAR_14.tms_cutime)); VAR_13->tms_cstime = tswapal(host_to_target_clock_t(VAR_14.tms_cstime)); } if (!is_error(ret)) ret = host_to_target_clock_t(ret); } break; #ifdef TARGET_NR_prof case TARGET_NR_prof: goto unimplemented; #endif #ifdef TARGET_NR_signal case TARGET_NR_signal: goto unimplemented; #endif case TARGET_NR_acct: if (arg1 == 0) { ret = get_errno(acct(NULL)); } else { if (!(VAR_2 = lock_user_string(arg1))) goto efault; ret = get_errno(acct(path(VAR_2))); unlock_user(VAR_2, arg1, 0); } break; #ifdef TARGET_NR_umount2 case TARGET_NR_umount2: if (!(VAR_2 = lock_user_string(arg1))) goto efault; ret = get_errno(umount2(VAR_2, arg2)); unlock_user(VAR_2, arg1, 0); break; #endif #ifdef TARGET_NR_lock case TARGET_NR_lock: goto unimplemented; #endif case TARGET_NR_ioctl: ret = do_ioctl(arg1, arg2, arg3); break; case TARGET_NR_fcntl: ret = do_fcntl(arg1, arg2, arg3); break; #ifdef TARGET_NR_mpx case TARGET_NR_mpx: goto unimplemented; #endif case TARGET_NR_setpgid: ret = get_errno(setpgid(arg1, arg2)); break; #ifdef TARGET_NR_ulimit case TARGET_NR_ulimit: goto unimplemented; #endif #ifdef TARGET_NR_oldolduname case TARGET_NR_oldolduname: goto unimplemented; #endif case TARGET_NR_umask: ret = get_errno(umask(arg1)); break; case TARGET_NR_chroot: if (!(VAR_2 = lock_user_string(arg1))) goto efault; ret = get_errno(chroot(VAR_2)); unlock_user(VAR_2, arg1, 0); break; case TARGET_NR_ustat: goto unimplemented; case TARGET_NR_dup2: ret = get_errno(dup2(arg1, arg2)); break; #if defined(CONFIG_DUP3) && defined(TARGET_NR_dup3) case TARGET_NR_dup3: ret = get_errno(dup3(arg1, arg2, arg3)); break; #endif #ifdef TARGET_NR_getppid case TARGET_NR_getppid: ret = get_errno(getppid()); break; #endif case TARGET_NR_getpgrp: ret = get_errno(getpgrp()); break; case TARGET_NR_setsid: ret = get_errno(setsid()); break; #ifdef TARGET_NR_sigaction case TARGET_NR_sigaction: { #if defined(TARGET_ALPHA) struct target_sigaction VAR_15, VAR_16, *pact = 0; struct target_old_sigaction *old_act; if (arg2) { if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1)) goto efault; VAR_15._sa_handler = old_act->_sa_handler; target_siginitset(&VAR_15.sa_mask, old_act->sa_mask); VAR_15.sa_flags = old_act->sa_flags; VAR_15.sa_restorer = 0; unlock_user_struct(old_act, arg2, 0); pact = &VAR_15; } ret = get_errno(do_sigaction(arg1, pact, &VAR_16)); if (!is_error(ret) && arg3) { if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0)) goto efault; old_act->_sa_handler = VAR_16._sa_handler; old_act->sa_mask = VAR_16.sa_mask.sig[0]; old_act->sa_flags = VAR_16.sa_flags; unlock_user_struct(old_act, arg3, 1); } #elif defined(TARGET_MIPS) struct target_sigaction VAR_15, VAR_16, *pact, *old_act; if (arg2) { if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1)) goto efault; VAR_15._sa_handler = old_act->_sa_handler; target_siginitset(&VAR_15.sa_mask, old_act->sa_mask.sig[0]); VAR_15.sa_flags = old_act->sa_flags; unlock_user_struct(old_act, arg2, 0); pact = &VAR_15; } else { pact = NULL; } ret = get_errno(do_sigaction(arg1, pact, &VAR_16)); if (!is_error(ret) && arg3) { if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0)) goto efault; old_act->_sa_handler = VAR_16._sa_handler; old_act->sa_flags = VAR_16.sa_flags; old_act->sa_mask.sig[0] = VAR_16.sa_mask.sig[0]; old_act->sa_mask.sig[1] = 0; old_act->sa_mask.sig[2] = 0; old_act->sa_mask.sig[3] = 0; unlock_user_struct(old_act, arg3, 1); } #else struct target_old_sigaction *old_act; struct target_sigaction VAR_15, VAR_16, *pact; if (arg2) { if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1)) goto efault; VAR_15._sa_handler = old_act->_sa_handler; target_siginitset(&VAR_15.sa_mask, old_act->sa_mask); VAR_15.sa_flags = old_act->sa_flags; VAR_15.sa_restorer = old_act->sa_restorer; unlock_user_struct(old_act, arg2, 0); pact = &VAR_15; } else { pact = NULL; } ret = get_errno(do_sigaction(arg1, pact, &VAR_16)); if (!is_error(ret) && arg3) { if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0)) goto efault; old_act->_sa_handler = VAR_16._sa_handler; old_act->sa_mask = VAR_16.sa_mask.sig[0]; old_act->sa_flags = VAR_16.sa_flags; old_act->sa_restorer = VAR_16.sa_restorer; unlock_user_struct(old_act, arg3, 1); } #endif } break; #endif case TARGET_NR_rt_sigaction: { #if defined(TARGET_ALPHA) struct target_sigaction VAR_15, VAR_16, *pact = 0; struct target_rt_sigaction *rt_act; if (arg2) { if (!lock_user_struct(VERIFY_READ, rt_act, arg2, 1)) goto efault; VAR_15._sa_handler = rt_act->_sa_handler; VAR_15.sa_mask = rt_act->sa_mask; VAR_15.sa_flags = rt_act->sa_flags; VAR_15.sa_restorer = arg5; unlock_user_struct(rt_act, arg2, 0); pact = &VAR_15; } ret = get_errno(do_sigaction(arg1, pact, &VAR_16)); if (!is_error(ret) && arg3) { if (!lock_user_struct(VERIFY_WRITE, rt_act, arg3, 0)) goto efault; rt_act->_sa_handler = VAR_16._sa_handler; rt_act->sa_mask = VAR_16.sa_mask; rt_act->sa_flags = VAR_16.sa_flags; unlock_user_struct(rt_act, arg3, 1); } #else struct target_sigaction *VAR_15; struct target_sigaction *VAR_16; if (arg2) { if (!lock_user_struct(VERIFY_READ, VAR_15, arg2, 1)) goto efault; } else VAR_15 = NULL; if (arg3) { if (!lock_user_struct(VERIFY_WRITE, VAR_16, arg3, 0)) { ret = -TARGET_EFAULT; goto rt_sigaction_fail; } } else VAR_16 = NULL; ret = get_errno(do_sigaction(arg1, VAR_15, VAR_16)); rt_sigaction_fail: if (VAR_15) unlock_user_struct(VAR_15, arg2, 0); if (VAR_16) unlock_user_struct(VAR_16, arg3, 1); #endif } break; #ifdef TARGET_NR_sgetmask case TARGET_NR_sgetmask: { sigset_t cur_set; abi_ulong target_set; sigprocmask(0, NULL, &cur_set); host_to_target_old_sigset(&target_set, &cur_set); ret = target_set; } break; #endif #ifdef TARGET_NR_ssetmask case TARGET_NR_ssetmask: { sigset_t set, oset, cur_set; abi_ulong target_set = arg1; sigprocmask(0, NULL, &cur_set); target_to_host_old_sigset(&set, &target_set); sigorset(&set, &set, &cur_set); sigprocmask(SIG_SETMASK, &set, &oset); host_to_target_old_sigset(&target_set, &oset); ret = target_set; } break; #endif #ifdef TARGET_NR_sigprocmask case TARGET_NR_sigprocmask: { #if defined(TARGET_ALPHA) sigset_t set, oldset; abi_ulong VAR_43; int VAR_17; switch (arg1) { case TARGET_SIG_BLOCK: VAR_17 = SIG_BLOCK; break; case TARGET_SIG_UNBLOCK: VAR_17 = SIG_UNBLOCK; break; case TARGET_SIG_SETMASK: VAR_17 = SIG_SETMASK; break; default: ret = -TARGET_EINVAL; goto fail; } VAR_43 = arg2; target_to_host_old_sigset(&set, &VAR_43); ret = get_errno(sigprocmask(VAR_17, &set, &oldset)); if (!is_error(ret)) { host_to_target_old_sigset(&VAR_43, &oldset); ret = VAR_43; ((CPUAlphaState *)cpu_env)->ir[IR_V0] = 0; } #else sigset_t set, oldset, *set_ptr; int VAR_17; if (arg2) { switch (arg1) { case TARGET_SIG_BLOCK: VAR_17 = SIG_BLOCK; break; case TARGET_SIG_UNBLOCK: VAR_17 = SIG_UNBLOCK; break; case TARGET_SIG_SETMASK: VAR_17 = SIG_SETMASK; break; default: ret = -TARGET_EINVAL; goto fail; } if (!(VAR_2 = lock_user(VERIFY_READ, arg2, sizeof(target_sigset_t), 1))) goto efault; target_to_host_old_sigset(&set, VAR_2); unlock_user(VAR_2, arg2, 0); set_ptr = &set; } else { VAR_17 = 0; set_ptr = NULL; } ret = get_errno(sigprocmask(VAR_17, set_ptr, &oldset)); if (!is_error(ret) && arg3) { if (!(VAR_2 = lock_user(VERIFY_WRITE, arg3, sizeof(target_sigset_t), 0))) goto efault; host_to_target_old_sigset(VAR_2, &oldset); unlock_user(VAR_2, arg3, sizeof(target_sigset_t)); } #endif } break; #endif case TARGET_NR_rt_sigprocmask: { int VAR_17 = arg1; sigset_t set, oldset, *set_ptr; if (arg2) { switch(VAR_17) { case TARGET_SIG_BLOCK: VAR_17 = SIG_BLOCK; break; case TARGET_SIG_UNBLOCK: VAR_17 = SIG_UNBLOCK; break; case TARGET_SIG_SETMASK: VAR_17 = SIG_SETMASK; break; default: ret = -TARGET_EINVAL; goto fail; } if (!(VAR_2 = lock_user(VERIFY_READ, arg2, sizeof(target_sigset_t), 1))) goto efault; target_to_host_sigset(&set, VAR_2); unlock_user(VAR_2, arg2, 0); set_ptr = &set; } else { VAR_17 = 0; set_ptr = NULL; } ret = get_errno(sigprocmask(VAR_17, set_ptr, &oldset)); if (!is_error(ret) && arg3) { if (!(VAR_2 = lock_user(VERIFY_WRITE, arg3, sizeof(target_sigset_t), 0))) goto efault; host_to_target_sigset(VAR_2, &oldset); unlock_user(VAR_2, arg3, sizeof(target_sigset_t)); } } break; #ifdef TARGET_NR_sigpending case TARGET_NR_sigpending: { sigset_t set; ret = get_errno(sigpending(&set)); if (!is_error(ret)) { if (!(VAR_2 = lock_user(VERIFY_WRITE, arg1, sizeof(target_sigset_t), 0))) goto efault; host_to_target_old_sigset(VAR_2, &set); unlock_user(VAR_2, arg1, sizeof(target_sigset_t)); } } break; #endif case TARGET_NR_rt_sigpending: { sigset_t set; ret = get_errno(sigpending(&set)); if (!is_error(ret)) { if (!(VAR_2 = lock_user(VERIFY_WRITE, arg1, sizeof(target_sigset_t), 0))) goto efault; host_to_target_sigset(VAR_2, &set); unlock_user(VAR_2, arg1, sizeof(target_sigset_t)); } } break; #ifdef TARGET_NR_sigsuspend case TARGET_NR_sigsuspend: { sigset_t set; #if defined(TARGET_ALPHA) abi_ulong VAR_43 = arg1; target_to_host_old_sigset(&set, &VAR_43); #else if (!(VAR_2 = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1))) goto efault; target_to_host_old_sigset(&set, VAR_2); unlock_user(VAR_2, arg1, 0); #endif ret = get_errno(sigsuspend(&set)); } break; #endif case TARGET_NR_rt_sigsuspend: { sigset_t set; if (!(VAR_2 = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1))) goto efault; target_to_host_sigset(&set, VAR_2); unlock_user(VAR_2, arg1, 0); ret = get_errno(sigsuspend(&set)); } break; case TARGET_NR_rt_sigtimedwait: { sigset_t set; struct timespec VAR_18, *VAR_19; siginfo_t uinfo; if (!(VAR_2 = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1))) goto efault; target_to_host_sigset(&set, VAR_2); unlock_user(VAR_2, arg1, 0); if (arg3) { VAR_19 = &VAR_18; target_to_host_timespec(VAR_19, arg3); } else { VAR_19 = NULL; } ret = get_errno(sigtimedwait(&set, &uinfo, VAR_19)); if (!is_error(ret) && arg2) { if (!(VAR_2 = lock_user(VERIFY_WRITE, arg2, sizeof(target_siginfo_t), 0))) goto efault; host_to_target_siginfo(VAR_2, &uinfo); unlock_user(VAR_2, arg2, sizeof(target_siginfo_t)); } } break; case TARGET_NR_rt_sigqueueinfo: { siginfo_t uinfo; if (!(VAR_2 = lock_user(VERIFY_READ, arg3, sizeof(target_sigset_t), 1))) goto efault; target_to_host_siginfo(&uinfo, VAR_2); unlock_user(VAR_2, arg1, 0); ret = get_errno(sys_rt_sigqueueinfo(arg1, arg2, &uinfo)); } break; #ifdef TARGET_NR_sigreturn case TARGET_NR_sigreturn: ret = do_sigreturn(cpu_env); break; #endif case TARGET_NR_rt_sigreturn: ret = do_rt_sigreturn(cpu_env); break; case TARGET_NR_sethostname: if (!(VAR_2 = lock_user_string(arg1))) goto efault; ret = get_errno(sethostname(VAR_2, arg2)); unlock_user(VAR_2, arg1, 0); break; case TARGET_NR_setrlimit: { int VAR_23 = target_to_host_resource(arg1); struct target_rlimit *VAR_23; struct rlimit VAR_23; if (!lock_user_struct(VERIFY_READ, VAR_23, arg2, 1)) goto efault; VAR_23.rlim_cur = target_to_host_rlim(VAR_23->rlim_cur); VAR_23.rlim_max = target_to_host_rlim(VAR_23->rlim_max); unlock_user_struct(VAR_23, arg2, 0); ret = get_errno(setrlimit(VAR_23, &VAR_23)); } break; case TARGET_NR_getrlimit: { int VAR_23 = target_to_host_resource(arg1); struct target_rlimit *VAR_23; struct rlimit VAR_23; ret = get_errno(getrlimit(VAR_23, &VAR_23)); if (!is_error(ret)) { if (!lock_user_struct(VERIFY_WRITE, VAR_23, arg2, 0)) goto efault; VAR_23->rlim_cur = host_to_target_rlim(VAR_23.rlim_cur); VAR_23->rlim_max = host_to_target_rlim(VAR_23.rlim_max); unlock_user_struct(VAR_23, arg2, 1); } } break; case TARGET_NR_getrusage: { struct VAR_32 VAR_32; ret = get_errno(getrusage(arg1, &VAR_32)); if (!is_error(ret)) { host_to_target_rusage(arg2, &VAR_32); } } break; case TARGET_NR_gettimeofday: { struct timeval VAR_24; ret = get_errno(gettimeofday(&VAR_24, NULL)); if (!is_error(ret)) { if (copy_to_user_timeval(arg1, &VAR_24)) goto efault; } } break; case TARGET_NR_settimeofday: { struct timeval VAR_24; if (copy_from_user_timeval(&VAR_24, arg1)) goto efault; ret = get_errno(settimeofday(&VAR_24, NULL)); } break; #if defined(TARGET_NR_select) && !defined(TARGET_S390X) && !defined(TARGET_S390) case TARGET_NR_select: { struct target_sel_arg_struct *sel; abi_ulong inp, outp, exp, VAR_11; long nsel; if (!lock_user_struct(VERIFY_READ, sel, arg1, 1)) goto efault; nsel = tswapal(sel->n); inp = tswapal(sel->inp); outp = tswapal(sel->outp); exp = tswapal(sel->exp); VAR_11 = tswapal(sel->VAR_11); unlock_user_struct(sel, arg1, 0); ret = do_select(nsel, inp, outp, exp, VAR_11); } break; #endif #ifdef TARGET_NR_pselect6 case TARGET_NR_pselect6: { abi_long rfd_addr, wfd_addr, efd_addr, n, ts_addr; fd_set rfds, wfds, efds; fd_set *rfds_ptr, *wfds_ptr, *efds_ptr; struct timespec VAR_45, *ts_ptr; sigset_t set; struct { sigset_t *set; size_t size; } sig, *sig_ptr; abi_ulong arg_sigset, arg_sigsize, *arg7; target_sigset_t *target_sigset; n = arg1; rfd_addr = arg2; wfd_addr = arg3; efd_addr = arg4; ts_addr = arg5; ret = copy_from_user_fdset_ptr(&rfds, &rfds_ptr, rfd_addr, n); if (ret) { goto fail; } ret = copy_from_user_fdset_ptr(&wfds, &wfds_ptr, wfd_addr, n); if (ret) { goto fail; } ret = copy_from_user_fdset_ptr(&efds, &efds_ptr, efd_addr, n); if (ret) { goto fail; } if (ts_addr) { if (target_to_host_timespec(&VAR_45, ts_addr)) { goto efault; } ts_ptr = &VAR_45; } else { ts_ptr = NULL; } if (arg6) { sig_ptr = &sig; sig.size = _NSIG / 8; arg7 = lock_user(VERIFY_READ, arg6, sizeof(*arg7) * 2, 1); if (!arg7) { goto efault; } arg_sigset = tswapal(arg7[0]); arg_sigsize = tswapal(arg7[1]); unlock_user(arg7, arg6, 0); if (arg_sigset) { sig.set = &set; if (arg_sigsize != sizeof(*target_sigset)) { ret = -TARGET_EINVAL; goto fail; } target_sigset = lock_user(VERIFY_READ, arg_sigset, sizeof(*target_sigset), 1); if (!target_sigset) { goto efault; } target_to_host_sigset(&set, target_sigset); unlock_user(target_sigset, arg_sigset, 0); } else { sig.set = NULL; } } else { sig_ptr = NULL; } ret = get_errno(sys_pselect6(n, rfds_ptr, wfds_ptr, efds_ptr, ts_ptr, sig_ptr)); if (!is_error(ret)) { if (rfd_addr && copy_to_user_fdset(rfd_addr, &rfds, n)) goto efault; if (wfd_addr && copy_to_user_fdset(wfd_addr, &wfds, n)) goto efault; if (efd_addr && copy_to_user_fdset(efd_addr, &efds, n)) goto efault; if (ts_addr && host_to_target_timespec(ts_addr, &VAR_45)) goto efault; } } break; #endif case TARGET_NR_symlink: { void *VAR_24; VAR_2 = lock_user_string(arg1); VAR_24 = lock_user_string(arg2); if (!VAR_2 || !VAR_24) ret = -TARGET_EFAULT; else ret = get_errno(symlink(VAR_2, VAR_24)); unlock_user(VAR_24, arg2, 0); unlock_user(VAR_2, arg1, 0); } break; #if defined(TARGET_NR_symlinkat) && defined(__NR_symlinkat) case TARGET_NR_symlinkat: { void *VAR_24; VAR_2 = lock_user_string(arg1); VAR_24 = lock_user_string(arg3); if (!VAR_2 || !VAR_24) ret = -TARGET_EFAULT; else ret = get_errno(sys_symlinkat(VAR_2, arg2, VAR_24)); unlock_user(VAR_24, arg3, 0); unlock_user(VAR_2, arg1, 0); } break; #endif #ifdef TARGET_NR_oldlstat case TARGET_NR_oldlstat: goto unimplemented; #endif case TARGET_NR_readlink: { void *VAR_24, *VAR_24; VAR_2 = lock_user_string(arg1); VAR_24 = lock_user(VERIFY_WRITE, arg2, arg3, 0); if (!VAR_2 || !VAR_24) ret = -TARGET_EFAULT; else { if (strncmp((const char *)VAR_2, "/proc/self/exe", 14) == 0) { char VAR_25[PATH_MAX]; VAR_24 = realpath(exec_path,VAR_25); ret = (VAR_24==NULL) ? get_errno(-1) : strlen(VAR_25) ; snprintf((char *)VAR_24, arg3, "%s", VAR_25); } else ret = get_errno(readlink(path(VAR_2), VAR_24, arg3)); } unlock_user(VAR_24, arg2, ret); unlock_user(VAR_2, arg1, 0); } break; #if defined(TARGET_NR_readlinkat) && defined(__NR_readlinkat) case TARGET_NR_readlinkat: { void *VAR_24; VAR_2 = lock_user_string(arg2); VAR_24 = lock_user(VERIFY_WRITE, arg3, arg4, 0); if (!VAR_2 || !VAR_24) ret = -TARGET_EFAULT; else ret = get_errno(sys_readlinkat(arg1, path(VAR_2), VAR_24, arg4)); unlock_user(VAR_24, arg3, ret); unlock_user(VAR_2, arg2, 0); } break; #endif #ifdef TARGET_NR_uselib case TARGET_NR_uselib: goto unimplemented; #endif #ifdef TARGET_NR_swapon case TARGET_NR_swapon: if (!(VAR_2 = lock_user_string(arg1))) goto efault; ret = get_errno(swapon(VAR_2, arg2)); unlock_user(VAR_2, arg1, 0); break; #endif case TARGET_NR_reboot: if (!(VAR_2 = lock_user_string(arg4))) goto efault; ret = reboot(arg1, arg2, arg3, VAR_2); unlock_user(VAR_2, arg4, 0); break; #ifdef TARGET_NR_readdir case TARGET_NR_readdir: goto unimplemented; #endif #ifdef TARGET_NR_mmap case TARGET_NR_mmap: #if (defined(TARGET_I386) && defined(TARGET_ABI32)) || defined(TARGET_ARM) || \ defined(TARGET_M68K) || defined(TARGET_CRIS) || defined(TARGET_MICROBLAZE) \ || defined(TARGET_S390X) { abi_ulong *v; abi_ulong v1, v2, v3, v4, v5, v6; if (!(v = lock_user(VERIFY_READ, arg1, 6 * sizeof(abi_ulong), 1))) goto efault; v1 = tswapal(v[0]); v2 = tswapal(v[1]); v3 = tswapal(v[2]); v4 = tswapal(v[3]); v5 = tswapal(v[4]); v6 = tswapal(v[5]); unlock_user(v, arg1, 0); ret = get_errno(target_mmap(v1, v2, v3, target_to_host_bitmask(v4, mmap_flags_tbl), v5, v6)); } #else ret = get_errno(target_mmap(arg1, arg2, arg3, target_to_host_bitmask(arg4, mmap_flags_tbl), arg5, arg6)); #endif break; #endif #ifdef TARGET_NR_mmap2 case TARGET_NR_mmap2: #ifndef MMAP_SHIFT #define MMAP_SHIFT 12 #endif ret = get_errno(target_mmap(arg1, arg2, arg3, target_to_host_bitmask(arg4, mmap_flags_tbl), arg5, arg6 << MMAP_SHIFT)); break; #endif case TARGET_NR_munmap: ret = get_errno(target_munmap(arg1, arg2)); break; case TARGET_NR_mprotect: { TaskState *VAR_45 = ((CPUArchState *)cpu_env)->opaque; if ((arg3 & PROT_GROWSDOWN) && arg1 >= VAR_45->info->stack_limit && arg1 <= VAR_45->info->start_stack) { arg3 &= ~PROT_GROWSDOWN; arg2 = arg2 + arg1 - VAR_45->info->stack_limit; arg1 = VAR_45->info->stack_limit; } } ret = get_errno(target_mprotect(arg1, arg2, arg3)); break; #ifdef TARGET_NR_mremap case TARGET_NR_mremap: ret = get_errno(target_mremap(arg1, arg2, arg3, arg4, arg5)); break; #endif #ifdef TARGET_NR_msync case TARGET_NR_msync: ret = get_errno(msync(g2h(arg1), arg2, arg3)); break; #endif #ifdef TARGET_NR_mlock case TARGET_NR_mlock: ret = get_errno(mlock(g2h(arg1), arg2)); break; #endif #ifdef TARGET_NR_munlock case TARGET_NR_munlock: ret = get_errno(munlock(g2h(arg1), arg2)); break; #endif #ifdef TARGET_NR_mlockall case TARGET_NR_mlockall: ret = get_errno(mlockall(arg1)); break; #endif #ifdef TARGET_NR_munlockall case TARGET_NR_munlockall: ret = get_errno(munlockall()); break; #endif case TARGET_NR_truncate: if (!(VAR_2 = lock_user_string(arg1))) goto efault; ret = get_errno(truncate(VAR_2, arg2)); unlock_user(VAR_2, arg1, 0); break; case TARGET_NR_ftruncate: ret = get_errno(ftruncate(arg1, arg2)); break; case TARGET_NR_fchmod: ret = get_errno(fchmod(arg1, arg2)); break; #if defined(TARGET_NR_fchmodat) && defined(__NR_fchmodat) case TARGET_NR_fchmodat: if (!(VAR_2 = lock_user_string(arg2))) goto efault; ret = get_errno(sys_fchmodat(arg1, VAR_2, arg3)); unlock_user(VAR_2, arg2, 0); break; #endif case TARGET_NR_getpriority: errno = 0; ret = getpriority(arg1, arg2); if (ret == -1 && errno != 0) { ret = -host_to_target_errno(errno); break; } #ifdef TARGET_ALPHA ((CPUAlphaState *)cpu_env)->ir[IR_V0] = 0; #else ret = 20 - ret; #endif break; case TARGET_NR_setpriority: ret = get_errno(setpriority(arg1, arg2, arg3)); break; #ifdef TARGET_NR_profil case TARGET_NR_profil: goto unimplemented; #endif case TARGET_NR_statfs: if (!(VAR_2 = lock_user_string(arg1))) goto efault; ret = get_errno(statfs(path(VAR_2), &VAR_1)); unlock_user(VAR_2, arg1, 0); convert_statfs: if (!is_error(ret)) { struct target_statfs *VAR_26; if (!lock_user_struct(VERIFY_WRITE, VAR_26, arg2, 0)) goto efault; __put_user(VAR_1.f_type, &VAR_26->f_type); __put_user(VAR_1.f_bsize, &VAR_26->f_bsize); __put_user(VAR_1.f_blocks, &VAR_26->f_blocks); __put_user(VAR_1.f_bfree, &VAR_26->f_bfree); __put_user(VAR_1.f_bavail, &VAR_26->f_bavail); __put_user(VAR_1.f_files, &VAR_26->f_files); __put_user(VAR_1.f_ffree, &VAR_26->f_ffree); __put_user(VAR_1.f_fsid.__val[0], &VAR_26->f_fsid.val[0]); __put_user(VAR_1.f_fsid.__val[1], &VAR_26->f_fsid.val[1]); __put_user(VAR_1.f_namelen, &VAR_26->f_namelen); __put_user(VAR_1.f_frsize, &VAR_26->f_frsize); memset(VAR_26->f_spare, 0, sizeof(VAR_26->f_spare)); unlock_user_struct(VAR_26, arg2, 1); } break; case TARGET_NR_fstatfs: ret = get_errno(fstatfs(arg1, &VAR_1)); goto convert_statfs; #ifdef TARGET_NR_statfs64 case TARGET_NR_statfs64: if (!(VAR_2 = lock_user_string(arg1))) goto efault; ret = get_errno(statfs(path(VAR_2), &VAR_1)); unlock_user(VAR_2, arg1, 0); convert_statfs64: if (!is_error(ret)) { struct target_statfs64 *VAR_26; if (!lock_user_struct(VERIFY_WRITE, VAR_26, arg3, 0)) goto efault; __put_user(VAR_1.f_type, &VAR_26->f_type); __put_user(VAR_1.f_bsize, &VAR_26->f_bsize); __put_user(VAR_1.f_blocks, &VAR_26->f_blocks); __put_user(VAR_1.f_bfree, &VAR_26->f_bfree); __put_user(VAR_1.f_bavail, &VAR_26->f_bavail); __put_user(VAR_1.f_files, &VAR_26->f_files); __put_user(VAR_1.f_ffree, &VAR_26->f_ffree); __put_user(VAR_1.f_fsid.__val[0], &VAR_26->f_fsid.val[0]); __put_user(VAR_1.f_fsid.__val[1], &VAR_26->f_fsid.val[1]); __put_user(VAR_1.f_namelen, &VAR_26->f_namelen); __put_user(VAR_1.f_frsize, &VAR_26->f_frsize); memset(VAR_26->f_spare, 0, sizeof(VAR_26->f_spare)); unlock_user_struct(VAR_26, arg3, 1); } break; case TARGET_NR_fstatfs64: ret = get_errno(fstatfs(arg1, &VAR_1)); goto convert_statfs64; #endif #ifdef TARGET_NR_ioperm case TARGET_NR_ioperm: goto unimplemented; #endif #ifdef TARGET_NR_socketcall case TARGET_NR_socketcall: ret = do_socketcall(arg1, arg2); break; #endif #ifdef TARGET_NR_accept case TARGET_NR_accept: ret = do_accept(arg1, arg2, arg3); break; #endif #ifdef TARGET_NR_bind case TARGET_NR_bind: ret = do_bind(arg1, arg2, arg3); break; #endif #ifdef TARGET_NR_connect case TARGET_NR_connect: ret = do_connect(arg1, arg2, arg3); break; #endif #ifdef TARGET_NR_getpeername case TARGET_NR_getpeername: ret = do_getpeername(arg1, arg2, arg3); break; #endif #ifdef TARGET_NR_getsockname case TARGET_NR_getsockname: ret = do_getsockname(arg1, arg2, arg3); break; #endif #ifdef TARGET_NR_getsockopt case TARGET_NR_getsockopt: ret = do_getsockopt(arg1, arg2, arg3, arg4, arg5); break; #endif #ifdef TARGET_NR_listen case TARGET_NR_listen: ret = get_errno(listen(arg1, arg2)); break; #endif #ifdef TARGET_NR_recv case TARGET_NR_recv: ret = do_recvfrom(arg1, arg2, arg3, arg4, 0, 0); break; #endif #ifdef TARGET_NR_recvfrom case TARGET_NR_recvfrom: ret = do_recvfrom(arg1, arg2, arg3, arg4, arg5, arg6); break; #endif #ifdef TARGET_NR_recvmsg case TARGET_NR_recvmsg: ret = do_sendrecvmsg(arg1, arg2, arg3, 0); break; #endif #ifdef TARGET_NR_send case TARGET_NR_send: ret = do_sendto(arg1, arg2, arg3, arg4, 0, 0); break; #endif #ifdef TARGET_NR_sendmsg case TARGET_NR_sendmsg: ret = do_sendrecvmsg(arg1, arg2, arg3, 1); break; #endif #ifdef TARGET_NR_sendto case TARGET_NR_sendto: ret = do_sendto(arg1, arg2, arg3, arg4, arg5, arg6); break; #endif #ifdef TARGET_NR_shutdown case TARGET_NR_shutdown: ret = get_errno(shutdown(arg1, arg2)); break; #endif #ifdef TARGET_NR_socket case TARGET_NR_socket: ret = do_socket(arg1, arg2, arg3); break; #endif #ifdef TARGET_NR_socketpair case TARGET_NR_socketpair: ret = do_socketpair(arg1, arg2, arg3, arg4); break; #endif #ifdef TARGET_NR_setsockopt case TARGET_NR_setsockopt: ret = do_setsockopt(arg1, arg2, arg3, arg4, (socklen_t) arg5); break; #endif case TARGET_NR_syslog: if (!(VAR_2 = lock_user_string(arg2))) goto efault; ret = get_errno(sys_syslog((int)arg1, VAR_2, (int)arg3)); unlock_user(VAR_2, arg2, 0); break; case TARGET_NR_setitimer: { struct itimerval VAR_34, VAR_28, *VAR_29; if (arg2) { VAR_29 = &VAR_34; if (copy_from_user_timeval(&VAR_29->it_interval, arg2) || copy_from_user_timeval(&VAR_29->it_value, arg2 + sizeof(struct target_timeval))) goto efault; } else { VAR_29 = NULL; } ret = get_errno(setitimer(arg1, VAR_29, &VAR_28)); if (!is_error(ret) && arg3) { if (copy_to_user_timeval(arg3, &VAR_28.it_interval) || copy_to_user_timeval(arg3 + sizeof(struct target_timeval), &VAR_28.it_value)) goto efault; } } break; case TARGET_NR_getitimer: { struct itimerval VAR_34; ret = get_errno(getitimer(arg1, &VAR_34)); if (!is_error(ret) && arg2) { if (copy_to_user_timeval(arg2, &VAR_34.it_interval) || copy_to_user_timeval(arg2 + sizeof(struct target_timeval), &VAR_34.it_value)) goto efault; } } break; case TARGET_NR_stat: if (!(VAR_2 = lock_user_string(arg1))) goto efault; ret = get_errno(stat(path(VAR_2), &VAR_0)); unlock_user(VAR_2, arg1, 0); goto do_stat; case TARGET_NR_lstat: if (!(VAR_2 = lock_user_string(arg1))) goto efault; ret = get_errno(lstat(path(VAR_2), &VAR_0)); unlock_user(VAR_2, arg1, 0); goto do_stat; case TARGET_NR_fstat: { ret = get_errno(fstat(arg1, &VAR_0)); do_stat: if (!is_error(ret)) { struct target_stat *VAR_30; if (!lock_user_struct(VERIFY_WRITE, VAR_30, arg2, 0)) goto efault; memset(VAR_30, 0, sizeof(*VAR_30)); __put_user(VAR_0.st_dev, &VAR_30->st_dev); __put_user(VAR_0.st_ino, &VAR_30->st_ino); __put_user(VAR_0.st_mode, &VAR_30->st_mode); __put_user(VAR_0.st_uid, &VAR_30->st_uid); __put_user(VAR_0.st_gid, &VAR_30->st_gid); __put_user(VAR_0.st_nlink, &VAR_30->st_nlink); __put_user(VAR_0.st_rdev, &VAR_30->st_rdev); __put_user(VAR_0.st_size, &VAR_30->st_size); __put_user(VAR_0.st_blksize, &VAR_30->st_blksize); __put_user(VAR_0.st_blocks, &VAR_30->st_blocks); __put_user(VAR_0.st_atime, &VAR_30->target_st_atime); __put_user(VAR_0.st_mtime, &VAR_30->target_st_mtime); __put_user(VAR_0.st_ctime, &VAR_30->target_st_ctime); unlock_user_struct(VAR_30, arg2, 1); } } break; #ifdef TARGET_NR_olduname case TARGET_NR_olduname: goto unimplemented; #endif #ifdef TARGET_NR_iopl case TARGET_NR_iopl: goto unimplemented; #endif case TARGET_NR_vhangup: ret = get_errno(vhangup()); break; #ifdef TARGET_NR_idle case TARGET_NR_idle: goto unimplemented; #endif #ifdef TARGET_NR_syscall case TARGET_NR_syscall: ret = FUNC_0(cpu_env, arg1 & 0xffff, arg2, arg3, arg4, arg5, arg6, arg7, arg8, 0); break; #endif case TARGET_NR_wait4: { int VAR_31; abi_long status_ptr = arg2; struct VAR_32 VAR_32, *VAR_32; abi_ulong target_rusage = arg4; if (target_rusage) VAR_32 = &VAR_32; else VAR_32 = NULL; ret = get_errno(wait4(arg1, &VAR_31, arg3, VAR_32)); if (!is_error(ret)) { if (status_ptr && ret) { VAR_31 = host_to_target_waitstatus(VAR_31); if (put_user_s32(VAR_31, status_ptr)) goto efault; } if (target_rusage) host_to_target_rusage(target_rusage, &VAR_32); } } break; #ifdef TARGET_NR_swapoff case TARGET_NR_swapoff: if (!(VAR_2 = lock_user_string(arg1))) goto efault; ret = get_errno(swapoff(VAR_2)); unlock_user(VAR_2, arg1, 0); break; #endif case TARGET_NR_sysinfo: { struct target_sysinfo *VAR_33; struct sysinfo VAR_34; ret = get_errno(sysinfo(&VAR_34)); if (!is_error(ret) && arg1) { if (!lock_user_struct(VERIFY_WRITE, VAR_33, arg1, 0)) goto efault; __put_user(VAR_34.uptime, &VAR_33->uptime); __put_user(VAR_34.loads[0], &VAR_33->loads[0]); __put_user(VAR_34.loads[1], &VAR_33->loads[1]); __put_user(VAR_34.loads[2], &VAR_33->loads[2]); __put_user(VAR_34.totalram, &VAR_33->totalram); __put_user(VAR_34.freeram, &VAR_33->freeram); __put_user(VAR_34.sharedram, &VAR_33->sharedram); __put_user(VAR_34.bufferram, &VAR_33->bufferram); __put_user(VAR_34.totalswap, &VAR_33->totalswap); __put_user(VAR_34.freeswap, &VAR_33->freeswap); __put_user(VAR_34.procs, &VAR_33->procs); __put_user(VAR_34.totalhigh, &VAR_33->totalhigh); __put_user(VAR_34.freehigh, &VAR_33->freehigh); __put_user(VAR_34.mem_unit, &VAR_33->mem_unit); unlock_user_struct(VAR_33, arg1, 1); } } break; #ifdef TARGET_NR_ipc case TARGET_NR_ipc: ret = do_ipc(arg1, arg2, arg3, arg4, arg5, arg6); break; #endif #ifdef TARGET_NR_semget case TARGET_NR_semget: ret = get_errno(semget(arg1, arg2, arg3)); break; #endif #ifdef TARGET_NR_semop case TARGET_NR_semop: ret = get_errno(do_semop(arg1, arg2, arg3)); break; #endif #ifdef TARGET_NR_semctl case TARGET_NR_semctl: ret = do_semctl(arg1, arg2, arg3, (union target_semun)(abi_ulong)arg4); break; #endif #ifdef TARGET_NR_msgctl case TARGET_NR_msgctl: ret = do_msgctl(arg1, arg2, arg3); break; #endif #ifdef TARGET_NR_msgget case TARGET_NR_msgget: ret = get_errno(msgget(arg1, arg2)); break; #endif #ifdef TARGET_NR_msgrcv case TARGET_NR_msgrcv: ret = do_msgrcv(arg1, arg2, arg3, arg4, arg5); break; #endif #ifdef TARGET_NR_msgsnd case TARGET_NR_msgsnd: ret = do_msgsnd(arg1, arg2, arg3, arg4); break; #endif #ifdef TARGET_NR_shmget case TARGET_NR_shmget: ret = get_errno(shmget(arg1, arg2, arg3)); break; #endif #ifdef TARGET_NR_shmctl case TARGET_NR_shmctl: ret = do_shmctl(arg1, arg2, arg3); break; #endif #ifdef TARGET_NR_shmat case TARGET_NR_shmat: ret = do_shmat(arg1, arg2, arg3); break; #endif #ifdef TARGET_NR_shmdt case TARGET_NR_shmdt: ret = do_shmdt(arg1); break; #endif case TARGET_NR_fsync: ret = get_errno(fsync(arg1)); break; case TARGET_NR_clone: #if defined(TARGET_SH4) || defined(TARGET_ALPHA) ret = get_errno(do_fork(cpu_env, arg1, arg2, arg3, arg5, arg4)); #elif defined(TARGET_CRIS) ret = get_errno(do_fork(cpu_env, arg2, arg1, arg3, arg4, arg5)); #elif defined(TARGET_S390X) ret = get_errno(do_fork(cpu_env, arg2, arg1, arg3, arg5, arg4)); #else ret = get_errno(do_fork(cpu_env, arg1, arg2, arg3, arg4, arg5)); #endif break; #ifdef __NR_exit_group case TARGET_NR_exit_group: #ifdef TARGET_GPROF _mcleanup(); #endif gdb_exit(cpu_env, arg1); ret = get_errno(exit_group(arg1)); break; #endif case TARGET_NR_setdomainname: if (!(VAR_2 = lock_user_string(arg1))) goto efault; ret = get_errno(setdomainname(VAR_2, arg2)); unlock_user(VAR_2, arg1, 0); break; case TARGET_NR_uname: { struct new_utsname * VAR_34; if (!lock_user_struct(VERIFY_WRITE, VAR_34, arg1, 0)) goto efault; ret = get_errno(sys_uname(VAR_34)); if (!is_error(ret)) { strcpy (VAR_34->machine, cpu_to_uname_machine(cpu_env)); if (qemu_uname_release && *qemu_uname_release) strcpy (VAR_34->release, qemu_uname_release); } unlock_user_struct(VAR_34, arg1, 1); } break; #ifdef TARGET_I386 case TARGET_NR_modify_ldt: ret = do_modify_ldt(cpu_env, arg1, arg2, arg3); break; #if !defined(TARGET_X86_64) case TARGET_NR_vm86old: goto unimplemented; case TARGET_NR_vm86: ret = do_vm86(cpu_env, arg1, arg2); break; #endif #endif case TARGET_NR_adjtimex: goto unimplemented; #ifdef TARGET_NR_create_module case TARGET_NR_create_module: #endif case TARGET_NR_init_module: case TARGET_NR_delete_module: #ifdef TARGET_NR_get_kernel_syms case TARGET_NR_get_kernel_syms: #endif goto unimplemented; case TARGET_NR_quotactl: goto unimplemented; case TARGET_NR_getpgid: ret = get_errno(getpgid(arg1)); break; case TARGET_NR_fchdir: ret = get_errno(fchdir(arg1)); break; #ifdef TARGET_NR_bdflush case TARGET_NR_bdflush: goto unimplemented; #endif #ifdef TARGET_NR_sysfs case TARGET_NR_sysfs: goto unimplemented; #endif case TARGET_NR_personality: ret = get_errno(personality(arg1)); break; #ifdef TARGET_NR_afs_syscall case TARGET_NR_afs_syscall: goto unimplemented; #endif #ifdef TARGET_NR__llseek case TARGET_NR__llseek: { int64_t res; #if !defined(__NR_llseek) res = lseek(arg1, ((uint64_t)arg2 << 32) | arg3, arg5); if (res == -1) { ret = get_errno(res); } else { ret = 0; } #else ret = get_errno(_llseek(arg1, arg2, arg3, &res, arg5)); #endif if ((ret == 0) && put_user_s64(res, arg4)) { goto efault; } } break; #endif case TARGET_NR_getdents: #if TARGET_ABI_BITS == 32 && HOST_LONG_BITS == 64 { struct target_dirent *target_dirp; struct linux_dirent *VAR_35; abi_long VAR_41 = arg3; VAR_35 = malloc(VAR_41); if (!VAR_35) { ret = -TARGET_ENOMEM; goto fail; } ret = get_errno(sys_getdents(arg1, VAR_35, VAR_41)); if (!is_error(ret)) { struct linux_dirent *VAR_36; struct target_dirent *tde; int VAR_37 = ret; int VAR_38, treclen; int count1, tnamelen; count1 = 0; VAR_36 = VAR_35; if (!(target_dirp = lock_user(VERIFY_WRITE, arg2, VAR_41, 0))) goto efault; tde = target_dirp; while (VAR_37 > 0) { VAR_38 = VAR_36->d_reclen; tnamelen = VAR_38 - offsetof(struct linux_dirent, d_name); assert(tnamelen >= 0); treclen = tnamelen + offsetof(struct target_dirent, d_name); assert(count1 + treclen <= VAR_41); tde->d_reclen = tswap16(treclen); tde->d_ino = tswapal(VAR_36->d_ino); tde->d_off = tswapal(VAR_36->d_off); memcpy(tde->d_name, VAR_36->d_name, tnamelen); VAR_36 = (struct linux_dirent *)((char *)VAR_36 + VAR_38); VAR_37 -= VAR_38; tde = (struct target_dirent *)((char *)tde + treclen); count1 += treclen; } ret = count1; unlock_user(target_dirp, arg2, ret); } free(VAR_35); } #else { struct linux_dirent *VAR_35; abi_long VAR_41 = arg3; if (!(VAR_35 = lock_user(VERIFY_WRITE, arg2, VAR_41, 0))) goto efault; ret = get_errno(sys_getdents(arg1, VAR_35, VAR_41)); if (!is_error(ret)) { struct linux_dirent *VAR_36; int VAR_37 = ret; int VAR_38; VAR_36 = VAR_35; while (VAR_37 > 0) { VAR_38 = VAR_36->d_reclen; if (VAR_38 > VAR_37) break; VAR_36->d_reclen = tswap16(VAR_38); tswapls(&VAR_36->d_ino); tswapls(&VAR_36->d_off); VAR_36 = (struct linux_dirent *)((char *)VAR_36 + VAR_38); VAR_37 -= VAR_38; } } unlock_user(VAR_35, arg2, ret); } #endif break; #if defined(TARGET_NR_getdents64) && defined(__NR_getdents64) case TARGET_NR_getdents64: { struct linux_dirent64 *VAR_35; abi_long VAR_41 = arg3; if (!(VAR_35 = lock_user(VERIFY_WRITE, arg2, VAR_41, 0))) goto efault; ret = get_errno(sys_getdents64(arg1, VAR_35, VAR_41)); if (!is_error(ret)) { struct linux_dirent64 *VAR_36; int VAR_37 = ret; int VAR_38; VAR_36 = VAR_35; while (VAR_37 > 0) { VAR_38 = VAR_36->d_reclen; if (VAR_38 > VAR_37) break; VAR_36->d_reclen = tswap16(VAR_38); tswap64s((uint64_t *)&VAR_36->d_ino); tswap64s((uint64_t *)&VAR_36->d_off); VAR_36 = (struct linux_dirent64 *)((char *)VAR_36 + VAR_38); VAR_37 -= VAR_38; } } unlock_user(VAR_35, arg2, ret); } break; #endif #if defined(TARGET_NR__newselect) || defined(TARGET_S390X) #ifdef TARGET_S390X case TARGET_NR_select: #else case TARGET_NR__newselect: #endif ret = do_select(arg1, arg2, arg3, arg4, arg5); break; #endif #if defined(TARGET_NR_poll) || defined(TARGET_NR_ppoll) # ifdef TARGET_NR_poll case TARGET_NR_poll: # endif # ifdef TARGET_NR_ppoll case TARGET_NR_ppoll: # endif { struct target_pollfd *target_pfd; unsigned int nfds = arg2; int timeout = arg3; struct pollfd *pfd; unsigned int VAR_51; target_pfd = lock_user(VERIFY_WRITE, arg1, sizeof(struct target_pollfd) * nfds, 1); if (!target_pfd) goto efault; pfd = alloca(sizeof(struct pollfd) * nfds); for(VAR_51 = 0; VAR_51 < nfds; VAR_51++) { pfd[VAR_51].fd = tswap32(target_pfd[VAR_51].fd); pfd[VAR_51].events = tswap16(target_pfd[VAR_51].events); } # ifdef TARGET_NR_ppoll if (num == TARGET_NR_ppoll) { struct timespec _timeout_ts, *timeout_ts = &_timeout_ts; target_sigset_t *target_set; sigset_t _set, *set = &_set; if (arg3) { if (target_to_host_timespec(timeout_ts, arg3)) { unlock_user(target_pfd, arg1, 0); goto efault; } } else { timeout_ts = NULL; } if (arg4) { target_set = lock_user(VERIFY_READ, arg4, sizeof(target_sigset_t), 1); if (!target_set) { unlock_user(target_pfd, arg1, 0); goto efault; } target_to_host_sigset(set, target_set); } else { set = NULL; } ret = get_errno(sys_ppoll(pfd, nfds, timeout_ts, set, _NSIG/8)); if (!is_error(ret) && arg3) { host_to_target_timespec(arg3, timeout_ts); } if (arg4) { unlock_user(target_set, arg4, 0); } } else # endif ret = get_errno(poll(pfd, nfds, timeout)); if (!is_error(ret)) { for(VAR_51 = 0; VAR_51 < nfds; VAR_51++) { target_pfd[VAR_51].revents = tswap16(pfd[VAR_51].revents); } } unlock_user(target_pfd, arg1, sizeof(struct target_pollfd) * nfds); } break; #endif case TARGET_NR_flock: ret = get_errno(flock(arg1, arg2)); break; case TARGET_NR_readv: { int VAR_41 = arg3; struct iovec *VAR_41; VAR_41 = alloca(VAR_41 * sizeof(struct iovec)); if (lock_iovec(VERIFY_WRITE, VAR_41, arg2, VAR_41, 0) < 0) goto efault; ret = get_errno(readv(arg1, VAR_41, VAR_41)); unlock_iovec(VAR_41, arg2, VAR_41, 1); } break; case TARGET_NR_writev: { int VAR_41 = arg3; struct iovec *VAR_41; VAR_41 = alloca(VAR_41 * sizeof(struct iovec)); if (lock_iovec(VERIFY_READ, VAR_41, arg2, VAR_41, 1) < 0) goto efault; ret = get_errno(writev(arg1, VAR_41, VAR_41)); unlock_iovec(VAR_41, arg2, VAR_41, 0); } break; case TARGET_NR_getsid: ret = get_errno(getsid(arg1)); break; #if defined(TARGET_NR_fdatasync) case TARGET_NR_fdatasync: ret = get_errno(fdatasync(arg1)); break; #endif case TARGET_NR__sysctl: ret = -TARGET_ENOTDIR; break; case TARGET_NR_sched_getaffinity: { unsigned int VAR_43; unsigned long *VAR_43; if (arg2 & (sizeof(abi_ulong) - 1)) { ret = -TARGET_EINVAL; break; } VAR_43 = (arg2 + (sizeof(*VAR_43) - 1)) & ~(sizeof(*VAR_43) - 1); VAR_43 = alloca(VAR_43); ret = get_errno(sys_sched_getaffinity(arg1, VAR_43, VAR_43)); if (!is_error(ret)) { if (copy_to_user(arg3, VAR_43, ret)) { goto efault; } } } break; case TARGET_NR_sched_setaffinity: { unsigned int VAR_43; unsigned long *VAR_43; if (arg2 & (sizeof(abi_ulong) - 1)) { ret = -TARGET_EINVAL; break; } VAR_43 = (arg2 + (sizeof(*VAR_43) - 1)) & ~(sizeof(*VAR_43) - 1); VAR_43 = alloca(VAR_43); if (!lock_user_struct(VERIFY_READ, VAR_2, arg3, 1)) { goto efault; } memcpy(VAR_43, VAR_2, arg2); unlock_user_struct(VAR_2, arg2, 0); ret = get_errno(sys_sched_setaffinity(arg1, VAR_43, VAR_43)); } break; case TARGET_NR_sched_setparam: { struct sched_param *VAR_45; struct sched_param VAR_45; if (!lock_user_struct(VERIFY_READ, VAR_45, arg2, 1)) goto efault; VAR_45.sched_priority = tswap32(VAR_45->sched_priority); unlock_user_struct(VAR_45, arg2, 0); ret = get_errno(sched_setparam(arg1, &VAR_45)); } break; case TARGET_NR_sched_getparam: { struct sched_param *VAR_45; struct sched_param VAR_45; ret = get_errno(sched_getparam(arg1, &VAR_45)); if (!is_error(ret)) { if (!lock_user_struct(VERIFY_WRITE, VAR_45, arg2, 0)) goto efault; VAR_45->sched_priority = tswap32(VAR_45.sched_priority); unlock_user_struct(VAR_45, arg2, 1); } } break; case TARGET_NR_sched_setscheduler: { struct sched_param *VAR_45; struct sched_param VAR_45; if (!lock_user_struct(VERIFY_READ, VAR_45, arg3, 1)) goto efault; VAR_45.sched_priority = tswap32(VAR_45->sched_priority); unlock_user_struct(VAR_45, arg3, 0); ret = get_errno(sched_setscheduler(arg1, arg2, &VAR_45)); } break; case TARGET_NR_sched_getscheduler: ret = get_errno(sched_getscheduler(arg1)); break; case TARGET_NR_sched_yield: ret = get_errno(sched_yield()); break; case TARGET_NR_sched_get_priority_max: ret = get_errno(sched_get_priority_max(arg1)); break; case TARGET_NR_sched_get_priority_min: ret = get_errno(sched_get_priority_min(arg1)); break; case TARGET_NR_sched_rr_get_interval: { struct timespec VAR_45; ret = get_errno(sched_rr_get_interval(arg1, &VAR_45)); if (!is_error(ret)) { host_to_target_timespec(arg2, &VAR_45); } } break; case TARGET_NR_nanosleep: { struct timespec VAR_46, VAR_47; target_to_host_timespec(&VAR_46, arg1); ret = get_errno(nanosleep(&VAR_46, &VAR_47)); if (is_error(ret) && arg2) { host_to_target_timespec(arg2, &VAR_47); } } break; #ifdef TARGET_NR_query_module case TARGET_NR_query_module: goto unimplemented; #endif #ifdef TARGET_NR_nfsservctl case TARGET_NR_nfsservctl: goto unimplemented; #endif case TARGET_NR_prctl: switch (arg1) { case PR_GET_PDEATHSIG: { int VAR_48; ret = get_errno(prctl(arg1, &VAR_48, arg3, arg4, arg5)); if (!is_error(ret) && arg2 && put_user_ual(VAR_48, arg2)) { goto efault; } break; } #ifdef PR_GET_NAME case PR_GET_NAME: { void *name = lock_user(VERIFY_WRITE, arg2, 16, 1); if (!name) { goto efault; } ret = get_errno(prctl(arg1, (unsigned long)name, arg3, arg4, arg5)); unlock_user(name, arg2, 16); break; } case PR_SET_NAME: { void *name = lock_user(VERIFY_READ, arg2, 16, 1); if (!name) { goto efault; } ret = get_errno(prctl(arg1, (unsigned long)name, arg3, arg4, arg5)); unlock_user(name, arg2, 0); break; } #endif default: ret = get_errno(prctl(arg1, arg2, arg3, arg4, arg5)); break; } break; #ifdef TARGET_NR_arch_prctl case TARGET_NR_arch_prctl: #if defined(TARGET_I386) && !defined(TARGET_ABI32) ret = do_arch_prctl(cpu_env, arg1, arg2); break; #else goto unimplemented; #endif #endif #ifdef TARGET_NR_pread case TARGET_NR_pread: if (regpairs_aligned(cpu_env)) arg4 = arg5; if (!(VAR_2 = lock_user(VERIFY_WRITE, arg2, arg3, 0))) goto efault; ret = get_errno(pread(arg1, VAR_2, arg3, arg4)); unlock_user(VAR_2, arg2, ret); break; case TARGET_NR_pwrite: if (regpairs_aligned(cpu_env)) arg4 = arg5; if (!(VAR_2 = lock_user(VERIFY_READ, arg2, arg3, 1))) goto efault; ret = get_errno(pwrite(arg1, VAR_2, arg3, arg4)); unlock_user(VAR_2, arg2, 0); break; #endif #ifdef TARGET_NR_pread64 case TARGET_NR_pread64: if (!(VAR_2 = lock_user(VERIFY_WRITE, arg2, arg3, 0))) goto efault; ret = get_errno(pread64(arg1, VAR_2, arg3, target_offset64(arg4, arg5))); unlock_user(VAR_2, arg2, ret); break; case TARGET_NR_pwrite64: if (!(VAR_2 = lock_user(VERIFY_READ, arg2, arg3, 1))) goto efault; ret = get_errno(pwrite64(arg1, VAR_2, arg3, target_offset64(arg4, arg5))); unlock_user(VAR_2, arg2, 0); break; #endif case TARGET_NR_getcwd: if (!(VAR_2 = lock_user(VERIFY_WRITE, arg1, arg2, 0))) goto efault; ret = get_errno(sys_getcwd1(VAR_2, arg2)); unlock_user(VAR_2, arg1, ret); break; case TARGET_NR_capget: goto unimplemented; case TARGET_NR_capset: goto unimplemented; case TARGET_NR_sigaltstack: #if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_MIPS) || \ defined(TARGET_SPARC) || defined(TARGET_PPC) || defined(TARGET_ALPHA) || \ defined(TARGET_M68K) || defined(TARGET_S390X) || defined(TARGET_OPENRISC) ret = do_sigaltstack(arg1, arg2, get_sp_from_cpustate((CPUArchState *)cpu_env)); break; #else goto unimplemented; #endif case TARGET_NR_sendfile: goto unimplemented; #ifdef TARGET_NR_getpmsg case TARGET_NR_getpmsg: goto unimplemented; #endif #ifdef TARGET_NR_putpmsg case TARGET_NR_putpmsg: goto unimplemented; #endif #ifdef TARGET_NR_vfork case TARGET_NR_vfork: ret = get_errno(do_fork(cpu_env, CLONE_VFORK | CLONE_VM | SIGCHLD, 0, 0, 0, 0)); break; #endif #ifdef TARGET_NR_ugetrlimit case TARGET_NR_ugetrlimit: { struct rlimit VAR_23; int VAR_23 = target_to_host_resource(arg1); ret = get_errno(getrlimit(VAR_23, &VAR_23)); if (!is_error(ret)) { struct target_rlimit *VAR_23; if (!lock_user_struct(VERIFY_WRITE, VAR_23, arg2, 0)) goto efault; VAR_23->rlim_cur = host_to_target_rlim(VAR_23.rlim_cur); VAR_23->rlim_max = host_to_target_rlim(VAR_23.rlim_max); unlock_user_struct(VAR_23, arg2, 1); } break; } #endif #ifdef TARGET_NR_truncate64 case TARGET_NR_truncate64: if (!(VAR_2 = lock_user_string(arg1))) goto efault; ret = target_truncate64(cpu_env, VAR_2, arg2, arg3, arg4); unlock_user(VAR_2, arg1, 0); break; #endif #ifdef TARGET_NR_ftruncate64 case TARGET_NR_ftruncate64: ret = target_ftruncate64(cpu_env, arg1, arg2, arg3, arg4); break; #endif #ifdef TARGET_NR_stat64 case TARGET_NR_stat64: if (!(VAR_2 = lock_user_string(arg1))) goto efault; ret = get_errno(stat(path(VAR_2), &VAR_0)); unlock_user(VAR_2, arg1, 0); if (!is_error(ret)) ret = host_to_target_stat64(cpu_env, arg2, &VAR_0); break; #endif #ifdef TARGET_NR_lstat64 case TARGET_NR_lstat64: if (!(VAR_2 = lock_user_string(arg1))) goto efault; ret = get_errno(lstat(path(VAR_2), &VAR_0)); unlock_user(VAR_2, arg1, 0); if (!is_error(ret)) ret = host_to_target_stat64(cpu_env, arg2, &VAR_0); break; #endif #ifdef TARGET_NR_fstat64 case TARGET_NR_fstat64: ret = get_errno(fstat(arg1, &VAR_0)); if (!is_error(ret)) ret = host_to_target_stat64(cpu_env, arg2, &VAR_0); break; #endif #if (defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)) && \ (defined(__NR_fstatat64) || defined(__NR_newfstatat)) #ifdef TARGET_NR_fstatat64 case TARGET_NR_fstatat64: #endif #ifdef TARGET_NR_newfstatat case TARGET_NR_newfstatat: #endif if (!(VAR_2 = lock_user_string(arg2))) goto efault; #ifdef __NR_fstatat64 ret = get_errno(sys_fstatat64(arg1, path(VAR_2), &VAR_0, arg4)); #else ret = get_errno(sys_newfstatat(arg1, path(VAR_2), &VAR_0, arg4)); #endif if (!is_error(ret)) ret = host_to_target_stat64(cpu_env, arg3, &VAR_0); break; #endif case TARGET_NR_lchown: if (!(VAR_2 = lock_user_string(arg1))) goto efault; ret = get_errno(lchown(VAR_2, low2highuid(arg2), low2highgid(arg3))); unlock_user(VAR_2, arg1, 0); break; #ifdef TARGET_NR_getuid case TARGET_NR_getuid: ret = get_errno(high2lowuid(getuid())); break; #endif #ifdef TARGET_NR_getgid case TARGET_NR_getgid: ret = get_errno(high2lowgid(getgid())); break; #endif #ifdef TARGET_NR_geteuid case TARGET_NR_geteuid: ret = get_errno(high2lowuid(geteuid())); break; #endif #ifdef TARGET_NR_getegid case TARGET_NR_getegid: ret = get_errno(high2lowgid(getegid())); break; #endif case TARGET_NR_setreuid: ret = get_errno(setreuid(low2highuid(arg1), low2highuid(arg2))); break; case TARGET_NR_setregid: ret = get_errno(setregid(low2highgid(arg1), low2highgid(arg2))); break; case TARGET_NR_getgroups: { int VAR_51 = arg1; target_id *target_grouplist; gid_t *grouplist; int VAR_51; grouplist = alloca(VAR_51 * sizeof(gid_t)); ret = get_errno(getgroups(VAR_51, grouplist)); if (VAR_51 == 0) break; if (!is_error(ret)) { target_grouplist = lock_user(VERIFY_WRITE, arg2, VAR_51 * 2, 0); if (!target_grouplist) goto efault; for(VAR_51 = 0;VAR_51 < ret; VAR_51++) target_grouplist[VAR_51] = tswapid(high2lowgid(grouplist[VAR_51])); unlock_user(target_grouplist, arg2, VAR_51 * 2); } } break; case TARGET_NR_setgroups: { int VAR_51 = arg1; target_id *target_grouplist; gid_t *grouplist; int VAR_51; grouplist = alloca(VAR_51 * sizeof(gid_t)); target_grouplist = lock_user(VERIFY_READ, arg2, VAR_51 * 2, 1); if (!target_grouplist) { ret = -TARGET_EFAULT; goto fail; } for(VAR_51 = 0;VAR_51 < VAR_51; VAR_51++) grouplist[VAR_51] = low2highgid(tswapid(target_grouplist[VAR_51])); unlock_user(target_grouplist, arg2, 0); ret = get_errno(setgroups(VAR_51, grouplist)); } break; case TARGET_NR_fchown: ret = get_errno(fchown(arg1, low2highuid(arg2), low2highgid(arg3))); break; #if defined(TARGET_NR_fchownat) && defined(__NR_fchownat) case TARGET_NR_fchownat: if (!(VAR_2 = lock_user_string(arg2))) goto efault; ret = get_errno(sys_fchownat(arg1, VAR_2, low2highuid(arg3), low2highgid(arg4), arg5)); unlock_user(VAR_2, arg2, 0); break; #endif #ifdef TARGET_NR_setresuid case TARGET_NR_setresuid: ret = get_errno(setresuid(low2highuid(arg1), low2highuid(arg2), low2highuid(arg3))); break; #endif #ifdef TARGET_NR_getresuid case TARGET_NR_getresuid: { uid_t ruid, euid, suid; ret = get_errno(getresuid(&ruid, &euid, &suid)); if (!is_error(ret)) { if (put_user_u16(high2lowuid(ruid), arg1) || put_user_u16(high2lowuid(euid), arg2) || put_user_u16(high2lowuid(suid), arg3)) goto efault; } } break; #endif #ifdef TARGET_NR_getresgid case TARGET_NR_setresgid: ret = get_errno(setresgid(low2highgid(arg1), low2highgid(arg2), low2highgid(arg3))); break; #endif #ifdef TARGET_NR_getresgid case TARGET_NR_getresgid: { gid_t rgid, egid, sgid; ret = get_errno(getresgid(&rgid, &egid, &sgid)); if (!is_error(ret)) { if (put_user_u16(high2lowgid(rgid), arg1) || put_user_u16(high2lowgid(egid), arg2) || put_user_u16(high2lowgid(sgid), arg3)) goto efault; } } break; #endif case TARGET_NR_chown: if (!(VAR_2 = lock_user_string(arg1))) goto efault; ret = get_errno(chown(VAR_2, low2highuid(arg2), low2highgid(arg3))); unlock_user(VAR_2, arg1, 0); break; case TARGET_NR_setuid: ret = get_errno(setuid(low2highuid(arg1))); break; case TARGET_NR_setgid: ret = get_errno(setgid(low2highgid(arg1))); break; case TARGET_NR_setfsuid: ret = get_errno(setfsuid(arg1)); break; case TARGET_NR_setfsgid: ret = get_errno(setfsgid(arg1)); break; #ifdef TARGET_NR_lchown32 case TARGET_NR_lchown32: if (!(VAR_2 = lock_user_string(arg1))) goto efault; ret = get_errno(lchown(VAR_2, arg2, arg3)); unlock_user(VAR_2, arg1, 0); break; #endif #ifdef TARGET_NR_getuid32 case TARGET_NR_getuid32: ret = get_errno(getuid()); break; #endif #if defined(TARGET_NR_getxuid) && defined(TARGET_ALPHA) case TARGET_NR_getxuid: { uid_t euid; euid=geteuid(); ((CPUAlphaState *)cpu_env)->ir[IR_A4]=euid; } ret = get_errno(getuid()); break; #endif #if defined(TARGET_NR_getxgid) && defined(TARGET_ALPHA) case TARGET_NR_getxgid: { uid_t egid; egid=getegid(); ((CPUAlphaState *)cpu_env)->ir[IR_A4]=egid; } ret = get_errno(getgid()); break; #endif #if defined(TARGET_NR_osf_getsysinfo) && defined(TARGET_ALPHA) case TARGET_NR_osf_getsysinfo: ret = -TARGET_EOPNOTSUPP; switch (arg1) { case TARGET_GSI_IEEE_FP_CONTROL: { uint64_t swcr, fpcr = cpu_alpha_load_fpcr (cpu_env); swcr = (fpcr >> 35) & SWCR_STATUS_MASK; swcr |= (fpcr >> 36) & SWCR_MAP_DMZ; swcr |= (~fpcr >> 48) & (SWCR_TRAP_ENABLE_INV | SWCR_TRAP_ENABLE_DZE | SWCR_TRAP_ENABLE_OVF); swcr |= (~fpcr >> 57) & (SWCR_TRAP_ENABLE_UNF | SWCR_TRAP_ENABLE_INE); swcr |= (fpcr >> 47) & SWCR_MAP_UMZ; swcr |= (~fpcr >> 41) & SWCR_TRAP_ENABLE_DNO; if (put_user_u64 (swcr, arg2)) goto efault; ret = 0; } break; } break; #endif #if defined(TARGET_NR_osf_setsysinfo) && defined(TARGET_ALPHA) case TARGET_NR_osf_setsysinfo: ret = -TARGET_EOPNOTSUPP; switch (arg1) { case TARGET_SSI_IEEE_FP_CONTROL: { uint64_t swcr, fpcr, orig_fpcr; if (get_user_u64 (swcr, arg2)) { goto efault; } orig_fpcr = cpu_alpha_load_fpcr(cpu_env); fpcr = orig_fpcr & FPCR_DYN_MASK; fpcr |= (swcr & SWCR_STATUS_MASK) << 35; fpcr |= (swcr & SWCR_MAP_DMZ) << 36; fpcr |= (~swcr & (SWCR_TRAP_ENABLE_INV | SWCR_TRAP_ENABLE_DZE | SWCR_TRAP_ENABLE_OVF)) << 48; fpcr |= (~swcr & (SWCR_TRAP_ENABLE_UNF | SWCR_TRAP_ENABLE_INE)) << 57; fpcr |= (swcr & SWCR_MAP_UMZ ? FPCR_UNDZ | FPCR_UNFD : 0); fpcr |= (~swcr & SWCR_TRAP_ENABLE_DNO) << 41; cpu_alpha_store_fpcr(cpu_env, fpcr); ret = 0; } break; case TARGET_SSI_IEEE_RAISE_EXCEPTION: { uint64_t exc, fpcr, orig_fpcr; int si_code; if (get_user_u64(exc, arg2)) { goto efault; } orig_fpcr = cpu_alpha_load_fpcr(cpu_env); fpcr = orig_fpcr | ((exc & SWCR_STATUS_MASK) << 35); cpu_alpha_store_fpcr(cpu_env, fpcr); ret = 0; fpcr &= ~(orig_fpcr & FPCR_STATUS_MASK); si_code = 0; if ((fpcr & (FPCR_INE | FPCR_INED)) == FPCR_INE) { si_code = TARGET_FPE_FLTRES; } if ((fpcr & (FPCR_UNF | FPCR_UNFD)) == FPCR_UNF) { si_code = TARGET_FPE_FLTUND; } if ((fpcr & (FPCR_OVF | FPCR_OVFD)) == FPCR_OVF) { si_code = TARGET_FPE_FLTOVF; } if ((fpcr & (FPCR_DZE | FPCR_DZED)) == FPCR_DZE) { si_code = TARGET_FPE_FLTDIV; } if ((fpcr & (FPCR_INV | FPCR_INVD)) == FPCR_INV) { si_code = TARGET_FPE_FLTINV; } if (si_code != 0) { target_siginfo_t info; info.si_signo = SIGFPE; info.si_errno = 0; info.si_code = si_code; info._sifields._sigfault._addr = ((CPUArchState *)cpu_env)->pc; queue_signal((CPUArchState *)cpu_env, info.si_signo, &info); } } break; } break; #endif #ifdef TARGET_NR_osf_sigprocmask case TARGET_NR_osf_sigprocmask: { abi_ulong VAR_43; int VAR_17; sigset_t set, oldset; switch(arg1) { case TARGET_SIG_BLOCK: VAR_17 = SIG_BLOCK; break; case TARGET_SIG_UNBLOCK: VAR_17 = SIG_UNBLOCK; break; case TARGET_SIG_SETMASK: VAR_17 = SIG_SETMASK; break; default: ret = -TARGET_EINVAL; goto fail; } VAR_43 = arg2; target_to_host_old_sigset(&set, &VAR_43); sigprocmask(VAR_17, &set, &oldset); host_to_target_old_sigset(&VAR_43, &oldset); ret = VAR_43; } break; #endif #ifdef TARGET_NR_getgid32 case TARGET_NR_getgid32: ret = get_errno(getgid()); break; #endif #ifdef TARGET_NR_geteuid32 case TARGET_NR_geteuid32: ret = get_errno(geteuid()); break; #endif #ifdef TARGET_NR_getegid32 case TARGET_NR_getegid32: ret = get_errno(getegid()); break; #endif #ifdef TARGET_NR_setreuid32 case TARGET_NR_setreuid32: ret = get_errno(setreuid(arg1, arg2)); break; #endif #ifdef TARGET_NR_setregid32 case TARGET_NR_setregid32: ret = get_errno(setregid(arg1, arg2)); break; #endif #ifdef TARGET_NR_getgroups32 case TARGET_NR_getgroups32: { int VAR_51 = arg1; uint32_t *target_grouplist; gid_t *grouplist; int VAR_51; grouplist = alloca(VAR_51 * sizeof(gid_t)); ret = get_errno(getgroups(VAR_51, grouplist)); if (VAR_51 == 0) break; if (!is_error(ret)) { target_grouplist = lock_user(VERIFY_WRITE, arg2, VAR_51 * 4, 0); if (!target_grouplist) { ret = -TARGET_EFAULT; goto fail; } for(VAR_51 = 0;VAR_51 < ret; VAR_51++) target_grouplist[VAR_51] = tswap32(grouplist[VAR_51]); unlock_user(target_grouplist, arg2, VAR_51 * 4); } } break; #endif #ifdef TARGET_NR_setgroups32 case TARGET_NR_setgroups32: { int VAR_51 = arg1; uint32_t *target_grouplist; gid_t *grouplist; int VAR_51; grouplist = alloca(VAR_51 * sizeof(gid_t)); target_grouplist = lock_user(VERIFY_READ, arg2, VAR_51 * 4, 1); if (!target_grouplist) { ret = -TARGET_EFAULT; goto fail; } for(VAR_51 = 0;VAR_51 < VAR_51; VAR_51++) grouplist[VAR_51] = tswap32(target_grouplist[VAR_51]); unlock_user(target_grouplist, arg2, 0); ret = get_errno(setgroups(VAR_51, grouplist)); } break; #endif #ifdef TARGET_NR_fchown32 case TARGET_NR_fchown32: ret = get_errno(fchown(arg1, arg2, arg3)); break; #endif #ifdef TARGET_NR_setresuid32 case TARGET_NR_setresuid32: ret = get_errno(setresuid(arg1, arg2, arg3)); break; #endif #ifdef TARGET_NR_getresuid32 case TARGET_NR_getresuid32: { uid_t ruid, euid, suid; ret = get_errno(getresuid(&ruid, &euid, &suid)); if (!is_error(ret)) { if (put_user_u32(ruid, arg1) || put_user_u32(euid, arg2) || put_user_u32(suid, arg3)) goto efault; } } break; #endif #ifdef TARGET_NR_setresgid32 case TARGET_NR_setresgid32: ret = get_errno(setresgid(arg1, arg2, arg3)); break; #endif #ifdef TARGET_NR_getresgid32 case TARGET_NR_getresgid32: { gid_t rgid, egid, sgid; ret = get_errno(getresgid(&rgid, &egid, &sgid)); if (!is_error(ret)) { if (put_user_u32(rgid, arg1) || put_user_u32(egid, arg2) || put_user_u32(sgid, arg3)) goto efault; } } break; #endif #ifdef TARGET_NR_chown32 case TARGET_NR_chown32: if (!(VAR_2 = lock_user_string(arg1))) goto efault; ret = get_errno(chown(VAR_2, arg2, arg3)); unlock_user(VAR_2, arg1, 0); break; #endif #ifdef TARGET_NR_setuid32 case TARGET_NR_setuid32: ret = get_errno(setuid(arg1)); break; #endif #ifdef TARGET_NR_setgid32 case TARGET_NR_setgid32: ret = get_errno(setgid(arg1)); break; #endif #ifdef TARGET_NR_setfsuid32 case TARGET_NR_setfsuid32: ret = get_errno(setfsuid(arg1)); break; #endif #ifdef TARGET_NR_setfsgid32 case TARGET_NR_setfsgid32: ret = get_errno(setfsgid(arg1)); break; #endif case TARGET_NR_pivot_root: goto unimplemented; #ifdef TARGET_NR_mincore case TARGET_NR_mincore: { void *a; ret = -TARGET_EFAULT; if (!(a = lock_user(VERIFY_READ, arg1,arg2, 0))) goto efault; if (!(VAR_2 = lock_user_string(arg3))) goto mincore_fail; ret = get_errno(mincore(a, arg2, VAR_2)); unlock_user(VAR_2, arg3, ret); mincore_fail: unlock_user(a, arg1, 0); } break; #endif #ifdef TARGET_NR_arm_fadvise64_64 case TARGET_NR_arm_fadvise64_64: { abi_long VAR_24; VAR_24 = arg3; arg3 = arg4; arg4 = VAR_24; } #endif #if defined(TARGET_NR_fadvise64_64) || defined(TARGET_NR_arm_fadvise64_64) || defined(TARGET_NR_fadvise64) #ifdef TARGET_NR_fadvise64_64 case TARGET_NR_fadvise64_64: #endif #ifdef TARGET_NR_fadvise64 case TARGET_NR_fadvise64: #endif #ifdef TARGET_S390X switch (arg4) { case 4: arg4 = POSIX_FADV_NOREUSE + 1; break; case 5: arg4 = POSIX_FADV_NOREUSE + 2; break; case 6: arg4 = POSIX_FADV_DONTNEED; break; case 7: arg4 = POSIX_FADV_NOREUSE; break; default: break; } #endif ret = -posix_fadvise(arg1, arg2, arg3, arg4); break; #endif #ifdef TARGET_NR_madvise case TARGET_NR_madvise: ret = get_errno(0); break; #endif #if TARGET_ABI_BITS == 32 case TARGET_NR_fcntl64: { int cmd; struct flock64 fl; struct target_flock64 *target_fl; #ifdef TARGET_ARM struct target_eabi_flock64 *target_efl; #endif cmd = target_to_host_fcntl_cmd(arg2); if (cmd == -TARGET_EINVAL) { ret = cmd; break; } switch(arg2) { case TARGET_F_GETLK64: #ifdef TARGET_ARM if (((CPUARMState *)cpu_env)->eabi) { if (!lock_user_struct(VERIFY_READ, target_efl, arg3, 1)) goto efault; fl.l_type = tswap16(target_efl->l_type); fl.l_whence = tswap16(target_efl->l_whence); fl.l_start = tswap64(target_efl->l_start); fl.l_len = tswap64(target_efl->l_len); fl.l_pid = tswap32(target_efl->l_pid); unlock_user_struct(target_efl, arg3, 0); } else #endif { if (!lock_user_struct(VERIFY_READ, target_fl, arg3, 1)) goto efault; fl.l_type = tswap16(target_fl->l_type); fl.l_whence = tswap16(target_fl->l_whence); fl.l_start = tswap64(target_fl->l_start); fl.l_len = tswap64(target_fl->l_len); fl.l_pid = tswap32(target_fl->l_pid); unlock_user_struct(target_fl, arg3, 0); } ret = get_errno(fcntl(arg1, cmd, &fl)); if (ret == 0) { #ifdef TARGET_ARM if (((CPUARMState *)cpu_env)->eabi) { if (!lock_user_struct(VERIFY_WRITE, target_efl, arg3, 0)) goto efault; target_efl->l_type = tswap16(fl.l_type); target_efl->l_whence = tswap16(fl.l_whence); target_efl->l_start = tswap64(fl.l_start); target_efl->l_len = tswap64(fl.l_len); target_efl->l_pid = tswap32(fl.l_pid); unlock_user_struct(target_efl, arg3, 1); } else #endif { if (!lock_user_struct(VERIFY_WRITE, target_fl, arg3, 0)) goto efault; target_fl->l_type = tswap16(fl.l_type); target_fl->l_whence = tswap16(fl.l_whence); target_fl->l_start = tswap64(fl.l_start); target_fl->l_len = tswap64(fl.l_len); target_fl->l_pid = tswap32(fl.l_pid); unlock_user_struct(target_fl, arg3, 1); } } break; case TARGET_F_SETLK64: case TARGET_F_SETLKW64: #ifdef TARGET_ARM if (((CPUARMState *)cpu_env)->eabi) { if (!lock_user_struct(VERIFY_READ, target_efl, arg3, 1)) goto efault; fl.l_type = tswap16(target_efl->l_type); fl.l_whence = tswap16(target_efl->l_whence); fl.l_start = tswap64(target_efl->l_start); fl.l_len = tswap64(target_efl->l_len); fl.l_pid = tswap32(target_efl->l_pid); unlock_user_struct(target_efl, arg3, 0); } else #endif { if (!lock_user_struct(VERIFY_READ, target_fl, arg3, 1)) goto efault; fl.l_type = tswap16(target_fl->l_type); fl.l_whence = tswap16(target_fl->l_whence); fl.l_start = tswap64(target_fl->l_start); fl.l_len = tswap64(target_fl->l_len); fl.l_pid = tswap32(target_fl->l_pid); unlock_user_struct(target_fl, arg3, 0); } ret = get_errno(fcntl(arg1, cmd, &fl)); break; default: ret = do_fcntl(arg1, arg2, arg3); break; } break; } #endif #ifdef TARGET_NR_cacheflush case TARGET_NR_cacheflush: ret = 0; break; #endif #ifdef TARGET_NR_security case TARGET_NR_security: goto unimplemented; #endif #ifdef TARGET_NR_getpagesize case TARGET_NR_getpagesize: ret = TARGET_PAGE_SIZE; break; #endif case TARGET_NR_gettid: ret = get_errno(gettid()); break; #ifdef TARGET_NR_readahead case TARGET_NR_readahead: #if TARGET_ABI_BITS == 32 if (regpairs_aligned(cpu_env)) { arg2 = arg3; arg3 = arg4; arg4 = arg5; } ret = get_errno(readahead(arg1, ((off64_t)arg3 << 32) | arg2, arg4)); #else ret = get_errno(readahead(arg1, arg2, arg3)); #endif break; #endif #ifdef CONFIG_ATTR #ifdef TARGET_NR_setxattr case TARGET_NR_listxattr: case TARGET_NR_llistxattr: { void *VAR_2, *b = 0; if (arg2) { b = lock_user(VERIFY_WRITE, arg2, arg3, 0); if (!b) { ret = -TARGET_EFAULT; break; } } VAR_2 = lock_user_string(arg1); if (VAR_2) { if (num == TARGET_NR_listxattr) { ret = get_errno(listxattr(VAR_2, b, arg3)); } else { ret = get_errno(llistxattr(VAR_2, b, arg3)); } } else { ret = -TARGET_EFAULT; } unlock_user(VAR_2, arg1, 0); unlock_user(b, arg2, arg3); break; } case TARGET_NR_flistxattr: { void *b = 0; if (arg2) { b = lock_user(VERIFY_WRITE, arg2, arg3, 0); if (!b) { ret = -TARGET_EFAULT; break; } } ret = get_errno(flistxattr(arg1, b, arg3)); unlock_user(b, arg2, arg3); break; } case TARGET_NR_setxattr: case TARGET_NR_lsetxattr: { void *VAR_2, *n, *v = 0; if (arg3) { v = lock_user(VERIFY_READ, arg3, arg4, 1); if (!v) { ret = -TARGET_EFAULT; break; } } VAR_2 = lock_user_string(arg1); n = lock_user_string(arg2); if (VAR_2 && n) { if (num == TARGET_NR_setxattr) { ret = get_errno(setxattr(VAR_2, n, v, arg4, arg5)); } else { ret = get_errno(lsetxattr(VAR_2, n, v, arg4, arg5)); } } else { ret = -TARGET_EFAULT; } unlock_user(VAR_2, arg1, 0); unlock_user(n, arg2, 0); unlock_user(v, arg3, 0); } break; case TARGET_NR_fsetxattr: { void *n, *v = 0; if (arg3) { v = lock_user(VERIFY_READ, arg3, arg4, 1); if (!v) { ret = -TARGET_EFAULT; break; } } n = lock_user_string(arg2); if (n) { ret = get_errno(fsetxattr(arg1, n, v, arg4, arg5)); } else { ret = -TARGET_EFAULT; } unlock_user(n, arg2, 0); unlock_user(v, arg3, 0); } break; case TARGET_NR_getxattr: case TARGET_NR_lgetxattr: { void *VAR_2, *n, *v = 0; if (arg3) { v = lock_user(VERIFY_WRITE, arg3, arg4, 0); if (!v) { ret = -TARGET_EFAULT; break; } } VAR_2 = lock_user_string(arg1); n = lock_user_string(arg2); if (VAR_2 && n) { if (num == TARGET_NR_getxattr) { ret = get_errno(getxattr(VAR_2, n, v, arg4)); } else { ret = get_errno(lgetxattr(VAR_2, n, v, arg4)); } } else { ret = -TARGET_EFAULT; } unlock_user(VAR_2, arg1, 0); unlock_user(n, arg2, 0); unlock_user(v, arg3, arg4); } break; case TARGET_NR_fgetxattr: { void *n, *v = 0; if (arg3) { v = lock_user(VERIFY_WRITE, arg3, arg4, 0); if (!v) { ret = -TARGET_EFAULT; break; } } n = lock_user_string(arg2); if (n) { ret = get_errno(fgetxattr(arg1, n, v, arg4)); } else { ret = -TARGET_EFAULT; } unlock_user(n, arg2, 0); unlock_user(v, arg3, arg4); } break; case TARGET_NR_removexattr: case TARGET_NR_lremovexattr: { void *VAR_2, *n; VAR_2 = lock_user_string(arg1); n = lock_user_string(arg2); if (VAR_2 && n) { if (num == TARGET_NR_removexattr) { ret = get_errno(removexattr(VAR_2, n)); } else { ret = get_errno(lremovexattr(VAR_2, n)); } } else { ret = -TARGET_EFAULT; } unlock_user(VAR_2, arg1, 0); unlock_user(n, arg2, 0); } break; case TARGET_NR_fremovexattr: { void *n; n = lock_user_string(arg2); if (n) { ret = get_errno(fremovexattr(arg1, n)); } else { ret = -TARGET_EFAULT; } unlock_user(n, arg2, 0); } break; #endif #endif #ifdef TARGET_NR_set_thread_area case TARGET_NR_set_thread_area: #if defined(TARGET_MIPS) ((CPUMIPSState *) cpu_env)->tls_value = arg1; ret = 0; break; #elif defined(TARGET_CRIS) if (arg1 & 0xff) ret = -TARGET_EINVAL; else { ((CPUCRISState *) cpu_env)->pregs[PR_PID] = arg1; ret = 0; } break; #elif defined(TARGET_I386) && defined(TARGET_ABI32) ret = do_set_thread_area(cpu_env, arg1); break; #else goto unimplemented_nowarn; #endif #endif #ifdef TARGET_NR_get_thread_area case TARGET_NR_get_thread_area: #if defined(TARGET_I386) && defined(TARGET_ABI32) ret = do_get_thread_area(cpu_env, arg1); #else goto unimplemented_nowarn; #endif #endif #ifdef TARGET_NR_getdomainname case TARGET_NR_getdomainname: goto unimplemented_nowarn; #endif #ifdef TARGET_NR_clock_gettime case TARGET_NR_clock_gettime: { struct timespec VAR_45; ret = get_errno(clock_gettime(arg1, &VAR_45)); if (!is_error(ret)) { host_to_target_timespec(arg2, &VAR_45); } break; } #endif #ifdef TARGET_NR_clock_getres case TARGET_NR_clock_getres: { struct timespec VAR_45; ret = get_errno(clock_getres(arg1, &VAR_45)); if (!is_error(ret)) { host_to_target_timespec(arg2, &VAR_45); } break; } #endif #ifdef TARGET_NR_clock_nanosleep case TARGET_NR_clock_nanosleep: { struct timespec VAR_45; target_to_host_timespec(&VAR_45, arg3); ret = get_errno(clock_nanosleep(arg1, arg2, &VAR_45, arg4 ? &VAR_45 : NULL)); if (arg4) host_to_target_timespec(arg4, &VAR_45); break; } #endif #if defined(TARGET_NR_set_tid_address) && defined(__NR_set_tid_address) case TARGET_NR_set_tid_address: ret = get_errno(set_tid_address((int *)g2h(arg1))); break; #endif #if defined(TARGET_NR_tkill) && defined(__NR_tkill) case TARGET_NR_tkill: ret = get_errno(sys_tkill((int)arg1, target_to_host_signal(arg2))); break; #endif #if defined(TARGET_NR_tgkill) && defined(__NR_tgkill) case TARGET_NR_tgkill: ret = get_errno(sys_tgkill((int)arg1, (int)arg2, target_to_host_signal(arg3))); break; #endif #ifdef TARGET_NR_set_robust_list case TARGET_NR_set_robust_list: goto unimplemented_nowarn; #endif #if defined(TARGET_NR_utimensat) && defined(__NR_utimensat) case TARGET_NR_utimensat: { struct timespec *tsp, VAR_45[2]; if (!arg3) { tsp = NULL; } else { target_to_host_timespec(VAR_45, arg3); target_to_host_timespec(VAR_45+1, arg3+sizeof(struct target_timespec)); tsp = VAR_45; } if (!arg2) ret = get_errno(sys_utimensat(arg1, NULL, tsp, arg4)); else { if (!(VAR_2 = lock_user_string(arg2))) { ret = -TARGET_EFAULT; goto fail; } ret = get_errno(sys_utimensat(arg1, path(VAR_2), tsp, arg4)); unlock_user(VAR_2, arg2, 0); } } break; #endif #if defined(CONFIG_USE_NPTL) case TARGET_NR_futex: ret = do_futex(arg1, arg2, arg3, arg4, arg5, arg6); break; #endif #if defined(TARGET_NR_inotify_init) && defined(__NR_inotify_init) case TARGET_NR_inotify_init: ret = get_errno(sys_inotify_init()); break; #endif #ifdef CONFIG_INOTIFY1 #if defined(TARGET_NR_inotify_init1) && defined(__NR_inotify_init1) case TARGET_NR_inotify_init1: ret = get_errno(sys_inotify_init1(arg1)); break; #endif #endif #if defined(TARGET_NR_inotify_add_watch) && defined(__NR_inotify_add_watch) case TARGET_NR_inotify_add_watch: VAR_2 = lock_user_string(arg2); ret = get_errno(sys_inotify_add_watch(arg1, path(VAR_2), arg3)); unlock_user(VAR_2, arg2, 0); break; #endif #if defined(TARGET_NR_inotify_rm_watch) && defined(__NR_inotify_rm_watch) case TARGET_NR_inotify_rm_watch: ret = get_errno(sys_inotify_rm_watch(arg1, arg2)); break; #endif #if defined(TARGET_NR_mq_open) && defined(__NR_mq_open) case TARGET_NR_mq_open: { struct mq_attr posix_mq_attr; VAR_2 = lock_user_string(arg1 - 1); if (arg4 != 0) copy_from_user_mq_attr (&posix_mq_attr, arg4); ret = get_errno(mq_open(VAR_2, arg2, arg3, &posix_mq_attr)); unlock_user (VAR_2, arg1, 0); } break; case TARGET_NR_mq_unlink: VAR_2 = lock_user_string(arg1 - 1); ret = get_errno(mq_unlink(VAR_2)); unlock_user (VAR_2, arg1, 0); break; case TARGET_NR_mq_timedsend: { struct timespec VAR_45; VAR_2 = lock_user (VERIFY_READ, arg2, arg3, 1); if (arg5 != 0) { target_to_host_timespec(&VAR_45, arg5); ret = get_errno(mq_timedsend(arg1, VAR_2, arg3, arg4, &VAR_45)); host_to_target_timespec(arg5, &VAR_45); } else ret = get_errno(mq_send(arg1, VAR_2, arg3, arg4)); unlock_user (VAR_2, arg2, arg3); } break; case TARGET_NR_mq_timedreceive: { struct timespec VAR_45; unsigned int prio; VAR_2 = lock_user (VERIFY_READ, arg2, arg3, 1); if (arg5 != 0) { target_to_host_timespec(&VAR_45, arg5); ret = get_errno(mq_timedreceive(arg1, VAR_2, arg3, &prio, &VAR_45)); host_to_target_timespec(arg5, &VAR_45); } else ret = get_errno(mq_receive(arg1, VAR_2, arg3, &prio)); unlock_user (VAR_2, arg2, arg3); if (arg4 != 0) put_user_u32(prio, arg4); } break; case TARGET_NR_mq_getsetattr: { struct mq_attr posix_mq_attr_in, posix_mq_attr_out; ret = 0; if (arg3 != 0) { ret = mq_getattr(arg1, &posix_mq_attr_out); copy_to_user_mq_attr(arg3, &posix_mq_attr_out); } if (arg2 != 0) { copy_from_user_mq_attr(&posix_mq_attr_in, arg2); ret |= mq_setattr(arg1, &posix_mq_attr_in, &posix_mq_attr_out); } } break; #endif #ifdef CONFIG_SPLICE #ifdef TARGET_NR_tee case TARGET_NR_tee: { ret = get_errno(tee(arg1,arg2,arg3,arg4)); } break; #endif #ifdef TARGET_NR_splice case TARGET_NR_splice: { loff_t loff_in, loff_out; loff_t *ploff_in = NULL, *ploff_out = NULL; if(arg2) { get_user_u64(loff_in, arg2); ploff_in = &loff_in; } if(arg4) { get_user_u64(loff_out, arg2); ploff_out = &loff_out; } ret = get_errno(splice(arg1, ploff_in, arg3, ploff_out, arg5, arg6)); } break; #endif #ifdef TARGET_NR_vmsplice case TARGET_NR_vmsplice: { int VAR_41 = arg3; struct iovec *VAR_41; VAR_41 = alloca(VAR_41 * sizeof(struct iovec)); if (lock_iovec(VERIFY_READ, VAR_41, arg2, VAR_41, 1) < 0) goto efault; ret = get_errno(vmsplice(arg1, VAR_41, VAR_41, arg4)); unlock_iovec(VAR_41, arg2, VAR_41, 0); } break; #endif #endif #ifdef CONFIG_EVENTFD #if defined(TARGET_NR_eventfd) case TARGET_NR_eventfd: ret = get_errno(eventfd(arg1, 0)); break; #endif #if defined(TARGET_NR_eventfd2) case TARGET_NR_eventfd2: ret = get_errno(eventfd(arg1, arg2)); break; #endif #endif #if defined(CONFIG_FALLOCATE) && defined(TARGET_NR_fallocate) case TARGET_NR_fallocate: #if TARGET_ABI_BITS == 32 ret = get_errno(fallocate(arg1, arg2, target_offset64(arg3, arg4), target_offset64(arg5, arg6))); #else ret = get_errno(fallocate(arg1, arg2, arg3, arg4)); #endif break; #endif #if defined(CONFIG_SYNC_FILE_RANGE) #if defined(TARGET_NR_sync_file_range) case TARGET_NR_sync_file_range: #if TARGET_ABI_BITS == 32 #if defined(TARGET_MIPS) ret = get_errno(sync_file_range(arg1, target_offset64(arg3, arg4), target_offset64(arg5, arg6), arg7)); #else ret = get_errno(sync_file_range(arg1, target_offset64(arg2, arg3), target_offset64(arg4, arg5), arg6)); #endif #else ret = get_errno(sync_file_range(arg1, arg2, arg3, arg4)); #endif break; #endif #if defined(TARGET_NR_sync_file_range2) case TARGET_NR_sync_file_range2: #if TARGET_ABI_BITS == 32 ret = get_errno(sync_file_range(arg1, target_offset64(arg3, arg4), target_offset64(arg5, arg6), arg2)); #else ret = get_errno(sync_file_range(arg1, arg3, arg4, arg2)); #endif break; #endif #endif #if defined(CONFIG_EPOLL) #if defined(TARGET_NR_epoll_create) case TARGET_NR_epoll_create: ret = get_errno(epoll_create(arg1)); break; #endif #if defined(TARGET_NR_epoll_create1) && defined(CONFIG_EPOLL_CREATE1) case TARGET_NR_epoll_create1: ret = get_errno(epoll_create1(arg1)); break; #endif #if defined(TARGET_NR_epoll_ctl) case TARGET_NR_epoll_ctl: { struct epoll_event ep; struct epoll_event *epp = 0; if (arg4) { struct target_epoll_event *target_ep; if (!lock_user_struct(VERIFY_READ, target_ep, arg4, 1)) { goto efault; } ep.events = tswap32(target_ep->events); ep.data.u64 = tswap64(target_ep->data.u64); unlock_user_struct(target_ep, arg4, 0); epp = &ep; } ret = get_errno(epoll_ctl(arg1, arg2, arg3, epp)); break; } #endif #if defined(TARGET_NR_epoll_pwait) && defined(CONFIG_EPOLL_PWAIT) #define IMPLEMENT_EPOLL_PWAIT #endif #if defined(TARGET_NR_epoll_wait) || defined(IMPLEMENT_EPOLL_PWAIT) #if defined(TARGET_NR_epoll_wait) case TARGET_NR_epoll_wait: #endif #if defined(IMPLEMENT_EPOLL_PWAIT) case TARGET_NR_epoll_pwait: #endif { struct target_epoll_event *target_ep; struct epoll_event *ep; int epfd = arg1; int maxevents = arg3; int timeout = arg4; target_ep = lock_user(VERIFY_WRITE, arg2, maxevents * sizeof(struct target_epoll_event), 1); if (!target_ep) { goto efault; } ep = alloca(maxevents * sizeof(struct epoll_event)); switch (num) { #if defined(IMPLEMENT_EPOLL_PWAIT) case TARGET_NR_epoll_pwait: { target_sigset_t *target_set; sigset_t _set, *set = &_set; if (arg5) { target_set = lock_user(VERIFY_READ, arg5, sizeof(target_sigset_t), 1); if (!target_set) { unlock_user(target_ep, arg2, 0); goto efault; } target_to_host_sigset(set, target_set); unlock_user(target_set, arg5, 0); } else { set = NULL; } ret = get_errno(epoll_pwait(epfd, ep, maxevents, timeout, set)); break; } #endif #if defined(TARGET_NR_epoll_wait) case TARGET_NR_epoll_wait: ret = get_errno(epoll_wait(epfd, ep, maxevents, timeout)); break; #endif default: ret = -TARGET_ENOSYS; } if (!is_error(ret)) { int VAR_51; for (VAR_51 = 0; VAR_51 < ret; VAR_51++) { target_ep[VAR_51].events = tswap32(ep[VAR_51].events); target_ep[VAR_51].data.u64 = tswap64(ep[VAR_51].data.u64); } } unlock_user(target_ep, arg2, ret * sizeof(struct target_epoll_event)); break; } #endif #endif #ifdef TARGET_NR_prlimit64 case TARGET_NR_prlimit64: { struct target_rlimit64 *target_rnew, *target_rold; struct host_rlimit64 rnew, rold, *rnewp = 0; if (arg3) { if (!lock_user_struct(VERIFY_READ, target_rnew, arg3, 1)) { goto efault; } rnew.rlim_cur = tswap64(target_rnew->rlim_cur); rnew.rlim_max = tswap64(target_rnew->rlim_max); unlock_user_struct(target_rnew, arg3, 0); rnewp = &rnew; } ret = get_errno(sys_prlimit64(arg1, arg2, rnewp, arg4 ? &rold : 0)); if (!is_error(ret) && arg4) { if (!lock_user_struct(VERIFY_WRITE, target_rold, arg4, 1)) { goto efault; } target_rold->rlim_cur = tswap64(rold.rlim_cur); target_rold->rlim_max = tswap64(rold.rlim_max); unlock_user_struct(target_rold, arg4, 1); } break; } #endif default: unimplemented: gemu_log("qemu: Unsupported syscall: %d\n", num); #if defined(TARGET_NR_setxattr) || defined(TARGET_NR_get_thread_area) || defined(TARGET_NR_getdomainname) || defined(TARGET_NR_set_robust_list) unimplemented_nowarn: #endif ret = -TARGET_ENOSYS; break; } fail: #ifdef DEBUG gemu_log(" = " TARGET_ABI_FMT_ld "\n", ret); #endif if(do_strace) print_syscall_ret(num, ret); return ret; efault: ret = -TARGET_EFAULT; goto fail; }
[ "abi_long FUNC_0(void *cpu_env, int num, abi_long arg1,\nabi_long arg2, abi_long arg3, abi_long arg4,\nabi_long arg5, abi_long arg6, abi_long arg7,\nabi_long arg8)\n{", "abi_long ret;", "struct stat VAR_0;", "struct statfs VAR_1;", "void *VAR_2;", "#ifdef DEBUG\ngemu_log(\"syscall %d\", num);", "#endif\nif(do_strace)\nprint_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6);", "switch(num) {", "case TARGET_NR_exit:\n#ifdef CONFIG_USE_NPTL\nif (first_cpu->next_cpu) {", "TaskState *VAR_45;", "CPUArchState **lastp;", "CPUArchState *VAR_2;", "cpu_list_lock();", "lastp = &first_cpu;", "VAR_2 = first_cpu;", "while (VAR_2 && VAR_2 != (CPUArchState *)cpu_env) {", "lastp = &VAR_2->next_cpu;", "VAR_2 = VAR_2->next_cpu;", "}", "if (!VAR_2)\nabort();", "*lastp = VAR_2->next_cpu;", "cpu_list_unlock();", "VAR_45 = ((CPUArchState *)cpu_env)->opaque;", "if (VAR_45->child_tidptr) {", "put_user_u32(0, VAR_45->child_tidptr);", "sys_futex(g2h(VAR_45->child_tidptr), FUTEX_WAKE, INT_MAX,\nNULL, NULL, 0);", "}", "thread_env = NULL;", "object_delete(OBJECT(ENV_GET_CPU(cpu_env)));", "g_free(VAR_45);", "pthread_exit(NULL);", "}", "#endif\n#ifdef TARGET_GPROF\n_mcleanup();", "#endif\ngdb_exit(cpu_env, arg1);", "_exit(arg1);", "ret = 0;", "break;", "case TARGET_NR_read:\nif (arg3 == 0)\nret = 0;", "else {", "if (!(VAR_2 = lock_user(VERIFY_WRITE, arg2, arg3, 0)))\ngoto efault;", "ret = get_errno(read(arg1, VAR_2, arg3));", "unlock_user(VAR_2, arg2, ret);", "}", "break;", "case TARGET_NR_write:\nif (!(VAR_2 = lock_user(VERIFY_READ, arg2, arg3, 1)))\ngoto efault;", "ret = get_errno(write(arg1, VAR_2, arg3));", "unlock_user(VAR_2, arg2, 0);", "break;", "case TARGET_NR_open:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;", "ret = get_errno(do_open(cpu_env, VAR_2,\ntarget_to_host_bitmask(arg2, fcntl_flags_tbl),\narg3));", "unlock_user(VAR_2, arg1, 0);", "break;", "#if defined(TARGET_NR_openat) && defined(__NR_openat)\ncase TARGET_NR_openat:\nif (!(VAR_2 = lock_user_string(arg2)))\ngoto efault;", "ret = get_errno(sys_openat(arg1,\npath(VAR_2),\ntarget_to_host_bitmask(arg3, fcntl_flags_tbl),\narg4));", "unlock_user(VAR_2, arg2, 0);", "break;", "#endif\ncase TARGET_NR_close:\nret = get_errno(close(arg1));", "break;", "case TARGET_NR_brk:\nret = do_brk(arg1);", "break;", "case TARGET_NR_fork:\nret = get_errno(do_fork(cpu_env, SIGCHLD, 0, 0, 0, 0));", "break;", "#ifdef TARGET_NR_waitpid\ncase TARGET_NR_waitpid:\n{", "int VAR_31;", "ret = get_errno(waitpid(arg1, &VAR_31, arg3));", "if (!is_error(ret) && arg2 && ret\n&& put_user_s32(host_to_target_waitstatus(VAR_31), arg2))\ngoto efault;", "}", "break;", "#endif\n#ifdef TARGET_NR_waitid\ncase TARGET_NR_waitid:\n{", "siginfo_t info;", "info.si_pid = 0;", "ret = get_errno(waitid(arg1, arg2, &info, arg4));", "if (!is_error(ret) && arg3 && info.si_pid != 0) {", "if (!(VAR_2 = lock_user(VERIFY_WRITE, arg3, sizeof(target_siginfo_t), 0)))\ngoto efault;", "host_to_target_siginfo(VAR_2, &info);", "unlock_user(VAR_2, arg3, sizeof(target_siginfo_t));", "}", "}", "break;", "#endif\n#ifdef TARGET_NR_creat\ncase TARGET_NR_creat:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;", "ret = get_errno(creat(VAR_2, arg2));", "unlock_user(VAR_2, arg1, 0);", "break;", "#endif\ncase TARGET_NR_link:\n{", "void * VAR_24;", "VAR_2 = lock_user_string(arg1);", "VAR_24 = lock_user_string(arg2);", "if (!VAR_2 || !VAR_24)\nret = -TARGET_EFAULT;", "else\nret = get_errno(link(VAR_2, VAR_24));", "unlock_user(VAR_24, arg2, 0);", "unlock_user(VAR_2, arg1, 0);", "}", "break;", "#if defined(TARGET_NR_linkat) && defined(__NR_linkat)\ncase TARGET_NR_linkat:\n{", "void * VAR_24 = NULL;", "if (!arg2 || !arg4)\ngoto efault;", "VAR_2 = lock_user_string(arg2);", "VAR_24 = lock_user_string(arg4);", "if (!VAR_2 || !VAR_24)\nret = -TARGET_EFAULT;", "else\nret = get_errno(sys_linkat(arg1, VAR_2, arg3, VAR_24, arg5));", "unlock_user(VAR_2, arg2, 0);", "unlock_user(VAR_24, arg4, 0);", "}", "break;", "#endif\ncase TARGET_NR_unlink:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;", "ret = get_errno(unlink(VAR_2));", "unlock_user(VAR_2, arg1, 0);", "break;", "#if defined(TARGET_NR_unlinkat) && defined(__NR_unlinkat)\ncase TARGET_NR_unlinkat:\nif (!(VAR_2 = lock_user_string(arg2)))\ngoto efault;", "ret = get_errno(sys_unlinkat(arg1, VAR_2, arg3));", "unlock_user(VAR_2, arg2, 0);", "break;", "#endif\ncase TARGET_NR_execve:\n{", "char **VAR_4, **VAR_5;", "int VAR_6, VAR_7;", "abi_ulong gp;", "abi_ulong guest_argp;", "abi_ulong guest_envp;", "abi_ulong addr;", "char **VAR_8;", "int VAR_9 = 0;", "VAR_6 = 0;", "guest_argp = arg2;", "for (gp = guest_argp; gp; gp += sizeof(abi_ulong)) {", "if (get_user_ual(addr, gp))\ngoto efault;", "if (!addr)\nbreak;", "VAR_6++;", "}", "VAR_7 = 0;", "guest_envp = arg3;", "for (gp = guest_envp; gp; gp += sizeof(abi_ulong)) {", "if (get_user_ual(addr, gp))\ngoto efault;", "if (!addr)\nbreak;", "VAR_7++;", "}", "VAR_4 = alloca((VAR_6 + 1) * sizeof(void *));", "VAR_5 = alloca((VAR_7 + 1) * sizeof(void *));", "for (gp = guest_argp, VAR_8 = VAR_4; gp;", "gp += sizeof(abi_ulong), VAR_8++) {", "if (get_user_ual(addr, gp))\ngoto execve_efault;", "if (!addr)\nbreak;", "if (!(*VAR_8 = lock_user_string(addr)))\ngoto execve_efault;", "VAR_9 += strlen(*VAR_8) + 1;", "}", "*VAR_8 = NULL;", "for (gp = guest_envp, VAR_8 = VAR_5; gp;", "gp += sizeof(abi_ulong), VAR_8++) {", "if (get_user_ual(addr, gp))\ngoto execve_efault;", "if (!addr)\nbreak;", "if (!(*VAR_8 = lock_user_string(addr)))\ngoto execve_efault;", "VAR_9 += strlen(*VAR_8) + 1;", "}", "*VAR_8 = NULL;", "if (VAR_9 > MAX_ARG_PAGES * TARGET_PAGE_SIZE) {", "ret = -TARGET_E2BIG;", "goto execve_end;", "}", "if (!(VAR_2 = lock_user_string(arg1)))\ngoto execve_efault;", "ret = get_errno(execve(VAR_2, VAR_4, VAR_5));", "unlock_user(VAR_2, arg1, 0);", "goto execve_end;", "execve_efault:\nret = -TARGET_EFAULT;", "execve_end:\nfor (gp = guest_argp, VAR_8 = VAR_4; *VAR_8;", "gp += sizeof(abi_ulong), VAR_8++) {", "if (get_user_ual(addr, gp)\n|| !addr)\nbreak;", "unlock_user(*VAR_8, addr, 0);", "}", "for (gp = guest_envp, VAR_8 = VAR_5; *VAR_8;", "gp += sizeof(abi_ulong), VAR_8++) {", "if (get_user_ual(addr, gp)\n|| !addr)\nbreak;", "unlock_user(*VAR_8, addr, 0);", "}", "}", "break;", "case TARGET_NR_chdir:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;", "ret = get_errno(chdir(VAR_2));", "unlock_user(VAR_2, arg1, 0);", "break;", "#ifdef TARGET_NR_time\ncase TARGET_NR_time:\n{", "time_t host_time;", "ret = get_errno(time(&host_time));", "if (!is_error(ret)\n&& arg1\n&& put_user_sal(host_time, arg1))\ngoto efault;", "}", "break;", "#endif\ncase TARGET_NR_mknod:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;", "ret = get_errno(mknod(VAR_2, arg2, arg3));", "unlock_user(VAR_2, arg1, 0);", "break;", "#if defined(TARGET_NR_mknodat) && defined(__NR_mknodat)\ncase TARGET_NR_mknodat:\nif (!(VAR_2 = lock_user_string(arg2)))\ngoto efault;", "ret = get_errno(sys_mknodat(arg1, VAR_2, arg3, arg4));", "unlock_user(VAR_2, arg2, 0);", "break;", "#endif\ncase TARGET_NR_chmod:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;", "ret = get_errno(chmod(VAR_2, arg2));", "unlock_user(VAR_2, arg1, 0);", "break;", "#ifdef TARGET_NR_break\ncase TARGET_NR_break:\ngoto unimplemented;", "#endif\n#ifdef TARGET_NR_oldstat\ncase TARGET_NR_oldstat:\ngoto unimplemented;", "#endif\ncase TARGET_NR_lseek:\nret = get_errno(lseek(arg1, arg2, arg3));", "break;", "#if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA)\ncase TARGET_NR_getxpid:\n((CPUAlphaState *)cpu_env)->ir[IR_A4] = getppid();", "ret = get_errno(getpid());", "break;", "#endif\n#ifdef TARGET_NR_getpid\ncase TARGET_NR_getpid:\nret = get_errno(getpid());", "break;", "#endif\ncase TARGET_NR_mount:\n{", "void *VAR_24, *VAR_10;", "VAR_2 = lock_user_string(arg1);", "VAR_24 = lock_user_string(arg2);", "VAR_10 = lock_user_string(arg3);", "if (!VAR_2 || !VAR_24 || !VAR_10)\nret = -TARGET_EFAULT;", "else {", "if ( ! arg5 )\nret = get_errno(mount(VAR_2, VAR_24, VAR_10, (unsigned long)arg4, NULL));", "else\nret = get_errno(mount(VAR_2, VAR_24, VAR_10, (unsigned long)arg4, g2h(arg5)));", "}", "unlock_user(VAR_2, arg1, 0);", "unlock_user(VAR_24, arg2, 0);", "unlock_user(VAR_10, arg3, 0);", "break;", "}", "#ifdef TARGET_NR_umount\ncase TARGET_NR_umount:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;", "ret = get_errno(umount(VAR_2));", "unlock_user(VAR_2, arg1, 0);", "break;", "#endif\n#ifdef TARGET_NR_stime\ncase TARGET_NR_stime:\n{", "time_t host_time;", "if (get_user_sal(host_time, arg1))\ngoto efault;", "ret = get_errno(stime(&host_time));", "}", "break;", "#endif\ncase TARGET_NR_ptrace:\ngoto unimplemented;", "#ifdef TARGET_NR_alarm\ncase TARGET_NR_alarm:\nret = alarm(arg1);", "break;", "#endif\n#ifdef TARGET_NR_oldfstat\ncase TARGET_NR_oldfstat:\ngoto unimplemented;", "#endif\n#ifdef TARGET_NR_pause\ncase TARGET_NR_pause:\nret = get_errno(pause());", "break;", "#endif\n#ifdef TARGET_NR_utime\ncase TARGET_NR_utime:\n{", "struct utimbuf tbuf, *host_tbuf;", "struct target_utimbuf *target_tbuf;", "if (arg2) {", "if (!lock_user_struct(VERIFY_READ, target_tbuf, arg2, 1))\ngoto efault;", "tbuf.actime = tswapal(target_tbuf->actime);", "tbuf.modtime = tswapal(target_tbuf->modtime);", "unlock_user_struct(target_tbuf, arg2, 0);", "host_tbuf = &tbuf;", "} else {", "host_tbuf = NULL;", "}", "if (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;", "ret = get_errno(utime(VAR_2, host_tbuf));", "unlock_user(VAR_2, arg1, 0);", "}", "break;", "#endif\ncase TARGET_NR_utimes:\n{", "struct timeval *VAR_11, VAR_24[2];", "if (arg2) {", "if (copy_from_user_timeval(&VAR_24[0], arg2)\n|| copy_from_user_timeval(&VAR_24[1],\narg2 + sizeof(struct target_timeval)))\ngoto efault;", "VAR_11 = VAR_24;", "} else {", "VAR_11 = NULL;", "}", "if (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;", "ret = get_errno(utimes(VAR_2, VAR_11));", "unlock_user(VAR_2, arg1, 0);", "}", "break;", "#if defined(TARGET_NR_futimesat) && defined(__NR_futimesat)\ncase TARGET_NR_futimesat:\n{", "struct timeval *VAR_11, VAR_24[2];", "if (arg3) {", "if (copy_from_user_timeval(&VAR_24[0], arg3)\n|| copy_from_user_timeval(&VAR_24[1],\narg3 + sizeof(struct target_timeval)))\ngoto efault;", "VAR_11 = VAR_24;", "} else {", "VAR_11 = NULL;", "}", "if (!(VAR_2 = lock_user_string(arg2)))\ngoto efault;", "ret = get_errno(sys_futimesat(arg1, path(VAR_2), VAR_11));", "unlock_user(VAR_2, arg2, 0);", "}", "break;", "#endif\n#ifdef TARGET_NR_stty\ncase TARGET_NR_stty:\ngoto unimplemented;", "#endif\n#ifdef TARGET_NR_gtty\ncase TARGET_NR_gtty:\ngoto unimplemented;", "#endif\ncase TARGET_NR_access:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;", "ret = get_errno(access(path(VAR_2), arg2));", "unlock_user(VAR_2, arg1, 0);", "break;", "#if defined(TARGET_NR_faccessat) && defined(__NR_faccessat)\ncase TARGET_NR_faccessat:\nif (!(VAR_2 = lock_user_string(arg2)))\ngoto efault;", "ret = get_errno(sys_faccessat(arg1, VAR_2, arg3));", "unlock_user(VAR_2, arg2, 0);", "break;", "#endif\n#ifdef TARGET_NR_nice\ncase TARGET_NR_nice:\nret = get_errno(nice(arg1));", "break;", "#endif\n#ifdef TARGET_NR_ftime\ncase TARGET_NR_ftime:\ngoto unimplemented;", "#endif\ncase TARGET_NR_sync:\nsync();", "ret = 0;", "break;", "case TARGET_NR_kill:\nret = get_errno(kill(arg1, target_to_host_signal(arg2)));", "break;", "case TARGET_NR_rename:\n{", "void *VAR_24;", "VAR_2 = lock_user_string(arg1);", "VAR_24 = lock_user_string(arg2);", "if (!VAR_2 || !VAR_24)\nret = -TARGET_EFAULT;", "else\nret = get_errno(rename(VAR_2, VAR_24));", "unlock_user(VAR_24, arg2, 0);", "unlock_user(VAR_2, arg1, 0);", "}", "break;", "#if defined(TARGET_NR_renameat) && defined(__NR_renameat)\ncase TARGET_NR_renameat:\n{", "void *VAR_24;", "VAR_2 = lock_user_string(arg2);", "VAR_24 = lock_user_string(arg4);", "if (!VAR_2 || !VAR_24)\nret = -TARGET_EFAULT;", "else\nret = get_errno(sys_renameat(arg1, VAR_2, arg3, VAR_24));", "unlock_user(VAR_24, arg4, 0);", "unlock_user(VAR_2, arg2, 0);", "}", "break;", "#endif\ncase TARGET_NR_mkdir:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;", "ret = get_errno(mkdir(VAR_2, arg2));", "unlock_user(VAR_2, arg1, 0);", "break;", "#if defined(TARGET_NR_mkdirat) && defined(__NR_mkdirat)\ncase TARGET_NR_mkdirat:\nif (!(VAR_2 = lock_user_string(arg2)))\ngoto efault;", "ret = get_errno(sys_mkdirat(arg1, VAR_2, arg3));", "unlock_user(VAR_2, arg2, 0);", "break;", "#endif\ncase TARGET_NR_rmdir:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;", "ret = get_errno(rmdir(VAR_2));", "unlock_user(VAR_2, arg1, 0);", "break;", "case TARGET_NR_dup:\nret = get_errno(dup(arg1));", "break;", "case TARGET_NR_pipe:\nret = do_pipe(cpu_env, arg1, 0, 0);", "break;", "#ifdef TARGET_NR_pipe2\ncase TARGET_NR_pipe2:\nret = do_pipe(cpu_env, arg1,\ntarget_to_host_bitmask(arg2, fcntl_flags_tbl), 1);", "break;", "#endif\ncase TARGET_NR_times:\n{", "struct target_tms *VAR_13;", "struct VAR_14 VAR_14;", "ret = get_errno(times(&VAR_14));", "if (arg1) {", "VAR_13 = lock_user(VERIFY_WRITE, arg1, sizeof(struct target_tms), 0);", "if (!VAR_13)\ngoto efault;", "VAR_13->tms_utime = tswapal(host_to_target_clock_t(VAR_14.tms_utime));", "VAR_13->tms_stime = tswapal(host_to_target_clock_t(VAR_14.tms_stime));", "VAR_13->tms_cutime = tswapal(host_to_target_clock_t(VAR_14.tms_cutime));", "VAR_13->tms_cstime = tswapal(host_to_target_clock_t(VAR_14.tms_cstime));", "}", "if (!is_error(ret))\nret = host_to_target_clock_t(ret);", "}", "break;", "#ifdef TARGET_NR_prof\ncase TARGET_NR_prof:\ngoto unimplemented;", "#endif\n#ifdef TARGET_NR_signal\ncase TARGET_NR_signal:\ngoto unimplemented;", "#endif\ncase TARGET_NR_acct:\nif (arg1 == 0) {", "ret = get_errno(acct(NULL));", "} else {", "if (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;", "ret = get_errno(acct(path(VAR_2)));", "unlock_user(VAR_2, arg1, 0);", "}", "break;", "#ifdef TARGET_NR_umount2\ncase TARGET_NR_umount2:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;", "ret = get_errno(umount2(VAR_2, arg2));", "unlock_user(VAR_2, arg1, 0);", "break;", "#endif\n#ifdef TARGET_NR_lock\ncase TARGET_NR_lock:\ngoto unimplemented;", "#endif\ncase TARGET_NR_ioctl:\nret = do_ioctl(arg1, arg2, arg3);", "break;", "case TARGET_NR_fcntl:\nret = do_fcntl(arg1, arg2, arg3);", "break;", "#ifdef TARGET_NR_mpx\ncase TARGET_NR_mpx:\ngoto unimplemented;", "#endif\ncase TARGET_NR_setpgid:\nret = get_errno(setpgid(arg1, arg2));", "break;", "#ifdef TARGET_NR_ulimit\ncase TARGET_NR_ulimit:\ngoto unimplemented;", "#endif\n#ifdef TARGET_NR_oldolduname\ncase TARGET_NR_oldolduname:\ngoto unimplemented;", "#endif\ncase TARGET_NR_umask:\nret = get_errno(umask(arg1));", "break;", "case TARGET_NR_chroot:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;", "ret = get_errno(chroot(VAR_2));", "unlock_user(VAR_2, arg1, 0);", "break;", "case TARGET_NR_ustat:\ngoto unimplemented;", "case TARGET_NR_dup2:\nret = get_errno(dup2(arg1, arg2));", "break;", "#if defined(CONFIG_DUP3) && defined(TARGET_NR_dup3)\ncase TARGET_NR_dup3:\nret = get_errno(dup3(arg1, arg2, arg3));", "break;", "#endif\n#ifdef TARGET_NR_getppid\ncase TARGET_NR_getppid:\nret = get_errno(getppid());", "break;", "#endif\ncase TARGET_NR_getpgrp:\nret = get_errno(getpgrp());", "break;", "case TARGET_NR_setsid:\nret = get_errno(setsid());", "break;", "#ifdef TARGET_NR_sigaction\ncase TARGET_NR_sigaction:\n{", "#if defined(TARGET_ALPHA)\nstruct target_sigaction VAR_15, VAR_16, *pact = 0;", "struct target_old_sigaction *old_act;", "if (arg2) {", "if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1))\ngoto efault;", "VAR_15._sa_handler = old_act->_sa_handler;", "target_siginitset(&VAR_15.sa_mask, old_act->sa_mask);", "VAR_15.sa_flags = old_act->sa_flags;", "VAR_15.sa_restorer = 0;", "unlock_user_struct(old_act, arg2, 0);", "pact = &VAR_15;", "}", "ret = get_errno(do_sigaction(arg1, pact, &VAR_16));", "if (!is_error(ret) && arg3) {", "if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0))\ngoto efault;", "old_act->_sa_handler = VAR_16._sa_handler;", "old_act->sa_mask = VAR_16.sa_mask.sig[0];", "old_act->sa_flags = VAR_16.sa_flags;", "unlock_user_struct(old_act, arg3, 1);", "}", "#elif defined(TARGET_MIPS)\nstruct target_sigaction VAR_15, VAR_16, *pact, *old_act;", "if (arg2) {", "if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1))\ngoto efault;", "VAR_15._sa_handler = old_act->_sa_handler;", "target_siginitset(&VAR_15.sa_mask, old_act->sa_mask.sig[0]);", "VAR_15.sa_flags = old_act->sa_flags;", "unlock_user_struct(old_act, arg2, 0);", "pact = &VAR_15;", "} else {", "pact = NULL;", "}", "ret = get_errno(do_sigaction(arg1, pact, &VAR_16));", "if (!is_error(ret) && arg3) {", "if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0))\ngoto efault;", "old_act->_sa_handler = VAR_16._sa_handler;", "old_act->sa_flags = VAR_16.sa_flags;", "old_act->sa_mask.sig[0] = VAR_16.sa_mask.sig[0];", "old_act->sa_mask.sig[1] = 0;", "old_act->sa_mask.sig[2] = 0;", "old_act->sa_mask.sig[3] = 0;", "unlock_user_struct(old_act, arg3, 1);", "}", "#else\nstruct target_old_sigaction *old_act;", "struct target_sigaction VAR_15, VAR_16, *pact;", "if (arg2) {", "if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1))\ngoto efault;", "VAR_15._sa_handler = old_act->_sa_handler;", "target_siginitset(&VAR_15.sa_mask, old_act->sa_mask);", "VAR_15.sa_flags = old_act->sa_flags;", "VAR_15.sa_restorer = old_act->sa_restorer;", "unlock_user_struct(old_act, arg2, 0);", "pact = &VAR_15;", "} else {", "pact = NULL;", "}", "ret = get_errno(do_sigaction(arg1, pact, &VAR_16));", "if (!is_error(ret) && arg3) {", "if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0))\ngoto efault;", "old_act->_sa_handler = VAR_16._sa_handler;", "old_act->sa_mask = VAR_16.sa_mask.sig[0];", "old_act->sa_flags = VAR_16.sa_flags;", "old_act->sa_restorer = VAR_16.sa_restorer;", "unlock_user_struct(old_act, arg3, 1);", "}", "#endif\n}", "break;", "#endif\ncase TARGET_NR_rt_sigaction:\n{", "#if defined(TARGET_ALPHA)\nstruct target_sigaction VAR_15, VAR_16, *pact = 0;", "struct target_rt_sigaction *rt_act;", "if (arg2) {", "if (!lock_user_struct(VERIFY_READ, rt_act, arg2, 1))\ngoto efault;", "VAR_15._sa_handler = rt_act->_sa_handler;", "VAR_15.sa_mask = rt_act->sa_mask;", "VAR_15.sa_flags = rt_act->sa_flags;", "VAR_15.sa_restorer = arg5;", "unlock_user_struct(rt_act, arg2, 0);", "pact = &VAR_15;", "}", "ret = get_errno(do_sigaction(arg1, pact, &VAR_16));", "if (!is_error(ret) && arg3) {", "if (!lock_user_struct(VERIFY_WRITE, rt_act, arg3, 0))\ngoto efault;", "rt_act->_sa_handler = VAR_16._sa_handler;", "rt_act->sa_mask = VAR_16.sa_mask;", "rt_act->sa_flags = VAR_16.sa_flags;", "unlock_user_struct(rt_act, arg3, 1);", "}", "#else\nstruct target_sigaction *VAR_15;", "struct target_sigaction *VAR_16;", "if (arg2) {", "if (!lock_user_struct(VERIFY_READ, VAR_15, arg2, 1))\ngoto efault;", "} else", "VAR_15 = NULL;", "if (arg3) {", "if (!lock_user_struct(VERIFY_WRITE, VAR_16, arg3, 0)) {", "ret = -TARGET_EFAULT;", "goto rt_sigaction_fail;", "}", "} else", "VAR_16 = NULL;", "ret = get_errno(do_sigaction(arg1, VAR_15, VAR_16));", "rt_sigaction_fail:\nif (VAR_15)\nunlock_user_struct(VAR_15, arg2, 0);", "if (VAR_16)\nunlock_user_struct(VAR_16, arg3, 1);", "#endif\n}", "break;", "#ifdef TARGET_NR_sgetmask\ncase TARGET_NR_sgetmask:\n{", "sigset_t cur_set;", "abi_ulong target_set;", "sigprocmask(0, NULL, &cur_set);", "host_to_target_old_sigset(&target_set, &cur_set);", "ret = target_set;", "}", "break;", "#endif\n#ifdef TARGET_NR_ssetmask\ncase TARGET_NR_ssetmask:\n{", "sigset_t set, oset, cur_set;", "abi_ulong target_set = arg1;", "sigprocmask(0, NULL, &cur_set);", "target_to_host_old_sigset(&set, &target_set);", "sigorset(&set, &set, &cur_set);", "sigprocmask(SIG_SETMASK, &set, &oset);", "host_to_target_old_sigset(&target_set, &oset);", "ret = target_set;", "}", "break;", "#endif\n#ifdef TARGET_NR_sigprocmask\ncase TARGET_NR_sigprocmask:\n{", "#if defined(TARGET_ALPHA)\nsigset_t set, oldset;", "abi_ulong VAR_43;", "int VAR_17;", "switch (arg1) {", "case TARGET_SIG_BLOCK:\nVAR_17 = SIG_BLOCK;", "break;", "case TARGET_SIG_UNBLOCK:\nVAR_17 = SIG_UNBLOCK;", "break;", "case TARGET_SIG_SETMASK:\nVAR_17 = SIG_SETMASK;", "break;", "default:\nret = -TARGET_EINVAL;", "goto fail;", "}", "VAR_43 = arg2;", "target_to_host_old_sigset(&set, &VAR_43);", "ret = get_errno(sigprocmask(VAR_17, &set, &oldset));", "if (!is_error(ret)) {", "host_to_target_old_sigset(&VAR_43, &oldset);", "ret = VAR_43;", "((CPUAlphaState *)cpu_env)->ir[IR_V0] = 0;", "}", "#else\nsigset_t set, oldset, *set_ptr;", "int VAR_17;", "if (arg2) {", "switch (arg1) {", "case TARGET_SIG_BLOCK:\nVAR_17 = SIG_BLOCK;", "break;", "case TARGET_SIG_UNBLOCK:\nVAR_17 = SIG_UNBLOCK;", "break;", "case TARGET_SIG_SETMASK:\nVAR_17 = SIG_SETMASK;", "break;", "default:\nret = -TARGET_EINVAL;", "goto fail;", "}", "if (!(VAR_2 = lock_user(VERIFY_READ, arg2, sizeof(target_sigset_t), 1)))\ngoto efault;", "target_to_host_old_sigset(&set, VAR_2);", "unlock_user(VAR_2, arg2, 0);", "set_ptr = &set;", "} else {", "VAR_17 = 0;", "set_ptr = NULL;", "}", "ret = get_errno(sigprocmask(VAR_17, set_ptr, &oldset));", "if (!is_error(ret) && arg3) {", "if (!(VAR_2 = lock_user(VERIFY_WRITE, arg3, sizeof(target_sigset_t), 0)))\ngoto efault;", "host_to_target_old_sigset(VAR_2, &oldset);", "unlock_user(VAR_2, arg3, sizeof(target_sigset_t));", "}", "#endif\n}", "break;", "#endif\ncase TARGET_NR_rt_sigprocmask:\n{", "int VAR_17 = arg1;", "sigset_t set, oldset, *set_ptr;", "if (arg2) {", "switch(VAR_17) {", "case TARGET_SIG_BLOCK:\nVAR_17 = SIG_BLOCK;", "break;", "case TARGET_SIG_UNBLOCK:\nVAR_17 = SIG_UNBLOCK;", "break;", "case TARGET_SIG_SETMASK:\nVAR_17 = SIG_SETMASK;", "break;", "default:\nret = -TARGET_EINVAL;", "goto fail;", "}", "if (!(VAR_2 = lock_user(VERIFY_READ, arg2, sizeof(target_sigset_t), 1)))\ngoto efault;", "target_to_host_sigset(&set, VAR_2);", "unlock_user(VAR_2, arg2, 0);", "set_ptr = &set;", "} else {", "VAR_17 = 0;", "set_ptr = NULL;", "}", "ret = get_errno(sigprocmask(VAR_17, set_ptr, &oldset));", "if (!is_error(ret) && arg3) {", "if (!(VAR_2 = lock_user(VERIFY_WRITE, arg3, sizeof(target_sigset_t), 0)))\ngoto efault;", "host_to_target_sigset(VAR_2, &oldset);", "unlock_user(VAR_2, arg3, sizeof(target_sigset_t));", "}", "}", "break;", "#ifdef TARGET_NR_sigpending\ncase TARGET_NR_sigpending:\n{", "sigset_t set;", "ret = get_errno(sigpending(&set));", "if (!is_error(ret)) {", "if (!(VAR_2 = lock_user(VERIFY_WRITE, arg1, sizeof(target_sigset_t), 0)))\ngoto efault;", "host_to_target_old_sigset(VAR_2, &set);", "unlock_user(VAR_2, arg1, sizeof(target_sigset_t));", "}", "}", "break;", "#endif\ncase TARGET_NR_rt_sigpending:\n{", "sigset_t set;", "ret = get_errno(sigpending(&set));", "if (!is_error(ret)) {", "if (!(VAR_2 = lock_user(VERIFY_WRITE, arg1, sizeof(target_sigset_t), 0)))\ngoto efault;", "host_to_target_sigset(VAR_2, &set);", "unlock_user(VAR_2, arg1, sizeof(target_sigset_t));", "}", "}", "break;", "#ifdef TARGET_NR_sigsuspend\ncase TARGET_NR_sigsuspend:\n{", "sigset_t set;", "#if defined(TARGET_ALPHA)\nabi_ulong VAR_43 = arg1;", "target_to_host_old_sigset(&set, &VAR_43);", "#else\nif (!(VAR_2 = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1)))\ngoto efault;", "target_to_host_old_sigset(&set, VAR_2);", "unlock_user(VAR_2, arg1, 0);", "#endif\nret = get_errno(sigsuspend(&set));", "}", "break;", "#endif\ncase TARGET_NR_rt_sigsuspend:\n{", "sigset_t set;", "if (!(VAR_2 = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1)))\ngoto efault;", "target_to_host_sigset(&set, VAR_2);", "unlock_user(VAR_2, arg1, 0);", "ret = get_errno(sigsuspend(&set));", "}", "break;", "case TARGET_NR_rt_sigtimedwait:\n{", "sigset_t set;", "struct timespec VAR_18, *VAR_19;", "siginfo_t uinfo;", "if (!(VAR_2 = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1)))\ngoto efault;", "target_to_host_sigset(&set, VAR_2);", "unlock_user(VAR_2, arg1, 0);", "if (arg3) {", "VAR_19 = &VAR_18;", "target_to_host_timespec(VAR_19, arg3);", "} else {", "VAR_19 = NULL;", "}", "ret = get_errno(sigtimedwait(&set, &uinfo, VAR_19));", "if (!is_error(ret) && arg2) {", "if (!(VAR_2 = lock_user(VERIFY_WRITE, arg2, sizeof(target_siginfo_t), 0)))\ngoto efault;", "host_to_target_siginfo(VAR_2, &uinfo);", "unlock_user(VAR_2, arg2, sizeof(target_siginfo_t));", "}", "}", "break;", "case TARGET_NR_rt_sigqueueinfo:\n{", "siginfo_t uinfo;", "if (!(VAR_2 = lock_user(VERIFY_READ, arg3, sizeof(target_sigset_t), 1)))\ngoto efault;", "target_to_host_siginfo(&uinfo, VAR_2);", "unlock_user(VAR_2, arg1, 0);", "ret = get_errno(sys_rt_sigqueueinfo(arg1, arg2, &uinfo));", "}", "break;", "#ifdef TARGET_NR_sigreturn\ncase TARGET_NR_sigreturn:\nret = do_sigreturn(cpu_env);", "break;", "#endif\ncase TARGET_NR_rt_sigreturn:\nret = do_rt_sigreturn(cpu_env);", "break;", "case TARGET_NR_sethostname:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;", "ret = get_errno(sethostname(VAR_2, arg2));", "unlock_user(VAR_2, arg1, 0);", "break;", "case TARGET_NR_setrlimit:\n{", "int VAR_23 = target_to_host_resource(arg1);", "struct target_rlimit *VAR_23;", "struct rlimit VAR_23;", "if (!lock_user_struct(VERIFY_READ, VAR_23, arg2, 1))\ngoto efault;", "VAR_23.rlim_cur = target_to_host_rlim(VAR_23->rlim_cur);", "VAR_23.rlim_max = target_to_host_rlim(VAR_23->rlim_max);", "unlock_user_struct(VAR_23, arg2, 0);", "ret = get_errno(setrlimit(VAR_23, &VAR_23));", "}", "break;", "case TARGET_NR_getrlimit:\n{", "int VAR_23 = target_to_host_resource(arg1);", "struct target_rlimit *VAR_23;", "struct rlimit VAR_23;", "ret = get_errno(getrlimit(VAR_23, &VAR_23));", "if (!is_error(ret)) {", "if (!lock_user_struct(VERIFY_WRITE, VAR_23, arg2, 0))\ngoto efault;", "VAR_23->rlim_cur = host_to_target_rlim(VAR_23.rlim_cur);", "VAR_23->rlim_max = host_to_target_rlim(VAR_23.rlim_max);", "unlock_user_struct(VAR_23, arg2, 1);", "}", "}", "break;", "case TARGET_NR_getrusage:\n{", "struct VAR_32 VAR_32;", "ret = get_errno(getrusage(arg1, &VAR_32));", "if (!is_error(ret)) {", "host_to_target_rusage(arg2, &VAR_32);", "}", "}", "break;", "case TARGET_NR_gettimeofday:\n{", "struct timeval VAR_24;", "ret = get_errno(gettimeofday(&VAR_24, NULL));", "if (!is_error(ret)) {", "if (copy_to_user_timeval(arg1, &VAR_24))\ngoto efault;", "}", "}", "break;", "case TARGET_NR_settimeofday:\n{", "struct timeval VAR_24;", "if (copy_from_user_timeval(&VAR_24, arg1))\ngoto efault;", "ret = get_errno(settimeofday(&VAR_24, NULL));", "}", "break;", "#if defined(TARGET_NR_select) && !defined(TARGET_S390X) && !defined(TARGET_S390)\ncase TARGET_NR_select:\n{", "struct target_sel_arg_struct *sel;", "abi_ulong inp, outp, exp, VAR_11;", "long nsel;", "if (!lock_user_struct(VERIFY_READ, sel, arg1, 1))\ngoto efault;", "nsel = tswapal(sel->n);", "inp = tswapal(sel->inp);", "outp = tswapal(sel->outp);", "exp = tswapal(sel->exp);", "VAR_11 = tswapal(sel->VAR_11);", "unlock_user_struct(sel, arg1, 0);", "ret = do_select(nsel, inp, outp, exp, VAR_11);", "}", "break;", "#endif\n#ifdef TARGET_NR_pselect6\ncase TARGET_NR_pselect6:\n{", "abi_long rfd_addr, wfd_addr, efd_addr, n, ts_addr;", "fd_set rfds, wfds, efds;", "fd_set *rfds_ptr, *wfds_ptr, *efds_ptr;", "struct timespec VAR_45, *ts_ptr;", "sigset_t set;", "struct {", "sigset_t *set;", "size_t size;", "} sig, *sig_ptr;", "abi_ulong arg_sigset, arg_sigsize, *arg7;", "target_sigset_t *target_sigset;", "n = arg1;", "rfd_addr = arg2;", "wfd_addr = arg3;", "efd_addr = arg4;", "ts_addr = arg5;", "ret = copy_from_user_fdset_ptr(&rfds, &rfds_ptr, rfd_addr, n);", "if (ret) {", "goto fail;", "}", "ret = copy_from_user_fdset_ptr(&wfds, &wfds_ptr, wfd_addr, n);", "if (ret) {", "goto fail;", "}", "ret = copy_from_user_fdset_ptr(&efds, &efds_ptr, efd_addr, n);", "if (ret) {", "goto fail;", "}", "if (ts_addr) {", "if (target_to_host_timespec(&VAR_45, ts_addr)) {", "goto efault;", "}", "ts_ptr = &VAR_45;", "} else {", "ts_ptr = NULL;", "}", "if (arg6) {", "sig_ptr = &sig;", "sig.size = _NSIG / 8;", "arg7 = lock_user(VERIFY_READ, arg6, sizeof(*arg7) * 2, 1);", "if (!arg7) {", "goto efault;", "}", "arg_sigset = tswapal(arg7[0]);", "arg_sigsize = tswapal(arg7[1]);", "unlock_user(arg7, arg6, 0);", "if (arg_sigset) {", "sig.set = &set;", "if (arg_sigsize != sizeof(*target_sigset)) {", "ret = -TARGET_EINVAL;", "goto fail;", "}", "target_sigset = lock_user(VERIFY_READ, arg_sigset,\nsizeof(*target_sigset), 1);", "if (!target_sigset) {", "goto efault;", "}", "target_to_host_sigset(&set, target_sigset);", "unlock_user(target_sigset, arg_sigset, 0);", "} else {", "sig.set = NULL;", "}", "} else {", "sig_ptr = NULL;", "}", "ret = get_errno(sys_pselect6(n, rfds_ptr, wfds_ptr, efds_ptr,\nts_ptr, sig_ptr));", "if (!is_error(ret)) {", "if (rfd_addr && copy_to_user_fdset(rfd_addr, &rfds, n))\ngoto efault;", "if (wfd_addr && copy_to_user_fdset(wfd_addr, &wfds, n))\ngoto efault;", "if (efd_addr && copy_to_user_fdset(efd_addr, &efds, n))\ngoto efault;", "if (ts_addr && host_to_target_timespec(ts_addr, &VAR_45))\ngoto efault;", "}", "}", "break;", "#endif\ncase TARGET_NR_symlink:\n{", "void *VAR_24;", "VAR_2 = lock_user_string(arg1);", "VAR_24 = lock_user_string(arg2);", "if (!VAR_2 || !VAR_24)\nret = -TARGET_EFAULT;", "else\nret = get_errno(symlink(VAR_2, VAR_24));", "unlock_user(VAR_24, arg2, 0);", "unlock_user(VAR_2, arg1, 0);", "}", "break;", "#if defined(TARGET_NR_symlinkat) && defined(__NR_symlinkat)\ncase TARGET_NR_symlinkat:\n{", "void *VAR_24;", "VAR_2 = lock_user_string(arg1);", "VAR_24 = lock_user_string(arg3);", "if (!VAR_2 || !VAR_24)\nret = -TARGET_EFAULT;", "else\nret = get_errno(sys_symlinkat(VAR_2, arg2, VAR_24));", "unlock_user(VAR_24, arg3, 0);", "unlock_user(VAR_2, arg1, 0);", "}", "break;", "#endif\n#ifdef TARGET_NR_oldlstat\ncase TARGET_NR_oldlstat:\ngoto unimplemented;", "#endif\ncase TARGET_NR_readlink:\n{", "void *VAR_24, *VAR_24;", "VAR_2 = lock_user_string(arg1);", "VAR_24 = lock_user(VERIFY_WRITE, arg2, arg3, 0);", "if (!VAR_2 || !VAR_24)\nret = -TARGET_EFAULT;", "else {", "if (strncmp((const char *)VAR_2, \"/proc/self/exe\", 14) == 0) {", "char VAR_25[PATH_MAX];", "VAR_24 = realpath(exec_path,VAR_25);", "ret = (VAR_24==NULL) ? get_errno(-1) : strlen(VAR_25) ;", "snprintf((char *)VAR_24, arg3, \"%s\", VAR_25);", "}", "else\nret = get_errno(readlink(path(VAR_2), VAR_24, arg3));", "}", "unlock_user(VAR_24, arg2, ret);", "unlock_user(VAR_2, arg1, 0);", "}", "break;", "#if defined(TARGET_NR_readlinkat) && defined(__NR_readlinkat)\ncase TARGET_NR_readlinkat:\n{", "void *VAR_24;", "VAR_2 = lock_user_string(arg2);", "VAR_24 = lock_user(VERIFY_WRITE, arg3, arg4, 0);", "if (!VAR_2 || !VAR_24)\nret = -TARGET_EFAULT;", "else\nret = get_errno(sys_readlinkat(arg1, path(VAR_2), VAR_24, arg4));", "unlock_user(VAR_24, arg3, ret);", "unlock_user(VAR_2, arg2, 0);", "}", "break;", "#endif\n#ifdef TARGET_NR_uselib\ncase TARGET_NR_uselib:\ngoto unimplemented;", "#endif\n#ifdef TARGET_NR_swapon\ncase TARGET_NR_swapon:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;", "ret = get_errno(swapon(VAR_2, arg2));", "unlock_user(VAR_2, arg1, 0);", "break;", "#endif\ncase TARGET_NR_reboot:\nif (!(VAR_2 = lock_user_string(arg4)))\ngoto efault;", "ret = reboot(arg1, arg2, arg3, VAR_2);", "unlock_user(VAR_2, arg4, 0);", "break;", "#ifdef TARGET_NR_readdir\ncase TARGET_NR_readdir:\ngoto unimplemented;", "#endif\n#ifdef TARGET_NR_mmap\ncase TARGET_NR_mmap:\n#if (defined(TARGET_I386) && defined(TARGET_ABI32)) || defined(TARGET_ARM) || \\\ndefined(TARGET_M68K) || defined(TARGET_CRIS) || defined(TARGET_MICROBLAZE) \\\n|| defined(TARGET_S390X)\n{", "abi_ulong *v;", "abi_ulong v1, v2, v3, v4, v5, v6;", "if (!(v = lock_user(VERIFY_READ, arg1, 6 * sizeof(abi_ulong), 1)))\ngoto efault;", "v1 = tswapal(v[0]);", "v2 = tswapal(v[1]);", "v3 = tswapal(v[2]);", "v4 = tswapal(v[3]);", "v5 = tswapal(v[4]);", "v6 = tswapal(v[5]);", "unlock_user(v, arg1, 0);", "ret = get_errno(target_mmap(v1, v2, v3,\ntarget_to_host_bitmask(v4, mmap_flags_tbl),\nv5, v6));", "}", "#else\nret = get_errno(target_mmap(arg1, arg2, arg3,\ntarget_to_host_bitmask(arg4, mmap_flags_tbl),\narg5,\narg6));", "#endif\nbreak;", "#endif\n#ifdef TARGET_NR_mmap2\ncase TARGET_NR_mmap2:\n#ifndef MMAP_SHIFT\n#define MMAP_SHIFT 12\n#endif\nret = get_errno(target_mmap(arg1, arg2, arg3,\ntarget_to_host_bitmask(arg4, mmap_flags_tbl),\narg5,\narg6 << MMAP_SHIFT));", "break;", "#endif\ncase TARGET_NR_munmap:\nret = get_errno(target_munmap(arg1, arg2));", "break;", "case TARGET_NR_mprotect:\n{", "TaskState *VAR_45 = ((CPUArchState *)cpu_env)->opaque;", "if ((arg3 & PROT_GROWSDOWN)\n&& arg1 >= VAR_45->info->stack_limit\n&& arg1 <= VAR_45->info->start_stack) {", "arg3 &= ~PROT_GROWSDOWN;", "arg2 = arg2 + arg1 - VAR_45->info->stack_limit;", "arg1 = VAR_45->info->stack_limit;", "}", "}", "ret = get_errno(target_mprotect(arg1, arg2, arg3));", "break;", "#ifdef TARGET_NR_mremap\ncase TARGET_NR_mremap:\nret = get_errno(target_mremap(arg1, arg2, arg3, arg4, arg5));", "break;", "#endif\n#ifdef TARGET_NR_msync\ncase TARGET_NR_msync:\nret = get_errno(msync(g2h(arg1), arg2, arg3));", "break;", "#endif\n#ifdef TARGET_NR_mlock\ncase TARGET_NR_mlock:\nret = get_errno(mlock(g2h(arg1), arg2));", "break;", "#endif\n#ifdef TARGET_NR_munlock\ncase TARGET_NR_munlock:\nret = get_errno(munlock(g2h(arg1), arg2));", "break;", "#endif\n#ifdef TARGET_NR_mlockall\ncase TARGET_NR_mlockall:\nret = get_errno(mlockall(arg1));", "break;", "#endif\n#ifdef TARGET_NR_munlockall\ncase TARGET_NR_munlockall:\nret = get_errno(munlockall());", "break;", "#endif\ncase TARGET_NR_truncate:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;", "ret = get_errno(truncate(VAR_2, arg2));", "unlock_user(VAR_2, arg1, 0);", "break;", "case TARGET_NR_ftruncate:\nret = get_errno(ftruncate(arg1, arg2));", "break;", "case TARGET_NR_fchmod:\nret = get_errno(fchmod(arg1, arg2));", "break;", "#if defined(TARGET_NR_fchmodat) && defined(__NR_fchmodat)\ncase TARGET_NR_fchmodat:\nif (!(VAR_2 = lock_user_string(arg2)))\ngoto efault;", "ret = get_errno(sys_fchmodat(arg1, VAR_2, arg3));", "unlock_user(VAR_2, arg2, 0);", "break;", "#endif\ncase TARGET_NR_getpriority:\nerrno = 0;", "ret = getpriority(arg1, arg2);", "if (ret == -1 && errno != 0) {", "ret = -host_to_target_errno(errno);", "break;", "}", "#ifdef TARGET_ALPHA\n((CPUAlphaState *)cpu_env)->ir[IR_V0] = 0;", "#else\nret = 20 - ret;", "#endif\nbreak;", "case TARGET_NR_setpriority:\nret = get_errno(setpriority(arg1, arg2, arg3));", "break;", "#ifdef TARGET_NR_profil\ncase TARGET_NR_profil:\ngoto unimplemented;", "#endif\ncase TARGET_NR_statfs:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;", "ret = get_errno(statfs(path(VAR_2), &VAR_1));", "unlock_user(VAR_2, arg1, 0);", "convert_statfs:\nif (!is_error(ret)) {", "struct target_statfs *VAR_26;", "if (!lock_user_struct(VERIFY_WRITE, VAR_26, arg2, 0))\ngoto efault;", "__put_user(VAR_1.f_type, &VAR_26->f_type);", "__put_user(VAR_1.f_bsize, &VAR_26->f_bsize);", "__put_user(VAR_1.f_blocks, &VAR_26->f_blocks);", "__put_user(VAR_1.f_bfree, &VAR_26->f_bfree);", "__put_user(VAR_1.f_bavail, &VAR_26->f_bavail);", "__put_user(VAR_1.f_files, &VAR_26->f_files);", "__put_user(VAR_1.f_ffree, &VAR_26->f_ffree);", "__put_user(VAR_1.f_fsid.__val[0], &VAR_26->f_fsid.val[0]);", "__put_user(VAR_1.f_fsid.__val[1], &VAR_26->f_fsid.val[1]);", "__put_user(VAR_1.f_namelen, &VAR_26->f_namelen);", "__put_user(VAR_1.f_frsize, &VAR_26->f_frsize);", "memset(VAR_26->f_spare, 0, sizeof(VAR_26->f_spare));", "unlock_user_struct(VAR_26, arg2, 1);", "}", "break;", "case TARGET_NR_fstatfs:\nret = get_errno(fstatfs(arg1, &VAR_1));", "goto convert_statfs;", "#ifdef TARGET_NR_statfs64\ncase TARGET_NR_statfs64:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;", "ret = get_errno(statfs(path(VAR_2), &VAR_1));", "unlock_user(VAR_2, arg1, 0);", "convert_statfs64:\nif (!is_error(ret)) {", "struct target_statfs64 *VAR_26;", "if (!lock_user_struct(VERIFY_WRITE, VAR_26, arg3, 0))\ngoto efault;", "__put_user(VAR_1.f_type, &VAR_26->f_type);", "__put_user(VAR_1.f_bsize, &VAR_26->f_bsize);", "__put_user(VAR_1.f_blocks, &VAR_26->f_blocks);", "__put_user(VAR_1.f_bfree, &VAR_26->f_bfree);", "__put_user(VAR_1.f_bavail, &VAR_26->f_bavail);", "__put_user(VAR_1.f_files, &VAR_26->f_files);", "__put_user(VAR_1.f_ffree, &VAR_26->f_ffree);", "__put_user(VAR_1.f_fsid.__val[0], &VAR_26->f_fsid.val[0]);", "__put_user(VAR_1.f_fsid.__val[1], &VAR_26->f_fsid.val[1]);", "__put_user(VAR_1.f_namelen, &VAR_26->f_namelen);", "__put_user(VAR_1.f_frsize, &VAR_26->f_frsize);", "memset(VAR_26->f_spare, 0, sizeof(VAR_26->f_spare));", "unlock_user_struct(VAR_26, arg3, 1);", "}", "break;", "case TARGET_NR_fstatfs64:\nret = get_errno(fstatfs(arg1, &VAR_1));", "goto convert_statfs64;", "#endif\n#ifdef TARGET_NR_ioperm\ncase TARGET_NR_ioperm:\ngoto unimplemented;", "#endif\n#ifdef TARGET_NR_socketcall\ncase TARGET_NR_socketcall:\nret = do_socketcall(arg1, arg2);", "break;", "#endif\n#ifdef TARGET_NR_accept\ncase TARGET_NR_accept:\nret = do_accept(arg1, arg2, arg3);", "break;", "#endif\n#ifdef TARGET_NR_bind\ncase TARGET_NR_bind:\nret = do_bind(arg1, arg2, arg3);", "break;", "#endif\n#ifdef TARGET_NR_connect\ncase TARGET_NR_connect:\nret = do_connect(arg1, arg2, arg3);", "break;", "#endif\n#ifdef TARGET_NR_getpeername\ncase TARGET_NR_getpeername:\nret = do_getpeername(arg1, arg2, arg3);", "break;", "#endif\n#ifdef TARGET_NR_getsockname\ncase TARGET_NR_getsockname:\nret = do_getsockname(arg1, arg2, arg3);", "break;", "#endif\n#ifdef TARGET_NR_getsockopt\ncase TARGET_NR_getsockopt:\nret = do_getsockopt(arg1, arg2, arg3, arg4, arg5);", "break;", "#endif\n#ifdef TARGET_NR_listen\ncase TARGET_NR_listen:\nret = get_errno(listen(arg1, arg2));", "break;", "#endif\n#ifdef TARGET_NR_recv\ncase TARGET_NR_recv:\nret = do_recvfrom(arg1, arg2, arg3, arg4, 0, 0);", "break;", "#endif\n#ifdef TARGET_NR_recvfrom\ncase TARGET_NR_recvfrom:\nret = do_recvfrom(arg1, arg2, arg3, arg4, arg5, arg6);", "break;", "#endif\n#ifdef TARGET_NR_recvmsg\ncase TARGET_NR_recvmsg:\nret = do_sendrecvmsg(arg1, arg2, arg3, 0);", "break;", "#endif\n#ifdef TARGET_NR_send\ncase TARGET_NR_send:\nret = do_sendto(arg1, arg2, arg3, arg4, 0, 0);", "break;", "#endif\n#ifdef TARGET_NR_sendmsg\ncase TARGET_NR_sendmsg:\nret = do_sendrecvmsg(arg1, arg2, arg3, 1);", "break;", "#endif\n#ifdef TARGET_NR_sendto\ncase TARGET_NR_sendto:\nret = do_sendto(arg1, arg2, arg3, arg4, arg5, arg6);", "break;", "#endif\n#ifdef TARGET_NR_shutdown\ncase TARGET_NR_shutdown:\nret = get_errno(shutdown(arg1, arg2));", "break;", "#endif\n#ifdef TARGET_NR_socket\ncase TARGET_NR_socket:\nret = do_socket(arg1, arg2, arg3);", "break;", "#endif\n#ifdef TARGET_NR_socketpair\ncase TARGET_NR_socketpair:\nret = do_socketpair(arg1, arg2, arg3, arg4);", "break;", "#endif\n#ifdef TARGET_NR_setsockopt\ncase TARGET_NR_setsockopt:\nret = do_setsockopt(arg1, arg2, arg3, arg4, (socklen_t) arg5);", "break;", "#endif\ncase TARGET_NR_syslog:\nif (!(VAR_2 = lock_user_string(arg2)))\ngoto efault;", "ret = get_errno(sys_syslog((int)arg1, VAR_2, (int)arg3));", "unlock_user(VAR_2, arg2, 0);", "break;", "case TARGET_NR_setitimer:\n{", "struct itimerval VAR_34, VAR_28, *VAR_29;", "if (arg2) {", "VAR_29 = &VAR_34;", "if (copy_from_user_timeval(&VAR_29->it_interval, arg2)\n|| copy_from_user_timeval(&VAR_29->it_value,\narg2 + sizeof(struct target_timeval)))\ngoto efault;", "} else {", "VAR_29 = NULL;", "}", "ret = get_errno(setitimer(arg1, VAR_29, &VAR_28));", "if (!is_error(ret) && arg3) {", "if (copy_to_user_timeval(arg3,\n&VAR_28.it_interval)\n|| copy_to_user_timeval(arg3 + sizeof(struct target_timeval),\n&VAR_28.it_value))\ngoto efault;", "}", "}", "break;", "case TARGET_NR_getitimer:\n{", "struct itimerval VAR_34;", "ret = get_errno(getitimer(arg1, &VAR_34));", "if (!is_error(ret) && arg2) {", "if (copy_to_user_timeval(arg2,\n&VAR_34.it_interval)\n|| copy_to_user_timeval(arg2 + sizeof(struct target_timeval),\n&VAR_34.it_value))\ngoto efault;", "}", "}", "break;", "case TARGET_NR_stat:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;", "ret = get_errno(stat(path(VAR_2), &VAR_0));", "unlock_user(VAR_2, arg1, 0);", "goto do_stat;", "case TARGET_NR_lstat:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;", "ret = get_errno(lstat(path(VAR_2), &VAR_0));", "unlock_user(VAR_2, arg1, 0);", "goto do_stat;", "case TARGET_NR_fstat:\n{", "ret = get_errno(fstat(arg1, &VAR_0));", "do_stat:\nif (!is_error(ret)) {", "struct target_stat *VAR_30;", "if (!lock_user_struct(VERIFY_WRITE, VAR_30, arg2, 0))\ngoto efault;", "memset(VAR_30, 0, sizeof(*VAR_30));", "__put_user(VAR_0.st_dev, &VAR_30->st_dev);", "__put_user(VAR_0.st_ino, &VAR_30->st_ino);", "__put_user(VAR_0.st_mode, &VAR_30->st_mode);", "__put_user(VAR_0.st_uid, &VAR_30->st_uid);", "__put_user(VAR_0.st_gid, &VAR_30->st_gid);", "__put_user(VAR_0.st_nlink, &VAR_30->st_nlink);", "__put_user(VAR_0.st_rdev, &VAR_30->st_rdev);", "__put_user(VAR_0.st_size, &VAR_30->st_size);", "__put_user(VAR_0.st_blksize, &VAR_30->st_blksize);", "__put_user(VAR_0.st_blocks, &VAR_30->st_blocks);", "__put_user(VAR_0.st_atime, &VAR_30->target_st_atime);", "__put_user(VAR_0.st_mtime, &VAR_30->target_st_mtime);", "__put_user(VAR_0.st_ctime, &VAR_30->target_st_ctime);", "unlock_user_struct(VAR_30, arg2, 1);", "}", "}", "break;", "#ifdef TARGET_NR_olduname\ncase TARGET_NR_olduname:\ngoto unimplemented;", "#endif\n#ifdef TARGET_NR_iopl\ncase TARGET_NR_iopl:\ngoto unimplemented;", "#endif\ncase TARGET_NR_vhangup:\nret = get_errno(vhangup());", "break;", "#ifdef TARGET_NR_idle\ncase TARGET_NR_idle:\ngoto unimplemented;", "#endif\n#ifdef TARGET_NR_syscall\ncase TARGET_NR_syscall:\nret = FUNC_0(cpu_env, arg1 & 0xffff, arg2, arg3, arg4, arg5,\narg6, arg7, arg8, 0);", "break;", "#endif\ncase TARGET_NR_wait4:\n{", "int VAR_31;", "abi_long status_ptr = arg2;", "struct VAR_32 VAR_32, *VAR_32;", "abi_ulong target_rusage = arg4;", "if (target_rusage)\nVAR_32 = &VAR_32;", "else\nVAR_32 = NULL;", "ret = get_errno(wait4(arg1, &VAR_31, arg3, VAR_32));", "if (!is_error(ret)) {", "if (status_ptr && ret) {", "VAR_31 = host_to_target_waitstatus(VAR_31);", "if (put_user_s32(VAR_31, status_ptr))\ngoto efault;", "}", "if (target_rusage)\nhost_to_target_rusage(target_rusage, &VAR_32);", "}", "}", "break;", "#ifdef TARGET_NR_swapoff\ncase TARGET_NR_swapoff:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;", "ret = get_errno(swapoff(VAR_2));", "unlock_user(VAR_2, arg1, 0);", "break;", "#endif\ncase TARGET_NR_sysinfo:\n{", "struct target_sysinfo *VAR_33;", "struct sysinfo VAR_34;", "ret = get_errno(sysinfo(&VAR_34));", "if (!is_error(ret) && arg1)\n{", "if (!lock_user_struct(VERIFY_WRITE, VAR_33, arg1, 0))\ngoto efault;", "__put_user(VAR_34.uptime, &VAR_33->uptime);", "__put_user(VAR_34.loads[0], &VAR_33->loads[0]);", "__put_user(VAR_34.loads[1], &VAR_33->loads[1]);", "__put_user(VAR_34.loads[2], &VAR_33->loads[2]);", "__put_user(VAR_34.totalram, &VAR_33->totalram);", "__put_user(VAR_34.freeram, &VAR_33->freeram);", "__put_user(VAR_34.sharedram, &VAR_33->sharedram);", "__put_user(VAR_34.bufferram, &VAR_33->bufferram);", "__put_user(VAR_34.totalswap, &VAR_33->totalswap);", "__put_user(VAR_34.freeswap, &VAR_33->freeswap);", "__put_user(VAR_34.procs, &VAR_33->procs);", "__put_user(VAR_34.totalhigh, &VAR_33->totalhigh);", "__put_user(VAR_34.freehigh, &VAR_33->freehigh);", "__put_user(VAR_34.mem_unit, &VAR_33->mem_unit);", "unlock_user_struct(VAR_33, arg1, 1);", "}", "}", "break;", "#ifdef TARGET_NR_ipc\ncase TARGET_NR_ipc:\nret = do_ipc(arg1, arg2, arg3, arg4, arg5, arg6);", "break;", "#endif\n#ifdef TARGET_NR_semget\ncase TARGET_NR_semget:\nret = get_errno(semget(arg1, arg2, arg3));", "break;", "#endif\n#ifdef TARGET_NR_semop\ncase TARGET_NR_semop:\nret = get_errno(do_semop(arg1, arg2, arg3));", "break;", "#endif\n#ifdef TARGET_NR_semctl\ncase TARGET_NR_semctl:\nret = do_semctl(arg1, arg2, arg3, (union target_semun)(abi_ulong)arg4);", "break;", "#endif\n#ifdef TARGET_NR_msgctl\ncase TARGET_NR_msgctl:\nret = do_msgctl(arg1, arg2, arg3);", "break;", "#endif\n#ifdef TARGET_NR_msgget\ncase TARGET_NR_msgget:\nret = get_errno(msgget(arg1, arg2));", "break;", "#endif\n#ifdef TARGET_NR_msgrcv\ncase TARGET_NR_msgrcv:\nret = do_msgrcv(arg1, arg2, arg3, arg4, arg5);", "break;", "#endif\n#ifdef TARGET_NR_msgsnd\ncase TARGET_NR_msgsnd:\nret = do_msgsnd(arg1, arg2, arg3, arg4);", "break;", "#endif\n#ifdef TARGET_NR_shmget\ncase TARGET_NR_shmget:\nret = get_errno(shmget(arg1, arg2, arg3));", "break;", "#endif\n#ifdef TARGET_NR_shmctl\ncase TARGET_NR_shmctl:\nret = do_shmctl(arg1, arg2, arg3);", "break;", "#endif\n#ifdef TARGET_NR_shmat\ncase TARGET_NR_shmat:\nret = do_shmat(arg1, arg2, arg3);", "break;", "#endif\n#ifdef TARGET_NR_shmdt\ncase TARGET_NR_shmdt:\nret = do_shmdt(arg1);", "break;", "#endif\ncase TARGET_NR_fsync:\nret = get_errno(fsync(arg1));", "break;", "case TARGET_NR_clone:\n#if defined(TARGET_SH4) || defined(TARGET_ALPHA)\nret = get_errno(do_fork(cpu_env, arg1, arg2, arg3, arg5, arg4));", "#elif defined(TARGET_CRIS)\nret = get_errno(do_fork(cpu_env, arg2, arg1, arg3, arg4, arg5));", "#elif defined(TARGET_S390X)\nret = get_errno(do_fork(cpu_env, arg2, arg1, arg3, arg5, arg4));", "#else\nret = get_errno(do_fork(cpu_env, arg1, arg2, arg3, arg4, arg5));", "#endif\nbreak;", "#ifdef __NR_exit_group\ncase TARGET_NR_exit_group:\n#ifdef TARGET_GPROF\n_mcleanup();", "#endif\ngdb_exit(cpu_env, arg1);", "ret = get_errno(exit_group(arg1));", "break;", "#endif\ncase TARGET_NR_setdomainname:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;", "ret = get_errno(setdomainname(VAR_2, arg2));", "unlock_user(VAR_2, arg1, 0);", "break;", "case TARGET_NR_uname:\n{", "struct new_utsname * VAR_34;", "if (!lock_user_struct(VERIFY_WRITE, VAR_34, arg1, 0))\ngoto efault;", "ret = get_errno(sys_uname(VAR_34));", "if (!is_error(ret)) {", "strcpy (VAR_34->machine, cpu_to_uname_machine(cpu_env));", "if (qemu_uname_release && *qemu_uname_release)\nstrcpy (VAR_34->release, qemu_uname_release);", "}", "unlock_user_struct(VAR_34, arg1, 1);", "}", "break;", "#ifdef TARGET_I386\ncase TARGET_NR_modify_ldt:\nret = do_modify_ldt(cpu_env, arg1, arg2, arg3);", "break;", "#if !defined(TARGET_X86_64)\ncase TARGET_NR_vm86old:\ngoto unimplemented;", "case TARGET_NR_vm86:\nret = do_vm86(cpu_env, arg1, arg2);", "break;", "#endif\n#endif\ncase TARGET_NR_adjtimex:\ngoto unimplemented;", "#ifdef TARGET_NR_create_module\ncase TARGET_NR_create_module:\n#endif\ncase TARGET_NR_init_module:\ncase TARGET_NR_delete_module:\n#ifdef TARGET_NR_get_kernel_syms\ncase TARGET_NR_get_kernel_syms:\n#endif\ngoto unimplemented;", "case TARGET_NR_quotactl:\ngoto unimplemented;", "case TARGET_NR_getpgid:\nret = get_errno(getpgid(arg1));", "break;", "case TARGET_NR_fchdir:\nret = get_errno(fchdir(arg1));", "break;", "#ifdef TARGET_NR_bdflush\ncase TARGET_NR_bdflush:\ngoto unimplemented;", "#endif\n#ifdef TARGET_NR_sysfs\ncase TARGET_NR_sysfs:\ngoto unimplemented;", "#endif\ncase TARGET_NR_personality:\nret = get_errno(personality(arg1));", "break;", "#ifdef TARGET_NR_afs_syscall\ncase TARGET_NR_afs_syscall:\ngoto unimplemented;", "#endif\n#ifdef TARGET_NR__llseek\ncase TARGET_NR__llseek:\n{", "int64_t res;", "#if !defined(__NR_llseek)\nres = lseek(arg1, ((uint64_t)arg2 << 32) | arg3, arg5);", "if (res == -1) {", "ret = get_errno(res);", "} else {", "ret = 0;", "}", "#else\nret = get_errno(_llseek(arg1, arg2, arg3, &res, arg5));", "#endif\nif ((ret == 0) && put_user_s64(res, arg4)) {", "goto efault;", "}", "}", "break;", "#endif\ncase TARGET_NR_getdents:\n#if TARGET_ABI_BITS == 32 && HOST_LONG_BITS == 64\n{", "struct target_dirent *target_dirp;", "struct linux_dirent *VAR_35;", "abi_long VAR_41 = arg3;", "VAR_35 = malloc(VAR_41);", "if (!VAR_35) {", "ret = -TARGET_ENOMEM;", "goto fail;", "}", "ret = get_errno(sys_getdents(arg1, VAR_35, VAR_41));", "if (!is_error(ret)) {", "struct linux_dirent *VAR_36;", "struct target_dirent *tde;", "int VAR_37 = ret;", "int VAR_38, treclen;", "int count1, tnamelen;", "count1 = 0;", "VAR_36 = VAR_35;", "if (!(target_dirp = lock_user(VERIFY_WRITE, arg2, VAR_41, 0)))\ngoto efault;", "tde = target_dirp;", "while (VAR_37 > 0) {", "VAR_38 = VAR_36->d_reclen;", "tnamelen = VAR_38 - offsetof(struct linux_dirent, d_name);", "assert(tnamelen >= 0);", "treclen = tnamelen + offsetof(struct target_dirent, d_name);", "assert(count1 + treclen <= VAR_41);", "tde->d_reclen = tswap16(treclen);", "tde->d_ino = tswapal(VAR_36->d_ino);", "tde->d_off = tswapal(VAR_36->d_off);", "memcpy(tde->d_name, VAR_36->d_name, tnamelen);", "VAR_36 = (struct linux_dirent *)((char *)VAR_36 + VAR_38);", "VAR_37 -= VAR_38;", "tde = (struct target_dirent *)((char *)tde + treclen);", "count1 += treclen;", "}", "ret = count1;", "unlock_user(target_dirp, arg2, ret);", "}", "free(VAR_35);", "}", "#else\n{", "struct linux_dirent *VAR_35;", "abi_long VAR_41 = arg3;", "if (!(VAR_35 = lock_user(VERIFY_WRITE, arg2, VAR_41, 0)))\ngoto efault;", "ret = get_errno(sys_getdents(arg1, VAR_35, VAR_41));", "if (!is_error(ret)) {", "struct linux_dirent *VAR_36;", "int VAR_37 = ret;", "int VAR_38;", "VAR_36 = VAR_35;", "while (VAR_37 > 0) {", "VAR_38 = VAR_36->d_reclen;", "if (VAR_38 > VAR_37)\nbreak;", "VAR_36->d_reclen = tswap16(VAR_38);", "tswapls(&VAR_36->d_ino);", "tswapls(&VAR_36->d_off);", "VAR_36 = (struct linux_dirent *)((char *)VAR_36 + VAR_38);", "VAR_37 -= VAR_38;", "}", "}", "unlock_user(VAR_35, arg2, ret);", "}", "#endif\nbreak;", "#if defined(TARGET_NR_getdents64) && defined(__NR_getdents64)\ncase TARGET_NR_getdents64:\n{", "struct linux_dirent64 *VAR_35;", "abi_long VAR_41 = arg3;", "if (!(VAR_35 = lock_user(VERIFY_WRITE, arg2, VAR_41, 0)))\ngoto efault;", "ret = get_errno(sys_getdents64(arg1, VAR_35, VAR_41));", "if (!is_error(ret)) {", "struct linux_dirent64 *VAR_36;", "int VAR_37 = ret;", "int VAR_38;", "VAR_36 = VAR_35;", "while (VAR_37 > 0) {", "VAR_38 = VAR_36->d_reclen;", "if (VAR_38 > VAR_37)\nbreak;", "VAR_36->d_reclen = tswap16(VAR_38);", "tswap64s((uint64_t *)&VAR_36->d_ino);", "tswap64s((uint64_t *)&VAR_36->d_off);", "VAR_36 = (struct linux_dirent64 *)((char *)VAR_36 + VAR_38);", "VAR_37 -= VAR_38;", "}", "}", "unlock_user(VAR_35, arg2, ret);", "}", "break;", "#endif\n#if defined(TARGET_NR__newselect) || defined(TARGET_S390X)\n#ifdef TARGET_S390X\ncase TARGET_NR_select:\n#else\ncase TARGET_NR__newselect:\n#endif\nret = do_select(arg1, arg2, arg3, arg4, arg5);", "break;", "#endif\n#if defined(TARGET_NR_poll) || defined(TARGET_NR_ppoll)\n# ifdef TARGET_NR_poll\ncase TARGET_NR_poll:\n# endif\n# ifdef TARGET_NR_ppoll\ncase TARGET_NR_ppoll:\n# endif\n{", "struct target_pollfd *target_pfd;", "unsigned int nfds = arg2;", "int timeout = arg3;", "struct pollfd *pfd;", "unsigned int VAR_51;", "target_pfd = lock_user(VERIFY_WRITE, arg1, sizeof(struct target_pollfd) * nfds, 1);", "if (!target_pfd)\ngoto efault;", "pfd = alloca(sizeof(struct pollfd) * nfds);", "for(VAR_51 = 0; VAR_51 < nfds; VAR_51++) {", "pfd[VAR_51].fd = tswap32(target_pfd[VAR_51].fd);", "pfd[VAR_51].events = tswap16(target_pfd[VAR_51].events);", "}", "# ifdef TARGET_NR_ppoll\nif (num == TARGET_NR_ppoll) {", "struct timespec _timeout_ts, *timeout_ts = &_timeout_ts;", "target_sigset_t *target_set;", "sigset_t _set, *set = &_set;", "if (arg3) {", "if (target_to_host_timespec(timeout_ts, arg3)) {", "unlock_user(target_pfd, arg1, 0);", "goto efault;", "}", "} else {", "timeout_ts = NULL;", "}", "if (arg4) {", "target_set = lock_user(VERIFY_READ, arg4, sizeof(target_sigset_t), 1);", "if (!target_set) {", "unlock_user(target_pfd, arg1, 0);", "goto efault;", "}", "target_to_host_sigset(set, target_set);", "} else {", "set = NULL;", "}", "ret = get_errno(sys_ppoll(pfd, nfds, timeout_ts, set, _NSIG/8));", "if (!is_error(ret) && arg3) {", "host_to_target_timespec(arg3, timeout_ts);", "}", "if (arg4) {", "unlock_user(target_set, arg4, 0);", "}", "} else", "# endif\nret = get_errno(poll(pfd, nfds, timeout));", "if (!is_error(ret)) {", "for(VAR_51 = 0; VAR_51 < nfds; VAR_51++) {", "target_pfd[VAR_51].revents = tswap16(pfd[VAR_51].revents);", "}", "}", "unlock_user(target_pfd, arg1, sizeof(struct target_pollfd) * nfds);", "}", "break;", "#endif\ncase TARGET_NR_flock:\nret = get_errno(flock(arg1, arg2));", "break;", "case TARGET_NR_readv:\n{", "int VAR_41 = arg3;", "struct iovec *VAR_41;", "VAR_41 = alloca(VAR_41 * sizeof(struct iovec));", "if (lock_iovec(VERIFY_WRITE, VAR_41, arg2, VAR_41, 0) < 0)\ngoto efault;", "ret = get_errno(readv(arg1, VAR_41, VAR_41));", "unlock_iovec(VAR_41, arg2, VAR_41, 1);", "}", "break;", "case TARGET_NR_writev:\n{", "int VAR_41 = arg3;", "struct iovec *VAR_41;", "VAR_41 = alloca(VAR_41 * sizeof(struct iovec));", "if (lock_iovec(VERIFY_READ, VAR_41, arg2, VAR_41, 1) < 0)\ngoto efault;", "ret = get_errno(writev(arg1, VAR_41, VAR_41));", "unlock_iovec(VAR_41, arg2, VAR_41, 0);", "}", "break;", "case TARGET_NR_getsid:\nret = get_errno(getsid(arg1));", "break;", "#if defined(TARGET_NR_fdatasync)\ncase TARGET_NR_fdatasync:\nret = get_errno(fdatasync(arg1));", "break;", "#endif\ncase TARGET_NR__sysctl:\nret = -TARGET_ENOTDIR;", "break;", "case TARGET_NR_sched_getaffinity:\n{", "unsigned int VAR_43;", "unsigned long *VAR_43;", "if (arg2 & (sizeof(abi_ulong) - 1)) {", "ret = -TARGET_EINVAL;", "break;", "}", "VAR_43 = (arg2 + (sizeof(*VAR_43) - 1)) & ~(sizeof(*VAR_43) - 1);", "VAR_43 = alloca(VAR_43);", "ret = get_errno(sys_sched_getaffinity(arg1, VAR_43, VAR_43));", "if (!is_error(ret)) {", "if (copy_to_user(arg3, VAR_43, ret)) {", "goto efault;", "}", "}", "}", "break;", "case TARGET_NR_sched_setaffinity:\n{", "unsigned int VAR_43;", "unsigned long *VAR_43;", "if (arg2 & (sizeof(abi_ulong) - 1)) {", "ret = -TARGET_EINVAL;", "break;", "}", "VAR_43 = (arg2 + (sizeof(*VAR_43) - 1)) & ~(sizeof(*VAR_43) - 1);", "VAR_43 = alloca(VAR_43);", "if (!lock_user_struct(VERIFY_READ, VAR_2, arg3, 1)) {", "goto efault;", "}", "memcpy(VAR_43, VAR_2, arg2);", "unlock_user_struct(VAR_2, arg2, 0);", "ret = get_errno(sys_sched_setaffinity(arg1, VAR_43, VAR_43));", "}", "break;", "case TARGET_NR_sched_setparam:\n{", "struct sched_param *VAR_45;", "struct sched_param VAR_45;", "if (!lock_user_struct(VERIFY_READ, VAR_45, arg2, 1))\ngoto efault;", "VAR_45.sched_priority = tswap32(VAR_45->sched_priority);", "unlock_user_struct(VAR_45, arg2, 0);", "ret = get_errno(sched_setparam(arg1, &VAR_45));", "}", "break;", "case TARGET_NR_sched_getparam:\n{", "struct sched_param *VAR_45;", "struct sched_param VAR_45;", "ret = get_errno(sched_getparam(arg1, &VAR_45));", "if (!is_error(ret)) {", "if (!lock_user_struct(VERIFY_WRITE, VAR_45, arg2, 0))\ngoto efault;", "VAR_45->sched_priority = tswap32(VAR_45.sched_priority);", "unlock_user_struct(VAR_45, arg2, 1);", "}", "}", "break;", "case TARGET_NR_sched_setscheduler:\n{", "struct sched_param *VAR_45;", "struct sched_param VAR_45;", "if (!lock_user_struct(VERIFY_READ, VAR_45, arg3, 1))\ngoto efault;", "VAR_45.sched_priority = tswap32(VAR_45->sched_priority);", "unlock_user_struct(VAR_45, arg3, 0);", "ret = get_errno(sched_setscheduler(arg1, arg2, &VAR_45));", "}", "break;", "case TARGET_NR_sched_getscheduler:\nret = get_errno(sched_getscheduler(arg1));", "break;", "case TARGET_NR_sched_yield:\nret = get_errno(sched_yield());", "break;", "case TARGET_NR_sched_get_priority_max:\nret = get_errno(sched_get_priority_max(arg1));", "break;", "case TARGET_NR_sched_get_priority_min:\nret = get_errno(sched_get_priority_min(arg1));", "break;", "case TARGET_NR_sched_rr_get_interval:\n{", "struct timespec VAR_45;", "ret = get_errno(sched_rr_get_interval(arg1, &VAR_45));", "if (!is_error(ret)) {", "host_to_target_timespec(arg2, &VAR_45);", "}", "}", "break;", "case TARGET_NR_nanosleep:\n{", "struct timespec VAR_46, VAR_47;", "target_to_host_timespec(&VAR_46, arg1);", "ret = get_errno(nanosleep(&VAR_46, &VAR_47));", "if (is_error(ret) && arg2) {", "host_to_target_timespec(arg2, &VAR_47);", "}", "}", "break;", "#ifdef TARGET_NR_query_module\ncase TARGET_NR_query_module:\ngoto unimplemented;", "#endif\n#ifdef TARGET_NR_nfsservctl\ncase TARGET_NR_nfsservctl:\ngoto unimplemented;", "#endif\ncase TARGET_NR_prctl:\nswitch (arg1) {", "case PR_GET_PDEATHSIG:\n{", "int VAR_48;", "ret = get_errno(prctl(arg1, &VAR_48, arg3, arg4, arg5));", "if (!is_error(ret) && arg2\n&& put_user_ual(VAR_48, arg2)) {", "goto efault;", "}", "break;", "}", "#ifdef PR_GET_NAME\ncase PR_GET_NAME:\n{", "void *name = lock_user(VERIFY_WRITE, arg2, 16, 1);", "if (!name) {", "goto efault;", "}", "ret = get_errno(prctl(arg1, (unsigned long)name,\narg3, arg4, arg5));", "unlock_user(name, arg2, 16);", "break;", "}", "case PR_SET_NAME:\n{", "void *name = lock_user(VERIFY_READ, arg2, 16, 1);", "if (!name) {", "goto efault;", "}", "ret = get_errno(prctl(arg1, (unsigned long)name,\narg3, arg4, arg5));", "unlock_user(name, arg2, 0);", "break;", "}", "#endif\ndefault:\nret = get_errno(prctl(arg1, arg2, arg3, arg4, arg5));", "break;", "}", "break;", "#ifdef TARGET_NR_arch_prctl\ncase TARGET_NR_arch_prctl:\n#if defined(TARGET_I386) && !defined(TARGET_ABI32)\nret = do_arch_prctl(cpu_env, arg1, arg2);", "break;", "#else\ngoto unimplemented;", "#endif\n#endif\n#ifdef TARGET_NR_pread\ncase TARGET_NR_pread:\nif (regpairs_aligned(cpu_env))\narg4 = arg5;", "if (!(VAR_2 = lock_user(VERIFY_WRITE, arg2, arg3, 0)))\ngoto efault;", "ret = get_errno(pread(arg1, VAR_2, arg3, arg4));", "unlock_user(VAR_2, arg2, ret);", "break;", "case TARGET_NR_pwrite:\nif (regpairs_aligned(cpu_env))\narg4 = arg5;", "if (!(VAR_2 = lock_user(VERIFY_READ, arg2, arg3, 1)))\ngoto efault;", "ret = get_errno(pwrite(arg1, VAR_2, arg3, arg4));", "unlock_user(VAR_2, arg2, 0);", "break;", "#endif\n#ifdef TARGET_NR_pread64\ncase TARGET_NR_pread64:\nif (!(VAR_2 = lock_user(VERIFY_WRITE, arg2, arg3, 0)))\ngoto efault;", "ret = get_errno(pread64(arg1, VAR_2, arg3, target_offset64(arg4, arg5)));", "unlock_user(VAR_2, arg2, ret);", "break;", "case TARGET_NR_pwrite64:\nif (!(VAR_2 = lock_user(VERIFY_READ, arg2, arg3, 1)))\ngoto efault;", "ret = get_errno(pwrite64(arg1, VAR_2, arg3, target_offset64(arg4, arg5)));", "unlock_user(VAR_2, arg2, 0);", "break;", "#endif\ncase TARGET_NR_getcwd:\nif (!(VAR_2 = lock_user(VERIFY_WRITE, arg1, arg2, 0)))\ngoto efault;", "ret = get_errno(sys_getcwd1(VAR_2, arg2));", "unlock_user(VAR_2, arg1, ret);", "break;", "case TARGET_NR_capget:\ngoto unimplemented;", "case TARGET_NR_capset:\ngoto unimplemented;", "case TARGET_NR_sigaltstack:\n#if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_MIPS) || \\\ndefined(TARGET_SPARC) || defined(TARGET_PPC) || defined(TARGET_ALPHA) || \\\ndefined(TARGET_M68K) || defined(TARGET_S390X) || defined(TARGET_OPENRISC)\nret = do_sigaltstack(arg1, arg2, get_sp_from_cpustate((CPUArchState *)cpu_env));", "break;", "#else\ngoto unimplemented;", "#endif\ncase TARGET_NR_sendfile:\ngoto unimplemented;", "#ifdef TARGET_NR_getpmsg\ncase TARGET_NR_getpmsg:\ngoto unimplemented;", "#endif\n#ifdef TARGET_NR_putpmsg\ncase TARGET_NR_putpmsg:\ngoto unimplemented;", "#endif\n#ifdef TARGET_NR_vfork\ncase TARGET_NR_vfork:\nret = get_errno(do_fork(cpu_env, CLONE_VFORK | CLONE_VM | SIGCHLD,\n0, 0, 0, 0));", "break;", "#endif\n#ifdef TARGET_NR_ugetrlimit\ncase TARGET_NR_ugetrlimit:\n{", "struct rlimit VAR_23;", "int VAR_23 = target_to_host_resource(arg1);", "ret = get_errno(getrlimit(VAR_23, &VAR_23));", "if (!is_error(ret)) {", "struct target_rlimit *VAR_23;", "if (!lock_user_struct(VERIFY_WRITE, VAR_23, arg2, 0))\ngoto efault;", "VAR_23->rlim_cur = host_to_target_rlim(VAR_23.rlim_cur);", "VAR_23->rlim_max = host_to_target_rlim(VAR_23.rlim_max);", "unlock_user_struct(VAR_23, arg2, 1);", "}", "break;", "}", "#endif\n#ifdef TARGET_NR_truncate64\ncase TARGET_NR_truncate64:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;", "ret = target_truncate64(cpu_env, VAR_2, arg2, arg3, arg4);", "unlock_user(VAR_2, arg1, 0);", "break;", "#endif\n#ifdef TARGET_NR_ftruncate64\ncase TARGET_NR_ftruncate64:\nret = target_ftruncate64(cpu_env, arg1, arg2, arg3, arg4);", "break;", "#endif\n#ifdef TARGET_NR_stat64\ncase TARGET_NR_stat64:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;", "ret = get_errno(stat(path(VAR_2), &VAR_0));", "unlock_user(VAR_2, arg1, 0);", "if (!is_error(ret))\nret = host_to_target_stat64(cpu_env, arg2, &VAR_0);", "break;", "#endif\n#ifdef TARGET_NR_lstat64\ncase TARGET_NR_lstat64:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;", "ret = get_errno(lstat(path(VAR_2), &VAR_0));", "unlock_user(VAR_2, arg1, 0);", "if (!is_error(ret))\nret = host_to_target_stat64(cpu_env, arg2, &VAR_0);", "break;", "#endif\n#ifdef TARGET_NR_fstat64\ncase TARGET_NR_fstat64:\nret = get_errno(fstat(arg1, &VAR_0));", "if (!is_error(ret))\nret = host_to_target_stat64(cpu_env, arg2, &VAR_0);", "break;", "#endif\n#if (defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)) && \\\n(defined(__NR_fstatat64) || defined(__NR_newfstatat))\n#ifdef TARGET_NR_fstatat64\ncase TARGET_NR_fstatat64:\n#endif\n#ifdef TARGET_NR_newfstatat\ncase TARGET_NR_newfstatat:\n#endif\nif (!(VAR_2 = lock_user_string(arg2)))\ngoto efault;", "#ifdef __NR_fstatat64\nret = get_errno(sys_fstatat64(arg1, path(VAR_2), &VAR_0, arg4));", "#else\nret = get_errno(sys_newfstatat(arg1, path(VAR_2), &VAR_0, arg4));", "#endif\nif (!is_error(ret))\nret = host_to_target_stat64(cpu_env, arg3, &VAR_0);", "break;", "#endif\ncase TARGET_NR_lchown:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;", "ret = get_errno(lchown(VAR_2, low2highuid(arg2), low2highgid(arg3)));", "unlock_user(VAR_2, arg1, 0);", "break;", "#ifdef TARGET_NR_getuid\ncase TARGET_NR_getuid:\nret = get_errno(high2lowuid(getuid()));", "break;", "#endif\n#ifdef TARGET_NR_getgid\ncase TARGET_NR_getgid:\nret = get_errno(high2lowgid(getgid()));", "break;", "#endif\n#ifdef TARGET_NR_geteuid\ncase TARGET_NR_geteuid:\nret = get_errno(high2lowuid(geteuid()));", "break;", "#endif\n#ifdef TARGET_NR_getegid\ncase TARGET_NR_getegid:\nret = get_errno(high2lowgid(getegid()));", "break;", "#endif\ncase TARGET_NR_setreuid:\nret = get_errno(setreuid(low2highuid(arg1), low2highuid(arg2)));", "break;", "case TARGET_NR_setregid:\nret = get_errno(setregid(low2highgid(arg1), low2highgid(arg2)));", "break;", "case TARGET_NR_getgroups:\n{", "int VAR_51 = arg1;", "target_id *target_grouplist;", "gid_t *grouplist;", "int VAR_51;", "grouplist = alloca(VAR_51 * sizeof(gid_t));", "ret = get_errno(getgroups(VAR_51, grouplist));", "if (VAR_51 == 0)\nbreak;", "if (!is_error(ret)) {", "target_grouplist = lock_user(VERIFY_WRITE, arg2, VAR_51 * 2, 0);", "if (!target_grouplist)\ngoto efault;", "for(VAR_51 = 0;VAR_51 < ret; VAR_51++)", "target_grouplist[VAR_51] = tswapid(high2lowgid(grouplist[VAR_51]));", "unlock_user(target_grouplist, arg2, VAR_51 * 2);", "}", "}", "break;", "case TARGET_NR_setgroups:\n{", "int VAR_51 = arg1;", "target_id *target_grouplist;", "gid_t *grouplist;", "int VAR_51;", "grouplist = alloca(VAR_51 * sizeof(gid_t));", "target_grouplist = lock_user(VERIFY_READ, arg2, VAR_51 * 2, 1);", "if (!target_grouplist) {", "ret = -TARGET_EFAULT;", "goto fail;", "}", "for(VAR_51 = 0;VAR_51 < VAR_51; VAR_51++)", "grouplist[VAR_51] = low2highgid(tswapid(target_grouplist[VAR_51]));", "unlock_user(target_grouplist, arg2, 0);", "ret = get_errno(setgroups(VAR_51, grouplist));", "}", "break;", "case TARGET_NR_fchown:\nret = get_errno(fchown(arg1, low2highuid(arg2), low2highgid(arg3)));", "break;", "#if defined(TARGET_NR_fchownat) && defined(__NR_fchownat)\ncase TARGET_NR_fchownat:\nif (!(VAR_2 = lock_user_string(arg2)))\ngoto efault;", "ret = get_errno(sys_fchownat(arg1, VAR_2, low2highuid(arg3), low2highgid(arg4), arg5));", "unlock_user(VAR_2, arg2, 0);", "break;", "#endif\n#ifdef TARGET_NR_setresuid\ncase TARGET_NR_setresuid:\nret = get_errno(setresuid(low2highuid(arg1),\nlow2highuid(arg2),\nlow2highuid(arg3)));", "break;", "#endif\n#ifdef TARGET_NR_getresuid\ncase TARGET_NR_getresuid:\n{", "uid_t ruid, euid, suid;", "ret = get_errno(getresuid(&ruid, &euid, &suid));", "if (!is_error(ret)) {", "if (put_user_u16(high2lowuid(ruid), arg1)\n|| put_user_u16(high2lowuid(euid), arg2)\n|| put_user_u16(high2lowuid(suid), arg3))\ngoto efault;", "}", "}", "break;", "#endif\n#ifdef TARGET_NR_getresgid\ncase TARGET_NR_setresgid:\nret = get_errno(setresgid(low2highgid(arg1),\nlow2highgid(arg2),\nlow2highgid(arg3)));", "break;", "#endif\n#ifdef TARGET_NR_getresgid\ncase TARGET_NR_getresgid:\n{", "gid_t rgid, egid, sgid;", "ret = get_errno(getresgid(&rgid, &egid, &sgid));", "if (!is_error(ret)) {", "if (put_user_u16(high2lowgid(rgid), arg1)\n|| put_user_u16(high2lowgid(egid), arg2)\n|| put_user_u16(high2lowgid(sgid), arg3))\ngoto efault;", "}", "}", "break;", "#endif\ncase TARGET_NR_chown:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;", "ret = get_errno(chown(VAR_2, low2highuid(arg2), low2highgid(arg3)));", "unlock_user(VAR_2, arg1, 0);", "break;", "case TARGET_NR_setuid:\nret = get_errno(setuid(low2highuid(arg1)));", "break;", "case TARGET_NR_setgid:\nret = get_errno(setgid(low2highgid(arg1)));", "break;", "case TARGET_NR_setfsuid:\nret = get_errno(setfsuid(arg1));", "break;", "case TARGET_NR_setfsgid:\nret = get_errno(setfsgid(arg1));", "break;", "#ifdef TARGET_NR_lchown32\ncase TARGET_NR_lchown32:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;", "ret = get_errno(lchown(VAR_2, arg2, arg3));", "unlock_user(VAR_2, arg1, 0);", "break;", "#endif\n#ifdef TARGET_NR_getuid32\ncase TARGET_NR_getuid32:\nret = get_errno(getuid());", "break;", "#endif\n#if defined(TARGET_NR_getxuid) && defined(TARGET_ALPHA)\ncase TARGET_NR_getxuid:\n{", "uid_t euid;", "euid=geteuid();", "((CPUAlphaState *)cpu_env)->ir[IR_A4]=euid;", "}", "ret = get_errno(getuid());", "break;", "#endif\n#if defined(TARGET_NR_getxgid) && defined(TARGET_ALPHA)\ncase TARGET_NR_getxgid:\n{", "uid_t egid;", "egid=getegid();", "((CPUAlphaState *)cpu_env)->ir[IR_A4]=egid;", "}", "ret = get_errno(getgid());", "break;", "#endif\n#if defined(TARGET_NR_osf_getsysinfo) && defined(TARGET_ALPHA)\ncase TARGET_NR_osf_getsysinfo:\nret = -TARGET_EOPNOTSUPP;", "switch (arg1) {", "case TARGET_GSI_IEEE_FP_CONTROL:\n{", "uint64_t swcr, fpcr = cpu_alpha_load_fpcr (cpu_env);", "swcr = (fpcr >> 35) & SWCR_STATUS_MASK;", "swcr |= (fpcr >> 36) & SWCR_MAP_DMZ;", "swcr |= (~fpcr >> 48) & (SWCR_TRAP_ENABLE_INV\n| SWCR_TRAP_ENABLE_DZE\n| SWCR_TRAP_ENABLE_OVF);", "swcr |= (~fpcr >> 57) & (SWCR_TRAP_ENABLE_UNF\n| SWCR_TRAP_ENABLE_INE);", "swcr |= (fpcr >> 47) & SWCR_MAP_UMZ;", "swcr |= (~fpcr >> 41) & SWCR_TRAP_ENABLE_DNO;", "if (put_user_u64 (swcr, arg2))\ngoto efault;", "ret = 0;", "}", "break;", "}", "break;", "#endif\n#if defined(TARGET_NR_osf_setsysinfo) && defined(TARGET_ALPHA)\ncase TARGET_NR_osf_setsysinfo:\nret = -TARGET_EOPNOTSUPP;", "switch (arg1) {", "case TARGET_SSI_IEEE_FP_CONTROL:\n{", "uint64_t swcr, fpcr, orig_fpcr;", "if (get_user_u64 (swcr, arg2)) {", "goto efault;", "}", "orig_fpcr = cpu_alpha_load_fpcr(cpu_env);", "fpcr = orig_fpcr & FPCR_DYN_MASK;", "fpcr |= (swcr & SWCR_STATUS_MASK) << 35;", "fpcr |= (swcr & SWCR_MAP_DMZ) << 36;", "fpcr |= (~swcr & (SWCR_TRAP_ENABLE_INV\n| SWCR_TRAP_ENABLE_DZE\n| SWCR_TRAP_ENABLE_OVF)) << 48;", "fpcr |= (~swcr & (SWCR_TRAP_ENABLE_UNF\n| SWCR_TRAP_ENABLE_INE)) << 57;", "fpcr |= (swcr & SWCR_MAP_UMZ ? FPCR_UNDZ | FPCR_UNFD : 0);", "fpcr |= (~swcr & SWCR_TRAP_ENABLE_DNO) << 41;", "cpu_alpha_store_fpcr(cpu_env, fpcr);", "ret = 0;", "}", "break;", "case TARGET_SSI_IEEE_RAISE_EXCEPTION:\n{", "uint64_t exc, fpcr, orig_fpcr;", "int si_code;", "if (get_user_u64(exc, arg2)) {", "goto efault;", "}", "orig_fpcr = cpu_alpha_load_fpcr(cpu_env);", "fpcr = orig_fpcr | ((exc & SWCR_STATUS_MASK) << 35);", "cpu_alpha_store_fpcr(cpu_env, fpcr);", "ret = 0;", "fpcr &= ~(orig_fpcr & FPCR_STATUS_MASK);", "si_code = 0;", "if ((fpcr & (FPCR_INE | FPCR_INED)) == FPCR_INE) {", "si_code = TARGET_FPE_FLTRES;", "}", "if ((fpcr & (FPCR_UNF | FPCR_UNFD)) == FPCR_UNF) {", "si_code = TARGET_FPE_FLTUND;", "}", "if ((fpcr & (FPCR_OVF | FPCR_OVFD)) == FPCR_OVF) {", "si_code = TARGET_FPE_FLTOVF;", "}", "if ((fpcr & (FPCR_DZE | FPCR_DZED)) == FPCR_DZE) {", "si_code = TARGET_FPE_FLTDIV;", "}", "if ((fpcr & (FPCR_INV | FPCR_INVD)) == FPCR_INV) {", "si_code = TARGET_FPE_FLTINV;", "}", "if (si_code != 0) {", "target_siginfo_t info;", "info.si_signo = SIGFPE;", "info.si_errno = 0;", "info.si_code = si_code;", "info._sifields._sigfault._addr\n= ((CPUArchState *)cpu_env)->pc;", "queue_signal((CPUArchState *)cpu_env, info.si_signo, &info);", "}", "}", "break;", "}", "break;", "#endif\n#ifdef TARGET_NR_osf_sigprocmask\ncase TARGET_NR_osf_sigprocmask:\n{", "abi_ulong VAR_43;", "int VAR_17;", "sigset_t set, oldset;", "switch(arg1) {", "case TARGET_SIG_BLOCK:\nVAR_17 = SIG_BLOCK;", "break;", "case TARGET_SIG_UNBLOCK:\nVAR_17 = SIG_UNBLOCK;", "break;", "case TARGET_SIG_SETMASK:\nVAR_17 = SIG_SETMASK;", "break;", "default:\nret = -TARGET_EINVAL;", "goto fail;", "}", "VAR_43 = arg2;", "target_to_host_old_sigset(&set, &VAR_43);", "sigprocmask(VAR_17, &set, &oldset);", "host_to_target_old_sigset(&VAR_43, &oldset);", "ret = VAR_43;", "}", "break;", "#endif\n#ifdef TARGET_NR_getgid32\ncase TARGET_NR_getgid32:\nret = get_errno(getgid());", "break;", "#endif\n#ifdef TARGET_NR_geteuid32\ncase TARGET_NR_geteuid32:\nret = get_errno(geteuid());", "break;", "#endif\n#ifdef TARGET_NR_getegid32\ncase TARGET_NR_getegid32:\nret = get_errno(getegid());", "break;", "#endif\n#ifdef TARGET_NR_setreuid32\ncase TARGET_NR_setreuid32:\nret = get_errno(setreuid(arg1, arg2));", "break;", "#endif\n#ifdef TARGET_NR_setregid32\ncase TARGET_NR_setregid32:\nret = get_errno(setregid(arg1, arg2));", "break;", "#endif\n#ifdef TARGET_NR_getgroups32\ncase TARGET_NR_getgroups32:\n{", "int VAR_51 = arg1;", "uint32_t *target_grouplist;", "gid_t *grouplist;", "int VAR_51;", "grouplist = alloca(VAR_51 * sizeof(gid_t));", "ret = get_errno(getgroups(VAR_51, grouplist));", "if (VAR_51 == 0)\nbreak;", "if (!is_error(ret)) {", "target_grouplist = lock_user(VERIFY_WRITE, arg2, VAR_51 * 4, 0);", "if (!target_grouplist) {", "ret = -TARGET_EFAULT;", "goto fail;", "}", "for(VAR_51 = 0;VAR_51 < ret; VAR_51++)", "target_grouplist[VAR_51] = tswap32(grouplist[VAR_51]);", "unlock_user(target_grouplist, arg2, VAR_51 * 4);", "}", "}", "break;", "#endif\n#ifdef TARGET_NR_setgroups32\ncase TARGET_NR_setgroups32:\n{", "int VAR_51 = arg1;", "uint32_t *target_grouplist;", "gid_t *grouplist;", "int VAR_51;", "grouplist = alloca(VAR_51 * sizeof(gid_t));", "target_grouplist = lock_user(VERIFY_READ, arg2, VAR_51 * 4, 1);", "if (!target_grouplist) {", "ret = -TARGET_EFAULT;", "goto fail;", "}", "for(VAR_51 = 0;VAR_51 < VAR_51; VAR_51++)", "grouplist[VAR_51] = tswap32(target_grouplist[VAR_51]);", "unlock_user(target_grouplist, arg2, 0);", "ret = get_errno(setgroups(VAR_51, grouplist));", "}", "break;", "#endif\n#ifdef TARGET_NR_fchown32\ncase TARGET_NR_fchown32:\nret = get_errno(fchown(arg1, arg2, arg3));", "break;", "#endif\n#ifdef TARGET_NR_setresuid32\ncase TARGET_NR_setresuid32:\nret = get_errno(setresuid(arg1, arg2, arg3));", "break;", "#endif\n#ifdef TARGET_NR_getresuid32\ncase TARGET_NR_getresuid32:\n{", "uid_t ruid, euid, suid;", "ret = get_errno(getresuid(&ruid, &euid, &suid));", "if (!is_error(ret)) {", "if (put_user_u32(ruid, arg1)\n|| put_user_u32(euid, arg2)\n|| put_user_u32(suid, arg3))\ngoto efault;", "}", "}", "break;", "#endif\n#ifdef TARGET_NR_setresgid32\ncase TARGET_NR_setresgid32:\nret = get_errno(setresgid(arg1, arg2, arg3));", "break;", "#endif\n#ifdef TARGET_NR_getresgid32\ncase TARGET_NR_getresgid32:\n{", "gid_t rgid, egid, sgid;", "ret = get_errno(getresgid(&rgid, &egid, &sgid));", "if (!is_error(ret)) {", "if (put_user_u32(rgid, arg1)\n|| put_user_u32(egid, arg2)\n|| put_user_u32(sgid, arg3))\ngoto efault;", "}", "}", "break;", "#endif\n#ifdef TARGET_NR_chown32\ncase TARGET_NR_chown32:\nif (!(VAR_2 = lock_user_string(arg1)))\ngoto efault;", "ret = get_errno(chown(VAR_2, arg2, arg3));", "unlock_user(VAR_2, arg1, 0);", "break;", "#endif\n#ifdef TARGET_NR_setuid32\ncase TARGET_NR_setuid32:\nret = get_errno(setuid(arg1));", "break;", "#endif\n#ifdef TARGET_NR_setgid32\ncase TARGET_NR_setgid32:\nret = get_errno(setgid(arg1));", "break;", "#endif\n#ifdef TARGET_NR_setfsuid32\ncase TARGET_NR_setfsuid32:\nret = get_errno(setfsuid(arg1));", "break;", "#endif\n#ifdef TARGET_NR_setfsgid32\ncase TARGET_NR_setfsgid32:\nret = get_errno(setfsgid(arg1));", "break;", "#endif\ncase TARGET_NR_pivot_root:\ngoto unimplemented;", "#ifdef TARGET_NR_mincore\ncase TARGET_NR_mincore:\n{", "void *a;", "ret = -TARGET_EFAULT;", "if (!(a = lock_user(VERIFY_READ, arg1,arg2, 0)))\ngoto efault;", "if (!(VAR_2 = lock_user_string(arg3)))\ngoto mincore_fail;", "ret = get_errno(mincore(a, arg2, VAR_2));", "unlock_user(VAR_2, arg3, ret);", "mincore_fail:\nunlock_user(a, arg1, 0);", "}", "break;", "#endif\n#ifdef TARGET_NR_arm_fadvise64_64\ncase TARGET_NR_arm_fadvise64_64:\n{", "abi_long VAR_24;", "VAR_24 = arg3;", "arg3 = arg4;", "arg4 = VAR_24;", "}", "#endif\n#if defined(TARGET_NR_fadvise64_64) || defined(TARGET_NR_arm_fadvise64_64) || defined(TARGET_NR_fadvise64)\n#ifdef TARGET_NR_fadvise64_64\ncase TARGET_NR_fadvise64_64:\n#endif\n#ifdef TARGET_NR_fadvise64\ncase TARGET_NR_fadvise64:\n#endif\n#ifdef TARGET_S390X\nswitch (arg4) {", "case 4: arg4 = POSIX_FADV_NOREUSE + 1; break;", "case 5: arg4 = POSIX_FADV_NOREUSE + 2; break;", "case 6: arg4 = POSIX_FADV_DONTNEED; break;", "case 7: arg4 = POSIX_FADV_NOREUSE; break;", "default: break;", "}", "#endif\nret = -posix_fadvise(arg1, arg2, arg3, arg4);", "break;", "#endif\n#ifdef TARGET_NR_madvise\ncase TARGET_NR_madvise:\nret = get_errno(0);", "break;", "#endif\n#if TARGET_ABI_BITS == 32\ncase TARGET_NR_fcntl64:\n{", "int cmd;", "struct flock64 fl;", "struct target_flock64 *target_fl;", "#ifdef TARGET_ARM\nstruct target_eabi_flock64 *target_efl;", "#endif\ncmd = target_to_host_fcntl_cmd(arg2);", "if (cmd == -TARGET_EINVAL) {", "ret = cmd;", "break;", "}", "switch(arg2) {", "case TARGET_F_GETLK64:\n#ifdef TARGET_ARM\nif (((CPUARMState *)cpu_env)->eabi) {", "if (!lock_user_struct(VERIFY_READ, target_efl, arg3, 1))\ngoto efault;", "fl.l_type = tswap16(target_efl->l_type);", "fl.l_whence = tswap16(target_efl->l_whence);", "fl.l_start = tswap64(target_efl->l_start);", "fl.l_len = tswap64(target_efl->l_len);", "fl.l_pid = tswap32(target_efl->l_pid);", "unlock_user_struct(target_efl, arg3, 0);", "} else", "#endif\n{", "if (!lock_user_struct(VERIFY_READ, target_fl, arg3, 1))\ngoto efault;", "fl.l_type = tswap16(target_fl->l_type);", "fl.l_whence = tswap16(target_fl->l_whence);", "fl.l_start = tswap64(target_fl->l_start);", "fl.l_len = tswap64(target_fl->l_len);", "fl.l_pid = tswap32(target_fl->l_pid);", "unlock_user_struct(target_fl, arg3, 0);", "}", "ret = get_errno(fcntl(arg1, cmd, &fl));", "if (ret == 0) {", "#ifdef TARGET_ARM\nif (((CPUARMState *)cpu_env)->eabi) {", "if (!lock_user_struct(VERIFY_WRITE, target_efl, arg3, 0))\ngoto efault;", "target_efl->l_type = tswap16(fl.l_type);", "target_efl->l_whence = tswap16(fl.l_whence);", "target_efl->l_start = tswap64(fl.l_start);", "target_efl->l_len = tswap64(fl.l_len);", "target_efl->l_pid = tswap32(fl.l_pid);", "unlock_user_struct(target_efl, arg3, 1);", "} else", "#endif\n{", "if (!lock_user_struct(VERIFY_WRITE, target_fl, arg3, 0))\ngoto efault;", "target_fl->l_type = tswap16(fl.l_type);", "target_fl->l_whence = tswap16(fl.l_whence);", "target_fl->l_start = tswap64(fl.l_start);", "target_fl->l_len = tswap64(fl.l_len);", "target_fl->l_pid = tswap32(fl.l_pid);", "unlock_user_struct(target_fl, arg3, 1);", "}", "}", "break;", "case TARGET_F_SETLK64:\ncase TARGET_F_SETLKW64:\n#ifdef TARGET_ARM\nif (((CPUARMState *)cpu_env)->eabi) {", "if (!lock_user_struct(VERIFY_READ, target_efl, arg3, 1))\ngoto efault;", "fl.l_type = tswap16(target_efl->l_type);", "fl.l_whence = tswap16(target_efl->l_whence);", "fl.l_start = tswap64(target_efl->l_start);", "fl.l_len = tswap64(target_efl->l_len);", "fl.l_pid = tswap32(target_efl->l_pid);", "unlock_user_struct(target_efl, arg3, 0);", "} else", "#endif\n{", "if (!lock_user_struct(VERIFY_READ, target_fl, arg3, 1))\ngoto efault;", "fl.l_type = tswap16(target_fl->l_type);", "fl.l_whence = tswap16(target_fl->l_whence);", "fl.l_start = tswap64(target_fl->l_start);", "fl.l_len = tswap64(target_fl->l_len);", "fl.l_pid = tswap32(target_fl->l_pid);", "unlock_user_struct(target_fl, arg3, 0);", "}", "ret = get_errno(fcntl(arg1, cmd, &fl));", "break;", "default:\nret = do_fcntl(arg1, arg2, arg3);", "break;", "}", "break;", "}", "#endif\n#ifdef TARGET_NR_cacheflush\ncase TARGET_NR_cacheflush:\nret = 0;", "break;", "#endif\n#ifdef TARGET_NR_security\ncase TARGET_NR_security:\ngoto unimplemented;", "#endif\n#ifdef TARGET_NR_getpagesize\ncase TARGET_NR_getpagesize:\nret = TARGET_PAGE_SIZE;", "break;", "#endif\ncase TARGET_NR_gettid:\nret = get_errno(gettid());", "break;", "#ifdef TARGET_NR_readahead\ncase TARGET_NR_readahead:\n#if TARGET_ABI_BITS == 32\nif (regpairs_aligned(cpu_env)) {", "arg2 = arg3;", "arg3 = arg4;", "arg4 = arg5;", "}", "ret = get_errno(readahead(arg1, ((off64_t)arg3 << 32) | arg2, arg4));", "#else\nret = get_errno(readahead(arg1, arg2, arg3));", "#endif\nbreak;", "#endif\n#ifdef CONFIG_ATTR\n#ifdef TARGET_NR_setxattr\ncase TARGET_NR_listxattr:\ncase TARGET_NR_llistxattr:\n{", "void *VAR_2, *b = 0;", "if (arg2) {", "b = lock_user(VERIFY_WRITE, arg2, arg3, 0);", "if (!b) {", "ret = -TARGET_EFAULT;", "break;", "}", "}", "VAR_2 = lock_user_string(arg1);", "if (VAR_2) {", "if (num == TARGET_NR_listxattr) {", "ret = get_errno(listxattr(VAR_2, b, arg3));", "} else {", "ret = get_errno(llistxattr(VAR_2, b, arg3));", "}", "} else {", "ret = -TARGET_EFAULT;", "}", "unlock_user(VAR_2, arg1, 0);", "unlock_user(b, arg2, arg3);", "break;", "}", "case TARGET_NR_flistxattr:\n{", "void *b = 0;", "if (arg2) {", "b = lock_user(VERIFY_WRITE, arg2, arg3, 0);", "if (!b) {", "ret = -TARGET_EFAULT;", "break;", "}", "}", "ret = get_errno(flistxattr(arg1, b, arg3));", "unlock_user(b, arg2, arg3);", "break;", "}", "case TARGET_NR_setxattr:\ncase TARGET_NR_lsetxattr:\n{", "void *VAR_2, *n, *v = 0;", "if (arg3) {", "v = lock_user(VERIFY_READ, arg3, arg4, 1);", "if (!v) {", "ret = -TARGET_EFAULT;", "break;", "}", "}", "VAR_2 = lock_user_string(arg1);", "n = lock_user_string(arg2);", "if (VAR_2 && n) {", "if (num == TARGET_NR_setxattr) {", "ret = get_errno(setxattr(VAR_2, n, v, arg4, arg5));", "} else {", "ret = get_errno(lsetxattr(VAR_2, n, v, arg4, arg5));", "}", "} else {", "ret = -TARGET_EFAULT;", "}", "unlock_user(VAR_2, arg1, 0);", "unlock_user(n, arg2, 0);", "unlock_user(v, arg3, 0);", "}", "break;", "case TARGET_NR_fsetxattr:\n{", "void *n, *v = 0;", "if (arg3) {", "v = lock_user(VERIFY_READ, arg3, arg4, 1);", "if (!v) {", "ret = -TARGET_EFAULT;", "break;", "}", "}", "n = lock_user_string(arg2);", "if (n) {", "ret = get_errno(fsetxattr(arg1, n, v, arg4, arg5));", "} else {", "ret = -TARGET_EFAULT;", "}", "unlock_user(n, arg2, 0);", "unlock_user(v, arg3, 0);", "}", "break;", "case TARGET_NR_getxattr:\ncase TARGET_NR_lgetxattr:\n{", "void *VAR_2, *n, *v = 0;", "if (arg3) {", "v = lock_user(VERIFY_WRITE, arg3, arg4, 0);", "if (!v) {", "ret = -TARGET_EFAULT;", "break;", "}", "}", "VAR_2 = lock_user_string(arg1);", "n = lock_user_string(arg2);", "if (VAR_2 && n) {", "if (num == TARGET_NR_getxattr) {", "ret = get_errno(getxattr(VAR_2, n, v, arg4));", "} else {", "ret = get_errno(lgetxattr(VAR_2, n, v, arg4));", "}", "} else {", "ret = -TARGET_EFAULT;", "}", "unlock_user(VAR_2, arg1, 0);", "unlock_user(n, arg2, 0);", "unlock_user(v, arg3, arg4);", "}", "break;", "case TARGET_NR_fgetxattr:\n{", "void *n, *v = 0;", "if (arg3) {", "v = lock_user(VERIFY_WRITE, arg3, arg4, 0);", "if (!v) {", "ret = -TARGET_EFAULT;", "break;", "}", "}", "n = lock_user_string(arg2);", "if (n) {", "ret = get_errno(fgetxattr(arg1, n, v, arg4));", "} else {", "ret = -TARGET_EFAULT;", "}", "unlock_user(n, arg2, 0);", "unlock_user(v, arg3, arg4);", "}", "break;", "case TARGET_NR_removexattr:\ncase TARGET_NR_lremovexattr:\n{", "void *VAR_2, *n;", "VAR_2 = lock_user_string(arg1);", "n = lock_user_string(arg2);", "if (VAR_2 && n) {", "if (num == TARGET_NR_removexattr) {", "ret = get_errno(removexattr(VAR_2, n));", "} else {", "ret = get_errno(lremovexattr(VAR_2, n));", "}", "} else {", "ret = -TARGET_EFAULT;", "}", "unlock_user(VAR_2, arg1, 0);", "unlock_user(n, arg2, 0);", "}", "break;", "case TARGET_NR_fremovexattr:\n{", "void *n;", "n = lock_user_string(arg2);", "if (n) {", "ret = get_errno(fremovexattr(arg1, n));", "} else {", "ret = -TARGET_EFAULT;", "}", "unlock_user(n, arg2, 0);", "}", "break;", "#endif\n#endif\n#ifdef TARGET_NR_set_thread_area\ncase TARGET_NR_set_thread_area:\n#if defined(TARGET_MIPS)\n((CPUMIPSState *) cpu_env)->tls_value = arg1;", "ret = 0;", "break;", "#elif defined(TARGET_CRIS)\nif (arg1 & 0xff)\nret = -TARGET_EINVAL;", "else {", "((CPUCRISState *) cpu_env)->pregs[PR_PID] = arg1;", "ret = 0;", "}", "break;", "#elif defined(TARGET_I386) && defined(TARGET_ABI32)\nret = do_set_thread_area(cpu_env, arg1);", "break;", "#else\ngoto unimplemented_nowarn;", "#endif\n#endif\n#ifdef TARGET_NR_get_thread_area\ncase TARGET_NR_get_thread_area:\n#if defined(TARGET_I386) && defined(TARGET_ABI32)\nret = do_get_thread_area(cpu_env, arg1);", "#else\ngoto unimplemented_nowarn;", "#endif\n#endif\n#ifdef TARGET_NR_getdomainname\ncase TARGET_NR_getdomainname:\ngoto unimplemented_nowarn;", "#endif\n#ifdef TARGET_NR_clock_gettime\ncase TARGET_NR_clock_gettime:\n{", "struct timespec VAR_45;", "ret = get_errno(clock_gettime(arg1, &VAR_45));", "if (!is_error(ret)) {", "host_to_target_timespec(arg2, &VAR_45);", "}", "break;", "}", "#endif\n#ifdef TARGET_NR_clock_getres\ncase TARGET_NR_clock_getres:\n{", "struct timespec VAR_45;", "ret = get_errno(clock_getres(arg1, &VAR_45));", "if (!is_error(ret)) {", "host_to_target_timespec(arg2, &VAR_45);", "}", "break;", "}", "#endif\n#ifdef TARGET_NR_clock_nanosleep\ncase TARGET_NR_clock_nanosleep:\n{", "struct timespec VAR_45;", "target_to_host_timespec(&VAR_45, arg3);", "ret = get_errno(clock_nanosleep(arg1, arg2, &VAR_45, arg4 ? &VAR_45 : NULL));", "if (arg4)\nhost_to_target_timespec(arg4, &VAR_45);", "break;", "}", "#endif\n#if defined(TARGET_NR_set_tid_address) && defined(__NR_set_tid_address)\ncase TARGET_NR_set_tid_address:\nret = get_errno(set_tid_address((int *)g2h(arg1)));", "break;", "#endif\n#if defined(TARGET_NR_tkill) && defined(__NR_tkill)\ncase TARGET_NR_tkill:\nret = get_errno(sys_tkill((int)arg1, target_to_host_signal(arg2)));", "break;", "#endif\n#if defined(TARGET_NR_tgkill) && defined(__NR_tgkill)\ncase TARGET_NR_tgkill:\nret = get_errno(sys_tgkill((int)arg1, (int)arg2,\ntarget_to_host_signal(arg3)));", "break;", "#endif\n#ifdef TARGET_NR_set_robust_list\ncase TARGET_NR_set_robust_list:\ngoto unimplemented_nowarn;", "#endif\n#if defined(TARGET_NR_utimensat) && defined(__NR_utimensat)\ncase TARGET_NR_utimensat:\n{", "struct timespec *tsp, VAR_45[2];", "if (!arg3) {", "tsp = NULL;", "} else {", "target_to_host_timespec(VAR_45, arg3);", "target_to_host_timespec(VAR_45+1, arg3+sizeof(struct target_timespec));", "tsp = VAR_45;", "}", "if (!arg2)\nret = get_errno(sys_utimensat(arg1, NULL, tsp, arg4));", "else {", "if (!(VAR_2 = lock_user_string(arg2))) {", "ret = -TARGET_EFAULT;", "goto fail;", "}", "ret = get_errno(sys_utimensat(arg1, path(VAR_2), tsp, arg4));", "unlock_user(VAR_2, arg2, 0);", "}", "}", "break;", "#endif\n#if defined(CONFIG_USE_NPTL)\ncase TARGET_NR_futex:\nret = do_futex(arg1, arg2, arg3, arg4, arg5, arg6);", "break;", "#endif\n#if defined(TARGET_NR_inotify_init) && defined(__NR_inotify_init)\ncase TARGET_NR_inotify_init:\nret = get_errno(sys_inotify_init());", "break;", "#endif\n#ifdef CONFIG_INOTIFY1\n#if defined(TARGET_NR_inotify_init1) && defined(__NR_inotify_init1)\ncase TARGET_NR_inotify_init1:\nret = get_errno(sys_inotify_init1(arg1));", "break;", "#endif\n#endif\n#if defined(TARGET_NR_inotify_add_watch) && defined(__NR_inotify_add_watch)\ncase TARGET_NR_inotify_add_watch:\nVAR_2 = lock_user_string(arg2);", "ret = get_errno(sys_inotify_add_watch(arg1, path(VAR_2), arg3));", "unlock_user(VAR_2, arg2, 0);", "break;", "#endif\n#if defined(TARGET_NR_inotify_rm_watch) && defined(__NR_inotify_rm_watch)\ncase TARGET_NR_inotify_rm_watch:\nret = get_errno(sys_inotify_rm_watch(arg1, arg2));", "break;", "#endif\n#if defined(TARGET_NR_mq_open) && defined(__NR_mq_open)\ncase TARGET_NR_mq_open:\n{", "struct mq_attr posix_mq_attr;", "VAR_2 = lock_user_string(arg1 - 1);", "if (arg4 != 0)\ncopy_from_user_mq_attr (&posix_mq_attr, arg4);", "ret = get_errno(mq_open(VAR_2, arg2, arg3, &posix_mq_attr));", "unlock_user (VAR_2, arg1, 0);", "}", "break;", "case TARGET_NR_mq_unlink:\nVAR_2 = lock_user_string(arg1 - 1);", "ret = get_errno(mq_unlink(VAR_2));", "unlock_user (VAR_2, arg1, 0);", "break;", "case TARGET_NR_mq_timedsend:\n{", "struct timespec VAR_45;", "VAR_2 = lock_user (VERIFY_READ, arg2, arg3, 1);", "if (arg5 != 0) {", "target_to_host_timespec(&VAR_45, arg5);", "ret = get_errno(mq_timedsend(arg1, VAR_2, arg3, arg4, &VAR_45));", "host_to_target_timespec(arg5, &VAR_45);", "}", "else\nret = get_errno(mq_send(arg1, VAR_2, arg3, arg4));", "unlock_user (VAR_2, arg2, arg3);", "}", "break;", "case TARGET_NR_mq_timedreceive:\n{", "struct timespec VAR_45;", "unsigned int prio;", "VAR_2 = lock_user (VERIFY_READ, arg2, arg3, 1);", "if (arg5 != 0) {", "target_to_host_timespec(&VAR_45, arg5);", "ret = get_errno(mq_timedreceive(arg1, VAR_2, arg3, &prio, &VAR_45));", "host_to_target_timespec(arg5, &VAR_45);", "}", "else\nret = get_errno(mq_receive(arg1, VAR_2, arg3, &prio));", "unlock_user (VAR_2, arg2, arg3);", "if (arg4 != 0)\nput_user_u32(prio, arg4);", "}", "break;", "case TARGET_NR_mq_getsetattr:\n{", "struct mq_attr posix_mq_attr_in, posix_mq_attr_out;", "ret = 0;", "if (arg3 != 0) {", "ret = mq_getattr(arg1, &posix_mq_attr_out);", "copy_to_user_mq_attr(arg3, &posix_mq_attr_out);", "}", "if (arg2 != 0) {", "copy_from_user_mq_attr(&posix_mq_attr_in, arg2);", "ret |= mq_setattr(arg1, &posix_mq_attr_in, &posix_mq_attr_out);", "}", "}", "break;", "#endif\n#ifdef CONFIG_SPLICE\n#ifdef TARGET_NR_tee\ncase TARGET_NR_tee:\n{", "ret = get_errno(tee(arg1,arg2,arg3,arg4));", "}", "break;", "#endif\n#ifdef TARGET_NR_splice\ncase TARGET_NR_splice:\n{", "loff_t loff_in, loff_out;", "loff_t *ploff_in = NULL, *ploff_out = NULL;", "if(arg2) {", "get_user_u64(loff_in, arg2);", "ploff_in = &loff_in;", "}", "if(arg4) {", "get_user_u64(loff_out, arg2);", "ploff_out = &loff_out;", "}", "ret = get_errno(splice(arg1, ploff_in, arg3, ploff_out, arg5, arg6));", "}", "break;", "#endif\n#ifdef TARGET_NR_vmsplice\ncase TARGET_NR_vmsplice:\n{", "int VAR_41 = arg3;", "struct iovec *VAR_41;", "VAR_41 = alloca(VAR_41 * sizeof(struct iovec));", "if (lock_iovec(VERIFY_READ, VAR_41, arg2, VAR_41, 1) < 0)\ngoto efault;", "ret = get_errno(vmsplice(arg1, VAR_41, VAR_41, arg4));", "unlock_iovec(VAR_41, arg2, VAR_41, 0);", "}", "break;", "#endif\n#endif\n#ifdef CONFIG_EVENTFD\n#if defined(TARGET_NR_eventfd)\ncase TARGET_NR_eventfd:\nret = get_errno(eventfd(arg1, 0));", "break;", "#endif\n#if defined(TARGET_NR_eventfd2)\ncase TARGET_NR_eventfd2:\nret = get_errno(eventfd(arg1, arg2));", "break;", "#endif\n#endif\n#if defined(CONFIG_FALLOCATE) && defined(TARGET_NR_fallocate)\ncase TARGET_NR_fallocate:\n#if TARGET_ABI_BITS == 32\nret = get_errno(fallocate(arg1, arg2, target_offset64(arg3, arg4),\ntarget_offset64(arg5, arg6)));", "#else\nret = get_errno(fallocate(arg1, arg2, arg3, arg4));", "#endif\nbreak;", "#endif\n#if defined(CONFIG_SYNC_FILE_RANGE)\n#if defined(TARGET_NR_sync_file_range)\ncase TARGET_NR_sync_file_range:\n#if TARGET_ABI_BITS == 32\n#if defined(TARGET_MIPS)\nret = get_errno(sync_file_range(arg1, target_offset64(arg3, arg4),\ntarget_offset64(arg5, arg6), arg7));", "#else\nret = get_errno(sync_file_range(arg1, target_offset64(arg2, arg3),\ntarget_offset64(arg4, arg5), arg6));", "#endif\n#else\nret = get_errno(sync_file_range(arg1, arg2, arg3, arg4));", "#endif\nbreak;", "#endif\n#if defined(TARGET_NR_sync_file_range2)\ncase TARGET_NR_sync_file_range2:\n#if TARGET_ABI_BITS == 32\nret = get_errno(sync_file_range(arg1, target_offset64(arg3, arg4),\ntarget_offset64(arg5, arg6), arg2));", "#else\nret = get_errno(sync_file_range(arg1, arg3, arg4, arg2));", "#endif\nbreak;", "#endif\n#endif\n#if defined(CONFIG_EPOLL)\n#if defined(TARGET_NR_epoll_create)\ncase TARGET_NR_epoll_create:\nret = get_errno(epoll_create(arg1));", "break;", "#endif\n#if defined(TARGET_NR_epoll_create1) && defined(CONFIG_EPOLL_CREATE1)\ncase TARGET_NR_epoll_create1:\nret = get_errno(epoll_create1(arg1));", "break;", "#endif\n#if defined(TARGET_NR_epoll_ctl)\ncase TARGET_NR_epoll_ctl:\n{", "struct epoll_event ep;", "struct epoll_event *epp = 0;", "if (arg4) {", "struct target_epoll_event *target_ep;", "if (!lock_user_struct(VERIFY_READ, target_ep, arg4, 1)) {", "goto efault;", "}", "ep.events = tswap32(target_ep->events);", "ep.data.u64 = tswap64(target_ep->data.u64);", "unlock_user_struct(target_ep, arg4, 0);", "epp = &ep;", "}", "ret = get_errno(epoll_ctl(arg1, arg2, arg3, epp));", "break;", "}", "#endif\n#if defined(TARGET_NR_epoll_pwait) && defined(CONFIG_EPOLL_PWAIT)\n#define IMPLEMENT_EPOLL_PWAIT\n#endif\n#if defined(TARGET_NR_epoll_wait) || defined(IMPLEMENT_EPOLL_PWAIT)\n#if defined(TARGET_NR_epoll_wait)\ncase TARGET_NR_epoll_wait:\n#endif\n#if defined(IMPLEMENT_EPOLL_PWAIT)\ncase TARGET_NR_epoll_pwait:\n#endif\n{", "struct target_epoll_event *target_ep;", "struct epoll_event *ep;", "int epfd = arg1;", "int maxevents = arg3;", "int timeout = arg4;", "target_ep = lock_user(VERIFY_WRITE, arg2,\nmaxevents * sizeof(struct target_epoll_event), 1);", "if (!target_ep) {", "goto efault;", "}", "ep = alloca(maxevents * sizeof(struct epoll_event));", "switch (num) {", "#if defined(IMPLEMENT_EPOLL_PWAIT)\ncase TARGET_NR_epoll_pwait:\n{", "target_sigset_t *target_set;", "sigset_t _set, *set = &_set;", "if (arg5) {", "target_set = lock_user(VERIFY_READ, arg5,\nsizeof(target_sigset_t), 1);", "if (!target_set) {", "unlock_user(target_ep, arg2, 0);", "goto efault;", "}", "target_to_host_sigset(set, target_set);", "unlock_user(target_set, arg5, 0);", "} else {", "set = NULL;", "}", "ret = get_errno(epoll_pwait(epfd, ep, maxevents, timeout, set));", "break;", "}", "#endif\n#if defined(TARGET_NR_epoll_wait)\ncase TARGET_NR_epoll_wait:\nret = get_errno(epoll_wait(epfd, ep, maxevents, timeout));", "break;", "#endif\ndefault:\nret = -TARGET_ENOSYS;", "}", "if (!is_error(ret)) {", "int VAR_51;", "for (VAR_51 = 0; VAR_51 < ret; VAR_51++) {", "target_ep[VAR_51].events = tswap32(ep[VAR_51].events);", "target_ep[VAR_51].data.u64 = tswap64(ep[VAR_51].data.u64);", "}", "}", "unlock_user(target_ep, arg2, ret * sizeof(struct target_epoll_event));", "break;", "}", "#endif\n#endif\n#ifdef TARGET_NR_prlimit64\ncase TARGET_NR_prlimit64:\n{", "struct target_rlimit64 *target_rnew, *target_rold;", "struct host_rlimit64 rnew, rold, *rnewp = 0;", "if (arg3) {", "if (!lock_user_struct(VERIFY_READ, target_rnew, arg3, 1)) {", "goto efault;", "}", "rnew.rlim_cur = tswap64(target_rnew->rlim_cur);", "rnew.rlim_max = tswap64(target_rnew->rlim_max);", "unlock_user_struct(target_rnew, arg3, 0);", "rnewp = &rnew;", "}", "ret = get_errno(sys_prlimit64(arg1, arg2, rnewp, arg4 ? &rold : 0));", "if (!is_error(ret) && arg4) {", "if (!lock_user_struct(VERIFY_WRITE, target_rold, arg4, 1)) {", "goto efault;", "}", "target_rold->rlim_cur = tswap64(rold.rlim_cur);", "target_rold->rlim_max = tswap64(rold.rlim_max);", "unlock_user_struct(target_rold, arg4, 1);", "}", "break;", "}", "#endif\ndefault:\nunimplemented:\ngemu_log(\"qemu: Unsupported syscall: %d\\n\", num);", "#if defined(TARGET_NR_setxattr) || defined(TARGET_NR_get_thread_area) || defined(TARGET_NR_getdomainname) || defined(TARGET_NR_set_robust_list)\nunimplemented_nowarn:\n#endif\nret = -TARGET_ENOSYS;", "break;", "}", "fail:\n#ifdef DEBUG\ngemu_log(\" = \" TARGET_ABI_FMT_ld \"\\n\", ret);", "#endif\nif(do_strace)\nprint_syscall_ret(num, ret);", "return ret;", "efault:\nret = -TARGET_EFAULT;", "goto fail;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21, 23 ], [ 25, 27, 29 ], [ 33 ], [ 35, 37, 51 ], [ 53 ], [ 55 ], [ 57 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 79, 81 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95, 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111, 113, 115 ], [ 117, 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127, 129, 131 ], [ 133 ], [ 135, 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147, 149, 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159, 161, 163 ], [ 165, 167, 169 ], [ 171 ], [ 173 ], [ 175, 177, 179, 181 ], [ 183, 185, 187, 189 ], [ 191 ], [ 193 ], [ 195, 197, 199 ], [ 201 ], [ 203, 205 ], [ 207 ], [ 209, 211 ], [ 213 ], [ 215, 217, 219 ], [ 221 ], [ 223 ], [ 225, 227, 229 ], [ 231 ], [ 233 ], [ 235, 237, 239, 241 ], [ 243 ], [ 245 ], [ 247 ], [ 249 ], [ 251, 253 ], [ 255 ], [ 257 ], [ 259 ], [ 261 ], [ 263 ], [ 265, 267, 269, 271, 273 ], [ 275 ], [ 277 ], [ 279 ], [ 281, 283, 285 ], [ 287 ], [ 289 ], [ 291 ], [ 293, 295 ], [ 297, 299 ], [ 301 ], [ 303 ], [ 305 ], [ 307 ], [ 309, 311, 313 ], [ 315 ], [ 317, 319 ], [ 321 ], [ 323 ], [ 325, 327 ], [ 329, 331 ], [ 333 ], [ 335 ], [ 337 ], [ 339 ], [ 341, 343, 345, 347 ], [ 349 ], [ 351 ], [ 353 ], [ 355, 357, 359, 361 ], [ 363 ], [ 365 ], [ 367 ], [ 369, 371, 373 ], [ 375 ], [ 377 ], [ 379 ], [ 381 ], [ 383 ], [ 385 ], [ 387 ], [ 389 ], [ 393 ], [ 395 ], [ 397 ], [ 399, 401 ], [ 403, 405 ], [ 407 ], [ 409 ], [ 411 ], [ 413 ], [ 415 ], [ 417, 419 ], [ 421, 423 ], [ 425 ], [ 427 ], [ 431 ], [ 433 ], [ 437 ], [ 439 ], [ 441, 443 ], [ 445, 447 ], [ 449, 451 ], [ 453 ], [ 455 ], [ 457 ], [ 461 ], [ 463 ], [ 465, 467 ], [ 469, 471 ], [ 473, 475 ], [ 477 ], [ 479 ], [ 481 ], [ 489 ], [ 491 ], [ 493 ], [ 495 ], [ 497, 499 ], [ 501 ], [ 503 ], [ 507 ], [ 511, 513 ], [ 517, 519 ], [ 521 ], [ 523, 525, 527 ], [ 529 ], [ 531 ], [ 533 ], [ 535 ], [ 537, 539, 541 ], [ 543 ], [ 545 ], [ 547 ], [ 549 ], [ 551, 553, 555 ], [ 557 ], [ 559 ], [ 561 ], [ 563, 565, 567 ], [ 569 ], [ 571 ], [ 573, 575, 577, 579 ], [ 581 ], [ 583 ], [ 585, 587, 589, 591 ], [ 593 ], [ 595 ], [ 597 ], [ 599, 601, 603, 605 ], [ 607 ], [ 609 ], [ 611 ], [ 613, 615, 617, 619 ], [ 621 ], [ 623 ], [ 625 ], [ 627, 629, 631 ], [ 633, 635, 637, 639 ], [ 641, 643, 645 ], [ 647 ], [ 649, 653, 655 ], [ 657 ], [ 659 ], [ 661, 663, 665, 667 ], [ 669 ], [ 671, 673, 675 ], [ 679 ], [ 681 ], [ 683 ], [ 685 ], [ 687, 689 ], [ 691 ], [ 701, 703 ], [ 705, 707 ], [ 709 ], [ 711 ], [ 713 ], [ 715 ], [ 717 ], [ 719 ], [ 721, 723, 725, 727 ], [ 729 ], [ 731 ], [ 733 ], [ 735, 737, 739, 741 ], [ 743 ], [ 745, 747 ], [ 749 ], [ 751 ], [ 753 ], [ 755, 757, 759 ], [ 761, 763, 765 ], [ 767 ], [ 769, 771, 773, 775 ], [ 777, 779, 781, 783 ], [ 785 ], [ 787, 789, 791, 793 ], [ 795 ], [ 797 ], [ 799 ], [ 801, 803 ], [ 805 ], [ 807 ], [ 809 ], [ 811 ], [ 813 ], [ 815 ], [ 817 ], [ 819, 821 ], [ 823 ], [ 825 ], [ 827 ], [ 829 ], [ 831, 833, 835 ], [ 837 ], [ 839 ], [ 841, 843, 845, 847 ], [ 849 ], [ 851 ], [ 853 ], [ 855 ], [ 857, 859 ], [ 861 ], [ 863 ], [ 865 ], [ 867 ], [ 869, 871, 873 ], [ 875 ], [ 877 ], [ 879, 881, 883, 885 ], [ 887 ], [ 889 ], [ 891 ], [ 893 ], [ 895, 897 ], [ 899 ], [ 901 ], [ 903 ], [ 905 ], [ 907, 909, 911, 913 ], [ 915, 917, 919, 921 ], [ 923, 925, 927, 929 ], [ 931 ], [ 933 ], [ 935 ], [ 937, 939, 941, 943 ], [ 945 ], [ 947 ], [ 949 ], [ 951, 953, 955, 957 ], [ 959 ], [ 961, 963, 965, 967 ], [ 969, 971, 973 ], [ 975 ], [ 977 ], [ 979, 981 ], [ 983 ], [ 985, 987 ], [ 989 ], [ 991 ], [ 993 ], [ 995, 997 ], [ 999, 1001 ], [ 1003 ], [ 1005 ], [ 1007 ], [ 1009 ], [ 1011, 1013, 1015 ], [ 1017 ], [ 1019 ], [ 1021 ], [ 1023, 1025 ], [ 1027, 1029 ], [ 1031 ], [ 1033 ], [ 1035 ], [ 1037 ], [ 1039, 1041, 1043, 1045 ], [ 1047 ], [ 1049 ], [ 1051 ], [ 1053, 1055, 1057, 1059 ], [ 1061 ], [ 1063 ], [ 1065 ], [ 1067, 1069, 1071, 1073 ], [ 1075 ], [ 1077 ], [ 1079 ], [ 1081, 1083 ], [ 1085 ], [ 1087, 1089 ], [ 1091 ], [ 1093, 1095, 1097, 1099 ], [ 1101 ], [ 1103, 1105, 1107 ], [ 1109 ], [ 1111 ], [ 1113 ], [ 1115 ], [ 1117 ], [ 1119, 1121 ], [ 1123 ], [ 1125 ], [ 1127 ], [ 1129 ], [ 1131 ], [ 1133, 1135 ], [ 1137 ], [ 1139 ], [ 1141, 1143, 1145 ], [ 1147, 1149, 1151, 1153 ], [ 1155, 1157, 1159 ], [ 1161 ], [ 1163 ], [ 1165, 1167 ], [ 1169 ], [ 1171 ], [ 1173 ], [ 1175 ], [ 1177, 1179, 1181, 1183 ], [ 1185 ], [ 1187 ], [ 1189 ], [ 1191, 1193, 1195, 1197 ], [ 1199, 1201, 1203 ], [ 1205 ], [ 1207, 1209 ], [ 1211 ], [ 1213, 1215, 1217 ], [ 1219, 1221, 1223 ], [ 1225 ], [ 1227, 1229, 1231 ], [ 1233, 1235, 1237, 1239 ], [ 1241, 1243, 1245 ], [ 1247 ], [ 1249, 1251, 1253 ], [ 1255 ], [ 1257 ], [ 1259 ], [ 1261, 1263 ], [ 1265, 1267 ], [ 1269 ], [ 1271, 1273, 1275 ], [ 1277 ], [ 1279, 1281, 1283, 1285 ], [ 1287 ], [ 1289, 1291, 1293 ], [ 1295 ], [ 1297, 1299 ], [ 1301 ], [ 1303, 1305, 1307 ], [ 1309, 1311 ], [ 1313 ], [ 1315 ], [ 1317, 1319 ], [ 1321 ], [ 1323 ], [ 1325 ], [ 1327 ], [ 1329 ], [ 1331 ], [ 1333 ], [ 1335 ], [ 1337 ], [ 1339, 1341 ], [ 1343 ], [ 1345 ], [ 1347 ], [ 1349 ], [ 1351 ], [ 1353, 1355 ], [ 1359 ], [ 1361, 1363 ], [ 1365 ], [ 1367 ], [ 1369 ], [ 1371 ], [ 1373 ], [ 1375 ], [ 1377 ], [ 1379 ], [ 1383 ], [ 1387 ], [ 1389, 1391 ], [ 1393 ], [ 1395 ], [ 1397 ], [ 1399 ], [ 1401 ], [ 1403 ], [ 1405 ], [ 1407 ], [ 1409, 1411 ], [ 1413 ], [ 1415 ], [ 1417, 1419 ], [ 1421 ], [ 1423 ], [ 1425 ], [ 1427 ], [ 1429 ], [ 1431 ], [ 1433 ], [ 1435 ], [ 1437 ], [ 1439 ], [ 1441 ], [ 1443, 1445 ], [ 1447 ], [ 1449 ], [ 1451 ], [ 1453 ], [ 1455 ], [ 1457 ], [ 1459, 1461 ], [ 1463 ], [ 1465, 1467, 1469 ], [ 1471, 1473 ], [ 1475 ], [ 1479 ], [ 1481, 1483 ], [ 1485 ], [ 1487 ], [ 1489 ], [ 1491 ], [ 1493 ], [ 1495 ], [ 1497 ], [ 1499 ], [ 1501 ], [ 1503, 1505 ], [ 1507 ], [ 1509 ], [ 1511 ], [ 1513 ], [ 1515 ], [ 1517, 1519 ], [ 1521 ], [ 1525 ], [ 1527, 1529 ], [ 1531 ], [ 1533 ], [ 1535 ], [ 1537 ], [ 1539 ], [ 1541 ], [ 1543 ], [ 1545 ], [ 1547 ], [ 1549 ], [ 1551, 1553, 1555 ], [ 1557, 1559 ], [ 1561, 1563 ], [ 1565 ], [ 1567, 1569, 1571 ], [ 1573 ], [ 1575 ], [ 1577 ], [ 1579 ], [ 1581 ], [ 1583 ], [ 1585 ], [ 1587, 1589, 1591, 1593 ], [ 1595 ], [ 1597 ], [ 1599 ], [ 1601 ], [ 1603 ], [ 1605 ], [ 1607 ], [ 1609 ], [ 1611 ], [ 1613 ], [ 1615, 1617, 1619, 1621 ], [ 1623, 1625 ], [ 1627 ], [ 1629 ], [ 1633 ], [ 1635, 1637 ], [ 1639 ], [ 1641, 1643 ], [ 1645 ], [ 1647, 1649 ], [ 1651 ], [ 1653, 1655 ], [ 1657 ], [ 1659 ], [ 1661 ], [ 1663 ], [ 1667 ], [ 1669 ], [ 1671 ], [ 1673 ], [ 1675 ], [ 1677 ], [ 1679, 1681 ], [ 1683 ], [ 1687 ], [ 1689 ], [ 1691, 1693 ], [ 1695 ], [ 1697, 1699 ], [ 1701 ], [ 1703, 1705 ], [ 1707 ], [ 1709, 1711 ], [ 1713 ], [ 1715 ], [ 1717, 1719 ], [ 1721 ], [ 1723 ], [ 1725 ], [ 1727 ], [ 1729 ], [ 1731 ], [ 1733 ], [ 1735 ], [ 1737 ], [ 1739, 1741 ], [ 1743 ], [ 1745 ], [ 1747 ], [ 1749, 1751 ], [ 1753 ], [ 1755, 1757, 1759 ], [ 1761 ], [ 1763 ], [ 1767 ], [ 1769 ], [ 1771, 1773 ], [ 1775 ], [ 1777, 1779 ], [ 1781 ], [ 1783, 1785 ], [ 1787 ], [ 1789, 1791 ], [ 1793 ], [ 1795 ], [ 1797, 1799 ], [ 1801 ], [ 1803 ], [ 1805 ], [ 1807 ], [ 1809 ], [ 1811 ], [ 1813 ], [ 1815 ], [ 1817 ], [ 1819, 1821 ], [ 1823 ], [ 1825 ], [ 1827 ], [ 1829 ], [ 1831 ], [ 1833, 1835, 1837 ], [ 1839 ], [ 1841 ], [ 1843 ], [ 1845, 1847 ], [ 1849 ], [ 1851 ], [ 1853 ], [ 1855 ], [ 1857 ], [ 1859, 1861, 1863 ], [ 1865 ], [ 1867 ], [ 1869 ], [ 1871, 1873 ], [ 1875 ], [ 1877 ], [ 1879 ], [ 1881 ], [ 1883 ], [ 1885, 1887, 1889 ], [ 1891 ], [ 1893, 1895 ], [ 1897 ], [ 1899, 1901, 1903 ], [ 1905 ], [ 1907 ], [ 1909, 1911 ], [ 1913 ], [ 1915 ], [ 1917, 1919, 1921 ], [ 1923 ], [ 1925, 1927 ], [ 1929 ], [ 1931 ], [ 1933 ], [ 1935 ], [ 1937 ], [ 1939, 1941 ], [ 1943 ], [ 1945 ], [ 1947 ], [ 1951, 1953 ], [ 1955 ], [ 1957 ], [ 1959 ], [ 1961 ], [ 1963 ], [ 1965 ], [ 1967 ], [ 1969 ], [ 1971 ], [ 1973 ], [ 1975, 1977 ], [ 1979 ], [ 1981 ], [ 1983 ], [ 1985 ], [ 1987 ], [ 1989, 1991 ], [ 1993 ], [ 1995, 1997 ], [ 1999 ], [ 2001 ], [ 2003 ], [ 2005 ], [ 2007 ], [ 2009, 2011, 2015 ], [ 2017 ], [ 2019, 2021, 2025 ], [ 2027 ], [ 2029, 2031, 2033 ], [ 2035 ], [ 2037 ], [ 2039 ], [ 2041, 2043 ], [ 2045 ], [ 2047 ], [ 2049 ], [ 2051, 2053 ], [ 2055 ], [ 2057 ], [ 2059 ], [ 2061 ], [ 2063 ], [ 2065 ], [ 2067, 2069 ], [ 2071 ], [ 2073 ], [ 2075 ], [ 2079 ], [ 2081 ], [ 2083, 2085 ], [ 2087 ], [ 2089 ], [ 2091 ], [ 2093 ], [ 2095 ], [ 2097 ], [ 2099, 2101 ], [ 2103 ], [ 2105 ], [ 2107 ], [ 2109 ], [ 2111 ], [ 2113 ], [ 2115 ], [ 2117, 2119 ], [ 2121 ], [ 2123 ], [ 2125 ], [ 2127, 2129 ], [ 2131 ], [ 2133 ], [ 2135 ], [ 2137, 2139 ], [ 2141 ], [ 2143, 2145 ], [ 2147 ], [ 2149 ], [ 2151 ], [ 2153, 2155, 2157 ], [ 2159 ], [ 2161 ], [ 2163 ], [ 2167, 2169 ], [ 2171 ], [ 2173 ], [ 2175 ], [ 2177 ], [ 2179 ], [ 2181 ], [ 2183 ], [ 2185 ], [ 2187 ], [ 2189, 2191, 2193, 2195 ], [ 2197 ], [ 2199 ], [ 2201 ], [ 2203 ], [ 2215 ], [ 2217 ], [ 2219 ], [ 2221 ], [ 2223 ], [ 2227 ], [ 2229 ], [ 2233 ], [ 2235 ], [ 2237 ], [ 2239 ], [ 2241 ], [ 2245 ], [ 2247 ], [ 2249 ], [ 2251 ], [ 2253 ], [ 2255 ], [ 2257 ], [ 2259 ], [ 2261 ], [ 2263 ], [ 2265 ], [ 2267 ], [ 2279 ], [ 2281 ], [ 2283 ], [ 2285 ], [ 2287 ], [ 2289 ], [ 2291 ], [ 2293 ], [ 2299 ], [ 2301 ], [ 2303 ], [ 2307 ], [ 2309 ], [ 2311 ], [ 2313 ], [ 2315 ], [ 2317 ], [ 2319 ], [ 2323 ], [ 2325 ], [ 2327 ], [ 2331 ], [ 2333 ], [ 2335 ], [ 2337, 2339 ], [ 2341 ], [ 2343 ], [ 2345 ], [ 2347 ], [ 2349 ], [ 2351 ], [ 2353 ], [ 2355 ], [ 2357 ], [ 2359 ], [ 2361 ], [ 2365, 2367 ], [ 2371 ], [ 2373, 2375 ], [ 2377, 2379 ], [ 2381, 2383 ], [ 2387, 2389 ], [ 2391 ], [ 2393 ], [ 2395 ], [ 2397, 2399, 2401 ], [ 2403 ], [ 2405 ], [ 2407 ], [ 2409, 2411 ], [ 2413, 2415 ], [ 2417 ], [ 2419 ], [ 2421 ], [ 2423 ], [ 2425, 2427, 2429 ], [ 2431 ], [ 2433 ], [ 2435 ], [ 2437, 2439 ], [ 2441, 2443 ], [ 2445 ], [ 2447 ], [ 2449 ], [ 2451 ], [ 2453, 2455, 2457, 2459 ], [ 2461, 2463, 2465 ], [ 2467 ], [ 2469 ], [ 2471 ], [ 2473, 2475 ], [ 2477 ], [ 2479 ], [ 2481 ], [ 2483 ], [ 2485 ], [ 2487 ], [ 2489 ], [ 2491, 2493 ], [ 2495 ], [ 2497 ], [ 2499 ], [ 2501 ], [ 2503 ], [ 2505, 2507, 2509 ], [ 2511 ], [ 2513 ], [ 2515 ], [ 2517, 2519 ], [ 2521, 2523 ], [ 2525 ], [ 2527 ], [ 2529 ], [ 2531 ], [ 2533, 2535, 2537, 2539 ], [ 2541, 2543, 2545, 2547, 2549 ], [ 2551 ], [ 2553 ], [ 2555 ], [ 2557, 2559, 2561, 2563 ], [ 2565 ], [ 2567 ], [ 2569 ], [ 2571, 2573, 2575 ], [ 2577, 2579, 2581, 2583, 2585, 2587, 2589 ], [ 2591 ], [ 2593 ], [ 2595, 2597 ], [ 2599 ], [ 2601 ], [ 2603 ], [ 2605 ], [ 2607 ], [ 2609 ], [ 2611 ], [ 2613, 2615, 2617 ], [ 2619 ], [ 2621, 2623, 2625, 2627, 2629 ], [ 2631, 2633 ], [ 2635, 2637, 2639, 2641, 2643, 2645, 2647, 2649, 2651, 2653 ], [ 2655 ], [ 2657, 2659, 2661 ], [ 2663 ], [ 2665, 2667 ], [ 2669 ], [ 2673, 2675, 2677 ], [ 2679 ], [ 2681 ], [ 2683 ], [ 2685 ], [ 2687 ], [ 2689 ], [ 2691 ], [ 2693, 2695, 2697 ], [ 2699 ], [ 2701, 2705, 2707, 2709 ], [ 2711 ], [ 2713, 2715, 2717, 2719 ], [ 2721 ], [ 2723, 2725, 2727, 2729 ], [ 2731 ], [ 2733, 2735, 2737, 2739 ], [ 2741 ], [ 2743, 2745, 2747, 2749 ], [ 2751 ], [ 2753, 2755, 2757, 2759 ], [ 2761 ], [ 2763 ], [ 2765 ], [ 2767, 2769 ], [ 2771 ], [ 2773, 2775 ], [ 2777 ], [ 2779, 2781, 2783, 2785 ], [ 2787 ], [ 2789 ], [ 2791 ], [ 2793, 2795, 2801 ], [ 2803 ], [ 2805 ], [ 2807 ], [ 2809 ], [ 2811 ], [ 2813, 2817 ], [ 2819, 2823 ], [ 2825, 2827 ], [ 2829, 2831 ], [ 2833 ], [ 2835, 2837, 2839 ], [ 2841, 2843, 2845, 2847 ], [ 2849 ], [ 2851 ], [ 2853, 2855 ], [ 2857 ], [ 2861, 2863 ], [ 2865 ], [ 2867 ], [ 2869 ], [ 2871 ], [ 2873 ], [ 2875 ], [ 2877 ], [ 2879 ], [ 2881 ], [ 2883 ], [ 2885 ], [ 2887 ], [ 2889 ], [ 2891 ], [ 2893 ], [ 2895, 2897 ], [ 2899 ], [ 2901, 2903, 2905, 2907 ], [ 2909 ], [ 2911 ], [ 2913, 2915 ], [ 2917 ], [ 2921, 2923 ], [ 2925 ], [ 2927 ], [ 2929 ], [ 2931 ], [ 2933 ], [ 2935 ], [ 2937 ], [ 2939 ], [ 2941 ], [ 2943 ], [ 2945 ], [ 2947 ], [ 2949 ], [ 2951 ], [ 2953 ], [ 2955, 2957 ], [ 2959 ], [ 2961, 2963, 2965, 2967 ], [ 2969, 2971, 2973, 2975 ], [ 2977 ], [ 2979, 2981, 2983, 2985 ], [ 2987 ], [ 2989, 2991, 2993, 2995 ], [ 2997 ], [ 2999, 3001, 3003, 3005 ], [ 3007 ], [ 3009, 3011, 3013, 3015 ], [ 3017 ], [ 3019, 3021, 3023, 3025 ], [ 3027 ], [ 3029, 3031, 3033, 3035 ], [ 3037 ], [ 3039, 3041, 3043, 3045 ], [ 3047 ], [ 3049, 3051, 3053, 3055 ], [ 3057 ], [ 3059, 3061, 3063, 3065 ], [ 3067 ], [ 3069, 3071, 3073, 3075 ], [ 3077 ], [ 3079, 3081, 3083, 3085 ], [ 3087 ], [ 3089, 3091, 3093, 3095 ], [ 3097 ], [ 3099, 3101, 3103, 3105 ], [ 3107 ], [ 3109, 3111, 3113, 3115 ], [ 3117 ], [ 3119, 3121, 3123, 3125 ], [ 3127 ], [ 3129, 3131, 3133, 3135 ], [ 3137 ], [ 3139, 3141, 3143, 3145 ], [ 3147 ], [ 3149, 3153, 3155, 3157 ], [ 3159 ], [ 3161 ], [ 3163 ], [ 3167, 3169 ], [ 3171 ], [ 3175 ], [ 3177 ], [ 3179, 3181, 3183, 3185 ], [ 3187 ], [ 3189 ], [ 3191 ], [ 3193 ], [ 3195 ], [ 3197, 3199, 3201, 3203, 3205 ], [ 3207 ], [ 3209 ], [ 3211 ], [ 3213, 3215 ], [ 3217 ], [ 3221 ], [ 3223 ], [ 3225, 3227, 3229, 3231, 3233 ], [ 3235 ], [ 3237 ], [ 3239 ], [ 3241, 3243, 3245 ], [ 3247 ], [ 3249 ], [ 3251 ], [ 3253, 3255, 3257 ], [ 3259 ], [ 3261 ], [ 3263 ], [ 3265, 3267 ], [ 3269 ], [ 3271, 3273 ], [ 3275 ], [ 3279, 3281 ], [ 3283 ], [ 3285 ], [ 3287 ], [ 3289 ], [ 3291 ], [ 3293 ], [ 3295 ], [ 3297 ], [ 3299 ], [ 3301 ], [ 3303 ], [ 3305 ], [ 3307 ], [ 3309 ], [ 3311 ], [ 3313 ], [ 3315 ], [ 3317 ], [ 3319, 3321, 3323 ], [ 3325, 3327, 3329, 3331 ], [ 3333, 3335, 3337 ], [ 3339 ], [ 3341, 3343, 3345 ], [ 3347, 3349, 3351, 3353, 3355 ], [ 3357 ], [ 3359, 3361, 3363 ], [ 3365 ], [ 3367 ], [ 3369 ], [ 3371 ], [ 3373, 3375 ], [ 3377, 3379 ], [ 3381 ], [ 3383 ], [ 3385 ], [ 3387 ], [ 3389, 3391 ], [ 3393 ], [ 3395, 3397 ], [ 3399 ], [ 3401 ], [ 3403 ], [ 3405, 3407, 3409, 3411 ], [ 3413 ], [ 3415 ], [ 3417 ], [ 3419, 3421, 3423 ], [ 3425 ], [ 3427 ], [ 3429 ], [ 3431, 3433 ], [ 3435, 3437 ], [ 3439 ], [ 3441 ], [ 3443 ], [ 3445 ], [ 3447 ], [ 3449 ], [ 3451 ], [ 3453 ], [ 3455 ], [ 3457 ], [ 3459 ], [ 3461 ], [ 3463 ], [ 3465 ], [ 3467 ], [ 3469 ], [ 3471 ], [ 3473 ], [ 3475, 3477, 3479 ], [ 3481 ], [ 3483, 3485, 3487, 3489 ], [ 3491 ], [ 3493, 3495, 3497, 3499 ], [ 3501 ], [ 3503, 3505, 3507, 3509 ], [ 3511 ], [ 3513, 3515, 3517, 3519 ], [ 3521 ], [ 3523, 3525, 3527, 3529 ], [ 3531 ], [ 3533, 3535, 3537, 3539 ], [ 3541 ], [ 3543, 3545, 3547, 3549 ], [ 3551 ], [ 3553, 3555, 3557, 3559 ], [ 3561 ], [ 3563, 3565, 3567, 3569 ], [ 3571 ], [ 3573, 3575, 3577, 3579 ], [ 3581 ], [ 3583, 3585, 3587, 3589 ], [ 3591 ], [ 3593, 3595, 3597 ], [ 3599 ], [ 3601, 3603, 3605 ], [ 3607, 3609 ], [ 3611, 3613 ], [ 3615, 3617 ], [ 3619, 3621 ], [ 3623, 3627, 3629, 3631 ], [ 3633, 3635 ], [ 3637 ], [ 3639 ], [ 3641, 3643, 3645, 3647 ], [ 3649 ], [ 3651 ], [ 3653 ], [ 3655, 3659 ], [ 3661 ], [ 3665, 3667 ], [ 3669 ], [ 3671 ], [ 3677 ], [ 3681, 3683 ], [ 3685 ], [ 3687 ], [ 3689 ], [ 3691 ], [ 3693, 3695, 3697 ], [ 3699 ], [ 3701, 3703, 3705 ], [ 3707, 3709 ], [ 3711 ], [ 3713, 3715, 3717, 3719 ], [ 3721, 3723, 3725, 3727, 3729, 3731, 3733, 3735, 3737 ], [ 3739, 3741 ], [ 3743, 3745 ], [ 3747 ], [ 3749, 3751 ], [ 3753 ], [ 3755, 3757, 3759 ], [ 3761, 3763, 3765, 3767 ], [ 3769, 3771, 3773 ], [ 3775 ], [ 3777, 3779, 3781 ], [ 3783, 3785, 3787, 3789 ], [ 3791 ], [ 3793, 3795 ], [ 3797 ], [ 3799 ], [ 3801 ], [ 3803 ], [ 3805 ], [ 3807, 3809 ], [ 3811, 3813 ], [ 3815 ], [ 3817 ], [ 3819 ], [ 3821 ], [ 3823, 3825, 3827, 3829 ], [ 3831 ], [ 3833 ], [ 3835 ], [ 3839 ], [ 3841 ], [ 3843 ], [ 3845 ], [ 3847 ], [ 3851 ], [ 3853 ], [ 3855 ], [ 3857 ], [ 3859 ], [ 3861 ], [ 3863 ], [ 3867 ], [ 3869 ], [ 3871, 3873 ], [ 3875 ], [ 3877 ], [ 3879 ], [ 3881 ], [ 3883 ], [ 3885 ], [ 3887 ], [ 3889 ], [ 3891 ], [ 3893 ], [ 3895 ], [ 3897 ], [ 3899 ], [ 3901 ], [ 3903 ], [ 3905 ], [ 3907 ], [ 3909 ], [ 3911 ], [ 3913 ], [ 3915 ], [ 3917, 3919 ], [ 3921 ], [ 3923 ], [ 3927, 3929 ], [ 3931 ], [ 3933 ], [ 3935 ], [ 3937 ], [ 3939 ], [ 3941 ], [ 3943 ], [ 3945 ], [ 3947, 3949 ], [ 3951 ], [ 3953 ], [ 3955 ], [ 3957 ], [ 3959 ], [ 3961 ], [ 3963 ], [ 3965 ], [ 3967 ], [ 3969, 3971 ], [ 3973, 3975, 3977 ], [ 3979 ], [ 3981 ], [ 3983, 3985 ], [ 3987 ], [ 3989 ], [ 3991 ], [ 3993 ], [ 3995 ], [ 3997 ], [ 3999 ], [ 4001 ], [ 4003, 4005 ], [ 4007 ], [ 4009 ], [ 4011 ], [ 4013 ], [ 4015 ], [ 4017 ], [ 4019 ], [ 4021 ], [ 4023 ], [ 4025 ], [ 4027, 4029, 4031, 4033, 4035, 4037, 4039, 4041 ], [ 4043 ], [ 4045, 4047, 4049, 4051, 4053, 4055, 4057, 4059, 4061 ], [ 4063 ], [ 4065 ], [ 4067 ], [ 4069 ], [ 4071 ], [ 4075 ], [ 4077, 4079 ], [ 4083 ], [ 4085 ], [ 4087 ], [ 4089 ], [ 4091 ], [ 4095, 4097 ], [ 4099 ], [ 4101 ], [ 4103 ], [ 4107 ], [ 4109 ], [ 4111 ], [ 4113 ], [ 4115 ], [ 4117 ], [ 4119 ], [ 4121 ], [ 4125 ], [ 4127 ], [ 4129 ], [ 4131 ], [ 4133 ], [ 4135 ], [ 4137 ], [ 4139 ], [ 4141 ], [ 4143 ], [ 4147 ], [ 4151 ], [ 4153 ], [ 4155 ], [ 4157 ], [ 4159 ], [ 4161 ], [ 4163 ], [ 4165, 4167 ], [ 4171 ], [ 4173 ], [ 4175 ], [ 4177 ], [ 4179 ], [ 4181 ], [ 4183 ], [ 4185 ], [ 4187, 4189, 4195 ], [ 4197 ], [ 4199, 4201 ], [ 4203 ], [ 4205 ], [ 4209 ], [ 4211, 4213 ], [ 4215 ], [ 4217 ], [ 4219 ], [ 4221 ], [ 4223, 4225 ], [ 4227 ], [ 4229 ], [ 4233 ], [ 4235, 4237 ], [ 4239 ], [ 4241 ], [ 4243 ], [ 4245 ], [ 4247, 4249 ], [ 4251 ], [ 4253, 4255, 4257 ], [ 4259 ], [ 4261, 4263, 4269 ], [ 4271 ], [ 4273, 4275 ], [ 4277 ], [ 4279 ], [ 4291 ], [ 4293 ], [ 4295 ], [ 4297 ], [ 4299 ], [ 4303 ], [ 4305 ], [ 4309 ], [ 4311 ], [ 4313 ], [ 4315 ], [ 4317 ], [ 4319 ], [ 4321 ], [ 4323, 4325 ], [ 4327 ], [ 4329 ], [ 4341 ], [ 4343 ], [ 4345 ], [ 4347 ], [ 4349 ], [ 4353 ], [ 4355 ], [ 4357 ], [ 4359 ], [ 4361 ], [ 4363 ], [ 4367 ], [ 4369 ], [ 4371 ], [ 4373, 4375 ], [ 4377 ], [ 4379 ], [ 4383, 4385 ], [ 4387 ], [ 4389 ], [ 4391 ], [ 4393 ], [ 4395 ], [ 4397, 4399 ], [ 4401 ], [ 4403 ], [ 4405 ], [ 4407 ], [ 4409, 4411 ], [ 4413 ], [ 4415 ], [ 4417 ], [ 4419 ], [ 4421 ], [ 4423, 4425 ], [ 4427 ], [ 4429 ], [ 4431, 4433 ], [ 4435 ], [ 4437 ], [ 4439 ], [ 4441 ], [ 4443 ], [ 4445, 4447 ], [ 4449 ], [ 4451, 4453 ], [ 4455 ], [ 4457, 4459 ], [ 4461 ], [ 4463, 4465 ], [ 4467 ], [ 4469, 4471 ], [ 4473 ], [ 4475 ], [ 4477 ], [ 4479 ], [ 4481 ], [ 4483 ], [ 4485 ], [ 4487, 4489 ], [ 4491 ], [ 4493 ], [ 4495 ], [ 4497 ], [ 4499 ], [ 4501 ], [ 4503 ], [ 4505 ], [ 4507, 4509, 4511 ], [ 4513, 4515, 4517, 4519 ], [ 4521, 4523, 4525 ], [ 4527, 4529 ], [ 4531 ], [ 4533 ], [ 4535, 4537 ], [ 4539 ], [ 4541 ], [ 4543 ], [ 4545 ], [ 4547, 4549, 4551 ], [ 4553 ], [ 4555 ], [ 4557 ], [ 4559 ], [ 4561, 4563 ], [ 4565 ], [ 4567 ], [ 4569 ], [ 4571, 4573 ], [ 4575 ], [ 4577 ], [ 4579 ], [ 4581 ], [ 4583, 4585 ], [ 4587 ], [ 4589 ], [ 4591 ], [ 4593, 4595, 4599 ], [ 4601 ], [ 4603 ], [ 4605 ], [ 4607, 4609, 4611, 4613 ], [ 4615 ], [ 4617, 4619 ], [ 4621, 4623, 4625, 4627, 4629, 4631 ], [ 4633, 4635 ], [ 4637 ], [ 4639 ], [ 4641 ], [ 4643, 4645, 4647 ], [ 4649, 4651 ], [ 4653 ], [ 4655 ], [ 4657 ], [ 4659, 4661, 4663, 4665, 4667 ], [ 4669 ], [ 4671 ], [ 4673 ], [ 4675, 4677, 4679 ], [ 4681 ], [ 4683 ], [ 4685 ], [ 4687, 4689, 4691, 4693 ], [ 4695 ], [ 4697 ], [ 4699 ], [ 4701, 4703 ], [ 4705, 4707 ], [ 4709, 4711, 4713, 4715, 4717 ], [ 4719 ], [ 4721, 4723 ], [ 4725, 4727, 4729 ], [ 4731, 4733, 4735 ], [ 4737, 4739, 4741, 4743 ], [ 4745, 4747, 4749, 4751, 4753 ], [ 4755 ], [ 4757, 4759, 4761, 4763 ], [ 4765 ], [ 4767 ], [ 4769 ], [ 4771 ], [ 4773 ], [ 4775, 4777 ], [ 4779 ], [ 4781 ], [ 4783 ], [ 4785 ], [ 4787 ], [ 4789 ], [ 4791, 4793, 4795, 4797, 4799 ], [ 4801 ], [ 4803 ], [ 4805 ], [ 4807, 4809, 4811, 4813 ], [ 4815 ], [ 4817, 4819, 4821, 4823, 4825 ], [ 4827 ], [ 4829 ], [ 4831, 4833 ], [ 4835 ], [ 4837, 4839, 4841, 4843, 4845 ], [ 4847 ], [ 4849 ], [ 4851, 4853 ], [ 4855 ], [ 4857, 4859, 4861, 4863 ], [ 4865, 4867 ], [ 4869 ], [ 4871, 4873, 4875, 4877, 4879, 4881, 4883, 4885, 4887, 4889, 4891 ], [ 4893, 4895 ], [ 4897, 4899 ], [ 4901, 4903, 4905 ], [ 4907 ], [ 4909, 4911, 4913, 4915 ], [ 4917 ], [ 4919 ], [ 4921 ], [ 4923, 4925, 4927 ], [ 4929 ], [ 4931, 4933, 4935, 4937 ], [ 4939 ], [ 4941, 4943, 4945, 4947 ], [ 4949 ], [ 4951, 4953, 4955, 4957 ], [ 4959 ], [ 4961, 4963, 4965 ], [ 4967 ], [ 4969, 4971 ], [ 4973 ], [ 4975, 4977 ], [ 4979 ], [ 4981 ], [ 4983 ], [ 4985 ], [ 4989 ], [ 4991 ], [ 4993, 4995 ], [ 4997 ], [ 4999 ], [ 5001, 5003 ], [ 5005 ], [ 5007 ], [ 5009 ], [ 5011 ], [ 5013 ], [ 5015 ], [ 5017, 5019 ], [ 5021 ], [ 5023 ], [ 5025 ], [ 5027 ], [ 5031 ], [ 5033 ], [ 5035 ], [ 5037 ], [ 5039 ], [ 5041 ], [ 5043 ], [ 5045 ], [ 5047 ], [ 5049 ], [ 5051 ], [ 5053 ], [ 5055, 5057 ], [ 5059 ], [ 5061, 5063, 5065, 5067 ], [ 5069 ], [ 5071 ], [ 5073 ], [ 5075, 5077, 5079, 5081, 5083, 5085 ], [ 5087 ], [ 5089, 5091, 5093, 5095 ], [ 5097 ], [ 5099 ], [ 5101 ], [ 5103, 5105, 5107, 5109 ], [ 5111 ], [ 5113 ], [ 5115 ], [ 5117, 5119, 5121, 5123, 5125, 5127 ], [ 5129 ], [ 5131, 5133, 5135, 5137 ], [ 5139 ], [ 5141 ], [ 5143 ], [ 5145, 5147, 5149, 5151 ], [ 5153 ], [ 5155 ], [ 5157 ], [ 5159, 5161, 5163, 5165 ], [ 5167 ], [ 5169 ], [ 5171 ], [ 5173, 5175 ], [ 5177 ], [ 5179, 5181 ], [ 5183 ], [ 5185, 5187 ], [ 5189 ], [ 5191, 5193 ], [ 5195 ], [ 5199, 5201, 5203, 5205 ], [ 5207 ], [ 5209 ], [ 5211 ], [ 5213, 5215, 5217, 5219 ], [ 5221 ], [ 5223, 5227, 5231, 5233 ], [ 5235 ], [ 5237 ], [ 5239 ], [ 5241 ], [ 5243 ], [ 5245 ], [ 5247, 5249, 5253, 5255 ], [ 5257 ], [ 5259 ], [ 5261 ], [ 5263 ], [ 5265 ], [ 5267 ], [ 5269, 5271, 5275, 5277 ], [ 5279 ], [ 5281, 5283 ], [ 5285 ], [ 5291 ], [ 5293 ], [ 5295, 5297, 5299 ], [ 5301, 5303 ], [ 5305 ], [ 5307 ], [ 5311, 5313 ], [ 5315 ], [ 5317 ], [ 5319 ], [ 5341 ], [ 5343 ], [ 5345, 5347, 5351, 5353 ], [ 5355 ], [ 5357, 5359 ], [ 5361 ], [ 5365 ], [ 5367 ], [ 5369 ], [ 5371 ], [ 5373 ], [ 5379 ], [ 5381 ], [ 5383, 5385, 5387 ], [ 5389, 5391 ], [ 5393 ], [ 5395 ], [ 5399 ], [ 5401 ], [ 5403 ], [ 5405 ], [ 5409, 5411 ], [ 5413 ], [ 5415 ], [ 5419 ], [ 5421 ], [ 5423 ], [ 5427 ], [ 5433 ], [ 5437 ], [ 5439 ], [ 5445 ], [ 5453 ], [ 5455 ], [ 5457 ], [ 5459 ], [ 5461 ], [ 5463 ], [ 5465 ], [ 5467 ], [ 5469 ], [ 5471 ], [ 5473 ], [ 5475 ], [ 5477 ], [ 5479 ], [ 5481 ], [ 5483 ], [ 5485 ], [ 5487 ], [ 5489 ], [ 5491 ], [ 5493 ], [ 5495, 5497 ], [ 5499 ], [ 5501 ], [ 5503 ], [ 5505 ], [ 5521 ], [ 5523 ], [ 5525, 5527, 5531, 5533 ], [ 5535 ], [ 5537 ], [ 5539 ], [ 5543 ], [ 5545, 5547 ], [ 5549 ], [ 5551, 5553 ], [ 5555 ], [ 5557, 5559 ], [ 5561 ], [ 5563, 5565 ], [ 5567 ], [ 5569 ], [ 5571 ], [ 5573 ], [ 5575 ], [ 5577 ], [ 5579 ], [ 5581 ], [ 5583 ], [ 5585, 5589, 5591, 5593 ], [ 5595 ], [ 5597, 5599, 5601, 5603 ], [ 5605 ], [ 5607, 5609, 5611, 5613 ], [ 5615 ], [ 5617, 5619, 5621, 5623 ], [ 5625 ], [ 5627, 5629, 5631, 5633 ], [ 5635 ], [ 5637, 5639, 5641, 5643 ], [ 5645 ], [ 5647 ], [ 5649 ], [ 5651 ], [ 5655 ], [ 5657 ], [ 5659, 5661 ], [ 5663 ], [ 5665 ], [ 5667 ], [ 5669 ], [ 5671 ], [ 5673 ], [ 5675 ], [ 5677 ], [ 5679 ], [ 5681 ], [ 5683 ], [ 5685 ], [ 5687, 5689, 5691, 5693 ], [ 5695 ], [ 5697 ], [ 5699 ], [ 5701 ], [ 5705 ], [ 5707 ], [ 5709 ], [ 5711 ], [ 5713 ], [ 5715 ], [ 5717 ], [ 5719 ], [ 5721 ], [ 5723 ], [ 5725 ], [ 5727 ], [ 5729, 5731, 5733, 5735 ], [ 5737 ], [ 5739, 5741, 5743, 5745 ], [ 5747 ], [ 5749, 5751, 5753, 5755 ], [ 5757 ], [ 5759 ], [ 5761 ], [ 5763, 5765, 5767, 5769 ], [ 5771 ], [ 5773 ], [ 5775 ], [ 5777, 5779, 5781, 5783 ], [ 5785 ], [ 5787, 5789, 5791, 5793 ], [ 5795 ], [ 5797 ], [ 5799 ], [ 5801, 5803, 5805, 5807 ], [ 5809 ], [ 5811 ], [ 5813 ], [ 5815, 5817, 5819, 5821, 5823 ], [ 5825 ], [ 5827 ], [ 5829 ], [ 5831, 5833, 5835, 5837 ], [ 5839 ], [ 5841, 5843, 5845, 5847 ], [ 5849 ], [ 5851, 5853, 5855, 5857 ], [ 5859 ], [ 5861, 5863, 5865, 5867 ], [ 5869 ], [ 5871, 5875, 5877 ], [ 5879, 5881, 5883 ], [ 5885 ], [ 5887 ], [ 5889, 5891 ], [ 5893, 5895 ], [ 5897 ], [ 5899 ], [ 5901, 5903 ], [ 5905 ], [ 5907 ], [ 5909, 5911, 5913, 5915 ], [ 5925 ], [ 5927 ], [ 5929 ], [ 5931 ], [ 5933 ], [ 5935, 5937, 5939, 5941, 5943, 5945, 5947, 5949, 5951, 5953 ], [ 5955 ], [ 5957 ], [ 5959 ], [ 5961 ], [ 5963 ], [ 5965 ], [ 5967, 5969 ], [ 5971 ], [ 5973, 5975, 5977, 5987 ], [ 5989 ], [ 5991, 5993, 5995, 5997 ], [ 5999 ], [ 6001 ], [ 6003 ], [ 6005, 6007 ], [ 6009, 6013 ], [ 6015 ], [ 6017 ], [ 6019 ], [ 6021 ], [ 6025 ], [ 6027, 6029, 6031 ], [ 6033, 6035 ], [ 6037 ], [ 6039 ], [ 6041 ], [ 6043 ], [ 6045 ], [ 6047 ], [ 6049 ], [ 6051, 6053 ], [ 6055, 6057 ], [ 6059 ], [ 6061 ], [ 6063 ], [ 6065 ], [ 6067 ], [ 6069 ], [ 6071 ], [ 6073 ], [ 6075 ], [ 6077, 6079 ], [ 6081, 6083 ], [ 6085 ], [ 6087 ], [ 6089 ], [ 6091 ], [ 6093 ], [ 6095 ], [ 6097 ], [ 6099, 6101 ], [ 6103, 6105 ], [ 6107 ], [ 6109 ], [ 6111 ], [ 6113 ], [ 6115 ], [ 6117 ], [ 6119 ], [ 6121 ], [ 6123 ], [ 6127, 6129, 6131, 6133 ], [ 6135, 6137 ], [ 6139 ], [ 6141 ], [ 6143 ], [ 6145 ], [ 6147 ], [ 6149 ], [ 6151 ], [ 6153, 6155 ], [ 6157, 6159 ], [ 6161 ], [ 6163 ], [ 6165 ], [ 6167 ], [ 6169 ], [ 6171 ], [ 6173 ], [ 6175 ], [ 6177 ], [ 6179, 6181 ], [ 6183 ], [ 6185 ], [ 6187 ], [ 6189 ], [ 6191, 6193, 6195, 6199 ], [ 6201 ], [ 6203, 6205, 6207, 6209 ], [ 6211, 6213, 6215, 6217 ], [ 6219 ], [ 6221, 6223, 6225 ], [ 6227 ], [ 6229, 6231, 6233, 6235 ], [ 6237 ], [ 6239 ], [ 6241 ], [ 6243 ], [ 6245 ], [ 6247, 6249 ], [ 6251, 6253 ], [ 6255, 6257, 6259, 6261, 6263, 6265 ], [ 6267 ], [ 6269 ], [ 6271 ], [ 6273 ], [ 6275 ], [ 6277 ], [ 6279 ], [ 6281 ], [ 6283 ], [ 6285 ], [ 6287 ], [ 6289 ], [ 6291 ], [ 6293 ], [ 6295 ], [ 6297 ], [ 6299 ], [ 6301 ], [ 6303 ], [ 6305 ], [ 6307 ], [ 6309 ], [ 6311, 6313 ], [ 6315 ], [ 6317 ], [ 6319 ], [ 6321 ], [ 6323 ], [ 6325 ], [ 6327 ], [ 6329 ], [ 6331 ], [ 6333 ], [ 6335 ], [ 6337 ], [ 6339, 6341, 6343 ], [ 6345 ], [ 6347 ], [ 6349 ], [ 6351 ], [ 6353 ], [ 6355 ], [ 6357 ], [ 6359 ], [ 6361 ], [ 6363 ], [ 6365 ], [ 6367 ], [ 6369 ], [ 6371 ], [ 6373 ], [ 6375 ], [ 6377 ], [ 6379 ], [ 6381 ], [ 6383 ], [ 6385 ], [ 6387 ], [ 6389 ], [ 6391 ], [ 6393, 6395 ], [ 6397 ], [ 6399 ], [ 6401 ], [ 6403 ], [ 6405 ], [ 6407 ], [ 6409 ], [ 6411 ], [ 6413 ], [ 6415 ], [ 6417 ], [ 6419 ], [ 6421 ], [ 6423 ], [ 6425 ], [ 6427 ], [ 6429 ], [ 6431 ], [ 6433, 6435, 6437 ], [ 6439 ], [ 6441 ], [ 6443 ], [ 6445 ], [ 6447 ], [ 6449 ], [ 6451 ], [ 6453 ], [ 6455 ], [ 6457 ], [ 6459 ], [ 6461 ], [ 6463 ], [ 6465 ], [ 6467 ], [ 6469 ], [ 6471 ], [ 6473 ], [ 6475 ], [ 6477 ], [ 6479 ], [ 6481 ], [ 6483 ], [ 6485 ], [ 6487, 6489 ], [ 6491 ], [ 6493 ], [ 6495 ], [ 6497 ], [ 6499 ], [ 6501 ], [ 6503 ], [ 6505 ], [ 6507 ], [ 6509 ], [ 6511 ], [ 6513 ], [ 6515 ], [ 6517 ], [ 6519 ], [ 6521 ], [ 6523 ], [ 6525 ], [ 6527, 6529, 6531 ], [ 6533 ], [ 6535 ], [ 6537 ], [ 6539 ], [ 6541 ], [ 6543 ], [ 6545 ], [ 6547 ], [ 6549 ], [ 6551 ], [ 6553 ], [ 6555 ], [ 6557 ], [ 6559 ], [ 6561 ], [ 6563 ], [ 6565, 6567 ], [ 6569 ], [ 6571 ], [ 6573 ], [ 6575 ], [ 6577 ], [ 6579 ], [ 6581 ], [ 6583 ], [ 6585 ], [ 6587 ], [ 6589, 6591, 6593, 6595, 6597, 6599 ], [ 6601 ], [ 6603 ], [ 6605, 6607, 6609 ], [ 6611 ], [ 6613 ], [ 6615 ], [ 6617 ], [ 6619 ], [ 6621, 6623 ], [ 6625 ], [ 6627, 6629 ], [ 6631, 6633, 6635, 6637, 6639, 6641 ], [ 6643, 6645 ], [ 6647, 6649, 6651, 6653, 6655 ], [ 6657, 6661, 6663, 6665 ], [ 6667 ], [ 6669 ], [ 6671 ], [ 6673 ], [ 6675 ], [ 6677 ], [ 6679 ], [ 6681, 6683, 6685, 6687 ], [ 6689 ], [ 6691 ], [ 6693 ], [ 6695 ], [ 6697 ], [ 6699 ], [ 6701 ], [ 6703, 6705, 6707, 6709 ], [ 6711 ], [ 6713 ], [ 6715 ], [ 6717, 6719 ], [ 6721 ], [ 6723 ], [ 6725, 6729, 6731, 6733 ], [ 6735 ], [ 6737, 6741, 6743, 6745 ], [ 6747 ], [ 6749, 6753, 6755, 6757, 6759 ], [ 6761 ], [ 6763, 6767, 6769, 6771 ], [ 6773, 6777, 6779, 6781 ], [ 6783 ], [ 6785 ], [ 6787 ], [ 6789 ], [ 6791 ], [ 6793 ], [ 6795 ], [ 6797 ], [ 6799, 6801 ], [ 6803 ], [ 6805 ], [ 6807 ], [ 6809 ], [ 6811 ], [ 6813 ], [ 6815 ], [ 6817 ], [ 6819 ], [ 6821 ], [ 6823, 6825, 6827, 6829 ], [ 6831 ], [ 6833, 6835, 6837, 6839 ], [ 6841 ], [ 6843, 6845, 6847, 6849, 6851 ], [ 6853 ], [ 6855, 6857, 6859, 6861, 6863 ], [ 6865 ], [ 6867 ], [ 6869 ], [ 6871, 6873, 6875, 6877 ], [ 6879 ], [ 6881, 6885, 6887, 6889 ], [ 6891 ], [ 6895 ], [ 6897, 6899 ], [ 6901 ], [ 6903 ], [ 6905 ], [ 6907 ], [ 6911, 6913 ], [ 6915 ], [ 6917 ], [ 6919 ], [ 6923, 6925 ], [ 6927 ], [ 6931 ], [ 6933 ], [ 6935 ], [ 6937 ], [ 6939 ], [ 6941 ], [ 6943, 6945 ], [ 6947 ], [ 6949 ], [ 6951 ], [ 6955, 6957 ], [ 6959 ], [ 6961 ], [ 6965 ], [ 6967 ], [ 6969 ], [ 6971 ], [ 6973 ], [ 6975 ], [ 6977, 6979 ], [ 6981 ], [ 6983, 6985 ], [ 6987 ], [ 6989 ], [ 7001, 7003 ], [ 7005 ], [ 7007 ], [ 7009 ], [ 7011 ], [ 7013 ], [ 7015 ], [ 7017 ], [ 7019 ], [ 7021 ], [ 7023 ], [ 7027 ], [ 7029 ], [ 7031, 7035, 7037, 7039, 7041 ], [ 7043 ], [ 7045 ], [ 7047 ], [ 7049, 7051, 7053, 7055 ], [ 7057 ], [ 7059 ], [ 7061 ], [ 7063 ], [ 7065 ], [ 7067 ], [ 7069 ], [ 7071 ], [ 7073 ], [ 7075 ], [ 7077 ], [ 7079 ], [ 7081 ], [ 7083, 7085, 7087, 7089 ], [ 7091 ], [ 7093 ], [ 7097 ], [ 7099, 7101 ], [ 7103 ], [ 7105 ], [ 7107 ], [ 7109 ], [ 7111, 7113, 7115, 7117, 7119, 7121 ], [ 7123 ], [ 7125, 7127, 7129, 7131 ], [ 7133 ], [ 7135, 7137, 7139, 7141, 7143, 7145, 7147 ], [ 7149, 7151 ], [ 7153, 7155 ], [ 7157, 7159, 7161, 7163, 7165, 7167, 7169, 7171 ], [ 7173, 7175, 7177 ], [ 7179, 7181, 7183 ], [ 7185, 7187 ], [ 7189, 7191, 7193, 7197, 7199, 7201 ], [ 7203, 7205 ], [ 7207, 7209 ], [ 7211, 7213, 7215, 7217, 7219, 7221 ], [ 7223 ], [ 7225, 7227, 7229, 7231 ], [ 7233 ], [ 7235, 7237, 7239, 7241 ], [ 7243 ], [ 7245 ], [ 7247 ], [ 7249 ], [ 7251 ], [ 7253 ], [ 7255 ], [ 7257 ], [ 7267 ], [ 7269 ], [ 7271 ], [ 7273 ], [ 7275 ], [ 7277 ], [ 7279 ], [ 7281, 7285, 7287, 7289, 7291, 7293, 7295, 7297, 7299, 7301, 7303, 7305 ], [ 7307 ], [ 7309 ], [ 7311 ], [ 7313 ], [ 7315 ], [ 7319, 7321 ], [ 7323 ], [ 7325 ], [ 7327 ], [ 7331 ], [ 7335 ], [ 7337, 7339, 7341 ], [ 7343 ], [ 7345 ], [ 7349 ], [ 7351, 7353 ], [ 7355 ], [ 7357 ], [ 7359 ], [ 7361 ], [ 7363 ], [ 7365 ], [ 7367 ], [ 7369 ], [ 7371 ], [ 7375 ], [ 7377 ], [ 7379 ], [ 7381, 7383, 7385, 7387 ], [ 7389 ], [ 7391, 7393, 7395 ], [ 7397 ], [ 7399 ], [ 7401 ], [ 7403 ], [ 7405 ], [ 7407 ], [ 7409 ], [ 7411 ], [ 7413 ], [ 7415 ], [ 7417 ], [ 7419, 7421, 7423, 7425, 7427 ], [ 7431 ], [ 7433 ], [ 7435 ], [ 7437 ], [ 7439 ], [ 7441 ], [ 7443 ], [ 7445 ], [ 7447 ], [ 7449 ], [ 7451 ], [ 7455 ], [ 7457 ], [ 7459 ], [ 7461 ], [ 7463 ], [ 7465 ], [ 7467 ], [ 7469 ], [ 7471 ], [ 7473 ], [ 7475 ], [ 7477, 7479, 7481, 7483 ], [ 7485, 7487, 7489, 7491 ], [ 7493 ], [ 7495 ], [ 7497, 7499, 7501 ], [ 7503, 7505, 7507 ], [ 7509 ], [ 7511, 7513 ], [ 7515 ], [ 7517 ] ]
22,175
static int64_t coroutine_fn vmdk_co_get_block_status(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum) { BDRVVmdkState *s = bs->opaque; int64_t index_in_cluster, n, ret; uint64_t offset; VmdkExtent *extent; extent = find_extent(s, sector_num, NULL); if (!extent) { return 0; } qemu_co_mutex_lock(&s->lock); ret = get_cluster_offset(bs, extent, NULL, sector_num * 512, false, &offset, 0, 0); qemu_co_mutex_unlock(&s->lock); switch (ret) { case VMDK_ERROR: ret = -EIO; break; case VMDK_UNALLOC: ret = 0; break; case VMDK_ZEROED: ret = BDRV_BLOCK_ZERO; break; case VMDK_OK: ret = BDRV_BLOCK_DATA; if (extent->file == bs->file && !extent->compressed) { ret |= BDRV_BLOCK_OFFSET_VALID | offset; } break; } index_in_cluster = vmdk_find_index_in_cluster(extent, sector_num); n = extent->cluster_sectors - index_in_cluster; if (n > nb_sectors) { n = nb_sectors; } *pnum = n; return ret; }
false
qemu
67a0fd2a9bca204d2b39f910a97c7137636a0715
static int64_t coroutine_fn vmdk_co_get_block_status(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum) { BDRVVmdkState *s = bs->opaque; int64_t index_in_cluster, n, ret; uint64_t offset; VmdkExtent *extent; extent = find_extent(s, sector_num, NULL); if (!extent) { return 0; } qemu_co_mutex_lock(&s->lock); ret = get_cluster_offset(bs, extent, NULL, sector_num * 512, false, &offset, 0, 0); qemu_co_mutex_unlock(&s->lock); switch (ret) { case VMDK_ERROR: ret = -EIO; break; case VMDK_UNALLOC: ret = 0; break; case VMDK_ZEROED: ret = BDRV_BLOCK_ZERO; break; case VMDK_OK: ret = BDRV_BLOCK_DATA; if (extent->file == bs->file && !extent->compressed) { ret |= BDRV_BLOCK_OFFSET_VALID | offset; } break; } index_in_cluster = vmdk_find_index_in_cluster(extent, sector_num); n = extent->cluster_sectors - index_in_cluster; if (n > nb_sectors) { n = nb_sectors; } *pnum = n; return ret; }
{ "code": [], "line_no": [] }
static int64_t VAR_0 vmdk_co_get_block_status(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum) { BDRVVmdkState *s = bs->opaque; int64_t index_in_cluster, n, ret; uint64_t offset; VmdkExtent *extent; extent = find_extent(s, sector_num, NULL); if (!extent) { return 0; } qemu_co_mutex_lock(&s->lock); ret = get_cluster_offset(bs, extent, NULL, sector_num * 512, false, &offset, 0, 0); qemu_co_mutex_unlock(&s->lock); switch (ret) { case VMDK_ERROR: ret = -EIO; break; case VMDK_UNALLOC: ret = 0; break; case VMDK_ZEROED: ret = BDRV_BLOCK_ZERO; break; case VMDK_OK: ret = BDRV_BLOCK_DATA; if (extent->file == bs->file && !extent->compressed) { ret |= BDRV_BLOCK_OFFSET_VALID | offset; } break; } index_in_cluster = vmdk_find_index_in_cluster(extent, sector_num); n = extent->cluster_sectors - index_in_cluster; if (n > nb_sectors) { n = nb_sectors; } *pnum = n; return ret; }
[ "static int64_t VAR_0 vmdk_co_get_block_status(BlockDriverState *bs,\nint64_t sector_num, int nb_sectors, int *pnum)\n{", "BDRVVmdkState *s = bs->opaque;", "int64_t index_in_cluster, n, ret;", "uint64_t offset;", "VmdkExtent *extent;", "extent = find_extent(s, sector_num, NULL);", "if (!extent) {", "return 0;", "}", "qemu_co_mutex_lock(&s->lock);", "ret = get_cluster_offset(bs, extent, NULL,\nsector_num * 512, false, &offset,\n0, 0);", "qemu_co_mutex_unlock(&s->lock);", "switch (ret) {", "case VMDK_ERROR:\nret = -EIO;", "break;", "case VMDK_UNALLOC:\nret = 0;", "break;", "case VMDK_ZEROED:\nret = BDRV_BLOCK_ZERO;", "break;", "case VMDK_OK:\nret = BDRV_BLOCK_DATA;", "if (extent->file == bs->file && !extent->compressed) {", "ret |= BDRV_BLOCK_OFFSET_VALID | offset;", "}", "break;", "}", "index_in_cluster = vmdk_find_index_in_cluster(extent, sector_num);", "n = extent->cluster_sectors - index_in_cluster;", "if (n > nb_sectors) {", "n = nb_sectors;", "}", "*pnum = n;", "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 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27, 29, 31 ], [ 33 ], [ 37 ], [ 39, 41 ], [ 43 ], [ 45, 47 ], [ 49 ], [ 51, 53 ], [ 55 ], [ 57, 59 ], [ 61 ], [ 63 ], [ 65 ], [ 69 ], [ 71 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ] ]
22,176
static void vfio_listener_region_add(MemoryListener *listener, MemoryRegionSection *section) { VFIOContainer *container = container_of(listener, VFIOContainer, listener); hwaddr iova, end; Int128 llend, llsize; void *vaddr; int ret; VFIOHostDMAWindow *hostwin; bool hostwin_found; if (vfio_listener_skipped_section(section)) { trace_vfio_listener_region_add_skip( section->offset_within_address_space, section->offset_within_address_space + int128_get64(int128_sub(section->size, int128_one()))); return; } if (unlikely((section->offset_within_address_space & ~TARGET_PAGE_MASK) != (section->offset_within_region & ~TARGET_PAGE_MASK))) { error_report("%s received unaligned region", __func__); return; } iova = TARGET_PAGE_ALIGN(section->offset_within_address_space); llend = int128_make64(section->offset_within_address_space); llend = int128_add(llend, section->size); llend = int128_and(llend, int128_exts64(TARGET_PAGE_MASK)); if (int128_ge(int128_make64(iova), llend)) { return; } end = int128_get64(int128_sub(llend, int128_one())); if (container->iommu_type == VFIO_SPAPR_TCE_v2_IOMMU) { VFIOHostDMAWindow *hostwin; hwaddr pgsize = 0; /* For now intersections are not allowed, we may relax this later */ QLIST_FOREACH(hostwin, &container->hostwin_list, hostwin_next) { if (ranges_overlap(hostwin->min_iova, hostwin->max_iova - hostwin->min_iova + 1, section->offset_within_address_space, int128_get64(section->size))) { ret = -1; goto fail; } } ret = vfio_spapr_create_window(container, section, &pgsize); if (ret) { goto fail; } vfio_host_win_add(container, section->offset_within_address_space, section->offset_within_address_space + int128_get64(section->size) - 1, pgsize); } hostwin_found = false; QLIST_FOREACH(hostwin, &container->hostwin_list, hostwin_next) { if (hostwin->min_iova <= iova && end <= hostwin->max_iova) { hostwin_found = true; break; } } if (!hostwin_found) { error_report("vfio: IOMMU container %p can't map guest IOVA region" " 0x%"HWADDR_PRIx"..0x%"HWADDR_PRIx, container, iova, end); ret = -EFAULT; goto fail; } memory_region_ref(section->mr); if (memory_region_is_iommu(section->mr)) { VFIOGuestIOMMU *giommu; trace_vfio_listener_region_add_iommu(iova, end); /* * FIXME: For VFIO iommu types which have KVM acceleration to * avoid bouncing all map/unmaps through qemu this way, this * would be the right place to wire that up (tell the KVM * device emulation the VFIO iommu handles to use). */ giommu = g_malloc0(sizeof(*giommu)); giommu->iommu = section->mr; giommu->iommu_offset = section->offset_within_address_space - section->offset_within_region; giommu->container = container; giommu->n.notify = vfio_iommu_map_notify; giommu->n.notifier_flags = IOMMU_NOTIFIER_ALL; QLIST_INSERT_HEAD(&container->giommu_list, giommu, giommu_next); memory_region_register_iommu_notifier(giommu->iommu, &giommu->n); memory_region_iommu_replay(giommu->iommu, &giommu->n, false); return; } /* Here we assume that memory_region_is_ram(section->mr)==true */ vaddr = memory_region_get_ram_ptr(section->mr) + section->offset_within_region + (iova - section->offset_within_address_space); trace_vfio_listener_region_add_ram(iova, end, vaddr); llsize = int128_sub(llend, int128_make64(iova)); ret = vfio_dma_map(container, iova, int128_get64(llsize), vaddr, section->readonly); if (ret) { error_report("vfio_dma_map(%p, 0x%"HWADDR_PRIx", " "0x%"HWADDR_PRIx", %p) = %d (%m)", container, iova, int128_get64(llsize), vaddr, ret); goto fail; } return; fail: /* * On the initfn path, store the first error in the container so we * can gracefully fail. Runtime, there's not much we can do other * than throw a hardware error. */ if (!container->initialized) { if (!container->error) { container->error = ret; } } else { hw_error("vfio: DMA mapping failed, unable to continue"); } }
false
qemu
698feb5e13a2d763369909ce33f2bd7a7c1c11c0
static void vfio_listener_region_add(MemoryListener *listener, MemoryRegionSection *section) { VFIOContainer *container = container_of(listener, VFIOContainer, listener); hwaddr iova, end; Int128 llend, llsize; void *vaddr; int ret; VFIOHostDMAWindow *hostwin; bool hostwin_found; if (vfio_listener_skipped_section(section)) { trace_vfio_listener_region_add_skip( section->offset_within_address_space, section->offset_within_address_space + int128_get64(int128_sub(section->size, int128_one()))); return; } if (unlikely((section->offset_within_address_space & ~TARGET_PAGE_MASK) != (section->offset_within_region & ~TARGET_PAGE_MASK))) { error_report("%s received unaligned region", __func__); return; } iova = TARGET_PAGE_ALIGN(section->offset_within_address_space); llend = int128_make64(section->offset_within_address_space); llend = int128_add(llend, section->size); llend = int128_and(llend, int128_exts64(TARGET_PAGE_MASK)); if (int128_ge(int128_make64(iova), llend)) { return; } end = int128_get64(int128_sub(llend, int128_one())); if (container->iommu_type == VFIO_SPAPR_TCE_v2_IOMMU) { VFIOHostDMAWindow *hostwin; hwaddr pgsize = 0; QLIST_FOREACH(hostwin, &container->hostwin_list, hostwin_next) { if (ranges_overlap(hostwin->min_iova, hostwin->max_iova - hostwin->min_iova + 1, section->offset_within_address_space, int128_get64(section->size))) { ret = -1; goto fail; } } ret = vfio_spapr_create_window(container, section, &pgsize); if (ret) { goto fail; } vfio_host_win_add(container, section->offset_within_address_space, section->offset_within_address_space + int128_get64(section->size) - 1, pgsize); } hostwin_found = false; QLIST_FOREACH(hostwin, &container->hostwin_list, hostwin_next) { if (hostwin->min_iova <= iova && end <= hostwin->max_iova) { hostwin_found = true; break; } } if (!hostwin_found) { error_report("vfio: IOMMU container %p can't map guest IOVA region" " 0x%"HWADDR_PRIx"..0x%"HWADDR_PRIx, container, iova, end); ret = -EFAULT; goto fail; } memory_region_ref(section->mr); if (memory_region_is_iommu(section->mr)) { VFIOGuestIOMMU *giommu; trace_vfio_listener_region_add_iommu(iova, end); giommu = g_malloc0(sizeof(*giommu)); giommu->iommu = section->mr; giommu->iommu_offset = section->offset_within_address_space - section->offset_within_region; giommu->container = container; giommu->n.notify = vfio_iommu_map_notify; giommu->n.notifier_flags = IOMMU_NOTIFIER_ALL; QLIST_INSERT_HEAD(&container->giommu_list, giommu, giommu_next); memory_region_register_iommu_notifier(giommu->iommu, &giommu->n); memory_region_iommu_replay(giommu->iommu, &giommu->n, false); return; } vaddr = memory_region_get_ram_ptr(section->mr) + section->offset_within_region + (iova - section->offset_within_address_space); trace_vfio_listener_region_add_ram(iova, end, vaddr); llsize = int128_sub(llend, int128_make64(iova)); ret = vfio_dma_map(container, iova, int128_get64(llsize), vaddr, section->readonly); if (ret) { error_report("vfio_dma_map(%p, 0x%"HWADDR_PRIx", " "0x%"HWADDR_PRIx", %p) = %d (%m)", container, iova, int128_get64(llsize), vaddr, ret); goto fail; } return; fail: if (!container->initialized) { if (!container->error) { container->error = ret; } } else { hw_error("vfio: DMA mapping failed, unable to continue"); } }
{ "code": [], "line_no": [] }
static void FUNC_0(MemoryListener *VAR_0, MemoryRegionSection *VAR_1) { VFIOContainer *container = container_of(VAR_0, VFIOContainer, VAR_0); hwaddr iova, end; Int128 llend, llsize; void *VAR_2; int VAR_3; VFIOHostDMAWindow *hostwin; bool hostwin_found; if (vfio_listener_skipped_section(VAR_1)) { trace_vfio_listener_region_add_skip( VAR_1->offset_within_address_space, VAR_1->offset_within_address_space + int128_get64(int128_sub(VAR_1->size, int128_one()))); return; } if (unlikely((VAR_1->offset_within_address_space & ~TARGET_PAGE_MASK) != (VAR_1->offset_within_region & ~TARGET_PAGE_MASK))) { error_report("%s received unaligned region", __func__); return; } iova = TARGET_PAGE_ALIGN(VAR_1->offset_within_address_space); llend = int128_make64(VAR_1->offset_within_address_space); llend = int128_add(llend, VAR_1->size); llend = int128_and(llend, int128_exts64(TARGET_PAGE_MASK)); if (int128_ge(int128_make64(iova), llend)) { return; } end = int128_get64(int128_sub(llend, int128_one())); if (container->iommu_type == VFIO_SPAPR_TCE_v2_IOMMU) { VFIOHostDMAWindow *hostwin; hwaddr pgsize = 0; QLIST_FOREACH(hostwin, &container->hostwin_list, hostwin_next) { if (ranges_overlap(hostwin->min_iova, hostwin->max_iova - hostwin->min_iova + 1, VAR_1->offset_within_address_space, int128_get64(VAR_1->size))) { VAR_3 = -1; goto fail; } } VAR_3 = vfio_spapr_create_window(container, VAR_1, &pgsize); if (VAR_3) { goto fail; } vfio_host_win_add(container, VAR_1->offset_within_address_space, VAR_1->offset_within_address_space + int128_get64(VAR_1->size) - 1, pgsize); } hostwin_found = false; QLIST_FOREACH(hostwin, &container->hostwin_list, hostwin_next) { if (hostwin->min_iova <= iova && end <= hostwin->max_iova) { hostwin_found = true; break; } } if (!hostwin_found) { error_report("vfio: IOMMU container %p can't map guest IOVA region" " 0x%"HWADDR_PRIx"..0x%"HWADDR_PRIx, container, iova, end); VAR_3 = -EFAULT; goto fail; } memory_region_ref(VAR_1->mr); if (memory_region_is_iommu(VAR_1->mr)) { VFIOGuestIOMMU *giommu; trace_vfio_listener_region_add_iommu(iova, end); giommu = g_malloc0(sizeof(*giommu)); giommu->iommu = VAR_1->mr; giommu->iommu_offset = VAR_1->offset_within_address_space - VAR_1->offset_within_region; giommu->container = container; giommu->n.notify = vfio_iommu_map_notify; giommu->n.notifier_flags = IOMMU_NOTIFIER_ALL; QLIST_INSERT_HEAD(&container->giommu_list, giommu, giommu_next); memory_region_register_iommu_notifier(giommu->iommu, &giommu->n); memory_region_iommu_replay(giommu->iommu, &giommu->n, false); return; } VAR_2 = memory_region_get_ram_ptr(VAR_1->mr) + VAR_1->offset_within_region + (iova - VAR_1->offset_within_address_space); trace_vfio_listener_region_add_ram(iova, end, VAR_2); llsize = int128_sub(llend, int128_make64(iova)); VAR_3 = vfio_dma_map(container, iova, int128_get64(llsize), VAR_2, VAR_1->readonly); if (VAR_3) { error_report("vfio_dma_map(%p, 0x%"HWADDR_PRIx", " "0x%"HWADDR_PRIx", %p) = %d (%m)", container, iova, int128_get64(llsize), VAR_2, VAR_3); goto fail; } return; fail: if (!container->initialized) { if (!container->error) { container->error = VAR_3; } } else { hw_error("vfio: DMA mapping failed, unable to continue"); } }
[ "static void FUNC_0(MemoryListener *VAR_0,\nMemoryRegionSection *VAR_1)\n{", "VFIOContainer *container = container_of(VAR_0, VFIOContainer, VAR_0);", "hwaddr iova, end;", "Int128 llend, llsize;", "void *VAR_2;", "int VAR_3;", "VFIOHostDMAWindow *hostwin;", "bool hostwin_found;", "if (vfio_listener_skipped_section(VAR_1)) {", "trace_vfio_listener_region_add_skip(\nVAR_1->offset_within_address_space,\nVAR_1->offset_within_address_space +\nint128_get64(int128_sub(VAR_1->size, int128_one())));", "return;", "}", "if (unlikely((VAR_1->offset_within_address_space & ~TARGET_PAGE_MASK) !=\n(VAR_1->offset_within_region & ~TARGET_PAGE_MASK))) {", "error_report(\"%s received unaligned region\", __func__);", "return;", "}", "iova = TARGET_PAGE_ALIGN(VAR_1->offset_within_address_space);", "llend = int128_make64(VAR_1->offset_within_address_space);", "llend = int128_add(llend, VAR_1->size);", "llend = int128_and(llend, int128_exts64(TARGET_PAGE_MASK));", "if (int128_ge(int128_make64(iova), llend)) {", "return;", "}", "end = int128_get64(int128_sub(llend, int128_one()));", "if (container->iommu_type == VFIO_SPAPR_TCE_v2_IOMMU) {", "VFIOHostDMAWindow *hostwin;", "hwaddr pgsize = 0;", "QLIST_FOREACH(hostwin, &container->hostwin_list, hostwin_next) {", "if (ranges_overlap(hostwin->min_iova,\nhostwin->max_iova - hostwin->min_iova + 1,\nVAR_1->offset_within_address_space,\nint128_get64(VAR_1->size))) {", "VAR_3 = -1;", "goto fail;", "}", "}", "VAR_3 = vfio_spapr_create_window(container, VAR_1, &pgsize);", "if (VAR_3) {", "goto fail;", "}", "vfio_host_win_add(container, VAR_1->offset_within_address_space,\nVAR_1->offset_within_address_space +\nint128_get64(VAR_1->size) - 1, pgsize);", "}", "hostwin_found = false;", "QLIST_FOREACH(hostwin, &container->hostwin_list, hostwin_next) {", "if (hostwin->min_iova <= iova && end <= hostwin->max_iova) {", "hostwin_found = true;", "break;", "}", "}", "if (!hostwin_found) {", "error_report(\"vfio: IOMMU container %p can't map guest IOVA region\"\n\" 0x%\"HWADDR_PRIx\"..0x%\"HWADDR_PRIx,\ncontainer, iova, end);", "VAR_3 = -EFAULT;", "goto fail;", "}", "memory_region_ref(VAR_1->mr);", "if (memory_region_is_iommu(VAR_1->mr)) {", "VFIOGuestIOMMU *giommu;", "trace_vfio_listener_region_add_iommu(iova, end);", "giommu = g_malloc0(sizeof(*giommu));", "giommu->iommu = VAR_1->mr;", "giommu->iommu_offset = VAR_1->offset_within_address_space -\nVAR_1->offset_within_region;", "giommu->container = container;", "giommu->n.notify = vfio_iommu_map_notify;", "giommu->n.notifier_flags = IOMMU_NOTIFIER_ALL;", "QLIST_INSERT_HEAD(&container->giommu_list, giommu, giommu_next);", "memory_region_register_iommu_notifier(giommu->iommu, &giommu->n);", "memory_region_iommu_replay(giommu->iommu, &giommu->n, false);", "return;", "}", "VAR_2 = memory_region_get_ram_ptr(VAR_1->mr) +\nVAR_1->offset_within_region +\n(iova - VAR_1->offset_within_address_space);", "trace_vfio_listener_region_add_ram(iova, end, VAR_2);", "llsize = int128_sub(llend, int128_make64(iova));", "VAR_3 = vfio_dma_map(container, iova, int128_get64(llsize),\nVAR_2, VAR_1->readonly);", "if (VAR_3) {", "error_report(\"vfio_dma_map(%p, 0x%\"HWADDR_PRIx\", \"\n\"0x%\"HWADDR_PRIx\", %p) = %d (%m)\",\ncontainer, iova, int128_get64(llsize), VAR_2, VAR_3);", "goto fail;", "}", "return;", "fail:\nif (!container->initialized) {", "if (!container->error) {", "container->error = VAR_3;", "}", "} else {", "hw_error(\"vfio: DMA mapping failed, unable to continue\");", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 23 ], [ 25, 27, 29, 31 ], [ 33 ], [ 35 ], [ 39, 41 ], [ 43 ], [ 45 ], [ 47 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 71 ], [ 73 ], [ 75 ], [ 81 ], [ 83, 85, 87, 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 111, 113, 115 ], [ 117 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 137 ], [ 139, 141, 143 ], [ 145 ], [ 147 ], [ 149 ], [ 153 ], [ 157 ], [ 159 ], [ 163 ], [ 177 ], [ 179 ], [ 181, 183 ], [ 185 ], [ 187 ], [ 189 ], [ 191 ], [ 195 ], [ 197 ], [ 201 ], [ 203 ], [ 211, 213, 215 ], [ 219 ], [ 223 ], [ 227, 229 ], [ 231 ], [ 233, 235, 237 ], [ 239 ], [ 241 ], [ 245 ], [ 249, 261 ], [ 263 ], [ 265 ], [ 267 ], [ 269 ], [ 271 ], [ 273 ], [ 275 ] ]
22,177
static void niagara_init(MachineState *machine) { NiagaraBoardState *s = g_new(NiagaraBoardState, 1); DriveInfo *dinfo = drive_get_next(IF_PFLASH); MemoryRegion *sysmem = get_system_memory(); /* init CPUs */ sparc64_cpu_devinit(machine->cpu_model, "Sun UltraSparc T1", NIAGARA_PROM_BASE); /* set up devices */ memory_region_allocate_system_memory(&s->hv_ram, NULL, "sun4v-hv.ram", NIAGARA_HV_RAM_SIZE); memory_region_add_subregion(sysmem, NIAGARA_HV_RAM_BASE, &s->hv_ram); memory_region_allocate_system_memory(&s->partition_ram, NULL, "sun4v-partition.ram", machine->ram_size); memory_region_add_subregion(sysmem, NIAGARA_PARTITION_RAM_BASE, &s->partition_ram); memory_region_allocate_system_memory(&s->nvram, NULL, "sun4v.nvram", NIAGARA_NVRAM_SIZE); memory_region_add_subregion(sysmem, NIAGARA_NVRAM_BASE, &s->nvram); memory_region_allocate_system_memory(&s->md_rom, NULL, "sun4v-md.rom", NIAGARA_MD_ROM_SIZE); memory_region_add_subregion(sysmem, NIAGARA_MD_ROM_BASE, &s->md_rom); memory_region_allocate_system_memory(&s->hv_rom, NULL, "sun4v-hv.rom", NIAGARA_HV_ROM_SIZE); memory_region_add_subregion(sysmem, NIAGARA_HV_ROM_BASE, &s->hv_rom); memory_region_allocate_system_memory(&s->prom, NULL, "sun4v.prom", PROM_SIZE_MAX); memory_region_add_subregion(sysmem, NIAGARA_PROM_BASE, &s->prom); add_rom_or_fail("nvram1", NIAGARA_NVRAM_BASE); add_rom_or_fail("1up-md.bin", NIAGARA_MD_ROM_BASE); add_rom_or_fail("1up-hv.bin", NIAGARA_HV_ROM_BASE); add_rom_or_fail("reset.bin", NIAGARA_PROM_BASE); add_rom_or_fail("q.bin", NIAGARA_PROM_BASE + NIAGARA_Q_OFFSET); add_rom_or_fail("openboot.bin", NIAGARA_PROM_BASE + NIAGARA_OBP_OFFSET); /* the virtual ramdisk is kind of initrd, but it resides outside of the partition RAM */ if (dinfo) { BlockBackend *blk = blk_by_legacy_dinfo(dinfo); int size = blk_getlength(blk); if (size > 0) { memory_region_allocate_system_memory(&s->vdisk_ram, NULL, "sun4v_vdisk.ram", size); memory_region_add_subregion(get_system_memory(), NIAGARA_VDISK_BASE, &s->vdisk_ram); dinfo->is_default = 1; rom_add_file_fixed(blk_bs(blk)->filename, NIAGARA_VDISK_BASE, -1); } else { fprintf(stderr, "qemu: could not load ram disk '%s'\n", blk_bs(blk)->filename); exit(1); } } serial_mm_init(sysmem, NIAGARA_UART_BASE, 0, NULL, 115200, serial_hds[0], DEVICE_BIG_ENDIAN); empty_slot_init(NIAGARA_IOBBASE, NIAGARA_IOBSIZE); sun4v_rtc_init(NIAGARA_RTC_BASE); }
false
qemu
a5a08302d44a8b1a8c5819b1411002f85bb5f847
static void niagara_init(MachineState *machine) { NiagaraBoardState *s = g_new(NiagaraBoardState, 1); DriveInfo *dinfo = drive_get_next(IF_PFLASH); MemoryRegion *sysmem = get_system_memory(); sparc64_cpu_devinit(machine->cpu_model, "Sun UltraSparc T1", NIAGARA_PROM_BASE); memory_region_allocate_system_memory(&s->hv_ram, NULL, "sun4v-hv.ram", NIAGARA_HV_RAM_SIZE); memory_region_add_subregion(sysmem, NIAGARA_HV_RAM_BASE, &s->hv_ram); memory_region_allocate_system_memory(&s->partition_ram, NULL, "sun4v-partition.ram", machine->ram_size); memory_region_add_subregion(sysmem, NIAGARA_PARTITION_RAM_BASE, &s->partition_ram); memory_region_allocate_system_memory(&s->nvram, NULL, "sun4v.nvram", NIAGARA_NVRAM_SIZE); memory_region_add_subregion(sysmem, NIAGARA_NVRAM_BASE, &s->nvram); memory_region_allocate_system_memory(&s->md_rom, NULL, "sun4v-md.rom", NIAGARA_MD_ROM_SIZE); memory_region_add_subregion(sysmem, NIAGARA_MD_ROM_BASE, &s->md_rom); memory_region_allocate_system_memory(&s->hv_rom, NULL, "sun4v-hv.rom", NIAGARA_HV_ROM_SIZE); memory_region_add_subregion(sysmem, NIAGARA_HV_ROM_BASE, &s->hv_rom); memory_region_allocate_system_memory(&s->prom, NULL, "sun4v.prom", PROM_SIZE_MAX); memory_region_add_subregion(sysmem, NIAGARA_PROM_BASE, &s->prom); add_rom_or_fail("nvram1", NIAGARA_NVRAM_BASE); add_rom_or_fail("1up-md.bin", NIAGARA_MD_ROM_BASE); add_rom_or_fail("1up-hv.bin", NIAGARA_HV_ROM_BASE); add_rom_or_fail("reset.bin", NIAGARA_PROM_BASE); add_rom_or_fail("q.bin", NIAGARA_PROM_BASE + NIAGARA_Q_OFFSET); add_rom_or_fail("openboot.bin", NIAGARA_PROM_BASE + NIAGARA_OBP_OFFSET); if (dinfo) { BlockBackend *blk = blk_by_legacy_dinfo(dinfo); int size = blk_getlength(blk); if (size > 0) { memory_region_allocate_system_memory(&s->vdisk_ram, NULL, "sun4v_vdisk.ram", size); memory_region_add_subregion(get_system_memory(), NIAGARA_VDISK_BASE, &s->vdisk_ram); dinfo->is_default = 1; rom_add_file_fixed(blk_bs(blk)->filename, NIAGARA_VDISK_BASE, -1); } else { fprintf(stderr, "qemu: could not load ram disk '%s'\n", blk_bs(blk)->filename); exit(1); } } serial_mm_init(sysmem, NIAGARA_UART_BASE, 0, NULL, 115200, serial_hds[0], DEVICE_BIG_ENDIAN); empty_slot_init(NIAGARA_IOBBASE, NIAGARA_IOBSIZE); sun4v_rtc_init(NIAGARA_RTC_BASE); }
{ "code": [], "line_no": [] }
static void FUNC_0(MachineState *VAR_0) { NiagaraBoardState *s = g_new(NiagaraBoardState, 1); DriveInfo *dinfo = drive_get_next(IF_PFLASH); MemoryRegion *sysmem = get_system_memory(); sparc64_cpu_devinit(VAR_0->cpu_model, "Sun UltraSparc T1", NIAGARA_PROM_BASE); memory_region_allocate_system_memory(&s->hv_ram, NULL, "sun4v-hv.ram", NIAGARA_HV_RAM_SIZE); memory_region_add_subregion(sysmem, NIAGARA_HV_RAM_BASE, &s->hv_ram); memory_region_allocate_system_memory(&s->partition_ram, NULL, "sun4v-partition.ram", VAR_0->ram_size); memory_region_add_subregion(sysmem, NIAGARA_PARTITION_RAM_BASE, &s->partition_ram); memory_region_allocate_system_memory(&s->nvram, NULL, "sun4v.nvram", NIAGARA_NVRAM_SIZE); memory_region_add_subregion(sysmem, NIAGARA_NVRAM_BASE, &s->nvram); memory_region_allocate_system_memory(&s->md_rom, NULL, "sun4v-md.rom", NIAGARA_MD_ROM_SIZE); memory_region_add_subregion(sysmem, NIAGARA_MD_ROM_BASE, &s->md_rom); memory_region_allocate_system_memory(&s->hv_rom, NULL, "sun4v-hv.rom", NIAGARA_HV_ROM_SIZE); memory_region_add_subregion(sysmem, NIAGARA_HV_ROM_BASE, &s->hv_rom); memory_region_allocate_system_memory(&s->prom, NULL, "sun4v.prom", PROM_SIZE_MAX); memory_region_add_subregion(sysmem, NIAGARA_PROM_BASE, &s->prom); add_rom_or_fail("nvram1", NIAGARA_NVRAM_BASE); add_rom_or_fail("1up-md.bin", NIAGARA_MD_ROM_BASE); add_rom_or_fail("1up-hv.bin", NIAGARA_HV_ROM_BASE); add_rom_or_fail("reset.bin", NIAGARA_PROM_BASE); add_rom_or_fail("q.bin", NIAGARA_PROM_BASE + NIAGARA_Q_OFFSET); add_rom_or_fail("openboot.bin", NIAGARA_PROM_BASE + NIAGARA_OBP_OFFSET); if (dinfo) { BlockBackend *blk = blk_by_legacy_dinfo(dinfo); int VAR_1 = blk_getlength(blk); if (VAR_1 > 0) { memory_region_allocate_system_memory(&s->vdisk_ram, NULL, "sun4v_vdisk.ram", VAR_1); memory_region_add_subregion(get_system_memory(), NIAGARA_VDISK_BASE, &s->vdisk_ram); dinfo->is_default = 1; rom_add_file_fixed(blk_bs(blk)->filename, NIAGARA_VDISK_BASE, -1); } else { fprintf(stderr, "qemu: could not load ram disk '%s'\n", blk_bs(blk)->filename); exit(1); } } serial_mm_init(sysmem, NIAGARA_UART_BASE, 0, NULL, 115200, serial_hds[0], DEVICE_BIG_ENDIAN); empty_slot_init(NIAGARA_IOBBASE, NIAGARA_IOBSIZE); sun4v_rtc_init(NIAGARA_RTC_BASE); }
[ "static void FUNC_0(MachineState *VAR_0)\n{", "NiagaraBoardState *s = g_new(NiagaraBoardState, 1);", "DriveInfo *dinfo = drive_get_next(IF_PFLASH);", "MemoryRegion *sysmem = get_system_memory();", "sparc64_cpu_devinit(VAR_0->cpu_model, \"Sun UltraSparc T1\",\nNIAGARA_PROM_BASE);", "memory_region_allocate_system_memory(&s->hv_ram, NULL, \"sun4v-hv.ram\",\nNIAGARA_HV_RAM_SIZE);", "memory_region_add_subregion(sysmem, NIAGARA_HV_RAM_BASE, &s->hv_ram);", "memory_region_allocate_system_memory(&s->partition_ram, NULL,\n\"sun4v-partition.ram\",\nVAR_0->ram_size);", "memory_region_add_subregion(sysmem, NIAGARA_PARTITION_RAM_BASE,\n&s->partition_ram);", "memory_region_allocate_system_memory(&s->nvram, NULL,\n\"sun4v.nvram\", NIAGARA_NVRAM_SIZE);", "memory_region_add_subregion(sysmem, NIAGARA_NVRAM_BASE, &s->nvram);", "memory_region_allocate_system_memory(&s->md_rom, NULL,\n\"sun4v-md.rom\", NIAGARA_MD_ROM_SIZE);", "memory_region_add_subregion(sysmem, NIAGARA_MD_ROM_BASE, &s->md_rom);", "memory_region_allocate_system_memory(&s->hv_rom, NULL,\n\"sun4v-hv.rom\", NIAGARA_HV_ROM_SIZE);", "memory_region_add_subregion(sysmem, NIAGARA_HV_ROM_BASE, &s->hv_rom);", "memory_region_allocate_system_memory(&s->prom, NULL,\n\"sun4v.prom\", PROM_SIZE_MAX);", "memory_region_add_subregion(sysmem, NIAGARA_PROM_BASE, &s->prom);", "add_rom_or_fail(\"nvram1\", NIAGARA_NVRAM_BASE);", "add_rom_or_fail(\"1up-md.bin\", NIAGARA_MD_ROM_BASE);", "add_rom_or_fail(\"1up-hv.bin\", NIAGARA_HV_ROM_BASE);", "add_rom_or_fail(\"reset.bin\", NIAGARA_PROM_BASE);", "add_rom_or_fail(\"q.bin\", NIAGARA_PROM_BASE + NIAGARA_Q_OFFSET);", "add_rom_or_fail(\"openboot.bin\", NIAGARA_PROM_BASE + NIAGARA_OBP_OFFSET);", "if (dinfo) {", "BlockBackend *blk = blk_by_legacy_dinfo(dinfo);", "int VAR_1 = blk_getlength(blk);", "if (VAR_1 > 0) {", "memory_region_allocate_system_memory(&s->vdisk_ram, NULL,\n\"sun4v_vdisk.ram\", VAR_1);", "memory_region_add_subregion(get_system_memory(),\nNIAGARA_VDISK_BASE, &s->vdisk_ram);", "dinfo->is_default = 1;", "rom_add_file_fixed(blk_bs(blk)->filename, NIAGARA_VDISK_BASE, -1);", "} else {", "fprintf(stderr, \"qemu: could not load ram disk '%s'\\n\",\nblk_bs(blk)->filename);", "exit(1);", "}", "}", "serial_mm_init(sysmem, NIAGARA_UART_BASE, 0, NULL, 115200,\nserial_hds[0], DEVICE_BIG_ENDIAN);", "empty_slot_init(NIAGARA_IOBBASE, NIAGARA_IOBSIZE);", "sun4v_rtc_init(NIAGARA_RTC_BASE);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 15, 17 ], [ 21, 23 ], [ 25 ], [ 29, 31, 33 ], [ 35, 37 ], [ 41, 43 ], [ 45 ], [ 47, 49 ], [ 51 ], [ 53, 55 ], [ 57 ], [ 59, 61 ], [ 63 ], [ 67 ], [ 69 ], [ 71 ], [ 75 ], [ 77 ], [ 79 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95, 97 ], [ 99, 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109, 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119, 121 ], [ 125 ], [ 127 ], [ 129 ] ]
22,178
static int virtqueue_num_heads(VirtQueue *vq, unsigned int idx) { uint16_t num_heads = vring_avail_idx(vq) - idx; /* Check it isn't doing very strange things with descriptor numbers. */ if (num_heads > vq->vring.num) { error_report("Guest moved used index from %u to %u", idx, vring_avail_idx(vq)); exit(1); } /* On success, callers read a descriptor at vq->last_avail_idx. * Make sure descriptor read does not bypass avail index read. */ if (num_heads) { smp_rmb(); } return num_heads; }
false
qemu
be1fea9bc286f64c6c995bb0d7145a0b738aeddb
static int virtqueue_num_heads(VirtQueue *vq, unsigned int idx) { uint16_t num_heads = vring_avail_idx(vq) - idx; if (num_heads > vq->vring.num) { error_report("Guest moved used index from %u to %u", idx, vring_avail_idx(vq)); exit(1); } if (num_heads) { smp_rmb(); } return num_heads; }
{ "code": [], "line_no": [] }
static int FUNC_0(VirtQueue *VAR_0, unsigned int VAR_1) { uint16_t num_heads = vring_avail_idx(VAR_0) - VAR_1; if (num_heads > VAR_0->vring.num) { error_report("Guest moved used index from %u to %u", VAR_1, vring_avail_idx(VAR_0)); exit(1); } if (num_heads) { smp_rmb(); } return num_heads; }
[ "static int FUNC_0(VirtQueue *VAR_0, unsigned int VAR_1)\n{", "uint16_t num_heads = vring_avail_idx(VAR_0) - VAR_1;", "if (num_heads > VAR_0->vring.num) {", "error_report(\"Guest moved used index from %u to %u\",\nVAR_1, vring_avail_idx(VAR_0));", "exit(1);", "}", "if (num_heads) {", "smp_rmb();", "}", "return num_heads;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 11 ], [ 13, 15 ], [ 17 ], [ 19 ], [ 25 ], [ 27 ], [ 29 ], [ 33 ], [ 35 ] ]
22,179
static void load_linux(void *fw_cfg, target_phys_addr_t option_rom, const char *kernel_filename, const char *initrd_filename, const char *kernel_cmdline, target_phys_addr_t max_ram_size) { uint16_t protocol; uint32_t gpr[8]; uint16_t seg[6]; uint16_t real_seg; int setup_size, kernel_size, initrd_size = 0, cmdline_size; uint32_t initrd_max; uint8_t header[8192]; target_phys_addr_t real_addr, prot_addr, cmdline_addr, initrd_addr = 0; FILE *f, *fi; char *vmode; /* Align to 16 bytes as a paranoia measure */ cmdline_size = (strlen(kernel_cmdline)+16) & ~15; /* load the kernel header */ f = fopen(kernel_filename, "rb"); if (!f || !(kernel_size = get_file_size(f)) || fread(header, 1, MIN(ARRAY_SIZE(header), kernel_size), f) != MIN(ARRAY_SIZE(header), kernel_size)) { fprintf(stderr, "qemu: could not load kernel '%s': %s\n", kernel_filename, strerror(errno)); exit(1); } /* kernel protocol version */ #if 0 fprintf(stderr, "header magic: %#x\n", ldl_p(header+0x202)); #endif if (ldl_p(header+0x202) == 0x53726448) protocol = lduw_p(header+0x206); else { /* This looks like a multiboot kernel. If it is, let's stop treating it like a Linux kernel. */ if (load_multiboot(fw_cfg, f, kernel_filename, initrd_filename, kernel_cmdline, header)) return; protocol = 0; } if (protocol < 0x200 || !(header[0x211] & 0x01)) { /* Low kernel */ real_addr = 0x90000; cmdline_addr = 0x9a000 - cmdline_size; prot_addr = 0x10000; } else if (protocol < 0x202) { /* High but ancient kernel */ real_addr = 0x90000; cmdline_addr = 0x9a000 - cmdline_size; prot_addr = 0x100000; } else { /* High and recent kernel */ real_addr = 0x10000; cmdline_addr = 0x20000; prot_addr = 0x100000; } #if 0 fprintf(stderr, "qemu: real_addr = 0x" TARGET_FMT_plx "\n" "qemu: cmdline_addr = 0x" TARGET_FMT_plx "\n" "qemu: prot_addr = 0x" TARGET_FMT_plx "\n", real_addr, cmdline_addr, prot_addr); #endif /* highest address for loading the initrd */ if (protocol >= 0x203) initrd_max = ldl_p(header+0x22c); else initrd_max = 0x37ffffff; if (initrd_max >= max_ram_size-ACPI_DATA_SIZE) initrd_max = max_ram_size-ACPI_DATA_SIZE-1; /* kernel command line */ pstrcpy_targphys(cmdline_addr, 4096, kernel_cmdline); if (protocol >= 0x202) { stl_p(header+0x228, cmdline_addr); } else { stw_p(header+0x20, 0xA33F); stw_p(header+0x22, cmdline_addr-real_addr); } /* handle vga= parameter */ vmode = strstr(kernel_cmdline, "vga="); if (vmode) { unsigned int video_mode; /* skip "vga=" */ vmode += 4; if (!strncmp(vmode, "normal", 6)) { video_mode = 0xffff; } else if (!strncmp(vmode, "ext", 3)) { video_mode = 0xfffe; } else if (!strncmp(vmode, "ask", 3)) { video_mode = 0xfffd; } else { video_mode = strtol(vmode, NULL, 0); } stw_p(header+0x1fa, video_mode); } /* loader type */ /* High nybble = B reserved for Qemu; low nybble is revision number. If this code is substantially changed, you may want to consider incrementing the revision. */ if (protocol >= 0x200) header[0x210] = 0xB0; /* heap */ if (protocol >= 0x201) { header[0x211] |= 0x80; /* CAN_USE_HEAP */ stw_p(header+0x224, cmdline_addr-real_addr-0x200); } /* load initrd */ if (initrd_filename) { if (protocol < 0x200) { fprintf(stderr, "qemu: linux kernel too old to load a ram disk\n"); exit(1); } fi = fopen(initrd_filename, "rb"); if (!fi) { fprintf(stderr, "qemu: could not load initial ram disk '%s': %s\n", initrd_filename, strerror(errno)); exit(1); } initrd_size = get_file_size(fi); initrd_addr = (initrd_max-initrd_size) & ~4095; if (!fread_targphys_ok(initrd_addr, initrd_size, fi)) { fprintf(stderr, "qemu: read error on initial ram disk '%s': %s\n", initrd_filename, strerror(errno)); exit(1); } fclose(fi); stl_p(header+0x218, initrd_addr); stl_p(header+0x21c, initrd_size); } /* store the finalized header and load the rest of the kernel */ cpu_physical_memory_write(real_addr, header, ARRAY_SIZE(header)); setup_size = header[0x1f1]; if (setup_size == 0) setup_size = 4; setup_size = (setup_size+1)*512; /* Size of protected-mode code */ kernel_size -= (setup_size > ARRAY_SIZE(header)) ? setup_size : ARRAY_SIZE(header); /* In case we have read too much already, copy that over */ if (setup_size < ARRAY_SIZE(header)) { cpu_physical_memory_write(prot_addr, header + setup_size, ARRAY_SIZE(header) - setup_size); prot_addr += (ARRAY_SIZE(header) - setup_size); setup_size = ARRAY_SIZE(header); } if (!fread_targphys_ok(real_addr + ARRAY_SIZE(header), setup_size - ARRAY_SIZE(header), f) || !fread_targphys_ok(prot_addr, kernel_size, f)) { fprintf(stderr, "qemu: read error on kernel '%s'\n", kernel_filename); exit(1); } fclose(f); /* generate bootsector to set up the initial register state */ real_seg = real_addr >> 4; seg[0] = seg[2] = seg[3] = seg[4] = seg[4] = real_seg; seg[1] = real_seg+0x20; /* CS */ memset(gpr, 0, sizeof gpr); gpr[4] = cmdline_addr-real_addr-16; /* SP (-16 is paranoia) */ option_rom_setup_reset(real_addr, setup_size); option_rom_setup_reset(prot_addr, kernel_size); option_rom_setup_reset(cmdline_addr, cmdline_size); if (initrd_filename) option_rom_setup_reset(initrd_addr, initrd_size); generate_bootsect(option_rom, gpr, seg, 0); }
false
qemu
45a50b1668822c23afc2a89f724654e176518bc4
static void load_linux(void *fw_cfg, target_phys_addr_t option_rom, const char *kernel_filename, const char *initrd_filename, const char *kernel_cmdline, target_phys_addr_t max_ram_size) { uint16_t protocol; uint32_t gpr[8]; uint16_t seg[6]; uint16_t real_seg; int setup_size, kernel_size, initrd_size = 0, cmdline_size; uint32_t initrd_max; uint8_t header[8192]; target_phys_addr_t real_addr, prot_addr, cmdline_addr, initrd_addr = 0; FILE *f, *fi; char *vmode; cmdline_size = (strlen(kernel_cmdline)+16) & ~15; f = fopen(kernel_filename, "rb"); if (!f || !(kernel_size = get_file_size(f)) || fread(header, 1, MIN(ARRAY_SIZE(header), kernel_size), f) != MIN(ARRAY_SIZE(header), kernel_size)) { fprintf(stderr, "qemu: could not load kernel '%s': %s\n", kernel_filename, strerror(errno)); exit(1); } #if 0 fprintf(stderr, "header magic: %#x\n", ldl_p(header+0x202)); #endif if (ldl_p(header+0x202) == 0x53726448) protocol = lduw_p(header+0x206); else { if (load_multiboot(fw_cfg, f, kernel_filename, initrd_filename, kernel_cmdline, header)) return; protocol = 0; } if (protocol < 0x200 || !(header[0x211] & 0x01)) { real_addr = 0x90000; cmdline_addr = 0x9a000 - cmdline_size; prot_addr = 0x10000; } else if (protocol < 0x202) { real_addr = 0x90000; cmdline_addr = 0x9a000 - cmdline_size; prot_addr = 0x100000; } else { real_addr = 0x10000; cmdline_addr = 0x20000; prot_addr = 0x100000; } #if 0 fprintf(stderr, "qemu: real_addr = 0x" TARGET_FMT_plx "\n" "qemu: cmdline_addr = 0x" TARGET_FMT_plx "\n" "qemu: prot_addr = 0x" TARGET_FMT_plx "\n", real_addr, cmdline_addr, prot_addr); #endif if (protocol >= 0x203) initrd_max = ldl_p(header+0x22c); else initrd_max = 0x37ffffff; if (initrd_max >= max_ram_size-ACPI_DATA_SIZE) initrd_max = max_ram_size-ACPI_DATA_SIZE-1; pstrcpy_targphys(cmdline_addr, 4096, kernel_cmdline); if (protocol >= 0x202) { stl_p(header+0x228, cmdline_addr); } else { stw_p(header+0x20, 0xA33F); stw_p(header+0x22, cmdline_addr-real_addr); } vmode = strstr(kernel_cmdline, "vga="); if (vmode) { unsigned int video_mode; vmode += 4; if (!strncmp(vmode, "normal", 6)) { video_mode = 0xffff; } else if (!strncmp(vmode, "ext", 3)) { video_mode = 0xfffe; } else if (!strncmp(vmode, "ask", 3)) { video_mode = 0xfffd; } else { video_mode = strtol(vmode, NULL, 0); } stw_p(header+0x1fa, video_mode); } if (protocol >= 0x200) header[0x210] = 0xB0; if (protocol >= 0x201) { header[0x211] |= 0x80; stw_p(header+0x224, cmdline_addr-real_addr-0x200); } if (initrd_filename) { if (protocol < 0x200) { fprintf(stderr, "qemu: linux kernel too old to load a ram disk\n"); exit(1); } fi = fopen(initrd_filename, "rb"); if (!fi) { fprintf(stderr, "qemu: could not load initial ram disk '%s': %s\n", initrd_filename, strerror(errno)); exit(1); } initrd_size = get_file_size(fi); initrd_addr = (initrd_max-initrd_size) & ~4095; if (!fread_targphys_ok(initrd_addr, initrd_size, fi)) { fprintf(stderr, "qemu: read error on initial ram disk '%s': %s\n", initrd_filename, strerror(errno)); exit(1); } fclose(fi); stl_p(header+0x218, initrd_addr); stl_p(header+0x21c, initrd_size); } cpu_physical_memory_write(real_addr, header, ARRAY_SIZE(header)); setup_size = header[0x1f1]; if (setup_size == 0) setup_size = 4; setup_size = (setup_size+1)*512; kernel_size -= (setup_size > ARRAY_SIZE(header)) ? setup_size : ARRAY_SIZE(header); if (setup_size < ARRAY_SIZE(header)) { cpu_physical_memory_write(prot_addr, header + setup_size, ARRAY_SIZE(header) - setup_size); prot_addr += (ARRAY_SIZE(header) - setup_size); setup_size = ARRAY_SIZE(header); } if (!fread_targphys_ok(real_addr + ARRAY_SIZE(header), setup_size - ARRAY_SIZE(header), f) || !fread_targphys_ok(prot_addr, kernel_size, f)) { fprintf(stderr, "qemu: read error on kernel '%s'\n", kernel_filename); exit(1); } fclose(f); real_seg = real_addr >> 4; seg[0] = seg[2] = seg[3] = seg[4] = seg[4] = real_seg; seg[1] = real_seg+0x20; memset(gpr, 0, sizeof gpr); gpr[4] = cmdline_addr-real_addr-16; option_rom_setup_reset(real_addr, setup_size); option_rom_setup_reset(prot_addr, kernel_size); option_rom_setup_reset(cmdline_addr, cmdline_size); if (initrd_filename) option_rom_setup_reset(initrd_addr, initrd_size); generate_bootsect(option_rom, gpr, seg, 0); }
{ "code": [], "line_no": [] }
static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1, const char *VAR_2, const char *VAR_3, const char *VAR_4, target_phys_addr_t VAR_5) { uint16_t protocol; uint32_t gpr[8]; uint16_t seg[6]; uint16_t real_seg; int VAR_6, VAR_7, VAR_8 = 0, VAR_9; uint32_t initrd_max; uint8_t header[8192]; target_phys_addr_t real_addr, prot_addr, cmdline_addr, initrd_addr = 0; FILE *f, *fi; char *VAR_10; VAR_9 = (strlen(VAR_4)+16) & ~15; f = fopen(VAR_2, "rb"); if (!f || !(VAR_7 = get_file_size(f)) || fread(header, 1, MIN(ARRAY_SIZE(header), VAR_7), f) != MIN(ARRAY_SIZE(header), VAR_7)) { fprintf(stderr, "qemu: could not load kernel '%s': %s\n", VAR_2, strerror(errno)); exit(1); } #if 0 fprintf(stderr, "header magic: %#x\n", ldl_p(header+0x202)); #endif if (ldl_p(header+0x202) == 0x53726448) protocol = lduw_p(header+0x206); else { if (load_multiboot(VAR_0, f, VAR_2, VAR_3, VAR_4, header)) return; protocol = 0; } if (protocol < 0x200 || !(header[0x211] & 0x01)) { real_addr = 0x90000; cmdline_addr = 0x9a000 - VAR_9; prot_addr = 0x10000; } else if (protocol < 0x202) { real_addr = 0x90000; cmdline_addr = 0x9a000 - VAR_9; prot_addr = 0x100000; } else { real_addr = 0x10000; cmdline_addr = 0x20000; prot_addr = 0x100000; } #if 0 fprintf(stderr, "qemu: real_addr = 0x" TARGET_FMT_plx "\n" "qemu: cmdline_addr = 0x" TARGET_FMT_plx "\n" "qemu: prot_addr = 0x" TARGET_FMT_plx "\n", real_addr, cmdline_addr, prot_addr); #endif if (protocol >= 0x203) initrd_max = ldl_p(header+0x22c); else initrd_max = 0x37ffffff; if (initrd_max >= VAR_5-ACPI_DATA_SIZE) initrd_max = VAR_5-ACPI_DATA_SIZE-1; pstrcpy_targphys(cmdline_addr, 4096, VAR_4); if (protocol >= 0x202) { stl_p(header+0x228, cmdline_addr); } else { stw_p(header+0x20, 0xA33F); stw_p(header+0x22, cmdline_addr-real_addr); } VAR_10 = strstr(VAR_4, "vga="); if (VAR_10) { unsigned int VAR_11; VAR_10 += 4; if (!strncmp(VAR_10, "normal", 6)) { VAR_11 = 0xffff; } else if (!strncmp(VAR_10, "ext", 3)) { VAR_11 = 0xfffe; } else if (!strncmp(VAR_10, "ask", 3)) { VAR_11 = 0xfffd; } else { VAR_11 = strtol(VAR_10, NULL, 0); } stw_p(header+0x1fa, VAR_11); } if (protocol >= 0x200) header[0x210] = 0xB0; if (protocol >= 0x201) { header[0x211] |= 0x80; stw_p(header+0x224, cmdline_addr-real_addr-0x200); } if (VAR_3) { if (protocol < 0x200) { fprintf(stderr, "qemu: linux kernel too old to load a ram disk\n"); exit(1); } fi = fopen(VAR_3, "rb"); if (!fi) { fprintf(stderr, "qemu: could not load initial ram disk '%s': %s\n", VAR_3, strerror(errno)); exit(1); } VAR_8 = get_file_size(fi); initrd_addr = (initrd_max-VAR_8) & ~4095; if (!fread_targphys_ok(initrd_addr, VAR_8, fi)) { fprintf(stderr, "qemu: read error on initial ram disk '%s': %s\n", VAR_3, strerror(errno)); exit(1); } fclose(fi); stl_p(header+0x218, initrd_addr); stl_p(header+0x21c, VAR_8); } cpu_physical_memory_write(real_addr, header, ARRAY_SIZE(header)); VAR_6 = header[0x1f1]; if (VAR_6 == 0) VAR_6 = 4; VAR_6 = (VAR_6+1)*512; VAR_7 -= (VAR_6 > ARRAY_SIZE(header)) ? VAR_6 : ARRAY_SIZE(header); if (VAR_6 < ARRAY_SIZE(header)) { cpu_physical_memory_write(prot_addr, header + VAR_6, ARRAY_SIZE(header) - VAR_6); prot_addr += (ARRAY_SIZE(header) - VAR_6); VAR_6 = ARRAY_SIZE(header); } if (!fread_targphys_ok(real_addr + ARRAY_SIZE(header), VAR_6 - ARRAY_SIZE(header), f) || !fread_targphys_ok(prot_addr, VAR_7, f)) { fprintf(stderr, "qemu: read error on kernel '%s'\n", VAR_2); exit(1); } fclose(f); real_seg = real_addr >> 4; seg[0] = seg[2] = seg[3] = seg[4] = seg[4] = real_seg; seg[1] = real_seg+0x20; memset(gpr, 0, sizeof gpr); gpr[4] = cmdline_addr-real_addr-16; option_rom_setup_reset(real_addr, VAR_6); option_rom_setup_reset(prot_addr, VAR_7); option_rom_setup_reset(cmdline_addr, VAR_9); if (VAR_3) option_rom_setup_reset(initrd_addr, VAR_8); generate_bootsect(VAR_1, gpr, seg, 0); }
[ "static void FUNC_0(void *VAR_0,\ntarget_phys_addr_t VAR_1,\nconst char *VAR_2,\nconst char *VAR_3,\nconst char *VAR_4,\ntarget_phys_addr_t VAR_5)\n{", "uint16_t protocol;", "uint32_t gpr[8];", "uint16_t seg[6];", "uint16_t real_seg;", "int VAR_6, VAR_7, VAR_8 = 0, VAR_9;", "uint32_t initrd_max;", "uint8_t header[8192];", "target_phys_addr_t real_addr, prot_addr, cmdline_addr, initrd_addr = 0;", "FILE *f, *fi;", "char *VAR_10;", "VAR_9 = (strlen(VAR_4)+16) & ~15;", "f = fopen(VAR_2, \"rb\");", "if (!f || !(VAR_7 = get_file_size(f)) ||\nfread(header, 1, MIN(ARRAY_SIZE(header), VAR_7), f) !=\nMIN(ARRAY_SIZE(header), VAR_7)) {", "fprintf(stderr, \"qemu: could not load kernel '%s': %s\\n\",\nVAR_2, strerror(errno));", "exit(1);", "}", "#if 0\nfprintf(stderr, \"header magic: %#x\\n\", ldl_p(header+0x202));", "#endif\nif (ldl_p(header+0x202) == 0x53726448)\nprotocol = lduw_p(header+0x206);", "else {", "if (load_multiboot(VAR_0, f, VAR_2,\nVAR_3, VAR_4, header))\nreturn;", "protocol = 0;", "}", "if (protocol < 0x200 || !(header[0x211] & 0x01)) {", "real_addr = 0x90000;", "cmdline_addr = 0x9a000 - VAR_9;", "prot_addr = 0x10000;", "} else if (protocol < 0x202) {", "real_addr = 0x90000;", "cmdline_addr = 0x9a000 - VAR_9;", "prot_addr = 0x100000;", "} else {", "real_addr = 0x10000;", "cmdline_addr = 0x20000;", "prot_addr = 0x100000;", "}", "#if 0\nfprintf(stderr,\n\"qemu: real_addr = 0x\" TARGET_FMT_plx \"\\n\"\n\"qemu: cmdline_addr = 0x\" TARGET_FMT_plx \"\\n\"\n\"qemu: prot_addr = 0x\" TARGET_FMT_plx \"\\n\",\nreal_addr,\ncmdline_addr,\nprot_addr);", "#endif\nif (protocol >= 0x203)\ninitrd_max = ldl_p(header+0x22c);", "else\ninitrd_max = 0x37ffffff;", "if (initrd_max >= VAR_5-ACPI_DATA_SIZE)\ninitrd_max = VAR_5-ACPI_DATA_SIZE-1;", "pstrcpy_targphys(cmdline_addr, 4096, VAR_4);", "if (protocol >= 0x202) {", "stl_p(header+0x228, cmdline_addr);", "} else {", "stw_p(header+0x20, 0xA33F);", "stw_p(header+0x22, cmdline_addr-real_addr);", "}", "VAR_10 = strstr(VAR_4, \"vga=\");", "if (VAR_10) {", "unsigned int VAR_11;", "VAR_10 += 4;", "if (!strncmp(VAR_10, \"normal\", 6)) {", "VAR_11 = 0xffff;", "} else if (!strncmp(VAR_10, \"ext\", 3)) {", "VAR_11 = 0xfffe;", "} else if (!strncmp(VAR_10, \"ask\", 3)) {", "VAR_11 = 0xfffd;", "} else {", "VAR_11 = strtol(VAR_10, NULL, 0);", "}", "stw_p(header+0x1fa, VAR_11);", "}", "if (protocol >= 0x200)\nheader[0x210] = 0xB0;", "if (protocol >= 0x201) {", "header[0x211] |= 0x80;", "stw_p(header+0x224, cmdline_addr-real_addr-0x200);", "}", "if (VAR_3) {", "if (protocol < 0x200) {", "fprintf(stderr, \"qemu: linux kernel too old to load a ram disk\\n\");", "exit(1);", "}", "fi = fopen(VAR_3, \"rb\");", "if (!fi) {", "fprintf(stderr, \"qemu: could not load initial ram disk '%s': %s\\n\",\nVAR_3, strerror(errno));", "exit(1);", "}", "VAR_8 = get_file_size(fi);", "initrd_addr = (initrd_max-VAR_8) & ~4095;", "if (!fread_targphys_ok(initrd_addr, VAR_8, fi)) {", "fprintf(stderr, \"qemu: read error on initial ram disk '%s': %s\\n\",\nVAR_3, strerror(errno));", "exit(1);", "}", "fclose(fi);", "stl_p(header+0x218, initrd_addr);", "stl_p(header+0x21c, VAR_8);", "}", "cpu_physical_memory_write(real_addr, header, ARRAY_SIZE(header));", "VAR_6 = header[0x1f1];", "if (VAR_6 == 0)\nVAR_6 = 4;", "VAR_6 = (VAR_6+1)*512;", "VAR_7 -= (VAR_6 > ARRAY_SIZE(header)) ? VAR_6 : ARRAY_SIZE(header);", "if (VAR_6 < ARRAY_SIZE(header)) {", "cpu_physical_memory_write(prot_addr, header + VAR_6, ARRAY_SIZE(header) - VAR_6);", "prot_addr += (ARRAY_SIZE(header) - VAR_6);", "VAR_6 = ARRAY_SIZE(header);", "}", "if (!fread_targphys_ok(real_addr + ARRAY_SIZE(header),\nVAR_6 - ARRAY_SIZE(header), f) ||\n!fread_targphys_ok(prot_addr, VAR_7, f)) {", "fprintf(stderr, \"qemu: read error on kernel '%s'\\n\",\nVAR_2);", "exit(1);", "}", "fclose(f);", "real_seg = real_addr >> 4;", "seg[0] = seg[2] = seg[3] = seg[4] = seg[4] = real_seg;", "seg[1] = real_seg+0x20;", "memset(gpr, 0, sizeof gpr);", "gpr[4] = cmdline_addr-real_addr-16;", "option_rom_setup_reset(real_addr, VAR_6);", "option_rom_setup_reset(prot_addr, VAR_7);", "option_rom_setup_reset(cmdline_addr, VAR_9);", "if (VAR_3)\noption_rom_setup_reset(initrd_addr, VAR_8);", "generate_bootsect(VAR_1, gpr, seg, 0);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 39 ], [ 45 ], [ 47, 49, 51 ], [ 53, 55 ], [ 57 ], [ 59 ], [ 65, 67 ], [ 69, 71, 73 ], [ 75 ], [ 81, 83, 85 ], [ 87 ], [ 89 ], [ 93 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 127, 129, 131, 133, 135, 137, 139, 141 ], [ 143, 149, 151 ], [ 153, 155 ], [ 159, 161 ], [ 167 ], [ 171 ], [ 173 ], [ 175 ], [ 177 ], [ 179 ], [ 181 ], [ 187 ], [ 189 ], [ 191 ], [ 195 ], [ 197 ], [ 199 ], [ 201 ], [ 203 ], [ 205 ], [ 207 ], [ 209 ], [ 211 ], [ 213 ], [ 215 ], [ 217 ], [ 229, 231 ], [ 237 ], [ 239 ], [ 241 ], [ 243 ], [ 249 ], [ 251 ], [ 253 ], [ 255 ], [ 257 ], [ 261 ], [ 263 ], [ 265, 267 ], [ 269 ], [ 271 ], [ 275 ], [ 277 ], [ 281 ], [ 283, 285 ], [ 287 ], [ 289 ], [ 291 ], [ 295 ], [ 297 ], [ 299 ], [ 305 ], [ 309 ], [ 311, 313 ], [ 317 ], [ 321 ], [ 327 ], [ 329 ], [ 331 ], [ 333 ], [ 335 ], [ 339, 341, 343 ], [ 345, 347 ], [ 349 ], [ 351 ], [ 353 ], [ 359 ], [ 361 ], [ 363 ], [ 365 ], [ 367 ], [ 371 ], [ 373 ], [ 375 ], [ 377, 379 ], [ 383 ], [ 385 ] ]
22,180
void qemu_boot_set(const char *boot_order, Error **errp) { Error *local_err = NULL; if (!boot_set_handler) { error_setg(errp, "no function defined to set boot device list for" " this architecture"); return; } validate_bootdevices(boot_order, &local_err); if (local_err) { error_propagate(errp, local_err); return; } if (boot_set_handler(boot_set_opaque, boot_order)) { error_setg(errp, "setting boot device list failed"); return; } }
false
qemu
ddcd55316fb2851e144e719171621ad2816487dc
void qemu_boot_set(const char *boot_order, Error **errp) { Error *local_err = NULL; if (!boot_set_handler) { error_setg(errp, "no function defined to set boot device list for" " this architecture"); return; } validate_bootdevices(boot_order, &local_err); if (local_err) { error_propagate(errp, local_err); return; } if (boot_set_handler(boot_set_opaque, boot_order)) { error_setg(errp, "setting boot device list failed"); return; } }
{ "code": [], "line_no": [] }
void FUNC_0(const char *VAR_0, Error **VAR_1) { Error *local_err = NULL; if (!boot_set_handler) { error_setg(VAR_1, "no function defined to set boot device list for" " this architecture"); return; } validate_bootdevices(VAR_0, &local_err); if (local_err) { error_propagate(VAR_1, local_err); return; } if (boot_set_handler(boot_set_opaque, VAR_0)) { error_setg(VAR_1, "setting boot device list failed"); return; } }
[ "void FUNC_0(const char *VAR_0, Error **VAR_1)\n{", "Error *local_err = NULL;", "if (!boot_set_handler) {", "error_setg(VAR_1, \"no function defined to set boot device list for\"\n\" this architecture\");", "return;", "}", "validate_bootdevices(VAR_0, &local_err);", "if (local_err) {", "error_propagate(VAR_1, local_err);", "return;", "}", "if (boot_set_handler(boot_set_opaque, VAR_0)) {", "error_setg(VAR_1, \"setting boot device list failed\");", "return;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11, 13 ], [ 15 ], [ 17 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ] ]
22,181
START_TEST(qdict_get_test) { QInt *qi; QObject *obj; const int value = -42; const char *key = "test"; qdict_put(tests_dict, key, qint_from_int(value)); obj = qdict_get(tests_dict, key); fail_unless(obj != NULL); qi = qobject_to_qint(obj); fail_unless(qint_get_int(qi) == value); }
false
qemu
ac531cb6e542b1e61d668604adf9dc5306a948c0
START_TEST(qdict_get_test) { QInt *qi; QObject *obj; const int value = -42; const char *key = "test"; qdict_put(tests_dict, key, qint_from_int(value)); obj = qdict_get(tests_dict, key); fail_unless(obj != NULL); qi = qobject_to_qint(obj); fail_unless(qint_get_int(qi) == value); }
{ "code": [], "line_no": [] }
FUNC_0(VAR_0) { QInt *qi; QObject *obj; const int VAR_1 = -42; const char *VAR_2 = "test"; qdict_put(tests_dict, VAR_2, qint_from_int(VAR_1)); obj = qdict_get(tests_dict, VAR_2); fail_unless(obj != NULL); qi = qobject_to_qint(obj); fail_unless(qint_get_int(qi) == VAR_1); }
[ "FUNC_0(VAR_0)\n{", "QInt *qi;", "QObject *obj;", "const int VAR_1 = -42;", "const char *VAR_2 = \"test\";", "qdict_put(tests_dict, VAR_2, qint_from_int(VAR_1));", "obj = qdict_get(tests_dict, VAR_2);", "fail_unless(obj != NULL);", "qi = qobject_to_qint(obj);", "fail_unless(qint_get_int(qi) == VAR_1);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 19 ], [ 21 ], [ 25 ], [ 27 ], [ 29 ] ]
22,182
static void rv40_h_loop_filter(uint8_t *src, int stride, int dmode, int lim_q1, int lim_p1, int alpha, int beta, int beta2, int chroma, int edge){ rv40_adaptive_loop_filter(src, stride, 1, dmode, lim_q1, lim_p1, alpha, beta, beta2, chroma, edge); }
false
FFmpeg
d8edf1b515ae9fbcea2103305241d130c16e1003
static void rv40_h_loop_filter(uint8_t *src, int stride, int dmode, int lim_q1, int lim_p1, int alpha, int beta, int beta2, int chroma, int edge){ rv40_adaptive_loop_filter(src, stride, 1, dmode, lim_q1, lim_p1, alpha, beta, beta2, chroma, edge); }
{ "code": [], "line_no": [] }
static void FUNC_0(uint8_t *VAR_0, int VAR_1, int VAR_2, int VAR_3, int VAR_4, int VAR_5, int VAR_6, int VAR_7, int VAR_8, int VAR_9){ rv40_adaptive_loop_filter(VAR_0, VAR_1, 1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9); }
[ "static void FUNC_0(uint8_t *VAR_0, int VAR_1, int VAR_2,\nint VAR_3, int VAR_4,\nint VAR_5, int VAR_6, int VAR_7, int VAR_8, int VAR_9){", "rv40_adaptive_loop_filter(VAR_0, VAR_1, 1, VAR_2, VAR_3, VAR_4,\nVAR_5, VAR_6, VAR_7, VAR_8, VAR_9);", "}" ]
[ 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7, 9 ], [ 11 ] ]
22,183
static int qio_dns_resolver_lookup_sync_nop(QIODNSResolver *resolver, SocketAddressLegacy *addr, size_t *naddrs, SocketAddressLegacy ***addrs, Error **errp) { *naddrs = 1; *addrs = g_new0(SocketAddressLegacy *, 1); (*addrs)[0] = QAPI_CLONE(SocketAddressLegacy, addr); return 0; }
false
qemu
bd269ebc82fbaa5fe7ce5bc7c1770ac8acecd884
static int qio_dns_resolver_lookup_sync_nop(QIODNSResolver *resolver, SocketAddressLegacy *addr, size_t *naddrs, SocketAddressLegacy ***addrs, Error **errp) { *naddrs = 1; *addrs = g_new0(SocketAddressLegacy *, 1); (*addrs)[0] = QAPI_CLONE(SocketAddressLegacy, addr); return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(QIODNSResolver *VAR_0, SocketAddressLegacy *VAR_1, size_t *VAR_2, SocketAddressLegacy ***VAR_3, Error **VAR_4) { *VAR_2 = 1; *VAR_3 = g_new0(SocketAddressLegacy *, 1); (*VAR_3)[0] = QAPI_CLONE(SocketAddressLegacy, VAR_1); return 0; }
[ "static int FUNC_0(QIODNSResolver *VAR_0,\nSocketAddressLegacy *VAR_1,\nsize_t *VAR_2,\nSocketAddressLegacy ***VAR_3,\nError **VAR_4)\n{", "*VAR_2 = 1;", "*VAR_3 = g_new0(SocketAddressLegacy *, 1);", "(*VAR_3)[0] = QAPI_CLONE(SocketAddressLegacy, VAR_1);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9, 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 23 ] ]
22,185
static uint64_t ehci_opreg_read(void *ptr, hwaddr addr, unsigned size) { EHCIState *s = ptr; uint32_t val; val = s->opreg[addr >> 2]; trace_usb_ehci_opreg_read(addr + s->opregbase, addr2str(addr), val); return val; }
false
qemu
9359a58b122187964d7465d48165680eadbf69d3
static uint64_t ehci_opreg_read(void *ptr, hwaddr addr, unsigned size) { EHCIState *s = ptr; uint32_t val; val = s->opreg[addr >> 2]; trace_usb_ehci_opreg_read(addr + s->opregbase, addr2str(addr), val); return val; }
{ "code": [], "line_no": [] }
static uint64_t FUNC_0(void *ptr, hwaddr addr, unsigned size) { EHCIState *s = ptr; uint32_t val; val = s->opreg[addr >> 2]; trace_usb_ehci_opreg_read(addr + s->opregbase, addr2str(addr), val); return val; }
[ "static uint64_t FUNC_0(void *ptr, hwaddr addr,\nunsigned size)\n{", "EHCIState *s = ptr;", "uint32_t val;", "val = s->opreg[addr >> 2];", "trace_usb_ehci_opreg_read(addr + s->opregbase, addr2str(addr), val);", "return val;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ] ]
22,186
static void qemu_fflush(QEMUFile *f) { int ret = 0; if (!f->ops->put_buffer) { return; } if (f->is_write && f->buf_index > 0) { ret = f->ops->put_buffer(f->opaque, f->buf, f->buf_offset, f->buf_index); if (ret >= 0) { f->buf_offset += f->buf_index; } f->buf_index = 0; } if (ret < 0) { qemu_file_set_error(f, ret); } }
false
qemu
4eb938102b3d533e142de23e255e46da1326fc5a
static void qemu_fflush(QEMUFile *f) { int ret = 0; if (!f->ops->put_buffer) { return; } if (f->is_write && f->buf_index > 0) { ret = f->ops->put_buffer(f->opaque, f->buf, f->buf_offset, f->buf_index); if (ret >= 0) { f->buf_offset += f->buf_index; } f->buf_index = 0; } if (ret < 0) { qemu_file_set_error(f, ret); } }
{ "code": [], "line_no": [] }
static void FUNC_0(QEMUFile *VAR_0) { int VAR_1 = 0; if (!VAR_0->ops->put_buffer) { return; } if (VAR_0->is_write && VAR_0->buf_index > 0) { VAR_1 = VAR_0->ops->put_buffer(VAR_0->opaque, VAR_0->buf, VAR_0->buf_offset, VAR_0->buf_index); if (VAR_1 >= 0) { VAR_0->buf_offset += VAR_0->buf_index; } VAR_0->buf_index = 0; } if (VAR_1 < 0) { qemu_file_set_error(VAR_0, VAR_1); } }
[ "static void FUNC_0(QEMUFile *VAR_0)\n{", "int VAR_1 = 0;", "if (!VAR_0->ops->put_buffer) {", "return;", "}", "if (VAR_0->is_write && VAR_0->buf_index > 0) {", "VAR_1 = VAR_0->ops->put_buffer(VAR_0->opaque, VAR_0->buf, VAR_0->buf_offset, VAR_0->buf_index);", "if (VAR_1 >= 0) {", "VAR_0->buf_offset += VAR_0->buf_index;", "}", "VAR_0->buf_index = 0;", "}", "if (VAR_1 < 0) {", "qemu_file_set_error(VAR_0, VAR_1);", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ] ]
22,188
static void omap_mpui_write(void *opaque, target_phys_addr_t addr, uint64_t value, unsigned size) { struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque; if (size != 4) { return omap_badwidth_write32(opaque, addr, value); } switch (addr) { case 0x00: /* CTRL */ s->mpui_ctrl = value & 0x007fffff; break; case 0x04: /* DEBUG_ADDR */ case 0x08: /* DEBUG_DATA */ case 0x0c: /* DEBUG_FLAG */ case 0x10: /* STATUS */ /* Not in OMAP310 */ case 0x14: /* DSP_STATUS */ OMAP_RO_REG(addr); case 0x18: /* DSP_BOOT_CONFIG */ case 0x1c: /* DSP_MPUI_CONFIG */ break; default: OMAP_BAD_REG(addr); } }
false
qemu
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
static void omap_mpui_write(void *opaque, target_phys_addr_t addr, uint64_t value, unsigned size) { struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque; if (size != 4) { return omap_badwidth_write32(opaque, addr, value); } switch (addr) { case 0x00: s->mpui_ctrl = value & 0x007fffff; break; case 0x04: case 0x08: case 0x0c: case 0x10: case 0x14: OMAP_RO_REG(addr); case 0x18: case 0x1c: break; default: OMAP_BAD_REG(addr); } }
{ "code": [], "line_no": [] }
static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1, uint64_t VAR_2, unsigned VAR_3) { struct omap_mpu_state_s *VAR_4 = (struct omap_mpu_state_s *) VAR_0; if (VAR_3 != 4) { return omap_badwidth_write32(VAR_0, VAR_1, VAR_2); } switch (VAR_1) { case 0x00: VAR_4->mpui_ctrl = VAR_2 & 0x007fffff; break; case 0x04: case 0x08: case 0x0c: case 0x10: case 0x14: OMAP_RO_REG(VAR_1); case 0x18: case 0x1c: break; default: OMAP_BAD_REG(VAR_1); } }
[ "static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{", "struct omap_mpu_state_s *VAR_4 = (struct omap_mpu_state_s *) VAR_0;", "if (VAR_3 != 4) {", "return omap_badwidth_write32(VAR_0, VAR_1, VAR_2);", "}", "switch (VAR_1) {", "case 0x00:\nVAR_4->mpui_ctrl = VAR_2 & 0x007fffff;", "break;", "case 0x04:\ncase 0x08:\ncase 0x0c:\ncase 0x10:\ncase 0x14:\nOMAP_RO_REG(VAR_1);", "case 0x18:\ncase 0x1c:\nbreak;", "default:\nOMAP_BAD_REG(VAR_1);", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21, 23 ], [ 25 ], [ 29, 31, 33, 35, 39, 41 ], [ 43, 45, 47 ], [ 51, 53 ], [ 55 ], [ 57 ] ]
22,191
static void sdl_mouse_mode_change(Notifier *notify, void *data) { if (kbd_mouse_is_absolute()) { if (!absolute_enabled) { sdl_hide_cursor(); if (gui_grab) { sdl_grab_end(); } absolute_enabled = 1; } } else if (absolute_enabled) { sdl_show_cursor(); absolute_enabled = 0; } }
false
qemu
35b0f237205dc6a5c9aa3eae14f19ef4d37dafcd
static void sdl_mouse_mode_change(Notifier *notify, void *data) { if (kbd_mouse_is_absolute()) { if (!absolute_enabled) { sdl_hide_cursor(); if (gui_grab) { sdl_grab_end(); } absolute_enabled = 1; } } else if (absolute_enabled) { sdl_show_cursor(); absolute_enabled = 0; } }
{ "code": [], "line_no": [] }
static void FUNC_0(Notifier *VAR_0, void *VAR_1) { if (kbd_mouse_is_absolute()) { if (!absolute_enabled) { sdl_hide_cursor(); if (gui_grab) { sdl_grab_end(); } absolute_enabled = 1; } } else if (absolute_enabled) { sdl_show_cursor(); absolute_enabled = 0; } }
[ "static void FUNC_0(Notifier *VAR_0, void *VAR_1)\n{", "if (kbd_mouse_is_absolute()) {", "if (!absolute_enabled) {", "sdl_hide_cursor();", "if (gui_grab) {", "sdl_grab_end();", "}", "absolute_enabled = 1;", "}", "} else if (absolute_enabled) {", "sdl_show_cursor();", "absolute_enabled = 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 ] ]
22,193
static int mono_decode(COOKContext *q, COOKSubpacket *p, float *mlt_buffer) { int category_index[128]; int quant_index_table[102]; int category[128]; int ret; memset(&category, 0, sizeof(category)); memset(&category_index, 0, sizeof(category_index)); if ((ret = decode_envelope(q, p, quant_index_table)) < 0) return ret; q->num_vectors = get_bits(&q->gb, p->log2_numvector_size); categorize(q, p, quant_index_table, category, category_index); expand_category(q, category, category_index); decode_vectors(q, p, category, quant_index_table, mlt_buffer); return 0; }
false
FFmpeg
d629f3edaa39b48ac92ac5e5ae8440e35805b792
static int mono_decode(COOKContext *q, COOKSubpacket *p, float *mlt_buffer) { int category_index[128]; int quant_index_table[102]; int category[128]; int ret; memset(&category, 0, sizeof(category)); memset(&category_index, 0, sizeof(category_index)); if ((ret = decode_envelope(q, p, quant_index_table)) < 0) return ret; q->num_vectors = get_bits(&q->gb, p->log2_numvector_size); categorize(q, p, quant_index_table, category, category_index); expand_category(q, category, category_index); decode_vectors(q, p, category, quant_index_table, mlt_buffer); return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(COOKContext *VAR_0, COOKSubpacket *VAR_1, float *VAR_2) { int VAR_3[128]; int VAR_4[102]; int VAR_5[128]; int VAR_6; memset(&VAR_5, 0, sizeof(VAR_5)); memset(&VAR_3, 0, sizeof(VAR_3)); if ((VAR_6 = decode_envelope(VAR_0, VAR_1, VAR_4)) < 0) return VAR_6; VAR_0->num_vectors = get_bits(&VAR_0->gb, VAR_1->log2_numvector_size); categorize(VAR_0, VAR_1, VAR_4, VAR_5, VAR_3); expand_category(VAR_0, VAR_5, VAR_3); decode_vectors(VAR_0, VAR_1, VAR_5, VAR_4, VAR_2); return 0; }
[ "static int FUNC_0(COOKContext *VAR_0, COOKSubpacket *VAR_1, float *VAR_2)\n{", "int VAR_3[128];", "int VAR_4[102];", "int VAR_5[128];", "int VAR_6;", "memset(&VAR_5, 0, sizeof(VAR_5));", "memset(&VAR_3, 0, sizeof(VAR_3));", "if ((VAR_6 = decode_envelope(VAR_0, VAR_1, VAR_4)) < 0)\nreturn VAR_6;", "VAR_0->num_vectors = get_bits(&VAR_0->gb, VAR_1->log2_numvector_size);", "categorize(VAR_0, VAR_1, VAR_4, VAR_5, VAR_3);", "expand_category(VAR_0, VAR_5, VAR_3);", "decode_vectors(VAR_0, VAR_1, VAR_5, VAR_4, VAR_2);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ], [ 21, 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 35 ], [ 37 ] ]
22,194
static void omap_clkm_write(void *opaque, target_phys_addr_t addr, uint64_t value, unsigned size) { struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque; uint16_t diff; omap_clk clk; static const char *clkschemename[8] = { "fully synchronous", "fully asynchronous", "synchronous scalable", "mix mode 1", "mix mode 2", "bypass mode", "mix mode 3", "mix mode 4", }; if (size != 2) { return omap_badwidth_write16(opaque, addr, value); } switch (addr) { case 0x00: /* ARM_CKCTL */ diff = s->clkm.arm_ckctl ^ value; s->clkm.arm_ckctl = value & 0x7fff; omap_clkm_ckctl_update(s, diff, value); return; case 0x04: /* ARM_IDLECT1 */ diff = s->clkm.arm_idlect1 ^ value; s->clkm.arm_idlect1 = value & 0x0fff; omap_clkm_idlect1_update(s, diff, value); return; case 0x08: /* ARM_IDLECT2 */ diff = s->clkm.arm_idlect2 ^ value; s->clkm.arm_idlect2 = value & 0x07ff; omap_clkm_idlect2_update(s, diff, value); return; case 0x0c: /* ARM_EWUPCT */ s->clkm.arm_ewupct = value & 0x003f; return; case 0x10: /* ARM_RSTCT1 */ diff = s->clkm.arm_rstct1 ^ value; s->clkm.arm_rstct1 = value & 0x0007; if (value & 9) { qemu_system_reset_request(); s->clkm.cold_start = 0xa; } if (diff & ~value & 4) { /* DSP_RST */ omap_mpui_reset(s); omap_tipb_bridge_reset(s->private_tipb); omap_tipb_bridge_reset(s->public_tipb); } if (diff & 2) { /* DSP_EN */ clk = omap_findclk(s, "dsp_ck"); omap_clk_canidle(clk, (~value >> 1) & 1); } return; case 0x14: /* ARM_RSTCT2 */ s->clkm.arm_rstct2 = value & 0x0001; return; case 0x18: /* ARM_SYSST */ if ((s->clkm.clocking_scheme ^ (value >> 11)) & 7) { s->clkm.clocking_scheme = (value >> 11) & 7; printf("%s: clocking scheme set to %s\n", __FUNCTION__, clkschemename[s->clkm.clocking_scheme]); } s->clkm.cold_start &= value & 0x3f; return; case 0x1c: /* ARM_CKOUT1 */ diff = s->clkm.arm_ckout1 ^ value; s->clkm.arm_ckout1 = value & 0x003f; omap_clkm_ckout1_update(s, diff, value); return; case 0x20: /* ARM_CKOUT2 */ default: OMAP_BAD_REG(addr); } }
false
qemu
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
static void omap_clkm_write(void *opaque, target_phys_addr_t addr, uint64_t value, unsigned size) { struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque; uint16_t diff; omap_clk clk; static const char *clkschemename[8] = { "fully synchronous", "fully asynchronous", "synchronous scalable", "mix mode 1", "mix mode 2", "bypass mode", "mix mode 3", "mix mode 4", }; if (size != 2) { return omap_badwidth_write16(opaque, addr, value); } switch (addr) { case 0x00: diff = s->clkm.arm_ckctl ^ value; s->clkm.arm_ckctl = value & 0x7fff; omap_clkm_ckctl_update(s, diff, value); return; case 0x04: diff = s->clkm.arm_idlect1 ^ value; s->clkm.arm_idlect1 = value & 0x0fff; omap_clkm_idlect1_update(s, diff, value); return; case 0x08: diff = s->clkm.arm_idlect2 ^ value; s->clkm.arm_idlect2 = value & 0x07ff; omap_clkm_idlect2_update(s, diff, value); return; case 0x0c: s->clkm.arm_ewupct = value & 0x003f; return; case 0x10: diff = s->clkm.arm_rstct1 ^ value; s->clkm.arm_rstct1 = value & 0x0007; if (value & 9) { qemu_system_reset_request(); s->clkm.cold_start = 0xa; } if (diff & ~value & 4) { omap_mpui_reset(s); omap_tipb_bridge_reset(s->private_tipb); omap_tipb_bridge_reset(s->public_tipb); } if (diff & 2) { clk = omap_findclk(s, "dsp_ck"); omap_clk_canidle(clk, (~value >> 1) & 1); } return; case 0x14: s->clkm.arm_rstct2 = value & 0x0001; return; case 0x18: if ((s->clkm.clocking_scheme ^ (value >> 11)) & 7) { s->clkm.clocking_scheme = (value >> 11) & 7; printf("%s: clocking scheme set to %s\n", __FUNCTION__, clkschemename[s->clkm.clocking_scheme]); } s->clkm.cold_start &= value & 0x3f; return; case 0x1c: diff = s->clkm.arm_ckout1 ^ value; s->clkm.arm_ckout1 = value & 0x003f; omap_clkm_ckout1_update(s, diff, value); return; case 0x20: default: OMAP_BAD_REG(addr); } }
{ "code": [], "line_no": [] }
static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1, uint64_t VAR_2, unsigned VAR_3) { struct omap_mpu_state_s *VAR_4 = (struct omap_mpu_state_s *) VAR_0; uint16_t diff; omap_clk clk; static const char *VAR_5[8] = { "fully synchronous", "fully asynchronous", "synchronous scalable", "mix mode 1", "mix mode 2", "bypass mode", "mix mode 3", "mix mode 4", }; if (VAR_3 != 2) { return omap_badwidth_write16(VAR_0, VAR_1, VAR_2); } switch (VAR_1) { case 0x00: diff = VAR_4->clkm.arm_ckctl ^ VAR_2; VAR_4->clkm.arm_ckctl = VAR_2 & 0x7fff; omap_clkm_ckctl_update(VAR_4, diff, VAR_2); return; case 0x04: diff = VAR_4->clkm.arm_idlect1 ^ VAR_2; VAR_4->clkm.arm_idlect1 = VAR_2 & 0x0fff; omap_clkm_idlect1_update(VAR_4, diff, VAR_2); return; case 0x08: diff = VAR_4->clkm.arm_idlect2 ^ VAR_2; VAR_4->clkm.arm_idlect2 = VAR_2 & 0x07ff; omap_clkm_idlect2_update(VAR_4, diff, VAR_2); return; case 0x0c: VAR_4->clkm.arm_ewupct = VAR_2 & 0x003f; return; case 0x10: diff = VAR_4->clkm.arm_rstct1 ^ VAR_2; VAR_4->clkm.arm_rstct1 = VAR_2 & 0x0007; if (VAR_2 & 9) { qemu_system_reset_request(); VAR_4->clkm.cold_start = 0xa; } if (diff & ~VAR_2 & 4) { omap_mpui_reset(VAR_4); omap_tipb_bridge_reset(VAR_4->private_tipb); omap_tipb_bridge_reset(VAR_4->public_tipb); } if (diff & 2) { clk = omap_findclk(VAR_4, "dsp_ck"); omap_clk_canidle(clk, (~VAR_2 >> 1) & 1); } return; case 0x14: VAR_4->clkm.arm_rstct2 = VAR_2 & 0x0001; return; case 0x18: if ((VAR_4->clkm.clocking_scheme ^ (VAR_2 >> 11)) & 7) { VAR_4->clkm.clocking_scheme = (VAR_2 >> 11) & 7; printf("%VAR_4: clocking scheme set to %VAR_4\n", __FUNCTION__, VAR_5[VAR_4->clkm.clocking_scheme]); } VAR_4->clkm.cold_start &= VAR_2 & 0x3f; return; case 0x1c: diff = VAR_4->clkm.arm_ckout1 ^ VAR_2; VAR_4->clkm.arm_ckout1 = VAR_2 & 0x003f; omap_clkm_ckout1_update(VAR_4, diff, VAR_2); return; case 0x20: default: OMAP_BAD_REG(VAR_1); } }
[ "static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{", "struct omap_mpu_state_s *VAR_4 = (struct omap_mpu_state_s *) VAR_0;", "uint16_t diff;", "omap_clk clk;", "static const char *VAR_5[8] = {", "\"fully synchronous\", \"fully asynchronous\", \"synchronous scalable\",\n\"mix mode 1\", \"mix mode 2\", \"bypass mode\", \"mix mode 3\", \"mix mode 4\",\n};", "if (VAR_3 != 2) {", "return omap_badwidth_write16(VAR_0, VAR_1, VAR_2);", "}", "switch (VAR_1) {", "case 0x00:\ndiff = VAR_4->clkm.arm_ckctl ^ VAR_2;", "VAR_4->clkm.arm_ckctl = VAR_2 & 0x7fff;", "omap_clkm_ckctl_update(VAR_4, diff, VAR_2);", "return;", "case 0x04:\ndiff = VAR_4->clkm.arm_idlect1 ^ VAR_2;", "VAR_4->clkm.arm_idlect1 = VAR_2 & 0x0fff;", "omap_clkm_idlect1_update(VAR_4, diff, VAR_2);", "return;", "case 0x08:\ndiff = VAR_4->clkm.arm_idlect2 ^ VAR_2;", "VAR_4->clkm.arm_idlect2 = VAR_2 & 0x07ff;", "omap_clkm_idlect2_update(VAR_4, diff, VAR_2);", "return;", "case 0x0c:\nVAR_4->clkm.arm_ewupct = VAR_2 & 0x003f;", "return;", "case 0x10:\ndiff = VAR_4->clkm.arm_rstct1 ^ VAR_2;", "VAR_4->clkm.arm_rstct1 = VAR_2 & 0x0007;", "if (VAR_2 & 9) {", "qemu_system_reset_request();", "VAR_4->clkm.cold_start = 0xa;", "}", "if (diff & ~VAR_2 & 4) {", "omap_mpui_reset(VAR_4);", "omap_tipb_bridge_reset(VAR_4->private_tipb);", "omap_tipb_bridge_reset(VAR_4->public_tipb);", "}", "if (diff & 2) {", "clk = omap_findclk(VAR_4, \"dsp_ck\");", "omap_clk_canidle(clk, (~VAR_2 >> 1) & 1);", "}", "return;", "case 0x14:\nVAR_4->clkm.arm_rstct2 = VAR_2 & 0x0001;", "return;", "case 0x18:\nif ((VAR_4->clkm.clocking_scheme ^ (VAR_2 >> 11)) & 7) {", "VAR_4->clkm.clocking_scheme = (VAR_2 >> 11) & 7;", "printf(\"%VAR_4: clocking scheme set to %VAR_4\\n\", __FUNCTION__,\nVAR_5[VAR_4->clkm.clocking_scheme]);", "}", "VAR_4->clkm.cold_start &= VAR_2 & 0x3f;", "return;", "case 0x1c:\ndiff = VAR_4->clkm.arm_ckout1 ^ VAR_2;", "VAR_4->clkm.arm_ckout1 = VAR_2 & 0x003f;", "omap_clkm_ckout1_update(VAR_4, diff, VAR_2);", "return;", "case 0x20:\ndefault:\nOMAP_BAD_REG(VAR_1);", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15, 17, 19 ], [ 23 ], [ 25 ], [ 27 ], [ 31 ], [ 33, 35 ], [ 37 ], [ 39 ], [ 41 ], [ 45, 47 ], [ 49 ], [ 51 ], [ 53 ], [ 57, 59 ], [ 61 ], [ 63 ], [ 65 ], [ 69, 71 ], [ 73 ], [ 77, 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 113, 115 ], [ 117 ], [ 121, 123 ], [ 125 ], [ 127, 129 ], [ 131 ], [ 133 ], [ 135 ], [ 139, 141 ], [ 143 ], [ 145 ], [ 147 ], [ 151, 153, 155 ], [ 157 ], [ 159 ] ]
22,195
static int cuvid_test_dummy_decoder(AVCodecContext *avctx, const CUVIDPARSERPARAMS *cuparseinfo, int probed_width, int probed_height) { CuvidContext *ctx = avctx->priv_data; CUVIDDECODECREATEINFO cuinfo; CUvideodecoder cudec = 0; int ret = 0; memset(&cuinfo, 0, sizeof(cuinfo)); cuinfo.CodecType = cuparseinfo->CodecType; cuinfo.ChromaFormat = cudaVideoChromaFormat_420; cuinfo.OutputFormat = cudaVideoSurfaceFormat_NV12; cuinfo.ulWidth = probed_width; cuinfo.ulHeight = probed_height; cuinfo.ulTargetWidth = cuinfo.ulWidth; cuinfo.ulTargetHeight = cuinfo.ulHeight; cuinfo.target_rect.left = 0; cuinfo.target_rect.top = 0; cuinfo.target_rect.right = cuinfo.ulWidth; cuinfo.target_rect.bottom = cuinfo.ulHeight; cuinfo.ulNumDecodeSurfaces = ctx->nb_surfaces; cuinfo.ulNumOutputSurfaces = 1; cuinfo.ulCreationFlags = cudaVideoCreate_PreferCUVID; cuinfo.bitDepthMinus8 = 0; cuinfo.DeinterlaceMode = cudaVideoDeinterlaceMode_Weave; ret = CHECK_CU(ctx->cvdl->cuvidCreateDecoder(&cudec, &cuinfo)); if (ret < 0) return ret; ret = CHECK_CU(ctx->cvdl->cuvidDestroyDecoder(cudec)); if (ret < 0) return ret; return 0; }
false
FFmpeg
fea471347218be0b8d1313b8f14ea9512e555d76
static int cuvid_test_dummy_decoder(AVCodecContext *avctx, const CUVIDPARSERPARAMS *cuparseinfo, int probed_width, int probed_height) { CuvidContext *ctx = avctx->priv_data; CUVIDDECODECREATEINFO cuinfo; CUvideodecoder cudec = 0; int ret = 0; memset(&cuinfo, 0, sizeof(cuinfo)); cuinfo.CodecType = cuparseinfo->CodecType; cuinfo.ChromaFormat = cudaVideoChromaFormat_420; cuinfo.OutputFormat = cudaVideoSurfaceFormat_NV12; cuinfo.ulWidth = probed_width; cuinfo.ulHeight = probed_height; cuinfo.ulTargetWidth = cuinfo.ulWidth; cuinfo.ulTargetHeight = cuinfo.ulHeight; cuinfo.target_rect.left = 0; cuinfo.target_rect.top = 0; cuinfo.target_rect.right = cuinfo.ulWidth; cuinfo.target_rect.bottom = cuinfo.ulHeight; cuinfo.ulNumDecodeSurfaces = ctx->nb_surfaces; cuinfo.ulNumOutputSurfaces = 1; cuinfo.ulCreationFlags = cudaVideoCreate_PreferCUVID; cuinfo.bitDepthMinus8 = 0; cuinfo.DeinterlaceMode = cudaVideoDeinterlaceMode_Weave; ret = CHECK_CU(ctx->cvdl->cuvidCreateDecoder(&cudec, &cuinfo)); if (ret < 0) return ret; ret = CHECK_CU(ctx->cvdl->cuvidDestroyDecoder(cudec)); if (ret < 0) return ret; return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(AVCodecContext *VAR_0, const CUVIDPARSERPARAMS *VAR_1, int VAR_2, int VAR_3) { CuvidContext *ctx = VAR_0->priv_data; CUVIDDECODECREATEINFO cuinfo; CUvideodecoder cudec = 0; int VAR_4 = 0; memset(&cuinfo, 0, sizeof(cuinfo)); cuinfo.CodecType = VAR_1->CodecType; cuinfo.ChromaFormat = cudaVideoChromaFormat_420; cuinfo.OutputFormat = cudaVideoSurfaceFormat_NV12; cuinfo.ulWidth = VAR_2; cuinfo.ulHeight = VAR_3; cuinfo.ulTargetWidth = cuinfo.ulWidth; cuinfo.ulTargetHeight = cuinfo.ulHeight; cuinfo.target_rect.left = 0; cuinfo.target_rect.top = 0; cuinfo.target_rect.right = cuinfo.ulWidth; cuinfo.target_rect.bottom = cuinfo.ulHeight; cuinfo.ulNumDecodeSurfaces = ctx->nb_surfaces; cuinfo.ulNumOutputSurfaces = 1; cuinfo.ulCreationFlags = cudaVideoCreate_PreferCUVID; cuinfo.bitDepthMinus8 = 0; cuinfo.DeinterlaceMode = cudaVideoDeinterlaceMode_Weave; VAR_4 = CHECK_CU(ctx->cvdl->cuvidCreateDecoder(&cudec, &cuinfo)); if (VAR_4 < 0) return VAR_4; VAR_4 = CHECK_CU(ctx->cvdl->cuvidDestroyDecoder(cudec)); if (VAR_4 < 0) return VAR_4; return 0; }
[ "static int FUNC_0(AVCodecContext *VAR_0,\nconst CUVIDPARSERPARAMS *VAR_1,\nint VAR_2,\nint VAR_3)\n{", "CuvidContext *ctx = VAR_0->priv_data;", "CUVIDDECODECREATEINFO cuinfo;", "CUvideodecoder cudec = 0;", "int VAR_4 = 0;", "memset(&cuinfo, 0, sizeof(cuinfo));", "cuinfo.CodecType = VAR_1->CodecType;", "cuinfo.ChromaFormat = cudaVideoChromaFormat_420;", "cuinfo.OutputFormat = cudaVideoSurfaceFormat_NV12;", "cuinfo.ulWidth = VAR_2;", "cuinfo.ulHeight = VAR_3;", "cuinfo.ulTargetWidth = cuinfo.ulWidth;", "cuinfo.ulTargetHeight = cuinfo.ulHeight;", "cuinfo.target_rect.left = 0;", "cuinfo.target_rect.top = 0;", "cuinfo.target_rect.right = cuinfo.ulWidth;", "cuinfo.target_rect.bottom = cuinfo.ulHeight;", "cuinfo.ulNumDecodeSurfaces = ctx->nb_surfaces;", "cuinfo.ulNumOutputSurfaces = 1;", "cuinfo.ulCreationFlags = cudaVideoCreate_PreferCUVID;", "cuinfo.bitDepthMinus8 = 0;", "cuinfo.DeinterlaceMode = cudaVideoDeinterlaceMode_Weave;", "VAR_4 = CHECK_CU(ctx->cvdl->cuvidCreateDecoder(&cudec, &cuinfo));", "if (VAR_4 < 0)\nreturn VAR_4;", "VAR_4 = CHECK_CU(ctx->cvdl->cuvidDestroyDecoder(cudec));", "if (VAR_4 < 0)\nreturn VAR_4;", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 25 ], [ 27 ], [ 29 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 63 ], [ 67 ], [ 69, 71 ], [ 75 ], [ 77, 79 ], [ 83 ], [ 85 ] ]
22,196
static void vfio_intp_inject_pending_lockheld(VFIOINTp *intp) { trace_vfio_platform_intp_inject_pending_lockheld(intp->pin, event_notifier_get_fd(&intp->interrupt)); intp->state = VFIO_IRQ_ACTIVE; /* trigger the virtual IRQ */ qemu_set_irq(intp->qemuirq, 1); }
false
qemu
a22313deca720e038ebc5805cf451b3a685d29ce
static void vfio_intp_inject_pending_lockheld(VFIOINTp *intp) { trace_vfio_platform_intp_inject_pending_lockheld(intp->pin, event_notifier_get_fd(&intp->interrupt)); intp->state = VFIO_IRQ_ACTIVE; qemu_set_irq(intp->qemuirq, 1); }
{ "code": [], "line_no": [] }
static void FUNC_0(VFIOINTp *VAR_0) { trace_vfio_platform_intp_inject_pending_lockheld(VAR_0->pin, event_notifier_get_fd(&VAR_0->interrupt)); VAR_0->state = VFIO_IRQ_ACTIVE; qemu_set_irq(VAR_0->qemuirq, 1); }
[ "static void FUNC_0(VFIOINTp *VAR_0)\n{", "trace_vfio_platform_intp_inject_pending_lockheld(VAR_0->pin,\nevent_notifier_get_fd(&VAR_0->interrupt));", "VAR_0->state = VFIO_IRQ_ACTIVE;", "qemu_set_irq(VAR_0->qemuirq, 1);", "}" ]
[ 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5, 7 ], [ 11 ], [ 17 ], [ 19 ] ]
22,197
void qemu_spice_display_resize(SimpleSpiceDisplay *ssd) { dprint(1, "%s:\n", __FUNCTION__); pthread_mutex_lock(&ssd->lock); memset(&ssd->dirty, 0, sizeof(ssd->dirty)); qemu_pf_conv_put(ssd->conv); ssd->conv = NULL; pthread_mutex_unlock(&ssd->lock); qemu_spice_destroy_host_primary(ssd); qemu_spice_create_host_primary(ssd); pthread_mutex_lock(&ssd->lock); memset(&ssd->dirty, 0, sizeof(ssd->dirty)); ssd->notify++; pthread_mutex_unlock(&ssd->lock); }
false
qemu
7466bc49107fbd84336ba680f860d5eadd6def13
void qemu_spice_display_resize(SimpleSpiceDisplay *ssd) { dprint(1, "%s:\n", __FUNCTION__); pthread_mutex_lock(&ssd->lock); memset(&ssd->dirty, 0, sizeof(ssd->dirty)); qemu_pf_conv_put(ssd->conv); ssd->conv = NULL; pthread_mutex_unlock(&ssd->lock); qemu_spice_destroy_host_primary(ssd); qemu_spice_create_host_primary(ssd); pthread_mutex_lock(&ssd->lock); memset(&ssd->dirty, 0, sizeof(ssd->dirty)); ssd->notify++; pthread_mutex_unlock(&ssd->lock); }
{ "code": [], "line_no": [] }
void FUNC_0(SimpleSpiceDisplay *VAR_0) { dprint(1, "%s:\n", __FUNCTION__); pthread_mutex_lock(&VAR_0->lock); memset(&VAR_0->dirty, 0, sizeof(VAR_0->dirty)); qemu_pf_conv_put(VAR_0->conv); VAR_0->conv = NULL; pthread_mutex_unlock(&VAR_0->lock); qemu_spice_destroy_host_primary(VAR_0); qemu_spice_create_host_primary(VAR_0); pthread_mutex_lock(&VAR_0->lock); memset(&VAR_0->dirty, 0, sizeof(VAR_0->dirty)); VAR_0->notify++; pthread_mutex_unlock(&VAR_0->lock); }
[ "void FUNC_0(SimpleSpiceDisplay *VAR_0)\n{", "dprint(1, \"%s:\\n\", __FUNCTION__);", "pthread_mutex_lock(&VAR_0->lock);", "memset(&VAR_0->dirty, 0, sizeof(VAR_0->dirty));", "qemu_pf_conv_put(VAR_0->conv);", "VAR_0->conv = NULL;", "pthread_mutex_unlock(&VAR_0->lock);", "qemu_spice_destroy_host_primary(VAR_0);", "qemu_spice_create_host_primary(VAR_0);", "pthread_mutex_lock(&VAR_0->lock);", "memset(&VAR_0->dirty, 0, sizeof(VAR_0->dirty));", "VAR_0->notify++;", "pthread_mutex_unlock(&VAR_0->lock);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 23 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ] ]
22,198
void qemu_savevm_state_cancel(Monitor *mon, QEMUFile *f) { SaveStateEntry *se; QTAILQ_FOREACH(se, &savevm_handlers, entry) { if (se->save_live_state) { se->save_live_state(mon, f, -1, se->opaque); } } }
false
qemu
539de1246d355d3b8aa33fb7cde732352d8827c7
void qemu_savevm_state_cancel(Monitor *mon, QEMUFile *f) { SaveStateEntry *se; QTAILQ_FOREACH(se, &savevm_handlers, entry) { if (se->save_live_state) { se->save_live_state(mon, f, -1, se->opaque); } } }
{ "code": [], "line_no": [] }
void FUNC_0(Monitor *VAR_0, QEMUFile *VAR_1) { SaveStateEntry *se; QTAILQ_FOREACH(se, &savevm_handlers, entry) { if (se->save_live_state) { se->save_live_state(VAR_0, VAR_1, -1, se->opaque); } } }
[ "void FUNC_0(Monitor *VAR_0, QEMUFile *VAR_1)\n{", "SaveStateEntry *se;", "QTAILQ_FOREACH(se, &savevm_handlers, entry) {", "if (se->save_live_state) {", "se->save_live_state(VAR_0, VAR_1, -1, se->opaque);", "}", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ] ]
22,199
VLANState *qemu_find_vlan(int id, int allocate) { VLANState **pvlan, *vlan; for(vlan = first_vlan; vlan != NULL; vlan = vlan->next) { if (vlan->id == id) return vlan; } if (!allocate) { return NULL; } vlan = qemu_mallocz(sizeof(VLANState)); vlan->id = id; TAILQ_INIT(&vlan->send_queue); vlan->next = NULL; pvlan = &first_vlan; while (*pvlan != NULL) pvlan = &(*pvlan)->next; *pvlan = vlan; return vlan; }
false
qemu
72cf2d4f0e181d0d3a3122e04129c58a95da713e
VLANState *qemu_find_vlan(int id, int allocate) { VLANState **pvlan, *vlan; for(vlan = first_vlan; vlan != NULL; vlan = vlan->next) { if (vlan->id == id) return vlan; } if (!allocate) { return NULL; } vlan = qemu_mallocz(sizeof(VLANState)); vlan->id = id; TAILQ_INIT(&vlan->send_queue); vlan->next = NULL; pvlan = &first_vlan; while (*pvlan != NULL) pvlan = &(*pvlan)->next; *pvlan = vlan; return vlan; }
{ "code": [], "line_no": [] }
VLANState *FUNC_0(int id, int allocate) { VLANState **pvlan, *vlan; for(vlan = first_vlan; vlan != NULL; vlan = vlan->next) { if (vlan->id == id) return vlan; } if (!allocate) { return NULL; } vlan = qemu_mallocz(sizeof(VLANState)); vlan->id = id; TAILQ_INIT(&vlan->send_queue); vlan->next = NULL; pvlan = &first_vlan; while (*pvlan != NULL) pvlan = &(*pvlan)->next; *pvlan = vlan; return vlan; }
[ "VLANState *FUNC_0(int id, int allocate)\n{", "VLANState **pvlan, *vlan;", "for(vlan = first_vlan; vlan != NULL; vlan = vlan->next) {", "if (vlan->id == id)\nreturn vlan;", "}", "if (!allocate) {", "return NULL;", "}", "vlan = qemu_mallocz(sizeof(VLANState));", "vlan->id = id;", "TAILQ_INIT(&vlan->send_queue);", "vlan->next = NULL;", "pvlan = &first_vlan;", "while (*pvlan != NULL)\npvlan = &(*pvlan)->next;", "*pvlan = vlan;", "return vlan;", "}" ]
[ 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 ] ]
22,200
static int qcow2_amend_options(BlockDriverState *bs, QemuOpts *opts, BlockDriverAmendStatusCB *status_cb) { BDRVQcowState *s = bs->opaque; int old_version = s->qcow_version, new_version = old_version; uint64_t new_size = 0; const char *backing_file = NULL, *backing_format = NULL; bool lazy_refcounts = s->use_lazy_refcounts; const char *compat = NULL; uint64_t cluster_size = s->cluster_size; bool encrypt; int ret; QemuOptDesc *desc = opts->list->desc; while (desc && desc->name) { if (!qemu_opt_find(opts, desc->name)) { /* only change explicitly defined options */ desc++; continue; } if (!strcmp(desc->name, BLOCK_OPT_COMPAT_LEVEL)) { compat = qemu_opt_get(opts, BLOCK_OPT_COMPAT_LEVEL); if (!compat) { /* preserve default */ } else if (!strcmp(compat, "0.10")) { new_version = 2; } else if (!strcmp(compat, "1.1")) { new_version = 3; } else { fprintf(stderr, "Unknown compatibility level %s.\n", compat); return -EINVAL; } } else if (!strcmp(desc->name, BLOCK_OPT_PREALLOC)) { fprintf(stderr, "Cannot change preallocation mode.\n"); return -ENOTSUP; } else if (!strcmp(desc->name, BLOCK_OPT_SIZE)) { new_size = qemu_opt_get_size(opts, BLOCK_OPT_SIZE, 0); } else if (!strcmp(desc->name, BLOCK_OPT_BACKING_FILE)) { backing_file = qemu_opt_get(opts, BLOCK_OPT_BACKING_FILE); } else if (!strcmp(desc->name, BLOCK_OPT_BACKING_FMT)) { backing_format = qemu_opt_get(opts, BLOCK_OPT_BACKING_FMT); } else if (!strcmp(desc->name, BLOCK_OPT_ENCRYPT)) { encrypt = qemu_opt_get_bool(opts, BLOCK_OPT_ENCRYPT, s->crypt_method); if (encrypt != !!s->crypt_method) { fprintf(stderr, "Changing the encryption flag is not " "supported.\n"); return -ENOTSUP; } } else if (!strcmp(desc->name, BLOCK_OPT_CLUSTER_SIZE)) { cluster_size = qemu_opt_get_size(opts, BLOCK_OPT_CLUSTER_SIZE, cluster_size); if (cluster_size != s->cluster_size) { fprintf(stderr, "Changing the cluster size is not " "supported.\n"); return -ENOTSUP; } } else if (!strcmp(desc->name, BLOCK_OPT_LAZY_REFCOUNTS)) { lazy_refcounts = qemu_opt_get_bool(opts, BLOCK_OPT_LAZY_REFCOUNTS, lazy_refcounts); } else if (!strcmp(desc->name, BLOCK_OPT_REFCOUNT_BITS)) { error_report("Cannot change refcount entry width"); return -ENOTSUP; } else { /* if this assertion fails, this probably means a new option was * added without having it covered here */ assert(false); } desc++; } if (new_version != old_version) { if (new_version > old_version) { /* Upgrade */ s->qcow_version = new_version; ret = qcow2_update_header(bs); if (ret < 0) { s->qcow_version = old_version; return ret; } } else { ret = qcow2_downgrade(bs, new_version, status_cb); if (ret < 0) { return ret; } } } if (backing_file || backing_format) { ret = qcow2_change_backing_file(bs, backing_file ?: bs->backing_file, backing_format ?: bs->backing_format); if (ret < 0) { return ret; } } if (s->use_lazy_refcounts != lazy_refcounts) { if (lazy_refcounts) { if (s->qcow_version < 3) { fprintf(stderr, "Lazy refcounts only supported with compatibility " "level 1.1 and above (use compat=1.1 or greater)\n"); return -EINVAL; } s->compatible_features |= QCOW2_COMPAT_LAZY_REFCOUNTS; ret = qcow2_update_header(bs); if (ret < 0) { s->compatible_features &= ~QCOW2_COMPAT_LAZY_REFCOUNTS; return ret; } s->use_lazy_refcounts = true; } else { /* make image clean first */ ret = qcow2_mark_clean(bs); if (ret < 0) { return ret; } /* now disallow lazy refcounts */ s->compatible_features &= ~QCOW2_COMPAT_LAZY_REFCOUNTS; ret = qcow2_update_header(bs); if (ret < 0) { s->compatible_features |= QCOW2_COMPAT_LAZY_REFCOUNTS; return ret; } s->use_lazy_refcounts = false; } } if (new_size) { ret = bdrv_truncate(bs, new_size); if (ret < 0) { return ret; } } return 0; }
false
qemu
e4603fe139e2161464d7e75faa3a650e31f057fc
static int qcow2_amend_options(BlockDriverState *bs, QemuOpts *opts, BlockDriverAmendStatusCB *status_cb) { BDRVQcowState *s = bs->opaque; int old_version = s->qcow_version, new_version = old_version; uint64_t new_size = 0; const char *backing_file = NULL, *backing_format = NULL; bool lazy_refcounts = s->use_lazy_refcounts; const char *compat = NULL; uint64_t cluster_size = s->cluster_size; bool encrypt; int ret; QemuOptDesc *desc = opts->list->desc; while (desc && desc->name) { if (!qemu_opt_find(opts, desc->name)) { desc++; continue; } if (!strcmp(desc->name, BLOCK_OPT_COMPAT_LEVEL)) { compat = qemu_opt_get(opts, BLOCK_OPT_COMPAT_LEVEL); if (!compat) { } else if (!strcmp(compat, "0.10")) { new_version = 2; } else if (!strcmp(compat, "1.1")) { new_version = 3; } else { fprintf(stderr, "Unknown compatibility level %s.\n", compat); return -EINVAL; } } else if (!strcmp(desc->name, BLOCK_OPT_PREALLOC)) { fprintf(stderr, "Cannot change preallocation mode.\n"); return -ENOTSUP; } else if (!strcmp(desc->name, BLOCK_OPT_SIZE)) { new_size = qemu_opt_get_size(opts, BLOCK_OPT_SIZE, 0); } else if (!strcmp(desc->name, BLOCK_OPT_BACKING_FILE)) { backing_file = qemu_opt_get(opts, BLOCK_OPT_BACKING_FILE); } else if (!strcmp(desc->name, BLOCK_OPT_BACKING_FMT)) { backing_format = qemu_opt_get(opts, BLOCK_OPT_BACKING_FMT); } else if (!strcmp(desc->name, BLOCK_OPT_ENCRYPT)) { encrypt = qemu_opt_get_bool(opts, BLOCK_OPT_ENCRYPT, s->crypt_method); if (encrypt != !!s->crypt_method) { fprintf(stderr, "Changing the encryption flag is not " "supported.\n"); return -ENOTSUP; } } else if (!strcmp(desc->name, BLOCK_OPT_CLUSTER_SIZE)) { cluster_size = qemu_opt_get_size(opts, BLOCK_OPT_CLUSTER_SIZE, cluster_size); if (cluster_size != s->cluster_size) { fprintf(stderr, "Changing the cluster size is not " "supported.\n"); return -ENOTSUP; } } else if (!strcmp(desc->name, BLOCK_OPT_LAZY_REFCOUNTS)) { lazy_refcounts = qemu_opt_get_bool(opts, BLOCK_OPT_LAZY_REFCOUNTS, lazy_refcounts); } else if (!strcmp(desc->name, BLOCK_OPT_REFCOUNT_BITS)) { error_report("Cannot change refcount entry width"); return -ENOTSUP; } else { assert(false); } desc++; } if (new_version != old_version) { if (new_version > old_version) { s->qcow_version = new_version; ret = qcow2_update_header(bs); if (ret < 0) { s->qcow_version = old_version; return ret; } } else { ret = qcow2_downgrade(bs, new_version, status_cb); if (ret < 0) { return ret; } } } if (backing_file || backing_format) { ret = qcow2_change_backing_file(bs, backing_file ?: bs->backing_file, backing_format ?: bs->backing_format); if (ret < 0) { return ret; } } if (s->use_lazy_refcounts != lazy_refcounts) { if (lazy_refcounts) { if (s->qcow_version < 3) { fprintf(stderr, "Lazy refcounts only supported with compatibility " "level 1.1 and above (use compat=1.1 or greater)\n"); return -EINVAL; } s->compatible_features |= QCOW2_COMPAT_LAZY_REFCOUNTS; ret = qcow2_update_header(bs); if (ret < 0) { s->compatible_features &= ~QCOW2_COMPAT_LAZY_REFCOUNTS; return ret; } s->use_lazy_refcounts = true; } else { ret = qcow2_mark_clean(bs); if (ret < 0) { return ret; } s->compatible_features &= ~QCOW2_COMPAT_LAZY_REFCOUNTS; ret = qcow2_update_header(bs); if (ret < 0) { s->compatible_features |= QCOW2_COMPAT_LAZY_REFCOUNTS; return ret; } s->use_lazy_refcounts = false; } } if (new_size) { ret = bdrv_truncate(bs, new_size); if (ret < 0) { return ret; } } return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(BlockDriverState *VAR_0, QemuOpts *VAR_1, BlockDriverAmendStatusCB *VAR_2) { BDRVQcowState *s = VAR_0->opaque; int VAR_3 = s->qcow_version, VAR_4 = VAR_3; uint64_t new_size = 0; const char *VAR_5 = NULL, *VAR_6 = NULL; bool lazy_refcounts = s->use_lazy_refcounts; const char *VAR_7 = NULL; uint64_t cluster_size = s->cluster_size; bool encrypt; int VAR_8; QemuOptDesc *desc = VAR_1->list->desc; while (desc && desc->name) { if (!qemu_opt_find(VAR_1, desc->name)) { desc++; continue; } if (!strcmp(desc->name, BLOCK_OPT_COMPAT_LEVEL)) { VAR_7 = qemu_opt_get(VAR_1, BLOCK_OPT_COMPAT_LEVEL); if (!VAR_7) { } else if (!strcmp(VAR_7, "0.10")) { VAR_4 = 2; } else if (!strcmp(VAR_7, "1.1")) { VAR_4 = 3; } else { fprintf(stderr, "Unknown compatibility level %s.\n", VAR_7); return -EINVAL; } } else if (!strcmp(desc->name, BLOCK_OPT_PREALLOC)) { fprintf(stderr, "Cannot change preallocation mode.\n"); return -ENOTSUP; } else if (!strcmp(desc->name, BLOCK_OPT_SIZE)) { new_size = qemu_opt_get_size(VAR_1, BLOCK_OPT_SIZE, 0); } else if (!strcmp(desc->name, BLOCK_OPT_BACKING_FILE)) { VAR_5 = qemu_opt_get(VAR_1, BLOCK_OPT_BACKING_FILE); } else if (!strcmp(desc->name, BLOCK_OPT_BACKING_FMT)) { VAR_6 = qemu_opt_get(VAR_1, BLOCK_OPT_BACKING_FMT); } else if (!strcmp(desc->name, BLOCK_OPT_ENCRYPT)) { encrypt = qemu_opt_get_bool(VAR_1, BLOCK_OPT_ENCRYPT, s->crypt_method); if (encrypt != !!s->crypt_method) { fprintf(stderr, "Changing the encryption flag is not " "supported.\n"); return -ENOTSUP; } } else if (!strcmp(desc->name, BLOCK_OPT_CLUSTER_SIZE)) { cluster_size = qemu_opt_get_size(VAR_1, BLOCK_OPT_CLUSTER_SIZE, cluster_size); if (cluster_size != s->cluster_size) { fprintf(stderr, "Changing the cluster size is not " "supported.\n"); return -ENOTSUP; } } else if (!strcmp(desc->name, BLOCK_OPT_LAZY_REFCOUNTS)) { lazy_refcounts = qemu_opt_get_bool(VAR_1, BLOCK_OPT_LAZY_REFCOUNTS, lazy_refcounts); } else if (!strcmp(desc->name, BLOCK_OPT_REFCOUNT_BITS)) { error_report("Cannot change refcount entry width"); return -ENOTSUP; } else { assert(false); } desc++; } if (VAR_4 != VAR_3) { if (VAR_4 > VAR_3) { s->qcow_version = VAR_4; VAR_8 = qcow2_update_header(VAR_0); if (VAR_8 < 0) { s->qcow_version = VAR_3; return VAR_8; } } else { VAR_8 = qcow2_downgrade(VAR_0, VAR_4, VAR_2); if (VAR_8 < 0) { return VAR_8; } } } if (VAR_5 || VAR_6) { VAR_8 = qcow2_change_backing_file(VAR_0, VAR_5 ?: VAR_0->VAR_5, VAR_6 ?: VAR_0->VAR_6); if (VAR_8 < 0) { return VAR_8; } } if (s->use_lazy_refcounts != lazy_refcounts) { if (lazy_refcounts) { if (s->qcow_version < 3) { fprintf(stderr, "Lazy refcounts only supported with compatibility " "level 1.1 and above (use VAR_7=1.1 or greater)\n"); return -EINVAL; } s->compatible_features |= QCOW2_COMPAT_LAZY_REFCOUNTS; VAR_8 = qcow2_update_header(VAR_0); if (VAR_8 < 0) { s->compatible_features &= ~QCOW2_COMPAT_LAZY_REFCOUNTS; return VAR_8; } s->use_lazy_refcounts = true; } else { VAR_8 = qcow2_mark_clean(VAR_0); if (VAR_8 < 0) { return VAR_8; } s->compatible_features &= ~QCOW2_COMPAT_LAZY_REFCOUNTS; VAR_8 = qcow2_update_header(VAR_0); if (VAR_8 < 0) { s->compatible_features |= QCOW2_COMPAT_LAZY_REFCOUNTS; return VAR_8; } s->use_lazy_refcounts = false; } } if (new_size) { VAR_8 = bdrv_truncate(VAR_0, new_size); if (VAR_8 < 0) { return VAR_8; } } return 0; }
[ "static int FUNC_0(BlockDriverState *VAR_0, QemuOpts *VAR_1,\nBlockDriverAmendStatusCB *VAR_2)\n{", "BDRVQcowState *s = VAR_0->opaque;", "int VAR_3 = s->qcow_version, VAR_4 = VAR_3;", "uint64_t new_size = 0;", "const char *VAR_5 = NULL, *VAR_6 = NULL;", "bool lazy_refcounts = s->use_lazy_refcounts;", "const char *VAR_7 = NULL;", "uint64_t cluster_size = s->cluster_size;", "bool encrypt;", "int VAR_8;", "QemuOptDesc *desc = VAR_1->list->desc;", "while (desc && desc->name) {", "if (!qemu_opt_find(VAR_1, desc->name)) {", "desc++;", "continue;", "}", "if (!strcmp(desc->name, BLOCK_OPT_COMPAT_LEVEL)) {", "VAR_7 = qemu_opt_get(VAR_1, BLOCK_OPT_COMPAT_LEVEL);", "if (!VAR_7) {", "} else if (!strcmp(VAR_7, \"0.10\")) {", "VAR_4 = 2;", "} else if (!strcmp(VAR_7, \"1.1\")) {", "VAR_4 = 3;", "} else {", "fprintf(stderr, \"Unknown compatibility level %s.\\n\", VAR_7);", "return -EINVAL;", "}", "} else if (!strcmp(desc->name, BLOCK_OPT_PREALLOC)) {", "fprintf(stderr, \"Cannot change preallocation mode.\\n\");", "return -ENOTSUP;", "} else if (!strcmp(desc->name, BLOCK_OPT_SIZE)) {", "new_size = qemu_opt_get_size(VAR_1, BLOCK_OPT_SIZE, 0);", "} else if (!strcmp(desc->name, BLOCK_OPT_BACKING_FILE)) {", "VAR_5 = qemu_opt_get(VAR_1, BLOCK_OPT_BACKING_FILE);", "} else if (!strcmp(desc->name, BLOCK_OPT_BACKING_FMT)) {", "VAR_6 = qemu_opt_get(VAR_1, BLOCK_OPT_BACKING_FMT);", "} else if (!strcmp(desc->name, BLOCK_OPT_ENCRYPT)) {", "encrypt = qemu_opt_get_bool(VAR_1, BLOCK_OPT_ENCRYPT,\ns->crypt_method);", "if (encrypt != !!s->crypt_method) {", "fprintf(stderr, \"Changing the encryption flag is not \"\n\"supported.\\n\");", "return -ENOTSUP;", "}", "} else if (!strcmp(desc->name, BLOCK_OPT_CLUSTER_SIZE)) {", "cluster_size = qemu_opt_get_size(VAR_1, BLOCK_OPT_CLUSTER_SIZE,\ncluster_size);", "if (cluster_size != s->cluster_size) {", "fprintf(stderr, \"Changing the cluster size is not \"\n\"supported.\\n\");", "return -ENOTSUP;", "}", "} else if (!strcmp(desc->name, BLOCK_OPT_LAZY_REFCOUNTS)) {", "lazy_refcounts = qemu_opt_get_bool(VAR_1, BLOCK_OPT_LAZY_REFCOUNTS,\nlazy_refcounts);", "} else if (!strcmp(desc->name, BLOCK_OPT_REFCOUNT_BITS)) {", "error_report(\"Cannot change refcount entry width\");", "return -ENOTSUP;", "} else {", "assert(false);", "}", "desc++;", "}", "if (VAR_4 != VAR_3) {", "if (VAR_4 > VAR_3) {", "s->qcow_version = VAR_4;", "VAR_8 = qcow2_update_header(VAR_0);", "if (VAR_8 < 0) {", "s->qcow_version = VAR_3;", "return VAR_8;", "}", "} else {", "VAR_8 = qcow2_downgrade(VAR_0, VAR_4, VAR_2);", "if (VAR_8 < 0) {", "return VAR_8;", "}", "}", "}", "if (VAR_5 || VAR_6) {", "VAR_8 = qcow2_change_backing_file(VAR_0, VAR_5 ?: VAR_0->VAR_5,\nVAR_6 ?: VAR_0->VAR_6);", "if (VAR_8 < 0) {", "return VAR_8;", "}", "}", "if (s->use_lazy_refcounts != lazy_refcounts) {", "if (lazy_refcounts) {", "if (s->qcow_version < 3) {", "fprintf(stderr, \"Lazy refcounts only supported with compatibility \"\n\"level 1.1 and above (use VAR_7=1.1 or greater)\\n\");", "return -EINVAL;", "}", "s->compatible_features |= QCOW2_COMPAT_LAZY_REFCOUNTS;", "VAR_8 = qcow2_update_header(VAR_0);", "if (VAR_8 < 0) {", "s->compatible_features &= ~QCOW2_COMPAT_LAZY_REFCOUNTS;", "return VAR_8;", "}", "s->use_lazy_refcounts = true;", "} else {", "VAR_8 = qcow2_mark_clean(VAR_0);", "if (VAR_8 < 0) {", "return VAR_8;", "}", "s->compatible_features &= ~QCOW2_COMPAT_LAZY_REFCOUNTS;", "VAR_8 = qcow2_update_header(VAR_0);", "if (VAR_8 < 0) {", "s->compatible_features |= QCOW2_COMPAT_LAZY_REFCOUNTS;", "return VAR_8;", "}", "s->use_lazy_refcounts = false;", "}", "}", "if (new_size) {", "VAR_8 = bdrv_truncate(VAR_0, new_size);", "if (VAR_8 < 0) {", "return VAR_8;", "}", "}", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 29 ], [ 31 ], [ 35 ], [ 37 ], [ 39 ], [ 43 ], [ 45 ], [ 47 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87, 89 ], [ 91 ], [ 93, 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103, 105 ], [ 107 ], [ 109, 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119, 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 135 ], [ 137 ], [ 141 ], [ 143 ], [ 147 ], [ 149 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 175 ], [ 177 ], [ 181 ], [ 183, 185 ], [ 187 ], [ 189 ], [ 191 ], [ 193 ], [ 197 ], [ 199 ], [ 201 ], [ 203, 205 ], [ 207 ], [ 209 ], [ 211 ], [ 213 ], [ 215 ], [ 217 ], [ 219 ], [ 221 ], [ 223 ], [ 225 ], [ 229 ], [ 231 ], [ 233 ], [ 235 ], [ 239 ], [ 241 ], [ 243 ], [ 245 ], [ 247 ], [ 249 ], [ 251 ], [ 253 ], [ 255 ], [ 259 ], [ 261 ], [ 263 ], [ 265 ], [ 267 ], [ 269 ], [ 273 ], [ 275 ] ]
22,202
void aio_set_event_notifier(AioContext *ctx, EventNotifier *e, bool is_external, EventNotifierHandler *io_notify, AioPollFn *io_poll) { AioHandler *node; qemu_lockcnt_lock(&ctx->list_lock); QLIST_FOREACH(node, &ctx->aio_handlers, node) { if (node->e == e && !node->deleted) { break; } } /* Are we deleting the fd handler? */ if (!io_notify) { if (node) { g_source_remove_poll(&ctx->source, &node->pfd); /* aio_poll is in progress, just mark the node as deleted */ if (qemu_lockcnt_count(&ctx->list_lock)) { node->deleted = 1; node->pfd.revents = 0; } else { /* Otherwise, delete it for real. We can't just mark it as * deleted because deleted nodes are only cleaned up after * releasing the list_lock. */ QLIST_REMOVE(node, node); g_free(node); } } } else { if (node == NULL) { /* Alloc and insert if it's not already there */ node = g_new0(AioHandler, 1); node->e = e; node->pfd.fd = (uintptr_t)event_notifier_get_handle(e); node->pfd.events = G_IO_IN; node->is_external = is_external; QLIST_INSERT_HEAD_RCU(&ctx->aio_handlers, node, node); g_source_add_poll(&ctx->source, &node->pfd); } /* Update handler with latest information */ node->io_notify = io_notify; } qemu_lockcnt_unlock(&ctx->list_lock); aio_notify(ctx); }
false
qemu
c2b38b277a7882a592f4f2ec955084b2b756daaa
void aio_set_event_notifier(AioContext *ctx, EventNotifier *e, bool is_external, EventNotifierHandler *io_notify, AioPollFn *io_poll) { AioHandler *node; qemu_lockcnt_lock(&ctx->list_lock); QLIST_FOREACH(node, &ctx->aio_handlers, node) { if (node->e == e && !node->deleted) { break; } } if (!io_notify) { if (node) { g_source_remove_poll(&ctx->source, &node->pfd); if (qemu_lockcnt_count(&ctx->list_lock)) { node->deleted = 1; node->pfd.revents = 0; } else { QLIST_REMOVE(node, node); g_free(node); } } } else { if (node == NULL) { node = g_new0(AioHandler, 1); node->e = e; node->pfd.fd = (uintptr_t)event_notifier_get_handle(e); node->pfd.events = G_IO_IN; node->is_external = is_external; QLIST_INSERT_HEAD_RCU(&ctx->aio_handlers, node, node); g_source_add_poll(&ctx->source, &node->pfd); } node->io_notify = io_notify; } qemu_lockcnt_unlock(&ctx->list_lock); aio_notify(ctx); }
{ "code": [], "line_no": [] }
void FUNC_0(AioContext *VAR_0, EventNotifier *VAR_1, bool VAR_2, EventNotifierHandler *VAR_3, AioPollFn *VAR_4) { AioHandler *node; qemu_lockcnt_lock(&VAR_0->list_lock); QLIST_FOREACH(node, &VAR_0->aio_handlers, node) { if (node->VAR_1 == VAR_1 && !node->deleted) { break; } } if (!VAR_3) { if (node) { g_source_remove_poll(&VAR_0->source, &node->pfd); if (qemu_lockcnt_count(&VAR_0->list_lock)) { node->deleted = 1; node->pfd.revents = 0; } else { QLIST_REMOVE(node, node); g_free(node); } } } else { if (node == NULL) { node = g_new0(AioHandler, 1); node->VAR_1 = VAR_1; node->pfd.fd = (uintptr_t)event_notifier_get_handle(VAR_1); node->pfd.events = G_IO_IN; node->VAR_2 = VAR_2; QLIST_INSERT_HEAD_RCU(&VAR_0->aio_handlers, node, node); g_source_add_poll(&VAR_0->source, &node->pfd); } node->VAR_3 = VAR_3; } qemu_lockcnt_unlock(&VAR_0->list_lock); aio_notify(VAR_0); }
[ "void FUNC_0(AioContext *VAR_0,\nEventNotifier *VAR_1,\nbool VAR_2,\nEventNotifierHandler *VAR_3,\nAioPollFn *VAR_4)\n{", "AioHandler *node;", "qemu_lockcnt_lock(&VAR_0->list_lock);", "QLIST_FOREACH(node, &VAR_0->aio_handlers, node) {", "if (node->VAR_1 == VAR_1 && !node->deleted) {", "break;", "}", "}", "if (!VAR_3) {", "if (node) {", "g_source_remove_poll(&VAR_0->source, &node->pfd);", "if (qemu_lockcnt_count(&VAR_0->list_lock)) {", "node->deleted = 1;", "node->pfd.revents = 0;", "} else {", "QLIST_REMOVE(node, node);", "g_free(node);", "}", "}", "} else {", "if (node == NULL) {", "node = g_new0(AioHandler, 1);", "node->VAR_1 = VAR_1;", "node->pfd.fd = (uintptr_t)event_notifier_get_handle(VAR_1);", "node->pfd.events = G_IO_IN;", "node->VAR_2 = VAR_2;", "QLIST_INSERT_HEAD_RCU(&VAR_0->aio_handlers, node, node);", "g_source_add_poll(&VAR_0->source, &node->pfd);", "}", "node->VAR_3 = VAR_3;", "}", "qemu_lockcnt_unlock(&VAR_0->list_lock);", "aio_notify(VAR_0);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9, 11 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 33 ], [ 35 ], [ 37 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 87 ], [ 89 ], [ 93 ], [ 95 ], [ 99 ], [ 101 ], [ 103 ] ]
22,203
static int ehci_state_fetchqtd(EHCIQueue *q) { EHCIqtd qtd; EHCIPacket *p; int again = 0; get_dwords(q->ehci, NLPTR_GET(q->qtdaddr), (uint32_t *) &qtd, sizeof(EHCIqtd) >> 2); ehci_trace_qtd(q, NLPTR_GET(q->qtdaddr), &qtd); p = QTAILQ_FIRST(&q->packets); if (p != NULL) { if (p->qtdaddr != q->qtdaddr || (!NLPTR_TBIT(p->qtd.next) && (p->qtd.next != qtd.next)) || (!NLPTR_TBIT(p->qtd.altnext) && (p->qtd.altnext != qtd.altnext)) || p->qtd.bufptr[0] != qtd.bufptr[0]) { ehci_cancel_queue(q); ehci_trace_guest_bug(q->ehci, "guest updated active QH or qTD"); p = NULL; } else { p->qtd = qtd; ehci_qh_do_overlay(q); } } if (!(qtd.token & QTD_TOKEN_ACTIVE)) { if (p != NULL) { /* transfer canceled by guest (clear active) */ ehci_cancel_queue(q); p = NULL; } ehci_set_state(q->ehci, q->async, EST_HORIZONTALQH); again = 1; } else if (p != NULL) { switch (p->async) { case EHCI_ASYNC_NONE: case EHCI_ASYNC_INITIALIZED: /* Not yet executed (MULT), or previously nacked (int) packet */ ehci_set_state(q->ehci, q->async, EST_EXECUTE); break; case EHCI_ASYNC_INFLIGHT: /* Unfinished async handled packet, go horizontal */ ehci_set_state(q->ehci, q->async, EST_HORIZONTALQH); break; case EHCI_ASYNC_FINISHED: /* * We get here when advqueue moves to a packet which is already * finished, which can happen with packets queued up by fill_queue */ ehci_set_state(q->ehci, q->async, EST_EXECUTING); break; } again = 1; } else { p = ehci_alloc_packet(q); p->qtdaddr = q->qtdaddr; p->qtd = qtd; ehci_set_state(q->ehci, q->async, EST_EXECUTE); again = 1; } return again; }
false
qemu
b4ea86649915eca5551a5166f76e7a9d9032de50
static int ehci_state_fetchqtd(EHCIQueue *q) { EHCIqtd qtd; EHCIPacket *p; int again = 0; get_dwords(q->ehci, NLPTR_GET(q->qtdaddr), (uint32_t *) &qtd, sizeof(EHCIqtd) >> 2); ehci_trace_qtd(q, NLPTR_GET(q->qtdaddr), &qtd); p = QTAILQ_FIRST(&q->packets); if (p != NULL) { if (p->qtdaddr != q->qtdaddr || (!NLPTR_TBIT(p->qtd.next) && (p->qtd.next != qtd.next)) || (!NLPTR_TBIT(p->qtd.altnext) && (p->qtd.altnext != qtd.altnext)) || p->qtd.bufptr[0] != qtd.bufptr[0]) { ehci_cancel_queue(q); ehci_trace_guest_bug(q->ehci, "guest updated active QH or qTD"); p = NULL; } else { p->qtd = qtd; ehci_qh_do_overlay(q); } } if (!(qtd.token & QTD_TOKEN_ACTIVE)) { if (p != NULL) { ehci_cancel_queue(q); p = NULL; } ehci_set_state(q->ehci, q->async, EST_HORIZONTALQH); again = 1; } else if (p != NULL) { switch (p->async) { case EHCI_ASYNC_NONE: case EHCI_ASYNC_INITIALIZED: ehci_set_state(q->ehci, q->async, EST_EXECUTE); break; case EHCI_ASYNC_INFLIGHT: ehci_set_state(q->ehci, q->async, EST_HORIZONTALQH); break; case EHCI_ASYNC_FINISHED: ehci_set_state(q->ehci, q->async, EST_EXECUTING); break; } again = 1; } else { p = ehci_alloc_packet(q); p->qtdaddr = q->qtdaddr; p->qtd = qtd; ehci_set_state(q->ehci, q->async, EST_EXECUTE); again = 1; } return again; }
{ "code": [], "line_no": [] }
static int FUNC_0(EHCIQueue *VAR_0) { EHCIqtd qtd; EHCIPacket *p; int VAR_1 = 0; get_dwords(VAR_0->ehci, NLPTR_GET(VAR_0->qtdaddr), (uint32_t *) &qtd, sizeof(EHCIqtd) >> 2); ehci_trace_qtd(VAR_0, NLPTR_GET(VAR_0->qtdaddr), &qtd); p = QTAILQ_FIRST(&VAR_0->packets); if (p != NULL) { if (p->qtdaddr != VAR_0->qtdaddr || (!NLPTR_TBIT(p->qtd.next) && (p->qtd.next != qtd.next)) || (!NLPTR_TBIT(p->qtd.altnext) && (p->qtd.altnext != qtd.altnext)) || p->qtd.bufptr[0] != qtd.bufptr[0]) { ehci_cancel_queue(VAR_0); ehci_trace_guest_bug(VAR_0->ehci, "guest updated active QH or qTD"); p = NULL; } else { p->qtd = qtd; ehci_qh_do_overlay(VAR_0); } } if (!(qtd.token & QTD_TOKEN_ACTIVE)) { if (p != NULL) { ehci_cancel_queue(VAR_0); p = NULL; } ehci_set_state(VAR_0->ehci, VAR_0->async, EST_HORIZONTALQH); VAR_1 = 1; } else if (p != NULL) { switch (p->async) { case EHCI_ASYNC_NONE: case EHCI_ASYNC_INITIALIZED: ehci_set_state(VAR_0->ehci, VAR_0->async, EST_EXECUTE); break; case EHCI_ASYNC_INFLIGHT: ehci_set_state(VAR_0->ehci, VAR_0->async, EST_HORIZONTALQH); break; case EHCI_ASYNC_FINISHED: ehci_set_state(VAR_0->ehci, VAR_0->async, EST_EXECUTING); break; } VAR_1 = 1; } else { p = ehci_alloc_packet(VAR_0); p->qtdaddr = VAR_0->qtdaddr; p->qtd = qtd; ehci_set_state(VAR_0->ehci, VAR_0->async, EST_EXECUTE); VAR_1 = 1; } return VAR_1; }
[ "static int FUNC_0(EHCIQueue *VAR_0)\n{", "EHCIqtd qtd;", "EHCIPacket *p;", "int VAR_1 = 0;", "get_dwords(VAR_0->ehci, NLPTR_GET(VAR_0->qtdaddr), (uint32_t *) &qtd,\nsizeof(EHCIqtd) >> 2);", "ehci_trace_qtd(VAR_0, NLPTR_GET(VAR_0->qtdaddr), &qtd);", "p = QTAILQ_FIRST(&VAR_0->packets);", "if (p != NULL) {", "if (p->qtdaddr != VAR_0->qtdaddr ||\n(!NLPTR_TBIT(p->qtd.next) && (p->qtd.next != qtd.next)) ||\n(!NLPTR_TBIT(p->qtd.altnext) && (p->qtd.altnext != qtd.altnext)) ||\np->qtd.bufptr[0] != qtd.bufptr[0]) {", "ehci_cancel_queue(VAR_0);", "ehci_trace_guest_bug(VAR_0->ehci, \"guest updated active QH or qTD\");", "p = NULL;", "} else {", "p->qtd = qtd;", "ehci_qh_do_overlay(VAR_0);", "}", "}", "if (!(qtd.token & QTD_TOKEN_ACTIVE)) {", "if (p != NULL) {", "ehci_cancel_queue(VAR_0);", "p = NULL;", "}", "ehci_set_state(VAR_0->ehci, VAR_0->async, EST_HORIZONTALQH);", "VAR_1 = 1;", "} else if (p != NULL) {", "switch (p->async) {", "case EHCI_ASYNC_NONE:\ncase EHCI_ASYNC_INITIALIZED:\nehci_set_state(VAR_0->ehci, VAR_0->async, EST_EXECUTE);", "break;", "case EHCI_ASYNC_INFLIGHT:\nehci_set_state(VAR_0->ehci, VAR_0->async, EST_HORIZONTALQH);", "break;", "case EHCI_ASYNC_FINISHED:\nehci_set_state(VAR_0->ehci, VAR_0->async, EST_EXECUTING);", "break;", "}", "VAR_1 = 1;", "} else {", "p = ehci_alloc_packet(VAR_0);", "p->qtdaddr = VAR_0->qtdaddr;", "p->qtd = qtd;", "ehci_set_state(VAR_0->ehci, VAR_0->async, EST_EXECUTE);", "VAR_1 = 1;", "}", "return VAR_1;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 51 ], [ 53 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71, 73, 77 ], [ 79 ], [ 81, 85 ], [ 87 ], [ 89, 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 123 ], [ 125 ] ]
22,204
int net_init_hubport(const NetClientOptions *opts, const char *name, NetClientState *peer) { const NetdevHubPortOptions *hubport; assert(opts->kind == NET_CLIENT_OPTIONS_KIND_HUBPORT); hubport = opts->hubport; if (peer) { return -EINVAL; } net_hub_add_port(hubport->hubid, name); return 0; }
false
qemu
ca7eb1848bb06d9b75784d7760b83c7b0beb1102
int net_init_hubport(const NetClientOptions *opts, const char *name, NetClientState *peer) { const NetdevHubPortOptions *hubport; assert(opts->kind == NET_CLIENT_OPTIONS_KIND_HUBPORT); hubport = opts->hubport; if (peer) { return -EINVAL; } net_hub_add_port(hubport->hubid, name); return 0; }
{ "code": [], "line_no": [] }
int FUNC_0(const NetClientOptions *VAR_0, const char *VAR_1, NetClientState *VAR_2) { const NetdevHubPortOptions *VAR_3; assert(VAR_0->kind == NET_CLIENT_OPTIONS_KIND_HUBPORT); VAR_3 = VAR_0->VAR_3; if (VAR_2) { return -EINVAL; } net_hub_add_port(VAR_3->hubid, VAR_1); return 0; }
[ "int FUNC_0(const NetClientOptions *VAR_0, const char *VAR_1,\nNetClientState *VAR_2)\n{", "const NetdevHubPortOptions *VAR_3;", "assert(VAR_0->kind == NET_CLIENT_OPTIONS_KIND_HUBPORT);", "VAR_3 = VAR_0->VAR_3;", "if (VAR_2) {", "return -EINVAL;", "}", "net_hub_add_port(VAR_3->hubid, VAR_1);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 25 ], [ 27 ], [ 29 ] ]
22,205
int cpu_breakpoint_remove(CPUState *env, target_ulong pc, int flags) { #if defined(TARGET_HAS_ICE) CPUBreakpoint *bp; TAILQ_FOREACH(bp, &env->breakpoints, entry) { if (bp->pc == pc && bp->flags == flags) { cpu_breakpoint_remove_by_ref(env, bp); return 0; } } return -ENOENT; #else return -ENOSYS; #endif }
false
qemu
72cf2d4f0e181d0d3a3122e04129c58a95da713e
int cpu_breakpoint_remove(CPUState *env, target_ulong pc, int flags) { #if defined(TARGET_HAS_ICE) CPUBreakpoint *bp; TAILQ_FOREACH(bp, &env->breakpoints, entry) { if (bp->pc == pc && bp->flags == flags) { cpu_breakpoint_remove_by_ref(env, bp); return 0; } } return -ENOENT; #else return -ENOSYS; #endif }
{ "code": [], "line_no": [] }
int FUNC_0(CPUState *VAR_0, target_ulong VAR_1, int VAR_2) { #if defined(TARGET_HAS_ICE) CPUBreakpoint *bp; TAILQ_FOREACH(bp, &VAR_0->breakpoints, entry) { if (bp->VAR_1 == VAR_1 && bp->VAR_2 == VAR_2) { cpu_breakpoint_remove_by_ref(VAR_0, bp); return 0; } } return -ENOENT; #else return -ENOSYS; #endif }
[ "int FUNC_0(CPUState *VAR_0, target_ulong VAR_1, int VAR_2)\n{", "#if defined(TARGET_HAS_ICE)\nCPUBreakpoint *bp;", "TAILQ_FOREACH(bp, &VAR_0->breakpoints, entry) {", "if (bp->VAR_1 == VAR_1 && bp->VAR_2 == VAR_2) {", "cpu_breakpoint_remove_by_ref(VAR_0, bp);", "return 0;", "}", "}", "return -ENOENT;", "#else\nreturn -ENOSYS;", "#endif\n}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5, 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25, 27 ], [ 29, 31 ] ]
22,206
static void mm_decode_inter(MmContext * s, int half_horiz, int half_vert, const uint8_t *buf, int buf_size) { const int data_ptr = 2 + AV_RL16(&buf[0]); int d, r, y; d = data_ptr; r = 2; y = 0; while(r < data_ptr) { int i, j; int length = buf[r] & 0x7f; int x = buf[r+1] + ((buf[r] & 0x80) << 1); r += 2; if (length==0) { y += x; continue; } for(i=0; i<length; i++) { for(j=0; j<8; j++) { int replace = (buf[r+i] >> (7-j)) & 1; if (replace) { int color = buf[d]; s->frame.data[0][y*s->frame.linesize[0] + x] = color; if (half_horiz) s->frame.data[0][y*s->frame.linesize[0] + x + 1] = color; if (half_vert) { s->frame.data[0][(y+1)*s->frame.linesize[0] + x] = color; if (half_horiz) s->frame.data[0][(y+1)*s->frame.linesize[0] + x + 1] = color; } d++; } x += half_horiz ? 2 : 1; } } r += length; y += half_vert ? 2 : 1; } }
false
FFmpeg
091bc6ca8c643bfece2c70ff2404c7b31574e1f1
static void mm_decode_inter(MmContext * s, int half_horiz, int half_vert, const uint8_t *buf, int buf_size) { const int data_ptr = 2 + AV_RL16(&buf[0]); int d, r, y; d = data_ptr; r = 2; y = 0; while(r < data_ptr) { int i, j; int length = buf[r] & 0x7f; int x = buf[r+1] + ((buf[r] & 0x80) << 1); r += 2; if (length==0) { y += x; continue; } for(i=0; i<length; i++) { for(j=0; j<8; j++) { int replace = (buf[r+i] >> (7-j)) & 1; if (replace) { int color = buf[d]; s->frame.data[0][y*s->frame.linesize[0] + x] = color; if (half_horiz) s->frame.data[0][y*s->frame.linesize[0] + x + 1] = color; if (half_vert) { s->frame.data[0][(y+1)*s->frame.linesize[0] + x] = color; if (half_horiz) s->frame.data[0][(y+1)*s->frame.linesize[0] + x + 1] = color; } d++; } x += half_horiz ? 2 : 1; } } r += length; y += half_vert ? 2 : 1; } }
{ "code": [], "line_no": [] }
static void FUNC_0(MmContext * VAR_0, int VAR_1, int VAR_2, const uint8_t *VAR_3, int VAR_4) { const int VAR_5 = 2 + AV_RL16(&VAR_3[0]); int VAR_6, VAR_7, VAR_8; VAR_6 = VAR_5; VAR_7 = 2; VAR_8 = 0; while(VAR_7 < VAR_5) { int VAR_9, VAR_10; int VAR_11 = VAR_3[VAR_7] & 0x7f; int VAR_12 = VAR_3[VAR_7+1] + ((VAR_3[VAR_7] & 0x80) << 1); VAR_7 += 2; if (VAR_11==0) { VAR_8 += VAR_12; continue; } for(VAR_9=0; VAR_9<VAR_11; VAR_9++) { for(VAR_10=0; VAR_10<8; VAR_10++) { int VAR_13 = (VAR_3[VAR_7+VAR_9] >> (7-VAR_10)) & 1; if (VAR_13) { int VAR_14 = VAR_3[VAR_6]; VAR_0->frame.data[0][VAR_8*VAR_0->frame.linesize[0] + VAR_12] = VAR_14; if (VAR_1) VAR_0->frame.data[0][VAR_8*VAR_0->frame.linesize[0] + VAR_12 + 1] = VAR_14; if (VAR_2) { VAR_0->frame.data[0][(VAR_8+1)*VAR_0->frame.linesize[0] + VAR_12] = VAR_14; if (VAR_1) VAR_0->frame.data[0][(VAR_8+1)*VAR_0->frame.linesize[0] + VAR_12 + 1] = VAR_14; } VAR_6++; } VAR_12 += VAR_1 ? 2 : 1; } } VAR_7 += VAR_11; VAR_8 += VAR_2 ? 2 : 1; } }
[ "static void FUNC_0(MmContext * VAR_0, int VAR_1, int VAR_2, const uint8_t *VAR_3, int VAR_4)\n{", "const int VAR_5 = 2 + AV_RL16(&VAR_3[0]);", "int VAR_6, VAR_7, VAR_8;", "VAR_6 = VAR_5; VAR_7 = 2; VAR_8 = 0;", "while(VAR_7 < VAR_5) {", "int VAR_9, VAR_10;", "int VAR_11 = VAR_3[VAR_7] & 0x7f;", "int VAR_12 = VAR_3[VAR_7+1] + ((VAR_3[VAR_7] & 0x80) << 1);", "VAR_7 += 2;", "if (VAR_11==0) {", "VAR_8 += VAR_12;", "continue;", "}", "for(VAR_9=0; VAR_9<VAR_11; VAR_9++) {", "for(VAR_10=0; VAR_10<8; VAR_10++) {", "int VAR_13 = (VAR_3[VAR_7+VAR_9] >> (7-VAR_10)) & 1;", "if (VAR_13) {", "int VAR_14 = VAR_3[VAR_6];", "VAR_0->frame.data[0][VAR_8*VAR_0->frame.linesize[0] + VAR_12] = VAR_14;", "if (VAR_1)\nVAR_0->frame.data[0][VAR_8*VAR_0->frame.linesize[0] + VAR_12 + 1] = VAR_14;", "if (VAR_2) {", "VAR_0->frame.data[0][(VAR_8+1)*VAR_0->frame.linesize[0] + VAR_12] = VAR_14;", "if (VAR_1)\nVAR_0->frame.data[0][(VAR_8+1)*VAR_0->frame.linesize[0] + VAR_12 + 1] = VAR_14;", "}", "VAR_6++;", "}", "VAR_12 += VAR_1 ? 2 : 1;", "}", "}", "VAR_7 += VAR_11;", "VAR_8 += VAR_2 ? 2 : 1;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47, 49 ], [ 51 ], [ 53 ], [ 55, 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ] ]
22,207
static void pxa2xx_ssp_fifo_update(PXA2xxSSPState *s) { s->sssr &= ~(0xf << 12); /* Clear RFL */ s->sssr &= ~(0xf << 8); /* Clear TFL */ s->sssr &= ~SSSR_TNF; if (s->enable) { s->sssr |= ((s->rx_level - 1) & 0xf) << 12; if (s->rx_level >= SSCR1_RFT(s->sscr[1])) s->sssr |= SSSR_RFS; else s->sssr &= ~SSSR_RFS; if (0 <= SSCR1_TFT(s->sscr[1])) s->sssr |= SSSR_TFS; else s->sssr &= ~SSSR_TFS; if (s->rx_level) s->sssr |= SSSR_RNE; else s->sssr &= ~SSSR_RNE; s->sssr |= SSSR_TNF; } pxa2xx_ssp_int_update(s); }
false
qemu
7d1476898fd58d6ae5c054e6afddf18c335d9d89
static void pxa2xx_ssp_fifo_update(PXA2xxSSPState *s) { s->sssr &= ~(0xf << 12); s->sssr &= ~(0xf << 8); s->sssr &= ~SSSR_TNF; if (s->enable) { s->sssr |= ((s->rx_level - 1) & 0xf) << 12; if (s->rx_level >= SSCR1_RFT(s->sscr[1])) s->sssr |= SSSR_RFS; else s->sssr &= ~SSSR_RFS; if (0 <= SSCR1_TFT(s->sscr[1])) s->sssr |= SSSR_TFS; else s->sssr &= ~SSSR_TFS; if (s->rx_level) s->sssr |= SSSR_RNE; else s->sssr &= ~SSSR_RNE; s->sssr |= SSSR_TNF; } pxa2xx_ssp_int_update(s); }
{ "code": [], "line_no": [] }
static void FUNC_0(PXA2xxSSPState *VAR_0) { VAR_0->sssr &= ~(0xf << 12); VAR_0->sssr &= ~(0xf << 8); VAR_0->sssr &= ~SSSR_TNF; if (VAR_0->enable) { VAR_0->sssr |= ((VAR_0->rx_level - 1) & 0xf) << 12; if (VAR_0->rx_level >= SSCR1_RFT(VAR_0->sscr[1])) VAR_0->sssr |= SSSR_RFS; else VAR_0->sssr &= ~SSSR_RFS; if (0 <= SSCR1_TFT(VAR_0->sscr[1])) VAR_0->sssr |= SSSR_TFS; else VAR_0->sssr &= ~SSSR_TFS; if (VAR_0->rx_level) VAR_0->sssr |= SSSR_RNE; else VAR_0->sssr &= ~SSSR_RNE; VAR_0->sssr |= SSSR_TNF; } pxa2xx_ssp_int_update(VAR_0); }
[ "static void FUNC_0(PXA2xxSSPState *VAR_0)\n{", "VAR_0->sssr &= ~(0xf << 12);", "VAR_0->sssr &= ~(0xf << 8);", "VAR_0->sssr &= ~SSSR_TNF;", "if (VAR_0->enable) {", "VAR_0->sssr |= ((VAR_0->rx_level - 1) & 0xf) << 12;", "if (VAR_0->rx_level >= SSCR1_RFT(VAR_0->sscr[1]))\nVAR_0->sssr |= SSSR_RFS;", "else\nVAR_0->sssr &= ~SSSR_RFS;", "if (0 <= SSCR1_TFT(VAR_0->sscr[1]))\nVAR_0->sssr |= SSSR_TFS;", "else\nVAR_0->sssr &= ~SSSR_TFS;", "if (VAR_0->rx_level)\nVAR_0->sssr |= SSSR_RNE;", "else\nVAR_0->sssr &= ~SSSR_RNE;", "VAR_0->sssr |= SSSR_TNF;", "}", "pxa2xx_ssp_int_update(VAR_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 ] ]
22,208
static void grlib_apbuart_write(void *opaque, target_phys_addr_t addr, uint64_t value, unsigned size) { UART *uart = opaque; unsigned char c = 0; addr &= 0xff; /* Unit registers */ switch (addr) { case DATA_OFFSET: case DATA_OFFSET + 3: /* When only one byte write */ c = value & 0xFF; qemu_chr_fe_write(uart->chr, &c, 1); return; case STATUS_OFFSET: /* Read Only */ return; case CONTROL_OFFSET: uart->control = value; return; case SCALER_OFFSET: /* Not supported */ return; default: break; } trace_grlib_apbuart_writel_unknown(addr, value); }
false
qemu
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
static void grlib_apbuart_write(void *opaque, target_phys_addr_t addr, uint64_t value, unsigned size) { UART *uart = opaque; unsigned char c = 0; addr &= 0xff; switch (addr) { case DATA_OFFSET: case DATA_OFFSET + 3: c = value & 0xFF; qemu_chr_fe_write(uart->chr, &c, 1); return; case STATUS_OFFSET: return; case CONTROL_OFFSET: uart->control = value; return; case SCALER_OFFSET: return; default: break; } trace_grlib_apbuart_writel_unknown(addr, value); }
{ "code": [], "line_no": [] }
static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1, uint64_t VAR_2, unsigned VAR_3) { UART *uart = VAR_0; unsigned char VAR_4 = 0; VAR_1 &= 0xff; switch (VAR_1) { case DATA_OFFSET: case DATA_OFFSET + 3: VAR_4 = VAR_2 & 0xFF; qemu_chr_fe_write(uart->chr, &VAR_4, 1); return; case STATUS_OFFSET: return; case CONTROL_OFFSET: uart->control = VAR_2; return; case SCALER_OFFSET: return; default: break; } trace_grlib_apbuart_writel_unknown(VAR_1, VAR_2); }
[ "static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{", "UART *uart = VAR_0;", "unsigned char VAR_4 = 0;", "VAR_1 &= 0xff;", "switch (VAR_1) {", "case DATA_OFFSET:\ncase DATA_OFFSET + 3:\nVAR_4 = VAR_2 & 0xFF;", "qemu_chr_fe_write(uart->chr, &VAR_4, 1);", "return;", "case STATUS_OFFSET:\nreturn;", "case CONTROL_OFFSET:\nuart->control = VAR_2;", "return;", "case SCALER_OFFSET:\nreturn;", "default:\nbreak;", "}", "trace_grlib_apbuart_writel_unknown(VAR_1, VAR_2);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13 ], [ 19 ], [ 21, 23, 25 ], [ 27 ], [ 29 ], [ 33, 37 ], [ 41, 43 ], [ 45 ], [ 49, 53 ], [ 57, 59 ], [ 61 ], [ 65 ], [ 67 ] ]
22,209
int cpu_x86_handle_mmu_fault(CPUX86State *env, uint32_t addr, int is_write, int is_user, int is_softmmu) { uint8_t *pde_ptr, *pte_ptr; uint32_t pde, pte, virt_addr, ptep; int error_code, is_dirty, prot, page_size, ret; unsigned long paddr, vaddr, page_offset; #if defined(DEBUG_MMU) printf("MMU fault: addr=0x%08x w=%d u=%d eip=%08x\n", addr, is_write, is_user, env->eip); #endif if (env->user_mode_only) { /* user mode only emulation */ error_code = 0; goto do_fault; } if (!(env->cr[0] & CR0_PG_MASK)) { pte = addr; virt_addr = addr & TARGET_PAGE_MASK; prot = PROT_READ | PROT_WRITE; page_size = 4096; goto do_mapping; } /* page directory entry */ pde_ptr = phys_ram_base + (((env->cr[3] & ~0xfff) + ((addr >> 20) & ~3)) & a20_mask); pde = ldl_raw(pde_ptr); if (!(pde & PG_PRESENT_MASK)) { error_code = 0; goto do_fault; } /* if PSE bit is set, then we use a 4MB page */ if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) { if (is_user) { if (!(pde & PG_USER_MASK)) goto do_fault_protect; if (is_write && !(pde & PG_RW_MASK)) goto do_fault_protect; } else { if ((env->cr[0] & CR0_WP_MASK) && (pde & PG_USER_MASK) && is_write && !(pde & PG_RW_MASK)) goto do_fault_protect; } is_dirty = is_write && !(pde & PG_DIRTY_MASK); if (!(pde & PG_ACCESSED_MASK) || is_dirty) { pde |= PG_ACCESSED_MASK; if (is_dirty) pde |= PG_DIRTY_MASK; stl_raw(pde_ptr, pde); } pte = pde & ~0x003ff000; /* align to 4MB */ ptep = pte; page_size = 4096 * 1024; virt_addr = addr & ~0x003fffff; } else { if (!(pde & PG_ACCESSED_MASK)) { pde |= PG_ACCESSED_MASK; stl_raw(pde_ptr, pde); } /* page directory entry */ pte_ptr = phys_ram_base + (((pde & ~0xfff) + ((addr >> 10) & 0xffc)) & a20_mask); pte = ldl_raw(pte_ptr); if (!(pte & PG_PRESENT_MASK)) { error_code = 0; goto do_fault; } /* combine pde and pte user and rw protections */ ptep = pte & pde; if (is_user) { if (!(ptep & PG_USER_MASK)) goto do_fault_protect; if (is_write && !(ptep & PG_RW_MASK)) goto do_fault_protect; } else { if ((env->cr[0] & CR0_WP_MASK) && (ptep & PG_USER_MASK) && is_write && !(ptep & PG_RW_MASK)) goto do_fault_protect; } is_dirty = is_write && !(pte & PG_DIRTY_MASK); if (!(pte & PG_ACCESSED_MASK) || is_dirty) { pte |= PG_ACCESSED_MASK; if (is_dirty) pte |= PG_DIRTY_MASK; stl_raw(pte_ptr, pte); } page_size = 4096; virt_addr = addr & ~0xfff; } /* the page can be put in the TLB */ prot = PROT_READ; if (pte & PG_DIRTY_MASK) { /* only set write access if already dirty... otherwise wait for dirty access */ if (is_user) { if (ptep & PG_RW_MASK) prot |= PROT_WRITE; } else { if (!(env->cr[0] & CR0_WP_MASK) || !(ptep & PG_USER_MASK) || (ptep & PG_RW_MASK)) prot |= PROT_WRITE; } } do_mapping: pte = pte & a20_mask; /* Even if 4MB pages, we map only one 4KB page in the cache to avoid filling it too fast */ page_offset = (addr & TARGET_PAGE_MASK) & (page_size - 1); paddr = (pte & TARGET_PAGE_MASK) + page_offset; vaddr = virt_addr + page_offset; ret = tlb_set_page(env, vaddr, paddr, prot, is_user, is_softmmu); return ret; do_fault_protect: error_code = PG_ERROR_P_MASK; do_fault: env->cr[2] = addr; env->error_code = (is_write << PG_ERROR_W_BIT) | error_code; if (is_user) env->error_code |= PG_ERROR_U_MASK; return 1; }
false
qemu
1ac157da77c863b62b1d2f467626a440d57cf17d
int cpu_x86_handle_mmu_fault(CPUX86State *env, uint32_t addr, int is_write, int is_user, int is_softmmu) { uint8_t *pde_ptr, *pte_ptr; uint32_t pde, pte, virt_addr, ptep; int error_code, is_dirty, prot, page_size, ret; unsigned long paddr, vaddr, page_offset; #if defined(DEBUG_MMU) printf("MMU fault: addr=0x%08x w=%d u=%d eip=%08x\n", addr, is_write, is_user, env->eip); #endif if (env->user_mode_only) { error_code = 0; goto do_fault; } if (!(env->cr[0] & CR0_PG_MASK)) { pte = addr; virt_addr = addr & TARGET_PAGE_MASK; prot = PROT_READ | PROT_WRITE; page_size = 4096; goto do_mapping; } pde_ptr = phys_ram_base + (((env->cr[3] & ~0xfff) + ((addr >> 20) & ~3)) & a20_mask); pde = ldl_raw(pde_ptr); if (!(pde & PG_PRESENT_MASK)) { error_code = 0; goto do_fault; } if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) { if (is_user) { if (!(pde & PG_USER_MASK)) goto do_fault_protect; if (is_write && !(pde & PG_RW_MASK)) goto do_fault_protect; } else { if ((env->cr[0] & CR0_WP_MASK) && (pde & PG_USER_MASK) && is_write && !(pde & PG_RW_MASK)) goto do_fault_protect; } is_dirty = is_write && !(pde & PG_DIRTY_MASK); if (!(pde & PG_ACCESSED_MASK) || is_dirty) { pde |= PG_ACCESSED_MASK; if (is_dirty) pde |= PG_DIRTY_MASK; stl_raw(pde_ptr, pde); } pte = pde & ~0x003ff000; ptep = pte; page_size = 4096 * 1024; virt_addr = addr & ~0x003fffff; } else { if (!(pde & PG_ACCESSED_MASK)) { pde |= PG_ACCESSED_MASK; stl_raw(pde_ptr, pde); } pte_ptr = phys_ram_base + (((pde & ~0xfff) + ((addr >> 10) & 0xffc)) & a20_mask); pte = ldl_raw(pte_ptr); if (!(pte & PG_PRESENT_MASK)) { error_code = 0; goto do_fault; } ptep = pte & pde; if (is_user) { if (!(ptep & PG_USER_MASK)) goto do_fault_protect; if (is_write && !(ptep & PG_RW_MASK)) goto do_fault_protect; } else { if ((env->cr[0] & CR0_WP_MASK) && (ptep & PG_USER_MASK) && is_write && !(ptep & PG_RW_MASK)) goto do_fault_protect; } is_dirty = is_write && !(pte & PG_DIRTY_MASK); if (!(pte & PG_ACCESSED_MASK) || is_dirty) { pte |= PG_ACCESSED_MASK; if (is_dirty) pte |= PG_DIRTY_MASK; stl_raw(pte_ptr, pte); } page_size = 4096; virt_addr = addr & ~0xfff; } prot = PROT_READ; if (pte & PG_DIRTY_MASK) { if (is_user) { if (ptep & PG_RW_MASK) prot |= PROT_WRITE; } else { if (!(env->cr[0] & CR0_WP_MASK) || !(ptep & PG_USER_MASK) || (ptep & PG_RW_MASK)) prot |= PROT_WRITE; } } do_mapping: pte = pte & a20_mask; page_offset = (addr & TARGET_PAGE_MASK) & (page_size - 1); paddr = (pte & TARGET_PAGE_MASK) + page_offset; vaddr = virt_addr + page_offset; ret = tlb_set_page(env, vaddr, paddr, prot, is_user, is_softmmu); return ret; do_fault_protect: error_code = PG_ERROR_P_MASK; do_fault: env->cr[2] = addr; env->error_code = (is_write << PG_ERROR_W_BIT) | error_code; if (is_user) env->error_code |= PG_ERROR_U_MASK; return 1; }
{ "code": [], "line_no": [] }
int FUNC_0(CPUX86State *VAR_0, uint32_t VAR_1, int VAR_2, int VAR_3, int VAR_4) { uint8_t *pde_ptr, *pte_ptr; uint32_t pde, pte, virt_addr, ptep; int VAR_5, VAR_6, VAR_7, VAR_8, VAR_9; unsigned long VAR_10, VAR_11, VAR_12; #if defined(DEBUG_MMU) printf("MMU fault: VAR_1=0x%08x w=%d u=%d eip=%08x\n", VAR_1, VAR_2, VAR_3, VAR_0->eip); #endif if (VAR_0->user_mode_only) { VAR_5 = 0; goto do_fault; } if (!(VAR_0->cr[0] & CR0_PG_MASK)) { pte = VAR_1; virt_addr = VAR_1 & TARGET_PAGE_MASK; VAR_7 = PROT_READ | PROT_WRITE; VAR_8 = 4096; goto do_mapping; } pde_ptr = phys_ram_base + (((VAR_0->cr[3] & ~0xfff) + ((VAR_1 >> 20) & ~3)) & a20_mask); pde = ldl_raw(pde_ptr); if (!(pde & PG_PRESENT_MASK)) { VAR_5 = 0; goto do_fault; } if ((pde & PG_PSE_MASK) && (VAR_0->cr[4] & CR4_PSE_MASK)) { if (VAR_3) { if (!(pde & PG_USER_MASK)) goto do_fault_protect; if (VAR_2 && !(pde & PG_RW_MASK)) goto do_fault_protect; } else { if ((VAR_0->cr[0] & CR0_WP_MASK) && (pde & PG_USER_MASK) && VAR_2 && !(pde & PG_RW_MASK)) goto do_fault_protect; } VAR_6 = VAR_2 && !(pde & PG_DIRTY_MASK); if (!(pde & PG_ACCESSED_MASK) || VAR_6) { pde |= PG_ACCESSED_MASK; if (VAR_6) pde |= PG_DIRTY_MASK; stl_raw(pde_ptr, pde); } pte = pde & ~0x003ff000; ptep = pte; VAR_8 = 4096 * 1024; virt_addr = VAR_1 & ~0x003fffff; } else { if (!(pde & PG_ACCESSED_MASK)) { pde |= PG_ACCESSED_MASK; stl_raw(pde_ptr, pde); } pte_ptr = phys_ram_base + (((pde & ~0xfff) + ((VAR_1 >> 10) & 0xffc)) & a20_mask); pte = ldl_raw(pte_ptr); if (!(pte & PG_PRESENT_MASK)) { VAR_5 = 0; goto do_fault; } ptep = pte & pde; if (VAR_3) { if (!(ptep & PG_USER_MASK)) goto do_fault_protect; if (VAR_2 && !(ptep & PG_RW_MASK)) goto do_fault_protect; } else { if ((VAR_0->cr[0] & CR0_WP_MASK) && (ptep & PG_USER_MASK) && VAR_2 && !(ptep & PG_RW_MASK)) goto do_fault_protect; } VAR_6 = VAR_2 && !(pte & PG_DIRTY_MASK); if (!(pte & PG_ACCESSED_MASK) || VAR_6) { pte |= PG_ACCESSED_MASK; if (VAR_6) pte |= PG_DIRTY_MASK; stl_raw(pte_ptr, pte); } VAR_8 = 4096; virt_addr = VAR_1 & ~0xfff; } VAR_7 = PROT_READ; if (pte & PG_DIRTY_MASK) { if (VAR_3) { if (ptep & PG_RW_MASK) VAR_7 |= PROT_WRITE; } else { if (!(VAR_0->cr[0] & CR0_WP_MASK) || !(ptep & PG_USER_MASK) || (ptep & PG_RW_MASK)) VAR_7 |= PROT_WRITE; } } do_mapping: pte = pte & a20_mask; VAR_12 = (VAR_1 & TARGET_PAGE_MASK) & (VAR_8 - 1); VAR_10 = (pte & TARGET_PAGE_MASK) + VAR_12; VAR_11 = virt_addr + VAR_12; VAR_9 = tlb_set_page(VAR_0, VAR_11, VAR_10, VAR_7, VAR_3, VAR_4); return VAR_9; do_fault_protect: VAR_5 = PG_ERROR_P_MASK; do_fault: VAR_0->cr[2] = VAR_1; VAR_0->VAR_5 = (VAR_2 << PG_ERROR_W_BIT) | VAR_5; if (VAR_3) VAR_0->VAR_5 |= PG_ERROR_U_MASK; return 1; }
[ "int FUNC_0(CPUX86State *VAR_0, uint32_t VAR_1,\nint VAR_2, int VAR_3, int VAR_4)\n{", "uint8_t *pde_ptr, *pte_ptr;", "uint32_t pde, pte, virt_addr, ptep;", "int VAR_5, VAR_6, VAR_7, VAR_8, VAR_9;", "unsigned long VAR_10, VAR_11, VAR_12;", "#if defined(DEBUG_MMU)\nprintf(\"MMU fault: VAR_1=0x%08x w=%d u=%d eip=%08x\\n\",\nVAR_1, VAR_2, VAR_3, VAR_0->eip);", "#endif\nif (VAR_0->user_mode_only) {", "VAR_5 = 0;", "goto do_fault;", "}", "if (!(VAR_0->cr[0] & CR0_PG_MASK)) {", "pte = VAR_1;", "virt_addr = VAR_1 & TARGET_PAGE_MASK;", "VAR_7 = PROT_READ | PROT_WRITE;", "VAR_8 = 4096;", "goto do_mapping;", "}", "pde_ptr = phys_ram_base +\n(((VAR_0->cr[3] & ~0xfff) + ((VAR_1 >> 20) & ~3)) & a20_mask);", "pde = ldl_raw(pde_ptr);", "if (!(pde & PG_PRESENT_MASK)) {", "VAR_5 = 0;", "goto do_fault;", "}", "if ((pde & PG_PSE_MASK) && (VAR_0->cr[4] & CR4_PSE_MASK)) {", "if (VAR_3) {", "if (!(pde & PG_USER_MASK))\ngoto do_fault_protect;", "if (VAR_2 && !(pde & PG_RW_MASK))\ngoto do_fault_protect;", "} else {", "if ((VAR_0->cr[0] & CR0_WP_MASK) && (pde & PG_USER_MASK) &&\nVAR_2 && !(pde & PG_RW_MASK))\ngoto do_fault_protect;", "}", "VAR_6 = VAR_2 && !(pde & PG_DIRTY_MASK);", "if (!(pde & PG_ACCESSED_MASK) || VAR_6) {", "pde |= PG_ACCESSED_MASK;", "if (VAR_6)\npde |= PG_DIRTY_MASK;", "stl_raw(pde_ptr, pde);", "}", "pte = pde & ~0x003ff000;", "ptep = pte;", "VAR_8 = 4096 * 1024;", "virt_addr = VAR_1 & ~0x003fffff;", "} else {", "if (!(pde & PG_ACCESSED_MASK)) {", "pde |= PG_ACCESSED_MASK;", "stl_raw(pde_ptr, pde);", "}", "pte_ptr = phys_ram_base +\n(((pde & ~0xfff) + ((VAR_1 >> 10) & 0xffc)) & a20_mask);", "pte = ldl_raw(pte_ptr);", "if (!(pte & PG_PRESENT_MASK)) {", "VAR_5 = 0;", "goto do_fault;", "}", "ptep = pte & pde;", "if (VAR_3) {", "if (!(ptep & PG_USER_MASK))\ngoto do_fault_protect;", "if (VAR_2 && !(ptep & PG_RW_MASK))\ngoto do_fault_protect;", "} else {", "if ((VAR_0->cr[0] & CR0_WP_MASK) && (ptep & PG_USER_MASK) &&\nVAR_2 && !(ptep & PG_RW_MASK))\ngoto do_fault_protect;", "}", "VAR_6 = VAR_2 && !(pte & PG_DIRTY_MASK);", "if (!(pte & PG_ACCESSED_MASK) || VAR_6) {", "pte |= PG_ACCESSED_MASK;", "if (VAR_6)\npte |= PG_DIRTY_MASK;", "stl_raw(pte_ptr, pte);", "}", "VAR_8 = 4096;", "virt_addr = VAR_1 & ~0xfff;", "}", "VAR_7 = PROT_READ;", "if (pte & PG_DIRTY_MASK) {", "if (VAR_3) {", "if (ptep & PG_RW_MASK)\nVAR_7 |= PROT_WRITE;", "} else {", "if (!(VAR_0->cr[0] & CR0_WP_MASK) || !(ptep & PG_USER_MASK) ||\n(ptep & PG_RW_MASK))\nVAR_7 |= PROT_WRITE;", "}", "}", "do_mapping:\npte = pte & a20_mask;", "VAR_12 = (VAR_1 & TARGET_PAGE_MASK) & (VAR_8 - 1);", "VAR_10 = (pte & TARGET_PAGE_MASK) + VAR_12;", "VAR_11 = virt_addr + VAR_12;", "VAR_9 = tlb_set_page(VAR_0, VAR_11, VAR_10, VAR_7, VAR_3, VAR_4);", "return VAR_9;", "do_fault_protect:\nVAR_5 = PG_ERROR_P_MASK;", "do_fault:\nVAR_0->cr[2] = VAR_1;", "VAR_0->VAR_5 = (VAR_2 << PG_ERROR_W_BIT) | VAR_5;", "if (VAR_3)\nVAR_0->VAR_5 |= PG_ERROR_U_MASK;", "return 1;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17, 19, 21 ], [ 23, 27 ], [ 31 ], [ 33 ], [ 35 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 57, 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 73 ], [ 75 ], [ 77, 79 ], [ 81, 83 ], [ 85 ], [ 87, 89, 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101, 103 ], [ 105 ], [ 107 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 133, 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 149 ], [ 151 ], [ 153, 155 ], [ 157, 159 ], [ 161 ], [ 163, 165, 167 ], [ 169 ], [ 171 ], [ 173 ], [ 175 ], [ 177, 179 ], [ 181 ], [ 183 ], [ 185 ], [ 187 ], [ 189 ], [ 195 ], [ 197 ], [ 203 ], [ 205, 207 ], [ 209 ], [ 211, 213, 215 ], [ 217 ], [ 219 ], [ 223, 225 ], [ 233 ], [ 235 ], [ 237 ], [ 241 ], [ 243 ], [ 245, 247 ], [ 249, 251 ], [ 253 ], [ 255, 257 ], [ 259 ], [ 261 ] ]
22,210
static void term_delete_char(void) { if (term_cmd_buf_index < term_cmd_buf_size) { memmove(term_cmd_buf + term_cmd_buf_index, term_cmd_buf + term_cmd_buf_index + 1, term_cmd_buf_size - term_cmd_buf_index - 1); term_cmd_buf_size--; } }
false
qemu
7e2515e87c41e2e658aaed466e11cbdf1ea8bcb1
static void term_delete_char(void) { if (term_cmd_buf_index < term_cmd_buf_size) { memmove(term_cmd_buf + term_cmd_buf_index, term_cmd_buf + term_cmd_buf_index + 1, term_cmd_buf_size - term_cmd_buf_index - 1); term_cmd_buf_size--; } }
{ "code": [], "line_no": [] }
static void FUNC_0(void) { if (term_cmd_buf_index < term_cmd_buf_size) { memmove(term_cmd_buf + term_cmd_buf_index, term_cmd_buf + term_cmd_buf_index + 1, term_cmd_buf_size - term_cmd_buf_index - 1); term_cmd_buf_size--; } }
[ "static void FUNC_0(void)\n{", "if (term_cmd_buf_index < term_cmd_buf_size) {", "memmove(term_cmd_buf + term_cmd_buf_index,\nterm_cmd_buf + term_cmd_buf_index + 1,\nterm_cmd_buf_size - term_cmd_buf_index - 1);", "term_cmd_buf_size--;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7, 9, 11 ], [ 13 ], [ 15 ], [ 17 ] ]
22,211
static void sch_handle_start_func(SubchDev *sch, ORB *orb) { PMCW *p = &sch->curr_status.pmcw; SCSW *s = &sch->curr_status.scsw; int path; int ret; bool suspend_allowed; /* Path management: In our simple css, we always choose the only path. */ path = 0x80; if (!(s->ctrl & SCSW_ACTL_SUSP)) { /* Start Function triggered via ssch, i.e. we have an ORB */ s->cstat = 0; s->dstat = 0; /* Look at the orb and try to execute the channel program. */ assert(orb != NULL); /* resume does not pass an orb */ p->intparm = orb->intparm; if (!(orb->lpm & path)) { /* Generate a deferred cc 3 condition. */ s->flags |= SCSW_FLAGS_MASK_CC; s->ctrl &= ~SCSW_CTRL_MASK_STCTL; s->ctrl |= (SCSW_STCTL_ALERT | SCSW_STCTL_STATUS_PEND); return; } sch->ccw_fmt_1 = !!(orb->ctrl0 & ORB_CTRL0_MASK_FMT); s->flags |= (sch->ccw_fmt_1) ? SCSW_FLAGS_MASK_FMT : 0; sch->ccw_no_data_cnt = 0; suspend_allowed = !!(orb->ctrl0 & ORB_CTRL0_MASK_SPND); } else { /* Start Function resumed via rsch, i.e. we don't have an * ORB */ s->ctrl &= ~(SCSW_ACTL_SUSP | SCSW_ACTL_RESUME_PEND); /* The channel program had been suspended before. */ suspend_allowed = true; } sch->last_cmd_valid = false; do { ret = css_interpret_ccw(sch, sch->channel_prog, suspend_allowed); switch (ret) { case -EAGAIN: /* ccw chain, continue processing */ break; case 0: /* success */ s->ctrl &= ~SCSW_ACTL_START_PEND; s->ctrl &= ~SCSW_CTRL_MASK_STCTL; s->ctrl |= SCSW_STCTL_PRIMARY | SCSW_STCTL_SECONDARY | SCSW_STCTL_STATUS_PEND; s->dstat = SCSW_DSTAT_CHANNEL_END | SCSW_DSTAT_DEVICE_END; s->cpa = sch->channel_prog + 8; break; case -EIO: /* I/O errors, status depends on specific devices */ break; case -ENOSYS: /* unsupported command, generate unit check (command reject) */ s->ctrl &= ~SCSW_ACTL_START_PEND; s->dstat = SCSW_DSTAT_UNIT_CHECK; /* Set sense bit 0 in ecw0. */ sch->sense_data[0] = 0x80; s->ctrl &= ~SCSW_CTRL_MASK_STCTL; s->ctrl |= SCSW_STCTL_PRIMARY | SCSW_STCTL_SECONDARY | SCSW_STCTL_ALERT | SCSW_STCTL_STATUS_PEND; s->cpa = sch->channel_prog + 8; break; case -EFAULT: /* memory problem, generate channel data check */ s->ctrl &= ~SCSW_ACTL_START_PEND; s->cstat = SCSW_CSTAT_DATA_CHECK; s->ctrl &= ~SCSW_CTRL_MASK_STCTL; s->ctrl |= SCSW_STCTL_PRIMARY | SCSW_STCTL_SECONDARY | SCSW_STCTL_ALERT | SCSW_STCTL_STATUS_PEND; s->cpa = sch->channel_prog + 8; break; case -EBUSY: /* subchannel busy, generate deferred cc 1 */ s->flags &= ~SCSW_FLAGS_MASK_CC; s->flags |= (1 << 8); s->ctrl &= ~SCSW_CTRL_MASK_STCTL; s->ctrl |= SCSW_STCTL_ALERT | SCSW_STCTL_STATUS_PEND; break; case -EINPROGRESS: /* channel program has been suspended */ s->ctrl &= ~SCSW_ACTL_START_PEND; s->ctrl |= SCSW_ACTL_SUSP; break; default: /* error, generate channel program check */ s->ctrl &= ~SCSW_ACTL_START_PEND; s->cstat = SCSW_CSTAT_PROG_CHECK; s->ctrl &= ~SCSW_CTRL_MASK_STCTL; s->ctrl |= SCSW_STCTL_PRIMARY | SCSW_STCTL_SECONDARY | SCSW_STCTL_ALERT | SCSW_STCTL_STATUS_PEND; s->cpa = sch->channel_prog + 8; break; } } while (ret == -EAGAIN); }
false
qemu
bab482d7405f9fe3cac9c213d60f9ca9442c047b
static void sch_handle_start_func(SubchDev *sch, ORB *orb) { PMCW *p = &sch->curr_status.pmcw; SCSW *s = &sch->curr_status.scsw; int path; int ret; bool suspend_allowed; path = 0x80; if (!(s->ctrl & SCSW_ACTL_SUSP)) { s->cstat = 0; s->dstat = 0; assert(orb != NULL); p->intparm = orb->intparm; if (!(orb->lpm & path)) { s->flags |= SCSW_FLAGS_MASK_CC; s->ctrl &= ~SCSW_CTRL_MASK_STCTL; s->ctrl |= (SCSW_STCTL_ALERT | SCSW_STCTL_STATUS_PEND); return; } sch->ccw_fmt_1 = !!(orb->ctrl0 & ORB_CTRL0_MASK_FMT); s->flags |= (sch->ccw_fmt_1) ? SCSW_FLAGS_MASK_FMT : 0; sch->ccw_no_data_cnt = 0; suspend_allowed = !!(orb->ctrl0 & ORB_CTRL0_MASK_SPND); } else { s->ctrl &= ~(SCSW_ACTL_SUSP | SCSW_ACTL_RESUME_PEND); suspend_allowed = true; } sch->last_cmd_valid = false; do { ret = css_interpret_ccw(sch, sch->channel_prog, suspend_allowed); switch (ret) { case -EAGAIN: break; case 0: s->ctrl &= ~SCSW_ACTL_START_PEND; s->ctrl &= ~SCSW_CTRL_MASK_STCTL; s->ctrl |= SCSW_STCTL_PRIMARY | SCSW_STCTL_SECONDARY | SCSW_STCTL_STATUS_PEND; s->dstat = SCSW_DSTAT_CHANNEL_END | SCSW_DSTAT_DEVICE_END; s->cpa = sch->channel_prog + 8; break; case -EIO: break; case -ENOSYS: s->ctrl &= ~SCSW_ACTL_START_PEND; s->dstat = SCSW_DSTAT_UNIT_CHECK; sch->sense_data[0] = 0x80; s->ctrl &= ~SCSW_CTRL_MASK_STCTL; s->ctrl |= SCSW_STCTL_PRIMARY | SCSW_STCTL_SECONDARY | SCSW_STCTL_ALERT | SCSW_STCTL_STATUS_PEND; s->cpa = sch->channel_prog + 8; break; case -EFAULT: s->ctrl &= ~SCSW_ACTL_START_PEND; s->cstat = SCSW_CSTAT_DATA_CHECK; s->ctrl &= ~SCSW_CTRL_MASK_STCTL; s->ctrl |= SCSW_STCTL_PRIMARY | SCSW_STCTL_SECONDARY | SCSW_STCTL_ALERT | SCSW_STCTL_STATUS_PEND; s->cpa = sch->channel_prog + 8; break; case -EBUSY: s->flags &= ~SCSW_FLAGS_MASK_CC; s->flags |= (1 << 8); s->ctrl &= ~SCSW_CTRL_MASK_STCTL; s->ctrl |= SCSW_STCTL_ALERT | SCSW_STCTL_STATUS_PEND; break; case -EINPROGRESS: s->ctrl &= ~SCSW_ACTL_START_PEND; s->ctrl |= SCSW_ACTL_SUSP; break; default: s->ctrl &= ~SCSW_ACTL_START_PEND; s->cstat = SCSW_CSTAT_PROG_CHECK; s->ctrl &= ~SCSW_CTRL_MASK_STCTL; s->ctrl |= SCSW_STCTL_PRIMARY | SCSW_STCTL_SECONDARY | SCSW_STCTL_ALERT | SCSW_STCTL_STATUS_PEND; s->cpa = sch->channel_prog + 8; break; } } while (ret == -EAGAIN); }
{ "code": [], "line_no": [] }
static void FUNC_0(SubchDev *VAR_0, ORB *VAR_1) { PMCW *p = &VAR_0->curr_status.pmcw; SCSW *s = &VAR_0->curr_status.scsw; int VAR_2; int VAR_3; bool suspend_allowed; VAR_2 = 0x80; if (!(s->ctrl & SCSW_ACTL_SUSP)) { s->cstat = 0; s->dstat = 0; assert(VAR_1 != NULL); p->intparm = VAR_1->intparm; if (!(VAR_1->lpm & VAR_2)) { s->flags |= SCSW_FLAGS_MASK_CC; s->ctrl &= ~SCSW_CTRL_MASK_STCTL; s->ctrl |= (SCSW_STCTL_ALERT | SCSW_STCTL_STATUS_PEND); return; } VAR_0->ccw_fmt_1 = !!(VAR_1->ctrl0 & ORB_CTRL0_MASK_FMT); s->flags |= (VAR_0->ccw_fmt_1) ? SCSW_FLAGS_MASK_FMT : 0; VAR_0->ccw_no_data_cnt = 0; suspend_allowed = !!(VAR_1->ctrl0 & ORB_CTRL0_MASK_SPND); } else { s->ctrl &= ~(SCSW_ACTL_SUSP | SCSW_ACTL_RESUME_PEND); suspend_allowed = true; } VAR_0->last_cmd_valid = false; do { VAR_3 = css_interpret_ccw(VAR_0, VAR_0->channel_prog, suspend_allowed); switch (VAR_3) { case -EAGAIN: break; case 0: s->ctrl &= ~SCSW_ACTL_START_PEND; s->ctrl &= ~SCSW_CTRL_MASK_STCTL; s->ctrl |= SCSW_STCTL_PRIMARY | SCSW_STCTL_SECONDARY | SCSW_STCTL_STATUS_PEND; s->dstat = SCSW_DSTAT_CHANNEL_END | SCSW_DSTAT_DEVICE_END; s->cpa = VAR_0->channel_prog + 8; break; case -EIO: break; case -ENOSYS: s->ctrl &= ~SCSW_ACTL_START_PEND; s->dstat = SCSW_DSTAT_UNIT_CHECK; VAR_0->sense_data[0] = 0x80; s->ctrl &= ~SCSW_CTRL_MASK_STCTL; s->ctrl |= SCSW_STCTL_PRIMARY | SCSW_STCTL_SECONDARY | SCSW_STCTL_ALERT | SCSW_STCTL_STATUS_PEND; s->cpa = VAR_0->channel_prog + 8; break; case -EFAULT: s->ctrl &= ~SCSW_ACTL_START_PEND; s->cstat = SCSW_CSTAT_DATA_CHECK; s->ctrl &= ~SCSW_CTRL_MASK_STCTL; s->ctrl |= SCSW_STCTL_PRIMARY | SCSW_STCTL_SECONDARY | SCSW_STCTL_ALERT | SCSW_STCTL_STATUS_PEND; s->cpa = VAR_0->channel_prog + 8; break; case -EBUSY: s->flags &= ~SCSW_FLAGS_MASK_CC; s->flags |= (1 << 8); s->ctrl &= ~SCSW_CTRL_MASK_STCTL; s->ctrl |= SCSW_STCTL_ALERT | SCSW_STCTL_STATUS_PEND; break; case -EINPROGRESS: s->ctrl &= ~SCSW_ACTL_START_PEND; s->ctrl |= SCSW_ACTL_SUSP; break; default: s->ctrl &= ~SCSW_ACTL_START_PEND; s->cstat = SCSW_CSTAT_PROG_CHECK; s->ctrl &= ~SCSW_CTRL_MASK_STCTL; s->ctrl |= SCSW_STCTL_PRIMARY | SCSW_STCTL_SECONDARY | SCSW_STCTL_ALERT | SCSW_STCTL_STATUS_PEND; s->cpa = VAR_0->channel_prog + 8; break; } } while (VAR_3 == -EAGAIN); }
[ "static void FUNC_0(SubchDev *VAR_0, ORB *VAR_1)\n{", "PMCW *p = &VAR_0->curr_status.pmcw;", "SCSW *s = &VAR_0->curr_status.scsw;", "int VAR_2;", "int VAR_3;", "bool suspend_allowed;", "VAR_2 = 0x80;", "if (!(s->ctrl & SCSW_ACTL_SUSP)) {", "s->cstat = 0;", "s->dstat = 0;", "assert(VAR_1 != NULL);", "p->intparm = VAR_1->intparm;", "if (!(VAR_1->lpm & VAR_2)) {", "s->flags |= SCSW_FLAGS_MASK_CC;", "s->ctrl &= ~SCSW_CTRL_MASK_STCTL;", "s->ctrl |= (SCSW_STCTL_ALERT | SCSW_STCTL_STATUS_PEND);", "return;", "}", "VAR_0->ccw_fmt_1 = !!(VAR_1->ctrl0 & ORB_CTRL0_MASK_FMT);", "s->flags |= (VAR_0->ccw_fmt_1) ? SCSW_FLAGS_MASK_FMT : 0;", "VAR_0->ccw_no_data_cnt = 0;", "suspend_allowed = !!(VAR_1->ctrl0 & ORB_CTRL0_MASK_SPND);", "} else {", "s->ctrl &= ~(SCSW_ACTL_SUSP | SCSW_ACTL_RESUME_PEND);", "suspend_allowed = true;", "}", "VAR_0->last_cmd_valid = false;", "do {", "VAR_3 = css_interpret_ccw(VAR_0, VAR_0->channel_prog, suspend_allowed);", "switch (VAR_3) {", "case -EAGAIN:\nbreak;", "case 0:\ns->ctrl &= ~SCSW_ACTL_START_PEND;", "s->ctrl &= ~SCSW_CTRL_MASK_STCTL;", "s->ctrl |= SCSW_STCTL_PRIMARY | SCSW_STCTL_SECONDARY |\nSCSW_STCTL_STATUS_PEND;", "s->dstat = SCSW_DSTAT_CHANNEL_END | SCSW_DSTAT_DEVICE_END;", "s->cpa = VAR_0->channel_prog + 8;", "break;", "case -EIO:\nbreak;", "case -ENOSYS:\ns->ctrl &= ~SCSW_ACTL_START_PEND;", "s->dstat = SCSW_DSTAT_UNIT_CHECK;", "VAR_0->sense_data[0] = 0x80;", "s->ctrl &= ~SCSW_CTRL_MASK_STCTL;", "s->ctrl |= SCSW_STCTL_PRIMARY | SCSW_STCTL_SECONDARY |\nSCSW_STCTL_ALERT | SCSW_STCTL_STATUS_PEND;", "s->cpa = VAR_0->channel_prog + 8;", "break;", "case -EFAULT:\ns->ctrl &= ~SCSW_ACTL_START_PEND;", "s->cstat = SCSW_CSTAT_DATA_CHECK;", "s->ctrl &= ~SCSW_CTRL_MASK_STCTL;", "s->ctrl |= SCSW_STCTL_PRIMARY | SCSW_STCTL_SECONDARY |\nSCSW_STCTL_ALERT | SCSW_STCTL_STATUS_PEND;", "s->cpa = VAR_0->channel_prog + 8;", "break;", "case -EBUSY:\ns->flags &= ~SCSW_FLAGS_MASK_CC;", "s->flags |= (1 << 8);", "s->ctrl &= ~SCSW_CTRL_MASK_STCTL;", "s->ctrl |= SCSW_STCTL_ALERT | SCSW_STCTL_STATUS_PEND;", "break;", "case -EINPROGRESS:\ns->ctrl &= ~SCSW_ACTL_START_PEND;", "s->ctrl |= SCSW_ACTL_SUSP;", "break;", "default:\ns->ctrl &= ~SCSW_ACTL_START_PEND;", "s->cstat = SCSW_CSTAT_PROG_CHECK;", "s->ctrl &= ~SCSW_CTRL_MASK_STCTL;", "s->ctrl |= SCSW_STCTL_PRIMARY | SCSW_STCTL_SECONDARY |\nSCSW_STCTL_ALERT | SCSW_STCTL_STATUS_PEND;", "s->cpa = VAR_0->channel_prog + 8;", "break;", "}", "} while (VAR_3 == -EAGAIN);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 21 ], [ 25 ], [ 29 ], [ 31 ], [ 35 ], [ 37 ], [ 39 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 67 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83, 87 ], [ 89, 93 ], [ 95 ], [ 97, 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107, 111 ], [ 113, 117 ], [ 119 ], [ 123 ], [ 125 ], [ 127, 129 ], [ 131 ], [ 133 ], [ 135, 139 ], [ 141 ], [ 143 ], [ 145, 147 ], [ 149 ], [ 151 ], [ 153, 157 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 167, 171 ], [ 173 ], [ 175 ], [ 177, 181 ], [ 183 ], [ 185 ], [ 187, 189 ], [ 191 ], [ 193 ], [ 195 ], [ 197 ], [ 201 ] ]
22,212
QEMUFile *qemu_fopen_ops_buffered(MigrationState *migration_state) { QEMUFileBuffered *s; s = g_malloc0(sizeof(*s)); s->migration_state = migration_state; s->xfer_limit = migration_state->bandwidth_limit / 10; s->file = qemu_fopen_ops(s, &buffered_file_ops); s->timer = qemu_new_timer_ms(rt_clock, buffered_rate_tick, s); qemu_mod_timer(s->timer, qemu_get_clock_ms(rt_clock) + 100); return s->file; }
false
qemu
c09f4cb2b3243085a86aee3c7ed4f31c77e4db87
QEMUFile *qemu_fopen_ops_buffered(MigrationState *migration_state) { QEMUFileBuffered *s; s = g_malloc0(sizeof(*s)); s->migration_state = migration_state; s->xfer_limit = migration_state->bandwidth_limit / 10; s->file = qemu_fopen_ops(s, &buffered_file_ops); s->timer = qemu_new_timer_ms(rt_clock, buffered_rate_tick, s); qemu_mod_timer(s->timer, qemu_get_clock_ms(rt_clock) + 100); return s->file; }
{ "code": [], "line_no": [] }
QEMUFile *FUNC_0(MigrationState *migration_state) { QEMUFileBuffered *s; s = g_malloc0(sizeof(*s)); s->migration_state = migration_state; s->xfer_limit = migration_state->bandwidth_limit / 10; s->file = qemu_fopen_ops(s, &buffered_file_ops); s->timer = qemu_new_timer_ms(rt_clock, buffered_rate_tick, s); qemu_mod_timer(s->timer, qemu_get_clock_ms(rt_clock) + 100); return s->file; }
[ "QEMUFile *FUNC_0(MigrationState *migration_state)\n{", "QEMUFileBuffered *s;", "s = g_malloc0(sizeof(*s));", "s->migration_state = migration_state;", "s->xfer_limit = migration_state->bandwidth_limit / 10;", "s->file = qemu_fopen_ops(s, &buffered_file_ops);", "s->timer = qemu_new_timer_ms(rt_clock, buffered_rate_tick, s);", "qemu_mod_timer(s->timer, qemu_get_clock_ms(rt_clock) + 100);", "return s->file;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 13 ], [ 15 ], [ 19 ], [ 23 ], [ 27 ], [ 31 ], [ 33 ] ]
22,214
static int walk_memory_regions_1(struct walk_memory_regions_data *data, abi_ulong base, int level, void **lp) { abi_ulong pa; int i, rc; if (*lp == NULL) { return walk_memory_regions_end(data, base, 0); } if (level == 0) { PageDesc *pd = *lp; for (i = 0; i < L2_SIZE; ++i) { int prot = pd[i].flags; pa = base | (i << TARGET_PAGE_BITS); if (prot != data->prot) { rc = walk_memory_regions_end(data, pa, prot); if (rc != 0) { return rc; } } } } else { void **pp = *lp; for (i = 0; i < L2_SIZE; ++i) { pa = base | ((abi_ulong)i << (TARGET_PAGE_BITS + L2_BITS * level)); rc = walk_memory_regions_1(data, pa, level - 1, pp + i); if (rc != 0) { return rc; } } } return 0; }
false
qemu
03f4995781a64e106e6f73864a1e9c4163dac53b
static int walk_memory_regions_1(struct walk_memory_regions_data *data, abi_ulong base, int level, void **lp) { abi_ulong pa; int i, rc; if (*lp == NULL) { return walk_memory_regions_end(data, base, 0); } if (level == 0) { PageDesc *pd = *lp; for (i = 0; i < L2_SIZE; ++i) { int prot = pd[i].flags; pa = base | (i << TARGET_PAGE_BITS); if (prot != data->prot) { rc = walk_memory_regions_end(data, pa, prot); if (rc != 0) { return rc; } } } } else { void **pp = *lp; for (i = 0; i < L2_SIZE; ++i) { pa = base | ((abi_ulong)i << (TARGET_PAGE_BITS + L2_BITS * level)); rc = walk_memory_regions_1(data, pa, level - 1, pp + i); if (rc != 0) { return rc; } } } return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(struct walk_memory_regions_data *VAR_0, abi_ulong VAR_1, int VAR_2, void **VAR_3) { abi_ulong pa; int VAR_4, VAR_5; if (*VAR_3 == NULL) { return walk_memory_regions_end(VAR_0, VAR_1, 0); } if (VAR_2 == 0) { PageDesc *pd = *VAR_3; for (VAR_4 = 0; VAR_4 < L2_SIZE; ++VAR_4) { int prot = pd[VAR_4].flags; pa = VAR_1 | (VAR_4 << TARGET_PAGE_BITS); if (prot != VAR_0->prot) { VAR_5 = walk_memory_regions_end(VAR_0, pa, prot); if (VAR_5 != 0) { return VAR_5; } } } } else { void **VAR_6 = *VAR_3; for (VAR_4 = 0; VAR_4 < L2_SIZE; ++VAR_4) { pa = VAR_1 | ((abi_ulong)VAR_4 << (TARGET_PAGE_BITS + L2_BITS * VAR_2)); VAR_5 = FUNC_0(VAR_0, pa, VAR_2 - 1, VAR_6 + VAR_4); if (VAR_5 != 0) { return VAR_5; } } } return 0; }
[ "static int FUNC_0(struct walk_memory_regions_data *VAR_0,\nabi_ulong VAR_1, int VAR_2, void **VAR_3)\n{", "abi_ulong pa;", "int VAR_4, VAR_5;", "if (*VAR_3 == NULL) {", "return walk_memory_regions_end(VAR_0, VAR_1, 0);", "}", "if (VAR_2 == 0) {", "PageDesc *pd = *VAR_3;", "for (VAR_4 = 0; VAR_4 < L2_SIZE; ++VAR_4) {", "int prot = pd[VAR_4].flags;", "pa = VAR_1 | (VAR_4 << TARGET_PAGE_BITS);", "if (prot != VAR_0->prot) {", "VAR_5 = walk_memory_regions_end(VAR_0, pa, prot);", "if (VAR_5 != 0) {", "return VAR_5;", "}", "}", "}", "} else {", "void **VAR_6 = *VAR_3;", "for (VAR_4 = 0; VAR_4 < L2_SIZE; ++VAR_4) {", "pa = VAR_1 | ((abi_ulong)VAR_4 <<\n(TARGET_PAGE_BITS + L2_BITS * VAR_2));", "VAR_5 = FUNC_0(VAR_0, pa, VAR_2 - 1, VAR_6 + VAR_4);", "if (VAR_5 != 0) {", "return VAR_5;", "}", "}", "}", "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 ], [ 15 ], [ 17 ], [ 21 ], [ 23 ], [ 27 ], [ 29 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 55 ], [ 57, 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 75 ], [ 77 ] ]
22,215
void helper_ldq_data(uint64_t t0, uint64_t t1) { ldq_data(t1, t0); }
false
qemu
2374e73edafff0586cbfb67c333c5a7588f81fd5
void helper_ldq_data(uint64_t t0, uint64_t t1) { ldq_data(t1, t0); }
{ "code": [], "line_no": [] }
void FUNC_0(uint64_t VAR_0, uint64_t VAR_1) { ldq_data(VAR_1, VAR_0); }
[ "void FUNC_0(uint64_t VAR_0, uint64_t VAR_1)\n{", "ldq_data(VAR_1, VAR_0);", "}" ]
[ 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ] ]
22,216
static int v9fs_do_open2(V9fsState *s, V9fsCreateState *vs) { FsCred cred; int flags; cred_init(&cred); cred.fc_uid = vs->fidp->uid; cred.fc_mode = vs->perm & 0777; flags = omode_to_uflags(vs->mode) | O_CREAT; return s->ops->open2(&s->ctx, vs->fullname.data, flags, &cred); }
false
qemu
c1568af597d71b2171c9b2ffffb336c2fdee205e
static int v9fs_do_open2(V9fsState *s, V9fsCreateState *vs) { FsCred cred; int flags; cred_init(&cred); cred.fc_uid = vs->fidp->uid; cred.fc_mode = vs->perm & 0777; flags = omode_to_uflags(vs->mode) | O_CREAT; return s->ops->open2(&s->ctx, vs->fullname.data, flags, &cred); }
{ "code": [], "line_no": [] }
static int FUNC_0(V9fsState *VAR_0, V9fsCreateState *VAR_1) { FsCred cred; int VAR_2; cred_init(&cred); cred.fc_uid = VAR_1->fidp->uid; cred.fc_mode = VAR_1->perm & 0777; VAR_2 = omode_to_uflags(VAR_1->mode) | O_CREAT; return VAR_0->ops->open2(&VAR_0->ctx, VAR_1->fullname.data, VAR_2, &cred); }
[ "static int FUNC_0(V9fsState *VAR_0, V9fsCreateState *VAR_1)\n{", "FsCred cred;", "int VAR_2;", "cred_init(&cred);", "cred.fc_uid = VAR_1->fidp->uid;", "cred.fc_mode = VAR_1->perm & 0777;", "VAR_2 = omode_to_uflags(VAR_1->mode) | O_CREAT;", "return VAR_0->ops->open2(&VAR_0->ctx, VAR_1->fullname.data, VAR_2, &cred);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 23 ] ]
22,217
static inline void RENAME(vu9_to_vu12)(const uint8_t *src1, const uint8_t *src2, uint8_t *dst1, uint8_t *dst2, long width, long height, long srcStride1, long srcStride2, long dstStride1, long dstStride2) { x86_reg y; long x,w,h; w=width/2; h=height/2; #if COMPILE_TEMPLATE_MMX __asm__ volatile( PREFETCH" %0 \n\t" PREFETCH" %1 \n\t" ::"m"(*(src1+srcStride1)),"m"(*(src2+srcStride2)):"memory"); #endif for (y=0;y<h;y++) { const uint8_t* s1=src1+srcStride1*(y>>1); uint8_t* d=dst1+dstStride1*y; x=0; #if COMPILE_TEMPLATE_MMX for (;x<w-31;x+=32) { __asm__ volatile( PREFETCH" 32%1 \n\t" "movq %1, %%mm0 \n\t" "movq 8%1, %%mm2 \n\t" "movq 16%1, %%mm4 \n\t" "movq 24%1, %%mm6 \n\t" "movq %%mm0, %%mm1 \n\t" "movq %%mm2, %%mm3 \n\t" "movq %%mm4, %%mm5 \n\t" "movq %%mm6, %%mm7 \n\t" "punpcklbw %%mm0, %%mm0 \n\t" "punpckhbw %%mm1, %%mm1 \n\t" "punpcklbw %%mm2, %%mm2 \n\t" "punpckhbw %%mm3, %%mm3 \n\t" "punpcklbw %%mm4, %%mm4 \n\t" "punpckhbw %%mm5, %%mm5 \n\t" "punpcklbw %%mm6, %%mm6 \n\t" "punpckhbw %%mm7, %%mm7 \n\t" MOVNTQ" %%mm0, %0 \n\t" MOVNTQ" %%mm1, 8%0 \n\t" MOVNTQ" %%mm2, 16%0 \n\t" MOVNTQ" %%mm3, 24%0 \n\t" MOVNTQ" %%mm4, 32%0 \n\t" MOVNTQ" %%mm5, 40%0 \n\t" MOVNTQ" %%mm6, 48%0 \n\t" MOVNTQ" %%mm7, 56%0" :"=m"(d[2*x]) :"m"(s1[x]) :"memory"); } #endif for (;x<w;x++) d[2*x]=d[2*x+1]=s1[x]; } for (y=0;y<h;y++) { const uint8_t* s2=src2+srcStride2*(y>>1); uint8_t* d=dst2+dstStride2*y; x=0; #if COMPILE_TEMPLATE_MMX for (;x<w-31;x+=32) { __asm__ volatile( PREFETCH" 32%1 \n\t" "movq %1, %%mm0 \n\t" "movq 8%1, %%mm2 \n\t" "movq 16%1, %%mm4 \n\t" "movq 24%1, %%mm6 \n\t" "movq %%mm0, %%mm1 \n\t" "movq %%mm2, %%mm3 \n\t" "movq %%mm4, %%mm5 \n\t" "movq %%mm6, %%mm7 \n\t" "punpcklbw %%mm0, %%mm0 \n\t" "punpckhbw %%mm1, %%mm1 \n\t" "punpcklbw %%mm2, %%mm2 \n\t" "punpckhbw %%mm3, %%mm3 \n\t" "punpcklbw %%mm4, %%mm4 \n\t" "punpckhbw %%mm5, %%mm5 \n\t" "punpcklbw %%mm6, %%mm6 \n\t" "punpckhbw %%mm7, %%mm7 \n\t" MOVNTQ" %%mm0, %0 \n\t" MOVNTQ" %%mm1, 8%0 \n\t" MOVNTQ" %%mm2, 16%0 \n\t" MOVNTQ" %%mm3, 24%0 \n\t" MOVNTQ" %%mm4, 32%0 \n\t" MOVNTQ" %%mm5, 40%0 \n\t" MOVNTQ" %%mm6, 48%0 \n\t" MOVNTQ" %%mm7, 56%0" :"=m"(d[2*x]) :"m"(s2[x]) :"memory"); } #endif for (;x<w;x++) d[2*x]=d[2*x+1]=s2[x]; } #if COMPILE_TEMPLATE_MMX __asm__( EMMS" \n\t" SFENCE" \n\t" ::: "memory" ); #endif }
false
FFmpeg
d1adad3cca407f493c3637e20ecd4f7124e69212
static inline void RENAME(vu9_to_vu12)(const uint8_t *src1, const uint8_t *src2, uint8_t *dst1, uint8_t *dst2, long width, long height, long srcStride1, long srcStride2, long dstStride1, long dstStride2) { x86_reg y; long x,w,h; w=width/2; h=height/2; #if COMPILE_TEMPLATE_MMX __asm__ volatile( PREFETCH" %0 \n\t" PREFETCH" %1 \n\t" ::"m"(*(src1+srcStride1)),"m"(*(src2+srcStride2)):"memory"); #endif for (y=0;y<h;y++) { const uint8_t* s1=src1+srcStride1*(y>>1); uint8_t* d=dst1+dstStride1*y; x=0; #if COMPILE_TEMPLATE_MMX for (;x<w-31;x+=32) { __asm__ volatile( PREFETCH" 32%1 \n\t" "movq %1, %%mm0 \n\t" "movq 8%1, %%mm2 \n\t" "movq 16%1, %%mm4 \n\t" "movq 24%1, %%mm6 \n\t" "movq %%mm0, %%mm1 \n\t" "movq %%mm2, %%mm3 \n\t" "movq %%mm4, %%mm5 \n\t" "movq %%mm6, %%mm7 \n\t" "punpcklbw %%mm0, %%mm0 \n\t" "punpckhbw %%mm1, %%mm1 \n\t" "punpcklbw %%mm2, %%mm2 \n\t" "punpckhbw %%mm3, %%mm3 \n\t" "punpcklbw %%mm4, %%mm4 \n\t" "punpckhbw %%mm5, %%mm5 \n\t" "punpcklbw %%mm6, %%mm6 \n\t" "punpckhbw %%mm7, %%mm7 \n\t" MOVNTQ" %%mm0, %0 \n\t" MOVNTQ" %%mm1, 8%0 \n\t" MOVNTQ" %%mm2, 16%0 \n\t" MOVNTQ" %%mm3, 24%0 \n\t" MOVNTQ" %%mm4, 32%0 \n\t" MOVNTQ" %%mm5, 40%0 \n\t" MOVNTQ" %%mm6, 48%0 \n\t" MOVNTQ" %%mm7, 56%0" :"=m"(d[2*x]) :"m"(s1[x]) :"memory"); } #endif for (;x<w;x++) d[2*x]=d[2*x+1]=s1[x]; } for (y=0;y<h;y++) { const uint8_t* s2=src2+srcStride2*(y>>1); uint8_t* d=dst2+dstStride2*y; x=0; #if COMPILE_TEMPLATE_MMX for (;x<w-31;x+=32) { __asm__ volatile( PREFETCH" 32%1 \n\t" "movq %1, %%mm0 \n\t" "movq 8%1, %%mm2 \n\t" "movq 16%1, %%mm4 \n\t" "movq 24%1, %%mm6 \n\t" "movq %%mm0, %%mm1 \n\t" "movq %%mm2, %%mm3 \n\t" "movq %%mm4, %%mm5 \n\t" "movq %%mm6, %%mm7 \n\t" "punpcklbw %%mm0, %%mm0 \n\t" "punpckhbw %%mm1, %%mm1 \n\t" "punpcklbw %%mm2, %%mm2 \n\t" "punpckhbw %%mm3, %%mm3 \n\t" "punpcklbw %%mm4, %%mm4 \n\t" "punpckhbw %%mm5, %%mm5 \n\t" "punpcklbw %%mm6, %%mm6 \n\t" "punpckhbw %%mm7, %%mm7 \n\t" MOVNTQ" %%mm0, %0 \n\t" MOVNTQ" %%mm1, 8%0 \n\t" MOVNTQ" %%mm2, 16%0 \n\t" MOVNTQ" %%mm3, 24%0 \n\t" MOVNTQ" %%mm4, 32%0 \n\t" MOVNTQ" %%mm5, 40%0 \n\t" MOVNTQ" %%mm6, 48%0 \n\t" MOVNTQ" %%mm7, 56%0" :"=m"(d[2*x]) :"m"(s2[x]) :"memory"); } #endif for (;x<w;x++) d[2*x]=d[2*x+1]=s2[x]; } #if COMPILE_TEMPLATE_MMX __asm__( EMMS" \n\t" SFENCE" \n\t" ::: "memory" ); #endif }
{ "code": [], "line_no": [] }
static inline void FUNC_0(vu9_to_vu12)(const uint8_t *src1, const uint8_t *src2, uint8_t *dst1, uint8_t *dst2, long width, long height, long srcStride1, long srcStride2, long dstStride1, long dstStride2) { x86_reg y; long VAR_0,VAR_1,VAR_2; VAR_1=width/2; VAR_2=height/2; #if COMPILE_TEMPLATE_MMX __asm__ volatile( PREFETCH" %0 \n\t" PREFETCH" %1 \n\t" ::"m"(*(src1+srcStride1)),"m"(*(src2+srcStride2)):"memory"); #endif for (y=0;y<VAR_2;y++) { const uint8_t* s1=src1+srcStride1*(y>>1); uint8_t* d=dst1+dstStride1*y; VAR_0=0; #if COMPILE_TEMPLATE_MMX for (;VAR_0<VAR_1-31;VAR_0+=32) { __asm__ volatile( PREFETCH" 32%1 \n\t" "movq %1, %%mm0 \n\t" "movq 8%1, %%mm2 \n\t" "movq 16%1, %%mm4 \n\t" "movq 24%1, %%mm6 \n\t" "movq %%mm0, %%mm1 \n\t" "movq %%mm2, %%mm3 \n\t" "movq %%mm4, %%mm5 \n\t" "movq %%mm6, %%mm7 \n\t" "punpcklbw %%mm0, %%mm0 \n\t" "punpckhbw %%mm1, %%mm1 \n\t" "punpcklbw %%mm2, %%mm2 \n\t" "punpckhbw %%mm3, %%mm3 \n\t" "punpcklbw %%mm4, %%mm4 \n\t" "punpckhbw %%mm5, %%mm5 \n\t" "punpcklbw %%mm6, %%mm6 \n\t" "punpckhbw %%mm7, %%mm7 \n\t" MOVNTQ" %%mm0, %0 \n\t" MOVNTQ" %%mm1, 8%0 \n\t" MOVNTQ" %%mm2, 16%0 \n\t" MOVNTQ" %%mm3, 24%0 \n\t" MOVNTQ" %%mm4, 32%0 \n\t" MOVNTQ" %%mm5, 40%0 \n\t" MOVNTQ" %%mm6, 48%0 \n\t" MOVNTQ" %%mm7, 56%0" :"=m"(d[2*VAR_0]) :"m"(s1[VAR_0]) :"memory"); } #endif for (;VAR_0<VAR_1;VAR_0++) d[2*VAR_0]=d[2*VAR_0+1]=s1[VAR_0]; } for (y=0;y<VAR_2;y++) { const uint8_t* s2=src2+srcStride2*(y>>1); uint8_t* d=dst2+dstStride2*y; VAR_0=0; #if COMPILE_TEMPLATE_MMX for (;VAR_0<VAR_1-31;VAR_0+=32) { __asm__ volatile( PREFETCH" 32%1 \n\t" "movq %1, %%mm0 \n\t" "movq 8%1, %%mm2 \n\t" "movq 16%1, %%mm4 \n\t" "movq 24%1, %%mm6 \n\t" "movq %%mm0, %%mm1 \n\t" "movq %%mm2, %%mm3 \n\t" "movq %%mm4, %%mm5 \n\t" "movq %%mm6, %%mm7 \n\t" "punpcklbw %%mm0, %%mm0 \n\t" "punpckhbw %%mm1, %%mm1 \n\t" "punpcklbw %%mm2, %%mm2 \n\t" "punpckhbw %%mm3, %%mm3 \n\t" "punpcklbw %%mm4, %%mm4 \n\t" "punpckhbw %%mm5, %%mm5 \n\t" "punpcklbw %%mm6, %%mm6 \n\t" "punpckhbw %%mm7, %%mm7 \n\t" MOVNTQ" %%mm0, %0 \n\t" MOVNTQ" %%mm1, 8%0 \n\t" MOVNTQ" %%mm2, 16%0 \n\t" MOVNTQ" %%mm3, 24%0 \n\t" MOVNTQ" %%mm4, 32%0 \n\t" MOVNTQ" %%mm5, 40%0 \n\t" MOVNTQ" %%mm6, 48%0 \n\t" MOVNTQ" %%mm7, 56%0" :"=m"(d[2*VAR_0]) :"m"(s2[VAR_0]) :"memory"); } #endif for (;VAR_0<VAR_1;VAR_0++) d[2*VAR_0]=d[2*VAR_0+1]=s2[VAR_0]; } #if COMPILE_TEMPLATE_MMX __asm__( EMMS" \n\t" SFENCE" \n\t" ::: "memory" ); #endif }
[ "static inline void FUNC_0(vu9_to_vu12)(const uint8_t *src1, const uint8_t *src2,\nuint8_t *dst1, uint8_t *dst2,\nlong width, long height,\nlong srcStride1, long srcStride2,\nlong dstStride1, long dstStride2)\n{", "x86_reg y;", "long VAR_0,VAR_1,VAR_2;", "VAR_1=width/2; VAR_2=height/2;", "#if COMPILE_TEMPLATE_MMX\n__asm__ volatile(\nPREFETCH\" %0 \\n\\t\"\nPREFETCH\" %1 \\n\\t\"\n::\"m\"(*(src1+srcStride1)),\"m\"(*(src2+srcStride2)):\"memory\");", "#endif\nfor (y=0;y<VAR_2;y++) {", "const uint8_t* s1=src1+srcStride1*(y>>1);", "uint8_t* d=dst1+dstStride1*y;", "VAR_0=0;", "#if COMPILE_TEMPLATE_MMX\nfor (;VAR_0<VAR_1-31;VAR_0+=32) {", "__asm__ volatile(\nPREFETCH\" 32%1 \\n\\t\"\n\"movq %1, %%mm0 \\n\\t\"\n\"movq 8%1, %%mm2 \\n\\t\"\n\"movq 16%1, %%mm4 \\n\\t\"\n\"movq 24%1, %%mm6 \\n\\t\"\n\"movq %%mm0, %%mm1 \\n\\t\"\n\"movq %%mm2, %%mm3 \\n\\t\"\n\"movq %%mm4, %%mm5 \\n\\t\"\n\"movq %%mm6, %%mm7 \\n\\t\"\n\"punpcklbw %%mm0, %%mm0 \\n\\t\"\n\"punpckhbw %%mm1, %%mm1 \\n\\t\"\n\"punpcklbw %%mm2, %%mm2 \\n\\t\"\n\"punpckhbw %%mm3, %%mm3 \\n\\t\"\n\"punpcklbw %%mm4, %%mm4 \\n\\t\"\n\"punpckhbw %%mm5, %%mm5 \\n\\t\"\n\"punpcklbw %%mm6, %%mm6 \\n\\t\"\n\"punpckhbw %%mm7, %%mm7 \\n\\t\"\nMOVNTQ\" %%mm0, %0 \\n\\t\"\nMOVNTQ\" %%mm1, 8%0 \\n\\t\"\nMOVNTQ\" %%mm2, 16%0 \\n\\t\"\nMOVNTQ\" %%mm3, 24%0 \\n\\t\"\nMOVNTQ\" %%mm4, 32%0 \\n\\t\"\nMOVNTQ\" %%mm5, 40%0 \\n\\t\"\nMOVNTQ\" %%mm6, 48%0 \\n\\t\"\nMOVNTQ\" %%mm7, 56%0\"\n:\"=m\"(d[2*VAR_0])\n:\"m\"(s1[VAR_0])\n:\"memory\");", "}", "#endif\nfor (;VAR_0<VAR_1;VAR_0++) d[2*VAR_0]=d[2*VAR_0+1]=s1[VAR_0];", "}", "for (y=0;y<VAR_2;y++) {", "const uint8_t* s2=src2+srcStride2*(y>>1);", "uint8_t* d=dst2+dstStride2*y;", "VAR_0=0;", "#if COMPILE_TEMPLATE_MMX\nfor (;VAR_0<VAR_1-31;VAR_0+=32) {", "__asm__ volatile(\nPREFETCH\" 32%1 \\n\\t\"\n\"movq %1, %%mm0 \\n\\t\"\n\"movq 8%1, %%mm2 \\n\\t\"\n\"movq 16%1, %%mm4 \\n\\t\"\n\"movq 24%1, %%mm6 \\n\\t\"\n\"movq %%mm0, %%mm1 \\n\\t\"\n\"movq %%mm2, %%mm3 \\n\\t\"\n\"movq %%mm4, %%mm5 \\n\\t\"\n\"movq %%mm6, %%mm7 \\n\\t\"\n\"punpcklbw %%mm0, %%mm0 \\n\\t\"\n\"punpckhbw %%mm1, %%mm1 \\n\\t\"\n\"punpcklbw %%mm2, %%mm2 \\n\\t\"\n\"punpckhbw %%mm3, %%mm3 \\n\\t\"\n\"punpcklbw %%mm4, %%mm4 \\n\\t\"\n\"punpckhbw %%mm5, %%mm5 \\n\\t\"\n\"punpcklbw %%mm6, %%mm6 \\n\\t\"\n\"punpckhbw %%mm7, %%mm7 \\n\\t\"\nMOVNTQ\" %%mm0, %0 \\n\\t\"\nMOVNTQ\" %%mm1, 8%0 \\n\\t\"\nMOVNTQ\" %%mm2, 16%0 \\n\\t\"\nMOVNTQ\" %%mm3, 24%0 \\n\\t\"\nMOVNTQ\" %%mm4, 32%0 \\n\\t\"\nMOVNTQ\" %%mm5, 40%0 \\n\\t\"\nMOVNTQ\" %%mm6, 48%0 \\n\\t\"\nMOVNTQ\" %%mm7, 56%0\"\n:\"=m\"(d[2*VAR_0])\n:\"m\"(s2[VAR_0])\n:\"memory\");", "}", "#endif\nfor (;VAR_0<VAR_1;VAR_0++) d[2*VAR_0]=d[2*VAR_0+1]=s2[VAR_0];", "}", "#if COMPILE_TEMPLATE_MMX\n__asm__(\nEMMS\" \\n\\t\"\nSFENCE\" \\n\\t\"\n::: \"memory\"\n);", "#endif\n}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9, 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19, 21, 23, 25, 27 ], [ 29, 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39, 41 ], [ 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99 ], [ 101 ], [ 103, 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117, 119 ], [ 121, 123, 125, 127, 129, 131, 133, 135, 137, 139, 141, 143, 145, 147, 149, 151, 153, 155, 157, 159, 161, 163, 165, 167, 169, 171, 173, 175, 177 ], [ 179 ], [ 181, 183 ], [ 185 ], [ 187, 189, 191, 193, 195, 197 ], [ 199, 201 ] ]
22,218
static TranslationBlock *tb_find_slow(target_ulong pc, target_ulong cs_base, uint64_t flags) { TranslationBlock *tb, **ptb1; unsigned int h; tb_page_addr_t phys_pc, phys_page1, phys_page2; target_ulong virt_page2; tb_invalidated_flag = 0; /* find translated block using physical mappings */ phys_pc = get_page_addr_code(env, pc); phys_page1 = phys_pc & TARGET_PAGE_MASK; phys_page2 = -1; h = tb_phys_hash_func(phys_pc); ptb1 = &tb_phys_hash[h]; for(;;) { tb = *ptb1; if (!tb) goto not_found; if (tb->pc == pc && tb->page_addr[0] == phys_page1 && tb->cs_base == cs_base && tb->flags == flags) { /* check next page if needed */ if (tb->page_addr[1] != -1) { virt_page2 = (pc & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; phys_page2 = get_page_addr_code(env, virt_page2); if (tb->page_addr[1] == phys_page2) goto found; } else { goto found; } } ptb1 = &tb->phys_hash_next; } not_found: /* if no translated code available, then translate it now */ tb = tb_gen_code(env, pc, cs_base, flags, 0); found: /* Move the last found TB to the head of the list */ if (likely(*ptb1)) { *ptb1 = tb->phys_hash_next; tb->phys_hash_next = tb_phys_hash[h]; tb_phys_hash[h] = tb; } /* we add the TB in the virtual pc hash table */ env->tb_jmp_cache[tb_jmp_cache_hash_func(pc)] = tb; return tb; }
false
qemu
cea5f9a28faa528b6b1b117c9ab2d8828f473fef
static TranslationBlock *tb_find_slow(target_ulong pc, target_ulong cs_base, uint64_t flags) { TranslationBlock *tb, **ptb1; unsigned int h; tb_page_addr_t phys_pc, phys_page1, phys_page2; target_ulong virt_page2; tb_invalidated_flag = 0; phys_pc = get_page_addr_code(env, pc); phys_page1 = phys_pc & TARGET_PAGE_MASK; phys_page2 = -1; h = tb_phys_hash_func(phys_pc); ptb1 = &tb_phys_hash[h]; for(;;) { tb = *ptb1; if (!tb) goto not_found; if (tb->pc == pc && tb->page_addr[0] == phys_page1 && tb->cs_base == cs_base && tb->flags == flags) { if (tb->page_addr[1] != -1) { virt_page2 = (pc & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; phys_page2 = get_page_addr_code(env, virt_page2); if (tb->page_addr[1] == phys_page2) goto found; } else { goto found; } } ptb1 = &tb->phys_hash_next; } not_found: tb = tb_gen_code(env, pc, cs_base, flags, 0); found: if (likely(*ptb1)) { *ptb1 = tb->phys_hash_next; tb->phys_hash_next = tb_phys_hash[h]; tb_phys_hash[h] = tb; } env->tb_jmp_cache[tb_jmp_cache_hash_func(pc)] = tb; return tb; }
{ "code": [], "line_no": [] }
static TranslationBlock *FUNC_0(target_ulong pc, target_ulong cs_base, uint64_t flags) { TranslationBlock *tb, **ptb1; unsigned int VAR_0; tb_page_addr_t phys_pc, phys_page1, phys_page2; target_ulong virt_page2; tb_invalidated_flag = 0; phys_pc = get_page_addr_code(env, pc); phys_page1 = phys_pc & TARGET_PAGE_MASK; phys_page2 = -1; VAR_0 = tb_phys_hash_func(phys_pc); ptb1 = &tb_phys_hash[VAR_0]; for(;;) { tb = *ptb1; if (!tb) goto not_found; if (tb->pc == pc && tb->page_addr[0] == phys_page1 && tb->cs_base == cs_base && tb->flags == flags) { if (tb->page_addr[1] != -1) { virt_page2 = (pc & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; phys_page2 = get_page_addr_code(env, virt_page2); if (tb->page_addr[1] == phys_page2) goto found; } else { goto found; } } ptb1 = &tb->phys_hash_next; } not_found: tb = tb_gen_code(env, pc, cs_base, flags, 0); found: if (likely(*ptb1)) { *ptb1 = tb->phys_hash_next; tb->phys_hash_next = tb_phys_hash[VAR_0]; tb_phys_hash[VAR_0] = tb; } env->tb_jmp_cache[tb_jmp_cache_hash_func(pc)] = tb; return tb; }
[ "static TranslationBlock *FUNC_0(target_ulong pc,\ntarget_ulong cs_base,\nuint64_t flags)\n{", "TranslationBlock *tb, **ptb1;", "unsigned int VAR_0;", "tb_page_addr_t phys_pc, phys_page1, phys_page2;", "target_ulong virt_page2;", "tb_invalidated_flag = 0;", "phys_pc = get_page_addr_code(env, pc);", "phys_page1 = phys_pc & TARGET_PAGE_MASK;", "phys_page2 = -1;", "VAR_0 = tb_phys_hash_func(phys_pc);", "ptb1 = &tb_phys_hash[VAR_0];", "for(;;) {", "tb = *ptb1;", "if (!tb)\ngoto not_found;", "if (tb->pc == pc &&\ntb->page_addr[0] == phys_page1 &&\ntb->cs_base == cs_base &&\ntb->flags == flags) {", "if (tb->page_addr[1] != -1) {", "virt_page2 = (pc & TARGET_PAGE_MASK) +\nTARGET_PAGE_SIZE;", "phys_page2 = get_page_addr_code(env, virt_page2);", "if (tb->page_addr[1] == phys_page2)\ngoto found;", "} else {", "goto found;", "}", "}", "ptb1 = &tb->phys_hash_next;", "}", "not_found:\ntb = tb_gen_code(env, pc, cs_base, flags, 0);", "found:\nif (likely(*ptb1)) {", "*ptb1 = tb->phys_hash_next;", "tb->phys_hash_next = tb_phys_hash[VAR_0];", "tb_phys_hash[VAR_0] = tb;", "}", "env->tb_jmp_cache[tb_jmp_cache_hash_func(pc)] = tb;", "return tb;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39, 41 ], [ 43, 45, 47, 49 ], [ 53 ], [ 55, 57 ], [ 59 ], [ 61, 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77, 81 ], [ 85, 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 101 ], [ 103 ], [ 105 ] ]
22,219
static int megasas_init_firmware(MegasasState *s, MegasasCmd *cmd) { uint32_t pa_hi, pa_lo; target_phys_addr_t iq_pa, initq_size; struct mfi_init_qinfo *initq; uint32_t flags; int ret = MFI_STAT_OK; pa_lo = le32_to_cpu(cmd->frame->init.qinfo_new_addr_lo); pa_hi = le32_to_cpu(cmd->frame->init.qinfo_new_addr_hi); iq_pa = (((uint64_t) pa_hi << 32) | pa_lo); trace_megasas_init_firmware((uint64_t)iq_pa); initq_size = sizeof(*initq); initq = cpu_physical_memory_map(iq_pa, &initq_size, 0); if (!initq || initq_size != sizeof(*initq)) { trace_megasas_initq_map_failed(cmd->index); s->event_count++; ret = MFI_STAT_MEMORY_NOT_AVAILABLE; goto out; } s->reply_queue_len = le32_to_cpu(initq->rq_entries) & 0xFFFF; if (s->reply_queue_len > s->fw_cmds) { trace_megasas_initq_mismatch(s->reply_queue_len, s->fw_cmds); s->event_count++; ret = MFI_STAT_INVALID_PARAMETER; goto out; } pa_lo = le32_to_cpu(initq->rq_addr_lo); pa_hi = le32_to_cpu(initq->rq_addr_hi); s->reply_queue_pa = ((uint64_t) pa_hi << 32) | pa_lo; pa_lo = le32_to_cpu(initq->ci_addr_lo); pa_hi = le32_to_cpu(initq->ci_addr_hi); s->consumer_pa = ((uint64_t) pa_hi << 32) | pa_lo; pa_lo = le32_to_cpu(initq->pi_addr_lo); pa_hi = le32_to_cpu(initq->pi_addr_hi); s->producer_pa = ((uint64_t) pa_hi << 32) | pa_lo; s->reply_queue_head = ldl_le_phys(s->producer_pa); s->reply_queue_tail = ldl_le_phys(s->consumer_pa); flags = le32_to_cpu(initq->flags); if (flags & MFI_QUEUE_FLAG_CONTEXT64) { s->flags |= MEGASAS_MASK_USE_QUEUE64; } trace_megasas_init_queue((unsigned long)s->reply_queue_pa, s->reply_queue_len, s->reply_queue_head, s->reply_queue_tail, flags); megasas_reset_frames(s); s->fw_state = MFI_FWSTATE_OPERATIONAL; out: if (initq) { cpu_physical_memory_unmap(initq, initq_size, 0, 0); } return ret; }
false
qemu
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
static int megasas_init_firmware(MegasasState *s, MegasasCmd *cmd) { uint32_t pa_hi, pa_lo; target_phys_addr_t iq_pa, initq_size; struct mfi_init_qinfo *initq; uint32_t flags; int ret = MFI_STAT_OK; pa_lo = le32_to_cpu(cmd->frame->init.qinfo_new_addr_lo); pa_hi = le32_to_cpu(cmd->frame->init.qinfo_new_addr_hi); iq_pa = (((uint64_t) pa_hi << 32) | pa_lo); trace_megasas_init_firmware((uint64_t)iq_pa); initq_size = sizeof(*initq); initq = cpu_physical_memory_map(iq_pa, &initq_size, 0); if (!initq || initq_size != sizeof(*initq)) { trace_megasas_initq_map_failed(cmd->index); s->event_count++; ret = MFI_STAT_MEMORY_NOT_AVAILABLE; goto out; } s->reply_queue_len = le32_to_cpu(initq->rq_entries) & 0xFFFF; if (s->reply_queue_len > s->fw_cmds) { trace_megasas_initq_mismatch(s->reply_queue_len, s->fw_cmds); s->event_count++; ret = MFI_STAT_INVALID_PARAMETER; goto out; } pa_lo = le32_to_cpu(initq->rq_addr_lo); pa_hi = le32_to_cpu(initq->rq_addr_hi); s->reply_queue_pa = ((uint64_t) pa_hi << 32) | pa_lo; pa_lo = le32_to_cpu(initq->ci_addr_lo); pa_hi = le32_to_cpu(initq->ci_addr_hi); s->consumer_pa = ((uint64_t) pa_hi << 32) | pa_lo; pa_lo = le32_to_cpu(initq->pi_addr_lo); pa_hi = le32_to_cpu(initq->pi_addr_hi); s->producer_pa = ((uint64_t) pa_hi << 32) | pa_lo; s->reply_queue_head = ldl_le_phys(s->producer_pa); s->reply_queue_tail = ldl_le_phys(s->consumer_pa); flags = le32_to_cpu(initq->flags); if (flags & MFI_QUEUE_FLAG_CONTEXT64) { s->flags |= MEGASAS_MASK_USE_QUEUE64; } trace_megasas_init_queue((unsigned long)s->reply_queue_pa, s->reply_queue_len, s->reply_queue_head, s->reply_queue_tail, flags); megasas_reset_frames(s); s->fw_state = MFI_FWSTATE_OPERATIONAL; out: if (initq) { cpu_physical_memory_unmap(initq, initq_size, 0, 0); } return ret; }
{ "code": [], "line_no": [] }
static int FUNC_0(MegasasState *VAR_0, MegasasCmd *VAR_1) { uint32_t pa_hi, pa_lo; target_phys_addr_t iq_pa, initq_size; struct mfi_init_qinfo *VAR_2; uint32_t flags; int VAR_3 = MFI_STAT_OK; pa_lo = le32_to_cpu(VAR_1->frame->init.qinfo_new_addr_lo); pa_hi = le32_to_cpu(VAR_1->frame->init.qinfo_new_addr_hi); iq_pa = (((uint64_t) pa_hi << 32) | pa_lo); trace_megasas_init_firmware((uint64_t)iq_pa); initq_size = sizeof(*VAR_2); VAR_2 = cpu_physical_memory_map(iq_pa, &initq_size, 0); if (!VAR_2 || initq_size != sizeof(*VAR_2)) { trace_megasas_initq_map_failed(VAR_1->index); VAR_0->event_count++; VAR_3 = MFI_STAT_MEMORY_NOT_AVAILABLE; goto out; } VAR_0->reply_queue_len = le32_to_cpu(VAR_2->rq_entries) & 0xFFFF; if (VAR_0->reply_queue_len > VAR_0->fw_cmds) { trace_megasas_initq_mismatch(VAR_0->reply_queue_len, VAR_0->fw_cmds); VAR_0->event_count++; VAR_3 = MFI_STAT_INVALID_PARAMETER; goto out; } pa_lo = le32_to_cpu(VAR_2->rq_addr_lo); pa_hi = le32_to_cpu(VAR_2->rq_addr_hi); VAR_0->reply_queue_pa = ((uint64_t) pa_hi << 32) | pa_lo; pa_lo = le32_to_cpu(VAR_2->ci_addr_lo); pa_hi = le32_to_cpu(VAR_2->ci_addr_hi); VAR_0->consumer_pa = ((uint64_t) pa_hi << 32) | pa_lo; pa_lo = le32_to_cpu(VAR_2->pi_addr_lo); pa_hi = le32_to_cpu(VAR_2->pi_addr_hi); VAR_0->producer_pa = ((uint64_t) pa_hi << 32) | pa_lo; VAR_0->reply_queue_head = ldl_le_phys(VAR_0->producer_pa); VAR_0->reply_queue_tail = ldl_le_phys(VAR_0->consumer_pa); flags = le32_to_cpu(VAR_2->flags); if (flags & MFI_QUEUE_FLAG_CONTEXT64) { VAR_0->flags |= MEGASAS_MASK_USE_QUEUE64; } trace_megasas_init_queue((unsigned long)VAR_0->reply_queue_pa, VAR_0->reply_queue_len, VAR_0->reply_queue_head, VAR_0->reply_queue_tail, flags); megasas_reset_frames(VAR_0); VAR_0->fw_state = MFI_FWSTATE_OPERATIONAL; out: if (VAR_2) { cpu_physical_memory_unmap(VAR_2, initq_size, 0, 0); } return VAR_3; }
[ "static int FUNC_0(MegasasState *VAR_0, MegasasCmd *VAR_1)\n{", "uint32_t pa_hi, pa_lo;", "target_phys_addr_t iq_pa, initq_size;", "struct mfi_init_qinfo *VAR_2;", "uint32_t flags;", "int VAR_3 = MFI_STAT_OK;", "pa_lo = le32_to_cpu(VAR_1->frame->init.qinfo_new_addr_lo);", "pa_hi = le32_to_cpu(VAR_1->frame->init.qinfo_new_addr_hi);", "iq_pa = (((uint64_t) pa_hi << 32) | pa_lo);", "trace_megasas_init_firmware((uint64_t)iq_pa);", "initq_size = sizeof(*VAR_2);", "VAR_2 = cpu_physical_memory_map(iq_pa, &initq_size, 0);", "if (!VAR_2 || initq_size != sizeof(*VAR_2)) {", "trace_megasas_initq_map_failed(VAR_1->index);", "VAR_0->event_count++;", "VAR_3 = MFI_STAT_MEMORY_NOT_AVAILABLE;", "goto out;", "}", "VAR_0->reply_queue_len = le32_to_cpu(VAR_2->rq_entries) & 0xFFFF;", "if (VAR_0->reply_queue_len > VAR_0->fw_cmds) {", "trace_megasas_initq_mismatch(VAR_0->reply_queue_len, VAR_0->fw_cmds);", "VAR_0->event_count++;", "VAR_3 = MFI_STAT_INVALID_PARAMETER;", "goto out;", "}", "pa_lo = le32_to_cpu(VAR_2->rq_addr_lo);", "pa_hi = le32_to_cpu(VAR_2->rq_addr_hi);", "VAR_0->reply_queue_pa = ((uint64_t) pa_hi << 32) | pa_lo;", "pa_lo = le32_to_cpu(VAR_2->ci_addr_lo);", "pa_hi = le32_to_cpu(VAR_2->ci_addr_hi);", "VAR_0->consumer_pa = ((uint64_t) pa_hi << 32) | pa_lo;", "pa_lo = le32_to_cpu(VAR_2->pi_addr_lo);", "pa_hi = le32_to_cpu(VAR_2->pi_addr_hi);", "VAR_0->producer_pa = ((uint64_t) pa_hi << 32) | pa_lo;", "VAR_0->reply_queue_head = ldl_le_phys(VAR_0->producer_pa);", "VAR_0->reply_queue_tail = ldl_le_phys(VAR_0->consumer_pa);", "flags = le32_to_cpu(VAR_2->flags);", "if (flags & MFI_QUEUE_FLAG_CONTEXT64) {", "VAR_0->flags |= MEGASAS_MASK_USE_QUEUE64;", "}", "trace_megasas_init_queue((unsigned long)VAR_0->reply_queue_pa,\nVAR_0->reply_queue_len, VAR_0->reply_queue_head,\nVAR_0->reply_queue_tail, flags);", "megasas_reset_frames(VAR_0);", "VAR_0->fw_state = MFI_FWSTATE_OPERATIONAL;", "out:\nif (VAR_2) {", "cpu_physical_memory_unmap(VAR_2, initq_size, 0, 0);", "}", "return VAR_3;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85, 87, 89 ], [ 91 ], [ 93 ], [ 95, 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ] ]
22,220
static void pmac_ide_writel (void *opaque, target_phys_addr_t addr, uint32_t val) { MACIOIDEState *d = opaque; addr = (addr & 0xFFF) >> 4; val = bswap32(val); if (addr == 0) { ide_data_writel(&d->bus, 0, val); } }
false
qemu
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
static void pmac_ide_writel (void *opaque, target_phys_addr_t addr, uint32_t val) { MACIOIDEState *d = opaque; addr = (addr & 0xFFF) >> 4; val = bswap32(val); if (addr == 0) { ide_data_writel(&d->bus, 0, val); } }
{ "code": [], "line_no": [] }
static void FUNC_0 (void *VAR_0, target_phys_addr_t VAR_1, uint32_t VAR_2) { MACIOIDEState *d = VAR_0; VAR_1 = (VAR_1 & 0xFFF) >> 4; VAR_2 = bswap32(VAR_2); if (VAR_1 == 0) { ide_data_writel(&d->bus, 0, VAR_2); } }
[ "static void FUNC_0 (void *VAR_0,\ntarget_phys_addr_t VAR_1, uint32_t VAR_2)\n{", "MACIOIDEState *d = VAR_0;", "VAR_1 = (VAR_1 & 0xFFF) >> 4;", "VAR_2 = bswap32(VAR_2);", "if (VAR_1 == 0) {", "ide_data_writel(&d->bus, 0, VAR_2);", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ] ]
22,221
static void control_out(VirtIODevice *vdev, VirtQueue *vq) { VirtQueueElement elem; VirtIOSerial *vser; uint8_t *buf; size_t len; vser = VIRTIO_SERIAL(vdev); len = 0; buf = NULL; while (virtqueue_pop(vq, &elem)) { size_t cur_len; cur_len = iov_size(elem.out_sg, elem.out_num); /* * Allocate a new buf only if we didn't have one previously or * if the size of the buf differs */ if (cur_len > len) { g_free(buf); buf = g_malloc(cur_len); len = cur_len; } iov_to_buf(elem.out_sg, elem.out_num, 0, buf, cur_len); handle_control_message(vser, buf, cur_len); virtqueue_push(vq, &elem, 0); } g_free(buf); virtio_notify(vdev, vq); }
false
qemu
51b19ebe4320f3dcd93cea71235c1219318ddfd2
static void control_out(VirtIODevice *vdev, VirtQueue *vq) { VirtQueueElement elem; VirtIOSerial *vser; uint8_t *buf; size_t len; vser = VIRTIO_SERIAL(vdev); len = 0; buf = NULL; while (virtqueue_pop(vq, &elem)) { size_t cur_len; cur_len = iov_size(elem.out_sg, elem.out_num); if (cur_len > len) { g_free(buf); buf = g_malloc(cur_len); len = cur_len; } iov_to_buf(elem.out_sg, elem.out_num, 0, buf, cur_len); handle_control_message(vser, buf, cur_len); virtqueue_push(vq, &elem, 0); } g_free(buf); virtio_notify(vdev, vq); }
{ "code": [], "line_no": [] }
static void FUNC_0(VirtIODevice *VAR_0, VirtQueue *VAR_1) { VirtQueueElement elem; VirtIOSerial *vser; uint8_t *buf; size_t len; vser = VIRTIO_SERIAL(VAR_0); len = 0; buf = NULL; while (virtqueue_pop(VAR_1, &elem)) { size_t cur_len; cur_len = iov_size(elem.out_sg, elem.out_num); if (cur_len > len) { g_free(buf); buf = g_malloc(cur_len); len = cur_len; } iov_to_buf(elem.out_sg, elem.out_num, 0, buf, cur_len); handle_control_message(vser, buf, cur_len); virtqueue_push(VAR_1, &elem, 0); } g_free(buf); virtio_notify(VAR_0, VAR_1); }
[ "static void FUNC_0(VirtIODevice *VAR_0, VirtQueue *VAR_1)\n{", "VirtQueueElement elem;", "VirtIOSerial *vser;", "uint8_t *buf;", "size_t len;", "vser = VIRTIO_SERIAL(VAR_0);", "len = 0;", "buf = NULL;", "while (virtqueue_pop(VAR_1, &elem)) {", "size_t cur_len;", "cur_len = iov_size(elem.out_sg, elem.out_num);", "if (cur_len > len) {", "g_free(buf);", "buf = g_malloc(cur_len);", "len = cur_len;", "}", "iov_to_buf(elem.out_sg, elem.out_num, 0, buf, cur_len);", "handle_control_message(vser, buf, cur_len);", "virtqueue_push(VAR_1, &elem, 0);", "}", "g_free(buf);", "virtio_notify(VAR_0, VAR_1);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 29 ], [ 39 ], [ 41 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ] ]
22,224
static int disas_thumb2_insn(CPUARMState *env, DisasContext *s, uint16_t insn_hw1) { uint32_t insn, imm, shift, offset; uint32_t rd, rn, rm, rs; TCGv_i32 tmp; TCGv_i32 tmp2; TCGv_i32 tmp3; TCGv_i32 addr; TCGv_i64 tmp64; int op; int shiftop; int conds; int logic_cc; if (!(arm_feature(env, ARM_FEATURE_THUMB2) || arm_feature (env, ARM_FEATURE_M))) { /* Thumb-1 cores may need to treat bl and blx as a pair of 16-bit instructions to get correct prefetch abort behavior. */ insn = insn_hw1; if ((insn & (1 << 12)) == 0) { ARCH(5); /* Second half of blx. */ offset = ((insn & 0x7ff) << 1); tmp = load_reg(s, 14); tcg_gen_addi_i32(tmp, tmp, offset); tcg_gen_andi_i32(tmp, tmp, 0xfffffffc); tmp2 = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp2, s->pc | 1); store_reg(s, 14, tmp2); gen_bx(s, tmp); return 0; } if (insn & (1 << 11)) { /* Second half of bl. */ offset = ((insn & 0x7ff) << 1) | 1; tmp = load_reg(s, 14); tcg_gen_addi_i32(tmp, tmp, offset); tmp2 = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp2, s->pc | 1); store_reg(s, 14, tmp2); gen_bx(s, tmp); return 0; } if ((s->pc & ~TARGET_PAGE_MASK) == 0) { /* Instruction spans a page boundary. Implement it as two 16-bit instructions in case the second half causes an prefetch abort. */ offset = ((int32_t)insn << 21) >> 9; tcg_gen_movi_i32(cpu_R[14], s->pc + 2 + offset); return 0; } /* Fall through to 32-bit decode. */ } insn = arm_lduw_code(env, s->pc, s->bswap_code); s->pc += 2; insn |= (uint32_t)insn_hw1 << 16; if ((insn & 0xf800e800) != 0xf000e800) { ARCH(6T2); } rn = (insn >> 16) & 0xf; rs = (insn >> 12) & 0xf; rd = (insn >> 8) & 0xf; rm = insn & 0xf; switch ((insn >> 25) & 0xf) { case 0: case 1: case 2: case 3: /* 16-bit instructions. Should never happen. */ abort(); case 4: if (insn & (1 << 22)) { /* Other load/store, table branch. */ if (insn & 0x01200000) { /* Load/store doubleword. */ if (rn == 15) { addr = tcg_temp_new_i32(); tcg_gen_movi_i32(addr, s->pc & ~3); } else { addr = load_reg(s, rn); } offset = (insn & 0xff) * 4; if ((insn & (1 << 23)) == 0) offset = -offset; if (insn & (1 << 24)) { tcg_gen_addi_i32(addr, addr, offset); offset = 0; } if (insn & (1 << 20)) { /* ldrd */ tmp = tcg_temp_new_i32(); tcg_gen_qemu_ld32u(tmp, addr, IS_USER(s)); store_reg(s, rs, tmp); tcg_gen_addi_i32(addr, addr, 4); tmp = tcg_temp_new_i32(); tcg_gen_qemu_ld32u(tmp, addr, IS_USER(s)); store_reg(s, rd, tmp); } else { /* strd */ tmp = load_reg(s, rs); tcg_gen_qemu_st32(tmp, addr, IS_USER(s)); tcg_temp_free_i32(tmp); tcg_gen_addi_i32(addr, addr, 4); tmp = load_reg(s, rd); tcg_gen_qemu_st32(tmp, addr, IS_USER(s)); tcg_temp_free_i32(tmp); } if (insn & (1 << 21)) { /* Base writeback. */ if (rn == 15) goto illegal_op; tcg_gen_addi_i32(addr, addr, offset - 4); store_reg(s, rn, addr); } else { tcg_temp_free_i32(addr); } } else if ((insn & (1 << 23)) == 0) { /* Load/store exclusive word. */ addr = tcg_temp_local_new_i32(); load_reg_var(s, addr, rn); tcg_gen_addi_i32(addr, addr, (insn & 0xff) << 2); if (insn & (1 << 20)) { gen_load_exclusive(s, rs, 15, addr, 2); } else { gen_store_exclusive(s, rd, rs, 15, addr, 2); } tcg_temp_free_i32(addr); } else if ((insn & (7 << 5)) == 0) { /* Table Branch. */ if (rn == 15) { addr = tcg_temp_new_i32(); tcg_gen_movi_i32(addr, s->pc); } else { addr = load_reg(s, rn); } tmp = load_reg(s, rm); tcg_gen_add_i32(addr, addr, tmp); if (insn & (1 << 4)) { /* tbh */ tcg_gen_add_i32(addr, addr, tmp); tcg_temp_free_i32(tmp); tmp = tcg_temp_new_i32(); tcg_gen_qemu_ld16u(tmp, addr, IS_USER(s)); } else { /* tbb */ tcg_temp_free_i32(tmp); tmp = tcg_temp_new_i32(); tcg_gen_qemu_ld8u(tmp, addr, IS_USER(s)); } tcg_temp_free_i32(addr); tcg_gen_shli_i32(tmp, tmp, 1); tcg_gen_addi_i32(tmp, tmp, s->pc); store_reg(s, 15, tmp); } else { int op2 = (insn >> 6) & 0x3; op = (insn >> 4) & 0x3; switch (op2) { case 0: goto illegal_op; case 1: /* Load/store exclusive byte/halfword/doubleword */ if (op == 2) { goto illegal_op; } ARCH(7); break; case 2: /* Load-acquire/store-release */ if (op == 3) { goto illegal_op; } /* Fall through */ case 3: /* Load-acquire/store-release exclusive */ ARCH(8); break; } addr = tcg_temp_local_new_i32(); load_reg_var(s, addr, rn); if (!(op2 & 1)) { if (insn & (1 << 20)) { tmp = tcg_temp_new_i32(); switch (op) { case 0: /* ldab */ tcg_gen_qemu_ld8u(tmp, addr, IS_USER(s)); break; case 1: /* ldah */ tcg_gen_qemu_ld16u(tmp, addr, IS_USER(s)); break; case 2: /* lda */ tcg_gen_qemu_ld32u(tmp, addr, IS_USER(s)); break; default: abort(); } store_reg(s, rs, tmp); } else { tmp = load_reg(s, rs); switch (op) { case 0: /* stlb */ tcg_gen_qemu_st8(tmp, addr, IS_USER(s)); break; case 1: /* stlh */ tcg_gen_qemu_st16(tmp, addr, IS_USER(s)); break; case 2: /* stl */ tcg_gen_qemu_st32(tmp, addr, IS_USER(s)); break; default: abort(); } tcg_temp_free_i32(tmp); } } else if (insn & (1 << 20)) { gen_load_exclusive(s, rs, rd, addr, op); } else { gen_store_exclusive(s, rm, rs, rd, addr, op); } tcg_temp_free_i32(addr); } } else { /* Load/store multiple, RFE, SRS. */ if (((insn >> 23) & 1) == ((insn >> 24) & 1)) { /* RFE, SRS: not available in user mode or on M profile */ if (IS_USER(s) || IS_M(env)) { goto illegal_op; } if (insn & (1 << 20)) { /* rfe */ addr = load_reg(s, rn); if ((insn & (1 << 24)) == 0) tcg_gen_addi_i32(addr, addr, -8); /* Load PC into tmp and CPSR into tmp2. */ tmp = tcg_temp_new_i32(); tcg_gen_qemu_ld32u(tmp, addr, 0); tcg_gen_addi_i32(addr, addr, 4); tmp2 = tcg_temp_new_i32(); tcg_gen_qemu_ld32u(tmp2, addr, 0); if (insn & (1 << 21)) { /* Base writeback. */ if (insn & (1 << 24)) { tcg_gen_addi_i32(addr, addr, 4); } else { tcg_gen_addi_i32(addr, addr, -4); } store_reg(s, rn, addr); } else { tcg_temp_free_i32(addr); } gen_rfe(s, tmp, tmp2); } else { /* srs */ gen_srs(s, (insn & 0x1f), (insn & (1 << 24)) ? 1 : 2, insn & (1 << 21)); } } else { int i, loaded_base = 0; TCGv_i32 loaded_var; /* Load/store multiple. */ addr = load_reg(s, rn); offset = 0; for (i = 0; i < 16; i++) { if (insn & (1 << i)) offset += 4; } if (insn & (1 << 24)) { tcg_gen_addi_i32(addr, addr, -offset); } TCGV_UNUSED_I32(loaded_var); for (i = 0; i < 16; i++) { if ((insn & (1 << i)) == 0) continue; if (insn & (1 << 20)) { /* Load. */ tmp = tcg_temp_new_i32(); tcg_gen_qemu_ld32u(tmp, addr, IS_USER(s)); if (i == 15) { gen_bx(s, tmp); } else if (i == rn) { loaded_var = tmp; loaded_base = 1; } else { store_reg(s, i, tmp); } } else { /* Store. */ tmp = load_reg(s, i); tcg_gen_qemu_st32(tmp, addr, IS_USER(s)); tcg_temp_free_i32(tmp); } tcg_gen_addi_i32(addr, addr, 4); } if (loaded_base) { store_reg(s, rn, loaded_var); } if (insn & (1 << 21)) { /* Base register writeback. */ if (insn & (1 << 24)) { tcg_gen_addi_i32(addr, addr, -offset); } /* Fault if writeback register is in register list. */ if (insn & (1 << rn)) goto illegal_op; store_reg(s, rn, addr); } else { tcg_temp_free_i32(addr); } } } break; case 5: op = (insn >> 21) & 0xf; if (op == 6) { /* Halfword pack. */ tmp = load_reg(s, rn); tmp2 = load_reg(s, rm); shift = ((insn >> 10) & 0x1c) | ((insn >> 6) & 0x3); if (insn & (1 << 5)) { /* pkhtb */ if (shift == 0) shift = 31; tcg_gen_sari_i32(tmp2, tmp2, shift); tcg_gen_andi_i32(tmp, tmp, 0xffff0000); tcg_gen_ext16u_i32(tmp2, tmp2); } else { /* pkhbt */ if (shift) tcg_gen_shli_i32(tmp2, tmp2, shift); tcg_gen_ext16u_i32(tmp, tmp); tcg_gen_andi_i32(tmp2, tmp2, 0xffff0000); } tcg_gen_or_i32(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); store_reg(s, rd, tmp); } else { /* Data processing register constant shift. */ if (rn == 15) { tmp = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp, 0); } else { tmp = load_reg(s, rn); } tmp2 = load_reg(s, rm); shiftop = (insn >> 4) & 3; shift = ((insn >> 6) & 3) | ((insn >> 10) & 0x1c); conds = (insn & (1 << 20)) != 0; logic_cc = (conds && thumb2_logic_op(op)); gen_arm_shift_im(tmp2, shiftop, shift, logic_cc); if (gen_thumb2_data_op(s, op, conds, 0, tmp, tmp2)) goto illegal_op; tcg_temp_free_i32(tmp2); if (rd != 15) { store_reg(s, rd, tmp); } else { tcg_temp_free_i32(tmp); } } break; case 13: /* Misc data processing. */ op = ((insn >> 22) & 6) | ((insn >> 7) & 1); if (op < 4 && (insn & 0xf000) != 0xf000) goto illegal_op; switch (op) { case 0: /* Register controlled shift. */ tmp = load_reg(s, rn); tmp2 = load_reg(s, rm); if ((insn & 0x70) != 0) goto illegal_op; op = (insn >> 21) & 3; logic_cc = (insn & (1 << 20)) != 0; gen_arm_shift_reg(tmp, op, tmp2, logic_cc); if (logic_cc) gen_logic_CC(tmp); store_reg_bx(env, s, rd, tmp); break; case 1: /* Sign/zero extend. */ tmp = load_reg(s, rm); shift = (insn >> 4) & 3; /* ??? In many cases it's not necessary to do a rotate, a shift is sufficient. */ if (shift != 0) tcg_gen_rotri_i32(tmp, tmp, shift * 8); op = (insn >> 20) & 7; switch (op) { case 0: gen_sxth(tmp); break; case 1: gen_uxth(tmp); break; case 2: gen_sxtb16(tmp); break; case 3: gen_uxtb16(tmp); break; case 4: gen_sxtb(tmp); break; case 5: gen_uxtb(tmp); break; default: goto illegal_op; } if (rn != 15) { tmp2 = load_reg(s, rn); if ((op >> 1) == 1) { gen_add16(tmp, tmp2); } else { tcg_gen_add_i32(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); } } store_reg(s, rd, tmp); break; case 2: /* SIMD add/subtract. */ op = (insn >> 20) & 7; shift = (insn >> 4) & 7; if ((op & 3) == 3 || (shift & 3) == 3) goto illegal_op; tmp = load_reg(s, rn); tmp2 = load_reg(s, rm); gen_thumb2_parallel_addsub(op, shift, tmp, tmp2); tcg_temp_free_i32(tmp2); store_reg(s, rd, tmp); break; case 3: /* Other data processing. */ op = ((insn >> 17) & 0x38) | ((insn >> 4) & 7); if (op < 4) { /* Saturating add/subtract. */ tmp = load_reg(s, rn); tmp2 = load_reg(s, rm); if (op & 1) gen_helper_double_saturate(tmp, cpu_env, tmp); if (op & 2) gen_helper_sub_saturate(tmp, cpu_env, tmp2, tmp); else gen_helper_add_saturate(tmp, cpu_env, tmp, tmp2); tcg_temp_free_i32(tmp2); } else { tmp = load_reg(s, rn); switch (op) { case 0x0a: /* rbit */ gen_helper_rbit(tmp, tmp); break; case 0x08: /* rev */ tcg_gen_bswap32_i32(tmp, tmp); break; case 0x09: /* rev16 */ gen_rev16(tmp); break; case 0x0b: /* revsh */ gen_revsh(tmp); break; case 0x10: /* sel */ tmp2 = load_reg(s, rm); tmp3 = tcg_temp_new_i32(); tcg_gen_ld_i32(tmp3, cpu_env, offsetof(CPUARMState, GE)); gen_helper_sel_flags(tmp, tmp3, tmp, tmp2); tcg_temp_free_i32(tmp3); tcg_temp_free_i32(tmp2); break; case 0x18: /* clz */ gen_helper_clz(tmp, tmp); break; default: goto illegal_op; } } store_reg(s, rd, tmp); break; case 4: case 5: /* 32-bit multiply. Sum of absolute differences. */ op = (insn >> 4) & 0xf; tmp = load_reg(s, rn); tmp2 = load_reg(s, rm); switch ((insn >> 20) & 7) { case 0: /* 32 x 32 -> 32 */ tcg_gen_mul_i32(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); if (rs != 15) { tmp2 = load_reg(s, rs); if (op) tcg_gen_sub_i32(tmp, tmp2, tmp); else tcg_gen_add_i32(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); } break; case 1: /* 16 x 16 -> 32 */ gen_mulxy(tmp, tmp2, op & 2, op & 1); tcg_temp_free_i32(tmp2); if (rs != 15) { tmp2 = load_reg(s, rs); gen_helper_add_setq(tmp, cpu_env, tmp, tmp2); tcg_temp_free_i32(tmp2); } break; case 2: /* Dual multiply add. */ case 4: /* Dual multiply subtract. */ if (op) gen_swap_half(tmp2); gen_smul_dual(tmp, tmp2); if (insn & (1 << 22)) { /* This subtraction cannot overflow. */ tcg_gen_sub_i32(tmp, tmp, tmp2); } else { /* This addition cannot overflow 32 bits; * however it may overflow considered as a signed * operation, in which case we must set the Q flag. */ gen_helper_add_setq(tmp, cpu_env, tmp, tmp2); } tcg_temp_free_i32(tmp2); if (rs != 15) { tmp2 = load_reg(s, rs); gen_helper_add_setq(tmp, cpu_env, tmp, tmp2); tcg_temp_free_i32(tmp2); } break; case 3: /* 32 * 16 -> 32msb */ if (op) tcg_gen_sari_i32(tmp2, tmp2, 16); else gen_sxth(tmp2); tmp64 = gen_muls_i64_i32(tmp, tmp2); tcg_gen_shri_i64(tmp64, tmp64, 16); tmp = tcg_temp_new_i32(); tcg_gen_trunc_i64_i32(tmp, tmp64); tcg_temp_free_i64(tmp64); if (rs != 15) { tmp2 = load_reg(s, rs); gen_helper_add_setq(tmp, cpu_env, tmp, tmp2); tcg_temp_free_i32(tmp2); } break; case 5: case 6: /* 32 * 32 -> 32msb (SMMUL, SMMLA, SMMLS) */ tmp64 = gen_muls_i64_i32(tmp, tmp2); if (rs != 15) { tmp = load_reg(s, rs); if (insn & (1 << 20)) { tmp64 = gen_addq_msw(tmp64, tmp); } else { tmp64 = gen_subq_msw(tmp64, tmp); } } if (insn & (1 << 4)) { tcg_gen_addi_i64(tmp64, tmp64, 0x80000000u); } tcg_gen_shri_i64(tmp64, tmp64, 32); tmp = tcg_temp_new_i32(); tcg_gen_trunc_i64_i32(tmp, tmp64); tcg_temp_free_i64(tmp64); break; case 7: /* Unsigned sum of absolute differences. */ gen_helper_usad8(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); if (rs != 15) { tmp2 = load_reg(s, rs); tcg_gen_add_i32(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); } break; } store_reg(s, rd, tmp); break; case 6: case 7: /* 64-bit multiply, Divide. */ op = ((insn >> 4) & 0xf) | ((insn >> 16) & 0x70); tmp = load_reg(s, rn); tmp2 = load_reg(s, rm); if ((op & 0x50) == 0x10) { /* sdiv, udiv */ if (!arm_feature(env, ARM_FEATURE_THUMB_DIV)) { goto illegal_op; } if (op & 0x20) gen_helper_udiv(tmp, tmp, tmp2); else gen_helper_sdiv(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); store_reg(s, rd, tmp); } else if ((op & 0xe) == 0xc) { /* Dual multiply accumulate long. */ if (op & 1) gen_swap_half(tmp2); gen_smul_dual(tmp, tmp2); if (op & 0x10) { tcg_gen_sub_i32(tmp, tmp, tmp2); } else { tcg_gen_add_i32(tmp, tmp, tmp2); } tcg_temp_free_i32(tmp2); /* BUGFIX */ tmp64 = tcg_temp_new_i64(); tcg_gen_ext_i32_i64(tmp64, tmp); tcg_temp_free_i32(tmp); gen_addq(s, tmp64, rs, rd); gen_storeq_reg(s, rs, rd, tmp64); tcg_temp_free_i64(tmp64); } else { if (op & 0x20) { /* Unsigned 64-bit multiply */ tmp64 = gen_mulu_i64_i32(tmp, tmp2); } else { if (op & 8) { /* smlalxy */ gen_mulxy(tmp, tmp2, op & 2, op & 1); tcg_temp_free_i32(tmp2); tmp64 = tcg_temp_new_i64(); tcg_gen_ext_i32_i64(tmp64, tmp); tcg_temp_free_i32(tmp); } else { /* Signed 64-bit multiply */ tmp64 = gen_muls_i64_i32(tmp, tmp2); } } if (op & 4) { /* umaal */ gen_addq_lo(s, tmp64, rs); gen_addq_lo(s, tmp64, rd); } else if (op & 0x40) { /* 64-bit accumulate. */ gen_addq(s, tmp64, rs, rd); } gen_storeq_reg(s, rs, rd, tmp64); tcg_temp_free_i64(tmp64); } break; } break; case 6: case 7: case 14: case 15: /* Coprocessor. */ if (((insn >> 24) & 3) == 3) { /* Translate into the equivalent ARM encoding. */ insn = (insn & 0xe2ffffff) | ((insn & (1 << 28)) >> 4) | (1 << 28); if (disas_neon_data_insn(env, s, insn)) goto illegal_op; } else { if (insn & (1 << 28)) goto illegal_op; if (disas_coproc_insn (env, s, insn)) goto illegal_op; } break; case 8: case 9: case 10: case 11: if (insn & (1 << 15)) { /* Branches, misc control. */ if (insn & 0x5000) { /* Unconditional branch. */ /* signextend(hw1[10:0]) -> offset[:12]. */ offset = ((int32_t)insn << 5) >> 9 & ~(int32_t)0xfff; /* hw1[10:0] -> offset[11:1]. */ offset |= (insn & 0x7ff) << 1; /* (~hw2[13, 11] ^ offset[24]) -> offset[23,22] offset[24:22] already have the same value because of the sign extension above. */ offset ^= ((~insn) & (1 << 13)) << 10; offset ^= ((~insn) & (1 << 11)) << 11; if (insn & (1 << 14)) { /* Branch and link. */ tcg_gen_movi_i32(cpu_R[14], s->pc | 1); } offset += s->pc; if (insn & (1 << 12)) { /* b/bl */ gen_jmp(s, offset); } else { /* blx */ offset &= ~(uint32_t)2; /* thumb2 bx, no need to check */ gen_bx_im(s, offset); } } else if (((insn >> 23) & 7) == 7) { /* Misc control */ if (insn & (1 << 13)) goto illegal_op; if (insn & (1 << 26)) { /* Secure monitor call (v6Z) */ goto illegal_op; /* not implemented. */ } else { op = (insn >> 20) & 7; switch (op) { case 0: /* msr cpsr. */ if (IS_M(env)) { tmp = load_reg(s, rn); addr = tcg_const_i32(insn & 0xff); gen_helper_v7m_msr(cpu_env, addr, tmp); tcg_temp_free_i32(addr); tcg_temp_free_i32(tmp); gen_lookup_tb(s); break; } /* fall through */ case 1: /* msr spsr. */ if (IS_M(env)) goto illegal_op; tmp = load_reg(s, rn); if (gen_set_psr(s, msr_mask(env, s, (insn >> 8) & 0xf, op == 1), op == 1, tmp)) goto illegal_op; break; case 2: /* cps, nop-hint. */ if (((insn >> 8) & 7) == 0) { gen_nop_hint(s, insn & 0xff); } /* Implemented as NOP in user mode. */ if (IS_USER(s)) break; offset = 0; imm = 0; if (insn & (1 << 10)) { if (insn & (1 << 7)) offset |= CPSR_A; if (insn & (1 << 6)) offset |= CPSR_I; if (insn & (1 << 5)) offset |= CPSR_F; if (insn & (1 << 9)) imm = CPSR_A | CPSR_I | CPSR_F; } if (insn & (1 << 8)) { offset |= 0x1f; imm |= (insn & 0x1f); } if (offset) { gen_set_psr_im(s, offset, 0, imm); } break; case 3: /* Special control operations. */ ARCH(7); op = (insn >> 4) & 0xf; switch (op) { case 2: /* clrex */ gen_clrex(s); break; case 4: /* dsb */ case 5: /* dmb */ case 6: /* isb */ /* These execute as NOPs. */ break; default: goto illegal_op; } break; case 4: /* bxj */ /* Trivial implementation equivalent to bx. */ tmp = load_reg(s, rn); gen_bx(s, tmp); break; case 5: /* Exception return. */ if (IS_USER(s)) { goto illegal_op; } if (rn != 14 || rd != 15) { goto illegal_op; } tmp = load_reg(s, rn); tcg_gen_subi_i32(tmp, tmp, insn & 0xff); gen_exception_return(s, tmp); break; case 6: /* mrs cpsr. */ tmp = tcg_temp_new_i32(); if (IS_M(env)) { addr = tcg_const_i32(insn & 0xff); gen_helper_v7m_mrs(tmp, cpu_env, addr); tcg_temp_free_i32(addr); } else { gen_helper_cpsr_read(tmp, cpu_env); } store_reg(s, rd, tmp); break; case 7: /* mrs spsr. */ /* Not accessible in user mode. */ if (IS_USER(s) || IS_M(env)) goto illegal_op; tmp = load_cpu_field(spsr); store_reg(s, rd, tmp); break; } } } else { /* Conditional branch. */ op = (insn >> 22) & 0xf; /* Generate a conditional jump to next instruction. */ s->condlabel = gen_new_label(); gen_test_cc(op ^ 1, s->condlabel); s->condjmp = 1; /* offset[11:1] = insn[10:0] */ offset = (insn & 0x7ff) << 1; /* offset[17:12] = insn[21:16]. */ offset |= (insn & 0x003f0000) >> 4; /* offset[31:20] = insn[26]. */ offset |= ((int32_t)((insn << 5) & 0x80000000)) >> 11; /* offset[18] = insn[13]. */ offset |= (insn & (1 << 13)) << 5; /* offset[19] = insn[11]. */ offset |= (insn & (1 << 11)) << 8; /* jump to the offset */ gen_jmp(s, s->pc + offset); } } else { /* Data processing immediate. */ if (insn & (1 << 25)) { if (insn & (1 << 24)) { if (insn & (1 << 20)) goto illegal_op; /* Bitfield/Saturate. */ op = (insn >> 21) & 7; imm = insn & 0x1f; shift = ((insn >> 6) & 3) | ((insn >> 10) & 0x1c); if (rn == 15) { tmp = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp, 0); } else { tmp = load_reg(s, rn); } switch (op) { case 2: /* Signed bitfield extract. */ imm++; if (shift + imm > 32) goto illegal_op; if (imm < 32) gen_sbfx(tmp, shift, imm); break; case 6: /* Unsigned bitfield extract. */ imm++; if (shift + imm > 32) goto illegal_op; if (imm < 32) gen_ubfx(tmp, shift, (1u << imm) - 1); break; case 3: /* Bitfield insert/clear. */ if (imm < shift) goto illegal_op; imm = imm + 1 - shift; if (imm != 32) { tmp2 = load_reg(s, rd); tcg_gen_deposit_i32(tmp, tmp2, tmp, shift, imm); tcg_temp_free_i32(tmp2); } break; case 7: goto illegal_op; default: /* Saturate. */ if (shift) { if (op & 1) tcg_gen_sari_i32(tmp, tmp, shift); else tcg_gen_shli_i32(tmp, tmp, shift); } tmp2 = tcg_const_i32(imm); if (op & 4) { /* Unsigned. */ if ((op & 1) && shift == 0) gen_helper_usat16(tmp, cpu_env, tmp, tmp2); else gen_helper_usat(tmp, cpu_env, tmp, tmp2); } else { /* Signed. */ if ((op & 1) && shift == 0) gen_helper_ssat16(tmp, cpu_env, tmp, tmp2); else gen_helper_ssat(tmp, cpu_env, tmp, tmp2); } tcg_temp_free_i32(tmp2); break; } store_reg(s, rd, tmp); } else { imm = ((insn & 0x04000000) >> 15) | ((insn & 0x7000) >> 4) | (insn & 0xff); if (insn & (1 << 22)) { /* 16-bit immediate. */ imm |= (insn >> 4) & 0xf000; if (insn & (1 << 23)) { /* movt */ tmp = load_reg(s, rd); tcg_gen_ext16u_i32(tmp, tmp); tcg_gen_ori_i32(tmp, tmp, imm << 16); } else { /* movw */ tmp = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp, imm); } } else { /* Add/sub 12-bit immediate. */ if (rn == 15) { offset = s->pc & ~(uint32_t)3; if (insn & (1 << 23)) offset -= imm; else offset += imm; tmp = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp, offset); } else { tmp = load_reg(s, rn); if (insn & (1 << 23)) tcg_gen_subi_i32(tmp, tmp, imm); else tcg_gen_addi_i32(tmp, tmp, imm); } } store_reg(s, rd, tmp); } } else { int shifter_out = 0; /* modified 12-bit immediate. */ shift = ((insn & 0x04000000) >> 23) | ((insn & 0x7000) >> 12); imm = (insn & 0xff); switch (shift) { case 0: /* XY */ /* Nothing to do. */ break; case 1: /* 00XY00XY */ imm |= imm << 16; break; case 2: /* XY00XY00 */ imm |= imm << 16; imm <<= 8; break; case 3: /* XYXYXYXY */ imm |= imm << 16; imm |= imm << 8; break; default: /* Rotated constant. */ shift = (shift << 1) | (imm >> 7); imm |= 0x80; imm = imm << (32 - shift); shifter_out = 1; break; } tmp2 = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp2, imm); rn = (insn >> 16) & 0xf; if (rn == 15) { tmp = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp, 0); } else { tmp = load_reg(s, rn); } op = (insn >> 21) & 0xf; if (gen_thumb2_data_op(s, op, (insn & (1 << 20)) != 0, shifter_out, tmp, tmp2)) goto illegal_op; tcg_temp_free_i32(tmp2); rd = (insn >> 8) & 0xf; if (rd != 15) { store_reg(s, rd, tmp); } else { tcg_temp_free_i32(tmp); } } } break; case 12: /* Load/store single data item. */ { int postinc = 0; int writeback = 0; int user; if ((insn & 0x01100000) == 0x01000000) { if (disas_neon_ls_insn(env, s, insn)) goto illegal_op; break; } op = ((insn >> 21) & 3) | ((insn >> 22) & 4); if (rs == 15) { if (!(insn & (1 << 20))) { goto illegal_op; } if (op != 2) { /* Byte or halfword load space with dest == r15 : memory hints. * Catch them early so we don't emit pointless addressing code. * This space is a mix of: * PLD/PLDW/PLI, which we implement as NOPs (note that unlike * the ARM encodings, PLDW space doesn't UNDEF for non-v7MP * cores) * unallocated hints, which must be treated as NOPs * UNPREDICTABLE space, which we NOP or UNDEF depending on * which is easiest for the decoding logic * Some space which must UNDEF */ int op1 = (insn >> 23) & 3; int op2 = (insn >> 6) & 0x3f; if (op & 2) { goto illegal_op; } if (rn == 15) { /* UNPREDICTABLE, unallocated hint or * PLD/PLDW/PLI (literal) */ return 0; } if (op1 & 1) { return 0; /* PLD/PLDW/PLI or unallocated hint */ } if ((op2 == 0) || ((op2 & 0x3c) == 0x30)) { return 0; /* PLD/PLDW/PLI or unallocated hint */ } /* UNDEF space, or an UNPREDICTABLE */ return 1; } } user = IS_USER(s); if (rn == 15) { addr = tcg_temp_new_i32(); /* PC relative. */ /* s->pc has already been incremented by 4. */ imm = s->pc & 0xfffffffc; if (insn & (1 << 23)) imm += insn & 0xfff; else imm -= insn & 0xfff; tcg_gen_movi_i32(addr, imm); } else { addr = load_reg(s, rn); if (insn & (1 << 23)) { /* Positive offset. */ imm = insn & 0xfff; tcg_gen_addi_i32(addr, addr, imm); } else { imm = insn & 0xff; switch ((insn >> 8) & 0xf) { case 0x0: /* Shifted Register. */ shift = (insn >> 4) & 0xf; if (shift > 3) { tcg_temp_free_i32(addr); goto illegal_op; } tmp = load_reg(s, rm); if (shift) tcg_gen_shli_i32(tmp, tmp, shift); tcg_gen_add_i32(addr, addr, tmp); tcg_temp_free_i32(tmp); break; case 0xc: /* Negative offset. */ tcg_gen_addi_i32(addr, addr, -imm); break; case 0xe: /* User privilege. */ tcg_gen_addi_i32(addr, addr, imm); user = 1; break; case 0x9: /* Post-decrement. */ imm = -imm; /* Fall through. */ case 0xb: /* Post-increment. */ postinc = 1; writeback = 1; break; case 0xd: /* Pre-decrement. */ imm = -imm; /* Fall through. */ case 0xf: /* Pre-increment. */ tcg_gen_addi_i32(addr, addr, imm); writeback = 1; break; default: tcg_temp_free_i32(addr); goto illegal_op; } } } if (insn & (1 << 20)) { /* Load. */ tmp = tcg_temp_new_i32(); switch (op) { case 0: tcg_gen_qemu_ld8u(tmp, addr, user); break; case 4: tcg_gen_qemu_ld8s(tmp, addr, user); break; case 1: tcg_gen_qemu_ld16u(tmp, addr, user); break; case 5: tcg_gen_qemu_ld16s(tmp, addr, user); break; case 2: tcg_gen_qemu_ld32u(tmp, addr, user); break; default: tcg_temp_free_i32(tmp); tcg_temp_free_i32(addr); goto illegal_op; } if (rs == 15) { gen_bx(s, tmp); } else { store_reg(s, rs, tmp); } } else { /* Store. */ tmp = load_reg(s, rs); switch (op) { case 0: tcg_gen_qemu_st8(tmp, addr, user); break; case 1: tcg_gen_qemu_st16(tmp, addr, user); break; case 2: tcg_gen_qemu_st32(tmp, addr, user); break; default: tcg_temp_free_i32(tmp); tcg_temp_free_i32(addr); goto illegal_op; } tcg_temp_free_i32(tmp); } if (postinc) tcg_gen_addi_i32(addr, addr, imm); if (writeback) { store_reg(s, rn, addr); } else { tcg_temp_free_i32(addr); } } break; default: goto illegal_op; } return 0; illegal_op: return 1; }
true
qemu
e0c270d946dc8efd723129b6a9d956b3084b55b1
static int disas_thumb2_insn(CPUARMState *env, DisasContext *s, uint16_t insn_hw1) { uint32_t insn, imm, shift, offset; uint32_t rd, rn, rm, rs; TCGv_i32 tmp; TCGv_i32 tmp2; TCGv_i32 tmp3; TCGv_i32 addr; TCGv_i64 tmp64; int op; int shiftop; int conds; int logic_cc; if (!(arm_feature(env, ARM_FEATURE_THUMB2) || arm_feature (env, ARM_FEATURE_M))) { insn = insn_hw1; if ((insn & (1 << 12)) == 0) { ARCH(5); offset = ((insn & 0x7ff) << 1); tmp = load_reg(s, 14); tcg_gen_addi_i32(tmp, tmp, offset); tcg_gen_andi_i32(tmp, tmp, 0xfffffffc); tmp2 = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp2, s->pc | 1); store_reg(s, 14, tmp2); gen_bx(s, tmp); return 0; } if (insn & (1 << 11)) { offset = ((insn & 0x7ff) << 1) | 1; tmp = load_reg(s, 14); tcg_gen_addi_i32(tmp, tmp, offset); tmp2 = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp2, s->pc | 1); store_reg(s, 14, tmp2); gen_bx(s, tmp); return 0; } if ((s->pc & ~TARGET_PAGE_MASK) == 0) { offset = ((int32_t)insn << 21) >> 9; tcg_gen_movi_i32(cpu_R[14], s->pc + 2 + offset); return 0; } } insn = arm_lduw_code(env, s->pc, s->bswap_code); s->pc += 2; insn |= (uint32_t)insn_hw1 << 16; if ((insn & 0xf800e800) != 0xf000e800) { ARCH(6T2); } rn = (insn >> 16) & 0xf; rs = (insn >> 12) & 0xf; rd = (insn >> 8) & 0xf; rm = insn & 0xf; switch ((insn >> 25) & 0xf) { case 0: case 1: case 2: case 3: abort(); case 4: if (insn & (1 << 22)) { if (insn & 0x01200000) { if (rn == 15) { addr = tcg_temp_new_i32(); tcg_gen_movi_i32(addr, s->pc & ~3); } else { addr = load_reg(s, rn); } offset = (insn & 0xff) * 4; if ((insn & (1 << 23)) == 0) offset = -offset; if (insn & (1 << 24)) { tcg_gen_addi_i32(addr, addr, offset); offset = 0; } if (insn & (1 << 20)) { tmp = tcg_temp_new_i32(); tcg_gen_qemu_ld32u(tmp, addr, IS_USER(s)); store_reg(s, rs, tmp); tcg_gen_addi_i32(addr, addr, 4); tmp = tcg_temp_new_i32(); tcg_gen_qemu_ld32u(tmp, addr, IS_USER(s)); store_reg(s, rd, tmp); } else { tmp = load_reg(s, rs); tcg_gen_qemu_st32(tmp, addr, IS_USER(s)); tcg_temp_free_i32(tmp); tcg_gen_addi_i32(addr, addr, 4); tmp = load_reg(s, rd); tcg_gen_qemu_st32(tmp, addr, IS_USER(s)); tcg_temp_free_i32(tmp); } if (insn & (1 << 21)) { if (rn == 15) goto illegal_op; tcg_gen_addi_i32(addr, addr, offset - 4); store_reg(s, rn, addr); } else { tcg_temp_free_i32(addr); } } else if ((insn & (1 << 23)) == 0) { addr = tcg_temp_local_new_i32(); load_reg_var(s, addr, rn); tcg_gen_addi_i32(addr, addr, (insn & 0xff) << 2); if (insn & (1 << 20)) { gen_load_exclusive(s, rs, 15, addr, 2); } else { gen_store_exclusive(s, rd, rs, 15, addr, 2); } tcg_temp_free_i32(addr); } else if ((insn & (7 << 5)) == 0) { if (rn == 15) { addr = tcg_temp_new_i32(); tcg_gen_movi_i32(addr, s->pc); } else { addr = load_reg(s, rn); } tmp = load_reg(s, rm); tcg_gen_add_i32(addr, addr, tmp); if (insn & (1 << 4)) { tcg_gen_add_i32(addr, addr, tmp); tcg_temp_free_i32(tmp); tmp = tcg_temp_new_i32(); tcg_gen_qemu_ld16u(tmp, addr, IS_USER(s)); } else { tcg_temp_free_i32(tmp); tmp = tcg_temp_new_i32(); tcg_gen_qemu_ld8u(tmp, addr, IS_USER(s)); } tcg_temp_free_i32(addr); tcg_gen_shli_i32(tmp, tmp, 1); tcg_gen_addi_i32(tmp, tmp, s->pc); store_reg(s, 15, tmp); } else { int op2 = (insn >> 6) & 0x3; op = (insn >> 4) & 0x3; switch (op2) { case 0: goto illegal_op; case 1: if (op == 2) { goto illegal_op; } ARCH(7); break; case 2: if (op == 3) { goto illegal_op; } case 3: ARCH(8); break; } addr = tcg_temp_local_new_i32(); load_reg_var(s, addr, rn); if (!(op2 & 1)) { if (insn & (1 << 20)) { tmp = tcg_temp_new_i32(); switch (op) { case 0: tcg_gen_qemu_ld8u(tmp, addr, IS_USER(s)); break; case 1: tcg_gen_qemu_ld16u(tmp, addr, IS_USER(s)); break; case 2: tcg_gen_qemu_ld32u(tmp, addr, IS_USER(s)); break; default: abort(); } store_reg(s, rs, tmp); } else { tmp = load_reg(s, rs); switch (op) { case 0: tcg_gen_qemu_st8(tmp, addr, IS_USER(s)); break; case 1: tcg_gen_qemu_st16(tmp, addr, IS_USER(s)); break; case 2: tcg_gen_qemu_st32(tmp, addr, IS_USER(s)); break; default: abort(); } tcg_temp_free_i32(tmp); } } else if (insn & (1 << 20)) { gen_load_exclusive(s, rs, rd, addr, op); } else { gen_store_exclusive(s, rm, rs, rd, addr, op); } tcg_temp_free_i32(addr); } } else { if (((insn >> 23) & 1) == ((insn >> 24) & 1)) { if (IS_USER(s) || IS_M(env)) { goto illegal_op; } if (insn & (1 << 20)) { addr = load_reg(s, rn); if ((insn & (1 << 24)) == 0) tcg_gen_addi_i32(addr, addr, -8); tmp = tcg_temp_new_i32(); tcg_gen_qemu_ld32u(tmp, addr, 0); tcg_gen_addi_i32(addr, addr, 4); tmp2 = tcg_temp_new_i32(); tcg_gen_qemu_ld32u(tmp2, addr, 0); if (insn & (1 << 21)) { if (insn & (1 << 24)) { tcg_gen_addi_i32(addr, addr, 4); } else { tcg_gen_addi_i32(addr, addr, -4); } store_reg(s, rn, addr); } else { tcg_temp_free_i32(addr); } gen_rfe(s, tmp, tmp2); } else { gen_srs(s, (insn & 0x1f), (insn & (1 << 24)) ? 1 : 2, insn & (1 << 21)); } } else { int i, loaded_base = 0; TCGv_i32 loaded_var; addr = load_reg(s, rn); offset = 0; for (i = 0; i < 16; i++) { if (insn & (1 << i)) offset += 4; } if (insn & (1 << 24)) { tcg_gen_addi_i32(addr, addr, -offset); } TCGV_UNUSED_I32(loaded_var); for (i = 0; i < 16; i++) { if ((insn & (1 << i)) == 0) continue; if (insn & (1 << 20)) { tmp = tcg_temp_new_i32(); tcg_gen_qemu_ld32u(tmp, addr, IS_USER(s)); if (i == 15) { gen_bx(s, tmp); } else if (i == rn) { loaded_var = tmp; loaded_base = 1; } else { store_reg(s, i, tmp); } } else { tmp = load_reg(s, i); tcg_gen_qemu_st32(tmp, addr, IS_USER(s)); tcg_temp_free_i32(tmp); } tcg_gen_addi_i32(addr, addr, 4); } if (loaded_base) { store_reg(s, rn, loaded_var); } if (insn & (1 << 21)) { if (insn & (1 << 24)) { tcg_gen_addi_i32(addr, addr, -offset); } if (insn & (1 << rn)) goto illegal_op; store_reg(s, rn, addr); } else { tcg_temp_free_i32(addr); } } } break; case 5: op = (insn >> 21) & 0xf; if (op == 6) { tmp = load_reg(s, rn); tmp2 = load_reg(s, rm); shift = ((insn >> 10) & 0x1c) | ((insn >> 6) & 0x3); if (insn & (1 << 5)) { if (shift == 0) shift = 31; tcg_gen_sari_i32(tmp2, tmp2, shift); tcg_gen_andi_i32(tmp, tmp, 0xffff0000); tcg_gen_ext16u_i32(tmp2, tmp2); } else { if (shift) tcg_gen_shli_i32(tmp2, tmp2, shift); tcg_gen_ext16u_i32(tmp, tmp); tcg_gen_andi_i32(tmp2, tmp2, 0xffff0000); } tcg_gen_or_i32(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); store_reg(s, rd, tmp); } else { if (rn == 15) { tmp = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp, 0); } else { tmp = load_reg(s, rn); } tmp2 = load_reg(s, rm); shiftop = (insn >> 4) & 3; shift = ((insn >> 6) & 3) | ((insn >> 10) & 0x1c); conds = (insn & (1 << 20)) != 0; logic_cc = (conds && thumb2_logic_op(op)); gen_arm_shift_im(tmp2, shiftop, shift, logic_cc); if (gen_thumb2_data_op(s, op, conds, 0, tmp, tmp2)) goto illegal_op; tcg_temp_free_i32(tmp2); if (rd != 15) { store_reg(s, rd, tmp); } else { tcg_temp_free_i32(tmp); } } break; case 13: op = ((insn >> 22) & 6) | ((insn >> 7) & 1); if (op < 4 && (insn & 0xf000) != 0xf000) goto illegal_op; switch (op) { case 0: tmp = load_reg(s, rn); tmp2 = load_reg(s, rm); if ((insn & 0x70) != 0) goto illegal_op; op = (insn >> 21) & 3; logic_cc = (insn & (1 << 20)) != 0; gen_arm_shift_reg(tmp, op, tmp2, logic_cc); if (logic_cc) gen_logic_CC(tmp); store_reg_bx(env, s, rd, tmp); break; case 1: tmp = load_reg(s, rm); shift = (insn >> 4) & 3; if (shift != 0) tcg_gen_rotri_i32(tmp, tmp, shift * 8); op = (insn >> 20) & 7; switch (op) { case 0: gen_sxth(tmp); break; case 1: gen_uxth(tmp); break; case 2: gen_sxtb16(tmp); break; case 3: gen_uxtb16(tmp); break; case 4: gen_sxtb(tmp); break; case 5: gen_uxtb(tmp); break; default: goto illegal_op; } if (rn != 15) { tmp2 = load_reg(s, rn); if ((op >> 1) == 1) { gen_add16(tmp, tmp2); } else { tcg_gen_add_i32(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); } } store_reg(s, rd, tmp); break; case 2: op = (insn >> 20) & 7; shift = (insn >> 4) & 7; if ((op & 3) == 3 || (shift & 3) == 3) goto illegal_op; tmp = load_reg(s, rn); tmp2 = load_reg(s, rm); gen_thumb2_parallel_addsub(op, shift, tmp, tmp2); tcg_temp_free_i32(tmp2); store_reg(s, rd, tmp); break; case 3: op = ((insn >> 17) & 0x38) | ((insn >> 4) & 7); if (op < 4) { tmp = load_reg(s, rn); tmp2 = load_reg(s, rm); if (op & 1) gen_helper_double_saturate(tmp, cpu_env, tmp); if (op & 2) gen_helper_sub_saturate(tmp, cpu_env, tmp2, tmp); else gen_helper_add_saturate(tmp, cpu_env, tmp, tmp2); tcg_temp_free_i32(tmp2); } else { tmp = load_reg(s, rn); switch (op) { case 0x0a: gen_helper_rbit(tmp, tmp); break; case 0x08: tcg_gen_bswap32_i32(tmp, tmp); break; case 0x09: gen_rev16(tmp); break; case 0x0b: gen_revsh(tmp); break; case 0x10: tmp2 = load_reg(s, rm); tmp3 = tcg_temp_new_i32(); tcg_gen_ld_i32(tmp3, cpu_env, offsetof(CPUARMState, GE)); gen_helper_sel_flags(tmp, tmp3, tmp, tmp2); tcg_temp_free_i32(tmp3); tcg_temp_free_i32(tmp2); break; case 0x18: gen_helper_clz(tmp, tmp); break; default: goto illegal_op; } } store_reg(s, rd, tmp); break; case 4: case 5: op = (insn >> 4) & 0xf; tmp = load_reg(s, rn); tmp2 = load_reg(s, rm); switch ((insn >> 20) & 7) { case 0: tcg_gen_mul_i32(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); if (rs != 15) { tmp2 = load_reg(s, rs); if (op) tcg_gen_sub_i32(tmp, tmp2, tmp); else tcg_gen_add_i32(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); } break; case 1: gen_mulxy(tmp, tmp2, op & 2, op & 1); tcg_temp_free_i32(tmp2); if (rs != 15) { tmp2 = load_reg(s, rs); gen_helper_add_setq(tmp, cpu_env, tmp, tmp2); tcg_temp_free_i32(tmp2); } break; case 2: case 4: if (op) gen_swap_half(tmp2); gen_smul_dual(tmp, tmp2); if (insn & (1 << 22)) { tcg_gen_sub_i32(tmp, tmp, tmp2); } else { gen_helper_add_setq(tmp, cpu_env, tmp, tmp2); } tcg_temp_free_i32(tmp2); if (rs != 15) { tmp2 = load_reg(s, rs); gen_helper_add_setq(tmp, cpu_env, tmp, tmp2); tcg_temp_free_i32(tmp2); } break; case 3: if (op) tcg_gen_sari_i32(tmp2, tmp2, 16); else gen_sxth(tmp2); tmp64 = gen_muls_i64_i32(tmp, tmp2); tcg_gen_shri_i64(tmp64, tmp64, 16); tmp = tcg_temp_new_i32(); tcg_gen_trunc_i64_i32(tmp, tmp64); tcg_temp_free_i64(tmp64); if (rs != 15) { tmp2 = load_reg(s, rs); gen_helper_add_setq(tmp, cpu_env, tmp, tmp2); tcg_temp_free_i32(tmp2); } break; case 5: case 6: tmp64 = gen_muls_i64_i32(tmp, tmp2); if (rs != 15) { tmp = load_reg(s, rs); if (insn & (1 << 20)) { tmp64 = gen_addq_msw(tmp64, tmp); } else { tmp64 = gen_subq_msw(tmp64, tmp); } } if (insn & (1 << 4)) { tcg_gen_addi_i64(tmp64, tmp64, 0x80000000u); } tcg_gen_shri_i64(tmp64, tmp64, 32); tmp = tcg_temp_new_i32(); tcg_gen_trunc_i64_i32(tmp, tmp64); tcg_temp_free_i64(tmp64); break; case 7: gen_helper_usad8(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); if (rs != 15) { tmp2 = load_reg(s, rs); tcg_gen_add_i32(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); } break; } store_reg(s, rd, tmp); break; case 6: case 7: op = ((insn >> 4) & 0xf) | ((insn >> 16) & 0x70); tmp = load_reg(s, rn); tmp2 = load_reg(s, rm); if ((op & 0x50) == 0x10) { if (!arm_feature(env, ARM_FEATURE_THUMB_DIV)) { goto illegal_op; } if (op & 0x20) gen_helper_udiv(tmp, tmp, tmp2); else gen_helper_sdiv(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); store_reg(s, rd, tmp); } else if ((op & 0xe) == 0xc) { if (op & 1) gen_swap_half(tmp2); gen_smul_dual(tmp, tmp2); if (op & 0x10) { tcg_gen_sub_i32(tmp, tmp, tmp2); } else { tcg_gen_add_i32(tmp, tmp, tmp2); } tcg_temp_free_i32(tmp2); tmp64 = tcg_temp_new_i64(); tcg_gen_ext_i32_i64(tmp64, tmp); tcg_temp_free_i32(tmp); gen_addq(s, tmp64, rs, rd); gen_storeq_reg(s, rs, rd, tmp64); tcg_temp_free_i64(tmp64); } else { if (op & 0x20) { tmp64 = gen_mulu_i64_i32(tmp, tmp2); } else { if (op & 8) { gen_mulxy(tmp, tmp2, op & 2, op & 1); tcg_temp_free_i32(tmp2); tmp64 = tcg_temp_new_i64(); tcg_gen_ext_i32_i64(tmp64, tmp); tcg_temp_free_i32(tmp); } else { tmp64 = gen_muls_i64_i32(tmp, tmp2); } } if (op & 4) { gen_addq_lo(s, tmp64, rs); gen_addq_lo(s, tmp64, rd); } else if (op & 0x40) { gen_addq(s, tmp64, rs, rd); } gen_storeq_reg(s, rs, rd, tmp64); tcg_temp_free_i64(tmp64); } break; } break; case 6: case 7: case 14: case 15: if (((insn >> 24) & 3) == 3) { insn = (insn & 0xe2ffffff) | ((insn & (1 << 28)) >> 4) | (1 << 28); if (disas_neon_data_insn(env, s, insn)) goto illegal_op; } else { if (insn & (1 << 28)) goto illegal_op; if (disas_coproc_insn (env, s, insn)) goto illegal_op; } break; case 8: case 9: case 10: case 11: if (insn & (1 << 15)) { if (insn & 0x5000) { offset = ((int32_t)insn << 5) >> 9 & ~(int32_t)0xfff; offset |= (insn & 0x7ff) << 1; offset ^= ((~insn) & (1 << 13)) << 10; offset ^= ((~insn) & (1 << 11)) << 11; if (insn & (1 << 14)) { tcg_gen_movi_i32(cpu_R[14], s->pc | 1); } offset += s->pc; if (insn & (1 << 12)) { gen_jmp(s, offset); } else { offset &= ~(uint32_t)2; gen_bx_im(s, offset); } } else if (((insn >> 23) & 7) == 7) { if (insn & (1 << 13)) goto illegal_op; if (insn & (1 << 26)) { goto illegal_op; } else { op = (insn >> 20) & 7; switch (op) { case 0: if (IS_M(env)) { tmp = load_reg(s, rn); addr = tcg_const_i32(insn & 0xff); gen_helper_v7m_msr(cpu_env, addr, tmp); tcg_temp_free_i32(addr); tcg_temp_free_i32(tmp); gen_lookup_tb(s); break; } case 1: if (IS_M(env)) goto illegal_op; tmp = load_reg(s, rn); if (gen_set_psr(s, msr_mask(env, s, (insn >> 8) & 0xf, op == 1), op == 1, tmp)) goto illegal_op; break; case 2: if (((insn >> 8) & 7) == 0) { gen_nop_hint(s, insn & 0xff); } if (IS_USER(s)) break; offset = 0; imm = 0; if (insn & (1 << 10)) { if (insn & (1 << 7)) offset |= CPSR_A; if (insn & (1 << 6)) offset |= CPSR_I; if (insn & (1 << 5)) offset |= CPSR_F; if (insn & (1 << 9)) imm = CPSR_A | CPSR_I | CPSR_F; } if (insn & (1 << 8)) { offset |= 0x1f; imm |= (insn & 0x1f); } if (offset) { gen_set_psr_im(s, offset, 0, imm); } break; case 3: ARCH(7); op = (insn >> 4) & 0xf; switch (op) { case 2: gen_clrex(s); break; case 4: case 5: case 6: break; default: goto illegal_op; } break; case 4: tmp = load_reg(s, rn); gen_bx(s, tmp); break; case 5: if (IS_USER(s)) { goto illegal_op; } if (rn != 14 || rd != 15) { goto illegal_op; } tmp = load_reg(s, rn); tcg_gen_subi_i32(tmp, tmp, insn & 0xff); gen_exception_return(s, tmp); break; case 6: tmp = tcg_temp_new_i32(); if (IS_M(env)) { addr = tcg_const_i32(insn & 0xff); gen_helper_v7m_mrs(tmp, cpu_env, addr); tcg_temp_free_i32(addr); } else { gen_helper_cpsr_read(tmp, cpu_env); } store_reg(s, rd, tmp); break; case 7: if (IS_USER(s) || IS_M(env)) goto illegal_op; tmp = load_cpu_field(spsr); store_reg(s, rd, tmp); break; } } } else { op = (insn >> 22) & 0xf; s->condlabel = gen_new_label(); gen_test_cc(op ^ 1, s->condlabel); s->condjmp = 1; offset = (insn & 0x7ff) << 1; offset |= (insn & 0x003f0000) >> 4; offset |= ((int32_t)((insn << 5) & 0x80000000)) >> 11; offset |= (insn & (1 << 13)) << 5; offset |= (insn & (1 << 11)) << 8; gen_jmp(s, s->pc + offset); } } else { if (insn & (1 << 25)) { if (insn & (1 << 24)) { if (insn & (1 << 20)) goto illegal_op; op = (insn >> 21) & 7; imm = insn & 0x1f; shift = ((insn >> 6) & 3) | ((insn >> 10) & 0x1c); if (rn == 15) { tmp = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp, 0); } else { tmp = load_reg(s, rn); } switch (op) { case 2: imm++; if (shift + imm > 32) goto illegal_op; if (imm < 32) gen_sbfx(tmp, shift, imm); break; case 6: imm++; if (shift + imm > 32) goto illegal_op; if (imm < 32) gen_ubfx(tmp, shift, (1u << imm) - 1); break; case 3: if (imm < shift) goto illegal_op; imm = imm + 1 - shift; if (imm != 32) { tmp2 = load_reg(s, rd); tcg_gen_deposit_i32(tmp, tmp2, tmp, shift, imm); tcg_temp_free_i32(tmp2); } break; case 7: goto illegal_op; default: if (shift) { if (op & 1) tcg_gen_sari_i32(tmp, tmp, shift); else tcg_gen_shli_i32(tmp, tmp, shift); } tmp2 = tcg_const_i32(imm); if (op & 4) { if ((op & 1) && shift == 0) gen_helper_usat16(tmp, cpu_env, tmp, tmp2); else gen_helper_usat(tmp, cpu_env, tmp, tmp2); } else { if ((op & 1) && shift == 0) gen_helper_ssat16(tmp, cpu_env, tmp, tmp2); else gen_helper_ssat(tmp, cpu_env, tmp, tmp2); } tcg_temp_free_i32(tmp2); break; } store_reg(s, rd, tmp); } else { imm = ((insn & 0x04000000) >> 15) | ((insn & 0x7000) >> 4) | (insn & 0xff); if (insn & (1 << 22)) { imm |= (insn >> 4) & 0xf000; if (insn & (1 << 23)) { tmp = load_reg(s, rd); tcg_gen_ext16u_i32(tmp, tmp); tcg_gen_ori_i32(tmp, tmp, imm << 16); } else { tmp = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp, imm); } } else { if (rn == 15) { offset = s->pc & ~(uint32_t)3; if (insn & (1 << 23)) offset -= imm; else offset += imm; tmp = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp, offset); } else { tmp = load_reg(s, rn); if (insn & (1 << 23)) tcg_gen_subi_i32(tmp, tmp, imm); else tcg_gen_addi_i32(tmp, tmp, imm); } } store_reg(s, rd, tmp); } } else { int shifter_out = 0; shift = ((insn & 0x04000000) >> 23) | ((insn & 0x7000) >> 12); imm = (insn & 0xff); switch (shift) { case 0: break; case 1: imm |= imm << 16; break; case 2: imm |= imm << 16; imm <<= 8; break; case 3: imm |= imm << 16; imm |= imm << 8; break; default: shift = (shift << 1) | (imm >> 7); imm |= 0x80; imm = imm << (32 - shift); shifter_out = 1; break; } tmp2 = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp2, imm); rn = (insn >> 16) & 0xf; if (rn == 15) { tmp = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp, 0); } else { tmp = load_reg(s, rn); } op = (insn >> 21) & 0xf; if (gen_thumb2_data_op(s, op, (insn & (1 << 20)) != 0, shifter_out, tmp, tmp2)) goto illegal_op; tcg_temp_free_i32(tmp2); rd = (insn >> 8) & 0xf; if (rd != 15) { store_reg(s, rd, tmp); } else { tcg_temp_free_i32(tmp); } } } break; case 12: { int postinc = 0; int writeback = 0; int user; if ((insn & 0x01100000) == 0x01000000) { if (disas_neon_ls_insn(env, s, insn)) goto illegal_op; break; } op = ((insn >> 21) & 3) | ((insn >> 22) & 4); if (rs == 15) { if (!(insn & (1 << 20))) { goto illegal_op; } if (op != 2) { int op1 = (insn >> 23) & 3; int op2 = (insn >> 6) & 0x3f; if (op & 2) { goto illegal_op; } if (rn == 15) { return 0; } if (op1 & 1) { return 0; } if ((op2 == 0) || ((op2 & 0x3c) == 0x30)) { return 0; } return 1; } } user = IS_USER(s); if (rn == 15) { addr = tcg_temp_new_i32(); imm = s->pc & 0xfffffffc; if (insn & (1 << 23)) imm += insn & 0xfff; else imm -= insn & 0xfff; tcg_gen_movi_i32(addr, imm); } else { addr = load_reg(s, rn); if (insn & (1 << 23)) { imm = insn & 0xfff; tcg_gen_addi_i32(addr, addr, imm); } else { imm = insn & 0xff; switch ((insn >> 8) & 0xf) { case 0x0: shift = (insn >> 4) & 0xf; if (shift > 3) { tcg_temp_free_i32(addr); goto illegal_op; } tmp = load_reg(s, rm); if (shift) tcg_gen_shli_i32(tmp, tmp, shift); tcg_gen_add_i32(addr, addr, tmp); tcg_temp_free_i32(tmp); break; case 0xc: tcg_gen_addi_i32(addr, addr, -imm); break; case 0xe: tcg_gen_addi_i32(addr, addr, imm); user = 1; break; case 0x9: imm = -imm; case 0xb: postinc = 1; writeback = 1; break; case 0xd: imm = -imm; case 0xf: tcg_gen_addi_i32(addr, addr, imm); writeback = 1; break; default: tcg_temp_free_i32(addr); goto illegal_op; } } } if (insn & (1 << 20)) { tmp = tcg_temp_new_i32(); switch (op) { case 0: tcg_gen_qemu_ld8u(tmp, addr, user); break; case 4: tcg_gen_qemu_ld8s(tmp, addr, user); break; case 1: tcg_gen_qemu_ld16u(tmp, addr, user); break; case 5: tcg_gen_qemu_ld16s(tmp, addr, user); break; case 2: tcg_gen_qemu_ld32u(tmp, addr, user); break; default: tcg_temp_free_i32(tmp); tcg_temp_free_i32(addr); goto illegal_op; } if (rs == 15) { gen_bx(s, tmp); } else { store_reg(s, rs, tmp); } } else { tmp = load_reg(s, rs); switch (op) { case 0: tcg_gen_qemu_st8(tmp, addr, user); break; case 1: tcg_gen_qemu_st16(tmp, addr, user); break; case 2: tcg_gen_qemu_st32(tmp, addr, user); break; default: tcg_temp_free_i32(tmp); tcg_temp_free_i32(addr); goto illegal_op; } tcg_temp_free_i32(tmp); } if (postinc) tcg_gen_addi_i32(addr, addr, imm); if (writeback) { store_reg(s, rn, addr); } else { tcg_temp_free_i32(addr); } } break; default: goto illegal_op; } return 0; illegal_op: return 1; }
{ "code": [], "line_no": [] }
static int FUNC_0(CPUARMState *VAR_0, DisasContext *VAR_1, uint16_t VAR_2) { uint32_t insn, imm, shift, offset; uint32_t rd, rn, rm, rs; TCGv_i32 tmp; TCGv_i32 tmp2; TCGv_i32 tmp3; TCGv_i32 addr; TCGv_i64 tmp64; int VAR_3; int VAR_4; int VAR_5; int VAR_6; if (!(arm_feature(VAR_0, ARM_FEATURE_THUMB2) || arm_feature (VAR_0, ARM_FEATURE_M))) { insn = VAR_2; if ((insn & (1 << 12)) == 0) { ARCH(5); offset = ((insn & 0x7ff) << 1); tmp = load_reg(VAR_1, 14); tcg_gen_addi_i32(tmp, tmp, offset); tcg_gen_andi_i32(tmp, tmp, 0xfffffffc); tmp2 = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp2, VAR_1->pc | 1); store_reg(VAR_1, 14, tmp2); gen_bx(VAR_1, tmp); return 0; } if (insn & (1 << 11)) { offset = ((insn & 0x7ff) << 1) | 1; tmp = load_reg(VAR_1, 14); tcg_gen_addi_i32(tmp, tmp, offset); tmp2 = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp2, VAR_1->pc | 1); store_reg(VAR_1, 14, tmp2); gen_bx(VAR_1, tmp); return 0; } if ((VAR_1->pc & ~TARGET_PAGE_MASK) == 0) { offset = ((int32_t)insn << 21) >> 9; tcg_gen_movi_i32(cpu_R[14], VAR_1->pc + 2 + offset); return 0; } } insn = arm_lduw_code(VAR_0, VAR_1->pc, VAR_1->bswap_code); VAR_1->pc += 2; insn |= (uint32_t)VAR_2 << 16; if ((insn & 0xf800e800) != 0xf000e800) { ARCH(6T2); } rn = (insn >> 16) & 0xf; rs = (insn >> 12) & 0xf; rd = (insn >> 8) & 0xf; rm = insn & 0xf; switch ((insn >> 25) & 0xf) { case 0: case 1: case 2: case 3: abort(); case 4: if (insn & (1 << 22)) { if (insn & 0x01200000) { if (rn == 15) { addr = tcg_temp_new_i32(); tcg_gen_movi_i32(addr, VAR_1->pc & ~3); } else { addr = load_reg(VAR_1, rn); } offset = (insn & 0xff) * 4; if ((insn & (1 << 23)) == 0) offset = -offset; if (insn & (1 << 24)) { tcg_gen_addi_i32(addr, addr, offset); offset = 0; } if (insn & (1 << 20)) { tmp = tcg_temp_new_i32(); tcg_gen_qemu_ld32u(tmp, addr, IS_USER(VAR_1)); store_reg(VAR_1, rs, tmp); tcg_gen_addi_i32(addr, addr, 4); tmp = tcg_temp_new_i32(); tcg_gen_qemu_ld32u(tmp, addr, IS_USER(VAR_1)); store_reg(VAR_1, rd, tmp); } else { tmp = load_reg(VAR_1, rs); tcg_gen_qemu_st32(tmp, addr, IS_USER(VAR_1)); tcg_temp_free_i32(tmp); tcg_gen_addi_i32(addr, addr, 4); tmp = load_reg(VAR_1, rd); tcg_gen_qemu_st32(tmp, addr, IS_USER(VAR_1)); tcg_temp_free_i32(tmp); } if (insn & (1 << 21)) { if (rn == 15) goto illegal_op; tcg_gen_addi_i32(addr, addr, offset - 4); store_reg(VAR_1, rn, addr); } else { tcg_temp_free_i32(addr); } } else if ((insn & (1 << 23)) == 0) { addr = tcg_temp_local_new_i32(); load_reg_var(VAR_1, addr, rn); tcg_gen_addi_i32(addr, addr, (insn & 0xff) << 2); if (insn & (1 << 20)) { gen_load_exclusive(VAR_1, rs, 15, addr, 2); } else { gen_store_exclusive(VAR_1, rd, rs, 15, addr, 2); } tcg_temp_free_i32(addr); } else if ((insn & (7 << 5)) == 0) { if (rn == 15) { addr = tcg_temp_new_i32(); tcg_gen_movi_i32(addr, VAR_1->pc); } else { addr = load_reg(VAR_1, rn); } tmp = load_reg(VAR_1, rm); tcg_gen_add_i32(addr, addr, tmp); if (insn & (1 << 4)) { tcg_gen_add_i32(addr, addr, tmp); tcg_temp_free_i32(tmp); tmp = tcg_temp_new_i32(); tcg_gen_qemu_ld16u(tmp, addr, IS_USER(VAR_1)); } else { tcg_temp_free_i32(tmp); tmp = tcg_temp_new_i32(); tcg_gen_qemu_ld8u(tmp, addr, IS_USER(VAR_1)); } tcg_temp_free_i32(addr); tcg_gen_shli_i32(tmp, tmp, 1); tcg_gen_addi_i32(tmp, tmp, VAR_1->pc); store_reg(VAR_1, 15, tmp); } else { int VAR_15 = (insn >> 6) & 0x3; VAR_3 = (insn >> 4) & 0x3; switch (VAR_15) { case 0: goto illegal_op; case 1: if (VAR_3 == 2) { goto illegal_op; } ARCH(7); break; case 2: if (VAR_3 == 3) { goto illegal_op; } case 3: ARCH(8); break; } addr = tcg_temp_local_new_i32(); load_reg_var(VAR_1, addr, rn); if (!(VAR_15 & 1)) { if (insn & (1 << 20)) { tmp = tcg_temp_new_i32(); switch (VAR_3) { case 0: tcg_gen_qemu_ld8u(tmp, addr, IS_USER(VAR_1)); break; case 1: tcg_gen_qemu_ld16u(tmp, addr, IS_USER(VAR_1)); break; case 2: tcg_gen_qemu_ld32u(tmp, addr, IS_USER(VAR_1)); break; default: abort(); } store_reg(VAR_1, rs, tmp); } else { tmp = load_reg(VAR_1, rs); switch (VAR_3) { case 0: tcg_gen_qemu_st8(tmp, addr, IS_USER(VAR_1)); break; case 1: tcg_gen_qemu_st16(tmp, addr, IS_USER(VAR_1)); break; case 2: tcg_gen_qemu_st32(tmp, addr, IS_USER(VAR_1)); break; default: abort(); } tcg_temp_free_i32(tmp); } } else if (insn & (1 << 20)) { gen_load_exclusive(VAR_1, rs, rd, addr, VAR_3); } else { gen_store_exclusive(VAR_1, rm, rs, rd, addr, VAR_3); } tcg_temp_free_i32(addr); } } else { if (((insn >> 23) & 1) == ((insn >> 24) & 1)) { if (IS_USER(VAR_1) || IS_M(VAR_0)) { goto illegal_op; } if (insn & (1 << 20)) { addr = load_reg(VAR_1, rn); if ((insn & (1 << 24)) == 0) tcg_gen_addi_i32(addr, addr, -8); tmp = tcg_temp_new_i32(); tcg_gen_qemu_ld32u(tmp, addr, 0); tcg_gen_addi_i32(addr, addr, 4); tmp2 = tcg_temp_new_i32(); tcg_gen_qemu_ld32u(tmp2, addr, 0); if (insn & (1 << 21)) { if (insn & (1 << 24)) { tcg_gen_addi_i32(addr, addr, 4); } else { tcg_gen_addi_i32(addr, addr, -4); } store_reg(VAR_1, rn, addr); } else { tcg_temp_free_i32(addr); } gen_rfe(VAR_1, tmp, tmp2); } else { gen_srs(VAR_1, (insn & 0x1f), (insn & (1 << 24)) ? 1 : 2, insn & (1 << 21)); } } else { int VAR_8, VAR_9 = 0; TCGv_i32 loaded_var; addr = load_reg(VAR_1, rn); offset = 0; for (VAR_8 = 0; VAR_8 < 16; VAR_8++) { if (insn & (1 << VAR_8)) offset += 4; } if (insn & (1 << 24)) { tcg_gen_addi_i32(addr, addr, -offset); } TCGV_UNUSED_I32(loaded_var); for (VAR_8 = 0; VAR_8 < 16; VAR_8++) { if ((insn & (1 << VAR_8)) == 0) continue; if (insn & (1 << 20)) { tmp = tcg_temp_new_i32(); tcg_gen_qemu_ld32u(tmp, addr, IS_USER(VAR_1)); if (VAR_8 == 15) { gen_bx(VAR_1, tmp); } else if (VAR_8 == rn) { loaded_var = tmp; VAR_9 = 1; } else { store_reg(VAR_1, VAR_8, tmp); } } else { tmp = load_reg(VAR_1, VAR_8); tcg_gen_qemu_st32(tmp, addr, IS_USER(VAR_1)); tcg_temp_free_i32(tmp); } tcg_gen_addi_i32(addr, addr, 4); } if (VAR_9) { store_reg(VAR_1, rn, loaded_var); } if (insn & (1 << 21)) { if (insn & (1 << 24)) { tcg_gen_addi_i32(addr, addr, -offset); } if (insn & (1 << rn)) goto illegal_op; store_reg(VAR_1, rn, addr); } else { tcg_temp_free_i32(addr); } } } break; case 5: VAR_3 = (insn >> 21) & 0xf; if (VAR_3 == 6) { tmp = load_reg(VAR_1, rn); tmp2 = load_reg(VAR_1, rm); shift = ((insn >> 10) & 0x1c) | ((insn >> 6) & 0x3); if (insn & (1 << 5)) { if (shift == 0) shift = 31; tcg_gen_sari_i32(tmp2, tmp2, shift); tcg_gen_andi_i32(tmp, tmp, 0xffff0000); tcg_gen_ext16u_i32(tmp2, tmp2); } else { if (shift) tcg_gen_shli_i32(tmp2, tmp2, shift); tcg_gen_ext16u_i32(tmp, tmp); tcg_gen_andi_i32(tmp2, tmp2, 0xffff0000); } tcg_gen_or_i32(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); store_reg(VAR_1, rd, tmp); } else { if (rn == 15) { tmp = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp, 0); } else { tmp = load_reg(VAR_1, rn); } tmp2 = load_reg(VAR_1, rm); VAR_4 = (insn >> 4) & 3; shift = ((insn >> 6) & 3) | ((insn >> 10) & 0x1c); VAR_5 = (insn & (1 << 20)) != 0; VAR_6 = (VAR_5 && thumb2_logic_op(VAR_3)); gen_arm_shift_im(tmp2, VAR_4, shift, VAR_6); if (gen_thumb2_data_op(VAR_1, VAR_3, VAR_5, 0, tmp, tmp2)) goto illegal_op; tcg_temp_free_i32(tmp2); if (rd != 15) { store_reg(VAR_1, rd, tmp); } else { tcg_temp_free_i32(tmp); } } break; case 13: VAR_3 = ((insn >> 22) & 6) | ((insn >> 7) & 1); if (VAR_3 < 4 && (insn & 0xf000) != 0xf000) goto illegal_op; switch (VAR_3) { case 0: tmp = load_reg(VAR_1, rn); tmp2 = load_reg(VAR_1, rm); if ((insn & 0x70) != 0) goto illegal_op; VAR_3 = (insn >> 21) & 3; VAR_6 = (insn & (1 << 20)) != 0; gen_arm_shift_reg(tmp, VAR_3, tmp2, VAR_6); if (VAR_6) gen_logic_CC(tmp); store_reg_bx(VAR_0, VAR_1, rd, tmp); break; case 1: tmp = load_reg(VAR_1, rm); shift = (insn >> 4) & 3; if (shift != 0) tcg_gen_rotri_i32(tmp, tmp, shift * 8); VAR_3 = (insn >> 20) & 7; switch (VAR_3) { case 0: gen_sxth(tmp); break; case 1: gen_uxth(tmp); break; case 2: gen_sxtb16(tmp); break; case 3: gen_uxtb16(tmp); break; case 4: gen_sxtb(tmp); break; case 5: gen_uxtb(tmp); break; default: goto illegal_op; } if (rn != 15) { tmp2 = load_reg(VAR_1, rn); if ((VAR_3 >> 1) == 1) { gen_add16(tmp, tmp2); } else { tcg_gen_add_i32(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); } } store_reg(VAR_1, rd, tmp); break; case 2: VAR_3 = (insn >> 20) & 7; shift = (insn >> 4) & 7; if ((VAR_3 & 3) == 3 || (shift & 3) == 3) goto illegal_op; tmp = load_reg(VAR_1, rn); tmp2 = load_reg(VAR_1, rm); gen_thumb2_parallel_addsub(VAR_3, shift, tmp, tmp2); tcg_temp_free_i32(tmp2); store_reg(VAR_1, rd, tmp); break; case 3: VAR_3 = ((insn >> 17) & 0x38) | ((insn >> 4) & 7); if (VAR_3 < 4) { tmp = load_reg(VAR_1, rn); tmp2 = load_reg(VAR_1, rm); if (VAR_3 & 1) gen_helper_double_saturate(tmp, cpu_env, tmp); if (VAR_3 & 2) gen_helper_sub_saturate(tmp, cpu_env, tmp2, tmp); else gen_helper_add_saturate(tmp, cpu_env, tmp, tmp2); tcg_temp_free_i32(tmp2); } else { tmp = load_reg(VAR_1, rn); switch (VAR_3) { case 0x0a: gen_helper_rbit(tmp, tmp); break; case 0x08: tcg_gen_bswap32_i32(tmp, tmp); break; case 0x09: gen_rev16(tmp); break; case 0x0b: gen_revsh(tmp); break; case 0x10: tmp2 = load_reg(VAR_1, rm); tmp3 = tcg_temp_new_i32(); tcg_gen_ld_i32(tmp3, cpu_env, offsetof(CPUARMState, GE)); gen_helper_sel_flags(tmp, tmp3, tmp, tmp2); tcg_temp_free_i32(tmp3); tcg_temp_free_i32(tmp2); break; case 0x18: gen_helper_clz(tmp, tmp); break; default: goto illegal_op; } } store_reg(VAR_1, rd, tmp); break; case 4: case 5: VAR_3 = (insn >> 4) & 0xf; tmp = load_reg(VAR_1, rn); tmp2 = load_reg(VAR_1, rm); switch ((insn >> 20) & 7) { case 0: tcg_gen_mul_i32(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); if (rs != 15) { tmp2 = load_reg(VAR_1, rs); if (VAR_3) tcg_gen_sub_i32(tmp, tmp2, tmp); else tcg_gen_add_i32(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); } break; case 1: gen_mulxy(tmp, tmp2, VAR_3 & 2, VAR_3 & 1); tcg_temp_free_i32(tmp2); if (rs != 15) { tmp2 = load_reg(VAR_1, rs); gen_helper_add_setq(tmp, cpu_env, tmp, tmp2); tcg_temp_free_i32(tmp2); } break; case 2: case 4: if (VAR_3) gen_swap_half(tmp2); gen_smul_dual(tmp, tmp2); if (insn & (1 << 22)) { tcg_gen_sub_i32(tmp, tmp, tmp2); } else { gen_helper_add_setq(tmp, cpu_env, tmp, tmp2); } tcg_temp_free_i32(tmp2); if (rs != 15) { tmp2 = load_reg(VAR_1, rs); gen_helper_add_setq(tmp, cpu_env, tmp, tmp2); tcg_temp_free_i32(tmp2); } break; case 3: if (VAR_3) tcg_gen_sari_i32(tmp2, tmp2, 16); else gen_sxth(tmp2); tmp64 = gen_muls_i64_i32(tmp, tmp2); tcg_gen_shri_i64(tmp64, tmp64, 16); tmp = tcg_temp_new_i32(); tcg_gen_trunc_i64_i32(tmp, tmp64); tcg_temp_free_i64(tmp64); if (rs != 15) { tmp2 = load_reg(VAR_1, rs); gen_helper_add_setq(tmp, cpu_env, tmp, tmp2); tcg_temp_free_i32(tmp2); } break; case 5: case 6: tmp64 = gen_muls_i64_i32(tmp, tmp2); if (rs != 15) { tmp = load_reg(VAR_1, rs); if (insn & (1 << 20)) { tmp64 = gen_addq_msw(tmp64, tmp); } else { tmp64 = gen_subq_msw(tmp64, tmp); } } if (insn & (1 << 4)) { tcg_gen_addi_i64(tmp64, tmp64, 0x80000000u); } tcg_gen_shri_i64(tmp64, tmp64, 32); tmp = tcg_temp_new_i32(); tcg_gen_trunc_i64_i32(tmp, tmp64); tcg_temp_free_i64(tmp64); break; case 7: gen_helper_usad8(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); if (rs != 15) { tmp2 = load_reg(VAR_1, rs); tcg_gen_add_i32(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); } break; } store_reg(VAR_1, rd, tmp); break; case 6: case 7: VAR_3 = ((insn >> 4) & 0xf) | ((insn >> 16) & 0x70); tmp = load_reg(VAR_1, rn); tmp2 = load_reg(VAR_1, rm); if ((VAR_3 & 0x50) == 0x10) { if (!arm_feature(VAR_0, ARM_FEATURE_THUMB_DIV)) { goto illegal_op; } if (VAR_3 & 0x20) gen_helper_udiv(tmp, tmp, tmp2); else gen_helper_sdiv(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); store_reg(VAR_1, rd, tmp); } else if ((VAR_3 & 0xe) == 0xc) { if (VAR_3 & 1) gen_swap_half(tmp2); gen_smul_dual(tmp, tmp2); if (VAR_3 & 0x10) { tcg_gen_sub_i32(tmp, tmp, tmp2); } else { tcg_gen_add_i32(tmp, tmp, tmp2); } tcg_temp_free_i32(tmp2); tmp64 = tcg_temp_new_i64(); tcg_gen_ext_i32_i64(tmp64, tmp); tcg_temp_free_i32(tmp); gen_addq(VAR_1, tmp64, rs, rd); gen_storeq_reg(VAR_1, rs, rd, tmp64); tcg_temp_free_i64(tmp64); } else { if (VAR_3 & 0x20) { tmp64 = gen_mulu_i64_i32(tmp, tmp2); } else { if (VAR_3 & 8) { gen_mulxy(tmp, tmp2, VAR_3 & 2, VAR_3 & 1); tcg_temp_free_i32(tmp2); tmp64 = tcg_temp_new_i64(); tcg_gen_ext_i32_i64(tmp64, tmp); tcg_temp_free_i32(tmp); } else { tmp64 = gen_muls_i64_i32(tmp, tmp2); } } if (VAR_3 & 4) { gen_addq_lo(VAR_1, tmp64, rs); gen_addq_lo(VAR_1, tmp64, rd); } else if (VAR_3 & 0x40) { gen_addq(VAR_1, tmp64, rs, rd); } gen_storeq_reg(VAR_1, rs, rd, tmp64); tcg_temp_free_i64(tmp64); } break; } break; case 6: case 7: case 14: case 15: if (((insn >> 24) & 3) == 3) { insn = (insn & 0xe2ffffff) | ((insn & (1 << 28)) >> 4) | (1 << 28); if (disas_neon_data_insn(VAR_0, VAR_1, insn)) goto illegal_op; } else { if (insn & (1 << 28)) goto illegal_op; if (disas_coproc_insn (VAR_0, VAR_1, insn)) goto illegal_op; } break; case 8: case 9: case 10: case 11: if (insn & (1 << 15)) { if (insn & 0x5000) { offset = ((int32_t)insn << 5) >> 9 & ~(int32_t)0xfff; offset |= (insn & 0x7ff) << 1; offset ^= ((~insn) & (1 << 13)) << 10; offset ^= ((~insn) & (1 << 11)) << 11; if (insn & (1 << 14)) { tcg_gen_movi_i32(cpu_R[14], VAR_1->pc | 1); } offset += VAR_1->pc; if (insn & (1 << 12)) { gen_jmp(VAR_1, offset); } else { offset &= ~(uint32_t)2; gen_bx_im(VAR_1, offset); } } else if (((insn >> 23) & 7) == 7) { if (insn & (1 << 13)) goto illegal_op; if (insn & (1 << 26)) { goto illegal_op; } else { VAR_3 = (insn >> 20) & 7; switch (VAR_3) { case 0: if (IS_M(VAR_0)) { tmp = load_reg(VAR_1, rn); addr = tcg_const_i32(insn & 0xff); gen_helper_v7m_msr(cpu_env, addr, tmp); tcg_temp_free_i32(addr); tcg_temp_free_i32(tmp); gen_lookup_tb(VAR_1); break; } case 1: if (IS_M(VAR_0)) goto illegal_op; tmp = load_reg(VAR_1, rn); if (gen_set_psr(VAR_1, msr_mask(VAR_0, VAR_1, (insn >> 8) & 0xf, VAR_3 == 1), VAR_3 == 1, tmp)) goto illegal_op; break; case 2: if (((insn >> 8) & 7) == 0) { gen_nop_hint(VAR_1, insn & 0xff); } if (IS_USER(VAR_1)) break; offset = 0; imm = 0; if (insn & (1 << 10)) { if (insn & (1 << 7)) offset |= CPSR_A; if (insn & (1 << 6)) offset |= CPSR_I; if (insn & (1 << 5)) offset |= CPSR_F; if (insn & (1 << 9)) imm = CPSR_A | CPSR_I | CPSR_F; } if (insn & (1 << 8)) { offset |= 0x1f; imm |= (insn & 0x1f); } if (offset) { gen_set_psr_im(VAR_1, offset, 0, imm); } break; case 3: ARCH(7); VAR_3 = (insn >> 4) & 0xf; switch (VAR_3) { case 2: gen_clrex(VAR_1); break; case 4: case 5: case 6: break; default: goto illegal_op; } break; case 4: tmp = load_reg(VAR_1, rn); gen_bx(VAR_1, tmp); break; case 5: if (IS_USER(VAR_1)) { goto illegal_op; } if (rn != 14 || rd != 15) { goto illegal_op; } tmp = load_reg(VAR_1, rn); tcg_gen_subi_i32(tmp, tmp, insn & 0xff); gen_exception_return(VAR_1, tmp); break; case 6: tmp = tcg_temp_new_i32(); if (IS_M(VAR_0)) { addr = tcg_const_i32(insn & 0xff); gen_helper_v7m_mrs(tmp, cpu_env, addr); tcg_temp_free_i32(addr); } else { gen_helper_cpsr_read(tmp, cpu_env); } store_reg(VAR_1, rd, tmp); break; case 7: if (IS_USER(VAR_1) || IS_M(VAR_0)) goto illegal_op; tmp = load_cpu_field(spsr); store_reg(VAR_1, rd, tmp); break; } } } else { VAR_3 = (insn >> 22) & 0xf; VAR_1->condlabel = gen_new_label(); gen_test_cc(VAR_3 ^ 1, VAR_1->condlabel); VAR_1->condjmp = 1; offset = (insn & 0x7ff) << 1; offset |= (insn & 0x003f0000) >> 4; offset |= ((int32_t)((insn << 5) & 0x80000000)) >> 11; offset |= (insn & (1 << 13)) << 5; offset |= (insn & (1 << 11)) << 8; gen_jmp(VAR_1, VAR_1->pc + offset); } } else { if (insn & (1 << 25)) { if (insn & (1 << 24)) { if (insn & (1 << 20)) goto illegal_op; VAR_3 = (insn >> 21) & 7; imm = insn & 0x1f; shift = ((insn >> 6) & 3) | ((insn >> 10) & 0x1c); if (rn == 15) { tmp = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp, 0); } else { tmp = load_reg(VAR_1, rn); } switch (VAR_3) { case 2: imm++; if (shift + imm > 32) goto illegal_op; if (imm < 32) gen_sbfx(tmp, shift, imm); break; case 6: imm++; if (shift + imm > 32) goto illegal_op; if (imm < 32) gen_ubfx(tmp, shift, (1u << imm) - 1); break; case 3: if (imm < shift) goto illegal_op; imm = imm + 1 - shift; if (imm != 32) { tmp2 = load_reg(VAR_1, rd); tcg_gen_deposit_i32(tmp, tmp2, tmp, shift, imm); tcg_temp_free_i32(tmp2); } break; case 7: goto illegal_op; default: if (shift) { if (VAR_3 & 1) tcg_gen_sari_i32(tmp, tmp, shift); else tcg_gen_shli_i32(tmp, tmp, shift); } tmp2 = tcg_const_i32(imm); if (VAR_3 & 4) { if ((VAR_3 & 1) && shift == 0) gen_helper_usat16(tmp, cpu_env, tmp, tmp2); else gen_helper_usat(tmp, cpu_env, tmp, tmp2); } else { if ((VAR_3 & 1) && shift == 0) gen_helper_ssat16(tmp, cpu_env, tmp, tmp2); else gen_helper_ssat(tmp, cpu_env, tmp, tmp2); } tcg_temp_free_i32(tmp2); break; } store_reg(VAR_1, rd, tmp); } else { imm = ((insn & 0x04000000) >> 15) | ((insn & 0x7000) >> 4) | (insn & 0xff); if (insn & (1 << 22)) { imm |= (insn >> 4) & 0xf000; if (insn & (1 << 23)) { tmp = load_reg(VAR_1, rd); tcg_gen_ext16u_i32(tmp, tmp); tcg_gen_ori_i32(tmp, tmp, imm << 16); } else { tmp = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp, imm); } } else { if (rn == 15) { offset = VAR_1->pc & ~(uint32_t)3; if (insn & (1 << 23)) offset -= imm; else offset += imm; tmp = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp, offset); } else { tmp = load_reg(VAR_1, rn); if (insn & (1 << 23)) tcg_gen_subi_i32(tmp, tmp, imm); else tcg_gen_addi_i32(tmp, tmp, imm); } } store_reg(VAR_1, rd, tmp); } } else { int VAR_10 = 0; shift = ((insn & 0x04000000) >> 23) | ((insn & 0x7000) >> 12); imm = (insn & 0xff); switch (shift) { case 0: break; case 1: imm |= imm << 16; break; case 2: imm |= imm << 16; imm <<= 8; break; case 3: imm |= imm << 16; imm |= imm << 8; break; default: shift = (shift << 1) | (imm >> 7); imm |= 0x80; imm = imm << (32 - shift); VAR_10 = 1; break; } tmp2 = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp2, imm); rn = (insn >> 16) & 0xf; if (rn == 15) { tmp = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp, 0); } else { tmp = load_reg(VAR_1, rn); } VAR_3 = (insn >> 21) & 0xf; if (gen_thumb2_data_op(VAR_1, VAR_3, (insn & (1 << 20)) != 0, VAR_10, tmp, tmp2)) goto illegal_op; tcg_temp_free_i32(tmp2); rd = (insn >> 8) & 0xf; if (rd != 15) { store_reg(VAR_1, rd, tmp); } else { tcg_temp_free_i32(tmp); } } } break; case 12: { int VAR_11 = 0; int VAR_12 = 0; int VAR_13; if ((insn & 0x01100000) == 0x01000000) { if (disas_neon_ls_insn(VAR_0, VAR_1, insn)) goto illegal_op; break; } VAR_3 = ((insn >> 21) & 3) | ((insn >> 22) & 4); if (rs == 15) { if (!(insn & (1 << 20))) { goto illegal_op; } if (VAR_3 != 2) { int VAR_14 = (insn >> 23) & 3; int VAR_15 = (insn >> 6) & 0x3f; if (VAR_3 & 2) { goto illegal_op; } if (rn == 15) { return 0; } if (VAR_14 & 1) { return 0; } if ((VAR_15 == 0) || ((VAR_15 & 0x3c) == 0x30)) { return 0; } return 1; } } VAR_13 = IS_USER(VAR_1); if (rn == 15) { addr = tcg_temp_new_i32(); imm = VAR_1->pc & 0xfffffffc; if (insn & (1 << 23)) imm += insn & 0xfff; else imm -= insn & 0xfff; tcg_gen_movi_i32(addr, imm); } else { addr = load_reg(VAR_1, rn); if (insn & (1 << 23)) { imm = insn & 0xfff; tcg_gen_addi_i32(addr, addr, imm); } else { imm = insn & 0xff; switch ((insn >> 8) & 0xf) { case 0x0: shift = (insn >> 4) & 0xf; if (shift > 3) { tcg_temp_free_i32(addr); goto illegal_op; } tmp = load_reg(VAR_1, rm); if (shift) tcg_gen_shli_i32(tmp, tmp, shift); tcg_gen_add_i32(addr, addr, tmp); tcg_temp_free_i32(tmp); break; case 0xc: tcg_gen_addi_i32(addr, addr, -imm); break; case 0xe: tcg_gen_addi_i32(addr, addr, imm); VAR_13 = 1; break; case 0x9: imm = -imm; case 0xb: VAR_11 = 1; VAR_12 = 1; break; case 0xd: imm = -imm; case 0xf: tcg_gen_addi_i32(addr, addr, imm); VAR_12 = 1; break; default: tcg_temp_free_i32(addr); goto illegal_op; } } } if (insn & (1 << 20)) { tmp = tcg_temp_new_i32(); switch (VAR_3) { case 0: tcg_gen_qemu_ld8u(tmp, addr, VAR_13); break; case 4: tcg_gen_qemu_ld8s(tmp, addr, VAR_13); break; case 1: tcg_gen_qemu_ld16u(tmp, addr, VAR_13); break; case 5: tcg_gen_qemu_ld16s(tmp, addr, VAR_13); break; case 2: tcg_gen_qemu_ld32u(tmp, addr, VAR_13); break; default: tcg_temp_free_i32(tmp); tcg_temp_free_i32(addr); goto illegal_op; } if (rs == 15) { gen_bx(VAR_1, tmp); } else { store_reg(VAR_1, rs, tmp); } } else { tmp = load_reg(VAR_1, rs); switch (VAR_3) { case 0: tcg_gen_qemu_st8(tmp, addr, VAR_13); break; case 1: tcg_gen_qemu_st16(tmp, addr, VAR_13); break; case 2: tcg_gen_qemu_st32(tmp, addr, VAR_13); break; default: tcg_temp_free_i32(tmp); tcg_temp_free_i32(addr); goto illegal_op; } tcg_temp_free_i32(tmp); } if (VAR_11) tcg_gen_addi_i32(addr, addr, imm); if (VAR_12) { store_reg(VAR_1, rn, addr); } else { tcg_temp_free_i32(addr); } } break; default: goto illegal_op; } return 0; illegal_op: return 1; }
[ "static int FUNC_0(CPUARMState *VAR_0, DisasContext *VAR_1, uint16_t VAR_2)\n{", "uint32_t insn, imm, shift, offset;", "uint32_t rd, rn, rm, rs;", "TCGv_i32 tmp;", "TCGv_i32 tmp2;", "TCGv_i32 tmp3;", "TCGv_i32 addr;", "TCGv_i64 tmp64;", "int VAR_3;", "int VAR_4;", "int VAR_5;", "int VAR_6;", "if (!(arm_feature(VAR_0, ARM_FEATURE_THUMB2)\n|| arm_feature (VAR_0, ARM_FEATURE_M))) {", "insn = VAR_2;", "if ((insn & (1 << 12)) == 0) {", "ARCH(5);", "offset = ((insn & 0x7ff) << 1);", "tmp = load_reg(VAR_1, 14);", "tcg_gen_addi_i32(tmp, tmp, offset);", "tcg_gen_andi_i32(tmp, tmp, 0xfffffffc);", "tmp2 = tcg_temp_new_i32();", "tcg_gen_movi_i32(tmp2, VAR_1->pc | 1);", "store_reg(VAR_1, 14, tmp2);", "gen_bx(VAR_1, tmp);", "return 0;", "}", "if (insn & (1 << 11)) {", "offset = ((insn & 0x7ff) << 1) | 1;", "tmp = load_reg(VAR_1, 14);", "tcg_gen_addi_i32(tmp, tmp, offset);", "tmp2 = tcg_temp_new_i32();", "tcg_gen_movi_i32(tmp2, VAR_1->pc | 1);", "store_reg(VAR_1, 14, tmp2);", "gen_bx(VAR_1, tmp);", "return 0;", "}", "if ((VAR_1->pc & ~TARGET_PAGE_MASK) == 0) {", "offset = ((int32_t)insn << 21) >> 9;", "tcg_gen_movi_i32(cpu_R[14], VAR_1->pc + 2 + offset);", "return 0;", "}", "}", "insn = arm_lduw_code(VAR_0, VAR_1->pc, VAR_1->bswap_code);", "VAR_1->pc += 2;", "insn |= (uint32_t)VAR_2 << 16;", "if ((insn & 0xf800e800) != 0xf000e800) {", "ARCH(6T2);", "}", "rn = (insn >> 16) & 0xf;", "rs = (insn >> 12) & 0xf;", "rd = (insn >> 8) & 0xf;", "rm = insn & 0xf;", "switch ((insn >> 25) & 0xf) {", "case 0: case 1: case 2: case 3:\nabort();", "case 4:\nif (insn & (1 << 22)) {", "if (insn & 0x01200000) {", "if (rn == 15) {", "addr = tcg_temp_new_i32();", "tcg_gen_movi_i32(addr, VAR_1->pc & ~3);", "} else {", "addr = load_reg(VAR_1, rn);", "}", "offset = (insn & 0xff) * 4;", "if ((insn & (1 << 23)) == 0)\noffset = -offset;", "if (insn & (1 << 24)) {", "tcg_gen_addi_i32(addr, addr, offset);", "offset = 0;", "}", "if (insn & (1 << 20)) {", "tmp = tcg_temp_new_i32();", "tcg_gen_qemu_ld32u(tmp, addr, IS_USER(VAR_1));", "store_reg(VAR_1, rs, tmp);", "tcg_gen_addi_i32(addr, addr, 4);", "tmp = tcg_temp_new_i32();", "tcg_gen_qemu_ld32u(tmp, addr, IS_USER(VAR_1));", "store_reg(VAR_1, rd, tmp);", "} else {", "tmp = load_reg(VAR_1, rs);", "tcg_gen_qemu_st32(tmp, addr, IS_USER(VAR_1));", "tcg_temp_free_i32(tmp);", "tcg_gen_addi_i32(addr, addr, 4);", "tmp = load_reg(VAR_1, rd);", "tcg_gen_qemu_st32(tmp, addr, IS_USER(VAR_1));", "tcg_temp_free_i32(tmp);", "}", "if (insn & (1 << 21)) {", "if (rn == 15)\ngoto illegal_op;", "tcg_gen_addi_i32(addr, addr, offset - 4);", "store_reg(VAR_1, rn, addr);", "} else {", "tcg_temp_free_i32(addr);", "}", "} else if ((insn & (1 << 23)) == 0) {", "addr = tcg_temp_local_new_i32();", "load_reg_var(VAR_1, addr, rn);", "tcg_gen_addi_i32(addr, addr, (insn & 0xff) << 2);", "if (insn & (1 << 20)) {", "gen_load_exclusive(VAR_1, rs, 15, addr, 2);", "} else {", "gen_store_exclusive(VAR_1, rd, rs, 15, addr, 2);", "}", "tcg_temp_free_i32(addr);", "} else if ((insn & (7 << 5)) == 0) {", "if (rn == 15) {", "addr = tcg_temp_new_i32();", "tcg_gen_movi_i32(addr, VAR_1->pc);", "} else {", "addr = load_reg(VAR_1, rn);", "}", "tmp = load_reg(VAR_1, rm);", "tcg_gen_add_i32(addr, addr, tmp);", "if (insn & (1 << 4)) {", "tcg_gen_add_i32(addr, addr, tmp);", "tcg_temp_free_i32(tmp);", "tmp = tcg_temp_new_i32();", "tcg_gen_qemu_ld16u(tmp, addr, IS_USER(VAR_1));", "} else {", "tcg_temp_free_i32(tmp);", "tmp = tcg_temp_new_i32();", "tcg_gen_qemu_ld8u(tmp, addr, IS_USER(VAR_1));", "}", "tcg_temp_free_i32(addr);", "tcg_gen_shli_i32(tmp, tmp, 1);", "tcg_gen_addi_i32(tmp, tmp, VAR_1->pc);", "store_reg(VAR_1, 15, tmp);", "} else {", "int VAR_15 = (insn >> 6) & 0x3;", "VAR_3 = (insn >> 4) & 0x3;", "switch (VAR_15) {", "case 0:\ngoto illegal_op;", "case 1:\nif (VAR_3 == 2) {", "goto illegal_op;", "}", "ARCH(7);", "break;", "case 2:\nif (VAR_3 == 3) {", "goto illegal_op;", "}", "case 3:\nARCH(8);", "break;", "}", "addr = tcg_temp_local_new_i32();", "load_reg_var(VAR_1, addr, rn);", "if (!(VAR_15 & 1)) {", "if (insn & (1 << 20)) {", "tmp = tcg_temp_new_i32();", "switch (VAR_3) {", "case 0:\ntcg_gen_qemu_ld8u(tmp, addr, IS_USER(VAR_1));", "break;", "case 1:\ntcg_gen_qemu_ld16u(tmp, addr, IS_USER(VAR_1));", "break;", "case 2:\ntcg_gen_qemu_ld32u(tmp, addr, IS_USER(VAR_1));", "break;", "default:\nabort();", "}", "store_reg(VAR_1, rs, tmp);", "} else {", "tmp = load_reg(VAR_1, rs);", "switch (VAR_3) {", "case 0:\ntcg_gen_qemu_st8(tmp, addr, IS_USER(VAR_1));", "break;", "case 1:\ntcg_gen_qemu_st16(tmp, addr, IS_USER(VAR_1));", "break;", "case 2:\ntcg_gen_qemu_st32(tmp, addr, IS_USER(VAR_1));", "break;", "default:\nabort();", "}", "tcg_temp_free_i32(tmp);", "}", "} else if (insn & (1 << 20)) {", "gen_load_exclusive(VAR_1, rs, rd, addr, VAR_3);", "} else {", "gen_store_exclusive(VAR_1, rm, rs, rd, addr, VAR_3);", "}", "tcg_temp_free_i32(addr);", "}", "} else {", "if (((insn >> 23) & 1) == ((insn >> 24) & 1)) {", "if (IS_USER(VAR_1) || IS_M(VAR_0)) {", "goto illegal_op;", "}", "if (insn & (1 << 20)) {", "addr = load_reg(VAR_1, rn);", "if ((insn & (1 << 24)) == 0)\ntcg_gen_addi_i32(addr, addr, -8);", "tmp = tcg_temp_new_i32();", "tcg_gen_qemu_ld32u(tmp, addr, 0);", "tcg_gen_addi_i32(addr, addr, 4);", "tmp2 = tcg_temp_new_i32();", "tcg_gen_qemu_ld32u(tmp2, addr, 0);", "if (insn & (1 << 21)) {", "if (insn & (1 << 24)) {", "tcg_gen_addi_i32(addr, addr, 4);", "} else {", "tcg_gen_addi_i32(addr, addr, -4);", "}", "store_reg(VAR_1, rn, addr);", "} else {", "tcg_temp_free_i32(addr);", "}", "gen_rfe(VAR_1, tmp, tmp2);", "} else {", "gen_srs(VAR_1, (insn & 0x1f), (insn & (1 << 24)) ? 1 : 2,\ninsn & (1 << 21));", "}", "} else {", "int VAR_8, VAR_9 = 0;", "TCGv_i32 loaded_var;", "addr = load_reg(VAR_1, rn);", "offset = 0;", "for (VAR_8 = 0; VAR_8 < 16; VAR_8++) {", "if (insn & (1 << VAR_8))\noffset += 4;", "}", "if (insn & (1 << 24)) {", "tcg_gen_addi_i32(addr, addr, -offset);", "}", "TCGV_UNUSED_I32(loaded_var);", "for (VAR_8 = 0; VAR_8 < 16; VAR_8++) {", "if ((insn & (1 << VAR_8)) == 0)\ncontinue;", "if (insn & (1 << 20)) {", "tmp = tcg_temp_new_i32();", "tcg_gen_qemu_ld32u(tmp, addr, IS_USER(VAR_1));", "if (VAR_8 == 15) {", "gen_bx(VAR_1, tmp);", "} else if (VAR_8 == rn) {", "loaded_var = tmp;", "VAR_9 = 1;", "} else {", "store_reg(VAR_1, VAR_8, tmp);", "}", "} else {", "tmp = load_reg(VAR_1, VAR_8);", "tcg_gen_qemu_st32(tmp, addr, IS_USER(VAR_1));", "tcg_temp_free_i32(tmp);", "}", "tcg_gen_addi_i32(addr, addr, 4);", "}", "if (VAR_9) {", "store_reg(VAR_1, rn, loaded_var);", "}", "if (insn & (1 << 21)) {", "if (insn & (1 << 24)) {", "tcg_gen_addi_i32(addr, addr, -offset);", "}", "if (insn & (1 << rn))\ngoto illegal_op;", "store_reg(VAR_1, rn, addr);", "} else {", "tcg_temp_free_i32(addr);", "}", "}", "}", "break;", "case 5:\nVAR_3 = (insn >> 21) & 0xf;", "if (VAR_3 == 6) {", "tmp = load_reg(VAR_1, rn);", "tmp2 = load_reg(VAR_1, rm);", "shift = ((insn >> 10) & 0x1c) | ((insn >> 6) & 0x3);", "if (insn & (1 << 5)) {", "if (shift == 0)\nshift = 31;", "tcg_gen_sari_i32(tmp2, tmp2, shift);", "tcg_gen_andi_i32(tmp, tmp, 0xffff0000);", "tcg_gen_ext16u_i32(tmp2, tmp2);", "} else {", "if (shift)\ntcg_gen_shli_i32(tmp2, tmp2, shift);", "tcg_gen_ext16u_i32(tmp, tmp);", "tcg_gen_andi_i32(tmp2, tmp2, 0xffff0000);", "}", "tcg_gen_or_i32(tmp, tmp, tmp2);", "tcg_temp_free_i32(tmp2);", "store_reg(VAR_1, rd, tmp);", "} else {", "if (rn == 15) {", "tmp = tcg_temp_new_i32();", "tcg_gen_movi_i32(tmp, 0);", "} else {", "tmp = load_reg(VAR_1, rn);", "}", "tmp2 = load_reg(VAR_1, rm);", "VAR_4 = (insn >> 4) & 3;", "shift = ((insn >> 6) & 3) | ((insn >> 10) & 0x1c);", "VAR_5 = (insn & (1 << 20)) != 0;", "VAR_6 = (VAR_5 && thumb2_logic_op(VAR_3));", "gen_arm_shift_im(tmp2, VAR_4, shift, VAR_6);", "if (gen_thumb2_data_op(VAR_1, VAR_3, VAR_5, 0, tmp, tmp2))\ngoto illegal_op;", "tcg_temp_free_i32(tmp2);", "if (rd != 15) {", "store_reg(VAR_1, rd, tmp);", "} else {", "tcg_temp_free_i32(tmp);", "}", "}", "break;", "case 13:\nVAR_3 = ((insn >> 22) & 6) | ((insn >> 7) & 1);", "if (VAR_3 < 4 && (insn & 0xf000) != 0xf000)\ngoto illegal_op;", "switch (VAR_3) {", "case 0:\ntmp = load_reg(VAR_1, rn);", "tmp2 = load_reg(VAR_1, rm);", "if ((insn & 0x70) != 0)\ngoto illegal_op;", "VAR_3 = (insn >> 21) & 3;", "VAR_6 = (insn & (1 << 20)) != 0;", "gen_arm_shift_reg(tmp, VAR_3, tmp2, VAR_6);", "if (VAR_6)\ngen_logic_CC(tmp);", "store_reg_bx(VAR_0, VAR_1, rd, tmp);", "break;", "case 1:\ntmp = load_reg(VAR_1, rm);", "shift = (insn >> 4) & 3;", "if (shift != 0)\ntcg_gen_rotri_i32(tmp, tmp, shift * 8);", "VAR_3 = (insn >> 20) & 7;", "switch (VAR_3) {", "case 0: gen_sxth(tmp); break;", "case 1: gen_uxth(tmp); break;", "case 2: gen_sxtb16(tmp); break;", "case 3: gen_uxtb16(tmp); break;", "case 4: gen_sxtb(tmp); break;", "case 5: gen_uxtb(tmp); break;", "default: goto illegal_op;", "}", "if (rn != 15) {", "tmp2 = load_reg(VAR_1, rn);", "if ((VAR_3 >> 1) == 1) {", "gen_add16(tmp, tmp2);", "} else {", "tcg_gen_add_i32(tmp, tmp, tmp2);", "tcg_temp_free_i32(tmp2);", "}", "}", "store_reg(VAR_1, rd, tmp);", "break;", "case 2:\nVAR_3 = (insn >> 20) & 7;", "shift = (insn >> 4) & 7;", "if ((VAR_3 & 3) == 3 || (shift & 3) == 3)\ngoto illegal_op;", "tmp = load_reg(VAR_1, rn);", "tmp2 = load_reg(VAR_1, rm);", "gen_thumb2_parallel_addsub(VAR_3, shift, tmp, tmp2);", "tcg_temp_free_i32(tmp2);", "store_reg(VAR_1, rd, tmp);", "break;", "case 3:\nVAR_3 = ((insn >> 17) & 0x38) | ((insn >> 4) & 7);", "if (VAR_3 < 4) {", "tmp = load_reg(VAR_1, rn);", "tmp2 = load_reg(VAR_1, rm);", "if (VAR_3 & 1)\ngen_helper_double_saturate(tmp, cpu_env, tmp);", "if (VAR_3 & 2)\ngen_helper_sub_saturate(tmp, cpu_env, tmp2, tmp);", "else\ngen_helper_add_saturate(tmp, cpu_env, tmp, tmp2);", "tcg_temp_free_i32(tmp2);", "} else {", "tmp = load_reg(VAR_1, rn);", "switch (VAR_3) {", "case 0x0a:\ngen_helper_rbit(tmp, tmp);", "break;", "case 0x08:\ntcg_gen_bswap32_i32(tmp, tmp);", "break;", "case 0x09:\ngen_rev16(tmp);", "break;", "case 0x0b:\ngen_revsh(tmp);", "break;", "case 0x10:\ntmp2 = load_reg(VAR_1, rm);", "tmp3 = tcg_temp_new_i32();", "tcg_gen_ld_i32(tmp3, cpu_env, offsetof(CPUARMState, GE));", "gen_helper_sel_flags(tmp, tmp3, tmp, tmp2);", "tcg_temp_free_i32(tmp3);", "tcg_temp_free_i32(tmp2);", "break;", "case 0x18:\ngen_helper_clz(tmp, tmp);", "break;", "default:\ngoto illegal_op;", "}", "}", "store_reg(VAR_1, rd, tmp);", "break;", "case 4: case 5:\nVAR_3 = (insn >> 4) & 0xf;", "tmp = load_reg(VAR_1, rn);", "tmp2 = load_reg(VAR_1, rm);", "switch ((insn >> 20) & 7) {", "case 0:\ntcg_gen_mul_i32(tmp, tmp, tmp2);", "tcg_temp_free_i32(tmp2);", "if (rs != 15) {", "tmp2 = load_reg(VAR_1, rs);", "if (VAR_3)\ntcg_gen_sub_i32(tmp, tmp2, tmp);", "else\ntcg_gen_add_i32(tmp, tmp, tmp2);", "tcg_temp_free_i32(tmp2);", "}", "break;", "case 1:\ngen_mulxy(tmp, tmp2, VAR_3 & 2, VAR_3 & 1);", "tcg_temp_free_i32(tmp2);", "if (rs != 15) {", "tmp2 = load_reg(VAR_1, rs);", "gen_helper_add_setq(tmp, cpu_env, tmp, tmp2);", "tcg_temp_free_i32(tmp2);", "}", "break;", "case 2:\ncase 4:\nif (VAR_3)\ngen_swap_half(tmp2);", "gen_smul_dual(tmp, tmp2);", "if (insn & (1 << 22)) {", "tcg_gen_sub_i32(tmp, tmp, tmp2);", "} else {", "gen_helper_add_setq(tmp, cpu_env, tmp, tmp2);", "}", "tcg_temp_free_i32(tmp2);", "if (rs != 15)\n{", "tmp2 = load_reg(VAR_1, rs);", "gen_helper_add_setq(tmp, cpu_env, tmp, tmp2);", "tcg_temp_free_i32(tmp2);", "}", "break;", "case 3:\nif (VAR_3)\ntcg_gen_sari_i32(tmp2, tmp2, 16);", "else\ngen_sxth(tmp2);", "tmp64 = gen_muls_i64_i32(tmp, tmp2);", "tcg_gen_shri_i64(tmp64, tmp64, 16);", "tmp = tcg_temp_new_i32();", "tcg_gen_trunc_i64_i32(tmp, tmp64);", "tcg_temp_free_i64(tmp64);", "if (rs != 15)\n{", "tmp2 = load_reg(VAR_1, rs);", "gen_helper_add_setq(tmp, cpu_env, tmp, tmp2);", "tcg_temp_free_i32(tmp2);", "}", "break;", "case 5: case 6:\ntmp64 = gen_muls_i64_i32(tmp, tmp2);", "if (rs != 15) {", "tmp = load_reg(VAR_1, rs);", "if (insn & (1 << 20)) {", "tmp64 = gen_addq_msw(tmp64, tmp);", "} else {", "tmp64 = gen_subq_msw(tmp64, tmp);", "}", "}", "if (insn & (1 << 4)) {", "tcg_gen_addi_i64(tmp64, tmp64, 0x80000000u);", "}", "tcg_gen_shri_i64(tmp64, tmp64, 32);", "tmp = tcg_temp_new_i32();", "tcg_gen_trunc_i64_i32(tmp, tmp64);", "tcg_temp_free_i64(tmp64);", "break;", "case 7:\ngen_helper_usad8(tmp, tmp, tmp2);", "tcg_temp_free_i32(tmp2);", "if (rs != 15) {", "tmp2 = load_reg(VAR_1, rs);", "tcg_gen_add_i32(tmp, tmp, tmp2);", "tcg_temp_free_i32(tmp2);", "}", "break;", "}", "store_reg(VAR_1, rd, tmp);", "break;", "case 6: case 7:\nVAR_3 = ((insn >> 4) & 0xf) | ((insn >> 16) & 0x70);", "tmp = load_reg(VAR_1, rn);", "tmp2 = load_reg(VAR_1, rm);", "if ((VAR_3 & 0x50) == 0x10) {", "if (!arm_feature(VAR_0, ARM_FEATURE_THUMB_DIV)) {", "goto illegal_op;", "}", "if (VAR_3 & 0x20)\ngen_helper_udiv(tmp, tmp, tmp2);", "else\ngen_helper_sdiv(tmp, tmp, tmp2);", "tcg_temp_free_i32(tmp2);", "store_reg(VAR_1, rd, tmp);", "} else if ((VAR_3 & 0xe) == 0xc) {", "if (VAR_3 & 1)\ngen_swap_half(tmp2);", "gen_smul_dual(tmp, tmp2);", "if (VAR_3 & 0x10) {", "tcg_gen_sub_i32(tmp, tmp, tmp2);", "} else {", "tcg_gen_add_i32(tmp, tmp, tmp2);", "}", "tcg_temp_free_i32(tmp2);", "tmp64 = tcg_temp_new_i64();", "tcg_gen_ext_i32_i64(tmp64, tmp);", "tcg_temp_free_i32(tmp);", "gen_addq(VAR_1, tmp64, rs, rd);", "gen_storeq_reg(VAR_1, rs, rd, tmp64);", "tcg_temp_free_i64(tmp64);", "} else {", "if (VAR_3 & 0x20) {", "tmp64 = gen_mulu_i64_i32(tmp, tmp2);", "} else {", "if (VAR_3 & 8) {", "gen_mulxy(tmp, tmp2, VAR_3 & 2, VAR_3 & 1);", "tcg_temp_free_i32(tmp2);", "tmp64 = tcg_temp_new_i64();", "tcg_gen_ext_i32_i64(tmp64, tmp);", "tcg_temp_free_i32(tmp);", "} else {", "tmp64 = gen_muls_i64_i32(tmp, tmp2);", "}", "}", "if (VAR_3 & 4) {", "gen_addq_lo(VAR_1, tmp64, rs);", "gen_addq_lo(VAR_1, tmp64, rd);", "} else if (VAR_3 & 0x40) {", "gen_addq(VAR_1, tmp64, rs, rd);", "}", "gen_storeq_reg(VAR_1, rs, rd, tmp64);", "tcg_temp_free_i64(tmp64);", "}", "break;", "}", "break;", "case 6: case 7: case 14: case 15:\nif (((insn >> 24) & 3) == 3) {", "insn = (insn & 0xe2ffffff) | ((insn & (1 << 28)) >> 4) | (1 << 28);", "if (disas_neon_data_insn(VAR_0, VAR_1, insn))\ngoto illegal_op;", "} else {", "if (insn & (1 << 28))\ngoto illegal_op;", "if (disas_coproc_insn (VAR_0, VAR_1, insn))\ngoto illegal_op;", "}", "break;", "case 8: case 9: case 10: case 11:\nif (insn & (1 << 15)) {", "if (insn & 0x5000) {", "offset = ((int32_t)insn << 5) >> 9 & ~(int32_t)0xfff;", "offset |= (insn & 0x7ff) << 1;", "offset ^= ((~insn) & (1 << 13)) << 10;", "offset ^= ((~insn) & (1 << 11)) << 11;", "if (insn & (1 << 14)) {", "tcg_gen_movi_i32(cpu_R[14], VAR_1->pc | 1);", "}", "offset += VAR_1->pc;", "if (insn & (1 << 12)) {", "gen_jmp(VAR_1, offset);", "} else {", "offset &= ~(uint32_t)2;", "gen_bx_im(VAR_1, offset);", "}", "} else if (((insn >> 23) & 7) == 7) {", "if (insn & (1 << 13))\ngoto illegal_op;", "if (insn & (1 << 26)) {", "goto illegal_op;", "} else {", "VAR_3 = (insn >> 20) & 7;", "switch (VAR_3) {", "case 0:\nif (IS_M(VAR_0)) {", "tmp = load_reg(VAR_1, rn);", "addr = tcg_const_i32(insn & 0xff);", "gen_helper_v7m_msr(cpu_env, addr, tmp);", "tcg_temp_free_i32(addr);", "tcg_temp_free_i32(tmp);", "gen_lookup_tb(VAR_1);", "break;", "}", "case 1:\nif (IS_M(VAR_0))\ngoto illegal_op;", "tmp = load_reg(VAR_1, rn);", "if (gen_set_psr(VAR_1,\nmsr_mask(VAR_0, VAR_1, (insn >> 8) & 0xf, VAR_3 == 1),\nVAR_3 == 1, tmp))\ngoto illegal_op;", "break;", "case 2:\nif (((insn >> 8) & 7) == 0) {", "gen_nop_hint(VAR_1, insn & 0xff);", "}", "if (IS_USER(VAR_1))\nbreak;", "offset = 0;", "imm = 0;", "if (insn & (1 << 10)) {", "if (insn & (1 << 7))\noffset |= CPSR_A;", "if (insn & (1 << 6))\noffset |= CPSR_I;", "if (insn & (1 << 5))\noffset |= CPSR_F;", "if (insn & (1 << 9))\nimm = CPSR_A | CPSR_I | CPSR_F;", "}", "if (insn & (1 << 8)) {", "offset |= 0x1f;", "imm |= (insn & 0x1f);", "}", "if (offset) {", "gen_set_psr_im(VAR_1, offset, 0, imm);", "}", "break;", "case 3:\nARCH(7);", "VAR_3 = (insn >> 4) & 0xf;", "switch (VAR_3) {", "case 2:\ngen_clrex(VAR_1);", "break;", "case 4:\ncase 5:\ncase 6:\nbreak;", "default:\ngoto illegal_op;", "}", "break;", "case 4:\ntmp = load_reg(VAR_1, rn);", "gen_bx(VAR_1, tmp);", "break;", "case 5:\nif (IS_USER(VAR_1)) {", "goto illegal_op;", "}", "if (rn != 14 || rd != 15) {", "goto illegal_op;", "}", "tmp = load_reg(VAR_1, rn);", "tcg_gen_subi_i32(tmp, tmp, insn & 0xff);", "gen_exception_return(VAR_1, tmp);", "break;", "case 6:\ntmp = tcg_temp_new_i32();", "if (IS_M(VAR_0)) {", "addr = tcg_const_i32(insn & 0xff);", "gen_helper_v7m_mrs(tmp, cpu_env, addr);", "tcg_temp_free_i32(addr);", "} else {", "gen_helper_cpsr_read(tmp, cpu_env);", "}", "store_reg(VAR_1, rd, tmp);", "break;", "case 7:\nif (IS_USER(VAR_1) || IS_M(VAR_0))\ngoto illegal_op;", "tmp = load_cpu_field(spsr);", "store_reg(VAR_1, rd, tmp);", "break;", "}", "}", "} else {", "VAR_3 = (insn >> 22) & 0xf;", "VAR_1->condlabel = gen_new_label();", "gen_test_cc(VAR_3 ^ 1, VAR_1->condlabel);", "VAR_1->condjmp = 1;", "offset = (insn & 0x7ff) << 1;", "offset |= (insn & 0x003f0000) >> 4;", "offset |= ((int32_t)((insn << 5) & 0x80000000)) >> 11;", "offset |= (insn & (1 << 13)) << 5;", "offset |= (insn & (1 << 11)) << 8;", "gen_jmp(VAR_1, VAR_1->pc + offset);", "}", "} else {", "if (insn & (1 << 25)) {", "if (insn & (1 << 24)) {", "if (insn & (1 << 20))\ngoto illegal_op;", "VAR_3 = (insn >> 21) & 7;", "imm = insn & 0x1f;", "shift = ((insn >> 6) & 3) | ((insn >> 10) & 0x1c);", "if (rn == 15) {", "tmp = tcg_temp_new_i32();", "tcg_gen_movi_i32(tmp, 0);", "} else {", "tmp = load_reg(VAR_1, rn);", "}", "switch (VAR_3) {", "case 2:\nimm++;", "if (shift + imm > 32)\ngoto illegal_op;", "if (imm < 32)\ngen_sbfx(tmp, shift, imm);", "break;", "case 6:\nimm++;", "if (shift + imm > 32)\ngoto illegal_op;", "if (imm < 32)\ngen_ubfx(tmp, shift, (1u << imm) - 1);", "break;", "case 3:\nif (imm < shift)\ngoto illegal_op;", "imm = imm + 1 - shift;", "if (imm != 32) {", "tmp2 = load_reg(VAR_1, rd);", "tcg_gen_deposit_i32(tmp, tmp2, tmp, shift, imm);", "tcg_temp_free_i32(tmp2);", "}", "break;", "case 7:\ngoto illegal_op;", "default:\nif (shift) {", "if (VAR_3 & 1)\ntcg_gen_sari_i32(tmp, tmp, shift);", "else\ntcg_gen_shli_i32(tmp, tmp, shift);", "}", "tmp2 = tcg_const_i32(imm);", "if (VAR_3 & 4) {", "if ((VAR_3 & 1) && shift == 0)\ngen_helper_usat16(tmp, cpu_env, tmp, tmp2);", "else\ngen_helper_usat(tmp, cpu_env, tmp, tmp2);", "} else {", "if ((VAR_3 & 1) && shift == 0)\ngen_helper_ssat16(tmp, cpu_env, tmp, tmp2);", "else\ngen_helper_ssat(tmp, cpu_env, tmp, tmp2);", "}", "tcg_temp_free_i32(tmp2);", "break;", "}", "store_reg(VAR_1, rd, tmp);", "} else {", "imm = ((insn & 0x04000000) >> 15)\n| ((insn & 0x7000) >> 4) | (insn & 0xff);", "if (insn & (1 << 22)) {", "imm |= (insn >> 4) & 0xf000;", "if (insn & (1 << 23)) {", "tmp = load_reg(VAR_1, rd);", "tcg_gen_ext16u_i32(tmp, tmp);", "tcg_gen_ori_i32(tmp, tmp, imm << 16);", "} else {", "tmp = tcg_temp_new_i32();", "tcg_gen_movi_i32(tmp, imm);", "}", "} else {", "if (rn == 15) {", "offset = VAR_1->pc & ~(uint32_t)3;", "if (insn & (1 << 23))\noffset -= imm;", "else\noffset += imm;", "tmp = tcg_temp_new_i32();", "tcg_gen_movi_i32(tmp, offset);", "} else {", "tmp = load_reg(VAR_1, rn);", "if (insn & (1 << 23))\ntcg_gen_subi_i32(tmp, tmp, imm);", "else\ntcg_gen_addi_i32(tmp, tmp, imm);", "}", "}", "store_reg(VAR_1, rd, tmp);", "}", "} else {", "int VAR_10 = 0;", "shift = ((insn & 0x04000000) >> 23) | ((insn & 0x7000) >> 12);", "imm = (insn & 0xff);", "switch (shift) {", "case 0:\nbreak;", "case 1:\nimm |= imm << 16;", "break;", "case 2:\nimm |= imm << 16;", "imm <<= 8;", "break;", "case 3:\nimm |= imm << 16;", "imm |= imm << 8;", "break;", "default:\nshift = (shift << 1) | (imm >> 7);", "imm |= 0x80;", "imm = imm << (32 - shift);", "VAR_10 = 1;", "break;", "}", "tmp2 = tcg_temp_new_i32();", "tcg_gen_movi_i32(tmp2, imm);", "rn = (insn >> 16) & 0xf;", "if (rn == 15) {", "tmp = tcg_temp_new_i32();", "tcg_gen_movi_i32(tmp, 0);", "} else {", "tmp = load_reg(VAR_1, rn);", "}", "VAR_3 = (insn >> 21) & 0xf;", "if (gen_thumb2_data_op(VAR_1, VAR_3, (insn & (1 << 20)) != 0,\nVAR_10, tmp, tmp2))\ngoto illegal_op;", "tcg_temp_free_i32(tmp2);", "rd = (insn >> 8) & 0xf;", "if (rd != 15) {", "store_reg(VAR_1, rd, tmp);", "} else {", "tcg_temp_free_i32(tmp);", "}", "}", "}", "break;", "case 12:\n{", "int VAR_11 = 0;", "int VAR_12 = 0;", "int VAR_13;", "if ((insn & 0x01100000) == 0x01000000) {", "if (disas_neon_ls_insn(VAR_0, VAR_1, insn))\ngoto illegal_op;", "break;", "}", "VAR_3 = ((insn >> 21) & 3) | ((insn >> 22) & 4);", "if (rs == 15) {", "if (!(insn & (1 << 20))) {", "goto illegal_op;", "}", "if (VAR_3 != 2) {", "int VAR_14 = (insn >> 23) & 3;", "int VAR_15 = (insn >> 6) & 0x3f;", "if (VAR_3 & 2) {", "goto illegal_op;", "}", "if (rn == 15) {", "return 0;", "}", "if (VAR_14 & 1) {", "return 0;", "}", "if ((VAR_15 == 0) || ((VAR_15 & 0x3c) == 0x30)) {", "return 0;", "}", "return 1;", "}", "}", "VAR_13 = IS_USER(VAR_1);", "if (rn == 15) {", "addr = tcg_temp_new_i32();", "imm = VAR_1->pc & 0xfffffffc;", "if (insn & (1 << 23))\nimm += insn & 0xfff;", "else\nimm -= insn & 0xfff;", "tcg_gen_movi_i32(addr, imm);", "} else {", "addr = load_reg(VAR_1, rn);", "if (insn & (1 << 23)) {", "imm = insn & 0xfff;", "tcg_gen_addi_i32(addr, addr, imm);", "} else {", "imm = insn & 0xff;", "switch ((insn >> 8) & 0xf) {", "case 0x0:\nshift = (insn >> 4) & 0xf;", "if (shift > 3) {", "tcg_temp_free_i32(addr);", "goto illegal_op;", "}", "tmp = load_reg(VAR_1, rm);", "if (shift)\ntcg_gen_shli_i32(tmp, tmp, shift);", "tcg_gen_add_i32(addr, addr, tmp);", "tcg_temp_free_i32(tmp);", "break;", "case 0xc:\ntcg_gen_addi_i32(addr, addr, -imm);", "break;", "case 0xe:\ntcg_gen_addi_i32(addr, addr, imm);", "VAR_13 = 1;", "break;", "case 0x9:\nimm = -imm;", "case 0xb:\nVAR_11 = 1;", "VAR_12 = 1;", "break;", "case 0xd:\nimm = -imm;", "case 0xf:\ntcg_gen_addi_i32(addr, addr, imm);", "VAR_12 = 1;", "break;", "default:\ntcg_temp_free_i32(addr);", "goto illegal_op;", "}", "}", "}", "if (insn & (1 << 20)) {", "tmp = tcg_temp_new_i32();", "switch (VAR_3) {", "case 0:\ntcg_gen_qemu_ld8u(tmp, addr, VAR_13);", "break;", "case 4:\ntcg_gen_qemu_ld8s(tmp, addr, VAR_13);", "break;", "case 1:\ntcg_gen_qemu_ld16u(tmp, addr, VAR_13);", "break;", "case 5:\ntcg_gen_qemu_ld16s(tmp, addr, VAR_13);", "break;", "case 2:\ntcg_gen_qemu_ld32u(tmp, addr, VAR_13);", "break;", "default:\ntcg_temp_free_i32(tmp);", "tcg_temp_free_i32(addr);", "goto illegal_op;", "}", "if (rs == 15) {", "gen_bx(VAR_1, tmp);", "} else {", "store_reg(VAR_1, rs, tmp);", "}", "} else {", "tmp = load_reg(VAR_1, rs);", "switch (VAR_3) {", "case 0:\ntcg_gen_qemu_st8(tmp, addr, VAR_13);", "break;", "case 1:\ntcg_gen_qemu_st16(tmp, addr, VAR_13);", "break;", "case 2:\ntcg_gen_qemu_st32(tmp, addr, VAR_13);", "break;", "default:\ntcg_temp_free_i32(tmp);", "tcg_temp_free_i32(addr);", "goto illegal_op;", "}", "tcg_temp_free_i32(tmp);", "}", "if (VAR_11)\ntcg_gen_addi_i32(addr, addr, imm);", "if (VAR_12) {", "store_reg(VAR_1, rn, addr);", "} else {", "tcg_temp_free_i32(addr);", "}", "}", "break;", "default:\ngoto illegal_op;", "}", "return 0;", "illegal_op:\nreturn 1;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 29, 31 ], [ 37 ], [ 39 ], [ 41 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 71 ], [ 73 ], [ 75 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 109 ], [ 113 ], [ 115 ], [ 117 ], [ 121 ], [ 123 ], [ 125 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139, 143 ], [ 145, 147 ], [ 151 ], [ 155 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 167 ], [ 169, 171 ], [ 173 ], [ 175 ], [ 177 ], [ 179 ], [ 181 ], [ 185 ], [ 187 ], [ 189 ], [ 191 ], [ 193 ], [ 195 ], [ 197 ], [ 199 ], [ 203 ], [ 205 ], [ 207 ], [ 209 ], [ 211 ], [ 213 ], [ 215 ], [ 217 ], [ 219 ], [ 223, 225 ], [ 227 ], [ 229 ], [ 231 ], [ 233 ], [ 235 ], [ 237 ], [ 241 ], [ 243 ], [ 245 ], [ 247 ], [ 249 ], [ 251 ], [ 253 ], [ 255 ], [ 257 ], [ 259 ], [ 263 ], [ 265 ], [ 267 ], [ 269 ], [ 271 ], [ 273 ], [ 275 ], [ 277 ], [ 279 ], [ 283 ], [ 285 ], [ 287 ], [ 289 ], [ 291 ], [ 293 ], [ 295 ], [ 297 ], [ 299 ], [ 301 ], [ 303 ], [ 305 ], [ 307 ], [ 309 ], [ 311 ], [ 313 ], [ 315 ], [ 317, 319 ], [ 321, 325 ], [ 327 ], [ 329 ], [ 331 ], [ 333 ], [ 335, 339 ], [ 341 ], [ 343 ], [ 347, 351 ], [ 353 ], [ 355 ], [ 357 ], [ 359 ], [ 361 ], [ 363 ], [ 365 ], [ 367 ], [ 369, 371 ], [ 373 ], [ 375, 377 ], [ 379 ], [ 381, 383 ], [ 385 ], [ 387, 389 ], [ 391 ], [ 393 ], [ 395 ], [ 397 ], [ 399 ], [ 401, 403 ], [ 405 ], [ 407, 409 ], [ 411 ], [ 413, 415 ], [ 417 ], [ 419, 421 ], [ 423 ], [ 425 ], [ 427 ], [ 429 ], [ 431 ], [ 433 ], [ 435 ], [ 437 ], [ 439 ], [ 441 ], [ 443 ], [ 447 ], [ 451 ], [ 453 ], [ 455 ], [ 457 ], [ 461 ], [ 463, 465 ], [ 469 ], [ 471 ], [ 473 ], [ 475 ], [ 477 ], [ 479 ], [ 483 ], [ 485 ], [ 487 ], [ 489 ], [ 491 ], [ 493 ], [ 495 ], [ 497 ], [ 499 ], [ 501 ], [ 503 ], [ 507, 509 ], [ 511 ], [ 513 ], [ 515 ], [ 517 ], [ 521 ], [ 523 ], [ 525 ], [ 527, 529 ], [ 531 ], [ 533 ], [ 535 ], [ 537 ], [ 541 ], [ 543 ], [ 545, 547 ], [ 549 ], [ 553 ], [ 555 ], [ 557 ], [ 559 ], [ 561 ], [ 563 ], [ 565 ], [ 567 ], [ 569 ], [ 571 ], [ 573 ], [ 577 ], [ 579 ], [ 581 ], [ 583 ], [ 585 ], [ 587 ], [ 589 ], [ 591 ], [ 593 ], [ 595 ], [ 599 ], [ 601 ], [ 603 ], [ 607, 609 ], [ 611 ], [ 613 ], [ 615 ], [ 617 ], [ 619 ], [ 621 ], [ 623 ], [ 625, 629 ], [ 631 ], [ 635 ], [ 637 ], [ 639 ], [ 641 ], [ 645, 647 ], [ 649 ], [ 651 ], [ 653 ], [ 655 ], [ 659, 661 ], [ 663 ], [ 665 ], [ 667 ], [ 669 ], [ 671 ], [ 673 ], [ 675 ], [ 679 ], [ 681 ], [ 683 ], [ 685 ], [ 687 ], [ 689 ], [ 691 ], [ 695 ], [ 697 ], [ 699 ], [ 701 ], [ 703 ], [ 705, 707 ], [ 709 ], [ 711 ], [ 713 ], [ 715 ], [ 717 ], [ 719 ], [ 721 ], [ 723 ], [ 725, 727 ], [ 729, 731 ], [ 733 ], [ 735, 737 ], [ 739 ], [ 741, 743 ], [ 745 ], [ 747 ], [ 749 ], [ 751, 753 ], [ 755 ], [ 757 ], [ 759, 761 ], [ 763 ], [ 769, 771 ], [ 773 ], [ 775 ], [ 777 ], [ 779 ], [ 781 ], [ 783 ], [ 785 ], [ 787 ], [ 789 ], [ 791 ], [ 793 ], [ 795 ], [ 797 ], [ 799 ], [ 801 ], [ 803 ], [ 805 ], [ 807 ], [ 809 ], [ 811 ], [ 813 ], [ 815, 817 ], [ 819 ], [ 821, 823 ], [ 825 ], [ 827 ], [ 829 ], [ 831 ], [ 833 ], [ 835 ], [ 837, 839 ], [ 841 ], [ 845 ], [ 847 ], [ 849, 851 ], [ 853, 855 ], [ 857, 859 ], [ 861 ], [ 863 ], [ 865 ], [ 867 ], [ 869, 871 ], [ 873 ], [ 875, 877 ], [ 879 ], [ 881, 883 ], [ 885 ], [ 887, 889 ], [ 891 ], [ 893, 895 ], [ 897 ], [ 899 ], [ 901 ], [ 903 ], [ 905 ], [ 907 ], [ 909, 911 ], [ 913 ], [ 915, 917 ], [ 919 ], [ 921 ], [ 923 ], [ 925 ], [ 927, 929 ], [ 931 ], [ 933 ], [ 935 ], [ 937, 939 ], [ 941 ], [ 943 ], [ 945 ], [ 947, 949 ], [ 951, 953 ], [ 955 ], [ 957 ], [ 959 ], [ 961, 963 ], [ 965 ], [ 967 ], [ 969 ], [ 971 ], [ 973 ], [ 975 ], [ 977 ], [ 979, 981, 983, 985 ], [ 987 ], [ 989 ], [ 993 ], [ 995 ], [ 1005 ], [ 1007 ], [ 1009 ], [ 1011, 1013 ], [ 1015 ], [ 1017 ], [ 1019 ], [ 1021 ], [ 1023 ], [ 1025, 1027, 1029 ], [ 1031, 1033 ], [ 1035 ], [ 1037 ], [ 1039 ], [ 1041 ], [ 1043 ], [ 1045, 1047 ], [ 1049 ], [ 1051 ], [ 1053 ], [ 1055 ], [ 1057 ], [ 1059, 1061 ], [ 1063 ], [ 1065 ], [ 1067 ], [ 1069 ], [ 1071 ], [ 1073 ], [ 1075 ], [ 1077 ], [ 1079 ], [ 1081 ], [ 1083 ], [ 1085 ], [ 1087 ], [ 1089 ], [ 1091 ], [ 1093 ], [ 1095, 1097 ], [ 1099 ], [ 1101 ], [ 1103 ], [ 1105 ], [ 1107 ], [ 1109 ], [ 1111 ], [ 1113 ], [ 1115 ], [ 1117 ], [ 1119, 1121 ], [ 1123 ], [ 1125 ], [ 1127 ], [ 1131 ], [ 1133 ], [ 1135 ], [ 1137, 1139 ], [ 1141, 1143 ], [ 1145 ], [ 1147 ], [ 1149 ], [ 1153, 1155 ], [ 1157 ], [ 1159 ], [ 1161 ], [ 1163 ], [ 1165 ], [ 1167 ], [ 1169 ], [ 1173 ], [ 1175 ], [ 1177 ], [ 1179 ], [ 1181 ], [ 1183 ], [ 1185 ], [ 1187 ], [ 1191 ], [ 1193 ], [ 1195 ], [ 1199 ], [ 1201 ], [ 1203 ], [ 1205 ], [ 1207 ], [ 1209 ], [ 1213 ], [ 1215 ], [ 1217 ], [ 1219 ], [ 1223 ], [ 1225 ], [ 1227 ], [ 1231 ], [ 1233 ], [ 1235 ], [ 1237 ], [ 1239 ], [ 1241 ], [ 1243 ], [ 1245 ], [ 1247, 1251 ], [ 1255 ], [ 1257, 1259 ], [ 1261 ], [ 1263, 1265 ], [ 1267, 1269 ], [ 1271 ], [ 1273 ], [ 1275, 1277 ], [ 1281 ], [ 1287 ], [ 1291 ], [ 1299 ], [ 1301 ], [ 1305 ], [ 1309 ], [ 1311 ], [ 1315 ], [ 1317 ], [ 1321 ], [ 1323 ], [ 1327 ], [ 1331 ], [ 1333 ], [ 1335 ], [ 1339, 1341 ], [ 1345 ], [ 1351 ], [ 1353 ], [ 1355 ], [ 1357 ], [ 1359, 1361 ], [ 1363 ], [ 1365 ], [ 1367 ], [ 1369 ], [ 1371 ], [ 1373 ], [ 1375 ], [ 1377 ], [ 1381, 1383, 1385 ], [ 1387 ], [ 1389, 1391, 1393, 1395 ], [ 1397 ], [ 1399, 1401 ], [ 1403 ], [ 1405 ], [ 1409, 1411 ], [ 1413 ], [ 1415 ], [ 1417 ], [ 1419, 1421 ], [ 1423, 1425 ], [ 1427, 1429 ], [ 1431, 1433 ], [ 1435 ], [ 1437 ], [ 1439 ], [ 1441 ], [ 1443 ], [ 1445 ], [ 1447 ], [ 1449 ], [ 1451 ], [ 1453, 1455 ], [ 1457 ], [ 1459 ], [ 1461, 1463 ], [ 1465 ], [ 1467, 1469, 1471, 1475 ], [ 1477, 1479 ], [ 1481 ], [ 1483 ], [ 1485, 1489 ], [ 1491 ], [ 1493 ], [ 1495, 1497 ], [ 1499 ], [ 1501 ], [ 1503 ], [ 1505 ], [ 1507 ], [ 1509 ], [ 1511 ], [ 1513 ], [ 1515 ], [ 1517, 1519 ], [ 1521 ], [ 1523 ], [ 1525 ], [ 1527 ], [ 1529 ], [ 1531 ], [ 1533 ], [ 1535 ], [ 1537 ], [ 1539, 1543, 1545 ], [ 1547 ], [ 1549 ], [ 1551 ], [ 1553 ], [ 1555 ], [ 1557 ], [ 1561 ], [ 1565 ], [ 1567 ], [ 1569 ], [ 1575 ], [ 1579 ], [ 1583 ], [ 1587 ], [ 1591 ], [ 1597 ], [ 1599 ], [ 1601 ], [ 1605 ], [ 1607 ], [ 1609, 1611 ], [ 1615 ], [ 1617 ], [ 1619 ], [ 1621 ], [ 1623 ], [ 1625 ], [ 1627 ], [ 1629 ], [ 1631 ], [ 1633 ], [ 1635, 1637 ], [ 1639, 1641 ], [ 1643, 1645 ], [ 1647 ], [ 1649, 1651 ], [ 1653, 1655 ], [ 1657, 1659 ], [ 1661 ], [ 1663, 1665, 1667 ], [ 1669 ], [ 1671 ], [ 1673 ], [ 1675 ], [ 1677 ], [ 1679 ], [ 1681 ], [ 1683, 1685 ], [ 1687, 1689 ], [ 1691, 1693 ], [ 1695, 1697 ], [ 1699 ], [ 1701 ], [ 1703 ], [ 1707, 1709 ], [ 1711, 1713 ], [ 1715 ], [ 1719, 1721 ], [ 1723, 1725 ], [ 1727 ], [ 1729 ], [ 1731 ], [ 1733 ], [ 1735 ], [ 1737 ], [ 1739, 1741 ], [ 1743 ], [ 1747 ], [ 1749 ], [ 1753 ], [ 1755 ], [ 1757 ], [ 1759 ], [ 1763 ], [ 1765 ], [ 1767 ], [ 1769 ], [ 1773 ], [ 1775 ], [ 1777, 1779 ], [ 1781, 1783 ], [ 1785 ], [ 1787 ], [ 1789 ], [ 1791 ], [ 1793, 1795 ], [ 1797, 1799 ], [ 1801 ], [ 1803 ], [ 1805 ], [ 1807 ], [ 1809 ], [ 1811 ], [ 1815 ], [ 1817 ], [ 1819 ], [ 1821, 1825 ], [ 1827, 1829 ], [ 1831 ], [ 1833, 1835 ], [ 1837 ], [ 1839 ], [ 1841, 1843 ], [ 1845 ], [ 1847 ], [ 1849, 1851 ], [ 1853 ], [ 1855 ], [ 1857 ], [ 1859 ], [ 1861 ], [ 1863 ], [ 1865 ], [ 1867 ], [ 1869 ], [ 1871 ], [ 1873 ], [ 1875 ], [ 1877 ], [ 1879 ], [ 1881 ], [ 1883, 1885, 1887 ], [ 1889 ], [ 1891 ], [ 1893 ], [ 1895 ], [ 1897 ], [ 1899 ], [ 1901 ], [ 1903 ], [ 1905 ], [ 1907 ], [ 1909, 1911 ], [ 1913 ], [ 1915 ], [ 1917 ], [ 1919 ], [ 1921, 1923 ], [ 1925 ], [ 1927 ], [ 1929 ], [ 1931 ], [ 1933 ], [ 1935 ], [ 1937 ], [ 1939 ], [ 1963 ], [ 1965 ], [ 1967 ], [ 1969 ], [ 1971 ], [ 1973 ], [ 1981 ], [ 1983 ], [ 1985 ], [ 1987 ], [ 1989 ], [ 1991 ], [ 1993 ], [ 1995 ], [ 1999 ], [ 2001 ], [ 2003 ], [ 2005 ], [ 2007 ], [ 2009 ], [ 2015 ], [ 2017, 2019 ], [ 2021, 2023 ], [ 2025 ], [ 2027 ], [ 2029 ], [ 2031 ], [ 2035 ], [ 2037 ], [ 2039 ], [ 2041 ], [ 2043 ], [ 2045, 2047 ], [ 2049 ], [ 2051 ], [ 2053 ], [ 2055 ], [ 2057 ], [ 2059, 2061 ], [ 2063 ], [ 2065 ], [ 2067 ], [ 2069, 2071 ], [ 2073 ], [ 2075, 2077 ], [ 2079 ], [ 2081 ], [ 2083, 2085 ], [ 2089, 2091 ], [ 2093 ], [ 2095 ], [ 2097, 2099 ], [ 2103, 2105 ], [ 2107 ], [ 2109 ], [ 2111, 2113 ], [ 2115 ], [ 2117 ], [ 2119 ], [ 2121 ], [ 2123 ], [ 2127 ], [ 2129 ], [ 2131, 2133 ], [ 2135 ], [ 2137, 2139 ], [ 2141 ], [ 2143, 2145 ], [ 2147 ], [ 2149, 2151 ], [ 2153 ], [ 2155, 2157 ], [ 2159 ], [ 2161, 2163 ], [ 2165 ], [ 2167 ], [ 2169 ], [ 2171 ], [ 2173 ], [ 2175 ], [ 2177 ], [ 2179 ], [ 2181 ], [ 2185 ], [ 2187 ], [ 2189, 2191 ], [ 2193 ], [ 2195, 2197 ], [ 2199 ], [ 2201, 2203 ], [ 2205 ], [ 2207, 2209 ], [ 2211 ], [ 2213 ], [ 2215 ], [ 2217 ], [ 2219 ], [ 2221, 2223 ], [ 2225 ], [ 2227 ], [ 2229 ], [ 2231 ], [ 2233 ], [ 2235 ], [ 2237 ], [ 2239, 2241 ], [ 2243 ], [ 2245 ], [ 2247, 2249 ], [ 2251 ] ]
22,225
static int hevc_decode_nal_units(const uint8_t *buf, int buf_size, HEVCParamSets *ps, int is_nalff, int nal_length_size, void *logctx) { int i; int ret = 0; H2645Packet pkt = { 0 }; ret = ff_h2645_packet_split(&pkt, buf, buf_size, logctx, is_nalff, nal_length_size, AV_CODEC_ID_HEVC, 1); if (ret < 0) { goto done; } for (i = 0; i < pkt.nb_nals; i++) { H2645NAL *nal = &pkt.nals[i]; /* ignore everything except parameter sets and VCL NALUs */ switch (nal->type) { case HEVC_NAL_VPS: ff_hevc_decode_nal_vps(&nal->gb, logctx, ps); break; case HEVC_NAL_SPS: ff_hevc_decode_nal_sps(&nal->gb, logctx, ps, 1); break; case HEVC_NAL_PPS: ff_hevc_decode_nal_pps(&nal->gb, logctx, ps); break; default: av_log(logctx, AV_LOG_VERBOSE, "Ignoring NAL type %d in extradata\n", nal->type); break; } } done: ff_h2645_packet_uninit(&pkt); return ret; }
true
FFmpeg
159ab4625bd3641e79b564335be8069dca881978
static int hevc_decode_nal_units(const uint8_t *buf, int buf_size, HEVCParamSets *ps, int is_nalff, int nal_length_size, void *logctx) { int i; int ret = 0; H2645Packet pkt = { 0 }; ret = ff_h2645_packet_split(&pkt, buf, buf_size, logctx, is_nalff, nal_length_size, AV_CODEC_ID_HEVC, 1); if (ret < 0) { goto done; } for (i = 0; i < pkt.nb_nals; i++) { H2645NAL *nal = &pkt.nals[i]; switch (nal->type) { case HEVC_NAL_VPS: ff_hevc_decode_nal_vps(&nal->gb, logctx, ps); break; case HEVC_NAL_SPS: ff_hevc_decode_nal_sps(&nal->gb, logctx, ps, 1); break; case HEVC_NAL_PPS: ff_hevc_decode_nal_pps(&nal->gb, logctx, ps); break; default: av_log(logctx, AV_LOG_VERBOSE, "Ignoring NAL type %d in extradata\n", nal->type); break; } } done: ff_h2645_packet_uninit(&pkt); return ret; }
{ "code": [ " int is_nalff, int nal_length_size, void *logctx)", " case HEVC_NAL_VPS: ff_hevc_decode_nal_vps(&nal->gb, logctx, ps); break;", " case HEVC_NAL_SPS: ff_hevc_decode_nal_sps(&nal->gb, logctx, ps, 1); break;", " case HEVC_NAL_PPS: ff_hevc_decode_nal_pps(&nal->gb, logctx, ps); break;", " return ret;" ], "line_no": [ 3, 35, 37, 39, 57 ] }
static int FUNC_0(const uint8_t *VAR_0, int VAR_1, HEVCParamSets *VAR_2, int VAR_3, int VAR_4, void *VAR_5) { int VAR_6; int VAR_7 = 0; H2645Packet pkt = { 0 }; VAR_7 = ff_h2645_packet_split(&pkt, VAR_0, VAR_1, VAR_5, VAR_3, VAR_4, AV_CODEC_ID_HEVC, 1); if (VAR_7 < 0) { goto done; } for (VAR_6 = 0; VAR_6 < pkt.nb_nals; VAR_6++) { H2645NAL *nal = &pkt.nals[VAR_6]; switch (nal->type) { case HEVC_NAL_VPS: ff_hevc_decode_nal_vps(&nal->gb, VAR_5, VAR_2); break; case HEVC_NAL_SPS: ff_hevc_decode_nal_sps(&nal->gb, VAR_5, VAR_2, 1); break; case HEVC_NAL_PPS: ff_hevc_decode_nal_pps(&nal->gb, VAR_5, VAR_2); break; default: av_log(VAR_5, AV_LOG_VERBOSE, "Ignoring NAL type %d in extradata\n", nal->type); break; } } done: ff_h2645_packet_uninit(&pkt); return VAR_7; }
[ "static int FUNC_0(const uint8_t *VAR_0, int VAR_1, HEVCParamSets *VAR_2,\nint VAR_3, int VAR_4, void *VAR_5)\n{", "int VAR_6;", "int VAR_7 = 0;", "H2645Packet pkt = { 0 };", "VAR_7 = ff_h2645_packet_split(&pkt, VAR_0, VAR_1, VAR_5, VAR_3, VAR_4, AV_CODEC_ID_HEVC, 1);", "if (VAR_7 < 0) {", "goto done;", "}", "for (VAR_6 = 0; VAR_6 < pkt.nb_nals; VAR_6++) {", "H2645NAL *nal = &pkt.nals[VAR_6];", "switch (nal->type) {", "case HEVC_NAL_VPS: ff_hevc_decode_nal_vps(&nal->gb, VAR_5, VAR_2); break;", "case HEVC_NAL_SPS: ff_hevc_decode_nal_sps(&nal->gb, VAR_5, VAR_2, 1); break;", "case HEVC_NAL_PPS: ff_hevc_decode_nal_pps(&nal->gb, VAR_5, VAR_2); break;", "default:\nav_log(VAR_5, AV_LOG_VERBOSE, \"Ignoring NAL type %d in extradata\\n\", nal->type);", "break;", "}", "}", "done:\nff_h2645_packet_uninit(&pkt);", "return VAR_7;", "}" ]
[ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 25 ], [ 27 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41, 43 ], [ 45 ], [ 47 ], [ 49 ], [ 53, 55 ], [ 57 ], [ 59 ] ]
22,227
static void test_qemu_strtoll_full_max(void) { const char *str = g_strdup_printf("%lld", LLONG_MAX); int64_t res; int err; err = qemu_strtoll(str, NULL, 0, &res); g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, LLONG_MAX); }
true
qemu
d6f723b513a0c3c4e58343b7c52a2f9850861fa0
static void test_qemu_strtoll_full_max(void) { const char *str = g_strdup_printf("%lld", LLONG_MAX); int64_t res; int err; err = qemu_strtoll(str, NULL, 0, &res); g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, LLONG_MAX); }
{ "code": [ " const char *str = g_strdup_printf(\"%lld\", LLONG_MAX);", " const char *str = g_strdup_printf(\"%lld\", LLONG_MAX);" ], "line_no": [ 7, 7 ] }
static void FUNC_0(void) { const char *VAR_0 = g_strdup_printf("%lld", LLONG_MAX); int64_t res; int VAR_1; VAR_1 = qemu_strtoll(VAR_0, NULL, 0, &res); g_assert_cmpint(VAR_1, ==, 0); g_assert_cmpint(res, ==, LLONG_MAX); }
[ "static void FUNC_0(void)\n{", "const char *VAR_0 = g_strdup_printf(\"%lld\", LLONG_MAX);", "int64_t res;", "int VAR_1;", "VAR_1 = qemu_strtoll(VAR_0, NULL, 0, &res);", "g_assert_cmpint(VAR_1, ==, 0);", "g_assert_cmpint(res, ==, LLONG_MAX);", "}" ]
[ 0, 1, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ] ]
22,228
static int dump_init(DumpState *s, int fd, bool paging, bool has_filter, int64_t begin, int64_t length, Error **errp) { CPUState *cpu; int nr_cpus; Error *err = NULL; int ret; if (runstate_is_running()) { vm_stop(RUN_STATE_SAVE_VM); s->resume = true; } else { s->resume = false; } /* If we use KVM, we should synchronize the registers before we get dump * info or physmap info. */ cpu_synchronize_all_states(); nr_cpus = 0; CPU_FOREACH(cpu) { nr_cpus++; } s->errp = errp; s->fd = fd; s->has_filter = has_filter; s->begin = begin; s->length = length; guest_phys_blocks_init(&s->guest_phys_blocks); guest_phys_blocks_append(&s->guest_phys_blocks); s->start = get_start_block(s); if (s->start == -1) { error_set(errp, QERR_INVALID_PARAMETER, "begin"); goto cleanup; } /* get dump info: endian, class and architecture. * If the target architecture is not supported, cpu_get_dump_info() will * return -1. */ ret = cpu_get_dump_info(&s->dump_info, &s->guest_phys_blocks); if (ret < 0) { error_set(errp, QERR_UNSUPPORTED); goto cleanup; } s->note_size = cpu_get_note_size(s->dump_info.d_class, s->dump_info.d_machine, nr_cpus); if (s->note_size < 0) { error_set(errp, QERR_UNSUPPORTED); goto cleanup; } /* get memory mapping */ memory_mapping_list_init(&s->list); if (paging) { qemu_get_guest_memory_mapping(&s->list, &s->guest_phys_blocks, &err); if (err != NULL) { error_propagate(errp, err); goto cleanup; } } else { qemu_get_guest_simple_memory_mapping(&s->list, &s->guest_phys_blocks); } s->nr_cpus = nr_cpus; s->page_size = TARGET_PAGE_SIZE; s->page_shift = ffs(s->page_size) - 1; get_max_mapnr(s); uint64_t tmp; tmp = DIV_ROUND_UP(DIV_ROUND_UP(s->max_mapnr, CHAR_BIT), s->page_size); s->len_dump_bitmap = tmp * s->page_size; if (s->has_filter) { memory_mapping_filter(&s->list, s->begin, s->length); } /* * calculate phdr_num * * the type of ehdr->e_phnum is uint16_t, so we should avoid overflow */ s->phdr_num = 1; /* PT_NOTE */ if (s->list.num < UINT16_MAX - 2) { s->phdr_num += s->list.num; s->have_section = false; } else { s->have_section = true; s->phdr_num = PN_XNUM; s->sh_info = 1; /* PT_NOTE */ /* the type of shdr->sh_info is uint32_t, so we should avoid overflow */ if (s->list.num <= UINT32_MAX - 1) { s->sh_info += s->list.num; } else { s->sh_info = UINT32_MAX; } } if (s->dump_info.d_class == ELFCLASS64) { if (s->have_section) { s->memory_offset = sizeof(Elf64_Ehdr) + sizeof(Elf64_Phdr) * s->sh_info + sizeof(Elf64_Shdr) + s->note_size; } else { s->memory_offset = sizeof(Elf64_Ehdr) + sizeof(Elf64_Phdr) * s->phdr_num + s->note_size; } } else { if (s->have_section) { s->memory_offset = sizeof(Elf32_Ehdr) + sizeof(Elf32_Phdr) * s->sh_info + sizeof(Elf32_Shdr) + s->note_size; } else { s->memory_offset = sizeof(Elf32_Ehdr) + sizeof(Elf32_Phdr) * s->phdr_num + s->note_size; } } return 0; cleanup: guest_phys_blocks_free(&s->guest_phys_blocks); if (s->resume) { vm_start(); } return -1; }
true
qemu
b53ccc30c40df52d192e469a86c188a8649c6df3
static int dump_init(DumpState *s, int fd, bool paging, bool has_filter, int64_t begin, int64_t length, Error **errp) { CPUState *cpu; int nr_cpus; Error *err = NULL; int ret; if (runstate_is_running()) { vm_stop(RUN_STATE_SAVE_VM); s->resume = true; } else { s->resume = false; } cpu_synchronize_all_states(); nr_cpus = 0; CPU_FOREACH(cpu) { nr_cpus++; } s->errp = errp; s->fd = fd; s->has_filter = has_filter; s->begin = begin; s->length = length; guest_phys_blocks_init(&s->guest_phys_blocks); guest_phys_blocks_append(&s->guest_phys_blocks); s->start = get_start_block(s); if (s->start == -1) { error_set(errp, QERR_INVALID_PARAMETER, "begin"); goto cleanup; } ret = cpu_get_dump_info(&s->dump_info, &s->guest_phys_blocks); if (ret < 0) { error_set(errp, QERR_UNSUPPORTED); goto cleanup; } s->note_size = cpu_get_note_size(s->dump_info.d_class, s->dump_info.d_machine, nr_cpus); if (s->note_size < 0) { error_set(errp, QERR_UNSUPPORTED); goto cleanup; } memory_mapping_list_init(&s->list); if (paging) { qemu_get_guest_memory_mapping(&s->list, &s->guest_phys_blocks, &err); if (err != NULL) { error_propagate(errp, err); goto cleanup; } } else { qemu_get_guest_simple_memory_mapping(&s->list, &s->guest_phys_blocks); } s->nr_cpus = nr_cpus; s->page_size = TARGET_PAGE_SIZE; s->page_shift = ffs(s->page_size) - 1; get_max_mapnr(s); uint64_t tmp; tmp = DIV_ROUND_UP(DIV_ROUND_UP(s->max_mapnr, CHAR_BIT), s->page_size); s->len_dump_bitmap = tmp * s->page_size; if (s->has_filter) { memory_mapping_filter(&s->list, s->begin, s->length); } s->phdr_num = 1; if (s->list.num < UINT16_MAX - 2) { s->phdr_num += s->list.num; s->have_section = false; } else { s->have_section = true; s->phdr_num = PN_XNUM; s->sh_info = 1; if (s->list.num <= UINT32_MAX - 1) { s->sh_info += s->list.num; } else { s->sh_info = UINT32_MAX; } } if (s->dump_info.d_class == ELFCLASS64) { if (s->have_section) { s->memory_offset = sizeof(Elf64_Ehdr) + sizeof(Elf64_Phdr) * s->sh_info + sizeof(Elf64_Shdr) + s->note_size; } else { s->memory_offset = sizeof(Elf64_Ehdr) + sizeof(Elf64_Phdr) * s->phdr_num + s->note_size; } } else { if (s->have_section) { s->memory_offset = sizeof(Elf32_Ehdr) + sizeof(Elf32_Phdr) * s->sh_info + sizeof(Elf32_Shdr) + s->note_size; } else { s->memory_offset = sizeof(Elf32_Ehdr) + sizeof(Elf32_Phdr) * s->phdr_num + s->note_size; } } return 0; cleanup: guest_phys_blocks_free(&s->guest_phys_blocks); if (s->resume) { vm_start(); } return -1; }
{ "code": [ "static int dump_init(DumpState *s, int fd, bool paging, bool has_filter," ], "line_no": [ 1 ] }
static int FUNC_0(DumpState *VAR_0, int VAR_1, bool VAR_2, bool VAR_3, int64_t VAR_4, int64_t VAR_5, Error **VAR_6) { CPUState *cpu; int VAR_7; Error *err = NULL; int VAR_8; if (runstate_is_running()) { vm_stop(RUN_STATE_SAVE_VM); VAR_0->resume = true; } else { VAR_0->resume = false; } cpu_synchronize_all_states(); VAR_7 = 0; CPU_FOREACH(cpu) { VAR_7++; } VAR_0->VAR_6 = VAR_6; VAR_0->VAR_1 = VAR_1; VAR_0->VAR_3 = VAR_3; VAR_0->VAR_4 = VAR_4; VAR_0->VAR_5 = VAR_5; guest_phys_blocks_init(&VAR_0->guest_phys_blocks); guest_phys_blocks_append(&VAR_0->guest_phys_blocks); VAR_0->start = get_start_block(VAR_0); if (VAR_0->start == -1) { error_set(VAR_6, QERR_INVALID_PARAMETER, "VAR_4"); goto cleanup; } VAR_8 = cpu_get_dump_info(&VAR_0->dump_info, &VAR_0->guest_phys_blocks); if (VAR_8 < 0) { error_set(VAR_6, QERR_UNSUPPORTED); goto cleanup; } VAR_0->note_size = cpu_get_note_size(VAR_0->dump_info.d_class, VAR_0->dump_info.d_machine, VAR_7); if (VAR_0->note_size < 0) { error_set(VAR_6, QERR_UNSUPPORTED); goto cleanup; } memory_mapping_list_init(&VAR_0->list); if (VAR_2) { qemu_get_guest_memory_mapping(&VAR_0->list, &VAR_0->guest_phys_blocks, &err); if (err != NULL) { error_propagate(VAR_6, err); goto cleanup; } } else { qemu_get_guest_simple_memory_mapping(&VAR_0->list, &VAR_0->guest_phys_blocks); } VAR_0->VAR_7 = VAR_7; VAR_0->page_size = TARGET_PAGE_SIZE; VAR_0->page_shift = ffs(VAR_0->page_size) - 1; get_max_mapnr(VAR_0); uint64_t tmp; tmp = DIV_ROUND_UP(DIV_ROUND_UP(VAR_0->max_mapnr, CHAR_BIT), VAR_0->page_size); VAR_0->len_dump_bitmap = tmp * VAR_0->page_size; if (VAR_0->VAR_3) { memory_mapping_filter(&VAR_0->list, VAR_0->VAR_4, VAR_0->VAR_5); } VAR_0->phdr_num = 1; if (VAR_0->list.num < UINT16_MAX - 2) { VAR_0->phdr_num += VAR_0->list.num; VAR_0->have_section = false; } else { VAR_0->have_section = true; VAR_0->phdr_num = PN_XNUM; VAR_0->sh_info = 1; if (VAR_0->list.num <= UINT32_MAX - 1) { VAR_0->sh_info += VAR_0->list.num; } else { VAR_0->sh_info = UINT32_MAX; } } if (VAR_0->dump_info.d_class == ELFCLASS64) { if (VAR_0->have_section) { VAR_0->memory_offset = sizeof(Elf64_Ehdr) + sizeof(Elf64_Phdr) * VAR_0->sh_info + sizeof(Elf64_Shdr) + VAR_0->note_size; } else { VAR_0->memory_offset = sizeof(Elf64_Ehdr) + sizeof(Elf64_Phdr) * VAR_0->phdr_num + VAR_0->note_size; } } else { if (VAR_0->have_section) { VAR_0->memory_offset = sizeof(Elf32_Ehdr) + sizeof(Elf32_Phdr) * VAR_0->sh_info + sizeof(Elf32_Shdr) + VAR_0->note_size; } else { VAR_0->memory_offset = sizeof(Elf32_Ehdr) + sizeof(Elf32_Phdr) * VAR_0->phdr_num + VAR_0->note_size; } } return 0; cleanup: guest_phys_blocks_free(&VAR_0->guest_phys_blocks); if (VAR_0->resume) { vm_start(); } return -1; }
[ "static int FUNC_0(DumpState *VAR_0, int VAR_1, bool VAR_2, bool VAR_3,\nint64_t VAR_4, int64_t VAR_5, Error **VAR_6)\n{", "CPUState *cpu;", "int VAR_7;", "Error *err = NULL;", "int VAR_8;", "if (runstate_is_running()) {", "vm_stop(RUN_STATE_SAVE_VM);", "VAR_0->resume = true;", "} else {", "VAR_0->resume = false;", "}", "cpu_synchronize_all_states();", "VAR_7 = 0;", "CPU_FOREACH(cpu) {", "VAR_7++;", "}", "VAR_0->VAR_6 = VAR_6;", "VAR_0->VAR_1 = VAR_1;", "VAR_0->VAR_3 = VAR_3;", "VAR_0->VAR_4 = VAR_4;", "VAR_0->VAR_5 = VAR_5;", "guest_phys_blocks_init(&VAR_0->guest_phys_blocks);", "guest_phys_blocks_append(&VAR_0->guest_phys_blocks);", "VAR_0->start = get_start_block(VAR_0);", "if (VAR_0->start == -1) {", "error_set(VAR_6, QERR_INVALID_PARAMETER, \"VAR_4\");", "goto cleanup;", "}", "VAR_8 = cpu_get_dump_info(&VAR_0->dump_info, &VAR_0->guest_phys_blocks);", "if (VAR_8 < 0) {", "error_set(VAR_6, QERR_UNSUPPORTED);", "goto cleanup;", "}", "VAR_0->note_size = cpu_get_note_size(VAR_0->dump_info.d_class,\nVAR_0->dump_info.d_machine, VAR_7);", "if (VAR_0->note_size < 0) {", "error_set(VAR_6, QERR_UNSUPPORTED);", "goto cleanup;", "}", "memory_mapping_list_init(&VAR_0->list);", "if (VAR_2) {", "qemu_get_guest_memory_mapping(&VAR_0->list, &VAR_0->guest_phys_blocks, &err);", "if (err != NULL) {", "error_propagate(VAR_6, err);", "goto cleanup;", "}", "} else {", "qemu_get_guest_simple_memory_mapping(&VAR_0->list, &VAR_0->guest_phys_blocks);", "}", "VAR_0->VAR_7 = VAR_7;", "VAR_0->page_size = TARGET_PAGE_SIZE;", "VAR_0->page_shift = ffs(VAR_0->page_size) - 1;", "get_max_mapnr(VAR_0);", "uint64_t tmp;", "tmp = DIV_ROUND_UP(DIV_ROUND_UP(VAR_0->max_mapnr, CHAR_BIT), VAR_0->page_size);", "VAR_0->len_dump_bitmap = tmp * VAR_0->page_size;", "if (VAR_0->VAR_3) {", "memory_mapping_filter(&VAR_0->list, VAR_0->VAR_4, VAR_0->VAR_5);", "}", "VAR_0->phdr_num = 1;", "if (VAR_0->list.num < UINT16_MAX - 2) {", "VAR_0->phdr_num += VAR_0->list.num;", "VAR_0->have_section = false;", "} else {", "VAR_0->have_section = true;", "VAR_0->phdr_num = PN_XNUM;", "VAR_0->sh_info = 1;", "if (VAR_0->list.num <= UINT32_MAX - 1) {", "VAR_0->sh_info += VAR_0->list.num;", "} else {", "VAR_0->sh_info = UINT32_MAX;", "}", "}", "if (VAR_0->dump_info.d_class == ELFCLASS64) {", "if (VAR_0->have_section) {", "VAR_0->memory_offset = sizeof(Elf64_Ehdr) +\nsizeof(Elf64_Phdr) * VAR_0->sh_info +\nsizeof(Elf64_Shdr) + VAR_0->note_size;", "} else {", "VAR_0->memory_offset = sizeof(Elf64_Ehdr) +\nsizeof(Elf64_Phdr) * VAR_0->phdr_num + VAR_0->note_size;", "}", "} else {", "if (VAR_0->have_section) {", "VAR_0->memory_offset = sizeof(Elf32_Ehdr) +\nsizeof(Elf32_Phdr) * VAR_0->sh_info +\nsizeof(Elf32_Shdr) + VAR_0->note_size;", "} else {", "VAR_0->memory_offset = sizeof(Elf32_Ehdr) +\nsizeof(Elf32_Phdr) * VAR_0->phdr_num + VAR_0->note_size;", "}", "}", "return 0;", "cleanup:\nguest_phys_blocks_free(&VAR_0->guest_phys_blocks);", "if (VAR_0->resume) {", "vm_start();", "}", "return -1;", "}" ]
[ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 61 ], [ 63 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 99, 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 137 ], [ 139 ], [ 141 ], [ 145 ], [ 149 ], [ 151 ], [ 153 ], [ 157 ], [ 159 ], [ 161 ], [ 175 ], [ 177 ], [ 179 ], [ 181 ], [ 183 ], [ 185 ], [ 187 ], [ 189 ], [ 195 ], [ 197 ], [ 199 ], [ 201 ], [ 203 ], [ 205 ], [ 209 ], [ 211 ], [ 213, 215, 217 ], [ 219 ], [ 221, 223 ], [ 225 ], [ 227 ], [ 229 ], [ 231, 233, 235 ], [ 237 ], [ 239, 241 ], [ 243 ], [ 245 ], [ 249 ], [ 253, 255 ], [ 259 ], [ 261 ], [ 263 ], [ 267 ], [ 269 ] ]
22,229
static void crs_replace_with_free_ranges(GPtrArray *ranges, uint64_t start, uint64_t end) { GPtrArray *free_ranges = g_ptr_array_new_with_free_func(crs_range_free); uint64_t free_base = start; int i; g_ptr_array_sort(ranges, crs_range_compare); for (i = 0; i < ranges->len; i++) { CrsRangeEntry *used = g_ptr_array_index(ranges, i); if (free_base < used->base) { crs_range_insert(free_ranges, free_base, used->base - 1); } free_base = used->limit + 1; } if (free_base < end) { crs_range_insert(free_ranges, free_base, end); } g_ptr_array_set_size(ranges, 0); for (i = 0; i < free_ranges->len; i++) { g_ptr_array_add(ranges, g_ptr_array_index(free_ranges, i)); } g_ptr_array_free(free_ranges, false); }
true
qemu
354fb471bd5faf527f3fa25388b8cffa6bd937d0
static void crs_replace_with_free_ranges(GPtrArray *ranges, uint64_t start, uint64_t end) { GPtrArray *free_ranges = g_ptr_array_new_with_free_func(crs_range_free); uint64_t free_base = start; int i; g_ptr_array_sort(ranges, crs_range_compare); for (i = 0; i < ranges->len; i++) { CrsRangeEntry *used = g_ptr_array_index(ranges, i); if (free_base < used->base) { crs_range_insert(free_ranges, free_base, used->base - 1); } free_base = used->limit + 1; } if (free_base < end) { crs_range_insert(free_ranges, free_base, end); } g_ptr_array_set_size(ranges, 0); for (i = 0; i < free_ranges->len; i++) { g_ptr_array_add(ranges, g_ptr_array_index(free_ranges, i)); } g_ptr_array_free(free_ranges, false); }
{ "code": [ " GPtrArray *free_ranges = g_ptr_array_new_with_free_func(crs_range_free);", " g_ptr_array_free(free_ranges, false);" ], "line_no": [ 7, 55 ] }
static void FUNC_0(GPtrArray *VAR_0, uint64_t VAR_1, uint64_t VAR_2) { GPtrArray *free_ranges = g_ptr_array_new_with_free_func(crs_range_free); uint64_t free_base = VAR_1; int VAR_3; g_ptr_array_sort(VAR_0, crs_range_compare); for (VAR_3 = 0; VAR_3 < VAR_0->len; VAR_3++) { CrsRangeEntry *used = g_ptr_array_index(VAR_0, VAR_3); if (free_base < used->base) { crs_range_insert(free_ranges, free_base, used->base - 1); } free_base = used->limit + 1; } if (free_base < VAR_2) { crs_range_insert(free_ranges, free_base, VAR_2); } g_ptr_array_set_size(VAR_0, 0); for (VAR_3 = 0; VAR_3 < free_ranges->len; VAR_3++) { g_ptr_array_add(VAR_0, g_ptr_array_index(free_ranges, VAR_3)); } g_ptr_array_free(free_ranges, false); }
[ "static void FUNC_0(GPtrArray *VAR_0,\nuint64_t VAR_1, uint64_t VAR_2)\n{", "GPtrArray *free_ranges = g_ptr_array_new_with_free_func(crs_range_free);", "uint64_t free_base = VAR_1;", "int VAR_3;", "g_ptr_array_sort(VAR_0, crs_range_compare);", "for (VAR_3 = 0; VAR_3 < VAR_0->len; VAR_3++) {", "CrsRangeEntry *used = g_ptr_array_index(VAR_0, VAR_3);", "if (free_base < used->base) {", "crs_range_insert(free_ranges, free_base, used->base - 1);", "}", "free_base = used->limit + 1;", "}", "if (free_base < VAR_2) {", "crs_range_insert(free_ranges, free_base, VAR_2);", "}", "g_ptr_array_set_size(VAR_0, 0);", "for (VAR_3 = 0; VAR_3 < free_ranges->len; VAR_3++) {", "g_ptr_array_add(VAR_0, g_ptr_array_index(free_ranges, VAR_3));", "}", "g_ptr_array_free(free_ranges, false);", "}" ]
[ 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ], [ 27 ], [ 31 ], [ 33 ], [ 37 ], [ 39 ], [ 41 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 55 ], [ 57 ] ]
22,230
static ssize_t qio_channel_websock_decode_payload(QIOChannelWebsock *ioc, Error **errp) { size_t i; size_t payload_len; uint32_t *payload32; if (!ioc->payload_remain) { error_setg(errp, "Decoding payload but no bytes of payload remain"); return -1; } /* If we aren't at the end of the payload, then drop * off the last bytes, so we're always multiple of 4 * for purpose of unmasking, except at end of payload */ if (ioc->encinput.offset < ioc->payload_remain) { payload_len = ioc->encinput.offset - (ioc->encinput.offset % 4); } else { payload_len = ioc->payload_remain; } if (payload_len == 0) { return QIO_CHANNEL_ERR_BLOCK; } ioc->payload_remain -= payload_len; /* unmask frame */ /* process 1 frame (32 bit op) */ payload32 = (uint32_t *)ioc->encinput.buffer; for (i = 0; i < payload_len / 4; i++) { payload32[i] ^= ioc->mask.u; } /* process the remaining bytes (if any) */ for (i *= 4; i < payload_len; i++) { ioc->encinput.buffer[i] ^= ioc->mask.c[i % 4]; } buffer_reserve(&ioc->rawinput, payload_len); buffer_append(&ioc->rawinput, ioc->encinput.buffer, payload_len); buffer_advance(&ioc->encinput, payload_len); return payload_len; }
true
qemu
eefa3d8ef649f9055611361e2201cca49f8c3433
static ssize_t qio_channel_websock_decode_payload(QIOChannelWebsock *ioc, Error **errp) { size_t i; size_t payload_len; uint32_t *payload32; if (!ioc->payload_remain) { error_setg(errp, "Decoding payload but no bytes of payload remain"); return -1; } if (ioc->encinput.offset < ioc->payload_remain) { payload_len = ioc->encinput.offset - (ioc->encinput.offset % 4); } else { payload_len = ioc->payload_remain; } if (payload_len == 0) { return QIO_CHANNEL_ERR_BLOCK; } ioc->payload_remain -= payload_len; payload32 = (uint32_t *)ioc->encinput.buffer; for (i = 0; i < payload_len / 4; i++) { payload32[i] ^= ioc->mask.u; } for (i *= 4; i < payload_len; i++) { ioc->encinput.buffer[i] ^= ioc->mask.c[i % 4]; } buffer_reserve(&ioc->rawinput, payload_len); buffer_append(&ioc->rawinput, ioc->encinput.buffer, payload_len); buffer_advance(&ioc->encinput, payload_len); return payload_len; }
{ "code": [ "static ssize_t qio_channel_websock_decode_payload(QIOChannelWebsock *ioc,", " Error **errp)", " return payload_len;" ], "line_no": [ 1, 3, 85 ] }
static ssize_t FUNC_0(QIOChannelWebsock *ioc, Error **errp) { size_t i; size_t payload_len; uint32_t *payload32; if (!ioc->payload_remain) { error_setg(errp, "Decoding payload but no bytes of payload remain"); return -1; } if (ioc->encinput.offset < ioc->payload_remain) { payload_len = ioc->encinput.offset - (ioc->encinput.offset % 4); } else { payload_len = ioc->payload_remain; } if (payload_len == 0) { return QIO_CHANNEL_ERR_BLOCK; } ioc->payload_remain -= payload_len; payload32 = (uint32_t *)ioc->encinput.buffer; for (i = 0; i < payload_len / 4; i++) { payload32[i] ^= ioc->mask.u; } for (i *= 4; i < payload_len; i++) { ioc->encinput.buffer[i] ^= ioc->mask.c[i % 4]; } buffer_reserve(&ioc->rawinput, payload_len); buffer_append(&ioc->rawinput, ioc->encinput.buffer, payload_len); buffer_advance(&ioc->encinput, payload_len); return payload_len; }
[ "static ssize_t FUNC_0(QIOChannelWebsock *ioc,\nError **errp)\n{", "size_t i;", "size_t payload_len;", "uint32_t *payload32;", "if (!ioc->payload_remain) {", "error_setg(errp,\n\"Decoding payload but no bytes of payload remain\");", "return -1;", "}", "if (ioc->encinput.offset < ioc->payload_remain) {", "payload_len = ioc->encinput.offset - (ioc->encinput.offset % 4);", "} else {", "payload_len = ioc->payload_remain;", "}", "if (payload_len == 0) {", "return QIO_CHANNEL_ERR_BLOCK;", "}", "ioc->payload_remain -= payload_len;", "payload32 = (uint32_t *)ioc->encinput.buffer;", "for (i = 0; i < payload_len / 4; i++) {", "payload32[i] ^= ioc->mask.u;", "}", "for (i *= 4; i < payload_len; i++) {", "ioc->encinput.buffer[i] ^= ioc->mask.c[i % 4];", "}", "buffer_reserve(&ioc->rawinput, payload_len);", "buffer_append(&ioc->rawinput, ioc->encinput.buffer, payload_len);", "buffer_advance(&ioc->encinput, payload_len);", "return payload_len;", "}" ]
[ 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, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17, 19 ], [ 21 ], [ 23 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 53 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 71 ], [ 73 ], [ 75 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ] ]
22,231
static int load_sofa(AVFilterContext *ctx, char *filename, int *samplingrate) { struct SOFAlizerContext *s = ctx->priv; /* variables associated with content of SOFA file: */ int ncid, n_dims, n_vars, n_gatts, n_unlim_dim_id, status; char data_delay_dim_name[NC_MAX_NAME]; float *sp_a, *sp_e, *sp_r, *data_ir; char *sofa_conventions; char dim_name[NC_MAX_NAME]; /* names of netCDF dimensions */ size_t *dim_length; /* lengths of netCDF dimensions */ char *text; unsigned int sample_rate; int data_delay_dim_id[2]; int samplingrate_id; int data_delay_id; int n_samples; int m_dim_id = -1; int n_dim_id = -1; int data_ir_id; size_t att_len; int m_dim; int *data_delay; int sp_id; int i, ret; s->sofa.ncid = 0; status = nc_open(filename, NC_NOWRITE, &ncid); /* open SOFA file read-only */ if (status != NC_NOERR) { av_log(ctx, AV_LOG_ERROR, "Can't find SOFA-file '%s'\n", filename); return AVERROR(EINVAL); } /* get number of dimensions, vars, global attributes and Id of unlimited dimensions: */ nc_inq(ncid, &n_dims, &n_vars, &n_gatts, &n_unlim_dim_id); /* -- get number of measurements ("M") and length of one IR ("N") -- */ dim_length = av_malloc_array(n_dims, sizeof(*dim_length)); if (!dim_length) { nc_close(ncid); return AVERROR(ENOMEM); } for (i = 0; i < n_dims; i++) { /* go through all dimensions of file */ nc_inq_dim(ncid, i, (char *)&dim_name, &dim_length[i]); /* get dimensions */ if (!strncmp("M", (const char *)&dim_name, 1)) /* get ID of dimension "M" */ m_dim_id = i; if (!strncmp("N", (const char *)&dim_name, 1)) /* get ID of dimension "N" */ n_dim_id = i; } if ((m_dim_id == -1) || (n_dim_id == -1)) { /* dimension "M" or "N" couldn't be found */ av_log(ctx, AV_LOG_ERROR, "Can't find required dimensions in SOFA file.\n"); av_freep(&dim_length); nc_close(ncid); return AVERROR(EINVAL); } n_samples = dim_length[n_dim_id]; /* get length of one IR */ m_dim = dim_length[m_dim_id]; /* get number of measurements */ av_freep(&dim_length); /* -- check file type -- */ /* get length of attritube "Conventions" */ status = nc_inq_attlen(ncid, NC_GLOBAL, "Conventions", &att_len); if (status != NC_NOERR) { av_log(ctx, AV_LOG_ERROR, "Can't get length of attribute \"Conventions\".\n"); nc_close(ncid); return AVERROR_INVALIDDATA; } /* check whether file is SOFA file */ text = av_malloc(att_len + 1); if (!text) { nc_close(ncid); return AVERROR(ENOMEM); } nc_get_att_text(ncid, NC_GLOBAL, "Conventions", text); *(text + att_len) = 0; if (strncmp("SOFA", text, 4)) { av_log(ctx, AV_LOG_ERROR, "Not a SOFA file!\n"); av_freep(&text); nc_close(ncid); return AVERROR(EINVAL); } av_freep(&text); status = nc_inq_attlen(ncid, NC_GLOBAL, "License", &att_len); if (status == NC_NOERR) { text = av_malloc(att_len + 1); if (text) { nc_get_att_text(ncid, NC_GLOBAL, "License", text); *(text + att_len) = 0; av_log(ctx, AV_LOG_INFO, "SOFA file License: %s\n", text); av_freep(&text); } } status = nc_inq_attlen(ncid, NC_GLOBAL, "SourceDescription", &att_len); if (status == NC_NOERR) { text = av_malloc(att_len + 1); if (text) { nc_get_att_text(ncid, NC_GLOBAL, "SourceDescription", text); *(text + att_len) = 0; av_log(ctx, AV_LOG_INFO, "SOFA file SourceDescription: %s\n", text); av_freep(&text); } } status = nc_inq_attlen(ncid, NC_GLOBAL, "Comment", &att_len); if (status == NC_NOERR) { text = av_malloc(att_len + 1); if (text) { nc_get_att_text(ncid, NC_GLOBAL, "Comment", text); *(text + att_len) = 0; av_log(ctx, AV_LOG_INFO, "SOFA file Comment: %s\n", text); av_freep(&text); } } status = nc_inq_attlen(ncid, NC_GLOBAL, "SOFAConventions", &att_len); if (status != NC_NOERR) { av_log(ctx, AV_LOG_ERROR, "Can't get length of attribute \"SOFAConventions\".\n"); nc_close(ncid); return AVERROR_INVALIDDATA; } sofa_conventions = av_malloc(att_len + 1); if (!sofa_conventions) { nc_close(ncid); return AVERROR(ENOMEM); } nc_get_att_text(ncid, NC_GLOBAL, "SOFAConventions", sofa_conventions); *(sofa_conventions + att_len) = 0; if (strncmp("SimpleFreeFieldHRIR", sofa_conventions, att_len)) { av_log(ctx, AV_LOG_ERROR, "Not a SimpleFreeFieldHRIR file!\n"); av_freep(&sofa_conventions); nc_close(ncid); return AVERROR(EINVAL); } av_freep(&sofa_conventions); /* -- get sampling rate of HRTFs -- */ /* read ID, then value */ status = nc_inq_varid(ncid, "Data.SamplingRate", &samplingrate_id); status += nc_get_var_uint(ncid, samplingrate_id, &sample_rate); if (status != NC_NOERR) { av_log(ctx, AV_LOG_ERROR, "Couldn't read Data.SamplingRate.\n"); nc_close(ncid); return AVERROR(EINVAL); } *samplingrate = sample_rate; /* remember sampling rate */ /* -- allocate memory for one value for each measurement position: -- */ sp_a = s->sofa.sp_a = av_malloc_array(m_dim, sizeof(float)); sp_e = s->sofa.sp_e = av_malloc_array(m_dim, sizeof(float)); sp_r = s->sofa.sp_r = av_malloc_array(m_dim, sizeof(float)); /* delay and IR values required for each ear and measurement position: */ data_delay = s->sofa.data_delay = av_calloc(m_dim, 2 * sizeof(int)); data_ir = s->sofa.data_ir = av_malloc_array(m_dim * n_samples, sizeof(float) * 2); if (!data_delay || !sp_a || !sp_e || !sp_r || !data_ir) { /* if memory could not be allocated */ close_sofa(&s->sofa); return AVERROR(ENOMEM); } /* get impulse responses (HRTFs): */ /* get corresponding ID */ status = nc_inq_varid(ncid, "Data.IR", &data_ir_id); status += nc_get_var_float(ncid, data_ir_id, data_ir); /* read and store IRs */ if (status != NC_NOERR) { av_log(ctx, AV_LOG_ERROR, "Couldn't read Data.IR!\n"); ret = AVERROR(EINVAL); goto error; } /* get source positions of the HRTFs in the SOFA file: */ status = nc_inq_varid(ncid, "SourcePosition", &sp_id); /* get corresponding ID */ status += nc_get_vara_float(ncid, sp_id, (size_t[2]){ 0, 0 } , (size_t[2]){ m_dim, 1}, sp_a); /* read & store azimuth angles */ status += nc_get_vara_float(ncid, sp_id, (size_t[2]){ 0, 1 } , (size_t[2]){ m_dim, 1}, sp_e); /* read & store elevation angles */ status += nc_get_vara_float(ncid, sp_id, (size_t[2]){ 0, 2 } , (size_t[2]){ m_dim, 1}, sp_r); /* read & store radii */ if (status != NC_NOERR) { /* if any source position variable coudn't be read */ av_log(ctx, AV_LOG_ERROR, "Couldn't read SourcePosition.\n"); ret = AVERROR(EINVAL); goto error; } /* read Data.Delay, check for errors and fit it to data_delay */ status = nc_inq_varid(ncid, "Data.Delay", &data_delay_id); status += nc_inq_vardimid(ncid, data_delay_id, &data_delay_dim_id[0]); status += nc_inq_dimname(ncid, data_delay_dim_id[0], data_delay_dim_name); if (status != NC_NOERR) { av_log(ctx, AV_LOG_ERROR, "Couldn't read Data.Delay.\n"); ret = AVERROR(EINVAL); goto error; } /* Data.Delay dimension check */ /* dimension of Data.Delay is [I R]: */ if (!strncmp(data_delay_dim_name, "I", 2)) { /* check 2 characters to assure string is 0-terminated after "I" */ int delay[2]; /* delays get from SOFA file: */ av_log(ctx, AV_LOG_DEBUG, "Data.Delay has dimension [I R]\n"); status = nc_get_var_int(ncid, data_delay_id, &delay[0]); if (status != NC_NOERR) { av_log(ctx, AV_LOG_ERROR, "Couldn't read Data.Delay\n"); ret = AVERROR(EINVAL); goto error; } int *data_delay_r = data_delay + m_dim; for (i = 0; i < m_dim; i++) { /* extend given dimension [I R] to [M R] */ /* assign constant delay value for all measurements to data_delay fields */ data_delay[i] = delay[0]; data_delay_r[i] = delay[1]; } /* dimension of Data.Delay is [M R] */ } else if (!strncmp(data_delay_dim_name, "M", 2)) { av_log(ctx, AV_LOG_ERROR, "Data.Delay in dimension [M R]\n"); /* get delays from SOFA file: */ status = nc_get_var_int(ncid, data_delay_id, data_delay); if (status != NC_NOERR) { av_log(ctx, AV_LOG_ERROR, "Couldn't read Data.Delay\n"); ret = AVERROR(EINVAL); goto error; } } else { /* dimension of Data.Delay is neither [I R] nor [M R] */ av_log(ctx, AV_LOG_ERROR, "Data.Delay does not have the required dimensions [I R] or [M R].\n"); ret = AVERROR(EINVAL); goto error; } /* save information in SOFA struct: */ s->sofa.m_dim = m_dim; /* no. measurement positions */ s->sofa.n_samples = n_samples; /* length on one IR */ s->sofa.ncid = ncid; /* netCDF ID of SOFA file */ nc_close(ncid); /* close SOFA file */ return 0; error: close_sofa(&s->sofa); return ret; }
true
FFmpeg
21234c835d2d003d390d462b6e1b2622e7b02c39
static int load_sofa(AVFilterContext *ctx, char *filename, int *samplingrate) { struct SOFAlizerContext *s = ctx->priv; int ncid, n_dims, n_vars, n_gatts, n_unlim_dim_id, status; char data_delay_dim_name[NC_MAX_NAME]; float *sp_a, *sp_e, *sp_r, *data_ir; char *sofa_conventions; char dim_name[NC_MAX_NAME]; size_t *dim_length; char *text; unsigned int sample_rate; int data_delay_dim_id[2]; int samplingrate_id; int data_delay_id; int n_samples; int m_dim_id = -1; int n_dim_id = -1; int data_ir_id; size_t att_len; int m_dim; int *data_delay; int sp_id; int i, ret; s->sofa.ncid = 0; status = nc_open(filename, NC_NOWRITE, &ncid); if (status != NC_NOERR) { av_log(ctx, AV_LOG_ERROR, "Can't find SOFA-file '%s'\n", filename); return AVERROR(EINVAL); } nc_inq(ncid, &n_dims, &n_vars, &n_gatts, &n_unlim_dim_id); dim_length = av_malloc_array(n_dims, sizeof(*dim_length)); if (!dim_length) { nc_close(ncid); return AVERROR(ENOMEM); } for (i = 0; i < n_dims; i++) { nc_inq_dim(ncid, i, (char *)&dim_name, &dim_length[i]); if (!strncmp("M", (const char *)&dim_name, 1)) m_dim_id = i; if (!strncmp("N", (const char *)&dim_name, 1)) n_dim_id = i; } if ((m_dim_id == -1) || (n_dim_id == -1)) { av_log(ctx, AV_LOG_ERROR, "Can't find required dimensions in SOFA file.\n"); av_freep(&dim_length); nc_close(ncid); return AVERROR(EINVAL); } n_samples = dim_length[n_dim_id]; m_dim = dim_length[m_dim_id]; av_freep(&dim_length); status = nc_inq_attlen(ncid, NC_GLOBAL, "Conventions", &att_len); if (status != NC_NOERR) { av_log(ctx, AV_LOG_ERROR, "Can't get length of attribute \"Conventions\".\n"); nc_close(ncid); return AVERROR_INVALIDDATA; } text = av_malloc(att_len + 1); if (!text) { nc_close(ncid); return AVERROR(ENOMEM); } nc_get_att_text(ncid, NC_GLOBAL, "Conventions", text); *(text + att_len) = 0; if (strncmp("SOFA", text, 4)) { av_log(ctx, AV_LOG_ERROR, "Not a SOFA file!\n"); av_freep(&text); nc_close(ncid); return AVERROR(EINVAL); } av_freep(&text); status = nc_inq_attlen(ncid, NC_GLOBAL, "License", &att_len); if (status == NC_NOERR) { text = av_malloc(att_len + 1); if (text) { nc_get_att_text(ncid, NC_GLOBAL, "License", text); *(text + att_len) = 0; av_log(ctx, AV_LOG_INFO, "SOFA file License: %s\n", text); av_freep(&text); } } status = nc_inq_attlen(ncid, NC_GLOBAL, "SourceDescription", &att_len); if (status == NC_NOERR) { text = av_malloc(att_len + 1); if (text) { nc_get_att_text(ncid, NC_GLOBAL, "SourceDescription", text); *(text + att_len) = 0; av_log(ctx, AV_LOG_INFO, "SOFA file SourceDescription: %s\n", text); av_freep(&text); } } status = nc_inq_attlen(ncid, NC_GLOBAL, "Comment", &att_len); if (status == NC_NOERR) { text = av_malloc(att_len + 1); if (text) { nc_get_att_text(ncid, NC_GLOBAL, "Comment", text); *(text + att_len) = 0; av_log(ctx, AV_LOG_INFO, "SOFA file Comment: %s\n", text); av_freep(&text); } } status = nc_inq_attlen(ncid, NC_GLOBAL, "SOFAConventions", &att_len); if (status != NC_NOERR) { av_log(ctx, AV_LOG_ERROR, "Can't get length of attribute \"SOFAConventions\".\n"); nc_close(ncid); return AVERROR_INVALIDDATA; } sofa_conventions = av_malloc(att_len + 1); if (!sofa_conventions) { nc_close(ncid); return AVERROR(ENOMEM); } nc_get_att_text(ncid, NC_GLOBAL, "SOFAConventions", sofa_conventions); *(sofa_conventions + att_len) = 0; if (strncmp("SimpleFreeFieldHRIR", sofa_conventions, att_len)) { av_log(ctx, AV_LOG_ERROR, "Not a SimpleFreeFieldHRIR file!\n"); av_freep(&sofa_conventions); nc_close(ncid); return AVERROR(EINVAL); } av_freep(&sofa_conventions); status = nc_inq_varid(ncid, "Data.SamplingRate", &samplingrate_id); status += nc_get_var_uint(ncid, samplingrate_id, &sample_rate); if (status != NC_NOERR) { av_log(ctx, AV_LOG_ERROR, "Couldn't read Data.SamplingRate.\n"); nc_close(ncid); return AVERROR(EINVAL); } *samplingrate = sample_rate; sp_a = s->sofa.sp_a = av_malloc_array(m_dim, sizeof(float)); sp_e = s->sofa.sp_e = av_malloc_array(m_dim, sizeof(float)); sp_r = s->sofa.sp_r = av_malloc_array(m_dim, sizeof(float)); data_delay = s->sofa.data_delay = av_calloc(m_dim, 2 * sizeof(int)); data_ir = s->sofa.data_ir = av_malloc_array(m_dim * n_samples, sizeof(float) * 2); if (!data_delay || !sp_a || !sp_e || !sp_r || !data_ir) { close_sofa(&s->sofa); return AVERROR(ENOMEM); } status = nc_inq_varid(ncid, "Data.IR", &data_ir_id); status += nc_get_var_float(ncid, data_ir_id, data_ir); if (status != NC_NOERR) { av_log(ctx, AV_LOG_ERROR, "Couldn't read Data.IR!\n"); ret = AVERROR(EINVAL); goto error; } status = nc_inq_varid(ncid, "SourcePosition", &sp_id); status += nc_get_vara_float(ncid, sp_id, (size_t[2]){ 0, 0 } , (size_t[2]){ m_dim, 1}, sp_a); status += nc_get_vara_float(ncid, sp_id, (size_t[2]){ 0, 1 } , (size_t[2]){ m_dim, 1}, sp_e); status += nc_get_vara_float(ncid, sp_id, (size_t[2]){ 0, 2 } , (size_t[2]){ m_dim, 1}, sp_r); if (status != NC_NOERR) { av_log(ctx, AV_LOG_ERROR, "Couldn't read SourcePosition.\n"); ret = AVERROR(EINVAL); goto error; } status = nc_inq_varid(ncid, "Data.Delay", &data_delay_id); status += nc_inq_vardimid(ncid, data_delay_id, &data_delay_dim_id[0]); status += nc_inq_dimname(ncid, data_delay_dim_id[0], data_delay_dim_name); if (status != NC_NOERR) { av_log(ctx, AV_LOG_ERROR, "Couldn't read Data.Delay.\n"); ret = AVERROR(EINVAL); goto error; } if (!strncmp(data_delay_dim_name, "I", 2)) { int delay[2]; av_log(ctx, AV_LOG_DEBUG, "Data.Delay has dimension [I R]\n"); status = nc_get_var_int(ncid, data_delay_id, &delay[0]); if (status != NC_NOERR) { av_log(ctx, AV_LOG_ERROR, "Couldn't read Data.Delay\n"); ret = AVERROR(EINVAL); goto error; } int *data_delay_r = data_delay + m_dim; for (i = 0; i < m_dim; i++) { data_delay[i] = delay[0]; data_delay_r[i] = delay[1]; } } else if (!strncmp(data_delay_dim_name, "M", 2)) { av_log(ctx, AV_LOG_ERROR, "Data.Delay in dimension [M R]\n"); status = nc_get_var_int(ncid, data_delay_id, data_delay); if (status != NC_NOERR) { av_log(ctx, AV_LOG_ERROR, "Couldn't read Data.Delay\n"); ret = AVERROR(EINVAL); goto error; } } else { av_log(ctx, AV_LOG_ERROR, "Data.Delay does not have the required dimensions [I R] or [M R].\n"); ret = AVERROR(EINVAL); goto error; } s->sofa.m_dim = m_dim; s->sofa.n_samples = n_samples; s->sofa.ncid = ncid; nc_close(ncid); return 0; error: close_sofa(&s->sofa); return ret; }
{ "code": [ " data_ir = s->sofa.data_ir = av_malloc_array(m_dim * n_samples, sizeof(float) * 2);" ], "line_no": [ 323 ] }
static int FUNC_0(AVFilterContext *VAR_0, char *VAR_1, int *VAR_2) { struct SOFAlizerContext *VAR_3 = VAR_0->priv; int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9; char VAR_10[NC_MAX_NAME]; float *VAR_11, *VAR_12, *VAR_13, *VAR_14; char *VAR_15; char VAR_16[NC_MAX_NAME]; size_t *dim_length; char *VAR_17; unsigned int VAR_18; int VAR_19[2]; int VAR_20; int VAR_21; int VAR_22; int VAR_23 = -1; int VAR_24 = -1; int VAR_25; size_t att_len; int VAR_26; int *VAR_27; int VAR_28; int VAR_29, VAR_30; VAR_3->sofa.VAR_4 = 0; VAR_9 = nc_open(VAR_1, NC_NOWRITE, &VAR_4); if (VAR_9 != NC_NOERR) { av_log(VAR_0, AV_LOG_ERROR, "Can't find SOFA-file '%VAR_3'\n", VAR_1); return AVERROR(EINVAL); } nc_inq(VAR_4, &VAR_5, &VAR_6, &VAR_7, &VAR_8); dim_length = av_malloc_array(VAR_5, sizeof(*dim_length)); if (!dim_length) { nc_close(VAR_4); return AVERROR(ENOMEM); } for (VAR_29 = 0; VAR_29 < VAR_5; VAR_29++) { nc_inq_dim(VAR_4, VAR_29, (char *)&VAR_16, &dim_length[VAR_29]); if (!strncmp("M", (const char *)&VAR_16, 1)) VAR_23 = VAR_29; if (!strncmp("N", (const char *)&VAR_16, 1)) VAR_24 = VAR_29; } if ((VAR_23 == -1) || (VAR_24 == -1)) { av_log(VAR_0, AV_LOG_ERROR, "Can't find required dimensions in SOFA file.\n"); av_freep(&dim_length); nc_close(VAR_4); return AVERROR(EINVAL); } VAR_22 = dim_length[VAR_24]; VAR_26 = dim_length[VAR_23]; av_freep(&dim_length); VAR_9 = nc_inq_attlen(VAR_4, NC_GLOBAL, "Conventions", &att_len); if (VAR_9 != NC_NOERR) { av_log(VAR_0, AV_LOG_ERROR, "Can't get length of attribute \"Conventions\".\n"); nc_close(VAR_4); return AVERROR_INVALIDDATA; } VAR_17 = av_malloc(att_len + 1); if (!VAR_17) { nc_close(VAR_4); return AVERROR(ENOMEM); } nc_get_att_text(VAR_4, NC_GLOBAL, "Conventions", VAR_17); *(VAR_17 + att_len) = 0; if (strncmp("SOFA", VAR_17, 4)) { av_log(VAR_0, AV_LOG_ERROR, "Not a SOFA file!\n"); av_freep(&VAR_17); nc_close(VAR_4); return AVERROR(EINVAL); } av_freep(&VAR_17); VAR_9 = nc_inq_attlen(VAR_4, NC_GLOBAL, "License", &att_len); if (VAR_9 == NC_NOERR) { VAR_17 = av_malloc(att_len + 1); if (VAR_17) { nc_get_att_text(VAR_4, NC_GLOBAL, "License", VAR_17); *(VAR_17 + att_len) = 0; av_log(VAR_0, AV_LOG_INFO, "SOFA file License: %VAR_3\n", VAR_17); av_freep(&VAR_17); } } VAR_9 = nc_inq_attlen(VAR_4, NC_GLOBAL, "SourceDescription", &att_len); if (VAR_9 == NC_NOERR) { VAR_17 = av_malloc(att_len + 1); if (VAR_17) { nc_get_att_text(VAR_4, NC_GLOBAL, "SourceDescription", VAR_17); *(VAR_17 + att_len) = 0; av_log(VAR_0, AV_LOG_INFO, "SOFA file SourceDescription: %VAR_3\n", VAR_17); av_freep(&VAR_17); } } VAR_9 = nc_inq_attlen(VAR_4, NC_GLOBAL, "Comment", &att_len); if (VAR_9 == NC_NOERR) { VAR_17 = av_malloc(att_len + 1); if (VAR_17) { nc_get_att_text(VAR_4, NC_GLOBAL, "Comment", VAR_17); *(VAR_17 + att_len) = 0; av_log(VAR_0, AV_LOG_INFO, "SOFA file Comment: %VAR_3\n", VAR_17); av_freep(&VAR_17); } } VAR_9 = nc_inq_attlen(VAR_4, NC_GLOBAL, "SOFAConventions", &att_len); if (VAR_9 != NC_NOERR) { av_log(VAR_0, AV_LOG_ERROR, "Can't get length of attribute \"SOFAConventions\".\n"); nc_close(VAR_4); return AVERROR_INVALIDDATA; } VAR_15 = av_malloc(att_len + 1); if (!VAR_15) { nc_close(VAR_4); return AVERROR(ENOMEM); } nc_get_att_text(VAR_4, NC_GLOBAL, "SOFAConventions", VAR_15); *(VAR_15 + att_len) = 0; if (strncmp("SimpleFreeFieldHRIR", VAR_15, att_len)) { av_log(VAR_0, AV_LOG_ERROR, "Not a SimpleFreeFieldHRIR file!\n"); av_freep(&VAR_15); nc_close(VAR_4); return AVERROR(EINVAL); } av_freep(&VAR_15); VAR_9 = nc_inq_varid(VAR_4, "Data.SamplingRate", &VAR_20); VAR_9 += nc_get_var_uint(VAR_4, VAR_20, &VAR_18); if (VAR_9 != NC_NOERR) { av_log(VAR_0, AV_LOG_ERROR, "Couldn't read Data.SamplingRate.\n"); nc_close(VAR_4); return AVERROR(EINVAL); } *VAR_2 = VAR_18; VAR_11 = VAR_3->sofa.VAR_11 = av_malloc_array(VAR_26, sizeof(float)); VAR_12 = VAR_3->sofa.VAR_12 = av_malloc_array(VAR_26, sizeof(float)); VAR_13 = VAR_3->sofa.VAR_13 = av_malloc_array(VAR_26, sizeof(float)); VAR_27 = VAR_3->sofa.VAR_27 = av_calloc(VAR_26, 2 * sizeof(int)); VAR_14 = VAR_3->sofa.VAR_14 = av_malloc_array(VAR_26 * VAR_22, sizeof(float) * 2); if (!VAR_27 || !VAR_11 || !VAR_12 || !VAR_13 || !VAR_14) { close_sofa(&VAR_3->sofa); return AVERROR(ENOMEM); } VAR_9 = nc_inq_varid(VAR_4, "Data.IR", &VAR_25); VAR_9 += nc_get_var_float(VAR_4, VAR_25, VAR_14); if (VAR_9 != NC_NOERR) { av_log(VAR_0, AV_LOG_ERROR, "Couldn't read Data.IR!\n"); VAR_30 = AVERROR(EINVAL); goto error; } VAR_9 = nc_inq_varid(VAR_4, "SourcePosition", &VAR_28); VAR_9 += nc_get_vara_float(VAR_4, VAR_28, (size_t[2]){ 0, 0 } , (size_t[2]){ VAR_26, 1}, VAR_11); VAR_9 += nc_get_vara_float(VAR_4, VAR_28, (size_t[2]){ 0, 1 } , (size_t[2]){ VAR_26, 1}, VAR_12); VAR_9 += nc_get_vara_float(VAR_4, VAR_28, (size_t[2]){ 0, 2 } , (size_t[2]){ VAR_26, 1}, VAR_13); if (VAR_9 != NC_NOERR) { av_log(VAR_0, AV_LOG_ERROR, "Couldn't read SourcePosition.\n"); VAR_30 = AVERROR(EINVAL); goto error; } VAR_9 = nc_inq_varid(VAR_4, "Data.Delay", &VAR_21); VAR_9 += nc_inq_vardimid(VAR_4, VAR_21, &VAR_19[0]); VAR_9 += nc_inq_dimname(VAR_4, VAR_19[0], VAR_10); if (VAR_9 != NC_NOERR) { av_log(VAR_0, AV_LOG_ERROR, "Couldn't read Data.Delay.\n"); VAR_30 = AVERROR(EINVAL); goto error; } if (!strncmp(VAR_10, "I", 2)) { int VAR_31[2]; av_log(VAR_0, AV_LOG_DEBUG, "Data.Delay has dimension [I R]\n"); VAR_9 = nc_get_var_int(VAR_4, VAR_21, &VAR_31[0]); if (VAR_9 != NC_NOERR) { av_log(VAR_0, AV_LOG_ERROR, "Couldn't read Data.Delay\n"); VAR_30 = AVERROR(EINVAL); goto error; } int *VAR_32 = VAR_27 + VAR_26; for (VAR_29 = 0; VAR_29 < VAR_26; VAR_29++) { VAR_27[VAR_29] = VAR_31[0]; VAR_32[VAR_29] = VAR_31[1]; } } else if (!strncmp(VAR_10, "M", 2)) { av_log(VAR_0, AV_LOG_ERROR, "Data.Delay in dimension [M R]\n"); VAR_9 = nc_get_var_int(VAR_4, VAR_21, VAR_27); if (VAR_9 != NC_NOERR) { av_log(VAR_0, AV_LOG_ERROR, "Couldn't read Data.Delay\n"); VAR_30 = AVERROR(EINVAL); goto error; } } else { av_log(VAR_0, AV_LOG_ERROR, "Data.Delay does not have the required dimensions [I R] or [M R].\n"); VAR_30 = AVERROR(EINVAL); goto error; } VAR_3->sofa.VAR_26 = VAR_26; VAR_3->sofa.VAR_22 = VAR_22; VAR_3->sofa.VAR_4 = VAR_4; nc_close(VAR_4); return 0; error: close_sofa(&VAR_3->sofa); return VAR_30; }
[ "static int FUNC_0(AVFilterContext *VAR_0, char *VAR_1, int *VAR_2)\n{", "struct SOFAlizerContext *VAR_3 = VAR_0->priv;", "int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9;", "char VAR_10[NC_MAX_NAME];", "float *VAR_11, *VAR_12, *VAR_13, *VAR_14;", "char *VAR_15;", "char VAR_16[NC_MAX_NAME];", "size_t *dim_length;", "char *VAR_17;", "unsigned int VAR_18;", "int VAR_19[2];", "int VAR_20;", "int VAR_21;", "int VAR_22;", "int VAR_23 = -1;", "int VAR_24 = -1;", "int VAR_25;", "size_t att_len;", "int VAR_26;", "int *VAR_27;", "int VAR_28;", "int VAR_29, VAR_30;", "VAR_3->sofa.VAR_4 = 0;", "VAR_9 = nc_open(VAR_1, NC_NOWRITE, &VAR_4);", "if (VAR_9 != NC_NOERR) {", "av_log(VAR_0, AV_LOG_ERROR, \"Can't find SOFA-file '%VAR_3'\\n\", VAR_1);", "return AVERROR(EINVAL);", "}", "nc_inq(VAR_4, &VAR_5, &VAR_6, &VAR_7, &VAR_8);", "dim_length = av_malloc_array(VAR_5, sizeof(*dim_length));", "if (!dim_length) {", "nc_close(VAR_4);", "return AVERROR(ENOMEM);", "}", "for (VAR_29 = 0; VAR_29 < VAR_5; VAR_29++) {", "nc_inq_dim(VAR_4, VAR_29, (char *)&VAR_16, &dim_length[VAR_29]);", "if (!strncmp(\"M\", (const char *)&VAR_16, 1))\nVAR_23 = VAR_29;", "if (!strncmp(\"N\", (const char *)&VAR_16, 1))\nVAR_24 = VAR_29;", "}", "if ((VAR_23 == -1) || (VAR_24 == -1)) {", "av_log(VAR_0, AV_LOG_ERROR, \"Can't find required dimensions in SOFA file.\\n\");", "av_freep(&dim_length);", "nc_close(VAR_4);", "return AVERROR(EINVAL);", "}", "VAR_22 = dim_length[VAR_24];", "VAR_26 = dim_length[VAR_23];", "av_freep(&dim_length);", "VAR_9 = nc_inq_attlen(VAR_4, NC_GLOBAL, \"Conventions\", &att_len);", "if (VAR_9 != NC_NOERR) {", "av_log(VAR_0, AV_LOG_ERROR, \"Can't get length of attribute \\\"Conventions\\\".\\n\");", "nc_close(VAR_4);", "return AVERROR_INVALIDDATA;", "}", "VAR_17 = av_malloc(att_len + 1);", "if (!VAR_17) {", "nc_close(VAR_4);", "return AVERROR(ENOMEM);", "}", "nc_get_att_text(VAR_4, NC_GLOBAL, \"Conventions\", VAR_17);", "*(VAR_17 + att_len) = 0;", "if (strncmp(\"SOFA\", VAR_17, 4)) {", "av_log(VAR_0, AV_LOG_ERROR, \"Not a SOFA file!\\n\");", "av_freep(&VAR_17);", "nc_close(VAR_4);", "return AVERROR(EINVAL);", "}", "av_freep(&VAR_17);", "VAR_9 = nc_inq_attlen(VAR_4, NC_GLOBAL, \"License\", &att_len);", "if (VAR_9 == NC_NOERR) {", "VAR_17 = av_malloc(att_len + 1);", "if (VAR_17) {", "nc_get_att_text(VAR_4, NC_GLOBAL, \"License\", VAR_17);", "*(VAR_17 + att_len) = 0;", "av_log(VAR_0, AV_LOG_INFO, \"SOFA file License: %VAR_3\\n\", VAR_17);", "av_freep(&VAR_17);", "}", "}", "VAR_9 = nc_inq_attlen(VAR_4, NC_GLOBAL, \"SourceDescription\", &att_len);", "if (VAR_9 == NC_NOERR) {", "VAR_17 = av_malloc(att_len + 1);", "if (VAR_17) {", "nc_get_att_text(VAR_4, NC_GLOBAL, \"SourceDescription\", VAR_17);", "*(VAR_17 + att_len) = 0;", "av_log(VAR_0, AV_LOG_INFO, \"SOFA file SourceDescription: %VAR_3\\n\", VAR_17);", "av_freep(&VAR_17);", "}", "}", "VAR_9 = nc_inq_attlen(VAR_4, NC_GLOBAL, \"Comment\", &att_len);", "if (VAR_9 == NC_NOERR) {", "VAR_17 = av_malloc(att_len + 1);", "if (VAR_17) {", "nc_get_att_text(VAR_4, NC_GLOBAL, \"Comment\", VAR_17);", "*(VAR_17 + att_len) = 0;", "av_log(VAR_0, AV_LOG_INFO, \"SOFA file Comment: %VAR_3\\n\", VAR_17);", "av_freep(&VAR_17);", "}", "}", "VAR_9 = nc_inq_attlen(VAR_4, NC_GLOBAL, \"SOFAConventions\", &att_len);", "if (VAR_9 != NC_NOERR) {", "av_log(VAR_0, AV_LOG_ERROR, \"Can't get length of attribute \\\"SOFAConventions\\\".\\n\");", "nc_close(VAR_4);", "return AVERROR_INVALIDDATA;", "}", "VAR_15 = av_malloc(att_len + 1);", "if (!VAR_15) {", "nc_close(VAR_4);", "return AVERROR(ENOMEM);", "}", "nc_get_att_text(VAR_4, NC_GLOBAL, \"SOFAConventions\", VAR_15);", "*(VAR_15 + att_len) = 0;", "if (strncmp(\"SimpleFreeFieldHRIR\", VAR_15, att_len)) {", "av_log(VAR_0, AV_LOG_ERROR, \"Not a SimpleFreeFieldHRIR file!\\n\");", "av_freep(&VAR_15);", "nc_close(VAR_4);", "return AVERROR(EINVAL);", "}", "av_freep(&VAR_15);", "VAR_9 = nc_inq_varid(VAR_4, \"Data.SamplingRate\", &VAR_20);", "VAR_9 += nc_get_var_uint(VAR_4, VAR_20, &VAR_18);", "if (VAR_9 != NC_NOERR) {", "av_log(VAR_0, AV_LOG_ERROR, \"Couldn't read Data.SamplingRate.\\n\");", "nc_close(VAR_4);", "return AVERROR(EINVAL);", "}", "*VAR_2 = VAR_18;", "VAR_11 = VAR_3->sofa.VAR_11 = av_malloc_array(VAR_26, sizeof(float));", "VAR_12 = VAR_3->sofa.VAR_12 = av_malloc_array(VAR_26, sizeof(float));", "VAR_13 = VAR_3->sofa.VAR_13 = av_malloc_array(VAR_26, sizeof(float));", "VAR_27 = VAR_3->sofa.VAR_27 = av_calloc(VAR_26, 2 * sizeof(int));", "VAR_14 = VAR_3->sofa.VAR_14 = av_malloc_array(VAR_26 * VAR_22, sizeof(float) * 2);", "if (!VAR_27 || !VAR_11 || !VAR_12 || !VAR_13 || !VAR_14) {", "close_sofa(&VAR_3->sofa);", "return AVERROR(ENOMEM);", "}", "VAR_9 = nc_inq_varid(VAR_4, \"Data.IR\", &VAR_25);", "VAR_9 += nc_get_var_float(VAR_4, VAR_25, VAR_14);", "if (VAR_9 != NC_NOERR) {", "av_log(VAR_0, AV_LOG_ERROR, \"Couldn't read Data.IR!\\n\");", "VAR_30 = AVERROR(EINVAL);", "goto error;", "}", "VAR_9 = nc_inq_varid(VAR_4, \"SourcePosition\", &VAR_28);", "VAR_9 += nc_get_vara_float(VAR_4, VAR_28, (size_t[2]){ 0, 0 } ,", "(size_t[2]){ VAR_26, 1}, VAR_11);", "VAR_9 += nc_get_vara_float(VAR_4, VAR_28, (size_t[2]){ 0, 1 } ,", "(size_t[2]){ VAR_26, 1}, VAR_12);", "VAR_9 += nc_get_vara_float(VAR_4, VAR_28, (size_t[2]){ 0, 2 } ,", "(size_t[2]){ VAR_26, 1}, VAR_13);", "if (VAR_9 != NC_NOERR) {", "av_log(VAR_0, AV_LOG_ERROR, \"Couldn't read SourcePosition.\\n\");", "VAR_30 = AVERROR(EINVAL);", "goto error;", "}", "VAR_9 = nc_inq_varid(VAR_4, \"Data.Delay\", &VAR_21);", "VAR_9 += nc_inq_vardimid(VAR_4, VAR_21, &VAR_19[0]);", "VAR_9 += nc_inq_dimname(VAR_4, VAR_19[0], VAR_10);", "if (VAR_9 != NC_NOERR) {", "av_log(VAR_0, AV_LOG_ERROR, \"Couldn't read Data.Delay.\\n\");", "VAR_30 = AVERROR(EINVAL);", "goto error;", "}", "if (!strncmp(VAR_10, \"I\", 2)) {", "int VAR_31[2];", "av_log(VAR_0, AV_LOG_DEBUG, \"Data.Delay has dimension [I R]\\n\");", "VAR_9 = nc_get_var_int(VAR_4, VAR_21, &VAR_31[0]);", "if (VAR_9 != NC_NOERR) {", "av_log(VAR_0, AV_LOG_ERROR, \"Couldn't read Data.Delay\\n\");", "VAR_30 = AVERROR(EINVAL);", "goto error;", "}", "int *VAR_32 = VAR_27 + VAR_26;", "for (VAR_29 = 0; VAR_29 < VAR_26; VAR_29++) {", "VAR_27[VAR_29] = VAR_31[0];", "VAR_32[VAR_29] = VAR_31[1];", "}", "} else if (!strncmp(VAR_10, \"M\", 2)) {", "av_log(VAR_0, AV_LOG_ERROR, \"Data.Delay in dimension [M R]\\n\");", "VAR_9 = nc_get_var_int(VAR_4, VAR_21, VAR_27);", "if (VAR_9 != NC_NOERR) {", "av_log(VAR_0, AV_LOG_ERROR, \"Couldn't read Data.Delay\\n\");", "VAR_30 = AVERROR(EINVAL);", "goto error;", "}", "} else {", "av_log(VAR_0, AV_LOG_ERROR, \"Data.Delay does not have the required dimensions [I R] or [M R].\\n\");", "VAR_30 = AVERROR(EINVAL);", "goto error;", "}", "VAR_3->sofa.VAR_26 = VAR_26;", "VAR_3->sofa.VAR_22 = VAR_22;", "VAR_3->sofa.VAR_4 = VAR_4;", "nc_close(VAR_4);", "return 0;", "error:\nclose_sofa(&VAR_3->sofa);", "return VAR_30;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 67 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 85 ], [ 87 ], [ 89, 91 ], [ 93, 95 ], [ 97 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 115 ], [ 117 ], [ 121 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 153 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 177 ], [ 179 ], [ 181 ], [ 183 ], [ 185 ], [ 187 ], [ 189 ], [ 191 ], [ 193 ], [ 195 ], [ 199 ], [ 201 ], [ 203 ], [ 205 ], [ 207 ], [ 209 ], [ 211 ], [ 213 ], [ 215 ], [ 217 ], [ 221 ], [ 223 ], [ 225 ], [ 227 ], [ 229 ], [ 231 ], [ 233 ], [ 235 ], [ 237 ], [ 239 ], [ 243 ], [ 245 ], [ 247 ], [ 249 ], [ 251 ], [ 253 ], [ 257 ], [ 259 ], [ 261 ], [ 263 ], [ 265 ], [ 269 ], [ 271 ], [ 273 ], [ 275 ], [ 277 ], [ 279 ], [ 281 ], [ 283 ], [ 285 ], [ 293 ], [ 295 ], [ 297 ], [ 299 ], [ 301 ], [ 303 ], [ 305 ], [ 307 ], [ 313 ], [ 315 ], [ 317 ], [ 321 ], [ 323 ], [ 327 ], [ 331 ], [ 333 ], [ 335 ], [ 343 ], [ 345 ], [ 347 ], [ 349 ], [ 351 ], [ 353 ], [ 355 ], [ 361 ], [ 363 ], [ 365 ], [ 367 ], [ 369 ], [ 371 ], [ 373 ], [ 375 ], [ 377 ], [ 379 ], [ 381 ], [ 383 ], [ 389 ], [ 391 ], [ 393 ], [ 395 ], [ 397 ], [ 399 ], [ 401 ], [ 403 ], [ 411 ], [ 415 ], [ 419 ], [ 421 ], [ 423 ], [ 425 ], [ 427 ], [ 429 ], [ 431 ], [ 433 ], [ 435 ], [ 439 ], [ 441 ], [ 443 ], [ 447 ], [ 449 ], [ 453 ], [ 455 ], [ 457 ], [ 459 ], [ 461 ], [ 463 ], [ 465 ], [ 467 ], [ 469 ], [ 471 ], [ 473 ], [ 479 ], [ 481 ], [ 483 ], [ 485 ], [ 489 ], [ 493, 495 ], [ 497 ], [ 499 ] ]
22,232
static void create_flash(const VirtBoardInfo *vbi) { /* Create two flash devices to fill the VIRT_FLASH space in the memmap. * Any file passed via -bios goes in the first of these. */ hwaddr flashsize = vbi->memmap[VIRT_FLASH].size / 2; hwaddr flashbase = vbi->memmap[VIRT_FLASH].base; char *nodename; if (bios_name) { char *fn; int image_size; if (drive_get(IF_PFLASH, 0, 0)) { error_report("The contents of the first flash device may be " "specified with -bios or with -drive if=pflash... " "but you cannot use both options at once"); exit(1); } fn = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); if (!fn) { error_report("Could not find ROM image '%s'", bios_name); exit(1); } image_size = load_image_targphys(fn, flashbase, flashsize); g_free(fn); if (image_size < 0) { error_report("Could not load ROM image '%s'", bios_name); exit(1); } g_free(fn); } create_one_flash("virt.flash0", flashbase, flashsize); create_one_flash("virt.flash1", flashbase + flashsize, flashsize); nodename = g_strdup_printf("/flash@%" PRIx64, flashbase); qemu_fdt_add_subnode(vbi->fdt, nodename); qemu_fdt_setprop_string(vbi->fdt, nodename, "compatible", "cfi-flash"); qemu_fdt_setprop_sized_cells(vbi->fdt, nodename, "reg", 2, flashbase, 2, flashsize, 2, flashbase + flashsize, 2, flashsize); qemu_fdt_setprop_cell(vbi->fdt, nodename, "bank-width", 4); g_free(nodename); }
true
qemu
c408d27a42318227092128b04cca555f78cf703d
static void create_flash(const VirtBoardInfo *vbi) { hwaddr flashsize = vbi->memmap[VIRT_FLASH].size / 2; hwaddr flashbase = vbi->memmap[VIRT_FLASH].base; char *nodename; if (bios_name) { char *fn; int image_size; if (drive_get(IF_PFLASH, 0, 0)) { error_report("The contents of the first flash device may be " "specified with -bios or with -drive if=pflash... " "but you cannot use both options at once"); exit(1); } fn = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); if (!fn) { error_report("Could not find ROM image '%s'", bios_name); exit(1); } image_size = load_image_targphys(fn, flashbase, flashsize); g_free(fn); if (image_size < 0) { error_report("Could not load ROM image '%s'", bios_name); exit(1); } g_free(fn); } create_one_flash("virt.flash0", flashbase, flashsize); create_one_flash("virt.flash1", flashbase + flashsize, flashsize); nodename = g_strdup_printf("/flash@%" PRIx64, flashbase); qemu_fdt_add_subnode(vbi->fdt, nodename); qemu_fdt_setprop_string(vbi->fdt, nodename, "compatible", "cfi-flash"); qemu_fdt_setprop_sized_cells(vbi->fdt, nodename, "reg", 2, flashbase, 2, flashsize, 2, flashbase + flashsize, 2, flashsize); qemu_fdt_setprop_cell(vbi->fdt, nodename, "bank-width", 4); g_free(nodename); }
{ "code": [ " g_free(fn);" ], "line_no": [ 51 ] }
static void FUNC_0(const VirtBoardInfo *VAR_0) { hwaddr flashsize = VAR_0->memmap[VIRT_FLASH].size / 2; hwaddr flashbase = VAR_0->memmap[VIRT_FLASH].base; char *VAR_1; if (bios_name) { char *VAR_2; int VAR_3; if (drive_get(IF_PFLASH, 0, 0)) { error_report("The contents of the first flash device may be " "specified with -bios or with -drive if=pflash... " "but you cannot use both options at once"); exit(1); } VAR_2 = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); if (!VAR_2) { error_report("Could not find ROM image '%s'", bios_name); exit(1); } VAR_3 = load_image_targphys(VAR_2, flashbase, flashsize); g_free(VAR_2); if (VAR_3 < 0) { error_report("Could not load ROM image '%s'", bios_name); exit(1); } g_free(VAR_2); } create_one_flash("virt.flash0", flashbase, flashsize); create_one_flash("virt.flash1", flashbase + flashsize, flashsize); VAR_1 = g_strdup_printf("/flash@%" PRIx64, flashbase); qemu_fdt_add_subnode(VAR_0->fdt, VAR_1); qemu_fdt_setprop_string(VAR_0->fdt, VAR_1, "compatible", "cfi-flash"); qemu_fdt_setprop_sized_cells(VAR_0->fdt, VAR_1, "reg", 2, flashbase, 2, flashsize, 2, flashbase + flashsize, 2, flashsize); qemu_fdt_setprop_cell(VAR_0->fdt, VAR_1, "bank-width", 4); g_free(VAR_1); }
[ "static void FUNC_0(const VirtBoardInfo *VAR_0)\n{", "hwaddr flashsize = VAR_0->memmap[VIRT_FLASH].size / 2;", "hwaddr flashbase = VAR_0->memmap[VIRT_FLASH].base;", "char *VAR_1;", "if (bios_name) {", "char *VAR_2;", "int VAR_3;", "if (drive_get(IF_PFLASH, 0, 0)) {", "error_report(\"The contents of the first flash device may be \"\n\"specified with -bios or with -drive if=pflash... \"\n\"but you cannot use both options at once\");", "exit(1);", "}", "VAR_2 = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);", "if (!VAR_2) {", "error_report(\"Could not find ROM image '%s'\", bios_name);", "exit(1);", "}", "VAR_3 = load_image_targphys(VAR_2, flashbase, flashsize);", "g_free(VAR_2);", "if (VAR_3 < 0) {", "error_report(\"Could not load ROM image '%s'\", bios_name);", "exit(1);", "}", "g_free(VAR_2);", "}", "create_one_flash(\"virt.flash0\", flashbase, flashsize);", "create_one_flash(\"virt.flash1\", flashbase + flashsize, flashsize);", "VAR_1 = g_strdup_printf(\"/flash@%\" PRIx64, flashbase);", "qemu_fdt_add_subnode(VAR_0->fdt, VAR_1);", "qemu_fdt_setprop_string(VAR_0->fdt, VAR_1, \"compatible\", \"cfi-flash\");", "qemu_fdt_setprop_sized_cells(VAR_0->fdt, VAR_1, \"reg\",\n2, flashbase, 2, flashsize,\n2, flashbase + flashsize, 2, flashsize);", "qemu_fdt_setprop_cell(VAR_0->fdt, VAR_1, \"bank-width\", 4);", "g_free(VAR_1);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 27 ], [ 29, 31, 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 67 ], [ 69 ], [ 73 ], [ 75 ], [ 77 ], [ 79, 81, 83 ], [ 85 ], [ 87 ], [ 89 ] ]
22,233
void mips_malta_init(QEMUMachineInitArgs *args) { ram_addr_t ram_size = args->ram_size; const char *cpu_model = args->cpu_model; const char *kernel_filename = args->kernel_filename; const char *kernel_cmdline = args->kernel_cmdline; const char *initrd_filename = args->initrd_filename; char *filename; pflash_t *fl; MemoryRegion *system_memory = get_system_memory(); MemoryRegion *ram = g_new(MemoryRegion, 1); MemoryRegion *bios, *bios_copy = g_new(MemoryRegion, 1); target_long bios_size = FLASH_SIZE; const size_t smbus_eeprom_size = 8 * 256; uint8_t *smbus_eeprom_buf = g_malloc0(smbus_eeprom_size); int64_t kernel_entry; PCIBus *pci_bus; ISABus *isa_bus; MIPSCPU *cpu; CPUMIPSState *env; qemu_irq *isa_irq; qemu_irq *cpu_exit_irq; int piix4_devfn; i2c_bus *smbus; int i; DriveInfo *dinfo; DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; DriveInfo *fd[MAX_FD]; int fl_idx = 0; int fl_sectors = bios_size >> 16; int be; DeviceState *dev = qdev_create(NULL, TYPE_MIPS_MALTA); MaltaState *s = MIPS_MALTA(dev); qdev_init_nofail(dev); /* Make sure the first 3 serial ports are associated with a device. */ for(i = 0; i < 3; i++) { if (!serial_hds[i]) { char label[32]; snprintf(label, sizeof(label), "serial%d", i); serial_hds[i] = qemu_chr_new(label, "null", NULL); } } /* init CPUs */ if (cpu_model == NULL) { #ifdef TARGET_MIPS64 cpu_model = "20Kc"; #else cpu_model = "24Kf"; #endif } for (i = 0; i < smp_cpus; i++) { cpu = cpu_mips_init(cpu_model); if (cpu == NULL) { fprintf(stderr, "Unable to find CPU definition\n"); exit(1); } env = &cpu->env; /* Init internal devices */ cpu_mips_irq_init_cpu(env); cpu_mips_clock_init(env); qemu_register_reset(main_cpu_reset, cpu); } cpu = MIPS_CPU(first_cpu); env = &cpu->env; /* allocate RAM */ if (ram_size > (256 << 20)) { fprintf(stderr, "qemu: Too much memory for this machine: %d MB, maximum 256 MB\n", ((unsigned int)ram_size / (1 << 20))); exit(1); } memory_region_init_ram(ram, NULL, "mips_malta.ram", ram_size); vmstate_register_ram_global(ram); memory_region_add_subregion(system_memory, 0, ram); /* generate SPD EEPROM data */ generate_eeprom_spd(&smbus_eeprom_buf[0 * 256], ram_size); generate_eeprom_serial(&smbus_eeprom_buf[6 * 256]); #ifdef TARGET_WORDS_BIGENDIAN be = 1; #else be = 0; #endif /* FPGA */ /* The CBUS UART is attached to the MIPS CPU INT2 pin, ie interrupt 4 */ malta_fpga_init(system_memory, FPGA_ADDRESS, env->irq[4], serial_hds[2]); /* Load firmware in flash / BIOS. */ dinfo = drive_get(IF_PFLASH, 0, fl_idx); #ifdef DEBUG_BOARD_INIT if (dinfo) { printf("Register parallel flash %d size " TARGET_FMT_lx " at " "addr %08llx '%s' %x\n", fl_idx, bios_size, FLASH_ADDRESS, bdrv_get_device_name(dinfo->bdrv), fl_sectors); } #endif fl = pflash_cfi01_register(FLASH_ADDRESS, NULL, "mips_malta.bios", BIOS_SIZE, dinfo ? dinfo->bdrv : NULL, 65536, fl_sectors, 4, 0x0000, 0x0000, 0x0000, 0x0000, be); bios = pflash_cfi01_get_memory(fl); fl_idx++; if (kernel_filename) { /* Write a small bootloader to the flash location. */ loaderparams.ram_size = ram_size; loaderparams.kernel_filename = kernel_filename; loaderparams.kernel_cmdline = kernel_cmdline; loaderparams.initrd_filename = initrd_filename; kernel_entry = load_kernel(); write_bootloader(env, memory_region_get_ram_ptr(bios), kernel_entry); } else { /* Load firmware from flash. */ if (!dinfo) { /* Load a BIOS image. */ if (bios_name == NULL) { bios_name = BIOS_FILENAME; } filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); if (filename) { bios_size = load_image_targphys(filename, FLASH_ADDRESS, BIOS_SIZE); g_free(filename); } else { bios_size = -1; } if ((bios_size < 0 || bios_size > BIOS_SIZE) && !kernel_filename && !qtest_enabled()) { error_report("Could not load MIPS bios '%s', and no " "-kernel argument was specified", bios_name); exit(1); } } /* In little endian mode the 32bit words in the bios are swapped, a neat trick which allows bi-endian firmware. */ #ifndef TARGET_WORDS_BIGENDIAN { uint32_t *end, *addr = rom_ptr(FLASH_ADDRESS); if (!addr) { addr = memory_region_get_ram_ptr(bios); } end = (void *)addr + MIN(bios_size, 0x3e0000); while (addr < end) { bswap32s(addr); addr++; } } #endif } /* * Map the BIOS at a 2nd physical location, as on the real board. * Copy it so that we can patch in the MIPS revision, which cannot be * handled by an overlapping region as the resulting ROM code subpage * regions are not executable. */ memory_region_init_ram(bios_copy, NULL, "bios.1fc", BIOS_SIZE); if (!rom_copy(memory_region_get_ram_ptr(bios_copy), FLASH_ADDRESS, BIOS_SIZE)) { memcpy(memory_region_get_ram_ptr(bios_copy), memory_region_get_ram_ptr(bios), BIOS_SIZE); } memory_region_set_readonly(bios_copy, true); memory_region_add_subregion(system_memory, RESET_ADDRESS, bios_copy); /* Board ID = 0x420 (Malta Board with CoreLV) */ stl_p(memory_region_get_ram_ptr(bios_copy) + 0x10, 0x00000420); /* Init internal devices */ cpu_mips_irq_init_cpu(env); cpu_mips_clock_init(env); /* * We have a circular dependency problem: pci_bus depends on isa_irq, * isa_irq is provided by i8259, i8259 depends on ISA, ISA depends * on piix4, and piix4 depends on pci_bus. To stop the cycle we have * qemu_irq_proxy() adds an extra bit of indirection, allowing us * to resolve the isa_irq -> i8259 dependency after i8259 is initialized. */ isa_irq = qemu_irq_proxy(&s->i8259, 16); /* Northbridge */ pci_bus = gt64120_register(isa_irq); /* Southbridge */ ide_drive_get(hd, MAX_IDE_BUS); piix4_devfn = piix4_init(pci_bus, &isa_bus, 80); /* Interrupt controller */ /* The 8259 is attached to the MIPS CPU INT0 pin, ie interrupt 2 */ s->i8259 = i8259_init(isa_bus, env->irq[2]); isa_bus_irqs(isa_bus, s->i8259); pci_piix4_ide_init(pci_bus, hd, piix4_devfn + 1); pci_create_simple(pci_bus, piix4_devfn + 2, "piix4-usb-uhci"); smbus = piix4_pm_init(pci_bus, piix4_devfn + 3, 0x1100, isa_get_irq(NULL, 9), NULL, 0, NULL); smbus_eeprom_init(smbus, 8, smbus_eeprom_buf, smbus_eeprom_size); g_free(smbus_eeprom_buf); pit = pit_init(isa_bus, 0x40, 0, NULL); cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1); DMA_init(0, cpu_exit_irq); /* Super I/O */ isa_create_simple(isa_bus, "i8042"); rtc_init(isa_bus, 2000, NULL); serial_isa_init(isa_bus, 0, serial_hds[0]); serial_isa_init(isa_bus, 1, serial_hds[1]); if (parallel_hds[0]) parallel_init(isa_bus, 0, parallel_hds[0]); for(i = 0; i < MAX_FD; i++) { fd[i] = drive_get(IF_FLOPPY, 0, i); } fdctrl_init_isa(isa_bus, fd); /* Network card */ network_init(pci_bus); /* Optional PCI video card */ pci_vga_init(pci_bus); }
true
qemu
cc413a39355ed910f22f8f0be5e233c08a0773a0
void mips_malta_init(QEMUMachineInitArgs *args) { ram_addr_t ram_size = args->ram_size; const char *cpu_model = args->cpu_model; const char *kernel_filename = args->kernel_filename; const char *kernel_cmdline = args->kernel_cmdline; const char *initrd_filename = args->initrd_filename; char *filename; pflash_t *fl; MemoryRegion *system_memory = get_system_memory(); MemoryRegion *ram = g_new(MemoryRegion, 1); MemoryRegion *bios, *bios_copy = g_new(MemoryRegion, 1); target_long bios_size = FLASH_SIZE; const size_t smbus_eeprom_size = 8 * 256; uint8_t *smbus_eeprom_buf = g_malloc0(smbus_eeprom_size); int64_t kernel_entry; PCIBus *pci_bus; ISABus *isa_bus; MIPSCPU *cpu; CPUMIPSState *env; qemu_irq *isa_irq; qemu_irq *cpu_exit_irq; int piix4_devfn; i2c_bus *smbus; int i; DriveInfo *dinfo; DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; DriveInfo *fd[MAX_FD]; int fl_idx = 0; int fl_sectors = bios_size >> 16; int be; DeviceState *dev = qdev_create(NULL, TYPE_MIPS_MALTA); MaltaState *s = MIPS_MALTA(dev); qdev_init_nofail(dev); for(i = 0; i < 3; i++) { if (!serial_hds[i]) { char label[32]; snprintf(label, sizeof(label), "serial%d", i); serial_hds[i] = qemu_chr_new(label, "null", NULL); } } if (cpu_model == NULL) { #ifdef TARGET_MIPS64 cpu_model = "20Kc"; #else cpu_model = "24Kf"; #endif } for (i = 0; i < smp_cpus; i++) { cpu = cpu_mips_init(cpu_model); if (cpu == NULL) { fprintf(stderr, "Unable to find CPU definition\n"); exit(1); } env = &cpu->env; cpu_mips_irq_init_cpu(env); cpu_mips_clock_init(env); qemu_register_reset(main_cpu_reset, cpu); } cpu = MIPS_CPU(first_cpu); env = &cpu->env; if (ram_size > (256 << 20)) { fprintf(stderr, "qemu: Too much memory for this machine: %d MB, maximum 256 MB\n", ((unsigned int)ram_size / (1 << 20))); exit(1); } memory_region_init_ram(ram, NULL, "mips_malta.ram", ram_size); vmstate_register_ram_global(ram); memory_region_add_subregion(system_memory, 0, ram); generate_eeprom_spd(&smbus_eeprom_buf[0 * 256], ram_size); generate_eeprom_serial(&smbus_eeprom_buf[6 * 256]); #ifdef TARGET_WORDS_BIGENDIAN be = 1; #else be = 0; #endif malta_fpga_init(system_memory, FPGA_ADDRESS, env->irq[4], serial_hds[2]); dinfo = drive_get(IF_PFLASH, 0, fl_idx); #ifdef DEBUG_BOARD_INIT if (dinfo) { printf("Register parallel flash %d size " TARGET_FMT_lx " at " "addr %08llx '%s' %x\n", fl_idx, bios_size, FLASH_ADDRESS, bdrv_get_device_name(dinfo->bdrv), fl_sectors); } #endif fl = pflash_cfi01_register(FLASH_ADDRESS, NULL, "mips_malta.bios", BIOS_SIZE, dinfo ? dinfo->bdrv : NULL, 65536, fl_sectors, 4, 0x0000, 0x0000, 0x0000, 0x0000, be); bios = pflash_cfi01_get_memory(fl); fl_idx++; if (kernel_filename) { loaderparams.ram_size = ram_size; loaderparams.kernel_filename = kernel_filename; loaderparams.kernel_cmdline = kernel_cmdline; loaderparams.initrd_filename = initrd_filename; kernel_entry = load_kernel(); write_bootloader(env, memory_region_get_ram_ptr(bios), kernel_entry); } else { if (!dinfo) { if (bios_name == NULL) { bios_name = BIOS_FILENAME; } filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); if (filename) { bios_size = load_image_targphys(filename, FLASH_ADDRESS, BIOS_SIZE); g_free(filename); } else { bios_size = -1; } if ((bios_size < 0 || bios_size > BIOS_SIZE) && !kernel_filename && !qtest_enabled()) { error_report("Could not load MIPS bios '%s', and no " "-kernel argument was specified", bios_name); exit(1); } } #ifndef TARGET_WORDS_BIGENDIAN { uint32_t *end, *addr = rom_ptr(FLASH_ADDRESS); if (!addr) { addr = memory_region_get_ram_ptr(bios); } end = (void *)addr + MIN(bios_size, 0x3e0000); while (addr < end) { bswap32s(addr); addr++; } } #endif } memory_region_init_ram(bios_copy, NULL, "bios.1fc", BIOS_SIZE); if (!rom_copy(memory_region_get_ram_ptr(bios_copy), FLASH_ADDRESS, BIOS_SIZE)) { memcpy(memory_region_get_ram_ptr(bios_copy), memory_region_get_ram_ptr(bios), BIOS_SIZE); } memory_region_set_readonly(bios_copy, true); memory_region_add_subregion(system_memory, RESET_ADDRESS, bios_copy); stl_p(memory_region_get_ram_ptr(bios_copy) + 0x10, 0x00000420); cpu_mips_irq_init_cpu(env); cpu_mips_clock_init(env); isa_irq = qemu_irq_proxy(&s->i8259, 16); pci_bus = gt64120_register(isa_irq); ide_drive_get(hd, MAX_IDE_BUS); piix4_devfn = piix4_init(pci_bus, &isa_bus, 80); s->i8259 = i8259_init(isa_bus, env->irq[2]); isa_bus_irqs(isa_bus, s->i8259); pci_piix4_ide_init(pci_bus, hd, piix4_devfn + 1); pci_create_simple(pci_bus, piix4_devfn + 2, "piix4-usb-uhci"); smbus = piix4_pm_init(pci_bus, piix4_devfn + 3, 0x1100, isa_get_irq(NULL, 9), NULL, 0, NULL); smbus_eeprom_init(smbus, 8, smbus_eeprom_buf, smbus_eeprom_size); g_free(smbus_eeprom_buf); pit = pit_init(isa_bus, 0x40, 0, NULL); cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1); DMA_init(0, cpu_exit_irq); isa_create_simple(isa_bus, "i8042"); rtc_init(isa_bus, 2000, NULL); serial_isa_init(isa_bus, 0, serial_hds[0]); serial_isa_init(isa_bus, 1, serial_hds[1]); if (parallel_hds[0]) parallel_init(isa_bus, 0, parallel_hds[0]); for(i = 0; i < MAX_FD; i++) { fd[i] = drive_get(IF_FLOPPY, 0, i); } fdctrl_init_isa(isa_bus, fd); network_init(pci_bus); pci_vga_init(pci_bus); }
{ "code": [], "line_no": [] }
void FUNC_0(QEMUMachineInitArgs *VAR_0) { ram_addr_t ram_size = VAR_0->ram_size; const char *VAR_1 = VAR_0->VAR_1; const char *VAR_2 = VAR_0->VAR_2; const char *VAR_3 = VAR_0->VAR_3; const char *VAR_4 = VAR_0->VAR_4; char *VAR_5; pflash_t *fl; MemoryRegion *system_memory = get_system_memory(); MemoryRegion *ram = g_new(MemoryRegion, 1); MemoryRegion *bios, *bios_copy = g_new(MemoryRegion, 1); target_long bios_size = FLASH_SIZE; const size_t VAR_6 = 8 * 256; uint8_t *smbus_eeprom_buf = g_malloc0(VAR_6); int64_t kernel_entry; PCIBus *pci_bus; ISABus *isa_bus; MIPSCPU *cpu; CPUMIPSState *env; qemu_irq *isa_irq; qemu_irq *cpu_exit_irq; int VAR_7; i2c_bus *smbus; int VAR_8; DriveInfo *dinfo; DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; DriveInfo *fd[MAX_FD]; int VAR_9 = 0; int VAR_10 = bios_size >> 16; int VAR_11; DeviceState *dev = qdev_create(NULL, TYPE_MIPS_MALTA); MaltaState *s = MIPS_MALTA(dev); qdev_init_nofail(dev); for(VAR_8 = 0; VAR_8 < 3; VAR_8++) { if (!serial_hds[VAR_8]) { char VAR_12[32]; snprintf(VAR_12, sizeof(VAR_12), "serial%d", VAR_8); serial_hds[VAR_8] = qemu_chr_new(VAR_12, "null", NULL); } } if (VAR_1 == NULL) { #ifdef TARGET_MIPS64 VAR_1 = "20Kc"; #else VAR_1 = "24Kf"; #endif } for (VAR_8 = 0; VAR_8 < smp_cpus; VAR_8++) { cpu = cpu_mips_init(VAR_1); if (cpu == NULL) { fprintf(stderr, "Unable to find CPU definition\n"); exit(1); } env = &cpu->env; cpu_mips_irq_init_cpu(env); cpu_mips_clock_init(env); qemu_register_reset(main_cpu_reset, cpu); } cpu = MIPS_CPU(first_cpu); env = &cpu->env; if (ram_size > (256 << 20)) { fprintf(stderr, "qemu: Too much memory for this machine: %d MB, maximum 256 MB\n", ((unsigned int)ram_size / (1 << 20))); exit(1); } memory_region_init_ram(ram, NULL, "mips_malta.ram", ram_size); vmstate_register_ram_global(ram); memory_region_add_subregion(system_memory, 0, ram); generate_eeprom_spd(&smbus_eeprom_buf[0 * 256], ram_size); generate_eeprom_serial(&smbus_eeprom_buf[6 * 256]); #ifdef TARGET_WORDS_BIGENDIAN VAR_11 = 1; #else VAR_11 = 0; #endif malta_fpga_init(system_memory, FPGA_ADDRESS, env->irq[4], serial_hds[2]); dinfo = drive_get(IF_PFLASH, 0, VAR_9); #ifdef DEBUG_BOARD_INIT if (dinfo) { printf("Register parallel flash %d size " TARGET_FMT_lx " at " "addr %08llx '%s' %x\n", VAR_9, bios_size, FLASH_ADDRESS, bdrv_get_device_name(dinfo->bdrv), VAR_10); } #endif fl = pflash_cfi01_register(FLASH_ADDRESS, NULL, "mips_malta.bios", BIOS_SIZE, dinfo ? dinfo->bdrv : NULL, 65536, VAR_10, 4, 0x0000, 0x0000, 0x0000, 0x0000, VAR_11); bios = pflash_cfi01_get_memory(fl); VAR_9++; if (VAR_2) { loaderparams.ram_size = ram_size; loaderparams.VAR_2 = VAR_2; loaderparams.VAR_3 = VAR_3; loaderparams.VAR_4 = VAR_4; kernel_entry = load_kernel(); write_bootloader(env, memory_region_get_ram_ptr(bios), kernel_entry); } else { if (!dinfo) { if (bios_name == NULL) { bios_name = BIOS_FILENAME; } VAR_5 = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); if (VAR_5) { bios_size = load_image_targphys(VAR_5, FLASH_ADDRESS, BIOS_SIZE); g_free(VAR_5); } else { bios_size = -1; } if ((bios_size < 0 || bios_size > BIOS_SIZE) && !VAR_2 && !qtest_enabled()) { error_report("Could not load MIPS bios '%s', and no " "-kernel argument was specified", bios_name); exit(1); } } #ifndef TARGET_WORDS_BIGENDIAN { uint32_t *end, *addr = rom_ptr(FLASH_ADDRESS); if (!addr) { addr = memory_region_get_ram_ptr(bios); } end = (void *)addr + MIN(bios_size, 0x3e0000); while (addr < end) { bswap32s(addr); addr++; } } #endif } memory_region_init_ram(bios_copy, NULL, "bios.1fc", BIOS_SIZE); if (!rom_copy(memory_region_get_ram_ptr(bios_copy), FLASH_ADDRESS, BIOS_SIZE)) { memcpy(memory_region_get_ram_ptr(bios_copy), memory_region_get_ram_ptr(bios), BIOS_SIZE); } memory_region_set_readonly(bios_copy, true); memory_region_add_subregion(system_memory, RESET_ADDRESS, bios_copy); stl_p(memory_region_get_ram_ptr(bios_copy) + 0x10, 0x00000420); cpu_mips_irq_init_cpu(env); cpu_mips_clock_init(env); isa_irq = qemu_irq_proxy(&s->i8259, 16); pci_bus = gt64120_register(isa_irq); ide_drive_get(hd, MAX_IDE_BUS); VAR_7 = piix4_init(pci_bus, &isa_bus, 80); s->i8259 = i8259_init(isa_bus, env->irq[2]); isa_bus_irqs(isa_bus, s->i8259); pci_piix4_ide_init(pci_bus, hd, VAR_7 + 1); pci_create_simple(pci_bus, VAR_7 + 2, "piix4-usb-uhci"); smbus = piix4_pm_init(pci_bus, VAR_7 + 3, 0x1100, isa_get_irq(NULL, 9), NULL, 0, NULL); smbus_eeprom_init(smbus, 8, smbus_eeprom_buf, VAR_6); g_free(smbus_eeprom_buf); pit = pit_init(isa_bus, 0x40, 0, NULL); cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1); DMA_init(0, cpu_exit_irq); isa_create_simple(isa_bus, "i8042"); rtc_init(isa_bus, 2000, NULL); serial_isa_init(isa_bus, 0, serial_hds[0]); serial_isa_init(isa_bus, 1, serial_hds[1]); if (parallel_hds[0]) parallel_init(isa_bus, 0, parallel_hds[0]); for(VAR_8 = 0; VAR_8 < MAX_FD; VAR_8++) { fd[VAR_8] = drive_get(IF_FLOPPY, 0, VAR_8); } fdctrl_init_isa(isa_bus, fd); network_init(pci_bus); pci_vga_init(pci_bus); }
[ "void FUNC_0(QEMUMachineInitArgs *VAR_0)\n{", "ram_addr_t ram_size = VAR_0->ram_size;", "const char *VAR_1 = VAR_0->VAR_1;", "const char *VAR_2 = VAR_0->VAR_2;", "const char *VAR_3 = VAR_0->VAR_3;", "const char *VAR_4 = VAR_0->VAR_4;", "char *VAR_5;", "pflash_t *fl;", "MemoryRegion *system_memory = get_system_memory();", "MemoryRegion *ram = g_new(MemoryRegion, 1);", "MemoryRegion *bios, *bios_copy = g_new(MemoryRegion, 1);", "target_long bios_size = FLASH_SIZE;", "const size_t VAR_6 = 8 * 256;", "uint8_t *smbus_eeprom_buf = g_malloc0(VAR_6);", "int64_t kernel_entry;", "PCIBus *pci_bus;", "ISABus *isa_bus;", "MIPSCPU *cpu;", "CPUMIPSState *env;", "qemu_irq *isa_irq;", "qemu_irq *cpu_exit_irq;", "int VAR_7;", "i2c_bus *smbus;", "int VAR_8;", "DriveInfo *dinfo;", "DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];", "DriveInfo *fd[MAX_FD];", "int VAR_9 = 0;", "int VAR_10 = bios_size >> 16;", "int VAR_11;", "DeviceState *dev = qdev_create(NULL, TYPE_MIPS_MALTA);", "MaltaState *s = MIPS_MALTA(dev);", "qdev_init_nofail(dev);", "for(VAR_8 = 0; VAR_8 < 3; VAR_8++) {", "if (!serial_hds[VAR_8]) {", "char VAR_12[32];", "snprintf(VAR_12, sizeof(VAR_12), \"serial%d\", VAR_8);", "serial_hds[VAR_8] = qemu_chr_new(VAR_12, \"null\", NULL);", "}", "}", "if (VAR_1 == NULL) {", "#ifdef TARGET_MIPS64\nVAR_1 = \"20Kc\";", "#else\nVAR_1 = \"24Kf\";", "#endif\n}", "for (VAR_8 = 0; VAR_8 < smp_cpus; VAR_8++) {", "cpu = cpu_mips_init(VAR_1);", "if (cpu == NULL) {", "fprintf(stderr, \"Unable to find CPU definition\\n\");", "exit(1);", "}", "env = &cpu->env;", "cpu_mips_irq_init_cpu(env);", "cpu_mips_clock_init(env);", "qemu_register_reset(main_cpu_reset, cpu);", "}", "cpu = MIPS_CPU(first_cpu);", "env = &cpu->env;", "if (ram_size > (256 << 20)) {", "fprintf(stderr,\n\"qemu: Too much memory for this machine: %d MB, maximum 256 MB\\n\",\n((unsigned int)ram_size / (1 << 20)));", "exit(1);", "}", "memory_region_init_ram(ram, NULL, \"mips_malta.ram\", ram_size);", "vmstate_register_ram_global(ram);", "memory_region_add_subregion(system_memory, 0, ram);", "generate_eeprom_spd(&smbus_eeprom_buf[0 * 256], ram_size);", "generate_eeprom_serial(&smbus_eeprom_buf[6 * 256]);", "#ifdef TARGET_WORDS_BIGENDIAN\nVAR_11 = 1;", "#else\nVAR_11 = 0;", "#endif\nmalta_fpga_init(system_memory, FPGA_ADDRESS, env->irq[4], serial_hds[2]);", "dinfo = drive_get(IF_PFLASH, 0, VAR_9);", "#ifdef DEBUG_BOARD_INIT\nif (dinfo) {", "printf(\"Register parallel flash %d size \" TARGET_FMT_lx \" at \"\n\"addr %08llx '%s' %x\\n\",\nVAR_9, bios_size, FLASH_ADDRESS,\nbdrv_get_device_name(dinfo->bdrv), VAR_10);", "}", "#endif\nfl = pflash_cfi01_register(FLASH_ADDRESS, NULL, \"mips_malta.bios\",\nBIOS_SIZE, dinfo ? dinfo->bdrv : NULL,\n65536, VAR_10,\n4, 0x0000, 0x0000, 0x0000, 0x0000, VAR_11);", "bios = pflash_cfi01_get_memory(fl);", "VAR_9++;", "if (VAR_2) {", "loaderparams.ram_size = ram_size;", "loaderparams.VAR_2 = VAR_2;", "loaderparams.VAR_3 = VAR_3;", "loaderparams.VAR_4 = VAR_4;", "kernel_entry = load_kernel();", "write_bootloader(env, memory_region_get_ram_ptr(bios), kernel_entry);", "} else {", "if (!dinfo) {", "if (bios_name == NULL) {", "bios_name = BIOS_FILENAME;", "}", "VAR_5 = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);", "if (VAR_5) {", "bios_size = load_image_targphys(VAR_5, FLASH_ADDRESS,\nBIOS_SIZE);", "g_free(VAR_5);", "} else {", "bios_size = -1;", "}", "if ((bios_size < 0 || bios_size > BIOS_SIZE) &&\n!VAR_2 && !qtest_enabled()) {", "error_report(\"Could not load MIPS bios '%s', and no \"\n\"-kernel argument was specified\", bios_name);", "exit(1);", "}", "}", "#ifndef TARGET_WORDS_BIGENDIAN\n{", "uint32_t *end, *addr = rom_ptr(FLASH_ADDRESS);", "if (!addr) {", "addr = memory_region_get_ram_ptr(bios);", "}", "end = (void *)addr + MIN(bios_size, 0x3e0000);", "while (addr < end) {", "bswap32s(addr);", "addr++;", "}", "}", "#endif\n}", "memory_region_init_ram(bios_copy, NULL, \"bios.1fc\", BIOS_SIZE);", "if (!rom_copy(memory_region_get_ram_ptr(bios_copy),\nFLASH_ADDRESS, BIOS_SIZE)) {", "memcpy(memory_region_get_ram_ptr(bios_copy),\nmemory_region_get_ram_ptr(bios), BIOS_SIZE);", "}", "memory_region_set_readonly(bios_copy, true);", "memory_region_add_subregion(system_memory, RESET_ADDRESS, bios_copy);", "stl_p(memory_region_get_ram_ptr(bios_copy) + 0x10, 0x00000420);", "cpu_mips_irq_init_cpu(env);", "cpu_mips_clock_init(env);", "isa_irq = qemu_irq_proxy(&s->i8259, 16);", "pci_bus = gt64120_register(isa_irq);", "ide_drive_get(hd, MAX_IDE_BUS);", "VAR_7 = piix4_init(pci_bus, &isa_bus, 80);", "s->i8259 = i8259_init(isa_bus, env->irq[2]);", "isa_bus_irqs(isa_bus, s->i8259);", "pci_piix4_ide_init(pci_bus, hd, VAR_7 + 1);", "pci_create_simple(pci_bus, VAR_7 + 2, \"piix4-usb-uhci\");", "smbus = piix4_pm_init(pci_bus, VAR_7 + 3, 0x1100,\nisa_get_irq(NULL, 9), NULL, 0, NULL);", "smbus_eeprom_init(smbus, 8, smbus_eeprom_buf, VAR_6);", "g_free(smbus_eeprom_buf);", "pit = pit_init(isa_bus, 0x40, 0, NULL);", "cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1);", "DMA_init(0, cpu_exit_irq);", "isa_create_simple(isa_bus, \"i8042\");", "rtc_init(isa_bus, 2000, NULL);", "serial_isa_init(isa_bus, 0, serial_hds[0]);", "serial_isa_init(isa_bus, 1, serial_hds[1]);", "if (parallel_hds[0])\nparallel_init(isa_bus, 0, parallel_hds[0]);", "for(VAR_8 = 0; VAR_8 < MAX_FD; VAR_8++) {", "fd[VAR_8] = drive_get(IF_FLOPPY, 0, VAR_8);", "}", "fdctrl_init_isa(isa_bus, fd);", "network_init(pci_bus);", "pci_vga_init(pci_bus);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 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 ], [ 36 ], [ 37 ], [ 38 ], [ 39 ], [ 40 ], [ 41 ], [ 42 ], [ 44 ], [ 45, 46 ], [ 47, 48 ], [ 49, 50 ], [ 51 ], [ 52 ], [ 53 ], [ 54 ], [ 55 ], [ 56 ], [ 57 ], [ 59 ], [ 60 ], [ 61 ], [ 62 ], [ 63 ], [ 64 ], [ 66 ], [ 67, 68, 69 ], [ 70 ], [ 71 ], [ 72 ], [ 73 ], [ 74 ], [ 76 ], [ 77 ], [ 78, 79 ], [ 80, 81 ], [ 82, 85 ], [ 87 ], [ 88, 89 ], [ 90, 91, 92, 93 ], [ 94 ], [ 95, 96, 97, 98, 99 ], [ 100 ], [ 101 ], [ 102 ], [ 104 ], [ 105 ], [ 106 ], [ 107 ], [ 108 ], [ 109 ], [ 110 ], [ 112 ], [ 114 ], [ 115 ], [ 116 ], [ 117 ], [ 118 ], [ 119, 120 ], [ 121 ], [ 122 ], [ 123 ], [ 124 ], [ 125, 126 ], [ 127, 128 ], [ 129 ], [ 130 ], [ 131 ], [ 134, 135 ], [ 136 ], [ 137 ], [ 138 ], [ 139 ], [ 140 ], [ 141 ], [ 142 ], [ 143 ], [ 144 ], [ 145 ], [ 146, 147 ], [ 154 ], [ 155, 156 ], [ 157, 158 ], [ 159 ], [ 160 ], [ 161 ], [ 163 ], [ 165 ], [ 166 ], [ 174 ], [ 176 ], [ 178 ], [ 179 ], [ 182 ], [ 183 ], [ 184 ], [ 185 ], [ 186, 187 ], [ 188 ], [ 189 ], [ 190 ], [ 191 ], [ 192 ], [ 194 ], [ 195 ], [ 196 ], [ 197 ], [ 198, 199 ], [ 200 ], [ 201 ], [ 202 ], [ 203 ], [ 205 ], [ 207 ], [ 208 ] ]
22,234
static qemu_irq *ppce500_init_mpic(PPCE500Params *params, MemoryRegion *ccsr, qemu_irq **irqs) { QemuOptsList *list; qemu_irq *mpic; DeviceState *dev = NULL; SysBusDevice *s; int i; mpic = g_new(qemu_irq, 256); if (kvm_enabled()) { bool irqchip_allowed = true, irqchip_required = false; list = qemu_find_opts("machine"); if (!QTAILQ_EMPTY(&list->head)) { irqchip_allowed = qemu_opt_get_bool(QTAILQ_FIRST(&list->head), "kernel_irqchip", true); irqchip_required = qemu_opt_get_bool(QTAILQ_FIRST(&list->head), "kernel_irqchip", false); } if (irqchip_allowed) { dev = ppce500_init_mpic_kvm(params, irqs); } if (irqchip_required && !dev) { fprintf(stderr, "%s: irqchip requested but unavailable\n", __func__); abort(); } } if (!dev) { dev = ppce500_init_mpic_qemu(params, irqs); } for (i = 0; i < 256; i++) { mpic[i] = qdev_get_gpio_in(dev, i); } s = SYS_BUS_DEVICE(dev); memory_region_add_subregion(ccsr, MPC8544_MPIC_REGS_OFFSET, s->mmio[0].memory); return mpic; }
true
qemu
36ad0e948e15d8d86c8dec1c17a8588d87b0107d
static qemu_irq *ppce500_init_mpic(PPCE500Params *params, MemoryRegion *ccsr, qemu_irq **irqs) { QemuOptsList *list; qemu_irq *mpic; DeviceState *dev = NULL; SysBusDevice *s; int i; mpic = g_new(qemu_irq, 256); if (kvm_enabled()) { bool irqchip_allowed = true, irqchip_required = false; list = qemu_find_opts("machine"); if (!QTAILQ_EMPTY(&list->head)) { irqchip_allowed = qemu_opt_get_bool(QTAILQ_FIRST(&list->head), "kernel_irqchip", true); irqchip_required = qemu_opt_get_bool(QTAILQ_FIRST(&list->head), "kernel_irqchip", false); } if (irqchip_allowed) { dev = ppce500_init_mpic_kvm(params, irqs); } if (irqchip_required && !dev) { fprintf(stderr, "%s: irqchip requested but unavailable\n", __func__); abort(); } } if (!dev) { dev = ppce500_init_mpic_qemu(params, irqs); } for (i = 0; i < 256; i++) { mpic[i] = qdev_get_gpio_in(dev, i); } s = SYS_BUS_DEVICE(dev); memory_region_add_subregion(ccsr, MPC8544_MPIC_REGS_OFFSET, s->mmio[0].memory); return mpic; }
{ "code": [ " QemuOptsList *list;", " bool irqchip_allowed = true, irqchip_required = false;", " list = qemu_find_opts(\"machine\");", " if (!QTAILQ_EMPTY(&list->head)) {", " irqchip_allowed = qemu_opt_get_bool(QTAILQ_FIRST(&list->head),", " irqchip_required = qemu_opt_get_bool(QTAILQ_FIRST(&list->head),", " \"kernel_irqchip\", false);" ], "line_no": [ 7, 25, 29, 31, 33, 37, 39 ] }
static qemu_irq *FUNC_0(PPCE500Params *params, MemoryRegion *ccsr, qemu_irq **irqs) { QemuOptsList *list; qemu_irq *mpic; DeviceState *dev = NULL; SysBusDevice *s; int VAR_0; mpic = g_new(qemu_irq, 256); if (kvm_enabled()) { bool irqchip_allowed = true, irqchip_required = false; list = qemu_find_opts("machine"); if (!QTAILQ_EMPTY(&list->head)) { irqchip_allowed = qemu_opt_get_bool(QTAILQ_FIRST(&list->head), "kernel_irqchip", true); irqchip_required = qemu_opt_get_bool(QTAILQ_FIRST(&list->head), "kernel_irqchip", false); } if (irqchip_allowed) { dev = ppce500_init_mpic_kvm(params, irqs); } if (irqchip_required && !dev) { fprintf(stderr, "%s: irqchip requested but unavailable\n", __func__); abort(); } } if (!dev) { dev = ppce500_init_mpic_qemu(params, irqs); } for (VAR_0 = 0; VAR_0 < 256; VAR_0++) { mpic[VAR_0] = qdev_get_gpio_in(dev, VAR_0); } s = SYS_BUS_DEVICE(dev); memory_region_add_subregion(ccsr, MPC8544_MPIC_REGS_OFFSET, s->mmio[0].memory); return mpic; }
[ "static qemu_irq *FUNC_0(PPCE500Params *params, MemoryRegion *ccsr,\nqemu_irq **irqs)\n{", "QemuOptsList *list;", "qemu_irq *mpic;", "DeviceState *dev = NULL;", "SysBusDevice *s;", "int VAR_0;", "mpic = g_new(qemu_irq, 256);", "if (kvm_enabled()) {", "bool irqchip_allowed = true, irqchip_required = false;", "list = qemu_find_opts(\"machine\");", "if (!QTAILQ_EMPTY(&list->head)) {", "irqchip_allowed = qemu_opt_get_bool(QTAILQ_FIRST(&list->head),\n\"kernel_irqchip\", true);", "irqchip_required = qemu_opt_get_bool(QTAILQ_FIRST(&list->head),\n\"kernel_irqchip\", false);", "}", "if (irqchip_allowed) {", "dev = ppce500_init_mpic_kvm(params, irqs);", "}", "if (irqchip_required && !dev) {", "fprintf(stderr, \"%s: irqchip requested but unavailable\\n\",\n__func__);", "abort();", "}", "}", "if (!dev) {", "dev = ppce500_init_mpic_qemu(params, irqs);", "}", "for (VAR_0 = 0; VAR_0 < 256; VAR_0++) {", "mpic[VAR_0] = qdev_get_gpio_in(dev, VAR_0);", "}", "s = SYS_BUS_DEVICE(dev);", "memory_region_add_subregion(ccsr, MPC8544_MPIC_REGS_OFFSET,\ns->mmio[0].memory);", "return mpic;", "}" ]
[ 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 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 ], [ 13 ], [ 15 ], [ 19 ], [ 23 ], [ 25 ], [ 29 ], [ 31 ], [ 33, 35 ], [ 37, 39 ], [ 41 ], [ 45 ], [ 47 ], [ 49 ], [ 53 ], [ 55, 57 ], [ 59 ], [ 61 ], [ 63 ], [ 67 ], [ 69 ], [ 71 ], [ 75 ], [ 77 ], [ 79 ], [ 83 ], [ 85, 87 ], [ 91 ], [ 93 ] ]
22,235
static char *spapr_get_fw_dev_path(FWPathProvider *p, BusState *bus, DeviceState *dev) { #define CAST(type, obj, name) \ ((type *)object_dynamic_cast(OBJECT(obj), (name))) SCSIDevice *d = CAST(SCSIDevice, dev, TYPE_SCSI_DEVICE); sPAPRPHBState *phb = CAST(sPAPRPHBState, dev, TYPE_SPAPR_PCI_HOST_BRIDGE); VHostSCSICommon *vsc = CAST(VHostSCSICommon, dev, TYPE_VHOST_SCSI_COMMON); if (d) { void *spapr = CAST(void, bus->parent, "spapr-vscsi"); VirtIOSCSI *virtio = CAST(VirtIOSCSI, bus->parent, TYPE_VIRTIO_SCSI); USBDevice *usb = CAST(USBDevice, bus->parent, TYPE_USB_DEVICE); if (spapr) { /* * Replace "channel@0/disk@0,0" with "disk@8000000000000000": * We use SRP luns of the form 8000 | (bus << 8) | (id << 5) | lun * in the top 16 bits of the 64-bit LUN */ unsigned id = 0x8000 | (d->id << 8) | d->lun; return g_strdup_printf("%s@%"PRIX64, qdev_fw_name(dev), (uint64_t)id << 48); } else if (virtio) { /* * We use SRP luns of the form 01000000 | (target << 8) | lun * in the top 32 bits of the 64-bit LUN * Note: the quote above is from SLOF and it is wrong, * the actual binding is: * swap 0100 or 10 << or 20 << ( target lun-id -- srplun ) */ unsigned id = 0x1000000 | (d->id << 16) | d->lun; return g_strdup_printf("%s@%"PRIX64, qdev_fw_name(dev), (uint64_t)id << 32); } else if (usb) { /* * We use SRP luns of the form 01000000 | (usb-port << 16) | lun * in the top 32 bits of the 64-bit LUN */ unsigned usb_port = atoi(usb->port->path); unsigned id = 0x1000000 | (usb_port << 16) | d->lun; return g_strdup_printf("%s@%"PRIX64, qdev_fw_name(dev), (uint64_t)id << 32); /* * SLOF probes the USB devices, and if it recognizes that the device is a * storage device, it changes its name to "storage" instead of "usb-host", * and additionally adds a child node for the SCSI LUN, so the correct * boot path in SLOF is something like .../storage@1/disk@xxx" instead. */ if (strcmp("usb-host", qdev_fw_name(dev)) == 0) { USBDevice *usbdev = CAST(USBDevice, dev, TYPE_USB_DEVICE); if (usb_host_dev_is_scsi_storage(usbdev)) { return g_strdup_printf("storage@%s/disk", usbdev->port->path); if (phb) { /* Replace "pci" with "pci@800000020000000" */ return g_strdup_printf("pci@%"PRIX64, phb->buid); if (vsc) { /* Same logic as virtio above */ unsigned id = 0x1000000 | (vsc->target << 16) | vsc->lun; return g_strdup_printf("disk@%"PRIX64, (uint64_t)id << 32); if (g_str_equal("pci-bridge", qdev_fw_name(dev))) { /* SLOF uses "pci" instead of "pci-bridge" for PCI bridges */ PCIDevice *pcidev = CAST(PCIDevice, dev, TYPE_PCI_DEVICE); return g_strdup_printf("pci@%x", PCI_SLOT(pcidev->devfn)); return NULL;
true
qemu
bac658d1a4dc9dd637b2eb5006abda137071f17f
static char *spapr_get_fw_dev_path(FWPathProvider *p, BusState *bus, DeviceState *dev) { #define CAST(type, obj, name) \ ((type *)object_dynamic_cast(OBJECT(obj), (name))) SCSIDevice *d = CAST(SCSIDevice, dev, TYPE_SCSI_DEVICE); sPAPRPHBState *phb = CAST(sPAPRPHBState, dev, TYPE_SPAPR_PCI_HOST_BRIDGE); VHostSCSICommon *vsc = CAST(VHostSCSICommon, dev, TYPE_VHOST_SCSI_COMMON); if (d) { void *spapr = CAST(void, bus->parent, "spapr-vscsi"); VirtIOSCSI *virtio = CAST(VirtIOSCSI, bus->parent, TYPE_VIRTIO_SCSI); USBDevice *usb = CAST(USBDevice, bus->parent, TYPE_USB_DEVICE); if (spapr) { unsigned id = 0x8000 | (d->id << 8) | d->lun; return g_strdup_printf("%s@%"PRIX64, qdev_fw_name(dev), (uint64_t)id << 48); } else if (virtio) { unsigned id = 0x1000000 | (d->id << 16) | d->lun; return g_strdup_printf("%s@%"PRIX64, qdev_fw_name(dev), (uint64_t)id << 32); } else if (usb) { unsigned usb_port = atoi(usb->port->path); unsigned id = 0x1000000 | (usb_port << 16) | d->lun; return g_strdup_printf("%s@%"PRIX64, qdev_fw_name(dev), (uint64_t)id << 32); if (strcmp("usb-host", qdev_fw_name(dev)) == 0) { USBDevice *usbdev = CAST(USBDevice, dev, TYPE_USB_DEVICE); if (usb_host_dev_is_scsi_storage(usbdev)) { return g_strdup_printf("storage@%s/disk", usbdev->port->path); if (phb) { return g_strdup_printf("pci@%"PRIX64, phb->buid); if (vsc) { unsigned id = 0x1000000 | (vsc->target << 16) | vsc->lun; return g_strdup_printf("disk@%"PRIX64, (uint64_t)id << 32); if (g_str_equal("pci-bridge", qdev_fw_name(dev))) { PCIDevice *pcidev = CAST(PCIDevice, dev, TYPE_PCI_DEVICE); return g_strdup_printf("pci@%x", PCI_SLOT(pcidev->devfn)); return NULL;
{ "code": [], "line_no": [] }
static char *FUNC_0(FWPathProvider *VAR_0, BusState *VAR_1, DeviceState *VAR_2) { #define CAST(type, obj, name) \ ((type *)object_dynamic_cast(OBJECT(obj), (name))) SCSIDevice *d = CAST(SCSIDevice, VAR_2, TYPE_SCSI_DEVICE); sPAPRPHBState *phb = CAST(sPAPRPHBState, VAR_2, TYPE_SPAPR_PCI_HOST_BRIDGE); VHostSCSICommon *vsc = CAST(VHostSCSICommon, VAR_2, TYPE_VHOST_SCSI_COMMON); if (d) { void *VAR_3 = CAST(void, VAR_1->parent, "VAR_3-vscsi"); VirtIOSCSI *virtio = CAST(VirtIOSCSI, VAR_1->parent, TYPE_VIRTIO_SCSI); USBDevice *usb = CAST(USBDevice, VAR_1->parent, TYPE_USB_DEVICE); if (VAR_3) { unsigned VAR_6 = 0x8000 | (d->VAR_6 << 8) | d->lun; return g_strdup_printf("%s@%"PRIX64, qdev_fw_name(VAR_2), (uint64_t)VAR_6 << 48); } else if (virtio) { unsigned VAR_6 = 0x1000000 | (d->VAR_6 << 16) | d->lun; return g_strdup_printf("%s@%"PRIX64, qdev_fw_name(VAR_2), (uint64_t)VAR_6 << 32); } else if (usb) { unsigned VAR_5 = atoi(usb->port->path); unsigned VAR_6 = 0x1000000 | (VAR_5 << 16) | d->lun; return g_strdup_printf("%s@%"PRIX64, qdev_fw_name(VAR_2), (uint64_t)VAR_6 << 32); if (strcmp("usb-host", qdev_fw_name(VAR_2)) == 0) { USBDevice *usbdev = CAST(USBDevice, VAR_2, TYPE_USB_DEVICE); if (usb_host_dev_is_scsi_storage(usbdev)) { return g_strdup_printf("storage@%s/disk", usbdev->port->path); if (phb) { return g_strdup_printf("pci@%"PRIX64, phb->buid); if (vsc) { unsigned VAR_6 = 0x1000000 | (vsc->target << 16) | vsc->lun; return g_strdup_printf("disk@%"PRIX64, (uint64_t)VAR_6 << 32); if (g_str_equal("pci-bridge", qdev_fw_name(VAR_2))) { PCIDevice *pcidev = CAST(PCIDevice, VAR_2, TYPE_PCI_DEVICE); return g_strdup_printf("pci@%x", PCI_SLOT(pcidev->devfn)); return NULL;
[ "static char *FUNC_0(FWPathProvider *VAR_0, BusState *VAR_1,\nDeviceState *VAR_2)\n{", "#define CAST(type, obj, name) \\\n((type *)object_dynamic_cast(OBJECT(obj), (name)))\nSCSIDevice *d = CAST(SCSIDevice, VAR_2, TYPE_SCSI_DEVICE);", "sPAPRPHBState *phb = CAST(sPAPRPHBState, VAR_2, TYPE_SPAPR_PCI_HOST_BRIDGE);", "VHostSCSICommon *vsc = CAST(VHostSCSICommon, VAR_2, TYPE_VHOST_SCSI_COMMON);", "if (d) {", "void *VAR_3 = CAST(void, VAR_1->parent, \"VAR_3-vscsi\");", "VirtIOSCSI *virtio = CAST(VirtIOSCSI, VAR_1->parent, TYPE_VIRTIO_SCSI);", "USBDevice *usb = CAST(USBDevice, VAR_1->parent, TYPE_USB_DEVICE);", "if (VAR_3) {", "unsigned VAR_6 = 0x8000 | (d->VAR_6 << 8) | d->lun;", "return g_strdup_printf(\"%s@%\"PRIX64, qdev_fw_name(VAR_2),\n(uint64_t)VAR_6 << 48);", "} else if (virtio) {", "unsigned VAR_6 = 0x1000000 | (d->VAR_6 << 16) | d->lun;", "return g_strdup_printf(\"%s@%\"PRIX64, qdev_fw_name(VAR_2),\n(uint64_t)VAR_6 << 32);", "} else if (usb) {", "unsigned VAR_5 = atoi(usb->port->path);", "unsigned VAR_6 = 0x1000000 | (VAR_5 << 16) | d->lun;", "return g_strdup_printf(\"%s@%\"PRIX64, qdev_fw_name(VAR_2),\n(uint64_t)VAR_6 << 32);", "if (strcmp(\"usb-host\", qdev_fw_name(VAR_2)) == 0) {", "USBDevice *usbdev = CAST(USBDevice, VAR_2, TYPE_USB_DEVICE);", "if (usb_host_dev_is_scsi_storage(usbdev)) {", "return g_strdup_printf(\"storage@%s/disk\", usbdev->port->path);", "if (phb) {", "return g_strdup_printf(\"pci@%\"PRIX64, phb->buid);", "if (vsc) {", "unsigned VAR_6 = 0x1000000 | (vsc->target << 16) | vsc->lun;", "return g_strdup_printf(\"disk@%\"PRIX64, (uint64_t)VAR_6 << 32);", "if (g_str_equal(\"pci-bridge\", qdev_fw_name(VAR_2))) {", "PCIDevice *pcidev = CAST(PCIDevice, VAR_2, TYPE_PCI_DEVICE);", "return g_strdup_printf(\"pci@%x\", PCI_SLOT(pcidev->devfn));", "return NULL;" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7, 9, 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 29 ], [ 41 ], [ 43, 45 ], [ 47 ], [ 63 ], [ 69, 71 ], [ 73 ], [ 83 ], [ 85 ], [ 87, 89 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 119 ], [ 123 ], [ 128 ], [ 132 ], [ 134 ], [ 139 ], [ 143 ], [ 145 ], [ 150 ] ]
22,237
static int qemu_rdma_alloc_qp(RDMAContext *rdma) { struct ibv_qp_init_attr attr = { 0 }; int ret; attr.cap.max_send_wr = RDMA_SIGNALED_SEND_MAX; attr.cap.max_recv_wr = 3; attr.cap.max_send_sge = 1; attr.cap.max_recv_sge = 1; attr.send_cq = rdma->cq; attr.recv_cq = rdma->cq; attr.qp_type = IBV_QPT_RC; ret = rdma_create_qp(rdma->cm_id, rdma->pd, &attr); if (ret) { return -1; } rdma->qp = rdma->cm_id->qp; return 0; }
true
qemu
60fe637bf0e4d7989e21e50f52526444765c63b4
static int qemu_rdma_alloc_qp(RDMAContext *rdma) { struct ibv_qp_init_attr attr = { 0 }; int ret; attr.cap.max_send_wr = RDMA_SIGNALED_SEND_MAX; attr.cap.max_recv_wr = 3; attr.cap.max_send_sge = 1; attr.cap.max_recv_sge = 1; attr.send_cq = rdma->cq; attr.recv_cq = rdma->cq; attr.qp_type = IBV_QPT_RC; ret = rdma_create_qp(rdma->cm_id, rdma->pd, &attr); if (ret) { return -1; } rdma->qp = rdma->cm_id->qp; return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(RDMAContext *VAR_0) { struct ibv_qp_init_attr VAR_1 = { 0 }; int VAR_2; VAR_1.cap.max_send_wr = RDMA_SIGNALED_SEND_MAX; VAR_1.cap.max_recv_wr = 3; VAR_1.cap.max_send_sge = 1; VAR_1.cap.max_recv_sge = 1; VAR_1.send_cq = VAR_0->cq; VAR_1.recv_cq = VAR_0->cq; VAR_1.qp_type = IBV_QPT_RC; VAR_2 = rdma_create_qp(VAR_0->cm_id, VAR_0->pd, &VAR_1); if (VAR_2) { return -1; } VAR_0->qp = VAR_0->cm_id->qp; return 0; }
[ "static int FUNC_0(RDMAContext *VAR_0)\n{", "struct ibv_qp_init_attr VAR_1 = { 0 };", "int VAR_2;", "VAR_1.cap.max_send_wr = RDMA_SIGNALED_SEND_MAX;", "VAR_1.cap.max_recv_wr = 3;", "VAR_1.cap.max_send_sge = 1;", "VAR_1.cap.max_recv_sge = 1;", "VAR_1.send_cq = VAR_0->cq;", "VAR_1.recv_cq = VAR_0->cq;", "VAR_1.qp_type = IBV_QPT_RC;", "VAR_2 = rdma_create_qp(VAR_0->cm_id, VAR_0->pd, &VAR_1);", "if (VAR_2) {", "return -1;", "}", "VAR_0->qp = VAR_0->cm_id->qp;", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 37 ], [ 39 ], [ 41 ] ]
22,238
static void qio_channel_websock_handshake_process(QIOChannelWebsock *ioc, char *buffer, Error **errp) { QIOChannelWebsockHTTPHeader hdrs[32]; size_t nhdrs = G_N_ELEMENTS(hdrs); const char *protocols = NULL, *version = NULL, *key = NULL, *host = NULL, *connection = NULL, *upgrade = NULL; nhdrs = qio_channel_websock_extract_headers(ioc, buffer, hdrs, nhdrs, errp); if (!nhdrs) { return; } protocols = qio_channel_websock_find_header( hdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_PROTOCOL); if (!protocols) { error_setg(errp, "Missing websocket protocol header data"); goto bad_request; } version = qio_channel_websock_find_header( hdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_VERSION); if (!version) { error_setg(errp, "Missing websocket version header data"); goto bad_request; } key = qio_channel_websock_find_header( hdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_KEY); if (!key) { error_setg(errp, "Missing websocket key header data"); goto bad_request; } host = qio_channel_websock_find_header( hdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_HOST); if (!host) { error_setg(errp, "Missing websocket host header data"); goto bad_request; } connection = qio_channel_websock_find_header( hdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_CONNECTION); if (!connection) { error_setg(errp, "Missing websocket connection header data"); goto bad_request; } upgrade = qio_channel_websock_find_header( hdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_UPGRADE); if (!upgrade) { error_setg(errp, "Missing websocket upgrade header data"); goto bad_request; } if (!g_strrstr(protocols, QIO_CHANNEL_WEBSOCK_PROTOCOL_BINARY)) { error_setg(errp, "No '%s' protocol is supported by client '%s'", QIO_CHANNEL_WEBSOCK_PROTOCOL_BINARY, protocols); goto bad_request; } if (!g_str_equal(version, QIO_CHANNEL_WEBSOCK_SUPPORTED_VERSION)) { error_setg(errp, "Version '%s' is not supported by client '%s'", QIO_CHANNEL_WEBSOCK_SUPPORTED_VERSION, version); goto bad_request; } if (strlen(key) != QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN) { error_setg(errp, "Key length '%zu' was not as expected '%d'", strlen(key), QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN); goto bad_request; } if (strcasecmp(connection, QIO_CHANNEL_WEBSOCK_CONNECTION_UPGRADE) != 0) { error_setg(errp, "No connection upgrade requested '%s'", connection); goto bad_request; } if (strcasecmp(upgrade, QIO_CHANNEL_WEBSOCK_UPGRADE_WEBSOCKET) != 0) { error_setg(errp, "Incorrect upgrade method '%s'", upgrade); goto bad_request; } qio_channel_websock_handshake_send_res_ok(ioc, key, errp); return; bad_request: qio_channel_websock_handshake_send_res_err( ioc, QIO_CHANNEL_WEBSOCK_HANDSHAKE_RES_BAD_REQUEST); }
true
qemu
6d5d23b00709510d55711661c7ca41408fd9934e
static void qio_channel_websock_handshake_process(QIOChannelWebsock *ioc, char *buffer, Error **errp) { QIOChannelWebsockHTTPHeader hdrs[32]; size_t nhdrs = G_N_ELEMENTS(hdrs); const char *protocols = NULL, *version = NULL, *key = NULL, *host = NULL, *connection = NULL, *upgrade = NULL; nhdrs = qio_channel_websock_extract_headers(ioc, buffer, hdrs, nhdrs, errp); if (!nhdrs) { return; } protocols = qio_channel_websock_find_header( hdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_PROTOCOL); if (!protocols) { error_setg(errp, "Missing websocket protocol header data"); goto bad_request; } version = qio_channel_websock_find_header( hdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_VERSION); if (!version) { error_setg(errp, "Missing websocket version header data"); goto bad_request; } key = qio_channel_websock_find_header( hdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_KEY); if (!key) { error_setg(errp, "Missing websocket key header data"); goto bad_request; } host = qio_channel_websock_find_header( hdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_HOST); if (!host) { error_setg(errp, "Missing websocket host header data"); goto bad_request; } connection = qio_channel_websock_find_header( hdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_CONNECTION); if (!connection) { error_setg(errp, "Missing websocket connection header data"); goto bad_request; } upgrade = qio_channel_websock_find_header( hdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_UPGRADE); if (!upgrade) { error_setg(errp, "Missing websocket upgrade header data"); goto bad_request; } if (!g_strrstr(protocols, QIO_CHANNEL_WEBSOCK_PROTOCOL_BINARY)) { error_setg(errp, "No '%s' protocol is supported by client '%s'", QIO_CHANNEL_WEBSOCK_PROTOCOL_BINARY, protocols); goto bad_request; } if (!g_str_equal(version, QIO_CHANNEL_WEBSOCK_SUPPORTED_VERSION)) { error_setg(errp, "Version '%s' is not supported by client '%s'", QIO_CHANNEL_WEBSOCK_SUPPORTED_VERSION, version); goto bad_request; } if (strlen(key) != QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN) { error_setg(errp, "Key length '%zu' was not as expected '%d'", strlen(key), QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN); goto bad_request; } if (strcasecmp(connection, QIO_CHANNEL_WEBSOCK_CONNECTION_UPGRADE) != 0) { error_setg(errp, "No connection upgrade requested '%s'", connection); goto bad_request; } if (strcasecmp(upgrade, QIO_CHANNEL_WEBSOCK_UPGRADE_WEBSOCKET) != 0) { error_setg(errp, "Incorrect upgrade method '%s'", upgrade); goto bad_request; } qio_channel_websock_handshake_send_res_ok(ioc, key, errp); return; bad_request: qio_channel_websock_handshake_send_res_err( ioc, QIO_CHANNEL_WEBSOCK_HANDSHAKE_RES_BAD_REQUEST); }
{ "code": [ " if (strcasecmp(connection, QIO_CHANNEL_WEBSOCK_CONNECTION_UPGRADE) != 0) {" ], "line_no": [ 149 ] }
static void FUNC_0(QIOChannelWebsock *VAR_0, char *VAR_1, Error **VAR_2) { QIOChannelWebsockHTTPHeader hdrs[32]; size_t nhdrs = G_N_ELEMENTS(hdrs); const char *VAR_3 = NULL, *VAR_4 = NULL, *VAR_5 = NULL, *VAR_6 = NULL, *VAR_7 = NULL, *VAR_8 = NULL; nhdrs = qio_channel_websock_extract_headers(VAR_0, VAR_1, hdrs, nhdrs, VAR_2); if (!nhdrs) { return; } VAR_3 = qio_channel_websock_find_header( hdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_PROTOCOL); if (!VAR_3) { error_setg(VAR_2, "Missing websocket protocol header data"); goto bad_request; } VAR_4 = qio_channel_websock_find_header( hdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_VERSION); if (!VAR_4) { error_setg(VAR_2, "Missing websocket VAR_4 header data"); goto bad_request; } VAR_5 = qio_channel_websock_find_header( hdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_KEY); if (!VAR_5) { error_setg(VAR_2, "Missing websocket VAR_5 header data"); goto bad_request; } VAR_6 = qio_channel_websock_find_header( hdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_HOST); if (!VAR_6) { error_setg(VAR_2, "Missing websocket VAR_6 header data"); goto bad_request; } VAR_7 = qio_channel_websock_find_header( hdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_CONNECTION); if (!VAR_7) { error_setg(VAR_2, "Missing websocket VAR_7 header data"); goto bad_request; } VAR_8 = qio_channel_websock_find_header( hdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_UPGRADE); if (!VAR_8) { error_setg(VAR_2, "Missing websocket VAR_8 header data"); goto bad_request; } if (!g_strrstr(VAR_3, QIO_CHANNEL_WEBSOCK_PROTOCOL_BINARY)) { error_setg(VAR_2, "No '%s' protocol is supported by client '%s'", QIO_CHANNEL_WEBSOCK_PROTOCOL_BINARY, VAR_3); goto bad_request; } if (!g_str_equal(VAR_4, QIO_CHANNEL_WEBSOCK_SUPPORTED_VERSION)) { error_setg(VAR_2, "Version '%s' is not supported by client '%s'", QIO_CHANNEL_WEBSOCK_SUPPORTED_VERSION, VAR_4); goto bad_request; } if (strlen(VAR_5) != QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN) { error_setg(VAR_2, "Key length '%zu' was not as expected '%d'", strlen(VAR_5), QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN); goto bad_request; } if (strcasecmp(VAR_7, QIO_CHANNEL_WEBSOCK_CONNECTION_UPGRADE) != 0) { error_setg(VAR_2, "No VAR_7 VAR_8 requested '%s'", VAR_7); goto bad_request; } if (strcasecmp(VAR_8, QIO_CHANNEL_WEBSOCK_UPGRADE_WEBSOCKET) != 0) { error_setg(VAR_2, "Incorrect VAR_8 method '%s'", VAR_8); goto bad_request; } qio_channel_websock_handshake_send_res_ok(VAR_0, VAR_5, VAR_2); return; bad_request: qio_channel_websock_handshake_send_res_err( VAR_0, QIO_CHANNEL_WEBSOCK_HANDSHAKE_RES_BAD_REQUEST); }
[ "static void FUNC_0(QIOChannelWebsock *VAR_0,\nchar *VAR_1,\nError **VAR_2)\n{", "QIOChannelWebsockHTTPHeader hdrs[32];", "size_t nhdrs = G_N_ELEMENTS(hdrs);", "const char *VAR_3 = NULL, *VAR_4 = NULL, *VAR_5 = NULL,\n*VAR_6 = NULL, *VAR_7 = NULL, *VAR_8 = NULL;", "nhdrs = qio_channel_websock_extract_headers(VAR_0, VAR_1, hdrs, nhdrs, VAR_2);", "if (!nhdrs) {", "return;", "}", "VAR_3 = qio_channel_websock_find_header(\nhdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_PROTOCOL);", "if (!VAR_3) {", "error_setg(VAR_2, \"Missing websocket protocol header data\");", "goto bad_request;", "}", "VAR_4 = qio_channel_websock_find_header(\nhdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_VERSION);", "if (!VAR_4) {", "error_setg(VAR_2, \"Missing websocket VAR_4 header data\");", "goto bad_request;", "}", "VAR_5 = qio_channel_websock_find_header(\nhdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_KEY);", "if (!VAR_5) {", "error_setg(VAR_2, \"Missing websocket VAR_5 header data\");", "goto bad_request;", "}", "VAR_6 = qio_channel_websock_find_header(\nhdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_HOST);", "if (!VAR_6) {", "error_setg(VAR_2, \"Missing websocket VAR_6 header data\");", "goto bad_request;", "}", "VAR_7 = qio_channel_websock_find_header(\nhdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_CONNECTION);", "if (!VAR_7) {", "error_setg(VAR_2, \"Missing websocket VAR_7 header data\");", "goto bad_request;", "}", "VAR_8 = qio_channel_websock_find_header(\nhdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_UPGRADE);", "if (!VAR_8) {", "error_setg(VAR_2, \"Missing websocket VAR_8 header data\");", "goto bad_request;", "}", "if (!g_strrstr(VAR_3, QIO_CHANNEL_WEBSOCK_PROTOCOL_BINARY)) {", "error_setg(VAR_2, \"No '%s' protocol is supported by client '%s'\",\nQIO_CHANNEL_WEBSOCK_PROTOCOL_BINARY, VAR_3);", "goto bad_request;", "}", "if (!g_str_equal(VAR_4, QIO_CHANNEL_WEBSOCK_SUPPORTED_VERSION)) {", "error_setg(VAR_2, \"Version '%s' is not supported by client '%s'\",\nQIO_CHANNEL_WEBSOCK_SUPPORTED_VERSION, VAR_4);", "goto bad_request;", "}", "if (strlen(VAR_5) != QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN) {", "error_setg(VAR_2, \"Key length '%zu' was not as expected '%d'\",\nstrlen(VAR_5), QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN);", "goto bad_request;", "}", "if (strcasecmp(VAR_7, QIO_CHANNEL_WEBSOCK_CONNECTION_UPGRADE) != 0) {", "error_setg(VAR_2, \"No VAR_7 VAR_8 requested '%s'\", VAR_7);", "goto bad_request;", "}", "if (strcasecmp(VAR_8, QIO_CHANNEL_WEBSOCK_UPGRADE_WEBSOCKET) != 0) {", "error_setg(VAR_2, \"Incorrect VAR_8 method '%s'\", VAR_8);", "goto bad_request;", "}", "qio_channel_websock_handshake_send_res_ok(VAR_0, VAR_5, VAR_2);", "return;", "bad_request:\nqio_channel_websock_handshake_send_res_err(\nVAR_0, QIO_CHANNEL_WEBSOCK_HANDSHAKE_RES_BAD_REQUEST);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13, 15 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 29, 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 43, 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 57, 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 71, 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 85, 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 99, 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 113 ], [ 115, 117 ], [ 119 ], [ 121 ], [ 125 ], [ 127, 129 ], [ 131 ], [ 133 ], [ 137 ], [ 139, 141 ], [ 143 ], [ 145 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 169 ], [ 171 ], [ 175, 177, 179 ], [ 181 ] ]