static void initSharedMemory(){ if (isSharedMemoryInited) return; ///// Critical section // Try to lock //while( __sync_fetch_and_add(&sharedMemoryInitSpinlock,1)!=0); //if (isSharedMemoryInited) return; initStats(); // Shared memory variables struct FunctionStatistic *** shm = getFunctionStatisticsStorage(); // Storing s_stats into shared memory *shm = s_stats; // Set flag - shared memory is already inited isSharedMemoryInited = 1; printf("Shared memory for FunctionStorage inited successfuly: shm = %p ,s_stats = %p\n", *shm, s_stats ); // Unlock //sharedMemoryInitSpinlock = 0; ///// Critical section ends }
int main(int argc, char **argv) { srand(time(NULL)); printIntro(); initStats(); processArgs(argc, argv); // Start the packet processor pthread_t packet_processor; pthread_create(&packet_processor, NULL, process_incoming, NULL); // Start the syn flood thread pthread_t syn_sender; pthread_create(&syn_sender, NULL, send_syns, NULL); pthread_t status_update; pthread_create(&status_update, NULL, print_status, NULL); // Wait for the threads to return, which is never. pthread_join(syn_sender, NULL); pthread_join(packet_processor, NULL); pthread_join(status_update, NULL); return 0; }
void VisualMatrix::init() { initSprite(); initEffect(); initMatrix(); initStats(); initState(); }
void Matrix::init() { initRules(); initField(); initStats(); initTetrominoes(); initState(); initTimer(); }
feCharacter::feCharacter(char id, std::string n, bool g, char l, feClass j) { uniqID = id; name = n; gender = g; loyalty = l; job = j; /* initialize stats */ initStats(); }
RTPReceptionStats::RTPReceptionStats(unsigned int SSRC):m_SSRC(0),m_numPacketsReceivedSinceLastReset(0), m_totalNumPacketsReceived(0),m_totalBytesReceived_hi(0),m_totalBytesReceived_lo(0), m_haveSeenInitialSequenceNumber(0),m_baseExtSeqNumReceived(0),m_lastResetExtSeqNumReceived(0), m_highestExtSeqNumReceived(0),m_lastTransit(0),m_previousPacketRTPTimestamp(0), m_jitter(0),m_lastReceivedSR_NTPmsw(0),m_lastReceivedSR_NTPlsw(0), m_minInterPacketGapUS(0),m_maxInterPacketGapUS(0),m_hasBeenSynchronized(0) { gethostname(m_CNAME,100); m_CNAME_length=strlen(m_CNAME); initStats(SSRC); }
void updateStats(void) { int i, value, diff, old_x, new_x; W_Color color; SLIDER *s; initStats(); for (i = 0; i < NUM_SLIDERS; i++) { s = &sliders[i]; value = *(s->var); if (value < s->min) value = s->min; else if (value > s->max) value = s->max; if (value == s->lastVal) continue; diff = value - s->lastVal; if (diff < 0) { old_x = s->lastVal * SL_WID / s->diff; new_x = value * SL_WID / s->diff; box(1, BX_OFF() + new_x, BY_OFF(i), old_x - new_x, SL_HEI, backColor); if (s->lastVal >= s->low_red && value < s->low_red) box(1, BX_OFF(), BY_OFF(i), new_x, SL_HEI, warningColor); else if (s->lastVal > s->high_red && value <= s->high_red) box(1, BX_OFF(), BY_OFF(i), new_x, SL_HEI, myColor); } else { if (value < s->low_red) color = warningColor; else if (value > s->high_red) { color = warningColor; if (s->lastVal <= s->high_red) s->lastVal = 0; } else { color = myColor; if (s->lastVal < s->low_red) s->lastVal = 0; } old_x = s->lastVal * SL_WID / s->diff; new_x = value * SL_WID / s->diff; box(1, BX_OFF() + old_x, BY_OFF(i), new_x - old_x, SL_HEI, color); } s->lastVal = value; } }
LLViewerRegion::LLViewerRegion( U64 regionHandle , const LLHost &host , const U32 surface_grid_width , const U32 patch_grid_width , const F32 region_width_meters ) : m_regionHandle(regionHandle) , m_host(host) , mWidth(region_width_meters) { mOriginGlobal = from_region_handle(regionHandle); initStats(); }
/* =================== Arx Interface Functions ================ */ extern "C" AcRx::AppRetCode acrxEntryPoint(AcRx::AppMsgCode msg, void* pAppId) { switch(msg) { case AcRx::kInitAppMsg: // Tell system that we are MDI-aware. acrxDynamicLinker->registerAppMDIAware(pAppId); initStats(); break; case AcRx::kUnloadAppMsg: termStats(); default: break; } return AcRx::kRetOK; }
void redrawStats(void) { int i; W_ClearWindow(statwin); initStats(); for (i = 0; i < NUM_SLIDERS; i++) { sliders[i].lastVal = 0; } for (i = 0; i < NUM_SLIDERS; i++) { W_WriteText(statwin, TX_OFF(sliders[i].label_length), TY_OFF(i), textColor, sliders[i].label, sliders[i].label_length, W_RegularFont); box(0, BX_OFF() - 1, BY_OFF(i) - 1, SL_WID + 2, SL_HEI + 2, borderColor); sliders[i].lastVal = 0; } }
void faGapSizes(char *fileName) /* faGapSizes - report on gap size counts/statistics. */ { struct dnaSeq *seqList = NULL; struct dnaSeq *seq = NULL; int nCount=0; int i=0; getNiceSizes(niceSizeList, &niceSizes, &niceSizeCount); initStats(niceSizeCount); seqList = faReadAllDna(fileName); nCount = 0; for (seq=seqList; seq != NULL; seq=seq->next) { for (i=0; i < seq->size; i++) { if (seq->dna[i] == 'n' || seq->dna[i] == 'N') { nCount++; } else if (nCount > 0) { recordGap(nCount); nCount = 0; } } if (nCount > 0) { recordGap(nCount); nCount = 0; } } reportStats(); }
hax::Skeleton::Skeleton(){ initStats(); }
hax::Necromancer::Necromancer(std::string name) : Undead(name){ initStats(); }
hax::Skeleton::Skeleton(std::string name) : Undead(name){ initStats(); }
hax::Necromancer::Necromancer(){ initStats(); }
LLViewerRegion::LLViewerRegion(const U64 &handle, const LLHost &host, const U32 grids_per_region_edge, const U32 grids_per_patch_edge, const F32 region_width_meters) : mCenterGlobal(), mHandle(handle), mHost( host ), mTimeDilation(1.0f), mName(""), mZoning(""), mOwnerID(), mIsEstateManager(FALSE), mCompositionp(NULL), mRegionFlags( REGION_FLAGS_DEFAULT ), mSimAccess( SIM_ACCESS_MIN ), mBillableFactor(1.0), mMaxTasks(DEFAULT_MAX_REGION_WIDE_PRIM_COUNT), mClassID(0), mCPURatio(0), mColoName("unknown"), mProductSKU("unknown"), mProductName("unknown"), mHttpUrl(""), mCacheLoaded(FALSE), mCacheDirty(FALSE), mCacheID(), mEventPoll(NULL), mReleaseNotesRequested(FALSE), // I'd prefer to set the LLCapabilityListener name to match the region // name -- it's disappointing that's not available at construction time. // We could instead store an LLCapabilityListener*, making // setRegionNameAndZone() replace the instance. Would that pose // consistency problems? Can we even request a capability before calling // setRegionNameAndZone()? // For testability -- the new Michael Feathers paradigm -- // LLCapabilityListener binds all the globals it expects to need at // construction time. mCapabilityListener(host.getString(), gMessageSystem, *this, gAgent.getID(), gAgent.getSessionID()) { mWidth = region_width_meters; mOriginGlobal = from_region_handle(handle); updateRenderMatrix(); mLandp = new LLSurface('l', NULL); if (!gNoRender) { // Create the composition layer for the surface mCompositionp = new LLVLComposition(mLandp, grids_per_region_edge, region_width_meters/grids_per_region_edge); mCompositionp->setSurface(mLandp); // Create the surfaces mLandp->setRegion(this); mLandp->create(grids_per_region_edge, grids_per_patch_edge, mOriginGlobal, mWidth); } if (!gNoRender) { mParcelOverlay = new LLViewerParcelOverlay(this, region_width_meters); } else { mParcelOverlay = NULL; } setOriginGlobal(from_region_handle(handle)); calculateCenterGlobal(); // Create the object lists initStats(); //create object partitions //MUST MATCH declaration of eObjectPartitions mObjectPartition.push_back(new LLHUDPartition()); //PARTITION_HUD mObjectPartition.push_back(new LLTerrainPartition()); //PARTITION_TERRAIN mObjectPartition.push_back(new LLWaterPartition()); //PARTITION_WATER mObjectPartition.push_back(new LLTreePartition()); //PARTITION_TREE mObjectPartition.push_back(new LLParticlePartition()); //PARTITION_PARTICLE mObjectPartition.push_back(new LLCloudPartition()); //PARTITION_CLOUD mObjectPartition.push_back(new LLGrassPartition()); //PARTITION_GRASS mObjectPartition.push_back(new LLVolumePartition()); //PARTITION_VOLUME mObjectPartition.push_back(new LLBridgePartition()); //PARTITION_BRIDGE mObjectPartition.push_back(new LLHUDParticlePartition());//PARTITION_HUD_PARTICLE mObjectPartition.push_back(NULL); //PARTITION_NONE }
PyObject * allstats(PyObject *self, PyObject *args, PyObject *kw) { static char *kwlist[] = {"input", "min", "max", "mean", "std", NULL}; PyObject *input, *inputarray; PyObject *switch_min, *switch_max, *switch_mean, *switch_std; PyObject *outputdict, *value; int input_typenum; stats result; /* Parse input args. * "input": a numpy array or a python object that converts to an array. * Optionally: "min", "max", "mean", "std" truth values, which default to False */ switch_min = switch_max = switch_mean = switch_std = Py_None; if (!PyArg_ParseTupleAndKeywords(args, kw, "O|OOOO", kwlist, &input, &switch_min, &switch_max, &switch_mean, &switch_std)) return NULL; /* * Create proper PyArrayObject from input python object. * This does the bare minimum to create a numpy array. If the input * python object is already a numpy array, then no copy will be made. * It will not ensure contiguous, aligned, etc, so operations on the * array object should account for that. */ inputarray = PyArray_FromAny(input, NULL, 0, 0, 0, NULL); if (inputarray == NULL) { Py_XDECREF(inputarray); return NULL; } /* * Initialize the result and switch stats on/off depending on args */ initStats(&result); if (PyObject_IsTrue(switch_min)) result.switch_min = 1; if (PyObject_IsTrue(switch_max)) result.switch_max = 1; if (PyObject_IsTrue(switch_mean)) result.switch_mean = 1; if (PyObject_IsTrue(switch_std)) result.switch_std = 1; /* * Delegate to type specific function. */ input_typenum = PyArray_TYPE(inputarray); switch (input_typenum) { case NPY_BYTE: allstats_byte(inputarray, &result); break; case NPY_UBYTE: allstats_ubyte(inputarray, &result); break; case NPY_SHORT: allstats_short(inputarray, &result); break; case NPY_USHORT: allstats_ushort(inputarray, &result); break; case NPY_INT: allstats_int(inputarray, &result); break; case NPY_UINT: allstats_uint(inputarray, &result); break; case NPY_LONG: allstats_long(inputarray, &result); break; case NPY_ULONG: allstats_ulong(inputarray, &result); break; case NPY_LONGLONG: allstats_longlong(inputarray, &result); break; case NPY_ULONGLONG: allstats_ulonglong(inputarray, &result); break; case NPY_FLOAT: allstats_float(inputarray, &result); break; case NPY_DOUBLE: allstats_double(inputarray, &result); break; case NPY_LONGDOUBLE: allstats_longdouble(inputarray, &result); break; case NPY_CFLOAT: case NPY_CDOUBLE: case NPY_CLONGDOUBLE: default: PyErr_Format(PyExc_TypeError, "no allstats support for typenum %d", input_typenum); Py_XDECREF(inputarray); return NULL; } Py_XDECREF(inputarray); /* Create return value: a python dict containing the stats. */ outputdict = PyDict_New(); if (result.switch_min) { value = PyFloat_FromDouble(result.min); PyMapping_SetItemString(outputdict, "min", value); Py_XDECREF(value); } if (result.switch_max) { value = PyFloat_FromDouble(result.max); PyMapping_SetItemString(outputdict, "max", value); Py_XDECREF(value); } if (result.switch_mean) { value = PyFloat_FromDouble(result.mean); PyMapping_SetItemString(outputdict, "mean", value); Py_XDECREF(value); } /* Need final calculation of standard deviation from variance */ if (result.switch_std) { result.std = sqrt(result.variance_n); value = PyFloat_FromDouble(result.std); PyMapping_SetItemString(outputdict, "std", value); Py_XDECREF(value); } return outputdict; }
LLViewerRegion::LLViewerRegion(const U64 &handle, const LLHost &host, const U32 grids_per_region_edge, const U32 grids_per_patch_edge, const F32 region_width_meters) : mImpl(new LLViewerRegionImpl(this, host)), mHandle(handle), mTimeDilation(1.0f), mName(""), mZoning(""), mIsEstateManager(FALSE), mRegionFlags( REGION_FLAGS_DEFAULT ), mSimAccess( SIM_ACCESS_MIN ), mBillableFactor(1.0), mMaxTasks(DEFAULT_MAX_REGION_WIDE_PRIM_COUNT), mClassID(0), mCPURatio(0), mColoName("unknown"), mProductSKU("unknown"), mProductName("unknown"), mHttpUrl(""), mCacheLoaded(FALSE), mCacheDirty(FALSE), mReleaseNotesRequested(FALSE), mCapabilitiesReceived(false) { mWidth = region_width_meters; mImpl->mOriginGlobal = from_region_handle(handle); updateRenderMatrix(); mImpl->mLandp = new LLSurface('l', NULL); // Create the composition layer for the surface mImpl->mCompositionp = new LLVLComposition(mImpl->mLandp, grids_per_region_edge, region_width_meters / grids_per_region_edge); mImpl->mCompositionp->setSurface(mImpl->mLandp); // Create the surfaces mImpl->mLandp->setRegion(this); mImpl->mLandp->create(grids_per_region_edge, grids_per_patch_edge, mImpl->mOriginGlobal, mWidth); mParcelOverlay = new LLViewerParcelOverlay(this, region_width_meters); setOriginGlobal(from_region_handle(handle)); calculateCenterGlobal(); // Create the object lists initStats(); //create object partitions //MUST MATCH declaration of eObjectPartitions mImpl->mObjectPartition.push_back(new LLHUDPartition()); //PARTITION_HUD mImpl->mObjectPartition.push_back(new LLTerrainPartition()); //PARTITION_TERRAIN mImpl->mObjectPartition.push_back(new LLVoidWaterPartition()); //PARTITION_VOIDWATER mImpl->mObjectPartition.push_back(new LLWaterPartition()); //PARTITION_WATER mImpl->mObjectPartition.push_back(new LLTreePartition()); //PARTITION_TREE mImpl->mObjectPartition.push_back(new LLParticlePartition()); //PARTITION_PARTICLE mImpl->mObjectPartition.push_back(new LLCloudPartition()); //PARTITION_CLOUD mImpl->mObjectPartition.push_back(new LLGrassPartition()); //PARTITION_GRASS mImpl->mObjectPartition.push_back(new LLVolumePartition()); //PARTITION_VOLUME mImpl->mObjectPartition.push_back(new LLBridgePartition()); //PARTITION_BRIDGE mImpl->mObjectPartition.push_back(new LLHUDParticlePartition());//PARTITION_HUD_PARTICLE mImpl->mObjectPartition.push_back(NULL); //PARTITION_NONE }