problem
stringlengths
26
131k
labels
class label
2 classes
connect to AWS IoT using web socket with Cognito authenticated users : <p>I'm trying to connect to AWS IoT using web socket from the browser.</p> <p>I've tried this example: <a href="https://github.com/awslabs/aws-iot-examples/tree/master/mqttSample" rel="noreferrer">https://github.com/awslabs/aws-iot-examples/tree/master/mqttSample</a> </p> <p>And another one a little bit modfied so it can be used with Cognito Identity pool logged users. <a href="https://github.com/dwyl/learn-aws-iot/blob/master/src/js/utils/request.js#L27" rel="noreferrer">https://github.com/dwyl/learn-aws-iot/blob/master/src/js/utils/request.js#L27</a> </p> <p>I can successfully connect if I use a IAM user with a valid IoT policy, but if I use the user credentials, I receive a "101 Switching Protocols" response but then it gets closed.</p> <p>The IAM role associated with the authenticated user is correct, and I can sign requests and perform other private operations like calling APIG endpoints. Also the socket connection does not respond with 403. So it's likely not a permissions problem.</p> <p>What else could it be?</p>
0debug
void pci_bus_reset(PCIBus *bus) { int i; for (i = 0; i < bus->nirq; i++) { bus->irq_count[i] = 0; } for (i = 0; i < ARRAY_SIZE(bus->devices); ++i) { if (bus->devices[i]) { pci_device_reset(bus->devices[i]); } } }
1threat
PHP : ranking on array value without ties : i have an array rank, <br> `rank = [1,3,2,1]` i want the output like this `rank = [1,4,3,2]` thank you in advice
0debug
Why is there a random bracket, "]", above the canvas element on my web app? : <p><a href="https://i.stack.imgur.com/qtJXb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qtJXb.png" alt="Web App with random bracket in the left corner"></a></p> <p>Above is an image that contains the random bracket I ram referring to. You can see in the developer tools at the bottom, that the bracket seems to be inserted at the top of the <code>body</code> tag. I have been doing a little research, but I cannot figure out why this random bracket is there. My code is below.</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;First Game&lt;/title&gt;] &lt;meta charset="utf-8"&gt; &lt;style type="text/css"&gt; * { padding: 0; margin: 0; } canvas { background: #eee; display: block; margin: 0 auto; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;canvas id="myCanvas" width="480" height="320"&gt;&lt;/canvas&gt; &lt;script type="text/javascript"&gt; var canvas = document.getElementById('myCanvas'); var ctx = canvas.getContext('2d'); ctx.beginPath(); ctx.rect(10, 40, 50, 50); ctx.fillStyle = "#eee"; ctx.fill(); ctx.closePath(); &lt;/script&gt; &lt;/body&gt; </code></pre> <p></p> <p>As you can see, there is not a stray square bracket in the code. I am not sure why this is appearing. As a side note, this bracket is making the red square, and any other code, to not show up in the canvas. Any ideas?</p>
0debug
static void do_savevm(int argc, const char **argv) { if (argc != 2) { help_cmd(argv[0]); return; } if (qemu_savevm(argv[1]) < 0) term_printf("I/O error when saving VM to '%s'\n", argv[1]); }
1threat
Cannot convert a partially converted tensor in TensorFlow : <p>There are many methods in TensorFlow that requires specifying a shape, for example truncated_normal:</p> <pre><code>tf.truncated_normal(shape, mean=0.0, stddev=1.0, dtype=tf.float32, seed=None, name=None) </code></pre> <p>I have a placeholder for the input of shape [None, 784], where the first dimension is None because the batch size can vary. I could use a fixed batch size but it still would be different from the test/validation set size.</p> <p>I cannot feed this placeholder to tf.truncated_normal because it requires a fully specified tensor shape. What is a simple way to having tf.truncated_normal accept different tensor shapes?</p>
0debug
static int udp_open(URLContext *h, const char *uri, int flags) { char hostname[1024], localaddr[1024] = ""; int port, udp_fd = -1, tmp, bind_ret = -1; UDPContext *s = h->priv_data; int is_output; const char *p; char buf[256]; struct sockaddr_storage my_addr; int len; int reuse_specified = 0; int i, include = 0, num_sources = 0; char *sources[32]; h->is_streamed = 1; h->max_packet_size = 1472; is_output = !(flags & AVIO_FLAG_READ); s->ttl = 16; s->buffer_size = is_output ? UDP_TX_BUF_SIZE : UDP_MAX_PKT_SIZE; s->circular_buffer_size = 7*188*4096; p = strchr(uri, '?'); if (p) { if (av_find_info_tag(buf, sizeof(buf), "reuse", p)) { char *endptr = NULL; s->reuse_socket = strtol(buf, &endptr, 10); if (buf == endptr) s->reuse_socket = 1; reuse_specified = 1; } if (av_find_info_tag(buf, sizeof(buf), "overrun_nonfatal", p)) { char *endptr = NULL; s->overrun_nonfatal = strtol(buf, &endptr, 10); if (buf == endptr) s->overrun_nonfatal = 1; } if (av_find_info_tag(buf, sizeof(buf), "ttl", p)) { s->ttl = strtol(buf, NULL, 10); } if (av_find_info_tag(buf, sizeof(buf), "localport", p)) { s->local_port = strtol(buf, NULL, 10); } if (av_find_info_tag(buf, sizeof(buf), "pkt_size", p)) { h->max_packet_size = strtol(buf, NULL, 10); } if (av_find_info_tag(buf, sizeof(buf), "buffer_size", p)) { s->buffer_size = strtol(buf, NULL, 10); } if (av_find_info_tag(buf, sizeof(buf), "connect", p)) { s->is_connected = strtol(buf, NULL, 10); } if (av_find_info_tag(buf, sizeof(buf), "fifo_size", p)) { s->circular_buffer_size = strtol(buf, NULL, 10)*188; "'circular_buffer_size' option was set but it is not supported " } if (av_find_info_tag(buf, sizeof(buf), "localaddr", p)) { av_strlcpy(localaddr, buf, sizeof(localaddr)); } if (av_find_info_tag(buf, sizeof(buf), "sources", p)) include = 1; if (include || av_find_info_tag(buf, sizeof(buf), "block", p)) { char *source_start; source_start = buf; while (1) { char *next = strchr(source_start, ','); if (next) *next = '\0'; sources[num_sources] = av_strdup(source_start); if (!sources[num_sources]) goto fail; source_start = next + 1; num_sources++; if (num_sources >= FF_ARRAY_ELEMS(sources) || !next) break; } } } av_url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), &port, NULL, 0, uri); if (hostname[0] == '\0' || hostname[0] == '?') { if (!(flags & AVIO_FLAG_READ)) goto fail; } else { if (ff_udp_set_remote_url(h, uri) < 0) goto fail; } if ((s->is_multicast || !s->local_port) && (h->flags & AVIO_FLAG_READ)) s->local_port = port; udp_fd = udp_socket_create(s, &my_addr, &len, localaddr); if (udp_fd < 0) goto fail; if (s->reuse_socket || (s->is_multicast && !reuse_specified)) { s->reuse_socket = 1; if (setsockopt (udp_fd, SOL_SOCKET, SO_REUSEADDR, &(s->reuse_socket), sizeof(s->reuse_socket)) != 0) goto fail; } if (s->is_multicast && !(h->flags & AVIO_FLAG_WRITE)) { bind_ret = bind(udp_fd,(struct sockaddr *)&s->dest_addr, len); } if (bind_ret < 0 && bind(udp_fd,(struct sockaddr *)&my_addr, len) < 0) { log_net_error(h, AV_LOG_ERROR, "bind failed"); goto fail; } len = sizeof(my_addr); getsockname(udp_fd, (struct sockaddr *)&my_addr, &len); s->local_port = udp_port(&my_addr, len); if (s->is_multicast) { if (h->flags & AVIO_FLAG_WRITE) { if (udp_set_multicast_ttl(udp_fd, s->ttl, (struct sockaddr *)&s->dest_addr) < 0) goto fail; } if (h->flags & AVIO_FLAG_READ) { if (num_sources == 0 || !include) { if (udp_join_multicast_group(udp_fd, (struct sockaddr *)&s->dest_addr) < 0) goto fail; if (num_sources) { if (udp_set_multicast_sources(udp_fd, (struct sockaddr *)&s->dest_addr, s->dest_addr_len, sources, num_sources, 0) < 0) goto fail; } } else if (include && num_sources) { if (udp_set_multicast_sources(udp_fd, (struct sockaddr *)&s->dest_addr, s->dest_addr_len, sources, num_sources, 1) < 0) goto fail; } else { av_log(NULL, AV_LOG_ERROR, "invalid udp settings: inclusive multicast but no sources given\n"); goto fail; } } } if (is_output) { tmp = s->buffer_size; if (setsockopt(udp_fd, SOL_SOCKET, SO_SNDBUF, &tmp, sizeof(tmp)) < 0) { log_net_error(h, AV_LOG_ERROR, "setsockopt(SO_SNDBUF)"); goto fail; } } else { tmp = s->buffer_size; if (setsockopt(udp_fd, SOL_SOCKET, SO_RCVBUF, &tmp, sizeof(tmp)) < 0) { log_net_error(h, AV_LOG_WARNING, "setsockopt(SO_RECVBUF)"); } ff_socket_nonblock(udp_fd, 1); } if (s->is_connected) { if (connect(udp_fd, (struct sockaddr *) &s->dest_addr, s->dest_addr_len)) { log_net_error(h, AV_LOG_ERROR, "connect"); goto fail; } } for (i = 0; i < num_sources; i++) av_freep(&sources[i]); s->udp_fd = udp_fd; #if HAVE_PTHREAD_CANCEL if (!is_output && s->circular_buffer_size) { int ret; s->fifo = av_fifo_alloc(s->circular_buffer_size); ret = pthread_mutex_init(&s->mutex, NULL); if (ret != 0) { av_log(h, AV_LOG_ERROR, "pthread_mutex_init failed : %s\n", strerror(ret)); goto fail; } ret = pthread_cond_init(&s->cond, NULL); if (ret != 0) { av_log(h, AV_LOG_ERROR, "pthread_cond_init failed : %s\n", strerror(ret)); goto cond_fail; } ret = pthread_create(&s->circular_buffer_thread, NULL, circular_buffer_task, h); if (ret != 0) { av_log(h, AV_LOG_ERROR, "pthread_create failed : %s\n", strerror(ret)); goto thread_fail; } s->thread_started = 1; } #endif return 0; #if HAVE_PTHREAD_CANCEL thread_fail: pthread_cond_destroy(&s->cond); cond_fail: pthread_mutex_destroy(&s->mutex); #endif fail: if (udp_fd >= 0) closesocket(udp_fd); av_fifo_free(s->fifo); for (i = 0; i < num_sources; i++) av_freep(&sources[i]); return AVERROR(EIO); }
1threat
Scroll up tableView when keyboard opening the keyboard : I have a UITable with some custom cells, on the last cell I have a `UITextField`, I want that all of the cells will scroll up when opening the keyboard (all kind of keyboards, with "Predictive" enabled and disabled). I've looked at the other questions about this topic and tried but it still don't good enough (there is a gap between the cells to the keyboard, the animation of the tableView and the keyboard aren't synced, etc...). Can you please help me with that? Thank you!
0debug
How can i add a 2dView having text in ARkit scene iOS : <p>How can i add a 2dView having text in ARkit scene iOS.How can i add that view in top of a node that won't rotate when we rotate the node.<a href="https://i.stack.imgur.com/g37gy.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/g37gy.jpg" alt="enter image description here"></a></p>
0debug
sorting a json array by one field during iteration using JS : I have an array as follows var array = {"week1":[{"id":1,"name":"x","mark":"20"},{"id":2,"name":"y","mark":"30"}],"week2":[{"id":1,"name":"x","mark":"40"},{"id":2,"name":"y","mark":"60"},{"id":3,"name":"z","mark":"10"}]} I want to sort the array by mark field. How can I achieve this?
0debug
void spapr_create_phb(sPAPREnvironment *spapr, const char *busname, uint64_t buid, uint64_t mem_win_addr, uint64_t mem_win_size, uint64_t io_win_addr, uint64_t msi_win_addr) { DeviceState *dev; dev = qdev_create(NULL, TYPE_SPAPR_PCI_HOST_BRIDGE); if (busname) { qdev_prop_set_string(dev, "busname", g_strdup(busname)); } qdev_prop_set_uint64(dev, "buid", buid); qdev_prop_set_uint64(dev, "mem_win_addr", mem_win_addr); qdev_prop_set_uint64(dev, "mem_win_size", mem_win_size); qdev_prop_set_uint64(dev, "io_win_addr", io_win_addr); qdev_prop_set_uint64(dev, "msi_win_addr", msi_win_addr); qdev_init_nofail(dev); }
1threat
Is there a Python shortcut for an __init__ that simply sets properties? : <p>It's sometimes common in Python to see <code>__init__</code> code like this:</p> <pre><code>class SomeClass(object): def __init__(self, a, b, c, d, e, f, g): self.a = a self.b = b self.c = c self.d = d self.e = e self.f = f self.g = g </code></pre> <p>especially if the class in question is purely a data structure with no behaviour. Is there a (Python 2.7) shortcut for this or a way to make one?</p>
0debug
Why did I get error by using strchr() in C++? : <pre><code>#include &lt;iostream&gt; #include &lt;string&gt; #include &lt;cstring&gt; using namespace std; int main(){ string a="asdasd"; if(!strchr(a,'a')) cout&lt;&lt;"yes"; return 0; } </code></pre> <p>I just began to learn C++ programming and I don't know why I got error in this line </p> <pre><code>if(!strchr(a,'a')) cout&lt;&lt;"yes"; </code></pre> <p>But if I tried to code it like this, it would run very well.</p> <pre><code>if(!strchr("asdasd",'a')) cout&lt;&lt;"yes"; </code></pre> <p>I know it is a stupid question but I really don't know why.. sorry..</p>
0debug
How is putting the lambda expression after the parameters on a mapTo call legal syntax? : <p>I found a piece of code I do not understand. </p> <p>I am transforming a <code>JSONArray</code> into a <code>List</code>.<br> Kotlin provides the function <code>mapTo</code> in it's <code>stdlib</code>(<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/map-to.html" rel="noreferrer">link</a>)</p> <blockquote> <p><strong>mapTo</strong></p> <pre><code>inline fun &lt;T, R, C : MutableCollection&lt;in R&gt;&gt; Iterable&lt;T&gt;.mapTo( destination: C, transform: (T) -&gt; R ): C (source) </code></pre> <p>Applies the given transform function to each element of the original collection and appends the results to the given destination.</p> </blockquote> <p>This functions has 2 parameters and can be used like this (as expected):</p> <pre><code>(0..jsonArray.length() - 1).mapTo(targetList, {it -&gt; jsonArray[it].toString()}) </code></pre> <p>But apparently this is also valid syntax (not expected):</p> <pre><code>(0..jsonArray.length()-1).mapTo(targetList) {it -&gt; jsonArray[it].toString()} </code></pre> <p>As you can see, the function parameters end after <code>outputList</code> and the lambda expression is just put at the end of the function call.</p> <hr> <p>Furthermore this is legal (as expected):</p> <pre><code>val transformation = {it : Int -&gt; jsonArray[it].toString()} (0..jsonArray.length()-1).mapTo(targetList, transformation) </code></pre> <p>but this is not (???):</p> <pre><code>val transformation = {it : Int -&gt; jsonArray[it].toString()} (0..jsonArray.length()-1).mapTo(targetList) transformation </code></pre>
0debug
Is it possible to use AWS SES with HEROKU? : If yes, then how? It is urgent. Although I am able to send mail from localhost,but not able to send mails from my application deployed on HEROKU..
0debug
How to make Typescript infer the keys of an object but define type of its value? : <p>I want to define the type of an object but let typescript infer the keys and don't have as much overhead to make and maintain a UnionType of all keys.</p> <p>Typing an object will allow all strings as keys:</p> <pre><code>const elementsTyped: { [key: string]: { nodes: number, symmetric?: boolean } } = { square: { nodes: 4, symmetric: true }, triangle: { nodes: 3 } } function isSymmetric(elementType: keyof typeof elementsTyped): boolean { return elementsTyped[elementType].symmetric; } isSymmetric('asdf'); // works but shouldn't </code></pre> <p>Inferring the whole object will show an error and allows all kind of values:</p> <pre><code>const elementsInferred = { square: { nodes: 4, symmetric: true }, triangle: { nodes: 3 }, line: { nodes: 2, notSymmetric: false /* don't want that to be possible */ } } function isSymmetric(elementType: keyof typeof elementsInferred): boolean { return elementsInferred[elementType].symmetric; // Property 'symmetric' does not exist on type '{ nodes: number; }'. } </code></pre> <p>The closest I got was this, but it don't want to maintain the set of keys like that:</p> <pre><code>type ElementTypes = 'square' | 'triangle'; // don't want to maintain that :( const elementsTyped: { [key in ElementTypes]: { nodes: number, symmetric?: boolean } } = { square: { nodes: 4, symmetric: true }, triangle: { nodes: 3 }, lines: { nodes: 2, notSymmetric: false } // 'lines' does not exist in type ... // if I add lines to the ElementTypes as expected =&gt; 'notSymmetric' does not exist in type { nodes: number, symmetric?: boolean } } function isSymmetric(elementType: keyof typeof elementsTyped): boolean { return elementsTyped[elementType].symmetric; } isSymmetric('asdf'); // Error: Argument of type '"asdf"' is not assignable to parameter of type '"square" | "triangle"'. </code></pre> <p>Is there a better way to define the object without maintaining the set of keys?</p>
0debug
Responsive Font Size Java : <p>I'm making a 2D game in Java and I'm trying to make it responsive (only in 16:9 aspect ratio). But to do that, I need my font size to change as well, depending on the screen size. How do I do that?</p> <p>Thanks!</p>
0debug
Updating state managed by another reducer : <p>In my React app, my appReducer manages global stuff such as notifications, user info, etc.</p> <p>One of the modules in the app is the inventory module which has its own reducer i.e. inventoryReducer. And in the redux store, I combine all the reducers. </p> <p>My questions is this: when a user makes an inventory entry, in addition to handling the inventory transaction, I want to display an on-screen notification which is handled in the appReducer. How do I update the state of displayNotification which is under appReducer from the inventoryReducer?</p> <p>The following is my app reducer:</p> <pre><code>import 'babel-polyfill'; import * as types from '../actions/actionTypes'; const initialState = { displayNotification: {} }; export default (state = initialState, action) =&gt; { switch (action.type) { case types.DISPLAY_NOTIFICATION : return Object.assign({}, state, { displayNotification: action.value }) default: return state } } </code></pre> <p>And this is the inventoryReducer:</p> <pre><code>import 'babel-polyfill'; import * as types from '../actions/actionTypes'; const initialState = { inventory: [] }; export default (state = initialState, action) =&gt; { switch (action.type) { case types.SET_INVENTORY : return Object.assign({}, state, { inventory: action.inventoryItem }) case types.DISPLAY_NOTIFICATION : return Object.assign({}, state, { app.displayNotification: action.value // &lt;-- Is this how I access displayNotification which is managed by the appReducer? }) default: return state } } </code></pre> <p>My update inventory action needs to dispatch both SET_INVENTORY and DISPLAY_NOTIFICATION. I'm trying to understand how I can update displayNotification from inventoryReducer where displayNotification is actually managed by the appReducer.</p>
0debug
Why return a function instead of just running that function again (recursion)? : <p>If I want to run my function again inside that same function when a certain condition is met, what's the difference between returning that function VS just calling that function again.</p> <pre><code>function myFunc(param) { if (param === "3") { return myFunc(param); } } </code></pre> <p>VS</p> <pre><code>function myFunc(param) { if (param === "3") { myFunc(param); } } </code></pre>
0debug
static int piix3_initfn(PCIDevice *dev) { PIIX3State *d = DO_UPCAST(PIIX3State, dev, dev); uint8_t *pci_conf; isa_bus_new(&d->dev.qdev); pci_conf = d->dev.config; pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_INTEL); pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82371SB_0); pci_config_set_class(pci_conf, PCI_CLASS_BRIDGE_ISA); pci_conf[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_NORMAL | PCI_HEADER_TYPE_MULTI_FUNCTION; qemu_register_reset(piix3_reset, d); return 0; }
1threat
Dynamically sort NSMutableArray data into NSDictionary alphabetically : <p>Unfortunatly I dont currently have internet on my laptop so I will have to describe my code, I have a mutable array of alphabetically sorted song titles. I have a uitableview that is currently displaying these however I want to have section heads and an alphabet index at the side of the table so I need to put these songs into an nsdictionary to display it, however I cant work out an an efficent method of sorting the array into the alphabetical sections (also has a # section, ive made a nsarray of section heads) in the nsdictionary.</p>
0debug
UNKNOWN - Segmentation Fault : I keep getting a Segmentation fault. I figured out that it happens between these two lines: printf("%s - File exists!\n", file_name); printf("inforloop"); But I'm unsure why the segmentation fault keeps occuring. This is the entire code: #include<stdio.h> #include<unistd.h> #include<string.h> FILE *fp; char err_message[128], file_name[128]; int main(int argc, char *argv[]) { if(argc <= 2) { printf("ERROR : Usage %s <file name>\n", argv[0]); return 1; } int i = 1; for(i; i< argc; i++) { strcpy(file_name, argv[i]); if ((access(file_name, F_OK)) != -1) { printf("begining of for loop\n"); printf("%s - File exists!\n", file_name); printf("inforloop"); fclose(fp); } else { sprintf(err_message, "open %s", file_name); perror(err_message); } } return 0; } Outcome: 1 begining of for loop date.txt - File exists! Segmentation fault (core dumped)
0debug
How to update the list of primary key of one Column in one table into another table : I just added a new data in [Driver Table], afterwards, I want to update [Driver Dimension] to get the value of every new data inserted in Driver Table. I'm using SQL server 2012. **My Code:** "Update [Driver Dimension] SET [DriverID] = [DriverID] From [Driver Table]" **ERROR MESSAGE:** Ambiguous column name 'DriverID'. Where both Tables have a column which contains their respective primary keys called [DriverID]
0debug
How to handle net::ERR_CONNECTION_REFUSED in Angular2 : <p><a href="https://angular.cn/docs/ts/latest/guide/server-communication.html#!#error-handling" rel="noreferrer">error-handling</a> shows how to handle errors as follows:</p> <pre><code>private handleError (error: Response | any) { // In a real world app, we might use a remote logging infrastructure let errMsg: string; if (error instanceof Response) { const body = error.json() || ''; const err = body.error || JSON.stringify(body); errMsg = `${error.status} - ${error.statusText || ''} ${err}`; } else { errMsg = error.message ? error.message : error.toString(); } console.error(errMsg); return Promise.reject(errMsg); } </code></pre> <p>I'd like to access an API server, but the server hasn't started. Then I got the error:</p> <pre><code>http://localhost:3000/api/heroes net::ERR_CONNECTION_REFUSED </code></pre> <p>I need to <strong>tell the user politely that the API server hasn't started</strong>. How should I handle the error?</p> <p>The error Response is:</p> <pre><code>_body:ProgressEvent headers:Headers ok:false status:0 statusText:"" type:3 url:null </code></pre> <p>Could I handle this according to the <strong>status</strong> of the response?</p>
0debug
static int mov_read_mfra(MOVContext *c, AVIOContext *f) { int64_t stream_size = avio_size(f); int64_t original_pos = avio_tell(f); int64_t seek_ret; int32_t mfra_size; int ret = -1; if ((seek_ret = avio_seek(f, stream_size - 4, SEEK_SET)) < 0) { ret = seek_ret; goto fail; } mfra_size = avio_rb32(f); if (mfra_size < 0 || mfra_size > stream_size) { av_log(c->fc, AV_LOG_DEBUG, "doesn't look like mfra (unreasonable size)\n"); goto fail; } if ((seek_ret = avio_seek(f, -mfra_size, SEEK_CUR)) < 0) { ret = seek_ret; goto fail; } if (avio_rb32(f) != mfra_size) { av_log(c->fc, AV_LOG_DEBUG, "doesn't look like mfra (size mismatch)\n"); goto fail; } if (avio_rb32(f) != MKBETAG('m', 'f', 'r', 'a')) { av_log(c->fc, AV_LOG_DEBUG, "doesn't look like mfra (tag mismatch)\n"); goto fail; } ret = 0; av_log(c->fc, AV_LOG_VERBOSE, "stream has mfra\n"); while (!read_tfra(c, f)) { } fail: seek_ret = avio_seek(f, original_pos, SEEK_SET); if (seek_ret < 0) { av_log(c->fc, AV_LOG_ERROR, "failed to seek back after looking for mfra\n"); ret = seek_ret; } return ret; }
1threat
Load in multiple input files with for-loop : <p>I have multiple (264 to be precise) files with yearly precipitation, which are named 'precip1752.xlsx','precip1753.xlsx', ... 'precip2016.xlsx'. How can I load all these files at once with a for loop?</p> <p>Thanks in advance! </p>
0debug
The index ranging in Matlab matrices : <p>I want to know what this line of code does. </p> <p><code>ind_x = [1,3:5:size(paths,2)]</code></p> <p>What would <code>ind_x</code> contain after this line? I already know that <code>size(paths,2)</code> means the size of second dimension of <code>paths</code> matrix. </p>
0debug
MUMPS doesn't permit create file bigger than 2 GB : We know MUMPS not allow create files bigger than 2 GB. A Volume Group accept 16GB, but only with 2 GB each VG file. How can I fix it?
0debug
C#: How to save image with best size for any screen size and any resolution : <p>just wonder if anyone can give me concept to generate image with right size for any monitor size and resolution.</p> <p>now i am in a situation where i have to generate several images from power point presentation each slides. i have to save each power point slides to each images. i will use the below code to do so.</p> <pre><code>PowerPoint.Presentation pptPresentation = pptApplication.Presentations.Open2007(FILE); foreach (PowerPoint.Slide pptSlide in pptPresentation.Slides) { pptSlide.Export(NEWNAME, "PNG", 1024, 768); } </code></pre> <p>my problem is that i will show those images in my winform picturebox one after one like slide show. winform will load with maximize state and picturebox dock has been set to fill.</p> <p>i do not know where my application will run. may be my application will run in 15 inch monitor or may be 17 inch or may be 21 inch. each pc may have different resolution. also my application may run in pc which is connected with big LCD TV as monitor.</p> <p>i want to save each slide to image in such a way as a result when image will be shown through picturebox then image should be pixelated. this is my main concern. so please guide me how could i save each slide to image as a result image should be pixelated wherever it is shown irrespective of monitor size and resolution.</p> <p>so tell me what height and width i should specify when will save each slide to image.</p> <p>if possible please guide me with concept or sample code to achieve what i am after. thanks</p>
0debug
Populate ConfigMap by importing data from file in k8s : <p>I have a requirement where i push bunch of key value pairs to a text/json file. Post that, i want to import the key value data into a configMap and consume this configMap within a POD using kubernetes-client API's.</p> <p>Any pointers on how to get this done would be great.</p> <p>TIA</p>
0debug
How do i store the entire text as words : <p>Suppose I've retrieved a text from EditText and stored it in a string:</p> <pre><code>String str = "Hello, I am new to Android. </code></pre> <p>Now i want to store the text in an array this way:</p> <pre><code>array={"Hello,","I","am","new","to","Android."}; </code></pre>
0debug
static void sbr_hf_assemble(float Y[2][38][64][2], const float X_high[64][40][2], SpectralBandReplication *sbr, SBRData *ch_data, const int e_a[2]) { int e, i, j, m; const int h_SL = 4 * !sbr->bs_smoothing_mode; const int kx = sbr->kx[1]; const int m_max = sbr->m[1]; static const float h_smooth[5] = { 0.33333333333333, 0.30150283239582, 0.21816949906249, 0.11516383427084, 0.03183050093751, }; static const int8_t phi[2][4] = { { 1, 0, -1, 0}, { 0, 1, 0, -1}, }; float (*g_temp)[48] = ch_data->g_temp, (*q_temp)[48] = ch_data->q_temp; int indexnoise = ch_data->f_indexnoise; int indexsine = ch_data->f_indexsine; memcpy(Y[0], Y[1], sizeof(Y[0])); if (sbr->reset) { for (i = 0; i < h_SL; i++) { memcpy(g_temp[i + 2*ch_data->t_env[0]], sbr->gain[0], m_max * sizeof(sbr->gain[0][0])); memcpy(q_temp[i + 2*ch_data->t_env[0]], sbr->q_m[0], m_max * sizeof(sbr->q_m[0][0])); } } else if (h_SL) { memcpy(g_temp[2*ch_data->t_env[0]], g_temp[2*ch_data->t_env_num_env_old], 4*sizeof(g_temp[0])); memcpy(q_temp[2*ch_data->t_env[0]], q_temp[2*ch_data->t_env_num_env_old], 4*sizeof(q_temp[0])); } for (e = 0; e < ch_data->bs_num_env; e++) { for (i = 2 * ch_data->t_env[e]; i < 2 * ch_data->t_env[e + 1]; i++) { memcpy(g_temp[h_SL + i], sbr->gain[e], m_max * sizeof(sbr->gain[0][0])); memcpy(q_temp[h_SL + i], sbr->q_m[e], m_max * sizeof(sbr->q_m[0][0])); } } for (e = 0; e < ch_data->bs_num_env; e++) { for (i = 2 * ch_data->t_env[e]; i < 2 * ch_data->t_env[e + 1]; i++) { int phi_sign = (1 - 2*(kx & 1)); if (h_SL && e != e_a[0] && e != e_a[1]) { for (m = 0; m < m_max; m++) { const int idx1 = i + h_SL; float g_filt = 0.0f; for (j = 0; j <= h_SL; j++) g_filt += g_temp[idx1 - j][m] * h_smooth[j]; Y[1][i][m + kx][0] = X_high[m + kx][i + ENVELOPE_ADJUSTMENT_OFFSET][0] * g_filt; Y[1][i][m + kx][1] = X_high[m + kx][i + ENVELOPE_ADJUSTMENT_OFFSET][1] * g_filt; } } else { for (m = 0; m < m_max; m++) { const float g_filt = g_temp[i + h_SL][m]; Y[1][i][m + kx][0] = X_high[m + kx][i + ENVELOPE_ADJUSTMENT_OFFSET][0] * g_filt; Y[1][i][m + kx][1] = X_high[m + kx][i + ENVELOPE_ADJUSTMENT_OFFSET][1] * g_filt; } } if (e != e_a[0] && e != e_a[1]) { for (m = 0; m < m_max; m++) { indexnoise = (indexnoise + 1) & 0x1ff; if (sbr->s_m[e][m]) { Y[1][i][m + kx][0] += sbr->s_m[e][m] * phi[0][indexsine]; Y[1][i][m + kx][1] += sbr->s_m[e][m] * (phi[1][indexsine] * phi_sign); } else { float q_filt; if (h_SL) { const int idx1 = i + h_SL; q_filt = 0.0f; for (j = 0; j <= h_SL; j++) q_filt += q_temp[idx1 - j][m] * h_smooth[j]; } else { q_filt = q_temp[i][m]; } Y[1][i][m + kx][0] += q_filt * sbr_noise_table[indexnoise][0]; Y[1][i][m + kx][1] += q_filt * sbr_noise_table[indexnoise][1]; } phi_sign = -phi_sign; } } else { indexnoise = (indexnoise + m_max) & 0x1ff; for (m = 0; m < m_max; m++) { Y[1][i][m + kx][0] += sbr->s_m[e][m] * phi[0][indexsine]; Y[1][i][m + kx][1] += sbr->s_m[e][m] * (phi[1][indexsine] * phi_sign); phi_sign = -phi_sign; } } indexsine = (indexsine + 1) & 3; } } ch_data->f_indexnoise = indexnoise; ch_data->f_indexsine = indexsine; }
1threat
NSAttributedStringKey giving an unresolved identifier error : <p>I'm following an online tutorial to build a magazine type iOS application. I'm attempting to use NSAttributedStringKey but keep getting the error shown below. Any ideas?</p> <p>This is the line of code that is causing the error:</p> <pre><code>let attrs = [NSAttributedStringKey.foregroundColor: color, NSAttributedStringKey.font: font] as [NSAttributedStringKey : Any] </code></pre>
0debug
i want apply different width in option menu but it's take first : i want to apply different width in different option menu but when page load my js is run and take default 25% width in all page option menu i need 25% width in header file and header include in all file so header first js is run and page option menu take also 25% width so what i do for assign different width in header and also page he my js and css is given and i try to apply inline css it's not working and also make different class and different js but its also not working because first run header js and it's width 25% so what i do for solve this issue. pls help me. <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-js --> this one is my js file ! function(t) { var e = t('<div class="stb-select-container"><span class="selected"></span></div>'), n = t('<ul class="stb-select" style="display:none;"></ul>'); t.fn.stbDropdown = function() { var i = t(this); i.hide(), i.each(function(i, a) { var o = e.clone(), s = n.clone(), r = t(a), c = r.find("option"); r.after(o), r.appendTo(o), s.appendTo(o), c.each(function(e, n) { var i = t(n), a = t("<li></li>"), o = i.prop("attributes"); a.prop("attributes", o), t.each(o, function(t, e) { a.attr(e.name, e.value) }), a.append(i.text()), s.append(a) }); var l, p = r.children("option").filter(function(e, n) { return t(n).is("[selected]") }); l = 0 == p.length ? c.first() : p.first(), o.find(".selected").text(l.text()), o.on("click.stb.select", function() { var e = t(this), n = t.grep(t(".stb-select-container"), function(n) { return !e.is(t(n)) }); t(n).find("ul").hide(), e.find("ul").toggle() }), o.on("click.stb.option", "li", function(e) { e.stopPropagation(); var n = t(this), i = n.parents(".stb-select-container"), a = i.find("span.selected"); a.text(n.text()), n.parents("ul").toggle(); var o = i.find("select"); o.val(n.attr("value")).change(), n.siblings().removeAttr("selected"), n.attr("selected", "selected") }), r.on("DOMNodeInserted", function(e) { var n = t(e.target); if (n.is("option")) { var i = t("<li></li>"), a = n.prop("attributes"); i.prop("attributes", a), t.each(a, function(t, e) { i.attr(e.name, e.value) }), i.append(n.text()), s.append(i) } }), r.on("DOMNodeRemoved", function(e) { var n = t(e.target); n.is("option") && s.find("li:contains('" + n.text() + "')").remove() }) }) } }(jQuery); <!-- language: lang-css --> .stb-select-container { font-family: inherit; /*border-radius: 4px;*/ width: 25%; /*width: 100%;*/ display: inline-block; outline: 0; box-shadow: none; border-right: 1px solid #ccc; /*border: solid thin rgba(0, 0, 0, 0.24);*/ padding: 14px 16px; /* margin: 4px 8px;*/ outline: 0; -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; position: relative; text-align: left; cursor: pointer } .stb-select-container ul { list-style-type: none; margin: 0; padding: 0 } .stb-select-container select { display: none } .stb-select-container .stb-select { position: absolute; background: white; left: -1px; top: 50px; padding: 8px 16px; border: solid thin rgba(0, 0, 0, 0.24); border-top: 0; z-index: 10; max-height: 200px; width: 100%; overflow-x: auto; -webkit-border-bottom-left-radius: 4px; -moz-border-bottom-left-radius: 4px; border-bottom-left-radius: 4px; -webkit-border-bottom-right-radius: 4px; -moz-border-bottom-right-radius: 4px; border-bottom-right-radius: 4px } .stb-select-container span { opacity: .54 } .stb-select-container::after { opacity: .54; content: "v"; position: absolute; right: 8px; -ms-transform: scaleY(0.5); -webkit-transform: scaleY(0.5); transform: scaleY(0.5) } .stb-select-container .stb-select li { opacity: .7 } .stb-select-container .stb-select li:first-of-type { /* opacity: .34*/ } .stb-select-container .stb-select li+li { margin-top: 10px } .stb-select-container .stb-select li:hover{ color:#3EA9D8; } @media screen and (max-width: 768px) { .stb-select-container { font-family: inherit; font-size: 16px; /*border-radius: 4px;*/ width: 100%; display: inline-block; outline: 0; box-shadow: none; border: 2px solid #e9e9e9; /*border: solid thin rgba(0, 0, 0, 0.24);*/ padding: 12px 12px; /* margin: 4px 8px;*/ outline: 0; -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; position: relative; text-align: left; cursor: pointer } } this one is my html code <!-- language: lang-html --> <select name="city" id="city_result" style="height: 50px; width:100%; margin: 0px; padding: 10px; box-shadow: 0px 0px 0px white; border: none;"> <option>Your city</option> </select> <!-- end snippet -->
0debug
CSS change button style after click : <p>I was wondering if there was a way to change a button's style, in css, after it's been clicked, so not a <code>element:active</code>. Thanks!</p>
0debug
How to do Onehotencoding in Sklearn Pipeline : <p>I am trying to oneHotEncode the categorical variables of my Pandas dataframe, which includes both categorical and continues variables. I realise this can be done easily with the pandas .get_dummies() function, but I need to use a pipeline so I can generate a PMML-file later on.</p> <p>This is the code to create a mapper. The categorical variables I would like to encode are stored in a list called 'dummies'.</p> <pre><code>from sklearn_pandas import DataFrameMapper from sklearn.preprocessing import OneHotEncoder from sklearn.preprocessing import LabelEncoder mapper = DataFrameMapper( [(d, LabelEncoder()) for d in dummies] + [(d, OneHotEncoder()) for d in dummies] ) </code></pre> <p>And this is the code to create a pipeline, including the mapper and linear regression.</p> <pre><code>from sklearn2pmml import PMMLPipeline from sklearn.linear_model import LinearRegression lm = PMMLPipeline([("mapper", mapper), ("regressor", LinearRegression())]) </code></pre> <p>When I now try to fit (with 'features' being a dataframe, and 'targets' a series), it gives an error 'could not convert string to float'.</p> <pre><code>lm.fit(features, targets) </code></pre> <p>Anyone who can help me out? I am desperate for working pipelines including the preprocessing of data... Thanks in advance!</p>
0debug
static int vt82c686b_initfn(PCIDevice *d) { uint8_t *pci_conf; uint8_t *wmask; int i; isa_bus_new(&d->qdev); pci_conf = d->config; pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_VIA); pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_VIA_ISA_BRIDGE); pci_config_set_class(pci_conf, PCI_CLASS_BRIDGE_ISA); pci_config_set_prog_interface(pci_conf, 0x0); pci_config_set_revision(pci_conf,0x40); wmask = d->wmask; for (i = 0x00; i < 0xff; i++) { if (i<=0x03 || (i>=0x08 && i<=0x3f)) { wmask[i] = 0x00; } } qemu_register_reset(vt82c686b_reset, d); return 0; }
1threat
How to export data from c# console application to Excel : <p>i have some rows and columns in c# console output, i want to export this to excel.any advice? Thanks</p>
0debug
Database connect in PHP 7 : <p>but i do not understand what i am doing wrong and why it is not working ? </p> <p>Seems like it connects with DB, but it wont update DB table. </p> <p>My PHP code </p> <pre><code>&lt;?php $host = 'localhost'; $db_name = 'db_name'; $db_user = 'user'; $db_password = 'password'; $con = mysqli_connect($host, $db_user, $db_password, $db_name); if (!$con) { die("Connection failed: " . mysqli_connect_error()); } function _VoteReward($custom) { $sql = "UPDATE `users` SET `gold` = `gold` + 50000 WHERE `id` = '".$custom."' "; mysqli_query($con, $sql); } $custom = $_POST["custom"]; $key = $_POST["key"]; $result = false; if (($custom &gt; 0) &amp;&amp; ($key == 'key')) { $result = true; _VoteReward($custom); } mysqli_close($con); ?&gt; </code></pre>
0debug
React Native: Generate .apk and .ipa using Expo : <p>I'm trying to generate a .ipa and a .apk file for my React Native app using Expo &amp; Create React Native App. I successfully built the app and was able to get it to run on both an iOS &amp; an Android device thanks to the docs: <a href="https://docs.expo.io/versions/v16.0.0/guides/building-standalone-apps.html" rel="noreferrer">https://docs.expo.io/versions/v16.0.0/guides/building-standalone-apps.html</a></p> <p>When the build is over, my console shows something like </p> <blockquote> <p>Your URL is <a href="https://exp.host/@myname/myapp" rel="noreferrer">https://exp.host/@myname/myapp</a></p> </blockquote> <p>I then open <code>exp.host/@myname/myapp</code> on my device and the app shows up via the Expo client. </p> <p>But at point 4 of the docs, it is said that </p> <blockquote> <p>When it’s done, you’ll see the url of a .apk (Android) or .ipa (iOS) file — this is your app.</p> </blockquote> <p>I'm a bit confused. No where in the process do I see any ipa or apk file generated anywhere on my pc. Am I missing something ? How do I actually generate the files ?</p>
0debug
RxSwift/RxCocoa: prevent UITextField from having more than ... characters : <p>I would like to have a UITextField configured with RxSwift/RxCocoa so that it only contains up to ... characters. I do not want to use the <code>UITextFieldDelegate</code> for this but would love to achieve this with RxSwift/RxCocoa. Is there a way to do this?</p>
0debug
What is the average migrate time from SVN to GIT using Subgit : <p>I would like to use subgit to migrate all branches, tags and trunks from svn to git. What is average time it takes to import everything from svn to git using subgit?</p>
0debug
static void jpeg_prepare_row(VncState *vs, uint8_t *dst, int x, int y, int count) { if (vs->tight_pixel24) jpeg_prepare_row24(vs, dst, x, y, count); else if (ds_get_bytes_per_pixel(vs->ds) == 4) jpeg_prepare_row32(vs, dst, x, y, count); else jpeg_prepare_row16(vs, dst, x, y, count); }
1threat
Make Puppeteer use local profile's cookies : <p>I want to use my local user's profile with Puppeteer. However, it doesn't seem to work.</p> <p>I launch it with these args.</p> <pre><code>const browser = await puppeteer.launch({ executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', userDataDir: '/Users/me/Library/Application Support/Google/Chrome', }); </code></pre> <p>When headless, it doesn't use the user's local profile's cookies at all, even though I'd expect it to. When it isn't headless, it can't even open the tab; Puppeteer crashes with</p> <pre><code>(node:23303) UnhandledPromiseRejectionWarning: Error: Failed to launch chrome! TROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md </code></pre> <p>Is there a way to use my local user's profile? I'm using <code>^1.7.0</code> and Chrome <code>70.0.3521.2</code>.</p>
0debug
How to add class all row : In given example, I can select/deselect each row on clicking on checkbox from td, but how to select/deselect all row on click id="selectAll" from th **JS :** $(document).ready(function () { $("input[type='checkbox']").change(function (e) { if ($(this).is(":checked")) { $(this).closest('tr').addClass("warning"); } else { $(this).closest('tr').removeClass("warning"); } }); }); **Demo Here (Fiddle)** [1]: https://fiddle.jshell.net/w9zkwb1f/
0debug
void bdrv_set_enable_write_cache(BlockDriverState *bs, bool wce) { bs->enable_write_cache = wce; if (wce) { bs->open_flags |= BDRV_O_CACHE_WB; } else { bs->open_flags &= ~BDRV_O_CACHE_WB; } }
1threat
static int start_ebml_master_crc32(AVIOContext *pb, AVIOContext **dyn_cp, ebml_master *master, unsigned int elementid, uint64_t expectedsize) { int ret; if ((ret = avio_open_dyn_buf(dyn_cp)) < 0) return ret; if (pb->seekable) *master = start_ebml_master(pb, elementid, expectedsize); else *master = start_ebml_master(*dyn_cp, elementid, expectedsize); return 0; }
1threat
static void dma_blk_cb(void *opaque, int ret) { DMAAIOCB *dbs = (DMAAIOCB *)opaque; dma_addr_t cur_addr, cur_len; void *mem; trace_dma_blk_cb(dbs, ret); dbs->acb = NULL; dbs->sector_num += dbs->iov.size / 512; if (dbs->sg_cur_index == dbs->sg->nsg || ret < 0) { dma_complete(dbs, ret); return; } dma_blk_unmap(dbs); while (dbs->sg_cur_index < dbs->sg->nsg) { cur_addr = dbs->sg->sg[dbs->sg_cur_index].base + dbs->sg_cur_byte; cur_len = dbs->sg->sg[dbs->sg_cur_index].len - dbs->sg_cur_byte; mem = dma_memory_map(dbs->sg->as, cur_addr, &cur_len, dbs->dir); if (!mem) break; qemu_iovec_add(&dbs->iov, mem, cur_len); dbs->sg_cur_byte += cur_len; if (dbs->sg_cur_byte == dbs->sg->sg[dbs->sg_cur_index].len) { dbs->sg_cur_byte = 0; ++dbs->sg_cur_index; } } if (dbs->iov.size == 0) { trace_dma_map_wait(dbs); cpu_register_map_client(dbs, continue_after_map_failure); return; } if (dbs->iov.size & ~BDRV_SECTOR_MASK) { qemu_iovec_discard_back(&dbs->iov, dbs->iov.size & ~BDRV_SECTOR_MASK); } dbs->acb = dbs->io_func(dbs->blk, dbs->sector_num, &dbs->iov, dbs->iov.size / 512, dma_blk_cb, dbs); assert(dbs->acb); }
1threat
Can I update an app while it's available for Pre-Order in the App-Store : <p>My app has been approved for release. I submitted the build only to be able to offer it for Pre-Order. There are still some final changes I would like to make before the actual release.</p> <p>Now that I am about to hit that 'Release as Pre-Order' Button, I'm starting to wonder if I will be able to update this build without any trouble.</p> <p>Currently my build number approved for release is 0.6.4</p> <p>I would like to make some changes and set it to 1.0 for the release. Is that going to be an issue for anyone who has already signed up for Pre-Order? I imagine there will be a way to replace the build once a new one is approved. But I want to be sure.</p> <p>Thanks in advance for any advice on this.</p>
0debug
When do we use newtype in Haskell? : <p>I'm a bit confused with type and newtype. It is said that newtype can contain only one field. I also find a post <a href="https://stackoverflow.com/questions/31815310/the-difference-between-type-and-newtype-in-haskell">here</a>.</p> <p>But still not quite clear. </p> <blockquote> <p>So if you want to declare different type class instances for a particular type, or want to make a type abstract, you can wrap it in a newtype and it'll be considered distinct to the type-checker, but identical at runtime.</p> </blockquote> <p>Any example would be helpful. Thank you!</p>
0debug
React Apollo: Dynamically update GraphQL query from Component state : <p>I have a component that shows results from a GraphQL query using the <code>react-apollo</code> decorator syntax. The query accepts a parameter, which I want to set dynamically based on component state.</p> <p>Consider the following simplified example:</p> <pre><code>import * as React from ‘react’; import { graphql } from ‘react-apollo’; import gql from ‘graphql-tag’; const myQuery = gql` query($active: boolean!) { items(active: $active) { } } `; @graphql(myQuery) class MyQueryResultComponent extends React.Component { public render() { return &lt;div&gt; &lt;input type=“checkbox” /* other attributes and bindings */ /&gt; {this.props.data.items} &lt;div&gt;; } } </code></pre> <p>When the checkbox is clicked I want to resubmit the query, dynamically setting the <code>active</code> attribute in <code>myQuery</code>, based on the state of the checkbox. I've omitted the handler and bindings of the checkbox for brevity, but how can I cause the query to be re-submitted upon a state change?</p>
0debug
What does this expression do?(Python) : I have this line: theta1 = zeros((3,2)) #this is a 3x2 matrix theta0 = zeros((2,1)) #this is a 2x1 matrix thetares = theta1.dot(theta0) #3x2 * 2x1 -> 3x1 res0 = thetares.T.dot(thetares)[0,0] #result 0.0 res1 = thetares.T.dot(thetares) #result [[0.]] but I dont know, what does this **[0,0]** at the end of the expression of **res0**. res0 and res1 result will be a 1x1 matrix
0debug
static int can_merge_formats(AVFilterFormats *a_arg, AVFilterFormats *b_arg, enum AVMediaType type, int is_sample_rate) { AVFilterFormats *a, *b, *ret; if (a == b) return 1; a = clone_filter_formats(a_arg); b = clone_filter_formats(b_arg); if (is_sample_rate) { ret = ff_merge_samplerates(a, b); } else { ret = ff_merge_formats(a, b, type); } if (ret) { av_freep(&ret->formats); av_freep(&ret); return 1; } else { av_freep(&a->formats); av_freep(&b->formats); av_freep(&a); av_freep(&b); return 0; } }
1threat
isset($_SESSION['id']) is not working properly : <p>I am trying to use the condition:</p> <blockquote> <p>isset($_SESSION['id'])</p> </blockquote> <p>So i just tried </p> <blockquote> <p>echo isset($_SESSION['id']); and echo $_SESSION['id'];</p> </blockquote> <p>But this gives output different. In fact true result gives by </p> <blockquote> <p>echo $_SESSION['id'];</p> </blockquote> <p>Any one have idea why this is happening? <br /><strong>Note:</strong> I use <code>session_start();</code> at the beginning of page.</p>
0debug
Postgre sql query ? whats wrong with the having clause in my query? : Select facid, sum(slots) as total from cd.bookings group by facid having total > 1000 oerder by facid;
0debug
I want to use SQL in my app | Alamofire, Swift : <p>I want to use a localhost database in SQL for my IOS's app, how can I use .POST in a specific table ?</p> <p>PD: I use Alamofire in Swift.</p>
0debug
void ff_http_auth_handle_header(HTTPAuthState *state, const char *key, const char *value) { if (!strcmp(key, "WWW-Authenticate") || !strcmp(key, "Proxy-Authenticate")) { const char *p; if (av_stristart(value, "Basic ", &p) && state->auth_type <= HTTP_AUTH_BASIC) { state->auth_type = HTTP_AUTH_BASIC; state->realm[0] = 0; state->stale = 0; ff_parse_key_value(p, (ff_parse_key_val_cb) handle_basic_params, state); } else if (av_stristart(value, "Digest ", &p) && state->auth_type <= HTTP_AUTH_DIGEST) { state->auth_type = HTTP_AUTH_DIGEST; memset(&state->digest_params, 0, sizeof(DigestParams)); state->realm[0] = 0; state->stale = 0; ff_parse_key_value(p, (ff_parse_key_val_cb) handle_digest_params, state); choose_qop(state->digest_params.qop, sizeof(state->digest_params.qop)); if (!av_strcasecmp(state->digest_params.stale, "true")) state->stale = 1; } } else if (!strcmp(key, "Authentication-Info")) { ff_parse_key_value(value, (ff_parse_key_val_cb) handle_digest_update, state); } }
1threat
static int test_scalarproduct_float(AVFloatDSPContext *fdsp, AVFloatDSPContext *cdsp, const float *v1, const float *v2) { float cprod, oprod; int ret; cprod = cdsp->scalarproduct_float(v1, v2, LEN); oprod = fdsp->scalarproduct_float(v1, v2, LEN); if (ret = compare_floats(&cprod, &oprod, 1, ARBITRARY_SCALARPRODUCT_CONST)) av_log(NULL, AV_LOG_ERROR, "scalarproduct_float failed\n"); return ret; }
1threat
Angular cli after update npm start give error : <p>I create application using angular cli and use backend proxy to handle backend and using polymer(vaadin) it work correctly until I update to angular cli 1.0.0-beta.22 it give Error </p> <pre><code>Tried to find bootstrap code, but could not. Specify either statically analyzable bootstrap code or pass in an entryModule to the plugins options. </code></pre> <p><strong>proxy.conf.json</strong></p> <pre><code>{ "/api": { "target": "http://127.0.0.1:3000", "secure": false } } </code></pre> <p><strong>main-polymer.ts</strong></p> <pre><code>document.addEventListener('WebComponentsReady', () =&gt; { require('./main.ts'); }); </code></pre> <p><strong>main.ts</strong></p> <pre><code>import './polyfills.ts'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { enableProdMode } from '@angular/core'; import { environment } from './environments/environment'; import { AppModule } from './app/'; if (environment.production) { enableProdMode(); } // platformBrowserDynamic().bootstrapModule(AppModule); platformBrowserDynamic().bootstrapModule(AppModule); </code></pre> <p>how can I correct this?.</p>
0debug
static void setup_frame(int sig, struct target_sigaction * ka, target_sigset_t *set, CPUMIPSState *regs) { struct sigframe *frame; abi_ulong frame_addr; int i; frame_addr = get_sigframe(ka, regs, sizeof(*frame)); if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) goto give_sigsegv; install_sigtramp(frame->sf_code, TARGET_NR_sigreturn); if(setup_sigcontext(regs, &frame->sf_sc)) goto give_sigsegv; for(i = 0; i < TARGET_NSIG_WORDS; i++) { if(__put_user(set->sig[i], &frame->sf_mask.sig[i])) goto give_sigsegv; } regs->active_tc.gpr[ 4] = sig; regs->active_tc.gpr[ 5] = 0; regs->active_tc.gpr[ 6] = frame_addr + offsetof(struct sigframe, sf_sc); regs->active_tc.gpr[29] = frame_addr; regs->active_tc.gpr[31] = frame_addr + offsetof(struct sigframe, sf_code); regs->active_tc.PC = regs->active_tc.gpr[25] = ka->_sa_handler; mips_set_hflags_isa_mode_from_pc(regs); unlock_user_struct(frame, frame_addr, 1); return; give_sigsegv: unlock_user_struct(frame, frame_addr, 1); force_sig(TARGET_SIGSEGV); }
1threat
static void disas_sparc_insn(DisasContext * dc, unsigned int insn) { unsigned int opc, rs1, rs2, rd; TCGv cpu_src1, cpu_src2, cpu_tmp1, cpu_tmp2; TCGv_i32 cpu_src1_32, cpu_src2_32, cpu_dst_32; TCGv_i64 cpu_src1_64, cpu_src2_64, cpu_dst_64; target_long simm; if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) { tcg_gen_debug_insn_start(dc->pc); } opc = GET_FIELD(insn, 0, 1); rd = GET_FIELD(insn, 2, 6); cpu_tmp1 = cpu_src1 = tcg_temp_new(); cpu_tmp2 = cpu_src2 = tcg_temp_new(); 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, 19); 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; cpu_src1 = get_src1(dc, insn); do_branch_reg(dc, target, insn, cpu_src1); 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: if (rd) { uint32_t value = GET_FIELD(insn, 10, 31); TCGv t = gen_dest_gpr(dc, rd); tcg_gen_movi_tl(t, value << 10); gen_store_gpr(dc, rd, t); } break; case 0x0: default: goto illegal_insn; } break; } break; case 1: { target_long target = GET_FIELDs(insn, 2, 31) << 2; TCGv o7 = gen_dest_gpr(dc, 15); tcg_gen_movi_tl(o7, dc->pc); gen_store_gpr(dc, 15, o7); target += dc->pc; gen_mov_pc_npc(dc); #ifdef TARGET_SPARC64 if (unlikely(AM_CHECK(dc))) { target &= 0xffffffffULL; } #endif dc->npc = target; } goto jmp_insn; case 2: { unsigned int xop = GET_FIELD(insn, 7, 12); if (xop == 0x3a) { int cond = GET_FIELD(insn, 3, 6); TCGv_i32 trap; int l1 = -1, mask; if (cond == 0) { break; } save_state(dc); if (cond != 8) { DisasCompare cmp; #ifdef TARGET_SPARC64 int cc = GET_FIELD_SP(insn, 11, 12); if (cc == 0) { gen_compare(&cmp, 0, cond, dc); } else if (cc == 2) { gen_compare(&cmp, 1, cond, dc); } else { goto illegal_insn; } #else gen_compare(&cmp, 0, cond, dc); #endif l1 = gen_new_label(); tcg_gen_brcond_tl(tcg_invert_cond(cmp.cond), cmp.c1, cmp.c2, l1); free_compare(&cmp); } mask = ((dc->def->features & CPU_FEATURE_HYPV) && supervisor(dc) ? UA2005_HTRAP_MASK : V8_TRAP_MASK); trap = tcg_temp_new_i32(); rs1 = GET_FIELD_SP(insn, 14, 18); if (IS_IMM) { rs2 = GET_FIELD_SP(insn, 0, 6); if (rs1 == 0) { tcg_gen_movi_i32(trap, (rs2 & mask) + TT_TRAP); mask = 0; } else { TCGv t1 = gen_load_gpr(dc, rs1); tcg_gen_trunc_tl_i32(trap, t1); tcg_gen_addi_i32(trap, trap, rs2); } } else { TCGv t1, t2; rs2 = GET_FIELD_SP(insn, 0, 4); t1 = gen_load_gpr(dc, rs1); t2 = gen_load_gpr(dc, rs2); tcg_gen_add_tl(t1, t1, t2); tcg_gen_trunc_tl_i32(trap, t1); } if (mask != 0) { tcg_gen_andi_i32(trap, trap, mask); tcg_gen_addi_i32(trap, trap, TT_TRAP); } gen_helper_raise_exception(cpu_env, trap); tcg_temp_free_i32(trap); if (cond == 8) { dc->is_br = 1; goto jmp_insn; } else { gen_set_label(l1); break; } } 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: if (rs1 == 0x11 && dc->def->features & CPU_FEATURE_ASR17) { TCGv t = gen_dest_gpr(dc, rd); tcg_gen_movi_tl(t, (1 << 8) | (dc->def->nwindows - 1)); gen_store_gpr(dc, rd, t); break; } #endif gen_store_gpr(dc, rd, cpu_y); break; #ifdef TARGET_SPARC64 case 0x2: update_psr(dc); gen_helper_rdccr(cpu_dst, cpu_env); gen_store_gpr(dc, rd, cpu_dst); break; case 0x3: tcg_gen_ext_i32_tl(cpu_dst, cpu_asi); gen_store_gpr(dc, rd, cpu_dst); break; case 0x4: { TCGv_ptr r_tickptr; r_tickptr = tcg_temp_new_ptr(); tcg_gen_ld_ptr(r_tickptr, cpu_env, offsetof(CPUSPARCState, tick)); gen_helper_tick_get_count(cpu_dst, r_tickptr); tcg_temp_free_ptr(r_tickptr); gen_store_gpr(dc, rd, cpu_dst); } break; case 0x5: { TCGv t = gen_dest_gpr(dc, rd); if (unlikely(AM_CHECK(dc))) { tcg_gen_movi_tl(t, dc->pc & 0xffffffffULL); } else { tcg_gen_movi_tl(t, dc->pc); } gen_store_gpr(dc, rd, t); } break; case 0x6: tcg_gen_ext_i32_tl(cpu_dst, cpu_fprs); gen_store_gpr(dc, rd, cpu_dst); break; case 0xf: break; case 0x13: if (gen_trap_ifnofpu(dc)) { goto jmp_insn; } gen_store_gpr(dc, rd, cpu_gsr); break; case 0x16: tcg_gen_ext_i32_tl(cpu_dst, cpu_softint); gen_store_gpr(dc, rd, cpu_dst); break; case 0x17: gen_store_gpr(dc, rd, cpu_tick_cmpr); break; case 0x18: { TCGv_ptr r_tickptr; r_tickptr = tcg_temp_new_ptr(); tcg_gen_ld_ptr(r_tickptr, cpu_env, offsetof(CPUSPARCState, stick)); gen_helper_tick_get_count(cpu_dst, r_tickptr); tcg_temp_free_ptr(r_tickptr); gen_store_gpr(dc, rd, cpu_dst); } break; case 0x19: gen_store_gpr(dc, rd, cpu_stick_cmpr); break; case 0x10: case 0x11: case 0x12: case 0x14: case 0x15: #endif default: goto illegal_insn; } #if !defined(CONFIG_USER_ONLY) } else if (xop == 0x29) { #ifndef TARGET_SPARC64 if (!supervisor(dc)) { goto priv_insn; } update_psr(dc); gen_helper_rdpsr(cpu_dst, cpu_env); #else CHECK_IU_FEATURE(dc, HYPV); if (!hypervisor(dc)) goto priv_insn; rs1 = GET_FIELD(insn, 13, 17); switch (rs1) { case 0: break; case 1: break; case 3: tcg_gen_mov_tl(cpu_dst, cpu_hintp); break; case 5: tcg_gen_mov_tl(cpu_dst, cpu_htba); break; case 6: tcg_gen_mov_tl(cpu_dst, cpu_hver); break; case 31: tcg_gen_mov_tl(cpu_dst, cpu_hstick_cmpr); break; default: goto illegal_insn; } #endif gen_store_gpr(dc, rd, cpu_dst); break; } else if (xop == 0x2a) { if (!supervisor(dc)) goto priv_insn; #ifdef TARGET_SPARC64 rs1 = GET_FIELD(insn, 13, 17); switch (rs1) { case 0: { TCGv_ptr r_tsptr; r_tsptr = tcg_temp_new_ptr(); gen_load_trap_state_at_tl(r_tsptr, cpu_env); tcg_gen_ld_tl(cpu_tmp0, r_tsptr, offsetof(trap_state, tpc)); tcg_temp_free_ptr(r_tsptr); } break; case 1: { TCGv_ptr r_tsptr; r_tsptr = tcg_temp_new_ptr(); gen_load_trap_state_at_tl(r_tsptr, cpu_env); tcg_gen_ld_tl(cpu_tmp0, r_tsptr, offsetof(trap_state, tnpc)); tcg_temp_free_ptr(r_tsptr); } break; case 2: { TCGv_ptr r_tsptr; r_tsptr = tcg_temp_new_ptr(); gen_load_trap_state_at_tl(r_tsptr, cpu_env); tcg_gen_ld_tl(cpu_tmp0, r_tsptr, offsetof(trap_state, tstate)); tcg_temp_free_ptr(r_tsptr); } break; case 3: { TCGv_ptr r_tsptr; r_tsptr = tcg_temp_new_ptr(); gen_load_trap_state_at_tl(r_tsptr, cpu_env); tcg_gen_ld_i32(cpu_tmp32, r_tsptr, offsetof(trap_state, tt)); tcg_temp_free_ptr(r_tsptr); tcg_gen_ext_i32_tl(cpu_tmp0, cpu_tmp32); } break; case 4: { TCGv_ptr r_tickptr; r_tickptr = tcg_temp_new_ptr(); tcg_gen_ld_ptr(r_tickptr, cpu_env, offsetof(CPUSPARCState, tick)); gen_helper_tick_get_count(cpu_tmp0, r_tickptr); tcg_temp_free_ptr(r_tickptr); } break; case 5: tcg_gen_mov_tl(cpu_tmp0, cpu_tbr); break; case 6: tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, pstate)); tcg_gen_ext_i32_tl(cpu_tmp0, cpu_tmp32); break; case 7: tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, tl)); tcg_gen_ext_i32_tl(cpu_tmp0, cpu_tmp32); break; case 8: tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, psrpil)); tcg_gen_ext_i32_tl(cpu_tmp0, cpu_tmp32); break; case 9: gen_helper_rdcwp(cpu_tmp0, cpu_env); break; case 10: tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, cansave)); tcg_gen_ext_i32_tl(cpu_tmp0, cpu_tmp32); break; case 11: tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, canrestore)); tcg_gen_ext_i32_tl(cpu_tmp0, cpu_tmp32); break; case 12: tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, cleanwin)); tcg_gen_ext_i32_tl(cpu_tmp0, cpu_tmp32); break; case 13: tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, otherwin)); tcg_gen_ext_i32_tl(cpu_tmp0, cpu_tmp32); break; case 14: tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, wstate)); tcg_gen_ext_i32_tl(cpu_tmp0, cpu_tmp32); break; case 16: CHECK_IU_FEATURE(dc, GL); tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, gl)); tcg_gen_ext_i32_tl(cpu_tmp0, cpu_tmp32); break; case 26: CHECK_IU_FEATURE(dc, HYPV); if (!hypervisor(dc)) goto priv_insn; tcg_gen_mov_tl(cpu_tmp0, cpu_ssr); break; case 31: tcg_gen_mov_tl(cpu_tmp0, cpu_ver); break; case 15: default: goto illegal_insn; } #else tcg_gen_ext_i32_tl(cpu_tmp0, cpu_wim); #endif gen_store_gpr(dc, rd, cpu_tmp0); break; } else if (xop == 0x2b) { #ifdef TARGET_SPARC64 save_state(dc); gen_helper_flushw(cpu_env); #else if (!supervisor(dc)) goto priv_insn; gen_store_gpr(dc, rd, cpu_tbr); #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); save_state(dc); switch (xop) { case 0x1: cpu_src1_32 = gen_load_fpr_F(dc, rs2); gen_store_fpr_F(dc, rd, cpu_src1_32); break; case 0x5: gen_ne_fop_FF(dc, rd, rs2, gen_helper_fnegs); break; case 0x9: gen_ne_fop_FF(dc, rd, rs2, gen_helper_fabss); break; case 0x29: CHECK_FPU_FEATURE(dc, FSQRT); gen_fop_FF(dc, rd, rs2, gen_helper_fsqrts); break; case 0x2a: CHECK_FPU_FEATURE(dc, FSQRT); gen_fop_DD(dc, rd, rs2, gen_helper_fsqrtd); break; case 0x2b: CHECK_FPU_FEATURE(dc, FLOAT128); gen_fop_QQ(dc, rd, rs2, gen_helper_fsqrtq); break; case 0x41: gen_fop_FFF(dc, rd, rs1, rs2, gen_helper_fadds); break; case 0x42: gen_fop_DDD(dc, rd, rs1, rs2, gen_helper_faddd); break; case 0x43: CHECK_FPU_FEATURE(dc, FLOAT128); gen_fop_QQQ(dc, rd, rs1, rs2, gen_helper_faddq); break; case 0x45: gen_fop_FFF(dc, rd, rs1, rs2, gen_helper_fsubs); break; case 0x46: gen_fop_DDD(dc, rd, rs1, rs2, gen_helper_fsubd); break; case 0x47: CHECK_FPU_FEATURE(dc, FLOAT128); gen_fop_QQQ(dc, rd, rs1, rs2, gen_helper_fsubq); break; case 0x49: CHECK_FPU_FEATURE(dc, FMUL); gen_fop_FFF(dc, rd, rs1, rs2, gen_helper_fmuls); break; case 0x4a: CHECK_FPU_FEATURE(dc, FMUL); gen_fop_DDD(dc, rd, rs1, rs2, gen_helper_fmuld); break; case 0x4b: CHECK_FPU_FEATURE(dc, FLOAT128); CHECK_FPU_FEATURE(dc, FMUL); gen_fop_QQQ(dc, rd, rs1, rs2, gen_helper_fmulq); break; case 0x4d: gen_fop_FFF(dc, rd, rs1, rs2, gen_helper_fdivs); break; case 0x4e: gen_fop_DDD(dc, rd, rs1, rs2, gen_helper_fdivd); break; case 0x4f: CHECK_FPU_FEATURE(dc, FLOAT128); gen_fop_QQQ(dc, rd, rs1, rs2, gen_helper_fdivq); break; case 0x69: CHECK_FPU_FEATURE(dc, FSMULD); gen_fop_DFF(dc, rd, rs1, rs2, gen_helper_fsmuld); break; case 0x6e: CHECK_FPU_FEATURE(dc, FLOAT128); gen_fop_QDD(dc, rd, rs1, rs2, gen_helper_fdmulq); break; case 0xc4: gen_fop_FF(dc, rd, rs2, gen_helper_fitos); break; case 0xc6: gen_fop_FD(dc, rd, rs2, gen_helper_fdtos); break; case 0xc7: CHECK_FPU_FEATURE(dc, FLOAT128); gen_fop_FQ(dc, rd, rs2, gen_helper_fqtos); break; case 0xc8: gen_ne_fop_DF(dc, rd, rs2, gen_helper_fitod); break; case 0xc9: gen_ne_fop_DF(dc, rd, rs2, gen_helper_fstod); break; case 0xcb: CHECK_FPU_FEATURE(dc, FLOAT128); gen_fop_DQ(dc, rd, rs2, gen_helper_fqtod); break; case 0xcc: CHECK_FPU_FEATURE(dc, FLOAT128); gen_ne_fop_QF(dc, rd, rs2, gen_helper_fitoq); break; case 0xcd: CHECK_FPU_FEATURE(dc, FLOAT128); gen_ne_fop_QF(dc, rd, rs2, gen_helper_fstoq); break; case 0xce: CHECK_FPU_FEATURE(dc, FLOAT128); gen_ne_fop_QD(dc, rd, rs2, gen_helper_fdtoq); break; case 0xd1: gen_fop_FF(dc, rd, rs2, gen_helper_fstoi); break; case 0xd2: gen_fop_FD(dc, rd, rs2, gen_helper_fdtoi); break; case 0xd3: CHECK_FPU_FEATURE(dc, FLOAT128); gen_fop_FQ(dc, rd, rs2, gen_helper_fqtoi); break; #ifdef TARGET_SPARC64 case 0x2: cpu_src1_64 = gen_load_fpr_D(dc, rs2); gen_store_fpr_D(dc, rd, cpu_src1_64); break; case 0x3: CHECK_FPU_FEATURE(dc, FLOAT128); gen_move_Q(rd, rs2); break; case 0x6: gen_ne_fop_DD(dc, rd, rs2, gen_helper_fnegd); break; case 0x7: CHECK_FPU_FEATURE(dc, FLOAT128); gen_ne_fop_QQ(dc, rd, rs2, gen_helper_fnegq); break; case 0xa: gen_ne_fop_DD(dc, rd, rs2, gen_helper_fabsd); break; case 0xb: CHECK_FPU_FEATURE(dc, FLOAT128); gen_ne_fop_QQ(dc, rd, rs2, gen_helper_fabsq); break; case 0x81: gen_fop_DF(dc, rd, rs2, gen_helper_fstox); break; case 0x82: gen_fop_DD(dc, rd, rs2, gen_helper_fdtox); break; case 0x83: CHECK_FPU_FEATURE(dc, FLOAT128); gen_fop_DQ(dc, rd, rs2, gen_helper_fqtox); break; case 0x84: gen_fop_FD(dc, rd, rs2, gen_helper_fxtos); break; case 0x88: gen_fop_DD(dc, rd, rs2, gen_helper_fxtod); break; case 0x8c: CHECK_FPU_FEATURE(dc, FLOAT128); gen_ne_fop_QD(dc, rd, rs2, gen_helper_fxtoq); break; #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); save_state(dc); #ifdef TARGET_SPARC64 #define FMOVR(sz) \ do { \ DisasCompare cmp; \ cond = GET_FIELD_SP(insn, 14, 17); \ cpu_src1 = get_src1(dc, insn); \ gen_compare_reg(&cmp, cond, cpu_src1); \ gen_fmov##sz(dc, &cmp, rd, rs2); \ free_compare(&cmp); \ } while (0) if ((xop & 0x11f) == 0x005) { FMOVR(s); break; } else if ((xop & 0x11f) == 0x006) { FMOVR(d); break; } else if ((xop & 0x11f) == 0x007) { CHECK_FPU_FEATURE(dc, FLOAT128); FMOVR(q); break; } #undef FMOVR #endif switch (xop) { #ifdef TARGET_SPARC64 #define FMOVCC(fcc, sz) \ do { \ DisasCompare cmp; \ cond = GET_FIELD_SP(insn, 14, 17); \ gen_fcompare(&cmp, fcc, cond); \ gen_fmov##sz(dc, &cmp, rd, rs2); \ free_compare(&cmp); \ } while (0) case 0x001: FMOVCC(0, s); break; case 0x002: FMOVCC(0, d); break; case 0x003: CHECK_FPU_FEATURE(dc, FLOAT128); FMOVCC(0, q); break; case 0x041: FMOVCC(1, s); break; case 0x042: FMOVCC(1, d); break; case 0x043: CHECK_FPU_FEATURE(dc, FLOAT128); FMOVCC(1, q); break; case 0x081: FMOVCC(2, s); break; case 0x082: FMOVCC(2, d); break; case 0x083: CHECK_FPU_FEATURE(dc, FLOAT128); FMOVCC(2, q); break; case 0x0c1: FMOVCC(3, s); break; case 0x0c2: FMOVCC(3, d); break; case 0x0c3: CHECK_FPU_FEATURE(dc, FLOAT128); FMOVCC(3, q); break; #undef FMOVCC #define FMOVCC(xcc, sz) \ do { \ DisasCompare cmp; \ cond = GET_FIELD_SP(insn, 14, 17); \ gen_compare(&cmp, xcc, cond, dc); \ gen_fmov##sz(dc, &cmp, rd, rs2); \ free_compare(&cmp); \ } while (0) case 0x101: FMOVCC(0, s); break; case 0x102: FMOVCC(0, d); break; case 0x103: CHECK_FPU_FEATURE(dc, FLOAT128); FMOVCC(0, q); break; case 0x181: FMOVCC(1, s); break; case 0x182: FMOVCC(1, d); break; case 0x183: CHECK_FPU_FEATURE(dc, FLOAT128); FMOVCC(1, q); break; #undef FMOVCC #endif case 0x51: cpu_src1_32 = gen_load_fpr_F(dc, rs1); cpu_src2_32 = gen_load_fpr_F(dc, rs2); gen_op_fcmps(rd & 3, cpu_src1_32, cpu_src2_32); break; case 0x52: cpu_src1_64 = gen_load_fpr_D(dc, rs1); cpu_src2_64 = gen_load_fpr_D(dc, rs2); gen_op_fcmpd(rd & 3, cpu_src1_64, cpu_src2_64); break; case 0x53: CHECK_FPU_FEATURE(dc, FLOAT128); gen_op_load_fpr_QT0(QFPREG(rs1)); gen_op_load_fpr_QT1(QFPREG(rs2)); gen_op_fcmpq(rd & 3); break; case 0x55: cpu_src1_32 = gen_load_fpr_F(dc, rs1); cpu_src2_32 = gen_load_fpr_F(dc, rs2); gen_op_fcmpes(rd & 3, cpu_src1_32, cpu_src2_32); break; case 0x56: cpu_src1_64 = gen_load_fpr_D(dc, rs1); cpu_src2_64 = gen_load_fpr_D(dc, rs2); gen_op_fcmped(rd & 3, cpu_src1_64, cpu_src2_64); break; case 0x57: CHECK_FPU_FEATURE(dc, FLOAT128); gen_op_load_fpr_QT0(QFPREG(rs1)); gen_op_load_fpr_QT1(QFPREG(rs2)); gen_op_fcmpeq(rd & 3); break; default: goto illegal_insn; } } else if (xop == 0x2) { TCGv dst = gen_dest_gpr(dc, rd); rs1 = GET_FIELD(insn, 13, 17); if (rs1 == 0) { if (IS_IMM) { simm = GET_FIELDs(insn, 19, 31); tcg_gen_movi_tl(dst, simm); gen_store_gpr(dc, rd, dst); } else { rs2 = GET_FIELD(insn, 27, 31); if (rs2 == 0) { tcg_gen_movi_tl(dst, 0); gen_store_gpr(dc, rd, dst); } else { cpu_src2 = gen_load_gpr(dc, rs2); gen_store_gpr(dc, rd, cpu_src2); } } } else { cpu_src1 = get_src1(dc, insn); if (IS_IMM) { simm = GET_FIELDs(insn, 19, 31); tcg_gen_ori_tl(dst, cpu_src1, simm); gen_store_gpr(dc, rd, dst); } else { rs2 = GET_FIELD(insn, 27, 31); if (rs2 == 0) { gen_store_gpr(dc, rd, cpu_src1); } else { cpu_src2 = gen_load_gpr(dc, rs2); tcg_gen_or_tl(dst, cpu_src1, cpu_src2); gen_store_gpr(dc, rd, dst); } } } #ifdef TARGET_SPARC64 } else if (xop == 0x25) { cpu_src1 = get_src1(dc, insn); if (IS_IMM) { simm = GET_FIELDs(insn, 20, 31); if (insn & (1 << 12)) { tcg_gen_shli_i64(cpu_dst, cpu_src1, simm & 0x3f); } else { tcg_gen_shli_i64(cpu_dst, cpu_src1, simm & 0x1f); } } else { rs2 = GET_FIELD(insn, 27, 31); cpu_src2 = gen_load_gpr(dc, rs2); if (insn & (1 << 12)) { tcg_gen_andi_i64(cpu_tmp0, cpu_src2, 0x3f); } else { tcg_gen_andi_i64(cpu_tmp0, cpu_src2, 0x1f); } tcg_gen_shl_i64(cpu_dst, cpu_src1, cpu_tmp0); } gen_store_gpr(dc, rd, cpu_dst); } else if (xop == 0x26) { cpu_src1 = get_src1(dc, insn); if (IS_IMM) { simm = GET_FIELDs(insn, 20, 31); if (insn & (1 << 12)) { tcg_gen_shri_i64(cpu_dst, cpu_src1, simm & 0x3f); } else { tcg_gen_andi_i64(cpu_dst, cpu_src1, 0xffffffffULL); tcg_gen_shri_i64(cpu_dst, cpu_dst, simm & 0x1f); } } else { rs2 = GET_FIELD(insn, 27, 31); cpu_src2 = gen_load_gpr(dc, rs2); if (insn & (1 << 12)) { tcg_gen_andi_i64(cpu_tmp0, cpu_src2, 0x3f); tcg_gen_shr_i64(cpu_dst, cpu_src1, cpu_tmp0); } else { tcg_gen_andi_i64(cpu_tmp0, cpu_src2, 0x1f); tcg_gen_andi_i64(cpu_dst, cpu_src1, 0xffffffffULL); tcg_gen_shr_i64(cpu_dst, cpu_dst, cpu_tmp0); } } gen_store_gpr(dc, rd, cpu_dst); } else if (xop == 0x27) { cpu_src1 = get_src1(dc, insn); if (IS_IMM) { simm = GET_FIELDs(insn, 20, 31); if (insn & (1 << 12)) { tcg_gen_sari_i64(cpu_dst, cpu_src1, simm & 0x3f); } else { tcg_gen_ext32s_i64(cpu_dst, cpu_src1); tcg_gen_sari_i64(cpu_dst, cpu_dst, simm & 0x1f); } } else { rs2 = GET_FIELD(insn, 27, 31); cpu_src2 = gen_load_gpr(dc, rs2); if (insn & (1 << 12)) { tcg_gen_andi_i64(cpu_tmp0, cpu_src2, 0x3f); tcg_gen_sar_i64(cpu_dst, cpu_src1, cpu_tmp0); } else { tcg_gen_andi_i64(cpu_tmp0, cpu_src2, 0x1f); tcg_gen_ext32s_i64(cpu_dst, cpu_src1); tcg_gen_sar_i64(cpu_dst, cpu_dst, cpu_tmp0); } } gen_store_gpr(dc, rd, cpu_dst); #endif } else if (xop < 0x36) { if (xop < 0x20) { cpu_src1 = get_src1(dc, insn); cpu_src2 = get_src2(dc, insn); switch (xop & ~0x10) { case 0x0: if (xop & 0x10) { gen_op_add_cc(cpu_dst, cpu_src1, cpu_src2); tcg_gen_movi_i32(cpu_cc_op, CC_OP_ADD); dc->cc_op = CC_OP_ADD; } else { tcg_gen_add_tl(cpu_dst, cpu_src1, cpu_src2); } break; case 0x1: tcg_gen_and_tl(cpu_dst, cpu_src1, cpu_src2); if (xop & 0x10) { tcg_gen_mov_tl(cpu_cc_dst, cpu_dst); tcg_gen_movi_i32(cpu_cc_op, CC_OP_LOGIC); dc->cc_op = CC_OP_LOGIC; } break; case 0x2: tcg_gen_or_tl(cpu_dst, cpu_src1, cpu_src2); if (xop & 0x10) { tcg_gen_mov_tl(cpu_cc_dst, cpu_dst); tcg_gen_movi_i32(cpu_cc_op, CC_OP_LOGIC); dc->cc_op = CC_OP_LOGIC; } break; case 0x3: tcg_gen_xor_tl(cpu_dst, cpu_src1, cpu_src2); if (xop & 0x10) { tcg_gen_mov_tl(cpu_cc_dst, cpu_dst); tcg_gen_movi_i32(cpu_cc_op, CC_OP_LOGIC); dc->cc_op = CC_OP_LOGIC; } break; case 0x4: if (xop & 0x10) { gen_op_sub_cc(cpu_dst, cpu_src1, cpu_src2); tcg_gen_movi_i32(cpu_cc_op, CC_OP_SUB); dc->cc_op = CC_OP_SUB; } else { tcg_gen_sub_tl(cpu_dst, cpu_src1, cpu_src2); } break; case 0x5: tcg_gen_andc_tl(cpu_dst, cpu_src1, cpu_src2); if (xop & 0x10) { tcg_gen_mov_tl(cpu_cc_dst, cpu_dst); tcg_gen_movi_i32(cpu_cc_op, CC_OP_LOGIC); dc->cc_op = CC_OP_LOGIC; } break; case 0x6: tcg_gen_orc_tl(cpu_dst, cpu_src1, cpu_src2); if (xop & 0x10) { tcg_gen_mov_tl(cpu_cc_dst, cpu_dst); tcg_gen_movi_i32(cpu_cc_op, CC_OP_LOGIC); dc->cc_op = CC_OP_LOGIC; } break; case 0x7: tcg_gen_eqv_tl(cpu_dst, cpu_src1, cpu_src2); if (xop & 0x10) { tcg_gen_mov_tl(cpu_cc_dst, cpu_dst); tcg_gen_movi_i32(cpu_cc_op, CC_OP_LOGIC); dc->cc_op = CC_OP_LOGIC; } break; case 0x8: gen_op_addx_int(dc, cpu_dst, cpu_src1, cpu_src2, (xop & 0x10)); break; #ifdef TARGET_SPARC64 case 0x9: tcg_gen_mul_i64(cpu_dst, cpu_src1, cpu_src2); break; #endif case 0xa: CHECK_IU_FEATURE(dc, MUL); gen_op_umul(cpu_dst, cpu_src1, cpu_src2); if (xop & 0x10) { tcg_gen_mov_tl(cpu_cc_dst, cpu_dst); tcg_gen_movi_i32(cpu_cc_op, CC_OP_LOGIC); dc->cc_op = CC_OP_LOGIC; } break; case 0xb: CHECK_IU_FEATURE(dc, MUL); gen_op_smul(cpu_dst, cpu_src1, cpu_src2); if (xop & 0x10) { tcg_gen_mov_tl(cpu_cc_dst, cpu_dst); tcg_gen_movi_i32(cpu_cc_op, CC_OP_LOGIC); dc->cc_op = CC_OP_LOGIC; } break; case 0xc: gen_op_subx_int(dc, cpu_dst, cpu_src1, cpu_src2, (xop & 0x10)); break; #ifdef TARGET_SPARC64 case 0xd: gen_helper_udivx(cpu_dst, cpu_env, cpu_src1, cpu_src2); break; #endif case 0xe: CHECK_IU_FEATURE(dc, DIV); if (xop & 0x10) { gen_helper_udiv_cc(cpu_dst, cpu_env, cpu_src1, cpu_src2); dc->cc_op = CC_OP_DIV; } else { gen_helper_udiv(cpu_dst, cpu_env, cpu_src1, cpu_src2); } break; case 0xf: CHECK_IU_FEATURE(dc, DIV); if (xop & 0x10) { gen_helper_sdiv_cc(cpu_dst, cpu_env, cpu_src1, cpu_src2); dc->cc_op = CC_OP_DIV; } else { gen_helper_sdiv(cpu_dst, cpu_env, cpu_src1, cpu_src2); } break; default: goto illegal_insn; } gen_store_gpr(dc, rd, cpu_dst); } else { cpu_src1 = get_src1(dc, insn); cpu_src2 = get_src2(dc, insn); switch (xop) { case 0x20: gen_op_add_cc(cpu_dst, cpu_src1, cpu_src2); gen_store_gpr(dc, rd, cpu_dst); tcg_gen_movi_i32(cpu_cc_op, CC_OP_TADD); dc->cc_op = CC_OP_TADD; break; case 0x21: gen_op_sub_cc(cpu_dst, cpu_src1, cpu_src2); gen_store_gpr(dc, rd, cpu_dst); tcg_gen_movi_i32(cpu_cc_op, CC_OP_TSUB); dc->cc_op = CC_OP_TSUB; break; case 0x22: gen_helper_taddcctv(cpu_dst, cpu_env, cpu_src1, cpu_src2); gen_store_gpr(dc, rd, cpu_dst); dc->cc_op = CC_OP_TADDTV; break; case 0x23: gen_helper_tsubcctv(cpu_dst, cpu_env, cpu_src1, cpu_src2); gen_store_gpr(dc, rd, cpu_dst); dc->cc_op = CC_OP_TSUBTV; break; case 0x24: update_psr(dc); gen_op_mulscc(cpu_dst, cpu_src1, cpu_src2); gen_store_gpr(dc, rd, cpu_dst); tcg_gen_movi_i32(cpu_cc_op, CC_OP_ADD); dc->cc_op = CC_OP_ADD; break; #ifndef TARGET_SPARC64 case 0x25: if (IS_IMM) { simm = GET_FIELDs(insn, 20, 31); tcg_gen_shli_tl(cpu_dst, cpu_src1, simm & 0x1f); } else { tcg_gen_andi_tl(cpu_tmp0, cpu_src2, 0x1f); tcg_gen_shl_tl(cpu_dst, cpu_src1, cpu_tmp0); } gen_store_gpr(dc, rd, cpu_dst); break; case 0x26: if (IS_IMM) { simm = GET_FIELDs(insn, 20, 31); tcg_gen_shri_tl(cpu_dst, cpu_src1, simm & 0x1f); } else { tcg_gen_andi_tl(cpu_tmp0, cpu_src2, 0x1f); tcg_gen_shr_tl(cpu_dst, cpu_src1, cpu_tmp0); } gen_store_gpr(dc, rd, cpu_dst); break; case 0x27: if (IS_IMM) { simm = GET_FIELDs(insn, 20, 31); tcg_gen_sari_tl(cpu_dst, cpu_src1, simm & 0x1f); } else { tcg_gen_andi_tl(cpu_tmp0, cpu_src2, 0x1f); tcg_gen_sar_tl(cpu_dst, cpu_src1, cpu_tmp0); } gen_store_gpr(dc, rd, cpu_dst); break; #endif case 0x30: { switch(rd) { case 0: tcg_gen_xor_tl(cpu_tmp0, cpu_src1, cpu_src2); tcg_gen_andi_tl(cpu_y, cpu_tmp0, 0xffffffff); break; #ifndef TARGET_SPARC64 case 0x01 ... 0x0f: case 0x10 ... 0x1f: break; #else case 0x2: tcg_gen_xor_tl(cpu_dst, cpu_src1, cpu_src2); gen_helper_wrccr(cpu_env, cpu_dst); tcg_gen_movi_i32(cpu_cc_op, CC_OP_FLAGS); dc->cc_op = CC_OP_FLAGS; break; case 0x3: tcg_gen_xor_tl(cpu_dst, cpu_src1, cpu_src2); tcg_gen_andi_tl(cpu_dst, cpu_dst, 0xff); tcg_gen_trunc_tl_i32(cpu_asi, cpu_dst); break; case 0x6: tcg_gen_xor_tl(cpu_dst, cpu_src1, cpu_src2); tcg_gen_trunc_tl_i32(cpu_fprs, cpu_dst); save_state(dc); gen_op_next_insn(); tcg_gen_exit_tb(0); dc->is_br = 1; break; case 0xf: #if !defined(CONFIG_USER_ONLY) if (supervisor(dc)) { ; } #endif break; case 0x13: if (gen_trap_ifnofpu(dc)) { goto jmp_insn; } tcg_gen_xor_tl(cpu_gsr, cpu_src1, cpu_src2); break; case 0x14: if (!supervisor(dc)) goto illegal_insn; tcg_gen_xor_tl(cpu_tmp64, cpu_src1, cpu_src2); gen_helper_set_softint(cpu_env, cpu_tmp64); break; case 0x15: if (!supervisor(dc)) goto illegal_insn; tcg_gen_xor_tl(cpu_tmp64, cpu_src1, cpu_src2); gen_helper_clear_softint(cpu_env, cpu_tmp64); break; case 0x16: if (!supervisor(dc)) goto illegal_insn; tcg_gen_xor_tl(cpu_tmp64, cpu_src1, cpu_src2); gen_helper_write_softint(cpu_env, cpu_tmp64); break; case 0x17: #if !defined(CONFIG_USER_ONLY) if (!supervisor(dc)) goto illegal_insn; #endif { TCGv_ptr r_tickptr; tcg_gen_xor_tl(cpu_tick_cmpr, cpu_src1, cpu_src2); r_tickptr = tcg_temp_new_ptr(); tcg_gen_ld_ptr(r_tickptr, cpu_env, offsetof(CPUSPARCState, tick)); gen_helper_tick_set_limit(r_tickptr, cpu_tick_cmpr); tcg_temp_free_ptr(r_tickptr); } break; case 0x18: #if !defined(CONFIG_USER_ONLY) if (!supervisor(dc)) goto illegal_insn; #endif { TCGv_ptr r_tickptr; tcg_gen_xor_tl(cpu_dst, cpu_src1, cpu_src2); r_tickptr = tcg_temp_new_ptr(); tcg_gen_ld_ptr(r_tickptr, cpu_env, offsetof(CPUSPARCState, stick)); gen_helper_tick_set_count(r_tickptr, cpu_dst); tcg_temp_free_ptr(r_tickptr); } break; case 0x19: #if !defined(CONFIG_USER_ONLY) if (!supervisor(dc)) goto illegal_insn; #endif { TCGv_ptr r_tickptr; tcg_gen_xor_tl(cpu_stick_cmpr, cpu_src1, cpu_src2); r_tickptr = tcg_temp_new_ptr(); tcg_gen_ld_ptr(r_tickptr, cpu_env, offsetof(CPUSPARCState, stick)); gen_helper_tick_set_limit(r_tickptr, cpu_stick_cmpr); tcg_temp_free_ptr(r_tickptr); } break; case 0x10: case 0x11: case 0x12: #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_helper_saved(cpu_env); break; case 1: gen_helper_restored(cpu_env); break; case 2: case 3: case 4: case 5: default: goto illegal_insn; } #else tcg_gen_xor_tl(cpu_dst, cpu_src1, cpu_src2); gen_helper_wrpsr(cpu_env, cpu_dst); tcg_gen_movi_i32(cpu_cc_op, CC_OP_FLAGS); dc->cc_op = CC_OP_FLAGS; save_state(dc); gen_op_next_insn(); tcg_gen_exit_tb(0); dc->is_br = 1; #endif } break; case 0x32: { if (!supervisor(dc)) goto priv_insn; tcg_gen_xor_tl(cpu_tmp0, cpu_src1, cpu_src2); #ifdef TARGET_SPARC64 switch (rd) { case 0: { TCGv_ptr r_tsptr; r_tsptr = tcg_temp_new_ptr(); gen_load_trap_state_at_tl(r_tsptr, cpu_env); tcg_gen_st_tl(cpu_tmp0, r_tsptr, offsetof(trap_state, tpc)); tcg_temp_free_ptr(r_tsptr); } break; case 1: { TCGv_ptr r_tsptr; r_tsptr = tcg_temp_new_ptr(); gen_load_trap_state_at_tl(r_tsptr, cpu_env); tcg_gen_st_tl(cpu_tmp0, r_tsptr, offsetof(trap_state, tnpc)); tcg_temp_free_ptr(r_tsptr); } break; case 2: { TCGv_ptr r_tsptr; r_tsptr = tcg_temp_new_ptr(); gen_load_trap_state_at_tl(r_tsptr, cpu_env); tcg_gen_st_tl(cpu_tmp0, r_tsptr, offsetof(trap_state, tstate)); tcg_temp_free_ptr(r_tsptr); } break; case 3: { TCGv_ptr r_tsptr; r_tsptr = tcg_temp_new_ptr(); gen_load_trap_state_at_tl(r_tsptr, cpu_env); tcg_gen_trunc_tl_i32(cpu_tmp32, cpu_tmp0); tcg_gen_st_i32(cpu_tmp32, r_tsptr, offsetof(trap_state, tt)); tcg_temp_free_ptr(r_tsptr); } break; case 4: { TCGv_ptr r_tickptr; r_tickptr = tcg_temp_new_ptr(); tcg_gen_ld_ptr(r_tickptr, cpu_env, offsetof(CPUSPARCState, tick)); gen_helper_tick_set_count(r_tickptr, cpu_tmp0); tcg_temp_free_ptr(r_tickptr); } break; case 5: tcg_gen_mov_tl(cpu_tbr, cpu_tmp0); break; case 6: save_state(dc); gen_helper_wrpstate(cpu_env, cpu_tmp0); dc->npc = DYNAMIC_PC; break; case 7: save_state(dc); tcg_gen_trunc_tl_i32(cpu_tmp32, cpu_tmp0); tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, tl)); dc->npc = DYNAMIC_PC; break; case 8: gen_helper_wrpil(cpu_env, cpu_tmp0); break; case 9: gen_helper_wrcwp(cpu_env, cpu_tmp0); break; case 10: tcg_gen_trunc_tl_i32(cpu_tmp32, cpu_tmp0); tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, cansave)); break; case 11: tcg_gen_trunc_tl_i32(cpu_tmp32, cpu_tmp0); tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, canrestore)); break; case 12: tcg_gen_trunc_tl_i32(cpu_tmp32, cpu_tmp0); tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, cleanwin)); break; case 13: tcg_gen_trunc_tl_i32(cpu_tmp32, cpu_tmp0); tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, otherwin)); break; case 14: tcg_gen_trunc_tl_i32(cpu_tmp32, cpu_tmp0); tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, wstate)); break; case 16: CHECK_IU_FEATURE(dc, GL); tcg_gen_trunc_tl_i32(cpu_tmp32, cpu_tmp0); tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, gl)); break; case 26: CHECK_IU_FEATURE(dc, HYPV); if (!hypervisor(dc)) goto priv_insn; tcg_gen_mov_tl(cpu_ssr, cpu_tmp0); break; default: goto illegal_insn; } #else tcg_gen_trunc_tl_i32(cpu_tmp32, cpu_tmp0); if (dc->def->nwindows != 32) tcg_gen_andi_tl(cpu_tmp32, cpu_tmp32, (1 << dc->def->nwindows) - 1); tcg_gen_mov_i32(cpu_wim, cpu_tmp32); #endif } break; case 0x33: { #ifndef TARGET_SPARC64 if (!supervisor(dc)) goto priv_insn; tcg_gen_xor_tl(cpu_tbr, cpu_src1, cpu_src2); #else CHECK_IU_FEATURE(dc, HYPV); if (!hypervisor(dc)) goto priv_insn; tcg_gen_xor_tl(cpu_tmp0, cpu_src1, cpu_src2); switch (rd) { case 0: gen_op_wrhpstate(); save_state(dc); gen_op_next_insn(); tcg_gen_exit_tb(0); dc->is_br = 1; break; case 1: gen_op_wrhtstate(); break; case 3: tcg_gen_mov_tl(cpu_hintp, cpu_tmp0); break; case 5: tcg_gen_mov_tl(cpu_htba, cpu_tmp0); break; case 31: { TCGv_ptr r_tickptr; tcg_gen_mov_tl(cpu_hstick_cmpr, cpu_tmp0); r_tickptr = tcg_temp_new_ptr(); tcg_gen_ld_ptr(r_tickptr, cpu_env, offsetof(CPUSPARCState, hstick)); gen_helper_tick_set_limit(r_tickptr, cpu_hstick_cmpr); tcg_temp_free_ptr(r_tickptr); } 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); DisasCompare cmp; TCGv dst; if (insn & (1 << 18)) { if (cc == 0) { gen_compare(&cmp, 0, cond, dc); } else if (cc == 2) { gen_compare(&cmp, 1, cond, dc); } else { goto illegal_insn; } } else { gen_fcompare(&cmp, cc, cond); } if (IS_IMM) { simm = GET_FIELD_SPs(insn, 0, 10); tcg_gen_movi_tl(cpu_src2, simm); } dst = gen_load_gpr(dc, rd); tcg_gen_movcond_tl(cmp.cond, dst, cmp.c1, cmp.c2, cpu_src2, dst); free_compare(&cmp); gen_store_gpr(dc, rd, dst); break; } case 0x2d: gen_helper_sdivx(cpu_dst, cpu_env, cpu_src1, cpu_src2); gen_store_gpr(dc, rd, cpu_dst); break; case 0x2e: gen_helper_popc(cpu_dst, cpu_src2); gen_store_gpr(dc, rd, cpu_dst); break; case 0x2f: { int cond = GET_FIELD_SP(insn, 10, 12); DisasCompare cmp; TCGv dst; gen_compare_reg(&cmp, cond, cpu_src1); if (IS_IMM) { simm = GET_FIELD_SPs(insn, 0, 9); tcg_gen_movi_tl(cpu_src2, simm); } dst = gen_load_gpr(dc, rd); tcg_gen_movcond_tl(cmp.cond, dst, cmp.c1, cmp.c2, cpu_src2, dst); free_compare(&cmp); gen_store_gpr(dc, rd, dst); 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: CHECK_FPU_FEATURE(dc, VIS1); cpu_src1 = gen_load_gpr(dc, rs1); cpu_src2 = gen_load_gpr(dc, rs2); gen_edge(dc, cpu_dst, cpu_src1, cpu_src2, 8, 1, 0); gen_store_gpr(dc, rd, cpu_dst); break; case 0x001: CHECK_FPU_FEATURE(dc, VIS2); cpu_src1 = gen_load_gpr(dc, rs1); cpu_src2 = gen_load_gpr(dc, rs2); gen_edge(dc, cpu_dst, cpu_src1, cpu_src2, 8, 0, 0); gen_store_gpr(dc, rd, cpu_dst); break; case 0x002: CHECK_FPU_FEATURE(dc, VIS1); cpu_src1 = gen_load_gpr(dc, rs1); cpu_src2 = gen_load_gpr(dc, rs2); gen_edge(dc, cpu_dst, cpu_src1, cpu_src2, 8, 1, 1); gen_store_gpr(dc, rd, cpu_dst); break; case 0x003: CHECK_FPU_FEATURE(dc, VIS2); cpu_src1 = gen_load_gpr(dc, rs1); cpu_src2 = gen_load_gpr(dc, rs2); gen_edge(dc, cpu_dst, cpu_src1, cpu_src2, 8, 0, 1); gen_store_gpr(dc, rd, cpu_dst); break; case 0x004: CHECK_FPU_FEATURE(dc, VIS1); cpu_src1 = gen_load_gpr(dc, rs1); cpu_src2 = gen_load_gpr(dc, rs2); gen_edge(dc, cpu_dst, cpu_src1, cpu_src2, 16, 1, 0); gen_store_gpr(dc, rd, cpu_dst); break; case 0x005: CHECK_FPU_FEATURE(dc, VIS2); cpu_src1 = gen_load_gpr(dc, rs1); cpu_src2 = gen_load_gpr(dc, rs2); gen_edge(dc, cpu_dst, cpu_src1, cpu_src2, 16, 0, 0); gen_store_gpr(dc, rd, cpu_dst); break; case 0x006: CHECK_FPU_FEATURE(dc, VIS1); cpu_src1 = gen_load_gpr(dc, rs1); cpu_src2 = gen_load_gpr(dc, rs2); gen_edge(dc, cpu_dst, cpu_src1, cpu_src2, 16, 1, 1); gen_store_gpr(dc, rd, cpu_dst); break; case 0x007: CHECK_FPU_FEATURE(dc, VIS2); cpu_src1 = gen_load_gpr(dc, rs1); cpu_src2 = gen_load_gpr(dc, rs2); gen_edge(dc, cpu_dst, cpu_src1, cpu_src2, 16, 0, 1); gen_store_gpr(dc, rd, cpu_dst); break; case 0x008: CHECK_FPU_FEATURE(dc, VIS1); cpu_src1 = gen_load_gpr(dc, rs1); cpu_src2 = gen_load_gpr(dc, rs2); gen_edge(dc, cpu_dst, cpu_src1, cpu_src2, 32, 1, 0); gen_store_gpr(dc, rd, cpu_dst); break; case 0x009: CHECK_FPU_FEATURE(dc, VIS2); cpu_src1 = gen_load_gpr(dc, rs1); cpu_src2 = gen_load_gpr(dc, rs2); gen_edge(dc, cpu_dst, cpu_src1, cpu_src2, 32, 0, 0); gen_store_gpr(dc, rd, cpu_dst); break; case 0x00a: CHECK_FPU_FEATURE(dc, VIS1); cpu_src1 = gen_load_gpr(dc, rs1); cpu_src2 = gen_load_gpr(dc, rs2); gen_edge(dc, cpu_dst, cpu_src1, cpu_src2, 32, 1, 1); gen_store_gpr(dc, rd, cpu_dst); break; case 0x00b: CHECK_FPU_FEATURE(dc, VIS2); cpu_src1 = gen_load_gpr(dc, rs1); cpu_src2 = gen_load_gpr(dc, rs2); gen_edge(dc, cpu_dst, cpu_src1, cpu_src2, 32, 0, 1); gen_store_gpr(dc, rd, cpu_dst); break; case 0x010: CHECK_FPU_FEATURE(dc, VIS1); cpu_src1 = gen_load_gpr(dc, rs1); cpu_src2 = gen_load_gpr(dc, rs2); gen_helper_array8(cpu_dst, cpu_src1, cpu_src2); gen_store_gpr(dc, rd, cpu_dst); break; case 0x012: CHECK_FPU_FEATURE(dc, VIS1); cpu_src1 = gen_load_gpr(dc, rs1); cpu_src2 = gen_load_gpr(dc, rs2); gen_helper_array8(cpu_dst, cpu_src1, cpu_src2); tcg_gen_shli_i64(cpu_dst, cpu_dst, 1); gen_store_gpr(dc, rd, cpu_dst); break; case 0x014: CHECK_FPU_FEATURE(dc, VIS1); cpu_src1 = gen_load_gpr(dc, rs1); cpu_src2 = gen_load_gpr(dc, rs2); gen_helper_array8(cpu_dst, cpu_src1, cpu_src2); tcg_gen_shli_i64(cpu_dst, cpu_dst, 2); gen_store_gpr(dc, rd, cpu_dst); break; case 0x018: CHECK_FPU_FEATURE(dc, VIS1); cpu_src1 = gen_load_gpr(dc, rs1); cpu_src2 = gen_load_gpr(dc, rs2); gen_alignaddr(cpu_dst, cpu_src1, cpu_src2, 0); gen_store_gpr(dc, rd, cpu_dst); break; case 0x01a: CHECK_FPU_FEATURE(dc, VIS1); cpu_src1 = gen_load_gpr(dc, rs1); cpu_src2 = gen_load_gpr(dc, rs2); gen_alignaddr(cpu_dst, cpu_src1, cpu_src2, 1); gen_store_gpr(dc, rd, cpu_dst); break; case 0x019: CHECK_FPU_FEATURE(dc, VIS2); cpu_src1 = gen_load_gpr(dc, rs1); cpu_src2 = gen_load_gpr(dc, rs2); tcg_gen_add_tl(cpu_dst, cpu_src1, cpu_src2); tcg_gen_deposit_tl(cpu_gsr, cpu_gsr, cpu_dst, 32, 32); gen_store_gpr(dc, rd, cpu_dst); break; case 0x020: CHECK_FPU_FEATURE(dc, VIS1); cpu_src1_64 = gen_load_fpr_D(dc, rs1); cpu_src2_64 = gen_load_fpr_D(dc, rs2); gen_helper_fcmple16(cpu_dst, cpu_src1_64, cpu_src2_64); gen_store_gpr(dc, rd, cpu_dst); break; case 0x022: CHECK_FPU_FEATURE(dc, VIS1); cpu_src1_64 = gen_load_fpr_D(dc, rs1); cpu_src2_64 = gen_load_fpr_D(dc, rs2); gen_helper_fcmpne16(cpu_dst, cpu_src1_64, cpu_src2_64); gen_store_gpr(dc, rd, cpu_dst); break; case 0x024: CHECK_FPU_FEATURE(dc, VIS1); cpu_src1_64 = gen_load_fpr_D(dc, rs1); cpu_src2_64 = gen_load_fpr_D(dc, rs2); gen_helper_fcmple32(cpu_dst, cpu_src1_64, cpu_src2_64); gen_store_gpr(dc, rd, cpu_dst); break; case 0x026: CHECK_FPU_FEATURE(dc, VIS1); cpu_src1_64 = gen_load_fpr_D(dc, rs1); cpu_src2_64 = gen_load_fpr_D(dc, rs2); gen_helper_fcmpne32(cpu_dst, cpu_src1_64, cpu_src2_64); gen_store_gpr(dc, rd, cpu_dst); break; case 0x028: CHECK_FPU_FEATURE(dc, VIS1); cpu_src1_64 = gen_load_fpr_D(dc, rs1); cpu_src2_64 = gen_load_fpr_D(dc, rs2); gen_helper_fcmpgt16(cpu_dst, cpu_src1_64, cpu_src2_64); gen_store_gpr(dc, rd, cpu_dst); break; case 0x02a: CHECK_FPU_FEATURE(dc, VIS1); cpu_src1_64 = gen_load_fpr_D(dc, rs1); cpu_src2_64 = gen_load_fpr_D(dc, rs2); gen_helper_fcmpeq16(cpu_dst, cpu_src1_64, cpu_src2_64); gen_store_gpr(dc, rd, cpu_dst); break; case 0x02c: CHECK_FPU_FEATURE(dc, VIS1); cpu_src1_64 = gen_load_fpr_D(dc, rs1); cpu_src2_64 = gen_load_fpr_D(dc, rs2); gen_helper_fcmpgt32(cpu_dst, cpu_src1_64, cpu_src2_64); gen_store_gpr(dc, rd, cpu_dst); break; case 0x02e: CHECK_FPU_FEATURE(dc, VIS1); cpu_src1_64 = gen_load_fpr_D(dc, rs1); cpu_src2_64 = gen_load_fpr_D(dc, rs2); gen_helper_fcmpeq32(cpu_dst, cpu_src1_64, cpu_src2_64); gen_store_gpr(dc, rd, cpu_dst); break; case 0x031: CHECK_FPU_FEATURE(dc, VIS1); gen_ne_fop_DDD(dc, rd, rs1, rs2, gen_helper_fmul8x16); break; case 0x033: CHECK_FPU_FEATURE(dc, VIS1); gen_ne_fop_DDD(dc, rd, rs1, rs2, gen_helper_fmul8x16au); break; case 0x035: CHECK_FPU_FEATURE(dc, VIS1); gen_ne_fop_DDD(dc, rd, rs1, rs2, gen_helper_fmul8x16al); break; case 0x036: CHECK_FPU_FEATURE(dc, VIS1); gen_ne_fop_DDD(dc, rd, rs1, rs2, gen_helper_fmul8sux16); break; case 0x037: CHECK_FPU_FEATURE(dc, VIS1); gen_ne_fop_DDD(dc, rd, rs1, rs2, gen_helper_fmul8ulx16); break; case 0x038: CHECK_FPU_FEATURE(dc, VIS1); gen_ne_fop_DDD(dc, rd, rs1, rs2, gen_helper_fmuld8sux16); break; case 0x039: CHECK_FPU_FEATURE(dc, VIS1); gen_ne_fop_DDD(dc, rd, rs1, rs2, gen_helper_fmuld8ulx16); break; case 0x03a: CHECK_FPU_FEATURE(dc, VIS1); gen_gsr_fop_DDD(dc, rd, rs1, rs2, gen_helper_fpack32); break; case 0x03b: CHECK_FPU_FEATURE(dc, VIS1); cpu_src1_64 = gen_load_fpr_D(dc, rs2); cpu_dst_32 = gen_dest_fpr_F(); gen_helper_fpack16(cpu_dst_32, cpu_gsr, cpu_src1_64); gen_store_fpr_F(dc, rd, cpu_dst_32); break; case 0x03d: CHECK_FPU_FEATURE(dc, VIS1); cpu_src1_64 = gen_load_fpr_D(dc, rs2); cpu_dst_32 = gen_dest_fpr_F(); gen_helper_fpackfix(cpu_dst_32, cpu_gsr, cpu_src1_64); gen_store_fpr_F(dc, rd, cpu_dst_32); break; case 0x03e: CHECK_FPU_FEATURE(dc, VIS1); gen_ne_fop_DDDD(dc, rd, rs1, rs2, gen_helper_pdist); break; case 0x048: CHECK_FPU_FEATURE(dc, VIS1); gen_gsr_fop_DDD(dc, rd, rs1, rs2, gen_faligndata); break; case 0x04b: CHECK_FPU_FEATURE(dc, VIS1); gen_ne_fop_DDD(dc, rd, rs1, rs2, gen_helper_fpmerge); break; case 0x04c: CHECK_FPU_FEATURE(dc, VIS2); gen_gsr_fop_DDD(dc, rd, rs1, rs2, gen_helper_bshuffle); break; case 0x04d: CHECK_FPU_FEATURE(dc, VIS1); gen_ne_fop_DDD(dc, rd, rs1, rs2, gen_helper_fexpand); break; case 0x050: CHECK_FPU_FEATURE(dc, VIS1); gen_ne_fop_DDD(dc, rd, rs1, rs2, gen_helper_fpadd16); break; case 0x051: CHECK_FPU_FEATURE(dc, VIS1); gen_ne_fop_FFF(dc, rd, rs1, rs2, gen_helper_fpadd16s); break; case 0x052: CHECK_FPU_FEATURE(dc, VIS1); gen_ne_fop_DDD(dc, rd, rs1, rs2, gen_helper_fpadd32); break; case 0x053: CHECK_FPU_FEATURE(dc, VIS1); gen_ne_fop_FFF(dc, rd, rs1, rs2, tcg_gen_add_i32); break; case 0x054: CHECK_FPU_FEATURE(dc, VIS1); gen_ne_fop_DDD(dc, rd, rs1, rs2, gen_helper_fpsub16); break; case 0x055: CHECK_FPU_FEATURE(dc, VIS1); gen_ne_fop_FFF(dc, rd, rs1, rs2, gen_helper_fpsub16s); break; case 0x056: CHECK_FPU_FEATURE(dc, VIS1); gen_ne_fop_DDD(dc, rd, rs1, rs2, gen_helper_fpsub32); break; case 0x057: CHECK_FPU_FEATURE(dc, VIS1); gen_ne_fop_FFF(dc, rd, rs1, rs2, tcg_gen_sub_i32); break; case 0x060: CHECK_FPU_FEATURE(dc, VIS1); cpu_dst_64 = gen_dest_fpr_D(); tcg_gen_movi_i64(cpu_dst_64, 0); gen_store_fpr_D(dc, rd, cpu_dst_64); break; case 0x061: CHECK_FPU_FEATURE(dc, VIS1); cpu_dst_32 = gen_dest_fpr_F(); tcg_gen_movi_i32(cpu_dst_32, 0); gen_store_fpr_F(dc, rd, cpu_dst_32); break; case 0x062: CHECK_FPU_FEATURE(dc, VIS1); gen_ne_fop_DDD(dc, rd, rs1, rs2, tcg_gen_nor_i64); break; case 0x063: CHECK_FPU_FEATURE(dc, VIS1); gen_ne_fop_FFF(dc, rd, rs1, rs2, tcg_gen_nor_i32); break; case 0x064: CHECK_FPU_FEATURE(dc, VIS1); gen_ne_fop_DDD(dc, rd, rs1, rs2, tcg_gen_andc_i64); break; case 0x065: CHECK_FPU_FEATURE(dc, VIS1); gen_ne_fop_FFF(dc, rd, rs1, rs2, tcg_gen_andc_i32); break; case 0x066: CHECK_FPU_FEATURE(dc, VIS1); gen_ne_fop_DD(dc, rd, rs2, tcg_gen_not_i64); break; case 0x067: CHECK_FPU_FEATURE(dc, VIS1); gen_ne_fop_FF(dc, rd, rs2, tcg_gen_not_i32); break; case 0x068: CHECK_FPU_FEATURE(dc, VIS1); gen_ne_fop_DDD(dc, rd, rs2, rs1, tcg_gen_andc_i64); break; case 0x069: CHECK_FPU_FEATURE(dc, VIS1); gen_ne_fop_FFF(dc, rd, rs2, rs1, tcg_gen_andc_i32); break; case 0x06a: CHECK_FPU_FEATURE(dc, VIS1); gen_ne_fop_DD(dc, rd, rs1, tcg_gen_not_i64); break; case 0x06b: CHECK_FPU_FEATURE(dc, VIS1); gen_ne_fop_FF(dc, rd, rs1, tcg_gen_not_i32); break; case 0x06c: CHECK_FPU_FEATURE(dc, VIS1); gen_ne_fop_DDD(dc, rd, rs1, rs2, tcg_gen_xor_i64); break; case 0x06d: CHECK_FPU_FEATURE(dc, VIS1); gen_ne_fop_FFF(dc, rd, rs1, rs2, tcg_gen_xor_i32); break; case 0x06e: CHECK_FPU_FEATURE(dc, VIS1); gen_ne_fop_DDD(dc, rd, rs1, rs2, tcg_gen_nand_i64); break; case 0x06f: CHECK_FPU_FEATURE(dc, VIS1); gen_ne_fop_FFF(dc, rd, rs1, rs2, tcg_gen_nand_i32); break; case 0x070: CHECK_FPU_FEATURE(dc, VIS1); gen_ne_fop_DDD(dc, rd, rs1, rs2, tcg_gen_and_i64); break; case 0x071: CHECK_FPU_FEATURE(dc, VIS1); gen_ne_fop_FFF(dc, rd, rs1, rs2, tcg_gen_and_i32); break; case 0x072: CHECK_FPU_FEATURE(dc, VIS1); gen_ne_fop_DDD(dc, rd, rs1, rs2, tcg_gen_eqv_i64); break; case 0x073: CHECK_FPU_FEATURE(dc, VIS1); gen_ne_fop_FFF(dc, rd, rs1, rs2, tcg_gen_eqv_i32); break; case 0x074: CHECK_FPU_FEATURE(dc, VIS1); cpu_src1_64 = gen_load_fpr_D(dc, rs1); gen_store_fpr_D(dc, rd, cpu_src1_64); break; case 0x075: CHECK_FPU_FEATURE(dc, VIS1); cpu_src1_32 = gen_load_fpr_F(dc, rs1); gen_store_fpr_F(dc, rd, cpu_src1_32); break; case 0x076: CHECK_FPU_FEATURE(dc, VIS1); gen_ne_fop_DDD(dc, rd, rs1, rs2, tcg_gen_orc_i64); break; case 0x077: CHECK_FPU_FEATURE(dc, VIS1); gen_ne_fop_FFF(dc, rd, rs1, rs2, tcg_gen_orc_i32); break; case 0x078: CHECK_FPU_FEATURE(dc, VIS1); cpu_src1_64 = gen_load_fpr_D(dc, rs2); gen_store_fpr_D(dc, rd, cpu_src1_64); break; case 0x079: CHECK_FPU_FEATURE(dc, VIS1); cpu_src1_32 = gen_load_fpr_F(dc, rs2); gen_store_fpr_F(dc, rd, cpu_src1_32); break; case 0x07a: CHECK_FPU_FEATURE(dc, VIS1); gen_ne_fop_DDD(dc, rd, rs2, rs1, tcg_gen_orc_i64); break; case 0x07b: CHECK_FPU_FEATURE(dc, VIS1); gen_ne_fop_FFF(dc, rd, rs2, rs1, tcg_gen_orc_i32); break; case 0x07c: CHECK_FPU_FEATURE(dc, VIS1); gen_ne_fop_DDD(dc, rd, rs1, rs2, tcg_gen_or_i64); break; case 0x07d: CHECK_FPU_FEATURE(dc, VIS1); gen_ne_fop_FFF(dc, rd, rs1, rs2, tcg_gen_or_i32); break; case 0x07e: CHECK_FPU_FEATURE(dc, VIS1); cpu_dst_64 = gen_dest_fpr_D(); tcg_gen_movi_i64(cpu_dst_64, -1); gen_store_fpr_D(dc, rd, cpu_dst_64); break; case 0x07f: CHECK_FPU_FEATURE(dc, VIS1); cpu_dst_32 = gen_dest_fpr_F(); tcg_gen_movi_i32(cpu_dst_32, -1); gen_store_fpr_F(dc, rd, cpu_dst_32); 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) { TCGv_i32 r_const; save_state(dc); cpu_src1 = get_src1(dc, insn); if (IS_IMM) { simm = GET_FIELDs(insn, 19, 31); tcg_gen_addi_tl(cpu_dst, cpu_src1, simm); } else { rs2 = GET_FIELD(insn, 27, 31); if (rs2) { cpu_src2 = gen_load_gpr(dc, rs2); tcg_gen_add_tl(cpu_dst, cpu_src1, cpu_src2); } else { tcg_gen_mov_tl(cpu_dst, cpu_src1); } } gen_helper_restore(cpu_env); gen_mov_pc_npc(dc); r_const = tcg_const_i32(3); gen_helper_check_align(cpu_env, cpu_dst, r_const); tcg_temp_free_i32(r_const); tcg_gen_mov_tl(cpu_npc, cpu_dst); dc->npc = DYNAMIC_PC; goto jmp_insn; #endif } else { cpu_src1 = get_src1(dc, insn); if (IS_IMM) { simm = GET_FIELDs(insn, 19, 31); tcg_gen_addi_tl(cpu_dst, cpu_src1, simm); } else { rs2 = GET_FIELD(insn, 27, 31); if (rs2) { cpu_src2 = gen_load_gpr(dc, rs2); tcg_gen_add_tl(cpu_dst, cpu_src1, cpu_src2); } else { tcg_gen_mov_tl(cpu_dst, cpu_src1); } } switch (xop) { case 0x38: { TCGv t; TCGv_i32 r_const; t = gen_dest_gpr(dc, rd); tcg_gen_movi_tl(t, dc->pc); gen_store_gpr(dc, rd, t); gen_mov_pc_npc(dc); r_const = tcg_const_i32(3); gen_helper_check_align(cpu_env, cpu_dst, r_const); tcg_temp_free_i32(r_const); gen_address_mask(dc, cpu_dst); tcg_gen_mov_tl(cpu_npc, cpu_dst); dc->npc = DYNAMIC_PC; } goto jmp_insn; #if !defined(CONFIG_USER_ONLY) && !defined(TARGET_SPARC64) case 0x39: { TCGv_i32 r_const; if (!supervisor(dc)) goto priv_insn; gen_mov_pc_npc(dc); r_const = tcg_const_i32(3); gen_helper_check_align(cpu_env, cpu_dst, r_const); tcg_temp_free_i32(r_const); tcg_gen_mov_tl(cpu_npc, cpu_dst); dc->npc = DYNAMIC_PC; gen_helper_rett(cpu_env); } goto jmp_insn; #endif case 0x3b: if (!((dc)->def->features & CPU_FEATURE_FLUSH)) goto unimp_flush; break; case 0x3c: save_state(dc); gen_helper_save(cpu_env); gen_store_gpr(dc, rd, cpu_dst); break; case 0x3d: save_state(dc); gen_helper_restore(cpu_env); gen_store_gpr(dc, rd, cpu_dst); 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_helper_done(cpu_env); goto jmp_insn; case 1: if (!supervisor(dc)) goto priv_insn; dc->npc = DYNAMIC_PC; dc->pc = DYNAMIC_PC; gen_helper_retry(cpu_env); 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); cpu_src1 = get_src1(dc, insn); if (xop == 0x3c || xop == 0x3e) { rs2 = GET_FIELD(insn, 27, 31); cpu_src2 = gen_load_gpr(dc, rs2); tcg_gen_mov_tl(cpu_addr, cpu_src1); } else if (IS_IMM) { simm = GET_FIELDs(insn, 19, 31); tcg_gen_addi_tl(cpu_addr, cpu_src1, simm); } else { rs2 = GET_FIELD(insn, 27, 31); if (rs2 != 0) { cpu_src2 = gen_load_gpr(dc, rs2); tcg_gen_add_tl(cpu_addr, cpu_src1, cpu_src2); } else { tcg_gen_mov_tl(cpu_addr, cpu_src1); } } if (xop < 4 || (xop > 7 && xop < 0x14 && xop != 0x0e) || (xop > 0x17 && xop <= 0x1d ) || (xop > 0x2c && xop <= 0x33) || xop == 0x1f || xop == 0x3d) { TCGv cpu_val = gen_dest_gpr(dc, rd); switch (xop) { case 0x0: gen_address_mask(dc, cpu_addr); tcg_gen_qemu_ld32u(cpu_val, cpu_addr, dc->mem_idx); break; case 0x1: gen_address_mask(dc, cpu_addr); tcg_gen_qemu_ld8u(cpu_val, cpu_addr, dc->mem_idx); break; case 0x2: gen_address_mask(dc, cpu_addr); tcg_gen_qemu_ld16u(cpu_val, cpu_addr, dc->mem_idx); break; case 0x3: if (rd & 1) goto illegal_insn; else { TCGv_i32 r_const; save_state(dc); r_const = tcg_const_i32(7); gen_helper_check_align(cpu_env, cpu_addr, r_const); tcg_temp_free_i32(r_const); gen_address_mask(dc, cpu_addr); tcg_gen_qemu_ld64(cpu_tmp64, cpu_addr, dc->mem_idx); tcg_gen_trunc_i64_tl(cpu_tmp0, cpu_tmp64); tcg_gen_andi_tl(cpu_tmp0, cpu_tmp0, 0xffffffffULL); gen_store_gpr(dc, rd + 1, cpu_tmp0); tcg_gen_shri_i64(cpu_tmp64, cpu_tmp64, 32); tcg_gen_trunc_i64_tl(cpu_val, cpu_tmp64); tcg_gen_andi_tl(cpu_val, cpu_val, 0xffffffffULL); } break; case 0x9: gen_address_mask(dc, cpu_addr); tcg_gen_qemu_ld8s(cpu_val, cpu_addr, dc->mem_idx); break; case 0xa: gen_address_mask(dc, cpu_addr); tcg_gen_qemu_ld16s(cpu_val, cpu_addr, dc->mem_idx); break; case 0xd: { TCGv r_const; gen_address_mask(dc, cpu_addr); tcg_gen_qemu_ld8s(cpu_val, cpu_addr, dc->mem_idx); r_const = tcg_const_tl(0xff); tcg_gen_qemu_st8(r_const, cpu_addr, dc->mem_idx); tcg_temp_free(r_const); } break; case 0x0f: CHECK_IU_FEATURE(dc, SWAP); cpu_src1 = gen_load_gpr(dc, rd); gen_address_mask(dc, cpu_addr); tcg_gen_qemu_ld32u(cpu_tmp0, cpu_addr, dc->mem_idx); tcg_gen_qemu_st32(cpu_src1, cpu_addr, dc->mem_idx); tcg_gen_mov_tl(cpu_val, cpu_tmp0); 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; #endif save_state(dc); gen_ld_asi(cpu_val, cpu_addr, insn, 4, 0); break; case 0x11: #ifndef TARGET_SPARC64 if (IS_IMM) goto illegal_insn; if (!supervisor(dc)) goto priv_insn; #endif save_state(dc); gen_ld_asi(cpu_val, cpu_addr, insn, 1, 0); break; case 0x12: #ifndef TARGET_SPARC64 if (IS_IMM) goto illegal_insn; if (!supervisor(dc)) goto priv_insn; #endif save_state(dc); gen_ld_asi(cpu_val, cpu_addr, 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; save_state(dc); gen_ldda_asi(dc, cpu_val, cpu_addr, insn, rd); goto skip_move; case 0x19: #ifndef TARGET_SPARC64 if (IS_IMM) goto illegal_insn; if (!supervisor(dc)) goto priv_insn; #endif save_state(dc); gen_ld_asi(cpu_val, cpu_addr, insn, 1, 1); break; case 0x1a: #ifndef TARGET_SPARC64 if (IS_IMM) goto illegal_insn; if (!supervisor(dc)) goto priv_insn; #endif save_state(dc); gen_ld_asi(cpu_val, cpu_addr, insn, 2, 1); break; case 0x1d: #ifndef TARGET_SPARC64 if (IS_IMM) goto illegal_insn; if (!supervisor(dc)) goto priv_insn; #endif save_state(dc); gen_ldstub_asi(cpu_val, cpu_addr, insn); break; case 0x1f: CHECK_IU_FEATURE(dc, SWAP); #ifndef TARGET_SPARC64 if (IS_IMM) goto illegal_insn; if (!supervisor(dc)) goto priv_insn; #endif save_state(dc); cpu_src1 = gen_load_gpr(dc, rd); gen_swap_asi(cpu_val, cpu_src1, cpu_addr, insn); break; #ifndef TARGET_SPARC64 case 0x30: case 0x31: case 0x33: goto ncp_insn; #endif #endif #ifdef TARGET_SPARC64 case 0x08: gen_address_mask(dc, cpu_addr); tcg_gen_qemu_ld32s(cpu_val, cpu_addr, dc->mem_idx); break; case 0x0b: gen_address_mask(dc, cpu_addr); tcg_gen_qemu_ld64(cpu_val, cpu_addr, dc->mem_idx); break; case 0x18: save_state(dc); gen_ld_asi(cpu_val, cpu_addr, insn, 4, 1); break; case 0x1b: save_state(dc); gen_ld_asi(cpu_val, cpu_addr, insn, 8, 0); break; case 0x2d: goto skip_move; case 0x30: if (gen_trap_ifnofpu(dc)) { goto jmp_insn; } save_state(dc); gen_ldf_asi(cpu_addr, insn, 4, rd); gen_update_fprs_dirty(rd); goto skip_move; case 0x33: if (gen_trap_ifnofpu(dc)) { goto jmp_insn; } save_state(dc); gen_ldf_asi(cpu_addr, insn, 8, DFPREG(rd)); gen_update_fprs_dirty(DFPREG(rd)); goto skip_move; case 0x3d: goto skip_move; case 0x32: CHECK_FPU_FEATURE(dc, FLOAT128); if (gen_trap_ifnofpu(dc)) { goto jmp_insn; } save_state(dc); gen_ldf_asi(cpu_addr, insn, 16, QFPREG(rd)); gen_update_fprs_dirty(QFPREG(rd)); goto skip_move; #endif default: goto illegal_insn; } gen_store_gpr(dc, rd, cpu_val); #if !defined(CONFIG_USER_ONLY) || defined(TARGET_SPARC64) skip_move: ; #endif } else if (xop >= 0x20 && xop < 0x24) { if (gen_trap_ifnofpu(dc)) { goto jmp_insn; } save_state(dc); switch (xop) { case 0x20: gen_address_mask(dc, cpu_addr); tcg_gen_qemu_ld32u(cpu_tmp0, cpu_addr, dc->mem_idx); cpu_dst_32 = gen_dest_fpr_F(); tcg_gen_trunc_tl_i32(cpu_dst_32, cpu_tmp0); gen_store_fpr_F(dc, rd, cpu_dst_32); break; case 0x21: #ifdef TARGET_SPARC64 gen_address_mask(dc, cpu_addr); if (rd == 1) { tcg_gen_qemu_ld64(cpu_tmp64, cpu_addr, dc->mem_idx); gen_helper_ldxfsr(cpu_env, cpu_tmp64); } else { tcg_gen_qemu_ld32u(cpu_tmp0, cpu_addr, dc->mem_idx); tcg_gen_trunc_tl_i32(cpu_tmp32, cpu_tmp0); gen_helper_ldfsr(cpu_env, cpu_tmp32); } #else { tcg_gen_qemu_ld32u(cpu_tmp32, cpu_addr, dc->mem_idx); gen_helper_ldfsr(cpu_env, cpu_tmp32); } #endif break; case 0x22: { TCGv_i32 r_const; CHECK_FPU_FEATURE(dc, FLOAT128); r_const = tcg_const_i32(dc->mem_idx); gen_address_mask(dc, cpu_addr); gen_helper_ldqf(cpu_env, cpu_addr, r_const); tcg_temp_free_i32(r_const); gen_op_store_QT0_fpr(QFPREG(rd)); gen_update_fprs_dirty(QFPREG(rd)); } break; case 0x23: gen_address_mask(dc, cpu_addr); cpu_dst_64 = gen_dest_fpr_D(); tcg_gen_qemu_ld64(cpu_dst_64, cpu_addr, dc->mem_idx); gen_store_fpr_D(dc, rd, cpu_dst_64); break; default: goto illegal_insn; } } else if (xop < 8 || (xop >= 0x14 && xop < 0x18) || xop == 0xe || xop == 0x1e) { TCGv cpu_val = gen_load_gpr(dc, rd); switch (xop) { case 0x4: gen_address_mask(dc, cpu_addr); tcg_gen_qemu_st32(cpu_val, cpu_addr, dc->mem_idx); break; case 0x5: gen_address_mask(dc, cpu_addr); tcg_gen_qemu_st8(cpu_val, cpu_addr, dc->mem_idx); break; case 0x6: gen_address_mask(dc, cpu_addr); tcg_gen_qemu_st16(cpu_val, cpu_addr, dc->mem_idx); break; case 0x7: if (rd & 1) goto illegal_insn; else { TCGv_i32 r_const; TCGv lo; save_state(dc); gen_address_mask(dc, cpu_addr); r_const = tcg_const_i32(7); gen_helper_check_align(cpu_env, cpu_addr, r_const); tcg_temp_free_i32(r_const); lo = gen_load_gpr(dc, rd + 1); tcg_gen_concat_tl_i64(cpu_tmp64, lo, cpu_val); tcg_gen_qemu_st64(cpu_tmp64, cpu_addr, dc->mem_idx); } 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 save_state(dc); gen_st_asi(cpu_val, cpu_addr, insn, 4); dc->npc = DYNAMIC_PC; break; case 0x15: #ifndef TARGET_SPARC64 if (IS_IMM) goto illegal_insn; if (!supervisor(dc)) goto priv_insn; #endif save_state(dc); gen_st_asi(cpu_val, cpu_addr, insn, 1); dc->npc = DYNAMIC_PC; break; case 0x16: #ifndef TARGET_SPARC64 if (IS_IMM) goto illegal_insn; if (!supervisor(dc)) goto priv_insn; #endif save_state(dc); gen_st_asi(cpu_val, cpu_addr, insn, 2); dc->npc = DYNAMIC_PC; 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; else { save_state(dc); gen_stda_asi(dc, cpu_val, cpu_addr, insn, rd); } break; #endif #ifdef TARGET_SPARC64 case 0x0e: gen_address_mask(dc, cpu_addr); tcg_gen_qemu_st64(cpu_val, cpu_addr, dc->mem_idx); break; case 0x1e: save_state(dc); gen_st_asi(cpu_val, cpu_addr, insn, 8); dc->npc = DYNAMIC_PC; break; #endif default: goto illegal_insn; } } else if (xop > 0x23 && xop < 0x28) { if (gen_trap_ifnofpu(dc)) { goto jmp_insn; } save_state(dc); switch (xop) { case 0x24: gen_address_mask(dc, cpu_addr); cpu_src1_32 = gen_load_fpr_F(dc, rd); tcg_gen_ext_i32_tl(cpu_tmp0, cpu_src1_32); tcg_gen_qemu_st32(cpu_tmp0, cpu_addr, dc->mem_idx); break; case 0x25: #ifdef TARGET_SPARC64 gen_address_mask(dc, cpu_addr); tcg_gen_ld_i64(cpu_tmp64, cpu_env, offsetof(CPUSPARCState, fsr)); if (rd == 1) tcg_gen_qemu_st64(cpu_tmp64, cpu_addr, dc->mem_idx); else tcg_gen_qemu_st32(cpu_tmp64, cpu_addr, dc->mem_idx); #else tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, fsr)); tcg_gen_qemu_st32(cpu_tmp32, cpu_addr, dc->mem_idx); #endif break; case 0x26: #ifdef TARGET_SPARC64 { TCGv_i32 r_const; CHECK_FPU_FEATURE(dc, FLOAT128); gen_op_load_fpr_QT0(QFPREG(rd)); r_const = tcg_const_i32(dc->mem_idx); gen_address_mask(dc, cpu_addr); gen_helper_stqf(cpu_env, cpu_addr, r_const); tcg_temp_free_i32(r_const); } break; #else #if defined(CONFIG_USER_ONLY) goto illegal_insn; #else if (!supervisor(dc)) goto priv_insn; if (gen_trap_ifnofpu(dc)) { goto jmp_insn; } goto nfq_insn; #endif #endif case 0x27: gen_address_mask(dc, cpu_addr); cpu_src1_64 = gen_load_fpr_D(dc, rd); tcg_gen_qemu_st64(cpu_src1_64, cpu_addr, dc->mem_idx); break; default: goto illegal_insn; } } else if (xop > 0x33 && xop < 0x3f) { save_state(dc); switch (xop) { #ifdef TARGET_SPARC64 case 0x34: if (gen_trap_ifnofpu(dc)) { goto jmp_insn; } gen_stf_asi(cpu_addr, insn, 4, rd); break; case 0x36: { TCGv_i32 r_const; CHECK_FPU_FEATURE(dc, FLOAT128); if (gen_trap_ifnofpu(dc)) { goto jmp_insn; } r_const = tcg_const_i32(7); gen_helper_check_align(cpu_env, cpu_addr, r_const); tcg_temp_free_i32(r_const); gen_stf_asi(cpu_addr, insn, 16, QFPREG(rd)); } break; case 0x37: if (gen_trap_ifnofpu(dc)) { goto jmp_insn; } gen_stf_asi(cpu_addr, insn, 8, DFPREG(rd)); break; case 0x3c: gen_cas_asi(dc, cpu_addr, cpu_src2, insn, rd); break; case 0x3e: gen_casx_asi(dc, cpu_addr, cpu_src2, insn, rd); break; #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], cpu_cond); dc->is_br = 1; } else { dc->pc = dc->npc; dc->npc = dc->npc + 4; } jmp_insn: goto egress; illegal_insn: { TCGv_i32 r_const; save_state(dc); r_const = tcg_const_i32(TT_ILL_INSN); gen_helper_raise_exception(cpu_env, r_const); tcg_temp_free_i32(r_const); dc->is_br = 1; } goto egress; unimp_flush: { TCGv_i32 r_const; save_state(dc); r_const = tcg_const_i32(TT_UNIMP_FLUSH); gen_helper_raise_exception(cpu_env, r_const); tcg_temp_free_i32(r_const); dc->is_br = 1; } goto egress; #if !defined(CONFIG_USER_ONLY) priv_insn: { TCGv_i32 r_const; save_state(dc); r_const = tcg_const_i32(TT_PRIV_INSN); gen_helper_raise_exception(cpu_env, r_const); tcg_temp_free_i32(r_const); dc->is_br = 1; } goto egress; #endif nfpu_insn: save_state(dc); gen_op_fpexception_im(FSR_FTT_UNIMPFPOP); dc->is_br = 1; goto egress; #if !defined(CONFIG_USER_ONLY) && !defined(TARGET_SPARC64) nfq_insn: save_state(dc); gen_op_fpexception_im(FSR_FTT_SEQ_ERROR); dc->is_br = 1; goto egress; #endif #ifndef TARGET_SPARC64 ncp_insn: { TCGv r_const; save_state(dc); r_const = tcg_const_i32(TT_NCP_INSN); gen_helper_raise_exception(cpu_env, r_const); tcg_temp_free(r_const); dc->is_br = 1; } goto egress; #endif egress: tcg_temp_free(cpu_tmp1); tcg_temp_free(cpu_tmp2); if (dc->n_t32 != 0) { int i; for (i = dc->n_t32 - 1; i >= 0; --i) { tcg_temp_free_i32(dc->t32[i]); } dc->n_t32 = 0; } if (dc->n_ttl != 0) { int i; for (i = dc->n_ttl - 1; i >= 0; --i) { tcg_temp_free(dc->ttl[i]); } dc->n_ttl = 0; } }
1threat
void virtio_scsi_set_iothread(VirtIOSCSI *s, IOThread *iothread) { BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(s))); VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s); assert(!s->ctx); s->ctx = iothread_get_aio_context(vs->conf.iothread); if (!k->set_guest_notifiers || !k->ioeventfd_assign) { fprintf(stderr, "virtio-scsi: Failed to set iothread " "(transport does not support notifiers)"); exit(1); } }
1threat
static int genh_read_packet(AVFormatContext *s, AVPacket *pkt) { AVCodecContext *codec = s->streams[0]->codec; GENHDemuxContext *c = s->priv_data; int ret; if (c->dsp_int_type == 1 && codec->codec_id == AV_CODEC_ID_ADPCM_THP && codec->channels > 1) { int i, ch; if (avio_feof(s->pb)) return AVERROR_EOF; av_new_packet(pkt, 8 * codec->channels); for (i = 0; i < 8 / c->interleave_size; i++) { for (ch = 0; ch < codec->channels; ch++) { pkt->data[ch * 8 + i*c->interleave_size+0] = avio_r8(s->pb); pkt->data[ch * 8 + i*c->interleave_size+1] = avio_r8(s->pb); } } ret = 0; } else { ret = av_get_packet(s->pb, pkt, codec->block_align ? codec->block_align : 1024 * codec->channels); } pkt->stream_index = 0; return ret; }
1threat
How to achieve the following Map functionality using leaflet.js (screenshot attached)? : <p>I want achieve the following map functionality in my maps. When i am zoomed out the properties appear something like this -></p> <p>[<img src="https://i.stack.imgur.com/4OfjI.png" alt="Zoomed out map [1]"></p> <p>But when i zoom in map changes to following -></p> <p><a href="https://i.stack.imgur.com/9gB5N.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9gB5N.png" alt="zoomed in map"></a></p> <p>I want to achieve this using leaflet.js but i dont have ant idea how to achieve this? I have lat-long data for the properties and i want to achieve this for properties all over the world.</p> <p>so when map is maxed zoomed out it look something like this -></p> <p><a href="https://i.stack.imgur.com/DjJTJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DjJTJ.png" alt="enter image description here"></a> </p> <p>you can visit actual website for Demo :- <a href="https://elocations.com/retail-location" rel="nofollow noreferrer">https://elocations.com/retail-location</a></p>
0debug
Wait until ajax done before returning the function : <p>I use this code to get a message from the server and print it to the frontend:</p> <pre><code>var message = getMessageFromServer(); $('.result').html(message); function getMessageFromServer() { var result = null; $.ajax({ url: 'index.php', type: 'GET', success: function (msg) { result = msg; } }); return result; } </code></pre> <p>It obviously isn't working because as how javascript works, the line <code>return result</code> is running before the ajax done, therefore my function <code>getMessageFromServer</code> always return null.</p> <p>I have searched all day about this problem and got many answers such as setting async to false, using when done, callback, re-structuring the code to be more ajax-friendly, etc. However, I'm using a framework that won't let me freely re-structuring my code, so I need to make the question myself: <strong>How do I print the message to the frontend with below conditions</strong>:</p> <ul> <li><p>The 2 first lines must not be changed, I need to return the result to <code>message</code>, so it can be print to the frontend.</p></li> <li><p>Not using the <code>async: false</code> because it's bad for user experience.</p></li> <li><p>We can create more method, as long as it is used within the function <code>getMessageFromServer</code></p></li> </ul> <p>P/s: If you're wondering, the framework I'm using is Magento and I'm trying to add a custom validation rule with AJAX, but I the main problem is javascript so I didn't put it into the tags.</p>
0debug
jslint --edition=latest Unexpected ES6 feature. const : <p>I'm trying to use node-jslint <a href="https://github.com/reid/node-jslint" rel="noreferrer">https://github.com/reid/node-jslint</a> in order to keep my code clean </p> <p>I've got a const in my nodejs script, but jslint says it isn't valid ES6 code</p> <pre><code> Unexpected ES6 feature. const pdPersonsFilterId = process.argv[2]; // Line 10, Pos 0 </code></pre> <p>Here is the command I use in the console</p> <pre><code>jslint --edition=latest index.js </code></pre> <p>According to the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const" rel="noreferrer">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const</a> it possible to use global constants.</p> <p>Why does jslint does not consider this code to be valid?</p>
0debug
build_srat(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info) { AcpiSystemResourceAffinityTable *srat; AcpiSratProcessorGiccAffinity *core; AcpiSratMemoryAffinity *numamem; int i, j, srat_start; uint64_t mem_base; uint32_t *cpu_node = g_malloc0(guest_info->smp_cpus * sizeof(uint32_t)); for (i = 0; i < guest_info->smp_cpus; i++) { for (j = 0; j < nb_numa_nodes; j++) { if (test_bit(i, numa_info[j].node_cpu)) { cpu_node[i] = j; break; } } } srat_start = table_data->len; srat = acpi_data_push(table_data, sizeof(*srat)); srat->reserved1 = cpu_to_le32(1); for (i = 0; i < guest_info->smp_cpus; ++i) { core = acpi_data_push(table_data, sizeof(*core)); core->type = ACPI_SRAT_PROCESSOR_GICC; core->length = sizeof(*core); core->proximity = cpu_to_le32(cpu_node[i]); core->acpi_processor_uid = cpu_to_le32(i); core->flags = cpu_to_le32(1); } g_free(cpu_node); mem_base = guest_info->memmap[VIRT_MEM].base; for (i = 0; i < nb_numa_nodes; ++i) { numamem = acpi_data_push(table_data, sizeof(*numamem)); build_srat_memory(numamem, mem_base, numa_info[i].node_mem, i, MEM_AFFINITY_ENABLED); mem_base += numa_info[i].node_mem; } build_header(linker, table_data, (void *)(table_data->data + srat_start), "SRAT", table_data->len - srat_start, 3, NULL, NULL); }
1threat
static int segment_end(AVFormatContext *oc, int write_trailer) { int ret = 0; av_write_frame(oc, NULL); if (write_trailer) av_write_trailer(oc); avio_close(oc->pb); return ret; }
1threat
String.format launch MissingFormatArgumentException due two "%" in text : <p>I have a text like: </p> <pre><code>DISK_ERROR_MESSAGE = "Server %s is using more than 90% of the disk." </code></pre> <p>The problem, is when I try to do something like:</p> <pre><code>String.format(DISK_ERROR_MESSAGE,host.getName()) </code></pre> <p>Java launches the error:</p> <pre><code>Method threw 'java.util.MissingFormatArgumentException' exception. java.util.MissingFormatArgumentException: Format specifier '% o' </code></pre> <p>The problem is that % of the 90%.</p> <p>But I don't know how to avoid it without separating the text in two strings.</p>
0debug
API in Spring Boot Repository vs DAO : <p>I'm trying to design an rest API in spring boot and what to ask about a few design decisions. I am completely confused by the whole difference between DAO vs Repository pattern/design. After hours of reading I still don't really understand the difference between the two or which one is preferred standard for designing API's that make backend connections. </p> <p>Here's a simply UML diagram to highlight the high level view of the api: <a href="https://i.stack.imgur.com/JYLQE.png" rel="noreferrer"><img src="https://i.stack.imgur.com/JYLQE.png" alt="enter image description here"></a></p> <p>This is how I understand a good architecture of an API. But then I came across <a href="https://thinkinginobjects.com/2012/08/26/dont-use-dao-use-repository/" rel="noreferrer">this article</a> using repository pattern instead of dao with a specification design. I don't understand why a dao interface can't just have a <code>query</code> function? Does that break the idea of what a DAO is or something?</p> <p>My question is: what's the best standard to use in today's day in developing an API in Spring Boot and Java 8</p>
0debug
What are the pros and cons of using a trunk-based Vs feature-based workflow in Git? : <p>I pretty much like the idea of the feature-based workflow in Git: using feature branches to support parallel development.</p> <p>In a feature-based workflow, I would develop my tasks in a feature branch (off master), and I would rebase often from master to avoid potential conflicts. If collaborative, I will push/pull the feature branch to the remote. When ready to integrate to master, I open a pull-request from my feature branch to master, so that the pull-requests is reviewed by peers &amp; automatically assessed to know if the pull-request (the merge of my feature branch into master) passes the build and unit-tests. If the pull-request is "green" then my feature branch is automatically merged to master. </p> <p>I find the aforementioned workflow fine. However, in some internet posts, they advocate for a "trunk-based development" (e.g. <a href="https://barro.github.io/2016/02/a-succesful-git-branching-model-considered-harmful/" rel="noreferrer">1</a>, <a href="http://paulhammant.com/2013/04/05/what-is-trunk-based-development/" rel="noreferrer">2</a>).</p> <p>As far as I am concerned, trunk-based development does not encourage developing into separate feature branches but all developers develop into master. This model, encourages that developers integrate daily (Martin Fowler's CI practice) to the master to avoid conflicts (in contrast, what I would do is to rebase my feature branch on master). </p> <p>I was wondering which advantages this model would carry over the feature-based model. I have several doubts with the trunk-based model:</p> <ol> <li><p>How would code-review be done? In feature-based model is easy: into the feature branch. In the trunk-based model, since all the commits are published in master, how can I make them reviewed? In fact, if I resolve conflicts when merging into master, wouldn't this commits appear as to be reviewed (i wouldn't like that)?</p></li> <li><p>How would two developers collaborate on the same feature? In the feature-based model, both would work on the feature branch. In the trunk-based model, all developers would be collaborating in "all the features" (somehow). Right?</p></li> <li><p>I believe, the trunk based model was "created" to avoid the problem of long-lived feature branches are their potential conflict hell when merging it to the mainline. However, if feature branches are short-lived, and if they are often rebased from the mainline, what is the issue then?</p></li> <li>Overall, which benefits can carry the trunk-based compared to the feature-based workflow?</li> </ol> <p>Thanks :-)</p>
0debug
static void tcx_realizefn(DeviceState *dev, Error **errp) { SysBusDevice *sbd = SYS_BUS_DEVICE(dev); TCXState *s = TCX(dev); ram_addr_t vram_offset = 0; int size, ret; uint8_t *vram_base; char *fcode_filename; memory_region_init_ram(&s->vram_mem, OBJECT(s), "tcx.vram", s->vram_size * (1 + 4 + 4), &error_abort); vmstate_register_ram_global(&s->vram_mem); memory_region_set_log(&s->vram_mem, true, DIRTY_MEMORY_VGA); vram_base = memory_region_get_ram_ptr(&s->vram_mem); vmstate_register_ram_global(&s->rom); fcode_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, TCX_ROM_FILE); if (fcode_filename) { ret = load_image_targphys(fcode_filename, s->prom_addr, FCODE_MAX_ROM_SIZE); g_free(fcode_filename); if (ret < 0 || ret > FCODE_MAX_ROM_SIZE) { error_report("tcx: could not load prom '%s'", TCX_ROM_FILE); } } s->vram = vram_base; size = s->vram_size; memory_region_init_alias(&s->vram_8bit, OBJECT(s), "tcx.vram.8bit", &s->vram_mem, vram_offset, size); sysbus_init_mmio(sbd, &s->vram_8bit); vram_offset += size; vram_base += size; size = s->vram_size * 4; s->vram24 = (uint32_t *)vram_base; s->vram24_offset = vram_offset; memory_region_init_alias(&s->vram_24bit, OBJECT(s), "tcx.vram.24bit", &s->vram_mem, vram_offset, size); sysbus_init_mmio(sbd, &s->vram_24bit); vram_offset += size; vram_base += size; size = s->vram_size * 4; s->cplane = (uint32_t *)vram_base; s->cplane_offset = vram_offset; memory_region_init_alias(&s->vram_cplane, OBJECT(s), "tcx.vram.cplane", &s->vram_mem, vram_offset, size); sysbus_init_mmio(sbd, &s->vram_cplane); if (s->depth == 8) { memory_region_init_io(&s->thc24, OBJECT(s), &tcx_dummy_ops, s, "tcx.thc24", TCX_THC_NREGS); sysbus_init_mmio(sbd, &s->thc24); } sysbus_init_irq(sbd, &s->irq); if (s->depth == 8) { s->con = graphic_console_init(DEVICE(dev), 0, &tcx_ops, s); } else { s->con = graphic_console_init(DEVICE(dev), 0, &tcx24_ops, s); } s->thcmisc = 0; qemu_console_resize(s->con, s->width, s->height); }
1threat
Difference between `yield from $generator` and `return $generator`? : <p>I have a function that gives back a generator. At the moment it uses <code>yield from</code>:</p> <pre><code>function foo() { $generator = getGenerator(); // some other stuff (no yields!) yield from $generator; } </code></pre> <p>If I replace that <code>yield from</code> with a simple <code>return</code>, does that change anything in this case? Maybe in the execution? Or performance? Does <code>yield from</code> produces a new 'outer' iterator?</p> <p>I know, in other cases <code>yield from</code> can be more flexible because I can use it several times and even mix it with simple <code>yield</code>s, however that doesn't matter for my case.</p>
0debug
my task is to write a method that takes 2 arrays containing doubles and takes the larger of the two numbers at each index and returns them : <p>Write a method that takes two arrays containing doubles and returns a new array<br> that contains the larger of the two values at each index. The method should handle<br> cases in which one array is longer than the other. I'm not really sure how to go about this, So far I have this in the main:</p> <pre><code> public static void main(String[] args){ double[] test1 = {3.3, 8.2, 19.0, 38.1, 2.1, 3.7}; double[] test2 = {4.8, 2.1, 27.3, 6.0}; double[] maxResult = maximize(test1, test2); System.out.println(Arrays.toString(test1)); System.out.println(Arrays.toString(test2)); System.out.println(Arrays.toString(maxResult)); } </code></pre> <p>the output I'm trying to get is:</p> <pre><code> [3.3, 8.2, 19.0, 38.1, 2.1, 3.7] [4.8, 2.1, 27.3, 6.0] [4.8, 8.2, 27.3, 38.1, 2.1, 3.7] </code></pre> <p>I don't know what to put inside the method to have it take the larger of the two arrays. </p>
0debug
static int asf_read_stream_properties(AVFormatContext *s, int64_t size) { ASFContext *asf = s->priv_data; AVIOContext *pb = s->pb; AVStream *st; ASFStream *asf_st; ff_asf_guid g; enum AVMediaType type; int type_specific_size, sizeX; unsigned int tag1; int64_t pos1, pos2, start_time; int test_for_ext_stream_audio, is_dvr_ms_audio=0; if (s->nb_streams == ASF_MAX_STREAMS) { av_log(s, AV_LOG_ERROR, "too many streams\n"); return AVERROR(EINVAL); } pos1 = avio_tell(pb); st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); avpriv_set_pts_info(st, 32, 1, 1000); asf_st = av_mallocz(sizeof(ASFStream)); if (!asf_st) return AVERROR(ENOMEM); st->priv_data = asf_st; start_time = asf->hdr.preroll; asf_st->stream_language_index = 128; if(!(asf->hdr.flags & 0x01)) { int64_t fsize = avio_size(pb); if (fsize <= 0 || (int64_t)asf->hdr.file_size <= 0 || FFABS(fsize - (int64_t)asf->hdr.file_size) < 10000) st->duration = asf->hdr.play_time / (10000000 / 1000) - start_time; } ff_get_guid(pb, &g); test_for_ext_stream_audio = 0; if (!ff_guidcmp(&g, &ff_asf_audio_stream)) { type = AVMEDIA_TYPE_AUDIO; } else if (!ff_guidcmp(&g, &ff_asf_video_stream)) { type = AVMEDIA_TYPE_VIDEO; } else if (!ff_guidcmp(&g, &ff_asf_jfif_media)) { type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = AV_CODEC_ID_MJPEG; } else if (!ff_guidcmp(&g, &ff_asf_command_stream)) { type = AVMEDIA_TYPE_DATA; } else if (!ff_guidcmp(&g, &ff_asf_ext_stream_embed_stream_header)) { test_for_ext_stream_audio = 1; type = AVMEDIA_TYPE_UNKNOWN; } else { return -1; } ff_get_guid(pb, &g); avio_skip(pb, 8); type_specific_size = avio_rl32(pb); avio_rl32(pb); st->id = avio_rl16(pb) & 0x7f; asf->asfid2avid[st->id] = s->nb_streams - 1; avio_rl32(pb); if (test_for_ext_stream_audio) { ff_get_guid(pb, &g); if (!ff_guidcmp(&g, &ff_asf_ext_stream_audio_stream)) { type = AVMEDIA_TYPE_AUDIO; is_dvr_ms_audio=1; ff_get_guid(pb, &g); avio_rl32(pb); avio_rl32(pb); avio_rl32(pb); ff_get_guid(pb, &g); avio_rl32(pb); } } st->codec->codec_type = type; if (type == AVMEDIA_TYPE_AUDIO) { int ret = ff_get_wav_header(pb, st->codec, type_specific_size); if (ret < 0) return ret; if (is_dvr_ms_audio) { st->request_probe= 1; st->codec->codec_tag = 0; } if (st->codec->codec_id == AV_CODEC_ID_AAC) { st->need_parsing = AVSTREAM_PARSE_NONE; } else { st->need_parsing = AVSTREAM_PARSE_FULL; } pos2 = avio_tell(pb); if (size >= (pos2 + 8 - pos1 + 24)) { asf_st->ds_span = avio_r8(pb); asf_st->ds_packet_size = avio_rl16(pb); asf_st->ds_chunk_size = avio_rl16(pb); avio_rl16(pb); avio_r8(pb); } if (asf_st->ds_span > 1) { if (!asf_st->ds_chunk_size || (asf_st->ds_packet_size/asf_st->ds_chunk_size <= 1) || asf_st->ds_packet_size % asf_st->ds_chunk_size) asf_st->ds_span = 0; } } else if (type == AVMEDIA_TYPE_VIDEO && size - (avio_tell(pb) - pos1 + 24) >= 51) { avio_rl32(pb); avio_rl32(pb); avio_r8(pb); avio_rl16(pb); sizeX= avio_rl32(pb); st->codec->width = avio_rl32(pb); st->codec->height = avio_rl32(pb); avio_rl16(pb); st->codec->bits_per_coded_sample = avio_rl16(pb); tag1 = avio_rl32(pb); avio_skip(pb, 20); if (sizeX > 40) { st->codec->extradata_size = sizeX - 40; st->codec->extradata = av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); avio_read(pb, st->codec->extradata, st->codec->extradata_size); } if (st->codec->extradata_size && (st->codec->bits_per_coded_sample <= 8)) { #if HAVE_BIGENDIAN int i; for (i = 0; i < FFMIN(st->codec->extradata_size, AVPALETTE_SIZE)/4; i++) asf_st->palette[i] = av_bswap32(((uint32_t*)st->codec->extradata)[i]); #else memcpy(asf_st->palette, st->codec->extradata, FFMIN(st->codec->extradata_size, AVPALETTE_SIZE)); #endif asf_st->palette_changed = 1; } st->codec->codec_tag = tag1; st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, tag1); if(tag1 == MKTAG('D', 'V', 'R', ' ')){ st->need_parsing = AVSTREAM_PARSE_FULL; st->codec->width = st->codec->height = 0; av_freep(&st->codec->extradata); st->codec->extradata_size=0; } if(st->codec->codec_id == AV_CODEC_ID_H264) st->need_parsing = AVSTREAM_PARSE_FULL_ONCE; } pos2 = avio_tell(pb); avio_skip(pb, size - (pos2 - pos1 + 24)); return 0; }
1threat
how to calculate row average in panda data frame ? : I have pandas df with column, T max & T min. I want to calculate T mean on next column. I did with this df['T mean']= df[['T max','T min']].mean(axis=1) but didnt worked out. I got T max as T mean. Could anybody help me?
0debug
How can I remove multiple occurrences from a string in python? : <p>I have a string like 'AABA'. I want to remove multiple occurances by removing others. The result should be 'AB'. Sample Input: AABA Sample Output: AB</p>
0debug
Displaying inputs in array in alphabetical order - java : <p>was wondering if someone could write an example code for elements of array being displayed in alphabetical order. The elements have come from the users input and have been stored in the array. Thanks.</p>
0debug
static void memory_init(void) { qemu_mutex_init(&flat_view_mutex); }
1threat
dispatchEvent Causes error failed to execute 'dispatchEvent' on 'EventTarget': parameter 1 is not of type 'Event' : <p>I am using Angular2 + TypeScript and when I try execute this code:</p> <pre><code>var event = new Event('check'); window.dispatchEvent(event); </code></pre> <p>This code causing the next error:</p> <blockquote> <p>failed to execute 'dispatchEvent' on 'EventTarget': parameter 1 is not of type 'Event'.</p> </blockquote> <p>I have tried everything, and found out that this will work:</p> <pre><code>var event = new CustomEvent('check'); </code></pre> <p>Problem is that CustomEvent is not supported by any IE.</p> <p>Another thing that works is:</p> <pre><code>var event = new Event('CustomEvent'); event.initCustomEvent('check'); </code></pre> <p>Problem is that InitCustomEvent is deprecated.</p> <p>Is there anything I can do to avoid this type error? Maybe make an exception somewhere in typescript? Or use any code that is not deprecated and works for IE Edge?</p>
0debug
How can I fix this error in my code? : getting error on expecting key word class Listing < ActiveRecord::Base if Rails.env.development? has_attached_file :image, :styles => { :medium => "200", :thumb => "100x100>" }, :default_url => "default.jpg" validates_attachment_content_type :image, :content_type => /\Aimage\/.*\Z/ else has_attached_file :image, :styles => { :medium => "200", :thumb => "100x100>" }, :default_url => "default.jpg", validates_attachment_content_type :image, :content_type => /\Aimage\/.*\Z/ :storage => :dropbox, :dropbox_credentials => Rails.root.join("config/dropbox.yml"), :path => ":style/:id_filename" end validates :name, :description, :price, :address, :phone, presence: true validates :price, numericality: { greater_than: 0} validates :phone, length: { maximum: 14 } validates_attachment_presence :image belongs_to :user end
0debug
def roman_to_int(s): rom_val = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000} int_val = 0 for i in range(len(s)): if i > 0 and rom_val[s[i]] > rom_val[s[i - 1]]: int_val += rom_val[s[i]] - 2 * rom_val[s[i - 1]] else: int_val += rom_val[s[i]] return int_val
0debug
reading a aplhanumeric text file and trying to store to a list or array : I am using scanner.usedelimiter("[^0-9|,]") this pattern to avoid alphabets from a text file.then using hasNext and next() methods to store to a string and then list but list is adding additional o and whitespaces. I am using Scanner class to read a text file and extract only numbers from that text file Scanner sc = new Scanner("123.txt"); sc.useDelimiter("[^0-9|,|-]"); while (sc.hasNext()) { String s=null; s=sc.next(); list.add(s.replaceAll("\\s+","")); } Actual file has data Class Student Details 1 total 25 students with 80% pass 2A - 3B total 90 students with 70% pass 4A - 5B total 69 students with 80% pass 10 distinction Expected Output 1 25 80 2 3 90 70 4 5 69 80 10
0debug
I am unable to execute batch file to run python script : <p>I am unable to execute batch file to run python script. The location of Python: C:\Python27, BAT file: ‪C:\Python27\a.bat and python script : ‪C:\Python27\Untitled.ipynb . This is the command I am trying to execute in batch file: c:\python27\python.exe ‪C:\Untitled.ipynb %*. Where am I going wrong?</p>
0debug
javascript - Get to the h4 element Text : [First of all, please understand that I will post to you by translator. Clicking button class "LEARN MORE" I want to get "h4" text][1] [1]: https://i.stack.imgur.com/6UCrY.png
0debug
query = 'SELECT * FROM customers WHERE email = ' + email_input
1threat
List <Objects> to String[] : <p>I am trying to query from a database and it returns List and I needed a string[] of the medName field</p> <pre><code>public List&lt;Medicines&gt; selectMeds() { try { using (var connection = new SQLiteConnection(System.IO.Path.Combine(folder, "mediapp.db"))) { return connection.Table&lt;Medicines&gt;().ToList(); } } catch (SQLiteException ex) { Log.Info("SQLiteEx", ex.Message); return null; } } </code></pre> <p>while the Medicines class is</p> <pre><code>[Table("Medicines")] public class Medicines { [PrimaryKey] public int id { get; set; } public string medName { get; set; } public string medDesc { get; set; } } </code></pre> <p>How can I query one column from the sqlite database to string[]? or can I convert the Medicine object to string[], getting only the values for medName?</p>
0debug
Heap Overflow And Stack Overflow examples : <p>I need help in understanding heap and stack overflow, so it would be a lot helpful if I had few examples to understand the concept well</p>
0debug
static void pc_xen_hvm_init(QEMUMachineInitArgs *args) { if (xen_hvm_init() != 0) { hw_error("xen hardware virtual machine initialisation failed"); } pc_init_pci(args); }
1threat
int ff_mp4_read_dec_config_descr(AVFormatContext *fc, AVStream *st, AVIOContext *pb) { int len, tag; int object_type_id = avio_r8(pb); avio_r8(pb); avio_rb24(pb); avio_rb32(pb); avio_rb32(pb); if(avcodec_is_open(st->codec)) { av_log(fc, AV_LOG_DEBUG, "codec open in read_dec_config_descr\n"); return -1; } st->codec->codec_id= ff_codec_get_id(ff_mp4_obj_type, object_type_id); av_dlog(fc, "esds object type id 0x%02x\n", object_type_id); len = ff_mp4_read_descr(fc, pb, &tag); if (tag == MP4DecSpecificDescrTag) { av_dlog(fc, "Specific MPEG4 header len=%d\n", len); if (!len || (uint64_t)len > (1<<30)) return -1; av_free(st->codec->extradata); if (ff_alloc_extradata(st->codec, len)) return AVERROR(ENOMEM); avio_read(pb, st->codec->extradata, len); if (st->codec->codec_id == AV_CODEC_ID_AAC) { MPEG4AudioConfig cfg = {0}; avpriv_mpeg4audio_get_config(&cfg, st->codec->extradata, st->codec->extradata_size * 8, 1); st->codec->channels = cfg.channels; if (cfg.object_type == 29 && cfg.sampling_index < 3) st->codec->sample_rate = avpriv_mpa_freq_tab[cfg.sampling_index]; else if (cfg.ext_sample_rate) st->codec->sample_rate = cfg.ext_sample_rate; else st->codec->sample_rate = cfg.sample_rate; av_dlog(fc, "mp4a config channels %d obj %d ext obj %d " "sample rate %d ext sample rate %d\n", st->codec->channels, cfg.object_type, cfg.ext_object_type, cfg.sample_rate, cfg.ext_sample_rate); if (!(st->codec->codec_id = ff_codec_get_id(mp4_audio_types, cfg.object_type))) st->codec->codec_id = AV_CODEC_ID_AAC; } } return 0; }
1threat
static always_inline void gen_load_spr(TCGv t, int reg) { tcg_gen_ld_tl(t, cpu_env, offsetof(CPUState, spr[reg])); }
1threat
static int read_f(BlockBackend *blk, int argc, char **argv) { struct timeval t1, t2; bool Cflag = false, qflag = false, vflag = false; bool Pflag = false, sflag = false, lflag = false, bflag = false; int c, cnt; char *buf; int64_t offset; int64_t count; int64_t total = 0; int pattern = 0; int64_t pattern_offset = 0, pattern_count = 0; while ((c = getopt(argc, argv, "bCl:pP:qs:v")) != -1) { switch (c) { case 'b': bflag = true; break; case 'C': Cflag = true; break; case 'l': lflag = true; pattern_count = cvtnum(optarg); if (pattern_count < 0) { print_cvtnum_err(pattern_count, optarg); return 0; } break; case 'p': break; case 'P': Pflag = true; pattern = parse_pattern(optarg); if (pattern < 0) { return 0; } break; case 'q': qflag = true; break; case 's': sflag = true; pattern_offset = cvtnum(optarg); if (pattern_offset < 0) { print_cvtnum_err(pattern_offset, optarg); return 0; } break; case 'v': vflag = true; break; default: return qemuio_command_usage(&read_cmd); } } if (optind != argc - 2) { return qemuio_command_usage(&read_cmd); } offset = cvtnum(argv[optind]); if (offset < 0) { print_cvtnum_err(offset, argv[optind]); return 0; } optind++; count = cvtnum(argv[optind]); if (count < 0) { print_cvtnum_err(count, argv[optind]); return 0; } else if (count > SIZE_MAX) { printf("length cannot exceed %" PRIu64 ", given %s\n", (uint64_t) SIZE_MAX, argv[optind]); return 0; } if (!Pflag && (lflag || sflag)) { return qemuio_command_usage(&read_cmd); } if (!lflag) { pattern_count = count - pattern_offset; } if ((pattern_count < 0) || (pattern_count + pattern_offset > count)) { printf("pattern verification range exceeds end of read data\n"); return 0; } if (bflag) { if (offset & 0x1ff) { printf("offset %" PRId64 " is not sector aligned\n", offset); return 0; } if (count & 0x1ff) { printf("count %"PRId64" is not sector aligned\n", count); return 0; } } buf = qemu_io_alloc(blk, count, 0xab); gettimeofday(&t1, NULL); if (bflag) { cnt = do_load_vmstate(blk, buf, offset, count, &total); } else { cnt = do_pread(blk, buf, offset, count, &total); } gettimeofday(&t2, NULL); if (cnt < 0) { printf("read failed: %s\n", strerror(-cnt)); goto out; } if (Pflag) { void *cmp_buf = g_malloc(pattern_count); memset(cmp_buf, pattern, pattern_count); if (memcmp(buf + pattern_offset, cmp_buf, pattern_count)) { printf("Pattern verification failed at offset %" PRId64 ", %"PRId64" bytes\n", offset + pattern_offset, pattern_count); } g_free(cmp_buf); } if (qflag) { goto out; } if (vflag) { dump_buffer(buf, offset, count); } t2 = tsub(t2, t1); print_report("read", &t2, offset, count, total, cnt, Cflag); out: qemu_io_free(buf); return 0; }
1threat
Substring out of range exception when I'm pretty sure the arguments are in range : I'm getting System.ArgumentOutOfRangeException error message when I'm trying to substring a year off of a string which is in DateTime format (*"mm/dd/yyyy hh:mm:ss xx"*). for(int i = 0; i < elementCounter; i++) { String stringDate = Convert.ToString(DatumPocetka[i]); DPGodina[i] = stringDate.Substring(stringDate.Length - 16, 4); } DatumPocetka is an ArrayList with string type values which are in DateTime format I mentioned earlier.<br><br>I have to calculate the starting character from the back of the string though. I don't know the index where the year starts when I'm calculating it from the beginning because days and months can be single and double digits. It's easier to calculate it from the back because the time part of the string stays static. (*"mm/dd/__yyyy hh:mm:ss xx__"*) this part of the string always has 16 characters, so that's why I'm subtracting the length by 16.<br>Even Visual Studio says that stringDate.Length is equal to 21, but I'm still getting the ArgumentOutOfRangeException. (I tried posting a picture but I can't because I don't have 10 reputation yet) I have tried doing this with List<*DateTime*> using *name.Year.ToString();* but that did not work either. I have probably explained things that I didn't need to because they are self explanatory, but this is my first post so I'm sorry. <br><br> Thanks.
0debug
static int nic_init(PCIDevice *pci_dev, uint32_t device) { PCIEEPRO100State *d = DO_UPCAST(PCIEEPRO100State, dev, pci_dev); EEPRO100State *s; logout("\n"); d->dev.unregister = pci_nic_uninit; s = &d->eepro100; s->device = device; s->pci_dev = &d->dev; pci_reset(s); s->eeprom = eeprom93xx_new(EEPROM_SIZE); d->eepro100.mmio_index = cpu_register_io_memory(pci_mmio_read, pci_mmio_write, s); pci_register_bar(&d->dev, 0, PCI_MEM_SIZE, PCI_ADDRESS_SPACE_MEM | PCI_ADDRESS_SPACE_MEM_PREFETCH, pci_mmio_map); pci_register_bar(&d->dev, 1, PCI_IO_SIZE, PCI_ADDRESS_SPACE_IO, pci_map); pci_register_bar(&d->dev, 2, PCI_FLASH_SIZE, PCI_ADDRESS_SPACE_MEM, pci_mmio_map); qdev_get_macaddr(&d->dev.qdev, s->macaddr); logout("macaddr: %s\n", nic_dump(&s->macaddr[0], 6)); assert(s->region[1] == 0); nic_reset(s); s->vc = qdev_get_vlan_client(&d->dev.qdev, nic_can_receive, nic_receive, NULL, nic_cleanup, s); qemu_format_nic_info_str(s->vc, s->macaddr); qemu_register_reset(nic_reset, s); register_savevm(s->vc->model, -1, 3, nic_save, nic_load, s); return 0; }
1threat
Java: non-distributed event-processing : <p>My application logic should be based on event processing. Its not that hard to implement corresponding producer-consumer patterns and event classes. But first I would like to ensure this was not implemented before.</p> <p>I would like to specify that I am talking about non-distributed event-processing. I.e. I dont need to serialize my events and send them to some other JVMs.</p> <p>Which options do I have?</p> <ol> <li>I use Spring. In Spring there is event-handling support already present. Is Spring event-processing robust enough? What are the limitations?</li> <li>I can use Akka. Good, but Akka is mainly for distributed systems. Is it worth to use it for single JVM application?</li> <li>I can implement this by myself. Not a big deal, but I always prefer to consult stackoverflow before reinventing the wheel.</li> </ol> <p>?</p>
0debug
Angular 6 route path not working for direct url when deployed in subdirectory : <p>app.routing.module.ts</p> <pre><code>import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { HomeComponent } from './public/home/home.component'; const routes: Routes = [ { path: 'customers', loadChildren: '../app/customers/customers.module#CustomersModule' }, { path: 'admin', loadChildren: '../app/admin/admin.module#AdminModule' }, { path: 'home', component: HomeComponent }, { path: '**', redirectTo: 'home', } ]; @NgModule({ imports: [RouterModule.forRoot(routes)], exports: [RouterModule] }) export class AppRoutingModule { } </code></pre> <p>These works fine under the <strong>Development environment</strong>. If I directly open <code>localhost:4200/home</code> then it's landing on the expected page.</p> <p>However, the one <strong>built</strong> and <strong>deployed</strong> using with <code>ng build --prod --base-href=/myngapp/</code> do works only on <code>www.domain.com/myngapp</code> if I open the <code>www.domain.com/myngapp/home</code> directly, then it gives 404 not found error.</p>
0debug
convert json tree structure to list : i am new in json. i have a json list in tree structure like bellow {"complaint@simulator.amazonses.com":{"time":"2018-01-02T20:45:46.650Z","type":"Complaint","bounceType":"null","bounceSubType":"null"}, "struax@afb.net":{"time":"2018-01-02T20:53:03.000Z","type":"Bounce","bounceType":"Permanent","bounceSubType":"Suppressed"}, "bounce-test@service.socketlabs.com":{"time":"2018-01-02T21:06:40.097Z","type":"Bounce","bounceType":"Permanent","bounceSubType":"Suppressed"}, "bounce@simulator.amazonses.com":{"time":"2018-01-02T21:08:02.000Z","type":"Bounce","bounceType":"Permanent","bounceSubType":"General"}, "jstrechay@afb.net":{"time":"2018-01-05T06:31:39.000Z","type":"Bounce","bounceType":"Permanent","bounceSubType":"General"}, "leematt45@hotmail.com":{"time":"2018-01-05T06:49:13.000Z","type":"Bounce","bounceType":"Permanent","bounceSubType":"Suppressed"}, "afbweb@afb.net":{"time":"2018-01-07T12:50:38.000Z","type":"Bounce","bounceType":"Transient","bounceSubType":"General"}, "rushjenacath@gmail.com":{"time":"2018-01-05T06:32:42.000Z","type":"Bounce","bounceType":"Permanent","bounceSubType":"Suppressed"}, "Kerryhoskins0925@gmaiil.com":{"time":"2018-01-02T09:18:20.000Z","type":"Bounce","bounceType":"Transient","bounceSubType":"General"}, how to extract data form the json list and save in db. please help
0debug
VTDAddressSpace *vtd_find_add_as(IntelIOMMUState *s, PCIBus *bus, int devfn) { uintptr_t key = (uintptr_t)bus; VTDBus *vtd_bus = g_hash_table_lookup(s->vtd_as_by_busptr, &key); VTDAddressSpace *vtd_dev_as; char name[128]; if (!vtd_bus) { uintptr_t *new_key = g_malloc(sizeof(*new_key)); *new_key = (uintptr_t)bus; vtd_bus = g_malloc0(sizeof(VTDBus) + sizeof(VTDAddressSpace *) * \ X86_IOMMU_PCI_DEVFN_MAX); vtd_bus->bus = bus; g_hash_table_insert(s->vtd_as_by_busptr, new_key, vtd_bus); } vtd_dev_as = vtd_bus->dev_as[devfn]; if (!vtd_dev_as) { snprintf(name, sizeof(name), "intel_iommu_devfn_%d", devfn); vtd_bus->dev_as[devfn] = vtd_dev_as = g_malloc0(sizeof(VTDAddressSpace)); vtd_dev_as->bus = bus; vtd_dev_as->devfn = (uint8_t)devfn; vtd_dev_as->iommu_state = s; vtd_dev_as->context_cache_entry.context_cache_gen = 0; memory_region_init_iommu(&vtd_dev_as->iommu, OBJECT(s), &s->iommu_ops, "intel_iommu", UINT64_MAX); memory_region_init_io(&vtd_dev_as->iommu_ir, OBJECT(s), &vtd_mem_ir_ops, s, "intel_iommu_ir", VTD_INTERRUPT_ADDR_SIZE); memory_region_add_subregion(&vtd_dev_as->iommu, VTD_INTERRUPT_ADDR_FIRST, &vtd_dev_as->iommu_ir); address_space_init(&vtd_dev_as->as, &vtd_dev_as->iommu, name); } return vtd_dev_as; }
1threat
static void restore_native_fp_fxrstor(CPUState *env) { struct fpxstate *fp = &fpx1; int i, j, fptag; fp->fpuc = env->fpuc; fp->fpus = (env->fpus & ~0x3800) | (env->fpstt & 0x7) << 11; fptag = 0; for(i = 0; i < 8; i++) fptag |= (env->fptags[i] << i); fp->fptag = fptag ^ 0xff; j = env->fpstt; for(i = 0;i < 8; i++) { memcpy(&fp->fpregs1[i * 16], &env->fpregs[j].d, 10); j = (j + 1) & 7; } if (env->cpuid_features & CPUID_SSE) { fp->mxcsr = env->mxcsr; fp->mxcsr_mask = 0xffff; memcpy(fp->xmm_regs, env->xmm_regs, CPU_NB_REGS * 16); } asm volatile ("fxrstor %0" : "=m" (*fp)); }
1threat
void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size, const char *boot_device, ISADevice *floppy, BusState *idebus0, BusState *idebus1, ISADevice *s) { int val, nb, i; FDriveType fd_type[2] = { FDRIVE_DRV_NONE, FDRIVE_DRV_NONE }; static pc_cmos_init_late_arg arg; val = 640; rtc_set_memory(s, 0x15, val); rtc_set_memory(s, 0x16, val >> 8); val = (ram_size / 1024) - 1024; if (val > 65535) val = 65535; rtc_set_memory(s, 0x17, val); rtc_set_memory(s, 0x18, val >> 8); rtc_set_memory(s, 0x30, val); rtc_set_memory(s, 0x31, val >> 8); if (above_4g_mem_size) { rtc_set_memory(s, 0x5b, (unsigned int)above_4g_mem_size >> 16); rtc_set_memory(s, 0x5c, (unsigned int)above_4g_mem_size >> 24); rtc_set_memory(s, 0x5d, (uint64_t)above_4g_mem_size >> 32); } if (ram_size > (16 * 1024 * 1024)) val = (ram_size / 65536) - ((16 * 1024 * 1024) / 65536); else val = 0; if (val > 65535) val = 65535; rtc_set_memory(s, 0x34, val); rtc_set_memory(s, 0x35, val >> 8); rtc_set_memory(s, 0x5f, smp_cpus - 1); if (set_boot_dev(s, boot_device, fd_bootchk)) { exit(1); } if (floppy) { for (i = 0; i < 2; i++) { fd_type[i] = isa_fdc_get_drive_type(floppy, i); } } val = (cmos_get_fd_drive_type(fd_type[0]) << 4) | cmos_get_fd_drive_type(fd_type[1]); rtc_set_memory(s, 0x10, val); val = 0; nb = 0; if (fd_type[0] < FDRIVE_DRV_NONE) { nb++; } if (fd_type[1] < FDRIVE_DRV_NONE) { nb++; } switch (nb) { case 0: break; case 1: val |= 0x01; break; case 2: val |= 0x41; break; } val |= 0x02; val |= 0x04; rtc_set_memory(s, REG_EQUIPMENT_BYTE, val); arg.rtc_state = s; arg.idebus[0] = idebus0; arg.idebus[1] = idebus1; qemu_register_reset(pc_cmos_init_late, &arg); }
1threat