problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
Camera2 ImageReader freezes repeating capture request : <p>I'm trying to capture image data from the camera using the camera2 API. I've mostly used code taken from the android Capture2RAW example. Only a few images come through (i.e. calls to onImageAvailable) before stopping completely. I've tried capturing using the RAW_SENSOR and JPEG formats at different sizes with the same results. What am I doing wrong?</p>
<pre><code>this.mImageReader = ImageReader.newInstance(width, height, ImageFormat.RAW_SENSOR, /*maxImages*/ 1);
Surface surface = this.mImageReader.getSurface();
final List<Surface> surfaces = Arrays.asList(surface);
this.mCamera.createCaptureSession(surfaces, new CameraCaptureSession.StateCallback() {
// Callback methods here
}, null);
CaptureRequest.Builder captureRequestBuilder;
captureRequestBuilder = this.mCamera.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
captureRequestBuilder.addTarget(surface);
this.mCaptureRequest = captureRequestBuilder.build();
this.mCaptureSession.setRepeatingRequest(mCaptureRequest, null, null);
</code></pre>
| 0debug
|
alert('Hello ' + user_input);
| 1threat
|
int kvmppc_remove_spapr_tce(void *table, int fd, uint32_t window_size)
{
long len;
if (fd < 0) {
return -1;
}
len = (window_size / SPAPR_TCE_PAGE_SIZE)*sizeof(sPAPRTCE);
if ((munmap(table, len) < 0) ||
(close(fd) < 0)) {
fprintf(stderr, "KVM: Unexpected error removing TCE table: %s",
strerror(errno));
}
return 0;
}
| 1threat
|
static void v9fs_unlinkat(void *opaque)
{
int err = 0;
V9fsString name;
int32_t dfid, flags;
size_t offset = 7;
V9fsPath path;
V9fsFidState *dfidp;
V9fsPDU *pdu = opaque;
pdu_unmarshal(pdu, offset, "dsd", &dfid, &name, &flags);
dfidp = get_fid(pdu, dfid);
if (dfidp == NULL) {
err = -EINVAL;
goto out_nofid;
}
v9fs_path_init(&path);
err = v9fs_co_name_to_path(pdu, &dfidp->path, name.data, &path);
if (err < 0) {
goto out_err;
}
err = v9fs_mark_fids_unreclaim(pdu, &path);
if (err < 0) {
goto out_err;
}
err = v9fs_co_unlinkat(pdu, &dfidp->path, &name, flags);
if (!err) {
err = offset;
}
out_err:
put_fid(pdu, dfidp);
v9fs_path_free(&path);
out_nofid:
complete_pdu(pdu->s, pdu, err);
v9fs_string_free(&name);
}
| 1threat
|
selenium with C# on IE : <p>Switching multiple windows in IE. </p>
<p>First page has LOGIN button which on clicked goes to second window. </p>
<p>Second window takes credentials and has a NEXT button which on clicked goes to third window.</p>
<p>Third window has a button which on clicking moves to the fourth window. </p>
<p>How do I navigate mutiple windows using Selenium with C#.My website runs on IE only.</p>
| 0debug
|
void cpu_loop(CPUM68KState *env)
{
CPUState *cs = CPU(m68k_env_get_cpu(env));
int trapnr;
unsigned int n;
target_siginfo_t info;
TaskState *ts = cs->opaque;
for(;;) {
cpu_exec_start(cs);
trapnr = cpu_m68k_exec(cs);
cpu_exec_end(cs);
switch(trapnr) {
case EXCP_ILLEGAL:
{
if (ts->sim_syscalls) {
uint16_t nr;
get_user_u16(nr, env->pc + 2);
env->pc += 4;
do_m68k_simcall(env, nr);
} else {
goto do_sigill;
}
}
break;
case EXCP_HALT_INSN:
env->pc += 4;
do_m68k_semihosting(env, env->dregs[0]);
break;
case EXCP_LINEA:
case EXCP_LINEF:
case EXCP_UNSUPPORTED:
do_sigill:
info.si_signo = TARGET_SIGILL;
info.si_errno = 0;
info.si_code = TARGET_ILL_ILLOPN;
info._sifields._sigfault._addr = env->pc;
queue_signal(env, info.si_signo, &info);
break;
case EXCP_TRAP0:
{
ts->sim_syscalls = 0;
n = env->dregs[0];
env->pc += 2;
env->dregs[0] = do_syscall(env,
n,
env->dregs[1],
env->dregs[2],
env->dregs[3],
env->dregs[4],
env->dregs[5],
env->aregs[0],
0, 0);
}
break;
case EXCP_INTERRUPT:
break;
case EXCP_ACCESS:
{
info.si_signo = TARGET_SIGSEGV;
info.si_errno = 0;
info.si_code = TARGET_SEGV_MAPERR;
info._sifields._sigfault._addr = env->mmu.ar;
queue_signal(env, info.si_signo, &info);
}
break;
case EXCP_DEBUG:
{
int sig;
sig = gdb_handlesig(cs, TARGET_SIGTRAP);
if (sig)
{
info.si_signo = sig;
info.si_errno = 0;
info.si_code = TARGET_TRAP_BRKPT;
queue_signal(env, info.si_signo, &info);
}
}
break;
default:
fprintf(stderr, "qemu: unhandled CPU exception 0x%x - aborting\n",
trapnr);
cpu_dump_state(cs, stderr, fprintf, 0);
abort();
}
process_pending_signals(env);
}
}
| 1threat
|
static int qcow2_check(BlockDriverState *bs, BdrvCheckResult *result,
BdrvCheckMode fix)
{
return qcow2_check_refcounts(bs, result, fix);
}
| 1threat
|
How to find the sum of an array using recursion? : <p>need some help figuring out this assignment, I basically have to find the sum of an array using recursion, I can't use any loops and my function could only have 2 arguments which are the array and the array's size. Also this is my first time posting so forgive me for any formatting errors. Working in C++.</p>
<pre><code>#include "stdafx.h"
#include <iostream>
using namespace std;
int arrayFact(int[], int);
int main()
{
const int SIZE = 4;
int fArray[SIZE] = { 4, 5, 10, 12, };
cout << "test: " << arrayFact(fArray, SIZE);
return 0;
}
int arrayFact(int array[], int s)
{
if (s == 0)
return 1;
else
return array[s] + arrayFact(array, s--);
}
</code></pre>
| 0debug
|
int bdrv_write_zeroes(BlockDriverState *bs, int64_t sector_num,
int nb_sectors, BdrvRequestFlags flags)
{
return bdrv_rw_co(bs, sector_num, NULL, nb_sectors, true,
BDRV_REQ_ZERO_WRITE | flags);
}
| 1threat
|
Sort Array of Objects Based on number of Keys it contains : <p>This is a sample code but it does not seem to sort the array. All I want is the array of object sorted in such a manner that the object with maximum keys comes first.</p>
<pre><code>CSVData.sort(function(item1,item2){
return Object.keys(item2).length - Object.keys(item1);
});
</code></pre>
| 0debug
|
static void RENAME(uyvytoyuv422)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src,
long width, long height,
long lumStride, long chromStride, long srcStride)
{
long y;
const long chromWidth= -((-width)>>1);
for (y=0; y<height; y++) {
RENAME(extract_even)(src+1, ydst, width);
RENAME(extract_even2)(src, udst, vdst, chromWidth);
src += srcStride;
ydst+= lumStride;
udst+= chromStride;
vdst+= chromStride;
}
#if COMPILE_TEMPLATE_MMX
__asm__(
EMMS" \n\t"
SFENCE" \n\t"
::: "memory"
);
#endif
}
| 1threat
|
SwsContext *getSwsContext(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat, int flags,
SwsFilter *srcFilter, SwsFilter *dstFilter){
SwsContext *c;
int i;
SwsFilter dummyFilter= {NULL, NULL, NULL, NULL};
#ifdef ARCH_X86
if(gCpuCaps.hasMMX)
asm volatile("emms\n\t"::: "memory");
#endif
if(swScale==NULL) globalInit();
if(srcW<4 || srcH<1 || dstW<8 || dstH<1) return NULL;
if(!dstFilter) dstFilter= &dummyFilter;
if(!srcFilter) srcFilter= &dummyFilter;
c= memalign(64, sizeof(SwsContext));
memset(c, 0, sizeof(SwsContext));
c->srcW= srcW;
c->srcH= srcH;
c->dstW= dstW;
c->dstH= dstH;
c->lumXInc= ((srcW<<16) + (dstW>>1))/dstW;
c->lumYInc= ((srcH<<16) + (dstH>>1))/dstH;
c->flags= flags;
c->dstFormat= dstFormat;
c->srcFormat= srcFormat;
if(cpuCaps.hasMMX2)
{
c->canMMX2BeUsed= (dstW >=srcW && (dstW&31)==0 && (srcW&15)==0) ? 1 : 0;
if(!c->canMMX2BeUsed && dstW >=srcW && (srcW&15)==0 && (flags&SWS_FAST_BILINEAR))
{
if(flags&SWS_PRINT_INFO)
fprintf(stderr, "SwScaler: output Width is not a multiple of 32 -> no MMX2 scaler\n");
}
}
else
c->canMMX2BeUsed=0;
if(isHalfChrV(srcFormat)) c->flags= flags= flags&(~SWS_FULL_CHR_V);
if(isHalfChrH(srcFormat)) c->flags= flags= flags&(~SWS_FULL_CHR_H_INP);
if(isHalfChrH(dstFormat)) c->flags= flags= flags&(~SWS_FULL_CHR_H_INT);
if(flags&SWS_FULL_CHR_H_INP) c->chrSrcW= srcW;
else c->chrSrcW= (srcW+1)>>1;
if(flags&SWS_FULL_CHR_H_INT) c->chrDstW= dstW;
else c->chrDstW= (dstW+1)>>1;
if(flags&SWS_FULL_CHR_V) c->chrSrcH= srcH;
else c->chrSrcH= (srcH+1)>>1;
if(isHalfChrV(dstFormat)) c->chrDstH= (dstH+1)>>1;
else c->chrDstH= dstH;
c->chrXInc= ((c->chrSrcW<<16) + (c->chrDstW>>1))/c->chrDstW;
c->chrYInc= ((c->chrSrcH<<16) + (c->chrDstH>>1))/c->chrDstH;
if(flags&SWS_FAST_BILINEAR)
{
if(c->canMMX2BeUsed)
{
c->lumXInc+= 20;
c->chrXInc+= 20;
}
else if(cpuCaps.hasMMX)
{
c->lumXInc = ((srcW-2)<<16)/(dstW-2) - 20;
c->chrXInc = ((c->chrSrcW-2)<<16)/(c->chrDstW-2) - 20;
}
}
{
const int filterAlign= cpuCaps.hasMMX ? 4 : 1;
initFilter(&c->hLumFilter, &c->hLumFilterPos, &c->hLumFilterSize, c->lumXInc,
srcW , dstW, filterAlign, 1<<14, flags,
srcFilter->lumH, dstFilter->lumH);
initFilter(&c->hChrFilter, &c->hChrFilterPos, &c->hChrFilterSize, c->chrXInc,
(srcW+1)>>1, c->chrDstW, filterAlign, 1<<14, flags,
srcFilter->chrH, dstFilter->chrH);
#ifdef ARCH_X86
if(c->canMMX2BeUsed && (flags & SWS_FAST_BILINEAR))
{
initMMX2HScaler( dstW, c->lumXInc, c->funnyYCode);
initMMX2HScaler(c->chrDstW, c->chrXInc, c->funnyUVCode);
}
#endif
}
initFilter(&c->vLumFilter, &c->vLumFilterPos, &c->vLumFilterSize, c->lumYInc,
srcH , dstH, 1, (1<<12)-4, flags,
srcFilter->lumV, dstFilter->lumV);
initFilter(&c->vChrFilter, &c->vChrFilterPos, &c->vChrFilterSize, c->chrYInc,
(srcH+1)>>1, c->chrDstH, 1, (1<<12)-4, flags,
srcFilter->chrV, dstFilter->chrV);
c->vLumBufSize= c->vLumFilterSize;
c->vChrBufSize= c->vChrFilterSize;
for(i=0; i<dstH; i++)
{
int chrI= i*c->chrDstH / dstH;
int nextSlice= MAX(c->vLumFilterPos[i ] + c->vLumFilterSize - 1,
((c->vChrFilterPos[chrI] + c->vChrFilterSize - 1)<<1));
nextSlice&= ~1;
if(c->vLumFilterPos[i ] + c->vLumBufSize < nextSlice)
c->vLumBufSize= nextSlice - c->vLumFilterPos[i ];
if(c->vChrFilterPos[chrI] + c->vChrBufSize < (nextSlice>>1))
c->vChrBufSize= (nextSlice>>1) - c->vChrFilterPos[chrI];
}
c->lumPixBuf= (int16_t**)memalign(4, c->vLumBufSize*2*sizeof(int16_t*));
c->chrPixBuf= (int16_t**)memalign(4, c->vChrBufSize*2*sizeof(int16_t*));
for(i=0; i<c->vLumBufSize; i++)
c->lumPixBuf[i]= c->lumPixBuf[i+c->vLumBufSize]= (uint16_t*)memalign(8, 4000);
for(i=0; i<c->vChrBufSize; i++)
c->chrPixBuf[i]= c->chrPixBuf[i+c->vChrBufSize]= (uint16_t*)memalign(8, 8000);
for(i=0; i<c->vLumBufSize; i++) memset(c->lumPixBuf[i], 0, 4000);
for(i=0; i<c->vChrBufSize; i++) memset(c->chrPixBuf[i], 64, 8000);
ASSERT(c->chrDstH <= dstH)
if(cpuCaps.hasMMX)
{
c->lumMmxFilter= (int16_t*)memalign(8, c->vLumFilterSize* dstH*4*sizeof(int16_t));
c->chrMmxFilter= (int16_t*)memalign(8, c->vChrFilterSize*c->chrDstH*4*sizeof(int16_t));
for(i=0; i<c->vLumFilterSize*dstH; i++)
c->lumMmxFilter[4*i]=c->lumMmxFilter[4*i+1]=c->lumMmxFilter[4*i+2]=c->lumMmxFilter[4*i+3]=
c->vLumFilter[i];
for(i=0; i<c->vChrFilterSize*c->chrDstH; i++)
c->chrMmxFilter[4*i]=c->chrMmxFilter[4*i+1]=c->chrMmxFilter[4*i+2]=c->chrMmxFilter[4*i+3]=
c->vChrFilter[i];
}
if(flags&SWS_PRINT_INFO)
{
#ifdef DITHER1XBPP
char *dither= " dithered";
#else
char *dither= "";
#endif
if(flags&SWS_FAST_BILINEAR)
fprintf(stderr, "\nSwScaler: FAST_BILINEAR scaler, ");
else if(flags&SWS_BILINEAR)
fprintf(stderr, "\nSwScaler: BILINEAR scaler, ");
else if(flags&SWS_BICUBIC)
fprintf(stderr, "\nSwScaler: BICUBIC scaler, ");
else if(flags&SWS_X)
fprintf(stderr, "\nSwScaler: Experimental scaler, ");
else if(flags&SWS_POINT)
fprintf(stderr, "\nSwScaler: Nearest Neighbor / POINT scaler, ");
else if(flags&SWS_AREA)
fprintf(stderr, "\nSwScaler: Area Averageing scaler, ");
else
fprintf(stderr, "\nSwScaler: ehh flags invalid?! ");
if(dstFormat==IMGFMT_BGR15 || dstFormat==IMGFMT_BGR16)
fprintf(stderr, "from %s to%s %s ",
vo_format_name(srcFormat), dither, vo_format_name(dstFormat));
else
fprintf(stderr, "from %s to %s ",
vo_format_name(srcFormat), vo_format_name(dstFormat));
if(cpuCaps.hasMMX2)
fprintf(stderr, "using MMX2\n");
else if(cpuCaps.has3DNow)
fprintf(stderr, "using 3DNOW\n");
else if(cpuCaps.hasMMX)
fprintf(stderr, "using MMX\n");
else
fprintf(stderr, "using C\n");
}
if((flags & SWS_PRINT_INFO) && verbose)
{
if(cpuCaps.hasMMX)
{
if(c->canMMX2BeUsed && (flags&SWS_FAST_BILINEAR))
printf("SwScaler: using FAST_BILINEAR MMX2 scaler for horizontal scaling\n");
else
{
if(c->hLumFilterSize==4)
printf("SwScaler: using 4-tap MMX scaler for horizontal luminance scaling\n");
else if(c->hLumFilterSize==8)
printf("SwScaler: using 8-tap MMX scaler for horizontal luminance scaling\n");
else
printf("SwScaler: using n-tap MMX scaler for horizontal luminance scaling\n");
if(c->hChrFilterSize==4)
printf("SwScaler: using 4-tap MMX scaler for horizontal chrominance scaling\n");
else if(c->hChrFilterSize==8)
printf("SwScaler: using 8-tap MMX scaler for horizontal chrominance scaling\n");
else
printf("SwScaler: using n-tap MMX scaler for horizontal chrominance scaling\n");
}
}
else
{
#ifdef ARCH_X86
printf("SwScaler: using X86-Asm scaler for horizontal scaling\n");
#else
if(flags & SWS_FAST_BILINEAR)
printf("SwScaler: using FAST_BILINEAR C scaler for horizontal scaling\n");
else
printf("SwScaler: using C scaler for horizontal scaling\n");
#endif
}
if(isPlanarYUV(dstFormat))
{
if(c->vLumFilterSize==1)
printf("SwScaler: using 1-tap %s \"scaler\" for vertical scaling (YV12 like)\n", cpuCaps.hasMMX ? "MMX" : "C");
else
printf("SwScaler: using n-tap %s scaler for vertical scaling (YV12 like)\n", cpuCaps.hasMMX ? "MMX" : "C");
}
else
{
if(c->vLumFilterSize==1 && c->vChrFilterSize==2)
printf("SwScaler: using 1-tap %s \"scaler\" for vertical luminance scaling (BGR)\n"
"SwScaler: 2-tap scaler for vertical chrominance scaling (BGR)\n",cpuCaps.hasMMX ? "MMX" : "C");
else if(c->vLumFilterSize==2 && c->vChrFilterSize==2)
printf("SwScaler: using 2-tap linear %s scaler for vertical scaling (BGR)\n", cpuCaps.hasMMX ? "MMX" : "C");
else
printf("SwScaler: using n-tap %s scaler for vertical scaling (BGR)\n", cpuCaps.hasMMX ? "MMX" : "C");
}
if(dstFormat==IMGFMT_BGR24)
printf("SwScaler: using %s YV12->BGR24 Converter\n",
cpuCaps.hasMMX2 ? "MMX2" : (cpuCaps.hasMMX ? "MMX" : "C"));
else if(dstFormat==IMGFMT_BGR32)
printf("SwScaler: using %s YV12->BGR32 Converter\n", cpuCaps.hasMMX ? "MMX" : "C");
else if(dstFormat==IMGFMT_BGR16)
printf("SwScaler: using %s YV12->BGR16 Converter\n", cpuCaps.hasMMX ? "MMX" : "C");
else if(dstFormat==IMGFMT_BGR15)
printf("SwScaler: using %s YV12->BGR15 Converter\n", cpuCaps.hasMMX ? "MMX" : "C");
printf("SwScaler: %dx%d -> %dx%d\n", srcW, srcH, dstW, dstH);
}
if((flags & SWS_PRINT_INFO) && verbose>1)
{
printf("SwScaler:Lum srcW=%d srcH=%d dstW=%d dstH=%d xInc=%d yInc=%d\n",
c->srcW, c->srcH, c->dstW, c->dstH, c->lumXInc, c->lumYInc);
printf("SwScaler:Chr srcW=%d srcH=%d dstW=%d dstH=%d xInc=%d yInc=%d\n",
c->chrSrcW, c->chrSrcH, c->chrDstW, c->chrDstH, c->chrXInc, c->chrYInc);
}
return c;
}
| 1threat
|
SQL server query help please, I am newbie : Can anyone help me with the correct query for this please?
I need to know the total number of Jobs completed by each Employee as well as the total Rate if I only have the following information.
*One job can be completed by 2 different Employees.
For Example, Employee A has completed 2 jobs (JobID and JobID 2)
So the total segments of Employee A is 30 segments but per jobID is different segment rate.
But I just need the total rate of all segments. SO Employee A has complete 2 jobs and a total of 90USD
(10 x 5 USD) + (20 x 2 USD) = 90 USD
Please see the image for the tale as I do not know yet how to post her, it is my first time. Thank you so much!
[Please view this image for the table][1]
[1]: https://i.stack.imgur.com/Jns9A.jpg
| 0debug
|
static int swScale(SwsContext *c, const uint8_t *src[],
int srcStride[], int srcSliceY,
int srcSliceH, uint8_t *dst[], int dstStride[])
{
const int srcW = c->srcW;
const int dstW = c->dstW;
const int dstH = c->dstH;
const int chrDstW = c->chrDstW;
const int chrSrcW = c->chrSrcW;
const int lumXInc = c->lumXInc;
const int chrXInc = c->chrXInc;
const enum PixelFormat dstFormat = c->dstFormat;
const int flags = c->flags;
int32_t *vLumFilterPos = c->vLumFilterPos;
int32_t *vChrFilterPos = c->vChrFilterPos;
int32_t *hLumFilterPos = c->hLumFilterPos;
int32_t *hChrFilterPos = c->hChrFilterPos;
int16_t *vLumFilter = c->vLumFilter;
int16_t *vChrFilter = c->vChrFilter;
int16_t *hLumFilter = c->hLumFilter;
int16_t *hChrFilter = c->hChrFilter;
int32_t *lumMmxFilter = c->lumMmxFilter;
int32_t *chrMmxFilter = c->chrMmxFilter;
const int vLumFilterSize = c->vLumFilterSize;
const int vChrFilterSize = c->vChrFilterSize;
const int hLumFilterSize = c->hLumFilterSize;
const int hChrFilterSize = c->hChrFilterSize;
int16_t **lumPixBuf = c->lumPixBuf;
int16_t **chrUPixBuf = c->chrUPixBuf;
int16_t **chrVPixBuf = c->chrVPixBuf;
int16_t **alpPixBuf = c->alpPixBuf;
const int vLumBufSize = c->vLumBufSize;
const int vChrBufSize = c->vChrBufSize;
uint8_t *formatConvBuffer = c->formatConvBuffer;
uint32_t *pal = c->pal_yuv;
yuv2planar1_fn yuv2plane1 = c->yuv2plane1;
yuv2planarX_fn yuv2planeX = c->yuv2planeX;
yuv2interleavedX_fn yuv2nv12cX = c->yuv2nv12cX;
yuv2packed1_fn yuv2packed1 = c->yuv2packed1;
yuv2packed2_fn yuv2packed2 = c->yuv2packed2;
yuv2packedX_fn yuv2packedX = c->yuv2packedX;
const int chrSrcSliceY = srcSliceY >> c->chrSrcVSubSample;
const int chrSrcSliceH = -((-srcSliceH) >> c->chrSrcVSubSample);
int should_dither = is9_OR_10BPS(c->srcFormat) ||
is16BPS(c->srcFormat);
int lastDstY;
int dstY = c->dstY;
int lumBufIndex = c->lumBufIndex;
int chrBufIndex = c->chrBufIndex;
int lastInLumBuf = c->lastInLumBuf;
int lastInChrBuf = c->lastInChrBuf;
if (isPacked(c->srcFormat)) {
src[0] =
src[1] =
src[2] =
src[3] = src[0];
srcStride[0] =
srcStride[1] =
srcStride[2] =
srcStride[3] = srcStride[0];
}
srcStride[1] <<= c->vChrDrop;
srcStride[2] <<= c->vChrDrop;
DEBUG_BUFFERS("swScale() %p[%d] %p[%d] %p[%d] %p[%d] -> %p[%d] %p[%d] %p[%d] %p[%d]\n",
src[0], srcStride[0], src[1], srcStride[1],
src[2], srcStride[2], src[3], srcStride[3],
dst[0], dstStride[0], dst[1], dstStride[1],
dst[2], dstStride[2], dst[3], dstStride[3]);
DEBUG_BUFFERS("srcSliceY: %d srcSliceH: %d dstY: %d dstH: %d\n",
srcSliceY, srcSliceH, dstY, dstH);
DEBUG_BUFFERS("vLumFilterSize: %d vLumBufSize: %d vChrFilterSize: %d vChrBufSize: %d\n",
vLumFilterSize, vLumBufSize, vChrFilterSize, vChrBufSize);
if (dstStride[0] % 8 != 0 || dstStride[1] % 8 != 0 ||
dstStride[2] % 8 != 0 || dstStride[3] % 8 != 0) {
static int warnedAlready = 0;
if (flags & SWS_PRINT_INFO && !warnedAlready) {
av_log(c, AV_LOG_WARNING,
"Warning: dstStride is not aligned!\n"
" ->cannot do aligned memory accesses anymore\n");
warnedAlready = 1;
}
}
if (srcSliceY == 0) {
lumBufIndex = -1;
chrBufIndex = -1;
dstY = 0;
lastInLumBuf = -1;
lastInChrBuf = -1;
}
if (!should_dither) {
c->chrDither8 = c->lumDither8 = ff_sws_pb_64;
}
lastDstY = dstY;
for (; dstY < dstH; dstY++) {
const int chrDstY = dstY >> c->chrDstVSubSample;
uint8_t *dest[4] = {
dst[0] + dstStride[0] * dstY,
dst[1] + dstStride[1] * chrDstY,
dst[2] + dstStride[2] * chrDstY,
(CONFIG_SWSCALE_ALPHA && alpPixBuf) ? dst[3] + dstStride[3] * dstY : NULL,
};
const int firstLumSrcY = FFMAX(1 - vLumFilterSize, vLumFilterPos[dstY]);
const int firstLumSrcY2 = FFMAX(1 - vLumFilterSize, vLumFilterPos[FFMIN(dstY | ((1 << c->chrDstVSubSample) - 1), dstH - 1)]);
const int firstChrSrcY = FFMAX(1 - vChrFilterSize, vChrFilterPos[chrDstY]);
int lastLumSrcY = FFMIN(c->srcH, firstLumSrcY + vLumFilterSize) - 1;
int lastLumSrcY2 = FFMIN(c->srcH, firstLumSrcY2 + vLumFilterSize) - 1;
int lastChrSrcY = FFMIN(c->chrSrcH, firstChrSrcY + vChrFilterSize) - 1;
int enough_lines;
if (firstLumSrcY > lastInLumBuf)
lastInLumBuf = firstLumSrcY - 1;
if (firstChrSrcY > lastInChrBuf)
lastInChrBuf = firstChrSrcY - 1;
assert(firstLumSrcY >= lastInLumBuf - vLumBufSize + 1);
assert(firstChrSrcY >= lastInChrBuf - vChrBufSize + 1);
DEBUG_BUFFERS("dstY: %d\n", dstY);
DEBUG_BUFFERS("\tfirstLumSrcY: %d lastLumSrcY: %d lastInLumBuf: %d\n",
firstLumSrcY, lastLumSrcY, lastInLumBuf);
DEBUG_BUFFERS("\tfirstChrSrcY: %d lastChrSrcY: %d lastInChrBuf: %d\n",
firstChrSrcY, lastChrSrcY, lastInChrBuf);
enough_lines = lastLumSrcY2 < srcSliceY + srcSliceH &&
lastChrSrcY < -((-srcSliceY - srcSliceH) >> c->chrSrcVSubSample);
if (!enough_lines) {
lastLumSrcY = srcSliceY + srcSliceH - 1;
lastChrSrcY = chrSrcSliceY + chrSrcSliceH - 1;
DEBUG_BUFFERS("buffering slice: lastLumSrcY %d lastChrSrcY %d\n",
lastLumSrcY, lastChrSrcY);
}
while (lastInLumBuf < lastLumSrcY) {
const uint8_t *src1[4] = {
src[0] + (lastInLumBuf + 1 - srcSliceY) * srcStride[0],
src[1] + (lastInLumBuf + 1 - srcSliceY) * srcStride[1],
src[2] + (lastInLumBuf + 1 - srcSliceY) * srcStride[2],
src[3] + (lastInLumBuf + 1 - srcSliceY) * srcStride[3],
};
lumBufIndex++;
assert(lumBufIndex < 2 * vLumBufSize);
assert(lastInLumBuf + 1 - srcSliceY < srcSliceH);
assert(lastInLumBuf + 1 - srcSliceY >= 0);
hyscale(c, lumPixBuf[lumBufIndex], dstW, src1, srcW, lumXInc,
hLumFilter, hLumFilterPos, hLumFilterSize,
formatConvBuffer, pal, 0);
if (CONFIG_SWSCALE_ALPHA && alpPixBuf)
hyscale(c, alpPixBuf[lumBufIndex], dstW, src1, srcW,
lumXInc, hLumFilter, hLumFilterPos, hLumFilterSize,
formatConvBuffer, pal, 1);
lastInLumBuf++;
DEBUG_BUFFERS("\t\tlumBufIndex %d: lastInLumBuf: %d\n",
lumBufIndex, lastInLumBuf);
}
while (lastInChrBuf < lastChrSrcY) {
const uint8_t *src1[4] = {
src[0] + (lastInChrBuf + 1 - chrSrcSliceY) * srcStride[0],
src[1] + (lastInChrBuf + 1 - chrSrcSliceY) * srcStride[1],
src[2] + (lastInChrBuf + 1 - chrSrcSliceY) * srcStride[2],
src[3] + (lastInChrBuf + 1 - chrSrcSliceY) * srcStride[3],
};
chrBufIndex++;
assert(chrBufIndex < 2 * vChrBufSize);
assert(lastInChrBuf + 1 - chrSrcSliceY < (chrSrcSliceH));
assert(lastInChrBuf + 1 - chrSrcSliceY >= 0);
if (c->needs_hcscale)
hcscale(c, chrUPixBuf[chrBufIndex], chrVPixBuf[chrBufIndex],
chrDstW, src1, chrSrcW, chrXInc,
hChrFilter, hChrFilterPos, hChrFilterSize,
formatConvBuffer, pal);
lastInChrBuf++;
DEBUG_BUFFERS("\t\tchrBufIndex %d: lastInChrBuf: %d\n",
chrBufIndex, lastInChrBuf);
}
if (lumBufIndex >= vLumBufSize)
lumBufIndex -= vLumBufSize;
if (chrBufIndex >= vChrBufSize)
chrBufIndex -= vChrBufSize;
if (!enough_lines)
break;
#if HAVE_MMX
updateMMXDitherTables(c, dstY, lumBufIndex, chrBufIndex,
lastInLumBuf, lastInChrBuf);
#endif
if (should_dither) {
c->chrDither8 = dither_8x8_128[chrDstY & 7];
c->lumDither8 = dither_8x8_128[dstY & 7];
}
if (dstY >= dstH - 2) {
ff_sws_init_output_funcs(c, &yuv2plane1, &yuv2planeX, &yuv2nv12cX,
&yuv2packed1, &yuv2packed2, &yuv2packedX);
}
{
const int16_t **lumSrcPtr = (const int16_t **)lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize;
const int16_t **chrUSrcPtr = (const int16_t **)chrUPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
const int16_t **chrVSrcPtr = (const int16_t **)chrVPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
const int16_t **alpSrcPtr = (CONFIG_SWSCALE_ALPHA && alpPixBuf) ?
(const int16_t **)alpPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize : NULL;
if (firstLumSrcY < 0 || firstLumSrcY + vLumFilterSize > c->srcH) {
const int16_t **tmpY = (const int16_t **)lumPixBuf +
2 * vLumBufSize;
int neg = -firstLumSrcY, i;
int end = FFMIN(c->srcH - firstLumSrcY, vLumFilterSize);
for (i = 0; i < neg; i++)
tmpY[i] = lumSrcPtr[neg];
for (; i < end; i++)
tmpY[i] = lumSrcPtr[i];
for (; i < vLumFilterSize; i++)
tmpY[i] = tmpY[i - 1];
lumSrcPtr = tmpY;
if (alpSrcPtr) {
const int16_t **tmpA = (const int16_t **)alpPixBuf +
2 * vLumBufSize;
for (i = 0; i < neg; i++)
tmpA[i] = alpSrcPtr[neg];
for (; i < end; i++)
tmpA[i] = alpSrcPtr[i];
for (; i < vLumFilterSize; i++)
tmpA[i] = tmpA[i - 1];
alpSrcPtr = tmpA;
}
}
if (firstChrSrcY < 0 ||
firstChrSrcY + vChrFilterSize > c->chrSrcH) {
const int16_t **tmpU = (const int16_t **)chrUPixBuf + 2 * vChrBufSize,
**tmpV = (const int16_t **)chrVPixBuf + 2 * vChrBufSize;
int neg = -firstChrSrcY, i;
int end = FFMIN(c->chrSrcH - firstChrSrcY, vChrFilterSize);
for (i = 0; i < neg; i++) {
tmpU[i] = chrUSrcPtr[neg];
tmpV[i] = chrVSrcPtr[neg];
}
for (; i < end; i++) {
tmpU[i] = chrUSrcPtr[i];
tmpV[i] = chrVSrcPtr[i];
}
for (; i < vChrFilterSize; i++) {
tmpU[i] = tmpU[i - 1];
tmpV[i] = tmpV[i - 1];
}
chrUSrcPtr = tmpU;
chrVSrcPtr = tmpV;
}
if (isPlanarYUV(dstFormat) ||
(isGray(dstFormat) && !isALPHA(dstFormat))) {
const int chrSkipMask = (1 << c->chrDstVSubSample) - 1;
if (vLumFilterSize == 1) {
yuv2plane1(lumSrcPtr[0], dest[0], dstW, c->lumDither8, 0);
} else {
yuv2planeX(vLumFilter + dstY * vLumFilterSize,
vLumFilterSize, lumSrcPtr, dest[0],
dstW, c->lumDither8, 0);
}
if (!((dstY & chrSkipMask) || isGray(dstFormat))) {
if (yuv2nv12cX) {
yuv2nv12cX(c, vChrFilter + chrDstY * vChrFilterSize,
vChrFilterSize, chrUSrcPtr, chrVSrcPtr,
dest[1], chrDstW);
} else if (vChrFilterSize == 1) {
yuv2plane1(chrUSrcPtr[0], dest[1], chrDstW, c->chrDither8, 0);
yuv2plane1(chrVSrcPtr[0], dest[2], chrDstW, c->chrDither8, 3);
} else {
yuv2planeX(vChrFilter + chrDstY * vChrFilterSize,
vChrFilterSize, chrUSrcPtr, dest[1],
chrDstW, c->chrDither8, 0);
yuv2planeX(vChrFilter + chrDstY * vChrFilterSize,
vChrFilterSize, chrVSrcPtr, dest[2],
chrDstW, c->chrDither8, 3);
}
}
if (CONFIG_SWSCALE_ALPHA && alpPixBuf) {
if (vLumFilterSize == 1) {
yuv2plane1(alpSrcPtr[0], dest[3], dstW,
c->lumDither8, 0);
} else {
yuv2planeX(vLumFilter + dstY * vLumFilterSize,
vLumFilterSize, alpSrcPtr, dest[3],
dstW, c->lumDither8, 0);
}
}
} else {
assert(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize * 2);
assert(chrUSrcPtr + vChrFilterSize - 1 < chrUPixBuf + vChrBufSize * 2);
if (c->yuv2packed1 && vLumFilterSize == 1 &&
vChrFilterSize <= 2) {
int chrAlpha = vChrFilterSize == 1 ? 0 : vChrFilter[2 * dstY + 1];
yuv2packed1(c, *lumSrcPtr, chrUSrcPtr, chrVSrcPtr,
alpPixBuf ? *alpSrcPtr : NULL,
dest[0], dstW, chrAlpha, dstY);
} else if (c->yuv2packed2 && vLumFilterSize == 2 &&
vChrFilterSize == 2) {
int lumAlpha = vLumFilter[2 * dstY + 1];
int chrAlpha = vChrFilter[2 * dstY + 1];
lumMmxFilter[2] =
lumMmxFilter[3] = vLumFilter[2 * dstY] * 0x10001;
chrMmxFilter[2] =
chrMmxFilter[3] = vChrFilter[2 * chrDstY] * 0x10001;
yuv2packed2(c, lumSrcPtr, chrUSrcPtr, chrVSrcPtr,
alpPixBuf ? alpSrcPtr : NULL,
dest[0], dstW, lumAlpha, chrAlpha, dstY);
} else {
yuv2packedX(c, vLumFilter + dstY * vLumFilterSize,
lumSrcPtr, vLumFilterSize,
vChrFilter + dstY * vChrFilterSize,
chrUSrcPtr, chrVSrcPtr, vChrFilterSize,
alpSrcPtr, dest[0], dstW, dstY);
}
}
}
}
if (isPlanar(dstFormat) && isALPHA(dstFormat) && !alpPixBuf)
fillPlane(dst[3], dstStride[3], dstW, dstY - lastDstY, lastDstY, 255);
#if HAVE_MMX2
if (av_get_cpu_flags() & AV_CPU_FLAG_MMX2)
__asm__ volatile ("sfence" ::: "memory");
#endif
emms_c();
c->dstY = dstY;
c->lumBufIndex = lumBufIndex;
c->chrBufIndex = chrBufIndex;
c->lastInLumBuf = lastInLumBuf;
c->lastInChrBuf = lastInChrBuf;
return dstY - lastDstY;
}
| 1threat
|
How to multiply two matrices in R? : <p>I hve two matrices . One of the matrix is 3x1 and another one is 3x3 matrix. How could I multiply them in R ?</p>
| 0debug
|
How to add custom font in react native android : <p>I am learning <code>react-native</code>, trying to create some demo apps just for learning. I want to set <code>fontFamily</code> to roboto thin of my toolbar title. </p>
<p>I have added roboto thin ttf in <code>assets/fonts</code> folder of my android project, however it seems that it is creating issues while running app. I am getting this issue while running </p>
<blockquote>
<p>react-native start</p>
</blockquote>
<pre><code>ERROR EPERM: operation not permitted, lstat 'E:\Myntra\android\app\build\gener
ated\source\r\debug\android\support\v7\appcompat'
{"errno":-4048,"code":"EPERM","syscall":"lstat","path":"E:\\Myntra\\android\\app
\\build\\generated\\source\\r\\debug\\android\\support\\v7\\appcompat"}
Error: EPERM: operation not permitted, lstat 'E:\Myntra\android\app\build\genera
ted\source\r\debug\android\support\v7\appcompat'
at Error (native)
</code></pre>
<p>When I am removing the font then it is working fine.
I am unable to fix this issue, can anyone help me what can be the reason for this.</p>
<p>Thanks in advance.</p>
| 0debug
|
NullReferenceException on foreach loop when list is populated (not null) : <p>I was going to write up a question on this very peculiar issue I was having, but while writing the question found my own answer. So I figured I would go ahead and post this for the benefit of others and give my answer below.</p>
<p>I have the following foreach loops in my view:</p>
<pre><code>foreach(CustomObject rt in Model.CustomObjectList1) {
...
}
foreach(CustomObject rt in Model.CustomObjectList2) {
...
}
foreach(CustomObject rt in Model.CustomObjectList3) {
...
}
foreach(CustomObject rt in Model.CustomObjectList4) {
...
}
foreach(CustomObject rt in Model.CustomObjectList5) {
...
}
foreach(CustomObject rt in Model.CustomObjectList6) {
...
}
</code></pre>
<p>Model.CustomObjectList1 through Model.CustomObjectList6 are all defined as <code>List<CustomObject></code>, as I have to place these custom objects into different buckets and iterate through each to display on the view.</p>
<p>Before today, this code has worked fine for a long time. Today, I made an edit to the view to add the following hidden input field <strong>outside</strong> the loops at the end of the page: </p>
<p><code><input type="hidden" id="otherObjectId" name="otherObjectId" value="@Model.OtherObject.ID" /></code></p>
<p>After making that change and trying to test my change, I now get a NullReferenceException error after iterating through Model.CustomObjectList6.</p>
<p>Debugging, I can see it looping through all the objects that populate Model.CustomObjectList6, and then after reaching the end of what should be the final iteration the code execution goes back to the top of the foreach loop and throws the NullReferenceException, with the debugger highlighting the "in" in the loop declaration.</p>
<p>I only get this problem on Model.CustomObjectList6. List 1-5 iterate just fine with no errors. I've also tried loading different datasets into this view as different users get different results by design, and the issue persists.</p>
<p>For example, if there are 10 objects in the list, I step through the code for each of the 10 objects and then get the error as if it is trying to execute an 11th iteration that doesn't exist.</p>
<p>To top it off, even if I change the iteration to a standard loop like this (since I know Model.CustomObjectList6 contains exactly 10, non-null items)...</p>
<pre><code>for(int x=0; x<10; x++) {
CustomObject rt = Model.CustomObjectList6[x];
...
}
</code></pre>
<p>...I still get the NullReferenceExceptionError and the debugger highlights <code>x<10</code> as the point of the NullReferenceException error. I can watch it loop through the 10 proper iterations, go back to the top (where it highlights x++), next step it tries to evaluate x<10, and then throws the error.</p>
| 0debug
|
Place an item at a fixed position in a scrolling div : <p>I have a page full of content and <code>window</code> is scrollable, in which there is scrollable <code>div</code> where my objective is to place an icon at the very bottom of the <code>div</code>, which will be visible when someone is scrolling the <code>div</code> and will not visible after content disappears or <code>window</code> scrolls.
But I am not getting how could I achieve my objective. As making it <code>fixed</code> It get visible to whole <code>body</code> scroll.</p>
<p>I want that element to be fixed at the div's bottom and will not visible if the <code>body</code> scrolls
Below I am giving an example:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>div { height: 100px;
border: 1px solid;
overflow:auto;
position:relative;
}
span {
background : red;
position : fixed;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><div>
<p>I have something</p>
<p>I have something shdbfs jsdfjhs d sdfhsjdgf dsb usbsd shdshdhsdbs ds dvhsd sdshd vcsgdvshuc sd chjsdcsshdcbshudcuysdchusd cuyssdc shd cscyusdc gsdcsducsgcs uycsucs sdusdyu</p>
<p>I have something shdbfs jsdfjhs d sdfhsjdgf dsb usbsd shdshdhsdbs ds dvhsd sdshd vcsgdvshuc sd chjsdcsshdcbshudcuysdchusd cuyssdc shd cscyusdc gsdcsducsgcs uycsucs sdusdyu</p>
<span>this need to fixed at the botti=om and visible while scrolling the div</span>
</div>
<p>I have something</p>
<p>I have something shdbfs jsdfjhs d sdfhsjdgf dsb usbsd shdshdhsdbs ds dvhsd sdshd vcsgdvshuc sd chjsdcsshdcbshudcuysdchusd cuyssdc shd cscyusdc gsdcsducsgcs uycsucs sdusdyu</p>
<p>I have something shdbfs jsdfjhs d sdfhsjdgf dsb usbsd shdshdhsdbs ds dvhsd sdshd vcsgdvshuc sd chjsdcsshdcbshudcuysdchusd cuyssdc shd cscyusdc gsdcsducsgcs uycsucs sdusdyu</p>
<p>I have something</p>
<p>I have something shdbfs jsdfjhs d sdfhsjdgf dsb usbsd shdshdhsdbs ds dvhsd sdshd vcsgdvshuc sd chjsdcsshdcbshudcuysdchusd cuyssdc shd cscyusdc gsdcsducsgcs uycsucs sdusdyu</p>
<p>I have something shdbfs jsdfjhs d sdfhsjdgf dsb usbsd shdshdhsdbs ds dvhsd sdshd vcsgdvshuc sd chjsdcsshdcbshudcuysdchusd cuyssdc shd cscyusdc gsdcsducsgcs uycsucs sdusdyu</p></code></pre>
</div>
</div>
</p>
<p>As you can see the red strip content is visible to the whole body if I <code>position</code> it to be <code>fixed</code>. However, i just want it to be fixed at the div's bottom and visible only when <code>div</code> scrolling.</p>
| 0debug
|
How can I capitalize the first letter of each sentence in C# using char? I'm very new to C#, so simplified responses would be appreciated : Sentence capitalization:
private string SentenceCapitalizer(string input)
{
char delim = '.';
string letter1;
string[] tokens = input.Split(delim);
foreach (string phrase in tokens)
{
letter1 = phrase.Remove(0);
letter1.ToUpper();
}
return input;
}
| 0debug
|
image grid css responsive unorganized : any suggestions on how i can make a unorganized gallery grid Like This one .
i have tagged the photo bellow.
i am limited to 6 pictures and no more ,
mostly want to make it responsive for any display size device
and my pictures are in standard horizontal format.
[The example image unorganized grid][1]
[1]: https://i.stack.imgur.com/P0hf3.png
i have tried fixed positioning but my pictures are rectangular shapes
and i dont know how to make them mask in a polygon shape
| 0debug
|
C++ friend function can't access public function of the class : <p>This is an excerpt of an implementation of a Stack class in C++:<br>
<strong>Stackdemo.hpp</strong></p>
<pre><code>#include<iostream>
using namespace std;
template<typename T>
class Stack
{
private:
int top;
T *arr;
public:
Stack(int size)
{
arr = new T[size];
top = 0;
}
void push(const T &x)
{
arr[top++] = x;
}
int size()
{
return top;
}
friend ostream& operator<<(ostream &out, const Stack &s)
{
for(int i = 0; i < s.top; ++i) out<<s.arr[i]<<' '; // Works
for(int i = 0; i < s.size(); ++i) out<<s.arr[i]<<' '; // Doesn't work
return out;
}
};
</code></pre>
<p>Here I am using a simple driver program to test it:<br>
<strong>StackTest.cpp</strong></p>
<pre><code>#include<iostream>
#include"Stackdemo.hpp"
int main()
{
Stack<int> S(5);
S.push(1);
S.push(2);
S.push(3);
cout<<S<<'\n';
return 0;
}
</code></pre>
<p>My problem is in the operator overloading function: the first loop works and produces the expected output, but the second doesn't and gives an error "passing 'const Stack' as 'this' argument discards qualifiers [-fpermissive]". Obviously, I'd be using only one loop at a time. Why is there an issue, since size() just returns the value of top?</p>
| 0debug
|
how to use class name after getting class name from event.target in jaquery? : i've this code on html
<div id="readMorediv_id">
<button class="readMorebtn_id">Read More</button>
<div class="afterReadMore_Class" style="display: none !important;">
<div >
<span><b>User CNIC:</b></span><span><?php $row['usercnic']?></span>
</div>
<div>
<span><b>Father CNIC:</b></span><span><?php echo$row['fathercnic']?>
</span>
</div>
</div>
</div>
and this is my jquery code
$(".readMorebtn_id").on('click', function( e )
{
var icon = e.target;
var parentDiv = $(icon).parent();
var child = $(parentDiv).children(".afterReadMore_Class");
var cls = $(child).attr('class');
console.log(cls);
});
in jquery, where i'm doing "console.log(cls)" class name is displaying in console box. but i want to use this class name for further process. anyone help me
| 0debug
|
def get_pell(n):
if (n <= 2):
return n
a = 1
b = 2
for i in range(3, n+1):
c = 2 * b + a
a = b
b = c
return b
| 0debug
|
Java Program using Linked List : <p>I am making a program in which the program shows some options like insert Book, delete Book etc. The program asks us to enter certain details about a book by Insert method.</p>
<p>I have made every method but I have no any idea of how to make a delete method. It's my assignment in class. First of all I am very very weak in programming and especially in linked list. So any help regarding delete method will be appreciated. Here is my code...</p>
<pre><code>import java.util.Scanner;
public class BookApplication {
static Book head, pointer;
static Scanner scan = new Scanner(System.in);
public static void main(String[] args) {
System.out.println("Welcome to Smart Book Store");
System.out.println("Please choose an option from the list below");
int choice = 0;
do {
System.out.println("1. Insert Book\n2. Delete Book\n3. Search Book\n4. Update Book\n5. View Book\n6. Exit");
choice = scan.nextInt();
try {
choice = Integer.parseInt(scan.nextLine());
} catch (Exception e) {
switch (choice) {
case 1:
addBook();
break;
case 2:
case 3:
searchBook();
break;
case 4:
updateBook();
viewBook();
break;
case 5:
viewBook();
break;
case 6:
scan.close();
System.exit(0);
break;
default:
System.out.println("Please choose from 1 to 5");
break;
}
}
} while (true);
}
static void addBook() {
if (head == null) {
String details[] = enterDetails();
pointer = new Book(details[0], details[1], details[2]);
head = pointer;
pointer.next = null;
} else {
String details[] = enterDetails();
pointer.next = new Book(details[0], details[1], details[2]);
pointer = pointer.next;
}
}
static String[] enterDetails() {
String[] details = new String[4];
try {
String title;
String ISBN;
String authors;
System.out.println("Please enter Book title");
title = scan.nextLine();
System.out.println("Please enter ISBN of book");
ISBN = scan.nextLine();
System.out.println("Please enter book's Author(s)");
authors = scan.nextLine();
details[0] = title;
details[1] = ISBN;
details[2] = authors;
} catch (Exception e) {
e.printStackTrace();
}
return details;
}
private static void searchBook() {
System.out.println();
System.out.println("1. Search by TITLE");
System.out.println("2. Search by ISBN");
System.out.println("3. Search by AUTHOR");
int choice = 0;
choice: try {
choice = Integer.parseInt(scan.nextLine());
} catch (Exception e) {
System.out.println();
System.out.println("PLEASE ENTER VALUE BETWEEN 1 - 3");
break choice;
}
switch (choice) {
case 1:
System.out.println("Please enter Title of BOOK");
String title = scan.nextLine();
if (head == null) {
System.out.println("List is EMPTY !");
return;
} else {
System.out.println();
System.out.println("BOOK(S) IN THE SYSTEM ARE: ");
System.out.println();
pointer = head;
while (pointer != null) {
if (pointer.getTitle().equals(title)) {
System.out.println(pointer.getBook());
}
pointer = pointer.next;
}
}
break;
case 2:
System.out.println("Please enter ISBN of BOOK");
String ISBN = scan.nextLine();
if (head == null) {
System.out.println("List is EMPTY !");
return;
} else {
System.out.println();
System.out.println("BOOK(S) IN THE SYSTEM ARE: ");
System.out.println();
pointer = head;
while (pointer != null) {
if (pointer.getISBN().equals(ISBN)) {
System.out.println(pointer.getBook());
break;
}
pointer = pointer.next;
}
}
break;
case 3:
System.out.println("Please enter Author(s) of BOOK");
String authors = scan.nextLine();
if (head == null) {
System.out.println("List is EMPTY !");
return;
} else {
System.out.println();
System.out.println("BOOK(S) IN THE SYSTEM ARE: ");
System.out.println();
pointer = head;
while (pointer != null) {
if (pointer.getAuthors().contains(authors)) {
System.out.println(pointer.getBook());
break;
}
pointer = pointer.next;
}
}
break;
default:
System.out.println("PLEASE ENTER VALUE BETWEEN 1 - 5");
}
}
static void updateBook() {
System.out.println();
System.out.println("1. Update by TITLE");
System.out.println("2. Update by ISBN");
System.out.println("3. Update by AUTHOR");
int choice = 0;
choice: try {
choice = Integer.parseInt(scan.nextLine());
} catch (Exception e) {
System.out.println();
System.out.println("PLEASE ENTER VALUE BETWEEN 1 - 3");
break choice;
}
switch (choice) {
case 1:
System.out.println("Please provide the Title of Book you want to update: ");
String another1 = scan.nextLine();
if (head == null) {
System.out.println("No Books to Update");
return;
} else {
Boolean found = false;
pointer = head;
while (!found & pointer != null) {
if (pointer.getTitle().equals(another1)) {
found = true;
System.out.println("Here is the current book:" + pointer.getBook());
System.out.println("Please enter the new Title:");
pointer.setTitle(scan.nextLine());
System.out.println("Please Enter the new ISBN:");
pointer.setISBN(scan.nextLine());
System.out.println("Please Enter the new Author:");
pointer.setAuthors(scan.nextLine());
}
pointer = pointer.next;
}
}
break;
case 2:
System.out.println("Please provide the ISBN of Book you want to update: ");
String ISBN = scan.nextLine();
if (head == null) {
System.out.println("No Books to Update!");
return;
} else {
Boolean found = false;
pointer = head;
while (!found && pointer != null) {
if (pointer.getISBN().equals(ISBN)) {
found = true;
System.out.println("Here is the current book:" + pointer.getBook());
System.out.println("Please enter the new Title:");
pointer.setTitle(scan.nextLine());
System.out.println("Please Enter the new ISBN:");
pointer.setISBN(scan.nextLine());
System.out.println("Please Enter the new Author:");
pointer.setAuthors(scan.nextLine());
}
pointer = pointer.next;
}
}
case 3:
System.out.println("Please enter Author(s) of the Book you want to Update: ");
String upauthor1 = scan.nextLine();
if (head == null) {
System.out.println("List is EMPTY !");
return;
} else {
Boolean found = false;
pointer = head;
while (!found && pointer != null) {
if (pointer.getAuthors().contains(upauthor1)) {
found = true;
System.out.println("Here is the current book:" + pointer.getBook());
System.out.println("Please enter the new Title:");
pointer.setTitle(scan.nextLine());
System.out.println("Please Enter the new ISBN:");
pointer.setISBN(scan.nextLine());
System.out.println("Please Enter the new Author:");
pointer.setAuthors(scan.nextLine());
}
pointer = pointer.next;
}
break;
}
}
}
private static void viewBook() {
Book element = head;
System.out.println();
System.out.println("Printing List");
while (element != null) {
System.out.println(element.getBook());
element = element.next;
}
System.out.println("Book Printing Ended");
System.out.println();
}
private static void deleteBook() {
System.out.println();
System.out.println("1. Delete by Title");
System.out.println("2. Delete by ISBN");
System.out.println("3. Delete by Author(s)");
}
}
</code></pre>
<p>As you can see I have left delete Method blank because I have no idea how to delete a specific book which is inserted in the beginning of compilation.</p>
<p>Here is my Book class</p>
<pre><code>public class Book {
private String authors;
private String ISBN;
private String title;
public Book next;
Book(String title, String ISBN, String authors) {
this.title = title;
this.authors = authors;
this.ISBN = ISBN;
}
public String getAuthors() {
return authors;
}
public void setISBN(String ISBN){
this.ISBN = ISBN;
}
public void setTitle(String title){
this.title = title;
}
public void setAuthors(String authors) {
this.authors = authors;
}
public String getISBN() {
return ISBN;
}
public String getTitle() {
return title;
}
public String getBook() {
return "Book [authors=" + authors + ", ISBN=" + ISBN + ", title="+ title + "]";
}
</code></pre>
<p>}</p>
| 0debug
|
static void blk_mig_cleanup(void)
{
BlkMigDevState *bmds;
BlkMigBlock *blk;
bdrv_drain_all();
unset_dirty_tracking();
blk_mig_lock();
while ((bmds = QSIMPLEQ_FIRST(&block_mig_state.bmds_list)) != NULL) {
QSIMPLEQ_REMOVE_HEAD(&block_mig_state.bmds_list, entry);
bdrv_set_in_use(bmds->bs, 0);
bdrv_unref(bmds->bs);
g_free(bmds->aio_bitmap);
g_free(bmds);
}
while ((blk = QSIMPLEQ_FIRST(&block_mig_state.blk_list)) != NULL) {
QSIMPLEQ_REMOVE_HEAD(&block_mig_state.blk_list, entry);
g_free(blk->buf);
g_free(blk);
}
blk_mig_unlock();
}
| 1threat
|
How to request user input (In-Line) Console Application C# : So getting and checking user input is easy and all, but when working with the C# Console Application how does one request input inline?
<br>EG:<br>
What is your name : (USER WRITES HERE)
Also, since I am on the topic of Console Applications, how do you detect when the user presses any key? The readline function only responds to enter, but say I want to pause until they press any key, how would I go about doing that?
Going to school atm, so I wont be able to check for a few hours at the very least.
| 0debug
|
static void lan9118_writel(void *opaque, hwaddr offset,
uint64_t val, unsigned size)
{
lan9118_state *s = (lan9118_state *)opaque;
offset &= 0xff;
if (offset >= 0x20 && offset < 0x40) {
tx_fifo_push(s, val);
return;
}
switch (offset) {
case CSR_IRQ_CFG:
val &= (IRQ_EN | IRQ_POL | IRQ_TYPE);
s->irq_cfg = (s->irq_cfg & IRQ_INT) | val;
break;
case CSR_INT_STS:
s->int_sts &= ~val;
break;
case CSR_INT_EN:
s->int_en = val & ~RESERVED_INT;
s->int_sts |= val & SW_INT;
break;
case CSR_FIFO_INT:
DPRINTF("FIFO INT levels %08x\n", val);
s->fifo_int = val;
break;
case CSR_RX_CFG:
if (val & 0x8000) {
s->rx_fifo_used = 0;
s->rx_status_fifo_used = 0;
s->rx_packet_size_tail = s->rx_packet_size_head;
s->rx_packet_size[s->rx_packet_size_head] = 0;
}
s->rx_cfg = val & 0xcfff1ff0;
break;
case CSR_TX_CFG:
if (val & 0x8000) {
s->tx_status_fifo_used = 0;
}
if (val & 0x4000) {
s->txp->state = TX_IDLE;
s->txp->fifo_used = 0;
s->txp->cmd_a = 0xffffffff;
}
s->tx_cfg = val & 6;
break;
case CSR_HW_CFG:
if (val & 1) {
lan9118_reset(DEVICE(s));
} else {
s->hw_cfg = (val & 0x003f300) | (s->hw_cfg & 0x4);
}
break;
case CSR_RX_DP_CTRL:
if (val & 0x80000000) {
s->rxp_pad = 0;
s->rxp_offset = 0;
if (s->rxp_size == 0) {
rx_fifo_pop(s);
s->rxp_pad = 0;
s->rxp_offset = 0;
}
s->rx_fifo_head += s->rxp_size;
if (s->rx_fifo_head >= s->rx_fifo_size) {
s->rx_fifo_head -= s->rx_fifo_size;
}
}
break;
case CSR_PMT_CTRL:
if (val & 0x400) {
phy_reset(s);
}
s->pmt_ctrl &= ~0x34e;
s->pmt_ctrl |= (val & 0x34e);
break;
case CSR_GPIO_CFG:
s->gpio_cfg = val & 0x7777071f;
break;
case CSR_GPT_CFG:
if ((s->gpt_cfg ^ val) & GPT_TIMER_EN) {
if (val & GPT_TIMER_EN) {
ptimer_set_count(s->timer, val & 0xffff);
ptimer_run(s->timer, 0);
} else {
ptimer_stop(s->timer);
ptimer_set_count(s->timer, 0xffff);
}
}
s->gpt_cfg = val & (GPT_TIMER_EN | 0xffff);
break;
case CSR_WORD_SWAP:
s->word_swap = val;
break;
case CSR_MAC_CSR_CMD:
s->mac_cmd = val & 0x4000000f;
if (val & 0x80000000) {
if (val & 0x40000000) {
s->mac_data = do_mac_read(s, val & 0xf);
DPRINTF("MAC read %d = 0x%08x\n", val & 0xf, s->mac_data);
} else {
DPRINTF("MAC write %d = 0x%08x\n", val & 0xf, s->mac_data);
do_mac_write(s, val & 0xf, s->mac_data);
}
}
break;
case CSR_MAC_CSR_DATA:
s->mac_data = val;
break;
case CSR_AFC_CFG:
s->afc_cfg = val & 0x00ffffff;
break;
case CSR_E2P_CMD:
lan9118_eeprom_cmd(s, (val >> 28) & 7, val & 0x7f);
break;
case CSR_E2P_DATA:
s->e2p_data = val & 0xff;
break;
default:
hw_error("lan9118_write: Bad reg 0x%x = %x\n", (int)offset, (int)val);
break;
}
lan9118_update(s);
}
| 1threat
|
how can I split the image into 3 parts in the image processing project : [filename pathname]=uigetfile('*.png','Pick the image file');
file=strcat(pathname,filename);
I=imread(file);
figure,imshow(I);
title('Input Image');
im1=I;
su=median(im1);
median=ceil(su);
disp('mean Value');
disp(median)
[row, col]=size(I);
%mr = median(row/2); % median of rows
mc = median(col/3); % median of columns
right = I(1:mr , (mc+1):col);
figure,imshow(right)
% Back_to_original = [top_left,top_right ; bot_left,bot_right];
i expect to split the image into three parts but it is splitted into top right and left and creating mirror image
| 0debug
|
Logical Operator Creation Cause : Almost all programming languages are having the concept of logical operator
I am having a query why logical operators were created.I googled and found its created for condition based operation, but that's a kind of usage i think. I am interested in the answer that what are the challenges people faced without this operator. Please explain with example if possible.
| 0debug
|
Compiler can't deduce the return type? : <p>I am trying to use the <code>decltype</code> keyword on an auto function:</p>
<pre><code>struct Thing {
static auto foo() {
return 12;
}
using type_t =
decltype(foo());
};
</code></pre>
<p>And I get the following error (gcc 7.4):</p>
<pre><code><source>:6:25: error: use of 'static auto Thing::foo()' before deduction of 'auto'
decltype(foo());
^
<source>:6:25: error: use of 'static auto Thing::foo()' before deduction of 'auto'
</code></pre>
<p>Why has the compiler not yet deduced the return type?</p>
| 0debug
|
C# How to extract specific column from 2D array using C# : I have an array and i want to extract specific column from it, let's say the 3rd column only.
**Example:**
> 1 2 3 4
>
> 1 2 3 4
>
> 1 2 3 4
>
> 1 2 3 4
What is want is to extract 3rd column and display only:
> 3
>
> 3
>
> 3
>
> 3
This is my code where i am able to create a dynamic array specified by the user:
int r;
int c;
Console.Write("Enter number of rows: ");
r = (int)Convert.ToInt32(Console.ReadLine());
Console.Write("Enter number of columns: ");
c = (int)Convert.ToInt32(Console.ReadLine());
int[,] matrix = new int[r, c];
/*Insert Values into Main Matrix
--------------------------------------------------------------------------------*/
for (int row = 0; row < r; row++)
{
for (int col = 0; col < c; col++)
{
Console.Write("Enter value for matrix[{0},{1}] = ",row, col);
matrix[row, col] = (int)Convert.ToInt32(Console.ReadLine());
}
}
/*Print and show initial Matrix
--------------------------------------------------------------------------------*/
Console.WriteLine("Your matrix is,");
for (int row = 0; row < r; row++)
{
for (int col = 0; col < c; col++)
{
Console.Write(matrix[row, col] + " ");
}
Console.WriteLine();
}
/*Fixing first 2 columns
--------------------------------------------------------------------------------*/
int startingMatrixCols = 2;
Console.WriteLine("Fixed first 2 columns:");
for (int row = 0; row < r; row++)
{
for (int col = 0; col < startingMatrixCols; col++)
{
Console.Write(matrix[row, col] + " ");
}
Console.WriteLine();
}
| 0debug
|
Printing current time, in different timez ones, in C : I'm trying to print in the console the current time in my local timezone (-0600), then printing the time at the +0100 timezone. Currently I'm using gmtime, and adding 1 to the tm_hour section.
However when using strftime, it still prints the: "... +0000".
How can I print it properly? How can I change my effective time zone, for instance?
| 0debug
|
static inline void mix_dualmono_to_mono(AC3DecodeContext *ctx)
{
int i;
float (*output)[256] = ctx->audio_block.block_output;
for (i = 0; i < 256; i++)
output[1][i] += output[2][i];
memset(output[2], 0, sizeof(output[2]));
}
| 1threat
|
Could not locate Gemfile or .bundle/ directory in Bash—bundle exec jekyll serve : I am working on getting my Jekyll blog configured, and when I ran `bundle exec jekyll serve`, I got the following error:
Could not locate Gemfile or .bundle/ directory
I cannot find the solution to this bug.
| 0debug
|
pp_context *pp_get_context(int width, int height, int cpuCaps){
PPContext *c= av_mallocz(sizeof(PPContext));
int stride= FFALIGN(width, 16);
int qpStride= (width+15)/16 + 2;
c->av_class = &av_codec_context_class;
if(cpuCaps&PP_FORMAT){
c->hChromaSubSample= cpuCaps&0x3;
c->vChromaSubSample= (cpuCaps>>4)&0x3;
}else{
c->hChromaSubSample= 1;
c->vChromaSubSample= 1;
}
if (cpuCaps & PP_CPU_CAPS_AUTO) {
c->cpuCaps = av_get_cpu_flags();
} else {
c->cpuCaps = 0;
if (cpuCaps & PP_CPU_CAPS_MMX) c->cpuCaps |= AV_CPU_FLAG_MMX;
if (cpuCaps & PP_CPU_CAPS_MMX2) c->cpuCaps |= AV_CPU_FLAG_MMXEXT;
if (cpuCaps & PP_CPU_CAPS_3DNOW) c->cpuCaps |= AV_CPU_FLAG_3DNOW;
if (cpuCaps & PP_CPU_CAPS_ALTIVEC) c->cpuCaps |= AV_CPU_FLAG_ALTIVEC;
}
reallocBuffers(c, width, height, stride, qpStride);
c->frameNum=-1;
return c;
}
| 1threat
|
static void disas_xtensa_insn(CPUXtensaState *env, DisasContext *dc)
{
#define HAS_OPTION_BITS(opt) do { \
if (!option_bits_enabled(dc, opt)) { \
qemu_log("Option is not enabled %s:%d\n", \
__FILE__, __LINE__); \
goto invalid_opcode; \
} \
} while (0)
#define HAS_OPTION(opt) HAS_OPTION_BITS(XTENSA_OPTION_BIT(opt))
#define TBD() qemu_log("TBD(pc = %08x): %s:%d\n", dc->pc, __FILE__, __LINE__)
#define RESERVED() do { \
qemu_log("RESERVED(pc = %08x, %02x%02x%02x): %s:%d\n", \
dc->pc, b0, b1, b2, __FILE__, __LINE__); \
goto invalid_opcode; \
} while (0)
#ifdef TARGET_WORDS_BIGENDIAN
#define OP0 (((b0) & 0xf0) >> 4)
#define OP1 (((b2) & 0xf0) >> 4)
#define OP2 ((b2) & 0xf)
#define RRR_R ((b1) & 0xf)
#define RRR_S (((b1) & 0xf0) >> 4)
#define RRR_T ((b0) & 0xf)
#else
#define OP0 (((b0) & 0xf))
#define OP1 (((b2) & 0xf))
#define OP2 (((b2) & 0xf0) >> 4)
#define RRR_R (((b1) & 0xf0) >> 4)
#define RRR_S (((b1) & 0xf))
#define RRR_T (((b0) & 0xf0) >> 4)
#endif
#define RRR_X ((RRR_R & 0x4) >> 2)
#define RRR_Y ((RRR_T & 0x4) >> 2)
#define RRR_W (RRR_R & 0x3)
#define RRRN_R RRR_R
#define RRRN_S RRR_S
#define RRRN_T RRR_T
#define RRI8_R RRR_R
#define RRI8_S RRR_S
#define RRI8_T RRR_T
#define RRI8_IMM8 (b2)
#define RRI8_IMM8_SE ((((b2) & 0x80) ? 0xffffff00 : 0) | RRI8_IMM8)
#ifdef TARGET_WORDS_BIGENDIAN
#define RI16_IMM16 (((b1) << 8) | (b2))
#else
#define RI16_IMM16 (((b2) << 8) | (b1))
#endif
#ifdef TARGET_WORDS_BIGENDIAN
#define CALL_N (((b0) & 0xc) >> 2)
#define CALL_OFFSET ((((b0) & 0x3) << 16) | ((b1) << 8) | (b2))
#else
#define CALL_N (((b0) & 0x30) >> 4)
#define CALL_OFFSET ((((b0) & 0xc0) >> 6) | ((b1) << 2) | ((b2) << 10))
#endif
#define CALL_OFFSET_SE \
(((CALL_OFFSET & 0x20000) ? 0xfffc0000 : 0) | CALL_OFFSET)
#define CALLX_N CALL_N
#ifdef TARGET_WORDS_BIGENDIAN
#define CALLX_M ((b0) & 0x3)
#else
#define CALLX_M (((b0) & 0xc0) >> 6)
#endif
#define CALLX_S RRR_S
#define BRI12_M CALLX_M
#define BRI12_S RRR_S
#ifdef TARGET_WORDS_BIGENDIAN
#define BRI12_IMM12 ((((b1) & 0xf) << 8) | (b2))
#else
#define BRI12_IMM12 ((((b1) & 0xf0) >> 4) | ((b2) << 4))
#endif
#define BRI12_IMM12_SE (((BRI12_IMM12 & 0x800) ? 0xfffff000 : 0) | BRI12_IMM12)
#define BRI8_M BRI12_M
#define BRI8_R RRI8_R
#define BRI8_S RRI8_S
#define BRI8_IMM8 RRI8_IMM8
#define BRI8_IMM8_SE RRI8_IMM8_SE
#define RSR_SR (b1)
uint8_t b0 = cpu_ldub_code(env, dc->pc);
uint8_t b1 = cpu_ldub_code(env, dc->pc + 1);
uint8_t b2 = 0;
static const uint32_t B4CONST[] = {
0xffffffff, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 16, 32, 64, 128, 256
};
static const uint32_t B4CONSTU[] = {
32768, 65536, 2, 3, 4, 5, 6, 7, 8, 10, 12, 16, 32, 64, 128, 256
};
if (OP0 >= 8) {
dc->next_pc = dc->pc + 2;
HAS_OPTION(XTENSA_OPTION_CODE_DENSITY);
} else {
dc->next_pc = dc->pc + 3;
b2 = cpu_ldub_code(env, dc->pc + 2);
}
switch (OP0) {
case 0:
switch (OP1) {
case 0:
switch (OP2) {
case 0:
if ((RRR_R & 0xc) == 0x8) {
HAS_OPTION(XTENSA_OPTION_BOOLEAN);
}
switch (RRR_R) {
case 0:
switch (CALLX_M) {
case 0:
gen_exception_cause(dc, ILLEGAL_INSTRUCTION_CAUSE);
break;
case 1:
RESERVED();
break;
case 2:
switch (CALLX_N) {
case 0:
case 2:
gen_window_check1(dc, CALLX_S);
gen_jump(dc, cpu_R[CALLX_S]);
break;
case 1:
HAS_OPTION(XTENSA_OPTION_WINDOWED_REGISTER);
{
TCGv_i32 tmp = tcg_const_i32(dc->pc);
gen_advance_ccount(dc);
gen_helper_retw(tmp, cpu_env, tmp);
gen_jump(dc, tmp);
tcg_temp_free(tmp);
}
break;
case 3:
RESERVED();
break;
}
break;
case 3:
gen_window_check2(dc, CALLX_S, CALLX_N << 2);
switch (CALLX_N) {
case 0:
{
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_mov_i32(tmp, cpu_R[CALLX_S]);
tcg_gen_movi_i32(cpu_R[0], dc->next_pc);
gen_jump(dc, tmp);
tcg_temp_free(tmp);
}
break;
case 1:
case 2:
case 3:
HAS_OPTION(XTENSA_OPTION_WINDOWED_REGISTER);
{
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_mov_i32(tmp, cpu_R[CALLX_S]);
gen_callw(dc, CALLX_N, tmp);
tcg_temp_free(tmp);
}
break;
}
break;
}
break;
case 1:
HAS_OPTION(XTENSA_OPTION_WINDOWED_REGISTER);
gen_window_check2(dc, RRR_T, RRR_S);
{
TCGv_i32 pc = tcg_const_i32(dc->pc);
gen_advance_ccount(dc);
gen_helper_movsp(cpu_env, pc);
tcg_gen_mov_i32(cpu_R[RRR_T], cpu_R[RRR_S]);
tcg_temp_free(pc);
}
break;
case 2:
switch (RRR_T) {
case 0:
break;
case 1:
break;
case 2:
break;
case 3:
break;
case 8:
HAS_OPTION(XTENSA_OPTION_EXCEPTION);
break;
case 12:
break;
case 13:
break;
case 15:
break;
default:
RESERVED();
break;
}
break;
case 3:
switch (RRR_T) {
case 0:
HAS_OPTION(XTENSA_OPTION_EXCEPTION);
switch (RRR_S) {
case 0:
gen_check_privilege(dc);
tcg_gen_andi_i32(cpu_SR[PS], cpu_SR[PS], ~PS_EXCM);
gen_helper_check_interrupts(cpu_env);
gen_jump(dc, cpu_SR[EPC1]);
break;
case 1:
RESERVED();
break;
case 2:
gen_check_privilege(dc);
gen_jump(dc, cpu_SR[
dc->config->ndepc ? DEPC : EPC1]);
break;
case 4:
case 5:
HAS_OPTION(XTENSA_OPTION_WINDOWED_REGISTER);
gen_check_privilege(dc);
{
TCGv_i32 tmp = tcg_const_i32(1);
tcg_gen_andi_i32(
cpu_SR[PS], cpu_SR[PS], ~PS_EXCM);
tcg_gen_shl_i32(tmp, tmp, cpu_SR[WINDOW_BASE]);
if (RRR_S == 4) {
tcg_gen_andc_i32(cpu_SR[WINDOW_START],
cpu_SR[WINDOW_START], tmp);
} else {
tcg_gen_or_i32(cpu_SR[WINDOW_START],
cpu_SR[WINDOW_START], tmp);
}
gen_helper_restore_owb(cpu_env);
gen_helper_check_interrupts(cpu_env);
gen_jump(dc, cpu_SR[EPC1]);
tcg_temp_free(tmp);
}
break;
default:
RESERVED();
break;
}
break;
case 1:
HAS_OPTION(XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT);
if (RRR_S >= 2 && RRR_S <= dc->config->nlevel) {
gen_check_privilege(dc);
tcg_gen_mov_i32(cpu_SR[PS],
cpu_SR[EPS2 + RRR_S - 2]);
gen_helper_check_interrupts(cpu_env);
gen_jump(dc, cpu_SR[EPC1 + RRR_S - 1]);
} else {
qemu_log("RFI %d is illegal\n", RRR_S);
gen_exception_cause(dc, ILLEGAL_INSTRUCTION_CAUSE);
}
break;
case 2:
TBD();
break;
default:
RESERVED();
break;
}
break;
case 4:
HAS_OPTION(XTENSA_OPTION_DEBUG);
if (dc->debug) {
gen_debug_exception(dc, DEBUGCAUSE_BI);
}
break;
case 5:
HAS_OPTION(XTENSA_OPTION_EXCEPTION);
switch (RRR_S) {
case 0:
gen_exception_cause(dc, SYSCALL_CAUSE);
break;
case 1:
if (semihosting_enabled) {
gen_check_privilege(dc);
gen_helper_simcall(cpu_env);
} else {
qemu_log("SIMCALL but semihosting is disabled\n");
gen_exception_cause(dc, ILLEGAL_INSTRUCTION_CAUSE);
}
break;
default:
RESERVED();
break;
}
break;
case 6:
HAS_OPTION(XTENSA_OPTION_INTERRUPT);
gen_check_privilege(dc);
gen_window_check1(dc, RRR_T);
tcg_gen_mov_i32(cpu_R[RRR_T], cpu_SR[PS]);
tcg_gen_andi_i32(cpu_SR[PS], cpu_SR[PS], ~PS_INTLEVEL);
tcg_gen_ori_i32(cpu_SR[PS], cpu_SR[PS], RRR_S);
gen_helper_check_interrupts(cpu_env);
gen_jumpi_check_loop_end(dc, 0);
break;
case 7:
HAS_OPTION(XTENSA_OPTION_INTERRUPT);
gen_check_privilege(dc);
gen_waiti(dc, RRR_S);
break;
case 8:
case 9:
case 10:
case 11:
HAS_OPTION(XTENSA_OPTION_BOOLEAN);
{
const unsigned shift = (RRR_R & 2) ? 8 : 4;
TCGv_i32 mask = tcg_const_i32(
((1 << shift) - 1) << RRR_S);
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_and_i32(tmp, cpu_SR[BR], mask);
if (RRR_R & 1) {
tcg_gen_addi_i32(tmp, tmp, 1 << RRR_S);
} else {
tcg_gen_add_i32(tmp, tmp, mask);
}
tcg_gen_shri_i32(tmp, tmp, RRR_S + shift);
tcg_gen_deposit_i32(cpu_SR[BR], cpu_SR[BR],
tmp, RRR_T, 1);
tcg_temp_free(mask);
tcg_temp_free(tmp);
}
break;
default:
RESERVED();
break;
}
break;
case 1:
gen_window_check3(dc, RRR_R, RRR_S, RRR_T);
tcg_gen_and_i32(cpu_R[RRR_R], cpu_R[RRR_S], cpu_R[RRR_T]);
break;
case 2:
gen_window_check3(dc, RRR_R, RRR_S, RRR_T);
tcg_gen_or_i32(cpu_R[RRR_R], cpu_R[RRR_S], cpu_R[RRR_T]);
break;
case 3:
gen_window_check3(dc, RRR_R, RRR_S, RRR_T);
tcg_gen_xor_i32(cpu_R[RRR_R], cpu_R[RRR_S], cpu_R[RRR_T]);
break;
case 4:
switch (RRR_R) {
case 0:
gen_window_check1(dc, RRR_S);
gen_right_shift_sar(dc, cpu_R[RRR_S]);
break;
case 1:
gen_window_check1(dc, RRR_S);
gen_left_shift_sar(dc, cpu_R[RRR_S]);
break;
case 2:
gen_window_check1(dc, RRR_S);
{
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_shli_i32(tmp, cpu_R[RRR_S], 3);
gen_right_shift_sar(dc, tmp);
tcg_temp_free(tmp);
}
break;
case 3:
gen_window_check1(dc, RRR_S);
{
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_shli_i32(tmp, cpu_R[RRR_S], 3);
gen_left_shift_sar(dc, tmp);
tcg_temp_free(tmp);
}
break;
case 4:
{
TCGv_i32 tmp = tcg_const_i32(
RRR_S | ((RRR_T & 1) << 4));
gen_right_shift_sar(dc, tmp);
tcg_temp_free(tmp);
}
break;
case 6:
TBD();
break;
case 7:
TBD();
break;
case 8:
HAS_OPTION(XTENSA_OPTION_WINDOWED_REGISTER);
gen_check_privilege(dc);
{
TCGv_i32 tmp = tcg_const_i32(
RRR_T | ((RRR_T & 8) ? 0xfffffff0 : 0));
gen_helper_rotw(cpu_env, tmp);
tcg_temp_free(tmp);
reset_used_window(dc);
}
break;
case 14:
HAS_OPTION(XTENSA_OPTION_MISC_OP_NSA);
gen_window_check2(dc, RRR_S, RRR_T);
gen_helper_nsa(cpu_R[RRR_T], cpu_R[RRR_S]);
break;
case 15:
HAS_OPTION(XTENSA_OPTION_MISC_OP_NSA);
gen_window_check2(dc, RRR_S, RRR_T);
gen_helper_nsau(cpu_R[RRR_T], cpu_R[RRR_S]);
break;
default:
RESERVED();
break;
}
break;
case 5:
HAS_OPTION_BITS(
XTENSA_OPTION_BIT(XTENSA_OPTION_MMU) |
XTENSA_OPTION_BIT(XTENSA_OPTION_REGION_PROTECTION) |
XTENSA_OPTION_BIT(XTENSA_OPTION_REGION_TRANSLATION));
gen_check_privilege(dc);
gen_window_check2(dc, RRR_S, RRR_T);
{
TCGv_i32 dtlb = tcg_const_i32((RRR_R & 8) != 0);
switch (RRR_R & 7) {
case 3:
gen_helper_rtlb0(cpu_R[RRR_T],
cpu_env, cpu_R[RRR_S], dtlb);
break;
case 4:
gen_helper_itlb(cpu_env, cpu_R[RRR_S], dtlb);
gen_jumpi_check_loop_end(dc, -1);
break;
case 5:
tcg_gen_movi_i32(cpu_pc, dc->pc);
gen_helper_ptlb(cpu_R[RRR_T],
cpu_env, cpu_R[RRR_S], dtlb);
break;
case 6:
gen_helper_wtlb(
cpu_env, cpu_R[RRR_T], cpu_R[RRR_S], dtlb);
gen_jumpi_check_loop_end(dc, -1);
break;
case 7:
gen_helper_rtlb1(cpu_R[RRR_T],
cpu_env, cpu_R[RRR_S], dtlb);
break;
default:
tcg_temp_free(dtlb);
RESERVED();
break;
}
tcg_temp_free(dtlb);
}
break;
case 6:
gen_window_check2(dc, RRR_R, RRR_T);
switch (RRR_S) {
case 0:
tcg_gen_neg_i32(cpu_R[RRR_R], cpu_R[RRR_T]);
break;
case 1:
{
int label = gen_new_label();
tcg_gen_mov_i32(cpu_R[RRR_R], cpu_R[RRR_T]);
tcg_gen_brcondi_i32(
TCG_COND_GE, cpu_R[RRR_R], 0, label);
tcg_gen_neg_i32(cpu_R[RRR_R], cpu_R[RRR_T]);
gen_set_label(label);
}
break;
default:
RESERVED();
break;
}
break;
case 7:
RESERVED();
break;
case 8:
gen_window_check3(dc, RRR_R, RRR_S, RRR_T);
tcg_gen_add_i32(cpu_R[RRR_R], cpu_R[RRR_S], cpu_R[RRR_T]);
break;
case 9:
case 10:
case 11:
gen_window_check3(dc, RRR_R, RRR_S, RRR_T);
{
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_shli_i32(tmp, cpu_R[RRR_S], OP2 - 8);
tcg_gen_add_i32(cpu_R[RRR_R], tmp, cpu_R[RRR_T]);
tcg_temp_free(tmp);
}
break;
case 12:
gen_window_check3(dc, RRR_R, RRR_S, RRR_T);
tcg_gen_sub_i32(cpu_R[RRR_R], cpu_R[RRR_S], cpu_R[RRR_T]);
break;
case 13:
case 14:
case 15:
gen_window_check3(dc, RRR_R, RRR_S, RRR_T);
{
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_shli_i32(tmp, cpu_R[RRR_S], OP2 - 12);
tcg_gen_sub_i32(cpu_R[RRR_R], tmp, cpu_R[RRR_T]);
tcg_temp_free(tmp);
}
break;
}
break;
case 1:
switch (OP2) {
case 0:
case 1:
gen_window_check2(dc, RRR_R, RRR_S);
tcg_gen_shli_i32(cpu_R[RRR_R], cpu_R[RRR_S],
32 - (RRR_T | ((OP2 & 1) << 4)));
break;
case 2:
case 3:
gen_window_check2(dc, RRR_R, RRR_T);
tcg_gen_sari_i32(cpu_R[RRR_R], cpu_R[RRR_T],
RRR_S | ((OP2 & 1) << 4));
break;
case 4:
gen_window_check2(dc, RRR_R, RRR_T);
tcg_gen_shri_i32(cpu_R[RRR_R], cpu_R[RRR_T], RRR_S);
break;
case 6:
{
TCGv_i32 tmp = tcg_temp_new_i32();
if (RSR_SR >= 64) {
gen_check_privilege(dc);
}
gen_window_check1(dc, RRR_T);
tcg_gen_mov_i32(tmp, cpu_R[RRR_T]);
gen_rsr(dc, cpu_R[RRR_T], RSR_SR);
gen_wsr(dc, RSR_SR, tmp);
tcg_temp_free(tmp);
if (!sregnames[RSR_SR]) {
TBD();
}
}
break;
#define gen_shift_reg(cmd, reg) do { \
TCGv_i64 tmp = tcg_temp_new_i64(); \
tcg_gen_extu_i32_i64(tmp, reg); \
tcg_gen_##cmd##_i64(v, v, tmp); \
tcg_gen_trunc_i64_i32(cpu_R[RRR_R], v); \
tcg_temp_free_i64(v); \
tcg_temp_free_i64(tmp); \
} while (0)
#define gen_shift(cmd) gen_shift_reg(cmd, cpu_SR[SAR])
case 8:
gen_window_check3(dc, RRR_R, RRR_S, RRR_T);
{
TCGv_i64 v = tcg_temp_new_i64();
tcg_gen_concat_i32_i64(v, cpu_R[RRR_T], cpu_R[RRR_S]);
gen_shift(shr);
}
break;
case 9:
gen_window_check2(dc, RRR_R, RRR_T);
if (dc->sar_5bit) {
tcg_gen_shr_i32(cpu_R[RRR_R], cpu_R[RRR_T], cpu_SR[SAR]);
} else {
TCGv_i64 v = tcg_temp_new_i64();
tcg_gen_extu_i32_i64(v, cpu_R[RRR_T]);
gen_shift(shr);
}
break;
case 10:
gen_window_check2(dc, RRR_R, RRR_S);
if (dc->sar_m32_5bit) {
tcg_gen_shl_i32(cpu_R[RRR_R], cpu_R[RRR_S], dc->sar_m32);
} else {
TCGv_i64 v = tcg_temp_new_i64();
TCGv_i32 s = tcg_const_i32(32);
tcg_gen_sub_i32(s, s, cpu_SR[SAR]);
tcg_gen_andi_i32(s, s, 0x3f);
tcg_gen_extu_i32_i64(v, cpu_R[RRR_S]);
gen_shift_reg(shl, s);
tcg_temp_free(s);
}
break;
case 11:
gen_window_check2(dc, RRR_R, RRR_T);
if (dc->sar_5bit) {
tcg_gen_sar_i32(cpu_R[RRR_R], cpu_R[RRR_T], cpu_SR[SAR]);
} else {
TCGv_i64 v = tcg_temp_new_i64();
tcg_gen_ext_i32_i64(v, cpu_R[RRR_T]);
gen_shift(sar);
}
break;
#undef gen_shift
#undef gen_shift_reg
case 12:
HAS_OPTION(XTENSA_OPTION_16_BIT_IMUL);
gen_window_check3(dc, RRR_R, RRR_S, RRR_T);
{
TCGv_i32 v1 = tcg_temp_new_i32();
TCGv_i32 v2 = tcg_temp_new_i32();
tcg_gen_ext16u_i32(v1, cpu_R[RRR_S]);
tcg_gen_ext16u_i32(v2, cpu_R[RRR_T]);
tcg_gen_mul_i32(cpu_R[RRR_R], v1, v2);
tcg_temp_free(v2);
tcg_temp_free(v1);
}
break;
case 13:
HAS_OPTION(XTENSA_OPTION_16_BIT_IMUL);
gen_window_check3(dc, RRR_R, RRR_S, RRR_T);
{
TCGv_i32 v1 = tcg_temp_new_i32();
TCGv_i32 v2 = tcg_temp_new_i32();
tcg_gen_ext16s_i32(v1, cpu_R[RRR_S]);
tcg_gen_ext16s_i32(v2, cpu_R[RRR_T]);
tcg_gen_mul_i32(cpu_R[RRR_R], v1, v2);
tcg_temp_free(v2);
tcg_temp_free(v1);
}
break;
default:
RESERVED();
break;
}
break;
case 2:
if (OP2 >= 8) {
gen_window_check3(dc, RRR_R, RRR_S, RRR_T);
}
if (OP2 >= 12) {
HAS_OPTION(XTENSA_OPTION_32_BIT_IDIV);
int label = gen_new_label();
tcg_gen_brcondi_i32(TCG_COND_NE, cpu_R[RRR_T], 0, label);
gen_exception_cause(dc, INTEGER_DIVIDE_BY_ZERO_CAUSE);
gen_set_label(label);
}
switch (OP2) {
#define BOOLEAN_LOGIC(fn, r, s, t) \
do { \
HAS_OPTION(XTENSA_OPTION_BOOLEAN); \
TCGv_i32 tmp1 = tcg_temp_new_i32(); \
TCGv_i32 tmp2 = tcg_temp_new_i32(); \
\
tcg_gen_shri_i32(tmp1, cpu_SR[BR], s); \
tcg_gen_shri_i32(tmp2, cpu_SR[BR], t); \
tcg_gen_##fn##_i32(tmp1, tmp1, tmp2); \
tcg_gen_deposit_i32(cpu_SR[BR], cpu_SR[BR], tmp1, r, 1); \
tcg_temp_free(tmp1); \
tcg_temp_free(tmp2); \
} while (0)
case 0:
BOOLEAN_LOGIC(and, RRR_R, RRR_S, RRR_T);
break;
case 1:
BOOLEAN_LOGIC(andc, RRR_R, RRR_S, RRR_T);
break;
case 2:
BOOLEAN_LOGIC(or, RRR_R, RRR_S, RRR_T);
break;
case 3:
BOOLEAN_LOGIC(orc, RRR_R, RRR_S, RRR_T);
break;
case 4:
BOOLEAN_LOGIC(xor, RRR_R, RRR_S, RRR_T);
break;
#undef BOOLEAN_LOGIC
case 8:
HAS_OPTION(XTENSA_OPTION_32_BIT_IMUL);
tcg_gen_mul_i32(cpu_R[RRR_R], cpu_R[RRR_S], cpu_R[RRR_T]);
break;
case 10:
case 11:
HAS_OPTION(XTENSA_OPTION_32_BIT_IMUL_HIGH);
{
TCGv_i64 r = tcg_temp_new_i64();
TCGv_i64 s = tcg_temp_new_i64();
TCGv_i64 t = tcg_temp_new_i64();
if (OP2 == 10) {
tcg_gen_extu_i32_i64(s, cpu_R[RRR_S]);
tcg_gen_extu_i32_i64(t, cpu_R[RRR_T]);
} else {
tcg_gen_ext_i32_i64(s, cpu_R[RRR_S]);
tcg_gen_ext_i32_i64(t, cpu_R[RRR_T]);
}
tcg_gen_mul_i64(r, s, t);
tcg_gen_shri_i64(r, r, 32);
tcg_gen_trunc_i64_i32(cpu_R[RRR_R], r);
tcg_temp_free_i64(r);
tcg_temp_free_i64(s);
tcg_temp_free_i64(t);
}
break;
case 12:
tcg_gen_divu_i32(cpu_R[RRR_R], cpu_R[RRR_S], cpu_R[RRR_T]);
break;
case 13:
case 15:
{
int label1 = gen_new_label();
int label2 = gen_new_label();
tcg_gen_brcondi_i32(TCG_COND_NE, cpu_R[RRR_S], 0x80000000,
label1);
tcg_gen_brcondi_i32(TCG_COND_NE, cpu_R[RRR_T], 0xffffffff,
label1);
tcg_gen_movi_i32(cpu_R[RRR_R],
OP2 == 13 ? 0x80000000 : 0);
tcg_gen_br(label2);
gen_set_label(label1);
if (OP2 == 13) {
tcg_gen_div_i32(cpu_R[RRR_R],
cpu_R[RRR_S], cpu_R[RRR_T]);
} else {
tcg_gen_rem_i32(cpu_R[RRR_R],
cpu_R[RRR_S], cpu_R[RRR_T]);
}
gen_set_label(label2);
}
break;
case 14:
tcg_gen_remu_i32(cpu_R[RRR_R], cpu_R[RRR_S], cpu_R[RRR_T]);
break;
default:
RESERVED();
break;
}
break;
case 3:
switch (OP2) {
case 0:
if (RSR_SR >= 64) {
gen_check_privilege(dc);
}
gen_window_check1(dc, RRR_T);
gen_rsr(dc, cpu_R[RRR_T], RSR_SR);
if (!sregnames[RSR_SR]) {
TBD();
}
break;
case 1:
if (RSR_SR >= 64) {
gen_check_privilege(dc);
}
gen_window_check1(dc, RRR_T);
gen_wsr(dc, RSR_SR, cpu_R[RRR_T]);
if (!sregnames[RSR_SR]) {
TBD();
}
break;
case 2:
HAS_OPTION(XTENSA_OPTION_MISC_OP_SEXT);
gen_window_check2(dc, RRR_R, RRR_S);
{
int shift = 24 - RRR_T;
if (shift == 24) {
tcg_gen_ext8s_i32(cpu_R[RRR_R], cpu_R[RRR_S]);
} else if (shift == 16) {
tcg_gen_ext16s_i32(cpu_R[RRR_R], cpu_R[RRR_S]);
} else {
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_shli_i32(tmp, cpu_R[RRR_S], shift);
tcg_gen_sari_i32(cpu_R[RRR_R], tmp, shift);
tcg_temp_free(tmp);
}
}
break;
case 3:
HAS_OPTION(XTENSA_OPTION_MISC_OP_CLAMPS);
gen_window_check2(dc, RRR_R, RRR_S);
{
TCGv_i32 tmp1 = tcg_temp_new_i32();
TCGv_i32 tmp2 = tcg_temp_new_i32();
int label = gen_new_label();
tcg_gen_sari_i32(tmp1, cpu_R[RRR_S], 24 - RRR_T);
tcg_gen_xor_i32(tmp2, tmp1, cpu_R[RRR_S]);
tcg_gen_andi_i32(tmp2, tmp2, 0xffffffff << (RRR_T + 7));
tcg_gen_mov_i32(cpu_R[RRR_R], cpu_R[RRR_S]);
tcg_gen_brcondi_i32(TCG_COND_EQ, tmp2, 0, label);
tcg_gen_sari_i32(tmp1, cpu_R[RRR_S], 31);
tcg_gen_xori_i32(cpu_R[RRR_R], tmp1,
0xffffffff >> (25 - RRR_T));
gen_set_label(label);
tcg_temp_free(tmp1);
tcg_temp_free(tmp2);
}
break;
case 4:
case 5:
case 6:
case 7:
HAS_OPTION(XTENSA_OPTION_MISC_OP_MINMAX);
gen_window_check3(dc, RRR_R, RRR_S, RRR_T);
{
static const TCGCond cond[] = {
TCG_COND_LE,
TCG_COND_GE,
TCG_COND_LEU,
TCG_COND_GEU
};
int label = gen_new_label();
if (RRR_R != RRR_T) {
tcg_gen_mov_i32(cpu_R[RRR_R], cpu_R[RRR_S]);
tcg_gen_brcond_i32(cond[OP2 - 4],
cpu_R[RRR_S], cpu_R[RRR_T], label);
tcg_gen_mov_i32(cpu_R[RRR_R], cpu_R[RRR_T]);
} else {
tcg_gen_brcond_i32(cond[OP2 - 4],
cpu_R[RRR_T], cpu_R[RRR_S], label);
tcg_gen_mov_i32(cpu_R[RRR_R], cpu_R[RRR_S]);
}
gen_set_label(label);
}
break;
case 8:
case 9:
case 10:
case 11:
gen_window_check3(dc, RRR_R, RRR_S, RRR_T);
{
static const TCGCond cond[] = {
TCG_COND_NE,
TCG_COND_EQ,
TCG_COND_GE,
TCG_COND_LT
};
int label = gen_new_label();
tcg_gen_brcondi_i32(cond[OP2 - 8], cpu_R[RRR_T], 0, label);
tcg_gen_mov_i32(cpu_R[RRR_R], cpu_R[RRR_S]);
gen_set_label(label);
}
break;
case 12:
case 13:
HAS_OPTION(XTENSA_OPTION_BOOLEAN);
gen_window_check2(dc, RRR_R, RRR_S);
{
int label = gen_new_label();
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_andi_i32(tmp, cpu_SR[BR], 1 << RRR_T);
tcg_gen_brcondi_i32(
OP2 & 1 ? TCG_COND_EQ : TCG_COND_NE,
tmp, 0, label);
tcg_gen_mov_i32(cpu_R[RRR_R], cpu_R[RRR_S]);
gen_set_label(label);
tcg_temp_free(tmp);
}
break;
case 14:
gen_window_check1(dc, RRR_R);
{
int st = (RRR_S << 4) + RRR_T;
if (uregnames[st]) {
tcg_gen_mov_i32(cpu_R[RRR_R], cpu_UR[st]);
} else {
qemu_log("RUR %d not implemented, ", st);
TBD();
}
}
break;
case 15:
gen_window_check1(dc, RRR_T);
if (uregnames[RSR_SR]) {
gen_wur(RSR_SR, cpu_R[RRR_T]);
} else {
qemu_log("WUR %d not implemented, ", RSR_SR);
TBD();
}
break;
}
break;
case 4:
case 5:
gen_window_check2(dc, RRR_R, RRR_T);
{
int shiftimm = RRR_S | ((OP1 & 1) << 4);
int maskimm = (1 << (OP2 + 1)) - 1;
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_shri_i32(tmp, cpu_R[RRR_T], shiftimm);
tcg_gen_andi_i32(cpu_R[RRR_R], tmp, maskimm);
tcg_temp_free(tmp);
}
break;
case 6:
RESERVED();
break;
case 7:
RESERVED();
break;
case 8:
switch (OP2) {
case 0:
case 1:
case 4:
case 5:
HAS_OPTION(XTENSA_OPTION_FP_COPROCESSOR);
gen_window_check2(dc, RRR_S, RRR_T);
gen_check_cpenable(dc, 0);
{
TCGv_i32 addr = tcg_temp_new_i32();
tcg_gen_add_i32(addr, cpu_R[RRR_S], cpu_R[RRR_T]);
gen_load_store_alignment(dc, 2, addr, false);
if (OP2 & 0x4) {
tcg_gen_qemu_st32(cpu_FR[RRR_R], addr, dc->cring);
} else {
tcg_gen_qemu_ld32u(cpu_FR[RRR_R], addr, dc->cring);
}
if (OP2 & 0x1) {
tcg_gen_mov_i32(cpu_R[RRR_S], addr);
}
tcg_temp_free(addr);
}
break;
default:
RESERVED();
break;
}
break;
case 9:
gen_window_check2(dc, RRR_S, RRR_T);
switch (OP2) {
case 0:
HAS_OPTION(XTENSA_OPTION_WINDOWED_REGISTER);
gen_check_privilege(dc);
{
TCGv_i32 addr = tcg_temp_new_i32();
tcg_gen_addi_i32(addr, cpu_R[RRR_S],
(0xffffffc0 | (RRR_R << 2)));
tcg_gen_qemu_ld32u(cpu_R[RRR_T], addr, dc->ring);
tcg_temp_free(addr);
}
break;
case 4:
HAS_OPTION(XTENSA_OPTION_WINDOWED_REGISTER);
gen_check_privilege(dc);
{
TCGv_i32 addr = tcg_temp_new_i32();
tcg_gen_addi_i32(addr, cpu_R[RRR_S],
(0xffffffc0 | (RRR_R << 2)));
tcg_gen_qemu_st32(cpu_R[RRR_T], addr, dc->ring);
tcg_temp_free(addr);
}
break;
default:
RESERVED();
break;
}
break;
case 10:
HAS_OPTION(XTENSA_OPTION_FP_COPROCESSOR);
switch (OP2) {
case 0:
gen_check_cpenable(dc, 0);
gen_helper_add_s(cpu_FR[RRR_R], cpu_env,
cpu_FR[RRR_S], cpu_FR[RRR_T]);
break;
case 1:
gen_check_cpenable(dc, 0);
gen_helper_sub_s(cpu_FR[RRR_R], cpu_env,
cpu_FR[RRR_S], cpu_FR[RRR_T]);
break;
case 2:
gen_check_cpenable(dc, 0);
gen_helper_mul_s(cpu_FR[RRR_R], cpu_env,
cpu_FR[RRR_S], cpu_FR[RRR_T]);
break;
case 4:
gen_check_cpenable(dc, 0);
gen_helper_madd_s(cpu_FR[RRR_R], cpu_env,
cpu_FR[RRR_R], cpu_FR[RRR_S], cpu_FR[RRR_T]);
break;
case 5:
gen_check_cpenable(dc, 0);
gen_helper_msub_s(cpu_FR[RRR_R], cpu_env,
cpu_FR[RRR_R], cpu_FR[RRR_S], cpu_FR[RRR_T]);
break;
case 8:
case 9:
case 10:
case 11:
case 14:
gen_window_check1(dc, RRR_R);
gen_check_cpenable(dc, 0);
{
static const unsigned rounding_mode_const[] = {
float_round_nearest_even,
float_round_to_zero,
float_round_down,
float_round_up,
[6] = float_round_to_zero,
};
TCGv_i32 rounding_mode = tcg_const_i32(
rounding_mode_const[OP2 & 7]);
TCGv_i32 scale = tcg_const_i32(RRR_T);
if (OP2 == 14) {
gen_helper_ftoui(cpu_R[RRR_R], cpu_FR[RRR_S],
rounding_mode, scale);
} else {
gen_helper_ftoi(cpu_R[RRR_R], cpu_FR[RRR_S],
rounding_mode, scale);
}
tcg_temp_free(rounding_mode);
tcg_temp_free(scale);
}
break;
case 12:
case 13:
gen_window_check1(dc, RRR_S);
gen_check_cpenable(dc, 0);
{
TCGv_i32 scale = tcg_const_i32(-RRR_T);
if (OP2 == 13) {
gen_helper_uitof(cpu_FR[RRR_R], cpu_env,
cpu_R[RRR_S], scale);
} else {
gen_helper_itof(cpu_FR[RRR_R], cpu_env,
cpu_R[RRR_S], scale);
}
tcg_temp_free(scale);
}
break;
case 15:
switch (RRR_T) {
case 0:
gen_check_cpenable(dc, 0);
tcg_gen_mov_i32(cpu_FR[RRR_R], cpu_FR[RRR_S]);
break;
case 1:
gen_check_cpenable(dc, 0);
gen_helper_abs_s(cpu_FR[RRR_R], cpu_FR[RRR_S]);
break;
case 4:
gen_window_check1(dc, RRR_R);
gen_check_cpenable(dc, 0);
tcg_gen_mov_i32(cpu_R[RRR_R], cpu_FR[RRR_S]);
break;
case 5:
gen_window_check1(dc, RRR_S);
gen_check_cpenable(dc, 0);
tcg_gen_mov_i32(cpu_FR[RRR_R], cpu_R[RRR_S]);
break;
case 6:
gen_check_cpenable(dc, 0);
gen_helper_neg_s(cpu_FR[RRR_R], cpu_FR[RRR_S]);
break;
default:
RESERVED();
break;
}
break;
default:
RESERVED();
break;
}
break;
case 11:
HAS_OPTION(XTENSA_OPTION_FP_COPROCESSOR);
#define gen_compare(rel, br, a, b) \
do { \
TCGv_i32 bit = tcg_const_i32(1 << br); \
\
gen_check_cpenable(dc, 0); \
gen_helper_##rel(cpu_env, bit, cpu_FR[a], cpu_FR[b]); \
tcg_temp_free(bit); \
} while (0)
switch (OP2) {
case 1:
gen_compare(un_s, RRR_R, RRR_S, RRR_T);
break;
case 2:
gen_compare(oeq_s, RRR_R, RRR_S, RRR_T);
break;
case 3:
gen_compare(ueq_s, RRR_R, RRR_S, RRR_T);
break;
case 4:
gen_compare(olt_s, RRR_R, RRR_S, RRR_T);
break;
case 5:
gen_compare(ult_s, RRR_R, RRR_S, RRR_T);
break;
case 6:
gen_compare(ole_s, RRR_R, RRR_S, RRR_T);
break;
case 7:
gen_compare(ule_s, RRR_R, RRR_S, RRR_T);
break;
#undef gen_compare
case 8:
case 9:
case 10:
case 11:
gen_window_check1(dc, RRR_T);
gen_check_cpenable(dc, 0);
{
static const TCGCond cond[] = {
TCG_COND_NE,
TCG_COND_EQ,
TCG_COND_GE,
TCG_COND_LT
};
int label = gen_new_label();
tcg_gen_brcondi_i32(cond[OP2 - 8], cpu_R[RRR_T], 0, label);
tcg_gen_mov_i32(cpu_FR[RRR_R], cpu_FR[RRR_S]);
gen_set_label(label);
}
break;
case 12:
case 13:
HAS_OPTION(XTENSA_OPTION_BOOLEAN);
gen_check_cpenable(dc, 0);
{
int label = gen_new_label();
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_andi_i32(tmp, cpu_SR[BR], 1 << RRR_T);
tcg_gen_brcondi_i32(
OP2 & 1 ? TCG_COND_EQ : TCG_COND_NE,
tmp, 0, label);
tcg_gen_mov_i32(cpu_FR[RRR_R], cpu_FR[RRR_S]);
gen_set_label(label);
tcg_temp_free(tmp);
}
break;
default:
RESERVED();
break;
}
break;
default:
RESERVED();
break;
}
break;
case 1:
gen_window_check1(dc, RRR_T);
{
TCGv_i32 tmp = tcg_const_i32(
((dc->tb->flags & XTENSA_TBFLAG_LITBASE) ?
0 : ((dc->pc + 3) & ~3)) +
(0xfffc0000 | (RI16_IMM16 << 2)));
if (dc->tb->flags & XTENSA_TBFLAG_LITBASE) {
tcg_gen_add_i32(tmp, tmp, dc->litbase);
}
tcg_gen_qemu_ld32u(cpu_R[RRR_T], tmp, dc->cring);
tcg_temp_free(tmp);
}
break;
case 2:
#define gen_load_store(type, shift) do { \
TCGv_i32 addr = tcg_temp_new_i32(); \
gen_window_check2(dc, RRI8_S, RRI8_T); \
tcg_gen_addi_i32(addr, cpu_R[RRI8_S], RRI8_IMM8 << shift); \
if (shift) { \
gen_load_store_alignment(dc, shift, addr, false); \
} \
tcg_gen_qemu_##type(cpu_R[RRI8_T], addr, dc->cring); \
tcg_temp_free(addr); \
} while (0)
switch (RRI8_R) {
case 0:
gen_load_store(ld8u, 0);
break;
case 1:
gen_load_store(ld16u, 1);
break;
case 2:
gen_load_store(ld32u, 2);
break;
case 4:
gen_load_store(st8, 0);
break;
case 5:
gen_load_store(st16, 1);
break;
case 6:
gen_load_store(st32, 2);
break;
case 7:
if (RRI8_T < 8) {
HAS_OPTION(XTENSA_OPTION_DCACHE);
}
switch (RRI8_T) {
case 0:
break;
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
case 6:
break;
case 7:
break;
case 8:
switch (OP1) {
case 0:
HAS_OPTION(XTENSA_OPTION_DCACHE_INDEX_LOCK);
break;
case 2:
HAS_OPTION(XTENSA_OPTION_DCACHE_INDEX_LOCK);
break;
case 3:
HAS_OPTION(XTENSA_OPTION_DCACHE_INDEX_LOCK);
break;
case 4:
HAS_OPTION(XTENSA_OPTION_DCACHE);
break;
case 5:
HAS_OPTION(XTENSA_OPTION_DCACHE);
break;
default:
RESERVED();
break;
}
break;
case 12:
HAS_OPTION(XTENSA_OPTION_ICACHE);
break;
case 13:
switch (OP1) {
case 0:
HAS_OPTION(XTENSA_OPTION_ICACHE_INDEX_LOCK);
break;
case 2:
HAS_OPTION(XTENSA_OPTION_ICACHE_INDEX_LOCK);
break;
case 3:
HAS_OPTION(XTENSA_OPTION_ICACHE_INDEX_LOCK);
break;
default:
RESERVED();
break;
}
break;
case 14:
HAS_OPTION(XTENSA_OPTION_ICACHE);
break;
case 15:
HAS_OPTION(XTENSA_OPTION_ICACHE);
break;
default:
RESERVED();
break;
}
break;
case 9:
gen_load_store(ld16s, 1);
break;
#undef gen_load_store
case 10:
gen_window_check1(dc, RRI8_T);
tcg_gen_movi_i32(cpu_R[RRI8_T],
RRI8_IMM8 | (RRI8_S << 8) |
((RRI8_S & 0x8) ? 0xfffff000 : 0));
break;
#define gen_load_store_no_hw_align(type) do { \
TCGv_i32 addr = tcg_temp_local_new_i32(); \
gen_window_check2(dc, RRI8_S, RRI8_T); \
tcg_gen_addi_i32(addr, cpu_R[RRI8_S], RRI8_IMM8 << 2); \
gen_load_store_alignment(dc, 2, addr, true); \
tcg_gen_qemu_##type(cpu_R[RRI8_T], addr, dc->cring); \
tcg_temp_free(addr); \
} while (0)
case 11:
HAS_OPTION(XTENSA_OPTION_MP_SYNCHRO);
gen_load_store_no_hw_align(ld32u);
break;
case 12:
gen_window_check2(dc, RRI8_S, RRI8_T);
tcg_gen_addi_i32(cpu_R[RRI8_T], cpu_R[RRI8_S], RRI8_IMM8_SE);
break;
case 13:
gen_window_check2(dc, RRI8_S, RRI8_T);
tcg_gen_addi_i32(cpu_R[RRI8_T], cpu_R[RRI8_S], RRI8_IMM8_SE << 8);
break;
case 14:
HAS_OPTION(XTENSA_OPTION_CONDITIONAL_STORE);
gen_window_check2(dc, RRI8_S, RRI8_T);
{
int label = gen_new_label();
TCGv_i32 tmp = tcg_temp_local_new_i32();
TCGv_i32 addr = tcg_temp_local_new_i32();
TCGv_i32 tpc;
tcg_gen_mov_i32(tmp, cpu_R[RRI8_T]);
tcg_gen_addi_i32(addr, cpu_R[RRI8_S], RRI8_IMM8 << 2);
gen_load_store_alignment(dc, 2, addr, true);
gen_advance_ccount(dc);
tpc = tcg_const_i32(dc->pc);
gen_helper_check_atomctl(cpu_env, tpc, addr);
tcg_gen_qemu_ld32u(cpu_R[RRI8_T], addr, dc->cring);
tcg_gen_brcond_i32(TCG_COND_NE, cpu_R[RRI8_T],
cpu_SR[SCOMPARE1], label);
tcg_gen_qemu_st32(tmp, addr, dc->cring);
gen_set_label(label);
tcg_temp_free(tpc);
tcg_temp_free(addr);
tcg_temp_free(tmp);
}
break;
case 15:
HAS_OPTION(XTENSA_OPTION_MP_SYNCHRO);
gen_load_store_no_hw_align(st32);
break;
#undef gen_load_store_no_hw_align
default:
RESERVED();
break;
}
break;
case 3:
switch (RRI8_R) {
case 0:
case 4:
case 8:
case 12:
HAS_OPTION(XTENSA_OPTION_FP_COPROCESSOR);
gen_window_check1(dc, RRI8_S);
gen_check_cpenable(dc, 0);
{
TCGv_i32 addr = tcg_temp_new_i32();
tcg_gen_addi_i32(addr, cpu_R[RRI8_S], RRI8_IMM8 << 2);
gen_load_store_alignment(dc, 2, addr, false);
if (RRI8_R & 0x4) {
tcg_gen_qemu_st32(cpu_FR[RRI8_T], addr, dc->cring);
} else {
tcg_gen_qemu_ld32u(cpu_FR[RRI8_T], addr, dc->cring);
}
if (RRI8_R & 0x8) {
tcg_gen_mov_i32(cpu_R[RRI8_S], addr);
}
tcg_temp_free(addr);
}
break;
default:
RESERVED();
break;
}
break;
case 4:
HAS_OPTION(XTENSA_OPTION_MAC16);
{
enum {
MAC16_UMUL = 0x0,
MAC16_MUL = 0x4,
MAC16_MULA = 0x8,
MAC16_MULS = 0xc,
MAC16_NONE = 0xf,
} op = OP1 & 0xc;
bool is_m1_sr = (OP2 & 0x3) == 2;
bool is_m2_sr = (OP2 & 0xc) == 0;
uint32_t ld_offset = 0;
if (OP2 > 9) {
RESERVED();
}
switch (OP2 & 2) {
case 0:
is_m1_sr = true;
ld_offset = (OP2 & 1) ? -4 : 4;
if (OP2 >= 8) {
if (OP1 == 0) {
op = MAC16_NONE;
} else {
RESERVED();
}
} else if (op != MAC16_MULA) {
RESERVED();
}
break;
case 2:
if (op == MAC16_UMUL && OP2 != 7) {
RESERVED();
}
break;
}
if (op != MAC16_NONE) {
if (!is_m1_sr) {
gen_window_check1(dc, RRR_S);
}
if (!is_m2_sr) {
gen_window_check1(dc, RRR_T);
}
}
{
TCGv_i32 vaddr = tcg_temp_new_i32();
TCGv_i32 mem32 = tcg_temp_new_i32();
if (ld_offset) {
gen_window_check1(dc, RRR_S);
tcg_gen_addi_i32(vaddr, cpu_R[RRR_S], ld_offset);
gen_load_store_alignment(dc, 2, vaddr, false);
tcg_gen_qemu_ld32u(mem32, vaddr, dc->cring);
}
if (op != MAC16_NONE) {
TCGv_i32 m1 = gen_mac16_m(
is_m1_sr ? cpu_SR[MR + RRR_X] : cpu_R[RRR_S],
OP1 & 1, op == MAC16_UMUL);
TCGv_i32 m2 = gen_mac16_m(
is_m2_sr ? cpu_SR[MR + 2 + RRR_Y] : cpu_R[RRR_T],
OP1 & 2, op == MAC16_UMUL);
if (op == MAC16_MUL || op == MAC16_UMUL) {
tcg_gen_mul_i32(cpu_SR[ACCLO], m1, m2);
if (op == MAC16_UMUL) {
tcg_gen_movi_i32(cpu_SR[ACCHI], 0);
} else {
tcg_gen_sari_i32(cpu_SR[ACCHI], cpu_SR[ACCLO], 31);
}
} else {
TCGv_i32 res = tcg_temp_new_i32();
TCGv_i64 res64 = tcg_temp_new_i64();
TCGv_i64 tmp = tcg_temp_new_i64();
tcg_gen_mul_i32(res, m1, m2);
tcg_gen_ext_i32_i64(res64, res);
tcg_gen_concat_i32_i64(tmp,
cpu_SR[ACCLO], cpu_SR[ACCHI]);
if (op == MAC16_MULA) {
tcg_gen_add_i64(tmp, tmp, res64);
} else {
tcg_gen_sub_i64(tmp, tmp, res64);
}
tcg_gen_trunc_i64_i32(cpu_SR[ACCLO], tmp);
tcg_gen_shri_i64(tmp, tmp, 32);
tcg_gen_trunc_i64_i32(cpu_SR[ACCHI], tmp);
tcg_gen_ext8s_i32(cpu_SR[ACCHI], cpu_SR[ACCHI]);
tcg_temp_free(res);
tcg_temp_free_i64(res64);
tcg_temp_free_i64(tmp);
}
tcg_temp_free(m1);
tcg_temp_free(m2);
}
if (ld_offset) {
tcg_gen_mov_i32(cpu_R[RRR_S], vaddr);
tcg_gen_mov_i32(cpu_SR[MR + RRR_W], mem32);
}
tcg_temp_free(vaddr);
tcg_temp_free(mem32);
}
}
break;
case 5:
switch (CALL_N) {
case 0:
tcg_gen_movi_i32(cpu_R[0], dc->next_pc);
gen_jumpi(dc, (dc->pc & ~3) + (CALL_OFFSET_SE << 2) + 4, 0);
break;
case 1:
case 2:
case 3:
HAS_OPTION(XTENSA_OPTION_WINDOWED_REGISTER);
gen_window_check1(dc, CALL_N << 2);
gen_callwi(dc, CALL_N,
(dc->pc & ~3) + (CALL_OFFSET_SE << 2) + 4, 0);
break;
}
break;
case 6:
switch (CALL_N) {
case 0:
gen_jumpi(dc, dc->pc + 4 + CALL_OFFSET_SE, 0);
break;
case 1:
gen_window_check1(dc, BRI12_S);
{
static const TCGCond cond[] = {
TCG_COND_EQ,
TCG_COND_NE,
TCG_COND_LT,
TCG_COND_GE,
};
gen_brcondi(dc, cond[BRI12_M & 3], cpu_R[BRI12_S], 0,
4 + BRI12_IMM12_SE);
}
break;
case 2:
gen_window_check1(dc, BRI8_S);
{
static const TCGCond cond[] = {
TCG_COND_EQ,
TCG_COND_NE,
TCG_COND_LT,
TCG_COND_GE,
};
gen_brcondi(dc, cond[BRI8_M & 3],
cpu_R[BRI8_S], B4CONST[BRI8_R], 4 + BRI8_IMM8_SE);
}
break;
case 3:
switch (BRI8_M) {
case 0:
HAS_OPTION(XTENSA_OPTION_WINDOWED_REGISTER);
{
TCGv_i32 pc = tcg_const_i32(dc->pc);
TCGv_i32 s = tcg_const_i32(BRI12_S);
TCGv_i32 imm = tcg_const_i32(BRI12_IMM12);
gen_advance_ccount(dc);
gen_helper_entry(cpu_env, pc, s, imm);
tcg_temp_free(imm);
tcg_temp_free(s);
tcg_temp_free(pc);
reset_used_window(dc);
}
break;
case 1:
switch (BRI8_R) {
case 0:
case 1:
HAS_OPTION(XTENSA_OPTION_BOOLEAN);
{
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_andi_i32(tmp, cpu_SR[BR], 1 << RRI8_S);
gen_brcondi(dc,
BRI8_R == 1 ? TCG_COND_NE : TCG_COND_EQ,
tmp, 0, 4 + RRI8_IMM8_SE);
tcg_temp_free(tmp);
}
break;
case 8:
case 9:
case 10:
HAS_OPTION(XTENSA_OPTION_LOOP);
gen_window_check1(dc, RRI8_S);
{
uint32_t lend = dc->pc + RRI8_IMM8 + 4;
TCGv_i32 tmp = tcg_const_i32(lend);
tcg_gen_subi_i32(cpu_SR[LCOUNT], cpu_R[RRI8_S], 1);
tcg_gen_movi_i32(cpu_SR[LBEG], dc->next_pc);
gen_helper_wsr_lend(cpu_env, tmp);
tcg_temp_free(tmp);
if (BRI8_R > 8) {
int label = gen_new_label();
tcg_gen_brcondi_i32(
BRI8_R == 9 ? TCG_COND_NE : TCG_COND_GT,
cpu_R[RRI8_S], 0, label);
gen_jumpi(dc, lend, 1);
gen_set_label(label);
}
gen_jumpi(dc, dc->next_pc, 0);
}
break;
default:
RESERVED();
break;
}
break;
case 2:
case 3:
gen_window_check1(dc, BRI8_S);
gen_brcondi(dc, BRI8_M == 2 ? TCG_COND_LTU : TCG_COND_GEU,
cpu_R[BRI8_S], B4CONSTU[BRI8_R], 4 + BRI8_IMM8_SE);
break;
}
break;
}
break;
case 7:
{
TCGCond eq_ne = (RRI8_R & 8) ? TCG_COND_NE : TCG_COND_EQ;
switch (RRI8_R & 7) {
case 0:
gen_window_check2(dc, RRI8_S, RRI8_T);
{
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_and_i32(tmp, cpu_R[RRI8_S], cpu_R[RRI8_T]);
gen_brcondi(dc, eq_ne, tmp, 0, 4 + RRI8_IMM8_SE);
tcg_temp_free(tmp);
}
break;
case 1:
case 2:
case 3:
gen_window_check2(dc, RRI8_S, RRI8_T);
{
static const TCGCond cond[] = {
[1] = TCG_COND_EQ,
[2] = TCG_COND_LT,
[3] = TCG_COND_LTU,
[9] = TCG_COND_NE,
[10] = TCG_COND_GE,
[11] = TCG_COND_GEU,
};
gen_brcond(dc, cond[RRI8_R], cpu_R[RRI8_S], cpu_R[RRI8_T],
4 + RRI8_IMM8_SE);
}
break;
case 4:
gen_window_check2(dc, RRI8_S, RRI8_T);
{
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_and_i32(tmp, cpu_R[RRI8_S], cpu_R[RRI8_T]);
gen_brcond(dc, eq_ne, tmp, cpu_R[RRI8_T],
4 + RRI8_IMM8_SE);
tcg_temp_free(tmp);
}
break;
case 5:
gen_window_check2(dc, RRI8_S, RRI8_T);
{
#ifdef TARGET_WORDS_BIGENDIAN
TCGv_i32 bit = tcg_const_i32(0x80000000);
#else
TCGv_i32 bit = tcg_const_i32(0x00000001);
#endif
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_andi_i32(tmp, cpu_R[RRI8_T], 0x1f);
#ifdef TARGET_WORDS_BIGENDIAN
tcg_gen_shr_i32(bit, bit, tmp);
#else
tcg_gen_shl_i32(bit, bit, tmp);
#endif
tcg_gen_and_i32(tmp, cpu_R[RRI8_S], bit);
gen_brcondi(dc, eq_ne, tmp, 0, 4 + RRI8_IMM8_SE);
tcg_temp_free(tmp);
tcg_temp_free(bit);
}
break;
case 6:
case 7:
gen_window_check1(dc, RRI8_S);
{
TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_andi_i32(tmp, cpu_R[RRI8_S],
#ifdef TARGET_WORDS_BIGENDIAN
0x80000000 >> (((RRI8_R & 1) << 4) | RRI8_T));
#else
0x00000001 << (((RRI8_R & 1) << 4) | RRI8_T));
#endif
gen_brcondi(dc, eq_ne, tmp, 0, 4 + RRI8_IMM8_SE);
tcg_temp_free(tmp);
}
break;
}
}
break;
#define gen_narrow_load_store(type) do { \
TCGv_i32 addr = tcg_temp_new_i32(); \
gen_window_check2(dc, RRRN_S, RRRN_T); \
tcg_gen_addi_i32(addr, cpu_R[RRRN_S], RRRN_R << 2); \
gen_load_store_alignment(dc, 2, addr, false); \
tcg_gen_qemu_##type(cpu_R[RRRN_T], addr, dc->cring); \
tcg_temp_free(addr); \
} while (0)
case 8:
gen_narrow_load_store(ld32u);
break;
case 9:
gen_narrow_load_store(st32);
break;
#undef gen_narrow_load_store
case 10:
gen_window_check3(dc, RRRN_R, RRRN_S, RRRN_T);
tcg_gen_add_i32(cpu_R[RRRN_R], cpu_R[RRRN_S], cpu_R[RRRN_T]);
break;
case 11:
gen_window_check2(dc, RRRN_R, RRRN_S);
tcg_gen_addi_i32(cpu_R[RRRN_R], cpu_R[RRRN_S], RRRN_T ? RRRN_T : -1);
break;
case 12:
gen_window_check1(dc, RRRN_S);
if (RRRN_T < 8) {
tcg_gen_movi_i32(cpu_R[RRRN_S],
RRRN_R | (RRRN_T << 4) |
((RRRN_T & 6) == 6 ? 0xffffff80 : 0));
} else {
TCGCond eq_ne = (RRRN_T & 4) ? TCG_COND_NE : TCG_COND_EQ;
gen_brcondi(dc, eq_ne, cpu_R[RRRN_S], 0,
4 + (RRRN_R | ((RRRN_T & 3) << 4)));
}
break;
case 13:
switch (RRRN_R) {
case 0:
gen_window_check2(dc, RRRN_S, RRRN_T);
tcg_gen_mov_i32(cpu_R[RRRN_T], cpu_R[RRRN_S]);
break;
case 15:
switch (RRRN_T) {
case 0:
gen_jump(dc, cpu_R[0]);
break;
case 1:
HAS_OPTION(XTENSA_OPTION_WINDOWED_REGISTER);
{
TCGv_i32 tmp = tcg_const_i32(dc->pc);
gen_advance_ccount(dc);
gen_helper_retw(tmp, cpu_env, tmp);
gen_jump(dc, tmp);
tcg_temp_free(tmp);
}
break;
case 2:
HAS_OPTION(XTENSA_OPTION_DEBUG);
if (dc->debug) {
gen_debug_exception(dc, DEBUGCAUSE_BN);
}
break;
case 3:
break;
case 6:
gen_exception_cause(dc, ILLEGAL_INSTRUCTION_CAUSE);
break;
default:
RESERVED();
break;
}
break;
default:
RESERVED();
break;
}
break;
default:
RESERVED();
break;
}
if (dc->is_jmp == DISAS_NEXT) {
gen_check_loop_end(dc, 0);
}
dc->pc = dc->next_pc;
return;
invalid_opcode:
qemu_log("INVALID(pc = %08x)\n", dc->pc);
gen_exception_cause(dc, ILLEGAL_INSTRUCTION_CAUSE);
#undef HAS_OPTION
}
| 1threat
|
static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size)
{
GetBitContext gb;
HuffContext h[4];
VLC vlc[4];
int16_t *samples = data;
int val;
int i, res;
int unp_size;
int bits, stereo;
int pred[2] = {0, 0};
unp_size = AV_RL32(buf);
init_get_bits(&gb, buf + 4, (buf_size - 4) * 8);
if(!get_bits1(&gb)){
av_log(avctx, AV_LOG_INFO, "Sound: no data\n");
*data_size = 0;
return 1;
}
stereo = get_bits1(&gb);
bits = get_bits1(&gb);
if ((unp_size << !bits) > *data_size) {
av_log(avctx, AV_LOG_ERROR, "Frame is too large to fit in buffer\n");
return -1;
}
memset(vlc, 0, sizeof(VLC) * 4);
memset(h, 0, sizeof(HuffContext) * 4);
for(i = 0; i < (1 << (bits + stereo)); i++) {
h[i].length = 256;
h[i].maxlength = 0;
h[i].current = 0;
h[i].bits = av_mallocz(256 * 4);
h[i].lengths = av_mallocz(256 * sizeof(int));
h[i].values = av_mallocz(256 * sizeof(int));
skip_bits1(&gb);
smacker_decode_tree(&gb, &h[i], 0, 0);
skip_bits1(&gb);
if(h[i].current > 1) {
res = init_vlc(&vlc[i], SMKTREE_BITS, h[i].length,
h[i].lengths, sizeof(int), sizeof(int),
h[i].bits, sizeof(uint32_t), sizeof(uint32_t), INIT_VLC_LE);
if(res < 0) {
av_log(avctx, AV_LOG_ERROR, "Cannot build VLC table\n");
return -1;
}
}
}
if(bits) {
for(i = stereo; i >= 0; i--)
pred[i] = bswap_16(get_bits(&gb, 16));
for(i = 0; i < stereo; i++)
*samples++ = pred[i];
for(i = 0; i < unp_size / 2; i++) {
if(i & stereo) {
if(vlc[2].table)
res = get_vlc2(&gb, vlc[2].table, SMKTREE_BITS, 3);
else
res = 0;
val = h[2].values[res];
if(vlc[3].table)
res = get_vlc2(&gb, vlc[3].table, SMKTREE_BITS, 3);
else
res = 0;
val |= h[3].values[res] << 8;
pred[1] += (int16_t)val;
*samples++ = pred[1];
} else {
if(vlc[0].table)
res = get_vlc2(&gb, vlc[0].table, SMKTREE_BITS, 3);
else
res = 0;
val = h[0].values[res];
if(vlc[1].table)
res = get_vlc2(&gb, vlc[1].table, SMKTREE_BITS, 3);
else
res = 0;
val |= h[1].values[res] << 8;
pred[0] += val;
*samples++ = pred[0];
}
}
} else {
for(i = stereo; i >= 0; i--)
pred[i] = get_bits(&gb, 8);
for(i = 0; i < stereo; i++)
*samples++ = (pred[i] - 0x80) << 8;
for(i = 0; i < unp_size; i++) {
if(i & stereo){
if(vlc[1].table)
res = get_vlc2(&gb, vlc[1].table, SMKTREE_BITS, 3);
else
res = 0;
pred[1] += (int8_t)h[1].values[res];
*samples++ = (pred[1] - 0x80) << 8;
} else {
if(vlc[0].table)
res = get_vlc2(&gb, vlc[0].table, SMKTREE_BITS, 3);
else
res = 0;
pred[0] += (int8_t)h[0].values[res];
*samples++ = (pred[0] - 0x80) << 8;
}
}
unp_size *= 2;
}
for(i = 0; i < 4; i++) {
if(vlc[i].table)
free_vlc(&vlc[i]);
if(h[i].bits)
av_free(h[i].bits);
if(h[i].lengths)
av_free(h[i].lengths);
if(h[i].values)
av_free(h[i].values);
}
*data_size = unp_size;
return buf_size;
}
| 1threat
|
I need the image aligned to left ie, the bank white space in this https://codepen.io/soorajbala/pen/JLbOgq?editors=1100 : Please check link : I need the image aligned to left ie, to the bank white space
[1]: https://codepen.io/soorajbala/pen/JLbOgq?editors=1100
| 0debug
|
how can i convert binary to string in c : <p>I want to create a function that converts a binary (int type) to string.
for example : if i have this
01001000 01100101 01101100 01101100 01101111 00100000 01010111 01101111 01110010 01101100 01100100</p>
<p>the function should return "Hello World".</p>
| 0debug
|
How generate list of string with Bogus library in C#? : <p>I use <a href="https://github.com/bchavez/Bogus" rel="noreferrer">Bogus</a> library for generate test data.</p>
<p>for example I have a class :</p>
<pre><code>public class Person
{
public int Id {get; set;}
public List<string> Phones {get; set;} // PROBLEM !!!
}
var Ids = 0;
var test = new Faker<Person>()
.RuleFor(p => p.Id, f => Ids ++)
.RuleFor(p => p.Phones , f => /*HOW ?????*/) // How can I return random list of PhoneNumbers ???
</code></pre>
<p>Can anyone guide me How generate list of predefined faker in bogus ?</p>
| 0debug
|
Build versus Runtime Dependencies in Nix : <p>I am just starting to get to grips with Nix, so apologies if I missed the answer to my question in the docs.</p>
<p>I want to use Nix to setup a secure production machine with the minimal set of libraries and executables. I don't want any compilers or other build tools present because these can be security risks. </p>
<p>When I install some packages, it seems that they depend on only the minimum set of runtime dependencies. For example if I install <code>apache-tomcat-8.0.23</code> then I get a Java runtime (JRE) and the pre-built JAR files comprising Tomcat.</p>
<p>On the other hand, some packages seem to include a full build toolchain as dependencies. Taking another Java-based example, when I install <code>spark-1.4.0</code> Nix pulls down the Java development kit (JDK) which includes a compiler, and it also pulls the Maven build tool etc.</p>
<p>So, my questions are as follows:</p>
<ol>
<li>Do Nix packages make any distinction between build and runtime dependencies?</li>
<li>Why do some packages appear to depend on build tools whereas others only need runtime? Is this all down to how the package author wrapped up the application?</li>
<li>If a package contains build dependencies that I don't want, is there anything that I, as the operator, can do about it except design my own alternative packaging for the same application?</li>
</ol>
<p>Many thanks.</p>
| 0debug
|
Is it possible to fill List<Interface> with items from a normal string list in c# : <p>First time dealing with a problem like this and i was wondering if it was even possible before spending a lot of time trying. If it is, would someone please explain/show me how.</p>
<p>Thank you in advance!</p>
| 0debug
|
Server Side Rendering Angular 2 in ASP.NET with Edge.js : <p>I'm exploring the possibility of rendering Angular 2 on the server side using Edge.js in an ASP.NET MVC application.</p>
<p>I'm aware that the Angular Universal Starter Kit has part of this equation: <a href="https://github.com/alexpods/angular2-universal-starter" rel="noreferrer">https://github.com/alexpods/angular2-universal-starter</a></p>
<p>However, it is using a Node.js server. I'd rather not add a Node.js server as an extra web server on top of the existing IIS server. My thought is I can perform the rendering of the Angular on the server side using Edge.js (i.e., to run the necessary JavaScript to generate the markup).</p>
<p>I am very new to Angular 2, so getting an example up and running is non-trivial for me. Based on this closed issue, I'd say there is currently no effort being made to add support for Edge.js (though it was being considered at one point): <a href="https://github.com/angular/universal/issues/40" rel="noreferrer">https://github.com/angular/universal/issues/40</a></p>
<p><strong>Does anybody know if rendering Angular on the server side using Edge.js from an ASP.NET MVC app is possible?</strong></p>
<p>By the way, I'm stuck on .NET 4.5.2 (Umbraco requires it), so I can't move to .NET Core and make use of this: <a href="https://github.com/MarkPieszak/aspnetcore-angular2-universal" rel="noreferrer">https://github.com/MarkPieszak/aspnetcore-angular2-universal</a></p>
| 0debug
|
How do i convert a memory address 0x8134597 to "\x97\x45\x13\x08" : Hi I'm going through the PWK course where this springs up in the notes:
0x08134597 - > \x97\x45\x13\x08
what is the conversion between the two. The left being hex and the right being whatever that is.
| 0debug
|
Changing the image of a button in a different layout - Android Studio : So I'm a bit stumped on this. I have a button in an 'Upgrades' activity that will change the image of an imagebutton in my Main Activity.
How would I go about doing this?
I simply want the image of that button to change/update when the upgrades button is clicked.
**Thanks in advance**
| 0debug
|
How to open a PopupMenuButton? : <p>How do I open a popup menu from a second widget?</p>
<pre><code>final button = new PopupMenuButton(
itemBuilder: (_) => <PopupMenuItem<String>>[
new PopupMenuItem<String>(
child: const Text('Doge'), value: 'Doge'),
new PopupMenuItem<String>(
child: const Text('Lion'), value: 'Lion'),
],
onSelected: _doSomething);
final tile = new ListTile(title: new Text('Doge or lion?'), trailing: button);
</code></pre>
<p>I want to open the <code>button</code>'s menu by tapping on <code>tile</code>.</p>
| 0debug
|
is there something wrong in this code written in java? : the actual answer is supposed to be "stack" and "overflow" in two separate lines for input "stack.overflow".delimiter used is ".".
nothing is shown in the output
Scanner p=new Scanner(System.in);
p.useDelimiter(".");
System.out.println("delimiter is "+ p.delimiter());
\\this above line is producing expected output
while(p.hasNext()){
System.out.println(p.next());
}
for input stack.overflow and delimiter "."
expected output is stack
overflow
| 0debug
|
when we use the pointer in C, what time do we need to use malloc?and why do we need to use malloc? :
[enter image description here][1]
why it's wrong when i define ans in this case
[enter image description here][2]
and when it will not wrong when i puls the malloc
why?
Thans in advance!
[1]: https://i.stack.imgur.com/VB2vH.png
[2]: https://i.stack.imgur.com/r0PWq.png
| 0debug
|
static void spapr_memory_unplug_request(HotplugHandler *hotplug_dev,
DeviceState *dev, Error **errp)
{
sPAPRMachineState *spapr = SPAPR_MACHINE(hotplug_dev);
Error *local_err = NULL;
PCDIMMDevice *dimm = PC_DIMM(dev);
PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm);
MemoryRegion *mr = ddc->get_memory_region(dimm);
uint64_t size = memory_region_size(mr);
uint32_t nr_lmbs = size / SPAPR_MEMORY_BLOCK_SIZE;
uint64_t addr_start, addr;
int i;
sPAPRDRConnector *drc;
addr_start = object_property_get_uint(OBJECT(dimm), PC_DIMM_ADDR_PROP,
&local_err);
if (local_err) {
goto out;
}
spapr_pending_dimm_unplugs_add(spapr, nr_lmbs, dimm);
addr = addr_start;
for (i = 0; i < nr_lmbs; i++) {
drc = spapr_drc_by_id(TYPE_SPAPR_DRC_LMB,
addr / SPAPR_MEMORY_BLOCK_SIZE);
g_assert(drc);
spapr_drc_detach(drc);
addr += SPAPR_MEMORY_BLOCK_SIZE;
}
drc = spapr_drc_by_id(TYPE_SPAPR_DRC_LMB,
addr_start / SPAPR_MEMORY_BLOCK_SIZE);
spapr_hotplug_req_remove_by_count_indexed(SPAPR_DR_CONNECTOR_TYPE_LMB,
nr_lmbs, spapr_drc_index(drc));
out:
error_propagate(errp, local_err);
}
| 1threat
|
static void asf_build_simple_index(AVFormatContext *s, int stream_index)
{
ff_asf_guid g;
ASFContext *asf = s->priv_data;
int64_t current_pos= avio_tell(s->pb);
int i;
avio_seek(s->pb, asf->data_object_offset + asf->data_object_size, SEEK_SET);
ff_get_guid(s->pb, &g);
while (ff_guidcmp(&g, &index_guid)) {
int64_t gsize= avio_rl64(s->pb);
if (gsize < 24 || url_feof(s->pb)) {
avio_seek(s->pb, current_pos, SEEK_SET);
return;
}
avio_skip(s->pb, gsize-24);
ff_get_guid(s->pb, &g);
}
{
int64_t itime, last_pos=-1;
int pct, ict;
int64_t av_unused gsize= avio_rl64(s->pb);
ff_get_guid(s->pb, &g);
itime=avio_rl64(s->pb);
pct=avio_rl32(s->pb);
ict=avio_rl32(s->pb);
av_log(s, AV_LOG_DEBUG, "itime:0x%"PRIx64", pct:%d, ict:%d\n",itime,pct,ict);
for (i=0;i<ict;i++){
int pktnum=avio_rl32(s->pb);
int pktct =avio_rl16(s->pb);
int64_t pos = s->data_offset + s->packet_size*(int64_t)pktnum;
int64_t index_pts= FFMAX(av_rescale(itime, i, 10000) - asf->hdr.preroll, 0);
if(pos != last_pos){
av_log(s, AV_LOG_DEBUG, "pktnum:%d, pktct:%d pts: %"PRId64"\n", pktnum, pktct, index_pts);
av_add_index_entry(s->streams[stream_index], pos, index_pts, s->packet_size, 0, AVINDEX_KEYFRAME);
last_pos=pos;
}
}
asf->index_read= 1;
}
avio_seek(s->pb, current_pos, SEEK_SET);
}
| 1threat
|
QT,QML , Combobox's popup is opened transparent : I Have an combobox(Control 2.0). I write myown combobox like
Rectangle
{
border.width: 1
border.color: "lightsteelblue"
height:dp(40)
width: parent.width
ComboBox {
id:tmCombo
model:combotm.datalist
textRole: "value"
anchors.fill: parent
currentIndex:-1;
contentItem: Text {
leftPadding: 0
rightPadding: tmCombo.indicator.width + tmCombo.spacing
text:tmCombo.currentIndex==-1 ? "":tmCombo.model[tmCombo.currentIndex].value
font: tmCombo.font
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}
onCurrentIndexChanged: {
if(currentIndex!=-1)
{
var sqlid=model[currentIndex].sqlid;
combotm.getsqlid(sqlid,1,Query.SelectSubParam,Query.Subq,"TMC",1);
TaskResult.taskresult.HatBilgisi_TM=sqlid;
tmsCombo.enabled=true;
}
else
tmsCombo.enabled=false;
tmsCombo.currentIndex=-1;
}
}
}
My Problem is , When Combobox first open , half of popup is transparent.Then I close and open combobox again. Everthing is OK. I am working in android platform.
| 0debug
|
Different output on recursive call using static variable : <pre><code>int fun1(int x){
static int n;
n = 0;
if(x > 0){
n++;
return fun1(x-1)+n;
}
return 0;
}
int fun(int x){
static int n = 0;
if(x > 0){
n++;
return fun(x-1)+n;
}
return 0;
}
</code></pre>
<p>Can anyone tell me the difference between fun and fun1 ?
Getting different output!!</p>
| 0debug
|
How to use GraphQL with Retrofit on Android? : <p>I'm new to GraphQL but I have been using Retrofit for a while now and its easy to use and fast. GraphQL is much different than rest apis in terms of how you pass data. There really are not too many tutorials out there on using GraphQL with Android, I was only able to find this video (<a href="https://www.youtube.com/watch?v=P0uJHI7GjIc&t=1s" rel="noreferrer">https://www.youtube.com/watch?v=P0uJHI7GjIc&t=1s</a>) but there is no real code in there. </p>
<p>In my current code for retrofit calls I have an endpoint I set like so:</p>
<pre><code>final RestAdapter restAdapter = new RestAdapter.Builder()
.setEndpoint(endPoint)
.build();
T service = restAdapter.create(clazz);
</code></pre>
<p>Then I call a rest service like this:</p>
<pre><code>@GET("/users/{login}")
Observable<Github> getUser(@Path("login") String login);
</code></pre>
<p>Now with GraphQL you only have a base url and no service path. Also if you are querying like userId=1 then you have to send as Post with Body parameters: </p>
<pre><code>operationName: arbitrary name ,
query: "{users(userid:$userId){username}},
variables: "{"userId":1}"
</code></pre>
<p>I'm just not sure how this translates to Retrofit</p>
| 0debug
|
document.write('<script src="evil.js"></script>');
| 1threat
|
C# Math.Tan error : <p>The following code produces result zero:</p>
<pre><code>double x = 1/2 + Math.Tan(0) + 1/2;
</code></pre>
<p>Or any other code that involves Math.Tan and some other items in the expression. Compiler seems to just calculate the Tan value and ignore the rest of the expression. Why is that?</p>
| 0debug
|
ssize_t nbd_wr_syncv(QIOChannel *ioc,
struct iovec *iov,
size_t niov,
size_t length,
bool do_read,
Error **errp)
{
ssize_t done = 0;
struct iovec *local_iov = g_new(struct iovec, niov);
struct iovec *local_iov_head = local_iov;
unsigned int nlocal_iov = niov;
nlocal_iov = iov_copy(local_iov, nlocal_iov, iov, niov, 0, length);
while (nlocal_iov > 0) {
ssize_t len;
if (do_read) {
len = qio_channel_readv(ioc, local_iov, nlocal_iov, errp);
} else {
len = qio_channel_writev(ioc, local_iov, nlocal_iov, errp);
}
if (len == QIO_CHANNEL_ERR_BLOCK) {
assert(qemu_in_coroutine());
qio_channel_yield(ioc, do_read ? G_IO_IN : G_IO_OUT);
continue;
}
if (len < 0) {
done = -EIO;
goto cleanup;
}
if (do_read && len == 0) {
break;
}
iov_discard_front(&local_iov, &nlocal_iov, len);
done += len;
}
cleanup:
g_free(local_iov_head);
return done;
}
| 1threat
|
Module not found: Error: Can't resolve 'bundle.js' in '/Users/jonathankuhl/Documents/Programming/node js/sandbox/webpack-app' : <p>I am trying to go through a very basic tutorial about Webpack. I cannot get it to compile a very basic single line javascript application. I have installed and uninstalled it multiple times.</p>
<p>It's just a tutorial to learn how to use Webpack. I used <code>npm init</code> to set up the <code>package.json</code> and did nothing else to touch that file. I have a single index.html file and a single app.js file that is suppose to bundle into a bundle.js file.</p>
<p>I enter: <code>webpack app.js bundle.js</code> into the terminal</p>
<p>I keep getting this error:</p>
<pre><code>Jonathans-MBP:webpack-app jonathankuhl$ webpack app.js bundle.js
Hash: 8d502a6e1f30f2ad64ab
Version: webpack 4.1.1
Time: 157ms
Built at: 2018-3-20 12:25:32
1 asset
Entrypoint main = main.js
[0] ./app.js 18 bytes {0} [built]
[1] multi ./app.js bundle.js 40 bytes {0} [built]
WARNING in configuration
The 'mode' option has not been set. Set 'mode' option to 'development' or 'production' to enable defaults for this environment.
ERROR in multi ./app.js bundle.js
Module not found: Error: Can't resolve 'bundle.js' in '/Users/jonathankuhl/Documents/Programming/node js/sandbox/webpack-app'
@ multi ./app.js bundle.js
</code></pre>
<p>Here's the package.json, there's nothing in it that I didn't do outside of <code>npm init</code>:</p>
<pre><code>{
"name": "webpack-app",
"version": "1.0.0",
"description": "testing",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"webpack": "^4.1.1"
}
}
</code></pre>
<p>What am I doing wrong? I'm literally doing exactly what the tutorial is telling me to do, step by step. I don't know much about webpack, thought I should look into it, since I want a job in web development. I don't know what it means by "can't resolve 'bundle.js'. It's as if bundle.js doesn't exist, but it's not supposed to exist, webpack creates it.</p>
<p>I've tried alternatives such as doing <code>npm run build</code> after adding <code>"build":"webpack"</code> to my package.json under <code>"scripts"</code>, and had no luck. That was before I deleted the entire directory and started over. I've installed and uninstalled both webpack and webpack-cli a few times as well.</p>
<p>What am I doing wrong?</p>
<p>Here's the tut, if it matters: <a href="https://www.youtube.com/watch?v=lziuNMk_8eQ" rel="noreferrer">https://www.youtube.com/watch?v=lziuNMk_8eQ</a> It's a little less than a year old, so maybe it's slightly outdated?</p>
| 0debug
|
PHP - Has anyway to encrypt/decrpyt hash in PHP? : <p>I'm interested to encrypt/decrpyt hash in PHP.</p>
<p>But as I know hash can be encoding only with md5, sha1, sha256.</p>
<p>However, is it possible to make encrypt/decrpyt in PHP by another hash like ripemd160, haval256,5 or ripemd256?</p>
<p>Thank</p>
| 0debug
|
How to add documentation to enum associated values in Swift : <p>Is there a way to add descriptions to associated values of enums in Swift 3? I want them to show up in the symbol documentation popup (option+click), like they do for function parameters in Xcode 8.</p>
<p>This is my enum:</p>
<pre><code>enum Result {
/**
Request succeeded.
- Parameters:
- something: Some description.
- otherThing: Other description.
*/
case Success(something: Int, otherThing: Int)
/**
Request failed.
- Parameter error: Error.
*/
case Error(error: Error)
}
</code></pre>
<p>I tried using <code>- Parameters:</code>, but it doesn't work in enums.</p>
| 0debug
|
Vagrant's Ubuntu 16.04 vagrantfile default password : <p>I'm attempting to deploy and run an Ubuntu 16.04 VM via Vagrant 1.9.1.
The Vagrantfile I'm using is from Atlas:</p>
<p><a href="https://atlas.hashicorp.com/ubuntu/boxes/xenial64/" rel="noreferrer">Ubuntu Xenial 16.04 Vagrantfile</a></p>
<p>I'm using Debian Stretch as the host OS. Vagrant was installed via a .deb available from Vagrant's website.</p>
<p>The Vagrantfile does run and deploy correctly. I can ssh into the VM via both my host OS and using 'vagrant ssh'. However, I have one minor blocker when attempting to ssh in from outside.</p>
<p>The default user in this VM is named 'ubuntu', and looks to have a password set. However, I have no idea what the password is at all, and no docs seem to have the information that I'm looking for. Attempting to set a password via 'passwd' within the VM asks for a current password. Anyone see where this is going?</p>
<p>So my big question is this: has anyone else deployed this same Vagrantfile, and if so, does anyone know what the default user's password is?</p>
| 0debug
|
react button onClick redirect page : <p>I am working on web application using React and bootstrap. When it comes to applying button onClick, it takes me hard time to let my page being redirect to another. if after a href , I cannot go the another page. </p>
<p>So would you please tell me is there any need for using react-navigation or other to navigate the page using Button onClick ? </p>
<pre><code>import React, { Component } from 'react';
import { Button, Card, CardBody, CardGroup, Col, Container, Input, InputGroup, InputGroupAddon, InputGroupText, Row, NavLink } from 'reactstrap';
class LoginLayout extends Component {
render() {
return (
<div className="app flex-row align-items-center">
<Container>
...
<Row>
<Col xs="6">
<Button color="primary" className="px-4">
Login
</Button>
</Col>
<Col xs="6" className="text-right">
<Button color="link" className="px-0">Forgot password?</Button>
</Col>
</Row>
...
</Container>
</div>
);
}
}
</code></pre>
| 0debug
|
static int huff_build(VLC *vlc, uint8_t *len)
{
HuffEntry he[256];
uint32_t codes[256];
uint8_t bits[256];
uint8_t syms[256];
uint32_t code;
int i;
for (i = 0; i < 256; i++) {
he[i].sym = 255 - i;
he[i].len = len[i];
if (len[i] == 0)
return AVERROR_INVALIDDATA;
}
AV_QSORT(he, 256, HuffEntry, huff_cmp_len);
code = 1;
for (i = 255; i >= 0; i--) {
codes[i] = code >> (32 - he[i].len);
bits[i] = he[i].len;
syms[i] = he[i].sym;
code += 0x80000000u >> (he[i].len - 1);
}
ff_free_vlc(vlc);
return ff_init_vlc_sparse(vlc, FFMIN(he[255].len, 12), 256,
bits, sizeof(*bits), sizeof(*bits),
codes, sizeof(*codes), sizeof(*codes),
syms, sizeof(*syms), sizeof(*syms), 0);
}
| 1threat
|
asp web api 2.x How to prevent access to Help Page Services : I'm using Help Page to "map" my asp.net web api services:
Install-Package Microsoft.AspNet.WebApi.HelpPage
How can I Prevent from Unauthorized users to access my all web services ?
even using in Web.Config (inside Areas/HelpPage/Views) :
<authorization>
<deny users="*" />
</authorization>
Also Add [Authorize] on the head of the HelpController.CS
Still, anyone can go to my: www.mydomain/help and get the whole list...
Please Any Help !
| 0debug
|
How do I parse an ISO 8601 Timestamp in GoLang? : <p>I know I need to use a time layout in GoLang (as shown here <a href="https://golang.org/src/time/format.go" rel="noreferrer">https://golang.org/src/time/format.go</a>) but I can't find the layout for an ISO 8601 timestamp. </p>
<p>If it helps, I get the timestamp from the Facebook API. Here is an example timestamp: <code>2016-07-25T02:22:33+0000</code></p>
| 0debug
|
static int64_t coroutine_fn raw_co_get_block_status(BlockDriverState *bs,
int64_t sector_num,
int nb_sectors, int *pnum)
{
off_t start, data = 0, hole = 0;
int64_t total_size;
int ret;
ret = fd_open(bs);
if (ret < 0) {
return ret;
}
start = sector_num * BDRV_SECTOR_SIZE;
total_size = bdrv_getlength(bs);
if (total_size < 0) {
return total_size;
} else if (start >= total_size) {
*pnum = 0;
return 0;
} else if (start + nb_sectors * BDRV_SECTOR_SIZE > total_size) {
nb_sectors = DIV_ROUND_UP(total_size - start, BDRV_SECTOR_SIZE);
}
ret = find_allocation(bs, start, &data, &hole);
if (ret == -ENXIO) {
*pnum = nb_sectors;
ret = BDRV_BLOCK_ZERO;
} else if (ret < 0) {
*pnum = nb_sectors;
ret = BDRV_BLOCK_DATA;
} else if (data == start) {
*pnum = MIN(nb_sectors, (hole - start) / BDRV_SECTOR_SIZE);
ret = BDRV_BLOCK_DATA;
} else {
assert(hole == start);
*pnum = MIN(nb_sectors, (data - start) / BDRV_SECTOR_SIZE);
ret = BDRV_BLOCK_ZERO;
}
return ret | BDRV_BLOCK_OFFSET_VALID | start;
}
| 1threat
|
static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
{
UnsharpContext *unsharp = ctx->priv;
int lmsize_x = 5, cmsize_x = 0;
int lmsize_y = 5, cmsize_y = 0;
double lamount = 1.0f, camount = 0.0f;
if (args)
sscanf(args, "%d:%d:%lf:%d:%d:%lf", &lmsize_x, &lmsize_y, &lamount,
&cmsize_x, &cmsize_y, &camount);
if (lmsize_x < 2 || lmsize_y < 2 || cmsize_x < 2 || cmsize_y < 2) {
av_log(ctx, AV_LOG_ERROR,
"Invalid value <2 for lmsize_x:%d or lmsize_y:%d or cmsize_x:%d or cmsize_y:%d\n",
lmsize_x, lmsize_y, cmsize_x, cmsize_y);
return AVERROR(EINVAL);
}
set_filter_param(&unsharp->luma, lmsize_x, lmsize_y, lamount);
set_filter_param(&unsharp->chroma, cmsize_x, cmsize_y, camount);
return 0;
}
| 1threat
|
from copy import deepcopy
def colon_tuplex(tuplex,m,n):
tuplex_colon = deepcopy(tuplex)
tuplex_colon[m].append(n)
return tuplex_colon
| 0debug
|
def find_max(test_list):
res = max(int(j) for i in test_list for j in i)
return (res)
| 0debug
|
yaml syntax error (Ansible playboook) : I'm new to ansible and yaml, so was just practicing to write a playbook that installs apache. but I get the below error :
"
The offending line appears to be:
tasks:
- name: command to install apache
^ here
here is my yaml code :
---
- hosts: all
tasks:
- name: command to install apache
sudo: yes
yum: name=httpd state=latest
service: name=httpd state=running
what could be wrong here ? have been trying for more than 1 hour.please help.
| 0debug
|
TraceEvent *trace_event_iter_next(TraceEventIter *iter)
{
while (iter->event < TRACE_EVENT_COUNT) {
TraceEvent *ev = &(trace_events[iter->event]);
iter->event++;
if (!iter->pattern ||
pattern_glob(iter->pattern,
trace_event_get_name(ev))) {
return ev;
}
}
return NULL;
}
| 1threat
|
What is the difference between the two codes in C++? : <p>I was trying the problem Hash Tables: Ice Cream Parlor on Hackerrank. It is a simple question, but here is the bizzare situation i got to. How does the change of data structure matter?
Case 1:</p>
<pre><code>void whatFlavors(vector<int> cost, int money) {
int ans1,ans2;
vector<int> arr(100,0); //notice this
for(int i=0;i<cost.size();i++){
if(arr[money-cost[i]]!=0){
ans1=i+1;ans2=arr[abs(money-cost[i])];
if(ans1>ans2){
cout<<ans2<<" "<<ans1<<endl;
}else{
cout<<ans2<<" "<<ans1<<endl;
}
break;
}
else{
arr[cost[i]]=i+1;
}
}
}
</code></pre>
<p>And output is:
<a href="https://i.stack.imgur.com/mHqK6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mHqK6.png" alt="enter image description here"></a></p>
<p>Case 2:
code:</p>
<pre><code>void whatFlavors(vector<int> cost, int money) {
int arr[100]={0}; //notice this
int ans1,ans2;
for(int i=0;i<cost.size();i++){
if(arr[money-cost[i]]!=0){
ans1=i+1;ans2=arr[abs(money-cost[i])];
if(ans1>ans2){
cout<<ans2<<" "<<ans1<<endl;
}else{
cout<<ans2<<" "<<ans1<<endl;
}
break;
}
else{
arr[cost[i]]=i+1;
}
}
}
</code></pre>
<p>output:
<a href="https://i.stack.imgur.com/2oeLx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2oeLx.png" alt="enter image description here"></a></p>
| 0debug
|
static int read_huffman_tables(HYuvContext *s, const uint8_t *src, int length)
{
GetBitContext gb;
int i;
init_get_bits(&gb, src, length * 8);
for (i = 0; i < 3; i++) {
if (read_len_table(s->len[i], &gb) < 0)
return -1;
if (ff_huffyuv_generate_bits_table(s->bits[i], s->len[i]) < 0)
return -1;
ff_free_vlc(&s->vlc[i]);
init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1,
s->bits[i], 4, 4, 0);
}
generate_joint_tables(s);
return (get_bits_count(&gb) + 7) / 8;
}
| 1threat
|
static int check_refcounts_l1(BlockDriverState *bs,
BdrvCheckResult *res,
uint16_t *refcount_table,
int64_t refcount_table_size,
int64_t l1_table_offset, int l1_size,
int flags)
{
BDRVQcowState *s = bs->opaque;
uint64_t *l1_table = NULL, l2_offset, l1_size2;
int i, ret;
l1_size2 = l1_size * sizeof(uint64_t);
ret = inc_refcounts(bs, res, refcount_table, refcount_table_size,
l1_table_offset, l1_size2);
if (ret < 0) {
goto fail;
}
if (l1_size2 > 0) {
l1_table = g_try_malloc(l1_size2);
if (l1_table == NULL) {
ret = -ENOMEM;
res->check_errors++;
goto fail;
}
ret = bdrv_pread(bs->file, l1_table_offset, l1_table, l1_size2);
if (ret < 0) {
fprintf(stderr, "ERROR: I/O error in check_refcounts_l1\n");
res->check_errors++;
goto fail;
}
for(i = 0;i < l1_size; i++)
be64_to_cpus(&l1_table[i]);
}
for(i = 0; i < l1_size; i++) {
l2_offset = l1_table[i];
if (l2_offset) {
l2_offset &= L1E_OFFSET_MASK;
ret = inc_refcounts(bs, res, refcount_table, refcount_table_size,
l2_offset, s->cluster_size);
if (ret < 0) {
goto fail;
}
if (offset_into_cluster(s, l2_offset)) {
fprintf(stderr, "ERROR l2_offset=%" PRIx64 ": Table is not "
"cluster aligned; L1 entry corrupted\n", l2_offset);
res->corruptions++;
}
ret = check_refcounts_l2(bs, res, refcount_table,
refcount_table_size, l2_offset, flags);
if (ret < 0) {
goto fail;
}
}
}
g_free(l1_table);
return 0;
fail:
g_free(l1_table);
return ret;
}
| 1threat
|
Show loading screen when navigating between routes in Angular 2 : <p>How do I show a loading screen when I change a route in Angular 2?</p>
| 0debug
|
Error: style attribute '@android:attr/windowExitAnimation' not found : <p>I recently upgraded to the gradle-3.0.0-alpha8 after which some styles are not resolved at compile time.<br>
Develop envirment:</p>
<ul>
<li>IDE: Android studio 3.0 Bate3 </li>
<li>Gradle build tools : 'com.android.tools.build:gradle:3.0.0-beta3' </li>
<li>Gradle :gradle-4.1-all.zip</li>
</ul>
<p>Error info: </p>
<blockquote>
<pre><code> Error:(94, 5) style attribute '@android:attr/windowExitAnimation' not found
Error:(94, 5) style attribute '@android:attr/windowEnterAnimation' not found
</code></pre>
</blockquote>
<p>Setting android.enableAapt2=false in gradle.properties file can solve this isuue.</p>
<p>But, Instant App need android.enableAapt2=true. What would i do?</p>
| 0debug
|
testing that a component method calls another method : <p>Given this simple component :</p>
<pre><code>import { Component} from '@angular/core';
@Component({
selector: 'app-component'
})
export class AppComponent {
foo() {
this.bar();
}
bar() {
console.log('hello');
}
}
</code></pre>
<p>How come the following test won't validate that <code>bar</code> is called when I call <code>foo</code></p>
<pre><code>describe('AppComponent', () => {
let component: AppComponent;
beforeEach(() => {
component = new AppComponent();
}
it('should foobar', () => {
component.foo();
spyOn(component, 'bar');
expect(component.bar).toHaveBeenCalled();
})
}
</code></pre>
<p>I get the failed test :</p>
<pre><code>Expected spy bar to have been called.
</code></pre>
| 0debug
|
static inline int gen_intermediate_code_internal (CPUState *env,
TranslationBlock *tb,
int search_pc)
{
DisasContext ctx, *ctxp = &ctx;
opc_handler_t **table, *handler;
target_ulong pc_start;
uint16_t *gen_opc_end;
int j, lj = -1;
pc_start = tb->pc;
gen_opc_ptr = gen_opc_buf;
gen_opc_end = gen_opc_buf + OPC_MAX_SIZE;
gen_opparam_ptr = gen_opparam_buf;
nb_gen_labels = 0;
ctx.nip = pc_start;
ctx.tb = tb;
ctx.exception = EXCP_NONE;
ctx.spr_cb = env->spr_cb;
#if defined(CONFIG_USER_ONLY)
ctx.mem_idx = msr_le;
#if defined(TARGET_PPC64)
ctx.mem_idx |= msr_sf << 1;
#endif
#else
ctx.supervisor = 1 - msr_pr;
ctx.mem_idx = ((1 - msr_pr) << 1) | msr_le;
#if defined(TARGET_PPC64)
ctx.mem_idx |= msr_sf << 2;
#endif
#endif
#if defined(TARGET_PPC64)
ctx.sf_mode = msr_sf;
#endif
ctx.fpu_enabled = msr_fp;
#if defined(TARGET_PPCEMB)
ctx.spe_enabled = msr_spe;
#endif
ctx.singlestep_enabled = env->singlestep_enabled;
#if defined (DO_SINGLE_STEP) && 0
msr_se = 1;
#endif
while (ctx.exception == EXCP_NONE && gen_opc_ptr < gen_opc_end) {
if (unlikely(env->nb_breakpoints > 0)) {
for (j = 0; j < env->nb_breakpoints; j++) {
if (env->breakpoints[j] == ctx.nip) {
gen_update_nip(&ctx, ctx.nip);
gen_op_debug();
break;
}
}
}
if (unlikely(search_pc)) {
j = gen_opc_ptr - gen_opc_buf;
if (lj < j) {
lj++;
while (lj < j)
gen_opc_instr_start[lj++] = 0;
gen_opc_pc[lj] = ctx.nip;
gen_opc_instr_start[lj] = 1;
}
}
#if defined PPC_DEBUG_DISAS
if (loglevel & CPU_LOG_TB_IN_ASM) {
fprintf(logfile, "----------------\n");
fprintf(logfile, "nip=" ADDRX " super=%d ir=%d\n",
ctx.nip, 1 - msr_pr, msr_ir);
}
#endif
ctx.opcode = ldl_code(ctx.nip);
if (msr_le) {
ctx.opcode = ((ctx.opcode & 0xFF000000) >> 24) |
((ctx.opcode & 0x00FF0000) >> 8) |
((ctx.opcode & 0x0000FF00) << 8) |
((ctx.opcode & 0x000000FF) << 24);
}
#if defined PPC_DEBUG_DISAS
if (loglevel & CPU_LOG_TB_IN_ASM) {
fprintf(logfile, "translate opcode %08x (%02x %02x %02x) (%s)\n",
ctx.opcode, opc1(ctx.opcode), opc2(ctx.opcode),
opc3(ctx.opcode), msr_le ? "little" : "big");
}
#endif
ctx.nip += 4;
table = env->opcodes;
handler = table[opc1(ctx.opcode)];
if (is_indirect_opcode(handler)) {
table = ind_table(handler);
handler = table[opc2(ctx.opcode)];
if (is_indirect_opcode(handler)) {
table = ind_table(handler);
handler = table[opc3(ctx.opcode)];
}
}
if (unlikely(handler->handler == &gen_invalid)) {
if (loglevel != 0) {
fprintf(logfile, "invalid/unsupported opcode: "
"%02x - %02x - %02x (%08x) 0x" ADDRX " %d\n",
opc1(ctx.opcode), opc2(ctx.opcode),
opc3(ctx.opcode), ctx.opcode, ctx.nip - 4, msr_ir);
} else {
printf("invalid/unsupported opcode: "
"%02x - %02x - %02x (%08x) 0x" ADDRX " %d\n",
opc1(ctx.opcode), opc2(ctx.opcode),
opc3(ctx.opcode), ctx.opcode, ctx.nip - 4, msr_ir);
}
} else {
if (unlikely((ctx.opcode & handler->inval) != 0)) {
if (loglevel != 0) {
fprintf(logfile, "invalid bits: %08x for opcode: "
"%02x -%02x - %02x (%08x) 0x" ADDRX "\n",
ctx.opcode & handler->inval, opc1(ctx.opcode),
opc2(ctx.opcode), opc3(ctx.opcode),
ctx.opcode, ctx.nip - 4);
} else {
printf("invalid bits: %08x for opcode: "
"%02x -%02x - %02x (%08x) 0x" ADDRX "\n",
ctx.opcode & handler->inval, opc1(ctx.opcode),
opc2(ctx.opcode), opc3(ctx.opcode),
ctx.opcode, ctx.nip - 4);
}
RET_INVAL(ctxp);
break;
}
}
(*(handler->handler))(&ctx);
#if defined(DO_PPC_STATISTICS)
handler->count++;
#endif
#if 0
if (unlikely((msr_be && ctx.exception == EXCP_BRANCH) ||
(msr_se && (ctx.nip < 0x100 ||
ctx.nip > 0xF00 ||
(ctx.nip & 0xFC) != 0x04) &&
ctx.exception != EXCP_SYSCALL &&
ctx.exception != EXCP_SYSCALL_USER &&
ctx.exception != EXCP_TRAP))) {
RET_EXCP(ctxp, EXCP_TRACE, 0);
}
#endif
if (unlikely(((ctx.nip & (TARGET_PAGE_SIZE - 1)) == 0) ||
(env->singlestep_enabled))) {
break;
}
#if defined (DO_SINGLE_STEP)
break;
#endif
}
if (ctx.exception == EXCP_NONE) {
gen_goto_tb(&ctx, 0, ctx.nip);
} else if (ctx.exception != EXCP_BRANCH) {
gen_op_reset_T0();
gen_op_exit_tb();
}
*gen_opc_ptr = INDEX_op_end;
if (unlikely(search_pc)) {
j = gen_opc_ptr - gen_opc_buf;
lj++;
while (lj <= j)
gen_opc_instr_start[lj++] = 0;
} else {
tb->size = ctx.nip - pc_start;
}
#if defined(DEBUG_DISAS)
if (loglevel & CPU_LOG_TB_CPU) {
fprintf(logfile, "---------------- excp: %04x\n", ctx.exception);
cpu_dump_state(env, logfile, fprintf, 0);
}
if (loglevel & CPU_LOG_TB_IN_ASM) {
int flags;
flags = env->bfd_mach;
flags |= msr_le << 16;
fprintf(logfile, "IN: %s\n", lookup_symbol(pc_start));
target_disas(logfile, pc_start, ctx.nip - pc_start, flags);
fprintf(logfile, "\n");
}
if (loglevel & CPU_LOG_TB_OP) {
fprintf(logfile, "OP:\n");
dump_ops(gen_opc_buf, gen_opparam_buf);
fprintf(logfile, "\n");
}
#endif
return 0;
}
| 1threat
|
static int transcode_init(OutputFile *output_files,
int nb_output_files,
InputFile *input_files,
int nb_input_files)
{
int ret = 0, i, j;
AVFormatContext *os;
AVCodecContext *codec, *icodec;
OutputStream *ost;
InputStream *ist;
char error[1024];
int want_sdp = 1;
for (i = 0; i < nb_input_files; i++) {
InputFile *ifile = &input_files[i];
if (ifile->rate_emu)
for (j = 0; j < ifile->nb_streams; j++)
input_streams[j + ifile->ist_index].start = av_gettime();
}
for(i=0;i<nb_output_files;i++) {
os = output_files[i].ctx;
if (!os->nb_streams && !(os->oformat->flags & AVFMT_NOSTREAMS)) {
av_dump_format(os, i, os->filename, 1);
fprintf(stderr, "Output file #%d does not contain any stream\n", i);
return AVERROR(EINVAL);
}
}
for (i = 0; i < nb_output_streams; i++) {
ost = &output_streams[i];
os = output_files[ost->file_index].ctx;
ist = &input_streams[ost->source_index];
codec = ost->st->codec;
icodec = ist->st->codec;
ost->st->disposition = ist->st->disposition;
codec->bits_per_raw_sample= icodec->bits_per_raw_sample;
codec->chroma_sample_location = icodec->chroma_sample_location;
if (ost->st->stream_copy) {
uint64_t extra_size = (uint64_t)icodec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE;
if (extra_size > INT_MAX) {
return AVERROR(EINVAL);
}
codec->codec_id = icodec->codec_id;
codec->codec_type = icodec->codec_type;
if(!codec->codec_tag){
if( !os->oformat->codec_tag
|| av_codec_get_id (os->oformat->codec_tag, icodec->codec_tag) == codec->codec_id
|| av_codec_get_tag(os->oformat->codec_tag, icodec->codec_id) <= 0)
codec->codec_tag = icodec->codec_tag;
}
codec->bit_rate = icodec->bit_rate;
codec->rc_max_rate = icodec->rc_max_rate;
codec->rc_buffer_size = icodec->rc_buffer_size;
codec->extradata= av_mallocz(extra_size);
if (!codec->extradata) {
return AVERROR(ENOMEM);
}
memcpy(codec->extradata, icodec->extradata, icodec->extradata_size);
codec->extradata_size= icodec->extradata_size;
if(!copy_tb && av_q2d(icodec->time_base)*icodec->ticks_per_frame > av_q2d(ist->st->time_base) && av_q2d(ist->st->time_base) < 1.0/500){
codec->time_base = icodec->time_base;
codec->time_base.num *= icodec->ticks_per_frame;
av_reduce(&codec->time_base.num, &codec->time_base.den,
codec->time_base.num, codec->time_base.den, INT_MAX);
}else
codec->time_base = ist->st->time_base;
switch(codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
if(audio_volume != 256) {
fprintf(stderr,"-acodec copy and -vol are incompatible (frames are not decoded)\n");
exit_program(1);
}
codec->channel_layout = icodec->channel_layout;
codec->sample_rate = icodec->sample_rate;
codec->channels = icodec->channels;
codec->frame_size = icodec->frame_size;
codec->audio_service_type = icodec->audio_service_type;
codec->block_align= icodec->block_align;
if(codec->block_align == 1 && codec->codec_id == CODEC_ID_MP3)
codec->block_align= 0;
if(codec->codec_id == CODEC_ID_AC3)
codec->block_align= 0;
break;
case AVMEDIA_TYPE_VIDEO:
codec->pix_fmt = icodec->pix_fmt;
codec->width = icodec->width;
codec->height = icodec->height;
codec->has_b_frames = icodec->has_b_frames;
if (!codec->sample_aspect_ratio.num) {
codec->sample_aspect_ratio =
ost->st->sample_aspect_ratio =
ist->st->sample_aspect_ratio.num ? ist->st->sample_aspect_ratio :
ist->st->codec->sample_aspect_ratio.num ?
ist->st->codec->sample_aspect_ratio : (AVRational){0, 1};
}
break;
case AVMEDIA_TYPE_SUBTITLE:
codec->width = icodec->width;
codec->height = icodec->height;
break;
case AVMEDIA_TYPE_DATA:
break;
default:
abort();
}
} else {
if (!ost->enc)
ost->enc = avcodec_find_encoder(ost->st->codec->codec_id);
switch(codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
ost->fifo= av_fifo_alloc(1024);
if (!ost->fifo) {
return AVERROR(ENOMEM);
}
ost->reformat_pair = MAKE_SFMT_PAIR(AV_SAMPLE_FMT_NONE,AV_SAMPLE_FMT_NONE);
if (!codec->sample_rate) {
codec->sample_rate = icodec->sample_rate;
if (icodec->lowres)
codec->sample_rate >>= icodec->lowres;
}
choose_sample_rate(ost->st, ost->enc);
codec->time_base = (AVRational){1, codec->sample_rate};
if (codec->sample_fmt == AV_SAMPLE_FMT_NONE)
codec->sample_fmt = icodec->sample_fmt;
choose_sample_fmt(ost->st, ost->enc);
if (!codec->channels)
codec->channels = icodec->channels;
codec->channel_layout = icodec->channel_layout;
if (av_get_channel_layout_nb_channels(codec->channel_layout) != codec->channels)
codec->channel_layout = 0;
ost->audio_resample = codec->sample_rate != icodec->sample_rate || audio_sync_method > 1;
icodec->request_channels = codec->channels;
ist->decoding_needed = 1;
ost->encoding_needed = 1;
ost->resample_sample_fmt = icodec->sample_fmt;
ost->resample_sample_rate = icodec->sample_rate;
ost->resample_channels = icodec->channels;
break;
case AVMEDIA_TYPE_VIDEO:
if (codec->pix_fmt == PIX_FMT_NONE)
codec->pix_fmt = icodec->pix_fmt;
choose_pixel_fmt(ost->st, ost->enc);
if (ost->st->codec->pix_fmt == PIX_FMT_NONE) {
fprintf(stderr, "Video pixel format is unknown, stream cannot be encoded\n");
exit_program(1);
}
if (!codec->width || !codec->height) {
codec->width = icodec->width;
codec->height = icodec->height;
}
ost->video_resample = codec->width != icodec->width ||
codec->height != icodec->height ||
codec->pix_fmt != icodec->pix_fmt;
if (ost->video_resample) {
#if !CONFIG_AVFILTER
avcodec_get_frame_defaults(&ost->pict_tmp);
if(avpicture_alloc((AVPicture*)&ost->pict_tmp, codec->pix_fmt,
codec->width, codec->height)) {
fprintf(stderr, "Cannot allocate temp picture, check pix fmt\n");
exit_program(1);
}
ost->img_resample_ctx = sws_getContext(
icodec->width,
icodec->height,
icodec->pix_fmt,
codec->width,
codec->height,
codec->pix_fmt,
ost->sws_flags, NULL, NULL, NULL);
if (ost->img_resample_ctx == NULL) {
fprintf(stderr, "Cannot get resampling context\n");
exit_program(1);
}
#endif
codec->bits_per_raw_sample= 0;
}
ost->resample_height = icodec->height;
ost->resample_width = icodec->width;
ost->resample_pix_fmt= icodec->pix_fmt;
ost->encoding_needed = 1;
ist->decoding_needed = 1;
if (!ost->frame_rate.num)
ost->frame_rate = ist->st->r_frame_rate.num ? ist->st->r_frame_rate : (AVRational){25,1};
if (ost->enc && ost->enc->supported_framerates && !force_fps) {
int idx = av_find_nearest_q_idx(ost->frame_rate, ost->enc->supported_framerates);
ost->frame_rate = ost->enc->supported_framerates[idx];
}
codec->time_base = (AVRational){ost->frame_rate.den, ost->frame_rate.num};
#if CONFIG_AVFILTER
if (configure_video_filters(ist, ost)) {
fprintf(stderr, "Error opening filters!\n");
exit(1);
}
#endif
break;
case AVMEDIA_TYPE_SUBTITLE:
ost->encoding_needed = 1;
ist->decoding_needed = 1;
break;
default:
abort();
break;
}
if (ost->encoding_needed &&
(codec->flags & (CODEC_FLAG_PASS1 | CODEC_FLAG_PASS2))) {
char logfilename[1024];
FILE *f;
snprintf(logfilename, sizeof(logfilename), "%s-%d.log",
pass_logfilename_prefix ? pass_logfilename_prefix : DEFAULT_PASS_LOGFILENAME_PREFIX,
i);
if (codec->flags & CODEC_FLAG_PASS1) {
f = fopen(logfilename, "wb");
if (!f) {
fprintf(stderr, "Cannot write log file '%s' for pass-1 encoding: %s\n", logfilename, strerror(errno));
exit_program(1);
}
ost->logfile = f;
} else {
char *logbuffer;
size_t logbuffer_size;
if (read_file(logfilename, &logbuffer, &logbuffer_size) < 0) {
fprintf(stderr, "Error reading log file '%s' for pass-2 encoding\n", logfilename);
exit_program(1);
}
codec->stats_in = logbuffer;
}
}
}
if(codec->codec_type == AVMEDIA_TYPE_VIDEO){
int size= codec->width * codec->height;
bit_buffer_size= FFMAX(bit_buffer_size, 6*size + 200);
}
}
if (!bit_buffer)
bit_buffer = av_malloc(bit_buffer_size);
if (!bit_buffer) {
fprintf(stderr, "Cannot allocate %d bytes output buffer\n",
bit_buffer_size);
return AVERROR(ENOMEM);
}
for (i = 0; i < nb_output_streams; i++) {
ost = &output_streams[i];
if (ost->encoding_needed) {
AVCodec *codec = ost->enc;
AVCodecContext *dec = input_streams[ost->source_index].st->codec;
if (!codec) {
snprintf(error, sizeof(error), "Encoder (codec id %d) not found for output stream #%d.%d",
ost->st->codec->codec_id, ost->file_index, ost->index);
ret = AVERROR(EINVAL);
goto dump_format;
}
if (dec->subtitle_header) {
ost->st->codec->subtitle_header = av_malloc(dec->subtitle_header_size);
if (!ost->st->codec->subtitle_header) {
ret = AVERROR(ENOMEM);
goto dump_format;
}
memcpy(ost->st->codec->subtitle_header, dec->subtitle_header, dec->subtitle_header_size);
ost->st->codec->subtitle_header_size = dec->subtitle_header_size;
}
if (avcodec_open2(ost->st->codec, codec, &ost->opts) < 0) {
snprintf(error, sizeof(error), "Error while opening encoder for output stream #%d.%d - maybe incorrect parameters such as bit_rate, rate, width or height",
ost->file_index, ost->index);
ret = AVERROR(EINVAL);
goto dump_format;
}
assert_codec_experimental(ost->st->codec, 1);
assert_avoptions(ost->opts);
if (ost->st->codec->bit_rate && ost->st->codec->bit_rate < 1000)
av_log(NULL, AV_LOG_WARNING, "The bitrate parameter is set too low."
"It takes bits/s as argument, not kbits/s\n");
extra_size += ost->st->codec->extradata_size;
}
}
for (i = 0; i < nb_input_streams; i++)
if ((ret = init_input_stream(i, output_streams, nb_output_streams, error, sizeof(error))) < 0)
goto dump_format;
for (i = 0; i < nb_output_files; i++) {
os = output_files[i].ctx;
if (avformat_write_header(os, &output_files[i].opts) < 0) {
snprintf(error, sizeof(error), "Could not write header for output file #%d (incorrect codec parameters ?)", i);
ret = AVERROR(EINVAL);
goto dump_format;
}
assert_avoptions(output_files[i].opts);
if (strcmp(os->oformat->name, "rtp")) {
want_sdp = 0;
}
}
dump_format:
for(i=0;i<nb_output_files;i++) {
av_dump_format(output_files[i].ctx, i, output_files[i].ctx->filename, 1);
}
if (verbose >= 0) {
fprintf(stderr, "Stream mapping:\n");
for (i = 0; i < nb_output_streams;i ++) {
ost = &output_streams[i];
fprintf(stderr, " Stream #%d.%d -> #%d.%d",
input_streams[ost->source_index].file_index,
input_streams[ost->source_index].st->index,
ost->file_index,
ost->index);
if (ost->sync_ist != &input_streams[ost->source_index])
fprintf(stderr, " [sync #%d.%d]",
ost->sync_ist->file_index,
ost->sync_ist->st->index);
if (ost->st->stream_copy)
fprintf(stderr, " (copy)");
else
fprintf(stderr, " (%s -> %s)", input_streams[ost->source_index].dec ?
input_streams[ost->source_index].dec->name : "?",
ost->enc ? ost->enc->name : "?");
fprintf(stderr, "\n");
}
}
if (ret) {
fprintf(stderr, "%s\n", error);
return ret;
}
if (want_sdp) {
print_sdp(output_files, nb_output_files);
}
return 0;
}
| 1threat
|
static int tcp_read_packet(AVFormatContext *s, RTSPStream **prtsp_st,
uint8_t *buf, int buf_size)
{
RTSPState *rt = s->priv_data;
int id, len, i, ret;
RTSPStream *rtsp_st;
#ifdef DEBUG_RTP_TCP
dprintf(s, "tcp_read_packet:\n");
#endif
redo:
for(;;) {
RTSPMessageHeader reply;
ret = rtsp_read_reply(s, &reply, NULL, 1);
if (ret == -1)
return -1;
if (ret == 1)
break;
if (rt->state != RTSP_STATE_PLAYING)
return 0;
}
ret = url_read_complete(rt->rtsp_hd, buf, 3);
if (ret != 3)
return -1;
id = buf[0];
len = AV_RB16(buf + 1);
#ifdef DEBUG_RTP_TCP
dprintf(s, "id=%d len=%d\n", id, len);
#endif
if (len > buf_size || len < 12)
goto redo;
ret = url_read_complete(rt->rtsp_hd, buf, len);
if (ret != len)
return -1;
if (rt->transport == RTSP_TRANSPORT_RDT &&
ff_rdt_parse_header(buf, len, &id, NULL, NULL, NULL, NULL) < 0)
return -1;
for(i = 0; i < rt->nb_rtsp_streams; i++) {
rtsp_st = rt->rtsp_streams[i];
if (id >= rtsp_st->interleaved_min &&
id <= rtsp_st->interleaved_max)
goto found;
}
goto redo;
found:
*prtsp_st = rtsp_st;
return len;
}
| 1threat
|
static int usb_hid_handle_data(USBDevice *dev, USBPacket *p)
{
USBHIDState *s = (USBHIDState *)dev;
int ret = 0;
switch(p->pid) {
case USB_TOKEN_IN:
if (p->devep == 1) {
int64_t curtime = qemu_get_clock_ns(vm_clock);
if (!s->changed && (!s->idle || s->next_idle_clock - curtime > 0))
return USB_RET_NAK;
usb_hid_set_next_idle(s, curtime);
if (s->kind == USB_MOUSE || s->kind == USB_TABLET) {
ret = usb_pointer_poll(s, p->data, p->len);
}
else if (s->kind == USB_KEYBOARD) {
ret = usb_keyboard_poll(s, p->data, p->len);
}
s->changed = s->n > 0;
} else {
goto fail;
}
break;
case USB_TOKEN_OUT:
default:
fail:
ret = USB_RET_STALL;
break;
}
return ret;
}
| 1threat
|
static void secondary_do_checkpoint(BDRVReplicationState *s, Error **errp)
{
Error *local_err = NULL;
int ret;
if (!s->secondary_disk->bs->job) {
error_setg(errp, "Backup job was cancelled unexpectedly");
backup_do_checkpoint(s->secondary_disk->bs->job, &local_err);
if (local_err) {
error_propagate(errp, local_err);
ret = s->active_disk->bs->drv->bdrv_make_empty(s->active_disk->bs);
if (ret < 0) {
error_setg(errp, "Cannot make active disk empty");
ret = s->hidden_disk->bs->drv->bdrv_make_empty(s->hidden_disk->bs);
if (ret < 0) {
error_setg(errp, "Cannot make hidden disk empty");
| 1threat
|
How to compare two strings and find the percent of similarity? : <p>How to <strong>compare two strings</strong> and print the <em>percentage of similarity</em>. It is easy to find similarities between string but <em>displaying it in percentage is hard.</em>
How to achieve it in <strong>Ruby</strong> ?</p>
| 0debug
|
void x86_cpudef_setup(void)
{
int i, j;
static const char *model_with_versions[] = { "qemu32", "qemu64", "athlon" };
for (i = 0; i < ARRAY_SIZE(builtin_x86_defs); ++i) {
X86CPUDefinition *def = &builtin_x86_defs[i];
for (j = 0; j < ARRAY_SIZE(model_with_versions); j++) {
if (strcmp(model_with_versions[j], def->name) == 0) {
pstrcpy(def->model_id, sizeof(def->model_id),
"QEMU Virtual CPU version ");
pstrcat(def->model_id, sizeof(def->model_id),
qemu_get_version());
break;
}
}
}
}
| 1threat
|
static int decode_packet(AVCodecContext *avctx,
void *data, int *data_size, AVPacket* avpkt)
{
WmallDecodeCtx *s = avctx->priv_data;
GetBitContext* gb = &s->pgb;
const uint8_t* buf = avpkt->data;
int buf_size = avpkt->size;
int num_bits_prev_frame;
int packet_sequence_number;
s->samples = data;
s->samples_end = (float*)((int8_t*)data + *data_size);
*data_size = 0;
if (s->packet_done || s->packet_loss) {
s->packet_done = 0;
if (buf_size < avctx->block_align)
return 0;
s->next_packet_start = buf_size - avctx->block_align;
buf_size = avctx->block_align;
s->buf_bit_size = buf_size << 3;
init_get_bits(gb, buf, s->buf_bit_size);
packet_sequence_number = get_bits(gb, 4);
int seekable_frame_in_packet = get_bits1(gb);
int spliced_packet = get_bits1(gb);
num_bits_prev_frame = get_bits(gb, s->log2_frame_size);
if (!s->packet_loss &&
((s->packet_sequence_number + 1) & 0xF) != packet_sequence_number) {
s->packet_loss = 1;
av_log(avctx, AV_LOG_ERROR, "Packet loss detected! seq %x vs %x\n",
s->packet_sequence_number, packet_sequence_number);
}
s->packet_sequence_number = packet_sequence_number;
if (num_bits_prev_frame > 0) {
int remaining_packet_bits = s->buf_bit_size - get_bits_count(gb);
if (num_bits_prev_frame >= remaining_packet_bits) {
num_bits_prev_frame = remaining_packet_bits;
s->packet_done = 1;
}
save_bits(s, gb, num_bits_prev_frame, 1);
if (!s->packet_loss)
decode_frame(s);
} else if (s->num_saved_bits - s->frame_offset) {
dprintf(avctx, "ignoring %x previously saved bits\n",
s->num_saved_bits - s->frame_offset);
}
if (s->packet_loss) {
s->num_saved_bits = 0;
s->packet_loss = 0;
}
} else {
int frame_size;
s->buf_bit_size = (avpkt->size - s->next_packet_start) << 3;
init_get_bits(gb, avpkt->data, s->buf_bit_size);
skip_bits(gb, s->packet_offset);
if (s->len_prefix && remaining_bits(s, gb) > s->log2_frame_size &&
(frame_size = show_bits(gb, s->log2_frame_size)) &&
frame_size <= remaining_bits(s, gb)) {
save_bits(s, gb, frame_size, 0);
s->packet_done = !decode_frame(s);
} else if (!s->len_prefix
&& s->num_saved_bits > get_bits_count(&s->gb)) {
s->packet_done = !decode_frame(s);
} else {
s->packet_done = 1;
}
}
if (s->packet_done && !s->packet_loss &&
remaining_bits(s, gb) > 0) {
save_bits(s, gb, remaining_bits(s, gb), 0);
}
*data_size = 0;
s->packet_offset = get_bits_count(gb) & 7;
return (s->packet_loss) ? AVERROR_INVALIDDATA : get_bits_count(gb) >> 3;
}
| 1threat
|
wieird beahaviour of String Pointers : code here
#include <stdio.h>
int main()
{
char*m ;
m="srm";
printf("%d",*m);
return 0;
}
the output is 115 can someone explain why it gives 115 as output
| 0debug
|
static int raw_decode(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
int linesize_align = 4;
RawVideoContext *context = avctx->priv_data;
AVFrame *frame = data;
AVPicture *picture = data;
frame->pict_type = avctx->coded_frame->pict_type;
frame->interlaced_frame = avctx->coded_frame->interlaced_frame;
frame->top_field_first = avctx->coded_frame->top_field_first;
frame->reordered_opaque = avctx->reordered_opaque;
frame->pkt_pts = avctx->pkt->pts;
frame->pkt_pos = avctx->pkt->pos;
if(context->tff>=0){
frame->interlaced_frame = 1;
frame->top_field_first = context->tff;
}
if(buf_size < context->length - (avctx->pix_fmt==PIX_FMT_PAL8 ? 256*4 : 0))
return -1;
if (avctx->width <= 0 || avctx->height <= 0) {
av_log(avctx, AV_LOG_ERROR, "w/h is invalid\n");
return AVERROR(EINVAL);
}
if (context->buffer) {
int i;
uint8_t *dst = context->buffer;
buf_size = context->length - 256*4;
if (avctx->bits_per_coded_sample == 4){
for(i=0; 2*i+1 < buf_size && i<avpkt->size; i++){
dst[2*i+0]= buf[i]>>4;
dst[2*i+1]= buf[i]&15;
}
linesize_align = 8;
} else {
for(i=0; 4*i+3 < buf_size && i<avpkt->size; i++){
dst[4*i+0]= buf[i]>>6;
dst[4*i+1]= buf[i]>>4&3;
dst[4*i+2]= buf[i]>>2&3;
dst[4*i+3]= buf[i] &3;
}
linesize_align = 16;
}
buf= dst;
}
if(avctx->codec_tag == MKTAG('A', 'V', '1', 'x') ||
avctx->codec_tag == MKTAG('A', 'V', 'u', 'p'))
buf += buf_size - context->length;
avpicture_fill(picture, buf, avctx->pix_fmt, avctx->width, avctx->height);
if((avctx->pix_fmt==PIX_FMT_PAL8 && buf_size < context->length) ||
(av_pix_fmt_descriptors[avctx->pix_fmt].flags & PIX_FMT_PSEUDOPAL)) {
frame->data[1]= context->palette;
}
if (avctx->pix_fmt == PIX_FMT_PAL8) {
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL);
if (pal) {
memcpy(frame->data[1], pal, AVPALETTE_SIZE);
frame->palette_has_changed = 1;
}
}
if((avctx->pix_fmt==PIX_FMT_BGR24 ||
avctx->pix_fmt==PIX_FMT_GRAY8 ||
avctx->pix_fmt==PIX_FMT_RGB555LE ||
avctx->pix_fmt==PIX_FMT_RGB555BE ||
avctx->pix_fmt==PIX_FMT_RGB565LE ||
avctx->pix_fmt==PIX_FMT_MONOWHITE ||
avctx->pix_fmt==PIX_FMT_PAL8) &&
FFALIGN(frame->linesize[0], linesize_align)*avctx->height <= buf_size)
frame->linesize[0] = FFALIGN(frame->linesize[0], linesize_align);
if(context->flip)
flip(avctx, picture);
if ( avctx->codec_tag == MKTAG('Y', 'V', '1', '2')
|| avctx->codec_tag == MKTAG('Y', 'V', '1', '6')
|| avctx->codec_tag == MKTAG('Y', 'V', '2', '4')
|| avctx->codec_tag == MKTAG('Y', 'V', 'U', '9'))
FFSWAP(uint8_t *, picture->data[1], picture->data[2]);
if(avctx->codec_tag == AV_RL32("yuv2") &&
avctx->pix_fmt == PIX_FMT_YUYV422) {
int x, y;
uint8_t *line = picture->data[0];
for(y = 0; y < avctx->height; y++) {
for(x = 0; x < avctx->width; x++)
line[2*x + 1] ^= 0x80;
line += picture->linesize[0];
}
}
*data_size = sizeof(AVPicture);
return buf_size;
}
| 1threat
|
What codes can I use in order to make music from parse I uploaded play shuffled for an app created by Xcode in swift language? : This is what I have so far...
let query = PFQuery(className: "Genres")
//Find objects in the background
query.findObjectsInBackgroundWithBlock({
//store objects in an array
(objectsArray :[PFObject]?, error: NSError?) -> Void in
let objectIDs = objectsArray
// objects being added to array
for i in 0...objectIDs!.count-1{
// add a new element in the array
self.iDArray.append(objectIDs![i].valueForKey("objectId") as! String)
//store song name in song array
self.NameArray.append(objectIDs![i].valueForKey("SongName")as! String)
self.tableView.reloadData()
NSLog("\(objectIDs)")
}
})
}
func grabSong () {
let songQuery = PFQuery(className: "Genres")
songQuery.getObjectInBackgroundWithId(iDArray[SelectedSongNumber], block: {
(object: PFObject?, error : NSError?) -> Void in
if let audioFile = object?["SongFile"] as? PFFile {
let audioFileUrlString: String = (audioFile.url)!
let audioFileUrl = NSURL(string: audioFileUrlString)!
AudioPlayer = AVPlayer(URL: audioFileUrl)
AudioPlayer.play()
}
})
}
| 0debug
|
Index out of bounds after I've already accessed that index less than 10 lines ago : <p>I'm creating a little text dungeon crawler and each floor of the dungeon is a 2d array of rooms. for some reason when you get to the third floor, after creating the array and making sure all rooms are set to null, when I'm setting up the rooms as soon as I get to floor3[1, 0] it throws an index out of bounds.</p>
<p>Having used break points and looking at the array it clearly has a [1,0] as well as everything else between [0,0] and [9,6]. I run a for loop that accesses that index and sets it to null and tried changing the for loop to instead change all the rooms to test rooms and it had no problem with that. I checked probably a dozen times to ensure that there aren't any typos, or that I'm trying to call the wrong floor or anything simple like that. I also wrote just a simple Console.Writeline(floor[1,0]) test line to make sure that I wasn't just missing a typo, I removed that line and it also occurs on anything past that point. Again the identical method works for floors 1 and 2.</p>
<pre><code>floor3 = new RoomClass[9, 6];
//loop through everything and make sure that it's empty
for (int i = 0; i < 9; i++)
{
for (int j = 0; j < 6; j++)
{
floor3[i, j] = null;
}
}
//create rooms that actually need to exist.
floor3[0, 0] = new RoomClass("test1.", false, 0, 0);
floor3[0, 1] = new RoomClass("test2.", false, 0, 1);
floor3[0, 2] = new RoomClass("test5.", false, 0, 2);
floor3[0, 3] = new RoomClass("test3.", false, 0, 3);
floor3[0, 4] = new RoomClass("test4.", false, 0, 4);
floor3[0, 5] = new RoomClass("test5.", false, 0, 5);
floor3[0, 6] = new RoomClass("test5.", false, 0, 6);
floor3[1, 0] = new RoomClass("test6.", false, 1, 0);
floor3[1, 3] = new RoomClass("test7.", false, 1, 3);
floor3[1, 6] = new RoomClass("test8.", false, 1, 6);
floor3[2, 0] = new RoomClass("test9.", false, 2, 0);
(etc.)
</code></pre>
<p>This should just go through all the important indexes and create a room for each.</p>
| 0debug
|
int coroutine_fn bdrv_co_preadv(BlockDriverState *bs,
int64_t offset, unsigned int bytes, QEMUIOVector *qiov,
BdrvRequestFlags flags)
{
BlockDriver *drv = bs->drv;
BdrvTrackedRequest req;
uint64_t align = bs->request_alignment;
uint8_t *head_buf = NULL;
uint8_t *tail_buf = NULL;
QEMUIOVector local_qiov;
bool use_local_qiov = false;
int ret;
if (!drv) {
return -ENOMEDIUM;
}
ret = bdrv_check_byte_request(bs, offset, bytes);
if (ret < 0) {
return ret;
}
if (bs->copy_on_read && !(flags & BDRV_REQ_NO_SERIALISING)) {
flags |= BDRV_REQ_COPY_ON_READ;
}
if (offset & (align - 1)) {
head_buf = qemu_blockalign(bs, align);
qemu_iovec_init(&local_qiov, qiov->niov + 2);
qemu_iovec_add(&local_qiov, head_buf, offset & (align - 1));
qemu_iovec_concat(&local_qiov, qiov, 0, qiov->size);
use_local_qiov = true;
bytes += offset & (align - 1);
offset = offset & ~(align - 1);
}
if ((offset + bytes) & (align - 1)) {
if (!use_local_qiov) {
qemu_iovec_init(&local_qiov, qiov->niov + 1);
qemu_iovec_concat(&local_qiov, qiov, 0, qiov->size);
use_local_qiov = true;
}
tail_buf = qemu_blockalign(bs, align);
qemu_iovec_add(&local_qiov, tail_buf,
align - ((offset + bytes) & (align - 1)));
bytes = ROUND_UP(bytes, align);
}
tracked_request_begin(&req, bs, offset, bytes, BDRV_TRACKED_READ);
ret = bdrv_aligned_preadv(bs, &req, offset, bytes, align,
use_local_qiov ? &local_qiov : qiov,
flags);
tracked_request_end(&req);
if (use_local_qiov) {
qemu_iovec_destroy(&local_qiov);
qemu_vfree(head_buf);
qemu_vfree(tail_buf);
}
return ret;
}
| 1threat
|
How to resolve java.lang.AssertionError when creating OkHttpClient in mockito? : <p>I'm trying to make some canned network respones. I have the json response for the actual request and I have Retrofit interfaces that serialize responses. I am beyond frustrated trying to set this up. What should I be doing here? It seems my options are, 1) Use a MockWebServer() 2) Use a RequestInterceptor().</p>
<p>While trying to use either 1 or 2, I can't for the life of me instantiate an OkHttpClient() without it failing, basically this puts every thing I try to death immediately. I get an java.lang.AssertionError because OkHttpClient is throwing this when it can't find a TLS algorithm.</p>
<pre><code> if (builder.sslSocketFactory != null || !isTLS) {
this.sslSocketFactory = builder.sslSocketFactory;
} else {
try {
SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(null, null, null);
this.sslSocketFactory = sslContext.getSocketFactory();
} catch (GeneralSecurityException e) {
**throw new AssertionError(); // The system has no TLS. Just give up.**
}
}
</code></pre>
<p>I've tried to keep the "javax.net.ssl" class in the android.jar using unMock, but that didn't resolve the error.</p>
<pre><code>unMock {
// URI to download the android-all.jar from. e.g. https://oss.sonatype.org/content/groups/public/org/robolectric/android-all/
downloadFrom 'https://oss.sonatype.org/content/groups/public/org/robolectric/android-all/4.3_r2-robolectric-0/android-all-4.3_r2-robolectric-0.jar'
keep "android.util.Log"
keep "javax.net.ssl"
}
</code></pre>
<p>So basically, I've come across various examples of how to mock network requests with retrofit 2, but I can't get past this hurdle, and I'm feeling pretty defeated. I haven't seen anyone else with this problem, and I'm baffled as to how everyone is easily instantiating new OkHttpClients in all their tests.</p>
<p>Here are the relevant dependencies I am using.</p>
<pre><code> testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-all:1.10.19'
testCompile 'org.powermock:powermock-mockito-release-full:1.6.4'
testCompile 'org.powermock:powermock-module-junit4:1.6.4'
testCompile 'org.easymock:easymock:3.4'
testCompile 'org.powermock:powermock-api-easymock:1.6.4'
testCompile 'com.squareup.okhttp3:mockwebserver:3.2.0'
compile 'com.squareup.retrofit2:retrofit:2.0.0'
compile 'com.squareup.retrofit2:converter-gson:2.0.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.0.1'
compile 'com.google.code.gson:gson:2.4'
</code></pre>
| 0debug
|
php how to check if date string in between dates : <p>I have date in string. i.e: 18/10/2018</p>
<p>and also date in an object: $pnrProduct['Date'] . i.e 20/10/2018</p>
<p>I would like to check if the second date is bigger then the first one (in this case it is bigger)</p>
<p>how can i do that?</p>
| 0debug
|
void *qemu_ram_ptr_length(target_phys_addr_t addr, target_phys_addr_t *size)
{
if (xen_enabled()) {
return xen_map_cache(addr, *size, 1);
} else {
RAMBlock *block;
QLIST_FOREACH(block, &ram_list.blocks, next) {
if (addr - block->offset < block->length) {
if (addr - block->offset + *size > block->length)
*size = block->length - addr + block->offset;
return block->host + (addr - block->offset);
}
}
fprintf(stderr, "Bad ram offset %" PRIx64 "\n", (uint64_t)addr);
abort();
*size = 0;
return NULL;
}
}
| 1threat
|
angularjs replace * for space : i'm triyng to replace * for a space. I got un loop of informations look like this : "FC Girondins de Bordeaux*null*null*OSC Lille" dans I would like to change the * for a simple space. I tried to split the informations but that didn't work. The loop of informations are stored in a localstorage.
| 0debug
|
SQL update using range in another table : I Have two table
**T1**
object Value Calculated_Name
AA 10
BB 100
CC 150
**T2**
R1 R2 Name
1 15 Z
16 130 w
I Want UPDATE T1.Calculated_Name with T2.name like this
**T1**
object Value Calculated_Name
AA 10 Z
BB 100 W
CC 150 Null
How I can do this
PS: I have to run the command on SQL2000 or higher
| 0debug
|
Empty atom in Ecto changeset : <p>Why in an Ecto <code>changeset</code> method do you set the params to the default <code>:empty</code> atom? e.g.</p>
<pre><code>def changeset(user, params \\ :empty) do
...
</code></pre>
<p>Does this allow you to call the changeset method with nil for params?</p>
| 0debug
|
syntax error near unexpected token error : <p>Below is my .vimrc file </p>
<pre><code>set nocompatible
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'tomlion/vim-solidity'
Plugin 'othreaa/yajs.vim'
call vundle#end()
filetype plugin indent on
set autoindent
set wrap
set nobackup
set ruler
syntax on
set number
set tabstop=4
colo desert
syntax on
</code></pre>
<p>when I type 'source .vimrc' to activate the configuration file, i got the following error message</p>
<pre><code>-bash: .vimrc: line 6: syntax error near unexpected
token `('
-bash: .vimrc: line 6: `call vundle#begin()'
</code></pre>
<p>I cannot see what is wrong. Can I help?</p>
| 0debug
|
meaning of a struct within a struct in c : <p>Can someone explain what we mean when we do, like what does struct Node* next do. does it create a pointer of type struct? any help and resources about structures in c would be helpful</p>
<pre><code>struct Node {
int dest;
struct Node* next;
};
</code></pre>
| 0debug
|
Haskell couldn't match 't0 ->t' with actual type '[Integer]' : <p>I am learning Haskell and after grasping some of the basics I decided to solve some easy problems in HackerRank. But I soon found myself stuck.</p>
<p>Problem 7 in Functional Problems is called "Array of N elements"</p>
<p>We are supposed to return any array of n elements for a given n. This would have fairly simple if n was an Int but it's read as <code>IO Int</code>. And I haven't really grasped the concept of monads. I hoogled for functions with type signature <code>IO Int -> Int</code> and found unsafePerform IO but it threw this:</p>
<pre><code>Couldn't match expected type ‘t0 -> t’
with actual type ‘[Integer]’
</code></pre>
<p>I dont't quite understand what types t0 and t are.</p>
<p>Any help is appreciated.</p>
<p>Link: <a href="https://www.hackerrank.com/challenges/fp-array-of-n-elements/problem" rel="nofollow noreferrer">https://www.hackerrank.com/challenges/fp-array-of-n-elements/problem</a></p>
| 0debug
|
a href can't return through ajax, echo whole code : Just a simple problem, I have used ajax to alert data which is echoed in php page. It is working fine except href link. a href link can't return, it returns whole code. For example, this is ajax code.
**form.html**
$("#ceb").submit(function(event){
event.preventDefault();
var formData = new FormData($(this)[0]);
$.ajax({
url: 'post.php',
type: 'POST',
data: formData,
async: false,
cache: false,
contentType: false,
processData: false,
success: function(returndata){
alert(returndata);
}
});
return false;
});
And this is php page **post.php**
echo "Thanks!, Please visit <a href='next.php'>this</a> page";
In alert window, it **displays whole code `<a href='next.php'>this</a>`** instead of **link**. I have tried assigning href link in php variable, but it doesn't work.
| 0debug
|
how connect 2 sql server table with a query and use data dynamically : i have two table in sql server
one is member table and other one is friend table
1- in member table we have information of members, like username password etc
2-in friend table, we have userID and FriendID , so we can know each user how many friend have
so with entity framework in asp.net
how i can write a query that i get friends name and ID of one member?
[tables look like this][1]
[an example of friend table, you can see user with ID =1 have few friend][2]
[1]: https://i.stack.imgur.com/L7h57.png
[2]: https://i.stack.imgur.com/aG5s2.png
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.