docstring
stringlengths
22
576
signature
stringlengths
9
317
prompt
stringlengths
57
886
code
stringlengths
20
1.36k
repository
stringclasses
49 values
language
stringclasses
2 values
license
stringclasses
9 values
stars
int64
15
21.3k
/* Scans across the directory table for a given file block number. If block not found, return 0. */
static sector_t find_block(struct inode *inode, struct omfs_extent_entry *ent, sector_t block, int count, int *left)
/* Scans across the directory table for a given file block number. If block not found, return 0. */ static sector_t find_block(struct inode *inode, struct omfs_extent_entry *ent, sector_t block, int count, int *left)
{ sector_t searched = 0; for (; count > 1; count--) { int numblocks = clus_to_blk(OMFS_SB(inode->i_sb), be64_to_cpu(ent->e_blocks)); if (block >= searched && block < searched + numblocks) { *left = numblocks - (block - searched); return clus_to_blk(OMFS_SB(inode->i_sb), be64_to_cpu(ent->e_cluster)) + block - searched; } searched += numblocks; ent++; } return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* These devices return the number of samples per packet instead of the number of samples per microframe. */
static int retire_playback_sync_urb_hs_emu(struct snd_usb_substream *subs, struct snd_pcm_runtime *runtime, struct urb *urb)
/* These devices return the number of samples per packet instead of the number of samples per microframe. */ static int retire_playback_sync_urb_hs_emu(struct snd_usb_substream *subs, struct snd_pcm_runtime *runtime, struct urb *urb)
{ unsigned int f; unsigned long flags; if (urb->iso_frame_desc[0].status == 0 && urb->iso_frame_desc[0].actual_length == 4) { f = combine_quad((u8*)urb->transfer_buffer) & 0x0fffffff; f >>= subs->datainterval; if (f >= subs->freqn - subs->freqn / 8 && f <= subs->freqmax) { spin_lock_irqsave(&subs->lock, flags); subs->freqm = f; spin_unlock_irqrestore(&subs->lock, flags); } } return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* sys_sched_getaffinity - get the cpu affinity of a process @pid: pid of the process @len: length in bytes of the bitmask pointed to by user_mask_ptr @user_mask_ptr: user-space pointer to hold the current cpu mask */
SYSCALL_DEFINE3(sched_getaffinity, pid_t, pid, unsigned int, len, unsigned long __user *, user_mask_ptr)
/* sys_sched_getaffinity - get the cpu affinity of a process @pid: pid of the process @len: length in bytes of the bitmask pointed to by user_mask_ptr @user_mask_ptr: user-space pointer to hold the current cpu mask */ SYSCALL_DEFINE3(sched_getaffinity, pid_t, pid, unsigned int, len, unsigned long __user *, user_mask_ptr)
{ int ret; cpumask_var_t mask; if (len < cpumask_size()) return -EINVAL; if (!alloc_cpumask_var(&mask, GFP_KERNEL)) return -ENOMEM; ret = sched_getaffinity(pid, mask); if (ret == 0) { if (copy_to_user(user_mask_ptr, mask, cpumask_size())) ret = -EFAULT; else ret = cpumask_size(); } free_cpumask_var(mask); return ret; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Send a sequence of bytes to an SPI device using USART in SPI mode. Received bytes on the USART in SPI mode are discarded. */
uint32_t usart_spi_write_packet(Usart *p_usart, const uint8_t *data, size_t len)
/* Send a sequence of bytes to an SPI device using USART in SPI mode. Received bytes on the USART in SPI mode are discarded. */ uint32_t usart_spi_write_packet(Usart *p_usart, const uint8_t *data, size_t len)
{ uint32_t dummy_data; size_t i=0; while(len) { usart_putchar(p_usart, *(data+i)); usart_getchar(p_usart, &dummy_data); len--; i++; } return 0; }
memfault/zero-to-main
C++
null
200
/* Serializes the supplied suback data into the supplied buffer, ready for sending */
int MQTTSerialize_suback(unsigned char *buf, int buflen, unsigned short packetid, int count, int *grantedQoSs)
/* Serializes the supplied suback data into the supplied buffer, ready for sending */ int MQTTSerialize_suback(unsigned char *buf, int buflen, unsigned short packetid, int count, int *grantedQoSs)
{ MQTTHeader header = {0}; int rc = -1; unsigned char* ptr = buf; int i; FUNC_ENTRY; if (buflen < 2 + count) { rc = MQTTPACKET_BUFFER_TOO_SHORT; goto exit; } header.byte = 0; header.bits.type = SUBACK; writeChar(&ptr, header.byte); ptr += MQTTPacket_encode(ptr, 2 + count); writeInt(&ptr, packetid); for (i = 0; i < count; ++i) writeChar(&ptr, grantedQoSs[i]); rc = ptr - buf; exit: FUNC_EXIT_RC(rc); return rc; }
pikasTech/PikaPython
C++
MIT License
1,403
/* Verify alloc and free of blocks from mem_slab. */
ZTEST(mslab_api, test_mslab_alloc_free_thread)
/* Verify alloc and free of blocks from mem_slab. */ ZTEST(mslab_api, test_mslab_alloc_free_thread)
{ tmslab_alloc_free(&mslab); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Returns true if and only if cfg->px_buf is big enough to convert num_pixels RGB color values into SPI frames. */
static bool num_pixels_ok(const struct ws2812_spi_cfg *cfg, size_t num_pixels)
/* Returns true if and only if cfg->px_buf is big enough to convert num_pixels RGB color values into SPI frames. */ static bool num_pixels_ok(const struct ws2812_spi_cfg *cfg, size_t num_pixels)
{ size_t nbytes; bool overflow; overflow = size_mul_overflow(num_pixels, cfg->num_colors * 8, &nbytes); return !overflow && (nbytes <= cfg->px_buf_size); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Pauses or Resumes the audio stream playing from the Media. */
static void Audio_MAL_PauseResume(uint32_t Cmd, uint32_t Addr)
/* Pauses or Resumes the audio stream playing from the Media. */ static void Audio_MAL_PauseResume(uint32_t Cmd, uint32_t Addr)
{ if (Cmd == AUDIO_PAUSE) { SPI_I2S_DMACmd(CODEC_I2S, SPI_I2S_DMAReq_Tx, DISABLE); DMA_Cmd(AUDIO_MAL_DMA_STREAM, DISABLE); } else { SPI_I2S_DMACmd(CODEC_I2S, SPI_I2S_DMAReq_Tx, ENABLE); DMA_Cmd(AUDIO_MAL_DMA_STREAM, ENABLE); if ((CODEC_I2S->I2SCFGR & I2S_ENABLE_MASK) == 0) { I2S_Cmd(CODEC_I2S, ENABLE); } } }
remotemcu/remcu-chip-sdks
C++
null
436
/* Function to read in the HID report descriptor from the attached device, and process it into easy-to-read structures via the HID parser routines in the LUFA library. */
uint8_t GetHIDReportData(void)
/* Function to read in the HID report descriptor from the attached device, and process it into easy-to-read structures via the HID parser routines in the LUFA library. */ uint8_t GetHIDReportData(void)
{ uint8_t HIDReportData[HIDReportSize]; USB_ControlRequest = (USB_Request_Header_t) { .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_INTERFACE), .bRequest = REQ_GetDescriptor, .wValue = (HID_DTYPE_Report << 8), .wIndex = 0, .wLength = HIDReportSize, }; Pipe_SelectPipe(PIPE_CONTROLPIPE); if (USB_Host_SendControlRequest(HIDReportData) != HOST_SENDCONTROL_Successful) return ParseControlError; if (USB_ProcessHIDReport(HIDReportData, HIDReportSize, &HIDReportInfo) != HID_PARSE_Successful) return ParseError; return ParseSuccessful; }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* This file is part of the Simba project. */
int mock_write_soam_module_init(int res)
/* This file is part of the Simba project. */ int mock_write_soam_module_init(int res)
{ harness_mock_write("soam_module_init()", NULL, 0); harness_mock_write("soam_module_init(): return (res)", &res, sizeof(res)); return (0); }
eerimoq/simba
C++
Other
337
/* DAC mute control idx = STAC9460 volume register number, mute: 0 = mute, 1 = unmute */
static int stac9460_dac_mute(struct snd_ice1712 *ice, int idx, unsigned char mute)
/* DAC mute control idx = STAC9460 volume register number, mute: 0 = mute, 1 = unmute */ static int stac9460_dac_mute(struct snd_ice1712 *ice, int idx, unsigned char mute)
{ unsigned char new, old; int change; old = stac9460_get(ice, idx); new = (~mute << 7 & 0x80) | (old & ~0x80); change = (new != old); if (change) stac9460_put(ice, idx, new); return change; }
robutest/uclinux
C++
GPL-2.0
60
/* See mss_uart.h for details of how to use this function. */
void MSS_UART_smartcard_init(mss_uart_instance_t *this_uart, uint32_t baud_rate, uint8_t line_config)
/* See mss_uart.h for details of how to use this function. */ void MSS_UART_smartcard_init(mss_uart_instance_t *this_uart, uint32_t baud_rate, uint8_t line_config)
{ ASSERT((this_uart == &g_mss_uart0) || (this_uart == &g_mss_uart1)); global_init(this_uart, baud_rate, line_config); clear_bit_reg8(&this_uart->hw_reg->MM0, ELIN); clear_bit_reg8(&this_uart->hw_reg->MM1, EIRD); if( ( MSS_UART_DATA_8_BITS | MSS_UART_TWO_STOP_BITS) == (line_config & (MSS_UART_DATA_8_BITS | MSS_UART_TWO_STOP_BITS))) { set_bit_reg8(&this_uart->hw_reg->MM2, EERR); set_bit_reg8(&this_uart->hw_reg->MM2,ESWM); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* @params pCBParam - Application passed pointer. @params nEvent - Code of the event that triggered the interrupt. @params pArg - Driver passed pointer. */
void SysTick_Handler(void)
/* @params pCBParam - Application passed pointer. @params nEvent - Code of the event that triggered the interrupt. @params pArg - Driver passed pointer. */ void SysTick_Handler(void)
{ if (timer_delayCount != 0u) --timer_delayCount; }
analogdevicesinc/EVAL-ADICUP3029
C++
Other
36
/* Fills each EXTI_InitStruct member with its reset value. */
void EXTI_StructInit(EXTI_InitTypeDef *EXTI_InitStruct)
/* Fills each EXTI_InitStruct member with its reset value. */ void EXTI_StructInit(EXTI_InitTypeDef *EXTI_InitStruct)
{ EXTI_InitStruct->EXTI_Line = EXTI_LineNone; EXTI_InitStruct->EXTI_Mode = EXTI_Mode_Interrupt; EXTI_InitStruct->EXTI_Trigger = EXTI_Trigger_Falling; EXTI_InitStruct->EXTI_LineCmd = DISABLE; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Update the module autoidle bit in @v to be @autoidle for the @oh hwmod. The autoidle bit controls whether the module can gate internal clocks automatically when it isn't doing anything; the exact function of this bit varies on a per-module basis. This function does not write to the hardware. Returns -EINVAL upon error or 0 upon success. */
static int _set_module_autoidle(struct omap_hwmod *oh, u8 autoidle, u32 *v)
/* Update the module autoidle bit in @v to be @autoidle for the @oh hwmod. The autoidle bit controls whether the module can gate internal clocks automatically when it isn't doing anything; the exact function of this bit varies on a per-module basis. This function does not write to the hardware. Returns -EINVAL upon error or 0 upon success. */ static int _set_module_autoidle(struct omap_hwmod *oh, u8 autoidle, u32 *v)
{ if (!oh->sysconfig || !(oh->sysconfig->sysc_flags & SYSC_HAS_AUTOIDLE)) return -EINVAL; *v &= ~SYSC_AUTOIDLE_MASK; *v |= autoidle << SYSC_AUTOIDLE_SHIFT; return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Starts the TIMER output compare signal generation on the complementary output. */
void ald_timer_ocn_start(ald_timer_handle_t *hperh, ald_timer_channel_t ch)
/* Starts the TIMER output compare signal generation on the complementary output. */ void ald_timer_ocn_start(ald_timer_handle_t *hperh, ald_timer_channel_t ch)
{ assert_param(IS_TIMER_CCXN_INSTANCE(hperh->perh, ch)); timer_ccxn_channel_cmd(hperh->perh, ch, ENABLE); ALD_TIMER_MOE_ENABLE(hperh); ALD_TIMER_ENABLE(hperh); return; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Get the I2C interrupt flag of the specified I2C port. The */
xtBoolean I2CIntFlagGet(unsigned long ulBase)
/* Get the I2C interrupt flag of the specified I2C port. The */ xtBoolean I2CIntFlagGet(unsigned long ulBase)
{ xASSERT((ulBase == I2C0_BASE)); return ((xHWREG(ulBase + I2C_O_CON) & I2C_CON_SI) ? xtrue : xfalse); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Enable device. used by dasdfmt after BIODASDDISABLE to retrigger blocksize detection */
static int dasd_ioctl_enable(struct block_device *bdev)
/* Enable device. used by dasdfmt after BIODASDDISABLE to retrigger blocksize detection */ static int dasd_ioctl_enable(struct block_device *bdev)
{ struct dasd_block *block = bdev->bd_disk->private_data; if (!capable(CAP_SYS_ADMIN)) return -EACCES; dasd_enable_device(block->base); mutex_lock(&bdev->bd_mutex); i_size_write(bdev->bd_inode, (loff_t)get_capacity(block->gdp) << 9); mutex_unlock(&bdev->bd_mutex); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Enqueue a request on EP0 if necessary to received any SETUP packets received from the host. */
static void s3c_hsotg_enqueue_setup(struct s3c_hsotg *hsotg)
/* Enqueue a request on EP0 if necessary to received any SETUP packets received from the host. */ static void s3c_hsotg_enqueue_setup(struct s3c_hsotg *hsotg)
{ struct usb_request *req = hsotg->ctrl_req; struct s3c_hsotg_req *hs_req = our_req(req); int ret; dev_dbg(hsotg->dev, "%s: queueing setup request\n", __func__); req->zero = 0; req->length = 8; req->buf = hsotg->ctrl_buff; req->complete = s3c_hsotg_complete_setup; if (!list_empty(&hs_req->queue)) { dev_dbg(hsotg->dev, "%s already queued???\n", __func__); return; } hsotg->eps[0].dir_in = 0; ret = s3c_hsotg_ep_queue(&hsotg->eps[0].ep, req, GFP_ATOMIC); if (ret < 0) { dev_err(hsotg->dev, "%s: failed queue (%d)\n", __func__, ret); } }
robutest/uclinux
C++
GPL-2.0
60
/* If RealModeBufferSize is NULL, then ASSERT(). If ExtraStackSize is NULL, then ASSERT(). */
VOID EFIAPI UnitTestHostBaseLibAsmGetThunk16Properties(OUT UINT32 *RealModeBufferSize, OUT UINT32 *ExtraStackSize)
/* If RealModeBufferSize is NULL, then ASSERT(). If ExtraStackSize is NULL, then ASSERT(). */ VOID EFIAPI UnitTestHostBaseLibAsmGetThunk16Properties(OUT UINT32 *RealModeBufferSize, OUT UINT32 *ExtraStackSize)
{ *RealModeBufferSize = 0; *ExtraStackSize = 0; }
tianocore/edk2
C++
Other
4,240
/* Same as dissect_spdy_stream_id below, except with explicit field index. */
static void dissect_spdy_stream_id_field(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *frame_tree, const int hfindex)
/* Same as dissect_spdy_stream_id below, except with explicit field index. */ static void dissect_spdy_stream_id_field(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *frame_tree, const int hfindex)
{ guint32 stream_id = tvb_get_ntohl(tvb, offset) & SPDY_STREAM_ID_MASK; proto_tree_add_item(frame_tree, hfindex, tvb, offset, 4, ENC_BIG_ENDIAN); if (hfindex == hf_spdy_streamid) { proto_item_append_text(frame_tree, ", Stream: %u", stream_id); } }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* The entry's receive function will be scheduled to run */
void __napi_schedule(struct napi_struct *n)
/* The entry's receive function will be scheduled to run */ void __napi_schedule(struct napi_struct *n)
{ unsigned long flags; local_irq_save(flags); list_add_tail(&n->poll_list, &__get_cpu_var(softnet_data).poll_list); __raise_softirq_irqoff(NET_RX_SOFTIRQ); local_irq_restore(flags); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Time Stamp Update Fine When reset the timestamp update is done using Fine method. */
void synopGMAC_TS_fine_update(synopGMACdevice *gmacdev)
/* Time Stamp Update Fine When reset the timestamp update is done using Fine method. */ void synopGMAC_TS_fine_update(synopGMACdevice *gmacdev)
{ synopGMACSetBits(gmacdev->MacBase,GmacTSControl,GmacTSCFUPDT); return; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Disable the floating point module. Call this function to disable the ARM hardware floating point module. */
void am_hal_sysctrl_fpu_disable(void)
/* Disable the floating point module. Call this function to disable the ARM hardware floating point module. */ void am_hal_sysctrl_fpu_disable(void)
{ AM_REG(SYSCTRL, CPACR) = 0x00000000 & ~(AM_REG_SYSCTRL_CPACR_CP11(0x3) | AM_REG_SYSCTRL_CPACR_CP10(0x3)); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function will clear feature for the endpoint of the usb device. */
rt_err_t rt_usbh_clear_feature(uinst_t device, int endpoint, int feature)
/* This function will clear feature for the endpoint of the usb device. */ rt_err_t rt_usbh_clear_feature(uinst_t device, int endpoint, int feature)
{ struct urequest setup; int timeout = USB_TIMEOUT_BASIC; RT_ASSERT(device != RT_NULL); setup.request_type = USB_REQ_TYPE_DIR_OUT | USB_REQ_TYPE_STANDARD | USB_REQ_TYPE_ENDPOINT; setup.bRequest = USB_REQ_CLEAR_FEATURE; setup.wIndex = endpoint; setup.wLength = 0; setup.wValue = feature; if(rt_usb_hcd_setup_xfer(device->hcd, device->pipe_ep0_out, &setup, timeout) != 8) { return -RT_ERROR; } return RT_EOK; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). */
UINT16 EFIAPI S3PciAnd16(IN UINTN Address, IN UINT16 AndData)
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). */ UINT16 EFIAPI S3PciAnd16(IN UINTN Address, IN UINT16 AndData)
{ return InternalSavePciWrite16ValueToBootScript (Address, PciAnd16 (Address, AndData)); }
tianocore/edk2
C++
Other
4,240
/* Returns: TRUE if pending was previously unset and is now set. */
gboolean g_input_stream_set_pending(GInputStream *stream, GError **error)
/* Returns: TRUE if pending was previously unset and is now set. */ gboolean g_input_stream_set_pending(GInputStream *stream, GError **error)
{ g_return_val_if_fail (G_IS_INPUT_STREAM (stream), FALSE); if (stream->priv->closed) { g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_CLOSED, _("Stream is already closed")); return FALSE; } if (stream->priv->pending) { g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_PENDING, _("Stream has outstanding operation")); return FALSE; } stream->priv->pending = TRUE; return TRUE; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Write errors are reported with an console message in TShark. */
static void write_failure_message(const char *filename, int err)
/* Write errors are reported with an console message in TShark. */ static void write_failure_message(const char *filename, int err)
{ cmdarg_err("An error occurred while writing to the file \"%s\": %s.", filename, g_strerror(err)); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* function : de_gsu_set_reg_base(unsigned int sel, unsigned int chno, void *base) description : set gsu reg base parameters : sel <rtmx select> chno <overlay select> base <reg base> return : success */
int de_gsu_set_reg_base(unsigned int sel, unsigned int chno, void *base)
/* function : de_gsu_set_reg_base(unsigned int sel, unsigned int chno, void *base) description : set gsu reg base parameters : sel <rtmx select> chno <overlay select> base <reg base> return : success */ int de_gsu_set_reg_base(unsigned int sel, unsigned int chno, void *base)
{ DE_INF("sel=%d, chno=%d, base=0x%p\n", sel, chno, base); gsu_dev[sel][chno] = (struct __gsu_reg_t *) base; return 0; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT(). */
VOID* EFIAPI InvalidateInstructionCacheRange(IN VOID *Address, IN UINTN Length)
/* If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT(). */ VOID* EFIAPI InvalidateInstructionCacheRange(IN VOID *Address, IN UINTN Length)
{ if (Length == 0) { return Address; } ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Address)); return Address; }
tianocore/edk2
C++
Other
4,240
/* This function designates type of PDU (I, S or U). */
static void llc_pdu_decode_pdu_type(struct sk_buff *skb, u8 *type)
/* This function designates type of PDU (I, S or U). */ static void llc_pdu_decode_pdu_type(struct sk_buff *skb, u8 *type)
{ struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb); if (pdu->ctrl_1 & 1) { if ((pdu->ctrl_1 & LLC_PDU_TYPE_U) == LLC_PDU_TYPE_U) *type = LLC_PDU_TYPE_U; else *type = LLC_PDU_TYPE_S; } else *type = LLC_PDU_TYPE_I; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* will remove the notifier from the notification chain that gets called upon changes to the pm_qos_class target value. */
int pm_qos_remove_notifier(int pm_qos_class, struct notifier_block *notifier)
/* will remove the notifier from the notification chain that gets called upon changes to the pm_qos_class target value. */ int pm_qos_remove_notifier(int pm_qos_class, struct notifier_block *notifier)
{ int retval; retval = blocking_notifier_chain_unregister( pm_qos_array[pm_qos_class]->notifiers, notifier); return retval; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Must be called with interrupts disabled and the RTC should be enabled. */
static __u8 via_pram_readbyte(void)
/* Must be called with interrupts disabled and the RTC should be enabled. */ static __u8 via_pram_readbyte(void)
{ int i,reg; __u8 data; reg = via1[vBufB] & ~VIA1B_vRTCClk; via1[vDirB] &= ~VIA1B_vRTCData; data = 0; for (i = 0 ; i < 8 ; i++) { via1[vBufB] = reg; via1[vBufB] = reg | VIA1B_vRTCClk; data = (data << 1) | (via1[vBufB] & VIA1B_vRTCData); } via1[vDirB] |= VIA1B_vRTCData; return data; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* @s1: pointer to first area @s2: pointer to second area */
int memcmp(const void *s1, const void *s2, size_t n)
/* @s1: pointer to first area @s2: pointer to second area */ int memcmp(const void *s1, const void *s2, size_t n)
{ const u8 *pos1 = s1; const u8 *pos2 = s2; for (; n; --n) { if (*pos1 != *pos2) return *pos1 - *pos2; ++pos1; ++pos2; } return 0; }
4ms/stm32mp1-baremetal
C++
Other
137
/* DMA SPI half transmit receive process complete callback. */
static void SPI_DMAHalfTransmitReceiveCplt(DMA_HandleTypeDef *hdma)
/* DMA SPI half transmit receive process complete callback. */ static void SPI_DMAHalfTransmitReceiveCplt(DMA_HandleTypeDef *hdma)
{ SPI_HandleTypeDef *hspi = (SPI_HandleTypeDef *)(((DMA_HandleTypeDef *)hdma)->Parent); HAL_SPI_TxRxHalfCpltCallback(hspi); }
pikasTech/PikaPython
C++
MIT License
1,403
/* This puts a job on a specific cpu */
int schedule_work_on(int cpu, struct work_struct *work)
/* This puts a job on a specific cpu */ int schedule_work_on(int cpu, struct work_struct *work)
{ return queue_work_on(cpu, keventd_wq, work); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* We use kgdb_early_setup so that functions we need to call now don't cause trouble when called again later. */
int kgdb_arch_init(void)
/* We use kgdb_early_setup so that functions we need to call now don't cause trouble when called again later. */ int kgdb_arch_init(void)
{ union mips_instruction insn = { .r_format = { .opcode = spec_op, .func = break_op, } }; memcpy(arch_kgdb_ops.gdb_bpt_instr, insn.byte, BREAK_INSTR_SIZE); register_die_notifier(&kgdb_notifier); return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Reads and returns the current value of MM6. This function is only available on IA-32 and X64. */
UINT64 EFIAPI AsmReadMm6(VOID)
/* Reads and returns the current value of MM6. This function is only available on IA-32 and X64. */ UINT64 EFIAPI AsmReadMm6(VOID)
{ UINT64 Data; __asm__ __volatile__ ( "push %%eax \n\t" "push %%eax \n\t" "movq %%mm6, (%%esp)\n\t" "pop %%eax \n\t" "pop %%edx \n\t" : "=A" (Data) ); return Data; }
tianocore/edk2
C++
Other
4,240
/* free_internal_volumes - free internal volumes. @ubi: UBI device description object */
static void free_internal_volumes(struct ubi_device *ubi)
/* free_internal_volumes - free internal volumes. @ubi: UBI device description object */ static void free_internal_volumes(struct ubi_device *ubi)
{ int i; for (i = ubi->vtbl_slots; i < ubi->vtbl_slots + UBI_INT_VOL_COUNT; i++) { kfree(ubi->volumes[i]->eba_tbl); kfree(ubi->volumes[i]); } }
robutest/uclinux
C++
GPL-2.0
60
/* If 64-bit I/O port operations are not supported, then ASSERT(). */
UINT64 EFIAPI IoRead64(IN UINTN Port)
/* If 64-bit I/O port operations are not supported, then ASSERT(). */ UINT64 EFIAPI IoRead64(IN UINTN Port)
{ ASSERT ((Port & 7) == 0); return IoReadWorker (Port, SMM_IO_UINT64); }
tianocore/edk2
C++
Other
4,240
/* Check if the memory address will be mapped by 4KB-page. */
BOOLEAN IsAddressSplit(IN EFI_PHYSICAL_ADDRESS Address)
/* Check if the memory address will be mapped by 4KB-page. */ BOOLEAN IsAddressSplit(IN EFI_PHYSICAL_ADDRESS Address)
{ UINTN Index; if (FeaturePcdGet (PcdCpuSmmProfileEnable)) { for (Index = 0; Index < mSplitMemRangeCount; Index++) { if ((Address >= mSplitMemRange[Index].Base) && (Address < mSplitMemRange[Index].Top)) { return TRUE; } } } else { if (Address < mCpuHotPlugData.SmrrBase) { if ((mCpuHotPlugData.SmrrBase - Address) < BASE_2MB) { return TRUE; } } else if (Address > (mCpuHotPlugData.SmrrBase + mCpuHotPlugData.SmrrSize - BASE_2MB)) { if ((Address - (mCpuHotPlugData.SmrrBase + mCpuHotPlugData.SmrrSize - BASE_2MB)) < BASE_2MB) { return TRUE; } } } return FALSE; }
tianocore/edk2
C++
Other
4,240
/* EFI_IFR_TYPE_REF, EFI_IFR_TYPE_DATE and EFI_IFR_TYPE_TIME are converted to EFI_IFR_TYPE_BUFFER when do the value compare. */
UINT16 GetLengthForValue(IN EFI_HII_VALUE *Value)
/* EFI_IFR_TYPE_REF, EFI_IFR_TYPE_DATE and EFI_IFR_TYPE_TIME are converted to EFI_IFR_TYPE_BUFFER when do the value compare. */ UINT16 GetLengthForValue(IN EFI_HII_VALUE *Value)
{ switch (Value->Type) { case EFI_IFR_TYPE_BUFFER: return Value->BufferLen; case EFI_IFR_TYPE_DATE: return (UINT16)sizeof (EFI_HII_DATE); case EFI_IFR_TYPE_TIME: return (UINT16)sizeof (EFI_HII_TIME); case EFI_IFR_TYPE_REF: return (UINT16)sizeof (EFI_HII_REF); default: return 0; } }
tianocore/edk2
C++
Other
4,240
/* Store a level 1 Data cache line. If the byte specified by the address (adr) is cached by the Data cache and the cacheline is modified (dirty), the entire contents of the cacheline are written to system memory. After the store completes, the cacheline is marked as unmodified (not dirty). */
void Xil_L1DCacheStoreLine(u32 adr)
/* Store a level 1 Data cache line. If the byte specified by the address (adr) is cached by the Data cache and the cacheline is modified (dirty), the entire contents of the cacheline are written to system memory. After the store completes, the cacheline is marked as unmodified (not dirty). */ void Xil_L1DCacheStoreLine(u32 adr)
{ mtcp(XREG_CP15_CACHE_SIZE_SEL, 0U); mtcp(XREG_CP15_CLEAN_DC_LINE_MVA_POC, (adr & (~0x1FU))); dsb(); }
ua1arn/hftrx
C++
null
69
/* matches two database records based on their MAC addresses and VLAN IDs */
IX_ETH_DB_PUBLIC BOOL ixEthDBVlanRecordMatch(void *untypedReference, void *untypedEntry)
/* matches two database records based on their MAC addresses and VLAN IDs */ IX_ETH_DB_PUBLIC BOOL ixEthDBVlanRecordMatch(void *untypedReference, void *untypedEntry)
{ MacDescriptor *entry = (MacDescriptor *) untypedEntry; MacDescriptor *reference = (MacDescriptor *) untypedReference; if ((entry->type & reference->type) == 0) return FALSE; return (IX_ETH_DB_GET_VLAN_ID(entry->recordData.filteringVlanData.ieee802_1qTag) == IX_ETH_DB_GET_VLAN_ID(reference->recordData.filteringVlanData.ieee802_1qTag)) && (ixEthDBAddressCompare(entry->macAddress, reference->macAddress) == 0); }
EmcraftSystems/u-boot
C++
Other
181
/* Check if a ack sequence number is a valid syncookie. Return the decoded mss if it is, or 0 if not. */
static int cookie_check(struct sk_buff *skb, __u32 cookie)
/* Check if a ack sequence number is a valid syncookie. Return the decoded mss if it is, or 0 if not. */ static int cookie_check(struct sk_buff *skb, __u32 cookie)
{ const struct iphdr *iph = ip_hdr(skb); const struct tcphdr *th = tcp_hdr(skb); __u32 seq = ntohl(th->seq) - 1; __u32 mssind = check_tcp_syn_cookie(cookie, iph->saddr, iph->daddr, th->source, th->dest, seq, jiffies / (HZ * 60), COUNTER_TRIES); return mssind < NUM_MSS ? msstab[mssind] + 1 : 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* While we find nice hex chars, build an int. Return number of chars processed. */
static int hexToInt(char **ptr, unsigned long *intValue)
/* While we find nice hex chars, build an int. Return number of chars processed. */ static int hexToInt(char **ptr, unsigned long *intValue)
{ int count = 0, ch; *_value = 0; while (**ptr) { ch = hex(**ptr); if (ch < 0) break; *_value = (*_value << 4) | ((uint8_t) ch & 0xf); count++; (*ptr)++; } return count; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Generate a Direct Select Address for the Hypervisor */
static u64 iseries_ds_addr(struct device_node *node)
/* Generate a Direct Select Address for the Hypervisor */ static u64 iseries_ds_addr(struct device_node *node)
{ struct pci_dn *pdn = PCI_DN(node); const u32 *sbp = of_get_property(node, "linux,subbus", NULL); return ((u64)pdn->busno << 48) + ((u64)(sbp ? *sbp : 0) << 40) + ((u64)0x10 << 32); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Panic handlers; these get called when an unhandled exception occurs or the assembly-level task switching / interrupt code runs into an unrecoverable error. The default task stack overflow handler and abort handler are also in here. Note: The linker script will put everything in this file in IRAM/DRAM, so it also works with flash cache disabled. */
static void panicPutChar(char c)
/* Panic handlers; these get called when an unhandled exception occurs or the assembly-level task switching / interrupt code runs into an unrecoverable error. The default task stack overflow handler and abort handler are also in here. Note: The linker script will put everything in this file in IRAM/DRAM, so it also works with flash cache disabled. */ static void panicPutChar(char c)
{ while (((READ_PERI_REG(UART_STATUS_REG(CONFIG_CONSOLE_UART_NUM)) >> UART_TXFIFO_CNT_S)&UART_TXFIFO_CNT) >= 126) ; WRITE_PERI_REG(UART_FIFO_REG(CONFIG_CONSOLE_UART_NUM), c); }
retro-esp32/RetroESP32
C++
Creative Commons Attribution Share Alike 4.0 International
581
/* "instructions" read/write data in "one-shot" or "software-triggered" mode. */
static int skel_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
/* "instructions" read/write data in "one-shot" or "software-triggered" mode. */ static int skel_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{ int n, i; unsigned int d; unsigned int status; for (n = 0; n < insn->n; n++) { #define TIMEOUT 100 for (i = 0; i < TIMEOUT; i++) { status = 1; if (status) break; } if (i == TIMEOUT) { printk("timeout\n"); return -ETIMEDOUT; } d = 0; d ^= 1 << (thisboard->ai_bits - 1); data[n] = d; } return n; }
robutest/uclinux
C++
GPL-2.0
60
/* Prompts and stores a single calibration point on the display. Prompts the user for a single calibration point on the display at the nominated coordinates, and saves the resulting raw touch point. */
static void touch_interface_get_calibration_point(rtouch_calibration_point_t *point)
/* Prompts and stores a single calibration point on the display. Prompts the user for a single calibration point on the display at the nominated coordinates, and saves the resulting raw touch point. */ static void touch_interface_get_calibration_point(rtouch_calibration_point_t *point)
{ rtouch_event_t event; gfx_draw_circle( point->panelX, point->panelY, 4, GFX_COLOR_BLUE, GFX_WHOLE); touch_interface_wait_touch(); rtouch_get_event(&event); point->rawX = event.rawX; point->rawY = event.rawY; gfx_draw_filled_circle( point->panelX, point->panelY, 4, GFX_COLOR_BLUE, GFX_WHOLE); }
memfault/zero-to-main
C++
null
200
/* This function handles DMA2 Stream 3 interrupt request. */
void DMA2_Stream3_IRQHandler(void)
/* This function handles DMA2 Stream 3 interrupt request. */ void DMA2_Stream3_IRQHandler(void)
{ BSP_SD_DMA_Rx_IRQHandler(); }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* This function handles external lines 15 to 10 interrupt request. */
void EXTI15_10_IRQHandler(void)
/* This function handles external lines 15 to 10 interrupt request. */ void EXTI15_10_IRQHandler(void)
{ HAL_GPIO_EXTI_IRQHandler(TAMPER_BUTTON_PIN); }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* dock_remove - free up resources related to the dock station */
static int dock_remove(struct dock_station *ds)
/* dock_remove - free up resources related to the dock station */ static int dock_remove(struct dock_station *ds)
{ struct dock_dependent_device *dd, *tmp; struct platform_device *dock_device = ds->dock_device; if (!dock_station_count) return 0; list_for_each_entry_safe(dd, tmp, &ds->dependent_devices, list) kfree(dd); list_del(&ds->sibling); sysfs_remove_group(&dock_device->dev.kobj, &dock_attribute_group); platform_device_unregister(dock_device); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Uninitialise the AqmIf module by unmapping memory, etc */
void ixQMgrAqmIfUninit(void)
/* Uninitialise the AqmIf module by unmapping memory, etc */ void ixQMgrAqmIfUninit(void)
{ UINT32 virtAddr; ixQMgrAqmIfBaseAddressGet (&virtAddr); IX_OSAL_MEM_UNMAP (virtAddr); ixQMgrAqmIfBaseAddressSet (0); }
EmcraftSystems/u-boot
C++
Other
181
/* The code below (invoked as a consequence of a "row-deleted" signal) rebuilds prefs.col_list by iterating over the (re-ordered) tree model. */
static void column_dnd_row_deleted_cb(GtkTreeModel *model, GtkTreePath *path _U_, gpointer data _U_)
/* The code below (invoked as a consequence of a "row-deleted" signal) rebuilds prefs.col_list by iterating over the (re-ordered) tree model. */ static void column_dnd_row_deleted_cb(GtkTreeModel *model, GtkTreePath *path _U_, gpointer data _U_)
{ gtk_tree_model_get(model, &iter, DATA_COLUMN, &clp, -1); if (clp) { prefs.col_list = g_list_remove_link(prefs.col_list, clp); new_col_list = g_list_concat(new_col_list, clp); } } if (prefs.col_list) { g_warning("column_dnd_row_deleted_cb: prefs.col_list has %d leftover data", g_list_length(prefs.col_list)); g_list_free(prefs.col_list); } prefs.col_list = new_col_list; cfile.columns_changed = TRUE; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* This is an internal worker function to get the Component Name (2) protocol interface and the language it supports. */
EFI_STATUS DriverHealthManagerGetComponentNameWorker(IN EFI_GUID *ProtocolGuid, IN EFI_HANDLE DriverBindingHandle, OUT EFI_COMPONENT_NAME_PROTOCOL **ComponentName, OUT CHAR8 **SupportedLanguage)
/* This is an internal worker function to get the Component Name (2) protocol interface and the language it supports. */ EFI_STATUS DriverHealthManagerGetComponentNameWorker(IN EFI_GUID *ProtocolGuid, IN EFI_HANDLE DriverBindingHandle, OUT EFI_COMPONENT_NAME_PROTOCOL **ComponentName, OUT CHAR8 **SupportedLanguage)
{ EFI_STATUS Status; Status = gBS->OpenProtocol ( DriverBindingHandle, ProtocolGuid, (VOID **)ComponentName, NULL, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL ); if (EFI_ERROR (Status)) { return Status; } *SupportedLanguage = DriverHealthManagerSelectBestLanguage ( (*ComponentName)->SupportedLanguages, (BOOLEAN)(ProtocolGuid == &gEfiComponentNameProtocolGuid) ); if (*SupportedLanguage == NULL) { Status = EFI_UNSUPPORTED; } return Status; }
tianocore/edk2
C++
Other
4,240
/* Description: Called when the NetLabel state of a sk_security_struct needs to be reset. The caller is responsibile for all the NetLabel sk_security_struct locking. */
void selinux_netlbl_sk_security_reset(struct sk_security_struct *ssec)
/* Description: Called when the NetLabel state of a sk_security_struct needs to be reset. The caller is responsibile for all the NetLabel sk_security_struct locking. */ void selinux_netlbl_sk_security_reset(struct sk_security_struct *ssec)
{ ssec->nlbl_state = NLBL_UNSET; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Return unit size power of 2 given number of bytes to transfer. */
static uint32_t qlen_shift(uint32_t len)
/* Return unit size power of 2 given number of bytes to transfer. */ static uint32_t qlen_shift(uint32_t len)
{ uint32_t ushift; if ((len & 0x0F) == 0) { ushift = 4; } else if ((len & 0x03) == 0) { ushift = 2; } else { ushift = 0; } return ushift; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* param base SAI base pointer. param handle SAI eDMA handle pointer. */
void SAI_TransferTerminateSendEDMA(I2S_Type *base, sai_edma_handle_t *handle)
/* param base SAI base pointer. param handle SAI eDMA handle pointer. */ void SAI_TransferTerminateSendEDMA(I2S_Type *base, sai_edma_handle_t *handle)
{ assert(handle); SAI_TransferAbortSendEDMA(base, handle); memset(handle->tcd, 0U, sizeof(handle->tcd)); memset(handle->saiQueue, 0U, sizeof(handle->saiQueue)); memset(handle->transferSize, 0U, sizeof(handle->transferSize)); handle->queueUser = 0U; handle->queueDriver = 0U; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* One notified function to stop UNDI device when gBS->ExitBootServices() called. */
VOID EFIAPI SnpNotifyExitBootServices(EFI_EVENT Event, VOID *Context)
/* One notified function to stop UNDI device when gBS->ExitBootServices() called. */ VOID EFIAPI SnpNotifyExitBootServices(EFI_EVENT Event, VOID *Context)
{ SNP_DRIVER *Snp; Snp = (SNP_DRIVER *)Context; PxeShutdown (Snp); PxeStop (Snp); }
tianocore/edk2
C++
Other
4,240
/* IRQ Handler when the watchdog times out. Any actions that you wish to take when a timeout occurs should be called from here. */
void WDT_IRQHandler(void)
/* IRQ Handler when the watchdog times out. Any actions that you wish to take when a timeout occurs should be called from here. */ void WDT_IRQHandler(void)
{ WDT_WDMOD &= ~WDT_WDMOD_WDTOF; wdt_counter++; }
microbuilder/LPC1343CodeBase
C++
Other
73
/* Print the hexical WORD raw index data to instruction content. */
UINTN EdbPrintRawIndexData16(IN UINT16 Data16)
/* Print the hexical WORD raw index data to instruction content. */ UINTN EdbPrintRawIndexData16(IN UINT16 Data16)
{ BOOLEAN Sign; UINTN NaturalUnits; UINTN ConstantUnits; UINTN Offset; Sign = EdbGetNaturalIndex16 (Data16, &NaturalUnits, &ConstantUnits); Offset = EdbPrintIndexData (Sign, NaturalUnits, ConstantUnits); return Offset; }
tianocore/edk2
C++
Other
4,240
/* Message: RegisterAvailableLinesMessage Opcode: 0x002d Type: RegistrationAndManagement Direction: dev2pbx VarLength: no */
static void handle_RegisterAvailableLinesMessage(ptvcursor_t *cursor, packet_info *pinfo _U_)
/* Message: RegisterAvailableLinesMessage Opcode: 0x002d Type: RegistrationAndManagement Direction: dev2pbx VarLength: no */ static void handle_RegisterAvailableLinesMessage(ptvcursor_t *cursor, packet_info *pinfo _U_)
{ ptvcursor_add(cursor, hf_skinny_maxNumOfAvailLines, 4, ENC_LITTLE_ENDIAN); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Configure the selected source to generate a global interrupt or not. */
int32_t MFXSTM32L152_TS_ITStatus(MFXSTM32L152_Object_t *pObj)
/* Configure the selected source to generate a global interrupt or not. */ int32_t MFXSTM32L152_TS_ITStatus(MFXSTM32L152_Object_t *pObj)
{ return (MFXSTM32L152_GlobalITStatus(pObj, MFXSTM32L152_IRQ_TS)); }
eclipse-threadx/getting-started
C++
Other
310
/* Returns allocated request address, NULL on allocation error */
struct usb_request* cdns3_gadget_ep_alloc_request(struct usb_ep *ep, gfp_t gfp_flags)
/* Returns allocated request address, NULL on allocation error */ struct usb_request* cdns3_gadget_ep_alloc_request(struct usb_ep *ep, gfp_t gfp_flags)
{ struct cdns3_endpoint *priv_ep = ep_to_cdns3_ep(ep); struct cdns3_request *priv_req; priv_req = kzalloc(sizeof(*priv_req), gfp_flags); if (!priv_req) return NULL; priv_req->priv_ep = priv_ep; trace_cdns3_alloc_request(priv_req); return &priv_req->request; }
4ms/stm32mp1-baremetal
C++
Other
137
/* note that a page has finished being written to the cache */
static void fscache_end_page_write(struct fscache_object *object, struct page *page)
/* note that a page has finished being written to the cache */ static void fscache_end_page_write(struct fscache_object *object, struct page *page)
{ struct fscache_cookie *cookie; struct page *xpage = NULL; spin_lock(&object->lock); cookie = object->cookie; if (cookie) { spin_lock(&cookie->stores_lock); radix_tree_tag_clear(&cookie->stores, page->index, FSCACHE_COOKIE_STORING_TAG); if (!radix_tree_tag_get(&cookie->stores, page->index, FSCACHE_COOKIE_PENDING_TAG)) { fscache_stat(&fscache_n_store_radix_deletes); xpage = radix_tree_delete(&cookie->stores, page->index); } spin_unlock(&cookie->stores_lock); wake_up_bit(&cookie->flags, 0); } spin_unlock(&object->lock); if (xpage) page_cache_release(xpage); }
robutest/uclinux
C++
GPL-2.0
60
/* RTC MSP Initialization This function configures the hardware resources used in this example. */
void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc)
/* RTC MSP Initialization This function configures the hardware resources used in this example. */ void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc)
{ RCC_PeriphCLKInitTypeDef PeriphClkInit = {0}; if(hrtc->Instance==RTC) { PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_RTC; PeriphClkInit.RTCClockSelection = RCC_RTCCLKSOURCE_LSE; if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) { Error_Handler(); } __HAL_RCC_RTC_ENABLE(); __HAL_RCC_RTCAPB_CLK_ENABLE(); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Clears or safeguards the OCREF1 signal on an external event. */
void TIM_ClearOC1Ref(TIM_TypeDef *TIMx, uint16_t TIM_OCClear)
/* Clears or safeguards the OCREF1 signal on an external event. */ void TIM_ClearOC1Ref(TIM_TypeDef *TIMx, uint16_t TIM_OCClear)
{ uint16_t tmpccmr1 = 0; assert_param(IS_TIM_LIST4_PERIPH(TIMx)); assert_param(IS_TIM_OCCLEAR_STATE(TIM_OCClear)); tmpccmr1 = TIMx->CCMR1; tmpccmr1 &= (uint16_t)~((uint16_t)TIM_CCMR1_OC1CE); tmpccmr1 |= TIM_OCClear; TIMx->CCMR1 = tmpccmr1; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* ADC Disable Deep-Power-Down Mdoe. Deep-power-down mode allows additional power saving by internally switching off to reduce leakage currents. */
void adc_disable_deeppwd(uint32_t adc)
/* ADC Disable Deep-Power-Down Mdoe. Deep-power-down mode allows additional power saving by internally switching off to reduce leakage currents. */ void adc_disable_deeppwd(uint32_t adc)
{ ADC_CR(adc) &= ~ADC_CR_DEEPPWD; }
libopencm3/libopencm3
C++
GNU General Public License v3.0
2,931
/* Updates ip_vs_seq if pkt has been resized Assumes already checked proto==IPPROTO_TCP and diff!=0. */
static void vs_seq_update(struct ip_vs_conn *cp, struct ip_vs_seq *vseq, unsigned flag, __u32 seq, int diff)
/* Updates ip_vs_seq if pkt has been resized Assumes already checked proto==IPPROTO_TCP and diff!=0. */ static void vs_seq_update(struct ip_vs_conn *cp, struct ip_vs_seq *vseq, unsigned flag, __u32 seq, int diff)
{ spin_lock(&cp->lock); if (!(cp->flags & flag) || after(seq, vseq->init_seq)) { vseq->previous_delta = vseq->delta; vseq->delta += diff; vseq->init_seq = seq; cp->flags |= flag; } spin_unlock(&cp->lock); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* If StartBit is greater than 31, then ASSERT(). If EndBit is greater than 31, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). */
UINT8 EFIAPI BitFieldCountOnes32(IN UINT32 Operand, IN UINTN StartBit, IN UINTN EndBit)
/* If StartBit is greater than 31, then ASSERT(). If EndBit is greater than 31, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). */ UINT8 EFIAPI BitFieldCountOnes32(IN UINT32 Operand, IN UINTN StartBit, IN UINTN EndBit)
{ UINT32 Count; ASSERT (EndBit < 32); ASSERT (StartBit <= EndBit); Count = BitFieldRead32 (Operand, StartBit, EndBit); Count -= ((Count >> 1) & 0x55555555); Count = (Count & 0x33333333) + ((Count >> 2) & 0x33333333); Count += Count >> 4; Count &= 0x0F0F0F0F; Count += Count >> 8; Count += Count >> 16; return (UINT8)Count & 0x3F; }
tianocore/edk2
C++
Other
4,240
/* AmlCodeGenNameResourceTemplate ("PRS0", ParentNode, NewObjectNode) is equivalent of the following ASL code: Name(PRS0, ResourceTemplate () {}) */
EFI_STATUS EFIAPI AmlCodeGenNameResourceTemplate(IN CONST CHAR8 *NameString, IN AML_NODE_HEADER *ParentNode, OPTIONAL OUT AML_OBJECT_NODE **NewObjectNode OPTIONAL)
/* AmlCodeGenNameResourceTemplate ("PRS0", ParentNode, NewObjectNode) is equivalent of the following ASL code: Name(PRS0, ResourceTemplate () {}) */ EFI_STATUS EFIAPI AmlCodeGenNameResourceTemplate(IN CONST CHAR8 *NameString, IN AML_NODE_HEADER *ParentNode, OPTIONAL OUT AML_OBJECT_NODE **NewObjectNode OPTIONAL)
{ EFI_STATUS Status; AML_OBJECT_NODE *ResourceTemplateNode; if ((NameString == NULL) || ((ParentNode == NULL) && (NewObjectNode == NULL))) { ASSERT (0); return EFI_INVALID_PARAMETER; } Status = AmlCodeGenResourceTemplate (&ResourceTemplateNode); if (EFI_ERROR (Status)) { ASSERT (0); return Status; } Status = AmlCodeGenName ( NameString, ResourceTemplateNode, ParentNode, NewObjectNode ); if (EFI_ERROR (Status)) { ASSERT (0); AmlDeleteTree ((AML_NODE_HEADER *)ResourceTemplateNode); } return Status; }
tianocore/edk2
C++
Other
4,240
/* Put one packet in an application-supplied AVPacket struct. Returns 0 on success or -1 on failure. */
static int matroska_deliver_packet(MatroskaDemuxContext *matroska, AVPacket *pkt)
/* Put one packet in an application-supplied AVPacket struct. Returns 0 on success or -1 on failure. */ static int matroska_deliver_packet(MatroskaDemuxContext *matroska, AVPacket *pkt)
{ if (matroska->num_packets > 0) { memcpy(pkt, matroska->packets[0], sizeof(AVPacket)); av_free(matroska->packets[0]); if (matroska->num_packets > 1) { memmove(&matroska->packets[0], &matroska->packets[1], (matroska->num_packets - 1) * sizeof(AVPacket *)); matroska->packets = av_realloc(matroska->packets, (matroska->num_packets - 1) * sizeof(AVPacket *)); } else { av_freep(&matroska->packets); } matroska->num_packets--; return 0; } return -1; }
DC-SWAT/DreamShell
C++
null
404
/* Compresses data to the result buffer The result size must be at least half of the input buffer. The number of samples also must be even! */
int l1oip_law_to_4bit(u8 *data, int len, u8 *result, u32 *state)
/* Compresses data to the result buffer The result size must be at least half of the input buffer. The number of samples also must be even! */ int l1oip_law_to_4bit(u8 *data, int len, u8 *result, u32 *state)
{ int ii, i = 0, o = 0; if (!len) return 0; if (*state) { *result++ = table_com[(((*state)<<8)&0xff00) | (*data++)]; len--; o++; } ii = len >> 1; while (i < ii) { *result++ = table_com[(data[0]<<8) | (data[1])]; data += 2; i++; o++; } if (len & 1) *state = 0x100 + *data; else *state = 0; return o; }
robutest/uclinux
C++
GPL-2.0
60
/* Read consecutive bytes of data from the SL811H/SL11H buffer */
static void sl811_read_buf(__u8 offset, __u8 *buf, __u8 size)
/* Read consecutive bytes of data from the SL811H/SL11H buffer */ static void sl811_read_buf(__u8 offset, __u8 *buf, __u8 size)
{ *(volatile unsigned char *) (SL811_ADR) = offset; EIEIO; while (size--) { *buf++ = *(volatile unsigned char *) (SL811_DAT); EIEIO; } }
EmcraftSystems/u-boot
C++
Other
181
/* This function handles External line 0 interrupt request. */
void EXTI15_10_IRQHandler(void)
/* This function handles External line 0 interrupt request. */ void EXTI15_10_IRQHandler(void)
{ HAL_GPIO_EXTI_IRQHandler(KEY_BUTTON_PIN); }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* Returns: 0 on success / -ENXIO if device does not exist */
static int ibmvfc_target_alloc(struct scsi_target *starget)
/* Returns: 0 on success / -ENXIO if device does not exist */ static int ibmvfc_target_alloc(struct scsi_target *starget)
{ struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); struct ibmvfc_host *vhost = shost_priv(shost); unsigned long flags = 0; spin_lock_irqsave(shost->host_lock, flags); starget->hostdata = (void *)(unsigned long)vhost->task_set++; spin_unlock_irqrestore(shost->host_lock, flags); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Release a DMA channel from exclusive access, similar to clk_put(). */
int stm32_dma_ch_put(int ch)
/* Release a DMA channel from exclusive access, similar to clk_put(). */ int stm32_dma_ch_put(int ch)
{ unsigned long fl; int rv; if (!stm32_dma_ch_valid(ch)) { rv = -EINVAL; goto out; } spin_lock_irqsave(&dma_ch[ch].lock, fl); rv = dma_ch[ch].in_use ? 0 : -EBUSY; dma_ch[ch].in_use = 0; spin_unlock_irqrestore(&dma_ch[ch].lock, fl); out: return rv; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Puts a data element into the SSI transmit FIFO. */
void SSIDataPut(unsigned long ulBase, unsigned long ulData)
/* Puts a data element into the SSI transmit FIFO. */ void SSIDataPut(unsigned long ulBase, unsigned long ulData)
{ ASSERT(SSIBaseValid(ulBase)); ASSERT((ulData & (0xfffffffe << (HWREG(ulBase + SSI_O_CR0) & SSI_CR0_DSS_M))) == 0); while(!(HWREG(ulBase + SSI_O_SR) & SSI_SR_TNF)) { } HWREG(ulBase + SSI_O_DR) = ulData; }
feaser/openblt
C++
GNU General Public License v3.0
601
/* This routine is called when a Restart Request is needed */
static void x25_transmit_restart_request(struct x25_neigh *nb)
/* This routine is called when a Restart Request is needed */ static void x25_transmit_restart_request(struct x25_neigh *nb)
{ unsigned char *dptr; int len = X25_MAX_L2_LEN + X25_STD_MIN_LEN + 2; struct sk_buff *skb = alloc_skb(len, GFP_ATOMIC); if (!skb) return; skb_reserve(skb, X25_MAX_L2_LEN); dptr = skb_put(skb, X25_STD_MIN_LEN + 2); *dptr++ = nb->extended ? X25_GFI_EXTSEQ : X25_GFI_STDSEQ; *dptr++ = 0x00; *dptr++ = X25_RESTART_REQUEST; *dptr++ = 0x00; *dptr++ = 0; skb->sk = NULL; x25_send_frame(skb, nb); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* load header - check the image header and copy data from it */
static int load_header(struct swsusp_info *info)
/* load header - check the image header and copy data from it */ static int load_header(struct swsusp_info *info)
{ int error; restore_pblist = NULL; error = check_header(info); if (!error) { nr_copy_pages = info->image_pages; nr_meta_pages = info->pages - info->image_pages - 1; } return error; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* There are several kind of iommu algorithm(tlb, pagetable) among omap series. This interface installs such an iommu algorighm. */
int install_iommu_arch(const struct iommu_functions *ops)
/* There are several kind of iommu algorithm(tlb, pagetable) among omap series. This interface installs such an iommu algorighm. */ int install_iommu_arch(const struct iommu_functions *ops)
{ if (arch_iommu) return -EBUSY; arch_iommu = ops; return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Change Logs: Date Author Notes liukang the first version */
static void test_thread(void)
/* Change Logs: Date Author Notes liukang the first version */ static void test_thread(void)
{ int count = 0; auto func = [&]() mutable { for (int i = 0; i < 100; ++i) { ++count; } }; std::thread t1(func); t1.join(); if (count != 100) { uassert_false(1); } std::thread t2(func); t2.join(); if (count != 200) { uassert_false(1); } uassert_true(1); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Obtains a bitmask of the resources for which an key algorithm is available. */
LIBOPENBLT_EXPORT uint32_t XCP_GetAvailablePrivileges(uint8_t *resourcePtr)
/* Obtains a bitmask of the resources for which an key algorithm is available. */ LIBOPENBLT_EXPORT uint32_t XCP_GetAvailablePrivileges(uint8_t *resourcePtr)
{ uint32_t result = XCP_RESULT_ERROR; assert(resourcePtr != NULL); if (resourcePtr != NULL) { *resourcePtr = XCP_RESOURCE_PGM; result = XCP_RESULT_OK; } return result; }
feaser/openblt
C++
GNU General Public License v3.0
601
/* If it is a relative filename, we search the full search path for it. */
static char* fopen_any_on_path(const char *fname, FILE **fp)
/* If it is a relative filename, we search the full search path for it. */ static char* fopen_any_on_path(const char *fname, FILE **fp)
{ const char *cur_dir = NULL; struct search_path *node; char *fullname; assert(fp); if (current_srcfile) cur_dir = current_srcfile->dir; fullname = try_open(cur_dir, fname, fp); for (node = search_path_head; !*fp && node; node = node->next) fullname = try_open(node->dirname, fname, fp); return fullname; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Change Logs: Date Author Notes Bernard first version */
static void fdszero(fd_set *set, int nfds)
/* Change Logs: Date Author Notes Bernard first version */ static void fdszero(fd_set *set, int nfds)
{ fd_mask *m; int n; m = (fd_mask *)set; for (n = 0; n < nfds; n += (sizeof(fd_mask) * 8)) { rt_memset(m, 0, sizeof(fd_mask)); m ++; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Returns: number of bytes read in, or -1 on error, or 0 on end of file. */
gssize g_input_stream_read_finish(GInputStream *stream, GAsyncResult *result, GError **error)
/* Returns: number of bytes read in, or -1 on error, or 0 on end of file. */ gssize g_input_stream_read_finish(GInputStream *stream, GAsyncResult *result, GError **error)
{ GInputStreamClass *class; g_return_val_if_fail (G_IS_INPUT_STREAM (stream), -1); g_return_val_if_fail (G_IS_ASYNC_RESULT (result), -1); if (g_async_result_legacy_propagate_error (result, error)) return -1; else if (g_async_result_is_tagged (result, g_input_stream_read_async)) return g_task_propagate_int (G_TASK (result), error); class = G_INPUT_STREAM_GET_CLASS (stream); return class->read_finish (stream, result, error); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* This function converts an input device structure to a Unicode string. */
CHAR16* EFIAPI DevicePathToStr(IN EFI_DEVICE_PATH_PROTOCOL *DevPath)
/* This function converts an input device structure to a Unicode string. */ CHAR16* EFIAPI DevicePathToStr(IN EFI_DEVICE_PATH_PROTOCOL *DevPath)
{ return ConvertDevicePathToText ( DevPath, FALSE, TRUE ); }
tianocore/edk2
C++
Other
4,240
/* This function should be called after each update to the EEPROM structure, to make sure the CRC is always correct. */
static void update_crc(void)
/* This function should be called after each update to the EEPROM structure, to make sure the CRC is always correct. */ static void update_crc(void)
{ u32 crc, crc_offset = offsetof(struct eeprom, crc); crc = crc32(0, (void *)&e, crc_offset); e.crc = cpu_to_be32(crc); }
4ms/stm32mp1-baremetal
C++
Other
137
/* Check the busy status of the specified SPI port. */
xtBoolean SPIIsBusy(unsigned long ulBase)
/* Check the busy status of the specified SPI port. */ xtBoolean SPIIsBusy(unsigned long ulBase)
{ xASSERT((ulBase == SPI3_BASE) || (ulBase == SPI1_BASE)|| (ulBase == SPI2_BASE)); return ((xHWREG(ulBase + SPI_SR) & SPI_SR_BSY) ? xtrue : xfalse); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Set the boot bank to the default bank */
void cpld_set_altbank(void)
/* Set the boot bank to the default bank */ void cpld_set_altbank(void)
{ CPLD_WRITE(system_rst_default, 1); }
4ms/stm32mp1-baremetal
C++
Other
137
/* Description: This function frees the memory associated with a cache entry including the LSM cache data if there are no longer any users, i.e. reference count == 0. */
static void cipso_v4_cache_entry_free(struct cipso_v4_map_cache_entry *entry)
/* Description: This function frees the memory associated with a cache entry including the LSM cache data if there are no longer any users, i.e. reference count == 0. */ static void cipso_v4_cache_entry_free(struct cipso_v4_map_cache_entry *entry)
{ if (entry->lsm_data) netlbl_secattr_cache_free(entry->lsm_data); kfree(entry->key); kfree(entry); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Sets the size in pixels of a frame (height * width * bpp). */
void LCD_SetFrameSize(unsigned int frameSize)
/* Sets the size in pixels of a frame (height * width * bpp). */ void LCD_SetFrameSize(unsigned int frameSize)
{ ASSERT((frameSize & 0xFF800000) == 0, "LCD_SetFrameSize: Wrong frameSize value.\n\r"); AT91C_BASE_LCDC->LCDC_FRMCFG = frameSize | (AT91C_BASE_LCDC->LCDC_FRMCFG & 0xFF000000); }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* do_s2io_chk_alarm_bit - Check for alarm and incrment the counter @value: alarm bits @addr: address value @cnt: counter variable Description: Check for alarm and increment the counter Return Value: 1 - if alarm bit set 0 - if alarm bit is not set */
static int do_s2io_chk_alarm_bit(u64 value, void __iomem *addr, unsigned long long *cnt)
/* do_s2io_chk_alarm_bit - Check for alarm and incrment the counter @value: alarm bits @addr: address value @cnt: counter variable Description: Check for alarm and increment the counter Return Value: 1 - if alarm bit set 0 - if alarm bit is not set */ static int do_s2io_chk_alarm_bit(u64 value, void __iomem *addr, unsigned long long *cnt)
{ u64 val64; val64 = readq(addr); if (val64 & value) { writeq(val64, addr); (*cnt)++; return 1; } return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Allocates the number of 4KB pages of a certain memory type and returns a pointer to the allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL is returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. */
VOID* InternalAllocatePages(IN EFI_MEMORY_TYPE MemoryType, IN UINTN Pages)
/* Allocates the number of 4KB pages of a certain memory type and returns a pointer to the allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL is returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. */ VOID* InternalAllocatePages(IN EFI_MEMORY_TYPE MemoryType, IN UINTN Pages)
{ EFI_STATUS Status; EFI_PHYSICAL_ADDRESS Memory; if (Pages == 0) { return NULL; } Status = gMmst->MmAllocatePages (AllocateAnyPages, MemoryType, Pages, &Memory); if (EFI_ERROR (Status)) { return NULL; } return (VOID *)(UINTN)Memory; }
tianocore/edk2
C++
Other
4,240
/* If a user requests an allocation which is small enough, we may simply use the space in the flex_array->parts array to store the user data. */
static int elements_fit_in_base(struct flex_array *fa)
/* If a user requests an allocation which is small enough, we may simply use the space in the flex_array->parts array to store the user data. */ static int elements_fit_in_base(struct flex_array *fa)
{ int data_size = fa->element_size * fa->total_nr_elements; if (data_size <= FLEX_ARRAY_BASE_BYTES_LEFT) return 1; return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* USB Device Remote Wakeup Function Called automatically on USB Device Remote Wakeup Return Value: None */
void USBD_WakeUp(void)
/* USB Device Remote Wakeup Function Called automatically on USB Device Remote Wakeup Return Value: None */ void USBD_WakeUp(void)
{ CNTR &= ~CNTR_FSUSP; }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* If this interface is not supported, then return FALSE. */
BOOLEAN EFIAPI Sha1HashAll(IN CONST VOID *Data, IN UINTN DataSize, OUT UINT8 *HashValue)
/* If this interface is not supported, then return FALSE. */ BOOLEAN EFIAPI Sha1HashAll(IN CONST VOID *Data, IN UINTN DataSize, OUT UINT8 *HashValue)
{ CALL_CRYPTO_SERVICE (Sha1HashAll, (Data, DataSize, HashValue), FALSE); }
tianocore/edk2
C++
Other
4,240
/* This file is part of the Simba project. */
int mock_write_upgrade_uds_init(void *chin_p, void *chout_p, int res)
/* This file is part of the Simba project. */ int mock_write_upgrade_uds_init(void *chin_p, void *chout_p, int res)
{ harness_mock_write("upgrade_uds_init(chin_p)", chin_p, sizeof(chin_p)); harness_mock_write("upgrade_uds_init(chout_p)", chout_p, sizeof(chout_p)); harness_mock_write("upgrade_uds_init(): return (res)", &res, sizeof(res)); return (0); }
eerimoq/simba
C++
Other
337
/* mpt_halt_firmware - Halts the firmware if it is operational and panic the kernel @ioc: Pointer to MPT_ADAPTER structure */
void mpt_halt_firmware(MPT_ADAPTER *ioc)
/* mpt_halt_firmware - Halts the firmware if it is operational and panic the kernel @ioc: Pointer to MPT_ADAPTER structure */ void mpt_halt_firmware(MPT_ADAPTER *ioc)
{ u32 ioc_raw_state; ioc_raw_state = mpt_GetIocState(ioc, 0); if ((ioc_raw_state & MPI_IOC_STATE_MASK) == MPI_IOC_STATE_FAULT) { printk(MYIOC_s_ERR_FMT "IOC is in FAULT state (%04xh)!!!\n", ioc->name, ioc_raw_state & MPI_DOORBELL_DATA_MASK); panic("%s: IOC Fault (%04xh)!!!\n", ioc->name, ioc_raw_state & MPI_DOORBELL_DATA_MASK); } else { CHIPREG_WRITE32(&ioc->chip->Doorbell, 0xC0FFEE00); panic("%s: Firmware is halted due to command timeout\n", ioc->name); } }
robutest/uclinux
C++
GPL-2.0
60