content
stringlengths
19
48.2k
/* * * irandomvalue - generates a random integer between lo and hi. * * Uses Sobol-Antonov_Saleev quasi-sequence * Assumes that random sequence has been initialized. * * M. Sambridge, Aug. 1997 */ static int irandomvalue(int lo, int hi) { int irnum = 0; double rval[2]; sobseq(1, rval); irnum = lo + (int)rval[0] * ( hi - lo + 1); return irnum; }
#ifndef _ASM_MICROBLAZE_FUTEX_H #define _ASM_MICROBLAZE_FUTEX_H #ifdef __KERNEL__ #include <linux/futex.h> #include <linux/uaccess.h> #include <asm/errno.h> #define __futex_atomic_op(insn, ret, oldval, uaddr, oparg) \ ({ \ __asm__ __volatile__ ( \ "1: lwx %0, %2, r0; " \ insn \ "2: swx %1, %2, r0; \ addic %1, r0, 0; \ bnei %1, 1b; \ 3: \ .section .fixup,\"ax\"; \ 4: brid 3b; \ addik %1, r0, %3; \ .previous; \ .section __ex_table,\"a\"; \ .word 1b,4b,2b,4b; \ .previous;" \ : "=&r" (oldval), "=&r" (ret) \ : "r" (uaddr), "i" (-EFAULT), "r" (oparg) \ ); \ }) static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr) { int op = (encoded_op >> 28) & 7; int cmp = (encoded_op >> 24) & 15; int oparg = (encoded_op << 8) >> 20; int cmparg = (encoded_op << 20) >> 20; int oldval = 0, ret; if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) oparg = 1 << oparg; if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32))) return -EFAULT; pagefault_disable(); switch (op) { case FUTEX_OP_SET: __futex_atomic_op("or %1,%4,%4;", ret, oldval, uaddr, oparg); break; case FUTEX_OP_ADD: __futex_atomic_op("add %1,%0,%4;", ret, oldval, uaddr, oparg); break; case FUTEX_OP_OR: __futex_atomic_op("or %1,%0,%4;", ret, oldval, uaddr, oparg); break; case FUTEX_OP_ANDN: __futex_atomic_op("andn %1,%0,%4;", ret, oldval, uaddr, oparg); break; case FUTEX_OP_XOR: __futex_atomic_op("xor %1,%0,%4;", ret, oldval, uaddr, oparg); break; default: ret = -ENOSYS; } pagefault_enable(); if (!ret) { switch (cmp) { case FUTEX_OP_CMP_EQ: ret = (oldval == cmparg); break; case FUTEX_OP_CMP_NE: ret = (oldval != cmparg); break; case FUTEX_OP_CMP_LT: ret = (oldval < cmparg); break; case FUTEX_OP_CMP_GE: ret = (oldval >= cmparg); break; case FUTEX_OP_CMP_LE: ret = (oldval <= cmparg); break; case FUTEX_OP_CMP_GT: ret = (oldval > cmparg); break; default: ret = -ENOSYS; } } return ret; } static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr, u32 oldval, u32 newval) { int ret = 0, cmp; u32 prev; if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32))) return -EFAULT; __asm__ __volatile__ ("1: lwx %1, %3, r0; \ cmp %2, %1, %4; \ bnei %2, 3f; \ 2: swx %5, %3, r0; \ addic %2, r0, 0; \ bnei %2, 1b; \ 3: \ .section .fixup,\"ax\"; \ 4: brid 3b; \ addik %0, r0, %6; \ .previous; \ .section __ex_table,\"a\"; \ .word 1b,4b,2b,4b; \ .previous;" \ : "+r" (ret), "=&r" (prev), "=&r"(cmp) \ : "r" (uaddr), "r" (oldval), "r" (newval), "i" (-EFAULT)); *uval = prev; return ret; } #endif /* __KERNEL__ */ #endif
/*********************** gauge_info.c *************************/ /* MIMD version 7 */ /* For pure_gauge */ /* Application-dependent routine for writing gauge info file */ /* This file is an ASCII companion to the gauge configuration file and contains information about the action used to generate it. This information is consistently written in the pattern keyword value or keyword[n] value1 value2 ... valuen where n is an integer. To maintain a semblance of consistency, the possible keywords are listed in io_lat.h. Add more as the need arises, but be sure to notify the rest of the collaboration. */ #include <stdio.h> #include <math.h> #include <stdlib.h> #include "../include/complex.h" #include "../include/su3.h" #include <lattice.h> /* global variables for lattice fields */ #include "../include/macros.h" #include "../include/comdefs.h" #include "../include/io_lat.h" #include "../include/generic.h" #include <string.h> /*---------------------------------------------------------------------------*/ /* This routine writes the ASCII info file. It is called from one of the lattice output routines in io_lat4.c.*/ void write_appl_gauge_info(FILE *fp, gauge_file *gf) { /* Write generic information */ write_generic_gauge_info(fp, gf); /* The rest are optional */ write_gauge_info_item(fp,"action.description","%s", "\"Pure gauge\"",0,0); write_gauge_info_item(fp,"gauge.description","%s", "\"One plaquette gauge action.\"",0,0); write_gauge_info_item(fp,"gauge.beta11","%f",(char *)&beta,0,0); } char *create_QCDML(){ char dummy[] = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><title>Dummy QCDML</title>"; char *qcdml = (char *)malloc(sizeof(dummy)+1); strcpy(qcdml, dummy); return qcdml; } void free_QCDML(char *qcdml){ if(qcdml != NULL)free(qcdml); }
// Address range: 0x5240 - 0x5286 // From class: N5boost6detail17sp_counted_impl_pINS_8signals26detail12signal1_implISsPKcNS2_19optional_last_valueISsEEiSt4lessIiENS_8functionIFSsS6_EEENSB_IFSsRKNS2_10connectionES6_EEENS2_5mutexEE16invocation_stateEEE // Type: virtual member function int32_t _ZN5boost6detail17sp_counted_impl_pINS_8signals26detail12signal1_implISsPKcNS2_19optional_last_valueISsEEiSt4lessIiENS_8functionIFSsS6_EEENSB_IFSsRKNS2_10connectionES6_EEENS2_5mutexEE16invocation_stateEE7disposeEv(int32_t a1) { int32_t v1 = *(int32_t *)(a1 + 12); g3 = v1; if (v1 == 0) { function_5290(-0x38ffff83); } int32_t v2 = v1 + 12; g1 = v2; function_a3b0(v2); int32_t v3 = v1 + 4; g1 = v3; function_a3b0(v3); return 0; }
/* * Decrement semaphore count, waiting if necessary * until that becomes possible. * Do not raise an exception in case of error (just return a status). */ static int GE_unprotected_semaphore_wait(EIF_POINTER a_semaphore) { #ifdef GE_USE_POSIX_THREADS if (sem_wait((EIF_SEM_TYPE*)a_semaphore)) { return GE_THREAD_ERROR; } return GE_THREAD_OK; #elif defined EIF_WINDOWS switch (WaitForSingleObject((EIF_SEM_TYPE*)a_semaphore, INFINITE)) { case WAIT_FAILED: case WAIT_ABANDONED: return GE_THREAD_ERROR; } return GE_THREAD_OK; #else return GE_THREAD_ERROR; #endif }
/* * * Fun: cmHstGrmFreeInsert * * Desc: Inserts a Freed information in into the hash list. Parameters are: * * bkt : pointer to bucket for which memory is freed. * line : Line where memory is freed. * file : file where memory is freed. * entId : Tapa task which releases the memory. * * Ret: ROK - insertion successful * RFAILED - insertion failed (incorrect parameter values) * * Notes: None * * File: cm_mem_wl.c * */ static S16 cmHstGrmFreeInsert ( CmHstGrmHashListCp* hashListCp, uint32_t blkSz, uint32_t line, uint8_t *fileName, uint8_t entId ) { uint32_t binIdx = 0; uint32_t key = 0; uint32_t ret = 0; CmMemEntries *entry = NULLP; cmHstGrmGetHashIdxAndKey(fileName, line, &binIdx, &key); ret = cmHstGrmFindEntry(hashListCp, key, &binIdx, &entry); if(ret == ROK) { entry->freedBytes += blkSz; entry->bucketFreeReq++; return ROK; } if(hashListCp->totalNumEntries == (CMM_HIST_MAX_MEM_BIN * CMM_HIST_MAX_MEM_ENTRY_PER_BIN)) { printf("No place in the hash list. Increase the value of macro CMM_HIST_MAX_MEM_BIN and CMM_HIST_MAX_MEM_ENTRY_PER_BIN \n"); return RFAILED; } entry = &(hashListCp->hashList[binIdx].entries[hashListCp->hashList[binIdx].numOfEntries]); entry->bucketFreeReq++; entry->freedBytes += blkSz; cmHstGrmFillEntry(entry, key, line, fileName, entId); hashListCp->hashList[binIdx].numOfEntries++; hashListCp->totalNumEntries++; return ROK; }
// ============================================================================= // PROJECT CHRONO - http://projectchrono.org // // Copyright (c) 2023 projectchrono.org // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be found // in the LICENSE file at the top level of the distribution and at // http://projectchrono.org/license-chrono.txt. // // ============================================================================= // Authors: Radu Serban // ============================================================================= // // Simple engine model for the mrole vehicle based on torque-speed engine maps // // ============================================================================= #ifndef MROLE_ENGINE_SIMPLEMAP_H #define MROLE_ENGINE_SIMPLEMAP_H #include "chrono_vehicle/powertrain/ChEngineSimpleMap.h" #include "chrono_models/ChApiModels.h" namespace chrono { namespace vehicle { namespace mrole { /// @addtogroup vehicle_models_mrole /// @{ /// mrole simple speed-torque engine map subsystem. class CH_MODELS_API mrole_EngineSimpleMap : public ChEngineSimpleMap { public: mrole_EngineSimpleMap(const std::string& name); /// Specify maximum engine speed. virtual double GetMaxEngineSpeed() override; /// Set the engine speed-torque maps. /// A concrete class must add the speed-torque points to the provided maps, /// using the ChFunction_Recorder::AddPoint() function. virtual void SetEngineTorqueMaps(ChFunction_Recorder& map0, ///< [out] engine map at zero throttle ChFunction_Recorder& mapF ///< [out] engine map at full throttle ) override; }; /// @} vehicle_models_mrole } // end namespace mrole } // end namespace vehicle } // end namespace chrono #endif
/** \brief Request the DMA SPI to stop handling Transfers. * * The stopping driver may finish a current Transfer, but it will then not start a new, pending one. * \see start() * \see running() * \see busy() * \see stopping() * \see stopped() **/ static void stop() { ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { switch (state_) { case eStopped: break; case eRunning: if (busy()) { state_ = eStopping; } else { state_ = eStopped; } break; case eStopping: break; default: state_ = eError; break; } } }
/** * hfi1_reset_device - reset the chip if possible * @unit: the device to reset * * Whether or not reset is successful, we attempt to re-initialize the chip * (that is, much like a driver unload/reload). We clear the INITTED flag * so that the various entry points will fail until we reinitialize. For * now, we only allow this if no user contexts are open that use chip resources */ int hfi1_reset_device(int unit) { int ret; struct hfi1_devdata *dd = hfi1_lookup(unit); struct hfi1_pportdata *ppd; int pidx; if (!dd) { ret = -ENODEV; goto bail; } dd_dev_info(dd, "Reset on unit %u requested\n", unit); if (!dd->kregbase1 || !(dd->flags & HFI1_PRESENT)) { dd_dev_info(dd, "Invalid unit number %u or not initialized or not present\n", unit); ret = -ENXIO; goto bail; } mutex_lock(&hfi1_mutex); if (dd->rcd) if (hfi1_stats.sps_ctxts) { mutex_unlock(&hfi1_mutex); ret = -EBUSY; goto bail; } mutex_unlock(&hfi1_mutex); for (pidx = 0; pidx < dd->num_pports; ++pidx) { ppd = dd->pport + pidx; shutdown_led_override(ppd); } if (dd->flags & HFI1_HAS_SEND_DMA) sdma_exit(dd); hfi1_reset_cpu_counters(dd); ret = hfi1_init(dd, 1); if (ret) dd_dev_err(dd, "Reinitialize unit %u after reset failed with %d\n", unit, ret); else dd_dev_info(dd, "Reinitialized unit %u after resetting\n", unit); bail: return ret; }
/* Read the contents of an input stream, and return it, terminated with a NUL byte. */ char * read_file (FILE *stream) { #define BUFSIZE 4096 char *buf = NULL; int alloc = 0; int size = 0; int count; while (! feof (stream)) { if (size + BUFSIZE > alloc) { alloc = alloc + alloc / 2; if (alloc < size + BUFSIZE) alloc = size + BUFSIZE; buf = realloc (buf, alloc); if (buf == NULL) { fprintf (stderr, "out of memory\n"); exit (1); } } count = fread (buf + size, 1, BUFSIZE, stream); if (count == 0) { if (ferror (stream)) { perror ("fread"); exit (1); } } else size += count; } buf = realloc (buf, size + 1); if (buf == NULL) { fprintf (stderr, "out of memory\n"); exit (1); } buf[size] = '\0'; return buf; #undef BUFSIZE }
/** * @brief Enables or disables the specified POWER interrupts. * @param POWER_IT: specifies the PVD interrupts sources to be enabled or disabled. * This parameter can be any combination of the @ref PWR_Voltage_Detector_ITEnable values. * @param NewState - @ref FunctionalState - new state of the specified POWER interrupts. * @retval None */ void POWER_PVD_ITconfig(uint32_t POWER_IT, FunctionalState NewState) { assert_param(IS_POWER_PVD_IT(POWER_IT)); assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { MDR_POWER->PVDCS |= POWER_IT; } else { MDR_POWER->PVDCS &= (uint32_t)~POWER_IT; } }
/** * ixgbe_dmac_update_tcs - Configure DMA Coalescing registers. * @hw: pointer to hardware structure * * Disables dmac, updates per TC settings, and then enable dmac. **/ s32 ixgbe_dmac_update_tcs(struct ixgbe_hw *hw) { return ixgbe_call_func(hw, hw->mac.ops.dmac_update_tcs, (hw), IXGBE_NOT_IMPLEMENTED); }
/*! \brief attempts to write up to len bytes to the SPI channel \param pBuff - points to first location to start getting the data from \param len - number of bytes to write to the SPI channel \return upon successful completion, the function shall return write size. Otherwise, -1 shall be returned \sa spi_Read_CPU , spi_Write_CPU \note This function could be implemented as zero copy and return only upon successful completion of writing the whole buffer, but in cases that memory allocation is not too tight, the function could copy the data to internal buffer, return back and complete the write in parallel to other activities as long as the other SPI activities would be blocked untill the entire buffer write would be completed \warning */ int spi_Write_CPU(unsigned char *pBuff, int len) { unsigned long ulCnt; unsigned long ulStatusReg; unsigned long *ulDataOut; unsigned long ulDataIn; unsigned long ulTxReg; unsigned long ulRxReg; SPICSEnable(LSPI_BASE); Initialize local variable. ulDataOut = (unsigned long *)pBuff; ulCnt = (len +3 ) >> 2; ulStatusReg = LSPI_BASE+MCSPI_O_CH0STAT; ulTxReg = LSPI_BASE + MCSPI_O_TX0; ulRxReg = LSPI_BASE + MCSPI_O_RX0; Writing Loop while(ulCnt--) { while(!( HWREG(ulStatusReg)& MCSPI_CH0STAT_TXS )); HWREG(ulTxReg) = *ulDataOut; while(!( HWREG(ulStatusReg)& MCSPI_CH0STAT_RXS )); ulDataIn = HWREG(ulRxReg); ulDataOut++; } Disable Chip Select HWREG(0x44022128)|= 1; SPICSDisable(LSPI_BASE); UNUSED(ulDataIn); return len; }
// 1 on yes, 0 on no static inline int check_is_stop(char *codon, int mito) { if ( mito == 0 ) return codon_matrix[seq2code4(codon[0])][seq2code4(codon[1])][seq2code4(codon[2])] == C4_Stop; else return mitomap_codon_matrix[seq2code4(codon[0])][seq2code4(codon[1])][seq2code4(codon[2])] == C4_Stop; }
/** * @brief Processing function for the Q31 DCT4/IDCT4. * @param[in] *S points to an instance of the Q31 DCT4 structure. * @param[in] *pState points to state buffer. * @param[in,out] *pInlineBuffer points to the in-place input and output buffer. * @return none. * \par Input an output formats: * Input samples need to be downscaled by 1 bit to avoid saturations in the Q31 DCT process, * as the conversion from DCT2 to DCT4 involves one subtraction. * Internally inputs are downscaled in the RFFT process function to avoid overflows. * Number of bits downscaled, depends on the size of the transform. * The input and output formats for different DCT sizes and number of bits to upscale are mentioned in the table below: * * \image html dct4FormatsQ31Table.gif */ void arm_dct4_q31( const arm_dct4_instance_q31 * S, q31_t * pState, q31_t * pInlineBuffer) { uint16_t i; q31_t *weights = S->pTwiddle; q31_t *cosFact = S->pCosFactor; q31_t *pS1, *pS2, *pbuff; q31_t in; arm_mult_q31(pInlineBuffer, cosFact, pInlineBuffer, S->N); arm_shift_q31(pInlineBuffer, 1, pInlineBuffer, S->N); pS1 = pState; pS2 = pState + (S->N - 1u); pbuff = pInlineBuffer; #ifndef ARM_MATH_CM0 i = S->Nby2 >> 2u; do { *pS1++ = *pbuff++; *pS2-- = *pbuff++; *pS1++ = *pbuff++; *pS2-- = *pbuff++; *pS1++ = *pbuff++; *pS2-- = *pbuff++; *pS1++ = *pbuff++; *pS2-- = *pbuff++; i--; } while(i > 0u); pbuff = pInlineBuffer; pS1 = pState; i = S->N >> 2u; do { *pbuff++ = *pS1++; *pbuff++ = *pS1++; *pbuff++ = *pS1++; *pbuff++ = *pS1++; i--; } while(i > 0u); arm_rfft_q31(S->pRfft, pInlineBuffer, pState); arm_cmplx_mult_cmplx_q31(pState, weights, pState, S->N); arm_shift_q31(pState, 2, pState, S->N * 2); i = (S->N - 1u) >> 2u; pbuff = pInlineBuffer; pS1 = pState; in = *pS1++ >> 1u; *pbuff++ = in; pS1++; do { in = *pS1++ - in; *pbuff++ = in; pS1++; in = *pS1++ - in; *pbuff++ = in; pS1++; in = *pS1++ - in; *pbuff++ = in; pS1++; in = *pS1++ - in; *pbuff++ = in; pS1++; i--; } while(i > 0u); i = (S->N - 1u) % 0x4u; while(i > 0u) { in = *pS1++ - in; *pbuff++ = in; pS1++; i--; } i = S->N >> 2u; pbuff = pInlineBuffer; do { in = *pbuff; *pbuff++ = ((q31_t) (((q63_t) in * S->normalize) >> 31)); in = *pbuff; *pbuff++ = ((q31_t) (((q63_t) in * S->normalize) >> 31)); in = *pbuff; *pbuff++ = ((q31_t) (((q63_t) in * S->normalize) >> 31)); in = *pbuff; *pbuff++ = ((q31_t) (((q63_t) in * S->normalize) >> 31)); i--; } while(i > 0u); #else i = S->Nby2; do { *pS1++ = *pbuff++; *pS2-- = *pbuff++; i--; } while(i > 0u); pbuff = pInlineBuffer; pS1 = pState; i = S->N; do { *pbuff++ = *pS1++; i--; } while(i > 0u); arm_rfft_q31(S->pRfft, pInlineBuffer, pState); arm_cmplx_mult_cmplx_q31(pState, weights, pState, S->N); arm_shift_q31(pState, 2, pState, S->N * 2); pbuff = pInlineBuffer; pS1 = pState; in = *pS1++ >> 1u; *pbuff++ = in; pS1++; i = (S->N - 1u); while(i > 0u) { in = *pS1++ - in; *pbuff++ = in; pS1++; i--; } i = S->N; pbuff = pInlineBuffer; do { in = *pbuff; *pbuff++ = ((q31_t) (((q63_t) in * S->normalize) >> 31)); i--; } while(i > 0u); #endif }
#ifndef DataFormats_BTLDetId_BTLDetId_h #define DataFormats_BTLDetId_BTLDetId_h #include "DataFormats/ForwardDetId/interface/MTDDetId.h" #include <ostream> #include <array> /** @class BTLDetId @brief Detector identifier class for the Barrel Timing Layer. The crystal count must start from 0, copy number must be scaled by 1 unit. bit 15-10: module sequential number bit 9-8 : crystal type (1 - 3) bit 7-6 : readout unit sequential number within a type ( 1 - 2 ) bit 5-0 : crystal sequential number within a module ( 0 - 15 ) */ class BTLDetId : public MTDDetId { public: static constexpr uint32_t kBTLmoduleOffset = 10; static constexpr uint32_t kBTLmoduleMask = 0x3F; static constexpr uint32_t kBTLmodTypeOffset = 8; static constexpr uint32_t kBTLmodTypeMask = 0x3; static constexpr uint32_t kBTLRUOffset = 6; static constexpr uint32_t kBTLRUMask = 0x3; static constexpr uint32_t kBTLCrystalOffset = 0; static constexpr uint32_t kBTLCrystalMask = 0x3F; /// range constants, need two sets for the time being (one for tiles and one for bars) static constexpr uint32_t HALF_ROD = 36; static constexpr uint32_t kModulesPerRODBarPhiFlat = 48; static constexpr uint32_t kModulePerTypeBarPhiFlat = 48 / 3; static constexpr uint32_t kRUPerTypeV2 = 2; static constexpr uint32_t kModulesPerRUV2 = 24; static constexpr uint32_t kCrystalsPerModuleV2 = 16; static constexpr uint32_t kModulesPerTrkV2 = 3; static constexpr uint32_t kCrystalTypes = 3; // Number of crystals in BTL according to TDR design, valid also for barphiflat scenario: // 16 crystals x 24 modules x 2 readout units/type x 3 types x 36 rods/side x 2 sides // static constexpr uint32_t kCrystalsBTL = kCrystalsPerModuleV2 * kModulesPerRUV2 * kRUPerTypeV2 * kCrystalTypes * HALF_ROD * 2; enum class CrysLayout { tile = 1, bar = 2, barzflat = 3, barphiflat = 4, v2 = 5 }; // ---------- Constructors, enumerated types ---------- /** Construct a null id */ BTLDetId() : MTDDetId(DetId::Forward, ForwardSubdetector::FastTime) { id_ |= (MTDType::BTL & kMTDsubdMask) << kMTDsubdOffset; } /** Construct from a raw value */ BTLDetId(const uint32_t& raw_id) : MTDDetId(raw_id) { ; } /** Construct from generic DetId */ BTLDetId(const DetId& det_id) : MTDDetId(det_id.rawId()) { ; } /** Construct from complete geometry information, v1 **/ BTLDetId(uint32_t zside, uint32_t rod, uint32_t module, uint32_t modtyp, uint32_t crystal) : MTDDetId(DetId::Forward, ForwardSubdetector::FastTime) { id_ |= (MTDType::BTL & kMTDsubdMask) << kMTDsubdOffset | (zside & kZsideMask) << kZsideOffset | (rod & kRodRingMask) << kRodRingOffset | (module & kBTLmoduleMask) << kBTLmoduleOffset | (modtyp & kBTLmodTypeMask) << kBTLmodTypeOffset | ((crystal - 1) & kBTLCrystalMask) << kBTLCrystalOffset; } /** Construct from complete geometry information, v2 **/ BTLDetId(uint32_t zside, uint32_t rod, uint32_t runit, uint32_t module, uint32_t modtyp, uint32_t crystal) : MTDDetId(DetId::Forward, ForwardSubdetector::FastTime) { id_ |= (MTDType::BTL & kMTDsubdMask) << kMTDsubdOffset | (zside & kZsideMask) << kZsideOffset | (rod & kRodRingMask) << kRodRingOffset | (module & kBTLmoduleMask) << kBTLmoduleOffset | (modtyp & kBTLmodTypeMask) << kBTLmodTypeOffset | (runit & kBTLRUMask) << kBTLRUOffset | ((crystal - 1) & kBTLCrystalMask) << kBTLCrystalOffset; } // ---------- Common methods ---------- /** Returns BTL module number. */ inline int module() const { return (id_ >> kBTLmoduleOffset) & kBTLmoduleMask; } /** Returns BTL crystal type number. */ inline int modType() const { return (id_ >> kBTLmodTypeOffset) & kBTLmodTypeMask; } /** Returns BTL crystal number. */ inline int crystal() const { return ((id_ >> kBTLCrystalOffset) & kBTLCrystalMask) + 1; } /** Returns BTL readout unit number per type. */ inline int runit() const { return (id_ >> kBTLRUOffset) & kBTLRUMask; } /** return the row in GeomDet language **/ inline int row(unsigned nrows = kCrystalsPerModuleV2) const { return (crystal() - 1) % nrows; // anything else for now } /** return the column in GeomDetLanguage **/ inline int column(unsigned nrows = kCrystalsPerModuleV2) const { return (crystal() - 1) / nrows; } /** create a Geographical DetId for Tracking **/ BTLDetId geographicalId(CrysLayout lay) const; }; std::ostream& operator<<(std::ostream&, const BTLDetId&); #endif // DataFormats_BTLDetId_BTLDetId_h
/* * Copyright (c) 2018 Agility Robotics * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifdef _WIN32 // Winsock compatibility #define _WIN32_WINNT 0x0601 #include <winsock2.h> #define poll WSAPoll #define close closesocket #define ioctl ioctlsocket #define perror(str) fprintf(stderr, str ": %d\n", WSAGetLastError()) #define SOCKETS_INIT \ do { \ WSADATA wsaData; \ int res = WSAStartup(MAKEWORD(2, 2), &wsaData); \ if (res) { \ printf("WSAStartup failed: %d\n", res); \ return -1; \ } \ } while (0) #define SOCKETS_CLEANUP WSACleanup() typedef u_long ioctl_arg_t; #else // Linux sockets #include <unistd.h> #include <sys/ioctl.h> #include <poll.h> #include <netdb.h> #include <fcntl.h> #define SOCKETS_INIT #define SOCKETS_CLEANUP typedef int ioctl_arg_t; #endif // _WIN32 #include "udp.h" #include <stdio.h> void process_packet_header(packet_header_info_t *info, const unsigned char *header_in, unsigned char *header_out) { // Increment outgoing packet sequence number ++info->seq_num_out; // header_in[0]: sequence number of incoming packet // header_in[1]: sequence number of previous outgoing packet, looped back char seq_num_in = (char) header_in[0]; char loopback = (char) header_in[1]; // Compute round-trip delay and incoming sequence number diff info->delay = info->seq_num_out - loopback; info->seq_num_in_diff = seq_num_in - info->seq_num_in_last; info->seq_num_in_last = seq_num_in; // Write outgoing packet header header_out[0] = (unsigned char) info->seq_num_out; header_out[1] = (unsigned char) seq_num_in; } int udp_init_host(const char *local_addr_str, const char *local_port_str) { // Platform-specific socket library initialization SOCKETS_INIT; int err; // Get address info struct addrinfo *local; struct addrinfo hints = {0}; hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_DGRAM; hints.ai_protocol = IPPROTO_UDP; err = getaddrinfo(local_addr_str, local_port_str, &hints, &local); if (err) { printf("%s\n", gai_strerror(err)); SOCKETS_CLEANUP; return -1; } // Create socket int sock = socket(local->ai_family, local->ai_socktype, local->ai_protocol); if (-1 == sock) { perror("Error creating socket"); freeaddrinfo(local); SOCKETS_CLEANUP; return -1; } // Bind to interface address if (bind(sock, (struct sockaddr *) local->ai_addr, local->ai_addrlen)) { perror("Error binding to interface address"); close(sock); freeaddrinfo(local); SOCKETS_CLEANUP; return -1; } // Free addrinfo struct freeaddrinfo(local); // Make socket non-blocking ioctl_arg_t mode = 1; ioctl(sock, FIONBIO, &mode); return sock; } int udp_init_client(const char *remote_addr_str, const char *remote_port_str, const char *local_addr_str, const char *local_port_str) { // Platform-specific socket library initialization SOCKETS_INIT; int err; // Get remote address info struct addrinfo *remote; struct addrinfo hints = {0}; hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_DGRAM; hints.ai_protocol = IPPROTO_UDP; err = getaddrinfo(remote_addr_str, remote_port_str, &hints, &remote); if (err) { printf("%s\n", gai_strerror(err)); SOCKETS_CLEANUP; return -1; } // Get remote address info struct addrinfo *local; err = getaddrinfo(local_addr_str, local_port_str, &hints, &local); if (err) { printf("%s\n", gai_strerror(err)); SOCKETS_CLEANUP; return -1; } // Create socket int sock = socket(remote->ai_family, remote->ai_socktype, remote->ai_protocol); if (-1 == sock) { perror("Error creating socket"); freeaddrinfo(remote); freeaddrinfo(local); SOCKETS_CLEANUP; return -1; } // Bind to interface address if (bind(sock, (struct sockaddr *) local->ai_addr, local->ai_addrlen)) { perror("Error binding to interface address"); close(sock); freeaddrinfo(remote); freeaddrinfo(local); SOCKETS_CLEANUP; return -1; } // Connect to remote address if (connect(sock, (struct sockaddr *) remote->ai_addr, remote->ai_addrlen)) { perror("Error connecting to remote address"); close(sock); freeaddrinfo(remote); freeaddrinfo(local); SOCKETS_CLEANUP; return -1; } // Free addrinfo structs freeaddrinfo(remote); freeaddrinfo(local); // Make socket non-blocking ioctl_arg_t mode = 1; ioctl(sock, FIONBIO, &mode); return sock; } void udp_close(int sock) { close(sock); SOCKETS_CLEANUP; } ssize_t get_newest_packet(int sock, void *recvbuf, size_t recvlen, struct sockaddr *src_addr, socklen_t *addrlen) { // Does not use sequence number for determining newest packet ssize_t nbytes = -1; struct pollfd fd = {.fd = sock, .events = POLLIN, .revents = 0}; // Loop through RX buffer, copying data if packet is correct size while (poll(&fd, 1, 0)) { ioctl_arg_t nbytes_avail; ioctl(sock, FIONREAD, &nbytes_avail); if (recvlen == (size_t) nbytes_avail) nbytes = recvfrom(sock, recvbuf, recvlen, 0, src_addr, addrlen); else recv(sock, recvbuf, 0, 0); // Discard packet } // Return the copied packet size, or -1 if no data was copied return nbytes; } ssize_t wait_for_packet(int sock, void *recvbuf, size_t recvlen, struct sockaddr *src_addr, socklen_t *addrlen) { ssize_t nbytes; do { // Wait if no packets are available struct pollfd fd = {.fd = sock, .events = POLLIN, .revents = 0}; while (!poll(&fd, 1, 0)) {} // Get the newest available packet nbytes = get_newest_packet(sock, recvbuf, recvlen, src_addr, addrlen); } while ((ssize_t) recvlen != nbytes); // Return the copied packet size return nbytes; } ssize_t send_packet(int sock, void *sendbuf, size_t sendlen, struct sockaddr *dst_addr, socklen_t addrlen) { ssize_t nbytes; // Send packet, retrying if busy do { nbytes = sendto(sock, sendbuf, sendlen, 0, dst_addr, addrlen); } while (-1 == nbytes); // Return the sent packet size return nbytes; }
/* * Copyright (c) 2014 The WebM project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #include "vp9/encoder/vp9_context_tree.h" #include "vp9/encoder/vp9_encoder.h" static const BLOCK_SIZE square[] = { BLOCK_8X8, BLOCK_16X16, BLOCK_32X32, BLOCK_64X64, }; static void alloc_mode_context(VP9_COMMON *cm, int num_4x4_blk, PICK_MODE_CONTEXT *ctx) { const int num_blk = (num_4x4_blk < 4 ? 4 : num_4x4_blk); const int num_pix = num_blk << 4; int i, k; ctx->num_4x4_blk = num_blk; CHECK_MEM_ERROR(&cm->error, ctx->zcoeff_blk, vpx_calloc(num_blk, sizeof(uint8_t))); for (i = 0; i < MAX_MB_PLANE; ++i) { for (k = 0; k < 3; ++k) { CHECK_MEM_ERROR(&cm->error, ctx->coeff[i][k], vpx_memalign(32, num_pix * sizeof(*ctx->coeff[i][k]))); CHECK_MEM_ERROR(&cm->error, ctx->qcoeff[i][k], vpx_memalign(32, num_pix * sizeof(*ctx->qcoeff[i][k]))); CHECK_MEM_ERROR(&cm->error, ctx->dqcoeff[i][k], vpx_memalign(32, num_pix * sizeof(*ctx->dqcoeff[i][k]))); CHECK_MEM_ERROR(&cm->error, ctx->eobs[i][k], vpx_memalign(32, num_blk * sizeof(*ctx->eobs[i][k]))); ctx->coeff_pbuf[i][k] = ctx->coeff[i][k]; ctx->qcoeff_pbuf[i][k] = ctx->qcoeff[i][k]; ctx->dqcoeff_pbuf[i][k] = ctx->dqcoeff[i][k]; ctx->eobs_pbuf[i][k] = ctx->eobs[i][k]; } } } static void free_mode_context(PICK_MODE_CONTEXT *ctx) { int i, k; vpx_free(ctx->zcoeff_blk); ctx->zcoeff_blk = 0; for (i = 0; i < MAX_MB_PLANE; ++i) { for (k = 0; k < 3; ++k) { vpx_free(ctx->coeff[i][k]); ctx->coeff[i][k] = 0; vpx_free(ctx->qcoeff[i][k]); ctx->qcoeff[i][k] = 0; vpx_free(ctx->dqcoeff[i][k]); ctx->dqcoeff[i][k] = 0; vpx_free(ctx->eobs[i][k]); ctx->eobs[i][k] = 0; } } } static void alloc_tree_contexts(VP9_COMMON *cm, PC_TREE *tree, int num_4x4_blk) { alloc_mode_context(cm, num_4x4_blk, &tree->none); alloc_mode_context(cm, num_4x4_blk / 2, &tree->horizontal[0]); alloc_mode_context(cm, num_4x4_blk / 2, &tree->vertical[0]); if (num_4x4_blk > 4) { alloc_mode_context(cm, num_4x4_blk / 2, &tree->horizontal[1]); alloc_mode_context(cm, num_4x4_blk / 2, &tree->vertical[1]); } else { memset(&tree->horizontal[1], 0, sizeof(tree->horizontal[1])); memset(&tree->vertical[1], 0, sizeof(tree->vertical[1])); } } static void free_tree_contexts(PC_TREE *tree) { free_mode_context(&tree->none); free_mode_context(&tree->horizontal[0]); free_mode_context(&tree->horizontal[1]); free_mode_context(&tree->vertical[0]); free_mode_context(&tree->vertical[1]); } // This function sets up a tree of contexts such that at each square // partition level. There are contexts for none, horizontal, vertical, and // split. Along with a block_size value and a selected block_size which // represents the state of our search. void vp9_setup_pc_tree(VP9_COMMON *cm, ThreadData *td) { int i, j; const int leaf_nodes = 64; const int tree_nodes = 64 + 16 + 4 + 1; int pc_tree_index = 0; PC_TREE *this_pc; PICK_MODE_CONTEXT *this_leaf; int square_index = 1; int nodes; vpx_free(td->leaf_tree); CHECK_MEM_ERROR(&cm->error, td->leaf_tree, vpx_calloc(leaf_nodes, sizeof(*td->leaf_tree))); vpx_free(td->pc_tree); CHECK_MEM_ERROR(&cm->error, td->pc_tree, vpx_calloc(tree_nodes, sizeof(*td->pc_tree))); this_pc = &td->pc_tree[0]; this_leaf = &td->leaf_tree[0]; // 4x4 blocks smaller than 8x8 but in the same 8x8 block share the same // context so we only need to allocate 1 for each 8x8 block. for (i = 0; i < leaf_nodes; ++i) alloc_mode_context(cm, 1, &td->leaf_tree[i]); // Sets up all the leaf nodes in the tree. for (pc_tree_index = 0; pc_tree_index < leaf_nodes; ++pc_tree_index) { PC_TREE *const tree = &td->pc_tree[pc_tree_index]; tree->block_size = square[0]; alloc_tree_contexts(cm, tree, 4); tree->leaf_split[0] = this_leaf++; for (j = 1; j < 4; j++) tree->leaf_split[j] = tree->leaf_split[0]; } // Each node has 4 leaf nodes, fill each block_size level of the tree // from leafs to the root. for (nodes = 16; nodes > 0; nodes >>= 2) { for (i = 0; i < nodes; ++i) { PC_TREE *const tree = &td->pc_tree[pc_tree_index]; alloc_tree_contexts(cm, tree, 4 << (2 * square_index)); tree->block_size = square[square_index]; for (j = 0; j < 4; j++) tree->split[j] = this_pc++; ++pc_tree_index; } ++square_index; } td->pc_root = &td->pc_tree[tree_nodes - 1]; td->pc_root[0].none.best_mode_index = 2; } void vp9_free_pc_tree(ThreadData *td) { int i; if (td == NULL) return; if (td->leaf_tree != NULL) { // Set up all 4x4 mode contexts for (i = 0; i < 64; ++i) free_mode_context(&td->leaf_tree[i]); vpx_free(td->leaf_tree); td->leaf_tree = NULL; } if (td->pc_tree != NULL) { const int tree_nodes = 64 + 16 + 4 + 1; // Sets up all the leaf nodes in the tree. for (i = 0; i < tree_nodes; ++i) free_tree_contexts(&td->pc_tree[i]); vpx_free(td->pc_tree); td->pc_tree = NULL; } }
/* This is mostly just a wrapper around the code in grammar.y */ aa_log_record *parse_record(char *str) { if (str == NULL) return NULL; return _parse_yacc(str); }
/** * Get the underlying ArrayBuffer from a TypedArray. * * Additionally the byteLength and byteOffset properties are also returned * which were specified when the TypedArray was created. * * Note: * the returned value must be freed with a jerry_release_value call * * @return ArrayBuffer of a TypedArray * TypeError if the object is not a TypedArray. */ jerry_value_t jerry_get_typedarray_buffer (jerry_value_t value, jerry_length_t *byte_offset, jerry_length_t *byte_length) { jerry_assert_api_available (); #if ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY) if (!ecma_is_typedarray (value)) { return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG ("Object is not a TypedArray."))); } ecma_object_t *array_p = ecma_get_object_from_value (value); uint8_t shift = ecma_typedarray_get_element_size_shift (array_p); if (byte_length != NULL) { *byte_length = (jerry_length_t) (ecma_typedarray_get_length (array_p) << shift); } if (byte_offset != NULL) { *byte_offset = (jerry_length_t) ecma_typedarray_get_offset (array_p); } ecma_object_t *arraybuffer_p = ecma_typedarray_get_arraybuffer (array_p); ecma_ref_object (arraybuffer_p); return jerry_return (ecma_make_object_value (arraybuffer_p)); #else JERRY_UNUSED (value); JERRY_UNUSED (byte_length); JERRY_UNUSED (byte_offset); return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG ("TypedArray is not supported."))); #endif }
/* * Guts of TS parser deletion. */ void RemoveTSParserById(Oid prsId) { Relation relation; HeapTuple tup; relation = table_open(TSParserRelationId, RowExclusiveLock); tup = SearchSysCache1(TSPARSEROID, ObjectIdGetDatum(prsId)); if (!HeapTupleIsValid(tup)) elog(ERROR, "cache lookup failed for text search parser %u", prsId); CatalogTupleDelete(relation, &tup->t_self); ReleaseSysCache(tup); table_close(relation, RowExclusiveLock); }
/* Compare leftmost AS value for MED check. If as1's leftmost AS and as2's leftmost AS is same return 1. (confederation as-path only). */ bool aspath_cmp_left_confed(const struct aspath *aspath1, const struct aspath *aspath2) { if (!(aspath1 && aspath2)) return false; if (!(aspath1->segments && aspath2->segments)) return false; if ((aspath1->segments->type != AS_CONFED_SEQUENCE) || (aspath2->segments->type != AS_CONFED_SEQUENCE)) return false; if (aspath1->segments->as[0] == aspath2->segments->as[0]) return true; return false; }
// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma // de Barcelona (UAB). // // This work is licensed under the terms of the MIT license. // For a copy, see <https://opensource.org/licenses/MIT>. #pragma once #include "carla/FileSystem.h" #include "carla/Logging.h" #include "carla/StringUtil.h" #include "carla/image/BoostGil.h" #ifndef LIBCARLA_IMAGE_WITH_PNG_SUPPORT # if defined(__has_include) && __has_include("png.h") # define LIBCARLA_IMAGE_WITH_PNG_SUPPORT true # else # define LIBCARLA_IMAGE_WITH_PNG_SUPPORT false # endif #endif #ifndef LIBCARLA_IMAGE_WITH_JPEG_SUPPORT # if defined(__has_include) && __has_include("jpeglib.h") # define LIBCARLA_IMAGE_WITH_JPEG_SUPPORT true # else # define LIBCARLA_IMAGE_WITH_JPEG_SUPPORT false # endif #endif #ifndef LIBCARLA_IMAGE_WITH_TIFF_SUPPORT # if defined(__has_include) && __has_include("tiffio.h") # define LIBCARLA_IMAGE_WITH_TIFF_SUPPORT true # else # define LIBCARLA_IMAGE_WITH_TIFF_SUPPORT false # endif #endif #if defined(__clang__) # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wunused-parameter" #endif #if LIBCARLA_IMAGE_WITH_PNG_SUPPORT == true # ifndef png_infopp_NULL # define png_infopp_NULL (png_infopp)NULL # endif // png_infopp_NULL # ifndef int_p_NULL # define int_p_NULL (int*)NULL # endif // int_p_NULL # if defined(__clang__) # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wignored-qualifiers" # pragma clang diagnostic ignored "-Wparentheses" # endif # include <boost/gil/extension/io/png.hpp> # if defined(__clang__) # pragma clang diagnostic pop # endif #endif #if LIBCARLA_IMAGE_WITH_JPEG_SUPPORT == true # include <boost/gil/extension/io/jpeg.hpp> #endif #if LIBCARLA_IMAGE_WITH_TIFF_SUPPORT == true # include <boost/gil/extension/io/tiff.hpp> #endif #if defined(__clang__) # pragma clang diagnostic pop #endif namespace carla { namespace image { namespace io { constexpr bool has_png_support() { return LIBCARLA_IMAGE_WITH_PNG_SUPPORT; } constexpr bool has_jpeg_support() { return LIBCARLA_IMAGE_WITH_JPEG_SUPPORT; } constexpr bool has_tiff_support() { return LIBCARLA_IMAGE_WITH_TIFF_SUPPORT; } static_assert(has_png_support() || has_jpeg_support() || has_tiff_support(), "No image format supported, please compile with at least one of " "LIBCARLA_IMAGE_WITH_PNG_SUPPORT, LIBCARLA_IMAGE_WITH_JPEG_SUPPORT, " "or LIBCARLA_IMAGE_WITH_TIFF_SUPPORT"); namespace detail { template <typename ViewT, typename IOTag> struct is_write_supported { static constexpr bool value = boost::gil::is_write_supported<typename boost::gil::get_pixel_type<ViewT>::type, IOTag>::value; }; struct io_png { static constexpr bool is_supported = has_png_support(); #if LIBCARLA_IMAGE_WITH_PNG_SUPPORT static constexpr const char *get_default_extension() { return "png"; } template <typename Str> static bool match_extension(const Str &str) { return StringUtil::EndsWith(str, get_default_extension()); } template <typename Str, typename ImageT> static void read_image(Str &&in_filename, ImageT &image) { boost::gil::read_and_convert_image(std::forward<Str>(in_filename), image, boost::gil::png_tag()); } template <typename Str, typename ViewT> static void write_view(Str &&out_filename, const ViewT &view) { boost::gil::write_view(std::forward<Str>(out_filename), view, boost::gil::png_tag()); } #endif // LIBCARLA_IMAGE_WITH_PNG_SUPPORT }; struct io_jpeg { static constexpr bool is_supported = has_jpeg_support(); #if LIBCARLA_IMAGE_WITH_JPEG_SUPPORT static constexpr const char *get_default_extension() { return "jpeg"; } template <typename Str> static bool match_extension(const Str &str) { return StringUtil::EndsWith(str, get_default_extension()) || StringUtil::EndsWith(str, "jpg"); } template <typename Str, typename ImageT> static void read_image(Str &&in_filename, ImageT &image) { boost::gil::read_image(std::forward<Str>(in_filename), image, boost::gil::jpeg_tag()); } template <typename Str, typename ViewT> static typename std::enable_if<is_write_supported<ViewT, boost::gil::jpeg_tag>::value>::type write_view(Str &&out_filename, const ViewT &view) { boost::gil::write_view(std::forward<Str>(out_filename), view, boost::gil::jpeg_tag()); } template <typename Str, typename ViewT> static typename std::enable_if<!is_write_supported<ViewT, boost::gil::jpeg_tag>::value>::type write_view(Str &&out_filename, const ViewT &view) { boost::gil::write_view( std::forward<Str>(out_filename), boost::gil::color_converted_view<boost::gil::rgb8_pixel_t>(view), boost::gil::jpeg_tag()); } #endif // LIBCARLA_IMAGE_WITH_JPEG_SUPPORT }; struct io_tiff { static constexpr bool is_supported = has_tiff_support(); #if LIBCARLA_IMAGE_WITH_TIFF_SUPPORT static constexpr const char *get_default_extension() { return "tiff"; } template <typename Str> static bool match_extension(const Str &str) { return StringUtil::EndsWith(str, get_default_extension()); } template <typename Str, typename ImageT> static void read_image(Str &&in_filename, ImageT &image) { boost::gil::read_and_convert_image(std::forward<Str>(in_filename), image, boost::gil::tiff_tag()); } template <typename Str, typename ViewT> static typename std::enable_if<is_write_supported<ViewT, boost::gil::tiff_tag>::value>::type write_view(Str &&out_filename, const ViewT &view) { boost::gil::write_view(std::forward<Str>(out_filename), view, boost::gil::tiff_tag()); } template <typename Str, typename ViewT> static typename std::enable_if<!is_write_supported<ViewT, boost::gil::tiff_tag>::value>::type write_view(Str &&out_filename, const ViewT &view) { boost::gil::write_view( std::forward<Str>(out_filename), boost::gil::color_converted_view<boost::gil::rgb8_pixel_t>(view), boost::gil::tiff_tag()); } #endif // LIBCARLA_IMAGE_WITH_TIFF_SUPPORT }; struct io_resolver { template <typename IO, typename Str> static typename std::enable_if<IO::is_supported, bool>::type match_extension(const Str &str) { return IO::match_extension(str); } template <typename IO, typename Str> static typename std::enable_if<!IO::is_supported, bool>::type match_extension(const Str &) { return false; } template <typename IO, typename Str, typename... Args> static typename std::enable_if<IO::is_supported>::type read_image(const Str &path, Args &&... args) { log_debug("reading", path, "as", IO::get_default_extension()); IO::read_image(path, std::forward<Args>(args)...); } template <typename IO, typename... Args> static typename std::enable_if<!IO::is_supported>::type read_image(Args &&...) { DEBUG_ASSERT(false); } template <typename IO, typename... Args> static typename std::enable_if<IO::is_supported>::type write_view(std::string &path, Args &&... args) { FileSystem::ValidateFilePath(path, IO::get_default_extension()); log_debug("writing", path, "as", IO::get_default_extension()); IO::write_view(path, std::forward<Args>(args)...); } template <typename IO, typename... Args> static typename std::enable_if<!IO::is_supported>::type write_view(Args &&...) { DEBUG_ASSERT(false); } }; template <typename... IOs> struct io_impl; template <typename IO> struct io_impl<IO> { constexpr static bool is_supported = IO::is_supported; template <typename... Args> static void read_image(Args &&... args) { io_resolver::read_image<IO>(std::forward<Args>(args)...); } template <typename... Args> static void write_view(Args &&... args) { io_resolver::write_view<IO>(std::forward<Args>(args)...); } template <typename Str, typename... Args> static bool try_read_image(const Str &filename, Args &&... args) { if (io_resolver::match_extension<IO>(filename)) { io_resolver::read_image<IO>(filename, std::forward<Args>(args)...); return true; } return false; } template <typename Str, typename... Args> static bool try_write_view(Str &filename, Args &&... args) { if (io_resolver::match_extension<IO>(filename)) { io_resolver::write_view<IO>(filename, std::forward<Args>(args)...); return true; } return false; } }; template <typename IO, typename... IOs> struct io_impl<IO, IOs...> { private: using self = io_impl<IO>; using recursive = io_impl<IOs...>; public: constexpr static bool is_supported = self::is_supported || recursive::is_supported; template <typename... Args> static void read_image(Args &... args) { if (!recursive::try_read_image(args...)) { self::read_image(args...); } } template <typename... Args> static bool try_read_image(Args &... args) { return recursive::try_read_image(args...) || self::try_read_image(args...); } template <typename... Args> static void write_view(Args &... args) { if (!recursive::try_write_view(args...)) { self::write_view(args...); } } template <typename... Args> static bool try_write_view(Args &... args) { return recursive::try_write_view(args...) || self::try_write_view(args...); } }; template <typename DefaultIO, typename... IOs> struct io_any : detail::io_impl<DefaultIO, IOs...> { static_assert(DefaultIO::is_supported, "Default IO needs to be supported."); }; } // namespace detail struct png : detail::io_impl<detail::io_png> {}; struct jpeg : detail::io_impl<detail::io_jpeg> {}; struct tiff : detail::io_impl<detail::io_tiff> {}; #if LIBCARLA_IMAGE_WITH_PNG_SUPPORT struct any : detail::io_any<detail::io_png, detail::io_tiff, detail::io_jpeg> {}; #elif LIBCARLA_IMAGE_WITH_TIFF_SUPPORT struct any : detail::io_any<detail::io_tiff, detail::io_jpeg> {}; #else // Then for sure this one is available. struct any : detail::io_any<detail::io_jpeg> {}; #endif } // namespace io } // namespace image } // namespace carla
/******************************************************************************* * * FUNCTION: AcpiUtCopyIpackageToIpackage * * PARAMETERS: *SourceObj - Pointer to the source package object * *DestObj - Where the internal object is returned * * RETURN: Status - the status of the call * * DESCRIPTION: This function is called to copy an internal package object * into another internal package object. * ******************************************************************************/ ACPI_STATUS AcpiUtCopyIpackageToIpackage ( ACPI_OPERAND_OBJECT *SourceObj, ACPI_OPERAND_OBJECT *DestObj, ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status = AE_OK; ACPI_FUNCTION_TRACE ("UtCopyIpackageToIpackage"); DestObj->Common.Type = ACPI_GET_OBJECT_TYPE (SourceObj); DestObj->Common.Flags = SourceObj->Common.Flags; DestObj->Package.Count = SourceObj->Package.Count; DestObj->Package.Elements = ACPI_MEM_CALLOCATE ( ((ACPI_SIZE) SourceObj->Package.Count + 1) * sizeof (void *)); if (!DestObj->Package.Elements) { ACPI_REPORT_ERROR ( ("AmlBuildCopyInternalPackageObject: Package allocation failure\n")); return_ACPI_STATUS (AE_NO_MEMORY); } Status = AcpiUtWalkPackageTree (SourceObj, DestObj, AcpiUtCopyIelementToIelement, WalkState); if (ACPI_FAILURE (Status)) { AcpiUtRemoveReference (DestObj); } return_ACPI_STATUS (Status); }
/* * PsychMovieInit() -- Initialize movie subsystem. * This routine is called by Screen's RegisterProject.c PsychModuleInit() * routine at Screen load-time. It clears out the movieRecordBANK to * bring the subsystem into a clean initial state. */ void PsychMovieInit(void) { #ifdef PTB_USE_GSTREAMER PsychGSMovieInit(); #endif #ifdef PSYCHQTAVAIL PsychQTMovieInit(); #endif firstTime = TRUE; return; }
/* SPDX-License-Identifier: BSD-3-Clause * Copyright (c) 2016 - 2018 Cavium Inc. * All rights reserved. * www.cavium.com */ #ifndef __ECORE_SP_API_H__ #define __ECORE_SP_API_H__ #include "ecore_status.h" enum spq_mode { ECORE_SPQ_MODE_BLOCK, /* Client will poll a designated mem. address */ ECORE_SPQ_MODE_CB, /* Client supplies a callback */ ECORE_SPQ_MODE_EBLOCK, /* ECORE should block until completion */ }; struct ecore_hwfn; union event_ring_data; struct eth_slow_path_rx_cqe; struct ecore_spq_comp_cb { void (*function)(struct ecore_hwfn *, void *, union event_ring_data *, u8 fw_return_code); void *cookie; }; /** * @brief ecore_eth_cqe_completion - handles the completion of a * ramrod on the cqe ring * * @param p_hwfn * @param cqe * * @return enum _ecore_status_t */ enum _ecore_status_t ecore_eth_cqe_completion(struct ecore_hwfn *p_hwfn, struct eth_slow_path_rx_cqe *cqe); /** * @brief ecore_sp_pf_update_tunn_cfg - PF Function Tunnel configuration * update Ramrod * * This ramrod is sent to update a tunneling configuration * for a physical function (PF). * * @param p_hwfn * @param p_ptt * @param p_tunn - pf update tunneling parameters * @param comp_mode - completion mode * @param p_comp_data - callback function * * @return enum _ecore_status_t */ enum _ecore_status_t ecore_sp_pf_update_tunn_cfg(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt, struct ecore_tunnel_info *p_tunn, enum spq_mode comp_mode, struct ecore_spq_comp_cb *p_comp_data); #endif
// Copyright (C) 2022 European Spallation Source, see LICENSE file //===----------------------------------------------------------------------===// /// /// \file /// /// \brief CDT Cuboid module abstractions /// /// Consult ICD for logical geometry dimensions, rotations etc. //===----------------------------------------------------------------------===// #pragma once #include <common/debug/Trace.h> #include <dream/geometry/Config.h> #include <dream/readout/DataParser.h> #include <logical_geometry/ESSGeometry.h> // #undef TRC_LEVEL // #define TRC_LEVEL TRC_L_WAR namespace Dream { class Cuboid { public: ESSGeometry Geometry{112, 112 * 32, 1, 1}; const uint8_t WiresPerCounter{16}; const uint8_t StripsPerCass{32}; struct CuboidOffset { int X; int Y; }; // clang-format off /// \brief Showing offsets roughly as the detector Cuboids are arranged /// std::vector<CuboidOffset> OffsetsHR { {32, 0}, {48, 0}, {64, 0}, {16, 16}, {32, 16}, {48, 16}, {64, 16}, {80, 16}, { 0, 32}, {16, 32}, {32, 32}, {48, 32}, {64, 32}, {80, 32}, {96, 32}, { 0, 48}, {16, 48}, {32, 48}, {64, 48}, {80, 48}, {96, 48}, { 0, 64}, {16, 64}, {32, 64}, {64, 64}, {80, 64}, {96, 64}, {16, 80}, {32, 80}, {64, 80}, {80, 80}, {32, 96}, {64, 96} }; std::vector<int> RotateHR = { 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 3, 3, 3, 1, 1, 1, 3, 3, 3, 2, 2, 2, 3, 3, 2, 2, 3, 2 }; std::vector<CuboidOffset> OffsetsSANS { {32, 0}, {48, 0}, {64, 0}, {16, 16}, {32, 16}, {48, 16}, {64, 16}, {80, 16}, { 0, 32}, {16, 32}, {32, 32}, {48, 32}, {64, 32}, {80, 32}, {96, 32}, { 0, 48}, {16, 48}, {32, 48}, {64, 48}, {80, 48}, {96, 48}, { 0, 64}, {16, 64}, {32, 64}, {48, 64}, {64, 64}, {80, 64}, {96, 64}, {16, 80}, {32, 80}, {48, 80}, {64, 80}, {80, 80}, {32, 96}, {48, 96}, {64, 96} }; std::vector<int> RotateSANS = { 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 3, 3, 3, 1, 1, 1, 3, 3, 3, 2, 2, 2, 2, 3, 3, 2, 2, 2, 3, 2, 2 }; // clang-format on /// \brief rotate (x,y) void rotateXY(int &LocalX, int &LocalY, int Rotate) { int SavedY = LocalY; switch (Rotate) { case 1: // 90 deg. clockwise LocalY = LocalX; LocalX = 15 - SavedY; break; case 2: // 180 deg. cockwise LocalY = 15 - LocalY; LocalX = 15 - LocalX; break; case 3: // 270 deg. clockwise LocalY = 15 - LocalX; LocalX = SavedY; break; } } // uint32_t getPixelId(Config::ModuleParms &Parms, DataParser::DreamReadout &Data) { uint8_t Index = Parms.P1.Index; Index += Data.Unused; // used as instance XTRACE(DATA, DEB, "index %u, anode %u, cathode %u", Index, Data.Anode, Data.Cathode); uint8_t Cassette = Data.Anode / 32 + 2 * (Data.Cathode / 32); uint8_t Counter = (Data.Anode / WiresPerCounter) % 2; uint8_t Wire = Data.Anode % WiresPerCounter; uint8_t Strip = Data.Cathode % StripsPerCass; XTRACE(DATA, DEB, "cass %u, ctr %u, wire %u, strip %u", Cassette, Counter, Wire, Strip); CuboidOffset Offset; int Rotation; if (Parms.Type == Config::ModuleType::SANS) { if (Index >= (int)OffsetsSANS.size()) { XTRACE(DATA, WAR, "Bad SANS index %u", Index); return -1; } Offset = OffsetsSANS[Index]; Rotation = RotateSANS[Index]; } else if (Parms.Type == Config::ModuleType::HR) { if (Index >= (int)OffsetsHR.size()) { XTRACE(DATA, WAR, "Bad HR index %u", Index); return -1; } Offset = OffsetsHR[Index]; Rotation = RotateHR[Index]; } else { XTRACE(DATA, WAR, "Inconsistent type (%d) for Cuboid", Parms.Type); return -1; } int LocalX = 2 * Cassette + Counter; // unrotated x,y values int LocalY = 15 - Wire; XTRACE(DATA, DEB, "local x %u, local y %u, rotate %u", LocalX, LocalY, Rotation); rotateXY(LocalX, LocalY, Rotation); constexpr int YDim{7 * 16}; int x = Offset.X + LocalX; int y = YDim * Strip + Offset.Y + LocalY; XTRACE(DATA, DEB, "x %u, y %u", x, y); return Geometry.pixel2D(x, y); } }; } // namespace Dream
/* filterbank.h - include file for filterbank and related routines */ #include <stdio.h> #include <stdlib.h> #include <math.h> /* input and output files and logfile (filterbank.monitor) */ extern FILE *input, *output, *logfile; extern char inpfile[80], outfile[80]; /* global variables describing the data */ #include "header.h" extern double time_offset; /* global variables describing the operating mode */ extern float start_time, final_time, clip_threshold; extern int obits, sumifs, headerless, headerfile, swapout, invert_band; extern int compute_spectra, do_vanvleck, hanning, hamming, zerolagdump; extern int headeronly; extern char ifstream[8]; /* library of subroutines and functions */ #include "sigproc.h"
/* * read_host_labels - read a label an its contents */ void read_host_labels(Label *route_label) { int j; char *line, *next_line; char *content; host_labels = alloc_labels(); route_label->labels = host_labels; content = strdup(route_label->content); line = content; n_labels = 0; while (*line) { next_line = strchr(line, '\n'); *next_line = '\0'; memcpy(&current_options, &route_label->options, sizeof(current_options)); yyfn = line; yyin = fopen(line, "r"); if (!yyin) err(1, "%s", line); yylex(); fclose(yyin); line = next_line+1; for (j=0; host_labels[j]; j++) { if (*host_labels[j]->export_paths != NULL) { fprintf(stderr, "%s: label validation error: '%s: %s'\n" " path export lists are only supported route files\n", yyfn, host_labels[j]->name, array_to_str(host_labels[j]->export_paths)); exit(1); } } } free(content); }
/* * arch/arm/mach-iop32x/em7210.c * * Board support code for the Lanner EM7210 platforms. * * Based on arch/arm/mach-iop32x/iq31244.c file. * * Copyright (C) 2007 Arnaud Patard <arnaud.patard@rtp-net.org> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * */ #include <linux/mm.h> #include <linux/init.h> #include <linux/kernel.h> #include <linux/pci.h> #include <linux/pm.h> #include <linux/serial_core.h> #include <linux/serial_8250.h> #include <linux/mtd/physmap.h> #include <linux/platform_device.h> #include <linux/i2c.h> #include <linux/gpio.h> #include <mach/hardware.h> #include <linux/io.h> #include <linux/irq.h> #include <asm/mach/arch.h> #include <asm/mach/map.h> #include <asm/mach/pci.h> #include <asm/mach/time.h> #include <asm/mach-types.h> #include <mach/time.h> #include "gpio-iop32x.h" static void __init em7210_timer_init(void) { /* http://www.kwaak.net/fotos/fotos-nas/slide_24.html */ /* 33.333 MHz crystal. */ iop_init_time(200000000); } /* * EM7210 RTC */ static struct i2c_board_info __initdata em7210_i2c_devices[] = { { I2C_BOARD_INFO("rs5c372a", 0x32), }, }; /* * EM7210 I/O */ static struct map_desc em7210_io_desc[] __initdata = { { /* on-board devices */ .virtual = IQ31244_UART, .pfn = __phys_to_pfn(IQ31244_UART), .length = 0x00100000, .type = MT_DEVICE, }, }; void __init em7210_map_io(void) { iop3xx_map_io(); iotable_init(em7210_io_desc, ARRAY_SIZE(em7210_io_desc)); } /* * EM7210 PCI */ #define INTA IRQ_IOP32X_XINT0 #define INTB IRQ_IOP32X_XINT1 #define INTC IRQ_IOP32X_XINT2 #define INTD IRQ_IOP32X_XINT3 static int __init em7210_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) { static int pci_irq_table[][4] = { /* * PCI IDSEL/INTPIN->INTLINE * A B C D */ {INTB, INTB, INTB, INTB}, /* console / uart */ {INTA, INTA, INTA, INTA}, /* 1st 82541 */ {INTD, INTD, INTD, INTD}, /* 2nd 82541 */ {INTC, INTC, INTC, INTC}, /* GD31244 */ {INTD, INTA, INTA, INTA}, /* mini-PCI */ {INTD, INTC, INTA, INTA}, /* NEC USB */ }; if (pin < 1 || pin > 4) return -1; return pci_irq_table[slot % 6][pin - 1]; } static struct hw_pci em7210_pci __initdata = { .nr_controllers = 1, .ops = &iop3xx_ops, .setup = iop3xx_pci_setup, .preinit = iop3xx_pci_preinit, .map_irq = em7210_pci_map_irq, }; static int __init em7210_pci_init(void) { if (machine_is_em7210()) pci_common_init(&em7210_pci); return 0; } subsys_initcall(em7210_pci_init); /* * EM7210 Flash */ static struct physmap_flash_data em7210_flash_data = { .width = 2, }; static struct resource em7210_flash_resource = { .start = 0xf0000000, .end = 0xf1ffffff, .flags = IORESOURCE_MEM, }; static struct platform_device em7210_flash_device = { .name = "physmap-flash", .id = 0, .dev = { .platform_data = &em7210_flash_data, }, .num_resources = 1, .resource = &em7210_flash_resource, }; /* * EM7210 UART * The physical address of the serial port is 0xfe800000, * so it can be used for physical and virtual address. */ static struct plat_serial8250_port em7210_serial_port[] = { { .mapbase = IQ31244_UART, .membase = (char *)IQ31244_UART, .irq = IRQ_IOP32X_XINT1, .flags = UPF_SKIP_TEST, .iotype = UPIO_MEM, .regshift = 0, .uartclk = 1843200, }, { }, }; static struct resource em7210_uart_resource = { .start = IQ31244_UART, .end = IQ31244_UART + 7, .flags = IORESOURCE_MEM, }; static struct platform_device em7210_serial_device = { .name = "serial8250", .id = PLAT8250_DEV_PLATFORM, .dev = { .platform_data = em7210_serial_port, }, .num_resources = 1, .resource = &em7210_uart_resource, }; #define EM7210_HARDWARE_POWER 0 void em7210_power_off(void) { int ret; ret = gpio_direction_output(EM7210_HARDWARE_POWER, 1); if (ret) pr_crit("could not drive power off GPIO high\n"); } static int __init em7210_request_gpios(void) { int ret; if (!machine_is_em7210()) return 0; ret = gpio_request(EM7210_HARDWARE_POWER, "power"); if (ret) { pr_err("could not request power off GPIO\n"); return 0; } pm_power_off = em7210_power_off; return 0; } device_initcall(em7210_request_gpios); static void __init em7210_init_machine(void) { register_iop32x_gpio(); platform_device_register(&em7210_serial_device); platform_device_register(&iop3xx_i2c0_device); platform_device_register(&iop3xx_i2c1_device); platform_device_register(&em7210_flash_device); platform_device_register(&iop3xx_dma_0_channel); platform_device_register(&iop3xx_dma_1_channel); i2c_register_board_info(0, em7210_i2c_devices, ARRAY_SIZE(em7210_i2c_devices)); } MACHINE_START(EM7210, "Lanner EM7210") .atag_offset = 0x100, .map_io = em7210_map_io, .init_irq = iop32x_init_irq, .init_time = em7210_timer_init, .init_machine = em7210_init_machine, .restart = iop3xx_restart, MACHINE_END
/* Release the parts of a point object. */ void mpi_point_free_parts(MPI_POINT p) { mpi_free(p->x); p->x = NULL; mpi_free(p->y); p->y = NULL; mpi_free(p->z); p->z = NULL; }
/** * Simple function to return the type of the array. */ static int32_t interface_arrayType(void) { return sidl_interface_array; }
/* Clear runtime params and encoding buffer */ static pj_status_t fec_enc_reset(void *user_data, pj_uint16_t n, pj_uint16_t len) { struct tp_adapter *a = (struct tp_adapter *)user_data; pj_uint16_t esi; if (!a) return PJ_EINVAL; for (esi = 0; esi < n; esi++) { memset(a->enc_symbols_ptr[esi], 0, len); a->enc_symbols_size[esi] = 0; } a->snd_k = 0; a->snd_len = 0; a->snd_ready = PJ_FALSE; return PJ_SUCCESS; }
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #ifndef mozilla_EventQueue_h #define mozilla_EventQueue_h #include "mozilla/Mutex.h" #include "mozilla/Queue.h" #include "mozilla/TimeStamp.h" #include "nsCOMPtr.h" class nsIRunnable; namespace mozilla { #define EVENT_QUEUE_PRIORITY_LIST(EVENT_PRIORITY) \ EVENT_PRIORITY(Idle, 0) \ EVENT_PRIORITY(DeferredTimers, 1) \ EVENT_PRIORITY(Low, 2) \ EVENT_PRIORITY(InputLow, 3) \ EVENT_PRIORITY(Normal, 4) \ EVENT_PRIORITY(MediumHigh, 5) \ EVENT_PRIORITY(InputHigh, 6) \ EVENT_PRIORITY(Vsync, 7) \ EVENT_PRIORITY(InputHighest, 8) \ EVENT_PRIORITY(RenderBlocking, 9) \ EVENT_PRIORITY(Control, 10) enum class EventQueuePriority { #define EVENT_PRIORITY(NAME, VALUE) NAME = VALUE, EVENT_QUEUE_PRIORITY_LIST(EVENT_PRIORITY) #undef EVENT_PRIORITY Invalid }; class IdlePeriodState; namespace detail { // EventQueue is our unsynchronized event queue implementation. It is a queue // of runnables used for non-main thread, as well as optionally providing // forwarding to TaskController. // // Since EventQueue is unsynchronized, it should be wrapped in an outer // SynchronizedEventQueue implementation (like ThreadEventQueue). template <size_t ItemsPerPage> class EventQueueInternal { public: explicit EventQueueInternal(bool aForwardToTC) : mForwardToTC(aForwardToTC) {} // Add an event to the end of the queue. Implementors are free to use // aPriority however they wish. If the runnable supports // nsIRunnablePriority and the implementing class supports // prioritization, aPriority represents the result of calling // nsIRunnablePriority::GetPriority(). *aDelay is time the event has // already been delayed (used when moving an event from one queue to // another) void PutEvent(already_AddRefed<nsIRunnable>&& aEvent, EventQueuePriority aPriority, const MutexAutoLock& aProofOfLock, mozilla::TimeDuration* aDelay = nullptr); // Get an event from the front of the queue. This should return null if the // queue is non-empty but the event in front is not ready to run. // *aLastEventDelay is the time the event spent in queues before being // retrieved. already_AddRefed<nsIRunnable> GetEvent( const MutexAutoLock& aProofOfLock, mozilla::TimeDuration* aLastEventDelay = nullptr); // Returns true if the queue is empty. Implies !HasReadyEvent(). bool IsEmpty(const MutexAutoLock& aProofOfLock); // Returns true if the queue is non-empty and if the event in front is ready // to run. Implies !IsEmpty(). This should return true iff GetEvent returns a // non-null value. bool HasReadyEvent(const MutexAutoLock& aProofOfLock); // Returns the number of events in the queue. size_t Count(const MutexAutoLock& aProofOfLock) const; // For some reason, if we put this in the .cpp file the linker can't find it already_AddRefed<nsIRunnable> PeekEvent(const MutexAutoLock& aProofOfLock) { if (mQueue.IsEmpty()) { return nullptr; } nsCOMPtr<nsIRunnable> result = mQueue.FirstElement(); return result.forget(); } void EnableInputEventPrioritization(const MutexAutoLock& aProofOfLock) {} void FlushInputEventPrioritization(const MutexAutoLock& aProofOfLock) {} void SuspendInputEventPrioritization(const MutexAutoLock& aProofOfLock) {} void ResumeInputEventPrioritization(const MutexAutoLock& aProofOfLock) {} size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf); } size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { size_t size = mQueue.ShallowSizeOfExcludingThis(aMallocSizeOf); size += mDispatchTimes.ShallowSizeOfExcludingThis(aMallocSizeOf); return size; } private: mozilla::Queue<nsCOMPtr<nsIRunnable>, ItemsPerPage> mQueue; // This queue is only populated when the profiler is turned on. mozilla::Queue<mozilla::TimeStamp, ItemsPerPage> mDispatchTimes; TimeDuration mLastEventDelay; // This indicates PutEvent forwards runnables to the TaskController. This // should be true for the top level event queue on the main thread. bool mForwardToTC; }; } // namespace detail class EventQueue final : public mozilla::detail::EventQueueInternal<16> { public: explicit EventQueue(bool aForwardToTC = false) : mozilla::detail::EventQueueInternal<16>(aForwardToTC) {} }; template <size_t ItemsPerPage = 16> class EventQueueSized final : public mozilla::detail::EventQueueInternal<ItemsPerPage> { public: explicit EventQueueSized(bool aForwardToTC = false) : mozilla::detail::EventQueueInternal<ItemsPerPage>(aForwardToTC) {} }; } // namespace mozilla #endif // mozilla_EventQueue_h
/* * Parses scope id. * Scope id is ulong on Windows, uint32 on unix, so returns long which can be cast to uint32. * On error sets last error and returns -1. */ static long parseScopeId(const char *str) { unsigned long scopeId = if_nametoindex(str); if (scopeId == 0) { char *end; scopeId = strtoul(str, &end, 10); if (*end != '\0') { setLastError(JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT, "failed to parse scope"); return -1; } } if (scopeId > 0xFFFFFFFF) { setLastError(JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT, "scope is out of range"); return -1; } return (long)scopeId; }
/******************************************************************************* ** ** Function ones32 ** ** Description This function returns number of bits set in an unsigned ** integer variable ** ** Returns int ** *******************************************************************************/ static unsigned int tags_ones32 (register unsigned int x) { x -= ((x >> 1) & 0x55555555); x = (((x >> 2) & 0x33333333) + (x & 0x33333333)); x = (((x >> 4) + x) & 0x0f0f0f0f); x += (x >> 8); x += (x >> 16); return (x & 0x0000003f); }
/** * read buffer block from disk * @param file: file structure * @return success or not */ int ext2_read_block(EXT2_FILE *file) { if (file->pointer >= file->inode.info.i_size) { return EXT2_FAIL; } __u32 b_id = ext2_find_block(file->pointer / fs_info.block_size, file->inode.info.i_block); if (b_id == EXT2_FAIL) { return EXT2_FAIL; } sd_read_block(file->buffer, fs_info.par_start_address + b_id * (fs_info.block_size / 512), fs_info.block_size / 512); file->dirty = EXT2_NOT_DIRTY; return EXT2_SUCCESS; }
/** * velocity_rx_csum - checksum process * @rd: receive packet descriptor * @skb: network layer packet buffer * * Process the status bits for the received packet and determine * if the checksum was computed and verified by the hardware */ static inline void velocity_rx_csum(struct rx_desc *rd, struct sk_buff *skb) { skb_checksum_none_assert(skb); if (rd->rdesc1.CSM & CSM_IPKT) { if (rd->rdesc1.CSM & CSM_IPOK) { if ((rd->rdesc1.CSM & CSM_TCPKT) || (rd->rdesc1.CSM & CSM_UDPKT)) { if (!(rd->rdesc1.CSM & CSM_TUPOK)) return; } skb->ip_summed = CHECKSUM_UNNECESSARY; } } }
#ifndef Py_CONFIG_H #define Py_CONFIG_H /* pyconfig.h. NOT Generated automatically by configure. This is a manually maintained version used for the Watcom, Borland and Microsoft Visual C++ compilers. It is a standard part of the Python distribution. WINDOWS DEFINES: The code specific to Windows should be wrapped around one of the following #defines MS_WIN64 - Code specific to the MS Win64 API MS_WIN32 - Code specific to the MS Win32 (and Win64) API (obsolete, this covers all supported APIs) MS_WINDOWS - Code specific to Windows, but all versions. Py_ENABLE_SHARED - Code if the Python core is built as a DLL. Also note that neither "_M_IX86" or "_MSC_VER" should be used for any purpose other than "Windows Intel x86 specific" and "Microsoft compiler specific". Therefore, these should be very rare. NOTE: The following symbols are deprecated: NT, USE_DL_EXPORT, USE_DL_IMPORT, DL_EXPORT, DL_IMPORT MS_CORE_DLL. WIN32 is still required for the locale module. */ /* Deprecated USE_DL_EXPORT macro - please use Py_BUILD_CORE */ #ifdef USE_DL_EXPORT # define Py_BUILD_CORE #endif /* USE_DL_EXPORT */ /* Visual Studio 2005 introduces deprecation warnings for "insecure" and POSIX functions. The insecure functions should be replaced by *_s versions (according to Microsoft); the POSIX functions by _* versions (which, according to Microsoft, would be ISO C conforming). Neither renaming is feasible, so we just silence the warnings. */ #ifndef _CRT_SECURE_NO_DEPRECATE #define _CRT_SECURE_NO_DEPRECATE 1 #endif #ifndef _CRT_NONSTDC_NO_DEPRECATE #define _CRT_NONSTDC_NO_DEPRECATE 1 #endif #define HAVE_IO_H #define HAVE_SYS_UTIME_H #define HAVE_TEMPNAM #define HAVE_TMPFILE #define HAVE_TMPNAM #define HAVE_CLOCK #define HAVE_STRERROR #include <io.h> #define HAVE_STRFTIME #define DONT_HAVE_SIG_ALARM #define DONT_HAVE_SIG_PAUSE #define LONG_BIT 32 #define WORD_BIT 32 #define MS_WIN32 /* only support win32 and greater. */ #define MS_WINDOWS #define NT_THREADS #define WITH_THREAD #ifndef NETSCAPE_PI #define USE_SOCKET #endif #if defined(Py_BUILD_CORE) || defined(Py_BUILD_CORE_BUILTIN) || defined(Py_BUILD_CORE_MODULE) #include <winapifamily.h> #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) #define MS_WINDOWS_DESKTOP #endif #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) #define MS_WINDOWS_APP #endif #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_SYSTEM) #define MS_WINDOWS_SYSTEM #endif #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_GAMES) #define MS_WINDOWS_GAMES #endif /* Define to 1 if you support windows console io */ #if defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_APP) || defined(MS_WINDOWS_SYSTEM) #define HAVE_WINDOWS_CONSOLE_IO 1 #endif #endif /* Py_BUILD_CORE || Py_BUILD_CORE_BUILTIN || Py_BUILD_CORE_MODULE */ /* Compiler specific defines */ /* ------------------------------------------------------------------------*/ /* Microsoft C defines _MSC_VER, as does clang-cl.exe */ #ifdef _MSC_VER /* We want COMPILER to expand to a string containing _MSC_VER's *value*. * This is horridly tricky, because the stringization operator only works * on macro arguments, and doesn't evaluate macros passed *as* arguments. */ #define _Py_PASTE_VERSION(SUFFIX) \ ("[MSC v." _Py_STRINGIZE(_MSC_VER) " " SUFFIX "]") /* e.g., this produces, after compile-time string catenation, * ("[MSC v.1900 64 bit (Intel)]") * * _Py_STRINGIZE(_MSC_VER) expands to * _Py_STRINGIZE1(_MSC_VER) and this second macro call is scanned * again for macros and so further expands to * _Py_STRINGIZE1(1900) which then expands to * "1900" */ #define _Py_STRINGIZE(X) _Py_STRINGIZE1(X) #define _Py_STRINGIZE1(X) #X /* MSVC defines _WINxx to differentiate the windows platform types Note that for compatibility reasons _WIN32 is defined on Win32 *and* on Win64. For the same reasons, in Python, MS_WIN32 is defined on Win32 *and* Win64. Win32 only code must therefore be guarded as follows: #if defined(MS_WIN32) && !defined(MS_WIN64) */ #ifdef _WIN64 #define MS_WIN64 #endif /* set the COMPILER and support tier * * win_amd64 MSVC (x86_64-pc-windows-msvc): 1 * win32 MSVC (i686-pc-windows-msvc): 1 * win_arm64 MSVC (aarch64-pc-windows-msvc): 3 * other archs and ICC: 0 */ #ifdef MS_WIN64 #if defined(_M_X64) || defined(_M_AMD64) #if defined(__clang__) #define COMPILER ("[Clang " __clang_version__ "] 64 bit (AMD64) with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]") #define PY_SUPPORT_TIER 0 #elif defined(__INTEL_COMPILER) #define COMPILER ("[ICC v." _Py_STRINGIZE(__INTEL_COMPILER) " 64 bit (amd64) with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]") #define PY_SUPPORT_TIER 0 #else #define COMPILER _Py_PASTE_VERSION("64 bit (AMD64)") #define PY_SUPPORT_TIER 1 #endif /* __clang__ */ #define PYD_PLATFORM_TAG "win_amd64" #elif defined(_M_ARM64) #define COMPILER _Py_PASTE_VERSION("64 bit (ARM64)") #define PY_SUPPORT_TIER 3 #define PYD_PLATFORM_TAG "win_arm64" #else #define COMPILER _Py_PASTE_VERSION("64 bit (Unknown)") #define PY_SUPPORT_TIER 0 #endif #endif /* MS_WIN64 */ /* set the version macros for the windows headers */ /* Python 3.9+ requires Windows 8 or greater */ #define Py_WINVER 0x0602 /* _WIN32_WINNT_WIN8 */ #define Py_NTDDI NTDDI_WIN8 /* We only set these values when building Python - we don't want to force these values on extensions, as that will affect the prototypes and structures exposed in the Windows headers. Even when building Python, we allow a single source file to override this - they may need access to structures etc so it can optionally use new Windows features if it determines at runtime they are available. */ #if defined(Py_BUILD_CORE) || defined(Py_BUILD_CORE_BUILTIN) || defined(Py_BUILD_CORE_MODULE) #ifndef NTDDI_VERSION #define NTDDI_VERSION Py_NTDDI #endif #ifndef WINVER #define WINVER Py_WINVER #endif #ifndef _WIN32_WINNT #define _WIN32_WINNT Py_WINVER #endif #endif /* _W64 is not defined for VC6 or eVC4 */ #ifndef _W64 #define _W64 #endif /* Define like size_t, omitting the "unsigned" */ #ifdef MS_WIN64 typedef __int64 Py_ssize_t; # define PY_SSIZE_T_MAX LLONG_MAX #else typedef _W64 int Py_ssize_t; # define PY_SSIZE_T_MAX INT_MAX #endif #define HAVE_PY_SSIZE_T 1 #if defined(MS_WIN32) && !defined(MS_WIN64) #if defined(_M_IX86) #if defined(__clang__) #define COMPILER ("[Clang " __clang_version__ "] 32 bit (Intel) with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]") #define PY_SUPPORT_TIER 0 #elif defined(__INTEL_COMPILER) #define COMPILER ("[ICC v." _Py_STRINGIZE(__INTEL_COMPILER) " 32 bit (Intel) with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]") #define PY_SUPPORT_TIER 0 #else #define COMPILER _Py_PASTE_VERSION("32 bit (Intel)") #define PY_SUPPORT_TIER 1 #endif /* __clang__ */ #define PYD_PLATFORM_TAG "win32" #elif defined(_M_ARM) #define COMPILER _Py_PASTE_VERSION("32 bit (ARM)") #define PYD_PLATFORM_TAG "win_arm32" #define PY_SUPPORT_TIER 0 #else #define COMPILER _Py_PASTE_VERSION("32 bit (Unknown)") #define PY_SUPPORT_TIER 0 #endif #endif /* MS_WIN32 && !MS_WIN64 */ typedef int pid_t; /* define some ANSI types that are not defined in earlier Win headers */ #if _MSC_VER >= 1200 /* This file only exists in VC 6.0 or higher */ #include <basetsd.h> #endif #endif /* _MSC_VER */ /* ------------------------------------------------------------------------*/ /* mingw and mingw-w64 define __MINGW32__ */ #ifdef __MINGW32__ #ifdef _WIN64 #define MS_WIN64 #endif #endif /* __MINGW32__*/ /* ------------------------------------------------------------------------*/ /* egcs/gnu-win32 defines __GNUC__ and _WIN32 */ #if defined(__GNUC__) && defined(_WIN32) /* XXX These defines are likely incomplete, but should be easy to fix. They should be complete enough to build extension modules. */ /* Suggested by Rene Liebscher <R.Liebscher@gmx.de> to avoid a GCC 2.91.* bug that requires structure imports. More recent versions of the compiler don't exhibit this bug. */ #if (__GNUC__==2) && (__GNUC_MINOR__<=91) #warning "Please use an up-to-date version of gcc! (>2.91 recommended)" #endif #define COMPILER "[gcc]" #define PY_LONG_LONG long long #define PY_LLONG_MIN LLONG_MIN #define PY_LLONG_MAX LLONG_MAX #define PY_ULLONG_MAX ULLONG_MAX #endif /* GNUC */ /* ------------------------------------------------------------------------*/ /* lcc-win32 defines __LCC__ */ #if defined(__LCC__) /* XXX These defines are likely incomplete, but should be easy to fix. They should be complete enough to build extension modules. */ #define COMPILER "[lcc-win32]" typedef int pid_t; /* __declspec() is supported here too - do nothing to get the defaults */ #endif /* LCC */ /* ------------------------------------------------------------------------*/ /* End of compilers - finish up */ #ifndef NO_STDIO_H # include <stdio.h> #endif /* 64 bit ints are usually spelt __int64 unless compiler has overridden */ #ifndef PY_LONG_LONG # define PY_LONG_LONG __int64 # define PY_LLONG_MAX _I64_MAX # define PY_LLONG_MIN _I64_MIN # define PY_ULLONG_MAX _UI64_MAX #endif /* For Windows the Python core is in a DLL by default. Test Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */ #if !defined(MS_NO_COREDLL) && !defined(Py_NO_ENABLE_SHARED) # define Py_ENABLE_SHARED 1 /* standard symbol for shared library */ # define MS_COREDLL /* deprecated old symbol */ #endif /* !MS_NO_COREDLL && ... */ /* All windows compilers that use this header support __declspec */ #define HAVE_DECLSPEC_DLL /* For an MSVC DLL, we can nominate the .lib files used by extensions */ #ifdef MS_COREDLL # if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN) /* not building the core - must be an ext */ # if defined(_MSC_VER) /* So MSVC users need not specify the .lib file in their Makefile (other compilers are generally taken care of by distutils.) */ # if defined(_DEBUG) # pragma comment(lib,"python313_d.lib") # elif defined(Py_LIMITED_API) # pragma comment(lib,"python3.lib") # else # pragma comment(lib,"python313.lib") # endif /* _DEBUG */ # endif /* _MSC_VER */ # endif /* Py_BUILD_CORE */ #endif /* MS_COREDLL */ #ifdef MS_WIN64 /* maintain "win32" sys.platform for backward compatibility of Python code, the Win64 API should be close enough to the Win32 API to make this preferable */ # define PLATFORM "win32" # define SIZEOF_VOID_P 8 # define SIZEOF_TIME_T 8 # define SIZEOF_OFF_T 4 # define SIZEOF_FPOS_T 8 # define SIZEOF_HKEY 8 # define SIZEOF_SIZE_T 8 # define ALIGNOF_SIZE_T 8 # define ALIGNOF_MAX_ALIGN_T 8 /* configure.ac defines HAVE_LARGEFILE_SUPPORT iff sizeof(off_t) > sizeof(long), and sizeof(long long) >= sizeof(off_t). On Win64 the second condition is not true, but if fpos_t replaces off_t then this is true. The uses of HAVE_LARGEFILE_SUPPORT imply that Win64 should define this. */ # define HAVE_LARGEFILE_SUPPORT #elif defined(MS_WIN32) # define PLATFORM "win32" # define HAVE_LARGEFILE_SUPPORT # define SIZEOF_VOID_P 4 # define SIZEOF_OFF_T 4 # define SIZEOF_FPOS_T 8 # define SIZEOF_HKEY 4 # define SIZEOF_SIZE_T 4 # define ALIGNOF_SIZE_T 4 /* MS VS2005 changes time_t to a 64-bit type on all platforms */ # if defined(_MSC_VER) && _MSC_VER >= 1400 # define SIZEOF_TIME_T 8 # else # define SIZEOF_TIME_T 4 # endif # define ALIGNOF_MAX_ALIGN_T 8 #endif #ifdef _DEBUG # define Py_DEBUG #endif #ifdef MS_WIN32 #define SIZEOF_SHORT 2 #define SIZEOF_INT 4 #define SIZEOF_LONG 4 #define ALIGNOF_LONG 4 #define SIZEOF_LONG_LONG 8 #define SIZEOF_DOUBLE 8 #define SIZEOF_FLOAT 4 /* VC 7.1 has them and VC 6.0 does not. VC 6.0 has a version number of 1200. Microsoft eMbedded Visual C++ 4.0 has a version number of 1201 and doesn't define these. If some compiler does not provide them, modify the #if appropriately. */ #if defined(_MSC_VER) #if _MSC_VER > 1300 #define HAVE_UINTPTR_T 1 #define HAVE_INTPTR_T 1 #else /* VC6, VS 2002 and eVC4 don't support the C99 LL suffix for 64-bit integer literals */ #define Py_LL(x) x##I64 #endif /* _MSC_VER > 1300 */ #endif /* _MSC_VER */ #endif /* define signed and unsigned exact-width 32-bit and 64-bit types, used in the implementation of Python integers. */ #define PY_UINT32_T uint32_t #define PY_UINT64_T uint64_t #define PY_INT32_T int32_t #define PY_INT64_T int64_t /* Fairly standard from here! */ /* Define if on AIX 3. System headers sometimes define this. We just want to avoid a redefinition error message. */ #ifndef _ALL_SOURCE /* #undef _ALL_SOURCE */ #endif /* Define to empty if the keyword does not work. */ /* #define const */ /* Define to 1 if you have the <conio.h> header file. */ #define HAVE_CONIO_H 1 /* Define to 1 if you have the <direct.h> header file. */ #define HAVE_DIRECT_H 1 /* Define to 1 if you have the declaration of `tzname', and to 0 if you don't. */ #define HAVE_DECL_TZNAME 1 /* Define if you have dirent.h. */ /* #define DIRENT 1 */ /* Define to the type of elements in the array set by `getgroups'. Usually this is either `int' or `gid_t'. */ /* #undef GETGROUPS_T */ /* Define to `int' if <sys/types.h> doesn't define. */ /* #undef gid_t */ /* Define if your struct tm has tm_zone. */ /* #undef HAVE_TM_ZONE */ /* Define if you don't have tm_zone but do have the external array tzname. */ #define HAVE_TZNAME /* Define to `int' if <sys/types.h> doesn't define. */ /* #undef mode_t */ /* Define if you don't have dirent.h, but have ndir.h. */ /* #undef NDIR */ /* Define to `long' if <sys/types.h> doesn't define. */ /* #undef off_t */ /* Define to `int' if <sys/types.h> doesn't define. */ /* #undef pid_t */ /* Define if the system does not provide POSIX.1 features except with this defined. */ /* #undef _POSIX_1_SOURCE */ /* Define if you need to in order for stat and other things to work. */ /* #undef _POSIX_SOURCE */ /* Define as the return type of signal handlers (int or void). */ #define RETSIGTYPE void /* Define to `unsigned' if <sys/types.h> doesn't define. */ /* #undef size_t */ /* Define if you have the ANSI C header files. */ #define STDC_HEADERS 1 /* Define if you don't have dirent.h, but have sys/dir.h. */ /* #undef SYSDIR */ /* Define if you don't have dirent.h, but have sys/ndir.h. */ /* #undef SYSNDIR */ /* Define if you can safely include both <sys/time.h> and <time.h>. */ /* #undef TIME_WITH_SYS_TIME */ /* Define if your <sys/time.h> declares struct tm. */ /* #define TM_IN_SYS_TIME 1 */ /* Define to `int' if <sys/types.h> doesn't define. */ /* #undef uid_t */ /* Define if the closedir function returns void instead of int. */ /* #undef VOID_CLOSEDIR */ /* Define if getpgrp() must be called as getpgrp(0) and (consequently) setpgrp() as setpgrp(0, 0). */ /* #undef GETPGRP_HAVE_ARGS */ /* Define this if your time.h defines altzone */ /* #define HAVE_ALTZONE */ /* Define if you have the putenv function. */ #define HAVE_PUTENV /* Define if your compiler supports function prototypes */ #define HAVE_PROTOTYPES /* Define if you can safely include both <sys/select.h> and <sys/time.h> (which you can't on SCO ODT 3.0). */ /* #undef SYS_SELECT_WITH_SYS_TIME */ /* Define if you want build the _decimal module using a coroutine-local rather than a thread-local context */ #define WITH_DECIMAL_CONTEXTVAR 1 /* Define if you want documentation strings in extension modules */ #define WITH_DOC_STRINGS 1 /* Define if you want to compile in rudimentary thread support */ /* #undef WITH_THREAD */ /* Define if you want to use the GNU readline library */ /* #define WITH_READLINE 1 */ /* Use Python's own small-block memory-allocator. */ #define WITH_PYMALLOC 1 /* Define if you want to compile in object freelists optimization */ #define WITH_FREELISTS 1 /* Define if you have clock. */ /* #define HAVE_CLOCK */ /* Define when any dynamic module loading is enabled */ #define HAVE_DYNAMIC_LOADING /* Define if you have ftime. */ #define HAVE_FTIME /* Define if you have getpeername. */ #define HAVE_GETPEERNAME /* Define if you have getpgrp. */ /* #undef HAVE_GETPGRP */ /* Define if you have getpid. */ #define HAVE_GETPID /* Define if you have gettimeofday. */ /* #undef HAVE_GETTIMEOFDAY */ /* Define if you have getwd. */ /* #undef HAVE_GETWD */ /* Define if you have lstat. */ /* #undef HAVE_LSTAT */ /* Define if you have the mktime function. */ #define HAVE_MKTIME /* Define if you have nice. */ /* #undef HAVE_NICE */ /* Define if you have readlink. */ /* #undef HAVE_READLINK */ /* Define if you have setpgid. */ /* #undef HAVE_SETPGID */ /* Define if you have setpgrp. */ /* #undef HAVE_SETPGRP */ /* Define if you have setsid. */ /* #undef HAVE_SETSID */ /* Define if you have setvbuf. */ #define HAVE_SETVBUF /* Define if you have siginterrupt. */ /* #undef HAVE_SIGINTERRUPT */ /* Define to 1 if you have the `shutdown' function. */ #define HAVE_SHUTDOWN 1 /* Define if you have symlink. */ /* #undef HAVE_SYMLINK */ /* Define if you have tcgetpgrp. */ /* #undef HAVE_TCGETPGRP */ /* Define if you have tcsetpgrp. */ /* #undef HAVE_TCSETPGRP */ /* Define if you have times. */ /* #undef HAVE_TIMES */ /* Define to 1 if you have the `umask' function. */ #define HAVE_UMASK 1 /* Define if you have uname. */ /* #undef HAVE_UNAME */ /* Define if you have waitpid. */ /* #undef HAVE_WAITPID */ /* Define to 1 if you have the `wcsftime' function. */ #if defined(_MSC_VER) && _MSC_VER >= 1310 #define HAVE_WCSFTIME 1 #endif /* Define to 1 if you have the `wcscoll' function. */ #define HAVE_WCSCOLL 1 /* Define to 1 if you have the `wcsxfrm' function. */ #define HAVE_WCSXFRM 1 /* Define if the zlib library has inflateCopy */ #define HAVE_ZLIB_COPY 1 /* Define if you have the <dlfcn.h> header file. */ /* #undef HAVE_DLFCN_H */ /* Define to 1 if you have the <errno.h> header file. */ #define HAVE_ERRNO_H 1 /* Define if you have the <fcntl.h> header file. */ #define HAVE_FCNTL_H 1 /* Define to 1 if you have the <process.h> header file. */ #define HAVE_PROCESS_H 1 /* Define to 1 if you have the <signal.h> header file. */ #define HAVE_SIGNAL_H 1 /* Define if you have the <stddef.h> header file. */ #define HAVE_STDDEF_H 1 /* Define if you have the <sys/audioio.h> header file. */ /* #undef HAVE_SYS_AUDIOIO_H */ /* Define if you have the <sys/param.h> header file. */ /* #define HAVE_SYS_PARAM_H 1 */ /* Define if you have the <sys/select.h> header file. */ /* #define HAVE_SYS_SELECT_H 1 */ /* Define to 1 if you have the <sys/stat.h> header file. */ #define HAVE_SYS_STAT_H 1 /* Define if you have the <sys/time.h> header file. */ /* #define HAVE_SYS_TIME_H 1 */ /* Define if you have the <sys/times.h> header file. */ /* #define HAVE_SYS_TIMES_H 1 */ /* Define to 1 if you have the <sys/types.h> header file. */ #define HAVE_SYS_TYPES_H 1 /* Define if you have the <sys/un.h> header file. */ /* #define HAVE_SYS_UN_H 1 */ /* Define if you have the <sys/utime.h> header file. */ /* #define HAVE_SYS_UTIME_H 1 */ /* Define if you have the <sys/utsname.h> header file. */ /* #define HAVE_SYS_UTSNAME_H 1 */ /* Define if you have the <unistd.h> header file. */ /* #define HAVE_UNISTD_H 1 */ /* Define if you have the <utime.h> header file. */ /* #define HAVE_UTIME_H 1 */ /* Define if the compiler provides a wchar.h header file. */ #define HAVE_WCHAR_H 1 /* The size of `wchar_t', as computed by sizeof. */ #define SIZEOF_WCHAR_T 2 /* The size of `_Bool', as computed by sizeof. */ #define SIZEOF__BOOL 1 /* The size of `pid_t', as computed by sizeof. */ #define SIZEOF_PID_T SIZEOF_INT /* Define if you have the dl library (-ldl). */ /* #undef HAVE_LIBDL */ /* Define if you have the mpc library (-lmpc). */ /* #undef HAVE_LIBMPC */ /* Define if you have the seq library (-lseq). */ /* #undef HAVE_LIBSEQ */ /* Define if you have the socket library (-lsocket). */ #define HAVE_LIBSOCKET 1 /* Define if you have the sun library (-lsun). */ /* #undef HAVE_LIBSUN */ /* Define if you have the termcap library (-ltermcap). */ /* #undef HAVE_LIBTERMCAP */ /* Define if you have the termlib library (-ltermlib). */ /* #undef HAVE_LIBTERMLIB */ /* Define if you have the thread library (-lthread). */ /* #undef HAVE_LIBTHREAD */ /* WinSock does not use a bitmask in select, and uses socket handles greater than FD_SETSIZE */ #define Py_SOCKET_FD_CAN_BE_GE_FD_SETSIZE /* Define if C doubles are 64-bit IEEE 754 binary format, stored with the least significant byte first */ #define DOUBLE_IS_LITTLE_ENDIAN_IEEE754 1 /* Define to 1 if you have the `erf' function. */ #define HAVE_ERF 1 /* Define to 1 if you have the `erfc' function. */ #define HAVE_ERFC 1 // netdb.h functions (provided by winsock.h) #define HAVE_GETHOSTNAME 1 #define HAVE_GETHOSTBYADDR 1 #define HAVE_GETHOSTBYNAME 1 #define HAVE_GETPROTOBYNAME 1 #define HAVE_GETSERVBYNAME 1 #define HAVE_GETSERVBYPORT 1 // sys/socket.h functions (provided by winsock.h) #define HAVE_INET_PTON 1 #define HAVE_INET_NTOA 1 #define HAVE_ACCEPT 1 #define HAVE_BIND 1 #define HAVE_CONNECT 1 #define HAVE_GETSOCKNAME 1 #define HAVE_LISTEN 1 #define HAVE_RECVFROM 1 #define HAVE_SENDTO 1 #define HAVE_SETSOCKOPT 1 #define HAVE_SOCKET 1 /* Define to 1 if you have the `dup' function. */ #define HAVE_DUP 1 /* framework name */ #define _PYTHONFRAMEWORK "" /* Define if libssl has X509_VERIFY_PARAM_set1_host and related function */ #define HAVE_X509_VERIFY_PARAM_SET1_HOST 1 #endif /* !Py_CONFIG_H */
/* SPDX-License-Identifier: BSD-3-Clause * Copyright (c) 2020 Marvell Semiconductor Inc. * All rights reserved. * www.marvell.com */ #include <stdio.h> #include <stdlib.h> #include <fcntl.h> #include <time.h> #include <rte_ethdev.h> #include "base/bcm_osal.h" #include "qede_ethdev.h" int qede_get_regs_len(struct qede_dev *qdev) { struct ecore_dev *edev = &qdev->edev; int cur_engine, num_of_hwfns, regs_len = 0; uint8_t org_engine; if (IS_VF(edev)) return 0; if (qdev->ops && qdev->ops->common) { num_of_hwfns = qdev->dev_info.common.num_hwfns; org_engine = qdev->ops->common->dbg_get_debug_engine(edev); for (cur_engine = 0; cur_engine < num_of_hwfns; cur_engine++) { /* compute required buffer size for idle_chks and * grcDump for each hw function */ DP_NOTICE(edev, false, "Calculating idle_chk and grcdump register length for current engine\n"); qdev->ops->common->dbg_set_debug_engine(edev, cur_engine); regs_len += REGDUMP_HEADER_SIZE + qdev->ops->common->dbg_idle_chk_size(edev) + REGDUMP_HEADER_SIZE + qdev->ops->common->dbg_idle_chk_size(edev) + REGDUMP_HEADER_SIZE + qdev->ops->common->dbg_grc_size(edev) + REGDUMP_HEADER_SIZE + qdev->ops->common->dbg_reg_fifo_size(edev) + REGDUMP_HEADER_SIZE + qdev->ops->common->dbg_protection_override_size(edev) + REGDUMP_HEADER_SIZE + qdev->ops->common->dbg_igu_fifo_size(edev) + REGDUMP_HEADER_SIZE + qdev->ops->common->dbg_fw_asserts_size(edev); } /* compute required buffer size for mcp trace and add it to the * total required buffer size */ regs_len += REGDUMP_HEADER_SIZE + qdev->ops->common->dbg_mcp_trace_size(edev); qdev->ops->common->dbg_set_debug_engine(edev, org_engine); } DP_NOTICE(edev, false, "Total length = %u\n", regs_len); return regs_len; } static uint32_t qede_calc_regdump_header(enum debug_print_features feature, int engine, uint32_t feature_size, uint8_t omit_engine) { /* insert the engine, feature and mode inside the header and * combine it with feature size */ return (feature_size | (feature << REGDUMP_HEADER_FEATURE_SHIFT) | (omit_engine << REGDUMP_HEADER_OMIT_ENGINE_SHIFT) | (engine << REGDUMP_HEADER_ENGINE_SHIFT)); } int qede_get_regs(struct rte_eth_dev *eth_dev, struct rte_dev_reg_info *regs) { struct qede_dev *qdev = eth_dev->data->dev_private; struct ecore_dev *edev = &qdev->edev; uint32_t *buffer = regs->data; int cur_engine, num_of_hwfns; /* '1' tells the parser to omit the engine number in the output files */ uint8_t omit_engine = 0; uint8_t org_engine; uint32_t feature_size; uint32_t offset = 0; if (IS_VF(edev)) return -ENOTSUP; if (buffer == NULL) { regs->length = qede_get_regs_len(qdev); regs->width = sizeof(uint32_t); DP_INFO(edev, "Length %u\n", regs->length); return 0; } memset(buffer, 0, regs->length); num_of_hwfns = qdev->dev_info.common.num_hwfns; if (num_of_hwfns == 1) omit_engine = 1; OSAL_MUTEX_ACQUIRE(&edev->dbg_lock); org_engine = qdev->ops->common->dbg_get_debug_engine(edev); for (cur_engine = 0; cur_engine < num_of_hwfns; cur_engine++) { /* collect idle_chks and grcDump for each hw function */ DP_NOTICE(edev, false, "obtaining idle_chk and grcdump for current engine\n"); qdev->ops->common->dbg_set_debug_engine(edev, cur_engine); /* first idle_chk */ qdev->ops->common->dbg_idle_chk(edev, (uint8_t *)buffer + offset + REGDUMP_HEADER_SIZE, &feature_size); *(uint32_t *)((uint8_t *)buffer + offset) = qede_calc_regdump_header(IDLE_CHK, cur_engine, feature_size, omit_engine); offset += (feature_size + REGDUMP_HEADER_SIZE); DP_NOTICE(edev, false, "Idle Check1 feature_size %u\n", feature_size); /* second idle_chk */ qdev->ops->common->dbg_idle_chk(edev, (uint8_t *)buffer + offset + REGDUMP_HEADER_SIZE, &feature_size); *(uint32_t *)((uint8_t *)buffer + offset) = qede_calc_regdump_header(IDLE_CHK, cur_engine, feature_size, omit_engine); offset += (feature_size + REGDUMP_HEADER_SIZE); DP_NOTICE(edev, false, "Idle Check2 feature_size %u\n", feature_size); /* reg_fifo dump */ qdev->ops->common->dbg_reg_fifo(edev, (uint8_t *)buffer + offset + REGDUMP_HEADER_SIZE, &feature_size); *(uint32_t *)((uint8_t *)buffer + offset) = qede_calc_regdump_header(REG_FIFO, cur_engine, feature_size, omit_engine); offset += (feature_size + REGDUMP_HEADER_SIZE); DP_NOTICE(edev, false, "Reg fifo feature_size %u\n", feature_size); /* igu_fifo dump */ qdev->ops->common->dbg_igu_fifo(edev, (uint8_t *)buffer + offset + REGDUMP_HEADER_SIZE, &feature_size); *(uint32_t *)((uint8_t *)buffer + offset) = qede_calc_regdump_header(IGU_FIFO, cur_engine, feature_size, omit_engine); offset += (feature_size + REGDUMP_HEADER_SIZE); DP_NOTICE(edev, false, "IGU fifo feature_size %u\n", feature_size); /* protection_override dump */ qdev->ops->common->dbg_protection_override(edev, (uint8_t *)buffer + offset + REGDUMP_HEADER_SIZE, &feature_size); *(uint32_t *)((uint8_t *)buffer + offset) = qede_calc_regdump_header(PROTECTION_OVERRIDE, cur_engine, feature_size, omit_engine); offset += (feature_size + REGDUMP_HEADER_SIZE); DP_NOTICE(edev, false, "Protection override feature_size %u\n", feature_size); /* fw_asserts dump */ qdev->ops->common->dbg_fw_asserts(edev, (uint8_t *)buffer + offset + REGDUMP_HEADER_SIZE, &feature_size); *(uint32_t *)((uint8_t *)buffer + offset) = qede_calc_regdump_header(FW_ASSERTS, cur_engine, feature_size, omit_engine); offset += (feature_size + REGDUMP_HEADER_SIZE); DP_NOTICE(edev, false, "FW assert feature_size %u\n", feature_size); /* grc dump */ qdev->ops->common->dbg_grc(edev, (uint8_t *)buffer + offset + REGDUMP_HEADER_SIZE, &feature_size); *(uint32_t *)((uint8_t *)buffer + offset) = qede_calc_regdump_header(GRC_DUMP, cur_engine, feature_size, omit_engine); offset += (feature_size + REGDUMP_HEADER_SIZE); DP_NOTICE(edev, false, "GRC dump feature_size %u\n", feature_size); } /* mcp_trace */ qdev->ops->common->dbg_mcp_trace(edev, (uint8_t *)buffer + offset + REGDUMP_HEADER_SIZE, &feature_size); *(uint32_t *)((uint8_t *)buffer + offset) = qede_calc_regdump_header(MCP_TRACE, cur_engine, feature_size, omit_engine); offset += (feature_size + REGDUMP_HEADER_SIZE); DP_NOTICE(edev, false, "MCP trace feature_size %u\n", feature_size); qdev->ops->common->dbg_set_debug_engine(edev, org_engine); OSAL_MUTEX_RELEASE(&edev->dbg_lock); return 0; } static void qede_set_fw_dump_file_name(struct qede_dev *qdev) { time_t ltime; struct tm *tm; ltime = time(NULL); tm = localtime(&ltime); snprintf(qdev->dump_file, QEDE_FW_DUMP_FILE_SIZE, "qede_pmd_dump_%02d-%02d-%02d_%02d-%02d-%02d.bin", tm->tm_mon + 1, (int)tm->tm_mday, 1900 + tm->tm_year, tm->tm_hour, tm->tm_min, tm->tm_sec); } static int qede_write_fwdump(const char *dump_file, void *dump, size_t len) { int err = 0; FILE *f; size_t bytes; f = fopen(dump_file, "wb+"); if (!f) { fprintf(stderr, "Can't open file %s: %s\n", dump_file, strerror(errno)); return 1; } bytes = fwrite(dump, 1, len, f); if (bytes != len) { fprintf(stderr, "Can not write all of dump data bytes=%zd len=%zd\n", bytes, len); err = 1; } if (fclose(f)) { fprintf(stderr, "Can't close file %s: %s\n", dump_file, strerror(errno)); err = 1; } return err; } int qede_save_fw_dump(uint16_t port_id) { struct rte_eth_dev *eth_dev = &rte_eth_devices[port_id]; struct rte_dev_reg_info regs; struct qede_dev *qdev = eth_dev->data->dev_private; struct ecore_dev *edev = &qdev->edev; int rc = 0; if (!rte_eth_dev_is_valid_port(port_id)) { DP_ERR(edev, "port %u invalid port ID", port_id); return -ENODEV; } memset(&regs, 0, sizeof(regs)); regs.length = qede_get_regs_len(qdev); regs.data = OSAL_ZALLOC(eth_dev, GFP_KERNEL, regs.length); if (regs.data) { qede_get_regs(eth_dev, &regs); qede_set_fw_dump_file_name(qdev); rc = qede_write_fwdump(qdev->dump_file, regs.data, regs.length); if (!rc) DP_NOTICE(edev, false, "FW dump written to %s file\n", qdev->dump_file); OSAL_FREE(edev, regs.data); } return rc; }
#include <stdio.h> int search(int s[],int key,int head,int tail){ if(head>tail)return -1; int mid=(head+tail)/2; if(s[mid]==key)return mid; else if(s[mid]>key)tail=mid-1; else if(s[mid]<key)head=mid+1; return search(s,key,head,tail); } int getLB(int s[],int key,int head,int tail){ if(head>tail){ if(tail<0)return 0; else return tail+1; } int mid=(head+tail)/2; if(s[mid]==key)return -1; else if(s[mid]<key)head=mid+1; else if(s[mid]>key){ if(mid-1>=0&&s[mid-1]<key)return mid; else tail=mid-1; } return getLB(s,key,head,tail); } void sort(int s[],int sCnt,int key,int d){ int i; for(i=sCnt;i>d;i--)s[i]=s[i-1]; s[i]=key; return; } int insert(int s[],int sCnt,int key){ if(search(s,key,0,sCnt-1)!=-1)return -1; int d=getLB(s,key,0,sCnt-1); sort(s,sCnt,key,d); return 0; } int main(void){ int q; scanf("%d\n",&q); int s[q]; int sCnt=0; int com,x; while(q--){ scanf("%d %d\n",&com,&x); switch(com){ case 0: //insert if(insert(s,sCnt,x)==0)sCnt++; printf("%d\n",sCnt); break; case 1: //find if(search(s,x,0,sCnt-1)==-1)printf("0\n"); else printf("1\n"); break; } } return 0; }
/******************************************************************* ** ** CFE_TBL_ReleaseAddress() -- Release previously obtained pointer ** to the contents of the specified table ** ** NOTE: For complete prolog information, see 'cfe_tbl.h' ********************************************************************/ int32 CFE_TBL_ReleaseAddress( CFE_TBL_Handle_t TblHandle ) { int32 Status; uint32 ThisAppId; Status = CFE_TBL_ValidateAccess(TblHandle, &ThisAppId); if (Status == CFE_SUCCESS) { CFE_TBL_TaskData.Handles[TblHandle].LockFlag = FALSE; Status = CFE_TBL_GetNextNotification(TblHandle); } else { CFE_ES_WriteToSysLog("CFE_TBL:ReleaseAddress-App(%d) does not have access to Tbl Handle=%d\n", ThisAppId, TblHandle); } return Status; }
/* * Lookup a param in the environment */ static int var_set_from_env (ocoms_mca_base_var_t *var) { const char *var_full_name = var->mbv_full_name; bool deprecated = VAR_IS_DEPRECATED(var[0]); char *source, *source_env; char *value, *value_env; int ret; if (VAR_IS_SYNONYM(var[0])) { ret = var_get (var->mbv_synonym_for, &var, true); if (OCOMS_SUCCESS != ret) { return OCOMS_ERROR; } if (var->mbv_source >= MCA_BASE_VAR_SOURCE_ENV) { return OCOMS_SUCCESS; } } ret = asprintf (&source, "%sSOURCE_%s", mca_prefix, var_full_name); if (0 > ret) { return OCOMS_ERROR; } ret = asprintf (&value, "%s%s", mca_prefix, var_full_name); if (0 > ret) { free (source); return OCOMS_ERROR; } source_env = getenv (source); value_env = getenv (value); free (source); free (value); if (NULL == value_env) { return OCOMS_ERR_NOT_FOUND; } if (VAR_IS_DEFAULT_ONLY(var[0])) { fprintf(stderr,"%s:%d: default-only-param-set: %s\n", __FILE__,__LINE__, var_full_name); return OCOMS_ERR_NOT_FOUND; } if (MCA_BASE_VAR_SOURCE_OVERRIDE == var->mbv_source) { if (!ocoms_mca_base_var_suppress_override_warning) { fprintf(stderr,"%s:%d: overridden-param-set: %s\n", __FILE__,__LINE__, var_full_name); } return OCOMS_ERR_NOT_FOUND; } var->mbv_source = MCA_BASE_VAR_SOURCE_ENV; if (NULL != source_env) { if (0 == strncasecmp (source_env, "file:", 5)) { var->mbv_source_file = append_filename_to_list(source_env + 5); if (0 == strcmp (var->mbv_source_file, ocoms_mca_base_var_override_file)) { var->mbv_source = MCA_BASE_VAR_SOURCE_OVERRIDE; } else { var->mbv_source = MCA_BASE_VAR_SOURCE_FILE; } } else if (0 == strcasecmp (source_env, "command")) { var->mbv_source = MCA_BASE_VAR_SOURCE_COMMAND_LINE; } } if (deprecated) { switch (var->mbv_source) { case MCA_BASE_VAR_SOURCE_ENV: fprintf(stderr,"%s:%d: deprecated-mca-env %s:%s\n", __FILE__,__LINE__, var->mbv_full_name); break; case MCA_BASE_VAR_SOURCE_COMMAND_LINE: fprintf(stderr,"%s:%d: deprecated-mca-cli %s\n", __FILE__,__LINE__, var->mbv_full_name ); break; case MCA_BASE_VAR_SOURCE_FILE: case MCA_BASE_VAR_SOURCE_OVERRIDE: fprintf(stderr,"%s:%d: deprecated-mca-file: %s:%s\n", __FILE__,__LINE__, var->mbv_full_name, var->mbv_source_file); break; case MCA_BASE_VAR_SOURCE_DEFAULT: case MCA_BASE_VAR_SOURCE_MAX: case MCA_BASE_VAR_SOURCE_SET: break; } } return var_set_from_string (var, value_env); }
/* Similar, but load SRC into new pseudos in a format that looks like PARALLEL. This can later be fed to emit_group_move to get things in the right place. */ rtx emit_group_load_into_temps (rtx parallel, rtx src, tree type, poly_int64 ssize) { rtvec vec; int i; vec = rtvec_alloc (XVECLEN (parallel, 0)); emit_group_load_1 (&RTVEC_ELT (vec, 0), parallel, src, type, ssize); for (i = 0; i < XVECLEN (parallel, 0); i++) { rtx e = XVECEXP (parallel, 0, i); rtx d = XEXP (e, 0); if (d) { d = force_reg (GET_MODE (d), RTVEC_ELT (vec, i)); e = alloc_EXPR_LIST (REG_NOTE_KIND (e), d, XEXP (e, 1)); } RTVEC_ELT (vec, i) = e; } return gen_rtx_PARALLEL (GET_MODE (parallel), vec); }
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2016-2019, Intel Corporation */ /* * rpmem_fip_common.h -- common definitions for librpmem and rpmemd */ #ifndef RPMEM_FIP_COMMON_H #define RPMEM_FIP_COMMON_H 1 #include <string.h> #include <netinet/in.h> #include <rdma/fabric.h> #include <rdma/fi_cm.h> #include <rdma/fi_rma.h> #ifdef __cplusplus extern "C" { #endif #define RPMEM_FIVERSION FI_VERSION(1, 4) #define RPMEM_FIP_CQ_WAIT_MS 100 #define min(a, b) ((a) < (b) ? (a) : (b)) #define max(a, b) ((a) > (b) ? (a) : (b)) /* * rpmem_fip_node -- client or server node type */ enum rpmem_fip_node { RPMEM_FIP_NODE_CLIENT, RPMEM_FIP_NODE_SERVER, MAX_RPMEM_FIP_NODE, }; /* * rpmem_fip_probe -- list of providers */ struct rpmem_fip_probe { unsigned providers; size_t max_wq_size[MAX_RPMEM_PROV]; }; /* * rpmem_fip_probe -- returns true if specified provider is available */ static inline int rpmem_fip_probe(struct rpmem_fip_probe probe, enum rpmem_provider provider) { return (probe.providers & (1U << provider)) != 0; } /* * rpmem_fip_probe_any -- returns true if any provider is available */ static inline int rpmem_fip_probe_any(struct rpmem_fip_probe probe) { return probe.providers != 0; } int rpmem_fip_probe_get(const char *target, struct rpmem_fip_probe *probe); struct fi_info *rpmem_fip_get_hints(enum rpmem_provider provider); int rpmem_fip_read_eq_check(struct fid_eq *eq, struct fi_eq_cm_entry *entry, uint32_t exp_event, fid_t exp_fid, int timeout); int rpmem_fip_read_eq(struct fid_eq *eq, struct fi_eq_cm_entry *entry, uint32_t *event, int timeout); size_t rpmem_fip_cq_size(enum rpmem_persist_method pm, enum rpmem_fip_node node); size_t rpmem_fip_wq_size(enum rpmem_persist_method pm, enum rpmem_fip_node node); size_t rpmem_fip_rx_size(enum rpmem_persist_method pm, enum rpmem_fip_node node); size_t rpmem_fip_max_nlanes(struct fi_info *fi); void rpmem_fip_print_info(struct fi_info *fi); #ifdef __cplusplus } #endif #endif
/* Return nonzero when QImode register that must be represented via REX prefix is used. */ bool x86_extended_QIreg_mentioned_p (rtx insn) { int i; extract_insn_cached (insn); for (i = 0; i < recog_data.n_operands; i++) if (REG_P (recog_data.operand[i]) && REGNO (recog_data.operand[i]) >= 4) return true; return false; }
long long minOperations(int* nums1, int nums1Size, int* nums2, int nums2Size, int k) { if (k == 0) { for (int i = 0; i < nums1Size; i++) { if (nums1[i] != nums2[i]) { return -1; } } return 0; } long long sum1 = 0; long long sum2 = 0; for (int i = 0; i < nums1Size; i++) { long long diff = nums1[i] - nums2[i]; sum1 += diff; if (diff % k != 0) { return -1; } sum2 += llabs(diff); } if (sum1 != 0) { return -1; } return sum2 / (k * 2); }
// ------------------------------------------------------------------------------------------ // Extract a vector from a segment. The vector goes from the start face to the end face. // The point on each face is the average of the four points forming the face. void extract_vector_from_segment(segment *sp, vms_vector *vp, int start, int end) { int i; vms_vector vs,ve; vm_vec_zero(&vs); vm_vec_zero(&ve); for (i=0; i<4; i++) { vm_vec_add2(&vs,&Vertices[sp->verts[Side_to_verts[start][i]]]); vm_vec_add2(&ve,&Vertices[sp->verts[Side_to_verts[end][i]]]); } vm_vec_sub(vp,&ve,&vs); vm_vec_scale(vp,F1_0/4); }
/* * Copyright (c) 2016-2018 Intel Corporation, Inc. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU * General Public License (GPL) Version 2, available from the file * COPYING in the main directory of this source tree, or the * BSD license below: * * Redistribution and use in source and binary forms, with or * without modification, are permitted provided that the following * conditions are met: * * - Redistributions of source code must retain the above * copyright notice, this list of conditions and the following * disclaimer. * * - Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials * provided with the distribution. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #ifndef FI_DIRECT_CM_H #define FI_DIRECT_CM_H #define FABRIC_DIRECT_CM int psmx2_cm_getname(fid_t fid, void *addr, size_t *addrlen); static inline int fi_setname(fid_t fid, void *addr, size_t addrlen) { return -FI_ENOSYS; } static inline int fi_getname(fid_t fid, void *addr, size_t *addrlen) { return psmx2_cm_getname(fid, addr, addrlen); } static inline int fi_getpeer(struct fid_ep *ep, void *addr, size_t *addrlen) { return -FI_ENOSYS; } static inline int fi_listen(struct fid_pep *pep) { return -FI_ENOSYS; } static inline int fi_connect(struct fid_ep *ep, const void *addr, const void *param, size_t paramlen) { return -FI_ENOSYS; } static inline int fi_accept(struct fid_ep *ep, const void *param, size_t paramlen) { return -FI_ENOSYS; } static inline int fi_reject(struct fid_pep *pep, fid_t handle, const void *param, size_t paramlen) { return -FI_ENOSYS; } static inline int fi_shutdown(struct fid_ep *ep, uint64_t flags) { return -FI_ENOSYS; } static inline int fi_join(struct fid_ep *ep, const void *addr, uint64_t flags, struct fid_mc **mc, void *context) { return -FI_ENOSYS; } static inline fi_addr_t fi_mc_addr(struct fid_mc *mc) { return -FI_ENOSYS; } #endif /* FI_DIRECT_CM_H */
#ifndef MaxCCCLostHitsTrajectoryFilter_H #define MaxCCCLostHitsTrajectoryFilter_H #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h" #include "TrackingTools/TrajectoryFiltering/interface/TrajectoryFilter.h" #include "RecoLocalTracker/SiStripClusterizer/interface/ClusterChargeCut.h" class MaxCCCLostHitsTrajectoryFilter final : public TrajectoryFilter { public: explicit MaxCCCLostHitsTrajectoryFilter(int maxCCCHits = 0, float CCC_value = 0) : theMaxCCCLostHits_(maxCCCHits), minGoodStripCharge_(CCC_value) {} explicit MaxCCCLostHitsTrajectoryFilter(const edm::ParameterSet& pset, edm::ConsumesCollector& iC) : theMaxCCCLostHits_(pset.getParameter<int>("maxCCCLostHits")), minGoodStripCharge_(clusterChargeCut(pset, "minGoodStripCharge")) {} static void fillPSetDescription(edm::ParameterSetDescription& iDesc) { iDesc.add<int>("maxCCCLostHits", 9999); iDesc.add<edm::ParameterSetDescription>("minGoodStripCharge", getConfigurationDescription4CCC(CCC::kLoose)); } bool qualityFilter(const Trajectory& traj) const override { return TrajectoryFilter::qualityFilterIfNotContributing; } bool qualityFilter(const TempTrajectory& traj) const override { return TrajectoryFilter::qualityFilterIfNotContributing; } bool toBeContinued(TempTrajectory& traj) const override { return TBC<TempTrajectory>(traj); } bool toBeContinued(Trajectory& traj) const override { return TBC<Trajectory>(traj); } std::string name() const override { return "MaxCCCLostHitsTrajectoryFilter"; } protected: template <class T> bool TBC(T& traj) const { bool ret = (traj.numberOfCCCBadHits(minGoodStripCharge_) <= theMaxCCCLostHits_); if (!ret) traj.setStopReason(StopReason::MAX_CCC_LOST_HITS); return ret; } int theMaxCCCLostHits_; float minGoodStripCharge_; }; #endif
/* * feed a character into the machine (from emulator display) */ unsigned uart_feed(struct machine_t* m, unsigned c){ if (m->regs[REG_FR] & FRBIT_UART1_INRDY) return 1; m->regs[REG_FR] |= FRBIT_UART1_INRDY; m->regs[REG_FR] |= FRBIT_UART1_IN; port_sw(m, mmu_la2pa(m, UART1_IN, NULL, 0), c); return 0; }
// RUN: %clang_builtins %s %librt -o %t && %run %t // REQUIRES: librt_has_subvti3 // REQUIRES: int128 #include "int_lib.h" #include <stdio.h> #include <stdlib.h> #ifdef CRT_HAS_128BIT // Returns: a - b // Effects: aborts if a - b overflows COMPILER_RT_ABI ti_int __subvti3(ti_int a, ti_int b); int test__subvti3(ti_int a, ti_int b) { ti_int x = __subvti3(a, b); ti_int expected = a - b; if (x != expected) { twords at; at.all = a; twords bt; bt.all = b; twords xt; xt.all = x; twords expectedt; expectedt.all = expected; printf("error in test__subvsi3(0x%.16llX%.16llX, 0x%.16llX%.16llX) = " "0x%.16llX%.16llX, expected 0x%.16llX%.16llX\n", at.s.high, at.s.low, bt.s.high, bt.s.low, xt.s.high, xt.s.low, expectedt.s.high, expectedt.s.low); } return x != expected; } #endif int main() { #ifdef CRT_HAS_128BIT // test__subvti3(make_ti(0x8000000000000000LL, 0), 1); // should abort // test__subvti3(0, make_ti(0x8000000000000000LL, 0)); // should abort // test__subvti3(1, make_ti(0x8000000000000000LL, 0)); // should abort // test__subvti3(make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL), -1); // should abort // test__subvti3(-2, make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL)); // should abort if (test__subvti3(make_ti(0x8000000000000000LL, 0), -1)) return 1; if (test__subvti3(make_ti(0x8000000000000000LL, 0), 0)) return 1; if (test__subvti3(-1, make_ti(0x8000000000000000LL, 0))) return 1; if (test__subvti3(make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL), 1)) return 1; if (test__subvti3(make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL), 0)) return 1; if (test__subvti3(1, make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL))) return 1; if (test__subvti3(0, make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL))) return 1; if (test__subvti3(-1, make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL))) return 1; #else printf("skipped\n"); #endif return 0; }
#include<stdio.h> #include<string.h> int main() { int n,ti,s=0,a,b=0,c; char ch[100000]; scanf("%s",ch); if(ch[0]>90)ch[0]=(char)(ch[0]-32); printf("%s\n",ch); }
#pragma once #include <torch/data/example.h> #include <torch/data/transforms/collate.h> #include <torch/types.h> #include <utility> #include <vector> namespace torch { namespace data { namespace transforms { template <typename T = Example<>> struct Stack; /// A `Collation` for `Example<Tensor, Tensor>` types that stacks all data /// tensors into one tensor, and all target (label) tensors into one tensor. template <> struct Stack<Example<>> : public Collation<Example<>> { Example<> apply_batch(std::vector<Example<>> examples) override { std::vector<torch::Tensor> data, targets; data.reserve(examples.size()); targets.reserve(examples.size()); for (auto& example : examples) { data.push_back(std::move(example.data)); targets.push_back(std::move(example.target)); } return {torch::stack(data), torch::stack(targets)}; } }; /// A `Collation` for `Example<Tensor, NoTarget>` types that stacks all data /// tensors into one tensor. template <> struct Stack<TensorExample> : public Collation<Example<Tensor, example::NoTarget>> { TensorExample apply_batch(std::vector<TensorExample> examples) override { std::vector<torch::Tensor> data; data.reserve(examples.size()); for (auto& example : examples) { data.push_back(std::move(example.data)); } return torch::stack(data); } }; } // namespace transforms } // namespace data } // namespace torch
/* Stores x/y in client coordinates. */ static void dinput_pointer_store_pos( struct pointer_status *pointer, WPARAM lParam) { POINT point; point.x = GET_X_LPARAM(lParam); point.y = GET_Y_LPARAM(lParam); ScreenToClient((HWND)video_driver_window_get(), &point); pointer->pointer_x = point.x; pointer->pointer_y = point.y; }
/* * adreno_isidle() - return true if the GPU hardware is idle * @device: Pointer to the KGSL device structure for the GPU * * Return true if the GPU hardware is idle and there are no commands pending in * the ringbuffer */ bool adreno_isidle(struct kgsl_device *device) { struct adreno_device *adreno_dev = ADRENO_DEVICE(device); struct adreno_ringbuffer *rb; int i; if (!kgsl_state_is_awake(device)) return true; smp_mb(); FOR_EACH_RINGBUFFER(adreno_dev, rb, i) { if (!adreno_rb_empty(rb)) return false; } return adreno_hw_isidle(adreno_dev); }
/*========================================================================= * * Copyright NumFOCUS * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0.txt * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * *=========================================================================*/ #ifndef itkPathIterator_h #define itkPathIterator_h #include "itkPathConstIterator.h" namespace itk { /** * \class PathIterator * \brief PathIterator iterates (traces) over a path through an image. * * This iterator visits only those indices of the image which are overlapped by * the path. All indices are visited in path order. If a path crosses itself * at an index, that index of the image will be visited twice. This class add * write-access to the functionality of the PathConstIterator. * * \par MORE INFORMATION * For a complete description of the ITK Image Iterators and their API, please * see the Iterators chapter in the ITK Software Guide. The ITK Software Guide * is available in print and as a free .pdf download from https://www.itk.org. * * \ingroup ImageIterators * * \sa ImageConstIterator \sa ConditionalConstIterator * \sa ConstNeighborhoodIterator \sa ConstShapedNeighborhoodIterator * \sa ConstSliceIterator \sa CorrespondenceDataStructureIterator * \sa FloodFilledFunctionConditionalConstIterator * \sa FloodFilledImageFunctionConditionalConstIterator * \sa FloodFilledImageFunctionConditionalIterator * \sa FloodFilledSpatialFunctionConditionalConstIterator * \sa FloodFilledSpatialFunctionConditionalIterator * \sa ImageConstIterator \sa ImageConstIteratorWithIndex * \sa ImageIterator \sa ImageIteratorWithIndex * \sa ImageLinearConstIteratorWithIndex \sa ImageLinearIteratorWithIndex * \sa ImageRandomConstIteratorWithIndex \sa ImageRandomIteratorWithIndex * \sa ImageRegionConstIterator \sa ImageRegionConstIteratorWithIndex * \sa ImageRegionExclusionConstIteratorWithIndex * \sa ImageRegionExclusionIteratorWithIndex * \sa ImageRegionIterator \sa ImageRegionIteratorWithIndex * \sa ImageRegionReverseConstIterator \sa ImageRegionReverseIterator * \sa ImageReverseConstIterator \sa ImageReverseIterator * \sa ImageSliceConstIteratorWithIndex \sa ImageSliceIteratorWithIndex * \sa NeighborhoodIterator \sa PathConstIterator * \sa ShapedNeighborhoodIterator \sa SliceIterator * \sa ImageConstIteratorWithIndex * * \ingroup PathObjects * \ingroup ITKPath */ template <typename TImage, typename TPath> class ITK_TEMPLATE_EXPORT PathIterator : public PathConstIterator<TImage, TPath> { public: /** Standard class type aliases. */ using Self = PathIterator; /** Dimension of the image the iterator walks. This constant is needed so * that functions that are templated over image iterator type (as opposed to * being templated over pixel type and dimension) can have compile time * access to the dimension of the image that the iterator walks. */ static constexpr unsigned int ImageIteratorDimension = TImage::ImageDimension; /** Define the superclass */ using Superclass = PathConstIterator<TImage, TPath>; /** Inherit types from the superclass */ using typename Superclass::IndexType; using typename Superclass::OffsetType; using typename Superclass::SizeType; using typename Superclass::ImageType; using typename Superclass::PixelContainer; using typename Superclass::PixelContainerPointer; using typename Superclass::InternalPixelType; using typename Superclass::PixelType; using typename Superclass::AccessorType; using typename Superclass::PathType; using typename Superclass::PathInputType; using typename Superclass::PathOutputType; /** Run-time type information (and related methods). */ itkTypeMacro(PathIterator, PathConstIterator); /** Set the pixel value */ void Set(const PixelType & value) { // Normally, this would just be the following: // m_Image->SetPixel(m_CurrentImageIndex,value); // However, we don't want a warning about m_Image being a ConstPointer // in the Superclass. const_cast<ImageType *>(this->m_Image.GetPointer())->SetPixel(this->m_CurrentImageIndex, value); } /** Return a reference to the pixel * This method will provide the fastest access to pixel * data, but it will NOT support ImageAdaptors. */ PixelType & Value() { return this->GetImage()->GetPixel(this->m_ImageIndex); } /** operator= is provided to make sure the handles to the image and path are * properly reference counted. */ Self & operator=(const Self & it); /** Constructor establishes an iterator to walk along a path */ PathIterator(ImageType * imagePtr, const PathType * pathPtr); /** Default Destructor. */ ~PathIterator() override = default; }; } // end namespace itk #ifndef ITK_MANUAL_INSTANTIATION # include "itkPathIterator.hxx" #endif #endif
#include <stdio.h> int res[1048576]; int mark[1048576]; void set(int i, int L, int R, int l, int r, int x) { int LR, RL; if(L <= R && l <= r && L <= l && r <= R && res[i] <= 0 && mark[i] == 0) { if(L == l && R == r) mark[i] = 1; if(res[i] == 0 && L == l && R == r) res[i] = x; else { if(res[i] >= 0) { res[(i << 1) + 1] = res[i]; res[(i << 1) + 2] = res[i]; res[i] = -1; mark[(i << 1) + 1] = 0; mark[(i << 1) + 2] = 0; } LR = L + ((R - L) >> 1); RL = LR + 1; if(l <= LR) { if(r < LR) set((i << 1) + 1, L, LR, l, r, x); else set((i << 1) + 1, L, LR, l, LR, x); } if(r >= RL) { if(l > RL) set((i << 1) + 2, RL, R, l, r, x); else set((i << 1) + 2, RL, R, RL, r, x); } } } } void out(int i, int L, int R) { int j; if(res[i] >= 0) for(j = L; j <= R; j++) printf("%d ", res[i]); else { out((i << 1) + 1, L, L + ((R - L) >> 1)); out((i << 1) + 2, L + ((R - L) >> 1) + 1, R); } } int main() { int i; int n; int m; int l, r, x; #ifndef ONLINE_JUDGE freopen("E:\\tmp\\in", "r", stdin); freopen("E:\\tmp\\out", "w", stdout); #endif scanf("%d%d", &n, &m); res[0] = 0; mark[0] = 0; for(i = 0; i < m; i++) { scanf("%d%d%d", &l, &r, &x); if(x - 1 >= l) set(0, 1, n, l, x - 1, x); if(x + 1 <= r) set(0, 1, n, x + 1, r, x); } out(0, 1, n); return 0; }
/* * Draw a rectangle on the display. * I guess just pick the longer dimension, and either draw * horizontal or vertical lines. * Notable args: * - outline: If <=0, fill the rectangle with 'color'. * If >0, draw an outline inside the dimensions of N pixels. * - color: If 0, clear drawn bits. If not 0, set drawn bits. */ inline void oled_draw_rect(int x, int y, int w, int h, int outline, uint8_t color) { if (outline > 0) { int o_pos; for (o_pos = y; o_pos < (y+outline); ++o_pos) { oled_draw_h_line(x, o_pos, w, color); } for (o_pos = (y+h-1); o_pos > (y+h-1-outline); --o_pos) { oled_draw_h_line(x, o_pos, w, color); } for (o_pos = x; o_pos < (x+outline); ++o_pos) { oled_draw_v_line(o_pos, y, h, color); } for (o_pos = (x+w-1); o_pos > (x+w-1-outline); --o_pos) { oled_draw_v_line(o_pos, y, h, color); } } else { if (w > h) { int y_pos; for (y_pos = y; y_pos < (y+h); ++y_pos) { oled_draw_h_line(x, y_pos, w, color); } } else { int x_pos; for (x_pos = x; x_pos < (x+w); ++x_pos) { oled_draw_v_line(x_pos, y, h, color); } } } }
/* Copyright (c) 2014, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and * only version 2 as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ #define VIDC_DBG_LABEL "venus_boot" #include <linux/kernel.h> #include <linux/err.h> #include <linux/io.h> #include <linux/delay.h> #include <linux/module.h> #include <linux/slab.h> #include <linux/platform_device.h> #include <linux/iommu.h> #include <linux/qcom_iommu.h> #include <linux/iopoll.h> #include <linux/of.h> #include <linux/msm_iommu_domains.h> #include <linux/platform_device.h> #include <linux/sizes.h> #include <linux/regulator/consumer.h> #include <asm/page.h> #include <soc/qcom/subsystem_restart.h> #include <soc/qcom/subsystem_notif.h> #include "msm_vidc_debug.h" #include "vidc_hfi_io.h" #include "venus_boot.h" /* VENUS WRAPPER registers */ #define VENUS_WRAPPER_VBIF_SS_SEC_CPA_START_ADDR_v1 \ (VIDC_WRAPPER_BASE_OFFS + 0x1018) #define VENUS_WRAPPER_VBIF_SS_SEC_CPA_END_ADDR_v1 \ (VIDC_WRAPPER_BASE_OFFS + 0x101C) #define VENUS_WRAPPER_VBIF_SS_SEC_FW_START_ADDR_v1 \ (VIDC_WRAPPER_BASE_OFFS + 0x1020) #define VENUS_WRAPPER_VBIF_SS_SEC_FW_END_ADDR_v1 \ (VIDC_WRAPPER_BASE_OFFS + 0x1024) #define VENUS_WRAPPER_VBIF_SS_SEC_CPA_START_ADDR_v2 \ (VIDC_WRAPPER_BASE_OFFS + 0x1020) #define VENUS_WRAPPER_VBIF_SS_SEC_CPA_END_ADDR_v2 \ (VIDC_WRAPPER_BASE_OFFS + 0x1024) #define VENUS_WRAPPER_VBIF_SS_SEC_FW_START_ADDR_v2 \ (VIDC_WRAPPER_BASE_OFFS + 0x1028) #define VENUS_WRAPPER_VBIF_SS_SEC_FW_END_ADDR_v2 \ (VIDC_WRAPPER_BASE_OFFS + 0x102C) #define VENUS_WRAPPER_SW_RESET (VIDC_WRAPPER_BASE_OFFS + 0x3000) /* VENUS VBIF registers */ #define VENUS_VBIF_CLKON_FORCE_ON BIT(0) #define VENUS_VBIF_ADDR_TRANS_EN (VIDC_VBIF_BASE_OFFS + 0x1000) #define VENUS_VBIF_AT_OLD_BASE (VIDC_VBIF_BASE_OFFS + 0x1004) #define VENUS_VBIF_AT_OLD_HIGH (VIDC_VBIF_BASE_OFFS + 0x1008) #define VENUS_VBIF_AT_NEW_BASE (VIDC_VBIF_BASE_OFFS + 0x1010) #define VENUS_VBIF_AT_NEW_HIGH (VIDC_VBIF_BASE_OFFS + 0x1018) /* Poll interval in uS */ #define POLL_INTERVAL_US 50 #define VENUS_REGION_SIZE 0x00500000 static struct { struct msm_vidc_platform_resources *resources; struct regulator *gdsc; const char *reg_name; void __iomem *reg_base; struct device *iommu_fw_ctx; struct iommu_domain *iommu_fw_domain; int venus_domain_num; bool is_booted; bool hw_ver_checked; u32 fw_sz; u32 hw_ver_major; u32 hw_ver_minor; void *venus_notif_hdle; } *venus_data = NULL; /* Get venus clocks and set rates for rate-settable clocks */ static int venus_clock_setup(struct device *dev) { int i, rc = 0; unsigned long rate; struct msm_vidc_platform_resources *res = venus_data->resources; struct clock_info *cl; for (i = 0; i < res->clock_set.count; i++) { cl = &res->clock_set.clock_tbl[i]; /* Make sure rate-settable clocks' rates are set */ if (clk_get_rate(cl->clk) == 0 && cl->count) { rate = clk_round_rate(cl->clk, 0); rc = clk_set_rate(cl->clk, rate); if (rc) { dprintk(VIDC_ERR, "Failed to set clock rate %lu %s: %d\n", rate, cl->name, rc); break; } } } return rc; } static int venus_clock_prepare_enable(struct device *dev) { int i, rc = 0; struct msm_vidc_platform_resources *res = venus_data->resources; struct clock_info *cl; for (i = 0; i < res->clock_set.count; i++) { cl = &res->clock_set.clock_tbl[i]; rc = clk_prepare_enable(cl->clk); if (rc) { dprintk(VIDC_ERR, "failed to enable %s\n", cl->name); for (i--; i >= 0; i--) { cl = &res->clock_set.clock_tbl[i]; clk_disable_unprepare(cl->clk); } return rc; } } return rc; } static void venus_clock_disable_unprepare(struct device *dev) { int i; struct msm_vidc_platform_resources *res = venus_data->resources; struct clock_info *cl; for (i = 0; i < res->clock_set.count; i++) { cl = &res->clock_set.clock_tbl[i]; clk_disable_unprepare(cl->clk); } } static int venus_register_domain(u32 fw_max_sz) { struct msm_iova_partition venus_fw_partition = { .start = 0, .size = fw_max_sz, }; struct msm_iova_layout venus_fw_layout = { .partitions = &venus_fw_partition, .npartitions = 1, .client_name = "pil_venus", .domain_flags = 0, }; return msm_register_domain(&venus_fw_layout); } static int pil_venus_mem_setup(struct platform_device *pdev, size_t size) { int domain; venus_data->iommu_fw_ctx = msm_iommu_get_ctx("venus_fw"); if (!venus_data->iommu_fw_ctx) { dprintk(VIDC_ERR, "No iommu fw context found\n"); return -ENODEV; } if (!venus_data->venus_domain_num) { size = round_up(size, SZ_4K); domain = venus_register_domain(size); if (domain < 0) { dprintk(VIDC_ERR, "Venus fw iommu domain register failed\n"); return -ENODEV; } venus_data->iommu_fw_domain = msm_get_iommu_domain(domain); if (!venus_data->iommu_fw_domain) { dprintk(VIDC_ERR, "No iommu fw domain found\n"); return -ENODEV; } venus_data->venus_domain_num = domain; venus_data->fw_sz = size; } return 0; } static int pil_venus_auth_and_reset(struct platform_device *pdev) { int rc; phys_addr_t fw_bias = venus_data->resources->firmware_base; void __iomem *reg_base = venus_data->reg_base; u32 ver; bool iommu_present = is_iommu_present(venus_data->resources); if (!fw_bias) { dprintk(VIDC_ERR, "FW bias is not valid\n"); return -EINVAL; } /* Get Venus version number */ if (!venus_data->hw_ver_checked) { ver = readl_relaxed(reg_base + VIDC_WRAPPER_HW_VERSION); venus_data->hw_ver_minor = (ver & 0x0FFF0000) >> 16; venus_data->hw_ver_major = (ver & 0xF0000000) >> 28; venus_data->hw_ver_checked = 1; } if (iommu_present) { u32 cpa_start_addr, cpa_end_addr, fw_start_addr, fw_end_addr; /* Get the cpa and fw start/end addr based on Venus version */ if (venus_data->hw_ver_major == 0x1 && venus_data->hw_ver_minor <= 1) { cpa_start_addr = VENUS_WRAPPER_VBIF_SS_SEC_CPA_START_ADDR_v1; cpa_end_addr = VENUS_WRAPPER_VBIF_SS_SEC_CPA_END_ADDR_v1; fw_start_addr = VENUS_WRAPPER_VBIF_SS_SEC_FW_START_ADDR_v1; fw_end_addr = VENUS_WRAPPER_VBIF_SS_SEC_FW_END_ADDR_v1; } else { cpa_start_addr = VENUS_WRAPPER_VBIF_SS_SEC_CPA_START_ADDR_v2; cpa_end_addr = VENUS_WRAPPER_VBIF_SS_SEC_CPA_END_ADDR_v2; fw_start_addr = VENUS_WRAPPER_VBIF_SS_SEC_FW_START_ADDR_v2; fw_end_addr = VENUS_WRAPPER_VBIF_SS_SEC_FW_END_ADDR_v2; } /* Program CPA start and end address */ writel_relaxed(0, reg_base + cpa_start_addr); writel_relaxed(venus_data->fw_sz, reg_base + cpa_end_addr); /* Program FW start and end address */ writel_relaxed(0, reg_base + fw_start_addr); writel_relaxed(venus_data->fw_sz, reg_base + fw_end_addr); } else { rc = regulator_enable(venus_data->gdsc); if (rc) { dprintk(VIDC_ERR, "GDSC enable failed\n"); goto err; } rc = venus_clock_prepare_enable(&pdev->dev); if (rc) { dprintk(VIDC_ERR, "Clock prepare and enable failed\n"); regulator_disable(venus_data->gdsc); goto err; } writel_relaxed(0, reg_base + VENUS_VBIF_AT_OLD_BASE); writel_relaxed(VENUS_REGION_SIZE, reg_base + VENUS_VBIF_AT_OLD_HIGH); writel_relaxed(fw_bias, reg_base + VENUS_VBIF_AT_NEW_BASE); writel_relaxed(fw_bias + VENUS_REGION_SIZE, reg_base + VENUS_VBIF_AT_NEW_HIGH); writel_relaxed(0x7F007F, reg_base + VENUS_VBIF_ADDR_TRANS_EN); venus_clock_disable_unprepare(&pdev->dev); regulator_disable(venus_data->gdsc); } /* Make sure all register writes are committed. */ mb(); /* * Need to wait 10 cycles of internal clocks before bringing ARM9 * out of reset. */ udelay(1); if (iommu_present) { phys_addr_t pa = fw_bias; dma_addr_t iova; rc = iommu_attach_device(venus_data->iommu_fw_domain, venus_data->iommu_fw_ctx); if (rc) { dprintk(VIDC_ERR, "venus fw iommu attach failed %d\n", rc); goto err; } /* * Map virtual addr space 0 - fw_sz to firmware physical * addr space */ rc = msm_iommu_map_contig_buffer(pa, venus_data->venus_domain_num, 0, venus_data->fw_sz, SZ_4K, 0, &iova); if (rc || (iova != 0)) { dprintk(VIDC_ERR, "Failed to setup IOMMU\n"); iommu_detach_device(venus_data->iommu_fw_domain, venus_data->iommu_fw_ctx); goto err; } } /* Bring Arm9 out of reset */ writel_relaxed(0, reg_base + VENUS_WRAPPER_SW_RESET); venus_data->is_booted = 1; return 0; err: return rc; } static int pil_venus_shutdown(struct platform_device *pdev) { void __iomem *reg_base = venus_data->reg_base; u32 reg; int rc; if (!venus_data->is_booted) return 0; /* Assert the reset to ARM9 */ reg = readl_relaxed(reg_base + VENUS_WRAPPER_SW_RESET); reg |= BIT(4); writel_relaxed(reg, reg_base + VENUS_WRAPPER_SW_RESET); /* Make sure reset is asserted before the mapping is removed */ mb(); if (is_iommu_present(venus_data->resources)) { msm_iommu_unmap_contig_buffer(0, venus_data->venus_domain_num, 0, venus_data->fw_sz); iommu_detach_device(venus_data->iommu_fw_domain, venus_data->iommu_fw_ctx); } /* * Force the VBIF clk to be on to avoid AXI bridge halt ack failure * for certain Venus version. */ if (venus_data->hw_ver_major == 0x1 && (venus_data->hw_ver_minor == 0x2 || venus_data->hw_ver_minor == 0x3)) { reg = readl_relaxed(reg_base + VIDC_VENUS_VBIF_CLK_ON); reg |= VENUS_VBIF_CLKON_FORCE_ON; writel_relaxed(reg, reg_base + VIDC_VENUS_VBIF_CLK_ON); } /* Halt AXI and AXI OCMEM VBIF Access */ reg = readl_relaxed(reg_base + VENUS_VBIF_AXI_HALT_CTRL0); reg |= VENUS_VBIF_AXI_HALT_CTRL0_HALT_REQ; writel_relaxed(reg, reg_base + VENUS_VBIF_AXI_HALT_CTRL0); /* Request for AXI bus port halt */ rc = readl_poll_timeout(reg_base + VENUS_VBIF_AXI_HALT_CTRL1, reg, reg & VENUS_VBIF_AXI_HALT_CTRL1_HALT_ACK, POLL_INTERVAL_US, VENUS_VBIF_AXI_HALT_ACK_TIMEOUT_US); if (rc) dprintk(VIDC_ERR, "Port halt timeout\n"); venus_data->is_booted = 0; return 0; } static int venus_notifier_cb(struct notifier_block *this, unsigned long code, void *ss_handle) { struct notif_data *data = (struct notif_data *)ss_handle; static bool venus_data_set; int ret; if (!data->no_auth) return NOTIFY_DONE; if (!venus_data_set) { ret = venus_clock_setup(&data->pdev->dev); if (ret) return ret; ret = of_property_read_string(data->pdev->dev.of_node, "qcom,proxy-reg-names", &venus_data->reg_name); if (ret) return ret; venus_data->gdsc = devm_regulator_get( &data->pdev->dev, venus_data->reg_name); if (IS_ERR(venus_data->gdsc)) { dprintk(VIDC_ERR, "Failed to get Venus GDSC\n"); return -ENODEV; } venus_data_set = true; } if (code != SUBSYS_AFTER_POWERUP && code != SUBSYS_AFTER_SHUTDOWN) return NOTIFY_DONE; ret = regulator_enable(venus_data->gdsc); if (ret) { dprintk(VIDC_ERR, "GDSC enable failed\n"); return ret; } ret = venus_clock_prepare_enable(&data->pdev->dev); if (ret) { dprintk(VIDC_ERR, "Clock prepare and enable failed\n"); goto err_clks; } if (code == SUBSYS_AFTER_POWERUP) { if (is_iommu_present(venus_data->resources)) pil_venus_mem_setup(data->pdev, VENUS_REGION_SIZE); pil_venus_auth_and_reset(data->pdev); } else if (code == SUBSYS_AFTER_SHUTDOWN) pil_venus_shutdown(data->pdev); venus_clock_disable_unprepare(&data->pdev->dev); regulator_disable(venus_data->gdsc); return NOTIFY_DONE; err_clks: regulator_disable(venus_data->gdsc); return ret; } static struct notifier_block venus_notifier = { .notifier_call = venus_notifier_cb, }; int venus_boot_init(struct msm_vidc_platform_resources *res) { int rc = 0; if (!res) { dprintk(VIDC_ERR, "Invalid platform resource handle\n"); return -EINVAL; } venus_data = kzalloc(sizeof(*venus_data), GFP_KERNEL); if (!venus_data) return -ENOMEM; venus_data->resources = res; venus_data->reg_base = ioremap_nocache(res->register_base, (unsigned long)res->register_size); if (!venus_data->reg_base) { dprintk(VIDC_ERR, "could not map reg addr 0x%pa of size %d\n", &res->register_base, res->register_size); rc = -ENOMEM; goto err_ioremap_fail; } venus_data->venus_notif_hdle = subsys_notif_register_notifier("venus", &venus_notifier); if (IS_ERR(venus_data->venus_notif_hdle)) { dprintk(VIDC_ERR, "register event notification failed\n"); rc = PTR_ERR(venus_data->venus_notif_hdle); goto err_subsys_notif; } return rc; err_subsys_notif: err_ioremap_fail: kfree(venus_data); return rc; } void venus_boot_deinit(void) { venus_data->resources = NULL; subsys_notif_unregister_notifier(venus_data->venus_notif_hdle, &venus_notifier); kfree(venus_data); }
/** Get the protocol name for a selected tree item. * * @param selection Tree selection * @param cfile Capture file * @return Name for a protocol or NULL */ static const gchar* ph_capture_get_protocol_name(GtkTreeSelection *selection, capture_file *cf) { int proto_id = ph_capture_get_protocol_id(selection, cf); return (!proto_id) ? NULL : proto_get_protocol_short_name(find_protocol_by_id(proto_id)); }
/* Tell how big the file is */ size_t iso_total(uint32 fd) { if(fd >= MAX_ISO_FILES || fh[fd].first_extent == 0) return -1; return fh[fd].size; }
// called from ref_make_create_range, returns the range for this fasta VB. note that we have exactly one range per VB // as txtfile_read_vblock makes sure we have only one full or partial contig per VB (if flag.make_reference) static Range *ref_make_ref_get_range (uint32_t vblock_i) { spin_lock (make_ref_spin); gref->ranges.len = MAX_(gref->ranges.len, (uint64_t)vblock_i); ASSERT (gref->ranges.len <= MAKE_REF_NUM_RANGES, "reference file too big - number of ranges exceeds %u", MAKE_REF_NUM_RANGES); spin_unlock (make_ref_spin); return ENT (Range, gref->ranges, vblock_i-1); }
/* Draws a string with given label, font and position */ void DrawString(float x, float y, void *font, const char *string, const float *color) { glColor3f(color[0], color[1], color[2]); glRasterPos2f(x, y); glutBitmapString(font, (const unsigned char *) string); }
//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef _LIBCPP___ALGORITHM_RANGES_TRANSFORM_H #define _LIBCPP___ALGORITHM_RANGES_TRANSFORM_H #include <__algorithm/in_in_out_result.h> #include <__algorithm/in_out_result.h> #include <__concepts/constructible.h> #include <__config> #include <__functional/identity.h> #include <__functional/invoke.h> #include <__iterator/concepts.h> #include <__iterator/projected.h> #include <__ranges/access.h> #include <__ranges/concepts.h> #include <__ranges/dangling.h> #include <__utility/move.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif #if _LIBCPP_STD_VER > 17 _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { template <class _Ip, class _Op> using unary_transform_result = in_out_result<_Ip, _Op>; template <class _I1, class _I2, class _O1> using binary_transform_result = in_in_out_result<_I1, _I2, _O1>; namespace __transform { struct __fn { private: template <class _InIter, class _Sent, class _OutIter, class _Func, class _Proj> _LIBCPP_HIDE_FROM_ABI static constexpr unary_transform_result<_InIter, _OutIter> __unary(_InIter __first, _Sent __last, _OutIter __result, _Func& __operation, _Proj& __projection) { while (__first != __last) { *__result = std::invoke(__operation, std::invoke(__projection, *__first)); ++__first; ++__result; } return {std::move(__first), std::move(__result)}; } template <class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter, class _Func, class _Proj1, class _Proj2> _LIBCPP_HIDE_FROM_ABI static constexpr binary_transform_result<_InIter1, _InIter2, _OutIter> __binary(_InIter1 __first1, _Sent1 __last1, _InIter2 __first2, _Sent2 __last2, _OutIter __result, _Func& __binary_operation, _Proj1& __projection1, _Proj2& __projection2) { while (__first1 != __last1 && __first2 != __last2) { *__result = std::invoke(__binary_operation, std::invoke(__projection1, *__first1), std::invoke(__projection2, *__first2)); ++__first1; ++__first2; ++__result; } return {std::move(__first1), std::move(__first2), std::move(__result)}; } public: template <input_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter, copy_constructible _Func, class _Proj = identity> requires indirectly_writable<_OutIter, indirect_result_t<_Func&, projected<_InIter, _Proj>>> _LIBCPP_HIDE_FROM_ABI constexpr unary_transform_result<_InIter, _OutIter> operator()(_InIter __first, _Sent __last, _OutIter __result, _Func __operation, _Proj __proj = {}) const { return __unary(std::move(__first), std::move(__last), std::move(__result), __operation, __proj); } template <input_range _Range, weakly_incrementable _OutIter, copy_constructible _Func, class _Proj = identity> requires indirectly_writable<_OutIter, indirect_result_t<_Func, projected<iterator_t<_Range>, _Proj>>> _LIBCPP_HIDE_FROM_ABI constexpr unary_transform_result<borrowed_iterator_t<_Range>, _OutIter> operator()(_Range&& __range, _OutIter __result, _Func __operation, _Proj __projection = {}) const { return __unary(ranges::begin(__range), ranges::end(__range), std::move(__result), __operation, __projection); } template <input_iterator _InIter1, sentinel_for<_InIter1> _Sent1, input_iterator _InIter2, sentinel_for<_InIter2> _Sent2, weakly_incrementable _OutIter, copy_constructible _Func, class _Proj1 = identity, class _Proj2 = identity> requires indirectly_writable<_OutIter, indirect_result_t<_Func&, projected<_InIter1, _Proj1>, projected<_InIter2, _Proj2>>> _LIBCPP_HIDE_FROM_ABI constexpr binary_transform_result<_InIter1, _InIter2, _OutIter> operator()(_InIter1 __first1, _Sent1 __last1, _InIter2 __first2, _Sent2 __last2, _OutIter __result, _Func __binary_operation, _Proj1 __projection1 = {}, _Proj2 __projection2 = {}) const { return __binary(std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2), std::move(__result), __binary_operation, __projection1, __projection2); } template <input_range _Range1, input_range _Range2, weakly_incrementable _OutIter, copy_constructible _Func, class _Proj1 = identity, class _Proj2 = identity> requires indirectly_writable<_OutIter, indirect_result_t<_Func&, projected<iterator_t<_Range1>, _Proj1>, projected<iterator_t<_Range2>, _Proj2>>> _LIBCPP_HIDE_FROM_ABI constexpr binary_transform_result<borrowed_iterator_t<_Range1>, borrowed_iterator_t<_Range2>, _OutIter> operator()(_Range1&& __range1, _Range2&& __range2, _OutIter __result, _Func __binary_operation, _Proj1 __projection1 = {}, _Proj2 __projection2 = {}) const { return __binary(ranges::begin(__range1), ranges::end(__range1), ranges::begin(__range2), ranges::end(__range2), std::move(__result), __binary_operation, __projection1, __projection2); } }; } // namespace __transform inline namespace __cpo { inline constexpr auto transform = __transform::__fn{}; } // namespace __cpo } // namespace ranges _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_STD_VER > 17 #endif // _LIBCPP___ALGORITHM_RANGES_TRANSFORM_H
/*****************************************************************************/ // Initialize variables, allocate memory. // Place the heavy obstacle particles that are fixated by springs also // counts the number of obstacle particles Nobs void initialize(){ int i; Ncell=Lx*(Ly+1); dLx=(double)Lx; dLy=(double)Ly; N=(int) ((dLx)*(dLy)*rho); flowstorecount = 0; fLx = ((int)(ceil(Lx/(double)(vis_cellsize))+0.5)); fLy = ((int)(ceil(Ly/(double)(vis_cellsize))+0.5)); obsStartx = (double *) malloc(sizeof(double)*(2*radius+1)*(2*radius+1)); obsStarty = (double *) malloc(sizeof(double)*(2*radius+1)*(2*radius+1)); int x,y; Nobs = 0; for (y = -(radius-1); y <= (radius-1); y++){ for (x = -(radius-1); x <= (radius-1); x++){ if (x*x+y*y <= (radius-1)*(radius-1)){ obsStartx[Nobs] = (double)x; obsStarty[Nobs] = (double)y; Nobs++; } } } for (x = 0; x < Nobs; x++){ obsStartx[x] += ((double)Lx)/2.0; obsStarty[x] += ((double)Ly)/2.0; } head=(int *) malloc(sizeof(int)*Ncell); list=(int *) malloc(sizeof(int)*(N+Nobs)); rx=(double *) malloc(sizeof(double)*(N+Nobs)); ry=(double *) malloc(sizeof(double)*(N+Nobs)); vx=(double *) malloc(sizeof(double)*(N+Nobs)); vy=(double *) malloc(sizeof(double)*(N+Nobs)); flowfieldx = (double *) malloc(sizeof(double)*fLx*fLy); flowfieldy = (double *) malloc(sizeof(double)*fLx*fLy); flowcellmass = (unsigned int *) malloc(sizeof(unsigned int)*fLx*fLy); for (i = 0; i < fLx*fLy; i++){ flowfieldx[i] = 0.0; flowfieldy[i] = 0.0; flowcellmass[i] = 0; } printf("/**********************************************************************/\n"); printf("CPU memory allocation and placed object\n"); }
/** * This interrupt indicates that the DWC_usb3 controller has detected a * resume or remote wakeup sequence. If the DWC_usb3 controller is in * low power mode, the handler must brings the controller out of low * power mode. The controller automatically begins resume * signaling. The handler schedules a time to stop resume signaling. */ static void handle_wakeup_detected_intr(dwc_usb3_pcd_t *pcd) { dwc_usb3_device_t *dev = pcd->usb3_dev; dwc_debug0(dev, "++Resume and Remote Wakeup Detected Interrupt++\n"); if (dwc_usb3_is_device_mode(dev)) { dwc_debug1(dev, "DSTS=0x%01x\n", dwc_rd32(dev, &pcd->dev_global_regs->dsts)); dwc_usb3_pcd_resume(pcd); } }
/* Create the AThread structure related to the main thread. */ AThread *ACreateMainThread(void) { AValue temp[4]; int i; for (i = 0; i < A_THREAD_ARG_BUFFER_SIZE * 3; i++) AThreadArgBuffer[i] = AZero; ANumThreads = 1; Threads = NULL; if (!AInitializeThreads()) return NULL; return ACreateThread(temp); }
// see soc/efuse_reg.h for packages list const char *package_description(int id) { switch(id) { case EFUSE_RD_CHIP_VER_PKG_ESP32D0WDQ6: return "ESP32D0WDQ6"; case EFUSE_RD_CHIP_VER_PKG_ESP32D0WDQ5: return "ESP32D0WDQ5"; case EFUSE_RD_CHIP_VER_PKG_ESP32D2WDQ5: return "ESP32D2WDQ5"; case EFUSE_RD_CHIP_VER_PKG_ESP32PICOD2: return "ESP32PICOD2"; case EFUSE_RD_CHIP_VER_PKG_ESP32PICOD4: return "ESP32PICOD4"; }; return "unknown"; }
/* * Device driver for the SYMBIOS/LSILOGIC 53C8XX and 53C1010 family * of PCI-SCSI IO processors. * * Copyright (C) 1999-2001 Gerard Roudier <groudier@free.fr> * * This driver is derived from the Linux sym53c8xx driver. * Copyright (C) 1998-2000 Gerard Roudier * * The sym53c8xx driver is derived from the ncr53c8xx driver that had been * a port of the FreeBSD ncr driver to Linux-1.2.13. * * The original ncr driver has been written for 386bsd and FreeBSD by * Wolfgang Stanglmeier <wolf@cologne.de> * Stefan Esser <se@mi.Uni-Koeln.de> * Copyright (C) 1994 Wolfgang Stanglmeier * * Other major contributions: * * NVRAM detection and reading. * Copyright (C) 1997 Richard Waltham <dormouse@farsrobt.demon.co.uk> * *----------------------------------------------------------------------------- * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "sym_glue.h" /* * Simple power of two buddy-like generic allocator. * Provides naturally aligned memory chunks. * * This simple code is not intended to be fast, but to * provide power of 2 aligned memory allocations. * Since the SCRIPTS processor only supplies 8 bit arithmetic, * this allocator allows simple and fast address calculations * from the SCRIPTS code. In addition, cache line alignment * is guaranteed for power of 2 cache line size. * * This allocator has been developed for the Linux sym53c8xx * driver, since this O/S does not provide naturally aligned * allocations. * It has the advantage of allowing the driver to use private * pages of memory that will be useful if we ever need to deal * with IO MMUs for PCI. */ static void *___sym_malloc(m_pool_p mp, int size) { int i = 0; int s = (1 << SYM_MEM_SHIFT); int j; void *a; m_link_p h = mp->h; if (size > SYM_MEM_CLUSTER_SIZE) return NULL; while (size > s) { s <<= 1; ++i; } j = i; while (!h[j].next) { if (s == SYM_MEM_CLUSTER_SIZE) { h[j].next = (m_link_p) M_GET_MEM_CLUSTER(); if (h[j].next) h[j].next->next = NULL; break; } ++j; s <<= 1; } a = h[j].next; if (a) { h[j].next = h[j].next->next; while (j > i) { j -= 1; s >>= 1; h[j].next = (m_link_p) (a+s); h[j].next->next = NULL; } } #ifdef DEBUG printf("___sym_malloc(%d) = %p\n", size, (void *) a); #endif return a; } /* * Counter-part of the generic allocator. */ static void ___sym_mfree(m_pool_p mp, void *ptr, int size) { int i = 0; int s = (1 << SYM_MEM_SHIFT); m_link_p q; unsigned long a, b; m_link_p h = mp->h; #ifdef DEBUG printf("___sym_mfree(%p, %d)\n", ptr, size); #endif if (size > SYM_MEM_CLUSTER_SIZE) return; while (size > s) { s <<= 1; ++i; } a = (unsigned long)ptr; while (1) { if (s == SYM_MEM_CLUSTER_SIZE) { #ifdef SYM_MEM_FREE_UNUSED M_FREE_MEM_CLUSTER((void *)a); #else ((m_link_p) a)->next = h[i].next; h[i].next = (m_link_p) a; #endif break; } b = a ^ s; q = &h[i]; while (q->next && q->next != (m_link_p) b) { q = q->next; } if (!q->next) { ((m_link_p) a)->next = h[i].next; h[i].next = (m_link_p) a; break; } q->next = q->next->next; a = a & b; s <<= 1; ++i; } } /* * Verbose and zeroing allocator that wrapps to the generic allocator. */ static void *__sym_calloc2(m_pool_p mp, int size, char *name, int uflags) { void *p; p = ___sym_malloc(mp, size); if (DEBUG_FLAGS & DEBUG_ALLOC) { printf ("new %-10s[%4d] @%p.\n", name, size, p); } if (p) memset(p, 0, size); else if (uflags & SYM_MEM_WARN) printf ("__sym_calloc2: failed to allocate %s[%d]\n", name, size); return p; } #define __sym_calloc(mp, s, n) __sym_calloc2(mp, s, n, SYM_MEM_WARN) /* * Its counter-part. */ static void __sym_mfree(m_pool_p mp, void *ptr, int size, char *name) { if (DEBUG_FLAGS & DEBUG_ALLOC) printf ("freeing %-10s[%4d] @%p.\n", name, size, ptr); ___sym_mfree(mp, ptr, size); } /* * Default memory pool we donnot need to involve in DMA. * * With DMA abstraction, we use functions (methods), to * distinguish between non DMAable memory and DMAable memory. */ static void *___mp0_get_mem_cluster(m_pool_p mp) { void *m = sym_get_mem_cluster(); if (m) ++mp->nump; return m; } #ifdef SYM_MEM_FREE_UNUSED static void ___mp0_free_mem_cluster(m_pool_p mp, void *m) { sym_free_mem_cluster(m); --mp->nump; } #else #define ___mp0_free_mem_cluster NULL #endif static struct sym_m_pool mp0 = { NULL, ___mp0_get_mem_cluster, ___mp0_free_mem_cluster }; /* * Methods that maintains DMAable pools according to user allocations. * New pools are created on the fly when a new pool id is provided. * They are deleted on the fly when they get emptied. */ /* Get a memory cluster that matches the DMA constraints of a given pool */ static void * ___get_dma_mem_cluster(m_pool_p mp) { m_vtob_p vbp; void *vaddr; vbp = __sym_calloc(&mp0, sizeof(*vbp), "VTOB"); if (!vbp) goto out_err; vaddr = sym_m_get_dma_mem_cluster(mp, vbp); if (vaddr) { int hc = VTOB_HASH_CODE(vaddr); vbp->next = mp->vtob[hc]; mp->vtob[hc] = vbp; ++mp->nump; } return vaddr; out_err: return NULL; } #ifdef SYM_MEM_FREE_UNUSED /* Free a memory cluster and associated resources for DMA */ static void ___free_dma_mem_cluster(m_pool_p mp, void *m) { m_vtob_p *vbpp, vbp; int hc = VTOB_HASH_CODE(m); vbpp = &mp->vtob[hc]; while (*vbpp && (*vbpp)->vaddr != m) vbpp = &(*vbpp)->next; if (*vbpp) { vbp = *vbpp; *vbpp = (*vbpp)->next; sym_m_free_dma_mem_cluster(mp, vbp); __sym_mfree(&mp0, vbp, sizeof(*vbp), "VTOB"); --mp->nump; } } #endif /* Fetch the memory pool for a given pool id (i.e. DMA constraints) */ static inline m_pool_p ___get_dma_pool(m_pool_ident_t dev_dmat) { m_pool_p mp; for (mp = mp0.next; mp && !sym_m_pool_match(mp->dev_dmat, dev_dmat); mp = mp->next); return mp; } /* Create a new memory DMAable pool (when fetch failed) */ static m_pool_p ___cre_dma_pool(m_pool_ident_t dev_dmat) { m_pool_p mp = __sym_calloc(&mp0, sizeof(*mp), "MPOOL"); if (mp) { mp->dev_dmat = dev_dmat; mp->get_mem_cluster = ___get_dma_mem_cluster; #ifdef SYM_MEM_FREE_UNUSED mp->free_mem_cluster = ___free_dma_mem_cluster; #endif mp->next = mp0.next; mp0.next = mp; return mp; } return NULL; } #ifdef SYM_MEM_FREE_UNUSED /* Destroy a DMAable memory pool (when got emptied) */ static void ___del_dma_pool(m_pool_p p) { m_pool_p *pp = &mp0.next; while (*pp && *pp != p) pp = &(*pp)->next; if (*pp) { *pp = (*pp)->next; __sym_mfree(&mp0, p, sizeof(*p), "MPOOL"); } } #endif /* This lock protects only the memory allocation/free. */ static DEFINE_SPINLOCK(sym53c8xx_lock); /* * Actual allocator for DMAable memory. */ void *__sym_calloc_dma(m_pool_ident_t dev_dmat, int size, char *name) { unsigned long flags; m_pool_p mp; void *m = NULL; spin_lock_irqsave(&sym53c8xx_lock, flags); mp = ___get_dma_pool(dev_dmat); if (!mp) mp = ___cre_dma_pool(dev_dmat); if (!mp) goto out; m = __sym_calloc(mp, size, name); #ifdef SYM_MEM_FREE_UNUSED if (!mp->nump) ___del_dma_pool(mp); #endif out: spin_unlock_irqrestore(&sym53c8xx_lock, flags); return m; } void __sym_mfree_dma(m_pool_ident_t dev_dmat, void *m, int size, char *name) { unsigned long flags; m_pool_p mp; spin_lock_irqsave(&sym53c8xx_lock, flags); mp = ___get_dma_pool(dev_dmat); if (!mp) goto out; __sym_mfree(mp, m, size, name); #ifdef SYM_MEM_FREE_UNUSED if (!mp->nump) ___del_dma_pool(mp); #endif out: spin_unlock_irqrestore(&sym53c8xx_lock, flags); } /* * Actual virtual to bus physical address translator * for 32 bit addressable DMAable memory. */ dma_addr_t __vtobus(m_pool_ident_t dev_dmat, void *m) { unsigned long flags; m_pool_p mp; int hc = VTOB_HASH_CODE(m); m_vtob_p vp = NULL; void *a = (void *)((unsigned long)m & ~SYM_MEM_CLUSTER_MASK); dma_addr_t b; spin_lock_irqsave(&sym53c8xx_lock, flags); mp = ___get_dma_pool(dev_dmat); if (mp) { vp = mp->vtob[hc]; while (vp && vp->vaddr != a) vp = vp->next; } if (!vp) panic("sym: VTOBUS FAILED!\n"); b = vp->baddr + (m - a); spin_unlock_irqrestore(&sym53c8xx_lock, flags); return b; }
/** * intel_enable_pipe - enable a pipe, asserting requirements * @crtc: crtc responsible for the pipe * * Enable @crtc's pipe, making sure that various hardware specific requirements * are met, if applicable, e.g. PLL enabled, LVDS pairs enabled, etc. */ static void intel_enable_pipe(struct intel_crtc *crtc) { struct drm_device *dev = crtc->base.dev; struct drm_i915_private *dev_priv = dev->dev_private; enum pipe pipe = crtc->pipe; enum transcoder cpu_transcoder = intel_pipe_to_cpu_transcoder(dev_priv, pipe); enum pipe pch_transcoder; int reg; u32 val; assert_planes_disabled(dev_priv, pipe); assert_cursor_disabled(dev_priv, pipe); assert_sprites_disabled(dev_priv, pipe); if (HAS_PCH_LPT(dev_priv->dev)) pch_transcoder = TRANSCODER_A; else pch_transcoder = pipe; if (!HAS_PCH_SPLIT(dev_priv->dev)) if (intel_pipe_has_type(crtc, INTEL_OUTPUT_DSI)) assert_dsi_pll_enabled(dev_priv); else assert_pll_enabled(dev_priv, pipe); else { if (crtc->config->has_pch_encoder) { assert_fdi_rx_pll_enabled(dev_priv, pch_transcoder); assert_fdi_tx_pll_enabled(dev_priv, (enum pipe) cpu_transcoder); } } reg = PIPECONF(cpu_transcoder); val = I915_READ(reg); if (val & PIPECONF_ENABLE) { WARN_ON(!((pipe == PIPE_A && dev_priv->quirks & QUIRK_PIPEA_FORCE) || (pipe == PIPE_B && dev_priv->quirks & QUIRK_PIPEB_FORCE))); return; } I915_WRITE(reg, val | PIPECONF_ENABLE); POSTING_READ(reg); }
/* Read formatted input from S, according to the format string FORMAT. */ /* VARARGS2 */ int __isoc99_sscanf (const char *s, const char *format, ...) { va_list arg; int done; va_start (arg, format); done = __isoc99_vsscanf (s, format, arg); va_end (arg); return done; }
/* * descriptions for simple tuners. */ #ifndef __TUNER_TYPES_H__ #define __TUNER_TYPES_H__ /** * enum param_type - type of the tuner pameters * * @TUNER_PARAM_TYPE_RADIO: Tuner params are for FM and/or AM radio * @TUNER_PARAM_TYPE_PAL: Tuner params are for PAL color TV standard * @TUNER_PARAM_TYPE_SECAM: Tuner params are for SECAM color TV standard * @TUNER_PARAM_TYPE_NTSC: Tuner params are for NTSC color TV standard * @TUNER_PARAM_TYPE_DIGITAL: Tuner params are for digital TV */ enum param_type { TUNER_PARAM_TYPE_RADIO, TUNER_PARAM_TYPE_PAL, TUNER_PARAM_TYPE_SECAM, TUNER_PARAM_TYPE_NTSC, TUNER_PARAM_TYPE_DIGITAL, }; /** * struct tuner_range - define the frequencies supported by the tuner * * @limit: Max frequency supported by that range, in 62.5 kHz * (TV) or 62.5 Hz (Radio), as defined by * V4L2_TUNER_CAP_LOW. * @config: Value of the band switch byte (BB) to setup this mode. * @cb: Value of the CB byte to setup this mode. * * Please notice that digital tuners like xc3028/xc4000/xc5000 don't use * those ranges, as they're defined inside the driver. This is used by * analog tuners that are compatible with the "Philips way" to setup the * tuners. On those devices, the tuner set is done via 4 bytes: * * #) divider byte1 (DB1) * #) divider byte 2 (DB2) * #) Control byte (CB) * #) band switch byte (BB) * * Some tuners also have an additional optional Auxiliary byte (AB). */ struct tuner_range { unsigned short limit; unsigned char config; unsigned char cb; }; /** * struct tuner_params - Parameters to be used to setup the tuner. Those * are used by drivers/media/tuners/tuner-types.c in * order to specify the tuner properties. Most of * the parameters are for tuners based on tda9887 IF-PLL * multi-standard analog TV/Radio demodulator, with is * very common on legacy analog tuners. * * @type: Type of the tuner parameters, as defined at * enum param_type. If the tuner supports multiple * standards, an array should be used, with one * row per different standard. * @cb_first_if_lower_freq: Many Philips-based tuners have a comment in * their datasheet like * "For channel selection involving band * switching, and to ensure smooth tuning to the * desired channel without causing unnecessary * charge pump action, it is recommended to * consider the difference between wanted channel * frequency and the current channel frequency. * Unnecessary charge pump action will result * in very low tuning voltage which may drive the * oscillator to extreme conditions". * Set cb_first_if_lower_freq to 1, if this check * is required for this tuner. I tested this for * PAL by first setting the TV frequency to * 203 MHz and then switching to 96.6 MHz FM * radio. The result was static unless the * control byte was sent first. * @has_tda9887: Set to 1 if this tuner uses a tda9887 * @port1_fm_high_sensitivity: Many Philips tuners use tda9887 PORT1 to select * the FM radio sensitivity. If this setting is 1, * then set PORT1 to 1 to get proper FM reception. * @port2_fm_high_sensitivity: Some Philips tuners use tda9887 PORT2 to select * the FM radio sensitivity. If this setting is 1, * then set PORT2 to 1 to get proper FM reception. * @fm_gain_normal: Some Philips tuners use tda9887 cGainNormal to * select the FM radio sensitivity. If this * setting is 1, e register will use cGainNormal * instead of cGainLow. * @intercarrier_mode: Most tuners with a tda9887 use QSS mode. * Some (cheaper) tuners use Intercarrier mode. * If this setting is 1, then the tuner needs to * be set to intercarrier mode. * @port1_active: This setting sets the default value for PORT1. * 0 means inactive, 1 means active. Note: the * actual bit value written to the tda9887 is * inverted. So a 0 here means a 1 in the B6 bit. * @port2_active: This setting sets the default value for PORT2. * 0 means inactive, 1 means active. Note: the * actual bit value written to the tda9887 is * inverted. So a 0 here means a 1 in the B7 bit. * @port1_invert_for_secam_lc: Sometimes PORT1 is inverted when the SECAM-L' * standard is selected. Set this bit to 1 if this * is needed. * @port2_invert_for_secam_lc: Sometimes PORT2 is inverted when the SECAM-L' * standard is selected. Set this bit to 1 if this * is needed. * @port1_set_for_fm_mono: Some cards require PORT1 to be 1 for mono Radio * FM and 0 for stereo. * @default_pll_gating_18: Select 18% (or according to datasheet 0%) * L standard PLL gating, vs the driver default * of 36%. * @radio_if: IF to use in radio mode. Tuners with a * separate radio IF filter seem to use 10.7, * while those without use 33.3 for PAL/SECAM * tuners and 41.3 for NTSC tuners. * 0 = 10.7, 1 = 33.3, 2 = 41.3 * @default_top_low: Default tda9887 TOP value in dB for the low * band. Default is 0. Range: -16:+15 * @default_top_mid: Default tda9887 TOP value in dB for the mid * band. Default is 0. Range: -16:+15 * @default_top_high: Default tda9887 TOP value in dB for the high * band. Default is 0. Range: -16:+15 * @default_top_secam_low: Default tda9887 TOP value in dB for SECAM-L/L' * for the low band. Default is 0. Several tuners * require a different TOP value for the * SECAM-L/L' standards. Range: -16:+15 * @default_top_secam_mid: Default tda9887 TOP value in dB for SECAM-L/L' * for the mid band. Default is 0. Several tuners * require a different TOP value for the * SECAM-L/L' standards. Range: -16:+15 * @default_top_secam_high: Default tda9887 TOP value in dB for SECAM-L/L' * for the high band. Default is 0. Several tuners * require a different TOP value for the * SECAM-L/L' standards. Range: -16:+15 * @iffreq: Intermediate frequency (IF) used by the tuner * on digital mode. * @count: Size of the ranges array. * @ranges: Array with the frequency ranges supported by * the tuner. */ struct tuner_params { enum param_type type; unsigned int cb_first_if_lower_freq:1; unsigned int has_tda9887:1; unsigned int port1_fm_high_sensitivity:1; unsigned int port2_fm_high_sensitivity:1; unsigned int fm_gain_normal:1; unsigned int intercarrier_mode:1; unsigned int port1_active:1; unsigned int port2_active:1; unsigned int port1_invert_for_secam_lc:1; unsigned int port2_invert_for_secam_lc:1; unsigned int port1_set_for_fm_mono:1; unsigned int default_pll_gating_18:1; unsigned int radio_if:2; signed int default_top_low:5; signed int default_top_mid:5; signed int default_top_high:5; signed int default_top_secam_low:5; signed int default_top_secam_mid:5; signed int default_top_secam_high:5; u16 iffreq; unsigned int count; struct tuner_range *ranges; }; struct tunertype { char *name; unsigned int count; struct tuner_params *params; u16 min; u16 max; u32 stepsize; u8 *initdata; u8 *sleepdata; }; extern struct tunertype tuners[]; extern unsigned const int tuner_count; #endif
// Called as starting function for new threads. Sets callstack, then calls the // real starting function. static void *wrapper_pthread_start(void *nta) { struct NewThreadArgs *args = (struct NewThreadArgs *)nta; void* result = NULL; set_will_i_be_reentrant(1); pymemprofile_set_current_callstack(args->callstack); void *(*start_routine)(void *) = args->start_routine; void *arg = args->arg; REAL_IMPL(free)(args); set_will_i_be_reentrant(0); pthread_cleanup_push(thread_shutdown_handler, NULL); result = start_routine(arg); pthread_cleanup_pop(1); return result; }
/* * old_GPDB4_check_no_free_aoseg() * * In 8.2 -> 8.3 the numeric datatype was altered and AO tables with numeric * columns will be rewritten as pages are encountered. In order to rewrite, we * need to be able to create new segment files so check that we aren't using * all 127 segfiles. */ void old_GPDB4_check_no_free_aoseg(migratorContext *ctx, Cluster whichCluster) { int dbnum; char output_path[MAXPGPATH]; bool found = false; FILE *logfile = NULL; ClusterInfo *active_cluster = (whichCluster == CLUSTER_OLD) ? &ctx->old : &ctx->new; prep_status(ctx, "Checking for AO tables with no free segfiles"); snprintf(output_path, sizeof(output_path), "%s/tables_no_free_aosegs.txt", ctx->cwd); for (dbnum = 0; dbnum < active_cluster->dbarr.ndbs; dbnum++) { PGresult *res; bool db_used = false; int ntups; int rowno; int i_nspname, i_relname, i_attname; DbInfo *active_db = &active_cluster->dbarr.dbs[dbnum]; PGconn *conn = connectToServer(ctx, active_db->db_name, whichCluster); res = executeQueryOrDie(ctx, conn, "SELECT n.nspname, c.relname, a.attname " "FROM pg_catalog.pg_class c, " " pg_catalog.pg_namespace n, " " pg_catalog.pg_attribute a " "WHERE c.oid = a.attrelid AND " " NOT a.attisdropped AND " " a.atttypid = 'pg_catalog.numeric'::pg_catalog.regtype AND " " c.relnamespace = n.oid AND " " n.nspname != 'pg_catalog' AND " " n.nspname !~ '^pg_temp_' AND " " n.nspname !~ '^pg_toast_temp_' AND " " n.nspname != 'information_schema' AND " " c.relname IN ( " " SELECT relname " " FROM gp_relation_node " " JOIN pg_appendonly ON relfilenode_oid = relid " " JOIN pg_class ON relfilenode_oid = relfilenode " " GROUP BY relname, segment_file_num HAVING count(*) >= 127 " " ) "); ntups = PQntuples(res); i_nspname = PQfnumber(res, "nspname"); i_relname = PQfnumber(res, "relname"); i_attname = PQfnumber(res, "attname"); if (ntups > 0) { if (logfile == NULL && (logfile = fopen(output_path, "w")) == NULL) pg_log(ctx, PG_FATAL, "Could not create necessary file: %s\n", output_path); found = true; for (rowno = 0; rowno < ntups; rowno++) { if (!db_used) { fprintf(logfile, "Database: %s\n", active_db->db_name); db_used = true; } fprintf(logfile, " %s.%s.%s\n", PQgetvalue(res, rowno, i_nspname), PQgetvalue(res, rowno, i_relname), PQgetvalue(res, rowno, i_attname)); } } PQclear(res); PQfinish(conn); } if (found) { if (logfile) fclose(logfile); pg_log(ctx, PG_REPORT, "warning\n"); pg_log(ctx, PG_WARNING, "| Your installation contains the \"numeric\" data type in\n" "| one or more AO tables without free segments. In order to\n" "| rewrite the table(s), please recreate them using a CREATE\n" "| TABLE AS .. statement. A list of the problem tables is in\n" "| the file:\n" "| \t%s\n\n", output_path); } else check_ok(ctx); }
/** Complete packet reception * * @v netdev Network device */ static void virtnet_process_rx_packets ( struct net_device *netdev ) { struct virtnet_nic *virtnet = netdev->priv; struct vring_virtqueue *rx_vq = &virtnet->virtqueue[RX_INDEX]; while ( vring_more_used ( rx_vq ) ) { unsigned int len; struct io_buffer *iobuf = vring_get_buf ( rx_vq, &len ); list_del ( &iobuf->list ); virtnet->rx_num_iobufs--; iob_unput ( iobuf, RX_BUF_SIZE ); iob_put ( iobuf, len - sizeof ( struct virtio_net_hdr ) ); DBGC ( virtnet, "VIRTIO-NET %p rx complete iobuf %p len %zd\n", virtnet, iobuf, iob_len ( iobuf ) ); netdev_rx ( netdev, iobuf ); } virtnet_refill_rx_virtqueue ( netdev ); }
/* * Wait for a reply to this request, then parse it. */ static int smb_rq_reply(struct smb_rq *rqp) { int error; if (rqp->sr_timo == SMBNOREPLYWAIT) { smb_iod_removerq(rqp); return (0); } error = smb_iod_waitrq(rqp); if (error) return (error); if (rqp->sr_rqflags2 & SMB_FLAGS2_SECURITY_SIGNATURE) { error = smb_rq_verify(rqp); if (error) return (error); } error = smb_rq_parsehdr(rqp); if (error != 0) return (error); if (rqp->sr_error != 0) { if (rqp->sr_rpflags2 & SMB_FLAGS2_ERR_STATUS) { error = smb_maperr32(rqp->sr_error); } else { uint8_t errClass = rqp->sr_error & 0xff; uint16_t errCode = rqp->sr_error >> 16; rqp->sr_error = smb_doserr2status(errClass, errCode); error = smb_maperror(errClass, errCode); } } if (error != 0) { if (rqp->sr_error == NT_STATUS_BUFFER_OVERFLOW) { rqp->sr_flags |= SMBR_MOREDATA; error = 0; } } else { rqp->sr_flags &= ~SMBR_MOREDATA; } return (error); }
#include <stdio.h> #include<string.h> int main() { int num,i,j,k,b,h1,h2,t1,t2,l; char s[10],p[10]; scanf("%s%s",&s,&p); h1=(s[0]-'0')*10+(s[1]-'0'); h2=(p[0]-'0')*10+(p[1]-'0'); t1=(s[3]-'0')*10+(s[4]-'0'); t2=(p[3]-'0')*10+(p[4]-'0'); if(h2>h1) { h1=h1+24; } if(t2>t1) { t1=t1+60; h1--; } k=h1-h2; if(k<0) { k=k+24; } l=t1-t2; if(k<10) { printf("0%d",k); } else { printf("%d",k); } printf(":"); if(l<10) { printf("0%d ",l); } else { printf("%d",l); } }
/** * Clean up history after editing * * @v history History buffer */ static void history_cleanup ( struct readline_history *history ) { struct readline_history_entry *entry; unsigned int i; for ( i = 0 ; i < ( sizeof ( history->entries ) / sizeof ( history->entries[0] ) ) ; i++ ) { entry = &history->entries[i]; free ( entry->temp ); entry->temp = NULL; } history->depth = 0; entry = history_entry ( history, 0 ); assert ( entry->string == NULL ); }
#ifndef TH_GENERIC_FILE #define TH_GENERIC_FILE "generic/THTensorMath.h" #else TH_API void THTensor_(fill)(THTensor *r_, real value); TH_API void THTensor_(zero)(THTensor *r_); TH_API void THTensor_(maskedFill)(THTensor *tensor, THByteTensor *mask, real value); TH_API void THTensor_(maskedCopy)(THTensor *tensor, THByteTensor *mask, THTensor* src); TH_API void THTensor_(maskedSelect)(THTensor *tensor, THTensor* src, THByteTensor *mask); TH_API void THTensor_(indexSelect)(THTensor *tensor, THTensor *src, int dim, THLongTensor *index); TH_API void THTensor_(indexCopy)(THTensor *tensor, int dim, THLongTensor *index, THTensor *src); TH_API void THTensor_(indexFill)(THTensor *tensor, int dim, THLongTensor *index, real val); TH_API accreal THTensor_(dot)(THTensor *t, THTensor *src); TH_API real THTensor_(minall)(THTensor *t); TH_API real THTensor_(maxall)(THTensor *t); TH_API accreal THTensor_(sumall)(THTensor *t); TH_API void THTensor_(add)(THTensor *r_, THTensor *t, real value); TH_API void THTensor_(mul)(THTensor *r_, THTensor *t, real value); TH_API void THTensor_(div)(THTensor *r_, THTensor *t, real value); TH_API void THTensor_(cadd)(THTensor *r_, THTensor *t, real value, THTensor *src); TH_API void THTensor_(cmul)(THTensor *r_, THTensor *t, THTensor *src); TH_API void THTensor_(cdiv)(THTensor *r_, THTensor *t, THTensor *src); TH_API void THTensor_(addcmul)(THTensor *r_, THTensor *t, real value, THTensor *src1, THTensor *src2); TH_API void THTensor_(addcdiv)(THTensor *r_, THTensor *t, real value, THTensor *src1, THTensor *src2); TH_API void THTensor_(addmv)(THTensor *r_, real beta, THTensor *t, real alpha, THTensor *mat, THTensor *vec); TH_API void THTensor_(addmm)(THTensor *r_, real beta, THTensor *t, real alpha, THTensor *mat1, THTensor *mat2); TH_API void THTensor_(addr)(THTensor *r_, real beta, THTensor *t, real alpha, THTensor *vec1, THTensor *vec2); TH_API void THTensor_(match)(THTensor *r_, THTensor *m1, THTensor *m2, real gain); TH_API long THTensor_(numel)(THTensor *t); TH_API void THTensor_(max)(THTensor *values_, THLongTensor *indices_, THTensor *t, int dimension); TH_API void THTensor_(min)(THTensor *values_, THLongTensor *indices_, THTensor *t, int dimension); TH_API void THTensor_(sum)(THTensor *r_, THTensor *t, int dimension); TH_API void THTensor_(prod)(THTensor *r_, THTensor *t, int dimension); TH_API void THTensor_(cumsum)(THTensor *r_, THTensor *t, int dimension); TH_API void THTensor_(cumprod)(THTensor *r_, THTensor *t, int dimension); TH_API void THTensor_(sign)(THTensor *r_, THTensor *t); TH_API accreal THTensor_(trace)(THTensor *t); TH_API void THTensor_(cross)(THTensor *r_, THTensor *a, THTensor *b, int dimension); TH_API void THTensor_(zeros)(THTensor *r_, THLongStorage *size); TH_API void THTensor_(ones)(THTensor *r_, THLongStorage *size); TH_API void THTensor_(diag)(THTensor *r_, THTensor *t, int k); TH_API void THTensor_(eye)(THTensor *r_, long n, long m); TH_API void THTensor_(range)(THTensor *r_, real xmin, real xmax, real step); TH_API void THTensor_(randperm)(THTensor *r_, long n); TH_API void THTensor_(reshape)(THTensor *r_, THTensor *t, THLongStorage *size); TH_API void THTensor_(sort)(THTensor *rt_, THLongTensor *ri_, THTensor *t, int dimension, int descendingOrder); TH_API void THTensor_(tril)(THTensor *r_, THTensor *t, long k); TH_API void THTensor_(triu)(THTensor *r_, THTensor *t, long k); TH_API void THTensor_(cat)(THTensor *r_, THTensor *ta, THTensor *tb, int dimension); TH_API void THTensor_(ltValue)(THByteTensor *r_, THTensor* t, real value); TH_API void THTensor_(leValue)(THByteTensor *r_, THTensor* t, real value); TH_API void THTensor_(gtValue)(THByteTensor *r_, THTensor* t, real value); TH_API void THTensor_(geValue)(THByteTensor *r_, THTensor* t, real value); TH_API void THTensor_(neValue)(THByteTensor *r_, THTensor* t, real value); TH_API void THTensor_(eqValue)(THByteTensor *r_, THTensor* t, real value); TH_API void THTensor_(ltValueT)(THTensor *r_, THTensor* t, real value); TH_API void THTensor_(leValueT)(THTensor *r_, THTensor* t, real value); TH_API void THTensor_(gtValueT)(THTensor *r_, THTensor* t, real value); TH_API void THTensor_(geValueT)(THTensor *r_, THTensor* t, real value); TH_API void THTensor_(neValueT)(THTensor *r_, THTensor* t, real value); TH_API void THTensor_(eqValueT)(THTensor *r_, THTensor* t, real value); TH_API void THTensor_(ltTensor)(THByteTensor *r_, THTensor *ta, THTensor *tb); TH_API void THTensor_(leTensor)(THByteTensor *r_, THTensor *ta, THTensor *tb); TH_API void THTensor_(gtTensor)(THByteTensor *r_, THTensor *ta, THTensor *tb); TH_API void THTensor_(geTensor)(THByteTensor *r_, THTensor *ta, THTensor *tb); TH_API void THTensor_(neTensor)(THByteTensor *r_, THTensor *ta, THTensor *tb); TH_API void THTensor_(eqTensor)(THByteTensor *r_, THTensor *ta, THTensor *tb); TH_API void THTensor_(ltTensorT)(THTensor *r_, THTensor *ta, THTensor *tb); TH_API void THTensor_(leTensorT)(THTensor *r_, THTensor *ta, THTensor *tb); TH_API void THTensor_(gtTensorT)(THTensor *r_, THTensor *ta, THTensor *tb); TH_API void THTensor_(geTensorT)(THTensor *r_, THTensor *ta, THTensor *tb); TH_API void THTensor_(neTensorT)(THTensor *r_, THTensor *ta, THTensor *tb); TH_API void THTensor_(eqTensorT)(THTensor *r_, THTensor *ta, THTensor *tb); #if defined(TH_REAL_IS_FLOAT) || defined(TH_REAL_IS_DOUBLE) TH_API void THTensor_(log)(THTensor *r_, THTensor *t); TH_API void THTensor_(log1p)(THTensor *r_, THTensor *t); TH_API void THTensor_(exp)(THTensor *r_, THTensor *t); TH_API void THTensor_(cos)(THTensor *r_, THTensor *t); TH_API void THTensor_(acos)(THTensor *r_, THTensor *t); TH_API void THTensor_(cosh)(THTensor *r_, THTensor *t); TH_API void THTensor_(sin)(THTensor *r_, THTensor *t); TH_API void THTensor_(asin)(THTensor *r_, THTensor *t); TH_API void THTensor_(sinh)(THTensor *r_, THTensor *t); TH_API void THTensor_(tan)(THTensor *r_, THTensor *t); TH_API void THTensor_(atan)(THTensor *r_, THTensor *t); TH_API void THTensor_(atan2)(THTensor *r_, THTensor *tx, THTensor *ty); TH_API void THTensor_(tanh)(THTensor *r_, THTensor *t); TH_API void THTensor_(pow)(THTensor *r_, THTensor *t, real value); TH_API void THTensor_(sqrt)(THTensor *r_, THTensor *t); TH_API void THTensor_(ceil)(THTensor *r_, THTensor *t); TH_API void THTensor_(floor)(THTensor *r_, THTensor *t); TH_API void THTensor_(abs)(THTensor *r_, THTensor *t); TH_API void THTensor_(mean)(THTensor *r_, THTensor *t, int dimension); TH_API void THTensor_(std)(THTensor *r_, THTensor *t, int dimension, int flag); TH_API void THTensor_(var)(THTensor *r_, THTensor *t, int dimension, int flag); TH_API void THTensor_(norm)(THTensor *r_, THTensor *t, real value, int dimension); TH_API accreal THTensor_(dist)(THTensor *a, THTensor *b, real value); TH_API void THTensor_(histc)(THTensor *hist, THTensor *tensor, long nbins, real minvalue, real maxvalue); TH_API accreal THTensor_(meanall)(THTensor *self); TH_API accreal THTensor_(varall)(THTensor *self); TH_API accreal THTensor_(stdall)(THTensor *self); TH_API accreal THTensor_(normall)(THTensor *t, real value); TH_API void THTensor_(linspace)(THTensor *r_, real a, real b, long n); TH_API void THTensor_(logspace)(THTensor *r_, real a, real b, long n); TH_API void THTensor_(rand)(THTensor *r_, THLongStorage *size); TH_API void THTensor_(randn)(THTensor *r_, THLongStorage *size); #endif #endif
/* * Hardware info about DECstation 5000/200 systems (otherwise known as * 3max or KN02). * * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. * * Copyright (C) 1995,1996 by Paul M. Antoine, some code and definitions * are by courtesy of Chris Fraser. * Copyright (C) 2002, 2003, 2005 Maciej W. Rozycki */ #ifndef __ASM_MIPS_DEC_KN02_H #define __ASM_MIPS_DEC_KN02_H #define KN02_SLOT_BASE 0x1fc00000 #define KN02_SLOT_SIZE 0x00080000 /* * Address ranges decoded by the "system slot" logic for onboard devices. */ #define KN02_SYS_ROM (0*KN02_SLOT_SIZE) /* system board ROM */ #define KN02_RES_1 (1*KN02_SLOT_SIZE) /* unused */ #define KN02_CHKSYN (2*KN02_SLOT_SIZE) /* ECC syndrome */ #define KN02_ERRADDR (3*KN02_SLOT_SIZE) /* bus error address */ #define KN02_DZ11 (4*KN02_SLOT_SIZE) /* DZ11 (DC7085) serial */ #define KN02_RTC (5*KN02_SLOT_SIZE) /* DS1287 RTC */ #define KN02_CSR (6*KN02_SLOT_SIZE) /* system ctrl & status reg */ #define KN02_SYS_ROM_7 (7*KN02_SLOT_SIZE) /* system board ROM (alias) */ /* * System Control & Status Register bits. */ #define KN02_CSR_RES_28 (0xf<<28) /* unused */ #define KN02_CSR_PSU (1<<27) /* power supply unit warning */ #define KN02_CSR_NVRAM (1<<26) /* ~NVRAM clear jumper */ #define KN02_CSR_REFEVEN (1<<25) /* mem refresh bank toggle */ #define KN02_CSR_NRMOD (1<<24) /* ~NRMOD manufact. jumper */ #define KN02_CSR_IOINTEN (0xff<<16) /* IRQ mask bits */ #define KN02_CSR_DIAGCHK (1<<15) /* diagn/norml ECC reads */ #define KN02_CSR_DIAGGEN (1<<14) /* diagn/norml ECC writes */ #define KN02_CSR_CORRECT (1<<13) /* ECC correct/check */ #define KN02_CSR_LEDIAG (1<<12) /* ECC diagn. latch strobe */ #define KN02_CSR_TXDIS (1<<11) /* DZ11 transmit disable */ #define KN02_CSR_BNK32M (1<<10) /* 32M/8M stride */ #define KN02_CSR_DIAGDN (1<<9) /* DIAGDN manufact. jumper */ #define KN02_CSR_BAUD38 (1<<8) /* DZ11 38/19kbps ext. rate */ #define KN02_CSR_IOINT (0xff<<0) /* IRQ status bits (r/o) */ #define KN02_CSR_LEDS (0xff<<0) /* ~diagnostic LEDs (w/o) */ /* * CPU interrupt bits. */ #define KN02_CPU_INR_RES_6 6 /* unused */ #define KN02_CPU_INR_BUS 5 /* memory, I/O bus read/write errors */ #define KN02_CPU_INR_RES_4 4 /* unused */ #define KN02_CPU_INR_RTC 3 /* DS1287 RTC */ #define KN02_CPU_INR_CASCADE 2 /* CSR cascade */ /* * CSR interrupt bits. */ #define KN02_CSR_INR_DZ11 7 /* DZ11 (DC7085) serial */ #define KN02_CSR_INR_LANCE 6 /* LANCE (Am7990) Ethernet */ #define KN02_CSR_INR_ASC 5 /* ASC (NCR53C94) SCSI */ #define KN02_CSR_INR_RES_4 4 /* unused */ #define KN02_CSR_INR_RES_3 3 /* unused */ #define KN02_CSR_INR_TC2 2 /* TURBOchannel slot #2 */ #define KN02_CSR_INR_TC1 1 /* TURBOchannel slot #1 */ #define KN02_CSR_INR_TC0 0 /* TURBOchannel slot #0 */ #define KN02_IRQ_BASE 8 /* first IRQ assigned to CSR */ #define KN02_IRQ_LINES 8 /* number of CSR interrupts */ #define KN02_IRQ_NR(n) ((n) + KN02_IRQ_BASE) #define KN02_IRQ_MASK(n) (1 << (n)) #define KN02_IRQ_ALL 0xff #ifndef __ASSEMBLY__ #include <linux/types.h> extern u32 cached_kn02_csr; extern void init_kn02_irqs(int base); #endif #endif /* __ASM_MIPS_DEC_KN02_H */
// An example of storing and retrieving a "text list". int ExampleText2() { long long ifltab[250]; char line[80]; char textList[1000]; zStructText *textStruct; int i; size_t len; int cellLength; int count; int status; #ifdef _MSC_VER status = zopen(ifltab, "j:/heclib/heclib7/test/ExampleText2pc.dss"); #else status = zopen(ifltab, "/netapp/perforce/depot/usr/hec/code/heclib7/test/ExampleText2.dss"); #endif if (status != STATUS_OKAY) return status; textStruct = zstructTextNew("/Group/Location/My List/d/e/f/"); count = 0; cellLength = 20; for (i = 0; i<20; i++) { _snprintf_s(line, sizeof(line), _TRUNCATE, "List Row %d, abcdefghijklmnopqrstuvwxyz", i); stringCopy(&textList[count], sizeof(textList) - count, line, cellLength); count += cellLength + 1; cellLength++; if (cellLength > 25) cellLength = 20; } textStruct->textTable = textList; textStruct->numberTableChars = count; textStruct->numberColumns = 1; textStruct->numberRows = 20; status = ztextStore(ifltab, textStruct); zstructFree((void *)textStruct); textStruct = 0; if (status != STATUS_OKAY) return status; textStruct = zstructTextNew("/Group/Location/My List/d/e/f/"); status = ztextRetrieve(ifltab, textStruct); if (status != STATUS_OKAY) { zstructFree((void *)textStruct); return status; } count = 0; for (i = 0; i<textStruct->numberRows; i++) { len = strnlen_hec(&textStruct->textTable[count], textStruct->numberTableChars - count); stringCopy(line, sizeof(line), &textStruct->textTable[count], len); printf("%s\n", line); count += (int)len + 1; if (count >= textStruct->numberTableChars) break; } zstructFree((void *)textStruct); zclose(ifltab); return 0; }
#include <stdio.h> int main() { int n; scanf("%d", &n); int tab[n]; int i; for (i = 0; i < n; i++) { scanf("%d", &tab[i]); } int posMin = 0, posMax = 0; for (i = 0; i < n; i++) { if (tab[i] > tab[posMax]) { posMax = i; } if (tab[i] <= tab[posMin]) { posMin = i; } } int s = posMax + n - posMin - 1; if (posMax > posMin) s--; printf("%d\n", s); return 0; }
/** * Print out general information for all systems. **/ void bblas_print_platform_info() { struct utsname info; FILE* fp; char buffer[1024]; int bytes_read; char* match; char model_name[100]; int cpu_cores; char cache_size[20]; char mem_size_char[20]; int mem_size_int; uname(&info); printf("Operating System: %s\n",info.sysname); printf(" Release: %s\n",info.release); printf(" Version: %s\n\n",info.version); printf("Hardware:\n"); fp = fopen ("/proc/cpuinfo", "r"); bytes_read = fread (buffer, 1, sizeof (buffer), fp); fclose (fp); buffer[bytes_read] = '\0'; match = strstr (buffer, "model name"); if (match != NULL) { sscanf (match, "model name : %[^\n]s", model_name); printf (" CPU Model: %s\n", model_name); } match = strstr(buffer, "cpu cores"); if (match != NULL) { sscanf (match, "cpu cores : %d", &cpu_cores); printf (" CPU cores: %d\n", cpu_cores); } match = strstr(buffer, "cache size"); if (match != NULL) { sscanf (match, "cache size : %[^\n]s", cache_size); printf (" Cache size: %s\n", cache_size); } if (match == NULL) { printf("Could not find cpu info.\n"); } fp = fopen ("/proc/meminfo", "r"); bytes_read = fread (buffer, 1, sizeof (buffer), fp); fclose (fp); buffer[bytes_read] = '\0'; match = strstr (buffer, "MemTotal"); if (match != NULL) { sscanf (match, "MemTotal : %s", mem_size_char); mem_size_int=atoi(mem_size_char); printf (" Memory (RAM) size: %d MB\n", mem_size_int/1024); } if (match == NULL) { printf("Could not find mem info.\n"); } }
/*****************************************************************************/ /** * This function executes a SHA256 transformation. * * @param Ctx is the context data for SHA256. * @param Data is the data to transform. * * @return None. * * @note None. * ******************************************************************************/ static void Sha256Transform(Sha256Type *Ctx, u8 *Data) { u32 a,b,c,d,e,f,g,h,i,j,t1,t2,m[64]; for (i=0,j=0; i < 16; ++i, j += 4) m[i] = (Data[j] << 24) | (Data[j+1] << 16) | (Data[j+2] << 8) | (Data[j+3]); for ( ; i < 64; ++i) m[i] = SIG1(m[i-2]) + m[i-7] + SIG0(m[i-15]) + m[i-16]; a = Ctx->state[0]; b = Ctx->state[1]; c = Ctx->state[2]; d = Ctx->state[3]; e = Ctx->state[4]; f = Ctx->state[5]; g = Ctx->state[6]; h = Ctx->state[7]; for (i = 0; i < 64; ++i) { t1 = h + EP1(e) + CH(e,f,g) + k[i] + m[i]; t2 = EP0(a) + MAJ(a,b,c); h = g; g = f; f = e; e = d + t1; d = c; c = b; b = a; a = t1 + t2; } Ctx->state[0] += a; Ctx->state[1] += b; Ctx->state[2] += c; Ctx->state[3] += d; Ctx->state[4] += e; Ctx->state[5] += f; Ctx->state[6] += g; Ctx->state[7] += h; }
/* * Searches the list according to request id. * */ static struct rqst_id *search_by_id(uint32_t id){ struct rqst_id *pid = ids; while(pid != NULL){ if(id == pid->request_id) return pid; pid = pid->next; } return NULL; }
/* * Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __ANALOG_H__ #define __ANALOG_H__ #ifdef __cplusplus extern "C" { #endif #include "stdbool.h" #include "hal_analogif.h" #include "hal_cmu.h" #include "hal_aud.h" #include "plat_addr_map.h" #include CHIP_SPECIFIC_HDR(analog) #ifndef ISPI_ANA_REG #define ISPI_ANA_REG(reg) (reg) #endif #define analog_read(reg, val) hal_analogif_reg_read(ISPI_ANA_REG(reg), val) #define analog_write(reg, val) hal_analogif_reg_write(ISPI_ANA_REG(reg), val) #define FLOAT_TO_PPB_INT(f) ((int)(f * 1000 * 1000 * 1000)) enum ANA_AUD_PLL_USER_T { ANA_AUD_PLL_USER_CODEC, ANA_AUD_PLL_USER_I2S, ANA_AUD_PLL_USER_SPDIF, ANA_AUD_PLL_USER_PCM, ANA_AUD_PLL_USER_QTY }; void analog_aud_freq_pll_config(uint32_t freq, uint32_t div); void analog_aud_get_dc_calib_value(int16_t *dc_l, int16_t *dc_r); void analog_open(void); void analog_aud_xtal_tune(float ratio); void analog_aud_pll_tune(float ratio); void analog_aud_pll_open(enum ANA_AUD_PLL_USER_T user); void analog_aud_pll_close(enum ANA_AUD_PLL_USER_T user); void analog_aud_set_dac_gain(int32_t v); uint32_t analog_codec_get_dac_gain(void); uint32_t analog_codec_dac_gain_to_db(int32_t gain); int32_t analog_codec_dac_max_attn_db(void); void analog_aud_apply_anc_adc_gain_offset(enum ANC_TYPE_T type, int16_t offset_l, int16_t offset_r); void analog_aud_apply_adc_gain_offset(enum AUD_CHANNEL_MAP_T ch_map, int16_t offset); void analog_aud_codec_open(void); void analog_aud_codec_close(void); void analog_aud_codec_mute(void); void analog_aud_codec_nomute(void); void analog_aud_codec_adc_enable(enum AUD_IO_PATH_T input_path, enum AUD_CHANNEL_MAP_T ch_map, bool en); void analog_aud_codec_dac_enable(bool en); void analog_aud_codec_speaker_enable(bool en); void analog_aud_codec_anc_enable(enum ANC_TYPE_T type, bool en); void analog_aud_mickey_enable(bool en); void analog_sleep(void); void analog_wakeup(void); int analog_debug_config_audio_output(bool diff); int analog_debug_config_codec(uint16_t mv); int analog_debug_config_low_power_adc(bool enable); #ifdef __cplusplus } #endif #endif
/* *---------------------------------------------------------------------- * * TclpGetSeconds -- * * This procedure returns the number of seconds from the epoch. * On most Unix systems the epoch is Midnight Jan 1, 1970 GMT. * * Results: * Number of seconds from the epoch. * * Side effects: * None. * *---------------------------------------------------------------------- */ unsigned long TclpGetSeconds() { Tcl_Time t; Tcl_GetTime( &t ); return t.sec; }
/*********************************************************************** * I87FindOpcode *********************************************************************** * SYNOPSIS: Locate the description of the given coprocessor opcode. * CALLED BY: EXTERNAL * RETURN: Pointer to an I86Opcode structure for the opcode. * SIDE EFFECTS: The name field of privOp may be overwritten. * * STRATEGY: * * REVISION HISTORY: * Name Date Description * ---- ---- ----------- * ardeb 6/29/88 Initial Revision * ardeb 10/10/88 Adapted to table linkage. * ***********************************************************************/ const I86Opcode * I87FindOpcode(unsigned long inst, unsigned char *modrmPtr) { register const I86Opcode *op = 0; int index; index = (inst & 0x3800) >> 11; *modrmPtr = (inst & 0xff00) >> 8; switch (inst & 0xdf) { case 0xd8: op = &Opcodes87_D8[index]; break; case 0xd9: switch (inst & 0xe000) { case 0xc000: index = (inst & 0x1800) >> 11; op = &Opcodes87_D9C[index]; break; case 0xe000: index = (inst & 0x1f00) >> 8; op = &Opcodes87_BigD9[index]; break; default: op = &Opcodes87_D9E[index]; break; } break; case 0xda: if ((inst & 0xc000) == 0xc000) { op = &Opcodes87_DEFAULT[0]; } else { op = &Opcodes87_DA[index]; } break; case 0xdb: if ((inst & 0xc000) != 0xc000) { op = &Opcodes87_DB[index]; } else { index = (inst & 0x1f00) >> 8; op = &Opcodes87_RegDB[index]; } break; case 0xdc: op = &Opcodes87_DC[index]; break; case 0xdd: switch (inst & 0xe000) { case 0xe000: op = &Opcodes87_DEFAULT[0]; break; case 0xc000: index = (0x1800 & inst) >> 11; op = &Opcodes87_DDC[index]; break; default: op = &Opcodes87_DD[index]; break; } break; case 0xde: switch (inst & 0xc000) { case 0xc000: op = &Opcodes87_DEReg[index]; break; default: op = &Opcodes87_DEMem[index]; break; } break; case 0xdf: switch (inst & 0xf000) { case 0xc000: case 0xd000: case 0xf000: op = &Opcodes87_DEFAULT[0]; break; case 0xe000: op = &Opcodes87_FSTSWAX[0]; break; default: op = &Opcodes87_DF[index]; break; } break; } return (op); }
/** * Gets the name of the function that should be used to sample a 2D texture. Coord type is used * to indicate whether the texture is sampled using projective textured (kVec3f) or not (kVec2f). */ inline const char* GrGLSLTexture2DFunctionName(GrSLType coordType, GrGLSLGeneration glslGen) { if (kVec2f_GrSLType == coordType) { return glslGen >= k130_GrGLSLGeneration ? "texture" : "texture2D"; } else { SkASSERT(kVec3f_GrSLType == coordType); return glslGen >= k130_GrGLSLGeneration ? "textureProj" : "texture2DProj"; } }
/** * Copyright 2020 Huawei Technologies Co., Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef MINDSPORE_LITE_SRC_RUNTIME_KERNEL_CPU_FP32_MATMUL_FP32_H_ #define MINDSPORE_LITE_SRC_RUNTIME_KERNEL_CPU_FP32_MATMUL_FP32_H_ #include <vector> #include "nnacl/matmul_parameter.h" #include "src/litert/kernel/cpu/fp32/matmul_fp32_base.h" namespace mindspore::kernel { MatmulFp32BaseCPUKernel *CreateMatmulFp32CPUKernel(OpParameter *parameter, const std::vector<lite::Tensor *> &inputs, const std::vector<lite::Tensor *> &outputs, const lite::InnerContext *ctx); class MatmulCPUKernel : public LiteKernel { public: explicit MatmulCPUKernel(OpParameter *parameter, const std::vector<lite::Tensor *> &inputs, const std::vector<lite::Tensor *> &outputs, const lite::InnerContext *ctx) : LiteKernel(parameter, inputs, outputs, ctx) { matmul_base_ = CreateMatmulFp32CPUKernel(parameter, inputs, outputs, ctx); } ~MatmulCPUKernel() { if (matmul_base_ != nullptr) { op_parameter_ = nullptr; // op_parameter will be freed in LiteKernel delete matmul_base_; matmul_base_ = nullptr; } } void set_in_tensors(const std::vector<lite::Tensor *> &in_tensors) override { this->in_tensors_ = in_tensors; if (matmul_base_ != nullptr) { matmul_base_->set_in_tensors(in_tensors); } } void set_in_tensor(lite::Tensor *in_tensor, size_t index) override { MS_ASSERT(index < in_tensors_.size()); this->in_tensors_[index] = in_tensor; if (matmul_base_ != nullptr) { matmul_base_->set_in_tensor(in_tensor, index); } } void set_out_tensors(const std::vector<lite::Tensor *> &out_tensors) override { this->out_tensors_ = out_tensors; if (matmul_base_ != nullptr) { matmul_base_->set_out_tensors(out_tensors); } } void set_out_tensor(lite::Tensor *out_tensor, size_t index) override { MS_ASSERT(index < out_tensors_.size()); this->out_tensors_[index] = out_tensor; if (matmul_base_ != nullptr) { matmul_base_->set_out_tensor(out_tensor, index); } } // Train API int Train() override { (void)LiteKernel::Train(); return matmul_base_->Train(); } void SetTrainable(bool trainable) override { LiteKernel::SetTrainable(trainable); return matmul_base_->SetTrainable(trainable); } size_t workspace_size() override { (void)LiteKernel::workspace_size(); return matmul_base_->workspace_size(); } int Prepare() override; int ReSize() override; int Run() override; int PreparePackedWeight(const lite::Tensor *tensor) override; MatmulFp32BaseCPUKernel *GetMatmulBase() const { return matmul_base_; } private: MatmulFp32BaseCPUKernel *matmul_base_ = nullptr; }; } // namespace mindspore::kernel #endif // MINDSPORE_LITE_SRC_RUNTIME_KERNEL_CPU_FP32_MATMUL_FP32_H_
/* * Copyright (C) 2011 * Boaz Harrosh <bharrosh@panasas.com> * * Public Declarations of the ORE API * * This file is part of the ORE (Object Raid Engine) library. * * ORE is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as published * by the Free Software Foundation. (GPL v2) * * ORE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with the ORE; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef __ORE_H__ #define __ORE_H__ #include <scsi/osd_initiator.h> #include <scsi/osd_attributes.h> #include <scsi/osd_sec.h> #include <linux/pnfs_osd_xdr.h> #include <linux/bug.h> struct ore_comp { struct osd_obj_id obj; u8 cred[OSD_CAP_LEN]; }; struct ore_layout { /* Our way of looking at the data_map */ enum pnfs_osd_raid_algorithm4 raid_algorithm; unsigned stripe_unit; unsigned mirrors_p1; unsigned group_width; unsigned parity; u64 group_depth; unsigned group_count; /* Cached often needed calculations filled in by * ore_verify_layout */ unsigned long max_io_length; /* Max length that should be passed to * ore_get_rw_state */ }; struct ore_dev { struct osd_dev *od; }; struct ore_components { unsigned first_dev; /* First logical device no */ unsigned numdevs; /* Num of devices in array */ /* If @single_comp == EC_SINGLE_COMP, @comps points to a single * component. else there are @numdevs components */ enum EC_COMP_USAGE { EC_SINGLE_COMP = 0, EC_MULTPLE_COMPS = 0xffffffff } single_comp; struct ore_comp *comps; /* Array of pointers to ore_dev-* . User will usually have these pointed * too a bigger struct which contain an "ore_dev ored" member and use * container_of(oc->ods[i], struct foo_dev, ored) to access the bigger * structure. */ struct ore_dev **ods; }; /* ore_comp_dev Recievies a logical device index */ static inline struct osd_dev *ore_comp_dev( const struct ore_components *oc, unsigned i) { BUG_ON((i < oc->first_dev) || (oc->first_dev + oc->numdevs <= i)); return oc->ods[i - oc->first_dev]->od; } static inline void ore_comp_set_dev( struct ore_components *oc, unsigned i, struct osd_dev *od) { oc->ods[i - oc->first_dev]->od = od; } struct ore_striping_info { u64 offset; u64 obj_offset; u64 length; u64 first_stripe_start; /* only used in raid writes */ u64 M; /* for truncate */ unsigned bytes_in_stripe; unsigned dev; unsigned par_dev; unsigned unit_off; unsigned cur_pg; unsigned cur_comp; unsigned maxdevUnits; }; struct ore_io_state; typedef void (*ore_io_done_fn)(struct ore_io_state *ios, void *private); struct _ore_r4w_op { /* @Priv given here is passed ios->private */ struct page * (*get_page)(void *priv, u64 page_index, bool *uptodate); void (*put_page)(void *priv, struct page *page); }; struct ore_io_state { struct kref kref; struct ore_striping_info si; void *private; ore_io_done_fn done; struct ore_layout *layout; struct ore_components *oc; /* Global read/write IO*/ loff_t offset; unsigned long length; void *kern_buff; struct page **pages; unsigned nr_pages; unsigned pgbase; unsigned pages_consumed; /* Attributes */ unsigned in_attr_len; struct osd_attr *in_attr; unsigned out_attr_len; struct osd_attr *out_attr; bool reading; /* House keeping of Parity pages */ bool extra_part_alloc; struct page **parity_pages; unsigned max_par_pages; unsigned cur_par_page; unsigned sgs_per_dev; struct __stripe_pages_2d *sp2d; struct ore_io_state *ios_read_4_write; const struct _ore_r4w_op *r4w; /* Variable array of size numdevs */ unsigned numdevs; struct ore_per_dev_state { struct osd_request *or; struct bio *bio; loff_t offset; unsigned length; unsigned last_sgs_total; unsigned dev; struct osd_sg_entry *sglist; unsigned cur_sg; } per_dev[]; }; static inline unsigned ore_io_state_size(unsigned numdevs) { return sizeof(struct ore_io_state) + sizeof(struct ore_per_dev_state) * numdevs; } /* ore.c */ int ore_verify_layout(unsigned total_comps, struct ore_layout *layout); void ore_calc_stripe_info(struct ore_layout *layout, u64 file_offset, u64 length, struct ore_striping_info *si); int ore_get_rw_state(struct ore_layout *layout, struct ore_components *comps, bool is_reading, u64 offset, u64 length, struct ore_io_state **ios); int ore_get_io_state(struct ore_layout *layout, struct ore_components *comps, struct ore_io_state **ios); void ore_put_io_state(struct ore_io_state *ios); typedef void (*ore_on_dev_error)(struct ore_io_state *ios, struct ore_dev *od, unsigned dev_index, enum osd_err_priority oep, u64 dev_offset, u64 dev_len); int ore_check_io(struct ore_io_state *ios, ore_on_dev_error rep); int ore_create(struct ore_io_state *ios); int ore_remove(struct ore_io_state *ios); int ore_write(struct ore_io_state *ios); int ore_read(struct ore_io_state *ios); int ore_truncate(struct ore_layout *layout, struct ore_components *comps, u64 size); int extract_attr_from_ios(struct ore_io_state *ios, struct osd_attr *attr); extern const struct osd_attr g_attr_logical_length; #endif
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stdlib.h> #include <math.h> struct point { int x, y; struct point* next; }; struct point* readPoints(int numberOfPoints); struct point* append(struct point*,struct point*); void freePoints(struct point*); long double calcTime(struct point* start,int numberOfPapers); int main() { int numberOfPoints=0, numberOfPapers=0; long double time; struct point* start = NULL; scanf("%d%d", &numberOfPoints, &numberOfPapers); start = readPoints(numberOfPoints); time = calcTime(start,numberOfPapers); printf("%.9Lf", time); freePoints(start); return 0; } struct point* readPoint() { struct point* ptr = (struct point*)malloc(sizeof(struct point)); scanf("%d %d", &ptr->x, &ptr->y); ptr->next = NULL; return ptr; } struct point* readPoints(int numberOfPoints) { struct point* start = NULL, * end = NULL, * ptr=NULL; for (int i = 0; i < numberOfPoints; i++) { if (i == 0) { start = end = ptr = readPoint(); } else { ptr = readPoint(); end = append(end, ptr); } } return start; } struct point* append(struct point* oldEnd, struct point* newEnd) { oldEnd->next = newEnd; return newEnd; } void freePoints(struct point* start) { struct point* ptr = start; while (ptr != NULL) { start = ptr->next; free(ptr); ptr = start; } } long double calcTime(struct point* start,int numberOfPapers) { struct point* ptr = start; long double totalDistance = 0.0, time = 0.0; while (ptr->next!=NULL) { totalDistance += sqrt(pow((double)abs(ptr->x - ptr->next->x),2.0) + pow((double)abs(ptr->y - ptr->next->y), 2.0)); ptr = ptr->next; } totalDistance *= (long double)numberOfPapers; time = totalDistance / 50.0; return time; }
/* * Copyright (c) 2010 The WebM project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #include <math.h> #include <stdlib.h> #include <stdio.h> #include "./vpx_dsp_rtcd.h" #include "./vpx_config.h" #include "./vpx_scale_rtcd.h" #include "./vp9_rtcd.h" #include "vpx_dsp/vpx_dsp_common.h" #include "vpx_dsp/postproc.h" #include "vpx_ports/mem.h" #include "vpx_ports/system_state.h" #include "vpx_scale/vpx_scale.h" #include "vpx_scale/yv12config.h" #include "vp9/common/vp9_onyxc_int.h" #include "vp9/common/vp9_postproc.h" #if CONFIG_VP9_POSTPROC static const uint8_t q_diff_thresh = 20; static const uint8_t last_q_thresh = 170; extern const int16_t vpx_rv[]; #if CONFIG_VP9_HIGHBITDEPTH static const int16_t kernel5[] = { 1, 1, 4, 1, 1 }; void vp9_highbd_post_proc_down_and_across_c(const uint16_t *src_ptr, uint16_t *dst_ptr, int src_pixels_per_line, int dst_pixels_per_line, int rows, int cols, int flimit) { uint16_t const *p_src; uint16_t *p_dst; int row, col, i, v, kernel; int pitch = src_pixels_per_line; uint16_t d[8]; for (row = 0; row < rows; row++) { // post_proc_down for one row. p_src = src_ptr; p_dst = dst_ptr; for (col = 0; col < cols; col++) { kernel = 4; v = p_src[col]; for (i = -2; i <= 2; i++) { if (abs(v - p_src[col + i * pitch]) > flimit) goto down_skip_convolve; kernel += kernel5[2 + i] * p_src[col + i * pitch]; } v = (kernel >> 3); down_skip_convolve: p_dst[col] = v; } /* now post_proc_across */ p_src = dst_ptr; p_dst = dst_ptr; for (i = 0; i < 8; i++) d[i] = p_src[i]; for (col = 0; col < cols; col++) { kernel = 4; v = p_src[col]; d[col & 7] = v; for (i = -2; i <= 2; i++) { if (abs(v - p_src[col + i]) > flimit) goto across_skip_convolve; kernel += kernel5[2 + i] * p_src[col + i]; } d[col & 7] = (kernel >> 3); across_skip_convolve: if (col >= 2) p_dst[col - 2] = d[(col - 2) & 7]; } /* handle the last two pixels */ p_dst[col - 2] = d[(col - 2) & 7]; p_dst[col - 1] = d[(col - 1) & 7]; /* next row */ src_ptr += pitch; dst_ptr += dst_pixels_per_line; } } #endif // CONFIG_VP9_HIGHBITDEPTH static int q2mbl(int x) { if (x < 20) x = 20; x = 50 + (x - 50) * 10 / 8; return x * x / 3; } #if CONFIG_VP9_HIGHBITDEPTH void vp9_highbd_mbpost_proc_across_ip_c(uint16_t *src, int pitch, int rows, int cols, int flimit) { int r, c, i; uint16_t *s = src; uint16_t d[16]; for (r = 0; r < rows; r++) { int sumsq = 0; int sum = 0; for (i = -8; i <= 6; i++) { sumsq += s[i] * s[i]; sum += s[i]; d[i + 8] = 0; } for (c = 0; c < cols + 8; c++) { int x = s[c + 7] - s[c - 8]; int y = s[c + 7] + s[c - 8]; sum += x; sumsq += x * y; d[c & 15] = s[c]; if (sumsq * 15 - sum * sum < flimit) { d[c & 15] = (8 + sum + s[c]) >> 4; } s[c - 8] = d[(c - 8) & 15]; } s += pitch; } } #endif // CONFIG_VP9_HIGHBITDEPTH #if CONFIG_VP9_HIGHBITDEPTH void vp9_highbd_mbpost_proc_down_c(uint16_t *dst, int pitch, int rows, int cols, int flimit) { int r, c, i; const int16_t *rv3 = &vpx_rv[63 & rand()]; // NOLINT for (c = 0; c < cols; c++) { uint16_t *s = &dst[c]; int sumsq = 0; int sum = 0; uint16_t d[16]; const int16_t *rv2 = rv3 + ((c * 17) & 127); for (i = -8; i <= 6; i++) { sumsq += s[i * pitch] * s[i * pitch]; sum += s[i * pitch]; } for (r = 0; r < rows + 8; r++) { sumsq += s[7 * pitch] * s[7 * pitch] - s[-8 * pitch] * s[-8 * pitch]; sum += s[7 * pitch] - s[-8 * pitch]; d[r & 15] = s[0]; if (sumsq * 15 - sum * sum < flimit) { d[r & 15] = (rv2[r & 127] + sum + s[0]) >> 4; } s[-8 * pitch] = d[(r - 8) & 15]; s += pitch; } } } #endif // CONFIG_VP9_HIGHBITDEPTH static void deblock_and_de_macro_block(VP9_COMMON *cm, YV12_BUFFER_CONFIG *source, YV12_BUFFER_CONFIG *post, int q, int low_var_thresh, int flag, uint8_t *limits) { (void)low_var_thresh; (void)flag; #if CONFIG_VP9_HIGHBITDEPTH if (source->flags & YV12_FLAG_HIGHBITDEPTH) { double level = 6.0e-05 * q * q * q - .0067 * q * q + .306 * q + .0065; int ppl = (int)(level + .5); vp9_highbd_post_proc_down_and_across( CONVERT_TO_SHORTPTR(source->y_buffer), CONVERT_TO_SHORTPTR(post->y_buffer), source->y_stride, post->y_stride, source->y_height, source->y_width, ppl); vp9_highbd_mbpost_proc_across_ip(CONVERT_TO_SHORTPTR(post->y_buffer), post->y_stride, post->y_height, post->y_width, q2mbl(q)); vp9_highbd_mbpost_proc_down(CONVERT_TO_SHORTPTR(post->y_buffer), post->y_stride, post->y_height, post->y_width, q2mbl(q)); vp9_highbd_post_proc_down_and_across( CONVERT_TO_SHORTPTR(source->u_buffer), CONVERT_TO_SHORTPTR(post->u_buffer), source->uv_stride, post->uv_stride, source->uv_height, source->uv_width, ppl); vp9_highbd_post_proc_down_and_across( CONVERT_TO_SHORTPTR(source->v_buffer), CONVERT_TO_SHORTPTR(post->v_buffer), source->uv_stride, post->uv_stride, source->uv_height, source->uv_width, ppl); } else { #endif // CONFIG_VP9_HIGHBITDEPTH vp9_deblock(cm, source, post, q, limits); vpx_mbpost_proc_across_ip(post->y_buffer, post->y_stride, post->y_height, post->y_width, q2mbl(q)); vpx_mbpost_proc_down(post->y_buffer, post->y_stride, post->y_height, post->y_width, q2mbl(q)); #if CONFIG_VP9_HIGHBITDEPTH } #endif // CONFIG_VP9_HIGHBITDEPTH } void vp9_deblock(struct VP9Common *cm, const YV12_BUFFER_CONFIG *src, YV12_BUFFER_CONFIG *dst, int q, uint8_t *limits) { const int ppl = (int)(6.0e-05 * q * q * q - 0.0067 * q * q + 0.306 * q + 0.0065 + 0.5); #if CONFIG_VP9_HIGHBITDEPTH if (src->flags & YV12_FLAG_HIGHBITDEPTH) { int i; const uint8_t *const srcs[3] = { src->y_buffer, src->u_buffer, src->v_buffer }; const int src_strides[3] = { src->y_stride, src->uv_stride, src->uv_stride }; const int src_widths[3] = { src->y_width, src->uv_width, src->uv_width }; const int src_heights[3] = { src->y_height, src->uv_height, src->uv_height }; uint8_t *const dsts[3] = { dst->y_buffer, dst->u_buffer, dst->v_buffer }; const int dst_strides[3] = { dst->y_stride, dst->uv_stride, dst->uv_stride }; for (i = 0; i < MAX_MB_PLANE; ++i) { vp9_highbd_post_proc_down_and_across( CONVERT_TO_SHORTPTR(srcs[i]), CONVERT_TO_SHORTPTR(dsts[i]), src_strides[i], dst_strides[i], src_heights[i], src_widths[i], ppl); } } else { #endif // CONFIG_VP9_HIGHBITDEPTH int mbr; const int mb_rows = cm->mb_rows; const int mb_cols = cm->mb_cols; memset(limits, (unsigned char)ppl, 16 * mb_cols); for (mbr = 0; mbr < mb_rows; mbr++) { vpx_post_proc_down_and_across_mb_row( src->y_buffer + 16 * mbr * src->y_stride, dst->y_buffer + 16 * mbr * dst->y_stride, src->y_stride, dst->y_stride, src->y_width, limits, 16); vpx_post_proc_down_and_across_mb_row( src->u_buffer + 8 * mbr * src->uv_stride, dst->u_buffer + 8 * mbr * dst->uv_stride, src->uv_stride, dst->uv_stride, src->uv_width, limits, 8); vpx_post_proc_down_and_across_mb_row( src->v_buffer + 8 * mbr * src->uv_stride, dst->v_buffer + 8 * mbr * dst->uv_stride, src->uv_stride, dst->uv_stride, src->uv_width, limits, 8); } #if CONFIG_VP9_HIGHBITDEPTH } #endif // CONFIG_VP9_HIGHBITDEPTH } void vp9_denoise(struct VP9Common *cm, const YV12_BUFFER_CONFIG *src, YV12_BUFFER_CONFIG *dst, int q, uint8_t *limits) { vp9_deblock(cm, src, dst, q, limits); } static void swap_mi_and_prev_mi(VP9_COMMON *cm) { // Current mip will be the prev_mip for the next frame. MODE_INFO *temp = cm->postproc_state.prev_mip; cm->postproc_state.prev_mip = cm->mip; cm->mip = temp; // Update the upper left visible macroblock ptrs. cm->mi = cm->mip + cm->mi_stride + 1; cm->postproc_state.prev_mi = cm->postproc_state.prev_mip + cm->mi_stride + 1; } int vp9_post_proc_frame(struct VP9Common *cm, YV12_BUFFER_CONFIG *dest, vp9_ppflags_t *ppflags, int unscaled_width) { const int q = VPXMIN(105, cm->lf.filter_level * 2); const int flags = ppflags->post_proc_flag; YV12_BUFFER_CONFIG *const ppbuf = &cm->post_proc_buffer; struct postproc_state *const ppstate = &cm->postproc_state; if (!cm->frame_to_show) return -1; if (!flags) { *dest = *cm->frame_to_show; return 0; } vpx_clear_system_state(); // Alloc memory for prev_mip in the first frame. if (cm->current_video_frame == 1) { ppstate->last_base_qindex = cm->base_qindex; ppstate->last_frame_valid = 1; } if ((flags & VP9D_MFQE) && ppstate->prev_mip == NULL) { ppstate->prev_mip = vpx_calloc(cm->mi_alloc_size, sizeof(*cm->mip)); if (!ppstate->prev_mip) { return 1; } ppstate->prev_mi = ppstate->prev_mip + cm->mi_stride + 1; } // Allocate post_proc_buffer_int if needed. if ((flags & VP9D_MFQE) && !cm->post_proc_buffer_int.buffer_alloc) { if ((flags & VP9D_DEMACROBLOCK) || (flags & VP9D_DEBLOCK)) { const int width = ALIGN_POWER_OF_TWO(cm->width, 4); const int height = ALIGN_POWER_OF_TWO(cm->height, 4); if (vpx_alloc_frame_buffer(&cm->post_proc_buffer_int, width, height, cm->subsampling_x, cm->subsampling_y, #if CONFIG_VP9_HIGHBITDEPTH cm->use_highbitdepth, #endif // CONFIG_VP9_HIGHBITDEPTH VP9_ENC_BORDER_IN_PIXELS, cm->byte_alignment) < 0) { vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, "Failed to allocate MFQE framebuffer"); } // Ensure that postproc is set to all 0s so that post proc // doesn't pull random data in from edge. memset(cm->post_proc_buffer_int.buffer_alloc, 128, cm->post_proc_buffer.frame_size); } } if (vpx_realloc_frame_buffer(&cm->post_proc_buffer, cm->width, cm->height, cm->subsampling_x, cm->subsampling_y, #if CONFIG_VP9_HIGHBITDEPTH cm->use_highbitdepth, #endif VP9_DEC_BORDER_IN_PIXELS, cm->byte_alignment, NULL, NULL, NULL) < 0) vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, "Failed to allocate post-processing buffer"); if (flags & (VP9D_DEMACROBLOCK | VP9D_DEBLOCK)) { if (!cm->postproc_state.limits) { cm->postproc_state.limits = vpx_calloc(unscaled_width, sizeof(*cm->postproc_state.limits)); if (!cm->postproc_state.limits) return 1; } } if (flags & VP9D_ADDNOISE) { if (!cm->postproc_state.generated_noise) { cm->postproc_state.generated_noise = vpx_calloc( cm->width + 256, sizeof(*cm->postproc_state.generated_noise)); if (!cm->postproc_state.generated_noise) return 1; } } if ((flags & VP9D_MFQE) && cm->current_video_frame >= 2 && ppstate->last_frame_valid && cm->bit_depth == 8 && ppstate->last_base_qindex <= last_q_thresh && cm->base_qindex - ppstate->last_base_qindex >= q_diff_thresh) { vp9_mfqe(cm); // TODO(jackychen): Consider whether enable deblocking by default // if mfqe is enabled. Need to take both the quality and the speed // into consideration. if ((flags & VP9D_DEMACROBLOCK) || (flags & VP9D_DEBLOCK)) { vpx_yv12_copy_frame(ppbuf, &cm->post_proc_buffer_int); } if ((flags & VP9D_DEMACROBLOCK) && cm->post_proc_buffer_int.buffer_alloc) { deblock_and_de_macro_block(cm, &cm->post_proc_buffer_int, ppbuf, q + (ppflags->deblocking_level - 5) * 10, 1, 0, cm->postproc_state.limits); } else if (flags & VP9D_DEBLOCK) { vp9_deblock(cm, &cm->post_proc_buffer_int, ppbuf, q, cm->postproc_state.limits); } else { vpx_yv12_copy_frame(&cm->post_proc_buffer_int, ppbuf); } } else if (flags & VP9D_DEMACROBLOCK) { deblock_and_de_macro_block(cm, cm->frame_to_show, ppbuf, q + (ppflags->deblocking_level - 5) * 10, 1, 0, cm->postproc_state.limits); } else if (flags & VP9D_DEBLOCK) { vp9_deblock(cm, cm->frame_to_show, ppbuf, q, cm->postproc_state.limits); } else { vpx_yv12_copy_frame(cm->frame_to_show, ppbuf); } ppstate->last_base_qindex = cm->base_qindex; ppstate->last_frame_valid = 1; if (flags & VP9D_ADDNOISE) { const int noise_level = ppflags->noise_level; if (ppstate->last_q != q || ppstate->last_noise != noise_level) { double sigma; vpx_clear_system_state(); sigma = noise_level + .5 + .6 * q / 63.0; ppstate->clamp = vpx_setup_noise(sigma, ppstate->generated_noise, cm->width + 256); ppstate->last_q = q; ppstate->last_noise = noise_level; } vpx_plane_add_noise(ppbuf->y_buffer, ppstate->generated_noise, ppstate->clamp, ppstate->clamp, ppbuf->y_width, ppbuf->y_height, ppbuf->y_stride); } *dest = *ppbuf; /* handle problem with extending borders */ dest->y_width = cm->width; dest->y_height = cm->height; dest->uv_width = dest->y_width >> cm->subsampling_x; dest->uv_height = dest->y_height >> cm->subsampling_y; if (flags & VP9D_MFQE) swap_mi_and_prev_mi(cm); return 0; } #endif // CONFIG_VP9_POSTPROC
#include<stdio.h> int main() { int i, j, num, temp, arr[256],k; scanf("%d", &num); for (i = 0; i < num; i++) { scanf("%d", &arr[i]); } for(i=0;i<num;i++){ if(i==num-1)printf("%d",arr[i]); else printf("%d ",arr[i]); } putchar('\n'); for (i = 1; i < num; i++) { temp = arr[i]; j = i - 1; while ((temp < arr[j]) && (j >= 0)) { arr[j + 1] = arr[j]; j = j - 1; } arr[j + 1] = temp; for (k = 0; k < num; k++) { if(k==num-1)printf("%d",arr[k]); else printf("%d ", arr[k]); } putchar('\n'); } return 0; }
/* * QTests for Nuvoton NPCM7xx ADCModules. * * Copyright 2020 Google LLC * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. */ #include "qemu/osdep.h" #include "qemu/bitops.h" #include "qemu/timer.h" #include "libqtest.h" #include "qapi/qmp/qdict.h" #define REF_HZ (25000000) #define CON_OFFSET 0x0 #define DATA_OFFSET 0x4 #define NUM_INPUTS 8 #define DEFAULT_IREF 2000000 #define CONV_CYCLES 20 #define RESET_CYCLES 10 #define R0_INPUT 500000 #define R1_INPUT 1500000 #define MAX_RESULT 1023 #define DEFAULT_CLKDIV 5 #define FUSE_ARRAY_BA 0xf018a000 #define FCTL_OFFSET 0x14 #define FST_OFFSET 0x0 #define FADDR_OFFSET 0x4 #define FDATA_OFFSET 0x8 #define ADC_CALIB_ADDR 24 #define FUSE_READ 0x2 /* Register field definitions. */ #define CON_MUX(rv) ((rv) << 24) #define CON_INT_EN BIT(21) #define CON_REFSEL BIT(19) #define CON_INT BIT(18) #define CON_EN BIT(17) #define CON_RST BIT(16) #define CON_CONV BIT(13) #define CON_DIV(rv) extract32(rv, 1, 8) #define FST_RDST BIT(1) #define FDATA_MASK 0xff #define MAX_ERROR 10000 #define MIN_CALIB_INPUT 100000 #define MAX_CALIB_INPUT 1800000 static const uint32_t input_list[] = { 100000, 500000, 1000000, 1500000, 1800000, 2000000, }; static const uint32_t vref_list[] = { 2000000, 2200000, 2500000, }; static const uint32_t iref_list[] = { 1800000, 1900000, 2000000, 2100000, 2200000, }; static const uint32_t div_list[] = {0, 1, 3, 7, 15}; typedef struct ADC { int irq; uint64_t base_addr; } ADC; ADC adc = { .irq = 0, .base_addr = 0xf000c000 }; static uint32_t adc_read_con(QTestState *qts, const ADC *adc) { return qtest_readl(qts, adc->base_addr + CON_OFFSET); } static void adc_write_con(QTestState *qts, const ADC *adc, uint32_t value) { qtest_writel(qts, adc->base_addr + CON_OFFSET, value); } static uint32_t adc_read_data(QTestState *qts, const ADC *adc) { return qtest_readl(qts, adc->base_addr + DATA_OFFSET); } static uint32_t adc_calibrate(uint32_t measured, uint32_t *rv) { return R0_INPUT + (R1_INPUT - R0_INPUT) * (int32_t)(measured - rv[0]) / (int32_t)(rv[1] - rv[0]); } static void adc_qom_set(QTestState *qts, const ADC *adc, const char *name, uint32_t value) { QDict *response; const char *path = "/machine/soc/adc"; g_test_message("Setting properties %s of %s with value %u", name, path, value); response = qtest_qmp(qts, "{ 'execute': 'qom-set'," " 'arguments': { 'path': %s, 'property': %s, 'value': %u}}", path, name, value); /* The qom set message returns successfully. */ g_assert_true(qdict_haskey(response, "return")); qobject_unref(response); } static void adc_write_input(QTestState *qts, const ADC *adc, uint32_t index, uint32_t value) { char name[100]; sprintf(name, "adci[%u]", index); adc_qom_set(qts, adc, name, value); } static void adc_write_vref(QTestState *qts, const ADC *adc, uint32_t value) { adc_qom_set(qts, adc, "vref", value); } static uint32_t adc_calculate_output(uint32_t input, uint32_t ref) { uint32_t output; g_assert_cmpuint(input, <=, ref); output = (input * (MAX_RESULT + 1)) / ref; if (output > MAX_RESULT) { output = MAX_RESULT; } return output; } static uint32_t adc_prescaler(QTestState *qts, const ADC *adc) { uint32_t div = extract32(adc_read_con(qts, adc), 1, 8); return 2 * (div + 1); } static int64_t adc_calculate_steps(uint32_t cycles, uint32_t prescale, uint32_t clkdiv) { return (NANOSECONDS_PER_SECOND / (REF_HZ >> clkdiv)) * cycles * prescale; } static void adc_wait_conv_finished(QTestState *qts, const ADC *adc, uint32_t clkdiv) { uint32_t prescaler = adc_prescaler(qts, adc); /* * ADC should takes roughly 20 cycles to convert one sample. So we assert it * should take 10~30 cycles here. */ qtest_clock_step(qts, adc_calculate_steps(CONV_CYCLES / 2, prescaler, clkdiv)); /* ADC is still converting. */ g_assert_true(adc_read_con(qts, adc) & CON_CONV); qtest_clock_step(qts, adc_calculate_steps(CONV_CYCLES, prescaler, clkdiv)); /* ADC has finished conversion. */ g_assert_false(adc_read_con(qts, adc) & CON_CONV); } /* Check ADC can be reset to default value. */ static void test_init(gconstpointer adc_p) { const ADC *adc = adc_p; QTestState *qts = qtest_init("-machine quanta-gsj"); adc_write_con(qts, adc, CON_REFSEL | CON_INT); g_assert_cmphex(adc_read_con(qts, adc), ==, CON_REFSEL); qtest_quit(qts); } /* Check ADC can convert from an internal reference. */ static void test_convert_internal(gconstpointer adc_p) { const ADC *adc = adc_p; uint32_t index, input, output, expected_output; QTestState *qts = qtest_init("-machine quanta-gsj"); qtest_irq_intercept_in(qts, "/machine/soc/a9mpcore/gic"); for (index = 0; index < NUM_INPUTS; ++index) { for (size_t i = 0; i < ARRAY_SIZE(input_list); ++i) { input = input_list[i]; expected_output = adc_calculate_output(input, DEFAULT_IREF); adc_write_input(qts, adc, index, input); adc_write_con(qts, adc, CON_MUX(index) | CON_REFSEL | CON_INT | CON_EN | CON_CONV); adc_wait_conv_finished(qts, adc, DEFAULT_CLKDIV); g_assert_cmphex(adc_read_con(qts, adc), ==, CON_MUX(index) | CON_REFSEL | CON_EN); g_assert_false(qtest_get_irq(qts, adc->irq)); output = adc_read_data(qts, adc); g_assert_cmpuint(output, ==, expected_output); } } qtest_quit(qts); } /* Check ADC can convert from an external reference. */ static void test_convert_external(gconstpointer adc_p) { const ADC *adc = adc_p; uint32_t index, input, vref, output, expected_output; QTestState *qts = qtest_init("-machine quanta-gsj"); qtest_irq_intercept_in(qts, "/machine/soc/a9mpcore/gic"); for (index = 0; index < NUM_INPUTS; ++index) { for (size_t i = 0; i < ARRAY_SIZE(input_list); ++i) { for (size_t j = 0; j < ARRAY_SIZE(vref_list); ++j) { input = input_list[i]; vref = vref_list[j]; expected_output = adc_calculate_output(input, vref); adc_write_input(qts, adc, index, input); adc_write_vref(qts, adc, vref); adc_write_con(qts, adc, CON_MUX(index) | CON_INT | CON_EN | CON_CONV); adc_wait_conv_finished(qts, adc, DEFAULT_CLKDIV); g_assert_cmphex(adc_read_con(qts, adc), ==, CON_MUX(index) | CON_EN); g_assert_false(qtest_get_irq(qts, adc->irq)); output = adc_read_data(qts, adc); g_assert_cmpuint(output, ==, expected_output); } } } qtest_quit(qts); } /* Check ADC interrupt files if and only if CON_INT_EN is set. */ static void test_interrupt(gconstpointer adc_p) { const ADC *adc = adc_p; uint32_t index, input, output, expected_output; QTestState *qts = qtest_init("-machine quanta-gsj"); index = 1; input = input_list[1]; expected_output = adc_calculate_output(input, DEFAULT_IREF); qtest_irq_intercept_in(qts, "/machine/soc/a9mpcore/gic"); adc_write_input(qts, adc, index, input); g_assert_false(qtest_get_irq(qts, adc->irq)); adc_write_con(qts, adc, CON_MUX(index) | CON_INT_EN | CON_REFSEL | CON_INT | CON_EN | CON_CONV); adc_wait_conv_finished(qts, adc, DEFAULT_CLKDIV); g_assert_cmphex(adc_read_con(qts, adc), ==, CON_MUX(index) | CON_INT_EN | CON_REFSEL | CON_INT | CON_EN); g_assert_true(qtest_get_irq(qts, adc->irq)); output = adc_read_data(qts, adc); g_assert_cmpuint(output, ==, expected_output); qtest_quit(qts); } /* Check ADC is reset after setting ADC_RST for 10 ADC cycles. */ static void test_reset(gconstpointer adc_p) { const ADC *adc = adc_p; QTestState *qts = qtest_init("-machine quanta-gsj"); for (size_t i = 0; i < ARRAY_SIZE(div_list); ++i) { uint32_t div = div_list[i]; adc_write_con(qts, adc, CON_INT | CON_EN | CON_RST | CON_DIV(div)); qtest_clock_step(qts, adc_calculate_steps(RESET_CYCLES, adc_prescaler(qts, adc), DEFAULT_CLKDIV)); g_assert_false(adc_read_con(qts, adc) & CON_EN); } qtest_quit(qts); } /* Check ADC Calibration works as desired. */ static void test_calibrate(gconstpointer adc_p) { int i, j; const ADC *adc = adc_p; for (j = 0; j < ARRAY_SIZE(iref_list); ++j) { uint32_t iref = iref_list[j]; uint32_t expected_rv[] = { adc_calculate_output(R0_INPUT, iref), adc_calculate_output(R1_INPUT, iref), }; char buf[100]; QTestState *qts; sprintf(buf, "-machine quanta-gsj -global npcm7xx-adc.iref=%u", iref); qts = qtest_init(buf); /* Check the converted value is correct using the calibration value. */ for (i = 0; i < ARRAY_SIZE(input_list); ++i) { uint32_t input; uint32_t output; uint32_t expected_output; uint32_t calibrated_voltage; uint32_t index = 0; input = input_list[i]; /* Calibration only works for input range 0.1V ~ 1.8V. */ if (input < MIN_CALIB_INPUT || input > MAX_CALIB_INPUT) { continue; } expected_output = adc_calculate_output(input, iref); adc_write_input(qts, adc, index, input); adc_write_con(qts, adc, CON_MUX(index) | CON_REFSEL | CON_INT | CON_EN | CON_CONV); adc_wait_conv_finished(qts, adc, DEFAULT_CLKDIV); g_assert_cmphex(adc_read_con(qts, adc), ==, CON_REFSEL | CON_MUX(index) | CON_EN); output = adc_read_data(qts, adc); g_assert_cmpuint(output, ==, expected_output); calibrated_voltage = adc_calibrate(output, expected_rv); g_assert_cmpuint(calibrated_voltage, >, input - MAX_ERROR); g_assert_cmpuint(calibrated_voltage, <, input + MAX_ERROR); } qtest_quit(qts); } } static void adc_add_test(const char *name, const ADC* wd, GTestDataFunc fn) { g_autofree char *full_name = g_strdup_printf("npcm7xx_adc/%s", name); qtest_add_data_func(full_name, wd, fn); } #define add_test(name, td) adc_add_test(#name, td, test_##name) int main(int argc, char **argv) { g_test_init(&argc, &argv, NULL); add_test(init, &adc); add_test(convert_internal, &adc); add_test(convert_external, &adc); add_test(interrupt, &adc); add_test(reset, &adc); add_test(calibrate, &adc); return g_test_run(); }
/** * Insert a flag into the flag set. * * Insertion uses binary search to keep the flag set order so lookups can be * faster. * * @param name The name of the flag command line argument * @param flag The flag to insert */ static void flag_insert(char *name, Flag flag) { if (!(nflags < MAX_FLAGS)) return; uint32_t pos = 0; int start = 0; int end = nflags; for (uint32_t i = (start + end) / 2; start <= end; pos = i, i = (start + end) / 2) { int cmp = strcmp(flag.name, flags[i].name); if (cmp == 0) break; if (cmp > 0) start = i + 1; if (cmp < 0) end = i - 1; } for (uint32_t x = nflags; x > pos; x--) { flags[x] = flags[x - 1]; } flags[pos] = flag; nflags++; }
#include<stdio.h> int main() { int i=0; char A[200]; scanf("%s",A); while((A[i]=='.')||(A[i]=='-')) { if(A[i]=='.') { printf("0"); i=i+1; } if(A[i]=='-') { if(A[i+1]=='-') printf("2"); else printf("1"); i=i+2; } } }
/* * Set/change the channel. The rate set is also updated as * to insure a consistent view by drivers. * XXX should be private but hostap needs it to deal with CSA */ void ieee80211_node_set_chan(struct ieee80211_node *ni, struct ieee80211_channel *chan) { struct ieee80211com *ic = ni->ni_ic; struct ieee80211vap *vap = ni->ni_vap; enum ieee80211_phymode mode; KASSERT(chan != IEEE80211_CHAN_ANYC, ("no channel")); ni->ni_chan = chan; mode = ieee80211_chan2mode(chan); if (IEEE80211_IS_CHAN_HT(chan)) { ni->ni_htrates = *ieee80211_get_suphtrates(ic, chan); if (mode == IEEE80211_MODE_11NA && (vap->iv_flags_ht & IEEE80211_FHT_PUREN) == 0) mode = IEEE80211_MODE_11A; else if (mode == IEEE80211_MODE_11NG && (vap->iv_flags_ht & IEEE80211_FHT_PUREN) == 0) mode = IEEE80211_MODE_11G; if (mode == IEEE80211_MODE_11G && (vap->iv_flags & IEEE80211_F_PUREG) == 0) mode = IEEE80211_MODE_11B; } ni->ni_txparms = &vap->iv_txparms[mode]; ni->ni_rates = *ieee80211_get_suprates(ic, chan); }
/* Check out the rhs of a static or global initialization VNODE to see if any of them contain addressof operations. Note that some of these variables may not even be referenced in the code in this compilation unit but their right hand sides may contain references to variables defined within this unit. */ static void analyze_variable (struct varpool_node *vnode) { tree global = vnode->decl; tree type = get_canon_type (TREE_TYPE (global), false, false); if (vnode->externally_visible) mark_interesting_type (type, FULL_ESCAPE); gcc_assert (TREE_CODE (global) == VAR_DECL); if (DECL_INITIAL (global)) check_tree (DECL_INITIAL (global)); }