problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
When to use ngrx/effect in angular2 : <p>I have an anuglar2 project that communicates with an api. Recently, I decided to integrate ngrx/store to maintain the state of the components, and follow the dump-smart component architecture. But then while moving on, I read about ngrx/effect which can be used upon the api requests.</p>
<p>And here my question comes, why should I use the ngrx/effect library, over just calling the corresponding function in my service from my container component to perform the api request and on success dispatch action to save the returned values in my store.</p>
| 0debug
|
how to store separated values with ',' and store it in database : i am trying to get multiple values separated with , from a single text box and store it in array and store it in database in each separated cell
> page save with the name of 'index.php'
There is Form
> `<form action="index.php" method=post>
<td>checking array implode</td>
<td><input name="implo" type="text" /></td>
</form>`
| 0debug
|
void dump_mmu(FILE *f, fprintf_function cpu_fprintf, CPUPPCState *env)
{
switch (env->mmu_model) {
case POWERPC_MMU_BOOKE:
mmubooke_dump_mmu(f, cpu_fprintf, env);
break;
case POWERPC_MMU_BOOKE206:
mmubooke206_dump_mmu(f, cpu_fprintf, env);
break;
case POWERPC_MMU_SOFT_6xx:
case POWERPC_MMU_SOFT_74xx:
mmu6xx_dump_mmu(f, cpu_fprintf, env);
break;
#if defined(TARGET_PPC64)
case POWERPC_MMU_64B:
case POWERPC_MMU_2_03:
case POWERPC_MMU_2_06:
case POWERPC_MMU_2_07:
dump_slb(f, cpu_fprintf, env);
break;
#endif
default:
qemu_log_mask(LOG_UNIMP, "%s: unimplemented\n", __func__);
}
}
| 1threat
|
working of these two lines of code in the program : <pre><code>total+=!used[str[i]-'a'];
used[str[i]-'a']=1;
</code></pre>
<p>It is the condition for checking the characters and saving the value in the variable total.</p>
| 0debug
|
Remove type hints in Python source programmatically : <p>I have some source code written for Python 3.5 that I want to make executable under Python 3.4. The only feature from 3.5 that I use which is not available in 3.4 are type hints, so I'd like to write a script to remove those entirely.</p>
<p>This seemed easy enough at first glance and I decided to write some regexes to do this, but then I thought about a few edge cases and I wasn't sure how to solve the problem for a more complex function like this:</p>
<pre><code>def foo(bar: Dict[T, List[T]],
baz: Callable[[T], int] = lambda x: (x+3)/7,
**kwargs) -> List[T]:
</code></pre>
<p>Basically, I'd have to parse the whole thing and rebuild the argument list without type annotations. How would I even approach this?</p>
| 0debug
|
Powershell - search through a file with multiple searches and remove matches in the file : I have a text file containing a single column of IMEI's (file1.txt). I have a second file containing a single column of IMEI's (file2.txt).
What I'm trying to do is take each IMEI in file2.txt and search through file1.txt locating any matches and then when it finds a match, remove that line in file1.txt.
What's making it difficult is the multiple searches I need to perform at once. Doing each one at a time would take quite a while as there are hundreds of IMEI's in each file.
Does anyone have any suggestions to accomplish this task?
Thanks!
| 0debug
|
C# high score in game : <p>Bassicaly I'm stucked with displaying high scores via listbox by discending order(like 500 to 1). Here is my code, keep in mind that label1 is score in the game, so if anyone may help me please? </p>
<pre><code>{
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
}
private void Form3_Load(object sender, EventArgs e)
{
label1.Text = Form2.passingText;
StreamWriter q = new StreamWriter("C:\\Users\\BS\\Desktop\\tex.txt", true);
q.WriteLine(label1.Text);
q.Close();
StreamReader sr = new StreamReader("C:\\Users\\BS\\Desktop\\tex.txt");
string g = sr.ReadLine();
while (g != null)
{
listBox1.Items.Add(g);
g = sr.ReadLine();
}
sr.Close();
}
private void button1_Click(object sender, EventArgs e)
{
this.Close();
}
}
</code></pre>
<p>}</p>
| 0debug
|
int qio_channel_socket_listen_sync(QIOChannelSocket *ioc,
SocketAddressLegacy *addr,
Error **errp)
{
int fd;
trace_qio_channel_socket_listen_sync(ioc, addr);
fd = socket_listen(addr, errp);
if (fd < 0) {
trace_qio_channel_socket_listen_fail(ioc);
return -1;
}
trace_qio_channel_socket_listen_complete(ioc, fd);
if (qio_channel_socket_set_fd(ioc, fd, errp) < 0) {
close(fd);
return -1;
}
qio_channel_set_feature(QIO_CHANNEL(ioc), QIO_CHANNEL_FEATURE_LISTEN);
return 0;
}
| 1threat
|
static uint32_t acpi_find_vgia(void)
{
uint32_t rsdp_offset;
uint32_t guid_offset = 0;
AcpiRsdpDescriptor rsdp_table;
uint32_t rsdt;
AcpiRsdtDescriptorRev1 rsdt_table;
int tables_nr;
uint32_t *tables;
AcpiTableHeader ssdt_table;
VgidTable vgid_table;
int i;
for (i = 0; i < RSDP_TRIES_MAX; i++) {
rsdp_offset = acpi_find_rsdp_address();
if (rsdp_offset < RSDP_ADDR_INVALID) {
break;
}
g_usleep(RSDP_SLEEP_US);
}
g_assert_cmphex(rsdp_offset, <, RSDP_ADDR_INVALID);
acpi_parse_rsdp_table(rsdp_offset, &rsdp_table);
rsdt = rsdp_table.rsdt_physical_address;
ACPI_READ_TABLE_HEADER(&rsdt_table, rsdt);
ACPI_ASSERT_CMP(rsdt_table.signature, "RSDT");
tables_nr = (rsdt_table.length - sizeof(AcpiRsdtDescriptorRev1)) /
sizeof(uint32_t);
g_assert_cmpint(tables_nr, >, 0);
tables = g_new0(uint32_t, tables_nr);
ACPI_READ_ARRAY_PTR(tables, tables_nr, rsdt);
for (i = 0; i < tables_nr; i++) {
ACPI_READ_TABLE_HEADER(&ssdt_table, tables[i]);
if (!strncmp((char *)ssdt_table.oem_table_id, "VMGENID", 7)) {
ACPI_READ_FIELD(vgid_table.name_op, tables[i]);
g_assert(vgid_table.name_op == 0x08);
ACPI_READ_ARRAY(vgid_table.vgia, tables[i]);
g_assert(memcmp(vgid_table.vgia, "VGIA", 4) == 0);
ACPI_READ_FIELD(vgid_table.val_op, tables[i]);
g_assert(vgid_table.val_op == 0x0C);
ACPI_READ_FIELD(vgid_table.vgia_val, tables[i]);
guid_offset = vgid_table.vgia_val + VMGENID_GUID_OFFSET;
break;
}
}
g_free(tables);
return guid_offset;
}
| 1threat
|
How to Change Multiple lines of Numbers with URL in PHP : <p>I have a list of Numbers I want to change it in URL. </p>
<pre><code><?php
$data "3337315417
3353100401
3337353827
3362572506";
?>
</code></pre>
<p>I want to change all of above listed numbers with URLs like below.</p>
<pre><code><a href="https://wa.me/3337315417" >3337315417</a>
<a href="https://wa.me/3353100401" >3353100401</a>
<a href="https://wa.me/3337353827" >3337353827</a>
<a href="https://wa.me/3362572506" >3362572506</a>
</code></pre>
<p>Please tell me how to do this in PHP</p>
| 0debug
|
POWERPC_FAMILY(POWER9)(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc);
dc->fw_name = "PowerPC,POWER9";
dc->desc = "POWER9";
dc->props = powerpc_servercpu_properties;
pcc->pvr_match = ppc_pvr_match_power9;
pcc->pcr_mask = PCR_COMPAT_2_05 | PCR_COMPAT_2_06 | PCR_COMPAT_2_07;
pcc->pcr_supported = PCR_COMPAT_3_00 | PCR_COMPAT_2_07 | PCR_COMPAT_2_06 |
PCR_COMPAT_2_05;
pcc->init_proc = init_proc_POWER9;
pcc->check_pow = check_pow_nocheck;
pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | PPC_STRING | PPC_MFTB |
PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES |
PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE |
PPC_FLOAT_FRSQRTES |
PPC_FLOAT_STFIWX |
PPC_FLOAT_EXT |
PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ |
PPC_MEM_SYNC | PPC_MEM_EIEIO |
PPC_MEM_TLBIE | PPC_MEM_TLBSYNC |
PPC_64B | PPC_64BX | PPC_ALTIVEC |
PPC_SEGMENT_64B | PPC_SLBI |
PPC_POPCNTB | PPC_POPCNTWD |
PPC_CILDST;
pcc->insns_flags2 = PPC2_VSX | PPC2_VSX207 | PPC2_DFP | PPC2_DBRX |
PPC2_PERM_ISA206 | PPC2_DIVE_ISA206 |
PPC2_ATOMIC_ISA206 | PPC2_FP_CVT_ISA206 |
PPC2_FP_TST_ISA206 | PPC2_BCTAR_ISA207 |
PPC2_LSQ_ISA207 | PPC2_ALTIVEC_207 |
PPC2_ISA205 | PPC2_ISA207S | PPC2_FP_CVT_S64 |
PPC2_TM | PPC2_PM_ISA206 | PPC2_ISA300;
pcc->msr_mask = (1ull << MSR_SF) |
(1ull << MSR_TM) |
(1ull << MSR_VR) |
(1ull << MSR_VSX) |
(1ull << MSR_EE) |
(1ull << MSR_PR) |
(1ull << MSR_FP) |
(1ull << MSR_ME) |
(1ull << MSR_FE0) |
(1ull << MSR_SE) |
(1ull << MSR_DE) |
(1ull << MSR_FE1) |
(1ull << MSR_IR) |
(1ull << MSR_DR) |
(1ull << MSR_PMM) |
(1ull << MSR_RI) |
(1ull << MSR_LE);
pcc->mmu_model = POWERPC_MMU_3_00;
#if defined(CONFIG_SOFTMMU)
pcc->handle_mmu_fault = ppc_hash64_handle_mmu_fault;
pcc->sps = &POWER7_POWER8_sps;
#endif
pcc->excp_model = POWERPC_EXCP_POWER8;
pcc->bus_model = PPC_FLAGS_INPUT_POWER7;
pcc->bfd_mach = bfd_mach_ppc64;
pcc->flags = POWERPC_FLAG_VRE | POWERPC_FLAG_SE |
POWERPC_FLAG_BE | POWERPC_FLAG_PMM |
POWERPC_FLAG_BUS_CLK | POWERPC_FLAG_CFAR |
POWERPC_FLAG_VSX | POWERPC_FLAG_TM;
pcc->l1_dcache_size = 0x8000;
pcc->l1_icache_size = 0x8000;
pcc->interrupts_big_endian = ppc_cpu_interrupts_big_endian_lpcr;
}
| 1threat
|
static void gen_addq(DisasContext *s, TCGv val, int rlow, int rhigh)
{
TCGv tmp;
TCGv tmpl;
TCGv tmph;
tmpl = load_reg(s, rlow);
tmph = load_reg(s, rhigh);
tmp = tcg_temp_new(TCG_TYPE_I64);
tcg_gen_concat_i32_i64(tmp, tmpl, tmph);
dead_tmp(tmpl);
dead_tmp(tmph);
tcg_gen_add_i64(val, val, tmp);
}
| 1threat
|
How to make a Javascript canvas button change function : <p>So I have a working javascript canvas button. Essentially what I am trying to do is make it so that once the button is pressed it will do something different when it is pressed again. I am relatively new to programming and cannot seem to work out a way to do it. Any advice and help would be great.</p>
| 0debug
|
python Tkinter and flask runtime 0xC0000005 : i can't show the code .
I made a gui for tkinter and a api for flask .
gui start a Thread and api start as a Thread . Api got a queue ,when i request to api . A value put to queue .Then gui's thread always get the queue . while got it .change the label. But now when I request .the gui exit for code 0xC0000005.
| 0debug
|
static void block_dirty_bitmap_clear_prepare(BlkActionState *common,
Error **errp)
{
BlockDirtyBitmapState *state = DO_UPCAST(BlockDirtyBitmapState,
common, common);
BlockDirtyBitmap *action;
if (action_check_completion_mode(common, errp) < 0) {
return;
}
action = common->action->u.block_dirty_bitmap_clear.data;
state->bitmap = block_dirty_bitmap_lookup(action->node,
action->name,
&state->bs,
&state->aio_context,
errp);
if (!state->bitmap) {
return;
}
if (bdrv_dirty_bitmap_frozen(state->bitmap)) {
error_setg(errp, "Cannot modify a frozen bitmap");
return;
} else if (!bdrv_dirty_bitmap_enabled(state->bitmap)) {
error_setg(errp, "Cannot clear a disabled bitmap");
return;
}
bdrv_clear_dirty_bitmap(state->bitmap, &state->backup);
}
| 1threat
|
static int ff_asf_get_packet(AVFormatContext *s, AVIOContext *pb)
{
ASFContext *asf = s->priv_data;
uint32_t packet_length, padsize;
int rsize = 8;
int c, d, e, off;
off= 32768;
if (s->packet_size > 0)
off= (avio_tell(pb) - s->data_offset) % s->packet_size + 3;
c=d=e=-1;
while(off-- > 0){
c=d; d=e;
e= avio_r8(pb);
if(c == 0x82 && !d && !e)
break;
if (c != 0x82) {
if (pb->error == AVERROR(EAGAIN))
return AVERROR(EAGAIN);
if (!pb->eof_reached)
av_log(s, AV_LOG_ERROR, "ff asf bad header %x at:%"PRId64"\n", c, avio_tell(pb));
if ((c & 0x8f) == 0x82) {
if (d || e) {
if (!pb->eof_reached)
av_log(s, AV_LOG_ERROR, "ff asf bad non zero\n");
c= avio_r8(pb);
d= avio_r8(pb);
rsize+=3;
}else{
avio_seek(pb, -1, SEEK_CUR);
asf->packet_flags = c;
asf->packet_property = d;
DO_2BITS(asf->packet_flags >> 5, packet_length, s->packet_size);
DO_2BITS(asf->packet_flags >> 1, padsize, 0);
DO_2BITS(asf->packet_flags >> 3, padsize, 0);
if(!packet_length || packet_length >= (1U<<29)){
av_log(s, AV_LOG_ERROR, "invalid packet_length %d at:%"PRId64"\n", packet_length, avio_tell(pb));
if(padsize >= packet_length){
av_log(s, AV_LOG_ERROR, "invalid padsize %d at:%"PRId64"\n", padsize, avio_tell(pb));
asf->packet_timestamp = avio_rl32(pb);
avio_rl16(pb);
if (asf->packet_flags & 0x01) {
asf->packet_segsizetype = avio_r8(pb); rsize++;
asf->packet_segments = asf->packet_segsizetype & 0x3f;
} else {
asf->packet_segments = 1;
asf->packet_segsizetype = 0x80;
asf->packet_size_left = packet_length - padsize - rsize;
if (packet_length < asf->hdr.min_pktsize)
padsize += asf->hdr.min_pktsize - packet_length;
asf->packet_padsize = padsize;
av_dlog(s, "packet: size=%d padsize=%d left=%d\n", s->packet_size, asf->packet_padsize, asf->packet_size_left);
return 0;
| 1threat
|
Multiple value in a dictionary key : <p>Is there any way to add multiple value in a dictionary key one by one. Suppose we have dictionary Dict and we want to insert value 3 and 4 with the associated key "xxx", 9 and 10 with key YYY. I want to add them one by one not by making a list.</p>
<p>Example is like this</p>
<pre><code>Dict[xxx]=3
Dict[YYY]=9
Dict[xxx]=4
Dict[YYY]=10
</code></pre>
<p>In this way the last value is retaining with the key XXX. Any other way to do this. Please let me know.</p>
| 0debug
|
RGBA COLOR MODEL : <p>I want to convert my rgb images to equivalent rgba so that i can extract transparency information of each pixel. Please help me. Your response will be highly appreciated.
Thanks in advance.</p>
| 0debug
|
static uint64_t jazz_led_read(void *opaque, target_phys_addr_t addr,
unsigned int size)
{
LedState *s = opaque;
uint8_t val;
val = s->segments;
trace_jazz_led_read(addr, val);
return val;
}
| 1threat
|
Fetch a single tag from remote repository : <p>This command fetches <strong>all</strong> tags:</p>
<pre><code>git fetch origin --tags
</code></pre>
<p>This command fetches a specific tag:</p>
<pre><code>git fetch origin refs/tags/1.0.0
</code></pre>
<p><strong>But</strong> that doesn't let me do:</p>
<pre><code>git checkout tags/2.3.18
</code></pre>
<p>How can I fetch a single tag and then perform a checkout?</p>
| 0debug
|
How creat a table in JS java script : :)
I'm trying create one simple thing, so let me try explain, where say "table here" is supposed appear one table with 4 columns and 6 lines of course, with content inside of cells.
Unfortunately I don't know how make this in java script.
code that I already have below:
_______________________________
<form name="part">
<p align="center">
</p>
<p align="center">
<font face="Verdana" size="2">Please insert the part ID in the field
below:</font></p>
<p align="center">
<font face="Verdana" size="2">Part ID</font><font face="Verdana"><font size="2"> </font><input type="text" name="userid" size="19"/></font></p>
<p align="center"><font face="Verdana"><font size="2">
<p align="center">
<input type="button" onclick="check(this.form)" value="Check now" style="font-family: Verdana"/><font face="Verdana" size="2">
</font>
<input type="reset" value="Cancel" style="font-family: Verdana"/></p>
</form>
<font face="Verdana" size="2">
<script language="javascript">
function check(form) {
if(form.userid.value == "1"){
document.write("table here");
}
else if(form.userid.value == "2"){
document.write("table 2 here");
}
else {
alert("The Part does not esxist\nor does not have compatibility") }
}
</script>
</font>
________________________________
I hope that you can help me! :)
| 0debug
|
av_cold void ff_vp8dsp_init_ppc(VP8DSPContext *c)
{
#if HAVE_ALTIVEC
if (!(av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC))
return;
c->put_vp8_epel_pixels_tab[0][0][0] = put_vp8_pixels16_altivec;
c->put_vp8_epel_pixels_tab[0][0][2] = put_vp8_epel16_h6_altivec;
c->put_vp8_epel_pixels_tab[0][2][0] = put_vp8_epel16_v6_altivec;
c->put_vp8_epel_pixels_tab[0][2][2] = put_vp8_epel16_h6v6_altivec;
c->put_vp8_epel_pixels_tab[1][0][2] = put_vp8_epel8_h6_altivec;
c->put_vp8_epel_pixels_tab[1][2][0] = put_vp8_epel8_v6_altivec;
c->put_vp8_epel_pixels_tab[1][0][1] = put_vp8_epel8_h4_altivec;
c->put_vp8_epel_pixels_tab[1][1][0] = put_vp8_epel8_v4_altivec;
c->put_vp8_epel_pixels_tab[1][2][2] = put_vp8_epel8_h6v6_altivec;
c->put_vp8_epel_pixels_tab[1][1][1] = put_vp8_epel8_h4v4_altivec;
c->put_vp8_epel_pixels_tab[1][1][2] = put_vp8_epel8_h6v4_altivec;
c->put_vp8_epel_pixels_tab[1][2][1] = put_vp8_epel8_h4v6_altivec;
c->put_vp8_epel_pixels_tab[2][0][2] = put_vp8_epel4_h6_altivec;
c->put_vp8_epel_pixels_tab[2][2][0] = put_vp8_epel4_v6_altivec;
c->put_vp8_epel_pixels_tab[2][0][1] = put_vp8_epel4_h4_altivec;
c->put_vp8_epel_pixels_tab[2][1][0] = put_vp8_epel4_v4_altivec;
c->put_vp8_epel_pixels_tab[2][2][2] = put_vp8_epel4_h6v6_altivec;
c->put_vp8_epel_pixels_tab[2][1][1] = put_vp8_epel4_h4v4_altivec;
c->put_vp8_epel_pixels_tab[2][1][2] = put_vp8_epel4_h6v4_altivec;
c->put_vp8_epel_pixels_tab[2][2][1] = put_vp8_epel4_h4v6_altivec;
#endif
}
| 1threat
|
uint32_t ldub_phys(target_phys_addr_t addr)
{
uint8_t val;
cpu_physical_memory_read(addr, &val, 1);
return val;
}
| 1threat
|
swagger error: Conflicting schemaIds: Duplicate schemaIds detected for types A and B : <p>Using Web API and using swashbuckle to generate swagger documentation,
I defined two different classes with the same name in two different namespaces. when I open swagger page in my browser it says</p>
<blockquote>
<p>Conflicting schemaIds: Duplicate schemaIds detected for types A and B. See the config setting - "UseFullTypeNameInSchemaIds" for a potential workaround</p>
</blockquote>
<p>full message:</p>
<blockquote>
<p>500 : {"Message":"An error has occurred.","ExceptionMessage":"Conflicting schemaIds: Duplicate schemaIds detected for types A and B. See the config setting - \"UseFullTypeNameInSchemaIds\" for a potential workaround","ExceptionType":"System.InvalidOperationException","StackTrace":" at Swashbuckle.Swagger.SchemaRegistry.CreateRefSchema(Type type)\r\n at Swashbuckle.Swagger.SchemaRegistry.CreateInlineSchema(Type type)\r\n at Swashbuckle.Swagger.SchemaRegistry.b__1f(JsonProperty prop)\r\n at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable<code>1 source, Func</code>2 keySelector, Func<code>2 elementSelector, IEqualityComparer</code>1 comparer)\r\n at Swashbuckle.Swagger.SchemaRegistry.CreateObjectSchema(JsonObjectContract jsonContract)\r\n at Swashbuckle.Swagger.SchemaRegistry.CreateDefinitionSchema(Type type)\r\n at Swashbuckle.Swagger.SchemaRegistry.GetOrRegister(Type type)\r\n at Swashbuckle.Swagger.SwaggerGenerator.CreateOperation(ApiDescription apiDesc, SchemaRegistry schemaRegistry)\r\n at Swashbuckle.Swagger.SwaggerGenerator.CreatePathItem(IEnumerable<code>1 apiDescriptions, SchemaRegistry schemaRegistry)\r\n at Swashbuckle.Swagger.SwaggerGenerator.<>c__DisplayClass7.<GetSwagger>b__4(IGrouping</code>2 group)\r\n at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable<code>1 source, Func</code>2 keySelector, Func<code>2 elementSelector, IEqualityComparer</code>1 comparer)\r\n at Swashbuckle.Swagger.SwaggerGenerator.GetSwagger(String rootUrl, String apiVersion)\r\n at Swashbuckle.Application.SwaggerDocsHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n at System.Net.Http.HttpMessageInvoker.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n at System.Web.Http.Dispatcher.HttpRoutingDispatcher.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n at System.Net.Http.DelegatingHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n at System.Web.Http.HttpServer.d__0.MoveNext()"} <a href="http://localhost:24215/swagger/docs/v1" rel="noreferrer">http://localhost:24215/swagger/docs/v1</a></p>
</blockquote>
<p>I don't want to change my classes' names. How can I fix it?</p>
| 0debug
|
mobx + react unexpected token : <p>so i created an app with react without configuration from <a href="https://facebook.github.io/react/blog/2016/07/22/create-apps-with-no-configuration.html" rel="noreferrer">https://facebook.github.io/react/blog/2016/07/22/create-apps-with-no-configuration.html</a></p>
<p>I installed mobx and mobx-react ,but is still shows the error of unexpected token before @ symb.</p>
<p>Do I need to add something else, or my current configuration is wrong ?:(</p>
<p>package.json</p>
<pre><code>"devDependencies": {
"react-scripts": "0.8.4",
"babel-core": "^6.7.6",
"babel-loader": "^6.2.4",
"babel-preset-es2015": "^6.6.0",
"babel-preset-react": "^6.5.0",
"babel-preset-stage-0": "^6.5.0"
},
"dependencies": {
"autobind-decorator": "^1.3.4",
"classnames": "^2.2.5",
"lodash": "^4.15.0",
"mobx": "^2.5.1",
"mobx-react": "^3.5.5",
"react": "^15.3.1",
"react-dom": "^15.3.1",
"validator": "^5.6.0"
},
</code></pre>
<p>.babelrc</p>
<pre><code>{
"presets": ["es2015", "stage-0", "react"],
"plugins": [
"transform-decorators-legacy",
"transform-class-properties"
]
}
</code></pre>
<p>And the code</p>
<pre><code>import React, { Component } from 'react';
import { action, observable } from 'mobx'
import {observer} from 'mobx-react';
class App {
@observer cake = [];
}
export default new App();
</code></pre>
| 0debug
|
I'm new user of laravel and em using laravel in phptorm and its not working like it dont recognize @yield @extend or @if @else etc : [You can see the @if @else it print as it in chrome on run. ][1]
[1]: https://i.stack.imgur.com/IHVfI.png
| 0debug
|
save result in new table sql : How can I save the data into a new table?
<!-- begin snippet: js hide: false -->
<!-- language: lang-js -->
SELECT
produse.DENUMIRE,
clase.CLASA,
furnizori.NUME_J,
furnizori.NUME_F,
stoc.CANTITATE,
produse.PRET,
produse.VALUTA,
stare.STARE
FROM clase
JOIN produse ON produse.ID_CLASA = clase.ID
JOIN furnizori ON produse.ID_FURNIZOR = furnizori.ID
JOIN stoc ON stoc.ID_PRODUS = produse.ID
JOIN stare ON stare.ID = stoc.ID_STARE;
<!-- end snippet -->
Thank you very much!
| 0debug
|
How to hide repeated date : I have table like this
[Click here][1]
But I want this type of records in table like this
[Click here][2]
[1]: https://i.stack.imgur.com/h80S3.jpg
[2]: https://i.stack.imgur.com/aF0ti.jpg
| 0debug
|
How is the parameter "weight" (DMatrix) used in the gradient boosting procedure (xgboost)? : <p>In xgboost it is possible to set the parameter <code>weight</code> for a <code>DMatrix</code>. This is apparently a list of weights wherein each value is a weight for a corresponding sample.
I can't find any information on how these weights are actually used in the gradient boosting procedure. Are they related to <code>eta</code> ? </p>
<p>For example, if I would set <code>weight</code> to 0.3 for all samples and <code>eta</code> to 1, would this be the same as setting <code>eta</code> to 0.3 and <code>weight</code> to 1?</p>
| 0debug
|
Add-Member inside an outside Foreach loop not exporting iterations to CSV : Foreach ($s in $servers)
{
Foreach ($srv in $services)
{
$Asrv = Get-Service -Name $srv -ComputerName $s
if($Asrv -ne $null)
{
$HashSrvs.Add($Asrv.Name, $Asrv.Status)
}
}
$infoObject = @()
$infoObject = New-Object PSObject
$infoObject | Add-Member -memberType NoteProperty -name "OS_Version" -value $OSVersion
$infoObject | Add-Member -memberType NoteProperty -name "Server Status Availability" -value $ConStatus
$i=0
***foreach ($key in $HashSrvs.GetEnumerator())***
{
$infoObject | Add-Member -memberType NoteProperty -name "Service Name[$i]" -value $key.Key -Force
$infoObject | Add-Member -memberType NoteProperty -name "Service Status[$i]" -value $key.Value -Force
$i++
}
$infoColl += $infoObject
}
$infoColl | Export-Csv -NoTypeInformation -path .\Server_Inventory_$((Get-Date).ToString('MM-dd-yyyy')).csv -Encoding UTF8
The Output is Correct. No Error Shown. The Error occurs at the CSV file ,the Members inside the highlighted Foreach loop is not iterated. It stops at "Service Name[0]" and "Service Status[0]".
| 0debug
|
Files transfer to HDFS : <p>I need to bring the files (zip, csv, xml etc) from windows share location to HDFS. Which is the best approach ? I have kafka - flume - hdfs in mind. Please suggest the efficient way.</p>
<p>I tried getting the files to Kafka consumer.</p>
<p>producer.send(
new ProducerRecord(topicName,key,value),</p>
<p>Expect an efficient approach</p>
| 0debug
|
unable to use Mixins in vue with typescript : <p>I have a folder structure like this </p>
<pre><code>--Page
-group.vue
--Services
-groupMixin.ts
</code></pre>
<p>script of group.vue</p>
<pre><code><script lang="ts">
import { Vue, Component, Mixins } from 'vue-property-decorator'
import { GroupMixin } from '../../services/groupMixin';
@Component
export default class Group extends Mixins(GroupMixin) {
created () {
console.log(this.test)
}
}
</script>
</code></pre>
<p>code of groupMixin.ts</p>
<pre><code>import { Vue } from 'vue-property-decorator'
//creating mixins.
export class GroupMixin extends Vue {
test: string = 'sss'
}
</code></pre>
<p>I am facing two problems here.</p>
<p>First, to import a ts file i used ../../, is there any way to use ./ or @/. Without using lang="ts", i can import a js file like this @/services/...</p>
<p>Second, not able to access the varaible <strong>test</strong> which i declared in groupmixin.ts.</p>
| 0debug
|
Non-programmer needs help finding click-counter for NFP website, written in iframe : I am a non-programmer working for a church. We have no tech staff. Our website is based upon a template that doesn't provide a widget for counting clicks. We'd like to add one (or preferably two) jpg image(s) with a counter(s) to track the number of times clicked, and display the cumulative total next to the jpg(s). Church members will go to the page and click each time they participate in one or both of two different church objectives.
Our web host says to do this I must find, write, or purchase 3rd party code written in iframe, to embed into one of our pages.
I googled the issue and am only finding hit counters which track visitors to a page, rather than clicks of an image. We'd prefer two different jpgs to track two different objectives, but if necessary I can change from two jpgs to one, if having two counters on the same page is a problem.
Can anyone point me to where I could get code like this either for free, or for pay, and what it would cost?
| 0debug
|
Read lines in file after given string and store each line in variable : <p>I have a textfile and I want to read every line after a specific string in this text and store each line in a variable.</p>
<p>The text has this format: </p>
<pre><code>[15-06-1999]
Brian
John
186
[26-08-2000]
//...
</code></pre>
<p>How do I read from below [15-06-1999] to the blank line and store the <strong>3 strings</strong> in seperate variables?</p>
<p>I haven't found any <strong>efficient</strong> method of doing this yet.</p>
<p>I'm trying to do this in C#.</p>
| 0debug
|
Difference between "raise" and "raise e"? : <p>In python, is there a difference between <code>raise</code> and <code>raise e</code> in an except block?</p>
<p><code>dis</code> is showing me different results, but I don't know what it means.</p>
<p>What's the end behavior of both?</p>
<pre><code>import dis
def a():
try:
raise Exception()
except Exception as e:
raise
def b():
try:
raise Exception()
except Exception as e:
raise e
dis.dis(a)
# OUT: 4 0 SETUP_EXCEPT 13 (to 16)
# OUT: 5 3 LOAD_GLOBAL 0 (Exception)
# OUT: 6 CALL_FUNCTION 0
# OUT: 9 RAISE_VARARGS 1
# OUT: 12 POP_BLOCK
# OUT: 13 JUMP_FORWARD 22 (to 38)
# OUT: 6 >> 16 DUP_TOP
# OUT: 17 LOAD_GLOBAL 0 (Exception)
# OUT: 20 COMPARE_OP 10 (exception match)
# OUT: 23 POP_JUMP_IF_FALSE 37
# OUT: 26 POP_TOP
# OUT: 27 STORE_FAST 0 (e)
# OUT: 30 POP_TOP
# OUT: 7 31 RAISE_VARARGS 0
# OUT: 34 JUMP_FORWARD 1 (to 38)
# OUT: >> 37 END_FINALLY
# OUT: >> 38 LOAD_CONST 0 (None)
# OUT: 41 RETURN_VALUE
dis.dis(b)
# OUT: 4 0 SETUP_EXCEPT 13 (to 16)
# OUT: 5 3 LOAD_GLOBAL 0 (Exception)
# OUT: 6 CALL_FUNCTION 0
# OUT: 9 RAISE_VARARGS 1
# OUT: 12 POP_BLOCK
# OUT: 13 JUMP_FORWARD 25 (to 41)
# OUT: 6 >> 16 DUP_TOP
# OUT: 17 LOAD_GLOBAL 0 (Exception)
# OUT: 20 COMPARE_OP 10 (exception match)
# OUT: 23 POP_JUMP_IF_FALSE 40
# OUT: 26 POP_TOP
# OUT: 27 STORE_FAST 0 (e)
# OUT: 30 POP_TOP
# OUT: 7 31 LOAD_FAST 0 (e)
# OUT: 34 RAISE_VARARGS 1
# OUT: 37 JUMP_FORWARD 1 (to 41)
# OUT: >> 40 END_FINALLY
# OUT: >> 41 LOAD_CONST 0 (None)
# OUT: 44 RETURN_VALUE
</code></pre>
| 0debug
|
BigDecimal, precision and scale : <p>I'm using BigDecimal for my numbers in my application, for example, with JPA. I did a bit of researching about the terms 'precision' and 'scale' but I don't understand what are they exactly.</p>
<p>Can anyone explain me the meaning of 'precision' and 'scale' for a BigDecimal value?</p>
<pre><code>@Column(precision = 11, scale = 2)
</code></pre>
<p>Thanks!</p>
| 0debug
|
bash script that kills java procceses : So my bash script kills a random java process every 10 seconds.
My goal is to make it every random amount seconds between 5 and 25.
Any idea how I would do that?
Thanks.
@echo off
for /f "tokens=2 delims=," %%T in ('tasklist /nh /fi "imagename eq java.exe" /fo csv') do (
taskkill /F /pid %%~T
timeout /t 10
goto :start
)
| 0debug
|
static int mov_write_stbl_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContext *mov, MOVTrack *track)
{
int64_t pos = avio_tell(pb);
int ret;
avio_wb32(pb, 0);
ffio_wfourcc(pb, "stbl");
mov_write_stsd_tag(s, pb, mov, track);
mov_write_stts_tag(pb, track);
if ((track->par->codec_type == AVMEDIA_TYPE_VIDEO ||
track->par->codec_tag == MKTAG('r','t','p',' ')) &&
track->has_keyframes && track->has_keyframes < track->entry)
mov_write_stss_tag(pb, track, MOV_SYNC_SAMPLE);
if (track->mode == MODE_MOV && track->flags & MOV_TRACK_STPS)
mov_write_stss_tag(pb, track, MOV_PARTIAL_SYNC_SAMPLE);
if (track->par->codec_type == AVMEDIA_TYPE_VIDEO &&
track->flags & MOV_TRACK_CTTS && track->entry) {
if ((ret = mov_write_ctts_tag(pb, track)) < 0)
return ret;
}
mov_write_stsc_tag(pb, track);
mov_write_stsz_tag(pb, track);
mov_write_stco_tag(pb, track);
if (mov->encryption_scheme == MOV_ENC_CENC_AES_CTR) {
ff_mov_cenc_write_stbl_atoms(&track->cenc, pb);
}
if (track->par->codec_id == AV_CODEC_ID_OPUS) {
mov_preroll_write_stbl_atoms(pb, track);
}
return update_size(pb, pos);
}
| 1threat
|
ReferenceError: $ is not defined or Uncaught ReferenceError: $ is not defined : <p>I am trying to call a bootstrap model in my page. but it throws an error in console output as <strong>ReferenceError: $ is not defined</strong>. Code for the reference as below :-</p>
<pre><code><head>
<title></title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="<?php echo base_url(); ?>assets/css/style.css" rel="stylesheet" type="text/css"/>
<link href="<?php echo base_url(); ?>assets/css/bootstrap.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="text-center">
<button class="btn btn-danger" id="delete" > Delete ID</button>
</div>
<div class="modal fade" id="confirm-delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
Confirm Delete
</div>
<div class="modal-body">Are you sure you want to Delete contact list ?</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<a id="sureDelete"><button class="btn btn-danger success">Delete</button></a>
</div>
</div>
</div>
</div>
<script type="text/javascript">
$(document).on('click', '#delete', function () {
$('#confirm-delete').modal('show');});
</script>
<script src="<?php echo base_url(); ?>assets/js/jquery.js" type="text/javascript"></script>
<script src="<?php echo base_url(); ?>assets/js/bootstrap.min.js" type="text/javascript"></script>
</body>
</code></pre>
| 0debug
|
static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args,
const int *const_args)
{
uint8_t *old_code_ptr = s->code_ptr;
tcg_out_op_t(s, opc);
switch (opc) {
case INDEX_op_exit_tb:
tcg_out64(s, args[0]);
break;
case INDEX_op_goto_tb:
if (s->tb_jmp_offset) {
assert(args[0] < ARRAY_SIZE(s->tb_jmp_offset));
s->tb_jmp_offset[args[0]] = s->code_ptr - s->code_buf;
tcg_out32(s, 0);
} else {
TODO();
}
assert(args[0] < ARRAY_SIZE(s->tb_next_offset));
s->tb_next_offset[args[0]] = s->code_ptr - s->code_buf;
break;
case INDEX_op_br:
tci_out_label(s, args[0]);
break;
case INDEX_op_call:
tcg_out_ri(s, const_args[0], args[0]);
break;
case INDEX_op_setcond_i32:
tcg_out_r(s, args[0]);
tcg_out_r(s, args[1]);
tcg_out_ri32(s, const_args[2], args[2]);
tcg_out8(s, args[3]);
break;
#if TCG_TARGET_REG_BITS == 32
case INDEX_op_setcond2_i32:
tcg_out_r(s, args[0]);
tcg_out_r(s, args[1]);
tcg_out_r(s, args[2]);
tcg_out_ri32(s, const_args[3], args[3]);
tcg_out_ri32(s, const_args[4], args[4]);
tcg_out8(s, args[5]);
break;
#elif TCG_TARGET_REG_BITS == 64
case INDEX_op_setcond_i64:
tcg_out_r(s, args[0]);
tcg_out_r(s, args[1]);
tcg_out_ri64(s, const_args[2], args[2]);
tcg_out8(s, args[3]);
break;
#endif
case INDEX_op_movi_i32:
TODO();
break;
case INDEX_op_ld8u_i32:
case INDEX_op_ld8s_i32:
case INDEX_op_ld16u_i32:
case INDEX_op_ld16s_i32:
case INDEX_op_ld_i32:
case INDEX_op_st8_i32:
case INDEX_op_st16_i32:
case INDEX_op_st_i32:
case INDEX_op_ld8u_i64:
case INDEX_op_ld8s_i64:
case INDEX_op_ld16u_i64:
case INDEX_op_ld16s_i64:
case INDEX_op_ld32u_i64:
case INDEX_op_ld32s_i64:
case INDEX_op_ld_i64:
case INDEX_op_st8_i64:
case INDEX_op_st16_i64:
case INDEX_op_st32_i64:
case INDEX_op_st_i64:
tcg_out_r(s, args[0]);
tcg_out_r(s, args[1]);
assert(args[2] == (uint32_t)args[2]);
tcg_out32(s, args[2]);
break;
case INDEX_op_add_i32:
case INDEX_op_sub_i32:
case INDEX_op_mul_i32:
case INDEX_op_and_i32:
case INDEX_op_andc_i32:
case INDEX_op_eqv_i32:
case INDEX_op_nand_i32:
case INDEX_op_nor_i32:
case INDEX_op_or_i32:
case INDEX_op_orc_i32:
case INDEX_op_xor_i32:
case INDEX_op_shl_i32:
case INDEX_op_shr_i32:
case INDEX_op_sar_i32:
case INDEX_op_rotl_i32:
case INDEX_op_rotr_i32:
tcg_out_r(s, args[0]);
tcg_out_ri32(s, const_args[1], args[1]);
tcg_out_ri32(s, const_args[2], args[2]);
break;
case INDEX_op_deposit_i32:
tcg_out_r(s, args[0]);
tcg_out_r(s, args[1]);
tcg_out_r(s, args[2]);
assert(args[3] <= UINT8_MAX);
tcg_out8(s, args[3]);
assert(args[4] <= UINT8_MAX);
tcg_out8(s, args[4]);
break;
#if TCG_TARGET_REG_BITS == 64
case INDEX_op_mov_i64:
case INDEX_op_movi_i64:
TODO();
break;
case INDEX_op_add_i64:
case INDEX_op_sub_i64:
case INDEX_op_mul_i64:
case INDEX_op_and_i64:
case INDEX_op_andc_i64:
case INDEX_op_eqv_i64:
case INDEX_op_nand_i64:
case INDEX_op_nor_i64:
case INDEX_op_or_i64:
case INDEX_op_orc_i64:
case INDEX_op_xor_i64:
case INDEX_op_shl_i64:
case INDEX_op_shr_i64:
case INDEX_op_sar_i64:
case INDEX_op_rotl_i64:
case INDEX_op_rotr_i64:
tcg_out_r(s, args[0]);
tcg_out_ri64(s, const_args[1], args[1]);
tcg_out_ri64(s, const_args[2], args[2]);
break;
case INDEX_op_deposit_i64:
tcg_out_r(s, args[0]);
tcg_out_r(s, args[1]);
tcg_out_r(s, args[2]);
assert(args[3] <= UINT8_MAX);
tcg_out8(s, args[3]);
assert(args[4] <= UINT8_MAX);
tcg_out8(s, args[4]);
break;
case INDEX_op_div_i64:
case INDEX_op_divu_i64:
case INDEX_op_rem_i64:
case INDEX_op_remu_i64:
TODO();
break;
case INDEX_op_div2_i64:
case INDEX_op_divu2_i64:
TODO();
break;
case INDEX_op_brcond_i64:
tcg_out_r(s, args[0]);
tcg_out_ri64(s, const_args[1], args[1]);
tcg_out8(s, args[2]);
tci_out_label(s, args[3]);
break;
case INDEX_op_bswap16_i64:
case INDEX_op_bswap32_i64:
case INDEX_op_bswap64_i64:
case INDEX_op_not_i64:
case INDEX_op_neg_i64:
case INDEX_op_ext8s_i64:
case INDEX_op_ext8u_i64:
case INDEX_op_ext16s_i64:
case INDEX_op_ext16u_i64:
case INDEX_op_ext32s_i64:
case INDEX_op_ext32u_i64:
#endif
case INDEX_op_neg_i32:
case INDEX_op_not_i32:
case INDEX_op_ext8s_i32:
case INDEX_op_ext16s_i32:
case INDEX_op_ext8u_i32:
case INDEX_op_ext16u_i32:
case INDEX_op_bswap16_i32:
case INDEX_op_bswap32_i32:
tcg_out_r(s, args[0]);
tcg_out_r(s, args[1]);
break;
case INDEX_op_div_i32:
case INDEX_op_divu_i32:
case INDEX_op_rem_i32:
case INDEX_op_remu_i32:
tcg_out_r(s, args[0]);
tcg_out_ri32(s, const_args[1], args[1]);
tcg_out_ri32(s, const_args[2], args[2]);
break;
case INDEX_op_div2_i32:
case INDEX_op_divu2_i32:
TODO();
break;
#if TCG_TARGET_REG_BITS == 32
case INDEX_op_add2_i32:
case INDEX_op_sub2_i32:
tcg_out_r(s, args[0]);
tcg_out_r(s, args[1]);
tcg_out_r(s, args[2]);
tcg_out_r(s, args[3]);
tcg_out_r(s, args[4]);
tcg_out_r(s, args[5]);
break;
case INDEX_op_brcond2_i32:
tcg_out_r(s, args[0]);
tcg_out_r(s, args[1]);
tcg_out_ri32(s, const_args[2], args[2]);
tcg_out_ri32(s, const_args[3], args[3]);
tcg_out8(s, args[4]);
tci_out_label(s, args[5]);
break;
case INDEX_op_mulu2_i32:
tcg_out_r(s, args[0]);
tcg_out_r(s, args[1]);
tcg_out_r(s, args[2]);
tcg_out_r(s, args[3]);
break;
#endif
case INDEX_op_brcond_i32:
tcg_out_r(s, args[0]);
tcg_out_ri32(s, const_args[1], args[1]);
tcg_out8(s, args[2]);
tci_out_label(s, args[3]);
break;
case INDEX_op_qemu_ld8u:
case INDEX_op_qemu_ld8s:
case INDEX_op_qemu_ld16u:
case INDEX_op_qemu_ld16s:
case INDEX_op_qemu_ld32:
#if TCG_TARGET_REG_BITS == 64
case INDEX_op_qemu_ld32s:
case INDEX_op_qemu_ld32u:
#endif
tcg_out_r(s, *args++);
tcg_out_r(s, *args++);
#if TARGET_LONG_BITS > TCG_TARGET_REG_BITS
tcg_out_r(s, *args++);
#endif
#ifdef CONFIG_SOFTMMU
tcg_out_i(s, *args);
#endif
break;
case INDEX_op_qemu_ld64:
tcg_out_r(s, *args++);
#if TCG_TARGET_REG_BITS == 32
tcg_out_r(s, *args++);
#endif
tcg_out_r(s, *args++);
#if TARGET_LONG_BITS > TCG_TARGET_REG_BITS
tcg_out_r(s, *args++);
#endif
#ifdef CONFIG_SOFTMMU
tcg_out_i(s, *args);
#endif
break;
case INDEX_op_qemu_st8:
case INDEX_op_qemu_st16:
case INDEX_op_qemu_st32:
tcg_out_r(s, *args++);
tcg_out_r(s, *args++);
#if TARGET_LONG_BITS > TCG_TARGET_REG_BITS
tcg_out_r(s, *args++);
#endif
#ifdef CONFIG_SOFTMMU
tcg_out_i(s, *args);
#endif
break;
case INDEX_op_qemu_st64:
tcg_out_r(s, *args++);
#if TCG_TARGET_REG_BITS == 32
tcg_out_r(s, *args++);
#endif
tcg_out_r(s, *args++);
#if TARGET_LONG_BITS > TCG_TARGET_REG_BITS
tcg_out_r(s, *args++);
#endif
#ifdef CONFIG_SOFTMMU
tcg_out_i(s, *args);
#endif
break;
case INDEX_op_end:
TODO();
break;
default:
fprintf(stderr, "Missing: %s\n", tcg_op_defs[opc].name);
tcg_abort();
}
old_code_ptr[1] = s->code_ptr - old_code_ptr;
}
| 1threat
|
how to remove word from string A to B point in php : i have this string :
<a href="/title/tt3110958/?ref_=nm_flmg_act_2" style="color:#666" >
how to remove all word from `?` to `"` in my string .
| 0debug
|
static void gen_mulldo(DisasContext *ctx)
{
TCGv_i64 t0 = tcg_temp_new_i64();
TCGv_i64 t1 = tcg_temp_new_i64();
tcg_gen_muls2_i64(t0, t1, cpu_gpr[rA(ctx->opcode)],
cpu_gpr[rB(ctx->opcode)]);
tcg_gen_mov_i64(cpu_gpr[rD(ctx->opcode)], t0);
tcg_gen_sari_i64(t0, t0, 63);
tcg_gen_setcond_i64(TCG_COND_NE, cpu_ov, t0, t1);
tcg_gen_or_tl(cpu_so, cpu_so, cpu_ov);
tcg_temp_free_i64(t0);
tcg_temp_free_i64(t1);
if (unlikely(Rc(ctx->opcode) != 0)) {
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
| 1threat
|
Covariance not working with delegates : <p>I am working on a project using <code>Microsoft Bot Builder</code>, but my question is not specific to that.</p>
<p>Microsoft Bot Builder has the following delegate</p>
<pre><code>WaterfallStep(DialogContext dc, IDictionary<string, object> args = null, SkipStepFunction next = null);
</code></pre>
<p>And my method's signature is </p>
<pre><code>async Task DidNotUnderstandQuery(DialogContext context, BotState state, SkipStepFunction next)
</code></pre>
<p>Notice the only difference is <code>BotState</code> parameter type which is defined as below</p>
<pre><code>class BotState : Dictionary<string, object>, IDictionary<string, object>
</code></pre>
<p>When I try to substitute my method where it is supposed to be a <code>WaterFallStep</code> I get the error saying the method does not match the delegate.</p>
<p>Why does Covariance not work with delegates?</p>
| 0debug
|
cant understand calculate method : i have problem in calculate method
it should do like give me that total price like quantity*5
it should do like any number*5 like 1*5 =5 2*5 =10
but the problem here if i change the quantity to 2 it will give me the price 20 $
quantity 3 it will give me price 45, while it should price be 15 i tried to search for the problem cant find anything
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
/**
* IMPORTANT: Make sure you are using the correct package name.
* This example uses the package name:
* package com.example.android.justjava
* If you get an error when copying this code into Android studio, update it to match teh package name found
* in the project's AndroidManifest.xml file.
**/
package justjava.andriod.example.com.justjava;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import java.text.NumberFormat;
import justjava.andriod.example.com.justjava.R;
/**
* This app displays an order form to order coffee.
*/
public class MainActivity extends AppCompatActivity {
int quantity = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
/**
* This method is called when the plus button is clicked.
*/
public void increment (View view) {
// this method to block the user to use increamnt method if the number is 100
if (quantity==100){
//show an error message as a toast
Toast.makeText(this, "you cannot have more than 100 coffes", Toast.LENGTH_SHORT).show();
// Exit this method early because there's nothing left to do
return;
}
quantity = quantity+1;
display(quantity);
}
/**
* This method is called when the minus button is clicked.
*/
public void decrement (View view) {
// this if statment block user to make decremnt method below number 1 so it wont go to 0
if (quantity==1) {
// show an error message as a toast
Toast.makeText(this, "you cannot have more less than 1 coffee", Toast.LENGTH_SHORT).show();
// Exit this method early because there's nothing left to do
return;
}
quantity = quantity - 1;
display(quantity);
}
/**
* Calculates the price of the order.
*@return total price
*/
private String creatOrderSummary(String name, int basePrice, boolean addWhippedCream , boolean addCocolate) {
String priceMessage = "Name : " + name;
priceMessage += "\nAdd Whipped Cream? " + addWhippedCream;
priceMessage += "\nadd chocolate? " + addCocolate;
priceMessage = priceMessage + "\nQuantity" + quantity;
priceMessage = priceMessage + "\nTotall: $"+ basePrice;
priceMessage = priceMessage + "\nthank you!";
return priceMessage;
}
/**
* Calculates the price of the order.
*@return total price
*/
private int calculatePrice(boolean addWhippedCream, boolean addChocolate ) {
// pice of 1 cup of coffe
int basePrice = quantity *5;
// add $1 if the user wants whipped cream
if (addChocolate) {
basePrice = basePrice + 1;
}
// add $2 if the user wants chocolate
if (addChocolate) {
basePrice = basePrice + 2;
}
// calcuate the tottal order price by multiplying by quantity
return quantity * basePrice;
}
/**
* This method is called when the order button is clicked.
*/
public void submitOrder(View view) {
// find the user's name
EditText text = (EditText) findViewById(R.id.name_field);
String name = text.getText().toString();
// figure it out if user wants whipped cream topping
CheckBox whippedCreamCheckBox = (CheckBox) findViewById(R.id.whipped_cream_checkbox);
boolean hasWippedCream = whippedCreamCheckBox.isChecked();
Log.v("MainActivity", "Has whipped cream: " + hasWippedCream);
// figure it out if user want chocolate
CheckBox chocolate = (CheckBox) findViewById(R.id.add_chocolate);
boolean hasCocolate = chocolate.isChecked();
int price = calculatePrice(hasWippedCream, hasCocolate);
String priceMessage = creatOrderSummary(name,price, hasWippedCream, hasCocolate);
displayMessage(priceMessage);
}
/**
* This method displays the given quantity value on the screen.
*/
private void display(int number) {
TextView quantityTextView = (TextView) findViewById(R.id.quantity_text_view);
quantityTextView.setText("" + number);
}
/**
* This method displays the given text on the screen.
*/
private void displayMessage(String message) {
TextView orderSummaryTextView = (TextView) findViewById(R.id.order_summary_text_view);
orderSummaryTextView.setText(message);
}
}
<!-- end snippet -->
| 0debug
|
int bdrv_get_translation_hint(BlockDriverState *bs)
{
return bs->translation;
}
| 1threat
|
Is there a way to disconnect USB device from ADB? : <p>I have a lot of scripts that use ADB to debug Android applications via Wi-Fi with emulators. The problem appears when I charge my Android phone via USB from my computer: ADB sees it and sends commands to my phone instead of emulator.
<strong>Is there a way to disconnect ADB from phone that charges via USB?</strong> I know I can send commands to emulators only via <code>-e</code> switch, as well as send them to specific device via <code>-s</code> switch. However, it is not OK for me, because I have to rewrite a lot of scripts to add more arguments if I want to implement this device selection feature. I don't need workarounds, I just curious does Google <em>force</em> ADB to debug any phone connected via USB that has USB debugging enabled in settings, or it is possible to remove specific USB connected phone from devices list on ADB side?
When I run <code>adb disconnect</code>, USB device remains connected.</p>
| 0debug
|
SEEK_END with WHENCE on binary stream : <p>I'm confused by this statement, from <a href="http://knking.com/books/c2/index.html" rel="nofollow noreferrer">C Programming: A Modern Approach, 2nd Edition</a> on Page 446,</p>
<blockquote>
<p>For binary streams, <code>fseek</code> isn't required to support calls in which whence is <code>SEEK_END</code></p>
</blockquote>
<p>Why is that? That seems like weird stipulation.</p>
| 0debug
|
Binary operator '===' cannot be applied to operands of type 'Any?' and 'UIBarButtonItem!' : <p>The following code used to be able to compile in swift 2.2, no longer in swift 3.0. How do we fix this? </p>
<blockquote>
<p>Error: Binary operator '===' cannot be applied to operands of type 'Any?' and 'UIBarButtonItem!'</p>
</blockquote>
<pre><code>override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if sender === saveButton { // Error!
// ...
} else if sender === closeButton { // Error!
// ...
}
}
</code></pre>
| 0debug
|
React-Native: How to wrap Child components under another class component : <p>Let me Explain my question with an example:</p>
<p>in SomeComponent.js I have the following</p>
<pre><code>export default class SomeComponent extends React.Component {
render() {
return (
<View style={{flex:1}}>
</View>
)
}
}
</code></pre>
<p>and in Root.js it imports 'SomeComponent' as follow</p>
<pre><code>import SomeComponent from './SomeCoponent'
export default class SomeComponent extends React.Component {
render() {
return (
<SomeComponent>
<Text> hello </Text>
</SomeComponent>
)
}
}
</code></pre>
<p>How does this work?</p>
<p>I saw some blog where some people do this:</p>
<pre><code>export default class SomeComponent extends React.Component {
render() {
return (
<View style={{flex:1}}>
{/* code added here - start */}
{React.Children.map(this.props.children, c => React.cloneElement(c, {
route: this.props.route
}))}
{/* code added here - end */}
</View>
)
}
}
</code></pre>
<p>But this does not work for me. </p>
<p>I am getting the following error: </p>
<pre><code>Warning: React.createElement: type should not be null, undefined, boolean, or number. It should be a string (for DOM elements) or a ReactClass (for composite components)
</code></pre>
<p>Any help would be appreciated. Thanks</p>
| 0debug
|
How the comapre() method without calling in main method? : enter code here
import java.util.*;
class MyComp implements Comparator<String>{<br/>
public int compare(String aStr, String bStr) {<br/>
return bStr.compareTo(aStr);<br/>
}
}<br/>
public class CustomComparatorTest {
public static void main(String[] args) {
MyComp my = new MyComp();
TreeSet<String> ts = new TreeSet<String>(my);
ts.add("C");
ts.add("A");
ts.add("B");
ts.add("Y");
ts.add("T");
ts.add("W");
for(String element : ts)
{
System.out.println(element + " ");
}
System.out.println();
}
}
| 0debug
|
other webelement is also treated as List<WebElement> : <p>After accessing the webelements of List. Other webelement is also treated as List webelement.</p>
<pre><code>List<WebElement> BrandTerms =driver.findElements(BrandTerm);
js = (JavascriptExecutor) driver;
for(int i=0;i<=1;i++)
{
js.executeScript("arguments[0].value='"+Bandtermsvalue+i + "'", BrandTerms.get(i));
}
js=null;
driver.findElements(By.id("btnAddBrandedTerms")).click();
</code></pre>
<p>Why is this webelement is treated as list element with message "click() is undefined for the type List"</p>
<p><a href="https://i.stack.imgur.com/dcjXz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dcjXz.png" alt="enter image description here"></a></p>
| 0debug
|
How to easily inspect styled-components using dev tools? : <p>I am using styled-components in a React project. When the components are rendered in the browser they are assigned a randomly generated classname, for example:</p>
<p><code><div class="sc-KSdffgy oPwefl"></code></p>
<p>This class name does not help me identify from which component the <code><div></code> came from, so is there a way to do this easily?</p>
<p>P.s. currently I am adding attrs to my styled components so that I can recognise them in dev tools, for example:</p>
<pre><code>const Foo = styled.div.attrs({
'data-id': 'foo'
})`
...
`;
</code></pre>
| 0debug
|
How to send final kafka-streams aggregation result of a time windowed KTable? : <p>What I'd like to do is this:</p>
<ol>
<li>Consume records from a numbers topic (Long's)</li>
<li>Aggregate (count) the values for each 5 sec window</li>
<li>Send the FINAL aggregation result to another topic</li>
</ol>
<p>My code looks like this:</p>
<pre><code>KStream<String, Long> longs = builder.stream(
Serdes.String(), Serdes.Long(), "longs");
// In one ktable, count by key, on a five second tumbling window.
KTable<Windowed<String>, Long> longCounts =
longs.countByKey(TimeWindows.of("longCounts", 5000L));
// Finally, sink to the long-avgs topic.
longCounts.toStream((wk, v) -> wk.key())
.to("long-counts");
</code></pre>
<p>It looks like everything works as expected, but the aggregations are sent to the destination topic for each incoming record. My question is how can I send only the final aggregation result of each window?</p>
| 0debug
|
how to determine if a .net app is a "core" app? : <p>I need to update a new .NET app and I think it was mentioned that it was .NET Core. How can I examine the solution properties to determine if it is in fact a "core" app?</p>
<p>The web project has a System.Core reference but I googled this and it seems that System.Core.dll has been a part of the .NET framework since at least .NET f/w 3.5.</p>
<p>The app has a package.json file but the existence of that file in a sln does not necessarily guarantee that the app is a .NET core app. I've also read that a .NET core app can run on different .NET framework versions.</p>
<p>So how can I determine if a .NET app is indeed a "Core" app? In other words, what makes a Core app a Core app?</p>
| 0debug
|
How can I connect alexa with recast.ai chatbot using powershell : I have build a chatbot with recast.ai and now want to connect it with alexa, so that the requests from alexa are integrated in recast.ai. Therefore I want to use
"REQUEST_TOKEN=xxxxxxxxx npm start" in windows powershell in order to send the requests to my server.
Then, I get the following error message:
[enter image description here][1]
[1]: https://i.stack.imgur.com/mddhI.png
Do you know how I can solve this problem instead?
Thank you very much for answering
| 0debug
|
Acces Listview delegate TEXT in qml after call qml function from c++ : *******///// !!invoke function for C++(main.cpp)*******
** ı want to access qml component with qml function from c++ can you help me ??
ı want to find waypoint path by two coordinates .
ı wan to access qml component with qml function from c++ .
import QtLocation 5.6
import QtPositioning 5.6
import QtQml 2.2
Item {
Plugin
{
id:osmPlugin
name:"osm"
}
RouteModel
{
id: routeModel
plugin: osmPlugin
autoUpdate: true
query: aQuery
}
RouteQuery
{
id: aQuery
}
property list<string> rectx
Repeater
{
id: listview
model: routeModel.status == RouteModel.Ready ? routeModel.get(0).segments : null
visible: model ? true : false
delegate: Row {
property bool hasManeuver : modelData.maneuver && modelData.maneuver.valid
property RouteSegment routeSegment: modelData
Text
{
id:tt2
text: routeSegment.path *** // I WANT THİS TEXT VALUE /////***
}
}
}
Location
{
id:l1
coordinate
{
latitude:0.0
longitude:0.0
}
}
Location
{
id:l2
coordinate
{
latitude:0.0
longitude:0.0
}
}
property string someString
property string someString1
property string lang
property string lang1
function myQmlFunction(coord)
{
someString=coord
someString1=coord
lang= someString.substring(0,6)
lang1= someString1.substring(10,16)
l1.coordinate.longitude = lang
l1.coordinate.latitude= lang1
l2.coordinate.longitude = lang
l2.coordinate.latitude= lang1
aQuery.addWaypoint(l1.coordinate,l2.coordinate)
aQuery.travelModes=RouteQuery.CarTravel
aQuery.routeOptimizations=RouteQuery.ShortestRoute
routeModel.update()
console.log("Got message:",)
return "some return value"
}
}
| 0debug
|
check if username exists inside firebase database : <p>Am trying to check if a username exists from a database by calling the function checkifUsernameExists(username) within an if statement. the problem is firebase's built function called</p>
<pre><code> public void onDataChange(@NonNull DataSnapshot dataSnapshot)
</code></pre>
<p>cannot return a boolean value. What can i do?</p>
<pre><code> mCreateBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String username = musername.getText().toString();
String email = mEmail.getText().toString();
String password = mPassword.getText().toString();
if (TextUtils.isEmpty(username) || TextUtils.isEmpty(email) || TextUtils.isEmpty(password)) {
Toast.makeText(registerActivity.this, "Cannot sign you in. Please check the form and try again",
Toast.LENGTH_SHORT).show();
} else if (password.length() < 6) {
Toast.makeText(registerActivity.this, "Password must be at least 6 characters",Toast.LENGTH_LONG).show();
} else if (email_exists == true) {
Toast.makeText(registerActivity.this, "Email already exists",Toast.LENGTH_LONG).show();
} else if (checkifUsernameExists(username)) {
Toast.makeText(registerActivity.this, "Username already exists", Toast.LENGTH_LONG).show();
} else {
message.setTitle("Registering user");
message.setMessage("Pleases wait while we create your account");
message.setCanceledOnTouchOutside(false);
message.show();
//registerUser(username, email, password);
}
}
});
}
</code></pre>
<pre><code>
private boolean checkifUsernameExists(String username) {
Query usernameQuery = FirebaseDatabase.getInstance().getReference().child("users").orderByChild("username").equalTo(username);
usernameQuery.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
if (dataSnapshot.getChildrenCount() > 0) {
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
}
</code></pre>
| 0debug
|
static void select_input_picture(MpegEncContext *s){
int i;
for(i=1; i<MAX_PICTURE_COUNT; i++)
s->reordered_input_picture[i-1]= s->reordered_input_picture[i];
s->reordered_input_picture[MAX_PICTURE_COUNT-1]= NULL;
if(s->reordered_input_picture[0]==NULL && s->input_picture[0]){
if( s->next_picture_ptr==NULL || s->intra_only){
s->reordered_input_picture[0]= s->input_picture[0];
s->reordered_input_picture[0]->pict_type= I_TYPE;
s->reordered_input_picture[0]->coded_picture_number= s->coded_picture_number++;
}else{
int b_frames;
if(s->avctx->frame_skip_threshold || s->avctx->frame_skip_factor){
if(s->picture_in_gop_number < s->gop_size && skip_check(s, s->input_picture[0], s->next_picture_ptr)){
if(s->input_picture[0]->type == FF_BUFFER_TYPE_SHARED){
for(i=0; i<4; i++)
s->input_picture[0]->data[i]= NULL;
s->input_picture[0]->type= 0;
}else{
assert( s->input_picture[0]->type==FF_BUFFER_TYPE_USER
|| s->input_picture[0]->type==FF_BUFFER_TYPE_INTERNAL);
s->avctx->release_buffer(s->avctx, (AVFrame*)s->input_picture[0]);
}
emms_c();
ff_vbv_update(s, 0);
goto no_output_pic;
}
}
if(s->flags&CODEC_FLAG_PASS2){
for(i=0; i<s->max_b_frames+1; i++){
int pict_num= s->input_picture[0]->display_picture_number + i;
if(pict_num >= s->rc_context.num_entries)
break;
if(!s->input_picture[i]){
s->rc_context.entry[pict_num-1].new_pict_type = P_TYPE;
break;
}
s->input_picture[i]->pict_type=
s->rc_context.entry[pict_num].new_pict_type;
}
}
if(s->avctx->b_frame_strategy==0){
b_frames= s->max_b_frames;
while(b_frames && !s->input_picture[b_frames]) b_frames--;
}else if(s->avctx->b_frame_strategy==1){
for(i=1; i<s->max_b_frames+1; i++){
if(s->input_picture[i] && s->input_picture[i]->b_frame_score==0){
s->input_picture[i]->b_frame_score=
get_intra_count(s, s->input_picture[i ]->data[0],
s->input_picture[i-1]->data[0], s->linesize) + 1;
}
}
for(i=0; i<s->max_b_frames+1; i++){
if(s->input_picture[i]==NULL || s->input_picture[i]->b_frame_score - 1 > s->mb_num/s->avctx->b_sensitivity) break;
}
b_frames= FFMAX(0, i-1);
for(i=0; i<b_frames+1; i++){
s->input_picture[i]->b_frame_score=0;
}
}else if(s->avctx->b_frame_strategy==2){
b_frames= estimate_best_b_count(s);
}else{
av_log(s->avctx, AV_LOG_ERROR, "illegal b frame strategy\n");
b_frames=0;
}
emms_c();
for(i= b_frames - 1; i>=0; i--){
int type= s->input_picture[i]->pict_type;
if(type && type != B_TYPE)
b_frames= i;
}
if(s->input_picture[b_frames]->pict_type == B_TYPE && b_frames == s->max_b_frames){
av_log(s->avctx, AV_LOG_ERROR, "warning, too many b frames in a row\n");
}
if(s->picture_in_gop_number + b_frames >= s->gop_size){
if((s->flags2 & CODEC_FLAG2_STRICT_GOP) && s->gop_size > s->picture_in_gop_number){
b_frames= s->gop_size - s->picture_in_gop_number - 1;
}else{
if(s->flags & CODEC_FLAG_CLOSED_GOP)
b_frames=0;
s->input_picture[b_frames]->pict_type= I_TYPE;
}
}
if( (s->flags & CODEC_FLAG_CLOSED_GOP)
&& b_frames
&& s->input_picture[b_frames]->pict_type== I_TYPE)
b_frames--;
s->reordered_input_picture[0]= s->input_picture[b_frames];
if(s->reordered_input_picture[0]->pict_type != I_TYPE)
s->reordered_input_picture[0]->pict_type= P_TYPE;
s->reordered_input_picture[0]->coded_picture_number= s->coded_picture_number++;
for(i=0; i<b_frames; i++){
s->reordered_input_picture[i+1]= s->input_picture[i];
s->reordered_input_picture[i+1]->pict_type= B_TYPE;
s->reordered_input_picture[i+1]->coded_picture_number= s->coded_picture_number++;
}
}
}
no_output_pic:
if(s->reordered_input_picture[0]){
s->reordered_input_picture[0]->reference= s->reordered_input_picture[0]->pict_type!=B_TYPE ? 3 : 0;
copy_picture(&s->new_picture, s->reordered_input_picture[0]);
if(s->reordered_input_picture[0]->type == FF_BUFFER_TYPE_SHARED){
int i= ff_find_unused_picture(s, 0);
Picture *pic= &s->picture[i];
for(i=0; i<4; i++)
s->reordered_input_picture[0]->data[i]= NULL;
s->reordered_input_picture[0]->type= 0;
pic->reference = s->reordered_input_picture[0]->reference;
alloc_picture(s, pic, 0);
copy_picture_attributes(s, (AVFrame*)pic, (AVFrame*)s->reordered_input_picture[0]);
s->current_picture_ptr= pic;
}else{
assert( s->reordered_input_picture[0]->type==FF_BUFFER_TYPE_USER
|| s->reordered_input_picture[0]->type==FF_BUFFER_TYPE_INTERNAL);
s->current_picture_ptr= s->reordered_input_picture[0];
for(i=0; i<4; i++){
s->new_picture.data[i]+= INPLACE_OFFSET;
}
}
copy_picture(&s->current_picture, s->current_picture_ptr);
s->picture_number= s->new_picture.display_picture_number;
}else{
memset(&s->new_picture, 0, sizeof(Picture));
}
}
| 1threat
|
copy from 2d dynamic char array to another 2d dynamic array in c : I wanted to copy the content of a two dimensional array into another two dimensional char array. I used the following `for` loop with `memcpy` but it is not working as desired. So I have two questions.
1. What is wrong with this code? and
2. Is there a way to do it without use of iteration?
for (int i = 0; i < count; i++)
{
memcpy(&buf_copy[i], buf[i], sizeof(buf[i]));
}
Both `buf` and `buf_copy` are 2d dynamic char arrays;
| 0debug
|
int qcow2_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info)
{
BDRVQcowState *s = bs->opaque;
QCowSnapshot *new_snapshot_list = NULL;
QCowSnapshot *old_snapshot_list = NULL;
QCowSnapshot sn1, *sn = &sn1;
int i, ret;
uint64_t *l1_table = NULL;
int64_t l1_table_offset;
memset(sn, 0, sizeof(*sn));
if (sn_info->id_str[0] == '\0') {
find_new_snapshot_id(bs, sn_info->id_str, sizeof(sn_info->id_str));
}
if (find_snapshot_by_id_and_name(bs, sn_info->id_str, NULL) >= 0) {
return -EEXIST;
}
sn->id_str = g_strdup(sn_info->id_str);
sn->name = g_strdup(sn_info->name);
sn->disk_size = bs->total_sectors * BDRV_SECTOR_SIZE;
sn->vm_state_size = sn_info->vm_state_size;
sn->date_sec = sn_info->date_sec;
sn->date_nsec = sn_info->date_nsec;
sn->vm_clock_nsec = sn_info->vm_clock_nsec;
l1_table_offset = qcow2_alloc_clusters(bs, s->l1_size * sizeof(uint64_t));
if (l1_table_offset < 0) {
ret = l1_table_offset;
goto fail;
}
sn->l1_table_offset = l1_table_offset;
sn->l1_size = s->l1_size;
l1_table = g_malloc(s->l1_size * sizeof(uint64_t));
for(i = 0; i < s->l1_size; i++) {
l1_table[i] = cpu_to_be64(s->l1_table[i]);
}
ret = qcow2_pre_write_overlap_check(bs, QCOW2_OL_DEFAULT,
sn->l1_table_offset, s->l1_size * sizeof(uint64_t));
if (ret < 0) {
goto fail;
}
ret = bdrv_pwrite(bs->file, sn->l1_table_offset, l1_table,
s->l1_size * sizeof(uint64_t));
if (ret < 0) {
goto fail;
}
g_free(l1_table);
l1_table = NULL;
ret = qcow2_update_snapshot_refcount(bs, s->l1_table_offset, s->l1_size, 1);
if (ret < 0) {
goto fail;
}
new_snapshot_list = g_malloc((s->nb_snapshots + 1) * sizeof(QCowSnapshot));
if (s->snapshots) {
memcpy(new_snapshot_list, s->snapshots,
s->nb_snapshots * sizeof(QCowSnapshot));
old_snapshot_list = s->snapshots;
}
s->snapshots = new_snapshot_list;
s->snapshots[s->nb_snapshots++] = *sn;
ret = qcow2_write_snapshots(bs);
if (ret < 0) {
g_free(s->snapshots);
s->snapshots = old_snapshot_list;
s->nb_snapshots--;
goto fail;
}
g_free(old_snapshot_list);
qcow2_discard_clusters(bs, qcow2_vm_state_offset(s),
align_offset(sn->vm_state_size, s->cluster_size)
>> BDRV_SECTOR_BITS,
QCOW2_DISCARD_NEVER);
#ifdef DEBUG_ALLOC
{
BdrvCheckResult result = {0};
qcow2_check_refcounts(bs, &result, 0);
}
#endif
return 0;
fail:
g_free(sn->id_str);
g_free(sn->name);
g_free(l1_table);
return ret;
}
| 1threat
|
Filter input text only accept number and dot vue.js : <p>i have a text box only want accept "Number" and ".[dot]" using Vue.js, anyone can help the code? i'm new on vue.</p>
| 0debug
|
Django - How do I get a str from this charField? : I have been trying to follow documentation but I keep getting the error: 'issues has no attribute content"
My goal is that i need a temp variable to hold data until I commit it to my actual database.
So when reading the code, content is basically tmp, and logComments is when I actually want to commit it to the database. Im trying to develop history tracking of who edited what, and when. However, whenever I call instance.logComments = formIssues.__str__() I keep getting that error even though ive defined a to string method. Can someone point out where I am going wrong?
class issues(ModelForm):
content = forms.CharField(widget=forms.Textarea,max_length=500, label='')
#forms.py
def __str__(self):
return str(self.content)
class Meta:
model = History
fields = ['content']
widgets = {'content': Textarea(attrs={'cols': 50, 'rows': 30})}
labels = {'content': ""}
#views.py
formIssues = issues(request.POST or None)
#This is for saving the issues textbox
if request.method == 'POST' and formIssues.is_valid() and 'Submit Issue' in request.POST:
#History.logComments = formIssues
instance = formIssues.save(commit=False)
instance.logComments = formIssues.__str__()
instance.projectID = 1337
instance.userID = request.user
instance.commentType = "Issue"
instance.save()
#models.py
class History(models.Model):
projectID = models.IntegerField()
userID = models.CharField(max_length=10)
logComments = models.TextField(max_length=500, default='')
commentType = models.CharField(max_length=20, default ='')
timeStamp = models.DateTimeField(auto_now_add=True, auto_now=False)
| 0debug
|
Could not load file or assembly Microsoft.Practices.ServiceLocation, Version=1.3.0.0 : <p>Here is the error I'm getting when I run my application (.NET 4.5):</p>
<pre><code>Server Error in '/' Application.
Could not load file or assembly 'Microsoft.Practices.ServiceLocation, Version=1.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Practices.ServiceLocation, Version=1.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Assembly Load Trace: The following information can be helpful to determine why the assembly 'Microsoft.Practices.ServiceLocation, Version=1.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' could not be loaded.
=== Pre-bind state information ===
LOG: DisplayName = Microsoft.Practices.ServiceLocation, Version=1.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///C:/Users/Austin/Documents/FileStore/FileStore.Web/
LOG: Initial PrivatePath = C:\Users\Austin\Documents\FileStore\FileStore.Web\bin
Calling assembly : Chicago.Security, Version=1.0.5826.21195, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\Austin\Documents\FileStore\FileStore.Web\web.config
LOG: Using host configuration file: C:\Users\Austin\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Redirect found in application configuration file: 1.3.0.0 redirected to 1.3.0.0.
LOG: Post-policy reference: Microsoft.Practices.ServiceLocation, Version=1.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: The same bind was seen before, and was failed with hr = 0x80070002.
Stack Trace:
[FileNotFoundException: Could not load file or assembly 'Microsoft.Practices.ServiceLocation, Version=1.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.]
Chicago.Security.AuthenticationModule.application_AuthenticateRequest(Object sender, EventArgs e) +0
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +141
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69
</code></pre>
<p>I installed the nuget package CommonServiceLocator, but I'm still getting this error. The weird thing is that there is an assembly binding redirect in my web.config file, but the assembly does not appear in the reference list for my project and I cannot find it anywhere to add it. I'm still relatively new to ASP.NET, so I can't seem to pin down what the issue is exactly. Another thing I found to try is to set 'Enable 32 bit applications' to true for my application pool in the IIS Manager, but this did not fix my problem. I've been stuck on this for a while, so any help would be appreciated.</p>
| 0debug
|
av_cold void ff_fft_init_arm(FFTContext *s)
{
int cpu_flags = av_get_cpu_flags();
if (have_vfp(cpu_flags) && !have_vfpv3(cpu_flags)) {
s->fft_calc = ff_fft_calc_vfp;
#if CONFIG_MDCT
s->imdct_half = ff_imdct_half_vfp;
#endif
}
if (have_neon(cpu_flags)) {
s->fft_permute = ff_fft_permute_neon;
s->fft_calc = ff_fft_calc_neon;
#if CONFIG_MDCT
s->imdct_calc = ff_imdct_calc_neon;
s->imdct_half = ff_imdct_half_neon;
s->mdct_calc = ff_mdct_calc_neon;
s->mdct_permutation = FF_MDCT_PERM_INTERLEAVE;
#endif
}
}
| 1threat
|
can you please help solve this error "mac'' : Installing collected packages: nose
Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/nose'
Consider using the `--user` option or check the permissions.
| 0debug
|
Invalid Syntax on .findall (text) highlighting just the ( or random letter? : <p>When attempting to run this I get an 'Invalid Syntax' error and it will highlight either the ( 't' or the space in line </p>
<p>extractedPhone = phoneRegex.findall (text)</p>
<p>Any reasons why? Double checked all other () to ensure everything was opened and closed, renamed text to sample, not sure what is going on! </p>
<p>The goal of this is to search for phone numbers and emails from PDF just by copying the file and then running this.</p>
<p>Thank you</p>
<pre><code>#! Python3
import re
import pyperclip
#create a regex for phone numbers
phoneRegex = re.compile(r'''
((\d\d\d)|(\(\d\d\d\)))? #area code optional
(\s | -) #first seperator
\d\d\d #three digits
(\s | -) #second seperator
\d\d\d\d #last four digits
(((ext(\.)?\s)|x) #ext. 12345
(\d{2,5))? #ext optional number
''', re.VERBOSE)
#create a regex for email addresses
emailRegex = re.compile('''(
[A-Za-z0-9-_+.]+ #name part (AZaz+_-.)
@ #@
[A-Za-z0-9-_+.]+ #domain
)''' re.VERBOSE)
#get text off the clipboard
text = pyperclip.paste()
#extract the email / phone from this text
extractedPhone = phoneRegex.findall (text) #here is the issue line
extractedEmail = emailRegex.findall (text)
allPhoneNumber = []
for numbers in extractedPhone:
allPhoneNumbers.append(phoneNumber[0])
print (extractedPhone)
print (extractedEmail)
</code></pre>
| 0debug
|
Android Studio 2.2 Google play services sync Error : <p>I have update to android studio 2.2</p>
<p>I started a new project and i included </p>
<pre><code>compile 'com.google.android.gms:play-services-vision:9.4.0+'
</code></pre>
<p>in my dependencies.</p>
<p>I am getting this Error when im launching the gradle sync.</p>
<p>Information:Gradle tasks [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies]
Error:com.android.builder.internal.aapt.AaptException: Failed to crunch file D:\Android\cloned apps\android-vision-master\android-vision-master\visionSamples\barcode-reader\app\build\intermediates\exploded-aar\com.google.android.gms\play-services-base\9.4.0\res\drawable-xhdpi-v4\common_google_signin_btn_text_dark_pressed.9.png into D:\Android\cloned apps\android-vision-master\android-vision-master\visionSamples\barcode-reader\app\build\intermediates\res\merged\debug\drawable-xhdpi-v4\common_google_signin_btn_text_dark_pressed.9.png
Error:Execution failed for task ':app:mergeDebugResources'.</p>
<blockquote>
<p>Error: com.android.builder.internal.aapt.AaptException: Failed to crunch file D:\Android\cloned apps\android-vision-master\android-vision-master\visionSamples\barcode-reader\app\build\intermediates\exploded-aar\com.google.android.gms\play-services-base\9.4.0\res\drawable-xhdpi-v4\common_google_signin_btn_text_dark_pressed.9.png into D:\Android\cloned apps\android-vision-master\android-vision-master\visionSamples\barcode-reader\app\build\intermediates\res\merged\debug\drawable-xhdpi-v4\common_google_signin_btn_text_dark_pressed.9.png
Information:BUILD FAILED
Information:Total time: 2.132 secs
Information:2 errors
Information:0 warnings
Information:See complete output in console</p>
</blockquote>
| 0debug
|
static int local_fsync(FsContext *ctx, int fd)
{
if (0)
(void)local_set_xattr(NULL, NULL);
return fsync(fd);
}
| 1threat
|
What are all the valid selectors for ViewChild and ContentChild? : <p>I'm looking for a comprehensive list of the valid selectors I can use to access child components / DOM elements via <code>@ViewChild</code> and <code>@ContentChild</code>.</p>
<p>Say I have a child <code>HelloComponent</code>:</p>
<p>I know I can add a template <code>#ref</code> and query for it, like so:</p>
<pre><code><hello #myHello></hello>
@ViewChild('myHello') myHello: HelloComponent;
</code></pre>
<p>Or I can look for that component directly (without the template <code>#ref</code>):</p>
<pre><code>@ViewChild(HelloComponent) myHello: HelloComponent;
</code></pre>
<p>In <a href="https://github.com/angular/angular/issues/21734" rel="noreferrer">this issue</a>, it is mentioned that one can use the following selectors: </p>
<blockquote>
<p>we are currently supporting a sub-set of CSS selectors:<br>
* element selectors<br>
* attribute selectors (including values)<br>
* :not(...) pseudo-selector<br>
* combination of the above (including ,)</p>
</blockquote>
<p>But when I tested these in Stackblitz to verify (<a href="https://stackblitz.com/edit/angular-ltsb4m" rel="noreferrer">here's the link to that</a>), I couldn't actually get any of the first three to work. <em>(Check the console to see <code>undefined</code> for the types of selectors I couldn't get working. I'm unsure if I'm doing something wrong with those selectors or if the actual list is different.)</em></p>
<p>So, which selectors will work? Also, is the list the same for <code>@ViewChild</code>, <code>@ContentChild</code>, <code>@ViewChildren</code>, and <code>@ContentChildren</code>?</p>
| 0debug
|
API interface errors : i have been following a online tutorial and i have been following carefully the code below is a API interface yet i keep getting errors like illegal start of type and such
package com.gwiddle.airsoftcreations.airsoftapp;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Query;
public interface ApiInterface {
@GET("register.php")
Call<User> performRegistration(@Query("name") String Name,
@Query("user_name") String UserName, @Query("user_password") String
UserPassword );
@GET("login.php")
Call<User>perfromUserLogin@Query("user_name") String Username,
@Query("user_password") String UserPassword)
}
please help
| 0debug
|
How to build executable with name other than Golang package : <p>Is it possible to build (install, go get, etc) an executable with the name <code>foobar</code> if my Golang package name is one of the following:</p>
<ul>
<li><code>github.com/username/go-foobar</code></li>
<li><code>github.com/username/foobar-tools</code></li>
</ul>
<p>and has <code>main.go</code> in the package root?</p>
| 0debug
|
static int mpeg_decode_mb(MpegEncContext *s,
DCTELEM block[12][64])
{
int i, j, k, cbp, val, mb_type, motion_type;
dprintf("decode_mb: x=%d y=%d\n", s->mb_x, s->mb_y);
assert(s->mb_skiped==0);
if (s->mb_skip_run-- != 0) {
if(s->pict_type == I_TYPE){
av_log(s->avctx, AV_LOG_ERROR, "skiped MB in I frame at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
s->mb_intra = 0;
for(i=0;i<12;i++)
s->block_last_index[i] = -1;
if(s->picture_structure == PICT_FRAME)
s->mv_type = MV_TYPE_16X16;
else
s->mv_type = MV_TYPE_FIELD;
if (s->pict_type == P_TYPE) {
s->mv_dir = MV_DIR_FORWARD;
s->mv[0][0][0] = s->mv[0][0][1] = 0;
s->last_mv[0][0][0] = s->last_mv[0][0][1] = 0;
s->last_mv[0][1][0] = s->last_mv[0][1][1] = 0;
s->field_select[0][0]= s->picture_structure - 1;
s->mb_skiped = 1;
s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride ]= MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16;
} else {
s->mv[0][0][0] = s->last_mv[0][0][0];
s->mv[0][0][1] = s->last_mv[0][0][1];
s->mv[1][0][0] = s->last_mv[1][0][0];
s->mv[1][0][1] = s->last_mv[1][0][1];
s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride ]=
s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride - 1] | MB_TYPE_SKIP;
if((s->mv[0][0][0]|s->mv[0][0][1]|s->mv[1][0][0]|s->mv[1][0][1])==0)
s->mb_skiped = 1;
}
return 0;
}
switch(s->pict_type) {
default:
case I_TYPE:
if (get_bits1(&s->gb) == 0) {
if (get_bits1(&s->gb) == 0){
av_log(s->avctx, AV_LOG_ERROR, "invalid mb type in I Frame at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
mb_type = MB_TYPE_QUANT | MB_TYPE_INTRA;
} else {
mb_type = MB_TYPE_INTRA;
}
break;
case P_TYPE:
mb_type = get_vlc2(&s->gb, mb_ptype_vlc.table, MB_PTYPE_VLC_BITS, 1);
if (mb_type < 0){
av_log(s->avctx, AV_LOG_ERROR, "invalid mb type in P Frame at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
mb_type = ptype2mb_type[ mb_type ];
break;
case B_TYPE:
mb_type = get_vlc2(&s->gb, mb_btype_vlc.table, MB_BTYPE_VLC_BITS, 1);
if (mb_type < 0){
av_log(s->avctx, AV_LOG_ERROR, "invalid mb type in B Frame at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
mb_type = btype2mb_type[ mb_type ];
break;
}
dprintf("mb_type=%x\n", mb_type);
if (IS_INTRA(mb_type)) {
if (s->picture_structure == PICT_FRAME &&
!s->frame_pred_frame_dct) {
s->interlaced_dct = get_bits1(&s->gb);
}
if (IS_QUANT(mb_type))
s->qscale = get_qscale(s);
if (s->concealment_motion_vectors) {
if (s->picture_structure != PICT_FRAME)
skip_bits1(&s->gb);
s->mv[0][0][0]= s->last_mv[0][0][0]= s->last_mv[0][1][0] =
mpeg_decode_motion(s, s->mpeg_f_code[0][0], s->last_mv[0][0][0]);
s->mv[0][0][1]= s->last_mv[0][0][1]= s->last_mv[0][1][1] =
mpeg_decode_motion(s, s->mpeg_f_code[0][1], s->last_mv[0][0][1]);
skip_bits1(&s->gb);
}else
memset(s->last_mv, 0, sizeof(s->last_mv));
s->mb_intra = 1;
#ifdef HAVE_XVMC
if(s->avctx->xvmc_acceleration > 1){
XVMC_pack_pblocks(s,-1);
if(s->swap_uv){
exchange_uv(s);
}
}
#endif
if (s->codec_id == CODEC_ID_MPEG2VIDEO) {
for(i=0;i<4+(1<<s->chroma_format);i++) {
if (mpeg2_decode_block_intra(s, s->pblocks[i], i) < 0)
return -1;
}
} else {
for(i=0;i<6;i++) {
if (mpeg1_decode_block_intra(s, s->pblocks[i], i) < 0)
return -1;
}
}
} else {
if (mb_type & MB_TYPE_ZERO_MV){
assert(mb_type & MB_TYPE_CBP);
if (s->picture_structure == PICT_FRAME &&
!s->frame_pred_frame_dct) {
s->interlaced_dct = get_bits1(&s->gb);
}
if (IS_QUANT(mb_type))
s->qscale = get_qscale(s);
s->mv_dir = MV_DIR_FORWARD;
if(s->picture_structure == PICT_FRAME)
s->mv_type = MV_TYPE_16X16;
else{
s->mv_type = MV_TYPE_FIELD;
mb_type |= MB_TYPE_INTERLACED;
s->field_select[0][0]= s->picture_structure - 1;
}
s->last_mv[0][0][0] = 0;
s->last_mv[0][0][1] = 0;
s->last_mv[0][1][0] = 0;
s->last_mv[0][1][1] = 0;
s->mv[0][0][0] = 0;
s->mv[0][0][1] = 0;
}else{
assert(mb_type & MB_TYPE_L0L1);
if (s->frame_pred_frame_dct)
motion_type = MT_FRAME;
else{
motion_type = get_bits(&s->gb, 2);
}
if (s->picture_structure == PICT_FRAME &&
!s->frame_pred_frame_dct && HAS_CBP(mb_type)) {
s->interlaced_dct = get_bits1(&s->gb);
}
if (IS_QUANT(mb_type))
s->qscale = get_qscale(s);
s->mv_dir = 0;
for(i=0;i<2;i++) {
if (USES_LIST(mb_type, i)) {
s->mv_dir |= (MV_DIR_FORWARD >> i);
dprintf("motion_type=%d\n", motion_type);
switch(motion_type) {
case MT_FRAME:
if (s->picture_structure == PICT_FRAME) {
mb_type |= MB_TYPE_16x16;
s->mv_type = MV_TYPE_16X16;
s->mv[i][0][0]= s->last_mv[i][0][0]= s->last_mv[i][1][0] =
mpeg_decode_motion(s, s->mpeg_f_code[i][0], s->last_mv[i][0][0]);
s->mv[i][0][1]= s->last_mv[i][0][1]= s->last_mv[i][1][1] =
mpeg_decode_motion(s, s->mpeg_f_code[i][1], s->last_mv[i][0][1]);
if (s->full_pel[i]){
s->mv[i][0][0] <<= 1;
s->mv[i][0][1] <<= 1;
}
} else {
mb_type |= MB_TYPE_16x8 | MB_TYPE_INTERLACED;
s->mv_type = MV_TYPE_16X8;
for(j=0;j<2;j++) {
s->field_select[i][j] = get_bits1(&s->gb);
for(k=0;k<2;k++) {
val = mpeg_decode_motion(s, s->mpeg_f_code[i][k],
s->last_mv[i][j][k]);
s->last_mv[i][j][k] = val;
s->mv[i][j][k] = val;
}
}
}
break;
case MT_FIELD:
s->mv_type = MV_TYPE_FIELD;
if (s->picture_structure == PICT_FRAME) {
mb_type |= MB_TYPE_16x8 | MB_TYPE_INTERLACED;
for(j=0;j<2;j++) {
s->field_select[i][j] = get_bits1(&s->gb);
val = mpeg_decode_motion(s, s->mpeg_f_code[i][0],
s->last_mv[i][j][0]);
s->last_mv[i][j][0] = val;
s->mv[i][j][0] = val;
dprintf("fmx=%d\n", val);
val = mpeg_decode_motion(s, s->mpeg_f_code[i][1],
s->last_mv[i][j][1] >> 1);
s->last_mv[i][j][1] = val << 1;
s->mv[i][j][1] = val;
dprintf("fmy=%d\n", val);
}
} else {
mb_type |= MB_TYPE_16x16 | MB_TYPE_INTERLACED;
s->field_select[i][0] = get_bits1(&s->gb);
for(k=0;k<2;k++) {
val = mpeg_decode_motion(s, s->mpeg_f_code[i][k],
s->last_mv[i][0][k]);
s->last_mv[i][0][k] = val;
s->last_mv[i][1][k] = val;
s->mv[i][0][k] = val;
}
}
break;
case MT_DMV:
{
int dmx, dmy, mx, my, m;
mx = mpeg_decode_motion(s, s->mpeg_f_code[i][0],
s->last_mv[i][0][0]);
s->last_mv[i][0][0] = mx;
s->last_mv[i][1][0] = mx;
dmx = get_dmv(s);
my = mpeg_decode_motion(s, s->mpeg_f_code[i][1],
s->last_mv[i][0][1] >> 1);
dmy = get_dmv(s);
s->mv_type = MV_TYPE_DMV;
s->last_mv[i][0][1] = my<<1;
s->last_mv[i][1][1] = my<<1;
s->mv[i][0][0] = mx;
s->mv[i][0][1] = my;
s->mv[i][1][0] = mx;
s->mv[i][1][1] = my;
if (s->picture_structure == PICT_FRAME) {
mb_type |= MB_TYPE_16x16 | MB_TYPE_INTERLACED;
m = s->top_field_first ? 1 : 3;
s->mv[i][2][0] = ((mx * m + (mx > 0)) >> 1) + dmx;
s->mv[i][2][1] = ((my * m + (my > 0)) >> 1) + dmy - 1;
m = 4 - m;
s->mv[i][3][0] = ((mx * m + (mx > 0)) >> 1) + dmx;
s->mv[i][3][1] = ((my * m + (my > 0)) >> 1) + dmy + 1;
} else {
mb_type |= MB_TYPE_16x16;
s->mv[i][2][0] = ((mx + (mx > 0)) >> 1) + dmx;
s->mv[i][2][1] = ((my + (my > 0)) >> 1) + dmy;
if(s->picture_structure == PICT_TOP_FIELD)
s->mv[i][2][1]--;
else
s->mv[i][2][1]++;
}
}
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "00 motion_type at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
}
}
}
s->mb_intra = 0;
if (HAS_CBP(mb_type)) {
cbp = get_vlc2(&s->gb, mb_pat_vlc.table, MB_PAT_VLC_BITS, 1);
if (cbp < 0){
av_log(s->avctx, AV_LOG_ERROR, "invalid cbp at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
cbp++;
if(s->chroma_format == 2){
cbp|= ( get_bits(&s->gb,2) ) << 6;
}else
if(s->chroma_format > 2){
cbp|= ( get_bits(&s->gb,6) ) << 6;
}
#ifdef HAVE_XVMC
if(s->avctx->xvmc_acceleration > 1){
XVMC_pack_pblocks(s,cbp);
if(s->swap_uv){
exchange_uv(s);
}
}
#endif
if (s->codec_id == CODEC_ID_MPEG2VIDEO) {
for(i=0;i<6;i++) {
if (cbp & (1<<(5-i)) ) {
if (mpeg2_decode_block_non_intra(s, s->pblocks[i], i) < 0)
return -1;
} else {
s->block_last_index[i] = -1;
}
}
if (s->chroma_format >= 2) {
if (s->chroma_format == 2) {
for(i=6;i<8;i++) {
if (cbp & (1<<(6+7-i)) ) {
if (mpeg2_decode_block_non_intra(s, s->pblocks[i], i) < 0)
return -1;
} else {
s->block_last_index[i] = -1;
}
}
}else{
for(i=6;i<12;i++) {
if (cbp & (1<<(6+11-i)) ) {
if (mpeg2_decode_block_non_intra(s, s->pblocks[i], i) < 0)
return -1;
} else {
s->block_last_index[i] = -1;
}
}
}
}
} else {
for(i=0;i<6;i++) {
if (cbp & 32) {
if (mpeg1_decode_block_inter(s, s->pblocks[i], i) < 0)
return -1;
} else {
s->block_last_index[i] = -1;
}
cbp+=cbp;
}
}
}else{
for(i=0;i<6;i++)
s->block_last_index[i] = -1;
}
}
s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride ]= mb_type;
return 0;
}
| 1threat
|
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max){
AVRational a0={0,1}, a1={1,0};
int sign= (num<0) ^ (den<0);
int64_t gcd= av_gcd(FFABS(num), FFABS(den));
if(gcd){
num = FFABS(num)/gcd;
den = FFABS(den)/gcd;
}
if(num<=max && den<=max){
a1= (AVRational){num, den};
den=0;
}
while(den){
uint64_t x = num / den;
int64_t next_den= num - den*x;
int64_t a2n= x*a1.num + a0.num;
int64_t a2d= x*a1.den + a0.den;
if(a2n > max || a2d > max){
if(a1.num) x= (max - a0.num) / a1.num;
if(a1.den) x= FFMIN(x, (max - a0.den) / a1.den);
if (den*(2*x*a1.den + a0.den) > num*a1.den)
a1 = (AVRational){x*a1.num + a0.num, x*a1.den + a0.den};
break;
}
a0= a1;
a1= (AVRational){a2n, a2d};
num= den;
den= next_den;
}
assert(av_gcd(a1.num, a1.den) <= 1U);
*dst_num = sign ? -a1.num : a1.num;
*dst_den = a1.den;
return den==0;
}
| 1threat
|
static int disas_neon_data_insn(DisasContext *s, uint32_t insn)
{
int op;
int q;
int rd, rn, rm;
int size;
int shift;
int pass;
int count;
int pairwise;
int u;
uint32_t imm, mask;
TCGv_i32 tmp, tmp2, tmp3, tmp4, tmp5;
TCGv_i64 tmp64;
if (!s->cpacr_fpen) {
gen_exception_insn(s, 4, EXCP_UDEF,
syn_fp_access_trap(1, 0xe, s->thumb),
default_exception_el(s));
return 0;
}
if (!s->vfp_enabled)
return 1;
q = (insn & (1 << 6)) != 0;
u = (insn >> 24) & 1;
VFP_DREG_D(rd, insn);
VFP_DREG_N(rn, insn);
VFP_DREG_M(rm, insn);
size = (insn >> 20) & 3;
if ((insn & (1 << 23)) == 0) {
op = ((insn >> 7) & 0x1e) | ((insn >> 4) & 1);
if ((neon_3r_sizes[op] & (1 << size)) == 0) {
return 1;
}
if (q && ((rd | rn | rm) & 1)) {
return 1;
}
if (op == NEON_3R_SHA) {
if (!q) {
return 1;
}
if (!u) {
if (!arm_dc_feature(s, ARM_FEATURE_V8_SHA1)) {
return 1;
}
tmp = tcg_const_i32(rd);
tmp2 = tcg_const_i32(rn);
tmp3 = tcg_const_i32(rm);
tmp4 = tcg_const_i32(size);
gen_helper_crypto_sha1_3reg(cpu_env, tmp, tmp2, tmp3, tmp4);
tcg_temp_free_i32(tmp4);
} else {
if (!arm_dc_feature(s, ARM_FEATURE_V8_SHA256) || size == 3) {
return 1;
}
tmp = tcg_const_i32(rd);
tmp2 = tcg_const_i32(rn);
tmp3 = tcg_const_i32(rm);
switch (size) {
case 0:
gen_helper_crypto_sha256h(cpu_env, tmp, tmp2, tmp3);
break;
case 1:
gen_helper_crypto_sha256h2(cpu_env, tmp, tmp2, tmp3);
break;
case 2:
gen_helper_crypto_sha256su1(cpu_env, tmp, tmp2, tmp3);
break;
}
}
tcg_temp_free_i32(tmp);
tcg_temp_free_i32(tmp2);
tcg_temp_free_i32(tmp3);
return 0;
}
if (size == 3 && op != NEON_3R_LOGIC) {
for (pass = 0; pass < (q ? 2 : 1); pass++) {
neon_load_reg64(cpu_V0, rn + pass);
neon_load_reg64(cpu_V1, rm + pass);
switch (op) {
case NEON_3R_VQADD:
if (u) {
gen_helper_neon_qadd_u64(cpu_V0, cpu_env,
cpu_V0, cpu_V1);
} else {
gen_helper_neon_qadd_s64(cpu_V0, cpu_env,
cpu_V0, cpu_V1);
}
break;
case NEON_3R_VQSUB:
if (u) {
gen_helper_neon_qsub_u64(cpu_V0, cpu_env,
cpu_V0, cpu_V1);
} else {
gen_helper_neon_qsub_s64(cpu_V0, cpu_env,
cpu_V0, cpu_V1);
}
break;
case NEON_3R_VSHL:
if (u) {
gen_helper_neon_shl_u64(cpu_V0, cpu_V1, cpu_V0);
} else {
gen_helper_neon_shl_s64(cpu_V0, cpu_V1, cpu_V0);
}
break;
case NEON_3R_VQSHL:
if (u) {
gen_helper_neon_qshl_u64(cpu_V0, cpu_env,
cpu_V1, cpu_V0);
} else {
gen_helper_neon_qshl_s64(cpu_V0, cpu_env,
cpu_V1, cpu_V0);
}
break;
case NEON_3R_VRSHL:
if (u) {
gen_helper_neon_rshl_u64(cpu_V0, cpu_V1, cpu_V0);
} else {
gen_helper_neon_rshl_s64(cpu_V0, cpu_V1, cpu_V0);
}
break;
case NEON_3R_VQRSHL:
if (u) {
gen_helper_neon_qrshl_u64(cpu_V0, cpu_env,
cpu_V1, cpu_V0);
} else {
gen_helper_neon_qrshl_s64(cpu_V0, cpu_env,
cpu_V1, cpu_V0);
}
break;
case NEON_3R_VADD_VSUB:
if (u) {
tcg_gen_sub_i64(CPU_V001);
} else {
tcg_gen_add_i64(CPU_V001);
}
break;
default:
abort();
}
neon_store_reg64(cpu_V0, rd + pass);
}
return 0;
}
pairwise = 0;
switch (op) {
case NEON_3R_VSHL:
case NEON_3R_VQSHL:
case NEON_3R_VRSHL:
case NEON_3R_VQRSHL:
{
int rtmp;
rtmp = rn;
rn = rm;
rm = rtmp;
}
break;
case NEON_3R_VPADD:
if (u) {
return 1;
}
case NEON_3R_VPMAX:
case NEON_3R_VPMIN:
pairwise = 1;
break;
case NEON_3R_FLOAT_ARITH:
pairwise = (u && size < 2);
break;
case NEON_3R_FLOAT_MINMAX:
pairwise = u;
break;
case NEON_3R_FLOAT_CMP:
if (!u && size) {
return 1;
}
break;
case NEON_3R_FLOAT_ACMP:
if (!u) {
return 1;
}
break;
case NEON_3R_FLOAT_MISC:
if (u && !arm_dc_feature(s, ARM_FEATURE_V8)) {
return 1;
}
break;
case NEON_3R_VMUL:
if (u && (size != 0)) {
return 1;
}
break;
case NEON_3R_VFM:
if (!arm_dc_feature(s, ARM_FEATURE_VFP4) || u) {
return 1;
}
break;
default:
break;
}
if (pairwise && q) {
return 1;
}
for (pass = 0; pass < (q ? 4 : 2); pass++) {
if (pairwise) {
if (pass < 1) {
tmp = neon_load_reg(rn, 0);
tmp2 = neon_load_reg(rn, 1);
} else {
tmp = neon_load_reg(rm, 0);
tmp2 = neon_load_reg(rm, 1);
}
} else {
tmp = neon_load_reg(rn, pass);
tmp2 = neon_load_reg(rm, pass);
}
switch (op) {
case NEON_3R_VHADD:
GEN_NEON_INTEGER_OP(hadd);
break;
case NEON_3R_VQADD:
GEN_NEON_INTEGER_OP_ENV(qadd);
break;
case NEON_3R_VRHADD:
GEN_NEON_INTEGER_OP(rhadd);
break;
case NEON_3R_LOGIC:
switch ((u << 2) | size) {
case 0:
tcg_gen_and_i32(tmp, tmp, tmp2);
break;
case 1:
tcg_gen_andc_i32(tmp, tmp, tmp2);
break;
case 2:
tcg_gen_or_i32(tmp, tmp, tmp2);
break;
case 3:
tcg_gen_orc_i32(tmp, tmp, tmp2);
break;
case 4:
tcg_gen_xor_i32(tmp, tmp, tmp2);
break;
case 5:
tmp3 = neon_load_reg(rd, pass);
gen_neon_bsl(tmp, tmp, tmp2, tmp3);
tcg_temp_free_i32(tmp3);
break;
case 6:
tmp3 = neon_load_reg(rd, pass);
gen_neon_bsl(tmp, tmp, tmp3, tmp2);
tcg_temp_free_i32(tmp3);
break;
case 7:
tmp3 = neon_load_reg(rd, pass);
gen_neon_bsl(tmp, tmp3, tmp, tmp2);
tcg_temp_free_i32(tmp3);
break;
}
break;
case NEON_3R_VHSUB:
GEN_NEON_INTEGER_OP(hsub);
break;
case NEON_3R_VQSUB:
GEN_NEON_INTEGER_OP_ENV(qsub);
break;
case NEON_3R_VCGT:
GEN_NEON_INTEGER_OP(cgt);
break;
case NEON_3R_VCGE:
GEN_NEON_INTEGER_OP(cge);
break;
case NEON_3R_VSHL:
GEN_NEON_INTEGER_OP(shl);
break;
case NEON_3R_VQSHL:
GEN_NEON_INTEGER_OP_ENV(qshl);
break;
case NEON_3R_VRSHL:
GEN_NEON_INTEGER_OP(rshl);
break;
case NEON_3R_VQRSHL:
GEN_NEON_INTEGER_OP_ENV(qrshl);
break;
case NEON_3R_VMAX:
GEN_NEON_INTEGER_OP(max);
break;
case NEON_3R_VMIN:
GEN_NEON_INTEGER_OP(min);
break;
case NEON_3R_VABD:
GEN_NEON_INTEGER_OP(abd);
break;
case NEON_3R_VABA:
GEN_NEON_INTEGER_OP(abd);
tcg_temp_free_i32(tmp2);
tmp2 = neon_load_reg(rd, pass);
gen_neon_add(size, tmp, tmp2);
break;
case NEON_3R_VADD_VSUB:
if (!u) {
gen_neon_add(size, tmp, tmp2);
} else {
switch (size) {
case 0: gen_helper_neon_sub_u8(tmp, tmp, tmp2); break;
case 1: gen_helper_neon_sub_u16(tmp, tmp, tmp2); break;
case 2: tcg_gen_sub_i32(tmp, tmp, tmp2); break;
default: abort();
}
}
break;
case NEON_3R_VTST_VCEQ:
if (!u) {
switch (size) {
case 0: gen_helper_neon_tst_u8(tmp, tmp, tmp2); break;
case 1: gen_helper_neon_tst_u16(tmp, tmp, tmp2); break;
case 2: gen_helper_neon_tst_u32(tmp, tmp, tmp2); break;
default: abort();
}
} else {
switch (size) {
case 0: gen_helper_neon_ceq_u8(tmp, tmp, tmp2); break;
case 1: gen_helper_neon_ceq_u16(tmp, tmp, tmp2); break;
case 2: gen_helper_neon_ceq_u32(tmp, tmp, tmp2); break;
default: abort();
}
}
break;
case NEON_3R_VML:
switch (size) {
case 0: gen_helper_neon_mul_u8(tmp, tmp, tmp2); break;
case 1: gen_helper_neon_mul_u16(tmp, tmp, tmp2); break;
case 2: tcg_gen_mul_i32(tmp, tmp, tmp2); break;
default: abort();
}
tcg_temp_free_i32(tmp2);
tmp2 = neon_load_reg(rd, pass);
if (u) {
gen_neon_rsb(size, tmp, tmp2);
} else {
gen_neon_add(size, tmp, tmp2);
}
break;
case NEON_3R_VMUL:
if (u) {
gen_helper_neon_mul_p8(tmp, tmp, tmp2);
} else {
switch (size) {
case 0: gen_helper_neon_mul_u8(tmp, tmp, tmp2); break;
case 1: gen_helper_neon_mul_u16(tmp, tmp, tmp2); break;
case 2: tcg_gen_mul_i32(tmp, tmp, tmp2); break;
default: abort();
}
}
break;
case NEON_3R_VPMAX:
GEN_NEON_INTEGER_OP(pmax);
break;
case NEON_3R_VPMIN:
GEN_NEON_INTEGER_OP(pmin);
break;
case NEON_3R_VQDMULH_VQRDMULH:
if (!u) {
switch (size) {
case 1:
gen_helper_neon_qdmulh_s16(tmp, cpu_env, tmp, tmp2);
break;
case 2:
gen_helper_neon_qdmulh_s32(tmp, cpu_env, tmp, tmp2);
break;
default: abort();
}
} else {
switch (size) {
case 1:
gen_helper_neon_qrdmulh_s16(tmp, cpu_env, tmp, tmp2);
break;
case 2:
gen_helper_neon_qrdmulh_s32(tmp, cpu_env, tmp, tmp2);
break;
default: abort();
}
}
break;
case NEON_3R_VPADD:
switch (size) {
case 0: gen_helper_neon_padd_u8(tmp, tmp, tmp2); break;
case 1: gen_helper_neon_padd_u16(tmp, tmp, tmp2); break;
case 2: tcg_gen_add_i32(tmp, tmp, tmp2); break;
default: abort();
}
break;
case NEON_3R_FLOAT_ARITH:
{
TCGv_ptr fpstatus = get_fpstatus_ptr(1);
switch ((u << 2) | size) {
case 0:
case 4:
gen_helper_vfp_adds(tmp, tmp, tmp2, fpstatus);
break;
case 2:
gen_helper_vfp_subs(tmp, tmp, tmp2, fpstatus);
break;
case 6:
gen_helper_neon_abd_f32(tmp, tmp, tmp2, fpstatus);
break;
default:
abort();
}
tcg_temp_free_ptr(fpstatus);
break;
}
case NEON_3R_FLOAT_MULTIPLY:
{
TCGv_ptr fpstatus = get_fpstatus_ptr(1);
gen_helper_vfp_muls(tmp, tmp, tmp2, fpstatus);
if (!u) {
tcg_temp_free_i32(tmp2);
tmp2 = neon_load_reg(rd, pass);
if (size == 0) {
gen_helper_vfp_adds(tmp, tmp, tmp2, fpstatus);
} else {
gen_helper_vfp_subs(tmp, tmp2, tmp, fpstatus);
}
}
tcg_temp_free_ptr(fpstatus);
break;
}
case NEON_3R_FLOAT_CMP:
{
TCGv_ptr fpstatus = get_fpstatus_ptr(1);
if (!u) {
gen_helper_neon_ceq_f32(tmp, tmp, tmp2, fpstatus);
} else {
if (size == 0) {
gen_helper_neon_cge_f32(tmp, tmp, tmp2, fpstatus);
} else {
gen_helper_neon_cgt_f32(tmp, tmp, tmp2, fpstatus);
}
}
tcg_temp_free_ptr(fpstatus);
break;
}
case NEON_3R_FLOAT_ACMP:
{
TCGv_ptr fpstatus = get_fpstatus_ptr(1);
if (size == 0) {
gen_helper_neon_acge_f32(tmp, tmp, tmp2, fpstatus);
} else {
gen_helper_neon_acgt_f32(tmp, tmp, tmp2, fpstatus);
}
tcg_temp_free_ptr(fpstatus);
break;
}
case NEON_3R_FLOAT_MINMAX:
{
TCGv_ptr fpstatus = get_fpstatus_ptr(1);
if (size == 0) {
gen_helper_vfp_maxs(tmp, tmp, tmp2, fpstatus);
} else {
gen_helper_vfp_mins(tmp, tmp, tmp2, fpstatus);
}
tcg_temp_free_ptr(fpstatus);
break;
}
case NEON_3R_FLOAT_MISC:
if (u) {
TCGv_ptr fpstatus = get_fpstatus_ptr(1);
if (size == 0) {
gen_helper_vfp_maxnums(tmp, tmp, tmp2, fpstatus);
} else {
gen_helper_vfp_minnums(tmp, tmp, tmp2, fpstatus);
}
tcg_temp_free_ptr(fpstatus);
} else {
if (size == 0) {
gen_helper_recps_f32(tmp, tmp, tmp2, cpu_env);
} else {
gen_helper_rsqrts_f32(tmp, tmp, tmp2, cpu_env);
}
}
break;
case NEON_3R_VFM:
{
TCGv_ptr fpstatus = get_fpstatus_ptr(1);
TCGv_i32 tmp3 = neon_load_reg(rd, pass);
if (size) {
gen_helper_vfp_negs(tmp, tmp);
}
gen_helper_vfp_muladds(tmp, tmp, tmp2, tmp3, fpstatus);
tcg_temp_free_i32(tmp3);
tcg_temp_free_ptr(fpstatus);
break;
}
default:
abort();
}
tcg_temp_free_i32(tmp2);
if (pairwise && rd == rm) {
neon_store_scratch(pass, tmp);
} else {
neon_store_reg(rd, pass, tmp);
}
}
if (pairwise && rd == rm) {
for (pass = 0; pass < (q ? 4 : 2); pass++) {
tmp = neon_load_scratch(pass);
neon_store_reg(rd, pass, tmp);
}
}
} else if (insn & (1 << 4)) {
if ((insn & 0x00380080) != 0) {
op = (insn >> 8) & 0xf;
if (insn & (1 << 7)) {
if (op > 7) {
return 1;
}
size = 3;
} else {
size = 2;
while ((insn & (1 << (size + 19))) == 0)
size--;
}
shift = (insn >> 16) & ((1 << (3 + size)) - 1);
if (op < 8) {
if (q && ((rd | rm) & 1)) {
return 1;
}
if (!u && (op == 4 || op == 6)) {
return 1;
}
if (op <= 4)
shift = shift - (1 << (size + 3));
if (size == 3) {
count = q + 1;
} else {
count = q ? 4: 2;
}
switch (size) {
case 0:
imm = (uint8_t) shift;
imm |= imm << 8;
imm |= imm << 16;
break;
case 1:
imm = (uint16_t) shift;
imm |= imm << 16;
break;
case 2:
case 3:
imm = shift;
break;
default:
abort();
}
for (pass = 0; pass < count; pass++) {
if (size == 3) {
neon_load_reg64(cpu_V0, rm + pass);
tcg_gen_movi_i64(cpu_V1, imm);
switch (op) {
case 0:
case 1:
if (u)
gen_helper_neon_shl_u64(cpu_V0, cpu_V0, cpu_V1);
else
gen_helper_neon_shl_s64(cpu_V0, cpu_V0, cpu_V1);
break;
case 2:
case 3:
if (u)
gen_helper_neon_rshl_u64(cpu_V0, cpu_V0, cpu_V1);
else
gen_helper_neon_rshl_s64(cpu_V0, cpu_V0, cpu_V1);
break;
case 4:
case 5:
gen_helper_neon_shl_u64(cpu_V0, cpu_V0, cpu_V1);
break;
case 6:
gen_helper_neon_qshlu_s64(cpu_V0, cpu_env,
cpu_V0, cpu_V1);
break;
case 7:
if (u) {
gen_helper_neon_qshl_u64(cpu_V0, cpu_env,
cpu_V0, cpu_V1);
} else {
gen_helper_neon_qshl_s64(cpu_V0, cpu_env,
cpu_V0, cpu_V1);
}
break;
}
if (op == 1 || op == 3) {
neon_load_reg64(cpu_V1, rd + pass);
tcg_gen_add_i64(cpu_V0, cpu_V0, cpu_V1);
} else if (op == 4 || (op == 5 && u)) {
neon_load_reg64(cpu_V1, rd + pass);
uint64_t mask;
if (shift < -63 || shift > 63) {
mask = 0;
} else {
if (op == 4) {
mask = 0xffffffffffffffffull >> -shift;
} else {
mask = 0xffffffffffffffffull << shift;
}
}
tcg_gen_andi_i64(cpu_V1, cpu_V1, ~mask);
tcg_gen_or_i64(cpu_V0, cpu_V0, cpu_V1);
}
neon_store_reg64(cpu_V0, rd + pass);
} else {
tmp = neon_load_reg(rm, pass);
tmp2 = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp2, imm);
switch (op) {
case 0:
case 1:
GEN_NEON_INTEGER_OP(shl);
break;
case 2:
case 3:
GEN_NEON_INTEGER_OP(rshl);
break;
case 4:
case 5:
switch (size) {
case 0: gen_helper_neon_shl_u8(tmp, tmp, tmp2); break;
case 1: gen_helper_neon_shl_u16(tmp, tmp, tmp2); break;
case 2: gen_helper_neon_shl_u32(tmp, tmp, tmp2); break;
default: abort();
}
break;
case 6:
switch (size) {
case 0:
gen_helper_neon_qshlu_s8(tmp, cpu_env,
tmp, tmp2);
break;
case 1:
gen_helper_neon_qshlu_s16(tmp, cpu_env,
tmp, tmp2);
break;
case 2:
gen_helper_neon_qshlu_s32(tmp, cpu_env,
tmp, tmp2);
break;
default:
abort();
}
break;
case 7:
GEN_NEON_INTEGER_OP_ENV(qshl);
break;
}
tcg_temp_free_i32(tmp2);
if (op == 1 || op == 3) {
tmp2 = neon_load_reg(rd, pass);
gen_neon_add(size, tmp, tmp2);
tcg_temp_free_i32(tmp2);
} else if (op == 4 || (op == 5 && u)) {
switch (size) {
case 0:
if (op == 4)
mask = 0xff >> -shift;
else
mask = (uint8_t)(0xff << shift);
mask |= mask << 8;
mask |= mask << 16;
break;
case 1:
if (op == 4)
mask = 0xffff >> -shift;
else
mask = (uint16_t)(0xffff << shift);
mask |= mask << 16;
break;
case 2:
if (shift < -31 || shift > 31) {
mask = 0;
} else {
if (op == 4)
mask = 0xffffffffu >> -shift;
else
mask = 0xffffffffu << shift;
}
break;
default:
abort();
}
tmp2 = neon_load_reg(rd, pass);
tcg_gen_andi_i32(tmp, tmp, mask);
tcg_gen_andi_i32(tmp2, tmp2, ~mask);
tcg_gen_or_i32(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
}
neon_store_reg(rd, pass, tmp);
}
}
} else if (op < 10) {
int input_unsigned = (op == 8) ? !u : u;
if (rm & 1) {
return 1;
}
shift = shift - (1 << (size + 3));
size++;
if (size == 3) {
tmp64 = tcg_const_i64(shift);
neon_load_reg64(cpu_V0, rm);
neon_load_reg64(cpu_V1, rm + 1);
for (pass = 0; pass < 2; pass++) {
TCGv_i64 in;
if (pass == 0) {
in = cpu_V0;
} else {
in = cpu_V1;
}
if (q) {
if (input_unsigned) {
gen_helper_neon_rshl_u64(cpu_V0, in, tmp64);
} else {
gen_helper_neon_rshl_s64(cpu_V0, in, tmp64);
}
} else {
if (input_unsigned) {
gen_helper_neon_shl_u64(cpu_V0, in, tmp64);
} else {
gen_helper_neon_shl_s64(cpu_V0, in, tmp64);
}
}
tmp = tcg_temp_new_i32();
gen_neon_narrow_op(op == 8, u, size - 1, tmp, cpu_V0);
neon_store_reg(rd, pass, tmp);
}
tcg_temp_free_i64(tmp64);
} else {
if (size == 1) {
imm = (uint16_t)shift;
imm |= imm << 16;
} else {
imm = (uint32_t)shift;
}
tmp2 = tcg_const_i32(imm);
tmp4 = neon_load_reg(rm + 1, 0);
tmp5 = neon_load_reg(rm + 1, 1);
for (pass = 0; pass < 2; pass++) {
if (pass == 0) {
tmp = neon_load_reg(rm, 0);
} else {
tmp = tmp4;
}
gen_neon_shift_narrow(size, tmp, tmp2, q,
input_unsigned);
if (pass == 0) {
tmp3 = neon_load_reg(rm, 1);
} else {
tmp3 = tmp5;
}
gen_neon_shift_narrow(size, tmp3, tmp2, q,
input_unsigned);
tcg_gen_concat_i32_i64(cpu_V0, tmp, tmp3);
tcg_temp_free_i32(tmp);
tcg_temp_free_i32(tmp3);
tmp = tcg_temp_new_i32();
gen_neon_narrow_op(op == 8, u, size - 1, tmp, cpu_V0);
neon_store_reg(rd, pass, tmp);
}
tcg_temp_free_i32(tmp2);
}
} else if (op == 10) {
if (q || (rd & 1)) {
return 1;
}
tmp = neon_load_reg(rm, 0);
tmp2 = neon_load_reg(rm, 1);
for (pass = 0; pass < 2; pass++) {
if (pass == 1)
tmp = tmp2;
gen_neon_widen(cpu_V0, tmp, size, u);
if (shift != 0) {
tcg_gen_shli_i64(cpu_V0, cpu_V0, shift);
if (size < 2 || !u) {
uint64_t imm64;
if (size == 0) {
imm = (0xffu >> (8 - shift));
imm |= imm << 16;
} else if (size == 1) {
imm = 0xffff >> (16 - shift);
} else {
imm = 0xffffffff >> (32 - shift);
}
if (size < 2) {
imm64 = imm | (((uint64_t)imm) << 32);
} else {
imm64 = imm;
}
tcg_gen_andi_i64(cpu_V0, cpu_V0, ~imm64);
}
}
neon_store_reg64(cpu_V0, rd + pass);
}
} else if (op >= 14) {
if (!(insn & (1 << 21)) || (q && ((rd | rm) & 1))) {
return 1;
}
shift = 32 - shift;
for (pass = 0; pass < (q ? 4 : 2); pass++) {
tcg_gen_ld_f32(cpu_F0s, cpu_env, neon_reg_offset(rm, pass));
if (!(op & 1)) {
if (u)
gen_vfp_ulto(0, shift, 1);
else
gen_vfp_slto(0, shift, 1);
} else {
if (u)
gen_vfp_toul(0, shift, 1);
else
gen_vfp_tosl(0, shift, 1);
}
tcg_gen_st_f32(cpu_F0s, cpu_env, neon_reg_offset(rd, pass));
}
} else {
return 1;
}
} else {
int invert;
if (q && (rd & 1)) {
return 1;
}
op = (insn >> 8) & 0xf;
imm = (u << 7) | ((insn >> 12) & 0x70) | (insn & 0xf);
invert = (insn & (1 << 5)) != 0;
switch (op) {
case 0: case 1:
break;
case 2: case 3:
imm <<= 8;
break;
case 4: case 5:
imm <<= 16;
break;
case 6: case 7:
imm <<= 24;
break;
case 8: case 9:
imm |= imm << 16;
break;
case 10: case 11:
imm = (imm << 8) | (imm << 24);
break;
case 12:
imm = (imm << 8) | 0xff;
break;
case 13:
imm = (imm << 16) | 0xffff;
break;
case 14:
imm |= (imm << 8) | (imm << 16) | (imm << 24);
if (invert)
imm = ~imm;
break;
case 15:
if (invert) {
return 1;
}
imm = ((imm & 0x80) << 24) | ((imm & 0x3f) << 19)
| ((imm & 0x40) ? (0x1f << 25) : (1 << 30));
break;
}
if (invert)
imm = ~imm;
for (pass = 0; pass < (q ? 4 : 2); pass++) {
if (op & 1 && op < 12) {
tmp = neon_load_reg(rd, pass);
if (invert) {
tcg_gen_andi_i32(tmp, tmp, imm);
} else {
tcg_gen_ori_i32(tmp, tmp, imm);
}
} else {
tmp = tcg_temp_new_i32();
if (op == 14 && invert) {
int n;
uint32_t val;
val = 0;
for (n = 0; n < 4; n++) {
if (imm & (1 << (n + (pass & 1) * 4)))
val |= 0xff << (n * 8);
}
tcg_gen_movi_i32(tmp, val);
} else {
tcg_gen_movi_i32(tmp, imm);
}
}
neon_store_reg(rd, pass, tmp);
}
}
} else {
if (size != 3) {
op = (insn >> 8) & 0xf;
if ((insn & (1 << 6)) == 0) {
int src1_wide;
int src2_wide;
int prewiden;
int undefreq;
static const int neon_3reg_wide[16][4] = {
{1, 0, 0, 0},
{1, 1, 0, 0},
{1, 0, 0, 0},
{1, 1, 0, 0},
{0, 1, 1, 0},
{0, 0, 0, 0},
{0, 1, 1, 0},
{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 0, 0, 9},
{0, 0, 0, 0},
{0, 0, 0, 9},
{0, 0, 0, 0},
{0, 0, 0, 1},
{0, 0, 0, 0xa},
{0, 0, 0, 7},
};
prewiden = neon_3reg_wide[op][0];
src1_wide = neon_3reg_wide[op][1];
src2_wide = neon_3reg_wide[op][2];
undefreq = neon_3reg_wide[op][3];
if ((undefreq & (1 << size)) ||
((undefreq & 8) && u)) {
return 1;
}
if ((src1_wide && (rn & 1)) ||
(src2_wide && (rm & 1)) ||
(!src2_wide && (rd & 1))) {
return 1;
}
if (op == 14 && size == 2) {
TCGv_i64 tcg_rn, tcg_rm, tcg_rd;
if (!arm_dc_feature(s, ARM_FEATURE_V8_PMULL)) {
return 1;
}
tcg_rn = tcg_temp_new_i64();
tcg_rm = tcg_temp_new_i64();
tcg_rd = tcg_temp_new_i64();
neon_load_reg64(tcg_rn, rn);
neon_load_reg64(tcg_rm, rm);
gen_helper_neon_pmull_64_lo(tcg_rd, tcg_rn, tcg_rm);
neon_store_reg64(tcg_rd, rd);
gen_helper_neon_pmull_64_hi(tcg_rd, tcg_rn, tcg_rm);
neon_store_reg64(tcg_rd, rd + 1);
tcg_temp_free_i64(tcg_rn);
tcg_temp_free_i64(tcg_rm);
tcg_temp_free_i64(tcg_rd);
return 0;
}
if (rd == rm && !src2_wide) {
tmp = neon_load_reg(rm, 1);
neon_store_scratch(2, tmp);
} else if (rd == rn && !src1_wide) {
tmp = neon_load_reg(rn, 1);
neon_store_scratch(2, tmp);
}
TCGV_UNUSED_I32(tmp3);
for (pass = 0; pass < 2; pass++) {
if (src1_wide) {
neon_load_reg64(cpu_V0, rn + pass);
TCGV_UNUSED_I32(tmp);
} else {
if (pass == 1 && rd == rn) {
tmp = neon_load_scratch(2);
} else {
tmp = neon_load_reg(rn, pass);
}
if (prewiden) {
gen_neon_widen(cpu_V0, tmp, size, u);
}
}
if (src2_wide) {
neon_load_reg64(cpu_V1, rm + pass);
TCGV_UNUSED_I32(tmp2);
} else {
if (pass == 1 && rd == rm) {
tmp2 = neon_load_scratch(2);
} else {
tmp2 = neon_load_reg(rm, pass);
}
if (prewiden) {
gen_neon_widen(cpu_V1, tmp2, size, u);
}
}
switch (op) {
case 0: case 1: case 4:
gen_neon_addl(size);
break;
case 2: case 3: case 6:
gen_neon_subl(size);
break;
case 5: case 7:
switch ((size << 1) | u) {
case 0:
gen_helper_neon_abdl_s16(cpu_V0, tmp, tmp2);
break;
case 1:
gen_helper_neon_abdl_u16(cpu_V0, tmp, tmp2);
break;
case 2:
gen_helper_neon_abdl_s32(cpu_V0, tmp, tmp2);
break;
case 3:
gen_helper_neon_abdl_u32(cpu_V0, tmp, tmp2);
break;
case 4:
gen_helper_neon_abdl_s64(cpu_V0, tmp, tmp2);
break;
case 5:
gen_helper_neon_abdl_u64(cpu_V0, tmp, tmp2);
break;
default: abort();
}
tcg_temp_free_i32(tmp2);
tcg_temp_free_i32(tmp);
break;
case 8: case 9: case 10: case 11: case 12: case 13:
gen_neon_mull(cpu_V0, tmp, tmp2, size, u);
break;
case 14:
gen_helper_neon_mull_p8(cpu_V0, tmp, tmp2);
tcg_temp_free_i32(tmp2);
tcg_temp_free_i32(tmp);
break;
default:
abort();
}
if (op == 13) {
gen_neon_addl_saturate(cpu_V0, cpu_V0, size);
neon_store_reg64(cpu_V0, rd + pass);
} else if (op == 5 || (op >= 8 && op <= 11)) {
neon_load_reg64(cpu_V1, rd + pass);
switch (op) {
case 10:
gen_neon_negl(cpu_V0, size);
case 5: case 8:
gen_neon_addl(size);
break;
case 9: case 11:
gen_neon_addl_saturate(cpu_V0, cpu_V0, size);
if (op == 11) {
gen_neon_negl(cpu_V0, size);
}
gen_neon_addl_saturate(cpu_V0, cpu_V1, size);
break;
default:
abort();
}
neon_store_reg64(cpu_V0, rd + pass);
} else if (op == 4 || op == 6) {
tmp = tcg_temp_new_i32();
if (!u) {
switch (size) {
case 0:
gen_helper_neon_narrow_high_u8(tmp, cpu_V0);
break;
case 1:
gen_helper_neon_narrow_high_u16(tmp, cpu_V0);
break;
case 2:
tcg_gen_shri_i64(cpu_V0, cpu_V0, 32);
tcg_gen_trunc_i64_i32(tmp, cpu_V0);
break;
default: abort();
}
} else {
switch (size) {
case 0:
gen_helper_neon_narrow_round_high_u8(tmp, cpu_V0);
break;
case 1:
gen_helper_neon_narrow_round_high_u16(tmp, cpu_V0);
break;
case 2:
tcg_gen_addi_i64(cpu_V0, cpu_V0, 1u << 31);
tcg_gen_shri_i64(cpu_V0, cpu_V0, 32);
tcg_gen_trunc_i64_i32(tmp, cpu_V0);
break;
default: abort();
}
}
if (pass == 0) {
tmp3 = tmp;
} else {
neon_store_reg(rd, 0, tmp3);
neon_store_reg(rd, 1, tmp);
}
} else {
neon_store_reg64(cpu_V0, rd + pass);
}
}
} else {
if (size == 0) {
return 1;
}
switch (op) {
case 1:
case 5:
case 9:
if (size == 1) {
return 1;
}
case 0:
case 4:
case 8:
case 12:
case 13:
if (u && ((rd | rn) & 1)) {
return 1;
}
tmp = neon_get_scalar(size, rm);
neon_store_scratch(0, tmp);
for (pass = 0; pass < (u ? 4 : 2); pass++) {
tmp = neon_load_scratch(0);
tmp2 = neon_load_reg(rn, pass);
if (op == 12) {
if (size == 1) {
gen_helper_neon_qdmulh_s16(tmp, cpu_env, tmp, tmp2);
} else {
gen_helper_neon_qdmulh_s32(tmp, cpu_env, tmp, tmp2);
}
} else if (op == 13) {
if (size == 1) {
gen_helper_neon_qrdmulh_s16(tmp, cpu_env, tmp, tmp2);
} else {
gen_helper_neon_qrdmulh_s32(tmp, cpu_env, tmp, tmp2);
}
} else if (op & 1) {
TCGv_ptr fpstatus = get_fpstatus_ptr(1);
gen_helper_vfp_muls(tmp, tmp, tmp2, fpstatus);
tcg_temp_free_ptr(fpstatus);
} else {
switch (size) {
case 0: gen_helper_neon_mul_u8(tmp, tmp, tmp2); break;
case 1: gen_helper_neon_mul_u16(tmp, tmp, tmp2); break;
case 2: tcg_gen_mul_i32(tmp, tmp, tmp2); break;
default: abort();
}
}
tcg_temp_free_i32(tmp2);
if (op < 8) {
tmp2 = neon_load_reg(rd, pass);
switch (op) {
case 0:
gen_neon_add(size, tmp, tmp2);
break;
case 1:
{
TCGv_ptr fpstatus = get_fpstatus_ptr(1);
gen_helper_vfp_adds(tmp, tmp, tmp2, fpstatus);
tcg_temp_free_ptr(fpstatus);
break;
}
case 4:
gen_neon_rsb(size, tmp, tmp2);
break;
case 5:
{
TCGv_ptr fpstatus = get_fpstatus_ptr(1);
gen_helper_vfp_subs(tmp, tmp2, tmp, fpstatus);
tcg_temp_free_ptr(fpstatus);
break;
}
default:
abort();
}
tcg_temp_free_i32(tmp2);
}
neon_store_reg(rd, pass, tmp);
}
break;
case 3:
case 7:
case 11:
if (u == 1) {
return 1;
}
case 2:
case 6:
case 10:
if (rd & 1) {
return 1;
}
tmp2 = neon_get_scalar(size, rm);
tmp4 = tcg_temp_new_i32();
tcg_gen_mov_i32(tmp4, tmp2);
tmp3 = neon_load_reg(rn, 1);
for (pass = 0; pass < 2; pass++) {
if (pass == 0) {
tmp = neon_load_reg(rn, 0);
} else {
tmp = tmp3;
tmp2 = tmp4;
}
gen_neon_mull(cpu_V0, tmp, tmp2, size, u);
if (op != 11) {
neon_load_reg64(cpu_V1, rd + pass);
}
switch (op) {
case 6:
gen_neon_negl(cpu_V0, size);
case 2:
gen_neon_addl(size);
break;
case 3: case 7:
gen_neon_addl_saturate(cpu_V0, cpu_V0, size);
if (op == 7) {
gen_neon_negl(cpu_V0, size);
}
gen_neon_addl_saturate(cpu_V0, cpu_V1, size);
break;
case 10:
break;
case 11:
gen_neon_addl_saturate(cpu_V0, cpu_V0, size);
break;
default:
abort();
}
neon_store_reg64(cpu_V0, rd + pass);
}
break;
default:
return 1;
}
}
} else {
if (!u) {
imm = (insn >> 8) & 0xf;
if (imm > 7 && !q)
return 1;
if (q && ((rd | rn | rm) & 1)) {
return 1;
}
if (imm == 0) {
neon_load_reg64(cpu_V0, rn);
if (q) {
neon_load_reg64(cpu_V1, rn + 1);
}
} else if (imm == 8) {
neon_load_reg64(cpu_V0, rn + 1);
if (q) {
neon_load_reg64(cpu_V1, rm);
}
} else if (q) {
tmp64 = tcg_temp_new_i64();
if (imm < 8) {
neon_load_reg64(cpu_V0, rn);
neon_load_reg64(tmp64, rn + 1);
} else {
neon_load_reg64(cpu_V0, rn + 1);
neon_load_reg64(tmp64, rm);
}
tcg_gen_shri_i64(cpu_V0, cpu_V0, (imm & 7) * 8);
tcg_gen_shli_i64(cpu_V1, tmp64, 64 - ((imm & 7) * 8));
tcg_gen_or_i64(cpu_V0, cpu_V0, cpu_V1);
if (imm < 8) {
neon_load_reg64(cpu_V1, rm);
} else {
neon_load_reg64(cpu_V1, rm + 1);
imm -= 8;
}
tcg_gen_shli_i64(cpu_V1, cpu_V1, 64 - (imm * 8));
tcg_gen_shri_i64(tmp64, tmp64, imm * 8);
tcg_gen_or_i64(cpu_V1, cpu_V1, tmp64);
tcg_temp_free_i64(tmp64);
} else {
neon_load_reg64(cpu_V0, rn);
tcg_gen_shri_i64(cpu_V0, cpu_V0, imm * 8);
neon_load_reg64(cpu_V1, rm);
tcg_gen_shli_i64(cpu_V1, cpu_V1, 64 - (imm * 8));
tcg_gen_or_i64(cpu_V0, cpu_V0, cpu_V1);
}
neon_store_reg64(cpu_V0, rd);
if (q) {
neon_store_reg64(cpu_V1, rd + 1);
}
} else if ((insn & (1 << 11)) == 0) {
op = ((insn >> 12) & 0x30) | ((insn >> 7) & 0xf);
size = (insn >> 18) & 3;
if ((neon_2rm_sizes[op] & (1 << size)) == 0) {
return 1;
}
if ((op != NEON_2RM_VMOVN && op != NEON_2RM_VQMOVN) &&
q && ((rm | rd) & 1)) {
return 1;
}
switch (op) {
case NEON_2RM_VREV64:
for (pass = 0; pass < (q ? 2 : 1); pass++) {
tmp = neon_load_reg(rm, pass * 2);
tmp2 = neon_load_reg(rm, pass * 2 + 1);
switch (size) {
case 0: tcg_gen_bswap32_i32(tmp, tmp); break;
case 1: gen_swap_half(tmp); break;
case 2: break;
default: abort();
}
neon_store_reg(rd, pass * 2 + 1, tmp);
if (size == 2) {
neon_store_reg(rd, pass * 2, tmp2);
} else {
switch (size) {
case 0: tcg_gen_bswap32_i32(tmp2, tmp2); break;
case 1: gen_swap_half(tmp2); break;
default: abort();
}
neon_store_reg(rd, pass * 2, tmp2);
}
}
break;
case NEON_2RM_VPADDL: case NEON_2RM_VPADDL_U:
case NEON_2RM_VPADAL: case NEON_2RM_VPADAL_U:
for (pass = 0; pass < q + 1; pass++) {
tmp = neon_load_reg(rm, pass * 2);
gen_neon_widen(cpu_V0, tmp, size, op & 1);
tmp = neon_load_reg(rm, pass * 2 + 1);
gen_neon_widen(cpu_V1, tmp, size, op & 1);
switch (size) {
case 0: gen_helper_neon_paddl_u16(CPU_V001); break;
case 1: gen_helper_neon_paddl_u32(CPU_V001); break;
case 2: tcg_gen_add_i64(CPU_V001); break;
default: abort();
}
if (op >= NEON_2RM_VPADAL) {
neon_load_reg64(cpu_V1, rd + pass);
gen_neon_addl(size);
}
neon_store_reg64(cpu_V0, rd + pass);
}
break;
case NEON_2RM_VTRN:
if (size == 2) {
int n;
for (n = 0; n < (q ? 4 : 2); n += 2) {
tmp = neon_load_reg(rm, n);
tmp2 = neon_load_reg(rd, n + 1);
neon_store_reg(rm, n, tmp2);
neon_store_reg(rd, n + 1, tmp);
}
} else {
goto elementwise;
}
break;
case NEON_2RM_VUZP:
if (gen_neon_unzip(rd, rm, size, q)) {
return 1;
}
break;
case NEON_2RM_VZIP:
if (gen_neon_zip(rd, rm, size, q)) {
return 1;
}
break;
case NEON_2RM_VMOVN: case NEON_2RM_VQMOVN:
if (rm & 1) {
return 1;
}
TCGV_UNUSED_I32(tmp2);
for (pass = 0; pass < 2; pass++) {
neon_load_reg64(cpu_V0, rm + pass);
tmp = tcg_temp_new_i32();
gen_neon_narrow_op(op == NEON_2RM_VMOVN, q, size,
tmp, cpu_V0);
if (pass == 0) {
tmp2 = tmp;
} else {
neon_store_reg(rd, 0, tmp2);
neon_store_reg(rd, 1, tmp);
}
}
break;
case NEON_2RM_VSHLL:
if (q || (rd & 1)) {
return 1;
}
tmp = neon_load_reg(rm, 0);
tmp2 = neon_load_reg(rm, 1);
for (pass = 0; pass < 2; pass++) {
if (pass == 1)
tmp = tmp2;
gen_neon_widen(cpu_V0, tmp, size, 1);
tcg_gen_shli_i64(cpu_V0, cpu_V0, 8 << size);
neon_store_reg64(cpu_V0, rd + pass);
}
break;
case NEON_2RM_VCVT_F16_F32:
if (!arm_dc_feature(s, ARM_FEATURE_VFP_FP16) ||
q || (rm & 1)) {
return 1;
}
tmp = tcg_temp_new_i32();
tmp2 = tcg_temp_new_i32();
tcg_gen_ld_f32(cpu_F0s, cpu_env, neon_reg_offset(rm, 0));
gen_helper_neon_fcvt_f32_to_f16(tmp, cpu_F0s, cpu_env);
tcg_gen_ld_f32(cpu_F0s, cpu_env, neon_reg_offset(rm, 1));
gen_helper_neon_fcvt_f32_to_f16(tmp2, cpu_F0s, cpu_env);
tcg_gen_shli_i32(tmp2, tmp2, 16);
tcg_gen_or_i32(tmp2, tmp2, tmp);
tcg_gen_ld_f32(cpu_F0s, cpu_env, neon_reg_offset(rm, 2));
gen_helper_neon_fcvt_f32_to_f16(tmp, cpu_F0s, cpu_env);
tcg_gen_ld_f32(cpu_F0s, cpu_env, neon_reg_offset(rm, 3));
neon_store_reg(rd, 0, tmp2);
tmp2 = tcg_temp_new_i32();
gen_helper_neon_fcvt_f32_to_f16(tmp2, cpu_F0s, cpu_env);
tcg_gen_shli_i32(tmp2, tmp2, 16);
tcg_gen_or_i32(tmp2, tmp2, tmp);
neon_store_reg(rd, 1, tmp2);
tcg_temp_free_i32(tmp);
break;
case NEON_2RM_VCVT_F32_F16:
if (!arm_dc_feature(s, ARM_FEATURE_VFP_FP16) ||
q || (rd & 1)) {
return 1;
}
tmp3 = tcg_temp_new_i32();
tmp = neon_load_reg(rm, 0);
tmp2 = neon_load_reg(rm, 1);
tcg_gen_ext16u_i32(tmp3, tmp);
gen_helper_neon_fcvt_f16_to_f32(cpu_F0s, tmp3, cpu_env);
tcg_gen_st_f32(cpu_F0s, cpu_env, neon_reg_offset(rd, 0));
tcg_gen_shri_i32(tmp3, tmp, 16);
gen_helper_neon_fcvt_f16_to_f32(cpu_F0s, tmp3, cpu_env);
tcg_gen_st_f32(cpu_F0s, cpu_env, neon_reg_offset(rd, 1));
tcg_temp_free_i32(tmp);
tcg_gen_ext16u_i32(tmp3, tmp2);
gen_helper_neon_fcvt_f16_to_f32(cpu_F0s, tmp3, cpu_env);
tcg_gen_st_f32(cpu_F0s, cpu_env, neon_reg_offset(rd, 2));
tcg_gen_shri_i32(tmp3, tmp2, 16);
gen_helper_neon_fcvt_f16_to_f32(cpu_F0s, tmp3, cpu_env);
tcg_gen_st_f32(cpu_F0s, cpu_env, neon_reg_offset(rd, 3));
tcg_temp_free_i32(tmp2);
tcg_temp_free_i32(tmp3);
break;
case NEON_2RM_AESE: case NEON_2RM_AESMC:
if (!arm_dc_feature(s, ARM_FEATURE_V8_AES)
|| ((rm | rd) & 1)) {
return 1;
}
tmp = tcg_const_i32(rd);
tmp2 = tcg_const_i32(rm);
tmp3 = tcg_const_i32(extract32(insn, 6, 1));
if (op == NEON_2RM_AESE) {
gen_helper_crypto_aese(cpu_env, tmp, tmp2, tmp3);
} else {
gen_helper_crypto_aesmc(cpu_env, tmp, tmp2, tmp3);
}
tcg_temp_free_i32(tmp);
tcg_temp_free_i32(tmp2);
tcg_temp_free_i32(tmp3);
break;
case NEON_2RM_SHA1H:
if (!arm_dc_feature(s, ARM_FEATURE_V8_SHA1)
|| ((rm | rd) & 1)) {
return 1;
}
tmp = tcg_const_i32(rd);
tmp2 = tcg_const_i32(rm);
gen_helper_crypto_sha1h(cpu_env, tmp, tmp2);
tcg_temp_free_i32(tmp);
tcg_temp_free_i32(tmp2);
break;
case NEON_2RM_SHA1SU1:
if ((rm | rd) & 1) {
return 1;
}
if (q) {
if (!arm_dc_feature(s, ARM_FEATURE_V8_SHA256)) {
return 1;
}
} else if (!arm_dc_feature(s, ARM_FEATURE_V8_SHA1)) {
return 1;
}
tmp = tcg_const_i32(rd);
tmp2 = tcg_const_i32(rm);
if (q) {
gen_helper_crypto_sha256su0(cpu_env, tmp, tmp2);
} else {
gen_helper_crypto_sha1su1(cpu_env, tmp, tmp2);
}
tcg_temp_free_i32(tmp);
tcg_temp_free_i32(tmp2);
break;
default:
elementwise:
for (pass = 0; pass < (q ? 4 : 2); pass++) {
if (neon_2rm_is_float_op(op)) {
tcg_gen_ld_f32(cpu_F0s, cpu_env,
neon_reg_offset(rm, pass));
TCGV_UNUSED_I32(tmp);
} else {
tmp = neon_load_reg(rm, pass);
}
switch (op) {
case NEON_2RM_VREV32:
switch (size) {
case 0: tcg_gen_bswap32_i32(tmp, tmp); break;
case 1: gen_swap_half(tmp); break;
default: abort();
}
break;
case NEON_2RM_VREV16:
gen_rev16(tmp);
break;
case NEON_2RM_VCLS:
switch (size) {
case 0: gen_helper_neon_cls_s8(tmp, tmp); break;
case 1: gen_helper_neon_cls_s16(tmp, tmp); break;
case 2: gen_helper_neon_cls_s32(tmp, tmp); break;
default: abort();
}
break;
case NEON_2RM_VCLZ:
switch (size) {
case 0: gen_helper_neon_clz_u8(tmp, tmp); break;
case 1: gen_helper_neon_clz_u16(tmp, tmp); break;
case 2: gen_helper_clz(tmp, tmp); break;
default: abort();
}
break;
case NEON_2RM_VCNT:
gen_helper_neon_cnt_u8(tmp, tmp);
break;
case NEON_2RM_VMVN:
tcg_gen_not_i32(tmp, tmp);
break;
case NEON_2RM_VQABS:
switch (size) {
case 0:
gen_helper_neon_qabs_s8(tmp, cpu_env, tmp);
break;
case 1:
gen_helper_neon_qabs_s16(tmp, cpu_env, tmp);
break;
case 2:
gen_helper_neon_qabs_s32(tmp, cpu_env, tmp);
break;
default: abort();
}
break;
case NEON_2RM_VQNEG:
switch (size) {
case 0:
gen_helper_neon_qneg_s8(tmp, cpu_env, tmp);
break;
case 1:
gen_helper_neon_qneg_s16(tmp, cpu_env, tmp);
break;
case 2:
gen_helper_neon_qneg_s32(tmp, cpu_env, tmp);
break;
default: abort();
}
break;
case NEON_2RM_VCGT0: case NEON_2RM_VCLE0:
tmp2 = tcg_const_i32(0);
switch(size) {
case 0: gen_helper_neon_cgt_s8(tmp, tmp, tmp2); break;
case 1: gen_helper_neon_cgt_s16(tmp, tmp, tmp2); break;
case 2: gen_helper_neon_cgt_s32(tmp, tmp, tmp2); break;
default: abort();
}
tcg_temp_free_i32(tmp2);
if (op == NEON_2RM_VCLE0) {
tcg_gen_not_i32(tmp, tmp);
}
break;
case NEON_2RM_VCGE0: case NEON_2RM_VCLT0:
tmp2 = tcg_const_i32(0);
switch(size) {
case 0: gen_helper_neon_cge_s8(tmp, tmp, tmp2); break;
case 1: gen_helper_neon_cge_s16(tmp, tmp, tmp2); break;
case 2: gen_helper_neon_cge_s32(tmp, tmp, tmp2); break;
default: abort();
}
tcg_temp_free_i32(tmp2);
if (op == NEON_2RM_VCLT0) {
tcg_gen_not_i32(tmp, tmp);
}
break;
case NEON_2RM_VCEQ0:
tmp2 = tcg_const_i32(0);
switch(size) {
case 0: gen_helper_neon_ceq_u8(tmp, tmp, tmp2); break;
case 1: gen_helper_neon_ceq_u16(tmp, tmp, tmp2); break;
case 2: gen_helper_neon_ceq_u32(tmp, tmp, tmp2); break;
default: abort();
}
tcg_temp_free_i32(tmp2);
break;
case NEON_2RM_VABS:
switch(size) {
case 0: gen_helper_neon_abs_s8(tmp, tmp); break;
case 1: gen_helper_neon_abs_s16(tmp, tmp); break;
case 2: tcg_gen_abs_i32(tmp, tmp); break;
default: abort();
}
break;
case NEON_2RM_VNEG:
tmp2 = tcg_const_i32(0);
gen_neon_rsb(size, tmp, tmp2);
tcg_temp_free_i32(tmp2);
break;
case NEON_2RM_VCGT0_F:
{
TCGv_ptr fpstatus = get_fpstatus_ptr(1);
tmp2 = tcg_const_i32(0);
gen_helper_neon_cgt_f32(tmp, tmp, tmp2, fpstatus);
tcg_temp_free_i32(tmp2);
tcg_temp_free_ptr(fpstatus);
break;
}
case NEON_2RM_VCGE0_F:
{
TCGv_ptr fpstatus = get_fpstatus_ptr(1);
tmp2 = tcg_const_i32(0);
gen_helper_neon_cge_f32(tmp, tmp, tmp2, fpstatus);
tcg_temp_free_i32(tmp2);
tcg_temp_free_ptr(fpstatus);
break;
}
case NEON_2RM_VCEQ0_F:
{
TCGv_ptr fpstatus = get_fpstatus_ptr(1);
tmp2 = tcg_const_i32(0);
gen_helper_neon_ceq_f32(tmp, tmp, tmp2, fpstatus);
tcg_temp_free_i32(tmp2);
tcg_temp_free_ptr(fpstatus);
break;
}
case NEON_2RM_VCLE0_F:
{
TCGv_ptr fpstatus = get_fpstatus_ptr(1);
tmp2 = tcg_const_i32(0);
gen_helper_neon_cge_f32(tmp, tmp2, tmp, fpstatus);
tcg_temp_free_i32(tmp2);
tcg_temp_free_ptr(fpstatus);
break;
}
case NEON_2RM_VCLT0_F:
{
TCGv_ptr fpstatus = get_fpstatus_ptr(1);
tmp2 = tcg_const_i32(0);
gen_helper_neon_cgt_f32(tmp, tmp2, tmp, fpstatus);
tcg_temp_free_i32(tmp2);
tcg_temp_free_ptr(fpstatus);
break;
}
case NEON_2RM_VABS_F:
gen_vfp_abs(0);
break;
case NEON_2RM_VNEG_F:
gen_vfp_neg(0);
break;
case NEON_2RM_VSWP:
tmp2 = neon_load_reg(rd, pass);
neon_store_reg(rm, pass, tmp2);
break;
case NEON_2RM_VTRN:
tmp2 = neon_load_reg(rd, pass);
switch (size) {
case 0: gen_neon_trn_u8(tmp, tmp2); break;
case 1: gen_neon_trn_u16(tmp, tmp2); break;
default: abort();
}
neon_store_reg(rm, pass, tmp2);
break;
case NEON_2RM_VRINTN:
case NEON_2RM_VRINTA:
case NEON_2RM_VRINTM:
case NEON_2RM_VRINTP:
case NEON_2RM_VRINTZ:
{
TCGv_i32 tcg_rmode;
TCGv_ptr fpstatus = get_fpstatus_ptr(1);
int rmode;
if (op == NEON_2RM_VRINTZ) {
rmode = FPROUNDING_ZERO;
} else {
rmode = fp_decode_rm[((op & 0x6) >> 1) ^ 1];
}
tcg_rmode = tcg_const_i32(arm_rmode_to_sf(rmode));
gen_helper_set_neon_rmode(tcg_rmode, tcg_rmode,
cpu_env);
gen_helper_rints(cpu_F0s, cpu_F0s, fpstatus);
gen_helper_set_neon_rmode(tcg_rmode, tcg_rmode,
cpu_env);
tcg_temp_free_ptr(fpstatus);
tcg_temp_free_i32(tcg_rmode);
break;
}
case NEON_2RM_VRINTX:
{
TCGv_ptr fpstatus = get_fpstatus_ptr(1);
gen_helper_rints_exact(cpu_F0s, cpu_F0s, fpstatus);
tcg_temp_free_ptr(fpstatus);
break;
}
case NEON_2RM_VCVTAU:
case NEON_2RM_VCVTAS:
case NEON_2RM_VCVTNU:
case NEON_2RM_VCVTNS:
case NEON_2RM_VCVTPU:
case NEON_2RM_VCVTPS:
case NEON_2RM_VCVTMU:
case NEON_2RM_VCVTMS:
{
bool is_signed = !extract32(insn, 7, 1);
TCGv_ptr fpst = get_fpstatus_ptr(1);
TCGv_i32 tcg_rmode, tcg_shift;
int rmode = fp_decode_rm[extract32(insn, 8, 2)];
tcg_shift = tcg_const_i32(0);
tcg_rmode = tcg_const_i32(arm_rmode_to_sf(rmode));
gen_helper_set_neon_rmode(tcg_rmode, tcg_rmode,
cpu_env);
if (is_signed) {
gen_helper_vfp_tosls(cpu_F0s, cpu_F0s,
tcg_shift, fpst);
} else {
gen_helper_vfp_touls(cpu_F0s, cpu_F0s,
tcg_shift, fpst);
}
gen_helper_set_neon_rmode(tcg_rmode, tcg_rmode,
cpu_env);
tcg_temp_free_i32(tcg_rmode);
tcg_temp_free_i32(tcg_shift);
tcg_temp_free_ptr(fpst);
break;
}
case NEON_2RM_VRECPE:
{
TCGv_ptr fpstatus = get_fpstatus_ptr(1);
gen_helper_recpe_u32(tmp, tmp, fpstatus);
tcg_temp_free_ptr(fpstatus);
break;
}
case NEON_2RM_VRSQRTE:
{
TCGv_ptr fpstatus = get_fpstatus_ptr(1);
gen_helper_rsqrte_u32(tmp, tmp, fpstatus);
tcg_temp_free_ptr(fpstatus);
break;
}
case NEON_2RM_VRECPE_F:
{
TCGv_ptr fpstatus = get_fpstatus_ptr(1);
gen_helper_recpe_f32(cpu_F0s, cpu_F0s, fpstatus);
tcg_temp_free_ptr(fpstatus);
break;
}
case NEON_2RM_VRSQRTE_F:
{
TCGv_ptr fpstatus = get_fpstatus_ptr(1);
gen_helper_rsqrte_f32(cpu_F0s, cpu_F0s, fpstatus);
tcg_temp_free_ptr(fpstatus);
break;
}
case NEON_2RM_VCVT_FS:
gen_vfp_sito(0, 1);
break;
case NEON_2RM_VCVT_FU:
gen_vfp_uito(0, 1);
break;
case NEON_2RM_VCVT_SF:
gen_vfp_tosiz(0, 1);
break;
case NEON_2RM_VCVT_UF:
gen_vfp_touiz(0, 1);
break;
default:
abort();
}
if (neon_2rm_is_float_op(op)) {
tcg_gen_st_f32(cpu_F0s, cpu_env,
neon_reg_offset(rd, pass));
} else {
neon_store_reg(rd, pass, tmp);
}
}
break;
}
} else if ((insn & (1 << 10)) == 0) {
int n = ((insn >> 8) & 3) + 1;
if ((rn + n) > 32) {
return 1;
}
n <<= 3;
if (insn & (1 << 6)) {
tmp = neon_load_reg(rd, 0);
} else {
tmp = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp, 0);
}
tmp2 = neon_load_reg(rm, 0);
tmp4 = tcg_const_i32(rn);
tmp5 = tcg_const_i32(n);
gen_helper_neon_tbl(tmp2, cpu_env, tmp2, tmp, tmp4, tmp5);
tcg_temp_free_i32(tmp);
if (insn & (1 << 6)) {
tmp = neon_load_reg(rd, 1);
} else {
tmp = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp, 0);
}
tmp3 = neon_load_reg(rm, 1);
gen_helper_neon_tbl(tmp3, cpu_env, tmp3, tmp, tmp4, tmp5);
tcg_temp_free_i32(tmp5);
tcg_temp_free_i32(tmp4);
neon_store_reg(rd, 0, tmp2);
neon_store_reg(rd, 1, tmp3);
tcg_temp_free_i32(tmp);
} else if ((insn & 0x380) == 0) {
if ((insn & (7 << 16)) == 0 || (q && (rd & 1))) {
return 1;
}
if (insn & (1 << 19)) {
tmp = neon_load_reg(rm, 1);
} else {
tmp = neon_load_reg(rm, 0);
}
if (insn & (1 << 16)) {
gen_neon_dup_u8(tmp, ((insn >> 17) & 3) * 8);
} else if (insn & (1 << 17)) {
if ((insn >> 18) & 1)
gen_neon_dup_high16(tmp);
else
gen_neon_dup_low16(tmp);
}
for (pass = 0; pass < (q ? 4 : 2); pass++) {
tmp2 = tcg_temp_new_i32();
tcg_gen_mov_i32(tmp2, tmp);
neon_store_reg(rd, pass, tmp2);
}
tcg_temp_free_i32(tmp);
} else {
return 1;
}
}
}
return 0;
}
| 1threat
|
why can't I compile the class on the jsp. Error 500 : [unable to compile the class "person"][1]
["person".class ][2]
[the jsp of which line9 causing Error][3]
[1]: https://i.stack.imgur.com/zZkTR.jpg
[2]: https://i.stack.imgur.com/J4yol.jpg
[3]: https://i.stack.imgur.com/SLuUe.jpg
| 0debug
|
static void decode_sigpass(Jpeg2000T1Context *t1, int width, int height,
int bpno, int bandno)
{
int mask = 3 << (bpno - 1), y0, x, y;
for (y0 = 0; y0 < height; y0 += 4)
for (x = 0; x < width; x++)
for (y = y0; y < height && y < y0 + 4; y++)
if ((t1->flags[y + 1][x + 1] & JPEG2000_T1_SIG_NB)
&& !(t1->flags[y + 1][x + 1] & (JPEG2000_T1_SIG | JPEG2000_T1_VIS))) {
if (ff_mqc_decode(&t1->mqc,
t1->mqc.cx_states +
ff_jpeg2000_getsigctxno(t1->flags[y + 1][x + 1],
bandno))) {
int xorbit, ctxno = ff_jpeg2000_getsgnctxno(t1->flags[y + 1][x + 1],
&xorbit);
t1->data[y][x] =
(ff_mqc_decode(&t1->mqc,
t1->mqc.cx_states + ctxno) ^ xorbit)
? -mask : mask;
ff_jpeg2000_set_significance(t1, x, y,
t1->data[y][x] < 0);
}
t1->flags[y + 1][x + 1] |= JPEG2000_T1_VIS;
}
}
| 1threat
|
Gradle: could not set unknown property 'classDumpFile' in Intellij : <p>I have been searching through the Internet and asking on irc chats but none of them were or did not give any answer for trying to solve my problem.</p>
<p>I am trying to make my project to use <code>JaCoCo</code> on <code>Intellij</code> IDE, the tests are going to be done in a <code>Jenkins</code> server, i have set some settings in my gradle.build file for <code>JaCoCo</code> but build compilation fails saying <code>Could not set unknown property 'classDumpFile' for object of type org.gradle.testing.jacoco.plugins.JacocoTaskExtension.</code></p>
<p>The build file is like this:</p>
<pre><code>version '1.0-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'jacoco'
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
}
jacoco{
toolVersion = '0.7.6.201602180812'
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.5'
compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.6'
compile group: 'org.json', name: 'json', version: '20180130'
}
test{
jacoco {
append = false
destinationFile = file("$buildDir/jacoco/jacocoTest.exec")
classDumpFile = file("$buildDir/jacoco/classpathdumps")
}
}
</code></pre>
<p>this is a gradle file generated by <code>IntelliJ</code> when creating the project and i have been adding some dependencies manually, now the developer that is managing the <code>jenkins</code> server told me to use these <code>JaCoCo</code> settings for <code>sonarQube</code> to work well, <code>IntelliJ</code> fails to make any compilation but when submitting the code to <code>Jenkins</code> it works fine.</p>
<p>I have been searching why does this happens and i have found out this might be due to gradle version and should use <code>classDumpDir</code> instead, this makes <code>IntelliJ</code> work but <code>Jenkins</code> server fails to build the project.</p>
<p>I believe this might be due to gradle version or something but i am still learning how to work with <code>Java</code> and <code>IntelliJ</code>, other developers are working with <code>Eclipse</code> and they do not get this error but i don't want to switch to <code>Eclipse</code> cause i am already too comfortable with <code>IntelliJ</code></p>
<p>In case is necessary here are the versions i am using:</p>
<ul>
<li>CLI Gradle version: 2.10</li>
<li>Java version: Ubuntu openjdk 1.8.0_151</li>
<li>IntelliJ version: 2017.3.4 Community Edition</li>
</ul>
| 0debug
|
Uninstalling Expo CLI : <p>I have installed Expo CLI globally and cant start a new react native app without using expo cli and therefore would like to uninstall it from my system. I have spent hours trying to work out how to removeit globally from my system </p>
| 0debug
|
compare size of types at compile time : I'm working on some code that requires 64 bit floating point calculations, but on some of the platforms where it's being deployed there isn't a 64 bit float type.
I have a version of code that uses a software emulated 64bit type, but I want to be able to combine the hard and soft versions as a single include the switches type definition between hardware and software float.
both float and double are available, but on the one platform they are both 4 bytes in size and on the other they are 4 and 8. I know I can't use sizeof in a preprocessor macro so I looked at comparing the max value for both, but in the arduino framework FLT_MAX and DBL_MAX don't seem to be defined?
how can I perform this check at compile time?
| 0debug
|
What's the command for SQL to change the date-format : <p>how can I change the Date format form YYYY-MM-DD to DD-MM-YYYY ? I tried this command: </p>
<pre><code>select CONVERT(varchar(10), @date, 101)
</code></pre>
<p>but it did not work. Can anyone help me?</p>
<p>Thanks!</p>
| 0debug
|
Javascript code is not wokring on mozilla : It is working like a charm on **Chrome** latest version and IE Edge(I have to allow **javascript** on **IE,EDGE** in order to work).
This code just validate an email if it is correct then it submits the form if it is worng prevent's the form action.
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
function validateEmail(email) {
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(email);
}
function validate() {
var email = $("#email").val();
if (validateEmail(email)) {
event.preventDefault();
setTimeout(function(){
$("#cpa-form").submit();
}, 5000);
$("#error").text('Well done');
$("#error").css({
'background-color':'#dff0d8',
'color': '#3c763d',
'border-color': '#d6e9c6',
'position': 'absolute',
'padding': '15px',
'margin-top': '5px',
'margin-bottom': '5px',
'border': '1px solid transparent',
'border-radius': '4px'
});
}
else {
event.preventDefault();
$("#error").text('Something went wrong');
$("#error").css({
'background-color':'#f2dede',
'color': '#a94442',
'border-color': '#ebccd1',
'position': 'absolute',
'padding': '15px',
'margin-top': '5px',
'margin-bottom': '5px',
'border': '1px solid transparent',
'border-radius': '4px'
});
}
return false;
}
<!-- language: lang-html -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.2.3/jquery.min.js"></script>
<form id="cpa-form">
<input type="email" id="email" name="email" value="email">
<br><br>
<button onclick="validate()" >button</button>
</form>
<span id="error"></span>
<!-- end snippet -->
| 0debug
|
static void rtas_ibm_query_interrupt_source_number(PowerPCCPU *cpu,
sPAPREnvironment *spapr,
uint32_t token,
uint32_t nargs,
target_ulong args,
uint32_t nret,
target_ulong rets)
{
uint32_t config_addr = rtas_ld(args, 0);
uint64_t buid = ((uint64_t)rtas_ld(args, 1) << 32) | rtas_ld(args, 2);
unsigned int intr_src_num = -1, ioa_intr_num = rtas_ld(args, 3);
int ndev;
sPAPRPHBState *phb = NULL;
phb = find_phb(spapr, buid);
if (!phb) {
rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
return;
}
ndev = spapr_msicfg_find(phb, config_addr, false);
if (ndev < 0) {
trace_spapr_pci_msi("MSI has not been enabled", -1, config_addr);
rtas_st(rets, 0, RTAS_OUT_HW_ERROR);
return;
}
intr_src_num = phb->msi_table[ndev].irq + ioa_intr_num;
trace_spapr_pci_rtas_ibm_query_interrupt_source_number(ioa_intr_num,
intr_src_num);
rtas_st(rets, 0, RTAS_OUT_SUCCESS);
rtas_st(rets, 1, intr_src_num);
rtas_st(rets, 2, 1);
}
| 1threat
|
Navigator routes Clear the stack of flutter : <p>In my app i have three screens login , verifyotp , generatepass. I know how to move from one page to other page eg: <code>Navigator.pushNamed(context, "/theNameOfThePage");</code>.
I have a flow in which i move from login->verifyotp->generatepass my question is now how can i move from generatepass to login page and clearing all the stack.
I am an android developer so in android we have <code>intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);</code>.
How can i achieve same result in flutter!</p>
| 0debug
|
What's the difference between firebase cloud messaging & firebase notifications? : <p>in the new Firebase 3.0, i am trying to get my head around when to use Firebase Cloud messaging and when to use Firebase Notifications. </p>
| 0debug
|
static int inet_aton(const char *str, struct in_addr *add)
{
return inet_aton(str, add);
}
| 1threat
|
Python dictionary doesn't have all the keys assigned, or items : <p>I created the following dictionary</p>
<pre><code>exDict = {True: 0, False: 1, 1: 'a', 2: 'b'}
</code></pre>
<p>and when I print <code>exDict.keys()</code>, well, it gives me a generator. Ok, so I coerce it to a list, and it gives me </p>
<pre><code>[False, True, 2]
</code></pre>
<p>Why isn't 1 there? When I print <code>exDict.items()</code> it gives me</p>
<pre><code>[(False, 1), (True, 'a'), (2, 'b')]
</code></pre>
<p>Anyone have a guess about what's going on here? I'm stumped.</p>
| 0debug
|
Is the object of Vector class in Java of static size? : <p>I'm looking for the answer to this question.
something I got from google-
Java.util.Vector Class in Java. The Vector class implements a growable array of objects. Vectors basically falls in legacy classes but now it is fully compatible with collections. They are very similar to ArrayList but Vector is synchronised and have some legacy method which collection framework does not contain.</p>
| 0debug
|
Change RDL version for RDLC Reports in Visual Studio 2017 : <p>I have a project in Visual Studio 2017 with .NET Framework 4. For reports I use the RDLC designer, but I have a problem. The designer creates the reports using RDL 2016 and I need you to use the 2010 definition.</p>
<p>Can I configure this?</p>
<p>I need it since the program has to be compatible with Windows XP and there is no ReportViewer Runtime that supports RDL 2016 for Windows XP.</p>
| 0debug
|
window.location.href = 'http://attack.com?user=' + user_input;
| 1threat
|
How can train and predict models with custom data? : <p>I have 2 arrays, one with sizes and one with prices. How can I train or predict or use a cost function (i'm a begginner yeah) so i can predict prices according to a random size?</p>
<p>Maybe i'm confused with the terms but I hope someone can understand. thanks.</p>
| 0debug
|
static void update_md5_sum(FlacEncodeContext *s, const int16_t *samples)
{
#if HAVE_BIGENDIAN
int i;
for (i = 0; i < s->frame.blocksize * s->channels; i++) {
int16_t smp = av_le2ne16(samples[i]);
av_md5_update(s->md5ctx, (uint8_t *)&smp, 2);
}
#else
av_md5_update(s->md5ctx, (const uint8_t *)samples, s->frame.blocksize*s->channels*2);
#endif
}
| 1threat
|
Golang - call func at memory address : I have a map with a struct as key and a func as value, I would like to call the func when i retrive the value for a given key
map[struct]func
map[
{contact %!s(int=1)}:%!s(main.Controller=0x4c7b50)
{services/basket %!s(int=2)}:%!s(main.Controller=0x4c7ad0)
{categories %!s(int=1)}:%!s(main.Controller=0x4c7ae0)
{categories/{category} %!s(int=2)}:%!s(main.Controller=0x4c7af0)
{categories/{category}/{product} %!s(int=3)}:%!s(main.Controller=0x4c7b00)
{basket %!s(int=1)}:%!s(main.Controller=0x4c7b10)
{checkout %!s(int=1)}:%!s(main.Controller=0x4c7b40)
{sitemap %!s(int=1)}:%!s(main.Controller=0x4c7b30)
{services/order %!s(int=2)}:%!s(main.Controller=0x4c7ac0)
{services/image %!s(int=2)}:%!s(main.Controller=0x4c7b20)
{/ %!s(int=1)}:%!s(main.Controller=0x4c7a00)
]
c := RouteMap[struct]
If I fmt.Printf("%s", c) I get the memory address, how do i invoke the func at the address?
I have tried c() but that gives a runtime error:
%s
0x4c7b10%s
<nil>panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x4c76f4]
goroutine 5 [running]:
main.RequestHandler(0x577ce0, 0xc042004018)
C:/Users/mon/Desktop/server.go:91 +0x684
created by main.main
C:/Users/mon/Desktop/server.go:41 +0x2a0
| 0debug
|
static int synth_superframe(AVCodecContext *ctx, AVFrame *frame,
int *got_frame_ptr)
{
WMAVoiceContext *s = ctx->priv_data;
GetBitContext *gb = &s->gb, s_gb;
int n, res, n_samples = 480;
double lsps[MAX_FRAMES][MAX_LSPS];
const double *mean_lsf = s->lsps == 16 ?
wmavoice_mean_lsf16[s->lsp_def_mode] : wmavoice_mean_lsf10[s->lsp_def_mode];
float excitation[MAX_SIGNAL_HISTORY + MAX_SFRAMESIZE + 12];
float synth[MAX_LSPS + MAX_SFRAMESIZE];
float *samples;
memcpy(synth, s->synth_history,
s->lsps * sizeof(*synth));
memcpy(excitation, s->excitation_history,
s->history_nsamples * sizeof(*excitation));
if (s->sframe_cache_size > 0) {
gb = &s_gb;
init_get_bits(gb, s->sframe_cache, s->sframe_cache_size);
s->sframe_cache_size = 0;
}
if ((res = check_bits_for_superframe(gb, s)) == 1) {
*got_frame_ptr = 0;
return 1;
} else if (res < 0)
return res;
if (!get_bits1(gb)) {
avpriv_request_sample(ctx, "WMAPro-in-WMAVoice");
return AVERROR_PATCHWELCOME;
}
if (get_bits1(gb)) {
if ((n_samples = get_bits(gb, 12)) > 480) {
av_log(ctx, AV_LOG_ERROR,
"Superframe encodes >480 samples (%d), not allowed\n",
n_samples);
return AVERROR_INVALIDDATA;
}
}
if (s->has_residual_lsps) {
double prev_lsps[MAX_LSPS], a1[MAX_LSPS * 2], a2[MAX_LSPS * 2];
for (n = 0; n < s->lsps; n++)
prev_lsps[n] = s->prev_lsps[n] - mean_lsf[n];
if (s->lsps == 10) {
dequant_lsp10r(gb, lsps[2], prev_lsps, a1, a2, s->lsp_q_mode);
} else
dequant_lsp16r(gb, lsps[2], prev_lsps, a1, a2, s->lsp_q_mode);
for (n = 0; n < s->lsps; n++) {
lsps[0][n] = mean_lsf[n] + (a1[n] - a2[n * 2]);
lsps[1][n] = mean_lsf[n] + (a1[s->lsps + n] - a2[n * 2 + 1]);
lsps[2][n] += mean_lsf[n];
}
for (n = 0; n < 3; n++)
stabilize_lsps(lsps[n], s->lsps);
}
frame->nb_samples = 480;
if ((res = ff_get_buffer(ctx, frame, 0)) < 0)
return res;
frame->nb_samples = n_samples;
samples = (float *)frame->data[0];
for (n = 0; n < 3; n++) {
if (!s->has_residual_lsps) {
int m;
if (s->lsps == 10) {
dequant_lsp10i(gb, lsps[n]);
} else
dequant_lsp16i(gb, lsps[n]);
for (m = 0; m < s->lsps; m++)
lsps[n][m] += mean_lsf[m];
stabilize_lsps(lsps[n], s->lsps);
}
if ((res = synth_frame(ctx, gb, n,
&samples[n * MAX_FRAMESIZE],
lsps[n], n == 0 ? s->prev_lsps : lsps[n - 1],
&excitation[s->history_nsamples + n * MAX_FRAMESIZE],
&synth[s->lsps + n * MAX_FRAMESIZE]))) {
*got_frame_ptr = 0;
return res;
}
}
if (get_bits1(gb)) {
res = get_bits(gb, 4);
skip_bits(gb, 10 * (res + 1));
}
*got_frame_ptr = 1;
memcpy(s->prev_lsps, lsps[2],
s->lsps * sizeof(*s->prev_lsps));
memcpy(s->synth_history, &synth[MAX_SFRAMESIZE],
s->lsps * sizeof(*synth));
memcpy(s->excitation_history, &excitation[MAX_SFRAMESIZE],
s->history_nsamples * sizeof(*excitation));
if (s->do_apf)
memmove(s->zero_exc_pf, &s->zero_exc_pf[MAX_SFRAMESIZE],
s->history_nsamples * sizeof(*s->zero_exc_pf));
return 0;
}
| 1threat
|
import re
def text_starta_endb(text):
patterns = 'a.*?b$'
if re.search(patterns, text):
return 'Found a match!'
else:
return('Not matched!')
| 0debug
|
int qcrypto_pbkdf2(QCryptoHashAlgorithm hash,
const uint8_t *key, size_t nkey,
const uint8_t *salt, size_t nsalt,
unsigned int iterations,
uint8_t *out, size_t nout,
Error **errp)
{
static const int hash_map[QCRYPTO_HASH_ALG__MAX] = {
[QCRYPTO_HASH_ALG_MD5] = GCRY_MD_MD5,
[QCRYPTO_HASH_ALG_SHA1] = GCRY_MD_SHA1,
[QCRYPTO_HASH_ALG_SHA256] = GCRY_MD_SHA256,
};
int ret;
if (hash >= G_N_ELEMENTS(hash_map) ||
hash_map[hash] == GCRY_MD_NONE) {
error_setg(errp, "Unexpected hash algorithm %d", hash);
return -1;
}
ret = gcry_kdf_derive(key, nkey, GCRY_KDF_PBKDF2,
hash_map[hash],
salt, nsalt, iterations,
nout, out);
if (ret != 0) {
error_setg(errp, "Cannot derive password: %s",
gcry_strerror(ret));
return -1;
}
return 0;
}
| 1threat
|
static void ff_h264_idct8_dc_add_mmx2(uint8_t *dst, int16_t *block, int stride)
{
int dc = (block[0] + 32) >> 6;
int y;
__asm__ volatile(
"movd %0, %%mm0 \n\t"
"pshufw $0, %%mm0, %%mm0 \n\t"
"pxor %%mm1, %%mm1 \n\t"
"psubw %%mm0, %%mm1 \n\t"
"packuswb %%mm0, %%mm0 \n\t"
"packuswb %%mm1, %%mm1 \n\t"
::"r"(dc)
);
for(y=2; y--; dst += 4*stride){
__asm__ volatile(
"movq %0, %%mm2 \n\t"
"movq %1, %%mm3 \n\t"
"movq %2, %%mm4 \n\t"
"movq %3, %%mm5 \n\t"
"paddusb %%mm0, %%mm2 \n\t"
"paddusb %%mm0, %%mm3 \n\t"
"paddusb %%mm0, %%mm4 \n\t"
"paddusb %%mm0, %%mm5 \n\t"
"psubusb %%mm1, %%mm2 \n\t"
"psubusb %%mm1, %%mm3 \n\t"
"psubusb %%mm1, %%mm4 \n\t"
"psubusb %%mm1, %%mm5 \n\t"
"movq %%mm2, %0 \n\t"
"movq %%mm3, %1 \n\t"
"movq %%mm4, %2 \n\t"
"movq %%mm5, %3 \n\t"
:"+m"(*(uint64_t*)(dst+0*stride)),
"+m"(*(uint64_t*)(dst+1*stride)),
"+m"(*(uint64_t*)(dst+2*stride)),
"+m"(*(uint64_t*)(dst+3*stride))
);
}
}
| 1threat
|
How to parse a requested parameter String to a double (or self-made class)? : <p>So as part of an add form to a database I request a parameter form the form by the id (request.getParameter("idOfInput"), this gives me a String but the input is a price. I have to parse this input into a double and pass it on to my setPrice() method. However when I parse it I get a NullPointerException saying there is a Floating Decimal. How do I pass on my paremeter correctly? Also I have class named Category and I want to do the same for that.</p>
<pre><code>private void setPrice(Bike bike, HttpServletRequest request, ArrayList<String> errors){
String priceS = request.getParameter("price");
double price = Double.parseDouble(priceS);
try{
bike.setPrice(price);
} catch (DomainException e){
errors.add(e.getMessage());
}
}
</code></pre>
| 0debug
|
usage of grep -v unix command : i have not used -v option before with grep. The description in help says "Invert the sense of matching, to select non-matching lines." what does the command `grep -v '^$' file.txt` does?
| 0debug
|
static void imx_ccm_write(void *opaque, target_phys_addr_t offset,
uint64_t value, unsigned size)
{
IMXCCMState *s = (IMXCCMState *)opaque;
DPRINTF("write(offset=%x, value = %x)\n",
offset >> 2, (unsigned int)value);
switch (offset >> 2) {
case 0:
s->ccmr = CCMR_FPMF | (value & 0x3b6fdfff);
break;
case 1:
s->pdr0 = value & 0xff9f3fff;
break;
case 2:
s->pdr1 = value;
break;
case 4:
s->mpctl = value & 0xbfff3fff;
break;
case 6:
s->spctl = value & 0xbfff3fff;
break;
case 8:
s->cgr[0] = value;
return;
case 9:
s->cgr[1] = value;
return;
case 10:
s->cgr[2] = value;
return;
default:
return;
}
update_clocks(s);
}
| 1threat
|
Why is the result 2 after decrement and increment operations : <p>There's some code:</p>
<pre><code>int a = 1111;
a = a-- - --a;
a = a++ + ++a;
</code></pre>
<p>I know about prefix and postfix operators. But could you please explain the order of operations perfoming in these expressions?</p>
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.