hexsha
stringlengths
40
40
size
int64
5
1.05M
ext
stringclasses
588 values
lang
stringclasses
305 values
max_stars_repo_path
stringlengths
3
363
max_stars_repo_name
stringlengths
5
118
max_stars_repo_head_hexsha
stringlengths
40
40
max_stars_repo_licenses
listlengths
1
10
max_stars_count
float64
1
191k
max_stars_repo_stars_event_min_datetime
stringdate
2015-01-01 00:00:35
2022-03-31 23:43:49
max_stars_repo_stars_event_max_datetime
stringdate
2015-01-01 12:37:38
2022-03-31 23:59:52
max_issues_repo_path
stringlengths
3
363
max_issues_repo_name
stringlengths
5
118
max_issues_repo_head_hexsha
stringlengths
40
40
max_issues_repo_licenses
listlengths
1
10
max_issues_count
float64
1
134k
max_issues_repo_issues_event_min_datetime
stringlengths
24
24
max_issues_repo_issues_event_max_datetime
stringlengths
24
24
max_forks_repo_path
stringlengths
3
363
max_forks_repo_name
stringlengths
5
135
max_forks_repo_head_hexsha
stringlengths
40
40
max_forks_repo_licenses
listlengths
1
10
max_forks_count
float64
1
105k
max_forks_repo_forks_event_min_datetime
stringdate
2015-01-01 00:01:02
2022-03-31 23:27:27
max_forks_repo_forks_event_max_datetime
stringdate
2015-01-03 08:55:07
2022-03-31 23:59:24
content
stringlengths
5
1.05M
avg_line_length
float64
1.13
1.04M
max_line_length
int64
1
1.05M
alphanum_fraction
float64
0
1
71f91060a1cfef97de9945648ca5121f9a6ed5d9
1,153
c
C
Kernel/drivers/timeDriver.c
srosati/TPE_ARQUI
b2e6a3b56c0a82026a353a9e4f487b629861440e
[ "BSD-3-Clause" ]
null
null
null
Kernel/drivers/timeDriver.c
srosati/TPE_ARQUI
b2e6a3b56c0a82026a353a9e4f487b629861440e
[ "BSD-3-Clause" ]
null
null
null
Kernel/drivers/timeDriver.c
srosati/TPE_ARQUI
b2e6a3b56c0a82026a353a9e4f487b629861440e
[ "BSD-3-Clause" ]
null
null
null
#include <timeDriver.h> #include <stdint.h> #define TICKS_PER_SECOND 18 static uint64_t ticks = 0; typedef struct { void (*func)(void); uint64_t ticks; uint64_t starting_tick; } INTERVAL; typedef struct { INTERVAL functions[64]; uint8_t active[64]; uint8_t size; } INTERVALS; static INTERVALS intervals; uint8_t bcdToInt(uint8_t n) { uint8_t d1 = n >> 4; uint8_t d2 = n & 0xF; return d1*10+d2; } void initTimer() { intervals.size = 0; } void timerTick() { ticks++; for (int i = 0; i < 10; ++i){ INTERVAL interval = intervals.functions[i]; if (intervals.active[i] && (ticks-interval.starting_tick) % interval.ticks == 0) { (*(interval.func))(); } } } uint64_t getTicks() { return ticks; } uint64_t getSeconds() { return ticks/TICKS_PER_SECOND; } uint8_t setInterval(uint16_t ticks, void (*func)(void)) { INTERVAL interval; interval.ticks = ticks; interval.func = func; interval.starting_tick = ticks; intervals.functions[intervals.size] = interval; intervals.active[intervals.size++] = 1; return intervals.size-1; } void stopInterval(uint8_t idx) { if (idx >= 0 && idx < 10) { intervals.active[idx] = 0; } }
18.015625
84
0.685169
84596db15c8236f86cdedc5bb570a0a58cb04907
122,240
c
C
lib/am335x_sdk/ti/drv/usb/src/cdn/core_driver/device/src/cusbd.c
brandonbraun653/Apollo
a1ece2cc3f1d3dae48fdf8fe94f0bbb59d405fce
[ "MIT" ]
2
2021-12-27T10:19:01.000Z
2022-03-15T07:09:06.000Z
lib/am335x_sdk/ti/drv/usb/src/cdn/core_driver/device/src/cusbd.c
brandonbraun653/Apollo
a1ece2cc3f1d3dae48fdf8fe94f0bbb59d405fce
[ "MIT" ]
null
null
null
lib/am335x_sdk/ti/drv/usb/src/cdn/core_driver/device/src/cusbd.c
brandonbraun653/Apollo
a1ece2cc3f1d3dae48fdf8fe94f0bbb59d405fce
[ "MIT" ]
null
null
null
/****************************************************************************** * * Copyright (C) 2012-2019 Cadence Design Systems, Inc. * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** * cusbd.c * Cadence-USB-Device interface implementation * * Main source file *****************************************************************************/ #include <stdio.h> #include <string.h> #include <stdint.h> #include <inttypes.h> #include "cusbd_if.h" #include "cusbd_structs_if.h" #include "cdn_errno.h" /* errors definitions */ #include "cdn_log.h" /* debugging messages */ #include "cps.h" /* reg_write, reg_read functions */ #include "cusb_ch9_structs_if.h" /* USB spec chapter 9 definitions */ #include "cusbdma_if.h" /* DMA interface */ #include "sduc_list.h" /* list types */ #include "sgdma_regs.h" /* some DMA definitions */ #include "ss_dev_hw.h" /* USBSS_DEV controller defs */ #include "byteorder.h" /* endian macros */ #include "cusb_ch9_if.h" #include "cusbd_sanity.h" #if !(defined CUSBD_DEFAULT_TIMEOUT) #define CUSBD_DEFAULT_TIMEOUT 1000000U #endif #define SS_DEV_NAME "Cadence USB Super Speed device controller" #define EP0_NAME "EP_0" #define EP0_ADDRESS 0x80U #define USBSSP_DBG_CUSBD 0x02 #define CUSBSS_U1_DEV_EXIT_LAT 4 #define CUSBSS_U2_DEV_EXIT_LAT 512 #define USB_SS_MAX_PACKET_SIZE 1024 static inline void reqListDeleteItem(CUSBD_Req **headReq, CUSBD_Req *item); static uint32_t startHwTransfer(CUSBD_PrivateData * dev, CUSBD_EpPrivate *epp, CUSBD_Req const *req); /** * This function converts a virtual address pointer to uintptr_t type for DMA * @param buffer Virtual pointer to data buffer * @return Physical address of data buffer */ /* parasoft-begin-suppress MISRA2012-RULE-11_4 "const CUSBDMA_DmaTrb* converted to unsigned long, DRV-4773" */ static inline uintptr_t getPhyAddrOfU8Ptr(const uint8_t * buffer) { return ((uintptr_t) buffer); } /* parasoft-end-suppress MISRA2012-RULE-11_4 */ /********************************************************************** * Static methods for EP-OUT Aux buffer handling **********************************************************************/ #define EPOUT_AUX_BUFFER_HDR_SZ 8U #define EPOUT_AUX_BUFFER_MIN_SZ 64U /** * Constructs a uint16_t value from uint8_t pointer * * @param dataPtr Pointer to uint8 buffer * @return uint16_t value constructed from uint8 buffer */ static inline uint16_t getU16ValFromU8Ptr(const uint8_t* dataPtr) { /* Constructs a uint32_t value from uint8_t pointer */ uint16_t value = (uint16_t) dataPtr[0]; uint16_t byte1 = (uint16_t) dataPtr[1] << 8U; value += byte1; return value; } /** * Store uint16_t data in byte buffer * @param dataPtr * @param value */ static inline void setU8PtrFromU16Val(uint8_t* dataPtr, uint16_t value) { /* Store uint16_t data in byte buffer */ dataPtr[0] = (uint8_t) (value); dataPtr[1] = (uint8_t) (value >> 8U); } /** * Initialize CUSBD Aux buffer for all EP-OUTs * @param dev: pointer to driver private data */ static void cusbdAuxBufferInit(CUSBD_PrivateData* dev) { uint32_t epOutIdx; /* Initialize CUSBD Aux buffer for all EP-OUTs */ for (epOutIdx = 0U; epOutIdx < CUSBD_NUM_EP_OUT; epOutIdx++) { dev->epOutAuxBuffer[epOutIdx].bufferAddr = dev->config.epOutAuxBufferCfg[epOutIdx].bufferAddr; dev->epOutAuxBuffer[epOutIdx].bufferSize = dev->config.epOutAuxBufferCfg[epOutIdx].bufferSize; dev->epOutAuxBuffer[epOutIdx].readIdx = 0U; dev->epOutAuxBuffer[epOutIdx].writeIdx = 0U; dev->epOutAuxBuffer[epOutIdx].updateIdx = 0U; dev->epOutAuxBuffer[epOutIdx].maxPacketSize = EPOUT_AUX_BUFFER_MIN_SZ; vDbgMsg(USBSSP_DBG_CUSBD, 1, "cusbdAuxBufferInit: epOutIdx(%d) bufferAddr(%x) bufferSize(%x)\n", epOutIdx, dev->epOutAuxBuffer[epOutIdx].bufferAddr, dev->epOutAuxBuffer[epOutIdx].bufferSize); } return; } /** * Reset CUSBD Aux buffer for for the specified EP-out-index * @param dev: pointer to driver private data * @param epOutIdx */ static void cusbdAuxBufferEpOutReset(CUSBD_PrivateData* dev, uint8_t epOutIdx) { vDbgMsg(USBSSP_DBG_CUSBD, 1, "cusbdAuxBufferEpOutReset: epOutIdx(%d)\n", epOutIdx); /* Reset all indices to zero */ dev->epOutAuxBuffer[epOutIdx].readIdx = 0U; dev->epOutAuxBuffer[epOutIdx].writeIdx = 0U; dev->epOutAuxBuffer[epOutIdx].updateIdx = 0U; return; } /** * Reset CUSBD Aux buffer for all EP-OUTs * @param dev: pointer to driver private data */ static void cusbdAuxBufferReset(CUSBD_PrivateData* dev) { uint8_t epOutIdx; vDbgMsg(USBSSP_DBG_CUSBD, 1, "cusbdAuxBufferReset (%d)\n", 0); /* Reset the pointers for all Aux buffers */ for (epOutIdx = 0U; epOutIdx < CUSBD_NUM_EP_OUT; epOutIdx++) { cusbdAuxBufferEpOutReset(dev, epOutIdx); } return; } static void cusbdAuxBufferEpSetMaxPktSz(CUSBD_PrivateData* dev, uint8_t epOutIdx, uint16_t maxPacketSize) { /* Update max packet size for this endpoint*/ dev->epOutAuxBuffer[epOutIdx].maxPacketSize = maxPacketSize; return; } static uint32_t checkAuxMemAvail(CUSBD_EpAuxBuffer *epAuxBuffer, uint8_t **bufferPtr, uint16_t bufferRemaining) { uint32_t ret = CDN_ENOMEM; /* check if the last queued transfer was completed */ if (epAuxBuffer->writeIdx == epAuxBuffer->updateIdx) { if ((bufferRemaining >= (epAuxBuffer->maxPacketSize + (2U * EPOUT_AUX_BUFFER_HDR_SZ)))) { /* we have buffer for transfer */ ret = CDN_EOK; } else if ((epAuxBuffer->writeIdx >= epAuxBuffer->readIdx) && (epAuxBuffer->readIdx > (epAuxBuffer->maxPacketSize + EPOUT_AUX_BUFFER_HDR_SZ))) { setU8PtrFromU16Val(*bufferPtr, 0xFFFFU); /* Indicate wrap around */ epAuxBuffer->writeIdx = 0; epAuxBuffer->updateIdx = 0; *bufferPtr = &(epAuxBuffer->bufferAddr[epAuxBuffer->writeIdx]); ret = CDN_EOK; } else { /* required for MISRA */ } } return ret; } /** * Handle Desc-MISS interrupt * @param dev: pointer to driver private data * @param channel Pointer to the DMA channel which generated the DESC_MISS */ static void cusbdAuxBufferHandleDescMiss(CUSBD_PrivateData* dev, CUSBDMA_DmaChannel *channel) { uint32_t ret = CDN_ENOMEM; uint8_t epOutIdx = (channel->hwUsbEppNum - 1U); CUSBD_EpAuxBuffer *epAuxBuffer = &dev->epOutAuxBuffer[epOutIdx]; uint16_t bufferRemaining = epAuxBuffer->bufferSize - epAuxBuffer->writeIdx; uint8_t *bufferPtr = &(epAuxBuffer->bufferAddr[epAuxBuffer->writeIdx]); if (epAuxBuffer->readIdx > epAuxBuffer->writeIdx) { bufferRemaining = epAuxBuffer->readIdx - epAuxBuffer->writeIdx; } /* Check whether we have memory to initiate transfer */ ret = checkAuxMemAvail(epAuxBuffer, &bufferPtr, bufferRemaining); /* program DMA for this transfer */ if (ret == CDN_EOK) { CUSBDMA_DmaTransferParam xferParams; xferParams.dmaAddr = getPhyAddrOfU8Ptr(&(epAuxBuffer->bufferAddr[epAuxBuffer->writeIdx + EPOUT_AUX_BUFFER_HDR_SZ])); xferParams.len = epAuxBuffer->maxPacketSize; xferParams.requestOverflowed = 1U; xferParams.requestQueued = 0U; xferParams.sid = 0; ret = dev->dmaDrv->channelProgram(&dev->dmaController, channel, &xferParams); } /* Update pointers if channel program was successful */ if (ret == CDN_EOK) { uint16_t nextOffset = (epAuxBuffer->maxPacketSize + EPOUT_AUX_BUFFER_HDR_SZ); epAuxBuffer->writeIdx += nextOffset; /* bytes 0&1 contain next-offset: Update them when transfer done & short packet */ setU8PtrFromU16Val(&bufferPtr[0], nextOffset); /* set actual xfer len to zero */ setU8PtrFromU16Val(&bufferPtr[2], 0U); /* Set bytesProcessed to zero */ setU8PtrFromU16Val(&bufferPtr[4], 0U); } } /* parasoft-begin-suppress MISRA2012-RULE-8_13_a "Pass parameter dev with const specifier, DRV-4771" */ /* Note that dev is used to obtain non-const bufferPtr, for update aux-buffer */ static void cusbdAuxBufferUpdateXfer(CUSBD_PrivateData* dev, const CUSBD_EpPrivate *epp, const CUSBDMA_DmaTrbChainDesc *dmaChainDesc) { uint8_t epOutIdx = (epp->channel->hwUsbEppNum - 1U); CUSBD_EpAuxBuffer *epAuxBuffer = &dev->epOutAuxBuffer[epOutIdx]; uint8_t *bufferPtr = &(epAuxBuffer->bufferAddr[epAuxBuffer->updateIdx]); uint32_t reqLength = epAuxBuffer->maxPacketSize; uint32_t actualLen = dmaChainDesc->actualLen; uint16_t nextOffset = EPOUT_AUX_BUFFER_HDR_SZ; vDbgMsg(USBSSP_DBG_CUSBD, 1, "EP%d-%s cusbdAuxBufferUpdateXfer xferLen(%d)\n", (epp->ep.address & 0xF), (epp->channel->isDirTx) ? "TX" : "RX", actualLen); if (actualLen > reqLength) { actualLen = reqLength; } /* Code actual len in byes 2 & 3 */ bufferPtr[2] = (uint8_t) actualLen; bufferPtr[3] = (uint8_t) (actualLen >> 8U); /* increment update and write index in steps of 8 bytes */ nextOffset += (uint16_t) ((actualLen + (EPOUT_AUX_BUFFER_HDR_SZ - 1U)) & (~(EPOUT_AUX_BUFFER_HDR_SZ - 1U))); /* update next-offset */ bufferPtr[0] = (uint8_t) nextOffset; bufferPtr[1] = (uint8_t) (nextOffset >> 8U); /* update context variables */ epAuxBuffer->updateIdx += nextOffset; /* note that there can't be more than 1 desc missing queued */ epAuxBuffer->writeIdx = epAuxBuffer->updateIdx; } /* parasoft-end-suppress MISRA2012-RULE-8_13_a */ static uint32_t cusbdAuxBufferIsDataValid(const CUSBD_PrivateData* dev, const CUSBD_EpPrivate *epp) { uint8_t epOutIdx = (epp->channel->hwUsbEppNum - 1U); const CUSBD_EpAuxBuffer *epAuxBuffer = &dev->epOutAuxBuffer[epOutIdx]; uint32_t dataValid = 0; if (epAuxBuffer->readIdx != epAuxBuffer->updateIdx) { dataValid = 1; vDbgMsg(USBSSP_DBG_CUSBD, 1, "EP%d-%s cusbdAuxBufferIsDataValid dataValid(%d)\n", (epp->ep.address & 0xF), ((epp->ep.address & 0x80) != 0U) ? "TX" : "RX", dataValid); } return dataValid; } static uint32_t cusbdAuxBufferIsXferQueued(const CUSBD_PrivateData* dev, const CUSBD_EpPrivate *epp) { uint8_t epOutIdx = (epp->channel->hwUsbEppNum - 1U); const CUSBD_EpAuxBuffer *epAuxBuffer = &dev->epOutAuxBuffer[epOutIdx]; uint32_t xferQueued = 0; /* If writeIdx != updateIdx then last transfer request has not finished */ if (epAuxBuffer->writeIdx != epAuxBuffer->updateIdx) { xferQueued = 1; } return xferQueued; } static void auxBufferCopy(uint8_t * dest, const uint8_t * src, uint16_t len) { /* Copy aux-buffer content to user specified - request- buffer */ #ifdef CDN_RIPE3_PLAT uint16_t idx; for (idx = 0U; idx < len; idx++) { dest[idx] = src[idx]; } #else (void) memcpy(dest, src, len); #endif } /** * * @param epAuxBuffer * @param req * @return */ static uint32_t cusbdAuxBufferDequeueXfer(CUSBD_EpAuxBuffer *epAuxBuffer, CUSBD_Req * req) { uint32_t reqBufferRem = req->length - req->actual; uint8_t *bufferPtr = &(epAuxBuffer->bufferAddr[epAuxBuffer->readIdx]); uint16_t nextOffset = getU16ValFromU8Ptr(&bufferPtr[0]); uint16_t xferLength = getU16ValFromU8Ptr(&bufferPtr[2]); uint16_t bytesProcessed = getU16ValFromU8Ptr(&bufferPtr[4]); uint16_t length = xferLength - bytesProcessed; if (reqBufferRem >= length) { /* if request buffer remaining is greater than xfer lenth then copy full */ auxBufferCopy(&req->buf[req->actual], &bufferPtr[bytesProcessed + EPOUT_AUX_BUFFER_HDR_SZ], length); /* Update the number of bytes xfered in the request*/ req->actual += length; /* update ep-out buffer read-index */ epAuxBuffer->readIdx += nextOffset; } else { length = (uint16_t) reqBufferRem; /* else copy only the amount possible */ auxBufferCopy(&req->buf[req->actual], &bufferPtr[bytesProcessed + EPOUT_AUX_BUFFER_HDR_SZ], length); req->actual += length; bytesProcessed += length; /* since we didn't consume the entire buffer, store the number of bytes consumed */ bufferPtr[4] = (uint8_t) bytesProcessed; bufferPtr[5] = (uint8_t) (bytesProcessed >> 8U); } return (uint32_t) length; } /* parasoft-begin-suppress MISRA2012-RULE-8_13_a "Pass parameter dev with const specifier, DRV-4772"*/ /* Note that dev is used to obtain non-const epAuxBuffer, for updating aux-buffer */ static uint32_t cusbdAuxBufferDequeue(CUSBD_PrivateData* dev, const CUSBD_EpPrivate *epp, CUSBD_Req * req) { uint8_t epOutIdx = (epp->channel->hwUsbEppNum - 1U); CUSBD_EpAuxBuffer *epAuxBuffer = &dev->epOutAuxBuffer[epOutIdx]; uint32_t xferLen = 0; vDbgMsg(USBSSP_DBG_CUSBD, 1, "EP%d-%s cusbdAuxBufferDequeue req->length(%d)\n", (epp->ep.address & 0xF), ((epp->ep.address & 0x80) != 0U) ? "TX" : "RX", req->length); /* Iterate through all the buffers, trying to fill the requested buffer */ while (epAuxBuffer->readIdx != epAuxBuffer->updateIdx) { uint32_t length = 0; uint8_t *bufferPtr = &(epAuxBuffer->bufferAddr[epAuxBuffer->readIdx]); /* check for wrap-around */ if ((bufferPtr[0] == 0xFFU) && (bufferPtr[1] == 0xFFU) && (epAuxBuffer->updateIdx < epAuxBuffer->readIdx)) { epAuxBuffer->readIdx = 0U; continue; } length = cusbdAuxBufferDequeueXfer(epAuxBuffer, req); xferLen += length; /* Break if we get a short packet, zero len packet or fill up the req buf */ if ((length == 0U) || ((length % epp->ep.maxPacket) != 0U) || (req->actual >= req->length)) { break; } } return xferLen; } /* parasoft-end-suppress MISRA2012-RULE-8_13_a */ /********************************************************************** * Static methods from cusbdma module **********************************************************************/ /** * Returns endpoint object * @param dev pointer to driver object * @param epNum endpoint number * @param epDir endpoint direction * @return pointer to endpoint object */ /* parasoft-begin-suppress MISRA2012-RULE-8_13_a "Pass parameter dev with const specifier, DRV-4278" */ /* Note that parameter 'dev' is used for obtaining non-const 'CUSBD_EpPrivate *' */ static inline CUSBD_EpPrivate *dmaCompleteCallbackGetEp(CUSBD_PrivateData * dev, uint8_t epNum, uint8_t epDir) { CUSBD_EpPrivate * epp; /* get endpoint from endpoint container */ if (epNum == 0U) { epp = &dev->ep0; } else if (epDir > 0U) { epp = &dev->ep_in_container[epNum - 1U]; } else { epp = &dev->ep_out_container[epNum - 1U]; } return epp; } /* parasoft-end-suppress MISRA2012-RULE-8_13_a */ static CUSBDMA_DmaTrbChainDesc* getNextChainDesc(const CUSBDMA_DmaChannel *channel) { CUSBDMA_DmaTrbChainDesc *nextChainDesc = NULL; if (channel->trbChainDescReadIdx != channel->trbChainDescWriteIdx) { nextChainDesc = &channel->trbChainDescListHead[channel->trbChainDescReadIdx]; } return nextChainDesc; } /** * Check if DMA is pending for this channel */ static uint8_t cusbdmaIsDMAPending(const CUSBDMA_DmaChannel *channel) { uint8_t dmaPending = 0; /* DMA is pending is TRB buffer dequeue Index is not same as enqueue index */ if (channel->trbBufferDequeueIdx != channel->trbBufferEnqueueIdx) { dmaPending = 1U; } return dmaPending; } /** * Handle TRB chain corresponding to Aux buffer * @param dev pointer to driver object * @param epp * @param nextChainDesc */ static void cusbdmaHandleAuxXferCmpl(CUSBD_PrivateData* dev, CUSBD_EpPrivate *epp, const CUSBDMA_DmaTrbChainDesc *nextChainDesc) { CUSBD_Req *nextReq = epp->reqListHead; cusbdAuxBufferUpdateXfer(dev, epp, nextChainDesc); /* check if a request was queued*/ if (nextReq != NULL) { uint32_t isShortPacket = 0U; /* dequeue in the request buffer */ uint32_t len = cusbdAuxBufferDequeue(dev, epp, nextReq); isShortPacket = ((len == 0U) || ((len % epp->ep.maxPacket) != 0U)) ? 1U : 0U; /* check whether the request is complete */ if ((isShortPacket != 0U) || (nextReq->actual >= nextReq->length)) { nextReq->status = CDN_EOK; reqListDeleteItem(&(epp->reqListHead), nextReq); if (nextReq->complete != NULL) { nextReq->complete(&epp->ep, nextReq); } } } return; } /** * Handle a completed TRB chain for non-zero EP * @param dev * @param nextChainDesc * @param epp */ static void cusbdmaHandleCmplTRBDescEpx(CUSBD_PrivateData* dev, const CUSBDMA_DmaTrbChainDesc *nextChainDesc, CUSBD_EpPrivate *epp) { CUSBD_Req *nextReq = epp->reqListHead; if (nextChainDesc->requestQueued != 0U) { /* check if request list not empty and call complete function */ if (nextReq != NULL) { reqListDeleteItem(&(epp->reqListHead), nextReq); nextReq->actual += nextChainDesc->actualLen; nextReq->status = CDN_EOK; if (nextReq->complete != NULL) { nextReq->complete(&epp->ep, nextReq); } } } else if (nextChainDesc->requestOverflowed != 0U) { /* if this corresponds to an overflow request */ cusbdmaHandleAuxXferCmpl(dev, epp, nextChainDesc); } else { /* required for MISRA */ } } /** * Process all completed chains * @param dev pointer to driver object * @param channel DMA Channel for the allocation */ static void cusbdmaHandleCompletedTRBChain(CUSBD_PrivateData* dev, CUSBD_EpPrivate *epp, CUSBDMA_DmaChannel *channel) { CUSBDMA_DmaTrbChainDesc *nextChainDesc = getNextChainDesc(channel); while (nextChainDesc != NULL) { if (nextChainDesc->trbChainState == CUSBDMA_TRB_CHAIN_COMPLETE) { /* Check if request is not empty and update number of actually processed bytes */ if (channel->hwUsbEppNum == 0U) { if (dev->request != NULL) { dev->request->actual += nextChainDesc->actualLen; } } else { cusbdmaHandleCmplTRBDescEpx(dev, nextChainDesc, epp); } /* Free the head(oldest) TRB chain descriptor for this channel */ (void) dev->dmaDrv->channelFreeHeadTrbChain(&dev->dmaController, channel); nextChainDesc = getNextChainDesc(channel); } else { break; } } } /** * Process IOC ISP ITP interrupt after data transfer * @param dev * @param channel */ static void cusbdmaProcessDataXferInt(CUSBD_PrivateData* dev, CUSBDMA_DmaChannel *channel) { CUSBD_EpPrivate *epp = NULL; CUSBDMA_OBJ *dmaDrv = dev->dmaDrv; /* update channel status */ (void) dmaDrv->channelUpdateState(&dev->dmaController, channel); epp = dmaCompleteCallbackGetEp(dev, channel->hwUsbEppNum, channel->isDirTx); /* Process all completed chains */ cusbdmaHandleCompletedTRBChain(dev, epp, channel); /* If EP is stalled, stall the corresponding DMA channel */ if (epp->ep_state == CUSBD_EP_STALLED) { (void) dmaDrv->channelHandleStall(&dev->dmaController, channel, 1U, CUSBD_DEFAULT_TIMEOUT); } } /** * Send ERDY packet * @param pD pointer to driver object * @param sid */ static void sendErdy(const CUSBD_PrivateData* pD, uint32_t sid) { CPS_UncachedWrite32(&pD->reg->USBR_EP_CMD, (DMARF_EP_ERDY | (sid << 16))); } /** * Handle Descriptor Missed interrupt * @param dev: pointer to driver object * @param channel: pointer to DMA channel */ static void isrHandleDescMiss(CUSBD_PrivateData* dev, CUSBDMA_DmaChannel *channel) { /* call callback if set */ if (channel->trbBufferEnqueueIdx != channel->trbBufferDequeueIdx) { vDbgMsg(USBSSP_DBG_CUSBD, 1, "EP%d-%s isrHandleOther: DMARF_EP_DESCMIS: Ignore\n", channel->hwUsbEppNum, (channel->isDirTx) ? "TX" : "RX"); } else if (dev->callbacks.descMissing != NULL) { dev->callbacks.descMissing(dev, (uint8_t) (channel->hwUsbEppNum | channel->isDirTx)); } else if ((channel->isDirTx == 0U) && (channel->hwUsbEppNum != 0U)) { CUSBD_EpPrivate *epp = dmaCompleteCallbackGetEp(dev, channel->hwUsbEppNum, channel->isDirTx); CUSBD_Req *req = epp->reqListHead; uint32_t ret = CDN_EOK; if (req == NULL) { cusbdAuxBufferHandleDescMiss(dev, channel); } else { while (req->requestPending != 0U) { ret = startHwTransfer(dev, epp, req); if (ret != CDN_EOK) { break; } req->requestPending = 0U; req = req->nextReq; } } } else { /* Required for MISRA */ } return; } static void isrHandlePrime(CUSBD_PrivateData* dev, const CUSBDMA_DmaChannel *channel, DmaRegs * regs) { CUSBD_EpPrivate * epp = NULL; CPS_UncachedWrite32(&regs->ep_sts, DMARF_EP_PRIME); vDbgMsg(USBSSP_DBG_CUSBD, 1, "DMAIRQ: PRIME\n", 0); /* Get the end point private object */ epp = dmaCompleteCallbackGetEp(dev, channel->hwUsbEppNum, channel->isDirTx); /* Check if streams are enabled */ if (epp->ep.maxStreams != 0U) { uint8_t dmaPending = cusbdmaIsDMAPending(channel); CUSBD_Req *nextReq = epp->reqListHead; uint8_t nextRequestPending = 0U; if (nextReq != NULL) { nextRequestPending = nextReq->requestPending; } /* * For PRIME received while data transfer we need to retry ERDY packet to * go back to DATA MOVE state * sent to re-open stream transfer */ if (dmaPending != 0U) { vDbgMsg(USBSSP_DBG_CUSBD, 1, "EP%d-%s sendErdy\r\n", channel->hwUsbEppNum, (channel->isDirTx ? "TX" : "RX")); sendErdy(dev, channel->currentStreamID); } else if (nextRequestPending != 0U) { vDbgMsg(USBSSP_DBG_CUSBD, 1, "EP%d-%s Start Pending Request \r\n", channel->hwUsbEppNum, (channel->isDirTx ? "TX" : "RX")); /* if the next request is pending, start it */ (void) startHwTransfer(dev, epp, nextReq); nextReq->requestPending = 0U; } else { vDbgMsg(USBSSP_DBG_CUSBD, 1, "EP%d-%s Primed - Waiting for transfer \r\n", channel->hwUsbEppNum, (channel->isDirTx ? "TX" : "RX")); } } } static void isrHandleMdExit(CUSBD_PrivateData* dev, CUSBDMA_DmaChannel *channel, DmaRegs * regs) { CPS_UncachedWrite32(&regs->ep_sts, DMARF_EP_MD_EXIT); vDbgMsg(USBSSP_DBG_CUSBD, 1, "DMAIRQ: MD_EXIT\n", 0); /* * handle only OUT stream endpoint here */ if (channel->isDirTx == 0U) { /* check TDL value of actual transfer*/ uint32_t tdl = CPS_UncachedRead32(&dev->reg->USBR_EP_CMD) & 0x0000FE00U; /* update request only when all data has been transferred for current request*/ if (tdl == 0U) { /* Handle tdl = 0 */ cusbdmaProcessDataXferInt(dev, channel); } else { /* we should have got PRIME */ } } else { vDbgMsg(USBSSP_DBG_CUSBD, 1, "EP%d-%s MD_EXIT Ignoring for IN transfers \r\n", channel->hwUsbEppNum, (channel->isDirTx ? "TX" : "RX")); } } static void isrHandleOther(CUSBD_PrivateData* dev, CUSBDMA_DmaChannel *channel, DmaRegs * regs, uint32_t epSts) { uint32_t *ep_sts_ptr = &regs->ep_sts; /* check descriptor missing interrupt */ if ((epSts & DMARF_EP_DESCMIS) != 0U) { CPS_UncachedWrite32(ep_sts_ptr, DMARF_EP_DESCMIS); vDbgMsg(USBSSP_DBG_CUSBD, 1, "DMAIRQ: DESCMIS%s\n", ""); isrHandleDescMiss(dev, channel); } /* check iso error */ if ((epSts & DMARF_EP_ISOERR) != 0U) { CPS_UncachedWrite32(ep_sts_ptr, DMARF_EP_ISOERR); vDbgMsg(USBSSP_DBG_CUSBD, 1, "DMAIRQ: ISOERR%s\n", ""); } /* check side error */ if ((epSts & DMARF_EP_SIDERR) != 0U) { CPS_UncachedWrite32(ep_sts_ptr, DMARF_EP_SIDERR); vDbgMsg(USBSSP_DBG_CUSBD, 1, "DMAIRQ: SIDERR\n", 0); } /* MD_EXIT should be handled first; * If PRIME & MD_EXIT came together this would cause a redundant ERDY to be sent to HOST * however sending redundant ERDY should not be an issue */ if ((epSts & DMARF_EP_MD_EXIT) != 0U) { isrHandleMdExit(dev, channel, regs); } /* check prime interrupt */ if ((epSts & DMARF_EP_PRIME) != 0U) { isrHandlePrime(dev, channel, regs); } /* check stream error */ if ((epSts & DMARF_EP_STREAMR) != 0U) { CPS_UncachedWrite32(ep_sts_ptr, DMARF_EP_STREAMR); vDbgMsg(USBSSP_DBG_CUSBD, 1, "DMAIRQ: STREAMR\n", 0); } } /** * Handle Interrupt * @param dev pointer to driver object * @param channel DMA Channel for the allocation * @param regs DMA register * @param epSts Endpoint status */ static void isrHandle(CUSBD_PrivateData* dev, CUSBDMA_DmaChannel *channel, DmaRegs * regs, uint32_t epSts) { vDbgMsg(USBSSP_DBG_CUSBD, 1, "isrHandle EP%d-%s epSts %x", channel->hwUsbEppNum, (channel->isDirTx ? "TX" : "RX"), epSts); /* check TRB error */ if ((epSts & DMARF_EP_TRBERR) != 0U) { vDbgMsg(USBSSP_DBG_CUSBD, 1, "DMAIRQ: TRBERR %s\n", ""); CPS_UncachedWrite32(&regs->ep_sts, DMARF_EP_TRBERR); if (channel->dmultEnabled != 0U) { (void) dev->dmaDrv->channelTrigger(&dev->dmaController, channel); } } /* check IOC and ISP */ if (((epSts & DMARF_EP_IOC) != 0U) || ((epSts & DMARF_EP_ISP) != 0U) || ((epSts & DMARF_EP_IOT) != 0U)) { CPS_UncachedWrite32(&regs->ep_sts, DMARF_EP_IOC | DMARF_EP_ISP | DMARF_EP_IOT); if (((epSts & DMARF_EP_IOT) > 0U) && (channel->isDirTx == 0U)) { /* * Updating transfer for stream OUT endpoint is handled on MD_EXIT event * For OUT packet IOT is mostly generated before MD_EXIT and rearming * transfer is useless: MD_EXITs cancels transfer issues to controller * so that we must rely on MD_EXIT rather than IOT for OUT transfers. */ } else { (void) cusbdmaProcessDataXferInt(dev, channel); } } /* stop program if critical error: Data overflow */ if ((epSts & DMARF_EP_OUTSMM) != 0U) { CPS_UncachedWrite32(&regs->ep_sts, DMARF_EP_OUTSMM); vDbgMsg(USBSSP_DBG_CUSBD, 1, "DMAIRQ: OUTSMM%s\n", ""); } isrHandleOther(dev, channel, regs, epSts); } /** * Interrupt handler * @param pD pointer to DMA controller object * @return CDN_EOK on success, error code elsewhere */ static uint32_t cusbdmaIsr(CUSBD_PrivateData* dev) { /* check input parameters */ uint32_t ret = (dev->dmaDrv == NULL) ? CDN_EINVAL : CDN_EOK; CUSBDMA_DmaController * ctrl = &(dev->dmaController); DmaRegs * regs = NULL; uint32_t epSts, epIsts = 0U; CUSBDMA_DmaChannel *channel = NULL; uint32_t i; if (ret == CDN_EOK) { regs = ctrl->regs; /* Check interrupts for all endpoints */ epIsts = CPS_UncachedRead32(&regs->ep_ists); } if ((ret == CDN_EOK) && (epIsts != 0U)) { vDbgMsg(USBSSP_DBG_CUSBD, 1, "DMAIRQ ep_ists SFR: %x\n", epIsts); /* check all endpoints interrupts */ for (i = 0; i < 32U; i++) { uint32_t isDirTx; uint32_t epNum; if ((epIsts & (((uint32_t) 1U) << i)) == 0U) { continue; } if (i > 15U) { isDirTx = DMARD_EP_TX; epNum = i - 16U; } else { isDirTx = 0U; epNum = i; } CPS_UncachedWrite32(&regs->ep_sel, epNum | isDirTx); epSts = CPS_UncachedRead32(&regs->ep_sts); if (isDirTx != 0U) /*transmit data*/ { channel = &ctrl->tx[epNum]; } else { channel = &ctrl->rx[epNum]; } isrHandle(dev, channel, regs, epSts); } } return ret; } /** * wait until bit is cleared macro * @param reg register * @param bit selected bit */ /* parasoft-begin-suppress METRICS-36-3 "A function should not be called from more than 5 different functions, DRV-3823" */ static uint32_t waitUntilBitCleared(uint32_t * reg, uint32_t bit) { uint32_t counter = CUSBD_DEFAULT_TIMEOUT; uint32_t ret = CDN_EOK; /* Check for specified bit to be set */ while ((CPS_UncachedRead32(reg) & bit) > 0U) { /* break loop if timeout occur */ if (counter == 0U) { ret = CDN_ETIMEDOUT; vDbgMsg(USBSSP_DBG_CUSBD, DBG_CRIT, "%s() Error timeout \n", __func__); break; } counter--; CPS_DelayNs(1000); } return ret; } /* parasoft-end-suppress METRICS-36-3 */ /** * wait until bit is cleared macro * @param reg register * @param bit selected bit */ /* parasoft-begin-suppress METRICS-36-3 "A function should not be called from more than 5 different functions, DRV-3823" */ static uint32_t waitUntilBitSet(uint32_t * reg, uint32_t bit) { uint32_t counter = CUSBD_DEFAULT_TIMEOUT; uint32_t ret = CDN_EOK; /* Check for specified bit to be set */ while ((CPS_UncachedRead32(reg) & bit) == 0U) { vDbgMsg(USBSSP_DBG_CUSBD, DBG_CRIT, "%s(), %x \n", __func__, ((CPS_UncachedRead32(reg) & bit))); /* break loop if timeout occur */ if (counter == 0U) { ret = CDN_ETIMEDOUT; vDbgMsg(USBSSP_DBG_CUSBD, DBG_CRIT, "%s() Error timeout \n", __func__); break; } counter--; CPS_DelayNs(1000); } return ret; } /* parasoft-end-suppress METRICS-36-3 */ /** * Function adds the item at tail of doubly-linked list */ static inline void reqListAddTail(CUSBD_Req **headReq, CUSBD_Req *item) { /* Check for an empty list */ if (*headReq == NULL) { *headReq = item; item->nextReq = item; item->prevReq = item; } else { CUSBD_Req *last = (*headReq)->prevReq; item->nextReq = *headReq; item->prevReq = last; last->nextReq = item; (*headReq)->prevReq = item; } } /** * Function deletes the corresponding item */ static inline void reqListDeleteItem(CUSBD_Req **headReq, CUSBD_Req *item) { /* If there is only one item in the list */ if ((item->nextReq == NULL) || (item->prevReq == NULL)) { vDbgMsg(USBSSP_DBG_CUSBD, DBG_FYI, "Warning: item already removed 0x%08X\n", (uintptr_t) item); } else if (item->nextReq == item) { *headReq = NULL; }/* Adjustments done with next and previous items */ else { CUSBD_Req *lastReq = item->prevReq; CUSBD_Req *firstReq = item->nextReq; firstReq->prevReq = lastReq; lastReq->nextReq = firstReq; if (*headReq == item) { *headReq = firstReq; } } item->nextReq = NULL; item->prevReq = NULL; } /** * return next request from endpoint transfer queue * @param ep pointer to endpoint object * @return next endpoint request, if NULL it means that next request does not exist */ static CUSBD_Req *getNextReq(CUSBD_EpPrivate const * ep) { return ep->reqListHead; } /** * get the last request queued * @param ep Pointer to endpoint private data * @return Pointer to last request */ static CUSBD_Req *getLastReq(CUSBD_EpPrivate const * ep) { CUSBD_Req *lastReq = NULL; CUSBD_Req *headReq = ep->reqListHead; /* Request are queued in doubly linked list.*/ /* The prev-pointer of the head request points to last request */ if (headReq != NULL) { lastReq = headReq->prevReq; } return lastReq; } /** * Function return actual speed basing on value read from USB_STS register * @param dev pointer to device object * @return actual speed value */ static CH9_UsbSpeed getActualSpeed(CUSBD_PrivateData * dev) { uint32_t reg = CPS_UncachedRead32(&dev->reg->USBR_STS); /*read speed from SFR*/ uint8_t speed = GET_USB_STS_SPEED(reg); CH9_UsbSpeed actualSpeed; switch (speed) { /* low*/ case 1: actualSpeed = CH9_USB_SPEED_LOW; break; /*full*/ case 2: actualSpeed = CH9_USB_SPEED_FULL; break; /*high*/ case 3: actualSpeed = CH9_USB_SPEED_HIGH; break; /*super*/ case 4: actualSpeed = CH9_USB_SPEED_SUPER; break; /*super plus*/ case 5: actualSpeed = CH9_USB_SPEED_SUPER_PLUS; break; /* unknown*/ default: actualSpeed = CH9_USB_SPEED_UNKNOWN; break; } return actualSpeed; } /** * start data transfer on selected endpoint * @param dev pointer to driver object * @param epp pointer to extended endpoint object * @param req pointer to request object */ static uint32_t startHwTransfer(CUSBD_PrivateData * dev, CUSBD_EpPrivate *epp, CUSBD_Req const *req) { uint32_t ret = CDN_EOK; CUSBDMA_DmaTransferParam trParams; /* calculate residue data */ uint32_t bytesToTransfer = req->length - req->actual; uint32_t numOfbytes = (bytesToTransfer > TD_SING_MAX_TRB_DATA_SIZE) ? TD_SING_MAX_TRB_DATA_SIZE : bytesToTransfer; trParams.dmaAddr = req->dma + req->actual; trParams.len = numOfbytes; trParams.sid = req->streamId; if (req->complete != NULL) { trParams.requestQueued = 1U; } else { trParams.requestQueued = 0; } /* create transfer descriptor on transfer ring*/ ret = dev->dmaDrv->channelProgram(&(dev->dmaController), epp->channel, &trParams); if (ret != CDN_EOK) { vDbgMsg(USBSSP_DBG_CUSBD, DBG_CRIT, "Failed to program DMA on ep: %02X\n", epp->ep.address); } return ret; } /** * Run control transfer on default endpoint * @param dev pointer to driver object * @param dir data direction 1: dev-to-host 0:host-to-dev * @param buffer address of data buffer * @param buffer_size data buffer size * @param erdy 1 force ERDY packet */ static uint32_t ep0transfer(CUSBD_PrivateData * dev, uint8_t dir, uintptr_t buffer, uint32_t buffer_size, uint8_t erdy) { uint32_t ret = (dev->dmaDrv == NULL) ? CDN_EINVAL : CDN_EOK; CUSBDMA_DmaChannel *channel = (dir > 0U) ? dev->ep0DmaChannelIn : dev->ep0DmaChannelOut; CUSBDMA_DmaTransferParam trParams; if (ret == CDN_EOK) { ret = CUSBDMA_ChannelReset(&dev->dmaController, channel); } if (ret == CDN_EOK) { trParams.dmaAddr = buffer; trParams.len = (buffer_size < dev->ep0.ep.maxPacket) ? buffer_size : dev->ep0.ep.maxPacket; trParams.sid = 0U; trParams.requestQueued = 1U; vDbgMsg(USBSSP_DBG_CUSBD, DBG_HIVERB, "Programming EP0 transfer for length %d\n", trParams.len); /* create transfer descriptor on TRB ring*/ ret = dev->dmaDrv->channelProgram(&(dev->dmaController), channel, &trParams); } if (ret != CDN_EOK) { vDbgMsg(USBSSP_DBG_CUSBD, DBG_CRIT, "Failed to program DMA on EP0\n", 0); } else { if (erdy != 0U) { /* send ERDY packet */ CPS_UncachedWrite32(&dev->reg->USBR_EP_CMD, EP_CMD_ERDY); /* OUT data phase */ } } return ret; } /** * Enable interrupt on given endpoint * @param dev pointer to driver object * @param epNum endpoint number * @param epDir endpoint index */ static void epEnableInterrupt(CUSBD_PrivateData *dev, uint8_t epNum, uint8_t epDir) { uint32_t epIntBit; uint32_t ep_ien; /* calculate bit position */ if (epDir > 0U) { epIntBit = (uint32_t) epNum << 16; } else { epIntBit = (uint32_t) epNum; } /* write selected bit to ep_ein register*/ ep_ien = CPS_UncachedRead32(&dev->reg->USBR_EP_IEN); ep_ien |= epIntBit << 1; CPS_UncachedWrite32(&dev->reg->USBR_EP_IEN, ep_ien); } static uint32_t constructEpCfgReg(uint8_t epType, uint16_t maxPacketSize, uint8_t epBuffering, uint8_t mult, uint8_t maxBurst) { uint32_t reg = 0; SET_EP_CONF_ENABLE(&reg); /* Enable end point */ SET_EP_CONF_EPTYPE(&reg, epType); /* set ep type */ SET_EP_CONF_MAXPKTSIZE(&reg, le16ToCpu(maxPacketSize)); /* set max packet size */ SET_EP_CONF_BUFFERING(&reg, epBuffering); SET_EP_CONF_MULT(&reg, mult); SET_EP_CONF_MAXBURST(&reg, maxBurst); SET_EP_CONF_EPENDIAN(&reg, (uint8_t)CUSBD_ENDIANESS_CONV_FLAG); return reg; } static void epEnableHw(CUSBD_PrivateData *dev, CUSBD_Ep *ep, const uint8_t * desc, CUSBDMA_ChannelParams *channelParams) { uint32_t reg = 0; uint8_t epBuffering = 0; uint8_t mult = ep->mult; /* must be calculated differently for HS and SS */ uint8_t epType = desc[3]; /* bDescriptorType */ uint8_t epNum = USBD_EPNUM_FROM_EPADDR(ep->address); uint8_t epDir = USBD_EPDIR_FROM_EPADDR(ep->address); uint32_t irqEnFlags = EP_STS_EN_TRBERREN | EP_STS_EN_ISOERREN | EP_STS_EN_DESCMISEN; /* get buffering value */ if (epDir > 0U) { epBuffering = dev->config.epIN[epNum - 1U].bufferingValue; } else { epBuffering = dev->config.epOUT[epNum - 1U].bufferingValue; } if (epBuffering > 0U) { epBuffering--; } reg = constructEpCfgReg(epType, channelParams->wMaxPacketSize, epBuffering, mult, ep->maxburst); /* Configure streams support only for SS and SSP mode */ if (dev->device.speed >= CH9_USB_SPEED_SUPER) { /* get information about streams from endpoint companion descriptors which should be located in memory just after endpoint descriptor */ if ((desc[7] == CH9_USB_DS_SS_USB_EP_COMPANION) && (desc[8] == CH9_USB_DT_SS_USB_EP_COMPANION)) { ep->compDesc = &desc[7]; /* check if streams are used for endpoint */ /* need some cleanup - 'maybe' - currently there is redundancy, but this works * for ep-in we use IOT * for ep-out we use MD_EXIT + TDL */ if (ep->compDesc[3] > 0U) { SET_EP_CONF_STREAM_EN(&reg); reg |= 0x10U; /* set TDL_CHK in ep_cfg */ reg |= 0x20U; /* set SID_CHK in ep_cfg */ ep->maxStreams = ep->compDesc[3]; irqEnFlags |= DMARF_EP_IOT | DMARF_EP_PRIME | DMARF_EP_SIDERR | DMARF_EP_MD_EXIT | DMARF_EP_STREAMR; } } else { vDbgMsg(USBSSP_DBG_CUSBD, DBG_CRIT, "Endpoint companion descriptor not found for ep: %02X\n", ep->address); } } channelParams->epConfig = reg; channelParams->epIrqConfig = irqEnFlags; /* Configure endpoint */ /* Enable ITP interrupt for iso endpoint */ if ((epType & CH9_USB_EP_TRANSFER_MASK) == CH9_USB_EP_ISOCHRONOUS) { reg = CPS_UncachedRead32(&dev->reg->USBR_IEN); reg |= USB_IEN_ITPIEN; CPS_UncachedWrite32(&dev->reg->USBR_IEN, reg); } } static uint32_t epEnableEx(CUSBD_PrivateData *dev, CUSBD_Ep *ep, const uint8_t * desc, uint16_t maxPacketSize) { CUSBD_EpPrivate * epp = ep->epPrivate; uint8_t epNum = USBD_EPNUM_FROM_EPADDR(ep->address); uint8_t epDir = USBD_EPDIR_FROM_EPADDR(ep->address); uint32_t ret = CDN_EOK; CUSBDMA_ChannelParams channelParams; /* set enabled state */ epp->ep_state = CUSBD_EP_ENABLED; /* no pending transfer on initializing procedure */ epp->transferPending = 0; /* No actual request */ epp->actualReq = NULL; /* clear wedge flag */ epp->wedgeFlag = 0; ep->desc = desc; ep->maxPacket = maxPacketSize; channelParams.hwEpNum = epNum; channelParams.isDirTx = epDir; channelParams.wMaxPacketSize = maxPacketSize; /* configure endpoint hardware -- needs to be moved to cusbdma */ epEnableHw(dev, ep, desc, &channelParams); /* allocate DMA channel */ ret = dev->dmaDrv->channelAlloc(&(dev->dmaController), &epp->channel, &channelParams); if (ret == CDN_EOK) { epEnableInterrupt(dev, epNum, epDir); if ((epDir == 0U) && (epNum != 0U)) { cusbdAuxBufferEpSetMaxPktSz(dev, (epNum - 1U), maxPacketSize); } } else { vDbgMsg(USBSSP_DBG_CUSBD, DBG_CRIT, "Could not allocate DMA channel EP%d-%s", epNum, (epDir != 0U) ? "TX" : "RX"); } return ret; } /** * Function gets max burst value for SS and SSP mode * @param desc endpoint descriptor * @param maxBurstSize max burst value */ static void getMaxBurstSizeSS(uint8_t const * desc, uint8_t * maxBurstSize) { /* in endpoint descriptor, type is done on third byte, mask it with two less */ /* significant bits */ uint8_t epDescType = desc[3] & 0x03U; /* check if super speed endpoint companion available */ if ((desc[7] == CH9_USB_DS_SS_USB_EP_COMPANION) && (desc[8] == CH9_USB_DT_SS_USB_EP_COMPANION)) { vDbgMsg(USBSSP_DBG_CUSBD, DBG_HIVERB, "SuperSpeed Endpoint companion found-\n", 0); *maxBurstSize = desc[9]; if (epDescType == CH9_USB_EP_INTERRUPT) { if (*maxBurstSize > 2U) { vDbgMsg(USBSSP_DBG_CUSBD, DBG_HIVERB, "WARNING: Limiting SS interrupt-ep maxBurstSize(%d) to 2 \n", *maxBurstSize); *maxBurstSize = 2; } } } } /** * This function gets 'mult' value for an endpoint * @param epDesc: Pointer the endpoint descriptor * @param actualSpeed: Actual speed * @param maxburst: Max burst * @return The Mult value */ static uint8_t getMult(const uint8_t * epDesc, CH9_UsbSpeed actualSpeed, uint8_t maxburst) { uint8_t mult = 0U; uint8_t epDescType = epDesc[3] & 0x03U; /* Only set for Super speed ISO end point when maxburst is > 0 */ if ((actualSpeed >= CH9_USB_SPEED_SUPER) && (epDescType == CH9_USB_EP_ISOCHRONOUS) && (maxburst != 0U)) { mult = epDesc[10] & 0x03U; } else if (actualSpeed == CH9_USB_SPEED_HIGH) { if ((epDescType == CH9_USB_EP_INTERRUPT) || (epDescType == CH9_USB_EP_ISOCHRONOUS)) { mult = (epDesc[5] & 0x18U) >> 3U; } } else { /* * All 'if ... else if' constructs shall be terminated with an 'else' statement * (MISRA2012-RULE-15_7-3) */ } /* Check for error conditions */ if (mult > 2U) { vDbgMsg(USBSSP_DBG_CUSBD, DBG_HIVERB, "WARNING: Limiting mult(%d) to 2 \n", mult); mult = 2U; } return mult; } static uint32_t epEnable(CUSBD_PrivateData *pD, CUSBD_Ep *ep, const uint8_t * desc) { uint32_t ret = CDN_EOK; uint16_t maxPacketSize; /* check endpoint descriptor correctness */ if (desc[1] != CH9_USB_DT_ENDPOINT) { vDbgMsg(USBSSP_DBG_CUSBD, DBG_CRIT, "Invalid endpoint descriptor on ep: %02X\n", ep->address); ret = CDN_EINVAL; } if (ret == CDN_EOK) { /* calculate max packet size from bytes: 4 and 5 written in Little endian */ maxPacketSize = (((uint16_t) desc[5] & 0x7U) << 8) | (uint16_t) desc[4]; /* check maxPacketSize */ if (maxPacketSize == 0U) { vDbgMsg(USBSSP_DBG_CUSBD, DBG_CRIT, "Incorrect wMaxPacketSize: %d\n", maxPacketSize); ret = CDN_EINVAL; } } if (ret == CDN_EOK) { /* Set max burst size */ if (pD->device.speed >= CH9_USB_SPEED_SUPER) { getMaxBurstSizeSS(desc, &(ep->maxburst)); } /* set mult */ ep->mult = getMult(desc, pD->device.speed, ep->maxburst); ret = epEnableEx(pD, ep, desc, maxPacketSize); } return ret; } static void epDisableCallback(CUSBD_Ep * ep) { /* get extended endpoint object */ CUSBD_EpPrivate * epp = ep->epPrivate; /* check if request list not empty and call complete function */ if (epp->reqListHead != NULL) { CUSBD_Req * nextReq = getNextReq(epp); while (nextReq != NULL) { /* remove request from transfer queue */ reqListDeleteItem(&(epp->reqListHead), nextReq); nextReq->status = CDN_ECANCELED; /*call complete callback*/ nextReq->complete(ep, nextReq); nextReq = getNextReq(epp); } } } /** * Disable endpoint * @param pD pointer to driver object * @param ep pointer to endpoint object * @return CDN_EOK for success, error code elsewhere */ static uint32_t epDisable(CUSBD_PrivateData *pD, CUSBD_Ep * ep) { uint32_t ret = CDN_EOK; /* check if endpoint exist and return if no */ if (ep->address == 0U) { ret = CDN_EINVAL; } if (ret == CDN_EOK) { CUSBD_PrivateData* dev; CUSBD_EpPrivate * epp; dev = pD; epp = ep->epPrivate; ret = dev->dmaDrv->channelRelease(&(dev->dmaController), epp->channel); if (ret != CDN_EOK) { vDbgMsg(USBSSP_DBG_CUSBD, DBG_CRIT, "Could not release DMA channel on ep:%02X \n", ep->address); } /* call callback */ epDisableCallback(ep); /* set enabled state to disabled */ epp->ep_state = CUSBD_EP_DISABLED; epp->transferPending = 0U; /* Reset aux buffer for epOut */ if (ep->address <= 0xFU) { cusbdAuxBufferEpOutReset(dev, (ep->address - 1U)); } } return ret; } /** * start transfer on hardware * @param dev pointer to driver object * @param epp pointer to endpoint object * @param req pointer to request object * @return CDN_EOK for success, error code elsewhere */ static uint32_t reqQueueRunHw(CUSBD_PrivateData * dev, CUSBD_EpPrivate * epp, CUSBD_Req * req) { uint32_t ret = 0U; /* add request to transfer queue*/ reqListAddTail(&(epp->reqListHead), req); /* queue transfer on hardware */ epp->transferPending = 1U; epp->actualReq = epp->reqListHead; /* start transfer on hardware */ ret = startHwTransfer(dev, epp, req); return ret; } static uint32_t handleSwEpOutReq(CUSBD_PrivateData * dev, CUSBD_EpPrivate * epp, CUSBD_Req * req) { uint32_t ret = CDN_EOK; uint32_t isShortPacket = 0U; /* check if this ep-out has un-handled aux buffer*/ if (cusbdAuxBufferIsDataValid(dev, epp) != 0U) { uint32_t len = cusbdAuxBufferDequeue(dev, epp, req); isShortPacket = ((len == 0U) || ((len % epp->ep.maxPacket) != 0U)) ? 1U : 0U; } if ((isShortPacket != 0U) || (req->actual >= req->length)) { req->status = CDN_EOK; if (req->complete != NULL) { req->complete(&epp->ep, req); } } else { /* request is not yet processed - check whether it is being processed */ uint32_t isAuxReqPending = cusbdAuxBufferIsXferQueued(dev, epp); if (req->complete != NULL) { if (isAuxReqPending == 0U) { ret = reqQueueRunHw(dev, epp, req); } else { req->requestPending = 1U; /* add request to transfer queue*/ reqListAddTail(&(epp->reqListHead), req); } } else if (isAuxReqPending == 0U) { epp->transferPending = 1U; epp->actualReq = req; ret = startHwTransfer(dev, epp, req); } else { /* Request is pending and callback is not set. Ignore*/ } } return ret; } static uint32_t handleSwEpInReq(CUSBD_PrivateData * dev, CUSBD_EpPrivate * epp, CUSBD_Req * req) { uint32_t ret = CDN_EOK; /* program in the transfer for remaining data */ if ((req->noInterrupt) > 0U) { epp->transferPending = 1U; epp->actualReq = req; ret = startHwTransfer(dev, epp, req); } else { /* add req to queue and then program TRBs*/ ret = reqQueueRunHw(dev, epp, req); } return ret; } static uint32_t handleEp0Req(CUSBD_PrivateData * dev, CUSBD_Req * req) { uint32_t ret; vDbgMsg(USBSSP_DBG_CUSBD, DBG_FYI, "dev->ep0NextState: %d\n", dev->ep0NextState); /* -------- Patch for Linux SET_CONFIGURATION(1) handling -------------- */ if (dev->ep0NextState == CH9_EP0_STATUS_PHASE) { /* set status stage OK */ vDbgMsg(USBSSP_DBG_CUSBD, DBG_FYI, "EP0 reqQueue in status phase %d \n", 0); dev->device.state = CH9_USB_STATE_CONFIGURED; CPS_UncachedWrite32(&dev->reg->USBR_EP_SEL, 0x00); CPS_UncachedWrite32(&dev->reg->USBR_EP_CMD, EP_CMD_REQ_CMPL | EP_CMD_ERDY); /* status phase */ dev->ep0NextState = CH9_EP0_SETUP_PHASE; req->status = 0U; if (req->complete != NULL) { req->complete(&dev->ep0.ep, req); } ret = CDN_EOK; } else { /*---------------------------------------------------------------------- */ /* for default endpoint data must be transfered in context of setup request */ if (dev->ep0NextState != CH9_EP0_DATA_PHASE) { vDbgMsg(USBSSP_DBG_CUSBD, DBG_FYI, "Error EP0 reqQueue in setup or unconnected phase %d \n", 0); ret = CDN_EPROTO; } else { /* it is assumed that ep0 doesn't enqueues requests */ vDbgMsg(USBSSP_DBG_CUSBD, DBG_FYI, "Processing EP0 req in data phase %d \n", 0); ret = ep0transfer(dev, dev->ep0DataDirFlag, req->dma, req->length, (dev->ep0DataDirFlag > 0U) ? 0U : 1U); dev->request = req; } } return ret; } static uint32_t handleSwEpReq(CUSBD_PrivateData * dev, CUSBD_EpPrivate * epp, CUSBD_Req * req) { uint32_t ret = CDN_EOK; /* handle request based on ep-direction */ if ((epp->ep.address & 0x80U) != 0U) { ret = handleSwEpInReq(dev, epp, req); } else { ret = handleSwEpOutReq(dev, epp, req); } return ret; } static uint32_t handleStreamEpReq(CUSBD_PrivateData * dev, CUSBD_EpPrivate * epp, CUSBD_Req * req) { uint32_t ret = CDN_EOK; CUSBD_Req *lastReq = getLastReq(epp); uint16_t lastReqStreamId = 0U; uint8_t lastRequestPending = 0U; if (lastReq != NULL) { lastReqStreamId = lastReq->streamId; lastRequestPending = lastReq->requestPending; } vDbgMsg(USBSSP_DBG_CUSBD, DBG_FYI, "EP%d-%s size(%d) streamId(%d) reqBuf(0x%X) lastRequestPending(%d)\r\n", (epp->ep.address & 0xF), ((epp->ep.address & 0xF0) == 0U) ? "RX" : "TX", req->length, req->streamId, req->dma, lastRequestPending); /* Enqueue this request in TRB buffer IF * There are no requests in Queue OR * The streamID of the lastReq is same as the current req AND last req is also queued in */ if ((lastReq == NULL) || ((lastReqStreamId == req->streamId) && (lastRequestPending == 0U))) { /* handle request based on ep-direction */ if ((epp->ep.address & 0x80U) != 0U) { ret = handleSwEpInReq(dev, epp, req); } else { ret = handleSwEpOutReq(dev, epp, req); } } else { if (req->complete != NULL) { req->requestPending = 1; /* add request to transfer queue*/ reqListAddTail(&(epp->reqListHead), req); } else { ret = CDN_EOPNOTSUPP; } } return ret; } /** * queue request to transfer * @param pD pointer to driver object * @param ep pointer to endpoint object * @param req pointer to request object * @return CDN_EOK for success, error code elsewhere */ static uint32_t reqQueue(CUSBD_PrivateData *dev, const CUSBD_Ep *ep, CUSBD_Req * req) { uint32_t ret = 0U; CUSBD_EpPrivate * epp = ep->epPrivate; /* set the actual number of bytes xfered to 0 */ req->actual = 0; req->status = EINPROGRESS; vDbgMsg(USBSSP_DBG_CUSBD, DBG_FYI, "EP%d-%s req(0x%08X) buffer(0x%08X) size(0x%08X) \n", (ep->address & 0xF), ((ep->address & 0xF0) == 0U) ? "RX" : "TX", (uintptr_t) req, (uintptr_t) req->buf, req->length); if (ep->address == EP0_ADDRESS) { /* Handle EP0 requests */ ret = handleEp0Req(dev, req); } else { /* check if endpoint enabled */ if (epp->ep_state == CUSBD_EP_DISABLED) { ret = CDN_EPERM; } else if (epp->ep_state == CUSBD_EP_STALLED) { if (req->complete != NULL) { req->requestPending = 1; /* add request to transfer queue*/ reqListAddTail(&(epp->reqListHead), req); } } else if (epp->ep.maxStreams != 0U) { /* Handle stream requests */ ret = handleStreamEpReq(dev, epp, req); } else { /* Handle all other non-EP0 requests */ ret = handleSwEpReq(dev, epp, req); } } return ret; } /** * Remove request from transfer queue * @param pD pointer to driver object * @param ep pointer to endpoint object * @param req pointer to request object * @return CDN_EOK for success, error code elsewhere */ static uint32_t reqDequeue(CUSBD_Ep *ep, CUSBD_Req * req) { /* get extended object reference */ CUSBD_EpPrivate *epp = ep->epPrivate; /* update status */ req->status = CDN_ECANCELED; /* delete request from transfer queue*/ reqListDeleteItem(&(epp->reqListHead), req); if (req->complete != NULL) { /* call complete callback with CDN_ECANCELED status */ req->complete(ep, req); } return EOK; } /** * Set halt on selected endpoint * @param pD pointer to driver object * @param ep pointer to endpoint object * @param value 1 for setting, 0 for clearing halt * @return CDN_EOK for success, error code elsewhere */ static uint32_t epSetHalt(CUSBD_PrivateData *pD, const CUSBD_Ep *ep, uint8_t value) { uint32_t ret = CDN_EOK; CUSBD_PrivateData* dev; CUSBD_EpPrivate *epp; vDbgMsg(USBSSP_DBG_CUSBD, DBG_FYI, "ep:%02X\n", ep->address); dev = pD; /* get extended endpoint object */ epp = ep->epPrivate; if (epp->ep_state == CUSBD_EP_DISABLED) { ret = CDN_EPERM; } /* when endpoint isn't stalled */ if (ret == CDN_EOK) { if (value > 0U) { /* set stall */ ret = dev->dmaDrv->channelHandleStall(&dev->dmaController, epp->channel, 1U, CUSBD_DEFAULT_TIMEOUT); epp->ep_state = CUSBD_EP_STALLED; } else { CUSBD_Req *nextReq = epp->reqListHead; CUSBD_Req *headReq = nextReq; /* clear stall */ epp->wedgeFlag = 0; ret = dev->dmaDrv->channelHandleStall(&dev->dmaController, epp->channel, 0U, CUSBD_DEFAULT_TIMEOUT); epp->ep_state = CUSBD_EP_ENABLED; /* queue any pending requests */ while (nextReq != NULL) { if (nextReq->requestPending != 0U) { nextReq->requestPending = 0U; ret = handleSwEpReq(dev, epp, nextReq); } nextReq = nextReq->nextReq; if ((nextReq == headReq) || (ret != CDN_EOK)) { break; } } } epp->transferPending = 0; } return ret; } /** * Set wedge feature on endpoint object * @param pD pointer to driver object * @param ep pointer to endpoint object * @return CDN_EOK for success, error code elsewhere */ static uint32_t epSetWedge(CUSBD_PrivateData *pD, const CUSBD_Ep * ep) { uint32_t res; vDbgMsg(USBSSP_DBG_CUSBD, DBG_FYI, "EP%d-%s epSetWedge", (ep->address & 0xF), ((ep->address & 0x80) != 0U) ? "TX" : "RX"); /* set wedge field in driver object */ ep->epPrivate->wedgeFlag = 1U; /* execute halt on endpoint*/ res = epSetHalt(pD, ep, 1); return res; } /** * Flush FIFO for selected endpoint * @param pD pointer to driver object * @param ep pointer to endpoint object */ static uint32_t epFifoFlush(CUSBD_PrivateData *pD, const CUSBD_Ep * ep) { uint32_t ret = CDN_EOK; CUSBD_PrivateData* dev; vDbgMsg(USBSSP_DBG_CUSBD, DBG_FYI, "ep:%02X\n", ep->address); dev = pD; /* Do flush on endpoint hardware*/ CPS_UncachedWrite32(&dev->reg->USBR_EP_SEL, (uint32_t) ep->address); CPS_UncachedWrite32(&dev->reg->USBR_EP_CMD, EP_CMD_DFLUSH); /* wait until operation is complete */ ret = waitUntilBitCleared(&dev->reg->USBR_EP_CMD, EP_CMD_DFLUSH); return ret; } static const CUSBD_EpOps epOps = { CUSBD_EpEnable, CUSBD_EpDisable, CUSBD_EpSetHalt, CUSBD_EpSetWedge, CUSBD_EpFifoStatus, CUSBD_EpFifoFlush, CUSBD_ReqQueue, CUSBD_ReqDequeue }; /* private function, initializes default endpoint, main/ISR context */ static uint32_t buildEp0config(uint16_t maxPacketSize) { uint32_t reg = 0U; /* configure endpoint-0 */ SET_EP_CONF_ENABLE(&reg); SET_EP_CONF_EPTYPE(&reg, USBRV_EP_CONTROL); SET_EP_CONF_MAXPKTSIZE(&reg, maxPacketSize); return reg; } /** * get max packet size for default endpoint * @param dev Pointer to druver object */ static uint16_t getEp0MaxPacketSize(const CUSBD_PrivateData * dev) { uint16_t maxPacketSize = 0U; /* select max packet size for default endpoint*/ switch (dev->device.speed) { /* max packet size is decided based on speed */ case CH9_USB_SPEED_LOW: /* low speed */ maxPacketSize = 8U; break; case CH9_USB_SPEED_FULL: /* full speed */ maxPacketSize = 64U; break; case CH9_USB_SPEED_HIGH: /* high speed */ maxPacketSize = 64U; break; case CH9_USB_SPEED_SUPER: /* super speed */ maxPacketSize = 512U; break; default: /* default max packet size */ maxPacketSize = 512U; break; } return maxPacketSize; } /** * initialize hardware of default endpoint * @param dev pointer to driver object */ static void initEp0Hw(CUSBD_PrivateData * dev) { uint16_t maxPacketSize = getEp0MaxPacketSize(dev); dev->ep0.ep.maxPacket = maxPacketSize; dev->ep0NextState = CH9_EP0_SETUP_PHASE; vDbgMsg(USBSSP_DBG_CUSBD, DBG_FYI, "EP0 maxPacket: %d\n", dev->ep0.ep.maxPacket); } static void initDevHw(CUSBD_PrivateData * dev) { uint32_t dmult = 0U; uint32_t usbForceDisconnect = 0U; ssReg_t* reg = dev->reg; if ((dev->config.dmultEnabled > 0U) && (dev->deviceVersion < DEV_VER_V3)) { /* Enable global DMULT mode if supported and configured */ dmult = USB_CONF_DMULT; } if (dev->config.forcedUsbMode == 1U) { /* Disconnect USB3 if mode if forced to 2 */ usbForceDisconnect = USB_CONF_USB3DIS | USB_CONF_SFORCE_FS; } else if (dev->config.forcedUsbMode == 2U) { /* Disconnect USB3 if mode if forced to 2 */ usbForceDisconnect = USB_CONF_USB3DIS; } else { /* Needed for MISRA compliance */ } /* configure device */ CPS_UncachedWrite32(&reg->USBR_CONF, USB_CONF_L1EN | dmult | usbForceDisconnect); if (dev->deviceVersion == DEV_VER_V3) { CPS_UncachedWrite32(&reg->DTRANS, dev->config.dmultEnabled); } /* clear all interrupts */ CPS_UncachedWrite32(&dev->reg->USBR_ISTS, 0xFFFFFFFFU); /* enable interrupts */ CPS_UncachedWrite32(&dev->reg->USBR_IEN, USB_IEN_UWRESIEN | USB_IEN_UHRESIEN | USB_IEN_DISIEN | USB_IEN_CONIEN | USB_IEN_CON2I | USB_IEN_U1ENTIEN | USB_IEN_U2ENTIEN | USB_IEN_U2RESIEN | USB_IEN_DIS2I); } static uint32_t initSwEp(CUSBD_PrivateData * dev, const CUSBD_EpConfig *endpoint, uint8_t dir) { uint8_t i; CUSBD_EpPrivate * epPriv; const CUSBD_EpConfig *ep = endpoint; for (i = 0U; i < 15U; i++) { if (ep[i].bufferingValue > 0U) { vDbgMsg(USBSSP_DBG_CUSBD, 1, " initSwEp Initializing EP%d-%s \n", (i + 1U), (dir != 0U) ? "TX" : "RX"); /* add endpoint to endpoint list */ if (dir > 0U) { epPriv = &dev->ep_in_container[i]; } else { epPriv = &dev->ep_out_container[i]; } /* clear endpoint object - this will ALSO set reqListHead pointers to NULL */ (void) memset(epPriv, 0, sizeof (CUSBD_EpPrivate)); /* set endpoint address */ epPriv->ep.address = ((dir > 0U) ? CH9_USB_EP_DIR_IN : 0U) | (uint8_t) (i + 1U); /* set MaxPacketSize */ epPriv->ep.maxPacket = 1024U; /* set Max Burst */ epPriv->ep.maxburst = 0U; /*set max stream */ epPriv->ep.maxStreams = 0U; /*set MULT */ epPriv->ep.mult = 0U; /* set endpoint pseudo-class public methods */ epPriv->ep.ops = &epOps; /* set pointer to epPriv */ epPriv->ep.epPrivate = epPriv; /*add endpoint to endpoint list */ listAddTail(&epPriv->ep.epList, &dev->device.epList); } else { vDbgMsg(USBSSP_DBG_CUSBD, 1, " initSwEp Skipping EP%d-%s \n", (i + 1U), (dir != 0U) ? "TX" : "RX"); } } return EOK; } /** * Update reqAlloc field of driver object * @param dev * @param size */ static void updateReqAlloc(CUSBD_PrivateData* dev, uint16_t size) { uint32_t ret = CDN_EOK; /* update field*/ dev->reqAlloc.length = size; dev->reqAlloc.dma = dev->setupPacketDma; dev->reqAlloc.complete = NULL; /* send request to hardware */ ret = reqQueue(dev, &dev->ep0.ep, &dev->reqAlloc); if (ret != CDN_EOK) { vDbgMsg(USBSSP_DBG_CUSBD, DBG_CRIT, "Could not reply to GET STATUS command\n", 0); } } /** * handle get status standard setup request * @param dev pointer to driver object * @param ctrl pointer to setup control request * @return CDN_EOK for success, error code elsewhere */ static uint32_t getStatus(CUSBD_PrivateData * dev, CH9_UsbSetup *ctrl) { uint16_t size = ctrl->wLength; uint8_t recip = (ctrl->bmRequestType & CH9_REQ_RECIPIENT_MASK); uint32_t ret = CDN_EOK; /* parasoft-begin-suppress MISRA2012-RULE-11_4 " uintptr_t converted to 'uint32_t*', DRV-4385" */ uint8_t * dmaBuf = (uint8_t *) dev->setupPacketDma; /* parasoft-end-suppress MISRA2012-RULE-11_4 */ switch (recip) { /* recipient device */ case CH9_USB_REQ_RECIPIENT_DEVICE: dev->status_value = cpuToLe16((uint16_t) dev->u2_value | (uint16_t) dev->u1_value | (uint16_t) 1U); /* write status in LE order */ dmaBuf[0] = (uint8_t) dev->status_value; dmaBuf[1] = (uint8_t) ((dev->status_value >> 8) & (uint16_t) 0x00FF); updateReqAlloc(dev, size); break; /* recipient interface */ case CH9_USB_REQ_RECIPIENT_INTERFACE: ctrl->wIndex = cpuToLe16(ctrl->wIndex); ctrl->wLength = cpuToLe16(ctrl->wLength); ctrl->wValue = cpuToLe16(ctrl->wValue); ret = dev->callbacks.setup(dev, ctrl); vDbgMsg(USBSSP_DBG_CUSBD, DBG_CRIT, "getStatus res: %d\n", ret); break; /* recipient endpoint */ case CH9_USB_REQ_RECIPIENT_ENDPOINT: CPS_UncachedWrite32(&dev->reg->USBR_EP_SEL, ctrl->wIndex); if ((CPS_UncachedRead32(&dev->reg->USBR_EP_STS) & EP_STS_STALL) > 0U) { dev->status_value = cpuToLe16(1U); } else { dev->status_value = cpuToLe16(0U); } /* write status in LE order */ dmaBuf[0] = (uint8_t) dev->status_value; dmaBuf[1] = (uint8_t) ((dev->status_value >> 8) & (uint16_t) 0x00FF); updateReqAlloc(dev, size); break; default: ret = CDN_EINVAL; break; } return ret; } /** * handle U1 feature * @param dev pointer to driver object * @param set 1 for set, 0 for clear * @return CDN_EOK for success, error code elsewhere */ static uint32_t handleFeatureRecDevU1(CUSBD_PrivateData * dev, uint8_t set) { uint32_t ret = CDN_EOK; CH9_UsbState state = dev->device.state; /* request only valid for configured device*/ if (state != CH9_USB_STATE_CONFIGURED) { ret = CDN_EINVAL; } /* check actual speed*/ if (dev->device.speed != CH9_USB_SPEED_SUPER) { ret = CDN_EINVAL; } if (ret == CDN_EOK) { /* set feature to hardware controller */ uint32_t reg = CPS_UncachedRead32(&dev->reg->USBR_CONF); if (set > 0U) { dev->u1_value = 0x04U; reg |= USB_CONF_U1EN; } else { dev->u1_value = 0x00U; reg |= USB_CONF_U1DS; } /* write to hardware configuration register*/ CPS_UncachedWrite32(&dev->reg->USBR_CONF, reg); } return ret; } /** * handle U2 feature * @param dev pointer to driver object * @param set 1 for set, 0 for clear * @return CDN_EOK for success, error code elsewhere */ static uint32_t handleFeatureRecDevU2(CUSBD_PrivateData * dev, uint8_t set) { uint32_t ret = CDN_EOK; CH9_UsbState state = dev->device.state; /* request only valid for configured device*/ if (state != CH9_USB_STATE_CONFIGURED) { ret = CDN_EINVAL; } /* check actual speed*/ if (dev->device.speed != CH9_USB_SPEED_SUPER) { ret = CDN_EINVAL; } if (ret == CDN_EOK) { /* set feature to hardware controller */ uint32_t reg = CPS_UncachedRead32(&dev->reg->USBR_CONF); if (set > 0U) { dev->u2_value = 0x08; reg |= USB_CONF_U2EN; } else { dev->u2_value = 0x00; reg |= USB_CONF_U2DS; } /* write to hardware configuration register*/ CPS_UncachedWrite32(&dev->reg->USBR_CONF, reg); } return ret; } /** * Handle feature, recipient device, test mode * @param dev pointer to driver object * @param ctrl pointer to setup object * @return CDN_EOK for success, error code elsewhere */ static uint32_t handleFeatureRecDevTest(CUSBD_PrivateData * dev, const CH9_UsbSetup *ctrl) { uint32_t wIndex = ctrl->wIndex; uint32_t ret = CDN_EOK; if ((wIndex & 0xffU) != 0U) { ret = CDN_EINVAL; } if (ret == CDN_EOK) { uint8_t test_selector = (uint8_t) ((ctrl->wIndex >> 8) & 0x00FFU); uint32_t regSelec = 0U; switch (test_selector) { /* TEST J */ case CH9_TEST_J: SET_USB_CMD_TMODE_SEL(&regSelec, USBRV_TM_TEST_J); break; /*test K*/ case CH9_TEST_K: SET_USB_CMD_TMODE_SEL(&regSelec, USBRV_TM_TEST_K); break; /*test se0_NAK*/ case CH9_TEST_SE0_NAK: SET_USB_CMD_TMODE_SEL(&regSelec, USBRV_TM_SE0_NAK); break; /* packet test */ case CH9_TEST_PACKET: SET_USB_CMD_TMODE_SEL(&regSelec, USBRV_TM_TEST_PACKET); break; case CH9_TEST_FORCE_EN: break; default:; break; } CPS_UncachedWrite32(&dev->reg->USBR_CMD, regSelec); } return ret; } /** * handle set/clear feature standard setup request for device recipient * @param dev pointer to driver object * @param ctrl pointer to setup object * @param set 1 for setting feature, 0 for clearing feature * @return CDN_EOK for success, error code elsewhere */ static uint32_t handleFeatureRecipientDevice(CUSBD_PrivateData * dev, const CH9_UsbSetup *ctrl, uint8_t set) { uint32_t ret = CDN_EOK; uint32_t wValue = ctrl->wValue; switch (wValue) { case CH9_USB_FS_DEVICE_REMOTE_WAKEUP: break; /* * 9.4.1 says only only for SS, in AddressState only for * default control pipe */ /* handle U1 feature */ case CH9_USB_FS_U1_ENABLE: ret = handleFeatureRecDevU1(dev, set); break; /* handle U2 feature */ case CH9_USB_FS_U2_ENABLE: ret = handleFeatureRecDevU2(dev, set); break; case CH9_USB_FS_LTM_ENABLE: ret = CDN_EINVAL; break; /* handle test mode */ case CH9_USB_FS_TEST_MODE: ret = handleFeatureRecDevTest(dev, ctrl); break; default: ret = CDN_EINVAL; break; } return ret; } /** * handle set/clear feature standard setup request for recipient interface * @param dev pointer to driver object * @param ctrl pointer to setup object * @return CDN_EOK for success, error code elsewhere */ static uint32_t handleFeatureRecipientInterface(CUSBD_PrivateData * dev, const CH9_UsbSetup *ctrl) { uint32_t wIndex; uint32_t wValue; uint32_t ret = CDN_EOK; wValue = ctrl->wValue; wIndex = ctrl->wIndex; switch (wValue) { /* for suspend selector */ case CH9_USB_FS_FUNCTION_SUSPEND: if ((wIndex & CH9_USB_SF_LOW_PWR_SUSP_STATE) > 0U) { /* XXX enable Low power suspend */ dev->suspend = (ctrl->wIndex & 0x0100U); } if ((wIndex & CH9_USB_SF_REMOTE_WAKE_ENABLED) > 0U) { /* XXX enable remote wakeup */ break; } break; default: ret = CDN_EINVAL; break; } return ret; } /** * handle set/clear feature for endpoint recipient * @param dev pointer to driver object * @param ctrl pointer to setup object * @param set 1 for setting stall, 0 for clearing stall * @return CDN_EOK for success, error code elsewhere */ static uint32_t handleFeatureRecipientEndpoint(CUSBD_PrivateData * dev, const CH9_UsbSetup *ctrl, uint8_t set) { CUSBD_EpPrivate * epp; uint32_t ret = CDN_EINVAL; uint32_t tempSel; uint8_t epAddress = (uint8_t) ctrl->wIndex; uint16_t wValue = ctrl->wValue; uint8_t epIndex = USBD_EPNUM_FROM_EPADDR(epAddress); uint8_t epDir = USBD_EPDIR_FROM_EPADDR(epAddress); /* get endpoint from endpoint container */ if (epDir > 0U) { epp = &dev->ep_in_container[epIndex - 1U]; } else { epp = &dev->ep_out_container[epIndex - 1U]; } /* check if endpoint is available at all */ if (epp->ep.ops != NULL) { ret = CDN_EOK; } if (ret == CDN_EOK) { tempSel = CPS_UncachedRead32(&dev->reg->USBR_EP_SEL); CPS_UncachedWrite32(&dev->reg->USBR_EP_SEL, (uint32_t) epp->ep.address); switch (wValue) { case CH9_USB_FS_ENDPOINT_HALT: if (set > 0U) { /* issue set stall to hardware controller */ ret = epSetHalt(dev, &epp->ep, 1); } else { if (epp->wedgeFlag == 0U) { /* handle clear feature*/ ret = epSetHalt(dev, &epp->ep, 0); } else { /* do nothing */ vDbgMsg(USBSSP_DBG_CUSBD, DBG_FYI, "CAN'T CLEAR ENDPOINT STALL %c\n", ' '); } }/*else (set) */ break; default: CPS_UncachedWrite32(&dev->reg->USBR_EP_SEL, tempSel); ret = CDN_EINVAL; break; } } if (ret == CDN_EOK) { CPS_UncachedWrite32(&dev->reg->USBR_EP_SEL, tempSel); } return ret; } /** * handle set/clear feature standard request * @param dev pointer to driver object * @param ctrl pointer to setup object * @param set 1 for set, 0 for clear * @return CDN_EOK for success, error code elsewhere */ static uint32_t handleFeature(CUSBD_PrivateData * dev, CH9_UsbSetup const *ctrl, uint8_t set) { uint32_t stat; switch (ctrl->bmRequestType & CH9_REQ_RECIPIENT_MASK) { /* recipient device */ case CH9_USB_REQ_RECIPIENT_DEVICE: stat = handleFeatureRecipientDevice(dev, ctrl, set); break; /*recipient interface */ case CH9_USB_REQ_RECIPIENT_INTERFACE: stat = handleFeatureRecipientInterface(dev, ctrl); break; /*recipient endpoint*/ case CH9_USB_REQ_RECIPIENT_ENDPOINT: stat = handleFeatureRecipientEndpoint(dev, ctrl, set); break; default: stat = CDN_EINVAL; break; }; return stat; } /** * handle set address standard request * @param dev pointer to driver object * @param ctrl pointer to setup object * @return CDN_EOK for success, error code elsewhere */ static uint32_t setAddress(CUSBD_PrivateData * dev, CH9_UsbSetup *ctrl) { uint32_t ret = CDN_EOK; CH9_UsbState state = dev->device.state; uint16_t addr; addr = ctrl->wValue; /* check if device address is within correct range */ if (addr > 0x007FU) { vDbgMsg(USBSSP_DBG_CUSBD, DBG_CRIT, "Invalid device address %d\n", addr); ret = CDN_EINVAL; } /* check if device is in correct state */ if (ret == CDN_EOK) { if (state == CH9_USB_STATE_CONFIGURED) { vDbgMsg(USBSSP_DBG_CUSBD, DBG_CRIT, "Trying to set address when configured %c\n", ' '); ret = CDN_EINVAL; } } if (ret == CDN_EOK) { /* set device address in controller */ CPS_UncachedWrite32(&dev->reg->USBR_CMD, (((uint32_t) ctrl->wValue & 0x007FU) << 1) | 0x00000001U); if (addr > 0U) { dev->device.state = CH9_USB_STATE_ADDRESS; } else { dev->device.state = CH9_USB_STATE_DEFAULT; } } return ret; } /** * Handle set configuration request for device in addresses state * @param dev pointer to driver object * @param ctrl pointer to setup object * @param confValue configuration value * @return CDN_EOK for success, error code elsewhere */ static uint32_t setConfigStateAddressed(CUSBD_PrivateData * dev, CH9_UsbSetup *ctrl, uint8_t confValue) { uint32_t ret; /* create setup object in CPU endian */ ctrl->wIndex = cpuToLe16(ctrl->wIndex); ctrl->wLength = cpuToLe16(ctrl->wLength); ctrl->wValue = cpuToLe16(ctrl->wValue); if (confValue > 0U) { /* set configuration in hardware controller */ CPS_UncachedWrite32(&dev->reg->USBR_CONF, USB_CONF_CFGSET); } ret = dev->callbacks.setup(dev, ctrl); if ((confValue > 0U) && (ret == CDN_EOK)) { /* check if USB controller has resources for required configuration */ /* and return error if no */ if ((CPS_UncachedRead32(&dev->reg->USBR_STS) & USB_STS_MEM_OV) > 0U) { ret = CDN_EINVAL; } } return ret; } /** * handle set configuration setup request * @param dev pointer to driver object * @param ctrl pointer to setup object * @return CDN_EOK for success, error code elsewhere */ static uint32_t setConfig(CUSBD_PrivateData * dev, CH9_UsbSetup *ctrl) { uint8_t confValue = (uint8_t) (ctrl->wValue & 0x00FFU); uint32_t ret; switch (dev->device.state) { /* state default: return error */ case CH9_USB_STATE_DEFAULT: ret = CDN_EINVAL; break; /* addressed state */ case CH9_USB_STATE_ADDRESS: ret = setConfigStateAddressed(dev, ctrl, confValue); break; /* configured state */ case CH9_USB_STATE_CONFIGURED: ctrl->wIndex = cpuToLe16(ctrl->wIndex); ctrl->wLength = cpuToLe16(ctrl->wLength); ctrl->wValue = cpuToLe16(ctrl->wValue); ret = dev->callbacks.setup(dev, ctrl); if (ret == CDN_EOK) { /* SET_CONFIGURATION(0): unconfigure hardware controller */ if (confValue == 0U) { CPS_UncachedWrite32(&dev->reg->USBR_CONF, USB_CONF_CFGRST); dev->device.state = CH9_USB_STATE_ADDRESS; } else { CPS_UncachedWrite32(&dev->reg->USBR_CONF, USB_CONF_CFGSET); if ((CPS_UncachedRead32(&dev->reg->USBR_STS) & USB_STS_MEM_OV) > 0U) { ret = CDN_EINVAL; } } } break; default: ret = CDN_EINVAL; break; } return ret; } static uint32_t setSel(CUSBD_PrivateData * dev, CH9_UsbSetup const *ctrl) { uint32_t ret = CDN_EOK; /* check current state */ if (dev->device.state == CH9_USB_STATE_DEFAULT) { ret = CDN_EINVAL; } /* check if setup has correct parameters */ if (ret == CDN_EOK) { if (ctrl->wLength != 6U) { vDbgMsg(USBSSP_DBG_CUSBD, DBG_FYI, "Set SEL should be 6 bytes, got %d\n", ctrl->wLength); ret = CDN_EINVAL; } } if (ret == CDN_EOK) { /* start transfer on default endpoint for 1 byte of data*/ dev->reqAlloc.complete = NULL; dev->reqAlloc.length = ctrl->wLength; dev->reqAlloc.actual = 0; dev->reqAlloc.status = EINPROGRESS; dev->request = &dev->reqAlloc; ret = ep0transfer(dev, 0U, (uintptr_t) dev->setupPacketDma, ctrl->wLength, 1U); } return ret; } static uint32_t setIsochDelay(CUSBD_PrivateData * dev, CH9_UsbSetup const *ctrl) { uint32_t ret = CDN_EOK; /* check if setup has correct parameters */ if ((ctrl->wIndex > 0U) || (ctrl->wLength > 0U)) { ret = CDN_EINVAL; } else { /* update isoch_delay private member of driver object */ dev->isoch_delay = ctrl->wValue; } return ret; } static uint32_t setupDevStand(CUSBD_PrivateData * dev, CH9_UsbSetup *ctrl) { uint32_t res = CDN_EOK; switch (ctrl->bRequest) { /* get status request */ case CH9_USB_REQ_GET_STATUS: res = getStatus(dev, ctrl); break; /* clear feature request */ case CH9_USB_REQ_CLEAR_FEATURE: res = handleFeature(dev, ctrl, 0U); break; /* set feature request */ case CH9_USB_REQ_SET_FEATURE: res = handleFeature(dev, ctrl, 1U); break; /* set address request */ case CH9_USB_REQ_SET_ADDRESS: res = setAddress(dev, ctrl); break; /* set configuration request */ case CH9_USB_REQ_SET_CONFIGURATION: res = setConfig(dev, ctrl); break; /* set sel request */ case CH9_USB_REQ_SET_SEL: res = setSel(dev, ctrl); break; /* set iso delay request */ case CH9_USB_REQ_ISOCH_DELAY: res = setIsochDelay(dev, ctrl); break; default: /* handle class or vendor specific request */ ctrl->wIndex = cpuToLe16(ctrl->wIndex); ctrl->wLength = cpuToLe16(ctrl->wLength); ctrl->wValue = cpuToLe16(ctrl->wValue); vDbgMsg(USBSSP_DBG_CUSBD, DBG_FYI, "res: %08X\n", res); res = dev->callbacks.setup(dev, ctrl); break; } return res; } static uint32_t setupDev(CUSBD_PrivateData * dev, CH9_UsbSetup *ctrl) { uint32_t res = 0U; uint16_t size = ctrl->wLength; /* check if data phase exists*/ if (size > 0U) { dev->ep0NextState = CH9_EP0_DATA_PHASE; } else { dev->ep0NextState = CH9_EP0_STATUS_PHASE; } /* set data direction flag */ if ((ctrl->bmRequestType & CH9_USB_DIR_DEVICE_TO_HOST) > 0U) { dev->ep0DataDirFlag = 1U; } else { dev->ep0DataDirFlag = 0U; } /* check if request is a standard request */ if ((ctrl->bmRequestType & CH9_USB_REQ_TYPE_MASK) == CH9_USB_REQ_TYPE_STANDARD) { res = setupDevStand(dev, ctrl); } else { /* delegate setup for class and vendor specific requests */ ctrl->wIndex = cpuToLe16(ctrl->wIndex); ctrl->wLength = cpuToLe16(ctrl->wLength); ctrl->wValue = cpuToLe16(ctrl->wValue); res = dev->callbacks.setup(dev, ctrl); } return res; } /** * handle status phase of control transfer * @param dev pointer to driver object */ static void handleEp0IrqStatus(CUSBD_PrivateData* dev) { if (dev->ep0NextState == CH9_EP0_STATUS_PHASE) { /* set status stage OK */ vDbgMsg(USBSSP_DBG_CUSBD, DBG_FYI, "Handle status phase %d\n", 0); CPS_UncachedWrite32(&dev->reg->USBR_EP_CMD, EP_CMD_REQ_CMPL | EP_CMD_ERDY); /* status phase */ dev->ep0NextState = CH9_EP0_SETUP_PHASE; /* check if any ep0 request waits for completion, If YES complete it */ if (dev->request != NULL) { if ((dev->request->length == 0U) && (dev->request->status == CDN_EINPROGRESS)) { vDbgMsg(USBSSP_DBG_CUSBD, DBG_FYI, "Call callback%s\n", " "); dev->request->status = 0U; /* call complete callback if defined */ if (dev->request->complete != NULL) { dev->request->complete(&dev->ep0.ep, dev->request); } } } } } /** * handle of setup phase of control transfer * @param dev pointer to device object * @param ep_sts pointer to endpoint status ep_sts register */ static uint32_t handleEp0IrqSetup(CUSBD_PrivateData* dev, uint32_t * ep_sts) { uint32_t ret = CDN_EOK; uint8_t i; CH9_UsbSetup ctrl; dev->request = NULL; /* display setup packet*/ vDbgMsg(USBSSP_DBG_CUSBD, DBG_FYI, "SETUP: %c\n", ' '); for (i = 0; i < 8U; i++) { vDbgMsg(USBSSP_DBG_CUSBD, DBG_FYI, "%02X", ((uint8_t *) dev->setupPacket)[i]); } vDbgMsg(USBSSP_DBG_CUSBD, DBG_FYI, "%c\n", ' '); /* create USB setup object */ ctrl.bRequest = dev->setupPacket->bRequest; ctrl.bmRequestType = dev->setupPacket->bmRequestType; ctrl.wIndex = le16ToCpu(dev->setupPacket->wIndex); ctrl.wLength = le16ToCpu(dev->setupPacket->wLength); ctrl.wValue = le16ToCpu(dev->setupPacket->wValue); ret = cusbdmaIsr(dev); CPS_UncachedWrite32(&dev->reg->USBR_EP_SEL, 0x00); CPS_UncachedWrite32(&dev->reg->USBR_EP_STS, EP_STS_SETUP | EP_STS_ISP | EP_STS_IOC); /* clear flags */ *ep_sts &= ~(EP_STS_SETUP | EP_STS_ISP | EP_STS_IOC); /* parse setup request */ ret = setupDev(dev, &ctrl); vDbgMsg(USBSSP_DBG_CUSBD, DBG_FYI, "res: %08X\n", ret); CPS_UncachedWrite32(&dev->reg->USBR_EP_SEL, 0x00); /* -------- Patch for Linux SET_CONFIGURATION(1) handling -------------- */ if (ret == CUSBD_INACTIVITY_TMOUT) { vDbgMsg(USBSSP_DBG_CUSBD, DBG_CRIT, "Respond delayed not finished yet%s\n", " "); dev->ep0NextState = CH9_EP0_STATUS_PHASE; } else { /*---------------------------------------------------------------------- */ if (ret != CDN_EOK) { vDbgMsg(USBSSP_DBG_CUSBD, DBG_FYI, "setupDev returned error %x\n", ret); CPS_UncachedWrite32(&dev->reg->USBR_EP_CMD, EP_CMD_SSTALL); CPS_UncachedWrite32(&dev->reg->USBR_EP_CMD, EP_CMD_REQ_CMPL | EP_CMD_ERDY); dev->ep0NextState = CH9_EP0_SETUP_PHASE; } else { handleEp0IrqStatus(dev); } } return ret; } /** * Handle IOC interrupt on default endpoint * @param dev pointer to driver object * @param dirFlag default endpoint direction */ static void handleEp0IrqIoc(CUSBD_PrivateData* dev) { (void) cusbdmaIsr(dev); /* check if actual transfer is done */ if (dev->request->actual >= dev->request->length) { vDbgMsg(USBSSP_DBG_CUSBD, DBG_FYI, "No more data to transfer on ep0%c\n", ' '); } /* this gets sent even for short packet */ dev->request->status = 0U; if (dev->request->complete != NULL) { dev->request->complete(&dev->ep0.ep, dev->request); } dev->ep0NextState = CH9_EP0_SETUP_PHASE; CPS_UncachedWrite32(&dev->reg->USBR_EP_SEL, 0x00U); CPS_UncachedWrite32(&dev->reg->USBR_EP_CMD, EP_CMD_REQ_CMPL | EP_CMD_ERDY); } /** * handle event generated on default endpoint * @param dev pointer to driver object * @param dirFlag default endpoint direction: 0 for OUT endpoint, 1 for IN */ static uint32_t handleEp0Irq(CUSBD_PrivateData* dev, uint8_t dirFlag) { uint32_t ep_sts; uint8_t dir = (dirFlag > 0U) ? 0x80U : 0x00U; uint32_t ret = CDN_EOK; CPS_UncachedWrite32(&dev->reg->USBR_EP_SEL, dir); ep_sts = CPS_UncachedRead32(&dev->reg->USBR_EP_STS); vDbgMsg(USBSSP_DBG_CUSBD, DBG_FYI, "EP0-%s, ep_sts: (%x)\n", (dirFlag > 0U) ? "TX" : "RX", ep_sts); /* clear TRB ERROR flag */ if ((ep_sts & EP_STS_TRBERR) > 0U) { vDbgMsg(USBSSP_DBG_CUSBD, DBG_FYI, "Handle TRB error dirFlag %d\n", dirFlag); CPS_UncachedWrite32(&dev->reg->USBR_EP_STS, EP_STS_TRBERR); } /* clear MISMATCH flag */ if ((ep_sts & EP_STS_OUTSMM) > 0U) { vDbgMsg(USBSSP_DBG_CUSBD, DBG_FYI, "Handle OUTSMM error dirFlag %d\n", dirFlag); CPS_UncachedWrite32(&dev->reg->USBR_EP_STS, EP_STS_OUTSMM); } /* Setup packet completion */ if ((ep_sts & EP_STS_SETUP) > 0U) { /* for ep0 setup IRQ overrides IOC and ISP */ ret = handleEp0IrqSetup(dev, &ep_sts); ep_sts &= ~(EP_STS_IOC | EP_STS_ISP); } else { /* should be called only when data phase exists */ if (((ep_sts & EP_STS_IOC) > 0U) || ((ep_sts & EP_STS_ISP) > 0U)) { handleEp0IrqIoc(dev); } else { if ((ep_sts & EP_STS_DESCMIS) > 0U) { CPS_UncachedWrite32(&dev->reg->USBR_EP_STS, EP_STS_DESCMIS); /* check if setup packet came in */ /* setup always come on OUT direction */ if ((dir == 0U) && (dev->ep0NextState == CH9_EP0_SETUP_PHASE)) { ret = ep0transfer(dev, 0U, (uintptr_t) dev->setupPacketDma, (uint32_t) (sizeof (CH9_UsbSetup)), 0U); } } } } return ret; } /********************************************************************** * API methods **********************************************************************/ /** * Obtain the private memory size required by the driver * @param[in] config driver/hardware configuration required * @param[out] sysReqCusbd returns the size of memory allocations required * @return 0 on success (requirements structure filled) * @return CDN_ENOTSUP if configuration cannot be supported due to driver/hardware constraints */ uint32_t CUSBD_Probe(const CUSBD_Config* config, CUSBD_SysReq* sysReqCusbd) { uint32_t ret = CUSBD_ProbeSF(config, sysReqCusbd); if (ret == CDN_EOK) { if ((config->didRegPtr == 0U) || (config->ridRegPtr == 0U)) { vDbgMsg(USBSSP_DBG_CUSBD, DBG_CRIT, "Warning! DID, RID register pointers are not set.\n", 0); } else { /* parasoft-begin-suppress MISRA2012-RULE-11_4 "uintptr_t converted to 'uint32_t *', DRV-4273" */ uint32_t did = CPS_UncachedRead32((uint32_t*) (config->didRegPtr)); uint32_t rid = CPS_UncachedRead32((uint32_t*) (config->ridRegPtr)); /* parasoft-end-suppress MISRA2012-RULE-11_4 */ if ((did != CUSBD_DID_VAL) && (rid != CUSBD_RID_VAL)) { ret = CDN_EPERM; } } } if (ret == CDN_EOK) { CUSBDMA_OBJ * dmaDrv = NULL; CUSBDMA_Config dmaConfig; CUSBDMA_SysReq sysReqCusbdma; (void) memset((void *) &dmaConfig, 0, sizeof (CUSBDMA_Config)); dmaConfig.regBase = config->regBase; /* check DMA controller memory requirements */ dmaDrv = CUSBDMA_GetInstance(); ret = dmaDrv->probe(&dmaConfig, &sysReqCusbdma); if (ret == CDN_EOK) { /* Device memory */ sysReqCusbd->privDataSize = (uint32_t)sizeof (CUSBD_PrivateData); /* + 8 is a length of setup packet */ sysReqCusbd->trbMemSize = sysReqCusbdma.trbMemSize + 8U; } } return ret; } #ifdef CUSBDSS_DMA_ACCESS_NON_SECURE /** * Configure DMA_AXI_CTRL for non secure access * @param reg: Pointer the the controller registers */ static void setAXIAccessNonSecure(ssReg_t* reg) { uint32_t regval = CPS_UncachedRead32(&reg->DMA_AXI_CTRL); /* set MARPROT bits to non-secure access */ regval = SET_DMA_AXI_CTRL_MARPROT(regval, DMA_AXI_CTRL_NON_SECURE); /* set MAWPROT bits to non-secure access */ regval = SET_DMA_AXI_CTRL_MAWPROT(regval, DMA_AXI_CTRL_NON_SECURE); CPS_UncachedWrite32(&reg->DMA_AXI_CTRL, regval); } #endif static uint32_t ramInit(CUSBD_PrivateData* pD) { CUSBD_PrivateData * dev = pD; uint32_t ret = CDN_EOK; /* The on-chip memory initialization requirements: - It should be performed as a first SW operation after POR - It must be performed before any Endpoint configurations ( any EP_XXX register) - it must be performed before USB_CONF.DEVEN (VBUS enable) is set */ /* wait until USB_STS.IN_RST is '1' (reset for USB clock domain is finished) */ ret = waitUntilBitSet(&(dev->reg->USBR_STS), USB_STS_IN_RST); if (ret == CDN_EOK) { /* set USB_PWR.FAST_REG_ACCESS bit (to ensure that USB clock is running even without VBUS) */ CPS_UncachedWrite32(&dev->reg->USBR_PWR, USB_PWR_FAST_REG_ACCESS); /* wait until USB_PWR.FAST_REG_ACCESS_STAT is '1' */ ret = waitUntilBitSet(&(dev->reg->USBR_PWR), USB_PWR_FAST_REG_ACCESS_STAT); } if (ret == CDN_EOK) { /* set BUF_ADDR register (it addresses individual words, not Bytes) to max address for attached memory . */ /* In case of TI we have 4 * 3328 of 32bit words, so max address is 13312 (0x3400). */ /* So we need to write 0x3400 to BUF_ADDR */ CPS_UncachedWrite32(&dev->reg->USBR_BUF_ADDR, 0x000033FF); /* BUF_DATA can be left as 0x00000000 (RSTV) then whole memory will be initialized to 0 */ CPS_UncachedWrite32(&dev->reg->USBR_BUF_DATA, 0x00000000); /* set BUF_CTRL.BUF_CMD_IWD (Incremental write down) bit + BUF_CMD_SET (one write). */ /* This will start internal operation of writing all memory cells (starting from BUFF_ADDR down to 0) */ /* with value prepared in BUF_DATA. For TI memory initialization should take about 27 us. */ CPS_UncachedWrite32(&dev->reg->USBR_BUF_CTRL, BUF_CTRL_BUF_CMD_SET | BUF_CTRL_BUF_CMD_IWD); /* wait until BUF_CTRL.BUF_CMD_STS is '0' it means that memory initialization was finished */ ret = waitUntilBitCleared(&(dev->reg->USBR_BUF_CTRL), BUF_CTRL_BUF_CMD_STS); } return ret; } /** * Initialize endpoints * @param dev pointer do driver object */ static inline uint32_t initConfigEpHw(const CUSBD_PrivateData* dev) { uint32_t ret = CDN_EOK; ssReg_t *cusbdReg = dev->reg; uint8_t i; /* initialize buffering value for all endpoints */ for (i = 0U; i < 30U; i++) { const CUSBD_EpConfig *ep; uint8_t epIndex = 0U; /* get proper endpoint object */ if (i < 15U) { epIndex = i; ep = &dev->config.epIN[epIndex]; } else { epIndex = i - 15U; ep = &dev->config.epOUT[epIndex]; epIndex |= 0x80U; } ++epIndex; /* ep_sel requires incrementation */ /* first check if endpoint is available */ if (ep->bufferingValue > 0U) { uint32_t epCfgReg = 0U; CPS_UncachedWrite32(&(cusbdReg->USBR_EP_SEL), epIndex); SET_EP_CONF_ENABLE(&epCfgReg); SET_EP_CONF_MAXPKTSIZE(&epCfgReg, USB_SS_MAX_PACKET_SIZE); SET_EP_CONF_BUFFERING(&epCfgReg, ep->bufferingValue - 1U); CPS_UncachedWrite32(&(cusbdReg->USBR_EP_CFG), epCfgReg); } } /* check if hardware has enough resources for required configuration */ CPS_UncachedWrite32(&(cusbdReg->USBR_CONF), USB_CONF_CFGSET); /* and return error if resources problem */ if (GET_USB_STS_MEM_OV(CPS_UncachedRead32(&cusbdReg->USBR_STS)) > 0U) { ret = CDN_ENOTSUP; } return ret; } /** * Initialize DMA module * @param dev pointer to driver object * @param dmaConfig pointer to DMA confuiguration structure * @return CDN_EOK if success, error code elsewhere */ static inline uint32_t initConfigDMA(CUSBD_PrivateData * dev, CUSBDMA_Config * dmaConfig) { uint32_t ret = CDN_EOK; /* set endpoint configuration bitmask for dmult mode */ if (dev->deviceVersion < DEV_VER_V3) { if (dev->config.dmultEnabled > 0U) { dmaConfig->dmaModeRx = 0xFFFF; dmaConfig->dmaModeTx = 0xFFFF; } else { dmaConfig->dmaModeRx = 0x0000; dmaConfig->dmaModeTx = 0x0000; } } else { /* For Device V3: Bits[15:0]: Control DMULT enable for EP-Out[15:0] * Bits[31:16]: Control DMULT enable for EP-In[15:0] */ dmaConfig->dmaModeRx = (uint16_t) (dev->config.dmultEnabled & 0xFFFFU); dmaConfig->dmaModeTx = (uint16_t) ((dev->config.dmultEnabled >> 16U) & 0xFFFFU); } /* initialize DMA module */ ret = dev->dmaDrv->init(&(dev->dmaController), dmaConfig); if (ret != CDN_EOK) { vDbgMsg(USBSSP_DBG_CUSBD, DBG_CRIT, "Could not initialize DMA controller\n", 0); } return ret; } /** * Initialize device object * @param dev pointer to driver object * @param dmaConfig pointer to DMA configuration object * @return CDN_EOK if no error, Error code elsewhere */ static inline uint32_t initConfigDev(CUSBD_PrivateData * dev, CUSBDMA_Config * dmaConfig) { uint32_t ret = CDN_EOK; CUSBDMA_SysReq dmaSysReq; uint32_t deviceVersion = CPS_UncachedRead32(&dev->reg->USBR_CAP6); /* if resources available, unconfigure device by now. It will be configured */ /* in SET_CONFIG context during enumeration */ CPS_UncachedWrite32(&dev->reg->USBR_CONF, USB_CONF_CFGRST); dev->deviceVersion = GET_USBR_CAP6_DEV_BASE_VER(deviceVersion); /* set device general device state to initial state */ dev->device.speed = CH9_USB_SPEED_UNKNOWN; dev->device.maxSpeed = CH9_USB_SPEED_SUPER; dev->device.state = CH9_USB_STATE_DEFAULT; /* <----- check if we set status, probably higher layer sets it */ #ifdef DEBUG (void) strncpy(dev->device.name, SS_DEV_NAME, sizeof (SS_DEV_NAME)); #endif /* Creating DMA Controller */ dev->dmaDrv = CUSBDMA_GetInstance(); dmaConfig->regBase = dev->config.regBase; dmaConfig->epMemRes = dev->config.epMemRes; ret = dev->dmaDrv->probe(dmaConfig, &dmaSysReq); if (ret != CDN_EOK) { vDbgMsg(USBSSP_DBG_CUSBD, DBG_CRIT, "Could not probe DMA controller\n", 0); } else { ret = initConfigDMA(dev, dmaConfig); } return ret; } /** * initialize default endpoint software object * @param dev pointer to driver object * @return CDN_EOK if no error, Error code elsewhere */ static inline uint32_t initEp0(CUSBD_PrivateData * dev) { uint32_t ret = CDN_EOK; CUSBDMA_ChannelParams channelParams; initEp0Hw(dev); /* initialize endpoint 0 - software */ dev->ep0.ep.address = EP0_ADDRESS; dev->ep0.ep.ops = &epOps; dev->device.ep0 = &dev->ep0.ep; channelParams.hwEpNum = 0U; channelParams.isDirTx = 1U; channelParams.wMaxPacketSize = getEp0MaxPacketSize(dev); channelParams.epConfig = buildEp0config(channelParams.wMaxPacketSize); channelParams.epIrqConfig = EP_STS_EN_SETUPEN | EP_STS_EN_DESCMISEN | EP_STS_EN_TRBERREN | EP_STS_EN_OUTSMMEN; /* save endpoint name */ #ifdef DEBUG (void) strncpy(dev->ep0.ep.name, EP0_NAME, 5); #endif /* initialize DMA channel for this endpoint */ ret = dev->dmaDrv->channelAlloc(&(dev->dmaController), &dev->ep0DmaChannelIn, &channelParams); if (ret != CDN_EOK) { vDbgMsg(USBSSP_DBG_CUSBD, DBG_CRIT, "Could not allocate EP0-IN channel\n", 0); } if (ret == CDN_EOK) { channelParams.isDirTx = 0U; ret = dev->dmaDrv->channelAlloc(&(dev->dmaController), &dev->ep0DmaChannelOut, &channelParams); if (ret != CDN_EOK) { vDbgMsg(USBSSP_DBG_CUSBD, DBG_CRIT, "Could not allocate EP0-OUT channel\n", 0); } } return ret; } /** * initialize non default endpoint software object * @param dev pointer to driver object * @return CDN_EOK if no error, Error code elsewhere */ static inline uint32_t initEp(CUSBD_PrivateData * dev) { uint32_t ret = CDN_EOK; CUSBD_EpConfig *ep; /* initialize endpoints given in configuration */ listInit(&dev->device.epList); /* initialize IN endpoints*/ ep = dev->config.epIN; ret = initSwEp(dev, ep, 1U); if (ret != CDN_EOK) { vDbgMsg(USBSSP_DBG_CUSBD, DBG_CRIT, "Could not initialize IN endpoints\n", 0); } if (ret == CDN_EOK) { /* Initialize OUT endpoints */ ep = dev->config.epOUT; ret = initSwEp(dev, ep, 0U); if (ret != CDN_EOK) { vDbgMsg(USBSSP_DBG_CUSBD, DBG_CRIT, "Could not initialize OUT endpoints\n", 0); } } return ret; } /** * Reset private fields of driver object * @param pD pointer to driver object */ static inline void initResetPriv(CUSBD_PrivateData * dev) { /* Reset pointer to the setup packet */ dev->setupPacket = dev->config.setupPacket; dev->setupPacketDma = dev->config.setupPacketDma; /* reset all internal state variable */ dev->status_value = 0U; dev->suspend = 0U; dev->u1_value = 0U; dev->u2_value = 0U; } static inline uint32_t initHw(CUSBD_PrivateData* dev) { uint32_t ret = CDN_EOK; CUSBDMA_Config dmaConfig; /* Initialize device object */ ret = initConfigDev(dev, &dmaConfig); /* initialize non default endpoints */ if (ret == CDN_EOK) { ret = initEp(dev); } if (ret == CDN_EOK) { /* reset private driver members */ initResetPriv(dev); /* Configure Device hardware */ initDevHw(dev); /* initialize default endpoint */ (void) initEp0(dev); } return ret; } /** * Initialize the driver instance and state, configure the USB device * as specified in the 'config' settings, initialize locks used by the * driver. * @param[in] pD driver state info specific to this instance * @param[in,out] config specifies driver/hardware configuration * @param[in] callbacks client-supplied callback functions * @return CDN_EOK on success * @return CDN_ENOTSUP if hardware has an inconsistent configuration or doesn't support feature(s) required by 'config' parameters * @return CDN_ENOENT if insufficient locks were available (i.e. something allocated locks between probe and init) * @return CDN_EIO if driver encountered an error accessing hardware * @return CDN_EINVAL if illegal/inconsistent values in 'config' */ uint32_t CUSBD_Init(CUSBD_PrivateData* pD, const CUSBD_Config* config, const CUSBD_Callbacks* callbacks) { uint32_t ret = CUSBD_InitSF(pD, config, callbacks); if (ret == CDN_EOK) { pD->callbacks = *callbacks; pD->config = *config; /* parasoft-begin-suppress MISRA2012-RULE-11_4 "'unsigned long' converted to 'ssReg_t *', DRV-4277" */ pD->reg = (ssReg_t*) pD->config.regBase; /* get pointer to HW registers */ /* parasoft-end-suppress MISRA2012-RULE-11_4 */ vDbgMsg(USBSSP_DBG_CUSBD, DBG_FYI, "regBase %08X\n", pD->config.regBase); #ifdef CUSBDSS_DMA_ACCESS_NON_SECURE setAXIAccessNonSecure(pD->reg); #endif #ifndef VSP_SIM ret = ramInit(pD); #endif #ifdef CPU_BIG_ENDIAN CPS_UncachedWrite32(&pD->reg->USBR_CONF, cpu_to_le32(USBRF_BENDIAN)); #endif if (ret == CDN_EOK) { /* Init aux buffer for EP-OUT */ cusbdAuxBufferInit(pD); /* configure endpoints */ ret = initConfigEpHw(pD); /* initialize hardware */ if (ret == CDN_EOK) { ret = initHw(pD); } } } return ret; } /** * Destroy the driver (automatically performs a stop) * @param[in] pD driver state info specific to this instance * @return CDN_EOK on success * @return CDN_EINVAL if illegal/inconsistent values in 'config' */ uint32_t CUSBD_Destroy(const CUSBD_PrivateData* pD) { uint32_t ret = CUSBD_DestroySF(pD); return ret; } /** * Start the USB driver. * @param[in] pD driver state info specific to this instance * @return CDN_EOK on success * @return CDN_EINVAL if illegal/inconsistent values in 'config' */ uint32_t CUSBD_Start(CUSBD_PrivateData* pD) { uint32_t ret = CUSBD_StartSF(pD); if (ret == CDN_EOK) { #ifndef VSP_SIM CUSBD_PrivateData * dev = pD; uint32_t reg; /* clear USB_PWR.FAST_REG_ACCESS bit to restore initial value */ reg = CPS_UncachedRead32(&dev->reg->USBR_PWR); reg &= ~USB_PWR_FAST_REG_ACCESS; CPS_UncachedWrite32(&dev->reg->USBR_PWR, reg); /* Check the USBSS-DEV controller version number */ if (dev->deviceVersion == DEV_VER_V1) { /* Fix LFPS timing */ reg = CPS_UncachedRead32(&dev->reg->USBR_DBG_LINK1); reg &= ~LINK1_LFPS_MIN_GEN_U1_EXIT; reg |= 0x00005500U; reg |= LINK1_LFPS_MIN_GEN_U1_EXIT_SET; CPS_UncachedWrite32(&dev->reg->USBR_DBG_LINK1, reg); } #endif /* Enable USB Device */ CPS_UncachedWrite32(&pD->reg->USBR_CONF, USB_CONF_DEVEN); } return ret; } /** * Stop the driver. This should disable the hardware, including its * interrupt at the source, and make a best-effort to cancel any * pending transactions. * @param[in] pD driver state info specific to this instance * @return CDN_EOK on success * @return CDN_EINVAL if illegal/inconsistent values in 'config' */ uint32_t CUSBD_Stop(CUSBD_PrivateData* pD) { uint32_t ret = CUSBD_StopSF(pD); if (ret == CDN_EOK) { /* disconnect device from host */ CPS_UncachedWrite32(&pD->reg->USBR_CONF, USB_CONF_DEVDS); } return ret; } /** * Abort all pending requests * @param pD pointer to device driver object */ static inline void handleIsrDevRSAbortReq(CUSBD_PrivateData* dev) { uint8_t i; /* abort requests for all endpoints */ for (i = 0U; i < 30U; i++) { CUSBD_Req * req; CUSBD_EpPrivate * epp; uint32_t ret; if (i < 15U) { epp = &dev->ep_in_container[i]; } else { epp = &dev->ep_out_container[i - 15U]; } if (epp->ep.ops == NULL) { continue; } /* release DMA channel */ ret = dev->dmaDrv->channelRelease(&(dev->dmaController), epp->channel); if (ret != CDN_EOK) { vDbgMsg(USBSSP_DBG_CUSBD, DBG_FYI, "Could not release DMA channel\n", 0); } epp->transferPending = 0; epp->ep_state = CUSBD_EP_DISABLED; /* endpoint disabled */ req = getNextReq(epp); /* abort request */ while (req != NULL) { reqListDeleteItem(&(epp->reqListHead), req); req->status = CDN_ECANCELED; req->complete(&epp->ep, req); req = getNextReq(epp); } } } /** * handle device interrupt for Resets and disconnect event * @param pD pointer to device driver object * @param usb_ists usb_ists register value */ static inline void handleIsrDevRS(CUSBD_PrivateData* dev, uint32_t usb_ists, uint8_t *exitFlag) { vDbgMsg(USBSSP_DBG_CUSBD, DBG_FYI, "handleIsrDevRS called with usb_ists: %x\n", usb_ists); /* set speed field */ if ((usb_ists & USB_ISTS_DISI) > 0U) { dev->device.speed = CH9_USB_SPEED_UNKNOWN; } else if ((usb_ists & USB_ISTS_UWRESI) > 0U) { } else if ((usb_ists & USB_ISTS_UHRESI) > 0U) { } else if ((usb_ists & USB_ISTS_DIS2I) > 0U) { dev->device.speed = CH9_USB_SPEED_UNKNOWN; } else if ((usb_ists & USB_ISTS_U2RESI) > 0U) { dev->device.speed = getActualSpeed(dev); if (dev->callbacks.usb2PhySoftReset != NULL) { vDbgMsg(USBSSP_DBG_CUSBD, DBG_FYI, "Invoking USB 2 PHY reset@ %lx\n", dev->callbacks.usb2PhySoftReset); dev->callbacks.usb2PhySoftReset(dev); } } else { /* required by MISRA */ } /* abort all pending requests on all active endpoints */ handleIsrDevRSAbortReq(dev); /* Reset SW endpoints */ CPS_UncachedWrite32(&dev->reg->USBR_CONF, USB_CONF_CFGRST); /* Reset aux buffer pointers */ cusbdAuxBufferReset(dev); /* clear interrupt flags */ CPS_UncachedWrite32(&dev->reg->USBR_ISTS, USB_ISTS_DISI | USB_ISTS_UWRESI | USB_ISTS_UHRESI | USB_ISTS_DIS2I | USB_ISTS_U2RESI); /* update device state */ dev->device.state = CH9_USB_STATE_DEFAULT; dev->u1_value = 0U; dev->u2_value = 0U; /* call callback */ dev->callbacks.disconnect(dev); *exitFlag = 1U; } /** * Handle U3 related interrupt * @param dev pointer to device driver object * @param usb_ists usb_ists register value * @param exitFlag pointer to exitFlag */ static inline void handleIsrDevOtherU3(CUSBD_PrivateData* dev, uint32_t usb_ists, uint8_t *exitFlag) { /* enter U3 */ if (((usb_ists & USB_ISTS_U3ENTI) > 0U) && (*exitFlag == 0U)) { CPS_UncachedWrite32(&dev->reg->USBR_ISTS, USB_ISTS_U3ENTI); *exitFlag = 1U; } /* exit U3 */ if (((usb_ists & USB_ISTS_U3EXTI) > 0U) && (*exitFlag == 0U)) { CPS_UncachedWrite32(&dev->reg->USBR_ISTS, USB_ISTS_U3EXTI); *exitFlag = 1U; } } /** * Handle U2 related interrupt * @param dev pointer to device driver object * @param usb_ists usb_ists register value * @param exitFlag pointer to exitFlag */ static inline void handleIsrDevOtherU2(CUSBD_PrivateData* dev, uint32_t usb_ists, uint8_t *exitFlag) { /* enter U2 */ if (((usb_ists & USB_ISTS_U2ENTI) > 0U) && (*exitFlag == 0U)) { CPS_UncachedWrite32(&dev->reg->USBR_ISTS, USB_ISTS_U2ENTI); *exitFlag = 1U; } /* exit U2 */ if (((usb_ists & USB_ISTS_U2EXTI) > 0U) && (*exitFlag == 0U)) { CPS_UncachedWrite32(&dev->reg->USBR_ISTS, USB_ISTS_U2EXTI); *exitFlag = 1U; } } /** * Handle U1 related interrupt * @param dev pointer to device driver object * @param usb_ists usb_ists register value * @param exitFlag pointer to exitFlag */ static inline void handleIsrDevOtherU1(CUSBD_PrivateData* dev, uint32_t usb_ists, uint8_t *exitFlag) { /* enter U1 */ if (((usb_ists & USB_ISTS_U1ENTI) > 0U) && (*exitFlag == 0U)) { CPS_UncachedWrite32(&dev->reg->USBR_ISTS, USB_ISTS_U1ENTI); *exitFlag = 1U; } /* exit U1 */ if (((usb_ists & USB_ISTS_U1EXTI) > 0U) && (*exitFlag == 0U)) { CPS_UncachedWrite32(&dev->reg->USBR_ISTS, USB_ISTS_U1EXTI); *exitFlag = 1U; } } /** * Handle other interrupts * @param dev pointer to device driver object * @param usb_ists usb_ists register value * @param exitFlag pointer to exitFlag */ static inline void handleIsrDevOther(CUSBD_PrivateData* dev, uint32_t usb_ists, uint8_t *exitFlag) { /* handle U1 */ handleIsrDevOtherU1(dev, usb_ists, exitFlag); /* handle U2 */ handleIsrDevOtherU2(dev, usb_ists, exitFlag); /* handle U3 */ handleIsrDevOtherU3(dev, usb_ists, exitFlag); /* handle ITP */ if (((usb_ists & USB_ISTS_ITPI) > 0U) && (*exitFlag == 0U)) { CPS_UncachedWrite32(&dev->reg->USBR_ISTS, USB_ISTS_ITPI); if (dev->callbacks.busInterval != NULL) { dev->callbacks.busInterval(dev); } *exitFlag = 1U; } } /** * internal function, handle device interrupt * @param pD pointer to device driver object * @param usb_ists usb_ists register value */ static inline void handleIsrDev(CUSBD_PrivateData* dev, uint32_t usb_ists, uint8_t *exitFlag) { if ( ((usb_ists & USB_ISTS_DISI) > 0U) || ((usb_ists & USB_ISTS_UWRESI) > 0U) || ((usb_ists & USB_ISTS_UHRESI) > 0U) || ((usb_ists & USB_ISTS_DIS2I) > 0U) || ((usb_ists & USB_ISTS_U2RESI) > 0U) ) { handleIsrDevRS(dev, usb_ists, exitFlag); } /* USB Connect interrupt */ if ((((usb_ists & USB_ISTS_CONI) > 0U) || ((usb_ists & USB_ISTS_CON2I) > 0U)) && (*exitFlag == 0U)) { /* initialize endpoint 0 - software */ CPS_UncachedWrite32(&dev->reg->USBR_ISTS, USB_ISTS_CONI | USB_ISTS_CON2I); /* set actual USB speed */ dev->device.speed = getActualSpeed(dev); initDevHw(dev); /* configure device hardware */ /* update EP0 max packet size */ dev->ep0.ep.maxPacket = getEp0MaxPacketSize(dev); (void) dev->dmaDrv->channelSetMaxPktSz(&dev->dmaController, dev->ep0DmaChannelIn, dev->ep0.ep.maxPacket); (void) dev->dmaDrv->channelSetMaxPktSz(&dev->dmaController, dev->ep0DmaChannelIn, dev->ep0.ep.maxPacket); vDbgMsg(USBSSP_DBG_CUSBD, DBG_FYI, "CONNECT EVENT, actual speed: %d\n", dev->device.speed); vDbgMsg(USBSSP_DBG_CUSBD, DBG_FYI, "CONNECT EVENT, max speed: %d\n", dev->device.maxSpeed); dev->callbacks.connect(dev); /* call user callback */ *exitFlag = 1U; } handleIsrDevOther(dev, usb_ists, exitFlag); } /** * Handle other interrupts * @param dev pointer to device driver object * @param ep_ists ep_ists register value * @param exitFlag pointer to exitFlag */ static inline uint32_t isrHandleEp0(CUSBD_PrivateData* dev, uint32_t ep_ists, uint8_t *exitFlag) { uint32_t ret = CDN_EOK; /* ep0out */ if (((ep_ists & 0x00000001U) > 0U) && (*exitFlag == 0U)) { vDbgMsg(USBSSP_DBG_CUSBD, DBG_FYI, "Handle EP0-out IRQ %x\n", ep_ists); ret = handleEp0Irq(dev, 0U); *exitFlag = 1U; } /* ep0in */ if (((ep_ists & 0x00010000U) > 0U) && (*exitFlag == 0U)) { vDbgMsg(USBSSP_DBG_CUSBD, DBG_FYI, "Handle EP0-in IRQ %x\n", ep_ists); ret = handleEp0Irq(dev, 1U); *exitFlag = 1U; } return ret; } /** * Driver ISR. Platform-specific code is responsible for ensuring * this gets called when the corresponding hardware's interrupt is * asserted. Registering the ISR should be done after calling init, * and before calling start. The driver's ISR will not attempt to lock * any locks, but will perform client callbacks. If the client wishes * to defer processing to non-interrupt time, it is responsible for * doing so. * @param[in] pD driver state info specific to this instance */ uint32_t CUSBD_Isr(CUSBD_PrivateData* pD) { uint32_t ret = CUSBD_IsrSF(pD); if (ret == CDN_EOK) { uint32_t usb_ists, ep_ists; CUSBD_PrivateData* dev = pD; uint8_t exitFlag = 0U; /* first check device interrupt */ usb_ists = CPS_UncachedRead32(&dev->reg->USBR_ISTS); vDbgMsg(USBSSP_DBG_CUSBD, DBG_FYI, "USB_ISTS: %08X\n", usb_ists); if (usb_ists > 0U) { handleIsrDev(dev, usb_ists, &exitFlag); } /* check if interrupt generated by endpoint */ ep_ists = CPS_UncachedRead32(&dev->reg->USBR_EP_ISTS); vDbgMsg(USBSSP_DBG_CUSBD, DBG_FYI, "EP_ISTS_0: %08X\n", ep_ists); if ((ep_ists == 0U) && (exitFlag == 0U)) { exitFlag = 1U; /* set exitFlag to return if no int. generated*/ } /* check if interrupt generated by default endpoint on both directions (ss speed) */ ret = isrHandleEp0(dev, ep_ists, &exitFlag); if (ret == CDN_EOK) { if (exitFlag == 0U) { ret = cusbdmaIsr(dev); } if ((ret != CDN_EOK) && (exitFlag == 0U)) { vDbgMsg(USBSSP_DBG_CUSBD, DBG_CRIT, "DMA handling irq error!\n", 0); } } } return ret; } /** * Enable Endpoint. This function should be called within * SET_CONFIGURATION(configNum > 0) request context. It configures * required hardware controller endpoint with parameters given in * desc. * @param[in] pD driver state info specific to this instance * @param[in] ep endpoint being configured * @param[in] desc endpoint descriptor * @return 0 on success * @return CDN_EINVAL if pD, ep or desc is NULL or desc is not a endpoint descriptor */ uint32_t CUSBD_EpEnable(CUSBD_PrivateData* pD, CUSBD_Ep* ep, const uint8_t* desc) { uint32_t ret = CDN_EOK; ret = CUSBD_EpEnableSF(pD, ep, desc); if (CDN_EOK == ret) { ret = epEnable(pD, ep, desc); } return ret; } /** * Disable Endpoint. Functions unconfigures hardware endpoint. * Endpoint will not respond to any host packets. This function should * be called within SET_CONFIGURATION(configNum = 0) request context * or on disconnect event. All queued requests on endpoint are * completed with CDN_ECANCELED status. * @param[in] pD driver state info specific to this instance * @param[in] ep endpoint being unconfigured * @return 0 on success * @return CDN_EINVAL if pD or ep is NULL */ uint32_t CUSBD_EpDisable(CUSBD_PrivateData* pD, CUSBD_Ep* ep) { uint32_t ret = CDN_EOK; ret = CUSBD_EpDisableSF(pD, ep); if (CDN_EOK == ret) { ret = epDisable(pD, ep); } return ret; } /** * Set halt or clear halt state on endpoint. When setting halt, device * will respond with STALL packet to each host packet. When clearing * halt, endpoint returns to normal operating. * @param[in] pD driver state info specific to this instance * @param[in] ep endpoint being setting or clearing halt state * @param[in] value if 1 sets halt, if 0 clears halt on endpoint * @return 0 on success * @return CDN_EPERM if endpoint is disabled (has not been configured yet) * @return CDN_EINVAL if pD or ep is NULL */ uint32_t CUSBD_EpSetHalt(CUSBD_PrivateData* pD, const CUSBD_Ep* ep, uint8_t value) { uint32_t ret = CDN_EOK; ret = CUSBD_EpSetHaltSF(pD, ep); if (CDN_EOK == ret) { ret = epSetHalt(pD, ep, value); } return ret; } /** * Set halt on endpoint. Function sets endpoint to permanent halt * state. State can not be changed even with epSetHalt(pD, ep, 0) * function. Endpoint returns automatically to its normal state on * disconnect event. * @param[in] pD driver state info specific to this instance * @param[in] ep endpoint being setting halt state * @return 0 on success * @return CDN_EPERM if endpoint is disabled (has not been configured yet) * @return CDN_EINVAL if pD or ep is NULL */ uint32_t CUSBD_EpSetWedge(CUSBD_PrivateData* pD, const CUSBD_Ep* ep) { uint32_t ret = CDN_EOK; ret = CUSBD_EpSetWedgeSF(pD, ep); if (CDN_EOK == ret) { ret = epSetWedge(pD, ep); } return ret; } /** * Returns number of bytes in hardware endpoint FIFO. Function useful * in application where exact number of data bytes is required. In * some situation software higher layers must be aware of number of * data bytes issued but not transfered by hardware because of aborted * transfers, for example on disconnect event. * * @param[in] pD driver state info specific to this instance * @param[in] ep endpoint which status is to be returned * @return number of bytes in hardware endpoint FIFO * @return CDN_EINVAL if pD or ep is NULL */ uint32_t CUSBD_EpFifoStatus(const CUSBD_PrivateData* pD, const CUSBD_Ep* ep) { uint32_t ret = CDN_EOK; ret = CUSBD_EpFifoStatusSF(pD, ep); if (CDN_EOK == ret) { /* Function needs to be implemented*/ vDbgMsg(USBSSP_DBG_CUSBD, DBG_FYI, "ep:%02X\n", ep->address); } return ret; } /** * Flush hardware endpoint FIFO. * @param[in] pD driver state info specific to this instance * @param[in] ep endpoint which FIFO is to be flushed */ uint32_t CUSBD_EpFifoFlush(CUSBD_PrivateData* pD, const CUSBD_Ep* ep) { uint32_t ret = CDN_EOK; ret = CUSBD_EpFifoFlushSF(pD, ep); if (CDN_EOK == ret) { ret = epFifoFlush(pD, ep); } return ret; } /** * Submits IN/OUT transfer request to an endpoint. * @param[in] pD driver state info specific to this instance * @param[in] ep endpoint associated with the request * @param[in] req request being submitted * @return 0 on success * @return CDN_EPROTO only on default endpoint if endpoint is not in data stage phase * @return CDN_EPERM if endpoint is not enabled * @return CDN_EINVAL if pD, ep, or req is NULL */ uint32_t CUSBD_ReqQueue(CUSBD_PrivateData* pD, const CUSBD_Ep* ep, CUSBD_Req* req) { uint32_t ret = CUSBD_ReqQueueSF(pD, ep, req); if (ret == CDN_EOK) { ret = reqQueue(pD, ep, req); } return ret; } /** * Dequeues IN/OUT transfer request from an endpoint. Function * completes all queued request with CDN_ECANCELED status. * @param[in] pD driver state info specific to this instance * @param[in] ep endpoint associated with the request * @param[in] req request being dequeued * @return 0 on success * @return CDN_EINVAL if pD or ep is NULL */ uint32_t CUSBD_ReqDequeue(CUSBD_PrivateData* pD, CUSBD_Ep* ep, CUSBD_Req* req) { uint32_t ret = CUSBD_ReqDequeueSF(pD, ep, req); if (ret == CDN_EOK) { ret = reqDequeue(ep, req); } return ret; } /** * Returns pointer to CUSBD object. CUSBD object is a logical * representation of USB device. CUSBD contains endpoint collection * accessed through epList field. Endpoints collection is organized as * double linked list. * @param[in] pD driver state info specific to this instance * @param[out] dev returns pointer to CUSBD instance */ void CUSBD_GetDevInstance(CUSBD_PrivateData* pD, CUSBD_Dev** dev) { uint32_t ret = ((pD == NULL) || (dev == NULL)) ? CDN_EINVAL : CDN_EOK; if (CDN_EOK == ret) { *dev = &pD->device; } } /** * Returns number of frame. Some controllers have counter of SOF * packets or ITP packets in the Super Speed case. Function returns * value of this counter. This counter can be used for time * measurement. Single FS frame is 1 ms measured, for HS and SS is * 125us. * @param[in] pD driver state info specific to this instance * @param[out] numOfFrame returns number of USB frame * @return CDN_EOK on success * @return CDN_EOPNOTSUPP if feature is not supported * @return CDN_EINVAL if pD or numOfFrame is NULL */ uint32_t CUSBD_DGetFrame(CUSBD_PrivateData* pD, uint32_t* numOfFrame) { uint32_t ret = CUSBD_DGetFrameSF(pD, numOfFrame); if (ret == CDN_EOK) { *numOfFrame = CPS_UncachedRead32(&pD->reg->USBR_ITPN); } return ret; } /** * Sets the device self powered feature. * @param[in] pD driver state info specific to this instance * @return CDN_EOK on success * @return CDN_EOPNOTSUPP if feature is not supported * @return CDN_EINVAL if pD is NULL */ uint32_t CUSBD_DSetSelfpowered(const CUSBD_PrivateData* pD) { uint32_t ret = CUSBD_DSetSelfpoweredSF(pD); if (ret == CDN_EOK) { ret = CDN_ENOTSUP; } return ret; } /** * Clear the device self powered feature. * @param[in] pD driver state info specific to this instance * @return CDN_EOK on success * @return CDN_EOPNOTSUPP if feature is not supported * @return CDN_EINVAL if pD is NULL */ uint32_t CUSBD_DClearSelfpowered(const CUSBD_PrivateData* pD) { uint32_t ret = CUSBD_DClearSelfpoweredSF(pD); if (ret == CDN_EOK) { ret = CDN_ENOTSUP; } return ret; } /** * Returns configuration parameters: U1 exit latency and U2 exit * latency Function useful only in Super Speed mode. * @param[in] pD driver state info specific to this instance * @param[out] configParams pointer to CH9_ConfigParams structure * @return CDN_EOK on success * @return CDN_EINVAL if illegal/inconsistent values in 'config' */ uint32_t CUSBD_DGetConfigParams(const CUSBD_PrivateData* pD, CH9_ConfigParams* configParams) { uint32_t ret = CUSBD_DGetConfigParamsSF(pD, configParams); if (ret == CDN_EOK) { configParams->bU1devExitLat = CUSBSS_U1_DEV_EXIT_LAT; configParams->bU2DevExitLat = CUSBSS_U2_DEV_EXIT_LAT; } return ret; }
33.31698
132
0.625695
a7f24841b74f7c8515b40a4f0bff962d37aa1bb2
2,321
h
C
Engine/Logic/gkParticleNode.h
gamekit-developers/gamekit
74c896af5826ebe8fb72f2911015738f38ab7bb2
[ "Zlib", "MIT" ]
241
2015-01-04T00:36:58.000Z
2022-01-06T19:19:23.000Z
Engine/Logic/gkParticleNode.h
slagusev/gamekit
a6e97fcf2a9c3b9b9799bc12c3643818503ffc7d
[ "MIT" ]
10
2015-07-10T18:27:17.000Z
2019-06-26T20:59:59.000Z
Engine/Logic/gkParticleNode.h
slagusev/gamekit
a6e97fcf2a9c3b9b9799bc12c3643818503ffc7d
[ "MIT" ]
82
2015-01-25T18:02:35.000Z
2022-03-05T12:28:17.000Z
/* ------------------------------------------------------------------------------- This file is part of OgreKit. http://gamekit.googlecode.com/ Copyright (c) 2006-2013 Nestor Silveira. Contributor(s): none yet. ------------------------------------------------------------------------------- This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. ------------------------------------------------------------------------------- */ #ifndef _gkParticleNode_h_ #define _gkParticleNode_h_ #include "gkLogicNode.h" #include "LinearMath/btQuickprof.h" class gkParticleObject; class gkParticleNode : public gkLogicNode { public: enum { CREATE, POSITION, ORIENTATION, PARTICLE_SYSTEM_NAME }; DECLARE_SOCKET_TYPE(CREATE, bool); DECLARE_SOCKET_TYPE(POSITION, gkVector3); DECLARE_SOCKET_TYPE(ORIENTATION, gkQuaternion); DECLARE_SOCKET_TYPE(PARTICLE_SYSTEM_NAME, gkString); gkParticleNode(gkLogicTree* parent, size_t id); ~gkParticleNode(); void initialize(); void update(Ogre::Real tick); bool evaluate(Ogre::Real tick); private: class ParticleObject { public: ParticleObject(gkParticleObject* parObj); ~ParticleObject(); GK_INLINE bool isExpired() { return m_timer.getTimeMilliseconds() > m_timeToLive; } gkParticleObject* m_parObj; gkScalar m_timeToLive; btClock m_timer; }; typedef utList<ParticleObject*> ParticleObjects; typedef utListIterator<ParticleObjects> ParticleObjectIterator; ParticleObjects m_particles; gkScene* m_scene; }; #endif//_gkParticleNode_h_
27.305882
85
0.686773
57d92d16676ef59bfc6fd423ec66d0aded1b0668
632
c
C
character_write_buffer.c
ibrisha/printf
94485e272d2ac1917725d4856c088c6a19bff9a9
[ "MIT" ]
null
null
null
character_write_buffer.c
ibrisha/printf
94485e272d2ac1917725d4856c088c6a19bff9a9
[ "MIT" ]
null
null
null
character_write_buffer.c
ibrisha/printf
94485e272d2ac1917725d4856c088c6a19bff9a9
[ "MIT" ]
null
null
null
#include "main.h" /** * print_char - writes char to buffer or standard output * @inv: the arguments inventory with most commonly used argument * Return: number of chars wrote to buffer */ void print_char(inventory_t *inv) { inv->c0 = va_arg(*(inv->args), int); write_buffer(inv); } /** * print_percent - writes a percent symbol to buffer or stdout * @inv: the arguments inventory with most commonly used arguments * Return: number of chars wrote to buffer */ void print_percent(inventory_t *inv) { inv->c0 = '%'; if (inv->space) { inv->space = 0; inv->buffer[--(inv->buf_index)] = '\0'; } write_buffer(inv); }
21.066667
66
0.68038
414fa664fc7a0e77b58f3fb7392b72893f21309e
56
h
C
include/config.h
sometao/FFmpegCMake
800547c758f20b3d16f085e367c46a597ac30f7f
[ "MIT" ]
null
null
null
include/config.h
sometao/FFmpegCMake
800547c758f20b3d16f085e367c46a597ac30f7f
[ "MIT" ]
null
null
null
include/config.h
sometao/FFmpegCMake
800547c758f20b3d16f085e367c46a597ac30f7f
[ "MIT" ]
null
null
null
#define CONFIG_AVFILTER 1 #define CONFIG_AVDEVICE 1
8
25
0.785714
84e39b47c103cf0dd0df95f5ec989b14b89ce4f7
792
h
C
MasterSim/src/MSIM_AlgorithmGaussJacobi.h
ghorwin/MasterSim
281b71e228435ca8fa02319bf2ce86b66b8b2b45
[ "BSD-3-Clause" ]
5
2021-11-17T07:12:54.000Z
2022-03-16T15:06:39.000Z
MasterSim/src/MSIM_AlgorithmGaussJacobi.h
ghorwin/MasterSim
281b71e228435ca8fa02319bf2ce86b66b8b2b45
[ "BSD-3-Clause" ]
25
2021-09-09T07:39:13.000Z
2022-01-23T13:00:19.000Z
MasterSim/src/MSIM_AlgorithmGaussJacobi.h
ghorwin/MasterSim
281b71e228435ca8fa02319bf2ce86b66b8b2b45
[ "BSD-3-Clause" ]
null
null
null
#ifndef MSIM_ALGORITHMGAUSSJACOBI_H #define MSIM_ALGORITHMGAUSSJACOBI_H #include "MSIM_AbstractAlgorithm.h" namespace MASTER_SIM { /*! Implementation class for Gauss-Jacobi algorithm. This algorithm does not do any state-setting or state-getting, and is compatible with FMI for CoSim v1. */ class AlgorithmGaussJacobi : public AbstractAlgorithm { public: /*! Default constructor. */ AlgorithmGaussJacobi(MasterSim * master) : AbstractAlgorithm(master) {} /*! Initialization function, called once all slaves have been set up. */ void init(); /*! Master-algorithm will evaluate all FMUs and advance state in time. Will throw an exception if any of the FMUs fails in unrecoverable manner. */ Result doStep(); }; } // namespace MASTER_SIM #endif // MSIM_ALGORITHMGAUSSJACOBI_H
26.4
75
0.770202
cb375c0d7445746f82b629b8fb8feb4421635ff3
530
h
C
FFCalendar/FFCalendars/FFDayCalendarView/FFDayScrollView/FFDayCollectionView/FFDayCollectionView.h
JHChan314/FFCalendar
ac3a475e15675518767eaaad41ef5e44e944e708
[ "MIT" ]
266
2015-01-02T20:15:36.000Z
2021-07-20T04:50:43.000Z
FFCalendar/FFCalendars/FFDayCalendarView/FFDayScrollView/FFDayCollectionView/FFDayCollectionView.h
mohsinalimat/FFCalendar
ac3a475e15675518767eaaad41ef5e44e944e708
[ "MIT" ]
11
2015-03-09T10:54:34.000Z
2019-02-07T09:18:34.000Z
FFCalendar/FFCalendars/FFDayCalendarView/FFDayScrollView/FFDayCollectionView/FFDayCollectionView.h
mohsinalimat/FFCalendar
ac3a475e15675518767eaaad41ef5e44e944e708
[ "MIT" ]
89
2015-01-12T17:03:34.000Z
2022-02-03T19:01:53.000Z
// // FFDayCollectionView.h // FFCalendar // // Created by Fernanda G. Geraissate on 2/23/14. // Copyright (c) 2014 Fernanda G. Geraissate. All rights reserved. // // http://fernandasportfolio.tumblr.com // #import <UIKit/UIKit.h> #import "FFDayCell.h" @protocol FFDayCollectionViewProtocol <NSObject> - (void)updateHeader; @end @interface FFDayCollectionView : UICollectionView @property (nonatomic, strong) id<FFDayCollectionViewProtocol> protocol; @property (nonatomic, strong) NSMutableDictionary *dictEvents; @end
21.2
71
0.754717
fe17c42631ed7e4572890cbffe4f5b0fb8b5e2e9
879
h
C
WVRPlayerUI/WVRPlayerUI/Classes/View/WVRPlayerUIFrameMacro.h
portal-io/portal-ios-midware-midware
81b151fddc7315a7373418e7f3371220d84dba8e
[ "MIT" ]
null
null
null
WVRPlayerUI/WVRPlayerUI/Classes/View/WVRPlayerUIFrameMacro.h
portal-io/portal-ios-midware-midware
81b151fddc7315a7373418e7f3371220d84dba8e
[ "MIT" ]
null
null
null
WVRPlayerUI/WVRPlayerUI/Classes/View/WVRPlayerUIFrameMacro.h
portal-io/portal-ios-midware-midware
81b151fddc7315a7373418e7f3371220d84dba8e
[ "MIT" ]
null
null
null
// // WVRPlayerUIFrameMacro.h // WhaleyVR // // Created by Bruce on 2017/8/24. // Copyright © 2017年 Snailvr. All rights reserved. // #ifndef WVRPlayerUIFrameMacro_h #define WVRPlayerUIFrameMacro_h #pragma mark - danmu //#define MAX_HEIGHT_HEADER_LABLE (fitToWidth(40)) #define HEIGHT_DANMU_LIST_VIEW (fitToWidth(163)) #define WIDTH_DANMU_VIEW (fitToWidth(270)) #define MARGIN_TOP (fitToWidth(5)) #define MARGIN_BETWEEN_DANMU_TEXTFILED (fitToWidth(4)) #define Y_DANMU (SCREEN_HEIGHT - HEIGHT_TEXTFILED_VIEW - HEIGHT_DANMU_LIST_VIEW - MARGIN_BETWEEN_DANMU_TEXTFILED) #pragma mark - textfield #define MARGIN_BOTTOM_TEXTFILED (fitToWidth(8)) #define MARGIN_TOP_TEXTFILED (fitToWidth(4)) #define HEIGHT_INPUT_VIEW (fitToWidth(40)) #define HEIGHT_TEXTFILED_VIEW (HEIGHT_INPUT_VIEW + MARGIN_BOTTOM_TEXTFILED + MARGIN_TOP_TEXTFILED) #endif /* WVRPlayerUIFrameMacro_h */
24.416667
113
0.796359
2ae9c9802ff7ded70436c3e00ce49498dfa38d9b
1,143
h
C
Day1/build/iOS/Preview/include/Uno.Compiler.ExportTargetInterop.Foreign.ObjC.Object.h
sauvikatinnofied/ExploringFuse
cc272d55c7221d88ba773494f571b6528e5279f8
[ "Apache-2.0" ]
null
null
null
Day1/build/iOS/Preview/include/Uno.Compiler.ExportTargetInterop.Foreign.ObjC.Object.h
sauvikatinnofied/ExploringFuse
cc272d55c7221d88ba773494f571b6528e5279f8
[ "Apache-2.0" ]
null
null
null
Day1/build/iOS/Preview/include/Uno.Compiler.ExportTargetInterop.Foreign.ObjC.Object.h
sauvikatinnofied/ExploringFuse
cc272d55c7221d88ba773494f571b6528e5279f8
[ "Apache-2.0" ]
null
null
null
// This file was generated based on '/usr/local/share/uno/Packages/UnoCore/0.24.3/Source/Uno/Compiler/ExportTargetInterop/Foreign/ObjC/$.uno'. // WARNING: Changes might be lost if you edit this file directly. #pragma once #include <ObjC.Object.h> #include <objc/objc.h> #include <Uno.Object.h> namespace g{namespace Uno{namespace Compiler{namespace ExportTargetInterop{namespace Foreign{namespace ObjC{struct Object;}}}}}} namespace g{ namespace Uno{ namespace Compiler{ namespace ExportTargetInterop{ namespace Foreign{ namespace ObjC{ // public sealed extern class Object :34 // { struct Object_type : uType { ::g::ObjC::Object interface0; }; Object_type* Object_typeof(); void Object__ctor__fn(Object* __this, ::id* handle); void Object__get_Handle_fn(Object* __this, ::id* __retval); void Object__set_Handle_fn(Object* __this, ::id* value); void Object__New1_fn(::id* handle, Object** __retval); struct Object : uObject { ::id _handle; void ctor_(::id handle); ::id Handle(); void Handle(::id value); static Object* New1(::id handle); }; // } }}}}}} // ::g::Uno::Compiler::ExportTargetInterop::Foreign::ObjC
27.214286
142
0.728784
f1ba62ce2e8f3ac92e049b0e2bc3753df2ea4941
295
h
C
Brose_63x19/Panel/Panel-Platformio/src/panelCommands.h
cazacov/FlipDot
d9185426fa04c622fdbf2522b9b904cfde302d9c
[ "MIT" ]
2
2018-07-11T08:16:06.000Z
2022-01-31T09:51:18.000Z
Brose_63x19/Panel/Panel-Platformio/src/panelCommands.h
cazacov/FlipDot
d9185426fa04c622fdbf2522b9b904cfde302d9c
[ "MIT" ]
null
null
null
Brose_63x19/Panel/Panel-Platformio/src/panelCommands.h
cazacov/FlipDot
d9185426fa04c622fdbf2522b9b904cfde302d9c
[ "MIT" ]
1
2021-05-20T06:59:21.000Z
2021-05-20T06:59:21.000Z
#define CMD_START 1 #define CMD_ALL_SET 2 #define CMD_ALL_RESET 3 #define CMD_POWER_ON 4 #define CMD_POWER_OFF 5 #define CMD_DOT_SET 6 #define CMD_DOT_RESET 7 #define CMD_DURATION_SET 8 #define CMD_SLEEP 9 #define CMD_TEST 10 #define CMD_CALIBRATE 11 #define CMD_SHOWID 12 #define CMD_DELAY 13
19.666667
26
0.820339
0bf16dce9c789a6a0abc55f7173391d1ff5dd905
445
h
C
code_process/lib/hlibrary.h
NewtonVan/OS2020
223bc0d190ddad352777587792f4bf12d4d0081d
[ "MIT" ]
1
2021-12-16T07:49:37.000Z
2021-12-16T07:49:37.000Z
code_process/lib/hlibrary.h
NewtonVan/OS2020
223bc0d190ddad352777587792f4bf12d4d0081d
[ "MIT" ]
null
null
null
code_process/lib/hlibrary.h
NewtonVan/OS2020
223bc0d190ddad352777587792f4bf12d4d0081d
[ "MIT" ]
null
null
null
#ifndef HLIBRARY_H #define HLIBRARY_H #include <list> #define DEAD -1 #define READY 0 #define RUNNING 1 #define BLOCK 2 #define INIT 0 #define USER 1 #define SYSTEM 2 #define FREE 0 #define ALLOCATED 1 #define WAIT_NONE -1 #define CR_LTH 3 #define DE_LTH 2 #define REQ_LTH 3 #define REL_LTH 3 #define TO_LTH 1 #define LP_LTH 1 #define LR_LTH 1 #define ALLOC_ERROR -1 #define REL_ERROR -2 #define WAKE_NONE -1 #define WAKEN 1 class PCB; #endif
15.344828
22
0.759551
a47e9b8490ae33ee570ec02c2e8a42868f0ab681
955
c
C
Basics/Recursion/11-Tree-Recursion.c
ArielMAJ/DataStructures
4f41a3eb152e2f2939e819793f528798c8cfbf9b
[ "MIT" ]
null
null
null
Basics/Recursion/11-Tree-Recursion.c
ArielMAJ/DataStructures
4f41a3eb152e2f2939e819793f528798c8cfbf9b
[ "MIT" ]
null
null
null
Basics/Recursion/11-Tree-Recursion.c
ArielMAJ/DataStructures
4f41a3eb152e2f2939e819793f528798c8cfbf9b
[ "MIT" ]
null
null
null
// Tree Recursion #include <stdio.h> void fun(int n) { if (n > 0) // It stops when (n <= 0); { printf("%d ", n); // "Tail recursion": It prints first then goes on to the recursion. fun(n - 1); // It recursively calls itself until it hits the stopping condition; fun(n - 1); // It recursively calls itself a second time; } } int main() { fun(3); // It prints 3 first, then call f(2) twice. /* * f(2) prints 2 then calls f(1) twice; * f(1) prints 1 and calls f(0) twice; * f(0) is the stop condition; * Basically it will call the functions in this order: * Starts -> prints and goes to the first stop condition -> goes back up * the stack and reaches the subsequent stopping conditions; * f(3) -> f(2) -> f(1) -> f(0) -> f(0) -> f(1) -> f(0) -> f(0) -> f(2) -> f(1) -> f(0) -> f(0) -> f(1) -> f(0) -> f(0) -> ends; * It prints: 3 2 1 1 2 1 1; */ return 0; }
30.806452
132
0.544503
f2f9ca40e245412d51fe9f0b3ae41db688dcf4a0
2,483
h
C
witj/cpp/src/Forwards.h
kant/CMMPPT
c64b339712db28a619880c4c04839aef7d3b6e2b
[ "Apache-2.0" ]
1
2019-10-25T05:25:23.000Z
2019-10-25T05:25:23.000Z
witj/cpp/src/Forwards.h
kant/CMMPPT
c64b339712db28a619880c4c04839aef7d3b6e2b
[ "Apache-2.0" ]
2
2019-09-04T17:34:59.000Z
2020-09-16T08:10:57.000Z
witj/cpp/src/Forwards.h
kant/CMMPPT
c64b339712db28a619880c4c04839aef7d3b6e2b
[ "Apache-2.0" ]
18
2019-07-22T19:01:25.000Z
2022-03-03T15:36:11.000Z
//------------------------------------------------------------------------------ // WIT-J C++ Header File Forwards.h. // // Contains the forward declarations used by WIT-J/C++. // Contains the typedef declarations used by WIT-J/C++. //------------------------------------------------------------------------------ #ifndef Forwards_h #define Forwards_h //------------------------------------------------------------------------------ // Forward class declarations. //------------------------------------------------------------------------------ namespace WitJ { class Att; class AttBldr; class BomEntry; class BopEntry; class CTVecSupply; class CaseToken; class Component; class ComponentJOR; class Coordinator; class DblALJOR; class DblArrayJOR; class Demand; class DemandALJOR; class IntALJOR; class JavaAccObj; class MessageMgr; class Operation; class Part; class PeggingTripleALJOR; class PggHandler; class PreJavaException; class Problem; class StringALJOR; class StringJOR; class StringVec; class Substitute; } //------------------------------------------------------------------------------ // Forward template declarations. //------------------------------------------------------------------------------ namespace WitJ { template <typename E> class ArrayJOR; template <typename C> class CompALJOR; } //------------------------------------------------------------------------------ // Typedefs. //------------------------------------------------------------------------------ namespace WitJ { typedef int Boolean; } //------------------------------------------------------------------------------ // Typedef DemPggFunc // // A pointer to a Demand pegging retrieval function. //------------------------------------------------------------------------------ namespace WitJ { typedef void (PggHandler::* DemPggFunc) ( Demand *, int, PeggingTripleALJOR &); } //------------------------------------------------------------------------------ // Typedef OpnPggFunc // // A pointer to an Operation pegging retrieval function. //------------------------------------------------------------------------------ namespace WitJ { typedef void (PggHandler::* OpnPggFunc) ( Operation * , int, PeggingTripleALJOR &); } //------------------------------------------------------------------------------ // Forward class declarations for WIT. //------------------------------------------------------------------------------ class WitRun; class WitErrorExc; #endif
24.83
80
0.409182
93d6d21760316950603e39bb733d4d2f469cd3bf
4,264
h
C
clock/Settings.h
Elements6007v2/lvgl-wasm2
3649270fade1b380f50b390331507f7320eaea7f
[ "MIT" ]
null
null
null
clock/Settings.h
Elements6007v2/lvgl-wasm2
3649270fade1b380f50b390331507f7320eaea7f
[ "MIT" ]
null
null
null
clock/Settings.h
Elements6007v2/lvgl-wasm2
3649270fade1b380f50b390331507f7320eaea7f
[ "MIT" ]
null
null
null
#pragma once #include <cstdint> #include <bitset> #include "components/datetime/DateTimeController.h" #include "components/brightness/BrightnessController.h" #include "components/fs/FS.h" #include "drivers/Cst816s.h" namespace Pinetime { namespace Controllers { class Settings { public: enum class ClockType : uint8_t { H24, H12 }; enum class Vibration : uint8_t { ON, OFF }; enum class WakeUpMode : uint8_t { SingleTap = 0, DoubleTap = 1, RaiseWrist = 2, }; Settings(Pinetime::Controllers::FS& fs); void Init(); void SaveSettings(); void SetClockFace(uint8_t face) { if (face != settings.clockFace) { settingsChanged = true; } settings.clockFace = face; }; uint8_t GetClockFace() const { return settings.clockFace; }; void SetAppMenu(uint8_t menu) { appMenu = menu; }; uint8_t GetAppMenu() { return appMenu; }; void SetSettingsMenu(uint8_t menu) { settingsMenu = menu; }; uint8_t GetSettingsMenu() const { return settingsMenu; }; void SetClockType(ClockType clocktype) { if (clocktype != settings.clockType) { settingsChanged = true; } settings.clockType = clocktype; }; ClockType GetClockType() const { return settings.clockType; }; void SetVibrationStatus(Vibration status) { if (status != settings.vibrationStatus) { settingsChanged = true; } settings.vibrationStatus = status; }; Vibration GetVibrationStatus() const { return settings.vibrationStatus; }; void SetScreenTimeOut(uint32_t timeout) { if (timeout != settings.screenTimeOut) { settingsChanged = true; } settings.screenTimeOut = timeout; }; uint32_t GetScreenTimeOut() const { return settings.screenTimeOut; }; void setWakeUpMode(WakeUpMode wakeUp, bool enabled) { if (!isWakeUpModeOn(wakeUp)) { settingsChanged = true; } settings.wakeUpMode.set(static_cast<size_t>(wakeUp), enabled); // Handle special behavior if (enabled) { switch (wakeUp) { case WakeUpMode::SingleTap: settings.wakeUpMode.set(static_cast<size_t>(WakeUpMode::DoubleTap), false); break; case WakeUpMode::DoubleTap: settings.wakeUpMode.set(static_cast<size_t>(WakeUpMode::SingleTap), false); break; case WakeUpMode::RaiseWrist: break; } } }; std::bitset<3> getWakeUpModes() const { return settings.wakeUpMode; } bool isWakeUpModeOn(const WakeUpMode mode) const { return getWakeUpModes()[static_cast<size_t>(mode)]; } void SetBrightness(Controllers::BrightnessController::Levels level) { if (level != settings.brightLevel) { settingsChanged = true; } settings.brightLevel = level; }; Controllers::BrightnessController::Levels GetBrightness() const { return settings.brightLevel; }; void SetStepsGoal( uint32_t goal ) { if ( goal != settings.stepsGoal ) { settingsChanged = true; } settings.stepsGoal = goal; }; uint32_t GetStepsGoal() const { return settings.stepsGoal; }; private: Pinetime::Controllers::FS& fs; static constexpr uint32_t settingsVersion = 0x0001; struct SettingsData { uint32_t version = settingsVersion; uint32_t stepsGoal = 10000; uint32_t screenTimeOut = 15000; ClockType clockType = ClockType::H24; Vibration vibrationStatus = Vibration::ON; uint8_t clockFace = 0; std::bitset<3> wakeUpMode {0}; Controllers::BrightnessController::Levels brightLevel = Controllers::BrightnessController::Levels::Medium; }; SettingsData settings; bool settingsChanged = false; uint8_t appMenu = 0; uint8_t settingsMenu = 0; void LoadSettingsFromFile(); void SaveSettingsToFile(); }; } }
26.987342
114
0.599437
13aecbf376bc6e5afa17e5c2ceb5ee33cad8402b
3,631
h
C
H.263/Indices.h
goodspeed24e/2011Corel
4efb585a589ea5587a877f4184493b758fa6f9b2
[ "MIT" ]
1
2019-07-24T07:59:07.000Z
2019-07-24T07:59:07.000Z
H.263/Indices.h
goodspeed24e/2011Corel
4efb585a589ea5587a877f4184493b758fa6f9b2
[ "MIT" ]
null
null
null
H.263/Indices.h
goodspeed24e/2011Corel
4efb585a589ea5587a877f4184493b758fa6f9b2
[ "MIT" ]
6
2015-03-17T12:11:38.000Z
2022-01-29T01:15:52.000Z
#ifdef INDICES int codtab[2]= {0,1}; int mcbpctab[21] = {0,16,32,48,1,17,33,49,2,18,34,50,3,19,35,51,4,20,36,52,255}; int mcbpc_intratab[9] = {3,19,35,51,4,20,36,52,255}; int modb_tab[3] = {0, 1, 2}; int ycbpb_tab[2] = {0, 1}; int uvcbpb_tab[2] = {0, 1}; int cbpytab[16] = {15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0}; int cbpy_intratab[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; int dquanttab[4] = {1,0,3,4}; int mvdtab[64] = {32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31}; int intradctab[254] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,255,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254}; int tcoeftab[103] = {1,2,3,4,5,6,7,8,9,10,11,12,17,18,19,20,21,22,33,34,35,36,49,50,51,65,66,67,81,82,83,97,98,99,113,114,129,130,145,146,161,162,177,193,209,225,241,257,273,289,305,321,337,353,369,385,401,417,4097,4098,4099,4113,4114,4129,4145,4161,4177,4193,4209,4225,4241,4257,4273,4289,4305,4321,4337,4353,4369,4385,4401,4417,4433,4449,4465,4481,4497,4513,4529,4545,4561,4577,4593,4609,4625,4641,4657,4673,4689,4705,4721,4737,7167}; int signtab[2] = {0,1}; int lasttab[2] = {0,1}; int last_intratab[2] = {0,1}; int runtab[64] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; int leveltab[254] = {129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127}; #else extern int codtab[]; extern int mcbpctab[]; extern int mcbpc_intratab[]; extern int modb_tab[]; extern int ycbpb_tab[]; extern int uvcbpb_tab[]; extern int cbpytab[]; extern int cbpy_intratab[]; extern int dquanttab[]; extern int mvdtab[]; extern int intradctab[]; extern int tcoeftab[]; extern int signtab[]; extern int lasttab[]; extern int last_intratab[]; extern int runtab[]; extern int leveltab[]; #endif
63.701754
932
0.695125
13ff8d1013a1cae53b1bfafa8d6d7f3ad59369c7
695
h
C
src/bfkl.h
kdusling/mpc
ccdc1f5ddcdba6cfc6ea5413ef5cc180ffe682bc
[ "MIT" ]
null
null
null
src/bfkl.h
kdusling/mpc
ccdc1f5ddcdba6cfc6ea5413ef5cc180ffe682bc
[ "MIT" ]
null
null
null
src/bfkl.h
kdusling/mpc
ccdc1f5ddcdba6cfc6ea5413ef5cc180ffe682bc
[ "MIT" ]
null
null
null
#ifndef bfkl_H_INCLUDED #define bfkl_H_INCLUDED #include <stdio.h> #include <math.h> #include <gsl/gsl_spline.h> #include <gsl/gsl_integration.h> #include <gsl/gsl_math.h> #include <gsl/gsl_errno.h> #include "cubature.h" #include "string.h" #include "alphas.h" #include "wf.h" //number of tabulated points in z and x for BFKL Kernel #define Nz 94 #define Nx 1201 #define Nhar 24 #define ZMIN (0.15) #define ZMAX (4.8) #define XMAX (100.00) void ReadInBFKL(); double BFKLfunc(double z, double x, int n); double d2N_BFKL(double pT, double qT, double phi, double yp, double yq, double rts); struct bfkl_params { double pT; double qT; double phi; double x1, x2; double dy; } ; #endif
19.305556
84
0.717986
fa9c06542bb160680a36c41bed6d07da6ac0967a
860
h
C
AliPayForDebug/AliPayForDebug/AlipayWallet_Headers/mobilerelationMobileContactRecord.h
ceekay1991/AliPayForDebug
5795e5db31e5b649d4758469b752585e63e84d94
[ "MIT" ]
5
2020-03-29T12:08:37.000Z
2021-05-26T05:20:11.000Z
AliPayForDebug/AliPayForDebug/AlipayWallet_Headers/mobilerelationMobileContactRecord.h
ceekay1991/AliPayForDebug
5795e5db31e5b649d4758469b752585e63e84d94
[ "MIT" ]
null
null
null
AliPayForDebug/AliPayForDebug/AlipayWallet_Headers/mobilerelationMobileContactRecord.h
ceekay1991/AliPayForDebug
5795e5db31e5b649d4758469b752585e63e84d94
[ "MIT" ]
5
2020-04-17T03:24:04.000Z
2022-03-30T05:42:17.000Z
// // Generated by class-dump 3.5 (64 bit) (Debug version compiled Sep 17 2017 16:24:48). // // class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2015 by Steve Nygard. // #import "APDPBGeneratedMessage.h" @class NSString; @interface mobilerelationMobileContactRecord : APDPBGeneratedMessage { } + (CDStruct_af61540b *)_fieldInfos; // Remaining properties @property(readonly) _Bool hasMemo; // @dynamic hasMemo; @property(readonly) _Bool hasMobile; // @dynamic hasMobile; @property(readonly) _Bool hasName; // @dynamic hasName; @property(readonly) _Bool hasRemove; // @dynamic hasRemove; @property(retain, nonatomic) NSString *memo; // @dynamic memo; @property(retain, nonatomic) NSString *mobile; // @dynamic mobile; @property(retain, nonatomic) NSString *name; // @dynamic name; @property(nonatomic) _Bool remove; // @dynamic remove; @end
29.655172
90
0.736047
780981cb509bd60498f5a743f6d3f4c2507e9cdb
3,476
h
C
include/relabsd/device/axis.h
nsensfel/relabsd
3e76054f937f471e352233f00a5c8ccfee8a78b9
[ "BSD-3-Clause" ]
13
2015-09-02T18:20:31.000Z
2021-11-17T17:46:55.000Z
include/relabsd/device/axis.h
nsensfel/relabsd
3e76054f937f471e352233f00a5c8ccfee8a78b9
[ "BSD-3-Clause" ]
5
2017-09-18T13:19:13.000Z
2021-05-03T18:38:06.000Z
include/relabsd/device/axis.h
nsensfel/relabsd
3e76054f937f471e352233f00a5c8ccfee8a78b9
[ "BSD-3-Clause" ]
null
null
null
#pragma once /**** LIBEVDEV ****************************************************************/ #include <libevdev/libevdev.h> /**** RELABSD *****************************************************************/ #include <relabsd/device/axis_types.h> /******************************************************************************/ /**** EXPORTED FUNCTIONS ******************************************************/ /******************************************************************************/ /* * Gives the relabsd_axis and EV_ABS event code equivalent to an EV_REL event * code. * If the returned relabsd_axis is RELABSD_UNKNOWN, no value is inserted into * 'abs_code'. */ enum relabsd_axis_name relabsd_axis_name_and_evdev_abs_from_evdev_rel ( const unsigned int rel_code, unsigned int abs_code [const restrict static 1] ); /* * Returns the EV_REL/EV_ABS equivalent of 'e'. * There is no equivalent for RELABSD_UNKNOWN, so 'e' is forbidden from * taking this value. */ unsigned int relabsd_axis_name_to_evdev_rel (const enum relabsd_axis_name e); unsigned int relabsd_axis_name_to_evdev_abs (const enum relabsd_axis_name e); /* * Returns the relabsd_axis equivalent of a EV_REL/EV_ABS code. */ enum relabsd_axis_name relabsd_axis_name_from_evdev_rel ( const unsigned int rel ); enum relabsd_axis_name relabsd_axis_name_from_evdev_abs ( const unsigned int abs ); /* * Returns the relabsd_axis whose name is 'name', according to the configuration * file syntax. * RELABSD_UNKNOWN is returned for any name that didn't match any other * possibility. */ enum relabsd_axis_name relabsd_axis_parse_name ( const char name [const restrict static 1] ); /* Same as above, but the string only has to start with the correct name. */ enum relabsd_axis_name relabsd_axis_parse_name_from_prefix ( const char name [const restrict static 1] ); /* * Gives an string representation of an relabsd_axis. * "??" is returned for RELABSD_UNKNOWN. * Returned values should be coherent with the configuration file syntax. */ const char * relabsd_axis_name_to_string (const enum relabsd_axis_name e); /* * Returns -1 if the option was discarded (an error has been reported), * 0 if the option was successfully parsed. */ int relabsd_axis_enable_option_from_name ( const char option_name [const restrict static 1], const char axis_name [const restrict static 1], struct relabsd_axis axis [const restrict static 1] ); void relabsd_axis_enable (struct relabsd_axis axis [const restrict static 1]); int relabsd_axis_is_enabled ( const struct relabsd_axis axis [const restrict static 1] ); void relabsd_axis_to_absinfo ( const struct relabsd_axis axis [const restrict static 1], struct input_absinfo absinfo [const restrict static 1] ); int relabsd_axis_filter_new_value ( struct relabsd_axis axis [const restrict static 1], int value [const restrict static 1] ); void relabsd_axis_initialize ( struct relabsd_axis axis [const restrict static 1] ); enum relabsd_axis_name relabsd_axis_get_convert_to ( const struct relabsd_axis axis [const restrict static 1] ); int relabsd_axis_attributes_are_dirty ( const struct relabsd_axis axis [const restrict static 1] ); void relabsd_axis_set_attributes_are_dirty ( const int val, struct relabsd_axis axis [const restrict static 1] ); int relabsd_axis_has_flag ( const struct relabsd_axis axis [const restrict static 1], const enum relabsd_axis_flag flag );
28.032258
80
0.691887
9e23f8b1400ea3dc0d0b5629ef208494c64c3dcf
1,101
c
C
hal/ia32/hal.c
mfkiwl/phoenix-rtos-kernel
b2e820d0f594427b8cad6f1df325bff336c9dde1
[ "BSD-3-Clause" ]
null
null
null
hal/ia32/hal.c
mfkiwl/phoenix-rtos-kernel
b2e820d0f594427b8cad6f1df325bff336c9dde1
[ "BSD-3-Clause" ]
null
null
null
hal/ia32/hal.c
mfkiwl/phoenix-rtos-kernel
b2e820d0f594427b8cad6f1df325bff336c9dde1
[ "BSD-3-Clause" ]
null
null
null
/* * Phoenix-RTOS * * Operating system kernel * * Hardware Abstraction Layer (IA32 PC) * * Copyright 2012, 2016 Phoenix Systems * Copyright 2006 Pawel Pisarczyk * Author: Pawel Pisarczyk * * This file is part of Phoenix-RTOS. * * %LICENSE% */ #include "../spinlock.h" #include "../console.h" #include "../exceptions.h" #include "../interrupts.h" #include "../cpu.h" #include "../pmap.h" #include "../timer.h" #include "pci.h" #include "halsyspage.h" struct { int started; } hal_common; syspage_t *syspage; extern void _hal_cpuInit(void); void *hal_syspageRelocate(void *data) { return ((u8 *)data + VADDR_KERNEL); } ptr_t hal_syspageAddr(void) { return (ptr_t)syspage; } int hal_started(void) { return hal_common.started; } void _hal_start(void) { hal_common.started = 1; } void hal_wdgReload(void) { } __attribute__ ((section (".init"))) void _hal_init(void) { _hal_spinlockInit(); _hal_consoleInit(); _hal_exceptionsInit(); _hal_interruptsInit(); _hal_timerInit(SYSTICK_INTERVAL); _hal_cpuInit(); _hal_pciInit(); hal_common.started = 0; return; }
12.952941
56
0.689373
b10e3fccda2566ff11ce2d8d03dfbfa32f1d8bf9
676
h
C
Pods/Headers/Private/iOS-GPX-Framework/GPXPerson.h
williamrussellajb/ios-geofence
bc866f25d7fa4331f4a4d90dea591c13be18a0ff
[ "Unlicense" ]
null
null
null
Pods/Headers/Private/iOS-GPX-Framework/GPXPerson.h
williamrussellajb/ios-geofence
bc866f25d7fa4331f4a4d90dea591c13be18a0ff
[ "Unlicense" ]
null
null
null
Pods/Headers/Private/iOS-GPX-Framework/GPXPerson.h
williamrussellajb/ios-geofence
bc866f25d7fa4331f4a4d90dea591c13be18a0ff
[ "Unlicense" ]
null
null
null
// // GPXPerson.h // GPX Framework // // Created by NextBusinessSystem on 12/04/06. // Copyright (c) 2012 NextBusinessSystem Co., Ltd. All rights reserved. // #import "GPXElement.h" @class GPXEmail; @class GPXLink; /** A person or organization. */ @interface GPXPerson : GPXElement /// --------------------------------- /// @name Accessing Properties /// --------------------------------- /** Name of person or organization. */ @property (strong, nonatomic) NSString *name; /** Email address. */ @property (strong, nonatomic) GPXEmail *email; /** Link to Web site or other external information about person. */ @property (strong, nonatomic) GPXLink *link; @end
19.882353
72
0.622781
7f50c0a59b688149f9968514ee25b721830a6596
404
h
C
OnlinePaymentsSDK/OPToolTip.h
wl-online-payments-direct/direct-sdk-client-objc
2d81b64e73f2320b9b47d802307958b6a1694f6c
[ "MIT" ]
null
null
null
OnlinePaymentsSDK/OPToolTip.h
wl-online-payments-direct/direct-sdk-client-objc
2d81b64e73f2320b9b47d802307958b6a1694f6c
[ "MIT" ]
null
null
null
OnlinePaymentsSDK/OPToolTip.h
wl-online-payments-direct/direct-sdk-client-objc
2d81b64e73f2320b9b47d802307958b6a1694f6c
[ "MIT" ]
null
null
null
// // Do not remove or alter the notices in this preamble. // This software code is created for Online Payments on 17/07/2020 // Copyright © 2020 Global Collect Services. All rights reserved. // #import <UIKit/UIKit.h> @interface OPTooltip : NSObject @property (strong, nonatomic) NSString *imagePath; @property (strong, nonatomic) UIImage *image; @property (strong, nonatomic) NSString *label; @end
25.25
66
0.747525
3d019da03536cfe874584c1f905f93b7c3d81cb3
1,757
c
C
cmd/wmii/root.c
bartman/wmii
703981eabd5addaf47350ebb59b43a464cf1529f
[ "MIT" ]
3
2016-05-09T07:15:29.000Z
2021-03-20T11:00:39.000Z
cmd/wmii/root.c
bartman/wmii
703981eabd5addaf47350ebb59b43a464cf1529f
[ "MIT" ]
null
null
null
cmd/wmii/root.c
bartman/wmii
703981eabd5addaf47350ebb59b43a464cf1529f
[ "MIT" ]
1
2017-01-27T15:55:33.000Z
2017-01-27T15:55:33.000Z
/* Copyright ©2008-2009 Kris Maglione <maglione.k at Gmail> * See LICENSE file for license details. */ #include "dat.h" #include "fns.h" static Handlers handlers; void root_init(void) { WinAttr wa; wa.event_mask = EnterWindowMask | FocusChangeMask | LeaveWindowMask | PointerMotionMask | SubstructureNotifyMask | SubstructureRedirectMask; wa.cursor = cursor[CurNormal]; setwinattr(&scr.root, &wa, CWEventMask | CWCursor); sethandler(&scr.root, &handlers); } static void enter_event(Window *w, XCrossingEvent *e) { disp.sel = true; frame_draw_all(); } static void leave_event(Window *w, XCrossingEvent *e) { if(!e->same_screen) { disp.sel = false; frame_draw_all(); } } static void focusin_event(Window *w, XFocusChangeEvent *e) { if(e->mode == NotifyGrab) disp.hasgrab = &c_root; } static void mapreq_event(Window *w, XMapRequestEvent *e) { XWindowAttributes wa; if(!XGetWindowAttributes(display, e->window, &wa)) return; if(wa.override_redirect) { /* Do I really want these? */ /* Probably not. XSelectInput(display, e->window, PropertyChangeMask | StructureNotifyMask); */ return; } if(!win2client(e->window)) client_create(e->window, &wa); } static void motion_event(Window *w, XMotionEvent *e) { Rectangle r, r2; r = rectsetorigin(Rect(0, 0, 1, 1), Pt(e->x_root, e->y_root)); r2 = constrain(r, 0); if(!eqrect(r, r2)) warppointer(r2.min); } static void kdown_event(Window *w, XKeyEvent *e) { e->state &= valid_mask; kpress(w->xid, e->state, (KeyCode)e->keycode); } static Handlers handlers = { .enter = enter_event, .focusin = focusin_event, .kdown = kdown_event, .leave = leave_event, .mapreq = mapreq_event, .motion = motion_event, };
19.522222
63
0.681275
9adbf80825d992a258b7a419d1569685274765e4
734
c
C
Uprosteni funkcii/funkciiRek.c
vasetrendafilov/Pia
cf0f06b9a2afca7b2fbf7849465f2aae4c19bae5
[ "MIT" ]
null
null
null
Uprosteni funkcii/funkciiRek.c
vasetrendafilov/Pia
cf0f06b9a2afca7b2fbf7849465f2aae4c19bae5
[ "MIT" ]
null
null
null
Uprosteni funkcii/funkciiRek.c
vasetrendafilov/Pia
cf0f06b9a2afca7b2fbf7849465f2aae4c19bae5
[ "MIT" ]
null
null
null
#include <stdio.h> /* Avtor: Nikola Stoimenov Rekurzivni funkcii za odredeni matemtichki izrazi *Napomena funkciite zavisat edna od druga */ //Broj na cifri vo eden broj (Rekurzivno) int brojCifri(int x){ if (x == 0) return 0; return 1 + brojCifri(x/10); } //Zbir na cifrite vo brojot (Rekurzivno) int zbirCifri(int x){ if (x == 0) return 0; return (x % 10) + zbirCifri(x/10); } //Stepenuvanje na broj (Rekurzivno) int stepen(int x, int y){ if (y == 0) return 1; return x * stepen(x, y-1); } //prevrtuvanje na cifri (rekurzivno) int prevrtiCifri(int x){ if (x == 0) return 0; return x%10 * stepen(10, brojCifri(x)-1) + prevrtiCifri(x/10); } int main(){ printf("%d\n", stepen(2, 5)); return 0; }
19.837838
66
0.643052
82944129a339fef33495c7ceb95d14d44672a3e4
321
h
C
iRun/Classes/ViewControllers/CategoryViewController/IRCategoryViewController.h
mohsinalimat/ExpenseManager
ec4e6f1657e188a5dbfed45537664a076439d9e1
[ "Apache-2.0" ]
1
2019-02-09T10:09:43.000Z
2019-02-09T10:09:43.000Z
iRun/Classes/ViewControllers/CategoryViewController/IRCategoryViewController.h
mohsinalimat/ExpenseManager
ec4e6f1657e188a5dbfed45537664a076439d9e1
[ "Apache-2.0" ]
null
null
null
iRun/Classes/ViewControllers/CategoryViewController/IRCategoryViewController.h
mohsinalimat/ExpenseManager
ec4e6f1657e188a5dbfed45537664a076439d9e1
[ "Apache-2.0" ]
null
null
null
// // IRAddCategoryViewController.h // ExpenseManager // // Created by Shibin S on 05/09/14. // Copyright (c) 2014 Shibin. All rights reserved. // #import <UIKit/UIKit.h> #import <iAd/iAd.h> @interface IRCategoryViewController : UIViewController<UITableViewDataSource,UITableViewDelegate,UIAlertViewDelegate> @end
21.4
117
0.760125
829d92d4d2b4d661bbde975f610085294ae0bbfc
1,280
h
C
FoundtionKit/NSString+CNKit.h
congni/CNKit
66a77db9f8c195249aea687026a312cc35722945
[ "MIT" ]
1
2016-08-27T01:47:45.000Z
2016-08-27T01:47:45.000Z
CNBasicDemo/Pods/CNKit/FoundtionKit/NSString+CNKit.h
congni/CNBasicTools-OC
77dc375fb0cb6d0cbf2c29f81f11720fd4749ba7
[ "MIT" ]
null
null
null
CNBasicDemo/Pods/CNKit/FoundtionKit/NSString+CNKit.h
congni/CNBasicTools-OC
77dc375fb0cb6d0cbf2c29f81f11720fd4749ba7
[ "MIT" ]
null
null
null
// // NSString+CNKit.h // SalesAssistantApp // // Created by haoju-congni on 15/1/13. // Copyright (c) 2015年 好居. All rights reserved. // #import <Foundation/Foundation.h> @interface NSString (CNKit) /** * 是否空字符串 没有任何字符 * * @return BOOL */ - (BOOL)isBlank; /** * 是否是有效的字符串 包括空字符串 * * @return BOOL */ - (BOOL)isValid; /** * 按指定字符串分割为数组 * * @param separatedStr 指定的字符串 * * @return NSArray */ - (NSArray *)divisionForArrayByString:(NSString *)separatedStr; /** * 是否是有效的Email * * @return BOOL */ - (BOOL)isEffectiveEmail; /** * 判断是否是URL * * @return BOOL */ - (BOOL)isEffectiveUrl; /** * 是否只包含数字 * * @return BOOL */ - (BOOL)isOnlyNumbers; /** * 是否只包含字母 * * @return BOOL */ - (BOOL)isOnlyLetters; /** * 删除所有空格 * * @return NSString */ - (NSString *)removeAllSpace; /** * 按指定字符数量 插入指定字符 当后面的字符串不足count值时 直接添加 * * @param insertStr 需要插入的字符串 * @param cutCount 每隔多少字符插入 * * @return NSString */ - (NSString *)insertStr:(NSString *)insertStr cutCount:(int)count; /** * 获取字符串长度 * * @param font 字体大小 * * @return CGSize */ - (CGSize)getStringSize:(UIFont *)font; - (CGSize)getStringSize:(UIFont *)font contentSize:(CGSize)contentSize; /** * md5 加密 * * @return self */ - (NSString *)md5Encrypt; @end
12.8
71
0.616406
d6041eb4a4605a05f95d766e812ea1e74db38768
1,729
h
C
lite/backends/nnadapter/nnadapter/include/nnadapter/core/types.h
714627034/Paddle-Lite
015ba88a4d639db0b73603e37f83e47be041a4eb
[ "Apache-2.0" ]
1
2022-03-18T19:48:40.000Z
2022-03-18T19:48:40.000Z
lite/backends/nnadapter/nnadapter/include/nnadapter/core/types.h
714627034/Paddle-Lite
015ba88a4d639db0b73603e37f83e47be041a4eb
[ "Apache-2.0" ]
null
null
null
lite/backends/nnadapter/nnadapter/include/nnadapter/core/types.h
714627034/Paddle-Lite
015ba88a4d639db0b73603e37f83e47be041a4eb
[ "Apache-2.0" ]
null
null
null
// Copyright (c) 2019 PaddlePaddle Authors. 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. #pragma once #include <list> #include <vector> #include "nnadapter.h" // NOLINT namespace nnadapter { namespace core { enum { NNADAPTER_MAX_SIZE_OF_HINTS = 8 }; typedef struct Hint { void* handler; void (*deleter)(void** handler); } Hint; typedef struct Operand { NNAdapterOperandType type; void* buffer; uint32_t length; Hint hints[NNADAPTER_MAX_SIZE_OF_HINTS]; } Operand; typedef struct Argument { int index; void* memory; void* (*access)(void* memory, NNAdapterOperandType* type); } Argument; typedef struct Operation { NNAdapterOperationType type; std::vector<Operand*> input_operands; std::vector<Operand*> output_operands; } Operation; typedef struct Cache { const char* token; const char* dir; std::vector<NNAdapterOperandType> input_types; std::vector<NNAdapterOperandType> output_types; std::vector<uint8_t> buffer; } Cache; typedef struct Model { std::list<Operand> operands; std::list<Operation> operations; std::vector<Operand*> input_operands; std::vector<Operand*> output_operands; } Model; } // namespace core } // namespace nnadapter
25.80597
75
0.73742
458c37135ef56f8d6f8d0bbd26a604601a88a252
2,607
h
C
Enemy.h
ahadrauf/magician_wars
a9b43ce520fc528b470aec10437f79dbd951547b
[ "MIT" ]
null
null
null
Enemy.h
ahadrauf/magician_wars
a9b43ce520fc528b470aec10437f79dbd951547b
[ "MIT" ]
null
null
null
Enemy.h
ahadrauf/magician_wars
a9b43ce520fc528b470aec10437f79dbd951547b
[ "MIT" ]
null
null
null
#pragma once #include <iostream> #include "Person.h" #include "List.h" #include "Skill.h" class Enemy : public Person { public: Enemy() //default constructor { *this = *getEnemy(1); } Enemy(string n, int l, bool spells, int HB = 20, int MB = 3, int aB = 3, int dB = 3, int mB = 3, int rB = 3, List<Skill *>s = List<Skill *>()) : Person(n), skills(s) //creates new enemies { addSkill(Fireball()); for (int i = 0; i < l; i++) { increaseLevel(HB, MB, aB, dB, mB, rB); } canUseSpells = spells; } Enemy(string n, int l, int h, int m, int aP, int dP, int mA, int mD, bool spells, List<Skill *>s = List<Skill *>()) : Person(n, l, h, m, aP, dP, mA, mD), skills(s) { addSkill(Fireball()); } void addSkill(Skill s) { skills.insertAtBack(new Skill(s)); } void useSkill(Skill *s, Person &p) { getSkill(s->getName())->useSkill(this, &p); } Enemy operator=( Enemy &right) //overloads = operator { Person::operator=(right); skills = right.skills; canUseSpells = right.canUseSpells; return *this; } void attack(Person &p) //AI for attacking { if (skills.isEmpty()) { Person::attack(p, true); } else { if (canUseSpells && (p.getMagicalDefense() < p.getPhysicalDefense() && getMP() >= skills.getLast()->getMPCost())) //attacks using magic if enemy can { useSkill(skills.getLast(), p); } else { Person::attack(p, true); } } } void createNewEnemy() //assigns spells to new enemy { *this = *getEnemy(getLevel() + 1); if (canUseSpells) { if (getLevel() >= 5) addSkill(*(new FireStorm())); if (getLevel() >= 10) addSkill(*(new LavaPlume())); } } Skill *getSkill(const string &n) //allows for polymorphism { if (n == "Fireball") return new Fireball(); if (n == "Fire Storm") return new FireStorm(); if (n == "Lava Plume") return new LavaPlume(); return NULL; } Enemy *getEnemy(int l) //randomly generates new enemy { int choice = rand() % 5; string names[5] = { "Soldier", "Knight", "Mage", "Dark Knight", "Dragon" }; int boostValues[5][6] = { { 20, 3, 3, 3, 3, 3 }, { 30, 1, 5, 5, 1, 3 }, { 10, 10, 1, 3, 5, 5 }, { 15, 15, 5, 5, 5, 5 }, { 30, 20, 7, 7, 7, 7 } }; //growth rates bool spells[5] = { false, false, true, true, true }; return new Enemy(names[choice], l, spells[choice], boostValues[choice][0], boostValues[choice][1], boostValues[choice][2], boostValues[choice][3], boostValues[choice][4], boostValues[choice][5]); } private: List<Skill *> skills; Item *helm; Item *weapon; Item *armor; bool canUseSpells = false; };
21.907563
151
0.59532
45953a8dae29ec10ae4477bf3aa326cc8b06b3c7
13,338
c
C
src/RingQueue/msvc/pthread.c
shines77/RingQueue-utf8
e1643121d1bf793cd3e91262f64a427bee9b0f86
[ "MIT" ]
26
2015-01-01T16:43:55.000Z
2022-03-29T08:05:29.000Z
src/RingQueue/msvc/pthread.c
shines77/RingQueue-utf8
e1643121d1bf793cd3e91262f64a427bee9b0f86
[ "MIT" ]
null
null
null
src/RingQueue/msvc/pthread.c
shines77/RingQueue-utf8
e1643121d1bf793cd3e91262f64a427bee9b0f86
[ "MIT" ]
15
2015-01-12T03:40:28.000Z
2021-06-21T08:34:03.000Z
#if defined(_MSC_VER) || defined(__INTEL_COMPILER) #include "msvc/pthread.h" #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include "msvc/targetver.h" #include <windows.h> #include <process.h> /* _beginthreadex(), _endthreadex() */ #include "port.h" #include <stdio.h> #include <assert.h> int PTW32_CDECL pthread_attr_init(pthread_attr_t * attr) { if (attr != NULL) { *attr = NULL; return (int)0; } else return (int)-1; } int PTW32_CDECL pthread_attr_destroy(pthread_attr_t * attr) { return 0; } pthread_t PTW32_CDECL pthread_self(void) { /// /// 关于GetCurrentThread()的返回 /// /// See: http://www.cnblogs.com/freebird92/articles/846520.html /// HANDLE hCurrentThread = NULL; DuplicateHandle( GetCurrentProcess(), // Handle of process that thread // pseudo-handle is relative to GetCurrentThread(), // Current thread's pseudo-handle GetCurrentProcess(), // Handle of process that the new, real, // thread handle is relative to &hCurrentThread, // Will receive the new, real, handle // identifying the parent thread 0, // Ignored due to DUPLICATE_SAME_ACCESS FALSE, // New thread handle is not inheritable DUPLICATE_SAME_ACCESS // New thread handle has same ); return (pthread_t)hCurrentThread; } /* * PThread Functions */ int PTW32_CDECL pthread_create(pthread_t * tid, const pthread_attr_t * attr, void *(PTW32_API *start)(void *), void * arg) { pthread_t hThread; unsigned int nThreadId; DWORD dwErrorCode; hThread = (pthread_t)_beginthreadex((void *)NULL, 0, (pthread_proc_t)start, arg, 0, (unsigned int *)&nThreadId); if (hThread == INVALID_HANDLE_VALUE || hThread == NULL) { dwErrorCode = GetLastError(); printf("pthread_create(): dwErrorCode = 0x%08X\n", dwErrorCode); return (int)-1; } if (tid != NULL) *tid = hThread; return (int)0; } int PTW32_CDECL pthread_detach(pthread_t tid) { BOOL bResult; bResult = TerminateThread((HANDLE)tid, -1); if (bResult && tid != NULL) bResult = CloseHandle((HANDLE)tid); return (bResult ? 0 : (int)-1); } int PTW32_CDECL pthread_join(pthread_t thread, void **value_ptr) { DWORD dwMillisecs; DWORD dwResponse; if (value_ptr == NULL) dwMillisecs = INFINITE; else dwMillisecs = (DWORD)(*value_ptr); dwResponse = WaitForSingleObject(thread, dwMillisecs); return ((dwResponse == WAIT_OBJECT_0) ? 0 : (int)-1); } /* * Mutex Functions */ int PTW32_CDECL pthread_mutex_init(pthread_mutex_t * mutex, const pthread_mutexattr_t * attr) { #if defined(_WIN64) || defined(_M_X64) || defined(_M_AMD64) || defined(_M_IA64) || defined(__amd64__) || defined(__x86_64__) static const DWORD dwSpinCount = 2; BOOL bResult = FALSE; if (mutex != NULL) bResult = InitializeCriticalSectionAndSpinCount(mutex, dwSpinCount); return (bResult ? 0 : (int)-1); #else if (mutex != NULL) InitializeCriticalSection(mutex); return ((mutex != NULL) ? 0 : (int)-1); #endif /* defined(_M_X64) || defined(_WIN64) */ } int PTW32_CDECL pthread_mutex_destroy(pthread_mutex_t * mutex) { if (mutex != NULL) DeleteCriticalSection(mutex); return ((mutex != NULL) ? 0 : (int)-1); } int PTW32_CDECL pthread_mutex_lock(pthread_mutex_t * mutex) { EnterCriticalSection(mutex); return ((mutex != NULL) ? 0 : (int)-1); } int PTW32_CDECL pthread_mutex_timedlock(pthread_mutex_t * mutex, const struct timespec *abstime) { EnterCriticalSection(mutex); return ((mutex != NULL) ? 0 : (int)-1); } int PTW32_CDECL pthread_mutex_trylock(pthread_mutex_t * mutex) { BOOL bResult = FALSE; if (mutex != NULL) bResult = TryEnterCriticalSection(mutex); return (bResult ? 0 : (int)-1); } int PTW32_CDECL pthread_mutex_unlock(pthread_mutex_t * mutex) { LeaveCriticalSection(mutex); return ((mutex != NULL) ? 0 : (int)-1); } int PTW32_CDECL pthread_mutex_consistent(pthread_mutex_t * mutex) { return 0; } /* * Spinlock Functions */ int PTW32_CDECL pthread_spin_init(pthread_spinlock_t * lock, int pshared) { return 0; } int PTW32_CDECL pthread_spin_destroy(pthread_spinlock_t * lock) { return 0; } int PTW32_CDECL pthread_spin_lock(pthread_spinlock_t * lock) { return 0; } int PTW32_CDECL pthread_spin_trylock(pthread_spinlock_t * lock) { return 0; } int PTW32_CDECL pthread_spin_unlock(pthread_spinlock_t * lock) { return 0; } #endif // defined(_MSC_VER) || defined(__INTERL_COMPILER) #if defined(_MSC_VER) || defined(__INTEL_COMPILER) || defined(__MINGW32__) || defined(__CYGWIN__) #if defined(__MINGW32__) || defined(__CYGWIN__) #include <pthread.h> #include "msvc/pthread.h" #include "port.h" #include <stdio.h> #include <assert.h> typedef struct ptw32_thread_t_ ptw32_thread_t; struct ptw32_thread_t_ { unsigned __int64 seqNumber; /* Process-unique thread sequence number */ HANDLE threadH; /* Win32 thread handle - POSIX thread is invalid if threadH == 0 */ pthread_t ptHandle; /* This thread's permanent pthread_t handle */ }; #endif /* defined(__MINGW32__) || defined(__CYGWIN__) */ HANDLE PTW32_CDECL pthread_process_self(void) { /// /// 关于GetCurrentThread()的返回 /// /// See: http://www.cnblogs.com/freebird92/articles/846520.html /// #if defined(__MINGW32__) || defined(__CYGWIN__) //pthread_t ptw32_process = { 0, 0 }; #endif HANDLE hCurrentProcess = NULL; DuplicateHandle( GetCurrentProcess(), // Handle of process that process // pseudo-handle is relative to GetCurrentProcess(), // Process's pseudo-handle GetCurrentProcess(), // Handle of process that the new, real, // thread handle is relative to &hCurrentProcess, // Will receive the new, real, handle // identifying the process 0, // Ignored due to DUPLICATE_SAME_ACCESS FALSE, // New thread handle is not inheritable DUPLICATE_SAME_ACCESS // New thread handle has same ); #if defined(__MINGW32__) || defined(__CYGWIN__) /* ptw32_process.p = hCurrentProcess; ptw32_process.x = 0; return ptw32_process; //*/ return (HANDLE)hCurrentProcess; #else return (HANDLE)hCurrentProcess; #endif } /* * About the thread affinity */ int PTW32_CDECL pthread_getaffinity_np(pthread_t thread, size_t cpuset_size, cpu_set_t * cpuset) { return 0; } int PTW32_CDECL pthread_setaffinity_np(pthread_t thread_in, size_t cpuset_size, const cpu_set_t * cpuset) { static const int echo = 0; HANDLE hCurrentProcess; HANDLE hTargetThread, thread; DWORD_PTR dwProcessAffinity, dwSystemAffinity; DWORD_PTR dwAffinityMask, dwAffinityMaskOld; #if defined(__MINGW32__) || defined(__CYGWIN__) ptw32_thread_t *sp; pthread_t threadTmp; #endif BOOL bAffResult; int numCore; unsigned int loop_cnt; #if defined(__MINGW32__) || defined(__CYGWIN__) || defined(__MSYS__) #if defined(PTW32_VERSION) && defined(PTW32_VERSION_STRING) sp = (ptw32_thread_t *)thread_in.p; thread = sp->threadH; #elif defined(__MSYS__) || defined(__CYGWIN__) thread = (HANDLE)thread_in; //printf("thread_in = %8p\n", thread_in); #else thread = (thread_t)NULL; #endif #else thread = thread_in; #endif //printf("thread = %8p\n", thread); assert(thread != NULL && thread != INVALID_HANDLE_VALUE); assert(cpuset != NULL); assert(cpuset_size != 0); if (thread == NULL || thread == INVALID_HANDLE_VALUE) { return -1; } numCore = get_num_of_processors(); if (numCore <= 1) { return 0; } if (echo) { printf("\n"); } dwAffinityMask = cpuset->mask; if (dwAffinityMask == 0) { dwAffinityMask = 0xFFFFFFFFU; } #if 1 // Check and set dwProcessAffinity to dwSystemAffinity loop_cnt = 0; hCurrentProcess = pthread_process_self(); dwProcessAffinity = 0; dwSystemAffinity = 0; bAffResult = GetProcessAffinityMask(hCurrentProcess, &dwProcessAffinity, &dwSystemAffinity); if (bAffResult) { while (dwProcessAffinity != dwSystemAffinity) { if (echo) { printf("This process can not utilize all processors.\n"); } bAffResult = SetProcessAffinityMask(hCurrentProcess, dwSystemAffinity); loop_cnt++; if (loop_cnt > 10) { printf("SetProcessAffinityMask(): bAffResult = %u, loop_cnt = %u.\n", bAffResult, loop_cnt); break; } if (bAffResult) { // Wait for the process affinity effected Sleep(1); // Update dwProcessAffinity bAffResult = GetProcessAffinityMask(hCurrentProcess, &dwProcessAffinity, &dwSystemAffinity); } } } else { return -1; } #else loop_cnt = 0; hCurrentProcess = pthread_process_self(); dwProcessAffinity = 0; dwSystemAffinity = 0; bAffResult = GetProcessAffinityMask(hCurrentProcess, &dwProcessAffinity, &dwSystemAffinity); #endif if (echo) { printf("dwProcessMask = %Iu, dwSystemMask = %Iu\n", dwProcessAffinity, dwSystemAffinity); } // Adjust dwAffinityMask dwAffinityMask = dwAffinityMask & dwProcessAffinity; // Set the affinity mask #if defined(__MINGW32__) || defined(__CYGWIN__) || defined(__MSYS__) #if defined(PTW32_VERSION) && defined(PTW32_VERSION_STRING) sp = (ptw32_thread_t *)thread_in.p; hTargetThread = sp->threadH; #elif defined(__MSYS__) || defined(__CYGWIN__) hTargetThread = (HANDLE)thread_in; //printf("hTargetThread = %8p\n", hTargetThread); #else hTargetThread = (thread_t)NULL; #endif #else hTargetThread = thread; #endif dwAffinityMaskOld = SetThreadAffinityMask(hTargetThread, dwAffinityMask); if (echo) { printf("dwMask = %Iu, dwOldMask = %Iu\n", dwAffinityMask, dwAffinityMaskOld); } if (echo) { printf("\n"); } if (dwAffinityMaskOld != 0) { if (echo) printf("pthread_setaffinity_np() ok.\n"); return 0; } else { if (echo) printf("pthread_setaffinity_np() failed.\n"); return -1; } } #if 0 int PTW32_CDECL pthread_setaffinity_np2(pthread_t thread_in, size_t cpuset_size, const cpu_set_t * cpuset) { static const int echo = 1; HANDLE hCurrentProcess = pthread_process_self(); HANDLE hCurrentThread = pthread_self(), thread; DWORD dwProcessAffinity = 0, dwSystemAffinity = 0; DWORD dwAffinityMask; BOOL bAffResult; #if defined(__MINGW32__) || defined(__CYGWIN__) thread = thread_in.p; #else thread = thread_in; #endif assert(thread != NULL); assert(cpuset != NULL); assert(cpuset_size != 0); if (echo) { printf("\n"); } dwAffinityMask = cpuset->mask; bAffResult = GetProcessAffinityMask(hCurrentProcess, &dwProcessAffinity, &dwSystemAffinity); if (bAffResult) { if (dwProcessAffinity != dwSystemAffinity) { if (echo) { printf("This process can not utilize all processors.\n"); } } while ((dwAffinityMask != 0) && (dwAffinityMask <= dwProcessAffinity)) { // Check to make sure we can utilize this processsor first. if ((dwAffinityMask & dwProcessAffinity) != 0) { bAffResult = SetProcessAffinityMask(hCurrentProcess, dwAffinityMask); if (bAffResult) { // Wait for the process affinity effected Sleep(1); // if (echo) { printf("SetProcessAffinityMask(): dwAffinityMask = 0x%08X\n", dwAffinityMask); } DWORD dwProcessAffinityNew = 0; bAffResult = GetProcessAffinityMask(hCurrentProcess, &dwProcessAffinityNew, &dwSystemAffinity); if (dwProcessAffinityNew == dwAffinityMask) { if (echo) { printf("SetProcessAffinityMask(): Success.\n"); } bAffResult = SetThreadAffinityMask(hCurrentThread, dwAffinityMask); Sleep(1); break; } } } } } if (echo) { printf("\n"); } return 0; } #endif #endif // defined(_MSC_VER) || defined(__INTERL_COMPILER) || defined(__MINGW32__) || defined(__CYGWIN__)
28.995652
124
0.607362
a9a49a7ad21428415c5bcbac19ab1841fff5c6f8
2,683
h
C
common/any.h
5r1gsOi1/other
16da2846da4f80cdbccf0232696301c50c10c005
[ "MIT" ]
null
null
null
common/any.h
5r1gsOi1/other
16da2846da4f80cdbccf0232696301c50c10c005
[ "MIT" ]
null
null
null
common/any.h
5r1gsOi1/other
16da2846da4f80cdbccf0232696301c50c10c005
[ "MIT" ]
null
null
null
#ifndef COMMON_ANY_H_ #define COMMON_ANY_H_ #include <exception> #include <string> template <typename = void, typename...> struct ToStringArgumentsMatch : std::false_type {}; template <typename... Args> struct ToStringArgumentsMatch< std::void_t<decltype(std::to_string(std::declval<Args>()...))>, Args...> : std::true_type {}; template <typename... Args> static inline constexpr bool CanBeArgumentOfToString = ToStringArgumentsMatch<void, Args...>::value; class Any { public: Any() : content(nullptr) {} ~Any() { delete content; } Any(const Any& other) { this->content = other.content ? other.content->clone() : nullptr; } Any(Any&& other) { this->content = other.content; other.content = nullptr; } template <typename T> Any(const T& x) { content = new Holder(x); } const std::type_info& type_info() const { return content ? content->type_info() : typeid(nullptr); } template <typename T> T value() const { if (this->type_info() != typeid(T)) { throw std::bad_cast(); } return dynamic_cast<Holder<T>*>(content)->held; } operator std::string() const { return content ? content->operator std::string() : std::string(); } bool operator==(const Any& other) { return this->type_info() == other.type_info() and (this->content == other.content or *this->content == *other.content); } Any operator=(const Any& other) { if (this->content != other.content) { delete this->content; this->content = other.content ? other.content->clone() : nullptr; } return *this; } private: class PlaceHolder { public: virtual ~PlaceHolder() {} virtual const std::type_info& type_info() const = 0; virtual PlaceHolder* clone() const = 0; virtual operator std::string() const = 0; virtual bool operator==(const PlaceHolder& other) const { return this->type_info() == other.type_info(); } }; template <typename ValueType> class Holder : public PlaceHolder { friend class Any; public: Holder(const ValueType& value) : held(value) {} virtual const std::type_info& type_info() const override { return typeid(ValueType); } virtual PlaceHolder* clone() const override { return new Holder(held); } virtual operator std::string() const override { if constexpr (CanBeArgumentOfToString<ValueType>) { return std::to_string(held); } else { return static_cast<std::string>(held); } } virtual bool operator==(const Holder& other) { return this->held == other.held; } private: const ValueType held; }; PlaceHolder* content; }; #endif
25.311321
80
0.641819
aa3de72d5817f64875ad9c508db5c6794aaeb6a7
622
h
C
libecc/src/musl/include/libutil.h
ghsecuritylab/ellcc-mirror
b03a4afac74d50cf0987554b8c0cd8209bcb92a2
[ "BSD-2-Clause" ]
null
null
null
libecc/src/musl/include/libutil.h
ghsecuritylab/ellcc-mirror
b03a4afac74d50cf0987554b8c0cd8209bcb92a2
[ "BSD-2-Clause" ]
null
null
null
libecc/src/musl/include/libutil.h
ghsecuritylab/ellcc-mirror
b03a4afac74d50cf0987554b8c0cd8209bcb92a2
[ "BSD-2-Clause" ]
null
null
null
#ifndef _LIBUTIL_H #define _LIBUTIL_H #ifdef __cplusplus extern "C" { #endif #ifdef _BSD_SOURCE char *getbsize(int *, long *); #define HN_DECIMAL 0x01 #define HN_NOSPACE 0x02 #define HN_B 0x04 #define HN_DIVISOR_1000 0x08 #define HN_GETSCALE 0x10 #define HN_AUTOSCALE 0x20 int humanize_number(char *, size_t, int64_t, const char *, int, int); int dehumanize_number(const char *, int64_t *); uint32_t arc4random(void); void arc4random_stir(void); void arc4random_addrandom(unsigned char *, int); #endif #ifdef __cplusplus } #endif #endif
20.064516
69
0.672026
b778f79638e48dcdef67ccb2049e65ca4afc53f1
1,630
h
C
WDL/jnetlib/netinc.h
wayne-chen/AudioPlugins
397112da7e992628652eddafcaf75f71ddf56d3f
[ "Zlib" ]
879
2015-01-01T16:25:39.000Z
2022-03-15T13:22:40.000Z
WDL/jnetlib/netinc.h
wayne-chen/AudioPlugins
397112da7e992628652eddafcaf75f71ddf56d3f
[ "Zlib" ]
65
2015-01-26T14:31:33.000Z
2018-12-18T16:40:29.000Z
WDL/jnetlib/netinc.h
wayne-chen/AudioPlugins
397112da7e992628652eddafcaf75f71ddf56d3f
[ "Zlib" ]
233
2015-01-21T01:00:56.000Z
2022-03-08T18:50:16.000Z
/* ** JNetLib ** Copyright (C) 2000-2001 Nullsoft, Inc. ** Author: Justin Frankel ** File: netinc.h - network includes and portability defines (used internally) ** License: see jnetlib.h */ #ifndef _NETINC_H_ #define _NETINC_H_ #ifdef _WIN32 #include <windows.h> #include <stdio.h> #include <time.h> #define ERRNO (WSAGetLastError()) #define SET_SOCK_BLOCK(s,block) { unsigned long __i=block?0:1; ioctlsocket(s,FIONBIO,&__i); } #ifndef EWOULDBLOCK #define EWOULDBLOCK WSAEWOULDBLOCK #endif #ifndef EINPROGRESS #define EINPROGRESS WSAEWOULDBLOCK #endif typedef int socklen_t; #else #ifndef THREAD_SAFE #define THREAD_SAFE #endif #ifndef _REENTRANT #define _REENTRANT #endif #include <pthread.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/socket.h> #include <netinet/in.h> #include <sys/time.h> #include <arpa/inet.h> #include <netdb.h> #include <stdarg.h> #include <stdio.h> #include <fcntl.h> #include <unistd.h> #include <signal.h> #include <stdlib.h> #include <errno.h> #include <string.h> #define ERRNO errno #define closesocket(s) close(s) #define SET_SOCK_BLOCK(s,block) { int __flags; if ((__flags = fcntl(s, F_GETFL, 0)) != -1) { if (!block) __flags |= O_NONBLOCK; else __flags &= ~O_NONBLOCK; fcntl(s, F_SETFL, __flags); } } typedef int SOCKET; #define INVALID_SOCKET (-1) #ifndef stricmp #define stricmp(x,y) strcasecmp(x,y) #endif #ifndef strnicmp #define strnicmp(x,y,z) strncasecmp(x,y,z) #endif #endif // !_WIN32 #ifndef INADDR_NONE #define INADDR_NONE 0xffffffff #endif #ifndef INADDR_ANY #define INADDR_ANY 0 #endif #ifndef SHUT_RDWR #define SHUT_RDWR 2 #endif #endif //_NETINC_H_
20.123457
189
0.734356
3198fb1f82b5638c9f5991b25f170b15c41a2231
1,376
h
C
lib/include/fx/easing/BackEase.h
joaoc/stm32plus
a53376c223de306d2192cf4754027bb28c851d28
[ "BSD-3-Clause" ]
null
null
null
lib/include/fx/easing/BackEase.h
joaoc/stm32plus
a53376c223de306d2192cf4754027bb28c851d28
[ "BSD-3-Clause" ]
null
null
null
lib/include/fx/easing/BackEase.h
joaoc/stm32plus
a53376c223de306d2192cf4754027bb28c851d28
[ "BSD-3-Clause" ]
null
null
null
/* * This file is a part of the open source stm32plus library. * Copyright (c) 2011,2012,2013,2014 Andy Brown <www.andybrown.me.uk> * Please see website for licensing terms. */ #pragma once namespace stm32plus { namespace fx { /** * @brief Back easing function. Goes back on itself. */ class BackEase : public EasingBase { private: float _overshoot; public: /// constructor - sets a default value for the overshoot BackEase(); /// Starts the motion by backtracking, then reversing /// direction and moving toward the target virtual float easeIn(float time) const override; /// Starts the motion by moving towards the target, overshooting /// it slightly, and then reversing direction back toward the target virtual float easeOut(float time) const override; /// Combines the motion of the easeIn and easeOut methods to /// start the motion by backtracking, then reversing direction /// and moving toward target, overshooting target slightly, /// reversing direction again, and then moving back toward the target virtual float easeInOut(float time) const override; /// set the overshoot value. The higher the value the /// greater the overshoot. void setOvershoot(float overshoot); }; } }
29.913043
77
0.659884
2c47dfe11aa30cd328904491d5416a6b6ab93d5e
686
h
C
Pods/Headers/Public/OPGFeedbackSDK/CategoryFlagConstants.h
OnePointGlobal/MySurvey-2.0-App_New
02368bee4a3b5b9e07f95d586c02c20880e35a4b
[ "MIT" ]
null
null
null
Pods/Headers/Public/OPGFeedbackSDK/CategoryFlagConstants.h
OnePointGlobal/MySurvey-2.0-App_New
02368bee4a3b5b9e07f95d586c02c20880e35a4b
[ "MIT" ]
12
2019-10-14T10:29:55.000Z
2020-04-23T10:52:13.000Z
Pods/Headers/Public/OPGFeedbackSDK/CategoryFlagConstants.h
OnePointGlobal/OnePoint-Global-MySurvey-2.0-App-iOS-Latest
02368bee4a3b5b9e07f95d586c02c20880e35a4b
[ "MIT" ]
1
2022-03-17T08:46:39.000Z
2022-03-17T08:46:39.000Z
// // Generated by the J2ObjC translator. DO NOT EDIT! // source: /Users/chinthan/Framework/Logger/ConvertCode/OnePoint/Runtime/Common/CategoryFlagConstants.java // // Created by chinthan on 1/15/14. // typedef enum { CategoryFlagConstants_flNone = 0, CategoryFlagConstants_flUser = 1, CategoryFlagConstants_flDontknow = 2, CategoryFlagConstants_flRefuse = 3, CategoryFlagConstants_flNoanswer = 4, CategoryFlagConstants_flOther = 5, CategoryFlagConstants_flMultiplier = 6, CategoryFlagConstants_flExclusive = 7, CategoryFlagConstants_flFixedPosition = 8, CategoryFlagConstants_flNoFilter = 9, CategoryFlagConstants_flInline = 10, } CategoryFlagConstants;
27.44
107
0.791545
bda31cb0e0951b97220b64ca88b6a6e507bb523c
1,195
h
C
src/wrapped/wrappedalure_private.h
ye-yeshun/box86
35f133cacd726aac85bcd7befc6ac21ae3a1f53d
[ "MIT" ]
2,059
2019-03-03T22:16:11.000Z
2022-03-31T21:53:33.000Z
src/wrapped/wrappedalure_private.h
ye-yeshun/box86
35f133cacd726aac85bcd7befc6ac21ae3a1f53d
[ "MIT" ]
428
2019-03-04T15:19:01.000Z
2022-03-31T23:46:30.000Z
src/wrapped/wrappedalure_private.h
ye-yeshun/box86
35f133cacd726aac85bcd7befc6ac21ae3a1f53d
[ "MIT" ]
207
2019-03-14T18:19:18.000Z
2022-03-30T08:52:41.000Z
#if !(defined(GO) && defined(GOM) && defined(GO2) && defined(DATA)) error Meh... #endif GO(alureGetVersion,vFpp) GO(alureGetErrorString,pFv) GO(alureGetDeviceNames,pFip) GO(alureFreeDeviceNames,vFp) GO(alureInitDevice,iFpp) GO(alureShutdownDevice,iFv) GO(alureGetSampleFormat,iFuuu) GO(alureSleep,iFf) GO(alureStreamSizeIsMicroSec,iFi) GO(alureCreateBufferFromFile,uFp) GO(alureCreateBufferFromMemory,uFpi) GO(alureBufferDataFromFile,iFpu) GO(alureBufferDataFromMemory,iFpiu) GO(alureCreateStreamFromFile,pFpiip) GO(alureCreateStreamFromMemory,pFpuiip) GO(alureCreateStreamFromStaticMemory,pFpuiip) //GOM(alureCreateStreamFromCallback,pFEBpiuiip) GO(alureGetStreamLength,IFp) GO(alureGetStreamFrequency,iFp) GO(alureGetStreamOrder,uFp) GO(alureBufferDataFromStream,iFpip) GO(alureRewindStream,iFp) GO(alureSetStreamOrder,iFpu) GO(alureSetStreamPatchset,iFpp) GO(alureDestroyStream,iFpip) GO(alureUpdate,vFv) GO(alureUpdateInterval,iFf) //GOM(alurePlaySourceStream,iFEupiiBp) //GOM(alurePlaySource,iFEuBp) GO(alureStopSource,iFui) GO(alurePauseSource,iFu) GO(alureResumeSource,iFu) //GOM(alureInstallDecodeCallbacks,iFEiBBBBBB) //GOM(alureSetIOCallbacks,iFEBBBBB) //GOM(alureGetProcAddress,pFEp)
30.641026
67
0.845188
081d2b48729eeb9d1721108110e6e7e552bba7e7
4,034
h
C
chuffed/support/vec.h
tlyphed/chuffed
23b9fcee3bb30b11f68d82ef4534040ebae1a8fb
[ "MIT" ]
62
2016-11-25T08:03:51.000Z
2022-03-05T18:24:19.000Z
chuffed/support/vec.h
tlyphed/chuffed
23b9fcee3bb30b11f68d82ef4534040ebae1a8fb
[ "MIT" ]
57
2016-11-29T16:43:51.000Z
2022-03-06T22:14:45.000Z
chuffed/support/vec.h
tlyphed/chuffed
23b9fcee3bb30b11f68d82ef4534040ebae1a8fb
[ "MIT" ]
31
2016-11-17T12:37:21.000Z
2022-01-22T20:39:17.000Z
#ifndef vec_h #define vec_h #include <cstdlib> #include <cassert> template <class T> class vec { int sz; int cap; T* data; public: // Constructors: vec() : sz(0), cap(0), data(NULL) {} vec(int _sz) : sz(_sz), cap(sz) { data = sz ? (T*) malloc(cap * sizeof(T)) : NULL; for (int i = 0; i < sz; i++) new (&data[i]) T(); } vec(int _sz, const T& pad) : sz(_sz), cap(sz) { data = sz ? (T*) malloc(cap * sizeof(T)) : NULL; for (int i = 0; i < sz; i++) new (&data[i]) T(pad); } template <class U> vec(vec<U>& other) : sz(other.size()), cap(sz) { assert(sizeof(U) == sizeof(T)); data = (T*) malloc(cap * sizeof(T)); for (int i = 0; i < sz; i++) new (&data[i]) T(other[i]); // for (int i = 0; i < sz; i++) data[i] = other[i]; } ~vec(void) { for (int i = 0; i < sz; i++) data[i].~T(); if (data) free(data); data = NULL; } // Size operations: int size (void) const { return sz; } int& _size () { return sz; } int capacity (void) const { return cap; } void resize (int nelems) { assert(nelems <= sz); for (int i = nelems; i < sz; i++) data[i].~T(); sz = nelems; } void shrink (int nelems) { assert(nelems <= sz); resize(sz-nelems); } void pop (void) { data[--sz].~T(); } // Stack interface: void push () { if (sz == cap) { cap = imax(2, (cap*3+1)>>1); data = (T*) realloc(data, cap * sizeof(T)); } new (&data[sz++]) T(); } void push (const T& elem) { if (sz == cap) { cap = imax(2, (cap*3+1)>>1); data = (T*) realloc(data, cap * sizeof(T)); } new (&data[sz++]) T(elem); } const T& last (void) const { return data[sz-1]; } T& last (void) { return data[sz-1]; } // Vector interface: const T& operator [] (int index) const { return data[index]; } T& operator [] (int index) { return data[index]; } // Raw access to data T* release (void) { T* ret = data; data = NULL; sz = 0; cap = 0; return ret; } operator T* (void) { return data; } // Duplicatation (preferred instead): void copyTo(vec<T>& copy) const { copy.clear(); copy.growTo(sz); for (int i = 0; i < sz; i++) new (&copy[i]) T(data[i]); } void moveTo(vec<T>& dest) { dest.clear(true); dest.data = data; dest.sz = sz; dest.cap = cap; data = NULL; sz = 0; cap = 0; } int imin(int x, int y) { int mask = ((x-y) >> 31); return (x&mask) + (y&(~mask)); } int imax(int x, int y) { int mask = ((y-x) >> 31); return (x&mask) + (y&(~mask)); } void reserve(int size) { if (size > cap) { if (cap == 0) cap = (size > 2) ? size : 2; else do cap = (cap*3+1) >> 1; while (cap < size); data = (T*) realloc(data, cap * sizeof(T)); } } void growTo(int size) { if (size <= sz) return; reserve(size); for (int i = sz; i < size; i++) new (&data[i]) T(); sz = size; } void growTo(int size, const T& pad) { if (size <= sz) return; reserve(size); for (int i = sz; i < size; i++) new (&data[i]) T(pad); sz = size; } void growBy(int extra, const T& pad = T()) { growTo(sz+extra, pad); } void clear(bool dealloc = false) { if (!data) return; for (int i = 0; i < sz; i++) data[i].~T(); sz = 0; if (dealloc) { cap = 0; free(data); data = NULL; } } void remove(const T& t) { int j; for (j = 0; j < sz && data[j] != t; j++); if (j < sz) { data[j] = last(); pop(); } } }; //----- template <class T> class queue { public: int sz; int cap; int head; int tail; bool fifo; T* data; queue() : sz(0), cap(10), head(0), tail(0), fifo(false) { data = (T*) malloc(cap * sizeof(T)); } void reserve() { if (++sz == cap) { cap = cap*3/2; data = (T*) realloc(data, cap * sizeof(T)); } } bool empty() { return tail == head; } void push(const T& e) { data[tail++] = e; if (fifo && tail == cap) tail = 0; } T pop() { if (!fifo) return data[--tail]; T& e = data[head++]; if (head == cap) head = 0; return e; } }; #endif
26.194805
159
0.505949
08443f50d80b111e796d06354a49477d51ef36db
21,628
h
C
kernel/huawei/hwp7/drivers/hisi/modem/ps/comm/comm/NFEXT/Interpeak/ip_net2-6.8/ipnet2/src/ipnet_nat_h.h
NightOfTwelve/android_device_huawei_hwp7
a0a1c28e44210ce485a4177ac53d3fd580008a1e
[ "Apache-2.0" ]
1
2020-04-03T14:00:34.000Z
2020-04-03T14:00:34.000Z
kernel/huawei/hwp7/drivers/hisi/modem/ps/comm/comm/NFEXT/Interpeak/ip_net2-6.8/ipnet2/src/ipnet_nat_h.h
NightOfTwelve/android_device_huawei_hwp7
a0a1c28e44210ce485a4177ac53d3fd580008a1e
[ "Apache-2.0" ]
null
null
null
kernel/huawei/hwp7/drivers/hisi/modem/ps/comm/comm/NFEXT/Interpeak/ip_net2-6.8/ipnet2/src/ipnet_nat_h.h
NightOfTwelve/android_device_huawei_hwp7
a0a1c28e44210ce485a4177ac53d3fd580008a1e
[ "Apache-2.0" ]
1
2020-04-03T14:00:39.000Z
2020-04-03T14:00:39.000Z
/* ****************************************************************************** * INTERPEAK INTERNAL API HEADER FILE * * Document no: @(#) $Name: VXWORKS_ITER18A_FRZ10 $ $RCSfile: ipnet_nat_h.h,v $ $Revision: 1.13 $ * $Source: /home/interpeak/CVSRoot/ipnet2/src/ipnet_nat_h.h,v $ * $State: Exp $ $Locker: $ * * Copyright Interpeak AB 2000-2002 <www.interpeak.se>. All rights reserved. * Design and implementation by FirstName LastName <email@interpeak.se> ****************************************************************************** */ #ifndef IPNET_NAT_H_H #define IPNET_NAT_H_H /* **************************************************************************** * 1 DESCRIPTION **************************************************************************** * Internal header file for the NAT. */ /* **************************************************************************** * 2 CONFIGURATION **************************************************************************** */ /* **************************************************************************** * 3 INCLUDE FILES **************************************************************************** */ #include "ipnet_nat.h" #include <ipcom_list.h> #include <ipcom_hash.h> #include <ipcom_pqueue.h> #include <ipcom_inet.h> #ifdef __cplusplus extern "C" { #endif /* **************************************************************************** * 4 DEFINES **************************************************************************** */ /* *=========================================================================== * IP_IP_NAT *=========================================================================== * NAT socket option. Define here for backward compatibility if not already * defined. */ #ifndef IP_IP_NAT #define IP_IP_NAT 50 /* Network address translation control */ #endif /* *=========================================================================== * IPNET_NAT_MAX_RULES *=========================================================================== * Defines the maximum number of rules that can be added to the NAT. */ #define IPNET_NAT_MAX_RULES 100 /* *=========================================================================== * IPNET_NAT_MAX_PROXIES *=========================================================================== * Defines the maximum number of proxies that can be added to the NAT. */ #define IPNET_NAT_MAX_PROXIES 10 /* *=========================================================================== * IPNET_NAT_MAX_RULE_ARGS *=========================================================================== * Defines the maximum number of arguments in a NAT rule string. */ #define IPNET_NAT_MAX_RULE_ARGS 16 /* *=========================================================================== * IPNET_NAT_PROXY_LABEL_LEN *=========================================================================== * Defines the maximum length of a proxy label. * */ #define IPNET_NAT_PROXY_LABEL_LEN 32 /* *=========================================================================== * IPNET_NAT_CTRL_XXX *=========================================================================== * Defines the available NAT control commands used to pass data to and from * the NAT kernel using the IP_IP_NAT socket option. */ #define IPNET_NAT_CTRL_ENABLE 0 #define IPNET_NAT_CTRL_DISABLE 1 #define IPNET_NAT_CTRL_ADD_RULE 2 #define IPNET_NAT_CTRL_DEL_RULE 3 #define IPNET_NAT_CTRL_FLUSH_RULES 4 #define IPNET_NAT_CTRL_GET_RULE 5 #define IPNET_NAT_CTRL_GET_INFO 6 #define IPNET_NAT_CTRL_CLEAR_STATS 7 #define IPNET_NAT_CTRL_FLUSH_MAPPINGS 8 #define IPNET_NAT_CTRL_GET_MAPPING 9 #define IPNET_NAT_CTRL_GET_PROXY 12 /* *=========================================================================== * Session states *=========================================================================== */ #define IPNET_NAT_MAPPING_CLO 0 #define IPNET_NAT_MAPPING_SYN 1 #define IPNET_NAT_MAPPING_EST 2 #define IPNET_NAT_MAPPING_FIN 3 /* *=========================================================================== * TCP flags *=========================================================================== */ #define IPNET_NAT_TCPFLAG_URGENT 0x0020 #define IPNET_NAT_TCPFLAG_ACK 0x0010 #define IPNET_NAT_TCPFLAG_PUSH 0x0008 #define IPNET_NAT_TCPFLAG_RESET 0x0004 #define IPNET_NAT_TCPFLAG_SYN 0x0002 #define IPNET_NAT_TCPFLAG_FIN 0x0001 /* *=========================================================================== * ICMP destination unreachable codes *=========================================================================== */ #define IPNET_NAT_ICMP4_CODE_DST_UNREACH_NET 0 #define IPNET_NAT_ICMP4_CODE_DST_UNREACH_HOST 1 #define IPNET_NAT_ICMP4_CODE_DST_UNREACH_PROTO 2 #define IPNET_NAT_ICMP4_CODE_DST_UNREACH_PORT 3 #define IPNET_NAT_ICMP4_CODE_DST_NEEDFRAG 4 #define IPNET_NAT_ICMP4_CODE_DST_SRCFAIL 5 #define IPNET_NAT_ICMP4_CODE_DST_UNKNOWN_NET 6 #define IPNET_NAT_ICMP4_CODE_DST_UNKNOWN_HOST 7 #define IPNET_NAT_ICMP4_CODE_DST_ISOLATED 8 #define IPNET_NAT_ICMP4_CODE_DST_PROHIBITED_NET 9 #define IPNET_NAT_ICMP4_CODE_DST_PROHIBITED_HOST 10 #define IPNET_NAT_ICMP4_CODE_DST_UNREACH_TOS_NET 11 #define IPNET_NAT_ICMP4_CODE_DST_UNREACH_TOS_HOST 12 /* *=========================================================================== * ICMP query messages common length *=========================================================================== */ #define IPNET_NAT_ICMP_QUERY_LENGTH 8 /* *=========================================================================== * NAT return codes *=========================================================================== */ #define IPNET_NAT_PT_TRANSLATED 2 /* Applied NAT-PT */ #define IPNET_NAT_TRANSLATED 1 /* Applied NAT */ #define IPNET_NAT_NOMATCH 0 /* No matching rule */ #define IPNET_NAT_INVALID -1 /* Cannot NAT packet */ #define IPNET_NAT_DROP -2 /* Drop packet */ /* *=========================================================================== * ICMP request type *=========================================================================== */ #define IPNET_NAT_IS_ICMP_REQUEST(type) (type == IPCOM_ICMP_ECHO_REQUEST || \ type == IPCOM_ICMP_TSTAMP_REQUEST || \ type == IPCOM_ICMP_INFO_REQUEST || \ type == IPCOM_ICMP_MASK_REQUEST) /* *=========================================================================== * ICMP reply type *=========================================================================== */ #define IPNET_NAT_IS_ICMP_REPLY(type) (type == IPCOM_ICMP_ECHO_REPLY || \ type == IPCOM_ICMP_TSTAMP_REPLY || \ type == IPCOM_ICMP_INFO_REPLY || \ type == IPCOM_ICMP_MASK_REPLY) /* *=========================================================================== * ICMP error type *=========================================================================== */ #define IPNET_NAT_IS_ICMP_ERROR(type) (type == IPCOM_ICMP_SOURCEQUENCH || \ type == IPCOM_ICMP_UNREACH || \ type == IPCOM_ICMP_PARAMPROB || \ type == IPCOM_ICMP_TIMEXCEED || \ type == IPCOM_ICMP_REDIRECT) /* *=========================================================================== * Link header size *=========================================================================== * Assume Ethernet and VLAN (IPNET will increase header space if required) */ #define IPNET_NAT_LINK_HDR_SIZE (14 + 4) /* **************************************************************************** * 5 TYPES **************************************************************************** */ /* *=========================================================================== * Ipnet_nat_pseudo_hdr *=========================================================================== * Pseudo header for IPv4 used in UDP/TCP checksum calculations. * */ #include <ipcom_align16.h> typedef IP_PACKED1 struct Ipnet_nat_pseudo_hdr_struct { Ip_u32 src_n; Ip_u32 dst_n; Ip_u8 mbz; Ip_u8 protocol; Ip_u16 length_n; } IP_PACKED2 Ipnet_nat_pseudo_hdr; #include <ipcom_align16.h> /* *=========================================================================== * Ipnet_nat_stats *=========================================================================== * NAT statistics. */ typedef struct Ipnet_nat_stats_struct { Ip_u32 translated_in; Ip_u32 translated_out; Ip_u32 invalid_in; Ip_u32 invalid_out; Ip_u32 dropped_in; Ip_u32 dropped_out; Ip_u32 no_rule_match_in; Ip_u32 no_rule_match_out; Ip_u32 mappings_added; Ip_u32 mappings_expired; Ip_u32 mapping_failures; } Ipnet_nat_stats; /* *=========================================================================== * Ipnet_nat_data_inner *=========================================================================== * */ struct Ipnet_nat_data_inner { Ip_s32 open; /* Opened or closed */ Ip_u16 port_lo; /* Start port for automatically NATed ports */ Ip_u16 port_hi; /* End port for automatically NATed ports */ Ip_u32 second; /* Current nat time */ Ipnet_nat_stats stats; /* Statistics */ Ip_s32 timeout_icmp; /* icmp timeout */ Ip_s32 timeout_udp; /* udp timeout */ Ip_s32 timeout_tcp; /* tcp timeout */ Ip_s32 timeout_other; /* tcp other */ Ip_s32 max_mappings; /* max number of mappings */ }; /* *=========================================================================== * Ipnet_nat_data *=========================================================================== * NAT data. */ typedef struct Ipnet_nat_data_struct { Ipcom_list head_rule; /* Rule list */ Ipcom_list head_proxy; /* Proxy list */ Ipcom_list head_mapping; /* Mapping list */ Ipcom_hash *hash_out_port; /* Hash table for outgoing packets with port protocols */ Ipcom_hash *hash_out_noport; /* Hash table for outgoing packets with noport protocols */ Ipcom_hash *hash_in_port; /* Hash table for incoming packets with port protocols */ Ipcom_hash *hash_in_noport; /* Hash table for incoming packets with noport protocols */ Ip_u32 *ports; /* Pointer to port array for automatically NATed ports */ struct Ip_in_addr *origfrom; /* original param->from */ struct Ip_in_addr newsource; /* new source address */ struct Ipnet_nat_data_inner inner; } Ipnet_nat_data; /* *=========================================================================== * Ipnet_nat_tuple *=========================================================================== * NAT packet tuple. */ typedef struct Ipnet_nat_tuple_struct { Ip_u8 protocol; Ip_u8 icmp_type; Ip_u16 icmp_id_n; Ip_u16 src_port_n; Ip_u16 dst_port_n; Ip_u32 src_n; Ip_u32 dst_n; Ip_u32 fragid; Ip_u16 fragoff; Ip_u16 tcp_flags; Ip_u8 fragmf; Ip_u8 tos; Ip_u8 ttl; #ifdef IPNET_USE_NAT_PT struct Ip_in6_addr pt_src; struct Ip_in6_addr pt_dst; #endif } Ipnet_nat_tuple; /* *=========================================================================== * Ipnet_nat_rule_inner *=========================================================================== * */ struct Ipnet_nat_rule_inner { /* Actions */ Ip_u8 map; /* Do not add any entries before the map member */ Ip_u8 map_block; Ip_u8 rdr; Ip_u8 pt; Ip_u8 pt_block; Ip_u8 proxy_nonapt; Ip_u8 unused[2]; /* Interface */ char ifname[IP_IFNAMSIZ]; /* Source address/mask */ Ip_u32 src_n; Ip_u32 src_mask_n; #ifdef IPNET_USE_NAT_PT struct Ip_in6_addr src_n_pt; struct Ip_in6_addr src_mask_n_pt; #endif /* Destination address/mask */ Ip_u32 dst_n; Ip_u32 dst_mask_n; /* NAT address/mask */ Ip_u32 nat_addr_n; Ip_u32 nat_mask_n; #ifdef IPNET_USE_NAT_PT struct Ip_in6_addr nat_addr_n_pt; struct Ip_in6_addr nat_mask_n_pt; #endif /* portmap and icmpidmap keyword */ Ip_u8 icmpidmap; Ip_u8 portmap; Ip_u8 portmap_tcpudp; Ip_u8 portmap_protocol; Ip_u16 port_lo; Ip_u16 port_hi; /* proxy keyword */ Ip_u8 proxy; Ip_u8 proxy_protocol; Ip_u16 proxy_trigger; char proxy_label[IPNET_NAT_PROXY_LABEL_LEN]; /* Redirection keyword */ Ip_u16 rdr_old_port_n; Ip_u16 rdr_new_port_n; Ip_u8 rdr_tcpudp; Ip_u8 rdr_protocol; }; /* *=========================================================================== * Ipnet_nat_rule *=========================================================================== * NAT rule */ typedef struct Ipnet_nat_rule_struct { Ipcom_list list_rule; /* Keep list entry first */ Ip_u32 *ports; Ipnet_nat_proxy_func proxy_func; void *proxy_cookie; struct Ipnet_nat_rule_inner inner; } Ipnet_nat_rule; /* *=========================================================================== * Ipnet_nat_mapping_inner *=========================================================================== * */ struct Ipnet_nat_mapping_inner { Ip_u32 tmo_abs_sec; /* Absolute timeout in seconds */ Ip_u32 tmo_int_sec; /* Timeout interval seconds */ Ipnet_nat_tuple tuple; /* Packet tuple */ Ip_u32 nat_addr_n; /* New address */ Ip_u16 nat_port_n; /* New port */ Ip_u8 inner_state; /* State inner */ Ip_u8 outer_state; /* State outer */ Ip_u32 seq_start; /* Initial sequence number */ Ip_s32 curr_delta; /* Current delta sequence number */ Ip_s32 prev_delta; /* Previous delta sequence number */ Ip_u8 seq_initiated; /* Sequence number initiated */ Ip_u8 seq_incoming; /* Incoming sequence number */ Ip_u8 pt; /* Set for pt mappings when listed */ Ip_u8 rdr; /* Mapping created by redirect rule */ Ip_u32 autoport; /* Set when automatic port is allocated */ #ifdef IPNET_USE_NAT_PT struct Ip_in6_addr nat_addr_n_pt; /* New address */ #endif }; /* *=========================================================================== * Ipnet_nat_mapping *=========================================================================== * NAT mapping. */ typedef struct Ipnet_nat_mapping_struct { Ipcom_list list; /* Keep list entry first */ Ipnet_timeout *tmo; /* Timeout handler */ Ipnet_nat_rule *rule; /* Reference to the rule */ Ipnet_nat_proxy_func proxy_func; /* Proxy function */ void *proxy_cookie; /* Proxy cookie */ struct Ipnet_nat_mapping_inner inner; } Ipnet_nat_mapping; /* *=========================================================================== * Ipnet_nat_hash_key *=========================================================================== * NAT hash key. */ typedef struct Ipnet_nat_hash_key_struct { Ip_u8 protocol; Ip_u16 src_port_n; Ip_u16 dst_port_n; Ip_u32 src_n; Ip_u32 dst_n; Ip_u32 nat_addr_n; Ip_u16 nat_port_n; } Ipnet_nat_hash_key; /* *=========================================================================== * Ipnet_nat_proxy_inner *=========================================================================== * */ struct Ipnet_nat_proxy_inner { char label[IPNET_NAT_PROXY_LABEL_LEN]; Ip_u8 protocol; }; /* *=========================================================================== * Ipnet_nat_proxy *=========================================================================== * NAT proxy. */ typedef struct Ipnet_nat_proxy_struct { Ipcom_list list_proxy; /* Keep list entry first */ Ipnet_nat_proxy_func func; void *cookie; struct Ipnet_nat_proxy_inner inner; } Ipnet_nat_proxy; /* *=========================================================================== * Ipnet_nat_ctrl *=========================================================================== * NAT control structure for the IP_IP_NAT socket option. */ typedef struct Ipnet_nat_ctrl_struct { Ip_s32 cmd; /* Control command */ Ip_s32 seqno; /* Optional sequence number */ union { struct Ipnet_nat_data_inner info; struct Ipnet_nat_rule_inner rule_info; struct Ipnet_nat_mapping_inner mapping_info; struct Ipnet_nat_proxy_inner proxy_info; } type; /* Optional type */ } Ipnet_nat_ctrl; /* **************************************************************************** * 6 FUNCTIONS **************************************************************************** */ IP_GLOBAL void ipnet_nat_translate_tcpudp_port(Ip_bool incoming, Ipcom_pkt *pkt, Ipnet_nat_mapping *nat_mapping); IP_GLOBAL void ipnet_nat_checksum_update(unsigned char *chksum, unsigned char *optr, int olen, unsigned char *nptr, int nlen); IP_GLOBAL void ipnet_nat_update_sequence_number(Ip_bool incoming, Ipnet_nat_mapping *nat_mapping, Ip_u32 seq_num, Ip_s32 delta); IP_GLOBAL void ipnet_nat_translate_sequence_number(Ip_bool incoming, Ipcom_pkt *pkt, Ipnet_nat_mapping *nat_mapping); IP_GLOBAL void ipnet_nat_translate_ack_number(Ip_bool incoming, Ipcom_pkt *pkt, Ipnet_nat_mapping *nat_mapping); IP_GLOBAL void ipnet_nat_update_mapping(Ip_bool incoming, Ipnet_nat_mapping *nat_mapping, Ipnet_nat_tuple *nat_tuple); IP_GLOBAL Ip_s32 ipnet_nat_match_rule(Ip_bool incoming, Ipnet_nat_rule *nat_rule, Ip_u32 ifindex, Ipnet_nat_tuple *nat_tuple); IP_GLOBAL Ip_s32 ipnet_nat_proxy(Ip_bool incoming, Ipcom_pkt **pktp, Ipnet_nat_tuple *nat_tuple, Ipnet_nat_mapping *nat_mapping, int hlen, Ip_bool *mod, Ip_s32 *delta); IP_GLOBAL Ip_s32 ipnet_nat_protocol_number(const char *name); IP_GLOBAL Ip_s32 ipnet_nat_output_hook(Ipcom_pkt **pktp, Ip_bool no_rules); IP_GLOBAL Ip_s32 ipnet_nat_input_hook(Ipcom_pkt **pktp, void *param); IP_GLOBAL Ipnet_nat_mapping *ipnet_nat_add_mapping(Ip_bool incoming, Ipnet_nat_rule *nat_rule, Ipnet_nat_tuple *nat_tuple, Ip_u32 timeout, Ipnet_nat_mapping *parent, Ip_bool napt, Ipnet_nat_proxy_func proxy_func, void *proxy_cookie); IP_GLOBAL Ipnet_nat_mapping *ipnet_nat_find_mapping(Ip_bool incoming, Ipcom_pkt *pkt, Ipnet_nat_tuple *nat_tuple); IP_GLOBAL char *ipnet_nat_protocol_name(Ip_u8 protocol, char *protostr, Ip_u32 protostrlen); IP_GLOBAL Ip_err ipnet_nat_init(void); #ifdef IPNET_USE_NAT_PT IP_GLOBAL Ip_s32 ipnet_nat_pt_translate(Ip_bool incoming, Ipnet_nat_mapping *nat_mapping, Ipcom_pkt **pktp, Ipnet_nat_tuple *nat_tuple, void *param); IP_GLOBAL Ip_s32 ipnet_nat_pt_output_hook(Ipnet_ip4_output_param *param4, Ipcom_pkt **pktp); #endif IP_PUBLIC int ipnet_cmd_nat(int argc, char **argv); #ifdef __cplusplus } #endif #endif /* **************************************************************************** * END OF FILE **************************************************************************** */
36.106845
131
0.44447
bd1ce60d1be1fbd6da623a796d469161492f81da
1,026
h
C
Sources/UIKit_ObjC/UIImagePickerController+NDUtils.h
hiep-nd/nd-utils
b6175b58aaae7ed5bc8883605e39e91666ad7afb
[ "MIT" ]
null
null
null
Sources/UIKit_ObjC/UIImagePickerController+NDUtils.h
hiep-nd/nd-utils
b6175b58aaae7ed5bc8883605e39e91666ad7afb
[ "MIT" ]
null
null
null
Sources/UIKit_ObjC/UIImagePickerController+NDUtils.h
hiep-nd/nd-utils
b6175b58aaae7ed5bc8883605e39e91666ad7afb
[ "MIT" ]
null
null
null
// // UIImagePickerController+NDUtils.h // NDUtils // // Created by Nguyen Duc Hiep on 8/10/20. // Copyright © 2020 Nguyen Duc Hiep. All rights reserved. // #import <NDUtils/UINavigationController+NDUtils.h> NS_ASSUME_NONNULL_BEGIN @interface NDUIImagePickerControllerDelegateHandlers : NDUINavigationControllerDelegateHandlers <UIImagePickerControllerDelegate> // The picker does not dismiss itself; the client dismisses it in these // callbacks. The delegate will receive one or the other, but not both, // depending whether the user confirms or cancels. @property(nonatomic, copy) void (^_Nullable didFinishPickingMediaWithInfo) (__kindof UIImagePickerController*, NSDictionary<UIImagePickerControllerInfoKey, id>*); @property(nonatomic, copy) void (^_Nullable didCancel) (__kindof UIImagePickerController*); @end @interface UIImagePickerController (NDUtils) @property(nonatomic, strong, readonly) NDUIImagePickerControllerDelegateHandlers* nd_delegateHandlers; @end NS_ASSUME_NONNULL_END
29.314286
80
0.795322
83449fb7c3620cac97a8326b03374d318dc6f79a
3,302
h
C
StuFW/src/core/commands/gcode/config/m305.h
onekk/StuFW
9dd7cd41c0cec2749ded8d1d97b7f9fcaa61489b
[ "RSA-MD" ]
1
2020-12-30T21:45:12.000Z
2020-12-30T21:45:12.000Z
StuFW/src/core/commands/gcode/config/m305.h
onekk/StuFW
9dd7cd41c0cec2749ded8d1d97b7f9fcaa61489b
[ "RSA-MD" ]
1
2020-08-24T16:17:25.000Z
2020-08-24T16:17:25.000Z
StuFW/src/core/commands/gcode/config/m305.h
onekk/StuFW
9dd7cd41c0cec2749ded8d1d97b7f9fcaa61489b
[ "RSA-MD" ]
null
null
null
/** * StuFW Firmware for 3D Printer * * Based on MK4duo, Marlin, Sprinter and grbl * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm * Copyright (C) 2013 Alberto Cotronei @MagoKimbra * * 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 3 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, see <http://www.gnu.org/licenses/>. * */ /** * mcode * * Copyright (C) 2017 Alberto Cotronei @MagoKimbra */ #if HEATER_COUNT > 0 #define CODE_M305 /** * M305: Set thermistor and ADC parameters * * H[heaters] H = 0-3 Hotend, H = -1 BED, H = -2 CHAMBER, H = -3 COOLER * * A[float] Thermistor resistance at 25°C * B[float] BetaK * C[float] Steinhart-Hart C coefficien * R[float] Pullup resistor value * L[int] ADC low offset correction * O[int] ADC high offset correction * P[int] Sensor Pin * T[int] Sensor Type * * D DHT parameters * S[int] Type Sensor * P[int] Sensor Pin * */ inline void gcode_M305(void) { #if ENABLED(DHT_SENSOR) if (parser.seen('D')) { #if DISABLED(DISABLE_M503) // No arguments? Show M305 report. if (!parser.seen("PS")) { dhtsensor.print_M305(); return; } #endif dhtsensor.data.pin = parser.intval('P', DHT_DATA_PIN); if (parser.seen('S')) dhtsensor.change_type(DHTEnum(parser.value_int())); dhtsensor.init(); return; } #endif int8_t h = 0; if (!commands.get_target_heater(h)) return; Heater *act = &heaters[h]; #if DISABLED(DISABLE_M503) // No arguments? Show M305 report. if (!parser.seen("ABCRLOTP")) { act->print_M305(); return; } #endif act->sensor.r25 = parser.floatval('A', act->sensor.r25); act->sensor.beta = parser.floatval('B', act->sensor.beta); act->sensor.shC = parser.floatval('C', act->sensor.shC); act->sensor.pullupR = parser.floatval('R', act->sensor.pullupR); act->sensor.adcLowOffset = parser.intval('L', act->sensor.adcLowOffset); act->sensor.adcHighOffset = parser.intval('O', act->sensor.adcHighOffset); act->sensor.type = parser.intval('T', act->sensor.type); if (parser.seen('P')) { // Put off the heaters act->setTarget(0); const pin_t new_pin = parser.analog_value_pin(); if (new_pin != NoPin) { const pin_t old_pin = act->sensor.pin; act->sensor.pin = new_pin; HAL::AdcChangePin(old_pin, act->sensor.pin); } } act->sensor.CalcDerivedParameters(); } #endif // HEATER_COUNT > 0
30.018182
79
0.589945
eabf015374f95be7f377d5f6356466bbc3d2a244
7,654
c
C
src/util/attr_clnt.c
TonyChengTW/Rmail
99ae0fc3371f0f11647921c7dc2bef6d3755c0ca
[ "BSD-4-Clause-UC", "Apache-2.0" ]
null
null
null
src/util/attr_clnt.c
TonyChengTW/Rmail
99ae0fc3371f0f11647921c7dc2bef6d3755c0ca
[ "BSD-4-Clause-UC", "Apache-2.0" ]
null
null
null
src/util/attr_clnt.c
TonyChengTW/Rmail
99ae0fc3371f0f11647921c7dc2bef6d3755c0ca
[ "BSD-4-Clause-UC", "Apache-2.0" ]
null
null
null
/*++ /* NAME /* attr_clnt 3 /* SUMMARY /* attribute query-reply client /* SYNOPSIS /* #include <attr_clnt.h> /* /* typedef int (*ATTR_CLNT_PRINT_FN) (VSTREAM *, int, va_list); /* typedef int (*ATTR_CLNT_SCAN_FN) (VSTREAM *, int, va_list); /* /* ATTR_CLNT *attr_clnt_create(server, timeout, max_idle, max_ttl) /* const char *server; /* int timeout; /* int max_idle; /* int max_ttl; /* /* int attr_clnt_request(client, /* send_flags, send_type, send_name, ..., ATTR_TYPE_END, /* recv_flags, recv_type, recv_name, ..., ATTR_TYPE_END) /* ATTR_CLNT *client; /* int send_flags; /* int send_type; /* const char *send_name; /* int recv_flags; /* int recv_type; /* const char *recv_name; /* /* void attr_clnt_free(client) /* ATTR_CLNT *client; /* /* void attr_clnt_control(client, name, value, ... ATTR_CLNT_CTL_END) /* ATTR_CLNT *client; /* int name; /* DESCRIPTION /* This module implements a client for a simple attribute-based /* protocol. The default protocol is described in attr_scan_plain(3). /* /* attr_clnt_create() creates a client handle. The server /* argument specifies "transport:servername" where transport is /* currently limited to "inet" or "unix", and servername has the /* form "host:port", "private/servicename" or "public/servicename". /* The timeout parameter limits the time for sending or receiving /* a reply, max_idle specifies how long an idle connection is /* kept open, and the max_ttl parameter bounds the time that a /* connection is kept open. /* Specify zero to disable a max_idle or max_ttl limit. /* /* attr_clnt_request() sends the specified request attributes and /* receives a reply. The reply argument specifies a name-value table. /* The other arguments are as described in attr_print_plain(3). The /* result is the number of attributes received or -1 in case of trouble. /* /* attr_clnt_free() destroys a client handle and closes its connection. /* /* attr_clnt_control() allows the user to fine tune the behavior of /* the specified client. The arguments are a list of (name, value) /* terminated with ATTR_CLNT_CTL_END. /* The following lists the names and the types of the corresponding /* value arguments. /* .IP "ATTR_CLNT_CTL_PROTO(ATTR_CLNT_PRINT_FN, ATTR_CLNT_SCAN_FN)" /* Specifies alternatives for the attr_plain_print() and /* attr_plain_scan() functions. /* DIAGNOSTICS /* Warnings: communication failure. /* SEE ALSO /* auto_clnt(3), client endpoint management /* attr_scan_plain(3), attribute protocol /* attr_print_plain(3), attribute protocol /* LICENSE /* .ad /* .fi /* The Secure Mailer license must be distributed with this software. /* AUTHOR(S) /* Wietse Venema /* IBM T.J. Watson Research /* P.O. Box 704 /* Yorktown Heights, NY 10598, USA /*--*/ /* System library. */ #include <sys_defs.h> #include <unistd.h> #include <errno.h> #include <string.h> /* Utility library. */ #include <msg.h> #include <mymalloc.h> #include <split_at.h> #include <vstream.h> #include <connect.h> #include <htable.h> #include <attr.h> #include <auto_clnt.h> #include <attr_clnt.h> /* Application-specific. */ struct ATTR_CLNT { AUTO_CLNT *auto_clnt; int (*connect) (const char *, int, int); char *endpoint; int timeout; ATTR_CLNT_PRINT_FN print; ATTR_CLNT_SCAN_FN scan; }; /* attr_clnt_connect - connect to server */ static VSTREAM *attr_clnt_connect(void *context) { const char *myname = "attr_clnt_connect"; ATTR_CLNT *client = (ATTR_CLNT *) context; VSTREAM *fp; int fd; fd = client->connect(client->endpoint, BLOCKING, client->timeout); if (fd < 0) { msg_warn("connect to %s: %m", client->endpoint); return (0); } else { if (msg_verbose) msg_info("%s: connected to %s", myname, client->endpoint); fp = vstream_fdopen(fd, O_RDWR); vstream_control(fp, VSTREAM_CTL_PATH, client->endpoint, VSTREAM_CTL_TIMEOUT, client->timeout, VSTREAM_CTL_END); return (fp); } } /* attr_clnt_free - destroy attribute client */ void attr_clnt_free(ATTR_CLNT *client) { myfree(client->endpoint); auto_clnt_free(client->auto_clnt); myfree((char *) client); } /* attr_clnt_create - create attribute client */ ATTR_CLNT *attr_clnt_create(const char *service, int timeout, int max_idle, int max_ttl) { const char *myname = "attr_clnt_create"; char *transport = mystrdup(service); char *endpoint; ATTR_CLNT *client; if ((endpoint = split_at(transport, ':')) == 0 || *endpoint == 0 || *transport == 0) msg_fatal("need service transport:endpoint instead of \"%s\"", service); if (msg_verbose) msg_info("%s: transport=%s endpoint=%s", myname, transport, endpoint); client = (ATTR_CLNT *) mymalloc(sizeof(*client)); client->scan = attr_vscan_plain; client->print = attr_vprint_plain; client->endpoint = mystrdup(endpoint); client->timeout = timeout; if (strcmp(transport, "inet") == 0) { client->connect = inet_connect; } else if (strcmp(transport, "local") == 0) { client->connect = LOCAL_CONNECT; } else if (strcmp(transport, "unix") == 0) { client->connect = unix_connect; } else { msg_fatal("invalid attribute transport name: %s", service); } client->auto_clnt = auto_clnt_create(max_idle, max_ttl, attr_clnt_connect, (void *) client); myfree(transport); return (client); } /* attr_clnt_request - send query, receive reply */ int attr_clnt_request(ATTR_CLNT *client, int send_flags,...) { const char *myname = "attr_clnt_request"; VSTREAM *stream; int count = 0; va_list ap; int type; int recv_flags; int err; int ret; /* * XXX If the stream is readable before we send anything, then assume the * remote end disconnected. * * XXX For some reason we can't simply call the scan routine after the print * routine, that messes up the argument list. */ #define SKIP_ARG(ap, type) { \ (void) va_arg(ap, char *); \ (void) va_arg(ap, type); \ } for (;;) { errno = 0; if ((stream = auto_clnt_access(client->auto_clnt)) != 0 && readable(vstream_fileno(stream)) == 0) { errno = 0; va_start(ap, send_flags); err = (client->print(stream, send_flags, ap) != 0 || vstream_fflush(stream) != 0); va_end(ap); if (err == 0) { va_start(ap, send_flags); while ((type = va_arg(ap, int)) != ATTR_TYPE_END) { switch (type) { case ATTR_TYPE_STR: SKIP_ARG(ap, char *); break; case ATTR_TYPE_NUM: SKIP_ARG(ap, int); break; case ATTR_TYPE_LONG: SKIP_ARG(ap, long); break; case ATTR_TYPE_HASH: SKIP_ARG(ap, HTABLE *); break; default: msg_panic("%s: unexpected attribute type %d", myname, type); } } recv_flags = va_arg(ap, int); ret = client->scan(stream, recv_flags, ap); va_end(ap); if (ret > 0) return (ret); } } if (++count >= 2 || msg_verbose || (errno && errno != EPIPE && errno != ENOENT && errno != ECONNRESET)) msg_warn("problem talking to server %s: %m", client->endpoint); if (count >= 2) return (-1); sleep(1); /* XXX make configurable */ auto_clnt_recover(client->auto_clnt); } } /* attr_clnt_control - fine control */ void attr_clnt_control(ATTR_CLNT *client, int name,...) { char *myname = "attr_clnt_control"; va_list ap; for (va_start(ap, name); name != ATTR_CLNT_CTL_END; name = va_arg(ap, int)) { switch (name) { case ATTR_CLNT_CTL_PROTO: client->print = va_arg(ap, ATTR_CLNT_PRINT_FN); client->scan = va_arg(ap, ATTR_CLNT_SCAN_FN); break; default: msg_panic("%s: bad name %d", myname, name); } } }
28.243542
81
0.667102
eacbdf58b263027c942019fe32823673ecd26b96
621
h
C
EterNet/src/EterNet/ClientSession.h
selim1763/EterNet
970116362ba2b68dc8f712320deb629ec315b8fc
[ "Apache-2.0" ]
1
2020-10-28T07:23:26.000Z
2020-10-28T07:23:26.000Z
EterNet/src/EterNet/ClientSession.h
selim1763/EterNet
970116362ba2b68dc8f712320deb629ec315b8fc
[ "Apache-2.0" ]
null
null
null
EterNet/src/EterNet/ClientSession.h
selim1763/EterNet
970116362ba2b68dc8f712320deb629ec315b8fc
[ "Apache-2.0" ]
null
null
null
#pragma once #include "Timer.h" #include <boost\asio.hpp> namespace etn { #define TIMER_INTERVAL 1000 #define TIME_OUT_SEC 5 //---- class ServerHandler; class ClientSession { public: ClientSession(ServerHandler * process_handler, boost::asio::ip::udp::endpoint & endpoint); ~ClientSession(); private: ServerHandler* m_ptr_handler; Timer m_timer_timeout; std::atomic<unsigned char> m_time{ 0 }; private: boost::asio::ip::udp::endpoint m_endpoint; public: void reset_time(); private: void StartTimer(); void DispatchTimer(const boost::system::error_code & error); void HandleTimer(); }; }
20.032258
92
0.719807
23bc3bf5c4c0c6c2e7d2afb487007ab273e4b04b
7,739
c
C
drivers/phy/marvell/phy-mvebu-a3700-utmi.c
CPU-Code/-Linux_kernel
44dc3358bc640197528f5b10dbed0fd3717af65b
[ "AFL-3.0" ]
2
2020-09-18T07:01:49.000Z
2022-01-27T08:59:04.000Z
drivers/phy/marvell/phy-mvebu-a3700-utmi.c
CPU-Code/-Linux_kernel
44dc3358bc640197528f5b10dbed0fd3717af65b
[ "AFL-3.0" ]
null
null
null
drivers/phy/marvell/phy-mvebu-a3700-utmi.c
CPU-Code/-Linux_kernel
44dc3358bc640197528f5b10dbed0fd3717af65b
[ "AFL-3.0" ]
4
2020-06-29T04:09:48.000Z
2022-01-27T08:59:01.000Z
// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2018 Marvell * * Authors: * Igal Liberman <igall@marvell.com> * Miquèl Raynal <miquel.raynal@bootlin.com> * * Marvell A3700 UTMI PHY driver */ #include <linux/io.h> #include <linux/iopoll.h> #include <linux/mfd/syscon.h> #include <linux/module.h> #include <linux/of_device.h> #include <linux/phy/phy.h> #include <linux/platform_device.h> #include <linux/regmap.h> /* Armada 3700 UTMI PHY registers */ #define USB2_PHY_PLL_CTRL_REG0 0x0 #define PLL_REF_DIV_OFF 0 #define PLL_REF_DIV_MASK GENMASK(6, 0) #define PLL_REF_DIV_5 5 #define PLL_FB_DIV_OFF 16 #define PLL_FB_DIV_MASK GENMASK(24, 16) #define PLL_FB_DIV_96 96 #define PLL_SEL_LPFR_OFF 28 #define PLL_SEL_LPFR_MASK GENMASK(29, 28) #define PLL_READY BIT(31) #define USB2_PHY_CAL_CTRL 0x8 #define PHY_PLLCAL_DONE BIT(31) #define PHY_IMPCAL_DONE BIT(23) #define USB2_RX_CHAN_CTRL1 0x18 #define USB2PHY_SQCAL_DONE BIT(31) #define USB2_PHY_OTG_CTRL 0x34 #define PHY_PU_OTG BIT(4) #define USB2_PHY_CHRGR_DETECT 0x38 #define PHY_CDP_EN BIT(2) #define PHY_DCP_EN BIT(3) #define PHY_PD_EN BIT(4) #define PHY_PU_CHRG_DTC BIT(5) #define PHY_CDP_DM_AUTO BIT(7) #define PHY_ENSWITCH_DP BIT(12) #define PHY_ENSWITCH_DM BIT(13) /* Armada 3700 USB miscellaneous registers */ #define USB2_PHY_CTRL(usb32) (usb32 ? 0x20 : 0x4) #define RB_USB2PHY_PU BIT(0) #define USB2_DP_PULLDN_DEV_MODE BIT(5) #define USB2_DM_PULLDN_DEV_MODE BIT(6) #define RB_USB2PHY_SUSPM(usb32) (usb32 ? BIT(14) : BIT(7)) #define PLL_LOCK_DELAY_US 10000 #define PLL_LOCK_TIMEOUT_US 1000000 /** * struct mvebu_a3700_utmi_caps - PHY capabilities * * @usb32: Flag indicating which PHY is in use (impacts the register map): * - The UTMI PHY wired to the USB3/USB2 controller (otg) * - The UTMI PHY wired to the USB2 controller (host only) * @ops: PHY operations */ struct mvebu_a3700_utmi_caps { int usb32; const struct phy_ops *ops; }; /** * struct mvebu_a3700_utmi - PHY driver data * * @regs: PHY registers * @usb_mis: Regmap with USB miscellaneous registers including PHY ones * @caps: PHY capabilities * @phy: PHY handle */ struct mvebu_a3700_utmi { void __iomem *regs; struct regmap *usb_misc; const struct mvebu_a3700_utmi_caps *caps; struct phy *phy; }; static int mvebu_a3700_utmi_phy_power_on(struct phy *phy) { struct mvebu_a3700_utmi *utmi = phy_get_drvdata(phy); struct device *dev = &phy->dev; int usb32 = utmi->caps->usb32; int ret = 0; u32 reg; /* * Setup PLL. 40MHz clock used to be the default, being 25MHz now. * See "PLL Settings for Typical REFCLK" table. */ reg = readl(utmi->regs + USB2_PHY_PLL_CTRL_REG0); reg &= ~(PLL_REF_DIV_MASK | PLL_FB_DIV_MASK | PLL_SEL_LPFR_MASK); reg |= (PLL_REF_DIV_5 << PLL_REF_DIV_OFF) | (PLL_FB_DIV_96 << PLL_FB_DIV_OFF); writel(reg, utmi->regs + USB2_PHY_PLL_CTRL_REG0); /* Enable PHY pull up and disable USB2 suspend */ regmap_update_bits(utmi->usb_misc, USB2_PHY_CTRL(usb32), RB_USB2PHY_SUSPM(usb32) | RB_USB2PHY_PU, RB_USB2PHY_SUSPM(usb32) | RB_USB2PHY_PU); if (usb32) { /* Power up OTG module */ reg = readl(utmi->regs + USB2_PHY_OTG_CTRL); reg |= PHY_PU_OTG; writel(reg, utmi->regs + USB2_PHY_OTG_CTRL); /* Disable PHY charger detection */ reg = readl(utmi->regs + USB2_PHY_CHRGR_DETECT); reg &= ~(PHY_CDP_EN | PHY_DCP_EN | PHY_PD_EN | PHY_PU_CHRG_DTC | PHY_CDP_DM_AUTO | PHY_ENSWITCH_DP | PHY_ENSWITCH_DM); writel(reg, utmi->regs + USB2_PHY_CHRGR_DETECT); /* Disable PHY DP/DM pull-down (used for device mode) */ regmap_update_bits(utmi->usb_misc, USB2_PHY_CTRL(usb32), USB2_DP_PULLDN_DEV_MODE | USB2_DM_PULLDN_DEV_MODE, 0); } /* Wait for PLL calibration */ ret = readl_poll_timeout(utmi->regs + USB2_PHY_CAL_CTRL, reg, reg & PHY_PLLCAL_DONE, PLL_LOCK_DELAY_US, PLL_LOCK_TIMEOUT_US); if (ret) { dev_err(dev, "Failed to end USB2 PLL calibration\n"); return ret; } /* Wait for impedance calibration */ ret = readl_poll_timeout(utmi->regs + USB2_PHY_CAL_CTRL, reg, reg & PHY_IMPCAL_DONE, PLL_LOCK_DELAY_US, PLL_LOCK_TIMEOUT_US); if (ret) { dev_err(dev, "Failed to end USB2 impedance calibration\n"); return ret; } /* Wait for squelch calibration */ ret = readl_poll_timeout(utmi->regs + USB2_RX_CHAN_CTRL1, reg, reg & USB2PHY_SQCAL_DONE, PLL_LOCK_DELAY_US, PLL_LOCK_TIMEOUT_US); if (ret) { dev_err(dev, "Failed to end USB2 unknown calibration\n"); return ret; } /* Wait for PLL to be locked */ ret = readl_poll_timeout(utmi->regs + USB2_PHY_PLL_CTRL_REG0, reg, reg & PLL_READY, PLL_LOCK_DELAY_US, PLL_LOCK_TIMEOUT_US); if (ret) dev_err(dev, "Failed to lock USB2 PLL\n"); return ret; } static int mvebu_a3700_utmi_phy_power_off(struct phy *phy) { struct mvebu_a3700_utmi *utmi = phy_get_drvdata(phy); int usb32 = utmi->caps->usb32; u32 reg; /* Disable PHY pull-up and enable USB2 suspend */ reg = readl(utmi->regs + USB2_PHY_CTRL(usb32)); reg &= ~(RB_USB2PHY_PU | RB_USB2PHY_SUSPM(usb32)); writel(reg, utmi->regs + USB2_PHY_CTRL(usb32)); /* Power down OTG module */ if (usb32) { reg = readl(utmi->regs + USB2_PHY_OTG_CTRL); reg &= ~PHY_PU_OTG; writel(reg, utmi->regs + USB2_PHY_OTG_CTRL); } return 0; } static const struct phy_ops mvebu_a3700_utmi_phy_ops = { .power_on = mvebu_a3700_utmi_phy_power_on, .power_off = mvebu_a3700_utmi_phy_power_off, .owner = THIS_MODULE, }; static const struct mvebu_a3700_utmi_caps mvebu_a3700_utmi_otg_phy_caps = { .usb32 = true, .ops = &mvebu_a3700_utmi_phy_ops, }; static const struct mvebu_a3700_utmi_caps mvebu_a3700_utmi_host_phy_caps = { .usb32 = false, .ops = &mvebu_a3700_utmi_phy_ops, }; static const struct of_device_id mvebu_a3700_utmi_of_match[] = { { .compatible = "marvell,a3700-utmi-otg-phy", .data = &mvebu_a3700_utmi_otg_phy_caps, }, { .compatible = "marvell,a3700-utmi-host-phy", .data = &mvebu_a3700_utmi_host_phy_caps, }, {}, }; MODULE_DEVICE_TABLE(of, mvebu_a3700_utmi_of_match); static int mvebu_a3700_utmi_phy_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct mvebu_a3700_utmi *utmi; struct phy_provider *provider; utmi = devm_kzalloc(dev, sizeof(*utmi), GFP_KERNEL); if (!utmi) return -ENOMEM; /* Get UTMI memory region */ utmi->regs = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(utmi->regs)) return PTR_ERR(utmi->regs); /* Get miscellaneous Host/PHY region */ utmi->usb_misc = syscon_regmap_lookup_by_phandle(dev->of_node, "marvell,usb-misc-reg"); if (IS_ERR(utmi->usb_misc)) { dev_err(dev, "Missing USB misc purpose system controller\n"); return PTR_ERR(utmi->usb_misc); } /* Retrieve PHY capabilities */ utmi->caps = of_device_get_match_data(dev); /* Instantiate the PHY */ utmi->phy = devm_phy_create(dev, NULL, utmi->caps->ops); if (IS_ERR(utmi->phy)) { dev_err(dev, "Failed to create the UTMI PHY\n"); return PTR_ERR(utmi->phy); } phy_set_drvdata(utmi->phy, utmi); /* Ensure the PHY is powered off */ utmi->caps->ops->power_off(utmi->phy); provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); return PTR_ERR_OR_ZERO(provider); } static struct platform_driver mvebu_a3700_utmi_driver = { .probe = mvebu_a3700_utmi_phy_probe, .driver = { .name = "mvebu-a3700-utmi-phy", .of_match_table = mvebu_a3700_utmi_of_match, }, }; module_platform_driver(mvebu_a3700_utmi_driver); MODULE_AUTHOR("Igal Liberman <igall@marvell.com>"); MODULE_AUTHOR("Miquel Raynal <miquel.raynal@bootlin.com>"); MODULE_DESCRIPTION("Marvell EBU A3700 UTMI PHY driver"); MODULE_LICENSE("GPL v2");
28.557196
76
0.720377
268bfcf0185d76ac106291ae8bb28fa63df69859
1,079
h
C
TemplateGlExt/GlMainWindow.h
Chrisso/gl-studies
916cd4851df09d1c959afe8cb4ec0985f881fb7e
[ "Naumen", "Condor-1.1", "MS-PL" ]
1
2020-03-24T01:43:15.000Z
2020-03-24T01:43:15.000Z
TemplateGlExt/GlMainWindow.h
Chrisso/gl-studies
916cd4851df09d1c959afe8cb4ec0985f881fb7e
[ "Naumen", "Condor-1.1", "MS-PL" ]
null
null
null
TemplateGlExt/GlMainWindow.h
Chrisso/gl-studies
916cd4851df09d1c959afe8cb4ec0985f881fb7e
[ "Naumen", "Condor-1.1", "MS-PL" ]
null
null
null
#pragma once #include <atlctrlw.h> #include <atlctrlx.h> #include <FrameCounter.h> #include "Resource.h" #include "GlView.h" #define WM_APP_BENCHMARK (WM_APP+10) class CGlMainWindow : public CFrameWindowImpl<CGlMainWindow> { private: CGlFrameCounter m_FrameCounter; CCommandBarCtrl m_CmdBar; CMultiPaneStatusBarCtrl m_StatusBar; CGlView m_View; public: CGlMainWindow(); ~CGlMainWindow(); bool InitGlew(); void Render(); int OnCreate(CREATESTRUCT *lpcs); void OnClose(); void OnDestroy(); void OnFileExit(UINT uNotifyCode, int nID, HWND hWnd); void OnHelpInfo(UINT uNotifyCode, int nID, HWND hWnd); LRESULT OnBenchmark(UINT uMsg, WPARAM wParam, LPARAM lParam); DECLARE_FRAME_WND_CLASS(_T("CS_TEMPLATEGL"), IDR_MAINFRAME); BEGIN_MSG_MAP_EX(CGlMainWindow) MSG_WM_CREATE(OnCreate) MSG_WM_CLOSE(OnClose) MSG_WM_DESTROY(OnDestroy) COMMAND_ID_HANDLER_EX(ID_APP_EXIT, OnFileExit) COMMAND_ID_HANDLER_EX(ID_APP_ABOUT, OnHelpInfo) MESSAGE_HANDLER_EX(WM_APP_BENCHMARK, OnBenchmark) CHAIN_MSG_MAP(CFrameWindowImpl<CGlMainWindow>) END_MSG_MAP() };
21.156863
62
0.785913
1b390c85343699968dc39ad6e715d9307da6f749
270
h
C
MIARuntime-Example/MIARuntime-Example/Person.h
tianjackyang/MIARuntime-Example
0cb9a483d7044712b0fc662ea790706d38d3652b
[ "MIT" ]
null
null
null
MIARuntime-Example/MIARuntime-Example/Person.h
tianjackyang/MIARuntime-Example
0cb9a483d7044712b0fc662ea790706d38d3652b
[ "MIT" ]
null
null
null
MIARuntime-Example/MIARuntime-Example/Person.h
tianjackyang/MIARuntime-Example
0cb9a483d7044712b0fc662ea790706d38d3652b
[ "MIT" ]
null
null
null
// // Person.h // MIARuntime-Example // // Created by 杨鹏 on 16/4/28. // Copyright © 2016年 杨鹏. All rights reserved. // #import <Foundation/Foundation.h> @interface Person : NSObject //声名getter和setter方法 @property (assign, nonatomic) NSInteger age; -(void)run; @end
15.882353
46
0.692593
bb139202f31099fb7958b3a62449af6f26f81fcc
5,643
c
C
functions.c
DirkHoldeman/circuit_development
73fd213e85e90efb2440b9ebdb2c3a148b143ab4
[ "Unlicense" ]
null
null
null
functions.c
DirkHoldeman/circuit_development
73fd213e85e90efb2440b9ebdb2c3a148b143ab4
[ "Unlicense" ]
null
null
null
functions.c
DirkHoldeman/circuit_development
73fd213e85e90efb2440b9ebdb2c3a148b143ab4
[ "Unlicense" ]
null
null
null
#include <teensy/common.h> #include "cores.h" uint16_t time_to_seconds(uint8_t hour_digit, uint8_t minute_digit_one, uint8_t minute_digit_two) { uint16_t minute_total = minute_digit_one * 10 + minute_digit_two; minute_total += hour_digit * 60; return minute_total * 60; } void wait_ms(uint16_t ms) { for(volatile uint32_t wait_num = (ms * 6600); wait_num; wait_num--); } void wait_us(uint16_t us) { for(volatile uint16_t wait_num = (us * 7); wait_num; wait_num--); } void lcd_init(void) { wait_ms(15); lcd_command(0x30); //function set wait_ms(5); lcd_command(0x30); //function set wait_us(100); lcd_command(0x30); //function set lcd_command(0x30); //final function set lcd_command(0x08); //turn off display lcd_command(0x01); //clear display lcd_command(0x06); //entry mode set lcd_command(0x0c); //turn on display } void lcd_check(void) { wait_ms(5); GPIOC_PCOR = (0xFF); GPIOC_PDDR = (0x00); GPIOD_PSOR = (1<<5); GPIOD_PCOR = (1<<4); GPIOC_PDDR = (0xFF); GPIOD_PCOR = (1<<5); } void lcd_command(char command) { lcd_check(); GPIOC_PSOR = (command); GPIOD_PSOR = (1<<6); wait_us(1); GPIOD_PCOR = (1<<6); } void display_char(char character) { lcd_check(); GPIOD_PSOR = (1<<4); GPIOC_PSOR = (character); GPIOD_PSOR = (1<<6); wait_us(1); GPIOD_PCOR = (1<<6); } void display_string(char *string) { while(*string > 0) { display_char(*string++); } } void adc_init() { ADC0_CFG1 = (ADC_CFG1_ADIV(0x00) | ADC_CFG1_ADICLK(0x01)) + ADC_CFG1_MODE(0x02); ADC0_SC3 = ADC_SC3_CAL_MASK; volatile uint32_t filler; while(ADC0_SC3 & ADC_SC3_CAL_MASK) { filler++; } uint16_t cal_sum = ADC0_CLPS + ADC0_CLP4 + ADC0_CLP3 + ADC0_CLP2 + ADC0_CLP1 + ADC0_CLP0; cal_sum = (cal_sum / 2) | 0x8000; ADC0_PG = cal_sum; cal_sum = ADC0_CLMS + ADC0_CLM4 + ADC0_CLM3 + ADC0_CLM2 + ADC0_CLM1 + ADC0_CLM0; cal_sum = (cal_sum / 2) | 0x8000; ADC0_MG = cal_sum; } uint16_t adc_convert() { ADC0_SC1A = ADC_SC1_ADCH(0x08); while(1) { if(ADC0_SC1A & ADC_SC1_COCO_MASK) { uint16_t adc_result = (ADC0_RA & ADC_R_D(0x08)); return adc_result; } } } uint8_t number_of_digits(uint16_t num) { uint8_t digit_count = 0; while(num > 0) { digit_count++; num /= 10; } return digit_count; } char *int_to_string(uint16_t num) { uint8_t digit_count = number_of_digits(num); char string[digit_count]; string[digit_count] = 0; while(num != 0) { string[digit_count - 1] = num % 10 + '0'; num = num / 10; digit_count--; } return string; } uint32_t voltage_to_ohms(uint16_t volts) { return (14000000 / ((volts * 1000) / 3000) - 14000); } uint8_t digital_read(uint8_t port, uint8_t pin) { uint32_t result; switch(port) { case 0: result = GPIOA_PDIR & (1<<pin); break; case 1: result = GPIOB_PDIR & (1<<pin); break; case 2: result = GPIOC_PDIR & (1<<pin); break; case 3: result = GPIOD_PDIR & (1<<pin); break; case 4: result = GPIOE_PDIR & (1<<pin); break; default: break; } return result; } uint8_t debounce_read(uint8_t port, uint8_t pin) { uint16_t switch_release_confidence = 0; uint16_t switch_press_confidence = 0; uint16_t switch_pressed = 0; while(1) { if(digital_read(port, pin)) { switch_release_confidence++; switch_press_confidence = 0; if(switch_release_confidence > 500) { if(switch_pressed == 1) { return 1; } else { return 0; } } } else { switch_press_confidence++; switch_release_confidence = 0; if(switch_press_confidence > 500) { switch_pressed = 1; } } } } void alarm_setup(void) { SIM_SCGC6 |= SIM_SCGC6_RTC_MASK; RTC_CR = RTC_CR_SWR_MASK; RTC_CR &= ~RTC_CR_SWR_MASK; if(RTC_SR & RTC_SR_TIF_MASK) { RTC_TSR = 0x00; } uint8_t digit_switch = 0; uint8_t twilight_hour = 0; uint8_t twilight_minute_one = 0; uint8_t twilight_minute_two = 0; uint8_t startup_hour = 0; uint8_t startup_minute_one = 0; uint8_t startup_minute_two = 0; uint8_t loop_run = 1; while(loop_run) { if(GPIOA_PDIR & (1<<13)) { if(debounce_read(0, 12)) { digit_switch++; } if(debounce_read(1, 2)) { if(digit_switch == 0) { twilight_hour++; display_char(twilight_hour + '0'); } else if(digit_switch == 1) { twilight_minute_one++; display_char(twilight_minute_one + '0'); } else if(digit_switch == 2) { twilight_minute_two++; display_char(twilight_minute_two + '0'); } else { digit_switch = 0; } } } else { if(debounce_read(0, 12)) { digit_switch++; } if(debounce_read(1, 2)) { if(digit_switch == 0) { startup_hour++; display_char(startup_hour + '0'); } else if(digit_switch == 1) { startup_minute_one++; display_char(startup_minute_one + '0'); } else if(digit_switch == 2) { startup_minute_two++; display_char(startup_minute_two + '0'); } else { loop_run = 0; } } } if(loop_run == 0) { twilight = time_to_seconds(twilight_hour, twilight_minute_one, twilight_minute_two); startup_time = time_to_seconds(startup_hour, startup_minute_one, startup_minute_two); RTC_TAR = RTC_TAR_TAR(twilight-startup_time); RTC_CR |= RTC_CR_OSCE_MASK; RTC_SR |= RTC_SR_TCE_MASK; } } }
24.012766
98
0.614567
15ad1f463196a7245d779b0d589e6664e337e59e
1,503
h
C
AppDelegate.h
lsmoura/caffeine
ff81cb14a41b1f661a02bdbe186d6b367b711b59
[ "MIT" ]
null
null
null
AppDelegate.h
lsmoura/caffeine
ff81cb14a41b1f661a02bdbe186d6b367b711b59
[ "MIT" ]
null
null
null
AppDelegate.h
lsmoura/caffeine
ff81cb14a41b1f661a02bdbe186d6b367b711b59
[ "MIT" ]
null
null
null
// // AppDelegate.h // Caffeine // // Created by Tomas Franzén on 2006-05-20. // Copyright 2006 Lighthead Software. All rights reserved. // #import <Cocoa/Cocoa.h> #import "LCMenuIconView.h" // Workaround for bug in 64-bit SDK #ifndef __POWER__ enum { OverallAct = 0, /* Delays idle sleep by small amount */ UsrActivity = 1, /* Delays idle sleep and dimming by timeout time */ NetActivity = 2, /* Delays idle sleep and power cycling by small amount */ HDActivity = 3, /* Delays hard drive spindown and idle sleep by small amount */ IdleActivity = 4 /* Delays idle sleep by timeout time */ }; extern OSErr UpdateSystemActivity(UInt8 activity); #endif @interface AppDelegate : NSObject { BOOL isActive; BOOL userSessionIsActive; NSTimer *timer; NSTimer *timeoutTimer; LCMenuIconView *menuView; IBOutlet NSMenu *menu; IBOutlet NSWindow *firstTimeWindow; IBOutlet NSMenuItem *infoMenuItem; IBOutlet NSMenuItem *infoSeparatorItem; } - (IBAction)showAbout:(id)sender; - (IBAction)showPreferences:(id)sender; - (IBAction)activateWithTimeout:(id)sender; - (void)activateWithTimeoutDuration:(NSTimeInterval)interval; - (void)activate; - (void)deactivate; - (BOOL)isActive; - (void)toggleActive:(id)sender; - (void)userSessionDidResignActive:(NSNotification *)note; - (void)userSessionDidBecomeActive:(NSNotification *)note; @end
30.06
104
0.671324
9bbfe9019de41267ce4ad5154fdd88b980bc8491
476
h
C
Spotifiron-TabView/Spotifiron-TabView/Album.h
BronxDupaix/Spotifiron
22bbe7f5b7adaff5c87a462ecdf9170a689523cb
[ "Apache-2.0" ]
2
2016-03-08T23:25:07.000Z
2020-07-20T20:14:54.000Z
Spotifiron-TabView/Spotifiron-TabView/Album.h
BronxDupaix/Spotifiron
22bbe7f5b7adaff5c87a462ecdf9170a689523cb
[ "Apache-2.0" ]
null
null
null
Spotifiron-TabView/Spotifiron-TabView/Album.h
BronxDupaix/Spotifiron
22bbe7f5b7adaff5c87a462ecdf9170a689523cb
[ "Apache-2.0" ]
null
null
null
// // Album.h // Spotifiron-TabView // // Created by Sean Calkins on 3/8/16. // Copyright © 2016 Bronson Dupaix. All rights reserved. // #import <Foundation/Foundation.h> @interface Album : NSObject @property (nonatomic, strong) NSString *name; @property (nonatomic, strong) NSString *idString; @property (nonatomic, strong) NSString *imageUrl; @property (nonatomic, strong) NSMutableArray *tracks; + (Album *)albumWithDictionary:(NSDictionary *)albumDictionary; @end
23.8
63
0.737395
ebaf653313b5c232ab4320279e4fd4b13c9797c1
22,620
c
C
external/esp32_wifi_adapter/esp32_wifi_os_adapter.c
ChinaTizenRT/mytest
5234e5a01735df9f49bdc23a22bfa1ab1be1c1cd
[ "Apache-2.0" ]
null
null
null
external/esp32_wifi_adapter/esp32_wifi_os_adapter.c
ChinaTizenRT/mytest
5234e5a01735df9f49bdc23a22bfa1ab1be1c1cd
[ "Apache-2.0" ]
null
null
null
external/esp32_wifi_adapter/esp32_wifi_os_adapter.c
ChinaTizenRT/mytest
5234e5a01735df9f49bdc23a22bfa1ab1be1c1cd
[ "Apache-2.0" ]
null
null
null
/****************************************************************** * * Copyright 2018 Samsung Electronics 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. * ******************************************************************/ /**************************************************************************** * * Copyright (C) 2014-2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> * * The Samsung sample code has a BSD compatible license that requires this * copyright notice: * * Copyright (c) 2016 Samsung Electronics, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. Neither the name NuttX nor the names of its contributors may be * used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * */ /**************************************************************************** // Copyright 2015-2016 Espressif Systems (Shanghai) PTE 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. ****************************************************************************/ #include <stddef.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <assert.h> #include <semaphore.h> #include <pthread.h> #include <errno.h> #include <sched.h> #include <debug.h> #include <sys/time.h> #include <sys/types.h> #include <fcntl.h> #include <tinyara/wdog.h> #include <tinyara/arch.h> #include <tinyara/cancelpt.h> #include "esp_attr.h" #include "esp_phy_init.h" #include "esp_wifi_os_adapter.h" #include "nvs.h" #include "esp_system.h" #include "rom/ets_sys.h" #include <sched/sched.h> #include <semaphore/semaphore.h> #include "event_groups.h" static irqstate_t wifi_int_disable_flags; /*extern functions declare*/ extern uint32_t IRAM_ATTR esp_random(void); int64_t get_instant_time(void); /*=================seamphore API=================*/ static void *IRAM_ATTR semphr_create_wrapper(uint32_t max, uint32_t init) { if (max > SEM_VALUE_MAX || init > SEM_VALUE_MAX) { return NULL; } sem_t *sem = (sem_t *)malloc(sizeof(*sem)); if (!sem) { return NULL; } int status = sem_init(sem, 0, init); if (status != OK) { return NULL; } return (void *)sem; } static void IRAM_ATTR semphr_delete_wrapper(void *semphr) { if (semphr == NULL) { dbg("semphr is NULL\n"); return; } sem_destroy(semphr); free(semphr); } static int32_t IRAM_ATTR semphr_take_from_isr_wrapper(void *semphr, void *hptw) { *(bool *) hptw = WIFI_ADAPTER_FALSE; FAR struct tcb_s *stcb = NULL; FAR struct tcb_s *rtcb = this_task(); sem_t *sem = (sem_t *) semphr; irqstate_t saved_state; int ret = pdFAIL; saved_state = irqsave(); if (enter_cancellation_point()) { set_errno(ECANCELED); leave_cancellation_point(); irqrestore(saved_state); return ERROR; } /* Make sure we were supplied with a valid semaphore */ if ((sem != NULL) && ((sem->flags & FLAGS_INITIALIZED) != 0)) { if (sem->semcount > 0) { /* It is, let the task take the semaphore. */ sem->semcount--; sem_addholder(sem); rtcb->waitsem = NULL; ret = pdPASS; for (stcb = (FAR struct tcb_s *)g_waitingforsemaphore.head; (stcb && stcb->waitsem != sem); stcb = stcb->flink) ; if (stcb) { if (stcb->sched_priority >= rtcb->sched_priority) { *(bool *) hptw = WIFI_ADAPTER_TRUE; } } } /* The semaphore is NOT available */ else { return ret; } } else { set_errno(EINVAL); } leave_cancellation_point(); irqrestore(saved_state); return ret; } static int32_t IRAM_ATTR semphr_take_wrapper(void *semphr, uint32_t block_time_tick) { int ret; if (semphr == NULL) { dbg("semphr is NULL\n"); return pdFAIL; } if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) { ret = sem_wait(semphr); if (ret == OK) { return pdPASS; } else { return pdFAIL; } } else { clock_t msecs; clock_t secs; clock_t nsecs; struct timespec abstime; (void)clock_gettime(CLOCK_REALTIME, &abstime); msecs = TICK2MSEC(block_time_tick); secs = msecs / MSEC_PER_SEC; nsecs = (msecs - (secs * MSEC_PER_SEC)) * NSEC_PER_MSEC; abstime.tv_sec += secs; abstime.tv_nsec += nsecs; ret = sem_timedwait(semphr, &abstime); if (ret == OK) { return pdPASS; } else { return pdFAIL; } } } static int32_t IRAM_ATTR semphr_give_wrapper(void *semphr) { int ret; if (semphr == NULL) { dbg("semphr is NULL\n"); return EINVAL; } ret = sem_post(semphr); if (ret == OK) { return pdPASS; } else { return pdFAIL; } } static int32_t IRAM_ATTR semphr_give_from_isr_wrapper(void *semphr, void *hptw) { *(int *)hptw = WIFI_ADAPTER_FALSE; return semphr_give_wrapper(semphr); } /*=================mutx API=================*/ static void *IRAM_ATTR recursive_mutex_create_wrapper(void) { pthread_mutexattr_t mattr; int status = 0; pthread_mutex_t *mutex = (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t)); if (mutex == NULL) { return NULL; } pthread_mutexattr_init(&mattr); status = pthread_mutexattr_settype(&mattr, PTHREAD_MUTEX_RECURSIVE); if (status != 0) { dbg("recursive_mutex_test: ERROR pthread_mutexattr_settype failed, status=%d\n", status); return NULL; } status = pthread_mutex_init(mutex, &mattr); if (status) { return NULL; } return (void *)mutex; } static void *IRAM_ATTR mutex_create_wrapper(void) { int status = 0; pthread_mutex_t *mutex = (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t)); if (mutex == NULL) { return NULL; } status = pthread_mutex_init(mutex, NULL); if (status) { return NULL; } return (void *)mutex; } static void IRAM_ATTR mutex_delete_wrapper(void *mutex) { if (mutex == NULL) { dbg("mutex is NULL\n"); return; } pthread_mutex_destroy(mutex); free(mutex); } static int32_t IRAM_ATTR mutex_lock_wrapper(void *mutex) { if (mutex == NULL) { dbg("mutex is NULL\n"); return EINVAL; } int ret = pthread_mutex_lock(mutex); if (ret) { return pdFAIL; } return pdPASS; } static int32_t IRAM_ATTR mutex_unlock_wrapper(void *mutex) { if (mutex == NULL) { dbg("mutex is NULL\n"); return EINVAL; } int ret = pthread_mutex_unlock(mutex); if (ret) { return pdFAIL; } return pdPASS; } /*=================task control API=================*/ static int32_t IRAM_ATTR task_create_wrapper(void *task_func, const char *name, uint32_t stack_depth, void *param, uint32_t prio, void *task_handle) { int pid = task_create(name, prio, stack_depth, task_func, param); if (pid < 0) { return pdFAIL; } task_handle = (void *)pid; return pdPASS; } static int32_t IRAM_ATTR task_create_pinned_to_core_wrapper(void *task_func, const char *name, uint32_t stack_depth, void *param, uint32_t prio, void *task_handle, uint32_t core_id) { #ifndef CONFIG_SMP return task_create_wrapper(task_func, name, stack_depth, param, prio, task_handle); #else /*currently TizenRT not support SMP*/ return pdFAIL; #endif } static void IRAM_ATTR task_delete_wrapper(void *task_handle) { if (task_handle < 0) { return; } int pid = (int)task_handle; task_delete(pid); } static void IRAM_ATTR task_delay_wrapper(uint32_t tick) { uint64_t usecs = TICK2USEC(tick); usleep(usecs); } static int curpid; static void *IRAM_ATTR task_get_current_task_wrapper(void) { curpid = getpid(); return (void *)&curpid; } static inline int32_t IRAM_ATTR task_ms_to_tick_wrapper(uint32_t ms) { return (int32_t) MSEC2TICK(ms); } static inline int32_t IRAM_ATTR task_get_max_priority_wrapper(void) { return (int32_t)(SCHED_PRIORITY_MAX); } static inline int32_t IRAM_ATTR is_in_isr_wrapper(void) { return (int32_t) up_interrupt_context(); } /*=================wifi RF API=================*/ static inline int32_t IRAM_ATTR esp_phy_rf_deinit_wrapper(uint32_t module) { return esp_phy_rf_deinit((phy_rf_module_t) module); } static inline int32_t IRAM_ATTR phy_rf_init_wrapper(const void *init_data, uint32_t mode, void *calibration_data, uint32_t module) { return esp_phy_rf_init(init_data, mode, calibration_data, module); } static inline void IRAM_ATTR esp_phy_load_cal_and_init_wrapper(uint32_t module) { return esp_phy_load_cal_and_init((phy_rf_module_t) module); } static inline int32_t esp_read_mac_wrapper(uint8_t *mac, uint32_t type) { return esp_read_mac(mac, (esp_mac_type_t) type); } /*=================soft timer API=================*/ void ets_timer_init(void) { } void ets_timer_deinit(void) { } static void IRAM_ATTR timer_arm_wrapper(void *timer, uint32_t tmout, bool repeat) { ETSTimer *etimer = (ETSTimer *) timer; if (etimer == NULL || etimer->wdog == NULL) { dbg("timer is NULL\n"); return; } int delay = MSEC2TICK(tmout); wd_start(etimer->wdog, delay, etimer->func, 0, NULL); } static void IRAM_ATTR timer_disarm_wrapper(void *timer) { ETSTimer *etimer = (ETSTimer *) timer; if (etimer == NULL || etimer->wdog == NULL) { dbg("timer is NULL\n"); return; } wd_cancel(etimer->wdog); } static void IRAM_ATTR timer_done_wrapper(void *ptimer) { ETSTimer *etimer = (ETSTimer *) ptimer; if (etimer == NULL || etimer->wdog == NULL) { dbg("timer is NULL\n"); return; } etimer->func = NULL; wd_delete(etimer->wdog); } static void IRAM_ATTR timer_setfn_wrapper(void *ptimer, void *pfunction, void *parg) { ETSTimer *etimer = (ETSTimer *) ptimer; if (etimer == NULL) { dbg("timer is NULL\n"); return; } etimer->wdog = wd_create(); if (!etimer->wdog) { return; } etimer->func = (wdentry_t)pfunction; } static void IRAM_ATTR timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repeat) { ETSTimer *etimer = (ETSTimer *) ptimer; if (etimer == NULL) { dbg("timer is NULL\n"); return; } int delay = USEC2TICK(us); wd_start(etimer->wdog, delay, etimer->func, 0, NULL); } static inline int32_t IRAM_ATTR get_time_wrapper(void *t) { return (int32_t) gettimeofday((struct timeval *)t, NULL); } /*=================Miscellaneous API================================*/ static inline int32_t IRAM_ATTR esp_os_get_random_wrapper(uint8_t *buf, size_t len) { return (int32_t) os_get_random((unsigned char *)buf, len); } typedef enum { ESP_LOG_NONE, /*!< No log output */ ESP_LOG_ERROR, /*!< Critical errors, software module can not recover on its own */ ESP_LOG_WARN, /*!< Error conditions from which recovery measures have been taken */ ESP_LOG_INFO, /*!< Information messages which describe normal flow of events */ ESP_LOG_DEBUG, /*!< Extra information which is not necessary for normal use (values, pointers, sizes, etc). */ ESP_LOG_VERBOSE /*!< Bigger chunks of debugging information, or frequent messages which can potentially flood the output. */ } esp_log_level_t; static void IRAM_ATTR log_write_wrapper(uint32_t level, const char *tag, const char *format, ...) { switch (level) { case ESP_LOG_ERROR: case ESP_LOG_DEBUG: dbg(format); break; case ESP_LOG_WARN: wdbg(format); break; case ESP_LOG_INFO: case ESP_LOG_VERBOSE: vdbg(format); break; case ESP_LOG_NONE: return; } } /*=================espwifi modem API=========================*/ static inline esp_err_t esp_modem_sleep_enter_wrapper(uint32_t module) { return esp_modem_sleep_enter((modem_sleep_module_t) module); } static inline esp_err_t esp_modem_sleep_exit_wrapper(uint32_t module) { return esp_modem_sleep_exit((modem_sleep_module_t) module); } static inline esp_err_t esp_modem_sleep_register_wrapper(uint32_t module) { return esp_modem_sleep_register((modem_sleep_module_t) module); } static inline esp_err_t esp_modem_sleep_deregister_wrapper(uint32_t module) { return esp_modem_sleep_deregister((modem_sleep_module_t) module); } /*=================espwifi NVS API=========================*/ static inline int32_t esp_nvs_open_wrapper(const char *name, uint32_t open_mode, uint32_t *out_handle) { return nvs_open(name, (nvs_open_mode) open_mode, (nvs_handle *) out_handle); } /*=================espwifi smart config API=========================*/ /* Will complete next stage, not block WIFI ENABLE*/ void IRAM_ATTR esp_dport_access_stall_other_cpu_start_wrap(void) { //useless for signle CPU return; } void IRAM_ATTR esp_dport_access_stall_other_cpu_end_wrap(void) { //useless for signle CPU return; } static void IRAM_ATTR set_isr_wrapper(int32_t n, void *f, void *arg) { irq_attach(n, f, arg); extern void up_enable_irq(int cpuint); up_enable_irq(n); } static void *IRAM_ATTR spin_lock_create_wrapper(void) { pthread_mutex_t *mux = (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t)); if (mux) { pthread_mutex_init(mux, NULL); return mux; } return NULL; } static irqstate_t wifi_int_disable_flags; static uint32_t IRAM_ATTR wifi_int_disable_wrapper(void *wifi_int_mux) { if (wifi_int_mux) { wifi_int_disable_flags = irqsave(); pthread_mutex_lock((pthread_mutex_t *) wifi_int_mux); } return 0; } static void IRAM_ATTR wifi_int_restore_wrapper(void *wifi_int_mux, uint32_t tmp) { //tmp is useless. if (wifi_int_mux) { pthread_mutex_unlock((pthread_mutex_t *) wifi_int_mux); irqrestore(wifi_int_disable_flags); } return; } static void IRAM_ATTR task_yield_from_isr_wrapper(void) { return; } static uint32_t IRAM_ATTR event_group_wait_bits_wrapper(void *event, uint32_t bits_to_wait_for, int32_t clear_on_exit, int32_t wait_for_all_bits, uint32_t block_time_tick) { if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) { return (uint32_t) event_group_wait_bits(event, bits_to_wait_for, clear_on_exit, wait_for_all_bits, port_max_delay); } return (uint32_t) event_group_wait_bits(event, bits_to_wait_for, clear_on_exit, wait_for_all_bits, block_time_tick); } uint32_t IRAM_ATTR esp_get_free_heap_size(void) { struct mallinfo mem_info; #ifdef CONFIG_CAN_PASS_STRUCTS mem_info = mallinfo(); #else (void)mallinfo(&mem_info); #endif return mem_info.fordblks; } static void *IRAM_ATTR malloc_internal_wrapper(size_t size) { return malloc(size); } static void *IRAM_ATTR realloc_internal_wrapper(void *ptr, size_t size) { return realloc(ptr, size); } static void *IRAM_ATTR calloc_internal_wrapper(size_t n, size_t size) { return calloc(n, size); } static void *IRAM_ATTR zalloc_internal_wrapper(size_t size) { return zalloc(size); } /* If CONFIG_WIFI_LWIP_ALLOCATION_FROM_SPIRAM_FIRST is enabled. Prefer to allocate a chunk of memory in SPIRAM firstly. If failed, try to allocate it in internal memory then. */ void *IRAM_ATTR wifi_malloc(size_t size) { return malloc(size); } /* If CONFIG_WIFI_LWIP_ALLOCATION_FROM_SPIRAM_FIRST is enabled. Prefer to allocate a chunk of memory in SPIRAM firstly. If failed, try to allocate it in internal memory then. */ void *IRAM_ATTR wifi_realloc(void *ptr, size_t size) { return realloc(ptr, size); } /* If CONFIG_WIFI_LWIP_ALLOCATION_FROM_SPIRAM_FIRST is enabled. Prefer to allocate a chunk of memory in SPIRAM firstly. If failed, try to allocate it in internal memory then. */ void *IRAM_ATTR wifi_calloc(size_t n, size_t size) { return calloc(n, size); } static void *IRAM_ATTR wifi_zalloc_wrapper(size_t size) { return zalloc(size); } wifi_static_queue_t *IRAM_ATTR wifi_create_queue(int queue_len, int item_size) { wifi_static_queue_t *wifi_queue = (wifi_static_queue_t *)malloc(sizeof(wifi_static_queue_t)); if (!wifi_queue) { return NULL; } wifi_queue->handle = queue_create_wrapper(queue_len, item_size); return wifi_queue; } void IRAM_ATTR wifi_delete_queue(wifi_static_queue_t *queue) { if (queue && queue->handle) { queue_delete_wrapper(queue->handle); } free(queue); } static void *IRAM_ATTR wifi_create_queue_wrapper(int32_t queue_len, int32_t item_size) { return wifi_create_queue(queue_len, item_size); } static void IRAM_ATTR wifi_delete_queue_wrapper(void *queue) { wifi_delete_queue(queue); } void IRAM_ATTR task_yield_wrapper(void) { extern int sched_yield(void); sched_yield(); } int32_t IRAM_ATTR get_random_wrapper(uint8_t *buf, size_t len) { extern int os_get_random(unsigned char * buf, size_t len); return (int32_t) os_get_random(buf, len); } extern void xtensa_enable_cpuint(uint32_t mask); extern void xtensa_disable_cpuint(uint32_t mask); extern int os_get_random(unsigned char *buf, size_t len); extern unsigned long os_random(void); /*=================espwifi os adapter interface =====================*/ wifi_osi_funcs_t g_wifi_osi_funcs = { ._version = ESP_WIFI_OS_ADAPTER_VERSION, ._set_isr = set_isr_wrapper, ._ints_on = xtensa_enable_cpuint, ._ints_off = xtensa_disable_cpuint, ._spin_lock_create = spin_lock_create_wrapper, ._spin_lock_delete = free, ._wifi_int_disable = wifi_int_disable_wrapper, ._wifi_int_restore = wifi_int_restore_wrapper, ._task_yield = task_yield_wrapper, ._task_yield_from_isr = task_yield_from_isr_wrapper, ._semphr_create = semphr_create_wrapper, ._semphr_delete = semphr_delete_wrapper, ._semphr_take_from_isr = semphr_take_from_isr_wrapper, ._semphr_give_from_isr = semphr_give_from_isr_wrapper, ._semphr_take = semphr_take_wrapper, ._semphr_give = semphr_give_wrapper, ._mutex_create = mutex_create_wrapper, ._recursive_mutex_create = recursive_mutex_create_wrapper, ._mutex_delete = mutex_delete_wrapper, ._mutex_lock = mutex_lock_wrapper, ._mutex_unlock = mutex_unlock_wrapper, ._queue_create = queue_create_wrapper, ._queue_delete = queue_delete_wrapper, ._queue_send = queue_send_wrapper, ._queue_send_from_isr = queue_send_from_isr_wrapper, ._queue_send_to_back = queue_send_to_back_wrapper, ._queue_send_to_front = queue_send_to_front_wrapper, ._queue_recv = queue_recv_wrapper, //._queue_recv_from_isr = xQueueReceiveFromISR, ._queue_msg_waiting = queue_msg_waiting_wrapper, ._event_group_create = event_group_create, ._event_group_delete = event_group_delete, ._event_group_set_bits = event_group_set_bits, ._event_group_clear_bits = event_group_clear_bits, ._event_group_wait_bits = event_group_wait_bits_wrapper, ._task_create_pinned_to_core = task_create_pinned_to_core_wrapper, ._task_create = task_create_wrapper, ._task_delete = task_delete_wrapper, ._task_delay = task_delay_wrapper, ._task_ms_to_tick = task_ms_to_tick_wrapper, ._task_get_current_task = task_get_current_task_wrapper, ._task_get_max_priority = task_get_max_priority_wrapper, ._is_in_isr = is_in_isr_wrapper, ._malloc = malloc, ._free = free, ._get_free_heap_size = esp_get_free_heap_size, ._rand = esp_random, ._dport_access_stall_other_cpu_start_wrap = esp_dport_access_stall_other_cpu_start_wrap, ._dport_access_stall_other_cpu_end_wrap = esp_dport_access_stall_other_cpu_end_wrap, //._phy_rf_init = phy_rf_init_wrapper, //._phy_rf_deinit = esp_phy_rf_deinit_wrapper, //._phy_load_cal_and_init = esp_phy_load_cal_and_init_wrapper, ._read_mac = esp_read_mac_wrapper, ._timer_init = ets_timer_init, ._timer_deinit = ets_timer_deinit, ._timer_arm = timer_arm_wrapper, ._timer_disarm = timer_disarm_wrapper, ._timer_done = timer_done_wrapper, ._timer_setfn = timer_setfn_wrapper, ._timer_arm_us = timer_arm_us_wrapper, ._esp_timer_get_time = get_instant_time, // ._nvs_set_i8 = nvs_set_i8, // ._nvs_get_i8 = nvs_get_i8, // ._nvs_set_u8 = nvs_set_u8, // ._nvs_get_u8 = nvs_get_u8, // ._nvs_set_u16 = nvs_set_u16, // ._nvs_get_u16 = nvs_get_u16, // ._nvs_open = esp_nvs_open_wrapper, // ._nvs_close = nvs_close, // ._nvs_commit = nvs_commit, // ._nvs_set_blob = nvs_set_blob, // ._nvs_get_blob = nvs_get_blob, // ._nvs_erase_key = nvs_erase_key, ._get_random = esp_os_get_random_wrapper, ._get_time = get_time_wrapper, ._random = esp_random, ._log_write = log_write_wrapper, ._log_timestamp = esp_log_timestamp, ._malloc_internal = malloc_internal_wrapper, ._realloc_internal = realloc_internal_wrapper, ._calloc_internal = calloc_internal_wrapper, ._zalloc_internal = zalloc_internal_wrapper, ._wifi_malloc = wifi_malloc, ._wifi_realloc = wifi_realloc, ._wifi_calloc = wifi_calloc, ._wifi_zalloc = wifi_zalloc_wrapper, ._wifi_create_queue = wifi_create_queue_wrapper, ._wifi_delete_queue = wifi_delete_queue_wrapper, //._modem_sleep_enter = esp_modem_sleep_enter_wrapper, //._modem_sleep_exit = esp_modem_sleep_exit_wrapper, //._modem_sleep_register = esp_modem_sleep_register_wrapper, //._modem_sleep_deregister = esp_modem_sleep_deregister_wrapper, //._sc_ack_send = sc_ack_send_wrapper, //._sc_ack_send_stop = sc_ack_send_stop, ._magic = ESP_WIFI_OS_ADAPTER_MAGIC, };
27.285887
181
0.728736
9dc547ea8de7d0f2b284705833103e3474c16cca
2,442
h
C
pomi/hw/I2C.h
jpfli/Pomifactory
ee736a97bcbb5f16625aedae492c267e4911378c
[ "MIT" ]
2
2020-06-16T18:14:53.000Z
2020-10-07T10:42:28.000Z
pomi/hw/I2C.h
jpfli/Pomifactory
ee736a97bcbb5f16625aedae492c267e4911378c
[ "MIT" ]
null
null
null
pomi/hw/I2C.h
jpfli/Pomifactory
ee736a97bcbb5f16625aedae492c267e4911378c
[ "MIT" ]
null
null
null
#pragma once namespace Pomi { namespace Hw { class I2C { public: I2C() = delete; I2C(const I2C&) = delete; I2C& operator =(const I2C&) = delete; static inline void write(unsigned char address, unsigned char data) { _start(); _sendFrame(address & ~1); _sendFrame(data); _stop(); } private: static constexpr unsigned int SDA = 4; static constexpr unsigned int SCL = 5; static inline void _wait() { volatile unsigned int delay = 10; while(delay-- > 0); } static inline void _start() { volatile unsigned int* DIR = reinterpret_cast<unsigned int*>(0xa0002000); volatile unsigned char* P0 = reinterpret_cast<unsigned char*>(0xa0000000); P0[SDA] = 1; P0[SCL] = 1; // Set SDA and SCL as outputs DIR[0] |= (1<<SDA) | (1<<SCL); _wait(); P0[SDA] = 0; _wait(); P0[SCL] = 0; } static inline void _stop() { volatile unsigned int* DIR = reinterpret_cast<unsigned int*>(0xa0002000); volatile unsigned char* P0 = reinterpret_cast<unsigned char*>(0xa0000000); P0[SDA] = 0; P0[SCL] = 1; _wait(); P0[SDA] = 1; } static inline bool _sendFrame(unsigned char value) { volatile unsigned int* DIR = reinterpret_cast<unsigned int*>(0xa0002000); volatile unsigned char* P0 = reinterpret_cast<unsigned char*>(0xa0000000); // Send out 8 bits, most significant bit first for(std::uint32_t bit = 8; bit > 0; --bit) { _wait(); P0[SDA] = (value >> (bit - 1)) & 1; P0[SCL] = 1; _wait(); P0[SCL] = 0; } // Set SDA as input and ask for the ACK bit DIR[0] &= ~(1<<SDA); P0[SCL] = 1; _wait(); // Read ACK bit and set SDA as output bool ack = !P0[SDA]; P0[SCL] = 0; DIR[0] |= (1<<SDA); return ack; } }; } // namespace Hw } // namespace Pomi
27.133333
86
0.445946
8d7cd671c8cfc94878c9d9499acced3123d68dc1
314
c
C
test/src/test_besh_initialization.c
Hektelion/besh
dd4103a61130fc8ae8dcbb6d9c3abe5c35970afd
[ "MIT" ]
null
null
null
test/src/test_besh_initialization.c
Hektelion/besh
dd4103a61130fc8ae8dcbb6d9c3abe5c35970afd
[ "MIT" ]
null
null
null
test/src/test_besh_initialization.c
Hektelion/besh
dd4103a61130fc8ae8dcbb6d9c3abe5c35970afd
[ "MIT" ]
null
null
null
#include "../include/test_besh_initialization.h" #include "../../include/besh_initialization.h" #include <CUnit/Basic.h> void test_besh_getenv() { } void test_besh_putenv() { } void test_besh_setenv() { } void test_besh_unsetenv() { } void test_besh_initenvironement() { besh_initenvironement(); }
8.971429
48
0.713376
0265f67f7db62689f288796d13f4ce75636443b4
1,039
h
C
src/modules/wl_screenshot/e_screenshooter_client_protocol.h
riban-bw/moksha
e8270d594b62e2424575901f60a9ceef826ccefe
[ "BSD-2-Clause" ]
152
2015-04-28T19:04:50.000Z
2022-03-16T01:01:46.000Z
src/modules/wl_screenshot/e_screenshooter_client_protocol.h
riban-bw/moksha
e8270d594b62e2424575901f60a9ceef826ccefe
[ "BSD-2-Clause" ]
90
2015-04-29T13:34:31.000Z
2022-02-15T06:56:14.000Z
src/modules/wl_screenshot/e_screenshooter_client_protocol.h
riban-bw/moksha
e8270d594b62e2424575901f60a9ceef826ccefe
[ "BSD-2-Clause" ]
44
2015-05-18T07:25:23.000Z
2022-03-13T08:51:40.000Z
#ifndef E_SCREENSHOOTER_CLIENT_PROTOCOL_H #define E_SCREENSHOOTER_CLIENT_PROTOCOL_H #ifdef __cplusplus extern "C" { #endif #include <stdint.h> #include <stddef.h> #include "wayland-util.h" struct wl_client; struct wl_resource; extern const struct wl_interface screenshooter_interface; #define SCREENSHOOTER_SHOOT 0 static inline void screenshooter_set_user_data(E_Screenshooter *screenshooter, void *user_data) { wl_proxy_set_user_data((struct wl_proxy *) screenshooter, user_data); } static inline void * screenshooter_get_user_data(E_Screenshooter *screenshooter) { return wl_proxy_get_user_data((struct wl_proxy *) screenshooter); } static inline void screenshooter_destroy(E_Screenshooter *screenshooter) { wl_proxy_destroy((struct wl_proxy *) screenshooter); } static inline void screenshooter_shoot(E_Screenshooter *screenshooter, struct wl_output *output, struct wl_buffer *buffer) { wl_proxy_marshal((struct wl_proxy *) screenshooter, SCREENSHOOTER_SHOOT, output, buffer); } #ifdef __cplusplus } #endif #endif
21.204082
103
0.81232
a08be74ba8ba24f4a7879510f56299cd60a597ca
1,140
c
C
ft_lstdelone.c
afillion/libft
c6bad03bf63e7a1b0967ba1d63df03d2be6176af
[ "MIT" ]
null
null
null
ft_lstdelone.c
afillion/libft
c6bad03bf63e7a1b0967ba1d63df03d2be6176af
[ "MIT" ]
null
null
null
ft_lstdelone.c
afillion/libft
c6bad03bf63e7a1b0967ba1d63df03d2be6176af
[ "MIT" ]
null
null
null
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_lstdelone.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: afillion <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2015/11/29 16:11:44 by afillion #+# #+# */ /* Updated: 2015/12/02 16:32:47 by afillion ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" #include <stdlib.h> void ft_lstdelone(t_list **alst, void (*del)(void *, size_t)) { t_list *tmp; if (del == NULL || alst == NULL) return ; tmp = *alst; del(tmp->content, tmp->content_size); free(*alst); *alst = NULL; }
42.222222
80
0.219298
992127f0bc9d158e7d1dd997e6f0a1f533fcd9e7
12,816
h
C
src/tiny_ssd1306.h
nRFMesh/ssd1306-nRF5
b06896279da4ccc8564a917363e910677d6b8274
[ "MIT" ]
1
2020-08-28T11:45:39.000Z
2020-08-28T11:45:39.000Z
src/tiny_ssd1306.h
nRFMesh/ssd1306-nRF5
b06896279da4ccc8564a917363e910677d6b8274
[ "MIT" ]
null
null
null
src/tiny_ssd1306.h
nRFMesh/ssd1306-nRF5
b06896279da4ccc8564a917363e910677d6b8274
[ "MIT" ]
null
null
null
/* MIT License Copyright (c) 2017-2018, Alexey Dynda Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 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. */ /** * @file tiny_ssd1306.h Drawing in memory buffer */ #ifndef _TINY_SSD1306_H_ #define _TINY_SSD1306_H_ #include "ssd1306.h" #include "i2c/ssd1306_i2c.h" #include "i2c/ssd1306_i2c_embedded.h" #include "i2c/ssd1306_i2c_wire.h" #include "spi/ssd1306_spi.h" #include <stdint.h> #include "Print.h" /** Initialization callback for SSD1306 128x64 OLED display */ #define SSD1306_128x64 &ssd1306_128x64_init /** Initialization callback for SSD1306 128x32 OLED display */ #define SSD1306_128x32 &ssd1306_128x32_init /** Initialization callback for SH1106 128x64 OLED display */ #define SH1106_128x64 &sh1106_128x64_init /** * TinySSD1306 represents object to work with LCD display. * Easy to use: * ~~~~~~~~~~~~~~~{.cpp} * TinySSD1306 lcd( SSD1306_128x64 ); * void setup() * { * lcd.beginI2C(); * * lcd.clear(); * lcd.charF6x8(0,0,"Hello"); * } * ~~~~~~~~~~~~~~~ */ class TinySSD1306: public Print { public: /** * Creates object for communicating with LCD display. * @param lcd - initialization callback for LCD * @see SSD1306_128x64 * @see SSD1306_128x32 */ explicit TinySSD1306( InitFunction lcd ) { m_init = lcd; }; /** * Initializes lcd display. * SPI or i2c interface should be initializes prior to calling this method. */ void begin() { m_init(); }; /** * Initializes default custom i2c interface and lcd display. Refer to ssd1306_i2cInitEx() for details. * * @param scl - i2c clock pin. Use -1 if you don't need to change default pin number * @param sda - i2c data pin. Use -1 if you don't need to change default pin number * @param addr - i2c address of lcd display. Use 0 to leave default * * @see ssd1306_i2cInitEx() */ void beginI2C(int8_t scl = -1, int8_t sda = -1, uint8_t addr = 0) { ssd1306_i2cInitEx(scl, sda, addr); m_init(); }; #ifdef SSD1306_I2C_SW_SUPPORTED /** * Initializes i2c Wire library interface and lcd display. Refer to ssd1306_i2cInit_Embedded() for details. * This API is available only if Wire library is supported for selected board. * * @param scl - i2c clock pin. Use -1 if you don't need to change default pin number * @param sda - i2c data pin. Use -1 if you don't need to change default pin number * @param addr - i2c address of lcd display. Use 0 to leave default * * @see ssd1306_i2cInit_Embedded() */ void beginI2CEmbedded(int8_t scl = -1, int8_t sda = -1, uint8_t addr = 0) { ssd1306_i2cInit_Embedded(scl, sda, addr); m_init(); } #endif #ifdef SSD1306_WIRE_SUPPORTED /** * Initializes i2c Wire library interface and lcd display. Refer to beginI2CWire() for details. * This API is available only if embedded i2c is supported for selected board. * * @param scl - i2c clock pin. Use -1 if you don't need to change default pin number * @param sda - i2c data pin. Use -1 if you don't need to change default pin number * @param addr - i2c address of lcd display. Use 0 to leave default * * @see beginI2CWire() */ void beginI2CWire(int8_t scl = -1, int8_t sda = -1, uint8_t addr = 0) { ssd1306_i2cConfigure_Wire(scl, sda); ssd1306_i2cInit_Wire(addr); m_init(); } #endif /** * @brief Initializes default custom spi interface and lcd display. * * Initializes default custom i2c interface and lcd display. * @param csPin - chip enable pin to LCD slave (-1 if not used) * @param dcPin - data/command pin to control LCD dc (required) */ void beginSPI(int8_t csPin = -1, int8_t dcPin = -1) { ssd1306_spiInit(csPin, dcPin); m_init(); }; /** * Turns off display */ void off() { ssd1306_displayOff(); }; /** * Turns on display */ void on() { ssd1306_displayOn(); }; /** * Switches display to inverse mode. * LCD will display 0-pixels as white, and 1-pixels as black. */ void invertMode() { ssd1306_invertMode(); }; /** * Switches display to normal mode. */ void normalMode() { ssd1306_normalMode(); }; /** * Returns display height in pixels */ uint8_t height() { return ssd1306_displayHeight(); }; /** * Returns display width in pixels */ uint8_t width() { return ssd1306_displayWidth(); }; /** * Sets position in terms of display for text output (Print class). * @param x - horizontal position in pixels * @param y - vertical position in blocks (pixels/8) */ void setCursor(uint8_t x, uint8_t y) { m_xpos = x; m_ypos = y; } /** * Fills screen with pattern byte. * @param fill_Data - pattern to fill display with. */ void fill(uint8_t fill_Data) { ssd1306_fillScreen(fill_Data); }; /** * Fills screen with zero-byte */ void clear(); /** * All drawing functions start to work in negative mode. * Old picture on the display remains unchanged. */ void negativeMode() { ssd1306_negativeMode(); }; /** * All drawing functions start to work in positive (default) mode. * Old picture on the display remains unchanged. */ void positiveMode() { ssd1306_positiveMode(); }; /** * Prints text to screen using font 6x8. * @param x - horizontal position in pixels * @param y - vertical position in blocks (pixels/8) * @param ch - NULL-terminated string to print * @param style - font style (EFontStyle), normal by default. * @returns number of chars in string */ uint8_t charF6x8(uint8_t x, uint8_t y, const char ch[], EFontStyle style = STYLE_NORMAL ) { return ssd1306_charF6x8(x, y, ch, style); }; /** * Prints text to screen using double size font 12x16. * @param xpos - horizontal position in pixels * @param y - vertical position in blocks (pixels/8) * @param ch - NULL-terminated string to print * @param style - font style (EFontStyle). * @returns number of chars in string */ uint8_t charF12x16(uint8_t xpos, uint8_t y, const char ch[], EFontStyle style = STYLE_NORMAL) { return ssd1306_charF12x16( xpos, y, ch, style ); }; /** * Prints text to screen using set font. * If real text ends before right boundary, * the remaining part on the display will be erased till right * boundary. * @param left - horizontal position in pixels * @param y - vertical position in blocks (pixels/8) * @param ch - NULL-terminated string to print * @param style - font style (EFontStyle), normal by default. * @param right - right boundary of the text to output * @returns number of chars in string */ uint8_t charF6x8_eol(uint8_t left, uint8_t y, const char ch[], EFontStyle style, uint8_t right) { return ssd1306_charF6x8_eol(left, y, ch, style, right); }; /** * Put single pixel on the LCD. * * @warning Please, take into account that there is no way * to read data from ssd1306, thus since each byte contains * 8 pixels, all other pixels in the same byte will be cleared * on the display. Use TinySSD1306::putPixels() instead. * If you need to have buffered output, please, refer to NanoCanvas. * * @param x - horizontal position in pixels * @param y - vertical position in pixels */ void putPixel(uint8_t x, uint8_t y) { ssd1306_putPixel(x,y); }; /** * Puts eight vertical pixels on the LCD at once. * * ~~~~~~~~~~~~~~~{.cpp} * // Draw 8 vertical pixels, starting at [10,16] position * lcd.putPixels(10,2,0xFF); * // Draw 4 vertical pixels, starting at [32,28] position * lcd.putPixels(32,3,0x0F); * ~~~~~~~~~~~~~~~ * * @param x - horizontal position in pixels * @param y - vertical position in blocks (pixels/8) * @param pixels - bit-pixels to draw on display */ void putPixels(uint8_t x, uint8_t y, uint8_t pixels) { ssd1306_putPixels(x,y,pixels); }; /** * Draws rectangle * @param x1 - left boundary in pixel units * @param y1 - top boundary in pixel units * @param x2 - right boundary in pixel units * @param y2 - bottom boundary int pixel units */ void drawRect(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2) { ssd1306_drawRect(x1, y1, x2, y2); }; /** * Draws horizontal line * @param x1 - left boundary in pixels * @param y1 - position Y in pixels * @param x2 - right boundary in pixels */ void drawHLine(uint8_t x1, uint8_t y1, uint8_t x2) { ssd1306_drawHLine(x1, y1, x2); }; /** * Draws vertical line * @param x1 - position X in pixels * @param y1 - top boundary in pixels * @param y2 - bottom boundary in pixels */ void drawVLine(uint8_t x1, uint8_t y1, uint8_t y2) { ssd1306_drawVLine(x1, y1, y2); }; /** * Draws bitmap, located in SRAM, on the display * Each byte represents 8 vertical pixels. * * ~~~~~~~~~~~~~~~{.c} * // Draw small rectangle 3x8 at position 10,8 * uint8_t buffer[3] = { 0xFF, 0x81, 0xFF }; * lcd.drawBuffer(10, 1, 3, 8, buffer); * ~~~~~~~~~~~~~~~ * * @param x - horizontal position in pixels * @param y - vertical position in blocks (pixels/8) * @param w - width of bitmap in pixels * @param h - height of bitmap in pixels (must be divided by 8) * @param buf - pointer to data, located in SRAM: each byte represents 8 vertical pixels. */ void drawBuffer(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *buf) { ssd1306_drawBuffer(x,y,w,h,buf); }; /** * Draws bitmap, located in Flash, on the display * * @param x - horizontal position in pixels * @param y - vertical position in blocks (pixels/8) * @param w - width of bitmap in pixels * @param h - height of bitmap in pixels (must be divided by 8) * @param buf - pointer to data, located in Flash: each byte represents 8 vertical pixels. */ void drawBitmap(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *buf) { ssd1306_drawBitmap(x,y,w,h,buf); }; /** * Fills block with black pixels * @param x - horizontal position in pixels * @param y - vertical position in blocks (pixels/8) * @param w - width of block in pixels * @param h - height of block in pixels (must be divided by 8) * @note usually this method is used to erase bitmap on the screen. */ void clearBlock(uint8_t x, uint8_t y, uint8_t w, uint8_t h) { ssd1306_clearBlock(x,y,w,h); }; /** * Writes single character to the display * @param ch - character to write */ virtual size_t write(uint8_t ch); private: /** lcd display initialization function */ InitFunction m_init; uint8_t m_xpos = 0; uint8_t m_ypos = 0; }; #endif
30.226415
111
0.606429
165c541ea229d065fd29a0dea49951e92bc01123
13,656
c
C
vendor/kore/src/pgsql.c
No9/kore-buildpack
4fc5956da042faa9e6c9a652a62d94fae01664f1
[ "MIT" ]
null
null
null
vendor/kore/src/pgsql.c
No9/kore-buildpack
4fc5956da042faa9e6c9a652a62d94fae01664f1
[ "MIT" ]
null
null
null
vendor/kore/src/pgsql.c
No9/kore-buildpack
4fc5956da042faa9e6c9a652a62d94fae01664f1
[ "MIT" ]
null
null
null
/* * Copyright (c) 2014-2016 Joris Vink <joris@coders.se> * * 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. */ #include <sys/param.h> #include <sys/queue.h> #include <libpq-fe.h> #include <pg_config.h> #include "kore.h" #include "http.h" #include "pgsql.h" struct pgsql_job { struct http_request *req; struct kore_pgsql *pgsql; TAILQ_ENTRY(pgsql_job) list; }; struct pgsql_wait { struct http_request *req; TAILQ_ENTRY(pgsql_wait) list; }; #define PGSQL_CONN_MAX 2 #define PGSQL_CONN_FREE 0x01 #define PGSQL_LIST_INSERTED 0x0100 static void pgsql_queue_wakeup(void); static void pgsql_set_error(struct kore_pgsql *, const char *); static void pgsql_queue_add(struct http_request *); static void pgsql_conn_release(struct kore_pgsql *); static void pgsql_conn_cleanup(struct pgsql_conn *); static void pgsql_read_result(struct kore_pgsql *); static void pgsql_schedule(struct kore_pgsql *); static struct pgsql_conn *pgsql_conn_create(struct kore_pgsql *, struct pgsql_db *); static struct pgsql_conn *pgsql_conn_next(struct kore_pgsql *, struct pgsql_db *, struct http_request *); static struct kore_pool pgsql_job_pool; static struct kore_pool pgsql_wait_pool; static TAILQ_HEAD(, pgsql_conn) pgsql_conn_free; static TAILQ_HEAD(, pgsql_wait) pgsql_wait_queue; static LIST_HEAD(, pgsql_db) pgsql_db_conn_strings; static u_int16_t pgsql_conn_count; u_int16_t pgsql_conn_max = PGSQL_CONN_MAX; void kore_pgsql_init(void) { pgsql_conn_count = 0; TAILQ_INIT(&pgsql_conn_free); TAILQ_INIT(&pgsql_wait_queue); LIST_INIT(&pgsql_db_conn_strings); kore_pool_init(&pgsql_job_pool, "pgsql_job_pool", sizeof(struct pgsql_job), 100); kore_pool_init(&pgsql_wait_pool, "pgsql_wait_pool", sizeof(struct pgsql_wait), 100); } int kore_pgsql_query_init(struct kore_pgsql *pgsql, struct http_request *req, const char *dbname, int flags) { struct pgsql_db *db; memset(pgsql, 0, sizeof(*pgsql)); pgsql->flags = flags; pgsql->state = KORE_PGSQL_STATE_INIT; if ((req == NULL && (flags & KORE_PGSQL_ASYNC)) || ((flags & KORE_PGSQL_ASYNC) && (flags & KORE_PGSQL_SYNC))) { pgsql_set_error(pgsql, "invalid query init parameters"); return (KORE_RESULT_ERROR); } db = NULL; LIST_FOREACH(db, &pgsql_db_conn_strings, rlist) { if (!strcmp(db->name, dbname)) break; } if (db == NULL) { pgsql_set_error(pgsql, "no database found"); return (KORE_RESULT_ERROR); } if ((pgsql->conn = pgsql_conn_next(pgsql, db, req)) == NULL) return (KORE_RESULT_ERROR); if (pgsql->flags & KORE_PGSQL_ASYNC) { pgsql->conn->job = kore_pool_get(&pgsql_job_pool); pgsql->conn->job->req = req; pgsql->conn->job->pgsql = pgsql; http_request_sleep(req); pgsql->flags |= PGSQL_LIST_INSERTED; LIST_INSERT_HEAD(&(req->pgsqls), pgsql, rlist); } return (KORE_RESULT_OK); } int kore_pgsql_query(struct kore_pgsql *pgsql, const char *query) { if (pgsql->conn == NULL) { pgsql_set_error(pgsql, "no connection was set before query"); return (KORE_RESULT_ERROR); } if (pgsql->flags & KORE_PGSQL_SYNC) { pgsql->result = PQexec(pgsql->conn->db, query); if ((PQresultStatus(pgsql->result) != PGRES_TUPLES_OK) && (PQresultStatus(pgsql->result) != PGRES_COMMAND_OK)) { pgsql_set_error(pgsql, PQerrorMessage(pgsql->conn->db)); return (KORE_RESULT_ERROR); } pgsql->state = KORE_PGSQL_STATE_DONE; } else { if (!PQsendQuery(pgsql->conn->db, query)) { pgsql_set_error(pgsql, PQerrorMessage(pgsql->conn->db)); return (KORE_RESULT_ERROR); } pgsql_schedule(pgsql); } return (KORE_RESULT_OK); } int kore_pgsql_v_query_params(struct kore_pgsql *pgsql, const char *query, int result, int count, va_list args) { u_int8_t i; char **values; int *lengths, *formats, ret; if (pgsql->conn == NULL) { pgsql_set_error(pgsql, "no connection was set before query"); return (KORE_RESULT_ERROR); } if (count > 0) { lengths = kore_calloc(count, sizeof(int)); formats = kore_calloc(count, sizeof(int)); values = kore_calloc(count, sizeof(char *)); for (i = 0; i < count; i++) { values[i] = va_arg(args, void *); lengths[i] = va_arg(args, int); formats[i] = va_arg(args, int); } } else { lengths = NULL; formats = NULL; values = NULL; } ret = KORE_RESULT_ERROR; if (pgsql->flags & KORE_PGSQL_SYNC) { pgsql->result = PQexecParams(pgsql->conn->db, query, count, NULL, (const char * const *)values, lengths, formats, result); if ((PQresultStatus(pgsql->result) != PGRES_TUPLES_OK) && (PQresultStatus(pgsql->result) != PGRES_COMMAND_OK)) { pgsql_set_error(pgsql, PQerrorMessage(pgsql->conn->db)); goto cleanup; } pgsql->state = KORE_PGSQL_STATE_DONE; } else { if (!PQsendQueryParams(pgsql->conn->db, query, count, NULL, (const char * const *)values, lengths, formats, result)) { pgsql_set_error(pgsql, PQerrorMessage(pgsql->conn->db)); goto cleanup; } pgsql_schedule(pgsql); } ret = KORE_RESULT_OK; cleanup: kore_free(values); kore_free(lengths); kore_free(formats); return (ret); } int kore_pgsql_query_params(struct kore_pgsql *pgsql, const char *query, int result, int count, ...) { int ret; va_list args; va_start(args, count); ret = kore_pgsql_v_query_params(pgsql, query, result, count, args); va_end(args); return (ret); } int kore_pgsql_register(const char *dbname, const char *connstring) { struct pgsql_db *pgsqldb; LIST_FOREACH(pgsqldb, &pgsql_db_conn_strings, rlist) { if (!strcmp(pgsqldb->name, dbname)) return (KORE_RESULT_ERROR); } pgsqldb = kore_malloc(sizeof(*pgsqldb)); pgsqldb->name = kore_strdup(dbname); pgsqldb->conn_string = kore_strdup(connstring); LIST_INSERT_HEAD(&pgsql_db_conn_strings, pgsqldb, rlist); return (KORE_RESULT_OK); } void kore_pgsql_handle(void *c, int err) { struct http_request *req; struct kore_pgsql *pgsql; struct pgsql_conn *conn = (struct pgsql_conn *)c; if (err) { pgsql_conn_cleanup(conn); return; } req = conn->job->req; pgsql = conn->job->pgsql; kore_debug("kore_pgsql_handle: %p (%d)", req, pgsql->state); if (!PQconsumeInput(conn->db)) { pgsql->state = KORE_PGSQL_STATE_ERROR; pgsql->error = kore_strdup(PQerrorMessage(conn->db)); } else { pgsql_read_result(pgsql); } if (pgsql->state == KORE_PGSQL_STATE_WAIT) { http_request_sleep(req); } else { http_request_wakeup(req); } } void kore_pgsql_continue(struct http_request *req, struct kore_pgsql *pgsql) { kore_debug("kore_pgsql_continue: %p->%p (%d)", req->owner, req, pgsql->state); if (pgsql->error) { kore_free(pgsql->error); pgsql->error = NULL; } if (pgsql->result) { PQclear(pgsql->result); pgsql->result = NULL; } switch (pgsql->state) { case KORE_PGSQL_STATE_INIT: case KORE_PGSQL_STATE_WAIT: break; case KORE_PGSQL_STATE_DONE: http_request_wakeup(req); pgsql_conn_release(pgsql); break; case KORE_PGSQL_STATE_ERROR: case KORE_PGSQL_STATE_RESULT: kore_pgsql_handle(pgsql->conn, 0); break; default: fatal("unknown pgsql state %d", pgsql->state); } } void kore_pgsql_cleanup(struct kore_pgsql *pgsql) { kore_debug("kore_pgsql_cleanup(%p)", pgsql); if (pgsql->result != NULL) PQclear(pgsql->result); if (pgsql->error != NULL) kore_free(pgsql->error); if (pgsql->conn != NULL) pgsql_conn_release(pgsql); pgsql->result = NULL; pgsql->error = NULL; pgsql->conn = NULL; if (pgsql->flags & PGSQL_LIST_INSERTED) { LIST_REMOVE(pgsql, rlist); pgsql->flags &= ~PGSQL_LIST_INSERTED; } } void kore_pgsql_logerror(struct kore_pgsql *pgsql) { kore_log(LOG_NOTICE, "pgsql error: %s", (pgsql->error) ? pgsql->error : "unknown"); } int kore_pgsql_ntuples(struct kore_pgsql *pgsql) { return (PQntuples(pgsql->result)); } int kore_pgsql_getlength(struct kore_pgsql *pgsql, int row, int col) { return (PQgetlength(pgsql->result, row, col)); } char * kore_pgsql_getvalue(struct kore_pgsql *pgsql, int row, int col) { return (PQgetvalue(pgsql->result, row, col)); } void kore_pgsql_queue_remove(struct http_request *req) { struct pgsql_wait *pgw, *next; for (pgw = TAILQ_FIRST(&pgsql_wait_queue); pgw != NULL; pgw = next) { next = TAILQ_NEXT(pgw, list); if (pgw->req != req) continue; TAILQ_REMOVE(&pgsql_wait_queue, pgw, list); kore_pool_put(&pgsql_wait_pool, pgw); return; } } static struct pgsql_conn * pgsql_conn_next(struct kore_pgsql *pgsql, struct pgsql_db *db, struct http_request *req) { struct pgsql_conn *conn; conn = NULL; TAILQ_FOREACH(conn, &pgsql_conn_free, list) { if (!(conn->flags & PGSQL_CONN_FREE)) fatal("got a pgsql connection that was not free?"); if (!strcmp(conn->name, db->name)) break; } if (conn == NULL) { if (pgsql_conn_count >= pgsql_conn_max) { if (pgsql->flags & KORE_PGSQL_ASYNC) { pgsql_queue_add(req); } else { pgsql_set_error(pgsql, "no available connection"); } return (NULL); } if ((conn = pgsql_conn_create(pgsql, db)) == NULL) return (NULL); } conn->flags &= ~PGSQL_CONN_FREE; TAILQ_REMOVE(&pgsql_conn_free, conn, list); return (conn); } static void pgsql_set_error(struct kore_pgsql *pgsql, const char *msg) { if (pgsql->error != NULL) kore_free(pgsql->error); pgsql->error = kore_strdup(msg); pgsql->state = KORE_PGSQL_STATE_ERROR; } static void pgsql_schedule(struct kore_pgsql *pgsql) { int fd; fd = PQsocket(pgsql->conn->db); if (fd < 0) fatal("PQsocket returned < 0 fd on open connection"); kore_platform_schedule_read(fd, pgsql->conn); pgsql->state = KORE_PGSQL_STATE_WAIT; } static void pgsql_queue_add(struct http_request *req) { struct pgsql_wait *pgw; http_request_sleep(req); pgw = kore_pool_get(&pgsql_wait_pool); pgw->req = req; pgw->req->flags |= HTTP_REQUEST_PGSQL_QUEUE; TAILQ_INSERT_TAIL(&pgsql_wait_queue, pgw, list); } static void pgsql_queue_wakeup(void) { struct pgsql_wait *pgw, *next; for (pgw = TAILQ_FIRST(&pgsql_wait_queue); pgw != NULL; pgw = next) { next = TAILQ_NEXT(pgw, list); if (pgw->req->flags & HTTP_REQUEST_DELETE) continue; http_request_wakeup(pgw->req); pgw->req->flags &= ~HTTP_REQUEST_PGSQL_QUEUE; TAILQ_REMOVE(&pgsql_wait_queue, pgw, list); kore_pool_put(&pgsql_wait_pool, pgw); return; } } static struct pgsql_conn * pgsql_conn_create(struct kore_pgsql *pgsql, struct pgsql_db *db) { struct pgsql_conn *conn; if (db == NULL || db->conn_string == NULL) fatal("pgsql_conn_create: no connection string"); pgsql_conn_count++; conn = kore_malloc(sizeof(*conn)); kore_debug("pgsql_conn_create(): %p", conn); conn->db = PQconnectdb(db->conn_string); if (conn->db == NULL || (PQstatus(conn->db) != CONNECTION_OK)) { pgsql_set_error(pgsql, PQerrorMessage(conn->db)); pgsql_conn_cleanup(conn); return (NULL); } conn->job = NULL; conn->flags = PGSQL_CONN_FREE; conn->type = KORE_TYPE_PGSQL_CONN; conn->name = kore_strdup(db->name); TAILQ_INSERT_TAIL(&pgsql_conn_free, conn, list); return (conn); } static void pgsql_conn_release(struct kore_pgsql *pgsql) { int fd; if (pgsql->conn == NULL) return; /* Async query cleanup */ if (pgsql->flags & KORE_PGSQL_ASYNC) { if (pgsql->conn != NULL) { fd = PQsocket(pgsql->conn->db); kore_platform_disable_read(fd); kore_pool_put(&pgsql_job_pool, pgsql->conn->job); } } /* Drain just in case. */ while (PQgetResult(pgsql->conn->db) != NULL) ; pgsql->conn->job = NULL; pgsql->conn->flags |= PGSQL_CONN_FREE; TAILQ_INSERT_TAIL(&pgsql_conn_free, pgsql->conn, list); pgsql->conn = NULL; pgsql->state = KORE_PGSQL_STATE_COMPLETE; pgsql_queue_wakeup(); } static void pgsql_conn_cleanup(struct pgsql_conn *conn) { struct http_request *req; struct kore_pgsql *pgsql; kore_debug("pgsql_conn_cleanup(): %p", conn); if (conn->flags & PGSQL_CONN_FREE) TAILQ_REMOVE(&pgsql_conn_free, conn, list); if (conn->job) { req = conn->job->req; pgsql = conn->job->pgsql; http_request_wakeup(req); pgsql->conn = NULL; pgsql_set_error(pgsql, PQerrorMessage(conn->db)); kore_pool_put(&pgsql_job_pool, conn->job); conn->job = NULL; } if (conn->db != NULL) PQfinish(conn->db); pgsql_conn_count--; kore_free(conn->name); kore_free(conn); } static void pgsql_read_result(struct kore_pgsql *pgsql) { if (PQisBusy(pgsql->conn->db)) { pgsql->state = KORE_PGSQL_STATE_WAIT; return; } pgsql->result = PQgetResult(pgsql->conn->db); if (pgsql->result == NULL) { pgsql->state = KORE_PGSQL_STATE_DONE; return; } switch (PQresultStatus(pgsql->result)) { case PGRES_COPY_OUT: case PGRES_COPY_IN: case PGRES_NONFATAL_ERROR: case PGRES_COPY_BOTH: break; case PGRES_COMMAND_OK: pgsql->state = KORE_PGSQL_STATE_DONE; break; case PGRES_TUPLES_OK: #if PG_VERSION_NUM >= 90200 case PGRES_SINGLE_TUPLE: #endif pgsql->state = KORE_PGSQL_STATE_RESULT; break; case PGRES_EMPTY_QUERY: case PGRES_BAD_RESPONSE: case PGRES_FATAL_ERROR: pgsql_set_error(pgsql, PQresultErrorMessage(pgsql->result)); break; } }
22.912752
75
0.710896
2754141856f3666e33289d2ecede49faeb7387c5
842
h
C
PrivateFrameworks/PassKitCore.framework/PKPassPreviewImageSet.h
shaojiankui/iOS10-Runtime-Headers
6b0d842bed0c52c2a7c1464087b3081af7e10c43
[ "MIT" ]
36
2016-04-20T04:19:04.000Z
2018-10-08T04:12:25.000Z
PrivateFrameworks/PassKitCore.framework/PKPassPreviewImageSet.h
shaojiankui/iOS10-Runtime-Headers
6b0d842bed0c52c2a7c1464087b3081af7e10c43
[ "MIT" ]
null
null
null
PrivateFrameworks/PassKitCore.framework/PKPassPreviewImageSet.h
shaojiankui/iOS10-Runtime-Headers
6b0d842bed0c52c2a7c1464087b3081af7e10c43
[ "MIT" ]
10
2016-06-16T02:40:44.000Z
2019-01-15T03:31:45.000Z
/* Generated by RuntimeBrowser Image: /System/Library/PrivateFrameworks/PassKitCore.framework/PassKitCore */ @interface PKPassPreviewImageSet : PKPassImageSet { PKImage * _iconImage; PKImage * _notificationIconImage; } @property (nonatomic, retain) PKImage *iconImage; @property (nonatomic, retain) PKImage *notificationIconImage; + (id)archiveName; + (unsigned int)currentVersion; + (long long)imageSetType; + (bool)supportsSecureCoding; - (void).cxx_destruct; - (void)encodeWithCoder:(id)arg1; - (unsigned long long)hash; - (id)iconImage; - (id)initWithCoder:(id)arg1; - (id)initWithDisplayProfile:(id)arg1 fileURL:(id)arg2 screenScale:(double)arg3 suffix:(id)arg4; - (bool)isEqual:(id)arg1; - (id)notificationIconImage; - (void)preheatImages; - (void)setIconImage:(id)arg1; - (void)setNotificationIconImage:(id)arg1; @end
27.16129
96
0.75772
e97ccdd1612f6e78767ca5002767c56a87d32d0a
21,036
c
C
src/lib/kernel/nt.c
leleobhz/mrt
178f776ed75c9c9ee568479657cf08ad1bb1f4a9
[ "BSD-4-Clause-UC" ]
3
2019-04-03T12:32:21.000Z
2020-12-27T22:47:09.000Z
src/lib/kernel/nt.c
leleobhz/mrt
178f776ed75c9c9ee568479657cf08ad1bb1f4a9
[ "BSD-4-Clause-UC" ]
null
null
null
src/lib/kernel/nt.c
leleobhz/mrt
178f776ed75c9c9ee568479657cf08ad1bb1f4a9
[ "BSD-4-Clause-UC" ]
2
2018-07-12T01:33:08.000Z
2021-12-24T02:37:56.000Z
/* * $Id: nt.c,v 1.1.1.1 2000/08/14 18:46:11 labovit Exp $ */ #include <config.h> #include <stdio.h> #include <mrt.h> #include <winsock2.h> #include <windef.h> #include <stdio.h> #include <stdlib.h> #include <excpt.h> #include <IPHlpApi.h> #include <windows.h> #include <ws2tcpip.h> #ifdef HAVE_IPV6 #include <ntddip6.h> #include <ws2ip6.h> #endif /* HAVE_IPV6 */ #define RTM_ADD 1 #define RTM_DELETE 2 #define RTM_CHANGE 3 #define MAX_LINK_LEVEL_ADDRESS_LENGTH 64 HANDLE Handle; #ifdef HAVE_IPV6 int readipv6_interfaces (); void PrintAddress(IPV6_INFO_ADDRESS *NTE); void ForEachAddress(IPV6_INFO_INTERFACE *IF, void (*func)(IPV6_INFO_ADDRESS *)); char *FormatIPv6Address(IPv6Addr *Address); char *FormatDADState(uint DADState); void krt_read_table_v6(); void add_address_to_interface (); void ForEachAddress2(); void ipv6_nt_update_kernel_route (IPV6_INFO_ROUTE_TABLE *RTE); void add_nt_ipv6_interface (IPV6_INFO_INTERFACE *IF, int index); IPV6_INFO_INTERFACE *GetInterface(uint Index); #endif /* HAVE_IPV6 */ int readipv4_interfaces (); void krt_read_table_v4(); int kernel_init (void) { SOCKET sd; /* good place to open WSA socket */ sd = WSASocket(AF_INET, SOCK_DGRAM, 0, 0, 0, 0); if (sd == SOCKET_ERROR) { printf ("Failed to get a socket. Error %d\n", WSAGetLastError()); return -1; } return (1); } sys_kernel_update_route (prefix_t * dest, prefix_t * nexthop, prefix_t * oldhop, int index, int oldindex) { #ifdef HAVE_IPV6 if (dest->family == AF_INET6) return (sys_kernel_update_route_v6 (dest, nexthop, oldhop, index, oldindex)); #else if (dest->family == AF_INET) return (sys_kernel_update_route_v4 (dest, nexthop, oldhop, index, oldindex)); #endif /* HAVE_IPV6 */ } int read_interfaces () { WSADATA WinsockData; if (WSAStartup(MAKEWORD(2, 2), &WinsockData) != 0) { printf ("Failed to find Winsock 2.2!\n"); return -1; } #ifdef HAVE_IPV6 readipv6_interfaces (); #else readipv4_interfaces (); #endif /* IPV6 */ return (1); } int sys_kernel_read_rt_table (void) { #ifdef CONFIG_RTNETLINK if (init_netlink () >= 0) { return (kernel_read_rt_table_by_netlink ()); } #endif /* CONFIG_RTNETLINK */ #ifdef HAVE_IPV6 krt_read_table_v6 (); #else krt_read_table_v4 (); #endif /* HAVE_IPV6 */ return (1); } #ifdef HAVE_IPV6 sys_kernel_update_route_v6 (prefix_t * dest, prefix_t * nexthop, prefix_t * oldhop, int index, int oldindex) { IPV6_INFO_ROUTE_TABLE Route; uint BytesReturned; int command; memset (&Route, 0, sizeof (IPV6_INFO_ROUTE_TABLE)); Route.ValidLifetime = 0xffffffff; /* infinite */ Route.Preference = 0; Route.SitePrefixLength = 0; Route.Publish = FALSE; Route.Immortal = -1; #ifdef NT if (nexthop) printf ("nexthop %s\n", prefix_toax (nexthop)); #endif /* NT */ Route.Query.PrefixLength = dest->bitlen; memcpy (&Route.Query.Prefix, &dest->add.sin6, sizeof (struct in6_addr)); // add if (nexthop && (oldhop == NULL)){ command = RTM_ADD; memcpy (&Route.Query.Neighbor.Address, &nexthop->add.sin6, sizeof (struct in6_addr)); Route.Query.Neighbor.IF.Index = index; } // delete else if ((nexthop == NULL) && oldhop) { Route.ValidLifetime = 0; command = RTM_DELETE; if (oldhop != NULL) memcpy (&Route.Query.Neighbor.Address, &oldhop->add.sin6, sizeof (struct in6_addr)); Route.Query.Neighbor.IF.Index = oldindex; } // change else if (nexthop && oldhop) { Route.ValidLifetime = 0; command = RTM_CHANGE; if (oldhop != NULL) memcpy (&Route.Query.Neighbor.Address, &oldhop->add.sin6, sizeof (struct in6_addr)); Route.Query.Neighbor.IF.Index = oldindex; } if (!DeviceIoControl(Handle, IOCTL_IPV6_UPDATE_ROUTE_TABLE, &Route, sizeof Route, NULL, 0, &BytesReturned, NULL)) { printf("route update error: %x\n", GetLastError()); return (-1); } /* change -- and the new route */ if (command == RTM_CHANGE) { memcpy (&Route.Query.Neighbor.Address, &nexthop->add.sin6, sizeof (struct in6_addr)); Route.Query.Neighbor.IF.Index = index; if (!DeviceIoControl(Handle, IOCTL_IPV6_UPDATE_ROUTE_TABLE, &Route, sizeof Route, NULL, 0, &BytesReturned, NULL)) { printf("route update error: %x\n", GetLastError()); return (-1); } } return (1); } #endif /* HAVE_IPV6 */ int readipv4_interfaces () { //struct sockaddr_in *pAddress, *pAddress_Mask, *pAddress_BroadCast; DWORD pAddress, pAddress_Mask, pAddress_BroadCast; INTERFACE_INFO InterfaceList[20]; unsigned long nBytesReturned; int nNumInterfaces, i; u_long nFlags; interface_t *interfce; char name[128]; int ret; MIB_IFROW IfRow; PMIB_IPADDRROW prow; BYTE buf[4096]; DWORD cbbuf = sizeof(buf); u_long index; PMIB_IPADDRTABLE ptable = (PMIB_IPADDRTABLE)&buf; ret = GetIpAddrTable(ptable, &cbbuf, TRUE); for (i=0; i < ptable->dwNumEntries; i++) { prow = &(ptable->table[i]); index = prow->dwIndex; index = index & 0x00ffff; /* remove the top bit -- see NT Notes for more info */ pAddress = prow->dwAddr; sprintf (name, "intf%d", index); /* just use index number, NT doesn't really have names */ pAddress_BroadCast = prow->dwBCastAddr; pAddress_Mask = prow->dwMask; IfRow.dwIndex = prow->dwIndex; GetIfEntry(&IfRow); nFlags = 0; if (IfRow.dwAdminStatus == MIB_IF_ADMIN_STATUS_UP) nFlags |= IFF_UP; if (prow->dwAddr == htonl (0x7f000001)) nFlags |= IFF_LOOPBACK; else { // not loopback nFlags |= IFF_MULTICAST; /* I have no idea how we determine this in NT */ nFlags |= IFF_BROADCAST; } interfce = new_interface (name, nFlags, prow->dwReasmSize, index); add_addr_to_interface (interfce, AF_INET, &pAddress, mask2len (&pAddress_Mask, 4), &pAddress_BroadCast); } return 0; } #ifdef HAVE_IPV6 int readipv6_interfaces () { IPV6_QUERY_INTERFACE Query, NextQuery; IPV6_INFO_INTERFACE *IF; uint InfoSize, BytesReturned; Handle = CreateFileW(WIN_IPV6_DEVICE_NAME, 0, // access mode FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, // security attributes OPEN_EXISTING, 0, // flags & attributes NULL); // template file assert (Handle != INVALID_HANDLE_VALUE); InfoSize = sizeof *IF + MAX_LINK_LEVEL_ADDRESS_LENGTH; IF = (IPV6_INFO_INTERFACE *) malloc(InfoSize); assert (IF != NULL); NextQuery.Index = 0; for (;;) { Query = NextQuery; if (!DeviceIoControl(Handle, IOCTL_IPV6_QUERY_INTERFACE, &Query, sizeof Query, IF, InfoSize, &BytesReturned, NULL)) { printf("bad index %u\n", Query.Index); exit(1); } NextQuery = IF->Query; if (Query.Index != 0) { if (BytesReturned != sizeof *IF + IF->LinkLevelAddressLength) { printf("inconsistent link-level address length\n"); return (-1); } IF->Query = Query; add_nt_ipv6_interface (IF, Query.Index); } if (NextQuery.Index == 0) break; } free(IF); return (1); } void add_nt_ipv6_interface (IPV6_INFO_INTERFACE *IF, int index) { interface_t *interfce; static char buffer[128]; int nFlags; // hardcode flags for now -- it looks like MSRIPv6 does not pass on this ifno nFlags = IFF_MULTICAST | IFF_BROADCAST; sprintf (buffer, "v6intf%d", index); // MSRIPv6 Interfaces don't really have names (just addresses) if (index == 1) nFlags |= IFF_LOOPBACK; if (IF->MediaConnected != 1) nFlags |= IFF_UP; interfce = new_interface (buffer, nFlags, IF->LinkMTU, index); ForEachAddress2(IF, interfce, add_address_to_interface); } void ForEachAddress2(IPV6_INFO_INTERFACE *IF, interface_t *interfce, void (*func)(interface_t *, IPV6_INFO_ADDRESS *)) { IPV6_QUERY_ADDRESS Query, NextQuery; IPV6_INFO_ADDRESS NTE; uint BytesReturned; NextQuery.IF.Index = IF->Query.Index; NextQuery.Address = in6addr_any; for (;;) { Query = NextQuery; if (!DeviceIoControl(Handle, IOCTL_IPV6_QUERY_ADDRESS, &Query, sizeof Query, &NTE, sizeof NTE, &BytesReturned, NULL)) { printf("bad address %s\n", FormatIPv6Address(&Query.Address)); return; } NextQuery = NTE.Query; if (!IN6_ADDR_EQUAL(&Query.Address, &in6addr_any)) { NTE.Query = Query; (*func)(interfce, &NTE); } if (IN6_ADDR_EQUAL(&NextQuery.Address, &in6addr_any)) break; } } void ForEachAddress(IPV6_INFO_INTERFACE *IF, void (*func)(IPV6_INFO_ADDRESS *)) { IPV6_QUERY_ADDRESS Query, NextQuery; IPV6_INFO_ADDRESS NTE; uint BytesReturned; NextQuery.IF.Index = IF->Query.Index; NextQuery.Address = in6addr_any; for (;;) { Query = NextQuery; if (!DeviceIoControl(Handle, IOCTL_IPV6_QUERY_ADDRESS, &Query, sizeof Query, &NTE, sizeof NTE, &BytesReturned, NULL)) { printf("bad address %s\n", FormatIPv6Address(&Query.Address)); return (NULL); } NextQuery = NTE.Query; if (!IN6_ADDR_EQUAL(&Query.Address, &in6addr_any)) { NTE.Query = Query; (*func)(&NTE); } if (IN6_ADDR_EQUAL(&NextQuery.Address, &in6addr_any)) break; } } interface_t *NT_find_neighbor_interface (prefix_t *prefix) { interface_t *interfce; IPV6_INFO_INTERFACE *IF; IPV6_QUERY_NEIGHBOR_CACHE Query, NextQuery; IPV6_INFO_NEIGHBOR_CACHE *NCE; uint InfoSize, BytesReturned; InfoSize = sizeof *NCE + MAX_LINK_LEVEL_ADDRESS_LENGTH; LL_Iterate (INTERFACE_MASTER->ll_interfaces, (char *) interfce) { if (interfce->primary6 == NULL) continue; IF = GetInterface(interfce->index); NCE = (IPV6_INFO_NEIGHBOR_CACHE *) malloc(InfoSize); if (NCE == NULL) { printf("malloc failed\n"); return (NULL); } NextQuery.IF.Index = IF->Query.Index; NextQuery.Address = in6addr_any; for (;;) { Query = NextQuery; if (!DeviceIoControl(Handle, IOCTL_IPV6_QUERY_NEIGHBOR_CACHE, &Query, sizeof Query, NCE, InfoSize, &BytesReturned, NULL)) { printf("bad address %s\n", FormatIPv6Address(&Query.Address)); return (NULL); } NextQuery = NCE->Query; if (!IN6_ADDR_EQUAL(&Query.Address, &in6addr_any)) { if (BytesReturned != sizeof *NCE + NCE->LinkLevelAddressLength) { printf("inconsistent link-level address length\n"); return (NULL); } NCE->Query = Query; /* do something here */ if (IN6_ADDR_EQUAL(&NextQuery.Address, &prefix->add.sin6)) return (interfce); } if (IN6_ADDR_EQUAL(&NextQuery.Address, &in6addr_any)) break; } free(NCE); } } interface_t *NT_find_interface (prefix_t *prefix, int link_local) { IPV6_QUERY_ROUTE_TABLE Query, NextQuery; IPV6_INFO_ROUTE_TABLE RTE; uint BytesReturned; //char tmp[128]; struct in6_addr addr, dst; int llocal = 0; int best = 0; int best_index = 0; NextQuery.Neighbor.IF.Index = 0; memcpy (&addr, prefix_toaddr6 (prefix), sizeof (addr)); #ifdef HAVE_IPV6 if (prefix->family == AF_INET6 && IN6_IS_ADDR_LINKLOCAL (&addr)) { llocal++; return (NT_find_neighbor_interface (prefix)); } #endif /* HAVE_IPV6 */ for (;;) { Query = NextQuery; if (!DeviceIoControl(Handle, IOCTL_IPV6_QUERY_ROUTE_TABLE, &Query, sizeof Query, &RTE, sizeof RTE, &BytesReturned, NULL)) { printf("bad index %u\n", Query.Neighbor.IF.Index); return (NULL); } NextQuery = RTE.Query; if (Query.Neighbor.IF.Index != 0) { RTE.Query = Query; memcpy (&dst, &(RTE.Query.Prefix), sizeof (dst)); if (comp_with_mask (&addr, &dst, (llocal) ? 128 : RTE.Query.PrefixLength)) { if ((link_local) && (!IN6_IS_ADDR_UNSPECIFIED (&Query.Neighbor.Address))) continue; if (RTE.Query.PrefixLength >= best) { best = RTE.Query.PrefixLength; best_index = Query.Neighbor.IF.Index; } //return (find_interface_byindex (Query.Neighbor.IF.Index)); } } if (NextQuery.Neighbor.IF.Index == 0) break; } if (best > 0) return (find_interface_byindex (best_index)); return (NULL); } void PrintAddress(IPV6_INFO_ADDRESS *NTE) { printf(" %s address %s, ", FormatDADState(NTE->DADState), FormatIPv6Address(&NTE->Query.Address)); if (NTE->ValidLifetime == 0xffffffff) printf("infinite/"); else printf("%us/", NTE->ValidLifetime); if (NTE->PreferredLifetime == 0xffffffff) printf("infinite\n"); else printf("%us\n", NTE->PreferredLifetime); } char * FormatIPv6Address(IPv6Addr *Address) { static char buffer[128]; DWORD buflen = sizeof buffer; struct sockaddr_in6 sin6; //interface_t *interfce; //int nFlags; sin6.sin6_family = AF_INET6; sin6.sin6_port = 0; sin6.sin6_flowinfo = 0; memcpy(&sin6.sin6_addr, Address, sizeof *Address); if (WSAAddressToString((struct sockaddr *) &sin6, sizeof sin6, NULL, // LPWSAPROTOCOL_INFO buffer, &buflen) == SOCKET_ERROR) { strcpy(buffer, "<invalid>"); printf ("WSAAdresstoString Error %d\n", WSAGetLastError()); } //interfce = new_interface (buffer, nFlags, 512, 0); //add_addr_to_interface (interfce, AF_INET6, // &sin6.sin6_addr, // 32, // &sin6.sin6_addr); return buffer; } void add_address_to_interface (interface_t *interfce, IPV6_INFO_ADDRESS *NTE) { struct sockaddr_in6 sin6; memcpy(&sin6.sin6_addr, &NTE->Query.Address, sizeof (NTE->Query.Address)); /* In MSRIPv6, the mask is not stored with the interface -- we'll have to check the * routing table */ add_addr_to_interface (interfce, AF_INET6, &sin6.sin6_addr, 128, NULL); } char * FormatDADState(uint DADState) { switch (DADState) { case 0: return "invalid"; case 1: return "duplicate"; case 2: return "tentative"; case 3: return "deprecated"; case 4: return "preferred"; } return "<bad state>"; } #endif /* HAVE_IPV6 */ #ifdef HAVE_IPV6 void krt_read_table_v6 () { // ForEachRoute(PrintRouteTableEntry); IPV6_QUERY_ROUTE_TABLE Query, NextQuery; IPV6_INFO_ROUTE_TABLE RTE; uint BytesReturned; NextQuery.Neighbor.IF.Index = 0; for (;;) { Query = NextQuery; if (!DeviceIoControl(Handle, IOCTL_IPV6_QUERY_ROUTE_TABLE, &Query, sizeof Query, &RTE, sizeof RTE, &BytesReturned, NULL)) { printf("bad index %u\n", Query.Neighbor.IF.Index); return (NULL); } NextQuery = RTE.Query; if (Query.Neighbor.IF.Index != 0) { RTE.Query = Query; if (!IN6_IS_ADDR_LOOPBACK (&RTE.Query.Prefix) && !IN6_IS_ADDR_MULTICAST(&RTE.Query.Prefix) && !IN6_IS_ADDR_UNSPECIFIED (&RTE.Query.Neighbor.Address)) { update_kernel_route ('A', AF_INET6, (void *) &RTE.Query.Prefix, &RTE.Query.Neighbor.Address, RTE.Query.PrefixLength, RTE.Query.Neighbor.IF.Index, PROTO_KERNEL); //ipv6_nt_update_kernel_route (&RTE); } if (NextQuery.Neighbor.IF.Index == 0) break; } } } IPV6_INFO_INTERFACE * GetInterface(uint Index) { IPV6_QUERY_INTERFACE Query; IPV6_INFO_INTERFACE *IF; uint InfoSize, BytesReturned; Query.Index = Index; InfoSize = sizeof *IF + MAX_LINK_LEVEL_ADDRESS_LENGTH; IF = (IPV6_INFO_INTERFACE *) malloc(InfoSize); if (IF == NULL) { printf("malloc failed\n"); return (NULL); } if (!DeviceIoControl(Handle, IOCTL_IPV6_QUERY_INTERFACE, &Query, sizeof Query, IF, InfoSize, &BytesReturned, NULL)) { printf("bad index %u\n", Query.Index); return (NULL); } if (BytesReturned != sizeof *IF + IF->LinkLevelAddressLength) { printf("inconsistent link-level address length\n"); return (NULL); } IF->Query = Query; return IF; } #endif /* HAVE_IPV6 */ #define PAGE 4096 LPWSTR wszType[] = {L"Other", L"Invalid", L"Direct", L"Indirect"}; LPWSTR wszProto[] ={L"Other", // MIB_IPPROTO_OTHER 1 L"Local", // MIB_IPPROTO_LOCAL 2 L"SNMP", // MIB_IPPROTO_NETMGMT 3 L"ICMP", // MIB_IPPROTO_ICMP 4 L"Exterior Gateway Protocol", // MIB_IPPROTO_EGP 5 L"GGP", // MIB_IPPROTO_GGP 6 L"Hello", // MIB_IPPROTO_HELLO 7 L"Routing Information Protocol", // MIB_IPPROTO_RIP 8 L"IS IS", // MIB_IPPROTO_IS_IS 9 L"ES IS", // MIB_IPPROTO_ES_IS 10 L"Cicso", // MIB_IPPROTO_CISCO 11 L"BBN", // MIB_IPPROTO_BBN 12 L"Open Shortest Path First", // MIB_IPPROTO_OSPF 13 L"Border Gateway Protocol"}; // MIB_IPPROTO_BGP 14 void krt_read_table_v4() { BYTE buf[PAGE]; DWORD cbbuf = sizeof(buf); DWORD d; PMIB_IPFORWARDROW pRow; PMIB_IPFORWARDTABLE table = (PMIB_IPFORWARDTABLE)&buf; // have to check return value -- buffer might be too small if (GetIpForwardTable (table, &cbbuf, TRUE)) return; for (d=0; d < table->dwNumEntries; ++d) { pRow = table->table+d; update_kernel_route ('A', AF_INET, (void *) &(pRow->dwForwardDest), &(pRow->dwForwardNextHop), mask2len (&pRow->dwForwardMask, 4), pRow->dwForwardIfIndex, PROTO_KERNEL); } } sys_kernel_update_route_v4 (prefix_t * dest, prefix_t * nexthop, prefix_t * oldhop, int index, int oldindex) { MIB_IPFORWARDROW Route; u_int BytesReturned; int command; int err1, err2; DWORD mask = 0; memset(&Route, 0, sizeof(MIB_IPFORWARDROW)); if (prefix_is_loopback (dest)) return; printf ("dest: %s", prefix_toax (dest)); printf (" Nexthop: %s", prefix_toa (nexthop)); printf (" index %d (old index %d)\n", index, oldindex); len2mask (dest->bitlen, &mask, 4); Route.dwForwardDest = prefix_tolong (dest); Route.dwForwardMask = mask; Route.dwForwardIfIndex = index; //Route.dwForwardIfIndex |= 0x01000000; /* hack, hack cause NT4 sets a high bit outside 256 range */ Route.dwForwardType = MIB_IPROUTE_TYPE_DIRECT; Route.dwForwardProto = MIB_IPPROTO_NETMGMT; Route.dwForwardAge = INFINITE; Route.dwForwardMetric1 = 1; Route.dwForwardMetric2 = (DWORD)-1; Route.dwForwardMetric3 = (DWORD)-1; Route.dwForwardMetric4 = (DWORD)-1; // add if (nexthop && (oldhop == NULL)){ command = RTM_ADD; Route.dwForwardNextHop = prefix_tolong (nexthop); if ((err1 = CreateIpForwardEntry(&Route)) != NO_ERROR) { err2= WSAGetLastError(); printf ("Error %d %d %s\n", err1, err2, strerror(NULL)); } } // delete else if ((nexthop == NULL) && oldhop) { command = RTM_DELETE; Route.dwForwardIfIndex = oldindex; //Route.dwForwardIfIndex |= 0x01000000; /* hack, hack cause NT4 sets a high bit outside 256 range */ Route.dwForwardNextHop = prefix_tolong (oldhop); if ((err1 = DeleteIpForwardEntry (&Route)) != NO_ERROR) { err2= GetLastError (); printf ("Error %d %d %s\n", err1, err2, strerror(NULL)); } } // change else if (nexthop && oldhop) { command = RTM_CHANGE; Route.dwForwardNextHop = prefix_tolong (nexthop); if ((err1 = SetIpForwardEntry(&Route)) != NO_ERROR) { err2= GetLastError (); printf ("Error %d %d %s\n", err1, err2, strerror(NULL)); } } return (1); }
25.102625
102
0.597262
8f0506cabbd9f51c630f7696fd8617c0d56d7bee
5,695
h
C
deps/libgeos/geos/include/geos/operation/intersection/Rectangle.h
khrushjing/node-gdal-async
6546b0c8690f2db677d5385b40b407523503b314
[ "Apache-2.0" ]
57
2020-02-08T17:52:17.000Z
2021-10-14T03:45:09.000Z
deps/libgeos/geos/include/geos/operation/intersection/Rectangle.h
khrushjing/node-gdal-async
6546b0c8690f2db677d5385b40b407523503b314
[ "Apache-2.0" ]
47
2020-02-12T16:41:40.000Z
2021-09-28T22:27:56.000Z
deps/libgeos/geos/include/geos/operation/intersection/Rectangle.h
khrushjing/node-gdal-async
6546b0c8690f2db677d5385b40b407523503b314
[ "Apache-2.0" ]
8
2020-03-17T11:18:07.000Z
2021-10-14T03:45:15.000Z
/********************************************************************** * * GEOS - Geometry Engine Open Source * http://geos.osgeo.org * * Copyright (C) 2014 Mika Heiskanen <mika.heiskanen@fmi.fi> * * This is free software; you can redistribute and/or modify it under * the terms of the GNU Lesser General Public Licence as published * by the Free Software Foundation. * See the COPYING file for more information. * **********************************************************************/ #ifndef GEOS_OP_INTERSECTION_RECTANGLE_H #define GEOS_OP_INTERSECTION_RECTANGLE_H #include <geos/export.h> #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class #endif // Forward declarations namespace geos { namespace geom { class GeometryFactory; class Geometry; class Polygon; class LinearRing; } } namespace geos { namespace operation { // geos::operation namespace intersection { // geos::operation::intersection /** * \brief Clipping rectangle * * A clipping rectangle defines the boundaries of the rectangle * by defining the limiting x- and y-coordinates. The clipping * rectangle must be non-empty. In addition, methods are provided * for specifying the location of a given coordinate with respect * to the clipping rectangle similarly to the Cohen-Sutherland * clipping algorithm. * */ class GEOS_DLL Rectangle { public: /** * \brief Construct a clipping rectangle * * @param x1 x-coordinate of the left edge * @param y1 y-coordinate of the bottom edge * @param x2 x-coordinate of the right edge * @param y2 y-coordinate of the right edge * @throws IllegalArgumentException if the rectangle is empty */ Rectangle(double x1, double y1, double x2, double y2); /** * @return the minimum x-coordinate of the rectangle */ double xmin() const { return xMin; } /** * @return the minimum y-coordinate of the rectangle */ double ymin() const { return yMin; } /** * @return the maximum x-coordinate of the rectangle */ double xmax() const { return xMax; } /** * @return the maximum y-coordinate of the rectangle */ double ymax() const { return yMax; } /** * @return the rectangle as a polygon geometry * * @note Ownership transferred to caller */ geom::Polygon* toPolygon(const geom::GeometryFactory& f) const; geom::LinearRing* toLinearRing(const geom::GeometryFactory& f) const; /** * @brief Position with respect to a clipping rectangle */ enum Position { Inside = 1, Outside = 2, Left = 4, Top = 8, Right = 16, Bottom = 32, TopLeft = Top | Left, // 12 TopRight = Top | Right, // 24 BottomLeft = Bottom | Left, // 36 BottomRight = Bottom | Right // 48 }; /** * @brief Test if the given position is on a Rectangle edge * @param pos Rectangle::Position * @return `true`, if the position is on an edge */ static bool onEdge(Position pos) { return (pos > Outside); } /** * @brief Test if the given positions are on the same Rectangle edge * @param pos1 [Position](@ref Rectangle::Position) of first coordinate * @param pos2 [Position](@ref Rectangle::Position) of second coordinate * @return `true`, if the positions are on the same edge */ static bool onSameEdge(Position pos1, Position pos2) { return onEdge(Position(pos1 & pos2)); } /** * @brief Establish position of coordinate with respect to a Rectangle * @param x x-coordinate * @param y y-coordinate * @return [Position](@ref Rectangle::Position) of the coordinate */ Position position(double x, double y) const { // We assume the point to be inside and test it first if(x > xMin && x < xMax && y > yMin && y < yMax) { return Inside; } // Next we assume the point to be outside and test it next if(x < xMin || x > xMax || y < yMin || y > yMax) { return Outside; } // Slower cases unsigned int pos = 0; if(x == xMin) { pos |= Left; } else if(x == xMax) { pos |= Right; } if(y == yMin) { pos |= Bottom; } else if(y == yMax) { pos |= Top; } return Position(pos); } /** * @brief Next edge in clock-wise direction * @param pos [Position](@ref Rectangle::Position) * @return next [Position](@ref Rectangle::Position) in clock-wise direction */ static Position nextEdge(Position pos) { switch(pos) { case BottomLeft: case Left: return Top; case TopLeft: case Top: return Right; case TopRight: case Right: return Bottom; case BottomRight: case Bottom: return Left; /* silences compiler warnings, Inside & Outside are not handled explicitly */ default: return pos; } } private: Rectangle(); double xMin; double yMin; double xMax; double yMax; }; // class RectangleIntersection } // namespace geos::operation::intersection } // namespace geos::operation } // namespace geos #endif // GEOS_OP_INTERSECTION_RECTANGLE_H
23.928571
107
0.574188
ac7e65c00cb1ca5fe569acfe1f413737b6a82471
3,551
h
C
usr/libexec/maild/FavoriteItem.h
lechium/iOS1351Headers
6bed3dada5ffc20366b27f7f2300a24a48a6284e
[ "MIT" ]
2
2021-11-02T09:23:27.000Z
2022-03-28T08:21:57.000Z
usr/libexec/maild/FavoriteItem.h
lechium/iOS1351Headers
6bed3dada5ffc20366b27f7f2300a24a48a6284e
[ "MIT" ]
null
null
null
usr/libexec/maild/FavoriteItem.h
lechium/iOS1351Headers
6bed3dada5ffc20366b27f7f2300a24a48a6284e
[ "MIT" ]
1
2022-03-28T08:21:59.000Z
2022-03-28T08:21:59.000Z
// // Generated by classdumpios 1.0.1 (64 bit) (iOS port by DreamDevLost)(Debug version compiled Sep 26 2020 13:48:20). // // Copyright (C) 1997-2019 Steve Nygard. // #import <objc/NSObject.h> #import "EFLoggable-Protocol.h" @class MFMessageCriterion, NSArray, NSNumber, NSPredicate, NSString; @interface FavoriteItem : NSObject <EFLoggable> { unsigned long long _type; // 8 = 0x8 _Bool _expanded; // 16 = 0x10 struct os_unfair_lock_s _lock; // 20 = 0x14 NSString *_syncKey; // 24 = 0x18 _Bool _selected; // 32 = 0x20 _Bool _shouldSync; // 33 = 0x21 MFMessageCriterion *_criterion; // 40 = 0x28 NSNumber *_badgeCount; // 48 = 0x30 NSArray *_subItems; // 56 = 0x38 } + (id)itemFromDictionary:(id)arg1; // IMP=0x000000010001a108 + (_Bool)_defaultShouldExpand; // IMP=0x0000000100019e40 + (_Bool)_defaultShouldSync; // IMP=0x0000000100019e38 + (id)itemForOutbox; // IMP=0x0000000100019e1c + (id)itemForVIP:(id)arg1 selected:(_Bool)arg2; // IMP=0x0000000100019d88 + (id)itemForSharedMailboxWithType:(unsigned long long)arg1 selected:(_Bool)arg2; // IMP=0x0000000100019d1c + (id)itemForUnifiedMailboxWithType:(int)arg1 selected:(_Bool)arg2; // IMP=0x0000000100019cb0 + (id)itemForInboxWithAccount:(id)arg1 selected:(_Bool)arg2; // IMP=0x0000000100019c1c + (id)itemForMailbox:(id)arg1 selected:(_Bool)arg2 shouldSync:(_Bool)arg3; // IMP=0x0000000100019b70 + (id)itemForMailbox:(id)arg1 selected:(_Bool)arg2; // IMP=0x0000000100019b48 + (id)itemForAccount:(id)arg1; // IMP=0x0000000100019ae0 + (id)log; // IMP=0x00000001000199f0 - (void).cxx_destruct; // IMP=0x000000010001ad4c @property(copy) NSArray *subItems; // @synthesize subItems=_subItems; @property _Bool shouldSync; // @synthesize shouldSync=_shouldSync; @property(getter=isSelected) _Bool selected; // @synthesize selected=_selected; @property(retain) NSNumber *badgeCount; // @synthesize badgeCount=_badgeCount; @property(readonly) MFMessageCriterion *criterion; // @synthesize criterion=_criterion; @property(readonly) unsigned long long type; // @synthesize type=_type; @property(readonly) unsigned long long sourceType; @property(readonly, copy) NSString *description; @property(getter=isExpanded) _Bool expanded; @property(readonly, getter=isExpandableInEditMode) _Bool expandableInEditMode; @property(readonly, getter=isExpandable) _Bool expandable; @property(readonly) _Bool acceptsMessageTransfers; - (id)persistentIDForMigration; // IMP=0x000000010001aa80 - (void)wasChangedExternally; // IMP=0x000000010001aa7c - (void)wasRemovedFromCollecion:(id)arg1; // IMP=0x000000010001aa78 - (void)wasAddedToCollection:(id)arg1; // IMP=0x000000010001aa74 - (id)syncValue; // IMP=0x000000010001aa6c - (id)syncKey; // IMP=0x000000010001aa64 - (_Bool)isVisible; // IMP=0x000000010001aa5c - (id)representingMailboxes; // IMP=0x000000010001a994 - (id)representingMailbox; // IMP=0x000000010001a98c - (id)account; // IMP=0x000000010001a984 @property(readonly) NSPredicate *additionalPredicate; - (id)serverCountMailboxScope; // IMP=0x000000010001a8bc - (id)countQueryPredicate; // IMP=0x000000010001a714 - (id)badgeCountString; // IMP=0x000000010001a5e8 - (id)displayName; // IMP=0x000000010001a5dc - (id)dictionaryRepresentation; // IMP=0x000000010001a358 - (id)initWithDictionary:(id)arg1; // IMP=0x0000000100019ee0 - (id)initWithType:(unsigned long long)arg1; // IMP=0x0000000100019e48 // Remaining properties @property(readonly, copy) NSString *debugDescription; @property(readonly) unsigned long long hash; @property(readonly) Class superclass; @end
46.116883
120
0.767953
5846a4dd763e26a2bf7e30ba34d1f944b27a6393
303
h
C
ShareFileSDK/ShareFileSDK/Credentials/SFAOAuth2Credential.h
NickNichollsCitrix/ShareFile-ObjectiveC
59c21fc5ab7288d83f3de64a34f1f6516ab7b7ba
[ "MIT" ]
2
2015-12-20T16:53:46.000Z
2018-09-13T14:16:47.000Z
ShareFileSDK/ShareFileSDK/Credentials/SFAOAuth2Credential.h
NickNichollsCitrix/ShareFile-ObjectiveC
59c21fc5ab7288d83f3de64a34f1f6516ab7b7ba
[ "MIT" ]
2
2019-12-23T23:22:35.000Z
2020-01-13T14:47:30.000Z
ShareFileSDK/ShareFileSDK/Credentials/SFAOAuth2Credential.h
NickNichollsCitrix/ShareFile-ObjectiveC
59c21fc5ab7288d83f3de64a34f1f6516ab7b7ba
[ "MIT" ]
4
2016-01-22T18:08:35.000Z
2020-01-13T12:50:26.000Z
#import <Foundation/Foundation.h> #import "SFAOAuthToken.h" #import "NSURLCredential+SFACredential.h" @interface SFAOAuth2Credential : NSURLCredential <NSSecureCoding> @property (strong, nonatomic, readonly) SFAOAuthToken *oAuthToken; - (instancetype)initWithOAuthToken:(SFAOAuthToken *)token; @end
25.25
66
0.805281
75852935344446415ad1df50ce87bd3f2ab81845
5,027
h
C
device/bluetooth/bluetooth_remote_gatt_service_winrt.h
mghgroup/Glide-Browser
6a4c1eaa6632ec55014fee87781c6bbbb92a2af5
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
575
2015-06-18T23:58:20.000Z
2022-03-23T09:32:39.000Z
device/bluetooth/bluetooth_remote_gatt_service_winrt.h
mghgroup/Glide-Browser
6a4c1eaa6632ec55014fee87781c6bbbb92a2af5
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
113
2015-05-04T09:58:14.000Z
2022-01-31T19:35:03.000Z
device/bluetooth/bluetooth_remote_gatt_service_winrt.h
DamieFC/chromium
54ce2d3c77723697efd22cfdb02aea38f9dfa25c
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
52
2015-07-14T10:40:50.000Z
2022-03-15T01:11:49.000Z
// Copyright 2018 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_WINRT_H_ #define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_WINRT_H_ #include <windows.devices.bluetooth.genericattributeprofile.h> #include <wrl/client.h> #include <stdint.h> #include <memory> #include <string> #include <vector> #include "base/logging.h" #include "base/macros.h" #include "device/bluetooth/bluetooth_export.h" #include "device/bluetooth/bluetooth_remote_gatt_characteristic_winrt.h" #include "device/bluetooth/bluetooth_remote_gatt_service.h" #include "device/bluetooth/public/cpp/bluetooth_uuid.h" namespace device { class BluetoothDevice; class BluetoothGattDiscovererWinrt; class DEVICE_BLUETOOTH_EXPORT BluetoothRemoteGattServiceWinrt : public BluetoothRemoteGattService { public: static std::unique_ptr<BluetoothRemoteGattServiceWinrt> Create( BluetoothDevice* device, Microsoft::WRL::ComPtr<ABI::Windows::Devices::Bluetooth:: GenericAttributeProfile::IGattDeviceService> gatt_service); ~BluetoothRemoteGattServiceWinrt() override; // BluetoothRemoteGattService: std::string GetIdentifier() const override; BluetoothUUID GetUUID() const override; bool IsPrimary() const override; BluetoothDevice* GetDevice() const override; std::vector<BluetoothRemoteGattService*> GetIncludedServices() const override; void UpdateCharacteristics(BluetoothGattDiscovererWinrt* gatt_discoverer); ABI::Windows::Devices::Bluetooth::GenericAttributeProfile::IGattDeviceService* GetDeviceServiceForTesting(); template <typename Interface> static GattErrorCode GetGattErrorCode(Interface* i) { Microsoft::WRL::ComPtr<ABI::Windows::Foundation::IReference<uint8_t>> protocol_error_ref; HRESULT hr = i->get_ProtocolError(&protocol_error_ref); if (FAILED(hr)) { DVLOG(2) << "Getting Protocol Error Reference failed: " << logging::SystemErrorCodeToString(hr); return GattErrorCode::GATT_ERROR_UNKNOWN; } if (!protocol_error_ref) { DVLOG(2) << "Got Null Protocol Error Reference."; return GattErrorCode::GATT_ERROR_UNKNOWN; } uint8_t protocol_error; hr = protocol_error_ref->get_Value(&protocol_error); if (FAILED(hr)) { DVLOG(2) << "Getting Protocol Error Value failed: " << logging::SystemErrorCodeToString(hr); return GattErrorCode::GATT_ERROR_UNKNOWN; } DVLOG(2) << "Got Protocol Error: " << static_cast<int>(protocol_error); // GATT Protocol Errors are described in the Bluetooth Core Specification // Version 5.0 Vol 3, Part F, 3.4.1.1. switch (protocol_error) { case 0x01: // Invalid Handle return GATT_ERROR_FAILED; case 0x02: // Read Not Permitted return GATT_ERROR_NOT_PERMITTED; case 0x03: // Write Not Permitted return GATT_ERROR_NOT_PERMITTED; case 0x04: // Invalid PDU return GATT_ERROR_FAILED; case 0x05: // Insufficient Authentication return GATT_ERROR_NOT_AUTHORIZED; case 0x06: // Request Not Supported return GATT_ERROR_NOT_SUPPORTED; case 0x07: // Invalid Offset return GATT_ERROR_INVALID_LENGTH; case 0x08: // Insufficient Authorization return GATT_ERROR_NOT_AUTHORIZED; case 0x09: // Prepare Queue Full return GATT_ERROR_IN_PROGRESS; case 0x0A: // Attribute Not Found return GATT_ERROR_FAILED; case 0x0B: // Attribute Not Long return GATT_ERROR_FAILED; case 0x0C: // Insufficient Encryption Key Size return GATT_ERROR_FAILED; case 0x0D: // Invalid Attribute Value Length return GATT_ERROR_INVALID_LENGTH; case 0x0E: // Unlikely Error return GATT_ERROR_FAILED; case 0x0F: // Insufficient Encryption return GATT_ERROR_NOT_PAIRED; case 0x10: // Unsupported Group Type return GATT_ERROR_FAILED; case 0x11: // Insufficient Resources return GATT_ERROR_FAILED; default: return GATT_ERROR_UNKNOWN; } } static uint8_t ToProtocolError(GattErrorCode error_code); private: BluetoothRemoteGattServiceWinrt( BluetoothDevice* device, Microsoft::WRL::ComPtr<ABI::Windows::Devices::Bluetooth:: GenericAttributeProfile::IGattDeviceService> gatt_service, BluetoothUUID uuid, uint16_t attribute_handle); BluetoothDevice* device_; Microsoft::WRL::ComPtr<ABI::Windows::Devices::Bluetooth:: GenericAttributeProfile::IGattDeviceService> gatt_service_; BluetoothUUID uuid_; uint16_t attribute_handle_; std::string identifier_; DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattServiceWinrt); }; } // namespace device #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_WINRT_H_
34.909722
80
0.717525
5939b196325b131505dcd444fbaccb04d259523c
1,071
c
C
examples/diff/strdiff.c
innerout/libmba
634bcaef7a88c31d1d6725ec1cae18e114ac63ec
[ "MIT" ]
null
null
null
examples/diff/strdiff.c
innerout/libmba
634bcaef7a88c31d1d6725ec1cae18e114ac63ec
[ "MIT" ]
null
null
null
examples/diff/strdiff.c
innerout/libmba
634bcaef7a88c31d1d6725ec1cae18e114ac63ec
[ "MIT" ]
1
2021-09-24T05:56:59.000Z
2021-09-24T05:56:59.000Z
#include <stdlib.h> #include <string.h> #include <stdio.h> #include <errno.h> #include <mba/diff.h> #include <mba/msgno.h> int main(int argc, char *argv[]) { const char *a = argv[1]; const char *b = argv[2]; int n, m, d; int sn, i; struct varray *ses = varray_new(sizeof(struct diff_edit), NULL); if (argc < 3) { fprintf(stderr, "usage: %s <str1> <str2>\n", argv[0]); return EXIT_FAILURE; } n = strlen(a); m = strlen(b); if ((d = diff(a, 0, n, b, 0, m, NULL, NULL, NULL, 0, ses, &sn, NULL)) == -1) { MMNO(errno); return EXIT_FAILURE; } printf("d=%d sn=%d\n", d, sn); for (i = 0; i < sn; i++) { struct diff_edit *e = varray_get(ses, i); switch (e->op) { case DIFF_MATCH: printf("MAT: "); fwrite(a + e->off, 1, e->len, stdout); break; case DIFF_INSERT: printf("INS: "); fwrite(b + e->off, 1, e->len, stdout); break; case DIFF_DELETE: printf("DEL: "); fwrite(a + e->off, 1, e->len, stdout); break; } printf("\n"); } return EXIT_SUCCESS; }
20.207547
80
0.537815
d9e8bee07c831f8b2846558337361f0465aaa984
1,476
h
C
os/arch/arm/src/s5j/sss/isp_util.h
ch1nh5/tizen_rt
2494416285c15c8b5bbc30aafef33d50e33ed320
[ "Apache-2.0" ]
2
2019-01-27T14:50:42.000Z
2019-01-27T14:51:25.000Z
os/arch/arm/src/s5j/sss/isp_util.h
ravisankarg/TizenRT
37644e1fd57168649f81527b2d5694e9dacfd14c
[ "Apache-2.0" ]
1
2017-10-19T18:20:33.000Z
2017-10-19T18:20:33.000Z
os/arch/arm/src/s5j/sss/isp_util.h
KimDongEon/mytest
79b2d65b350bd058260e8c4d4011289dabe5f1a8
[ "Apache-2.0" ]
1
2020-02-27T09:33:42.000Z
2020-02-27T09:33:42.000Z
/*! * @file isp_util.h * @brief Headerfile : util functions to support memset, memcpy, memcmp * @author jinsu.hyun * @version v0.50 : 2016.8.13 Init. release version */ #ifndef ISP_UTIL_H_ #define ISP_UTIL_H_ #include "isp_type.h" // ====================================== // Function // ====================================== int _isp_memcpy_u32_4PKA(u32 *pu32Dst, u32 *pu32Src, u32 u32Size); int _isp_memset_u32(u32 *pu32Dst, u32 u32Src, u32 u32Size); int _isp_memcpy_u32(u32 *pu32Dst, u32 *pu32Src, u32 u32Size); int _isp_memcmp_u32(const u32 *pu32Src1, const u32 *pu32Src2, u32 u32Size); int _isp_memxor_u32(u32 *pu32Dst, u32 *pu32Src1, u32 *pu32Src2, u32 u32Size); int _isp_memcpy_u32_4PKA_Swap(u32 *pu32Dst, u32 *pu32Src, u32 u32Size, int u32Swap); int _isp_memcpy_swap_u32(u32 *pu32Dst, u32 *pu32Src, u32 u32Size); int _isp_memset_u8(u8 *pu8Dst, u8 u8Src, u32 u32Size); int _isp_memcpy_u8(u8 *pu8Dst, u8 *pu8Src, u32 u32Size); int _isp_memcmp_u8(const u8 *pu8Src1, const u8 *pu8Src2, u32 u32Size); int _isp_memcpy_mailbox(u32 *pu32Dst, u32 *pu32Src, u32 u32Size_byte_len); int _isp_memcpy_mailbox_swap(u32 *pu32Dst, u32 *pu32Src, u32 u32Size_byte_len); int _isp_check_oid(u32 inputoid, u32 algorithm); int _isp_is_zero(const u32 *pu32Src, u32 u32Size); #define ISP_HMAC (0x001) #define ISP_HASH (0x002) #define ISP_DH (0x003) #define ISP_ECDH (0x004) #define ISP_RSA (0x005) #define ISP_ECDSA (0x006) #endif /* ISP_UTIL_H_ */
35.142857
84
0.705285
3defea30cab7522d9176b37c053435bcfebfd3e5
846
h
C
7_Turtle/turtle.h
inventshah/mini-projects
fbe26fc37f945cad481e4c30615a9ac91971cd32
[ "MIT" ]
1
2019-12-05T00:46:00.000Z
2019-12-05T00:46:00.000Z
7_Turtle/turtle.h
inventshah/mini-projects
fbe26fc37f945cad481e4c30615a9ac91971cd32
[ "MIT" ]
null
null
null
7_Turtle/turtle.h
inventshah/mini-projects
fbe26fc37f945cad481e4c30615a9ac91971cd32
[ "MIT" ]
null
null
null
#ifndef __TURTLE_H #define __TURTLE_H #define GL_SILENCE_DEPRECATION #define RED_SHIFT 16 #define GREEN_SHIFT 8 #define BLUE_SHIFT 0 #define WIDTH 1024 #define HEIGHT 768 #define DELTA_TIME 0.1 typedef struct painter { float x; float y; int color; short brush_size; struct painter *next; struct painter *before; } painter_t; // User input methods float hex_to_color(unsigned int c, int shift); unsigned int get_color(void); int get_int(char *msg); void get_command(painter_t *painter); // Drawing a circle as n-polygon void draw_circle(float x, float y, float radius); // Clean up malloc void destroy_painters(void); // Keyboard input logic void release_key(int key, int x, int y); void paint_turtle(painter_t *painter); // OpenGL needed methods void render(); void idle(); void changeSize(int w, int h); #endif
17.265306
49
0.741135
dbdfb83466b5bdfaf4366b2c2e46207473dea26a
7,860
h
C
benchmark/workloads/sigmod_2012_properties.h
lmaas/sigmod2012contest
636ae037c135c5461ab4674a3cb6e23287eaac1f
[ "MIT" ]
1
2015-11-27T06:13:22.000Z
2015-11-27T06:13:22.000Z
benchmark/workloads/sigmod_2012_properties.h
lmaas/sigmod2012contest
636ae037c135c5461ab4674a3cb6e23287eaac1f
[ "MIT" ]
null
null
null
benchmark/workloads/sigmod_2012_properties.h
lmaas/sigmod2012contest
636ae037c135c5461ab4674a3cb6e23287eaac1f
[ "MIT" ]
null
null
null
// // Copyright (c) 2012 TU Dresden - Database Technology Group // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // 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. // // Author: Lukas M. Maas <Lukas_Michael.Maas@mailbox.tu-dresden.de> // #ifndef BENCHMARK_WORKLOADS_SIGMOD_2012_PROPERTIES_H_ #define BENCHMARK_WORKLOADS_SIGMOD_2012_PROPERTIES_H_ #include <vector> #include <cassert> #include "contest_interface.h" #include "core/cached_key_store.h" #include "core/logger.h" #include "core/utils/lexical_cast.h" class SIGMOD2012IndexProperties; class Generator; // Defines properties for the SIGMOD 2012 Programming Contest workload class SIGMOD2012Properties{ public: // Creates a new properties object for the SIGMOD 2012 Programming Contest // workload SIGMOD2012Properties():range_portion_(0),point_portion_(0),update_portion_(0), insert_portion_(0),delete_portion_(0),extensive_stats_(false){} // Loads the properties from a file static SIGMOD2012Properties *LoadFromFile(Logger &logger, std::string filename, unsigned int seed); // Adds a new index to the properties object void AddIndex(SIGMOD2012IndexProperties *index){indices_.push_back(index);} // Returns the index at the given index SIGMOD2012IndexProperties &GetIndex(unsigned int index){ return *indices_[index]; } // Returns the portion of range queries int range_portion() const {return range_portion_;} // Returns the portion of point queries int point_portion() const {return point_portion_;} // Returns the portion of update operations int update_portion() const {return update_portion_;} // Returns the portion of insert operations int insert_portion() const {return insert_portion_;} // Returns the portion of delete operations int delete_portion() const {return delete_portion_;} // Returns whether extensive stats are enabled bool extensive_stats() const{return extensive_stats_;} // Returns the number of indices inside this property object size_t index_count() const {return indices_.size();} // Sets the portion of range queries void range_portion(int range_portion){range_portion_=range_portion;} // Sets the portion of point queries void point_portion(int point_portion){point_portion_=point_portion;} // Sets the portion of update operations void update_portion(int update_portion){update_portion_=update_portion;} // Sets the portion of insert operations void insert_portion(int insert_portion){insert_portion_=insert_portion;} // Sets the portion of delete operations void delete_portion(int delete_portion){delete_portion_=delete_portion;} // Sets whether extensive stats should be used void extensive_stats(bool extensive_stats){extensive_stats_=extensive_stats;} private: // A list of all indices to be used by the benchmark std::vector<SIGMOD2012IndexProperties*> indices_; // The portion of range queries int range_portion_; // The portion of point queries int point_portion_; // The portion of update operations int update_portion_; // The portion of insert operations int insert_portion_; // The portion of delete operations int delete_portion_; // Whether extensive statistics are enabled bool extensive_stats_; }; // Defines properties for indices used by the SIGMOD 2012 Programming Contest // workload class SIGMOD2012IndexProperties{ public: // Creates a new index properties object SIGMOD2012IndexProperties(const char* name, unsigned int dimensions, AttributeType* types, Generator** generators, unsigned int size, unsigned int payload_size, float capacity_factor): name_(name),dimensions_(dimensions),types_(types),size_(size), payload_size_(payload_size),generators_(generators){ // Get the record size unsigned int key_size = 0; for(unsigned int i = 0; i < dimensions_; i++){ switch(types_[i]){ case kShort: key_size += sizeof(int32_t); break; case kInt: key_size += sizeof(int64_t); break; case kVarchar: key_size += MAX_VARCHAR_LENGTH; break; default: assert(false); } } key_size_ = key_size; record_size_ = key_size_+payload_size_; populate_count_ = (size_/record_size_); keystore_capacity_ = (capacity_factor*populate_count_); keystore_ = new CachedKeyStore<char*>(keystore_capacity_); } // Destroys an index properties object ~SIGMOD2012IndexProperties(){ delete keystore_; }; // Returns the name of the index const char* name() const {return name_;} // Returns the attribute types of the index AttributeType* types() const {return types_;} // Returns the number of dimensions of the index unsigned int dimensions() const {return dimensions_;} // Returns the size of the index in byte unsigned int size() const {return size_;} // Returns the payload size used for this index unsigned int payload_size() const {return payload_size_;} // Returns the array of generators used to generator records for this index Generator **generators() const{return generators_;} // Returns the keystore for this index CachedKeyStore<char*> &keystore() const {return *keystore_;} // Returns the size of a record for this index in byte unsigned int record_size() const {return record_size_;} // Returns the number of records used to populate this index unsigned int populate_count() const {return populate_count_;} // Returns the max. number of records that can be stored inside the keystore unsigned int keystore_capacity() const {return keystore_capacity_;} // Returns the size of a key for this index in byte unsigned int key_size() const {return key_size_;} private: // The name of the index const char* name_; // The number of dimensions of the index unsigned int dimensions_; // The attribute types of the index AttributeType* types_; // The size of the index in byte unsigned int size_; // The payload size used for this index unsigned int payload_size_; // An array of generators used to generator records for this index Generator **generators_; // The size of a key for this index in byte unsigned int key_size_; // The size of a record for this index in byte unsigned int record_size_; // The number of records used to populate this index unsigned int populate_count_; // The max. number of records that can be stored inside the keystore unsigned int keystore_capacity_; // The keystore for this index CachedKeyStore<char*> *keystore_; }; #endif // BENCHMARK_WORKLOADS_SIGMOD_2012_PROPERTIES_H_
33.87931
80
0.722392
334f39ca85eb84379de07fe452298d04951688e9
1,762
h
C
src/ios/GameAnalyticsPlugin.h
sirg2003/cordova-plugin-gameanalyticscom
b55a782625e65d61d785d6a4f767ced79d79ddf8
[ "MIT" ]
1
2018-01-24T20:06:52.000Z
2018-01-24T20:06:52.000Z
src/ios/GameAnalyticsPlugin.h
sirg2003/cordova-plugin-gameanalyticscom
b55a782625e65d61d785d6a4f767ced79d79ddf8
[ "MIT" ]
null
null
null
src/ios/GameAnalyticsPlugin.h
sirg2003/cordova-plugin-gameanalyticscom
b55a782625e65d61d785d6a4f767ced79d79ddf8
[ "MIT" ]
null
null
null
#import <Cordova/CDVPlugin.h> @interface GameAnalyticsPlugin : CDVPlugin - (void) initialize:(CDVInvokedUrlCommand*)command; - (void) configureBuild:(CDVInvokedUrlCommand*)command; - (void) configureGameEngineVersion:(CDVInvokedUrlCommand*)command; - (void) configureSdkGameEngineVersion:(CDVInvokedUrlCommand*)command; - (void) configureUserId:(CDVInvokedUrlCommand*)command; - (void) addBusinessEvent:(CDVInvokedUrlCommand*)command; - (void) addBusinessEventWithReceipt:(CDVInvokedUrlCommand*)command; - (void) addResourceEvent:(CDVInvokedUrlCommand*)command; - (void) addProgressionEvent:(CDVInvokedUrlCommand*)command; - (void) addProgressionEventWithScore:(CDVInvokedUrlCommand*)command; - (void) addDesignEvent:(CDVInvokedUrlCommand*)command; - (void) addDesignEventWithValue:(CDVInvokedUrlCommand*)command; - (void) addErrorEvent:(CDVInvokedUrlCommand*)command; - (void) setEnabledInfoLog:(CDVInvokedUrlCommand*)command; - (void) setEnabledVerboseLog:(CDVInvokedUrlCommand*)command; - (void) setEnabledManualSessionHandling:(CDVInvokedUrlCommand*)command; - (void) configureAvailableCustomDimensions01:(CDVInvokedUrlCommand*)command; - (void) configureAvailableCustomDimensions02:(CDVInvokedUrlCommand*)command; - (void) configureAvailableCustomDimensions03:(CDVInvokedUrlCommand*)command; - (void) setCustomDimension01:(CDVInvokedUrlCommand*)command; - (void) setCustomDimension02:(CDVInvokedUrlCommand*)command; - (void) setCustomDimension03:(CDVInvokedUrlCommand*)command; - (void) setFacebookId:(CDVInvokedUrlCommand*)command; - (void) setGender:(CDVInvokedUrlCommand*)command; - (void) setBirthYear:(CDVInvokedUrlCommand*)command; - (void) startSession:(CDVInvokedUrlCommand*)command; - (void) endSession:(CDVInvokedUrlCommand*)command; @end
45.179487
77
0.818388
98f86ec41bb364ad0b03543ca0066d790b410ae5
535
h
C
engine/core/object/ui/Image.h
supernovaengine/supernova
54dfdc1032a0e7cf2de10a2dd72ae6654e75c8b8
[ "MIT" ]
10
2020-05-17T15:19:11.000Z
2022-03-31T13:46:19.000Z
engine/core/object/ui/Image.h
supernovaengine/supernova
54dfdc1032a0e7cf2de10a2dd72ae6654e75c8b8
[ "MIT" ]
null
null
null
engine/core/object/ui/Image.h
supernovaengine/supernova
54dfdc1032a0e7cf2de10a2dd72ae6654e75c8b8
[ "MIT" ]
2
2020-06-17T21:43:02.000Z
2022-03-31T13:46:21.000Z
// // (c) 2021 Eduardo Doria. // #ifndef IMAGE_H #define IMAGE_H #include "buffer/InterleavedBuffer.h" #include "buffer/IndexBuffer.h" #include "Object.h" namespace Supernova{ class Image: public Object{ protected: InterleavedBuffer buffer; IndexBuffer indices; public: Image(Scene* scene); void setSize(int width, int height); void setMargin(int margin); void setTexture(std::string path); int getWidth(); int getHeight(); }; } #endif //IMAGE_H
16.212121
44
0.628037
8e77d0bf31f3fce91c32984d3ae56b4e88470943
953
h
C
themes/c_header/headers/base16-brushtrees.h
base16-fork/base16-fork
79856b7e6195dde0874a9e6d191101ac6c5c74f5
[ "MIT" ]
null
null
null
themes/c_header/headers/base16-brushtrees.h
base16-fork/base16-fork
79856b7e6195dde0874a9e6d191101ac6c5c74f5
[ "MIT" ]
null
null
null
themes/c_header/headers/base16-brushtrees.h
base16-fork/base16-fork
79856b7e6195dde0874a9e6d191101ac6c5c74f5
[ "MIT" ]
null
null
null
/* base16-c_header (https://github.com/m1sports20/base16-c_header) * by Michael Spradling (http://mspradling.com) * Brush Trees schema by Abraham White <abelincoln.white@gmail.com> * * This is a standard c header that can be included in any c project. */ #ifndef BASE16_COLORS #define BASE16_COLORS static const char base00[] = "#E3EFEF"; static const char base01[] = "#C9DBDC"; static const char base02[] = "#B0C5C8"; static const char base03[] = "#98AFB5"; static const char base04[] = "#8299A1"; static const char base05[] = "#6D828E"; static const char base06[] = "#5A6D7A"; static const char base07[] = "#485867"; static const char base08[] = "#b38686"; static const char base09[] = "#d8bba2"; static const char base0A[] = "#aab386"; static const char base0B[] = "#87b386"; static const char base0C[] = "#86b3b3"; static const char base0D[] = "#868cb3"; static const char base0E[] = "#b386b2"; static const char base0F[] = "#b39f9f"; #endif
32.862069
69
0.699895
e6f46deb3d374db70a7206f21405859020e96dec
1,067
h
C
customui.h
ventosus/customui.lv2
46d01b79172a4b69b87457884527b9c8978df798
[ "Artistic-2.0" ]
null
null
null
customui.h
ventosus/customui.lv2
46d01b79172a4b69b87457884527b9c8978df798
[ "Artistic-2.0" ]
null
null
null
customui.h
ventosus/customui.lv2
46d01b79172a4b69b87457884527b9c8978df798
[ "Artistic-2.0" ]
null
null
null
/* * Copyright (c) 2016 Hanspeter Portner (dev@open-music-kontrollers.ch) * * This is free software: you can redistribute it and/or modify * it under the terms of the Artistic License 2.0 as published by * The Perl Foundation. * * This source 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 * Artistic License 2.0 for more details. * * You should have received a copy of the Artistic License 2.0 * along the source as a COPYING file. If not, obtain it from * http://www.perlfoundation.org/artistic_license_2_0. */ #ifndef _CUSTOMUI_LV2_H #define _CUSTOMUI_LV2_H #include <lv2/lv2plug.in/ns/lv2core/lv2.h> #include <lv2/lv2plug.in/ns/extensions/ui/ui.h> #define CUSTOMUI_URI "http://open-music-kontrollers.ch/lv2/customui" #define CUSTOMUI_TEST_URI CUSTOMUI_URI"#test" #define CUSTOMUI_TEST_SHOW_URI CUSTOMUI_URI"#ui_6_show" #define CUSTOMUI_TEST_KX_URI CUSTOMUI_URI"#ui_7_kx" #endif // _CUSTOMUI_LV2_H
33.34375
74
0.759138
fc340915baa3dcad7f9f3b685fd9187c10cfdc23
34,269
h
C
src/lib/common/include/sol-log.h
undeadinu/soletta
5ca6d6a70bead00caf154b445755be94f3f68099
[ "ECL-2.0", "Apache-2.0" ]
266
2015-06-11T00:21:02.000Z
2022-03-27T20:45:17.000Z
src/lib/common/include/sol-log.h
undeadinu/soletta
5ca6d6a70bead00caf154b445755be94f3f68099
[ "ECL-2.0", "Apache-2.0" ]
2,224
2015-06-17T17:29:50.000Z
2018-07-20T23:43:40.000Z
src/lib/common/include/sol-log.h
undeadinu/soletta
5ca6d6a70bead00caf154b445755be94f3f68099
[ "ECL-2.0", "Apache-2.0" ]
151
2015-06-17T14:42:54.000Z
2022-01-27T17:01:35.000Z
/* * This file is part of the Soletta (TM) Project * * Copyright (C) 2015 Intel Corporation. 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. */ #pragma once #include "sol-common-buildopts.h" #include "sol-macros.h" #include <inttypes.h> #include <stdint.h> #include <stdarg.h> #include <stdbool.h> #include <stdio.h> #include <sys/types.h> #ifdef __cplusplus template <typename T> inline const char *sol_int_format(T) { return NULL; } template <> inline const char *sol_int_format<int>(int) { return "%d"; } template <> inline const char *sol_int_format<long>(long) { return "%ld"; } template <> inline const char *sol_int_format<long long>(long long) { return "%lld"; } template <> inline const char *sol_int_format<short>(short) { return "%hd"; } template <> inline const char *sol_int_format<signed char>(signed char) { return "%hhd"; } template <> inline const char *sol_int_format<unsigned>(unsigned) { return "%u"; } template <> inline const char *sol_int_format<unsigned long>(unsigned long) { return "%lu"; } template <> inline const char *sol_int_format<unsigned long long>(unsigned long long) { return "%llu"; } template <> inline const char *sol_int_format<unsigned short>(unsigned short) { return "%hu"; } template <> inline const char *sol_int_format<unsigned char>(unsigned char) { return "%hhu"; } #define SOL_INT_CHECK_IMPL(var, exp, ...) \ do { \ if (SOL_UNLIKELY((var)exp)) { \ char *str = (char *)alloca(snprintf(NULL, 0, "%s (%s) %s", #var, sol_int_format(var), #exp) + 1); \ sprintf(str, "%s (%s) %s", #var, sol_int_format(var), #exp); \ SOL_WRN(str, var); \ return __VA_ARGS__; \ } \ } while (0) #define SOL_INT_CHECK_GOTO_IMPL(var, exp, label) \ do { \ if (SOL_UNLIKELY((var)exp)) { \ char *str = (char *)alloca(snprintf(NULL, 0, "%s (%s) %s", #var, sol_int_format(var), #exp) + 1); \ sprintf(str, "%s (%s) %s", #var, sol_int_format(var), #exp); \ SOL_WRN(str, var); \ goto label; \ } \ } while (0) #define SOL_INT_CHECK_GOTO_IMPL_ERRNO(var, exp, err, label) \ do { \ if (SOL_UNLIKELY((var)exp)) { \ char *str = (char *)alloca(snprintf(NULL, 0, "%s (%s) %s", \ # var, sol_int_format(var), # exp) + 1); \ sprintf(str, "%s (%s) %s", # var, sol_int_format(var), # exp); \ SOL_WRN(str, var); \ errno = err; \ goto label; \ } \ } while (0) #define SOL_INT_CHECK_IMPL_ERRNO(var, exp, err, ...) \ do { \ if (SOL_UNLIKELY((var)exp)) { \ char *str = (char *)alloca(snprintf(NULL, 0, "%s (%s) %s", \ # var, sol_int_format(var), # exp) + 1); \ sprintf(str, "%s (%s) %s", # var, sol_int_format(var), # exp); \ SOL_WRN(str, var); \ errno = err; \ return __VA_ARGS__; \ } \ } while (0) #else /** * @brief Auxiliary macro intended to be used by @ref SOL_INT_CHECK to format it's output. * * @param var Integer checked by @ref SOL_INT_CHECK */ #define _SOL_INT_CHECK_FMT(var) \ __builtin_choose_expr( \ __builtin_types_compatible_p(__typeof__(var), int), \ "" # var " (%d) %s", \ __builtin_choose_expr( \ __builtin_types_compatible_p(__typeof__(var), long), \ "" # var " (%ld) %s", \ __builtin_choose_expr( \ __builtin_types_compatible_p(__typeof__(var), size_t), \ "" # var " (%zu) %s", \ __builtin_choose_expr( \ __builtin_types_compatible_p(__typeof__(var), unsigned), \ "" # var " (%u) %s", \ __builtin_choose_expr( \ __builtin_types_compatible_p(__typeof__(var), uint64_t), \ "" # var " (%" PRIu64 ") %s", \ __builtin_choose_expr( \ __builtin_types_compatible_p(__typeof__(var), uint32_t), \ "" # var " (%" PRIu32 ") %s", \ __builtin_choose_expr( \ __builtin_types_compatible_p(__typeof__(var), uint16_t), \ "" # var " (%" PRIu16 ") %s", \ __builtin_choose_expr( \ __builtin_types_compatible_p(__typeof__(var), uint8_t), \ "" # var " (%" PRIu8 ") %s", \ __builtin_choose_expr( \ __builtin_types_compatible_p(__typeof__(var), int64_t), \ "" # var " (%" PRId64 ") %s", \ __builtin_choose_expr( \ __builtin_types_compatible_p(__typeof__(var), int32_t), \ "" # var " (%" PRId32 ") %s", \ __builtin_choose_expr( \ __builtin_types_compatible_p(__typeof__(var), int16_t), \ "" # var " (%" PRId16 ") %s", \ __builtin_choose_expr( \ __builtin_types_compatible_p(__typeof__(var), int8_t), \ "" # var " (%" PRId8 ") %s", \ __builtin_choose_expr( \ __builtin_types_compatible_p(__typeof__(var), ssize_t), \ "" # var " (%zd) %s", \ (void)0))))))))))))) #define SOL_INT_CHECK_IMPL(var, exp, ...) \ do { \ if (SOL_UNLIKELY((var)exp)) { \ SOL_WRN(_SOL_INT_CHECK_FMT(var), var, # exp); \ return __VA_ARGS__; \ } \ } while (0) #define SOL_INT_CHECK_GOTO_IMPL(var, exp, label) \ do { \ if (SOL_UNLIKELY((var)exp)) { \ SOL_WRN(_SOL_INT_CHECK_FMT(var), var, # exp); \ goto label; \ } \ } while (0) #define SOL_INT_CHECK_GOTO_IMPL_ERRNO(var, exp, err, label) \ do { \ if (SOL_UNLIKELY((var)exp)) { \ SOL_WRN(_SOL_INT_CHECK_FMT(var), var, # exp); \ errno = err; \ goto label; \ } \ } while (0) #define SOL_INT_CHECK_IMPL_ERRNO(var, exp, err, ...) \ do { \ if (SOL_UNLIKELY((var)exp)) { \ SOL_WRN(_SOL_INT_CHECK_FMT(var), var, # exp); \ errno = err; \ return __VA_ARGS__; \ } \ } while (0) #endif #ifdef __cplusplus extern "C" { #endif /** * @file * @brief These routines are used for Soletta logging. */ /** * @defgroup Log Logging * * @{ */ /** * @defgroup Colors Colors * * @brief ANSI/VT100 colors as understood by most consoles and terminals. * * @{ */ #define SOL_LOG_COLOR_LIGHTRED "\033[31;1m" /**< @brief Light Red color code */ #define SOL_LOG_COLOR_RED "\033[31m" /**< @brief Red color code */ #define SOL_LOG_COLOR_LIGHTBLUE "\033[34;1m" /**< @brief Light Blue color code */ #define SOL_LOG_COLOR_BLUE "\033[34m" /**< @brief Blue color code */ #define SOL_LOG_COLOR_GREEN "\033[32;1m" /**< @brief Green color code */ #define SOL_LOG_COLOR_YELLOW "\033[33;1m" /**< @brief Yellow color code */ #define SOL_LOG_COLOR_ORANGE "\033[0;33m" /**< @brief Orange color code */ #define SOL_LOG_COLOR_WHITE "\033[37;1m" /**< @brief White color code */ #define SOL_LOG_COLOR_LIGHTMAGENTA "\033[35;1m" /**< @brief Light Magenta color code */ #define SOL_LOG_COLOR_MAGENTA "\033[35m" /**< @brief Magenta color code */ #define SOL_LOG_COLOR_LIGHTCYAN "\033[36;1m" /**< @brief Light Cyan color code */ #define SOL_LOG_COLOR_CYAN "\033[36m" /**< @brief Cyan color code */ #define SOL_LOG_COLOR_RESET "\033[0m" /**< @brief Code to Reset the color to default */ #define SOL_LOG_COLOR_HIGH "\033[1m" /**< @brief Highlight code */ /** * @} */ /** * @brief Convenience macro to check for @c NULL pointer. * * This macro logs a warning message and returns if the pointer @c ptr * happens to be @c NULL. * * @param ptr Pointer to check * @param ... Optional return value */ #define SOL_NULL_CHECK(ptr, ...) \ do { \ if (SOL_UNLIKELY(!(ptr))) { \ SOL_WRN("%s == NULL", # ptr); \ return __VA_ARGS__; \ } \ } while (0) /** * @brief Convenience macro to check for @c NULL pointer (and set @c * errno). * * This macro logs a warning message and returns if the pointer @a ptr * happens to be @c NULL. Additionally, it sets the @c errno variable * to @a err. * * @param ptr Pointer to check * @param err @c errno value to set * @param ... Optional return value */ #define SOL_NULL_CHECK_ERRNO(ptr, err, ...) \ do { \ if (SOL_UNLIKELY(!(ptr))) { \ SOL_WRN("%s == NULL", # ptr); \ errno = err; \ return __VA_ARGS__; \ } \ } while (0) /** * @brief Convenience macro to check for @c NULL pointer and jump to a given label. * * This macro logs a warning message and jumps to @c label if the pointer @c ptr * happens to be @c NULL. * * @param ptr Pointer to check * @param label @c goto label * @param ... Optional return value */ #define SOL_NULL_CHECK_GOTO(ptr, label) \ do { \ if (SOL_UNLIKELY(!(ptr))) { \ SOL_WRN("%s == NULL", # ptr); \ goto label; \ } \ } while (0) /** * @brief Similar to @ref SOL_NULL_CHECK but allowing for a custom warning message. * * @param ptr Pointer to check * @param ret Value to return * @param fmt A standard 'printf()' format string * @param ... The arguments for @c fmt * * @see SOL_NULL_CHECK */ #define SOL_NULL_CHECK_MSG(ptr, ret, fmt, ...) \ do { \ if (SOL_UNLIKELY(!(ptr))) { \ SOL_WRN(fmt, ## __VA_ARGS__); \ return ret; \ } \ } while (0) /** * @brief Similar to @ref SOL_NULL_CHECK_GOTO but allowing for a custom warning message. * * @param ptr Pointer to check * @param label @c goto label * @param fmt A standard 'printf()' format string * @param ... The arguments for @c fmt * * @see SOL_NULL_CHECK_GOTO */ #define SOL_NULL_CHECK_MSG_GOTO(ptr, label, fmt, ...) \ do { \ if (SOL_UNLIKELY(!(ptr))) { \ SOL_WRN(fmt, ## __VA_ARGS__); \ goto label; \ } \ } while (0) /** * @brief Safety-check macro to check if integer @c var against @c exp. * * This macro logs a warning message and returns if the integer @c var * satisfies the expression @c exp. * * @param var Integer to be check * @param exp Safety-check expression * @param ... Optional return value */ #define SOL_INT_CHECK(var, exp, ...) \ SOL_INT_CHECK_IMPL(var, exp, __VA_ARGS__) /** * @brief Safety-check macro to check if integer @c var against @c exp * (and set @c errno). * * This macro logs a warning message and returns if the integer @a var * satisfies the expression @c exp. Additionally, it sets the @c errno variable * to @a err. * * @param var Integer to be check * @param exp Safety-check expression * @param err @c errno value to set * @param ... Optional return value */ #define SOL_INT_CHECK_ERRNO(var, exp, err, ...) \ SOL_INT_CHECK_IMPL_ERRNO(var, exp, err, __VA_ARGS__) /** * @brief Similar to @ref SOL_INT_CHECK but jumping to @c label instead of returning. * * This macro logs a warning message and jumps to @c label if the integer @c var * satisfies the expression @c exp. * * @param var Integer to be check * @param exp Safety-check expression * @param label @c goto label */ #define SOL_INT_CHECK_GOTO(var, exp, label) \ SOL_INT_CHECK_GOTO_IMPL(var, exp, label) /** * @brief Similar to @ref SOL_INT_CHECK but jumping to @c label * instead of returning (and setting @c errno value). * * This macro logs a warning message and jumps to @c label if the * integer @c var satisfies the expression @c exp. Additionally, it * sets the @c errno variable to @a err. * * @param var Integer to be check * @param exp Safety-check expression * @param err @c errno value to set * @param label @c goto label */ #define SOL_INT_CHECK_GOTO_ERRNO(var, exp, err, label) \ SOL_INT_CHECK_GOTO_IMPL_ERRNO(var, exp, label) /** * @brief Safety-check macro to check the expression @c exp. * * This macro logs a warning message and returns if the expression @c exp * is @c true. * * @param exp Safety-check expression * @param ... Optional return value */ #define SOL_EXP_CHECK(exp, ...) \ do { \ if (SOL_UNLIKELY((exp))) { \ SOL_WRN("(%s) is true", # exp); \ return __VA_ARGS__; \ } \ } while (0) /** * @brief Similar to @ref SOL_EXP_CHECK but jumping to @c label instead of returning. * * This macro logs a warning message and jumps to @c label if the expression @c exp * is @c true. * * @param exp Safety-check expression * @param label @c goto label */ #define SOL_EXP_CHECK_GOTO(exp, label) \ do { \ if (SOL_UNLIKELY((exp))) { \ SOL_WRN("(%s) is true", # exp); \ goto label; \ } \ } while (0) /** * @brief Available logging levels. * * Levels are use to identify the severity of the issue related to a given log message. */ enum sol_log_level { SOL_LOG_LEVEL_CRITICAL = 0, /**< @brief Critical */ SOL_LOG_LEVEL_ERROR, /**< @brief Error */ SOL_LOG_LEVEL_WARNING, /**< @brief Warning */ SOL_LOG_LEVEL_INFO, /**< @brief Informational */ SOL_LOG_LEVEL_DEBUG /**< @brief Debug */ }; /** * @brief Structure containing the attributes of the domain used for logging. */ typedef struct sol_log_domain { const char *color; /**< @brief Color to be used */ const char *name; /**< @brief Domain name */ uint8_t level; /**< @brief Maximum level to log for this domain */ } sol_log_domain; /** * @brief Global logging domain. * * Log domain is a way to provide a scope or category to messages that can * be used for filtering in addition to log levels. */ extern struct sol_log_domain *sol_log_global_domain; /** * @fn void sol_log_domain_init_level(struct sol_log_domain *domain) * * @brief Initialize domain log level based on system configuration. * * The system configuration may be environment variables like @c * $SOL_LOG_LEVEL=NUMBER (or sol_log_set_level()) to apply for all or @c * $SOL_LOG_LEVELS=\<domain1_name\>:\<domain1_level\>,\<domainN_name\>:\<domainN_level\> * to give each domain its specific level. * * @param domain the structure to fill @c level with system configuration value. * * @see sol_log_set_level() */ /** * @def SOL_LOG_LEVEL_INIT() * * @brief Sets the global log level based on the SOL_LOG_LEVEL macro. * * Not to be used directly. Applications using #SOL_MAIN_DEFAULT can be built * passing -DSOL_LOG_LEVEL=\"level\" on @c CFLAGS, in which case this macro * will initialize the global log level to the value the macro is defined to. */ /** * @def SOL_LOG_LEVELS_INIT() * * @brief Sets the log level of the given log domains. * * Not to be used directly. Applications using #SOL_MAIN_DEFAULT can be built * passing -DSOL_LOG_LEVELS=\"domain:level,...\" on @c CFLAGS, in which case * this macro will initialize each domain's log level to the values specified * in the macro. */ #ifdef SOL_LOG_ENABLED void sol_log_domain_init_level(struct sol_log_domain *domain); void sol_log_init_level_global(const char *str, size_t length); void sol_log_init_levels(const char *str, size_t length); #ifdef SOL_LOG_LEVEL #define SOL_LOG_LEVEL_INIT() \ sol_log_init_level_global(SOL_LOG_LEVEL, sizeof(SOL_LOG_LEVEL) - 1) #else #define SOL_LOG_LEVEL_INIT() #endif #ifdef SOL_LOG_LEVELS #define SOL_LOG_LEVELS_INIT() \ sol_log_init_levels(SOL_LOG_LEVELS, sizeof(SOL_LOG_LEVELS) - 1) #else #define SOL_LOG_LEVELS_INIT() #endif #else static inline void sol_log_domain_init_level(struct sol_log_domain *domain) { } #define SOL_LOG_LEVEL_INIT() #define SOL_LOG_LEVELS_INIT() #endif #ifndef SOL_LOG_DOMAIN /** * @def SOL_LOG_DOMAIN * * @brief Defines the default log domain that is used by SOL_LOG(), * SOL_CRI(), SOL_ERR(), SOL_WRN(), SOL_INF() and SOL_DBG(). * * If not set prior to inclusion of sol-log.h, then * sol_log_global_domain is used. * * It can be used to provide custom log domains for nodes and modules. */ #define SOL_LOG_DOMAIN sol_log_global_domain #endif /** * @def SOL_LOG_LEVEL_MAXIMUM * * @brief Ensures a maximum log level. * * If defined, this level will be ensured before sol_log_print() is * called by SOL_LOG(), SOL_CRI(), SOL_ERR(), SOL_WRN(), SOL_INF() and * SOL_DBG(), which will avoid calling sol_log_print() at all and since * it is comparing two constants the compiler will optimize out the * block, effectively removing such code (and associated string) from * the output binary. * * One should check using SOL_LOG_LEVEL_POSSIBLE(). * * It only affects log levels in the library functions. * If an application is using Soletta log system, it * needs to be changed using application CFLAGS. * * So to disable all log levels greater than warning on application build: * CFLAGS += -DSOL_LOG_LEVEL_MAXIMUM=2 */ #if 0 #define SOL_LOG_LEVEL_MAXIMUM SOL_LOG_LEVEL_WARNING #endif /** * @def SOL_LOG_LEVEL_POSSIBLE(level) * * @brief Check if log level is possible. * * If #SOL_LOG_LEVEL_MAXIMUM is set, it should be less or equal to it, * otherwise it is always impossible. */ #ifdef SOL_LOG_ENABLED #ifdef SOL_LOG_LEVEL_MAXIMUM #define SOL_LOG_LEVEL_POSSIBLE(level) (level <= SOL_LOG_LEVEL_MAXIMUM) #else #define SOL_LOG_LEVEL_POSSIBLE(level) (1) #endif #else #ifdef SOL_LOG_LEVEL_MAXIMUM #undef SOL_LOG_LEVEL_MAXIMUM #endif #define SOL_LOG_LEVEL_MAXIMUM -1 #define SOL_LOG_LEVEL_POSSIBLE(level) (0) #endif /** * @def SOL_LOG_FILE * * @brief Macro defining what to log for file entries * * Set at build time. By default, it's set to @c __FILE__, i.e. the * file name of the log call entry will be part of the log (and thus * take part in the final Soletta binary/image). One can disable that * behavior, though, when it'll be set to @c NULL (and no file name * will take part in the log entries). */ #ifdef SOL_LOG_FILES #define SOL_LOG_FILE __FILE__ #else #define SOL_LOG_FILE "" #endif /** * @def SOL_LOG_FUNCTION * * @brief Macro defining what to log for function entries * * Set at build time. By default, it's set to @c __PRETTY_FUNCTION__, * i.e. the function name of the log call entry will be part of the * log (and thus take part in the final Soletta binary/image). One can * disable that behavior, though, when it'll be set to @c NULL (and no * function name will take part in the log entries). */ #ifdef SOL_LOG_FUNCTIONS #define SOL_LOG_FUNCTION __PRETTY_FUNCTION__ #else #define SOL_LOG_FUNCTION "" #endif /** * @def SOL_LOG(level, fmt, ...) * * @brief Logs to #SOL_LOG_DOMAIN using the given level and * format message. * * Also uses the current source file, line and function. * * @see SOL_CRI(), SOL_ERR(), SOL_WRN(), SOL_INF() and SOL_DBG(). */ #define SOL_LOG(level, fmt, ...) \ do { \ if (SOL_LOG_LEVEL_POSSIBLE(level)) { \ sol_log_print(SOL_LOG_DOMAIN, level, \ SOL_LOG_FILE, SOL_LOG_FUNCTION, __LINE__, \ fmt, ## __VA_ARGS__); \ } \ } while (0) /** * @def SOL_CRI(fmt, ...) * * @brief Logs a message with @c critical level. * * Logs a critical message to the #SOL_LOG_DOMAIN using the * given format message, as well as using current source file, line * and function. * * @see SOL_LOG(), SOL_ERR(), SOL_WRN(), SOL_INF() and SOL_DBG(). */ #define SOL_CRI(fmt, ...) SOL_LOG(SOL_LOG_LEVEL_CRITICAL, fmt, ## __VA_ARGS__) /** * @def SOL_ERR(fmt, ...) * * @brief Logs a message with @c error level. * * Logs an error message to the #SOL_LOG_DOMAIN using the * given format message, as well as using current source file, line * and function. * * @see SOL_LOG(), SOL_CRI(), SOL_WRN(), SOL_INF() and SOL_DBG(). */ #define SOL_ERR(fmt, ...) SOL_LOG(SOL_LOG_LEVEL_ERROR, fmt, ## __VA_ARGS__) /** * @def SOL_WRN(fmt, ...) * * @brief Logs a message with @c warning level. * * Logs a warning message to the #SOL_LOG_DOMAIN using the * given format message, as well as using current source file, line * and function. * * @see SOL_LOG(), SOL_CRI(), SOL_ERR(), SOL_INF() and SOL_DBG(). */ #define SOL_WRN(fmt, ...) SOL_LOG(SOL_LOG_LEVEL_WARNING, fmt, ## __VA_ARGS__) /** * @def SOL_INF(fmt, ...) * * @brief Logs a message with @c informational level. * * Logs an informational message to the #SOL_LOG_DOMAIN * using the given format message, as well as using current source * file, line and function. * * @see SOL_LOG(), SOL_CRI(), SOL_ERR(), SOL_WRN() and SOL_DBG(). */ #define SOL_INF(fmt, ...) SOL_LOG(SOL_LOG_LEVEL_INFO, fmt, ## __VA_ARGS__) /** * @def SOL_DBG(fmt, ...) * * @brief Logs a message with @c debug level. * * Logs a debug message to the #SOL_LOG_DOMAIN using the * given format message, as well as using current source file, line * and function. * * @see SOL_LOG(), SOL_CRI(), SOL_ERR(), SOL_WRN() and SOL_INF(). */ #define SOL_DBG(fmt, ...) SOL_LOG(SOL_LOG_LEVEL_DEBUG, fmt, ## __VA_ARGS__) /** * @fn void sol_log_print(const struct sol_log_domain *domain, uint8_t message_level, * const char *file, const char *function, int line, const char *format, ...) * * @brief Print out a message in a given domain and level. * * This function will print out the given message only if the given * domain's level is greater or equal to the @a message_level. Then it * will call the current print function as set by * sol_log_set_print_function(), which defaults to * sol_log_print_function_stderr(). * * Some environment variables affect the behavior: * @li @c $SOL_LOG_ABORT=LEVEL if @a message_level is less or equal to * @c LEVEL, then the program will abort execution with * abort(3). Say @c $SOL_LOG_ABORT=ERROR, then it will abort on * #SOL_LOG_LEVEL_CRITICAL or #SOL_LOG_LEVEL_ERROR. * @li @c $SOL_LOG_SHOW_COLORS=[0|1] will disable or enable the color * output in functions that support it such as * sol_log_print_function_stderr(). Defaults to enabled if * terminal supports it. * @li @c $SOL_LOG_SHOW_FILE=[0|1] will disable or enable the file name * in output. Enabled by default. * @li @c $SOL_LOG_SHOW_FUNCTION=[0|1] will disable or enable the * function name in output. Enabled by default. * @li @c $SOL_LOG_SHOW_LINE=[0|1] will disable or enable the line * number in output. Enabled by default. * * @note use the SOL_LOG(), SOL_CRI(), SOL_ERR(), SOL_WRN(), SOL_INF() or * SOL_DBG() macros instead of this one, it should be easier to * deal with. * * @param domain where the message belongs to. * @param message_level the level of the message such as #SOL_LOG_LEVEL_ERROR. * @param file the source file name that originated the message. * @param function the function that originated the message. * @param line the source file line number that originated the message. * @param format printf(3) format string for the extra arguments. It * does not need trailing "\n" as this will be enforced. * * @see sol_log_set_level() * @see sol_log_set_abort_level() */ /** * @fn void sol_log_vprint(const struct sol_log_domain *domain, uint8_t message_level, * const char *file, const char *function, int line, const char *format, va_list args) * * @brief Similar to @ref sol_log_print, but called with @c va_list instead of a variable number of arguments. * * @param domain where the message belongs to. * @param message_level the level of the message such as #SOL_LOG_LEVEL_ERROR. * @param file the source file name that originated the message. * @param function the function that originated the message. * @param line the source file line number that originated the message. * @param format printf(3) format string for the extra arguments. It * does not need trailing "\n" as this will be enforced. * @param args Variables list. */ #ifdef SOL_LOG_ENABLED void sol_log_print(const struct sol_log_domain *domain, uint8_t message_level, const char *file, const char *function, int line, const char *format, ...) SOL_ATTR_PRINTF(6, 7) SOL_ATTR_NO_INSTRUMENT; void sol_log_vprint(const struct sol_log_domain *domain, uint8_t message_level, const char *file, const char *function, int line, const char *format, va_list args) SOL_ATTR_PRINTF(6, 0) SOL_ATTR_NO_INSTRUMENT; #else static inline void sol_log_print(const struct sol_log_domain *domain, uint8_t message_level, const char *file, const char *function, int line, const char *format, ...) { } static inline void sol_log_vprint(const struct sol_log_domain *domain, uint8_t message_level, const char *file, const char *function, int line, const char *format, va_list args) { } #endif /** * @brief Set the function to print out log messages. * * The function will be called with sanitized values for @a domain, @a * file, @a function, @a format. * * The function is called with the first argument @c data being the * same pointer given to this function as @a data parameter. * * @note The function is called with a lock held if threads are * enabled. Then you should not trigger sol_log functions from * inside it! * * @param print the function to use to print out messages. If @c NULL, * then sol_log_print_function_stderr() is used. * @param data the context to give back to @a print when it is called. */ #ifdef SOL_LOG_ENABLED void sol_log_set_print_function(void (*print)(void *data, const struct sol_log_domain *domain, uint8_t message_level, const char *file, const char *function, int line, const char *format, va_list args), const void *data); #else static inline void sol_log_set_print_function(void (*print)(void *data, const struct sol_log_domain *domain, uint8_t message_level, const char *file, const char *function, int line, const char *format, va_list args), const void *data) { } #endif /** * @brief Standard logging function that send to standard error output. * * This function must exist in every platform and is the default if no * custom function is set. * * @see sol_log_set_print_function() */ #ifdef SOL_LOG_ENABLED void sol_log_print_function_stderr(void *data, const struct sol_log_domain *domain, uint8_t message_level, const char *file, const char *function, int line, const char *format, va_list args) SOL_ATTR_PRINTF(7, 0); #else static inline void sol_log_print_function_stderr(void *data, const struct sol_log_domain *domain, uint8_t message_level, const char *file, const char *function, int line, const char *format, va_list args) { } #endif #ifdef SOL_PLATFORM_LINUX /** * @fn void sol_log_print_function_file(void *data, const struct sol_log_domain *domain, * uint8_t message_level, const char *file, const char *function, * int line, const char *format, * va_list args) * * @brief Log to a file. * * The first parameter must be a pointer to FILE* previously opened * with fopen(), it should be set as the @c "data" parameter of * sol_log_set_print_function(). * * @see sol_log_set_print_function() */ #ifdef SOL_LOG_ENABLED void sol_log_print_function_file(void *data, const struct sol_log_domain *domain, uint8_t message_level, const char *file, const char *function, int line, const char *format, va_list args) SOL_ATTR_PRINTF(7, 0); #else static inline void sol_log_print_function_file(void *data, const struct sol_log_domain *domain, uint8_t message_level, const char *file, const char *function, int line, const char *format, va_list args) { } #endif #endif #ifdef SOL_PLATFORM_LINUX /** * @fn void sol_log_print_function_syslog(void *data, const struct sol_log_domain *domain, * uint8_t message_level, const char *syslog, const char *function, int line, const char *format, * va_list args) * @brief Log to syslog. * * This function will use vsyslog(), translate sol_log_level to * syslog's priority and send the message to the daemon. * * This function is used automatically if there is an environment * variable $SOL_LOG_PRINT_FUNCTION=syslog. * * @see sol_log_set_print_function() * @see sol_log_print_function_journal() */ #ifdef SOL_LOG_ENABLED void sol_log_print_function_syslog(void *data, const struct sol_log_domain *domain, uint8_t message_level, const char *syslog, const char *function, int line, const char *format, va_list args) SOL_ATTR_PRINTF(7, 0); #else static inline void sol_log_print_function_syslog(void *data, const struct sol_log_domain *domain, uint8_t message_level, const char *syslog, const char *function, int line, const char *format, va_list args) { } #endif #endif #ifdef SOL_PLATFORM_LINUX /** * @fn void sol_log_print_function_journal(void *data, const struct sol_log_domain *domain, * uint8_t message_level, const char *journal, const char *function, int line, const char *format, * va_list args) * * @brief Log to systemd's journal. * * This function will use sd_journal_send_with_location() to * communicate with systemd's journald daemon and it will use * journal's extended capabilities, such as logging the source file * name, line and function, as well as thread id (if pthread is * enabled). * * If systemd support was not compiled in, then it will use syslog. * * This function is used automatically if there is an environment * variable $NOTIFY_SOCKET or $SOL_LOG_PRINT_FUNCTION=journal. * * @see sol_log_set_print_function() * @see sol_log_print_function_syslog() */ #ifdef SOL_LOG_ENABLED void sol_log_print_function_journal(void *data, const struct sol_log_domain *domain, uint8_t message_level, const char *journal, const char *function, int line, const char *format, va_list args) SOL_ATTR_PRINTF(7, 0); #else static inline void sol_log_print_function_journal(void *data, const struct sol_log_domain *domain, uint8_t message_level, const char *journal, const char *function, int line, const char *format, va_list args) { } #endif #endif /** * @fn void sol_log_level_to_str(uint8_t level, char *buf, size_t buflen) * * @brief Convenience function to convert the logging @c level to string. * * @param level Logging level * @param buf Where to write the string * @param buflen Buffer size */ /** * @fn const char *sol_log_get_level_color(uint8_t level) * * @brief Get the color code used for the given logging level @c level. * * @param level Logging level * * @return Color code string */ /** * @fn uint8_t sol_log_get_abort_level(void) * * @brief Get the logging level that triggers the program to abort. * * @return The logging level */ /** * @fn uint8_t sol_log_get_level(void) * * @brief Get the maximum log level allowed. * * @return The logging level */ /** * @fn bool sol_log_get_show_colors(void) * * @brief Get if color output is enabled or not. * * @return @c true if enabled, @c false otherwise */ /** * @fn bool sol_log_get_show_file(void) * * @brief Get if showing source file's name is enabled or not. * * @return @c true if enabled, @c false otherwise */ /** * @fn bool sol_log_get_show_function(void) * * @brief Get if showing function's name is enabled or not. * * @return @c true if enabled, @c false otherwise */ /** * @fn bool sol_log_get_show_line(void) * * @brief Get if showing the line number is enabled or not. * * @return @c true if enabled, @c false otherwise */ /** * @fn void sol_log_set_abort_level(uint8_t level) * * @brief Set the logging level that should trigger the program to abort. * * @param level Logging level */ /** * @fn void sol_log_set_level(uint8_t level) * * @brief Set the global domain maximum level to @c level. * * @param level Logging level */ /** * @fn void sol_log_set_show_colors(bool enabled) * * @brief Enable/Disables the use of colors in logging messages. * * @param enabled Enables color if @c true, disables if @c false */ /** * @fn void sol_log_set_show_file(bool enabled) * * @brief Enable/Disables the output of source file's name in logging messages. * * @param enabled Enables file's name output if @c true, disables if @c false */ /** * @fn void sol_log_set_show_function(bool enabled) * * @brief Enable/Disables the output of function's name containing the logging messages. * * @param enabled Enables function's name output if @c true, disables if @c false */ /** * @fn void sol_log_set_show_line(bool enabled) * * @brief Enable/Disables the output of the line number in logging messages. * * @param enabled Enables line number output if @c true, disables if @c false */ #ifdef SOL_LOG_ENABLED /* * Those implementing custom logging functions may use the following getters */ void sol_log_level_to_str(uint8_t level, char *buf, size_t buflen); const char *sol_log_get_level_color(uint8_t level); uint8_t sol_log_get_abort_level(void); uint8_t sol_log_get_level(void); bool sol_log_get_show_colors(void); bool sol_log_get_show_file(void); bool sol_log_get_show_function(void); bool sol_log_get_show_line(void); /* * To force some logging setting independent of platform initializations, * use the following setters */ void sol_log_set_abort_level(uint8_t level); void sol_log_set_level(uint8_t level); void sol_log_set_show_colors(bool enabled); void sol_log_set_show_file(bool enabled); void sol_log_set_show_function(bool enabled); void sol_log_set_show_line(bool enabled); #else static inline void sol_log_level_to_str(uint8_t level, char *buf, size_t buflen) { } static inline const char * sol_log_get_level_color(uint8_t level) { return ""; } static inline uint8_t sol_log_get_abort_level(void) { return 0; } static inline uint8_t sol_log_get_level(void) { return 0; } static inline bool sol_log_get_show_colors(void) { return false; } static inline bool sol_log_get_show_file(void) { return false; } static inline bool sol_log_get_show_function(void) { return false; } static inline bool sol_log_get_show_line(void) { return false; } static inline void sol_log_set_abort_level(uint8_t level) { } static inline void sol_log_set_level(uint8_t level) { } static inline void sol_log_set_show_colors(bool enabled) { } static inline void sol_log_set_show_file(bool enabled) { } static inline void sol_log_set_show_function(bool enabled) { } static inline void sol_log_set_show_line(bool enabled) { } #endif /** * @} */ #ifdef __cplusplus } #endif
31.584332
221
0.687502
0a4ae18aa9a76bddafcc0e53de5b49c325d8815a
69,054
h
C
include/qt5xhb_macros_qtgui.h
marcosgambeta/Qt5xHb-cpp11
aaae121a2cb36c88a8f205503073aee0da4fa069
[ "MIT" ]
null
null
null
include/qt5xhb_macros_qtgui.h
marcosgambeta/Qt5xHb-cpp11
aaae121a2cb36c88a8f205503073aee0da4fa069
[ "MIT" ]
null
null
null
include/qt5xhb_macros_qtgui.h
marcosgambeta/Qt5xHb-cpp11
aaae121a2cb36c88a8f205503073aee0da4fa069
[ "MIT" ]
null
null
null
/* Qt5xHb/C++11 - Bindings libraries for Harbour/xHarbour and Qt Framework 5 Copyright (C) 2022 Marcos Antonio Gambeta <marcosgambeta AT outlook DOT com> */ /* DO NOT EDIT THIS FILE - the content was created using a source code generator */ #ifndef QT5XHB_MACROS_QTGUI_H #define QT5XHB_MACROS_QTGUI_H #define ISQABSTRACTTEXTDOCUMENTLAYOUT( n ) Qt5xHb::isObjectDerivedFrom( n, "QAbstractTextDocumentLayout" ) #define ISQABSTRACTUNDOITEM( n ) Qt5xHb::isObjectDerivedFrom( n, "QAbstractUndoItem" ) #define ISQACCESSIBLE( n ) Qt5xHb::isObjectDerivedFrom( n, "QAccessible" ) #define ISQACCESSIBLEACTIONINTERFACE( n ) Qt5xHb::isObjectDerivedFrom( n, "QAccessibleActionInterface" ) #define ISQACCESSIBLEAPPLICATION( n ) Qt5xHb::isObjectDerivedFrom( n, "QAccessibleApplication" ) #define ISQACCESSIBLEBRIDGE( n ) Qt5xHb::isObjectDerivedFrom( n, "QAccessibleBridge" ) #define ISQACCESSIBLEBRIDGEPLUGIN( n ) Qt5xHb::isObjectDerivedFrom( n, "QAccessibleBridgePlugin" ) #define ISQACCESSIBLEEDITABLETEXTINTERFACE( n ) Qt5xHb::isObjectDerivedFrom( n, "QAccessibleEditableTextInterface" ) #define ISQACCESSIBLEEVENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QAccessibleEvent" ) #define ISQACCESSIBLEIMAGEINTERFACE( n ) Qt5xHb::isObjectDerivedFrom( n, "QAccessibleImageInterface" ) #define ISQACCESSIBLEINTERFACE( n ) Qt5xHb::isObjectDerivedFrom( n, "QAccessibleInterface" ) #define ISQACCESSIBLEOBJECT( n ) Qt5xHb::isObjectDerivedFrom( n, "QAccessibleObject" ) #define ISQACCESSIBLEPLUGIN( n ) Qt5xHb::isObjectDerivedFrom( n, "QAccessiblePlugin" ) #define ISQACCESSIBLESTATECHANGEEVENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QAccessibleStateChangeEvent" ) #define ISQACCESSIBLETABLECELLINTERFACE( n ) Qt5xHb::isObjectDerivedFrom( n, "QAccessibleTableCellInterface" ) #define ISQACCESSIBLETABLEINTERFACE( n ) Qt5xHb::isObjectDerivedFrom( n, "QAccessibleTableInterface" ) #define ISQACCESSIBLETABLEMODELCHANGEEVENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QAccessibleTableModelChangeEvent" ) #define ISQACCESSIBLETEXTCURSOREVENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QAccessibleTextCursorEvent" ) #define ISQACCESSIBLETEXTINSERTEVENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QAccessibleTextInsertEvent" ) #define ISQACCESSIBLETEXTINTERFACE( n ) Qt5xHb::isObjectDerivedFrom( n, "QAccessibleTextInterface" ) #define ISQACCESSIBLETEXTREMOVEEVENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QAccessibleTextRemoveEvent" ) #define ISQACCESSIBLETEXTSELECTIONEVENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QAccessibleTextSelectionEvent" ) #define ISQACCESSIBLETEXTUPDATEEVENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QAccessibleTextUpdateEvent" ) #define ISQACCESSIBLEVALUECHANGEEVENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QAccessibleValueChangeEvent" ) #define ISQACCESSIBLEVALUEINTERFACE( n ) Qt5xHb::isObjectDerivedFrom( n, "QAccessibleValueInterface" ) #define ISQACTIONEVENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QActionEvent" ) #define ISQAPPLICATIONSTATECHANGEEVENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QApplicationStateChangeEvent" ) #define ISQBACKINGSTORE( n ) Qt5xHb::isObjectDerivedFrom( n, "QBackingStore" ) #define ISQBITMAP( n ) Qt5xHb::isObjectDerivedFrom( n, "QBitmap" ) #define ISQBRUSH( n ) Qt5xHb::isObjectDerivedFrom( n, "QBrush" ) #define ISQCLIPBOARD( n ) Qt5xHb::isObjectDerivedFrom( n, "QClipboard" ) #define ISQCLOSEEVENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QCloseEvent" ) #define ISQCOLOR( n ) Qt5xHb::isObjectDerivedFrom( n, "QColor" ) #define ISQCOLORSPACE( n ) Qt5xHb::isObjectDerivedFrom( n, "QColorSpace" ) #define ISQCONICALGRADIENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QConicalGradient" ) #define ISQCONTEXTMENUEVENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QContextMenuEvent" ) #define ISQCURSOR( n ) Qt5xHb::isObjectDerivedFrom( n, "QCursor" ) #define ISQDESKTOPSERVICES( n ) Qt5xHb::isObjectDerivedFrom( n, "QDesktopServices" ) #define ISQDOUBLEVALIDATOR( n ) Qt5xHb::isObjectDerivedFrom( n, "QDoubleValidator" ) #define ISQDRAG( n ) Qt5xHb::isObjectDerivedFrom( n, "QDrag" ) #define ISQDRAGENTEREVENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QDragEnterEvent" ) #define ISQDRAGLEAVEEVENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QDragLeaveEvent" ) #define ISQDRAGMOVEEVENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QDragMoveEvent" ) #define ISQDROPEVENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QDropEvent" ) #define ISQENTEREVENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QEnterEvent" ) #define ISQEXPOSEEVENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QExposeEvent" ) #define ISQFILEOPENEVENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QFileOpenEvent" ) #define ISQFOCUSEVENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QFocusEvent" ) #define ISQFONT( n ) Qt5xHb::isObjectDerivedFrom( n, "QFont" ) #define ISQFONTDATABASE( n ) Qt5xHb::isObjectDerivedFrom( n, "QFontDatabase" ) #define ISQFONTINFO( n ) Qt5xHb::isObjectDerivedFrom( n, "QFontInfo" ) #define ISQFONTMETRICS( n ) Qt5xHb::isObjectDerivedFrom( n, "QFontMetrics" ) #define ISQFONTMETRICSF( n ) Qt5xHb::isObjectDerivedFrom( n, "QFontMetricsF" ) #define ISQGENERICPLUGIN( n ) Qt5xHb::isObjectDerivedFrom( n, "QGenericPlugin" ) #define ISQGENERICPLUGINFACTORY( n ) Qt5xHb::isObjectDerivedFrom( n, "QGenericPluginFactory" ) #define ISQGLYPHRUN( n ) Qt5xHb::isObjectDerivedFrom( n, "QGlyphRun" ) #define ISQGRADIENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QGradient" ) #define ISQGUIAPPLICATION( n ) Qt5xHb::isObjectDerivedFrom( n, "QGuiApplication" ) #define ISQHELPEVENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QHelpEvent" ) #define ISQHIDEEVENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QHideEvent" ) #define ISQHOVEREVENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QHoverEvent" ) #define ISQICON( n ) Qt5xHb::isObjectDerivedFrom( n, "QIcon" ) #define ISQICONDRAGEVENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QIconDragEvent" ) #define ISQICONENGINE( n ) Qt5xHb::isObjectDerivedFrom( n, "QIconEngine" ) #define ISQICONENGINEPLUGIN( n ) Qt5xHb::isObjectDerivedFrom( n, "QIconEnginePlugin" ) #define ISQIMAGE( n ) Qt5xHb::isObjectDerivedFrom( n, "QImage" ) #define ISQIMAGEIOHANDLER( n ) Qt5xHb::isObjectDerivedFrom( n, "QImageIOHandler" ) #define ISQIMAGEIOPLUGIN( n ) Qt5xHb::isObjectDerivedFrom( n, "QImageIOPlugin" ) #define ISQIMAGEREADER( n ) Qt5xHb::isObjectDerivedFrom( n, "QImageReader" ) #define ISQIMAGEWRITER( n ) Qt5xHb::isObjectDerivedFrom( n, "QImageWriter" ) #define ISQINPUTEVENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QInputEvent" ) #define ISQINPUTMETHOD( n ) Qt5xHb::isObjectDerivedFrom( n, "QInputMethod" ) #define ISQINPUTMETHODEVENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QInputMethodEvent" ) #define ISQINPUTMETHODQUERYEVENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QInputMethodQueryEvent" ) #define ISQINTVALIDATOR( n ) Qt5xHb::isObjectDerivedFrom( n, "QIntValidator" ) #define ISQKEYEVENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QKeyEvent" ) #define ISQKEYSEQUENCE( n ) Qt5xHb::isObjectDerivedFrom( n, "QKeySequence" ) #define ISQLINEARGRADIENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QLinearGradient" ) #define ISQMATRIX( n ) Qt5xHb::isObjectDerivedFrom( n, "QMatrix" ) #define ISQMATRIX4X4( n ) Qt5xHb::isObjectDerivedFrom( n, "QMatrix4x4" ) #define ISQMOUSEEVENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QMouseEvent" ) #define ISQMOVEEVENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QMoveEvent" ) #define ISQMOVIE( n ) Qt5xHb::isObjectDerivedFrom( n, "QMovie" ) #define ISQNATIVEGESTUREEVENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QNativeGestureEvent" ) #define ISQOFFSCREENSURFACE( n ) Qt5xHb::isObjectDerivedFrom( n, "QOffscreenSurface" ) #define ISQOPENGLBUFFER( n ) Qt5xHb::isObjectDerivedFrom( n, "QOpenGLBuffer" ) #define ISQOPENGLCONTEXT( n ) Qt5xHb::isObjectDerivedFrom( n, "QOpenGLContext" ) #define ISQOPENGLCONTEXTGROUP( n ) Qt5xHb::isObjectDerivedFrom( n, "QOpenGLContextGroup" ) #define ISQOPENGLDEBUGLOGGER( n ) Qt5xHb::isObjectDerivedFrom( n, "QOpenGLDebugLogger" ) #define ISQOPENGLDEBUGMESSAGE( n ) Qt5xHb::isObjectDerivedFrom( n, "QOpenGLDebugMessage" ) #define ISQOPENGLFRAMEBUFFEROBJECT( n ) Qt5xHb::isObjectDerivedFrom( n, "QOpenGLFramebufferObject" ) #define ISQOPENGLFRAMEBUFFEROBJECTFORMAT( n ) Qt5xHb::isObjectDerivedFrom( n, "QOpenGLFramebufferObjectFormat" ) #define ISQOPENGLPAINTDEVICE( n ) Qt5xHb::isObjectDerivedFrom( n, "QOpenGLPaintDevice" ) #define ISQOPENGLPIXELTRANSFEROPTIONS( n ) Qt5xHb::isObjectDerivedFrom( n, "QOpenGLPixelTransferOptions" ) #define ISQOPENGLSHADER( n ) Qt5xHb::isObjectDerivedFrom( n, "QOpenGLShader" ) #define ISQOPENGLSHADERPROGRAM( n ) Qt5xHb::isObjectDerivedFrom( n, "QOpenGLShaderProgram" ) #define ISQOPENGLTEXTURE( n ) Qt5xHb::isObjectDerivedFrom( n, "QOpenGLTexture" ) #define ISQOPENGLTIMEMONITOR( n ) Qt5xHb::isObjectDerivedFrom( n, "QOpenGLTimeMonitor" ) #define ISQOPENGLTIMERQUERY( n ) Qt5xHb::isObjectDerivedFrom( n, "QOpenGLTimerQuery" ) #define ISQOPENGLVERTEXARRAYOBJECT( n ) Qt5xHb::isObjectDerivedFrom( n, "QOpenGLVertexArrayObject" ) #define ISQPAGEDPAINTDEVICE( n ) Qt5xHb::isObjectDerivedFrom( n, "QPagedPaintDevice" ) #define ISQPAGELAYOUT( n ) Qt5xHb::isObjectDerivedFrom( n, "QPageLayout" ) #define ISQPAGESIZE( n ) Qt5xHb::isObjectDerivedFrom( n, "QPageSize" ) #define ISQPAINTDEVICE( n ) Qt5xHb::isObjectDerivedFrom( n, "QPaintDevice" ) #define ISQPAINTENGINE( n ) Qt5xHb::isObjectDerivedFrom( n, "QPaintEngine" ) #define ISQPAINTENGINESTATE( n ) Qt5xHb::isObjectDerivedFrom( n, "QPaintEngineState" ) #define ISQPAINTER( n ) Qt5xHb::isObjectDerivedFrom( n, "QPainter" ) #define ISQPAINTERPATH( n ) Qt5xHb::isObjectDerivedFrom( n, "QPainterPath" ) #define ISQPAINTERPATHSTROKER( n ) Qt5xHb::isObjectDerivedFrom( n, "QPainterPathStroker" ) #define ISQPAINTEVENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QPaintEvent" ) #define ISQPALETTE( n ) Qt5xHb::isObjectDerivedFrom( n, "QPalette" ) #define ISQPDFWRITER( n ) Qt5xHb::isObjectDerivedFrom( n, "QPdfWriter" ) #define ISQPEN( n ) Qt5xHb::isObjectDerivedFrom( n, "QPen" ) #define ISQPICTURE( n ) Qt5xHb::isObjectDerivedFrom( n, "QPicture" ) #define ISQPICTUREFORMATPLUGIN( n ) Qt5xHb::isObjectDerivedFrom( n, "QPictureFormatPlugin" ) #define ISQPICTUREIO( n ) Qt5xHb::isObjectDerivedFrom( n, "QPictureIO" ) #define ISQPIXMAP( n ) Qt5xHb::isObjectDerivedFrom( n, "QPixmap" ) #define ISQPIXMAPCACHE( n ) Qt5xHb::isObjectDerivedFrom( n, "QPixmapCache" ) #define ISQPOLYGON( n ) Qt5xHb::isObjectDerivedFrom( n, "QPolygon" ) #define ISQPOLYGONF( n ) Qt5xHb::isObjectDerivedFrom( n, "QPolygonF" ) #define ISQQUATERNION( n ) Qt5xHb::isObjectDerivedFrom( n, "QQuaternion" ) #define ISQRADIALGRADIENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QRadialGradient" ) #define ISQRAWFONT( n ) Qt5xHb::isObjectDerivedFrom( n, "QRawFont" ) #define ISQREGEXPVALIDATOR( n ) Qt5xHb::isObjectDerivedFrom( n, "QRegExpValidator" ) #define ISQREGION( n ) Qt5xHb::isObjectDerivedFrom( n, "QRegion" ) #define ISQREGULAREXPRESSIONVALIDATOR( n ) Qt5xHb::isObjectDerivedFrom( n, "QRegularExpressionValidator" ) #define ISQRESIZEEVENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QResizeEvent" ) #define ISQSCREEN( n ) Qt5xHb::isObjectDerivedFrom( n, "QScreen" ) #define ISQSCREENORIENTATIONCHANGEEVENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QScreenOrientationChangeEvent" ) #define ISQSCROLLEVENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QScrollEvent" ) #define ISQSCROLLPREPAREEVENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QScrollPrepareEvent" ) #define ISQSESSIONMANAGER( n ) Qt5xHb::isObjectDerivedFrom( n, "QSessionManager" ) #define ISQSHORTCUTEVENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QShortcutEvent" ) #define ISQSHOWEVENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QShowEvent" ) #define ISQSTANDARDITEM( n ) Qt5xHb::isObjectDerivedFrom( n, "QStandardItem" ) #define ISQSTANDARDITEMMODEL( n ) Qt5xHb::isObjectDerivedFrom( n, "QStandardItemModel" ) #define ISQSTATICTEXT( n ) Qt5xHb::isObjectDerivedFrom( n, "QStaticText" ) #define ISQSTATUSTIPEVENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QStatusTipEvent" ) #define ISQSTYLEHINTS( n ) Qt5xHb::isObjectDerivedFrom( n, "QStyleHints" ) #define ISQSURFACE( n ) Qt5xHb::isObjectDerivedFrom( n, "QSurface" ) #define ISQSURFACEFORMAT( n ) Qt5xHb::isObjectDerivedFrom( n, "QSurfaceFormat" ) #define ISQSYNTAXHIGHLIGHTER( n ) Qt5xHb::isObjectDerivedFrom( n, "QSyntaxHighlighter" ) #define ISQTABLETEVENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QTabletEvent" ) #define ISQTEXTBLOCK( n ) Qt5xHb::isObjectDerivedFrom( n, "QTextBlock" ) #define ISQTEXTBLOCKFORMAT( n ) Qt5xHb::isObjectDerivedFrom( n, "QTextBlockFormat" ) #define ISQTEXTBLOCKGROUP( n ) Qt5xHb::isObjectDerivedFrom( n, "QTextBlockGroup" ) #define ISQTEXTBLOCKUSERDATA( n ) Qt5xHb::isObjectDerivedFrom( n, "QTextBlockUserData" ) #define ISQTEXTCHARFORMAT( n ) Qt5xHb::isObjectDerivedFrom( n, "QTextCharFormat" ) #define ISQTEXTCURSOR( n ) Qt5xHb::isObjectDerivedFrom( n, "QTextCursor" ) #define ISQTEXTDOCUMENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QTextDocument" ) #define ISQTEXTDOCUMENTFRAGMENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QTextDocumentFragment" ) #define ISQTEXTDOCUMENTWRITER( n ) Qt5xHb::isObjectDerivedFrom( n, "QTextDocumentWriter" ) #define ISQTEXTFORMAT( n ) Qt5xHb::isObjectDerivedFrom( n, "QTextFormat" ) #define ISQTEXTFRAGMENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QTextFragment" ) #define ISQTEXTFRAME( n ) Qt5xHb::isObjectDerivedFrom( n, "QTextFrame" ) #define ISQTEXTFRAMEFORMAT( n ) Qt5xHb::isObjectDerivedFrom( n, "QTextFrameFormat" ) #define ISQTEXTFRAMELAYOUTDATA( n ) Qt5xHb::isObjectDerivedFrom( n, "QTextFrameLayoutData" ) #define ISQTEXTIMAGEFORMAT( n ) Qt5xHb::isObjectDerivedFrom( n, "QTextImageFormat" ) #define ISQTEXTINLINEOBJECT( n ) Qt5xHb::isObjectDerivedFrom( n, "QTextInlineObject" ) #define ISQTEXTITEM( n ) Qt5xHb::isObjectDerivedFrom( n, "QTextItem" ) #define ISQTEXTLAYOUT( n ) Qt5xHb::isObjectDerivedFrom( n, "QTextLayout" ) #define ISQTEXTLENGTH( n ) Qt5xHb::isObjectDerivedFrom( n, "QTextLength" ) #define ISQTEXTLINE( n ) Qt5xHb::isObjectDerivedFrom( n, "QTextLine" ) #define ISQTEXTLIST( n ) Qt5xHb::isObjectDerivedFrom( n, "QTextList" ) #define ISQTEXTLISTFORMAT( n ) Qt5xHb::isObjectDerivedFrom( n, "QTextListFormat" ) #define ISQTEXTOBJECT( n ) Qt5xHb::isObjectDerivedFrom( n, "QTextObject" ) #define ISQTEXTOBJECTINTERFACE( n ) Qt5xHb::isObjectDerivedFrom( n, "QTextObjectInterface" ) #define ISQTEXTOPTION( n ) Qt5xHb::isObjectDerivedFrom( n, "QTextOption" ) #define ISQTEXTTABLE( n ) Qt5xHb::isObjectDerivedFrom( n, "QTextTable" ) #define ISQTEXTTABLECELL( n ) Qt5xHb::isObjectDerivedFrom( n, "QTextTableCell" ) #define ISQTEXTTABLECELLFORMAT( n ) Qt5xHb::isObjectDerivedFrom( n, "QTextTableCellFormat" ) #define ISQTEXTTABLEFORMAT( n ) Qt5xHb::isObjectDerivedFrom( n, "QTextTableFormat" ) #define ISQTOOLBARCHANGEEVENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QToolBarChangeEvent" ) #define ISQTOUCHDEVICE( n ) Qt5xHb::isObjectDerivedFrom( n, "QTouchDevice" ) #define ISQTOUCHEVENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QTouchEvent" ) #define ISQTRANSFORM( n ) Qt5xHb::isObjectDerivedFrom( n, "QTransform" ) #define ISQVALIDATOR( n ) Qt5xHb::isObjectDerivedFrom( n, "QValidator" ) #define ISQVECTOR2D( n ) Qt5xHb::isObjectDerivedFrom( n, "QVector2D" ) #define ISQVECTOR3D( n ) Qt5xHb::isObjectDerivedFrom( n, "QVector3D" ) #define ISQVECTOR4D( n ) Qt5xHb::isObjectDerivedFrom( n, "QVector4D" ) #define ISQWHATSTHISCLICKEDEVENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QWhatsThisClickedEvent" ) #define ISQWHEELEVENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QWheelEvent" ) #define ISQWINDOW( n ) Qt5xHb::isObjectDerivedFrom( n, "QWindow" ) #define ISQWINDOWSTATECHANGEEVENT( n ) Qt5xHb::isObjectDerivedFrom( n, "QWindowStateChangeEvent" ) #define PQABSTRACTTEXTDOCUMENTLAYOUT( n ) static_cast< QAbstractTextDocumentLayout * >( Qt5xHb::itemGetPtr( n ) ) #define PQABSTRACTUNDOITEM( n ) static_cast< QAbstractUndoItem * >( Qt5xHb::itemGetPtr( n ) ) #define PQACCESSIBLE( n ) static_cast< QAccessible * >( Qt5xHb::itemGetPtr( n ) ) #define PQACCESSIBLEACTIONINTERFACE( n ) static_cast< QAccessibleActionInterface * >( Qt5xHb::itemGetPtr( n ) ) #define PQACCESSIBLEAPPLICATION( n ) static_cast< QAccessibleApplication * >( Qt5xHb::itemGetPtr( n ) ) #define PQACCESSIBLEBRIDGE( n ) static_cast< QAccessibleBridge * >( Qt5xHb::itemGetPtr( n ) ) #define PQACCESSIBLEBRIDGEPLUGIN( n ) static_cast< QAccessibleBridgePlugin * >( Qt5xHb::itemGetPtr( n ) ) #define PQACCESSIBLEEDITABLETEXTINTERFACE( n ) static_cast< QAccessibleEditableTextInterface * >( Qt5xHb::itemGetPtr( n ) ) #define PQACCESSIBLEEVENT( n ) static_cast< QAccessibleEvent * >( Qt5xHb::itemGetPtr( n ) ) #define PQACCESSIBLEIMAGEINTERFACE( n ) static_cast< QAccessibleImageInterface * >( Qt5xHb::itemGetPtr( n ) ) #define PQACCESSIBLEINTERFACE( n ) static_cast< QAccessibleInterface * >( Qt5xHb::itemGetPtr( n ) ) #define PQACCESSIBLEOBJECT( n ) static_cast< QAccessibleObject * >( Qt5xHb::itemGetPtr( n ) ) #define PQACCESSIBLEPLUGIN( n ) static_cast< QAccessiblePlugin * >( Qt5xHb::itemGetPtr( n ) ) #define PQACCESSIBLESTATECHANGEEVENT( n ) static_cast< QAccessibleStateChangeEvent * >( Qt5xHb::itemGetPtr( n ) ) #define PQACCESSIBLETABLECELLINTERFACE( n ) static_cast< QAccessibleTableCellInterface * >( Qt5xHb::itemGetPtr( n ) ) #define PQACCESSIBLETABLEINTERFACE( n ) static_cast< QAccessibleTableInterface * >( Qt5xHb::itemGetPtr( n ) ) #define PQACCESSIBLETABLEMODELCHANGEEVENT( n ) static_cast< QAccessibleTableModelChangeEvent * >( Qt5xHb::itemGetPtr( n ) ) #define PQACCESSIBLETEXTCURSOREVENT( n ) static_cast< QAccessibleTextCursorEvent * >( Qt5xHb::itemGetPtr( n ) ) #define PQACCESSIBLETEXTINSERTEVENT( n ) static_cast< QAccessibleTextInsertEvent * >( Qt5xHb::itemGetPtr( n ) ) #define PQACCESSIBLETEXTINTERFACE( n ) static_cast< QAccessibleTextInterface * >( Qt5xHb::itemGetPtr( n ) ) #define PQACCESSIBLETEXTREMOVEEVENT( n ) static_cast< QAccessibleTextRemoveEvent * >( Qt5xHb::itemGetPtr( n ) ) #define PQACCESSIBLETEXTSELECTIONEVENT( n ) static_cast< QAccessibleTextSelectionEvent * >( Qt5xHb::itemGetPtr( n ) ) #define PQACCESSIBLETEXTUPDATEEVENT( n ) static_cast< QAccessibleTextUpdateEvent * >( Qt5xHb::itemGetPtr( n ) ) #define PQACCESSIBLEVALUECHANGEEVENT( n ) static_cast< QAccessibleValueChangeEvent * >( Qt5xHb::itemGetPtr( n ) ) #define PQACCESSIBLEVALUEINTERFACE( n ) static_cast< QAccessibleValueInterface * >( Qt5xHb::itemGetPtr( n ) ) #define PQACTIONEVENT( n ) static_cast< QActionEvent * >( Qt5xHb::itemGetPtr( n ) ) #define PQAPPLICATIONSTATECHANGEEVENT( n ) static_cast< QApplicationStateChangeEvent * >( Qt5xHb::itemGetPtr( n ) ) #define PQBACKINGSTORE( n ) static_cast< QBackingStore * >( Qt5xHb::itemGetPtr( n ) ) #define PQBITMAP( n ) static_cast< QBitmap * >( Qt5xHb::itemGetPtr( n ) ) #define PQBRUSH( n ) static_cast< QBrush * >( Qt5xHb::itemGetPtr( n ) ) #define PQCLIPBOARD( n ) static_cast< QClipboard * >( Qt5xHb::itemGetPtr( n ) ) #define PQCLOSEEVENT( n ) static_cast< QCloseEvent * >( Qt5xHb::itemGetPtr( n ) ) #define PQCOLOR( n ) static_cast< QColor * >( Qt5xHb::itemGetPtr( n ) ) #define PQCOLORSPACE( n ) static_cast< QColorSpace * >( Qt5xHb::itemGetPtr( n ) ) #define PQCONICALGRADIENT( n ) static_cast< QConicalGradient * >( Qt5xHb::itemGetPtr( n ) ) #define PQCONTEXTMENUEVENT( n ) static_cast< QContextMenuEvent * >( Qt5xHb::itemGetPtr( n ) ) #define PQCURSOR( n ) static_cast< QCursor * >( Qt5xHb::itemGetPtr( n ) ) #define PQDESKTOPSERVICES( n ) static_cast< QDesktopServices * >( Qt5xHb::itemGetPtr( n ) ) #define PQDOUBLEVALIDATOR( n ) static_cast< QDoubleValidator * >( Qt5xHb::itemGetPtr( n ) ) #define PQDRAG( n ) static_cast< QDrag * >( Qt5xHb::itemGetPtr( n ) ) #define PQDRAGENTEREVENT( n ) static_cast< QDragEnterEvent * >( Qt5xHb::itemGetPtr( n ) ) #define PQDRAGLEAVEEVENT( n ) static_cast< QDragLeaveEvent * >( Qt5xHb::itemGetPtr( n ) ) #define PQDRAGMOVEEVENT( n ) static_cast< QDragMoveEvent * >( Qt5xHb::itemGetPtr( n ) ) #define PQDROPEVENT( n ) static_cast< QDropEvent * >( Qt5xHb::itemGetPtr( n ) ) #define PQENTEREVENT( n ) static_cast< QEnterEvent * >( Qt5xHb::itemGetPtr( n ) ) #define PQEXPOSEEVENT( n ) static_cast< QExposeEvent * >( Qt5xHb::itemGetPtr( n ) ) #define PQFILEOPENEVENT( n ) static_cast< QFileOpenEvent * >( Qt5xHb::itemGetPtr( n ) ) #define PQFOCUSEVENT( n ) static_cast< QFocusEvent * >( Qt5xHb::itemGetPtr( n ) ) #define PQFONT( n ) static_cast< QFont * >( Qt5xHb::itemGetPtr( n ) ) #define PQFONTDATABASE( n ) static_cast< QFontDatabase * >( Qt5xHb::itemGetPtr( n ) ) #define PQFONTINFO( n ) static_cast< QFontInfo * >( Qt5xHb::itemGetPtr( n ) ) #define PQFONTMETRICS( n ) static_cast< QFontMetrics * >( Qt5xHb::itemGetPtr( n ) ) #define PQFONTMETRICSF( n ) static_cast< QFontMetricsF * >( Qt5xHb::itemGetPtr( n ) ) #define PQGENERICPLUGIN( n ) static_cast< QGenericPlugin * >( Qt5xHb::itemGetPtr( n ) ) #define PQGENERICPLUGINFACTORY( n ) static_cast< QGenericPluginFactory * >( Qt5xHb::itemGetPtr( n ) ) #define PQGLYPHRUN( n ) static_cast< QGlyphRun * >( Qt5xHb::itemGetPtr( n ) ) #define PQGRADIENT( n ) static_cast< QGradient * >( Qt5xHb::itemGetPtr( n ) ) #define PQGUIAPPLICATION( n ) static_cast< QGuiApplication * >( Qt5xHb::itemGetPtr( n ) ) #define PQHELPEVENT( n ) static_cast< QHelpEvent * >( Qt5xHb::itemGetPtr( n ) ) #define PQHIDEEVENT( n ) static_cast< QHideEvent * >( Qt5xHb::itemGetPtr( n ) ) #define PQHOVEREVENT( n ) static_cast< QHoverEvent * >( Qt5xHb::itemGetPtr( n ) ) #define PQICON( n ) static_cast< QIcon * >( Qt5xHb::itemGetPtr( n ) ) #define PQICONDRAGEVENT( n ) static_cast< QIconDragEvent * >( Qt5xHb::itemGetPtr( n ) ) #define PQICONENGINE( n ) static_cast< QIconEngine * >( Qt5xHb::itemGetPtr( n ) ) #define PQICONENGINEPLUGIN( n ) static_cast< QIconEnginePlugin * >( Qt5xHb::itemGetPtr( n ) ) #define PQIMAGE( n ) static_cast< QImage * >( Qt5xHb::itemGetPtr( n ) ) #define PQIMAGEIOHANDLER( n ) static_cast< QImageIOHandler * >( Qt5xHb::itemGetPtr( n ) ) #define PQIMAGEIOPLUGIN( n ) static_cast< QImageIOPlugin * >( Qt5xHb::itemGetPtr( n ) ) #define PQIMAGEREADER( n ) static_cast< QImageReader * >( Qt5xHb::itemGetPtr( n ) ) #define PQIMAGEWRITER( n ) static_cast< QImageWriter * >( Qt5xHb::itemGetPtr( n ) ) #define PQINPUTEVENT( n ) static_cast< QInputEvent * >( Qt5xHb::itemGetPtr( n ) ) #define PQINPUTMETHOD( n ) static_cast< QInputMethod * >( Qt5xHb::itemGetPtr( n ) ) #define PQINPUTMETHODEVENT( n ) static_cast< QInputMethodEvent * >( Qt5xHb::itemGetPtr( n ) ) #define PQINPUTMETHODQUERYEVENT( n ) static_cast< QInputMethodQueryEvent * >( Qt5xHb::itemGetPtr( n ) ) #define PQINTVALIDATOR( n ) static_cast< QIntValidator * >( Qt5xHb::itemGetPtr( n ) ) #define PQKEYEVENT( n ) static_cast< QKeyEvent * >( Qt5xHb::itemGetPtr( n ) ) #define PQKEYSEQUENCE( n ) static_cast< QKeySequence * >( Qt5xHb::itemGetPtr( n ) ) #define PQLINEARGRADIENT( n ) static_cast< QLinearGradient * >( Qt5xHb::itemGetPtr( n ) ) #define PQMATRIX( n ) static_cast< QMatrix * >( Qt5xHb::itemGetPtr( n ) ) #define PQMATRIX4X4( n ) static_cast< QMatrix4x4 * >( Qt5xHb::itemGetPtr( n ) ) #define PQMOUSEEVENT( n ) static_cast< QMouseEvent * >( Qt5xHb::itemGetPtr( n ) ) #define PQMOVEEVENT( n ) static_cast< QMoveEvent * >( Qt5xHb::itemGetPtr( n ) ) #define PQMOVIE( n ) static_cast< QMovie * >( Qt5xHb::itemGetPtr( n ) ) #define PQNATIVEGESTUREEVENT( n ) static_cast< QNativeGestureEvent * >( Qt5xHb::itemGetPtr( n ) ) #define PQOFFSCREENSURFACE( n ) static_cast< QOffscreenSurface * >( Qt5xHb::itemGetPtr( n ) ) #define PQOPENGLBUFFER( n ) static_cast< QOpenGLBuffer * >( Qt5xHb::itemGetPtr( n ) ) #define PQOPENGLCONTEXT( n ) static_cast< QOpenGLContext * >( Qt5xHb::itemGetPtr( n ) ) #define PQOPENGLCONTEXTGROUP( n ) static_cast< QOpenGLContextGroup * >( Qt5xHb::itemGetPtr( n ) ) #define PQOPENGLDEBUGLOGGER( n ) static_cast< QOpenGLDebugLogger * >( Qt5xHb::itemGetPtr( n ) ) #define PQOPENGLDEBUGMESSAGE( n ) static_cast< QOpenGLDebugMessage * >( Qt5xHb::itemGetPtr( n ) ) #define PQOPENGLFRAMEBUFFEROBJECT( n ) static_cast< QOpenGLFramebufferObject * >( Qt5xHb::itemGetPtr( n ) ) #define PQOPENGLFRAMEBUFFEROBJECTFORMAT( n ) static_cast< QOpenGLFramebufferObjectFormat * >( Qt5xHb::itemGetPtr( n ) ) #define PQOPENGLPAINTDEVICE( n ) static_cast< QOpenGLPaintDevice * >( Qt5xHb::itemGetPtr( n ) ) #define PQOPENGLPIXELTRANSFEROPTIONS( n ) static_cast< QOpenGLPixelTransferOptions * >( Qt5xHb::itemGetPtr( n ) ) #define PQOPENGLSHADER( n ) static_cast< QOpenGLShader * >( Qt5xHb::itemGetPtr( n ) ) #define PQOPENGLSHADERPROGRAM( n ) static_cast< QOpenGLShaderProgram * >( Qt5xHb::itemGetPtr( n ) ) #define PQOPENGLTEXTURE( n ) static_cast< QOpenGLTexture * >( Qt5xHb::itemGetPtr( n ) ) #define PQOPENGLTIMEMONITOR( n ) static_cast< QOpenGLTimeMonitor * >( Qt5xHb::itemGetPtr( n ) ) #define PQOPENGLTIMERQUERY( n ) static_cast< QOpenGLTimerQuery * >( Qt5xHb::itemGetPtr( n ) ) #define PQOPENGLVERTEXARRAYOBJECT( n ) static_cast< QOpenGLVertexArrayObject * >( Qt5xHb::itemGetPtr( n ) ) #define PQPAGEDPAINTDEVICE( n ) static_cast< QPagedPaintDevice * >( Qt5xHb::itemGetPtr( n ) ) #define PQPAGELAYOUT( n ) static_cast< QPageLayout * >( Qt5xHb::itemGetPtr( n ) ) #define PQPAGESIZE( n ) static_cast< QPageSize * >( Qt5xHb::itemGetPtr( n ) ) #define PQPAINTDEVICE( n ) static_cast< QPaintDevice * >( Qt5xHb::itemGetPtr( n ) ) #define PQPAINTENGINE( n ) static_cast< QPaintEngine * >( Qt5xHb::itemGetPtr( n ) ) #define PQPAINTENGINESTATE( n ) static_cast< QPaintEngineState * >( Qt5xHb::itemGetPtr( n ) ) #define PQPAINTER( n ) static_cast< QPainter * >( Qt5xHb::itemGetPtr( n ) ) #define PQPAINTERPATH( n ) static_cast< QPainterPath * >( Qt5xHb::itemGetPtr( n ) ) #define PQPAINTERPATHSTROKER( n ) static_cast< QPainterPathStroker * >( Qt5xHb::itemGetPtr( n ) ) #define PQPAINTEVENT( n ) static_cast< QPaintEvent * >( Qt5xHb::itemGetPtr( n ) ) #define PQPALETTE( n ) static_cast< QPalette * >( Qt5xHb::itemGetPtr( n ) ) #define PQPDFWRITER( n ) static_cast< QPdfWriter * >( Qt5xHb::itemGetPtr( n ) ) #define PQPEN( n ) static_cast< QPen * >( Qt5xHb::itemGetPtr( n ) ) #define PQPICTURE( n ) static_cast< QPicture * >( Qt5xHb::itemGetPtr( n ) ) #define PQPICTUREFORMATPLUGIN( n ) static_cast< QPictureFormatPlugin * >( Qt5xHb::itemGetPtr( n ) ) #define PQPICTUREIO( n ) static_cast< QPictureIO * >( Qt5xHb::itemGetPtr( n ) ) #define PQPIXMAP( n ) static_cast< QPixmap * >( Qt5xHb::itemGetPtr( n ) ) #define PQPIXMAPCACHE( n ) static_cast< QPixmapCache * >( Qt5xHb::itemGetPtr( n ) ) #define PQPOLYGON( n ) static_cast< QPolygon * >( Qt5xHb::itemGetPtr( n ) ) #define PQPOLYGONF( n ) static_cast< QPolygonF * >( Qt5xHb::itemGetPtr( n ) ) #define PQQUATERNION( n ) static_cast< QQuaternion * >( Qt5xHb::itemGetPtr( n ) ) #define PQRADIALGRADIENT( n ) static_cast< QRadialGradient * >( Qt5xHb::itemGetPtr( n ) ) #define PQRAWFONT( n ) static_cast< QRawFont * >( Qt5xHb::itemGetPtr( n ) ) #define PQREGEXPVALIDATOR( n ) static_cast< QRegExpValidator * >( Qt5xHb::itemGetPtr( n ) ) #define PQREGION( n ) static_cast< QRegion * >( Qt5xHb::itemGetPtr( n ) ) #define PQREGULAREXPRESSIONVALIDATOR( n ) static_cast< QRegularExpressionValidator * >( Qt5xHb::itemGetPtr( n ) ) #define PQRESIZEEVENT( n ) static_cast< QResizeEvent * >( Qt5xHb::itemGetPtr( n ) ) #define PQSCREEN( n ) static_cast< QScreen * >( Qt5xHb::itemGetPtr( n ) ) #define PQSCREENORIENTATIONCHANGEEVENT( n ) static_cast< QScreenOrientationChangeEvent * >( Qt5xHb::itemGetPtr( n ) ) #define PQSCROLLEVENT( n ) static_cast< QScrollEvent * >( Qt5xHb::itemGetPtr( n ) ) #define PQSCROLLPREPAREEVENT( n ) static_cast< QScrollPrepareEvent * >( Qt5xHb::itemGetPtr( n ) ) #define PQSESSIONMANAGER( n ) static_cast< QSessionManager * >( Qt5xHb::itemGetPtr( n ) ) #define PQSHORTCUTEVENT( n ) static_cast< QShortcutEvent * >( Qt5xHb::itemGetPtr( n ) ) #define PQSHOWEVENT( n ) static_cast< QShowEvent * >( Qt5xHb::itemGetPtr( n ) ) #define PQSTANDARDITEM( n ) static_cast< QStandardItem * >( Qt5xHb::itemGetPtr( n ) ) #define PQSTANDARDITEMMODEL( n ) static_cast< QStandardItemModel * >( Qt5xHb::itemGetPtr( n ) ) #define PQSTATICTEXT( n ) static_cast< QStaticText * >( Qt5xHb::itemGetPtr( n ) ) #define PQSTATUSTIPEVENT( n ) static_cast< QStatusTipEvent * >( Qt5xHb::itemGetPtr( n ) ) #define PQSTYLEHINTS( n ) static_cast< QStyleHints * >( Qt5xHb::itemGetPtr( n ) ) #define PQSURFACE( n ) static_cast< QSurface * >( Qt5xHb::itemGetPtr( n ) ) #define PQSURFACEFORMAT( n ) static_cast< QSurfaceFormat * >( Qt5xHb::itemGetPtr( n ) ) #define PQSYNTAXHIGHLIGHTER( n ) static_cast< QSyntaxHighlighter * >( Qt5xHb::itemGetPtr( n ) ) #define PQTABLETEVENT( n ) static_cast< QTabletEvent * >( Qt5xHb::itemGetPtr( n ) ) #define PQTEXTBLOCK( n ) static_cast< QTextBlock * >( Qt5xHb::itemGetPtr( n ) ) #define PQTEXTBLOCKFORMAT( n ) static_cast< QTextBlockFormat * >( Qt5xHb::itemGetPtr( n ) ) #define PQTEXTBLOCKGROUP( n ) static_cast< QTextBlockGroup * >( Qt5xHb::itemGetPtr( n ) ) #define PQTEXTBLOCKUSERDATA( n ) static_cast< QTextBlockUserData * >( Qt5xHb::itemGetPtr( n ) ) #define PQTEXTCHARFORMAT( n ) static_cast< QTextCharFormat * >( Qt5xHb::itemGetPtr( n ) ) #define PQTEXTCURSOR( n ) static_cast< QTextCursor * >( Qt5xHb::itemGetPtr( n ) ) #define PQTEXTDOCUMENT( n ) static_cast< QTextDocument * >( Qt5xHb::itemGetPtr( n ) ) #define PQTEXTDOCUMENTFRAGMENT( n ) static_cast< QTextDocumentFragment * >( Qt5xHb::itemGetPtr( n ) ) #define PQTEXTDOCUMENTWRITER( n ) static_cast< QTextDocumentWriter * >( Qt5xHb::itemGetPtr( n ) ) #define PQTEXTFORMAT( n ) static_cast< QTextFormat * >( Qt5xHb::itemGetPtr( n ) ) #define PQTEXTFRAGMENT( n ) static_cast< QTextFragment * >( Qt5xHb::itemGetPtr( n ) ) #define PQTEXTFRAME( n ) static_cast< QTextFrame * >( Qt5xHb::itemGetPtr( n ) ) #define PQTEXTFRAMEFORMAT( n ) static_cast< QTextFrameFormat * >( Qt5xHb::itemGetPtr( n ) ) #define PQTEXTFRAMELAYOUTDATA( n ) static_cast< QTextFrameLayoutData * >( Qt5xHb::itemGetPtr( n ) ) #define PQTEXTIMAGEFORMAT( n ) static_cast< QTextImageFormat * >( Qt5xHb::itemGetPtr( n ) ) #define PQTEXTINLINEOBJECT( n ) static_cast< QTextInlineObject * >( Qt5xHb::itemGetPtr( n ) ) #define PQTEXTITEM( n ) static_cast< QTextItem * >( Qt5xHb::itemGetPtr( n ) ) #define PQTEXTLAYOUT( n ) static_cast< QTextLayout * >( Qt5xHb::itemGetPtr( n ) ) #define PQTEXTLENGTH( n ) static_cast< QTextLength * >( Qt5xHb::itemGetPtr( n ) ) #define PQTEXTLINE( n ) static_cast< QTextLine * >( Qt5xHb::itemGetPtr( n ) ) #define PQTEXTLIST( n ) static_cast< QTextList * >( Qt5xHb::itemGetPtr( n ) ) #define PQTEXTLISTFORMAT( n ) static_cast< QTextListFormat * >( Qt5xHb::itemGetPtr( n ) ) #define PQTEXTOBJECT( n ) static_cast< QTextObject * >( Qt5xHb::itemGetPtr( n ) ) #define PQTEXTOBJECTINTERFACE( n ) static_cast< QTextObjectInterface * >( Qt5xHb::itemGetPtr( n ) ) #define PQTEXTOPTION( n ) static_cast< QTextOption * >( Qt5xHb::itemGetPtr( n ) ) #define PQTEXTTABLE( n ) static_cast< QTextTable * >( Qt5xHb::itemGetPtr( n ) ) #define PQTEXTTABLECELL( n ) static_cast< QTextTableCell * >( Qt5xHb::itemGetPtr( n ) ) #define PQTEXTTABLECELLFORMAT( n ) static_cast< QTextTableCellFormat * >( Qt5xHb::itemGetPtr( n ) ) #define PQTEXTTABLEFORMAT( n ) static_cast< QTextTableFormat * >( Qt5xHb::itemGetPtr( n ) ) #define PQTOOLBARCHANGEEVENT( n ) static_cast< QToolBarChangeEvent * >( Qt5xHb::itemGetPtr( n ) ) #define PQTOUCHDEVICE( n ) static_cast< QTouchDevice * >( Qt5xHb::itemGetPtr( n ) ) #define PQTOUCHEVENT( n ) static_cast< QTouchEvent * >( Qt5xHb::itemGetPtr( n ) ) #define PQTRANSFORM( n ) static_cast< QTransform * >( Qt5xHb::itemGetPtr( n ) ) #define PQVALIDATOR( n ) static_cast< QValidator * >( Qt5xHb::itemGetPtr( n ) ) #define PQVECTOR2D( n ) static_cast< QVector2D * >( Qt5xHb::itemGetPtr( n ) ) #define PQVECTOR3D( n ) static_cast< QVector3D * >( Qt5xHb::itemGetPtr( n ) ) #define PQVECTOR4D( n ) static_cast< QVector4D * >( Qt5xHb::itemGetPtr( n ) ) #define PQWHATSTHISCLICKEDEVENT( n ) static_cast< QWhatsThisClickedEvent * >( Qt5xHb::itemGetPtr( n ) ) #define PQWHEELEVENT( n ) static_cast< QWheelEvent * >( Qt5xHb::itemGetPtr( n ) ) #define PQWINDOW( n ) static_cast< QWindow * >( Qt5xHb::itemGetPtr( n ) ) #define PQWINDOWSTATECHANGEEVENT( n ) static_cast< QWindowStateChangeEvent * >( Qt5xHb::itemGetPtr( n ) ) #define OPQABSTRACTTEXTDOCUMENTLAYOUT( n, v ) HB_ISNIL( n )? v : static_cast< QAbstractTextDocumentLayout * >( Qt5xHb::itemGetPtr( n ) ) #define OPQABSTRACTUNDOITEM( n, v ) HB_ISNIL( n )? v : static_cast< QAbstractUndoItem * >( Qt5xHb::itemGetPtr( n ) ) #define OPQACCESSIBLE( n, v ) HB_ISNIL( n )? v : static_cast< QAccessible * >( Qt5xHb::itemGetPtr( n ) ) #define OPQACCESSIBLEACTIONINTERFACE( n, v ) HB_ISNIL( n )? v : static_cast< QAccessibleActionInterface * >( Qt5xHb::itemGetPtr( n ) ) #define OPQACCESSIBLEAPPLICATION( n, v ) HB_ISNIL( n )? v : static_cast< QAccessibleApplication * >( Qt5xHb::itemGetPtr( n ) ) #define OPQACCESSIBLEBRIDGE( n, v ) HB_ISNIL( n )? v : static_cast< QAccessibleBridge * >( Qt5xHb::itemGetPtr( n ) ) #define OPQACCESSIBLEBRIDGEPLUGIN( n, v ) HB_ISNIL( n )? v : static_cast< QAccessibleBridgePlugin * >( Qt5xHb::itemGetPtr( n ) ) #define OPQACCESSIBLEEDITABLETEXTINTERFACE( n, v ) HB_ISNIL( n )? v : static_cast< QAccessibleEditableTextInterface * >( Qt5xHb::itemGetPtr( n ) ) #define OPQACCESSIBLEEVENT( n, v ) HB_ISNIL( n )? v : static_cast< QAccessibleEvent * >( Qt5xHb::itemGetPtr( n ) ) #define OPQACCESSIBLEIMAGEINTERFACE( n, v ) HB_ISNIL( n )? v : static_cast< QAccessibleImageInterface * >( Qt5xHb::itemGetPtr( n ) ) #define OPQACCESSIBLEINTERFACE( n, v ) HB_ISNIL( n )? v : static_cast< QAccessibleInterface * >( Qt5xHb::itemGetPtr( n ) ) #define OPQACCESSIBLEOBJECT( n, v ) HB_ISNIL( n )? v : static_cast< QAccessibleObject * >( Qt5xHb::itemGetPtr( n ) ) #define OPQACCESSIBLEPLUGIN( n, v ) HB_ISNIL( n )? v : static_cast< QAccessiblePlugin * >( Qt5xHb::itemGetPtr( n ) ) #define OPQACCESSIBLESTATECHANGEEVENT( n, v ) HB_ISNIL( n )? v : static_cast< QAccessibleStateChangeEvent * >( Qt5xHb::itemGetPtr( n ) ) #define OPQACCESSIBLETABLECELLINTERFACE( n, v ) HB_ISNIL( n )? v : static_cast< QAccessibleTableCellInterface * >( Qt5xHb::itemGetPtr( n ) ) #define OPQACCESSIBLETABLEINTERFACE( n, v ) HB_ISNIL( n )? v : static_cast< QAccessibleTableInterface * >( Qt5xHb::itemGetPtr( n ) ) #define OPQACCESSIBLETABLEMODELCHANGEEVENT( n, v ) HB_ISNIL( n )? v : static_cast< QAccessibleTableModelChangeEvent * >( Qt5xHb::itemGetPtr( n ) ) #define OPQACCESSIBLETEXTCURSOREVENT( n, v ) HB_ISNIL( n )? v : static_cast< QAccessibleTextCursorEvent * >( Qt5xHb::itemGetPtr( n ) ) #define OPQACCESSIBLETEXTINSERTEVENT( n, v ) HB_ISNIL( n )? v : static_cast< QAccessibleTextInsertEvent * >( Qt5xHb::itemGetPtr( n ) ) #define OPQACCESSIBLETEXTINTERFACE( n, v ) HB_ISNIL( n )? v : static_cast< QAccessibleTextInterface * >( Qt5xHb::itemGetPtr( n ) ) #define OPQACCESSIBLETEXTREMOVEEVENT( n, v ) HB_ISNIL( n )? v : static_cast< QAccessibleTextRemoveEvent * >( Qt5xHb::itemGetPtr( n ) ) #define OPQACCESSIBLETEXTSELECTIONEVENT( n, v ) HB_ISNIL( n )? v : static_cast< QAccessibleTextSelectionEvent * >( Qt5xHb::itemGetPtr( n ) ) #define OPQACCESSIBLETEXTUPDATEEVENT( n, v ) HB_ISNIL( n )? v : static_cast< QAccessibleTextUpdateEvent * >( Qt5xHb::itemGetPtr( n ) ) #define OPQACCESSIBLEVALUECHANGEEVENT( n, v ) HB_ISNIL( n )? v : static_cast< QAccessibleValueChangeEvent * >( Qt5xHb::itemGetPtr( n ) ) #define OPQACCESSIBLEVALUEINTERFACE( n, v ) HB_ISNIL( n )? v : static_cast< QAccessibleValueInterface * >( Qt5xHb::itemGetPtr( n ) ) #define OPQACTIONEVENT( n, v ) HB_ISNIL( n )? v : static_cast< QActionEvent * >( Qt5xHb::itemGetPtr( n ) ) #define OPQAPPLICATIONSTATECHANGEEVENT( n, v ) HB_ISNIL( n )? v : static_cast< QApplicationStateChangeEvent * >( Qt5xHb::itemGetPtr( n ) ) #define OPQBACKINGSTORE( n, v ) HB_ISNIL( n )? v : static_cast< QBackingStore * >( Qt5xHb::itemGetPtr( n ) ) #define OPQBITMAP( n, v ) HB_ISNIL( n )? v : static_cast< QBitmap * >( Qt5xHb::itemGetPtr( n ) ) #define OPQBRUSH( n, v ) HB_ISNIL( n )? v : static_cast< QBrush * >( Qt5xHb::itemGetPtr( n ) ) #define OPQCLIPBOARD( n, v ) HB_ISNIL( n )? v : static_cast< QClipboard * >( Qt5xHb::itemGetPtr( n ) ) #define OPQCLOSEEVENT( n, v ) HB_ISNIL( n )? v : static_cast< QCloseEvent * >( Qt5xHb::itemGetPtr( n ) ) #define OPQCOLOR( n, v ) HB_ISNIL( n )? v : static_cast< QColor * >( Qt5xHb::itemGetPtr( n ) ) #define OPQCOLORSPACE( n, v ) HB_ISNIL( n )? v : static_cast< QColorSpace * >( Qt5xHb::itemGetPtr( n ) ) #define OPQCONICALGRADIENT( n, v ) HB_ISNIL( n )? v : static_cast< QConicalGradient * >( Qt5xHb::itemGetPtr( n ) ) #define OPQCONTEXTMENUEVENT( n, v ) HB_ISNIL( n )? v : static_cast< QContextMenuEvent * >( Qt5xHb::itemGetPtr( n ) ) #define OPQCURSOR( n, v ) HB_ISNIL( n )? v : static_cast< QCursor * >( Qt5xHb::itemGetPtr( n ) ) #define OPQDESKTOPSERVICES( n, v ) HB_ISNIL( n )? v : static_cast< QDesktopServices * >( Qt5xHb::itemGetPtr( n ) ) #define OPQDOUBLEVALIDATOR( n, v ) HB_ISNIL( n )? v : static_cast< QDoubleValidator * >( Qt5xHb::itemGetPtr( n ) ) #define OPQDRAG( n, v ) HB_ISNIL( n )? v : static_cast< QDrag * >( Qt5xHb::itemGetPtr( n ) ) #define OPQDRAGENTEREVENT( n, v ) HB_ISNIL( n )? v : static_cast< QDragEnterEvent * >( Qt5xHb::itemGetPtr( n ) ) #define OPQDRAGLEAVEEVENT( n, v ) HB_ISNIL( n )? v : static_cast< QDragLeaveEvent * >( Qt5xHb::itemGetPtr( n ) ) #define OPQDRAGMOVEEVENT( n, v ) HB_ISNIL( n )? v : static_cast< QDragMoveEvent * >( Qt5xHb::itemGetPtr( n ) ) #define OPQDROPEVENT( n, v ) HB_ISNIL( n )? v : static_cast< QDropEvent * >( Qt5xHb::itemGetPtr( n ) ) #define OPQENTEREVENT( n, v ) HB_ISNIL( n )? v : static_cast< QEnterEvent * >( Qt5xHb::itemGetPtr( n ) ) #define OPQEXPOSEEVENT( n, v ) HB_ISNIL( n )? v : static_cast< QExposeEvent * >( Qt5xHb::itemGetPtr( n ) ) #define OPQFILEOPENEVENT( n, v ) HB_ISNIL( n )? v : static_cast< QFileOpenEvent * >( Qt5xHb::itemGetPtr( n ) ) #define OPQFOCUSEVENT( n, v ) HB_ISNIL( n )? v : static_cast< QFocusEvent * >( Qt5xHb::itemGetPtr( n ) ) #define OPQFONT( n, v ) HB_ISNIL( n )? v : static_cast< QFont * >( Qt5xHb::itemGetPtr( n ) ) #define OPQFONTDATABASE( n, v ) HB_ISNIL( n )? v : static_cast< QFontDatabase * >( Qt5xHb::itemGetPtr( n ) ) #define OPQFONTINFO( n, v ) HB_ISNIL( n )? v : static_cast< QFontInfo * >( Qt5xHb::itemGetPtr( n ) ) #define OPQFONTMETRICS( n, v ) HB_ISNIL( n )? v : static_cast< QFontMetrics * >( Qt5xHb::itemGetPtr( n ) ) #define OPQFONTMETRICSF( n, v ) HB_ISNIL( n )? v : static_cast< QFontMetricsF * >( Qt5xHb::itemGetPtr( n ) ) #define OPQGENERICPLUGIN( n, v ) HB_ISNIL( n )? v : static_cast< QGenericPlugin * >( Qt5xHb::itemGetPtr( n ) ) #define OPQGENERICPLUGINFACTORY( n, v ) HB_ISNIL( n )? v : static_cast< QGenericPluginFactory * >( Qt5xHb::itemGetPtr( n ) ) #define OPQGLYPHRUN( n, v ) HB_ISNIL( n )? v : static_cast< QGlyphRun * >( Qt5xHb::itemGetPtr( n ) ) #define OPQGRADIENT( n, v ) HB_ISNIL( n )? v : static_cast< QGradient * >( Qt5xHb::itemGetPtr( n ) ) #define OPQGUIAPPLICATION( n, v ) HB_ISNIL( n )? v : static_cast< QGuiApplication * >( Qt5xHb::itemGetPtr( n ) ) #define OPQHELPEVENT( n, v ) HB_ISNIL( n )? v : static_cast< QHelpEvent * >( Qt5xHb::itemGetPtr( n ) ) #define OPQHIDEEVENT( n, v ) HB_ISNIL( n )? v : static_cast< QHideEvent * >( Qt5xHb::itemGetPtr( n ) ) #define OPQHOVEREVENT( n, v ) HB_ISNIL( n )? v : static_cast< QHoverEvent * >( Qt5xHb::itemGetPtr( n ) ) #define OPQICON( n, v ) HB_ISNIL( n )? v : static_cast< QIcon * >( Qt5xHb::itemGetPtr( n ) ) #define OPQICONDRAGEVENT( n, v ) HB_ISNIL( n )? v : static_cast< QIconDragEvent * >( Qt5xHb::itemGetPtr( n ) ) #define OPQICONENGINE( n, v ) HB_ISNIL( n )? v : static_cast< QIconEngine * >( Qt5xHb::itemGetPtr( n ) ) #define OPQICONENGINEPLUGIN( n, v ) HB_ISNIL( n )? v : static_cast< QIconEnginePlugin * >( Qt5xHb::itemGetPtr( n ) ) #define OPQIMAGE( n, v ) HB_ISNIL( n )? v : static_cast< QImage * >( Qt5xHb::itemGetPtr( n ) ) #define OPQIMAGEIOHANDLER( n, v ) HB_ISNIL( n )? v : static_cast< QImageIOHandler * >( Qt5xHb::itemGetPtr( n ) ) #define OPQIMAGEIOPLUGIN( n, v ) HB_ISNIL( n )? v : static_cast< QImageIOPlugin * >( Qt5xHb::itemGetPtr( n ) ) #define OPQIMAGEREADER( n, v ) HB_ISNIL( n )? v : static_cast< QImageReader * >( Qt5xHb::itemGetPtr( n ) ) #define OPQIMAGEWRITER( n, v ) HB_ISNIL( n )? v : static_cast< QImageWriter * >( Qt5xHb::itemGetPtr( n ) ) #define OPQINPUTEVENT( n, v ) HB_ISNIL( n )? v : static_cast< QInputEvent * >( Qt5xHb::itemGetPtr( n ) ) #define OPQINPUTMETHOD( n, v ) HB_ISNIL( n )? v : static_cast< QInputMethod * >( Qt5xHb::itemGetPtr( n ) ) #define OPQINPUTMETHODEVENT( n, v ) HB_ISNIL( n )? v : static_cast< QInputMethodEvent * >( Qt5xHb::itemGetPtr( n ) ) #define OPQINPUTMETHODQUERYEVENT( n, v ) HB_ISNIL( n )? v : static_cast< QInputMethodQueryEvent * >( Qt5xHb::itemGetPtr( n ) ) #define OPQINTVALIDATOR( n, v ) HB_ISNIL( n )? v : static_cast< QIntValidator * >( Qt5xHb::itemGetPtr( n ) ) #define OPQKEYEVENT( n, v ) HB_ISNIL( n )? v : static_cast< QKeyEvent * >( Qt5xHb::itemGetPtr( n ) ) #define OPQKEYSEQUENCE( n, v ) HB_ISNIL( n )? v : static_cast< QKeySequence * >( Qt5xHb::itemGetPtr( n ) ) #define OPQLINEARGRADIENT( n, v ) HB_ISNIL( n )? v : static_cast< QLinearGradient * >( Qt5xHb::itemGetPtr( n ) ) #define OPQMATRIX( n, v ) HB_ISNIL( n )? v : static_cast< QMatrix * >( Qt5xHb::itemGetPtr( n ) ) #define OPQMATRIX4X4( n, v ) HB_ISNIL( n )? v : static_cast< QMatrix4x4 * >( Qt5xHb::itemGetPtr( n ) ) #define OPQMOUSEEVENT( n, v ) HB_ISNIL( n )? v : static_cast< QMouseEvent * >( Qt5xHb::itemGetPtr( n ) ) #define OPQMOVEEVENT( n, v ) HB_ISNIL( n )? v : static_cast< QMoveEvent * >( Qt5xHb::itemGetPtr( n ) ) #define OPQMOVIE( n, v ) HB_ISNIL( n )? v : static_cast< QMovie * >( Qt5xHb::itemGetPtr( n ) ) #define OPQNATIVEGESTUREEVENT( n, v ) HB_ISNIL( n )? v : static_cast< QNativeGestureEvent * >( Qt5xHb::itemGetPtr( n ) ) #define OPQOFFSCREENSURFACE( n, v ) HB_ISNIL( n )? v : static_cast< QOffscreenSurface * >( Qt5xHb::itemGetPtr( n ) ) #define OPQOPENGLBUFFER( n, v ) HB_ISNIL( n )? v : static_cast< QOpenGLBuffer * >( Qt5xHb::itemGetPtr( n ) ) #define OPQOPENGLCONTEXT( n, v ) HB_ISNIL( n )? v : static_cast< QOpenGLContext * >( Qt5xHb::itemGetPtr( n ) ) #define OPQOPENGLCONTEXTGROUP( n, v ) HB_ISNIL( n )? v : static_cast< QOpenGLContextGroup * >( Qt5xHb::itemGetPtr( n ) ) #define OPQOPENGLDEBUGLOGGER( n, v ) HB_ISNIL( n )? v : static_cast< QOpenGLDebugLogger * >( Qt5xHb::itemGetPtr( n ) ) #define OPQOPENGLDEBUGMESSAGE( n, v ) HB_ISNIL( n )? v : static_cast< QOpenGLDebugMessage * >( Qt5xHb::itemGetPtr( n ) ) #define OPQOPENGLFRAMEBUFFEROBJECT( n, v ) HB_ISNIL( n )? v : static_cast< QOpenGLFramebufferObject * >( Qt5xHb::itemGetPtr( n ) ) #define OPQOPENGLFRAMEBUFFEROBJECTFORMAT( n, v ) HB_ISNIL( n )? v : static_cast< QOpenGLFramebufferObjectFormat * >( Qt5xHb::itemGetPtr( n ) ) #define OPQOPENGLPAINTDEVICE( n, v ) HB_ISNIL( n )? v : static_cast< QOpenGLPaintDevice * >( Qt5xHb::itemGetPtr( n ) ) #define OPQOPENGLPIXELTRANSFEROPTIONS( n, v ) HB_ISNIL( n )? v : static_cast< QOpenGLPixelTransferOptions * >( Qt5xHb::itemGetPtr( n ) ) #define OPQOPENGLSHADER( n, v ) HB_ISNIL( n )? v : static_cast< QOpenGLShader * >( Qt5xHb::itemGetPtr( n ) ) #define OPQOPENGLSHADERPROGRAM( n, v ) HB_ISNIL( n )? v : static_cast< QOpenGLShaderProgram * >( Qt5xHb::itemGetPtr( n ) ) #define OPQOPENGLTEXTURE( n, v ) HB_ISNIL( n )? v : static_cast< QOpenGLTexture * >( Qt5xHb::itemGetPtr( n ) ) #define OPQOPENGLTIMEMONITOR( n, v ) HB_ISNIL( n )? v : static_cast< QOpenGLTimeMonitor * >( Qt5xHb::itemGetPtr( n ) ) #define OPQOPENGLTIMERQUERY( n, v ) HB_ISNIL( n )? v : static_cast< QOpenGLTimerQuery * >( Qt5xHb::itemGetPtr( n ) ) #define OPQOPENGLVERTEXARRAYOBJECT( n, v ) HB_ISNIL( n )? v : static_cast< QOpenGLVertexArrayObject * >( Qt5xHb::itemGetPtr( n ) ) #define OPQPAGEDPAINTDEVICE( n, v ) HB_ISNIL( n )? v : static_cast< QPagedPaintDevice * >( Qt5xHb::itemGetPtr( n ) ) #define OPQPAGELAYOUT( n, v ) HB_ISNIL( n )? v : static_cast< QPageLayout * >( Qt5xHb::itemGetPtr( n ) ) #define OPQPAGESIZE( n, v ) HB_ISNIL( n )? v : static_cast< QPageSize * >( Qt5xHb::itemGetPtr( n ) ) #define OPQPAINTDEVICE( n, v ) HB_ISNIL( n )? v : static_cast< QPaintDevice * >( Qt5xHb::itemGetPtr( n ) ) #define OPQPAINTENGINE( n, v ) HB_ISNIL( n )? v : static_cast< QPaintEngine * >( Qt5xHb::itemGetPtr( n ) ) #define OPQPAINTENGINESTATE( n, v ) HB_ISNIL( n )? v : static_cast< QPaintEngineState * >( Qt5xHb::itemGetPtr( n ) ) #define OPQPAINTER( n, v ) HB_ISNIL( n )? v : static_cast< QPainter * >( Qt5xHb::itemGetPtr( n ) ) #define OPQPAINTERPATH( n, v ) HB_ISNIL( n )? v : static_cast< QPainterPath * >( Qt5xHb::itemGetPtr( n ) ) #define OPQPAINTERPATHSTROKER( n, v ) HB_ISNIL( n )? v : static_cast< QPainterPathStroker * >( Qt5xHb::itemGetPtr( n ) ) #define OPQPAINTEVENT( n, v ) HB_ISNIL( n )? v : static_cast< QPaintEvent * >( Qt5xHb::itemGetPtr( n ) ) #define OPQPALETTE( n, v ) HB_ISNIL( n )? v : static_cast< QPalette * >( Qt5xHb::itemGetPtr( n ) ) #define OPQPDFWRITER( n, v ) HB_ISNIL( n )? v : static_cast< QPdfWriter * >( Qt5xHb::itemGetPtr( n ) ) #define OPQPEN( n, v ) HB_ISNIL( n )? v : static_cast< QPen * >( Qt5xHb::itemGetPtr( n ) ) #define OPQPICTURE( n, v ) HB_ISNIL( n )? v : static_cast< QPicture * >( Qt5xHb::itemGetPtr( n ) ) #define OPQPICTUREFORMATPLUGIN( n, v ) HB_ISNIL( n )? v : static_cast< QPictureFormatPlugin * >( Qt5xHb::itemGetPtr( n ) ) #define OPQPICTUREIO( n, v ) HB_ISNIL( n )? v : static_cast< QPictureIO * >( Qt5xHb::itemGetPtr( n ) ) #define OPQPIXMAP( n, v ) HB_ISNIL( n )? v : static_cast< QPixmap * >( Qt5xHb::itemGetPtr( n ) ) #define OPQPIXMAPCACHE( n, v ) HB_ISNIL( n )? v : static_cast< QPixmapCache * >( Qt5xHb::itemGetPtr( n ) ) #define OPQPOLYGON( n, v ) HB_ISNIL( n )? v : static_cast< QPolygon * >( Qt5xHb::itemGetPtr( n ) ) #define OPQPOLYGONF( n, v ) HB_ISNIL( n )? v : static_cast< QPolygonF * >( Qt5xHb::itemGetPtr( n ) ) #define OPQQUATERNION( n, v ) HB_ISNIL( n )? v : static_cast< QQuaternion * >( Qt5xHb::itemGetPtr( n ) ) #define OPQRADIALGRADIENT( n, v ) HB_ISNIL( n )? v : static_cast< QRadialGradient * >( Qt5xHb::itemGetPtr( n ) ) #define OPQRAWFONT( n, v ) HB_ISNIL( n )? v : static_cast< QRawFont * >( Qt5xHb::itemGetPtr( n ) ) #define OPQREGEXPVALIDATOR( n, v ) HB_ISNIL( n )? v : static_cast< QRegExpValidator * >( Qt5xHb::itemGetPtr( n ) ) #define OPQREGION( n, v ) HB_ISNIL( n )? v : static_cast< QRegion * >( Qt5xHb::itemGetPtr( n ) ) #define OPQREGULAREXPRESSIONVALIDATOR( n, v ) HB_ISNIL( n )? v : static_cast< QRegularExpressionValidator * >( Qt5xHb::itemGetPtr( n ) ) #define OPQRESIZEEVENT( n, v ) HB_ISNIL( n )? v : static_cast< QResizeEvent * >( Qt5xHb::itemGetPtr( n ) ) #define OPQSCREEN( n, v ) HB_ISNIL( n )? v : static_cast< QScreen * >( Qt5xHb::itemGetPtr( n ) ) #define OPQSCREENORIENTATIONCHANGEEVENT( n, v ) HB_ISNIL( n )? v : static_cast< QScreenOrientationChangeEvent * >( Qt5xHb::itemGetPtr( n ) ) #define OPQSCROLLEVENT( n, v ) HB_ISNIL( n )? v : static_cast< QScrollEvent * >( Qt5xHb::itemGetPtr( n ) ) #define OPQSCROLLPREPAREEVENT( n, v ) HB_ISNIL( n )? v : static_cast< QScrollPrepareEvent * >( Qt5xHb::itemGetPtr( n ) ) #define OPQSESSIONMANAGER( n, v ) HB_ISNIL( n )? v : static_cast< QSessionManager * >( Qt5xHb::itemGetPtr( n ) ) #define OPQSHORTCUTEVENT( n, v ) HB_ISNIL( n )? v : static_cast< QShortcutEvent * >( Qt5xHb::itemGetPtr( n ) ) #define OPQSHOWEVENT( n, v ) HB_ISNIL( n )? v : static_cast< QShowEvent * >( Qt5xHb::itemGetPtr( n ) ) #define OPQSTANDARDITEM( n, v ) HB_ISNIL( n )? v : static_cast< QStandardItem * >( Qt5xHb::itemGetPtr( n ) ) #define OPQSTANDARDITEMMODEL( n, v ) HB_ISNIL( n )? v : static_cast< QStandardItemModel * >( Qt5xHb::itemGetPtr( n ) ) #define OPQSTATICTEXT( n, v ) HB_ISNIL( n )? v : static_cast< QStaticText * >( Qt5xHb::itemGetPtr( n ) ) #define OPQSTATUSTIPEVENT( n, v ) HB_ISNIL( n )? v : static_cast< QStatusTipEvent * >( Qt5xHb::itemGetPtr( n ) ) #define OPQSTYLEHINTS( n, v ) HB_ISNIL( n )? v : static_cast< QStyleHints * >( Qt5xHb::itemGetPtr( n ) ) #define OPQSURFACE( n, v ) HB_ISNIL( n )? v : static_cast< QSurface * >( Qt5xHb::itemGetPtr( n ) ) #define OPQSURFACEFORMAT( n, v ) HB_ISNIL( n )? v : static_cast< QSurfaceFormat * >( Qt5xHb::itemGetPtr( n ) ) #define OPQSYNTAXHIGHLIGHTER( n, v ) HB_ISNIL( n )? v : static_cast< QSyntaxHighlighter * >( Qt5xHb::itemGetPtr( n ) ) #define OPQTABLETEVENT( n, v ) HB_ISNIL( n )? v : static_cast< QTabletEvent * >( Qt5xHb::itemGetPtr( n ) ) #define OPQTEXTBLOCK( n, v ) HB_ISNIL( n )? v : static_cast< QTextBlock * >( Qt5xHb::itemGetPtr( n ) ) #define OPQTEXTBLOCKFORMAT( n, v ) HB_ISNIL( n )? v : static_cast< QTextBlockFormat * >( Qt5xHb::itemGetPtr( n ) ) #define OPQTEXTBLOCKGROUP( n, v ) HB_ISNIL( n )? v : static_cast< QTextBlockGroup * >( Qt5xHb::itemGetPtr( n ) ) #define OPQTEXTBLOCKUSERDATA( n, v ) HB_ISNIL( n )? v : static_cast< QTextBlockUserData * >( Qt5xHb::itemGetPtr( n ) ) #define OPQTEXTCHARFORMAT( n, v ) HB_ISNIL( n )? v : static_cast< QTextCharFormat * >( Qt5xHb::itemGetPtr( n ) ) #define OPQTEXTCURSOR( n, v ) HB_ISNIL( n )? v : static_cast< QTextCursor * >( Qt5xHb::itemGetPtr( n ) ) #define OPQTEXTDOCUMENT( n, v ) HB_ISNIL( n )? v : static_cast< QTextDocument * >( Qt5xHb::itemGetPtr( n ) ) #define OPQTEXTDOCUMENTFRAGMENT( n, v ) HB_ISNIL( n )? v : static_cast< QTextDocumentFragment * >( Qt5xHb::itemGetPtr( n ) ) #define OPQTEXTDOCUMENTWRITER( n, v ) HB_ISNIL( n )? v : static_cast< QTextDocumentWriter * >( Qt5xHb::itemGetPtr( n ) ) #define OPQTEXTFORMAT( n, v ) HB_ISNIL( n )? v : static_cast< QTextFormat * >( Qt5xHb::itemGetPtr( n ) ) #define OPQTEXTFRAGMENT( n, v ) HB_ISNIL( n )? v : static_cast< QTextFragment * >( Qt5xHb::itemGetPtr( n ) ) #define OPQTEXTFRAME( n, v ) HB_ISNIL( n )? v : static_cast< QTextFrame * >( Qt5xHb::itemGetPtr( n ) ) #define OPQTEXTFRAMEFORMAT( n, v ) HB_ISNIL( n )? v : static_cast< QTextFrameFormat * >( Qt5xHb::itemGetPtr( n ) ) #define OPQTEXTFRAMELAYOUTDATA( n, v ) HB_ISNIL( n )? v : static_cast< QTextFrameLayoutData * >( Qt5xHb::itemGetPtr( n ) ) #define OPQTEXTIMAGEFORMAT( n, v ) HB_ISNIL( n )? v : static_cast< QTextImageFormat * >( Qt5xHb::itemGetPtr( n ) ) #define OPQTEXTINLINEOBJECT( n, v ) HB_ISNIL( n )? v : static_cast< QTextInlineObject * >( Qt5xHb::itemGetPtr( n ) ) #define OPQTEXTITEM( n, v ) HB_ISNIL( n )? v : static_cast< QTextItem * >( Qt5xHb::itemGetPtr( n ) ) #define OPQTEXTLAYOUT( n, v ) HB_ISNIL( n )? v : static_cast< QTextLayout * >( Qt5xHb::itemGetPtr( n ) ) #define OPQTEXTLENGTH( n, v ) HB_ISNIL( n )? v : static_cast< QTextLength * >( Qt5xHb::itemGetPtr( n ) ) #define OPQTEXTLINE( n, v ) HB_ISNIL( n )? v : static_cast< QTextLine * >( Qt5xHb::itemGetPtr( n ) ) #define OPQTEXTLIST( n, v ) HB_ISNIL( n )? v : static_cast< QTextList * >( Qt5xHb::itemGetPtr( n ) ) #define OPQTEXTLISTFORMAT( n, v ) HB_ISNIL( n )? v : static_cast< QTextListFormat * >( Qt5xHb::itemGetPtr( n ) ) #define OPQTEXTOBJECT( n, v ) HB_ISNIL( n )? v : static_cast< QTextObject * >( Qt5xHb::itemGetPtr( n ) ) #define OPQTEXTOBJECTINTERFACE( n, v ) HB_ISNIL( n )? v : static_cast< QTextObjectInterface * >( Qt5xHb::itemGetPtr( n ) ) #define OPQTEXTOPTION( n, v ) HB_ISNIL( n )? v : static_cast< QTextOption * >( Qt5xHb::itemGetPtr( n ) ) #define OPQTEXTTABLE( n, v ) HB_ISNIL( n )? v : static_cast< QTextTable * >( Qt5xHb::itemGetPtr( n ) ) #define OPQTEXTTABLECELL( n, v ) HB_ISNIL( n )? v : static_cast< QTextTableCell * >( Qt5xHb::itemGetPtr( n ) ) #define OPQTEXTTABLECELLFORMAT( n, v ) HB_ISNIL( n )? v : static_cast< QTextTableCellFormat * >( Qt5xHb::itemGetPtr( n ) ) #define OPQTEXTTABLEFORMAT( n, v ) HB_ISNIL( n )? v : static_cast< QTextTableFormat * >( Qt5xHb::itemGetPtr( n ) ) #define OPQTOOLBARCHANGEEVENT( n, v ) HB_ISNIL( n )? v : static_cast< QToolBarChangeEvent * >( Qt5xHb::itemGetPtr( n ) ) #define OPQTOUCHDEVICE( n, v ) HB_ISNIL( n )? v : static_cast< QTouchDevice * >( Qt5xHb::itemGetPtr( n ) ) #define OPQTOUCHEVENT( n, v ) HB_ISNIL( n )? v : static_cast< QTouchEvent * >( Qt5xHb::itemGetPtr( n ) ) #define OPQTRANSFORM( n, v ) HB_ISNIL( n )? v : static_cast< QTransform * >( Qt5xHb::itemGetPtr( n ) ) #define OPQVALIDATOR( n, v ) HB_ISNIL( n )? v : static_cast< QValidator * >( Qt5xHb::itemGetPtr( n ) ) #define OPQVECTOR2D( n, v ) HB_ISNIL( n )? v : static_cast< QVector2D * >( Qt5xHb::itemGetPtr( n ) ) #define OPQVECTOR3D( n, v ) HB_ISNIL( n )? v : static_cast< QVector3D * >( Qt5xHb::itemGetPtr( n ) ) #define OPQVECTOR4D( n, v ) HB_ISNIL( n )? v : static_cast< QVector4D * >( Qt5xHb::itemGetPtr( n ) ) #define OPQWHATSTHISCLICKEDEVENT( n, v ) HB_ISNIL( n )? v : static_cast< QWhatsThisClickedEvent * >( Qt5xHb::itemGetPtr( n ) ) #define OPQWHEELEVENT( n, v ) HB_ISNIL( n )? v : static_cast< QWheelEvent * >( Qt5xHb::itemGetPtr( n ) ) #define OPQWINDOW( n, v ) HB_ISNIL( n )? v : static_cast< QWindow * >( Qt5xHb::itemGetPtr( n ) ) #define OPQWINDOWSTATECHANGEEVENT( n, v ) HB_ISNIL( n )? v : static_cast< QWindowStateChangeEvent * >( Qt5xHb::itemGetPtr( n ) ) #endif /* QT5XHB_MACROS_QTGUI_H */
120.723776
156
0.556883
92b7599551902a57e1e9fe0a44a36358db9f1db2
3,143
c
C
wasm/malloc.c
wibblymat/inflate-demo
ddb8800c0eb06e8b7b541af8674ebdd9ba920c2f
[ "Apache-2.0" ]
null
null
null
wasm/malloc.c
wibblymat/inflate-demo
ddb8800c0eb06e8b7b541af8674ebdd9ba920c2f
[ "Apache-2.0" ]
null
null
null
wasm/malloc.c
wibblymat/inflate-demo
ddb8800c0eb06e8b7b541af8674ebdd9ba920c2f
[ "Apache-2.0" ]
null
null
null
/* Copyright 2016 Google Inc. 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. */ #define STACK_SIZE 8192 // 8192 * 4 bytes = 32768 bytes stack #define NULL (void*)0 #define PAGE_SIZE 65536 // Exploit the fact that we know about the internals of binaryen to set the // stack correctly. The name __stack_pointer is special in LLVM. unsigned stack[STACK_SIZE]; unsigned* __stack_pointer = &stack[STACK_SIZE - 1]; void* malloc(unsigned size); void free(void* ptr); // void* realloc(void* ptr, unsigned int size); unsigned grow_memory(unsigned delta); struct header { struct header *ptr; unsigned size; }; typedef struct header Header; static Header* morecore(unsigned size); static Header base; // empty initial free list static Header *freep = NULL; // pointer to free list void* malloc(unsigned size) { Header *p, *prevp; unsigned units; units = (size + sizeof(Header) - 1) / sizeof(Header) + 1; if ((prevp = freep) == NULL) { base.ptr = freep = prevp = &base; base.size = 0; } for (p = prevp->ptr; ; prevp = p, p = p->ptr) { if (p->size >= units) { /* big enough */ if (p->size == units) {/* exactly */ prevp->ptr = p->ptr; } else { /* allocate tail end */ p->size -= units; p += p->size; p->size = units; } freep = prevp; return (void*)(p + 1); } if (p == freep) {/* wrapped around free list */ if ((p = morecore(units)) == NULL) { return NULL; /* none left */ } } } } static Header* morecore(unsigned size) { int current_page; Header* up; int pages = ((size * sizeof(Header)) >> 16) + 1; // We can only request full pages from grow_memory current_page = grow_memory(pages); if (current_page == -1) /* no space at all */ return NULL; up = (Header*)(current_page * PAGE_SIZE); up->size = pages * PAGE_SIZE / sizeof(Header); free((void*)(up + 1)); return freep; } unsigned grow_memory(unsigned delta) { int result; asm("grow_memory %0=, %1" : "=r"(result) : "r"(delta) : "memory"); return result; } void free(void * ap) { Header *bp, *p; bp = (Header*)ap - 1; /* point to block header */ for (p = freep; !(bp > p && bp < p->ptr); p = p->ptr) { if (p >= p->ptr && (bp > p || bp < p->ptr)) { break; /* freed block at start or end of arena */ } } if (bp + bp->size == p->ptr) { /* join to upper nbr */ bp->size += p->ptr->size; bp->ptr = p->ptr->ptr; } else { bp->ptr = p->ptr; } if (p + p->size == bp) { /* join to lower nbr */ p->size += bp->size; p->ptr = bp->ptr; } else { p->ptr = bp; } freep = p; }
27.570175
101
0.61279
1f7453f59e9757a20bd21a448b76a8fc68fdb0c9
25,737
h
C
drivers/media/platform/exynos/mfc/regs-mfc-v10.h
CaelestisZ/HeraQ
2804afc99bf59c43740038833077ef7b14993592
[ "MIT" ]
null
null
null
drivers/media/platform/exynos/mfc/regs-mfc-v10.h
CaelestisZ/HeraQ
2804afc99bf59c43740038833077ef7b14993592
[ "MIT" ]
null
null
null
drivers/media/platform/exynos/mfc/regs-mfc-v10.h
CaelestisZ/HeraQ
2804afc99bf59c43740038833077ef7b14993592
[ "MIT" ]
null
null
null
/* * drivers/media/platform/exynos/mfc/regs-mfc-v10.h * * Copyright (c) 2015 Samsung Electronics * http://www.samsung.com/ * * Register definition file for Samsung MFC V10 Driver * * 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. */ #ifndef __REGS_MFC_V10_H #define __REGS_MFC_V10_H __FILE__ /* Number of bits that the buffer address should be shifted for particular * MFC buffers. */ #define S5P_FIMV_MEM_OFFSET 0 #define S5P_FIMV_START_ADDR 0x0000 #define S5P_FIMV_END_ADDR 0xfdd0 #define S5P_FIMV_REG_SIZE (S5P_FIMV_END_ADDR - S5P_FIMV_START_ADDR) #define S5P_FIMV_REG_COUNT ((S5P_FIMV_END_ADDR - S5p_FIMV_START_ADDR) / 4) #define S5P_FIMV_REG_CLEAR_BEGIN 0xf000 #define S5P_FIMV_REG_CLEAR_COUNT 1024 /* Codec Common Registers */ #define S5P_FIMV_SW_RESET 0x0000 #define S5P_FIMV_RISC_ON 0x0000 #define S5P_FIMV_RISC2HOST_INT 0x003C #define S5P_FIMV_HOST2RISC_INT 0x0044 #define S5P_FIMV_RISC_BASE_ADDRESS 0x0054 #define S5P_FIMV_MFC_FW_CLOCK 0x1060 #define S5P_FIMV_MFC_RESET 0x1070 #define S5P_FIMV_HOST2RISC_CMD 0x1100 #define S5P_FIMV_RISC2HOST_CMD 0x1104 /* Channel & stream interface register */ #define S5P_FIMV_SI_RTN_CHID 0x2000 /* Return CH instance ID register */ #define S5P_FIMV_SI_CH0_INST_ID 0x2040 /* codec instance ID */ #define S5P_FIMV_SI_CH1_INST_ID 0x2080 /* codec instance ID */ #define S5P_FIMV_SI_CH0_DPB_CONF_CTRL 0x2068 /* DPB Config Control Register */ #define S5P_FIMV_MFC_BUS_RESET_CTRL 0x7110 #define S5P_FIMV_MFC_BUS_STATUS 0x7018 #define S5P_FIMV_MFC_CLOCK_OFF 0x7120 #define S5P_FIMV_MFC_STATE 0x7124 #define S5P_FIMV_FW_VERSION 0xF000 #define S5P_FIMV_INSTANCE_ID 0xF008 #define S5P_FIMV_CODEC_TYPE 0xF00C #define S5P_FIMV_CONTEXT_MEM_ADDR 0xF014 #define S5P_FIMV_CONTEXT_MEM_SIZE 0xF018 #define S5P_FIMV_PIXEL_FORMAT 0xF020 #define S5P_FIMV_METADATA_ENABLE 0xF024 #define S5P_FIMV_MFC_VERSION 0xF028 #define S5P_FIMV_DBG_BUFFER_ADDR 0xF030 #define S5P_FIMV_DBG_BUFFER_SIZE 0xF034 #define S5P_FIMV_HED_CONTROL 0xF038 #define S5P_FIMV_DEC_TIMEOUT_VALUE 0xF03C #define S5P_FIMV_SHARED_MEM_ADDR 0xF040 /* NAL QUEUE */ #define S5P_FIMV_NAL_QUEUE_INPUT_ADDR 0xF044 #define S5P_FIMV_NAL_QUEUE_INPUT_SIZE 0xF048 #define S5P_FIMV_NAL_QUEUE_OUTPUT_ADDR 0xF04C #define S5P_FIMV_NAL_QUEUE_OUTPUT_SIZE 0xF050 #define S5P_FIMV_NAL_QUEUE_INPUT_COUNT 0xF054 #define S5P_FIMV_RET_INSTANCE_ID 0xF070 #define S5P_FIMV_ERROR_CODE 0xF074 #define S5P_FIMV_DBG_BUFFER_OUTPUT_SIZE 0xF078 #define S5P_FIMV_METADATA_STATUS 0xF07C #define S5P_FIMV_DBG_INFO_STAGE_COUNTER 0xF088 /* NAL QUEUE */ #define S5P_FIMV_NAL_QUEUE_OUTPUT_COUNT 0xF08C #define S5P_FIMV_NAL_QUEUE_INPUT_EXE_COUNT 0xF090 #define S5P_FIMV_NAL_QUEUE_INFO 0xF094 /* Decoder Registers */ #define S5P_FIMV_D_CRC_CTRL 0xF0B0 #define S5P_FIMV_D_DEC_OPTIONS 0xF0B4 #define S5P_FIMV_D_DISPLAY_DELAY 0xF0B8 #define S5P_FIMV_D_SET_FRAME_WIDTH 0xF0BC #define S5P_FIMV_D_SET_FRAME_HEIGHT 0xF0C0 #define S5P_FIMV_D_SEI_ENABLE 0xF0C4 #define S5P_FIMV_D_FORCE_PIXEL_VAL 0xF0C8 /* Buffer setting registers */ /* Session return */ #define S5P_FIMV_D_MIN_NUM_DPB 0xF0F0 #define S5P_FIMV_D_MIN_FIRST_PLANE_DPB_SIZE 0xF0F4 #define S5P_FIMV_D_MIN_SECOND_PLANE_DPB_SIZE 0xF0F8 #define S5P_FIMV_D_MIN_THIRD_PLANE_DPB_SIZE 0xF0FC #define S5P_FIMV_D_MIN_NUM_MV 0xF100 #define S5P_FIMV_D_MVC_NUM_VIEWS 0xF104 #define S5P_FIMV_D_MIN_SCRATCH_BUFFER_SIZE 0xF108 #define S5P_FIMV_D_MIN_FIRST_PLANE_2BIT_DPB_SIZE 0xF10C #define S5P_FIMV_D_MIN_SECOND_PLANE_2BIT_DPB_SIZE 0xF110 /* Buffers */ #define S5P_FIMV_D_NUM_DPB 0xF130 #define S5P_FIMV_D_NUM_MV 0xF134 #define S5P_FIMV_D_FIRST_PLANE_DPB_STRIDE_SIZE 0xF138 #define S5P_FIMV_D_SECOND_PLANE_DPB_STRIDE_SIZE 0xF13C #define S5P_FIMV_D_THIRD_PLANE_DPB_STRIDE_SIZE 0xF140 #define S5P_FIMV_D_FIRST_PLANE_DPB_SIZE 0xF144 #define S5P_FIMV_D_SECOND_PLANE_DPB_SIZE 0xF148 #define S5P_FIMV_D_THIRD_PLANE_DPB_SIZE 0xF14C #define S5P_FIMV_D_MV_BUFFER_SIZE 0xF150 #define S5P_FIMV_D_INIT_BUFFER_OPTIONS 0xF154 #define S5P_FIMV_D_FIRST_PLANE_DPB0 0xF160 #define S5P_FIMV_D_SECOND_PLANE_DPB0 0xF260 #define S5P_FIMV_D_THIRD_PLANE_DPB0 0xF360 #define S5P_FIMV_D_MV_BUFFER0 0xF460 #define S5P_FIMV_D_SCRATCH_BUFFER_ADDR 0xF560 #define S5P_FIMV_D_SCRATCH_BUFFER_SIZE 0xF564 #define S5P_FIMV_D_METADATA_BUFFER_ADDR 0xF568 #define S5P_FIMV_D_METADATA_BUFFER_SIZE 0xF56C #define S5P_FIMV_D_STATIC_BUFFER_ADDR 0xF570 #define S5P_FIMV_D_STATIC_BUFFER_SIZE 0xF574 #define S5P_FIMV_D_FIRST_PLANE_2BIT_DPB_SIZE 0xF578 #define S5P_FIMV_D_SECOND_PLANE_2BIT_DPB_SIZE 0xF57C #define S5P_FIMV_D_FIRST_PLANE_2BIT_DPB_STRIDE_SIZE 0xF580 #define S5P_FIMV_D_SECOND_PLANE_2BIT_DPB_STRIDE_SIZE 0xF584 #define S5P_FIMV_D_NAL_START_OPTIONS 0xF5AC /* Nal cmd */ #define S5P_FIMV_D_CPB_BUFFER_ADDR 0xF5B0 #define S5P_FIMV_D_CPB_BUFFER_SIZE 0xF5B4 #define S5P_FIMV_D_AVAILABLE_DPB_FLAG_UPPER 0xF5B8 #define S5P_FIMV_D_AVAILABLE_DPB_FLAG_LOWER 0xF5BC #define S5P_FIMV_D_CPB_BUFFER_OFFSET 0xF5C0 #define S5P_FIMV_D_SLICE_IF_ENABLE 0xF5C4 #define S5P_FIMV_D_PICTURE_TAG 0xF5C8 #define S5P_FIMV_D_STREAM_DATA_SIZE 0xF5D0 #define S5P_FIMV_D_DYNAMIC_DPB_FLAG_UPPER 0xF5D4 #define S5P_FIMV_D_DYNAMIC_DPB_FLAG_LOWER 0xF5D8 /* Nal return */ #define S5P_FIMV_D_DISPLAY_FRAME_WIDTH 0xF600 #define S5P_FIMV_D_DISPLAY_FRAME_HEIGHT 0xF604 #define S5P_FIMV_D_DISPLAY_STATUS 0xF608 #define S5P_FIMV_D_DISPLAY_FIRST_PLANE_ADDR 0xF60C #define S5P_FIMV_D_DISPLAY_SECOND_PLANE_ADDR 0xF610 #define S5P_FIMV_D_DISPLAY_THIRD_PLANE_ADDR 0xF614 #define S5P_FIMV_D_DISPLAY_FRAME_TYPE 0xF618 #define S5P_FIMV_D_DISPLAY_CROP_INFO1 0xF61C #define S5P_FIMV_D_DISPLAY_CROP_INFO2 0xF620 #define S5P_FIMV_D_DISPLAY_PICTURE_PROFILE 0xF624 #define S5P_FIMV_D_DISPLAY_FIRST_PLANE_CRC 0xF628 #define S5P_FIMV_D_DISPLAY_SECOND_PLANE_CRC 0xF62C #define S5P_FIMV_D_DISPLAY_THIRD_PLANE_CRC 0xF630 #define S5P_FIMV_D_DISPLAY_ASPECT_RATIO 0xF634 #define S5P_FIMV_D_DISPLAY_EXTENDED_AR 0xF638 #define S5P_FIMV_D_DECODED_FRAME_WIDTH 0xF63C #define S5P_FIMV_D_DECODED_FRAME_HEIGHT 0xF640 #define S5P_FIMV_D_DECODED_STATUS 0xF644 #define S5P_FIMV_D_DECODED_FIRST_PLANE_ADDR 0xF648 #define S5P_FIMV_D_DECODED_SECOND_PLANE_ADDR 0xF64C #define S5P_FIMV_D_DECODED_THIRD_PLANE_ADDR 0xF650 #define S5P_FIMV_D_DECODED_FRAME_TYPE 0xF654 #define S5P_FIMV_D_DECODED_CROP_INFO1 0xF658 #define S5P_FIMV_D_DECODED_CROP_INFO2 0xF65C #define S5P_FIMV_D_DECODED_PICTURE_PROFILE 0xF660 #define S5P_FIMV_D_DECODED_NAL_SIZE 0xF664 #define S5P_FIMV_D_DECODED_FIRST_PLANE_CRC 0xF668 #define S5P_FIMV_D_DECODED_SECOND_PLANE_CRC 0xF66C #define S5P_FIMV_D_DECODED_THIRD_PLANE_CRC 0xF670 #define S5P_FIMV_D_RET_PICTURE_TAG_TOP 0xF674 #define S5P_FIMV_D_RET_PICTURE_TAG_BOT 0xF678 #define S5P_FIMV_D_RET_PICTURE_TIME_TOP 0xF67C #define S5P_FIMV_D_RET_PICTURE_TIME_BOT 0xF680 #define S5P_FIMV_D_CHROMA_FORMAT 0xF684 #define S5P_FIMV_D_VC1_INFO 0xF688 #define S5P_FIMV_D_MPEG4_INFO 0xF68C #define S5P_FIMV_D_H264_INFO 0xF690 #define S5P_FIMV_D_HEVC_INFO 0xF6A0 #define S5P_FIMV_D_METADATA_ADDR_CONCEALED_MB 0xF6B0 #define S5P_FIMV_D_METADATA_SIZE_CONCEALED_MB 0xF6B4 #define S5P_FIMV_D_METADATA_ADDR_VC1_PARAM 0xF6B8 #define S5P_FIMV_D_METADATA_SIZE_VC1_PARAM 0xF6BC #define S5P_FIMV_D_METADATA_ADDR_SEI_NAL 0xF6C0 #define S5P_FIMV_D_METADATA_SIZE_SEI_NAL 0xF6C4 #define S5P_FIMV_D_METADATA_ADDR_VUI 0xF6C8 #define S5P_FIMV_D_METADATA_SIZE_VUI 0xF6CC #define S5P_FIMV_D_METADATA_ADDR_MVCVUI 0xF6D0 #define S5P_FIMV_D_METADATA_SIZE_MVCVUI 0xF6D4 #define S5P_FIMV_D_MVC_VIEW_ID 0xF6D8 #define S5P_FIMV_D_FRAME_PACK_SEI_AVAIL 0xF6DC #define S5P_FIMV_D_FRAME_PACK_ARRGMENT_ID 0xF6E0 #define S5P_FIMV_D_FRAME_PACK_SEI_INFO 0xF6E4 #define S5P_FIMV_D_FRAME_PACK_GRID_POS 0xF6E8 #define S5P_FIMV_D_DISPLAY_RECOVERY_SEI_INFO 0xF6EC #define S5P_FIMV_D_DECODED_RECOVERY_SEI_INFO 0xF6F0 #define S5P_FIMV_D_DISPLAY_FIRST_PLANE_2BIT_CRC 0xF6FC #define S5P_FIMV_D_DISPLAY_SECOND_PLANE_2BIT_CRC 0xF700 #define S5P_FIMV_D_DECODED_FIRST_PLANE_2BIT_CRC 0xF704 #define S5P_FIMV_D_DECODED_SECOND_PLANE_2BIT_CRC 0xF708 #define S5P_FIMV_D_VIDEO_SIGNAL_TYPE 0xF70C #define S5P_FIMV_D_USED_DPB_FLAG_UPPER 0xF720 #define S5P_FIMV_D_USED_DPB_FLAG_LOWER 0xF724 #define S5P_FIMV_D_BLACK_BAR_START_POS 0xF738 #define S5P_FIMV_D_BLACK_BAR_IMAGE_SIZE 0xF73C #define S5P_FIMV_D_DISPLAY_LUMA_ADDR 0xF60C #define S5P_FIMV_D_DISPLAY_CHROMA_ADDR 0xF610 #define S5P_FIMV_D_DECODED_LUMA_ADDR 0xF648 #define S5P_FIMV_D_DECODED_CHROMA_ADDR 0xF64C /* Encoder Registers */ #define S5P_FIMV_E_FRAME_WIDTH 0xF770 #define S5P_FIMV_E_FRAME_HEIGHT 0xF774 #define S5P_FIMV_E_CROPPED_FRAME_WIDTH 0xF778 #define S5P_FIMV_E_CROPPED_FRAME_HEIGHT 0xF77C #define S5P_FIMV_E_FRAME_CROP_OFFSET 0xF780 #define S5P_FIMV_E_ENC_OPTIONS 0xF784 #define S5P_FIMV_E_PICTURE_PROFILE 0xF788 #define S5P_FIMV_E_VBV_BUFFER_SIZE 0xF78C #define S5P_FIMV_E_VBV_INIT_DELAY 0xF790 #define S5P_FIMV_E_FIXED_PICTURE_QP 0xF794 #define S5P_FIMV_E_RC_CONFIG 0xF798 #define S5P_FIMV_E_RC_QP_BOUND 0xF79C #define S5P_FIMV_E_RC_QP_BOUND_PB 0xF7A0 #define S5P_FIMV_E_RC_MODE 0xF7A4 #define S5P_FIMV_E_MB_RC_CONFIG 0xF7A8 #define S5P_FIMV_E_PADDING_CTRL 0xF7AC #define S5P_FIMV_E_AIR_THRESHOLD 0xF7B0 #define S5P_FIMV_E_MV_HOR_RANGE 0xF7B4 #define S5P_FIMV_E_MV_VER_RANGE 0xF7B8 #define S5P_FIMV_E_NUM_DPB 0xF890 #define S5P_FIMV_E_MIN_SCRATCH_BUFFER_SIZE 0xF894 #define S5P_FIMV_E_LUMA_DPB 0xF8C0 #define S5P_FIMV_E_CHROMA_DPB 0xF904 #define S5P_FIMV_E_ME_BUFFER 0xF948 #define S5P_FIMV_E_SCRATCH_BUFFER_ADDR 0xF98C #define S5P_FIMV_E_SCRATCH_BUFFER_SIZE 0xF990 #define S5P_FIMV_E_TMV_BUFFER0 0xF994 #define S5P_FIMV_E_TMV_BUFFER1 0xF998 #define S5P_FIMV_E_IR_BUFFER_ADDR 0xF99C #define S5P_FIMV_E_SOURCE_FIRST_ADDR 0xF9E0 #define S5P_FIMV_E_SOURCE_SECOND_ADDR 0xF9E4 #define S5P_FIMV_E_SOURCE_THIRD_ADDR 0xF9E8 #define S5P_FIMV_E_SOURCE_FIRST_STRIDE 0xF9EC #define S5P_FIMV_E_SOURCE_SECOND_STRIDE 0xF9F0 #define S5P_FIMV_E_SOURCE_THIRD_STRIDE 0xF9F4 #define S5P_FIMV_E_STREAM_BUFFER_ADDR 0xF9F8 #define S5P_FIMV_E_STREAM_BUFFER_SIZE 0xF9FC #define S5P_FIMV_E_ROI_BUFFER_ADDR 0xFA00 #define S5P_FIMV_E_PARAM_CHANGE 0xFA04 #define S5P_FIMV_E_IR_SIZE 0xFA08 #define S5P_FIMV_E_GOP_CONFIG 0xFA0C #define S5P_FIMV_E_MSLICE_MODE 0xFA10 #define S5P_FIMV_E_MSLICE_SIZE_MB 0xFA14 #define S5P_FIMV_E_MSLICE_SIZE_BITS 0xFA18 #define S5P_FIMV_E_FRAME_INSERTION 0xFA1C #define S5P_FIMV_E_RC_FRAME_RATE 0xFA20 #define S5P_FIMV_E_RC_BIT_RATE 0xFA24 #define S5P_FIMV_E_RC_ROI_CTRL 0xFA2C #define S5P_FIMV_E_PICTURE_TAG 0xFA30 #define S5P_FIMV_E_BIT_COUNT_ENABLE 0xFA34 #define S5P_FIMV_E_MAX_BIT_COUNT 0xFA38 #define S5P_FIMV_E_MIN_BIT_COUNT 0xFA3C #define S5P_FIMV_E_METADATA_BUFFER_ADDR 0xFA40 #define S5P_FIMV_E_METADATA_BUFFER_SIZE 0xFA44 #define S5P_FIMV_E_ENCODING_ORDER_TIME_INFO 0xFA50 #define S5P_FIMV_E_ENCODING_ORDER_INFO 0xFA54 #define S5P_FIMV_E_STREAM_BUFFER_OFFSET 0xFA58 #define S5P_FIMV_E_GOP_CONFIG2 0xFA5C #define S5P_FIMV_E_ENCODED_SOURCE_FIRST_ADDR 0xFA70 #define S5P_FIMV_E_ENCODED_SOURCE_SECOND_ADDR 0xFA74 #define S5P_FIMV_E_ENCODED_SOURCE_THIRD_ADDR 0xFA78 #define S5P_FIMV_E_STREAM_SIZE 0xFA80 #define S5P_FIMV_E_SLICE_TYPE 0xFA84 #define S5P_FIMV_E_PICTURE_COUNT 0xFA88 #define S5P_FIMV_E_RET_PICTURE_TAG 0xFA8C #define S5P_FIMV_E_RECON_LUMA_DPB_ADDR 0xFA9C #define S5P_FIMV_E_RECON_CHROMA_DPB_ADDR 0xFAA0 #define S5P_FIMV_E_METADATA_ADDR_ENC_SLICE 0xFAA4 #define S5P_FIMV_E_METADATA_SIZE_ENC_SLICE 0xFAA8 #define S5P_FIMV_E_NAL_DONE_INFO 0xFAEC #define S5P_FIMV_E_MPEG4_OPTIONS 0xFB10 #define S5P_FIMV_E_MPEG4_HEC_PERIOD 0xFB14 #define S5P_FIMV_E_H264_HD_SVC_EXTENSION_0 0xFB44 #define S5P_FIMV_E_H264_HD_SVC_EXTENSION_1 0xFB48 #define S5P_FIMV_E_ASPECT_RATIO 0xFB4C #define S5P_FIMV_E_EXTENDED_SAR 0xFB50 #define S5P_FIMV_E_H264_OPTIONS 0xFB54 #define S5P_FIMV_E_H264_OPTIONS_2 0xFB58 #define S5P_FIMV_E_H264_LF_ALPHA_OFFSET 0xFB5C #define S5P_FIMV_E_H264_LF_BETA_OFFSET 0xFB60 #define S5P_FIMV_E_H264_REFRESH_PERIOD 0xFB64 #define S5P_FIMV_E_H264_FMO_SLICE_GRP_MAP_TYPE 0xFB68 #define S5P_FIMV_E_H264_FMO_NUM_SLICE_GRP_MINUS1 0xFB6C #define S5P_FIMV_E_H264_FMO_SLICE_GRP_CHANGE_DIR 0xFB70 #define S5P_FIMV_E_H264_FMO_SLICE_GRP_CHANGE_RATE_MINUS1 0xFB74 #define S5P_FIMV_E_H264_FMO_RUN_LENGTH_MINUS1_0 0xFB78 #define S5P_FIMV_E_H264_FMO_RUN_LENGTH_MINUS1_1 0xFB7C #define S5P_FIMV_E_H264_FMO_RUN_LENGTH_MINUS1_2 0xFB80 #define S5P_FIMV_E_H264_FMO_RUN_LENGTH_MINUS1_3 0xFB84 #define S5P_FIMV_E_H264_ASO_SLICE_ORDER_0 0xFB88 #define S5P_FIMV_E_H264_ASO_SLICE_ORDER_1 0xFB8C #define S5P_FIMV_E_H264_ASO_SLICE_ORDER_2 0xFB90 #define S5P_FIMV_E_H264_ASO_SLICE_ORDER_3 0xFB94 #define S5P_FIMV_E_H264_ASO_SLICE_ORDER_4 0xFB98 #define S5P_FIMV_E_H264_ASO_SLICE_ORDER_5 0xFB9C #define S5P_FIMV_E_H264_ASO_SLICE_ORDER_6 0xFBA0 #define S5P_FIMV_E_H264_ASO_SLICE_ORDER_7 0xFBA4 #define S5P_FIMV_E_H264_CHROMA_QP_OFFSET 0xFBA8 #define S5P_FIMV_E_NUM_T_LAYER 0xFBAC #define S5P_FIMV_E_HIERARCHICAL_QP_LAYER0 0xFBB0 #define S5P_FIMV_E_HIERARCHICAL_QP_LAYER1 0xFBB4 #define S5P_FIMV_E_HIERARCHICAL_QP_LAYER2 0xFBB8 #define S5P_FIMV_E_HIERARCHICAL_QP_LAYER3 0xFBBC #define S5P_FIMV_E_HIERARCHICAL_QP_LAYER4 0xFBC0 #define S5P_FIMV_E_HIERARCHICAL_QP_LAYER5 0xFBC4 #define S5P_FIMV_E_HIERARCHICAL_QP_LAYER6 0xFBC8 /* For backward compatibility */ #define S5P_FIMV_E_H264_FRAME_PACKING_SEI_INFO 0xFC4C #define S5P_FIMV_E_H264_NAL_CONTROL 0xFD14 #define S5P_FIMV_E_HIERARCHICAL_BIT_RATE_LAYER0 0xFD18 #define S5P_FIMV_E_HIERARCHICAL_BIT_RATE_LAYER1 0xFD1C #define S5P_FIMV_E_HIERARCHICAL_BIT_RATE_LAYER2 0xFD20 #define S5P_FIMV_E_HIERARCHICAL_BIT_RATE_LAYER3 0xFD24 #define S5P_FIMV_E_HIERARCHICAL_BIT_RATE_LAYER4 0xFD28 #define S5P_FIMV_E_HIERARCHICAL_BIT_RATE_LAYER5 0xFD2C #define S5P_FIMV_E_HIERARCHICAL_BIT_RATE_LAYER6 0xFD30 #define S5P_FIMV_E_MVC_FRAME_QP_VIEW1 0xFD40 #define S5P_FIMV_E_MVC_RC_FRAME_RATE_VIEW1 0xFD44 #define S5P_FIMV_E_MVC_RC_BIT_RATE_VIEW1 0xFD48 #define S5P_FIMV_E_MVC_RC_QBOUND_VIEW1 0xFD4C #define S5P_FIMV_E_MVC_RC_MODE_VIEW1 0xFD50 #define S5P_FIMV_E_MVC_INTER_VIEW_PREDICTION_ON 0xFD80 #define S5P_FIMV_E_VP9_OPTION 0xFD90 #define S5P_FIMV_E_VP9_GOLDEN_FRAME_OPTION 0xFD98 #define S5P_FIMV_E_VP8_OPTION 0xFDB0 #define S5P_FIMV_E_VP8_FILTER_OPTIONS 0xFDB4 #define S5P_FIMV_E_VP8_GOLDEN_FRAME_OPTION 0xFDB8 #define S5P_FIMV_E_HEVC_OPTIONS 0xFDD4 #define S5P_FIMV_E_HEVC_REFRESH_PERIOD 0xFDD8 #define S5P_FIMV_E_HEVC_CHROMA_QP_OFFSET 0xFDDC #define S5P_FIMV_E_HEVC_LF_BETA_OFFSET_DIV2 0xFDE0 #define S5P_FIMV_E_HEVC_LF_TC_OFFSET_DIV2 0xFDE4 #define S5P_FIMV_E_HEVC_NAL_CONTROL 0xFDE8 #define S5P_FIMV_E_VP8_NAL_CONTROL 0xFDF0 #define S5P_FIMV_E_VP9_NAL_CONTROL 0xFDF4 /* Memory controller register */ #define S5P_FIMV_MC_DRAMBASE_ADR_A 0x0508 #define S5P_FIMV_MC_DRAMBASE_ADR_B 0x050c #define S5P_FIMV_MC_STATUS 0x0510 /* Encoder SFRs for MFC v6.x only */ #define S5P_FIMV_E_SOURCE_LUMA_ADDR 0xF9E0 #define S5P_FIMV_E_SOURCE_CHROMA_ADDR 0xF9E4 #define S5P_FIMV_E_ENCODED_SOURCE_LUMA_ADDR 0xFA70 #define S5P_FIMV_E_ENCODED_SOURCE_CHROMA_ADDR 0xFA74 /* Bit Definitions */ /* 0x1100: S5P_FIMV_HOST2RISC_CMD */ #define S5P_FIMV_H2R_CMD_EMPTY 0 #define S5P_FIMV_H2R_CMD_SYS_INIT 1 #define S5P_FIMV_H2R_CMD_OPEN_INSTANCE 2 #define S5P_FIMV_CH_SEQ_HEADER 3 #define S5P_FIMV_CH_INIT_BUFS 4 #define S5P_FIMV_CH_NAL_START 5 #define S5P_FIMV_CH_FRAME_START S5P_FIMV_CH_NAL_START #define S5P_FIMV_H2R_CMD_CLOSE_INSTANCE 6 #define S5P_FIMV_H2R_CMD_SLEEP 7 #define S5P_FIMV_H2R_CMD_WAKEUP 8 #define S5P_FIMV_CH_LAST_FRAME 9 #define S5P_FIMV_H2R_CMD_FLUSH 10 #define S5P_FIMV_CH_NAL_ABORT 11 #define S5P_FIMV_CH_CACHE_FLUSH 12 #define S5P_FIMV_CH_NAL_QUEUE 13 #define S5P_FIMV_CH_STOP_QUEUE 14 /* 0x1104: S5P_FIMV_RISC2HOST_CMD */ #define S5P_FIMV_RISC2HOST_CMD_MASK 0x1FFFF #define S5P_FIMV_R2H_CMD_EMPTY 0 #define S5P_FIMV_R2H_CMD_SYS_INIT_RET 1 #define S5P_FIMV_R2H_CMD_OPEN_INSTANCE_RET 2 #define S5P_FIMV_R2H_CMD_SEQ_DONE_RET 3 #define S5P_FIMV_R2H_CMD_INIT_BUFFERS_RET 4 #define S5P_FIMV_R2H_CMD_CLOSE_INSTANCE_RET 6 #define S5P_FIMV_R2H_CMD_SLEEP_RET 7 #define S5P_FIMV_R2H_CMD_WAKEUP_RET 8 #define S5P_FIMV_R2H_CMD_COMPLETE_SEQ_RET 9 #define S5P_FIMV_R2H_CMD_DPB_FLUSH_RET 10 #define S5P_FIMV_R2H_CMD_NAL_ABORT_RET 11 #define S5P_FIMV_R2H_CMD_FW_STATUS_RET 12 #define S5P_FIMV_R2H_CMD_FRAME_DONE_RET 13 #define S5P_FIMV_R2H_CMD_FIELD_DONE_RET 14 #define S5P_FIMV_R2H_CMD_SLICE_DONE_RET 15 #define S5P_FIMV_R2H_CMD_ENC_BUFFER_FULL_RET 16 #define S5P_FIMV_R2H_CMD_QUEUE_DONE_RET 17 #define S5P_FIMV_R2H_CMD_COMPLETE_QUEUE_RET 18 #define S5P_FIMV_R2H_CMD_CACHE_FLUSH_RET 20 #define S5P_FIMV_R2H_CMD_ERR_RET 32 /* 0xF000: S5P_FIMV_FW_VERSION */ #define S5P_FIMV_FW_VER_INFO_MASK 0xFF #define S5P_FIMV_FW_VER_INFO_SHFT 24 #define S5P_FIMV_FW_VER_YEAR_MASK 0xFF #define S5P_FIMV_FW_VER_YEAR_SHFT 16 #define S5P_FIMV_FW_VER_MONTH_MASK 0xFF #define S5P_FIMV_FW_VER_MONTH_SHFT 8 #define S5P_FIMV_FW_VER_DATE_MASK 0xFF #define S5P_FIMV_FW_VER_DATE_SHFT 0 #define S5P_FIMV_FW_VER_ALL_MASK 0xFFFFFF #define S5P_FIMV_FW_VER_ALL_SHFT 0 /* 0xF00C: S5P_FIMV_CODEC_TYPE */ #define MFC_FORMATS_NO_CODEC -1 /* Decoder */ #define S5P_FIMV_CODEC_H264_DEC 0 #define S5P_FIMV_CODEC_H264_MVC_DEC 1 #define S5P_FIMV_CODEC_MPEG4_DEC 3 #define S5P_FIMV_CODEC_FIMV1_DEC 4 #define S5P_FIMV_CODEC_FIMV2_DEC 5 #define S5P_FIMV_CODEC_FIMV3_DEC 6 #define S5P_FIMV_CODEC_FIMV4_DEC 7 #define S5P_FIMV_CODEC_H263_DEC 8 #define S5P_FIMV_CODEC_VC1RCV_DEC 9 #define S5P_FIMV_CODEC_VC1_DEC 10 #define S5P_FIMV_CODEC_MPEG2_DEC 13 #define S5P_FIMV_CODEC_VP8_DEC 14 #define S5P_FIMV_CODEC_HEVC_DEC 17 #define S5P_FIMV_CODEC_VP9_DEC 18 /* Encoder */ #define S5P_FIMV_CODEC_H264_ENC 20 #define S5P_FIMV_CODEC_H264_MVC_ENC 21 #define S5P_FIMV_CODEC_MPEG4_ENC 23 #define S5P_FIMV_CODEC_H263_ENC 24 #define S5P_FIMV_CODEC_VP8_ENC 25 #define S5P_FIMV_CODEC_HEVC_ENC 26 #define S5P_FIMV_CODEC_VP9_ENC 27 /* 0xF028: S5P_FIMV_MFC_VERSION */ #define S5P_FIMV_MFC_VER_MASK 0xFFFFFFFF #define S5P_FIMV_MFC_VER_SHFT 0 /* 0xF074: S5P_FIMV_ERROR_CODE */ #define S5P_FIMV_ERR_DEC_MASK 0xFFFF #define S5P_FIMV_ERR_DEC_SHIFT 0 #define S5P_FIMV_ERR_DSPL_MASK 0xFFFF0000 #define S5P_FIMV_ERR_DSPL_SHIFT 16 /* Error number */ #define S5P_FIMV_ERR_VPS_ONLY_ERROR 42 #define S5P_FIMV_ERR_NULL_SCRATCH 61 #define S5P_FIMV_ERR_HEADER_NOT_FOUND 102 #define S5P_FIMV_ERR_FRAME_CONCEAL 150 #define S5P_FIMV_ERR_WARNINGS_START 160 #define S5P_FIMV_ERR_BROKEN_LINK 161 #define S5P_FIMV_ERR_SYNC_POINT_NOT_RECEIVED 190 #define S5P_FIMV_ERR_NON_PAIRED_FIELD 191 #define S5P_FIMV_ERR_WARNINGS_END 222 /* 0xF0B4: S5P_FIMV_D_DEC_OPTIONS */ #define S5P_FIMV_D_OPT_DISPLAY_LINEAR_EN 11 #define S5P_FIMV_D_OPT_CONCEAL_CONTROL 8 #define S5P_FIMV_D_OPT_DISCARD_RCV_HEADER 7 #define S5P_FIMV_D_OPT_IDR_DECODING_SHFT 6 #define S5P_FIMV_D_OPT_FMO_ASO_CTRL_MASK 4 #define S5P_FIMV_D_OPT_DDELAY_EN_SHIFT 3 #define S5P_FIMV_D_OPT_LF_CTRL_SHIFT 1 #define S5P_FIMV_D_OPT_LF_CTRL_MASK 0x3 #define S5P_FIMV_D_OPT_TILE_MODE_SHIFT 0 #define S5P_FIMV_D_OPT_DYNAMIC_DPB_SET_SHIFT 3 #define S5P_FIMV_D_OPT_NOT_CODED_SET_SHIFT 4 #define S5P_FIMV_D_OPT_DITHERING_SET_SHIFT 6 #define S5P_FIMV_D_OPT_SPECIAL_PARSING_SHIFT 15 #define S5P_FIMV_D_PROFILE_HEVC_MAIN 1 #define S5P_FIMV_D_PROFILE_HEVC_MAIN_10 2 /* 0xF0C4: S5P_FIMV_D_SEI_ENABLE */ #define S5P_FIMV_D_SEI_NEED_INIT_BUFFER_SHIFT 1 /* 0xF5AC: S5P_FIMV_D_NAL_START_OPTIONS */ #define S5P_FIMV_D_NAL_START_OPT_BLACK_BAR_SHIFT 3 /* 0xF608: S5P_FIMV_D_DISPLAY_STATUS */ #define S5P_FIMV_DISP_STATUS_BLACK_BAR_DETECT_MASK 0x3 #define S5P_FIMV_DISP_STATUS_BLACK_BAR_DETECT_SHIFT 13 #define S5P_FIMV_DISP_STATUS_NOT_DETECTED 0x0 #define S5P_FIMV_DISP_STATUS_BLACK_BAR 0x1 #define S5P_FIMV_DISP_STATUS_BLACK_SCREEN 0x2 /* 0xF618: S5P_FIMV_D_DISPLAY_FRAME_TYPE */ #define S5P_FIMV_DISPLAY_FRAME_MASK 7 #define S5P_FIMV_DISPLAY_FRAME_NOT_CODED 0 #define S5P_FIMV_DISPLAY_FRAME_I 1 #define S5P_FIMV_DISPLAY_FRAME_P 2 #define S5P_FIMV_DISPLAY_FRAME_B 3 #define S5P_FIMV_DISPLAY_TEMP_INFO_MASK 0x1 #define S5P_FIMV_DISPLAY_TEMP_INFO_SHIFT 7 #define S5P_FIMV_DISPLAY_LAST_INFO_MASK 0x1 #define S5P_FIMV_DISPLAY_LAST_INFO_SHIFT 11 /* 0xF61C: S5P_FIMV_D_DISPLAY_CROP_INFO1 */ #define S5P_FIMV_SHARED_CROP_LEFT_MASK 0xFFFF #define S5P_FIMV_SHARED_CROP_RIGHT_SHIFT 16 /* 0xF620: S5P_FIMV_D_DISPLAY_CROP_INFO2 */ #define S5P_FIMV_SHARED_CROP_TOP_MASK 0xFFFF #define S5P_FIMV_SHARED_CROP_BOTTOM_SHIFT 16 /* 0xF644: S5P_FIMV_D_DECODED_STATUS */ #define S5P_FIMV_DEC_STATUS_DECODING_ONLY 0 #define S5P_FIMV_DEC_STATUS_DECODING_DISPLAY 1 #define S5P_FIMV_DEC_STATUS_DISPLAY_ONLY 2 #define S5P_FIMV_DEC_STATUS_DECODING_EMPTY 3 #define S5P_FIMV_DEC_STATUS_LAST_DISP 4 /* Hooking value */ #define S5P_FIMV_DEC_STATUS_DECODING_STATUS_MASK 7 #define S5P_FIMV_DEC_STATUS_PROGRESSIVE (0<<3) #define S5P_FIMV_DEC_STATUS_INTERLACE (1<<3) #define S5P_FIMV_DEC_STATUS_INTERLACE_MASK (1<<3) #define S5P_FIMV_DEC_STATUS_INTERLACE_SHIFT 3 #define S5P_FIMV_DEC_STATUS_RESOLUTION_MASK (3<<4) #define S5P_FIMV_DEC_STATUS_RESOLUTION_INC (1<<4) #define S5P_FIMV_DEC_STATUS_RESOLUTION_DEC (2<<4) #define S5P_FIMV_DEC_STATUS_RESOLUTION_SHIFT 4 #define S5P_FIMV_DEC_STATUS_CRC_GEN_MASK 0x1 #define S5P_FIMV_DEC_STATUS_CRC_GEN_SHIFT 6 /* 0xF654: S5P_FIMV_D_DECODED_FRAME_TYPE */ #define S5P_FIMV_DECODED_FRAME_MASK 7 #define S5P_FIMV_DECODED_FRAME_NOT_CODED 0 #define S5P_FIMV_DECODED_FRAME_I 1 #define S5P_FIMV_DECODED_FRAME_P 2 #define S5P_FIMV_DECODED_FRAME_B 3 /* 0xF660: S5P_FIMV_D_DECODED_PICTURE_PROFILE */ #define S5P_FIMV_DECODED_PIC_PROFILE_MASK 0x001F /* 0xF6D8: S5P_FIMV_D_MVC_VIEW_ID */ #define S5P_FIMV_D_MVC_VIEW_ID_DISP_MASK 0xFFFF /* 0xF690: S5P_FIMV_D_H264_INFO */ #define S5P_FIMV_D_H264_INFO_MBAFF_FRAME_FLAG_SHIFT 9 #define S5P_FIMV_D_H264_INFO_MBAFF_FRAME_FLAG_MASK 0x1 /* 0xF70C: S5P_FIMV_D_VIDEO_SIGNAL_TYPE */ #define S5P_FIMV_D_VIDEO_SIGNAL_TYPE_FLAG_SHIFT 29 #define S5P_FIMV_D_VIDEO_SIGNAL_TYPE_FLAG_MASK 0x1 #define S5P_FIMV_D_COLOUR_DESCRIPTION_FLAG_SHIFT 24 #define S5P_FIMV_D_COLOUR_DESCRIPTION_FLAG_MASK 0x1 /* 0xF738: S5P_FIMV_D_BLACK_BAR_START_POS */ #define S5P_FIMV_D_BLACK_BAR_START_X_SHIFT 0 #define S5P_FIMV_D_BLACK_BAR_START_X_MASK 0xFFFF #define S5P_FIMV_D_BLACK_BAR_START_Y_SHIFT 16 #define S5P_FIMV_D_BLACK_BAR_START_Y_MASK 0xFFFF /* 0xF73C: S5P_FIMV_D_BLACK_BAR_IMAGE_SIZE */ #define S5P_FIMV_D_BLACK_BAR_IMAGE_W_SHIFT 0 #define S5P_FIMV_D_BLACK_BAR_IMAGE_W_MASK 0xFFFF #define S5P_FIMV_D_BLACK_BAR_IMAGE_H_SHIFT 16 #define S5P_FIMV_D_BLACK_BAR_IMAGE_H_MASK 0xFFFF /* 0xF788: S5P_FIMV_E_PICTURE_PROFILE */ #define S5P_FIMV_ENC_PROFILE_H264_BASELINE 0 #define S5P_FIMV_ENC_PROFILE_H264_MAIN 1 #define S5P_FIMV_ENC_PROFILE_H264_HIGH 2 #define S5P_FIMV_ENC_PROFILE_H264_CONSTRAINED_BASELINE 3 #define S5P_FIMV_ENC_PROFILE_H264_CONSTRAINED_HIGH 5 #define S5P_FIMV_ENC_PROFILE_MPEG4_SIMPLE 0 #define S5P_FIMV_ENC_PROFILE_MPEG4_ADVANCED_SIMPLE 1 /* 0xF7A4: S5P_FIMV_E_RC_MODE */ #define S5P_FIMV_ENC_TIGHT_CBR 1 #define S5P_FIMV_ENC_LOOSE_CBR 2 #define S5P_FIMV_ENC_ADV_TIGHT_CBR 0 #define S5P_FIMV_ENC_ADV_LOOSE_CBR 1 #define S5P_FIMV_ENC_ADV_CAM_CBR 2 #define S5P_FIMV_ENC_ADV_I_LIMIT_CBR 3 /* 0xFA84: S5P_FIMV_E_SLICE_TYPE */ #define S5P_FIMV_ENCODED_TYPE_NOT_CODED 0 #define S5P_FIMV_ENCODED_TYPE_I 1 #define S5P_FIMV_ENCODED_TYPE_P 2 #define S5P_FIMV_ENCODED_TYPE_B 3 #define S5P_FIMV_ENCODED_TYPE_SKIPPED 4 /* 0xFB54: S5P_FIMV_E_H264_OPTIONS */ #define S5P_FIMV_E_IDR_H264_IDR 1 #endif /* __REGS_MFC_V10_H */
38.877644
79
0.80359
dd2569d82096eebd1a7e5da333d4fc99cd90aa06
17,906
h
C
StRoot/StFmsDbMaker/StFmsDbMaker.h
xiaohaijin/RHIC-STAR
a305cb0a6ac15c8165bd8f0d074d7075d5e58752
[ "MIT" ]
2
2018-12-24T19:37:00.000Z
2022-02-28T06:57:20.000Z
StRoot/StFmsDbMaker/StFmsDbMaker.h
xiaohaijin/RHIC-STAR
a305cb0a6ac15c8165bd8f0d074d7075d5e58752
[ "MIT" ]
null
null
null
StRoot/StFmsDbMaker/StFmsDbMaker.h
xiaohaijin/RHIC-STAR
a305cb0a6ac15c8165bd8f0d074d7075d5e58752
[ "MIT" ]
null
null
null
/*************************************************************************** * $Id: StFmsDbMaker.h,v 1.23 2018/03/09 21:36:18 smirnovd Exp $ * \author: akio ogawa *************************************************************************** * * Description: FMS DB access Maker * Please visit http://drupal.star.bnl.gov/STAR/subsys/fms/database/stfmsdbmaker for more information * *************************************************************************** * * $Log: StFmsDbMaker.h,v $ * Revision 1.23 2018/03/09 21:36:18 smirnovd * Remove declared but undefined function * * Revision 1.22 2018/02/07 14:45:15 akio * Update for faster DB tables * * Revision 1.21 2017/11/02 13:09:25 akio * Adding getCorrectedAdc and fix a memory leak * * Revision 1.20 2017/09/28 17:00:48 akio * adding BitShiftGain * * Revision 1.19 2017/09/15 15:43:54 akio * Adding readGainCorrFromText() * * Revision 1.18 2017/08/14 16:08:55 smirnovd * StFmsDbMaker: Declare member functions const * * These methods don't change the object by design * * Revision 1.17 2017/08/14 16:08:43 smirnovd * [Cosmetic] Remove StRoot/ from include path * * $STAR/StRoot is already in the default path search * * Revision 1.16 2017/05/03 17:14:01 akio * Adding Sigma and Valley for Fps/Fpost * * Revision 1.15 2017/01/30 17:50:16 akio * adding Fpost * * Revision 1.14 2016/11/22 18:23:32 akio * added getLorentzVector to take into account beamline angles/offsets for pt calc * * Revision 1.13 2016/06/08 19:58:03 akio * Applying Coverity report * * Revision 1.12 2015/11/10 19:06:02 akio * Adding TimeDepCorr for LED gain correction based on event# * * Revision 1.11 2015/10/20 19:49:28 akio * Fixing distanceFromEdge() * Adding readRecParamFromFile() * * Revision 1.10 2015/09/23 17:34:01 akio * Adding distanceFromEdge() for fiducial volume cut * * Revision 1.9 2015/09/18 18:34:35 akio * Adding getStarXYZfromColumnRow() to convert from local grid space [cell width unit, not cm] * Adding protection for fmsGain and fmsGainCorrection when table length get shorter and can * overwritten by old values. * Removing some error log * * Revision 1.8 2015/09/02 14:45:14 akio * Adding new functions for un-uniform grid cell positions, switched based on DB fmsPositionModel * * Revision 1.4 2014/08/06 11:43:15 jeromel * Suffix on literals need to be space (later gcc compiler makes it an error) - first wave of fixes * * Revision 1.3 2014/04/24 21:15:04 tpb * Change default name to fmsDb to match BFC * * Revision 1.2 2010/01/11 20:35:30 jgma * Added reversed map and some other minor updates * * Revision 1.1 2009/10/28 16:11:15 jgma * This is the first check in of the code. * **************************************************************************/ #ifndef STFMSDBMAKER_H #define STFMSDBMAKER_H #ifndef StMaker_H #include "StMaker.h" #endif #include "StThreeVectorF.hh" #include "StLorentzVectorF.hh" #include "StFmsUtil/StFmsDbConfig.h" struct fmsDetectorPosition_st; struct fmsChannelGeometry_st; struct fmsMap_st; struct fmsPatchPanelMap_st; struct fmsQTMap_st; struct fmsGain_st; struct fmsGainCorrection_st; struct fmsBitShiftGain_st; struct fmsGainB_st; struct fmsGainCorrectionB_st; struct fmsBitShiftGainB_st; struct fmsTimeDepCorr_st; struct fmsRec_st; struct fpsConstant_st; struct fpsChannelGeometry_st; struct fpsSlatId_st; struct fpsPosition_st; struct fpsMap_st; struct fpsGain_st; struct fpsStatus_st; struct fpostConstant_st; struct fpostChannelGeometry_st; struct fpostSlatId_st; struct fpostPosition_st; struct fpostMap_st; struct fpostGain_st; struct fpostStatus_st; class StFmsHit; class StFmsPoint; class StFmsDbMaker : public StMaker { public: StFmsDbMaker(const Char_t *name="fmsDb"); virtual ~StFmsDbMaker(); virtual Int_t Init(); virtual Int_t InitRun(Int_t runNumber); virtual Int_t Make(); virtual Int_t Finish(); virtual void Clear(const Char_t *opt); void setDebug(Int_t debug); ///< debug mode, 0 for minimal message, >0 for more debug messages //! getting the whole table fmsChannelGeometry_st* ChannelGeometry(); fmsDetectorPosition_st* DetectorPosition(); fmsMap_st* Map(); fmsPatchPanelMap_st* PatchPanelMap(); fmsQTMap_st* QTMap(); fmsGain_st* Gain(); fmsGainCorrection_st* GainCorrection(); fmsRec_st* RecPar(); //reconstruction related parameters fpsConstant_st* FpsConstant(); fpsChannelGeometry_st** FpsChannelGeometry(); fpsSlatId_st* FpsSlatId(); fpsPosition_st* FpsPosition(); fpsMap_st* FpsMap(); fpsGain_st* FpsGain(); fpostConstant_st* FpostConstant(); fpostChannelGeometry_st** FpostChannelGeometry(); fpostSlatId_st* FpostSlatId(); fpostPosition_st* FpostPosition(); fpostMap_st* FpostMap(); fpostGain_st* FpostGain(); //! Utility functions related to FMS ChannelGeometry UShort_t maxDetectorId(); //! maximum value of detector Id Int_t detectorId(Int_t ew, Int_t ns, Int_t type); //! convert to detector Id Int_t eastWest(Int_t detectorId); //! east or west to the STAR IP Int_t northSouth(Int_t detectorId); //! north or south side Int_t largeSmall(Int_t detectorId); //! large or small cells for FMS Int_t type(Int_t detectorId); //! type of the detector Int_t nRow(Int_t detectorId); //! number of rows Int_t nColumn(Int_t detectorId); //! number of column UShort_t maxChannel(Int_t detectorId) const; //! maximum number of channels Int_t getRowNumber(Int_t detectorId, Int_t ch); //! get the row number for the channel Int_t getColumnNumber(Int_t detectorId, Int_t ch); //! get the column number for the channel Int_t getChannelNumber(Int_t detectorId, Int_t row, Int_t column); //! get the channel number //! Utility functions related to DetectorPosition StThreeVectorF getDetectorOffset(Int_t detectorId); //! get the offset of the detector Float_t getXWidth(Int_t detectorId); //! get the X width of the cell Float_t getYWidth(Int_t detectorId); //! get the Y width of the cell StThreeVectorF getStarXYZ(Int_t detectorId,Float_t FmsX, Float_t FmsY); //! get the STAR frame coordinates from local X/Y [cm] StThreeVectorF getStarXYZ(Int_t detectorId,Double_t FmsX, Double_t FmsY); //! get the STAR frame coordinates from local X/Y [cm] StThreeVectorF getStarXYZ(Int_t detectorId,Int_t column, int row); //! get the STAR frame coordinates from column/row StThreeVectorF getStarXYZfromColumnRow(Int_t detectorId,Float_t column, Float_t row); //! get the STAR frame coordinates from column/row grid space [unit is cell size] StThreeVectorF getStarXYZ(StFmsHit*); //! get the STAR frame coordinates from StFmsHit StThreeVectorF getStarXYZ(Int_t detectorId,Int_t ch); //! get the STAR frame cooridnates for center of the cell Float_t getPhi(Int_t detectorId,Float_t FmsX, Float_t FmsY); //! get the STAR frame phi angle from from local X/Y [cm] Float_t getEta(Int_t detectorId,Float_t FmsX, Float_t FmsY, Float_t Vertex); //! get the STAR frame pseudo rapidity from the vertex from local X/Y [cm] StLorentzVectorF getLorentzVector(const StThreeVectorF& xyz, Float_t energy); //! get 4 vector assuing m=0 and taking beamline from DB // Distance(unit is incell space) from edge for given local X/Y [cm] for fiducial volume cut // return negative distance if inside, positive outside // edge: 0=well inside (more than 1 cell) // 1=inner edge // 2=outer edge // 3=between north and south // 4=between small and large // 4=large cell corner Float_t distanceFromEdge(Int_t det,Float_t x, Float_t y, int& edge); Float_t distanceFromEdge(StFmsPoint* point, int& edge); Int_t nCellHole(Int_t det); Int_t nCellCorner(Int_t det); //! fmsMap related Int_t maxMap(); void getMap(Int_t detectorId, Int_t ch, Int_t* qtCrate, Int_t* qtSlot, Int_t* qtChannel); void getReverseMap(Int_t qtCrate, Int_t qtSlot, Int_t qtChannel, Int_t* detectorId, Int_t* ch) const; //! fmsPatchPanelMap related Int_t maxModule(); //! fmsQTMap related Int_t maxNS(); //! fmsGain/GainCorrection/Bitshift related Int_t maxGain(); Int_t maxGainCorrection(); Int_t maxBitShiftGain(); Float_t getGain(Int_t detectorId, Int_t ch) const; //! get the gain for the channel Float_t getGainCorrection(Int_t detectorId, Int_t ch) const; //! get the gain correction for the channel Short_t getBitShiftGain(Int_t detectorId, Int_t ch) const; //! get the bit shift gain for the channel unsigned short getCorrectedAdc(unsigned short detectorId, unsigned short ch, unsigned short adc) const; unsigned short getCorrectedAdc(StFmsHit* hit) const; void forceUniformGain(float v) {mForceUniformGain=v; } //! force gain to be specified value void forceUniformGainCorrection(float v) {mForceUniformGainCorrection=v;} //! force gaincorr to be specified value void forceUniformBitShiftGain(short v) {mForceUniformBitShiftGain=v;} //! force bits hift gain to be specified value void readGainFromText(int v=1) {mReadGainFile=v;} //! force gain to be read from FmsGain.txt void readGainCorrFromText(int v=1) {mReadGainCorrFile=v;} //! force gain corr to be read from FmsGainCorr.txt void readBitShiftGainFromText(int v=1) {mReadBitShiftGainFile=v;} //! force bit shift to be read from FmsBitShiftGain.txt //! fmsTimeDepCorr relayed float getTimeDepCorr(int event, int det, int ch); //det = detectorId - 8 (0=largeNoth, 1=largeSouth, 2=smallNorth, 3=smallSouth) //ch=1 to 578 //reference to StFmsDbConfig StFmsDbConfig& getRecConfig(); void readRecParamFromFile(int v=1){mReadRecParam=v;} // Read fmsrecpar.txt for reconstuction parameters //! FPS related Int_t fpsNQuad(); Int_t fpsNLayer(); Int_t fpsMaxSlat(); Int_t fpsMaxQTaddr(); Int_t fpsMaxQTch(); Int_t fpsMaxSlatId(); Int_t fpsNSlat(int quad, int layer); Int_t fpsSlatId(int quad, int layer, int slat); void fpsQLSfromSlatId(int slatid, int* quad, int* layer, int* slat); void fpsPosition(int slatid, float xyz[3], float dxyz[3]); void fpsPosition(int quad, int layer, int slat, float xyz[3], float dxyz[3]); void fpsQTMap(int slatid, int* QTaddr, int* QTch); Int_t fpsSlatidFromQT(int QTaddr, int QTch); void fpsQLSFromQT(int QTaddr, int QTch, int* quad, int* layer, int* slat); Float_t fpsGain(int slatid); Float_t fpsGain(int quad, int layer, int slat); Float_t fpsMipSigma(int slatid); Float_t fpsMipSigma(int quad, int layer, int slat); Float_t fpsValley(int slatid); Float_t fpsValley(int quad, int layer, int slat); UShort_t fpsStatus(int slatid); UShort_t fpsStatus(int quad, int layer, int slat); Int_t fpsSlatIdFromG2t(int g2tvolid); //! FPost related Int_t fpostNQuad(); Int_t fpostNLayer(); Int_t fpostMaxSlat(); Int_t fpostMaxQTaddr(); Int_t fpostMaxQTch(); Int_t fpostMaxSlatId(); Int_t fpostNSlat(int quad, int layer); Int_t fpostSlatId(int quad, int layer, int slat); void fpostQLSfromSlatId(int slatid, int* quad, int* layer, int* slat); void fpostPosition(int slatid, float xyz[3], float dxyz[3], float * angle); void fpostPosition(int quad, int layer, int slat, float xyz[3], float dxyz[3], float* angle); void fpostQTMap(int slatid, int* QTaddr, int* QTch); Int_t fpostSlatidFromQT(int QTaddr, int QTch); void fpostQLSFromQT(int QTaddr, int QTch, int* quad, int* layer, int* slat); Float_t fpostGain(int slatid); Float_t fpostGain(int quad, int layer, int slat); Float_t fpostMipSigma(int slatid); Float_t fpostMipSigma(int quad, int layer, int slat); Float_t fpostValley(int slatid); Float_t fpostValley(int quad, int layer, int slat); UShort_t fpostStatus(int slatid); UShort_t fpostStatus(int quad, int layer, int slat); Int_t fpostSlatIdFromG2t(int g2tvolid); //! text dump for debugging void dumpFmsChannelGeometry (const Char_t* filename="dumpFmsChannelGeometry.txt"); void dumpFmsDetectorPosition(const Char_t* filename="dumpFmsDetectorPosition.txt"); void dumpFmsMap (const Char_t* filename="dumpFmsMap.txt"); void dumpFmsPatchPanelMap (const Char_t* filename="dumpFmsPatchPanelMap.txt"); void dumpFmsQTMap (const Char_t* filename="dumpFmsQTMap.txt"); void dumpFmsGain (const Char_t* filename="dumpFmsGain.txt"); void dumpFmsGainCorrection (const Char_t* filename="dumpFmsGainCorrection.txt"); void dumpFmsBitShiftGain (const Char_t* filename="dumpFmsBitShiftGain.txt"); void dumpFmsTimeDepCorr (const Char_t* filename="dumpFmsTimeDepCorr.txt"); void dumpFmsRec (const Char_t* filename="dumpFmsRec.txt"); void dumpFpsConstant (const Char_t* filename="dumpFpsConstant.txt"); void dumpFpsChannelGeometry (const Char_t* filename="dumpFpsChannelGeometry.txt"); void dumpFpsSlatId (const Char_t* filename="dumpSlatId.txt"); void dumpFpsPosition (const Char_t* filename="dumpFpsPosition.txt"); void dumpFpsMap (const Char_t* filename="dumpFpsMap.txt"); void dumpFpsGain (const Char_t* filename="dumpFpsGain.txt"); void dumpFpsStatus (const Char_t* filename="dumpFpsStatus.txt"); void dumpFpostConstant (const Char_t* filename="dumpFpostConstant.txt"); void dumpFpostChannelGeometry (const Char_t* filename="dumpFpostChannelGeometry.txt"); void dumpFpostSlatId (const Char_t* filename="dumpSlatId.txt"); void dumpFpostPosition (const Char_t* filename="dumpFpostPosition.txt"); void dumpFpostMap (const Char_t* filename="dumpFpostMap.txt"); void dumpFpostGain (const Char_t* filename="dumpFpostGain.txt"); void dumpFpostStatus (const Char_t* filename="dumpFpostStatus.txt"); private: void deleteArrays(); Int_t mDebug=0; //! >0 dump tables to text files fmsChannelGeometry_st *mChannelGeometry=0; //! channel configuration for each detector UShort_t mMaxDetectorId=0; //! max detector Id fmsDetectorPosition_st *mDetectorPosition=0; //! position (in STAR frame) of each detector unsigned int mPositionModel=0; //! Position model (0=uniform, 1=run15pp, 2=run15pA) fmsMap_st *mMap=0; //! detector map fmsMap_st **mmMap=0; Int_t mMaxMap=0; enum {mMaxCrate=8, mMaxSlot=17, mMaxCh=32}; Int_t mReverseMapDetectorId[mMaxCrate][mMaxSlot][mMaxCh]; //! Int_t mReverseMapChannel[mMaxCrate][mMaxSlot][mMaxCh]; //! fmsPatchPanelMap_st *mPatchPanelMap=0; //! patch panel map Int_t mMaxModule=0; fmsQTMap_st *mQTMap=0; //! Qt map Int_t mMaxNS=0; fmsGain_st *mGain=0; //! gain table fmsGainB_st *mGainB=0; //! new gain table fmsGain_st **mmGain=0; Int_t mMaxGain=0; fmsGainCorrection_st *mGainCorrection=0; //! gain correction table fmsGainCorrectionB_st *mGainCorrectionB=0; //! new gain correction table fmsGainCorrection_st **mmGainCorrection=0; Int_t mMaxGainCorrection=0; fmsBitShiftGain_st *mBitShiftGain=0; //! bit shift gain table fmsBitShiftGainB_st *mBitShiftGainB=0; //! new bit shift gain table fmsBitShiftGain_st **mmBitShiftGain=0; Int_t mMaxBitShiftGain=0; enum {mFmsTimeDepMaxData=20000,mFmsTimeDepMaxTimeSlice=200,mFmsTimeDepMaxDet=4,mFmsTimeDepMaxCh=578}; fmsTimeDepCorr_st *mTimeDepCorr=0; int mMaxTimeSlice=0; int mTimeDepEvt[mFmsTimeDepMaxTimeSlice]; float mTimeDep[mFmsTimeDepMaxTimeSlice][mFmsTimeDepMaxDet][mFmsTimeDepMaxCh]; fmsRec_st *mRecPar=0; //! rec. parameters table Int_t mMaxRecPar=0; StFmsDbConfig& mRecConfig; //reference to StFmsDbConfig singleton, for accessing rec. parameter values by name Float_t mForceUniformGain=0.0; //! Float_t mForceUniformGainCorrection=0.0; //! Short_t mForceUniformBitShiftGain=0; //! Int_t mReadGainFile=0; //! Int_t mReadGainCorrFile=0; //! Int_t mReadBitShiftGainFile=0; //! Int_t mReadRecParam=0; //! fpsConstant_st* mFpsConstant=0; Int_t mFpsMaxSlatId=0; fpsChannelGeometry_st** mFpsChannelGeometry=0; fpsSlatId_st* mFpsSlatId=0; Int_t*** mFpsReverseSlatId=0; fpsPosition_st* mFpsPosition=0; fpsMap_st* mFpsMap=0; Int_t** mFpsReverseMap=0; fpsGain_st* mFpsGain=0; fpsStatus_st* mFpsStatus=0; fpostConstant_st* mFpostConstant=0; Int_t mFpostMaxSlatId=0; fpostChannelGeometry_st** mFpostChannelGeometry=0; fpostSlatId_st* mFpostSlatId=0; Int_t*** mFpostReverseSlatId=0; fpostPosition_st* mFpostPosition=0; fpostMap_st* mFpostMap=0; Int_t** mFpostReverseMap=0; fpostGain_st* mFpostGain=0; fpostStatus_st* mFpostStatus=0; virtual const Char_t *GetCVS() const {static const Char_t cvs[]="Tag $Name:" __DATE__ " " __TIME__ ; return cvs;} ClassDef(StFmsDbMaker,3) //StAF chain virtual base class for Makers }; #endif
44.765
157
0.677873
5aae1e3cbca3633ac8ea281da8b0b589b5f55afe
410
h
C
Sources/Mimus/Mimus.h
AirHelp/Mimus
fca9cd6ac22e08ac397c4ab4415fe849bd377cc8
[ "MIT" ]
107
2017-03-23T14:43:37.000Z
2021-01-29T12:30:55.000Z
Sources/Mimus/Mimus.h
mimus-swift/Mimus
fca9cd6ac22e08ac397c4ab4415fe849bd377cc8
[ "MIT" ]
16
2017-03-23T14:37:00.000Z
2020-11-05T09:31:44.000Z
Sources/Mimus/Mimus.h
AirHelp/Mimus
fca9cd6ac22e08ac397c4ab4415fe849bd377cc8
[ "MIT" ]
9
2017-03-24T15:39:22.000Z
2020-11-03T10:35:08.000Z
// // Copyright (©) 2017 AirHelp. All rights reserved. // #import <Foundation/Foundation.h> //! Project version number for Mimus. FOUNDATION_EXPORT double MimusVersionNumber; //! Project version string for Mimus. FOUNDATION_EXPORT const unsigned char MimusVersionString[]; // In this header, you should import all the public headers of your framework using statements like #import <Mimus/PublicHeader.h>
25.625
130
0.773171
204c966632832538933e3d5e60c1e3cb9efdd337
27,164
c
C
src/lib/init/devices/processors/Proc_padsynth.c
kagu/kunquat
83a2e972121e6a114ecc5ef4392b501ce926bb06
[ "CC0-1.0" ]
13
2016-09-01T21:52:49.000Z
2022-03-24T06:07:20.000Z
src/lib/init/devices/processors/Proc_padsynth.c
kagu/kunquat
83a2e972121e6a114ecc5ef4392b501ce926bb06
[ "CC0-1.0" ]
290
2015-03-14T10:59:25.000Z
2022-03-20T08:32:17.000Z
src/lib/init/devices/processors/Proc_padsynth.c
kagu/kunquat
83a2e972121e6a114ecc5ef4392b501ce926bb06
[ "CC0-1.0" ]
7
2015-03-19T13:28:11.000Z
2019-09-03T16:21:16.000Z
/* * Author: Tomi Jylhä-Ollila, Finland 2016-2019 * * This file is part of Kunquat. * * CC0 1.0 Universal, http://creativecommons.org/publicdomain/zero/1.0/ * * To the extent possible under law, Kunquat Affirmers have waived all * copyright and related or neighboring rights to Kunquat. */ #include <init/devices/processors/Proc_padsynth.h> #include <containers/AAtree.h> #include <containers/Array.h> #include <debug/assert.h> #include <init/Background_loader.h> #include <init/devices/param_types/Padsynth_params.h> #include <init/devices/Proc_cons.h> #include <init/devices/processors/Proc_init_utils.h> #include <mathnum/common.h> #include <mathnum/conversions.h> #include <mathnum/fft.h> #include <mathnum/Random.h> #include <memory.h> #include <player/devices/processors/Padsynth_state.h> #include <math.h> #include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> static Set_padsynth_params_func Proc_padsynth_set_params; static Set_bool_func Proc_padsynth_set_ramp_attack; static Set_bool_func Proc_padsynth_set_stereo; static Set_float_func Proc_padsynth_set_start_pos; static Set_bool_func Proc_padsynth_set_start_pos_var_enabled; static Set_bool_func Proc_padsynth_set_round_start_pos_var_to_period; static Set_float_func Proc_padsynth_set_start_pos_var; static bool apply_padsynth( Proc_padsynth* padsynth, const Padsynth_params* params, Background_loader* bkg_loader); static void del_Proc_padsynth(Device_impl* dimpl); struct Padsynth_sample_map { int sample_count; int32_t sample_length; double min_pitch; double max_pitch; double centre_pitch; AAtree* map; }; #define PADSYNTH_SAMPLE_ENTRY_KEY(pitch) \ (&(Padsynth_sample_entry){ .centre_pitch = pitch, .sample = NULL }) static int Padsynth_sample_entry_cmp( const Padsynth_sample_entry* entry1, const Padsynth_sample_entry* entry2) { rassert(entry1 != NULL); rassert(entry2 != NULL); if (entry1->centre_pitch < entry2->centre_pitch) return -1; else if (entry1->centre_pitch > entry2->centre_pitch) return 1; return 0; } static void del_Padsynth_sample_entry(Padsynth_sample_entry* entry) { if (entry == NULL) return; del_Sample(entry->sample); memory_free(entry); return; } static void del_Padsynth_sample_map(Padsynth_sample_map* sm); static Padsynth_sample_map* new_Padsynth_sample_map( int sample_count, int32_t sample_length) { rassert(sample_count > 0); rassert(sample_count <= 128); rassert(sample_length >= PADSYNTH_MIN_SAMPLE_LENGTH); rassert(sample_length <= PADSYNTH_MAX_SAMPLE_LENGTH); rassert(is_p2(sample_length)); Padsynth_sample_map* sm = memory_alloc_item(Padsynth_sample_map); if (sm == NULL) return NULL; sm->sample_count = sample_count; sm->sample_length = sample_length; sm->min_pitch = NAN; sm->max_pitch = NAN; sm->centre_pitch = NAN; sm->map = NULL; sm->map = new_AAtree( (AAtree_item_cmp*)Padsynth_sample_entry_cmp, (AAtree_item_destroy*)del_Padsynth_sample_entry); if (sm->map == NULL) { del_Padsynth_sample_map(sm); return NULL; } for (int i = 0; i < sample_count; ++i) { float* buf = memory_alloc_items(float, sample_length + 1); if (buf == NULL) { del_Padsynth_sample_map(sm); return NULL; } Sample* sample = new_Sample_from_buffers(&buf, 1, sample_length + 1); if (sample == NULL) { memory_free(buf); del_Padsynth_sample_map(sm); return NULL; } Padsynth_sample_entry* entry = memory_alloc_item(Padsynth_sample_entry); if (entry == NULL) { del_Sample(sample); del_Padsynth_sample_map(sm); return NULL; } entry->centre_pitch = (double)i; // placeholder to get unique keys :-P entry->sample = sample; if (!AAtree_ins(sm->map, entry)) { del_Padsynth_sample_entry(entry); del_Padsynth_sample_map(sm); return NULL; } } return sm; } static void Padsynth_sample_map_set_centre_pitch( Padsynth_sample_map* sm, double centre_pitch) { rassert(sm != NULL); rassert(isfinite(centre_pitch)); sm->centre_pitch = centre_pitch; return; } static void Padsynth_sample_map_set_pitch_range( Padsynth_sample_map* sm, double min_pitch, double max_pitch) { rassert(sm != NULL); rassert(isfinite(min_pitch)); rassert(isfinite(max_pitch)); rassert(min_pitch <= max_pitch); sm->min_pitch = min_pitch; sm->max_pitch = max_pitch; return; } static double round_to_period(double cents, int32_t sample_length) { rassert(isfinite(cents)); rassert(sample_length > 0); const double entry_Hz = cents_to_Hz(cents); const double cycle_length = PADSYNTH_DEFAULT_AUDIO_RATE / entry_Hz; const double cycle_count = sample_length / cycle_length; const double rounded_cycle_count = round(cycle_count); const double rounded_cycle_length = sample_length / rounded_cycle_count; const double rounded_entry_Hz = PADSYNTH_DEFAULT_AUDIO_RATE / rounded_cycle_length; const double rounded_entry_cents = log2(rounded_entry_Hz / 440) * 1200.0; return rounded_entry_cents; } static void Padsynth_sample_map_update_sample_pitches( Padsynth_sample_map* sm, bool enable_rounding) { rassert(sm != NULL); rassert(isfinite(sm->min_pitch)); rassert(isfinite(sm->max_pitch)); rassert(isfinite(sm->centre_pitch)); AAiter* iter = AAiter_init(AAITER_AUTO, sm->map); const Padsynth_sample_entry* key = PADSYNTH_SAMPLE_ENTRY_KEY(-INFINITY); Padsynth_sample_entry* entry = AAiter_get_at_least(iter, key); if (sm->sample_count == 1) { rassert(entry != NULL); const double unrounded_pitch = (sm->min_pitch + sm->max_pitch) * 0.5; if (enable_rounding) entry->centre_pitch = round_to_period(unrounded_pitch, sm->sample_length); else entry->centre_pitch = unrounded_pitch; entry = AAiter_get_next(iter); } else { for (int i = 0; i < sm->sample_count; ++i) { rassert(entry != NULL); const double unrounded_pitch = lerp(sm->min_pitch, sm->max_pitch, i / (double)(sm->sample_count - 1)); if (enable_rounding) entry->centre_pitch = round_to_period(unrounded_pitch, sm->sample_length); else entry->centre_pitch = unrounded_pitch; entry = AAiter_get_next(iter); } } rassert(entry == NULL); return; } const Padsynth_sample_entry* Padsynth_sample_map_get_entry( const Padsynth_sample_map* sm, double pitch) { rassert(sm != NULL); rassert(isfinite(pitch)); const Padsynth_sample_entry* key = PADSYNTH_SAMPLE_ENTRY_KEY(pitch); const Padsynth_sample_entry* prev = AAtree_get_at_most(sm->map, key); const Padsynth_sample_entry* next = AAtree_get_at_least(sm->map, key); if (prev == NULL) return next; else if (next == NULL) return prev; if (fabs(next->centre_pitch - pitch) < fabs(prev->centre_pitch - pitch)) return next; return prev; } int32_t Padsynth_sample_map_get_sample_length(const Padsynth_sample_map* sm) { rassert(sm != NULL); return sm->sample_length; } static void del_Padsynth_sample_map(Padsynth_sample_map* sm) { if (sm == NULL) return; del_AAtree(sm->map); memory_free(sm); return; } Device_impl* new_Proc_padsynth(void) { Proc_padsynth* padsynth = memory_alloc_item(Proc_padsynth); if (padsynth == NULL) return NULL; padsynth->sample_map = NULL; padsynth->is_ramp_attack_enabled = true; padsynth->is_stereo_enabled = false; padsynth->start_pos = 0.0; padsynth->is_start_pos_var_enabled = true; padsynth->round_start_pos_var_to_period = false; padsynth->start_pos_var = 1.0; if (!Device_impl_init(&padsynth->parent, del_Proc_padsynth)) { del_Device_impl(&padsynth->parent); return NULL; } padsynth->parent.get_vstate_size = Padsynth_vstate_get_size; padsynth->parent.init_vstate = Padsynth_vstate_init; padsynth->parent.render_voice = Padsynth_vstate_render_voice; if (!(REGISTER_SET_FIXED_STATE( padsynth, padsynth_params, params, "p_ps_params.json", NULL) && REGISTER_SET_FIXED_STATE( padsynth, bool, ramp_attack, "p_b_ramp_attack.json", true) && REGISTER_SET_FIXED_STATE( padsynth, bool, stereo, "p_b_stereo.json", false) && REGISTER_SET_FIXED_STATE( padsynth, float, start_pos, "p_f_start_pos.json", 0.0) && REGISTER_SET_FIXED_STATE( padsynth, bool, start_pos_var_enabled, "p_b_start_pos_var_enabled.json", true) && REGISTER_SET_FIXED_STATE( padsynth, bool, round_start_pos_var_to_period, "p_b_round_start_pos_var_to_period.json", false) && REGISTER_SET_FIXED_STATE( padsynth, float, start_pos_var, "p_f_start_pos_var.json", 1.0) )) { del_Device_impl(&padsynth->parent); return NULL; } Random_init(&padsynth->random, "PADsynth"); if (!apply_padsynth(padsynth, NULL, NULL)) { del_Device_impl(&padsynth->parent); return NULL; } return &padsynth->parent; } static bool Proc_padsynth_set_params( Device_impl* dimpl, const Key_indices indices, const Padsynth_params* params, Background_loader* bkg_loader) { rassert(dimpl != NULL); ignore(indices); Proc_padsynth* padsynth = (Proc_padsynth*)dimpl; return apply_padsynth(padsynth, params, bkg_loader); } static bool Proc_padsynth_set_ramp_attack( Device_impl* dimpl, const Key_indices indices, bool enabled) { rassert(dimpl != NULL); rassert(indices != NULL); Proc_padsynth* padsynth = (Proc_padsynth*)dimpl; padsynth->is_ramp_attack_enabled = enabled; return true; } static bool Proc_padsynth_set_stereo( Device_impl* dimpl, const Key_indices indices, bool enabled) { rassert(dimpl != NULL); rassert(indices != NULL); Proc_padsynth* padsynth = (Proc_padsynth*)dimpl; padsynth->is_stereo_enabled = enabled; return true; } static bool Proc_padsynth_set_start_pos_var_enabled( Device_impl* dimpl, const Key_indices indices, bool enabled) { rassert(dimpl != NULL); rassert(indices != NULL); Proc_padsynth* padsynth = (Proc_padsynth*)dimpl; padsynth->is_start_pos_var_enabled = enabled; return true; } static bool Proc_padsynth_set_round_start_pos_var_to_period( Device_impl* dimpl, const Key_indices indices, bool enabled) { rassert(dimpl != NULL); rassert(indices != NULL); Proc_padsynth* padsynth = (Proc_padsynth*)dimpl; padsynth->round_start_pos_var_to_period = enabled; return true; } static bool Proc_padsynth_set_start_pos_var( Device_impl* dimpl, const Key_indices indices, double var) { rassert(dimpl != NULL); rassert(indices != NULL); const double applied_var = ((0 <= var) && (var <= 1.0)) ? var : 0.0; Proc_padsynth* padsynth = (Proc_padsynth*)dimpl; padsynth->start_pos_var = applied_var; return true; } static bool Proc_padsynth_set_start_pos( Device_impl* dimpl, const Key_indices indices, double pos) { rassert(dimpl != NULL); rassert(indices != NULL); const double applied_pos = ((0 <= pos) && (pos <= 1.0)) ? pos : 0.0; Proc_padsynth* padsynth = (Proc_padsynth*)dimpl; padsynth->start_pos = applied_pos; return true; } static double profile(double freq_i, double bandwidth_i) { double x = freq_i / bandwidth_i; x *= x; if (x > 27.2972) return 0.0; return exp(-x) / bandwidth_i; } static double get_profile_bound(double bandwidth_i) { rassert(isfinite(bandwidth_i)); rassert(bandwidth_i > 0); return 5.2247 * bandwidth_i; // 5.2247 ~ sqrt(27.2972), see profile() above } static double get_phase_spread(double freq_i, double bandwidth_i) { const double x = freq_i / bandwidth_i; return 1.0 - exp(-x * x); } typedef struct Callback_data { Padsynth_sample_entry* entry; int context_index; double* freq_amp; double* freq_phase; FFT_worker fw; const Padsynth_params* params; } Callback_data; static void del_Callback_data(Callback_data* cb_data) { if (cb_data == NULL) return; memory_free(cb_data->freq_amp); memory_free(cb_data->freq_phase); FFT_worker_deinit(&cb_data->fw); memory_free(cb_data); return; } static Callback_data* new_Callback_data(const Padsynth_params* params) { Callback_data* cb_data = memory_alloc_item(Callback_data); if (cb_data == NULL) return NULL; cb_data->entry = NULL; cb_data->context_index = 0; cb_data->freq_amp = NULL; cb_data->freq_phase = NULL; cb_data->params = params; int32_t sample_length = PADSYNTH_DEFAULT_SAMPLE_LENGTH; if (params != NULL) sample_length = params->sample_length; const int32_t buf_length = sample_length / 2; cb_data->freq_amp = memory_alloc_items(double, buf_length); cb_data->freq_phase = memory_alloc_items(double, buf_length); FFT_worker* fw = FFT_worker_init(&cb_data->fw, sample_length); if (cb_data->freq_amp == NULL || cb_data->freq_phase == NULL || fw == NULL) { del_Callback_data(cb_data); return NULL; } return cb_data; } static void cleanup_cb_data(Error* error, void* user_data) { rassert(error != NULL); rassert(user_data != NULL); Callback_data* cb_data = user_data; del_Callback_data(cb_data); return; } static void make_padsynth_sample(Error* error, void* user_data) { rassert(error != NULL); rassert(user_data != NULL); Callback_data* cb_data = user_data; rassert(cb_data->entry != NULL); rassert(cb_data->context_index >= 0); rassert(cb_data->context_index < PADSYNTH_MAX_SAMPLE_COUNT); rassert(cb_data->freq_amp != NULL); rassert(cb_data->freq_phase != NULL); char context_str[16] = ""; snprintf(context_str, 16, "PADsynth%hd", (short)cb_data->context_index); Random* random = Random_init(RANDOM_AUTO, context_str); double* freq_amp = cb_data->freq_amp; double* freq_phase = cb_data->freq_phase; const Padsynth_params* params = cb_data->params; int32_t sample_length = PADSYNTH_DEFAULT_SAMPLE_LENGTH; if (params != NULL) sample_length = params->sample_length; const int32_t buf_length = sample_length / 2; for (int32_t i = 0; i < buf_length; ++i) { freq_amp[i] = 0; freq_phase[i] = 0; } const bool use_phase_data = (params != NULL) ? params->use_phase_data : false; if (params != NULL) { const int32_t audio_rate = params->audio_rate; const double bandwidth_base = params->bandwidth_base; const double bandwidth_scale = params->bandwidth_scale; const double freq = cents_to_Hz(cb_data->entry->centre_pitch); const double ps_bw_base = params->phase_spread_bandwidth_base; const double ps_bw_scale = params->phase_spread_bandwidth_scale; const double phase_var_at_h = params->phase_var_at_harmonic; const double phase_var_off_h = params->phase_var_off_harmonic; const int32_t nyquist = params->audio_rate / 2; char phase_context_str[16] = ""; snprintf(phase_context_str, 16, "PADphase%hd", (short)cb_data->context_index); Random* phase_random = Random_init(RANDOM_AUTO, phase_context_str); for (int64_t h = 0; h < Array_get_size(params->harmonics); ++h) { const Padsynth_harmonic* harmonic = Array_get_ref(params->harmonics, h); // Skip harmonics that are not representable // NOTE: this only checks the centre frequency if (freq * harmonic->freq_mul >= nyquist) continue; const double bandwidth_Hz = (exp2(bandwidth_base / 1200.0) - 1.0) * freq * pow(harmonic->freq_mul, bandwidth_scale); const double bandwidth_i = bandwidth_Hz / (2.0 * audio_rate); const double freq_i = freq * harmonic->freq_mul / audio_rate; // Get index range with non-zero data const double profile_bound = get_profile_bound(bandwidth_i); int32_t buf_start = (int32_t)ceil(sample_length * (freq_i - profile_bound)); int32_t buf_stop = (int32_t)ceil(sample_length * (freq_i + profile_bound)); if (buf_start >= buf_length || buf_stop <= 0) continue; //rassert(profile((buf_start - 1) / (double)sample_length - freq_i, bandwidth_i) == 0.0); //rassert(profile((buf_stop + 1) / (double)sample_length - freq_i, bandwidth_i) == 0.0); buf_start = max(0, buf_start); buf_stop = min(buf_stop, buf_length); if (use_phase_data) { // Phase spread const double ps_bandwidth_Hz = (exp2(ps_bw_base / 1200.0) - 1.0) * freq * pow(harmonic->freq_mul, ps_bw_scale); const double ps_bandwidth_i = ps_bandwidth_Hz / (2.0 * audio_rate); Random_set_seed(phase_random, Random_get_uint64(random)); for (int32_t i = buf_start; i < buf_stop; ++i) { // Add amplitude and phase of the harmonic const double orig_amp = freq_amp[i]; const double orig_phase = freq_phase[i]; const double orig_real = orig_amp * cos(orig_phase); const double orig_imag = orig_amp * sin(orig_phase); const double harmonic_profile = profile((i / (double)sample_length) - freq_i, bandwidth_i); const double add_amp = harmonic_profile * harmonic->amplitude; const double add_real = add_amp * cos(harmonic->phase); const double add_imag = add_amp * sin(harmonic->phase); const double new_real = orig_real + add_real; const double new_imag = orig_imag + add_imag; const double new_amp = sqrt((new_real * new_real) + (new_imag * new_imag)); double new_phase = atan2(new_imag, new_real); if (new_phase < 0) new_phase += PI2; // Add phase variation const double phase_spread_norm = get_phase_spread( (i / (double)sample_length) - freq_i, ps_bandwidth_i); const double phase_spread = lerp(phase_var_at_h, phase_var_off_h, phase_spread_norm); new_phase += Random_get_float_lb(phase_random) * PI2 * phase_spread; if (new_phase >= PI2) new_phase = fmod(new_phase, PI2); freq_amp[i] = new_amp; freq_phase[i] = new_phase; } } else { for (int32_t i = buf_start; i < buf_stop; ++i) { const double harmonic_profile = profile((i / (double)sample_length) - freq_i, bandwidth_i); freq_amp[i] += harmonic_profile * harmonic->amplitude; } } } if (params->is_res_env_enabled && (params->res_env != NULL)) { // Apply resonance envelope for (int i = 0; i < buf_length; ++i) { const double env_x = i * 24000.0 / (buf_length - 1); const double mult = Envelope_get_value(params->res_env, env_x); rassert(isfinite(mult)); freq_amp[i] *= mult; } } } else { static const int32_t audio_rate = PADSYNTH_DEFAULT_AUDIO_RATE; static const double bandwidth_base = PADSYNTH_DEFAULT_BANDWIDTH_BASE; static const double freq = 440; const double bandwidth_Hz = (exp2(bandwidth_base / 1200.0) - 1.0) * freq; const double bandwidth_i = bandwidth_Hz / (2.0 * audio_rate); const double freq_i = freq / audio_rate; for (int32_t i = 0; i < buf_length; ++i) { const double harmonic_profile = profile((i / (double)sample_length) - freq_i, bandwidth_i); freq_amp[i] += harmonic_profile; } } if (!use_phase_data) { // Add randomised phases for (int32_t i = 0; i < buf_length; ++i) freq_phase[i] = Random_get_float_lb(random) * PI2; } // Set up frequencies in half-complex representation float* buf = Sample_get_buffer(cb_data->entry->sample, 0); rassert(buf != NULL); buf[0] = 0; buf[sample_length - 1] = 0; buf[sample_length] = 0; for (int32_t i = 1; i < buf_length; ++i) { buf[i * 2 - 1] = (float)(freq_amp[i] * cos(freq_phase[i])); buf[i * 2] = (float)(freq_amp[i] * sin(freq_phase[i])); } // Apply IFFT FFT_worker_irfft(&cb_data->fw, buf, sample_length); // Normalise { float max_abs = 0.0f; for (int32_t i = 0; i < sample_length; ++i) max_abs = max(max_abs, fabsf(buf[i])); if (max_abs > 0.0f) { const float scale = 1.0f / max_abs; for (int32_t i = 0; i < sample_length; ++i) buf[i] *= scale; } } // Duplicate first frame (for interpolation code) buf[sample_length] = buf[0]; return; } static bool apply_padsynth( Proc_padsynth* padsynth, const Padsynth_params* params, Background_loader* bkg_loader) { rassert(padsynth != NULL); int32_t sample_length = PADSYNTH_DEFAULT_SAMPLE_LENGTH; int sample_count = 1; double min_pitch = 0; double max_pitch = 0; double centre_pitch = 0; if (params != NULL) { sample_length = params->sample_length; sample_count = params->sample_count; min_pitch = params->min_pitch; max_pitch = params->max_pitch; centre_pitch = params->centre_pitch; } // Use only one sample with very small pitch ranges // TODO: Make sure we don't use more samples than we can differentiate // with rounded pitches if (fabs(min_pitch - max_pitch) < 1) sample_count = 1; Callback_data* cb_datas[PADSYNTH_MAX_SAMPLE_COUNT] = { NULL }; int cb_data_count = 0; for (int i = 0; i < sample_count; ++i) { cb_datas[i] = new_Callback_data(params); if (cb_datas[i] == NULL) break; cb_data_count = i + 1; } if (cb_data_count == 0) return false; bool last_cb_data_is_direct = (cb_data_count < sample_count); // Allocate new sample map here so that we don't lose old data on allocation failure if (padsynth->sample_map == NULL || padsynth->sample_map->sample_length != sample_length || padsynth->sample_map->sample_count != sample_count) { Padsynth_sample_map* new_sm = new_Padsynth_sample_map(sample_count, sample_length); if (new_sm == NULL) { for (int i = 0; i < cb_data_count; ++i) del_Callback_data(cb_datas[i]); return false; } del_Padsynth_sample_map(padsynth->sample_map); padsynth->sample_map = new_sm; } Padsynth_sample_map_set_centre_pitch(padsynth->sample_map, centre_pitch); Padsynth_sample_map_set_pitch_range(padsynth->sample_map, min_pitch, max_pitch); const bool enable_rounding = (params != NULL) ? params->round_to_period : true; Padsynth_sample_map_update_sample_pitches(padsynth->sample_map, enable_rounding); // Build samples if (params != NULL) { rassert(bkg_loader != NULL); AAiter* iter = AAiter_init(AAITER_AUTO, padsynth->sample_map->map); int context_index = 0; const Padsynth_sample_entry* key = PADSYNTH_SAMPLE_ENTRY_KEY(-INFINITY); Padsynth_sample_entry* entry = AAiter_get_at_least(iter, key); while (entry != NULL) { Callback_data* cb_data = cb_datas[min(context_index, cb_data_count - 1)]; rassert(cb_data != NULL); cb_data->entry = entry; cb_data->context_index = context_index; if (last_cb_data_is_direct && (context_index >= cb_data_count - 1)) { Error* error = ERROR_AUTO; make_padsynth_sample(error, cb_data); rassert(!Error_is_set(error)); } else { Background_loader_task* task = MAKE_BACKGROUND_LOADER_TASK( make_padsynth_sample, cleanup_cb_data, cb_data); if (!Background_loader_add_task(bkg_loader, task)) { Error* error = ERROR_AUTO; make_padsynth_sample(error, cb_data); cleanup_cb_data(error, cb_data); rassert(!Error_is_set(error)); } } ++context_index; entry = AAiter_get_next(iter); } } else { const Padsynth_sample_entry* key = PADSYNTH_SAMPLE_ENTRY_KEY(-INFINITY); Padsynth_sample_entry* entry = AAtree_get_at_least(padsynth->sample_map->map, key); rassert(entry != NULL); Callback_data* cb_data = cb_datas[0]; rassert(cb_data != NULL); cb_data->entry = entry; cb_data->context_index = 0; rassert(!last_cb_data_is_direct); Background_loader_task* task = MAKE_BACKGROUND_LOADER_TASK( make_padsynth_sample, cleanup_cb_data, cb_data); if ((bkg_loader == NULL) || !Background_loader_add_task(bkg_loader, task)) { Error* error = ERROR_AUTO; make_padsynth_sample(error, cb_data); cleanup_cb_data(error, cb_data); rassert(!Error_is_set(error)); } } if (last_cb_data_is_direct) del_Callback_data(cb_datas[cb_data_count - 1]); return true; } static void del_Proc_padsynth(Device_impl* dimpl) { if (dimpl == NULL) return; Proc_padsynth* padsynth = (Proc_padsynth*)dimpl; del_Padsynth_sample_map(padsynth->sample_map); memory_free(padsynth); return; }
29.271552
101
0.625902
ee16c4a7b03ac61c92e69ba0723f3626286fd365
12,088
c
C
src/kem/sike/external/compression/async_batch_lib/batch.c
KEMTLS-SIKE/liboqs
0547be83ed08f0c3919fc709465d67e70aa603ae
[ "MIT" ]
null
null
null
src/kem/sike/external/compression/async_batch_lib/batch.c
KEMTLS-SIKE/liboqs
0547be83ed08f0c3919fc709465d67e70aa603ae
[ "MIT" ]
null
null
null
src/kem/sike/external/compression/async_batch_lib/batch.c
KEMTLS-SIKE/liboqs
0547be83ed08f0c3919fc709465d67e70aa603ae
[ "MIT" ]
null
null
null
/* * engNTRU - An engine for batch NTRU Prime PQC in OpenSSL. * Copyright (C) 2019 Tampere University Foundation sr * * This file is part of engNTRU. * * engNTRU is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the * Free Software Foundation, either version 3 of the License, or (at your * option) any later version. * * engNTRU 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ #include <string.h> #include <stdint.h> #include "batch.h" #include <pthread.h> #define BATCH_SIZE 10 static void *crypto_kem_async_batch_filler_routine(void *arg); int crypto_kem_keypair(unsigned char *pk, unsigned char *sk); static void *zalloc(size_t size){ void *ptr = malloc(size); if(ptr == NULL) return NULL; return memset(ptr, 0, size); } static pthread_mutex_t global_mut = PTHREAD_MUTEX_INITIALIZER; static struct { int ref_count; BATCH_CTX *ctx; BATCH_CTX *ctx_B; } crypto_kem_async_batch_global_ctx = {0, NULL, NULL}; /* Returns 0 on success, 1 otherwise */ static int crypto_kem_async_batch_keypair(unsigned char *pk, unsigned char *sk, unsigned n) { unsigned i; for (i = 0; i < n; i++) { int ret; ret = crypto_kem_keypair(pk + i * CRYPTO_PUBLICKEYBYTES, sk + i * CRYPTO_SECRETKEYBYTES); if (ret != 0) { return 1; } } return 0; } static int crypto_kem_async_batch_keypair_B(unsigned char *ct, unsigned char *sk, unsigned n) { unsigned i; for (i = 0; i < n; i++) { int ret; random_mod_order_B(sk + i * SECRETKEY_B_BYTES); ret = EphemeralKeyGeneration_B_extended(sk + i * SECRETKEY_B_BYTES, ct + i * CRYPTO_CIPHERTEXTBYTES, 0); if (ret != 0) { return 1; } } return 0; } static inline int BATCH_STORE_fill(BATCH_STORE *store, size_t batch_size, int key_gen_b) { int (*crypto_kem_batch_keygen_fn)(unsigned char *pk, unsigned char *sk, unsigned n) = NULL; if(key_gen_b == 0){ crypto_kem_batch_keygen_fn = crypto_kem_async_batch_keypair; } else{ crypto_kem_batch_keygen_fn = crypto_kem_async_batch_keypair_B; } if (crypto_kem_batch_keygen_fn(store->pks, store->sks, batch_size) == 0) { // success store->available = batch_size; return 0; } return 1; } static inline BATCH_STORE *BATCH_STORE_new(size_t batch_size, int key_gen_b) { int ok = 0; BATCH_STORE *store = NULL; size_t data_size = 0, sks_len = 0, pks_len = 0; if(key_gen_b){ pks_len = batch_size * CRYPTO_CIPHERTEXTBYTES; sks_len = batch_size * SECRETKEY_B_BYTES; } else{ pks_len = batch_size * CRYPTO_PUBLICKEYBYTES; sks_len = batch_size * CRYPTO_SECRETKEYBYTES; } data_size = pks_len + sks_len; if (data_size <= 0 || NULL == (store = zalloc(sizeof(*store)+data_size))) goto end; store->data_size = data_size; store->pks = &(store->_data[0]); store->sks = &(store->_data[pks_len]); /* if (BATCH_STORE_fill(store, batch_size)) goto end;*/ ok = 1; end: if (!ok) { OQS_MEM_insecure_free(store); store = NULL; } return store; } static inline void BATCH_STORE_free(BATCH_STORE *store) { size_t data_size = 0; if (store == NULL) return; data_size = store->data_size; OQS_MEM_secure_free(store, sizeof(*store) + data_size); } static inline BATCH_CTX *BATCH_CTX_new(int key_gen_b) { int i; int ok = 0; size_t batch_size = 0; BATCH_CTX *ctx = NULL; if (NULL == (ctx = zalloc(sizeof(*ctx)))) goto err; batch_size = ctx->batch_size = BATCH_SIZE; if (batch_size == 0) goto err; ctx->key_gen_b = key_gen_b; if (pthread_mutex_init(&ctx->mutex, NULL) || pthread_cond_init(&ctx->emptied, NULL) || pthread_cond_init(&ctx->filled, NULL)) goto err; for (i = 0; i < BATCH_STORE_N; i++) { if (NULL == (ctx->stores[i] = BATCH_STORE_new(batch_size, key_gen_b))) goto err; } if (pthread_create(&ctx->filler_th, NULL, &crypto_kem_async_batch_filler_routine, (void*)ctx)) { goto err; } pthread_mutex_lock(&ctx->mutex); while (ctx->store == NULL) { pthread_cond_wait(&ctx->filled, &ctx->mutex); } pthread_mutex_unlock(&ctx->mutex); ok = 1; err: if (!ok) { for (i=0; i<BATCH_STORE_N; i++) { BATCH_STORE_free(ctx->stores[i]); } if (pthread_cond_destroy(&ctx->filled)) { fprintf(stderr, "Failed destroying filled cond\n"); } if (pthread_cond_destroy(&ctx->emptied)) { fprintf(stderr, "Failed destroying emptied cond\n"); } if (pthread_mutex_destroy(&ctx->mutex)) { fprintf(stderr, "Failed destroying mutex\n"); } OQS_MEM_insecure_free(ctx); ctx = NULL; } return ctx; } static inline void BATCH_CTX_free(BATCH_CTX *ctx) { /* This should be called while holding the parent lock */ void *tret; int i; if (ctx == NULL) return; pthread_mutex_lock(&ctx->mutex); ctx->destroy = 1; ctx->store = NULL; pthread_cond_signal(&ctx->emptied); pthread_mutex_unlock(&ctx->mutex); if (pthread_join(ctx->filler_th, &tret)) { fprintf(stderr, "pthread_join() failed\n"); } else { intptr_t ret = (intptr_t)tret; if (ret != 0) fprintf(stderr, "filler thread returned %" PRIxPTR "\n", ret); } for (i=0; i<BATCH_STORE_N; i++) { BATCH_STORE_free(ctx->stores[i]); } if (pthread_cond_destroy(&ctx->filled) || pthread_cond_destroy(&ctx->emptied) || pthread_mutex_destroy(&ctx->mutex)) fprintf(stderr, "failure destroying cond or mutex\n"); OQS_MEM_insecure_free(ctx); } static inline int BATCH_STORE_get_keypair(BATCH_STORE *store, KEM_KEYPAIR *kp, int key_gen_b) { int ret = 1, pk_bytes, sk_bytes; size_t i; if (store->available == 0) { /* This branch should never be taken */ return 1; } i = --store->available; if(key_gen_b){ pk_bytes = CRYPTO_CIPHERTEXTBYTES; sk_bytes = SECRETKEY_B_BYTES; } else{ pk_bytes = CRYPTO_PUBLICKEYBYTES; sk_bytes = CRYPTO_SECRETKEYBYTES; } memcpy(kp->pk, store->pks + i * pk_bytes, pk_bytes); memcpy(kp->sk, store->sks + i * sk_bytes, sk_bytes); /* Erase keypair from buffer for PFS */ OQS_MEM_cleanse(store->sks + i * sk_bytes, sk_bytes); OQS_MEM_cleanse(store->pks + i * pk_bytes, pk_bytes); if (store->available == 0) { /* * We took the last key! */ ret = -1; } else { ret = 0; } return ret; } static inline int BATCH_CTX_get_keypair(BATCH_CTX *ctx, KEM_KEYPAIR *kp) { int ret = 1, r; int key_gen_b = ctx->key_gen_b; pthread_mutex_lock(&ctx->mutex); while (ctx->store == NULL) { pthread_cond_wait(&ctx->filled, &ctx->mutex); } r = BATCH_STORE_get_keypair(ctx->store, kp, key_gen_b); if (r == -1) { /* * The store has been emptied. */ ctx->store = NULL; pthread_cond_signal(&ctx->emptied); } else if (r != 0) { goto end; } ret = 0; end: pthread_mutex_unlock(&ctx->mutex); return ret; } static int crypto_kem_async_batch_get_keypair(KEM_KEYPAIR *kp) { BATCH_CTX *ctx = NULL; int err; /* This is always called only internally, assume kp is valid */ if ((err = pthread_mutex_lock(&global_mut)) != 0) { //fprintf(stderr, "keypair %d", err); return 1; } if (crypto_kem_async_batch_global_ctx.ctx == NULL) { ctx = crypto_kem_async_batch_global_ctx.ctx = BATCH_CTX_new(0); if (ctx == NULL) return 1; } else { ctx = crypto_kem_async_batch_global_ctx.ctx; } if (pthread_mutex_unlock(&global_mut) != 0) { return 1; } if (BATCH_CTX_get_keypair(ctx, kp)) { return 1; } return 0; } static int crypto_kem_async_batch_get_keypair_B(KEM_KEYPAIR *kp) { BATCH_CTX *ctx = NULL; int err; /* This is always called only internally, assume kp is valid */ if ((err = pthread_mutex_lock(&global_mut)) != 0) { //fprintf(stderr, "keypair %d", err); return 1; } if (crypto_kem_async_batch_global_ctx.ctx_B == NULL) { ctx = crypto_kem_async_batch_global_ctx.ctx_B = BATCH_CTX_new(1); if (ctx == NULL) return 1; } else { ctx = crypto_kem_async_batch_global_ctx.ctx_B; } if (pthread_mutex_unlock(&global_mut) != 0) { return 1; } if (BATCH_CTX_get_keypair(ctx, kp)) { return 1; } return 0; } int crypto_kem_async_batch_init(void) { BATCH_CTX *ctx = NULL; BATCH_CTX *ctx_B = NULL; if (pthread_mutex_lock(&global_mut) != 0) { return 1; } crypto_kem_async_batch_global_ctx.ref_count++; if (crypto_kem_async_batch_global_ctx.ctx == NULL) { ctx = crypto_kem_async_batch_global_ctx.ctx = BATCH_CTX_new(0); ctx_B = crypto_kem_async_batch_global_ctx.ctx_B = BATCH_CTX_new(1); if (ctx == NULL || ctx_B == NULL) return 1; } if (pthread_mutex_unlock(&global_mut) != 0) { return 1; } return 0; } /** * Should be called at the very end of the process, global deinitialization. */ int crypto_kem_async_batch_deinit(void) { if (pthread_mutex_lock(&global_mut) != 0) { return 1; } crypto_kem_async_batch_global_ctx.ref_count--; // if (crypto_kem_async_batch_global_ctx.ref_count == 0) { BATCH_CTX_free(crypto_kem_async_batch_global_ctx.ctx); BATCH_CTX_free(crypto_kem_async_batch_global_ctx.ctx_B); if (pthread_mutex_unlock(&global_mut) != 0) { return 1; } // } else { // if (pthread_mutex_unlock(&global_mut) != 0) { // return 1; // } // } return 0; } static inline int crypto_kem_async_batch_filler(BATCH_CTX *ctx) { int ret = 1; int i, j; int key_gen_b = ctx->key_gen_b; // int nid = ctx->nid_data->nid; //int nid = 0; size_t batch_size = ctx->batch_size; BATCH_STORE *q[BATCH_STORE_N] = { NULL }; while (1) { pthread_mutex_lock(&ctx->mutex); while (ctx->store != NULL && ctx->destroy != 1) { pthread_cond_wait(&ctx->emptied, &ctx->mutex); } if (ctx->destroy) { break; } /* assert(ctx->store == NULL); */ for (i = 0, j = 0; i < BATCH_STORE_N; i++) { if (ctx->stores[i]->available == 0) { q[j++] = ctx->stores[i]; } else { ctx->store = ctx->stores[i]; } } if (ctx->store != NULL) { pthread_cond_broadcast(&ctx->filled); } pthread_mutex_unlock(&ctx->mutex); for (--j; j >= 0; j--) { if (BATCH_STORE_fill(q[j], batch_size, key_gen_b)) { goto end; } q[j] = NULL; } } pthread_mutex_unlock(&ctx->mutex); ret = 0; end: return ret; } static void *crypto_kem_async_batch_filler_routine(void *arg) { intptr_t ret; BATCH_CTX *ctx = arg; ret = (intptr_t) crypto_kem_async_batch_filler(ctx); return (void*)ret; }
23.936634
95
0.592488
4c1b82e0eb773b1b7e44efa385ada55d3d962871
9,915
h
C
CareKit/CarePlan/OCKCarePlanEventResult.h
kellyisworking/CareKit
bedafc590b4da9d9f7ed0326dabc0e1a69a733c1
[ "BSD-3-Clause" ]
null
null
null
CareKit/CarePlan/OCKCarePlanEventResult.h
kellyisworking/CareKit
bedafc590b4da9d9f7ed0326dabc0e1a69a733c1
[ "BSD-3-Clause" ]
null
null
null
CareKit/CarePlan/OCKCarePlanEventResult.h
kellyisworking/CareKit
bedafc590b4da9d9f7ed0326dabc0e1a69a733c1
[ "BSD-3-Clause" ]
2
2018-10-28T23:45:18.000Z
2018-11-21T16:09:45.000Z
/* Copyright (c) 2016, Apple Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. 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. 3. Neither the name of the copyright holder(s) nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission. No license is granted to the trademarks of the copyright holders even if such marks are included in this software. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #import <CareKit/OCKDefines.h> #import <HealthKit/HealthKit.h> NS_ASSUME_NONNULL_BEGIN /** The 'OCKCarePlanEventResult'class defines a result object for an OCKCarePlanEvent object. Create an instance of this class and attach it to an event using the OCKCarePlanStore API. */ OCK_CLASS_AVAILABLE @interface OCKCarePlanEventResult : NSObject - (instancetype)init NS_UNAVAILABLE; /** Initializer for creating an OCKCarePlanEventResult instance. Attach the created instance to an OCKCarePlanEvent object using the OCKCarePlanStore API. @param valueString Value string to be displayed to the user. @param unitString Unit string to be displayed to the user. @param userInfo Dictionary to save any additional objects that comply with the NSCoding protocol. @return Initialized instance. */ - (instancetype)initWithValueString:(NSString *)valueString unitString:(nullable NSString *)unitString userInfo:(nullable NSDictionary<NSString *, id<NSCoding>> *)userInfo; /** The time the result object is created. */ @property (nonatomic, readonly) NSDate *creationDate; /** A representative value string. */ @property (nonatomic, copy, readonly) NSString *valueString; /** A representative unit string for the value string. */ @property (nonatomic, copy, readonly, nullable) NSString *unitString; /** Use this dictionary to store objects that comply with the NSCoding protocol. */ @property (nonatomic, copy, readonly, nullable) NSDictionary<NSString *, id<NSCoding>> *userInfo; @end /** To avoid saving duplicates of health data, use the HealthKit category for an HKSample object that is already in HealthKit. Simply pass in the HKSample object with value formatting parameters. OCKCarePlanStore stores only the UUID and sample type from an HKSample object. The OCKCarePlanStore object uses the UUID and type to fetch the actual sample object from HealthKit. An OCKCarePlanEventResult object uses the HKSample object with the value formatting parameters to populate `valueString` and `unitString`. */ @interface OCKCarePlanEventResult (HealthKit) /** Initializer for creating an OCKCarePlanEventResult instance with an HKQuantitySample object. Attach the created instance to an OCKCarePlanEvent object using the OCKCarePlanStore API. @param quantitySample An HKQuantitySample object that is in HealthKit. @param quantityStringFormatter A formatter formats the quantity value to valueString. @param displayUnit A preferred HKUnit object for displaying the value. @param displayUnitStringKey A localized string key of the unit. @param userInfo Dictionary to save any additional objects that comply with the NSCoding protocol. @return Initialized instance. */ - (instancetype)initWithQuantitySample:(HKQuantitySample *)quantitySample quantityStringFormatter:(nullable NSNumberFormatter *)quantityStringFormatter displayUnit:(HKUnit *)displayUnit displayUnitStringKey:(NSString *)displayUnitStringKey userInfo:(nullable NSDictionary<NSString *, id<NSCoding>> *)userInfo; /** Initializer for creating an OCKCarePlanEventResult instance with an HKQuantitySample object. Attach the created instance to an OCKCarePlanEvent object using the OCKCarePlanStore API. @param quantitySample An HKQuantitySample object that is in HealthKit. @param quantityStringFormatter A formatter formats the quantity value to valueString. @param unitStringKeys A dictionary of localized string keys for possible system preferred units. @param userInfo Dictionary to save any additional objects that comply with the NSCoding protocol. @return Initialized instance. */ - (instancetype)initWithQuantitySample:(HKQuantitySample *)quantitySample quantityStringFormatter:(nullable NSNumberFormatter *)quantityStringFormatter unitStringKeys:(NSDictionary<HKUnit *, NSString *> *)unitStringKeys userInfo:(nullable NSDictionary<NSString *, id<NSCoding>> *)userInfo; /** Initializer for creating an OCKCarePlanEventResult instance with an HKCorrelation object. Attach the created instance to an OCKCarePlanEvent object using the OCKCarePlanStore API. @param correlation A correlation object that is in HealthKit. (Currently only supports correlation with type HKCorrelationTypeIdentifierBloodPressure) @param quantityStringFormatter A formatter formats the systolic and diastolic blood pressure value to valueString. @param displayUnit A preferred HKUnit object for displaying the value. @param unitStringKeys A dictionary of localized string keys for possible units. @param userInfo Dictionary to save any additional objects that comply with the NSCoding protocol. @return Initialized instance. */ - (instancetype)initWithCorrelation:(HKCorrelation *)correlation quantityStringFormatter:(nullable NSNumberFormatter *)quantityStringFormatter displayUnit:(nullable HKUnit *)displayUnit unitStringKeys:(NSDictionary<HKUnit *, NSString *> *)unitStringKeys userInfo:(nullable NSDictionary<NSString *, id<NSCoding>> *)userInfo; /** Initializer for creating an OCKCarePlanEventResult instance with an HKCategorySample object. Attach the created instance to an OCKCarePlanEvent object using the OCKCarePlanStore API. @param categorySample A HKCategorySample object that is in HealthKit. @param categoryValueStringKeys An dictionary of localized string keys for the enum values in the HKCategorySample. @param userInfo Dictionary to save any additional objects that comply with the NSCoding protocol. @return Initialized instance. */ - (instancetype)initWithCategorySample:(HKCategorySample *)categorySample categoryValueStringKeys:(NSDictionary<NSNumber *, NSString *> *)categoryValueStringKeys userInfo:(nullable NSDictionary<NSString *, id<NSCoding>> *)userInfo; /** UUID of the HKSample object. */ @property (nonatomic, strong, readonly, nullable) NSUUID *sampleUUID; /** Type of the HKSample object. */ @property (nonatomic, strong, readonly, nullable) HKSampleType *sampleType; /** Prefered HKUnit object for displaying the value for an HKQuantitySample or HKCorrelation object. If this attribute is nil, the OCKCarePlanEventResult object uses a system preferred HKUnit object. */ @property (nonatomic, strong, readonly, nullable) HKUnit *displayUnit; /** Localized string keys for units. If you provide a display unit, then this dictionary only contains one string key for the display unit. Otherwise, you need to provide string keys for all possible system preferred HKUnit objects. This attribute only applies when the sample is HKQuantitySample or HKCorrelation type. */ @property (nonatomic, copy, readonly, nullable) NSDictionary<HKUnit *, NSString *> *unitStringKeys; /** Formats the quantity value of an HKQuantitySample object to value string. If formatter is nil, framework uses `[NSNumberFormatter localizedStringFromNumber:@(value) numberStyle:NSNumberFormatterDecimalStyle]`. This attribute only applies when the sample is HKQuantitySample or HKCorrelation type. */ @property (nonatomic, strong, readonly, nullable) NSNumberFormatter *quantityStringFormatter; /** Localized string keys for the enum values in the HKCategorySample. The OCKCarePlanEventResult object use this string dictionary to map an enum value to a string. This attribute only applies when the sample is HKCategorySample type. */ @property (nonatomic, copy, readonly, nullable) NSDictionary<NSNumber *, NSString *> *categoryValueStringKeys; /** The HKSample object. This sample itself is not persisted in care plan store to avoid saving duplicated health data. Each time store uses UUID and type to fetch the actual sample object from HealthKit. If the sample cannot be found in HealthKit, this attribute returns nil. */ @property (nonatomic, strong, readonly, nullable) HKSample *sample; @end NS_ASSUME_NONNULL_END
46.768868
139
0.764599
7bf7c71ed5509f91079efd993c6846b13664e3df
8,388
h
C
sdk-6.5.20/libs/sdklt/bcmfp/include/bcmfp/bcmfp_cth_policy.h
copslock/broadcom_cpri
8e2767676e26faae270cf485591902a4c50cf0c5
[ "Spencer-94" ]
null
null
null
sdk-6.5.20/libs/sdklt/bcmfp/include/bcmfp/bcmfp_cth_policy.h
copslock/broadcom_cpri
8e2767676e26faae270cf485591902a4c50cf0c5
[ "Spencer-94" ]
null
null
null
sdk-6.5.20/libs/sdklt/bcmfp/include/bcmfp/bcmfp_cth_policy.h
copslock/broadcom_cpri
8e2767676e26faae270cf485591902a4c50cf0c5
[ "Spencer-94" ]
null
null
null
/*! \file bcmfp_cth_policy.h * * Defines, Enums, Structures and APIs corresponding to * FP policy LT. */ /* * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. * * Copyright 2007-2020 Broadcom Inc. All rights reserved. */ #ifndef BCMFP_CTH_POLICY_H #define BCMFP_CTH_POLICY_H #include <shr/shr_bitop.h> #include <bcmfp/bcmfp_action_internal.h> #include <bcmltd/bcmltd_types.h> #include <bcmltd/bcmltd_handler.h> #include <bcmfp/bcmfp_types_internal.h> /*! Configuration provided in FP policy LT entry. */ typedef struct bcmfp_policy_config_s { /*! Key */ uint32_t policy_id; /*! * Flag to indicate whether to counter red * packets with flex counter. Also indicates * what is the offset for red packet counter * from the base index. */ uint8_t flex_ctr_r_count; /*! * Flag to indicate whether to counter yellow * packets with flex counter. Also indicates * what is the offset for yellow packet counter * from the base index. */ uint8_t flex_ctr_y_count; /*! * Flag to indicate whether to counter green * packets with flex counter. Also indicates * what is the offset for green packet counter * from the base index. */ uint8_t flex_ctr_g_count; /*! Flex counter object */ uint32_t flex_ctr_object; /*! Flex counter container ID */ uint16_t flex_ctr_container_id; /*! Actions data to be configured in part 0 */ bcmfp_action_data_t *action_data; /*! Actions data to be configured in part 1 */ bcmfp_action_data_t *action_data1; /*! Actions data to be configured in part 2 */ bcmfp_action_data_t *action_data2; /*! viewtype of the action data */ bcmfp_action_viewtype_t viewtype; } bcmfp_policy_config_t; /*! * \brief Get the information provided in FP policy LT entry into * bcmfp_policy_config_t strcuture. * * \param [in] unit Logical device id. * \param [in] trans_id Transactio ID. * \param [in] tbl_id Logical Table ID. * \param [in] stage_id BCMFP stage ID. * \param [in] key Key consisting of all key field values. * \param [in] data Data consisting of user specified data * field values. * \param [out] config FP policy LT entry configuration * * \retval SHR_E_NONE Success * \retval SHR_E_PARAM Invalid parameters. */ extern int bcmfp_policy_config_get(int unit, const bcmltd_op_arg_t *op_arg, bcmltd_sid_t tbl_id, bcmfp_stage_id_t stage_id, const bcmltd_field_t *key, const bcmltd_field_t *data, bcmfp_policy_config_t **config); /*! * \brief Get the information provided in FP policy LT entry with * policy_id as key into bcmfp_policy_config_t strcuture. * * \param [in] unit Logical device id. * \param [in] trans_id Transactio ID. * \param [in] stage_id BCMFP stage ID. * \param [in] policy_id BCMFP policy ID. * \param [out] config FP entry LT entry configuration * * \retval SHR_E_NONE Success * \retval SHR_E_PARAM Invalid parameters. */ extern int bcmfp_policy_remote_config_get(int unit, const bcmltd_op_arg_t *op_arg, bcmfp_stage_id_t stage_id, bcmfp_policy_id_t policy_id, bcmfp_policy_config_t **config); /*! * \brief Insert the entry into policy template LT with a given key. * * \param [in] unit Logical device id. * \param [in] trans_id Transactio ID. * \param [in] tbl_id Logical Table ID. * \param [in] stage_id BCMFP stage ID. * \param [in] key Key consisting of all key field values. * \param [in] data Data consisting of user specified data * field values. * \param [out] output_fields If LT has any read only fields, BCMFP * BCMFP driver can add those fields to * LT entry in IMM so that application can * see those values upon LT entry LOOKUP. * * \retval SHR_E_NONE Success * \retval SHR_E_PARAM Invalid parameters. */ extern int bcmfp_policy_config_insert(int unit, const bcmltd_op_arg_t *op_arg, bcmltd_sid_t tbl_id, bcmfp_stage_id_t stage_id, const bcmltd_field_t *key, const bcmltd_field_t *data, bcmltd_fields_t *output_fields); /*! * \brief Update the entry in policy template LT with a given key. * * \param [in] unit Logical device id. * \param [in] trans_id Transactio ID. * \param [in] tbl_id Logical Table ID. * \param [in] stage_id BCMFP stage ID. * \param [in] key Key consisting of all key field values. * \param [in] data Data consisting of user specified data * field values. * \param [out] output_fields If LT has any read only fields, BCMFP * BCMFP driver can add those fields to * LT entry in IMM so that application can * see those values upon LT entry LOOKUP. * * \retval SHR_E_NONE Success * \retval SHR_E_PARAM Invalid parameters. */ extern int bcmfp_policy_config_update(int unit, const bcmltd_op_arg_t *op_arg, bcmltd_sid_t tbl_id, bcmfp_stage_id_t stage_id, const bcmltd_field_t *key, const bcmltd_field_t *data, bcmltd_fields_t *output_fields); /*! * \brief Delete the entry from policy template LT with a given key. * * \param [in] unit Logical device id. * \param [in] trans_id Transactio ID. * \param [in] tbl_id Logical Table ID. * \param [in] stage_id BCMFP stage ID. * \param [in] key Key consisting of all key field values. * \param [in] data Data consisting of user specified data * field values. * \param [out] output_fields If LT has any read only fields, BCMFP * BCMFP driver can add those fields to * LT entry in IMM so that application can * see those values upon LT entry LOOKUP. * * \retval SHR_E_NONE Success * \retval SHR_E_PARAM Invalid parameters. */ extern int bcmfp_policy_config_delete(int unit, const bcmltd_op_arg_t *op_arg, bcmltd_sid_t tbl_id, bcmfp_stage_id_t stage_id, const bcmltd_field_t *key, const bcmltd_field_t *data, bcmltd_fields_t *output_fields); /*! * \brief Free the memory created for FP policy LT entry configuration. * * \param [in] unit Logical device id. * \param [in] policy_config FP policy LT entry configuration * * \retval SHR_E_NONE Success */ extern int bcmfp_policy_config_free(int unit, bcmfp_policy_config_t *policy_config); /*! * \brief Compare two policy configurations and check if they are * same w.r.t actions and actions data. * * \param [in] unit Logical device id. * \param [in] p1 First policy configuration. * \param [in] p2 Second policy configuration. * \param [out] matched TRUE = if p1 and p2 are same * FALSE = if p1 and p2 are not same. * * \retval SHR_E_NONE Success * \retval SHR_E_PARAM Invalid parameters. */ extern int bcmfp_policy_config_compare(int unit, bcmfp_policy_config_t *p1, bcmfp_policy_config_t *p2, bool *matched); #endif /* BCMFP_CTH_POLICY_H */
37.446429
134
0.580591
0b458ff578630e126ed2923c4afe17396aef5e2a
569
h
C
src/widgets/pincodeview.h
reubenscratton/oaknut
03b37965ad84745bd5c077a27d8b53d58a173662
[ "MIT" ]
5
2019-10-04T05:10:06.000Z
2021-02-03T23:29:10.000Z
src/widgets/pincodeview.h
reubenscratton/oaknut
03b37965ad84745bd5c077a27d8b53d58a173662
[ "MIT" ]
null
null
null
src/widgets/pincodeview.h
reubenscratton/oaknut
03b37965ad84745bd5c077a27d8b53d58a173662
[ "MIT" ]
2
2019-09-27T00:34:36.000Z
2020-10-27T09:44:26.000Z
// // Copyright © 2018 Sandcastle Software Ltd. All rights reserved. // // This file is part of 'Oaknut' which is released under the MIT License. // See the LICENSE file in the root of this installation for details. // class PinCodeView : public LinearLayout { public: PinCodeView(); // API string getText(); void clear(); std::function<void(bool)> onFilled; std::function<void()> onKeyboardAction; // Overrides bool applySingleStyle(const string &name, const style& value) override; bool requestFocus() override; };
24.73913
75
0.676626
f0a839a7537984380c7f2a7e5200ba56b5e1e612
2,147
h
C
yituiyun/yituiyun/Common/Tool/XKNetworkManager.h
HJXIcon/YiTuiYun
b6d700d8905f8929e180f662392058d8f349906d
[ "MIT" ]
1
2018-08-31T03:37:42.000Z
2018-08-31T03:37:42.000Z
yituiyun/yituiyun/Common/Tool/XKNetworkManager.h
HJXIcon/YiTuiYun
b6d700d8905f8929e180f662392058d8f349906d
[ "MIT" ]
null
null
null
yituiyun/yituiyun/Common/Tool/XKNetworkManager.h
HJXIcon/YiTuiYun
b6d700d8905f8929e180f662392058d8f349906d
[ "MIT" ]
null
null
null
// // XKNetworkManager.h // Minshuku // // Created by Nicholas on 16/5/10. // Copyright © 2016年 Nicholas. All rights reserved. // #import <Foundation/Foundation.h> #define kNetworkReachability [XKNetworkManager networkStateChange] // 有网 typedef void (^ErrorBlock)(NSError *error); @interface XKNetworkManager : NSObject /// 判断网络连接 + (BOOL)networkStateChange; /** * 判断定位服务是否开启 * * @return YES or NO */ + (BOOL)locationServicesEnabled; /** * 判断是否网络连接 */ + (void)hasNetwork:(void(^)())hasBlock hasNotNetwork:(void(^)())hasNotBlock; /** * 一般POST通用 * * @param parameters 上传的参数 * @param success 上传成功的处理 * @param failure 上传失败的处理 */ + (void)POSTToUrlString:(NSString *)urlString parameters:(NSDictionary *)parameters progress:(void(^)(CGFloat progress))progress success:(void(^)(id responseObject))success failure:(void(^)(NSError *error))failure; /** * 上传视频 * * @param urlString 服务器地址 * @param parameters 参数 * @param videoName 视频名 * @param videoPath 视频地址 * @param imageName 图片名 * @param imagePath 图片地址 * @param progress 进度 * @param success 成功 * @param failure 失败 */ + (void)POSTVideoToUrlString:(NSString *)urlString parameters:(NSDictionary *)parameters videoName:(NSString *)videoName videoPath:(NSString *)videoPath imageName:(NSString *)imageName imagePath:(NSString *)imagePath progress:(void (^)(CGFloat progress))progress success:(void (^)(id responseObject))success failure:(void (^)(NSError * error))failure; /** * GET请求,一般请求数据用 * * @param urlString 地址 * @param parameters 参数 * @param progress 进度 * @param success 成功 * @param failure 失败 */ + (void)GETDataFromUrlString:(NSString *)urlString parameters:(NSDictionary *)parameters progress:(void (^)(CGFloat progress))progress success:(void (^)(id responseObject))success failure:(void (^)(NSError *error))failure; ///上传图片 + (void)xk_uploadImages:(NSArray *)images toURL:(NSString *)urlString parameters:(NSDictionary *)parameters progress:(void (^)(CGFloat progress))progress success:(void (^)(id responseObject))success failure:(void (^)(NSError *error))failure; @end
21.686869
351
0.697252
423c0a061adef79a9adb06ef2c86bfb06cac04d8
3,691
c
C
src/config.c
frankschlegel/pebble-mtg-counter
7f1a88187133636f02eb86602dfaff10c58d4ed2
[ "MIT" ]
1
2015-06-24T18:23:16.000Z
2015-06-24T18:23:16.000Z
src/config.c
frankschlegel/pebble-mtg-counter
7f1a88187133636f02eb86602dfaff10c58d4ed2
[ "MIT" ]
null
null
null
src/config.c
frankschlegel/pebble-mtg-counter
7f1a88187133636f02eb86602dfaff10c58d4ed2
[ "MIT" ]
null
null
null
#include <pebble.h> #include "config.h" #include "appmessage.h" #include "state.h" #include "ui.h" #include "match_time_notifications.h" #include "match_timer.h" #include "autorotate.h" #include "invert_colors.h" int life_default = LIFE_DEFAULT_DEFAULT; int match_duration = MATCH_DURATION_DEFAULT; bool match_end_vibration = MATCH_END_VIBRATION_DEFAULT; bool before_match_end_vibration = BEFORE_MATCH_END_VIBRATION_DEFAULT; int before_match_end_time = BEFORE_MATCH_END_TIME; bool show_timer = SHOW_TIMER_DEFAULT; bool rotation_lock = ROTATION_LOCK_DEFAULT; bool invert_colors = INVERT_COLORS_DEFAULT; bool has_config = false; // prevents saving default config in JavaScript. See deinit() static void config_update_show_timer(); static void config_update_rotation_lock(); static void config_update_invert_colors(); void request_config_via_appmessage() { APP_LOG(APP_LOG_LEVEL_DEBUG, "Requesting config"); DictionaryIterator *iter; app_message_outbox_begin(&iter); if (!iter) { APP_LOG(APP_LOG_LEVEL_ERROR, "Cannot write to AppMessage outbox"); return; } Tuplet request_tuple = TupletInteger(APP_MESSAGE_KEY_REQUEST_CONFIG, 1); dict_write_tuplet(iter, &request_tuple); dict_write_end(iter); app_message_outbox_send(); } void handle_config_received_via_appmessage(DictionaryIterator *received) { bool will_reset_life = life_opponent == life_default && life_player == life_default; Tuple *tuple = dict_read_first(received); while (tuple) { int32_t value = tuple->value->int32; switch (tuple->key) { case CONFIG_KEY_LIFE_DEFAULT: life_default = value; break; case CONFIG_KEY_MATCH_DURATION: match_duration = value; break; case CONFIG_KEY_MATCH_END_VIBRATION: match_end_vibration = value; break; case CONFIG_KEY_BEFORE_MATCH_END_VIBRATION: before_match_end_vibration = value; break; case CONFIG_KEY_BEFORE_MATCH_END_TIME: before_match_end_time = value; break; case CONFIG_KEY_SHOW_TIMER: show_timer = value; break; case CONFIG_KEY_ROTATION_LOCK: rotation_lock = value; break; case CONFIG_KEY_INVERT_COLORS: invert_colors = value; break; } tuple = dict_read_next(received); } APP_LOG(APP_LOG_LEVEL_DEBUG, "Received config"); has_config = true; if (will_reset_life) { // No scores have been changed yet // --> set initial life counts to life_default just received from config life_player = life_default; life_opponent = life_default; update_opponent_life_counter(); update_player_life_counter(); } config_handle_update(); } void config_handle_update() { config_update_match_end_vibration(); config_update_before_match_end_vibration(); config_update_show_timer(); config_update_rotation_lock(); config_update_invert_colors(); } void config_update_match_end_vibration() { if (match_end_vibration) { match_time_notifications_end_enable(match_start_time, match_duration); } else { match_time_notifications_end_disable(); } } void config_update_before_match_end_vibration() { if (before_match_end_vibration) { match_time_notifications_before_end_enable(match_start_time, match_duration, before_match_end_time); } else { match_time_notifications_before_end_disable(); } } static void config_update_show_timer() { if (show_timer) { match_timer_enable(); } else { match_timer_disable(); } } static void config_update_rotation_lock() { if (rotation_lock) { autorotate_disable(true /* rotate back to normal */); } else { autorotate_enable(); } } static void config_update_invert_colors() { if (invert_colors) { invert_colors_enable(); } else { invert_colors_disable(); } }
29.293651
104
0.766188
a40a28ff65ada178e0256658727aa87829cb5372
4,698
h
C
FemtoRV/FIRMWARE/LIBFEMTORV32/fat_io_lib/fat_filelib.h
corerd/learn-fpga
7e3abbc3d31dda03faafc86ea2f3617090e376b6
[ "BSD-3-Clause" ]
907
2020-05-27T15:42:29.000Z
2022-03-31T22:10:54.000Z
FemtoRV/FIRMWARE/LiteX/LiteOS/fat_io_lib/fat_filelib.h
phonix2012/learn-fpga
2d4bf8c30d77cc19be94b10d678946846366dc23
[ "BSD-3-Clause" ]
53
2020-06-18T00:45:29.000Z
2022-03-31T22:57:36.000Z
FemtoRV/FIRMWARE/LiteX/LiteOS/fat_io_lib/fat_filelib.h
phonix2012/learn-fpga
2d4bf8c30d77cc19be94b10d678946846366dc23
[ "BSD-3-Clause" ]
86
2020-06-20T15:43:45.000Z
2022-03-30T12:39:18.000Z
#ifndef __FAT_FILELIB_H__ #define __FAT_FILELIB_H__ #include "fat_opts.h" #include "fat_access.h" #include "fat_list.h" //----------------------------------------------------------------------------- // Defines //----------------------------------------------------------------------------- #ifndef SEEK_CUR #define SEEK_CUR 1 #endif #ifndef SEEK_END #define SEEK_END 2 #endif #ifndef SEEK_SET #define SEEK_SET 0 #endif #ifndef EOF #define EOF (-1) #endif //----------------------------------------------------------------------------- // Structures //----------------------------------------------------------------------------- struct sFL_FILE; struct cluster_lookup { uint32 ClusterIdx; uint32 CurrentCluster; }; typedef struct sFL_FILE { uint32 parentcluster; uint32 startcluster; uint32 bytenum; uint32 filelength; int filelength_changed; char path[FATFS_MAX_LONG_FILENAME]; char filename[FATFS_MAX_LONG_FILENAME]; uint8 shortfilename[11]; #ifdef FAT_CLUSTER_CACHE_ENTRIES uint32 cluster_cache_idx[FAT_CLUSTER_CACHE_ENTRIES]; uint32 cluster_cache_data[FAT_CLUSTER_CACHE_ENTRIES]; #endif // Cluster Lookup struct cluster_lookup last_fat_lookup; // Read/Write sector buffer uint8 file_data_sector[FAT_SECTOR_SIZE]; uint32 file_data_address; int file_data_dirty; // File fopen flags uint8 flags; #define FILE_READ (1 << 0) #define FILE_WRITE (1 << 1) #define FILE_APPEND (1 << 2) #define FILE_BINARY (1 << 3) #define FILE_ERASE (1 << 4) #define FILE_CREATE (1 << 5) struct fat_node list_node; } FL_FILE; //----------------------------------------------------------------------------- // Prototypes //----------------------------------------------------------------------------- // External void fl_init(void); void fl_attach_locks(void (*lock)(void), void (*unlock)(void)); int fl_attach_media(fn_diskio_read rd, fn_diskio_write wr); void fl_shutdown(void); // Standard API void* fl_fopen(const char *path, const char *modifiers); void fl_fclose(void *file); int fl_fflush(void *file); int fl_fgetc(void *file); char * fl_fgets(char *s, int n, void *f); int fl_fputc(int c, void *file); int fl_fputs(const char * str, void *file); int fl_fwrite(const void * data, int size, int count, void *file ); int fl_fread(void * data, int size, int count, void *file ); int fl_fseek(void *file , long offset , int origin ); int fl_fgetpos(void *file , uint32 * position); long fl_ftell(void *f); int fl_feof(void *f); int fl_remove(const char * filename); // Equivelant dirent.h typedef struct fs_dir_list_status FL_DIR; typedef struct fs_dir_ent fl_dirent; FL_DIR* fl_opendir(const char* path, FL_DIR *dir); int fl_readdir(FL_DIR *dirls, fl_dirent *entry); int fl_closedir(FL_DIR* dir); // Extensions void fl_listdirectory(const char *path); int fl_createdirectory(const char *path); int fl_is_dir(const char *path); int fl_format(uint32 volume_sectors, const char *name); // Test hooks #ifdef FATFS_INC_TEST_HOOKS struct fatfs* fl_get_fs(void); #endif //----------------------------------------------------------------------------- // Stdio file I/O names //----------------------------------------------------------------------------- #ifdef USE_FILELIB_STDIO_COMPAT_NAMES #define FILE FL_FILE #define fopen(a,b) fl_fopen(a, b) #define fclose(a) fl_fclose(a) #define fflush(a) fl_fflush(a) #define fgetc(a) fl_fgetc(a) #define fgets(a,b,c) fl_fgets(a, b, c) #define fputc(a,b) fl_fputc(a, b) #define fputs(a,b) fl_fputs(a, b) #define fwrite(a,b,c,d) fl_fwrite(a, b, c, d) #define fread(a,b,c,d) fl_fread(a, b, c, d) #define fseek(a,b,c) fl_fseek(a, b, c) #define fgetpos(a,b) fl_fgetpos(a, b) #define ftell(a) fl_ftell(a) #define feof(a) fl_feof(a) #define remove(a) fl_remove(a) #define mkdir(a) fl_createdirectory(a) #define rmdir(a) 0 #endif #endif
31.959184
83
0.502341
06a310eaa66debccc5dd6fcb7b9969f5544fa344
198
h
C
Technology/Software/ProgrammingLanguage/C++/Testing/unit_testing_catch2.h
MislavJaksic/Knowledge-Repository
3bab8b00d79a776725bcce88b5a1b66a24ecea23
[ "MIT" ]
3
2019-07-09T09:46:58.000Z
2020-12-10T12:46:12.000Z
Technology/Software/ProgrammingLanguage/C++/Testing/unit_testing_catch2.h
MislavJaksic/Knowledge-Repository
3bab8b00d79a776725bcce88b5a1b66a24ecea23
[ "MIT" ]
null
null
null
Technology/Software/ProgrammingLanguage/C++/Testing/unit_testing_catch2.h
MislavJaksic/Knowledge-Repository
3bab8b00d79a776725bcce88b5a1b66a24ecea23
[ "MIT" ]
2
2019-11-14T23:07:10.000Z
2019-11-30T19:12:34.000Z
//Header guard start #ifndef UNIT_TESTING_CATCH2 #define UNIT_TESTING_CATCH2 //Includes #include <vector> #define CATCH_CONFIG_MAIN #include "catch.hpp" //Declarations //Header guard end #endif
13.2
27
0.787879
c9750363347f82b1115796de4bb3d182cc6892f7
1,596
h
C
PrivateFrameworks/CalDAV.framework/CalDAVGetAccountPropertiesTaskGroup.h
shaojiankui/iOS10-Runtime-Headers
6b0d842bed0c52c2a7c1464087b3081af7e10c43
[ "MIT" ]
36
2016-04-20T04:19:04.000Z
2018-10-08T04:12:25.000Z
PrivateFrameworks/CalDAV.framework/CalDAVGetAccountPropertiesTaskGroup.h
shaojiankui/iOS10-Runtime-Headers
6b0d842bed0c52c2a7c1464087b3081af7e10c43
[ "MIT" ]
null
null
null
PrivateFrameworks/CalDAV.framework/CalDAVGetAccountPropertiesTaskGroup.h
shaojiankui/iOS10-Runtime-Headers
6b0d842bed0c52c2a7c1464087b3081af7e10c43
[ "MIT" ]
10
2016-06-16T02:40:44.000Z
2019-01-15T03:31:45.000Z
/* Generated by RuntimeBrowser Image: /System/Library/PrivateFrameworks/CalDAV.framework/CalDAV */ @interface CalDAVGetAccountPropertiesTaskGroup : CoreDAVGetAccountPropertiesTaskGroup { NSSet * _calendarHomes; NSURL * _delegatePrincipalURL; NSURL * _dropboxURL; NSURL * _inboxURL; NSURL * _notificationURL; NSURL * _outboxURL; CalDAVServerVersion * _serverVersion; bool _supportsCalendarUserSearch; NSURL * _updatedPrincipalURL; NSSet * _userAddresses; } @property (nonatomic, readonly) NSSet *calendarHomes; @property (nonatomic, retain) NSURL *delegatePrincipalURL; @property (nonatomic, readonly) NSURL *dropboxURL; @property (nonatomic, readonly) NSURL *inboxURL; @property (nonatomic, readonly) NSURL *notificationURL; @property (nonatomic, readonly) NSURL *outboxURL; @property (nonatomic, readonly) CalDAVServerVersion *serverVersion; @property (nonatomic, readonly) bool supportsCalendarUserSearch; @property (nonatomic, readonly) NSURL *updatedPrincipalURL; @property (nonatomic, readonly) NSSet *userAddresses; - (void).cxx_destruct; - (id)_copyAccountPropertiesPropFindElements; - (void)_setPropertiesFromParsedResponses:(id)arg1; - (id)calendarHomes; - (id)delegatePrincipalURL; - (id)description; - (id)dropboxURL; - (bool)forceOptionsRequest; - (id)homeSet; - (id)inboxURL; - (id)notificationURL; - (id)outboxURL; - (void)processPrincipalHeaders:(id)arg1; - (id)serverVersion; - (void)setDelegatePrincipalURL:(id)arg1; - (void)startTaskGroup; - (bool)supportsCalendarUserSearch; - (id)updatedPrincipalURL; - (id)userAddresses; @end
31.92
87
0.774436
a7e38423c857385e691aef7764e4065c6bb49033
390
h
C
Pods/GoogleMaps/Example/GoogleMapsDemos/SDKDemoAPIKey.h
guarani/Xaddress-iOS
23bd724054e58f2e30a5f0111369b6534a910eea
[ "MIT" ]
2
2017-08-12T07:17:03.000Z
2018-06-11T09:30:03.000Z
Pods/GoogleMaps/Example/GoogleMapsDemos/SDKDemoAPIKey.h
guarani/Xaddress-iOS
23bd724054e58f2e30a5f0111369b6534a910eea
[ "MIT" ]
null
null
null
Pods/GoogleMaps/Example/GoogleMapsDemos/SDKDemoAPIKey.h
guarani/Xaddress-iOS
23bd724054e58f2e30a5f0111369b6534a910eea
[ "MIT" ]
null
null
null
/** * To use GoogleMapsDemos, please register an API Key for your application and set it here. Your * API Key should be kept private. * * See documentation on getting an API Key for your API Project here: * https://developers.google.com/maps/documentation/ios/start#get-key */ #error Register for API Key and insert here. Then delete this line. static NSString *const kAPIKey = @"";
35.454545
96
0.741026
71de3901e28bd8287a63c600cc427fb00ce225ab
8,221
h
C
octet/src/scene/mesh_particle_system.h
MatthewDuddington/MG1_01_LSystems
5aa0f657452705ee4960e4859f04192d121cc960
[ "MIT" ]
null
null
null
octet/src/scene/mesh_particle_system.h
MatthewDuddington/MG1_01_LSystems
5aa0f657452705ee4960e4859f04192d121cc960
[ "MIT" ]
null
null
null
octet/src/scene/mesh_particle_system.h
MatthewDuddington/MG1_01_LSystems
5aa0f657452705ee4960e4859f04192d121cc960
[ "MIT" ]
null
null
null
//////////////////////////////////////////////////////////////////////////////// // // (C) Andy Thomason 2012-2014 // // Modular Framework for OpenGLES2 rendering on multiple platforms. // namespace octet { namespace scene { /// Particle system: billboards, trails and cloth. /// Note all particles in the system must use the same material, but you /// can use a custom shader to select different effects. class mesh_particle_system : public mesh { public: /// general particle, billboard, trail, cloth etc. struct particle { int link; vec3p pos; particle() {} }; /// traditional sprite-like particle, ie. smoke, fire, sparks etc. /// link unused struct billboard_particle : particle { vec2p size; /// half-size in world space vec2p uv_bottom_left; /// texture location vec2p uv_top_right; /// texture location uint32_t angle; /// rotation angle 2^32 = 360 degrees bool enabled; billboard_particle() {} }; /// trail-like particle, tyre streaks, missile trails, lasers, volumetric lights, hair etc. /// link points to previous particle in trail. struct trail_particle : particle { vec3p axis; float size; vec2p uv_top; vec2p uv_bottom; }; /// cloth-like particle /// link points to left hand particle (x), y_link points to particle below (y). struct cloth_particle : particle { int y_link; vec2p uv; }; /// animator for particles /// link points to particle struct particle_animator { int link; vec3p vel; vec3p acceleration; uint32_t lifetime; /// time to live in frames uint32_t age; /// how many frames has this particle lived; uint32_t spin; }; /// animator for cloth particles /// left, bottom link to other particle animators struct cloth_particle_animator : particle_animator { int left; int bottom; float mass; vec2p angle_stiffness; vec2p spacing_stiffness; vec2p spacing; }; /// sphere collider, used to prevent penetration of particles struct sphere_collider { float restitution; float friction; sphere geom; }; private: // POD (plain-old-data) structure dynarray of camera-facing particles dynarray<billboard_particle> billboard_particles; int free_billboard_particle; // POD structure dynarray of trail particles. dynarray<trail_particle> trail_particles; int free_trail_particle; // POD structure dynarray of animators for particles. dynarray<particle_animator> particle_animators; int free_particle_animator; // camera matrix mat4t cameraToWorld; void init(const aabb &size, int bbcap, int tpcap, int pacap) { set_default_attributes(); set_aabb(size); billboard_particles.reserve(bbcap); trail_particles.reserve(tpcap); particle_animators.reserve(pacap); free_billboard_particle = -1; free_trail_particle = -1; free_particle_animator = -1; unsigned vsize = (bbcap * 4 + tpcap * 2) * sizeof(vertex); unsigned isize = (bbcap * 6 + tpcap * 6) * sizeof(uint32_t); mesh::allocate(vsize, isize); } // pool allocation of particles. // note: we won't allocate beyond the capacity template <class Type> int allocate(dynarray<Type> &array, int &free) { int result = free; if (free != -1) { free = array[free].link; } else if (array.size() < array.capacity()) { result = (int)array.size(); array.resize(result+1); } return result; } // return to pool template <class Type> void free(dynarray<Type> &array, int &free, int element) { array[free].link = free; free = element; } public: RESOURCE_META(mesh_particle_system) /// Default constructor mesh_particle_system(aabb_in size=aabb(vec3(0, 0, 0), vec3(1, 1, 1)), int bbcap=256, int tpcap=256, int pacap=256) { init(size, bbcap, tpcap, pacap); } /// Update the vertices for newtonian physics. void animate(float time_step) { for (unsigned i = 0; i != particle_animators.size(); ++i) { particle_animator &g = particle_animators[i]; if (g.link >= 0) { billboard_particle &p = billboard_particles[g.link]; if (g.age >= g.lifetime) { p.enabled = false; free(billboard_particles, free_billboard_particle, g.link); g.link = -1; free(particle_animators, free_particle_animator, i); } else { p.pos = (vec3)p.pos + (vec3)g.vel * time_step; g.vel = (vec3)g.vel + (vec3)g.acceleration * time_step; p.angle += (uint32_t)(g.spin * time_step); g.age++; } } } } /// camera-facing particles need the camera matrix to generate world space geometry. void set_cameraToWorld(mat4t_in mx) { cameraToWorld = mx; } /// Generate mesh from particles virtual void update() { //unsigned np = billboard_particles.size(); //unsigned vsize = billboard_particles.capacity() * sizeof(vertex) * 4; //unsigned isize = billboard_particles.capacity() * sizeof(uint32_t) * 4; gl_resource::wolock vlock(get_vertices()); vertex *vtx = (vertex*)vlock.u8(); gl_resource::wolock ilock(get_indices()); uint32_t *idx = ilock.u32(); unsigned num_vertices = 0; unsigned num_indices = 0; vec3 cx = cameraToWorld.x().xyz(); vec3 cy = cameraToWorld.y().xyz(); vec3p n = cameraToWorld.z().xyz(); for (unsigned i = 0; i != billboard_particles.size(); ++i) { billboard_particle &p = billboard_particles[i]; if (p.enabled) { vec2 size = p.size; vec3 dx = size.x() * cx; vec3 dy = size.y() * cy; vec2 bl = p.uv_bottom_left; vec2 tr = p.uv_top_right; vec2 tl = vec2(bl.x(), tr.y()); vec2 br = vec2(tr.x(), bl.y()); vtx->pos = (vec3)p.pos - dx + dy; vtx->normal = n; vtx->uv = tl; vtx++; vtx->pos = (vec3)p.pos + dx + dy; vtx->normal = n; vtx->uv = tr; vtx++; vtx->pos = (vec3)p.pos + dx - dy; vtx->normal = n; vtx->uv = br; vtx++; vtx->pos = (vec3)p.pos - dx - dy; vtx->normal = n; vtx->uv = bl; vtx++; idx[0] = num_vertices; idx[1] = num_vertices+1; idx[2] = num_vertices+2; idx[3] = num_vertices; idx[4] = num_vertices+2; idx[5] = num_vertices+3; idx += 6; num_vertices += 4; num_indices += 6; } } set_num_vertices(num_vertices); set_num_indices(num_indices); //dump(log("mesh\n")); } /// Add a billboard particle. Returns -1 if capacity reached. int add_billboard_particle(const billboard_particle &p) { int i = allocate(billboard_particles, free_billboard_particle); if (i != -1) { billboard_particles[i] = p; } return i; } /// Add a particle animator. Returns -1 if capacity reached. int add_particle_animator(const particle_animator &p) { int i = allocate(particle_animators, free_particle_animator); if (i != -1) { particle_animators[i] = p; } return i; } /// Add a trail particle. Returns -1 if capacity reached. int add_trail_particle(const trail_particle &p) { int i = allocate(trail_particles, free_trail_particle); if (i != -1) { trail_particles[i] = p; } return i; } billboard_particle &access_billboard_particle(int i) { return billboard_particles[i]; } trail_particle &access_trail_particle(int i) { return trail_particles[i]; } particle_animator &access_particle_animator(int i) { return particle_animators[i]; } /// Serialise void visit(visitor &v) { mesh::visit(v); /* v.visit(billboard_particles); v.visit(free_billboard_particle); v.visit(trail_particles); v.visit(free_trail_particle); v.visit(particle_animators); v.visit(free_particle_animator); v.visit(cameraToWorld); */ } }; }}
32.752988
120
0.605279
c51b77879db7eaac2c5cc1074e313b7feab85ba1
1,910
h
C
filterlibrary/src/main/cpp/nativefilter/BlendFilter.h
WakeHao/CainCamera
34549c18150201d68967f02246991b8bf2d3bfb7
[ "Apache-2.0" ]
2,564
2017-11-14T07:22:16.000Z
2022-03-30T13:39:41.000Z
filterlibrary/src/main/cpp/nativefilter/BlendFilter.h
WakeHao/CainCamera
34549c18150201d68967f02246991b8bf2d3bfb7
[ "Apache-2.0" ]
166
2017-12-15T02:26:24.000Z
2022-03-05T10:50:03.000Z
filterlibrary/src/main/cpp/nativefilter/BlendFilter.h
WakeHao/CainCamera
34549c18150201d68967f02246991b8bf2d3bfb7
[ "Apache-2.0" ]
693
2017-09-12T12:20:23.000Z
2022-03-30T13:39:43.000Z
// // Created by cain on 2018/9/7. // #ifndef CAINCAMERA_BLENDFILTER_H #define CAINCAMERA_BLENDFILTER_H #ifdef __cplusplus extern "C" { #endif // 默认模式 normal 公式 T = S // 正片底叠模式 multiply 公式: T = S*D unsigned char blendMultiply(unsigned char mask, unsigned char image); // 正片底叠模式,带alpha unsigned char blendMultiplyWithAlpha(unsigned char mask, unsigned char image, float alpha); // 滤色模式 screen 公式: T = 1-(1-S)*(1-D); unsigned char blendScreen(unsigned char mask, unsigned char image); // 滤色模式,带alpha unsigned char blendScreenWithAlpha(unsigned char mask, unsigned char image, float alpha); // 叠加模式 overlay 公式: T = 2*S*D, D<0.5; T = 1-2*(1-S)*(1-D), D >= 0.5 unsigned char blendOverlay(unsigned char mask, unsigned char image); // 叠加模式,带alpha unsigned char blendOverlayWithAlpha(unsigned char mask, unsigned char image, float alpha); // 强光模式 hardlight 公式: T = 2*S*D, S < 0.5; T = 1 - 2*(1-S)*(1-D), S >= 0.5; unsigned char blendHardLight(unsigned char mask, unsigned char image); // 柔光模式 softlight 公式: T = 2*S*D + D*D*(1-2*S), S < 0.5; T = 2*D*(1-S)+sqrt(D)*(2*S-1), S >= 0.5 unsigned char blendSoftLight(unsigned char mask, unsigned char image); // 划分模式 divide 公式: T = D/S, D/S取值0~1之间 unsigned char blendDivide(unsigned char mask, unsigned char image); // 增加模式 add 公式: T=D+S, D+S取值0~1之间 unsigned char blendAdd(unsigned char mask, unsigned char image); // 减去模式 subtract 公式: T=D-S, D-S取值0~1之间 unsigned char blendSubtract(unsigned char mask, unsigned char image); // 反色模式 diff 公式: T=|D-S| unsigned char blendDiff(unsigned char mask, unsigned char image); // 深色模式 darken 公式: T=MIN(D,S) unsigned char blendDarken(unsigned char mask, unsigned char image); // 浅色模式 lighten 公式: T=MAX(D,S) unsigned char blendLighten(unsigned char mask, unsigned char image); // 合并模式 unsigned char blendGrainMerge(unsigned char mask, unsigned char image); #ifdef __cplusplus } #endif #endif //CAINCAMERA_BLENDFILTER_H
29.84375
95
0.722513
57c7da6041799a5e8a0f3524ec331580a7178991
609
h
C
System/Library/PrivateFrameworks/SpringBoardServices.framework/SBSSecureAppAction.h
lechium/iPhoneOS_12.1.1_Headers
aac688b174273dfcbade13bab104461f463db772
[ "MIT" ]
12
2019-06-02T02:42:41.000Z
2021-04-13T07:22:20.000Z
System/Library/PrivateFrameworks/SpringBoardServices.framework/SBSSecureAppAction.h
lechium/iPhoneOS_12.1.1_Headers
aac688b174273dfcbade13bab104461f463db772
[ "MIT" ]
null
null
null
System/Library/PrivateFrameworks/SpringBoardServices.framework/SBSSecureAppAction.h
lechium/iPhoneOS_12.1.1_Headers
aac688b174273dfcbade13bab104461f463db772
[ "MIT" ]
3
2019-06-11T02:46:10.000Z
2019-12-21T14:58:16.000Z
/* * This header is generated by classdump-dyld 1.0 * on Saturday, June 1, 2019 at 6:42:42 PM Mountain Standard Time * Operating System: Version 12.1.1 (Build 16C5050a) * Image Source: /System/Library/PrivateFrameworks/SpringBoardServices.framework/SpringBoardServices * classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos. */ #import <BaseBoard/BSAction.h> @interface SBSSecureAppAction : BSAction @property (nonatomic,readonly) unsigned long long secureAppType; -(unsigned long long)secureAppType; -(id)initWithType:(unsigned long long)arg1 handler:(/*^block*/id)arg2 ; @end
33.833333
99
0.778325
4166d4ae3b0b2041d2d487cb9b6d16289e90d574
1,077
h
C
YPProject/Classes/Discover/View/TopView/TGHomeTopView.h
emosiony/YPMobileProject
f68c991512ca76db71e565a792db113ebc89c91e
[ "MIT" ]
null
null
null
YPProject/Classes/Discover/View/TopView/TGHomeTopView.h
emosiony/YPMobileProject
f68c991512ca76db71e565a792db113ebc89c91e
[ "MIT" ]
null
null
null
YPProject/Classes/Discover/View/TopView/TGHomeTopView.h
emosiony/YPMobileProject
f68c991512ca76db71e565a792db113ebc89c91e
[ "MIT" ]
null
null
null
// // TGHomeTopView.h // ScrollView嵌套悬停Demo // // Created by Jtg_yao on 2019/8/21. // Copyright © 2019 谭高丰. All rights reserved. // #import <UIKit/UIKit.h> NS_ASSUME_NONNULL_BEGIN static CGFloat Line_Margin = 10; #define Menu_Page_Count 5 #define Item_Width ((kScreenWidth - 2 * Line_Margin) / Menu_Page_Count) #define TOP_SCROLL_HEIGHT (kScreenWidth - 2 * Line_Margin)/3 #define MENU_SCROLL_HEIGHT (((kScreenWidth - 2 * Line_Margin) / Menu_Page_Count - ((Menu_Page_Count - 1) * Line_Margin)) + 50) #define BOTTOM_SCROLL_HEIGHT (kScreenWidth - 2 * Line_Margin) / 4.0 @interface TGHomeTopView : UIView @property (nonatomic,copy) NSArray *topList; @property (nonatomic,copy) NSArray *menuList; @property (nonatomic,copy) NSArray *bottomList; @property (nonatomic,copy) void(^clickCallBackBlock)(NSDictionary *info); @property (nonatomic,copy) void(^clickMenuBlock)(NSDictionary *info); -(void)setTopList:(NSArray *)topList menuList:(NSArray *)menuList bottomList:(NSArray *)bottomList; /** 获取 真实 高度 */ -(CGFloat)getContentHeight; @end NS_ASSUME_NONNULL_END
27.615385
128
0.749304
41aae931fd938de43553d0cc1d22c43d845d3f0a
541
h
C
xmltree.h
seanyeh/skdal
bfd3bb74b4e04f8a5737b35b79bf951cf00c547d
[ "MIT" ]
1
2020-07-15T11:51:16.000Z
2020-07-15T11:51:16.000Z
xmltree.h
seanyeh/skdal
bfd3bb74b4e04f8a5737b35b79bf951cf00c547d
[ "MIT" ]
null
null
null
xmltree.h
seanyeh/skdal
bfd3bb74b4e04f8a5737b35b79bf951cf00c547d
[ "MIT" ]
null
null
null
/* skdal - a simple keyboard-driven app launcher * * Copyright (c) 2011 Sean Yeh * Distributed under the MIT License (see LICENSE file). */ #ifndef __XMLTREE_H__ #define __XMLTREE_H__ #include <mxml.h> extern char* get_text( mxml_node_t* node ); extern void print_node( mxml_node_t* node, mxml_node_t* tree ); extern mxml_node_t* get_child_element( mxml_node_t* node ); extern mxml_node_t* get_next_sibling_element( mxml_node_t* node ); extern mxml_node_t* send_char( mxml_node_t* cur, mxml_node_t* tree, char* key ); #endif
24.590909
80
0.750462
921c04d4ab5aecca87f683524eec4827909780b3
6,003
c
C
firmware/PIFWRobot/Core/Src/application/mode/mode_pidt/mode_pidt_tw.c
tucuongbrt/PIFer
e2ac4d4443e1c6a6263f91c32f28dbe767590359
[ "MIT" ]
2
2021-03-17T18:23:15.000Z
2021-03-18T06:19:44.000Z
firmware/PIFWRobot/Core/Src/application/mode/mode_pidt/mode_pidt_tw.c
tucuongbrt/PIFer
e2ac4d4443e1c6a6263f91c32f28dbe767590359
[ "MIT" ]
2
2021-04-03T08:50:46.000Z
2021-04-03T08:50:57.000Z
firmware/PIFWRobot/Core/Src/application/mode/mode_pidt/mode_pidt_tw.c
tucuongbrt/PIFer
e2ac4d4443e1c6a6263f91c32f28dbe767590359
[ "MIT" ]
2
2021-04-14T00:18:23.000Z
2021-05-06T05:57:54.000Z
/* * PID_Tunnng.c * * Created on: Oct 12, 2019 * Author: 16138 */ #include "mode_pidt.h" #if ROBOT_MODEL==0 typedef struct{ float vx; float vy; float omega; uint8_t cnt; bool is_dir_change; }cmd_velocity_t; static cmd_velocity_t gcmd_velocity; static float tilt_setpoint; TID(gtid_tilt_controller); TID(gtid_vel_controller); TID(gtid_imu_tilt); TID(gtid_pid_report); bool tilt_dir = true; static void tilt_controller_callback(void* ctx){ float tilt; switch(params.tilt_type){ case ROLL: tilt = imu_get_roll(); break; case PITCH: tilt = imu_get_pitch(); break; default: tilt = 0; } tilt -= params.tilt_offset; float speed = pid_compute(&params.pid[0], tilt_setpoint, tilt, 0.001f*TILT_CONTROLLER_PERIOD); if(tilt > 70 || tilt < -70) { speed = 0; pid_reset(&params.pid[0]); pid_reset(&params.pid[1]); } motors_setspeed(MOTOR_0, speed + (float)gcmd_velocity.omega*OMEGA_COEFF); motors_setspeed(MOTOR_1, speed - (float)gcmd_velocity.omega*OMEGA_COEFF); } static void vel_controller_callback(void* ctx){ if(gcmd_velocity.cnt == 0){ gcmd_velocity.vx = 0; gcmd_velocity.omega = 0; } else{ gcmd_velocity.cnt--; } int16_t motor0_speed = enc_read(MOTOR_0); int16_t motor1_speed = enc_read(MOTOR_1); float direction = -(motor0_speed + motor1_speed)/2; tilt_setpoint = pid_compute(&params.pid[1], gcmd_velocity.vx*VELOC_COEFF, direction, 0.001f*VEL_CONTROLLER_PERIOD); } static int load_params(){ static mavlink_message_t msg; params_load(); // Load parameters from non-volatile memory mavlink_msg_pid_params_pack(0,0,&msg,PID_TILT,params.pid[0].KP,params.pid[0].KI,params.pid[0].KD); mav_send_msg(&msg); mavlink_msg_pid_params_pack(0,0,&msg,PID_VEL,params.pid[1].KP,params.pid[1].KI,params.pid[1].KD); mav_send_msg(&msg); mavlink_msg_pid_params_pack(0,0,&msg,PID_POS,params.pid[2].KP,params.pid[2].KI,params.pid[2].KD); mav_send_msg(&msg); pid_reset(&params.pid[0]); pid_reset(&params.pid[1]); pid_reset(&params.pid[2]); return 0; } static int save_params(){ // Save parameters to non-volatile memory params_save(); return 0; } static int write_param(mavlink_message_t *msg){ // Change current parameters according to GCS mavlink_pid_params_t pid_msg; mavlink_msg_pid_params_decode(msg,&pid_msg); if(pid_msg.pid_control == PID_TILT){ params.pid[0].KP = pid_msg.KP; params.pid[0].KI = pid_msg.KI; params.pid[0].KD = pid_msg.KD; } else if(pid_msg.pid_control == PID_VEL){ params.pid[1].KP = pid_msg.KP; params.pid[1].KI = pid_msg.KI; params.pid[1].KD = pid_msg.KD; } else if(pid_msg.pid_control == PID_POS){ params.pid[2].KP = pid_msg.KP; params.pid[2].KI = pid_msg.KI; params.pid[2].KD = pid_msg.KD; } return 0; } static void tilt_report_callback(void *ctx){ mavlink_message_t msg; float tilt; switch(params.tilt_type){ case ROLL: tilt = imu_get_roll(); break; case PITCH: tilt = imu_get_pitch(); break; default: tilt = 0; } tilt -= params.tilt_offset; mavlink_msg_evt_tilt_cal_pack(0,0,&msg,tilt); mav_send_msg(&msg); } static void pid_report_callback(void *ctx){ mavlink_message_t msg; mavlink_msg_pid_report_pack(0,0,&msg,PID_TILT, params.pid[0].sp, params.pid[0].fb, params.pid[0].P_Part, params.pid[0].I_Part, params.pid[0].D_Part, params.pid[0].U); mav_send_msg(&msg); mavlink_msg_pid_report_pack(0,0,&msg,PID_VEL, params.pid[1].sp, params.pid[1].fb, params.pid[1].P_Part, params.pid[1].I_Part, params.pid[1].D_Part, params.pid[1].U); mav_send_msg(&msg); mavlink_msg_pid_report_pack(0,0,&msg,PID_POS, params.pid[2].sp, params.pid[2].fb, params.pid[2].P_Part, params.pid[2].I_Part, params.pid[2].D_Part, params.pid[2].U); mav_send_msg(&msg); } void mode_pidt_init(){ motors_init(); enc_init(); imu_init(); params.pid[1].maxIPart = 5; params.pid[1].minIpart = -5; params.pid[1].maxDPart = 5; params.pid[1].minDpart = -5; params.pid[1].maxOut = 5; params.pid[1].minOut = -5; pid_reset(&params.pid[0]); pid_reset(&params.pid[1]); pid_reset(&params.pid[2]); // Periodic task initialization gtid_tilt_controller = timer_register_callback(tilt_controller_callback, TILT_CONTROLLER_PERIOD, 0, TIMER_MODE_REPEAT); gtid_vel_controller = timer_register_callback(vel_controller_callback, VEL_CONTROLLER_PERIOD, 0, TIMER_MODE_REPEAT); gtid_imu_tilt = timer_register_callback(tilt_report_callback, TILT_REPORT_PERIOD, 0, TIMER_MODE_REPEAT); gtid_pid_report = timer_register_callback(pid_report_callback, PID_REPORT_PERIOD, 0, TIMER_MODE_REPEAT); } void mode_pidt_deinit(){ // Hardware de-initialization motors_deinit(); enc_deinit(); imu_deinit(); // Periodic task de-initialization timer_unregister_callback(gtid_tilt_controller); timer_unregister_callback(gtid_vel_controller); timer_unregister_callback(gtid_imu_tilt); timer_unregister_callback(gtid_pid_report); } void on_mode_pidt_mavlink_recv(mavlink_message_t *msg){ switch(msg->msgid){ case MAVLINK_MSG_ID_CMD_PARAMS: { mavlink_cmd_params_t cmd_msg; mavlink_msg_cmd_params_decode(msg, &cmd_msg); if(cmd_msg.cmd_params == CMD_LOAD){ if(load_params() != 0) respond_error(); else respond_ok(); } else if(cmd_msg.cmd_params == CMD_SAVE){ if(save_params() != 0) respond_error(); else respond_ok(); } } break; case MAVLINK_MSG_ID_PID_PARAMS: if(write_param(msg) != 0) respond_error(); else respond_ok(); break; case MAVLINK_MSG_ID_CMD_VELOCITY: { mavlink_cmd_velocity_t cmd_velocity; mavlink_msg_cmd_velocity_decode(msg, &cmd_velocity); gcmd_velocity.vx += 0.2*(cmd_velocity.v-gcmd_velocity.vx); if(gcmd_velocity.vx > 1) gcmd_velocity.vx=1; if(gcmd_velocity.vx < -1) gcmd_velocity.vx=-1; gcmd_velocity.omega = cmd_velocity.omega; if(gcmd_velocity.omega > 1) gcmd_velocity.omega=1; if(gcmd_velocity.omega < -1) gcmd_velocity.omega=-1; gcmd_velocity.cnt = (CONTROL_TIMEOUT_MS/VEL_CONTROLLER_PERIOD); } break; default: break; } } #endif
23.821429
120
0.727303
7f735896668f9ea4ab9029721f6beac4270ef01e
1,083
h
C
examples/pxScene2d/external/libnode-v10.15.3/deps/v8/src/unicode-cache-inl.h
madanagopaltcomcast/pxCore
c4a3a40a190521c8b6383d126c87612eca5b3c42
[ "Apache-2.0" ]
5,964
2016-09-27T03:46:29.000Z
2022-03-31T16:25:27.000Z
examples/pxScene2d/external/libnode-v10.15.3/deps/v8/src/unicode-cache-inl.h
madanagopaltcomcast/pxCore
c4a3a40a190521c8b6383d126c87612eca5b3c42
[ "Apache-2.0" ]
1,432
2017-06-21T04:08:48.000Z
2020-08-25T16:21:15.000Z
examples/pxScene2d/external/libnode-v10.15.3/deps/v8/src/unicode-cache-inl.h
madanagopaltcomcast/pxCore
c4a3a40a190521c8b6383d126c87612eca5b3c42
[ "Apache-2.0" ]
1,006
2016-09-27T05:17:27.000Z
2022-03-30T02:46:51.000Z
// Copyright 2015 the V8 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. #ifndef V8_UNICODE_CACHE_INL_H_ #define V8_UNICODE_CACHE_INL_H_ #include "src/unicode-inl.h" #include "src/unicode-cache.h" namespace v8 { namespace internal { bool UnicodeCache::IsIdentifierStart(unibrow::uchar c) { return kIsIdentifierStart.get(c); } bool UnicodeCache::IsIdentifierPart(unibrow::uchar c) { return kIsIdentifierPart.get(c); } bool UnicodeCache::IsLineTerminatorSequence(unibrow::uchar c, unibrow::uchar next) { if (!unibrow::IsLineTerminator(c)) return false; if (c == 0x000d && next == 0x000a) return false; // CR with following LF. return true; } bool UnicodeCache::IsWhiteSpace(unibrow::uchar c) { return kIsWhiteSpace.get(c); } bool UnicodeCache::IsWhiteSpaceOrLineTerminator(unibrow::uchar c) { return kIsWhiteSpaceOrLineTerminator.get(c); } } // namespace internal } // namespace v8 #endif // V8_UNICODE_CACHE_INL_H_
24.613636
76
0.721145
7fe21a82fcbec0783837142f0f887cc9ca00924e
577
h
C
ui.h
vitorhnn/Jogo-AA-Comp1
77ed74e8a8e23b296b5328578170ee30c12ff360
[ "MIT" ]
1
2016-07-05T01:05:11.000Z
2016-07-05T01:05:11.000Z
ui.h
vitorhnn/Jogo-AA-Comp1
77ed74e8a8e23b296b5328578170ee30c12ff360
[ "MIT" ]
null
null
null
ui.h
vitorhnn/Jogo-AA-Comp1
77ed74e8a8e23b296b5328578170ee30c12ff360
[ "MIT" ]
null
null
null
// Copyright © 2016 Victor Hermann "vitorhnn" Chiletto // Licensed under the MIT/Expat license. #ifndef UI_H #define UI_H #include <stdbool.h> #include <SDL2/SDL_render.h> #include <SDL2/SDL_events.h> #include "vecmath.h" #ifdef UI_NOCONFLICT #define UI_ID (UI_NOCONFLICT + __LINE__) #else #define UI_ID (__LINE__) #endif void ui_init(void); void ui_handle(SDL_Event *event); void ui_think(void); void ui_paint(SDL_Renderer *renderer); void ui_quit(void); bool ui_rect(int id, rect rect); bool ui_button(int id, const char *text, vec2 pos, SDL_Color color); #endif
16.970588
68
0.746967
3696008788bd982b931b648fb741cfabcdc19dcd
129
h
C
agent/mibgroup/tunnel.h
sjz6578/net-snmp-5.1.4.2
f69255dc8834bcac61ae9c6f7f39fe89fbf54f8e
[ "Net-SNMP", "MIT-CMU", "OLDAP-2.2.1" ]
278
2015-11-03T03:01:20.000Z
2022-01-20T18:21:05.000Z
agent/mibgroup/tunnel.h
sjz6578/net-snmp-5.1.4.2
f69255dc8834bcac61ae9c6f7f39fe89fbf54f8e
[ "Net-SNMP", "MIT-CMU", "OLDAP-2.2.1" ]
374
2015-11-03T12:37:22.000Z
2021-12-17T14:18:08.000Z
agent/mibgroup/tunnel.h
sjz6578/net-snmp-5.1.4.2
f69255dc8834bcac61ae9c6f7f39fe89fbf54f8e
[ "Net-SNMP", "MIT-CMU", "OLDAP-2.2.1" ]
96
2015-11-22T07:47:26.000Z
2022-01-20T19:52:19.000Z
/* * tunnel.h: top level .h file to merely include the sub-module. */ config_require(tunnel/tunnel) config_add_mib(TUNNEL-MIB)
21.5
64
0.744186
d21f77d875ba7b690a0c46231e0b539172488562
5,722
c
C
sources/net/openvswitch/vport-netdev.c
fuldaros/paperplane_kernel_wileyfox-spark
bea244880d2de50f4ad14bb6fa5777652232c033
[ "Apache-2.0" ]
55
2019-12-20T03:25:14.000Z
2022-01-16T07:19:47.000Z
sources/net/openvswitch/vport-netdev.c
fuldaros/paperplane_kernel_wileyfox-spark
bea244880d2de50f4ad14bb6fa5777652232c033
[ "Apache-2.0" ]
2
2020-11-02T08:01:00.000Z
2022-03-27T02:59:18.000Z
sources/net/openvswitch/vport-netdev.c
fuldaros/paperplane_kernel_wileyfox-spark
bea244880d2de50f4ad14bb6fa5777652232c033
[ "Apache-2.0" ]
11
2020-08-06T03:59:45.000Z
2022-02-25T02:31:59.000Z
/* * Copyright (c) 2007-2012 Nicira, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public * License 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. * * 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., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include <linux/if_arp.h> #include <linux/if_bridge.h> #include <linux/if_vlan.h> #include <linux/kernel.h> #include <linux/llc.h> #include <linux/rtnetlink.h> #include <linux/skbuff.h> #include <linux/openvswitch.h> #include <net/llc.h> #include "datapath.h" #include "vport-internal_dev.h" #include "vport-netdev.h" /* Must be called with rcu_read_lock. */ static void netdev_port_receive(struct vport *vport, struct sk_buff *skb) { if (unlikely(!vport)) goto error; if (unlikely(skb_warn_if_lro(skb))) goto error; /* Make our own copy of the packet. Otherwise we will mangle the * packet for anyone who came before us (e.g. tcpdump via AF_PACKET). */ skb = skb_share_check(skb, GFP_ATOMIC); if (unlikely(!skb)) return; skb_push(skb, ETH_HLEN); ovs_skb_postpush_rcsum(skb, skb->data, ETH_HLEN); ovs_vport_receive(vport, skb, NULL); return; error: kfree_skb(skb); } /* Called with rcu_read_lock and bottom-halves disabled. */ static rx_handler_result_t netdev_frame_hook(struct sk_buff **pskb) { struct sk_buff *skb = *pskb; struct vport *vport; if (unlikely(skb->pkt_type == PACKET_LOOPBACK)) return RX_HANDLER_PASS; vport = ovs_netdev_get_vport(skb->dev); netdev_port_receive(vport, skb); return RX_HANDLER_CONSUMED; } static struct net_device *get_dpdev(struct datapath *dp) { struct vport *local; local = ovs_vport_ovsl(dp, OVSP_LOCAL); BUG_ON(!local); return netdev_vport_priv(local)->dev; } static struct vport *netdev_create(const struct vport_parms *parms) { struct vport *vport; struct netdev_vport *netdev_vport; int err; vport = ovs_vport_alloc(sizeof(struct netdev_vport), &ovs_netdev_vport_ops, parms); if (IS_ERR(vport)) { err = PTR_ERR(vport); goto error; } netdev_vport = netdev_vport_priv(vport); netdev_vport->dev = dev_get_by_name(ovs_dp_get_net(vport->dp), parms->name); if (!netdev_vport->dev) { err = -ENODEV; goto error_free_vport; } if (netdev_vport->dev->flags & IFF_LOOPBACK || netdev_vport->dev->type != ARPHRD_ETHER || ovs_is_internal_dev(netdev_vport->dev)) { err = -EINVAL; goto error_put; } rtnl_lock(); err = netdev_master_upper_dev_link(netdev_vport->dev, get_dpdev(vport->dp)); if (err) goto error_unlock; err = netdev_rx_handler_register(netdev_vport->dev, netdev_frame_hook, vport); if (err) goto error_master_upper_dev_unlink; dev_set_promiscuity(netdev_vport->dev, 1); netdev_vport->dev->priv_flags |= IFF_OVS_DATAPATH; rtnl_unlock(); return vport; error_master_upper_dev_unlink: netdev_upper_dev_unlink(netdev_vport->dev, get_dpdev(vport->dp)); error_unlock: rtnl_unlock(); error_put: dev_put(netdev_vport->dev); error_free_vport: ovs_vport_free(vport); error: return ERR_PTR(err); } static void free_port_rcu(struct rcu_head *rcu) { struct netdev_vport *netdev_vport = container_of(rcu, struct netdev_vport, rcu); dev_put(netdev_vport->dev); ovs_vport_free(vport_from_priv(netdev_vport)); } void ovs_netdev_detach_dev(struct vport *vport) { struct netdev_vport *netdev_vport = netdev_vport_priv(vport); ASSERT_RTNL(); netdev_vport->dev->priv_flags &= ~IFF_OVS_DATAPATH; netdev_rx_handler_unregister(netdev_vport->dev); netdev_upper_dev_unlink(netdev_vport->dev, netdev_master_upper_dev_get(netdev_vport->dev)); dev_set_promiscuity(netdev_vport->dev, -1); } static void netdev_destroy(struct vport *vport) { struct netdev_vport *netdev_vport = netdev_vport_priv(vport); rtnl_lock(); if (netdev_vport->dev->priv_flags & IFF_OVS_DATAPATH) ovs_netdev_detach_dev(vport); rtnl_unlock(); call_rcu(&netdev_vport->rcu, free_port_rcu); } const char *ovs_netdev_get_name(const struct vport *vport) { const struct netdev_vport *netdev_vport = netdev_vport_priv(vport); return netdev_vport->dev->name; } static unsigned int packet_length(const struct sk_buff *skb) { unsigned int length = skb->len - ETH_HLEN; if (skb->protocol == htons(ETH_P_8021Q)) length -= VLAN_HLEN; return length; } static int netdev_send(struct vport *vport, struct sk_buff *skb) { struct netdev_vport *netdev_vport = netdev_vport_priv(vport); int mtu = netdev_vport->dev->mtu; int len; if (unlikely(packet_length(skb) > mtu && !skb_is_gso(skb))) { net_warn_ratelimited("%s: dropped over-mtu packet: %d > %d\n", netdev_vport->dev->name, packet_length(skb), mtu); goto drop; } skb->dev = netdev_vport->dev; len = skb->len; dev_queue_xmit(skb); return len; drop: kfree_skb(skb); return 0; } /* Returns null if this device is not attached to a datapath. */ struct vport *ovs_netdev_get_vport(struct net_device *dev) { if (likely(dev->priv_flags & IFF_OVS_DATAPATH)) return (struct vport *) rcu_dereference_rtnl(dev->rx_handler_data); else return NULL; } const struct vport_ops ovs_netdev_vport_ops = { .type = OVS_VPORT_TYPE_NETDEV, .create = netdev_create, .destroy = netdev_destroy, .get_name = ovs_netdev_get_name, .send = netdev_send, };
24.452991
77
0.740475
32205602d2033717949850edbc26ea180de2edf6
5,051
c
C
netbsd/sys/arch/ofppc/ofppc/mainbus.c
shisa/kame-shisa
25dfcf220c0cd8192e475a602501206ccbd9263e
[ "BSD-3-Clause" ]
1
2019-10-15T06:29:32.000Z
2019-10-15T06:29:32.000Z
netbsd/sys/arch/ofppc/ofppc/mainbus.c
shisa/kame-shisa
25dfcf220c0cd8192e475a602501206ccbd9263e
[ "BSD-3-Clause" ]
null
null
null
netbsd/sys/arch/ofppc/ofppc/mainbus.c
shisa/kame-shisa
25dfcf220c0cd8192e475a602501206ccbd9263e
[ "BSD-3-Clause" ]
3
2017-01-09T02:15:36.000Z
2019-10-15T06:30:25.000Z
/* $NetBSD: mainbus.c,v 1.7 2001/10/23 22:52:14 thorpej Exp $ */ /*- * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Charles M. Hannum; by Jason R. Thorpe. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the NetBSD * Foundation, Inc. and its contributors. * 4. Neither the name of The NetBSD Foundation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #include <sys/param.h> #include <sys/systm.h> #include <sys/device.h> #include <dev/ofw/openfirm.h> #include <machine/platform.h> int mainbus_match(struct device *, struct cfdata *, void *); void mainbus_attach(struct device *, struct device *, void *); struct cfattach mainbus_ca = { sizeof(struct device), mainbus_match, mainbus_attach }; int mainbus_print(void *, const char *); extern struct cfdriver mainbus_cd; /* * Probe for the mainbus; always succeeds. */ int mainbus_match(struct device *parent, struct cfdata *cf, void *aux) { return (1); } /* * Attach the mainbus. */ void mainbus_attach(struct device *parent, struct device *self, void *aux) { struct ofbus_attach_args oba; char buf[32]; const char * const *ssp, *sp = NULL; int node; static const char * const openfirmware_special[] = { /* * These are _root_ devices to ignore. Others must be * handled elsewhere, if at all. */ "virtual-memory", "mmu", "aliases", "memory", "openprom", "options", "packages", "chosen", /* * This one is extra-special .. we make a special case * and attach CPUs early. */ "cpus", NULL }; printf(": %s\n", platform_name); /* * Before we do anything else, attach CPUs. We do this early, * because we might need to make CPU dependent decisions during * the autoconfiguration process. Also, it's a little weird to * see CPUs after other devices in the boot messages. */ node = OF_finddevice("/cpus"); if (node != -1) { for (node = OF_child(node); node != 0; node = OF_peer(node)) { oba.oba_busname = "cpu"; oba.oba_phandle = node; (void) config_found(self, &oba, mainbus_print); } } else { /* * No /cpus node; assume they're all children of the * root OFW node. */ for (node = OF_child(OF_peer(0)); node != 0; node = OF_peer(node)) { if (OF_getprop(node, "device_type", buf, sizeof(buf)) <= 0) continue; if (strcmp(buf, "cpu") != 0) continue; oba.oba_busname = "cpu"; oba.oba_phandle = node; (void) config_found(self, &oba, mainbus_print); } } /* * Now attach the rest of the devices on the system. */ for (node = OF_child(OF_peer(0)); node != 0; node = OF_peer(node)) { /* * Make sure it's not a CPU (we've already attached * those). */ if (OF_getprop(node, "device_type", buf, sizeof(buf)) > 0 && strcmp(buf, "cpu") == 0) continue; /* * Make sure this isn't one of our "special" child nodes. */ OF_getprop(node, "name", buf, sizeof(buf)); for (ssp = openfirmware_special; (sp = *ssp) != NULL; ssp++) { if (strcmp(buf, sp) == 0) break; } if (sp != NULL) continue; oba.oba_busname = "ofw"; oba.oba_phandle = node; (void) config_found(self, &oba, mainbus_print); } } int mainbus_print(void *aux, const char *pnp) { struct ofbus_attach_args *oba = aux; char name[64]; if (pnp) { OF_getprop(oba->oba_phandle, "name", name, sizeof(name)); printf("%s at %s", name, pnp); } return (UNCONF); }
28.376404
78
0.681053
d652219c86c78e34586fb8ab5bbd3f932fa67663
648
h
C
XVim2/XcodeHeader/DVTFoundation/DVTSimpleDeserializer.h
jsuo/XVim2
f0126ed41be3d04f237e81c240c5f1f36443fcbc
[ "MIT" ]
null
null
null
XVim2/XcodeHeader/DVTFoundation/DVTSimpleDeserializer.h
jsuo/XVim2
f0126ed41be3d04f237e81c240c5f1f36443fcbc
[ "MIT" ]
null
null
null
XVim2/XcodeHeader/DVTFoundation/DVTSimpleDeserializer.h
jsuo/XVim2
f0126ed41be3d04f237e81c240c5f1f36443fcbc
[ "MIT" ]
null
null
null
// // Generated by class-dump 3.5 (64 bit) (Debug version compiled Mar 30 2018 09:30:25). // // class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2015 by Steve Nygard. // #import <objc/NSObject.h> @class DVTByteBuffer, NSData, NSError; @interface DVTSimpleDeserializer : NSObject { NSData *_inputData; DVTByteBuffer *_buffer; NSError *_error; } - (void).cxx_destruct; - (id)error; - (unsigned long long)streamFormatVersion; - (id)decodeObjectList; - (id)decodeObject; - (id)decodeString; - (double)decodeDouble; - (float)decodeFloat; - (unsigned long long)decodeInteger; - (id)init; - (id)initWithData:(id)arg1; @end
20.25
90
0.699074
32549d177b198ae2f7f2b9a738d6b8a0cb9de049
10,744
h
C
linux-3.0.1/drivers/video/savage/savagefb.h
tonghua209/samsun6410_linux_3_0_0_1_for_aws
31aa0dc27c4aab51a92309a74fd84ca65e8c6a58
[ "Apache-2.0" ]
null
null
null
linux-3.0.1/drivers/video/savage/savagefb.h
tonghua209/samsun6410_linux_3_0_0_1_for_aws
31aa0dc27c4aab51a92309a74fd84ca65e8c6a58
[ "Apache-2.0" ]
null
null
null
linux-3.0.1/drivers/video/savage/savagefb.h
tonghua209/samsun6410_linux_3_0_0_1_for_aws
31aa0dc27c4aab51a92309a74fd84ca65e8c6a58
[ "Apache-2.0" ]
null
null
null
/* * linux/drivers/video/savagefb.h -- S3 Savage Framebuffer Driver * * Copyright (c) 2001 Denis Oliver Kropp <dok@convergence.de> * * 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. */ #ifndef __SAVAGEFB_H__ #define __SAVAGEFB_H__ #include <linux/i2c.h> #include <linux/i2c-algo-bit.h> #include <linux/mutex.h> #include <video/vga.h> #include "../edid.h" #ifdef SAVAGEFB_DEBUG # define DBG(x) printk (KERN_DEBUG "savagefb: %s\n", (x)); #else # define DBG(x) # define SavagePrintRegs(...) #endif #define PCI_CHIP_SAVAGE4 0x8a22 #define PCI_CHIP_SAVAGE3D 0x8a20 #define PCI_CHIP_SAVAGE3D_MV 0x8a21 #define PCI_CHIP_SAVAGE2000 0x9102 #define PCI_CHIP_SAVAGE_MX_MV 0x8c10 #define PCI_CHIP_SAVAGE_MX 0x8c11 #define PCI_CHIP_SAVAGE_IX_MV 0x8c12 #define PCI_CHIP_SAVAGE_IX 0x8c13 #define PCI_CHIP_PROSAVAGE_PM 0x8a25 #define PCI_CHIP_PROSAVAGE_KM 0x8a26 #define PCI_CHIP_S3TWISTER_P 0x8d01 #define PCI_CHIP_S3TWISTER_K 0x8d02 #define PCI_CHIP_PROSAVAGE_DDR 0x8d03 #define PCI_CHIP_PROSAVAGE_DDRK 0x8d04 #define PCI_CHIP_SUPSAV_MX128 0x8c22 #define PCI_CHIP_SUPSAV_MX64 0x8c24 #define PCI_CHIP_SUPSAV_MX64C 0x8c26 #define PCI_CHIP_SUPSAV_IX128SDR 0x8c2a #define PCI_CHIP_SUPSAV_IX128DDR 0x8c2b #define PCI_CHIP_SUPSAV_IX64SDR 0x8c2c #define PCI_CHIP_SUPSAV_IX64DDR 0x8c2d #define PCI_CHIP_SUPSAV_IXCSDR 0x8c2e #define PCI_CHIP_SUPSAV_IXCDDR 0x8c2f #define S3_SAVAGE_SERIES(chip) ((chip>=S3_SAVAGE3D) && (chip<=S3_SAVAGE2000)) #define S3_SAVAGE3D_SERIES(chip) ((chip>=S3_SAVAGE3D) && (chip<=S3_SAVAGE_MX)) #define S3_SAVAGE4_SERIES(chip) ((chip>=S3_SAVAGE4) || (chip<=S3_PROSAVAGEDDR)) #define S3_SAVAGE_MOBILE_SERIES(chip) ((chip==S3_SAVAGE_MX) || (chip==S3_SUPERSAVAGE)) #define S3_MOBILE_TWISTER_SERIES(chip) ((chip==S3_TWISTER) || (chip==S3_PROSAVAGEDDR)) /* Chip tags. These are used to group the adapters into * related families. */ typedef enum { S3_UNKNOWN = 0, S3_SAVAGE3D, S3_SAVAGE_MX, S3_SAVAGE4, S3_PROSAVAGE, S3_TWISTER, S3_PROSAVAGEDDR, S3_SUPERSAVAGE, S3_SAVAGE2000, S3_LAST } savage_chipset; #define BIOS_BSIZE 1024 #define BIOS_BASE 0xc0000 #define SAVAGE_NEWMMIO_REGBASE_S3 0x1000000 /* 16MB */ #define SAVAGE_NEWMMIO_REGBASE_S4 0x0000000 #define SAVAGE_NEWMMIO_REGSIZE 0x0080000 /* 512kb */ #define SAVAGE_NEWMMIO_VGABASE 0x8000 #define BASE_FREQ 14318 #define HALF_BASE_FREQ 7159 #define FIFO_CONTROL_REG 0x8200 #define MIU_CONTROL_REG 0x8204 #define STREAMS_TIMEOUT_REG 0x8208 #define MISC_TIMEOUT_REG 0x820c #define MONO_PAT_0 0xa4e8 #define MONO_PAT_1 0xa4ec #define MAXFIFO 0x7f00 #define BCI_CMD_NOP 0x40000000 #define BCI_CMD_SETREG 0x96000000 #define BCI_CMD_RECT 0x48000000 #define BCI_CMD_RECT_XP 0x01000000 #define BCI_CMD_RECT_YP 0x02000000 #define BCI_CMD_SEND_COLOR 0x00008000 #define BCI_CMD_DEST_GBD 0x00000000 #define BCI_CMD_SRC_GBD 0x00000020 #define BCI_CMD_SRC_SOLID 0x00000000 #define BCI_CMD_SRC_MONO 0x00000060 #define BCI_CMD_CLIP_NEW 0x00006000 #define BCI_CMD_CLIP_LR 0x00004000 #define BCI_CLIP_LR(l, r) ((((r) << 16) | (l)) & 0x0FFF0FFF) #define BCI_CLIP_TL(t, l) ((((t) << 16) | (l)) & 0x0FFF0FFF) #define BCI_CLIP_BR(b, r) ((((b) << 16) | (r)) & 0x0FFF0FFF) #define BCI_W_H(w, h) (((h) << 16) | ((w) & 0xFFF)) #define BCI_X_Y(x, y) (((y) << 16) | ((x) & 0xFFF)) #define BCI_GBD1 0xE0 #define BCI_GBD2 0xE1 #define BCI_BUFFER_OFFSET 0x10000 #define BCI_SIZE 0x4000 #define BCI_SEND(dw) writel(dw, par->bci_base + par->bci_ptr++) #define BCI_CMD_GET_ROP(cmd) (((cmd) >> 16) & 0xFF) #define BCI_CMD_SET_ROP(cmd, rop) ((cmd) |= ((rop & 0xFF) << 16)) #define BCI_CMD_SEND_COLOR 0x00008000 #define DISP_CRT 1 #define DISP_LCD 2 #define DISP_DFP 3 struct xtimings { unsigned int Clock; unsigned int HDisplay; unsigned int HSyncStart; unsigned int HSyncEnd; unsigned int HTotal; unsigned int HAdjusted; unsigned int VDisplay; unsigned int VSyncStart; unsigned int VSyncEnd; unsigned int VTotal; unsigned int sync; int dblscan; int interlaced; }; struct savage_reg { unsigned char MiscOutReg; /* Misc */ unsigned char CRTC[25]; /* Crtc Controller */ unsigned char Sequencer[5]; /* Video Sequencer */ unsigned char Graphics[9]; /* Video Graphics */ unsigned char Attribute[21]; /* Video Attribute */ unsigned int mode, refresh; unsigned char SR08, SR0E, SR0F; unsigned char SR10, SR11, SR12, SR13, SR15, SR18, SR29, SR30; unsigned char SR54[8]; unsigned char Clock; unsigned char CR31, CR32, CR33, CR34, CR36, CR3A, CR3B, CR3C; unsigned char CR40, CR41, CR42, CR43, CR45; unsigned char CR50, CR51, CR53, CR55, CR58, CR5B, CR5D, CR5E; unsigned char CR60, CR63, CR65, CR66, CR67, CR68, CR69, CR6D, CR6F; unsigned char CR86, CR88; unsigned char CR90, CR91, CRB0; unsigned int STREAMS[22]; /* yuck, streams regs */ unsigned int MMPR0, MMPR1, MMPR2, MMPR3; }; /* --------------------------------------------------------------------- */ #define NR_PALETTE 256 struct savagefb_par; struct savagefb_i2c_chan { struct savagefb_par *par; struct i2c_adapter adapter; struct i2c_algo_bit_data algo; volatile u8 __iomem *ioaddr; u32 reg; }; struct savagefb_par { struct pci_dev *pcidev; savage_chipset chip; struct savagefb_i2c_chan chan; struct savage_reg state; struct savage_reg save; struct savage_reg initial; struct vgastate vgastate; struct mutex open_lock; unsigned char *edid; u32 pseudo_palette[16]; u32 open_count; int paletteEnabled; int pm_state; int display_type; int dvi; int crtonly; int dacSpeedBpp; int maxClock; int minClock; int numClocks; int clock[4]; int MCLK, REFCLK, LCDclk; struct { void __iomem *vbase; u32 pbase; u32 len; #ifdef CONFIG_MTRR int mtrr; #endif } video; struct { void __iomem *vbase; u32 pbase; u32 len; } mmio; volatile u32 __iomem *bci_base; unsigned int bci_ptr; u32 cob_offset; u32 cob_size; int cob_index; void (*SavageWaitIdle) (struct savagefb_par *par); void (*SavageWaitFifo) (struct savagefb_par *par, int space); int HorizScaleFactor; /* Panels size */ int SavagePanelWidth; int SavagePanelHeight; struct { u16 red, green, blue, transp; } palette[NR_PALETTE]; int depth; int vwidth; }; #define BCI_BD_BW_DISABLE 0x10000000 #define BCI_BD_SET_BPP(bd, bpp) ((bd) |= (((bpp) & 0xFF) << 16)) #define BCI_BD_SET_STRIDE(bd, st) ((bd) |= ((st) & 0xFFFF)) /* IO functions */ static inline u8 savage_in8(u32 addr, struct savagefb_par *par) { return readb(par->mmio.vbase + addr); } static inline u16 savage_in16(u32 addr, struct savagefb_par *par) { return readw(par->mmio.vbase + addr); } static inline u32 savage_in32(u32 addr, struct savagefb_par *par) { return readl(par->mmio.vbase + addr); } static inline void savage_out8(u32 addr, u8 val, struct savagefb_par *par) { writeb(val, par->mmio.vbase + addr); } static inline void savage_out16(u32 addr, u16 val, struct savagefb_par *par) { writew(val, par->mmio.vbase + addr); } static inline void savage_out32(u32 addr, u32 val, struct savagefb_par *par) { writel(val, par->mmio.vbase + addr); } static inline u8 vga_in8(int addr, struct savagefb_par *par) { return savage_in8(0x8000 + addr, par); } static inline u16 vga_in16(int addr, struct savagefb_par *par) { return savage_in16(0x8000 + addr, par); } static inline u8 vga_in32(int addr, struct savagefb_par *par) { return savage_in32(0x8000 + addr, par); } static inline void vga_out8(int addr, u8 val, struct savagefb_par *par) { savage_out8(0x8000 + addr, val, par); } static inline void vga_out16(int addr, u16 val, struct savagefb_par *par) { savage_out16(0x8000 + addr, val, par); } static inline void vga_out32(int addr, u32 val, struct savagefb_par *par) { savage_out32(0x8000 + addr, val, par); } static inline u8 VGArCR (u8 index, struct savagefb_par *par) { vga_out8(0x3d4, index, par); return vga_in8(0x3d5, par); } static inline u8 VGArGR (u8 index, struct savagefb_par *par) { vga_out8(0x3ce, index, par); return vga_in8(0x3cf, par); } static inline u8 VGArSEQ (u8 index, struct savagefb_par *par) { vga_out8(0x3c4, index, par); return vga_in8(0x3c5, par); } static inline void VGAwCR(u8 index, u8 val, struct savagefb_par *par) { vga_out8(0x3d4, index, par); vga_out8(0x3d5, val, par); } static inline void VGAwGR(u8 index, u8 val, struct savagefb_par *par) { vga_out8(0x3ce, index, par); vga_out8(0x3cf, val, par); } static inline void VGAwSEQ(u8 index, u8 val, struct savagefb_par *par) { vga_out8(0x3c4, index, par); vga_out8 (0x3c5, val, par); } static inline void VGAenablePalette(struct savagefb_par *par) { u8 tmp; tmp = vga_in8(0x3da, par); vga_out8(0x3c0, 0x00, par); par->paletteEnabled = 1; } static inline void VGAdisablePalette(struct savagefb_par *par) { u8 tmp; tmp = vga_in8(0x3da, par); vga_out8(0x3c0, 0x20, par); par->paletteEnabled = 0; } static inline void VGAwATTR(u8 index, u8 value, struct savagefb_par *par) { u8 tmp; if (par->paletteEnabled) index &= ~0x20; else index |= 0x20; tmp = vga_in8(0x3da, par); vga_out8(0x3c0, index, par); vga_out8 (0x3c0, value, par); } static inline void VGAwMISC(u8 value, struct savagefb_par *par) { vga_out8(0x3c2, value, par); } #ifndef CONFIG_FB_SAVAGE_ACCEL #define savagefb_set_clip(x) #endif static inline void VerticalRetraceWait(struct savagefb_par *par) { vga_out8(0x3d4, 0x17, par); if (vga_in8(0x3d5, par) & 0x80) { while ((vga_in8(0x3da, par) & 0x08) == 0x08); while ((vga_in8(0x3da, par) & 0x08) == 0x00); } } extern int savagefb_probe_i2c_connector(struct fb_info *info, u8 **out_edid); extern void savagefb_create_i2c_busses(struct fb_info *info); extern void savagefb_delete_i2c_busses(struct fb_info *info); extern int savagefb_sync(struct fb_info *info); extern void savagefb_copyarea(struct fb_info *info, const struct fb_copyarea *region); extern void savagefb_fillrect(struct fb_info *info, const struct fb_fillrect *rect); extern void savagefb_imageblit(struct fb_info *info, const struct fb_image *image); #endif /* __SAVAGEFB_H__ */
25.826923
87
0.696109
326ab234fea7a722b5139e1fa927d6fc8793b386
1,408
h
C
System/Library/PrivateFrameworks/BulletinBoard.framework/BBAttachments.h
lechium/iPhoneOS_12.1.1_Headers
aac688b174273dfcbade13bab104461f463db772
[ "MIT" ]
12
2019-06-02T02:42:41.000Z
2021-04-13T07:22:20.000Z
System/Library/PrivateFrameworks/BulletinBoard.framework/BBAttachments.h
lechium/iPhoneOS_12.1.1_Headers
aac688b174273dfcbade13bab104461f463db772
[ "MIT" ]
null
null
null
System/Library/PrivateFrameworks/BulletinBoard.framework/BBAttachments.h
lechium/iPhoneOS_12.1.1_Headers
aac688b174273dfcbade13bab104461f463db772
[ "MIT" ]
3
2019-06-11T02:46:10.000Z
2019-12-21T14:58:16.000Z
/* * This header is generated by classdump-dyld 1.0 * on Saturday, June 1, 2019 at 6:45:19 PM Mountain Standard Time * Operating System: Version 12.1.1 (Build 16C5050a) * Image Source: /System/Library/PrivateFrameworks/BulletinBoard.framework/BulletinBoard * classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos. */ #import <BulletinBoard/BulletinBoard-Structs.h> #import <libobjc.A.dylib/NSCopying.h> #import <libobjc.A.dylib/NSSecureCoding.h> @class NSCountedSet; @interface BBAttachments : NSObject <NSCopying, NSSecureCoding> { long long primaryType; NSCountedSet* _additionalAttachments; } @property (nonatomic,retain) NSCountedSet * additionalAttachments; //@synthesize additionalAttachments=_additionalAttachments - In the implementation block @property (assign,nonatomic) long long primaryType; +(BOOL)supportsSecureCoding; -(long long)primaryType; -(unsigned long long)numberOfAdditionalAttachmentsOfType:(long long)arg1 ; -(unsigned long long)numberOfAdditionalAttachments; -(void)addAttachmentOfType:(long long)arg1 ; -(BOOL)isEqualToAttachments:(id)arg1 ; -(void)setPrimaryType:(long long)arg1 ; -(NSCountedSet *)additionalAttachments; -(void)setAdditionalAttachments:(NSCountedSet *)arg1 ; -(BOOL)isEqual:(id)arg1 ; -(void)encodeWithCoder:(id)arg1 ; -(id)initWithCoder:(id)arg1 ; -(unsigned long long)hash; -(id)copyWithZone:(NSZone*)arg1 ; @end
35.2
168
0.78054
3018b68536b3c9ece4edd73825a35c39efb8f89c
5,732
c
C
adi_study_watch/nrf5_sdk_15.2.0/adi_study_watch/modules/ad7156_lt/dcb_general_block.c
ArrowElectronics/Vital-Signs-Monitoring
ba43fe9a116d94170561433910fd7bffba5726e7
[ "Unlicense" ]
5
2021-06-13T17:11:19.000Z
2021-12-01T18:20:38.000Z
adi_study_watch/nrf5_sdk_15.2.0/adi_study_watch/modules/ad7156_lt/dcb_general_block.c
ArrowElectronics/Vital-Signs-Monitoring
ba43fe9a116d94170561433910fd7bffba5726e7
[ "Unlicense" ]
null
null
null
adi_study_watch/nrf5_sdk_15.2.0/adi_study_watch/modules/ad7156_lt/dcb_general_block.c
ArrowElectronics/Vital-Signs-Monitoring
ba43fe9a116d94170561433910fd7bffba5726e7
[ "Unlicense" ]
1
2022-01-08T15:01:44.000Z
2022-01-08T15:01:44.000Z
/** *************************************************************************** * @file dcb_general_block.c * @author ADI Team * @version V0.0.1 * @date 22-April-2020 * @brief General Block DCB configuration file *************************************************************************** * @attention *************************************************************************** */ /*! * \copyright Analog Devices * **************************************************************************** * * License Agreement * * Copyright (c) 2020 Analog Devices Inc. * All rights reserved. * * This source code is intended for the recipient only under the guidelines of * the non-disclosure agreement with Analog Devices Inc. * * 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. * **************************************************************************** */ #ifdef DCB #ifdef LOW_TOUCH_FEATURE #include "nrf_log_ctrl.h" /* General DCB Block Module Log settings */ #define NRF_LOG_MODULE_NAME GEN_DCB_BLK #include "nrf_log.h" NRF_LOG_MODULE_REGISTER(); #include "adi_dcb_config.h" #include "dcb_general_block.h" #include "dcb_interface.h" #include <stdlib.h> /**< Flag variable to check if gen_blk DCB entry is present or not. This is * updated for every DCB Write/Read and on bootup */ static volatile bool g_gen_blk_dcb_present = false; /** * @brief Reads gen blk DCB and copy the contents to the * location passed * @param dest_ptr - pointer location to where contents are copied * @param dest_len - no: of bytes from the RAM buffer, which gets copied to the * dest_ptr * @return return value of type GEN_BLK_DCB_STATUS_t */ GEN_BLK_DCB_STATUS_t copy_lt_config_from_gen_blk_dcb(uint8_t *dest_ptr, uint16_t *dest_len) { // Read General Block DCB for LT configs uint16_t dcb_sz = (uint16_t)(MAXGENBLKDCBSIZE * MAX_GEN_BLK_DCB_PKTS * DCB_BLK_WORD_SZ); //Sz in bytes memset(dest_ptr, 0, dcb_sz); uint32_t *dcbdata = (uint32_t *)dest_ptr; dcb_sz = dcb_sz/DCB_BLK_WORD_SZ; // Max words that can be read from FDS NRF_LOG_INFO("Read General Block DCB for LT configs"); if (read_gen_blk_dcb(dcbdata, &dcb_sz) == GEN_BLK_DCB_STATUS_OK) { NRF_LOG_INFO("General Block DCB Read success! %d",dcb_sz); } else { NRF_LOG_INFO("General Block DCB Read failed!"); return GEN_BLK_DCB_STATUS_ERR; } *dest_len = dcb_sz*DCB_BLK_WORD_SZ; // converting words read from DCB into // no: of valid bytes in the array return GEN_BLK_DCB_STATUS_OK; } /**@brief Gets the entire General Blk DCB configuration written in flash * * @param gen_blk_dcb_data - pointer to dcb struct variable, * @param read_size: size of gen_blk_dcb_data array filled from FDS(length in * Double Word (32-bits)) * @return return value of type GEN_BLK_DCB_STATUS_t */ GEN_BLK_DCB_STATUS_t read_gen_blk_dcb( uint32_t *gen_blk_dcb_data, uint16_t *read_size) { GEN_BLK_DCB_STATUS_t dcb_status = GEN_BLK_DCB_STATUS_ERR; if (adi_dcb_read_from_fds( ADI_DCB_GENERAL_BLOCK_IDX, gen_blk_dcb_data, read_size) == DEF_OK) { dcb_status = GEN_BLK_DCB_STATUS_OK; } return dcb_status; } /**@brief Sets the entire General Blk DCB configuration in flash * * @param gen_blk_dcb_data - pointer to dcb struct variable, * @param in_size: size of gen_blk_dcb_data array(length in Double Word * (32-bits)) * @return return value of type GEN_BLK_DCB_STATUS_t */ GEN_BLK_DCB_STATUS_t write_gen_blk_dcb( uint32_t *gen_blk_dcb_data, uint16_t in_size) { GEN_BLK_DCB_STATUS_t dcb_status = GEN_BLK_DCB_STATUS_ERR; if (adi_dcb_write_to_fds( ADI_DCB_GENERAL_BLOCK_IDX, gen_blk_dcb_data, in_size) == DEF_OK) { dcb_status = GEN_BLK_DCB_STATUS_OK; } return dcb_status; } /** * @brief Delete the entire General blk DCB configuration in flash * @param void * @retval Status */ GEN_BLK_DCB_STATUS_t delete_gen_blk_dcb(void) { GEN_BLK_DCB_STATUS_t dcb_status = GEN_BLK_DCB_STATUS_ERR; if (adi_dcb_delete_fds_settings(ADI_DCB_GENERAL_BLOCK_IDX) == DEF_OK) { dcb_status = GEN_BLK_DCB_STATUS_OK; } return dcb_status; } /** * @brief Function to set the global flag which holds the status for gen_blk * DCB presence. This gets called from DCB write/delete api * @param set_flag - true/flag * @retval None */ void gen_blk_set_dcb_present_flag(bool set_flag) { g_gen_blk_dcb_present = set_flag; NRF_LOG_INFO("Setting..GEN BLK DCB present: %s", (g_gen_blk_dcb_present == true ? "TRUE" : "FALSE")); } /** * @brief Function to get the value of global flag which holds the status for * gen_blk DCB presence. * @param None * @retval true/false */ bool gen_blk_get_dcb_present_flag(void) { NRF_LOG_INFO("GENERAL BLK DCB present: %s", (g_gen_blk_dcb_present == true ? "TRUE" : "FALSE")); return g_gen_blk_dcb_present; } /** * @brief Function to which does actual FDS read to update the global flag * which holds the status for gen_blk DCB presence. * @param None * @retval None */ void gen_blk_update_dcb_present_flag(void) { g_gen_blk_dcb_present = adi_dcb_check_fds_entry(ADI_DCB_GENERAL_BLOCK_IDX); NRF_LOG_INFO("Updated. GENERAL BLK DCB present: %s", (g_gen_blk_dcb_present == true ? "TRUE" : "FALSE")); } #endif//LOW_TOUCH_FEATURE #endif
33.717647
104
0.686497
65a08f1d29bc5a41e434ed8fcbd8938b6fe575c2
6,312
h
C
lib/am335x_sdk/ti/csl/arch/a53/intMacros.h
brandonbraun653/Apollo
a1ece2cc3f1d3dae48fdf8fe94f0bbb59d405fce
[ "MIT" ]
2
2021-12-27T10:19:01.000Z
2022-03-15T07:09:06.000Z
lib/am335x_sdk/ti/csl/arch/a53/intMacros.h
brandonbraun653/Apollo
a1ece2cc3f1d3dae48fdf8fe94f0bbb59d405fce
[ "MIT" ]
null
null
null
lib/am335x_sdk/ti/csl/arch/a53/intMacros.h
brandonbraun653/Apollo
a1ece2cc3f1d3dae48fdf8fe94f0bbb59d405fce
[ "MIT" ]
null
null
null
/* * Copyright (c) 2016, Texas Instruments Incorporated * All rights reserved. * * 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. * * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * ======== intMacros.h ======== * Assembly macros for csl arm gicv3 module */ #ifndef TI_CSL_ARM_GICV3_MACROS #define TI_CSL_ARM_GICV3_MACROS #if defined(__ASSEMBLER__) && defined(__GNUC__) && !defined(__ti__) #define icc_asgi1r_el1 s3_0_c12_c11_6 #define icc_bpr0_el1 s3_0_c12_c8_3 #define icc_bpr1_el1 s3_0_c12_c12_3 #define icc_ctlr_el1 s3_0_c12_c12_4 #define icc_ctlr_el3 s3_6_c12_c12_4 #define icc_dir_el1 s3_0_c12_c11_1 #define icc_eoir0_el1 s3_0_c12_c8_1 #define icc_eoir1_el1 s3_0_c12_c12_1 #define icc_iar0_el1 s3_0_c12_c8_0 #define icc_iar1_el1 s3_0_c12_c12_0 #define icc_igrpen0_el1 s3_0_c12_c12_6 #define icc_igrpen1_el1 s3_0_c12_c12_7 #define icc_igrpen1_el3 s3_6_c12_c12_7 #define icc_pmr_el1 s3_0_c4_c6_0 #define icc_rpr_el1 s3_0_c12_c11_3 #define icc_sgi0r_el1 s3_0_c12_c11_7 #define icc_sgi1r_el1 s3_0_c12_c11_5 #define icc_sre_el1 s3_0_c12_c12_5 #define icc_sre_el2 s3_4_c12_c9_5 #define icc_sre_el3 s3_6_c12_c12_5 #define ich_ap0r0_el2 s3_4_c12_c8_0 #define ich_ap1r0_el2 s3_4_c12_c8_1 #define ich_hcr_el2 s3_4_c12_c11_0 #define ich_lr0_el2 s3_4_c12_c12_0 #define ich_vmcr_el2 s3_4_c12_c11_7 .macro VECTOR_ENTRY name .align 7 \name: .endm .macro PUSH_CALLER_SAVE_CPU_REGS stackPtr stp x0, x1, [\stackPtr, #-16]! stp x2, x3, [\stackPtr, #-16]! stp x4, x5, [\stackPtr, #-16]! stp x6, x7, [\stackPtr, #-16]! stp x8, x9, [\stackPtr, #-16]! stp x10, x11, [\stackPtr, #-16]! stp x12, x13, [\stackPtr, #-16]! stp x14, x15, [\stackPtr, #-16]! stp x16, x17, [\stackPtr, #-16]! stp x18, x19, [\stackPtr, #-16]! stp x29, x30, [\stackPtr, #-16]! .endm .macro POP_CALLER_SAVE_CPU_REGS stackPtr ldp x29, x30, [\stackPtr], #16 ldp x18, x19, [\stackPtr], #16 ldp x16, x17, [\stackPtr], #16 ldp x14, x15, [\stackPtr], #16 ldp x12, x13, [\stackPtr], #16 ldp x10, x11, [\stackPtr], #16 ldp x8, x9, [\stackPtr], #16 ldp x6, x7, [\stackPtr], #16 ldp x4, x5, [\stackPtr], #16 ldp x2, x3, [\stackPtr], #16 ldp x0, x1, [\stackPtr], #16 /* x0 & x1 saved by vector entry */ .endm .macro PUSH_CALLER_SAVE_FPU_REGS stackPtr stp q0, q1, [\stackPtr, #-32]! stp q2, q3, [\stackPtr, #-32]! stp q4, q5, [\stackPtr, #-32]! stp q6, q7, [\stackPtr, #-32]! stp q8, q9, [\stackPtr, #-32]! stp q10, q11, [\stackPtr, #-32]! stp q12, q13, [\stackPtr, #-32]! stp q14, q15, [\stackPtr, #-32]! stp q16, q17, [\stackPtr, #-32]! stp q18, q19, [\stackPtr, #-32]! stp q20, q21, [\stackPtr, #-32]! stp q22, q23, [\stackPtr, #-32]! stp q24, q25, [\stackPtr, #-32]! stp q26, q27, [\stackPtr, #-32]! stp q28, q29, [\stackPtr, #-32]! stp q30, q31, [\stackPtr, #-32]! .endm .macro POP_CALLER_SAVE_FPU_REGS stackPtr ldp q30, q31, [\stackPtr], #32 ldp q28, q29, [\stackPtr], #32 ldp q26, q27, [\stackPtr], #32 ldp q24, q25, [\stackPtr], #32 ldp q22, q23, [\stackPtr], #32 ldp q20, q21, [\stackPtr], #32 ldp q18, q19, [\stackPtr], #32 ldp q16, q17, [\stackPtr], #32 ldp q14, q15, [\stackPtr], #32 ldp q12, q13, [\stackPtr], #32 ldp q10, q11, [\stackPtr], #32 ldp q8, q9, [\stackPtr], #32 ldp q6, q7, [\stackPtr], #32 ldp q4, q5, [\stackPtr], #32 ldp q2, q3, [\stackPtr], #32 ldp q0, q1, [\stackPtr], #32 .endm .macro PUSH_ALL_CPU_REGS stackPtr stp x0, x1, [\stackPtr, #-16]! stp x2, x3, [\stackPtr, #-16]! stp x4, x5, [\stackPtr, #-16]! stp x6, x7, [\stackPtr, #-16]! stp x8, x9, [\stackPtr, #-16]! stp x10, x11, [\stackPtr, #-16]! stp x12, x13, [\stackPtr, #-16]! stp x14, x15, [\stackPtr, #-16]! stp x16, x17, [\stackPtr, #-16]! stp x18, x19, [\stackPtr, #-16]! stp x20, x21, [\stackPtr, #-16]! stp x22, x23, [\stackPtr, #-16]! stp x24, x25, [\stackPtr, #-16]! stp x26, x27, [\stackPtr, #-16]! stp x28, x29, [\stackPtr, #-16]! stp x30, xzr, [\stackPtr, #-16]! .endm #elif defined(__GNUC__) && !defined(__ti__) #endif /* __ASSEMBLER__ && __GNUC__ && !__ti__ */ #endif /* TI_CSL_ARM_GICV3_MACROS */
38.962963
79
0.604721