problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
static void cmd646_data_write(void *opaque, target_phys_addr_t addr,
uint64_t data, unsigned size)
{
CMD646BAR *cmd646bar = opaque;
if (size == 1) {
ide_ioport_write(cmd646bar->bus, addr, data);
} else if (addr == 0) {
if (size == 2) {
ide_data_writew(cmd646bar->bus, addr, data);
} else {
ide_data_writel(cmd646bar->bus, addr, data);
}
}
}
| 1threat
|
static int coroutine_fn iscsi_co_flush(BlockDriverState *bs)
{
IscsiLun *iscsilun = bs->opaque;
struct IscsiTask iTask;
if (bdrv_is_sg(bs)) {
return 0;
}
if (!iscsilun->force_next_flush) {
return 0;
}
iscsilun->force_next_flush = false;
iscsi_co_init_iscsitask(iscsilun, &iTask);
retry:
if (iscsi_synchronizecache10_task(iscsilun->iscsi, iscsilun->lun, 0, 0, 0,
0, iscsi_co_generic_cb, &iTask) == NULL) {
return -ENOMEM;
}
while (!iTask.complete) {
iscsi_set_events(iscsilun);
qemu_coroutine_yield();
}
if (iTask.task != NULL) {
scsi_free_scsi_task(iTask.task);
iTask.task = NULL;
}
if (iTask.do_retry) {
iTask.complete = 0;
goto retry;
}
if (iTask.status != SCSI_STATUS_GOOD) {
return -EIO;
}
return 0;
}
| 1threat
|
why for structure with flexible array member, we shouldn't use structure assignment for copying : <p>I'm currently learning c structure, especially structure with flexible array member. </p>
<p>Given a structure flexible array </p>
<pre><code>struct flex
{
size_t count;
double average;
double scores[]; // flexible array member
};
</code></pre>
<p>I have been told not to use assignment for copying </p>
<p><a href="https://i.stack.imgur.com/bfxVo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bfxVo.png" alt="enter image description here"></a></p>
<p>I'm not sure why this operation only copy the non-flexible member of the structure. </p>
<p>Could someone please explain to me the underlying reasons why this is the case? </p>
| 0debug
|
What are the semantics of ADRP and ADRL instructions in ARM assembly? : <p><a href="http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0802a/ADRP.html" rel="noreferrer">ADRP</a></p>
<blockquote>
<p>Address of 4KB page at a PC-relative offset.</p>
</blockquote>
<p><a href="http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0802b/CIHDDDEI.html" rel="noreferrer">ADRL</a></p>
<blockquote>
<p>Load a PC-relative address into a register. It is similar to the ADR
instruction. ADRL can load a wider range of addresses than ADR because
it generates two data processing instructions.</p>
</blockquote>
<p>Specifically,</p>
<blockquote>
<p>ADRL assembles to two instructions, an ADRP followed by ADD. If the
assembler cannot construct the address in two instructions, it
generates a relocation. The linker then generates the correct offsets.
ADRL produces position-independent code, because the address is
calculated relative to PC.</p>
</blockquote>
<p>What do <code>ADRP</code> and <code>ADRL</code> instructions do? More importantly, how does and <code>ADRP</code> followed by an <code>ADD</code> construct a PC-relative address?</p>
| 0debug
|
static int float64_is_unordered(int sig, float64 a, float64 b STATUS_PARAM)
{
if (float64_is_signaling_nan(a) ||
float64_is_signaling_nan(b) ||
(sig && (float64_is_nan(a) || float64_is_nan(b)))) {
float_raise(float_flag_invalid, status);
return 1;
} else if (float64_is_nan(a) || float64_is_nan(b)) {
return 1;
} else {
return 0;
}
}
| 1threat
|
static void pci_vpb_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
dc->realize = pci_vpb_realize;
dc->reset = pci_vpb_reset;
dc->vmsd = &pci_vpb_vmstate;
dc->props = pci_vpb_properties;
}
| 1threat
|
Trying to connect with a databse but it sais that i do not have the draiver,any tips? thanks in advance : here my code, if you want to see it.
// TODO Auto-generated method stub
Connection connection = null;
try {
// String driverName = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
String driverName = "sun.jdbc.odbc.JdbcOdbcDriver";
String serverName = "serverName";
String databaseName = "databaseName";
String portNumber = "portNumber";
String myDatabase = serverName + ":" + portNumber;
String domainName = "domain name";
String url = "jdbc:jtds:sqlserver://" + myDatabase + ";Database=" + databaseName + ";domain=" + domainName; // a JDBC url
String username = "username";
String password = "password";
// Load the JDBC driver
Class.forName(driverName);
// Create a connection to the database
connection = DriverManager.getConnection(url, username, password);
// Execute a query
Statement stmt = connection.createStatement();
String sql;
sql="SELECT CODFISC, SURNAME FROM tbPersonale order by SURNAME;";
ResultSet rs = stmt.executeQuery(sql);
// Estrazione Dati
while(rs.next() ) {
// Legge i valori
String CODFISC = rs.getString("CODFISC"); //CODFISC is the fiscal code
String SURNAMENAME = rs.getString("SURNAME");
// Visualizza i dati
System.out.print("Codice Fiscale: " + CODFISC );
System.out.println("SURNAME and NAME: " + SURNAMENAME );
}
} catch (ClassNotFoundException e) {
System.out.println("Could not find the database driver");//here is where i always end up :(
} catch (SQLException e) {
System.out.println("Could not connect to the database");
}
| 0debug
|
Disable nginx cache for JavaScript files : <p>Ok, I'm almost giving up on this, but how can I disable the caching from Nginx for JavaScript files? I'm using a docker container with Nginx. When I now change something in the JavaScript file, I need multiple reloads until the new file is there.</p>
<p>How do I know it's Nginx and not the browser/docker?</p>
<p>Browser: I used <code>curl</code> on the command line to simulate the request and had the same issues. Also, I'm using a <code>CacheKiller</code> plugin and have cache disabled in Chrome Dev Tools.</p>
<p>Docker: When I connect to the container's bash, and use <code>cat</code> after changing the file, I get the correct result immediately.</p>
<p>I changed my <code>nginx.conf</code> for the <code>sites-enabled</code> to this (which I found in another stackoverflow thread)</p>
<pre><code>location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf|xml|html|htm)$ {
# clear all access_log directives for the current level
access_log off;
add_header Cache-Control no-cache;
# set the Expires header to 31 December 2037 23:59:59 GMT, and the Cache-Control max-age to 10 years
expires 1s;
}
</code></pre>
<p>However, after rebuilding the containers (and making sure it's in the container with <code>cat</code>), it still didn't work. This here is the complete <code>.conf</code></p>
<pre><code>server {
server_name app;
root /var/www/app/web;
# Redirect to blog
location ~* ^/blog {
proxy_set_header Accept-Encoding "";
sub_filter 'https://testproject.wordpress.com/' '/blog/';
sub_filter_once off;
rewrite ^/blog/(.*) /$1 break;
rewrite ^/blog / break;
proxy_pass https://testproject.wordpress.com;
}
# Serve index.html only for exact root URL
location / {
try_files $uri /app_dev.php$is_args$args;
}
location ~ ^/(app|app_dev|config)\.php(/|$) {
fastcgi_pass php-upstream;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
# Prevents URIs that include the front controller. This will 404:
# http://domain.tld/app_dev.php/some-path
# Remove the internal directive to allow URIs like this
internal;
}
location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf|xml|html|htm)$ {
# clear all access_log directives for the current level
access_log off;
add_header Cache-Control no-cache;
# set the Expires header to 31 December 2037 23:59:59 GMT, and the Cache-Control max-age to 10 years
expires 1s;
}
error_log /var/log/nginx/app_error.log;
access_log /var/log/nginx/app_access.log;
}
</code></pre>
| 0debug
|
Why does my App start incredibly slow (10s+) at first run, showing only white screen on android 5.0? : <p>I have a freshly created app (built in android studio 2.0), having a few activities.</p>
<p>When I test it on my Android 4.3 (note 2) device it starts nicely and fast after a clean install, in turn the same app on my samsung galaxy S4 with android 5.0, hangs for about 10-15 seconds while showing a white screen only.</p>
<p>To be sure I have unplugged it from android studio and commented out almost every method that was in my MainActivity, but it makes no difference, I get the same 10 seconds startup after install or after clearing the app's cache.</p>
<p>I am really concerned about this issue, this could really hurt my app's user experience.</p>
<p>What could be wrong?</p>
<p>Logcat:</p>
<pre><code>05-10 02:07:14.266 26036-26631/com.cerculdivelor I/GMPM: App measurement is starting up
05-10 02:07:14.747 26036-26036/com.cerculdivelor W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
05-10 02:07:14.867 26036-26036/com.cerculdivelor D/Activity: performCreate Call secproduct feature valuefalse
05-10 02:07:14.867 26036-26036/com.cerculdivelor D/Activity: performCreate Call debug elastic valuetrue
05-10 02:07:14.907 26036-26036/com.cerculdivelor I/LOGTAG: Table has been created!
05-10 02:07:14.967 26036-26650/com.cerculdivelor D/OpenGLRenderer: Render dirty regions requested: true
05-10 02:07:15.007 26036-26649/com.cerculdivelor I/Timeline: Timeline: Activity_launch_request id:com.cerculdivelor time:111211793
05-10 02:07:15.127 26036-26645/com.cerculdivelor I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
05-10 02:07:15.127 26036-26645/com.cerculdivelor I/System.out: (HTTPLog)-Static: isShipBuild true
05-10 02:07:15.127 26036-26645/com.cerculdivelor I/System.out: (HTTPLog)-Thread-62285-755755249: SmartBonding Enabling is false, SHIP_BUILD is true, log to file is false, DBG is false
05-10 02:07:15.127 26036-26645/com.cerculdivelor I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
05-10 02:07:15.137 26036-26645/com.cerculdivelor I/System.out: KnoxVpnUidStorageknoxVpnSupported API value returned is false
05-10 02:07:15.147 26036-26650/com.cerculdivelor I/Adreno-EGL: <qeglDrvAPI_eglInitialize:410>: EGL 1.4 QUALCOMM build: ()
OpenGL ES Shader Compiler Version: E031.25.03.06
Build Date: 01/24/15 Sat
Local Branch: AF11_RB1_AU15
Remote Branch:
Local Patches:
Reconstruct Branch:
05-10 02:07:15.147 26036-26650/com.cerculdivelor I/OpenGLRenderer: Initialized EGL, version 1.4
05-10 02:07:15.197 26036-26650/com.cerculdivelor D/OpenGLRenderer: Enabling debug mode 0
05-10 02:07:15.417 26036-26036/com.cerculdivelor I/LOGTAG: Returned0rows
05-10 02:07:15.417 26036-26036/com.cerculdivelor I/LOGTAG: Returned0rows
05-10 02:07:15.988 26036-26051/com.cerculdivelor I/art: Background sticky concurrent mark sweep GC freed 40699(4MB) AllocSpace objects, 12(383KB) LOS objects, 0% free, 49MB/49MB, paused 1.007ms total 161.285ms
05-10 02:07:16.168 26036-26043/com.cerculdivelor W/art: Suspending all threads took: 5.249ms
05-10 02:07:16.228 26036-26036/com.cerculdivelor D/Activity: performCreate Call secproduct feature valuefalse
05-10 02:07:16.228 26036-26036/com.cerculdivelor D/Activity: performCreate Call debug elastic valuetrue
05-10 02:07:16.238 26036-26036/com.cerculdivelor I/Choreographer: Skipped 44 frames! The application may be doing too much work on its main thread.
05-10 02:07:17.349 26036-26036/com.cerculdivelor I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@4e1915e time:111214133
05-10 02:07:17.349 26036-26036/com.cerculdivelor I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@2d342603 time:111214133
05-10 02:07:17.369 26036-26036/com.cerculdivelor V/ActivityThread: updateVisibility : ActivityRecord{10b472f8 token=android.os.BinderProxy@2d342603 {com.cerculdivelor/com.cerculdivelor.MainActivity}} show : false
05-10 02:07:30.622 26036-26036/com.cerculdivelor I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@4e1915e time:111227400
05-10 02:08:36.286 26036-26036/com.cerculdivelor V/ActivityThread: updateVisibility : ActivityRecord{1e1f9137 token=android.os.BinderProxy@4e1915e {com.cerculdivelor/com.cerculdivelor.SplashActivity}} show : true
</code></pre>
<p>Main Activity:</p>
<pre><code>public class MainActivity extends AppCompatActivity implements View.OnClickListener, HttpConActivity.downloadListener {
private static final int PLAY_SERVICES_RESOLUTION_REQUEST = 9000;
private BroadcastReceiver mRegistrationBroadcastReceiver;
private boolean isReceiverRegistered;
CallbackManager callbackManager;
private AccessTokenTracker accessTokenTracker;
private List<ProductsGetterSetter> products;
private SQLiteDataSource datasource;
private TextView toolbarTitle;
private String fbId;
private String name;
private TextView notifBubbleText;
private TextView inboxBubbleText;
private ArrayList<NotificationSetter> notifications;
private SharedPreferences preferences;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.my_toolbar);
toolbarTitle = (TextView) findViewById(R.id.toolbar_title);
setSupportActionBar(toolbar);
/****
TextView title = (TextView) findViewById(R.id.toolbar_title);
Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/Baron.otf");
title.setTypeface(tf);
TextView feedTv = (TextView) findViewById(R.id.feedTv);
feedTv.setOnClickListener(this);
TextView shopTv = (TextView) findViewById(R.id.shopTv);
shopTv.setOnClickListener(this);
TextView sellTv = (TextView) findViewById(R.id.sellTv);
sellTv.setOnClickListener(this);
TextView likesTv = (TextView) findViewById(R.id.likesTv);
likesTv.setOnClickListener(this);
TextView myShopTv = (TextView) findViewById(R.id.myShopTv);
myShopTv.setOnClickListener(this);
// Send crash report if exists
if (!(Thread.getDefaultUncaughtExceptionHandler() instanceof CustomExceptionHandler)) {
Thread.setDefaultUncaughtExceptionHandler(new CustomExceptionHandler(this));
}
****/
}
@Override
protected void onResume() {
super.onResume();
/****
datasource = new SQLiteDataSource(this);
datasource.open();
preferences = getSharedPreferences("user", MODE_PRIVATE);
if (preferences.getString("fbId", "").equals("")) {
promtForLogin();
} else {
initialiseApp();
}
this.invalidateOptionsMenu();
****/
}
</code></pre>
<p>Gradle</p>
<pre><code>apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.cerculdivelor"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile 'com.loopj.android:android-async-http:1.4.9'
compile 'com.android.support:cardview-v7:23.0.+'
compile 'com.android.support:recyclerview-v7:23.0.+'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
compile "com.google.android.gms:play-services-gcm:8.3.0"
}
</code></pre>
| 0debug
|
Show other form when click button Java FX netbeans : i want to solve my homework and i dont know how to start, the goal is make 2 form Gui in JavaFX the 1st is home form contain Button1, when the user click Button1 : show the 2nd Form and close the 1st
how to do that ? hope to give me examples
thanks for reading and helping
| 0debug
|
static int mon_init_func(void *opaque, QemuOpts *opts, Error **errp)
{
CharDriverState *chr;
const char *chardev;
const char *mode;
int flags;
mode = qemu_opt_get(opts, "mode");
if (mode == NULL) {
mode = "readline";
}
if (strcmp(mode, "readline") == 0) {
flags = MONITOR_USE_READLINE;
} else if (strcmp(mode, "control") == 0) {
flags = MONITOR_USE_CONTROL;
} else {
fprintf(stderr, "unknown monitor mode \"%s\"\n", mode);
exit(1);
}
if (qemu_opt_get_bool(opts, "pretty", 0))
flags |= MONITOR_USE_PRETTY;
if (qemu_opt_get_bool(opts, "default", 0))
flags |= MONITOR_IS_DEFAULT;
chardev = qemu_opt_get(opts, "chardev");
chr = qemu_chr_find(chardev);
if (chr == NULL) {
fprintf(stderr, "chardev \"%s\" not found\n", chardev);
exit(1);
}
qemu_chr_fe_claim_no_fail(chr);
monitor_init(chr, flags);
return 0;
}
| 1threat
|
static int ehci_state_fetchsitd(EHCIState *ehci, int async)
{
uint32_t entry;
EHCIsitd sitd;
assert(!async);
entry = ehci_get_fetch_addr(ehci, async);
get_dwords(NLPTR_GET(entry), (uint32_t *)&sitd,
sizeof(EHCIsitd) >> 2);
ehci_trace_sitd(ehci, entry, &sitd);
if (!(sitd.results & SITD_RESULTS_ACTIVE)) {
;
} else {
fprintf(stderr, "WARNING: Skipping active siTD\n");
}
ehci_set_fetch_addr(ehci, async, sitd.next);
ehci_set_state(ehci, async, EST_FETCHENTRY);
return 1;
}
| 1threat
|
makemigrations doesn't detect changes in model : <p>I'm using django 1.9.6. I recently deleted my migrations and ran <code>migrate --run-syncdb</code> and <code>makemigrations my_app</code>. Today I added a new field to one of my models:</p>
<p><em>models.py:</em></p>
<pre><code>value = models.PositiveSmallIntegerField(null=True)
</code></pre>
<p>I tried to migrate the changes, but <code>makemigrations</code> doesn't detect the change. It's just the development version, so I can resync (I don't have to preserve the data), but running <code>--run-syncdb</code> again doesn't detect it either.</p>
<p>Why isn't this migrating?</p>
| 0debug
|
C# How to create own builder with stub.exe : I have windowsform application with one textbox and one button1
and i have another console.application with source code like
console.writeline(textbox1.text);
console.read();
I want to create somethings like when i will click on windowsform application button1
To compile my console application stub.exe
| 0debug
|
void ff_limiter_init_x86(LimiterDSPContext *dsp, int bpp)
{
int cpu_flags = av_get_cpu_flags();
if (ARCH_X86_64 && EXTERNAL_SSE2(cpu_flags)) {
if (bpp <= 8) {
dsp->limiter = ff_limiter_8bit_sse2;
}
}
if (ARCH_X86_64 && EXTERNAL_SSE4(cpu_flags)) {
if (bpp > 8) {
dsp->limiter = ff_limiter_16bit_sse4;
}
}
}
| 1threat
|
How to process html user input Django? : <p>I want to process html form user input using Django. This I can do with Django form method but I want to do this with html form .</p>
<p>In short I want to take user input from html search box and in back-end Django will give related information from LDAP. LDAP part I have done but getting user input and passing values to LDAP search is making problem for me.</p>
<p>Please help.</p>
| 0debug
|
can someone help me converting this sql query into a stored proc..I am new to sql : Select OpportunityId
from opportunity AS c
left JOIN (
select a.opportunitynameid
from opportunity o
JOIN ApprovalDocument a ON a.opportunitynameid=o.OpportunityId
) AS b ON c.OpportunityId=b.opportunitynameid
Where b.opportunitynameid IS NULL and statecode=0
| 0debug
|
Lombok annotation @Getter for boolean field : <p>I am using Java lombok annotation @Getter to generate getters for my POJO. I have a 'boolean' field by the name 'isAbc'. The @Getter annotation in this case generates a method by the name 'isAbc()'. Shouldn't it generate a method by the name 'isIsAbc()'?</p>
| 0debug
|
Uncaught ReferenceError: Vue is not defined when put vue setting in Index.html : <p>i recently learning about <code>vue</code></p>
<p>I have this file <code>main.js</code></p>
<pre><code>import Vue from 'vue/dist/vue.js'
import Buefy from 'buefy'
import 'buefy/lib/buefy.css'
Vue.use(Buefy)
var App = new Vue({
el: '#app',
data: {
message : "It's working"
}
})
</code></pre>
<p>and here is my html</p>
<pre><code><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Vue Example</title>
</head>
<body>
<h3 id="app">{{ message }}</h3>
<script src="dist/build.js"></script>
<script>
</script>
</body>
</html>
</code></pre>
<p>It's working. But, now i'm trying to do something with my script. I change <code>main.js</code> (I'm using <code>webpack</code>)</p>
<pre><code>import Vue from 'vue/dist/vue.js'
import Buefy from 'buefy'
import 'buefy/lib/buefy.css'
Vue.use(Buefy)
</code></pre>
<p>then my index.html to this</p>
<pre><code><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Vue Example</title>
</head>
<body>
<h3 id="app">{{ message }}</h3>
<script src="dist/build.js"></script>
<script>
var App = new Vue({
el: '#app',
data: {
message:"It's not working"
}
})
</script>
</body>
</html>
</code></pre>
<p>and i get this error</p>
<blockquote>
<p>Uncaught ReferenceError: Vue is not defined</p>
</blockquote>
<p>How can i fix this ? </p>
| 0debug
|
How to Fix Segmentation fault (core dumped) Error : <p>I am trying to read some values from a txt file and load it into mem, this is actually a dataset for neural network training, I am getting a segmentation fault when the following function is called, how can i fix this error, my main issue is this error does not show it is thrown, how can i find the line and resolve it.
This function takes a file pointer and allocates mem to a strcut named dataset, which consist of data_members as shown below and split into training and testing data</p>
<pre><code>typedef struct data_member {
double* inputs; /* The input data */
double* targets; /* The target outputs */
} data_member;
typedef struct dataset{
data_member* members; /* The members of the dataset */
int num_members; /* The number of members in the set */
int num_inputs; /* The number of inputs in the set */
int num_outputs; /* The number of outputs in the set */
} dataset;
</code></pre>
<p>the function</p>
<pre><code>
dataset *load_dataset(FILE *datafile, double ratio, dataset *testset)
{
dataset *trainset;
int num_inputs, num_outputs, num_members;
int i, j;
double temp=0.0;
char trainset_check = 0x00;
char testset_check = 0x00;
/* Load first line which contain settings */
fscanf(datafile, "%d, %d, %d\n", &num_members, &num_inputs, &num_outputs);
/* Set ratio of split*/
int trainset_size = (int) num_members * (1- ratio);
int testset_size = (int) num_members * (ratio);
printf("size of train:%d, test: %d\n", trainset_size, testset_size);
/* Setup the dataset */
/* Allocate memory for the trainset */
if ((trainset = (dataset *)malloc(sizeof(dataset))) == NULL)
{
perror("Couldn't allocate the trainset\n");
return (NULL);
}
/* Allocate memory for the testset */
if ((testset = (dataset *)malloc(sizeof(dataset))) == NULL)
{
perror("Couldn't allocate the testset\n");
return (NULL);
}
/* Set the variables trainset*/
trainset->num_members = trainset_size;
trainset->num_inputs = num_inputs;
trainset->num_outputs = num_outputs;
/* Set the variables testset*/
testset->num_members = testset_size;
testset->num_inputs = num_inputs;
testset->num_outputs = num_outputs;
/* Allocate memory for the arrays in the trainset */
if ((trainset->members = (data_member *)malloc(trainset_size * sizeof(data_member))) != NULL)
trainset_check |= 0x01;
/* Allocate memory for the arrays in the testset */
if ((trainset->members = (data_member *)malloc(testset_size * sizeof(data_member))) != NULL)
testset_check |= 0x01;
if (trainset_check < 1)
{
printf("1.Couldn't allocate trainset\n");
if (trainset_check & 0x01)
free(trainset->members);
free(trainset);
return (NULL);
}
if (testset_check < 1)
{
printf("1.Couldn't allocate testset\n");
if (testset_check & 0x01)
free(testset->members);
free(testset);
return (NULL);
}
/* Get the data for trainset */
/* For each Member */
for (i = 0; i < trainset_size; i++)
{
printf("itr:%d\n", i);
/* Allocate the memory for the member */
trainset_check = 0x00;
if (((trainset->members + i)->inputs = (double *)malloc(num_inputs * sizeof(double))) != NULL)
trainset_check |= 0x01;
if (((trainset->members + i)->targets = (double *)malloc(num_outputs * sizeof(double))) != NULL)
trainset_check |= 0x03;
if (trainset_check < 3)
{
printf("2.Couldn't allocate trainset\n");
/* Deallocate the previous loops */
for (j = 0; j < i; j++)
{
free((trainset->members + j)->inputs);
free((trainset->members + j)->targets);
}
if (trainset_check & 0x01)
free((trainset->members + i)->inputs);
if (trainset_check & 0x02)
free((trainset->members + i)->targets);
free(trainset->members);
free(trainset);
return (NULL);
}
/* Read the inputs */
for (j = 0; j < num_inputs; j++)
{
fscanf(datafile, "%lf, ", &temp);
printf("%lf, ", temp);
(trainset->members + i)->inputs[j] = temp;
}
/* Read the outputs */
for (j = 0; j < num_outputs - 1; j++)
{
fscanf(datafile, "%lf, ", &temp);
printf("%lf, ", temp);
(trainset->members + i)->targets[j] = temp;
}
fscanf(datafile, "%lf\n", &temp);
printf("%lf\n", temp);
printf("****************\n");
(trainset->members + i)->targets[j] = temp;
printf("########################%d\n",i);
}
printf("done loading trainset");
/* Get the data for testset */
/* For each Member */
for (i = 0; i < testset_size -1; i++)
{
/* Allocate the memory for the member */
testset_check = 0x00;
if (((testset->members + i)->inputs = (double *)malloc(num_inputs * sizeof(double))) != NULL)
testset_check |= 0x01;
if (((testset->members + i)->targets = (double *)malloc(num_outputs * sizeof(double))) != NULL)
testset_check |= 0x03;
if (testset_check < 3)
{
printf("2.Couldn't allocate testset\n");
/* Deallocate the previous loops */
for (j = 0; j < i; j++)
{
free((testset->members + j)->inputs);
free((testset->members + j)->targets);
}
if (testset_check & 0x01)
free((testset->members + i)->inputs);
if (testset_check & 0x02)
free((testset->members + i)->targets);
free(testset->members);
free(testset);
return (NULL);
}
/* Read the inputs */
for (j = 0; j < num_inputs; j++)
{
fscanf(datafile, "%lf, ", &temp);
printf("%lf, ", temp);
(testset->members + i)->inputs[j] = temp;
}
/* Read the outputs */
for (j = 0; j < num_outputs - 1; j++)
{
fscanf(datafile, "%lf, ", &temp);
printf("%lf, ", temp);
(testset->members + i)->targets[j] = temp;
}
fscanf(datafile, "%lf\n", &temp);
printf("%lf\n", temp);
(testset->members + i)->targets[j] = temp;
}
/* Make sure the file is closed */
fclose(datafile);
/* Finally, return the pointer to the dataset */
return (trainset);
}
</code></pre>
| 0debug
|
How to set background color IONIC 4 : <p>I having problems trying to change the background color in just one IONIC 4 (--type=angular) page. I am trying to add a class for the ion-content. In my html file I Have:</p>
<pre><code><ion-content class="fondologin">
...
</ion-content>
</code></pre>
<p>In my sass I have:</p>
<pre><code>.fondologin{
background-color: #111D12!important;
}
</code></pre>
<p>The background color is never changed. If I add --ion-background-color:#111D12; in variables.scss the background is successfully changed for every page but I just one to change the color in one page. How can I achieve this?</p>
| 0debug
|
How do I move some dependecies from require to require-dev with composer? : <p>Some dependencies were mistakenly added to <code>require</code> instead of <code>require-dev</code>. I tried manually changing <code>composer.json</code> and running <code>composer install</code>, but <code>composer.lock</code> wasn't changed. So my guess is, that it ignored changes in <code>composer.json</code>, and just ensured that what's installed reflects what's in <code>composer.lock</code> file. Am I wrong here? If not wrong, how do I do that? I'd like to preserve versions of packages in <code>composer.lock</code> file as they are now as much as possible.</p>
| 0debug
|
save image in public folder instead storage laravel 5 : <p>i wanna save my avatar at "Public" folder and ther retrieve.</p>
<p>ok. i can save it but in "storage/app" folder instead "public"</p>
<p>my friend told me go to "config/filesystem.php" and edit it ,so i did it like this</p>
<pre><code> 'disks' => [
'public' => [
'driver' => 'local',
'root' => storage_path('image'),
'url' => env('APP_URL').'/public',
'visibility' => 'public',
],
</code></pre>
<p>still no change.</p>
<p>here my simple codes</p>
<p>Route :</p>
<pre><code>Route::get('pic',function (){
return view('pic.pic');
});
Route::post('saved','test2Controller@save');
</code></pre>
<p>Controller</p>
<pre><code>public function save(Request $request)
{
$file = $request->file('image');
//save format
$format = $request->image->extension();
//save full adress of image
$patch = $request->image->store('images');
$name = $file->getClientOriginalName();
//save on table
DB::table('pictbl')->insert([
'orginal_name'=>$name,
'format'=>$base,
'patch'=>$patch
]);
return response()
->view('pic.pic',compact("patch"));
}
</code></pre>
<p>View:</p>
<pre><code>{!! Form::open(['url'=>'saved','method'=>'post','files'=>true]) !!}
{!! Form::file('image') !!}
{!! Form::submit('save') !!}
{!! Form::close() !!}
<img src="storage/app/{{$patch}}">
</code></pre>
<p>How Can save my image (and file in future) at public folder instead storage?</p>
| 0debug
|
void start_ahci_device(AHCIQState *ahci)
{
ahci->hba_base = qpci_iomap(ahci->dev, 5, &ahci->barsize);
g_assert(ahci->hba_base);
qpci_device_enable(ahci->dev);
}
| 1threat
|
Is IntelliJ Python 3 inspection "Expected a dictionary, got a dict" a false positive for super with **kwargs? : <p>I use Python 3 and want to wrap <code>argparse.ArgumentParser</code> with a custom class that sets
<code>formatter_class=argparse.RawDescriptionHelpFormatter</code> by default. I can do this successfully, however IntelliJ IDEA 2017.1 with Python Plugin (PyCharm) gives a warning for the following code:</p>
<pre class="lang-py prettyprint-override"><code>class CustomParser(argparse.ArgumentParser):
def __init__(self, formatter_class=argparse.RawDescriptionHelpFormatter, **kwargs):
# noinspection PyArgumentList
super().__init__(formatter_class=formatter_class, **kwargs) # warning in this line for the last argument if suppression comment above removed
</code></pre>
<p>If one removes the comment with the IntelliJ suppression command the warning on kwargs is "Expected a dictionary, got a dict", however it is working. Is this a false positive warning or can this be done better without the warning? Is there a real issue behind this warning that it helps avoiding?</p>
<p>Side question: Is there a difference in using<br>
<code>formatter_class = kwargs.pop('formatter_class', argparse.RawDescriptionHelpFormatter)</code> instead of explicitly defining the named parameter in the signature? According to <a href="https://www.python.org/dev/peps/pep-0020/" rel="noreferrer">PEP20</a> more explicit in the signature is better, right?</p>
| 0debug
|
static int protocol_version(VncState *vs, char *version, size_t len)
{
char local[13];
int maj, min;
memcpy(local, version, 12);
local[12] = 0;
if (sscanf(local, "RFB %03d.%03d\n", &maj, &min) != 2) {
vnc_client_error(vs);
return 0;
}
vnc_write_u32(vs, 1);
vnc_flush(vs);
vnc_read_when(vs, protocol_client_init, 1);
return 0;
}
| 1threat
|
Organize local code in packages using Go modules : <p>I can not find a way to factor out some code from <code>main.go</code> into a local package when using Go modules (go version >= 1.11) outside of <code>$GOPATH</code>.</p>
<p>I am not importing any external dependencies that need to be included into <code>go.mod</code>, I am just trying to organize locally the source code of this Go module.</p>
<p>The file <code>main.go</code>:</p>
<pre class="lang-golang prettyprint-override"><code>package main
// this import does not work
import "./stuff"
func main() {
stuff.PrintBaz()
}
</code></pre>
<p>The file <code>./stuff/bar.go</code> (pretending to be a local package):</p>
<pre class="lang-golang prettyprint-override"><code>package stuff
import "log"
type Bar struct {
Baz int
}
func PrintBaz() {
baz := Bar{42}
log.Printf("Bar struct: %v", baz)
}
</code></pre>
<p>The file <code>go.mod</code> (command <code>go mod init foo</code>):</p>
<pre><code>module foo
go 1.12
</code></pre>
<p>When executing <code>go run main.go</code>:</p>
<ul>
<li>If I <code>import "./stuff"</code>, then I see <code>build command-line-arguments: cannot find module for path _/home/<PATH_TO>/fooprj/stuff</code>.</li>
<li>If I <code>import "stuff"</code>, then I see <code>build command-line-arguments: cannot load stuff: cannot find module providing package stuff</code>.</li>
<li>If I <code>import stuff "./stuff"</code> with a package alias, then I see again: <code>build command-line-arguments: cannot find module for path _/home/<PATH_TO>/fooprj/stuff</code>.</li>
</ul>
<p>I can not find a way to make local packages work with go modules.</p>
<ul>
<li>What's wrong with the code above?</li>
<li>How can I import local packages into other Go code inside a project defined with Go modules (file <code>go.mod</code>)?</li>
</ul>
| 0debug
|
static void decode_opc_special3(CPUMIPSState *env, DisasContext *ctx)
{
int rs, rt, rd, sa;
uint32_t op1, op2;
rs = (ctx->opcode >> 21) & 0x1f;
rt = (ctx->opcode >> 16) & 0x1f;
rd = (ctx->opcode >> 11) & 0x1f;
sa = (ctx->opcode >> 6) & 0x1f;
op1 = MASK_SPECIAL3(ctx->opcode);
case OPC_EXT:
case OPC_INS:
check_insn(ctx, ISA_MIPS32R2);
gen_bitops(ctx, op1, rt, rs, sa, rd);
break;
case OPC_BSHFL:
op2 = MASK_BSHFL(ctx->opcode);
switch (op2) {
case OPC_ALIGN ... OPC_ALIGN_END:
case OPC_BITSWAP:
check_insn(ctx, ISA_MIPS32R6);
decode_opc_special3_r6(env, ctx);
break;
default:
check_insn(ctx, ISA_MIPS32R2);
gen_bshfl(ctx, op2, rt, rd);
break;
break;
#if defined(TARGET_MIPS64)
case OPC_DEXTM ... OPC_DEXT:
case OPC_DINSM ... OPC_DINS:
check_insn(ctx, ISA_MIPS64R2);
check_mips_64(ctx);
gen_bitops(ctx, op1, rt, rs, sa, rd);
break;
case OPC_DBSHFL:
op2 = MASK_DBSHFL(ctx->opcode);
switch (op2) {
case OPC_DALIGN ... OPC_DALIGN_END:
case OPC_DBITSWAP:
check_insn(ctx, ISA_MIPS32R6);
decode_opc_special3_r6(env, ctx);
break;
default:
check_insn(ctx, ISA_MIPS64R2);
check_mips_64(ctx);
op2 = MASK_DBSHFL(ctx->opcode);
gen_bshfl(ctx, op2, rt, rd);
break;
break;
#endif
case OPC_RDHWR:
gen_rdhwr(ctx, rt, rd, extract32(ctx->opcode, 6, 3));
break;
case OPC_FORK:
check_insn(ctx, ASE_MT);
{
TCGv t0 = tcg_temp_new();
TCGv t1 = tcg_temp_new();
gen_load_gpr(t0, rt);
gen_load_gpr(t1, rs);
gen_helper_fork(t0, t1);
tcg_temp_free(t0);
tcg_temp_free(t1);
break;
case OPC_YIELD:
check_insn(ctx, ASE_MT);
{
TCGv t0 = tcg_temp_new();
gen_load_gpr(t0, rs);
gen_helper_yield(t0, cpu_env, t0);
gen_store_gpr(t0, rd);
tcg_temp_free(t0);
break;
default:
if (ctx->insn_flags & ISA_MIPS32R6) {
decode_opc_special3_r6(env, ctx);
} else {
decode_opc_special3_legacy(env, ctx);
| 1threat
|
when i type letter like m i get number like 0 value in laptop how to fix : <p>My dads laptop has a problem. The keys on the keyboard that have a second symol on the key example the letter m has a 0. The letter L has a 3 and so on.
It seems that some how it is set as default to write the secondary symbol. Any body know how to set as it was before.</p>
| 0debug
|
What is the best way to represent a large field of objects while using minimal resources? : <p>all I am looking to develop a project in unity, it is for android! I was wondering if I could get some clarity on a few things. My problem involves me trying to creating a universe of stars, 150,000 individual stars to be exact, granted there would only be a certain percentage in view at any one time. What is the most efficient structure for being able to convince the user of a realistic environment while keeping the overhead to a minimum since it will be on a phone? </p>
<p>What type of objects do I want to use to represent the masses of stars vs. the likes of stars in close proximity that require finer details?</p>
<p>What sort of threading structures should I consider while planning this project?</p>
<p>How easily does a project port from unity to android, in such scenarios?</p>
<p>Any help is much appreciated as I am looking to better develop with unity, cheers</p>
| 0debug
|
Why output is 0.0 when we assign double or float with some value (< 1) without suffix 'd' or 'f'? : <p>When I assign some value (< 1) to float or double without any suffix 'f' or 'd' respectively, then why the output shows 0.0? My program is</p>
<pre>
public class Example {
double a = 1/2d;
float b = 1/2f;
double c = 1/2;
float d = 1/2;
public static void main(String[] args) {
Example e = new Example();
System.out.println("a: "+e.a);
System.out.println("b: "+e.b);
System.out.println("c: "+e.c);
System.out.println("d: "+e.d);
}
}
</pre>
<p>The output is </p>
<pre>
a: 0.5
b: 0.5
c: 0.0
d: 0.0
</pre>
| 0debug
|
javascript create an array : <p>I want to create a javascript array of all these following divs so I can write a for loop function over them. How should I create this array? Thanks</p>
<pre><code><div class="Org-popover-body-1">
1
</div>
<div class="Org-popover-body-2">
2
</div>
<div class="Org-popover-body-3">
3
</div>
<div class="Org-popover-body-4">
4
</div>
<div class="Org-popover-body-5">
5
</div>
<div class="Org-popover-body-6">
6
</div>
</code></pre>
| 0debug
|
Auto Syncing JSON data in Android for a Blog : <p>i have been working on getting Json data from a blog, parsing it (using the google volley library and Glide for loading the Images) and displaying it in a Linear Recycler View + Card Views, i then stored the post in an SQlite database.</p>
<p>The blog is updated at irregular intervals.
I am confused, as to how to auto sync the json data and show notifications (for new posts) even when the app is not opened. How do i go about this?</p>
<p>I Have heard of Job Scheduler and Sync Adapters.</p>
<ul>
<li><p>is Job Scheduler appropriate? (if yes please point me to a tutorial)</p></li>
<li><p>Sync adapter seem kinda complicated but it appropriate? (if yes please point me to a tutorial).</p></li>
</ul>
<p>if neither is appropriate i would appreciate if you can explain how i can successfully achieve my aim.</p>
<p>I am confused, Please Help!!
Thanks</p>
| 0debug
|
static int disas_iwmmxt_insn(CPUState *env, DisasContext *s, uint32_t insn)
{
int rd, wrd;
int rdhi, rdlo, rd0, rd1, i;
TCGv addr;
TCGv tmp, tmp2, tmp3;
if ((insn & 0x0e000e00) == 0x0c000000) {
if ((insn & 0x0fe00ff0) == 0x0c400000) {
wrd = insn & 0xf;
rdlo = (insn >> 12) & 0xf;
rdhi = (insn >> 16) & 0xf;
if (insn & ARM_CP_RW_BIT) {
iwmmxt_load_reg(cpu_V0, wrd);
tcg_gen_trunc_i64_i32(cpu_R[rdlo], cpu_V0);
tcg_gen_shri_i64(cpu_V0, cpu_V0, 32);
tcg_gen_trunc_i64_i32(cpu_R[rdhi], cpu_V0);
} else {
tcg_gen_concat_i32_i64(cpu_V0, cpu_R[rdlo], cpu_R[rdhi]);
iwmmxt_store_reg(cpu_V0, wrd);
gen_op_iwmmxt_set_mup();
}
return 0;
}
wrd = (insn >> 12) & 0xf;
addr = new_tmp();
if (gen_iwmmxt_address(s, insn, addr)) {
return 1;
}
if (insn & ARM_CP_RW_BIT) {
if ((insn >> 28) == 0xf) {
tmp = new_tmp();
tcg_gen_qemu_ld32u(tmp, addr, IS_USER(s));
iwmmxt_store_creg(wrd, tmp);
} else {
i = 1;
if (insn & (1 << 8)) {
if (insn & (1 << 22)) {
tcg_gen_qemu_ld64(cpu_M0, addr, IS_USER(s));
i = 0;
} else {
tmp = gen_ld32(addr, IS_USER(s));
}
} else {
if (insn & (1 << 22)) {
tmp = gen_ld16u(addr, IS_USER(s));
} else {
tmp = gen_ld8u(addr, IS_USER(s));
}
}
if (i) {
tcg_gen_extu_i32_i64(cpu_M0, tmp);
dead_tmp(tmp);
}
gen_op_iwmmxt_movq_wRn_M0(wrd);
}
} else {
if ((insn >> 28) == 0xf) {
tmp = iwmmxt_load_creg(wrd);
gen_st32(tmp, addr, IS_USER(s));
} else {
gen_op_iwmmxt_movq_M0_wRn(wrd);
tmp = new_tmp();
if (insn & (1 << 8)) {
if (insn & (1 << 22)) {
dead_tmp(tmp);
tcg_gen_qemu_st64(cpu_M0, addr, IS_USER(s));
} else {
tcg_gen_trunc_i64_i32(tmp, cpu_M0);
gen_st32(tmp, addr, IS_USER(s));
}
} else {
if (insn & (1 << 22)) {
tcg_gen_trunc_i64_i32(tmp, cpu_M0);
gen_st16(tmp, addr, IS_USER(s));
} else {
tcg_gen_trunc_i64_i32(tmp, cpu_M0);
gen_st8(tmp, addr, IS_USER(s));
}
}
}
}
return 0;
}
if ((insn & 0x0f000000) != 0x0e000000)
return 1;
switch (((insn >> 12) & 0xf00) | ((insn >> 4) & 0xff)) {
case 0x000:
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 0) & 0xf;
rd1 = (insn >> 16) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
gen_op_iwmmxt_orq_M0_wRn(rd1);
gen_op_iwmmxt_setpsr_nz();
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
gen_op_iwmmxt_set_cup();
break;
case 0x011:
if (insn & 0xf)
return 1;
rd = (insn >> 12) & 0xf;
wrd = (insn >> 16) & 0xf;
switch (wrd) {
case ARM_IWMMXT_wCID:
case ARM_IWMMXT_wCASF:
break;
case ARM_IWMMXT_wCon:
gen_op_iwmmxt_set_cup();
case ARM_IWMMXT_wCSSF:
tmp = iwmmxt_load_creg(wrd);
tmp2 = load_reg(s, rd);
tcg_gen_andc_i32(tmp, tmp, tmp2);
dead_tmp(tmp2);
iwmmxt_store_creg(wrd, tmp);
break;
case ARM_IWMMXT_wCGR0:
case ARM_IWMMXT_wCGR1:
case ARM_IWMMXT_wCGR2:
case ARM_IWMMXT_wCGR3:
gen_op_iwmmxt_set_cup();
tmp = load_reg(s, rd);
iwmmxt_store_creg(wrd, tmp);
break;
default:
return 1;
}
break;
case 0x100:
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 0) & 0xf;
rd1 = (insn >> 16) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
gen_op_iwmmxt_xorq_M0_wRn(rd1);
gen_op_iwmmxt_setpsr_nz();
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
gen_op_iwmmxt_set_cup();
break;
case 0x111:
if (insn & 0xf)
return 1;
rd = (insn >> 12) & 0xf;
wrd = (insn >> 16) & 0xf;
tmp = iwmmxt_load_creg(wrd);
store_reg(s, rd, tmp);
break;
case 0x300:
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 0) & 0xf;
rd1 = (insn >> 16) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
tcg_gen_neg_i64(cpu_M0, cpu_M0);
gen_op_iwmmxt_andq_M0_wRn(rd1);
gen_op_iwmmxt_setpsr_nz();
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
gen_op_iwmmxt_set_cup();
break;
case 0x200:
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 0) & 0xf;
rd1 = (insn >> 16) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
gen_op_iwmmxt_andq_M0_wRn(rd1);
gen_op_iwmmxt_setpsr_nz();
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
gen_op_iwmmxt_set_cup();
break;
case 0x810: case 0xa10:
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 0) & 0xf;
rd1 = (insn >> 16) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
if (insn & (1 << 21))
gen_op_iwmmxt_maddsq_M0_wRn(rd1);
else
gen_op_iwmmxt_madduq_M0_wRn(rd1);
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
break;
case 0x10e: case 0x50e: case 0x90e: case 0xd0e:
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 16) & 0xf;
rd1 = (insn >> 0) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
switch ((insn >> 22) & 3) {
case 0:
gen_op_iwmmxt_unpacklb_M0_wRn(rd1);
break;
case 1:
gen_op_iwmmxt_unpacklw_M0_wRn(rd1);
break;
case 2:
gen_op_iwmmxt_unpackll_M0_wRn(rd1);
break;
case 3:
return 1;
}
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
gen_op_iwmmxt_set_cup();
break;
case 0x10c: case 0x50c: case 0x90c: case 0xd0c:
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 16) & 0xf;
rd1 = (insn >> 0) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
switch ((insn >> 22) & 3) {
case 0:
gen_op_iwmmxt_unpackhb_M0_wRn(rd1);
break;
case 1:
gen_op_iwmmxt_unpackhw_M0_wRn(rd1);
break;
case 2:
gen_op_iwmmxt_unpackhl_M0_wRn(rd1);
break;
case 3:
return 1;
}
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
gen_op_iwmmxt_set_cup();
break;
case 0x012: case 0x112: case 0x412: case 0x512:
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 16) & 0xf;
rd1 = (insn >> 0) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
if (insn & (1 << 22))
gen_op_iwmmxt_sadw_M0_wRn(rd1);
else
gen_op_iwmmxt_sadb_M0_wRn(rd1);
if (!(insn & (1 << 20)))
gen_op_iwmmxt_addl_M0_wRn(wrd);
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
break;
case 0x010: case 0x110: case 0x210: case 0x310:
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 16) & 0xf;
rd1 = (insn >> 0) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
if (insn & (1 << 21)) {
if (insn & (1 << 20))
gen_op_iwmmxt_mulshw_M0_wRn(rd1);
else
gen_op_iwmmxt_mulslw_M0_wRn(rd1);
} else {
if (insn & (1 << 20))
gen_op_iwmmxt_muluhw_M0_wRn(rd1);
else
gen_op_iwmmxt_mululw_M0_wRn(rd1);
}
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
break;
case 0x410: case 0x510: case 0x610: case 0x710:
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 16) & 0xf;
rd1 = (insn >> 0) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
if (insn & (1 << 21))
gen_op_iwmmxt_macsw_M0_wRn(rd1);
else
gen_op_iwmmxt_macuw_M0_wRn(rd1);
if (!(insn & (1 << 20))) {
iwmmxt_load_reg(cpu_V1, wrd);
tcg_gen_add_i64(cpu_M0, cpu_M0, cpu_V1);
}
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
break;
case 0x006: case 0x406: case 0x806: case 0xc06:
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 16) & 0xf;
rd1 = (insn >> 0) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
switch ((insn >> 22) & 3) {
case 0:
gen_op_iwmmxt_cmpeqb_M0_wRn(rd1);
break;
case 1:
gen_op_iwmmxt_cmpeqw_M0_wRn(rd1);
break;
case 2:
gen_op_iwmmxt_cmpeql_M0_wRn(rd1);
break;
case 3:
return 1;
}
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
gen_op_iwmmxt_set_cup();
break;
case 0x800: case 0x900: case 0xc00: case 0xd00:
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 16) & 0xf;
rd1 = (insn >> 0) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
if (insn & (1 << 22)) {
if (insn & (1 << 20))
gen_op_iwmmxt_avgw1_M0_wRn(rd1);
else
gen_op_iwmmxt_avgw0_M0_wRn(rd1);
} else {
if (insn & (1 << 20))
gen_op_iwmmxt_avgb1_M0_wRn(rd1);
else
gen_op_iwmmxt_avgb0_M0_wRn(rd1);
}
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
gen_op_iwmmxt_set_cup();
break;
case 0x802: case 0x902: case 0xa02: case 0xb02:
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 16) & 0xf;
rd1 = (insn >> 0) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
tmp = iwmmxt_load_creg(ARM_IWMMXT_wCGR0 + ((insn >> 20) & 3));
tcg_gen_andi_i32(tmp, tmp, 7);
iwmmxt_load_reg(cpu_V1, rd1);
gen_helper_iwmmxt_align(cpu_M0, cpu_M0, cpu_V1, tmp);
dead_tmp(tmp);
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
break;
case 0x601: case 0x605: case 0x609: case 0x60d:
if (((insn >> 6) & 3) == 3)
return 1;
rd = (insn >> 12) & 0xf;
wrd = (insn >> 16) & 0xf;
tmp = load_reg(s, rd);
gen_op_iwmmxt_movq_M0_wRn(wrd);
switch ((insn >> 6) & 3) {
case 0:
tmp2 = tcg_const_i32(0xff);
tmp3 = tcg_const_i32((insn & 7) << 3);
break;
case 1:
tmp2 = tcg_const_i32(0xffff);
tmp3 = tcg_const_i32((insn & 3) << 4);
break;
case 2:
tmp2 = tcg_const_i32(0xffffffff);
tmp3 = tcg_const_i32((insn & 1) << 5);
break;
default:
TCGV_UNUSED(tmp2);
TCGV_UNUSED(tmp3);
}
gen_helper_iwmmxt_insr(cpu_M0, cpu_M0, tmp, tmp2, tmp3);
tcg_temp_free(tmp3);
tcg_temp_free(tmp2);
dead_tmp(tmp);
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
break;
case 0x107: case 0x507: case 0x907: case 0xd07:
rd = (insn >> 12) & 0xf;
wrd = (insn >> 16) & 0xf;
if (rd == 15 || ((insn >> 22) & 3) == 3)
return 1;
gen_op_iwmmxt_movq_M0_wRn(wrd);
tmp = new_tmp();
switch ((insn >> 22) & 3) {
case 0:
tcg_gen_shri_i64(cpu_M0, cpu_M0, (insn & 7) << 3);
tcg_gen_trunc_i64_i32(tmp, cpu_M0);
if (insn & 8) {
tcg_gen_ext8s_i32(tmp, tmp);
} else {
tcg_gen_andi_i32(tmp, tmp, 0xff);
}
break;
case 1:
tcg_gen_shri_i64(cpu_M0, cpu_M0, (insn & 3) << 4);
tcg_gen_trunc_i64_i32(tmp, cpu_M0);
if (insn & 8) {
tcg_gen_ext16s_i32(tmp, tmp);
} else {
tcg_gen_andi_i32(tmp, tmp, 0xffff);
}
break;
case 2:
tcg_gen_shri_i64(cpu_M0, cpu_M0, (insn & 1) << 5);
tcg_gen_trunc_i64_i32(tmp, cpu_M0);
break;
}
store_reg(s, rd, tmp);
break;
case 0x117: case 0x517: case 0x917: case 0xd17:
if ((insn & 0x000ff008) != 0x0003f000 || ((insn >> 22) & 3) == 3)
return 1;
tmp = iwmmxt_load_creg(ARM_IWMMXT_wCASF);
switch ((insn >> 22) & 3) {
case 0:
tcg_gen_shri_i32(tmp, tmp, ((insn & 7) << 2) + 0);
break;
case 1:
tcg_gen_shri_i32(tmp, tmp, ((insn & 3) << 3) + 4);
break;
case 2:
tcg_gen_shri_i32(tmp, tmp, ((insn & 1) << 4) + 12);
break;
}
tcg_gen_shli_i32(tmp, tmp, 28);
gen_set_nzcv(tmp);
dead_tmp(tmp);
break;
case 0x401: case 0x405: case 0x409: case 0x40d:
if (((insn >> 6) & 3) == 3)
return 1;
rd = (insn >> 12) & 0xf;
wrd = (insn >> 16) & 0xf;
tmp = load_reg(s, rd);
switch ((insn >> 6) & 3) {
case 0:
gen_helper_iwmmxt_bcstb(cpu_M0, tmp);
break;
case 1:
gen_helper_iwmmxt_bcstw(cpu_M0, tmp);
break;
case 2:
gen_helper_iwmmxt_bcstl(cpu_M0, tmp);
break;
}
dead_tmp(tmp);
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
break;
case 0x113: case 0x513: case 0x913: case 0xd13:
if ((insn & 0x000ff00f) != 0x0003f000 || ((insn >> 22) & 3) == 3)
return 1;
tmp = iwmmxt_load_creg(ARM_IWMMXT_wCASF);
tmp2 = new_tmp();
tcg_gen_mov_i32(tmp2, tmp);
switch ((insn >> 22) & 3) {
case 0:
for (i = 0; i < 7; i ++) {
tcg_gen_shli_i32(tmp2, tmp2, 4);
tcg_gen_and_i32(tmp, tmp, tmp2);
}
break;
case 1:
for (i = 0; i < 3; i ++) {
tcg_gen_shli_i32(tmp2, tmp2, 8);
tcg_gen_and_i32(tmp, tmp, tmp2);
}
break;
case 2:
tcg_gen_shli_i32(tmp2, tmp2, 16);
tcg_gen_and_i32(tmp, tmp, tmp2);
break;
}
gen_set_nzcv(tmp);
dead_tmp(tmp2);
dead_tmp(tmp);
break;
case 0x01c: case 0x41c: case 0x81c: case 0xc1c:
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 16) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
switch ((insn >> 22) & 3) {
case 0:
gen_helper_iwmmxt_addcb(cpu_M0, cpu_M0);
break;
case 1:
gen_helper_iwmmxt_addcw(cpu_M0, cpu_M0);
break;
case 2:
gen_helper_iwmmxt_addcl(cpu_M0, cpu_M0);
break;
case 3:
return 1;
}
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
break;
case 0x115: case 0x515: case 0x915: case 0xd15:
if ((insn & 0x000ff00f) != 0x0003f000 || ((insn >> 22) & 3) == 3)
return 1;
tmp = iwmmxt_load_creg(ARM_IWMMXT_wCASF);
tmp2 = new_tmp();
tcg_gen_mov_i32(tmp2, tmp);
switch ((insn >> 22) & 3) {
case 0:
for (i = 0; i < 7; i ++) {
tcg_gen_shli_i32(tmp2, tmp2, 4);
tcg_gen_or_i32(tmp, tmp, tmp2);
}
break;
case 1:
for (i = 0; i < 3; i ++) {
tcg_gen_shli_i32(tmp2, tmp2, 8);
tcg_gen_or_i32(tmp, tmp, tmp2);
}
break;
case 2:
tcg_gen_shli_i32(tmp2, tmp2, 16);
tcg_gen_or_i32(tmp, tmp, tmp2);
break;
}
gen_set_nzcv(tmp);
dead_tmp(tmp2);
dead_tmp(tmp);
break;
case 0x103: case 0x503: case 0x903: case 0xd03:
rd = (insn >> 12) & 0xf;
rd0 = (insn >> 16) & 0xf;
if ((insn & 0xf) != 0 || ((insn >> 22) & 3) == 3)
return 1;
gen_op_iwmmxt_movq_M0_wRn(rd0);
tmp = new_tmp();
switch ((insn >> 22) & 3) {
case 0:
gen_helper_iwmmxt_msbb(tmp, cpu_M0);
break;
case 1:
gen_helper_iwmmxt_msbw(tmp, cpu_M0);
break;
case 2:
gen_helper_iwmmxt_msbl(tmp, cpu_M0);
break;
}
store_reg(s, rd, tmp);
break;
case 0x106: case 0x306: case 0x506: case 0x706:
case 0x906: case 0xb06: case 0xd06: case 0xf06:
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 16) & 0xf;
rd1 = (insn >> 0) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
switch ((insn >> 22) & 3) {
case 0:
if (insn & (1 << 21))
gen_op_iwmmxt_cmpgtsb_M0_wRn(rd1);
else
gen_op_iwmmxt_cmpgtub_M0_wRn(rd1);
break;
case 1:
if (insn & (1 << 21))
gen_op_iwmmxt_cmpgtsw_M0_wRn(rd1);
else
gen_op_iwmmxt_cmpgtuw_M0_wRn(rd1);
break;
case 2:
if (insn & (1 << 21))
gen_op_iwmmxt_cmpgtsl_M0_wRn(rd1);
else
gen_op_iwmmxt_cmpgtul_M0_wRn(rd1);
break;
case 3:
return 1;
}
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
gen_op_iwmmxt_set_cup();
break;
case 0x00e: case 0x20e: case 0x40e: case 0x60e:
case 0x80e: case 0xa0e: case 0xc0e: case 0xe0e:
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 16) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
switch ((insn >> 22) & 3) {
case 0:
if (insn & (1 << 21))
gen_op_iwmmxt_unpacklsb_M0();
else
gen_op_iwmmxt_unpacklub_M0();
break;
case 1:
if (insn & (1 << 21))
gen_op_iwmmxt_unpacklsw_M0();
else
gen_op_iwmmxt_unpackluw_M0();
break;
case 2:
if (insn & (1 << 21))
gen_op_iwmmxt_unpacklsl_M0();
else
gen_op_iwmmxt_unpacklul_M0();
break;
case 3:
return 1;
}
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
gen_op_iwmmxt_set_cup();
break;
case 0x00c: case 0x20c: case 0x40c: case 0x60c:
case 0x80c: case 0xa0c: case 0xc0c: case 0xe0c:
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 16) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
switch ((insn >> 22) & 3) {
case 0:
if (insn & (1 << 21))
gen_op_iwmmxt_unpackhsb_M0();
else
gen_op_iwmmxt_unpackhub_M0();
break;
case 1:
if (insn & (1 << 21))
gen_op_iwmmxt_unpackhsw_M0();
else
gen_op_iwmmxt_unpackhuw_M0();
break;
case 2:
if (insn & (1 << 21))
gen_op_iwmmxt_unpackhsl_M0();
else
gen_op_iwmmxt_unpackhul_M0();
break;
case 3:
return 1;
}
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
gen_op_iwmmxt_set_cup();
break;
case 0x204: case 0x604: case 0xa04: case 0xe04:
case 0x214: case 0x614: case 0xa14: case 0xe14:
if (((insn >> 22) & 3) == 0)
return 1;
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 16) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
tmp = new_tmp();
if (gen_iwmmxt_shift(insn, 0xff, tmp)) {
dead_tmp(tmp);
return 1;
}
switch ((insn >> 22) & 3) {
case 1:
gen_helper_iwmmxt_srlw(cpu_M0, cpu_env, cpu_M0, tmp);
break;
case 2:
gen_helper_iwmmxt_srll(cpu_M0, cpu_env, cpu_M0, tmp);
break;
case 3:
gen_helper_iwmmxt_srlq(cpu_M0, cpu_env, cpu_M0, tmp);
break;
}
dead_tmp(tmp);
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
gen_op_iwmmxt_set_cup();
break;
case 0x004: case 0x404: case 0x804: case 0xc04:
case 0x014: case 0x414: case 0x814: case 0xc14:
if (((insn >> 22) & 3) == 0)
return 1;
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 16) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
tmp = new_tmp();
if (gen_iwmmxt_shift(insn, 0xff, tmp)) {
dead_tmp(tmp);
return 1;
}
switch ((insn >> 22) & 3) {
case 1:
gen_helper_iwmmxt_sraw(cpu_M0, cpu_env, cpu_M0, tmp);
break;
case 2:
gen_helper_iwmmxt_sral(cpu_M0, cpu_env, cpu_M0, tmp);
break;
case 3:
gen_helper_iwmmxt_sraq(cpu_M0, cpu_env, cpu_M0, tmp);
break;
}
dead_tmp(tmp);
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
gen_op_iwmmxt_set_cup();
break;
case 0x104: case 0x504: case 0x904: case 0xd04:
case 0x114: case 0x514: case 0x914: case 0xd14:
if (((insn >> 22) & 3) == 0)
return 1;
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 16) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
tmp = new_tmp();
if (gen_iwmmxt_shift(insn, 0xff, tmp)) {
dead_tmp(tmp);
return 1;
}
switch ((insn >> 22) & 3) {
case 1:
gen_helper_iwmmxt_sllw(cpu_M0, cpu_env, cpu_M0, tmp);
break;
case 2:
gen_helper_iwmmxt_slll(cpu_M0, cpu_env, cpu_M0, tmp);
break;
case 3:
gen_helper_iwmmxt_sllq(cpu_M0, cpu_env, cpu_M0, tmp);
break;
}
dead_tmp(tmp);
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
gen_op_iwmmxt_set_cup();
break;
case 0x304: case 0x704: case 0xb04: case 0xf04:
case 0x314: case 0x714: case 0xb14: case 0xf14:
if (((insn >> 22) & 3) == 0)
return 1;
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 16) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
tmp = new_tmp();
switch ((insn >> 22) & 3) {
case 1:
if (gen_iwmmxt_shift(insn, 0xf, tmp)) {
dead_tmp(tmp);
return 1;
}
gen_helper_iwmmxt_rorw(cpu_M0, cpu_env, cpu_M0, tmp);
break;
case 2:
if (gen_iwmmxt_shift(insn, 0x1f, tmp)) {
dead_tmp(tmp);
return 1;
}
gen_helper_iwmmxt_rorl(cpu_M0, cpu_env, cpu_M0, tmp);
break;
case 3:
if (gen_iwmmxt_shift(insn, 0x3f, tmp)) {
dead_tmp(tmp);
return 1;
}
gen_helper_iwmmxt_rorq(cpu_M0, cpu_env, cpu_M0, tmp);
break;
}
dead_tmp(tmp);
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
gen_op_iwmmxt_set_cup();
break;
case 0x116: case 0x316: case 0x516: case 0x716:
case 0x916: case 0xb16: case 0xd16: case 0xf16:
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 16) & 0xf;
rd1 = (insn >> 0) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
switch ((insn >> 22) & 3) {
case 0:
if (insn & (1 << 21))
gen_op_iwmmxt_minsb_M0_wRn(rd1);
else
gen_op_iwmmxt_minub_M0_wRn(rd1);
break;
case 1:
if (insn & (1 << 21))
gen_op_iwmmxt_minsw_M0_wRn(rd1);
else
gen_op_iwmmxt_minuw_M0_wRn(rd1);
break;
case 2:
if (insn & (1 << 21))
gen_op_iwmmxt_minsl_M0_wRn(rd1);
else
gen_op_iwmmxt_minul_M0_wRn(rd1);
break;
case 3:
return 1;
}
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
break;
case 0x016: case 0x216: case 0x416: case 0x616:
case 0x816: case 0xa16: case 0xc16: case 0xe16:
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 16) & 0xf;
rd1 = (insn >> 0) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
switch ((insn >> 22) & 3) {
case 0:
if (insn & (1 << 21))
gen_op_iwmmxt_maxsb_M0_wRn(rd1);
else
gen_op_iwmmxt_maxub_M0_wRn(rd1);
break;
case 1:
if (insn & (1 << 21))
gen_op_iwmmxt_maxsw_M0_wRn(rd1);
else
gen_op_iwmmxt_maxuw_M0_wRn(rd1);
break;
case 2:
if (insn & (1 << 21))
gen_op_iwmmxt_maxsl_M0_wRn(rd1);
else
gen_op_iwmmxt_maxul_M0_wRn(rd1);
break;
case 3:
return 1;
}
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
break;
case 0x002: case 0x102: case 0x202: case 0x302:
case 0x402: case 0x502: case 0x602: case 0x702:
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 16) & 0xf;
rd1 = (insn >> 0) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
tmp = tcg_const_i32((insn >> 20) & 3);
iwmmxt_load_reg(cpu_V1, rd1);
gen_helper_iwmmxt_align(cpu_M0, cpu_M0, cpu_V1, tmp);
tcg_temp_free(tmp);
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
break;
case 0x01a: case 0x11a: case 0x21a: case 0x31a:
case 0x41a: case 0x51a: case 0x61a: case 0x71a:
case 0x81a: case 0x91a: case 0xa1a: case 0xb1a:
case 0xc1a: case 0xd1a: case 0xe1a: case 0xf1a:
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 16) & 0xf;
rd1 = (insn >> 0) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
switch ((insn >> 20) & 0xf) {
case 0x0:
gen_op_iwmmxt_subnb_M0_wRn(rd1);
break;
case 0x1:
gen_op_iwmmxt_subub_M0_wRn(rd1);
break;
case 0x3:
gen_op_iwmmxt_subsb_M0_wRn(rd1);
break;
case 0x4:
gen_op_iwmmxt_subnw_M0_wRn(rd1);
break;
case 0x5:
gen_op_iwmmxt_subuw_M0_wRn(rd1);
break;
case 0x7:
gen_op_iwmmxt_subsw_M0_wRn(rd1);
break;
case 0x8:
gen_op_iwmmxt_subnl_M0_wRn(rd1);
break;
case 0x9:
gen_op_iwmmxt_subul_M0_wRn(rd1);
break;
case 0xb:
gen_op_iwmmxt_subsl_M0_wRn(rd1);
break;
default:
return 1;
}
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
gen_op_iwmmxt_set_cup();
break;
case 0x01e: case 0x11e: case 0x21e: case 0x31e:
case 0x41e: case 0x51e: case 0x61e: case 0x71e:
case 0x81e: case 0x91e: case 0xa1e: case 0xb1e:
case 0xc1e: case 0xd1e: case 0xe1e: case 0xf1e:
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 16) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
tmp = tcg_const_i32(((insn >> 16) & 0xf0) | (insn & 0x0f));
gen_helper_iwmmxt_shufh(cpu_M0, cpu_env, cpu_M0, tmp);
tcg_temp_free(tmp);
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
gen_op_iwmmxt_set_cup();
break;
case 0x018: case 0x118: case 0x218: case 0x318:
case 0x418: case 0x518: case 0x618: case 0x718:
case 0x818: case 0x918: case 0xa18: case 0xb18:
case 0xc18: case 0xd18: case 0xe18: case 0xf18:
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 16) & 0xf;
rd1 = (insn >> 0) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
switch ((insn >> 20) & 0xf) {
case 0x0:
gen_op_iwmmxt_addnb_M0_wRn(rd1);
break;
case 0x1:
gen_op_iwmmxt_addub_M0_wRn(rd1);
break;
case 0x3:
gen_op_iwmmxt_addsb_M0_wRn(rd1);
break;
case 0x4:
gen_op_iwmmxt_addnw_M0_wRn(rd1);
break;
case 0x5:
gen_op_iwmmxt_adduw_M0_wRn(rd1);
break;
case 0x7:
gen_op_iwmmxt_addsw_M0_wRn(rd1);
break;
case 0x8:
gen_op_iwmmxt_addnl_M0_wRn(rd1);
break;
case 0x9:
gen_op_iwmmxt_addul_M0_wRn(rd1);
break;
case 0xb:
gen_op_iwmmxt_addsl_M0_wRn(rd1);
break;
default:
return 1;
}
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
gen_op_iwmmxt_set_cup();
break;
case 0x008: case 0x108: case 0x208: case 0x308:
case 0x408: case 0x508: case 0x608: case 0x708:
case 0x808: case 0x908: case 0xa08: case 0xb08:
case 0xc08: case 0xd08: case 0xe08: case 0xf08:
if (!(insn & (1 << 20)) || ((insn >> 22) & 3) == 0)
return 1;
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 16) & 0xf;
rd1 = (insn >> 0) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
switch ((insn >> 22) & 3) {
case 1:
if (insn & (1 << 21))
gen_op_iwmmxt_packsw_M0_wRn(rd1);
else
gen_op_iwmmxt_packuw_M0_wRn(rd1);
break;
case 2:
if (insn & (1 << 21))
gen_op_iwmmxt_packsl_M0_wRn(rd1);
else
gen_op_iwmmxt_packul_M0_wRn(rd1);
break;
case 3:
if (insn & (1 << 21))
gen_op_iwmmxt_packsq_M0_wRn(rd1);
else
gen_op_iwmmxt_packuq_M0_wRn(rd1);
break;
}
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
gen_op_iwmmxt_set_cup();
break;
case 0x201: case 0x203: case 0x205: case 0x207:
case 0x209: case 0x20b: case 0x20d: case 0x20f:
case 0x211: case 0x213: case 0x215: case 0x217:
case 0x219: case 0x21b: case 0x21d: case 0x21f:
wrd = (insn >> 5) & 0xf;
rd0 = (insn >> 12) & 0xf;
rd1 = (insn >> 0) & 0xf;
if (rd0 == 0xf || rd1 == 0xf)
return 1;
gen_op_iwmmxt_movq_M0_wRn(wrd);
tmp = load_reg(s, rd0);
tmp2 = load_reg(s, rd1);
switch ((insn >> 16) & 0xf) {
case 0x0:
gen_helper_iwmmxt_muladdsl(cpu_M0, cpu_M0, tmp, tmp2);
break;
case 0x8:
gen_helper_iwmmxt_muladdsw(cpu_M0, cpu_M0, tmp, tmp2);
break;
case 0xc: case 0xd: case 0xe: case 0xf:
if (insn & (1 << 16))
tcg_gen_shri_i32(tmp, tmp, 16);
if (insn & (1 << 17))
tcg_gen_shri_i32(tmp2, tmp2, 16);
gen_helper_iwmmxt_muladdswl(cpu_M0, cpu_M0, tmp, tmp2);
break;
default:
dead_tmp(tmp2);
dead_tmp(tmp);
return 1;
}
dead_tmp(tmp2);
dead_tmp(tmp);
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
break;
default:
return 1;
}
return 0;
}
| 1threat
|
Class Diagrams in VS 2017 : <p>I have been using VS 2015 and like the Class Diagram item. I recently upgraded to 2017 and can't seem to find the Class Diagram item. Anyone know how I get to it?</p>
| 0debug
|
Controling user input as per expected in Python 3 : If you ask someone a yes/no question then the answer is one of these two options.
In programming what if the response was "Y" or "y" or "yes" or whatever?
I had to create a compound condition repeating my statement while its actually the same one.
I'm not an expert but i can see that it can be improved.
below is s snippet from my code:
--------------------------------
def note_maker(note):
case_note = open("case_note.txt", "a+")
update = case_note.write("\n" + note)
multiple_inputs = input("Do you want to enter more details? Y/N")
while multiple_inputs == "yes" or multiple_inputs == "YES" or multiple_inputs == "Yes" or multiple_inputs == "Y" or multiple_inputs == "y":
update_again = case_note.write("\n" + input("Enter your additional information"))
multiple_inputs = input("Do you want to enter more details?")
case_note.close()
Is there a way to control the user input into what I expect ?
thanks alot,
| 0debug
|
How to remove distinct rows using sql query? : I have a table which is as follows:
cust_name cust_address sex orderactive
xxxx yyy m 1
iiii iii f 1
xxxx yyy m 1
I want to keep the duplicate entries and remove unique one's and my resultant table (after removing the duplicates) should look like -
cust_name cust_address sex orderactive
xxxx yyy m 1
xxxx yyy m 1
Any clues or help would be appreciated.
| 0debug
|
Compatibility between Instant and ZonedDateTime : <p>It is my understanding that a <code>ZonedDateTime</code> is really an enhanced version of an <code>Instant</code>. It has all the data an <code>Instant</code> has (precise value along UTC timeline), plus time zone information. So my naïve assumption was that a <code>ZonedDateTime</code> <em>is-an</em> <code>Instant</code> and that any method taking an <code>Instant</code> will happily take a <code>ZonedDateTime</code> instead. Furthermore, I expected <code>isBefore()</code>, <code>isAfter()</code> etc. to work seamlessly between <code>Instant</code>s and <code>ZonedDateTime</code>s.</p>
<p>Looking at the API documentation for <a href="http://docs.oracle.com/javase/8/docs/api/index.html?java/time/Instant.html" rel="noreferrer"><code>Instant</code></a> and <a href="http://docs.oracle.com/javase/8/docs/api/index.html?java/time/ZonedDateTime.html" rel="noreferrer"><code>ZonedDateTime</code></a>, none of this is the case. I can compare <code>Instant</code>s with <code>Instant</code>s and <code>ZonedDateTime</code>s with <code>ZonedDateTime</code>s, but the two classes seem to be incompatible. What's more, third-party code like ThreeTen-Extra's <a href="http://www.threeten.org/threeten-extra/apidocs/index.html?org/threeten/extra/Interval.html" rel="noreferrer"><code>Interval</code></a> seem to work exclusively with <code>Instant</code>s.</p>
<p>Is there a reason why <code>Instant</code> and <code>ZonedDateTime</code> are not meant to be mixed?</p>
| 0debug
|
Limited number of tires to a simple game? : How would I limit the tries of a simple game to just three? I would think you would use a boolean. But not sure.
import java.util.Scanner;
public class guess {
public static void main(String[] args) {
int randomN = (int) (Math.random() * 10) + 1;
Scanner input = new Scanner(System.in);
int guess;
System.out.println("Enter a number between 1 and 10.");
System.out.println();
do {
System.out.print("Enter your guess: ");
guess = input.nextInt();
if (guess == randomN) {
System.out.println("You won!");
} else if (guess > randomN) {
System.out.println("Too high");
} else if (guess < randomN) {
System.out.println("Too low");
}
} while (guess != randomN);
}
}
| 0debug
|
Allow Specific Characters in a textbox C# : <p>I need to allow specific characters in my textbox but not range of letters only those ( T, A, G, C ).. the problem is I can't find the regular expression pattern for that.</p>
| 0debug
|
displaying only 5 number in acc and password java : i need user to only input 5 number for acc bumber and password i try this one but i can still run with more than 5 number ..
public static void login() throws IllegalLoginException {
int acc, password;
System.out.println("Welcome!");
System.out.print("Enter your account number: ");
acc = in.nextInt();
if (acc > 010000 && acc < 9999){
throw new IllegalLoginException("from Exception: Account number not enough 5 digits");
}
System.out.print("Enter your password number: ");
password = in.nextInt();
if (password >= 12345 && password <= 9999) {
throw new IllegalLoginException("from Exception: 5 Digits password required!");
}
System.out.println("\nHello there, " + acc);
}
| 0debug
|
How to make something like float: down with relative position? : <p>I'm trying to move the element to the bottom of its parent but only way to do that is to make it positioned absolute but i want it to be relative.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>#output{
height: 100px;
background-color: red;
}
#inner{
height: 30px;
background-color: blue;
/*float: down*/
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><div id="output">
<div id="inner"></div>
</div></code></pre>
</div>
</div>
</p>
| 0debug
|
GuestNetworkInterfaceList *qmp_guest_network_get_interfaces(Error **errp)
{
GuestNetworkInterfaceList *head = NULL, *cur_item = NULL;
struct ifaddrs *ifap, *ifa;
char err_msg[512];
if (getifaddrs(&ifap) < 0) {
snprintf(err_msg, sizeof(err_msg),
"getifaddrs failed: %s", strerror(errno));
error_set(errp, QERR_QGA_COMMAND_FAILED, err_msg);
goto error;
}
for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
GuestNetworkInterfaceList *info;
GuestIpAddressList **address_list = NULL, *address_item = NULL;
char addr4[INET_ADDRSTRLEN];
char addr6[INET6_ADDRSTRLEN];
int sock;
struct ifreq ifr;
unsigned char *mac_addr;
void *p;
g_debug("Processing %s interface", ifa->ifa_name);
info = guest_find_interface(head, ifa->ifa_name);
if (!info) {
info = g_malloc0(sizeof(*info));
info->value = g_malloc0(sizeof(*info->value));
info->value->name = g_strdup(ifa->ifa_name);
if (!cur_item) {
head = cur_item = info;
} else {
cur_item->next = info;
cur_item = info;
}
}
if (!info->value->has_hardware_address &&
ifa->ifa_flags & SIOCGIFHWADDR) {
sock = socket(PF_INET, SOCK_STREAM, 0);
if (sock == -1) {
snprintf(err_msg, sizeof(err_msg),
"failed to create socket: %s", strerror(errno));
error_set(errp, QERR_QGA_COMMAND_FAILED, err_msg);
goto error;
}
memset(&ifr, 0, sizeof(ifr));
strncpy(ifr.ifr_name, info->value->name, IF_NAMESIZE);
if (ioctl(sock, SIOCGIFHWADDR, &ifr) == -1) {
snprintf(err_msg, sizeof(err_msg),
"failed to get MAC addres of %s: %s",
ifa->ifa_name,
strerror(errno));
error_set(errp, QERR_QGA_COMMAND_FAILED, err_msg);
goto error;
}
mac_addr = (unsigned char *) &ifr.ifr_hwaddr.sa_data;
if (asprintf(&info->value->hardware_address,
"%02x:%02x:%02x:%02x:%02x:%02x",
(int) mac_addr[0], (int) mac_addr[1],
(int) mac_addr[2], (int) mac_addr[3],
(int) mac_addr[4], (int) mac_addr[5]) == -1) {
snprintf(err_msg, sizeof(err_msg),
"failed to format MAC: %s", strerror(errno));
error_set(errp, QERR_QGA_COMMAND_FAILED, err_msg);
goto error;
}
info->value->has_hardware_address = true;
close(sock);
}
if (ifa->ifa_addr &&
ifa->ifa_addr->sa_family == AF_INET) {
address_item = g_malloc0(sizeof(*address_item));
address_item->value = g_malloc0(sizeof(*address_item->value));
p = &((struct sockaddr_in *)ifa->ifa_addr)->sin_addr;
if (!inet_ntop(AF_INET, p, addr4, sizeof(addr4))) {
snprintf(err_msg, sizeof(err_msg),
"inet_ntop failed : %s", strerror(errno));
error_set(errp, QERR_QGA_COMMAND_FAILED, err_msg);
goto error;
}
address_item->value->ip_address = g_strdup(addr4);
address_item->value->ip_address_type = GUEST_IP_ADDRESS_TYPE_IPV4;
if (ifa->ifa_netmask) {
p = &((struct sockaddr_in *)ifa->ifa_netmask)->sin_addr;
address_item->value->prefix = ctpop32(((uint32_t *) p)[0]);
}
} else if (ifa->ifa_addr &&
ifa->ifa_addr->sa_family == AF_INET6) {
address_item = g_malloc0(sizeof(*address_item));
address_item->value = g_malloc0(sizeof(*address_item->value));
p = &((struct sockaddr_in6 *)ifa->ifa_addr)->sin6_addr;
if (!inet_ntop(AF_INET6, p, addr6, sizeof(addr6))) {
snprintf(err_msg, sizeof(err_msg),
"inet_ntop failed : %s", strerror(errno));
error_set(errp, QERR_QGA_COMMAND_FAILED, err_msg);
goto error;
}
address_item->value->ip_address = g_strdup(addr6);
address_item->value->ip_address_type = GUEST_IP_ADDRESS_TYPE_IPV6;
if (ifa->ifa_netmask) {
p = &((struct sockaddr_in6 *)ifa->ifa_netmask)->sin6_addr;
address_item->value->prefix =
ctpop32(((uint32_t *) p)[0]) +
ctpop32(((uint32_t *) p)[1]) +
ctpop32(((uint32_t *) p)[2]) +
ctpop32(((uint32_t *) p)[3]);
}
}
if (!address_item) {
continue;
}
address_list = &info->value->ip_addresses;
while (*address_list && (*address_list)->next) {
address_list = &(*address_list)->next;
}
if (!*address_list) {
*address_list = address_item;
} else {
(*address_list)->next = address_item;
}
info->value->has_ip_addresses = true;
}
freeifaddrs(ifap);
return head;
error:
freeifaddrs(ifap);
qapi_free_GuestNetworkInterfaceList(head);
return NULL;
}
| 1threat
|
static ssize_t stellaris_enet_receive(NetClientState *nc, const uint8_t *buf, size_t size)
{
stellaris_enet_state *s = qemu_get_nic_opaque(nc);
int n;
uint8_t *p;
uint32_t crc;
if ((s->rctl & SE_RCTL_RXEN) == 0)
return -1;
if (s->np >= 31) {
return 0;
}
DPRINTF("Received packet len=%zu\n", size);
n = s->next_packet + s->np;
if (n >= 31)
n -= 31;
s->np++;
s->rx[n].len = size + 6;
p = s->rx[n].data;
*(p++) = (size + 6);
*(p++) = (size + 6) >> 8;
memcpy (p, buf, size);
p += size;
crc = crc32(~0, buf, size);
*(p++) = crc;
*(p++) = crc >> 8;
*(p++) = crc >> 16;
*(p++) = crc >> 24;
if ((size & 3) != 2) {
memset(p, 0, (6 - size) & 3);
}
s->ris |= SE_INT_RX;
stellaris_enet_update(s);
return size;
}
| 1threat
|
VBA Outlook Inbox search- Only shows emails received before certain date : The follow VBA excerpt that loops through emails in Outlook inbox only shows emails that have been received before a certain date( more than a week ago).
For Each obj In olFolder.Items
Debug.Print obj.Subject & Chr(10) & obj.SenderEmailAddress & Chr(10) & obj.ReceivedTime
Next
Many more emails show in the very same account and very same folder in Outlook itself.
What can this issue be?
| 0debug
|
. How do I swap odd elements in array of a String????? Eg: Input: I Love India Output will be: I voLe dnIia :
How do I swap odd elements in Array of a String????? Eg: Input: I Love India Output will be: I voLe dnIia
package com.String;
import java.util.Scanner;
public class swap_odd_element {
public static void main(String[] args) {
String s1= "I Love India";
String[] arr= s1.split(" ");
for(String s2:arr)
{
if(s2.length()>1)
{
char[] arr1= s2.toCharArray();
int len=arr1.length;
for(int i=0; i< len;i++)
{
char temp=arr1[i];
arr1[i]=arr1[i+2];
arr1[i+2]= temp;
String swap = new String(arr1);
}
}
else{
System.out.println(s2);
}
}
}
}
| 0debug
|
static int default_monitor_get_fd(Monitor *mon, const char *name, Error **errp)
{
error_setg(errp, "only QEMU supports file descriptor passing");
return -1;
}
| 1threat
|
How to include jquery and bootstrap after instilling them with npm : <p>I was including frameworks and libraries by CDN, but I want to be more professional so I jumped to new tools to learn. I started wih NPM and I grasped all its basis like how to install, to update ....! but I puzzled how to include them in my project and when it comes to host should I add the node_modules folder too! </p>
<p>I know that including them this way
<code><link rel="stylesheet" href="./node_modules/bootstrap/css/bootstrap.min.css" /></code><br>
aint the way unless why the hell is npm for</p>
<p>my questions are:
what is the nxt step after installing ? and how to including them in my project?
when it comes to host or save it in git should I add the folder node_modules too?
thanks all of you</p>
| 0debug
|
async constructor functions in TypeScript? : <p>I have some setup I want during a constructor, but it seems that is not allowed</p>
<p><a href="https://i.stack.imgur.com/xUSOH.png" rel="noreferrer"><img src="https://i.stack.imgur.com/xUSOH.png" alt="no async const"></a></p>
<p>Which means I can't use:</p>
<p><a href="https://i.stack.imgur.com/IIlGJ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/IIlGJ.png" alt="await"></a></p>
<p>How else should I do this?</p>
<p>Currently I have something outside like this, but this is not guaranteed to run in the order I want?</p>
<pre><code>async function run() {
let topic;
debug("new TopicsModel");
try {
topic = new TopicsModel();
} catch (err) {
debug("err", err);
}
await topic.setup();
</code></pre>
| 0debug
|
c# add a textbox field in livecycle xfd form using itextsharper : I have a livecycle form. I want to add a input field to it programmatically using c#. I tried many ways to do so but not able to add a field to an existing livecycle xfd form.
Please help me if anybody has a code snippet that i can use.
Kind Regards
Tripat
| 0debug
|
how to change a string to date with particular format? : > I have a string like "2016-04-13" i need to change it date format like
> 13 April, 2016 how can i do this in javascript
new Date(dateString);
new Date(year, month[, day[, hour[, minutes[, seconds[, milliseconds]]]]]);
| 0debug
|
What is the most 'pure javascript' way to write my function? (to reduce the execution time) : var AcceptLngs = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pt-BR'],
_getI18N = {
'wordToTranslate' : {
'pt' : `translatedWord`,
[...]
},
'2ndWordToTranslate' : {
'pt-BR' : `translatedWord`,
[...]
}
},
nav = window.navigator,
navLng = nav.language || nav.browserLanguage || nav.userLanguage,
defaultLng = 'en',
lng = navLng, //It must be set for translation
// CHECK THE LANGUAGE OF THE NAVIGATOR.
checkLng = function checkLng() {
// isL10nAvailable:
if (AcceptLngs.indexOf(lng) < -1) {
lng = lng;
return lng;
}
},
// SEARCH IF LANGUAGE OF THE APP IS AVAILABLE.
isLngDispo = function isLngDispo() {
// isSubstrL10nAvailable:
checkLng();
if (AcceptLngs.indexOf(lng) === -1) {
lng = lng.substring(0,2);
return lng;
}
},
// SEARCH IF LANGUAGE OF THE APP IS AVAILABLE.
setLng = function setLng() {
// isL10nNoAvailable:
isLngDispo();
if (AcceptLngs.indexOf(lng) === -1) {
lng = defaultLng;
return lng;
}
};
// APPLYING LANGUAGE FOR THE APP.
setLng();
I am beginner in javascript (it shows, isn't it?).
My script works. The problem is its execution time.
I go from 102 ms (without the translation) to 448 ms (with).
I have try with loop, but I didn't manage to make it work properly. He didn't detect the language in `AcceptedLng` and automatically put me the nav.language.
Perhaps, more simply, I should search directly in '_getI18N', but I have not yet gotten familiar with the search in the arrays, and I can not get any results either.
Info: To translate, I use _getI18N[`wordToTranslate`][lng] into my script.
Thanks in advance.
| 0debug
|
How do I make custom buttons in Visual Studio? C# : I'm trying to make a launcher for a game that fixes some of it's bugs.
Right now I'm just working on the interface and I want to make custom buttons, not just those generic squares, but I can't figure out how.
Here's some example images.
[Regular button, not moused over.][1]
[Moused over / Highlighted button.][2]
[1]: http://i.stack.imgur.com/kT4iU.png
[2]: http://i.stack.imgur.com/KKYAg.png
I just threw those buttons together quickly, but that's what I want.
I want the button to highlight when I mouse over it, without it being inside of the default square buttons.
I hope I explained that well, I tried my best.
| 0debug
|
static int webm_dash_manifest_read_header(AVFormatContext *s)
{
char *buf;
int ret = matroska_read_header(s);
MatroskaTrack *tracks;
MatroskaDemuxContext *matroska = s->priv_data;
if (ret) {
av_log(s, AV_LOG_ERROR, "Failed to read file headers\n");
return -1;
if (!matroska->is_live) {
buf = av_asprintf("%g", matroska->duration);
if (!buf) return AVERROR(ENOMEM);
av_dict_set(&s->streams[0]->metadata, DURATION, buf, 0);
av_free(buf);
av_dict_set_int(&s->streams[0]->metadata, INITIALIZATION_RANGE, avio_tell(s->pb) - 5, 0);
buf = strrchr(s->filename, '/');
av_dict_set(&s->streams[0]->metadata, FILENAME, buf ? ++buf : s->filename, 0);
tracks = matroska->tracks.elem;
av_dict_set_int(&s->streams[0]->metadata, TRACK_NUMBER, tracks[0].num, 0);
return matroska->is_live ? 0 : webm_dash_manifest_cues(s);
| 1threat
|
How do I prevent a randomly generated picture from appearing twice in a row? (.Net) : Hi I started programming a couple of weeks ago and now I have a project in school where I want to make a program. I have a picturebox ("piturebox1") and an imagelist ("imagelist1") with four pictures. I want these to change randomly every 2 seconds and I don't want the same picture to appear twice in a row.
Is there some helpful person who would want to help me with this?
/Marcus from Sweden
| 0debug
|
static inline void gen_jcc1_noeob(DisasContext *s, int b, int l1)
{
CCPrepare cc = gen_prepare_cc(s, b, cpu_T[0]);
if (cc.mask != -1) {
tcg_gen_andi_tl(cpu_T[0], cc.reg, cc.mask);
cc.reg = cpu_T[0];
}
if (cc.use_reg2) {
tcg_gen_brcond_tl(cc.cond, cc.reg, cc.reg2, l1);
} else {
tcg_gen_brcondi_tl(cc.cond, cc.reg, cc.imm, l1);
}
}
| 1threat
|
static uint32_t slow_bar_readw(void *opaque, target_phys_addr_t addr)
{
AssignedDevRegion *d = opaque;
uint16_t *in = (uint16_t *)(d->u.r_virtbase + addr);
uint32_t r;
r = *in;
DEBUG("slow_bar_readl addr=0x" TARGET_FMT_plx " val=0x%08x\n", addr, r);
return r;
}
| 1threat
|
Reading a CSV files using Akka Streams : <p>I'm reading a csv file. I am using Akka Streams to do this so that I can create a graph of actions to perform on each line. I've got the following toy example up and running.</p>
<pre><code> def main(args: Array[String]): Unit = {
implicit val system = ActorSystem("MyAkkaSystem")
implicit val materializer = ActorMaterializer()
val source = akka.stream.scaladsl.Source.fromIterator(Source.fromFile("a.csv").getLines)
val sink = Sink.foreach(println)
source.runWith(sink)
}
</code></pre>
<p>The two <code>Source</code> types don't sit easy with me. Is this idiomatic or is there is a better way to write this?</p>
| 0debug
|
Loading Bar on my website : <p>Please I'm trying to knockoff a loading bar on my site, I have searched through the files, still can't find it. I also tried inspecting using google chrome, but I couldn't target the loader. Kindly help out</p>
<p><a href="http://crewresolution.com/public/" rel="nofollow noreferrer">Click here for to visit website.</a></p>
| 0debug
|
udp_listen(Slirp *slirp, uint32_t haddr, u_int hport, uint32_t laddr,
u_int lport, int flags)
{
struct sockaddr_in addr;
struct socket *so;
socklen_t addrlen = sizeof(struct sockaddr_in);
so = socreate(slirp);
if (!so) {
return NULL;
}
so->s = qemu_socket(AF_INET,SOCK_DGRAM,0);
so->so_expire = curtime + SO_EXPIRE;
insque(so, &slirp->udb);
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = haddr;
addr.sin_port = hport;
if (bind(so->s,(struct sockaddr *)&addr, addrlen) < 0) {
udp_detach(so);
return NULL;
}
socket_set_fast_reuse(so->s);
getsockname(so->s,(struct sockaddr *)&addr,&addrlen);
so->so_ffamily = AF_INET;
so->so_fport = addr.sin_port;
if (addr.sin_addr.s_addr == 0 ||
addr.sin_addr.s_addr == loopback_addr.s_addr) {
so->so_faddr = slirp->vhost_addr;
} else {
so->so_faddr = addr.sin_addr;
}
so->so_lfamily = AF_INET;
so->so_lport = lport;
so->so_laddr.s_addr = laddr;
if (flags != SS_FACCEPTONCE)
so->so_expire = 0;
so->so_state &= SS_PERSISTENT_MASK;
so->so_state |= SS_ISFCONNECTED | flags;
return so;
}
| 1threat
|
Difference between storing files in public directory and in storage in Laravel 5.4 : <p>What's the difference between storing files (images) in <code>public/images</code> folder and storing them in <code>storage/app/public</code>? </p>
| 0debug
|
static void virtio_ccw_notify(DeviceState *d, uint16_t vector)
{
VirtioCcwDevice *dev = to_virtio_ccw_dev_fast(d);
SubchDev *sch = dev->sch;
uint64_t indicators;
if (vector >= 128) {
return;
}
if (vector < VIRTIO_CCW_QUEUE_MAX) {
if (!dev->indicators) {
return;
}
if (sch->thinint_active) {
uint64_t ind_bit = dev->routes.adapter.ind_offset;
virtio_set_ind_atomic(sch, dev->indicators->addr +
(ind_bit + vector) / 8,
0x80 >> ((ind_bit + vector) % 8));
if (!virtio_set_ind_atomic(sch, dev->summary_indicator->addr,
0x01)) {
css_adapter_interrupt(dev->thinint_isc);
}
} else {
indicators = address_space_ldq(&address_space_memory,
dev->indicators->addr,
MEMTXATTRS_UNSPECIFIED,
NULL);
indicators |= 1ULL << vector;
address_space_stq(&address_space_memory, dev->indicators->addr,
indicators, MEMTXATTRS_UNSPECIFIED, NULL);
css_conditional_io_interrupt(sch);
}
} else {
if (!dev->indicators2) {
return;
}
vector = 0;
indicators = address_space_ldq(&address_space_memory,
dev->indicators2->addr,
MEMTXATTRS_UNSPECIFIED,
NULL);
indicators |= 1ULL << vector;
address_space_stq(&address_space_memory, dev->indicators2->addr,
indicators, MEMTXATTRS_UNSPECIFIED, NULL);
css_conditional_io_interrupt(sch);
}
}
| 1threat
|
How to test if function was called with defined parameters ( toHaveBeenCalledWith ) with Jest : <p>I want to test, if particular function was called in my test and with the correct parameters. From JEST documentation I'm not able to figure out, what is the correct way to do it.</p>
<p>Let's say I have something like this:</p>
<pre><code>// add.js
function child(ch) {
const t = ch + 1;
// no return value here. Function has some other "side effect"
}
function main(a) {
if (a == 2) {
child(a + 2);
}
return a + 1;
}
exports.main = main;
exports.child = child;
</code></pre>
<p>Now in unit test:</p>
<p>1.
I want to run <code>main(1)</code> and test that it returned <code>2</code> and <code>child()</code> was not called.</p>
<p>2.
And then I want to run <code>main(2)</code> and thest that it returned <code>3</code> and <code>child(4)</code> was called exactly once.</p>
<p>I have something like this now:</p>
<pre><code>// add-spec.js
module = require('./add');
describe('main', () => {
it('should add one and not call child Fn', () => {
expect(module.main(1)).toBe(2);
// TODO: child() was not called
});
it('should add one andcall child Fn', () => {
expect(module.main(2)).toBe(3);
// TODO: child() was called with param 4 exactly once
// expect(module.child).toHaveBeenCalledWith(4);
});
});
</code></pre>
<p>I'm testing this in <a href="https://repl.it/languages/jest" rel="noreferrer">https://repl.it/languages/jest</a> , so a working example in this REPL will be much appreciated. </p>
| 0debug
|
static void etsec_cleanup(NetClientState *nc)
{
}
| 1threat
|
Why is 'key' function appended to the end of my OrderedDict when sorting? : <p>I am using python 3.6.5 and I am sorting an <code>OrderedDict</code>, e.g. <code>tmp.py</code>:</p>
<pre><code>from collections import OrderedDict
d = OrderedDict()
d[6] = 'a'
d[5] = 'b'
d[3] = 'c'
d[4] = 'd'
print(d)
print("keys : {}".format(d.keys()))
d = OrderedDict(sorted(d.items()), key=lambda t: t[1])
print(d)
print("keys : {}".format(d.keys()))
</code></pre>
<p>When I run <code>tmp.py</code>, I get :</p>
<pre><code>OrderedDict([(6, 'a'), (5, 'b'), (3, 'c'), (4, 'd')])
keys : odict_keys([6, 5, 3, 4])
OrderedDict([(3, 'c'), (4, 'd'), (5, 'b'), (6, 'a'), ('key', <function <lambda> at 0x2ab444506bf8>)])
keys : odict_keys([3, 4, 5, 6, 'key'])
</code></pre>
<p>Clearly the process of sorting has appended the <code>key()</code> function to my new <code>OrderedDict</code>. I believe that I am sorting this in the same fashion prescribed in <a href="https://stackoverflow.com/a/8031431/4021436">this</a> post.</p>
<p><strong>QUESTION</strong> :
Why does this happen and how to I properly sort an <code>OrderedDict</code>? </p>
| 0debug
|
default parameters in node.js : <p>How does one go about setting default parameters in node.js?</p>
<p>For instance, let's say I have a function that would normally look like this:</p>
<pre><code>function(anInt, aString, cb, aBool=true){
if(bool){...;}else{...;}
cb();
}
</code></pre>
<p>To call it would look something like this:</p>
<pre><code>function(1, 'no', function(){
...
}, false);
</code></pre>
<p>or:</p>
<pre><code>function(2, 'yes', function(){
...
});
</code></pre>
<p>However, it doesn't seem that node.js supports default parameters in this manner. What is the best way to acomplish above?</p>
| 0debug
|
Unknown override specifier, missing type specifier : <p>First, <code>Parameter.h</code>:</p>
<pre><code>#pragma once
#include <string>
class Parameter {
public:
Parameter();
~Parameter();
private:
string constValue;
string varName;
};
</code></pre>
<p>And <code>Parameter.cpp</code>:</p>
<pre><code>#include "Parameter.h"
using namespace std;
Parameter::Parameter() {};
Parameter::~Parameter() {};
</code></pre>
<p>I've brought these two files down to the barest of bones to get the errors that seem to be popping up. At the two private declarations for <code>string</code>s, I get the two errors:</p>
<pre><code>'constValue': unknown override specifier
missing type specifier - int assumed. Note: C++ does not support default-int
</code></pre>
<p>I've seen several questions with these errors, but each refers to circular or missing references. As I've stripped it down to what's absolutely required, I can see no circular references or references that are missing.</p>
<p>Any ideas?</p>
| 0debug
|
How can I create a public static method while implementing an interface in c#? : <p>I have the following interface</p>
<pre><code>public interface IQueryBuilder
{
SqlCommand Build(IReportDataSource dataSource, List<IReportColumn> columns, List<IReportRelationMapping> relationMappings, IReportFilterMapping filters, List<IReportColumn> columsToSortBy, ReportFormat reportFormat);
string GetSqlClause(List<IReportFilter> reportFilters, ref List<IDataParameter> sqlParams);
}
</code></pre>
<p>However, I would like to be able to access the method <code>GetSqlClause</code> in the implementation directly.</p>
<p>Here is how I implemented the above </p>
<pre><code>public class QueryBuilder : IQueryBuilder
{
public SqlCommand Build(IReportDataSource dataSource, List<IReportColumn> columns, List<IReportRelationMapping> relationMappings, IReportFilterMapping filters, List<IReportColumn> columsToSortBy, ReportFormat reportType)
{
//Do something awsome!!!
string sqlQuery = "";
List<IDataParameter> sqlParameters = new List<IDataParameter>();
return this.GetSqlCommand(sqlQuery, sqlParameters);
}
private SqlCommand GetSqlCommand(string sqlQuery, List<IDataParameter> sqlParams)
{
var command = new SqlCommand(sqlQuery);
foreach (IDataParameter dataParameter in sqlParams)
{
command.Parameters.Add(dataParameter);
}
return command;
}
public static string GetSqlClause(List<IReportFilter> reportFilters, ref List<IDataParameter> sqlParams)
{
string sqlFilter = "";
if (reportFilters != null && reportFilters.Any())
{
//At this point we know there are some filter to add to the list
var firstFilter = reportFilters.First();
foreach (var reportFilter in reportFilters)
{
var parameter = GenerateDbParameter("p" + sqlParams.Count, reportFilter.FormattedValue, SqlDbType.NVarChar);
....
....
}
}
return sqlFilter;
}
private static IDataParameter GenerateDbParameter(string parameterName, object parameterValue, SqlDbType parameterType)
{
if (string.IsNullOrEmpty(parameterName) || parameterValue == null)
{
throw new ArgumentException();
}
var parameter = new SqlParameter("@" + parameterName, parameterType)
{
Value = parameterValue
};
return parameter;
}
}
</code></pre>
<p>Because I am using <code>static</code> on my <code>GetSqlClause</code> method I get an error</p>
<blockquote>
<p>cannot implement an interface member because it is static.</p>
</blockquote>
<p>What is a good work around to this problem? How can I access my <code>GetSqlClause</code> directly?</p>
| 0debug
|
static void uncouple_channels(AC3DecodeContext * ctx)
{
ac3_audio_block *ab = &ctx->audio_block;
int ch, sbnd, bin;
int index;
int16_t mantissa;
for (ch = 0; ch < ctx->bsi.nfchans; ch++)
if (ab->chincpl & (1 << ch))
for (sbnd = ab->cplbegf; sbnd < 3 + ab->cplendf; sbnd++)
for (bin = 0; bin < 12; bin++) {
index = sbnd * 12 + bin + 37;
ab->transform_coeffs[ch + 1][index] = ab->cplcoeffs[index] * ab->cplco[ch][sbnd] * ab->chcoeffs[ch];
if (!ab->bap[ch][index] && (ab->chincpl & (1 << ch)) && (ab->dithflag & (1 << ch))) {
mantissa = dither_int16(&ctx->state);
ab->transform_coeffs[ch + 1][index] = to_float(ab->dexps[ch][index], mantissa) * ab->chcoeffs[ch];
}
}
}
| 1threat
|
how to make my program check if its a palindrome by ignoring non-alpha characters and white spaces : <p>Hi this code currently checks if it is a palindrome if there all the letters are same capitalization and if there is no spaces. I am trying to make it so it ignores non-alpha and white spaces. </p>
<pre><code>import java.util.*;
public class PalindromeTester
{
public static void main(String args[])
{
String original, reverse = "";
Scanner in = new Scanner(System.in);
System.out.println("Enter a string to check if it is a palindrome");
original = in.nextLine();
int length = original.length();
for ( int i = length - 1; i >= 0; i-- )
reverse = reverse + original.charAt(i);
if (original.equals(reverse))
System.out.println("Entered string is a palindrome.");
else
System.out.println("Entered string is not a palindrome.");
}
}
</code></pre>
| 0debug
|
static uint32_t qvirtio_pci_get_guest_features(QVirtioDevice *d)
{
QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d;
return qpci_io_readl(dev->pdev, dev->addr + VIRTIO_PCI_GUEST_FEATURES);
}
| 1threat
|
void qemu_cpu_kick(void *env)
{
}
| 1threat
|
static void qemu_s390_flic_class_init(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
S390FLICStateClass *fsc = S390_FLIC_COMMON_CLASS(oc);
dc->reset = qemu_s390_flic_reset;
fsc->register_io_adapter = qemu_s390_register_io_adapter;
fsc->io_adapter_map = qemu_s390_io_adapter_map;
fsc->add_adapter_routes = qemu_s390_add_adapter_routes;
fsc->release_adapter_routes = qemu_s390_release_adapter_routes;
fsc->clear_io_irq = qemu_s390_clear_io_flic;
fsc->modify_ais_mode = qemu_s390_modify_ais_mode;
}
| 1threat
|
How to add a data from textarea in database without refresh page : <p>I was developing a system of Login and Register with PHP, HTML, MySql etc, so, i have a problem with my chat!</p>
<p>I want to get data from textarea, and if the button was clicked, empty the textarea, and send the text to database without refresh a page! I have a system that refresh the data from the database and refresh the div "chat" in index.php !</p>
<p>Help me!</p>
| 0debug
|
void qemu_set_fd_handler(int fd,
IOHandler *fd_read,
IOHandler *fd_write,
void *opaque)
{
iohandler_init();
aio_set_fd_handler(iohandler_ctx, fd, false,
fd_read, fd_write, NULL, opaque);
}
| 1threat
|
static int timer_load(QEMUFile *f, void *opaque, int version_id)
{
if (version_id != 1 && version_id != 2)
return -EINVAL;
if (cpu_ticks_enabled) {
return -EINVAL;
}
cpu_ticks_offset=qemu_get_be64(f);
ticks_per_sec=qemu_get_be64(f);
if (version_id == 2) {
cpu_clock_offset=qemu_get_be64(f);
}
return 0;
}
| 1threat
|
static void cpu_pre_save(void *opaque)
{
CPUState *env = opaque;
int i;
cpu_synchronize_state(env);
env->fpus_vmstate = (env->fpus & ~0x3800) | (env->fpstt & 0x7) << 11;
env->fptag_vmstate = 0;
for(i = 0; i < 8; i++) {
env->fptag_vmstate |= ((!env->fptags[i]) << i);
}
#ifdef USE_X86LDOUBLE
env->fpregs_format_vmstate = 0;
#else
env->fpregs_format_vmstate = 1;
#endif
}
| 1threat
|
Get Rows based on distinct values from Column 2 : <p>I am a newbie to pandas, tried searching this on google but still no luck. How can I get the rows by distinct values in column2?</p>
<p>For example, I have the dataframe bellow:</p>
<pre><code>>>> df
COL1 COL2
a.com 22
b.com 45
c.com 34
e.com 45
f.com 56
g.com 22
h.com 45
</code></pre>
<p>I want to get the rows based on unique values in COL2</p>
<pre><code>>>> df
COL1 COL2
a.com 22
b.com 45
c.com 34
f.com 56
</code></pre>
<p>So, how can I get that? I would appreciate it very much if anyone can provide any help.</p>
| 0debug
|
void net_tx_pkt_reset(struct NetTxPkt *pkt)
{
int i;
if (!pkt) {
return;
}
memset(&pkt->virt_hdr, 0, sizeof(pkt->virt_hdr));
g_free(pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_base);
pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_base = NULL;
assert(pkt->vec);
for (i = NET_TX_PKT_L2HDR_FRAG;
i < pkt->payload_frags + NET_TX_PKT_PL_START_FRAG; i++) {
pkt->vec[i].iov_len = 0;
}
pkt->payload_len = 0;
pkt->payload_frags = 0;
assert(pkt->raw);
for (i = 0; i < pkt->raw_frags; i++) {
assert(pkt->raw[i].iov_base);
cpu_physical_memory_unmap(pkt->raw[i].iov_base, pkt->raw[i].iov_len,
false, pkt->raw[i].iov_len);
pkt->raw[i].iov_len = 0;
}
pkt->raw_frags = 0;
pkt->hdr_len = 0;
pkt->packet_type = 0;
pkt->l4proto = 0;
}
| 1threat
|
static void mips_cpu_initfn(Object *obj)
{
CPUState *cs = CPU(obj);
MIPSCPU *cpu = MIPS_CPU(obj);
CPUMIPSState *env = &cpu->env;
cs->env_ptr = env;
cpu_exec_init(cs, &error_abort);
if (tcg_enabled()) {
mips_tcg_init();
}
}
| 1threat
|
void qpci_plug_device_test(const char *driver, const char *id,
uint8_t slot, const char *opts)
{
QDict *response;
char *cmd;
cmd = g_strdup_printf("{'execute': 'device_add',"
" 'arguments': {"
" 'driver': '%s',"
" 'addr': '%d',"
" %s%s"
" 'id': '%s'"
"}}", driver, slot,
opts ? opts : "", opts ? "," : "",
id);
response = qmp(cmd);
g_free(cmd);
g_assert(response);
g_assert(!qdict_haskey(response, "error"));
QDECREF(response);
}
| 1threat
|
pd.read_excel throws PermissionError if file is open in Excel : <p>Whenever I have the file open in Excel and run the code, I get the following error which is surprising because I thought read_excel should be a read only operation and would not require the file to be unlocked?</p>
<pre><code> Traceback (most recent call last):
File "C:\Users\Public\a.py", line 53, in <module>
main()
File "C:\Users\Public\workspace\a.py", line 47, in main
blend = plStream(rootDir);
File "C:\Users\Public\workspace\a.py", line 20, in plStream
df = pd.read_excel(fPath, sheetname="linear strategy", index_col="date", parse_dates=True)
File "C:\Users\Public\Continuum\Anaconda35\lib\site-packages\pandas\io\excel.py", line 163, in read_excel
io = ExcelFile(io, engine=engine)
File "C:\Users\Public\Continuum\Anaconda35\lib\site-packages\pandas\io\excel.py", line 206, in __init__
self.book = xlrd.open_workbook(io)
File "C:\Users\Public\Continuum\Anaconda35\lib\site-packages\xlrd\__init__.py", line 394, in open_workbook
f = open(filename, "rb")
PermissionError: [Errno 13] Permission denied: '<Path to File>'
</code></pre>
| 0debug
|
React Enzyme - Test `componentDidMount` Async Call : <p>everyone.</p>
<p>I'm having weird issues with testing a state update after an async call happening in <code>componentDidMount</code>.</p>
<p>Here's my component code:</p>
<pre><code>'use strict';
import React from 'react';
import UserComponent from './userComponent';
const request = require('request');
class UsersListComponent extends React.Component {
constructor(props) {
super(props);
this.state = {
usersList: []
};
}
componentDidMount() {
request('https://api.github.com/users', (err, res) => {
if (!err && res.statusCode === 200) {
this.setState({
usersList: res.slice(0)
});
}
else {
console.log(err);
}
});
}
render() {
if (!this.state.usersList.length) {
return null;
}
return (
<div className="users-list">
{ this._constructUsersList() }
</div>
);
}
_constructUsersList() {
return this.state.usersList.map((user, index) => {
return (
<UserComponent
key={ index }
name={ user.name }
age={ user.age } />
);
});
}
};
export default UsersListComponent;
</code></pre>
<p>Now, what I'm doing in my test files (I have a setup comprised of Mocha + Chai + Sinon, all working):</p>
<pre><code>import React from 'react';
import { expect } from 'chai';
import { shallow, mount, render } from 'enzyme';
import sinon from 'sinon';
import UsersListComponent from '../src/usersListComponent';
describe('Test suite for UsersListComponent', () => {
it('Correctly updates the state after AJAX call in `componentDidMount` was made', () => {
const server = sinon.fakeServer.create();
server.respondWith('GET', 'https://api.github.com/users', [
200,
{
'Content-Type': 'application/json',
'Content-Length': 2
},
'[{ "name": "Reign", "age": 26 }]'
]);
let wrapper = mount(<UsersListComponent />);
server.respond();
server.restore();
expect(wrapper.update().state().usersList).to.be.instanceof(Array);
console.log(wrapper.update().state().usersList.length);
});
});
</code></pre>
<p>State does not get updated, even though I call <code>update()</code> on wrapper. Length is still 0. Am I missing something here? Do I need to mock the server response in another way?</p>
<p>Thnx for the help!</p>
| 0debug
|
MigrationInfo *qmp_query_migrate(Error **errp)
{
MigrationInfo *info = g_malloc0(sizeof(*info));
MigrationState *s = migrate_get_current();
switch (s->state) {
case MIGRATION_STATUS_NONE:
break;
case MIGRATION_STATUS_SETUP:
info->has_status = true;
info->status = MIGRATION_STATUS_SETUP;
info->has_total_time = false;
break;
case MIGRATION_STATUS_ACTIVE:
case MIGRATION_STATUS_CANCELLING:
info->has_status = true;
info->status = MIGRATION_STATUS_ACTIVE;
info->has_total_time = true;
info->total_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME)
- s->total_time;
info->has_expected_downtime = true;
info->expected_downtime = s->expected_downtime;
info->has_setup_time = true;
info->setup_time = s->setup_time;
info->has_ram = true;
info->ram = g_malloc0(sizeof(*info->ram));
info->ram->transferred = ram_bytes_transferred();
info->ram->remaining = ram_bytes_remaining();
info->ram->total = ram_bytes_total();
info->ram->duplicate = dup_mig_pages_transferred();
info->ram->skipped = skipped_mig_pages_transferred();
info->ram->normal = norm_mig_pages_transferred();
info->ram->normal_bytes = norm_mig_bytes_transferred();
info->ram->dirty_pages_rate = s->dirty_pages_rate;
info->ram->mbps = s->mbps;
info->ram->dirty_sync_count = s->dirty_sync_count;
if (blk_mig_active()) {
info->has_disk = true;
info->disk = g_malloc0(sizeof(*info->disk));
info->disk->transferred = blk_mig_bytes_transferred();
info->disk->remaining = blk_mig_bytes_remaining();
info->disk->total = blk_mig_bytes_total();
}
get_xbzrle_cache_stats(info);
break;
case MIGRATION_STATUS_COMPLETED:
get_xbzrle_cache_stats(info);
info->has_status = true;
info->status = MIGRATION_STATUS_COMPLETED;
info->has_total_time = true;
info->total_time = s->total_time;
info->has_downtime = true;
info->downtime = s->downtime;
info->has_setup_time = true;
info->setup_time = s->setup_time;
info->has_ram = true;
info->ram = g_malloc0(sizeof(*info->ram));
info->ram->transferred = ram_bytes_transferred();
info->ram->remaining = 0;
info->ram->total = ram_bytes_total();
info->ram->duplicate = dup_mig_pages_transferred();
info->ram->skipped = skipped_mig_pages_transferred();
info->ram->normal = norm_mig_pages_transferred();
info->ram->normal_bytes = norm_mig_bytes_transferred();
info->ram->mbps = s->mbps;
info->ram->dirty_sync_count = s->dirty_sync_count;
break;
case MIGRATION_STATUS_FAILED:
info->has_status = true;
info->status = MIGRATION_STATUS_FAILED;
break;
case MIGRATION_STATUS_CANCELLED:
info->has_status = true;
info->status = MIGRATION_STATUS_CANCELLED;
break;
}
return info;
}
| 1threat
|
How can I store a char * in a struct which as an unsigned int : I'm trying to store a char into my `_float`. I do this in my `getBits` function. However, I am a little confused. I am trying to store the chars into the struct but when I print it out, it only prints the whatever the first digit is.
Example:
/program 0 10000100 01000000010000100000000
Test 1
// The answer should be 10000100?
So my question is how do I store it correctly?
struct _float {
unsigned int sign:1, exp:8, frac:23;
};
typedef struct _float Float32;
union _bits32 {
float fval; // Bits as a float
Word xval; // Bits as a word
Float32 bits; // manipulate individual bits
};
typedef union _bits32 Union32;
int main(int argc, char **argv) {
union _bits32 u;
char out[50];
u.bits.sign = u.bits.exp = u.bits.frac = 0;
u = getBits(argv[1], argv[2], argv[3]);
return 0;
}
// convert three bit-strings (already checked)
// into the components of a struct _float
Union32 getBits(char *sign, char *exp, char *frac) {
Union32 new;
// convert char *sign into a single bit in new.bits
new.bits.sign = *sign;
// convert char *exp into an 8-bit value in new.bits
new.bits.exp = *exp;
printf("Test %c\n", new.bits.exp); // <<<<<<<<< My question is here
// convert char *frac into a 23-bit value in new.bits
new.bits.frac = *frac;
return new;
}
| 0debug
|
int kvm_set_ioeventfd_pio_word(int fd, uint16_t addr, uint16_t val, bool assign)
{
struct kvm_ioeventfd kick = {
.datamatch = val,
.addr = addr,
.len = 2,
.flags = KVM_IOEVENTFD_FLAG_DATAMATCH | KVM_IOEVENTFD_FLAG_PIO,
.fd = fd,
};
int r;
if (!kvm_enabled())
return -ENOSYS;
if (!assign)
kick.flags |= KVM_IOEVENTFD_FLAG_DEASSIGN;
r = kvm_vm_ioctl(kvm_state, KVM_IOEVENTFD, &kick);
if (r < 0)
return r;
return 0;
}
| 1threat
|
How to check the weights after every epoc in Keras model : <p>I am using the sequential model in Keras. I would like to check the weight of the model after every epoch. Could you please guide me on how to do so. </p>
<pre><code>model = Sequential()
model.add(Embedding(max_features, 128, dropout=0.2))
model.add(LSTM(128, dropout_W=0.2, dropout_U=0.2))
model.add(Dense(1))
model.add(Activation('sigmoid'))
model.compile(loss='binary_crossentropy',optimizer='adam',metrics['accuracy'])
model.fit(X_train, y_train, batch_size=batch_size, nb_epoch=5 validation_data=(X_test, y_test))
</code></pre>
<p>Thanks in advance.</p>
| 0debug
|
void configure_icount(const char *option)
{
vmstate_register(NULL, 0, &vmstate_timers, &timers_state);
if (!option)
return;
#ifdef CONFIG_IOTHREAD
vm_clock->warp_timer = qemu_new_timer_ns(rt_clock, icount_warp_rt, NULL);
#endif
if (strcmp(option, "auto") != 0) {
icount_time_shift = strtol(option, NULL, 0);
use_icount = 1;
return;
}
use_icount = 2;
icount_time_shift = 3;
icount_rt_timer = qemu_new_timer_ms(rt_clock, icount_adjust_rt, NULL);
qemu_mod_timer(icount_rt_timer,
qemu_get_clock_ms(rt_clock) + 1000);
icount_vm_timer = qemu_new_timer_ns(vm_clock, icount_adjust_vm, NULL);
qemu_mod_timer(icount_vm_timer,
qemu_get_clock_ns(vm_clock) + get_ticks_per_sec() / 10);
}
| 1threat
|
Android Emulator's "Enable keyboard input" always unchecked after Mac OS Sierra reboot : <p>Since updating the emulator it doesn't remember the "Enable keyboard input" checkbox on system restarts. </p>
<p><a href="https://i.stack.imgur.com/6710E.png" rel="noreferrer"><img src="https://i.stack.imgur.com/6710E.png" alt="enter image description here"></a></p>
<p>Does anybody have a similar issue or knows how to fix it?</p>
<p>I use:</p>
<p><a href="https://i.stack.imgur.com/rOESW.png" rel="noreferrer"><img src="https://i.stack.imgur.com/rOESW.png" alt="enter image description here"></a></p>
| 0debug
|
Can i turn my eclipse project into linux application? : <p>Right now I'm working on a app, using eclipse on windows 10. I want to know can i turn my project into a linux runable file?</p>
| 0debug
|
How can I pass into and use two integer arguments into a C# command line program? : <p>I have a C# program called data-1 that I run on Mac OS</p>
<p>Where I run this I use:</p>
<pre><code>> dotnet data-1.dll
</code></pre>
<p>How can I change the main so that I can enter something like</p>
<pre><code>> dotnet data-1.dll 10, 20
</code></pre>
<p>and pass into the code the numbers 10 and 20?</p>
<pre><code>static void Main(string[] args)
{
</code></pre>
| 0debug
|
Difference of BPMN and BPEL : <p>What's the difference between BPMN (Business Process Model & Notation) and BPEL (Business Process Expression Language) and Where do we use BPMN and where do we use BPEL and which one is better?</p>
| 0debug
|
static void lsi_do_dma(LSIState *s, int out)
{
uint32_t count;
target_phys_addr_t addr;
if (!s->current_dma_len) {
DPRINTF("DMA no data available\n");
return;
}
count = s->dbc;
if (count > s->current_dma_len)
count = s->current_dma_len;
addr = s->dnad;
if (lsi_dma_40bit(s))
addr |= ((uint64_t)s->dnad64 << 32);
else if (s->sbms)
addr |= ((uint64_t)s->sbms << 32);
DPRINTF("DMA addr=0x" TARGET_FMT_plx " len=%d\n", addr, count);
s->csbc += count;
s->dnad += count;
s->dbc -= count;
if (s->dma_buf == NULL) {
s->dma_buf = s->current_dev->get_buf(s->current_dev,
s->current_tag);
}
if (out) {
cpu_physical_memory_read(addr, s->dma_buf, count);
} else {
cpu_physical_memory_write(addr, s->dma_buf, count);
}
s->current_dma_len -= count;
if (s->current_dma_len == 0) {
s->dma_buf = NULL;
if (out) {
s->current_dev->write_data(s->current_dev, s->current_tag);
} else {
s->current_dev->read_data(s->current_dev, s->current_tag);
}
} else {
s->dma_buf += count;
lsi_resume_script(s);
}
}
| 1threat
|
av_cold int ff_nvenc_encode_close(AVCodecContext *avctx)
{
NVENCContext *ctx = avctx->priv_data;
NV_ENCODE_API_FUNCTION_LIST *nv = &ctx->nvel.nvenc_funcs;
int i;
av_fifo_free(ctx->timestamps);
av_fifo_free(ctx->pending);
av_fifo_free(ctx->ready);
if (ctx->in) {
for (i = 0; i < ctx->nb_surfaces; ++i) {
nv->nvEncDestroyInputBuffer(ctx->nvenc_ctx, ctx->in[i].in);
nv->nvEncDestroyBitstreamBuffer(ctx->nvenc_ctx, ctx->out[i].out);
av_freep(&ctx->in);
av_freep(&ctx->out);
if (ctx->nvenc_ctx)
nv->nvEncDestroyEncoder(ctx->nvenc_ctx);
if (ctx->cu_context)
ctx->nvel.cu_ctx_destroy(ctx->cu_context);
if (ctx->nvel.nvenc)
dlclose(ctx->nvel.nvenc);
if (ctx->nvel.cuda)
dlclose(ctx->nvel.cuda);
return 0;
| 1threat
|
static void list_formats(AVFormatContext *ctx, int type)
{
const struct video_data *s = ctx->priv_data;
struct v4l2_fmtdesc vfd = { .type = V4L2_BUF_TYPE_VIDEO_CAPTURE };
while(!v4l2_ioctl(s->fd, VIDIOC_ENUM_FMT, &vfd)) {
enum AVCodecID codec_id = avpriv_fmt_v4l2codec(vfd.pixelformat);
enum AVPixelFormat pix_fmt = avpriv_fmt_v4l2ff(vfd.pixelformat, codec_id);
vfd.index++;
if (!(vfd.flags & V4L2_FMT_FLAG_COMPRESSED) &&
type & V4L_RAWFORMATS) {
const char *fmt_name = av_get_pix_fmt_name(pix_fmt);
av_log(ctx, AV_LOG_INFO, "Raw : %9s : %20s :",
fmt_name ? fmt_name : "Unsupported",
vfd.description);
} else if (vfd.flags & V4L2_FMT_FLAG_COMPRESSED &&
type & V4L_COMPFORMATS) {
AVCodec *codec = avcodec_find_decoder(codec_id);
av_log(ctx, AV_LOG_INFO, "Compressed: %9s : %20s :",
codec ? codec->name : "Unsupported",
vfd.description);
} else {
continue;
}
#ifdef V4L2_FMT_FLAG_EMULATED
if (vfd.flags & V4L2_FMT_FLAG_EMULATED)
av_log(ctx, AV_LOG_INFO, " Emulated :");
#endif
#if HAVE_STRUCT_V4L2_FRMIVALENUM_DISCRETE
list_framesizes(ctx, vfd.pixelformat);
#endif
av_log(ctx, AV_LOG_INFO, "\n");
}
}
| 1threat
|
Python Pandas: pivot only certain columns in the DataFrame while keeping others : <p>I am trying to re-arrange a DataFrame that I automatically read in from a json using Pandas. I've searched but have had no success.</p>
<p>I have the following json (saved as a string for copy/paste convenience) with a bunch of json objects/dictionarys under the tag 'value'</p>
<pre><code>json_str = '''{"preferred_timestamp": "internal_timestamp",
"internal_timestamp": 3606765503.684,
"stream_name": "ctdpf_j_cspp_instrument",
"values": [{
"value_id": "temperature",
"value": 9.8319
}, {
"value_id": "conductivity",
"value": 3.58847
}, {
"value_id": "pressure",
"value": 22.963
}]
}'''
</code></pre>
<p>I use the function 'json_normalize' in order to load the json into a flattened Pandas dataframe.</p>
<pre><code>>>> from pandas.io.json import json_normalize
>>> import simplejson as json
>>> df = json_normalize(json.loads(json_str), 'values', ['preferred_timestamp', 'stream_name', 'internal_timestamp'])
>>> df
value value_id preferred_timestamp internal_timestamp \
0 9.83190 temperature internal_timestamp 3.606766e+09
1 3.58847 conductivity internal_timestamp 3.606766e+09
2 22.96300 pressure internal_timestamp 3.606766e+09
3 32.89470 salinity internal_timestamp 3.606766e+09
stream_name
0 ctdpf_j_cspp_instrument
1 ctdpf_j_cspp_instrument
2 ctdpf_j_cspp_instrument
3 ctdpf_j_cspp_instrument
</code></pre>
<p>Here is where I am stuck. I want to take the value and value_id columns and pivot these into new columns based off of value_id. </p>
<p>I want the dataframe to look like the following:</p>
<pre><code>stream_name preferred_timestamp internal_timestamp conductivity pressure salinity temperature
ctdpf_j_cspp_instrument internal_timestamp 3.606766e+09 3.58847 22.96300 32.89470 9.83190
</code></pre>
<p>I've tried both the pivot and pivot_table Pandas functions and even tried to manually pivot the tables by using 'set_index' and 'stack' but it's not quite how I want it.</p>
<pre><code>>>> df.pivot_table(values='value', index=['stream_name', 'preferred_timestamp', 'internal_timestamp', 'value_id'])
stream_name preferred_timestamp internal_timestamp value_id
ctdpf_j_cspp_instrument internal_timestamp 3.606766e+09 conductivity 3.58847
pressure 22.96300
salinity 32.89470
temperature 9.83190
Name: value, dtype: float64
</code></pre>
<p>This is close, but it didn't seem to pivot the values in 'value_id' into separate columns.</p>
<p>and </p>
<pre><code>>>> df.pivot('stream_name', 'value_id', 'value')
value_id conductivity pressure salinity temperature
stream_name
ctdpf_j_cspp_instrument 3.58847 22.963 32.8947 9.8319
</code></pre>
<p>Close again, but it lacks the other columns that I want to be associated with this line.</p>
<p>I'm stuck here. Is there an elegant way of doing this or should I split the DataFrames and re-merge them to how I want?</p>
| 0debug
|
static void vp8_idct_dc_add4y_c(uint8_t *dst, int16_t block[4][16],
ptrdiff_t stride)
{
vp8_idct_dc_add_c(dst + 0, block[0], stride);
vp8_idct_dc_add_c(dst + 4, block[1], stride);
vp8_idct_dc_add_c(dst + 8, block[2], stride);
vp8_idct_dc_add_c(dst + 12, block[3], stride);
}
| 1threat
|
guys any one have implementation of bubble sort in netlogo : guys any one have implementation of bubble sort in netlogo help because i want to sort turtles by their strength and i have not much knowledge about that language
turtles-own[strength]
to setup
ca
create-turtles num-turtle [set strength random 100
fd 5
set size 2
set label strength
]
ask turtles [show sort [strength] of turtles ]
end
to bubblesort
set liste [strength] of turtles
if (turtle 0 [strength]) >= (turtle 1 [strength] ) ) [set size 5 ]
end
| 0debug
|
static void setup_frame(int sig, struct target_sigaction *ka,
target_sigset_t *set, CPUS390XState *env)
{
sigframe *frame;
abi_ulong frame_addr;
frame_addr = get_sigframe(ka, env, sizeof(*frame));
qemu_log("%s: frame_addr 0x%llx\n", __FUNCTION__,
(unsigned long long)frame_addr);
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) {
goto give_sigsegv;
}
qemu_log("%s: 1\n", __FUNCTION__);
if (__put_user(set->sig[0], &frame->sc.oldmask[0])) {
goto give_sigsegv;
}
save_sigregs(env, &frame->sregs);
__put_user((abi_ulong)(unsigned long)&frame->sregs,
(abi_ulong *)&frame->sc.sregs);
if (ka->sa_flags & TARGET_SA_RESTORER) {
env->regs[14] = (unsigned long)
ka->sa_restorer | PSW_ADDR_AMODE;
} else {
env->regs[14] = (unsigned long)
frame->retcode | PSW_ADDR_AMODE;
if (__put_user(S390_SYSCALL_OPCODE | TARGET_NR_sigreturn,
(uint16_t *)(frame->retcode)))
goto give_sigsegv;
}
if (__put_user(env->regs[15], (abi_ulong *) frame)) {
goto give_sigsegv;
}
env->regs[15] = frame_addr;
env->psw.addr = (target_ulong) ka->_sa_handler | PSW_ADDR_AMODE;
env->regs[2] = sig;
env->regs[3] = frame_addr += offsetof(typeof(*frame), sc);
env->regs[4] = 0;
env->regs[5] = 0;
if (__put_user(env->regs[2], (int *) &frame->signo)) {
goto give_sigsegv;
}
unlock_user_struct(frame, frame_addr, 1);
return;
give_sigsegv:
qemu_log("%s: give_sigsegv\n", __FUNCTION__);
unlock_user_struct(frame, frame_addr, 1);
force_sig(TARGET_SIGSEGV);
}
| 1threat
|
void qemu_acl_reset(qemu_acl *acl)
{
qemu_acl_entry *entry;
acl->defaultDeny = 1;
TAILQ_FOREACH(entry, &acl->entries, next) {
TAILQ_REMOVE(&acl->entries, entry, next);
free(entry->match);
free(entry);
}
acl->nentries = 0;
}
| 1threat
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.