problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
void ahci_command_wait(AHCIQState *ahci, AHCICommand *cmd)
{
while (BITSET(ahci_px_rreg(ahci, cmd->port, AHCI_PX_TFD),
AHCI_PX_TFD_STS_BSY) ||
BITSET(ahci_px_rreg(ahci, cmd->port, AHCI_PX_CI), (1 << cmd->slot))) {
usleep(50);
}
}
| 1threat |
C++ abstract class inheritance : <p>Suppose that I have this piece of code:</p>
<pre><code>class Vehicle {
virtual const char* media() const = 0;
virtual unsigned speed() const = 0;
} V, *PV;
class LandVehicle : public Vehicle {
const char* media() const override{ return "Land";}
} L, *PL;
class Train : public LandVehicle{
virtual unsigned speed() const override {return 130;}
} T, *PT;
</code></pre>
<p>I have a few questions about it :D</p>
<p>1) LandVehicle doesn't implement speed(). is that an error and if so, what kind of error? or does it just make it an abstract class as well ?</p>
<p>2) is the keyword <strong>override</strong> in class LandVehicle in method media() used correctly? as a derived class from an abstract class is it really overriding the method?</p>
<p>3) same as 2 for <strong>override</strong> in Train's speed() method.</p>
<p>4) is Train a concrete class now?</p>
<p>5) is it necessary to add the keyword <strong>virtual</strong> in the declaration of LandVehicle's media() method?</p>
<p>6) if I add this method in Train class:</p>
<pre><code>const char* media() const{ return "Just a train";}
</code></pre>
<p>does it hide LandVehicle's media() or does it override it ?</p>
<p>7) after adding the method in 6, can LandVehicle's media() be accessed in Train class?</p>
| 0debug |
Python 3: Print in a while LOOP : I can get the print statements to display to terminal if I enter a number that is not equivalent to 15. I want to display a message when the input is not 15, but it won't. Only when I enter 15, I get only "Right Guess"
Thanks
x=15
y=10
while x != y:
y = int(input("Please Try to guess the random number: "))
if y < x:
print("Low guess")
elif y > x:
print("High Guess")
else :
print ("Right Guess!") | 0debug |
How to convert cURL to postman? : <p>Postman has built-in function to convert postman to cURL code, but if I want to convert cURL code to postman, How can I do this efficiently?
For example, cURL code as following;</p>
<p>curl -v -X POST "<a href="https://speech.platform.bing.com/recognize?scenarios=smd&appid=D4D52672-91D7-4C74-8AD8-42B1D98141A5&locale=your_locale&device.os=your_device_os&version=3.0&format=json&instanceid=your_instance_id&requestid=your_request_id" rel="noreferrer">https://speech.platform.bing.com/recognize?scenarios=smd&appid=D4D52672-91D7-4C74-8AD8-42B1D98141A5&locale=your_locale&device.os=your_device_os&version=3.0&format=json&instanceid=your_instance_id&requestid=your_request_id</a>" -H 'Authorization: Bearer your_access_token' -H 'Content-type: audio/wav; codec="audio/pcm"; samplerate=16000' --data-binary @your_wave_file</p>
<p>Thanks and Best regards,</p>
| 0debug |
Javascript issue "Unexpected token :" : > Error
Like the title says, I have an error of javascript with
`Uncaught SyntaxError: Unexpected token :`
The result of this error is this:
```
{"id":19728251846714,"properties":null,"quantity":1,"variant_id":19728251846714,"key":"19728251846714:f1a55a69aed71e7c10ca53fd3549edda","title":"Ritual Petalos de rosas y vino tinto - Obispado","price":139900,"original_price":139900,"discounted_price":139900,"line_price":139900,"original_line_price":139900,"total_discount":0,"discounts":[],"sku":"","grams":0,"vendor":"Casa Azul Spa","taxable":false,"product_id":1959512244282,"gift_card":false,"url":"\/products\/ritual-petalos-de-rosas-y-vino-tinto?variant=19728251846714","image":"https:\/\/cdn.shopify.com\/s\/files\/1\/0087\/2267\/7818\/products\/PETALOS_DE_ROSAS_Y_VINO_TINTO.jpg?v=1538589224","handle":"ritual-petalos-de-rosas-y-vino-tinto","requires_shipping":false,"product_type":"","product_title":"Ritual Petalos de rosas y vino tinto","product_description":"\u0026lt;!--\ntd {border: 1px solid #ccc;}br {mso-data-placement:same-cell;}\n--\u003eRitual Pétalos de Rosas y Vino tinto, Exquisito masaje que ofrece bienestar, relajación e hidrata la piel. Realizamos el ritual con mascarilla hidratante y antioxidante, piedras calientes, y cuarzos para ofrecer un delicioso y aromático descanso a todo el cuerpo.","variant_title":"Obispado","variant_options":["Obispado"]}
```
While I was reading the JSON and validate the JSON between multiple platforms I cannot see the error here...
> Code
The following error is due to this function:
```
jQuery.getJSON('/products/'+getProduct.product_handle+'.js', function(product) {
product.variants.forEach(function(variant) {
if (getProduct.sucursal == variant.title){
jQuery.post('/cart/add.js', {
quantity: 1,
id: variant.id
});
}
});
});
```
> Platforms
I'm working with Shopify with the template language Liquid, inside this liquid I have a `<script>` tag that runs AJAX for calling a method from Shopify.
> More information
I know that the error it must have javascript syntax but like I said before I didn't see the error.
**Anyone knows about this error?**
I appreciate every answer. | 0debug |
int kvm_arch_put_registers(CPUState *cs, int level)
{
struct kvm_one_reg reg;
uint32_t fpr;
uint64_t val;
int i;
int ret;
ARMCPU *cpu = ARM_CPU(cs);
CPUARMState *env = &cpu->env;
if (!is_a64(env)) {
aarch64_sync_32_to_64(env);
}
for (i = 0; i < 31; i++) {
reg.id = AARCH64_CORE_REG(regs.regs[i]);
reg.addr = (uintptr_t) &env->xregs[i];
ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®);
if (ret) {
return ret;
}
}
aarch64_save_sp(env, 1);
reg.id = AARCH64_CORE_REG(regs.sp);
reg.addr = (uintptr_t) &env->sp_el[0];
ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®);
if (ret) {
return ret;
}
reg.id = AARCH64_CORE_REG(sp_el1);
reg.addr = (uintptr_t) &env->sp_el[1];
ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®);
if (ret) {
return ret;
}
if (is_a64(env)) {
val = pstate_read(env);
} else {
val = cpsr_read(env);
}
reg.id = AARCH64_CORE_REG(regs.pstate);
reg.addr = (uintptr_t) &val;
ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®);
if (ret) {
return ret;
}
reg.id = AARCH64_CORE_REG(regs.pc);
reg.addr = (uintptr_t) &env->pc;
ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®);
if (ret) {
return ret;
}
reg.id = AARCH64_CORE_REG(elr_el1);
reg.addr = (uintptr_t) &env->elr_el[1];
ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®);
if (ret) {
return ret;
}
for (i = 0; i < KVM_NR_SPSR; i++) {
reg.id = AARCH64_CORE_REG(spsr[i]);
reg.addr = (uintptr_t) &env->banked_spsr[i - 1];
ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®);
if (ret) {
return ret;
}
}
for (i = 0; i < 32; i++) {
int rd = i << 1;
uint64_t fp_val[2];
#ifdef HOST_WORDS_BIGENDIAN
fp_val[0] = env->vfp.regs[rd + 1];
fp_val[1] = env->vfp.regs[rd];
#else
fp_val[1] = env->vfp.regs[rd + 1];
fp_val[0] = env->vfp.regs[rd];
#endif
reg.id = AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]);
reg.addr = (uintptr_t)(&fp_val);
ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®);
if (ret) {
return ret;
}
}
reg.addr = (uintptr_t)(&fpr);
fpr = vfp_get_fpsr(env);
reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpsr);
ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®);
if (ret) {
return ret;
}
fpr = vfp_get_fpcr(env);
reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpcr);
ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®);
if (ret) {
return ret;
}
if (!write_list_to_kvmstate(cpu)) {
return EINVAL;
}
kvm_arm_sync_mpstate_to_kvm(cpu);
return ret;
}
| 1threat |
- Use the `$(inherited)` flag, or - Remove the build settings from the target. CocoaPod Swift3 pod update error : <p>I've been running into a couple of strange errors in terminal when updating cocoapods after updating a Switf2 project to Swift3. Here are the errors:</p>
<pre><code>[!] The `MyShowGuide [Debug]` target overrides the `FRAMEWORK_SEARCH_PATHS` build setting defined in `Pods/Target Support Files/Pods-MyShowGuide/Pods-MyShowGuide.debug.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
[!] The `MyShowGuide [Release]` target overrides the `FRAMEWORK_SEARCH_PATHS` build setting defined in `Pods/Target Support Files/Pods-MyShowGuide/Pods-MyShowGuide.release.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
</code></pre>
<p>So far I've tried numerous ways to try and remedy the issue including deleting derived data and running <code>pod deintegrate/ pod install</code>. I also added <code>$(inherited)</code> to the <code>Other Linker Flags</code> and <code>Header Search Paths</code> but still get the error.</p>
| 0debug |
static av_cold int imc_decode_init(AVCodecContext * avctx)
{
int i, j;
IMCContext *q = avctx->priv_data;
double r1, r2;
q->decoder_reset = 1;
for(i = 0; i < BANDS; i++)
q->old_floor[i] = 1.0;
ff_sine_window_init(q->mdct_sine_window, COEFFS);
for(i = 0; i < COEFFS; i++)
q->mdct_sine_window[i] *= sqrt(2.0);
for(i = 0; i < COEFFS/2; i++){
q->post_cos[i] = (1.0f / 32768) * cos(i / 256.0 * M_PI);
q->post_sin[i] = (1.0f / 32768) * sin(i / 256.0 * M_PI);
r1 = sin((i * 4.0 + 1.0) / 1024.0 * M_PI);
r2 = cos((i * 4.0 + 1.0) / 1024.0 * M_PI);
if (i & 0x1)
{
q->pre_coef1[i] = (r1 + r2) * sqrt(2.0);
q->pre_coef2[i] = -(r1 - r2) * sqrt(2.0);
}
else
{
q->pre_coef1[i] = -(r1 + r2) * sqrt(2.0);
q->pre_coef2[i] = (r1 - r2) * sqrt(2.0);
}
q->last_fft_im[i] = 0;
}
for(i = 0; i < 30; i++) {
q->sqrt_tab[i] = sqrt(i);
}
for(i = 0; i < 4 ; i++) {
for(j = 0; j < 4; j++) {
huffman_vlc[i][j].table = &vlc_tables[vlc_offsets[i * 4 + j]];
huffman_vlc[i][j].table_allocated = vlc_offsets[i * 4 + j + 1] - vlc_offsets[i * 4 + j];
init_vlc(&huffman_vlc[i][j], 9, imc_huffman_sizes[i],
imc_huffman_lens[i][j], 1, 1,
imc_huffman_bits[i][j], 2, 2, INIT_VLC_USE_NEW_STATIC);
}
}
q->one_div_log2 = 1/log(2);
ff_fft_init(&q->fft, 7, 1);
dsputil_init(&q->dsp, avctx);
avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;
return 0;
}
| 1threat |
what is the mistake i made this program it will through runtime error? : <p><a href="https://i.stack.imgur.com/qmtxx.png" rel="nofollow noreferrer">Insert the element in last using single link list . please suggest what is the mistake i made . i shows run time error </a></p>
| 0debug |
static void test_native_list_integer_helper(TestInputVisitorData *data,
const void *unused,
UserDefNativeListUnionKind kind)
{
UserDefNativeListUnion *cvalue = NULL;
Visitor *v;
GString *gstr_list = g_string_new("");
GString *gstr_union = g_string_new("");
int i;
for (i = 0; i < 32; i++) {
g_string_append_printf(gstr_list, "%d", i);
if (i != 31) {
g_string_append(gstr_list, ", ");
}
}
g_string_append_printf(gstr_union, "{ 'type': '%s', 'data': [ %s ] }",
UserDefNativeListUnionKind_lookup[kind],
gstr_list->str);
v = visitor_input_test_init_raw(data, gstr_union->str);
visit_type_UserDefNativeListUnion(v, NULL, &cvalue, &error_abort);
g_assert(cvalue != NULL);
g_assert_cmpint(cvalue->type, ==, kind);
switch (kind) {
case USER_DEF_NATIVE_LIST_UNION_KIND_INTEGER: {
intList *elem = NULL;
for (i = 0, elem = cvalue->u.integer.data;
elem; elem = elem->next, i++) {
g_assert_cmpint(elem->value, ==, i);
}
break;
}
case USER_DEF_NATIVE_LIST_UNION_KIND_S8: {
int8List *elem = NULL;
for (i = 0, elem = cvalue->u.s8.data; elem; elem = elem->next, i++) {
g_assert_cmpint(elem->value, ==, i);
}
break;
}
case USER_DEF_NATIVE_LIST_UNION_KIND_S16: {
int16List *elem = NULL;
for (i = 0, elem = cvalue->u.s16.data; elem; elem = elem->next, i++) {
g_assert_cmpint(elem->value, ==, i);
}
break;
}
case USER_DEF_NATIVE_LIST_UNION_KIND_S32: {
int32List *elem = NULL;
for (i = 0, elem = cvalue->u.s32.data; elem; elem = elem->next, i++) {
g_assert_cmpint(elem->value, ==, i);
}
break;
}
case USER_DEF_NATIVE_LIST_UNION_KIND_S64: {
int64List *elem = NULL;
for (i = 0, elem = cvalue->u.s64.data; elem; elem = elem->next, i++) {
g_assert_cmpint(elem->value, ==, i);
}
break;
}
case USER_DEF_NATIVE_LIST_UNION_KIND_U8: {
uint8List *elem = NULL;
for (i = 0, elem = cvalue->u.u8.data; elem; elem = elem->next, i++) {
g_assert_cmpint(elem->value, ==, i);
}
break;
}
case USER_DEF_NATIVE_LIST_UNION_KIND_U16: {
uint16List *elem = NULL;
for (i = 0, elem = cvalue->u.u16.data; elem; elem = elem->next, i++) {
g_assert_cmpint(elem->value, ==, i);
}
break;
}
case USER_DEF_NATIVE_LIST_UNION_KIND_U32: {
uint32List *elem = NULL;
for (i = 0, elem = cvalue->u.u32.data; elem; elem = elem->next, i++) {
g_assert_cmpint(elem->value, ==, i);
}
break;
}
case USER_DEF_NATIVE_LIST_UNION_KIND_U64: {
uint64List *elem = NULL;
for (i = 0, elem = cvalue->u.u64.data; elem; elem = elem->next, i++) {
g_assert_cmpint(elem->value, ==, i);
}
break;
}
default:
g_assert_not_reached();
}
g_string_free(gstr_union, true);
g_string_free(gstr_list, true);
qapi_free_UserDefNativeListUnion(cvalue);
}
| 1threat |
static target_ulong disas_insn(DisasContext *s, target_ulong pc_start)
{
int b, prefixes, aflag, dflag;
int shift, ot;
int modrm, reg, rm, mod, reg_addr, op, opreg, offset_addr, val;
target_ulong next_eip, tval;
int rex_w, rex_r;
if (unlikely(loglevel & CPU_LOG_TB_OP))
tcg_gen_debug_insn_start(pc_start);
s->pc = pc_start;
prefixes = 0;
aflag = s->code32;
dflag = s->code32;
s->override = -1;
rex_w = -1;
rex_r = 0;
#ifdef TARGET_X86_64
s->rex_x = 0;
s->rex_b = 0;
x86_64_hregs = 0;
#endif
s->rip_offset = 0;
next_byte:
b = ldub_code(s->pc);
s->pc++;
#ifdef TARGET_X86_64
if (CODE64(s)) {
switch (b) {
case 0xf3:
prefixes |= PREFIX_REPZ;
goto next_byte;
case 0xf2:
prefixes |= PREFIX_REPNZ;
goto next_byte;
case 0xf0:
prefixes |= PREFIX_LOCK;
goto next_byte;
case 0x2e:
s->override = R_CS;
goto next_byte;
case 0x36:
s->override = R_SS;
goto next_byte;
case 0x3e:
s->override = R_DS;
goto next_byte;
case 0x26:
s->override = R_ES;
goto next_byte;
case 0x64:
s->override = R_FS;
goto next_byte;
case 0x65:
s->override = R_GS;
goto next_byte;
case 0x66:
prefixes |= PREFIX_DATA;
goto next_byte;
case 0x67:
prefixes |= PREFIX_ADR;
goto next_byte;
case 0x40 ... 0x4f:
rex_w = (b >> 3) & 1;
rex_r = (b & 0x4) << 1;
s->rex_x = (b & 0x2) << 2;
REX_B(s) = (b & 0x1) << 3;
x86_64_hregs = 1;
goto next_byte;
}
if (rex_w == 1) {
dflag = 2;
} else {
if (prefixes & PREFIX_DATA)
dflag ^= 1;
}
if (!(prefixes & PREFIX_ADR))
aflag = 2;
} else
#endif
{
switch (b) {
case 0xf3:
prefixes |= PREFIX_REPZ;
goto next_byte;
case 0xf2:
prefixes |= PREFIX_REPNZ;
goto next_byte;
case 0xf0:
prefixes |= PREFIX_LOCK;
goto next_byte;
case 0x2e:
s->override = R_CS;
goto next_byte;
case 0x36:
s->override = R_SS;
goto next_byte;
case 0x3e:
s->override = R_DS;
goto next_byte;
case 0x26:
s->override = R_ES;
goto next_byte;
case 0x64:
s->override = R_FS;
goto next_byte;
case 0x65:
s->override = R_GS;
goto next_byte;
case 0x66:
prefixes |= PREFIX_DATA;
goto next_byte;
case 0x67:
prefixes |= PREFIX_ADR;
goto next_byte;
}
if (prefixes & PREFIX_DATA)
dflag ^= 1;
if (prefixes & PREFIX_ADR)
aflag ^= 1;
}
s->prefix = prefixes;
s->aflag = aflag;
s->dflag = dflag;
if (prefixes & PREFIX_LOCK)
gen_helper_lock();
reswitch:
switch(b) {
case 0x0f:
b = ldub_code(s->pc++) | 0x100;
goto reswitch;
case 0x00 ... 0x05:
case 0x08 ... 0x0d:
case 0x10 ... 0x15:
case 0x18 ... 0x1d:
case 0x20 ... 0x25:
case 0x28 ... 0x2d:
case 0x30 ... 0x35:
case 0x38 ... 0x3d:
{
int op, f, val;
op = (b >> 3) & 7;
f = (b >> 1) & 3;
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
switch(f) {
case 0:
modrm = ldub_code(s->pc++);
reg = ((modrm >> 3) & 7) | rex_r;
mod = (modrm >> 6) & 3;
rm = (modrm & 7) | REX_B(s);
if (mod != 3) {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
opreg = OR_TMP0;
} else if (op == OP_XORL && rm == reg) {
xor_zero:
gen_op_movl_T0_0();
s->cc_op = CC_OP_LOGICB + ot;
gen_op_mov_reg_T0(ot, reg);
gen_op_update1_cc();
break;
} else {
opreg = rm;
}
gen_op_mov_TN_reg(ot, 1, reg);
gen_op(s, op, ot, opreg);
break;
case 1:
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
reg = ((modrm >> 3) & 7) | rex_r;
rm = (modrm & 7) | REX_B(s);
if (mod != 3) {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_ld_T1_A0(ot + s->mem_index);
} else if (op == OP_XORL && rm == reg) {
goto xor_zero;
} else {
gen_op_mov_TN_reg(ot, 1, rm);
}
gen_op(s, op, ot, reg);
break;
case 2:
val = insn_get(s, ot);
gen_op_movl_T1_im(val);
gen_op(s, op, ot, OR_EAX);
break;
}
}
break;
case 0x82:
if (CODE64(s))
goto illegal_op;
case 0x80:
case 0x81:
case 0x83:
{
int val;
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
rm = (modrm & 7) | REX_B(s);
op = (modrm >> 3) & 7;
if (mod != 3) {
if (b == 0x83)
s->rip_offset = 1;
else
s->rip_offset = insn_const_size(ot);
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
opreg = OR_TMP0;
} else {
opreg = rm;
}
switch(b) {
default:
case 0x80:
case 0x81:
case 0x82:
val = insn_get(s, ot);
break;
case 0x83:
val = (int8_t)insn_get(s, OT_BYTE);
break;
}
gen_op_movl_T1_im(val);
gen_op(s, op, ot, opreg);
}
break;
case 0x40 ... 0x47:
ot = dflag ? OT_LONG : OT_WORD;
gen_inc(s, ot, OR_EAX + (b & 7), 1);
break;
case 0x48 ... 0x4f:
ot = dflag ? OT_LONG : OT_WORD;
gen_inc(s, ot, OR_EAX + (b & 7), -1);
break;
case 0xf6:
case 0xf7:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
rm = (modrm & 7) | REX_B(s);
op = (modrm >> 3) & 7;
if (mod != 3) {
if (op == 0)
s->rip_offset = insn_const_size(ot);
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_ld_T0_A0(ot + s->mem_index);
} else {
gen_op_mov_TN_reg(ot, 0, rm);
}
switch(op) {
case 0:
val = insn_get(s, ot);
gen_op_movl_T1_im(val);
gen_op_testl_T0_T1_cc();
s->cc_op = CC_OP_LOGICB + ot;
break;
case 2:
tcg_gen_not_tl(cpu_T[0], cpu_T[0]);
if (mod != 3) {
gen_op_st_T0_A0(ot + s->mem_index);
} else {
gen_op_mov_reg_T0(ot, rm);
}
break;
case 3:
tcg_gen_neg_tl(cpu_T[0], cpu_T[0]);
if (mod != 3) {
gen_op_st_T0_A0(ot + s->mem_index);
} else {
gen_op_mov_reg_T0(ot, rm);
}
gen_op_update_neg_cc();
s->cc_op = CC_OP_SUBB + ot;
break;
case 4:
switch(ot) {
case OT_BYTE:
gen_op_mov_TN_reg(OT_BYTE, 1, R_EAX);
tcg_gen_ext8u_tl(cpu_T[0], cpu_T[0]);
tcg_gen_ext8u_tl(cpu_T[1], cpu_T[1]);
tcg_gen_mul_tl(cpu_T[0], cpu_T[0], cpu_T[1]);
gen_op_mov_reg_T0(OT_WORD, R_EAX);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);
tcg_gen_andi_tl(cpu_cc_src, cpu_T[0], 0xff00);
s->cc_op = CC_OP_MULB;
break;
case OT_WORD:
gen_op_mov_TN_reg(OT_WORD, 1, R_EAX);
tcg_gen_ext16u_tl(cpu_T[0], cpu_T[0]);
tcg_gen_ext16u_tl(cpu_T[1], cpu_T[1]);
tcg_gen_mul_tl(cpu_T[0], cpu_T[0], cpu_T[1]);
gen_op_mov_reg_T0(OT_WORD, R_EAX);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);
tcg_gen_shri_tl(cpu_T[0], cpu_T[0], 16);
gen_op_mov_reg_T0(OT_WORD, R_EDX);
tcg_gen_mov_tl(cpu_cc_src, cpu_T[0]);
s->cc_op = CC_OP_MULW;
break;
default:
case OT_LONG:
#ifdef TARGET_X86_64
gen_op_mov_TN_reg(OT_LONG, 1, R_EAX);
tcg_gen_ext32u_tl(cpu_T[0], cpu_T[0]);
tcg_gen_ext32u_tl(cpu_T[1], cpu_T[1]);
tcg_gen_mul_tl(cpu_T[0], cpu_T[0], cpu_T[1]);
gen_op_mov_reg_T0(OT_LONG, R_EAX);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);
tcg_gen_shri_tl(cpu_T[0], cpu_T[0], 32);
gen_op_mov_reg_T0(OT_LONG, R_EDX);
tcg_gen_mov_tl(cpu_cc_src, cpu_T[0]);
#else
{
TCGv_i64 t0, t1;
t0 = tcg_temp_new_i64();
t1 = tcg_temp_new_i64();
gen_op_mov_TN_reg(OT_LONG, 1, R_EAX);
tcg_gen_extu_i32_i64(t0, cpu_T[0]);
tcg_gen_extu_i32_i64(t1, cpu_T[1]);
tcg_gen_mul_i64(t0, t0, t1);
tcg_gen_trunc_i64_i32(cpu_T[0], t0);
gen_op_mov_reg_T0(OT_LONG, R_EAX);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);
tcg_gen_shri_i64(t0, t0, 32);
tcg_gen_trunc_i64_i32(cpu_T[0], t0);
gen_op_mov_reg_T0(OT_LONG, R_EDX);
tcg_gen_mov_tl(cpu_cc_src, cpu_T[0]);
}
#endif
s->cc_op = CC_OP_MULL;
break;
#ifdef TARGET_X86_64
case OT_QUAD:
gen_helper_mulq_EAX_T0(cpu_T[0]);
s->cc_op = CC_OP_MULQ;
break;
#endif
}
break;
case 5:
switch(ot) {
case OT_BYTE:
gen_op_mov_TN_reg(OT_BYTE, 1, R_EAX);
tcg_gen_ext8s_tl(cpu_T[0], cpu_T[0]);
tcg_gen_ext8s_tl(cpu_T[1], cpu_T[1]);
tcg_gen_mul_tl(cpu_T[0], cpu_T[0], cpu_T[1]);
gen_op_mov_reg_T0(OT_WORD, R_EAX);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);
tcg_gen_ext8s_tl(cpu_tmp0, cpu_T[0]);
tcg_gen_sub_tl(cpu_cc_src, cpu_T[0], cpu_tmp0);
s->cc_op = CC_OP_MULB;
break;
case OT_WORD:
gen_op_mov_TN_reg(OT_WORD, 1, R_EAX);
tcg_gen_ext16s_tl(cpu_T[0], cpu_T[0]);
tcg_gen_ext16s_tl(cpu_T[1], cpu_T[1]);
tcg_gen_mul_tl(cpu_T[0], cpu_T[0], cpu_T[1]);
gen_op_mov_reg_T0(OT_WORD, R_EAX);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);
tcg_gen_ext16s_tl(cpu_tmp0, cpu_T[0]);
tcg_gen_sub_tl(cpu_cc_src, cpu_T[0], cpu_tmp0);
tcg_gen_shri_tl(cpu_T[0], cpu_T[0], 16);
gen_op_mov_reg_T0(OT_WORD, R_EDX);
s->cc_op = CC_OP_MULW;
break;
default:
case OT_LONG:
#ifdef TARGET_X86_64
gen_op_mov_TN_reg(OT_LONG, 1, R_EAX);
tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
tcg_gen_ext32s_tl(cpu_T[1], cpu_T[1]);
tcg_gen_mul_tl(cpu_T[0], cpu_T[0], cpu_T[1]);
gen_op_mov_reg_T0(OT_LONG, R_EAX);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);
tcg_gen_ext32s_tl(cpu_tmp0, cpu_T[0]);
tcg_gen_sub_tl(cpu_cc_src, cpu_T[0], cpu_tmp0);
tcg_gen_shri_tl(cpu_T[0], cpu_T[0], 32);
gen_op_mov_reg_T0(OT_LONG, R_EDX);
#else
{
TCGv_i64 t0, t1;
t0 = tcg_temp_new_i64();
t1 = tcg_temp_new_i64();
gen_op_mov_TN_reg(OT_LONG, 1, R_EAX);
tcg_gen_ext_i32_i64(t0, cpu_T[0]);
tcg_gen_ext_i32_i64(t1, cpu_T[1]);
tcg_gen_mul_i64(t0, t0, t1);
tcg_gen_trunc_i64_i32(cpu_T[0], t0);
gen_op_mov_reg_T0(OT_LONG, R_EAX);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);
tcg_gen_sari_tl(cpu_tmp0, cpu_T[0], 31);
tcg_gen_shri_i64(t0, t0, 32);
tcg_gen_trunc_i64_i32(cpu_T[0], t0);
gen_op_mov_reg_T0(OT_LONG, R_EDX);
tcg_gen_sub_tl(cpu_cc_src, cpu_T[0], cpu_tmp0);
}
#endif
s->cc_op = CC_OP_MULL;
break;
#ifdef TARGET_X86_64
case OT_QUAD:
gen_helper_imulq_EAX_T0(cpu_T[0]);
s->cc_op = CC_OP_MULQ;
break;
#endif
}
break;
case 6:
switch(ot) {
case OT_BYTE:
gen_jmp_im(pc_start - s->cs_base);
gen_helper_divb_AL(cpu_T[0]);
break;
case OT_WORD:
gen_jmp_im(pc_start - s->cs_base);
gen_helper_divw_AX(cpu_T[0]);
break;
default:
case OT_LONG:
gen_jmp_im(pc_start - s->cs_base);
gen_helper_divl_EAX(cpu_T[0]);
break;
#ifdef TARGET_X86_64
case OT_QUAD:
gen_jmp_im(pc_start - s->cs_base);
gen_helper_divq_EAX(cpu_T[0]);
break;
#endif
}
break;
case 7:
switch(ot) {
case OT_BYTE:
gen_jmp_im(pc_start - s->cs_base);
gen_helper_idivb_AL(cpu_T[0]);
break;
case OT_WORD:
gen_jmp_im(pc_start - s->cs_base);
gen_helper_idivw_AX(cpu_T[0]);
break;
default:
case OT_LONG:
gen_jmp_im(pc_start - s->cs_base);
gen_helper_idivl_EAX(cpu_T[0]);
break;
#ifdef TARGET_X86_64
case OT_QUAD:
gen_jmp_im(pc_start - s->cs_base);
gen_helper_idivq_EAX(cpu_T[0]);
break;
#endif
}
break;
default:
goto illegal_op;
}
break;
case 0xfe:
case 0xff:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
rm = (modrm & 7) | REX_B(s);
op = (modrm >> 3) & 7;
if (op >= 2 && b == 0xfe) {
goto illegal_op;
}
if (CODE64(s)) {
if (op == 2 || op == 4) {
ot = OT_QUAD;
} else if (op == 3 || op == 5) {
ot = dflag ? OT_LONG : OT_WORD;
} else if (op == 6) {
ot = dflag ? OT_QUAD : OT_WORD;
}
}
if (mod != 3) {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
if (op >= 2 && op != 3 && op != 5)
gen_op_ld_T0_A0(ot + s->mem_index);
} else {
gen_op_mov_TN_reg(ot, 0, rm);
}
switch(op) {
case 0:
if (mod != 3)
opreg = OR_TMP0;
else
opreg = rm;
gen_inc(s, ot, opreg, 1);
break;
case 1:
if (mod != 3)
opreg = OR_TMP0;
else
opreg = rm;
gen_inc(s, ot, opreg, -1);
break;
case 2:
if (s->dflag == 0)
gen_op_andl_T0_ffff();
next_eip = s->pc - s->cs_base;
gen_movtl_T1_im(next_eip);
gen_push_T1(s);
gen_op_jmp_T0();
gen_eob(s);
break;
case 3:
gen_op_ld_T1_A0(ot + s->mem_index);
gen_add_A0_im(s, 1 << (ot - OT_WORD + 1));
gen_op_ldu_T0_A0(OT_WORD + s->mem_index);
do_lcall:
if (s->pe && !s->vm86) {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_lcall_protected(cpu_tmp2_i32, cpu_T[1],
tcg_const_i32(dflag),
tcg_const_i32(s->pc - pc_start));
} else {
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_lcall_real(cpu_tmp2_i32, cpu_T[1],
tcg_const_i32(dflag),
tcg_const_i32(s->pc - s->cs_base));
}
gen_eob(s);
break;
case 4:
if (s->dflag == 0)
gen_op_andl_T0_ffff();
gen_op_jmp_T0();
gen_eob(s);
break;
case 5:
gen_op_ld_T1_A0(ot + s->mem_index);
gen_add_A0_im(s, 1 << (ot - OT_WORD + 1));
gen_op_ldu_T0_A0(OT_WORD + s->mem_index);
do_ljmp:
if (s->pe && !s->vm86) {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_ljmp_protected(cpu_tmp2_i32, cpu_T[1],
tcg_const_i32(s->pc - pc_start));
} else {
gen_op_movl_seg_T0_vm(R_CS);
gen_op_movl_T0_T1();
gen_op_jmp_T0();
}
gen_eob(s);
break;
case 6:
gen_push_T0(s);
break;
default:
goto illegal_op;
}
break;
case 0x84:
case 0x85:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
rm = (modrm & 7) | REX_B(s);
reg = ((modrm >> 3) & 7) | rex_r;
gen_ldst_modrm(s, modrm, ot, OR_TMP0, 0);
gen_op_mov_TN_reg(ot, 1, reg);
gen_op_testl_T0_T1_cc();
s->cc_op = CC_OP_LOGICB + ot;
break;
case 0xa8:
case 0xa9:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
val = insn_get(s, ot);
gen_op_mov_TN_reg(ot, 0, OR_EAX);
gen_op_movl_T1_im(val);
gen_op_testl_T0_T1_cc();
s->cc_op = CC_OP_LOGICB + ot;
break;
case 0x98:
#ifdef TARGET_X86_64
if (dflag == 2) {
gen_op_mov_TN_reg(OT_LONG, 0, R_EAX);
tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
gen_op_mov_reg_T0(OT_QUAD, R_EAX);
} else
#endif
if (dflag == 1) {
gen_op_mov_TN_reg(OT_WORD, 0, R_EAX);
tcg_gen_ext16s_tl(cpu_T[0], cpu_T[0]);
gen_op_mov_reg_T0(OT_LONG, R_EAX);
} else {
gen_op_mov_TN_reg(OT_BYTE, 0, R_EAX);
tcg_gen_ext8s_tl(cpu_T[0], cpu_T[0]);
gen_op_mov_reg_T0(OT_WORD, R_EAX);
}
break;
case 0x99:
#ifdef TARGET_X86_64
if (dflag == 2) {
gen_op_mov_TN_reg(OT_QUAD, 0, R_EAX);
tcg_gen_sari_tl(cpu_T[0], cpu_T[0], 63);
gen_op_mov_reg_T0(OT_QUAD, R_EDX);
} else
#endif
if (dflag == 1) {
gen_op_mov_TN_reg(OT_LONG, 0, R_EAX);
tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
tcg_gen_sari_tl(cpu_T[0], cpu_T[0], 31);
gen_op_mov_reg_T0(OT_LONG, R_EDX);
} else {
gen_op_mov_TN_reg(OT_WORD, 0, R_EAX);
tcg_gen_ext16s_tl(cpu_T[0], cpu_T[0]);
tcg_gen_sari_tl(cpu_T[0], cpu_T[0], 15);
gen_op_mov_reg_T0(OT_WORD, R_EDX);
}
break;
case 0x1af:
case 0x69:
case 0x6b:
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
reg = ((modrm >> 3) & 7) | rex_r;
if (b == 0x69)
s->rip_offset = insn_const_size(ot);
else if (b == 0x6b)
s->rip_offset = 1;
gen_ldst_modrm(s, modrm, ot, OR_TMP0, 0);
if (b == 0x69) {
val = insn_get(s, ot);
gen_op_movl_T1_im(val);
} else if (b == 0x6b) {
val = (int8_t)insn_get(s, OT_BYTE);
gen_op_movl_T1_im(val);
} else {
gen_op_mov_TN_reg(ot, 1, reg);
}
#ifdef TARGET_X86_64
if (ot == OT_QUAD) {
gen_helper_imulq_T0_T1(cpu_T[0], cpu_T[0], cpu_T[1]);
} else
#endif
if (ot == OT_LONG) {
#ifdef TARGET_X86_64
tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
tcg_gen_ext32s_tl(cpu_T[1], cpu_T[1]);
tcg_gen_mul_tl(cpu_T[0], cpu_T[0], cpu_T[1]);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);
tcg_gen_ext32s_tl(cpu_tmp0, cpu_T[0]);
tcg_gen_sub_tl(cpu_cc_src, cpu_T[0], cpu_tmp0);
#else
{
TCGv_i64 t0, t1;
t0 = tcg_temp_new_i64();
t1 = tcg_temp_new_i64();
tcg_gen_ext_i32_i64(t0, cpu_T[0]);
tcg_gen_ext_i32_i64(t1, cpu_T[1]);
tcg_gen_mul_i64(t0, t0, t1);
tcg_gen_trunc_i64_i32(cpu_T[0], t0);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);
tcg_gen_sari_tl(cpu_tmp0, cpu_T[0], 31);
tcg_gen_shri_i64(t0, t0, 32);
tcg_gen_trunc_i64_i32(cpu_T[1], t0);
tcg_gen_sub_tl(cpu_cc_src, cpu_T[1], cpu_tmp0);
}
#endif
} else {
tcg_gen_ext16s_tl(cpu_T[0], cpu_T[0]);
tcg_gen_ext16s_tl(cpu_T[1], cpu_T[1]);
tcg_gen_mul_tl(cpu_T[0], cpu_T[0], cpu_T[1]);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);
tcg_gen_ext16s_tl(cpu_tmp0, cpu_T[0]);
tcg_gen_sub_tl(cpu_cc_src, cpu_T[0], cpu_tmp0);
}
gen_op_mov_reg_T0(ot, reg);
s->cc_op = CC_OP_MULB + ot;
break;
case 0x1c0:
case 0x1c1:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
reg = ((modrm >> 3) & 7) | rex_r;
mod = (modrm >> 6) & 3;
if (mod == 3) {
rm = (modrm & 7) | REX_B(s);
gen_op_mov_TN_reg(ot, 0, reg);
gen_op_mov_TN_reg(ot, 1, rm);
gen_op_addl_T0_T1();
gen_op_mov_reg_T1(ot, reg);
gen_op_mov_reg_T0(ot, rm);
} else {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_mov_TN_reg(ot, 0, reg);
gen_op_ld_T1_A0(ot + s->mem_index);
gen_op_addl_T0_T1();
gen_op_st_T0_A0(ot + s->mem_index);
gen_op_mov_reg_T1(ot, reg);
}
gen_op_update2_cc();
s->cc_op = CC_OP_ADDB + ot;
break;
case 0x1b0:
case 0x1b1:
{
int label1, label2;
TCGv t0, t1, t2, a0;
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
reg = ((modrm >> 3) & 7) | rex_r;
mod = (modrm >> 6) & 3;
t0 = tcg_temp_local_new();
t1 = tcg_temp_local_new();
t2 = tcg_temp_local_new();
a0 = tcg_temp_local_new();
gen_op_mov_v_reg(ot, t1, reg);
if (mod == 3) {
rm = (modrm & 7) | REX_B(s);
gen_op_mov_v_reg(ot, t0, rm);
} else {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
tcg_gen_mov_tl(a0, cpu_A0);
gen_op_ld_v(ot + s->mem_index, t0, a0);
rm = 0;
}
label1 = gen_new_label();
tcg_gen_ld_tl(t2, cpu_env, offsetof(CPUState, regs[R_EAX]));
tcg_gen_sub_tl(t2, t2, t0);
gen_extu(ot, t2);
tcg_gen_brcondi_tl(TCG_COND_EQ, t2, 0, label1);
if (mod == 3) {
label2 = gen_new_label();
gen_op_mov_reg_v(ot, R_EAX, t0);
tcg_gen_br(label2);
gen_set_label(label1);
gen_op_mov_reg_v(ot, rm, t1);
gen_set_label(label2);
} else {
tcg_gen_mov_tl(t1, t0);
gen_op_mov_reg_v(ot, R_EAX, t0);
gen_set_label(label1);
gen_op_st_v(ot + s->mem_index, t1, a0);
}
tcg_gen_mov_tl(cpu_cc_src, t0);
tcg_gen_mov_tl(cpu_cc_dst, t2);
s->cc_op = CC_OP_SUBB + ot;
tcg_temp_free(t0);
tcg_temp_free(t1);
tcg_temp_free(t2);
tcg_temp_free(a0);
}
break;
case 0x1c7:
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
if ((mod == 3) || ((modrm & 0x38) != 0x8))
goto illegal_op;
#ifdef TARGET_X86_64
if (dflag == 2) {
if (!(s->cpuid_ext_features & CPUID_EXT_CX16))
goto illegal_op;
gen_jmp_im(pc_start - s->cs_base);
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_helper_cmpxchg16b(cpu_A0);
} else
#endif
{
if (!(s->cpuid_features & CPUID_CX8))
goto illegal_op;
gen_jmp_im(pc_start - s->cs_base);
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_helper_cmpxchg8b(cpu_A0);
}
s->cc_op = CC_OP_EFLAGS;
break;
case 0x50 ... 0x57:
gen_op_mov_TN_reg(OT_LONG, 0, (b & 7) | REX_B(s));
gen_push_T0(s);
break;
case 0x58 ... 0x5f:
if (CODE64(s)) {
ot = dflag ? OT_QUAD : OT_WORD;
} else {
ot = dflag + OT_WORD;
}
gen_pop_T0(s);
gen_pop_update(s);
gen_op_mov_reg_T0(ot, (b & 7) | REX_B(s));
break;
case 0x60:
if (CODE64(s))
goto illegal_op;
gen_pusha(s);
break;
case 0x61:
if (CODE64(s))
goto illegal_op;
gen_popa(s);
break;
case 0x68:
case 0x6a:
if (CODE64(s)) {
ot = dflag ? OT_QUAD : OT_WORD;
} else {
ot = dflag + OT_WORD;
}
if (b == 0x68)
val = insn_get(s, ot);
else
val = (int8_t)insn_get(s, OT_BYTE);
gen_op_movl_T0_im(val);
gen_push_T0(s);
break;
case 0x8f:
if (CODE64(s)) {
ot = dflag ? OT_QUAD : OT_WORD;
} else {
ot = dflag + OT_WORD;
}
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
gen_pop_T0(s);
if (mod == 3) {
gen_pop_update(s);
rm = (modrm & 7) | REX_B(s);
gen_op_mov_reg_T0(ot, rm);
} else {
s->popl_esp_hack = 1 << ot;
gen_ldst_modrm(s, modrm, ot, OR_TMP0, 1);
s->popl_esp_hack = 0;
gen_pop_update(s);
}
break;
case 0xc8:
{
int level;
val = lduw_code(s->pc);
s->pc += 2;
level = ldub_code(s->pc++);
gen_enter(s, val, level);
}
break;
case 0xc9:
if (CODE64(s)) {
gen_op_mov_TN_reg(OT_QUAD, 0, R_EBP);
gen_op_mov_reg_T0(OT_QUAD, R_ESP);
} else if (s->ss32) {
gen_op_mov_TN_reg(OT_LONG, 0, R_EBP);
gen_op_mov_reg_T0(OT_LONG, R_ESP);
} else {
gen_op_mov_TN_reg(OT_WORD, 0, R_EBP);
gen_op_mov_reg_T0(OT_WORD, R_ESP);
}
gen_pop_T0(s);
if (CODE64(s)) {
ot = dflag ? OT_QUAD : OT_WORD;
} else {
ot = dflag + OT_WORD;
}
gen_op_mov_reg_T0(ot, R_EBP);
gen_pop_update(s);
break;
case 0x06:
case 0x0e:
case 0x16:
case 0x1e:
if (CODE64(s))
goto illegal_op;
gen_op_movl_T0_seg(b >> 3);
gen_push_T0(s);
break;
case 0x1a0:
case 0x1a8:
gen_op_movl_T0_seg((b >> 3) & 7);
gen_push_T0(s);
break;
case 0x07:
case 0x17:
case 0x1f:
if (CODE64(s))
goto illegal_op;
reg = b >> 3;
gen_pop_T0(s);
gen_movl_seg_T0(s, reg, pc_start - s->cs_base);
gen_pop_update(s);
if (reg == R_SS) {
if (!(s->tb->flags & HF_INHIBIT_IRQ_MASK))
gen_helper_set_inhibit_irq();
s->tf = 0;
}
if (s->is_jmp) {
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
}
break;
case 0x1a1:
case 0x1a9:
gen_pop_T0(s);
gen_movl_seg_T0(s, (b >> 3) & 7, pc_start - s->cs_base);
gen_pop_update(s);
if (s->is_jmp) {
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
}
break;
case 0x88:
case 0x89:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
reg = ((modrm >> 3) & 7) | rex_r;
gen_ldst_modrm(s, modrm, ot, reg, 1);
break;
case 0xc6:
case 0xc7:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
if (mod != 3) {
s->rip_offset = insn_const_size(ot);
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
}
val = insn_get(s, ot);
gen_op_movl_T0_im(val);
if (mod != 3)
gen_op_st_T0_A0(ot + s->mem_index);
else
gen_op_mov_reg_T0(ot, (modrm & 7) | REX_B(s));
break;
case 0x8a:
case 0x8b:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = OT_WORD + dflag;
modrm = ldub_code(s->pc++);
reg = ((modrm >> 3) & 7) | rex_r;
gen_ldst_modrm(s, modrm, ot, OR_TMP0, 0);
gen_op_mov_reg_T0(ot, reg);
break;
case 0x8e:
modrm = ldub_code(s->pc++);
reg = (modrm >> 3) & 7;
if (reg >= 6 || reg == R_CS)
goto illegal_op;
gen_ldst_modrm(s, modrm, OT_WORD, OR_TMP0, 0);
gen_movl_seg_T0(s, reg, pc_start - s->cs_base);
if (reg == R_SS) {
if (!(s->tb->flags & HF_INHIBIT_IRQ_MASK))
gen_helper_set_inhibit_irq();
s->tf = 0;
}
if (s->is_jmp) {
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
}
break;
case 0x8c:
modrm = ldub_code(s->pc++);
reg = (modrm >> 3) & 7;
mod = (modrm >> 6) & 3;
if (reg >= 6)
goto illegal_op;
gen_op_movl_T0_seg(reg);
if (mod == 3)
ot = OT_WORD + dflag;
else
ot = OT_WORD;
gen_ldst_modrm(s, modrm, ot, OR_TMP0, 1);
break;
case 0x1b6:
case 0x1b7:
case 0x1be:
case 0x1bf:
{
int d_ot;
d_ot = dflag + OT_WORD;
ot = (b & 1) + OT_BYTE;
modrm = ldub_code(s->pc++);
reg = ((modrm >> 3) & 7) | rex_r;
mod = (modrm >> 6) & 3;
rm = (modrm & 7) | REX_B(s);
if (mod == 3) {
gen_op_mov_TN_reg(ot, 0, rm);
switch(ot | (b & 8)) {
case OT_BYTE:
tcg_gen_ext8u_tl(cpu_T[0], cpu_T[0]);
break;
case OT_BYTE | 8:
tcg_gen_ext8s_tl(cpu_T[0], cpu_T[0]);
break;
case OT_WORD:
tcg_gen_ext16u_tl(cpu_T[0], cpu_T[0]);
break;
default:
case OT_WORD | 8:
tcg_gen_ext16s_tl(cpu_T[0], cpu_T[0]);
break;
}
gen_op_mov_reg_T0(d_ot, reg);
} else {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
if (b & 8) {
gen_op_lds_T0_A0(ot + s->mem_index);
} else {
gen_op_ldu_T0_A0(ot + s->mem_index);
}
gen_op_mov_reg_T0(d_ot, reg);
}
}
break;
case 0x8d:
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
if (mod == 3)
goto illegal_op;
reg = ((modrm >> 3) & 7) | rex_r;
s->override = -1;
val = s->addseg;
s->addseg = 0;
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
s->addseg = val;
gen_op_mov_reg_A0(ot - OT_WORD, reg);
break;
case 0xa0:
case 0xa1:
case 0xa2:
case 0xa3:
{
target_ulong offset_addr;
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
#ifdef TARGET_X86_64
if (s->aflag == 2) {
offset_addr = ldq_code(s->pc);
s->pc += 8;
gen_op_movq_A0_im(offset_addr);
} else
#endif
{
if (s->aflag) {
offset_addr = insn_get(s, OT_LONG);
} else {
offset_addr = insn_get(s, OT_WORD);
}
gen_op_movl_A0_im(offset_addr);
}
gen_add_A0_ds_seg(s);
if ((b & 2) == 0) {
gen_op_ld_T0_A0(ot + s->mem_index);
gen_op_mov_reg_T0(ot, R_EAX);
} else {
gen_op_mov_TN_reg(ot, 0, R_EAX);
gen_op_st_T0_A0(ot + s->mem_index);
}
}
break;
case 0xd7:
#ifdef TARGET_X86_64
if (s->aflag == 2) {
gen_op_movq_A0_reg(R_EBX);
gen_op_mov_TN_reg(OT_QUAD, 0, R_EAX);
tcg_gen_andi_tl(cpu_T[0], cpu_T[0], 0xff);
tcg_gen_add_tl(cpu_A0, cpu_A0, cpu_T[0]);
} else
#endif
{
gen_op_movl_A0_reg(R_EBX);
gen_op_mov_TN_reg(OT_LONG, 0, R_EAX);
tcg_gen_andi_tl(cpu_T[0], cpu_T[0], 0xff);
tcg_gen_add_tl(cpu_A0, cpu_A0, cpu_T[0]);
if (s->aflag == 0)
gen_op_andl_A0_ffff();
else
tcg_gen_andi_tl(cpu_A0, cpu_A0, 0xffffffff);
}
gen_add_A0_ds_seg(s);
gen_op_ldu_T0_A0(OT_BYTE + s->mem_index);
gen_op_mov_reg_T0(OT_BYTE, R_EAX);
break;
case 0xb0 ... 0xb7:
val = insn_get(s, OT_BYTE);
gen_op_movl_T0_im(val);
gen_op_mov_reg_T0(OT_BYTE, (b & 7) | REX_B(s));
break;
case 0xb8 ... 0xbf:
#ifdef TARGET_X86_64
if (dflag == 2) {
uint64_t tmp;
tmp = ldq_code(s->pc);
s->pc += 8;
reg = (b & 7) | REX_B(s);
gen_movtl_T0_im(tmp);
gen_op_mov_reg_T0(OT_QUAD, reg);
} else
#endif
{
ot = dflag ? OT_LONG : OT_WORD;
val = insn_get(s, ot);
reg = (b & 7) | REX_B(s);
gen_op_movl_T0_im(val);
gen_op_mov_reg_T0(ot, reg);
}
break;
case 0x91 ... 0x97:
ot = dflag + OT_WORD;
reg = (b & 7) | REX_B(s);
rm = R_EAX;
goto do_xchg_reg;
case 0x86:
case 0x87:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
reg = ((modrm >> 3) & 7) | rex_r;
mod = (modrm >> 6) & 3;
if (mod == 3) {
rm = (modrm & 7) | REX_B(s);
do_xchg_reg:
gen_op_mov_TN_reg(ot, 0, reg);
gen_op_mov_TN_reg(ot, 1, rm);
gen_op_mov_reg_T0(ot, rm);
gen_op_mov_reg_T1(ot, reg);
} else {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_mov_TN_reg(ot, 0, reg);
if (!(prefixes & PREFIX_LOCK))
gen_helper_lock();
gen_op_ld_T1_A0(ot + s->mem_index);
gen_op_st_T0_A0(ot + s->mem_index);
if (!(prefixes & PREFIX_LOCK))
gen_helper_unlock();
gen_op_mov_reg_T1(ot, reg);
}
break;
case 0xc4:
if (CODE64(s))
goto illegal_op;
op = R_ES;
goto do_lxx;
case 0xc5:
if (CODE64(s))
goto illegal_op;
op = R_DS;
goto do_lxx;
case 0x1b2:
op = R_SS;
goto do_lxx;
case 0x1b4:
op = R_FS;
goto do_lxx;
case 0x1b5:
op = R_GS;
do_lxx:
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub_code(s->pc++);
reg = ((modrm >> 3) & 7) | rex_r;
mod = (modrm >> 6) & 3;
if (mod == 3)
goto illegal_op;
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_ld_T1_A0(ot + s->mem_index);
gen_add_A0_im(s, 1 << (ot - OT_WORD + 1));
gen_op_ldu_T0_A0(OT_WORD + s->mem_index);
gen_movl_seg_T0(s, op, pc_start - s->cs_base);
gen_op_mov_reg_T1(ot, reg);
if (s->is_jmp) {
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
}
break;
case 0xc0:
case 0xc1:
shift = 2;
grp2:
{
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
op = (modrm >> 3) & 7;
if (mod != 3) {
if (shift == 2) {
s->rip_offset = 1;
}
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
opreg = OR_TMP0;
} else {
opreg = (modrm & 7) | REX_B(s);
}
if (shift == 0) {
gen_shift(s, op, ot, opreg, OR_ECX);
} else {
if (shift == 2) {
shift = ldub_code(s->pc++);
}
gen_shifti(s, op, ot, opreg, shift);
}
}
break;
case 0xd0:
case 0xd1:
shift = 1;
goto grp2;
case 0xd2:
case 0xd3:
shift = 0;
goto grp2;
case 0x1a4:
op = 0;
shift = 1;
goto do_shiftd;
case 0x1a5:
op = 0;
shift = 0;
goto do_shiftd;
case 0x1ac:
op = 1;
shift = 1;
goto do_shiftd;
case 0x1ad:
op = 1;
shift = 0;
do_shiftd:
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
rm = (modrm & 7) | REX_B(s);
reg = ((modrm >> 3) & 7) | rex_r;
if (mod != 3) {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
opreg = OR_TMP0;
} else {
opreg = rm;
}
gen_op_mov_TN_reg(ot, 1, reg);
if (shift) {
val = ldub_code(s->pc++);
tcg_gen_movi_tl(cpu_T3, val);
} else {
tcg_gen_ld_tl(cpu_T3, cpu_env, offsetof(CPUState, regs[R_ECX]));
}
gen_shiftd_rm_T1_T3(s, ot, opreg, op);
break;
case 0xd8 ... 0xdf:
if (s->flags & (HF_EM_MASK | HF_TS_MASK)) {
gen_exception(s, EXCP07_PREX, pc_start - s->cs_base);
break;
}
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
rm = modrm & 7;
op = ((b & 7) << 3) | ((modrm >> 3) & 7);
if (mod != 3) {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
switch(op) {
case 0x00 ... 0x07:
case 0x10 ... 0x17:
case 0x20 ... 0x27:
case 0x30 ... 0x37:
{
int op1;
op1 = op & 7;
switch(op >> 4) {
case 0:
gen_op_ld_T0_A0(OT_LONG + s->mem_index);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_flds_FT0(cpu_tmp2_i32);
break;
case 1:
gen_op_ld_T0_A0(OT_LONG + s->mem_index);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_fildl_FT0(cpu_tmp2_i32);
break;
case 2:
tcg_gen_qemu_ld64(cpu_tmp1_i64, cpu_A0,
(s->mem_index >> 2) - 1);
gen_helper_fldl_FT0(cpu_tmp1_i64);
break;
case 3:
default:
gen_op_lds_T0_A0(OT_WORD + s->mem_index);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_fildl_FT0(cpu_tmp2_i32);
break;
}
gen_helper_fp_arith_ST0_FT0(op1);
if (op1 == 3) {
gen_helper_fpop();
}
}
break;
case 0x08:
case 0x0a:
case 0x0b:
case 0x18 ... 0x1b:
case 0x28 ... 0x2b:
case 0x38 ... 0x3b:
switch(op & 7) {
case 0:
switch(op >> 4) {
case 0:
gen_op_ld_T0_A0(OT_LONG + s->mem_index);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_flds_ST0(cpu_tmp2_i32);
break;
case 1:
gen_op_ld_T0_A0(OT_LONG + s->mem_index);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_fildl_ST0(cpu_tmp2_i32);
break;
case 2:
tcg_gen_qemu_ld64(cpu_tmp1_i64, cpu_A0,
(s->mem_index >> 2) - 1);
gen_helper_fldl_ST0(cpu_tmp1_i64);
break;
case 3:
default:
gen_op_lds_T0_A0(OT_WORD + s->mem_index);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_fildl_ST0(cpu_tmp2_i32);
break;
}
break;
case 1:
switch(op >> 4) {
case 1:
gen_helper_fisttl_ST0(cpu_tmp2_i32);
tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);
gen_op_st_T0_A0(OT_LONG + s->mem_index);
break;
case 2:
gen_helper_fisttll_ST0(cpu_tmp1_i64);
tcg_gen_qemu_st64(cpu_tmp1_i64, cpu_A0,
(s->mem_index >> 2) - 1);
break;
case 3:
default:
gen_helper_fistt_ST0(cpu_tmp2_i32);
tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);
gen_op_st_T0_A0(OT_WORD + s->mem_index);
break;
}
gen_helper_fpop();
break;
default:
switch(op >> 4) {
case 0:
gen_helper_fsts_ST0(cpu_tmp2_i32);
tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);
gen_op_st_T0_A0(OT_LONG + s->mem_index);
break;
case 1:
gen_helper_fistl_ST0(cpu_tmp2_i32);
tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);
gen_op_st_T0_A0(OT_LONG + s->mem_index);
break;
case 2:
gen_helper_fstl_ST0(cpu_tmp1_i64);
tcg_gen_qemu_st64(cpu_tmp1_i64, cpu_A0,
(s->mem_index >> 2) - 1);
break;
case 3:
default:
gen_helper_fist_ST0(cpu_tmp2_i32);
tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);
gen_op_st_T0_A0(OT_WORD + s->mem_index);
break;
}
if ((op & 7) == 3)
gen_helper_fpop();
break;
}
break;
case 0x0c:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_fldenv(
cpu_A0, tcg_const_i32(s->dflag));
break;
case 0x0d:
gen_op_ld_T0_A0(OT_WORD + s->mem_index);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_fldcw(cpu_tmp2_i32);
break;
case 0x0e:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_fstenv(cpu_A0, tcg_const_i32(s->dflag));
break;
case 0x0f:
gen_helper_fnstcw(cpu_tmp2_i32);
tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);
gen_op_st_T0_A0(OT_WORD + s->mem_index);
break;
case 0x1d:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_fldt_ST0(cpu_A0);
break;
case 0x1f:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_fstt_ST0(cpu_A0);
gen_helper_fpop();
break;
case 0x2c:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_frstor(cpu_A0, tcg_const_i32(s->dflag));
break;
case 0x2e:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_fsave(cpu_A0, tcg_const_i32(s->dflag));
break;
case 0x2f:
gen_helper_fnstsw(cpu_tmp2_i32);
tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);
gen_op_st_T0_A0(OT_WORD + s->mem_index);
break;
case 0x3c:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_fbld_ST0(cpu_A0);
break;
case 0x3e:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_fbst_ST0(cpu_A0);
gen_helper_fpop();
break;
case 0x3d:
tcg_gen_qemu_ld64(cpu_tmp1_i64, cpu_A0,
(s->mem_index >> 2) - 1);
gen_helper_fildll_ST0(cpu_tmp1_i64);
break;
case 0x3f:
gen_helper_fistll_ST0(cpu_tmp1_i64);
tcg_gen_qemu_st64(cpu_tmp1_i64, cpu_A0,
(s->mem_index >> 2) - 1);
gen_helper_fpop();
break;
default:
goto illegal_op;
}
} else {
opreg = rm;
switch(op) {
case 0x08:
gen_helper_fpush();
gen_helper_fmov_ST0_STN(tcg_const_i32((opreg + 1) & 7));
break;
case 0x09:
case 0x29:
case 0x39:
gen_helper_fxchg_ST0_STN(tcg_const_i32(opreg));
break;
case 0x0a:
switch(rm) {
case 0:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_fwait();
break;
default:
goto illegal_op;
}
break;
case 0x0c:
switch(rm) {
case 0:
gen_helper_fchs_ST0();
break;
case 1:
gen_helper_fabs_ST0();
break;
case 4:
gen_helper_fldz_FT0();
gen_helper_fcom_ST0_FT0();
break;
case 5:
gen_helper_fxam_ST0();
break;
default:
goto illegal_op;
}
break;
case 0x0d:
{
switch(rm) {
case 0:
gen_helper_fpush();
gen_helper_fld1_ST0();
break;
case 1:
gen_helper_fpush();
gen_helper_fldl2t_ST0();
break;
case 2:
gen_helper_fpush();
gen_helper_fldl2e_ST0();
break;
case 3:
gen_helper_fpush();
gen_helper_fldpi_ST0();
break;
case 4:
gen_helper_fpush();
gen_helper_fldlg2_ST0();
break;
case 5:
gen_helper_fpush();
gen_helper_fldln2_ST0();
break;
case 6:
gen_helper_fpush();
gen_helper_fldz_ST0();
break;
default:
goto illegal_op;
}
}
break;
case 0x0e:
switch(rm) {
case 0:
gen_helper_f2xm1();
break;
case 1:
gen_helper_fyl2x();
break;
case 2:
gen_helper_fptan();
break;
case 3:
gen_helper_fpatan();
break;
case 4:
gen_helper_fxtract();
break;
case 5:
gen_helper_fprem1();
break;
case 6:
gen_helper_fdecstp();
break;
default:
case 7:
gen_helper_fincstp();
break;
}
break;
case 0x0f:
switch(rm) {
case 0:
gen_helper_fprem();
break;
case 1:
gen_helper_fyl2xp1();
break;
case 2:
gen_helper_fsqrt();
break;
case 3:
gen_helper_fsincos();
break;
case 5:
gen_helper_fscale();
break;
case 4:
gen_helper_frndint();
break;
case 6:
gen_helper_fsin();
break;
default:
case 7:
gen_helper_fcos();
break;
}
break;
case 0x00: case 0x01: case 0x04 ... 0x07:
case 0x20: case 0x21: case 0x24 ... 0x27:
case 0x30: case 0x31: case 0x34 ... 0x37:
{
int op1;
op1 = op & 7;
if (op >= 0x20) {
gen_helper_fp_arith_STN_ST0(op1, opreg);
if (op >= 0x30)
gen_helper_fpop();
} else {
gen_helper_fmov_FT0_STN(tcg_const_i32(opreg));
gen_helper_fp_arith_ST0_FT0(op1);
}
}
break;
case 0x02:
case 0x22:
gen_helper_fmov_FT0_STN(tcg_const_i32(opreg));
gen_helper_fcom_ST0_FT0();
break;
case 0x03:
case 0x23:
case 0x32:
gen_helper_fmov_FT0_STN(tcg_const_i32(opreg));
gen_helper_fcom_ST0_FT0();
gen_helper_fpop();
break;
case 0x15:
switch(rm) {
case 1:
gen_helper_fmov_FT0_STN(tcg_const_i32(1));
gen_helper_fucom_ST0_FT0();
gen_helper_fpop();
gen_helper_fpop();
break;
default:
goto illegal_op;
}
break;
case 0x1c:
switch(rm) {
case 0:
break;
case 1:
break;
case 2:
gen_helper_fclex();
break;
case 3:
gen_helper_fninit();
break;
case 4:
break;
default:
goto illegal_op;
}
break;
case 0x1d:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_helper_fmov_FT0_STN(tcg_const_i32(opreg));
gen_helper_fucomi_ST0_FT0();
s->cc_op = CC_OP_EFLAGS;
break;
case 0x1e:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_helper_fmov_FT0_STN(tcg_const_i32(opreg));
gen_helper_fcomi_ST0_FT0();
s->cc_op = CC_OP_EFLAGS;
break;
case 0x28:
gen_helper_ffree_STN(tcg_const_i32(opreg));
break;
case 0x2a:
gen_helper_fmov_STN_ST0(tcg_const_i32(opreg));
break;
case 0x2b:
case 0x0b:
case 0x3a:
case 0x3b:
gen_helper_fmov_STN_ST0(tcg_const_i32(opreg));
gen_helper_fpop();
break;
case 0x2c:
gen_helper_fmov_FT0_STN(tcg_const_i32(opreg));
gen_helper_fucom_ST0_FT0();
break;
case 0x2d:
gen_helper_fmov_FT0_STN(tcg_const_i32(opreg));
gen_helper_fucom_ST0_FT0();
gen_helper_fpop();
break;
case 0x33:
switch(rm) {
case 1:
gen_helper_fmov_FT0_STN(tcg_const_i32(1));
gen_helper_fcom_ST0_FT0();
gen_helper_fpop();
gen_helper_fpop();
break;
default:
goto illegal_op;
}
break;
case 0x38:
gen_helper_ffree_STN(tcg_const_i32(opreg));
gen_helper_fpop();
break;
case 0x3c:
switch(rm) {
case 0:
gen_helper_fnstsw(cpu_tmp2_i32);
tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);
gen_op_mov_reg_T0(OT_WORD, R_EAX);
break;
default:
goto illegal_op;
}
break;
case 0x3d:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_helper_fmov_FT0_STN(tcg_const_i32(opreg));
gen_helper_fucomi_ST0_FT0();
gen_helper_fpop();
s->cc_op = CC_OP_EFLAGS;
break;
case 0x3e:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_helper_fmov_FT0_STN(tcg_const_i32(opreg));
gen_helper_fcomi_ST0_FT0();
gen_helper_fpop();
s->cc_op = CC_OP_EFLAGS;
break;
case 0x10 ... 0x13:
case 0x18 ... 0x1b:
{
int op1, l1;
static const uint8_t fcmov_cc[8] = {
(JCC_B << 1),
(JCC_Z << 1),
(JCC_BE << 1),
(JCC_P << 1),
};
op1 = fcmov_cc[op & 3] | (((op >> 3) & 1) ^ 1);
l1 = gen_new_label();
gen_jcc1(s, s->cc_op, op1, l1);
gen_helper_fmov_ST0_STN(tcg_const_i32(opreg));
gen_set_label(l1);
}
break;
default:
goto illegal_op;
}
}
break;
case 0xa4:
case 0xa5:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
if (prefixes & (PREFIX_REPZ | PREFIX_REPNZ)) {
gen_repz_movs(s, ot, pc_start - s->cs_base, s->pc - s->cs_base);
} else {
gen_movs(s, ot);
}
break;
case 0xaa:
case 0xab:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
if (prefixes & (PREFIX_REPZ | PREFIX_REPNZ)) {
gen_repz_stos(s, ot, pc_start - s->cs_base, s->pc - s->cs_base);
} else {
gen_stos(s, ot);
}
break;
case 0xac:
case 0xad:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
if (prefixes & (PREFIX_REPZ | PREFIX_REPNZ)) {
gen_repz_lods(s, ot, pc_start - s->cs_base, s->pc - s->cs_base);
} else {
gen_lods(s, ot);
}
break;
case 0xae:
case 0xaf:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
if (prefixes & PREFIX_REPNZ) {
gen_repz_scas(s, ot, pc_start - s->cs_base, s->pc - s->cs_base, 1);
} else if (prefixes & PREFIX_REPZ) {
gen_repz_scas(s, ot, pc_start - s->cs_base, s->pc - s->cs_base, 0);
} else {
gen_scas(s, ot);
s->cc_op = CC_OP_SUBB + ot;
}
break;
case 0xa6:
case 0xa7:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
if (prefixes & PREFIX_REPNZ) {
gen_repz_cmps(s, ot, pc_start - s->cs_base, s->pc - s->cs_base, 1);
} else if (prefixes & PREFIX_REPZ) {
gen_repz_cmps(s, ot, pc_start - s->cs_base, s->pc - s->cs_base, 0);
} else {
gen_cmps(s, ot);
s->cc_op = CC_OP_SUBB + ot;
}
break;
case 0x6c:
case 0x6d:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
gen_op_mov_TN_reg(OT_WORD, 0, R_EDX);
gen_op_andl_T0_ffff();
gen_check_io(s, ot, pc_start - s->cs_base,
SVM_IOIO_TYPE_MASK | svm_is_rep(prefixes) | 4);
if (prefixes & (PREFIX_REPZ | PREFIX_REPNZ)) {
gen_repz_ins(s, ot, pc_start - s->cs_base, s->pc - s->cs_base);
} else {
gen_ins(s, ot);
if (use_icount) {
gen_jmp(s, s->pc - s->cs_base);
}
}
break;
case 0x6e:
case 0x6f:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
gen_op_mov_TN_reg(OT_WORD, 0, R_EDX);
gen_op_andl_T0_ffff();
gen_check_io(s, ot, pc_start - s->cs_base,
svm_is_rep(prefixes) | 4);
if (prefixes & (PREFIX_REPZ | PREFIX_REPNZ)) {
gen_repz_outs(s, ot, pc_start - s->cs_base, s->pc - s->cs_base);
} else {
gen_outs(s, ot);
if (use_icount) {
gen_jmp(s, s->pc - s->cs_base);
}
}
break;
case 0xe4:
case 0xe5:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
val = ldub_code(s->pc++);
gen_op_movl_T0_im(val);
gen_check_io(s, ot, pc_start - s->cs_base,
SVM_IOIO_TYPE_MASK | svm_is_rep(prefixes));
if (use_icount)
gen_io_start();
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_in_func(ot, cpu_T[1], cpu_tmp2_i32);
gen_op_mov_reg_T1(ot, R_EAX);
if (use_icount) {
gen_io_end();
gen_jmp(s, s->pc - s->cs_base);
}
break;
case 0xe6:
case 0xe7:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
val = ldub_code(s->pc++);
gen_op_movl_T0_im(val);
gen_check_io(s, ot, pc_start - s->cs_base,
svm_is_rep(prefixes));
gen_op_mov_TN_reg(ot, 1, R_EAX);
if (use_icount)
gen_io_start();
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
tcg_gen_andi_i32(cpu_tmp2_i32, cpu_tmp2_i32, 0xffff);
tcg_gen_trunc_tl_i32(cpu_tmp3_i32, cpu_T[1]);
gen_helper_out_func(ot, cpu_tmp2_i32, cpu_tmp3_i32);
if (use_icount) {
gen_io_end();
gen_jmp(s, s->pc - s->cs_base);
}
break;
case 0xec:
case 0xed:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
gen_op_mov_TN_reg(OT_WORD, 0, R_EDX);
gen_op_andl_T0_ffff();
gen_check_io(s, ot, pc_start - s->cs_base,
SVM_IOIO_TYPE_MASK | svm_is_rep(prefixes));
if (use_icount)
gen_io_start();
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_in_func(ot, cpu_T[1], cpu_tmp2_i32);
gen_op_mov_reg_T1(ot, R_EAX);
if (use_icount) {
gen_io_end();
gen_jmp(s, s->pc - s->cs_base);
}
break;
case 0xee:
case 0xef:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
gen_op_mov_TN_reg(OT_WORD, 0, R_EDX);
gen_op_andl_T0_ffff();
gen_check_io(s, ot, pc_start - s->cs_base,
svm_is_rep(prefixes));
gen_op_mov_TN_reg(ot, 1, R_EAX);
if (use_icount)
gen_io_start();
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
tcg_gen_andi_i32(cpu_tmp2_i32, cpu_tmp2_i32, 0xffff);
tcg_gen_trunc_tl_i32(cpu_tmp3_i32, cpu_T[1]);
gen_helper_out_func(ot, cpu_tmp2_i32, cpu_tmp3_i32);
if (use_icount) {
gen_io_end();
gen_jmp(s, s->pc - s->cs_base);
}
break;
case 0xc2:
val = ldsw_code(s->pc);
s->pc += 2;
gen_pop_T0(s);
if (CODE64(s) && s->dflag)
s->dflag = 2;
gen_stack_update(s, val + (2 << s->dflag));
if (s->dflag == 0)
gen_op_andl_T0_ffff();
gen_op_jmp_T0();
gen_eob(s);
break;
case 0xc3:
gen_pop_T0(s);
gen_pop_update(s);
if (s->dflag == 0)
gen_op_andl_T0_ffff();
gen_op_jmp_T0();
gen_eob(s);
break;
case 0xca:
val = ldsw_code(s->pc);
s->pc += 2;
do_lret:
if (s->pe && !s->vm86) {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_lret_protected(tcg_const_i32(s->dflag),
tcg_const_i32(val));
} else {
gen_stack_A0(s);
gen_op_ld_T0_A0(1 + s->dflag + s->mem_index);
if (s->dflag == 0)
gen_op_andl_T0_ffff();
gen_op_jmp_T0();
gen_op_addl_A0_im(2 << s->dflag);
gen_op_ld_T0_A0(1 + s->dflag + s->mem_index);
gen_op_movl_seg_T0_vm(R_CS);
gen_stack_update(s, val + (4 << s->dflag));
}
gen_eob(s);
break;
case 0xcb:
val = 0;
goto do_lret;
case 0xcf:
gen_svm_check_intercept(s, pc_start, SVM_EXIT_IRET);
if (!s->pe) {
gen_helper_iret_real(tcg_const_i32(s->dflag));
s->cc_op = CC_OP_EFLAGS;
} else if (s->vm86) {
if (s->iopl != 3) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_helper_iret_real(tcg_const_i32(s->dflag));
s->cc_op = CC_OP_EFLAGS;
}
} else {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_iret_protected(tcg_const_i32(s->dflag),
tcg_const_i32(s->pc - s->cs_base));
s->cc_op = CC_OP_EFLAGS;
}
gen_eob(s);
break;
case 0xe8:
{
if (dflag)
tval = (int32_t)insn_get(s, OT_LONG);
else
tval = (int16_t)insn_get(s, OT_WORD);
next_eip = s->pc - s->cs_base;
tval += next_eip;
if (s->dflag == 0)
tval &= 0xffff;
gen_movtl_T0_im(next_eip);
gen_push_T0(s);
gen_jmp(s, tval);
}
break;
case 0x9a:
{
unsigned int selector, offset;
if (CODE64(s))
goto illegal_op;
ot = dflag ? OT_LONG : OT_WORD;
offset = insn_get(s, ot);
selector = insn_get(s, OT_WORD);
gen_op_movl_T0_im(selector);
gen_op_movl_T1_imu(offset);
}
goto do_lcall;
case 0xe9:
if (dflag)
tval = (int32_t)insn_get(s, OT_LONG);
else
tval = (int16_t)insn_get(s, OT_WORD);
tval += s->pc - s->cs_base;
if (s->dflag == 0)
tval &= 0xffff;
gen_jmp(s, tval);
break;
case 0xea:
{
unsigned int selector, offset;
if (CODE64(s))
goto illegal_op;
ot = dflag ? OT_LONG : OT_WORD;
offset = insn_get(s, ot);
selector = insn_get(s, OT_WORD);
gen_op_movl_T0_im(selector);
gen_op_movl_T1_imu(offset);
}
goto do_ljmp;
case 0xeb:
tval = (int8_t)insn_get(s, OT_BYTE);
tval += s->pc - s->cs_base;
if (s->dflag == 0)
tval &= 0xffff;
gen_jmp(s, tval);
break;
case 0x70 ... 0x7f:
tval = (int8_t)insn_get(s, OT_BYTE);
goto do_jcc;
case 0x180 ... 0x18f:
if (dflag) {
tval = (int32_t)insn_get(s, OT_LONG);
} else {
tval = (int16_t)insn_get(s, OT_WORD);
}
do_jcc:
next_eip = s->pc - s->cs_base;
tval += next_eip;
if (s->dflag == 0)
tval &= 0xffff;
gen_jcc(s, b, tval, next_eip);
break;
case 0x190 ... 0x19f:
modrm = ldub_code(s->pc++);
gen_setcc(s, b);
gen_ldst_modrm(s, modrm, OT_BYTE, OR_TMP0, 1);
break;
case 0x140 ... 0x14f:
{
int l1;
TCGv t0;
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
reg = ((modrm >> 3) & 7) | rex_r;
mod = (modrm >> 6) & 3;
t0 = tcg_temp_local_new();
if (mod != 3) {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_ld_v(ot + s->mem_index, t0, cpu_A0);
} else {
rm = (modrm & 7) | REX_B(s);
gen_op_mov_v_reg(ot, t0, rm);
}
#ifdef TARGET_X86_64
if (ot == OT_LONG) {
l1 = gen_new_label();
gen_jcc1(s, s->cc_op, b ^ 1, l1);
tcg_gen_st32_tl(t0, cpu_env, offsetof(CPUState, regs[reg]) + REG_L_OFFSET);
gen_set_label(l1);
tcg_gen_movi_tl(cpu_tmp0, 0);
tcg_gen_st32_tl(cpu_tmp0, cpu_env, offsetof(CPUState, regs[reg]) + REG_LH_OFFSET);
} else
#endif
{
l1 = gen_new_label();
gen_jcc1(s, s->cc_op, b ^ 1, l1);
gen_op_mov_reg_v(ot, reg, t0);
gen_set_label(l1);
}
tcg_temp_free(t0);
}
break;
case 0x9c:
gen_svm_check_intercept(s, pc_start, SVM_EXIT_PUSHF);
if (s->vm86 && s->iopl != 3) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_helper_read_eflags(cpu_T[0]);
gen_push_T0(s);
}
break;
case 0x9d:
gen_svm_check_intercept(s, pc_start, SVM_EXIT_POPF);
if (s->vm86 && s->iopl != 3) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_pop_T0(s);
if (s->cpl == 0) {
if (s->dflag) {
gen_helper_write_eflags(cpu_T[0],
tcg_const_i32((TF_MASK | AC_MASK | ID_MASK | NT_MASK | IF_MASK | IOPL_MASK)));
} else {
gen_helper_write_eflags(cpu_T[0],
tcg_const_i32((TF_MASK | AC_MASK | ID_MASK | NT_MASK | IF_MASK | IOPL_MASK) & 0xffff));
}
} else {
if (s->cpl <= s->iopl) {
if (s->dflag) {
gen_helper_write_eflags(cpu_T[0],
tcg_const_i32((TF_MASK | AC_MASK | ID_MASK | NT_MASK | IF_MASK)));
} else {
gen_helper_write_eflags(cpu_T[0],
tcg_const_i32((TF_MASK | AC_MASK | ID_MASK | NT_MASK | IF_MASK) & 0xffff));
}
} else {
if (s->dflag) {
gen_helper_write_eflags(cpu_T[0],
tcg_const_i32((TF_MASK | AC_MASK | ID_MASK | NT_MASK)));
} else {
gen_helper_write_eflags(cpu_T[0],
tcg_const_i32((TF_MASK | AC_MASK | ID_MASK | NT_MASK) & 0xffff));
}
}
}
gen_pop_update(s);
s->cc_op = CC_OP_EFLAGS;
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
}
break;
case 0x9e:
if (CODE64(s) && !(s->cpuid_ext3_features & CPUID_EXT3_LAHF_LM))
goto illegal_op;
gen_op_mov_TN_reg(OT_BYTE, 0, R_AH);
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_compute_eflags(cpu_cc_src);
tcg_gen_andi_tl(cpu_cc_src, cpu_cc_src, CC_O);
tcg_gen_andi_tl(cpu_T[0], cpu_T[0], CC_S | CC_Z | CC_A | CC_P | CC_C);
tcg_gen_or_tl(cpu_cc_src, cpu_cc_src, cpu_T[0]);
s->cc_op = CC_OP_EFLAGS;
break;
case 0x9f:
if (CODE64(s) && !(s->cpuid_ext3_features & CPUID_EXT3_LAHF_LM))
goto illegal_op;
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_compute_eflags(cpu_T[0]);
tcg_gen_ori_tl(cpu_T[0], cpu_T[0], 0x02);
gen_op_mov_reg_T0(OT_BYTE, R_AH);
break;
case 0xf5:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_compute_eflags(cpu_cc_src);
tcg_gen_xori_tl(cpu_cc_src, cpu_cc_src, CC_C);
s->cc_op = CC_OP_EFLAGS;
break;
case 0xf8:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_compute_eflags(cpu_cc_src);
tcg_gen_andi_tl(cpu_cc_src, cpu_cc_src, ~CC_C);
s->cc_op = CC_OP_EFLAGS;
break;
case 0xf9:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_compute_eflags(cpu_cc_src);
tcg_gen_ori_tl(cpu_cc_src, cpu_cc_src, CC_C);
s->cc_op = CC_OP_EFLAGS;
break;
case 0xfc:
tcg_gen_movi_i32(cpu_tmp2_i32, 1);
tcg_gen_st_i32(cpu_tmp2_i32, cpu_env, offsetof(CPUState, df));
break;
case 0xfd:
tcg_gen_movi_i32(cpu_tmp2_i32, -1);
tcg_gen_st_i32(cpu_tmp2_i32, cpu_env, offsetof(CPUState, df));
break;
case 0x1ba:
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
op = (modrm >> 3) & 7;
mod = (modrm >> 6) & 3;
rm = (modrm & 7) | REX_B(s);
if (mod != 3) {
s->rip_offset = 1;
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_ld_T0_A0(ot + s->mem_index);
} else {
gen_op_mov_TN_reg(ot, 0, rm);
}
val = ldub_code(s->pc++);
gen_op_movl_T1_im(val);
if (op < 4)
goto illegal_op;
op -= 4;
goto bt_op;
case 0x1a3:
op = 0;
goto do_btx;
case 0x1ab:
op = 1;
goto do_btx;
case 0x1b3:
op = 2;
goto do_btx;
case 0x1bb:
op = 3;
do_btx:
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
reg = ((modrm >> 3) & 7) | rex_r;
mod = (modrm >> 6) & 3;
rm = (modrm & 7) | REX_B(s);
gen_op_mov_TN_reg(OT_LONG, 1, reg);
if (mod != 3) {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_exts(ot, cpu_T[1]);
tcg_gen_sari_tl(cpu_tmp0, cpu_T[1], 3 + ot);
tcg_gen_shli_tl(cpu_tmp0, cpu_tmp0, ot);
tcg_gen_add_tl(cpu_A0, cpu_A0, cpu_tmp0);
gen_op_ld_T0_A0(ot + s->mem_index);
} else {
gen_op_mov_TN_reg(ot, 0, rm);
}
bt_op:
tcg_gen_andi_tl(cpu_T[1], cpu_T[1], (1 << (3 + ot)) - 1);
switch(op) {
case 0:
tcg_gen_shr_tl(cpu_cc_src, cpu_T[0], cpu_T[1]);
tcg_gen_movi_tl(cpu_cc_dst, 0);
break;
case 1:
tcg_gen_shr_tl(cpu_tmp4, cpu_T[0], cpu_T[1]);
tcg_gen_movi_tl(cpu_tmp0, 1);
tcg_gen_shl_tl(cpu_tmp0, cpu_tmp0, cpu_T[1]);
tcg_gen_or_tl(cpu_T[0], cpu_T[0], cpu_tmp0);
break;
case 2:
tcg_gen_shr_tl(cpu_tmp4, cpu_T[0], cpu_T[1]);
tcg_gen_movi_tl(cpu_tmp0, 1);
tcg_gen_shl_tl(cpu_tmp0, cpu_tmp0, cpu_T[1]);
tcg_gen_not_tl(cpu_tmp0, cpu_tmp0);
tcg_gen_and_tl(cpu_T[0], cpu_T[0], cpu_tmp0);
break;
default:
case 3:
tcg_gen_shr_tl(cpu_tmp4, cpu_T[0], cpu_T[1]);
tcg_gen_movi_tl(cpu_tmp0, 1);
tcg_gen_shl_tl(cpu_tmp0, cpu_tmp0, cpu_T[1]);
tcg_gen_xor_tl(cpu_T[0], cpu_T[0], cpu_tmp0);
break;
}
s->cc_op = CC_OP_SARB + ot;
if (op != 0) {
if (mod != 3)
gen_op_st_T0_A0(ot + s->mem_index);
else
gen_op_mov_reg_T0(ot, rm);
tcg_gen_mov_tl(cpu_cc_src, cpu_tmp4);
tcg_gen_movi_tl(cpu_cc_dst, 0);
}
break;
case 0x1bc:
case 0x1bd:
{
int label1;
TCGv t0;
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
reg = ((modrm >> 3) & 7) | rex_r;
gen_ldst_modrm(s, modrm, ot, OR_TMP0, 0);
gen_extu(ot, cpu_T[0]);
label1 = gen_new_label();
tcg_gen_movi_tl(cpu_cc_dst, 0);
t0 = tcg_temp_local_new();
tcg_gen_mov_tl(t0, cpu_T[0]);
tcg_gen_brcondi_tl(TCG_COND_EQ, t0, 0, label1);
if (b & 1) {
gen_helper_bsr(cpu_T[0], t0);
} else {
gen_helper_bsf(cpu_T[0], t0);
}
gen_op_mov_reg_T0(ot, reg);
tcg_gen_movi_tl(cpu_cc_dst, 1);
gen_set_label(label1);
tcg_gen_discard_tl(cpu_cc_src);
s->cc_op = CC_OP_LOGICB + ot;
tcg_temp_free(t0);
}
break;
case 0x27:
if (CODE64(s))
goto illegal_op;
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_helper_daa();
s->cc_op = CC_OP_EFLAGS;
break;
case 0x2f:
if (CODE64(s))
goto illegal_op;
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_helper_das();
s->cc_op = CC_OP_EFLAGS;
break;
case 0x37:
if (CODE64(s))
goto illegal_op;
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_helper_aaa();
s->cc_op = CC_OP_EFLAGS;
break;
case 0x3f:
if (CODE64(s))
goto illegal_op;
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_helper_aas();
s->cc_op = CC_OP_EFLAGS;
break;
case 0xd4:
if (CODE64(s))
goto illegal_op;
val = ldub_code(s->pc++);
if (val == 0) {
gen_exception(s, EXCP00_DIVZ, pc_start - s->cs_base);
} else {
gen_helper_aam(tcg_const_i32(val));
s->cc_op = CC_OP_LOGICB;
}
break;
case 0xd5:
if (CODE64(s))
goto illegal_op;
val = ldub_code(s->pc++);
gen_helper_aad(tcg_const_i32(val));
s->cc_op = CC_OP_LOGICB;
break;
case 0x90:
if (prefixes & PREFIX_LOCK)
goto illegal_op;
if (prefixes & PREFIX_REPZ) {
gen_svm_check_intercept(s, pc_start, SVM_EXIT_PAUSE);
}
break;
case 0x9b:
if ((s->flags & (HF_MP_MASK | HF_TS_MASK)) ==
(HF_MP_MASK | HF_TS_MASK)) {
gen_exception(s, EXCP07_PREX, pc_start - s->cs_base);
} else {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_fwait();
}
break;
case 0xcc:
gen_interrupt(s, EXCP03_INT3, pc_start - s->cs_base, s->pc - s->cs_base);
break;
case 0xcd:
val = ldub_code(s->pc++);
if (s->vm86 && s->iopl != 3) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_interrupt(s, val, pc_start - s->cs_base, s->pc - s->cs_base);
}
break;
case 0xce:
if (CODE64(s))
goto illegal_op;
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_into(tcg_const_i32(s->pc - pc_start));
break;
#ifdef WANT_ICEBP
case 0xf1:
gen_svm_check_intercept(s, pc_start, SVM_EXIT_ICEBP);
#if 1
gen_debug(s, pc_start - s->cs_base);
#else
tb_flush(cpu_single_env);
cpu_set_log(CPU_LOG_INT | CPU_LOG_TB_IN_ASM);
#endif
break;
#endif
case 0xfa:
if (!s->vm86) {
if (s->cpl <= s->iopl) {
gen_helper_cli();
} else {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
}
} else {
if (s->iopl == 3) {
gen_helper_cli();
} else {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
}
}
break;
case 0xfb:
if (!s->vm86) {
if (s->cpl <= s->iopl) {
gen_sti:
gen_helper_sti();
if (!(s->tb->flags & HF_INHIBIT_IRQ_MASK))
gen_helper_set_inhibit_irq();
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
} else {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
}
} else {
if (s->iopl == 3) {
goto gen_sti;
} else {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
}
}
break;
case 0x62:
if (CODE64(s))
goto illegal_op;
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub_code(s->pc++);
reg = (modrm >> 3) & 7;
mod = (modrm >> 6) & 3;
if (mod == 3)
goto illegal_op;
gen_op_mov_TN_reg(ot, 0, reg);
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_jmp_im(pc_start - s->cs_base);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
if (ot == OT_WORD)
gen_helper_boundw(cpu_A0, cpu_tmp2_i32);
else
gen_helper_boundl(cpu_A0, cpu_tmp2_i32);
break;
case 0x1c8 ... 0x1cf:
reg = (b & 7) | REX_B(s);
#ifdef TARGET_X86_64
if (dflag == 2) {
gen_op_mov_TN_reg(OT_QUAD, 0, reg);
tcg_gen_bswap_i64(cpu_T[0], cpu_T[0]);
gen_op_mov_reg_T0(OT_QUAD, reg);
} else
{
TCGv_i32 tmp0;
gen_op_mov_TN_reg(OT_LONG, 0, reg);
tmp0 = tcg_temp_new_i32();
tcg_gen_trunc_i64_i32(tmp0, cpu_T[0]);
tcg_gen_bswap_i32(tmp0, tmp0);
tcg_gen_extu_i32_i64(cpu_T[0], tmp0);
gen_op_mov_reg_T0(OT_LONG, reg);
}
#else
{
gen_op_mov_TN_reg(OT_LONG, 0, reg);
tcg_gen_bswap_i32(cpu_T[0], cpu_T[0]);
gen_op_mov_reg_T0(OT_LONG, reg);
}
#endif
break;
case 0xd6:
if (CODE64(s))
goto illegal_op;
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_compute_eflags_c(cpu_T[0]);
tcg_gen_neg_tl(cpu_T[0], cpu_T[0]);
gen_op_mov_reg_T0(OT_BYTE, R_EAX);
break;
case 0xe0:
case 0xe1:
case 0xe2:
case 0xe3:
{
int l1, l2, l3;
tval = (int8_t)insn_get(s, OT_BYTE);
next_eip = s->pc - s->cs_base;
tval += next_eip;
if (s->dflag == 0)
tval &= 0xffff;
l1 = gen_new_label();
l2 = gen_new_label();
l3 = gen_new_label();
b &= 3;
switch(b) {
case 0:
case 1:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_op_add_reg_im(s->aflag, R_ECX, -1);
gen_op_jz_ecx(s->aflag, l3);
gen_compute_eflags(cpu_tmp0);
tcg_gen_andi_tl(cpu_tmp0, cpu_tmp0, CC_Z);
if (b == 0) {
tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_tmp0, 0, l1);
} else {
tcg_gen_brcondi_tl(TCG_COND_NE, cpu_tmp0, 0, l1);
}
break;
case 2:
gen_op_add_reg_im(s->aflag, R_ECX, -1);
gen_op_jnz_ecx(s->aflag, l1);
break;
default:
case 3:
gen_op_jz_ecx(s->aflag, l1);
break;
}
gen_set_label(l3);
gen_jmp_im(next_eip);
tcg_gen_br(l2);
gen_set_label(l1);
gen_jmp_im(tval);
gen_set_label(l2);
gen_eob(s);
}
break;
case 0x130:
case 0x132:
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
if (b & 2) {
gen_helper_rdmsr();
} else {
gen_helper_wrmsr();
}
}
break;
case 0x131:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
if (use_icount)
gen_io_start();
gen_helper_rdtsc();
if (use_icount) {
gen_io_end();
gen_jmp(s, s->pc - s->cs_base);
}
break;
case 0x133:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_rdpmc();
break;
case 0x134:
if (CODE64(s) && cpu_single_env->cpuid_vendor1 != CPUID_VENDOR_INTEL_1)
goto illegal_op;
if (!s->pe) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
if (s->cc_op != CC_OP_DYNAMIC) {
gen_op_set_cc_op(s->cc_op);
s->cc_op = CC_OP_DYNAMIC;
}
gen_jmp_im(pc_start - s->cs_base);
gen_helper_sysenter();
gen_eob(s);
}
break;
case 0x135:
if (CODE64(s) && cpu_single_env->cpuid_vendor1 != CPUID_VENDOR_INTEL_1)
goto illegal_op;
if (!s->pe) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
if (s->cc_op != CC_OP_DYNAMIC) {
gen_op_set_cc_op(s->cc_op);
s->cc_op = CC_OP_DYNAMIC;
}
gen_jmp_im(pc_start - s->cs_base);
gen_helper_sysexit(tcg_const_i32(dflag));
gen_eob(s);
}
break;
#ifdef TARGET_X86_64
case 0x105:
if (s->cc_op != CC_OP_DYNAMIC) {
gen_op_set_cc_op(s->cc_op);
s->cc_op = CC_OP_DYNAMIC;
}
gen_jmp_im(pc_start - s->cs_base);
gen_helper_syscall(tcg_const_i32(s->pc - pc_start));
gen_eob(s);
break;
case 0x107:
if (!s->pe) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
if (s->cc_op != CC_OP_DYNAMIC) {
gen_op_set_cc_op(s->cc_op);
s->cc_op = CC_OP_DYNAMIC;
}
gen_jmp_im(pc_start - s->cs_base);
gen_helper_sysret(tcg_const_i32(s->dflag));
if (s->lma)
s->cc_op = CC_OP_EFLAGS;
gen_eob(s);
}
break;
#endif
case 0x1a2:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_cpuid();
break;
case 0xf4:
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_hlt(tcg_const_i32(s->pc - pc_start));
s->is_jmp = 3;
}
break;
case 0x100:
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
op = (modrm >> 3) & 7;
switch(op) {
case 0:
if (!s->pe || s->vm86)
goto illegal_op;
gen_svm_check_intercept(s, pc_start, SVM_EXIT_LDTR_READ);
tcg_gen_ld32u_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,ldt.selector));
ot = OT_WORD;
if (mod == 3)
ot += s->dflag;
gen_ldst_modrm(s, modrm, ot, OR_TMP0, 1);
break;
case 2:
if (!s->pe || s->vm86)
goto illegal_op;
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_svm_check_intercept(s, pc_start, SVM_EXIT_LDTR_WRITE);
gen_ldst_modrm(s, modrm, OT_WORD, OR_TMP0, 0);
gen_jmp_im(pc_start - s->cs_base);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_lldt(cpu_tmp2_i32);
}
break;
case 1:
if (!s->pe || s->vm86)
goto illegal_op;
gen_svm_check_intercept(s, pc_start, SVM_EXIT_TR_READ);
tcg_gen_ld32u_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,tr.selector));
ot = OT_WORD;
if (mod == 3)
ot += s->dflag;
gen_ldst_modrm(s, modrm, ot, OR_TMP0, 1);
break;
case 3:
if (!s->pe || s->vm86)
goto illegal_op;
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_svm_check_intercept(s, pc_start, SVM_EXIT_TR_WRITE);
gen_ldst_modrm(s, modrm, OT_WORD, OR_TMP0, 0);
gen_jmp_im(pc_start - s->cs_base);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_ltr(cpu_tmp2_i32);
}
break;
case 4:
case 5:
if (!s->pe || s->vm86)
goto illegal_op;
gen_ldst_modrm(s, modrm, OT_WORD, OR_TMP0, 0);
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
if (op == 4)
gen_helper_verr(cpu_T[0]);
else
gen_helper_verw(cpu_T[0]);
s->cc_op = CC_OP_EFLAGS;
break;
default:
goto illegal_op;
}
break;
case 0x101:
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
op = (modrm >> 3) & 7;
rm = modrm & 7;
switch(op) {
case 0:
if (mod == 3)
goto illegal_op;
gen_svm_check_intercept(s, pc_start, SVM_EXIT_GDTR_READ);
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
tcg_gen_ld32u_tl(cpu_T[0], cpu_env, offsetof(CPUX86State, gdt.limit));
gen_op_st_T0_A0(OT_WORD + s->mem_index);
gen_add_A0_im(s, 2);
tcg_gen_ld_tl(cpu_T[0], cpu_env, offsetof(CPUX86State, gdt.base));
if (!s->dflag)
gen_op_andl_T0_im(0xffffff);
gen_op_st_T0_A0(CODE64(s) + OT_LONG + s->mem_index);
break;
case 1:
if (mod == 3) {
switch (rm) {
case 0:
if (!(s->cpuid_ext_features & CPUID_EXT_MONITOR) ||
s->cpl != 0)
goto illegal_op;
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
#ifdef TARGET_X86_64
if (s->aflag == 2) {
gen_op_movq_A0_reg(R_EAX);
} else
#endif
{
gen_op_movl_A0_reg(R_EAX);
if (s->aflag == 0)
gen_op_andl_A0_ffff();
}
gen_add_A0_ds_seg(s);
gen_helper_monitor(cpu_A0);
break;
case 1:
if (!(s->cpuid_ext_features & CPUID_EXT_MONITOR) ||
s->cpl != 0)
goto illegal_op;
if (s->cc_op != CC_OP_DYNAMIC) {
gen_op_set_cc_op(s->cc_op);
s->cc_op = CC_OP_DYNAMIC;
}
gen_jmp_im(pc_start - s->cs_base);
gen_helper_mwait(tcg_const_i32(s->pc - pc_start));
gen_eob(s);
break;
default:
goto illegal_op;
}
} else {
gen_svm_check_intercept(s, pc_start, SVM_EXIT_IDTR_READ);
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
tcg_gen_ld32u_tl(cpu_T[0], cpu_env, offsetof(CPUX86State, idt.limit));
gen_op_st_T0_A0(OT_WORD + s->mem_index);
gen_add_A0_im(s, 2);
tcg_gen_ld_tl(cpu_T[0], cpu_env, offsetof(CPUX86State, idt.base));
if (!s->dflag)
gen_op_andl_T0_im(0xffffff);
gen_op_st_T0_A0(CODE64(s) + OT_LONG + s->mem_index);
}
break;
case 2:
case 3:
if (mod == 3) {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
switch(rm) {
case 0:
if (!(s->flags & HF_SVME_MASK) || !s->pe)
goto illegal_op;
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
break;
} else {
gen_helper_vmrun(tcg_const_i32(s->aflag),
tcg_const_i32(s->pc - pc_start));
tcg_gen_exit_tb(0);
s->is_jmp = 3;
}
break;
case 1:
if (!(s->flags & HF_SVME_MASK))
goto illegal_op;
gen_helper_vmmcall();
break;
case 2:
if (!(s->flags & HF_SVME_MASK) || !s->pe)
goto illegal_op;
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
break;
} else {
gen_helper_vmload(tcg_const_i32(s->aflag));
}
break;
case 3:
if (!(s->flags & HF_SVME_MASK) || !s->pe)
goto illegal_op;
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
break;
} else {
gen_helper_vmsave(tcg_const_i32(s->aflag));
}
break;
case 4:
if ((!(s->flags & HF_SVME_MASK) &&
!(s->cpuid_ext3_features & CPUID_EXT3_SKINIT)) ||
!s->pe)
goto illegal_op;
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
break;
} else {
gen_helper_stgi();
}
break;
case 5:
if (!(s->flags & HF_SVME_MASK) || !s->pe)
goto illegal_op;
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
break;
} else {
gen_helper_clgi();
}
break;
case 6:
if ((!(s->flags & HF_SVME_MASK) &&
!(s->cpuid_ext3_features & CPUID_EXT3_SKINIT)) ||
!s->pe)
goto illegal_op;
gen_helper_skinit();
break;
case 7:
if (!(s->flags & HF_SVME_MASK) || !s->pe)
goto illegal_op;
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
break;
} else {
gen_helper_invlpga(tcg_const_i32(s->aflag));
}
break;
default:
goto illegal_op;
}
} else if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_svm_check_intercept(s, pc_start,
op==2 ? SVM_EXIT_GDTR_WRITE : SVM_EXIT_IDTR_WRITE);
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_ld_T1_A0(OT_WORD + s->mem_index);
gen_add_A0_im(s, 2);
gen_op_ld_T0_A0(CODE64(s) + OT_LONG + s->mem_index);
if (!s->dflag)
gen_op_andl_T0_im(0xffffff);
if (op == 2) {
tcg_gen_st_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,gdt.base));
tcg_gen_st32_tl(cpu_T[1], cpu_env, offsetof(CPUX86State,gdt.limit));
} else {
tcg_gen_st_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,idt.base));
tcg_gen_st32_tl(cpu_T[1], cpu_env, offsetof(CPUX86State,idt.limit));
}
}
break;
case 4:
gen_svm_check_intercept(s, pc_start, SVM_EXIT_READ_CR0);
tcg_gen_ld32u_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,cr[0]));
gen_ldst_modrm(s, modrm, OT_WORD, OR_TMP0, 1);
break;
case 6:
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_svm_check_intercept(s, pc_start, SVM_EXIT_WRITE_CR0);
gen_ldst_modrm(s, modrm, OT_WORD, OR_TMP0, 0);
gen_helper_lmsw(cpu_T[0]);
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
}
break;
case 7:
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
if (mod == 3) {
#ifdef TARGET_X86_64
if (CODE64(s) && rm == 0) {
tcg_gen_ld_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,segs[R_GS].base));
tcg_gen_ld_tl(cpu_T[1], cpu_env, offsetof(CPUX86State,kernelgsbase));
tcg_gen_st_tl(cpu_T[1], cpu_env, offsetof(CPUX86State,segs[R_GS].base));
tcg_gen_st_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,kernelgsbase));
} else
#endif
{
goto illegal_op;
}
} else {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_helper_invlpg(cpu_A0);
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
}
}
break;
default:
goto illegal_op;
}
break;
case 0x108:
case 0x109:
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_svm_check_intercept(s, pc_start, (b & 2) ? SVM_EXIT_INVD : SVM_EXIT_WBINVD);
}
break;
case 0x63:
#ifdef TARGET_X86_64
if (CODE64(s)) {
int d_ot;
d_ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
reg = ((modrm >> 3) & 7) | rex_r;
mod = (modrm >> 6) & 3;
rm = (modrm & 7) | REX_B(s);
if (mod == 3) {
gen_op_mov_TN_reg(OT_LONG, 0, rm);
if (d_ot == OT_QUAD)
tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
gen_op_mov_reg_T0(d_ot, reg);
} else {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
if (d_ot == OT_QUAD) {
gen_op_lds_T0_A0(OT_LONG + s->mem_index);
} else {
gen_op_ld_T0_A0(OT_LONG + s->mem_index);
}
gen_op_mov_reg_T0(d_ot, reg);
}
} else
#endif
{
int label1;
TCGv t0, t1, t2;
if (!s->pe || s->vm86)
goto illegal_op;
t0 = tcg_temp_local_new();
t1 = tcg_temp_local_new();
t2 = tcg_temp_local_new();
ot = OT_WORD;
modrm = ldub_code(s->pc++);
reg = (modrm >> 3) & 7;
mod = (modrm >> 6) & 3;
rm = modrm & 7;
if (mod != 3) {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_ld_v(ot + s->mem_index, t0, cpu_A0);
} else {
gen_op_mov_v_reg(ot, t0, rm);
}
gen_op_mov_v_reg(ot, t1, reg);
tcg_gen_andi_tl(cpu_tmp0, t0, 3);
tcg_gen_andi_tl(t1, t1, 3);
tcg_gen_movi_tl(t2, 0);
label1 = gen_new_label();
tcg_gen_brcond_tl(TCG_COND_GE, cpu_tmp0, t1, label1);
tcg_gen_andi_tl(t0, t0, ~3);
tcg_gen_or_tl(t0, t0, t1);
tcg_gen_movi_tl(t2, CC_Z);
gen_set_label(label1);
if (mod != 3) {
gen_op_st_v(ot + s->mem_index, t0, cpu_A0);
} else {
gen_op_mov_reg_v(ot, rm, t0);
}
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_compute_eflags(cpu_cc_src);
tcg_gen_andi_tl(cpu_cc_src, cpu_cc_src, ~CC_Z);
tcg_gen_or_tl(cpu_cc_src, cpu_cc_src, t2);
s->cc_op = CC_OP_EFLAGS;
tcg_temp_free(t0);
tcg_temp_free(t1);
tcg_temp_free(t2);
}
break;
case 0x102:
case 0x103:
{
int label1;
TCGv t0;
if (!s->pe || s->vm86)
goto illegal_op;
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub_code(s->pc++);
reg = ((modrm >> 3) & 7) | rex_r;
gen_ldst_modrm(s, modrm, OT_WORD, OR_TMP0, 0);
t0 = tcg_temp_local_new();
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
if (b == 0x102)
gen_helper_lar(t0, cpu_T[0]);
else
gen_helper_lsl(t0, cpu_T[0]);
tcg_gen_andi_tl(cpu_tmp0, cpu_cc_src, CC_Z);
label1 = gen_new_label();
tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_tmp0, 0, label1);
gen_op_mov_reg_v(ot, reg, t0);
gen_set_label(label1);
s->cc_op = CC_OP_EFLAGS;
tcg_temp_free(t0);
}
break;
case 0x118:
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
op = (modrm >> 3) & 7;
switch(op) {
case 0:
case 1:
case 2:
case 3:
if (mod == 3)
goto illegal_op;
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
break;
default:
gen_nop_modrm(s, modrm);
break;
}
break;
case 0x119 ... 0x11f:
modrm = ldub_code(s->pc++);
gen_nop_modrm(s, modrm);
break;
case 0x120:
case 0x122:
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
modrm = ldub_code(s->pc++);
if ((modrm & 0xc0) != 0xc0)
goto illegal_op;
rm = (modrm & 7) | REX_B(s);
reg = ((modrm >> 3) & 7) | rex_r;
if (CODE64(s))
ot = OT_QUAD;
else
ot = OT_LONG;
switch(reg) {
case 0:
case 2:
case 3:
case 4:
case 8:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
if (b & 2) {
gen_op_mov_TN_reg(ot, 0, rm);
gen_helper_write_crN(tcg_const_i32(reg), cpu_T[0]);
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
} else {
gen_helper_read_crN(cpu_T[0], tcg_const_i32(reg));
gen_op_mov_reg_T0(ot, rm);
}
break;
default:
goto illegal_op;
}
}
break;
case 0x121:
case 0x123:
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
modrm = ldub_code(s->pc++);
if ((modrm & 0xc0) != 0xc0)
goto illegal_op;
rm = (modrm & 7) | REX_B(s);
reg = ((modrm >> 3) & 7) | rex_r;
if (CODE64(s))
ot = OT_QUAD;
else
ot = OT_LONG;
if (reg == 4 || reg == 5 || reg >= 8)
goto illegal_op;
if (b & 2) {
gen_svm_check_intercept(s, pc_start, SVM_EXIT_WRITE_DR0 + reg);
gen_op_mov_TN_reg(ot, 0, rm);
gen_helper_movl_drN_T0(tcg_const_i32(reg), cpu_T[0]);
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
} else {
gen_svm_check_intercept(s, pc_start, SVM_EXIT_READ_DR0 + reg);
tcg_gen_ld_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,dr[reg]));
gen_op_mov_reg_T0(ot, rm);
}
}
break;
case 0x106:
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_svm_check_intercept(s, pc_start, SVM_EXIT_WRITE_CR0);
gen_helper_clts();
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
}
break;
case 0x1c3:
if (!(s->cpuid_features & CPUID_SSE2))
goto illegal_op;
ot = s->dflag == 2 ? OT_QUAD : OT_LONG;
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
if (mod == 3)
goto illegal_op;
reg = ((modrm >> 3) & 7) | rex_r;
gen_ldst_modrm(s, modrm, ot, reg, 1);
break;
case 0x1ae:
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
op = (modrm >> 3) & 7;
switch(op) {
case 0:
if (mod == 3 || !(s->cpuid_features & CPUID_FXSR) ||
(s->flags & HF_EM_MASK))
goto illegal_op;
if (s->flags & HF_TS_MASK) {
gen_exception(s, EXCP07_PREX, pc_start - s->cs_base);
break;
}
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_fxsave(cpu_A0, tcg_const_i32((s->dflag == 2)));
break;
case 1:
if (mod == 3 || !(s->cpuid_features & CPUID_FXSR) ||
(s->flags & HF_EM_MASK))
goto illegal_op;
if (s->flags & HF_TS_MASK) {
gen_exception(s, EXCP07_PREX, pc_start - s->cs_base);
break;
}
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_fxrstor(cpu_A0, tcg_const_i32((s->dflag == 2)));
break;
case 2:
case 3:
if (s->flags & HF_TS_MASK) {
gen_exception(s, EXCP07_PREX, pc_start - s->cs_base);
break;
}
if ((s->flags & HF_EM_MASK) || !(s->flags & HF_OSFXSR_MASK) ||
mod == 3)
goto illegal_op;
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
if (op == 2) {
gen_op_ld_T0_A0(OT_LONG + s->mem_index);
tcg_gen_st32_tl(cpu_T[0], cpu_env, offsetof(CPUX86State, mxcsr));
} else {
tcg_gen_ld32u_tl(cpu_T[0], cpu_env, offsetof(CPUX86State, mxcsr));
gen_op_st_T0_A0(OT_LONG + s->mem_index);
}
break;
case 5:
case 6:
if ((modrm & 0xc7) != 0xc0 || !(s->cpuid_features & CPUID_SSE))
goto illegal_op;
break;
case 7:
if ((modrm & 0xc7) == 0xc0) {
if (!(s->cpuid_features & CPUID_SSE))
goto illegal_op;
} else {
if (!(s->cpuid_features & CPUID_CLFLUSH))
goto illegal_op;
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
}
break;
default:
goto illegal_op;
}
break;
case 0x10d:
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
if (mod == 3)
goto illegal_op;
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
break;
case 0x1aa:
gen_svm_check_intercept(s, pc_start, SVM_EXIT_RSM);
if (!(s->flags & HF_SMM_MASK))
goto illegal_op;
if (s->cc_op != CC_OP_DYNAMIC) {
gen_op_set_cc_op(s->cc_op);
s->cc_op = CC_OP_DYNAMIC;
}
gen_jmp_im(s->pc - s->cs_base);
gen_helper_rsm();
gen_eob(s);
break;
case 0x1b8:
if ((prefixes & (PREFIX_REPZ | PREFIX_LOCK | PREFIX_REPNZ)) !=
PREFIX_REPZ)
goto illegal_op;
if (!(s->cpuid_ext_features & CPUID_EXT_POPCNT))
goto illegal_op;
modrm = ldub_code(s->pc++);
reg = ((modrm >> 3) & 7);
if (s->prefix & PREFIX_DATA)
ot = OT_WORD;
else if (s->dflag != 2)
ot = OT_LONG;
else
ot = OT_QUAD;
gen_ldst_modrm(s, modrm, ot, OR_TMP0, 0);
gen_helper_popcnt(cpu_T[0], cpu_T[0], tcg_const_i32(ot));
gen_op_mov_reg_T0(ot, reg);
s->cc_op = CC_OP_EFLAGS;
break;
case 0x10e ... 0x10f:
s->prefix &= ~(PREFIX_REPZ | PREFIX_REPNZ | PREFIX_DATA);
case 0x110 ... 0x117:
case 0x128 ... 0x12f:
case 0x138 ... 0x13a:
case 0x150 ... 0x177:
case 0x17c ... 0x17f:
case 0x1c2:
case 0x1c4 ... 0x1c6:
case 0x1d0 ... 0x1fe:
gen_sse(s, b, pc_start, rex_r);
break;
default:
goto illegal_op;
}
if (s->prefix & PREFIX_LOCK)
gen_helper_unlock();
return s->pc;
illegal_op:
if (s->prefix & PREFIX_LOCK)
gen_helper_unlock();
gen_exception(s, EXCP06_ILLOP, pc_start - s->cs_base);
return s->pc;
} | 1threat |
How to get specific date in php : <p>I want to get UTC time as in below format.</p>
<blockquote>
<p>2017-09-12T10:14:00.000Z</p>
</blockquote>
<p>Thanks in advance</p>
| 0debug |
Swift4 Error on High Sierra, can't resolve symbol : <p>I've got this prefpane made in Swift and Cocoa... Yesterday I migrated it to Swift 4 as-per-the-migration guide and after some initial pains everything appeared to be working perfectly.</p>
<p>I did this on Sierra, running Xcode 9.0 with the latest SDK.</p>
<p>Problem is, at least two people running High Sierra tell me the pane is not running at all for them. From attempting to run it from the command line, this is the reported error:</p>
<pre><code>2017-09-27 23:00:59.921 System Preferences[3047:337095] Error loading /Users/luckman212/Library/PreferencePanes/SwiftDefaultApps.prefPane/Contents/MacOS/SwiftDefaultApps: dlopen(/Users/luckman212/Library/PreferencePanes/SwiftDefaultApps.prefPane/Contents/MacOS/SwiftDefaultApps, 265): can't resolve symbol _OBJC_CLASS_$_NSError in /Users/luckman212/Library/PreferencePanes/SwiftDefaultApps.prefPane/Contents/MacOS/../Frameworks/libswiftCore.dylib because dependent dylib #1 could not be loaded in /Users/luckman212/Library/PreferencePanes/SwiftDefaultApps.prefPane/Contents/MacOS/../Frameworks/libswiftCore.dylib
2017-09-27 23:00:59.922 System Preferences[3047:337095] [NSPrefPaneBundle instantiatePrefPaneObject] (/Users/luckman212/Library/PreferencePanes/SwiftDefaultApps.prefPane): principalClass is nil.
2017-09-27 23:01:00.072 System Preferences[3047:337095] ### AE 1868656752 sender's PID is 3047 (System Preferences)
</code></pre>
<p>I haven't upgraded yet and have no way to do it at present, even if I was so-inclined. Haas anybody faced this issue, and/or know the cause for it?</p>
| 0debug |
To fetch distinct record in a table using sql : [enter image description here][1]i have redundancy data in the table where i have to fetch only distinct records in my table . here my table data sample
here only unique records should be displayed
which means 4th and last record in the table.. please suggest on this
[1]: http://i.stack.imgur.com/aGzhB.png | 0debug |
static void test_identify(void)
{
uint8_t data;
uint16_t buf[256];
int i;
int ret;
ide_test_start(
"-vnc none "
"-drive file=%s,if=ide,serial=%s,cache=writeback "
"-global ide-hd.ver=%s",
tmp_path, "testdisk", "version");
outb(IDE_BASE + reg_device, 0);
outb(IDE_BASE + reg_command, CMD_IDENTIFY);
data = inb(IDE_BASE + reg_device);
g_assert_cmpint(data & DEV, ==, 0);
for (i = 0; i < 256; i++) {
data = inb(IDE_BASE + reg_status);
assert_bit_set(data, DRDY | DRQ);
assert_bit_clear(data, BSY | DF | ERR);
((uint16_t*) buf)[i] = inw(IDE_BASE + reg_data);
}
data = inb(IDE_BASE + reg_status);
assert_bit_set(data, DRDY);
assert_bit_clear(data, BSY | DF | ERR | DRQ);
string_cpu_to_be16(&buf[10], 20);
ret = memcmp(&buf[10], "testdisk ", 20);
g_assert(ret == 0);
string_cpu_to_be16(&buf[23], 8);
ret = memcmp(&buf[23], "version ", 8);
g_assert(ret == 0);
assert_bit_set(buf[85], 0x20);
ide_test_quit();
}
| 1threat |
static void print_report(int is_last_report, int64_t timer_start)
{
char buf[1024];
OutputStream *ost;
AVFormatContext *oc;
int64_t total_size;
AVCodecContext *enc;
int frame_number, vid, i;
double bitrate, ti1, pts;
static int64_t last_time = -1;
static int qp_histogram[52];
if (!print_stats && !is_last_report)
return;
if (!is_last_report) {
int64_t cur_time;
cur_time = av_gettime();
if (last_time == -1) {
last_time = cur_time;
return;
}
if ((cur_time - last_time) < 500000)
return;
last_time = cur_time;
}
oc = output_files[0]->ctx;
total_size = avio_size(oc->pb);
if (total_size <= 0)
total_size = avio_tell(oc->pb);
if (total_size < 0) {
char errbuf[128];
av_strerror(total_size, errbuf, sizeof(errbuf));
av_log(NULL, AV_LOG_VERBOSE, "Bitrate not available, "
"avio_tell() failed: %s\n", errbuf);
total_size = 0;
}
buf[0] = '\0';
ti1 = 1e10;
vid = 0;
for (i = 0; i < nb_output_streams; i++) {
float q = -1;
ost = output_streams[i];
enc = ost->st->codec;
if (!ost->stream_copy && enc->coded_frame)
q = enc->coded_frame->quality / (float)FF_QP2LAMBDA;
if (vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) {
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "q=%2.1f ", q);
}
if (!vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) {
float t = (av_gettime() - timer_start) / 1000000.0;
frame_number = ost->frame_number;
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "frame=%5d fps=%3d q=%3.1f ",
frame_number, (t > 1) ? (int)(frame_number / t + 0.5) : 0, q);
if (is_last_report)
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "L");
if (qp_hist) {
int j;
int qp = lrintf(q);
if (qp >= 0 && qp < FF_ARRAY_ELEMS(qp_histogram))
qp_histogram[qp]++;
for (j = 0; j < 32; j++)
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "%X", (int)lrintf(log2(qp_histogram[j] + 1)));
}
if (enc->flags&CODEC_FLAG_PSNR) {
int j;
double error, error_sum = 0;
double scale, scale_sum = 0;
char type[3] = { 'Y','U','V' };
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "PSNR=");
for (j = 0; j < 3; j++) {
if (is_last_report) {
error = enc->error[j];
scale = enc->width * enc->height * 255.0 * 255.0 * frame_number;
} else {
error = enc->coded_frame->error[j];
scale = enc->width * enc->height * 255.0 * 255.0;
}
if (j)
scale /= 4;
error_sum += error;
scale_sum += scale;
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "%c:%2.2f ", type[j], psnr(error / scale));
}
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "*:%2.2f ", psnr(error_sum / scale_sum));
}
vid = 1;
}
pts = (double)ost->st->pts.val * av_q2d(ost->st->time_base);
if ((pts < ti1) && (pts > 0))
ti1 = pts;
}
if (ti1 < 0.01)
ti1 = 0.01;
bitrate = (double)(total_size * 8) / ti1 / 1000.0;
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
"size=%8.0fkB time=%0.2f bitrate=%6.1fkbits/s",
(double)total_size / 1024, ti1, bitrate);
if (nb_frames_dup || nb_frames_drop)
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " dup=%d drop=%d",
nb_frames_dup, nb_frames_drop);
av_log(NULL, AV_LOG_INFO, "%s \r", buf);
fflush(stderr);
if (is_last_report) {
int64_t raw= audio_size + video_size + extra_size;
av_log(NULL, AV_LOG_INFO, "\n");
av_log(NULL, AV_LOG_INFO, "video:%1.0fkB audio:%1.0fkB global headers:%1.0fkB muxing overhead %f%%\n",
video_size / 1024.0,
audio_size / 1024.0,
extra_size / 1024.0,
100.0 * (total_size - raw) / raw
);
}
}
| 1threat |
Mean as a window-function in dplyr : <p>I want to calculate group means but save them as a vector next to the raw data. Is there an efficient way to do this in <code>dplyr</code>?</p>
<p>Original <code>data.frame</code>: </p>
<pre><code>dat <- data.frame(
group = c("A","A","A","B","B","B"),
value = c(4, 5, 6, 7, 8, 9)
)
> dat
group value
1 A 4
2 A 5
3 A 6
4 B 7
5 B 8
6 B 9
</code></pre>
<p>Desired <code>data.frame</code> with full vector of group means:</p>
<pre><code>dat2 <- data.frame(
group = c("A","A","A","B","B","B"),
value = c(4, 5, 6, 7, 8, 9),
groupmeanvalue = c(5, 5, 5, 8, 8, 8)
)
> dat2
group value groupmeanvalue
1 A 4 5
2 A 5 5
3 A 6 5
4 B 7 8
5 B 8 8
6 B 9 8
</code></pre>
| 0debug |
Get the height of SafeAreaView from within BottomTabBar : <p>I am attempting to use <a href="https://github.com/Andr3wHur5t/react-native-keyboard-spacer" rel="noreferrer"><code>react-native-keyboard-spacer</code></a> in conjunction with <a href="https://github.com/react-navigation/react-navigation" rel="noreferrer"><code>react-navigation</code></a>.</p>
<p>I am currently setting the <code>topSpacing</code> of the keyboard spacer to be <code>-49</code> which is the height of the tab bar from <code>react-navigation</code>, but the tab bar is within a <a href="https://facebook.github.io/react-native/docs/safeareaview" rel="noreferrer"><code>SafeAreaView</code></a> which <em>magically</em> adds padding to move content into an area that doesn't interfere with native UI.</p>
<p>This means that when viewing the app on an iPhone X, or other similar devices, the tab bar becomes taller than <code>50</code>.</p>
<p>What would be the best way to get the height of the <code>SafeAreaView</code>?</p>
| 0debug |
Firebase and google play on different accounts : <p>I want to integrate a Google Play Account to Firebase. In our company only my boss has owner priviledge for the google play account. The account used for firebase and other tools like adsense has administrator priviledges.</p>
<p>Is it possible to integrate the google play account to firebase in this setup?
How would I do this?</p>
| 0debug |
I can't find the problm area in the following code (finding power of a number using user defined functions). : [code along with the outputstrong text][1]
The following code is not working. It has no errors, am doing some mistake in the logic i think. I am a newbie in programming and following is a very basic code, I want to find power of a number using functions. I kinda suck at functions. Please help me make this code work,I can't find the problem area.
[1]: https://i.stack.imgur.com/a7d9o.png | 0debug |
altivec_yuv2packedX (SwsContext *c,
int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,
int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
uint8_t *dest, int dstW, int dstY)
{
int i,j;
short tmp __attribute__((aligned (16)));
int16_t *p;
short *f;
vector signed short X,X0,X1,Y0,U0,V0,Y1,U1,V1,U,V;
vector signed short R0,G0,B0,R1,G1,B1;
vector unsigned char R,G,B,pels[3];
vector unsigned char *out,*nout;
vector signed short RND = vec_splat((vector signed short)AVV(1<<3),0);
vector unsigned short SCL = vec_splat((vector unsigned short)AVV(4),0);
unsigned long scratch[16] __attribute__ ((aligned (16)));
vector signed short *vYCoeffsBank, *vCCoeffsBank;
vector signed short *YCoeffs, *CCoeffs;
vYCoeffsBank = malloc (sizeof (vector signed short)*lumFilterSize*dstW);
vCCoeffsBank = malloc (sizeof (vector signed short)*chrFilterSize*dstW);
for (i=0;i<lumFilterSize*dstW;i++) {
tmp = c->vLumFilter[i];
p = &vYCoeffsBank[i];
for (j=0;j<8;j++)
p[j] = tmp;
}
for (i=0;i<chrFilterSize*dstW;i++) {
tmp = c->vChrFilter[i];
p = &vCCoeffsBank[i];
for (j=0;j<8;j++)
p[j] = tmp;
}
YCoeffs = vYCoeffsBank+dstY*lumFilterSize;
CCoeffs = vCCoeffsBank+dstY*chrFilterSize;
out = (vector unsigned char *)dest;
for(i=0; i<dstW; i+=16){
Y0 = RND;
Y1 = RND;
for(j=0; j<lumFilterSize; j++) {
X0 = vec_ld (0, &lumSrc[j][i]);
X1 = vec_ld (16, &lumSrc[j][i]);
Y0 = vec_mradds (X0, YCoeffs[j], Y0);
Y1 = vec_mradds (X1, YCoeffs[j], Y1);
}
U = RND;
V = RND;
for(j=0; j<chrFilterSize; j++) {
X = vec_ld (0, &chrSrc[j][i/2]);
U = vec_mradds (X, CCoeffs[j], U);
X = vec_ld (0, &chrSrc[j][i/2+2048]);
V = vec_mradds (X, CCoeffs[j], V);
}
Y0 = vec_sra (Y0, SCL);
Y1 = vec_sra (Y1, SCL);
U = vec_sra (U, SCL);
V = vec_sra (V, SCL);
Y0 = vec_clip (Y0);
Y1 = vec_clip (Y1);
U = vec_clip (U);
V = vec_clip (V);
U0 = vec_mergeh (U,U);
V0 = vec_mergeh (V,V);
U1 = vec_mergel (U,U);
V1 = vec_mergel (V,V);
cvtyuvtoRGB (c, Y0,U0,V0,&R0,&G0,&B0);
cvtyuvtoRGB (c, Y1,U1,V1,&R1,&G1,&B1);
R = vec_packclp (R0,R1);
G = vec_packclp (G0,G1);
B = vec_packclp (B0,B1);
out_rgba (R,G,B,out);
}
if (i < dstW) {
i -= 16;
Y0 = RND;
Y1 = RND;
for(j=0; j<lumFilterSize; j++) {
X0 = vec_ld (0, &lumSrc[j][i]);
X1 = vec_ld (16, &lumSrc[j][i]);
Y0 = vec_mradds (X0, YCoeffs[j], Y0);
Y1 = vec_mradds (X1, YCoeffs[j], Y1);
}
U = RND;
V = RND;
for(j=0; j<chrFilterSize; j++) {
X = vec_ld (0, &chrSrc[j][i/2]);
U = vec_mradds (X, CCoeffs[j], U);
X = vec_ld (0, &chrSrc[j][i/2+2048]);
V = vec_mradds (X, CCoeffs[j], V);
}
Y0 = vec_sra (Y0, SCL);
Y1 = vec_sra (Y1, SCL);
U = vec_sra (U, SCL);
V = vec_sra (V, SCL);
Y0 = vec_clip (Y0);
Y1 = vec_clip (Y1);
U = vec_clip (U);
V = vec_clip (V);
U0 = vec_mergeh (U,U);
V0 = vec_mergeh (V,V);
U1 = vec_mergel (U,U);
V1 = vec_mergel (V,V);
cvtyuvtoRGB (c, Y0,U0,V0,&R0,&G0,&B0);
cvtyuvtoRGB (c, Y1,U1,V1,&R1,&G1,&B1);
R = vec_packclp (R0,R1);
G = vec_packclp (G0,G1);
B = vec_packclp (B0,B1);
nout = (vector unsigned char *)scratch;
out_rgba (R,G,B,nout);
memcpy (&((uint32_t*)dest)[i], scratch, (dstW-i)/4);
}
if (vYCoeffsBank) free (vYCoeffsBank);
if (vCCoeffsBank) free (vCCoeffsBank);
}
| 1threat |
static int decode(AVCodecContext *avctx, void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
const uint8_t *buf_end;
uint8_t segment_type;
int segment_length;
int i, ret;
av_dlog(avctx, "PGS sub packet:\n");
for (i = 0; i < buf_size; i++) {
av_dlog(avctx, "%02x ", buf[i]);
if (i % 16 == 15)
av_dlog(avctx, "\n");
}
if (i & 15)
av_dlog(avctx, "\n");
*data_size = 0;
if (buf_size < 3)
return -1;
buf_end = buf + buf_size;
while (buf < buf_end) {
segment_type = bytestream_get_byte(&buf);
segment_length = bytestream_get_be16(&buf);
av_dlog(avctx, "Segment Length %d, Segment Type %x\n", segment_length, segment_type);
if (segment_type != DISPLAY_SEGMENT && segment_length > buf_end - buf)
break;
switch (segment_type) {
case PALETTE_SEGMENT:
parse_palette_segment(avctx, buf, segment_length);
break;
case PICTURE_SEGMENT:
parse_picture_segment(avctx, buf, segment_length);
break;
case PRESENTATION_SEGMENT:
ret = parse_presentation_segment(avctx, buf, segment_length, avpkt->pts);
if (ret < 0)
return ret;
break;
case WINDOW_SEGMENT:
break;
case DISPLAY_SEGMENT:
*data_size = display_end_segment(avctx, data, buf, segment_length);
break;
default:
av_log(avctx, AV_LOG_ERROR, "Unknown subtitle segment type 0x%x, length %d\n",
segment_type, segment_length);
break;
}
buf += segment_length;
}
return buf_size;
}
| 1threat |
void qemu_del_nic(NICState *nic)
{
int i, queues = nic->conf->queues;
if (nic->peer_deleted) {
for (i = 0; i < queues; i++) {
qemu_free_net_client(qemu_get_subqueue(nic, i)->peer);
}
}
for (i = queues - 1; i >= 0; i--) {
NetClientState *nc = qemu_get_subqueue(nic, i);
qemu_cleanup_net_client(nc);
qemu_free_net_client(nc);
}
}
| 1threat |
How to add other themes for Jekyll Now? : <p>I am using Jekyll Now on GitHub Pages.</p>
<p><code>Version 1.2.0</code></p>
<p>My question is how do I add other themes that are compatible with <code>Jekyll Now</code>?</p>
<p>Is it simply a case of adding the <code>theme: <themename></code> into the <code>_config.yml</code>?</p>
<p>This is the <a href="https://github.com/barryclark/jekyll-now#other-forkable-themes" rel="noreferrer">list of themes</a> compatible with <code>Jekyll Now</code></p>
| 0debug |
static void omap_rtc_alarm_update(struct omap_rtc_s *s)
{
s->alarm_ti = mktimegm(&s->alarm_tm);
if (s->alarm_ti == -1)
printf("%s: conversion failed\n", __FUNCTION__);
}
| 1threat |
envlist_setenv(envlist_t *envlist, const char *env)
{
struct envlist_entry *entry = NULL;
const char *eq_sign;
size_t envname_len;
if ((envlist == NULL) || (env == NULL))
return (EINVAL);
if ((eq_sign = strchr(env, '=')) == NULL)
return (EINVAL);
envname_len = eq_sign - env + 1;
for (entry = envlist->el_entries.lh_first; entry != NULL;
entry = entry->ev_link.le_next) {
if (strncmp(entry->ev_var, env, envname_len) == 0)
break;
}
if (entry != NULL) {
LIST_REMOVE(entry, ev_link);
free((char *)entry->ev_var);
free(entry);
} else {
envlist->el_count++;
}
if ((entry = malloc(sizeof (*entry))) == NULL)
return (errno);
if ((entry->ev_var = strdup(env)) == NULL) {
free(entry);
return (errno);
}
LIST_INSERT_HEAD(&envlist->el_entries, entry, ev_link);
return (0);
}
| 1threat |
Create a nested json object from another nested json object : As the question states, I want to create a new object from a current json object.
My current json object:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
{
"name": "Parent",
"children": [
{
"name": "Child1",
"children": [
{
"name": "GrandChid1",
"children": []
},
{
"name": "GrandChild2",
"children": []
},
{
"name": "GrandChild3",
"children": [
{
"name": "GrandGrandChild1",
"children": [
{
"name": "GrandGrandGrandChild1",
"children": []
},
{
"name": "GrandGrandGrandChild2",
"children": []
}
]
}
]
}
]
}
]
}
<!-- end snippet -->
Now the new object will look something like this:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
{
"Parent": [
{
"name": "Child1",
"Child1": [
{
"GrandChid1": ''
},
{
"GrandChild2": ''
},
{
"GrandChild3": [
{
"GrandGrandChild1": [
{
"GrandGrandGrandChild1": ''
},
{
"GrandGrandGrandChild2": ''
}
]
}
]
}
]
}
]
}
<!-- end snippet -->
if there are no children then it becomes a string (simple key value) pair.
Any help is appreciated especially with a recursive solution | 0debug |
How to write the below result in a file in python/How to store the results : Have made a python GUI and now I want to store the variable say Reference and Total cost in a file how can I achieve that?[enter image description here][1]
Have tried writing a file like :
def writetofile():
import os
outputname ='tutorial.txt'
a= "TotalCost"
myfile = open(outputname,'w')
myfile.write('File A value is : ' + str(a) + '\n')
myfile.close()
if os.stat(outputname).st_size > 0:
print("tutorial.txt file has been populated")
else:
print("the output value is empty")
print("The A value should read: " + str(a) + '\n')
writetofile()
but only the text is coming not the calculated value of TotalCost
[1]: https://i.stack.imgur.com/EeR4Q.jpg | 0debug |
SourceTree - how to checkout to remote repo branch : <p>I create a new branch in remote GIT repository. Repository stored on BitBucket.</p>
<p>In my my local repository I can see this new branch with SourceTree. It appears in commits list, on same commit I create branch from. But I cannot see this new branch under branches list and cannot checkout it. </p>
<p>I want to checkout and push updated on my local workstation code to remote repository back, but within exactly this new branch. I started development on same branch, what was source to clone new branch.</p>
<p>I tried to pull this new branch. It is empty as it should, but it still not under branches list and I cannot checkout it.</p>
<p>How to commit to this new branch?</p>
| 0debug |
How to use Python's RotatingFileHandler : <p>I'm trying to do a test run of the <code>logging</code> module's <code>RotatingFileHandler</code> as follows:</p>
<pre><code>import logging
from logging.handlers import RotatingFileHandler
# logging.basicConfig(filename="example.log", level=logging.DEBUG)
logger = logging.getLogger('my_logger')
handler = RotatingFileHandler("my_log.log", maxBytes=2000, backupCount=10)
logger.addHandler(handler)
for _ in range(10000):
logger.debug("Hello, world!")
</code></pre>
<p>However, with <code>logging.basicConfig</code> line commented out, the resulting <code>my_log.log</code> file contains no data:</p>
<p><a href="https://i.stack.imgur.com/Q3CoP.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Q3CoP.png" alt="enter image description here"></a></p>
<p>If I comment in the line with <code>logging.basicConfig(filename="example.log", level=logging.DEBUG)</code>, I get the expected <code>my_log.log</code> files with numbered suffixes. However, there is also the <code>example.log</code> which is a (relatively) large file:</p>
<p><a href="https://i.stack.imgur.com/J77C7.png" rel="noreferrer"><img src="https://i.stack.imgur.com/J77C7.png" alt="enter image description here"></a></p>
<p>How can I set up the logging so that it only generates the <code>my_log.log</code> files, and not the large <code>example.log</code> file?</p>
| 0debug |
static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, int predictor, int point_transform){
int i, mb_x, mb_y;
uint16_t buffer[2048][4];
int left[3], top[3], topleft[3];
const int linesize= s->linesize[0];
const int mask= (1<<s->bits)-1;
for(i=0; i<3; i++){
buffer[0][i]= 1 << (s->bits + point_transform - 1);
}
for(mb_y = 0; mb_y < s->mb_height; mb_y++) {
const int modified_predictor= mb_y ? predictor : 1;
uint8_t *ptr = s->picture.data[0] + (linesize * mb_y);
if (s->interlaced && s->bottom_field)
ptr += linesize >> 1;
for(i=0; i<3; i++){
top[i]= left[i]= topleft[i]= buffer[0][i];
}
for(mb_x = 0; mb_x < s->mb_width; mb_x++) {
if (s->restart_interval && !s->restart_count)
s->restart_count = s->restart_interval;
for(i=0;i<3;i++) {
int pred;
topleft[i]= top[i];
top[i]= buffer[mb_x][i];
PREDICT(pred, topleft[i], top[i], left[i], modified_predictor);
left[i]=
buffer[mb_x][i]= mask & (pred + (mjpeg_decode_dc(s, s->dc_index[i]) << point_transform));
}
if (s->restart_interval && !--s->restart_count) {
align_get_bits(&s->gb);
skip_bits(&s->gb, 16);
}
}
if(s->rct){
for(mb_x = 0; mb_x < s->mb_width; mb_x++) {
ptr[4*mb_x+1] = buffer[mb_x][0] - ((buffer[mb_x][1] + buffer[mb_x][2] - 0x200)>>2);
ptr[4*mb_x+0] = buffer[mb_x][1] + ptr[4*mb_x+1];
ptr[4*mb_x+2] = buffer[mb_x][2] + ptr[4*mb_x+1];
}
}else if(s->pegasus_rct){
for(mb_x = 0; mb_x < s->mb_width; mb_x++) {
ptr[4*mb_x+1] = buffer[mb_x][0] - ((buffer[mb_x][1] + buffer[mb_x][2])>>2);
ptr[4*mb_x+0] = buffer[mb_x][1] + ptr[4*mb_x+1];
ptr[4*mb_x+2] = buffer[mb_x][2] + ptr[4*mb_x+1];
}
}else{
for(mb_x = 0; mb_x < s->mb_width; mb_x++) {
ptr[4*mb_x+0] = buffer[mb_x][0];
ptr[4*mb_x+1] = buffer[mb_x][1];
ptr[4*mb_x+2] = buffer[mb_x][2];
}
}
}
return 0;
}
| 1threat |
static inline void RENAME(hyscale)(SwsContext *c, uint16_t *dst, long dstWidth, const uint8_t *src, int srcW, int xInc,
const int16_t *hLumFilter,
const int16_t *hLumFilterPos, int hLumFilterSize,
uint8_t *formatConvBuffer,
uint32_t *pal, int isAlpha)
{
void (*toYV12)(uint8_t *, const uint8_t *, long, uint32_t *) = isAlpha ? c->alpToYV12 : c->lumToYV12;
void (*convertRange)(int16_t *, int) = isAlpha ? NULL : c->lumConvertRange;
src += isAlpha ? c->alpSrcOffset : c->lumSrcOffset;
if (toYV12) {
toYV12(formatConvBuffer, src, srcW, pal);
src= formatConvBuffer;
}
if (c->hScale16) {
c->hScale16(dst, dstWidth, (uint16_t*)src, srcW, xInc, hLumFilter, hLumFilterPos, hLumFilterSize, av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1);
} else if (!c->hyscale_fast) {
c->hScale(dst, dstWidth, src, srcW, xInc, hLumFilter, hLumFilterPos, hLumFilterSize);
} else {
c->hyscale_fast(c, dst, dstWidth, src, srcW, xInc);
}
if (convertRange)
convertRange(dst, dstWidth);
}
| 1threat |
static void version(void)
{
printf("qemu-" TARGET_ARCH " version " QEMU_VERSION QEMU_PKGVERSION
", Copyright (c) 2003-2008 Fabrice Bellard\n");
}
| 1threat |
How to get request's URI from WebRequest in Spring? : <p>I am handling REST exceptions using <code>@ControllerAdvice</code> and <code>ResponseEntityExceptionHandler</code> in a spring Rest webservice. So far everything was working fine until I decided to add the <code>URI</code> path(for which exception has occurred) into the <strong>BAD_REQUEST</strong> response.</p>
<pre><code>@ControllerAdvice
public class RestResponseEntityExceptionHandler extends ResponseEntityExceptionHandler {
@Override
protected ResponseEntity<Object> handleHttpMessageNotReadable(HttpMessageNotReadableException ex,
HttpHeaders headers, HttpStatus status, WebRequest request) {
logger.info(request.toString());
return handleExceptionInternal(ex, errorMessage(HttpStatus.BAD_REQUEST, ex, request), headers, HttpStatus.BAD_REQUEST, request);
}
private ApiError errorMessage(HttpStatus httpStatus, Exception ex, WebRequest request) {
final String message = ex.getMessage() == null ? ex.getClass().getName() : ex.getMessage();
final String developerMessage = ex.getCause() == null ? ex.toString() : ex.getCause().getMessage();
return new ApiError(httpStatus.value(), message, developerMessage, System.currentTimeMillis(), request.getDescription(false));
}
</code></pre>
<p>ApiError is just a Pojo class:</p>
<pre><code>public class ApiError {
private Long timeStamp;
private int status;
private String message;
private String developerMessage;
private String path;
}
</code></pre>
<p>But WebRequest has not given any api to get the path for which the request failed. I tried:
<code>request.toString()</code> returns -> <em>ServletWebRequest: uri=/signup;client=0:0:0:0:0:0:0:1</em><br>
<code>request.getDescription(false)</code> returns -> <em>uri=/signup</em><br>
<code>getDescription</code> is pretty close to the requirement, but doesn't meet it. Is there any way to get only the uri part?</p>
| 0debug |
mips_mipssim_init (ram_addr_t ram_size, int vga_ram_size,
const char *boot_device, DisplayState *ds,
const char *kernel_filename, const char *kernel_cmdline,
const char *initrd_filename, const char *cpu_model)
{
char buf[1024];
unsigned long bios_offset;
CPUState *env;
int bios_size;
if (cpu_model == NULL) {
#ifdef TARGET_MIPS64
cpu_model = "5Kf";
#else
cpu_model = "24Kf";
#endif
}
env = cpu_init(cpu_model);
if (!env) {
fprintf(stderr, "Unable to find CPU definition\n");
exit(1);
}
qemu_register_reset(main_cpu_reset, env);
cpu_register_physical_memory(0, ram_size, IO_MEM_RAM);
bios_offset = ram_size + vga_ram_size;
if (bios_name == NULL)
bios_name = BIOS_FILENAME;
snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
bios_size = load_image(buf, phys_ram_base + bios_offset);
if ((bios_size < 0 || bios_size > BIOS_SIZE) && !kernel_filename) {
fprintf(stderr,
"qemu: Could not load MIPS bios '%s', and no -kernel argument was specified\n",
buf);
exit(1);
} else {
cpu_register_physical_memory(0x1fc00000LL,
bios_size, bios_offset | IO_MEM_ROM);
env->active_tc.PC = (target_long)(int32_t)0xbfc00000;
}
if (kernel_filename) {
loaderparams.ram_size = ram_size;
loaderparams.kernel_filename = kernel_filename;
loaderparams.kernel_cmdline = kernel_cmdline;
loaderparams.initrd_filename = initrd_filename;
load_kernel(env);
}
cpu_mips_irq_init_cpu(env);
cpu_mips_clock_init(env);
isa_mmio_init(0x1fd00000, 0x00010000);
if (serial_hds[0])
serial_init(0x3f8, env->irq[4], 115200, serial_hds[0]);
if (nd_table[0].vlan) {
if (nd_table[0].model == NULL
|| strcmp(nd_table[0].model, "mipsnet") == 0) {
mipsnet_init(0x4200, env->irq[2], &nd_table[0]);
} else if (strcmp(nd_table[0].model, "?") == 0) {
fprintf(stderr, "qemu: Supported NICs: mipsnet\n");
exit (1);
} else {
fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd_table[0].model);
exit (1);
}
}
}
| 1threat |
Associativity of fold-expressions : <p><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4191.html" rel="noreferrer"><strong>N4191</strong></a> proposed fold-expressions to C++. The definition there was that</p>
<pre><code>(args + ...)
</code></pre>
<p>is a left-fold (i.e. <code>(((a0 + a1) + a2) + ...)</code>, and that </p>
<pre><code>(... + args)
</code></pre>
<p>is a right-fold (i.e. <code>(... + (a8 + (a9 + a10)))</code>. However, the revised paper <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4295.html" rel="noreferrer"><strong>N4295</strong></a> reversed the definitions of left and right unary folds.</p>
<p><strong>Question</strong>: what is the rationale? It seems more intuitive (at least when you are used to left-to-right alphabets) to evaluate <code>(args + ...)</code> from left-to-right.</p>
| 0debug |
solisten(port, laddr, lport, flags)
u_int port;
u_int32_t laddr;
u_int lport;
int flags;
{
struct sockaddr_in addr;
struct socket *so;
int s, addrlen = sizeof(addr), opt = 1;
DEBUG_CALL("solisten");
DEBUG_ARG("port = %d", port);
DEBUG_ARG("laddr = %x", laddr);
DEBUG_ARG("lport = %d", lport);
DEBUG_ARG("flags = %x", flags);
if ((so = socreate()) == NULL) {
return NULL;
}
if ((so->so_tcpcb = tcp_newtcpcb(so)) == NULL) {
free(so);
return NULL;
}
insque(so,&tcb);
if (flags & SS_FACCEPTONCE)
so->so_tcpcb->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT*2;
so->so_state = (SS_FACCEPTCONN|flags);
so->so_lport = lport;
so->so_laddr.s_addr = laddr;
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = INADDR_ANY;
addr.sin_port = port;
if (((s = socket(AF_INET,SOCK_STREAM,0)) < 0) ||
(setsockopt(s,SOL_SOCKET,SO_REUSEADDR,(char *)&opt,sizeof(int)) < 0) ||
(bind(s,(struct sockaddr *)&addr, sizeof(addr)) < 0) ||
(listen(s,1) < 0)) {
int tmperrno = errno;
close(s);
sofree(so);
#ifdef _WIN32
WSASetLastError(tmperrno);
#else
errno = tmperrno;
#endif
return NULL;
}
setsockopt(s,SOL_SOCKET,SO_OOBINLINE,(char *)&opt,sizeof(int));
getsockname(s,(struct sockaddr *)&addr,&addrlen);
so->so_fport = addr.sin_port;
if (addr.sin_addr.s_addr == 0 || addr.sin_addr.s_addr == loopback_addr.s_addr)
so->so_faddr = alias_addr;
else
so->so_faddr = addr.sin_addr;
so->s = s;
return so;
}
| 1threat |
void cpu_dump_state(CPUState *env, FILE *f,
int (*cpu_fprintf)(FILE *f, const char *fmt, ...),
int flags)
{
int i, x;
cpu_fprintf(f, "pc: " TARGET_FMT_lx " npc: " TARGET_FMT_lx "\n", env->pc,
env->npc);
cpu_fprintf(f, "General Registers:\n");
for (i = 0; i < 4; i++)
cpu_fprintf(f, "%%g%c: " TARGET_FMT_lx "\t", i + '0', env->gregs[i]);
cpu_fprintf(f, "\n");
for (; i < 8; i++)
cpu_fprintf(f, "%%g%c: " TARGET_FMT_lx "\t", i + '0', env->gregs[i]);
cpu_fprintf(f, "\nCurrent Register Window:\n");
for (x = 0; x < 3; x++) {
for (i = 0; i < 4; i++)
cpu_fprintf(f, "%%%c%d: " TARGET_FMT_lx "\t",
(x == 0 ? 'o' : (x == 1 ? 'l' : 'i')), i,
env->regwptr[i + x * 8]);
cpu_fprintf(f, "\n");
for (; i < 8; i++)
cpu_fprintf(f, "%%%c%d: " TARGET_FMT_lx "\t",
(x == 0 ? 'o' : x == 1 ? 'l' : 'i'), i,
env->regwptr[i + x * 8]);
cpu_fprintf(f, "\n");
}
cpu_fprintf(f, "\nFloating Point Registers:\n");
for (i = 0; i < 32; i++) {
if ((i & 3) == 0)
cpu_fprintf(f, "%%f%02d:", i);
cpu_fprintf(f, " %016lf", env->fpr[i]);
if ((i & 3) == 3)
cpu_fprintf(f, "\n");
}
#ifdef TARGET_SPARC64
cpu_fprintf(f, "pstate: 0x%08x ccr: 0x%02x asi: 0x%02x tl: %d fprs: %d\n",
env->pstate, GET_CCR(env), env->asi, env->tl, env->fprs);
cpu_fprintf(f, "cansave: %d canrestore: %d otherwin: %d wstate %d "
"cleanwin %d cwp %d\n",
env->cansave, env->canrestore, env->otherwin, env->wstate,
env->cleanwin, env->nwindows - 1 - env->cwp);
#else
cpu_fprintf(f, "psr: 0x%08x -> %c%c%c%c %c%c%c wim: 0x%08x\n",
GET_PSR(env), GET_FLAG(PSR_ZERO, 'Z'), GET_FLAG(PSR_OVF, 'V'),
GET_FLAG(PSR_NEG, 'N'), GET_FLAG(PSR_CARRY, 'C'),
env->psrs?'S':'-', env->psrps?'P':'-',
env->psret?'E':'-', env->wim);
#endif
cpu_fprintf(f, "fsr: 0x%08x\n", GET_FSR32(env));
}
| 1threat |
Java Cannot intialize ArrayList variables in constructor : I have several different types of ArrayLists. Each stores split data from a .csv file.
//NOTE: this is for understanding, syntax may not be correct.
ArrayList<String> name = {item1, item2, item3, item4};
ArrayList<String> type = {type1, type2, type3, type4};
ArrayList<Double> price = {price1, price2, price3, price4};
ArrayList<Integer> qty = {qty1, qty2, qty3, qty4};
In my Item class I have a constructor like so,
public Items(String t, String n, Double p, Integer q){
type = t; //type mismatch : cannot convert from String to ArrayList<String>
name = n;//type mismatch : cannot convert from String to ArrayList<String>
price = p;//type mismatch : cannot convert from Double to ArrayList<Double>
qty = q;//type mismatch : cannot convert from Integer to ArrayList<Integer>
}
As you can see, I cant initialize my constructor because of different types. However, in my main method I call each variable as so,
public static void main(String[] args){
ArrayList<Items> itm = new ArrayList<Items>();
Items general = new Items();
//place each item into object itm
for(int i = 0; general.name.size(); i++)
{
itm.add(new Items(general.type.get(i), general.name.get(i), general.price.get(i); general.qty.get(i)));
} //throws no syntax errors
If I put "general.name.get(i)" for example, wouldn't Java see that as a String and not an ArrayList? How do I initialize these variables in my constructor?
| 0debug |
Please help me to SUM SQL tables : Please help me to get a expected output. I have 2 tables
table 1
[CODE]
Project_Name Start Date
P-2018-001 2018/06/20
P-2018-002 2018/06/21
P-2018-003 2018/06/22
[/CODE]
table 2
[CODE]
Date Project_Name Staff Working_Time
2018/06/20 P-2018-001 Staff01 8
2018/06/20 P-2018-002 Staff02 6
2018/06/21 P-2018-001 Staff03 9
2018/06/21 P-2018-003 Staff02 8
2018/06/21 P-2018-002 Staff01 9
2018/06/22 P-2018-003 Staff03 5
2018/06/22 P-2018-002 Staff01 7
2018/06/22 P-2018-001 Staff02 10
[/CODE]
Expected Output:
[CODE]
Project_Name Start Date Staff01 Staff02 Staff03
P-2018-001 2018/06/20 8 10 9
P-2018-002 2018/06/21 16 6 0
P-2018-003 2018/06/22 0 8 5
[/CODE] | 0debug |
find name and add sentence in C# (windows form) : I have a name List (name.txt) and want if find "David" name , A line before add "find my name"
For example:
Name.txt:
<br>
Jacob
<br>
William
<br>
Ethan
<br>
James
<br>
**David**
--------------
i want =
<br>
Jacob
<br>
William
<br>
Ethan
<br>
James
<br>
**"find my word"**
<br>
**David**
tip: David name may have been repeated many times!
I want Repeat "find my word"
my code:
private void button1_Click(object sender, EventArgs e)
{
if (File.Exists("name.txt"))
{
string content = File.ReadAllText("name.txt");
string sensentence = "find my name";
//I don't know how to proceed
}
}
Thanks Guys | 0debug |
Updating column datatype in mongodb : <p>I am trying to update datatype of a column in mongodb dataset, but even after successful run of command expected changes are not reflecting in compass.</p>
<p>query:</p>
<pre><code>db.EquityPrice.find().forEach(function(data) {
db.EquityPrice.update({_id : doc._id}, {$set : {Trade_Date : new Date(doc.Trade_Date) }});
})
</code></pre>
<p>Can anyone please help to figure out where I am going wrong?</p>
| 0debug |
can we modify private variables in child class : <blockquote>
<p>can we <em>modify</em> a private variable through <strong>child class</strong>. <br/>We can use it by set and get methods but how can we modify them in child class. </p>
</blockquote>
| 0debug |
Python 'map' function inserting NaN, possible to return original values instead? : <p>I am passing a dictionary to the <code>map</code> function to recode values in the column of a Pandas dataframe. However, I noticed that if there is a value in the original series that is not explicitly in the dictionary, it gets recoded to <code>NaN</code>. Here is a simple example:</p>
<p>Typing...</p>
<pre><code>s = pd.Series(['one','two','three','four'])
</code></pre>
<p>...creates the series</p>
<pre><code>0 one
1 two
2 three
3 four
dtype: object
</code></pre>
<p>But applying the map...</p>
<pre><code>recodes = {'one':'A', 'two':'B', 'three':'C'}
s.map(recodes)
</code></pre>
<p>...returns the series</p>
<pre><code>0 A
1 B
2 C
3 NaN
dtype: object
</code></pre>
<p>I would prefer that if any element in series <code>s</code> is not in the <code>recodes</code> dictionary, it remains unchanged. That is, I would prefer to return the series below (with the original <code>four</code> instead of <code>NaN</code>).</p>
<pre><code>0 A
1 B
2 C
3 four
dtype: object
</code></pre>
<p>Is there an easy way to do this, for example an option to pass to the <code>map</code> function? The challenge I am having is that I can't always anticipate all possible values that will be in the series I'm recoding - the data will be updated in the future and new values could appear. </p>
<p>Thanks!</p>
| 0debug |
NestedScrollView could not scroll with match_parent height child : <p>I implement NonSwipeableViewPager with a fragment has NestedScrollView like this, what I expect is that the scrollview can scroll up and show 2 textviews:</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="match_parent"
layout="@layout/header" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="16dp"
android:src="@drawable/ic_up" />
</RelativeLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Text 1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Text 2" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</code></pre>
<p>But it could not scroll, I tried many ways but still did not get any solution</p>
| 0debug |
enum AVPixelFormat avpriv_fmt_v4l2ff(uint32_t v4l2_fmt, enum AVCodecID codec_id)
{
int i;
for (i = 0; avpriv_fmt_conversion_table[i].codec_id != AV_CODEC_ID_NONE; i++) {
if (avpriv_fmt_conversion_table[i].v4l2_fmt == v4l2_fmt &&
avpriv_fmt_conversion_table[i].codec_id == codec_id) {
return avpriv_fmt_conversion_table[i].ff_fmt;
}
}
return AV_PIX_FMT_NONE;
}
| 1threat |
static int dirac_decode_picture_header(DiracContext *s)
{
unsigned retire, picnum;
int i, j, ret;
int64_t refdist, refnum;
GetBitContext *gb = &s->gb;
picnum = s->current_picture->avframe->display_picture_number = get_bits_long(gb, 32);
av_log(s->avctx,AV_LOG_DEBUG,"PICTURE_NUM: %d\n",picnum);
if (s->frame_number < 0)
s->frame_number = picnum;
s->ref_pics[0] = s->ref_pics[1] = NULL;
for (i = 0; i < s->num_refs; i++) {
refnum = (picnum + dirac_get_se_golomb(gb)) & 0xFFFFFFFF;
refdist = INT64_MAX;
for (j = 0; j < MAX_REFERENCE_FRAMES && refdist; j++)
if (s->ref_frames[j]
&& FFABS(s->ref_frames[j]->avframe->display_picture_number - refnum) < refdist) {
s->ref_pics[i] = s->ref_frames[j];
refdist = FFABS(s->ref_frames[j]->avframe->display_picture_number - refnum);
}
if (!s->ref_pics[i] || refdist)
av_log(s->avctx, AV_LOG_DEBUG, "Reference not found\n");
if (!s->ref_pics[i])
for (j = 0; j < MAX_FRAMES; j++)
if (!s->all_frames[j].avframe->data[0]) {
s->ref_pics[i] = &s->all_frames[j];
get_buffer_with_edge(s->avctx, s->ref_pics[i]->avframe, AV_GET_BUFFER_FLAG_REF);
break;
}
if (!s->ref_pics[i]) {
av_log(s->avctx, AV_LOG_ERROR, "Reference could not be allocated\n");
return AVERROR_INVALIDDATA;
}
}
if (s->current_picture->reference) {
retire = (picnum + dirac_get_se_golomb(gb)) & 0xFFFFFFFF;
if (retire != picnum) {
DiracFrame *retire_pic = remove_frame(s->ref_frames, retire);
if (retire_pic)
retire_pic->reference &= DELAYED_PIC_REF;
else
av_log(s->avctx, AV_LOG_DEBUG, "Frame to retire not found\n");
}
while (add_frame(s->ref_frames, MAX_REFERENCE_FRAMES, s->current_picture)) {
av_log(s->avctx, AV_LOG_ERROR, "Reference frame overflow\n");
remove_frame(s->ref_frames, s->ref_frames[0]->avframe->display_picture_number)->reference &= DELAYED_PIC_REF;
}
}
if (s->num_refs) {
ret = dirac_unpack_prediction_parameters(s);
if (ret < 0)
return ret;
ret = dirac_unpack_block_motion_data(s);
if (ret < 0)
return ret;
}
ret = dirac_unpack_idwt_params(s);
if (ret < 0)
return ret;
init_planes(s);
return 0;
}
| 1threat |
static int hds_flush(AVFormatContext *s, OutputStream *os, int final,
int64_t end_ts)
{
HDSContext *c = s->priv_data;
int i, ret = 0;
char target_filename[1024];
int index = s->streams[os->first_stream]->id;
if (!os->packets_written)
return 0;
avio_flush(os->ctx->pb);
os->packets_written = 0;
close_file(os);
snprintf(target_filename, sizeof(target_filename),
"%s/stream%dSeg1-Frag%d", s->filename, index, os->fragment_index);
ret = ff_rename(os->temp_filename, target_filename);
if (ret < 0)
return ret;
add_fragment(os, target_filename, os->frag_start_ts, end_ts - os->frag_start_ts);
if (!final) {
ret = init_file(s, os, end_ts);
if (ret < 0)
return ret;
}
if (c->window_size || (final && c->remove_at_exit)) {
int remove = os->nb_fragments - c->window_size - c->extra_window_size;
if (final && c->remove_at_exit)
remove = os->nb_fragments;
if (remove > 0) {
for (i = 0; i < remove; i++) {
unlink(os->fragments[i]->file);
av_free(os->fragments[i]);
}
os->nb_fragments -= remove;
memmove(os->fragments, os->fragments + remove,
os->nb_fragments * sizeof(*os->fragments));
}
}
if (ret >= 0)
ret = write_abst(s, os, final);
return ret;
}
| 1threat |
Java Regular Expression to mask sensitive data in access log : "PUT /v1/users/me/change_password.json?api_key=pDY0VK7YFv9btw6pasXZ¤t_password=Qwerty123&password=Qwerty1234&password_confirmation=Qwerty1234 HTTP/1.1" 200 -
I need regular expression which replace password ,current_password and password_confirmation values with text Filtered.
Required Output
"PUT /v1/users/me/change_password.json?api_key=pDY0VK7YFv9btw6pasXZ¤t_password=[FILTERED]&password=[FILTERED]&password_confirmation=[FILTERED] HTTP/1.1" 200 -
| 0debug |
temp += {expression}; vs temp = {expression}; sum += temp; : I just finished spending ~4hours debugging an issue I had with a larger program, and even after fixing it, I still can't figure out why it was causing an issue.
Here's the mini version of the code:
#include <cstdlib>
#include<iostream>
#include <math.h>
#define PI 3.1415926535897932384626433832795 // the value of PI
void calculate_idct(double input_data[8][8], double out64[8][8], double fcosine[8][8]){
double temp;
for (int x=0;x<8;x++){
for (int y=0;y<8;y++){
temp = 0.0;
for (int u=0;u<8;u++){
for (int v=0;v<8;v++){
temp += input_data[u][v] * fcosine[x][u] * fcosine[y][v];
if (u == 0){
temp /= (double) sqrt(2);
}
if (v==0){
temp /= (double) sqrt(2);
}
}
}
out64[x][y] = temp/4;
}
}
}
///THE WORKING ONE
void calculate_idct2(double input[8][8], double out[8][8], double fcosine[8][8]){
double temp, sum;
for (int x =0;x<8;x++){
for (int y=0;y<8;y++){
sum = 0;
for (int u=0;u<8;u++){
for (int v=0;v<8;v++){
temp = input[u][v] * fcosine[x][u] * fcosine[y][v];
//I don't get it at all, but making the above line a
// += gives the wrong result
if (!u){
temp /= (double) sqrt(2);
}
if (!v){
temp /= (double) sqrt(2);
}
sum +=temp;
}
}
out[x][y] = (sum/4);
}
}
}
void calculate_dct(double input_data[8][8], double out64[8][8], double fcosine[8][8]) {
unsigned char u, v, x, y;
double temp;
// do forward discrete cosine transform
for (u = 0; u < 8; u++)
for (v = 0; v < 8; v++) {
temp = 0.0;
for (x = 0; x < 8; x++)
for (y = 0; y < 8; y++)
temp += input_data[x][y] * fcosine[x][u] * fcosine[y][v];
if ((u == 0) && (v == 0))
temp /= 8.0;
else if (((u == 0) && (v != 0)) || ((u != 0) && (v == 0)))
temp /= (4.0*sqrt(2.0));
else
temp /= 4.0;
out64[u][v] = temp;
}
}
void make_cosine_tbl(double cosine[8][8]) {
// calculate the cosine table as defined in the formula
for (unsigned char i = 0; i < 8; i++)
for (unsigned char j = 0; j < 8; j++)
cosine[i][j] = cos((((2*i)+1)*j*PI)/16);
}
using namespace std;
int main(int argc, char** argv) {
double cosine[8][8];
make_cosine_tbl(cosine);
double input_data[8][8] = {{255, 0, 255, 0, 255, 0, 255, 0},
{0, 255, 0, 255, 0, 255, 0, 255},
{255, 0, 255, 0, 255, 0, 255, 0},
{0, 255, 0, 255, 0, 255, 0, 255},
{255, 0, 255, 0, 255, 0, 255, 0},
{0, 255, 0, 255, 0, 255, 0, 255},
{255, 0, 255, 0, 255, 0, 255, 0},
{0, 255, 0, 255, 0, 255, 0, 255} };
double out64[8][8];
calculate_dct(input_data, out64, cosine);
double out5[8][8];
cout << "Input" << endl;
for (int i = 0;i<8;i++){
for (int j=0;j<8;j++){
cout << input_data[i][j] << " ";
}
cout << endl;
}
cout << "\n Version 1 \n " << endl;
calculate_idct(out64,out5,cosine);
for (int i = 0;i<8;i++){
for (int j=0;j<8;j++){
cout << out5[i][j] << " ";
}
cout << endl;
}
cout << "\n Version 2 \n " << endl;
calculate_idct2(out64,out5,cosine);
for (int i = 0;i<8;i++){
for (int j=0;j<8;j++){
cout << out5[i][j] << " ";
}
cout << endl;
}
}
Here's the output:
Version 1
60.7617 -58.7695 60.7617 -58.7695 60.7617 -58.7695 60.7617 -58.7695
-116.404 118.396 -116.404 118.396 -116.404 118.396 -116.404 118.396
135.3 -133.308 135.3 -133.308 135.3 -133.308 135.3 -133.308
-139.93 141.922 -139.93 141.922 -139.93 141.922 -139.93 141.922
141.922 -139.93 141.922 -139.93 141.922 -139.93 141.922 -139.93
-133.308 135.3 -133.308 135.3 -133.308 135.3 -133.308 135.3
118.396 -116.404 118.396 -116.404 118.396 -116.404 118.396 -116.404
-58.7695 60.7617 -58.7695 60.7617 -58.7695 60.7617 -58.7695 60.7617
Version 2
255 -1.42109e-14 255 -7.10543e-15 255 2.13163e-14 255 -7.10543e-14
3.55271e-15 255 -1.13687e-13 255 -9.9476e-14 255 1.7053e-13 255
255 -5.68434e-14 255 0 255 -2.84217e-14 255 -1.91847e-13
6.39488e-14 255 0 255 -5.68434e-14 255 1.56319e-13 255
255 -5.68434e-14 255 -5.68434e-14 255 -2.84217e-14 255 -1.27898e-13
7.10543e-15 255 0 255 0 255 2.13163e-13 255
255 2.98428e-13 255 2.55795e-13 255 2.13163e-13 255 1.52767e-13
3.55271e-15 255 -4.9738e-14 255 -2.84217e-14 255 1.74083e-13 255
Version 2 is right, but Version 1 is no where close to being correct.
I got the program working, but I am curiosity as to why there was such a big difference. This was for a school assignment, and fdct was given to us.
| 0debug |
static inline void RENAME(rgb32tobgr15)(const uint8_t *src, uint8_t *dst, unsigned src_size)
{
const uint8_t *s = src;
const uint8_t *end;
#ifdef HAVE_MMX
const uint8_t *mm_end;
#endif
uint16_t *d = (uint16_t *)dst;
end = s + src_size;
#ifdef HAVE_MMX
__asm __volatile(PREFETCH" %0"::"m"(*src):"memory");
__asm __volatile(
"movq %0, %%mm7\n\t"
"movq %1, %%mm6\n\t"
::"m"(red_15mask),"m"(green_15mask));
mm_end = end - 15;
while(s < mm_end)
{
__asm __volatile(
PREFETCH" 32%1\n\t"
"movd %1, %%mm0\n\t"
"movd 4%1, %%mm3\n\t"
"punpckldq 8%1, %%mm0\n\t"
"punpckldq 12%1, %%mm3\n\t"
"movq %%mm0, %%mm1\n\t"
"movq %%mm0, %%mm2\n\t"
"movq %%mm3, %%mm4\n\t"
"movq %%mm3, %%mm5\n\t"
"psllq $7, %%mm0\n\t"
"psllq $7, %%mm3\n\t"
"pand %%mm7, %%mm0\n\t"
"pand %%mm7, %%mm3\n\t"
"psrlq $6, %%mm1\n\t"
"psrlq $6, %%mm4\n\t"
"pand %%mm6, %%mm1\n\t"
"pand %%mm6, %%mm4\n\t"
"psrlq $19, %%mm2\n\t"
"psrlq $19, %%mm5\n\t"
"pand %2, %%mm2\n\t"
"pand %2, %%mm5\n\t"
"por %%mm1, %%mm0\n\t"
"por %%mm4, %%mm3\n\t"
"por %%mm2, %%mm0\n\t"
"por %%mm5, %%mm3\n\t"
"psllq $16, %%mm3\n\t"
"por %%mm3, %%mm0\n\t"
MOVNTQ" %%mm0, %0\n\t"
:"=m"(*d):"m"(*s),"m"(blue_15mask):"memory");
d += 4;
s += 16;
}
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#endif
while(s < end)
{
const int src= *s; s += 4;
*d++ = ((src&0xF8)<<7) + ((src&0xF800)>>6) + ((src&0xF80000)>>19);
}
}
| 1threat |
query = 'SELECT * FROM customers WHERE email = ' + email_input | 1threat |
(Excel VBA) - Copy webpage content to a string : I need to access webpages and copy their content (everything) into a string which I will then extract some figures from.
The webpage address changes each time, as I am basically accessing an online simulation tool and I have to specify the sim parameters each time. And the outpit is always a string of about 320 characters. the web page consists ONLY in that text.
Example of web addess / query:
**http://re.jrc.ec.europa.eu/pvgis5/PVcalc.php?lat=45&lon=8&peakpower=1&loss=14&optimalangles=1&outputformat=basic**
Example of webpage content (string to retrieve):
**37 0 1 54.9 72.1 7.21 2 73.1 96.0 12.0 3 114 149 15.5 4 121 160 17.9 5 140 185 11.3 6 142 188 9.31 7 161 212 10.2 8 149 197 10.0 9 123 162 10.3 10 83.0 109 15.5 11 55.8 73.3 13.5 12 55.8 73.2 9.47 Year 1270 1680 58.8 AOI loss: 2.7% Spectral effects: - Temperature and low irradiance loss: 8.0% Combined losses: 24.1%**
***Question to you*** - Is there a method to copy that string without having to open aand close a browser each time? I have to repeat that operation (determine the query parameters, retrieve the relative string, extract the values that I need from the string) a total of **7200 times** when I run my analysis and I'd like it to be as smooth and as fast as possible.
Note: I don't necessary need to save the string text on a document but it would be OK to do so if needed, and then open the file and retrieve my string. But that sounds so inefficient that I#m sure there must be a better way of doing it! | 0debug |
static int vda_h264_decode_slice(AVCodecContext *avctx,
const uint8_t *buffer,
uint32_t size)
{
VDAContext *vda = avctx->internal->hwaccel_priv_data;
struct vda_context *vda_ctx = avctx->hwaccel_context;
void *tmp;
if (!vda_ctx->decoder)
return -1;
tmp = av_fast_realloc(vda->bitstream,
&vda->allocated_size,
vda->bitstream_size + size + 4);
if (!tmp)
return AVERROR(ENOMEM);
vda->bitstream = tmp;
AV_WB32(vda->bitstream + vda->bitstream_size, size);
memcpy(vda->bitstream + vda->bitstream_size + 4, buffer, size);
vda->bitstream_size += size + 4;
return 0;
}
| 1threat |
static void patch_pci_windows(PcPciInfo *pci, uint8_t *start, unsigned size)
{
*ACPI_BUILD_PTR(start, size, acpi_pci32_start[0], uint32_t) =
cpu_to_le32(pci->w32.begin);
*ACPI_BUILD_PTR(start, size, acpi_pci32_end[0], uint32_t) =
cpu_to_le32(pci->w32.end - 1);
if (pci->w64.end || pci->w64.begin) {
*ACPI_BUILD_PTR(start, size, acpi_pci64_valid[0], uint8_t) = 1;
*ACPI_BUILD_PTR(start, size, acpi_pci64_start[0], uint64_t) =
cpu_to_le64(pci->w64.begin);
*ACPI_BUILD_PTR(start, size, acpi_pci64_end[0], uint64_t) =
cpu_to_le64(pci->w64.end - 1);
*ACPI_BUILD_PTR(start, size, acpi_pci64_length[0], uint64_t) =
cpu_to_le64(pci->w64.end - pci->w64.begin);
} else {
*ACPI_BUILD_PTR(start, size, acpi_pci64_valid[0], uint8_t) = 0;
}
}
| 1threat |
Equivalent urllib.parse.quote() in python 2.7 : <p>What is the equivalent of <code>urllib.parse.quote</code></p>
<p>It's <code>urllib.urlencode()</code>?</p>
<p>Thanks</p>
| 0debug |
Msg 512, Level 16, State 1, Line 19 Subquery returned more than 1 value. : update ActiveParty
set rmname = (select CONCAT(rmname,rmadr1)
from ActiveParty
where RMADR1 like ('%C/O%') or RMADR1 like ('%Attention%') or RMADR1 LIKE '%!%%' escape '!')
where RMADR1 in (select RMADR1
from ActiveParty
where RMADR1 like ('%C/O%') or RMADR1 like ('%Attention%') or RMADR1 LIKE '%!%%' escape '!');
Anyone can give some solution for this as soon | 0debug |
Something Wrong with QuickSort algorithm : <p>Quick Sort Java Implementation-
I have made a program to implement QuickSort algorithm, but it is not showing the sorted sequence properly, It is also showing array out of bound Index exception. can someone tell what is wrong with code or logic?</p>
<pre><code>import java.util.*;
public class QuickSort{
int num,arrayQS[],i;
public void quicksort(int ar[],int start,int end){
if(start<end){
int pindex=partition(ar,start,end);
System.out.println(pindex);
quicksort(ar,start,pindex-1);
quicksort(ar,pindex+1,end);
}
}
public int partition(int pAR[],int start, int end){ //partition function
int key;
int swapper;
int pivot=pAR[end];
int pIndex=start;
for(i=0;i<end;i++){
if(pAR[i]<=pivot){
//swapiing
key=pAR[pIndex];
pAR[pIndex]=pAR[i];
pAR[i]=key;
pIndex++;
}
}
//swap
swapper=pAR[pIndex];
pAR[pIndex]=pAR[end];
pAR[end]=swapper;
return pIndex;
}
public void arrayInputFn(){
Scanner in=new Scanner(System.in);
System.out.println("enter the number you want to insert in an array");
num=in.nextInt();
arrayQS=new int[num];
System.out.println("enter the elements in an array: ");
for(i=0;i<num;i++){
arrayQS[i]=in.nextInt();
}
quicksort(arrayQS,0,arrayQS.length-1);
for(i=0;i<arrayQS.length;i++){
System.out.print(arrayQS[i]);
}
}
public static void main(String[] args){
QuickSort qs=new QuickSort();
qs.arrayInputFn();
}
}
</code></pre>
| 0debug |
static void show_format(WriterContext *w, AVFormatContext *fmt_ctx)
{
char val_str[128];
int64_t size = fmt_ctx->pb ? avio_size(fmt_ctx->pb) : -1;
writer_print_section_header(w, SECTION_ID_FORMAT);
print_str("filename", fmt_ctx->filename);
print_int("nb_streams", fmt_ctx->nb_streams);
print_int("nb_programs", fmt_ctx->nb_programs);
print_str("format_name", fmt_ctx->iformat->name);
if (!do_bitexact) {
if (fmt_ctx->iformat->long_name) print_str ("format_long_name", fmt_ctx->iformat->long_name);
else print_str_opt("format_long_name", "unknown");
}
print_time("start_time", fmt_ctx->start_time, &AV_TIME_BASE_Q);
print_time("duration", fmt_ctx->duration, &AV_TIME_BASE_Q);
if (size >= 0) print_val ("size", size, unit_byte_str);
else print_str_opt("size", "N/A");
if (fmt_ctx->bit_rate > 0) print_val ("bit_rate", fmt_ctx->bit_rate, unit_bit_per_second_str);
else print_str_opt("bit_rate", "N/A");
print_int("probe_score", av_format_get_probe_score(fmt_ctx));
show_tags(w, fmt_ctx->metadata, SECTION_ID_FORMAT_TAGS);
writer_print_section_footer(w);
fflush(stdout);
}
| 1threat |
static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
{
AVFilterContext *ctx = link->dst;
CropContext *crop = ctx->priv;
AVFilterBufferRef *ref2;
int i;
picref->video->w = crop->w;
picref->video->h = crop->h;
ref2 = avfilter_ref_buffer(picref, ~0);
crop->var_values[VAR_T] = picref->pts == AV_NOPTS_VALUE ?
NAN : picref->pts * av_q2d(link->time_base);
crop->var_values[VAR_POS] = picref->pos == -1 ? NAN : picref->pos;
crop->var_values[VAR_X] = av_expr_eval(crop->x_pexpr, crop->var_values, NULL);
crop->var_values[VAR_Y] = av_expr_eval(crop->y_pexpr, crop->var_values, NULL);
crop->var_values[VAR_X] = av_expr_eval(crop->x_pexpr, crop->var_values, NULL);
normalize_double(&crop->x, crop->var_values[VAR_X]);
normalize_double(&crop->y, crop->var_values[VAR_Y]);
if (crop->x < 0) crop->x = 0;
if (crop->y < 0) crop->y = 0;
if ((unsigned)crop->x + (unsigned)crop->w > link->w) crop->x = link->w - crop->w;
if ((unsigned)crop->y + (unsigned)crop->h > link->h) crop->y = link->h - crop->h;
crop->x &= ~((1 << crop->hsub) - 1);
crop->y &= ~((1 << crop->vsub) - 1);
av_log(ctx, AV_LOG_DEBUG,
"n:%d t:%f x:%d y:%d x+w:%d y+h:%d\n",
(int)crop->var_values[VAR_N], crop->var_values[VAR_T], crop->x, crop->y, crop->x+crop->w, crop->y+crop->h);
ref2->data[0] += crop->y * ref2->linesize[0];
ref2->data[0] += crop->x * crop->max_step[0];
if (!(av_pix_fmt_descriptors[link->format].flags & PIX_FMT_PAL)) {
for (i = 1; i < 3; i ++) {
if (ref2->data[i]) {
ref2->data[i] += (crop->y >> crop->vsub) * ref2->linesize[i];
ref2->data[i] += (crop->x * crop->max_step[i]) >> crop->hsub;
}
}
}
if (ref2->data[3]) {
ref2->data[3] += crop->y * ref2->linesize[3];
ref2->data[3] += crop->x * crop->max_step[3];
}
avfilter_start_frame(link->dst->outputs[0], ref2);
} | 1threat |
Creating cell same like fb and gmail login page : I want to create automated cells in excel which will show the type of data to be entered in that cells. I want to create cells which will show "Enter Username here", " Enter DOB here" same as that which shows in fb and gmail login page. I don't want to save any credentials. I had created multiple dropdown lists and people are not understanding that there is a dropdown untill they click on that cell. So i want to create automated cells which will show the type of data to be entered into it. It should disappear when i click on that cell and should appear if i erase the contents from that cell which i anyone had entered. Can anyone help me? | 0debug |
void unix_start_incoming_migration(const char *path, Error **errp)
{
SocketAddressLegacy *saddr = unix_build_address(path);
socket_start_incoming_migration(saddr, errp);
}
| 1threat |
void ff_mqc_init_contexts(MqcState *mqc)
{
int i;
memset(mqc->cx_states, 0, sizeof(mqc->cx_states));
mqc->cx_states[MQC_CX_UNI] = 2 * 46;
mqc->cx_states[MQC_CX_RL] = 2 * 3;
mqc->cx_states[0] = 2 * 4;
for (i = 0; i < 47; i++) {
ff_mqc_qe[2 * i] =
ff_mqc_qe[2 * i + 1] = cx_states[i].qe;
ff_mqc_nlps[2 * i] = 2 * cx_states[i].nlps + cx_states[i].sw;
ff_mqc_nlps[2 * i + 1] = 2 * cx_states[i].nlps + 1 - cx_states[i].sw;
ff_mqc_nmps[2 * i] = 2 * cx_states[i].nmps;
ff_mqc_nmps[2 * i + 1] = 2 * cx_states[i].nmps + 1;
}
}
| 1threat |
void RENAME(ff_init_mpadsp_tabs)(void)
{
int i, j;
for (i = 0; i < 36; i++) {
for (j = 0; j < 4; j++) {
double d;
if (j == 2 && i % 3 != 1)
continue;
d = sin(M_PI * (i + 0.5) / 36.0);
if (j == 1) {
if (i >= 30) d = 0;
else if (i >= 24) d = sin(M_PI * (i - 18 + 0.5) / 12.0);
else if (i >= 18) d = 1;
} else if (j == 3) {
if (i < 6) d = 0;
else if (i < 12) d = sin(M_PI * (i - 6 + 0.5) / 12.0);
else if (i < 18) d = 1;
}
d *= 0.5 / cos(M_PI * (2 * i + 19) / 72);
if (j == 2)
RENAME(ff_mdct_win)[j][i/3] = FIXHR((d / (1<<5)));
else {
int idx = i < 18 ? i : i + (MDCT_BUF_SIZE/2 - 18);
RENAME(ff_mdct_win)[j][idx] = FIXHR((d / (1<<5)));
}
}
}
for (j = 0; j < 4; j++) {
for (i = 0; i < MDCT_BUF_SIZE; i += 2) {
RENAME(ff_mdct_win)[j + 4][i ] = RENAME(ff_mdct_win)[j][i ];
RENAME(ff_mdct_win)[j + 4][i + 1] = -RENAME(ff_mdct_win)[j][i + 1];
}
}
}
| 1threat |
Checking if a type is a map : <p>I sometimes find the need to write general routines that can be applied to a container of objects, or a map of such containers (i.e. process each container in the map). One approach is to write separate routines for map types, but I think it can be more natural and less verbose to have one routine that works for both types of input:</p>
<pre><code>template <typename T>
auto foo(const T& items)
{
return foo(items, /* tag dispatch to map or non-map */);
}
</code></pre>
<p>What is a safe, clean way to do this tag dispatch?</p>
| 0debug |
static int raw_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
BDRVRawState *s = bs->opaque;
int access_flags;
DWORD overlapped;
QemuOpts *opts;
Error *local_err = NULL;
const char *filename;
int ret;
s->type = FTYPE_FILE;
opts = qemu_opts_create(&raw_runtime_opts, NULL, 0, &error_abort);
qemu_opts_absorb_qdict(opts, options, &local_err);
if (local_err) {
error_propagate(errp, local_err);
ret = -EINVAL;
goto fail;
}
filename = qemu_opt_get(opts, "filename");
raw_parse_flags(flags, &access_flags, &overlapped);
if (filename[0] && filename[1] == ':') {
snprintf(s->drive_path, sizeof(s->drive_path), "%c:\\", filename[0]);
} else if (filename[0] == '\\' && filename[1] == '\\') {
s->drive_path[0] = 0;
} else {
char buf[MAX_PATH];
GetCurrentDirectory(MAX_PATH, buf);
snprintf(s->drive_path, sizeof(s->drive_path), "%c:\\", buf[0]);
}
s->hfile = CreateFile(filename, access_flags,
FILE_SHARE_READ, NULL,
OPEN_EXISTING, overlapped, NULL);
if (s->hfile == INVALID_HANDLE_VALUE) {
int err = GetLastError();
if (err == ERROR_ACCESS_DENIED) {
ret = -EACCES;
} else {
ret = -EINVAL;
}
goto fail;
}
if (flags & BDRV_O_NATIVE_AIO) {
s->aio = win32_aio_init();
if (s->aio == NULL) {
CloseHandle(s->hfile);
error_setg(errp, "Could not initialize AIO");
ret = -EINVAL;
goto fail;
}
ret = win32_aio_attach(s->aio, s->hfile);
if (ret < 0) {
win32_aio_cleanup(s->aio);
CloseHandle(s->hfile);
error_setg_errno(errp, -ret, "Could not enable AIO");
goto fail;
}
win32_aio_attach_aio_context(s->aio, bdrv_get_aio_context(bs));
}
raw_probe_alignment(bs);
ret = 0;
fail:
qemu_opts_del(opts);
return ret;
}
| 1threat |
Splitting the values of an array based on a property and then form a new array of objects : <p>I have an objects that contains arrays with following structure:</p>
<pre><code>var obj = {
"feature1" : ["val1","val2"],
"feature2" : ["val3"]
}
</code></pre>
<p>Now I want to split the values that are present inside of this each array and form a new array of objects that should like :</p>
<pre><code>var result = [
{
"field": "feature1",
"value": "val1",
"type": "add"
},
{
"field": "feature1",
"value": "val2",
"type": "add"
},
{
"field": "feature2",
"value": "val3",
"type": "add"
}
]
</code></pre>
<p>Here splitting must happen based on the "field" and it show something that is similar to above.here "type" is an extra field that is hardcoded</p>
<p>Help would be appreciated.</p>
| 0debug |
linq count (list of datastructures, compared to an array value) : related to a [question I asked previously][1] (and got a great answer for)
i have a list<data_struct> roi and an array[][]avg. the list contains an index (of course), each index contains X,Y,Z values in a data structure
i've gotten some averages and other calculations using the answers from my previous question, but now i need to (my current not working code)
for (int i = 0;i>total;i++)
{
foreach (var r in roi)
{
if(r.X == avg[0][i]
{
var count = roi.Count(x=> (r.Z - 0.5) < 0);
}
}
}
this returns a value, but not the correct one on my small test list
basically i'm trying to count through the list: if the X value in the datastructure is a certain value, count how many of the Z values (indexed to that X value) meet a condition
thanks
[1]: http://stackoverflow.com/questions/40654590/list-of-lists-of-data-structure-how-do-i-access-with-linq | 0debug |
Kotlin: How to check if enum contains a given String without messing with Exceptions? : <p>Why there is no <code>contains</code> method in enum classes (as well as in Java)? And how to implement it elegantly? Now I'm using this ugly approach:</p>
<pre><code>val contains: Boolean =
try {
MyEnum.valueOf("some string")
true
} catch (e: IllegalArgumentException) {
false
}
</code></pre>
| 0debug |
com.android.ddmlib.AdbCommandRejectedException: device offline (Even when device is connected) : <p>After update of Android Studio to 2.1.2 I've been getting the following error too many times when i make a change.</p>
<blockquote>
<p>com.android.ddmlib.AdbCommandRejectedException: device offline</p>
<p>Error while Installing APK</p>
</blockquote>
<p><strong>The problem is device was never connected and is not offline</strong></p>
<p>If i unplug and re-plug the device it starts working fine again. This never happened in the previous version of AS.</p>
<p>Question: Is there a setting to be changed in AS for this to stop happening or it is a bug?</p>
| 0debug |
static int rm_read_audio_stream_info(AVFormatContext *s, ByteIOContext *pb,
AVStream *st, int read_all)
{
RMDemuxContext *rm = s->priv_data;
char buf[256];
uint32_t version;
int i;
version = get_be32(pb);
if (((version >> 16) & 0xff) == 3) {
int64_t startpos = url_ftell(pb);
for(i = 0; i < 14; i++)
get_byte(pb);
get_str8(pb, s->title, sizeof(s->title));
get_str8(pb, s->author, sizeof(s->author));
get_str8(pb, s->copyright, sizeof(s->copyright));
get_str8(pb, s->comment, sizeof(s->comment));
if ((startpos + (version & 0xffff)) >= url_ftell(pb) + 2) {
get_byte(pb);
get_str8(pb, buf, sizeof(buf));
}
if ((startpos + (version & 0xffff)) > url_ftell(pb))
url_fskip(pb, (version & 0xffff) + startpos - url_ftell(pb));
st->codec->sample_rate = 8000;
st->codec->channels = 1;
st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec->codec_id = CODEC_ID_RA_144;
} else {
int flavor, sub_packet_h, coded_framesize, sub_packet_size;
get_be32(pb);
get_be32(pb);
get_be16(pb);
get_be32(pb);
flavor= get_be16(pb);
rm->coded_framesize = coded_framesize = get_be32(pb);
get_be32(pb);
get_be32(pb);
get_be32(pb);
rm->sub_packet_h = sub_packet_h = get_be16(pb);
st->codec->block_align= get_be16(pb);
rm->sub_packet_size = sub_packet_size = get_be16(pb);
get_be16(pb);
if (((version >> 16) & 0xff) == 5) {
get_be16(pb); get_be16(pb); get_be16(pb);
}
st->codec->sample_rate = get_be16(pb);
get_be32(pb);
st->codec->channels = get_be16(pb);
if (((version >> 16) & 0xff) == 5) {
get_be32(pb);
buf[0] = get_byte(pb);
buf[1] = get_byte(pb);
buf[2] = get_byte(pb);
buf[3] = get_byte(pb);
buf[4] = 0;
} else {
get_str8(pb, buf, sizeof(buf));
get_str8(pb, buf, sizeof(buf));
}
st->codec->codec_type = CODEC_TYPE_AUDIO;
if (!strcmp(buf, "dnet")) {
st->codec->codec_id = CODEC_ID_AC3;
st->need_parsing = AVSTREAM_PARSE_FULL;
} else if (!strcmp(buf, "28_8")) {
st->codec->codec_id = CODEC_ID_RA_288;
st->codec->extradata_size= 0;
rm->audio_framesize = st->codec->block_align;
st->codec->block_align = coded_framesize;
if(rm->audio_framesize >= UINT_MAX / sub_packet_h){
av_log(s, AV_LOG_ERROR, "rm->audio_framesize * sub_packet_h too large\n");
return -1;
}
rm->audiobuf = av_malloc(rm->audio_framesize * sub_packet_h);
} else if ((!strcmp(buf, "cook")) || (!strcmp(buf, "atrc")) || (!strcmp(buf, "sipr"))) {
int codecdata_length, i;
get_be16(pb); get_byte(pb);
if (((version >> 16) & 0xff) == 5)
get_byte(pb);
codecdata_length = get_be32(pb);
if(codecdata_length + FF_INPUT_BUFFER_PADDING_SIZE <= (unsigned)codecdata_length){
av_log(s, AV_LOG_ERROR, "codecdata_length too large\n");
return -1;
}
if(sub_packet_size <= 0){
av_log(s, AV_LOG_ERROR, "sub_packet_size is invalid\n");
return -1;
}
if (!strcmp(buf, "cook")) st->codec->codec_id = CODEC_ID_COOK;
else if (!strcmp(buf, "sipr")) st->codec->codec_id = CODEC_ID_SIPR;
else st->codec->codec_id = CODEC_ID_ATRAC3;
st->codec->extradata_size= codecdata_length;
st->codec->extradata= av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
for(i = 0; i < codecdata_length; i++)
((uint8_t*)st->codec->extradata)[i] = get_byte(pb);
rm->audio_framesize = st->codec->block_align;
st->codec->block_align = rm->sub_packet_size;
if(rm->audio_framesize >= UINT_MAX / sub_packet_h){
av_log(s, AV_LOG_ERROR, "rm->audio_framesize * sub_packet_h too large\n");
return -1;
}
rm->audiobuf = av_malloc(rm->audio_framesize * sub_packet_h);
} else if (!strcmp(buf, "raac") || !strcmp(buf, "racp")) {
int codecdata_length, i;
get_be16(pb); get_byte(pb);
if (((version >> 16) & 0xff) == 5)
get_byte(pb);
st->codec->codec_id = CODEC_ID_AAC;
codecdata_length = get_be32(pb);
if(codecdata_length + FF_INPUT_BUFFER_PADDING_SIZE <= (unsigned)codecdata_length){
av_log(s, AV_LOG_ERROR, "codecdata_length too large\n");
return -1;
}
if (codecdata_length >= 1) {
st->codec->extradata_size = codecdata_length - 1;
st->codec->extradata = av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
get_byte(pb);
for(i = 0; i < st->codec->extradata_size; i++)
((uint8_t*)st->codec->extradata)[i] = get_byte(pb);
}
} else {
st->codec->codec_id = CODEC_ID_NONE;
av_strlcpy(st->codec->codec_name, buf, sizeof(st->codec->codec_name));
}
if (read_all) {
get_byte(pb);
get_byte(pb);
get_byte(pb);
get_str8(pb, s->title, sizeof(s->title));
get_str8(pb, s->author, sizeof(s->author));
get_str8(pb, s->copyright, sizeof(s->copyright));
get_str8(pb, s->comment, sizeof(s->comment));
}
}
return 0;
}
| 1threat |
import re
def snake_to_camel(word):
return ''.join(x.capitalize() or '_' for x in word.split('_')) | 0debug |
static int rv20_decode_picture_header(RVDecContext *rv)
{
MpegEncContext *s = &rv->m;
int seq, mb_pos, i;
int rpr_bits;
#if 0
GetBitContext gb= s->gb;
for(i=0; i<64; i++){
av_log(s->avctx, AV_LOG_DEBUG, "%d", get_bits1(&gb));
if(i%4==3) av_log(s->avctx, AV_LOG_DEBUG, " ");
}
av_log(s->avctx, AV_LOG_DEBUG, "\n");
#endif
#if 0
av_log(s->avctx, AV_LOG_DEBUG, "%3dx%03d/%02Xx%02X ", s->width, s->height, s->width/4, s->height/4);
for(i=0; i<s->avctx->extradata_size; i++){
av_log(s->avctx, AV_LOG_DEBUG, "%02X ", ((uint8_t*)s->avctx->extradata)[i]);
if(i%4==3) av_log(s->avctx, AV_LOG_DEBUG, " ");
}
av_log(s->avctx, AV_LOG_DEBUG, "\n");
#endif
i= get_bits(&s->gb, 2);
switch(i){
case 0: s->pict_type= AV_PICTURE_TYPE_I; break;
case 1: s->pict_type= AV_PICTURE_TYPE_I; break;
case 2: s->pict_type= AV_PICTURE_TYPE_P; break;
case 3: s->pict_type= AV_PICTURE_TYPE_B; break;
default:
av_log(s->avctx, AV_LOG_ERROR, "unknown frame type\n");
return -1;
}
if(s->low_delay && s->pict_type==AV_PICTURE_TYPE_B){
av_log(s->avctx, AV_LOG_ERROR, "low delay B\n");
return -1;
}
if(s->last_picture_ptr==NULL && s->pict_type==AV_PICTURE_TYPE_B){
av_log(s->avctx, AV_LOG_ERROR, "early B pix\n");
return -1;
}
if (get_bits1(&s->gb)){
av_log(s->avctx, AV_LOG_ERROR, "reserved bit set\n");
return -1;
}
s->qscale = get_bits(&s->gb, 5);
if(s->qscale==0){
av_log(s->avctx, AV_LOG_ERROR, "error, qscale:0\n");
return -1;
}
if(RV_GET_MINOR_VER(rv->sub_id) >= 2)
s->loop_filter = get_bits1(&s->gb) && !s->avctx->lowres;
if(RV_GET_MINOR_VER(rv->sub_id) <= 1)
seq = get_bits(&s->gb, 8) << 7;
else
seq = get_bits(&s->gb, 13) << 2;
rpr_bits = s->avctx->extradata[1] & 7;
if(rpr_bits){
int f, new_w, new_h;
rpr_bits = FFMIN((rpr_bits >> 1) + 1, 3);
f = get_bits(&s->gb, rpr_bits);
if(f){
new_w= 4*((uint8_t*)s->avctx->extradata)[6+2*f];
new_h= 4*((uint8_t*)s->avctx->extradata)[7+2*f];
}else{
new_w= s->orig_width ;
new_h= s->orig_height;
}
if(new_w != s->width || new_h != s->height){
AVRational old_aspect = s->avctx->sample_aspect_ratio;
av_log(s->avctx, AV_LOG_DEBUG, "attempting to change resolution to %dx%d\n", new_w, new_h);
if (av_image_check_size(new_w, new_h, 0, s->avctx) < 0)
return -1;
ff_MPV_common_end(s);
if (!old_aspect.num)
old_aspect = (AVRational){1, 1};
if (2 * new_w * s->height == new_h * s->width)
s->avctx->sample_aspect_ratio = av_mul_q(old_aspect, (AVRational){2, 1});
if (new_w * s->height == 2 * new_h * s->width)
s->avctx->sample_aspect_ratio = av_mul_q(old_aspect, (AVRational){1, 2});
avcodec_set_dimensions(s->avctx, new_w, new_h);
s->width = new_w;
s->height = new_h;
if (ff_MPV_common_init(s) < 0)
return -1;
}
if(s->avctx->debug & FF_DEBUG_PICT_INFO){
av_log(s->avctx, AV_LOG_DEBUG, "F %d/%d\n", f, rpr_bits);
}
}
if (av_image_check_size(s->width, s->height, 0, s->avctx) < 0)
return AVERROR_INVALIDDATA;
mb_pos = ff_h263_decode_mba(s);
seq |= s->time &~0x7FFF;
if(seq - s->time > 0x4000) seq -= 0x8000;
if(seq - s->time < -0x4000) seq += 0x8000;
if(seq != s->time){
if(s->pict_type!=AV_PICTURE_TYPE_B){
s->time= seq;
s->pp_time= s->time - s->last_non_b_time;
s->last_non_b_time= s->time;
}else{
s->time= seq;
s->pb_time= s->pp_time - (s->last_non_b_time - s->time);
if(s->pp_time <=s->pb_time || s->pp_time <= s->pp_time - s->pb_time || s->pp_time<=0){
av_log(s->avctx, AV_LOG_DEBUG, "messed up order, possible from seeking? skipping current b frame\n");
return FRAME_SKIPPED;
}
ff_mpeg4_init_direct_mv(s);
}
}
s->no_rounding= get_bits1(&s->gb);
if(RV_GET_MINOR_VER(rv->sub_id) <= 1 && s->pict_type == AV_PICTURE_TYPE_B)
skip_bits(&s->gb, 5);
s->f_code = 1;
s->unrestricted_mv = 1;
s->h263_aic= s->pict_type == AV_PICTURE_TYPE_I;
s->modified_quant=1;
if(!s->avctx->lowres)
s->loop_filter=1;
if(s->avctx->debug & FF_DEBUG_PICT_INFO){
av_log(s->avctx, AV_LOG_INFO, "num:%5d x:%2d y:%2d type:%d qscale:%2d rnd:%d\n",
seq, s->mb_x, s->mb_y, s->pict_type, s->qscale, s->no_rounding);
}
av_assert0(s->pict_type != AV_PICTURE_TYPE_B || !s->low_delay);
return s->mb_width*s->mb_height - mb_pos;
}
| 1threat |
Click event not working on the append item : <p>I am not being able to call the click function on the appended data. I have a html structure like below and items are added after slider move. After the items are added, I need to get the click event but at the moment its not working.</p>
<h2>HTML</h2>
<pre><code> <div id="sidebar-right">
<div id="found-results">
<div class="ui list found-result"></div>
</div>
</div>
</code></pre>
<h2>JS</h2>
<pre><code>var showNearbySearchResult = function(result, popLat, popLong) {
item = '';
item = '<div class="item id_">' +
'<div class="content">' +
'<a class="header right-header">' + result.name_e + '</a>' +
'<div class="description">' + result.amphoe_e + ' ' + result.province_e +'<i class="map marker icon"></i>'+'</div>' +
'</div>' +
'</div><div class="pop-geometry">'+popLat+', '+ popLong+'</div>' + '</div>';
$(".ui.list.found-result").append(item);
}
$('.ui.list.found-result').on('click', '._id', function(e) {
alert(2);
console.log($(this).text());
});
</code></pre>
| 0debug |
how to call method with array input : int n;
//this is a method for get and set value of array
public static int[] avali(int n) {
System.out.println("insert number");
Scanner num = new Scanner(System.in);
int a1[] = new int[n];
for (int i = 0; i < n; i++) {
a1[i] = num.nextInt();
}
return a1;
}
//method of inverse array
public void dovomi(int[] a) {
for (int i = n; i > 0; i--) {
System.out.println(a);
}
}
public static void main(String[] args) {
System.out.println("insert arr size: ");
Scanner n = new Scanner(System.in);
JavaApplication17 x = new JavaApplication17();
x.avali(n.nextInt());
x.dovomi(a1);
}
| 0debug |
Unexpected value 'DecoratorFactory' imported by the module 'TempModule' : <p>In my sample application I have written a feature module "TempModule" and
below is the code.</p>
<pre><code>import { NgModule } from '@angular/core';
import { CommonModule} from '@angular/common';
import { TempOneComponent } from './temp.one.component';
import { TempTwoComponent } from './temp.two.component';
import { tempRouting } from './temp.routing';
@NgModule({
declarations: [ TempOneComponent,
TempTwoComponent],
imports: [ NgModule,
CommonModule,
tempRouting]
})
export class TempModule {}
</code></pre>
<p>I am referring to the TempModule in root module , below is the root module code</p>
<pre><code>import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
//-- routing import
import { routing,
appRoutingProviders} from './app.routing';
//-- root component import
import { AppComponent } from './app.component';
import { AppAboutComponent } from './app-about.component';
import { AppCreatTicketComponent } from './tickets/ app.create-ticket.component';
import { AppOpenTicketComponent } from './tickets/app.open-ticket.component';
import { AppSearchTicketComponent } from './tickets/ app.search-ticket.component';
import { AppDashboardComponent } from './tickets/app.dashboard.component';
import { AppUsersComponent } from './users/app.users.component';
import { TempModule } from './tempModule/temp.module';
@NgModule({
declarations: [AppComponent ,
AppAboutComponent ,
AppCreatTicketComponent,
AppOpenTicketComponent,
AppSearchTicketComponent,
AppDashboardComponent,
AppUsersComponent
],
imports: [BrowserModule ,
FormsModule ,
routing,
TempModule ],
providers: [appRoutingProviders],
bootstrap: [AppComponent]
})
export class AppModule {}
</code></pre>
<p>When I run the application , "Unexpected value 'DecoratorFactory' imported by the module 'TempModule'" is displayed in browser console.</p>
<p>Any idea what could be the reason for this error ?</p>
| 0debug |
Passing a variable through href - is it a good approach? : <p>I'm currently working on my school project and I started wondering if it's a good approach to pass some variable through href so it can been seen in the URL.
Is it good or a bad way and why? </p>
<p>Or are there any better ways? </p>
| 0debug |
javscript regexp get no quotes params : eg: var str = '2+3+name+"obj.name name"+"g233"';
how can i get the name params from the str with out "obj.name name" and "g233" string
if it can use regexp to realize it;
the fitst name is what i want to replace, not want the name in quotes! | 0debug |
How to split a string in java by a non printable ascii character (Example - Record Seperator) : <p>In C# this would work -
<code>String[] elements = sample.Split((char)30);</code></p>
<p>What is the java equivalent?</p>
| 0debug |
What does that $$ mean? : Firstly, I am beginner in Perl. I would like to know what does this code mean.
sub function
{
my $var1 = shift;
my $var2 = shift;
if ($$var1)
{
#code
}
else
{
#code
}
}
I know that it is a function, and var1 is first argument of function and var2 is the second argument. But what does mean that $$ in if statement? | 0debug |
Is there any way to analyze a truncated Java Heap Dump (hprof file)? : <p>In my work, we are running into a difficult to reproduce OOM issue. Or, more accurately, it is very easy to reproduce on one system, making that system unusable, but difficult to reproduce anywhere else, given the same inputs.</p>
<p>The application is being run as a service using a service wrapper. We did manage to get the configuration changed to launch it with the option of outputting a heap dump file on OOM but, unfortunately, they were truncated, most likely due to the service wrapper timing out and killing the process as it wrote the file. This is readily apparent, since the max memory is set to 1GB, and the hprof files are as small as 700MB, which is too small to be the entire heap upon OOM.</p>
<p>It would take a lot of jumping through hoops to additionally configure the wrapper to give the java process a longer time to write out the heap, but we are pursuing this using these 2 options:</p>
<pre><code>wrapper.jvm_exit.timeout=600
wrapper.shutdown.timeout=600
</code></pre>
<p>The question is, is there anything useful I can do with the truncated hprof files I have? Eclipse MAT chokes on them. Jhat appears to load them, but then only shows 3 instances of Java.Object of size 0 and nothing else. I tried YourKit and it couldn't write its oids file.</p>
<p>It seems to me like these files should have some useful, accessible information in them. Is there a tool that can read what's there?</p>
<p>Thank you for your time!</p>
| 0debug |
static void lz_unpack(unsigned char *src, unsigned char *dest)
{
unsigned char *s;
unsigned char *d;
unsigned char queue[QUEUE_SIZE];
unsigned int qpos;
unsigned int dataleft;
unsigned int chainofs;
unsigned int chainlen;
unsigned int speclen;
unsigned char tag;
unsigned int i, j;
s = src;
d = dest;
dataleft = LE_32(s);
s += 4;
memset(queue, QUEUE_SIZE, 0x20);
if (LE_32(s) == 0x56781234) {
s += 4;
qpos = 0x111;
speclen = 0xF + 3;
} else {
qpos = 0xFEE;
speclen = 100;
}
while (dataleft > 0) {
tag = *s++;
if ((tag == 0xFF) && (dataleft > 8)) {
for (i = 0; i < 8; i++) {
queue[qpos++] = *d++ = *s++;
qpos &= QUEUE_MASK;
}
dataleft -= 8;
} else {
for (i = 0; i < 8; i++) {
if (dataleft == 0)
break;
if (tag & 0x01) {
queue[qpos++] = *d++ = *s++;
qpos &= QUEUE_MASK;
dataleft--;
} else {
chainofs = *s++;
chainofs |= ((*s & 0xF0) << 4);
chainlen = (*s++ & 0x0F) + 3;
if (chainlen == speclen)
chainlen = *s++ + 0xF + 3;
for (j = 0; j < chainlen; j++) {
*d = queue[chainofs++ & QUEUE_MASK];
queue[qpos++] = *d++;
qpos &= QUEUE_MASK;
}
dataleft -= chainlen;
}
tag >>= 1;
}
}
}
}
| 1threat |
static inline void direct_ref_list_init(H264Context * const h){
MpegEncContext * const s = &h->s;
Picture * const ref1 = &h->ref_list[1][0];
Picture * const cur = s->current_picture_ptr;
int list, i, j;
int sidx= s->picture_structure&1;
int ref1sidx= ref1->reference&1;
for(list=0; list<2; list++){
cur->ref_count[sidx][list] = h->ref_count[list];
for(j=0; j<h->ref_count[list]; j++)
cur->ref_poc[sidx][list][j] = h->ref_list[list][j].poc;
}
if(s->picture_structure == PICT_FRAME){
memcpy(cur->ref_count[0], cur->ref_count[1], sizeof(cur->ref_count[0]));
memcpy(cur->ref_poc [0], cur->ref_poc [1], sizeof(cur->ref_poc [0]));
}
if(cur->pict_type != FF_B_TYPE || h->direct_spatial_mv_pred)
return;
for(list=0; list<2; list++){
for(i=0; i<ref1->ref_count[ref1sidx][list]; i++){
const int poc = ref1->ref_poc[ref1sidx][list][i];
h->map_col_to_list0[list][i] = 0;
for(j=0; j<h->ref_count[list]; j++)
if(h->ref_list[list][j].poc == poc){
h->map_col_to_list0[list][i] = j;
break;
}
}
}
if(FRAME_MBAFF){
for(list=0; list<2; list++){
for(i=0; i<ref1->ref_count[ref1sidx][list]; i++){
j = h->map_col_to_list0[list][i];
h->map_col_to_list0_field[list][2*i] = 2*j;
h->map_col_to_list0_field[list][2*i+1] = 2*j+1;
}
}
}
}
| 1threat |
Error while finding the outliers in R for diamonds dataset : for the below code, i am getting an error of diamonds[which(diamonds$carat,diamonds$depth,diamonds$table,diamonds$x,diamonds$y,diamonds$z%in% outliers),]
error is
Error in which(diamonds$carat, diamonds$depth, diamonds$table, diamonds$x, :
unused arguments (diamonds$x, diamonds$y, diamonds$z %in% outliers)
| 0debug |
Authorization method for REST API utilising Active Directory : <p>What is the best method of securing a REST Web API with the following requirements. The system has an Angular JS frontend with the REST APIs implemented in ASP.net.</p>
<ul>
<li>There are two "roles" in the system, users will have one of the
roles. One role should allows access to some APIs (call it "VIEW"),
the other role allows access to other APIs</li>
<li>All users are in Active Directory, so if I have a username, I can check what role they are in- Some clients are on Windows boxes, the others are on Linux</li>
<li>I would like to persist the session so I don't have to look up AD for every API call</li>
<li>I would like single sign on. On the Windows machines, I don't require them to enter user and pass as I already can retrieve their username using Windows Authentication.</li>
</ul>
<p>I believe that Oauth would be my best option.</p>
| 0debug |
Simulate history.go(-1) with Javascript/JQuery : <p>I have three different html files (<strong>page1.html</strong>, <strong>page2.html</strong>, <strong>page3.html</strong>) that each contain a link to the same target in a fourth html file (<strong>glossary.html</strong>).</p>
<p>For technical reasons, I can't use <strong>history.go(-1)</strong> or other brower-specific functions, but I can use JavaScript and JavaScript libraries, e.g. JQuery, and LocalStorage.</p>
<p>What would be the best way to mimic the functionality of <strong>history.go(-1)</strong> with JavaScript?</p>
<p>The technical details are as follows:</p>
<p><strong>page1.html</strong> contains the following link:</p>
<pre><code><a id="page1" href="glossary.html#def1" class="footnote">1</a>
</code></pre>
<p><strong>page2.html</strong> contains the following link:</p>
<pre><code><a id="page2" href="glossary.html#def1" class="footnote">1</a>
</code></pre>
<p><strong>page3.html</strong> contains the following link:</p>
<pre><code><a id="page3" href="glossary.html#def1" class="footnote">1</a>
</code></pre>
<p><strong>glossary.html</strong> contains the following link:</p>
<pre><code><a id="fn1" href="#">↵ Back </a>Term 1: Definition of term one.
</code></pre>
<p>I.e., the script(s) should do the following:</p>
<ol>
<li><p>Retrieve the id of the calling html page (<strong>page1</strong>, <strong>page2</strong> or <strong>page3</strong>) and save it as a LocalStorage item or in another suitable persistent manner.</p></li>
<li><p>When the user clicks the <strong>↵ Go back</strong> link, the href of the definition in glossary.html needs to be updated so that it points to <strong>page1.html#page1</strong>, <strong>page2.html#page2</strong> or <strong>page3.html#page3</strong>, depending on the html page that the glossary link was clicked on. </p></li>
</ol>
<p>What would be the easiest way to solve this problem?</p>
| 0debug |
spring JNDI logging before logback is initialized : <p>I've got a spring boot app that is outputing around 1500 lines of JNDI debug logging to stdout at startup before logback is initialized. Does anyone know what's causing this and if there is a way to get logback initialized before this? I've got -Dlogback.debug=true but it doesn't help much.</p>
<pre><code>10:44:56.453 [main] DEBUG org.springframework.jndi.JndiTemplate - Looking up JNDI object with name [java:comp/env/logging.exception-conversion-word]
10:44:56.457 [main] DEBUG jndi - InitialContextFactory.getInitialContext()
10:44:56.457 [main] DEBUG jndi - Created initial context delegate for local namespace:org.eclipse.jetty.jndi.local.localContextRoot@564fabc8
10:44:56.457 [main] DEBUG org.eclipse.jetty.jndi.java.javaURLContextFactory - >>> new root context requested
10:44:56.457 [main] DEBUG jndi - Looking up name="comp/env/logging.exception-conversion-word"
10:44:56.457 [main] DEBUG jndi - Trying thread context classloader
10:44:56.457 [main] DEBUG jndi - Looking up name="env/logging.exception-conversion-word"
10:44:56.458 [main] DEBUG org.springframework.jndi.JndiLocatorDelegate - Converted JNDI name [java:comp/env/logging.exception-conversion-word] not found - trying original name [logging.exception-conversion-word]. javax.naming.NameNotFoundException; remaining name 'env/logging.exception-conversion-word'
10:44:56.458 [main] DEBUG org.springframework.jndi.JndiTemplate - Looking up JNDI object with name [logging.exception-conversion-word]
...
10:44:56.487 [main] DEBUG jndi - Looking up name="env/LOGGING_PATTERNLEVEL"
10:44:56.487 [main] DEBUG org.springframework.jndi.JndiLocatorDelegate - Converted JNDI name [java:comp/env/LOGGING_PATTERNLEVEL] not found - trying original name [LOGGING_PATTERNLEVEL]. javax.naming.NameNotFoundException; remaining name 'env/LOGGING_PATTERNLEVEL'
10:44:56.487 [main] DEBUG org.springframework.jndi.JndiTemplate - Looking up JNDI object with name [LOGGING_PATTERNLEVEL]
10:44:56.487 [main] DEBUG jndi - InitialContextFactory.getInitialContext()
10:44:56.487 [main] DEBUG jndi - Created initial context delegate for local namespace:org.eclipse.jetty.jndi.local.localContextRoot@bcec361
10:44:56.487 [main] DEBUG jndi - Looking up name="LOGGING_PATTERNLEVEL"
10:44:56.487 [main] DEBUG org.springframework.jndi.JndiPropertySource - JNDI lookup for name [LOGGING_PATTERNLEVEL] threw NamingException with message: null. Returning null.
10:44:56,536 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
10:44:56,539 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT]
10:44:56,543 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
10:44:56,561 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender]
10:44:56,564 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [FILE]
10:44:56,565 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
10:44:56,571 |-INFO in my.log.TimestampRollingPolicy@24fcf36f - Will use the pattern /tmp/logs/qs.%d{yyyyMMdd-HHmmss}.log to archive files
10:44:56,574 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[FILE] - Active log file name: /tmp/logs/qs.log
10:44:56,574 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[FILE] - File property is set to [/tmp/logs/qs.log]
10:44:56,576 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to WARN
10:44:56,576 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@4a7f959b - Propagating WARN level on Logger[ROOT] onto the JUL framework
10:44:56,576 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [FILE] to Logger[ROOT]
10:44:56,576 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT]
10:44:56,576 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
10:44:56,577 |-INFO in org.springframework.boot.logging.logback.SpringBootJoranConfigurator@32b260fa - Registering current configuration as safe fallback point
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.4.4.RELEASE)
10:44:56,750 |-INFO in c.q.l.co.rolling.helper.RenameUtil - Renaming file [/tmp/logs/qs.log] to [/tmp/logs/qs.20170222-173130.log]
10:44:56 [main] INFO my.Application - Starting ...
</code></pre>
| 0debug |
import datetime
def check_date(m, d, y):
try:
m, d, y = map(int, (m, d, y))
datetime.date(y, m, d)
return True
except ValueError:
return False | 0debug |
SCSIRequest *scsi_req_alloc(const SCSIReqOps *reqops, SCSIDevice *d,
uint32_t tag, uint32_t lun, void *hba_private)
{
SCSIRequest *req;
SCSIBus *bus = scsi_bus_from_device(d);
BusState *qbus = BUS(bus);
req = g_malloc0(reqops->size);
req->refcount = 1;
req->bus = bus;
req->dev = d;
req->tag = tag;
req->lun = lun;
req->hba_private = hba_private;
req->status = -1;
req->sense_len = 0;
req->ops = reqops;
object_ref(OBJECT(d));
object_ref(OBJECT(qbus->parent));
trace_scsi_req_alloc(req->dev->id, req->lun, req->tag);
return req;
}
| 1threat |
Retrofit v2 Does Call.cancel() remove Callback? : <p>I've read in the <a href="https://github.com/square/retrofit/issues/297" rel="noreferrer">Retrofit v2 API Spec</a> that calling the cancel() method on the Call class returned from your custom retrofit interface should set the Callback passed in to null.</p>
<blockquote>
<p>cancel() is a no-op after the response has been received. In all other
cases the method will set any callbacks to null (thus freeing strong
references to the enclosing class if declared anonymously)</p>
</blockquote>
<p>Going through the code I can't see that the Callback is explicitly set to null when cancel is called. I can see the callback being referenced in the <a href="https://github.com/square/retrofit/blob/6269b91f2d7436c6afed47fb5f2be80c566f412a/retrofit/src/main/java/retrofit2/OkHttpCall.java" rel="noreferrer">OkHttpCall</a> class (although not explicitly stored). Calling cancel will in turn call cancel on the RealCall class which takes care of the Http side of canceling, but does not concern itself with the stored callback in the AsyncCall class (which is put in the readyAsyncCalls and runningAsyncCalls queues in the Dispatcher class. It is unfamiliar code to me so I might be missing something.</p>
<p>Can someone confidently confirm that calling cancel() on my call object will remove reference to the Callback I've passed in so I don't leak memory?</p>
<p>Simplified code example:</p>
<pre><code>@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final Retrofit retrofit = new Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.build();
api = retrofit.create(Api.class);
}
@Override
public void onStart() {
super.onStart();
call = api.getPokedex();
call.enqueue(new Callback<Pokedex>() {
@Override
public void onResponse(Call<Pokedex> call, Response<Pokedex> response) {
populate(response.body());
}
@Override
public void onFailure(Call<Pokedex> call, Throwable t) {
error(t.getMessage());
}
});
}
@Override
public void onStop() {
call.cancel();
super.onStop();
}
</code></pre>
| 0debug |
static void dma_bdrv_unmap(DMAAIOCB *dbs)
{
int i;
for (i = 0; i < dbs->iov.niov; ++i) {
dma_memory_unmap(dbs->sg->as, dbs->iov.iov[i].iov_base,
dbs->iov.iov[i].iov_len, dbs->dir,
dbs->iov.iov[i].iov_len);
}
qemu_iovec_reset(&dbs->iov);
}
| 1threat |
static int megasas_dcmd_cfg_read(MegasasState *s, MegasasCmd *cmd)
{
uint8_t data[4096];
struct mfi_config_data *info;
int num_pd_disks = 0, array_offset, ld_offset;
BusChild *kid;
if (cmd->iov_size > 4096) {
return MFI_STAT_INVALID_PARAMETER;
}
QTAILQ_FOREACH(kid, &s->bus.qbus.children, sibling) {
num_pd_disks++;
}
info = (struct mfi_config_data *)&data;
info->array_count = num_pd_disks;
info->array_size = sizeof(struct mfi_array) * num_pd_disks;
info->log_drv_count = num_pd_disks;
info->log_drv_size = sizeof(struct mfi_ld_config) * num_pd_disks;
info->spares_count = 0;
info->spares_size = sizeof(struct mfi_spare);
info->size = sizeof(struct mfi_config_data) + info->array_size +
info->log_drv_size;
if (info->size > 4096) {
return MFI_STAT_INVALID_PARAMETER;
}
array_offset = sizeof(struct mfi_config_data);
ld_offset = array_offset + sizeof(struct mfi_array) * num_pd_disks;
QTAILQ_FOREACH(kid, &s->bus.qbus.children, sibling) {
SCSIDevice *sdev = SCSI_DEVICE(kid->child);
uint16_t sdev_id = ((sdev->id & 0xFF) << 8) | (sdev->lun & 0xFF);
struct mfi_array *array;
struct mfi_ld_config *ld;
uint64_t pd_size;
int i;
array = (struct mfi_array *)(data + array_offset);
blk_get_geometry(sdev->conf.blk, &pd_size);
array->size = cpu_to_le64(pd_size);
array->num_drives = 1;
array->array_ref = cpu_to_le16(sdev_id);
array->pd[0].ref.v.device_id = cpu_to_le16(sdev_id);
array->pd[0].ref.v.seq_num = 0;
array->pd[0].fw_state = MFI_PD_STATE_ONLINE;
array->pd[0].encl.pd = 0xFF;
array->pd[0].encl.slot = (sdev->id & 0xFF);
for (i = 1; i < MFI_MAX_ROW_SIZE; i++) {
array->pd[i].ref.v.device_id = 0xFFFF;
array->pd[i].ref.v.seq_num = 0;
array->pd[i].fw_state = MFI_PD_STATE_UNCONFIGURED_GOOD;
array->pd[i].encl.pd = 0xFF;
array->pd[i].encl.slot = 0xFF;
}
array_offset += sizeof(struct mfi_array);
ld = (struct mfi_ld_config *)(data + ld_offset);
memset(ld, 0, sizeof(struct mfi_ld_config));
ld->properties.ld.v.target_id = sdev->id;
ld->properties.default_cache_policy = MR_LD_CACHE_READ_AHEAD |
MR_LD_CACHE_READ_ADAPTIVE;
ld->properties.current_cache_policy = MR_LD_CACHE_READ_AHEAD |
MR_LD_CACHE_READ_ADAPTIVE;
ld->params.state = MFI_LD_STATE_OPTIMAL;
ld->params.stripe_size = 3;
ld->params.num_drives = 1;
ld->params.span_depth = 1;
ld->params.is_consistent = 1;
ld->span[0].start_block = 0;
ld->span[0].num_blocks = cpu_to_le64(pd_size);
ld->span[0].array_ref = cpu_to_le16(sdev_id);
ld_offset += sizeof(struct mfi_ld_config);
}
cmd->iov_size -= dma_buf_read((uint8_t *)data, info->size, &cmd->qsg);
return MFI_STAT_OK;
}
| 1threat |
Python - remainder operator : <p>Although I know there is a built in <code>str()</code> <code>function</code> in <code>python</code>, I'm trying to understand its logic.</p>
<pre><code>def intToStr(i):
digits = '0123456789'
if i == 0:
return '0'
result = ''
while i > 0:
result = digits[i%10] + result
i = i/10
return result
</code></pre>
<p>what I don't get is the part in the <code>loop</code> where <code>[i%10]</code>. </p>
<p>How do I get a remainder when <code>i</code> <code><</code> <code>10</code>?</p>
| 0debug |
static int RENAME(dct_quantize)(MpegEncContext *s,
DCTELEM *block, int n,
int qscale)
{
int i, level, last_non_zero_p1, q;
const UINT16 *qmat;
static __align8 INT16 temp_block[64];
int minLevel, maxLevel;
if(s->avctx!=NULL && s->avctx->codec->id==CODEC_ID_MPEG4){
minLevel= -2048;
maxLevel= 2047;
}else if(s->out_format==FMT_MPEG1){
minLevel= -255;
maxLevel= 255;
}else if(s->out_format==FMT_MJPEG){
minLevel= -1023;
maxLevel= 1023;
}else{
minLevel= -128;
maxLevel= 127;
}
av_fdct (block);
if (s->mb_intra) {
int dummy;
if (n < 4)
q = s->y_dc_scale;
else
q = s->c_dc_scale;
#if 1
asm volatile (
"xorl %%edx, %%edx \n\t"
"mul %%ecx \n\t"
: "=d" (temp_block[0]), "=a"(dummy)
: "a" (block[0] + (q >> 1)), "c" (inverse[q])
);
#else
asm volatile (
"xorl %%edx, %%edx \n\t"
"divw %%cx \n\t"
"movzwl %%ax, %%eax \n\t"
: "=a" (temp_block[0])
: "a" (block[0] + (q >> 1)), "c" (q)
: "%edx"
);
#endif
i = 1;
last_non_zero_p1 = 1;
if (s->out_format == FMT_H263) {
qmat = s->q_non_intra_matrix16;
} else {
qmat = s->q_intra_matrix16;
}
for(i=1;i<4;i++) {
level = block[i] * qmat[i];
level = level / (1 << (QMAT_SHIFT_MMX - 3));
if (level > maxLevel)
level = maxLevel;
else if (level < minLevel)
level = minLevel;
temp_block[i] = level;
if(level)
if(last_non_zero_p1 < inv_zigzag_direct16[i]) last_non_zero_p1= inv_zigzag_direct16[i];
block[i]=0;
}
} else {
i = 0;
last_non_zero_p1 = 0;
qmat = s->q_non_intra_matrix16;
}
asm volatile(
"movd %3, %%mm3 \n\t"
SPREADW(%%mm3)
"movd %4, %%mm4 \n\t"
SPREADW(%%mm4)
#ifndef HAVE_MMX2
"movd %5, %%mm5 \n\t"
SPREADW(%%mm5)
#endif
"pxor %%mm7, %%mm7 \n\t"
"movd %%eax, %%mm2 \n\t"
SPREADW(%%mm2)
"movl %6, %%eax \n\t"
".balign 16 \n\t"
"1: \n\t"
"movq (%1, %%eax), %%mm0 \n\t"
"movq (%2, %%eax), %%mm1 \n\t"
"movq %%mm0, %%mm6 \n\t"
"psraw $15, %%mm6 \n\t"
"pmulhw %%mm0, %%mm1 \n\t"
"psubsw %%mm6, %%mm1 \n\t"
#ifdef HAVE_MMX2
"pminsw %%mm3, %%mm1 \n\t"
"pmaxsw %%mm4, %%mm1 \n\t"
#else
"paddsw %%mm3, %%mm1 \n\t"
"psubusw %%mm4, %%mm1 \n\t"
"paddsw %%mm5, %%mm1 \n\t"
#endif
"movq %%mm1, (%8, %%eax) \n\t"
"pcmpeqw %%mm7, %%mm1 \n\t"
"movq (%7, %%eax), %%mm0 \n\t"
"movq %%mm7, (%1, %%eax) \n\t"
"pandn %%mm0, %%mm1 \n\t"
PMAXW(%%mm1, %%mm2)
"addl $8, %%eax \n\t"
" js 1b \n\t"
"movq %%mm2, %%mm0 \n\t"
"psrlq $32, %%mm2 \n\t"
PMAXW(%%mm0, %%mm2)
"movq %%mm2, %%mm0 \n\t"
"psrlq $16, %%mm2 \n\t"
PMAXW(%%mm0, %%mm2)
"movd %%mm2, %%eax \n\t"
"movzbl %%al, %%eax \n\t"
: "+a" (last_non_zero_p1)
: "r" (block+64), "r" (qmat+64),
#ifdef HAVE_MMX2
"m" (maxLevel), "m" (minLevel), "m" (minLevel ), "g" (2*i - 128),
#else
"m" (0x7FFF - maxLevel), "m" (0x7FFF -maxLevel + minLevel), "m" (minLevel), "g" (2*i - 128),
#endif
"r" (inv_zigzag_direct16+64), "r" (temp_block+64)
);
asm volatile(
"movl %0, %%eax \n\t"
"pushl %%ebp \n\t"
"movl %%esp, " MANGLE(esp_temp) "\n\t"
"1: \n\t"
"movzbl (%1, %%eax), %%ebx \n\t"
"movzbl 1(%1, %%eax), %%ebp \n\t"
"movw (%2, %%ebx, 2), %%cx \n\t"
"movw (%2, %%ebp, 2), %%sp \n\t"
"movzbl " MANGLE(permutation) "(%%ebx), %%ebx\n\t"
"movzbl " MANGLE(permutation) "(%%ebp), %%ebp\n\t"
"movw %%cx, (%3, %%ebx, 2) \n\t"
"movw %%sp, (%3, %%ebp, 2) \n\t"
"addl $2, %%eax \n\t"
" js 1b \n\t"
"movl " MANGLE(esp_temp) ", %%esp\n\t"
"popl %%ebp \n\t"
:
: "g" (-last_non_zero_p1), "d" (zigzag_direct_noperm+last_non_zero_p1), "S" (temp_block), "D" (block)
: "%eax", "%ebx", "%ecx"
);
return last_non_zero_p1 - 1;
}
| 1threat |
How to delete all columns in DataFrame except certain ones? : <p>Let's say I have a DataFrame that looks like this:</p>
<pre><code>a b c d e f g
1 2 3 4 5 6 7
4 3 7 1 6 9 4
8 9 0 2 4 2 1
</code></pre>
<p>How would I go about deleting every column besides <code>a</code> and <code>b</code>?</p>
<p>This would result in:</p>
<pre><code>a b
1 2
4 3
8 9
</code></pre>
<p>I would like a way to delete these using a simple line of code that says, delete all columns besides <code>a</code> and <code>b</code>, because let's say hypothetically I have 1000 columns of data.</p>
<p>Thank you.</p>
| 0debug |
Regular Expression email address Python : <p>I want to extract top level domains from email addresses with Python.
I want to use a regular expression to get everything after the FIRST dot after the @ symbol</p>
<p>E.g.</p>
<pre><code>tony.manero@testing.com
ted.br@top.domain.us
</code></pre>
<p>Expected result</p>
<pre><code>.com
.domain.us
</code></pre>
<p>How can I use regex to achieve this result?</p>
| 0debug |
android set margin programmatically : <p>after i press a button, i would like to move a textfield programmatically from the actual position + 20 margin left.</p>
<p>this is my xml file:</p>
<pre><code><RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="5dp"
android:paddingBottom="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/txtField"
android:layout_below="@+id/txtField2"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="20dp"
android:layout_toLeftOf="@+id/Seperator"
android:layout_toStartOf="@+id/Seperator"
android:layout_marginRight="10p" />
....
</RelativeLayout>
</code></pre>
<p>i tried this code:</p>
<pre><code>parameter = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
parameter.setMargins(30, 32, 10, 0); // left, top, right, bottom
txtField.setLayoutParams(parameter);
</code></pre>
<p>this works semi optimal.
is there an way to use all the values of an xml file and only change the margin left value programmatically?</p>
| 0debug |
static void spice_update_buttons(QemuSpicePointer *pointer,
int wheel, uint32_t button_mask)
{
static uint32_t bmap[INPUT_BUTTON__MAX] = {
[INPUT_BUTTON_LEFT] = 0x01,
[INPUT_BUTTON_MIDDLE] = 0x04,
[INPUT_BUTTON_RIGHT] = 0x02,
[INPUT_BUTTON_WHEEL_UP] = 0x10,
[INPUT_BUTTON_WHEEL_DOWN] = 0x20,
};
if (wheel < 0) {
button_mask |= 0x10;
}
if (wheel > 0) {
button_mask |= 0x20;
}
if (pointer->last_bmask == button_mask) {
return;
}
qemu_input_update_buttons(NULL, bmap, pointer->last_bmask, button_mask);
pointer->last_bmask = button_mask;
}
| 1threat |
How to sort ArrayList<String> in Java in decreasing order? : <p>I am new in java i am trying to sort a list of install app in device according to their data use. i want like highest at the top.i use code to find install package are:</p>
<pre><code> List<ApplicationItem> mApplicationItemList = new ArrayList<ApplicationItem>();
PackageManager p = getPackageManager();
final List<PackageInfo> apps = p.getInstalledPackages(PackageManager.GET_PERMISSIONS);
for (PackageInfo packageInfo : apps) {
ApplicationItem item = new ApplicationItem();
if (packageInfo.requestedPermissions == null)
continue;
if (Arrays.asList(packageInfo.requestedPermissions).contains(android.Manifest.permission.INTERNET) &&
!Utility.isSystemApp(packageInfo.packageName) &&
(p.getLaunchIntentForPackage(packageInfo.packageName) != null)) {
item.setPkgName(packageInfo.packageName);
mApplicationItemList.add(item);
}
}
and find data usage by this code:
public static long getTotalDataByUid(String pkgName) {
long totalData = 0;
try {
ApplicationInfo appInfo = getApplicationContext().getPackageManager().getApplicationInfo(pkgName, 0);
//TODO Handle UNSUPPORTED
long tx = TrafficStats.getUidTxBytes(appInfo.uid);
long rx = TrafficStats.getUidRxBytes(appInfo.uid);
totalData = tx + rx;
if (totalData < 0) {
totalData = 0;
}
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
totalData = 0;
}
return totalData;
}
</code></pre>
| 0debug |
Please help me to write this procedure to get auto-increment alphanumeric id in ms sql server : CREATE PROC Usp_GetNewInquiryId
AS
BEGIN
IF NOT EXISTS(SELECT InquiryId FROM JobPortal.dbo.tblContact)
DECLARE @PrefixValue VARCHAR(10)='INQ'
DECLARE @InitialValue DECIMAL(10)=1001
SELECT InquiryId = @PrefixValue+CAST(ISNULL(MAX(InquiryId),@InitialValue) AS VARCHAR(10)) FROM JobPortal.dbo.tblContact
ELSE
/* here i wanna eliminate the word 'INQ' from 'INQ1001' towards left side and do increment 1002 from 1001, lastly wanna select INQ1002 and so on... */
END | 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.