problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
Visual Studio Code quick-fix & python : <p>Visual Studio Code is never able to populate the 'Quick Fix' contextual drop down, only displaying 'No Code Actions Available'</p>
<p>Python extension is installed, along with python3.7.3 and flake8, pep8.</p>
| 0debug |
NPM stuck giving the same error EISDIR: Illegal operation on a directory, read at error (native) : <p>I am stuck with this error no matter what directory I am in, and what I type after "npm" in cmd.exe. Here is the npm-debug.log: </p>
<pre><code>0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js' ]
2 info using npm@2.14.12
3 info using node@v4.2.6
4 verbose stack Error: EISDIR: illegal operation on a directory, read
4 verbose stack at Error (native)
5 verbose cwd C:\Users\me
6 error Windows_NT 6.1.7601
7 error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js"
8 error node v4.2.6
9 error npm v2.14.12
10 error code EISDIR
11 error errno -4068
12 error syscall read
13 error eisdir EISDIR: illegal operation on a directory, read
13 error eisdir This is most likely not a problem with npm itself
13 error eisdir and is related to npm not being able to find a package.json in
13 error eisdir a package you are trying to install.
14 verbose exit [ -4068, true ]
</code></pre>
<p>I have tried and uninstalling/reinstalling nodejs multiple times, I even deleted npm and npm-cache folders in C:\Users\me\AppData\Roaming. I'm not sure what went wrong to cause this. One second it was working fine, and now I can't get rid of this error. The explanation in the log does not make sense, as it gives this error in any directory. I should note that running a command prompt as administrator does not give this error. I'm pulling my hair out this Friday evening trying to get this fixed, any help would be greatly appreciated!</p>
| 0debug |
db.execute('SELECT * FROM products WHERE product_id = ' + product_input) | 1threat |
RegEx to remove key and certificate headers and footers : <p>I need to strip out the header and footer of key and certificate files (as well as any LF found in the data). Yes, I can use String.Replace for all of the headers and footers but it can be done in one or perhaps two lines using RegEx. My problem is that I know nothing about the RegEx syntax. Can anyone tell me the search pattern to locate the headers (-----BEGIN <em>some variable text</em>-----) and replace them with empty strings? Note the footers all start with -----END.</p>
| 0debug |
static inline int l1_unscale(int n, int mant, int scale_factor)
{
int shift, mod;
int64_t val;
shift = scale_factor_modshift[scale_factor];
mod = shift & 3;
shift >>= 2;
val = MUL64(mant + (-1 << n) + 1, scale_factor_mult[n-1][mod]);
shift += n;
return (int)((val + (1LL << (shift - 1))) >> shift);
}
| 1threat |
how to use val insted of var in scala : I simply want to remove var and use Val instead in below code
def getConfigId: Long = {
val object1: java.util.List[objectA] = objectRepo.findByUser(User(session.id))
var object2: objectA = null
if (object1.size() == 1) {
object2 = object1.get(0)
} else if (object1.size() > 1) {
object2 = object1.get(0)
object1.forEach(a => if (a.endDate.compareTo(object2.endDate) >= 0) {
object2 = a
})
}
object2.configId
}
I am trying to use case match but not working
def getConfigId: Long = {
val object1: java.util.List[objectA] = objectRepo.findByUser(User(session.id))
val object2: objectA = {
case x if object1.size() == 1 => object1.get(0)
case x => if (object1.size() > 1) {
object1.get(0)
object1.forEach(a => if(a.endDate.compareTo(object2.endDate) >= 0) {
object2 = a
})
}
| 0debug |
Bootstrap 4.2.1 - Failed to execute 'querySelector' on 'Document': 'javascript:void(0);' is not a valid selector : <p>I am working on a project which I started building on <strong>bootstrap 4.0.0</strong>. During this project, I had updated bootstrap regulary whenever the new versions ( 4.1.0 , 4.1.3 ) of bootstrap came and all the things were working perfectly until I have update to <strong>bootstrap 4.2.1</strong> from there I encountered error in console when ever I click on the document</p>
<blockquote>
<p>Uncaught DOMException: Failed to execute 'querySelector' on
'Document': 'javascript:void(0);' is not a valid selector.</p>
</blockquote>
<p>I figured out that it occur due to the dropdown because of this error the dropdown does not work. I also checked, that if I am using <strong>href="javascript:void(0);"</strong>, <strong>href="#!"</strong> the error occur but if i use anchor tag without href or href="#" then it is working fine.</p>
<p><strong>Note:-</strong> I need the solution with <strong>href="javascript:void(0);</strong> as <strong>href="#</strong> in the address link does not look pretty and page scrolls up to the top </p>
<pre><code><div class="dropdown">
<a class="btn btn-secondary dropdown-toggle" href="javascript:void();" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown link
</a>
<div class="dropdown-menu" aria-labelledby="dropdownMenuLink">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</div>
</code></pre>
<p>Here is my <a href="https://codepen.io/anon/pen/wReoxa" rel="noreferrer">codepen</a></p>
| 0debug |
static target_ulong disas_insn(DisasContext *s, CPUState *cpu)
{
CPUX86State *env = cpu->env_ptr;
int b, prefixes;
int shift;
TCGMemOp ot, aflag, dflag;
int modrm, reg, rm, mod, op, opreg, val;
target_ulong next_eip, tval;
int rex_w, rex_r;
target_ulong pc_start = s->base.pc_next;
s->pc_start = s->pc = pc_start;
prefixes = 0;
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;
s->vex_l = 0;
s->vex_v = 0;
if (sigsetjmp(s->jmpbuf, 0) != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
return s->pc;
}
next_byte:
b = x86_ldub_code(env, 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;
#ifdef TARGET_X86_64
case 0x40 ... 0x4f:
if (CODE64(s)) {
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;
}
break;
#endif
case 0xc5:
case 0xc4:
if (s->code32 && !s->vm86) {
static const int pp_prefix[4] = {
0, PREFIX_DATA, PREFIX_REPZ, PREFIX_REPNZ
};
int vex3, vex2 = x86_ldub_code(env, s);
if (!CODE64(s) && (vex2 & 0xc0) != 0xc0) {
break;
}
s->pc++;
if (prefixes & (PREFIX_REPZ | PREFIX_REPNZ
| PREFIX_LOCK | PREFIX_DATA)) {
goto illegal_op;
}
#ifdef TARGET_X86_64
if (x86_64_hregs) {
goto illegal_op;
}
#endif
rex_r = (~vex2 >> 4) & 8;
if (b == 0xc5) {
vex3 = vex2;
b = x86_ldub_code(env, s);
} else {
#ifdef TARGET_X86_64
s->rex_x = (~vex2 >> 3) & 8;
s->rex_b = (~vex2 >> 2) & 8;
#endif
vex3 = x86_ldub_code(env, s);
rex_w = (vex3 >> 7) & 1;
switch (vex2 & 0x1f) {
case 0x01:
b = x86_ldub_code(env, s) | 0x100;
break;
case 0x02:
b = 0x138;
break;
case 0x03:
b = 0x13a;
break;
default:
goto unknown_op;
}
}
s->vex_v = (~vex3 >> 3) & 0xf;
s->vex_l = (vex3 >> 2) & 1;
prefixes |= pp_prefix[vex3 & 3] | PREFIX_VEX;
}
break;
}
if (CODE64(s)) {
dflag = (rex_w > 0 ? MO_64 : prefixes & PREFIX_DATA ? MO_16 : MO_32);
aflag = (prefixes & PREFIX_ADR ? MO_32 : MO_64);
} else {
if (s->code32 ^ ((prefixes & PREFIX_DATA) != 0)) {
dflag = MO_32;
} else {
dflag = MO_16;
}
if (s->code32 ^ ((prefixes & PREFIX_ADR) != 0)) {
aflag = MO_32;
} else {
aflag = MO_16;
}
}
s->prefix = prefixes;
s->aflag = aflag;
s->dflag = dflag;
reswitch:
switch(b) {
case 0x0f:
b = x86_ldub_code(env, s) | 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;
ot = mo_b_d(b, dflag);
switch(f) {
case 0:
modrm = x86_ldub_code(env, s);
reg = ((modrm >> 3) & 7) | rex_r;
mod = (modrm >> 6) & 3;
rm = (modrm & 7) | REX_B(s);
if (mod != 3) {
gen_lea_modrm(env, s, modrm);
opreg = OR_TMP0;
} else if (op == OP_XORL && rm == reg) {
xor_zero:
set_cc_op(s, CC_OP_CLR);
tcg_gen_movi_tl(cpu_T0, 0);
gen_op_mov_reg_v(ot, reg, cpu_T0);
break;
} else {
opreg = rm;
}
gen_op_mov_v_reg(ot, cpu_T1, reg);
gen_op(s, op, ot, opreg);
break;
case 1:
modrm = x86_ldub_code(env, s);
mod = (modrm >> 6) & 3;
reg = ((modrm >> 3) & 7) | rex_r;
rm = (modrm & 7) | REX_B(s);
if (mod != 3) {
gen_lea_modrm(env, s, modrm);
gen_op_ld_v(s, ot, cpu_T1, cpu_A0);
} else if (op == OP_XORL && rm == reg) {
goto xor_zero;
} else {
gen_op_mov_v_reg(ot, cpu_T1, rm);
}
gen_op(s, op, ot, reg);
break;
case 2:
val = insn_get(env, s, ot);
tcg_gen_movi_tl(cpu_T1, 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;
ot = mo_b_d(b, dflag);
modrm = x86_ldub_code(env, s);
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(env, s, modrm);
opreg = OR_TMP0;
} else {
opreg = rm;
}
switch(b) {
default:
case 0x80:
case 0x81:
case 0x82:
val = insn_get(env, s, ot);
break;
case 0x83:
val = (int8_t)insn_get(env, s, MO_8);
break;
}
tcg_gen_movi_tl(cpu_T1, val);
gen_op(s, op, ot, opreg);
}
break;
case 0x40 ... 0x47:
ot = dflag;
gen_inc(s, ot, OR_EAX + (b & 7), 1);
break;
case 0x48 ... 0x4f:
ot = dflag;
gen_inc(s, ot, OR_EAX + (b & 7), -1);
break;
case 0xf6:
case 0xf7:
ot = mo_b_d(b, dflag);
modrm = x86_ldub_code(env, s);
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(env, s, modrm);
if (!(s->prefix & PREFIX_LOCK)
|| op != 2) {
gen_op_ld_v(s, ot, cpu_T0, cpu_A0);
}
} else {
gen_op_mov_v_reg(ot, cpu_T0, rm);
}
switch(op) {
case 0:
val = insn_get(env, s, ot);
tcg_gen_movi_tl(cpu_T1, val);
gen_op_testl_T0_T1_cc();
set_cc_op(s, CC_OP_LOGICB + ot);
break;
case 2:
if (s->prefix & PREFIX_LOCK) {
if (mod == 3) {
goto illegal_op;
}
tcg_gen_movi_tl(cpu_T0, ~0);
tcg_gen_atomic_xor_fetch_tl(cpu_T0, cpu_A0, cpu_T0,
s->mem_index, ot | MO_LE);
} else {
tcg_gen_not_tl(cpu_T0, cpu_T0);
if (mod != 3) {
gen_op_st_v(s, ot, cpu_T0, cpu_A0);
} else {
gen_op_mov_reg_v(ot, rm, cpu_T0);
}
}
break;
case 3:
if (s->prefix & PREFIX_LOCK) {
TCGLabel *label1;
TCGv a0, t0, t1, t2;
if (mod == 3) {
goto illegal_op;
}
a0 = tcg_temp_local_new();
t0 = tcg_temp_local_new();
label1 = gen_new_label();
tcg_gen_mov_tl(a0, cpu_A0);
tcg_gen_mov_tl(t0, cpu_T0);
gen_set_label(label1);
t1 = tcg_temp_new();
t2 = tcg_temp_new();
tcg_gen_mov_tl(t2, t0);
tcg_gen_neg_tl(t1, t0);
tcg_gen_atomic_cmpxchg_tl(t0, a0, t0, t1,
s->mem_index, ot | MO_LE);
tcg_temp_free(t1);
tcg_gen_brcond_tl(TCG_COND_NE, t0, t2, label1);
tcg_temp_free(t2);
tcg_temp_free(a0);
tcg_gen_mov_tl(cpu_T0, t0);
tcg_temp_free(t0);
} else {
tcg_gen_neg_tl(cpu_T0, cpu_T0);
if (mod != 3) {
gen_op_st_v(s, ot, cpu_T0, cpu_A0);
} else {
gen_op_mov_reg_v(ot, rm, cpu_T0);
}
}
gen_op_update_neg_cc();
set_cc_op(s, CC_OP_SUBB + ot);
break;
case 4:
switch(ot) {
case MO_8:
gen_op_mov_v_reg(MO_8, cpu_T1, R_EAX);
tcg_gen_ext8u_tl(cpu_T0, cpu_T0);
tcg_gen_ext8u_tl(cpu_T1, cpu_T1);
tcg_gen_mul_tl(cpu_T0, cpu_T0, cpu_T1);
gen_op_mov_reg_v(MO_16, R_EAX, cpu_T0);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T0);
tcg_gen_andi_tl(cpu_cc_src, cpu_T0, 0xff00);
set_cc_op(s, CC_OP_MULB);
break;
case MO_16:
gen_op_mov_v_reg(MO_16, cpu_T1, R_EAX);
tcg_gen_ext16u_tl(cpu_T0, cpu_T0);
tcg_gen_ext16u_tl(cpu_T1, cpu_T1);
tcg_gen_mul_tl(cpu_T0, cpu_T0, cpu_T1);
gen_op_mov_reg_v(MO_16, R_EAX, cpu_T0);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T0);
tcg_gen_shri_tl(cpu_T0, cpu_T0, 16);
gen_op_mov_reg_v(MO_16, R_EDX, cpu_T0);
tcg_gen_mov_tl(cpu_cc_src, cpu_T0);
set_cc_op(s, CC_OP_MULW);
break;
default:
case MO_32:
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T0);
tcg_gen_trunc_tl_i32(cpu_tmp3_i32, cpu_regs[R_EAX]);
tcg_gen_mulu2_i32(cpu_tmp2_i32, cpu_tmp3_i32,
cpu_tmp2_i32, cpu_tmp3_i32);
tcg_gen_extu_i32_tl(cpu_regs[R_EAX], cpu_tmp2_i32);
tcg_gen_extu_i32_tl(cpu_regs[R_EDX], cpu_tmp3_i32);
tcg_gen_mov_tl(cpu_cc_dst, cpu_regs[R_EAX]);
tcg_gen_mov_tl(cpu_cc_src, cpu_regs[R_EDX]);
set_cc_op(s, CC_OP_MULL);
break;
#ifdef TARGET_X86_64
case MO_64:
tcg_gen_mulu2_i64(cpu_regs[R_EAX], cpu_regs[R_EDX],
cpu_T0, cpu_regs[R_EAX]);
tcg_gen_mov_tl(cpu_cc_dst, cpu_regs[R_EAX]);
tcg_gen_mov_tl(cpu_cc_src, cpu_regs[R_EDX]);
set_cc_op(s, CC_OP_MULQ);
break;
#endif
}
break;
case 5:
switch(ot) {
case MO_8:
gen_op_mov_v_reg(MO_8, cpu_T1, R_EAX);
tcg_gen_ext8s_tl(cpu_T0, cpu_T0);
tcg_gen_ext8s_tl(cpu_T1, cpu_T1);
tcg_gen_mul_tl(cpu_T0, cpu_T0, cpu_T1);
gen_op_mov_reg_v(MO_16, R_EAX, cpu_T0);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T0);
tcg_gen_ext8s_tl(cpu_tmp0, cpu_T0);
tcg_gen_sub_tl(cpu_cc_src, cpu_T0, cpu_tmp0);
set_cc_op(s, CC_OP_MULB);
break;
case MO_16:
gen_op_mov_v_reg(MO_16, cpu_T1, R_EAX);
tcg_gen_ext16s_tl(cpu_T0, cpu_T0);
tcg_gen_ext16s_tl(cpu_T1, cpu_T1);
tcg_gen_mul_tl(cpu_T0, cpu_T0, cpu_T1);
gen_op_mov_reg_v(MO_16, R_EAX, cpu_T0);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T0);
tcg_gen_ext16s_tl(cpu_tmp0, cpu_T0);
tcg_gen_sub_tl(cpu_cc_src, cpu_T0, cpu_tmp0);
tcg_gen_shri_tl(cpu_T0, cpu_T0, 16);
gen_op_mov_reg_v(MO_16, R_EDX, cpu_T0);
set_cc_op(s, CC_OP_MULW);
break;
default:
case MO_32:
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T0);
tcg_gen_trunc_tl_i32(cpu_tmp3_i32, cpu_regs[R_EAX]);
tcg_gen_muls2_i32(cpu_tmp2_i32, cpu_tmp3_i32,
cpu_tmp2_i32, cpu_tmp3_i32);
tcg_gen_extu_i32_tl(cpu_regs[R_EAX], cpu_tmp2_i32);
tcg_gen_extu_i32_tl(cpu_regs[R_EDX], cpu_tmp3_i32);
tcg_gen_sari_i32(cpu_tmp2_i32, cpu_tmp2_i32, 31);
tcg_gen_mov_tl(cpu_cc_dst, cpu_regs[R_EAX]);
tcg_gen_sub_i32(cpu_tmp2_i32, cpu_tmp2_i32, cpu_tmp3_i32);
tcg_gen_extu_i32_tl(cpu_cc_src, cpu_tmp2_i32);
set_cc_op(s, CC_OP_MULL);
break;
#ifdef TARGET_X86_64
case MO_64:
tcg_gen_muls2_i64(cpu_regs[R_EAX], cpu_regs[R_EDX],
cpu_T0, cpu_regs[R_EAX]);
tcg_gen_mov_tl(cpu_cc_dst, cpu_regs[R_EAX]);
tcg_gen_sari_tl(cpu_cc_src, cpu_regs[R_EAX], 63);
tcg_gen_sub_tl(cpu_cc_src, cpu_cc_src, cpu_regs[R_EDX]);
set_cc_op(s, CC_OP_MULQ);
break;
#endif
}
break;
case 6:
switch(ot) {
case MO_8:
gen_helper_divb_AL(cpu_env, cpu_T0);
break;
case MO_16:
gen_helper_divw_AX(cpu_env, cpu_T0);
break;
default:
case MO_32:
gen_helper_divl_EAX(cpu_env, cpu_T0);
break;
#ifdef TARGET_X86_64
case MO_64:
gen_helper_divq_EAX(cpu_env, cpu_T0);
break;
#endif
}
break;
case 7:
switch(ot) {
case MO_8:
gen_helper_idivb_AL(cpu_env, cpu_T0);
break;
case MO_16:
gen_helper_idivw_AX(cpu_env, cpu_T0);
break;
default:
case MO_32:
gen_helper_idivl_EAX(cpu_env, cpu_T0);
break;
#ifdef TARGET_X86_64
case MO_64:
gen_helper_idivq_EAX(cpu_env, cpu_T0);
break;
#endif
}
break;
default:
goto unknown_op;
}
break;
case 0xfe:
case 0xff:
ot = mo_b_d(b, dflag);
modrm = x86_ldub_code(env, s);
mod = (modrm >> 6) & 3;
rm = (modrm & 7) | REX_B(s);
op = (modrm >> 3) & 7;
if (op >= 2 && b == 0xfe) {
goto unknown_op;
}
if (CODE64(s)) {
if (op == 2 || op == 4) {
ot = MO_64;
} else if (op == 3 || op == 5) {
ot = dflag != MO_16 ? MO_32 + (rex_w == 1) : MO_16;
} else if (op == 6) {
ot = mo_pushpop(s, dflag);
}
}
if (mod != 3) {
gen_lea_modrm(env, s, modrm);
if (op >= 2 && op != 3 && op != 5)
gen_op_ld_v(s, ot, cpu_T0, cpu_A0);
} else {
gen_op_mov_v_reg(ot, cpu_T0, 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 (dflag == MO_16) {
tcg_gen_ext16u_tl(cpu_T0, cpu_T0);
}
next_eip = s->pc - s->cs_base;
tcg_gen_movi_tl(cpu_T1, next_eip);
gen_push_v(s, cpu_T1);
gen_op_jmp_v(cpu_T0);
gen_bnd_jmp(s);
gen_jr(s, cpu_T0);
break;
case 3:
gen_op_ld_v(s, ot, cpu_T1, cpu_A0);
gen_add_A0_im(s, 1 << ot);
gen_op_ld_v(s, MO_16, cpu_T0, cpu_A0);
do_lcall:
if (s->pe && !s->vm86) {
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T0);
gen_helper_lcall_protected(cpu_env, cpu_tmp2_i32, cpu_T1,
tcg_const_i32(dflag - 1),
tcg_const_tl(s->pc - s->cs_base));
} else {
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T0);
gen_helper_lcall_real(cpu_env, cpu_tmp2_i32, cpu_T1,
tcg_const_i32(dflag - 1),
tcg_const_i32(s->pc - s->cs_base));
}
tcg_gen_ld_tl(cpu_tmp4, cpu_env, offsetof(CPUX86State, eip));
gen_jr(s, cpu_tmp4);
break;
case 4:
if (dflag == MO_16) {
tcg_gen_ext16u_tl(cpu_T0, cpu_T0);
}
gen_op_jmp_v(cpu_T0);
gen_bnd_jmp(s);
gen_jr(s, cpu_T0);
break;
case 5:
gen_op_ld_v(s, ot, cpu_T1, cpu_A0);
gen_add_A0_im(s, 1 << ot);
gen_op_ld_v(s, MO_16, cpu_T0, cpu_A0);
do_ljmp:
if (s->pe && !s->vm86) {
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T0);
gen_helper_ljmp_protected(cpu_env, cpu_tmp2_i32, cpu_T1,
tcg_const_tl(s->pc - s->cs_base));
} else {
gen_op_movl_seg_T0_vm(R_CS);
gen_op_jmp_v(cpu_T1);
}
tcg_gen_ld_tl(cpu_tmp4, cpu_env, offsetof(CPUX86State, eip));
gen_jr(s, cpu_tmp4);
break;
case 6:
gen_push_v(s, cpu_T0);
break;
default:
goto unknown_op;
}
break;
case 0x84:
case 0x85:
ot = mo_b_d(b, dflag);
modrm = x86_ldub_code(env, s);
reg = ((modrm >> 3) & 7) | rex_r;
gen_ldst_modrm(env, s, modrm, ot, OR_TMP0, 0);
gen_op_mov_v_reg(ot, cpu_T1, reg);
gen_op_testl_T0_T1_cc();
set_cc_op(s, CC_OP_LOGICB + ot);
break;
case 0xa8:
case 0xa9:
ot = mo_b_d(b, dflag);
val = insn_get(env, s, ot);
gen_op_mov_v_reg(ot, cpu_T0, OR_EAX);
tcg_gen_movi_tl(cpu_T1, val);
gen_op_testl_T0_T1_cc();
set_cc_op(s, CC_OP_LOGICB + ot);
break;
case 0x98:
switch (dflag) {
#ifdef TARGET_X86_64
case MO_64:
gen_op_mov_v_reg(MO_32, cpu_T0, R_EAX);
tcg_gen_ext32s_tl(cpu_T0, cpu_T0);
gen_op_mov_reg_v(MO_64, R_EAX, cpu_T0);
break;
#endif
case MO_32:
gen_op_mov_v_reg(MO_16, cpu_T0, R_EAX);
tcg_gen_ext16s_tl(cpu_T0, cpu_T0);
gen_op_mov_reg_v(MO_32, R_EAX, cpu_T0);
break;
case MO_16:
gen_op_mov_v_reg(MO_8, cpu_T0, R_EAX);
tcg_gen_ext8s_tl(cpu_T0, cpu_T0);
gen_op_mov_reg_v(MO_16, R_EAX, cpu_T0);
break;
default:
tcg_abort();
}
break;
case 0x99:
switch (dflag) {
#ifdef TARGET_X86_64
case MO_64:
gen_op_mov_v_reg(MO_64, cpu_T0, R_EAX);
tcg_gen_sari_tl(cpu_T0, cpu_T0, 63);
gen_op_mov_reg_v(MO_64, R_EDX, cpu_T0);
break;
#endif
case MO_32:
gen_op_mov_v_reg(MO_32, cpu_T0, R_EAX);
tcg_gen_ext32s_tl(cpu_T0, cpu_T0);
tcg_gen_sari_tl(cpu_T0, cpu_T0, 31);
gen_op_mov_reg_v(MO_32, R_EDX, cpu_T0);
break;
case MO_16:
gen_op_mov_v_reg(MO_16, cpu_T0, R_EAX);
tcg_gen_ext16s_tl(cpu_T0, cpu_T0);
tcg_gen_sari_tl(cpu_T0, cpu_T0, 15);
gen_op_mov_reg_v(MO_16, R_EDX, cpu_T0);
break;
default:
tcg_abort();
}
break;
case 0x1af:
case 0x69:
case 0x6b:
ot = dflag;
modrm = x86_ldub_code(env, s);
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(env, s, modrm, ot, OR_TMP0, 0);
if (b == 0x69) {
val = insn_get(env, s, ot);
tcg_gen_movi_tl(cpu_T1, val);
} else if (b == 0x6b) {
val = (int8_t)insn_get(env, s, MO_8);
tcg_gen_movi_tl(cpu_T1, val);
} else {
gen_op_mov_v_reg(ot, cpu_T1, reg);
}
switch (ot) {
#ifdef TARGET_X86_64
case MO_64:
tcg_gen_muls2_i64(cpu_regs[reg], cpu_T1, cpu_T0, cpu_T1);
tcg_gen_mov_tl(cpu_cc_dst, cpu_regs[reg]);
tcg_gen_sari_tl(cpu_cc_src, cpu_cc_dst, 63);
tcg_gen_sub_tl(cpu_cc_src, cpu_cc_src, cpu_T1);
break;
#endif
case MO_32:
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T0);
tcg_gen_trunc_tl_i32(cpu_tmp3_i32, cpu_T1);
tcg_gen_muls2_i32(cpu_tmp2_i32, cpu_tmp3_i32,
cpu_tmp2_i32, cpu_tmp3_i32);
tcg_gen_extu_i32_tl(cpu_regs[reg], cpu_tmp2_i32);
tcg_gen_sari_i32(cpu_tmp2_i32, cpu_tmp2_i32, 31);
tcg_gen_mov_tl(cpu_cc_dst, cpu_regs[reg]);
tcg_gen_sub_i32(cpu_tmp2_i32, cpu_tmp2_i32, cpu_tmp3_i32);
tcg_gen_extu_i32_tl(cpu_cc_src, cpu_tmp2_i32);
break;
default:
tcg_gen_ext16s_tl(cpu_T0, cpu_T0);
tcg_gen_ext16s_tl(cpu_T1, cpu_T1);
tcg_gen_mul_tl(cpu_T0, cpu_T0, cpu_T1);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T0);
tcg_gen_ext16s_tl(cpu_tmp0, cpu_T0);
tcg_gen_sub_tl(cpu_cc_src, cpu_T0, cpu_tmp0);
gen_op_mov_reg_v(ot, reg, cpu_T0);
break;
}
set_cc_op(s, CC_OP_MULB + ot);
break;
case 0x1c0:
case 0x1c1:
ot = mo_b_d(b, dflag);
modrm = x86_ldub_code(env, s);
reg = ((modrm >> 3) & 7) | rex_r;
mod = (modrm >> 6) & 3;
gen_op_mov_v_reg(ot, cpu_T0, reg);
if (mod == 3) {
rm = (modrm & 7) | REX_B(s);
gen_op_mov_v_reg(ot, cpu_T1, rm);
tcg_gen_add_tl(cpu_T0, cpu_T0, cpu_T1);
gen_op_mov_reg_v(ot, reg, cpu_T1);
gen_op_mov_reg_v(ot, rm, cpu_T0);
} else {
gen_lea_modrm(env, s, modrm);
if (s->prefix & PREFIX_LOCK) {
tcg_gen_atomic_fetch_add_tl(cpu_T1, cpu_A0, cpu_T0,
s->mem_index, ot | MO_LE);
tcg_gen_add_tl(cpu_T0, cpu_T0, cpu_T1);
} else {
gen_op_ld_v(s, ot, cpu_T1, cpu_A0);
tcg_gen_add_tl(cpu_T0, cpu_T0, cpu_T1);
gen_op_st_v(s, ot, cpu_T0, cpu_A0);
}
gen_op_mov_reg_v(ot, reg, cpu_T1);
}
gen_op_update2_cc();
set_cc_op(s, CC_OP_ADDB + ot);
break;
case 0x1b0:
case 0x1b1:
{
TCGv oldv, newv, cmpv;
ot = mo_b_d(b, dflag);
modrm = x86_ldub_code(env, s);
reg = ((modrm >> 3) & 7) | rex_r;
mod = (modrm >> 6) & 3;
oldv = tcg_temp_new();
newv = tcg_temp_new();
cmpv = tcg_temp_new();
gen_op_mov_v_reg(ot, newv, reg);
tcg_gen_mov_tl(cmpv, cpu_regs[R_EAX]);
if (s->prefix & PREFIX_LOCK) {
if (mod == 3) {
goto illegal_op;
}
gen_lea_modrm(env, s, modrm);
tcg_gen_atomic_cmpxchg_tl(oldv, cpu_A0, cmpv, newv,
s->mem_index, ot | MO_LE);
gen_op_mov_reg_v(ot, R_EAX, oldv);
} else {
if (mod == 3) {
rm = (modrm & 7) | REX_B(s);
gen_op_mov_v_reg(ot, oldv, rm);
} else {
gen_lea_modrm(env, s, modrm);
gen_op_ld_v(s, ot, oldv, cpu_A0);
rm = 0;
}
gen_extu(ot, oldv);
gen_extu(ot, cmpv);
tcg_gen_movcond_tl(TCG_COND_EQ, newv, oldv, cmpv, newv, oldv);
if (mod == 3) {
gen_op_mov_reg_v(ot, R_EAX, oldv);
gen_op_mov_reg_v(ot, rm, newv);
} else {
gen_op_st_v(s, ot, newv, cpu_A0);
gen_op_mov_reg_v(ot, R_EAX, oldv);
}
}
tcg_gen_mov_tl(cpu_cc_src, oldv);
tcg_gen_mov_tl(cpu_cc_srcT, cmpv);
tcg_gen_sub_tl(cpu_cc_dst, cmpv, oldv);
set_cc_op(s, CC_OP_SUBB + ot);
tcg_temp_free(oldv);
tcg_temp_free(newv);
tcg_temp_free(cmpv);
}
break;
case 0x1c7:
modrm = x86_ldub_code(env, s);
mod = (modrm >> 6) & 3;
if ((mod == 3) || ((modrm & 0x38) != 0x8))
goto illegal_op;
#ifdef TARGET_X86_64
if (dflag == MO_64) {
if (!(s->cpuid_ext_features & CPUID_EXT_CX16))
goto illegal_op;
gen_lea_modrm(env, s, modrm);
if ((s->prefix & PREFIX_LOCK) && parallel_cpus) {
gen_helper_cmpxchg16b(cpu_env, cpu_A0);
} else {
gen_helper_cmpxchg16b_unlocked(cpu_env, cpu_A0);
}
} else
#endif
{
if (!(s->cpuid_features & CPUID_CX8))
goto illegal_op;
gen_lea_modrm(env, s, modrm);
if ((s->prefix & PREFIX_LOCK) && parallel_cpus) {
gen_helper_cmpxchg8b(cpu_env, cpu_A0);
} else {
gen_helper_cmpxchg8b_unlocked(cpu_env, cpu_A0);
}
}
set_cc_op(s, CC_OP_EFLAGS);
break;
case 0x50 ... 0x57:
gen_op_mov_v_reg(MO_32, cpu_T0, (b & 7) | REX_B(s));
gen_push_v(s, cpu_T0);
break;
case 0x58 ... 0x5f:
ot = gen_pop_T0(s);
gen_pop_update(s, ot);
gen_op_mov_reg_v(ot, (b & 7) | REX_B(s), cpu_T0);
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:
ot = mo_pushpop(s, dflag);
if (b == 0x68)
val = insn_get(env, s, ot);
else
val = (int8_t)insn_get(env, s, MO_8);
tcg_gen_movi_tl(cpu_T0, val);
gen_push_v(s, cpu_T0);
break;
case 0x8f:
modrm = x86_ldub_code(env, s);
mod = (modrm >> 6) & 3;
ot = gen_pop_T0(s);
if (mod == 3) {
gen_pop_update(s, ot);
rm = (modrm & 7) | REX_B(s);
gen_op_mov_reg_v(ot, rm, cpu_T0);
} else {
s->popl_esp_hack = 1 << ot;
gen_ldst_modrm(env, s, modrm, ot, OR_TMP0, 1);
s->popl_esp_hack = 0;
gen_pop_update(s, ot);
}
break;
case 0xc8:
{
int level;
val = x86_lduw_code(env, s);
level = x86_ldub_code(env, s);
gen_enter(s, val, level);
}
break;
case 0xc9:
gen_leave(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_v(s, cpu_T0);
break;
case 0x1a0:
case 0x1a8:
gen_op_movl_T0_seg((b >> 3) & 7);
gen_push_v(s, cpu_T0);
break;
case 0x07:
case 0x17:
case 0x1f:
if (CODE64(s))
goto illegal_op;
reg = b >> 3;
ot = gen_pop_T0(s);
gen_movl_seg_T0(s, reg);
gen_pop_update(s, ot);
if (s->base.is_jmp) {
gen_jmp_im(s->pc - s->cs_base);
if (reg == R_SS) {
s->tf = 0;
gen_eob_inhibit_irq(s, true);
} else {
gen_eob(s);
}
}
break;
case 0x1a1:
case 0x1a9:
ot = gen_pop_T0(s);
gen_movl_seg_T0(s, (b >> 3) & 7);
gen_pop_update(s, ot);
if (s->base.is_jmp) {
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
}
break;
case 0x88:
case 0x89:
ot = mo_b_d(b, dflag);
modrm = x86_ldub_code(env, s);
reg = ((modrm >> 3) & 7) | rex_r;
gen_ldst_modrm(env, s, modrm, ot, reg, 1);
break;
case 0xc6:
case 0xc7:
ot = mo_b_d(b, dflag);
modrm = x86_ldub_code(env, s);
mod = (modrm >> 6) & 3;
if (mod != 3) {
s->rip_offset = insn_const_size(ot);
gen_lea_modrm(env, s, modrm);
}
val = insn_get(env, s, ot);
tcg_gen_movi_tl(cpu_T0, val);
if (mod != 3) {
gen_op_st_v(s, ot, cpu_T0, cpu_A0);
} else {
gen_op_mov_reg_v(ot, (modrm & 7) | REX_B(s), cpu_T0);
}
break;
case 0x8a:
case 0x8b:
ot = mo_b_d(b, dflag);
modrm = x86_ldub_code(env, s);
reg = ((modrm >> 3) & 7) | rex_r;
gen_ldst_modrm(env, s, modrm, ot, OR_TMP0, 0);
gen_op_mov_reg_v(ot, reg, cpu_T0);
break;
case 0x8e:
modrm = x86_ldub_code(env, s);
reg = (modrm >> 3) & 7;
if (reg >= 6 || reg == R_CS)
goto illegal_op;
gen_ldst_modrm(env, s, modrm, MO_16, OR_TMP0, 0);
gen_movl_seg_T0(s, reg);
if (s->base.is_jmp) {
gen_jmp_im(s->pc - s->cs_base);
if (reg == R_SS) {
s->tf = 0;
gen_eob_inhibit_irq(s, true);
} else {
gen_eob(s);
}
}
break;
case 0x8c:
modrm = x86_ldub_code(env, s);
reg = (modrm >> 3) & 7;
mod = (modrm >> 6) & 3;
if (reg >= 6)
goto illegal_op;
gen_op_movl_T0_seg(reg);
ot = mod == 3 ? dflag : MO_16;
gen_ldst_modrm(env, s, modrm, ot, OR_TMP0, 1);
break;
case 0x1b6:
case 0x1b7:
case 0x1be:
case 0x1bf:
{
TCGMemOp d_ot;
TCGMemOp s_ot;
d_ot = dflag;
ot = (b & 1) + MO_8;
s_ot = b & 8 ? MO_SIGN | ot : ot;
modrm = x86_ldub_code(env, s);
reg = ((modrm >> 3) & 7) | rex_r;
mod = (modrm >> 6) & 3;
rm = (modrm & 7) | REX_B(s);
if (mod == 3) {
if (s_ot == MO_SB && byte_reg_is_xH(rm)) {
tcg_gen_sextract_tl(cpu_T0, cpu_regs[rm - 4], 8, 8);
} else {
gen_op_mov_v_reg(ot, cpu_T0, rm);
switch (s_ot) {
case MO_UB:
tcg_gen_ext8u_tl(cpu_T0, cpu_T0);
break;
case MO_SB:
tcg_gen_ext8s_tl(cpu_T0, cpu_T0);
break;
case MO_UW:
tcg_gen_ext16u_tl(cpu_T0, cpu_T0);
break;
default:
case MO_SW:
tcg_gen_ext16s_tl(cpu_T0, cpu_T0);
break;
}
}
gen_op_mov_reg_v(d_ot, reg, cpu_T0);
} else {
gen_lea_modrm(env, s, modrm);
gen_op_ld_v(s, s_ot, cpu_T0, cpu_A0);
gen_op_mov_reg_v(d_ot, reg, cpu_T0);
}
}
break;
case 0x8d:
modrm = x86_ldub_code(env, s);
mod = (modrm >> 6) & 3;
if (mod == 3)
goto illegal_op;
reg = ((modrm >> 3) & 7) | rex_r;
{
AddressParts a = gen_lea_modrm_0(env, s, modrm);
TCGv ea = gen_lea_modrm_1(a);
gen_lea_v_seg(s, s->aflag, ea, -1, -1);
gen_op_mov_reg_v(dflag, reg, cpu_A0);
}
break;
case 0xa0:
case 0xa1:
case 0xa2:
case 0xa3:
{
target_ulong offset_addr;
ot = mo_b_d(b, dflag);
switch (s->aflag) {
#ifdef TARGET_X86_64
case MO_64:
offset_addr = x86_ldq_code(env, s);
break;
#endif
default:
offset_addr = insn_get(env, s, s->aflag);
break;
}
tcg_gen_movi_tl(cpu_A0, offset_addr);
gen_add_A0_ds_seg(s);
if ((b & 2) == 0) {
gen_op_ld_v(s, ot, cpu_T0, cpu_A0);
gen_op_mov_reg_v(ot, R_EAX, cpu_T0);
} else {
gen_op_mov_v_reg(ot, cpu_T0, R_EAX);
gen_op_st_v(s, ot, cpu_T0, cpu_A0);
}
}
break;
case 0xd7:
tcg_gen_mov_tl(cpu_A0, cpu_regs[R_EBX]);
tcg_gen_ext8u_tl(cpu_T0, cpu_regs[R_EAX]);
tcg_gen_add_tl(cpu_A0, cpu_A0, cpu_T0);
gen_extu(s->aflag, cpu_A0);
gen_add_A0_ds_seg(s);
gen_op_ld_v(s, MO_8, cpu_T0, cpu_A0);
gen_op_mov_reg_v(MO_8, R_EAX, cpu_T0);
break;
case 0xb0 ... 0xb7:
val = insn_get(env, s, MO_8);
tcg_gen_movi_tl(cpu_T0, val);
gen_op_mov_reg_v(MO_8, (b & 7) | REX_B(s), cpu_T0);
break;
case 0xb8 ... 0xbf:
#ifdef TARGET_X86_64
if (dflag == MO_64) {
uint64_t tmp;
tmp = x86_ldq_code(env, s);
reg = (b & 7) | REX_B(s);
tcg_gen_movi_tl(cpu_T0, tmp);
gen_op_mov_reg_v(MO_64, reg, cpu_T0);
} else
#endif
{
ot = dflag;
val = insn_get(env, s, ot);
reg = (b & 7) | REX_B(s);
tcg_gen_movi_tl(cpu_T0, val);
gen_op_mov_reg_v(ot, reg, cpu_T0);
}
break;
case 0x91 ... 0x97:
do_xchg_reg_eax:
ot = dflag;
reg = (b & 7) | REX_B(s);
rm = R_EAX;
goto do_xchg_reg;
case 0x86:
case 0x87:
ot = mo_b_d(b, dflag);
modrm = x86_ldub_code(env, s);
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_v_reg(ot, cpu_T0, reg);
gen_op_mov_v_reg(ot, cpu_T1, rm);
gen_op_mov_reg_v(ot, rm, cpu_T0);
gen_op_mov_reg_v(ot, reg, cpu_T1);
} else {
gen_lea_modrm(env, s, modrm);
gen_op_mov_v_reg(ot, cpu_T0, reg);
tcg_gen_atomic_xchg_tl(cpu_T1, cpu_A0, cpu_T0,
s->mem_index, ot | MO_LE);
gen_op_mov_reg_v(ot, reg, cpu_T1);
}
break;
case 0xc4:
op = R_ES;
goto do_lxx;
case 0xc5:
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 != MO_16 ? MO_32 : MO_16;
modrm = x86_ldub_code(env, s);
reg = ((modrm >> 3) & 7) | rex_r;
mod = (modrm >> 6) & 3;
if (mod == 3)
goto illegal_op;
gen_lea_modrm(env, s, modrm);
gen_op_ld_v(s, ot, cpu_T1, cpu_A0);
gen_add_A0_im(s, 1 << ot);
gen_op_ld_v(s, MO_16, cpu_T0, cpu_A0);
gen_movl_seg_T0(s, op);
gen_op_mov_reg_v(ot, reg, cpu_T1);
if (s->base.is_jmp) {
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
}
break;
case 0xc0:
case 0xc1:
shift = 2;
grp2:
{
ot = mo_b_d(b, dflag);
modrm = x86_ldub_code(env, s);
mod = (modrm >> 6) & 3;
op = (modrm >> 3) & 7;
if (mod != 3) {
if (shift == 2) {
s->rip_offset = 1;
}
gen_lea_modrm(env, s, modrm);
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 = x86_ldub_code(env, s);
}
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;
modrm = x86_ldub_code(env, s);
mod = (modrm >> 6) & 3;
rm = (modrm & 7) | REX_B(s);
reg = ((modrm >> 3) & 7) | rex_r;
if (mod != 3) {
gen_lea_modrm(env, s, modrm);
opreg = OR_TMP0;
} else {
opreg = rm;
}
gen_op_mov_v_reg(ot, cpu_T1, reg);
if (shift) {
TCGv imm = tcg_const_tl(x86_ldub_code(env, s));
gen_shiftd_rm_T1(s, ot, opreg, op, imm);
tcg_temp_free(imm);
} else {
gen_shiftd_rm_T1(s, ot, opreg, op, cpu_regs[R_ECX]);
}
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 = x86_ldub_code(env, s);
mod = (modrm >> 6) & 3;
rm = modrm & 7;
op = ((b & 7) << 3) | ((modrm >> 3) & 7);
if (mod != 3) {
gen_lea_modrm(env, s, modrm);
switch(op) {
case 0x00 ... 0x07:
case 0x10 ... 0x17:
case 0x20 ... 0x27:
case 0x30 ... 0x37:
{
int op1;
op1 = op & 7;
switch(op >> 4) {
case 0:
tcg_gen_qemu_ld_i32(cpu_tmp2_i32, cpu_A0,
s->mem_index, MO_LEUL);
gen_helper_flds_FT0(cpu_env, cpu_tmp2_i32);
break;
case 1:
tcg_gen_qemu_ld_i32(cpu_tmp2_i32, cpu_A0,
s->mem_index, MO_LEUL);
gen_helper_fildl_FT0(cpu_env, cpu_tmp2_i32);
break;
case 2:
tcg_gen_qemu_ld_i64(cpu_tmp1_i64, cpu_A0,
s->mem_index, MO_LEQ);
gen_helper_fldl_FT0(cpu_env, cpu_tmp1_i64);
break;
case 3:
default:
tcg_gen_qemu_ld_i32(cpu_tmp2_i32, cpu_A0,
s->mem_index, MO_LESW);
gen_helper_fildl_FT0(cpu_env, cpu_tmp2_i32);
break;
}
gen_helper_fp_arith_ST0_FT0(op1);
if (op1 == 3) {
gen_helper_fpop(cpu_env);
}
}
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:
tcg_gen_qemu_ld_i32(cpu_tmp2_i32, cpu_A0,
s->mem_index, MO_LEUL);
gen_helper_flds_ST0(cpu_env, cpu_tmp2_i32);
break;
case 1:
tcg_gen_qemu_ld_i32(cpu_tmp2_i32, cpu_A0,
s->mem_index, MO_LEUL);
gen_helper_fildl_ST0(cpu_env, cpu_tmp2_i32);
break;
case 2:
tcg_gen_qemu_ld_i64(cpu_tmp1_i64, cpu_A0,
s->mem_index, MO_LEQ);
gen_helper_fldl_ST0(cpu_env, cpu_tmp1_i64);
break;
case 3:
default:
tcg_gen_qemu_ld_i32(cpu_tmp2_i32, cpu_A0,
s->mem_index, MO_LESW);
gen_helper_fildl_ST0(cpu_env, cpu_tmp2_i32);
break;
}
break;
case 1:
switch(op >> 4) {
case 1:
gen_helper_fisttl_ST0(cpu_tmp2_i32, cpu_env);
tcg_gen_qemu_st_i32(cpu_tmp2_i32, cpu_A0,
s->mem_index, MO_LEUL);
break;
case 2:
gen_helper_fisttll_ST0(cpu_tmp1_i64, cpu_env);
tcg_gen_qemu_st_i64(cpu_tmp1_i64, cpu_A0,
s->mem_index, MO_LEQ);
break;
case 3:
default:
gen_helper_fistt_ST0(cpu_tmp2_i32, cpu_env);
tcg_gen_qemu_st_i32(cpu_tmp2_i32, cpu_A0,
s->mem_index, MO_LEUW);
break;
}
gen_helper_fpop(cpu_env);
break;
default:
switch(op >> 4) {
case 0:
gen_helper_fsts_ST0(cpu_tmp2_i32, cpu_env);
tcg_gen_qemu_st_i32(cpu_tmp2_i32, cpu_A0,
s->mem_index, MO_LEUL);
break;
case 1:
gen_helper_fistl_ST0(cpu_tmp2_i32, cpu_env);
tcg_gen_qemu_st_i32(cpu_tmp2_i32, cpu_A0,
s->mem_index, MO_LEUL);
break;
case 2:
gen_helper_fstl_ST0(cpu_tmp1_i64, cpu_env);
tcg_gen_qemu_st_i64(cpu_tmp1_i64, cpu_A0,
s->mem_index, MO_LEQ);
break;
case 3:
default:
gen_helper_fist_ST0(cpu_tmp2_i32, cpu_env);
tcg_gen_qemu_st_i32(cpu_tmp2_i32, cpu_A0,
s->mem_index, MO_LEUW);
break;
}
if ((op & 7) == 3)
gen_helper_fpop(cpu_env);
break;
}
break;
case 0x0c:
gen_helper_fldenv(cpu_env, cpu_A0, tcg_const_i32(dflag - 1));
break;
case 0x0d:
tcg_gen_qemu_ld_i32(cpu_tmp2_i32, cpu_A0,
s->mem_index, MO_LEUW);
gen_helper_fldcw(cpu_env, cpu_tmp2_i32);
break;
case 0x0e:
gen_helper_fstenv(cpu_env, cpu_A0, tcg_const_i32(dflag - 1));
break;
case 0x0f:
gen_helper_fnstcw(cpu_tmp2_i32, cpu_env);
tcg_gen_qemu_st_i32(cpu_tmp2_i32, cpu_A0,
s->mem_index, MO_LEUW);
break;
case 0x1d:
gen_helper_fldt_ST0(cpu_env, cpu_A0);
break;
case 0x1f:
gen_helper_fstt_ST0(cpu_env, cpu_A0);
gen_helper_fpop(cpu_env);
break;
case 0x2c:
gen_helper_frstor(cpu_env, cpu_A0, tcg_const_i32(dflag - 1));
break;
case 0x2e:
gen_helper_fsave(cpu_env, cpu_A0, tcg_const_i32(dflag - 1));
break;
case 0x2f:
gen_helper_fnstsw(cpu_tmp2_i32, cpu_env);
tcg_gen_qemu_st_i32(cpu_tmp2_i32, cpu_A0,
s->mem_index, MO_LEUW);
break;
case 0x3c:
gen_helper_fbld_ST0(cpu_env, cpu_A0);
break;
case 0x3e:
gen_helper_fbst_ST0(cpu_env, cpu_A0);
gen_helper_fpop(cpu_env);
break;
case 0x3d:
tcg_gen_qemu_ld_i64(cpu_tmp1_i64, cpu_A0, s->mem_index, MO_LEQ);
gen_helper_fildll_ST0(cpu_env, cpu_tmp1_i64);
break;
case 0x3f:
gen_helper_fistll_ST0(cpu_tmp1_i64, cpu_env);
tcg_gen_qemu_st_i64(cpu_tmp1_i64, cpu_A0, s->mem_index, MO_LEQ);
gen_helper_fpop(cpu_env);
break;
default:
goto unknown_op;
}
} else {
opreg = rm;
switch(op) {
case 0x08:
gen_helper_fpush(cpu_env);
gen_helper_fmov_ST0_STN(cpu_env,
tcg_const_i32((opreg + 1) & 7));
break;
case 0x09:
case 0x29:
case 0x39:
gen_helper_fxchg_ST0_STN(cpu_env, tcg_const_i32(opreg));
break;
case 0x0a:
switch(rm) {
case 0:
gen_helper_fwait(cpu_env);
break;
default:
goto unknown_op;
}
break;
case 0x0c:
switch(rm) {
case 0:
gen_helper_fchs_ST0(cpu_env);
break;
case 1:
gen_helper_fabs_ST0(cpu_env);
break;
case 4:
gen_helper_fldz_FT0(cpu_env);
gen_helper_fcom_ST0_FT0(cpu_env);
break;
case 5:
gen_helper_fxam_ST0(cpu_env);
break;
default:
goto unknown_op;
}
break;
case 0x0d:
{
switch(rm) {
case 0:
gen_helper_fpush(cpu_env);
gen_helper_fld1_ST0(cpu_env);
break;
case 1:
gen_helper_fpush(cpu_env);
gen_helper_fldl2t_ST0(cpu_env);
break;
case 2:
gen_helper_fpush(cpu_env);
gen_helper_fldl2e_ST0(cpu_env);
break;
case 3:
gen_helper_fpush(cpu_env);
gen_helper_fldpi_ST0(cpu_env);
break;
case 4:
gen_helper_fpush(cpu_env);
gen_helper_fldlg2_ST0(cpu_env);
break;
case 5:
gen_helper_fpush(cpu_env);
gen_helper_fldln2_ST0(cpu_env);
break;
case 6:
gen_helper_fpush(cpu_env);
gen_helper_fldz_ST0(cpu_env);
break;
default:
goto unknown_op;
}
}
break;
case 0x0e:
switch(rm) {
case 0:
gen_helper_f2xm1(cpu_env);
break;
case 1:
gen_helper_fyl2x(cpu_env);
break;
case 2:
gen_helper_fptan(cpu_env);
break;
case 3:
gen_helper_fpatan(cpu_env);
break;
case 4:
gen_helper_fxtract(cpu_env);
break;
case 5:
gen_helper_fprem1(cpu_env);
break;
case 6:
gen_helper_fdecstp(cpu_env);
break;
default:
case 7:
gen_helper_fincstp(cpu_env);
break;
}
break;
case 0x0f:
switch(rm) {
case 0:
gen_helper_fprem(cpu_env);
break;
case 1:
gen_helper_fyl2xp1(cpu_env);
break;
case 2:
gen_helper_fsqrt(cpu_env);
break;
case 3:
gen_helper_fsincos(cpu_env);
break;
case 5:
gen_helper_fscale(cpu_env);
break;
case 4:
gen_helper_frndint(cpu_env);
break;
case 6:
gen_helper_fsin(cpu_env);
break;
default:
case 7:
gen_helper_fcos(cpu_env);
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(cpu_env);
} else {
gen_helper_fmov_FT0_STN(cpu_env, tcg_const_i32(opreg));
gen_helper_fp_arith_ST0_FT0(op1);
}
}
break;
case 0x02:
case 0x22:
gen_helper_fmov_FT0_STN(cpu_env, tcg_const_i32(opreg));
gen_helper_fcom_ST0_FT0(cpu_env);
break;
case 0x03:
case 0x23:
case 0x32:
gen_helper_fmov_FT0_STN(cpu_env, tcg_const_i32(opreg));
gen_helper_fcom_ST0_FT0(cpu_env);
gen_helper_fpop(cpu_env);
break;
case 0x15:
switch(rm) {
case 1:
gen_helper_fmov_FT0_STN(cpu_env, tcg_const_i32(1));
gen_helper_fucom_ST0_FT0(cpu_env);
gen_helper_fpop(cpu_env);
gen_helper_fpop(cpu_env);
break;
default:
goto unknown_op;
}
break;
case 0x1c:
switch(rm) {
case 0:
break;
case 1:
break;
case 2:
gen_helper_fclex(cpu_env);
break;
case 3:
gen_helper_fninit(cpu_env);
break;
case 4:
break;
default:
goto unknown_op;
}
break;
case 0x1d:
if (!(s->cpuid_features & CPUID_CMOV)) {
goto illegal_op;
}
gen_update_cc_op(s);
gen_helper_fmov_FT0_STN(cpu_env, tcg_const_i32(opreg));
gen_helper_fucomi_ST0_FT0(cpu_env);
set_cc_op(s, CC_OP_EFLAGS);
break;
case 0x1e:
if (!(s->cpuid_features & CPUID_CMOV)) {
goto illegal_op;
}
gen_update_cc_op(s);
gen_helper_fmov_FT0_STN(cpu_env, tcg_const_i32(opreg));
gen_helper_fcomi_ST0_FT0(cpu_env);
set_cc_op(s, CC_OP_EFLAGS);
break;
case 0x28:
gen_helper_ffree_STN(cpu_env, tcg_const_i32(opreg));
break;
case 0x2a:
gen_helper_fmov_STN_ST0(cpu_env, tcg_const_i32(opreg));
break;
case 0x2b:
case 0x0b:
case 0x3a:
case 0x3b:
gen_helper_fmov_STN_ST0(cpu_env, tcg_const_i32(opreg));
gen_helper_fpop(cpu_env);
break;
case 0x2c:
gen_helper_fmov_FT0_STN(cpu_env, tcg_const_i32(opreg));
gen_helper_fucom_ST0_FT0(cpu_env);
break;
case 0x2d:
gen_helper_fmov_FT0_STN(cpu_env, tcg_const_i32(opreg));
gen_helper_fucom_ST0_FT0(cpu_env);
gen_helper_fpop(cpu_env);
break;
case 0x33:
switch(rm) {
case 1:
gen_helper_fmov_FT0_STN(cpu_env, tcg_const_i32(1));
gen_helper_fcom_ST0_FT0(cpu_env);
gen_helper_fpop(cpu_env);
gen_helper_fpop(cpu_env);
break;
default:
goto unknown_op;
}
break;
case 0x38:
gen_helper_ffree_STN(cpu_env, tcg_const_i32(opreg));
gen_helper_fpop(cpu_env);
break;
case 0x3c:
switch(rm) {
case 0:
gen_helper_fnstsw(cpu_tmp2_i32, cpu_env);
tcg_gen_extu_i32_tl(cpu_T0, cpu_tmp2_i32);
gen_op_mov_reg_v(MO_16, R_EAX, cpu_T0);
break;
default:
goto unknown_op;
}
break;
case 0x3d:
if (!(s->cpuid_features & CPUID_CMOV)) {
goto illegal_op;
}
gen_update_cc_op(s);
gen_helper_fmov_FT0_STN(cpu_env, tcg_const_i32(opreg));
gen_helper_fucomi_ST0_FT0(cpu_env);
gen_helper_fpop(cpu_env);
set_cc_op(s, CC_OP_EFLAGS);
break;
case 0x3e:
if (!(s->cpuid_features & CPUID_CMOV)) {
goto illegal_op;
}
gen_update_cc_op(s);
gen_helper_fmov_FT0_STN(cpu_env, tcg_const_i32(opreg));
gen_helper_fcomi_ST0_FT0(cpu_env);
gen_helper_fpop(cpu_env);
set_cc_op(s, CC_OP_EFLAGS);
break;
case 0x10 ... 0x13:
case 0x18 ... 0x1b:
{
int op1;
TCGLabel *l1;
static const uint8_t fcmov_cc[8] = {
(JCC_B << 1),
(JCC_Z << 1),
(JCC_BE << 1),
(JCC_P << 1),
};
if (!(s->cpuid_features & CPUID_CMOV)) {
goto illegal_op;
}
op1 = fcmov_cc[op & 3] | (((op >> 3) & 1) ^ 1);
l1 = gen_new_label();
gen_jcc1_noeob(s, op1, l1);
gen_helper_fmov_ST0_STN(cpu_env, tcg_const_i32(opreg));
gen_set_label(l1);
}
break;
default:
goto unknown_op;
}
}
break;
case 0xa4:
case 0xa5:
ot = mo_b_d(b, dflag);
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:
ot = mo_b_d(b, dflag);
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:
ot = mo_b_d(b, dflag);
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:
ot = mo_b_d(b, dflag);
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);
}
break;
case 0xa6:
case 0xa7:
ot = mo_b_d(b, dflag);
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);
}
break;
case 0x6c:
case 0x6d:
ot = mo_b_d32(b, dflag);
tcg_gen_ext16u_tl(cpu_T0, cpu_regs[R_EDX]);
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 (tb_cflags(s->base.tb) & CF_USE_ICOUNT) {
gen_jmp(s, s->pc - s->cs_base);
}
}
break;
case 0x6e:
case 0x6f:
ot = mo_b_d32(b, dflag);
tcg_gen_ext16u_tl(cpu_T0, cpu_regs[R_EDX]);
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 (tb_cflags(s->base.tb) & CF_USE_ICOUNT) {
gen_jmp(s, s->pc - s->cs_base);
}
}
break;
case 0xe4:
case 0xe5:
ot = mo_b_d32(b, dflag);
val = x86_ldub_code(env, s);
tcg_gen_movi_tl(cpu_T0, val);
gen_check_io(s, ot, pc_start - s->cs_base,
SVM_IOIO_TYPE_MASK | svm_is_rep(prefixes));
if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) {
gen_io_start();
}
tcg_gen_movi_i32(cpu_tmp2_i32, val);
gen_helper_in_func(ot, cpu_T1, cpu_tmp2_i32);
gen_op_mov_reg_v(ot, R_EAX, cpu_T1);
gen_bpt_io(s, cpu_tmp2_i32, ot);
if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) {
gen_io_end();
gen_jmp(s, s->pc - s->cs_base);
}
break;
case 0xe6:
case 0xe7:
ot = mo_b_d32(b, dflag);
val = x86_ldub_code(env, s);
tcg_gen_movi_tl(cpu_T0, val);
gen_check_io(s, ot, pc_start - s->cs_base,
svm_is_rep(prefixes));
gen_op_mov_v_reg(ot, cpu_T1, R_EAX);
if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) {
gen_io_start();
}
tcg_gen_movi_i32(cpu_tmp2_i32, val);
tcg_gen_trunc_tl_i32(cpu_tmp3_i32, cpu_T1);
gen_helper_out_func(ot, cpu_tmp2_i32, cpu_tmp3_i32);
gen_bpt_io(s, cpu_tmp2_i32, ot);
if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) {
gen_io_end();
gen_jmp(s, s->pc - s->cs_base);
}
break;
case 0xec:
case 0xed:
ot = mo_b_d32(b, dflag);
tcg_gen_ext16u_tl(cpu_T0, cpu_regs[R_EDX]);
gen_check_io(s, ot, pc_start - s->cs_base,
SVM_IOIO_TYPE_MASK | svm_is_rep(prefixes));
if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) {
gen_io_start();
}
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T0);
gen_helper_in_func(ot, cpu_T1, cpu_tmp2_i32);
gen_op_mov_reg_v(ot, R_EAX, cpu_T1);
gen_bpt_io(s, cpu_tmp2_i32, ot);
if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) {
gen_io_end();
gen_jmp(s, s->pc - s->cs_base);
}
break;
case 0xee:
case 0xef:
ot = mo_b_d32(b, dflag);
tcg_gen_ext16u_tl(cpu_T0, cpu_regs[R_EDX]);
gen_check_io(s, ot, pc_start - s->cs_base,
svm_is_rep(prefixes));
gen_op_mov_v_reg(ot, cpu_T1, R_EAX);
if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) {
gen_io_start();
}
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T0);
tcg_gen_trunc_tl_i32(cpu_tmp3_i32, cpu_T1);
gen_helper_out_func(ot, cpu_tmp2_i32, cpu_tmp3_i32);
gen_bpt_io(s, cpu_tmp2_i32, ot);
if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) {
gen_io_end();
gen_jmp(s, s->pc - s->cs_base);
}
break;
case 0xc2:
val = x86_ldsw_code(env, s);
ot = gen_pop_T0(s);
gen_stack_update(s, val + (1 << ot));
gen_op_jmp_v(cpu_T0);
gen_bnd_jmp(s);
gen_jr(s, cpu_T0);
break;
case 0xc3:
ot = gen_pop_T0(s);
gen_pop_update(s, ot);
gen_op_jmp_v(cpu_T0);
gen_bnd_jmp(s);
gen_jr(s, cpu_T0);
break;
case 0xca:
val = x86_ldsw_code(env, s);
do_lret:
if (s->pe && !s->vm86) {
gen_update_cc_op(s);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_lret_protected(cpu_env, tcg_const_i32(dflag - 1),
tcg_const_i32(val));
} else {
gen_stack_A0(s);
gen_op_ld_v(s, dflag, cpu_T0, cpu_A0);
gen_op_jmp_v(cpu_T0);
gen_add_A0_im(s, 1 << dflag);
gen_op_ld_v(s, dflag, cpu_T0, cpu_A0);
gen_op_movl_seg_T0_vm(R_CS);
gen_stack_update(s, val + (2 << 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(cpu_env, tcg_const_i32(dflag - 1));
set_cc_op(s, 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(cpu_env, tcg_const_i32(dflag - 1));
set_cc_op(s, CC_OP_EFLAGS);
}
} else {
gen_helper_iret_protected(cpu_env, tcg_const_i32(dflag - 1),
tcg_const_i32(s->pc - s->cs_base));
set_cc_op(s, CC_OP_EFLAGS);
}
gen_eob(s);
break;
case 0xe8:
{
if (dflag != MO_16) {
tval = (int32_t)insn_get(env, s, MO_32);
} else {
tval = (int16_t)insn_get(env, s, MO_16);
}
next_eip = s->pc - s->cs_base;
tval += next_eip;
if (dflag == MO_16) {
tval &= 0xffff;
} else if (!CODE64(s)) {
tval &= 0xffffffff;
}
tcg_gen_movi_tl(cpu_T0, next_eip);
gen_push_v(s, cpu_T0);
gen_bnd_jmp(s);
gen_jmp(s, tval);
}
break;
case 0x9a:
{
unsigned int selector, offset;
if (CODE64(s))
goto illegal_op;
ot = dflag;
offset = insn_get(env, s, ot);
selector = insn_get(env, s, MO_16);
tcg_gen_movi_tl(cpu_T0, selector);
tcg_gen_movi_tl(cpu_T1, offset);
}
goto do_lcall;
case 0xe9:
if (dflag != MO_16) {
tval = (int32_t)insn_get(env, s, MO_32);
} else {
tval = (int16_t)insn_get(env, s, MO_16);
}
tval += s->pc - s->cs_base;
if (dflag == MO_16) {
tval &= 0xffff;
} else if (!CODE64(s)) {
tval &= 0xffffffff;
}
gen_bnd_jmp(s);
gen_jmp(s, tval);
break;
case 0xea:
{
unsigned int selector, offset;
if (CODE64(s))
goto illegal_op;
ot = dflag;
offset = insn_get(env, s, ot);
selector = insn_get(env, s, MO_16);
tcg_gen_movi_tl(cpu_T0, selector);
tcg_gen_movi_tl(cpu_T1, offset);
}
goto do_ljmp;
case 0xeb:
tval = (int8_t)insn_get(env, s, MO_8);
tval += s->pc - s->cs_base;
if (dflag == MO_16) {
tval &= 0xffff;
}
gen_jmp(s, tval);
break;
case 0x70 ... 0x7f:
tval = (int8_t)insn_get(env, s, MO_8);
goto do_jcc;
case 0x180 ... 0x18f:
if (dflag != MO_16) {
tval = (int32_t)insn_get(env, s, MO_32);
} else {
tval = (int16_t)insn_get(env, s, MO_16);
}
do_jcc:
next_eip = s->pc - s->cs_base;
tval += next_eip;
if (dflag == MO_16) {
tval &= 0xffff;
}
gen_bnd_jmp(s);
gen_jcc(s, b, tval, next_eip);
break;
case 0x190 ... 0x19f:
modrm = x86_ldub_code(env, s);
gen_setcc1(s, b, cpu_T0);
gen_ldst_modrm(env, s, modrm, MO_8, OR_TMP0, 1);
break;
case 0x140 ... 0x14f:
if (!(s->cpuid_features & CPUID_CMOV)) {
goto illegal_op;
}
ot = dflag;
modrm = x86_ldub_code(env, s);
reg = ((modrm >> 3) & 7) | rex_r;
gen_cmovcc1(env, s, ot, b, modrm, reg);
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 {
gen_update_cc_op(s);
gen_helper_read_eflags(cpu_T0, cpu_env);
gen_push_v(s, cpu_T0);
}
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 {
ot = gen_pop_T0(s);
if (s->cpl == 0) {
if (dflag != MO_16) {
gen_helper_write_eflags(cpu_env, cpu_T0,
tcg_const_i32((TF_MASK | AC_MASK |
ID_MASK | NT_MASK |
IF_MASK |
IOPL_MASK)));
} else {
gen_helper_write_eflags(cpu_env, cpu_T0,
tcg_const_i32((TF_MASK | AC_MASK |
ID_MASK | NT_MASK |
IF_MASK | IOPL_MASK)
& 0xffff));
}
} else {
if (s->cpl <= s->iopl) {
if (dflag != MO_16) {
gen_helper_write_eflags(cpu_env, cpu_T0,
tcg_const_i32((TF_MASK |
AC_MASK |
ID_MASK |
NT_MASK |
IF_MASK)));
} else {
gen_helper_write_eflags(cpu_env, cpu_T0,
tcg_const_i32((TF_MASK |
AC_MASK |
ID_MASK |
NT_MASK |
IF_MASK)
& 0xffff));
}
} else {
if (dflag != MO_16) {
gen_helper_write_eflags(cpu_env, cpu_T0,
tcg_const_i32((TF_MASK | AC_MASK |
ID_MASK | NT_MASK)));
} else {
gen_helper_write_eflags(cpu_env, cpu_T0,
tcg_const_i32((TF_MASK | AC_MASK |
ID_MASK | NT_MASK)
& 0xffff));
}
}
}
gen_pop_update(s, ot);
set_cc_op(s, 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_v_reg(MO_8, cpu_T0, R_AH);
gen_compute_eflags(s);
tcg_gen_andi_tl(cpu_cc_src, cpu_cc_src, CC_O);
tcg_gen_andi_tl(cpu_T0, cpu_T0, CC_S | CC_Z | CC_A | CC_P | CC_C);
tcg_gen_or_tl(cpu_cc_src, cpu_cc_src, cpu_T0);
break;
case 0x9f:
if (CODE64(s) && !(s->cpuid_ext3_features & CPUID_EXT3_LAHF_LM))
goto illegal_op;
gen_compute_eflags(s);
tcg_gen_ori_tl(cpu_T0, cpu_cc_src, 0x02);
gen_op_mov_reg_v(MO_8, R_AH, cpu_T0);
break;
case 0xf5:
gen_compute_eflags(s);
tcg_gen_xori_tl(cpu_cc_src, cpu_cc_src, CC_C);
break;
case 0xf8:
gen_compute_eflags(s);
tcg_gen_andi_tl(cpu_cc_src, cpu_cc_src, ~CC_C);
break;
case 0xf9:
gen_compute_eflags(s);
tcg_gen_ori_tl(cpu_cc_src, cpu_cc_src, CC_C);
break;
case 0xfc:
tcg_gen_movi_i32(cpu_tmp2_i32, 1);
tcg_gen_st_i32(cpu_tmp2_i32, cpu_env, offsetof(CPUX86State, df));
break;
case 0xfd:
tcg_gen_movi_i32(cpu_tmp2_i32, -1);
tcg_gen_st_i32(cpu_tmp2_i32, cpu_env, offsetof(CPUX86State, df));
break;
case 0x1ba:
ot = dflag;
modrm = x86_ldub_code(env, s);
op = (modrm >> 3) & 7;
mod = (modrm >> 6) & 3;
rm = (modrm & 7) | REX_B(s);
if (mod != 3) {
s->rip_offset = 1;
gen_lea_modrm(env, s, modrm);
if (!(s->prefix & PREFIX_LOCK)) {
gen_op_ld_v(s, ot, cpu_T0, cpu_A0);
}
} else {
gen_op_mov_v_reg(ot, cpu_T0, rm);
}
val = x86_ldub_code(env, s);
tcg_gen_movi_tl(cpu_T1, val);
if (op < 4)
goto unknown_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;
modrm = x86_ldub_code(env, s);
reg = ((modrm >> 3) & 7) | rex_r;
mod = (modrm >> 6) & 3;
rm = (modrm & 7) | REX_B(s);
gen_op_mov_v_reg(MO_32, cpu_T1, reg);
if (mod != 3) {
AddressParts a = gen_lea_modrm_0(env, s, modrm);
gen_exts(ot, cpu_T1);
tcg_gen_sari_tl(cpu_tmp0, cpu_T1, 3 + ot);
tcg_gen_shli_tl(cpu_tmp0, cpu_tmp0, ot);
tcg_gen_add_tl(cpu_A0, gen_lea_modrm_1(a), cpu_tmp0);
gen_lea_v_seg(s, s->aflag, cpu_A0, a.def_seg, s->override);
if (!(s->prefix & PREFIX_LOCK)) {
gen_op_ld_v(s, ot, cpu_T0, cpu_A0);
}
} else {
gen_op_mov_v_reg(ot, cpu_T0, rm);
}
bt_op:
tcg_gen_andi_tl(cpu_T1, cpu_T1, (1 << (3 + ot)) - 1);
tcg_gen_movi_tl(cpu_tmp0, 1);
tcg_gen_shl_tl(cpu_tmp0, cpu_tmp0, cpu_T1);
if (s->prefix & PREFIX_LOCK) {
switch (op) {
case 0:
gen_op_ld_v(s, ot, cpu_T0, cpu_A0);
break;
case 1:
tcg_gen_atomic_fetch_or_tl(cpu_T0, cpu_A0, cpu_tmp0,
s->mem_index, ot | MO_LE);
break;
case 2:
tcg_gen_not_tl(cpu_tmp0, cpu_tmp0);
tcg_gen_atomic_fetch_and_tl(cpu_T0, cpu_A0, cpu_tmp0,
s->mem_index, ot | MO_LE);
break;
default:
case 3:
tcg_gen_atomic_fetch_xor_tl(cpu_T0, cpu_A0, cpu_tmp0,
s->mem_index, ot | MO_LE);
break;
}
tcg_gen_shr_tl(cpu_tmp4, cpu_T0, cpu_T1);
} else {
tcg_gen_shr_tl(cpu_tmp4, cpu_T0, cpu_T1);
switch (op) {
case 0:
break;
case 1:
tcg_gen_or_tl(cpu_T0, cpu_T0, cpu_tmp0);
break;
case 2:
tcg_gen_andc_tl(cpu_T0, cpu_T0, cpu_tmp0);
break;
default:
case 3:
tcg_gen_xor_tl(cpu_T0, cpu_T0, cpu_tmp0);
break;
}
if (op != 0) {
if (mod != 3) {
gen_op_st_v(s, ot, cpu_T0, cpu_A0);
} else {
gen_op_mov_reg_v(ot, rm, cpu_T0);
}
}
}
switch (s->cc_op) {
case CC_OP_MULB ... CC_OP_MULQ:
case CC_OP_ADDB ... CC_OP_ADDQ:
case CC_OP_ADCB ... CC_OP_ADCQ:
case CC_OP_SUBB ... CC_OP_SUBQ:
case CC_OP_SBBB ... CC_OP_SBBQ:
case CC_OP_LOGICB ... CC_OP_LOGICQ:
case CC_OP_INCB ... CC_OP_INCQ:
case CC_OP_DECB ... CC_OP_DECQ:
case CC_OP_SHLB ... CC_OP_SHLQ:
case CC_OP_SARB ... CC_OP_SARQ:
case CC_OP_BMILGB ... CC_OP_BMILGQ:
tcg_gen_mov_tl(cpu_cc_src, cpu_tmp4);
set_cc_op(s, ((s->cc_op - CC_OP_MULB) & 3) + CC_OP_SARB);
break;
default:
gen_compute_eflags(s);
tcg_gen_deposit_tl(cpu_cc_src, cpu_cc_src, cpu_tmp4,
ctz32(CC_C), 1);
break;
}
break;
case 0x1bc:
case 0x1bd:
ot = dflag;
modrm = x86_ldub_code(env, s);
reg = ((modrm >> 3) & 7) | rex_r;
gen_ldst_modrm(env, s, modrm, ot, OR_TMP0, 0);
gen_extu(ot, cpu_T0);
if ((prefixes & PREFIX_REPZ)
&& (b & 1
? s->cpuid_ext3_features & CPUID_EXT3_ABM
: s->cpuid_7_0_ebx_features & CPUID_7_0_EBX_BMI1)) {
int size = 8 << ot;
tcg_gen_mov_tl(cpu_cc_src, cpu_T0);
if (b & 1) {
tcg_gen_clzi_tl(cpu_T0, cpu_T0, TARGET_LONG_BITS);
tcg_gen_subi_tl(cpu_T0, cpu_T0, TARGET_LONG_BITS - size);
} else {
tcg_gen_ctzi_tl(cpu_T0, cpu_T0, size);
}
gen_op_update1_cc();
set_cc_op(s, CC_OP_BMILGB + ot);
} else {
tcg_gen_mov_tl(cpu_cc_dst, cpu_T0);
set_cc_op(s, CC_OP_LOGICB + ot);
if (b & 1) {
tcg_gen_xori_tl(cpu_T1, cpu_regs[reg], TARGET_LONG_BITS - 1);
tcg_gen_clz_tl(cpu_T0, cpu_T0, cpu_T1);
tcg_gen_xori_tl(cpu_T0, cpu_T0, TARGET_LONG_BITS - 1);
} else {
tcg_gen_ctz_tl(cpu_T0, cpu_T0, cpu_regs[reg]);
}
}
gen_op_mov_reg_v(ot, reg, cpu_T0);
break;
case 0x27:
if (CODE64(s))
goto illegal_op;
gen_update_cc_op(s);
gen_helper_daa(cpu_env);
set_cc_op(s, CC_OP_EFLAGS);
break;
case 0x2f:
if (CODE64(s))
goto illegal_op;
gen_update_cc_op(s);
gen_helper_das(cpu_env);
set_cc_op(s, CC_OP_EFLAGS);
break;
case 0x37:
if (CODE64(s))
goto illegal_op;
gen_update_cc_op(s);
gen_helper_aaa(cpu_env);
set_cc_op(s, CC_OP_EFLAGS);
break;
case 0x3f:
if (CODE64(s))
goto illegal_op;
gen_update_cc_op(s);
gen_helper_aas(cpu_env);
set_cc_op(s, CC_OP_EFLAGS);
break;
case 0xd4:
if (CODE64(s))
goto illegal_op;
val = x86_ldub_code(env, s);
if (val == 0) {
gen_exception(s, EXCP00_DIVZ, pc_start - s->cs_base);
} else {
gen_helper_aam(cpu_env, tcg_const_i32(val));
set_cc_op(s, CC_OP_LOGICB);
}
break;
case 0xd5:
if (CODE64(s))
goto illegal_op;
val = x86_ldub_code(env, s);
gen_helper_aad(cpu_env, tcg_const_i32(val));
set_cc_op(s, CC_OP_LOGICB);
break;
case 0x90:
if (prefixes & PREFIX_LOCK) {
goto illegal_op;
}
if (REX_B(s)) {
goto do_xchg_reg_eax;
}
if (prefixes & PREFIX_REPZ) {
gen_update_cc_op(s);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_pause(cpu_env, tcg_const_i32(s->pc - pc_start));
s->base.is_jmp = DISAS_NORETURN;
}
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 {
gen_helper_fwait(cpu_env);
}
break;
case 0xcc:
gen_interrupt(s, EXCP03_INT3, pc_start - s->cs_base, s->pc - s->cs_base);
break;
case 0xcd:
val = x86_ldub_code(env, s);
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;
gen_update_cc_op(s);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_into(cpu_env, 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(x86_env_get_cpu(env)));
qemu_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(cpu_env);
} else {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
}
} else {
if (s->iopl == 3) {
gen_helper_cli(cpu_env);
} else {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
}
}
break;
case 0xfb:
if (s->vm86 ? s->iopl == 3 : s->cpl <= s->iopl) {
gen_helper_sti(cpu_env);
gen_jmp_im(s->pc - s->cs_base);
gen_eob_inhibit_irq(s, true);
} else {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
}
break;
case 0x62:
if (CODE64(s))
goto illegal_op;
ot = dflag;
modrm = x86_ldub_code(env, s);
reg = (modrm >> 3) & 7;
mod = (modrm >> 6) & 3;
if (mod == 3)
goto illegal_op;
gen_op_mov_v_reg(ot, cpu_T0, reg);
gen_lea_modrm(env, s, modrm);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T0);
if (ot == MO_16) {
gen_helper_boundw(cpu_env, cpu_A0, cpu_tmp2_i32);
} else {
gen_helper_boundl(cpu_env, cpu_A0, cpu_tmp2_i32);
}
break;
case 0x1c8 ... 0x1cf:
reg = (b & 7) | REX_B(s);
#ifdef TARGET_X86_64
if (dflag == MO_64) {
gen_op_mov_v_reg(MO_64, cpu_T0, reg);
tcg_gen_bswap64_i64(cpu_T0, cpu_T0);
gen_op_mov_reg_v(MO_64, reg, cpu_T0);
} else
#endif
{
gen_op_mov_v_reg(MO_32, cpu_T0, reg);
tcg_gen_ext32u_tl(cpu_T0, cpu_T0);
tcg_gen_bswap32_tl(cpu_T0, cpu_T0);
gen_op_mov_reg_v(MO_32, reg, cpu_T0);
}
break;
case 0xd6:
if (CODE64(s))
goto illegal_op;
gen_compute_eflags_c(s, cpu_T0);
tcg_gen_neg_tl(cpu_T0, cpu_T0);
gen_op_mov_reg_v(MO_8, R_EAX, cpu_T0);
break;
case 0xe0:
case 0xe1:
case 0xe2:
case 0xe3:
{
TCGLabel *l1, *l2, *l3;
tval = (int8_t)insn_get(env, s, MO_8);
next_eip = s->pc - s->cs_base;
tval += next_eip;
if (dflag == MO_16) {
tval &= 0xffff;
}
l1 = gen_new_label();
l2 = gen_new_label();
l3 = gen_new_label();
b &= 3;
switch(b) {
case 0:
case 1:
gen_op_add_reg_im(s->aflag, R_ECX, -1);
gen_op_jz_ecx(s->aflag, l3);
gen_jcc1(s, (JCC_Z << 1) | (b ^ 1), 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 {
gen_update_cc_op(s);
gen_jmp_im(pc_start - s->cs_base);
if (b & 2) {
gen_helper_rdmsr(cpu_env);
} else {
gen_helper_wrmsr(cpu_env);
}
}
break;
case 0x131:
gen_update_cc_op(s);
gen_jmp_im(pc_start - s->cs_base);
if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) {
gen_io_start();
}
gen_helper_rdtsc(cpu_env);
if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) {
gen_io_end();
gen_jmp(s, s->pc - s->cs_base);
}
break;
case 0x133:
gen_update_cc_op(s);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_rdpmc(cpu_env);
break;
case 0x134:
if (CODE64(s) && env->cpuid_vendor1 != CPUID_VENDOR_INTEL_1)
goto illegal_op;
if (!s->pe) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_helper_sysenter(cpu_env);
gen_eob(s);
}
break;
case 0x135:
if (CODE64(s) && env->cpuid_vendor1 != CPUID_VENDOR_INTEL_1)
goto illegal_op;
if (!s->pe) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_helper_sysexit(cpu_env, tcg_const_i32(dflag - 1));
gen_eob(s);
}
break;
#ifdef TARGET_X86_64
case 0x105:
gen_update_cc_op(s);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_syscall(cpu_env, tcg_const_i32(s->pc - pc_start));
gen_eob_worker(s, false, true);
break;
case 0x107:
if (!s->pe) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_helper_sysret(cpu_env, tcg_const_i32(dflag - 1));
if (s->lma) {
set_cc_op(s, CC_OP_EFLAGS);
}
gen_eob_worker(s, false, true);
}
break;
#endif
case 0x1a2:
gen_update_cc_op(s);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_cpuid(cpu_env);
break;
case 0xf4:
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_update_cc_op(s);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_hlt(cpu_env, tcg_const_i32(s->pc - pc_start));
s->base.is_jmp = DISAS_NORETURN;
}
break;
case 0x100:
modrm = x86_ldub_code(env, s);
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_T0, cpu_env,
offsetof(CPUX86State, ldt.selector));
ot = mod == 3 ? dflag : MO_16;
gen_ldst_modrm(env, 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(env, s, modrm, MO_16, OR_TMP0, 0);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T0);
gen_helper_lldt(cpu_env, 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_T0, cpu_env,
offsetof(CPUX86State, tr.selector));
ot = mod == 3 ? dflag : MO_16;
gen_ldst_modrm(env, 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(env, s, modrm, MO_16, OR_TMP0, 0);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T0);
gen_helper_ltr(cpu_env, cpu_tmp2_i32);
}
break;
case 4:
case 5:
if (!s->pe || s->vm86)
goto illegal_op;
gen_ldst_modrm(env, s, modrm, MO_16, OR_TMP0, 0);
gen_update_cc_op(s);
if (op == 4) {
gen_helper_verr(cpu_env, cpu_T0);
} else {
gen_helper_verw(cpu_env, cpu_T0);
}
set_cc_op(s, CC_OP_EFLAGS);
break;
default:
goto unknown_op;
}
break;
case 0x101:
modrm = x86_ldub_code(env, s);
switch (modrm) {
CASE_MODRM_MEM_OP(0):
gen_svm_check_intercept(s, pc_start, SVM_EXIT_GDTR_READ);
gen_lea_modrm(env, s, modrm);
tcg_gen_ld32u_tl(cpu_T0,
cpu_env, offsetof(CPUX86State, gdt.limit));
gen_op_st_v(s, MO_16, cpu_T0, cpu_A0);
gen_add_A0_im(s, 2);
tcg_gen_ld_tl(cpu_T0, cpu_env, offsetof(CPUX86State, gdt.base));
if (dflag == MO_16) {
tcg_gen_andi_tl(cpu_T0, cpu_T0, 0xffffff);
}
gen_op_st_v(s, CODE64(s) + MO_32, cpu_T0, cpu_A0);
break;
case 0xc8:
if (!(s->cpuid_ext_features & CPUID_EXT_MONITOR) || s->cpl != 0) {
goto illegal_op;
}
gen_update_cc_op(s);
gen_jmp_im(pc_start - s->cs_base);
tcg_gen_mov_tl(cpu_A0, cpu_regs[R_EAX]);
gen_extu(s->aflag, cpu_A0);
gen_add_A0_ds_seg(s);
gen_helper_monitor(cpu_env, cpu_A0);
break;
case 0xc9:
if (!(s->cpuid_ext_features & CPUID_EXT_MONITOR) || s->cpl != 0) {
goto illegal_op;
}
gen_update_cc_op(s);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_mwait(cpu_env, tcg_const_i32(s->pc - pc_start));
gen_eob(s);
break;
case 0xca:
if (!(s->cpuid_7_0_ebx_features & CPUID_7_0_EBX_SMAP)
|| s->cpl != 0) {
goto illegal_op;
}
gen_helper_clac(cpu_env);
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
break;
case 0xcb:
if (!(s->cpuid_7_0_ebx_features & CPUID_7_0_EBX_SMAP)
|| s->cpl != 0) {
goto illegal_op;
}
gen_helper_stac(cpu_env);
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
break;
CASE_MODRM_MEM_OP(1):
gen_svm_check_intercept(s, pc_start, SVM_EXIT_IDTR_READ);
gen_lea_modrm(env, s, modrm);
tcg_gen_ld32u_tl(cpu_T0, cpu_env, offsetof(CPUX86State, idt.limit));
gen_op_st_v(s, MO_16, cpu_T0, cpu_A0);
gen_add_A0_im(s, 2);
tcg_gen_ld_tl(cpu_T0, cpu_env, offsetof(CPUX86State, idt.base));
if (dflag == MO_16) {
tcg_gen_andi_tl(cpu_T0, cpu_T0, 0xffffff);
}
gen_op_st_v(s, CODE64(s) + MO_32, cpu_T0, cpu_A0);
break;
case 0xd0:
if ((s->cpuid_ext_features & CPUID_EXT_XSAVE) == 0
|| (s->prefix & (PREFIX_LOCK | PREFIX_DATA
| PREFIX_REPZ | PREFIX_REPNZ))) {
goto illegal_op;
}
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_regs[R_ECX]);
gen_helper_xgetbv(cpu_tmp1_i64, cpu_env, cpu_tmp2_i32);
tcg_gen_extr_i64_tl(cpu_regs[R_EAX], cpu_regs[R_EDX], cpu_tmp1_i64);
break;
case 0xd1:
if ((s->cpuid_ext_features & CPUID_EXT_XSAVE) == 0
|| (s->prefix & (PREFIX_LOCK | PREFIX_DATA
| PREFIX_REPZ | PREFIX_REPNZ))) {
goto illegal_op;
}
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
break;
}
tcg_gen_concat_tl_i64(cpu_tmp1_i64, cpu_regs[R_EAX],
cpu_regs[R_EDX]);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_regs[R_ECX]);
gen_helper_xsetbv(cpu_env, cpu_tmp2_i32, cpu_tmp1_i64);
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
break;
case 0xd8:
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;
}
gen_update_cc_op(s);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_vmrun(cpu_env, tcg_const_i32(s->aflag - 1),
tcg_const_i32(s->pc - pc_start));
tcg_gen_exit_tb(0);
s->base.is_jmp = DISAS_NORETURN;
break;
case 0xd9:
if (!(s->flags & HF_SVME_MASK)) {
goto illegal_op;
}
gen_update_cc_op(s);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_vmmcall(cpu_env);
break;
case 0xda:
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;
}
gen_update_cc_op(s);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_vmload(cpu_env, tcg_const_i32(s->aflag - 1));
break;
case 0xdb:
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;
}
gen_update_cc_op(s);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_vmsave(cpu_env, tcg_const_i32(s->aflag - 1));
break;
case 0xdc:
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;
}
gen_update_cc_op(s);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_stgi(cpu_env);
break;
case 0xdd:
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;
}
gen_update_cc_op(s);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_clgi(cpu_env);
break;
case 0xde:
if ((!(s->flags & HF_SVME_MASK)
&& !(s->cpuid_ext3_features & CPUID_EXT3_SKINIT))
|| !s->pe) {
goto illegal_op;
}
gen_update_cc_op(s);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_skinit(cpu_env);
break;
case 0xdf:
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;
}
gen_update_cc_op(s);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_invlpga(cpu_env, tcg_const_i32(s->aflag - 1));
break;
CASE_MODRM_MEM_OP(2):
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
break;
}
gen_svm_check_intercept(s, pc_start, SVM_EXIT_GDTR_WRITE);
gen_lea_modrm(env, s, modrm);
gen_op_ld_v(s, MO_16, cpu_T1, cpu_A0);
gen_add_A0_im(s, 2);
gen_op_ld_v(s, CODE64(s) + MO_32, cpu_T0, cpu_A0);
if (dflag == MO_16) {
tcg_gen_andi_tl(cpu_T0, cpu_T0, 0xffffff);
}
tcg_gen_st_tl(cpu_T0, cpu_env, offsetof(CPUX86State, gdt.base));
tcg_gen_st32_tl(cpu_T1, cpu_env, offsetof(CPUX86State, gdt.limit));
break;
CASE_MODRM_MEM_OP(3):
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
break;
}
gen_svm_check_intercept(s, pc_start, SVM_EXIT_IDTR_WRITE);
gen_lea_modrm(env, s, modrm);
gen_op_ld_v(s, MO_16, cpu_T1, cpu_A0);
gen_add_A0_im(s, 2);
gen_op_ld_v(s, CODE64(s) + MO_32, cpu_T0, cpu_A0);
if (dflag == MO_16) {
tcg_gen_andi_tl(cpu_T0, cpu_T0, 0xffffff);
}
tcg_gen_st_tl(cpu_T0, cpu_env, offsetof(CPUX86State, idt.base));
tcg_gen_st32_tl(cpu_T1, cpu_env, offsetof(CPUX86State, idt.limit));
break;
CASE_MODRM_OP(4):
gen_svm_check_intercept(s, pc_start, SVM_EXIT_READ_CR0);
tcg_gen_ld_tl(cpu_T0, cpu_env, offsetof(CPUX86State, cr[0]));
if (CODE64(s)) {
mod = (modrm >> 6) & 3;
ot = (mod != 3 ? MO_16 : s->dflag);
} else {
ot = MO_16;
}
gen_ldst_modrm(env, s, modrm, ot, OR_TMP0, 1);
break;
case 0xee:
if (prefixes & PREFIX_LOCK) {
goto illegal_op;
}
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_regs[R_ECX]);
gen_helper_rdpkru(cpu_tmp1_i64, cpu_env, cpu_tmp2_i32);
tcg_gen_extr_i64_tl(cpu_regs[R_EAX], cpu_regs[R_EDX], cpu_tmp1_i64);
break;
case 0xef:
if (prefixes & PREFIX_LOCK) {
goto illegal_op;
}
tcg_gen_concat_tl_i64(cpu_tmp1_i64, cpu_regs[R_EAX],
cpu_regs[R_EDX]);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_regs[R_ECX]);
gen_helper_wrpkru(cpu_env, cpu_tmp2_i32, cpu_tmp1_i64);
break;
CASE_MODRM_OP(6):
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
break;
}
gen_svm_check_intercept(s, pc_start, SVM_EXIT_WRITE_CR0);
gen_ldst_modrm(env, s, modrm, MO_16, OR_TMP0, 0);
gen_helper_lmsw(cpu_env, cpu_T0);
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
break;
CASE_MODRM_MEM_OP(7):
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
break;
}
gen_update_cc_op(s);
gen_jmp_im(pc_start - s->cs_base);
gen_lea_modrm(env, s, modrm);
gen_helper_invlpg(cpu_env, cpu_A0);
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
break;
case 0xf8:
#ifdef TARGET_X86_64
if (CODE64(s)) {
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
tcg_gen_mov_tl(cpu_T0, cpu_seg_base[R_GS]);
tcg_gen_ld_tl(cpu_seg_base[R_GS], cpu_env,
offsetof(CPUX86State, kernelgsbase));
tcg_gen_st_tl(cpu_T0, cpu_env,
offsetof(CPUX86State, kernelgsbase));
}
break;
}
#endif
goto illegal_op;
case 0xf9:
if (!(s->cpuid_ext2_features & CPUID_EXT2_RDTSCP)) {
goto illegal_op;
}
gen_update_cc_op(s);
gen_jmp_im(pc_start - s->cs_base);
if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) {
gen_io_start();
}
gen_helper_rdtscp(cpu_env);
if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) {
gen_io_end();
gen_jmp(s, s->pc - s->cs_base);
}
break;
default:
goto unknown_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;
modrm = x86_ldub_code(env, s);
reg = ((modrm >> 3) & 7) | rex_r;
mod = (modrm >> 6) & 3;
rm = (modrm & 7) | REX_B(s);
if (mod == 3) {
gen_op_mov_v_reg(MO_32, cpu_T0, rm);
if (d_ot == MO_64) {
tcg_gen_ext32s_tl(cpu_T0, cpu_T0);
}
gen_op_mov_reg_v(d_ot, reg, cpu_T0);
} else {
gen_lea_modrm(env, s, modrm);
gen_op_ld_v(s, MO_32 | MO_SIGN, cpu_T0, cpu_A0);
gen_op_mov_reg_v(d_ot, reg, cpu_T0);
}
} else
#endif
{
TCGLabel *label1;
TCGv t0, t1, t2, a0;
if (!s->pe || s->vm86)
goto illegal_op;
t0 = tcg_temp_local_new();
t1 = tcg_temp_local_new();
t2 = tcg_temp_local_new();
ot = MO_16;
modrm = x86_ldub_code(env, s);
reg = (modrm >> 3) & 7;
mod = (modrm >> 6) & 3;
rm = modrm & 7;
if (mod != 3) {
gen_lea_modrm(env, s, modrm);
gen_op_ld_v(s, ot, t0, cpu_A0);
a0 = tcg_temp_local_new();
tcg_gen_mov_tl(a0, cpu_A0);
} else {
gen_op_mov_v_reg(ot, t0, rm);
TCGV_UNUSED(a0);
}
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(s, ot, t0, a0);
tcg_temp_free(a0);
} else {
gen_op_mov_reg_v(ot, rm, t0);
}
gen_compute_eflags(s);
tcg_gen_andi_tl(cpu_cc_src, cpu_cc_src, ~CC_Z);
tcg_gen_or_tl(cpu_cc_src, cpu_cc_src, t2);
tcg_temp_free(t0);
tcg_temp_free(t1);
tcg_temp_free(t2);
}
break;
case 0x102:
case 0x103:
{
TCGLabel *label1;
TCGv t0;
if (!s->pe || s->vm86)
goto illegal_op;
ot = dflag != MO_16 ? MO_32 : MO_16;
modrm = x86_ldub_code(env, s);
reg = ((modrm >> 3) & 7) | rex_r;
gen_ldst_modrm(env, s, modrm, MO_16, OR_TMP0, 0);
t0 = tcg_temp_local_new();
gen_update_cc_op(s);
if (b == 0x102) {
gen_helper_lar(t0, cpu_env, cpu_T0);
} else {
gen_helper_lsl(t0, cpu_env, cpu_T0);
}
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);
set_cc_op(s, CC_OP_EFLAGS);
tcg_temp_free(t0);
}
break;
case 0x118:
modrm = x86_ldub_code(env, s);
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_nop_modrm(env, s, modrm);
break;
default:
gen_nop_modrm(env, s, modrm);
break;
}
break;
case 0x11a:
modrm = x86_ldub_code(env, s);
if (s->flags & HF_MPX_EN_MASK) {
mod = (modrm >> 6) & 3;
reg = ((modrm >> 3) & 7) | rex_r;
if (prefixes & PREFIX_REPZ) {
if (reg >= 4
|| (prefixes & PREFIX_LOCK)
|| s->aflag == MO_16) {
goto illegal_op;
}
gen_bndck(env, s, modrm, TCG_COND_LTU, cpu_bndl[reg]);
} else if (prefixes & PREFIX_REPNZ) {
if (reg >= 4
|| (prefixes & PREFIX_LOCK)
|| s->aflag == MO_16) {
goto illegal_op;
}
TCGv_i64 notu = tcg_temp_new_i64();
tcg_gen_not_i64(notu, cpu_bndu[reg]);
gen_bndck(env, s, modrm, TCG_COND_GTU, notu);
tcg_temp_free_i64(notu);
} else if (prefixes & PREFIX_DATA) {
if (reg >= 4 || s->aflag == MO_16) {
goto illegal_op;
}
if (mod == 3) {
int reg2 = (modrm & 7) | REX_B(s);
if (reg2 >= 4 || (prefixes & PREFIX_LOCK)) {
goto illegal_op;
}
if (s->flags & HF_MPX_IU_MASK) {
tcg_gen_mov_i64(cpu_bndl[reg], cpu_bndl[reg2]);
tcg_gen_mov_i64(cpu_bndu[reg], cpu_bndu[reg2]);
}
} else {
gen_lea_modrm(env, s, modrm);
if (CODE64(s)) {
tcg_gen_qemu_ld_i64(cpu_bndl[reg], cpu_A0,
s->mem_index, MO_LEQ);
tcg_gen_addi_tl(cpu_A0, cpu_A0, 8);
tcg_gen_qemu_ld_i64(cpu_bndu[reg], cpu_A0,
s->mem_index, MO_LEQ);
} else {
tcg_gen_qemu_ld_i64(cpu_bndl[reg], cpu_A0,
s->mem_index, MO_LEUL);
tcg_gen_addi_tl(cpu_A0, cpu_A0, 4);
tcg_gen_qemu_ld_i64(cpu_bndu[reg], cpu_A0,
s->mem_index, MO_LEUL);
}
gen_set_hflag(s, HF_MPX_IU_MASK);
}
} else if (mod != 3) {
AddressParts a = gen_lea_modrm_0(env, s, modrm);
if (reg >= 4
|| (prefixes & PREFIX_LOCK)
|| s->aflag == MO_16
|| a.base < -1) {
goto illegal_op;
}
if (a.base >= 0) {
tcg_gen_addi_tl(cpu_A0, cpu_regs[a.base], a.disp);
} else {
tcg_gen_movi_tl(cpu_A0, 0);
}
gen_lea_v_seg(s, s->aflag, cpu_A0, a.def_seg, s->override);
if (a.index >= 0) {
tcg_gen_mov_tl(cpu_T0, cpu_regs[a.index]);
} else {
tcg_gen_movi_tl(cpu_T0, 0);
}
if (CODE64(s)) {
gen_helper_bndldx64(cpu_bndl[reg], cpu_env, cpu_A0, cpu_T0);
tcg_gen_ld_i64(cpu_bndu[reg], cpu_env,
offsetof(CPUX86State, mmx_t0.MMX_Q(0)));
} else {
gen_helper_bndldx32(cpu_bndu[reg], cpu_env, cpu_A0, cpu_T0);
tcg_gen_ext32u_i64(cpu_bndl[reg], cpu_bndu[reg]);
tcg_gen_shri_i64(cpu_bndu[reg], cpu_bndu[reg], 32);
}
gen_set_hflag(s, HF_MPX_IU_MASK);
}
}
gen_nop_modrm(env, s, modrm);
break;
case 0x11b:
modrm = x86_ldub_code(env, s);
if (s->flags & HF_MPX_EN_MASK) {
mod = (modrm >> 6) & 3;
reg = ((modrm >> 3) & 7) | rex_r;
if (mod != 3 && (prefixes & PREFIX_REPZ)) {
if (reg >= 4
|| (prefixes & PREFIX_LOCK)
|| s->aflag == MO_16) {
goto illegal_op;
}
AddressParts a = gen_lea_modrm_0(env, s, modrm);
if (a.base >= 0) {
tcg_gen_extu_tl_i64(cpu_bndl[reg], cpu_regs[a.base]);
if (!CODE64(s)) {
tcg_gen_ext32u_i64(cpu_bndl[reg], cpu_bndl[reg]);
}
} else if (a.base == -1) {
tcg_gen_movi_i64(cpu_bndl[reg], 0);
} else {
goto illegal_op;
}
tcg_gen_not_tl(cpu_A0, gen_lea_modrm_1(a));
if (!CODE64(s)) {
tcg_gen_ext32u_tl(cpu_A0, cpu_A0);
}
tcg_gen_extu_tl_i64(cpu_bndu[reg], cpu_A0);
gen_set_hflag(s, HF_MPX_IU_MASK);
break;
} else if (prefixes & PREFIX_REPNZ) {
if (reg >= 4
|| (prefixes & PREFIX_LOCK)
|| s->aflag == MO_16) {
goto illegal_op;
}
gen_bndck(env, s, modrm, TCG_COND_GTU, cpu_bndu[reg]);
} else if (prefixes & PREFIX_DATA) {
if (reg >= 4 || s->aflag == MO_16) {
goto illegal_op;
}
if (mod == 3) {
int reg2 = (modrm & 7) | REX_B(s);
if (reg2 >= 4 || (prefixes & PREFIX_LOCK)) {
goto illegal_op;
}
if (s->flags & HF_MPX_IU_MASK) {
tcg_gen_mov_i64(cpu_bndl[reg2], cpu_bndl[reg]);
tcg_gen_mov_i64(cpu_bndu[reg2], cpu_bndu[reg]);
}
} else {
gen_lea_modrm(env, s, modrm);
if (CODE64(s)) {
tcg_gen_qemu_st_i64(cpu_bndl[reg], cpu_A0,
s->mem_index, MO_LEQ);
tcg_gen_addi_tl(cpu_A0, cpu_A0, 8);
tcg_gen_qemu_st_i64(cpu_bndu[reg], cpu_A0,
s->mem_index, MO_LEQ);
} else {
tcg_gen_qemu_st_i64(cpu_bndl[reg], cpu_A0,
s->mem_index, MO_LEUL);
tcg_gen_addi_tl(cpu_A0, cpu_A0, 4);
tcg_gen_qemu_st_i64(cpu_bndu[reg], cpu_A0,
s->mem_index, MO_LEUL);
}
}
} else if (mod != 3) {
AddressParts a = gen_lea_modrm_0(env, s, modrm);
if (reg >= 4
|| (prefixes & PREFIX_LOCK)
|| s->aflag == MO_16
|| a.base < -1) {
goto illegal_op;
}
if (a.base >= 0) {
tcg_gen_addi_tl(cpu_A0, cpu_regs[a.base], a.disp);
} else {
tcg_gen_movi_tl(cpu_A0, 0);
}
gen_lea_v_seg(s, s->aflag, cpu_A0, a.def_seg, s->override);
if (a.index >= 0) {
tcg_gen_mov_tl(cpu_T0, cpu_regs[a.index]);
} else {
tcg_gen_movi_tl(cpu_T0, 0);
}
if (CODE64(s)) {
gen_helper_bndstx64(cpu_env, cpu_A0, cpu_T0,
cpu_bndl[reg], cpu_bndu[reg]);
} else {
gen_helper_bndstx32(cpu_env, cpu_A0, cpu_T0,
cpu_bndl[reg], cpu_bndu[reg]);
}
}
}
gen_nop_modrm(env, s, modrm);
break;
case 0x119: case 0x11c ... 0x11f:
modrm = x86_ldub_code(env, s);
gen_nop_modrm(env, s, modrm);
break;
case 0x120:
case 0x122:
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
modrm = x86_ldub_code(env, s);
rm = (modrm & 7) | REX_B(s);
reg = ((modrm >> 3) & 7) | rex_r;
if (CODE64(s))
ot = MO_64;
else
ot = MO_32;
if ((prefixes & PREFIX_LOCK) && (reg == 0) &&
(s->cpuid_ext3_features & CPUID_EXT3_CR8LEG)) {
reg = 8;
}
switch(reg) {
case 0:
case 2:
case 3:
case 4:
case 8:
gen_update_cc_op(s);
gen_jmp_im(pc_start - s->cs_base);
if (b & 2) {
if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) {
gen_io_start();
}
gen_op_mov_v_reg(ot, cpu_T0, rm);
gen_helper_write_crN(cpu_env, tcg_const_i32(reg),
cpu_T0);
if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) {
gen_io_end();
}
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
} else {
if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) {
gen_io_start();
}
gen_helper_read_crN(cpu_T0, cpu_env, tcg_const_i32(reg));
gen_op_mov_reg_v(ot, rm, cpu_T0);
if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) {
gen_io_end();
}
}
break;
default:
goto unknown_op;
}
}
break;
case 0x121:
case 0x123:
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
modrm = x86_ldub_code(env, s);
rm = (modrm & 7) | REX_B(s);
reg = ((modrm >> 3) & 7) | rex_r;
if (CODE64(s))
ot = MO_64;
else
ot = MO_32;
if (reg >= 8) {
goto illegal_op;
}
if (b & 2) {
gen_svm_check_intercept(s, pc_start, SVM_EXIT_WRITE_DR0 + reg);
gen_op_mov_v_reg(ot, cpu_T0, rm);
tcg_gen_movi_i32(cpu_tmp2_i32, reg);
gen_helper_set_dr(cpu_env, cpu_tmp2_i32, cpu_T0);
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_movi_i32(cpu_tmp2_i32, reg);
gen_helper_get_dr(cpu_T0, cpu_env, cpu_tmp2_i32);
gen_op_mov_reg_v(ot, rm, cpu_T0);
}
}
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(cpu_env);
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
}
break;
case 0x1c3:
if (!(s->cpuid_features & CPUID_SSE2))
goto illegal_op;
ot = mo_64_32(dflag);
modrm = x86_ldub_code(env, s);
mod = (modrm >> 6) & 3;
if (mod == 3)
goto illegal_op;
reg = ((modrm >> 3) & 7) | rex_r;
gen_ldst_modrm(env, s, modrm, ot, reg, 1);
break;
case 0x1ae:
modrm = x86_ldub_code(env, s);
switch (modrm) {
CASE_MODRM_MEM_OP(0):
if (!(s->cpuid_features & CPUID_FXSR)
|| (prefixes & PREFIX_LOCK)) {
goto illegal_op;
}
if ((s->flags & HF_EM_MASK) || (s->flags & HF_TS_MASK)) {
gen_exception(s, EXCP07_PREX, pc_start - s->cs_base);
break;
}
gen_lea_modrm(env, s, modrm);
gen_helper_fxsave(cpu_env, cpu_A0);
break;
CASE_MODRM_MEM_OP(1):
if (!(s->cpuid_features & CPUID_FXSR)
|| (prefixes & PREFIX_LOCK)) {
goto illegal_op;
}
if ((s->flags & HF_EM_MASK) || (s->flags & HF_TS_MASK)) {
gen_exception(s, EXCP07_PREX, pc_start - s->cs_base);
break;
}
gen_lea_modrm(env, s, modrm);
gen_helper_fxrstor(cpu_env, cpu_A0);
break;
CASE_MODRM_MEM_OP(2):
if ((s->flags & HF_EM_MASK) || !(s->flags & HF_OSFXSR_MASK)) {
goto illegal_op;
}
if (s->flags & HF_TS_MASK) {
gen_exception(s, EXCP07_PREX, pc_start - s->cs_base);
break;
}
gen_lea_modrm(env, s, modrm);
tcg_gen_qemu_ld_i32(cpu_tmp2_i32, cpu_A0, s->mem_index, MO_LEUL);
gen_helper_ldmxcsr(cpu_env, cpu_tmp2_i32);
break;
CASE_MODRM_MEM_OP(3):
if ((s->flags & HF_EM_MASK) || !(s->flags & HF_OSFXSR_MASK)) {
goto illegal_op;
}
if (s->flags & HF_TS_MASK) {
gen_exception(s, EXCP07_PREX, pc_start - s->cs_base);
break;
}
gen_lea_modrm(env, s, modrm);
tcg_gen_ld32u_tl(cpu_T0, cpu_env, offsetof(CPUX86State, mxcsr));
gen_op_st_v(s, MO_32, cpu_T0, cpu_A0);
break;
CASE_MODRM_MEM_OP(4):
if ((s->cpuid_ext_features & CPUID_EXT_XSAVE) == 0
|| (prefixes & (PREFIX_LOCK | PREFIX_DATA
| PREFIX_REPZ | PREFIX_REPNZ))) {
goto illegal_op;
}
gen_lea_modrm(env, s, modrm);
tcg_gen_concat_tl_i64(cpu_tmp1_i64, cpu_regs[R_EAX],
cpu_regs[R_EDX]);
gen_helper_xsave(cpu_env, cpu_A0, cpu_tmp1_i64);
break;
CASE_MODRM_MEM_OP(5):
if ((s->cpuid_ext_features & CPUID_EXT_XSAVE) == 0
|| (prefixes & (PREFIX_LOCK | PREFIX_DATA
| PREFIX_REPZ | PREFIX_REPNZ))) {
goto illegal_op;
}
gen_lea_modrm(env, s, modrm);
tcg_gen_concat_tl_i64(cpu_tmp1_i64, cpu_regs[R_EAX],
cpu_regs[R_EDX]);
gen_helper_xrstor(cpu_env, cpu_A0, cpu_tmp1_i64);
gen_update_cc_op(s);
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
break;
CASE_MODRM_MEM_OP(6):
if (prefixes & PREFIX_LOCK) {
goto illegal_op;
}
if (prefixes & PREFIX_DATA) {
if (!(s->cpuid_7_0_ebx_features & CPUID_7_0_EBX_CLWB)) {
goto illegal_op;
}
gen_nop_modrm(env, s, modrm);
} else {
if ((s->cpuid_ext_features & CPUID_EXT_XSAVE) == 0
|| (s->cpuid_xsave_features & CPUID_XSAVE_XSAVEOPT) == 0
|| (prefixes & (PREFIX_REPZ | PREFIX_REPNZ))) {
goto illegal_op;
}
gen_lea_modrm(env, s, modrm);
tcg_gen_concat_tl_i64(cpu_tmp1_i64, cpu_regs[R_EAX],
cpu_regs[R_EDX]);
gen_helper_xsaveopt(cpu_env, cpu_A0, cpu_tmp1_i64);
}
break;
CASE_MODRM_MEM_OP(7):
if (prefixes & PREFIX_LOCK) {
goto illegal_op;
}
if (prefixes & PREFIX_DATA) {
if (!(s->cpuid_7_0_ebx_features & CPUID_7_0_EBX_CLFLUSHOPT)) {
goto illegal_op;
}
} else {
if ((s->prefix & (PREFIX_REPZ | PREFIX_REPNZ))
|| !(s->cpuid_features & CPUID_CLFLUSH)) {
goto illegal_op;
}
}
gen_nop_modrm(env, s, modrm);
break;
case 0xc0 ... 0xc7:
case 0xc8 ... 0xcf:
case 0xd0 ... 0xd7:
case 0xd8 ... 0xdf:
if (CODE64(s)
&& (prefixes & PREFIX_REPZ)
&& !(prefixes & PREFIX_LOCK)
&& (s->cpuid_7_0_ebx_features & CPUID_7_0_EBX_FSGSBASE)) {
TCGv base, treg, src, dst;
tcg_gen_movi_i32(cpu_tmp2_i32, CR4_FSGSBASE_MASK);
gen_helper_cr4_testbit(cpu_env, cpu_tmp2_i32);
base = cpu_seg_base[modrm & 8 ? R_GS : R_FS];
treg = cpu_regs[(modrm & 7) | REX_B(s)];
if (modrm & 0x10) {
dst = base, src = treg;
} else {
dst = treg, src = base;
}
if (s->dflag == MO_32) {
tcg_gen_ext32u_tl(dst, src);
} else {
tcg_gen_mov_tl(dst, src);
}
break;
}
goto unknown_op;
case 0xf8:
if (prefixes & PREFIX_DATA) {
if (!(s->cpuid_7_0_ebx_features & CPUID_7_0_EBX_PCOMMIT)
|| (prefixes & PREFIX_LOCK)) {
goto illegal_op;
}
break;
}
case 0xf9 ... 0xff:
if (!(s->cpuid_features & CPUID_SSE)
|| (prefixes & PREFIX_LOCK)) {
goto illegal_op;
}
tcg_gen_mb(TCG_MO_ST_ST | TCG_BAR_SC);
break;
case 0xe8 ... 0xef:
if (!(s->cpuid_features & CPUID_SSE)
|| (prefixes & PREFIX_LOCK)) {
goto illegal_op;
}
tcg_gen_mb(TCG_MO_LD_LD | TCG_BAR_SC);
break;
case 0xf0 ... 0xf7:
if (!(s->cpuid_features & CPUID_SSE2)
|| (prefixes & PREFIX_LOCK)) {
goto illegal_op;
}
tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC);
break;
default:
goto unknown_op;
}
break;
case 0x10d:
modrm = x86_ldub_code(env, s);
mod = (modrm >> 6) & 3;
if (mod == 3)
goto illegal_op;
gen_nop_modrm(env, s, modrm);
break;
case 0x1aa:
gen_svm_check_intercept(s, pc_start, SVM_EXIT_RSM);
if (!(s->flags & HF_SMM_MASK))
goto illegal_op;
gen_update_cc_op(s);
gen_jmp_im(s->pc - s->cs_base);
gen_helper_rsm(cpu_env);
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 = x86_ldub_code(env, s);
reg = ((modrm >> 3) & 7) | rex_r;
if (s->prefix & PREFIX_DATA) {
ot = MO_16;
} else {
ot = mo_64_32(dflag);
}
gen_ldst_modrm(env, s, modrm, ot, OR_TMP0, 0);
gen_extu(ot, cpu_T0);
tcg_gen_mov_tl(cpu_cc_src, cpu_T0);
tcg_gen_ctpop_tl(cpu_T0, cpu_T0);
gen_op_mov_reg_v(ot, reg, cpu_T0);
set_cc_op(s, CC_OP_POPCNT);
break;
case 0x10e ... 0x10f:
s->prefix &= ~(PREFIX_REPZ | PREFIX_REPNZ | PREFIX_DATA);
case 0x110 ... 0x117:
case 0x128 ... 0x12f:
case 0x138 ... 0x13a:
case 0x150 ... 0x179:
case 0x17c ... 0x17f:
case 0x1c2:
case 0x1c4 ... 0x1c6:
case 0x1d0 ... 0x1fe:
gen_sse(env, s, b, pc_start, rex_r);
break;
default:
goto unknown_op;
}
return s->pc;
illegal_op:
gen_illegal_opcode(s);
return s->pc;
unknown_op:
gen_unknown_opcode(env, s);
return s->pc;
}
| 1threat |
ngrok speed became slow : <p>Ive been using <a href="https://ngrok.com/" rel="noreferrer">ngrok</a> to test an app on my phone, with react-native for the past 2 weeks. And so far its been pretty decent and quick. </p>
<p>Until today.
Now it suddenly takes about 50 seconds for a request to make a roundtrip from my phone, to my localhost and back. Or from my browser, to the ngrok tunnel, back to my localhost.</p>
<p>At first I thought, ok ngrok is either down or experiencing slowdowns. But then I decided to hit it with Postman, and with that the request is fast. Around 0.5 seconds. Same when I access the tunnel stats. A replay request is like 1second. </p>
<p>Just when I do it over my phone, or browser its now extremely slow.
Is there any specific reason this may suddenly be occuring?
Can anyone shed any light on where I should even begin looking?</p>
<p>I've tried rebooting, and flushing DNS, to no avail.</p>
| 0debug |
static int kvm_get_fpu(CPUState *env)
{
struct kvm_fpu fpu;
int i, ret;
ret = kvm_vcpu_ioctl(env, KVM_GET_FPU, &fpu);
if (ret < 0)
return ret;
env->fpstt = (fpu.fsw >> 11) & 7;
env->fpus = fpu.fsw;
env->fpuc = fpu.fcw;
for (i = 0; i < 8; ++i)
env->fptags[i] = !((fpu.ftwx >> i) & 1);
memcpy(env->fpregs, fpu.fpr, sizeof env->fpregs);
memcpy(env->xmm_regs, fpu.xmm, sizeof env->xmm_regs);
env->mxcsr = fpu.mxcsr;
return 0;
}
| 1threat |
static void virtio_balloon_to_target(void *opaque, ram_addr_t target,
MonitorCompletion cb, void *cb_data)
{
VirtIOBalloon *dev = opaque;
if (target > ram_size) {
target = ram_size;
}
if (target) {
dev->num_pages = (ram_size - target) >> VIRTIO_BALLOON_PFN_SHIFT;
virtio_notify_config(&dev->vdev);
} else {
virtio_balloon_stat(opaque, cb, cb_data);
}
}
| 1threat |
Why Do We Extend Application Class In Android : <p>Why do we extend application class. Android apps run properly even without extending it.</p>
<p>Can anyone explain this scenario as why exactly do we extend it.</p>
<p>For Example:</p>
<pre><code>public class MyApp extends Application {
private static MyApp app;
private ImageDownloaderComponent imageDownloaderComponent;
@Override
public void onCreate() {
super.onCreate();
app = this;
imageDownloaderComponent = DaggerImageDownloaderComponent.builder().imageDownloaderModule(new ImageDownloaderModule(this)).build();
}
}
</code></pre>
| 0debug |
static int bayer_to_yv12_wrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dst[], int dstStride[])
{
const uint8_t *srcPtr= src[0];
uint8_t *dstY= dst[0];
uint8_t *dstU= dst[1];
uint8_t *dstV= dst[2];
int i;
void (*copy) (const uint8_t *src, int src_stride, uint8_t *dstY, uint8_t *dstU, uint8_t *dstV, int luma_stride, int width, int32_t *rgb2yuv);
void (*interpolate)(const uint8_t *src, int src_stride, uint8_t *dstY, uint8_t *dstU, uint8_t *dstV, int luma_stride, int width, int32_t *rgb2yuv);
switch(c->srcFormat) {
#define CASE(pixfmt, prefix) \
case pixfmt: copy = bayer_##prefix##_to_yv12_copy; \
interpolate = bayer_##prefix##_to_yv12_interpolate; \
break;
CASE(AV_PIX_FMT_BAYER_BGGR8, bggr8)
CASE(AV_PIX_FMT_BAYER_BGGR16LE, bggr16le)
CASE(AV_PIX_FMT_BAYER_BGGR16BE, bggr16be)
CASE(AV_PIX_FMT_BAYER_RGGB8, rggb8)
CASE(AV_PIX_FMT_BAYER_RGGB16LE, rggb16le)
CASE(AV_PIX_FMT_BAYER_RGGB16BE, rggb16be)
CASE(AV_PIX_FMT_BAYER_GBRG8, gbrg8)
CASE(AV_PIX_FMT_BAYER_GBRG16LE, gbrg16le)
CASE(AV_PIX_FMT_BAYER_GBRG16BE, gbrg16be)
CASE(AV_PIX_FMT_BAYER_GRBG8, grbg8)
CASE(AV_PIX_FMT_BAYER_GRBG16LE, grbg16le)
CASE(AV_PIX_FMT_BAYER_GRBG16BE, grbg16be)
#undef CASE
default: return 0;
}
copy(srcPtr, srcStride[0], dstY, dstU, dstV, dstStride[0], c->srcW, c->input_rgb2yuv_table);
srcPtr += 2 * srcStride[0];
dstY += 2 * dstStride[0];
dstU += dstStride[1];
dstV += dstStride[1];
for (i = 2; i < srcSliceH - 2; i += 2) {
interpolate(srcPtr, srcStride[0], dstY, dstU, dstV, dstStride[0], c->srcW, c->input_rgb2yuv_table);
srcPtr += 2 * srcStride[0];
dstY += 2 * dstStride[0];
dstU += dstStride[1];
dstV += dstStride[1];
}
copy(srcPtr, srcStride[0], dstY, dstU, dstV, dstStride[0], c->srcW, c->input_rgb2yuv_table);
return srcSliceH;
}
| 1threat |
Servlet with Mysql database : I have the following Servlet code with mysql database.I have written
query for displaying source to destination cost that will be
retrieved from database.But how to write a query that will return same cost when i reverse my source and destination in the select box?
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class Test3
*/
@WebServlet("/Test3")
public class Test3 extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException
{
RequestDispatcher rd = request.getRequestDispatcher("source.jsp");
rd.include(request, response);
try
{
Class.forName("com.mysql.jdbc.Driver");
//conn code//
Statement stmt=(Statement)con.createStatement();
PrintWriter out=response.getWriter();
String name=request.getParameter("sel");
String name1=request.getParameter("sel1");
String sql="select * from USER where (source='"+name+"' AND
destination='"+name1+"')";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next())
{
out.println("<br>");
out.println(rs.getString("source"));
out.println(rs.getString("destination"));
out.println("<br>");
out.println("Cost:"+rs.getInt("cost"));
}
//method may be include or forward
}
catch(Exception e)
{
System.out.println("Error:"+e.getMessage());
}
}
}
| 0debug |
to many IF how to make quicker search c# : <p>Have 5 Names and 5 number.
Giv name need number.
better way?</p>
<pre><code> string name = "Mark";
int x;
if(name == "John")
{
x = 1;
}else if(name == "Jimy"){
x = 2;
}else if(name == "Mark"){
x = 3;
}.... etc
return x;
</code></pre>
<p>result is x=3.</p>
| 0debug |
Best way to add "display: flex" to flexslider2 [wordpress plugin] slide? : <p>I want to add "display: flex" to flexslider2 slides but the plugin's javascript sets the slides to "display: block" so I can't just declare that in my wp theme stylesheet because the javascript's style declarations take precedence over the stylesheet's. I <strong><em>can</em></strong> go in and change the lines of code in the flexslider.js that but then I run into the trouble of having those lines overwritten when the wordpress plugin gets updated. So, what's the best way to override javascript css? Should I even be using the flexslider plugin? Is there a better way to use jquery/js to create a slider that I can use flex properties on? It seemed the cleanest and easiest slider plugin to implement as a featured posts slider in wp. Thanks for your help.</p>
| 0debug |
void ff_MPV_encode_init_x86(MpegEncContext *s)
{
int mm_flags = av_get_cpu_flags();
const int dct_algo = s->avctx->dct_algo;
if (dct_algo == FF_DCT_AUTO || dct_algo == FF_DCT_MMX) {
#if HAVE_MMX_INLINE
if (mm_flags & AV_CPU_FLAG_MMX && HAVE_MMX)
s->dct_quantize = dct_quantize_MMX;
#endif
#if HAVE_MMXEXT_INLINE
if (mm_flags & AV_CPU_FLAG_MMXEXT && HAVE_MMXEXT)
s->dct_quantize = dct_quantize_MMX2;
#endif
#if HAVE_SSE2_INLINE
if (mm_flags & AV_CPU_FLAG_SSE2 && HAVE_SSE2)
s->dct_quantize = dct_quantize_SSE2;
#endif
#if HAVE_SSSE3_INLINE
if (mm_flags & AV_CPU_FLAG_SSSE3)
s->dct_quantize = dct_quantize_SSSE3;
#endif
}
}
| 1threat |
Running an uber jar from sbt assembly results in error: Could not find or load main class : <p>I have a spark job packaged as an uber-jar using the sbt assembly plugin.
The <code>build.sbt</code> specifies a runnable main to be the target of the resulting uber-jar</p>
<pre><code>mainClass in assembly := Some("com.foo.Bar")
</code></pre>
<p>After the assembly is correctly created, running the intended command:</p>
<pre><code>java -jar assembly.jar
</code></pre>
<p>results in</p>
<blockquote>
<p>Error: Could not find or load main class com.foo.Bar</p>
</blockquote>
<p>Using the an alternative method, like <code>java -cp assembly.jar com.foo.Bar</code> gives the same error message.</p>
<p>Then, I extracted the contents of the uber-jar in a new directory. I can see my <code>com/foo/</code> directory and the <code>Bar.class</code> file.
From the root of the extracted directory I tried:</p>
<pre><code>java -cp . com.foo.Bar
</code></pre>
<p>and I get a correct result.</p>
<p>Further trying to find the reason of the error, I tried:</p>
<pre><code>java -verbose -jar assembly.jar
</code></pre>
<p>I can see the java core classes being loaded, but I don't see any of my packaged classes being loaded.</p>
<p>What can possibly be wrong here?</p>
| 0debug |
static int pic_arrays_init(HEVCContext *s)
{
int log2_min_cb_size = s->sps->log2_min_cb_size;
int width = s->sps->width;
int height = s->sps->height;
int pic_size = width * height;
int pic_size_in_ctb = ((width >> log2_min_cb_size) + 1) *
((height >> log2_min_cb_size) + 1);
int ctb_count = s->sps->ctb_width * s->sps->ctb_height;
int min_pu_width = width >> s->sps->log2_min_pu_size;
int pic_height_in_min_pu = height >> s->sps->log2_min_pu_size;
int pic_size_in_min_pu = min_pu_width * pic_height_in_min_pu;
int pic_width_in_min_tu = width >> s->sps->log2_min_tb_size;
int pic_height_in_min_tu = height >> s->sps->log2_min_tb_size;
s->bs_width = width >> 3;
s->bs_height = height >> 3;
s->sao = av_mallocz_array(ctb_count, sizeof(*s->sao));
s->deblock = av_mallocz_array(ctb_count, sizeof(*s->deblock));
s->split_cu_flag = av_malloc(pic_size);
if (!s->sao || !s->deblock || !s->split_cu_flag)
goto fail;
s->skip_flag = av_malloc(pic_size_in_ctb);
s->tab_ct_depth = av_malloc(s->sps->min_cb_height * s->sps->min_cb_width);
if (!s->skip_flag || !s->tab_ct_depth)
goto fail;
s->tab_ipm = av_malloc(pic_size_in_min_pu);
s->cbf_luma = av_malloc(pic_width_in_min_tu * pic_height_in_min_tu);
s->is_pcm = av_malloc(pic_size_in_min_pu);
if (!s->tab_ipm || !s->cbf_luma || !s->is_pcm)
goto fail;
s->filter_slice_edges = av_malloc(ctb_count);
s->tab_slice_address = av_malloc(pic_size_in_ctb * sizeof(*s->tab_slice_address));
s->qp_y_tab = av_malloc(pic_size_in_ctb * sizeof(*s->qp_y_tab));
if (!s->qp_y_tab || !s->filter_slice_edges || !s->tab_slice_address)
goto fail;
s->horizontal_bs = av_mallocz(2 * s->bs_width * (s->bs_height + 1));
s->vertical_bs = av_mallocz(2 * s->bs_width * (s->bs_height + 1));
if (!s->horizontal_bs || !s->vertical_bs)
goto fail;
s->tab_mvf_pool = av_buffer_pool_init(pic_size_in_min_pu * sizeof(MvField),
av_buffer_alloc);
s->rpl_tab_pool = av_buffer_pool_init(ctb_count * sizeof(RefPicListTab),
av_buffer_allocz);
if (!s->tab_mvf_pool || !s->rpl_tab_pool)
goto fail;
return 0;
fail:
pic_arrays_free(s);
return AVERROR(ENOMEM);
}
| 1threat |
av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx)
{
MpegEncContext *s = avctx->priv_data;
static int done = 0;
int i;
MVTable *mv;
ff_h263_decode_init(avctx);
common_init(s);
if (!done) {
done = 1;
for(i=0;i<NB_RL_TABLES;i++) {
init_rl(&rl_table[i], static_rl_table_store[i]);
}
INIT_VLC_RL(rl_table[0], 642);
INIT_VLC_RL(rl_table[1], 1104);
INIT_VLC_RL(rl_table[2], 554);
INIT_VLC_RL(rl_table[3], 940);
INIT_VLC_RL(rl_table[4], 962);
INIT_VLC_RL(rl_table[5], 554);
mv = &mv_tables[0];
INIT_VLC_STATIC(&mv->vlc, MV_VLC_BITS, mv->n + 1,
mv->table_mv_bits, 1, 1,
mv->table_mv_code, 2, 2, 3714);
mv = &mv_tables[1];
INIT_VLC_STATIC(&mv->vlc, MV_VLC_BITS, mv->n + 1,
mv->table_mv_bits, 1, 1,
mv->table_mv_code, 2, 2, 2694);
INIT_VLC_STATIC(&ff_msmp4_dc_luma_vlc[0], DC_VLC_BITS, 120,
&ff_table0_dc_lum[0][1], 8, 4,
&ff_table0_dc_lum[0][0], 8, 4, 1158);
INIT_VLC_STATIC(&ff_msmp4_dc_chroma_vlc[0], DC_VLC_BITS, 120,
&ff_table0_dc_chroma[0][1], 8, 4,
&ff_table0_dc_chroma[0][0], 8, 4, 1118);
INIT_VLC_STATIC(&ff_msmp4_dc_luma_vlc[1], DC_VLC_BITS, 120,
&ff_table1_dc_lum[0][1], 8, 4,
&ff_table1_dc_lum[0][0], 8, 4, 1476);
INIT_VLC_STATIC(&ff_msmp4_dc_chroma_vlc[1], DC_VLC_BITS, 120,
&ff_table1_dc_chroma[0][1], 8, 4,
&ff_table1_dc_chroma[0][0], 8, 4, 1216);
INIT_VLC_STATIC(&v2_dc_lum_vlc, DC_VLC_BITS, 512,
&v2_dc_lum_table[0][1], 8, 4,
&v2_dc_lum_table[0][0], 8, 4, 1472);
INIT_VLC_STATIC(&v2_dc_chroma_vlc, DC_VLC_BITS, 512,
&v2_dc_chroma_table[0][1], 8, 4,
&v2_dc_chroma_table[0][0], 8, 4, 1506);
INIT_VLC_STATIC(&v2_intra_cbpc_vlc, V2_INTRA_CBPC_VLC_BITS, 4,
&v2_intra_cbpc[0][1], 2, 1,
&v2_intra_cbpc[0][0], 2, 1, 8);
INIT_VLC_STATIC(&v2_mb_type_vlc, V2_MB_TYPE_VLC_BITS, 8,
&v2_mb_type[0][1], 2, 1,
&v2_mb_type[0][0], 2, 1, 128);
INIT_VLC_STATIC(&v2_mv_vlc, V2_MV_VLC_BITS, 33,
&mvtab[0][1], 2, 1,
&mvtab[0][0], 2, 1, 538);
INIT_VLC_STATIC(&ff_mb_non_intra_vlc[0], MB_NON_INTRA_VLC_BITS, 128,
&wmv2_inter_table[0][0][1], 8, 4,
&wmv2_inter_table[0][0][0], 8, 4, 1636);
INIT_VLC_STATIC(&ff_mb_non_intra_vlc[1], MB_NON_INTRA_VLC_BITS, 128,
&wmv2_inter_table[1][0][1], 8, 4,
&wmv2_inter_table[1][0][0], 8, 4, 2648);
INIT_VLC_STATIC(&ff_mb_non_intra_vlc[2], MB_NON_INTRA_VLC_BITS, 128,
&wmv2_inter_table[2][0][1], 8, 4,
&wmv2_inter_table[2][0][0], 8, 4, 1532);
INIT_VLC_STATIC(&ff_mb_non_intra_vlc[3], MB_NON_INTRA_VLC_BITS, 128,
&wmv2_inter_table[3][0][1], 8, 4,
&wmv2_inter_table[3][0][0], 8, 4, 2488);
INIT_VLC_STATIC(&ff_msmp4_mb_i_vlc, MB_INTRA_VLC_BITS, 64,
&ff_msmp4_mb_i_table[0][1], 4, 2,
&ff_msmp4_mb_i_table[0][0], 4, 2, 536);
INIT_VLC_STATIC(&ff_inter_intra_vlc, INTER_INTRA_VLC_BITS, 4,
&table_inter_intra[0][1], 2, 1,
&table_inter_intra[0][0], 2, 1, 8);
}
switch(s->msmpeg4_version){
case 1:
case 2:
s->decode_mb= msmpeg4v12_decode_mb;
break;
case 3:
case 4:
s->decode_mb= msmpeg4v34_decode_mb;
break;
case 5:
if (CONFIG_WMV2_DECODER)
s->decode_mb= ff_wmv2_decode_mb;
case 6:
break;
}
s->slice_height= s->mb_height;
return 0;
}
| 1threat |
How to stop IntelliJ IDEA from expanding the "External Libraries" with "Autoscroll from Source" enabled? : <p>I'm using IntelliJ with Java and the "Autoscroll from Source" function enabled.</p>
<p>I like when the IDE jumps to the class in the package list, but it will also expand the "External Liubraries" making the whole "Project" view pretty messy.</p>
<p>Is there a way to stop IntelliJ from expanding External Libraries?</p>
| 0debug |
static int alloc_picture(H264Context *h, Picture *pic)
{
int i, ret = 0;
av_assert0(!pic->f.data[0]);
if (h->avctx->hwaccel) {
const AVHWAccel *hwaccel = h->avctx->hwaccel;
av_assert0(!pic->hwaccel_picture_private);
if (hwaccel->priv_data_size) {
pic->hwaccel_priv_buf = av_buffer_allocz(hwaccel->priv_data_size);
if (!pic->hwaccel_priv_buf)
return AVERROR(ENOMEM);
pic->hwaccel_picture_private = pic->hwaccel_priv_buf->data;
}
}
pic->tf.f = &pic->f;
ret = ff_thread_get_buffer(h->avctx, &pic->tf, pic->reference ?
AV_GET_BUFFER_FLAG_REF : 0);
if (ret < 0)
goto fail;
h->linesize = pic->f.linesize[0];
h->uvlinesize = pic->f.linesize[1];
if (!h->qscale_table_pool) {
ret = init_table_pools(h);
if (ret < 0)
goto fail;
}
pic->qscale_table_buf = av_buffer_pool_get(h->qscale_table_pool);
pic->mb_type_buf = av_buffer_pool_get(h->mb_type_pool);
if (!pic->qscale_table_buf || !pic->mb_type_buf)
goto fail;
pic->mb_type = (uint32_t*)pic->mb_type_buf->data + 2 * h->mb_stride + 1;
pic->qscale_table = pic->qscale_table_buf->data + 2 * h->mb_stride + 1;
for (i = 0; i < 2; i++) {
pic->motion_val_buf[i] = av_buffer_pool_get(h->motion_val_pool);
pic->ref_index_buf[i] = av_buffer_pool_get(h->ref_index_pool);
if (!pic->motion_val_buf[i] || !pic->ref_index_buf[i])
goto fail;
pic->motion_val[i] = (int16_t (*)[2])pic->motion_val_buf[i]->data + 4;
pic->ref_index[i] = pic->ref_index_buf[i]->data;
}
return 0;
fail:
unref_picture(h, pic);
return (ret < 0) ? ret : AVERROR(ENOMEM);
}
| 1threat |
static void vp5_parse_coeff_models(VP56Context *s)
{
VP56RangeCoder *c = &s->c;
VP56Model *model = s->modelp;
uint8_t def_prob[11];
int node, cg, ctx;
int ct;
int pt;
memset(def_prob, 0x80, sizeof(def_prob));
for (pt=0; pt<2; pt++)
for (node=0; node<11; node++)
if (vp56_rac_get_prob(c, vp5_dccv_pct[pt][node])) {
def_prob[node] = vp56_rac_gets_nn(c, 7);
model->coeff_dccv[pt][node] = def_prob[node];
} else if (s->framep[VP56_FRAME_CURRENT]->key_frame) {
model->coeff_dccv[pt][node] = def_prob[node];
}
for (ct=0; ct<3; ct++)
for (pt=0; pt<2; pt++)
for (cg=0; cg<6; cg++)
for (node=0; node<11; node++)
if (vp56_rac_get_prob(c, vp5_ract_pct[ct][pt][cg][node])) {
def_prob[node] = vp56_rac_gets_nn(c, 7);
model->coeff_ract[pt][ct][cg][node] = def_prob[node];
} else if (s->framep[VP56_FRAME_CURRENT]->key_frame) {
model->coeff_ract[pt][ct][cg][node] = def_prob[node];
}
for (pt=0; pt<2; pt++)
for (ctx=0; ctx<36; ctx++)
for (node=0; node<5; node++)
model->coeff_dcct[pt][ctx][node] = av_clip(((model->coeff_dccv[pt][node] * vp5_dccv_lc[node][ctx][0] + 128) >> 8) + vp5_dccv_lc[node][ctx][1], 1, 254);
for (ct=0; ct<3; ct++)
for (pt=0; pt<2; pt++)
for (cg=0; cg<3; cg++)
for (ctx=0; ctx<6; ctx++)
for (node=0; node<5; node++)
model->coeff_acct[pt][ct][cg][ctx][node] = av_clip(((model->coeff_ract[pt][ct][cg][node] * vp5_ract_lc[ct][cg][node][ctx][0] + 128) >> 8) + vp5_ract_lc[ct][cg][node][ctx][1], 1, 254);
}
| 1threat |
why it's impossible to sort a string just like a sorting of a c++ array? : <p>can't we sort a string just like a classical sorting(bubble sort or something..) of an array?I tried. But it's not working.</p>
<pre><code>string newstr = "dcba";
for(int i = 0; i < (newstr.size())-1; i++)
{
for(int k = i+1; k < newstr.size(); k++)
{
if(newstr[i] > newstr[k])
{
temp = newstr[i];
newstr[k] = newstr[i];
newstr[i] = temp;
}
}
}
</code></pre>
| 0debug |
If i am getting 1 TB of data daily basis what would be my cluster size in hadoop : <p>Cloud era distribution Cloud computing Amazon Web Services What should be the EC2 type of instance</p>
| 0debug |
I have Error in c++ when i write my code say : Error 1 error C2601: 'circle' : local function definitions are illegal : **i have problem inn c++ when i write this code
the vs say error C2601: 'circle' : local function definitions are illegal**
*how can find solution for the problem*
#include < iostream >
using namespace std;
int main() {
char grade;
cout << "enter grade : ";
cin >> grade;
switch (grade) {
case 'A':
void circle(float &, float &, float);
{
float r, a, c;
cout << "enter radius:";
cin >> r;
circle(a, c, r);
cout << "area=" << a << "\t" << "circumference=" << c << endl;
return 0;
}
void circle(float & area, float & circumference, float r)
{
const double pi = 3.14159;
area = pi * r * r;
circumference = 2 * pi * r;
}
break;
default:
cout << "Invalid grade" << endl;
}
cout << "Your grade is " << grade << endl;
return 0;
} | 0debug |
Search button value/id and addclass/changecolor : how can i search for a button id/value using jquery, if textbox = button value, addclass to it, dynamically since the button and their ID's are inside database and looped to display | 0debug |
How to access JSON nested objects with ruby? : <p>so I have a JSON file that is made of nested objects that follow the following pattern : <code>parent -> child -> grand_child</code> and looks like the following : </p>
<pre><code>//seed.json
{
"parent_0":[
{
"child_10":[
{
"grand_child_A":[],
"grand_child_B":[],
"grand_child_C":[]
}
],
"child_20":[],
"child_30":[],
"child_40":[]
}
],
"parent_1":[
{
"child_11":[
{
"grand_child_D":[],
"grand_child_E":[],
"grand_child_F":[]
}
]
}
]
}
</code></pre>
<p>What I am trying to do is to list all objects present in parents , child and grand_child with ruby.</p>
<p>I was able to pull that off with <code>parent</code> by doing the following :</p>
<pre><code># seed.json
json = File.read('seed.json')
content = JSON.parse(json).keys
</code></pre>
<p>which return the following : </p>
<pre><code>$ ruby seed.rb
"parent_0"
"parent_1"
$
</code></pre>
<p>I'm stuck there ... I'd like to access <code>child_10</code> and list all its objects which are <code>grand_child_A</code>, <code>grand_child_B</code>, <code>grand_child_C</code>, the same way I did access and list <code>parent_0 and parent_1</code> but I have no idea how to proceed.</p>
<p>Any idea ?</p>
| 0debug |
How to check that string further doesn't contain a dot : <p>Maybe someone could help me with this:</p>
<p>I have a string such as <code>"1.something"</code>, <code>"1.0.something"</code> or <code>1.0.0.something</code> </p>
<p>The question is how can I check that there is no more dot in <em>something</em> section? </p>
<p>Thank you.</p>
| 0debug |
Control is not waiting to read for string object in JAVA programming : [**What is the problem with this code? When I execute it control is waiting to read.**][1]
[1]: http://i.stack.imgur.com/ZZstQ.png | 0debug |
Regex for accepting Aplahanumric and Numeric, but not Alphabates : <p>I want the <code>regular expression</code> in <code>java script</code> which accepts both Alphanumeric and only numeric, space and period is allowed.</p>
<p><strong>Acceptable:</strong></p>
<p>Hello Mr. 3367</p>
<p>6576567 55</p>
<p>3432 abc</p>
<p>3333333</p>
<p>ending in...4454</p>
<p><strong>Not Acceptable</strong> </p>
<p>Hello Mr. Khan</p>
<p>One Two Three</p>
<p>ABCSDS</p>
| 0debug |
Check that button is disabled in react-testing-library : <p>I have a React component that generates a button, which content contains <code><span></code> element like this one:</p>
<pre><code>function Click(props) {
return (
<button disable={props.disable}>
<span>Click me</span>
</button>
);
}
</code></pre>
<p>I want to test the logic of this component with the use of <code>react-testing-library</code> and <code>mocha</code> + <code>chai</code>.</p>
<p>The problem which I stuck at the moment is that <code>getByText("Click me")</code> selector return the <code><span></code> DOM node, but for the tests, I need to check <code>disable</code> attribute of the <code><button></code> node. What is the best practice handling such test cases? I see a couple of solutions, but all of them sounds a little bit off:</p>
<ol>
<li>Use <code>data-test-id</code> for <code><button></code> element</li>
<li>Select one of the ancestors of the <code><Click /></code> component and then select the button <code>within(...)</code> this scope</li>
<li>Click on the selected element with <code>fireEvent</code> and check that nothing is happened</li>
</ol>
<p>Can you suggest a better approach?</p>
| 0debug |
How can I remove default version of bundler? : <p>I tried to change default bundle version but it getting updated with 2 default version. How can I modify to single default?</p>
<pre><code>$ gem list bundler
*** LOCAL GEMS ***
bundler (2.0.1, default: 1.16.6, default: 1.16.2)
</code></pre>
<p>If I do gem uninstall not removing defaults,</p>
<pre><code>$ gem uninstall bundler
Successfully uninstalled bundler-2.0.1
$ gem list bundle
*** LOCAL GEMS ***
bundler (default: 1.16.6, default: 1.16.2)
</code></pre>
<p>How can I set (like the below) default as single version?</p>
<pre><code>bundler (2.0.1, default: 1.16.6)
</code></pre>
| 0debug |
error on window.location.hash : <p>i have rails app where i modify some files and then run bundle instal and assets:precompile.</p>
<p>after that i have error in file wich was not changed.
part of file where error happened:</p>
<pre><code><script type="text/javascript">
function openCurrentTab() {
var hash = window.location.hash || '#info'
$('a[href=' + hash + ']').tab('show')
}
$(function() {
openCurrentTab()
$('#outage-tabs > li > a').click(function(evt) {
evt.preventDefault()
$(this).tab('show')
history.pushState(null, null, this.hash)
})
})
window.onpopstate = openCurrentTab
</script>
</code></pre>
<p>error (in console)</p>
<pre><code>application-76c7fea….js:24 Uncaught Error: Syntax error, unrecognized expression: a[href=#info]
</code></pre>
<p>thank for help</p>
| 0debug |
static void copy_video_props(AVFilterBufferRefVideoProps *dst, AVFilterBufferRefVideoProps *src) {
*dst = *src;
if (src->qp_table) {
int qsize = src->qp_table_size;
dst->qp_table = av_malloc(qsize);
memcpy(dst->qp_table, src->qp_table, qsize);
}
}
| 1threat |
int load_uboot(const char *filename, target_ulong *ep, int *is_linux)
{
int fd;
int size;
uboot_image_header_t h;
uboot_image_header_t *hdr = &h;
uint8_t *data = NULL;
fd = open(filename, O_RDONLY | O_BINARY);
if (fd < 0)
return -1;
size = read(fd, hdr, sizeof(uboot_image_header_t));
if (size < 0)
goto fail;
bswap_uboot_header(hdr);
if (hdr->ih_magic != IH_MAGIC)
goto fail;
if (hdr->ih_type == IH_TYPE_MULTI) {
fprintf(stderr, "Unable to load multi-file u-boot images\n");
goto fail;
}
if (hdr->ih_comp != IH_COMP_NONE) {
fprintf(stderr, "Unable to load compressed u-boot images\n");
goto fail;
}
if (is_linux) {
if (hdr->ih_type == IH_TYPE_KERNEL && hdr->ih_os == IH_OS_LINUX)
*is_linux = 1;
else
*is_linux = 0;
}
*ep = hdr->ih_ep;
data = qemu_malloc(hdr->ih_size);
if (!data)
goto fail;
if (read(fd, data, hdr->ih_size) != hdr->ih_size) {
fprintf(stderr, "Error reading file\n");
goto fail;
}
cpu_physical_memory_write_rom(hdr->ih_load, data, hdr->ih_size);
return hdr->ih_size;
fail:
if (data)
qemu_free(data);
close(fd);
return -1;
}
| 1threat |
petalogix_ml605_init(QEMUMachineInitArgs *args)
{
ram_addr_t ram_size = args->ram_size;
const char *cpu_model = args->cpu_model;
MemoryRegion *address_space_mem = get_system_memory();
DeviceState *dev, *dma, *eth0;
Object *peer;
MicroBlazeCPU *cpu;
SysBusDevice *busdev;
CPUMBState *env;
DriveInfo *dinfo;
int i;
hwaddr ddr_base = MEMORY_BASEADDR;
MemoryRegion *phys_lmb_bram = g_new(MemoryRegion, 1);
MemoryRegion *phys_ram = g_new(MemoryRegion, 1);
qemu_irq irq[32], *cpu_irq;
if (cpu_model == NULL) {
cpu_model = "microblaze";
}
cpu = cpu_mb_init(cpu_model);
env = &cpu->env;
memory_region_init_ram(phys_lmb_bram, "petalogix_ml605.lmb_bram",
LMB_BRAM_SIZE);
vmstate_register_ram_global(phys_lmb_bram);
memory_region_add_subregion(address_space_mem, 0x00000000, phys_lmb_bram);
memory_region_init_ram(phys_ram, "petalogix_ml605.ram", ram_size);
vmstate_register_ram_global(phys_ram);
memory_region_add_subregion(address_space_mem, ddr_base, phys_ram);
dinfo = drive_get(IF_PFLASH, 0, 0);
pflash_cfi01_register(FLASH_BASEADDR,
NULL, "petalogix_ml605.flash", FLASH_SIZE,
dinfo ? dinfo->bdrv : NULL, (64 * 1024),
FLASH_SIZE >> 16,
2, 0x89, 0x18, 0x0000, 0x0, 0);
cpu_irq = microblaze_pic_init_cpu(env);
dev = xilinx_intc_create(INTC_BASEADDR, cpu_irq[0], 4);
for (i = 0; i < 32; i++) {
irq[i] = qdev_get_gpio_in(dev, i);
}
serial_mm_init(address_space_mem, UART16550_BASEADDR + 0x1000, 2,
irq[5], 115200, serial_hds[0], DEVICE_LITTLE_ENDIAN);
xilinx_timer_create(TIMER_BASEADDR, irq[2], 0, 100 * 1000000);
qemu_check_nic_model(&nd_table[0], "xlnx.axi-ethernet");
eth0 = qdev_create(NULL, "xlnx.axi-ethernet");
dma = qdev_create(NULL, "xlnx.axi-dma");
object_property_add_child(qdev_get_machine(), "xilinx-eth", OBJECT(eth0),
NULL);
object_property_add_child(qdev_get_machine(), "xilinx-dma", OBJECT(dma),
NULL);
peer = object_property_get_link(OBJECT(dma),
"axistream-connected-target", NULL);
xilinx_axiethernet_init(eth0, &nd_table[0], STREAM_SLAVE(peer),
0x82780000, irq[3], 0x1000, 0x1000);
peer = object_property_get_link(OBJECT(eth0),
"axistream-connected-target", NULL);
xilinx_axidma_init(dma, STREAM_SLAVE(peer), 0x84600000, irq[1], irq[0],
100 * 1000000);
{
SSIBus *spi;
dev = qdev_create(NULL, "xlnx.xps-spi");
qdev_prop_set_uint8(dev, "num-ss-bits", NUM_SPI_FLASHES);
qdev_init_nofail(dev);
busdev = SYS_BUS_DEVICE(dev);
sysbus_mmio_map(busdev, 0, 0x40a00000);
sysbus_connect_irq(busdev, 0, irq[4]);
spi = (SSIBus *)qdev_get_child_bus(dev, "spi");
for (i = 0; i < NUM_SPI_FLASHES; i++) {
qemu_irq cs_line;
dev = ssi_create_slave(spi, "n25q128");
cs_line = qdev_get_gpio_in(dev, 0);
sysbus_connect_irq(busdev, i+1, cs_line);
}
}
microblaze_load_kernel(cpu, ddr_base, ram_size, BINARY_DEVICE_TREE_FILE,
machine_cpu_reset);
}
| 1threat |
static int fdk_aac_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt)
{
FDKAACDecContext *s = avctx->priv_data;
AVFrame *frame = data;
int ret;
AAC_DECODER_ERROR err;
UINT valid = avpkt->size;
err = aacDecoder_Fill(s->handle, &avpkt->data, &avpkt->size, &valid);
if (err != AAC_DEC_OK) {
av_log(avctx, AV_LOG_ERROR, "aacDecoder_Fill() failed: %x\n", err);
return AVERROR_INVALIDDATA;
}
err = aacDecoder_DecodeFrame(s->handle, (INT_PCM *) s->decoder_buffer, s->decoder_buffer_size, 0);
if (err == AAC_DEC_NOT_ENOUGH_BITS) {
ret = avpkt->size - valid;
goto end;
}
if (err != AAC_DEC_OK) {
av_log(avctx, AV_LOG_ERROR,
"aacDecoder_DecodeFrame() failed: %x\n", err);
ret = AVERROR_UNKNOWN;
goto end;
}
if ((ret = get_stream_info(avctx)) < 0)
goto end;
frame->nb_samples = avctx->frame_size;
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
goto end;
memcpy(frame->extended_data[0], s->decoder_buffer,
avctx->channels * avctx->frame_size *
av_get_bytes_per_sample(avctx->sample_fmt));
*got_frame_ptr = 1;
ret = avpkt->size - valid;
end:
return ret;
}
| 1threat |
How do I break an input into individual characters in python? : <p>I would like to be able to take an input that could be anything from A-Z or 0-9 and of an indefinite quantity of characters and put them into a list. Here is an example of the code I am envisioning.</p>
<pre><code> number = input()
num_list = break_string(number)
print num_list
</code></pre>
| 0debug |
Display text in textview and save it in cach : How can I display text ( title and message) in textview and save it in chach
Thanks for all
public class sev_data extends IntentService { public static boolean ServiceIsRun = false; public sev_data() { super("Service"); } @Override protected void onHandleIntent(@Nullable Intent intent) { while (ServiceIsRun) { int id_s=0;//هنا رقم اخر رسلة وصلة التطبيق String url0 = "http://172.17.100.2/mham/sendapp.php?co>"+id_s;//رايط ملف الداتة من السيرفر String NewsData; try { URL url = new URL(url0); HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); InputStream in = new BufferedInputStream(urlConnection.getInputStream()); NewsData = Stream2String(in); in.close(); JSONObject jsonRootObject = new JSONObject(NewsData); JSONArray jsonArray = jsonRootObject.optJSONArray("date"); for (int i = 0; i < jsonArray.length(); i++) { JSONObject jsonObject = jsonArray.getJSONObject(i); String id= jsonObject.optString("id"); String title = jsonObject.optString("title"); String mess = jsonObject.optString("mess"); ///// هنا نهاية الموضوع دي اخر رسلة علي السيرفر } } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (JSONException e) { Log.e("mmmm", "hhhhhhhh", e); } } } public String Stream2String(InputStream inputStream) { BufferedReader bureader = new BufferedReader(new InputStreamReader(inputStream)); String line; String Text = ""; try { while ((line = bureader.readLine()) != null) { Text += line; } } catch (Exception ex) { } return Text; } } | 0debug |
DECL_IMDCT_BLOCKS(sse,sse)
DECL_IMDCT_BLOCKS(sse2,sse)
DECL_IMDCT_BLOCKS(sse3,sse)
DECL_IMDCT_BLOCKS(ssse3,sse)
DECL_IMDCT_BLOCKS(avx,avx)
#endif
void ff_mpadsp_init_mmx(MPADSPContext *s)
{
int mm_flags = av_get_cpu_flags();
int i, j;
for (j = 0; j < 4; j++) {
for (i = 0; i < 40; i ++) {
mdct_win_sse[0][j][4*i ] = ff_mdct_win_float[j ][i];
mdct_win_sse[0][j][4*i + 1] = ff_mdct_win_float[j + 4][i];
mdct_win_sse[0][j][4*i + 2] = ff_mdct_win_float[j ][i];
mdct_win_sse[0][j][4*i + 3] = ff_mdct_win_float[j + 4][i];
mdct_win_sse[1][j][4*i ] = ff_mdct_win_float[0 ][i];
mdct_win_sse[1][j][4*i + 1] = ff_mdct_win_float[4 ][i];
mdct_win_sse[1][j][4*i + 2] = ff_mdct_win_float[j ][i];
mdct_win_sse[1][j][4*i + 3] = ff_mdct_win_float[j + 4][i];
}
}
#if HAVE_SSE2_INLINE
if (mm_flags & AV_CPU_FLAG_SSE2) {
s->apply_window_float = apply_window_mp3;
}
#endif
#if HAVE_YASM
if (mm_flags & AV_CPU_FLAG_AVX && HAVE_AVX) {
s->imdct36_blocks_float = imdct36_blocks_avx;
#if HAVE_SSE
} else if (mm_flags & AV_CPU_FLAG_SSSE3) {
s->imdct36_blocks_float = imdct36_blocks_ssse3;
} else if (mm_flags & AV_CPU_FLAG_SSE3) {
s->imdct36_blocks_float = imdct36_blocks_sse3;
} else if (mm_flags & AV_CPU_FLAG_SSE2) {
s->imdct36_blocks_float = imdct36_blocks_sse2;
} else if (mm_flags & AV_CPU_FLAG_SSE) {
s->imdct36_blocks_float = imdct36_blocks_sse;
#endif
}
#endif
}
| 1threat |
static int update_packetheader(NUTContext *nut, ByteIOContext *bc, int additional_size){
int64_t start= nut->packet_start;
int64_t cur= url_ftell(bc);
int size= cur - start + additional_size;
if(size != nut->written_packet_size){
int i;
assert( size <= nut->written_packet_size );
url_fseek(bc, nut->packet_size_pos, SEEK_SET);
for(i=get_length(size); i < get_length(nut->written_packet_size); i+=7)
put_byte(bc, 0x80);
put_v(bc, size);
url_fseek(bc, cur, SEEK_SET);
nut->written_packet_size= size;
}
return 0;
}
| 1threat |
How do I upgrade the Python installation in Windows 10? : <p>I have a Python 2.7.11 installed on one of my LAB stations. I would like to upgrade Python to at least 3.5.</p>
<p>How should I do that ?
Should I prefer to completely uninstall 2.7.11 and than install the new one ?
Is there a way to update it ? Is an update a good idea ?</p>
| 0debug |
How to see appended child nodes in `View Page Source`? : <p>I create elements and append them to <code>BODY</code> tag but I don't see them in page source. How can I see newly created tags in the source code?</p>
| 0debug |
static int nvme_start_ctrl(NvmeCtrl *n)
{
uint32_t page_bits = NVME_CC_MPS(n->bar.cc) + 12;
uint32_t page_size = 1 << page_bits;
if (n->cq[0] || n->sq[0] || !n->bar.asq || !n->bar.acq ||
n->bar.asq & (page_size - 1) || n->bar.acq & (page_size - 1) ||
NVME_CC_MPS(n->bar.cc) < NVME_CAP_MPSMIN(n->bar.cap) ||
NVME_CC_MPS(n->bar.cc) > NVME_CAP_MPSMAX(n->bar.cap) ||
NVME_CC_IOCQES(n->bar.cc) < NVME_CTRL_CQES_MIN(n->id_ctrl.cqes) ||
NVME_CC_IOCQES(n->bar.cc) > NVME_CTRL_CQES_MAX(n->id_ctrl.cqes) ||
NVME_CC_IOSQES(n->bar.cc) < NVME_CTRL_SQES_MIN(n->id_ctrl.sqes) ||
NVME_CC_IOSQES(n->bar.cc) > NVME_CTRL_SQES_MAX(n->id_ctrl.sqes) ||
!NVME_AQA_ASQS(n->bar.aqa) || !NVME_AQA_ACQS(n->bar.aqa)) {
return -1;
}
n->page_bits = page_bits;
n->page_size = page_size;
n->max_prp_ents = n->page_size / sizeof(uint64_t);
n->cqe_size = 1 << NVME_CC_IOCQES(n->bar.cc);
n->sqe_size = 1 << NVME_CC_IOSQES(n->bar.cc);
nvme_init_cq(&n->admin_cq, n, n->bar.acq, 0, 0,
NVME_AQA_ACQS(n->bar.aqa) + 1, 1);
nvme_init_sq(&n->admin_sq, n, n->bar.asq, 0, 0,
NVME_AQA_ASQS(n->bar.aqa) + 1);
return 0;
}
| 1threat |
What is the Bitwise complement of (-4) i.e. [~(-4)]? : <p>I am new at this portal, I am searching for Bitwise complement of (-4) or any negative number in Java. Can anyone help me out of this?</p>
| 0debug |
Why i am using eslint, lint, in my NODE JS project? : I am looking for light,facile answer what is the benefit using eslint,lint in my Node js project | 0debug |
static int avisynth_read_packet_video(AVFormatContext *s, AVPacket *pkt,
int discard)
{
AviSynthContext *avs = s->priv_data;
AVS_VideoFrame *frame;
unsigned char *dst_p;
const unsigned char *src_p;
int n, i, plane, rowsize, planeheight, pitch, bits;
const char *error;
if (avs->curr_frame >= avs->vi->num_frames)
return AVERROR_EOF;
n = avs->curr_frame++;
if (discard)
return 0;
#ifdef USING_AVISYNTH
if (avs_library.avs_is_yv24(avs->vi))
bits = 24;
else if (avs_library.avs_is_yv16(avs->vi))
bits = 16;
else if (avs_library.avs_is_yv411(avs->vi))
bits = 12;
else if (avs_library.avs_is_y8(avs->vi))
bits = 8;
else
bits = avs_library.avs_bits_per_pixel(avs->vi);
#else
bits = avs_bits_per_pixel(avs->vi);
#endif
pkt->size = (((int64_t)avs->vi->width *
(int64_t)avs->vi->height) * bits) / 8;
if (!pkt->size)
return AVERROR_UNKNOWN;
if (av_new_packet(pkt, pkt->size) < 0)
return AVERROR(ENOMEM);
pkt->pts = n;
pkt->dts = n;
pkt->duration = 1;
pkt->stream_index = avs->curr_stream;
frame = avs_library.avs_get_frame(avs->clip, n);
error = avs_library.avs_clip_get_error(avs->clip);
if (error) {
av_log(s, AV_LOG_ERROR, "%s\n", error);
avs->error = 1;
av_packet_unref(pkt);
return AVERROR_UNKNOWN;
}
dst_p = pkt->data;
for (i = 0; i < avs->n_planes; i++) {
plane = avs->planes[i];
#ifdef USING_AVISYNTH
src_p = avs_library.avs_get_read_ptr_p(frame, plane);
pitch = avs_library.avs_get_pitch_p(frame, plane);
rowsize = avs_library.avs_get_row_size_p(frame, plane);
planeheight = avs_library.avs_get_height_p(frame, plane);
#else
src_p = avs_get_read_ptr_p(frame, plane);
pitch = avs_get_pitch_p(frame, plane);
rowsize = avs_get_row_size_p(frame, plane);
planeheight = avs_get_height_p(frame, plane);
#endif
if (avs_is_rgb24(avs->vi) || avs_is_rgb(avs->vi)) {
src_p = src_p + (planeheight - 1) * pitch;
pitch = -pitch;
}
avs_library.avs_bit_blt(avs->env, dst_p, rowsize, src_p, pitch,
rowsize, planeheight);
dst_p += rowsize * planeheight;
}
avs_library.avs_release_video_frame(frame);
return 0;
}
| 1threat |
Add conda environment info to terminal prompt : <p>(I'm using anaconda on a MacBook)<br>
By default conda adds the environment info to the comand prompt as follows:</p>
<pre><code>$ source activate my_env
(my_env) $ source deactivate
$
</code></pre>
<p>This can be switched off and on using</p>
<pre><code>conda config --set changeps1 (true|false)
</code></pre>
<p>Since my terminal prompt is already customised I'd like to add the env info in a different way, but don't know how to exactly.</p>
<p>Right now I'm using the two commands <code>sac</code>and <code>dac</code> in my .bash_profile file to activate and deactivate envs and therefore did this amateurish attempt adding <code>env_var</code>:</p>
<pre><code>env_var=""
#activate env (default env = my_env)
sac() {
if [ -z $1 ];
then
ENV="my_env"
else
ENV="${1}"
fi
source activate ${ENV}
env_var="${ENV}"
}
#deactivate env
dac() {
source deactivate
env_var=""
}
env_info() {
if [[ ${env_var} == "" ]]
then
echo ""
else
echo "in ${env_var}"
fi
}
PS1="\u "
PS1+="$(env_info) \$";
</code></pre>
<p>Which is not working (my bash knowledge is only rudimentary sorry...).
<code>env_info</code> always stays <code>""</code> no matter wether I call <code>sac</code>or <code>dac</code>in the terminal or not.</p>
<p><strong>Question1:</strong> Why is the code not working?</p>
<p><strong>Question2:</strong> Or is there maybe another way to get the current env-info in a - for this purpose - useful format?<br>
<code>conda info --envs</code> returns to much info...</p>
| 0debug |
bat and exe to sellf delete : I have wrote a batch script which will open some websites ive also added a countdown timer and shutdown code , but im wondering if there is a way i would be able to delete it when its finished opening the website and before the shutdown but the other peoblem is ive tried to use "del (filename.bat)" and with the exe extension but wouldnt work. The end result will be in exe so im looking for it to self delete but ive also been tried to make it open another batch which would then delete both but that wouldnt work either any ideas what i can do | 0debug |
How do I retrieve the private key for a certificate generated on AWS Certificate Manager? : <p>Someone purchased a wildcard certificate via AWS Certificate Manager for their domain name and I need to transfer it to Heroku for an app that uses a sub-domain of the domain name.</p>
<p>I can't figure out, either through the AWS Console or through their CLI, how I would get the private key used to generate the CSR for this certificate? Can anyone on here help me?</p>
| 0debug |
Regex for complex password : <p>This question has obviously been asked many times regarding how to make a regex using c# to meet the requirements. I require a regex that..</p>
<ul>
<li>Is at least 8 characters long</li>
<li>At least 1 upper case character</li>
<li>1 number</li>
<li>1 special character !@#$%^&*()</li>
<li>password not the same as the login name(easy to check)</li>
<li>not contain more than 2 recurring characters e.g. aaa123</li>
</ul>
<p>Trying to work this out myself i was thinking to search for how to do each 1 of these requirements one by one and build the regex up as i go. Is this the right approach?</p>
<p>I feel like i could be missing something. I am reading up about regex expressions and how to create a complex one. Your feedback much needed.</p>
<p>Thanks.</p>
| 0debug |
static void qdev_prop_set_globals_for_type(DeviceState *dev,
const char *typename)
{
GlobalProperty *prop;
QTAILQ_FOREACH(prop, &global_props, next) {
Error *err = NULL;
if (strcmp(typename, prop->driver) != 0) {
continue;
}
prop->used = true;
object_property_parse(OBJECT(dev), prop->value, prop->property, &err);
if (err != NULL) {
assert(prop->user_provided);
error_reportf_err(err, "Warning: global %s.%s=%s ignored: ",
prop->driver, prop->property, prop->value);
return;
}
}
}
| 1threat |
static int dirac_decode_frame_internal(DiracContext *s)
{
DWTContext d;
int y, i, comp, dsty;
int ret;
if (s->low_delay) {
for (comp = 0; comp < 3; comp++) {
Plane *p = &s->plane[comp];
memset(p->idwt_buf, 0, p->idwt_stride * p->idwt_height * sizeof(IDWTELEM));
}
if (!s->zero_res) {
if ((ret = decode_lowdelay(s)) < 0)
return ret;
}
}
for (comp = 0; comp < 3; comp++) {
Plane *p = &s->plane[comp];
uint8_t *frame = s->current_picture->avframe->data[comp];
for (i = 0; i < 4; i++)
s->edge_emu_buffer[i] = s->edge_emu_buffer_base + i*FFALIGN(p->width, 16);
if (!s->zero_res && !s->low_delay)
{
memset(p->idwt_buf, 0, p->idwt_stride * p->idwt_height * sizeof(IDWTELEM));
decode_component(s, comp);
}
ret = ff_spatial_idwt_init2(&d, p->idwt_buf, p->idwt_width, p->idwt_height, p->idwt_stride,
s->wavelet_idx+2, s->wavelet_depth, p->idwt_tmp);
if (ret < 0)
return ret;
if (!s->num_refs) {
for (y = 0; y < p->height; y += 16) {
ff_spatial_idwt_slice2(&d, y+16);
s->diracdsp.put_signed_rect_clamped(frame + y*p->stride, p->stride,
p->idwt_buf + y*p->idwt_stride, p->idwt_stride, p->width, 16);
}
} else {
int rowheight = p->ybsep*p->stride;
select_dsp_funcs(s, p->width, p->height, p->xblen, p->yblen);
for (i = 0; i < s->num_refs; i++)
interpolate_refplane(s, s->ref_pics[i], comp, p->width, p->height);
memset(s->mctmp, 0, 4*p->yoffset*p->stride);
dsty = -p->yoffset;
for (y = 0; y < s->blheight; y++) {
int h = 0,
start = FFMAX(dsty, 0);
uint16_t *mctmp = s->mctmp + y*rowheight;
DiracBlock *blocks = s->blmotion + y*s->blwidth;
init_obmc_weights(s, p, y);
if (y == s->blheight-1 || start+p->ybsep > p->height)
h = p->height - start;
else
h = p->ybsep - (start - dsty);
if (h < 0)
break;
memset(mctmp+2*p->yoffset*p->stride, 0, 2*rowheight);
mc_row(s, blocks, mctmp, comp, dsty);
mctmp += (start - dsty)*p->stride + p->xoffset;
ff_spatial_idwt_slice2(&d, start + h);
s->diracdsp.add_rect_clamped(frame + start*p->stride, mctmp, p->stride,
p->idwt_buf + start*p->idwt_stride, p->idwt_stride, p->width, h);
dsty += p->ybsep;
}
}
}
return 0;
}
| 1threat |
static NetSocketState *net_socket_fd_init_stream(VLANState *vlan,
const char *model,
const char *name,
int fd, int is_connected)
{
NetSocketState *s;
s = qemu_mallocz(sizeof(NetSocketState));
s->fd = fd;
s->vc = qemu_new_vlan_client(vlan, model, name,
net_socket_receive, NULL, s);
snprintf(s->vc->info_str, sizeof(s->vc->info_str),
"socket: fd=%d", fd);
if (is_connected) {
net_socket_connect(s);
} else {
qemu_set_fd_handler(s->fd, NULL, net_socket_connect, s);
}
return s;
}
| 1threat |
How can I serialize a jgrapht simple graph to json? : <p>I have a simple directed graph from jgrapht and I am trying to serialize it into a JSON file using jackson as follows:</p>
<pre><code>ObjectMapper mapper = new ObjectMapper();
File output = new File("P:\\tree.json");
ObjectWriter objectWriter = mapper.writer().withDefaultPrettyPrinter();
objectWriter.writeValue(output,simpleDirectedGraph);
</code></pre>
<p>However I get this error:</p>
<pre><code>Exception in thread "main" com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class org.jgrapht.graph.AbstractBaseGraph$ArrayListFactory and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: org.jgrapht.graph.SimpleDirectedGraph["edgeSetFactory"])
at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.failForEmpty(UnknownSerializer.java:69)
at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.serialize(UnknownSerializer.java:32)
at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:693)
at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:675)
at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:157)
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:130)
at com.fasterxml.jackson.databind.ObjectWriter$Prefetch.serialize(ObjectWriter.java:1387)
at com.fasterxml.jackson.databind.ObjectWriter._configAndWriteValue(ObjectWriter.java:1088)
at com.fasterxml.jackson.databind.ObjectWriter.writeValue(ObjectWriter.java:909)
at ms.fragment.JSONTreeGenerator.main(JSONTreeGenerator.java:45)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
</code></pre>
<p>I have seen that there is a GmlExporter but I am interested in json...how can I do that?</p>
| 0debug |
Ceaser Cipher using char * ? c++ : So i am trying to use the Ceaser Cipher with `char *`'s, i've written a simple function out like this:
char * Encrypt(char * Source, int Key)
{
char * Crypted = Source;
for(int Current = 0; Current < strlen(Source); Current++)
Crypted[Current] += Key;
return Crypted;
}
that seems to look like it should work but it doesn't? It throws an error when running program. And before you say "why not just use `string`?", well the answer is I'm writing c++ on a certain sdk that causes compiler errors when using `string`. Ok but yeah, any form of help will greatly be appreciated, thanks! | 0debug |
static void mips_fulong2e_init(MachineState *machine)
{
ram_addr_t ram_size = machine->ram_size;
const char *cpu_model = machine->cpu_model;
const char *kernel_filename = machine->kernel_filename;
const char *kernel_cmdline = machine->kernel_cmdline;
const char *initrd_filename = machine->initrd_filename;
char *filename;
MemoryRegion *address_space_mem = get_system_memory();
MemoryRegion *ram = g_new(MemoryRegion, 1);
MemoryRegion *bios = g_new(MemoryRegion, 1);
long bios_size;
int64_t kernel_entry;
qemu_irq *i8259;
qemu_irq *cpu_exit_irq;
PCIBus *pci_bus;
ISABus *isa_bus;
I2CBus *smbus;
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
MIPSCPU *cpu;
CPUMIPSState *env;
if (cpu_model == NULL) {
cpu_model = "Loongson-2E";
}
cpu = cpu_mips_init(cpu_model);
if (cpu == NULL) {
fprintf(stderr, "Unable to find CPU definition\n");
exit(1);
}
env = &cpu->env;
qemu_register_reset(main_cpu_reset, cpu);
ram_size = 256 * 1024 * 1024;
bios_size = 1024 * 1024;
memory_region_allocate_system_memory(ram, NULL, "fulong2e.ram", ram_size);
memory_region_init_ram(bios, NULL, "fulong2e.bios", bios_size,
&error_abort);
vmstate_register_ram_global(bios);
memory_region_set_readonly(bios, true);
memory_region_add_subregion(address_space_mem, 0, ram);
memory_region_add_subregion(address_space_mem, 0x1fc00000LL, bios);
if (kernel_filename) {
loaderparams.ram_size = ram_size;
loaderparams.kernel_filename = kernel_filename;
loaderparams.kernel_cmdline = kernel_cmdline;
loaderparams.initrd_filename = initrd_filename;
kernel_entry = load_kernel (env);
write_bootloader(env, memory_region_get_ram_ptr(bios), kernel_entry);
} else {
if (bios_name == NULL) {
bios_name = FULONG_BIOSNAME;
}
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (filename) {
bios_size = load_image_targphys(filename, 0x1fc00000LL,
BIOS_SIZE);
g_free(filename);
} else {
bios_size = -1;
}
if ((bios_size < 0 || bios_size > BIOS_SIZE) &&
!kernel_filename && !qtest_enabled()) {
error_report("Could not load MIPS bios '%s'", bios_name);
exit(1);
}
}
cpu_mips_irq_init_cpu(env);
cpu_mips_clock_init(env);
pci_bus = bonito_init((qemu_irq *)&(env->irq[2]));
ide_drive_get(hd, ARRAY_SIZE(hd));
isa_bus = vt82c686b_init(pci_bus, PCI_DEVFN(FULONG2E_VIA_SLOT, 0));
if (!isa_bus) {
fprintf(stderr, "vt82c686b_init error\n");
exit(1);
}
i8259 = i8259_init(isa_bus, env->irq[5]);
isa_bus_irqs(isa_bus, i8259);
vt82c686b_ide_init(pci_bus, hd, PCI_DEVFN(FULONG2E_VIA_SLOT, 1));
pci_create_simple(pci_bus, PCI_DEVFN(FULONG2E_VIA_SLOT, 2),
"vt82c686b-usb-uhci");
pci_create_simple(pci_bus, PCI_DEVFN(FULONG2E_VIA_SLOT, 3),
"vt82c686b-usb-uhci");
smbus = vt82c686b_pm_init(pci_bus, PCI_DEVFN(FULONG2E_VIA_SLOT, 4),
0xeee1, NULL);
smbus_eeprom_init(smbus, 1, eeprom_spd, sizeof(eeprom_spd));
pit = pit_init(isa_bus, 0x40, 0, NULL);
cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1);
DMA_init(0, cpu_exit_irq);
isa_create_simple(isa_bus, "i8042");
rtc_init(isa_bus, 2000, NULL);
serial_hds_isa_init(isa_bus, MAX_SERIAL_PORTS);
parallel_hds_isa_init(isa_bus, 1);
audio_init(pci_bus);
network_init(pci_bus);
}
| 1threat |
C# enum and radiobuttons : Hello how can i tell if one radion buton is checked do something in swith? this is part of my code:
this is in my class Person.cs
public enum TypeTimer { Unlimited, Countdown, Limited}
This is my switch where i will put the funciotns
public Person(TypeTimer s1)
{
switch (s1)
{
case TypeTimer.Unlimited:
(code here)
break;
case TypeTimer.Countdown:
(code here)
break;
case TypeTimer.Limited:
(code here)
break;
default:
break;
}
}
Here how do i tell if checked == true is equal to enum limited or unlimited or countdown?
this is in Form.cs
private void button1_Click(object sender, EventArgs e)
{
if (rbtnNormalTimer.Checked == true)
{
}
else if(rbtnCountDown.Checked == true)
{
}
else if(rbtnLimited.Checked == true)
{
}
}
CAn someone please help me?
| 0debug |
static int div_round (int dividend, int divisor)
{
if (dividend > 0)
return (dividend + (divisor>>1)) / divisor;
else
return -((-dividend + (divisor>>1)) / divisor);
}
| 1threat |
PostgreSQL constraint using prefixes : <p>Let's say I have the following PostgreSQL table:</p>
<pre><code>id | key
---+--------
1 | 'a.b.c'
</code></pre>
<p>I need to prevent inserting records with a key that is a prefix of another key. For example, I should be able to insert:</p>
<ul>
<li><code>'a.b.b'</code></li>
</ul>
<p>But the following keys should not be accepted:</p>
<ul>
<li><code>'a.b'</code></li>
<li><code>'a.b.c'</code></li>
<li><code>'a.b.c.d'</code></li>
</ul>
<p>Is there a way to achieve this - either by a constraint or by a locking mechanism (check the existance before inserting)?</p>
| 0debug |
When to use external style sheet and the other types? : <p>I am a beginner in html/css, i want to know when i should use external ,internal,inline style sheets respectively. What makes the big difference.? [I read a couple of answers on the same site] but i need something which is more clear.</p>
| 0debug |
sapnco BAPI invoked in CUA for child systems : Hi I am currently developing an C# application with sapnco 3 connector.
I am wondering if I could invoke BAPI into CUA and this BAPI would pass details to child system.
This field is available through Test Function Module (field "RFC target sys"), but it is unavailable directly in standard BAPIs when accessed from sapnco.
[![RFC target sys:][1]][1]
[1]: https://i.stack.imgur.com/OMgTz.png
In ABAP devs can use
call function 'BAPI_USER_CHANGE' destination '<TARGET_SYS>'
Can I use something similar in sapnco library?
IRfcFunction rfcs = rfcDest.Repository.CreateFunction("BAPI_USER_CHANGE");
Does anybody know how this could be achieved?
Main intent is to reset user passwords to initial ones through App(BAPI) --> CUA --> ChildSystem
Without direct access into child systems. | 0debug |
How to pass parameters into a SPARQL query : <p>How do I pass var1 and var2 into the sparql query shown below. I have the code below but its not returning anything. </p>
<p>I appreciate your help on this. Thank you in adavnce</p>
<pre><code>string var1, var2;
var1 = DropDownList1.SelectedValue.ToString();
var2 = DropDownList2.SelectedValue.ToString();
//Load first listbox
private const string loadlist1 = @"
PREFIX au: <http://semwebowl.somee.com/au/n3_notation#>
SELECT DISTINCT ?ResearchArea
WHERE {
[a au:var1;
au:ResearchArea var2;
au:ResearchArea ?ResearchArea].
}";
</code></pre>
| 0debug |
Open a new tab in browser with custom html code. Javascript : <p>How do I have a function that opens a new tab in the browser with custom html that is generated in the root tab?</p>
| 0debug |
AVInputFormat *av_probe_input_format2(AVProbeData *pd, int is_opened, int *score_max)
{
AVProbeData lpd = *pd;
AVInputFormat *fmt1 = NULL, *fmt;
int score, id3 = 0;
if (lpd.buf_size > 10 && ff_id3v2_match(lpd.buf, ID3v2_DEFAULT_MAGIC)) {
int id3len = ff_id3v2_tag_len(lpd.buf);
if (lpd.buf_size > id3len + 16) {
lpd.buf += id3len;
lpd.buf_size -= id3len;
}
id3 = 1;
}
fmt = NULL;
while ((fmt1 = av_iformat_next(fmt1))) {
if (!is_opened == !(fmt1->flags & AVFMT_NOFILE))
continue;
score = 0;
if (fmt1->read_probe) {
score = fmt1->read_probe(&lpd);
} else if (fmt1->extensions) {
if (av_match_ext(lpd.filename, fmt1->extensions)) {
score = 50;
}
}
if (score > *score_max) {
*score_max = score;
fmt = fmt1;
}else if (score == *score_max)
fmt = NULL;
}
if (!fmt && id3 && *score_max < AVPROBE_SCORE_MAX/4) {
while ((fmt = av_iformat_next(fmt)))
if (fmt->extensions && av_match_ext(lpd.filename, fmt->extensions)) {
*score_max = AVPROBE_SCORE_MAX/4;
break;
}
}
return fmt;
}
| 1threat |
Kotlin - Override/Implement array-like accessor function : <p>Is it possible to override or implement the <code>[]</code> accessors in Kotlin (using operator overloading or similar)?</p>
<pre><code>val testObject = MyCustumObject()
println(testObject["hi"]) // i.e. implement this accessor.
</code></pre>
<p>In Python this is possible by implementing <code>__getitem__</code> and <code>__setitem__</code>.</p>
| 0debug |
static int vc1_decode_frame(AVCodecContext *avctx, void *data,
int *data_size, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size, n_slices = 0, i;
VC1Context *v = avctx->priv_data;
MpegEncContext *s = &v->s;
AVFrame *pict = data;
uint8_t *buf2 = NULL;
const uint8_t *buf_start = buf;
int mb_height, n_slices1;
struct {
uint8_t *buf;
GetBitContext gb;
int mby_start;
} *slices = NULL, *tmp;
if (buf_size == 0 || (buf_size == 4 && AV_RB32(buf) == VC1_CODE_ENDOFSEQ)) {
if (s->low_delay == 0 && s->next_picture_ptr) {
*pict = s->next_picture_ptr->f;
s->next_picture_ptr = NULL;
*data_size = sizeof(AVFrame);
}
return 0;
}
if (s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU) {
if (v->profile < PROFILE_ADVANCED)
avctx->pix_fmt = AV_PIX_FMT_VDPAU_WMV3;
else
avctx->pix_fmt = AV_PIX_FMT_VDPAU_VC1;
}
if (avctx->codec_id == AV_CODEC_ID_VC1 || avctx->codec_id == AV_CODEC_ID_VC1IMAGE) {
int buf_size2 = 0;
buf2 = av_mallocz(buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
if (IS_MARKER(AV_RB32(buf))) {
const uint8_t *start, *end, *next;
int size;
next = buf;
for (start = buf, end = buf + buf_size; next < end; start = next) {
next = find_next_marker(start + 4, end);
size = next - start - 4;
if (size <= 0) continue;
switch (AV_RB32(start)) {
case VC1_CODE_FRAME:
if (avctx->hwaccel ||
s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
buf_start = start;
buf_size2 = vc1_unescape_buffer(start + 4, size, buf2);
break;
case VC1_CODE_FIELD: {
int buf_size3;
tmp = av_realloc(slices, sizeof(*slices) * (n_slices+1));
if (!tmp)
goto err;
slices = tmp;
slices[n_slices].buf = av_mallocz(buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!slices[n_slices].buf)
goto err;
buf_size3 = vc1_unescape_buffer(start + 4, size,
slices[n_slices].buf);
init_get_bits(&slices[n_slices].gb, slices[n_slices].buf,
buf_size3 << 3);
slices[n_slices].mby_start = s->mb_height >> 1;
n_slices1 = n_slices - 1;
n_slices++;
break;
}
case VC1_CODE_ENTRYPOINT:
buf_size2 = vc1_unescape_buffer(start + 4, size, buf2);
init_get_bits(&s->gb, buf2, buf_size2 * 8);
ff_vc1_decode_entry_point(avctx, v, &s->gb);
break;
case VC1_CODE_SLICE: {
int buf_size3;
tmp = av_realloc(slices, sizeof(*slices) * (n_slices+1));
if (!tmp)
goto err;
slices = tmp;
slices[n_slices].buf = av_mallocz(buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!slices[n_slices].buf)
goto err;
buf_size3 = vc1_unescape_buffer(start + 4, size,
slices[n_slices].buf);
init_get_bits(&slices[n_slices].gb, slices[n_slices].buf,
buf_size3 << 3);
slices[n_slices].mby_start = get_bits(&slices[n_slices].gb, 9);
n_slices++;
break;
}
}
}
} else if (v->interlace && ((buf[0] & 0xC0) == 0xC0)) {
const uint8_t *divider;
int buf_size3;
divider = find_next_marker(buf, buf + buf_size);
if ((divider == (buf + buf_size)) || AV_RB32(divider) != VC1_CODE_FIELD) {
av_log(avctx, AV_LOG_ERROR, "Error in WVC1 interlaced frame\n");
goto err;
} else {
tmp = av_realloc(slices, sizeof(*slices) * (n_slices+1));
if (!tmp)
goto err;
slices = tmp;
slices[n_slices].buf = av_mallocz(buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!slices[n_slices].buf)
goto err;
buf_size3 = vc1_unescape_buffer(divider + 4, buf + buf_size - divider - 4, slices[n_slices].buf);
init_get_bits(&slices[n_slices].gb, slices[n_slices].buf,
buf_size3 << 3);
slices[n_slices].mby_start = s->mb_height >> 1;
n_slices1 = n_slices - 1;
n_slices++;
}
buf_size2 = vc1_unescape_buffer(buf, divider - buf, buf2);
} else {
buf_size2 = vc1_unescape_buffer(buf, buf_size, buf2);
}
init_get_bits(&s->gb, buf2, buf_size2*8);
} else
init_get_bits(&s->gb, buf, buf_size*8);
if (v->res_sprite) {
v->new_sprite = !get_bits1(&s->gb);
v->two_sprites = get_bits1(&s->gb);
if (avctx->codec_id == AV_CODEC_ID_WMV3IMAGE || avctx->codec_id == AV_CODEC_ID_VC1IMAGE) {
if (v->new_sprite) {
avctx->width = avctx->coded_width = v->sprite_width;
avctx->height = avctx->coded_height = v->sprite_height;
} else {
goto image;
}
}
}
if (s->context_initialized &&
(s->width != avctx->coded_width ||
s->height != avctx->coded_height)) {
ff_vc1_decode_end(avctx);
}
if (!s->context_initialized) {
if (ff_msmpeg4_decode_init(avctx) < 0 || ff_vc1_decode_init_alloc_tables(v) < 0)
return -1;
s->low_delay = !avctx->has_b_frames || v->res_sprite;
if (v->profile == PROFILE_ADVANCED) {
s->h_edge_pos = avctx->coded_width;
s->v_edge_pos = avctx->coded_height;
}
}
if (s->current_picture_ptr == NULL || s->current_picture_ptr->f.data[0]) {
int i = ff_find_unused_picture(s, 0);
if (i < 0)
goto err;
s->current_picture_ptr = &s->picture[i];
}
v->pic_header_flag = 0;
if (v->profile < PROFILE_ADVANCED) {
if (ff_vc1_parse_frame_header(v, &s->gb) == -1) {
goto err;
}
} else {
if (ff_vc1_parse_frame_header_adv(v, &s->gb) == -1) {
goto err;
}
}
if ((avctx->codec_id == AV_CODEC_ID_WMV3IMAGE || avctx->codec_id == AV_CODEC_ID_VC1IMAGE)
&& s->pict_type != AV_PICTURE_TYPE_I) {
av_log(v->s.avctx, AV_LOG_ERROR, "Sprite decoder: expected I-frame\n");
goto err;
}
s->current_picture_ptr->f.repeat_pict = 0;
if (v->rff) {
s->current_picture_ptr->f.repeat_pict = 1;
} else if (v->rptfrm) {
s->current_picture_ptr->f.repeat_pict = v->rptfrm * 2;
}
s->current_picture.f.pict_type = s->pict_type;
s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;
if (s->last_picture_ptr == NULL && (s->pict_type == AV_PICTURE_TYPE_B || s->dropable)) {
goto err;
}
if ((avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type == AV_PICTURE_TYPE_B) ||
(avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type != AV_PICTURE_TYPE_I) ||
avctx->skip_frame >= AVDISCARD_ALL) {
goto end;
}
if (s->next_p_frame_damaged) {
if (s->pict_type == AV_PICTURE_TYPE_B)
goto end;
else
s->next_p_frame_damaged = 0;
}
if (ff_MPV_frame_start(s, avctx) < 0) {
goto err;
}
s->me.qpel_put = s->dsp.put_qpel_pixels_tab;
s->me.qpel_avg = s->dsp.avg_qpel_pixels_tab;
if ((CONFIG_VC1_VDPAU_DECODER)
&&s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
ff_vdpau_vc1_decode_picture(s, buf_start, (buf + buf_size) - buf_start);
else if (avctx->hwaccel) {
if (avctx->hwaccel->start_frame(avctx, buf, buf_size) < 0)
goto err;
if (avctx->hwaccel->decode_slice(avctx, buf_start, (buf + buf_size) - buf_start) < 0)
goto err;
if (avctx->hwaccel->end_frame(avctx) < 0)
goto err;
} else {
ff_er_frame_start(s);
v->bits = buf_size * 8;
v->end_mb_x = s->mb_width;
if (v->field_mode) {
uint8_t *tmp[2];
s->current_picture.f.linesize[0] <<= 1;
s->current_picture.f.linesize[1] <<= 1;
s->current_picture.f.linesize[2] <<= 1;
s->linesize <<= 1;
s->uvlinesize <<= 1;
tmp[0] = v->mv_f_last[0];
tmp[1] = v->mv_f_last[1];
v->mv_f_last[0] = v->mv_f_next[0];
v->mv_f_last[1] = v->mv_f_next[1];
v->mv_f_next[0] = v->mv_f[0];
v->mv_f_next[1] = v->mv_f[1];
v->mv_f[0] = tmp[0];
v->mv_f[1] = tmp[1];
}
mb_height = s->mb_height >> v->field_mode;
for (i = 0; i <= n_slices; i++) {
if (i > 0 && slices[i - 1].mby_start >= mb_height) {
if (v->field_mode <= 0) {
av_log(v->s.avctx, AV_LOG_ERROR, "Slice %d starts beyond "
"picture boundary (%d >= %d)\n", i,
slices[i - 1].mby_start, mb_height);
continue;
}
v->second_field = 1;
v->blocks_off = s->mb_width * s->mb_height << 1;
v->mb_off = s->mb_stride * s->mb_height >> 1;
} else {
v->second_field = 0;
v->blocks_off = 0;
v->mb_off = 0;
}
if (i) {
v->pic_header_flag = 0;
if (v->field_mode && i == n_slices1 + 2) {
if (ff_vc1_parse_frame_header_adv(v, &s->gb) < 0) {
av_log(v->s.avctx, AV_LOG_ERROR, "Field header damaged\n");
continue;
}
} else if (get_bits1(&s->gb)) {
v->pic_header_flag = 1;
if (ff_vc1_parse_frame_header_adv(v, &s->gb) < 0) {
av_log(v->s.avctx, AV_LOG_ERROR, "Slice header damaged\n");
continue;
}
}
}
s->start_mb_y = (i == 0) ? 0 : FFMAX(0, slices[i-1].mby_start % mb_height);
if (!v->field_mode || v->second_field)
s->end_mb_y = (i == n_slices ) ? mb_height : FFMIN(mb_height, slices[i].mby_start % mb_height);
else
s->end_mb_y = (i <= n_slices1 + 1) ? mb_height : FFMIN(mb_height, slices[i].mby_start % mb_height);
ff_vc1_decode_blocks(v);
if (i != n_slices)
s->gb = slices[i].gb;
}
if (v->field_mode) {
v->second_field = 0;
if (s->pict_type == AV_PICTURE_TYPE_B) {
memcpy(v->mv_f_base, v->mv_f_next_base,
2 * (s->b8_stride * (s->mb_height * 2 + 1) + s->mb_stride * (s->mb_height + 1) * 2));
}
s->current_picture.f.linesize[0] >>= 1;
s->current_picture.f.linesize[1] >>= 1;
s->current_picture.f.linesize[2] >>= 1;
s->linesize >>= 1;
s->uvlinesize >>= 1;
}
av_dlog(s->avctx, "Consumed %i/%i bits\n",
get_bits_count(&s->gb), s->gb.size_in_bits);
ff_er_frame_end(s);
}
ff_MPV_frame_end(s);
if (avctx->codec_id == AV_CODEC_ID_WMV3IMAGE || avctx->codec_id == AV_CODEC_ID_VC1IMAGE) {
image:
avctx->width = avctx->coded_width = v->output_width;
avctx->height = avctx->coded_height = v->output_height;
if (avctx->skip_frame >= AVDISCARD_NONREF)
goto end;
#if CONFIG_WMV3IMAGE_DECODER || CONFIG_VC1IMAGE_DECODER
if (vc1_decode_sprites(v, &s->gb))
goto err;
#endif
*pict = v->sprite_output_frame;
*data_size = sizeof(AVFrame);
} else {
if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
*pict = s->current_picture_ptr->f;
} else if (s->last_picture_ptr != NULL) {
*pict = s->last_picture_ptr->f;
}
if (s->last_picture_ptr || s->low_delay) {
*data_size = sizeof(AVFrame);
ff_print_debug_info(s, pict);
}
}
end:
av_free(buf2);
for (i = 0; i < n_slices; i++)
av_free(slices[i].buf);
av_free(slices);
return buf_size;
err:
av_free(buf2);
for (i = 0; i < n_slices; i++)
av_free(slices[i].buf);
av_free(slices);
return -1;
}
| 1threat |
Is it "pythonic" to add attributes into class instance in runtime? : <p>Lets say I have a set of class instances to operate on. But I need some additional status variables per instance. The instance is not aware of them.
Is it recommended to simply put such extra variable as attribute into an instance like this:
<code>instances[x].extra_status_attribute = x</code>,
or it is better to keep them separately?</p>
| 0debug |
int av_write_frame(AVFormatContext *s, AVPacket *pkt)
{
int ret;
compute_pkt_fields2(s->streams[pkt->stream_index], pkt);
truncate_ts(s->streams[pkt->stream_index], pkt);
ret= s->oformat->write_packet(s, pkt);
if(!ret)
ret= url_ferror(&s->pb);
return ret;
}
| 1threat |
static uint32_t read_long(const unsigned char *p)
{
return (p[0]<<24)|(p[1]<<16)|(p[2]<<8)|p[3];
}
| 1threat |
How to bring back "Add to home" banner for progressive web app after removed the icon from home screen? : <p>The reason - I made a <code>Progressive web app</code>, opened in the browser - all is fine and browser offered me to add it to home screen.</p>
<p>Now, I want to demonstrate this on a presentation, and so - removed the icon from home screen. But for the last whole day I've been playing with the website in chrome a lot, and the banner never appears back.</p>
<p>Is it really a once-in-a-lifetime thing? Or is there something specific I need to do?</p>
| 0debug |
int qcrypto_cipher_encrypt(QCryptoCipher *cipher,
const void *in,
void *out,
size_t len,
Error **errp)
{
QCryptoCipherBuiltin *ctxt = cipher->opaque;
return ctxt->encrypt(cipher, in, out, len, errp); | 1threat |
static void write_section_data(AVFormatContext *s, MpegTSFilter *tss1,
const uint8_t *buf, int buf_size, int is_start)
{
MpegTSContext *ts = s->priv_data;
MpegTSSectionFilter *tss = &tss1->u.section_filter;
int len;
if (is_start) {
memcpy(tss->section_buf, buf, buf_size);
tss->section_index = buf_size;
tss->section_h_size = -1;
tss->end_of_section_reached = 0;
} else {
if (tss->end_of_section_reached)
return;
len = 4096 - tss->section_index;
if (buf_size < len)
len = buf_size;
memcpy(tss->section_buf + tss->section_index, buf, len);
tss->section_index += len;
}
if (tss->section_h_size == -1 && tss->section_index >= 3) {
len = (AV_RB16(tss->section_buf + 1) & 0xfff) + 3;
if (len > 4096)
return;
tss->section_h_size = len;
}
if (tss->section_h_size != -1 &&
tss->section_index >= tss->section_h_size) {
int crc_valid = 1;
tss->end_of_section_reached = 1;
if (tss->check_crc) {
crc_valid = !av_crc(av_crc_get_table(AV_CRC_32_IEEE), -1, tss->section_buf, tss->section_h_size);
if (crc_valid) {
ts->crc_validity[ tss1->pid ] = 100;
}else if (ts->crc_validity[ tss1->pid ] > -10) {
ts->crc_validity[ tss1->pid ]--;
}else
crc_valid = 2;
}
if (crc_valid)
tss->section_cb(tss1, tss->section_buf, tss->section_h_size);
}
}
| 1threat |
int bdrv_pwritev(BlockDriverState *bs, int64_t offset, QEMUIOVector *qiov)
{
int ret;
ret = bdrv_prwv_co(bs, offset, qiov, true, 0);
if (ret < 0) {
return ret;
}
return qiov->size;
}
| 1threat |
How to Stored entered data into server database in android studio : **How to Stored entered data into server database in android studio** | 0debug |
static int qcow_check(BlockDriverState *bs)
{
return qcow2_check_refcounts(bs);
}
| 1threat |
android studios display name instead of email : How do i make the following code display the name as a welcome instead of the email?? When i just change EMAIL to Name it displys null instead of the name. Any help much appreciated.
Ive tried changing email to name but this dosent work i dont know what else to do.
UsersActivity.java (this is what i want to change so it displays the name instead of email)
package com.delaroystudios.sqlitelogin.activities;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;
import com.delaroystudios.sqlitelogin.R;
public class UsersActivity extends AppCompatActivity {
private TextView textViewName;
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_users);
textViewName = (TextView) findViewById(R.id.text1);
String nameFromIntent = getIntent().getStringExtra("NAME");
textViewName.setText("Welcome " + nameFromIntent);
}
}
LoginActivity.java
package com.delaroystudios.sqlitelogin.activities;
import android.content.Intent;
import android.support.design.widget.Snackbar;
import android.support.design.widget.TextInputEditText;
import android.support.design.widget.TextInputLayout;
import android.support.v4.widget.NestedScrollView;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.AppCompatButton;
import android.support.v7.widget.AppCompatTextView;
import android.view.View;
import com.delaroystudios.sqlitelogin.R;
import com.delaroystudios.sqlitelogin.helper.InputValidation;
import com.delaroystudios.sqlitelogin.sql.DatabaseHelper;
public class LoginActivity extends AppCompatActivity implements View.OnClickListener {
private final AppCompatActivity activity = LoginActivity.this;
private NestedScrollView nestedScrollView;
private TextInputLayout textInputLayoutEmail;
private TextInputLayout textInputLayoutPassword;
private TextInputEditText textInputEditTextEmail;
private TextInputEditText textInputEditTextPassword;
private AppCompatButton appCompatButtonLogin;
private AppCompatTextView textViewLinkRegister;
private InputValidation inputValidation;
private DatabaseHelper databaseHelper;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
getSupportActionBar().hide();
initViews();
initListeners();
initObjects();
}
private void initViews(){
nestedScrollView = (NestedScrollView) findViewById(R.id.nestedScrollView);
textInputLayoutEmail = (TextInputLayout) findViewById(R.id.textInputLayoutEmail);
textInputLayoutPassword = (TextInputLayout) findViewById(R.id.textInputLayoutPassword);
textInputEditTextEmail = (TextInputEditText) findViewById(R.id.textInputEditTextEmail);
textInputEditTextPassword = (TextInputEditText) findViewById(R.id.textInputEditTextPassword);
appCompatButtonLogin = (AppCompatButton) findViewById(R.id.appCompatButtonLogin);
textViewLinkRegister = (AppCompatTextView) findViewById(R.id.textViewLinkRegister);
}
private void initListeners(){
appCompatButtonLogin.setOnClickListener(this);
textViewLinkRegister.setOnClickListener(this);
}
private void initObjects(){
databaseHelper = new DatabaseHelper(activity);
inputValidation = new InputValidation(activity);
}
@Override
public void onClick(View v){
switch (v.getId()){
case R.id.appCompatButtonLogin:
verifyFromSQLite();
break;
case R.id.textViewLinkRegister:
Intent intentRegister = new Intent(getApplicationContext(), RegisterActivity.class);
startActivity(intentRegister);
break;
}
}
private void verifyFromSQLite(){
if (!inputValidation.isInputEditTextFilled(textInputEditTextEmail, textInputLayoutEmail, getString(R.string.error_message_email))) {
return;
}
if (!inputValidation.isInputEditTextEmail(textInputEditTextEmail, textInputLayoutEmail, getString(R.string.error_message_email))) {
return;
}
if (!inputValidation.isInputEditTextFilled(textInputEditTextPassword, textInputLayoutPassword, getString(R.string.error_message_email))) {
return;
}
if (databaseHelper.checkUser(textInputEditTextEmail.getText().toString().trim()
, textInputEditTextPassword.getText().toString().trim())) {
Intent accountsIntent = new Intent(activity, UsersActivity.class);
accountsIntent.putExtra("EMAIL", textInputEditTextEmail.getText().toString().trim());
emptyInputEditText();
startActivity(accountsIntent);
}
else {
Snackbar.make(nestedScrollView, getString(R.string.error_valid_email_password), Snackbar.LENGTH_LONG).show();
}
}
private void emptyInputEditText(){
textInputEditTextEmail.setText(null);
textInputEditTextPassword.setText(null);
}
}
RegisterActivity.java
package com.delaroystudios.sqlitelogin.activities;
import android.os.Bundle;
import android.support.design.widget.Snackbar;
import android.support.design.widget.TextInputEditText;
import android.support.design.widget.TextInputLayout;
import android.support.v4.widget.NestedScrollView;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.AppCompatButton;
import android.support.v7.widget.AppCompatTextView;
import android.view.View;
import com.delaroystudios.sqlitelogin.R;
import com.delaroystudios.sqlitelogin.helper.InputValidation;
import com.delaroystudios.sqlitelogin.model.User;
import com.delaroystudios.sqlitelogin.sql.DatabaseHelper;
public class RegisterActivity extends AppCompatActivity implements View.OnClickListener {
private final AppCompatActivity activity = RegisterActivity.this;
private NestedScrollView nestedScrollView;
private TextInputLayout textInputLayoutName;
private TextInputLayout textInputLayoutEmail;
private TextInputLayout textInputLayoutPassword;
private TextInputLayout textInputLayoutConfirmPassword;
private TextInputEditText textInputEditTextName;
private TextInputEditText textInputEditTextEmail;
private TextInputEditText textInputEditTextPassword;
private TextInputEditText textInputEditTextConfirmPassword;
private AppCompatButton appCompatButtonRegister;
private AppCompatTextView appCompatTextViewLoginLink;
private InputValidation inputValidation;
private DatabaseHelper databaseHelper;
private User user;
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
getSupportActionBar().hide();
initViews();
initListeners();
initObjects();
}
private void initViews(){
nestedScrollView = (NestedScrollView) findViewById(R.id.nestedScrollView);
textInputLayoutName = (TextInputLayout) findViewById(R.id.textInputLayoutName);
textInputLayoutEmail = (TextInputLayout) findViewById(R.id.textInputLayoutEmail);
textInputLayoutPassword = (TextInputLayout) findViewById(R.id.textInputLayoutPassword);
textInputLayoutConfirmPassword = (TextInputLayout) findViewById(R.id.textInputLayoutConfirmPassword);
textInputEditTextName = (TextInputEditText) findViewById(R.id.textInputEditTextName);
textInputEditTextEmail = (TextInputEditText) findViewById(R.id.textInputEditTextEmail);
textInputEditTextPassword = (TextInputEditText) findViewById(R.id.textInputEditTextPassword);
textInputEditTextConfirmPassword = (TextInputEditText) findViewById(R.id.textInputEditTextConfirmPassword);
appCompatButtonRegister = (AppCompatButton) findViewById(R.id.appCompatButtonRegister);
appCompatTextViewLoginLink = (AppCompatTextView) findViewById(R.id.appCompatTextViewLoginLink);
}
private void initListeners(){
appCompatButtonRegister.setOnClickListener(this);
appCompatTextViewLoginLink.setOnClickListener(this);
}
private void initObjects(){
inputValidation = new InputValidation(activity);
databaseHelper = new DatabaseHelper(activity);
user = new User();
}
@Override
public void onClick(View v){
switch (v.getId()){
case R.id.appCompatButtonRegister:
postDataToSQLite();
break;
case R.id.appCompatTextViewLoginLink:
finish();
break;
}
}
private void postDataToSQLite(){
if (!inputValidation.isInputEditTextFilled(textInputEditTextName, textInputLayoutName, getString(R.string.error_message_name))) {
return;
}
if (!inputValidation.isInputEditTextFilled(textInputEditTextEmail, textInputLayoutEmail, getString(R.string.error_message_email))) {
return;
}
if (!inputValidation.isInputEditTextEmail(textInputEditTextEmail, textInputLayoutEmail, getString(R.string.error_message_email))) {
return;
}
if (!inputValidation.isInputEditTextFilled(textInputEditTextPassword, textInputLayoutPassword, getString(R.string.error_message_password))) {
return;
}
if (!inputValidation.isInputEditTextMatches(textInputEditTextPassword, textInputEditTextConfirmPassword,
textInputLayoutConfirmPassword, getString(R.string.error_password_match))) {
return;
}
if (!databaseHelper.checkUser(textInputEditTextEmail.getText().toString().trim())) {
user.setName(textInputEditTextName.getText().toString().trim());
user.setEmail(textInputEditTextEmail.getText().toString().trim());
user.setPassword(textInputEditTextPassword.getText().toString().trim());
databaseHelper.addUser(user);
// Snack Bar to show success message that record saved successfully
Snackbar.make(nestedScrollView, getString(R.string.success_message), Snackbar.LENGTH_LONG).show();
emptyInputEditText();
} else {
// Snack Bar to show error message that record already exists
Snackbar.make(nestedScrollView, getString(R.string.error_email_exists), Snackbar.LENGTH_LONG).show();
}
}
private void emptyInputEditText(){
textInputEditTextName.setText(null);
textInputEditTextEmail.setText(null);
textInputEditTextPassword.setText(null);
textInputEditTextConfirmPassword.setText(null);
}
}
InputValidation.java
package com.delaroystudios.sqlitelogin.helper;
import android.app.Activity;
import android.content.Context;
import android.support.design.widget.TextInputEditText;
import android.support.design.widget.TextInputLayout;
import android.util.Patterns;
import android.view.View;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
public class InputValidation {
private Context context;
public InputValidation(Context context){
this.context = context;
}
public boolean isInputEditTextFilled(TextInputEditText textInputEditText, TextInputLayout textInputLayout, String message){
String value = textInputEditText.getText().toString().trim();
if (value.isEmpty()){
textInputLayout.setError(message);
hideKeyboardFrom(textInputEditText);
return false;
} else {
textInputLayout.setErrorEnabled(false);
}
return true;
}
public boolean isInputEditTextEmail(TextInputEditText textInputEditText, TextInputLayout textInputLayout, String message){
String value = textInputEditText.getText().toString().trim();
if (value.isEmpty() || !Patterns.EMAIL_ADDRESS.matcher(value).matches()){
textInputLayout.setError(message);
hideKeyboardFrom(textInputEditText);
return false;
}else {
textInputLayout.setErrorEnabled(false);
}
return true;
}
public boolean isInputEditTextMatches(TextInputEditText textInputEditText1, TextInputEditText textInputEditText2, TextInputLayout textInputLayout, String message ){
String value1 = textInputEditText1.getText().toString().trim();
String value2 = textInputEditText2.getText().toString().trim();
if (!value1.contentEquals(value2)){
textInputLayout.setError(message);
hideKeyboardFrom(textInputEditText2);
return false;
}else {
textInputLayout.setErrorEnabled(false);
}
return true;
}
private void hideKeyboardFrom(View view){
InputMethodManager imm = (InputMethodManager) context.getSystemService(Activity.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
}
}
User.java
package com.delaroystudios.sqlitelogin.model;
public class User {
private int id;
private String name;
private String email;
private String password;
public int getId(){
return id;
}
public void setId(int id){
this.id = id;
}
public String getName(){
return name;
}
public void setName(String name){
this.name = name;
}
public String getEmail(){
return email;
}
public void setEmail(String email){
this.email = email;
}
public String getPassword(){
return password;
}
public void setPassword(String password){
this.password = password;
}
}
Databasehelper.java
package com.delaroystudios.sqlitelogin.sql;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import com.delaroystudios.sqlitelogin.model.User;
public class DatabaseHelper extends SQLiteOpenHelper{
private static final int DATABASE_VERSION = 1;
private static final String DATABASE_NAME = "UserManager.db";
private static final String TABLE_USER = "user";
private static final String COLUMN_USER_ID = "user_id";
private static final String COLUMN_USER_NAME = "user_name";
private static final String COLUMN_USER_EMAIL = "user_email";
private static final String COLUMN_USER_PASSWORD = "user_password";
private String CREATE_USER_TABLE = "CREATE TABLE " + TABLE_USER + "("
+ COLUMN_USER_ID + " INTEGER PRIMARY KEY AUTOINCREMENT," + COLUMN_USER_NAME + " TEXT,"
+ COLUMN_USER_EMAIL + " TEXT," + COLUMN_USER_PASSWORD + " TEXT" + ")";
private String DROP_USER_TABLE = "DROP TABLE IF EXISTS " + TABLE_USER;
public DatabaseHelper(Context context){
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db){
db.execSQL(CREATE_USER_TABLE);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion){
db.execSQL(DROP_USER_TABLE);
onCreate(db);
}
public void addUser(User user){
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(COLUMN_USER_NAME, user.getName());
values.put(COLUMN_USER_EMAIL, user.getEmail());
values.put(COLUMN_USER_PASSWORD, user.getPassword());
db.insert(TABLE_USER, null, values);
db.close();
}
public boolean checkUser(String email){
String[] columns = {
COLUMN_USER_ID
};
SQLiteDatabase db = this.getWritableDatabase();
String selection = COLUMN_USER_EMAIL + " = ?";
String[] selectionArgs = { email };
Cursor cursor = db.query(TABLE_USER,
columns,
selection,
selectionArgs,
null,
null,
null);
int cursorCount = cursor.getCount();
cursor.close();
db.close();
if (cursorCount > 0){
return true;
}
return false;
}
public boolean checkUser(String email, String password){
String[] columns = {
COLUMN_USER_ID
};
SQLiteDatabase db = this.getWritableDatabase();
String selection = COLUMN_USER_EMAIL + " = ?" + " AND " + COLUMN_USER_PASSWORD + " =?";
String[] selectionArgs = { email, password };
Cursor cursor = db.query(TABLE_USER,
columns,
selection,
selectionArgs,
null,
null,
null);
int cursorCount = cursor.getCount();
cursor.close();
db.close();
if (cursorCount > 0){
return true;
}
return false;
}
}
| 0debug |
Entering data in a input from an other host : <p>I have a question, is possible to send data from an other host in an input of another host?</p>
<p>For example, my host is www.example.com and i wanna send data to an input from the host called www.example2.com. Is it possible with PHP, Python, JavaScript?</p>
| 0debug |
How to list the content of a named volume in docker 1.9+? : <p>Docker 1.9 added named volumes, so I..</p>
<pre><code>docker volume create --name postgres-data
docker volume ls
</code></pre>
<p>and I get</p>
<pre><code>local postgres-data
</code></pre>
<p>all good so far.. </p>
<p>so how do I see what is in the named volume? Is there a way to cd to it on the host system. Like I can for a mounted host directory?</p>
| 0debug |
Can Python make an OS similar to Windows? : <p>I want to make a OS that could be gaming-friendly (like Windows) yet easy to use. I can already use Python perfectly fine, and I'm looking to see if I could make an OS with it. Is it possible? If not, what are some Python-like coding languages that I could use?</p>
<p>I've looked in to Buildroot but it uses the Makefile language which I am extremely confused about, it's just non-logical (at least to me).</p>
<p>I expect it to be possible because C# is <strong><em>quite</em></strong> the complex language and it works fine.</p>
| 0debug |
Java has .class file which is the executable file/ binary file. Same way what is it for Python or Javascript? : <p>In java .class files hide the actual source code and can only be executed. Am new to Python and JavaScript languages, how is source code protected in these languages? Do they also have something similar to .class files where in the source code isn't visible ?</p>
| 0debug |
static abi_ulong mmap_find_vma_reserved(abi_ulong start, abi_ulong size)
{
abi_ulong addr;
abi_ulong end_addr;
int prot;
int looped = 0;
if (size > reserved_va) {
return (abi_ulong)-1;
}
size = HOST_PAGE_ALIGN(size);
end_addr = start + size;
if (end_addr > reserved_va) {
end_addr = reserved_va;
}
addr = end_addr - qemu_host_page_size;
while (1) {
if (addr > end_addr) {
if (looped) {
return (abi_ulong)-1;
}
end_addr = reserved_va;
addr = end_addr - qemu_host_page_size;
looped = 1;
continue;
}
prot = page_get_flags(addr);
if (prot) {
end_addr = addr;
}
if (addr + size == end_addr) {
break;
}
addr -= qemu_host_page_size;
}
if (start == mmap_next_start) {
mmap_next_start = addr;
}
return addr;
}
| 1threat |
Using the $ selector in Chrome Console with on jQuery : <p>I'm wondering why I can use <code>$('.myelement')</code> in Google Chrome console? I thought that was only a jQuery thing. </p>
<p>Is this part of JavaScript? </p>
| 0debug |
int ff_rtsp_open_transport_ctx(AVFormatContext *s, RTSPStream *rtsp_st)
{
RTSPState *rt = s->priv_data;
AVStream *st = NULL;
int reordering_queue_size = rt->reordering_queue_size;
if (reordering_queue_size < 0) {
if (rt->lower_transport == RTSP_LOWER_TRANSPORT_TCP || !s->max_delay)
reordering_queue_size = 0;
else
reordering_queue_size = RTP_REORDER_QUEUE_DEFAULT_SIZE;
}
if (rtsp_st->stream_index >= 0)
st = s->streams[rtsp_st->stream_index];
if (!st)
s->ctx_flags |= AVFMTCTX_NOHEADER;
if (CONFIG_RTSP_MUXER && s->oformat) {
int ret = ff_rtp_chain_mux_open((AVFormatContext **)&rtsp_st->transport_priv,
s, st, rtsp_st->rtp_handle,
RTSP_TCP_MAX_PACKET_SIZE,
rtsp_st->stream_index);
rtsp_st->rtp_handle = NULL;
if (ret < 0)
return ret;
st->time_base = ((AVFormatContext*)rtsp_st->transport_priv)->streams[0]->time_base;
} else if (rt->transport == RTSP_TRANSPORT_RAW) {
return 0;
} else if (CONFIG_RTPDEC && rt->transport == RTSP_TRANSPORT_RDT)
rtsp_st->transport_priv = ff_rdt_parse_open(s, st->index,
rtsp_st->dynamic_protocol_context,
rtsp_st->dynamic_handler);
else if (CONFIG_RTPDEC)
rtsp_st->transport_priv = ff_rtp_parse_open(s, st,
rtsp_st->sdp_payload_type,
reordering_queue_size);
if (!rtsp_st->transport_priv) {
return AVERROR(ENOMEM);
} else if (CONFIG_RTPDEC && rt->transport == RTSP_TRANSPORT_RTP) {
if (rtsp_st->dynamic_handler) {
ff_rtp_parse_set_dynamic_protocol(rtsp_st->transport_priv,
rtsp_st->dynamic_protocol_context,
rtsp_st->dynamic_handler);
}
if (rtsp_st->crypto_suite[0])
ff_rtp_parse_set_crypto(rtsp_st->transport_priv,
rtsp_st->crypto_suite,
rtsp_st->crypto_params);
}
return 0;
}
| 1threat |
How to combine multiple excel file into one? : I have multiple excel file in same format and I want to make a single file. How can I merge them into one single excel file.
Thanks for help in advance. | 0debug |
recursive sub string length : im trying to write a recursive function that receives an array and its size and some other variables (of my choice). the function returns the length of the longest ascending substring in the array. the limitation are no loops and no calling other functions or using pointers or other libraries.
this is the code i wrote, which unfortunately isn't working and i don't understand why!
int max_set(int arr[], int size, int max, int index1, int index2, int
currentMax) {
int path1, path2;
if (index1 == size)
return currentMax;
if (index2 = size){
if (currentMax < max)
currentMax = max;
index1++;
index2 = index1 + 1;
max = 1;
}
if (arr[index2]> arr[index1])
max++;
path1 = max_set(arr, size, max, index1, index2 + 1, currentMax);
path2 = max_set(arr, size, max, index1 + 1, index2 + 1, currentMax);
if (path1 > path2)
return path1;
else
return path2;
}
thank you! | 0debug |
FpPort *fp_port_alloc(Rocker *r, char *sw_name,
MACAddr *start_mac, unsigned int index,
NICPeers *peers)
{
FpPort *port = g_malloc0(sizeof(FpPort));
if (!port) {
return NULL;
}
port->r = r;
port->index = index;
port->pport = index + 1;
port->name = g_strdup_printf("%sp%d", sw_name, port->pport);
memcpy(port->conf.macaddr.a, start_mac, sizeof(port->conf.macaddr.a));
port->conf.macaddr.a[5] += index;
port->conf.bootindex = -1;
port->conf.peers = *peers;
port->nic = qemu_new_nic(&fp_port_info, &port->conf,
sw_name, NULL, port);
qemu_format_nic_info_str(qemu_get_queue(port->nic),
port->conf.macaddr.a);
fp_port_reset(port);
return port;
}
| 1threat |
In Java, if one boolean true then all others become false : <p>I was wondering if it was possible in Java to have a series of booleans such as:</p>
<pre><code> boolean boo1, boo2, boo3, boo4, boo5;
</code></pre>
<p>I want to make it so that if one of these booleans become true than all others become false. I know this can be done with a series of long if statements but is there a simpler way to achieve this.</p>
<p>Thanks!</p>
| 0debug |
Why does VS 2015 allow attributes separated by spaces while VS 2017 does not? : <p>Take the following simple code. The <code>DoMyCode</code> method has two attributes applied to it, with a space between the entries.</p>
<pre><code>using System;
namespace AttributeSpaceTesting
{
class Program
{
static void Main(string[] args) { }
[Horse Cow]
static void DoMyCode() { }
}
[AttributeUsage(AttributeTargets.Method)]
class HorseAttribute : Attribute { }
[AttributeUsage(AttributeTargets.Method)]
class CowAttribute : Attribute { }
}
</code></pre>
<p>This was made in VS 2015 targeting .Net 4.6.</p>
<p>If you run this code in Visual Studio 2015 (update 3) it will compile and run with no errors or warnings.</p>
<p>However, running the exact same code in Visual Studio 2017 will produce the following exception:</p>
<pre>
Syntax error, ',' expected
</pre>
<p>I understand <em>why</em> this error happens. I expect that you would need commas between attribute items. In section 17.2 of the C# 5 specifications:</p>
<blockquote>
<p>An attribute section consists of a pair of square brackets, which surround a comma-separated list of one or more attributes.</p>
</blockquote>
<p>So why is this syntax legal in VS 2015?</p>
<hr>
<p>For full context, I am experimenting with using VS 2017 on my team's unit test projects. I've noticed lines like this:</p>
<pre><code>[Description(@"The Test Description")]
[TestCategory("Regression"), TestCategory("Module"), TestCategory("ModuleRegression") TestMethod]
public void TC_12345_VerifyTheThingWorks()
</code></pre>
<p>which cause syntax errors when compiled in the new Visual Studio system.</p>
| 0debug |
The email address is badly formatted. I don't know what's wrong with this can someone help me. : <p><a href="https://i.stack.imgur.com/PW3Dy.png" rel="nofollow noreferrer">Code is not working, I dont know what was the problem </a></p>
| 0debug |
My site won't display content images : My website won't display images on http://teretana.mk/. When I open the debugging console in Chrome I get 2 errors which I do not understand at all(can be seen here http://i.imgur.com/2tLcsl3.jpg). I hope someone will be able to resolve this issue I've had all day. And hopefully this will fix the images, it's also really weird if you go in a post like this one http://teretana.mk/2016/04/22/td_d_slug_20/ you can actually drag the blank image in Chrome(maybe in other browsers too) and the actual image will display. | 0debug |
Python_Select only the rows with certain condition. (Key words: Duplicates, highest score, drop, functions, select) : ID IP Score
vul1 12.345.678.01 5
vul2 12.345.678.01 7
vul3 12.345.678.01 10
vul4 12.345.678.02 7
vul5 12.345.678.02 10
I have a table that looks like above. I'm using python, and pandas library.
I have different rows that share same IP address. For those rows with duplicate IP addresses, I want to select only one row with highest score (score being from 0-10), and drop all duplicates.
Logically thinking, I need to define a function something like,
"For rowss that share same IP address, select only one row that has highest score. Else (if ID doesn't have duplicate IP address, generate as it is (Or leave it as it is)"
I'm having a difficult time in turning this logic into a python function. Any help will be appreciated!
| 0debug |
int av_image_fill_black(uint8_t *dst_data[4], const ptrdiff_t dst_linesize[4],
enum AVPixelFormat pix_fmt, enum AVColorRange range,
int width, int height)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
int nb_planes = av_pix_fmt_count_planes(pix_fmt);
uint8_t clear_block[4][MAX_BLOCK_SIZE] = {0};
int clear_block_size[4] = {0};
ptrdiff_t plane_line_bytes[4] = {0};
int rgb, limited;
int plane, c;
if (!desc || nb_planes < 1 || nb_planes > 4 || desc->flags & AV_PIX_FMT_FLAG_HWACCEL)
return AVERROR(EINVAL);
rgb = !!(desc->flags & AV_PIX_FMT_FLAG_RGB);
limited = !rgb && range != AVCOL_RANGE_JPEG;
if (desc->flags & AV_PIX_FMT_FLAG_BITSTREAM) {
ptrdiff_t bytewidth = av_image_get_linesize(pix_fmt, width, 0);
uint8_t *data;
int mono = pix_fmt == AV_PIX_FMT_MONOWHITE || pix_fmt == AV_PIX_FMT_MONOBLACK;
int fill = pix_fmt == AV_PIX_FMT_MONOWHITE ? 0xFF : 0;
if (nb_planes != 1 || !(rgb || mono) || bytewidth < 1)
return AVERROR(EINVAL);
if (!dst_data)
return 0;
data = dst_data[0];
for (;height > 0; height--) {
memset(data, fill, bytewidth);
data += dst_linesize[0];
}
return 0;
}
for (c = 0; c < desc->nb_components; c++) {
const AVComponentDescriptor comp = desc->comp[c];
clear_block_size[comp.plane] = FFMAX(clear_block_size[comp.plane], comp.step);
if (clear_block_size[comp.plane] > MAX_BLOCK_SIZE)
return AVERROR(EINVAL);
}
for (c = 0; c < desc->nb_components; c++) {
const AVComponentDescriptor comp = desc->comp[c];
int w = clear_block_size[comp.plane] / comp.step;
uint8_t *c_data[4];
const int c_linesize[4] = {0};
uint16_t src_array[MAX_BLOCK_SIZE];
uint16_t src = 0;
int x;
if (comp.depth > 16)
return AVERROR(EINVAL);
if (!rgb && comp.depth < 8)
return AVERROR(EINVAL);
if (w < 1)
return AVERROR(EINVAL);
if (c == 0 && limited) {
src = 16 << (comp.depth - 8);
} else if ((c == 1 || c == 2) && !rgb) {
src = 128 << (comp.depth - 8);
} else if (c == 3) {
src = (1 << comp.depth) - 1;
}
for (x = 0; x < w; x++)
src_array[x] = src;
for (x = 0; x < 4; x++)
c_data[x] = &clear_block[x][0];
av_write_image_line(src_array, c_data, c_linesize, desc, 0, 0, c, w);
}
for (plane = 0; plane < nb_planes; plane++) {
plane_line_bytes[plane] = av_image_get_linesize(pix_fmt, width, plane);
if (plane_line_bytes[plane] < 0)
return AVERROR(EINVAL);
}
if (!dst_data)
return 0;
for (plane = 0; plane < nb_planes; plane++) {
size_t bytewidth = plane_line_bytes[plane];
uint8_t *data = dst_data[plane];
int chroma_div = plane == 1 || plane == 2 ? desc->log2_chroma_h : 0;
int plane_h = ((height + ( 1 << chroma_div) - 1)) >> chroma_div;
for (; plane_h > 0; plane_h--) {
memset_bytes(data, bytewidth, &clear_block[plane][0], clear_block_size[plane]);
data += dst_linesize[plane];
}
}
return 0;
}
| 1threat |
SImple code runs correctly in DevC++ but not Virtual Studio Code : Code runs fine DevC++ but not Virtual studio Code
Was doing a Homework question. Simple code adding two integers. Code looked fine but running it kept giving me the wrong result. After losing my mind I tried to run it in DevC++ to which it gave me the result I expected
I'm very very new to coding. Virtual studio Code is trying to tell me something in the output window but I don't know what it's is trying to tell me.
````
#include <stdio.h>
int main()
{
double x,y,z;
printf("Enter first number:" );
scanf("%i", &x);
printf("Enter second number:" );
scanf("%i", &y);
printf("the first number is: %d \n",x);
printf("the second number is: %d \n ",y);
z= x+y;
printf("Output 1: The result is %d . \n",z);
printf("Output 2: The sum of %d and %d is %d . ",x,y,z);
return 0;
}
````
-------------------VS Code output Window-------------------------
````
hwidk.cpp:19:8: warning: format '%d' expects argument of type 'int', but argument 2 has type 'double' [-Wformat=]
printf("Output 1: The result is %d . \n",z);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~
[hwidk.cpp 2019-05-27 21:35:01.608]
hwidk.cpp:20:8: warning: format '%d' expects argument of type 'int', but argument 2 has type 'double' [-Wformat=]
printf("Output 2: The sum of %d and %d is %d . ",x,y,z);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~
hwidk.cpp:20:8: warning: format '%d' expects argument of type 'int', but argument 3 has type 'double' [-Wformat=]
[hwidk.cpp 2019-05-27 21:35:01.608]
hwidk.cpp:20:8: warning: format '%d' expects argument of type 'int', but argument 4 has type 'double' [-Wformat=]
````
--------------Virtual Studio Runs the code as------------------------
````
Enter first number:5
Enter second number:6
the first number is: 5
the second number is: 6
Output 1: The result is 7 .
Output 2: The sum of 5 and 0 is 6
```` | 0debug |
int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
AVInputFormat *fmt,
int buf_size,
AVFormatParameters *ap)
{
int err;
AVProbeData probe_data, *pd = &probe_data;
ByteIOContext *pb = NULL;
void *logctx= ap && ap->prealloced_context ? *ic_ptr : NULL;
pd->filename = "";
if (filename)
pd->filename = filename;
pd->buf = NULL;
pd->buf_size = 0;
if (!fmt) {
fmt = av_probe_input_format(pd, 0);
}
if (!fmt || !(fmt->flags & AVFMT_NOFILE)) {
if ((err=url_fopen(&pb, filename, URL_RDONLY)) < 0) {
goto fail;
}
if (buf_size > 0) {
url_setbufsize(pb, buf_size);
}
if ((err = ff_probe_input_buffer(&pb, &fmt, filename, logctx, 0, 0)) < 0) {
goto fail;
}
}
if (!fmt) {
err = AVERROR_NOFMT;
goto fail;
}
if (fmt->flags & AVFMT_NEEDNUMBER) {
if (!av_filename_number_test(filename)) {
err = AVERROR_NUMEXPECTED;
goto fail;
}
}
err = av_open_input_stream(ic_ptr, pb, filename, fmt, ap);
if (err)
goto fail;
return 0;
fail:
av_freep(&pd->buf);
if (pb)
url_fclose(pb);
if (ap && ap->prealloced_context)
av_free(*ic_ptr);
*ic_ptr = NULL;
return err;
}
| 1threat |
How to add worksheet tab name in excel in SSRS Report : <p>I have multiple tab in my report and generate multiple worksheet tab name in excel.</p>
<p>How to add worksheet tab name in excel in SSRS Report</p>
| 0debug |
In a type trait, why do people use enum rather than static const for the value? : <p>For example, this is how I would write it, and it compiles and works just fine:</p>
<pre><code>template<typename T> struct is_pointer<T*> {
static const bool value = true;
}
</code></pre>
<p>Then why do some people write the less obvious</p>
<pre><code>template<typename T> struct is_pointer<T*> {
enum { value = true };
}
</code></pre>
<p>instead? Is it only because the <code>static const</code> variable uses a byte of memory, whereas the <code>enum</code> doesn't?</p>
| 0debug |
static int decode_exponents(GetBitContext *gbc, int exp_strategy, int ngrps,
uint8_t absexp, int8_t *dexps)
{
int i, j, grp, group_size;
int dexp[256];
int expacc, prevexp;
group_size = exp_strategy + (exp_strategy == EXP_D45);
for(grp=0,i=0; grp<ngrps; grp++) {
expacc = get_bits(gbc, 7);
dexp[i++] = ungroup_3_in_7_bits_tab[expacc][0];
dexp[i++] = ungroup_3_in_7_bits_tab[expacc][1];
dexp[i++] = ungroup_3_in_7_bits_tab[expacc][2];
}
prevexp = absexp;
for(i=0,j=0; i<ngrps*3; i++) {
prevexp += dexp[i] - 2;
if (prevexp < 0 || prevexp > 24)
return -1;
switch (group_size) {
case 4: dexps[j++] = prevexp;
dexps[j++] = prevexp;
case 2: dexps[j++] = prevexp;
case 1: dexps[j++] = prevexp;
}
}
return 0;
}
| 1threat |
Matrix conversion : <p>How do I convert the following column matrix:</p>
<pre><code>129
83
83
83
83
83
47
47
45
45
45
45
112
129
83
83
83
83
39
39
47
46
45
112
112
112
.
.
.
</code></pre>
<p>into this (using awk):</p>
<pre><code>129
83
47
45
129
83
39
47
46
45
112
.
.
.
</code></pre>
<p>Basically, if I have any consecutive instances of a string, I would like to remove any copies. However, for a single instance of '112', I would like to remove it altogether, unless there are at least 2 or more consecutive instances of '112', then I would like to keep a copy of it. Thanks!</p>
| 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.