problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
void omap_mpuio_out_set(struct omap_mpuio_s *s, int line, qemu_irq handler)
{
if (line >= 16 || line < 0)
hw_error("%s: No GPIO line %i\n", __FUNCTION__, line);
s->handler[line] = handler;
}
| 1threat
|
static int parse_picture(AVFormatContext *s, uint8_t *buf, int buf_size)
{
const CodecMime *mime = ff_id3v2_mime_tags;
enum CodecID id = CODEC_ID_NONE;
uint8_t mimetype[64], *desc = NULL, *data = NULL;
AVIOContext *pb = NULL;
AVStream *st;
int type, width, height;
int len, ret = 0;
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
pb = avio_alloc_context(buf, buf_size, 0, NULL, NULL, NULL, NULL);
if (!pb)
return AVERROR(ENOMEM);
type = avio_rb32(pb);
if (type >= FF_ARRAY_ELEMS(ff_id3v2_picture_types) || type < 0) {
av_log(s, AV_LOG_ERROR, "Invalid picture type: %d.\n", type);
ret = AVERROR_INVALIDDATA;
goto fail;
}
len = avio_rb32(pb);
if (len <= 0 ||
avio_read(pb, mimetype, FFMIN(len, sizeof(mimetype) - 1)) != len) {
av_log(s, AV_LOG_ERROR, "Could not read mimetype from an attached "
"picture.\n");
ret = AVERROR_INVALIDDATA;
goto fail;
}
mimetype[len] = 0;
while (mime->id != CODEC_ID_NONE) {
if (!strncmp(mime->str, mimetype, sizeof(mimetype))) {
id = mime->id;
break;
}
mime++;
}
if (id == CODEC_ID_NONE) {
av_log(s, AV_LOG_ERROR, "Unknown attached picture mimetype: %s.\n",
mimetype);
ret = AVERROR_INVALIDDATA;
goto fail;
}
len = avio_rb32(pb);
if (len > 0) {
if (!(desc = av_malloc(len + 1))) {
ret = AVERROR(ENOMEM);
goto fail;
}
if (avio_read(pb, desc, len) != len) {
ret = AVERROR(EIO);
goto fail;
}
desc[len] = 0;
}
width = avio_rb32(pb);
height = avio_rb32(pb);
avio_skip(pb, 8);
len = avio_rb32(pb);
if (len <= 0) {
ret = AVERROR_INVALIDDATA;
goto fail;
}
if (!(data = av_malloc(len))) {
ret = AVERROR(ENOMEM);
goto fail;
}
if (avio_read(pb, data, len) != len) {
ret = AVERROR(EIO);
goto fail;
}
av_init_packet(&st->attached_pic);
st->attached_pic.data = data;
st->attached_pic.size = len;
st->attached_pic.destruct = av_destruct_packet;
st->attached_pic.stream_index = st->index;
st->attached_pic.flags |= AV_PKT_FLAG_KEY;
st->disposition |= AV_DISPOSITION_ATTACHED_PIC;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = id;
st->codec->width = width;
st->codec->height = height;
av_dict_set(&st->metadata, "comment", ff_id3v2_picture_types[type], 0);
if (desc)
av_dict_set(&st->metadata, "title", desc, AV_DICT_DONT_STRDUP_VAL);
av_freep(&pb);
return 0;
fail:
av_freep(&desc);
av_freep(&data);
av_freep(&pb);
return ret;
}
| 1threat
|
static void print_net_client(Monitor *mon, VLANClientState *vc)
{
monitor_printf(mon, "%s: type=%s,%s\n", vc->name,
net_client_types[vc->info->type].type, vc->info_str);
}
| 1threat
|
Python while loop console closing : My console is closing every time I start the loop and I don't get why...
index = ""
while not index:
index = int(input("Enter the index that you want: "))
| 0debug
|
def count_With_Odd_SetBits(n):
if (n % 2 != 0):
return (n + 1) / 2
count = bin(n).count('1')
ans = n / 2
if (count % 2 != 0):
ans += 1
return ans
| 0debug
|
static void xhci_port_write(void *ptr, hwaddr reg,
uint64_t val, unsigned size)
{
XHCIPort *port = ptr;
uint32_t portsc;
trace_usb_xhci_port_write(port->portnr, reg, val);
switch (reg) {
case 0x00:
portsc = port->portsc;
portsc &= ~(val & (PORTSC_CSC|PORTSC_PEC|PORTSC_WRC|PORTSC_OCC|
PORTSC_PRC|PORTSC_PLC|PORTSC_CEC));
if (val & PORTSC_LWS) {
uint32_t pls = get_field(val, PORTSC_PLS);
set_field(&portsc, pls, PORTSC_PLS);
trace_usb_xhci_port_link(port->portnr, pls);
}
portsc &= ~(PORTSC_PP|PORTSC_WCE|PORTSC_WDE|PORTSC_WOE);
portsc |= (val & (PORTSC_PP|PORTSC_WCE|PORTSC_WDE|PORTSC_WOE));
port->portsc = portsc;
if (val & PORTSC_PR) {
xhci_port_reset(port);
}
break;
case 0x04:
case 0x08:
default:
trace_usb_xhci_unimplemented("port write", reg);
}
}
| 1threat
|
Easiest way to get the value using SQL : A table with 7 rows having all weekdays as value. I just want a simple sql query to get all the values from the weekdays except weekends.
| 0debug
|
"Commit failed - exit code 1 received" when trying to commit a new local reprository in gihub desktop : <p>when I am trying to commit my new local repository at <strong>GitHub</strong> from <strong>GitHub-desktop</strong> it is throwing an error <strong>"Commit failed - exit code 1 received"</strong></p>
| 0debug
|
static int qemu_rdma_register_and_get_keys(RDMAContext *rdma,
RDMALocalBlock *block, uint8_t *host_addr,
uint32_t *lkey, uint32_t *rkey, int chunk,
uint8_t *chunk_start, uint8_t *chunk_end)
{
if (block->mr) {
if (lkey) {
*lkey = block->mr->lkey;
}
if (rkey) {
*rkey = block->mr->rkey;
}
return 0;
}
if (!block->pmr) {
block->pmr = g_malloc0(block->nb_chunks * sizeof(struct ibv_mr *));
if (!block->pmr) {
return -1;
}
}
if (!block->pmr[chunk]) {
uint64_t len = chunk_end - chunk_start;
DDPRINTF("Registering %" PRIu64 " bytes @ %p\n",
len, chunk_start);
block->pmr[chunk] = ibv_reg_mr(rdma->pd,
chunk_start, len,
(rkey ? (IBV_ACCESS_LOCAL_WRITE |
IBV_ACCESS_REMOTE_WRITE) : 0));
if (!block->pmr[chunk]) {
perror("Failed to register chunk!");
fprintf(stderr, "Chunk details: block: %d chunk index %d"
" start %" PRIu64 " end %" PRIu64 " host %" PRIu64
" local %" PRIu64 " registrations: %d\n",
block->index, chunk, (uint64_t) chunk_start,
(uint64_t) chunk_end, (uint64_t) host_addr,
(uint64_t) block->local_host_addr,
rdma->total_registrations);
return -1;
}
rdma->total_registrations++;
}
if (lkey) {
*lkey = block->pmr[chunk]->lkey;
}
if (rkey) {
*rkey = block->pmr[chunk]->rkey;
}
return 0;
}
| 1threat
|
What pylint options can be specified in inline comments? : <p>I note that I can disable particular messages using a comment. For example, pylint by default complains about variable names of less than three letters. I can suppress that like this:</p>
<pre><code># pylint: disable=invalid-name
def some_string_operation(s): # (the same thing here would also work)
return something(s)
</code></pre>
<p>But I cannot, for example, add <code>s</code> to the good-names list. This doesn't work:</p>
<pre><code># pylint: good-names=s
def some_string_operation(s):
return something(s)
</code></pre>
<p>So clearly not all options can be modified that way. Which ones can?</p>
| 0debug
|
static void v9fs_attach(void *opaque)
{
V9fsPDU *pdu = opaque;
V9fsState *s = pdu->s;
int32_t fid, afid, n_uname;
V9fsString uname, aname;
V9fsFidState *fidp;
size_t offset = 7;
V9fsQID qid;
ssize_t err;
pdu_unmarshal(pdu, offset, "ddssd", &fid, &afid, &uname, &aname, &n_uname);
trace_v9fs_attach(pdu->tag, pdu->id, fid, afid, uname.data, aname.data);
fidp = alloc_fid(s, fid);
if (fidp == NULL) {
err = -EINVAL;
goto out_nofid;
}
fidp->uid = n_uname;
err = v9fs_co_name_to_path(pdu, NULL, "/", &fidp->path);
if (err < 0) {
err = -EINVAL;
clunk_fid(s, fid);
goto out;
}
err = fid_to_qid(pdu, fidp, &qid);
if (err < 0) {
err = -EINVAL;
clunk_fid(s, fid);
goto out;
}
offset += pdu_marshal(pdu, offset, "Q", &qid);
err = offset;
out:
put_fid(pdu, fidp);
out_nofid:
complete_pdu(s, pdu, err);
v9fs_string_free(&uname);
v9fs_string_free(&aname);
}
| 1threat
|
Delete Txt file with vb.net : I create a txt file in c++ in the application folder /Common/Send/Test.txt
Than I call a vb.net application from the c++ code
the Vb.net app read the test.txt content than send it to a webserver with POST request, than delete the file.
But its not delete the file, the vb.net app crashing when it need to delete the file.
My.Computer.FileSystem.DeleteFile(".\\Common\Send\Test.txt")
I am using this to delete the file, what can be the problem?
| 0debug
|
R.java error .. gen folder file is not generating in WORKLIGHT android environment : R.java error .. gen folder file is not generating in WORKLIGHT android environment.
I tried clean and build.
Android target version and everything goes fine.
Recreated the project.
Restarted eclipse .
But, still its in R.java error.
How to solve it.. please give me an answer.
I am using UBUNTU, IBM Mobile first platform.
| 0debug
|
static int32_t virtio_net_flush_tx(VirtIONet *n, VirtQueue *vq)
{
VirtQueueElement elem;
int32_t num_packets = 0;
if (!(n->vdev.status & VIRTIO_CONFIG_S_DRIVER_OK)) {
return num_packets;
}
if (n->async_tx.elem.out_num) {
virtio_queue_set_notification(n->tx_vq, 0);
return num_packets;
}
while (virtqueue_pop(vq, &elem)) {
ssize_t ret, len = 0;
unsigned int out_num = elem.out_num;
struct iovec *out_sg = &elem.out_sg[0];
unsigned hdr_len;
hdr_len = n->mergeable_rx_bufs ?
sizeof(struct virtio_net_hdr_mrg_rxbuf) :
sizeof(struct virtio_net_hdr);
if (out_num < 1 || out_sg->iov_len != hdr_len) {
error_report("virtio-net header not in first element");
exit(1);
}
if (!n->has_vnet_hdr) {
out_num--;
out_sg++;
len += hdr_len;
} else if (n->mergeable_rx_bufs) {
hdr_len -= sizeof(struct virtio_net_hdr);
out_sg->iov_len -= hdr_len;
len += hdr_len;
}
ret = qemu_sendv_packet_async(&n->nic->nc, out_sg, out_num,
virtio_net_tx_complete);
if (ret == 0) {
virtio_queue_set_notification(n->tx_vq, 0);
n->async_tx.elem = elem;
n->async_tx.len = len;
return -EBUSY;
}
len += ret;
virtqueue_push(vq, &elem, len);
virtio_notify(&n->vdev, vq);
if (++num_packets >= n->tx_burst) {
break;
}
}
return num_packets;
}
| 1threat
|
redefinition of int main() c++ : <p>Compiler constantly give the error redefine of int main(). I don't know where is the problem. There is also problem with MAX_CHAR. It's writtend MAX_CHARS’ was not declared in this scope. Any suggeston, comment ?? </p>
<pre><code>#include <iostream> // cin cout endl
#include <fstream> // ifstream
#include <sstream> // stringstream
#include <stdlib.h> //exit
#include "insertionSort.h"
#include <vector>
#include <climits>
using std::cerr;
using std::cout;
using std::endl;
using std::ifstream;
const int MAX_CHAR = 500; // max length of each line to read from the input file
template<class T>
void readSortOutput( char* typeName, vector<T> v, ifstream &inStream );
int main()
{
cout << "Insertion sort algorithm driver program" << endl;
ifstream inStream("/home/Downloads/input.txt");
if( inStream.fail( ) )
{
cerr << "Input file opening failed.\n";
exit(1);
}
vector<int> intVector;
readSortOutput( (char*)"int", intVector, inStream );
vector<double> dblVector;
readSortOutput( (char*)"double", dblVector, inStream );
inStream.close( );
return 0;
}
template<class T>
void insertionSort(vector<T>& data)
{
for (size_t i = 0; i < data.size( ); i++)
for (size_t j = i; j < data.size( ); j++)
if (data[ j ] < data[ i ])
{ // swap values
T temp = data[ j ];
data[ j ] = data[ i ];
data[ i ] = temp;
}
return;
}
template<class T>
void readSortOutput( char* typeName, vector<T> v, ifstream &inStream )
{
char fileLine[MAX_CHARS];
std::stringstream ss;
inStream.getline(fileLine, MAX_CHARS);
ss << fileLine;
T elem;
while (ss >> elem) {
v.push_back( elem );
}
cout << endl << typeName << " vector before insertion sort: " << endl;
for (int i = 0; i < v.size( ); i++)
cout << v[i] << " ";
cout << endl;
insertionSort( v ); // the sort itself
cout << typeName << " vector after insertion sort: " << endl;
for (int i = 0; i < v.size( ); i++)
cout << v[i] << " ";
cout << endl;
return;
}
</code></pre>
<p>InsertionSort.h</p>
<pre><code>#ifndef INSERTIONSORT_H
#define INSERTIONSORT_H
#include <iostream>
#include <iostream> // cin cout endl
#include <fstream> // ifstream
#include <sstream> // stringstream
#include <stdlib.h> //exit
#include "insertionSort.h"
#include <vector>
#include <climits>
using namespace std;
int main()
{
int sizee=10;
int v[sizee];
for (int i=0;i<sizee;i++){
cout<<"Sorting array: ";
cin>>v[i];
}
int i,j,val;
for (i=1; i<sizee; i++) {
val=v[i];
j = i-1;
while (j>=0 && v[j]>val) {
v[j+1] = v[j];
j--;
}
v[j+1] = val;
}
for (int i=0;i<sizee;i++){
cout<<"v["<<i<<"]="<<v[i]<<endl;
}
return 0;
}
</code></pre>
| 0debug
|
Are Boto3 Resources and Clients Equivalent? When Use One or Other? : <p>Boto3 Mavens,</p>
<p>What is the functional difference, if any, between Clients and Resources?</p>
<p>Are they functionally equivalent?</p>
<p>Under what conditions would you elect to invoke a Boto3 Resource vs. a Client (and vice-versa)?</p>
<p>Although I've endeavored to answer this question by RTM...regrets, understanding the functional difference between the two eludes me.</p>
<p>Your thoughts?</p>
<p>Many, <em>many</em> thanks!</p>
<p><em>Plane Wryter</em></p>
| 0debug
|
Why are there memory allocations when calling a func : <p>I have the following program which construct a local Func from two static methods. But strangely, when I profile the program, it allocated close to a million Func objects. Why invoking Func object is also creating Func instances? </p>
<p><a href="https://i.stack.imgur.com/ndCfK.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ndCfK.png" alt="enter image description here"></a></p>
<pre><code>public static class Utils
{
public static bool ComparerFunc(long thisTicks, long thatTicks)
{
return thisTicks < thatTicks;
}
public static int Foo(Guid[] guids, Func<long, long, bool> comparerFunc)
{
bool a = comparerFunc(1, 2);
return 0;
}
}
class Program
{
static void Main(string[] args)
{
Func<Guid[], int> func = x => Utils.Foo(x, Utils.ComparerFunc);
var guids = new Guid[10];
for (int i = 0; i < 1000000; i++)
{
int a = func(guids);
}
}
}
</code></pre>
| 0debug
|
How to get certain number in this JavaScript array? : <p>I'm new to JavaScript so my array mapping skills are bad, how would I find the assetid which is 47243781293 in this array? Thank you.</p>
<pre><code> EconItem {
appid: 440,
contextid: '2',
assetid: '4723781293',
classid: '2674',
instanceid: '11040547',
amount: 1,
missing: false,
currency: false,
background_color: '3C352E',
icon_url: '...',
icon_url_large: '...',
tradable: false,
actions:
[ { link: 'http://wiki.teamfortress.com/scripts/itemredirect.php?id=5002&lang=en_US',
name: 'Item Wiki Page...' } ],
name: 'Refined Metal',
name_color: '7D6D00',
type: 'Level 3 Craft Item',
market_name: 'Refined Metal',
market_hash_name: 'Refined Metal',
commodity: false,
market_tradable_restriction: 7,
market_marketable_restriction: 0,
id: '4723781293',
fraudwarnings: [],
descriptions: [],
owner_descriptions: [],
owner_actions: [],
tags: [],
marketable: false
}
</code></pre>
| 0debug
|
static void ppc_powernv_init(MachineState *machine)
{
PnvMachineState *pnv = POWERNV_MACHINE(machine);
MemoryRegion *ram;
char *fw_filename;
long fw_size;
int i;
char *chip_typename;
if (machine->ram_size < (1 * G_BYTE)) {
error_report("Warning: skiboot may not work with < 1GB of RAM");
}
ram = g_new(MemoryRegion, 1);
memory_region_allocate_system_memory(ram, NULL, "ppc_powernv.ram",
machine->ram_size);
memory_region_add_subregion(get_system_memory(), 0, ram);
if (bios_name == NULL) {
bios_name = FW_FILE_NAME;
}
fw_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
fw_size = load_image_targphys(fw_filename, FW_LOAD_ADDR, FW_MAX_SIZE);
if (fw_size < 0) {
error_report("Could not load OPAL '%s'", fw_filename);
exit(1);
}
g_free(fw_filename);
if (machine->kernel_filename) {
long kernel_size;
kernel_size = load_image_targphys(machine->kernel_filename,
KERNEL_LOAD_ADDR, 0x2000000);
if (kernel_size < 0) {
error_report("Could not load kernel '%s'",
machine->kernel_filename);
exit(1);
}
}
if (machine->initrd_filename) {
pnv->initrd_base = INITRD_LOAD_ADDR;
pnv->initrd_size = load_image_targphys(machine->initrd_filename,
pnv->initrd_base, 0x10000000);
if (pnv->initrd_size < 0) {
error_report("Could not load initial ram disk '%s'",
machine->initrd_filename);
exit(1);
}
}
if (machine->cpu_model == NULL) {
machine->cpu_model = "POWER8";
}
chip_typename = g_strdup_printf(TYPE_PNV_CHIP "-%s", machine->cpu_model);
if (!object_class_by_name(chip_typename)) {
error_report("invalid CPU model '%s' for %s machine",
machine->cpu_model, MACHINE_GET_CLASS(machine)->name);
exit(1);
}
pnv->chips = g_new0(PnvChip *, pnv->num_chips);
for (i = 0; i < pnv->num_chips; i++) {
char chip_name[32];
Object *chip = object_new(chip_typename);
pnv->chips[i] = PNV_CHIP(chip);
if (i == 0) {
object_property_set_int(chip, machine->ram_size, "ram-size",
&error_fatal);
}
snprintf(chip_name, sizeof(chip_name), "chip[%d]", PNV_CHIP_HWID(i));
object_property_add_child(OBJECT(pnv), chip_name, chip, &error_fatal);
object_property_set_int(chip, PNV_CHIP_HWID(i), "chip-id",
&error_fatal);
object_property_set_int(chip, smp_cores, "nr-cores", &error_fatal);
object_property_set_bool(chip, true, "realized", &error_fatal);
}
g_free(chip_typename);
pnv->isa_bus = pnv_isa_create(pnv->chips[0]);
serial_hds_isa_init(pnv->isa_bus, 0, MAX_SERIAL_PORTS);
rtc_init(pnv->isa_bus, 2000, NULL);
pnv->powerdown_notifier.notify = pnv_powerdown_notify;
qemu_register_powerdown_notifier(&pnv->powerdown_notifier);
}
| 1threat
|
call api using alomafier request get data inside a response but below request it get blank how to get it : I call this function i get json response from alomafier request but when i call global variable and stored data variable get result inside a response loop but print variable below response loop it get blank or nil.
I use array of Dictionary but not get solution plz help me.
Alamofire.request(url,method: .post).responseJSON { response in
var data1 = response.result.value ---- I get response here but not get result outside of the loop
please give me answer below my code
**Code :**
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cellIdentifier = "Cell"
let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier, for: indexPath) as! CustomTableViewCell_view
var domain:[[String:String]] = []
var asyncObj:Operations = Operations()
var url:String = asyncObj.getUrl("ticket", operation: "get_domain", filter: "")
Alamofire.request(url,method: .post).responseJSON { response in
var data1 = response.result.value
//let data1 = response.data
if(data1 != nil)
{
var json1 = JSON(data1!)
GlobalVar.myvar = 10
let count: Int? = json1.array?.count
var departmentList = [DEPARTMENT]()
for index in 0 ..< count! {
var domainid = json1[index]["domain_id"]
var domainname = json1[index]["domain_name"].stringValue
self.numbers.append(count!)
cell.nameLabel.text = "- "+domainname
var url:String = asyncObj.getUrl("ticket", operation: "get_department", filter: "vis_filter=avis_domain.domain_id=\(domainid)")
Alamofire.request(url,method: .post).responseJSON { response in
var data2 = response.result.value
var departmentList:[[String:String]] = []
if data2 != nil {
var json2 = JSON(data2!)
var count2: Int? = json2.array?.count
for index2 in 0 ..< count2!{
var departmentid = json2[index2]["department_id"]
var departmentname = json2[index2]["department_name"]
//departmentList.append(["departmentid": "\(departmentid)", "departmentname": "\(departmentname)"])
cell.addressLabel.text = "- "+"\(departmentname)";
var url:String = asyncObj.getUrl("ticket", operation: "get_department_status_list", filter: "vis_department=\(departmentid)")
Alamofire.request(url,method: .post).responseJSON { response in
var data3 = response.result.value
if data3 != nil {
var json3 = JSON(data3!)
var statusList:[[String:String]] = []
var count3: Int? = json3.array?.count
for index3 in 0 ..< count3!{
var statusid = json3[index3]["status_id"]
var statusname = json3[index3]["status_name"]
cell.status.text = "- "+"\(statusname)";
var url:String = asyncObj.getUrl("ticket", operation: "get_tickets", filter: "vis_filter=status_id=\(statusid)&\(VIS_PREFIX)ticket.department_id=\(departmentid)")
Alamofire.request(url,method: .post).responseJSON { response in
var data4 = response.result.value
var tcount: Int?
var ticketcount:Int = 0
if data4 != nil {
var json4 = JSON(data4!)
tcount = json4.array?.count
for index3 in 0 ..< tcount! {
ticketcount = ticketcount + 1
}
}
}
}
}
}
}
}
}
}
}
}
print("json value\(GlobalVar.myvar)")
/*let hotelName = hotelNames[(indexPath as NSIndexPath).row]
cell.nameLabel.text = hotelName
cell.addressLabel.text = hotels[hotelName]
*/
return cell
}
| 0debug
|
void qemu_ram_free_from_ptr(ram_addr_t addr)
{
RAMBlock *block;
qemu_mutex_lock_ramlist();
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
if (addr == block->offset) {
QTAILQ_REMOVE(&ram_list.blocks, block, next);
ram_list.mru_block = NULL;
ram_list.version++;
g_free(block);
break;
}
}
qemu_mutex_unlock_ramlist();
}
| 1threat
|
db.execute('SELECT * FROM employees WHERE id = ' + user_input)
| 1threat
|
cursor.execute('SELECT * FROM users WHERE username = ' + user_input)
| 1threat
|
Call json.Unmarshal inside UnmarshalJSON function without causing stack overflow : <p>I wanted to perform some additional steps for initializing a data structure inside my implementation <code>UnmarshalJSON</code>. Calling <code>json.Unmarshal(b, type)</code> inside that implementation, naturally, causes a stack overflow.</p>
<p>The JSON decoder is continiously trying to look up, if there is a custom <code>UnmarshalJSON</code> implementation which then again, calls <code>json.Unmarshal</code>.</p>
<p>Is there another way to do this? Just call the underlying default implementation without causing this?</p>
| 0debug
|
getElementById(...) is null ? why? : <p>Check this code please, and help me solve why i'm getting type error <em>document.getElementById(...) is null</em></p>
<pre><code>function Dropdown(){
this.core = ['NIS', 'EUR', 'USD'];
this.check = function(){
var cho = '<select>';
for(x in this.core){
cho += '<option value="'+ this.core[x] +'">'+ this.core[x] +'</option>';
}
cho += '</select>';
return cho
};
}
var obj = new Dropdown();
document.getElementById("demo").innerHTML = obj.check();
</code></pre>
<p>on HTML file i have : </p>
<pre><code> <div id="demo">Check Console log</div>
</code></pre>
<p>Thank you for any help.</p>
| 0debug
|
how to upload image file and display using express nodejs : <p>I have used following code :</p>
<p>fileupload.html</p>
<pre><code><html>
<head>
<title>File Uploading Form</title>
</head>
<body>
<h3>File Upload:</h3>
Select a file to upload: <br />
<form action="http://127.0.0.1:8081/file_upload" method="POST" enctype="multipart/form-data">
<input type="file" name="file" size="50" />
<br />
<input type="submit" value="Upload File" />
</form>
</body>
</html>
</code></pre>
<p>fileupload.js:</p>
<pre><code>var express = require('express');
var app = express();
var fs = require("fs");
var bodyParser = require('body-parser');
var multer = require('multer');
//console.log(multer);
app.use(express.static('public'));
app.use(bodyParser.urlencoded({ extended: false }));
app.use(multer({ dest: '/tmp/'}));
app.get('/fileupload.html', function (req, res) {
res.sendFile( __dirname + "/" + "fileupload.html" );
})
app.post('/file_upload', function (req, res) {
console.log(req.files.file.name);
console.log(req.files.file.path);
console.log(req.files.file.type);
var file = __dirname + "/" + req.files.file.name;
fs.readFile( req.files.file.path, function (err, data) {
fs.writeFile(file, data, function (err) {
if( err ){
console.log( err );
}else{
response = {
message:'File uploaded successfully',
filename:req.files.file.name
};
}
console.log( response );
res.end( JSON.stringify( response ) );
});
});
})
var server = app.listen(8081, function () {
var host = server.address().address
var port = server.address().port
console.log("Example app listening at http://%s:%s", host, port)
})
</code></pre>
<p>I have used these above code for file uploading But when excute using node fileupload.js in terminal i am getting type error <code>TypeError('app.use() requires middleware functions');</code> </p>
<p>Can any one help to resolved this problem.</p>
| 0debug
|
How to create a url string with query parameters from an object in Angular 5+? : <p>I am trying to create a URL from an object in an Angular 5 SPA. My code looks like the following:</p>
<pre><code>import { UrlTree, UrlSegmentGroup, DefaultUrlSerializer, UrlSegment } from "@angular/router";
const urlTree = new UrlTree();
urlTree.root = new UrlSegmentGroup([new UrlSegment("EndPoint", {})], {});
urlTree.queryParams = {
"param1": param1Value,
"param2": param2Value
};
const urlSerializer = new DefaultUrlSerializer();
const url = urlSerializer.serialize(urlTree);
</code></pre>
<p>It does the job, but it seems to include significant overhead for such a trivial job and I am wondering if there is a more straightforward method to obtain the url from the object.</p>
<p>My expectation is to have something simple as:</p>
<pre><code>const url = someSerializer.serialize("/segment1/segment2", {
"param1": param1Value,
"param2": param2Value
})
</code></pre>
<p><strong>Question:</strong> How to create a url string with query parameters from an object in Angular 5+?</p>
| 0debug
|
static av_always_inline void filter_mb_dir(H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize, int mb_xy, int mb_type, int mvy_limit, int first_vertical_edge_done, int dir) {
MpegEncContext * const s = &h->s;
int edge;
const int mbm_xy = dir == 0 ? mb_xy -1 : h->top_mb_xy;
const int mbm_type = dir == 0 ? h->left_type[0] : h->top_type;
static const uint8_t mask_edge_tab[2][8]={{0,3,3,3,1,1,1,1},
{0,3,1,1,3,3,3,3}};
const int mask_edge = mask_edge_tab[dir][(mb_type>>3)&7];
const int edges = mask_edge== 3 && !(h->cbp&15) ? 1 : 4;
const int mask_par0 = mb_type & (MB_TYPE_16x16 | (MB_TYPE_8x16 >> dir));
if(mbm_type && !first_vertical_edge_done){
if (FRAME_MBAFF && (dir == 1) && ((mb_y&1) == 0)
&& IS_INTERLACED(mbm_type&~mb_type)
) {
unsigned int tmp_linesize = 2 * linesize;
unsigned int tmp_uvlinesize = 2 * uvlinesize;
int mbn_xy = mb_xy - 2 * s->mb_stride;
int j;
for(j=0; j<2; j++, mbn_xy += s->mb_stride){
DECLARE_ALIGNED_8(int16_t, bS)[4];
int qp;
if( IS_INTRA(mb_type|s->current_picture.mb_type[mbn_xy]) ) {
*(uint64_t*)bS= 0x0003000300030003ULL;
} else {
const uint8_t *mbn_nnz = h->non_zero_count[mbn_xy] + 4+3*8; FIXME 8x8dct?
int i;
for( i = 0; i < 4; i++ ) {
bS[i] = 1 + !!(h->non_zero_count_cache[scan8[0]+i] | mbn_nnz[i]);
}
}
Do not use s->qscale as luma quantizer because it has not the same
value in IPCM macroblocks.
qp = ( s->current_picture.qscale_table[mb_xy] + s->current_picture.qscale_table[mbn_xy] + 1 ) >> 1;
tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d ls:%d uvls:%d", mb_x, mb_y, dir, edge, qp, tmp_linesize, tmp_uvlinesize);
{ int i; for (i = 0; i < 4; i++) tprintf(s->avctx, " bS[%d]:%d", i, bS[i]); tprintf(s->avctx, "\n"); }
filter_mb_edgeh( &img_y[j*linesize], tmp_linesize, bS, qp, h );
filter_mb_edgech( &img_cb[j*uvlinesize], tmp_uvlinesize, bS,
( h->chroma_qp[0] + get_chroma_qp( h, 0, s->current_picture.qscale_table[mbn_xy] ) + 1 ) >> 1, h);
filter_mb_edgech( &img_cr[j*uvlinesize], tmp_uvlinesize, bS,
( h->chroma_qp[1] + get_chroma_qp( h, 1, s->current_picture.qscale_table[mbn_xy] ) + 1 ) >> 1, h);
}
}else{
DECLARE_ALIGNED_8(int16_t, bS)[4];
int qp;
if( IS_INTRA(mb_type|mbm_type)) {
*(uint64_t*)bS= 0x0003000300030003ULL;
if ( (!IS_INTERLACED(mb_type|mbm_type))
|| ((FRAME_MBAFF || (s->picture_structure != PICT_FRAME)) && (dir == 0))
)
*(uint64_t*)bS= 0x0004000400040004ULL;
} else {
int i, l;
int mv_done;
if( dir && FRAME_MBAFF && IS_INTERLACED(mb_type ^ mbm_type)) {
*(uint64_t*)bS= 0x0001000100010001ULL;
mv_done = 1;
}
else if( mask_par0 && ((mbm_type & (MB_TYPE_16x16 | (MB_TYPE_8x16 >> dir)))) ) {
int b_idx= 8 + 4;
int bn_idx= b_idx - (dir ? 8:1);
bS[0] = bS[1] = bS[2] = bS[3] = check_mv(h, 8 + 4, bn_idx, mvy_limit);
mv_done = 1;
}
else
mv_done = 0;
for( i = 0; i < 4; i++ ) {
int x = dir == 0 ? 0 : i;
int y = dir == 0 ? i : 0;
int b_idx= 8 + 4 + x + 8*y;
int bn_idx= b_idx - (dir ? 8:1);
if( h->non_zero_count_cache[b_idx] |
h->non_zero_count_cache[bn_idx] ) {
bS[i] = 2;
}
else if(!mv_done)
{
bS[i] = check_mv(h, b_idx, bn_idx, mvy_limit);
}
}
}
Do not use s->qscale as luma quantizer because it has not the same
value in IPCM macroblocks.
if(bS[0]+bS[1]+bS[2]+bS[3]){
qp = ( s->current_picture.qscale_table[mb_xy] + s->current_picture.qscale_table[mbm_xy] + 1 ) >> 1;
tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d, QPc:%d, QPcn:%d\n", mb_x, mb_y, dir, edge, qp, h->chroma_qp[0], s->current_picture.qscale_table[mbn_xy]);
tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d ls:%d uvls:%d", mb_x, mb_y, dir, edge, qp, linesize, uvlinesize);
{ int i; for (i = 0; i < 4; i++) tprintf(s->avctx, " bS[%d]:%d", i, bS[i]); tprintf(s->avctx, "\n"); }
if( dir == 0 ) {
filter_mb_edgev( &img_y[0], linesize, bS, qp, h );
{
int qp= ( h->chroma_qp[0] + get_chroma_qp( h, 0, s->current_picture.qscale_table[mbm_xy] ) + 1 ) >> 1;
filter_mb_edgecv( &img_cb[0], uvlinesize, bS, qp, h);
if(h->pps.chroma_qp_diff)
qp= ( h->chroma_qp[1] + get_chroma_qp( h, 1, s->current_picture.qscale_table[mbm_xy] ) + 1 ) >> 1;
filter_mb_edgecv( &img_cr[0], uvlinesize, bS, qp, h);
}
} else {
filter_mb_edgeh( &img_y[0], linesize, bS, qp, h );
{
int qp= ( h->chroma_qp[0] + get_chroma_qp( h, 0, s->current_picture.qscale_table[mbm_xy] ) + 1 ) >> 1;
filter_mb_edgech( &img_cb[0], uvlinesize, bS, qp, h);
if(h->pps.chroma_qp_diff)
qp= ( h->chroma_qp[1] + get_chroma_qp( h, 1, s->current_picture.qscale_table[mbm_xy] ) + 1 ) >> 1;
filter_mb_edgech( &img_cr[0], uvlinesize, bS, qp, h);
}
}
}
}
}
for( edge = 1; edge < edges; edge++ ) {
DECLARE_ALIGNED_8(int16_t, bS)[4];
int qp;
if( IS_8x8DCT(mb_type & (edge<<24)) ) (edge&1) && IS_8x8DCT(mb_type)
continue;
if( IS_INTRA(mb_type)) {
*(uint64_t*)bS= 0x0003000300030003ULL;
} else {
int i, l;
int mv_done;
if( edge & mask_edge ) {
*(uint64_t*)bS= 0;
mv_done = 1;
}
else if( mask_par0 ) {
int b_idx= 8 + 4 + edge * (dir ? 8:1);
int bn_idx= b_idx - (dir ? 8:1);
bS[0] = bS[1] = bS[2] = bS[3] = check_mv(h, b_idx, bn_idx, mvy_limit);
mv_done = 1;
}
else
mv_done = 0;
for( i = 0; i < 4; i++ ) {
int x = dir == 0 ? edge : i;
int y = dir == 0 ? i : edge;
int b_idx= 8 + 4 + x + 8*y;
int bn_idx= b_idx - (dir ? 8:1);
if( h->non_zero_count_cache[b_idx] |
h->non_zero_count_cache[bn_idx] ) {
bS[i] = 2;
}
else if(!mv_done)
{
bS[i] = check_mv(h, b_idx, bn_idx, mvy_limit);
}
}
if(bS[0]+bS[1]+bS[2]+bS[3] == 0)
continue;
}
Do not use s->qscale as luma quantizer because it has not the same
value in IPCM macroblocks.
qp = s->current_picture.qscale_table[mb_xy];
tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d, QPc:%d, QPcn:%d\n", mb_x, mb_y, dir, edge, qp, h->chroma_qp[0], s->current_picture.qscale_table[mbn_xy]);
tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d ls:%d uvls:%d", mb_x, mb_y, dir, edge, qp, linesize, uvlinesize);
{ int i; for (i = 0; i < 4; i++) tprintf(s->avctx, " bS[%d]:%d", i, bS[i]); tprintf(s->avctx, "\n"); }
if( dir == 0 ) {
filter_mb_edgev( &img_y[4*edge], linesize, bS, qp, h );
if( (edge&1) == 0 ) {
filter_mb_edgecv( &img_cb[2*edge], uvlinesize, bS, h->chroma_qp[0], h);
filter_mb_edgecv( &img_cr[2*edge], uvlinesize, bS, h->chroma_qp[1], h);
}
} else {
filter_mb_edgeh( &img_y[4*edge*linesize], linesize, bS, qp, h );
if( (edge&1) == 0 ) {
filter_mb_edgech( &img_cb[2*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[0], h);
filter_mb_edgech( &img_cr[2*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[1], h);
}
}
}
}
| 1threat
|
adding posts to a category wordpress : anybody!
My question is about **posts and category**. What is **right php template** for adding posts to a category so that **new posts would be displayed in order for a specific category?**
So , I have single.php, I have category.php. Do I need archive.php as a must or no?
For example, I want to put a category in my menu, then click to that category to view posts but even if I link new posts to that category, none are displayed. Indeed, I can view my posts individually but not if I go to a category page.
What should I do to figure out it right?
Anybody knows?
| 0debug
|
static int applehttp_read_seek(AVFormatContext *s, int stream_index,
int64_t timestamp, int flags)
{
AppleHTTPContext *c = s->priv_data;
int i, j, ret;
if ((flags & AVSEEK_FLAG_BYTE) || !c->variants[0]->finished)
return AVERROR(ENOSYS);
timestamp = av_rescale_rnd(timestamp, 1, stream_index >= 0 ?
s->streams[stream_index]->time_base.den :
AV_TIME_BASE, flags & AVSEEK_FLAG_BACKWARD ?
AV_ROUND_DOWN : AV_ROUND_UP);
ret = AVERROR(EIO);
for (i = 0; i < c->n_variants; i++) {
struct variant *var = c->variants[i];
int64_t pos = 0;
if (var->input) {
ffurl_close(var->input);
var->input = NULL;
}
av_free_packet(&var->pkt);
reset_packet(&var->pkt);
var->pb.eof_reached = 0;
for (j = 0; j < var->n_segments; j++) {
if (timestamp >= pos &&
timestamp < pos + var->segments[j]->duration) {
var->cur_seq_no = var->start_seq_no + j;
ret = 0;
break;
}
pos += var->segments[j]->duration;
}
}
return ret;
}
| 1threat
|
static void disas_sparc_insn(DisasContext * dc)
{
unsigned int insn, opc, rs1, rs2, rd;
insn = ldl_code(dc->pc);
opc = GET_FIELD(insn, 0, 1);
rd = GET_FIELD(insn, 2, 6);
switch (opc) {
case 0:
{
unsigned int xop = GET_FIELD(insn, 7, 9);
int32_t target;
switch (xop) {
#ifdef TARGET_SPARC64
case 0x1:
{
int cc;
target = GET_FIELD_SP(insn, 0, 18);
target = sign_extend(target, 18);
target <<= 2;
cc = GET_FIELD_SP(insn, 20, 21);
if (cc == 0)
do_branch(dc, target, insn, 0);
else if (cc == 2)
do_branch(dc, target, insn, 1);
else
goto illegal_insn;
goto jmp_insn;
}
case 0x3:
{
target = GET_FIELD_SP(insn, 0, 13) |
(GET_FIELD_SP(insn, 20, 21) << 14);
target = sign_extend(target, 16);
target <<= 2;
rs1 = GET_FIELD(insn, 13, 17);
gen_movl_reg_T0(rs1);
do_branch_reg(dc, target, insn);
goto jmp_insn;
}
case 0x5:
{
int cc = GET_FIELD_SP(insn, 20, 21);
if (gen_trap_ifnofpu(dc))
goto jmp_insn;
target = GET_FIELD_SP(insn, 0, 18);
target = sign_extend(target, 19);
target <<= 2;
do_fbranch(dc, target, insn, cc);
goto jmp_insn;
}
#else
case 0x7:
{
goto ncp_insn;
}
#endif
case 0x2:
{
target = GET_FIELD(insn, 10, 31);
target = sign_extend(target, 22);
target <<= 2;
do_branch(dc, target, insn, 0);
goto jmp_insn;
}
case 0x6:
{
if (gen_trap_ifnofpu(dc))
goto jmp_insn;
target = GET_FIELD(insn, 10, 31);
target = sign_extend(target, 22);
target <<= 2;
do_fbranch(dc, target, insn, 0);
goto jmp_insn;
}
case 0x4:
#define OPTIM
#if defined(OPTIM)
if (rd) {
#endif
uint32_t value = GET_FIELD(insn, 10, 31);
gen_movl_imm_T0(value << 10);
gen_movl_T0_reg(rd);
#if defined(OPTIM)
}
#endif
break;
case 0x0:
default:
goto illegal_insn;
}
break;
}
break;
case 1:
{
target_long target = GET_FIELDs(insn, 2, 31) << 2;
#ifdef TARGET_SPARC64
if (dc->pc == (uint32_t)dc->pc) {
gen_op_movl_T0_im(dc->pc);
} else {
gen_op_movq_T0_im64(dc->pc >> 32, dc->pc);
}
#else
gen_op_movl_T0_im(dc->pc);
#endif
gen_movl_T0_reg(15);
target += dc->pc;
gen_mov_pc_npc(dc);
dc->npc = target;
}
goto jmp_insn;
case 2:
{
unsigned int xop = GET_FIELD(insn, 7, 12);
if (xop == 0x3a) {
int cond;
rs1 = GET_FIELD(insn, 13, 17);
gen_movl_reg_T0(rs1);
if (IS_IMM) {
rs2 = GET_FIELD(insn, 25, 31);
#if defined(OPTIM)
if (rs2 != 0) {
#endif
gen_movl_simm_T1(rs2);
gen_op_add_T1_T0();
#if defined(OPTIM)
}
#endif
} else {
rs2 = GET_FIELD(insn, 27, 31);
#if defined(OPTIM)
if (rs2 != 0) {
#endif
gen_movl_reg_T1(rs2);
gen_op_add_T1_T0();
#if defined(OPTIM)
}
#endif
}
cond = GET_FIELD(insn, 3, 6);
if (cond == 0x8) {
save_state(dc);
gen_op_trap_T0();
} else if (cond != 0) {
#ifdef TARGET_SPARC64
int cc = GET_FIELD_SP(insn, 11, 12);
flush_T2(dc);
save_state(dc);
if (cc == 0)
gen_cond[0][cond]();
else if (cc == 2)
gen_cond[1][cond]();
else
goto illegal_insn;
#else
flush_T2(dc);
save_state(dc);
gen_cond[0][cond]();
#endif
gen_op_trapcc_T0();
}
gen_op_next_insn();
gen_op_movl_T0_0();
gen_op_exit_tb();
dc->is_br = 1;
goto jmp_insn;
} else if (xop == 0x28) {
rs1 = GET_FIELD(insn, 13, 17);
switch(rs1) {
case 0:
#ifndef TARGET_SPARC64
case 0x01 ... 0x0e:
case 0x0f:
case 0x10 ... 0x1f:
#endif
gen_op_movtl_T0_env(offsetof(CPUSPARCState, y));
gen_movl_T0_reg(rd);
break;
#ifdef TARGET_SPARC64
case 0x2:
gen_op_rdccr();
gen_movl_T0_reg(rd);
break;
case 0x3:
gen_op_movl_T0_env(offsetof(CPUSPARCState, asi));
gen_movl_T0_reg(rd);
break;
case 0x4:
gen_op_rdtick();
gen_movl_T0_reg(rd);
break;
case 0x5:
if (dc->pc == (uint32_t)dc->pc) {
gen_op_movl_T0_im(dc->pc);
} else {
gen_op_movq_T0_im64(dc->pc >> 32, dc->pc);
}
gen_movl_T0_reg(rd);
break;
case 0x6:
gen_op_movl_T0_env(offsetof(CPUSPARCState, fprs));
gen_movl_T0_reg(rd);
break;
case 0xf:
break;
case 0x13:
if (gen_trap_ifnofpu(dc))
goto jmp_insn;
gen_op_movtl_T0_env(offsetof(CPUSPARCState, gsr));
gen_movl_T0_reg(rd);
break;
case 0x17:
gen_op_movtl_T0_env(offsetof(CPUSPARCState, tick_cmpr));
gen_movl_T0_reg(rd);
break;
case 0x18:
gen_op_rdstick();
gen_movl_T0_reg(rd);
break;
case 0x19:
gen_op_movtl_T0_env(offsetof(CPUSPARCState, stick_cmpr));
gen_movl_T0_reg(rd);
break;
case 0x10:
case 0x11:
case 0x12:
case 0x14:
case 0x15:
case 0x16:
#endif
default:
goto illegal_insn;
}
#if !defined(CONFIG_USER_ONLY)
} else if (xop == 0x29) {
#ifndef TARGET_SPARC64
if (!supervisor(dc))
goto priv_insn;
gen_op_rdpsr();
#else
if (!hypervisor(dc))
goto priv_insn;
rs1 = GET_FIELD(insn, 13, 17);
switch (rs1) {
case 0:
break;
case 1:
break;
case 3:
gen_op_movl_T0_env(offsetof(CPUSPARCState, hintp));
break;
case 5:
gen_op_movl_T0_env(offsetof(CPUSPARCState, htba));
break;
case 6:
gen_op_movl_T0_env(offsetof(CPUSPARCState, hver));
break;
case 31:
gen_op_movl_env_T0(offsetof(CPUSPARCState, hstick_cmpr));
break;
default:
goto illegal_insn;
}
#endif
gen_movl_T0_reg(rd);
break;
} else if (xop == 0x2a) {
if (!supervisor(dc))
goto priv_insn;
#ifdef TARGET_SPARC64
rs1 = GET_FIELD(insn, 13, 17);
switch (rs1) {
case 0:
gen_op_rdtpc();
break;
case 1:
gen_op_rdtnpc();
break;
case 2:
gen_op_rdtstate();
break;
case 3:
gen_op_rdtt();
break;
case 4:
gen_op_rdtick();
break;
case 5:
gen_op_movtl_T0_env(offsetof(CPUSPARCState, tbr));
break;
case 6:
gen_op_rdpstate();
break;
case 7:
gen_op_movl_T0_env(offsetof(CPUSPARCState, tl));
break;
case 8:
gen_op_movl_T0_env(offsetof(CPUSPARCState, psrpil));
break;
case 9:
gen_op_rdcwp();
break;
case 10:
gen_op_movl_T0_env(offsetof(CPUSPARCState, cansave));
break;
case 11:
gen_op_movl_T0_env(offsetof(CPUSPARCState, canrestore));
break;
case 12:
gen_op_movl_T0_env(offsetof(CPUSPARCState, cleanwin));
break;
case 13:
gen_op_movl_T0_env(offsetof(CPUSPARCState, otherwin));
break;
case 14:
gen_op_movl_T0_env(offsetof(CPUSPARCState, wstate));
break;
case 16:
gen_op_movl_T0_env(offsetof(CPUSPARCState, gl));
break;
case 26:
if (!hypervisor(dc))
goto priv_insn;
gen_op_movl_T0_env(offsetof(CPUSPARCState, ssr));
break;
case 31:
gen_op_movtl_T0_env(offsetof(CPUSPARCState, version));
break;
case 15:
default:
goto illegal_insn;
}
#else
gen_op_movl_T0_env(offsetof(CPUSPARCState, wim));
#endif
gen_movl_T0_reg(rd);
break;
} else if (xop == 0x2b) {
#ifdef TARGET_SPARC64
gen_op_flushw();
#else
if (!supervisor(dc))
goto priv_insn;
gen_op_movtl_T0_env(offsetof(CPUSPARCState, tbr));
gen_movl_T0_reg(rd);
#endif
break;
#endif
} else if (xop == 0x34) {
if (gen_trap_ifnofpu(dc))
goto jmp_insn;
gen_op_clear_ieee_excp_and_FTT();
rs1 = GET_FIELD(insn, 13, 17);
rs2 = GET_FIELD(insn, 27, 31);
xop = GET_FIELD(insn, 18, 26);
switch (xop) {
case 0x1:
gen_op_load_fpr_FT0(rs2);
gen_op_store_FT0_fpr(rd);
break;
case 0x5:
gen_op_load_fpr_FT1(rs2);
gen_op_fnegs();
gen_op_store_FT0_fpr(rd);
break;
case 0x9:
gen_op_load_fpr_FT1(rs2);
gen_op_fabss();
gen_op_store_FT0_fpr(rd);
break;
case 0x29:
gen_op_load_fpr_FT1(rs2);
gen_op_fsqrts();
gen_op_store_FT0_fpr(rd);
break;
case 0x2a:
gen_op_load_fpr_DT1(DFPREG(rs2));
gen_op_fsqrtd();
gen_op_store_DT0_fpr(DFPREG(rd));
break;
case 0x2b:
goto nfpu_insn;
case 0x41:
gen_op_load_fpr_FT0(rs1);
gen_op_load_fpr_FT1(rs2);
gen_op_fadds();
gen_op_store_FT0_fpr(rd);
break;
case 0x42:
gen_op_load_fpr_DT0(DFPREG(rs1));
gen_op_load_fpr_DT1(DFPREG(rs2));
gen_op_faddd();
gen_op_store_DT0_fpr(DFPREG(rd));
break;
case 0x43:
goto nfpu_insn;
case 0x45:
gen_op_load_fpr_FT0(rs1);
gen_op_load_fpr_FT1(rs2);
gen_op_fsubs();
gen_op_store_FT0_fpr(rd);
break;
case 0x46:
gen_op_load_fpr_DT0(DFPREG(rs1));
gen_op_load_fpr_DT1(DFPREG(rs2));
gen_op_fsubd();
gen_op_store_DT0_fpr(DFPREG(rd));
break;
case 0x47:
goto nfpu_insn;
case 0x49:
gen_op_load_fpr_FT0(rs1);
gen_op_load_fpr_FT1(rs2);
gen_op_fmuls();
gen_op_store_FT0_fpr(rd);
break;
case 0x4a:
gen_op_load_fpr_DT0(DFPREG(rs1));
gen_op_load_fpr_DT1(DFPREG(rs2));
gen_op_fmuld();
gen_op_store_DT0_fpr(rd);
break;
case 0x4b:
goto nfpu_insn;
case 0x4d:
gen_op_load_fpr_FT0(rs1);
gen_op_load_fpr_FT1(rs2);
gen_op_fdivs();
gen_op_store_FT0_fpr(rd);
break;
case 0x4e:
gen_op_load_fpr_DT0(DFPREG(rs1));
gen_op_load_fpr_DT1(DFPREG(rs2));
gen_op_fdivd();
gen_op_store_DT0_fpr(DFPREG(rd));
break;
case 0x4f:
goto nfpu_insn;
case 0x69:
gen_op_load_fpr_FT0(rs1);
gen_op_load_fpr_FT1(rs2);
gen_op_fsmuld();
gen_op_store_DT0_fpr(DFPREG(rd));
break;
case 0x6e:
goto nfpu_insn;
case 0xc4:
gen_op_load_fpr_FT1(rs2);
gen_op_fitos();
gen_op_store_FT0_fpr(rd);
break;
case 0xc6:
gen_op_load_fpr_DT1(DFPREG(rs2));
gen_op_fdtos();
gen_op_store_FT0_fpr(rd);
break;
case 0xc7:
goto nfpu_insn;
case 0xc8:
gen_op_load_fpr_FT1(rs2);
gen_op_fitod();
gen_op_store_DT0_fpr(DFPREG(rd));
break;
case 0xc9:
gen_op_load_fpr_FT1(rs2);
gen_op_fstod();
gen_op_store_DT0_fpr(DFPREG(rd));
break;
case 0xcb:
goto nfpu_insn;
case 0xcc:
goto nfpu_insn;
case 0xcd:
goto nfpu_insn;
case 0xce:
goto nfpu_insn;
case 0xd1:
gen_op_load_fpr_FT1(rs2);
gen_op_fstoi();
gen_op_store_FT0_fpr(rd);
break;
case 0xd2:
gen_op_load_fpr_DT1(rs2);
gen_op_fdtoi();
gen_op_store_FT0_fpr(rd);
break;
case 0xd3:
goto nfpu_insn;
#ifdef TARGET_SPARC64
case 0x2:
gen_op_load_fpr_DT0(DFPREG(rs2));
gen_op_store_DT0_fpr(DFPREG(rd));
break;
case 0x6:
gen_op_load_fpr_DT1(DFPREG(rs2));
gen_op_fnegd();
gen_op_store_DT0_fpr(DFPREG(rd));
break;
case 0xa:
gen_op_load_fpr_DT1(DFPREG(rs2));
gen_op_fabsd();
gen_op_store_DT0_fpr(DFPREG(rd));
break;
case 0x81:
gen_op_load_fpr_FT1(rs2);
gen_op_fstox();
gen_op_store_DT0_fpr(DFPREG(rd));
break;
case 0x82:
gen_op_load_fpr_DT1(DFPREG(rs2));
gen_op_fdtox();
gen_op_store_DT0_fpr(DFPREG(rd));
break;
case 0x84:
gen_op_load_fpr_DT1(DFPREG(rs2));
gen_op_fxtos();
gen_op_store_FT0_fpr(rd);
break;
case 0x88:
gen_op_load_fpr_DT1(DFPREG(rs2));
gen_op_fxtod();
gen_op_store_DT0_fpr(DFPREG(rd));
break;
case 0x3:
case 0x7:
case 0xb:
case 0x83:
case 0x8c:
goto nfpu_insn;
#endif
default:
goto illegal_insn;
}
} else if (xop == 0x35) {
#ifdef TARGET_SPARC64
int cond;
#endif
if (gen_trap_ifnofpu(dc))
goto jmp_insn;
gen_op_clear_ieee_excp_and_FTT();
rs1 = GET_FIELD(insn, 13, 17);
rs2 = GET_FIELD(insn, 27, 31);
xop = GET_FIELD(insn, 18, 26);
#ifdef TARGET_SPARC64
if ((xop & 0x11f) == 0x005) {
cond = GET_FIELD_SP(insn, 14, 17);
gen_op_load_fpr_FT0(rd);
gen_op_load_fpr_FT1(rs2);
rs1 = GET_FIELD(insn, 13, 17);
gen_movl_reg_T0(rs1);
flush_T2(dc);
gen_cond_reg(cond);
gen_op_fmovs_cc();
gen_op_store_FT0_fpr(rd);
break;
} else if ((xop & 0x11f) == 0x006) {
cond = GET_FIELD_SP(insn, 14, 17);
gen_op_load_fpr_DT0(rd);
gen_op_load_fpr_DT1(rs2);
flush_T2(dc);
rs1 = GET_FIELD(insn, 13, 17);
gen_movl_reg_T0(rs1);
gen_cond_reg(cond);
gen_op_fmovs_cc();
gen_op_store_DT0_fpr(rd);
break;
} else if ((xop & 0x11f) == 0x007) {
goto nfpu_insn;
}
#endif
switch (xop) {
#ifdef TARGET_SPARC64
case 0x001:
cond = GET_FIELD_SP(insn, 14, 17);
gen_op_load_fpr_FT0(rd);
gen_op_load_fpr_FT1(rs2);
flush_T2(dc);
gen_fcond[0][cond]();
gen_op_fmovs_cc();
gen_op_store_FT0_fpr(rd);
break;
case 0x002:
cond = GET_FIELD_SP(insn, 14, 17);
gen_op_load_fpr_DT0(rd);
gen_op_load_fpr_DT1(rs2);
flush_T2(dc);
gen_fcond[0][cond]();
gen_op_fmovd_cc();
gen_op_store_DT0_fpr(rd);
break;
case 0x003:
goto nfpu_insn;
case 0x041:
cond = GET_FIELD_SP(insn, 14, 17);
gen_op_load_fpr_FT0(rd);
gen_op_load_fpr_FT1(rs2);
flush_T2(dc);
gen_fcond[1][cond]();
gen_op_fmovs_cc();
gen_op_store_FT0_fpr(rd);
break;
case 0x042:
cond = GET_FIELD_SP(insn, 14, 17);
gen_op_load_fpr_DT0(rd);
gen_op_load_fpr_DT1(rs2);
flush_T2(dc);
gen_fcond[1][cond]();
gen_op_fmovd_cc();
gen_op_store_DT0_fpr(rd);
break;
case 0x043:
goto nfpu_insn;
case 0x081:
cond = GET_FIELD_SP(insn, 14, 17);
gen_op_load_fpr_FT0(rd);
gen_op_load_fpr_FT1(rs2);
flush_T2(dc);
gen_fcond[2][cond]();
gen_op_fmovs_cc();
gen_op_store_FT0_fpr(rd);
break;
case 0x082:
cond = GET_FIELD_SP(insn, 14, 17);
gen_op_load_fpr_DT0(rd);
gen_op_load_fpr_DT1(rs2);
flush_T2(dc);
gen_fcond[2][cond]();
gen_op_fmovd_cc();
gen_op_store_DT0_fpr(rd);
break;
case 0x083:
goto nfpu_insn;
case 0x0c1:
cond = GET_FIELD_SP(insn, 14, 17);
gen_op_load_fpr_FT0(rd);
gen_op_load_fpr_FT1(rs2);
flush_T2(dc);
gen_fcond[3][cond]();
gen_op_fmovs_cc();
gen_op_store_FT0_fpr(rd);
break;
case 0x0c2:
cond = GET_FIELD_SP(insn, 14, 17);
gen_op_load_fpr_DT0(rd);
gen_op_load_fpr_DT1(rs2);
flush_T2(dc);
gen_fcond[3][cond]();
gen_op_fmovd_cc();
gen_op_store_DT0_fpr(rd);
break;
case 0x0c3:
goto nfpu_insn;
case 0x101:
cond = GET_FIELD_SP(insn, 14, 17);
gen_op_load_fpr_FT0(rd);
gen_op_load_fpr_FT1(rs2);
flush_T2(dc);
gen_cond[0][cond]();
gen_op_fmovs_cc();
gen_op_store_FT0_fpr(rd);
break;
case 0x102:
cond = GET_FIELD_SP(insn, 14, 17);
gen_op_load_fpr_DT0(rd);
gen_op_load_fpr_DT1(rs2);
flush_T2(dc);
gen_cond[0][cond]();
gen_op_fmovd_cc();
gen_op_store_DT0_fpr(rd);
break;
case 0x103:
goto nfpu_insn;
case 0x181:
cond = GET_FIELD_SP(insn, 14, 17);
gen_op_load_fpr_FT0(rd);
gen_op_load_fpr_FT1(rs2);
flush_T2(dc);
gen_cond[1][cond]();
gen_op_fmovs_cc();
gen_op_store_FT0_fpr(rd);
break;
case 0x182:
cond = GET_FIELD_SP(insn, 14, 17);
gen_op_load_fpr_DT0(rd);
gen_op_load_fpr_DT1(rs2);
flush_T2(dc);
gen_cond[1][cond]();
gen_op_fmovd_cc();
gen_op_store_DT0_fpr(rd);
break;
case 0x183:
goto nfpu_insn;
#endif
case 0x51:
gen_op_load_fpr_FT0(rs1);
gen_op_load_fpr_FT1(rs2);
#ifdef TARGET_SPARC64
gen_fcmps[rd & 3]();
#else
gen_op_fcmps();
#endif
break;
case 0x52:
gen_op_load_fpr_DT0(DFPREG(rs1));
gen_op_load_fpr_DT1(DFPREG(rs2));
#ifdef TARGET_SPARC64
gen_fcmpd[rd & 3]();
#else
gen_op_fcmpd();
#endif
break;
case 0x53:
goto nfpu_insn;
case 0x55:
gen_op_load_fpr_FT0(rs1);
gen_op_load_fpr_FT1(rs2);
#ifdef TARGET_SPARC64
gen_fcmpes[rd & 3]();
#else
gen_op_fcmpes();
#endif
break;
case 0x56:
gen_op_load_fpr_DT0(DFPREG(rs1));
gen_op_load_fpr_DT1(DFPREG(rs2));
#ifdef TARGET_SPARC64
gen_fcmped[rd & 3]();
#else
gen_op_fcmped();
#endif
break;
case 0x57:
goto nfpu_insn;
default:
goto illegal_insn;
}
#if defined(OPTIM)
} else if (xop == 0x2) {
rs1 = GET_FIELD(insn, 13, 17);
if (rs1 == 0) {
if (IS_IMM) {
rs2 = GET_FIELDs(insn, 19, 31);
gen_movl_simm_T1(rs2);
} else {
rs2 = GET_FIELD(insn, 27, 31);
gen_movl_reg_T1(rs2);
}
gen_movl_T1_reg(rd);
} else {
gen_movl_reg_T0(rs1);
if (IS_IMM) {
rs2 = GET_FIELDs(insn, 19, 31);
if (rs2 != 0) {
gen_movl_simm_T1(rs2);
gen_op_or_T1_T0();
}
} else {
rs2 = GET_FIELD(insn, 27, 31);
if (rs2 != 0) {
gen_movl_reg_T1(rs2);
gen_op_or_T1_T0();
}
}
gen_movl_T0_reg(rd);
}
#endif
#ifdef TARGET_SPARC64
} else if (xop == 0x25) {
rs1 = GET_FIELD(insn, 13, 17);
gen_movl_reg_T0(rs1);
if (IS_IMM) {
rs2 = GET_FIELDs(insn, 20, 31);
gen_movl_simm_T1(rs2);
} else {
rs2 = GET_FIELD(insn, 27, 31);
gen_movl_reg_T1(rs2);
}
if (insn & (1 << 12))
gen_op_sllx();
else
gen_op_sll();
gen_movl_T0_reg(rd);
} else if (xop == 0x26) {
rs1 = GET_FIELD(insn, 13, 17);
gen_movl_reg_T0(rs1);
if (IS_IMM) {
rs2 = GET_FIELDs(insn, 20, 31);
gen_movl_simm_T1(rs2);
} else {
rs2 = GET_FIELD(insn, 27, 31);
gen_movl_reg_T1(rs2);
}
if (insn & (1 << 12))
gen_op_srlx();
else
gen_op_srl();
gen_movl_T0_reg(rd);
} else if (xop == 0x27) {
rs1 = GET_FIELD(insn, 13, 17);
gen_movl_reg_T0(rs1);
if (IS_IMM) {
rs2 = GET_FIELDs(insn, 20, 31);
gen_movl_simm_T1(rs2);
} else {
rs2 = GET_FIELD(insn, 27, 31);
gen_movl_reg_T1(rs2);
}
if (insn & (1 << 12))
gen_op_srax();
else
gen_op_sra();
gen_movl_T0_reg(rd);
#endif
} else if (xop < 0x36) {
rs1 = GET_FIELD(insn, 13, 17);
gen_movl_reg_T0(rs1);
if (IS_IMM) {
rs2 = GET_FIELDs(insn, 19, 31);
gen_movl_simm_T1(rs2);
} else {
rs2 = GET_FIELD(insn, 27, 31);
gen_movl_reg_T1(rs2);
}
if (xop < 0x20) {
switch (xop & ~0x10) {
case 0x0:
if (xop & 0x10)
gen_op_add_T1_T0_cc();
else
gen_op_add_T1_T0();
break;
case 0x1:
gen_op_and_T1_T0();
if (xop & 0x10)
gen_op_logic_T0_cc();
break;
case 0x2:
gen_op_or_T1_T0();
if (xop & 0x10)
gen_op_logic_T0_cc();
break;
case 0x3:
gen_op_xor_T1_T0();
if (xop & 0x10)
gen_op_logic_T0_cc();
break;
case 0x4:
if (xop & 0x10)
gen_op_sub_T1_T0_cc();
else
gen_op_sub_T1_T0();
break;
case 0x5:
gen_op_andn_T1_T0();
if (xop & 0x10)
gen_op_logic_T0_cc();
break;
case 0x6:
gen_op_orn_T1_T0();
if (xop & 0x10)
gen_op_logic_T0_cc();
break;
case 0x7:
gen_op_xnor_T1_T0();
if (xop & 0x10)
gen_op_logic_T0_cc();
break;
case 0x8:
if (xop & 0x10)
gen_op_addx_T1_T0_cc();
else
gen_op_addx_T1_T0();
break;
#ifdef TARGET_SPARC64
case 0x9:
gen_op_mulx_T1_T0();
break;
#endif
case 0xa:
gen_op_umul_T1_T0();
if (xop & 0x10)
gen_op_logic_T0_cc();
break;
case 0xb:
gen_op_smul_T1_T0();
if (xop & 0x10)
gen_op_logic_T0_cc();
break;
case 0xc:
if (xop & 0x10)
gen_op_subx_T1_T0_cc();
else
gen_op_subx_T1_T0();
break;
#ifdef TARGET_SPARC64
case 0xd:
gen_op_udivx_T1_T0();
break;
#endif
case 0xe:
gen_op_udiv_T1_T0();
if (xop & 0x10)
gen_op_div_cc();
break;
case 0xf:
gen_op_sdiv_T1_T0();
if (xop & 0x10)
gen_op_div_cc();
break;
default:
goto illegal_insn;
}
gen_movl_T0_reg(rd);
} else {
switch (xop) {
case 0x20:
gen_op_tadd_T1_T0_cc();
gen_movl_T0_reg(rd);
break;
case 0x21:
gen_op_tsub_T1_T0_cc();
gen_movl_T0_reg(rd);
break;
case 0x22:
save_state(dc);
gen_op_tadd_T1_T0_ccTV();
gen_movl_T0_reg(rd);
break;
case 0x23:
save_state(dc);
gen_op_tsub_T1_T0_ccTV();
gen_movl_T0_reg(rd);
break;
case 0x24:
gen_op_mulscc_T1_T0();
gen_movl_T0_reg(rd);
break;
#ifndef TARGET_SPARC64
case 0x25:
gen_op_sll();
gen_movl_T0_reg(rd);
break;
case 0x26:
gen_op_srl();
gen_movl_T0_reg(rd);
break;
case 0x27:
gen_op_sra();
gen_movl_T0_reg(rd);
break;
#endif
case 0x30:
{
switch(rd) {
case 0:
gen_op_xor_T1_T0();
gen_op_movtl_env_T0(offsetof(CPUSPARCState, y));
break;
#ifndef TARGET_SPARC64
case 0x01 ... 0x0f:
case 0x10 ... 0x1f:
break;
#else
case 0x2:
gen_op_xor_T1_T0();
gen_op_wrccr();
break;
case 0x3:
gen_op_xor_T1_T0();
gen_op_movl_env_T0(offsetof(CPUSPARCState, asi));
break;
case 0x6:
gen_op_xor_T1_T0();
gen_op_movl_env_T0(offsetof(CPUSPARCState, fprs));
save_state(dc);
gen_op_next_insn();
gen_op_movl_T0_0();
gen_op_exit_tb();
dc->is_br = 1;
break;
case 0xf:
#if !defined(CONFIG_USER_ONLY)
if (supervisor(dc))
gen_op_sir();
#endif
break;
case 0x13:
if (gen_trap_ifnofpu(dc))
goto jmp_insn;
gen_op_xor_T1_T0();
gen_op_movtl_env_T0(offsetof(CPUSPARCState, gsr));
break;
case 0x17:
#if !defined(CONFIG_USER_ONLY)
if (!supervisor(dc))
goto illegal_insn;
#endif
gen_op_xor_T1_T0();
gen_op_movtl_env_T0(offsetof(CPUSPARCState, tick_cmpr));
gen_op_wrtick_cmpr();
break;
case 0x18:
#if !defined(CONFIG_USER_ONLY)
if (!supervisor(dc))
goto illegal_insn;
#endif
gen_op_xor_T1_T0();
gen_op_wrstick();
break;
case 0x19:
#if !defined(CONFIG_USER_ONLY)
if (!supervisor(dc))
goto illegal_insn;
#endif
gen_op_xor_T1_T0();
gen_op_movtl_env_T0(offsetof(CPUSPARCState, stick_cmpr));
gen_op_wrstick_cmpr();
break;
case 0x10:
case 0x11:
case 0x12:
case 0x14:
case 0x15:
case 0x16:
#endif
default:
goto illegal_insn;
}
}
break;
#if !defined(CONFIG_USER_ONLY)
case 0x31:
{
if (!supervisor(dc))
goto priv_insn;
#ifdef TARGET_SPARC64
switch (rd) {
case 0:
gen_op_saved();
break;
case 1:
gen_op_restored();
break;
case 2:
case 3:
case 4:
case 5:
default:
goto illegal_insn;
}
#else
gen_op_xor_T1_T0();
gen_op_wrpsr();
save_state(dc);
gen_op_next_insn();
gen_op_movl_T0_0();
gen_op_exit_tb();
dc->is_br = 1;
#endif
}
break;
case 0x32:
{
if (!supervisor(dc))
goto priv_insn;
gen_op_xor_T1_T0();
#ifdef TARGET_SPARC64
switch (rd) {
case 0:
gen_op_wrtpc();
break;
case 1:
gen_op_wrtnpc();
break;
case 2:
gen_op_wrtstate();
break;
case 3:
gen_op_wrtt();
break;
case 4:
gen_op_wrtick();
break;
case 5:
gen_op_movtl_env_T0(offsetof(CPUSPARCState, tbr));
break;
case 6:
gen_op_wrpstate();
save_state(dc);
gen_op_next_insn();
gen_op_movl_T0_0();
gen_op_exit_tb();
dc->is_br = 1;
break;
case 7:
gen_op_movl_env_T0(offsetof(CPUSPARCState, tl));
break;
case 8:
gen_op_movl_env_T0(offsetof(CPUSPARCState, psrpil));
break;
case 9:
gen_op_wrcwp();
break;
case 10:
gen_op_movl_env_T0(offsetof(CPUSPARCState, cansave));
break;
case 11:
gen_op_movl_env_T0(offsetof(CPUSPARCState, canrestore));
break;
case 12:
gen_op_movl_env_T0(offsetof(CPUSPARCState, cleanwin));
break;
case 13:
gen_op_movl_env_T0(offsetof(CPUSPARCState, otherwin));
break;
case 14:
gen_op_movl_env_T0(offsetof(CPUSPARCState, wstate));
break;
case 16:
gen_op_movl_env_T0(offsetof(CPUSPARCState, gl));
break;
case 26:
if (!hypervisor(dc))
goto priv_insn;
gen_op_movl_env_T0(offsetof(CPUSPARCState, ssr));
break;
default:
goto illegal_insn;
}
#else
gen_op_wrwim();
#endif
}
break;
case 0x33:
{
#ifndef TARGET_SPARC64
if (!supervisor(dc))
goto priv_insn;
gen_op_xor_T1_T0();
gen_op_movtl_env_T0(offsetof(CPUSPARCState, tbr));
#else
if (!hypervisor(dc))
goto priv_insn;
gen_op_xor_T1_T0();
switch (rd) {
case 0:
gen_op_wrhpstate();
save_state(dc);
gen_op_next_insn();
gen_op_movl_T0_0();
gen_op_exit_tb();
dc->is_br = 1;
break;
case 1:
gen_op_wrhtstate();
break;
case 3:
gen_op_movl_env_T0(offsetof(CPUSPARCState, hintp));
break;
case 5:
gen_op_movl_env_T0(offsetof(CPUSPARCState, htba));
break;
case 31:
gen_op_movtl_env_T0(offsetof(CPUSPARCState, hstick_cmpr));
gen_op_wrhstick_cmpr();
break;
case 6: readonly
default:
goto illegal_insn;
}
#endif
}
break;
#endif
#ifdef TARGET_SPARC64
case 0x2c:
{
int cc = GET_FIELD_SP(insn, 11, 12);
int cond = GET_FIELD_SP(insn, 14, 17);
if (IS_IMM) {
rs2 = GET_FIELD_SPs(insn, 0, 10);
gen_movl_simm_T1(rs2);
}
else {
rs2 = GET_FIELD_SP(insn, 0, 4);
gen_movl_reg_T1(rs2);
}
gen_movl_reg_T0(rd);
flush_T2(dc);
if (insn & (1 << 18)) {
if (cc == 0)
gen_cond[0][cond]();
else if (cc == 2)
gen_cond[1][cond]();
else
goto illegal_insn;
} else {
gen_fcond[cc][cond]();
}
gen_op_mov_cc();
gen_movl_T0_reg(rd);
break;
}
case 0x2d:
gen_op_sdivx_T1_T0();
gen_movl_T0_reg(rd);
break;
case 0x2e:
{
if (IS_IMM) {
rs2 = GET_FIELD_SPs(insn, 0, 12);
gen_movl_simm_T1(rs2);
optimize: popc(constant)
}
else {
rs2 = GET_FIELD_SP(insn, 0, 4);
gen_movl_reg_T1(rs2);
}
gen_op_popc();
gen_movl_T0_reg(rd);
}
case 0x2f:
{
int cond = GET_FIELD_SP(insn, 10, 12);
rs1 = GET_FIELD(insn, 13, 17);
flush_T2(dc);
gen_movl_reg_T0(rs1);
gen_cond_reg(cond);
if (IS_IMM) {
rs2 = GET_FIELD_SPs(insn, 0, 9);
gen_movl_simm_T1(rs2);
}
else {
rs2 = GET_FIELD_SP(insn, 0, 4);
gen_movl_reg_T1(rs2);
}
gen_movl_reg_T0(rd);
gen_op_mov_cc();
gen_movl_T0_reg(rd);
break;
}
#endif
default:
goto illegal_insn;
}
}
} else if (xop == 0x36) {
#ifdef TARGET_SPARC64
int opf = GET_FIELD_SP(insn, 5, 13);
rs1 = GET_FIELD(insn, 13, 17);
rs2 = GET_FIELD(insn, 27, 31);
if (gen_trap_ifnofpu(dc))
goto jmp_insn;
switch (opf) {
case 0x000:
case 0x001:
case 0x002:
case 0x003:
case 0x004:
case 0x005:
case 0x006:
case 0x007:
case 0x008:
case 0x009:
case 0x00a:
case 0x00b:
goto illegal_insn;
case 0x010:
gen_movl_reg_T0(rs1);
gen_movl_reg_T1(rs2);
gen_op_array8();
gen_movl_T0_reg(rd);
break;
case 0x012:
gen_movl_reg_T0(rs1);
gen_movl_reg_T1(rs2);
gen_op_array16();
gen_movl_T0_reg(rd);
break;
case 0x014:
gen_movl_reg_T0(rs1);
gen_movl_reg_T1(rs2);
gen_op_array32();
gen_movl_T0_reg(rd);
break;
case 0x018:
gen_movl_reg_T0(rs1);
gen_movl_reg_T1(rs2);
gen_op_alignaddr();
gen_movl_T0_reg(rd);
break;
case 0x019:
case 0x01a:
goto illegal_insn;
case 0x020:
gen_op_load_fpr_DT0(rs1);
gen_op_load_fpr_DT1(rs2);
gen_op_fcmple16();
gen_op_store_DT0_fpr(rd);
break;
case 0x022:
gen_op_load_fpr_DT0(rs1);
gen_op_load_fpr_DT1(rs2);
gen_op_fcmpne16();
gen_op_store_DT0_fpr(rd);
break;
case 0x024:
gen_op_load_fpr_DT0(rs1);
gen_op_load_fpr_DT1(rs2);
gen_op_fcmple32();
gen_op_store_DT0_fpr(rd);
break;
case 0x026:
gen_op_load_fpr_DT0(rs1);
gen_op_load_fpr_DT1(rs2);
gen_op_fcmpne32();
gen_op_store_DT0_fpr(rd);
break;
case 0x028:
gen_op_load_fpr_DT0(rs1);
gen_op_load_fpr_DT1(rs2);
gen_op_fcmpgt16();
gen_op_store_DT0_fpr(rd);
break;
case 0x02a:
gen_op_load_fpr_DT0(rs1);
gen_op_load_fpr_DT1(rs2);
gen_op_fcmpeq16();
gen_op_store_DT0_fpr(rd);
break;
case 0x02c:
gen_op_load_fpr_DT0(rs1);
gen_op_load_fpr_DT1(rs2);
gen_op_fcmpgt32();
gen_op_store_DT0_fpr(rd);
break;
case 0x02e:
gen_op_load_fpr_DT0(rs1);
gen_op_load_fpr_DT1(rs2);
gen_op_fcmpeq32();
gen_op_store_DT0_fpr(rd);
break;
case 0x031:
gen_op_load_fpr_DT0(rs1);
gen_op_load_fpr_DT1(rs2);
gen_op_fmul8x16();
gen_op_store_DT0_fpr(rd);
break;
case 0x033:
gen_op_load_fpr_DT0(rs1);
gen_op_load_fpr_DT1(rs2);
gen_op_fmul8x16au();
gen_op_store_DT0_fpr(rd);
break;
case 0x035:
gen_op_load_fpr_DT0(rs1);
gen_op_load_fpr_DT1(rs2);
gen_op_fmul8x16al();
gen_op_store_DT0_fpr(rd);
break;
case 0x036:
gen_op_load_fpr_DT0(rs1);
gen_op_load_fpr_DT1(rs2);
gen_op_fmul8sux16();
gen_op_store_DT0_fpr(rd);
break;
case 0x037:
gen_op_load_fpr_DT0(rs1);
gen_op_load_fpr_DT1(rs2);
gen_op_fmul8ulx16();
gen_op_store_DT0_fpr(rd);
break;
case 0x038:
gen_op_load_fpr_DT0(rs1);
gen_op_load_fpr_DT1(rs2);
gen_op_fmuld8sux16();
gen_op_store_DT0_fpr(rd);
break;
case 0x039:
gen_op_load_fpr_DT0(rs1);
gen_op_load_fpr_DT1(rs2);
gen_op_fmuld8ulx16();
gen_op_store_DT0_fpr(rd);
break;
case 0x03a:
case 0x03b:
case 0x03d:
case 0x03e:
goto illegal_insn;
case 0x048:
gen_op_load_fpr_DT0(rs1);
gen_op_load_fpr_DT1(rs2);
gen_op_faligndata();
gen_op_store_DT0_fpr(rd);
break;
case 0x04b:
gen_op_load_fpr_DT0(rs1);
gen_op_load_fpr_DT1(rs2);
gen_op_fpmerge();
gen_op_store_DT0_fpr(rd);
break;
case 0x04c:
goto illegal_insn;
case 0x04d:
gen_op_load_fpr_DT0(rs1);
gen_op_load_fpr_DT1(rs2);
gen_op_fexpand();
gen_op_store_DT0_fpr(rd);
break;
case 0x050:
gen_op_load_fpr_DT0(rs1);
gen_op_load_fpr_DT1(rs2);
gen_op_fpadd16();
gen_op_store_DT0_fpr(rd);
break;
case 0x051:
gen_op_load_fpr_FT0(rs1);
gen_op_load_fpr_FT1(rs2);
gen_op_fpadd16s();
gen_op_store_FT0_fpr(rd);
break;
case 0x052:
gen_op_load_fpr_DT0(rs1);
gen_op_load_fpr_DT1(rs2);
gen_op_fpadd32();
gen_op_store_DT0_fpr(rd);
break;
case 0x053:
gen_op_load_fpr_FT0(rs1);
gen_op_load_fpr_FT1(rs2);
gen_op_fpadd32s();
gen_op_store_FT0_fpr(rd);
break;
case 0x054:
gen_op_load_fpr_DT0(rs1);
gen_op_load_fpr_DT1(rs2);
gen_op_fpsub16();
gen_op_store_DT0_fpr(rd);
break;
case 0x055:
gen_op_load_fpr_FT0(rs1);
gen_op_load_fpr_FT1(rs2);
gen_op_fpsub16s();
gen_op_store_FT0_fpr(rd);
break;
case 0x056:
gen_op_load_fpr_DT0(rs1);
gen_op_load_fpr_DT1(rs2);
gen_op_fpadd32();
gen_op_store_DT0_fpr(rd);
break;
case 0x057:
gen_op_load_fpr_FT0(rs1);
gen_op_load_fpr_FT1(rs2);
gen_op_fpsub32s();
gen_op_store_FT0_fpr(rd);
break;
case 0x060:
gen_op_movl_DT0_0();
gen_op_store_DT0_fpr(rd);
break;
case 0x061:
gen_op_movl_FT0_0();
gen_op_store_FT0_fpr(rd);
break;
case 0x062:
gen_op_load_fpr_DT0(rs1);
gen_op_load_fpr_DT1(rs2);
gen_op_fnor();
gen_op_store_DT0_fpr(rd);
break;
case 0x063:
gen_op_load_fpr_FT0(rs1);
gen_op_load_fpr_FT1(rs2);
gen_op_fnors();
gen_op_store_FT0_fpr(rd);
break;
case 0x064:
gen_op_load_fpr_DT1(rs1);
gen_op_load_fpr_DT0(rs2);
gen_op_fandnot();
gen_op_store_DT0_fpr(rd);
break;
case 0x065:
gen_op_load_fpr_FT1(rs1);
gen_op_load_fpr_FT0(rs2);
gen_op_fandnots();
gen_op_store_FT0_fpr(rd);
break;
case 0x066:
gen_op_load_fpr_DT1(rs2);
gen_op_fnot();
gen_op_store_DT0_fpr(rd);
break;
case 0x067:
gen_op_load_fpr_FT1(rs2);
gen_op_fnot();
gen_op_store_FT0_fpr(rd);
break;
case 0x068:
gen_op_load_fpr_DT0(rs1);
gen_op_load_fpr_DT1(rs2);
gen_op_fandnot();
gen_op_store_DT0_fpr(rd);
break;
case 0x069:
gen_op_load_fpr_FT0(rs1);
gen_op_load_fpr_FT1(rs2);
gen_op_fandnots();
gen_op_store_FT0_fpr(rd);
break;
case 0x06a:
gen_op_load_fpr_DT1(rs1);
gen_op_fnot();
gen_op_store_DT0_fpr(rd);
break;
case 0x06b:
gen_op_load_fpr_FT1(rs1);
gen_op_fnot();
gen_op_store_FT0_fpr(rd);
break;
case 0x06c:
gen_op_load_fpr_DT0(rs1);
gen_op_load_fpr_DT1(rs2);
gen_op_fxor();
gen_op_store_DT0_fpr(rd);
break;
case 0x06d:
gen_op_load_fpr_FT0(rs1);
gen_op_load_fpr_FT1(rs2);
gen_op_fxors();
gen_op_store_FT0_fpr(rd);
break;
case 0x06e:
gen_op_load_fpr_DT0(rs1);
gen_op_load_fpr_DT1(rs2);
gen_op_fnand();
gen_op_store_DT0_fpr(rd);
break;
case 0x06f:
gen_op_load_fpr_FT0(rs1);
gen_op_load_fpr_FT1(rs2);
gen_op_fnands();
gen_op_store_FT0_fpr(rd);
break;
case 0x070:
gen_op_load_fpr_DT0(rs1);
gen_op_load_fpr_DT1(rs2);
gen_op_fand();
gen_op_store_DT0_fpr(rd);
break;
case 0x071:
gen_op_load_fpr_FT0(rs1);
gen_op_load_fpr_FT1(rs2);
gen_op_fands();
gen_op_store_FT0_fpr(rd);
break;
case 0x072:
gen_op_load_fpr_DT0(rs1);
gen_op_load_fpr_DT1(rs2);
gen_op_fxnor();
gen_op_store_DT0_fpr(rd);
break;
case 0x073:
gen_op_load_fpr_FT0(rs1);
gen_op_load_fpr_FT1(rs2);
gen_op_fxnors();
gen_op_store_FT0_fpr(rd);
break;
case 0x074:
gen_op_load_fpr_DT0(rs1);
gen_op_store_DT0_fpr(rd);
break;
case 0x075:
gen_op_load_fpr_FT0(rs1);
gen_op_store_FT0_fpr(rd);
break;
case 0x076:
gen_op_load_fpr_DT1(rs1);
gen_op_load_fpr_DT0(rs2);
gen_op_fornot();
gen_op_store_DT0_fpr(rd);
break;
case 0x077:
gen_op_load_fpr_FT1(rs1);
gen_op_load_fpr_FT0(rs2);
gen_op_fornots();
gen_op_store_FT0_fpr(rd);
break;
case 0x078:
gen_op_load_fpr_DT0(rs2);
gen_op_store_DT0_fpr(rd);
break;
case 0x079:
gen_op_load_fpr_FT0(rs2);
gen_op_store_FT0_fpr(rd);
break;
case 0x07a:
gen_op_load_fpr_DT0(rs1);
gen_op_load_fpr_DT1(rs2);
gen_op_fornot();
gen_op_store_DT0_fpr(rd);
break;
case 0x07b:
gen_op_load_fpr_FT0(rs1);
gen_op_load_fpr_FT1(rs2);
gen_op_fornots();
gen_op_store_FT0_fpr(rd);
break;
case 0x07c:
gen_op_load_fpr_DT0(rs1);
gen_op_load_fpr_DT1(rs2);
gen_op_for();
gen_op_store_DT0_fpr(rd);
break;
case 0x07d:
gen_op_load_fpr_FT0(rs1);
gen_op_load_fpr_FT1(rs2);
gen_op_fors();
gen_op_store_FT0_fpr(rd);
break;
case 0x07e:
gen_op_movl_DT0_1();
gen_op_store_DT0_fpr(rd);
break;
case 0x07f:
gen_op_movl_FT0_1();
gen_op_store_FT0_fpr(rd);
break;
case 0x080:
case 0x081:
goto illegal_insn;
default:
goto illegal_insn;
}
#else
goto ncp_insn;
#endif
} else if (xop == 0x37) {
#ifdef TARGET_SPARC64
goto illegal_insn;
#else
goto ncp_insn;
#endif
#ifdef TARGET_SPARC64
} else if (xop == 0x39) {
rs1 = GET_FIELD(insn, 13, 17);
save_state(dc);
gen_movl_reg_T0(rs1);
if (IS_IMM) {
rs2 = GET_FIELDs(insn, 19, 31);
#if defined(OPTIM)
if (rs2) {
#endif
gen_movl_simm_T1(rs2);
gen_op_add_T1_T0();
#if defined(OPTIM)
}
#endif
} else {
rs2 = GET_FIELD(insn, 27, 31);
#if defined(OPTIM)
if (rs2) {
#endif
gen_movl_reg_T1(rs2);
gen_op_add_T1_T0();
#if defined(OPTIM)
}
#endif
}
gen_op_restore();
gen_mov_pc_npc(dc);
gen_op_check_align_T0_3();
gen_op_movl_npc_T0();
dc->npc = DYNAMIC_PC;
goto jmp_insn;
#endif
} else {
rs1 = GET_FIELD(insn, 13, 17);
gen_movl_reg_T0(rs1);
if (IS_IMM) {
rs2 = GET_FIELDs(insn, 19, 31);
#if defined(OPTIM)
if (rs2) {
#endif
gen_movl_simm_T1(rs2);
gen_op_add_T1_T0();
#if defined(OPTIM)
}
#endif
} else {
rs2 = GET_FIELD(insn, 27, 31);
#if defined(OPTIM)
if (rs2) {
#endif
gen_movl_reg_T1(rs2);
gen_op_add_T1_T0();
#if defined(OPTIM)
}
#endif
}
switch (xop) {
case 0x38:
{
if (rd != 0) {
#ifdef TARGET_SPARC64
if (dc->pc == (uint32_t)dc->pc) {
gen_op_movl_T1_im(dc->pc);
} else {
gen_op_movq_T1_im64(dc->pc >> 32, dc->pc);
}
#else
gen_op_movl_T1_im(dc->pc);
#endif
gen_movl_T1_reg(rd);
}
gen_mov_pc_npc(dc);
gen_op_check_align_T0_3();
gen_op_movl_npc_T0();
dc->npc = DYNAMIC_PC;
}
goto jmp_insn;
#if !defined(CONFIG_USER_ONLY) && !defined(TARGET_SPARC64)
case 0x39:
{
if (!supervisor(dc))
goto priv_insn;
gen_mov_pc_npc(dc);
gen_op_check_align_T0_3();
gen_op_movl_npc_T0();
dc->npc = DYNAMIC_PC;
gen_op_rett();
}
goto jmp_insn;
#endif
case 0x3b:
gen_op_flush_T0();
break;
case 0x3c:
save_state(dc);
gen_op_save();
gen_movl_T0_reg(rd);
break;
case 0x3d:
save_state(dc);
gen_op_restore();
gen_movl_T0_reg(rd);
break;
#if !defined(CONFIG_USER_ONLY) && defined(TARGET_SPARC64)
case 0x3e:
{
switch (rd) {
case 0:
if (!supervisor(dc))
goto priv_insn;
dc->npc = DYNAMIC_PC;
dc->pc = DYNAMIC_PC;
gen_op_done();
goto jmp_insn;
case 1:
if (!supervisor(dc))
goto priv_insn;
dc->npc = DYNAMIC_PC;
dc->pc = DYNAMIC_PC;
gen_op_retry();
goto jmp_insn;
default:
goto illegal_insn;
}
}
break;
#endif
default:
goto illegal_insn;
}
}
break;
}
break;
case 3:
{
unsigned int xop = GET_FIELD(insn, 7, 12);
rs1 = GET_FIELD(insn, 13, 17);
save_state(dc);
gen_movl_reg_T0(rs1);
if (xop == 0x3c || xop == 0x3e)
{
rs2 = GET_FIELD(insn, 27, 31);
gen_movl_reg_T1(rs2);
}
else if (IS_IMM) {
rs2 = GET_FIELDs(insn, 19, 31);
#if defined(OPTIM)
if (rs2 != 0) {
#endif
gen_movl_simm_T1(rs2);
gen_op_add_T1_T0();
#if defined(OPTIM)
}
#endif
} else {
rs2 = GET_FIELD(insn, 27, 31);
#if defined(OPTIM)
if (rs2 != 0) {
#endif
gen_movl_reg_T1(rs2);
gen_op_add_T1_T0();
#if defined(OPTIM)
}
#endif
}
if (xop < 4 || (xop > 7 && xop < 0x14 && xop != 0x0e) ||
(xop > 0x17 && xop <= 0x1d ) ||
(xop > 0x2c && xop <= 0x33) || xop == 0x1f || xop == 0x3d) {
switch (xop) {
case 0x0:
#ifdef CONFIG_USER_ONLY
gen_op_check_align_T0_3();
#endif
#ifndef TARGET_SPARC64
gen_op_ldst(ld);
#else
gen_op_ldst(lduw);
#endif
break;
case 0x1:
gen_op_ldst(ldub);
break;
case 0x2:
#ifdef CONFIG_USER_ONLY
gen_op_check_align_T0_1();
#endif
gen_op_ldst(lduh);
break;
case 0x3:
gen_op_check_align_T0_7();
if (rd & 1)
goto illegal_insn;
gen_op_ldst(ldd);
gen_movl_T0_reg(rd + 1);
break;
case 0x9:
gen_op_ldst(ldsb);
break;
case 0xa:
#ifdef CONFIG_USER_ONLY
gen_op_check_align_T0_1();
#endif
gen_op_ldst(ldsh);
break;
case 0xd:
gen_op_ldst(ldstub);
break;
case 0x0f:
#ifdef CONFIG_USER_ONLY
gen_op_check_align_T0_3();
#endif
gen_movl_reg_T1(rd);
gen_op_ldst(swap);
break;
#if !defined(CONFIG_USER_ONLY) || defined(TARGET_SPARC64)
case 0x10:
#ifndef TARGET_SPARC64
if (IS_IMM)
goto illegal_insn;
if (!supervisor(dc))
goto priv_insn;
#elif CONFIG_USER_ONLY
gen_op_check_align_T0_3();
#endif
gen_ld_asi(insn, 4, 0);
break;
case 0x11:
#ifndef TARGET_SPARC64
if (IS_IMM)
goto illegal_insn;
if (!supervisor(dc))
goto priv_insn;
#endif
gen_ld_asi(insn, 1, 0);
break;
case 0x12:
#ifndef TARGET_SPARC64
if (IS_IMM)
goto illegal_insn;
if (!supervisor(dc))
goto priv_insn;
#elif CONFIG_USER_ONLY
gen_op_check_align_T0_1();
#endif
gen_ld_asi(insn, 2, 0);
break;
case 0x13:
#ifndef TARGET_SPARC64
if (IS_IMM)
goto illegal_insn;
if (!supervisor(dc))
goto priv_insn;
#endif
if (rd & 1)
goto illegal_insn;
gen_op_check_align_T0_7();
gen_ldda_asi(insn);
gen_movl_T0_reg(rd + 1);
break;
case 0x19:
#ifndef TARGET_SPARC64
if (IS_IMM)
goto illegal_insn;
if (!supervisor(dc))
goto priv_insn;
#endif
gen_ld_asi(insn, 1, 1);
break;
case 0x1a:
#ifndef TARGET_SPARC64
if (IS_IMM)
goto illegal_insn;
if (!supervisor(dc))
goto priv_insn;
#elif CONFIG_USER_ONLY
gen_op_check_align_T0_1();
#endif
gen_ld_asi(insn, 2, 1);
break;
case 0x1d:
#ifndef TARGET_SPARC64
if (IS_IMM)
goto illegal_insn;
if (!supervisor(dc))
goto priv_insn;
#endif
gen_ldstub_asi(insn);
break;
case 0x1f:
#ifndef TARGET_SPARC64
if (IS_IMM)
goto illegal_insn;
if (!supervisor(dc))
goto priv_insn;
#elif CONFIG_USER_ONLY
gen_op_check_align_T0_3();
#endif
gen_movl_reg_T1(rd);
gen_swap_asi(insn);
break;
#ifndef TARGET_SPARC64
case 0x30:
case 0x31:
case 0x33:
goto ncp_insn;
#endif
#endif
#ifdef TARGET_SPARC64
case 0x08:
#ifdef CONFIG_USER_ONLY
gen_op_check_align_T0_3();
#endif
gen_op_ldst(ldsw);
break;
case 0x0b:
gen_op_check_align_T0_7();
gen_op_ldst(ldx);
break;
case 0x18:
#ifdef CONFIG_USER_ONLY
gen_op_check_align_T0_3();
#endif
gen_ld_asi(insn, 4, 1);
break;
case 0x1b:
gen_op_check_align_T0_7();
gen_ld_asi(insn, 8, 0);
break;
case 0x2d:
goto skip_move;
case 0x30:
#ifdef CONFIG_USER_ONLY
gen_op_check_align_T0_3();
#endif
gen_ldf_asi(insn, 4);
goto skip_move;
case 0x33:
gen_op_check_align_T0_3();
gen_ldf_asi(insn, 8);
goto skip_move;
case 0x3d:
goto skip_move;
case 0x32:
goto nfpu_insn;
#endif
default:
goto illegal_insn;
}
gen_movl_T1_reg(rd);
#ifdef TARGET_SPARC64
skip_move: ;
#endif
} else if (xop >= 0x20 && xop < 0x24) {
if (gen_trap_ifnofpu(dc))
goto jmp_insn;
switch (xop) {
case 0x20:
#ifdef CONFIG_USER_ONLY
gen_op_check_align_T0_3();
#endif
gen_op_ldst(ldf);
gen_op_store_FT0_fpr(rd);
break;
case 0x21:
#ifdef CONFIG_USER_ONLY
gen_op_check_align_T0_3();
#endif
gen_op_ldst(ldf);
gen_op_ldfsr();
break;
case 0x22:
goto nfpu_insn;
case 0x23:
gen_op_check_align_T0_7();
gen_op_ldst(lddf);
gen_op_store_DT0_fpr(DFPREG(rd));
break;
default:
goto illegal_insn;
}
} else if (xop < 8 || (xop >= 0x14 && xop < 0x18) || \
xop == 0xe || xop == 0x1e) {
gen_movl_reg_T1(rd);
switch (xop) {
case 0x4:
#ifdef CONFIG_USER_ONLY
gen_op_check_align_T0_3();
#endif
gen_op_ldst(st);
break;
case 0x5:
gen_op_ldst(stb);
break;
case 0x6:
#ifdef CONFIG_USER_ONLY
gen_op_check_align_T0_1();
#endif
gen_op_ldst(sth);
break;
case 0x7:
if (rd & 1)
goto illegal_insn;
gen_op_check_align_T0_7();
flush_T2(dc);
gen_movl_reg_T2(rd + 1);
gen_op_ldst(std);
break;
#if !defined(CONFIG_USER_ONLY) || defined(TARGET_SPARC64)
case 0x14:
#ifndef TARGET_SPARC64
if (IS_IMM)
goto illegal_insn;
if (!supervisor(dc))
goto priv_insn;
#endif
#ifdef CONFIG_USER_ONLY
gen_op_check_align_T0_3();
#endif
gen_st_asi(insn, 4);
break;
case 0x15:
#ifndef TARGET_SPARC64
if (IS_IMM)
goto illegal_insn;
if (!supervisor(dc))
goto priv_insn;
#endif
gen_st_asi(insn, 1);
break;
case 0x16:
#ifndef TARGET_SPARC64
if (IS_IMM)
goto illegal_insn;
if (!supervisor(dc))
goto priv_insn;
#endif
#ifdef CONFIG_USER_ONLY
gen_op_check_align_T0_1();
#endif
gen_st_asi(insn, 2);
break;
case 0x17:
#ifndef TARGET_SPARC64
if (IS_IMM)
goto illegal_insn;
if (!supervisor(dc))
goto priv_insn;
#endif
if (rd & 1)
goto illegal_insn;
gen_op_check_align_T0_7();
flush_T2(dc);
gen_movl_reg_T2(rd + 1);
gen_stda_asi(insn);
break;
#endif
#ifdef TARGET_SPARC64
case 0x0e:
gen_op_check_align_T0_7();
gen_op_ldst(stx);
break;
case 0x1e:
gen_op_check_align_T0_7();
gen_st_asi(insn, 8);
break;
#endif
default:
goto illegal_insn;
}
} else if (xop > 0x23 && xop < 0x28) {
if (gen_trap_ifnofpu(dc))
goto jmp_insn;
switch (xop) {
case 0x24:
#ifdef CONFIG_USER_ONLY
gen_op_check_align_T0_3();
#endif
gen_op_load_fpr_FT0(rd);
gen_op_ldst(stf);
break;
case 0x25:
#ifdef CONFIG_USER_ONLY
gen_op_check_align_T0_3();
#endif
gen_op_stfsr();
gen_op_ldst(stf);
break;
#if !defined(CONFIG_USER_ONLY)
case 0x26:
if (!supervisor(dc))
goto priv_insn;
if (gen_trap_ifnofpu(dc))
goto jmp_insn;
goto nfq_insn;
#endif
case 0x27:
gen_op_check_align_T0_7();
gen_op_load_fpr_DT0(DFPREG(rd));
gen_op_ldst(stdf);
break;
default:
goto illegal_insn;
}
} else if (xop > 0x33 && xop < 0x3f) {
switch (xop) {
#ifdef TARGET_SPARC64
case 0x34:
#ifdef CONFIG_USER_ONLY
gen_op_check_align_T0_3();
#endif
gen_op_load_fpr_FT0(rd);
gen_stf_asi(insn, 4);
break;
case 0x37:
gen_op_check_align_T0_3();
gen_op_load_fpr_DT0(DFPREG(rd));
gen_stf_asi(insn, 8);
break;
case 0x3c:
#ifdef CONFIG_USER_ONLY
gen_op_check_align_T0_3();
#endif
flush_T2(dc);
gen_movl_reg_T2(rd);
gen_cas_asi(insn);
gen_movl_T1_reg(rd);
break;
case 0x3e:
gen_op_check_align_T0_7();
flush_T2(dc);
gen_movl_reg_T2(rd);
gen_casx_asi(insn);
gen_movl_T1_reg(rd);
break;
case 0x36:
goto nfpu_insn;
#else
case 0x34:
case 0x35:
case 0x36:
case 0x37:
goto ncp_insn;
#endif
default:
goto illegal_insn;
}
}
else
goto illegal_insn;
}
break;
}
if (dc->npc == DYNAMIC_PC) {
dc->pc = DYNAMIC_PC;
gen_op_next_insn();
} else if (dc->npc == JUMP_PC) {
gen_branch2(dc, dc->jump_pc[0], dc->jump_pc[1]);
dc->is_br = 1;
} else {
dc->pc = dc->npc;
dc->npc = dc->npc + 4;
}
jmp_insn:
return;
illegal_insn:
save_state(dc);
gen_op_exception(TT_ILL_INSN);
dc->is_br = 1;
return;
#if !defined(CONFIG_USER_ONLY)
priv_insn:
save_state(dc);
gen_op_exception(TT_PRIV_INSN);
dc->is_br = 1;
return;
#endif
nfpu_insn:
save_state(dc);
gen_op_fpexception_im(FSR_FTT_UNIMPFPOP);
dc->is_br = 1;
return;
#if !defined(CONFIG_USER_ONLY)
nfq_insn:
save_state(dc);
gen_op_fpexception_im(FSR_FTT_SEQ_ERROR);
dc->is_br = 1;
return;
#endif
#ifndef TARGET_SPARC64
ncp_insn:
save_state(dc);
gen_op_exception(TT_NCP_INSN);
dc->is_br = 1;
return;
#endif
}
| 1threat
|
How Can I solve the logical error in the flowing code? : <p>No value is being printed inside if condition block.
Where is the logical error?
Thanks.</p>
<pre><code>#include<bits/stdc++.h>
using namespace std;
int fx[]= {-1,-1,-1,0,1,1,1,0};
int fy[]= {-1,0,1,1,1,0,-1,-1};
int ar[20][20];
int n;
int v1, v2;
void fun(int a, int b)
{
for(int i=0; i<8; i++)
{
v1 = a+fx[i];
v2 = b+fy[i];
//cout<<v1<<" "<<v2<<endl;
if(v1>=0 && v1<n)
{
if(v2>=0 && v2<n)
{
// Not executing
cout<<"----------"<<endl;
cout<<v1<<" "<<v2<<endl;
}
}
}
}
int main()
{
int n;
cin>> n;
for(int i=0; i<n; i++)
{
for(int j=0; j<n; j++)
cin>> ar[i][j];
}
fun(0,1);
return 0;
}
</code></pre>
<p>SAMPLE INPUT:<br>
4<br>
1 1 1 1<br>
1 1 1 1<br>
1 1 1 1<br>
1 1 1 1<br>
EXPECTED OUTPUT:<br>
<p>---------<p>
0 2<br>
1 2<br>
1 1<br>
1 0<br>
0 0<br> </p>
| 0debug
|
URL Well Formed returns true for invalid url : <p>How come the following URL is valid ?</p>
<pre><code>var testURL = "http://" + "ggggggggg" +"/"
if(Uri.IsWellFormedUriString(testURL, UriKind.RelativeOrAbsolute))
{
// it comes here
}
</code></pre>
| 0debug
|
How to read file? java : <p>I have created a class that has the features of reading and writing to a file even parsing what is in the file. But when I run my test, I am not able to read the file. This is the snippet of what I have, if it is not enough I can post the rest of what I have to help.</p>
<p>this is what my main looks like:</p>
<pre><code>public static void main(String args[]) throws IOException {
String fileLocation = File.separator + "Users" + File.separator + "Desktop" + File.separator + "test.txt";
File file = new File(fileLocation);
DataStorage data = new DataStorage(fileLocation);
data.read();
}
</code></pre>
<p>this is what my read method looks like:</p>
<pre><code>public File file;
public DataStorage(String filePath) {
setFile(filePath);
}
public Data read() throws IOException {
Data db = new Data();
Scanner scan = new Scanner(file);
Person person;
//check if file has data print selected data
while(scan.hasNextLine()) {
person = parsePerson(scan.nextLine());
db.add(person);
}
if(scan != null) {
// close() may throw IOException if fails;
scan.close();
}
return db;
}
</code></pre>
| 0debug
|
static void test_qga_set_time(gconstpointer fix)
{
const TestFixture *fixture = fix;
QDict *ret;
int64_t current, time;
gchar *cmd;
ret = qmp_fd(fixture->fd, "{'execute': 'guest-get-time'}");
g_assert_nonnull(ret);
qmp_assert_no_error(ret);
current = qdict_get_int(ret, "return");
g_assert_cmpint(current, >, 0);
QDECREF(ret);
ret = qmp_fd(fixture->fd, "{'execute': 'guest-set-time',"
" 'arguments': { 'time': 1000 } }");
g_assert_nonnull(ret);
qmp_assert_no_error(ret);
QDECREF(ret);
ret = qmp_fd(fixture->fd, "{'execute': 'guest-get-time'}");
g_assert_nonnull(ret);
qmp_assert_no_error(ret);
time = qdict_get_int(ret, "return");
g_assert_cmpint(time / 1000, <, G_USEC_PER_SEC * 10);
QDECREF(ret);
cmd = g_strdup_printf("{'execute': 'guest-set-time',"
" 'arguments': { 'time': %" PRId64 " } }",
current + time * 1000);
ret = qmp_fd(fixture->fd, cmd);
g_free(cmd);
g_assert_nonnull(ret);
qmp_assert_no_error(ret);
QDECREF(ret);
}
| 1threat
|
How can I simplify repeated pow() function? :
How can I simplify this?
function x(a, b, c){
rv = Math.floor(a * Math.pow(2, b));
for (i = 1; i < c; i++){
rv += Math.floor(a* Math.pow(1.2, b+i));
}
return rv;
}
I'm using da PC and on da WINDOWS 64 bit thingy.. please hel me i am bery stuck here..
| 0debug
|
Why is the compiler still demanding a return statement? : <p>Why is my java compiler asking for a return statement when I've already placed one in my if statement loop? And how to I fix this so it returns the proper value?</p>
<pre><code>public static String checkNumbers(int x1, int y1, int x2, int y2, int x3, int y3) {
String x = "True";
String y = "False";
int[][] array = {{x1, y1}, {x2, y2}, {x3, y3}};
for (int i = 0; i < array.length; i++) {
if (array[0][0] == 5) {
return x;
} else return y;
}
}
</code></pre>
| 0debug
|
static void test_ide_mbr(bool use_device, MBRcontents mbr)
{
char *argv[256];
int argc;
Backend i;
const char *dev;
argc = setup_common(argv, ARRAY_SIZE(argv));
for (i = 0; i < backend_last; i++) {
cur_ide[i] = &hd_chst[i][mbr];
dev = use_device ? (is_hd(cur_ide[i]) ? "ide-hd" : "ide-cd") : NULL;
argc = setup_ide(argc, argv, ARRAY_SIZE(argv), i, dev, i, mbr, "");
}
qtest_start(g_strjoinv(" ", argv));
test_cmos();
qtest_end();
}
| 1threat
|
pass a db connexion instance to other classes php : <p>i am trying to make a registration system using PHP OOP but im getting this errors when i excute it</p>
<blockquote>
<p>Notice: Undefined variable: connect in C:\wamp64\www\news\classes\user.php on line 14</p>
<p>Fatal error: Call to a member function prepare() on null in C:\wamp64\www\news\classes\user.php on line 14</p>
</blockquote>
<p>i beleive that my problem is that my calsse can't get the db connection instance even im passing it on intiation. i have 2 classes and a registration page
my first class is dbconnect.php</p>
<pre><code><?php
include "./config.php";
class dbconnect{
public function __construct(){
try {
$conect = new PDO('mysql:host='.SERVER.'; dbname='.DATABASE, USERNAME, PASSWORD);
$conect->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
return $conect;
}
catch(PDOException $e)
{
echo "Connection failed: " . $e->getMessage();
}
}
}
?>
</code></pre>
<p>my second class is user.php</p>
<pre><code><?php
class user{
public $username;
public $connect;
function __construct($username,$connect){
$this->username=$username;
$this->connect=$connect;
}
protected function user_exist(){
$request="SELECT * FROM `users` where username='".$this->username."'";
$sql=$connect->prepare($request);
$sql->execute();
$results = $sql->fetch(PDO::FETCH_ASSOC);
if(is_array($results)){
//echo "utilisateur exist";
return true;
}
else{
//echo "utilisateur n'existe pas";
return false;
}
}
public function register($firstname,$lastname,$email,$user,$password){
if(!($this->user_exist())){
$request="INSERT INTO USERS (nom,prenom,email,user,pass,role,statut,date ) VALUES (:firstname, :lastname, :email, :username, :password, :role,:staut, :now())";
$sql = $connect->prepare($request);
$sql->bindParam(':fistname', $firstname);
$sql->bindParam(':lastname', $lastname);
$sql->bindParam(':email', $email);
$sql->bindParam(':username', $username);
$sql->bindParam(':password', $password);
$sql->bindParam(':role', 'subscriber');
$sql->bindParam(':statut', 'waiting for validation');
//$sql->bindParam(':date', $date);
try{
$sql->execute();
}
catch(Exception $e){
if ($e->getCode() == 1062) {
echo $e;
} else {
throw $e;
}
}
}
}
}
?>
</code></pre>
<p>and then my registration page</p>
<pre><code><?php
include "classes/dbconnect.php";
include "classes/user.php";
if((isset($_POST["submit"])) and $_POST["verificaation"]=="submit1"){
$nom = $_POST["nom"];
$prenom = $_POST["prenom"];
$email = $_POST["email"];
$username = $_POST["username"];
$pass = $_POST["password"];
$passver = $_POST["passver"];
$conect=new dbconnect();
$user= new user($username,$conect->connect);
$msg=$user->register($nom,$prenom,$email,$user,$pass);
print_r ($conect);
}
?>
<form method="post" action="register.php">
<label>Nom</label>
<input type="text" name="nom"/><br />
<label>Prenom</label>
<input type="text" name="prenom"/><br />
<label>Email</label>
<input type="email" name="email"/><br />
<label>Nom d'utilisateur</label>
<input type="text" name="username" /><br />
<label>Mot de passe</label>
<input type="password" name="password" /><br />
<label>Recrivez le mot de passe</label>
<input type="password" name="passver"/><br />
<input type="submit" name="submit" value="submit" /><br />
<input type="hidden" name="verificaation" value="submit1" />
</form>
</code></pre>
| 0debug
|
how to use permission_send Manifest android inside subclass? : <p>I made an application using the tab navigation in android studio. On one of the tabs I want to make an SMS sending feature. I've added permissions to AndroidManifest.xml but the feature still won't work</p>
<p>This is My AndroidManifest.xml</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.melani.dprdbkt">
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".SendSMSActivity"
android:parentActivityName=".MainActivity" />
</application>
</manifest>
</code></pre>
<p>This is My MainActivity.java</p>
<pre><code>package com.melani.dprdbkt;
import android.os.Build;
import android.os.Bundle;
import android.support.design.widget.TabItem;
import android.support.design.widget.TabLayout;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
public class MainActivity extends AppCompatActivity {
Toolbar toolbar;
TabLayout tabLayout;
ViewPager viewPager;
PageAdapter pageAdapter;
TabItem tabHome;
TabItem tabBerita;
TabItem tabAgenda;
TabItem tabAnggota;
TabItem tabLink;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
toolbar = findViewById(R.id.toolbar);
toolbar.setTitle(getResources().getString(R.string.app_name));
setSupportActionBar(toolbar);
tabLayout = findViewById(R.id.tablayout);
tabHome = findViewById(R.id.tabHome);
tabBerita = findViewById(R.id.tabBerita);
tabAgenda = findViewById(R.id.tabAgenda);
tabAnggota = findViewById(R.id.tabAnggota);
tabLink = findViewById(R.id.tabLink);
viewPager = findViewById(R.id.viewPager);
pageAdapter = new PageAdapter(getSupportFragmentManager(), tabLayout.getTabCount());
viewPager.setAdapter(pageAdapter);
tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
viewPager.setCurrentItem(tab.getPosition());
if (tab.getPosition() == 1) {
toolbar.setBackgroundColor(ContextCompat.getColor(MainActivity.this,
R.color.colorHome));
tabLayout.setBackgroundColor(ContextCompat.getColor(MainActivity.this,
R.color.colorHome));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setStatusBarColor(ContextCompat.getColor(MainActivity.this,
R.color.colorHome));
}
} else if (tab.getPosition() == 2) {
toolbar.setBackgroundColor(ContextCompat.getColor(MainActivity.this,
R.color.colorBerita));
tabLayout.setBackgroundColor(ContextCompat.getColor(MainActivity.this,
R.color.colorBerita));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setStatusBarColor(ContextCompat.getColor(MainActivity.this,
R.color.colorBerita));
}
}
else if (tab.getPosition() == 3) {
toolbar.setBackgroundColor(ContextCompat.getColor(MainActivity.this,
R.color.colorAgenda));
tabLayout.setBackgroundColor(ContextCompat.getColor(MainActivity.this,
R.color.colorAgenda));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setStatusBarColor(ContextCompat.getColor(MainActivity.this,
R.color.colorAgenda));
}
} else if (tab.getPosition() == 4) {
toolbar.setBackgroundColor(ContextCompat.getColor(MainActivity.this,
R.color.colorAnggota));
tabLayout.setBackgroundColor(ContextCompat.getColor(MainActivity.this,
R.color.colorAnggota));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setStatusBarColor(ContextCompat.getColor(MainActivity.this,
R.color.colorAnggota));
}
}
else {
toolbar.setBackgroundColor(ContextCompat.getColor(MainActivity.this,
R.color.colorLink));
tabLayout.setBackgroundColor(ContextCompat.getColor(MainActivity.this,
R.color.colorLink));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setStatusBarColor(ContextCompat.getColor(MainActivity.this,
R.color.colorLink));
}
}
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
});
viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
}
}
</code></pre>
<p>Send SMSActivity.java</p>
<pre><code>package com.melani.dprdbkt;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class SendSMSActivity extends MainActivity {
private static final int MY_PERMISSION_REQUEST_SEND_SMS=0;
private EditText txtMobile;
private EditText txtMessage;
private Button btnSms;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fragment_link);
txtMobile = (EditText)findViewById(R.id.editTextPhoneNo);
txtMessage = (EditText)findViewById(R.id.editTextSMS);
btnSms = (Button)findViewById(R.id.buttonSend);
btnSms.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try{
SmsManager smgr = SmsManager.getDefault();
smgr.sendTextMessage(txtMobile.getText().toString(),null,txtMessage.getText().toString(),null,null);
Toast.makeText(SendSMSActivity.this, "SMS Sent Successfully", Toast.LENGTH_SHORT).show();
}
catch (Exception e){
Toast.makeText(SendSMSActivity.this, "SMS Failed to Send, Please try again", Toast.LENGTH_SHORT).show();
}
}
});
}
}
</code></pre>
<p>linkFragment.java</p>
<pre><code>package com.melani.dprdbkt;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
//import android.app.m
/**
* A simple {@link Fragment} subclass.
*/
public class LinkFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
setHasOptionsMenu(true);
return inflater.inflate(R.layout.fragment_link, container, false);
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.menu_link, menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.action_link) {
Toast.makeText(getActivity(), "Clicked on " + item.getTitle(), Toast.LENGTH_SHORT)
.show();
}
return true;
}
}
</code></pre>
<p>fragment_link.xml</p>
<pre><code><FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.melani.dprdbkt.LinkFragment">
<!-- TODO: Update blank fragment layout -->
<TextView
android:id="@+id/textViewPhoneNo"
android:layout_width="63dp"
android:layout_height="50dp"
android:layout_marginTop="10dp"
android:text="Ke : "
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
<EditText
android:id="@+id/editTextPhoneNo"
android:layout_width="337dp"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginTop="0dp"
android:phoneNumber="true"></EditText>
<TextView
android:id="@+id/textViewSMS"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="45dp"
android:text="Pesan : "
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
<EditText
android:id="@+id/editTextSMS"
android:layout_width="fill_parent"
android:layout_height="120dp"
android:gravity="top"
android:inputType="textMultiLine"
android:lines="5"
android:layout_marginTop="70dp"
/>
<Button
android:id="@+id/buttonSend"
android:layout_width="180dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="190dp"
android:text="Send" />
</FrameLayout>
</code></pre>
| 0debug
|
Vue 2 - vuex mapGetters and pass params : <p>Is it possible to pass params with <strong>mapGetters</strong>?</p>
<p>I have this in main Vue instance:</p>
<pre><code>computed: {
filterAuthors() {
return this.$store.getters.filterAuthors(this.search.toLowerCase());
}
}
</code></pre>
<p><strong>this.search</strong> is bind to the input field via <strong>v-model="search=</strong>, and in my Vuex instance I have this getters:</p>
<pre><code>getters: {
filterAuthors: (state) => (search) => {
return state.authors.filter((author) => {
return author.name.toLowerCase().indexOf(search) >= 0;
})
}
},
</code></pre>
<p>This one is working fine, but I am trying to find a way (if it is possible) to use mapGetters and to pass the argument. Can this be done?</p>
| 0debug
|
Java Big Decimal Half Even Bug? : <p>I'm trying to specifically use this value</p>
<p><code>new BigDecimal("23.025").setScale(2, RoundingMode.HALF_EVEN);</code></p>
<p>The output is 23.02, but should be 23.03. Is it a bug?</p>
<p>Just for curiosity <code>DecimalFormat("#####0,00");</code> also does not work</p>
<p>Any other suggestion?</p>
| 0debug
|
static void do_screen_dump(int argc, const char **argv)
{
if (argc != 2) {
help_cmd(argv[0]);
return;
}
vga_screen_dump(argv[1]);
}
| 1threat
|
static void pc_init1(ram_addr_t ram_size,
const char *boot_device,
const char *kernel_filename, const char *kernel_cmdline,
const char *initrd_filename,
int pci_enabled, const char *cpu_model)
{
char *filename;
int ret, linux_boot, i;
ram_addr_t ram_addr, bios_offset, option_rom_offset;
ram_addr_t below_4g_mem_size, above_4g_mem_size = 0;
int bios_size, isa_bios_size, oprom_area_size;
PCIBus *pci_bus;
int piix3_devfn = -1;
CPUState *env;
qemu_irq *cpu_irq;
qemu_irq *i8259;
int index;
BlockDriverState *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
BlockDriverState *fd[MAX_FD];
int using_vga = cirrus_vga_enabled || std_vga_enabled || vmsvga_enabled;
if (ram_size >= 0xe0000000 ) {
above_4g_mem_size = ram_size - 0xe0000000;
below_4g_mem_size = 0xe0000000;
} else {
below_4g_mem_size = ram_size;
}
linux_boot = (kernel_filename != NULL);
if (cpu_model == NULL) {
#ifdef TARGET_X86_64
cpu_model = "qemu64";
#else
cpu_model = "qemu32";
#endif
}
for(i = 0; i < smp_cpus; i++) {
env = cpu_init(cpu_model);
if (!env) {
fprintf(stderr, "Unable to find x86 CPU definition\n");
exit(1);
}
if ((env->cpuid_features & CPUID_APIC) || smp_cpus > 1) {
env->cpuid_apic_id = env->cpu_index;
apic_init(env);
}
qemu_register_reset(main_cpu_reset, 0, env);
}
vmport_init();
ram_addr = qemu_ram_alloc(0xa0000);
cpu_register_physical_memory(0, 0xa0000, ram_addr);
ram_addr = qemu_ram_alloc(0x100000 - 0xa0000);
ram_addr = qemu_ram_alloc(below_4g_mem_size - 0x100000);
cpu_register_physical_memory(0x100000,
below_4g_mem_size - 0x100000,
ram_addr);
if (above_4g_mem_size > 0) {
#if TARGET_PHYS_ADDR_BITS == 32
hw_error("To much RAM for 32-bit physical address");
#else
ram_addr = qemu_ram_alloc(above_4g_mem_size);
cpu_register_physical_memory(0x100000000ULL,
above_4g_mem_size,
ram_addr);
#endif
}
if (bios_name == NULL)
bios_name = BIOS_FILENAME;
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (filename) {
bios_size = get_image_size(filename);
} else {
bios_size = -1;
}
if (bios_size <= 0 ||
(bios_size % 65536) != 0) {
goto bios_error;
}
bios_offset = qemu_ram_alloc(bios_size);
ret = load_image(filename, qemu_get_ram_ptr(bios_offset));
if (ret != bios_size) {
bios_error:
fprintf(stderr, "qemu: could not load PC BIOS '%s'\n", bios_name);
exit(1);
}
if (filename) {
qemu_free(filename);
}
isa_bios_size = bios_size;
if (isa_bios_size > (128 * 1024))
isa_bios_size = 128 * 1024;
cpu_register_physical_memory(0x100000 - isa_bios_size,
isa_bios_size,
(bios_offset + bios_size - isa_bios_size) | IO_MEM_ROM);
option_rom_offset = qemu_ram_alloc(0x20000);
oprom_area_size = 0;
cpu_register_physical_memory(0xc0000, 0x20000, option_rom_offset);
if (using_vga) {
const char *vgabios_filename;
if (cirrus_vga_enabled) {
vgabios_filename = VGABIOS_CIRRUS_FILENAME;
} else {
vgabios_filename = VGABIOS_FILENAME;
}
oprom_area_size = load_option_rom(vgabios_filename, 0xc0000, 0xe0000);
}
if (oprom_area_size < 0x8000)
oprom_area_size = 0x8000;
if (linux_boot) {
load_linux(0xc0000 + oprom_area_size,
kernel_filename, initrd_filename, kernel_cmdline, below_4g_mem_size);
oprom_area_size += 2048;
}
for (i = 0; i < nb_option_roms; i++) {
oprom_area_size += load_option_rom(option_rom[i],
0xc0000 + oprom_area_size, 0xe0000);
}
cpu_register_physical_memory((uint32_t)(-bios_size),
bios_size, bios_offset | IO_MEM_ROM);
bochs_bios_init();
cpu_irq = qemu_allocate_irqs(pic_irq_request, NULL, 1);
i8259 = i8259_init(cpu_irq[0]);
ferr_irq = i8259[13];
if (pci_enabled) {
pci_bus = i440fx_init(&i440fx_state, i8259);
piix3_devfn = piix3_init(pci_bus, -1);
} else {
pci_bus = NULL;
}
register_ioport_write(0x80, 1, 1, ioport80_write, NULL);
register_ioport_write(0xf0, 1, 1, ioportF0_write, NULL);
if (cirrus_vga_enabled) {
if (pci_enabled) {
pci_cirrus_vga_init(pci_bus);
} else {
isa_cirrus_vga_init();
}
} else if (vmsvga_enabled) {
if (pci_enabled)
pci_vmsvga_init(pci_bus);
else
fprintf(stderr, "%s: vmware_vga: no PCI bus\n", __FUNCTION__);
} else if (std_vga_enabled) {
if (pci_enabled) {
pci_vga_init(pci_bus, 0, 0);
} else {
isa_vga_init();
}
}
rtc_state = rtc_init(0x70, i8259[8], 2000);
qemu_register_boot_set(pc_boot_set, rtc_state);
register_ioport_read(0x92, 1, 1, ioport92_read, NULL);
register_ioport_write(0x92, 1, 1, ioport92_write, NULL);
if (pci_enabled) {
ioapic = ioapic_init();
}
pit = pit_init(0x40, i8259[0]);
pcspk_init(pit);
if (!no_hpet) {
hpet_init(i8259);
}
if (pci_enabled) {
pic_set_alt_irq_func(isa_pic, ioapic_set_irq, ioapic);
}
for(i = 0; i < MAX_SERIAL_PORTS; i++) {
if (serial_hds[i]) {
serial_init(serial_io[i], i8259[serial_irq[i]], 115200,
serial_hds[i]);
}
}
for(i = 0; i < MAX_PARALLEL_PORTS; i++) {
if (parallel_hds[i]) {
parallel_init(parallel_io[i], i8259[parallel_irq[i]],
parallel_hds[i]);
}
}
watchdog_pc_init(pci_bus);
for(i = 0; i < nb_nics; i++) {
NICInfo *nd = &nd_table[i];
if (!pci_enabled || (nd->model && strcmp(nd->model, "ne2k_isa") == 0))
pc_init_ne2k_isa(nd, i8259);
else
pci_nic_init(pci_bus, nd, -1, "ne2k_pci");
}
qemu_system_hot_add_init();
if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
fprintf(stderr, "qemu: too many IDE bus\n");
exit(1);
}
for(i = 0; i < MAX_IDE_BUS * MAX_IDE_DEVS; i++) {
index = drive_get_index(IF_IDE, i / MAX_IDE_DEVS, i % MAX_IDE_DEVS);
if (index != -1)
hd[i] = drives_table[index].bdrv;
else
hd[i] = NULL;
}
if (pci_enabled) {
pci_piix3_ide_init(pci_bus, hd, piix3_devfn + 1, i8259);
} else {
for(i = 0; i < MAX_IDE_BUS; i++) {
isa_ide_init(ide_iobase[i], ide_iobase2[i], i8259[ide_irq[i]],
hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]);
}
}
i8042_init(i8259[1], i8259[12], 0x60);
DMA_init(0);
#ifdef HAS_AUDIO
audio_init(pci_enabled ? pci_bus : NULL, i8259);
#endif
for(i = 0; i < MAX_FD; i++) {
index = drive_get_index(IF_FLOPPY, 0, i);
if (index != -1)
fd[i] = drives_table[index].bdrv;
else
fd[i] = NULL;
}
floppy_controller = fdctrl_init(i8259[6], 2, 0, 0x3f0, fd);
cmos_init(below_4g_mem_size, above_4g_mem_size, boot_device, hd);
if (pci_enabled && usb_enabled) {
usb_uhci_piix3_init(pci_bus, piix3_devfn + 2);
}
if (pci_enabled && acpi_enabled) {
uint8_t *eeprom_buf = qemu_mallocz(8 * 256);
i2c_bus *smbus;
smbus = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100, i8259[9]);
for (i = 0; i < 8; i++) {
DeviceState *eeprom;
eeprom = qdev_create((BusState *)smbus, "smbus-eeprom");
qdev_set_prop_int(eeprom, "address", 0x50 + i);
qdev_set_prop_ptr(eeprom, "data", eeprom_buf + (i * 256));
qdev_init(eeprom);
}
}
if (i440fx_state) {
i440fx_init_memory_mappings(i440fx_state);
}
if (pci_enabled) {
int max_bus;
int bus;
max_bus = drive_get_max_bus(IF_SCSI);
for (bus = 0; bus <= max_bus; bus++) {
pci_create_simple(pci_bus, -1, "lsi53c895a");
}
}
if (pci_enabled) {
int index;
int unit_id = 0;
while ((index = drive_get_index(IF_VIRTIO, 0, unit_id)) != -1) {
pci_create_simple(pci_bus, -1, "virtio-blk-pci");
unit_id++;
}
}
if (pci_enabled && !no_virtio_balloon) {
pci_create_simple(pci_bus, -1, "virtio-balloon-pci");
}
if (pci_enabled) {
for(i = 0; i < MAX_VIRTIO_CONSOLES; i++) {
if (virtcon_hds[i]) {
pci_create_simple(pci_bus, -1, "virtio-console-pci");
}
}
}
}
| 1threat
|
Sql server view issue : i've ran the select query on a view to check it's count. but the select statement is running continuously and no result set is coming. i've verifued deadlocks and locks on tables etc.. and refreshed the view. but no use.
Any suggestions for me
| 0debug
|
static void init_timers(void)
{
init_get_clock();
rt_clock = qemu_new_clock(QEMU_TIMER_REALTIME);
vm_clock = qemu_new_clock(QEMU_TIMER_VIRTUAL);
}
| 1threat
|
static inline void yuv2rgbXinC(int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,
int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
uint8_t *dest, int dstW, int dstbpp)
{
if(dstbpp==32)
{
int i;
for(i=0; i<(dstW>>1); i++){
int j;
int Y1=0;
int Y2=0;
int U=0;
int V=0;
int Cb, Cr, Cg;
for(j=0; j<lumFilterSize; j++)
{
Y1 += lumSrc[j][2*i] * lumFilter[j];
Y2 += lumSrc[j][2*i+1] * lumFilter[j];
}
for(j=0; j<chrFilterSize; j++)
{
U += chrSrc[j][i] * chrFilter[j];
V += chrSrc[j][i+2048] * chrFilter[j];
}
Y1= clip_yuvtab_2568[ (Y1>>19) + 256 ];
Y2= clip_yuvtab_2568[ (Y2>>19) + 256 ];
U >>= 19;
V >>= 19;
Cb= clip_yuvtab_40cf[U+ 256];
Cg= clip_yuvtab_1a1e[V+ 256] + yuvtab_0c92[U+ 256];
Cr= clip_yuvtab_3343[V+ 256];
dest[8*i+0]=clip_table[((Y1 + Cb) >>13)];
dest[8*i+1]=clip_table[((Y1 + Cg) >>13)];
dest[8*i+2]=clip_table[((Y1 + Cr) >>13)];
dest[8*i+4]=clip_table[((Y2 + Cb) >>13)];
dest[8*i+5]=clip_table[((Y2 + Cg) >>13)];
dest[8*i+6]=clip_table[((Y2 + Cr) >>13)];
}
}
else if(dstbpp==24)
{
int i;
for(i=0; i<(dstW>>1); i++){
int j;
int Y1=0;
int Y2=0;
int U=0;
int V=0;
int Cb, Cr, Cg;
for(j=0; j<lumFilterSize; j++)
{
Y1 += lumSrc[j][2*i] * lumFilter[j];
Y2 += lumSrc[j][2*i+1] * lumFilter[j];
}
for(j=0; j<chrFilterSize; j++)
{
U += chrSrc[j][i] * chrFilter[j];
V += chrSrc[j][i+2048] * chrFilter[j];
}
Y1= clip_yuvtab_2568[ (Y1>>19) + 256 ];
Y2= clip_yuvtab_2568[ (Y2>>19) + 256 ];
U >>= 19;
V >>= 19;
Cb= clip_yuvtab_40cf[U+ 256];
Cg= clip_yuvtab_1a1e[V+ 256] + yuvtab_0c92[U+ 256];
Cr= clip_yuvtab_3343[V+ 256];
dest[0]=clip_table[((Y1 + Cb) >>13)];
dest[1]=clip_table[((Y1 + Cg) >>13)];
dest[2]=clip_table[((Y1 + Cr) >>13)];
dest[3]=clip_table[((Y2 + Cb) >>13)];
dest[4]=clip_table[((Y2 + Cg) >>13)];
dest[5]=clip_table[((Y2 + Cr) >>13)];
dest+=6;
}
}
else if(dstbpp==16)
{
int i;
for(i=0; i<(dstW>>1); i++){
int j;
int Y1=0;
int Y2=0;
int U=0;
int V=0;
int Cb, Cr, Cg;
for(j=0; j<lumFilterSize; j++)
{
Y1 += lumSrc[j][2*i] * lumFilter[j];
Y2 += lumSrc[j][2*i+1] * lumFilter[j];
}
for(j=0; j<chrFilterSize; j++)
{
U += chrSrc[j][i] * chrFilter[j];
V += chrSrc[j][i+2048] * chrFilter[j];
}
Y1= clip_yuvtab_2568[ (Y1>>19) + 256 ];
Y2= clip_yuvtab_2568[ (Y2>>19) + 256 ];
U >>= 19;
V >>= 19;
Cb= clip_yuvtab_40cf[U+ 256];
Cg= clip_yuvtab_1a1e[V+ 256] + yuvtab_0c92[U+ 256];
Cr= clip_yuvtab_3343[V+ 256];
((uint16_t*)dest)[2*i] =
clip_table16b[(Y1 + Cb) >>13] |
clip_table16g[(Y1 + Cg) >>13] |
clip_table16r[(Y1 + Cr) >>13];
((uint16_t*)dest)[2*i+1] =
clip_table16b[(Y2 + Cb) >>13] |
clip_table16g[(Y2 + Cg) >>13] |
clip_table16r[(Y2 + Cr) >>13];
}
}
else if(dstbpp==15)
{
int i;
for(i=0; i<(dstW>>1); i++){
int j;
int Y1=0;
int Y2=0;
int U=0;
int V=0;
int Cb, Cr, Cg;
for(j=0; j<lumFilterSize; j++)
{
Y1 += lumSrc[j][2*i] * lumFilter[j];
Y2 += lumSrc[j][2*i+1] * lumFilter[j];
}
for(j=0; j<chrFilterSize; j++)
{
U += chrSrc[j][i] * chrFilter[j];
V += chrSrc[j][i+2048] * chrFilter[j];
}
Y1= clip_yuvtab_2568[ (Y1>>19) + 256 ];
Y2= clip_yuvtab_2568[ (Y2>>19) + 256 ];
U >>= 19;
V >>= 19;
Cb= clip_yuvtab_40cf[U+ 256];
Cg= clip_yuvtab_1a1e[V+ 256] + yuvtab_0c92[U+ 256];
Cr= clip_yuvtab_3343[V+ 256];
((uint16_t*)dest)[2*i] =
clip_table15b[(Y1 + Cb) >>13] |
clip_table15g[(Y1 + Cg) >>13] |
clip_table15r[(Y1 + Cr) >>13];
((uint16_t*)dest)[2*i+1] =
clip_table15b[(Y2 + Cb) >>13] |
clip_table15g[(Y2 + Cg) >>13] |
clip_table15r[(Y2 + Cr) >>13];
}
}
}
| 1threat
|
C++ String Comparison "Good Luck" > "Good Bye" : <p>I am comparing two strings "Good Luck" > "Good Bye" in c++. Shouldn't the boolean result be true? The 'L' is greater than the 'B' The blank space between the words is one whitespace. </p>
<p>However, I am getting false with run the code.</p>
<p>Do you know why? Below is my code. </p>
<pre><code>#include <iostream>
using namespace std;
int main()
{
bool result = "Good Luck" > "Good Bye!";
cout << result;
return 0;
}
</code></pre>
| 0debug
|
static void zynq_init(MachineState *machine)
{
ram_addr_t ram_size = machine->ram_size;
const char *cpu_model = machine->cpu_model;
const char *kernel_filename = machine->kernel_filename;
const char *kernel_cmdline = machine->kernel_cmdline;
const char *initrd_filename = machine->initrd_filename;
ObjectClass *cpu_oc;
ARMCPU *cpu;
MemoryRegion *address_space_mem = get_system_memory();
MemoryRegion *ext_ram = g_new(MemoryRegion, 1);
MemoryRegion *ocm_ram = g_new(MemoryRegion, 1);
DeviceState *dev;
SysBusDevice *busdev;
qemu_irq pic[64];
Error *err = NULL;
int n;
if (!cpu_model) {
cpu_model = "cortex-a9";
}
cpu_oc = cpu_class_by_name(TYPE_ARM_CPU, cpu_model);
cpu = ARM_CPU(object_new(object_class_get_name(cpu_oc)));
object_property_set_int(OBJECT(cpu), ZYNQ_BOARD_MIDR, "midr", &err);
if (err) {
error_report("%s", error_get_pretty(err));
exit(1);
}
object_property_set_int(OBJECT(cpu), MPCORE_PERIPHBASE, "reset-cbar", &err);
if (err) {
error_report("%s", error_get_pretty(err));
exit(1);
}
object_property_set_bool(OBJECT(cpu), true, "realized", &err);
if (err) {
error_report("%s", error_get_pretty(err));
exit(1);
}
if (ram_size > 0x80000000) {
ram_size = 0x80000000;
}
memory_region_init_ram(ext_ram, NULL, "zynq.ext_ram", ram_size,
&error_abort);
vmstate_register_ram_global(ext_ram);
memory_region_add_subregion(address_space_mem, 0, ext_ram);
memory_region_init_ram(ocm_ram, NULL, "zynq.ocm_ram", 256 << 10,
&error_abort);
vmstate_register_ram_global(ocm_ram);
memory_region_add_subregion(address_space_mem, 0xFFFC0000, ocm_ram);
DriveInfo *dinfo = drive_get(IF_PFLASH, 0, 0);
pflash_cfi02_register(0xe2000000, NULL, "zynq.pflash", FLASH_SIZE,
dinfo ? blk_bs(blk_by_legacy_dinfo(dinfo)) : NULL,
FLASH_SECTOR_SIZE,
FLASH_SIZE/FLASH_SECTOR_SIZE, 1,
1, 0x0066, 0x0022, 0x0000, 0x0000, 0x0555, 0x2aa,
0);
dev = qdev_create(NULL, "xilinx,zynq_slcr");
qdev_init_nofail(dev);
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0xF8000000);
dev = qdev_create(NULL, "a9mpcore_priv");
qdev_prop_set_uint32(dev, "num-cpu", 1);
qdev_init_nofail(dev);
busdev = SYS_BUS_DEVICE(dev);
sysbus_mmio_map(busdev, 0, MPCORE_PERIPHBASE);
sysbus_connect_irq(busdev, 0,
qdev_get_gpio_in(DEVICE(cpu), ARM_CPU_IRQ));
for (n = 0; n < 64; n++) {
pic[n] = qdev_get_gpio_in(dev, n);
}
zynq_init_spi_flashes(0xE0006000, pic[58-IRQ_OFFSET], false);
zynq_init_spi_flashes(0xE0007000, pic[81-IRQ_OFFSET], false);
zynq_init_spi_flashes(0xE000D000, pic[51-IRQ_OFFSET], true);
sysbus_create_simple("xlnx,ps7-usb", 0xE0002000, pic[53-IRQ_OFFSET]);
sysbus_create_simple("xlnx,ps7-usb", 0xE0003000, pic[76-IRQ_OFFSET]);
sysbus_create_simple("cadence_uart", 0xE0000000, pic[59-IRQ_OFFSET]);
sysbus_create_simple("cadence_uart", 0xE0001000, pic[82-IRQ_OFFSET]);
sysbus_create_varargs("cadence_ttc", 0xF8001000,
pic[42-IRQ_OFFSET], pic[43-IRQ_OFFSET], pic[44-IRQ_OFFSET], NULL);
sysbus_create_varargs("cadence_ttc", 0xF8002000,
pic[69-IRQ_OFFSET], pic[70-IRQ_OFFSET], pic[71-IRQ_OFFSET], NULL);
gem_init(&nd_table[0], 0xE000B000, pic[54-IRQ_OFFSET]);
gem_init(&nd_table[1], 0xE000C000, pic[77-IRQ_OFFSET]);
dev = qdev_create(NULL, "generic-sdhci");
qdev_init_nofail(dev);
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0xE0100000);
sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[56-IRQ_OFFSET]);
dev = qdev_create(NULL, "generic-sdhci");
qdev_init_nofail(dev);
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0xE0101000);
sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[79-IRQ_OFFSET]);
dev = qdev_create(NULL, "pl330");
qdev_prop_set_uint8(dev, "num_chnls", 8);
qdev_prop_set_uint8(dev, "num_periph_req", 4);
qdev_prop_set_uint8(dev, "num_events", 16);
qdev_prop_set_uint8(dev, "data_width", 64);
qdev_prop_set_uint8(dev, "wr_cap", 8);
qdev_prop_set_uint8(dev, "wr_q_dep", 16);
qdev_prop_set_uint8(dev, "rd_cap", 8);
qdev_prop_set_uint8(dev, "rd_q_dep", 16);
qdev_prop_set_uint16(dev, "data_buffer_dep", 256);
qdev_init_nofail(dev);
busdev = SYS_BUS_DEVICE(dev);
sysbus_mmio_map(busdev, 0, 0xF8003000);
sysbus_connect_irq(busdev, 0, pic[45-IRQ_OFFSET]);
for (n = 0; n < 8; ++n) {
sysbus_connect_irq(busdev, n + 1, pic[dma_irqs[n] - IRQ_OFFSET]);
}
zynq_binfo.ram_size = ram_size;
zynq_binfo.kernel_filename = kernel_filename;
zynq_binfo.kernel_cmdline = kernel_cmdline;
zynq_binfo.initrd_filename = initrd_filename;
zynq_binfo.nb_cpus = 1;
zynq_binfo.board_id = 0xd32;
zynq_binfo.loader_start = 0;
arm_load_kernel(ARM_CPU(first_cpu), &zynq_binfo);
}
| 1threat
|
static int handle_instruction(CPUState *env, struct kvm_run *run)
{
unsigned int ipa0 = (run->s390_sieic.ipa & 0xff00);
uint8_t ipa1 = run->s390_sieic.ipa & 0x00ff;
int ipb_code = (run->s390_sieic.ipb & 0x0fff0000) >> 16;
int r = -1;
dprintf("handle_instruction 0x%x 0x%x\n", run->s390_sieic.ipa, run->s390_sieic.ipb);
switch (ipa0) {
case IPA0_PRIV:
r = handle_priv(env, run, ipa1);
break;
case IPA0_DIAG:
r = handle_diag(env, run, ipb_code);
break;
case IPA0_SIGP:
r = handle_sigp(env, run, ipa1);
break;
}
if (r < 0) {
enter_pgmcheck(env, 0x0001);
}
return r;
}
| 1threat
|
How do I create an executable fat jar with Gradle with implementation dependencies : <p>I've got a simple project in Gradle 4.6 and would like to make an executable jar of it. I've tried <code>shadow</code>, <code>gradle-fatjar-plugin</code>, <code>gradle-one-jar</code>, <code>spring-boot-gradle-plugin</code> plugins but neither of them adds my dependencies declared as <code>implementation</code> (I don't have any <code>compile</code> ones). It works with <code>compile</code> e.g. for <code>gradle-one-jar</code> plugin but I would like to have <code>implementation</code> dependencies.</p>
<p>Thank you very much!</p>
| 0debug
|
All jupyter contrib nbextensions are marked as possibly incompatible : <p>I have just installed <code>jupyter_contrib_nbextensions</code> by:</p>
<pre><code>pip install jupyter_contrib_nbextensions
jupyter contrib nbextension install --user
</code></pre>
<p>When I open a jupyter notebook and navigate to <strong><em>Edit -> nbextensions config</em></strong>, I see the below screen:</p>
<p><a href="https://i.stack.imgur.com/ClDy1.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ClDy1.png" alt="nbextensions config"></a></p>
<p>All extensions are marked as "<strong><em>possibly incompatible</em></strong>". A solution is to uncheck the option: "<strong><em>disable configuration for nbextensions without explicit compatibility</em></strong>". But is it safe? Any ideas why the <code>nbextensions</code> are incombatible?</p>
<p>My package versions are:</p>
<pre><code>jupyter==1.0.0
notebook==6.0.1
jupyter-contrib-nbextensions==0.5.1
</code></pre>
| 0debug
|
Change background colou of active div : I have created a drop down menu.I wanna change the background color of active span tag, which contains the arrow image. And on click of any dropdown option, it should close and that option should come in the menu.
example:- if i click on option 'DROP ITEM 2' option , it should replace the 'ITEM NAME'.
<div class="custom-table brand-portal-panel">
<div class="custom-table-row">
<div class="custom-table-cell"><div class="table-cell-data"><input type="checkbox" /></div></div>
<div class="custom-table-cell"><div class="table-cell-data"><ul class="nav">
<li class="button-dropdown">
<a href="javascript:void(0)" class="dropdown-toggle">
ITEM name <span id="rotate_sign" class="sign_rotate"><img src="images/dropdown.png" alt="dropdown"/></span>
</a>
<ul class="dropdown_menu">
<li>
<a href="#" class="dropdown_items">
Drop Item 1
</a>
</li>
<li>
<a href="#" class="dropdown_items">
Drop Item 2
</a>
</li>
<li>
<a href="#" class="dropdown_items border_bottom_none">
Drop Item 3
</a>
</li>
</ul>
</li>
</ul></div></div>
<div class="custom-table-cell"><div class="table-cell-data"><ul class="nav">
<li class="button-dropdown">
<a href="javascript:void(0)" class="dropdown-toggle">
DATE IMPORTED <span id="rotate_sign" class="sign_rotate"><img src="images/dropdown.png" alt="dropdown"/></span>
</a>
<ul class="dropdown_menu">
<li>
<a href="#" class="dropdown_items">
Drop Item 1
</a>
</li>
<li>
<a href="#" class="dropdown_items">
Drop Item 2
</a>
</li>
<li>
<a href="#" class="dropdown_items border_bottom_none">
Drop Item 3
</a>
</li>
</ul>
</li>
</ul></div></div>
<div class="custom-table-cell"><div class="table-cell-data"><ul class="nav">
<li class="button-dropdown">
<a href="javascript:void(0)" class="dropdown-toggle">
CATOGERY <span id="rotate_sign" class="sign_rotate"><img src="images/dropdown.png" alt="dropdown"/></span>
</a>
<ul class="dropdown_menu">
<li>
<a href="#" class="dropdown_items">
Drop Item 1
</a>
</li>
<li>
<a href="#" class="dropdown_items">
Drop Item 2
</a>
</li>
<li>
<a href="#" class="dropdown_items border_bottom_none">
Drop Item 3
</a>
</li>
</ul>
</li>
</ul></div></div>
<div class="custom-table-cell"><div class="table-cell-data right-align"><ul class="nav">
<li class="button-dropdown">
<a href="javascript:void(0)" class="dropdown-toggle">
STATUS <span id="rotate_sign" class="sign_rotate"><img src="images/dropdown.png" alt="dropdown"/></span>
</a>
<ul class="dropdown_menu">
<li>
<a href="#" class="dropdown_items">
Drop Item 1
</a>
</li>
<li>
<a href="#" class="dropdown_items">
Drop Item 2
</a>
</li>
<li>
<a href="#" class="dropdown_items border_bottom_none">
Drop Item 3
</a>
</li>
</ul>
</li>
</ul></div></div>
</div>
</div>
/*css*/
* {
box-sizing: border-box;
}
body {
background-color: #eee;
text-align: center;
padding-top: 50px;
}
.nav {
display: block;
font-family: 'PT Sans Caption', sans-serif;
text-transform: uppercase;
margin: 0;
padding: 0;
padding: 5px 0px 0px 0px;
}
.nav li {
display: inline-block;
list-style: none;
width: 100%;
}
.nav .button-dropdown {
position: relative;
}
.nav .button-dropdown .dropdown-toggle {
display: block;
padding: 0px 0px 0px 20px;
text-decoration: none;
font-family: 'PT Sans Caption', sans-serif;
font-size: 7.5px;
font-weight: bold;
line-height: 2.33;
letter-spacing: 0px;
text-align: center;
color: #666667;
}
.nav .button-dropdown .dropdown_items {
display: block;
padding: 10px 2px;
text-decoration: none;
font-family: 'PT Sans Caption', sans-serif;
font-size: 7.5px;
font-weight: bold;
line-height: 2.33;
letter-spacing: 0px;
text-align: center;
color: #666667;
border-bottom: solid 0.5px #e4e4e4;
}
.border_bottom_none{
border-bottom: solid 1px #ffffff;
}
.nav li a span {
display: inline-block;
margin-left: 5px;
font-size: 10px;
color: #999;
height: 26.5px;
background-color: #f3f3f3;
}
.dropdown_menu {
z-index: 1000;
float: left;
/*min-width: 160px;*/
font-size: 14px;
list-style: none;
border-radius: 1px;
}
.nav li .dropdown_menu {
display: none;
position: absolute;
left: 0;
padding: 0;
margin: 0;
text-align: left;
width: 100%;
background-color: #f3f3f3;
box-shadow: -1px 1px 0.5px 0 rgba(200, 200, 200, 0.5);
}
.nav li .dropdown_menu.active {
display: block;
}
.nav li .dropdown_menu a {
width: 90%;
margin: auto;
}
div.custom-table{
display: table;
width: 100%;
}
div.custom-table-row{
display: table-row
}
div.custom-table-cell{
display: table-cell;
padding: 3px;
}
.custom-table-row > .custom-table-cell{
height: 35px;
padding-bottom: 0px;
}
div.table-cell-data{
position: relative;
height: 100%;
width: 100%;
display: flex;
align-items: center;
justify-content: flex-start;
padding: 5px 0;
}
div.table-cell-data.right-align{
justify-content: flex-end;
}
div.custom-table.brand-portal-panel div.custom-table-row div.custom-table-cell{
border-bottom: 1px solid #cccccc;
}
div.custom-table.brand-portal-panel div.custom-table-row div.custom-table-cell img.brand-icon{
width: 32px;
height: 32px;
margin: 0 5px;
margin-right:10px;
}
div.custom-table.brand-portal-panel div.custom-table-row div.custom-table-cell:first-child{
min-width: 5%;
white-space: nowrap;
border: none;
vertical-align: middle;
}
div.custom-table.brand-portal-panel div.custom-table-row div.custom-table-cell:nth-child(2){
width: 45%;
}
div.custom-table.brand-portal-panel div.custom-table-row div.custom-table-cell:nth-child(3){
width: 25%;
}
div.custom-table.brand-portal-panel div.custom-table-row div.custom-table-cell:nth-child(4){
width: 15%;
}
div.custom-table.brand-portal-panel div.custom-table-row div.custom-table-cell:nth-child(5){
width: 10%;
}
.sign_rotate{
height: 20px;
width: 19px;
}
.sign_rotate img{
width: 100%;
-ms-transform: rotate(90deg);
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
}
/* js code */
<script>
jQuery(document).ready(function (e) {
function t(t) {
e(t).bind("click", function (t) {
t.preventDefault();
e(this).parent().fadeOut()
})
}
e(".dropdown-toggle").click(function () {
$("#rotate_sign").css({'background-color':'green' });
var t = e(this).parents(".button-dropdown").children(".dropdown_menu").is(":hidden");
e(".button-dropdown .dropdown_menu").hide();
e(".button-dropdown .dropdown-toggle").removeClass("active");
if (t) {
e(this).parents(".button-dropdown").children(".dropdown_menu").toggle().parents(".button-dropdown").children(".dropdown-toggle").addClass("active")
}
});
e(document).bind("click", function (t) {
var n = e(t.target);
if (!n.parents().hasClass("button-dropdown"))
e(".button-dropdown .dropdown_menu").hide();
});
e(document).bind("click", function (t) {
var n = e(t.target);
if (!n.parents().hasClass("button-dropdown"))
e(".button-dropdown .dropdown-toggle").removeClass("active");
})
});
</script>
| 0debug
|
Change text-color on div :hover : <p>I can't seem to find how to change the text-color from black to white whenever I hover over the schedule over here <a href="http://apavtcongresso.staging.wpengine.com/" rel="nofollow noreferrer">http://apavtcongresso.staging.wpengine.com/</a></p>
<p>Scroll down to "PROGRAMA" and you'll find the schedule, it has a couple of tabs named "Day - 01, Day - 02" etc, inside there's black text that I wish to change to white whenever I hover over the tabs. I've already changed the :active color but I can't find the right classes to customize the css of hover, any help please?</p>
<p>Thanks.</p>
| 0debug
|
null value not detected. Bypass if condition java : <p><a href="https://i.stack.imgur.com/zU9ry.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zU9ry.jpg" alt="enter image description here"></a></p>
<p>As seen in the image, expiryTime is printed out as null as shown in the console. However, it bypass my if condition and i even printed out (expiryTime == null) and (expiryTime == "null"). However, it is giving me as false. Why is this possible?</p>
| 0debug
|
AngularJS 1.5 error bootstrap IBM Mobilefirst : <p>I seem to have problems combining an MFP hybrid (no cordova) application and angular 1.5. The same application with angular 1.4.9 works fine, but if I switch to angular1.5 then i get this error:</p>
<pre><code>Error: [$injector:modulerr] Failed to instantiate module ng due to:
TypeError: Cannot set property 'aHrefSanitizationWhitelist' of null
at $$SanitizeUriProvider (http://localhost:10080/Hybrid/apps/services/preview/HelloWorld/android/1.0/default/vendor/angular5.js:17272:35)
at new <anonymous> (http://localhost:10080/Hybrid/apps/services/preview/HelloWorld/android/1.0/default/worklight/worklight.js:1033:23)
at Object.instantiate (http://localhost:10080/Hybrid/apps/services/preview/HelloWorld/android/1.0/default/vendor/angular5.js:4621:14)
at provider (http://localhost:10080/Hybrid/apps/services/preview/HelloWorld/android/1.0/default/vendor/angular5.js:4435:36)
at http://localhost:10080/Hybrid/apps/services/preview/HelloWorld/android/1.0/default/vendor/angular5.js:367:32
at forEach (http://localhost:10080/Hybrid/apps/services/preview/HelloWorld/android/1.0/default/vendor/angular5.js:337:20)
at Object.provider (http://localhost:10080/Hybrid/apps/services/preview/HelloWorld/android/1.0/default/vendor/angular5.js:4425:9)
at ngModule (http://localhost:10080/Hybrid/apps/services/preview/HelloWorld/android/1.0/default/vendor/angular5.js:2476:16)
at Object.invoke (http://localhost:10080/Hybrid/apps/services/preview/HelloWorld/android/1.0/default/vendor/angular5.js:4606:19)
at runInvokeQueue (http://localhost:10080/Hybrid/apps/services/preview/HelloWorld/android/1.0/default/vendor/angular5.js:4499:35)
http://errors.angularjs.org/1.5.0/$injector/modulerr?p0=ng&p1=TypeError%3A%…%2FHelloWorld%2Fandroid%2F1.0%2Fdefault%2Fvendor%2Fangular5.js%3A4499%3A35)
</code></pre>
<p>anyone a clue what it could be?</p>
| 0debug
|
Color picker in angular js : <p>I want to implement color picker in angular JS and below is the sample,</p>
<p><a href="http://screencast.com/t/A7q6rTN5e" rel="nofollow">http://screencast.com/t/A7q6rTN5e</a></p>
<p>Can anyone suggest how to implement this in angular js?</p>
| 0debug
|
GraphicsMagick: toBuffer() Stream yields empty buffer : <p>I am trying to read a file into a buffer, resize it and then write it to disk using the following example code:</p>
<pre><code>function processImage(data) {
gm(data, 'test.jpg')
.resize('300x300')
.background('white')
.flatten()
.setFormat('jpg')
.toBuffer(function(err, buffer) {
if (err) {
throw err;
} else {
fs.writeFile('asd.jpg', buffer);
}
});
}
</code></pre>
<p>However, this generates an error <code>Error: Stream yields empty buffer</code>. I have played around, used imageMagick and graphicsMagick, still the same. </p>
<p>If i substitute<br>
<code>toBuffer(...</code><br>
with<br>
<code>write('asd.jpg', function(err) ...</code></p>
<p>it actually writes a proper file.</p>
<p><strong>EDIT</strong> While writing this question I found the solution, see reply</p>
| 0debug
|
What is the meaning of bind = True keyword in celery? : <p>What is the meaning of <code>bind=True</code> in below <strong>celery</strong> code? When to use it and when not?</p>
<pre><code>@app.task(bind=True)
def send_twitter_status(self, oauth, tweet):
try:
twitter = Twitter(oauth)
twitter.update_status(tweet)
except (Twitter.FailWhaleError, Twitter.LoginError) as exc:
raise self.retry(exc=exc)
</code></pre>
| 0debug
|
static int migrate_fd_cleanup(MigrationState *s)
{
int ret = 0;
qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL);
if (s->file) {
DPRINTF("closing file\n");
if (qemu_fclose(s->file) != 0) {
ret = -1;
}
s->file = NULL;
} else {
if (s->mon) {
monitor_resume(s->mon);
}
}
if (s->fd != -1) {
close(s->fd);
s->fd = -1;
}
return ret;
}
| 1threat
|
how to create a alert box in android alternative presents? : <p><strong>Create an alert box that show alternative during application run</strong>
I want to alert box that appear even time when my app is open </p>
| 0debug
|
static int paf_vid_decode(AVCodecContext *avctx, void *data,
int *data_size, AVPacket *pkt)
{
PAFVideoDecContext *c = avctx->priv_data;
uint8_t code, *dst, *src, *end;
int i, frame, ret;
c->pic.reference = 3;
if ((ret = avctx->reget_buffer(avctx, &c->pic)) < 0)
return ret;
bytestream2_init(&c->gb, pkt->data, pkt->size);
code = bytestream2_get_byte(&c->gb);
if (code & 0x20) {
for (i = 0; i < 4; i++)
memset(c->frame[i], 0, c->frame_size);
memset(c->pic.data[1], 0, AVPALETTE_SIZE);
c->current_frame = 0;
c->pic.key_frame = 1;
c->pic.pict_type = AV_PICTURE_TYPE_I;
} else {
c->pic.key_frame = 0;
c->pic.pict_type = AV_PICTURE_TYPE_P;
}
if (code & 0x40) {
uint32_t *out = (uint32_t *)c->pic.data[1];
int index, count;
index = bytestream2_get_byte(&c->gb);
count = bytestream2_get_byte(&c->gb) + 1;
if (index + count > AVPALETTE_SIZE)
return AVERROR_INVALIDDATA;
if (bytestream2_get_bytes_left(&c->gb) < 3 * AVPALETTE_SIZE)
return AVERROR_INVALIDDATA;
out += index;
for (i = 0; i < count; i++) {
unsigned r, g, b;
r = bytestream2_get_byteu(&c->gb);
r = r << 2 | r >> 4;
g = bytestream2_get_byteu(&c->gb);
g = g << 2 | g >> 4;
b = bytestream2_get_byteu(&c->gb);
b = b << 2 | b >> 4;
*out++ = 0xFFU << 24 | r << 16 | g << 8 | b;
}
c->pic.palette_has_changed = 1;
}
switch (code & 0x0F) {
case 0:
if ((ret = decode_0(avctx, code, pkt->data)) < 0)
return ret;
break;
case 1:
dst = c->frame[c->current_frame];
bytestream2_skip(&c->gb, 2);
if (bytestream2_get_bytes_left(&c->gb) < c->video_size)
return AVERROR_INVALIDDATA;
bytestream2_get_bufferu(&c->gb, dst, c->video_size);
break;
case 2:
frame = bytestream2_get_byte(&c->gb);
if (frame > 3)
return AVERROR_INVALIDDATA;
if (frame != c->current_frame)
memcpy(c->frame[c->current_frame], c->frame[frame], c->frame_size);
break;
case 4:
dst = c->frame[c->current_frame];
end = dst + c->video_size;
bytestream2_skip(&c->gb, 2);
while (dst < end) {
int8_t code;
int count;
if (bytestream2_get_bytes_left(&c->gb) < 2)
return AVERROR_INVALIDDATA;
code = bytestream2_get_byteu(&c->gb);
count = FFABS(code) + 1;
if (dst + count > end)
return AVERROR_INVALIDDATA;
if (code < 0)
memset(dst, bytestream2_get_byteu(&c->gb), count);
else
bytestream2_get_buffer(&c->gb, dst, count);
dst += count;
}
break;
default:
av_log_ask_for_sample(avctx, "unknown/invalid code\n");
return AVERROR_INVALIDDATA;
}
dst = c->pic.data[0];
src = c->frame[c->current_frame];
for (i = 0; i < avctx->height; i++) {
memcpy(dst, src, avctx->width);
dst += c->pic.linesize[0];
src += avctx->width;
}
c->current_frame = (c->current_frame + 1) & 3;
*data_size = sizeof(AVFrame);
*(AVFrame *)data = c->pic;
return pkt->size;
}
| 1threat
|
static int event_qdev_exit(DeviceState *qdev)
{
SCLPEvent *event = DO_UPCAST(SCLPEvent, qdev, qdev);
SCLPEventClass *child = SCLP_EVENT_GET_CLASS(event);
if (child->exit) {
child->exit(event);
}
return 0;
}
| 1threat
|
write_f(int argc, char **argv)
{
struct timeval t1, t2;
int Cflag = 0, pflag = 0, qflag = 0;
int c, cnt;
char *buf;
int64_t offset;
int count;
int total = 0;
int pattern = 0xcd;
while ((c = getopt(argc, argv, "CpP:q")) != EOF) {
switch (c) {
case 'C':
Cflag = 1;
break;
case 'p':
pflag = 1;
break;
case 'P':
pattern = atoi(optarg);
break;
case 'q':
qflag = 1;
break;
default:
return command_usage(&write_cmd);
}
}
if (optind != argc - 2)
return command_usage(&write_cmd);
offset = cvtnum(argv[optind]);
if (offset < 0) {
printf("non-numeric length argument -- %s\n", argv[optind]);
return 0;
}
optind++;
count = cvtnum(argv[optind]);
if (count < 0) {
printf("non-numeric length argument -- %s\n", argv[optind]);
return 0;
}
if (!pflag) {
if (offset & 0x1ff) {
printf("offset %lld is not sector aligned\n",
(long long)offset);
return 0;
}
if (count & 0x1ff) {
printf("count %d is not sector aligned\n",
count);
return 0;
}
}
buf = qemu_io_alloc(count, pattern);
gettimeofday(&t1, NULL);
if (pflag)
cnt = do_pwrite(buf, offset, count, &total);
else
cnt = do_write(buf, offset, count, &total);
gettimeofday(&t2, NULL);
if (cnt < 0) {
printf("write failed: %s\n", strerror(-cnt));
return 0;
}
if (qflag)
return 0;
t2 = tsub(t2, t1);
print_report("wrote", &t2, offset, count, total, cnt, Cflag);
qemu_io_free(buf);
return 0;
}
| 1threat
|
How to write not in query in cakephp find : I have created one sql sub query which was running perfectly.
SELECT o.*, u.*,OD.* FROM orders o LEFT JOIN order_details OD on o.id = OD.order_id LEFT JOIN users u ON o.user_id = u.id WHERE o.order_status = 1 AND o.id NOT IN (SELECT r.order_id FROM order_rejected_details r WHERE r.courier_id = $courierId) order by o.id desc
Now my question is How to write above query with not in condition in cakephp.
plz help me to write this with cakephp find..
| 0debug
|
static int flac_encode_frame(AVCodecContext *avctx, uint8_t *frame,
int buf_size, void *data)
{
FlacEncodeContext *s;
const int16_t *samples = data;
int frame_bytes, out_bytes;
s = avctx->priv_data;
if (!data) {
s->max_framesize = s->max_encoded_framesize;
av_md5_final(s->md5ctx, s->md5sum);
write_streaminfo(s, avctx->extradata);
return 0;
}
if (avctx->frame_size < s->frame.blocksize) {
s->max_framesize = ff_flac_get_max_frame_size(avctx->frame_size,
s->channels, 16);
}
init_frame(s);
copy_samples(s, samples);
channel_decorrelation(s);
frame_bytes = encode_frame(s);
if (buf_size < frame_bytes) {
av_log(avctx, AV_LOG_ERROR, "output buffer too small\n");
return 0;
}
out_bytes = write_frame(s, frame, buf_size);
if (out_bytes > s->max_framesize) {
s->frame.verbatim_only = 1;
frame_bytes = encode_frame(s);
if (buf_size < frame_bytes) {
av_log(avctx, AV_LOG_ERROR, "output buffer too small\n");
return 0;
}
out_bytes = write_frame(s, frame, buf_size);
}
s->frame_count++;
avctx->coded_frame->pts = s->sample_count;
s->sample_count += avctx->frame_size;
update_md5_sum(s, samples);
if (out_bytes > s->max_encoded_framesize)
s->max_encoded_framesize = out_bytes;
if (out_bytes < s->min_framesize)
s->min_framesize = out_bytes;
return out_bytes;
}
| 1threat
|
def extract_freq(test_list):
res = len(list(set(tuple(sorted(sub)) for sub in test_list)))
return (res)
| 0debug
|
How to make http request using desktop browser in Swift : <p>is there a good example to open up a link on Chrome on Mac os x desktop using Swift language? i found NSWorkspace example, is that the same as making an http request</p>
| 0debug
|
static int usb_serial_handle_data(USBDevice *dev, USBPacket *p)
{
USBSerialState *s = (USBSerialState *)dev;
int i, ret = 0;
uint8_t devep = p->devep;
struct iovec *iov;
uint8_t header[2];
int first_len, len;
switch (p->pid) {
case USB_TOKEN_OUT:
if (devep != 2)
goto fail;
for (i = 0; i < p->iov.niov; i++) {
iov = p->iov.iov + i;
qemu_chr_fe_write(s->cs, iov->iov_base, iov->iov_len);
}
break;
case USB_TOKEN_IN:
if (devep != 1)
goto fail;
first_len = RECV_BUF - s->recv_ptr;
len = p->iov.size;
if (len <= 2) {
ret = USB_RET_NAK;
break;
}
header[0] = usb_get_modem_lines(s) | 1;
if (s->event_trigger && s->event_trigger & FTDI_BI) {
s->event_trigger &= ~FTDI_BI;
header[1] = FTDI_BI;
usb_packet_copy(p, header, 2);
ret = 2;
break;
} else {
header[1] = 0;
}
len -= 2;
if (len > s->recv_used)
len = s->recv_used;
if (!len) {
ret = USB_RET_NAK;
break;
}
if (first_len > len)
first_len = len;
usb_packet_copy(p, header, 2);
usb_packet_copy(p, s->recv_buf + s->recv_ptr, first_len);
if (len > first_len)
usb_packet_copy(p, s->recv_buf, len - first_len);
s->recv_used -= len;
s->recv_ptr = (s->recv_ptr + len) % RECV_BUF;
ret = len + 2;
break;
default:
DPRINTF("Bad token\n");
fail:
ret = USB_RET_STALL;
break;
}
return ret;
}
| 1threat
|
Is it possible to store the value from a populated dropdown list in HTML/php and store it again into another table? : I have 7 populated dropdown lists and I want it's values to be stored again into another table is even possible. How do I do it?
| 0debug
|
static uint8_t *advance_line(uint8_t *start, uint8_t *line,
int stride, int *y, int h, int interleave)
{
*y += interleave;
if (*y < h) {
return line + interleave * stride;
} else {
*y = (*y + 1) & (interleave - 1);
if (*y) {
return start + *y * stride;
} else {
return NULL;
}
}
}
| 1threat
|
Can I run Windows containers on Docker Desktop for Mac? : <p>I want to be able to run Windows Docker Containers on my Mac, it seems this was sort of supported using Docker Toolbox
<a href="https://stackoverflow.com/questions/45380972/how-can-i-run-a-docker-windows-container-on-osx">How can I run a docker windows container on osx?</a></p>
<p>But it seems that this is now deprecated and we should be using Docker Desktop now. </p>
<p>Docker Desktop has a better and New Hypervisor called HyperKit instead of Virtual Box <a href="https://docs.docker.com/docker-for-mac/docker-toolbox/" rel="noreferrer">https://docs.docker.com/docker-for-mac/docker-toolbox/</a></p>
<p>Docker toolbox allowed starting Windows Containers using VirtualBox, so not sure if that mean's that this is still possible? </p>
<p>I have found a reference to putting Docker Desktop into "Windows Container Mode" here <a href="https://www.clearpeople.com/insights/blog/2018/june/sitecore-demo-in-a-docker-container" rel="noreferrer">https://www.clearpeople.com/insights/blog/2018/june/sitecore-demo-in-a-docker-container</a></p>
<p>But I cannot find anywhere to enable this, any help or insight would be very much appreciated.</p>
| 0debug
|
AWS Free Tier Instances - Running two instances : <p>Can I run a EC2, t2.micro instance & a RDS db.t2.micro instance, parallel & continuously a whole month ?
Or is it I can only run one of them ?</p>
<p>I know both of them have 750 hours of up time available in the free tier. But I'm bit confused whether it is (EC2 OR RDS) or (EC2 & RDS) in the free tier.</p>
| 0debug
|
static int packet_alloc(AVBufferRef **buf, int size)
{
int ret;
if ((unsigned)size >= (unsigned)size + AV_INPUT_BUFFER_PADDING_SIZE)
return AVERROR(EINVAL);
ret = av_buffer_realloc(buf, size + AV_INPUT_BUFFER_PADDING_SIZE);
if (ret < 0)
return ret;
memset((*buf)->data + size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
return 0;
}
| 1threat
|
What does "|| [];" mean? : <p>What does <code>|| []</code> mean in the code below? Why might this be needed? </p>
<pre><code>getPair: function() {
return this.props.pair || [];
},
</code></pre>
| 0debug
|
css triangule with a curve : <p>I have this code to draw a triangule:</p>
<pre><code>.triangulo-equilatero-bottom {
width: 0;
height: 0;
border-right: 100px solid transparent;
border-top: 100px solid transparent;
border-left: 100px solid transparent;
border-bottom: 100px solid #f0ad4e;
}
</code></pre>
<p>But I would like to know how can I draw a curve like this image:</p>
<p><a href="https://i.stack.imgur.com/3tnj5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3tnj5.png" alt="enter image description here"></a></p>
<p>Any help ??</p>
| 0debug
|
How memory is allocated to object in java. : I have pojo containing 300 variable in it. I want to hold list of this pojo. There will always 150 field will be null which are not used.
Could you please let me will jvm will allocate memory to null fields. ? Will it be problematic for heap memory. ?
| 0debug
|
import cmath
def convert(numbers):
num = cmath.polar(numbers)
return (num)
| 0debug
|
void qemu_spice_display_init_common(SimpleSpiceDisplay *ssd)
{
qemu_mutex_init(&ssd->lock);
QTAILQ_INIT(&ssd->updates);
ssd->mouse_x = -1;
ssd->mouse_y = -1;
if (ssd->num_surfaces == 0) {
ssd->num_surfaces = 1024;
}
ssd->bufsize = (16 * 1024 * 1024);
ssd->buf = g_malloc(ssd->bufsize);
}
| 1threat
|
static void vga_screen_dump_blank(VGAState *s, const char *filename)
{
FILE *f;
unsigned int y, x, w, h;
w = s->last_scr_width * sizeof(uint32_t);
h = s->last_scr_height;
f = fopen(filename, "wb");
if (!f)
return;
fprintf(f, "P6\n%d %d\n%d\n", w, h, 255);
for (y = 0; y < h; y++) {
for (x = 0; x < w; x++) {
fputc(0, f);
}
}
fclose(f);
}
| 1threat
|
static int get_packetheader(NUTContext *nut, ByteIOContext *bc, int prefix_length)
{
int64_t start, size, last_size;
start= url_ftell(bc) - prefix_length;
if(start != nut->packet_start + nut->written_packet_size){
av_log(nut->avf, AV_LOG_ERROR, "get_packetheader called at weird position\n");
return -1;
}
size= get_v(bc);
last_size= get_v(bc);
if(nut->written_packet_size != last_size){
av_log(nut->avf, AV_LOG_ERROR, "packet size missmatch %d != %lld at %lld\n", nut->written_packet_size, last_size, start);
return -1;
}
nut->last_packet_start = nut->packet_start;
nut->packet_start = start;
nut->written_packet_size= size;
return size;
}
| 1threat
|
static void superh_cpu_class_init(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
CPUClass *cc = CPU_CLASS(oc);
SuperHCPUClass *scc = SUPERH_CPU_CLASS(oc);
scc->parent_realize = dc->realize;
dc->realize = superh_cpu_realizefn;
scc->parent_reset = cc->reset;
cc->reset = superh_cpu_reset;
cc->class_by_name = superh_cpu_class_by_name;
cc->has_work = superh_cpu_has_work;
cc->do_interrupt = superh_cpu_do_interrupt;
cc->cpu_exec_interrupt = superh_cpu_exec_interrupt;
cc->dump_state = superh_cpu_dump_state;
cc->set_pc = superh_cpu_set_pc;
cc->synchronize_from_tb = superh_cpu_synchronize_from_tb;
cc->gdb_read_register = superh_cpu_gdb_read_register;
cc->gdb_write_register = superh_cpu_gdb_write_register;
#ifdef CONFIG_USER_ONLY
cc->handle_mmu_fault = superh_cpu_handle_mmu_fault;
#else
cc->get_phys_page_debug = superh_cpu_get_phys_page_debug;
#endif
cc->disas_set_info = superh_cpu_disas_set_info;
cc->gdb_num_core_regs = 59;
dc->vmsd = &vmstate_sh_cpu;
dc->cannot_destroy_with_object_finalize_yet = true;
}
| 1threat
|
Finding duplicates in different lines of a text file c++ : I have a simple text file that looks like this:
1 3 0.5
1 5 0.5
3 5 0.5
2 3 0.5
2 4 0.5
3 4 0.5
3 6 0.5
3 5 0.5
6 5 0.5
7 6 0.5
7 8 0.5
6 8 0.5
4 6 1
7 5 1
The first number in the line is a node number for a graph, and the second number is the number of the node that is connected to the first. The third number is the weight of the edge. In this case there are two lines that 3 and 5 with a weight of .5 I would like to be able to merge these into just one line that has the connection for 3 and 5 but update the weight to be the sum of their weights (in this case 1).
I have tried reading every line into separate arrays but run into problems when the first and second node are the same, but in different order (3 5 and 5 3 are the same edge and their weights should be added together). I am also using a text file where there are sometimes up to 100 duplicates that all need to be added together and then have the other connections deleted and just have 1 updated one with the total sum.
I am having trouble understanding how to store all of this information, such as which lines to delete, and how to handle the case of the nodes being switched. I still think comparing arrays is the way to go I am just having trouble with it. Thank you for any feedback, and just let me know if I need to post any more information!
| 0debug
|
how can I make a triangle appear on the screen using OpenGL? : <p>I'm trying to make a triangle appear on the screen using OpenGL but when I run the code, a black screen appears</p>
<p>I am currently using a guide I found on the internet (here is the link: <a href="http://www.opengl-tutorial.org/beginners-tutorials/tutorial-2-the-first-triangle/" rel="nofollow noreferrer">http://www.opengl-tutorial.org/beginners-tutorials/tutorial-2-the-first-triangle/</a>).</p>
<p>this is the code :</p>
<pre><code>#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
int larghezza = 1024;
int altezza = 768;
int main (){
glewExperimental = true;
if (!glfwInit() )
{
fprintf (stderr, "non è stato possibile inizzializzare glfw\n");
return -1;
}
glfwWindowHint(GLFW_SAMPLES, 4);// 4x antialiasing
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR,4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);// utilizza OpenGL 4.1
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);//NON VOGLIO VECCHIE VERSIONI DI OPENGL
GLFWwindow* window; // crea una finestra
window = glfwCreateWindow(larghezza, altezza, "FINESTRA 1", NULL, NULL);
if (!window){
fprintf (stderr, "Non è stato possibile aprire la finestra!\n");
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window); //inizzializza GLEW
glewExperimental = true;
if (glewInit() != GLEW_OK){
fprintf (stderr, "non è stato possibile inizzializzare GLEW");
return -1;
}
glfwSetInputMode(window, GLFW_STICKY_KEYS, GL_TRUE);
do {
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(window);
glfwPollEvents();
}
while( glfwGetKey(window, GLFW_KEY_ESCAPE ) != GLFW_PRESS &&
glfwWindowShouldClose(window) == 0 );
GLuint VertexArrayID;
glGenVertexArrays(1, &VertexArrayID);
glBindVertexArray(VertexArrayID);
static const GLfloat g_vertex_buffer_data[] = {
-1.0f, -1.0f, 0.0f,
1.0f, -1.0f, 0.0f,
0.0f, 1.0f, 0.0f,
};
GLuint vertexbuffer;
// Generate 1 buffer, put the resulting identifier in vertexbuffer
glGenBuffers(1, &vertexbuffer);
// The following commands will talk about our 'vertexbuffer' buffer
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
// Give our vertices to OpenGL.
glBufferData(GL_ARRAY_BUFFER, sizeof(g_vertex_buffer_data), g_vertex_buffer_data, GL_STATIC_DRAW);
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
glVertexAttribPointer(
0, // attribute 0. No particular reason for 0, but must match the layout in the shader.
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
// Draw the triangle !
glDrawArrays(GL_TRIANGLES, 0, 3); // Starting from vertex 0; 3 vertices total -> 1 triangle
glDisableVertexAttribArray(0);
}
</code></pre>
<p>how can i fix it?</p>
| 0debug
|
static int decode_cell_data(Cell *cell, uint8_t *block, uint8_t *ref_block,
int pitch, int h_zoom, int v_zoom, int mode,
const vqEntry *delta[2], int swap_quads[2],
const uint8_t **data_ptr, const uint8_t *last_ptr)
{
int x, y, line, num_lines;
int rle_blocks = 0;
uint8_t code, *dst, *ref;
const vqEntry *delta_tab;
unsigned int dyad1, dyad2;
uint64_t pix64;
int skip_flag = 0, is_top_of_cell, is_first_row = 1;
int row_offset, blk_row_offset, line_offset;
row_offset = pitch;
blk_row_offset = (row_offset << (2 + v_zoom)) - (cell->width << 2);
line_offset = v_zoom ? row_offset : 0;
for (y = 0; y < cell->height; is_first_row = 0, y += 1 + v_zoom) {
for (x = 0; x < cell->width; x += 1 + h_zoom) {
ref = ref_block;
dst = block;
if (rle_blocks > 0) {
if (mode <= 4) {
RLE_BLOCK_COPY;
} else if (mode == 10 && !cell->mv_ptr) {
RLE_BLOCK_COPY_8;
}
rle_blocks--;
} else {
for (line = 0; line < 4;) {
num_lines = 1;
is_top_of_cell = is_first_row && !line;
if (mode <= 4)
delta_tab = delta[line & 1];
else
delta_tab = delta[1];
BUFFER_PRECHECK;
code = bytestream_get_byte(data_ptr);
if (code < 248) {
if (code < delta_tab->num_dyads) {
BUFFER_PRECHECK;
dyad1 = bytestream_get_byte(data_ptr);
dyad2 = code;
if (dyad1 >= delta_tab->num_dyads || dyad1 >= 248)
} else {
code -= delta_tab->num_dyads;
dyad1 = code / delta_tab->quad_exp;
dyad2 = code % delta_tab->quad_exp;
if (swap_quads[line & 1])
FFSWAP(unsigned int, dyad1, dyad2);
}
if (mode <= 4) {
APPLY_DELTA_4;
} else if (mode == 10 && !cell->mv_ptr) {
APPLY_DELTA_8;
} else {
APPLY_DELTA_1011_INTER;
}
} else {
switch (code) {
case RLE_ESC_FC:
skip_flag = 0;
rle_blocks = 1;
code = 253;
case RLE_ESC_FF:
case RLE_ESC_FE:
case RLE_ESC_FD:
num_lines = 257 - code - line;
if (num_lines <= 0)
return IV3_BAD_RLE;
if (mode <= 4) {
RLE_LINES_COPY;
} else if (mode == 10 && !cell->mv_ptr) {
RLE_LINES_COPY_M10;
}
break;
case RLE_ESC_FB:
BUFFER_PRECHECK;
code = bytestream_get_byte(data_ptr);
rle_blocks = (code & 0x1F) - 1;
if (code >= 64 || rle_blocks < 0)
return IV3_BAD_COUNTER;
skip_flag = code & 0x20;
num_lines = 4 - line;
if (mode >= 10 || (cell->mv_ptr || !skip_flag)) {
if (mode <= 4) {
RLE_LINES_COPY;
} else if (mode == 10 && !cell->mv_ptr) {
RLE_LINES_COPY_M10;
}
}
break;
case RLE_ESC_F9:
skip_flag = 1;
rle_blocks = 1;
case RLE_ESC_FA:
if (line)
return IV3_BAD_RLE;
num_lines = 4;
if (cell->mv_ptr) {
if (mode <= 4) {
RLE_LINES_COPY;
} else if (mode == 10 && !cell->mv_ptr) {
RLE_LINES_COPY_M10;
}
}
break;
default:
return IV3_UNSUPPORTED;
}
}
line += num_lines;
ref += row_offset * (num_lines << v_zoom);
dst += row_offset * (num_lines << v_zoom);
}
}
block += 4 << h_zoom;
ref_block += 4 << h_zoom;
}
ref_block += blk_row_offset;
block += blk_row_offset;
}
return IV3_NOERR;
}
| 1threat
|
static int mov_read_elst(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
MOVStreamContext *sc;
int i, edit_count, version;
if (c->fc->nb_streams < 1 || c->ignore_editlist)
return 0;
sc = c->fc->streams[c->fc->nb_streams-1]->priv_data;
version = avio_r8(pb);
avio_rb24(pb);
edit_count = avio_rb32(pb);
if (!edit_count)
return 0;
if (sc->elst_data)
av_log(c->fc, AV_LOG_WARNING, "Duplicated ELST atom\n");
av_free(sc->elst_data);
sc->elst_count = 0;
sc->elst_data = av_malloc_array(edit_count, sizeof(*sc->elst_data));
if (!sc->elst_data)
return AVERROR(ENOMEM);
av_log(c->fc, AV_LOG_TRACE, "track[%u].edit_count = %i\n", c->fc->nb_streams - 1, edit_count);
for (i = 0; i < edit_count && !pb->eof_reached; i++) {
MOVElst *e = &sc->elst_data[i];
if (version == 1) {
e->duration = avio_rb64(pb);
e->time = avio_rb64(pb);
} else {
e->duration = avio_rb32(pb);
e->time = (int32_t)avio_rb32(pb);
}
e->rate = avio_rb32(pb) / 65536.0;
av_log(c->fc, AV_LOG_TRACE, "duration=%"PRId64" time=%"PRId64" rate=%f\n",
e->duration, e->time, e->rate);
if (e->time < 0 && e->time != -1 &&
c->fc->strict_std_compliance >= FF_COMPLIANCE_STRICT) {
av_log(c->fc, AV_LOG_ERROR, "Track %d, edit %d: Invalid edit list media time=%"PRId64"\n",
c->fc->nb_streams-1, i, e->time);
return AVERROR_INVALIDDATA;
}
}
sc->elst_count = i;
return 0;
}
| 1threat
|
def tuple_intersection(test_list1, test_list2):
res = set([tuple(sorted(ele)) for ele in test_list1]) & set([tuple(sorted(ele)) for ele in test_list2])
return (res)
| 0debug
|
How to divide a tuple in C++ : <p>I have a question about dividing a tuple, as the title said.</p>
<p>In fact, I can do it using <code>std::index_sequence</code>, but the code looks ugly.</p>
<p>Is there an elegant way of accomplishing this?</p>
<p>Here are some code to show what I mean.</p>
<pre><code>#include<tuple>
using namespace std;
template<typename THead, typename ...TTails>
void foo(tuple<THead, TTails...> tpl)
{
tuple<THead> tpl_h { get<0>(tpl) };
tuple<TTails...> tpl_t { /* an elegent way? */ }
do_sth(tpl_h, tpl_t);
}
int main()
{
foo(make_tuple(1, 2.0f, 'c'));
return 0;
}
</code></pre>
| 0debug
|
How to replace some characters in a string : <p>What is the best way to replace \n or \r or \r\n when they are between double quotes, with an empty string </p>
<p>using c#?</p>
<p>Example: "abc\ndef" should be "abcdef"</p>
| 0debug
|
ie11 Downloading Base64 documents : <p>I have tried pretty much everything at this point and I cannot get anything to work in ie. </p>
<p>I need ie to download base64 documents from an attachment panel. I have no access to the server side code or database. The images cannot be stored in a folder to be pulled up, they need to be presented this way.</p>
<p>I have tried using a plain link and sticking the base64 sting in there and it just opens up a new blank window. </p>
<pre><code><a target="_blank" download class="btn btn-primary downloadAttachment" href="' + blobUrl + '" >Download</a>
</code></pre>
<p>I have tried turning the url into a <code>blob</code> and opening the blob and that resulted in the browser not doing anything. </p>
<pre><code>function base64toBlob(base64Data, contentType) {
contentType = contentType || '';
var sliceSize = 1024;
var byteCharacters = base64Data;
var bytesLength = byteCharacters.length;
var slicesCount = Math.ceil(bytesLength / sliceSize);
var byteArrays = new Array(slicesCount);
for (var sliceIndex = 0; sliceIndex < slicesCount; ++sliceIndex) {
var begin = sliceIndex * sliceSize;
var end = Math.min(begin + sliceSize, bytesLength);
var bytes = new Array(end - begin);
for (var offset = begin, i = 0 ; offset < end; ++i, ++offset) {
bytes[i] = byteCharacters[offset].charCodeAt(0);
}
byteArrays[sliceIndex] = new Uint8Array(bytes);
}
return new Blob(byteArrays, { type: contentType });
}
</code></pre>
<p>I am completely and totally stuck. I have tried everything from google and on here.</p>
<p>My two latest attempts here</p>
<p><a href="https://jsfiddle.net/pqhdce2L/" rel="noreferrer">https://jsfiddle.net/pqhdce2L/</a></p>
<p><a href="http://jsfiddle.net/VB59f/464/" rel="noreferrer">http://jsfiddle.net/VB59f/464/</a></p>
| 0debug
|
Guessing game in C, cannot get the number of tries to work, variable is "counter" : <p>Not too sure how to make the counter variable work to count how many tries it takes to guess the number right. Ive tried putting "counter++;" in each if statement but that doesn't do anything. This is my first code that I've written by myself so don't drag it too hard please <3</p>
<pre><code>int main()
int counter
{
int num , guess;
counter = 0;
srand(time(0));
num = rand() % 200 + 1;
printf ( "Guessing game, guess the number between 1 and 200" );
do {
scanf ( "%d" , &guess);
if ( guess > num ){
printf ( "Too high" );
}
if ( guess < num ){
printf ( "Too low" );
}
if ( guess == num ){
counter++;
printf ( "Your guess is correct!, it took you %d tries" , counter );
}
}while (guess != num);
return 0;
}
</code></pre>
| 0debug
|
Last Date Attended from 2 Tables MS SQL : I have searched the forum, and couldn't find an answer. So I apologize if this is out there. This seems simple in my mind, however, I can't seem to get the correct code.
I have 2 tables. STUDENT_TERMS_VIEW table holds the STTR_STUDENT, STTR_TERM and TERMS table, holds the TERM_END_DATE. I need to find a way to select the student's last term based on MAX(TERM_END_DATE), but I get STTR_TERM duplicate rows per student. I need to get 1 row per student and their last term attended.
thanx
[View SQL Image][1]
[1]: http://i.stack.imgur.com/vjGLQ.png
| 0debug
|
How to do random selection of numbers in your program : <p>How to do random selection of numbers in your program </p>
| 0debug
|
How to sort array according to value in sub-sub array? : I am trying to sort each 'Rates' array by price from low to high. I cannot figure it out looking at other solutions.
Is there anyone who knows how to sort this?
**Note that there is multiple arrays like [13188] within the main array.**
`Array
(
[13188] => Array
(
[Rates] => Array
(
[0] => Array
(
[RateName] => Standard Rate
[Price] => 499.56
)
[18739] => Array
(
[RateName] => Second Rate
[Price] => 449.6
)
)
)`
I want it to be like this:
`Array
(
[13188] => Array
(
[Rates] => Array
(
[18739] => Array
(
[RateName] => Second Rate
[Price] => 449.6
)
[0] => Array
(
[RateName] => Standard Rate
[Price] => 499.56
)
)
)`
| 0debug
|
Use Transpiled FlowJS or Typescript in Pure Javascript : i have question regarding FlowJS or Typescript (which quite popular these days).
While both do great job doing static type check, but not all project will be compatible with superset language.
So, how do i use transpiled superset language (preferable CommonJS) in PURE JS. If you came from Java, this questions similar to Scala in Java.
I have fair knowledge to setup Webpack, so expected answer is explaining how to use FlowJS and Typescript transpiled in CommonJS in Pure JS.
| 0debug
|
No match for operator [ ] c++ : I'm not entirely sure why I'm getting this message, given that square brackets aren't an operator, but here we go.
In my `IntSet.h` file, I have declared a particular function that looks like this.
`IntSet unions(const IntSet& operand)const;`
The file is called by an `IntSet`, takes another `IntSet` as an argument, and returns the union of the two sets.
In my `IntSet.cpp` file, it looks like this.
IntSet IntSet::unions(const IntSet& operand) const
{
IntSet returnSet(50);
for (int i = 0; i < 50; i++){
if (setArray[i] == 1 || operand[i]==1){
if(setArray[i] == 1 ){
returnSet.addElement(setArray[i]);
}
else if(operand[i] == 1){
returnSet.addElement(operand[i]);
}
}
}
return returnSet;
}
The error I'm getting comes from the the `operand[I] == 1`.
`IntSet.cpp|52|error: no match for 'operator[]' (operand types are 'const IntSet' and 'int')`.
I looked into overloading operators, but the square brackets don't seem to be overloadable. Regardless, the program must not override and operators to start. I Should also mention that `IntSet unions(const IntSet& operand)const;` was provided and can also not be changed.
Any direction as to how I should solve this?
| 0debug
|
Swift IF statement bug? : <p>The if statement below does not catch loc!.speed < 1.0. Why?</p>
<pre><code>if loc == nil || loc!.speed < 1.0, self.tripOver
{
return
}
</code></pre>
<p>However the if statement below works</p>
<pre><code>if loc == nil || loc!.speed < 1.0 || self.tripOver
{
return
}
</code></pre>
<p>The above if statement <em>does</em> catch loc!.speed < 1.0 and properly returns.</p>
<p>Why does swift not evaluate the second part of the conditional expression when there is a ',' separating another part of the statement?</p>
<p>This looks like a bug to me. </p>
| 0debug
|
PHP Artisan Tinker crashing from any command : <p>I haven't had this problem before, but my <code>php artisan tinker</code> crashes from issuing any command - and leaves no logs whatsoever on what is causing the crash.</p>
<pre><code>project4 $ php artisan tinker
Psy Shell v0.9.9 (PHP 7.3.0 — cli) by Justin Hileman
>>> use \App\Jobs\testJob;
project4 $
</code></pre>
<p>or even the simplest command:</p>
<pre><code>project4 $ php artisan tinker
Psy Shell v0.9.9 (PHP 7.3.0 — cli) by Justin Hileman
>>> print("Hello World!");
project4 $
</code></pre>
<p>I almost wonder if it isn't connecting to PHP correctly, but I can't find any logs anywhere. Laravel has no trace of the commands. I ran <code>brew update</code>, but no difference. For the record, <em>all</em> of my projects are affected. I can't <em>tinker</em> on any of my projects. Help!</p>
<p>I did recently upgrade to PHP 7.3.0, which is working fine in every other area. Hmm...</p>
| 0debug
|
count character input using a single variable : 1) I'm trying to count the input of characters, for example: 1 1 1 1 1 2 2 2 2 5 5 5 5 5 5 10 10 10, but I can not get rid of the loop and start a new countdown.
2) When I try to record only the total number of cents on the screen, cout is always repeated in each cycle, how can I get only the whole amount at the end of the cycle?
3) How can I change my code to simplify the calculation of numbers?
Any suggestions?
int main(){
int cent = 0;
int cent_input = 0;
int cent_quantity = 0;
int downgrade_to_one = 0;
do{
while(true){
cout << "\nEnter number: " && cin >> cent;
switch(cent){
case 1:
downgrade_to_one = cent + downgrade_to_one;
if(cent == 0)
cent + 1;
cout << "\nYou have: " << downgrade_to_one << " one cent monets.";
break;
case 2:
cent_input = (cent_input + cent) / cent;
cent_quantity = cent_quantity + cent_input;
cout << "\nYou have: " << cent_quantity << " two cent monets.";
case 5:
cent_input = (cent_input + cent) / cent;
cent_quantity = cent_quantity + cent_input;
cout << "\nYou have: " << cent_quantity << " five cent monets.";
break;
case 10:
cent_input = (cent_input + cent) / cent;
cent_quantity = cent_quantity + cent_input;
cout << "\nYou have: " << cent_quantity << " ten cent monets.";
break;
case 25:
cent_input = (cent_input + cent) / cent;
cent_quantity = cent_quantity + cent_input;
cout << "\nYou have: " << cent_quantity << " twentyfive cent monets.";
break;
case 50:
cent_input = (cent_input + cent) / cent;
cent_quantity = cent_quantity + cent_input;
cout << "\nYou have: " << cent_quantity << " fifty cent monets.";
break;
default:
cout << "\nUndefined input!";
}
}
}
while(false);
}
| 0debug
|
Linux Docker container on Windows Server 2016 : <p>What is the way to run Linux docker container on Windows Server 2016? With Docker for Windows it easy to do in Windows 10. Is the only way to install Docker Toolbox and ignore the build-in containers feature all together?</p>
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.