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
/* lapic_get_maxlvt - get the maximum number of local vector table entries */
int lapic_get_maxlvt(void)
/* lapic_get_maxlvt - get the maximum number of local vector table entries */ int lapic_get_maxlvt(void)
{ unsigned int v; v = apic_read(APIC_LVR); return APIC_INTEGRATED(GET_APIC_VERSION(v)) ? GET_APIC_MAXLVT(v) : 2; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Register the Service B.2 and all its Characteristics... */
void service_b_2_1_init(void)
/* Register the Service B.2 and all its Characteristics... */ void service_b_2_1_init(void)
{ bt_gatt_service_register(&service_b_2_1_svc); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Gets the I The default configuration is as follows: */
void i2c_slave_get_config_defaults(struct i2c_slave_config *const config)
/* Gets the I The default configuration is as follows: */ void i2c_slave_get_config_defaults(struct i2c_slave_config *const config)
{ Assert(config); config->clock_source = I2C_CLK_INPUT_3; config->clock_divider = 0x10; config->pin_number_pad0 = PIN_LP_GPIO_8; config->pin_number_pad1 = PIN_LP_GPIO_9; config->pinmux_sel_pad0 = ((PIN_LP_GPIO_8 << 16) | MUX_LP_GPIO_8_I2C0_SDA); config->pinmux_sel_pad1 = ((PIN_LP_GPIO_9 << 16) | MUX_LP_GPIO_9_I2C0_SCL); }
memfault/zero-to-main
C++
null
200
/* Allocates and initializes one HMAC_CTX context for subsequent HMAC-SHA256 use. */
VOID* EFIAPI CryptoServiceHmacSha256New(VOID)
/* Allocates and initializes one HMAC_CTX context for subsequent HMAC-SHA256 use. */ VOID* EFIAPI CryptoServiceHmacSha256New(VOID)
{ return CALL_BASECRYPTLIB (HmacSha256.Services.New, HmacSha256New, (), NULL); }
tianocore/edk2
C++
Other
4,240
/* Remove the Request element from the Config Request. */
VOID RemoveElement(IN OUT BROWSER_STORAGE *Storage, IN CHAR16 *RequestElement)
/* Remove the Request element from the Config Request. */ VOID RemoveElement(IN OUT BROWSER_STORAGE *Storage, IN CHAR16 *RequestElement)
{ CHAR16 *NewStr; CHAR16 *DestStr; ASSERT (Storage->ConfigRequest != NULL && RequestElement != NULL); NewStr = StrStr (Storage->ConfigRequest, RequestElement); if (NewStr == NULL) { return; } DestStr = NewStr; NewStr += StrLen (RequestElement); CopyMem (DestStr, NewStr, StrSize (NewStr)); Storage->SpareStrLen += StrLen (RequestElement); }
tianocore/edk2
C++
Other
4,240
/* Sets or resets the current global font data. The font data array is organized in follows: = ... where = ... ... where = ... where = */
void gfxPrimitivesSetFont(const void *fontdata, Uint32 cw, Uint32 ch)
/* Sets or resets the current global font data. The font data array is organized in follows: = ... where = ... ... where = ... where = */ void gfxPrimitivesSetFont(const void *fontdata, Uint32 cw, Uint32 ch)
{ int i; if ((fontdata) && (cw) && (ch)) { currentFontdata = fontdata; charWidth = cw; charHeight = ch; } else { currentFontdata = gfxPrimitivesFontdata; charWidth = 8; charHeight = 8; } charPitch = (charWidth+7)/8; charSize = charPitch * charHeight; if ((charRotation==1) || (charRotation==3)) { charWidthLocal = charHeight; charHeightLocal = charWidth; } else { charWidthLocal = charWidth; charHeightLocal = charHeight; } for (i = 0; i < 256; i++) { if (gfxPrimitivesFont[i]) { SDL_FreeSurface(gfxPrimitivesFont[i]); gfxPrimitivesFont[i] = NULL; } } }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Note : separate from irlmp_do_discovery() so that we can handle passive discovery properly. */
void irlmp_do_expiry(void)
/* Note : separate from irlmp_do_discovery() so that we can handle passive discovery properly. */ void irlmp_do_expiry(void)
{ struct lap_cb *lap; lap = (struct lap_cb *) hashbin_get_first(irlmp->links); while (lap != NULL) { IRDA_ASSERT(lap->magic == LMP_LAP_MAGIC, return;); if (lap->lap_state == LAP_STANDBY) { irlmp_expire_discoveries(irlmp->cachelog, lap->saddr, FALSE); } lap = (struct lap_cb *) hashbin_get_next(irlmp->links); } }
EmcraftSystems/linux-emcraft
C++
Other
266
/* updates the Frame Control and Duration/ID WiFi header conversion parameters in an NPE */
IX_ETH_DB_PRIVATE IxEthDBStatus ixEthDBWiFiFrameControlDurationIDUpdate(IxEthDBPortId portID)
/* updates the Frame Control and Duration/ID WiFi header conversion parameters in an NPE */ IX_ETH_DB_PRIVATE IxEthDBStatus ixEthDBWiFiFrameControlDurationIDUpdate(IxEthDBPortId portID)
{ IxNpeMhMessage message; IX_STATUS result; FILL_SETFRAMECONTROLDURATIONID(message, portID, ixEthDBPortInfo[portID].frameControlDurationID); IX_ETHDB_SEND_NPE_MSG(IX_ETH_DB_PORT_ID_TO_NPE(portID), message, result); return result; }
EmcraftSystems/u-boot
C++
Other
181
/* 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: */
static int SDLCALL RemovePendingSizeChangedAndResizedEvents(void *userdata, SDL_Event *event)
/* 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: */ static int SDLCALL RemovePendingSizeChangedAndResizedEvents(void *userdata, SDL_Event *event)
{ SDL_Event *new_event = (SDL_Event *)userdata; if (event->type == SDL_WINDOWEVENT && (event->window.event == SDL_WINDOWEVENT_SIZE_CHANGED || event->window.event == SDL_WINDOWEVENT_RESIZED) && event->window.windowID == new_event->window.windowID) { return 0; } return 1; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Autonomous QTouch Group status change callback function example prototype. Autonomous QTouch status change interrupt callback function. This callback function is called by the Touch library in the CAT Autonomous QTouch status change Interrupt context, each time there is a status change in the Autonomous Touch sensor. */
void touch_at_status_change_interrupt_callback(touch_at_status *p_at_status)
/* Autonomous QTouch Group status change callback function example prototype. Autonomous QTouch status change interrupt callback function. This callback function is called by the Touch library in the CAT Autonomous QTouch status change Interrupt context, each time there is a status change in the Autonomous Touch sensor. */ void touch_at_status_change_interrupt_callback(touch_at_status *p_at_status)
{ if (p_at_status->status_change == IN_TOUCH) { autonomous_qtouch_in_touch = 1u; } else { autonomous_qtouch_in_touch = 0u; } }
remotemcu/remcu-chip-sdks
C++
null
436
/* fc_vport_setlink() - update link and status on a VN_Port @vn_port: virtual port to update */
void fc_vport_setlink(struct fc_lport *vn_port)
/* fc_vport_setlink() - update link and status on a VN_Port @vn_port: virtual port to update */ void fc_vport_setlink(struct fc_lport *vn_port)
{ struct fc_vport *vport = vn_port->vport; struct Scsi_Host *shost = vport_to_shost(vport); struct fc_lport *n_port = shost_priv(shost); mutex_lock(&n_port->lp_mutex); mutex_lock_nested(&vn_port->lp_mutex, LPORT_MUTEX_VN_PORT); __fc_vport_setlink(n_port, vn_port); mutex_unlock(&vn_port->lp_mutex); mutex_unlock(&n_port->lp_mutex); }
robutest/uclinux
C++
GPL-2.0
60
/* Unregister a notifier previously registered by register_neigh_notifier(). The notifier is unlinked into the kernel structures and may then be reused. A negative errno code is returned on a failure. */
int unregister_netevent_notifier(struct notifier_block *nb)
/* Unregister a notifier previously registered by register_neigh_notifier(). The notifier is unlinked into the kernel structures and may then be reused. A negative errno code is returned on a failure. */ int unregister_netevent_notifier(struct notifier_block *nb)
{ return atomic_notifier_chain_unregister(&netevent_notif_chain, nb); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Mode setting Command Function: MX25_DP Arguments: None. Description: The DP instruction is for setting the device on the minimizing the power consumption. Return Message: FlashOperationSuccess */
ReturnMsg MX25_DP(void)
/* Mode setting Command Function: MX25_DP Arguments: None. Description: The DP instruction is for setting the device on the minimizing the power consumption. Return Message: FlashOperationSuccess */ ReturnMsg MX25_DP(void)
{ CS_Low(); SendByte( FLASH_CMD_DP, SIO ); CS_High(); return FlashOperationSuccess; }
remotemcu/remcu-chip-sdks
C++
null
436
/* param base USART peripheral base address. param handle USART handle pointer. param callback The callback function. param userData The parameter of the callback function. */
status_t USART_TransferCreateHandle(USART_Type *base, usart_handle_t *handle, usart_transfer_callback_t callback, void *userData)
/* param base USART peripheral base address. param handle USART handle pointer. param callback The callback function. param userData The parameter of the callback function. */ status_t USART_TransferCreateHandle(USART_Type *base, usart_handle_t *handle, usart_transfer_callback_t callback, void *userData)
{ assert(!((NULL == base) || (NULL == handle))); uint32_t instance = 0; usart_to_flexcomm_t handler; handler.usart_master_handler = USART_TransferHandleIRQ; if ((NULL == base) || (NULL == handle)) { return kStatus_InvalidArgument; } instance = USART_GetInstance(base); (void)memset(handle, 0, sizeof(*handle)); handle->rxState = (uint8_t)kUSART_RxIdle; handle->txState = (uint8_t)kUSART_TxIdle; handle->callback = callback; handle->userData = userData; handle->rxWatermark = (uint8_t)USART_FIFOTRIG_RXLVL_GET(base); handle->txWatermark = (uint8_t)USART_FIFOTRIG_TXLVL_GET(base); FLEXCOMM_SetIRQHandler(base, handler.flexcomm_handler, handle); (void)EnableIRQ(s_usartIRQ[instance]); return kStatus_Success; }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* Determine if a valid string is a valid number for the 'for' command. */
BOOLEAN ShellIsValidForNumber(IN CONST CHAR16 *Number)
/* Determine if a valid string is a valid number for the 'for' command. */ BOOLEAN ShellIsValidForNumber(IN CONST CHAR16 *Number)
{ if ((Number == NULL) || (*Number == CHAR_NULL)) { return (FALSE); } if (*Number == L'-') { Number++; } if (StrLen (Number) == 0) { return (FALSE); } if (StrLen (Number) >= 7) { if ((StrStr (Number, L" ") == NULL) || (((StrStr (Number, L" ") != NULL) && ((StrStr (Number, L" ") - Number) >= 7)))) { return (FALSE); } } if (!ShellIsDecimalDigitCharacter (*Number)) { return (FALSE); } return (TRUE); }
tianocore/edk2
C++
Other
4,240
/* If the lock is not held, then let the signal proceed as usual. If the lock is held, then set the contended flag and keep the signal blocked. */
static int drm_notifier(void *priv)
/* If the lock is not held, then let the signal proceed as usual. If the lock is held, then set the contended flag and keep the signal blocked. */ static int drm_notifier(void *priv)
{ struct drm_sigdata *s = (struct drm_sigdata *) priv; unsigned int old, new, prev; if (!s->lock || !_DRM_LOCK_IS_HELD(s->lock->lock) || _DRM_LOCKING_CONTEXT(s->lock->lock) != s->context) return 1; do { old = s->lock->lock; new = old | _DRM_LOCK_CONT; prev = cmpxchg(&s->lock->lock, old, new); } while (prev != old); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Flush all the connection entries in the ip_vs_conn_tab */
static void ip_vs_conn_flush(void)
/* Flush all the connection entries in the ip_vs_conn_tab */ static void ip_vs_conn_flush(void)
{ int idx; struct ip_vs_conn *cp; flush_again: for (idx=0; idx<IP_VS_CONN_TAB_SIZE; idx++) { ct_write_lock_bh(idx); list_for_each_entry(cp, &ip_vs_conn_tab[idx], c_list) { IP_VS_DBG(4, "del connection\n"); ip_vs_conn_expire_now(cp); if (cp->control) { IP_VS_DBG(4, "del conn template\n"); ip_vs_conn_expire_now(cp->control); } } ct_write_unlock_bh(idx); } if (atomic_read(&ip_vs_conn_count) != 0) { schedule(); goto flush_again; } }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Traverse a table with weak values and link it to proper list. During propagate phase, keep it in 'grayagain' list, to be revisited in the atomic phase. In the atomic phase, if table has any white value, put it in 'weak' list, to be cleared. */
static void traverseweakvalue(global_State *g, Table *h)
/* Traverse a table with weak values and link it to proper list. During propagate phase, keep it in 'grayagain' list, to be revisited in the atomic phase. In the atomic phase, if table has any white value, put it in 'weak' list, to be cleared. */ static void traverseweakvalue(global_State *g, Table *h)
{ if (isempty(gval(n))) clearkey(n); else { lua_assert(!keyisnil(n)); markkey(g, n); if (!hasclears && iscleared(g, gcvalueN(gval(n)))) hasclears = 1; } } if (g->gcstate == GCSatomic && hasclears) linkgclist(h, g->weak); else linkgclist(h, g->grayagain); }
Nicholas3388/LuaNode
C++
Other
1,055
/* Get message from skb. Each message is processed by audit_receive_msg. Malformed skbs with wrong length are discarded silently. */
static void audit_receive_skb(struct sk_buff *skb)
/* Get message from skb. Each message is processed by audit_receive_msg. Malformed skbs with wrong length are discarded silently. */ static void audit_receive_skb(struct sk_buff *skb)
{ struct nlmsghdr *nlh; int len; int err; nlh = nlmsg_hdr(skb); len = skb->len; while (NLMSG_OK(nlh, len)) { err = audit_receive_msg(skb, nlh); if (err || (nlh->nlmsg_flags & NLM_F_ACK)) netlink_ack(skb, nlh, err); nlh = NLMSG_NEXT(nlh, len); } }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Defaults to returning the channel with the desired capability and the lowest reference count when 'n' cannot be satisfied. Must be called under dma_list_mutex. */
static struct dma_chan* nth_chan(enum dma_transaction_type cap, int n)
/* Defaults to returning the channel with the desired capability and the lowest reference count when 'n' cannot be satisfied. Must be called under dma_list_mutex. */ static struct dma_chan* nth_chan(enum dma_transaction_type cap, int n)
{ struct dma_device *device; struct dma_chan *chan; struct dma_chan *ret = NULL; struct dma_chan *min = NULL; list_for_each_entry(device, &dma_device_list, global_node) { if (!dma_has_cap(cap, device->cap_mask) || dma_has_cap(DMA_PRIVATE, device->cap_mask)) continue; list_for_each_entry(chan, &device->channels, device_node) { if (!chan->client_count) continue; if (!min) min = chan; else if (chan->table_count < min->table_count) min = chan; if (n-- == 0) { ret = chan; break; } } if (ret) break; } if (!ret) ret = min; if (ret) ret->table_count++; return ret; }
robutest/uclinux
C++
GPL-2.0
60
/* Returns an event of type @type otherwise NULL Called with trace_event_read_lock() held. */
struct trace_event* ftrace_find_event(int type)
/* Returns an event of type @type otherwise NULL Called with trace_event_read_lock() held. */ struct trace_event* ftrace_find_event(int type)
{ struct trace_event *event; struct hlist_node *n; unsigned key; key = type & (EVENT_HASHSIZE - 1); hlist_for_each_entry(event, n, &event_hash[key], node) { if (event->type == type) return event; } return NULL; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* User-defined threshold value for xl interrupt event on generator. Data format is the same of output data raw: two’s complement with 1LSb = 1.5mG.. */
int32_t lis2mdl_int_gen_treshold_get(stmdev_ctx_t *ctx, uint8_t *buff)
/* User-defined threshold value for xl interrupt event on generator. Data format is the same of output data raw: two’s complement with 1LSb = 1.5mG.. */ int32_t lis2mdl_int_gen_treshold_get(stmdev_ctx_t *ctx, uint8_t *buff)
{ int32_t ret; ret = lis2mdl_read_reg(ctx, LIS2MDL_INT_THS_L_REG, buff, 2); return ret; }
eclipse-threadx/getting-started
C++
Other
310
/* USB Endpoint 3 Event Callback Called automatically on USB Endpoint 3 Event Parameter: event */
void USB_EndPoint3(uint32_t event)
/* USB Endpoint 3 Event Callback Called automatically on USB Endpoint 3 Event Parameter: event */ void USB_EndPoint3(uint32_t event)
{ case USB_EVT_OUT: CDC_BulkOut (); break; case USB_EVT_IN: CDC_BulkIn (); break; } }
microbuilder/LPC1343CodeBase
C++
Other
73
/* Waits until last write operation on RTC registers has finished. */
void RTC_WaitForLastTask(void)
/* Waits until last write operation on RTC registers has finished. */ void RTC_WaitForLastTask(void)
{ while ((RTC->CRL & RTC_FLAG_RTOFF) == (uint16_t)RESET) { } }
gcallipo/RadioDSP-Stm32f103
C++
Common Creative - Attribution 3.0
51
/* This sets @prtad and @mmds in the MDIO interface if successful. Returns 0 on success, negative on error. */
int mdio45_probe(struct mdio_if_info *mdio, int prtad)
/* This sets @prtad and @mmds in the MDIO interface if successful. Returns 0 on success, negative on error. */ int mdio45_probe(struct mdio_if_info *mdio, int prtad)
{ int mmd, stat2, devs1, devs2; for (mmd = 1; mmd <= 5; mmd++) { stat2 = mdio->mdio_read(mdio->dev, prtad, mmd, MDIO_STAT2); if (stat2 < 0 || (stat2 & MDIO_STAT2_DEVPRST) != MDIO_STAT2_DEVPRST_VAL) continue; devs1 = mdio->mdio_read(mdio->dev, prtad, mmd, MDIO_DEVS1); devs2 = mdio->mdio_read(mdio->dev, prtad, mmd, MDIO_DEVS2); if (devs1 < 0 || devs2 < 0) continue; mdio->prtad = prtad; mdio->mmds = devs1 | (devs2 << 16); return 0; } return -ENODEV; }
robutest/uclinux
C++
GPL-2.0
60
/* ext4_ext_find_extent wrapper. Return 0 on success, or a negative error value on failure. */
static int get_ext_path(struct inode *inode, ext4_lblk_t lblock, struct ext4_ext_path **path)
/* ext4_ext_find_extent wrapper. Return 0 on success, or a negative error value on failure. */ static int get_ext_path(struct inode *inode, ext4_lblk_t lblock, struct ext4_ext_path **path)
{ int ret = 0; *path = ext4_ext_find_extent(inode, lblock, *path); if (IS_ERR(*path)) { ret = PTR_ERR(*path); *path = NULL; } else if ((*path)[ext_depth(inode)].p_ext == NULL) ret = -ENODATA; return ret; }
robutest/uclinux
C++
GPL-2.0
60
/* I2C MSP De-Initialization This function freeze the hardware resources used in this example. */
void HAL_I2C_MspDeInit(I2C_HandleTypeDef *hi2c)
/* I2C MSP De-Initialization This function freeze the hardware resources used in this example. */ void HAL_I2C_MspDeInit(I2C_HandleTypeDef *hi2c)
{ if(hi2c->Instance==I2C1) { __HAL_RCC_I2C1_CLK_DISABLE(); HAL_GPIO_DeInit(GPIOB, GPIO_PIN_6|GPIO_PIN_9); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This API configure the source of interrupt for no motion. */
static int8_t config_no_motion_data_src(const struct bmi160_acc_no_motion_int_cfg *no_mot_int_cfg, const struct bmi160_dev *dev)
/* This API configure the source of interrupt for no motion. */ static int8_t config_no_motion_data_src(const struct bmi160_acc_no_motion_int_cfg *no_mot_int_cfg, const struct bmi160_dev *dev)
{ int8_t rslt; uint8_t data = 0; uint8_t temp = 0; rslt = bmi160_get_regs(BMI160_INT_DATA_1_ADDR, &data, 1, dev); if (rslt == BMI160_OK) { temp = data & ~BMI160_MOTION_SRC_INT_MASK; data = temp | ((no_mot_int_cfg->no_motion_src << 7) & BMI160_MOTION_SRC_INT_MASK); rslt = bmi160_set_regs(BMI160_INT_DATA_1_ADDR, &data, 1, dev); } return rslt; }
eclipse-threadx/getting-started
C++
Other
310
/* dissect_reliable_message_index_base is a utility function which calculates the packets RMIB if and only if the reliable flag is set to 1. */
static int dissect_reliable_message_index_base(tvbuff_t *buffer, int offset, proto_tree *tree)
/* dissect_reliable_message_index_base is a utility function which calculates the packets RMIB if and only if the reliable flag is set to 1. */ static int dissect_reliable_message_index_base(tvbuff_t *buffer, int offset, proto_tree *tree)
{ int byte_count = 2; if(tvb_get_guint8(buffer, offset+1) & 0x80) byte_count = 4; proto_tree_add_item(tree, hf_knet_rmib, buffer, offset, byte_count, ENC_LITTLE_ENDIAN); return byte_count; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Returns: the status of the operation: One of #G_IO_STATUS_NORMAL, #G_IO_STATUS_AGAIN, or #G_IO_STATUS_ERROR. */
GIOStatus g_io_channel_flush(GIOChannel *channel, GError **error)
/* Returns: the status of the operation: One of #G_IO_STATUS_NORMAL, #G_IO_STATUS_AGAIN, or #G_IO_STATUS_ERROR. */ GIOStatus g_io_channel_flush(GIOChannel *channel, GError **error)
{ GIOStatus status; gsize this_time = 1, bytes_written = 0; g_return_val_if_fail (channel != NULL, G_IO_STATUS_ERROR); g_return_val_if_fail ((error == NULL) || (*error == NULL), G_IO_STATUS_ERROR); if (channel->write_buf == NULL || channel->write_buf->len == 0) return G_IO_STATUS_NORMAL; do { g_assert (this_time > 0); status = channel->funcs->io_write (channel, channel->write_buf->str + bytes_written, channel->write_buf->len - bytes_written, &this_time, error); bytes_written += this_time; } while ((bytes_written < channel->write_buf->len) && (status == G_IO_STATUS_NORMAL)); g_string_erase (channel->write_buf, 0, bytes_written); return status; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* NOTE: This routine is just an optimization so it does not guarantee that no dcache entries will exist at process exit time it just makes it very unlikely that any will persist. */
void proc_flush_task(struct task_struct *task)
/* NOTE: This routine is just an optimization so it does not guarantee that no dcache entries will exist at process exit time it just makes it very unlikely that any will persist. */ void proc_flush_task(struct task_struct *task)
{ int i; struct pid *pid, *tgid; struct upid *upid; pid = task_pid(task); tgid = task_tgid(task); for (i = 0; i <= pid->level; i++) { upid = &pid->numbers[i]; proc_flush_task_mnt(upid->ns->proc_mnt, upid->nr, tgid->numbers[i].nr); } upid = &pid->numbers[pid->level]; if (upid->nr == 1) pid_ns_release_proc(upid->ns); }
robutest/uclinux
C++
GPL-2.0
60
/* This has to be called under both b_lock and fetch_lock, because it accesses both b_cnt and b_out. */
static void mon_buff_area_free(struct mon_reader_bin *rp, unsigned int size)
/* This has to be called under both b_lock and fetch_lock, because it accesses both b_cnt and b_out. */ static void mon_buff_area_free(struct mon_reader_bin *rp, unsigned int size)
{ size = (size + PKT_ALIGN-1) & ~(PKT_ALIGN-1); rp->b_cnt -= size; if ((rp->b_out += size) >= rp->b_size) rp->b_out -= rp->b_size; }
robutest/uclinux
C++
GPL-2.0
60
/* Set the clock rate of the specified I2C port. The */
void I2CMasterInit(unsigned long ulBase, unsigned long ulI2CClk)
/* Set the clock rate of the specified I2C port. The */ void I2CMasterInit(unsigned long ulBase, unsigned long ulI2CClk)
{ unsigned long ulHclk; unsigned long ulDiv; xASSERT((ulBase == I2C0_BASE) || (ulBase == I2C1_BASE)); if (ulBase == I2C0_BASE) { SysCtlPeripheralReset(SYSCTL_PERIPH_I2C0); } else { SysCtlPeripheralReset(SYSCTL_PERIPH_I2C1); } xHWREG(ulBase + I2C_O_CON) = I2C_CON_ENS1; ulHclk = SysCtlHClockGet(); ulDiv = (unsigned long) (((ulHclk * 10)/(ulI2CClk * 4) + 5) / 10 - 1); xHWREG(ulBase + I2C_O_CLK) = ulDiv; xHWREG(ulBase + I2C_O_CON) = 0; xHWREG(ulBase + I2C_O_CON) = I2C_CON_ENS1; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Restores the Audio Codec audio interface to its default state. */
static void Codec_AudioInterface_DeInit(void)
/* Restores the Audio Codec audio interface to its default state. */ static void Codec_AudioInterface_DeInit(void)
{ I2S_Cmd(CODEC_I2S, DISABLE); SPI_I2S_DeInit(CODEC_I2S); RCC_APB1PeriphClockCmd(CODEC_I2S_CLK, DISABLE); }
remotemcu/remcu-chip-sdks
C++
null
436
/* The pin(s) are specified using a bit-packed byte, where each bit that is set identifies the pin to be accessed, and where bit 0 of the byte represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on. */
void GPIOPinTypeEthernetLED(unsigned long ulPort, unsigned char ucPins)
/* The pin(s) are specified using a bit-packed byte, where each bit that is set identifies the pin to be accessed, and where bit 0 of the byte represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on. */ void GPIOPinTypeEthernetLED(unsigned long ulPort, unsigned char ucPins)
{ ASSERT(GPIOBaseValid(ulPort)); GPIODirModeSet(ulPort, ucPins, GPIO_DIR_MODE_HW); GPIOPadConfigSet(ulPort, ucPins, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD); }
watterott/WebRadio
C++
null
71
/* Wait for the completion of a page program, erase and random read completion. */
static void wait_ready(void)
/* Wait for the completion of a page program, erase and random read completion. */ static void wait_ready(void)
{ while (gpio_pin_is_low(PIN_NF_RB_IDX)) { } }
remotemcu/remcu-chip-sdks
C++
null
436
/* RETURN: XOR_CHANNEL_IDLE - If the engine is idle. XOR_CHANNEL_ACTIVE - If the engine is busy. XOR_CHANNEL_PAUSED - If the engine is paused. MV_UNDEFINED_STATE - If the engine state is undefind or there is no such engine */
enum mv_state mv_xor_state_get(u32 chan)
/* RETURN: XOR_CHANNEL_IDLE - If the engine is idle. XOR_CHANNEL_ACTIVE - If the engine is busy. XOR_CHANNEL_PAUSED - If the engine is paused. MV_UNDEFINED_STATE - If the engine state is undefind or there is no such engine */ enum mv_state mv_xor_state_get(u32 chan)
{ u32 state; if (chan >= MV_XOR_MAX_CHAN) { DB(printf("%s: ERR. Invalid chan num %d\n", __func__, chan)); return MV_UNDEFINED_STATE; } state = reg_read(XOR_ACTIVATION_REG(XOR_UNIT(chan), XOR_CHAN(chan))); state &= XEXACTR_XESTATUS_MASK; switch (state) { case XEXACTR_XESTATUS_IDLE: return MV_IDLE; case XEXACTR_XESTATUS_ACTIVE: return MV_ACTIVE; case XEXACTR_XESTATUS_PAUSED: return MV_PAUSED; } return MV_UNDEFINED_STATE; }
4ms/stm32mp1-baremetal
C++
Other
137
/* If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned. */
UINTN EFIAPI UnicodeVSPrintAsciiFormat(OUT CHAR16 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR8 *FormatString, IN VA_LIST Marker)
/* If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned. */ UINTN EFIAPI UnicodeVSPrintAsciiFormat(OUT CHAR16 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR8 *FormatString, IN VA_LIST Marker)
{ UINT64 BaseListMarker[256 / sizeof (UINT64)]; BOOLEAN Converted; ASSERT_UNICODE_BUFFER (StartOfBuffer); Converted = DxePrintLibPrint2ProtocolVaListToBaseList ( TRUE, FormatString, Marker, (BASE_LIST)BaseListMarker, sizeof (BaseListMarker) - 8 ); if (!Converted) { return 0; } return UnicodeBSPrintAsciiFormat (StartOfBuffer, BufferSize, FormatString, (BASE_LIST)BaseListMarker); }
tianocore/edk2
C++
Other
4,240
/* ADC Set Resolution. ADC Resolution can be reduced from 12 bits to 10, 8 or 6 bits for a corresponding reduction in conversion time. */
void adc_set_resolution(uint32_t adc, uint16_t resolution)
/* ADC Set Resolution. ADC Resolution can be reduced from 12 bits to 10, 8 or 6 bits for a corresponding reduction in conversion time. */ void adc_set_resolution(uint32_t adc, uint16_t resolution)
{ ADC_CFGR1(adc) = (ADC_CFGR1(adc) & ~ADC_CFGR1_RES_MASK) | resolution; }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* This API initializes the auxiliary interface to access auxiliary sensor. */
uint16_t bma4_aux_interface_init(struct bma4_dev *dev)
/* This API initializes the auxiliary interface to access auxiliary sensor. */ uint16_t bma4_aux_interface_init(struct bma4_dev *dev)
{ uint16_t rslt = BMA4_OK; rslt |= bma4_null_pointer_check(dev); if (rslt == BMA4_OK) { rslt = bma4_set_aux_interface_config(dev); if (rslt != BMA4_OK) rslt = BMA4_E_AUX_CONFIG_FAIL; } return rslt; }
arendst/Tasmota
C++
GNU General Public License v3.0
21,318
/* param base Pointer to the FLEXIO_UART_Type structure. param handle Pointer to the flexio_uart_handle_t structure to store the transfer state. param ringBuffer Start address of ring buffer for background receiving. Pass NULL to disable the ring buffer. param ringBufferSize Size of the ring buffer. */
void FLEXIO_UART_TransferStartRingBuffer(FLEXIO_UART_Type *base, flexio_uart_handle_t *handle, uint8_t *ringBuffer, size_t ringBufferSize)
/* param base Pointer to the FLEXIO_UART_Type structure. param handle Pointer to the flexio_uart_handle_t structure to store the transfer state. param ringBuffer Start address of ring buffer for background receiving. Pass NULL to disable the ring buffer. param ringBufferSize Size of the ring buffer. */ void FLEXIO_UART_TransferStartRingBuffer(FLEXIO_UART_Type *base, flexio_uart_handle_t *handle, uint8_t *ringBuffer, size_t ringBufferSize)
{ assert(handle); if (ringBuffer) { handle->rxRingBuffer = ringBuffer; handle->rxRingBufferSize = ringBufferSize; handle->rxRingBufferHead = 0U; handle->rxRingBufferTail = 0U; FLEXIO_UART_EnableInterrupts(base, kFLEXIO_UART_RxDataRegFullInterruptEnable); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Driver done interrupt service routine for channel 4. We need this done ISR mainly because the driver needs to release the DMA program buffer. This is the one that connects the GIC */
void XDmaPs_DoneISR_4(XDmaPs *InstPtr)
/* Driver done interrupt service routine for channel 4. We need this done ISR mainly because the driver needs to release the DMA program buffer. This is the one that connects the GIC */ void XDmaPs_DoneISR_4(XDmaPs *InstPtr)
{ XDmaPs_DoneISR_n(InstPtr, 4); }
ua1arn/hftrx
C++
null
69
/* Returns 1 if the page can be released, false otherwise. */
static int v9fs_release_page(struct page *page, gfp_t gfp)
/* Returns 1 if the page can be released, false otherwise. */ static int v9fs_release_page(struct page *page, gfp_t gfp)
{ if (PagePrivate(page)) return 0; return v9fs_fscache_release_page(page, gfp); }
robutest/uclinux
C++
GPL-2.0
60
/* This procedure is passed a buffer descriptor for an iframe. It builds the rest of the control part of the frame and then writes it out. */
static void nr_send_iframe(struct sock *sk, struct sk_buff *skb)
/* This procedure is passed a buffer descriptor for an iframe. It builds the rest of the control part of the frame and then writes it out. */ static void nr_send_iframe(struct sock *sk, struct sk_buff *skb)
{ struct nr_sock *nr = nr_sk(sk); if (skb == NULL) return; skb->data[2] = nr->vs; skb->data[3] = nr->vr; if (nr->condition & NR_COND_OWN_RX_BUSY) skb->data[4] |= NR_CHOKE_FLAG; nr_start_idletimer(sk); nr_transmit_buffer(sk, skb); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Return NRST pin level ( 1 or 0 ). */
unsigned char RSTC_GetNrstLevel(void)
/* Return NRST pin level ( 1 or 0 ). */ unsigned char RSTC_GetNrstLevel(void)
{ if (AT91C_BASE_RSTC->RSTC_RSR & AT91C_RSTC_NRSTL) { return 1; } return 0; }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* ‘g’ Reads the general registers into an output buffer and sends it as a packet */
VOID EFIAPI ReadGeneralRegisters(IN EFI_SYSTEM_CONTEXT SystemContext)
/* ‘g’ Reads the general registers into an output buffer and sends it as a packet */ VOID EFIAPI ReadGeneralRegisters(IN EFI_SYSTEM_CONTEXT SystemContext)
{ UINTN i; CHAR8 OutBuffer[129]; CHAR8 *OutBufPtr; OutBufPtr = OutBuffer; for (i = 0; i < MaxRegisterCount (); i++) { OutBufPtr = BasicReadRegister (SystemContext, i, OutBufPtr); } *OutBufPtr = '\0'; SendPacket (OutBuffer); }
tianocore/edk2
C++
Other
4,240
/* Call this if system is going to down or if immediate flushing messages to console is required. (ex. recovery was failed, crash dump is going to be invoked, long-wait rendezvous etc.) NOTE: this should be called from monarch. */
static void ia64_mlogbuf_finish(int wait)
/* Call this if system is going to down or if immediate flushing messages to console is required. (ex. recovery was failed, crash dump is going to be invoked, long-wait rendezvous etc.) NOTE: this should be called from monarch. */ static void ia64_mlogbuf_finish(int wait)
{ BREAK_LOGLEVEL(console_loglevel); spin_lock_init(&mlogbuf_rlock); ia64_mlogbuf_dump(); printk(KERN_EMERG "mlogbuf_finish: printing switched to urgent mode, " "MCA/INIT might be dodgy or fail.\n"); if (!wait) return; printk("Delaying for 5 seconds...\n"); udelay(5*1000000); mlogbuf_finished = 1; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* map the specified device/slot/pin to an IRQ. Different backplanes may need to modify this. */
static int __init versatile_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
/* map the specified device/slot/pin to an IRQ. Different backplanes may need to modify this. */ static int __init versatile_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
{ int irq; int devslot = PCI_SLOT(dev->devfn); irq = 27 + ((slot + pin - 1) & 3); printk("PCI map irq: slot %d, pin %d, devslot %d, irq: %d\n",slot,pin,devslot,irq); return irq; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* This function allocates memory below 4G memory address. */
VOID* AllocateMemoryBelow4G(IN EFI_MEMORY_TYPE MemoryType, IN UINTN Size)
/* This function allocates memory below 4G memory address. */ VOID* AllocateMemoryBelow4G(IN EFI_MEMORY_TYPE MemoryType, IN UINTN Size)
{ UINTN Pages; EFI_PHYSICAL_ADDRESS Address; EFI_STATUS Status; VOID *Buffer; Pages = EFI_SIZE_TO_PAGES (Size); Address = 0xffffffff; Status = gBS->AllocatePages ( AllocateMaxAddress, MemoryType, Pages, &Address ); ASSERT_EFI_ERROR (Status); Buffer = (VOID *)(UINTN)Address; ZeroMem (Buffer, Size); return Buffer; }
tianocore/edk2
C++
Other
4,240
/* Checks whether this rx descriptor is last rx descriptor. This returns true if it is last descriptor either in ring mode or in chain mode. */
bool synopGMAC_is_last_rx_desc(synopGMACdevice *gmacdev, DmaDesc *desc)
/* Checks whether this rx descriptor is last rx descriptor. This returns true if it is last descriptor either in ring mode or in chain mode. */ bool synopGMAC_is_last_rx_desc(synopGMACdevice *gmacdev, DmaDesc *desc)
{ return (((desc->length & RxDescEndOfRing) == RxDescEndOfRing)); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Checks if any input data on the given channel is available Checks RxAvail */
static int portman_data_avail(struct portman *pm, int channel)
/* Checks if any input data on the given channel is available Checks RxAvail */ static int portman_data_avail(struct portman *pm, int channel)
{ int command = INT_EN; switch (channel) { case 0: command |= RXDATA0; break; case 1: command |= RXDATA1; break; } portman_write_command(pm, command); if ((portman_read_status(pm) & RXAVAIL) == RXAVAIL) return 1; return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Set the condition code in the user psw. 0 : Result is zero 1 : Result is less than zero 2 : Result is greater than zero 3 : Result is NaN or INF */
static void emu_set_CC_cs(struct pt_regs *regs, int class, int sign)
/* Set the condition code in the user psw. 0 : Result is zero 1 : Result is less than zero 2 : Result is greater than zero 3 : Result is NaN or INF */ static void emu_set_CC_cs(struct pt_regs *regs, int class, int sign)
{ switch (class) { case FP_CLS_NORMAL: case FP_CLS_INF: emu_set_CC(regs, sign ? 1 : 2); break; case FP_CLS_ZERO: emu_set_CC(regs, 0); break; case FP_CLS_NAN: emu_set_CC(regs, 3); break; } }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Fills each init_struct member with its default value. */
void I2C_StructInit(I2C_InitTypeDef *init_struct)
/* Fills each init_struct member with its default value. */ void I2C_StructInit(I2C_InitTypeDef *init_struct)
{ init_struct->I2C_Mode = I2C_CR_MASTER; init_struct->I2C_OwnAddress = I2C_OWN_ADDRESS; init_struct->I2C_Speed = I2C_CR_STD; init_struct->I2C_ClockSpeed = 100000; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Get available stack space of a thread based on stack watermark recording during execution. */
static uint32_t svcRtxThreadGetStackSpace(osThreadId_t thread_id)
/* Get available stack space of a thread based on stack watermark recording during execution. */ static uint32_t svcRtxThreadGetStackSpace(osThreadId_t thread_id)
{ EvrRtxThreadGetStackSpace(thread, 0U); return 0U; } if ((osRtxConfig.flags & osRtxConfigStackWatermark) == 0U) { EvrRtxThreadGetStackSpace(thread, 0U); return 0U; } stack = thread->stack_mem; if (*stack++ == osRtxStackMagicWord) { for (space = 4U; space < thread->stack_size; space += 4U) { if (*stack++ != osRtxStackFillPattern) { break; } } } else { space = 0U; } EvrRtxThreadGetStackSpace(thread, space); return space; }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* This function creates a new device node in a newly allocated buffer of size NodeLength and initializes the device path node header with NodeType and NodeSubType. The new device path node is returned. If NodeLength is smaller than a device path header, then NULL is returned. If there is not enough memory to allocate space for the new device path, then NULL is returned. The memory is allocated from EFI boot services memory. It is the responsibility of the caller to free the memory allocated. */
EFI_DEVICE_PATH_PROTOCOL* EFIAPI CreateDeviceNode(IN UINT8 NodeType, IN UINT8 NodeSubType, IN UINT16 NodeLength)
/* This function creates a new device node in a newly allocated buffer of size NodeLength and initializes the device path node header with NodeType and NodeSubType. The new device path node is returned. If NodeLength is smaller than a device path header, then NULL is returned. If there is not enough memory to allocate space for the new device path, then NULL is returned. The memory is allocated from EFI boot services memory. It is the responsibility of the caller to free the memory allocated. */ EFI_DEVICE_PATH_PROTOCOL* EFIAPI CreateDeviceNode(IN UINT8 NodeType, IN UINT8 NodeSubType, IN UINT16 NodeLength)
{ if (mDevicePathLibDevicePathUtilities != NULL) { return mDevicePathLibDevicePathUtilities->CreateDeviceNode (NodeType, NodeSubType, NodeLength); } else { return UefiDevicePathLibCreateDeviceNode (NodeType, NodeSubType, NodeLength); } }
tianocore/edk2
C++
Other
4,240
/* Returns a negative error number on failure, or the number of bytes used / required on success. */
int ext3_xattr_get(struct inode *inode, int name_index, const char *name, void *buffer, size_t buffer_size)
/* Returns a negative error number on failure, or the number of bytes used / required on success. */ int ext3_xattr_get(struct inode *inode, int name_index, const char *name, void *buffer, size_t buffer_size)
{ int error; down_read(&EXT3_I(inode)->xattr_sem); error = ext3_xattr_ibody_get(inode, name_index, name, buffer, buffer_size); if (error == -ENODATA) error = ext3_xattr_block_get(inode, name_index, name, buffer, buffer_size); up_read(&EXT3_I(inode)->xattr_sem); return error; }
robutest/uclinux
C++
GPL-2.0
60
/* Get information about an image. Try the created image decoder one by one. Once one is able to get info that info will be used. */
lv_res_t lv_img_decoder_get_info(const char *src, lv_img_header_t *header)
/* Get information about an image. Try the created image decoder one by one. Once one is able to get info that info will be used. */ lv_res_t lv_img_decoder_get_info(const char *src, lv_img_header_t *header)
{ header->always_zero = 0; lv_res_t res = LV_RES_INV; lv_img_decoder_t * d; LV_LL_READ(LV_GC_ROOT(_lv_img_defoder_ll), d) { res = LV_RES_INV; if(d->info_cb) { res = d->info_cb(d, src, header); if(res == LV_RES_OK) break; } } return res; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Add specified device to the global device list. */
static void device_add(struct mtd_device *dev)
/* Add specified device to the global device list. */ static void device_add(struct mtd_device *dev)
{ u8 current_save_needed = 0; if (list_empty(&devices)) { current_mtd_dev = dev; current_mtd_partnum = 0; current_save_needed = 1; } list_add_tail(&dev->link, &devices); if (current_save_needed > 0) current_save(); else index_partitions(); }
EmcraftSystems/u-boot
C++
Other
181
/* Wait for User push-button press to start transfer. */
void WaitForUserButtonPress(void)
/* Wait for User push-button press to start transfer. */ void WaitForUserButtonPress(void)
{ while (ubButtonPress == 0) { LL_GPIO_TogglePin(LED1_GPIO_PORT, LED1_PIN); LL_mDelay(LED_BLINK_FAST); } LL_GPIO_ResetOutputPin(LED1_GPIO_PORT, LED1_PIN); }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* Set all the currently used IO bank timing information generated by s3c2410_iotiming_calc() once the core has validated that all the new values are within permitted bounds. */
void s3c2410_iotiming_set(struct s3c_cpufreq_config *cfg, struct s3c_iotimings *iot)
/* Set all the currently used IO bank timing information generated by s3c2410_iotiming_calc() once the core has validated that all the new values are within permitted bounds. */ void s3c2410_iotiming_set(struct s3c_cpufreq_config *cfg, struct s3c_iotimings *iot)
{ struct s3c2410_iobank_timing *bt; int bank; for (bank = 0; bank < MAX_BANKS; bank++) { bt = iot->bank[bank].io_2410; if (!bt) continue; __raw_writel(bt->bankcon, bank_reg(bank)); } }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Handles the ESBC uboot client header verification failure. This function handles all the errors which might occur in the parsing and checking of ESBC uboot client header. It will also set the error bits in the SEC_MON. */
static void fsl_secboot_header_verification_failure(void)
/* Handles the ESBC uboot client header verification failure. This function handles all the errors which might occur in the parsing and checking of ESBC uboot client header. It will also set the error bits in the SEC_MON. */ static void fsl_secboot_header_verification_failure(void)
{ struct ccsr_sfp_regs *sfp_regs = (void *)(CONFIG_SYS_SFP_ADDR); u32 its = sfp_in32(&sfp_regs->ospr) >> 2; if (its == 1) set_sec_mon_state(HPSR_SSM_ST_SOFT_FAIL); else set_sec_mon_state(HPSR_SSM_ST_NON_SECURE); printf("Generating reset request\n"); do_reset(NULL, 0, 0, NULL); do_esbc_halt(NULL, 0, 0, NULL); }
4ms/stm32mp1-baremetal
C++
Other
137
/* This is a helper function which releases budget corresponding to the budget of changing one one page of data which already exists on the flash media. */
static void release_existing_page_budget(struct ubifs_info *c)
/* This is a helper function which releases budget corresponding to the budget of changing one one page of data which already exists on the flash media. */ static void release_existing_page_budget(struct ubifs_info *c)
{ struct ubifs_budget_req req = { .dd_growth = c->page_budget}; ubifs_release_budget(c, &req); }
robutest/uclinux
C++
GPL-2.0
60
/* This function handles USART3 and USART4 global interrupts. */
void USART3_4_IRQHandler(void)
/* This function handles USART3 and USART4 global interrupts. */ void USART3_4_IRQHandler(void)
{ HAL_UART_IRQHandler(&huart3); }
Luos-io/luos_engine
C++
MIT License
496
/* Enables or disables the TIM Capture Compare Channel x. */
void TIM_CCxCmd(TIM_TypeDef *TIMx, uint16_t TIM_Channel, uint16_t TIM_CCx)
/* Enables or disables the TIM Capture Compare Channel x. */ void TIM_CCxCmd(TIM_TypeDef *TIMx, uint16_t TIM_Channel, uint16_t TIM_CCx)
{ uint16_t tmp = 0; assert_param(IS_TIM_LIST1_PERIPH(TIMx)); assert_param(IS_TIM_CHANNEL(TIM_Channel)); assert_param(IS_TIM_CCX(TIM_CCx)); tmp = CCER_CCE_SET << TIM_Channel; TIMx->CCER &= (uint16_t)~ tmp; TIMx->CCER |= (uint16_t)(TIM_CCx << TIM_Channel); }
MaJerle/stm32f429
C++
null
2,036
/* Calls the @unuse_plugin function from the #GTypePluginClass of @plugin. There should be no need to use this function outside of the GObject type system itself. */
void g_type_plugin_unuse(GTypePlugin *plugin)
/* Calls the @unuse_plugin function from the #GTypePluginClass of @plugin. There should be no need to use this function outside of the GObject type system itself. */ void g_type_plugin_unuse(GTypePlugin *plugin)
{ GTypePluginClass *iface; g_return_if_fail (G_IS_TYPE_PLUGIN (plugin)); iface = G_TYPE_PLUGIN_GET_CLASS (plugin); iface->unuse_plugin (plugin); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Allow the pointer to move on the whole screen. */
void POINTER_SetRectScreen(void)
/* Allow the pointer to move on the whole screen. */ void POINTER_SetRectScreen(void)
{ POINTER_SetRect( 0, 0, POS_MAX, POS_MAX ); }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* RNG MSP Initialization This function configures the hardware resources used in this example: */
void HAL_RNG_MspInit(RNG_HandleTypeDef *hrng)
/* RNG MSP Initialization This function configures the hardware resources used in this example: */ void HAL_RNG_MspInit(RNG_HandleTypeDef *hrng)
{ __HAL_RCC_RNG_CLK_ENABLE(); }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* (Re)fill a cache with the contents in the kernel. */
int nl_cache_refill(struct nl_sock *sk, struct nl_cache *cache)
/* (Re)fill a cache with the contents in the kernel. */ int nl_cache_refill(struct nl_sock *sk, struct nl_cache *cache)
{ int err; err = nl_cache_request_full_dump(sk, cache); if (err < 0) return err; NL_DBG(2, "Upading cache %p <%s>, request sent, waiting for dump...\n", cache, nl_cache_name(cache)); nl_cache_clear(cache); return nl_cache_pickup(sk, cache); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* This function should be used to verify the external oscillator is active and valid before attempting to recover from a */
bool HibernateTamperExtOscValid(void)
/* This function should be used to verify the external oscillator is active and valid before attempting to recover from a */ bool HibernateTamperExtOscValid(void)
{ if (HibernateTamperStatusGet() & (HIBERNATE_TAMPER_STATUS_EXT_OSC_ACTIVE | HIBERNATE_TAMPER_STATUS_EXT_OSC_VALID)) { return (true); } return (false); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Returns CR_OK upon successful completion, CR_PARSING_ERROR if next char is different from a_char, an other error code otherwise */
enum CRStatus cr_input_consume_char(CRInput *a_this, guint32 a_char)
/* Returns CR_OK upon successful completion, CR_PARSING_ERROR if next char is different from a_char, an other error code otherwise */ enum CRStatus cr_input_consume_char(CRInput *a_this, guint32 a_char)
{ guint32 c; enum CRStatus status; g_return_val_if_fail (a_this && PRIVATE (a_this), CR_BAD_PARAM_ERROR); if ((status = cr_input_peek_char (a_this, &c)) != CR_OK) { return status; } if (c == a_char || a_char == 0) { status = cr_input_read_char (a_this, &c); } else { return CR_PARSING_ERROR; } return status; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Sets the cursor to the home position (0,0) */
void ili9328Home(void)
/* Sets the cursor to the home position (0,0) */ void ili9328Home(void)
{ ili9328SetCursor(0, 0); ili9328WriteCmd(ILI9328_COMMANDS_WRITEDATATOGRAM); }
microbuilder/LPC1343CodeBase
C++
Other
73
/* If 16-bit MMIO register operations are not supported, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). If StartBit is greater than 15, then ASSERT(). If EndBit is greater than 15, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
UINT16 EFIAPI MmioBitFieldAnd16(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT16 AndData)
/* If 16-bit MMIO register operations are not supported, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). If StartBit is greater than 15, then ASSERT(). If EndBit is greater than 15, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */ UINT16 EFIAPI MmioBitFieldAnd16(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT16 AndData)
{ return MmioWrite16 ( Address, BitFieldAnd16 (MmioRead16 (Address), StartBit, EndBit, AndData) ); }
tianocore/edk2
C++
Other
4,240
/* Gets the timer load value for a 64-bit timer. */
uint64_t TimerLoadGet64(uint32_t ui32Base)
/* Gets the timer load value for a 64-bit timer. */ uint64_t TimerLoadGet64(uint32_t ui32Base)
{ uint32_t ui32High1, ui32High2, ui32Low; ASSERT(_TimerBaseValid(ui32Base)); do { ui32High1 = HWREG(ui32Base + TIMER_O_TBILR); ui32Low = HWREG(ui32Base + TIMER_O_TAILR); ui32High2 = HWREG(ui32Base + TIMER_O_TBILR); } while(ui32High1 != ui32High2); return(((uint64_t)ui32High1 << 32) | (uint64_t)ui32Low); }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Polarity is determined based on the PHY specific status register. */
static s32 igb_check_polarity_82580(struct e1000_hw *hw)
/* Polarity is determined based on the PHY specific status register. */ static s32 igb_check_polarity_82580(struct e1000_hw *hw)
{ struct e1000_phy_info *phy = &hw->phy; s32 ret_val; u16 data; ret_val = phy->ops.read_reg(hw, I82580_PHY_STATUS_2, &data); if (!ret_val) phy->cable_polarity = (data & I82580_PHY_STATUS2_REV_POLARITY) ? e1000_rev_polarity_reversed : e1000_rev_polarity_normal; return ret_val; }
robutest/uclinux
C++
GPL-2.0
60
/* give a range error for cache space constraints */
static int cachefiles_daemon_range_error(struct cachefiles_cache *cache, char *args)
/* give a range error for cache space constraints */ static int cachefiles_daemon_range_error(struct cachefiles_cache *cache, char *args)
{ kerror("Free space limits must be in range" " 0%%<=stop<cull<run<100%%"); return -EINVAL; }
robutest/uclinux
C++
GPL-2.0
60
/* If the requested operation results in an overflow or an underflow condition, then Result is set to UINT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */
RETURN_STATUS EFIAPI SafeUint16Mult(IN UINT16 Multiplicand, IN UINT16 Multiplier, OUT UINT16 *Result)
/* If the requested operation results in an overflow or an underflow condition, then Result is set to UINT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */ RETURN_STATUS EFIAPI SafeUint16Mult(IN UINT16 Multiplicand, IN UINT16 Multiplier, OUT UINT16 *Result)
{ UINT32 IntermediateResult; IntermediateResult = ((UINT32)Multiplicand) *((UINT32)Multiplier); return SafeUint32ToUint16 (IntermediateResult, Result); }
tianocore/edk2
C++
Other
4,240
/* Writes more than one byte to the EEPROM with a single WRITE cycle (Page WRITE sequence). */
uint32_t sEE_WritePage(uint8_t *pBuffer, uint16_t WriteAddr, uint16_t *NumByteToWrite)
/* Writes more than one byte to the EEPROM with a single WRITE cycle (Page WRITE sequence). */ uint32_t sEE_WritePage(uint8_t *pBuffer, uint16_t WriteAddr, uint16_t *NumByteToWrite)
{ sEE_WriteEnable(); sEE_CS_LOW(); sEE_SendByte(sEE_CMD_WRITE); sEE_SendByte((WriteAddr & 0xFF0000) >> 16); sEE_SendByte((WriteAddr & 0xFF00) >> 8); sEE_SendByte(WriteAddr & 0xFF); while ((*NumByteToWrite)--) { sEE_SendByte(*pBuffer); pBuffer++; } sEE_CS_HIGH(); sEE_WaitEepromStandbyState(); sEE_WriteDisable(); return 0; }
avem-labs/Avem
C++
MIT License
1,752
/* Get the mapped of a number given an input and output range */
int32_t lv_map(int32_t x, int32_t min_in, int32_t max_in, int32_t min_out, int32_t max_out)
/* Get the mapped of a number given an input and output range */ int32_t lv_map(int32_t x, int32_t min_in, int32_t max_in, int32_t min_out, int32_t max_out)
{ if(max_in >= min_in && x >= max_in) return max_out; if(max_in >= min_in && x <= min_in) return min_out; if(max_in <= min_in && x <= max_in) return max_out; if(max_in <= min_in && x >= min_in) return min_out; int32_t delta_in = max_in - min_in; int32_t delta_out = max_out - min_out; return ((x - min_in) * delta_out) / delta_in + min_out; }
pikasTech/PikaPython
C++
MIT License
1,403
/* Perform basic hardware initialization at boot. Assumption: MAINCLK = 24Mhz */
static int arm_beetle_init(void)
/* Perform basic hardware initialization at boot. Assumption: MAINCLK = 24Mhz */ static int arm_beetle_init(void)
{ soc_power_init(); return 0; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* set_dec() - Set the value of the decrementer register @val: The value of the decrementer register to be set */
static void set_dec(unsigned long val)
/* set_dec() - Set the value of the decrementer register @val: The value of the decrementer register to be set */ static void set_dec(unsigned long val)
{ if (val) asm volatile ("mtdec %0"::"r" (val)); }
4ms/stm32mp1-baremetal
C++
Other
137
/* Reads the LED default settings from the NVM to data. If the NVM LED settings is all 0's or F's, set the LED default to a valid LED default setting. */
static s32 e1000_valid_led_default_ich8lan(struct e1000_hw *hw, u16 *data)
/* Reads the LED default settings from the NVM to data. If the NVM LED settings is all 0's or F's, set the LED default to a valid LED default setting. */ static s32 e1000_valid_led_default_ich8lan(struct e1000_hw *hw, u16 *data)
{ s32 ret_val; ret_val = e1000_read_nvm(hw, NVM_ID_LED_SETTINGS, 1, data); if (ret_val) { e_dbg("NVM Read Error\n"); return ret_val; } if (*data == ID_LED_RESERVED_0000 || *data == ID_LED_RESERVED_FFFF) *data = ID_LED_DEFAULT_ICH8LAN; return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* In Multidrop mode only, the next character written to the US_THR is sent with the address bit set. */
uint32_t usart_send_address(Usart *p_usart, uint32_t ul_addr)
/* In Multidrop mode only, the next character written to the US_THR is sent with the address bit set. */ uint32_t usart_send_address(Usart *p_usart, uint32_t ul_addr)
{ if ((p_usart->US_MR & US_MR_PAR_MULTIDROP) != US_MR_PAR_MULTIDROP) { return 1; } p_usart->US_CR = US_CR_SENDA; if (usart_write(p_usart, ul_addr)) { return 1; } else { return 0; } }
remotemcu/remcu-chip-sdks
C++
null
436
/* Configure the specified MCU pin. Returns 0 on success, -EINVAL otherwise. */
static int lpc18xx_pin_config(int group, int pin, u32 regval)
/* Configure the specified MCU pin. Returns 0 on success, -EINVAL otherwise. */ static int lpc18xx_pin_config(int group, int pin, u32 regval)
{ int rv; rv = lpc18xx_validate_pin(group, pin); if (! rv) { writel(0, &LPC18XX_PIN(group, pin)); writel(regval, &LPC18XX_PIN(group, pin)); } return rv; }
robutest/uclinux
C++
GPL-2.0
60
/* FLEXIO UART EDMA send finished callback function. This function is called when FLEXIO UART EDMA send finished. It disables the UART TX EDMA request and sends kStatus_FLEXIO_UART_TxIdle to FLEXIO UART callback. */
static void FLEXIO_UART_TransferSendEDMACallback(edma_handle_t *handle, void *param, bool transferDone, uint32_t tcds)
/* FLEXIO UART EDMA send finished callback function. This function is called when FLEXIO UART EDMA send finished. It disables the UART TX EDMA request and sends kStatus_FLEXIO_UART_TxIdle to FLEXIO UART callback. */ static void FLEXIO_UART_TransferSendEDMACallback(edma_handle_t *handle, void *param, bool transferDone, uint32_t tcds)
{ flexio_uart_edma_private_handle_t *uartPrivateHandle = (flexio_uart_edma_private_handle_t *)param; assert(uartPrivateHandle->handle); handle = handle; tcds = tcds; if (transferDone) { FLEXIO_UART_TransferAbortSendEDMA(uartPrivateHandle->base, uartPrivateHandle->handle); if (uartPrivateHandle->handle->callback) { uartPrivateHandle->handle->callback(uartPrivateHandle->base, uartPrivateHandle->handle, kStatus_FLEXIO_UART_TxIdle, uartPrivateHandle->handle->userData); } } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function will enable the USB controller's PLL which is used by it's physical layer. This call is necessary before connecting to any external devices. */
void SysCtlUSBPLLEnable(void)
/* This function will enable the USB controller's PLL which is used by it's physical layer. This call is necessary before connecting to any external devices. */ void SysCtlUSBPLLEnable(void)
{ HWREG(SYSCTL_RCC2) &= ~SYSCTL_RCC2_USBPWRDN; }
watterott/WebRadio
C++
null
71
/* Handler for RM7000 extended interrupts. These are a non-standard feature so we handle them separately from standard interrupts. */
static void unmask_rm7k_irq(unsigned int irq)
/* Handler for RM7000 extended interrupts. These are a non-standard feature so we handle them separately from standard interrupts. */ static void unmask_rm7k_irq(unsigned int irq)
{ set_c0_intcontrol(0x100 << (irq - RM7K_CPU_IRQ_BASE)); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Removes given child from given inode on server. */
int pohmelfs_remove_child(struct pohmelfs_inode *pi, struct pohmelfs_name *n)
/* Removes given child from given inode on server. */ int pohmelfs_remove_child(struct pohmelfs_inode *pi, struct pohmelfs_name *n)
{ return pohmelfs_meta_command_data(pi, pi->ino, NETFS_REMOVE, NULL, 0, NULL, NULL, 0); }
robutest/uclinux
C++
GPL-2.0
60
/* Enables or disables the SGPIO multiple match FIFO mode. */
void SGPIO_MULFIFO_Cmd(SGPIO_TypeDef *SGPIOx, u8 NewState)
/* Enables or disables the SGPIO multiple match FIFO mode. */ void SGPIO_MULFIFO_Cmd(SGPIO_TypeDef *SGPIOx, u8 NewState)
{ assert_param(IS_SGPIO_ALL_PERIPH(SGPIOx)); if (NewState != DISABLE) { SGPIOx->SGPIO_MULMC_CTRL |= BIT_SGPIO_MUL_FMODE_EN; } else { SGPIOx->SGPIO_MULMC_CTRL &= (~BIT_SGPIO_MUL_FMODE_EN); } }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Set each stc_canfd_config_t field to a default value. Based on 40MHz CAN clock, TQ clock is CAN clock divided by 1. Bit rate 2Mbps, 1 bit time is 20TQs, primary sample point is 80%, secondary sample point is 80%. */
int32_t CAN_FD_StructInit(stc_canfd_config_t *pstcCanFd)
/* Set each stc_canfd_config_t field to a default value. Based on 40MHz CAN clock, TQ clock is CAN clock divided by 1. Bit rate 2Mbps, 1 bit time is 20TQs, primary sample point is 80%, secondary sample point is 80%. */ int32_t CAN_FD_StructInit(stc_canfd_config_t *pstcCanFd)
{ int32_t i32Ret = LL_ERR_INVD_PARAM; if (pstcCanFd != NULL) { pstcCanFd->stcBitCfg.u32Prescaler = 1U; pstcCanFd->stcBitCfg.u32TimeSeg1 = 16U; pstcCanFd->stcBitCfg.u32TimeSeg2 = 4U; pstcCanFd->stcBitCfg.u32SJW = 4U; pstcCanFd->u8Mode = CAN_FD_MD_ISO; pstcCanFd->u8TDC = CAN_FD_TDC_ENABLE; pstcCanFd->u8SSPOffset = 16U; i32Ret = LL_OK; } return i32Ret; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function should be called when a tracked request is completing. */
static void tracked_request_end(BdrvTrackedRequest *req)
/* This function should be called when a tracked request is completing. */ static void tracked_request_end(BdrvTrackedRequest *req)
{ if (req->serialising) { req->bs->serialising_in_flight--; } QLIST_REMOVE(req, list); qemu_co_queue_restart_all(&req->wait_queue); }
ve3wwg/teensy3_qemu
C
Other
15
/* call to complete the construction of a key */
void complete_request_key(struct key_construction *cons, int error)
/* call to complete the construction of a key */ void complete_request_key(struct key_construction *cons, int error)
{ kenter("{%d,%d},%d", cons->key->serial, cons->authkey->serial, error); if (error < 0) key_negate_and_link(cons->key, key_negative_timeout, NULL, cons->authkey); else key_revoke(cons->authkey); key_put(cons->key); key_put(cons->authkey); kfree(cons); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Gets the value of SysTick Calibration Value Register. This register contains of TENMS, which can be used to set Systick 10ms value. */
unsigned long xSysTickCalibrGet(void)
/* Gets the value of SysTick Calibration Value Register. This register contains of TENMS, which can be used to set Systick 10ms value. */ unsigned long xSysTickCalibrGet(void)
{ return(xHWREG(NVIC_ST_CAL)); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Returns: the silicon revision of the cpu -EINVAL - not a mx27 */
int mx27_revision(void)
/* Returns: the silicon revision of the cpu -EINVAL - not a mx27 */ int mx27_revision(void)
{ if (cpu_silicon_rev == -1) query_silicon_parameter(); if (cpu_partnumber != 0x8821) return -EINVAL; return cpu_silicon_rev; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* @westwood_fast_bw It is called when we are in fast path. In particular it is called when header prediction is successful. In such case in fact update is straight forward and doesn't need any particular care. */
static void westwood_fast_bw(struct sock *sk)
/* @westwood_fast_bw It is called when we are in fast path. In particular it is called when header prediction is successful. In such case in fact update is straight forward and doesn't need any particular care. */ static void westwood_fast_bw(struct sock *sk)
{ const struct tcp_sock *tp = tcp_sk(sk); struct westwood *w = inet_csk_ca(sk); westwood_update_window(sk); w->bk += tp->snd_una - w->snd_una; w->snd_una = tp->snd_una; update_rtt_min(w); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* cpu_pwr_down() is invoked from idle task when it detects that the kernel can go idle. cpu_pwr_down() checks the current cpu idle mode and put cpu into lower power mode according different idle mode. */
void cpu_pwr_down(void)
/* cpu_pwr_down() is invoked from idle task when it detects that the kernel can go idle. cpu_pwr_down() checks the current cpu idle mode and put cpu into lower power mode according different idle mode. */ void cpu_pwr_down(void)
{ if (cpu_pwr_init_flag == 0) { return; } krhino_spin_lock_irq_save(&cpu_pwr_spin); pmu_yield_os_set(0); SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk; if(!AliOS_ready_to_sleep()){ SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk; pmu_yield_os_set(1); krhino_spin_unlock_irq_restore(&cpu_pwr_spin); return; } tickless_enter(); SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk; pmu_yield_os_set(1); krhino_spin_unlock_irq_restore(&cpu_pwr_spin); }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* LSM hook implementation that authorizes deletion of labeled SAs. */
int selinux_xfrm_state_delete(struct xfrm_state *x)
/* LSM hook implementation that authorizes deletion of labeled SAs. */ int selinux_xfrm_state_delete(struct xfrm_state *x)
{ const struct task_security_struct *tsec = current_security(); struct xfrm_sec_ctx *ctx = x->security; int rc = 0; if (ctx) { rc = avc_has_perm(tsec->sid, ctx->ctx_sid, SECCLASS_ASSOCIATION, ASSOCIATION__SETCONTEXT, NULL); if (rc == 0) atomic_dec(&selinux_xfrm_refcount); } return rc; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Get I2C status of the specified I2C port. The */
unsigned long I2CStatusGet(unsigned long ulBase)
/* Get I2C status of the specified I2C port. The */ unsigned long I2CStatusGet(unsigned long ulBase)
{ xASSERT((ulBase == I2C0_BASE) || (ulBase == I2C1_BASE)); return (xHWREG(ulBase + I2C_O_STATUS) & I2C_STATUS_M); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Move count entries from end of map between two memory locations. Returns pointer to last entry moved. */
static struct ext3_dir_entry_2 * dx_move_dirents(char *from, char *to, struct dx_map_entry *offsets, int count)
/* Move count entries from end of map between two memory locations. Returns pointer to last entry moved. */ static struct ext3_dir_entry_2 * dx_move_dirents(char *from, char *to, struct dx_map_entry *offsets, int count)
{ unsigned rec_len = 0; while (count--) { struct ext3_dir_entry_2 *de = (struct ext3_dir_entry_2 *) (from + map->offs); rec_len = EXT3_DIR_REC_LEN(de->name_len); memcpy (to, de, rec_len); ((struct ext3_dir_entry_2 *) to)->rec_len = ext3_rec_len_to_disk(rec_len); de->inode = 0; map++; to += rec_len; } return (struct ext3_dir_entry_2 *) (to - rec_len); }
robutest/uclinux
C++
GPL-2.0
60
/* If Sha512Context is NULL, then return FALSE. If HashValue is NULL, then return FALSE. */
BOOLEAN EFIAPI Sha512Final(IN OUT VOID *Sha512Context, OUT UINT8 *HashValue)
/* If Sha512Context is NULL, then return FALSE. If HashValue is NULL, then return FALSE. */ BOOLEAN EFIAPI Sha512Final(IN OUT VOID *Sha512Context, OUT UINT8 *HashValue)
{ CALL_CRYPTO_SERVICE (Sha512Final, (Sha512Context, HashValue), FALSE); }
tianocore/edk2
C++
Other
4,240
/* Sets the elements of the DCM matrixto the corresponding elements of the identity matrix. */
void IMU_dcmReset(float dcm[3][3])
/* Sets the elements of the DCM matrixto the corresponding elements of the identity matrix. */ void IMU_dcmReset(float dcm[3][3])
{ int x, y; for( y = 0; y < 3; y++ ) { for( x = 0; x < 3; x++ ) { dcm[y][x] = ( x == y ) ? 1 : 0; } } return; }
remotemcu/remcu-chip-sdks
C++
null
436