hexsha stringlengths 40 40 | size int64 5 1.05M | ext stringclasses 588
values | lang stringclasses 305
values | max_stars_repo_path stringlengths 3 363 | max_stars_repo_name stringlengths 5 118 | max_stars_repo_head_hexsha stringlengths 40 40 | max_stars_repo_licenses listlengths 1 10 | max_stars_count float64 1 191k ⌀ | max_stars_repo_stars_event_min_datetime stringdate 2015-01-01 00:00:35 2022-03-31 23:43:49 ⌀ | max_stars_repo_stars_event_max_datetime stringdate 2015-01-01 12:37:38 2022-03-31 23:59:52 ⌀ | max_issues_repo_path stringlengths 3 363 | max_issues_repo_name stringlengths 5 118 | max_issues_repo_head_hexsha stringlengths 40 40 | max_issues_repo_licenses listlengths 1 10 | max_issues_count float64 1 134k ⌀ | max_issues_repo_issues_event_min_datetime stringlengths 24 24 ⌀ | max_issues_repo_issues_event_max_datetime stringlengths 24 24 ⌀ | max_forks_repo_path stringlengths 3 363 | max_forks_repo_name stringlengths 5 135 | max_forks_repo_head_hexsha stringlengths 40 40 | max_forks_repo_licenses listlengths 1 10 | max_forks_count float64 1 105k ⌀ | max_forks_repo_forks_event_min_datetime stringdate 2015-01-01 00:01:02 2022-03-31 23:27:27 ⌀ | max_forks_repo_forks_event_max_datetime stringdate 2015-01-03 08:55:07 2022-03-31 23:59:24 ⌀ | content stringlengths 5 1.05M | avg_line_length float64 1.13 1.04M | max_line_length int64 1 1.05M | alphanum_fraction float64 0 1 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
eb7532f9a9bdf5e05e35f12cc7fc73ce928e97f6 | 6,600 | h | C | Crawler/Install Files/pygame/src/doc/examples_doc.h | hanvo/MusicCloud | b91b9481df087955fcb09f472308c9ad1a94ba94 | [
"BSD-3-Clause"
] | null | null | null | Crawler/Install Files/pygame/src/doc/examples_doc.h | hanvo/MusicCloud | b91b9481df087955fcb09f472308c9ad1a94ba94 | [
"BSD-3-Clause"
] | null | null | null | Crawler/Install Files/pygame/src/doc/examples_doc.h | hanvo/MusicCloud | b91b9481df087955fcb09f472308c9ad1a94ba94 | [
"BSD-3-Clause"
] | null | null | null | /* Auto generated file: with makeref.py . Docs go in src/ *.doc . */
#define DOC_PYGAMEEXAMPLES "module of example programs"
#define DOC_PYGAMEEXAMPLESALIENSMAIN "aliens.main() -> None\nplay the full aliens example"
#define DOC_PYGAMEEXAMPLESOLDALIENMAIN "oldalien.main() -> None\nplay the original aliens example"
#define DOC_PYGAMEEXAMPLESSTARSMAIN "stars.main() -> None\nrun a simple starfield example"
#define DOC_PYGAMEEXAMPLESCHIMPMAIN "chimp.main() -> None\nhit the moving chimp"
#define DOC_PYGAMEEXAMPLESMOVEITMAIN "moveit.main() -> None\ndisplay animated objects on the screen"
#define DOC_PYGAMEEXAMPLESFONTYMAIN "fonty.main() -> None\nrun a font rendering example"
#define DOC_PYGAMEEXAMPLESFREETYPEMISCMAIN "freetype_misc.main() -> None\nrun a freetype rendering example"
#define DOC_PYGAMEEXAMPLESVGRADEMAIN "vgrade.main() -> None\ndisplay a vertical gradient"
#define DOC_PYGAMEEXAMPLESEVENTLISTMAIN "eventlist.main() -> None\ndisplay pygame events"
#define DOC_PYGAMEEXAMPLESARRAYDEMOMAIN "arraydemo.main(arraytype=None) -> None\nshow various surfarray effects"
#define DOC_PYGAMEEXAMPLESSOUNDMAIN "sound.main(file_path=None) -> None\nload and play a sound"
#define DOC_PYGAMEEXAMPLESSOUNDARRAYDEMOSMAIN "sound_array_demos.main(arraytype=None) -> None\nplay various sndarray effects"
#define DOC_PYGAMEEXAMPLESLIQUIDMAIN "liquid.main() -> None\ndisplay an animated liquid effect"
#define DOC_PYGAMEEXAMPLESGLCUBEMAIN "glcube.main() -> None\ndisplay an animated 3D cube using OpenGL"
#define DOC_PYGAMEEXAMPLESSCRAPCLIPBOARDMAIN "scrap_clipboard.main() -> None\naccess the clipboard"
#define DOC_PYGAMEEXAMPLESMASKMAIN "mask.main(*args) -> None\ndisplay multiple images bounce off each other using collision detection"
#define DOC_PYGAMEEXAMPLESTESTSPRITEMAIN "testsprite.main(update_rects = True, use_static = False, use_FastRenderGroup = False, screen_dims = [640, 480], use_alpha = False, flags = 0) -> None\nshow lots of sprites moving around"
#define DOC_PYGAMEEXAMPLESHEADLESSNOWINDOWSNEEDEDMAIN "headless_no_windows_needed.main(fin, fout, w, h) -> None\nwrite an image file that is smoothscaled copy of an input file"
#define DOC_PYGAMEEXAMPLESFASTEVENTSMAIN "fastevents.main() -> None\nstress test the fastevents module"
#define DOC_PYGAMEEXAMPLESOVERLAYMAIN "overlay.main(fname) -> None\nplay a .pgm video using overlays"
#define DOC_PYGAMEEXAMPLESBLENDFILLMAIN "blend_fill.main() -> None\ndemonstrate the various surface.fill method blend options"
#define DOC_PYGAMEEXAMPLESBLITBLENDSMAIN "blit_blends.main() -> None\nuses alternative additive fill to that of surface.fill"
#define DOC_PYGAMEEXAMPLESCURSORSMAIN "cursors.main() -> None\ndisplay two different custom cursors"
#define DOC_PYGAMEEXAMPLESPIXELARRAYMAIN "pixelarray.main() -> None\ndisplay various pixelarray generated effects"
#define DOC_PYGAMEEXAMPLESSCALETESTMAIN "scaletest.main(imagefile, convert_alpha=False, run_speed_test=True) -> None\ninteractively scale an image using smoothscale"
#define DOC_PYGAMEEXAMPLESMIDIMAIN "midi.main(mode='output', device_id=None) -> None\nrun a midi example"
#define DOC_PYGAMEEXAMPLESSCROLLMAIN "scroll.main(image_file=None) -> None\nrun a Surface.scroll example that shows a magnified image"
#define DOC_PYGAMEEXAMPLESMOVIEPLAYERMAIN "movieplayer.main(filepath) -> None\nplay an MPEG movie"
#define DOC_PYGAMEEXAMPLESCAMERAMAIN "camera.main() -> None\ndisplay video captured live from an attached camera"
/* Docs in a comment... slightly easier to read. */
/*
pygame.examples
module of example programs
pygame.examples.aliens.main
aliens.main() -> None
play the full aliens example
pygame.examples.oldalien.main
oldalien.main() -> None
play the original aliens example
pygame.examples.stars.main
stars.main() -> None
run a simple starfield example
pygame.examples.chimp.main
chimp.main() -> None
hit the moving chimp
pygame.examples.moveit.main
moveit.main() -> None
display animated objects on the screen
pygame.examples.fonty.main
fonty.main() -> None
run a font rendering example
pygame.examples.freetype_misc.main
freetype_misc.main() -> None
run a freetype rendering example
pygame.examples.vgrade.main
vgrade.main() -> None
display a vertical gradient
pygame.examples.eventlist.main
eventlist.main() -> None
display pygame events
pygame.examples.arraydemo.main
arraydemo.main(arraytype=None) -> None
show various surfarray effects
pygame.examples.sound.main
sound.main(file_path=None) -> None
load and play a sound
pygame.examples.sound_array_demos.main
sound_array_demos.main(arraytype=None) -> None
play various sndarray effects
pygame.examples.liquid.main
liquid.main() -> None
display an animated liquid effect
pygame.examples.glcube.main
glcube.main() -> None
display an animated 3D cube using OpenGL
pygame.examples.scrap_clipboard.main
scrap_clipboard.main() -> None
access the clipboard
pygame.examples.mask.main
mask.main(*args) -> None
display multiple images bounce off each other using collision detection
pygame.examples.testsprite.main
testsprite.main(update_rects = True, use_static = False, use_FastRenderGroup = False, screen_dims = [640, 480], use_alpha = False, flags = 0) -> None
show lots of sprites moving around
pygame.examples.headless_no_windows_needed.main
headless_no_windows_needed.main(fin, fout, w, h) -> None
write an image file that is smoothscaled copy of an input file
pygame.examples.fastevents.main
fastevents.main() -> None
stress test the fastevents module
pygame.examples.overlay.main
overlay.main(fname) -> None
play a .pgm video using overlays
pygame.examples.blend_fill.main
blend_fill.main() -> None
demonstrate the various surface.fill method blend options
pygame.examples.blit_blends.main
blit_blends.main() -> None
uses alternative additive fill to that of surface.fill
pygame.examples.cursors.main
cursors.main() -> None
display two different custom cursors
pygame.examples.pixelarray.main
pixelarray.main() -> None
display various pixelarray generated effects
pygame.examples.scaletest.main
scaletest.main(imagefile, convert_alpha=False, run_speed_test=True) -> None
interactively scale an image using smoothscale
pygame.examples.midi.main
midi.main(mode='output', device_id=None) -> None
run a midi example
pygame.examples.scroll.main
scroll.main(image_file=None) -> None
run a Surface.scroll example that shows a magnified image
pygame.examples.movieplayer.main
movieplayer.main(filepath) -> None
play an MPEG movie
pygame.examples.camera.main
camera.main() -> None
display video captured live from an attached camera
*/ | 35.294118 | 228 | 0.798485 |
6fae1c26244652bdfbc426ea8272f08422eadd5d | 14,836 | h | C | drivers/staging/media/atomisp/pci/css_2401_system/hrt/mipi_backend_defs.h | jainsakshi2395/linux | 7ccb860232bb83fb60cd6bcf5aaf0c008d903acb | [
"Linux-OpenIB"
] | 44 | 2022-03-16T08:32:31.000Z | 2022-03-31T16:02:35.000Z | drivers/staging/media/atomisp/pci/css_2401_system/hrt/mipi_backend_defs.h | jainsakshi2395/linux | 7ccb860232bb83fb60cd6bcf5aaf0c008d903acb | [
"Linux-OpenIB"
] | 13 | 2021-07-10T04:36:17.000Z | 2022-03-03T10:50:05.000Z | drivers/staging/media/atomisp/pci/css_2401_system/hrt/mipi_backend_defs.h | jainsakshi2395/linux | 7ccb860232bb83fb60cd6bcf5aaf0c008d903acb | [
"Linux-OpenIB"
] | 18 | 2022-03-19T04:41:04.000Z | 2022-03-31T03:32:12.000Z | /* SPDX-License-Identifier: GPL-2.0 */
/*
* Support for Intel Camera Imaging ISP subsystem.
* Copyright (c) 2015, Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*/
#ifndef _mipi_backend_defs_h
#define _mipi_backend_defs_h
#include "mipi_backend_common_defs.h"
#define MIPI_BACKEND_REG_ALIGN 4 // assuming 32 bit control bus width
#define _HRT_MIPI_BACKEND_NOF_IRQS 3 // sid_lut
// SH Backend Register IDs
#define _HRT_MIPI_BACKEND_ENABLE_REG_IDX 0
#define _HRT_MIPI_BACKEND_STATUS_REG_IDX 1
//#define _HRT_MIPI_BACKEND_HIGH_PREC_REG_IDX 2
#define _HRT_MIPI_BACKEND_COMP_FORMAT_REG0_IDX 2
#define _HRT_MIPI_BACKEND_COMP_FORMAT_REG1_IDX 3
#define _HRT_MIPI_BACKEND_COMP_FORMAT_REG2_IDX 4
#define _HRT_MIPI_BACKEND_COMP_FORMAT_REG3_IDX 5
#define _HRT_MIPI_BACKEND_RAW16_CONFIG_REG_IDX 6
#define _HRT_MIPI_BACKEND_RAW18_CONFIG_REG_IDX 7
#define _HRT_MIPI_BACKEND_FORCE_RAW8_REG_IDX 8
#define _HRT_MIPI_BACKEND_IRQ_STATUS_REG_IDX 9
#define _HRT_MIPI_BACKEND_IRQ_CLEAR_REG_IDX 10
////
#define _HRT_MIPI_BACKEND_CUST_EN_REG_IDX 11
#define _HRT_MIPI_BACKEND_CUST_DATA_STATE_REG_IDX 12
#define _HRT_MIPI_BACKEND_CUST_PIX_EXT_S0P0_REG_IDX 13
#define _HRT_MIPI_BACKEND_CUST_PIX_EXT_S0P1_REG_IDX 14
#define _HRT_MIPI_BACKEND_CUST_PIX_EXT_S0P2_REG_IDX 15
#define _HRT_MIPI_BACKEND_CUST_PIX_EXT_S0P3_REG_IDX 16
#define _HRT_MIPI_BACKEND_CUST_PIX_EXT_S1P0_REG_IDX 17
#define _HRT_MIPI_BACKEND_CUST_PIX_EXT_S1P1_REG_IDX 18
#define _HRT_MIPI_BACKEND_CUST_PIX_EXT_S1P2_REG_IDX 19
#define _HRT_MIPI_BACKEND_CUST_PIX_EXT_S1P3_REG_IDX 20
#define _HRT_MIPI_BACKEND_CUST_PIX_EXT_S2P0_REG_IDX 21
#define _HRT_MIPI_BACKEND_CUST_PIX_EXT_S2P1_REG_IDX 22
#define _HRT_MIPI_BACKEND_CUST_PIX_EXT_S2P2_REG_IDX 23
#define _HRT_MIPI_BACKEND_CUST_PIX_EXT_S2P3_REG_IDX 24
#define _HRT_MIPI_BACKEND_CUST_PIX_VALID_EOP_REG_IDX 25
////
#define _HRT_MIPI_BACKEND_GLOBAL_LUT_DISREGARD_REG_IDX 26
#define _HRT_MIPI_BACKEND_PKT_STALL_STATUS_REG_IDX 27
//#define _HRT_MIPI_BACKEND_SP_LUT_ENABLE_REG_IDX 28
#define _HRT_MIPI_BACKEND_SP_LUT_ENTRY_0_REG_IDX 28
#define _HRT_MIPI_BACKEND_SP_LUT_ENTRY_1_REG_IDX 29
#define _HRT_MIPI_BACKEND_SP_LUT_ENTRY_2_REG_IDX 30
#define _HRT_MIPI_BACKEND_SP_LUT_ENTRY_3_REG_IDX 31
#define _HRT_MIPI_BACKEND_NOF_REGISTERS 32 // excluding the LP LUT entries
#define _HRT_MIPI_BACKEND_LP_LUT_ENTRY_0_REG_IDX 32
/////////////////////////////////////////////////////////////////////////////////////////////////////
#define _HRT_MIPI_BACKEND_ENABLE_REG_WIDTH 1
#define _HRT_MIPI_BACKEND_STATUS_REG_WIDTH 1
//#define _HRT_MIPI_BACKEND_HIGH_PREC_REG_WIDTH 1
#define _HRT_MIPI_BACKEND_COMP_FORMAT_REG_WIDTH 32
#define _HRT_MIPI_BACKEND_RAW16_CONFIG_REG_WIDTH 7
#define _HRT_MIPI_BACKEND_RAW18_CONFIG_REG_WIDTH 9
#define _HRT_MIPI_BACKEND_FORCE_RAW8_REG_WIDTH 8
#define _HRT_MIPI_BACKEND_IRQ_STATUS_REG_WIDTH _HRT_MIPI_BACKEND_NOF_IRQS
#define _HRT_MIPI_BACKEND_IRQ_CLEAR_REG_WIDTH 0
#define _HRT_MIPI_BACKEND_GLOBAL_LUT_DISREGARD_REG_WIDTH 1
#define _HRT_MIPI_BACKEND_PKT_STALL_STATUS_REG_WIDTH 1 + 2 + 6
//#define _HRT_MIPI_BACKEND_SP_LUT_ENABLE_REG_WIDTH 1
//#define _HRT_MIPI_BACKEND_SP_LUT_ENTRY_0_REG_WIDTH 7
//#define _HRT_MIPI_BACKEND_SP_LUT_ENTRY_1_REG_WIDTH 7
//#define _HRT_MIPI_BACKEND_SP_LUT_ENTRY_2_REG_WIDTH 7
//#define _HRT_MIPI_BACKEND_SP_LUT_ENTRY_3_REG_WIDTH 7
/////////////////////////////////////////////////////////////////////////////////////////////////////
#define _HRT_MIPI_BACKEND_NOF_SP_LUT_ENTRIES 4
//#define _HRT_MIPI_BACKEND_MAX_NOF_LP_LUT_ENTRIES 16 // to satisfy hss model static array declaration
#define _HRT_MIPI_BACKEND_CHANNEL_ID_WIDTH 2
#define _HRT_MIPI_BACKEND_FORMAT_TYPE_WIDTH 6
#define _HRT_MIPI_BACKEND_PACKET_ID_WIDTH _HRT_MIPI_BACKEND_CHANNEL_ID_WIDTH + _HRT_MIPI_BACKEND_FORMAT_TYPE_WIDTH
#define _HRT_MIPI_BACKEND_STREAMING_PIX_A_LSB 0
#define _HRT_MIPI_BACKEND_STREAMING_PIX_A_MSB(pix_width) (_HRT_MIPI_BACKEND_STREAMING_PIX_A_LSB + (pix_width) - 1)
#define _HRT_MIPI_BACKEND_STREAMING_PIX_A_VAL_BIT(pix_width) (_HRT_MIPI_BACKEND_STREAMING_PIX_A_MSB(pix_width) + 1)
#define _HRT_MIPI_BACKEND_STREAMING_PIX_B_LSB(pix_width) (_HRT_MIPI_BACKEND_STREAMING_PIX_A_VAL_BIT(pix_width) + 1)
#define _HRT_MIPI_BACKEND_STREAMING_PIX_B_MSB(pix_width) (_HRT_MIPI_BACKEND_STREAMING_PIX_B_LSB(pix_width) + (pix_width) - 1)
#define _HRT_MIPI_BACKEND_STREAMING_PIX_B_VAL_BIT(pix_width) (_HRT_MIPI_BACKEND_STREAMING_PIX_B_MSB(pix_width) + 1)
#define _HRT_MIPI_BACKEND_STREAMING_SOP_BIT(pix_width) (_HRT_MIPI_BACKEND_STREAMING_PIX_B_VAL_BIT(pix_width) + 1)
#define _HRT_MIPI_BACKEND_STREAMING_EOP_BIT(pix_width) (_HRT_MIPI_BACKEND_STREAMING_SOP_BIT(pix_width) + 1)
#define _HRT_MIPI_BACKEND_STREAMING_WIDTH(pix_width) (_HRT_MIPI_BACKEND_STREAMING_EOP_BIT(pix_width) + 1)
/*************************************************************************************************/
/* Custom Decoding */
/* These Custom Defs are defined based on design-time config in "mipi_backend_pixel_formatter.chdl" !! */
/*************************************************************************************************/
#define _HRT_MIPI_BACKEND_CUST_EN_IDX 0 /* 2bits */
#define _HRT_MIPI_BACKEND_CUST_EN_DATAID_IDX 2 /* 6bits MIPI DATA ID */
#define _HRT_MIPI_BACKEND_CUST_EN_HIGH_PREC_IDX 8 // 1 bit
#define _HRT_MIPI_BACKEND_CUST_EN_WIDTH 9
#define _HRT_MIPI_BACKEND_CUST_MODE_ALL 1 /* Enable Custom Decoding for all DATA IDs */
#define _HRT_MIPI_BACKEND_CUST_MODE_ONE 3 /* Enable Custom Decoding for ONE DATA ID, programmed in CUST_EN_DATA_ID */
#define _HRT_MIPI_BACKEND_CUST_EN_OPTION_IDX 1
/* Data State config = {get_bits(6bits), valid(1bit)} */
#define _HRT_MIPI_BACKEND_CUST_DATA_STATE_S0_IDX 0 /* 7bits */
#define _HRT_MIPI_BACKEND_CUST_DATA_STATE_S1_IDX 8 /* 7bits */
#define _HRT_MIPI_BACKEND_CUST_DATA_STATE_S2_IDX 16 /* was 14 7bits */
#define _HRT_MIPI_BACKEND_CUST_DATA_STATE_WIDTH 24 /* was 21*/
#define _HRT_MIPI_BACKEND_CUST_DATA_STATE_VALID_IDX 0 /* 1bits */
#define _HRT_MIPI_BACKEND_CUST_DATA_STATE_GETBITS_IDX 1 /* 6bits */
/* Pixel Extractor config */
#define _HRT_MIPI_BACKEND_CUST_PIX_EXT_DATA_ALIGN_IDX 0 /* 6bits */
#define _HRT_MIPI_BACKEND_CUST_PIX_EXT_PIX_ALIGN_IDX 6 /* 5bits */
#define _HRT_MIPI_BACKEND_CUST_PIX_EXT_PIX_MASK_IDX 11 /* was 10 18bits */
#define _HRT_MIPI_BACKEND_CUST_PIX_EXT_PIX_EN_IDX 29 /* was 28 1bits */
#define _HRT_MIPI_BACKEND_CUST_PIX_EXT_WIDTH 30 /* was 29 */
/* Pixel Valid & EoP config = {[eop,valid](especial), [eop,valid](normal)} */
#define _HRT_MIPI_BACKEND_CUST_PIX_VALID_EOP_P0_IDX 0 /* 4bits */
#define _HRT_MIPI_BACKEND_CUST_PIX_VALID_EOP_P1_IDX 4 /* 4bits */
#define _HRT_MIPI_BACKEND_CUST_PIX_VALID_EOP_P2_IDX 8 /* 4bits */
#define _HRT_MIPI_BACKEND_CUST_PIX_VALID_EOP_P3_IDX 12 /* 4bits */
#define _HRT_MIPI_BACKEND_CUST_PIX_VALID_EOP_WIDTH 16
#define _HRT_MIPI_BACKEND_CUST_PIX_VALID_EOP_NOR_VALID_IDX 0 /* Normal (NO less get_bits case) Valid - 1bits */
#define _HRT_MIPI_BACKEND_CUST_PIX_VALID_EOP_NOR_EOP_IDX 1 /* Normal (NO less get_bits case) EoP - 1bits */
#define _HRT_MIPI_BACKEND_CUST_PIX_VALID_EOP_ESP_VALID_IDX 2 /* Especial (less get_bits case) Valid - 1bits */
#define _HRT_MIPI_BACKEND_CUST_PIX_VALID_EOP_ESP_EOP_IDX 3 /* Especial (less get_bits case) EoP - 1bits */
/*************************************************************************************************/
/* MIPI backend output streaming interface definition */
/* These parameters define the fields within the streaming bus. These should also be used by the */
/* subsequent block, ie stream2mmio. */
/*************************************************************************************************/
/* The pipe backend - stream2mmio should be design time configurable in */
/* PixWidth - Number of bits per pixel */
/* PPC - Pixel per Clocks */
/* NumSids - Max number of source Ids (ifc's) and derived from that: */
/* SidWidth - Number of bits required for the sid parameter */
/* In order to keep this configurability, below Macro's have these as a parameter */
/*************************************************************************************************/
#define HRT_MIPI_BACKEND_STREAM_EOP_BIT 0
#define HRT_MIPI_BACKEND_STREAM_SOP_BIT 1
#define HRT_MIPI_BACKEND_STREAM_EOF_BIT 2
#define HRT_MIPI_BACKEND_STREAM_SOF_BIT 3
#define HRT_MIPI_BACKEND_STREAM_CHID_LS_BIT 4
#define HRT_MIPI_BACKEND_STREAM_CHID_MS_BIT(sid_width) (HRT_MIPI_BACKEND_STREAM_CHID_LS_BIT + (sid_width) - 1)
#define HRT_MIPI_BACKEND_STREAM_PIX_VAL_BIT(sid_width, p) (HRT_MIPI_BACKEND_STREAM_CHID_MS_BIT(sid_width) + 1 + p)
#define HRT_MIPI_BACKEND_STREAM_PIX_LS_BIT(sid_width, ppc, pix_width, p) (HRT_MIPI_BACKEND_STREAM_PIX_VAL_BIT(sid_width, ppc) + ((pix_width) * p))
#define HRT_MIPI_BACKEND_STREAM_PIX_MS_BIT(sid_width, ppc, pix_width, p) (HRT_MIPI_BACKEND_STREAM_PIX_LS_BIT(sid_width, ppc, pix_width, p) + (pix_width) - 1)
#if 0
//#define HRT_MIPI_BACKEND_STREAM_PIX_BITS 14
//#define HRT_MIPI_BACKEND_STREAM_CHID_BITS 4
//#define HRT_MIPI_BACKEND_STREAM_PPC 4
#endif
#define HRT_MIPI_BACKEND_STREAM_BITS(sid_width, ppc, pix_width) (HRT_MIPI_BACKEND_STREAM_PIX_MS_BIT(sid_width, ppc, pix_width, (ppc - 1)) + 1)
/* SP and LP LUT BIT POSITIONS */
#define HRT_MIPI_BACKEND_LUT_PKT_DISREGARD_BIT 0 // 0
#define HRT_MIPI_BACKEND_LUT_SID_LS_BIT HRT_MIPI_BACKEND_LUT_PKT_DISREGARD_BIT + 1 // 1
#define HRT_MIPI_BACKEND_LUT_SID_MS_BIT(sid_width) (HRT_MIPI_BACKEND_LUT_SID_LS_BIT + (sid_width) - 1) // 1 + (4) - 1 = 4
#define HRT_MIPI_BACKEND_LUT_MIPI_CH_ID_LS_BIT(sid_width) HRT_MIPI_BACKEND_LUT_SID_MS_BIT(sid_width) + 1 // 5
#define HRT_MIPI_BACKEND_LUT_MIPI_CH_ID_MS_BIT(sid_width) HRT_MIPI_BACKEND_LUT_MIPI_CH_ID_LS_BIT(sid_width) + _HRT_MIPI_BACKEND_CHANNEL_ID_WIDTH - 1 // 6
#define HRT_MIPI_BACKEND_LUT_MIPI_FMT_LS_BIT(sid_width) HRT_MIPI_BACKEND_LUT_MIPI_CH_ID_MS_BIT(sid_width) + 1 // 7
#define HRT_MIPI_BACKEND_LUT_MIPI_FMT_MS_BIT(sid_width) HRT_MIPI_BACKEND_LUT_MIPI_FMT_LS_BIT(sid_width) + _HRT_MIPI_BACKEND_FORMAT_TYPE_WIDTH - 1 // 12
/* #define HRT_MIPI_BACKEND_SP_LUT_BITS(sid_width) HRT_MIPI_BACKEND_LUT_MIPI_CH_ID_MS_BIT(sid_width) + 1 // 7 */
#define HRT_MIPI_BACKEND_SP_LUT_BITS(sid_width) HRT_MIPI_BACKEND_LUT_SID_MS_BIT(sid_width) + 1
#define HRT_MIPI_BACKEND_LP_LUT_BITS(sid_width) HRT_MIPI_BACKEND_LUT_MIPI_FMT_MS_BIT(sid_width) + 1 // 13
// temp solution
//#define HRT_MIPI_BACKEND_STREAM_PIXA_VAL_BIT HRT_MIPI_BACKEND_STREAM_CHID_MS_BIT + 1 // 8
//#define HRT_MIPI_BACKEND_STREAM_PIXB_VAL_BIT HRT_MIPI_BACKEND_STREAM_PIXA_VAL_BIT + 1 // 9
//#define HRT_MIPI_BACKEND_STREAM_PIXC_VAL_BIT HRT_MIPI_BACKEND_STREAM_PIXB_VAL_BIT + 1 // 10
//#define HRT_MIPI_BACKEND_STREAM_PIXD_VAL_BIT HRT_MIPI_BACKEND_STREAM_PIXC_VAL_BIT + 1 // 11
//#define HRT_MIPI_BACKEND_STREAM_PIXA_LS_BIT HRT_MIPI_BACKEND_STREAM_PIXD_VAL_BIT + 1 // 12
//#define HRT_MIPI_BACKEND_STREAM_PIXA_MS_BIT HRT_MIPI_BACKEND_STREAM_PIXA_LS_BIT + HRT_MIPI_BACKEND_STREAM_PIX_BITS - 1 // 25
//#define HRT_MIPI_BACKEND_STREAM_PIXB_LS_BIT HRT_MIPI_BACKEND_STREAM_PIXA_MS_BIT + 1 // 26
//#define HRT_MIPI_BACKEND_STREAM_PIXB_MS_BIT HRT_MIPI_BACKEND_STREAM_PIXB_LS_BIT + HRT_MIPI_BACKEND_STREAM_PIX_BITS - 1 // 39
//#define HRT_MIPI_BACKEND_STREAM_PIXC_LS_BIT HRT_MIPI_BACKEND_STREAM_PIXB_MS_BIT + 1 // 40
//#define HRT_MIPI_BACKEND_STREAM_PIXC_MS_BIT HRT_MIPI_BACKEND_STREAM_PIXC_LS_BIT + HRT_MIPI_BACKEND_STREAM_PIX_BITS - 1 // 53
//#define HRT_MIPI_BACKEND_STREAM_PIXD_LS_BIT HRT_MIPI_BACKEND_STREAM_PIXC_MS_BIT + 1 // 54
//#define HRT_MIPI_BACKEND_STREAM_PIXD_MS_BIT HRT_MIPI_BACKEND_STREAM_PIXD_LS_BIT + HRT_MIPI_BACKEND_STREAM_PIX_BITS - 1 // 67
// vc hidden in pixb data (passed as raw12 the pipe)
#define HRT_MIPI_BACKEND_STREAM_VC_LS_BIT(sid_width, ppc, pix_width) HRT_MIPI_BACKEND_STREAM_PIX_LS_BIT(sid_width, ppc, pix_width, 1) + 10 //HRT_MIPI_BACKEND_STREAM_PIXB_LS_BIT + 10 // 36
#define HRT_MIPI_BACKEND_STREAM_VC_MS_BIT(sid_width, ppc, pix_width) HRT_MIPI_BACKEND_STREAM_VC_LS_BIT(sid_width, ppc, pix_width) + 1 // 37
#endif /* _mipi_backend_defs_h */
| 70.647619 | 189 | 0.66278 |
cbee98642e2f461a433a3c64a93bb46397632489 | 3,215 | h | C | MediaRemote.framework/MRAVOutputContext.h | reels-research/iOS-Private-Frameworks | 9a4f4534939310a51fdbf5a439dd22487efb0f01 | [
"MIT"
] | 4 | 2021-10-06T12:15:26.000Z | 2022-02-21T02:26:00.000Z | MediaRemote.framework/MRAVOutputContext.h | reels-research/iOS-Private-Frameworks | 9a4f4534939310a51fdbf5a439dd22487efb0f01 | [
"MIT"
] | null | null | null | MediaRemote.framework/MRAVOutputContext.h | reels-research/iOS-Private-Frameworks | 9a4f4534939310a51fdbf5a439dd22487efb0f01 | [
"MIT"
] | 1 | 2021-10-08T07:40:53.000Z | 2021-10-08T07:40:53.000Z | /* Generated by RuntimeBrowser
Image: /System/Library/PrivateFrameworks/MediaRemote.framework/MediaRemote
*/
@interface MRAVOutputContext : NSObject {
bool _attemptingLogicalDeviceRecovery;
AVOutputContext * _avOutputContext;
bool _handleDiscoverySessionOutputDevicesChangedScheduled;
bool _handleOutputDeviceChangedScheduled;
bool _handleOutputDevicesChangedScheduled;
bool _isVolumeControlAvailable;
MRAVOutputDeviceSourceInfo * _outputDeviceSourceInfo;
NSArray * _outputDevices;
NSMutableArray * _pendingModifications;
bool _postOutputDeviceChangedScheduled;
bool _postOutputDevicesChangedScheduled;
NSObject<OS_dispatch_queue> * _serialQueue;
unsigned int _type;
NSString * _uniqueIdentifier;
}
@property (nonatomic, readonly) AVOutputContext *avOutputContext;
@property (nonatomic, copy) NSArray *outputDevices;
@property (nonatomic, readonly) bool supportsVolumeControl;
@property (nonatomic, readonly) unsigned int type;
@property (nonatomic, readonly) NSString *uniqueIdentifier;
@property (nonatomic) float volume;
@property (getter=isVolumeControlAvailable, nonatomic, readonly) bool volumeControlAvailable;
+ (void)_initializeAVFNotificationForwarding;
+ (id)_notificationQueue;
+ (id)_sharedOutputContextFromType:(unsigned int)arg1;
+ (id)createOutputContextWithUniqueIdentifier:(id)arg1;
+ (id)sharedAudioPresentationContext;
+ (id)sharedSystemAudioContext;
+ (id)sharedSystemScreenContext;
- (void).cxx_destruct;
- (void)_clearAnyCompletedModifications;
- (void)_commitModification:(id)arg1;
- (bool)_contextSupportsMultipleDevices;
- (void)_handleDiscoverySessionOutputDevicesDidChangeNotification:(id)arg1;
- (void)_handleOutputDeviceCanSetVolumeDidChangeNotification:(id)arg1;
- (void)_handleOutputDeviceDidChangeNotification:(id)arg1;
- (void)_handleOutputDeviceSupportsVolumeDidChangeNotification:(id)arg1;
- (void)_handleOutputDeviceVolumeDidChangeNotification:(id)arg1;
- (void)_handleOutputDevicesDidChangeNotification:(id)arg1;
- (void)_outputContextChangeInitiatedNotification:(id)arg1;
- (id)_pendingModifications;
- (void)_registerNotifications;
- (void)_reloadOutputDevicesForInitialLoad:(bool)arg1;
- (void)_scheduleOutputContextDeviceDidChangeNotification;
- (void)_scheduleOutputContextDevicesDidChangeNotification;
- (void)_unregisterNotifications;
- (void)addOutputDevices:(id)arg1 withCallbackQueue:(id)arg2 block:(id /* block */)arg3;
- (void)attemptLogicalDeviceRecovery;
- (id)avOutputContext;
- (void)dealloc;
- (id)description;
- (id)initWithAVOutputContext:(id)arg1 type:(unsigned int)arg2;
- (bool)isVolumeControlAvailable;
- (id)localDevice;
- (id)outputDevices;
- (void)removeAllOutputDevicesWithCallbackQueue:(id)arg1 block:(id /* block */)arg2;
- (void)removeOutputDevices:(id)arg1 withCallbackQueue:(id)arg2 block:(id /* block */)arg3;
- (void)setOutputDevices:(id)arg1;
- (void)setOutputDevices:(id)arg1 withCallbackQueue:(id)arg2 block:(id /* block */)arg3;
- (void)setOutputDevices:(id)arg1 withPassword:(id)arg2 callbackQueue:(id)arg3 block:(id /* block */)arg4;
- (void)setVolume:(float)arg1;
- (bool)supportsVolumeControl;
- (unsigned int)type;
- (id)uniqueIdentifier;
- (float)volume;
@end
| 42.302632 | 106 | 0.80311 |
c4e21d43929a691d5a138f0569b8efdf0d66380f | 1,491 | h | C | Source/Core/Utils/SystemUtils_win.h | igor-sadchenko/image-uploader | d559aa0d7319660a93b036821b7b99cc53e70c7e | [
"Apache-2.0"
] | 107 | 2015-03-13T08:58:26.000Z | 2022-03-14T02:56:36.000Z | Source/Core/Utils/SystemUtils_win.h | igor-sadchenko/image-uploader | d559aa0d7319660a93b036821b7b99cc53e70c7e | [
"Apache-2.0"
] | 285 | 2015-03-12T23:08:54.000Z | 2022-02-20T15:22:31.000Z | Source/Core/Utils/SystemUtils_win.h | igor-sadchenko/image-uploader | d559aa0d7319660a93b036821b7b99cc53e70c7e | [
"Apache-2.0"
] | 40 | 2015-03-14T13:37:08.000Z | 2021-08-15T05:58:10.000Z | #ifndef IU_CORE_UTILS_SYSTEMUTILS_WIN_H
#define IU_CORE_UTILS_SYSTEMUTILS_WIN_H
#include <string>
#include <windows.h>
namespace IuCoreUtils
{
bool IsOs64Bit() {
#if _WIN64
return true;
#elif _WIN32
BOOL isWow64 = FALSE;
//IsWow64Process is not available on all supported versions of Windows.
//Use GetModuleHandle to get a handle to the DLL that contains the function
//and GetProcAddress to get a pointer to the function if available.
typedef BOOL(WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
LPFN_ISWOW64PROCESS fnIsWow64Process = (LPFN_ISWOW64PROCESS)
GetProcAddress(GetModuleHandle(TEXT("kernel32")), "IsWow64Process");
if (fnIsWow64Process) {
if (!fnIsWow64Process(GetCurrentProcess(), &isWow64))
return false;
if (isWow64)
return true;
else
return false;
} else
return false;
#else
assert(0);
return false;
#endif
}
std::string GetOsName() {
return "Windows";
}
std::string GetOsVersion() {
OSVERSIONINFOEX osvi;
ZeroMemory(&osvi, sizeof(osvi));
osvi.dwOSVersionInfoSize = sizeof(osvi);
GetVersionEx(reinterpret_cast<OSVERSIONINFO*>(&osvi));
char res[40];
sprintf(res, "%u.%u.%u SP %u.%u", osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber,
osvi.wServicePackMajor, osvi.wServicePackMinor);
return res;
}
}
#endif | 24.442623 | 100 | 0.646546 |
ae20057cfaad74258bd4d97d15bf3eb36bcb3046 | 729 | h | C | src/utility/models/VoxelContourModel.h | Shimmen/ArkoseRendererThesis | 51497768ae910587a7f03050ceda5eb1c0a9be3d | [
"MIT"
] | 2 | 2021-07-21T16:30:33.000Z | 2021-08-21T16:47:32.000Z | src/utility/models/VoxelContourModel.h | Shimmen/ArkoseRendererThesis | 51497768ae910587a7f03050ceda5eb1c0a9be3d | [
"MIT"
] | null | null | null | src/utility/models/VoxelContourModel.h | Shimmen/ArkoseRendererThesis | 51497768ae910587a7f03050ceda5eb1c0a9be3d | [
"MIT"
] | null | null | null | #pragma once
#include "utility/Model.h"
#include <vector>
class VoxelContourModel final : public Model {
public:
struct VoxelContour {
aabb3 aabb;
vec3 normal;
float distance;
uint32_t colorIndex;
};
VoxelContourModel(std::vector<VoxelContour>, std::vector<vec3> colors);
VoxelContourModel() = default;
~VoxelContourModel() = default;
bool hasMeshes() const override;
void forEachMesh(std::function<void(const Mesh&)>) const override;
const std::vector<VoxelContour>& contours() const { return m_contours; }
const std::vector<vec3>& colors() const { return m_colors; }
private:
std::vector<VoxelContour> m_contours;
std::vector<vec3> m_colors;
};
| 25.137931 | 76 | 0.679012 |
993c791be50d4f7ad82a8c40ae6f48866e80a7fb | 750 | h | C | src/common/console_inputter.h | jeroendebaat/lc3tools | b1ceb8bc28a82227ccbd17c90f6b6cfcdf324d41 | [
"Apache-2.0"
] | 58 | 2018-07-13T03:41:38.000Z | 2022-03-08T19:06:20.000Z | src/common/console_inputter.h | jeroendebaat/lc3tools | b1ceb8bc28a82227ccbd17c90f6b6cfcdf324d41 | [
"Apache-2.0"
] | 26 | 2019-12-02T05:33:00.000Z | 2022-03-12T15:54:26.000Z | src/common/console_inputter.h | jeroendebaat/lc3tools | b1ceb8bc28a82227ccbd17c90f6b6cfcdf324d41 | [
"Apache-2.0"
] | 24 | 2019-08-30T15:00:13.000Z | 2022-01-26T05:11:36.000Z | /*
* Copyright 2020 McGraw-Hill Education. All rights reserved. No reproduction or distribution without the prior written consent of McGraw-Hill Education.
*/
#ifndef CONSOLE_INPUTTER_H
#define CONSOLE_INPUTTER_H
#include "inputter.h"
namespace lc3 {
class ConsoleInputter : public utils::IInputter
{
public:
ConsoleInputter(void) = default;
~ConsoleInputter(void) = default;
virtual void beginInput(void) override;
virtual bool getChar(char & c) override;
virtual void endInput(void) override;
virtual bool hasRemaining(void) const override { return false; }
private:
#if !(defined(WIN32) || defined(_WIN32) || defined(__WIN32))
int kbhit(void);
#endif
};
};
#endif
| 25.862069 | 153 | 0.689333 |
c42b9bcb52f850916839e551cf854ff410d0421e | 1,551 | h | C | src/LogisticRegression.h | BR903/percolator | 2d9315699cf3309421b83c4c21ce8275ede87089 | [
"Apache-2.0"
] | 71 | 2015-03-30T17:22:52.000Z | 2022-01-01T14:19:23.000Z | src/LogisticRegression.h | BR903/percolator | 2d9315699cf3309421b83c4c21ce8275ede87089 | [
"Apache-2.0"
] | 190 | 2015-01-27T16:18:58.000Z | 2022-03-31T16:49:58.000Z | src/LogisticRegression.h | BR903/percolator | 2d9315699cf3309421b83c4c21ce8275ede87089 | [
"Apache-2.0"
] | 45 | 2015-04-13T13:42:35.000Z | 2021-12-17T08:26:21.000Z | /*******************************************************************************
Copyright 2006-2012 Lukas Käll <lukas.kall@scilifelab.se>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*******************************************************************************/
#ifndef LOGISTICREGRESSION_H_
#define LOGISTICREGRESSION_H_
#include <vector>
#include "BaseSpline.h"
class LogisticRegression : public BaseSpline {
public:
LogisticRegression(){};
virtual ~LogisticRegression(){};
void predict(const std::vector<double>& x, std::vector<double>& predict) {
return BaseSpline::predict(x, predict);
}
void setData(const std::vector<double>& xx, const std::vector<double>& yy,
const std::vector<double>& mm) {
BaseSpline::setData(xx);
y = yy;
m = mm;
}
protected:
virtual void calcPZW();
virtual void initg();
virtual void limitg();
virtual void limitgamma();
std::vector<double> y, m;
static const double gRange;
Array<double> p;
};
#endif /*LOGISTICREGRESSION_H_*/
| 31.653061 | 81 | 0.63314 |
e345304337fcdc10c164a071eab7102591fddec1 | 3,643 | h | C | src/verifier/state_dumper.h | jre233kei/slim | 13764ed193cc49a6008e1fdb28575e66165b045d | [
"BSD-3-Clause"
] | 18 | 2015-02-11T13:52:46.000Z | 2021-07-05T10:50:22.000Z | src/verifier/state_dumper.h | jre233kei/slim | 13764ed193cc49a6008e1fdb28575e66165b045d | [
"BSD-3-Clause"
] | 58 | 2015-01-02T11:31:12.000Z | 2022-03-23T07:16:47.000Z | src/verifier/state_dumper.h | jre233kei/slim | 13764ed193cc49a6008e1fdb28575e66165b045d | [
"BSD-3-Clause"
] | 17 | 2015-04-02T03:52:48.000Z | 2021-02-07T02:29:38.000Z | /**
* @file state_dumper.h
*
* Copyright (c) 2019, Ueda Laboratory LMNtal Group
* <lmntal@ueda.info.waseda.ac.jp>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. Neither the name of the Ueda Laboratory LMNtal Group nor the
* names of its contributors may be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef SLIM_VERIFIER_STATE_DUMPER_H
#define SLIM_VERIFIER_STATE_DUMPER_H
class StateSpace;
class State;
class LmnMembrane;
#include "lmntal.h"
#include <cstdio>
#include <memory>
#include <string>
#include <stdexcept>
/**
* A dumper class for states and statespaces.
*
* Usage:
* @code
* StateSpace *ss = ...;
* auto sd = StateDumper::from_env(stdout);
* sd->dump(ss);
* @endcode
*
* @todo インターフェースは多少整理したので中身を綺麗にする
*/
class StateDumper {
public:
virtual ~StateDumper() {}
virtual void dump(StateSpace *ss) = 0;
void dump(State *s) { dump(s, nullptr); }
//! @todo このメンバ関数をなんとかしたい
void state_print_mem(State *s);
//! Factory method used to create a dumper its format depends on command-line
//! arguments passed to SLIM.
static std::unique_ptr<StateDumper> from_env(FILE *fp) {
return std::unique_ptr<StateDumper>(from_env_ptr(fp));
}
protected:
//! use factory method instead.
StateDumper(FILE *fp) : _fp(fp) {}
void dump(State *s, const StateSpace *_owner);
void state_print_label(State *s, const StateSpace *_owner);
void state_print_transition(State *s, const StateSpace *_owner);
virtual void print_mem(LmnMembrane *mem);
//! output stream
FILE *_fp;
private:
static StateDumper *from_env_ptr(FILE *fp);
virtual MCdumpFormat dump_format() const = 0;
virtual bool need_id_foreach_trans() const = 0;
virtual std::string state_separator() const = 0;
virtual std::string trans_separator() const = 0;
virtual std::string label_begin() const = 0;
virtual std::string label_end() const = 0;
virtual void dump_state_data(State *s, unsigned long print_id,
StateSpace *owner) {
throw std::runtime_error("unexpected");
}
virtual void print_state_label(State *s, StateSpace *owner) {
throw std::runtime_error("unexpected");
}
};
#endif
| 33.118182 | 79 | 0.706286 |
64cf772329c1a9fad15d7da0d70f23cb98a044a3 | 386 | h | C | twrt/src/utils.h | lingfliu/smart_tuwa | 6dc4bcfe7ee72828e1bc34269413d8596ea65acd | [
"Apache-2.0"
] | null | null | null | twrt/src/utils.h | lingfliu/smart_tuwa | 6dc4bcfe7ee72828e1bc34269413d8596ea65acd | [
"Apache-2.0"
] | null | null | null | twrt/src/utils.h | lingfliu/smart_tuwa | 6dc4bcfe7ee72828e1bc34269413d8596ea65acd | [
"Apache-2.0"
] | null | null | null | #ifndef _UTILS_
#define _UTILS_
#include <sys/time.h>
//time functions
/*get the time difference in milli-seconds*/
long timediff_ms(struct timeval time1, struct timeval time2);
/*get the time difference in seconds*/
long timediff_s(struct timeval time1, struct timeval time2);
/*get the time difference in hours*/
long timediff_h(struct timeval time1, struct timeval time2);
#endif
| 25.733333 | 61 | 0.777202 |
fedc51f7c5dd8438e6dba4ddf9a52a5c85afc9ad | 4,583 | h | C | source/r_emwin_rx/r_emwin_rx_vx.xx/r_emwin_rx/lib/GUI/GUIDRV_TemplateI.h | HirokiIshiguro/rx-driver-package | 4af73486ecdd07ad58258625e9e8410db2fdaaba | [
"MIT"
] | null | null | null | source/r_emwin_rx/r_emwin_rx_vx.xx/r_emwin_rx/lib/GUI/GUIDRV_TemplateI.h | HirokiIshiguro/rx-driver-package | 4af73486ecdd07ad58258625e9e8410db2fdaaba | [
"MIT"
] | null | null | null | source/r_emwin_rx/r_emwin_rx_vx.xx/r_emwin_rx/lib/GUI/GUIDRV_TemplateI.h | HirokiIshiguro/rx-driver-package | 4af73486ecdd07ad58258625e9e8410db2fdaaba | [
"MIT"
] | null | null | null | /*********************************************************************
* SEGGER Microcontroller GmbH *
* Solutions for real time microcontroller applications *
**********************************************************************
* *
* (c) 1996 - 2019 SEGGER Microcontroller GmbH *
* *
* Internet: www.segger.com Support: support@segger.com *
* *
**********************************************************************
** emWin V5.50 - Graphical user interface for embedded applications **
emWin is protected by international copyright laws. Knowledge of the
source code may not be used to write a similar product. This file may
only be used in accordance with a license and should not be re-
distributed in any way. We appreciate your understanding and fairness.
----------------------------------------------------------------------
Licensing information
Licensor: SEGGER Software GmbH
Licensed to: Renesas Electronics Europe GmbH, Arcadiastrasse 10, 40472 Duesseldorf, Germany
Licensed SEGGER software: emWin
License number: GUI-00678
License model: License and Service Agreement, signed December 16th, 2016 and Amendment No. 1, signed May 16th, 2019
License valid for: RX65N, RX651, RX72M, RX72N, RX661, RX66N
----------------------------------------------------------------------
Support and Update Agreement (SUA)
SUA period: 2016-12-22 - 2019-12-31
Contact to extend SUA: sales@segger.com
----------------------------------------------------------------------
File : GUIDRV_TemplateI.h
Purpose : Interface definition for GUIDRV_TemplateI driver
---------------------------END-OF-HEADER------------------------------
*/
#ifndef GUIDRV_TEMPLATE_I_H
#define GUIDRV_TEMPLATE_I_H
#if defined(__cplusplus)
extern "C" { /* Make sure we have C-declarations in C++ programs */
#endif
/*********************************************************************
*
* Configuration structure
*/
typedef struct {
//
// Driver specific configuration items
//
int Dummy;
} CONFIG_TEMPLATE_I;
/*********************************************************************
*
* Display drivers
*/
//
// Addresses
//
extern const GUI_DEVICE_API GUIDRV_TEMPLATE_I_16_API;
extern const GUI_DEVICE_API GUIDRV_TEMPLATE_I_OY_16_API;
extern const GUI_DEVICE_API GUIDRV_TEMPLATE_I_OX_16_API;
extern const GUI_DEVICE_API GUIDRV_TEMPLATE_I_OXY_16_API;
extern const GUI_DEVICE_API GUIDRV_TEMPLATE_I_OS_16_API;
extern const GUI_DEVICE_API GUIDRV_TEMPLATE_I_OSY_16_API;
extern const GUI_DEVICE_API GUIDRV_TEMPLATE_I_OSX_16_API;
extern const GUI_DEVICE_API GUIDRV_TEMPLATE_I_OSXY_16_API;
//
// Macros to be used in configuration files
//
#if defined(WIN32) && !defined(LCD_SIMCONTROLLER)
#define GUIDRV_TEMPLATE_I_16 &GUIDRV_Win_API
#define GUIDRV_TEMPLATE_I_OY_16 &GUIDRV_Win_API
#define GUIDRV_TEMPLATE_I_OX_16 &GUIDRV_Win_API
#define GUIDRV_TEMPLATE_I_OXY_16 &GUIDRV_Win_API
#define GUIDRV_TEMPLATE_I_OS_16 &GUIDRV_Win_API
#define GUIDRV_TEMPLATE_I_OSY_16 &GUIDRV_Win_API
#define GUIDRV_TEMPLATE_I_OSX_16 &GUIDRV_Win_API
#define GUIDRV_TEMPLATE_I_OSXY_16 &GUIDRV_Win_API
#else
#define GUIDRV_TEMPLATE_I_16 &GUIDRV_TEMPLATE_I_16_API
#define GUIDRV_TEMPLATE_I_OY_16 &GUIDRV_TEMPLATE_I_OY_16_API
#define GUIDRV_TEMPLATE_I_OX_16 &GUIDRV_TEMPLATE_I_OX_16_API
#define GUIDRV_TEMPLATE_I_OXY_16 &GUIDRV_TEMPLATE_I_OXY_16_API
#define GUIDRV_TEMPLATE_I_OS_16 &GUIDRV_TEMPLATE_I_OS_16_API
#define GUIDRV_TEMPLATE_I_OSY_16 &GUIDRV_TEMPLATE_I_OSY_16_API
#define GUIDRV_TEMPLATE_I_OSX_16 &GUIDRV_TEMPLATE_I_OSX_16_API
#define GUIDRV_TEMPLATE_I_OSXY_16 &GUIDRV_TEMPLATE_I_OSXY_16_API
#endif
/*********************************************************************
*
* Public routines
*/
void GUIDRV_TemplateI_Config (GUI_DEVICE * pDevice, CONFIG_TEMPLATE_I * pConfig);
void GUIDRV_TemplateI_SetBus_XXX(GUI_DEVICE * pDevice, GUI_PORT_API * pHW_API);
void GUIDRV_TemplateI_SetFuncXXX(GUI_DEVICE * pDevice);
#if defined(__cplusplus)
}
#endif
#endif
/*************************** End of file ****************************/
| 41.288288 | 127 | 0.58237 |
5fcef20fe3ed6eed3609a066d81d5ffa48b67b9d | 266 | h | C | StRoot/StEEmcPool/muEztPanitkin/SpyCorruption.h | xiaohaijin/RHIC-STAR | a305cb0a6ac15c8165bd8f0d074d7075d5e58752 | [
"MIT"
] | 2 | 2018-12-24T19:37:00.000Z | 2022-02-28T06:57:20.000Z | StRoot/StEEmcPool/muEztPanitkin/SpyCorruption.h | xiaohaijin/RHIC-STAR | a305cb0a6ac15c8165bd8f0d074d7075d5e58752 | [
"MIT"
] | null | null | null | StRoot/StEEmcPool/muEztPanitkin/SpyCorruption.h | xiaohaijin/RHIC-STAR | a305cb0a6ac15c8165bd8f0d074d7075d5e58752 | [
"MIT"
] | null | null | null | #ifndef SpyCorruption_h
#define SpyCorruption_h
#include <TArrayF.h>
#include "SpyGeneric.h"
class SpyCorruption: public SpyGeneric {
TArrayF a0,d0;// last histo and last difference
int lastSum;
public:
SpyCorruption();
bool sense(FILE *fd);
};
#endif
| 15.647059 | 49 | 0.733083 |
38b5cf002a00486af2ed8d28de5920bd8c57e12e | 1,395 | h | C | shared/source/os_interface/windows/windows_wrapper.h | troels/compute-runtime | 3269e719a3ee7bcd97c50ec2cfe78fc8674adec0 | [
"Intel",
"MIT"
] | null | null | null | shared/source/os_interface/windows/windows_wrapper.h | troels/compute-runtime | 3269e719a3ee7bcd97c50ec2cfe78fc8674adec0 | [
"Intel",
"MIT"
] | null | null | null | shared/source/os_interface/windows/windows_wrapper.h | troels/compute-runtime | 3269e719a3ee7bcd97c50ec2cfe78fc8674adec0 | [
"Intel",
"MIT"
] | null | null | null | /*
* Copyright (C) 2018-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#if _WIN32
#include <windows.h>
#pragma warning(push)
#pragma warning(disable : 4005)
#include <ntstatus.h>
#pragma warning(pop)
// There is a conflict with max/min defined as macro in windows headers with std::max/std::min
#undef min
#undef max
#undef RegOpenKeyExA
#undef RegQueryValueExA
#pragma warning(disable : 4273)
LSTATUS APIENTRY RegOpenKeyExA(
HKEY hKey,
LPCSTR lpSubKey,
DWORD ulOptions,
REGSAM samDesired,
PHKEY phkResult);
LSTATUS APIENTRY RegQueryValueExA(
HKEY hKey,
LPCSTR lpValueName,
LPDWORD lpReserved,
LPDWORD lpType,
LPBYTE lpData,
LPDWORD lpcbData);
#else
#include <cstdint>
#if __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-value"
#endif
#include <winadapter.h>
#if __clang__
#pragma clang diagnostic pop
#endif
#include <x86intrin.h>
#define STATUS_GRAPHICS_NO_VIDEO_MEMORY ((NTSTATUS)0xC01E0100L)
#define PAGE_NOACCESS 0x01
#define PAGE_READWRITE 0x04
#define MEM_COMMIT 0x00001000
#define MEM_RESERVE 0x00002000
#define MEM_TOP_DOWN 0x00100000
#define MEM_RELEASE 0x00008000
#define MEM_FREE 0x00010000
#define DXGI_RESOURCE_PRIORITY_NORMAL 0x78000000
#define DXGI_RESOURCE_PRIORITY_HIGH 0xa0000000
#define DXGI_RESOURCE_PRIORITY_MAXIMUM 0xc8000000
#endif
#define NULL_HANDLE 0U
| 22.5 | 94 | 0.780645 |
0dfd37e0120acebeebbfc3b970e0fbde775d0b7a | 2,615 | c | C | tsl/src/fdw/fdw_utils.c | backwardn/timescaledb | b1eeb56c12c699c336245bb75dc1a843b19f949b | [
"Apache-2.0"
] | 1 | 2020-09-17T10:21:21.000Z | 2020-09-17T10:21:21.000Z | tsl/src/fdw/fdw_utils.c | backwardn/timescaledb | b1eeb56c12c699c336245bb75dc1a843b19f949b | [
"Apache-2.0"
] | null | null | null | tsl/src/fdw/fdw_utils.c | backwardn/timescaledb | b1eeb56c12c699c336245bb75dc1a843b19f949b | [
"Apache-2.0"
] | null | null | null | /*
* This file and its contents are licensed under the Timescale License.
* Please see the included NOTICE for copyright information and
* LICENSE-TIMESCALE for a copy of the license.
*/
#include <postgres.h>
#include <optimizer/paths.h>
#include <optimizer/pathnode.h>
#include <nodes/extensible.h>
#include "fdw_utils.h"
#include "fdw/relinfo.h"
#if TS_DEBUG
/*
* Copy a path.
*
* The returned path is a shallow copy that includes deep copies of a few
* fields of interest when printing debug information. Doing a deep copy of a
* Path is a lot of work so we only copy the fields we need.
*
* The copied path is intended to be used only in debug.c.
*
* Note that PostgreSQL's copyObject does not support copying Path(s) so we
* have our own copy function.
*/
static Path *
copy_path(Path *in)
{
Path *path;
RelOptInfo *parent = makeNode(RelOptInfo);
*parent = *in->parent;
switch (nodeTag(in))
{
case T_CustomPath:
{
CustomPath *cp_copy = makeNode(CustomPath);
CustomPath *cp = castNode(CustomPath, in);
ListCell *lc;
*cp_copy = *cp;
cp_copy->custom_paths = NIL;
foreach (lc, cp->custom_paths)
{
Path *p = copy_path(lfirst_node(Path, lc));
cp_copy->custom_paths = lappend(cp_copy->custom_paths, p);
}
path = &cp_copy->path;
break;
}
case T_ForeignPath:
{
ForeignPath *fp = makeNode(ForeignPath);
*fp = *castNode(ForeignPath, in);
path = &fp->path;
break;
}
default:
/* Not supported */
Assert(false);
pg_unreachable();
return in;
}
path->parent = parent;
return path;
}
static ConsideredPath *
create_considered_path(Path *path)
{
ConsideredPath *cp = palloc(sizeof(ConsideredPath));
cp->path = copy_path(path);
cp->origin = (uintptr_t) path;
return cp;
}
void
fdw_utils_add_path(RelOptInfo *rel, Path *new_path)
{
TsFdwRelInfo *fdw_info = fdw_relinfo_get(rel);
ConsideredPath *cp = create_considered_path(new_path);
/* Since add_path will deallocate thrown paths we need to create a copy here so we can print it
* later on */
fdw_info->considered_paths = lappend(fdw_info->considered_paths, cp);
add_path(rel, new_path);
}
static void
free_path(Path *path)
{
pfree(path->parent);
if (nodeTag(path) == T_CustomPath)
{
CustomPath *cp = (CustomPath *) path;
ListCell *lc;
foreach (lc, cp->custom_paths)
{
Path *p = lfirst(lc);
cp->custom_paths = list_delete_ptr(cp->custom_paths, p);
free_path(p);
}
}
pfree(path);
}
/*
* Deallocate path copy
*/
void
fdw_utils_free_path(ConsideredPath *cpath)
{
free_path(cpath->path);
pfree(cpath);
}
#endif /* TS_DEBUG */
| 20.429688 | 96 | 0.691013 |
be084bea1fb5892bd4f4358a52f9e10af16328c4 | 611 | h | C | CMSPaaSDemo/Classes/CMSPaaS.framework/Headers/CMSAdaptWidthButtonCollectionViewCell.h | fyaojie/CMSPaaSDemo | b1f2f90b41f82dd008e50bb77bcfffe40f025eca | [
"MIT"
] | null | null | null | CMSPaaSDemo/Classes/CMSPaaS.framework/Headers/CMSAdaptWidthButtonCollectionViewCell.h | fyaojie/CMSPaaSDemo | b1f2f90b41f82dd008e50bb77bcfffe40f025eca | [
"MIT"
] | null | null | null | CMSPaaSDemo/Classes/CMSPaaS.framework/Headers/CMSAdaptWidthButtonCollectionViewCell.h | fyaojie/CMSPaaSDemo | b1f2f90b41f82dd008e50bb77bcfffe40f025eca | [
"MIT"
] | null | null | null | //
// CMSAdaptWidthButtonCollectionViewCell.h
// CMSPaaS
//
// Created by sway on 2020/10/16.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface CMSAdaptWidthButtonItem : NSObject
@property (nonatomic, copy) NSString *title;
@property (nonatomic, assign) BOOL isSelected;
@property (nonatomic, copy) NSString *key;
@end
@interface CMSAdaptWidthButtonCollectionViewCell : UICollectionViewCell
@property (nonatomic, strong) UILabel *title;
@property (nonatomic, assign) CGFloat backCornerRadius;
+ (CGFloat)widthForCell:(NSString *)text byFont:(UIFont*)font;
@end
NS_ASSUME_NONNULL_END
| 23.5 | 71 | 0.772504 |
0796c396405932b498f933a7475cf999cfadcaaf | 497 | h | C | duilib/Utils/SvgUtil.h | l619534951/monitor_helper_duilib | a0df2a0285bdd37b77a611fba080dee0e55bda4f | [
"BSD-2-Clause",
"MIT"
] | null | null | null | duilib/Utils/SvgUtil.h | l619534951/monitor_helper_duilib | a0df2a0285bdd37b77a611fba080dee0e55bda4f | [
"BSD-2-Clause",
"MIT"
] | null | null | null | duilib/Utils/SvgUtil.h | l619534951/monitor_helper_duilib | a0df2a0285bdd37b77a611fba080dee0e55bda4f | [
"BSD-2-Clause",
"MIT"
] | null | null | null | #ifndef UI_UTILS_SVGUTIL_H_
#define UI_UTILS_SVGUTIL_H_
namespace ui
{
class UILIB_API SvgUtil
{
public:
static bool IsSvgFile(const std::wstring& strImageFullPath);
static std::unique_ptr<ImageInfo> LoadSvg(const std::wstring& strImageFullPath);
static std::unique_ptr<ImageInfo> LoadSvg(HGLOBAL hGlobal, const std::wstring& strImageFullPath);
private:
static std::unique_ptr<ImageInfo> LoadImageBySvg(void *svg, const std::wstring& strImageFullPath);
};
}
#endif // UI_UTILS_SVGUTIL_H_
| 23.666667 | 99 | 0.794769 |
e03dc35c18ff4bff2b44df0f1b5f0e97304e4d6c | 5,299 | c | C | 5th_sem_C_Java_VB/local system/Graphics/cia4.c | SayanGhoshBDA/code-backup | 8b6135facc0e598e9686b2e8eb2d69dd68198b80 | [
"MIT"
] | 16 | 2018-11-26T08:39:42.000Z | 2019-05-08T10:09:52.000Z | 5th_sem_C_Java_VB/local system/Graphics/cia4.c | SayanGhoshBDA/code-backup | 8b6135facc0e598e9686b2e8eb2d69dd68198b80 | [
"MIT"
] | 8 | 2020-05-04T06:29:26.000Z | 2022-02-12T05:33:16.000Z | 5th_sem_C_Java_VB/local system/Graphics/cia4.c | SayanGhoshBDA/code-backup | 8b6135facc0e598e9686b2e8eb2d69dd68198b80 | [
"MIT"
] | 5 | 2020-02-11T16:02:21.000Z | 2021-02-05T07:48:30.000Z | #include<stdio.h>
#include<graphics.h>
#include<conio.h>
#include<math.h>
int c_bgcolor,c_line;
void draw_xy();
int signx(int x);
int round1(float x);
void line_draw(int x1,int y1,int x2,int y2,int c);
int bresenham(int x1,int y1,int x2,int y2,int x[],int y[]);
void rotation(int x1,int y1,int x2,int y2,int x3,int y3,float th);
void triangle_draw(int x1,int y1,int x2,int y2,int x3,int y3);
int main()
{
int x1,y1,x2,y2,x3,y3;
float th;
clrscr();
printf("\nEnter x - coordinate of 1st point(x1) = ");
scanf("%d",&x1);
printf("\nEnter y - coordinate of 1st point(y1) = ");
scanf("%d",&y1);
printf("\nEnter x - coordinate of 2nd point(x2) = ");
scanf("%d",&x2);
printf("\nEnter y - coordinate of 2nd point(y2) = ");
scanf("%d",&y2);
printf("\nEnter x - coordinate of 3rd point(x3) = ");
scanf("%d",&x3);
printf("\nEnter y - coordinate of 3rd point(y3) = ");
scanf("%d",&y3);
printf("\nEnter rotation angle(th) = ");
scanf("%f",&th);
printf("Enter Background color(2-14) = ");
scanf("%d",&c_bgcolor);
printf("Enter Line color(1 or 15) = ");
scanf("%d",&c_line);
draw_xy();
triangle_draw(x1,y1,x2,y2,x3,y3);
rotation(x1,-y1,x2,-y2,x3,-y3,th);
getch();
closegraph();
return 0;
}
/* Function to get rounded value of a number */
int round1(float x)
{
int ix;
float x1,x2;
int s1;
ix=(int)x; /* To get whole number part from x */
if(x<0)
s1=-1;
else
s1=1;
x1=x-(float)ix; /* To get fractional part of x */
if(x1<0)
x2=-x1;
else
x2=x1;
if(x2>=.5)
{
if(s1==1)
ix=ix+1;
else
ix=ix-1;
}
return ix;
}
void rotation(int x1,int y1,int x2,int y2,int x3,int y3,float th)
{
int x11,y11,x22,y22,x33,y33;
float rot[3][3],pt[3][3],p[3][3];
int i,j,k;
rot[0][0]=cos(th*3.141593/180);
rot[0][1]=-sin(th*3.141593/180);
rot[1][0]=sin(th*3.141593/180);
rot[1][1]=cos(th*3.141593/180);
rot[0][2]=0;
rot[1][2]=0;
rot[2][0]=0;
rot[2][1]=0;
rot[2][2]=1;
pt[0][0]=x1;
pt[0][1]=x2;
pt[0][2]=x3;
pt[1][0]=y1;
pt[1][1]=y2;
pt[1][2]=y3;
pt[2][0]=1;
pt[2][1]=1;
pt[2][2]=1;
for(i=0;i<3;i++)
for(j=0;j<3;j++)
{
p[i][j]=0;
for(k=0;k<3;k++)
p[i][j]=p[i][j]+rot[i][k]*pt[k][j];
}
x11=round1(p[0][0]);
y11=round1(p[1][0]);
x22=round1(p[0][1]);
y22=round1(p[1][1]);
x33=round1(p[0][2]);
y33=round1(p[1][2]);
triangle_draw(x1,y1,x2,y2,x3,y3);
triangle_draw(x11,y11,x22,y22,x33,y33);
}
/* Function to draw x and y axes on screen */
void draw_xy()
{
int i;
int gd=DETECT,gm;
initgraph(&gd,&gm,"c://TurboC3//bgi");
setbkcolor(c_bgcolor);
/* To draw x-axis and y-axis */
for(i=0;i<640;i++)
{
putpixel(i,240,c_line);
delay(0);
}
for(i=0;i<480;i++)
{
putpixel(320,i,c_line);
delay(0);
}
/* To display +x, -x, +y, -y, O(0,0) */
outtextxy(10,245,"-X");
outtextxy(620,245,"+X");
outtextxy(325,10,"+Y");
outtextxy(325,470,"-Y");
outtextxy(325,245,"O(0,0)");
}
void line_draw(int x1,int y1,int x2,int y2,int c)
{
int x[700],y[700],i,n;
n=bresenham(x1,y1,x2,y2,x,y); /* Calling bresenham function to generate 'n' pixel co-ordinates */
/* To plot all points */
for(i=0;i<n;i++)
{
putpixel(320+x[i],240-y[i],c);
delay(0);
}
}
/* Function to generate pixel co-ordinates using Bresenham algorithm */
int bresenham(int x1,int y1,int x2,int y2,int x[],int y[])
{
int xx,yy,delx,dely,e,s1,s2,interchange,temp;
int i,dx,dy;
xx=x1;
yy=y1;
dx=x2-x1;
dy=y2-y1;
if(dx<0)
delx=-dx;
else
delx=dx;
if(dy<0)
dely=-dy;
else
dely=dy;
s1=signx(dx);
s2=signx(dy);
if(dely>delx)
{
temp=dely;
dely=delx;
delx=temp;
interchange=1;
}
else
interchange=0;
e=2*dely-delx;
for(i=0;i<=delx;i++)
{
x[i]=xx;
y[i]=yy;
while(e>=0)
{
if(interchange==1)
xx=xx+s1;
else
yy=yy+s2;
e=e-2*delx;
}
if(interchange==1)
yy=yy+s2;
else
xx=xx+s1;
e=e+2*dely;
}
return delx;
}
int signx(int x)
{
if(x<0)
return -1;
else if(x==0)
return 0;
else
return 1;
}
void triangle_draw(int x1,int y1,int x2,int y2,int x3,int y3)
{
char a[100];
line_draw(x1,y1,x2,y2,c_line);
line_draw(x2,y2,x3,y3,c_line);
line_draw(x3,y3,x1,y1,c_line);
setcolor(2);
sprintf(a,"A(%d, %d)",x1,y1);
outtextxy(320+x1,240-y1,a);
setcolor(1);
sprintf(a,"B(%d, %d)",x2,y2);
outtextxy(320+x2,240-y2,a);
setcolor(3);
sprintf(a,"C(%d, %d)",x3,y3);
outtextxy(320+x3,240-y3,a);
} | 24.532407 | 105 | 0.480845 |
6aea94e0034c7c92812a9efc5cdf49afdd0a95db | 18,429 | c | C | lib/peak_netmap.c | fichtner/libpeak | ae6b6389245e2345807e67286c80533becc1cf29 | [
"ISC"
] | 14 | 2015-04-22T13:58:15.000Z | 2020-09-27T11:04:34.000Z | lib/peak_netmap.c | packetwerk/libpeak | ae6b6389245e2345807e67286c80533becc1cf29 | [
"0BSD"
] | null | null | null | lib/peak_netmap.c | packetwerk/libpeak | ae6b6389245e2345807e67286c80533becc1cf29 | [
"0BSD"
] | 4 | 2015-05-07T07:25:26.000Z | 2020-10-01T20:36:16.000Z | /*
* Copyright (c) 2013-2014 Franco Fichtner <franco@packetwerk.com>
* Copyright (c) 2014 Alexey Saushev <alexey@packetwerk.com>
* Copyright (c) 2014 Tobias Boertitz <tobias@packetwerk.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*
* Copyright (C) 2012 Luigi Rizzo. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <peak.h>
#if !defined(NETMAP_API) || NETMAP_API != 11
const struct peak_transfers transfer_netmap = {
.attach = peak_transfer_attach,
.master = peak_transfer_master,
.slave = peak_transfer_slave,
.lock = peak_transfer_lock,
.recv = peak_transfer_recv,
.send = peak_transfer_send,
.forward = peak_transfer_forward,
.unlock = peak_transfer_unlock,
.detach = peak_transfer_detach,
};
#else
#include <errno.h>
#include <signal.h> /* signal */
#include <stdlib.h>
#include <stdio.h>
#include <inttypes.h> /* PRI* macros */
#include <string.h> /* strcmp */
#include <fcntl.h> /* open */
#include <unistd.h> /* close */
#include <ifaddrs.h> /* getifaddrs */
#include <sys/mman.h> /* PROT_* */
#include <sys/ioctl.h> /* ioctl */
#include <sys/poll.h>
#include <sys/socket.h> /* sockaddr.. */
#include <arpa/inet.h> /* ntohs */
#include <sys/param.h>
#include <sys/sysctl.h> /* sysctl */
#include <sys/time.h> /* timersub */
#include <net/ethernet.h>
#include <net/if.h> /* ifreq */
#include <netinet/in.h>
#include <netinet/if_ether.h>
#include <netinet/in_systm.h>
#include <net/netmap.h>
#include <net/netmap_user.h>
#include <netinet/ip.h>
#include <machine/param.h>
#include <pthread_np.h> /* pthread w/ affinity */
#include <sys/cpuset.h> /* cpu_set */
#include <net/if_dl.h> /* LLADDR */
const struct peak_transfers transfer_netmap = {
.attach = peak_netmap_attach,
.master = peak_netmap_master,
.slave = peak_netmap_slave,
.lock = peak_netmap_lock,
.recv = peak_netmap_recv,
.send = peak_netmap_send,
.forward = peak_netmap_forward,
.unlock = peak_netmap_unlock,
.detach = peak_netmap_detach,
};
#define NETMAP_MAX 64
static pthread_mutex_t netmap_mutex = PTHREAD_MUTEX_INITIALIZER;
struct peak_netmap_dev {
char ifname[IFNAMSIZ];
struct netmap_if *nifp;
void *mem; /* userspace mmap address */
int fd;
unsigned int type;
unsigned int memsize;
unsigned int begin; /* first ring to check */
unsigned int end; /* last+1 ring to check */
};
struct peak_netmap {
struct netmap_ring *ring;
unsigned int used;
unsigned int i;
};
static struct peak_netmaps {
unsigned int count;
unsigned int last;
struct peak_netmap_dev dev[NETMAP_MAX];
struct pollfd fd[NETMAP_MAX];
} netmap_self;
static struct peak_netmaps *const self = &netmap_self; /* global ref */
static struct peak_netmap __thread netmap_priv; /* XXX not sure */
static struct peak_timeval __thread netmap_ts; /* XXX not sure */
#define NR_FOREACH_WIRE(mode, ring, idx, dev) \
for ((idx) = (dev)->begin, \
(ring) = NETMAP_##mode##RING((dev)->nifp, idx); \
(idx) < (dev)->end; ++(idx), \
(ring) = NETMAP_##mode##RING((dev)->nifp, idx))
#define NR_FOREACH_HOST(mode, ring, idx, dev) \
for ((idx) = (dev)->end, \
(ring) = NETMAP_##mode##RING((dev)->nifp, idx); \
(idx) <= (dev)->end; ++(idx), \
(ring) = NETMAP_##mode##RING((dev)->nifp, idx))
static int
__peak_netmap_init(struct peak_netmap_dev *dev)
{
const unsigned int if_flags = IFF_UP | IFF_PPROMISC;
struct ifreq ifr;
memset(&ifr, 0, sizeof(ifr));
strlcpy(ifr.ifr_name, dev->ifname, sizeof(ifr.ifr_name));
if (ioctl(dev->fd, SIOCGIFFLAGS, &ifr)) {
error("ioctl error on SIOCGIFFLAGS\n");
return (1);
}
ifr.ifr_flagshigh |= if_flags >> 16;
ifr.ifr_flags |= if_flags & 0xffff;
if (ioctl(dev->fd, SIOCSIFFLAGS, &ifr)) {
error("ioctl error on SIOCSIFFLAGS\n");
return (1);
}
memset(&ifr, 0, sizeof(ifr));
strlcpy(ifr.ifr_name, dev->ifname, sizeof(ifr.ifr_name));
if (ioctl(dev->fd, SIOCGIFCAP, &ifr)) {
error("ioctl error on SIOCGIFCAP\n");
return (1);
}
ifr.ifr_reqcap = ifr.ifr_curcap;
ifr.ifr_reqcap &= ~(IFCAP_HWCSUM | IFCAP_TSO | IFCAP_TOE);
if (ioctl(dev->fd, SIOCSIFCAP, &ifr)) {
error("ioctl error on SIOCSIFCAP\n");
return (1);
}
return (0);
}
static int
_peak_netmap_init(struct peak_netmap_dev *dev)
{
struct nmreq req;
memset(&req, 0, sizeof(req));
dev->fd = open("/dev/netmap", O_RDWR);
if (dev->fd < 0) {
error("unable to open /dev/netmap\n");
return (1);
}
if (dev->type == NR_REG_ALL_NIC && __peak_netmap_init(dev)) {
goto _peak_netmap_init_error;
}
/* Put the interface into netmap mode: */
req.nr_version = NETMAP_API;
req.nr_flags = dev->type;
switch (dev->type) {
case NR_REG_PIPE_MASTER:
case NR_REG_PIPE_SLAVE:
/* hardcoded name, meh */
strlcpy(req.nr_name, "vale", sizeof(req.nr_name));
/* must extract ring id */
req.nr_ringid = atoi(dev->ifname);
if (req.nr_ringid >= NETMAP_RING_MASK) {
goto _peak_netmap_init_error;
}
/* bump the pipe count to reasonable levels */
req.nr_arg1 = 16;
break;
default:
strlcpy(req.nr_name, dev->ifname, sizeof(req.nr_name));
req.nr_ringid = 0;
break;
}
if (ioctl(dev->fd, NIOCREGIF, &req)) {
error("NIOCREGIF failed on %s\n", dev->ifname);
goto _peak_netmap_init_error;
}
dev->memsize = req.nr_memsize;
dev->mem = mmap(0, dev->memsize, PROT_WRITE | PROT_READ,
MAP_SHARED, dev->fd, 0);
if (dev->mem == MAP_FAILED) {
error("mmap() failed on %s\n", dev->ifname);
goto _peak_netmap_init_error;
}
dev->nifp = NETMAP_IF(dev->mem, req.nr_offset);
/* setup for NR_REG_ALL_NIC */
dev->begin = 0;
dev->end = req.nr_rx_rings; // XXX max of the two
return (0);
_peak_netmap_init_error:
close(dev->fd);
return (1);
}
static inline unsigned int
peak_netmap_find(const char *ifname, const unsigned int ignore)
{
unsigned int i;
if (!ifname) {
return self->count;
}
for (i = 0; i < self->count; ++i) {
if (ignore != NR_REG_ALL_NIC &&
ignore == self->dev[i].type) {
/* must ignore pipe then */
continue;
}
if (!strcmp(ifname, self->dev[i].ifname)) {
break;
}
}
return (i);
}
static struct peak_transfer *
___peak_netmap_recv(struct peak_transfer *packet,
struct peak_netmap_dev *dev, struct netmap_ring *ring,
const unsigned int rx)
{
struct peak_netmap *priv = &netmap_priv;
unsigned int i, idx;
if (nm_ring_empty(ring)) {
return (NULL);
}
memset(packet, 0, sizeof(*packet));
i = ring->cur;
idx = ring->slot[i].buf_idx;
if (unlikely(idx < 2)) {
/* XXX this can probably be zapped */
panic("%s bogus RX index %d at offset %d\n",
dev->nifp->ni_name, idx, i);
}
/* volatile internals */
priv->ring = ring;
priv->used = 1;
priv->i = i;
/*
* netmap(4) seems to have trouble syncing the timestamp
* under yet unknown conditions, causing the timestamp to
* jump back and forth, causing `extra' time to appear
* inside peak_timeslice(3) as it tries to adapt to `real'
* time changes inside the system. To temporarily address
* this, any backwards leap smaller than 3 seconds must be
* ignored.
*/
if (ring->ts.tv_sec > netmap_ts.tv_sec ||
netmap_ts.tv_sec - ring->ts.tv_sec >= 3) {
netmap_ts.tv_usec = ring->ts.tv_usec;
netmap_ts.tv_sec = ring->ts.tv_sec;
}
/* external stuff */
packet->ts.tv_usec = netmap_ts.tv_usec;
packet->ts.tv_sec = netmap_ts.tv_sec;
packet->buf = NETMAP_BUF(ring, idx);
packet->len = ring->slot[i].len;
packet->ll = LINKTYPE_ETHERNET;
packet->ifname = dev->ifname;
packet->private_data = priv;
/* packet origin info */
packet->id = idx;
switch (dev->type) {
case NR_REG_PIPE_SLAVE:
packet->type = NETMAP_PIPE;
break;
default:
packet->type = rx != dev->end ?
NETMAP_WIRE : NETMAP_HOST;
break;
}
return (packet);
}
static struct peak_transfer *
__peak_netmap_recv(struct peak_transfer *packet,
struct peak_netmap_dev *dev, const unsigned int mode)
{
struct netmap_ring *ring;
unsigned int rx;
if (dev->type == NR_REG_PIPE_MASTER) {
/* can't read from master pipe */
return (NULL);
}
switch (mode) {
case NETMAP_DFLT:
case NETMAP_HOST:
if (dev->type != NR_REG_PIPE_SLAVE) {
/*
* Host not requested or nonexisting
* ring on slave pipe (I think).
*/
NR_FOREACH_HOST(RX, ring, rx, dev) {
if (___peak_netmap_recv(packet, dev,
ring, rx)) {
return (packet);
}
}
if (mode == NETMAP_HOST) {
break;
}
}
/* FALLTHROUGH */
default:
NR_FOREACH_WIRE(RX, ring, rx, dev) {
if (___peak_netmap_recv(packet, dev,
ring, rx)) {
return (packet);
}
}
break;
}
return (NULL);
}
static struct peak_transfer *
_peak_netmap_recv(struct peak_transfer *packet,
const unsigned int mode)
{
unsigned int i, j = self->last;
struct peak_transfer *ret = NULL;
for (i = 0; i < self->count; ++i) {
/* reshuffle the index */
j = (j + 1) % self->count;
ret = __peak_netmap_recv(packet, &self->dev[j], mode);
if (ret) {
/* set the last device */
self->last = j;
break;
}
}
return (ret);
}
struct peak_transfer *
peak_netmap_recv(struct peak_transfer *packet, int timeout,
const char *ifname, const unsigned int mode)
{
struct peak_netmap *priv = &netmap_priv;
struct peak_netmap_dev *dev;
struct pollfd *fd;
unsigned int i;
int ret;
if (unlikely(priv->used)) {
alert("must release claimed packet first\n");
return (NULL);
}
/*
* Look for packets prior to polling to avoid
* the system call overhead when not needed.
*/
if (ifname) {
i = peak_netmap_find(ifname, NR_REG_PIPE_MASTER);
if (i >= self->count) {
/* not found means error */
return (NULL);
}
dev = &self->dev[i];
if (__peak_netmap_recv(packet, dev, mode)) {
return (packet);
}
} else {
if (_peak_netmap_recv(packet, mode)) {
return (packet);
}
}
/*
* Call poll() to relax the CPU while adapters are idle.
* The caller is in charge of providing an appropriate
* timeout value (see poll(3)'s timeout parameter).
*/
if (ifname) {
fd = &self->fd[i];
fd->events = POLLIN;
fd->revents = 0;
ret = poll(fd, 1, timeout);
if (ret <= 0) {
/* error or timeout */
return (NULL);
}
if (fd->revents & POLLERR) {
alert("poll() error on %s\n", dev->ifname);
}
if (fd->revents & POLLIN) {
return (__peak_netmap_recv(packet, dev, mode));
}
} else {
for (i = 0; i < self->count; ++i) {
fd = &self->fd[i];
fd->events = POLLIN;
fd->revents = 0;
}
ret = poll(self->fd, self->count, timeout);
if (ret <= 0) {
/* error or timeout */
return (NULL);
}
for (i = 0; i < self->count; ++i) {
dev = &self->dev[i];
fd = &self->fd[i];
if (fd->revents & POLLERR) {
alert("poll() error on %s\n", dev->ifname);
}
if (fd->revents & POLLIN) {
self->last = i;
return (__peak_netmap_recv(packet,
dev, mode));
}
}
}
return (NULL);
}
unsigned int
peak_netmap_forward(struct peak_transfer *packet)
{
struct peak_netmap *priv = packet->private_data;
struct netmap_ring *source = priv->ring;
struct netmap_slot *slot = &source->slot[priv->i];
/* set the forward bit */
slot->flags |= NS_FORWARD;
/* drop kernel reference */
source->head = source->cur = nm_ring_next(source, source->cur);
/* scrub content */
memset(packet, 0, sizeof(*packet));
memset(priv, 0, sizeof(*priv));
return (0);
}
static unsigned int
peak_netmap_drop(struct peak_transfer *packet)
{
struct peak_netmap *priv = packet->private_data;
struct netmap_ring *source = priv->ring;
struct netmap_slot *slot = &source->slot[priv->i];
/* clear the forward bit */
slot->flags &= ~NS_FORWARD;
/* drop kernel reference */
source->head = source->cur = nm_ring_next(source, source->cur);
/* scrub content */
memset(packet, 0, sizeof(*packet));
memset(priv, 0, sizeof(*priv));
return (0);
}
static unsigned int
_peak_netmap_send(struct peak_transfer *packet, struct netmap_ring *ring)
{
struct peak_netmap *priv = packet->private_data;
struct netmap_ring *curr = priv->ring;
struct netmap_slot *rs, *ts;
unsigned int i, idx;
if (nm_ring_empty(ring)) {
return (1);
}
i = ring->cur;
rs = &curr->slot[priv->i];
ts = &ring->slot[i];
/* zero-copy magic */
idx = ts->buf_idx;
ts->buf_idx = rs->buf_idx;
rs->buf_idx = idx;
ts->len = rs->len;
/* report the buffer change */
ts->flags |= NS_BUF_CHANGED;
rs->flags |= NS_BUF_CHANGED;
/* don't forward to host anymore */
rs->flags &= ~NS_FORWARD;
curr->head = curr->cur = nm_ring_next(curr, curr->cur);
ring->head = ring->cur = nm_ring_next(ring, ring->cur);
/* scrub content */
memset(packet, 0, sizeof(*packet));
memset(priv, 0, sizeof(*priv));
return (0);
}
unsigned int
peak_netmap_send(struct peak_transfer *packet, const char *ifname,
const unsigned int mode)
{
struct peak_netmap *priv = packet->private_data;
struct peak_netmap_dev *dev;
struct netmap_ring *ring;
unsigned int i, tx;
if (!priv || !priv->used) {
/* packet is empty */
return (1);
}
if (!ifname) {
/* quick path for drop */
peak_netmap_drop(packet);
return (0);
}
i = peak_netmap_find(ifname, NR_REG_PIPE_SLAVE);
if (i >= self->count) {
/* not found means error */
return (1);
}
dev = &self->dev[i];
switch (mode) {
case NETMAP_HOST:
NR_FOREACH_HOST(TX, ring, tx, dev) {
if (!_peak_netmap_send(packet, ring)) {
/* XXX workaround is slow */
ioctl(dev->fd, NIOCTXSYNC, NULL);
return (0);
}
}
break;
default:
NR_FOREACH_WIRE(TX, ring, tx, dev) {
if (!_peak_netmap_send(packet, ring)) {
/* XXX workaround is slow */
ioctl(dev->fd, NIOCTXSYNC, NULL);
return (0);
}
}
break;
}
/* could not release packet, try again */
return (1);
}
static void
peak_netmap_configure(struct peak_netmap_dev *dev)
{
struct netmap_ring *ring;
unsigned int i;
NR_FOREACH_WIRE(RX, ring, i, dev) {
/* transparent mode: automatic forward via NS_FORWARD */
ring->flags |= NR_FORWARD;
/* timestamping: always update timestamps */
ring->flags |= NR_TIMESTAMP;
}
NR_FOREACH_HOST(RX, ring, i, dev) {
ring->flags |= NR_FORWARD | NR_TIMESTAMP;
}
}
static unsigned int
_peak_netmap_attach(const char *ifname, const unsigned int type)
{
unsigned int ignore = type;
unsigned int i;
if (pthread_mutex_trylock(&netmap_mutex)) {
/* mutex is busy or locked externally */
return (1);
}
switch (type) {
case NR_REG_PIPE_MASTER:
ignore = NR_REG_PIPE_SLAVE;
break;
case NR_REG_PIPE_SLAVE:
ignore = NR_REG_PIPE_MASTER;
break;
default:
break;
}
i = peak_netmap_find(ifname, ignore);
if (i < self->count) {
pthread_mutex_unlock(&netmap_mutex);
alert("netmap interface %s already attached\n", ifname);
return (1);
}
if (self->count >= lengthof(self->dev)) {
pthread_mutex_unlock(&netmap_mutex);
alert("netmap interface capacity reached\n");
return (1);
}
i = self->count;
memset(&self->dev[i], 0, sizeof(self->dev[i]));
strlcpy(self->dev[i].ifname, ifname, sizeof(self->dev[i].ifname));
self->dev[i].type = type;
if (_peak_netmap_init(&self->dev[i])) {
pthread_mutex_unlock(&netmap_mutex);
alert("could not open netmap device %s\n", ifname);
return (1);
}
peak_netmap_configure(&self->dev[i]);
self->fd[i].fd = self->dev[i].fd;
++self->count;
pthread_mutex_unlock(&netmap_mutex);
return (0);
}
unsigned int
peak_netmap_master(const char *pipeid)
{
return (_peak_netmap_attach(pipeid, NR_REG_PIPE_MASTER));
}
unsigned int
peak_netmap_slave(const char *pipeid)
{
return (_peak_netmap_attach(pipeid, NR_REG_PIPE_SLAVE));
}
unsigned int
peak_netmap_attach(const char *ifname)
{
return (_peak_netmap_attach(ifname, NR_REG_ALL_NIC));
}
unsigned int
peak_netmap_detach(const char *ifname)
{
unsigned int i;
if (pthread_mutex_trylock(&netmap_mutex)) {
/* mutex is busy or locked externally */
return (1);
}
i = peak_netmap_find(ifname, NR_REG_ALL_NIC);
if (i >= self->count) {
pthread_mutex_unlock(&netmap_mutex);
alert("netmap interface %s not attached\n", ifname);
return (1);
}
if (self->dev[i].mem) {
munmap(self->dev[i].mem, self->dev[i].memsize);
}
close(self->dev[i].fd);
if (i < self->count - 1) {
/*
* Replace the dead element with the last
* element in the list to fill the hole.
*/
self->dev[i] = self->dev[self->count - 1];
self->fd[i] = self->fd[self->count - 1];
};
self->count--;
pthread_mutex_unlock(&netmap_mutex);
return (0);
}
void
peak_netmap_lock(void)
{
pthread_mutex_lock(&netmap_mutex);
}
void
peak_netmap_unlock(void)
{
pthread_mutex_unlock(&netmap_mutex);
}
#endif
| 23.416773 | 77 | 0.672636 |
9837f53430e560899c26de68322d785feea64216 | 483 | c | C | build/stx/support/tools/splint-3.1.2/test/argorder4.c | GunterMueller/ST_STX_Fork | d891b139f3c016b81feeb5bf749e60585575bff7 | [
"MIT"
] | 1 | 2020-01-23T20:46:08.000Z | 2020-01-23T20:46:08.000Z | build/stx/support/tools/splint-3.1.2/test/argorder4.c | GunterMueller/ST_STX_Fork | d891b139f3c016b81feeb5bf749e60585575bff7 | [
"MIT"
] | null | null | null | build/stx/support/tools/splint-3.1.2/test/argorder4.c | GunterMueller/ST_STX_Fork | d891b139f3c016b81feeb5bf749e60585575bff7 | [
"MIT"
] | null | null | null | int glob;
int add(int x, int y) { return (x + y); }
int f()
{
return (glob);
}
int g()
{
return (++glob);
}
int h()
{
if (f() > 3)
{
return (f() + g()); /* bad --- order of evaluation matters! */
}
else
{
if (g() < 2)
{
return (f() + (++glob)); /* bad! */
}
else
{
return (g() + h()); /* bad (twice) */
}
}
/* unreachable code here */
return (add ((printf("hullo"), 3), (printf("goodbye"), 4))); /* bad (wrice) */
}
| 12.075 | 80 | 0.42236 |
a6522f3e50b5596f8a04c7e8afcdc36b909cd87e | 344 | c | C | UESTC-Programming-Course/Grade 1/Chapter 13/Homework 2/F.c | HeRaNO/ChickenRibs | 9aa8dd8f915aa39a7168940b5ff99a1d665f5212 | [
"MIT"
] | 14 | 2020-03-02T09:55:44.000Z | 2021-09-17T09:39:40.000Z | UESTC-Programming-Course/Grade 1/Chapter 13/Homework 2/F.c | HeRaNO/ChickenRibs | 9aa8dd8f915aa39a7168940b5ff99a1d665f5212 | [
"MIT"
] | null | null | null | UESTC-Programming-Course/Grade 1/Chapter 13/Homework 2/F.c | HeRaNO/ChickenRibs | 9aa8dd8f915aa39a7168940b5ff99a1d665f5212 | [
"MIT"
] | 8 | 2020-06-08T12:38:56.000Z | 2021-06-27T14:23:30.000Z | #include <stdio.h>
#include <string.h>
int max(int a,int b){return a>b?a:b;}
int main()
{
int i,n;char s[100];
puts("Enter full name of a file:");printf("The extension is: ");
scanf("%s",s);n=strlen(s);
for (i=n-1;~i;i--) if (s[i]=='.') break;
if (s[max(i,0)]!='.') return 0;
for (++i;i<n;i++) putchar(s[i]);putchar('\n');
return 0;
}
| 21.5 | 65 | 0.561047 |
074ad4cd52ff2b701ebf8aaa570db9b298dab14e | 306 | h | C | include/processor.h | xjohncz/CppND-System-Monitor | 4b40c77da7366cfbb2c3b9c9b93627f5d77b7a0e | [
"MIT"
] | null | null | null | include/processor.h | xjohncz/CppND-System-Monitor | 4b40c77da7366cfbb2c3b9c9b93627f5d77b7a0e | [
"MIT"
] | null | null | null | include/processor.h | xjohncz/CppND-System-Monitor | 4b40c77da7366cfbb2c3b9c9b93627f5d77b7a0e | [
"MIT"
] | null | null | null | #ifndef PROCESSOR_H
#define PROCESSOR_H
class Processor {
public:
float Utilization(); // TODO: See src/processor.cpp
// TODO: Declare any necessary private members
private:
static int previdle, previowait;
static int prevuser, prevnice, prevsystem, previrq, prevsoftirq, prevsteal;
};
#endif | 21.857143 | 77 | 0.751634 |
727abfb94f456651cf60de93d372c1abc63e0a68 | 3,954 | c | C | thirdparty/dmcurl/thirdparty/curl/tests/libtest/lib576.c | brinkqiang/luahttpclient | 1c5e0555a80aa15dd0e765a8084d0af83f0a488a | [
"MIT"
] | null | null | null | thirdparty/dmcurl/thirdparty/curl/tests/libtest/lib576.c | brinkqiang/luahttpclient | 1c5e0555a80aa15dd0e765a8084d0af83f0a488a | [
"MIT"
] | null | null | null | thirdparty/dmcurl/thirdparty/curl/tests/libtest/lib576.c | brinkqiang/luahttpclient | 1c5e0555a80aa15dd0e765a8084d0af83f0a488a | [
"MIT"
] | null | null | null | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "memdebug.h"
typedef struct {
int remains;
int print_content;
} chunk_data_t;
static
long chunk_bgn(const struct curl_fileinfo *finfo, void *ptr, int remains);
static
long chunk_end(void *ptr);
static
long chunk_bgn(const struct curl_fileinfo *finfo, void *ptr, int remains)
{
chunk_data_t *ch_d = ptr;
ch_d->remains = remains;
printf("=============================================================\n");
printf("Remains: %d\n", remains);
printf("Filename: %s\n", finfo->filename);
if(finfo->strings.perm) {
printf("Permissions: %s", finfo->strings.perm);
if(finfo->flags & CURLFINFOFLAG_KNOWN_PERM)
printf(" (parsed => %o)", finfo->perm);
printf("\n");
}
printf("Size: %ldB\n", (long)finfo->size);
if(finfo->strings.user)
printf("User: %s\n", finfo->strings.user);
if(finfo->strings.group)
printf("Group: %s\n", finfo->strings.group);
if(finfo->strings.time)
printf("Time: %s\n", finfo->strings.time);
printf("Filetype: ");
switch(finfo->filetype) {
case CURLFILETYPE_FILE:
printf("regular file\n");
break;
case CURLFILETYPE_DIRECTORY:
printf("directory\n");
break;
case CURLFILETYPE_SYMLINK:
printf("symlink\n");
printf("Target: %s\n", finfo->strings.target);
break;
default:
printf("other type\n");
break;
}
if(finfo->filetype == CURLFILETYPE_FILE) {
ch_d->print_content = 1;
printf("Content:\n-----------------------"
"--------------------------------------\n");
}
if(strcmp(finfo->filename, "someothertext.txt") == 0) {
printf("# THIS CONTENT WAS SKIPPED IN CHUNK_BGN CALLBACK #\n");
return CURL_CHUNK_BGN_FUNC_SKIP;
}
return CURL_CHUNK_BGN_FUNC_OK;
}
static
long chunk_end(void *ptr)
{
chunk_data_t *ch_d = ptr;
if(ch_d->print_content) {
ch_d->print_content = 0;
printf("-------------------------------------------------------------\n");
}
if(ch_d->remains == 1)
printf("=============================================================\n");
return CURL_CHUNK_END_FUNC_OK;
}
int test(char *URL)
{
CURL *handle = NULL;
CURLcode res = CURLE_OK;
chunk_data_t chunk_data = {0, 0};
curl_global_init(CURL_GLOBAL_ALL);
handle = curl_easy_init();
if(!handle) {
res = CURLE_OUT_OF_MEMORY;
goto test_cleanup;
}
test_setopt(handle, CURLOPT_URL, URL);
test_setopt(handle, CURLOPT_WILDCARDMATCH, 1L);
test_setopt(handle, CURLOPT_CHUNK_BGN_FUNCTION, chunk_bgn);
test_setopt(handle, CURLOPT_CHUNK_END_FUNCTION, chunk_end);
test_setopt(handle, CURLOPT_CHUNK_DATA, &chunk_data);
res = curl_easy_perform(handle);
test_cleanup:
if(handle)
curl_easy_cleanup(handle);
curl_global_cleanup();
return res;
}
| 31.380952 | 79 | 0.549317 |
729676bc0b611b2255f40a78623ca68df73aef51 | 537 | h | C | Sources/CXX/include/CXX.h | ProfFan/cxx-interop-test | 9b9d2a6857397bc4e3dbda57025c4822bf6bd0f1 | [
"Apache-2.0"
] | null | null | null | Sources/CXX/include/CXX.h | ProfFan/cxx-interop-test | 9b9d2a6857397bc4e3dbda57025c4822bf6bd0f1 | [
"Apache-2.0"
] | null | null | null | Sources/CXX/include/CXX.h | ProfFan/cxx-interop-test | 9b9d2a6857397bc4e3dbda57025c4822bf6bd0f1 | [
"Apache-2.0"
] | null | null | null | #ifndef CXX_H
#define CXX_H
#include <sstream>
#include <string>
#include <vector>
class V {
public:
V() : Vec({1, 2, 3, 4}), str("Hello from C++!") {}
std::vector<int> &getVec() { return Vec; }
std::vector<int> Vec;
std::string str;
};
using cxx_std_vector_of_int = std::vector<int>;
static int dummy() {
auto v = new V();
std::vector<int> vec(v->Vec);
vec.push_back(10);
delete v;
return vec[0];
}
namespace test {
class Dumper {
public:
static std::string dump(const std::vector<int> &array);
};
}
#endif
| 14.513514 | 57 | 0.625698 |
72b0e7212d003d8d5cc0d61989ebc84246ac0bf3 | 1,685 | h | C | src/file_storage.h | G-Ray/libtorrent-native | ce89d1ffaeba51cb99e70a417b932f987f7d31e1 | [
"MIT"
] | null | null | null | src/file_storage.h | G-Ray/libtorrent-native | ce89d1ffaeba51cb99e70a417b932f987f7d31e1 | [
"MIT"
] | null | null | null | src/file_storage.h | G-Ray/libtorrent-native | ce89d1ffaeba51cb99e70a417b932f987f7d31e1 | [
"MIT"
] | null | null | null | #ifndef FILESTORAGE_H
#define FILESTORAGE_H
#include <memory>
#include <nan.h>
namespace libtorrent
{
class file_storage;
}
namespace lt
{
class FileStorage : public Nan::ObjectWrap
{
public:
static NAN_MODULE_INIT(Init);
static v8::Local<v8::Object> NewInstance(v8::Local<v8::Value> arg);
libtorrent::file_storage const& GetWrapped();
private:
explicit FileStorage(std::reference_wrapper<const libtorrent::file_storage> fs);
static NAN_METHOD(New);
static NAN_METHOD(IsValid);
// TODO: Reserve
// TODO: AddFile
// TODO: RenameFile
// TODO: MapBlock
// TODO: MapFile
static NAN_METHOD(NumFiles);
static NAN_METHOD(TotalSize);
static NAN_METHOD(NumPieces);
static NAN_METHOD(PieceLength);
static NAN_METHOD(PieceSize);
static NAN_METHOD(Name);
static NAN_METHOD(IsLoaded);
static NAN_METHOD(Hash);
static NAN_METHOD(Symlink);
static NAN_METHOD(Mtime);
static NAN_METHOD(FilePath);
static NAN_METHOD(FileName);
static NAN_METHOD(FileSize);
static NAN_METHOD(PadFileAt);
static NAN_METHOD(FileOffset);
static NAN_METHOD(FilePathHash);
static NAN_METHOD(AllPathHashes);
static NAN_METHOD(Paths);
static NAN_METHOD(FileFlags);
static NAN_METHOD(FileAbsolutePath);
static NAN_METHOD(FileIndexAtOffset);
// TODO file_name_ptr
// TODO file_name_len
static Nan::Persistent<v8::Function> constructor;
std::reference_wrapper<const libtorrent::file_storage> fs_;
};
}
#endif
| 26.328125 | 88 | 0.647478 |
b84c89c8f45dd4e7d98c89972d24573cd7eadd3e | 2,985 | c | C | nm_otool/src/ft_otool.c | fflorens/portofolio42 | 4368c33460129beaebea0c983a133f717bc9fe13 | [
"MIT"
] | null | null | null | nm_otool/src/ft_otool.c | fflorens/portofolio42 | 4368c33460129beaebea0c983a133f717bc9fe13 | [
"MIT"
] | null | null | null | nm_otool/src/ft_otool.c | fflorens/portofolio42 | 4368c33460129beaebea0c983a133f717bc9fe13 | [
"MIT"
] | null | null | null | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_otool.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: fflorens <fflorens@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/05/24 11:09:23 by fflorens #+# #+# */
/* Updated: 2017/05/30 09:57:33 by fflorens ### ########.fr */
/* */
/* ************************************************************************** */
#include <sys/mman.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdlib.h>
#include <mach-o/loader.h>
#include <mach-o/nlist.h>
#include <mach-o/fat.h>
#include <mach-o/ranlib.h>
#include <ar.h>
#include "libft.h"
#include "ft_nm_otool.h"
#define PROT_MMAP (PROT_READ | PROT_WRITE)
char *g_arch = NULL;
static int open_file(char *name, void **ptr, int *fd, t_stat *buf)
{
if ((*fd = open(name, O_RDONLY)) < 0)
return (ft_error("Unable to open: ", name));
if (fstat(*fd, buf) < 0)
{
close(*fd);
return (ft_error("Unable to stat: ", name));
}
*ptr = mmap(NULL, buf->st_size, PROT_MMAP, MAP_PRIVATE, *fd, 0);
if (*ptr == MAP_FAILED)
{
close(*fd);
return (ft_error("Unable to map: ", name));
}
return (EXIT_SUCCESS);
}
static int close_file(t_file *file, void **ptr, int *fd, int ret)
{
if (munmap(*ptr, file->size))
return (ft_error("Unable to unmap: ", file->name));
if (close(*fd))
return (ft_error("Unable to close: ", file->name));
return (ret);
}
static int check_arch_arg(int ac, char **av)
{
NXArchInfo *info;
if (ac < 3 || ft_strcmp(av[1], "-arch"))
return (0);
else if (!ft_strcmp(av[2], "all"))
{
g_arch = av[2];
return (2);
}
else
{
if (!ft_strcmp(av[2], "armv5e"))
av[2][5] = '\0';
if ((info = (NXArchInfo *)NXGetArchInfoFromName(av[2])) == NULL)
return (1);
g_arch = av[2];
}
return (2);
}
int main(int ac, char **av)
{
int i;
int fd;
void *ptr;
t_stat buf;
t_file file;
if (ac < 2)
return (ft_error("Missing arguments.\n", NULL));
i = check_arch_arg(ac, av);
if (!ft_strcmp(av[i], "-arch"))
return (ft_error("Missing parameters for -arch.\n", NULL));
while (++i < ac)
{
if (open_file(av[i], &ptr, &fd, &buf) != EXIT_SUCCESS)
return (EXIT_FAILURE);
ft_bzero(&file, sizeof(t_file));
file.size = buf.st_size;
file.name = av[i];
file.ptr = ptr;
if (ft_otool(&file) != EXIT_SUCCESS)
return (close_file(&file, &ptr, &fd, EXIT_FAILURE));
if (close_file(&file, &ptr, &fd, EXIT_SUCCESS) != EXIT_SUCCESS)
return (EXIT_FAILURE);
}
return (EXIT_SUCCESS);
}
| 28.160377 | 80 | 0.468677 |
f747b3c201ab42ef8477bfcbfb20b86d44018c28 | 1,282 | c | C | nitan/d/beijing/zhuang3.c | cantona/NT6 | 073f4d491b3cfe6bfbe02fbad12db8983c1b9201 | [
"MIT"
] | 1 | 2019-03-27T07:25:16.000Z | 2019-03-27T07:25:16.000Z | nitan/d/beijing/zhuang3.c | cantona/NT6 | 073f4d491b3cfe6bfbe02fbad12db8983c1b9201 | [
"MIT"
] | null | null | null | nitan/d/beijing/zhuang3.c | cantona/NT6 | 073f4d491b3cfe6bfbe02fbad12db8983c1b9201 | [
"MIT"
] | null | null | null | #include <room.h>
#include <ansi.h>
inherit ROOM;
int do_break(string arg);
void create()
{
set("short", "莊府大門");
set("long", @LONG
這裏就是文士莊允城的舊居。自從他被朝廷抓走後,這裏好像就
沒有人住了。一扇大門(men)緊鎖着, 周圍是高高的圍牆(wall)。一
切都很乾淨,並沒有積多少灰塵。
LONG );
set("exits", ([
"south" : "/d/beijing/zhuang2",
]));
set("item_desc", ([
"men" : "這扇門是鎖着的,除非你打破(break)它。\n",
]) );
set("coor/x", -2780);
set("coor/y", 7640);
set("coor/z", 0);
setup();
}
void init()
{
object book, me;
me = this_player();
add_action("do_break", "break");
}
int do_break(string arg)
{
int n;
n=query("neili", this_player());
if (! arg || arg != "men")
{
write("不要隨便打碎別人的東西!\n");
return 1;
}
message_vision("$N走到門前,深吸一口氣,雙掌同時拍出。\n",
this_player());
if (n >= 200)
{
message_vision("$N只聽一聲轟響,$N把門震開了!\n",
this_player());
set("exits/north", "/d/beijing/zhuang5");
set("neili", n-200, this_player());
remove_call_out("close");
call_out("close", 5, this_object());
} else
{
message_vision("$N大吼一聲“開!”,結果什麼也沒發生。"
"看來$N的內力不夠強。\n", this_player());
set("neili", 0, this_player());
}
return 1;
} | 20.03125 | 55 | 0.514041 |
743ff97377b98e6523f153487743d3a49f5a2497 | 3,085 | h | C | include/il2cpp/System/Collections/Generic/Dictionary/ValueCollection_byte__object_.h | martmists-gh/BDSP | d6326c5d3ad9697ea65269ed47aa0b63abac2a0a | [
"MIT"
] | 1 | 2022-01-15T20:20:27.000Z | 2022-01-15T20:20:27.000Z | include/il2cpp/System/Collections/Generic/Dictionary/ValueCollection_byte__object_.h | martmists-gh/BDSP | d6326c5d3ad9697ea65269ed47aa0b63abac2a0a | [
"MIT"
] | null | null | null | include/il2cpp/System/Collections/Generic/Dictionary/ValueCollection_byte__object_.h | martmists-gh/BDSP | d6326c5d3ad9697ea65269ed47aa0b63abac2a0a | [
"MIT"
] | null | null | null | #pragma once
#include "il2cpp.h"
void System_Collections_Generic_Dictionary_ValueCollection_byte__object____ctor (System_Collections_Generic_Dictionary_ValueCollection_byte__object__o* __this, System_Collections_Generic_Dictionary_TKey__TValue__o* dictionary, const MethodInfo* method_info);
System_Collections_Generic_Dictionary_ValueCollection_Enumerator_TKey__TValue__o System_Collections_Generic_Dictionary_ValueCollection_byte__object___GetEnumerator (System_Collections_Generic_Dictionary_ValueCollection_byte__object__o* __this, const MethodInfo* method_info);
void System_Collections_Generic_Dictionary_ValueCollection_byte__object___CopyTo (System_Collections_Generic_Dictionary_ValueCollection_byte__object__o* __this, System_Object_array* array, int32_t index, const MethodInfo* method_info);
int32_t System_Collections_Generic_Dictionary_ValueCollection_byte__object___get_Count (System_Collections_Generic_Dictionary_ValueCollection_byte__object__o* __this, const MethodInfo* method_info);
bool System_Collections_Generic_Dictionary_ValueCollection_byte__object___System_Collections_Generic_ICollection_TValue__get_IsReadOnly (System_Collections_Generic_Dictionary_ValueCollection_byte__object__o* __this, const MethodInfo* method_info);
void System_Collections_Generic_Dictionary_ValueCollection_byte__object___System_Collections_Generic_ICollection_TValue__Add (System_Collections_Generic_Dictionary_ValueCollection_byte__object__o* __this, Il2CppObject* item, const MethodInfo* method_info);
bool System_Collections_Generic_Dictionary_ValueCollection_byte__object___System_Collections_Generic_ICollection_TValue__Remove (System_Collections_Generic_Dictionary_ValueCollection_byte__object__o* __this, Il2CppObject* item, const MethodInfo* method_info);
void System_Collections_Generic_Dictionary_ValueCollection_byte__object___System_Collections_Generic_ICollection_TValue__Clear (System_Collections_Generic_Dictionary_ValueCollection_byte__object__o* __this, const MethodInfo* method_info);
bool System_Collections_Generic_Dictionary_ValueCollection_byte__object___System_Collections_Generic_ICollection_TValue__Contains (System_Collections_Generic_Dictionary_ValueCollection_byte__object__o* __this, Il2CppObject* item, const MethodInfo* method_info);
System_Collections_Generic_IEnumerator_TValue__o* System_Collections_Generic_Dictionary_ValueCollection_byte__object___System_Collections_Generic_IEnumerable_TValue__GetEnumerator (System_Collections_Generic_Dictionary_ValueCollection_byte__object__o* __this, const MethodInfo* method_info);
System_Collections_IEnumerator_o* System_Collections_Generic_Dictionary_ValueCollection_byte__object___System_Collections_IEnumerable_GetEnumerator (System_Collections_Generic_Dictionary_ValueCollection_byte__object__o* __this, const MethodInfo* method_info);
void System_Collections_Generic_Dictionary_ValueCollection_byte__object___System_Collections_ICollection_CopyTo (System_Collections_Generic_Dictionary_ValueCollection_byte__object__o* __this, System_Array_o* array, int32_t index, const MethodInfo* method_info);
| 181.470588 | 291 | 0.935494 |
ddf7a4cb9d05f7b9a8e387206edefff16a656e11 | 2,491 | h | C | src/trusted/channel.h | pinklite34/Teechain | d27fad8e30ac75f38a7b443280dbe4df260bfbb5 | [
"Unlicense"
] | 46 | 2018-02-12T14:42:28.000Z | 2022-03-10T12:48:55.000Z | src/trusted/channel.h | pinklite34/Teechain | d27fad8e30ac75f38a7b443280dbe4df260bfbb5 | [
"Unlicense"
] | 5 | 2018-10-05T07:27:30.000Z | 2021-04-14T06:16:18.000Z | src/trusted/channel.h | pinklite34/Teechain | d27fad8e30ac75f38a7b443280dbe4df260bfbb5 | [
"Unlicense"
] | 14 | 2018-02-24T00:54:24.000Z | 2021-09-27T07:44:16.000Z | #ifndef _CHANNEL_H_
#define _CHANNEL_H_
#include <string>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include "service_provider.h"
#include "state.h"
enum BackupBlockRequest {
Channel_Create_Request, // perform backup: a new channel is being created
Backup_Store_Request, // a new backup channel is being created
Send_Bitcoin_Request, // perform backup: we want to send bitcoins
Receive_Bitcoin_Request, // perform backup: we want to receive bitcoins
Add_Deposit_Request, // perform backup: we want to add deposit
Add_Deposit_Ack, // perform backup: acking deposit added
Remove_Deposit_Request, // perform backup: we want to remove deposit
Remove_Deposit_Ack, // perform backup: acking deposit removed
};
#include "network.h" // prevent circular deps
enum ChannelStatus {
Unverified, // not yet verified by the remote
Alive, // alive and ready to rock
Settled, // has been settled
};
class ChannelState {
public:
ChannelStatus status;
std::string channel_id;
bool is_initiator; // am I the initiator?
bool is_backup_channel;
bool deposits_verified;
bool other_party_deposits_verified;
SetupTransaction remote_setup_transaction;
// state per in-flight request
std::string most_recent_nonce;
// backup requests in flight
std::map<std::string, struct BackupRequest> backup_requests;
// account totals and monotonic counters
unsigned long long my_balance;
unsigned long long remote_balance;
unsigned long long remote_last_seen; // highest seen transaction from the remote side
unsigned long long my_monotonic_counter; // the id of the last transaction sent from me to the other side
// transactions processed, just for debugging and information
int my_sends;
int my_receives;
// cache to sync across backups
unsigned long long unsynced_bitcoin_amount; // the current amount of funds in this node not backed up
// service provider shared secret state
sp_db_item_t g_sp_db;
};
ChannelState *create_channel_state();
ChannelState *get_channel_state(std::string channel_id);
void destroy_channel_state(std::string channel_id);
ChannelState* associate_channel_state(std::string channel_id, ChannelState* state_to_associate);
void remove_association(std::string channel_id);
std::vector<std::string> get_all_non_backup_channel_ids();
bool check_status(ChannelState* state, ChannelStatus status);
#endif
| 32.776316 | 110 | 0.7499 |
a19af3a18d9a128d51907cdaebaedc8f8e5bcfd4 | 9,312 | c | C | freeswitch/src/mod/asr_tts/mod_tts_commandline/mod_tts_commandline.c | gidmoth/freeswitch-image-builder | f0169671d6a4683dd4ac7226a6b38ad94640e592 | [
"BSD-2-Clause"
] | null | null | null | freeswitch/src/mod/asr_tts/mod_tts_commandline/mod_tts_commandline.c | gidmoth/freeswitch-image-builder | f0169671d6a4683dd4ac7226a6b38ad94640e592 | [
"BSD-2-Clause"
] | null | null | null | freeswitch/src/mod/asr_tts/mod_tts_commandline/mod_tts_commandline.c | gidmoth/freeswitch-image-builder | f0169671d6a4683dd4ac7226a6b38ad94640e592 | [
"BSD-2-Clause"
] | null | null | null | /*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2009, Mathieu Parent <math.parent@gmail.com>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* Mathieu Parent <math.parent@gmail.com>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Mathieu Parent <math.parent@gmail.com>
*
* mod_tts_commandline.c -- System command ASR TTS Interface
*
*/
#include <switch.h>
#include <unistd.h>
SWITCH_MODULE_LOAD_FUNCTION(mod_tts_commandline_load);
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_tts_commandline_shutdown);
SWITCH_MODULE_DEFINITION(mod_tts_commandline, mod_tts_commandline_load, mod_tts_commandline_shutdown, NULL);
static switch_event_node_t *NODE = NULL;
static struct {
char *command;
} globals;
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_command, globals.command);
struct tts_commandline_data {
char *voice_name;
int rate;
char *file;
switch_file_handle_t *fh;
};
typedef struct tts_commandline_data tts_commandline_t;
static int load_tts_commandline_config(void)
{
char *cf = "tts_commandline.conf";
switch_xml_t cfg, xml, settings, param;
if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", cf);
} else {
if ((settings = switch_xml_child(cfg, "settings"))) {
for (param = switch_xml_child(settings, "param"); param; param = param->next) {
char *var = (char *) switch_xml_attr_soft(param, "name");
char *val = (char *) switch_xml_attr_soft(param, "value");
if (!strcmp(var, "command")) {
set_global_command(val);
}
}
}
switch_xml_free(xml);
}
if (zstr(globals.command)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No command set, please edit %s\n", cf);
}
return SWITCH_STATUS_SUCCESS;
}
static void event_handler(switch_event_t *event)
{
if (event->event_id == SWITCH_EVENT_RELOADXML) {
if (load_tts_commandline_config() != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to reload config file\n");
}
}
}
static switch_status_t tts_commandline_speech_open(switch_speech_handle_t *sh, const char *voice_name, int rate, int channels, switch_speech_flag_t *flags)
{
switch_uuid_t uuid;
char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
char outfile[512] = "";
tts_commandline_t *info = switch_core_alloc(sh->memory_pool, sizeof(*info));
info->voice_name = switch_core_strdup(sh->memory_pool, voice_name);
info->rate = rate;
/* Construct temporary file name with a new UUID */
switch_uuid_get(&uuid);
switch_uuid_format(uuid_str, &uuid);
switch_snprintf(outfile, sizeof(outfile), "%s%s%s.tmp.wav", SWITCH_GLOBAL_dirs.temp_dir, SWITCH_PATH_SEPARATOR, uuid_str);
info->file = switch_core_strdup(sh->memory_pool, outfile);
info->fh = (switch_file_handle_t *) switch_core_alloc(sh->memory_pool, sizeof(switch_file_handle_t));
sh->private_info = info;
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t tts_commandline_speech_close(switch_speech_handle_t *sh, switch_speech_flag_t *flags)
{
tts_commandline_t *info = (tts_commandline_t *) sh->private_info;
assert(info != NULL);
if (switch_test_flag(info->fh, SWITCH_FILE_OPEN)) {
switch_core_file_close(info->fh);
unlink(info->file);
}
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t tts_commandline_speech_feed_tts(switch_speech_handle_t *sh, char *text, switch_speech_flag_t *flags)
{
switch_status_t ret=SWITCH_STATUS_SUCCESS;
char *message, *tmp, *mtmp, *rate;
tts_commandline_t *info = (tts_commandline_t *) sh->private_info;
assert(info != NULL);
if (switch_test_flag(info->fh, SWITCH_FILE_OPEN)) {
switch_core_file_close(info->fh);
unlink(info->file);
}
tmp = switch_util_quote_shell_arg(text);
message = switch_string_replace(globals.command, "${text}", tmp);
switch_safe_free(tmp); mtmp=message;
tmp = switch_util_quote_shell_arg(info->voice_name);
message = switch_string_replace(mtmp, "${voice}", tmp);
switch_safe_free(tmp); switch_safe_free(mtmp); mtmp=message;
rate = switch_core_sprintf(sh->memory_pool, "%d", info->rate);
message = switch_string_replace(mtmp, "${rate}", rate);
switch_safe_free(mtmp); mtmp=message;
tmp = switch_util_quote_shell_arg(info->file);
message = switch_string_replace(mtmp, "${file}", tmp);
switch_safe_free(tmp); switch_safe_free(mtmp); mtmp=message;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Executing: %s\n", message);
if (switch_system(message, SWITCH_TRUE) < 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to execute command: %s\n", message);
ret = SWITCH_STATUS_FALSE; goto done;
}
if (switch_core_file_open(info->fh, info->file, 0, //number_of_channels,
info->rate, //samples_per_second,
SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to open file: %s\n", info->file);
ret = SWITCH_STATUS_FALSE; goto done;
}
sh->private_info = info;
done:
switch_safe_free(mtmp);
return ret;
}
static switch_status_t tts_commandline_speech_read_tts(switch_speech_handle_t *sh, void *data, size_t *datalen, switch_speech_flag_t *flags)
{
tts_commandline_t *info = (tts_commandline_t *) sh->private_info;
size_t my_datalen = *datalen / 2;
assert(info != NULL);
if (switch_core_file_read(info->fh, data, &my_datalen) != SWITCH_STATUS_SUCCESS) {
if (switch_test_flag(info->fh, SWITCH_FILE_OPEN)) {
switch_core_file_close(info->fh);
}
unlink(info->file);
return SWITCH_STATUS_FALSE;
}
*datalen = my_datalen * 2;
if (datalen == 0) {
if (switch_test_flag(info->fh, SWITCH_FILE_OPEN)) {
switch_core_file_close(info->fh);
}
unlink(info->file);
return SWITCH_STATUS_BREAK;
} else {
return SWITCH_STATUS_SUCCESS;
}
}
static void tts_commandline_speech_flush_tts(switch_speech_handle_t *sh)
{
tts_commandline_t *info = (tts_commandline_t *) sh->private_info;
assert(info != NULL);
if (info->fh != NULL && info->fh->file_interface != NULL && switch_test_flag(info->fh, SWITCH_FILE_OPEN)) {
switch_core_file_close(info->fh);
}
if (switch_file_exists(info->file, NULL) == SWITCH_STATUS_SUCCESS) {
if (unlink(info->file) != 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Sound file [%s] delete failed\n", info->file);
}
}
}
static void tts_commandline_text_param_tts(switch_speech_handle_t *sh, char *param, const char *val)
{
tts_commandline_t *info = (tts_commandline_t *) sh->private_info;
assert(info != NULL);
if (!strcasecmp(param, "voice")) {
info->voice_name = switch_core_strdup(sh->memory_pool, val);
}
}
static void tts_commandline_numeric_param_tts(switch_speech_handle_t *sh, char *param, int val)
{
}
static void tts_commandline_float_param_tts(switch_speech_handle_t *sh, char *param, double val)
{
}
SWITCH_MODULE_LOAD_FUNCTION(mod_tts_commandline_load)
{
switch_speech_interface_t *speech_interface;
load_tts_commandline_config();
/* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
if ((switch_event_bind_removable(modname, SWITCH_EVENT_RELOADXML, NULL, event_handler, NULL, &NODE) != SWITCH_STATUS_SUCCESS)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind our reloadxml handler!\n");
/* Not such severe to prevent loading */
}
speech_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_SPEECH_INTERFACE);
speech_interface->interface_name = "tts_commandline";
speech_interface->speech_open = tts_commandline_speech_open;
speech_interface->speech_close = tts_commandline_speech_close;
speech_interface->speech_feed_tts = tts_commandline_speech_feed_tts;
speech_interface->speech_read_tts = tts_commandline_speech_read_tts;
speech_interface->speech_flush_tts = tts_commandline_speech_flush_tts;
speech_interface->speech_text_param_tts = tts_commandline_text_param_tts;
speech_interface->speech_numeric_param_tts = tts_commandline_numeric_param_tts;
speech_interface->speech_float_param_tts = tts_commandline_float_param_tts;
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
}
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_tts_commandline_shutdown)
{
switch_event_unbind(&NODE);
switch_safe_free(globals.command);
return SWITCH_STATUS_UNLOAD;
}
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
*/
| 32.333333 | 155 | 0.764175 |
a1e8bd92671eab20848d59316313e50376f43d08 | 546 | h | C | src/core/checkpoint.h | dani3/sc-emulator | 54b61a56e801c353c15bf3d88f27c836c5559242 | [
"MIT"
] | null | null | null | src/core/checkpoint.h | dani3/sc-emulator | 54b61a56e801c353c15bf3d88f27c836c5559242 | [
"MIT"
] | 3 | 2021-11-26T14:20:08.000Z | 2022-02-04T23:04:44.000Z | src/core/checkpoint.h | dani3/sc-emulator | 54b61a56e801c353c15bf3d88f27c836c5559242 | [
"MIT"
] | null | null | null | /**
* \file checkpoint.h
*
* \brief Set of 'checkpoints' that can be left in the code.
*/
#ifndef CHECKPOINT_H
#define CHECKPOINT_H
#include <setjmp.h>
/**
* \brief Action to be performed when a reset has been received.
*/
typedef enum {
COLD_RESET = 1, ///< Perform a cold reset.
ACCEPT_NEW_CONNECTION = 2, ///< Accept a new connection.
EXIT = 3, ///< Exit the process.
} reset_action_t;
/// \brief When a reset is received, this is the `jmp_buf` to be used.
extern jmp_buf g_reset_checkpoint;
#endif
| 22.75 | 70 | 0.652015 |
74c630bb9847185f952a16ee72c0908768dec765 | 11,679 | c | C | sound/soc/sof/intel/atom.c | rajkinkhabwala/linux | bbb30aa9e76b23422327d886527014449b79099a | [
"Linux-OpenIB"
] | null | null | null | sound/soc/sof/intel/atom.c | rajkinkhabwala/linux | bbb30aa9e76b23422327d886527014449b79099a | [
"Linux-OpenIB"
] | null | null | null | sound/soc/sof/intel/atom.c | rajkinkhabwala/linux | bbb30aa9e76b23422327d886527014449b79099a | [
"Linux-OpenIB"
] | null | null | null | // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
//
// This file is provided under a dual BSD/GPLv2 license. When using or
// redistributing this file, you may do so under either license.
//
// Copyright(c) 2018-2021 Intel Corporation. All rights reserved.
//
// Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
//
/*
* Hardware interface for audio DSP on Atom devices
*/
#include <linux/module.h>
#include <sound/sof.h>
#include <sound/sof/xtensa.h>
#include <sound/soc-acpi.h>
#include <sound/soc-acpi-intel-match.h>
#include <sound/intel-dsp-config.h>
#include "../ops.h"
#include "shim.h"
#include "atom.h"
#include "../sof-acpi-dev.h"
#include "../sof-audio.h"
#include "../../intel/common/soc-intel-quirks.h"
static void atom_host_done(struct snd_sof_dev *sdev);
static void atom_dsp_done(struct snd_sof_dev *sdev);
static void atom_get_reply(struct snd_sof_dev *sdev);
/*
* Debug
*/
static void atom_get_registers(struct snd_sof_dev *sdev,
struct sof_ipc_dsp_oops_xtensa *xoops,
struct sof_ipc_panic_info *panic_info,
u32 *stack, size_t stack_words)
{
u32 offset = sdev->dsp_oops_offset;
/* first read regsisters */
sof_mailbox_read(sdev, offset, xoops, sizeof(*xoops));
/* note: variable AR register array is not read */
/* then get panic info */
if (xoops->arch_hdr.totalsize > EXCEPT_MAX_HDR_SIZE) {
dev_err(sdev->dev, "invalid header size 0x%x. FW oops is bogus\n",
xoops->arch_hdr.totalsize);
return;
}
offset += xoops->arch_hdr.totalsize;
sof_mailbox_read(sdev, offset, panic_info, sizeof(*panic_info));
/* then get the stack */
offset += sizeof(*panic_info);
sof_mailbox_read(sdev, offset, stack, stack_words * sizeof(u32));
}
void atom_dump(struct snd_sof_dev *sdev, u32 flags)
{
struct sof_ipc_dsp_oops_xtensa xoops;
struct sof_ipc_panic_info panic_info;
u32 stack[STACK_DUMP_SIZE];
u64 status, panic, imrd, imrx;
/* now try generic SOF status messages */
status = snd_sof_dsp_read64(sdev, DSP_BAR, SHIM_IPCD);
panic = snd_sof_dsp_read64(sdev, DSP_BAR, SHIM_IPCX);
atom_get_registers(sdev, &xoops, &panic_info, stack,
STACK_DUMP_SIZE);
snd_sof_get_status(sdev, status, panic, &xoops, &panic_info, stack,
STACK_DUMP_SIZE);
/* provide some context for firmware debug */
imrx = snd_sof_dsp_read64(sdev, DSP_BAR, SHIM_IMRX);
imrd = snd_sof_dsp_read64(sdev, DSP_BAR, SHIM_IMRD);
dev_err(sdev->dev,
"error: ipc host -> DSP: pending %s complete %s raw 0x%llx\n",
(panic & SHIM_IPCX_BUSY) ? "yes" : "no",
(panic & SHIM_IPCX_DONE) ? "yes" : "no", panic);
dev_err(sdev->dev,
"error: mask host: pending %s complete %s raw 0x%llx\n",
(imrx & SHIM_IMRX_BUSY) ? "yes" : "no",
(imrx & SHIM_IMRX_DONE) ? "yes" : "no", imrx);
dev_err(sdev->dev,
"error: ipc DSP -> host: pending %s complete %s raw 0x%llx\n",
(status & SHIM_IPCD_BUSY) ? "yes" : "no",
(status & SHIM_IPCD_DONE) ? "yes" : "no", status);
dev_err(sdev->dev,
"error: mask DSP: pending %s complete %s raw 0x%llx\n",
(imrd & SHIM_IMRD_BUSY) ? "yes" : "no",
(imrd & SHIM_IMRD_DONE) ? "yes" : "no", imrd);
}
EXPORT_SYMBOL_NS(atom_dump, SND_SOC_SOF_INTEL_ATOM_HIFI_EP);
/*
* IPC Doorbell IRQ handler and thread.
*/
irqreturn_t atom_irq_handler(int irq, void *context)
{
struct snd_sof_dev *sdev = context;
u64 ipcx, ipcd;
int ret = IRQ_NONE;
ipcx = snd_sof_dsp_read64(sdev, DSP_BAR, SHIM_IPCX);
ipcd = snd_sof_dsp_read64(sdev, DSP_BAR, SHIM_IPCD);
if (ipcx & SHIM_BYT_IPCX_DONE) {
/* reply message from DSP, Mask Done interrupt first */
snd_sof_dsp_update_bits64_unlocked(sdev, DSP_BAR,
SHIM_IMRX,
SHIM_IMRX_DONE,
SHIM_IMRX_DONE);
ret = IRQ_WAKE_THREAD;
}
if (ipcd & SHIM_BYT_IPCD_BUSY) {
/* new message from DSP, Mask Busy interrupt first */
snd_sof_dsp_update_bits64_unlocked(sdev, DSP_BAR,
SHIM_IMRX,
SHIM_IMRX_BUSY,
SHIM_IMRX_BUSY);
ret = IRQ_WAKE_THREAD;
}
return ret;
}
EXPORT_SYMBOL_NS(atom_irq_handler, SND_SOC_SOF_INTEL_ATOM_HIFI_EP);
irqreturn_t atom_irq_thread(int irq, void *context)
{
struct snd_sof_dev *sdev = context;
u64 ipcx, ipcd;
ipcx = snd_sof_dsp_read64(sdev, DSP_BAR, SHIM_IPCX);
ipcd = snd_sof_dsp_read64(sdev, DSP_BAR, SHIM_IPCD);
/* reply message from DSP */
if (ipcx & SHIM_BYT_IPCX_DONE) {
spin_lock_irq(&sdev->ipc_lock);
/*
* handle immediate reply from DSP core. If the msg is
* found, set done bit in cmd_done which is called at the
* end of message processing function, else set it here
* because the done bit can't be set in cmd_done function
* which is triggered by msg
*/
atom_get_reply(sdev);
snd_sof_ipc_reply(sdev, ipcx);
atom_dsp_done(sdev);
spin_unlock_irq(&sdev->ipc_lock);
}
/* new message from DSP */
if (ipcd & SHIM_BYT_IPCD_BUSY) {
/* Handle messages from DSP Core */
if ((ipcd & SOF_IPC_PANIC_MAGIC_MASK) == SOF_IPC_PANIC_MAGIC) {
snd_sof_dsp_panic(sdev, PANIC_OFFSET(ipcd) +
MBOX_OFFSET);
} else {
snd_sof_ipc_msgs_rx(sdev);
}
atom_host_done(sdev);
}
return IRQ_HANDLED;
}
EXPORT_SYMBOL_NS(atom_irq_thread, SND_SOC_SOF_INTEL_ATOM_HIFI_EP);
int atom_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg)
{
/* unmask and prepare to receive Done interrupt */
snd_sof_dsp_update_bits64_unlocked(sdev, DSP_BAR, SHIM_IMRX,
SHIM_IMRX_DONE, 0);
/* send the message */
sof_mailbox_write(sdev, sdev->host_box.offset, msg->msg_data,
msg->msg_size);
snd_sof_dsp_write64(sdev, DSP_BAR, SHIM_IPCX, SHIM_BYT_IPCX_BUSY);
return 0;
}
EXPORT_SYMBOL_NS(atom_send_msg, SND_SOC_SOF_INTEL_ATOM_HIFI_EP);
static void atom_get_reply(struct snd_sof_dev *sdev)
{
struct snd_sof_ipc_msg *msg = sdev->msg;
struct sof_ipc_reply reply;
int ret = 0;
/*
* Sometimes, there is unexpected reply ipc arriving. The reply
* ipc belongs to none of the ipcs sent from driver.
* In this case, the driver must ignore the ipc.
*/
if (!msg) {
dev_warn(sdev->dev, "unexpected ipc interrupt raised!\n");
return;
}
/* get reply */
sof_mailbox_read(sdev, sdev->host_box.offset, &reply, sizeof(reply));
if (reply.error < 0) {
memcpy(msg->reply_data, &reply, sizeof(reply));
ret = reply.error;
} else {
/* reply correct size ? */
if (reply.hdr.size != msg->reply_size) {
dev_err(sdev->dev, "error: reply expected %zu got %u bytes\n",
msg->reply_size, reply.hdr.size);
ret = -EINVAL;
}
/* read the message */
if (msg->reply_size > 0)
sof_mailbox_read(sdev, sdev->host_box.offset,
msg->reply_data, msg->reply_size);
}
msg->reply_error = ret;
}
int atom_get_mailbox_offset(struct snd_sof_dev *sdev)
{
return MBOX_OFFSET;
}
EXPORT_SYMBOL_NS(atom_get_mailbox_offset, SND_SOC_SOF_INTEL_ATOM_HIFI_EP);
int atom_get_window_offset(struct snd_sof_dev *sdev, u32 id)
{
return MBOX_OFFSET;
}
EXPORT_SYMBOL_NS(atom_get_window_offset, SND_SOC_SOF_INTEL_ATOM_HIFI_EP);
static void atom_host_done(struct snd_sof_dev *sdev)
{
/* clear BUSY bit and set DONE bit - accept new messages */
snd_sof_dsp_update_bits64_unlocked(sdev, DSP_BAR, SHIM_IPCD,
SHIM_BYT_IPCD_BUSY |
SHIM_BYT_IPCD_DONE,
SHIM_BYT_IPCD_DONE);
/* unmask and prepare to receive next new message */
snd_sof_dsp_update_bits64_unlocked(sdev, DSP_BAR, SHIM_IMRX,
SHIM_IMRX_BUSY, 0);
}
static void atom_dsp_done(struct snd_sof_dev *sdev)
{
/* clear DONE bit - tell DSP we have completed */
snd_sof_dsp_update_bits64_unlocked(sdev, DSP_BAR, SHIM_IPCX,
SHIM_BYT_IPCX_DONE, 0);
}
/*
* DSP control.
*/
int atom_run(struct snd_sof_dev *sdev)
{
int tries = 10;
/* release stall and wait to unstall */
snd_sof_dsp_update_bits64(sdev, DSP_BAR, SHIM_CSR,
SHIM_BYT_CSR_STALL, 0x0);
while (tries--) {
if (!(snd_sof_dsp_read64(sdev, DSP_BAR, SHIM_CSR) &
SHIM_BYT_CSR_PWAITMODE))
break;
msleep(100);
}
if (tries < 0)
return -ENODEV;
/* return init core mask */
return 1;
}
EXPORT_SYMBOL_NS(atom_run, SND_SOC_SOF_INTEL_ATOM_HIFI_EP);
int atom_reset(struct snd_sof_dev *sdev)
{
/* put DSP into reset, set reset vector and stall */
snd_sof_dsp_update_bits64(sdev, DSP_BAR, SHIM_CSR,
SHIM_BYT_CSR_RST | SHIM_BYT_CSR_VECTOR_SEL |
SHIM_BYT_CSR_STALL,
SHIM_BYT_CSR_RST | SHIM_BYT_CSR_VECTOR_SEL |
SHIM_BYT_CSR_STALL);
usleep_range(10, 15);
/* take DSP out of reset and keep stalled for FW loading */
snd_sof_dsp_update_bits64(sdev, DSP_BAR, SHIM_CSR,
SHIM_BYT_CSR_RST, 0);
return 0;
}
EXPORT_SYMBOL_NS(atom_reset, SND_SOC_SOF_INTEL_ATOM_HIFI_EP);
static const char *fixup_tplg_name(struct snd_sof_dev *sdev,
const char *sof_tplg_filename,
const char *ssp_str)
{
const char *tplg_filename = NULL;
char *filename;
char *split_ext;
filename = devm_kstrdup(sdev->dev, sof_tplg_filename, GFP_KERNEL);
if (!filename)
return NULL;
/* this assumes a .tplg extension */
split_ext = strsep(&filename, ".");
if (split_ext) {
tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL,
"%s-%s.tplg",
split_ext, ssp_str);
if (!tplg_filename)
return NULL;
}
return tplg_filename;
}
void atom_machine_select(struct snd_sof_dev *sdev)
{
struct snd_sof_pdata *sof_pdata = sdev->pdata;
const struct sof_dev_desc *desc = sof_pdata->desc;
struct snd_soc_acpi_mach *mach;
struct platform_device *pdev;
const char *tplg_filename;
mach = snd_soc_acpi_find_machine(desc->machines);
if (!mach) {
dev_warn(sdev->dev, "warning: No matching ASoC machine driver found\n");
return;
}
pdev = to_platform_device(sdev->dev);
if (soc_intel_is_byt_cr(pdev)) {
dev_dbg(sdev->dev,
"BYT-CR detected, SSP0 used instead of SSP2\n");
tplg_filename = fixup_tplg_name(sdev,
mach->sof_tplg_filename,
"ssp0");
} else {
tplg_filename = mach->sof_tplg_filename;
}
if (!tplg_filename) {
dev_dbg(sdev->dev,
"error: no topology filename\n");
return;
}
sof_pdata->tplg_filename = tplg_filename;
mach->mach_params.acpi_ipc_irq_index = desc->irqindex_host_ipc;
sof_pdata->machine = mach;
}
EXPORT_SYMBOL_NS(atom_machine_select, SND_SOC_SOF_INTEL_ATOM_HIFI_EP);
/* Atom DAIs */
struct snd_soc_dai_driver atom_dai[] = {
{
.name = "ssp0-port",
.playback = {
.channels_min = 1,
.channels_max = 8,
},
.capture = {
.channels_min = 1,
.channels_max = 8,
},
},
{
.name = "ssp1-port",
.playback = {
.channels_min = 1,
.channels_max = 8,
},
.capture = {
.channels_min = 1,
.channels_max = 8,
},
},
{
.name = "ssp2-port",
.playback = {
.channels_min = 1,
.channels_max = 8,
},
.capture = {
.channels_min = 1,
.channels_max = 8,
}
},
{
.name = "ssp3-port",
.playback = {
.channels_min = 1,
.channels_max = 8,
},
.capture = {
.channels_min = 1,
.channels_max = 8,
},
},
{
.name = "ssp4-port",
.playback = {
.channels_min = 1,
.channels_max = 8,
},
.capture = {
.channels_min = 1,
.channels_max = 8,
},
},
{
.name = "ssp5-port",
.playback = {
.channels_min = 1,
.channels_max = 8,
},
.capture = {
.channels_min = 1,
.channels_max = 8,
},
},
};
EXPORT_SYMBOL_NS(atom_dai, SND_SOC_SOF_INTEL_ATOM_HIFI_EP);
void atom_set_mach_params(const struct snd_soc_acpi_mach *mach,
struct snd_sof_dev *sdev)
{
struct snd_sof_pdata *pdata = sdev->pdata;
const struct sof_dev_desc *desc = pdata->desc;
struct snd_soc_acpi_mach_params *mach_params;
mach_params = (struct snd_soc_acpi_mach_params *)&mach->mach_params;
mach_params->platform = dev_name(sdev->dev);
mach_params->num_dai_drivers = desc->ops->num_drv;
mach_params->dai_drivers = desc->ops->drv;
}
EXPORT_SYMBOL_NS(atom_set_mach_params, SND_SOC_SOF_INTEL_ATOM_HIFI_EP);
MODULE_LICENSE("Dual BSD/GPL");
| 25.334056 | 74 | 0.70494 |
de79728922c6374f8d6f5fa3d5696e20b758c47e | 172 | c | C | getMaxPIDTest.c | yousef-virgal/operating-system-project | 31b4116df77f7dd6aa72ce6e813207ba80395da3 | [
"MIT-0"
] | null | null | null | getMaxPIDTest.c | yousef-virgal/operating-system-project | 31b4116df77f7dd6aa72ce6e813207ba80395da3 | [
"MIT-0"
] | null | null | null | getMaxPIDTest.c | yousef-virgal/operating-system-project | 31b4116df77f7dd6aa72ce6e813207ba80395da3 | [
"MIT-0"
] | null | null | null | #include "types.h"
#include "stat.h"
#include "user.h"
int
main(void){
printf(1, "The maximum PID of all active processes in the system is %d\n", getMaxPID());
exit();
} | 19.111111 | 89 | 0.674419 |
d31581c01cb7d78db1fbfe8da520751343ed0bd1 | 2,090 | h | C | src/stt/stt_operations_simple_list.h | katesalazar/bat | 3c84a3c2263f3d40147411843c066b9313b967b4 | [
"Apache-2.0"
] | 1 | 2019-06-04T22:39:37.000Z | 2019-06-04T22:39:37.000Z | src/stt/stt_operations_simple_list.h | katesalazar/bat | 3c84a3c2263f3d40147411843c066b9313b967b4 | [
"Apache-2.0"
] | null | null | null | src/stt/stt_operations_simple_list.h | katesalazar/bat | 3c84a3c2263f3d40147411843c066b9313b967b4 | [
"Apache-2.0"
] | null | null | null | /*
* Copyright 2018-2019 Mercedes Catherine Salazar
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* src/stt/stt_operations_simple_list.h: Amara syntax tree application
* function operations simple list.
*/
#ifndef __AMARA__SYNTAX_TREE__OPERATIONS_SIMPLE_LIST__H__
#define __AMARA__SYNTAX_TREE__OPERATIONS_SIMPLE_LIST__H__
#include "../definitions.h"
/* For `stt_operation`. */
#include "stt_operation.h"
typedef struct stt_operations_simple_list {
stt_operation * first;
struct stt_operations_simple_list * next;
} stt_operations_simple_list;
stt_operations_simple_list *
stt_operations_simple_list_default_constructor(void)
__attribute__((warn_unused_result))
;
stt_operations_simple_list *
stt_operations_simple_list_copy_constructor(
const stt_operations_simple_list * operations)
__attribute__((warn_unused_result))
;
void
stt_operations_simple_list_destructor(stt_operations_simple_list * list)
;
stt_operations_simple_list *
stt_operations_simple_list_push_front(
stt_operations_simple_list * operations,
const stt_operation * operation)
__attribute__((warn_unused_result))
;
void
stt_operations_simple_list_push_back(
stt_operations_simple_list * operations,
const stt_operation * operation)
;
amara_boolean
stt_operations_simple_list_equality(
const stt_operations_simple_list * l0,
const stt_operations_simple_list * l1)
__attribute__((warn_unused_result))
;
amara_boolean
stt_operations_simple_lists_equality(
const stt_operations_simple_list * l0,
const stt_operations_simple_list * l1)
__amara__warn_unused_result__
;
#endif
| 27.5 | 75 | 0.814354 |
5adb81f4e3ce459424422f265c2af153e55fff8d | 1,557 | h | C | butano/include/bn_log.h | laqieer/butano | 986ec1d235922fbe7acafa7564a911085d3a9c6e | [
"Zlib"
] | 1 | 2022-02-06T10:02:14.000Z | 2022-02-06T10:02:14.000Z | butano/include/bn_log.h | laqieer/butano | 986ec1d235922fbe7acafa7564a911085d3a9c6e | [
"Zlib"
] | null | null | null | butano/include/bn_log.h | laqieer/butano | 986ec1d235922fbe7acafa7564a911085d3a9c6e | [
"Zlib"
] | null | null | null | /*
* Copyright (c) 2020-2022 Gustavo Valiente gustavo.valiente@protonmail.com
* zlib License, see LICENSE file.
*/
#ifndef BN_LOG_H
#define BN_LOG_H
/**
* @file
* BN_LOG header file.
*
* @ingroup log
*/
#include "bn_config_log.h"
#include "bn_config_doxygen.h"
/**
* @def BN_LOG(...)
*
* Prints in one line of text the representation of the given parameters.
*
* Example:
*
* @code{.cpp}
* BN_LOG("Invalid integer: ", integer);
* @endcode
*
* Custom parameter types are supported by overloading bn::ostringstream::operator<<.
*
* Example:
*
* @code{.cpp}
* bn::ostringstream& operator<<(bn::ostringstream& stream, const custom_type& custom_value)
* {
* stream.append("custom_type: ");
* stream.append(custom_value.data);
* return stream;
* }
* @endcode
*
* @ingroup log
*/
#if BN_CFG_LOG_ENABLED || BN_DOXYGEN
#include "bn_sstream.h"
#include "bn_istring_base.h"
#define BN_LOG(...) \
do \
{ \
char _bn_string[BN_CFG_LOG_MAX_SIZE]; \
bn::istring_base _bn_istring(_bn_string); \
bn::ostringstream _bn_string_stream(_bn_istring); \
_bn_string_stream.append_args(__VA_ARGS__); \
bn::log(_bn_istring); \
} while(false)
namespace bn
{
/**
* @brief Prints in one line of text the given message.
*
* @ingroup log
*/
void log(const istring_base& message);
}
#else
#define BN_LOG(...) \
do \
{ \
} while(false)
#endif
#endif
| 20.220779 | 92 | 0.597945 |
c1cc746b362102bc09c48d701d8d5a9ec70c93a6 | 1,046 | h | C | include/bits/minelement.h | peterlauro/type_list | 945695a5d45362f2a676945d49675b0e78dbee3f | [
"Apache-2.0"
] | null | null | null | include/bits/minelement.h | peterlauro/type_list | 945695a5d45362f2a676945d49675b0e78dbee3f | [
"Apache-2.0"
] | null | null | null | include/bits/minelement.h | peterlauro/type_list | 945695a5d45362f2a676945d49675b0e78dbee3f | [
"Apache-2.0"
] | null | null | null | #ifndef STDX_BITS_MINELEMENT_H
#define STDX_BITS_MINELEMENT_H
#include <cstdlib>
namespace stdx::detail
{
template<typename List>
struct min_element_mixin
{
template<class Compare>
static constexpr std::size_t min_element(Compare comp)
{
if constexpr (List::empty())
{
return List::npos;
}
else if constexpr (List::size() == 1U)
{
return 0U;
}
else
{
return min_element_impl<0U, 1U>(comp);
}
}
private:
template<std::size_t SmallestIdx, std::size_t Idx, typename Compare>
static constexpr std::size_t min_element_impl(Compare comp)
{
if constexpr (Idx < List::size())
{
if constexpr (comp(List::template get<Idx>(), List::template get<SmallestIdx>()))
{
return min_element_impl<Idx, Idx + 1U>(comp);
}
else
{
return min_element_impl<SmallestIdx, Idx + 1U>(comp);
}
}
else
{
return SmallestIdx;
}
}
};
}
#endif
| 20.115385 | 89 | 0.572658 |
94232fe715a9cfad67ae8108dea927448982e401 | 7,110 | h | C | include/amino/rx/rx_ct.h | dyalab/amino | e3063ceeeed7d1a3d55fc0d3071c9aacb4466b22 | [
"BSD-3-Clause"
] | 32 | 2015-06-02T20:06:09.000Z | 2022-03-14T16:49:22.000Z | include/amino/rx/rx_ct.h | dyalab/amino | e3063ceeeed7d1a3d55fc0d3071c9aacb4466b22 | [
"BSD-3-Clause"
] | 28 | 2016-05-18T20:54:44.000Z | 2021-03-22T23:43:23.000Z | include/amino/rx/rx_ct.h | dyalab/amino | e3063ceeeed7d1a3d55fc0d3071c9aacb4466b22 | [
"BSD-3-Clause"
] | 20 | 2016-01-05T18:55:14.000Z | 2022-02-22T01:32:20.000Z | /* -*- mode: C; c-basic-offset: 4; -*- */
/* ex: set shiftwidth=4 tabstop=4 expandtab: */
/*
* Copyright (c) 2017, Rice University
* Copyright (c) 2018, Colorado School of Mines
* All rights reserved.
*
* Author(s): Neil T. Dantam <ndantam@mines.edu>
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of copyright holder the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef AMINO_RX_CT_H
#define AMINO_RX_CT_H
/**
* @file rx_ct.h
* @brief Integration between scene graphs and control
*/
#include "amino/ct/state.h"
#include "amino/ct/traj.h"
/**
* Return a point list for a path.
*
* @param region Memory region to allocate point list from
* @param n_q Number of configuration variables
* @param n_path Number of waypoints in the path
* @param path Path data
*/
AA_API struct aa_ct_pt_list *
aa_rx_ct_pt_list( struct aa_mem_region *region,
size_t n_q, size_t n_path, double *path );
/**
* Extract the limits from a scene graph.
*
* @param region Memory region to allocate limits from
* @param sg The scene graph
*/
AA_API struct aa_ct_limit *
aa_rx_ct_limits( struct aa_mem_region *region, const struct aa_rx_sg *sg );
AA_API int
aa_rx_ct_tjx_path( struct aa_mem_region *region,
const struct aa_rx_ik_parm *opts,
const struct aa_rx_sg_sub *ssg,
struct aa_ct_seg_list *segs,
size_t n_q_all, const double *q_start_all,
size_t *n_points, double **path );
AA_API struct aa_ct_limit *
aa_rx_ct_sg_limits( struct aa_mem_region *region, const struct aa_rx_sg *sg );
/**
* @struct aa_rx_ct_wk_opts
* Opaque structure for workspace control options.
*/
struct aa_rx_ct_wk_opts;
/**
* Create workspce control options.
*/
AA_API struct aa_rx_ct_wk_opts *
aa_rx_ct_wk_opts_create(void);
/**
* Destroy workspce control options.
*/
AA_API void
aa_rx_ct_wk_opts_destroy( struct aa_rx_ct_wk_opts * );
/**
* Proportional control on pose error.
*
* The computed reference term is ADDED to dx.
*
* @param[in] opts Workspace control options
* @param[in] E_act Actual pose (quaternion-translation)
* @param[in] E_ref Reference pose (quaternion-translation)
* @param[inout] dx Reference workspace velocity
*/
AA_API void
aa_rx_ct_wk_dx_pos( const struct aa_rx_ct_wk_opts * opts,
const double *E_act, const double *E_ref,
double *dx );
/**
* Convert workspace (Cartesian) velocity to joint velocity.
*
* @param[in] ssg the subscenegraph to control
* @param[in] opts workspace control options
* @param[in] n_tf number of frames in TF_abs
* @param[in] TF_abs absolute frames (quaternion-translations) for the entire scenegraph
* @param[in] ld_tf Leading dimension of TF_abs
* @param[in] n_x size of dx
* @param[in] dx reference workspace velocity
* @param[in] n_q size of dq
* @param[out] dq reference joint velocity for subscenegraph
*/
AA_API int
aa_rx_ct_wk_dx2dq( const const struct aa_rx_sg_sub *ssg,
const struct aa_rx_ct_wk_opts * opts,
size_t n_tf, const double *TF_abs, size_t ld_tf,
size_t n_x, const double *dx,
size_t n_q, double *dq );
/**
* Convert workspace (Cartesian) velocity to joint velocity, with
* nullspace projection
*
* @see aa_rx_ct_wk_dqcenter()
*
* @param[in] ssg the subscenegraph to control
* @param[in] opts workspace control options
* @param[in] n_tf number of frames in TF_abs
* @param[in] TF_abs absolute frames (quaternion-translations) for the entire scenegraph
* @param[in] ld_tf Leading dimension of TF_abs
* @param[in] n_x size of dx
* @param[in] dx reference workspace velocity
* @param[in] n_q size of dq
* @param[in] dq_r reference joint velocity (nullspace projected) for subscenegraph
* @param[out] dq computed reference joint velocity for subscenegraph
*/
AA_API int
aa_rx_ct_wk_dx2dq_np( const const struct aa_rx_sg_sub *ssg,
const struct aa_rx_ct_wk_opts * opts,
size_t n_tf, const double *TF_abs, size_t ld_tf,
size_t n_x, const double *dx,
size_t n_q, const double *dq_r, double *dq );
/**
* @struct aa_rx_ct_wk_lc3_cx;
*
* Opaque context struct for LC3.
*
* Z. Kingston, N. Dantam, and L. Kavraki.
* [Kinematically Constrained Workspace Control via Linear Optimization]
* (http://dx.doi.org/10.1109/HUMANOIDS.2015.7363455). International
* Conference on Humanoid Robots (Humanoids), IEEE. 2015.
*
*/
struct aa_rx_ct_wk_lc3_cx;
AA_API struct aa_rx_ct_wk_lc3_cx *
aa_rx_ct_wk_lc3_create ( const const struct aa_rx_sg_sub *ssg,
const struct aa_rx_ct_wk_opts * opts );
AA_API int
aa_rx_ct_wk_dx2dq_lc3( const struct aa_rx_ct_wk_lc3_cx *lc3,
double dt,
size_t n_tf, const double *TF_abs, size_t ld_tf,
size_t n_x, const double *dx_r,
size_t n_q,
const double *q_a, const double *dq_a,
const double *dq_r, double *dq );
/**
* Find joint-centering reference velocity.
*
* @param[in] ssg the subscenegraph to control
* @param[in] opts workspace control options
* @param[in] n_q size of q
* @param[in] q actual joint positions for the subscenegraph
* @param[out] dq_r centering velocities for the subscenegraph
*/
AA_API void
aa_rx_ct_wk_dqcenter( const const struct aa_rx_sg_sub *ssg,
const struct aa_rx_ct_wk_opts * opts,
size_t n_q, const double *q, double *dq_r );
#endif /*AMINO_RX_CT_H*/
| 34.514563 | 88 | 0.687482 |
ea18cac20ad489b2f139971fed5847bfce05c720 | 585 | h | C | iOS/Runtime/MethodSwizzling/MethodSwizzling/SwizzlingMethodObject.h | lzackx/Zone | bf8a3d2b965c383a691a6e7b61d23db15ce11dba | [
"MIT"
] | null | null | null | iOS/Runtime/MethodSwizzling/MethodSwizzling/SwizzlingMethodObject.h | lzackx/Zone | bf8a3d2b965c383a691a6e7b61d23db15ce11dba | [
"MIT"
] | null | null | null | iOS/Runtime/MethodSwizzling/MethodSwizzling/SwizzlingMethodObject.h | lzackx/Zone | bf8a3d2b965c383a691a6e7b61d23db15ce11dba | [
"MIT"
] | null | null | null | //
// SwizzlingMethodObject.h
// MethodSwizzling
//
// Created by lzackx on 2018/3/15.
// Copyright © 2018年 lzackx. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface SwizzlingMethodObject : NSObject
- (instancetype)initWithOriginalClass:(Class)original_class
OriginalSelector:(SEL)original_selector
OriginalIMP:(IMP)original_imp
SMClass:(Class)sm_class
SMSelector:(SEL)sm_selector
SMIMP:(IMP)sm_imp;
- (void)swizzle;
@end
| 26.590909 | 60 | 0.596581 |
ea40e9cbe3136523ce92d89885c46e9d1c94fd4c | 2,699 | h | C | Engine/Source/Editor/DetailCustomizations/Private/IntervalStructCustomization.h | PopCap/GameIdea | 201e1df50b2bc99afc079ce326aa0a44b178a391 | [
"BSD-2-Clause"
] | null | null | null | Engine/Source/Editor/DetailCustomizations/Private/IntervalStructCustomization.h | PopCap/GameIdea | 201e1df50b2bc99afc079ce326aa0a44b178a391 | [
"BSD-2-Clause"
] | 2 | 2015-06-21T17:38:11.000Z | 2015-06-22T20:54:42.000Z | Engine/Source/Editor/DetailCustomizations/Private/IntervalStructCustomization.h | PopCap/GameIdea | 201e1df50b2bc99afc079ce326aa0a44b178a391 | [
"BSD-2-Clause"
] | null | null | null | // Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#pragma once
/**
* Implements a details panel customization for numeric TInterval structures.
*/
template <typename NumericType>
class FIntervalStructCustomization : public IPropertyTypeCustomization
{
public:
FIntervalStructCustomization()
: bIsUsingSlider(false) {}
public:
// IPropertyTypeCustomization interface
virtual void CustomizeHeader(TSharedRef<IPropertyHandle> StructPropertyHandle, FDetailWidgetRow& HeaderRow, IPropertyTypeCustomizationUtils& StructCustomizationUtils) override;
virtual void CustomizeChildren(TSharedRef<IPropertyHandle> StructPropertyHandle, IDetailChildrenBuilder& StructBuilder, IPropertyTypeCustomizationUtils& StructCustomizationUtils) override;
public:
/**
* Creates a new instance.
*
* @return A new struct customization for Guids.
*/
static TSharedRef<IPropertyTypeCustomization> MakeInstance();
protected:
/**
* Gets the value for the provided property handle
*
* @param ValueWeakPtr Handle to the property to get the value from
* @return The value or unset if it could not be accessed
*/
TOptional<NumericType> OnGetValue(TWeakPtr<IPropertyHandle> ValueWeakPtr) const;
/**
* Called when the value is committed from the property editor
*
* @param NewValue The new value of the property
* @param CommitType How the value was committed (unused)
* @param HandleWeakPtr Handle to the property that the new value is for
*/
void OnValueCommitted(NumericType NewValue, ETextCommit::Type CommitType, TWeakPtr<IPropertyHandle> HandleWeakPtr);
/**
* Called when the value is changed in the property editor
*
* @param NewValue The new value of the property
* @param HandleWeakPtr Handle to the property that the new value is for
*/
void OnValueChanged(NumericType NewValue, TWeakPtr<IPropertyHandle> HandleWeakPtr);
/**
* Called when a value starts to be changed by a slider
*/
void OnBeginSliderMovement();
/**
* Called when a value stops being changed by a slider
*
* @param NewValue The new value of the property
*/
void OnEndSliderMovement(NumericType NewValue);
/**
* Determines if the spin box is enabled on a numeric value widget
*
* @return Whether the spin box should be enabled.
*/
bool ShouldAllowSpin() const;
// Cached shared pointers to properties that we are managing
TSharedPtr<IPropertyHandle> MinValueHandle;
TSharedPtr<IPropertyHandle> MaxValueHandle;
// Min and max allowed values from the metadata
TOptional<NumericType> MinAllowedValue;
TOptional<NumericType> MaxAllowedValue;
// Flags whether the slider is being moved at the moment on any of our widgets
bool bIsUsingSlider;
};
| 30.325843 | 189 | 0.772138 |
c6e495d34fe95bb31b3b9a188ad8a3bf6a582809 | 4,887 | c | C | src/tool/hpcrun/syscalls/select.c | vladaindjic/hpctoolkit | 8a401b37384965272fabcee57064dcfa614ff834 | [
"BSD-3-Clause"
] | null | null | null | src/tool/hpcrun/syscalls/select.c | vladaindjic/hpctoolkit | 8a401b37384965272fabcee57064dcfa614ff834 | [
"BSD-3-Clause"
] | null | null | null | src/tool/hpcrun/syscalls/select.c | vladaindjic/hpctoolkit | 8a401b37384965272fabcee57064dcfa614ff834 | [
"BSD-3-Clause"
] | 2 | 2021-11-30T18:24:10.000Z | 2022-02-13T18:13:17.000Z | // -*-Mode: C++;-*- // technically C99
// * BeginRiceCopyright *****************************************************
//
// $HeadURL$
// $Id$
//
// --------------------------------------------------------------------------
// Part of HPCToolkit (hpctoolkit.org)
//
// Information about sources of support for research and development of
// HPCToolkit is at 'hpctoolkit.org' and in 'README.Acknowledgments'.
// --------------------------------------------------------------------------
//
// Copyright ((c)) 2002-2020, Rice University
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of Rice University (RICE) nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// This software is provided by RICE and contributors "as is" and any
// express or implied warranties, including, but not limited to, the
// implied warranties of merchantability and fitness for a particular
// purpose are disclaimed. In no event shall RICE or contributors be
// liable for any direct, indirect, incidental, special, exemplary, or
// consequential damages (including, but not limited to, procurement of
// substitute goods or services; loss of use, data, or profits; or
// business interruption) however caused and on any theory of liability,
// whether in contract, strict liability, or tort (including negligence
// or otherwise) arising in any way out of the use of this software, even
// if advised of the possibility of such damage.
//
// ******************************************************* EndRiceCopyright *
//------------------------------------------------------------------------------
// File: select.c
//
// Purpose:
// wrapper for libc select. if select returns a -1 because it was
// interrupted, assume the interrupt was from asynchronous sampling
// caused by hpcrun and restart.
//
// Note:
// The kernel automatically updates the timout parameter for select(),
// but not for poll(), ppoll() or pselect().
//------------------------------------------------------------------------------
//******************************************************************************
// system includes
//******************************************************************************
#define _GNU_SOURCE 1
#include <sys/types.h>
#include <sys/time.h>
#include <sys/select.h>
#include <assert.h>
#include <errno.h>
#include <pthread.h>
#include <stdlib.h>
#include <unistd.h>
#ifndef HPCRUN_STATIC_LINK
#include <dlfcn.h>
#endif
#include <monitor-exts/monitor_ext.h>
//******************************************************************************
// type declarations
//******************************************************************************
typedef int select_fn
(
int nfds,
fd_set *read_fds,
fd_set *write_fds,
fd_set *except_fds,
struct timeval *timeout
);
//******************************************************************************
// local data
//******************************************************************************
#ifdef HPCRUN_STATIC_LINK
extern select_fn __real_select;
#endif
static select_fn *real_select = NULL;
//******************************************************************************
// local operations
//******************************************************************************
static void
find_select(void)
{
#ifdef HPCRUN_STATIC_LINK
real_select = __real_select;
#else
real_select = (select_fn *) dlsym(RTLD_NEXT, "select");
#endif
assert(real_select);
}
//******************************************************************************
// interface operations
//******************************************************************************
int
MONITOR_EXT_WRAP_NAME(select)
(
int nfds,
fd_set *read_fds,
fd_set *write_fds,
fd_set *except_fds,
struct timeval *timeout
)
{
static pthread_once_t initialized = PTHREAD_ONCE_INIT;
pthread_once(&initialized, find_select);
int retval;
int incoming_errno = errno; // save incoming errno
for(;;) {
retval = (* real_select) (nfds, read_fds, write_fds, except_fds, timeout);
if (retval == -1) {
if (errno == EINTR) {
// restart on EINTR
errno = incoming_errno; // restore incoming errno
continue;
}
}
// return otherwise
break;
}
return retval;
}
| 30.166667 | 80 | 0.536935 |
0c8e34afe7cf54a397aff4dc87597ca489029f46 | 324 | h | C | budejie/budejie/Classes/Essence/View/ELTopicVideoView.h | CoderEllis/budejie | deb15cf246445d9e06ee190f3ead9f27eb74de2b | [
"Apache-2.0"
] | null | null | null | budejie/budejie/Classes/Essence/View/ELTopicVideoView.h | CoderEllis/budejie | deb15cf246445d9e06ee190f3ead9f27eb74de2b | [
"Apache-2.0"
] | null | null | null | budejie/budejie/Classes/Essence/View/ELTopicVideoView.h | CoderEllis/budejie | deb15cf246445d9e06ee190f3ead9f27eb74de2b | [
"Apache-2.0"
] | null | null | null | //
// ELTopicVideoView.h
// budejie
//
// Created by Soul Ai on 29/11/2018.
// Copyright © 2018 Soul Ai. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class ELTopic;
@interface ELTopicVideoView : UIView
/** 模型数据 */
@property (nonatomic, strong) ELTopic *topic;
@end
NS_ASSUME_NONNULL_END
| 15.428571 | 50 | 0.712963 |
7b75b2607e1edd499931f40b529f022f028d1e7a | 371 | h | C | Hoko/HOKFilterBlockWrapper.h | YourMD/hoko-ios | 6bc738ad8d43375fc6244ed87e5263d74cea3d77 | [
"Apache-2.0"
] | 32 | 2015-01-16T17:49:33.000Z | 2016-05-09T01:25:10.000Z | Hoko/HOKFilterBlockWrapper.h | YourMD/hoko-ios | 6bc738ad8d43375fc6244ed87e5263d74cea3d77 | [
"Apache-2.0"
] | 4 | 2016-10-20T10:39:50.000Z | 2018-12-01T20:53:09.000Z | Hoko/HOKFilterBlockWrapper.h | YourMD/hoko-ios | 6bc738ad8d43375fc6244ed87e5263d74cea3d77 | [
"Apache-2.0"
] | 8 | 2016-06-12T08:44:36.000Z | 2019-05-23T11:30:58.000Z | //
// HOKFilterBlockWrapper.h
// Hoko
//
// Created by Hoko, S.A. on 04/08/15.
// Copyright (c) 2015 Hoko, S.A. All rights reserved.
//
#import "HOKDeeplink.h"
@interface HOKFilterBlockWrapper : NSObject
- (instancetype)initWithFilterBlock:(BOOL (^)(HOKDeeplink *deeplink))filterBlock;
@property (nonatomic, copy) BOOL (^filterBlock)(HOKDeeplink *deeplink);
@end | 21.823529 | 81 | 0.714286 |
72fd748ec188a8c959011d5c13d57d530fd73836 | 3,965 | h | C | common/inc/qcc/windows/util.h | liuxiang88/core-alljoyn | 549c966482d9b89da84aa528117584e7049916cb | [
"Apache-2.0"
] | 33 | 2018-01-12T00:37:43.000Z | 2022-03-24T02:31:36.000Z | common/inc/qcc/windows/util.h | liuxiang88/core-alljoyn | 549c966482d9b89da84aa528117584e7049916cb | [
"Apache-2.0"
] | 1 | 2020-01-05T05:51:27.000Z | 2020-01-05T05:51:27.000Z | common/inc/qcc/windows/util.h | liuxiang88/core-alljoyn | 549c966482d9b89da84aa528117584e7049916cb | [
"Apache-2.0"
] | 30 | 2017-12-13T23:24:00.000Z | 2022-01-25T02:11:19.000Z | #ifndef _QCC_UTIL_WINDOWS_H
#define _QCC_UTIL_WINDOWS_H
/**
* @file
*
* This file provides platform specific macros for Windows
*/
/******************************************************************************
* Copyright (c) Open Connectivity Foundation (OCF), AllJoyn Open Source
* Project (AJOSP) Contributors and others.
*
* SPDX-License-Identifier: Apache-2.0
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Apache License, Version 2.0
* which accompanies this distribution, and is available at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Copyright (c) Open Connectivity Foundation and Contributors to AllSeen
* Alliance. All rights reserved.
*
* Permission to use, copy, modify, and/or distribute this software for
* any purpose with or without fee is hereby granted, provided that the
* above copyright notice and this permission notice appear in all
* copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
* AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
******************************************************************************/
/* Windows only runs on little endian machines (for now?) */
#include <stdlib.h>
/**
* This target is little endian
*/
#define QCC_TARGET_ENDIAN QCC_LITTLE_ENDIAN
/*
* Define some endian conversion macros to be compatible with posix macros.
* Macros with the _same_ names are available on BSD (and Android Bionic)
* systems (and with _similar_ names on GLibC based systems).
*
* Don't bother with a version of those macros for big-endian targets for
* Windows.
*/
#define htole16(_val) (_val)
#define htole32(_val) (_val)
#define htole64(_val) (_val)
#define htobe16(_val) _byteswap_ushort(_val)
#define htobe32(_val) _byteswap_ulong(_val)
#define htobe64(_val) _byteswap_uint64(_val)
#define letoh16(_val) (_val)
#define letoh32(_val) (_val)
#define letoh64(_val) (_val)
#define betoh16(_val) _byteswap_ushort(_val)
#define betoh32(_val) _byteswap_ulong(_val)
#define betoh64(_val) _byteswap_uint64(_val)
/**
* Swap bytes to convert endianness of a 16 bit integer
*/
#define EndianSwap16(_val) (_byteswap_ushort(_val))
/**
* Swap bytes to convert endianness of a 32 bit integer
*/
#define EndianSwap32(_val) (_byteswap_ulong(_val))
/**
* Swap bytes to convert endianness of a 64 bit integer
*/
#define EndianSwap64(_val) (_byteswap_uint64(_val))
#define ER_DIR_SEPARATOR "\\"
/**
* Non-standard/non-compliant snprintf implementation, based on _vsnprintf.
*
* @remark This function always adds a zero character string terminator,
* even when the output is truncated due to the output buffer
* being too small. However, it is non-compliant - mainly because
* it returns -1 when the output buffer is too small, rather than
* returning the required length of the output buffer as required
* by the C99 standard.
*
* @param[out] buffer Storage location for the output.
* @param[in] count Maximum number of characters to store.
* @param[in] format Format-control string.
* @param[in] ... String format parameters.
*
* @return
* - The length of the output buffer, not including the zero terminator, on success
* - Value -1 if the output has been truncated
*/
int32_t AJ_snprintf(char* buffer, size_t count, const char* format, ...);
#if ((_MSC_VER <= 1800) || defined(DO_SNPRINTF_MAPPING))
#define snprintf AJ_snprintf
#endif
#endif
| 33.888889 | 88 | 0.693569 |
73a808a9c53c709c34f185e843ca77b30dc5e1b2 | 1,671 | c | C | include/libmlx/src/ft_draw_line.c | W2Codam/FDF | 4dcbaf330b1d81ba1f3453321659cb9967833982 | [
"MIT"
] | null | null | null | include/libmlx/src/ft_draw_line.c | W2Codam/FDF | 4dcbaf330b1d81ba1f3453321659cb9967833982 | [
"MIT"
] | null | null | null | include/libmlx/src/ft_draw_line.c | W2Codam/FDF | 4dcbaf330b1d81ba1f3453321659cb9967833982 | [
"MIT"
] | null | null | null | /* ************************************************************************** */
/* */
/* :::::::: */
/* ft_draw_line.c :+: :+: */
/* +:+ */
/* By: lde-la-h <lde-la-h@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2021/10/27 14:37:37 by lde-la-h #+# #+# */
/* Updated: 2021/11/08 17:15:19 by lde-la-h ######## odam.nl */
/* */
/* ************************************************************************** */
#include "libmlx.h"
static t_i32 ft_select(t_bool Val, t_i32 a, t_i32 b)
{
if (Val)
return (a);
return (b);
}
static void ft_setup(t_point s, t_point e, t_point *delta, t_point *incr)
{
delta->x = ft_abs(s.x - e.x);
delta->y = ft_abs(s.y - e.y);
incr->x = ft_select(e.x < s.x, 1, -1);
incr->y = ft_select(e.y < s.y, 1, -1);
}
void ft_draw_line(t_canvas *canvas, t_point s, t_point e)
{
t_point delta;
t_point incr;
t_point cur;
t_i32 error;
ft_setup(s, e, &delta, &incr);
error = 2 * (delta.y - delta.x);
cur = e;
while (true)
{
ft_set_pixel(canvas, cur, WHITE);
if (cur.x == s.x && cur.y == s.y)
break ;
if (error >= 0)
{
cur.y += incr.y;
error -= 2 * delta.x;
}
if (error < 0)
{
cur.x += incr.x;
error += 2 * delta.y;
}
}
}
| 29.315789 | 80 | 0.329144 |
73db449c1af93c82db97ad383cb5b4db232e1636 | 2,733 | c | C | sr/lsri/lib/libsys/env_get_prm.c | ducis/operating-system-labs | 7df84f3dae792ee96461497b7d47414d24d233ee | [
"MIT"
] | 2 | 2018-03-01T13:45:41.000Z | 2018-03-01T14:11:47.000Z | src.clean/lib/libsys/env_get_prm.c | ducis/operating-system-labs | 7df84f3dae792ee96461497b7d47414d24d233ee | [
"MIT"
] | null | null | null | src.clean/lib/libsys/env_get_prm.c | ducis/operating-system-labs | 7df84f3dae792ee96461497b7d47414d24d233ee | [
"MIT"
] | null | null | null | #include "sysutil.h"
#include <string.h>
PUBLIC int env_argc = 0;
PUBLIC char **env_argv = NULL;
FORWARD _PROTOTYPE( char *find_key, (const char *params, const char *key));
/*===========================================================================*
* env_setargs *
*===========================================================================*/
PUBLIC void env_setargs(arg_c, arg_v)
int arg_c;
char *arg_v[];
{
env_argc= arg_c;
env_argv= arg_v;
}
/*===========================================================================*
* env_get_param *
*===========================================================================*/
PUBLIC int env_get_param(key, value, max_len)
char *key; /* which key to look up */
char *value; /* where to store value */
int max_len; /* maximum length of value */
{
message m;
static char mon_params[128*sizeof(char *)]; /* copy parameters here */
char *key_value;
int i, s;
size_t keylen;
if (key == NULL)
return EINVAL;
keylen= strlen(key);
for (i= 1; i<env_argc; i++)
{
if (strncmp(env_argv[i], key, keylen) != 0)
continue;
if (strlen(env_argv[i]) <= keylen)
continue;
if (env_argv[i][keylen] != '=')
continue;
key_value= env_argv[i]+keylen+1;
if (strlen(key_value)+1 > (size_t) max_len)
return(E2BIG);
strcpy(value, key_value);
return OK;
}
/* Get copy of boot monitor parameters. */
m.m_type = SYS_GETINFO;
m.I_REQUEST = GET_MONPARAMS;
m.I_ENDPT = SELF;
m.I_VAL_LEN = sizeof(mon_params);
m.I_VAL_PTR = mon_params;
if ((s=_kernel_call(SYS_GETINFO, &m)) != OK) {
printf("SYS_GETINFO: %d (size %u)\n", s, sizeof(mon_params));
return(s);
}
/* We got a copy, now search requested key. */
if ((key_value = find_key(mon_params, key)) == NULL)
return(ESRCH);
/* Value found, see if it fits in the client's buffer. Callers assume that
* their buffer is unchanged on error, so don't make a partial copy.
*/
if ((strlen(key_value)+1) > (size_t) max_len) return(E2BIG);
/* Make the actual copy. */
strcpy(value, key_value);
return(OK);
}
/*==========================================================================*
* find_key *
*==========================================================================*/
PRIVATE char *find_key(params,name)
const char *params;
const char *name;
{
register const char *namep;
register char *envp;
for (envp = (char *) params; *envp != 0;) {
for (namep = name; *namep != 0 && *namep == *envp; namep++, envp++)
;
if (*namep == '\0' && *envp == '=')
return(envp + 1);
while (*envp++ != 0)
;
}
return(NULL);
}
| 27.059406 | 80 | 0.493231 |
ad2e63cc8d3eba0857598a5971f71be1c25333c3 | 551 | h | C | src/subsystem/perception/detection/basic_lane_detector.h | AndrewCr0w/road_controller | 3db8cadf828c118607f2c3e07b3feffc22b6232c | [
"MIT"
] | null | null | null | src/subsystem/perception/detection/basic_lane_detector.h | AndrewCr0w/road_controller | 3db8cadf828c118607f2c3e07b3feffc22b6232c | [
"MIT"
] | null | null | null | src/subsystem/perception/detection/basic_lane_detector.h | AndrewCr0w/road_controller | 3db8cadf828c118607f2c3e07b3feffc22b6232c | [
"MIT"
] | null | null | null | #ifndef ROAD_CONTROLLER_LANE_DETECTOR_H
#define ROAD_CONTROLLER_LANE_DETECTOR_H
#include "lane_detector_strategy.h"
class BasicLaneDetector {
protected:
#pragma clang diagnostic push
#pragma ide diagnostic ignored "OCUnusedGlobalDeclarationInspection"
cv::Mat execute(const cv::Mat&);
#pragma clang diagnostic pop
private:
cv::Mat normalizeImage(const cv::Mat&);
cv::Mat cropImage(const cv::Mat&);
cv::Mat selectColors(const cv::Mat&);
std::vector<cv::Vec4i> detectLaneLines(const cv::Mat&);
};
#endif //ROAD_CONTROLLER_LANE_DETECTOR_H
| 27.55 | 68 | 0.782214 |
f8e71a2ba6d23fba5922534ebbfbcfa60ab37b3e | 881 | h | C | iOS/10.0.2/Frameworks/HomeKit.framework/HMVendorDataManager.h | onmyway133/Runtime-Headers | e9b80e7ab9103f37ad421ad6b8b58ee06369d21f | [
"MIT"
] | 30 | 2016-10-09T20:13:00.000Z | 2022-01-24T04:14:57.000Z | iOS/10.0.2/Frameworks/HomeKit.framework/HMVendorDataManager.h | onmyway133/Runtime-Headers | e9b80e7ab9103f37ad421ad6b8b58ee06369d21f | [
"MIT"
] | null | null | null | iOS/10.0.2/Frameworks/HomeKit.framework/HMVendorDataManager.h | onmyway133/Runtime-Headers | e9b80e7ab9103f37ad421ad6b8b58ee06369d21f | [
"MIT"
] | 7 | 2017-08-29T14:41:25.000Z | 2022-01-19T17:14:54.000Z | /* Generated by RuntimeBrowser
Image: /System/Library/Frameworks/HomeKit.framework/HomeKit
*/
@interface HMVendorDataManager : NSObject {
long long _dataVersion;
NSObject<OS_dispatch_queue> * _databaseQueue;
NSDictionary * _vendorModelEntries;
}
@property (nonatomic) long long dataVersion;
@property (nonatomic, retain) NSObject<OS_dispatch_queue> *databaseQueue;
@property (nonatomic, readonly) NSDictionary *vendorModelEntries;
+ (id)sharedVendorDataManager;
- (void).cxx_destruct;
- (id)_modelEntryForManufacturer:(id)arg1 model:(id)arg2;
- (void)_parseManufacturersList:(id)arg1;
- (id)bundleIDForManufacturer:(id)arg1 model:(id)arg2;
- (long long)dataVersion;
- (id)databaseQueue;
- (id)init;
- (void)setDataVersion:(long long)arg1;
- (void)setDatabaseQueue:(id)arg1;
- (id)storeIDForManufacturer:(id)arg1 model:(id)arg2;
- (id)vendorModelEntries;
@end
| 29.366667 | 73 | 0.766175 |
5d75ab683026eb21c52322a71a9a5ed9b2f46f5d | 11,308 | h | C | WoW API/WoWClientDB.h | Fernir/Dinnerbot | 7f517a46c66a44b32ab9904283babb8b3faa1d5b | [
"MIT"
] | 3 | 2018-04-25T10:01:53.000Z | 2022-01-09T20:30:37.000Z | WoW API/WoWClientDB.h | Fernir/Dinnerbot | 7f517a46c66a44b32ab9904283babb8b3faa1d5b | [
"MIT"
] | null | null | null | WoW API/WoWClientDB.h | Fernir/Dinnerbot | 7f517a46c66a44b32ab9904283babb8b3faa1d5b | [
"MIT"
] | 1 | 2022-01-09T20:30:40.000Z | 2022-01-09T20:30:40.000Z | #pragma once
#include <Windows.h>
enum eClientDb
{
Achievement = 0x000000EB, // 0x00A73888
Achievement_Criteria = 0x000000EC, // 0x00A738AC
Achievement_Category = 0x000000ED, // 0x00A738D0
AnimationData = 0x000000EE, // 0x00A738F4
AreaGroup = 0x000000EF, // 0x00A73918
AreaPOI = 0x000000F0, // 0x00A7393
AreaTable = 0x000000F1, // 0x00A7960
AreaTrigger = 0x000000F2, // 0x00A7984
AttackAnimKits = 0x000000F3, // 0x00A39A8
AttackAnimTypes = 0x000000F4, // 0x00A73CC
AuctionHouse = 0x000000F5, // 0x00A739F
BankBagSlotPrices = 0x000000F6, // 0x0A73A14
BannedAddOns = 0x000000F7, // 0x00A73A3
BarberShopStyle = 0x000000F8, // 0x00A3A5C
BattlemasterList = 0x000000F9, // 0x00A7380
CameraShakes = 0x000000FA, // 0x00A73AA
Cfg_Categories = 0x000000FB, // 0x00A7AC8
Cfg_Configs = 0x000000FC, // 0x00A73AE
CharBaseInfo = 0x000000FD, // 0x00A7310
CharHairGeosets = 0x000000FE, // 0x00A3B34
CharSections = 0x000000FF, // 0x00A73B5
CharStartOutfit = 0x00000100, // 0x00A3B7C
CharTitles = 0x00000101, // 0x00A73BA
CharacterFacialHairStyles = 0x0000012, // 0x00A73BC4
ChatChannels = 0x00000103, // 0x00A73BE
ChatProfanity = 0x00000104, // 0x00A73C0C
ChrClasses = 0x00000105, // 0x00A73C30
ChrRaces = 0x00000106, // 0x00A73C54
CinematicCamera = 0x00000107, // 0x00A73C78
CinematicSequences = 0x00000108, // 0x00A73C9C
CreatureDisplayInfo = 0x00000109, // 0x00A73CE4
CreatureDisplayInfoExtra = 0x0000010A, // 0x00A73CC0
CreatureFamily = 0x0000010B, // 0x00A73D08
CreatureModelData = 0x0000010C, // 0x00A73D2C
CreatureMovementInfo = 0x0000010D, // 0x00A73D50
CreatureSoundData = 0x0000010E, // 0x00A73D74
CreatureSpellData = 0x0000010F, // 0x00A73D98
CreatureType = 0x00000110, // 0x00A73DBC
CurrencyTypes = 0x00000111, // 0x00A73DE0
CurrencyCategory = 0x00000112, // 0x00A73E04
DanceMoves = 0x00000113, // 0x00A73E28
DeathThudLookups = 0x00000114, // 0x00A73E4C
DestructibleModelData = 0x00000115, // 0x00A73EB8
DungeonEncounter = 0x00000116, // 0x00A73EDC
DungeonMap = 0x00000117, // 0x00A73F00
DungeonMapChunk = 0x00000118, // 0x00A73F24
DurabilityCosts = 0x00000119, // 0x00A73F48
DurabilityQuality = 0x0000011A, // 0x00A73F6C
Emotes = 0x0000011B, // 0x00A73F90
EmotesText = 0x0000011C, // 0x00A73FFC
EmotesTextData = 0x0000011D, // 0x00A73FB4
EmotesTextSound = 0x0000011E, // 0x00A73FD8
EnvironmentalDamage = 0x0000011F, // 0x00A74020
Exhaustion = 0x00000120, // 0x00A74044
Faction = 0x00000121, // 0x00A7408C
FactionGroup = 0x00000122, // 0x00A74068
FactionTemplate = 0x00000123, // 0x00A740B0
FileData = 0x00000124, // 0x00A740D4
FootprintTextures = 0x00000125, // 0x00A740F8
FootstepTerrainLookup = 0x00000126, // 0x00A7411C
GameObjectArtKit = 0x00000127, // 0x00A74140
GameObjectDisplayInfo = 0x00000128, // 0x00A74164
GameTables = 0x00000129, // 0x00A74188
GameTips = 0x0000012A, // 0x00A741AC
GemProperties = 0x0000012B, // 0x00A741D0
GlyphProperties = 0x0000012C, // 0x00A741F4
GlyphSlot = 0x0000012D, // 0x00A74218
GMSurveyAnswers = 0x0000012E, // 0x00A7423C
GMSurveyCurrentSurvey = 0x0000012F, // 0x00A74260
GMSurveyQuestions = 0x00000130, // 0x00A74284
GMSurveySurveys = 0x00000131, // 0x00A742A8
GMTicketCategory = 0x00000132, // 0x00A742CC
GroundEffectDoodad = 0x00000133, // 0x00A742F0
GroundEffectTexture = 0x00000134, // 0x00A74314
gtBarberShopCostBase = 0x00000135, // 0x00A74338
gtCombatRatings = 0x00000136, // 0x00A7435C
gtChanceToMeleeCrit = 0x00000137, // 0x00A74380
gtChanceToMeleeCritBase = 0x00000138, // 0x00A743A4
gtChanceToSpellCrit = 0x00000139, // 0x00A743C8
gtChanceToSpellCritBase = 0x0000013A, // 0x00A743EC
gtNPCManaCostScaler = 0x0000013B, // 0x00A74410
gtOCTClassCombatRatingScalar = 0x0000013C, // 0x00A74434
gtOCTRegenHP = 0x0000013D, // 0x00A74458
gtOCTRegenMP = 0x0000013E, // 0x00A7447C
gtRegenHPPerSpt = 0x0000013F, // 0x00A744A0
gtRegenMPPerSpt = 0x00000140, // 0x00A744C4
HelmetGeosetVisData = 0x00000141, // 0x00A744E8
HolidayDescriptions = 0x00000142, // 0x00A7450C
HolidayNames = 0x00000143, // 0x00A74530
Holidays = 0x00000144, // 0x00A74554
Item = 0x00000145, // 0x00A74578
ItemBagFamily = 0x00000146, // 0x00A7459C
ItemClass = 0x00000147, // 0x00A745C0
ItemCondExtCosts = 0x00000148, // 0x00A745E4
ItemDisplayInfo = 0x00000149, // 0x00A74608
ItemExtendedCost = 0x0000014A, // 0x00A7462C
ItemGroupSounds = 0x0000014B, // 0x00A74650
ItemLimitCategory = 0x0000014C, // 0x00A74674
ItemPetFood = 0x0000014D, // 0x00A74698
ItemPurchaseGroup = 0x0000014E, // 0x00A746BC
ItemRandomProperties = 0x0000014F, // 0x00A746E0
ItemRandomSuffix = 0x00000150, // 0x00A74704
ItemSet = 0x00000151, // 0x00A74728
ItemSubClass = 0x00000152, // 0x00A74770
ItemSubClassMask = 0x00000153, // 0x00A7474C
ItemVisualEffects = 0x00000154, // 0x00A74794
ItemVisuals = 0x00000155, // 0x00A747B8
LanguageWords = 0x00000156, // 0x00A747DC
Languages = 0x00000157, // 0x00A74800
LfgDungeonExpansion = 0x00000158, // 0x00A74824
LfgDungeonGroup = 0x00000159, // 0x00A74848
LfgDungeons = 0x0000015A, // 0x00A7486C
Light = 0x0000015B, // 0x00A96C08
LightFloatBand = 0x0000015C, // 0x00A96BC0
LightIntBand = 0x0000015D, // 0x00A96B9C
LightParams = 0x0000015E, // 0x00A96BE4
LightSkybox = 0x0000015F, // 0x00A96B78
LiquidType = 0x00000160, // 0x00A74890
LiquidMaterial = 0x00000161, // 0x00A748B4
LoadingScreens = 0x00000162, // 0x00A748D8
LoadingScreenTaxiSplines = 0x00000163, // 0x00A748FC
Lock = 0x00000164, // 0x00A74920
LockType = 0x00000165, // 0x00A74944
MailTemplate = 0x00000166, // 0x00A74968
Map = 0x00000167, // 0x00A7498C
MapDifficulty = 0x00000168, // 0x00A749B0
Material = 0x00000169, // 0x00A749D4
Movie = 0x0000016A, // 0x00A749F8
MovieFileData = 0x0000016B, // 0x00A74A1C
MovieVariation = 0x0000016C, // 0x00A74A40
NameGen = 0x0000016D, // 0x00A74A64
NPCSounds = 0x0000016E, // 0x00A74A88
NamesProfanity = 0x0000016F, // 0x00A74AAC
NamesReserved = 0x00000170, // 0x00A74AD0
OverrideSpellData = 0x00000171, // 0x00A74AF4
Package = 0x00000172, // 0x00A74B18
PageTextMaterial = 0x00000173, // 0x00A74B3C
PaperDollItemFrame = 0x00000174, // 0x00A74B60
ParticleColor = 0x00000175, // 0x00A74B84
PetPersonality = 0x00000176, // 0x00A74BA8
PowerDisplay = 0x00000177, // 0x00A74BCC
PvpDifficulty = 0x00000178, // 0x00A74BF0
QuestFactionReward = 0x00000179, // 0x00A74C14
QuestInfo = 0x0000017A, // 0x00A74C38
QuestSort = 0x0000017B, // 0x00A74C5C
QuestXP = 0x0000017C, // 0x00A74C80
Resistances = 0x0000017D, // 0x00A74CA4
RandPropPoints = 0x0000017E, // 0x00A74CC8
ScalingStatDistribution = 0x0000017F, // 0x00A74CEC
ScalingStatValues = 0x00000180, // 0x00A74D10
ScreenEffect = 0x00000181, // 0x00A74D34
ServerMessages = 0x00000182, // 0x00A74D58
SheatheSoundLookups = 0x00000183, // 0x00A74D7C
SkillCostsData = 0x00000184, // 0x00A74DA0
SkillLineAbility = 0x00000185, // 0x00A74DC4
SkillLineCategory = 0x00000186, // 0x00A74DE8
SkillLine = 0x00000187, // 0x00A74E0C
SkillRaceClassInfo = 0x00000188, // 0x00A74E30
SkillTiers = 0x00000189, // 0x00A74E54
SoundAmbience = 0x0000018A, // 0x00A74E78
SoundEmitters = 0x0000018B, // 0x00A74EC0
SoundEntries = 0x0000018C, // 0x00A74E9C
SoundProviderPreferences = 0x0000018D, // 0x00A74EE4
SoundSamplePreferences = 0x0000018E, // 0x00A74F08
SoundWaterType = 0x0000018F, // 0x00A74F2C
SpamMessages = 0x00000190, // 0x00A74F50
SpellCastTimes = 0x00000191, // 0x00A74F74
SpellCategory = 0x00000192, // 0x00A74F98
SpellChainEffects = 0x00000193, // 0x00A74FBC
Spell = 0x00000194, // 0x00A751FC
SpellDescriptionVariables = 0x00000195, // 0x00A74FE0
SpellDifficulty = 0x00000196, // 0x00A75004
SpellDispelType = 0x00000197, // 0x00A75028
SpellDuration = 0x00000198, // 0x00A7504C
SpellEffectCameraShakes = 0x00000199, // 0x00A75070
SpellFocusObject = 0x0000019A, // 0x00A75094
SpellIcon = 0x0000019B, // 0x00A750B8
SpellItemEnchantment = 0x0000019C, // 0x00A750DC
SpellItemEnchantmentCondition = 0x0000019D, // 0x00A75100
SpellMechanic = 0x0000019E, // 0x00A75124
SpellMissile = 0x0000019F, // 0x00A75148
SpellMissileMotion = 0x000001A0, // 0x00A7516C
SpellRadius = 0x000001A1, // 0x00A75190
SpellRange = 0x000001A2, // 0x00A751B4
SpellRuneCost = 0x000001A3, // 0x00A751D8
SpellShapeshiftForm = 0x000001A4, // 0x00A75220
SpellVisual = 0x000001A5, // 0x00A752D4
SpellVisualEffectName = 0x000001A6, // 0x00A75244
SpellVisualKit = 0x000001A7, // 0x00A75268
SpellVisualKitAreaModel = 0x000001A8, // 0x00A7528C
SpellVisualKitModelAttach = 0x000001A9, // 0x00A752B0
StableSlotPrices = 0x000001AA, // 0x00A752F8
Stationery = 0x000001AB, // 0x00A7531C
StringLookups = 0x000001AC, // 0x00A75340
SummonProperties = 0x000001AD, // 0x00A75364
Talent = 0x000001AE, // 0x00A75388
TalentTab = 0x000001AF, // 0x00A753AC
TaxiNodes = 0x000001B0, // 0x00A753D0
TaxiPath = 0x000001B1, // 0x00A75418
TaxiPathNode = 0x000001B2, // 0x00A753F4
TeamContributionPoints = 0x000001B3, // 0x00A7543C
TerrainType = 0x000001B4, // 0x00A75460
TerrainTypeSounds = 0x000001B5, // 0x00A75484
TotemCategory = 0x000001B6, // 0x00A754A8
TransportAnimation = 0x000001B7, // 0x00A754CC
TransportPhysics = 0x000001B8, // 0x00A754F0
TransportRotation = 0x000001B9, // 0x00A75514
UISoundLookups = 0x000001BA, // 0x00A75538
UnitBlood = 0x000001BB, // 0x00A75580
UnitBloodLevels = 0x000001BC, // 0x00A7555C
Vehicle = 0x000001BD, // 0x00A755A4
VehicleSeat = 0x000001BE, // 0x00A755C8
VehicleUIIndicator = 0x000001BF, // 0x00A755EC
VehicleUIIndSeat = 0x000001C0, // 0x00A75610
VocalUISounds = 0x000001C1, // 0x00A75634
WMOAreaTable = 0x000001C2, // 0x00A75658
WeaponImpactSounds = 0x000001C3, // 0x00A7567C
WeaponSwingSounds2 = 0x000001C4, // 0x00A756A0
Weather = 0x000001C5, // 0x00A756C4
WorldMapArea = 0x000001C6, // 0x00A756E8
WorldMapTransforms = 0x000001C7, // 0x00A75754
WorldMapContinent = 0x000001C8, // 0x00A7570C
WorldMapOverlay = 0x000001C9, // 0x00A75730
WorldSafeLocs = 0x000001CA, // 0x00A75778
WorldStateUI = 0x000001CB, // 0x00A7579C
ZoneIntroMusicTable = 0x000001CC, // 0x00A757C0
ZoneMusic = 0x000001CD, // 0x00A757E4
WorldStateZoneSounds = 0x000001CE, // 0x00A75808
WorldChunkSounds = 0x000001CF, // 0x00A7582C
SoundEntriesAdvanced = 0x000001D0, // 0x00A75850
ObjectEffect = 0x000001D1, // 0x00A75874
ObjectEffectGroup = 0x000001D2, // 0x00A75898
ObjectEffectModifier = 0x000001D3, // 0x00A758BC
ObjectEffectPackage = 0x000001D4, // 0x00A758E0
ObjectEffectPackageElem = 0x000001D5, // 0x00A75904
SoundFilter = 0x000001D6, // 0x00A75928
SoundFilterElem = 0x000001D7, // 0x00A7594C
};
struct WoWClientDB
{
DWORD vTable;
DWORD isLoaded;
DWORD numRows;
DWORD maxIndex;
DWORD minIndex;
DWORD stringTable;
DWORD vTable2;
DWORD FirstRow;
DWORD Rows;
}; | 44.171875 | 62 | 0.732313 |
56f68eae6f409cce4217f2ea454db3fbc78e6876 | 3,292 | c | C | extern/llvm/tools/clang/test/CodeGen/override-layout.c | chip5441/clReflect | d366cced2fff9aefcfc5ec6a0c97ed6c827263eb | [
"MIT"
] | null | null | null | extern/llvm/tools/clang/test/CodeGen/override-layout.c | chip5441/clReflect | d366cced2fff9aefcfc5ec6a0c97ed6c827263eb | [
"MIT"
] | 1 | 2020-02-22T09:59:21.000Z | 2020-02-22T09:59:21.000Z | extern/llvm/tools/clang/test/CodeGen/override-layout.c | chip5441/clReflect | d366cced2fff9aefcfc5ec6a0c97ed6c827263eb | [
"MIT"
] | null | null | null | // RUN: %clang_cc1 -w -fdump-record-layouts %s 2> %t.layouts
// RUN: %clang_cc1 -w -fdump-record-layouts-simple %s > %t.before 2>&1
// RUN: %clang_cc1 -w -DPACKED= -DALIGNED16= -fdump-record-layouts-simple -foverride-record-layout=%t.layouts %s > %t.after 2>&1
// RUN: diff %t.before %t.after
// RUN: FileCheck %s < %t.after
// If not explicitly disabled, set PACKED to the packed attribute.
#ifndef PACKED
# define PACKED __attribute__((packed))
#endif
// If not explicitly disabled, set ALIGNED16 to 16-byte alignment.
#ifndef ALIGNED16
# define ALIGNED16 __attribute__((aligned(16)))
#endif
// CHECK: Type: struct X0
struct X0 {
int x[6] PACKED;
};
// CHECK: Type: struct X1
struct X1 {
char x[13];
struct X0 y;
} PACKED;
// CHECK: Type: struct X2
struct PACKED X2 {
short x;
int y;
};
// CHECK: Type: struct X3
struct X3 {
short x PACKED;
int y;
};
#pragma pack(push,2)
// CHECK: Type: struct X4
struct X4 {
int x;
int y;
};
#pragma pack(pop)
// CHECK: Type: struct X5
struct PACKED X5 { double a[19]; signed char b; };
// CHECK: Type: struct X6
struct PACKED X6 { long double a; char b; };
// CHECK: Type: struct X7
struct X7 {
unsigned x;
unsigned char y;
} PACKED;
// CHECK: Type: union X8
union X8 {
struct X7 x;
unsigned y;
} PACKED;
// CHECK: Type: struct X9
struct X9 {
unsigned int x[2] PACKED;
unsigned int y;
unsigned int z PACKED;
};
// CHECK: Type: struct X10
struct X10 {
unsigned int x[2] PACKED;
unsigned int y PACKED;
unsigned int z PACKED;
};
// CHECK: Type: struct X11
struct PACKED X11 {
unsigned int x[2];
unsigned int y;
unsigned int z;
};
// CHECK: Type: struct X12
struct PACKED X12 {
int x : 24;
};
// CHECK: Type: struct X13
struct PACKED X13 {
signed x : 10;
signed y : 10;
};
// CHECK: Type: union X14
union PACKED X14 {
unsigned long long x : 3;
};
// CHECK: Type: struct X15
struct X15 {
unsigned x : 16;
unsigned y : 28 PACKED;
};
// CHECK: Type: struct X16
struct ALIGNED16 X16 {
int a, b, c;
int x : 5;
int y : 29;
};
void use_structs() {
struct X0 x0;
x0.x[5] = sizeof(struct X0);
struct X1 x1;
x1.x[5] = sizeof(struct X1);
struct X2 x2;
x2.y = sizeof(struct X2);
struct X3 x3;
x3.y = sizeof(struct X3);
struct X4 x4;
x4.y = sizeof(struct X4);
struct X5 x5;
x5.b = sizeof(struct X5);
struct X6 x6;
x6.b = sizeof(struct X6);
struct X7 x7;
typedef int X7array[sizeof(struct X7)];
x7.x = sizeof(struct X7);
x7.y = x7.x;
union X8 x8;
typedef int X8array[sizeof(union X8)];
x8.y = sizeof(union X8);
x8.x.x = x8.y;
struct X9 x9;
typedef int X9array[sizeof(struct X9)];
x9.y = sizeof(struct X9);
struct X10 x10;
typedef int X10array[sizeof(struct X10)];
x10.y = sizeof(struct X10);
struct X11 x11;
typedef int X11array[sizeof(struct X11)];
x11.y = sizeof(struct X11);
struct X12 x12;
x12.x = sizeof(struct X12);
struct X13 x13;
x13.x = sizeof(struct X13);
union X14 x14;
x14.x = sizeof(union X14);
struct X15 x15;
x15.x = sizeof(struct X15);
struct X16 x16;
x16.x = sizeof(struct X16);
}
| 18.811429 | 129 | 0.606318 |
5ea903413022b3cff36981d9729752cd037f4ce8 | 821 | h | C | bobuniverse.h | OtacilioN/Bob-Robot-Simulator | 5c6beb5062c0299f270fc703b1d1c514ad10c5ab | [
"MIT"
] | 2 | 2017-12-23T14:39:52.000Z | 2018-10-23T19:39:23.000Z | bobuniverse.h | OtacilioN/Bob-Robot-Simulator | 5c6beb5062c0299f270fc703b1d1c514ad10c5ab | [
"MIT"
] | null | null | null | bobuniverse.h | OtacilioN/Bob-Robot-Simulator | 5c6beb5062c0299f270fc703b1d1c514ad10c5ab | [
"MIT"
] | null | null | null | /*
* bobuniverse.h
*
* It is a Bob Robot Universe Simulator
*
* Created on September 13, 2017
* By Otacilio Neto (github: @OtacilioN | Email: contato@otaciliomaia.com)
*
* Published under mit license
*/
#ifndef bobuniverse_h
#define bobuniverse_h
class Universe {
public:
Universe(int initialDistance, int setPoint, int friction = 100);
void restart(int initialDistance, int setPoint, int friction = 100);
int getStatus();
void move(int power);
void brake();
int getDistance();
int getSpeed();
int getTime();
private:
int _initialDistance;
int _setPoint;
int _friction;
float speed;
float acceleration;
float position;
int status;
int seconds;
};
#endif
| 22.189189 | 76 | 0.601705 |
957dfece35e8ac8cd8c369c4e11f2a4225b2b597 | 469 | h | C | renderer/core/include/core/ogl/uniforms/OpenGLDoubleUniformVariable.h | wookie41/blitz | 7f587bee9b6189c32f0f60c69316bc8deca23c16 | [
"MIT"
] | 1 | 2020-01-04T21:04:52.000Z | 2020-01-04T21:04:52.000Z | renderer/core/include/core/ogl/uniforms/OpenGLDoubleUniformVariable.h | wookie41/blitz | 7f587bee9b6189c32f0f60c69316bc8deca23c16 | [
"MIT"
] | 15 | 2019-08-26T20:54:31.000Z | 2020-03-15T14:11:44.000Z | renderer/core/include/core/ogl/uniforms/OpenGLDoubleUniformVariable.h | wookie41/blitz | 7f587bee9b6189c32f0f60c69316bc8deca23c16 | [
"MIT"
] | null | null | null | #pragma once
#include <core/UniformVariable.h>
#include <core/ogl/uniforms/OpenGLUniformVariable.h>
namespace blitz::ogl
{
class OpenGLDoubleUniformVariable : public UniformVariable<double>, public OpenGLUniformVariable
{
public:
OpenGLDoubleUniformVariable(const GLint& variableLocation, const double& value, const blitz::string& name);
void bind() override;
DataType getType() const override;
};
} // namespace blitz::ogl | 27.588235 | 115 | 0.724947 |
e5ef65b0efdf1663032162baa70bd56b2d958fd4 | 4,668 | h | C | third_party/hpipm/include/hpipm_d_dense_qp_ipm_hard.h | Ewpratten/frc_971_mirror | 3a8a0c4359f284d29547962c2b4c43d290d8065c | [
"BSD-2-Clause"
] | null | null | null | third_party/hpipm/include/hpipm_d_dense_qp_ipm_hard.h | Ewpratten/frc_971_mirror | 3a8a0c4359f284d29547962c2b4c43d290d8065c | [
"BSD-2-Clause"
] | null | null | null | third_party/hpipm/include/hpipm_d_dense_qp_ipm_hard.h | Ewpratten/frc_971_mirror | 3a8a0c4359f284d29547962c2b4c43d290d8065c | [
"BSD-2-Clause"
] | null | null | null | /**************************************************************************************************
* *
* This file is part of HPIPM. *
* *
* HPIPM -- High Performance Interior Point Method. *
* Copyright (C) 2017 by Gianluca Frison. *
* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. *
* All rights reserved. *
* *
* HPMPC is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
* License as published by the Free Software Foundation; either *
* version 2.1 of the License, or (at your option) any later version. *
* *
* HPMPC is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with HPMPC; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
* *
* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de *
* *
**************************************************************************************************/
#include <blasfeo_target.h>
#include <blasfeo_common.h>
struct d_ipm_hard_dense_qp_workspace
{
struct d_ipm_hard_core_qp_workspace *core_workspace;
struct d_strvec *dv; // step in v
struct d_strvec *dpi; // step in pi
struct d_strvec *dlam; // step in lam XXX needed ???
struct d_strvec *dt; // step in t XXX needed ???
struct d_strvec *dt_lb; //
struct d_strvec *dt_ub; // XXX needed ???
struct d_strvec *dt_lg; //
struct d_strvec *dt_ug; // XXX needed ???
struct d_strvec *res_g; // q-residuals
struct d_strvec *res_b; // b-residuals
struct d_strvec *res_d; // d-residuals
struct d_strvec *res_d_lb; // d-residuals
struct d_strvec *res_d_ub; // d-residuals
struct d_strvec *res_d_lg; // d-residuals
struct d_strvec *res_d_ug; // d-residuals
struct d_strvec *res_m; // m-residuals
struct d_strvec *Qx; // hessian update
struct d_strvec *qx; // gradient update
struct d_strmat *Lv; //
struct d_strmat *AL; //
struct d_strmat *Le; //
struct d_strmat *Ctx; //
struct d_strvec *lv; //
struct d_strvec *tmp_nb; // work space of size nb
struct d_strvec *tmp_ng0; // work space of size nb
struct d_strvec *tmp_ng1; // work space of size nb
double *stat; // convergence statistics
double res_mu; // mu-residual
int iter; // iteration number
int memsize; // memory size (in bytes) of workspace
};
struct d_ipm_hard_dense_qp_arg
{
double alpha_min; // exit cond on step length
double mu_max; // exit cond on duality measure
double mu0; // initial value for duality measure
int iter_max; // exit cond in iter number
};
//
int d_memsize_ipm_hard_dense_qp(struct d_dense_qp *qp, struct d_ipm_hard_dense_qp_arg *arg);
//
void d_create_ipm_hard_dense_qp(struct d_dense_qp *qp, struct d_ipm_hard_dense_qp_arg *arg, struct d_ipm_hard_dense_qp_workspace *ws, void *mem);
//
void d_solve_ipm_hard_dense_qp(struct d_dense_qp *qp, struct d_dense_qp_sol *qp_sol, struct d_ipm_hard_dense_qp_workspace *ws);
//
void d_solve_ipm2_hard_dense_qp(struct d_dense_qp *qp, struct d_dense_qp_sol *qp_sol, struct d_ipm_hard_dense_qp_workspace *ws);
| 51.866667 | 145 | 0.495716 |
b56bc02f6a970b6249f55245e7f493095e158cd9 | 875 | h | C | util/include/outputinterface.h | jpatton-USGS/neic-glass3 | 52ab2eabd5d5d97c9d74f44c462aec7e88e51899 | [
"CC0-1.0"
] | 9 | 2019-02-18T09:08:43.000Z | 2021-08-25T13:59:15.000Z | util/include/outputinterface.h | jpatton-USGS/neic-glass3 | 52ab2eabd5d5d97c9d74f44c462aec7e88e51899 | [
"CC0-1.0"
] | 65 | 2017-12-06T16:01:11.000Z | 2021-06-10T15:24:23.000Z | util/include/outputinterface.h | jpatton-USGS/neic-glass3 | 52ab2eabd5d5d97c9d74f44c462aec7e88e51899 | [
"CC0-1.0"
] | 7 | 2017-12-04T20:21:28.000Z | 2021-12-01T15:59:40.000Z | #ifndef OUTPUTINTERFACE_H
#define OUTPUTINTERFACE_H
#include <json.h>
#include <memory>
namespace glass3 {
namespace util {
/**
* \interface iOutput
* \brief The output message interface, used in sending data to output classes in
* neic-glass3
*
* The iOutput interface is implemented by classes that manage outputting
* data from neic-glass3, providing a method for other classes in neic-glass3 to
* send output data via the sendtooutput() function.
*/
class iOutput {
public:
/**
* \brief Send output data
*
* This pure virtual function is implemented by a class to support sending
* data to be output.
*
* \param data - A std::shared_ptr to a json::object containing the output
* data.
*/
virtual void sendToOutput(std::shared_ptr<json::Object> data) = 0; // NOLINT
};
} // namespace util
} // namespace glass3
#endif // OUTPUTINTERFACE_H
| 25 | 81 | 0.72 |
67ea545178052edb20c06d6bf5941f1dfd45151a | 549 | h | C | examples/NEED_GRRLIB_FUNCTION/source/gfx/font9x12.h | HTV04/GRRLIB | 7840bd4e1e23faf52015e8ef3d3fd55a2539dca4 | [
"MIT"
] | 72 | 2015-04-05T00:03:18.000Z | 2022-03-27T19:43:59.000Z | examples/NEED_GRRLIB_FUNCTION/source/gfx/font9x12.h | HTV04/GRRLIB | 7840bd4e1e23faf52015e8ef3d3fd55a2539dca4 | [
"MIT"
] | 10 | 2015-11-17T05:25:31.000Z | 2022-03-03T20:57:42.000Z | examples/NEED_GRRLIB_FUNCTION/source/gfx/font9x12.h | HTV04/GRRLIB | 7840bd4e1e23faf52015e8ef3d3fd55a2539dca4 | [
"MIT"
] | 18 | 2015-07-07T03:53:23.000Z | 2022-03-27T19:44:00.000Z | /*
This file was autogenerated by raw2c.
Visit http://www.devkitpro.org
*/
//---------------------------------------------------------------------------------
#ifndef _font9x12_h_
#define _font9x12_h_
//---------------------------------------------------------------------------------
extern const unsigned char font9x12[];
extern const int font9x12_size;
//---------------------------------------------------------------------------------
#endif //_font9x12_h_
//---------------------------------------------------------------------------------
| 36.6 | 83 | 0.302368 |
d5ac4ab6bb267a2757d12f56cb4c789ca1012317 | 18,364 | h | C | headers/termios.h | mwichmann/lsb-buildenv | 7a7eb64b5960172e0032e7202aeb454e076880fa | [
"BSD-3-Clause"
] | null | null | null | headers/termios.h | mwichmann/lsb-buildenv | 7a7eb64b5960172e0032e7202aeb454e076880fa | [
"BSD-3-Clause"
] | null | null | null | headers/termios.h | mwichmann/lsb-buildenv | 7a7eb64b5960172e0032e7202aeb454e076880fa | [
"BSD-3-Clause"
] | null | null | null | #if (__LSB_VERSION__ >= 10 )
#ifndef _TERMIOS_H_
#define _TERMIOS_H_
#include <sys/types.h>
#ifdef __cplusplus
extern "C" {
#endif
#if __LSB_VERSION__ >= 11
#define TCIFLUSH 0
#define TCOOFF 0
#define TCSANOW 0
#define BS0 0000000
#define CR0 0000000
#define FF0 0000000
#define NL0 0000000
#define TAB0 0000000
#define VT0 0000000
#define OPOST 0000001
#if defined __i386__
#define OLCUC 0000002
#define ONLCR 0000004
#define XCASE 0000004
#endif
#define OCRNL 0000010
#define ONOCR 0000020
#define ONLRET 0000040
#define OFILL 0000100
#define OFDEL 0000200
#define NL1 0000400
#if defined __i386__
#define NLDLY 0000400
#define CR1 0001000
#define IUCLC 0001000
#define CR2 0002000
#define CR3 0003000
#define CRDLY 0003000
#define TAB1 0004000
#define TAB2 0010000
#define TAB3 0014000
#define TABDLY 0014000
#define BS1 0020000
#define BSDLY 0020000
#define VT1 0040000
#define VTDLY 0040000
#define FF1 0100000
#define FFDLY 0100000
#endif
#define TCOFLUSH 1
#define TCOON 1
#define TCSADRAIN 1
#define TCIOFF 2
#define TCIOFLUSH 2
#define TCSAFLUSH 2
#define TCION 3
#endif /* __LSB_VERSION__ >= 1.1 */
#if __LSB_VERSION__ >= 12
#if defined __powerpc__ && !defined __powerpc64__
#define TAB1 1024
#define CR3 12288
#define CRDLY 12288
#define FF1 16384
#define FFDLY 16384
#define XCASE 16384
#define ONLCR 2
#define TAB2 2048
#define TAB3 3072
#define TABDLY 3072
#define BS1 32768
#define BSDLY 32768
#define OLCUC 4
#define CR1 4096
#define IUCLC 4096
#define VT1 65536
#define VTDLY 65536
#define NLDLY 768
#define CR2 8192
#endif
#endif /* __LSB_VERSION__ >= 1.2 */
#if __LSB_VERSION__ >= 13
#if defined __ia64__
#define OLCUC 0000002
#endif
#if defined __s390__ && !defined __s390x__
#define OLCUC 0000002
#endif
#if defined __ia64__
#define ONLCR 0000004
#endif
#if defined __s390__ && !defined __s390x__
#define ONLCR 0000004
#endif
#if defined __ia64__
#define XCASE 0000004
#endif
#if defined __s390__ && !defined __s390x__
#define XCASE 0000004
#endif
#if defined __ia64__
#define NLDLY 0000400
#endif
#if defined __s390__ && !defined __s390x__
#define NLDLY 0000400
#endif
#if defined __ia64__
#define CR1 0001000
#endif
#if defined __s390__ && !defined __s390x__
#define CR1 0001000
#endif
#if defined __ia64__
#define IUCLC 0001000
#endif
#if defined __s390__ && !defined __s390x__
#define IUCLC 0001000
#endif
#if defined __ia64__
#define CR2 0002000
#endif
#if defined __s390__ && !defined __s390x__
#define CR2 0002000
#endif
#if defined __ia64__
#define CR3 0003000
#endif
#if defined __s390__ && !defined __s390x__
#define CR3 0003000
#endif
#if defined __ia64__
#define CRDLY 0003000
#endif
#if defined __s390__ && !defined __s390x__
#define CRDLY 0003000
#endif
#if defined __ia64__
#define TAB1 0004000
#endif
#if defined __s390__ && !defined __s390x__
#define TAB1 0004000
#endif
#if defined __ia64__
#define TAB2 0010000
#endif
#if defined __s390__ && !defined __s390x__
#define TAB2 0010000
#endif
#if defined __ia64__
#define TAB3 0014000
#endif
#if defined __s390__ && !defined __s390x__
#define TAB3 0014000
#endif
#if defined __ia64__
#define TABDLY 0014000
#endif
#if defined __s390__ && !defined __s390x__
#define TABDLY 0014000
#endif
#if defined __ia64__
#define BS1 0020000
#endif
#if defined __s390__ && !defined __s390x__
#define BS1 0020000
#endif
#if defined __ia64__
#define BSDLY 0020000
#endif
#if defined __s390__ && !defined __s390x__
#define BSDLY 0020000
#endif
#if defined __ia64__
#define VT1 0040000
#endif
#if defined __s390__ && !defined __s390x__
#define VT1 0040000
#endif
#if defined __ia64__
#define VTDLY 0040000
#endif
#if defined __s390__ && !defined __s390x__
#define VTDLY 0040000
#endif
#if defined __ia64__
#define FF1 0100000
#endif
#if defined __s390__ && !defined __s390x__
#define FF1 0100000
#endif
#if defined __ia64__
#define FFDLY 0100000
#endif
#if defined __s390__ && !defined __s390x__
#define FFDLY 0100000
#endif
#if defined __s390x__
#define CR2 1024
#define CR3 1536
#define CRDLY 1536
#define VT1 16384
#define VTDLY 16384
#define OLCUC 2
#define TAB1 2048
#define NLDLY 256
#define FF1 32768
#define FFDLY 32768
#define ONLCR 4
#define XCASE 4
#define TAB2 4096
#define CR1 512
#define IUCLC 512
#define TAB3 6144
#define TABDLY 6144
#define BS1 8192
#define BSDLY 8192
#endif
#endif /* __LSB_VERSION__ >= 1.3 */
#if __LSB_VERSION__ >= 20
#if defined __x86_64__
#define OLCUC 0000002
#define ONLCR 0000004
#define XCASE 0000004
#define NLDLY 0000400
#define CR1 0001000
#define IUCLC 0001000
#define CR2 0002000
#define CR3 0003000
#define CRDLY 0003000
#define TAB1 0004000
#define TAB2 0010000
#define TAB3 0014000
#define TABDLY 0014000
#define BS1 0020000
#define BSDLY 0020000
#define VT1 0040000
#define VTDLY 0040000
#define FF1 0100000
#define FFDLY 0100000
#endif
#if defined __powerpc64__
#define TAB1 1024
#define CR3 12288
#define CRDLY 12288
#define FF1 16384
#define FFDLY 16384
#define XCASE 16384
#define ONLCR 2
#define TAB2 2048
#define TAB3 3072
#define TABDLY 3072
#define BS1 32768
#define BSDLY 32768
#define OLCUC 4
#define CR1 4096
#define IUCLC 4096
#define VT1 65536
#define VTDLY 65536
#define NLDLY 768
#define CR2 8192
#endif
#endif /* __LSB_VERSION__ >= 2.0 */
typedef unsigned int speed_t;
#if __LSB_VERSION__ >= 12
typedef unsigned char cc_t;
typedef unsigned int tcflag_t;
#endif /* __LSB_VERSION__ >= 1.2 */
#if __LSB_VERSION__ >= 11
#define NCCS 32
#endif /* __LSB_VERSION__ >= 1.1 */
#if __LSB_VERSION__ >= 12
struct termios {
tcflag_t c_iflag; /* input mode flags */
tcflag_t c_oflag; /* output mode flags */
tcflag_t c_cflag; /* control mode flags */
tcflag_t c_lflag; /* local mode flags */
cc_t c_line; /* line discipline */
cc_t c_cc[NCCS]; /* control characters */
speed_t c_ispeed; /* input speed */
speed_t c_ospeed; /* output speed */
};
#endif /* __LSB_VERSION__ >= 1.2 */
/* Special Control Characters*/
#if __LSB_VERSION__ >= 11
#define VINTR 0
#define VQUIT 1
#if defined __i386__
#define VSUSP 10
#define VEOL 11
#define VREPRINT 12
#define VDISCARD 13
#define VWERASE 14
#endif
#define VLNEXT 15
#if defined __i386__
#define VEOL2 16
#endif
#define VERASE 2
#define VKILL 3
#define VEOF 4
#if defined __i386__
#define VMIN 6
#define VSWTC 7
#define VSTART 8
#define VSTOP 9
#endif
#endif /* __LSB_VERSION__ >= 1.1 */
#if __LSB_VERSION__ >= 12
#if defined __powerpc__ && !defined __powerpc64__
#define VWERASE 10
#define VREPRINT 11
#define VSUSP 12
#define VSTART 13
#define VSTOP 14
#define VDISCARD 16
#define VMIN 5
#define VEOL 6
#define VEOL2 8
#define VSWTC 9
#endif
#endif /* __LSB_VERSION__ >= 1.2 */
#if __LSB_VERSION__ >= 13
#if defined __ia64__
#define VSUSP 10
#endif
#if defined __s390__ && !defined __s390x__
#define VSUSP 10
#endif
#if defined __s390x__
#define VSUSP 10
#endif
#if defined __ia64__
#define VEOL 11
#endif
#if defined __s390__ && !defined __s390x__
#define VEOL 11
#endif
#if defined __s390x__
#define VEOL 11
#endif
#if defined __ia64__
#define VREPRINT 12
#endif
#if defined __s390__ && !defined __s390x__
#define VREPRINT 12
#endif
#if defined __s390x__
#define VREPRINT 12
#endif
#if defined __ia64__
#define VDISCARD 13
#endif
#if defined __s390__ && !defined __s390x__
#define VDISCARD 13
#endif
#if defined __s390x__
#define VDISCARD 13
#endif
#if defined __ia64__
#define VWERASE 14
#endif
#if defined __s390__ && !defined __s390x__
#define VWERASE 14
#endif
#if defined __s390x__
#define VWERASE 14
#endif
#if defined __ia64__
#define VEOL2 16
#endif
#if defined __s390__ && !defined __s390x__
#define VEOL2 16
#endif
#if defined __s390x__
#define VEOL2 16
#endif
#if defined __ia64__
#define VMIN 6
#endif
#if defined __s390__ && !defined __s390x__
#define VMIN 6
#endif
#if defined __s390x__
#define VMIN 6
#endif
#if defined __ia64__
#define VSWTC 7
#endif
#if defined __s390__ && !defined __s390x__
#define VSWTC 7
#endif
#if defined __s390x__
#define VSWTC 7
#endif
#if defined __ia64__
#define VSTART 8
#endif
#if defined __s390__ && !defined __s390x__
#define VSTART 8
#endif
#if defined __s390x__
#define VSTART 8
#endif
#if defined __ia64__
#define VSTOP 9
#endif
#if defined __s390__ && !defined __s390x__
#define VSTOP 9
#endif
#if defined __s390x__
#define VSTOP 9
#endif
#endif /* __LSB_VERSION__ >= 1.3 */
#if __LSB_VERSION__ >= 20
#if defined __x86_64__
#define VSUSP 10
#endif
#if defined __powerpc64__
#define VWERASE 10
#endif
#if defined __x86_64__
#define VEOL 11
#endif
#if defined __powerpc64__
#define VREPRINT 11
#endif
#if defined __x86_64__
#define VREPRINT 12
#endif
#if defined __powerpc64__
#define VSUSP 12
#endif
#if defined __x86_64__
#define VDISCARD 13
#endif
#if defined __powerpc64__
#define VSTART 13
#define VSTOP 14
#endif
#if defined __x86_64__
#define VWERASE 14
#endif
#if defined __powerpc64__
#define VDISCARD 16
#endif
#if defined __x86_64__
#define VEOL2 16
#endif
#if defined __powerpc64__
#define VMIN 5
#define VEOL 6
#endif
#if defined __x86_64__
#define VMIN 6
#define VSWTC 7
#endif
#if defined __powerpc64__
#define VEOL2 8
#endif
#if defined __x86_64__
#define VSTART 8
#define VSTOP 9
#endif
#if defined __powerpc64__
#define VSWTC 9
#endif
#endif /* __LSB_VERSION__ >= 2.0 */
/* Input flags - software input processing*/
#if __LSB_VERSION__ >= 11
#define IGNBRK 0000001
#define BRKINT 0000002
#define IGNPAR 0000004
#define PARMRK 0000010
#define INPCK 0000020
#define ISTRIP 0000040
#define INLCR 0000100
#define IGNCR 0000200
#define ICRNL 0000400
#if defined __i386__
#define IXON 0002000
#endif
#define IXANY 0004000
#if defined __i386__
#define IXOFF 0010000
#endif
#define IMAXBEL 0020000
#endif /* __LSB_VERSION__ >= 1.1 */
#if __LSB_VERSION__ >= 12
#if defined __powerpc__ && !defined __powerpc64__
#define IXOFF 1024
#define IXON 512
#endif
#endif /* __LSB_VERSION__ >= 1.2 */
#if __LSB_VERSION__ >= 13
#if defined __ia64__
#define IXON 0002000
#endif
#if defined __s390__ && !defined __s390x__
#define IXON 0002000
#endif
#if defined __ia64__
#define IXOFF 0010000
#endif
#if defined __s390__ && !defined __s390x__
#define IXOFF 0010000
#endif
#if defined __s390x__
#define IXON 1024
#define IXOFF 4096
#endif
#endif /* __LSB_VERSION__ >= 1.3 */
#if __LSB_VERSION__ >= 20
#if defined __x86_64__
#define IXON 0002000
#define IXOFF 0010000
#endif
#if defined __powerpc64__
#define IXOFF 1024
#define IXON 512
#endif
#endif /* __LSB_VERSION__ >= 2.0 */
/* Output flags - software output processing*/
/* Control flags - hardware control of terminal*/
#if __LSB_VERSION__ >= 11
#define CS5 0000000
#if defined __i386__
#define CS6 0000020
#define CS7 0000040
#define CS8 0000060
#define CSIZE 0000060
#define CSTOPB 0000100
#define CREAD 0000200
#define PARENB 0000400
#define PARODD 0001000
#define HUPCL 0002000
#define CLOCAL 0004000
#define VTIME 5
#endif
#endif /* __LSB_VERSION__ >= 1.1 */
#if __LSB_VERSION__ >= 12
#if defined __powerpc__ && !defined __powerpc64__
#define CSTOPB 1024
#define HUPCL 16384
#define CREAD 2048
#define CS6 256
#define CLOCAL 32768
#define PARENB 4096
#define CS7 512
#define VTIME 7
#define CS8 768
#define CSIZE 768
#define PARODD 8192
#endif
#endif /* __LSB_VERSION__ >= 1.2 */
#if __LSB_VERSION__ >= 13
#if defined __ia64__
#define CS6 0000020
#endif
#if defined __s390__ && !defined __s390x__
#define CS6 0000020
#endif
#if defined __ia64__
#define CS7 0000040
#endif
#if defined __s390__ && !defined __s390x__
#define CS7 0000040
#endif
#if defined __ia64__
#define CS8 0000060
#endif
#if defined __s390__ && !defined __s390x__
#define CS8 0000060
#endif
#if defined __ia64__
#define CSIZE 0000060
#endif
#if defined __s390__ && !defined __s390x__
#define CSIZE 0000060
#endif
#if defined __ia64__
#define CSTOPB 0000100
#endif
#if defined __s390__ && !defined __s390x__
#define CSTOPB 0000100
#endif
#if defined __ia64__
#define CREAD 0000200
#endif
#if defined __s390__ && !defined __s390x__
#define CREAD 0000200
#endif
#if defined __ia64__
#define PARENB 0000400
#endif
#if defined __s390__ && !defined __s390x__
#define PARENB 0000400
#endif
#if defined __ia64__
#define PARODD 0001000
#endif
#if defined __s390__ && !defined __s390x__
#define PARODD 0001000
#endif
#if defined __ia64__
#define HUPCL 0002000
#endif
#if defined __s390__ && !defined __s390x__
#define HUPCL 0002000
#endif
#if defined __ia64__
#define CLOCAL 0004000
#endif
#if defined __s390__ && !defined __s390x__
#define CLOCAL 0004000
#endif
#if defined __s390x__
#define HUPCL 1024
#define CREAD 128
#define CS6 16
#define CLOCAL 2048
#define PARENB 256
#define CS7 32
#define CS8 48
#define CSIZE 48
#endif
#if defined __ia64__
#define VTIME 5
#endif
#if defined __s390__ && !defined __s390x__
#define VTIME 5
#endif
#if defined __s390x__
#define VTIME 5
#define PARODD 512
#define CSTOPB 64
#endif
#endif /* __LSB_VERSION__ >= 1.3 */
#if __LSB_VERSION__ >= 20
#if defined __x86_64__
#define CS6 0000020
#define CS7 0000040
#define CS8 0000060
#define CSIZE 0000060
#define CSTOPB 0000100
#define CREAD 0000200
#define PARENB 0000400
#define PARODD 0001000
#define HUPCL 0002000
#define CLOCAL 0004000
#endif
#if defined __powerpc64__
#define CSTOPB 1024
#define HUPCL 16384
#define CREAD 2048
#define CS6 256
#define CLOCAL 32768
#define PARENB 4096
#endif
#if defined __x86_64__
#define VTIME 5
#endif
#if defined __powerpc64__
#define CS7 512
#define VTIME 7
#define CS8 768
#define CSIZE 768
#define PARODD 8192
#endif
#endif /* __LSB_VERSION__ >= 2.0 */
/* "Local" flags - dumping ground for other state*/
#if __LSB_VERSION__ >= 11
#if defined __i386__
#define ISIG 0000001
#define ICANON 0000002
#endif
#define ECHO 0000010
#if defined __i386__
#define ECHOE 0000020
#define ECHOK 0000040
#define ECHONL 0000100
#define NOFLSH 0000200
#define TOSTOP 0000400
#define ECHOCTL 0001000
#define ECHOPRT 0002000
#define ECHOKE 0004000
#define FLUSHO 0010000
#define PENDIN 0040000
#define IEXTEN 0100000
#endif
#endif /* __LSB_VERSION__ >= 1.1 */
#if __LSB_VERSION__ >= 12
#if defined __powerpc__ && !defined __powerpc64__
#define NOFLSH 0x80000000
#define ECHOKE 1
#define IEXTEN 1024
#define ISIG 128
#define ECHONL 16
#define ECHOE 2
#define ICANON 256
#define ECHOPRT 32
#define ECHOK 4
#define TOSTOP 4194304
#define PENDIN 536870912
#define ECHOCTL 64
#define FLUSHO 8388608
#endif
#endif /* __LSB_VERSION__ >= 1.2 */
#if __LSB_VERSION__ >= 13
#if defined __ia64__
#define ISIG 0000001
#endif
#if defined __s390__ && !defined __s390x__
#define ISIG 0000001
#endif
#if defined __ia64__
#define ICANON 0000002
#endif
#if defined __s390__ && !defined __s390x__
#define ICANON 0000002
#endif
#if defined __ia64__
#define ECHOE 0000020
#endif
#if defined __s390__ && !defined __s390x__
#define ECHOE 0000020
#endif
#if defined __ia64__
#define ECHOK 0000040
#endif
#if defined __s390__ && !defined __s390x__
#define ECHOK 0000040
#endif
#if defined __ia64__
#define ECHONL 0000100
#endif
#if defined __s390__ && !defined __s390x__
#define ECHONL 0000100
#endif
#if defined __ia64__
#define NOFLSH 0000200
#endif
#if defined __s390__ && !defined __s390x__
#define NOFLSH 0000200
#endif
#if defined __ia64__
#define TOSTOP 0000400
#endif
#if defined __s390__ && !defined __s390x__
#define TOSTOP 0000400
#endif
#if defined __ia64__
#define ECHOCTL 0001000
#endif
#if defined __s390__ && !defined __s390x__
#define ECHOCTL 0001000
#endif
#if defined __ia64__
#define ECHOPRT 0002000
#endif
#if defined __s390__ && !defined __s390x__
#define ECHOPRT 0002000
#endif
#if defined __ia64__
#define ECHOKE 0004000
#endif
#if defined __s390__ && !defined __s390x__
#define ECHOKE 0004000
#endif
#if defined __ia64__
#define FLUSHO 0010000
#endif
#if defined __s390__ && !defined __s390x__
#define FLUSHO 0010000
#endif
#if defined __ia64__
#define PENDIN 0040000
#endif
#if defined __s390__ && !defined __s390x__
#define PENDIN 0040000
#endif
#if defined __ia64__
#define IEXTEN 0100000
#endif
#if defined __s390__ && !defined __s390x__
#define IEXTEN 0100000
#endif
#if defined __s390x__
#define ISIG 1
#define ECHOPRT 1024
#define NOFLSH 128
#define ECHOE 16
#define PENDIN 16384
#define ICANON 2
#define ECHOKE 2048
#define TOSTOP 256
#define ECHOK 32
#define IEXTEN 32768
#define FLUSHO 4096
#define ECHOCTL 512
#define ECHONL 64
#endif
#endif /* __LSB_VERSION__ >= 1.3 */
#if __LSB_VERSION__ >= 20
#if defined __x86_64__
#define ISIG 0000001
#define ICANON 0000002
#define ECHOE 0000020
#define ECHOK 0000040
#define ECHONL 0000100
#define NOFLSH 0000200
#define TOSTOP 0000400
#define ECHOCTL 0001000
#define ECHOPRT 0002000
#define ECHOKE 0004000
#define FLUSHO 0010000
#define PENDIN 0040000
#define IEXTEN 0100000
#endif
#if defined __powerpc64__
#define NOFLSH 0x80000000
#define ECHOKE 1
#define IEXTEN 1024
#define ISIG 128
#define ECHONL 16
#define ECHOE 2
#define ICANON 256
#define ECHOPRT 32
#define ECHOK 4
#define TOSTOP 4194304
#define PENDIN 536870912
#define ECHOCTL 64
#define FLUSHO 8388608
#endif
#endif /* __LSB_VERSION__ >= 2.0 */
/* Standard speeds*/
#if __LSB_VERSION__ >= 11
#define B0 0000000
#define B50 0000001
#define B75 0000002
#define B110 0000003
#define B134 0000004
#define B150 0000005
#define B200 0000006
#define B300 0000007
#define B600 0000010
#define B1200 0000011
#define B1800 0000012
#define B2400 0000013
#define B4800 0000014
#define B9600 0000015
#define B19200 0000016
#define B38400 0000017
#endif /* __LSB_VERSION__ >= 1.1 */
/* Function prototypes */
extern speed_t cfgetispeed(const struct termios *__termios_p);
#undef cfgetospeed
extern speed_t cfgetospeed(const struct termios *__termios_p);
extern void cfmakeraw(struct termios *__termios_p);
extern int cfsetispeed(struct termios *__termios_p, speed_t __speed);
extern int cfsetospeed(struct termios *__termios_p, speed_t __speed);
extern int cfsetspeed(struct termios *__termios_p, speed_t __speed);
extern int tcdrain(int __fd);
extern int tcflow(int __fd, int __action);
#undef tcflush
extern int tcflush(int __fd, int __queue_selector);
#undef tcgetattr
extern int tcgetattr(int __fd, struct termios *__termios_p);
extern pid_t tcgetsid(int __fd);
extern int tcsendbreak(int __fd, int __duration);
#undef tcsetattr
extern int tcsetattr(int __fd, int __optional_actions,
const struct termios *__termios_p);
#ifdef __cplusplus
}
#endif
#endif /* protection */
#endif /* LSB version */
| 19.725027 | 73 | 0.768242 |
84f975ed02361820aac340ce9da6229fbeb77618 | 2,724 | c | C | src/besh_initialization.c | Hektelion/besh | dd4103a61130fc8ae8dcbb6d9c3abe5c35970afd | [
"MIT"
] | null | null | null | src/besh_initialization.c | Hektelion/besh | dd4103a61130fc8ae8dcbb6d9c3abe5c35970afd | [
"MIT"
] | null | null | null | src/besh_initialization.c | Hektelion/besh | dd4103a61130fc8ae8dcbb6d9c3abe5c35970afd | [
"MIT"
] | null | null | null | #include "../include/besh_initialization.h"
#include "../include/besh_constant.h"
#include "../include/environement.h"
#include <stdio.h> //stderr, printf() et EOF
#include <stdlib.h> //EXIT_FAILURE et NULL
#include <unistd.h> //environ
#include <string.h>
#include <fcntl.h>
char **besh_environement;
int besh_nb_var_environement;
/* Entrées : -
* Sorties : -
* Variables : -
* Traitement : -
* Erreur : -
*/
char *besh_getenv(char *name)
{
}
/* Entrées : -
* Sorties : -
* Variables : -
* Traitement : -
* Erreur : -
*/
int besh_putenv(char *name_equal_val)
{
}
/* Entrées : -
* Sorties : -
* Variables : -
* Traitement : -
* Erreur : -
*/
int besh_setenv(char *name, const char *value, int overwrite)
{
}
/* Entrées : -
* Sorties : -
* Variables : -
* Traitement : -
* Erreur : -
*/
int besh_unsetenv(const char *name)
{
}
/* Entrées : -
* Sorties : -
* Variables : -
* Traitement : -
* Erreur : -
*/
/*
int besh_initenvironement()
{
char *path_profile = NULL;
char c;
int profile_fd;
path_profile = getcwd(path_profile, 0);
strcat(path_profile, "/profile");
if( (profile_fd = open(path_profile, O_RDONLY)) == -1 )
{
//AJOUTER LA GESTION DE ERRNO ET PERROR
fprintf(stderr, "ERREUR : open()\n");
free(path_profile);
exit(EXIT_FAILURE);
}
//TRAITEMENT
if(close(profile_fd) == -1)
{
//AJOUTER LA GESTION DE ERRNO ET PERROR
fprintf(stderr, "ERREUR : close()\n");
}
free(path_profile);
}
*/
/* Entrées : -
* Sorties : -
* Variables : -
* Traitement : -
* Erreur : -
*/
int besh_initenvironement()
{
char *path_profile = NULL;
char c;
FILE *profile = NULL;
int i = 0;
int ret;
besh_nb_var_environement = 1;
besh_environement = NULL;
besh_environement = malloc(besh_nb_var_environement * sizeof(char*));
if(besh_environement == NULL)
{
fprintf(stderr, "Erreur pendant l'allocation de : besh_environement\n");
exit(EXIT_FAILURE);
}
path_profile = getcwd(path_profile, 0);
strcat(path_profile, "/profile");
//OUVERTURE DE PROFILE
profile = fopen(path_profile, "r");
if(profile == NULL)
{
fprintf(stderr, "Erreur pendant l'ouverture de : %s\n", path_profile);
exit(EXIT_FAILURE);
}
//TRAITEMENT
while( (ret = fscanf(profile, "%s\n", besh_environement[i])) != EOF && ret != 0)
{
printf("%s\n", besh_environement[i]);
besh_nb_var_environement ++;
besh_environement = realloc(besh_environement, besh_nb_var_environement * sizeof(char*));
if(besh_environement == NULL)
{
fprintf(stderr, "Erreur pendant la réallocation de : besh_environement\n");
exit(EXIT_FAILURE);
}
i++;
}
printf("OK\n");
//FERMETURE DE PROFILE
fclose(profile);
free(path_profile);
return 0;
}
| 17.350318 | 91 | 0.644273 |
b90fdc64ddaf99c797983149f8b4811dd6994229 | 12,462 | c | C | src/bcmltd/chip/bcmltd_vlan_egr_tag_action_profile_t.c | lguohan/SDKLT | 37acbc80e162bdfc7f7d5fb0833178f4f7a8afd4 | [
"Apache-2.0"
] | 2 | 2018-01-31T07:21:32.000Z | 2018-01-31T07:21:49.000Z | src/bcmltd/chip/bcmltd_vlan_egr_tag_action_profile_t.c | lguohan/SDKLT | 37acbc80e162bdfc7f7d5fb0833178f4f7a8afd4 | [
"Apache-2.0"
] | null | null | null | src/bcmltd/chip/bcmltd_vlan_egr_tag_action_profile_t.c | lguohan/SDKLT | 37acbc80e162bdfc7f7d5fb0833178f4f7a8afd4 | [
"Apache-2.0"
] | 3 | 2021-07-13T08:29:18.000Z | 2022-01-14T06:14:56.000Z | /*******************************************************************************
*
* DO NOT EDIT THIS FILE!
* This file is auto-generated by fltg from INTERNAL/fltg/xgs/vlan/VLAN_EGR_TAG_ACTION_PROFILE.tbl.ltl
* Edits to this file will be lost when it is regenerated.
*
* Copyright: (c) 2018 Broadcom. All Rights Reserved. "Broadcom" refers to
* Broadcom Limited and/or its subsidiaries.
*
* Broadcom Switch Software License
*
* This license governs the use of the accompanying Broadcom software. Your
* use of the software indicates your acceptance of the terms and conditions
* of this license. If you do not agree to the terms and conditions of this
* license, do not use the software.
* 1. Definitions
* "Licensor" means any person or entity that distributes its Work.
* "Software" means the original work of authorship made available under
* this license.
* "Work" means the Software and any additions to or derivative works of
* the Software that are made available under this license.
* The terms "reproduce," "reproduction," "derivative works," and
* "distribution" have the meaning as provided under U.S. copyright law.
* Works, including the Software, are "made available" under this license
* by including in or with the Work either (a) a copyright notice
* referencing the applicability of this license to the Work, or (b) a copy
* of this license.
* 2. Grant of Copyright License
* Subject to the terms and conditions of this license, each Licensor
* grants to you a perpetual, worldwide, non-exclusive, and royalty-free
* copyright license to reproduce, prepare derivative works of, publicly
* display, publicly perform, sublicense and distribute its Work and any
* resulting derivative works in any form.
* 3. Grant of Patent License
* Subject to the terms and conditions of this license, each Licensor
* grants to you a perpetual, worldwide, non-exclusive, and royalty-free
* patent license to make, have made, use, offer to sell, sell, import, and
* otherwise transfer its Work, in whole or in part. This patent license
* applies only to the patent claims licensable by Licensor that would be
* infringed by Licensor's Work (or portion thereof) individually and
* excluding any combinations with any other materials or technology.
* If you institute patent litigation against any Licensor (including a
* cross-claim or counterclaim in a lawsuit) to enforce any patents that
* you allege are infringed by any Work, then your patent license from such
* Licensor to the Work shall terminate as of the date such litigation is
* filed.
* 4. Redistribution
* You may reproduce or distribute the Work only if (a) you do so under
* this License, (b) you include a complete copy of this License with your
* distribution, and (c) you retain without modification any copyright,
* patent, trademark, or attribution notices that are present in the Work.
* 5. Derivative Works
* You may specify that additional or different terms apply to the use,
* reproduction, and distribution of your derivative works of the Work
* ("Your Terms") only if (a) Your Terms provide that the limitations of
* Section 7 apply to your derivative works, and (b) you identify the
* specific derivative works that are subject to Your Terms.
* Notwithstanding Your Terms, this license (including the redistribution
* requirements in Section 4) will continue to apply to the Work itself.
* 6. Trademarks
* This license does not grant any rights to use any Licensor's or its
* affiliates' names, logos, or trademarks, except as necessary to
* reproduce the notices described in this license.
* 7. Limitations
* Platform. The Work and any derivative works thereof may only be used, or
* intended for use, with a Broadcom switch integrated circuit.
* No Reverse Engineering. You will not use the Work to disassemble,
* reverse engineer, decompile, or attempt to ascertain the underlying
* technology of a Broadcom switch integrated circuit.
* 8. Termination
* If you violate any term of this license, then your rights under this
* license (including the license grants of Sections 2 and 3) will
* terminate immediately.
* 9. Disclaimer of Warranty
* THE WORK IS PROVIDED "AS IS" WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WARRANTIES OR CONDITIONS OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE OR
* NON-INFRINGEMENT. YOU BEAR THE RISK OF UNDERTAKING ANY ACTIVITIES UNDER
* THIS LICENSE. SOME STATES' CONSUMER LAWS DO NOT ALLOW EXCLUSION OF AN
* IMPLIED WARRANTY, SO THIS DISCLAIMER MAY NOT APPLY TO YOU.
* 10. Limitation of Liability
* EXCEPT AS PROHIBITED BY APPLICABLE LAW, IN NO EVENT AND UNDER NO LEGAL
* THEORY, WHETHER IN TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE
* SHALL ANY LICENSOR BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY DIRECT,
* INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
* OR RELATED TO THIS LICENSE, THE USE OR INABILITY TO USE THE WORK
* (INCLUDING BUT NOT LIMITED TO LOSS OF GOODWILL, BUSINESS INTERRUPTION,
* LOST PROFITS OR DATA, COMPUTER FAILURE OR MALFUNCTION, OR ANY OTHER
* COMMERCIAL DAMAGES OR LOSSES), EVEN IF THE LICENSOR HAS BEEN ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGES.
*/
#include <bcmltd/bcmltd_internal.h>
#include "bcmltd_strpool.h"
static const bcmltd_field_rep_t bcmltd_vlan_egr_tag_action_profile_t_fields[] = {
{
.name = bcmltd_strpool_vlan_egr_tag_action_profile_id, /* VLAN_EGR_TAG_ACTION_PROFILE_ID */
.flags = BCMLTD_FIELD_F_KEY,
.width = 12,
.depth = 0,
.desc = "Egress VLAN tag action profile ID.",
},
{
.name = bcmltd_strpool_ut_otag, /* UT_OTAG */
.flags = BCMLTD_FIELD_F_ENUM,
.width = 32,
.depth = 0,
.desc = "Outer VLAN action for the untagged packets.",
},
{
.name = bcmltd_strpool_ut_opri, /* UT_OPRI */
.flags = BCMLTD_FIELD_F_ENUM,
.width = 32,
.depth = 0,
.desc = "Outer VLAN priority action for the untagged packets.",
},
{
.name = bcmltd_strpool_ut_ocfi, /* UT_OCFI */
.flags = BCMLTD_FIELD_F_ENUM,
.width = 32,
.depth = 0,
.desc = "Outer VLAN CFI action for the untagged packets.",
},
{
.name = bcmltd_strpool_ut_itag, /* UT_ITAG */
.flags = BCMLTD_FIELD_F_ENUM,
.width = 32,
.depth = 0,
.desc = "Inner VLAN action for the untagged packets.",
},
{
.name = bcmltd_strpool_ut_ipri, /* UT_IPRI */
.flags = BCMLTD_FIELD_F_ENUM,
.width = 32,
.depth = 0,
.desc = "Inner VLAN priority action for the untagged packets.",
},
{
.name = bcmltd_strpool_ut_icfi, /* UT_ICFI */
.flags = BCMLTD_FIELD_F_ENUM,
.width = 32,
.depth = 0,
.desc = "Inner VLAN CFI action for the untagged packets.",
},
{
.name = bcmltd_strpool_sot_potag, /* SOT_POTAG */
.flags = BCMLTD_FIELD_F_ENUM,
.width = 32,
.depth = 0,
.desc = "Outer VLAN action for the single outer priority tagged packets.",
},
{
.name = bcmltd_strpool_sot_otag, /* SOT_OTAG */
.flags = BCMLTD_FIELD_F_ENUM,
.width = 32,
.depth = 0,
.desc = "Outer VLAN action for the single outer tagged packets.",
},
{
.name = bcmltd_strpool_sot_opri, /* SOT_OPRI */
.flags = BCMLTD_FIELD_F_ENUM,
.width = 32,
.depth = 0,
.desc = "Outer VLAN priority action for the single outer tagged packets.",
},
{
.name = bcmltd_strpool_sot_ocfi, /* SOT_OCFI */
.flags = BCMLTD_FIELD_F_ENUM,
.width = 32,
.depth = 0,
.desc = "Outer VLAN CFI action for the single outer tagged packets.",
},
{
.name = bcmltd_strpool_sot_itag, /* SOT_ITAG */
.flags = BCMLTD_FIELD_F_ENUM,
.width = 32,
.depth = 0,
.desc = "Inner VLAN action for the single outer tagged packets.",
},
{
.name = bcmltd_strpool_sot_ipri, /* SOT_IPRI */
.flags = BCMLTD_FIELD_F_ENUM,
.width = 32,
.depth = 0,
.desc = "Inner VLAN priority action for the single outer tagged packets.",
},
{
.name = bcmltd_strpool_sot_icfi, /* SOT_ICFI */
.flags = BCMLTD_FIELD_F_ENUM,
.width = 32,
.depth = 0,
.desc = "Outer VLAN CFI action for the single outer tagged packets.",
},
{
.name = bcmltd_strpool_sit_pitag, /* SIT_PITAG */
.flags = BCMLTD_FIELD_F_ENUM,
.width = 32,
.depth = 0,
.desc = "Inner VLAN action for the single inner priority tagged packets.",
},
{
.name = bcmltd_strpool_sit_otag, /* SIT_OTAG */
.flags = BCMLTD_FIELD_F_ENUM,
.width = 32,
.depth = 0,
.desc = "Outer VLAN action for the single inner tagged packets.",
},
{
.name = bcmltd_strpool_sit_opri, /* SIT_OPRI */
.flags = BCMLTD_FIELD_F_ENUM,
.width = 32,
.depth = 0,
.desc = "Outer VLAN priority action for the single inner tagged packets.",
},
{
.name = bcmltd_strpool_sit_ocfi, /* SIT_OCFI */
.flags = BCMLTD_FIELD_F_ENUM,
.width = 32,
.depth = 0,
.desc = "Outer VLAN CFI action for the single inner tagged packets.",
},
{
.name = bcmltd_strpool_sit_itag, /* SIT_ITAG */
.flags = BCMLTD_FIELD_F_ENUM,
.width = 32,
.depth = 0,
.desc = "Inner VLAN action for the single inner tagged packets.",
},
{
.name = bcmltd_strpool_sit_ipri, /* SIT_IPRI */
.flags = BCMLTD_FIELD_F_ENUM,
.width = 32,
.depth = 0,
.desc = "Inner VLAN priority action for the single inner tagged packets.",
},
{
.name = bcmltd_strpool_sit_icfi, /* SIT_ICFI */
.flags = BCMLTD_FIELD_F_ENUM,
.width = 32,
.depth = 0,
.desc = "Inner VLAN CFI action for the single inner tagged packets.",
},
{
.name = bcmltd_strpool_dt_potag, /* DT_POTAG */
.flags = BCMLTD_FIELD_F_ENUM,
.width = 32,
.depth = 0,
.desc = "Outer VLAN action for the double priority tagged packets.",
},
{
.name = bcmltd_strpool_dt_pitag, /* DT_PITAG */
.flags = BCMLTD_FIELD_F_ENUM,
.width = 32,
.depth = 0,
.desc = "Inner VLAN action for the double priority tagged packets.",
},
{
.name = bcmltd_strpool_dt_otag, /* DT_OTAG */
.flags = BCMLTD_FIELD_F_ENUM,
.width = 32,
.depth = 0,
.desc = "Outer VLAN action for the double tagged packets.",
},
{
.name = bcmltd_strpool_dt_opri, /* DT_OPRI */
.flags = BCMLTD_FIELD_F_ENUM,
.width = 32,
.depth = 0,
.desc = "Outer VLAN priority action for the double tagged packets.",
},
{
.name = bcmltd_strpool_dt_ocfi, /* DT_OCFI */
.flags = BCMLTD_FIELD_F_ENUM,
.width = 32,
.depth = 0,
.desc = "Outer VLAN CFI action for the double tagged packets.",
},
{
.name = bcmltd_strpool_dt_itag, /* DT_ITAG */
.flags = BCMLTD_FIELD_F_ENUM,
.width = 32,
.depth = 0,
.desc = "Inner VLAN action for the double tagged packets.",
},
{
.name = bcmltd_strpool_dt_ipri, /* DT_IPRI */
.flags = BCMLTD_FIELD_F_ENUM,
.width = 32,
.depth = 0,
.desc = "Inner VLAN priority action for the double tagged packets.",
},
{
.name = bcmltd_strpool_dt_icfi, /* DT_ICFI */
.flags = BCMLTD_FIELD_F_ENUM,
.width = 32,
.depth = 0,
.desc = "Inner VLAN CFI action for the double tagged packets.",
},
};
const bcmltd_table_rep_t bcmltd_vlan_egr_tag_action_profile_t = {
.name = bcmltd_strpool_vlan_egr_tag_action_profile, /* VLAN_EGR_TAG_ACTION_PROFILE */
.flags = 0,
.fields = 29,
.field = bcmltd_vlan_egr_tag_action_profile_t_fields,
.desc = "",
};
| 40.72549 | 102 | 0.628872 |
fe2ca13ec187c819b86a4d6de72d5e21ccccc1ce | 334 | c | C | test.c | sanjitk7/bankersAlgorithmWithInterrupts | 724edb95d9174a4bebdc6dd276ce7156e28ff63f | [
"MIT"
] | null | null | null | test.c | sanjitk7/bankersAlgorithmWithInterrupts | 724edb95d9174a4bebdc6dd276ce7156e28ff63f | [
"MIT"
] | null | null | null | test.c | sanjitk7/bankersAlgorithmWithInterrupts | 724edb95d9174a4bebdc6dd276ce7156e28ff63f | [
"MIT"
] | null | null | null | #include<stdio.h>
#include<string.h>
char stringBuffer[20];
char* outputStrings[5];
int main(){
int i;
int example[]={1,2,3,4,5};
for (i = 0 ; i < 5 ; ++i)
{
snprintf(stringBuffer, 20, "%d", example[i]);
// check for overrun omitted
outputStrings[i] = strdup(stringBuffer);
printf("%s",stringBuffer);
}
} | 20.875 | 49 | 0.601796 |
b3fe89f3c963ef2e7591639afd49748d6a0f912f | 436 | h | C | src/coreclr/ToolBox/superpmi/superpmi/jithost.h | pyracanda/runtime | 72bee25ab532a4d0636118ec2ed3eabf3fd55245 | [
"MIT"
] | 9,402 | 2019-11-25T23:26:24.000Z | 2022-03-31T23:19:41.000Z | src/coreclr/ToolBox/superpmi/superpmi/jithost.h | pyracanda/runtime | 72bee25ab532a4d0636118ec2ed3eabf3fd55245 | [
"MIT"
] | 37,522 | 2019-11-25T23:30:32.000Z | 2022-03-31T23:58:30.000Z | src/coreclr/ToolBox/superpmi/superpmi/jithost.h | pyracanda/runtime | 72bee25ab532a4d0636118ec2ed3eabf3fd55245 | [
"MIT"
] | 3,629 | 2019-11-25T23:29:16.000Z | 2022-03-31T21:52:28.000Z | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#ifndef _JITHOST
#define _JITHOST
class JitHost final : public ICorJitHost
{
public:
JitHost(JitInstance& jitInstance);
#include "icorjithostimpl.h"
private:
bool convertStringValueToInt(const WCHAR* key, const WCHAR* stringValue, int& result);
JitInstance& jitInstance;
};
#endif
| 20.761905 | 90 | 0.754587 |
bef91ec2df3e0c8185af7f51b05e54833ebcc7f6 | 961 | h | C | modules/paged_article/paged_article.h | Relintai/rcpp_framework | 6416ecc5e0c88115f209cd63945a29c0e16a8e99 | [
"MIT"
] | null | null | null | modules/paged_article/paged_article.h | Relintai/rcpp_framework | 6416ecc5e0c88115f209cd63945a29c0e16a8e99 | [
"MIT"
] | null | null | null | modules/paged_article/paged_article.h | Relintai/rcpp_framework | 6416ecc5e0c88115f209cd63945a29c0e16a8e99 | [
"MIT"
] | null | null | null | #ifndef PAGED_ARTICLE_H
#define PAGED_ARTICLE_H
#include <map>
#include "core/containers/vector.h"
#include "core/string.h"
#include "core/file_cache.h"
#include "core/http/web_node.h"
#include "core/http/request.h"
struct Article {
String url;
String summary_page;
std::map<String, String *> pages;
FileCache *file_cache;
Article() {
file_cache = new FileCache();
}
~Article() {
for (std::map<String, String *>::iterator it = pages.begin(); it != pages.end(); ++it) {
delete ((*it).second);
}
pages.clear();
delete file_cache;
}
};
class PagedArticle : public WebNode {
RCPP_OBJECT(PagedArticle, WebNode);
public:
void handle_request_main(Request *request);
void load();
Article *load_folder(const String &folder, const String &path);
void generate_summaries();
void generate_summary(Article *article);
PagedArticle();
~PagedArticle();
std::map<String, Article *> pages;
String folder;
String base_path;
};
#endif | 18.480769 | 90 | 0.702393 |
7eba2beef75fe511d5e39d7d2b96a01d2a10f488 | 477 | c | C | q11332.c | abraxaslee/ACM-ICPC | d8db31a4a2a36258bfba42a806b02bbf3eceaf2b | [
"MIT"
] | 1 | 2018-03-19T05:18:49.000Z | 2018-03-19T05:18:49.000Z | q11332.c | abraxaslee/ACM-ICPC | d8db31a4a2a36258bfba42a806b02bbf3eceaf2b | [
"MIT"
] | null | null | null | q11332.c | abraxaslee/ACM-ICPC | d8db31a4a2a36258bfba42a806b02bbf3eceaf2b | [
"MIT"
] | null | null | null | // 0.004
#include <stdio.h>
int sum(int inputNum){
if(inputNum<10){
return inputNum;
}
int outputNum = 0;
while(inputNum>0){
outputNum += inputNum%10;
inputNum /= 10;
}
return sum(outputNum);
}
int main(){
#ifndef ONLINE_JUDGE
freopen("q11332.in", "r", stdin);
freopen("q11332.out", "w", stdout);
#endif
int n;
while(scanf("%d",&n)!=EOF){
if(n==0){
return 0;
}else{
printf("%d\n", sum(n));
}
}
return 0;
}
| 14.029412 | 37 | 0.54717 |
62561043d1fda457a014578503f108adf6d50908 | 1,976 | h | C | myexamplederivedclassl3.h | LouisParkin/VoidPtrDemonstration | 89cf979c1c927733598281b6d3a6428f772bdc03 | [
"MIT"
] | null | null | null | myexamplederivedclassl3.h | LouisParkin/VoidPtrDemonstration | 89cf979c1c927733598281b6d3a6428f772bdc03 | [
"MIT"
] | null | null | null | myexamplederivedclassl3.h | LouisParkin/VoidPtrDemonstration | 89cf979c1c927733598281b6d3a6428f772bdc03 | [
"MIT"
] | null | null | null | /// @file myexamplederivedclassl3.h
///
/// For the better part, this class (MyExampleDerivedClassL3) actually does nothing but occupy memory.
///
/// It inherits from MyExampleDerivedClassL2, overrides some virtual functions, but those, inherited
/// and overridden mostly do nothing.
///
/// The purpose of it and its ancestor is to carry arbitrary data for memory analysis.
#ifndef MYEXAMPLEDERIVEDCLASSL3_H
#define MYEXAMPLEDERIVEDCLASSL3_H
#include "myexamplederivedclassl2.h"
class MyExampleDerivedClassL3 : public MyExampleDerivedClassL2
{
public:
MyExampleDerivedClassL3();
virtual ~MyExampleDerivedClassL3();
/// A normal non-virtual public function. Can't be overridden in a derived class.
void publicDerivedL3MemberFunction1();
/// A normal non-virtual public function. Can't be overridden in a derived class.
void publicDerivedL3MemberFunction2();
/// A normal non-virtual public function. Can't be overridden in a derived class.
void publicDerivedL3MemberFunction3();
virtual void populatename(char withWhat);
protected:
/// A normal non-virtual protected function. Can't be overridden in a derived class.
void protectedDerivedL3MemberFunction1();
/// A normal non-virtual protected function. Can't be overridden in a derived class.
void protectedDerivedL3MemberFunction2();
/// A normal non-virtual protected function. Can't be overridden in a derived class.
void protectedDerivedL3MemberFunction3();
char _derivedL3name[32];
private:
/// A normal non-virtual private function. Can't be overridden in a derived class.
void privateDerivedL3MemberFunction1();
/// A normal non-virtual private function. Can't be overridden in a derived class.
void privateDerivedL3MemberFunction2();
/// A normal non-virtual private function. Can't be overridden in a derived class.
void privateDerivedL3MemberFunction3();
};
#endif // MYEXAMPLEDERIVEDCLASSL3_H
| 34.666667 | 102 | 0.752024 |
2bd32519c3a92adf1ca21a09f1e6c01ffe18cade | 4,025 | h | C | PrivateFrameworks/AudioServerDriver/ASDPlugin.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 17 | 2018-11-13T04:02:58.000Z | 2022-01-20T09:27:13.000Z | PrivateFrameworks/AudioServerDriver/ASDPlugin.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 3 | 2018-04-06T02:02:27.000Z | 2018-10-02T01:12:10.000Z | PrivateFrameworks/AudioServerDriver/ASDPlugin.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 1 | 2018-09-28T13:54:23.000Z | 2018-09-28T13:54:23.000Z | //
// Generated by class-dump 3.5 (64 bit).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard.
//
#import <AudioServerDriver/ASDObject.h>
#import "ASDDeviceConfigurationChangeDelegate.h"
#import "ASDPropertyChangedDelegate.h"
@class NSMapTable, NSMutableDictionary, NSObject<OS_dispatch_queue>, NSString;
@interface ASDPlugin : ASDObject <ASDDeviceConfigurationChangeDelegate, ASDPropertyChangedDelegate>
{
NSMapTable *_objects;
NSObject<OS_dispatch_queue> *_objectQueue;
NSMutableDictionary *_boxes;
NSObject<OS_dispatch_queue> *_boxQueue;
NSMutableDictionary *_audioDevices;
NSObject<OS_dispatch_queue> *_audioDeviceQueue;
NSMutableDictionary *_clockDevices;
NSObject<OS_dispatch_queue> *_clockDeviceQueue;
NSString *_manufacturerName;
unsigned int _nextObjectID;
struct AudioServerPlugInDriverInterface *_interfacePtr;
struct AudioServerPlugInDriverInterface **_driverRef;
struct AudioServerPlugInHostInterface *_pluginHost;
unsigned int _pluginRefCount;
NSObject<OS_dispatch_queue> *_powerNotificationQueue;
struct IONotificationPort *_powerNotificationPort;
unsigned int _powerConnection;
unsigned int _powerNotifier;
unsigned int _transportType;
NSString *_bundleID;
}
@property(nonatomic) unsigned int transportType; // @synthesize transportType=_transportType;
@property(readonly, nonatomic) NSString *bundleID; // @synthesize bundleID=_bundleID;
@property(readonly, nonatomic) struct AudioServerPlugInDriverInterface **driverRef; // @synthesize driverRef=_driverRef;
- (void).cxx_destruct;
- (id)driverClassName;
- (id)diagnosticDescriptionWithIndent:(id)arg1 walkTree:(BOOL)arg2;
- (BOOL)deregisterForSystemSleepNotifications;
- (void)systemHasPoweredOn;
- (void)systemWillSleep;
- (void)_handlePowerNotificationWithMessageType:(unsigned int)arg1 andArgument:(long long)arg2;
- (BOOL)registerForSystemSleepNotifications;
- (void)setArray:(id)arg1 forKey:(id)arg2;
- (id)arrayForKey:(id)arg1;
- (void)setDictionary:(id)arg1 forKey:(id)arg2;
- (id)dictionaryForKey:(id)arg1;
- (id)plugin;
- (BOOL)requestConfigurationChangeForDevice:(id)arg1 withBlock:(CDUnknownBlockType)arg2;
- (void)changedProperty:(const struct AudioObjectPropertyAddress *)arg1 forObjectID:(unsigned int)arg2;
- (void)changedProperty:(const struct AudioObjectPropertyAddress *)arg1 forObject:(id)arg2;
- (unsigned int)objectIDForClockDeviceUID:(id)arg1;
- (id)clockDevices;
- (void)removeClockDevices:(id)arg1;
- (void)removeClockDevice:(id)arg1;
- (void)addClockDevices:(id)arg1;
- (void)addClockDevice:(id)arg1;
- (unsigned int)objectIDForBoxUID:(id)arg1;
- (id)boxes;
- (void)removeBox:(id)arg1;
- (void)addBox:(id)arg1;
- (unsigned int)objectIDForDeviceUID:(id)arg1;
- (id)audioDevices;
- (id)devices;
- (void)removeAudioDevices:(id)arg1;
- (void)removeDevices:(id)arg1;
- (void)addAudioDevices:(id)arg1;
- (void)addDevices:(id)arg1;
- (void)removeAudioDevice:(id)arg1;
- (void)removeDevice:(id)arg1;
- (void)addAudioDevice:(id)arg1;
- (void)addDevice:(id)arg1;
- (id)objectForObjectID:(unsigned int)arg1;
- (void)removeCAObject:(id)arg1;
- (void)addCAObject:(id)arg1;
- (unsigned int)removeRef;
- (unsigned int)addRef;
- (BOOL)getProperty:(const struct AudioObjectPropertyAddress *)arg1 withQualifierSize:(unsigned int)arg2 qualifierData:(const void *)arg3 dataSize:(unsigned int *)arg4 andData:(void *)arg5 forClient:(int)arg6;
- (unsigned int)dataSizeForProperty:(const struct AudioObjectPropertyAddress *)arg1 withQualifierSize:(unsigned int)arg2 andQualifierData:(const void *)arg3;
- (BOOL)hasProperty:(const struct AudioObjectPropertyAddress *)arg1;
- (unsigned int)objectClass;
- (void)halInitializeWithPluginHost:(struct AudioServerPlugInHostInterface *)arg1;
- (void)dealloc;
- (id)init;
// Remaining properties
@property(readonly, copy) NSString *debugDescription;
@property(readonly, copy) NSString *description;
@property(readonly) unsigned long long hash;
@property(readonly) Class superclass;
@end
| 40.656566 | 209 | 0.78236 |
2e15577b0e16d2a34880d8a7be550877db871941 | 632 | c | C | RandC/openMP.c | joey-kilgore/playground | 2ad1f9f0c51a4a3a4ad9e2646e8a8bde7f368320 | [
"Unlicense"
] | null | null | null | RandC/openMP.c | joey-kilgore/playground | 2ad1f9f0c51a4a3a4ad9e2646e8a8bde7f368320 | [
"Unlicense"
] | 1 | 2019-12-10T01:37:23.000Z | 2019-12-10T01:37:23.000Z | RandC/openMP.c | joey-kilgore/playground | 2ad1f9f0c51a4a3a4ad9e2646e8a8bde7f368320 | [
"Unlicense"
] | 2 | 2019-03-26T03:20:41.000Z | 2019-12-09T23:22:40.000Z | #include <omp.h>
#include <stdio.h>
#include <stdlib.h>
int someMath(int num,int i){
num = num * num * num * i;
return num;
}
int main(int argc, char** argv){
int nthreads, tid;
int i;
int num = atoi(argv[1]);
int data[10000];
#pragma omp parallel
{
#pragma omp for
for(i=0; i<10000; i++){
data[i] = someMath(num,i);
}
}
FILE *fp;
fp = fopen("data.csv","w+");
for(i=0; i<10000; i++){
fprintf(fp, "%d,",data[i]);
}
fprintf(fp, "\n");
for(i=0; i<10000; i++){
fprintf(fp, "%d,",data[i]);
}
fprintf(fp, "\n");
fclose(fp);
}
| 17.555556 | 35 | 0.488924 |
f3ba937cafd6eb1dce6c7c38d69a63680503723f | 4,906 | h | C | oi_async.h | citisolo/liboi | f6d0026f9ef69f5fdca779b14a983d44a23d3f00 | [
"BSD-2-Clause"
] | null | null | null | oi_async.h | citisolo/liboi | f6d0026f9ef69f5fdca779b14a983d44a23d3f00 | [
"BSD-2-Clause"
] | null | null | null | oi_async.h | citisolo/liboi | f6d0026f9ef69f5fdca779b14a983d44a23d3f00 | [
"BSD-2-Clause"
] | 1 | 2020-11-02T12:03:51.000Z | 2020-11-02T12:03:51.000Z | #include <ev.h>
#include <pthread.h>
#include <netdb.h>
#include <oi.h>
#ifndef oi_async_h
#define oi_async_h
#ifdef __cplusplus
extern "C" {
#endif
typedef struct oi_async oi_async;
typedef struct oi_task oi_task;
struct oi_async {
/* private */
ev_async watcher;
struct ev_loop *loop;
oi_queue finished_tasks;
oi_queue new_tasks;
/* public */
void *data;
};
typedef void (*oi_task_int_cb)(oi_task *, int result);
typedef void (*oi_task_uint_cb)(oi_task *, unsigned int result);
typedef void (*oi_task_ssize_cb)(oi_task *, ssize_t result);
struct oi_task {
/* private */
oi_async *async;
oi_queue queue;
int type;
union {
struct {
const char *pathname;
int flags;
mode_t mode;
oi_task_int_cb cb;
int result;
} open;
struct {
int fd;
void *buf;
size_t count;
oi_task_ssize_cb cb;
ssize_t result;
} read;
struct {
int fd;
const void *buf;
size_t count;
oi_task_ssize_cb cb;
ssize_t result;
} write;
struct {
int fd;
oi_task_int_cb cb;
int result;
} close;
struct {
unsigned int seconds;
oi_task_uint_cb cb;
unsigned int result;
} sleep;
struct {
int out_fd;
int in_fd;
off_t offset;
size_t count;
oi_task_ssize_cb cb;
ssize_t result;
} eio__sendfile;
struct {
const char *nodename; /* restrict ? */
const char *servname; /* restrict ? */
struct addrinfo *hints;
struct addrinfo **res; /* restrict ? */
oi_task_int_cb cb;
int result;
} getaddrinfo;
struct {
const char *path;
struct stat *buf;
oi_task_int_cb cb;
int result;
} lstat;
} params;
/* read-only */
volatile unsigned active:1;
int errorno;
/* public */
void *data;
};
void oi_async_init (oi_async *);
void oi_async_attach (struct ev_loop *loop, oi_async *);
void oi_async_detach (oi_async *);
void oi_async_submit (oi_async *, oi_task *);
/* To submit a task for async processing
* (0) allocate memory for your task
* (1) initialize the task with one of the functions below
* (2) optionally set the task->data pointer
* (3) oi_async_submit() the task
*/
enum { OI_TASK_OPEN
, OI_TASK_READ
, OI_TASK_WRITE
, OI_TASK_CLOSE
, OI_TASK_SLEEP
, OI_TASK_SENDFILE
, OI_TASK_GETADDRINFO
, OI_TASK_LSTAT
};
#define oi_task_init_common(task, _type) do {\
(task)->active = 0;\
(task)->async = NULL;\
(task)->type = _type;\
} while(0)
static inline void
oi_task_init_open(oi_task *t, oi_task_int_cb cb, const char *pathname, int flags, mode_t mode)
{
oi_task_init_common(t, OI_TASK_OPEN);
t->params.open.cb = cb;
t->params.open.pathname = pathname;
t->params.open.flags = flags;
t->params.open.mode = mode;
}
static inline void
oi_task_init_read(oi_task *t, oi_task_ssize_cb cb, int fd, void *buf, size_t count)
{
oi_task_init_common(t, OI_TASK_READ);
t->params.read.cb = cb;
t->params.read.fd = fd;
t->params.read.buf = buf;
t->params.read.count = count;
}
static inline void
oi_task_init_write(oi_task *t, oi_task_ssize_cb cb, int fd, const void *buf, size_t count)
{
oi_task_init_common(t, OI_TASK_WRITE);
t->params.write.cb = cb;
t->params.write.fd = fd;
t->params.write.buf = buf;
t->params.write.count = count;
}
static inline void
oi_task_init_close(oi_task *t, oi_task_int_cb cb, int fd)
{
oi_task_init_common(t, OI_TASK_CLOSE);
t->params.close.cb = cb;
t->params.close.fd = fd;
}
static inline void
oi_task_init_sleep(oi_task *t, oi_task_uint_cb cb, unsigned int seconds)
{
oi_task_init_common(t, OI_TASK_SLEEP);
t->params.sleep.cb = cb;
t->params.sleep.seconds = seconds;
}
static inline void
oi_task_init_sendfile(oi_task *t, oi_task_ssize_cb cb, int out_fd, int in_fd, off_t offset, size_t count)
{
oi_task_init_common(t, OI_TASK_SENDFILE);
t->params.eio__sendfile.cb = cb;
t->params.eio__sendfile.out_fd = out_fd;
t->params.eio__sendfile.in_fd = in_fd;
t->params.eio__sendfile.offset = offset;
t->params.eio__sendfile.count = count;
}
static inline void
oi_task_init_getaddrinfo(oi_task *t, oi_task_int_cb cb, const char *node,
const char *service, struct addrinfo *hints, struct addrinfo **res)
{
oi_task_init_common(t, OI_TASK_GETADDRINFO);
t->params.getaddrinfo.cb = cb;
t->params.getaddrinfo.nodename = node;
t->params.getaddrinfo.servname = service;
t->params.getaddrinfo.hints = hints;
t->params.getaddrinfo.res = res;
}
static inline void
oi_task_init_lstat(oi_task *t, oi_task_int_cb cb, const char *path, struct stat *buf)
{
oi_task_init_common(t, OI_TASK_LSTAT);
t->params.lstat.cb = cb;
t->params.lstat.path = path;
t->params.lstat.buf = buf;
}
#ifdef __cplusplus
}
#endif
#endif /* oi_async_h */
| 22.401826 | 106 | 0.664696 |
4317f8a58e6680b9a1368363efb6b6e02117b880 | 4,347 | c | C | src/hexmove.c | YTEC-info/hexed | f81dc2c6144a49607bdfdcad7993b48e03dfcf6b | [
"BSD-2-Clause"
] | null | null | null | src/hexmove.c | YTEC-info/hexed | f81dc2c6144a49607bdfdcad7993b48e03dfcf6b | [
"BSD-2-Clause"
] | null | null | null | src/hexmove.c | YTEC-info/hexed | f81dc2c6144a49607bdfdcad7993b48e03dfcf6b | [
"BSD-2-Clause"
] | null | null | null | /******************************************************************************
*
* hexmove.c - hexed move command
*
******************************************************************************
*
* Copyright (c) 2011, B.ZaaR
*
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* The names of contributors may not be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*****************************************************************************/
#include <errno.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "bfile.h"
#include "hexed.h"
/*
* Move len words from src to dest
*/
static int move(Command *cmd)
{
bfmove(hexfile, cmd->opts.dest, cmd->opts.src, cmd->opts.bytes);
return 0;
}
/*
* Move overwriting len words from src to dest
*/
static int moveover(Command *cmd)
{
long cnt, len, off;
bfmove(hexfile, cmd->opts.dest, cmd->opts.src, cmd->opts.bytes);
// insert zeroes in chunks (keeps dest set)
if(cmd->opts.src < cmd->opts.dest){
memset(cmd->opts.buf, 0, OPT_BUF_SZ);
len = OPT_BUF_SZ;
cnt = cmd->opts.bytes;
off = cmd->opts.dest - cmd->opts.bytes;
if(off < cmd->opts.src){
cnt = cmd->opts.dest - cmd->opts.src;
off = cmd->opts.src;
}
for(; cnt; cnt -= len){
// end of count?
if(cnt < len){
len = cnt;
}
// insert zeroes
bfwrite(hexfile, off, cmd->opts.buf, len);
off += len;
}
// clip data
}else{
bfclip(hexfile, cmd->opts.dest + cmd->opts.len, cmd->opts.bytes);
}
return 0;
}
/*
* Run the move command
*/
static int runmove(Command *cmd)
{
// error: source past EOF
if(cmd->opts.src > hexfile->size){
RETURN_ERR(EINVAL);
}
switch(cmd->id){
case CMD_MOVE:
return move(cmd);
case CMD_MOVE_OVER:
return moveover(cmd);
default:
return -1;
}
}
/*
* set the move command
*/
static int setmove(Command *cmd, int optc, char *opt)
{
char *s;
uint64_t v;
// set defaults
if(optc == 0){
cmd->flags |= CMD_FL_QUIT;
}
// NULL option
if(opt == NULL){
RETURN_ERR(EFAULT);
}
v = strtoll(opt, &s, 0x10);
// no value set in option
if(s == opt){
RETURN_ERR(EINVAL);
}
// set options
switch(optc){
case 0:
// set source
cmd->opts.src = v;
optc++;
break;
case 1:
// set destination
cmd->opts.dest = v;
optc++;
break;
case 2:
// set length
cmd->opts.len = v;
cmd->opts.bytes = cmd->opts.len * cmd->opts.word;
optc = 0;
break;
default:
// too many options specified
RETURN_ERR(E2BIG);
}
return optc;
}
/*
* Move command
*/
int hexmove(Command *cmd, int optc, char *opt)
{
// invalid command
if(cmd == NULL || (cmd->id != CMD_MOVE && cmd->id != CMD_MOVE_OVER)){
RETURN_ERR(EINVAL);
}
// set/run move
if(optc >= 0){
optc = setmove(cmd, optc, opt);
}else{
optc = runmove(cmd);
}
return optc;
}
| 22.878947 | 80 | 0.603635 |
28787235cff2018f3cc34f3d24ef2d789140410c | 1,092 | h | C | Practice - other groups tasks/Practice 1/Lilbib.h | Keikeu/CPP-Laboratories | 6030838ce666ab42755754523e4513a32b586a65 | [
"MIT"
] | null | null | null | Practice - other groups tasks/Practice 1/Lilbib.h | Keikeu/CPP-Laboratories | 6030838ce666ab42755754523e4513a32b586a65 | [
"MIT"
] | 3 | 2019-11-15T22:58:09.000Z | 2019-11-15T23:09:15.000Z | Practice - other groups tasks/Practice 1/Lilbib.h | Keikeu/CPP-Laboratories | 6030838ce666ab42755754523e4513a32b586a65 | [
"MIT"
] | null | null | null | #pragma once
#include <string>
#include <iostream>
using namespace std;
class Page
{
public:
Page(string header = "empty", string text = "empty") : m_header(header), m_text(text) {}
Page* Copy();
void Print();
void AddHeader(string header) {m_header = header;}
void AddText(string text) {m_text = text;}
string getHeader() {return m_header;}
string getText() {return m_text;}
private:
string m_header;
string m_text;
};
class Book
{
public:
Book(string title = "dummy");
void Print();
void Copy(Book* book);
void AddPage(Page *page);
void AddTitle(string title);
void AddHeader(string header);
void AddText(string text);
string getTitle() {return m_title;}
private:
Page* m_pages[100];
string m_title;
string m_author;
int m_number;
int m_iterator;
};
class Catalog
{
public:
Catalog(string name) : m_name(name), m_number(0) {};
void AddBook(Book *book) {m_books[m_number] = book; m_number++;}
void Print();
private:
string m_name;
Book* m_books[100];
int m_number;
};
| 18.508475 | 92 | 0.644689 |
1a938bf2a492439d3d04b4e5f9030fa86402aa73 | 1,082 | h | C | Engine/ResourcePacker/Packer/ResourcePacker.h | azhirnov/GraphicsGenFramework-modular | 348be601f1991f102defa0c99250529f5e44c4d3 | [
"BSD-2-Clause"
] | 12 | 2017-12-23T14:24:57.000Z | 2020-10-02T19:52:12.000Z | Engine/ResourcePacker/Packer/ResourcePacker.h | azhirnov/ModularGraphicsFramework | 348be601f1991f102defa0c99250529f5e44c4d3 | [
"BSD-2-Clause"
] | null | null | null | Engine/ResourcePacker/Packer/ResourcePacker.h | azhirnov/ModularGraphicsFramework | 348be601f1991f102defa0c99250529f5e44c4d3 | [
"BSD-2-Clause"
] | null | null | null | // Copyright (c) Zhirnov Andrey. For more information see 'LICENSE.txt'
#pragma once
#include "Engine/ResourcePacker/Pipelines/PipelineConverter.h"
#include "Engine/ResourcePacker/FilePacker/IFileSystemPacker.h"
namespace ResPack
{
//
// Resource Packer
//
class ResourcePacker final
{
friend struct ScriptHelper;
// types
private:
class ScriptResourcePacker;
using PipelinePtr = PipelineConverter::PipelinePtr;
using PipelineConverterConfig = PipelineConverter::ConverterConfig;
// variables
private:
PipelineConverter _pplnConverter;
String _exeName;
// methods
protected:
ResourcePacker ();
~ResourcePacker ();
public:
static Ptr<ResourcePacker> Instance ();
bool Initialize ();
void SetExecutable (StringCRef name);
bool Run (StringCRef res);
void AddPipeline (const PipelinePtr &ppln);
StringCRef GetExecutableName () const { return _exeName; }
private:
//bool _PackFile (IFilePackerPtr &&file, StringCRef input, StringCRef output);
static void _Bind (GXScript::ScriptEnginePtr se);
};
} // ResPack
| 18.338983 | 80 | 0.735675 |
9f8afea1e1aa83dea22ffa85c44f155c1d2e84d6 | 2,524 | h | C | cores/arduino/USBMscHandler.h | Tophness/Arduino_Core_STM32 | d892359dfe4ab0140358ff389e1e8321c01f9119 | [
"Apache-2.0"
] | null | null | null | cores/arduino/USBMscHandler.h | Tophness/Arduino_Core_STM32 | d892359dfe4ab0140358ff389e1e8321c01f9119 | [
"Apache-2.0"
] | null | null | null | cores/arduino/USBMscHandler.h | Tophness/Arduino_Core_STM32 | d892359dfe4ab0140358ff389e1e8321c01f9119 | [
"Apache-2.0"
] | null | null | null | /*
Copyright (c) 2015 Arduino LLC. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _USB_MSC_HANDLER_H_
#define _USB_MSC_HANDLER_H_
#if defined(USBCON) && defined(USBD_USE_MSC_CLASS)
#include "usbd_core.h"
#include "usbd_msc.h"
/* Handler for mass storage devices */
class USBMscHandler {
public:
// Example: A 128 MB SD card has 245760 blocks, at a block size of 512 bytes
// Returns true if successful, otherwise false.
virtual bool GetCapacity(uint32_t *pBlockNum, uint16_t *pBlockSize) = 0;
// Read [blk_len] blocks, starting at [blk_addr] into [buf].
// Returns true if successful, otherwise false.
virtual bool Read(uint8_t *pBuf, uint32_t blkAddr, uint16_t blkLen) = 0;
// Write [blk_len] blocks, starting at [blk_addr] into [buf].
// Returns true if successful, otherwise false.
virtual bool Write(uint8_t *pBuf, uint32_t blkAddr, uint16_t blkLen) = 0;
/** Optional functions **/
virtual bool Init()
{
return true;
}
// Return false if the mass storage device has not been connected or initialized yet.
virtual bool IsReady()
{
return true;
}
// If the device should be read-only then this function should return true.
virtual bool IsWriteProtected()
{
return false;
}
};
class DummyUSBMscHandler : public USBMscHandler {
public:
// Any call to one of these functions always fails.
bool GetCapacity(uint32_t *pBlockNum, uint16_t *pBlockSize)
{
return false;
}
bool Read(uint8_t *pBuf, uint32_t blockAddr, uint16_t blkLen)
{
return false;
}
bool Write(uint8_t *pBuf, uint32_t blockAddr, uint16_t blkLen)
{
return false;
}
// The dummy handler is never ready.
bool IsReady()
{
return false;
}
};
#endif
#endif | 28.359551 | 89 | 0.697702 |
5881fbf93d4ff0a1bcd50e0993441dc55a4f8a28 | 341 | h | C | development/plot-var/plot-var.h | makamekm/genome | a951caa74dd38893e4b18a90a8a5ec432e33334c | [
"Apache-2.0"
] | null | null | null | development/plot-var/plot-var.h | makamekm/genome | a951caa74dd38893e4b18a90a8a5ec432e33334c | [
"Apache-2.0"
] | null | null | null | development/plot-var/plot-var.h | makamekm/genome | a951caa74dd38893e4b18a90a8a5ec432e33334c | [
"Apache-2.0"
] | null | null | null | #include <imgui.h>
namespace ImGui {
// Plot value over time
// Pass FLT_MAX value to draw without adding a new value
void PlotVar(const char* label, float value, float scale_min = FLT_MAX, float scale_max = FLT_MAX, size_t buffer_size = 120);
// Call this periodically to discard old/unused data
void PlotVarFlushOldEntries();
} | 34.1 | 127 | 0.741935 |
bf23a5d47e0c0ac520d8c4a9ce521a0ee6f42d8f | 10,411 | c | C | Userland/SampleCodeModule/shell.c | gprinc/RoundTwo | afec4b592b7fb1226338c5af7c4574cb1a0cbc8f | [
"BSD-3-Clause"
] | 1 | 2016-06-11T22:15:03.000Z | 2016-06-11T22:15:03.000Z | Userland/SampleCodeModule/shell.c | jcaracciolo/Arqui2016 | 180bbfd8cc657f2de72c5ec6a32912c0cadcf6c2 | [
"BSD-3-Clause"
] | null | null | null | Userland/SampleCodeModule/shell.c | jcaracciolo/Arqui2016 | 180bbfd8cc657f2de72c5ec6a32912c0cadcf6c2 | [
"BSD-3-Clause"
] | null | null | null | #include "include/shell.h"
#include "include/IPCstructs.h"
#include "types.h"
#include "include/stdio.h"
#include "include/strings.h"
#include "include/stdvid.h"
#include "include/stdtime.h"
#include "include/sw.h"
#include "include/gedit.h"
#include "include/paint.h"
#include "include/sync.h"
#include "include/philosophers.h"
#include "include/stdlib.h"
#include "include/prodCons.h"
#include "include/donPepito.h"
int rand=1;
const char* instructions =
" help - display all available commands\n\
func - print a simple message (completly useless)\n\
echo *param* - prints message on console\n\
clear - clears the screen\n\
time - get current system time\n\
setTimeZone *param* - set computer's time zone\n\
date - get current system date\n\
fractal Zelda - draws a triforce inspirated fractal\n\
multifractal - multipled colored fractals in a cool animation\n\
star wars - little star wars animation\n\
gedit - simple text editor\n\
paint - simple keyboard controlled paint\n\
paintBg *param* - paint the console background (only once)\n\
setupFont *param* - setup font to write\n\
ps - list all processes\n\
ipcs - list all open mutexes and pipes\n\
newps - create a useless process\n\
philo - simulation of philosophers problem\n\
prod - simulation of producer-consumer problem\n\
pepito - Don Pepito and Don Jose conversation\n\
isRunning *param* - check if a process is running\n\
fg *pid* - gives foreground to a custom process\n\
pacman clear *cant* - pacmans will help you to clear the screen\n\
kill *pid* *msg* - send a message to a process\n\
memory - Shows memory used\n";
extern void int80(qword rdi, qword rsi, qword rdx, qword rcx, qword r8, qword r9);
char screen[ROWS * COLS] = {0};
int screenIndex = 0;
char sbuffer[COLS + 1] = {0}; // + 1 to add '\0' at the end
char * shellBuffer;
int shellIndex = 0;
void initShell() {
//clearScreen();
printf("-- WELCOME THE SHELL --\n\n >>");
setTimeZone(-3);
setConsoleSize();
shellBuffer = sbuffer[0];
cleanBuffer();
while(1) {
int c = getc();
if (c != EOF) {
if (c == '\n') {
execute();
} else if (c == '\b') {
removeKey();
} else {
addToShellBuffer(c);
putc(c);
}
}
}
}
void clearScreen() {
clear();
shellIndex = 0;
}
void removeKey() {
if (shellIndex != 0) {
shellIndex--;
shellBuffer[shellIndex] = '\0';
; putc('\b');
}
}
void addToShellBuffer(char c) {
if (shellIndex <= COLS) {
shellBuffer[shellIndex++] = c;
}
}
void drawFractal() {
drawCFractalEquilateral(150,768,768,10,readData());
}
void drawFractalc() {
rand+=rand*3^getSeconds()*500;
drawCFractalEquilateral(150,768,768,9,rand);
}
void func() {
printf("execute!");
}
void printTime() {
printf("%d:%d\n", getHours(), getMinutes());
}
void printDate() {
printf("%d/%d/%d\n", getDay(), getMonth(), getYear());
}
/* pargs[1] -> tz */
void callSetTimeZone(int cargs, void ** pargs) {
int tz = pargs[1];
if(tz>=-12 && tz<=12) {
setTimeZone(tz);
printf("\nTime set correctly to GTM %d \n",tz);
} else{
printf("\nInput error\n");
}
}
void printInstructions() {
printf("%s\n", instructions);
}
void callRunGedit() {
runGedit();
}
void callPaintLoop() {
paintLoop();
}
/*
* parg[0]: process description
* parg[1]: color
*/
void paintBg(int carg, void ** pargs) {
drawCSquare(0,0,768,1024, pargs[1]);
setCursorPos(0);
}
/*
* parg[0]: process description
* parg[1]: font id
*/
void callChangeFont(int carg, void ** pargs) {
changeFont(pargs[1]);
}
/*
* parg[0]: process description
* parg[1]: msg
*/
void callEcho(int carg, void ** pargs) {
printf("%s",pargs[1]);
printf("\n");
}
/*
* pargs[0]: process description
* pargs[1]: pid
* pargs[2]: msg
*/
void callKill(int cargs, void ** pargs) {
kill(pargs[1], pargs[2]);
}
void multifractal(){
for(int i=0;i<50;i++) {
void** parg = (void**)malloc(sizeof(void*));
parg[0] = (void*)"colorfractal";
int pid = exec(&drawFractalc, 1, parg, 0);
sleep(500);
}
}
void uslessPs(){
printf("Dont mind me, im just gonna be here for a while");
while(1){
yield();
}
}
void printIPCs(){
ipcs ans;
int cantM;
int cantP;
ans.mutexNames=malloc(256* sizeof(*ans.mutexNames));
ans.pipesNames=malloc(256* sizeof(*ans.pipesNames));
for (int i = 0; i < 256; ++i) {
ans.mutexNames[i]=malloc(16);
ans.pipesNames[i]=malloc(16);
}
getIpcs(&ans,256,256,&cantM,&cantP);
printf("MUTEXES:\n");
for (int k = 0; k < cantM; ++k) {
printf(" %s\n",ans.mutexNames[k]);
}
printf("PIPES:\n");
for (int k = 0; k < cantP; ++k) {
printf(" %s\n",ans.pipesNames[k]);
}
for (int j = 0; j < 256 ; ++j) {
free(ans.mutexNames[j]);
free(ans.pipesNames[j]);
}
free(ans.mutexNames);
free(ans.pipesNames);
}
void execute() {
char arr[100] = {0};
int number = 0;
int tz;
sbuffer[shellIndex] = '\0';
int num, pidToKill, msg = 0, psToFg = 1;
putc('\n');
if(shellBuffer[0] == '&') {
psToFg = 0;
shellBuffer++;
}
if (strcmp(shellBuffer, "func") == 0) {
void** parg = (void**)malloc(sizeof(void*) * 2);
parg[0] = (void*)"func";
exec(&func, 1, parg, psToFg);
} else if (strcmp(shellBuffer, "clear") == 0) {
// void** parg = (void**)malloc(sizeof(void*));
// parg[0] = (void*)"clear";
// exec(&clearScreen, 1, parg, psToFg);
clear();
} else if(strcmp(shellBuffer, "time") == 0) {
void** parg = (void**)malloc(sizeof(void*));
parg[0] = (void*)"time";
exec(&printTime, 1, parg, psToFg);
} else if(strcmp(shellBuffer, "date") == 0) {
void** parg = (void**)malloc(sizeof(void*));
parg[0] = (void*)"date";
exec(&printDate, 1, parg, psToFg);
} else if(sscanf("setTimeZone %d",shellBuffer,&tz)==1) {
void** parg = (void**)malloc(sizeof(void*) * 2);
parg[0] = (void*)"setTimeZone";
parg[1] = (void*)tz;
exec(&callSetTimeZone, 2, parg, psToFg);
} else if(strcmp(shellBuffer, "fractal Zelda") == 0) {
void** parg = (void**)malloc(sizeof(void*));
parg[0] = (void*)"fractal";
clear();
int pid = exec(&drawFractal, 1, parg, psToFg);
//sleep(1000);
//clear();
} else if(strcmp(shellBuffer, "multifractal") == 0) {
clear();
void** parg = (void**)malloc(sizeof(void*) * 1);
parg[0] = (void*)"multifractal";
exec(&multifractal, 1, parg, psToFg);
} else if(sscanf("kill %d %d",shellBuffer,&pidToKill, &msg)==2){
void** parg = (void**)malloc(sizeof(void*) * 3);
parg[0] = (void*)"kill";
parg[1] = (void*)pidToKill;
parg[2] = (void*)msg;
exec(&callKill, 3, parg, psToFg);
} else if(strcmp(shellBuffer, "help") == 0) {
void** parg = (void**)malloc(sizeof(void*));
parg[0] = (void*)"help";
exec(&printInstructions, 1, parg, psToFg);
} else if(strcmp(shellBuffer, "star wars") == 0) {
void** parg = (void**)malloc(sizeof(void*));
parg[0] = (void*)"starwars";
exec(&playStarWars, 1, parg, psToFg);
} else if(strcmp(shellBuffer, "philo") == 0) {
if(isRunningSync("philoManager")) {
printf("Philo already running...\n");
}else{
void** parg = (void**)malloc(sizeof(void*));
parg[0] = (void*)"philoManager";
exec(&philosphers,1,parg, psToFg);
}
}else if(strcmp(shellBuffer, "prod") == 0) {
if(isRunningSync("prodConsManager")) {
printf("Producer-Consumer already running...\n");
}else{
void** parg = (void**)malloc(sizeof(void*));
parg[0] = (void*)"prodConsManager";
exec(&producerConsumer,1,parg, psToFg);
}
} else if(strcmp(shellBuffer, "gedit") == 0) {
void** parg = (void**)malloc(sizeof(void*));
parg[0] = (void*)"gedit";
exec(&callRunGedit, 1, parg, psToFg);
} else if(strcmp(shellBuffer, "paint") == 0) {
void** parg = (void**)malloc(sizeof(void*));
parg[0] = (void*)"paint";
exec(&callPaintLoop, 1, parg, psToFg);
} else if(sscanf("paintBg %d", shellBuffer, &num) == 1) {
void** parg = (void**)malloc(sizeof(void*) * 2);
parg[0] = (void*)"paintBg";
parg[1] = (void*)num;
exec(&paintBg, 2, parg, psToFg);
} else if(sscanf("setupFont %d", shellBuffer, &num) == 1) {
void** parg = (void**)malloc(sizeof(void*) * 2);
parg[0] = (void*)"setupFont";
parg[1] = (void*)num;
exec(callChangeFont, 2, parg, psToFg);
}else if(sscanf("echo %s",shellBuffer,arr)==1) {
// void** parg = (void**)malloc(sizeof(void*) * 2);
// parg[0] = (void*)"echo";
// parg[1] = (void*)arr;
// exec(&callEcho, 2, parg, psToFg);
printf("%s\n",arr);
} else if(strcmp(shellBuffer, "ps") == 0) {
void** parg = (void**)malloc(sizeof(void*));
parg[0] = (void*)"ps";
exec(&ps, 1, parg, psToFg);
} else if(strcmp(shellBuffer, "newps") == 0) {
void** parg = (void**)malloc(sizeof(void*));
parg[0] = (void*)"uslessPs";
exec(&uslessPs, 1,parg, psToFg);
} else if(strcmp(shellBuffer, "pepito") == 0) {
void** parg = (void**)malloc(sizeof(void*));
parg[0] = (void*)"PepitoJoseCreator";
exec(&pepitoJose, 1,parg, psToFg);
} else if(sscanf("pacman clear %d", shellBuffer, &num) == 1) {
if(num<1 || num>20)
printf("Number muste be between 1 and 20\n");
else
pacmanClear(num);
} else if(strcmp(shellBuffer, "ipcs") == 0) {
printIPCs();
} else if(sscanf("fg %i",shellBuffer, &num)==1) {
void** parg = (void**)malloc(sizeof(void*) * 3);
parg[0] = (void*)"giveForeground";
parg[1] = (void*)num;
parg[2] = (void*)3;
exec(&callKill, 3, parg, psToFg);
} else if(sscanf("isRunning %s",shellBuffer, arr)==1) {
char * array = malloc(strlen(arr)); // <---- Necesita hacer malloc si no el parámetro se pierde a veces en exec
strcpy(array, arr, 100);
void** parg = (void**)malloc(sizeof(void*) * 2);
parg[0] = (void*)"isRunning";
parg[1] = (void*)array;
exec(&isRunning, 2, parg, psToFg);
} else if(strcmp(shellBuffer, "memory") == 0) {
void** parg = (void**)malloc(sizeof(void*));
parg[0] = (void*)"MemoryUsed";
exec(&getMemoryUsed, 1, parg, psToFg);
free(parg);
} else {
printf("Command not found.\n");
}
if (psToFg == 0) {
shellBuffer--;
}
sleep(200);
printf(" >>");
cleanBuffer();
}
void cleanBuffer() {
int i;
for (i = 0; i < COLS + 1; i++) {
shellBuffer[i] = '\0';
}
shellIndex = 0;
}
| 25.89801 | 113 | 0.592642 |
f9694ac9c4d3aadd1bfa118684d4a5d4e6be2c1a | 533 | c | C | developments/boot/boot/src/script/system_script.c | kokabe2/surfes | 7c93fc08e74973cef53cf4a5859767201d457134 | [
"MIT"
] | null | null | null | developments/boot/boot/src/script/system_script.c | kokabe2/surfes | 7c93fc08e74973cef53cf4a5859767201d457134 | [
"MIT"
] | null | null | null | developments/boot/boot/src/script/system_script.c | kokabe2/surfes | 7c93fc08e74973cef53cf4a5859767201d457134 | [
"MIT"
] | null | null | null | // Copyright(c) 2019 Ken Okabe
// This software is released under the MIT License, see LICENSE.
#include "system_script.h"
#include <stddef.h>
static ISystemExecutorFactory its_factory = NULL;
void SystemScript_Create(ISystemExecutorFactory factory) {
its_factory = factory;
}
void SystemScript_Destroy(void) { its_factory = NULL; }
void SystemScript_Run(int runlevel) {
if (!its_factory) return;
ISystemExecutable se;
while ((se = its_factory->Make(runlevel)) != NULL) runlevel = se->Execute();
}
| 25.380952 | 79 | 0.718574 |
80737b9149ae6d3dbfccbdbec13fbdf5106a59f8 | 1,720 | h | C | src/sys/events/windowevent.h | AlkimiaStudios/alkahest-engine | f8ad44a78362e45361f9fc2b1ab17048537eeb82 | [
"Beerware"
] | null | null | null | src/sys/events/windowevent.h | AlkimiaStudios/alkahest-engine | f8ad44a78362e45361f9fc2b1ab17048537eeb82 | [
"Beerware"
] | null | null | null | src/sys/events/windowevent.h | AlkimiaStudios/alkahest-engine | f8ad44a78362e45361f9fc2b1ab17048537eeb82 | [
"Beerware"
] | null | null | null | #pragma once
#include "../../macros.h"
#include "event.h"
// Much of the early systems developed for AlkahestEngine were developed following
// along with the Game Engine series from The Cherno (Yan Chernikov) as he built
// the Hazel game engine. A future refactor of these systems is planned to
// eventually re-work this code to adapt it more closely to the direction the
// AlkahestEngine is heading. In the meantime, however, thank you to Yan for
// providing one of the most educational channels on YT when it comes to C++
// and OpenGL development.
//
// In compliance with the Hazel license, a copy of said license is available at
// {project_root}/.licenses/Hazel.LICENSE
//
// The code within this file has been modified from the original source, and
// this notice is provided in compliance with the above license terms.
namespace Alkahest
{
class API WindowResizeEvent : public Event
{
public:
WindowResizeEvent(int width, int height): m_Width(width), m_Height(height) {};
SETUP_EVENT_TYPE(WindowResize);
SETUP_EVENT_FLAGS(EventCategory::Window);
int getWidth() { return m_Width; }
int getHeight() { return m_Height; }
std::string toString() const override { return "WindowResizeEvent: (" + std::to_string(m_Width) + "x" + std::to_string(m_Height) + ")"; };
private:
// auto m_Window;
int m_Width, m_Height;
};
class API WindowCloseEvent : public Event
{
public:
WindowCloseEvent() {};
SETUP_EVENT_TYPE(WindowClose);
SETUP_EVENT_FLAGS(EventCategory::Window);
std::string toString() const override { return "WindowCloseEvent"; };
private:
// auto m_Window;
};
} | 37.391304 | 146 | 0.690698 |
57e7514c32bf8925d7c4902ac2564f12ab5eccb4 | 604 | h | C | cases/spherical_surfers/param/env/objects/surfer__us_1o0__surftimeconst_5o0__reorientationtime_2o5/choice.h | C0PEP0D/sheld0n | 497d4ee8b6b1815cd5fa1b378d1b947ee259f4bc | [
"MIT"
] | null | null | null | cases/spherical_surfers/param/env/objects/surfer__us_1o0__surftimeconst_5o0__reorientationtime_2o5/choice.h | C0PEP0D/sheld0n | 497d4ee8b6b1815cd5fa1b378d1b947ee259f4bc | [
"MIT"
] | null | null | null | cases/spherical_surfers/param/env/objects/surfer__us_1o0__surftimeconst_5o0__reorientationtime_2o5/choice.h | C0PEP0D/sheld0n | 497d4ee8b6b1815cd5fa1b378d1b947ee259f4bc | [
"MIT"
] | null | null | null | #ifndef C0P_PARAM_OBJECTS_SURFER__US_1O0__SURFTIMECONST_5O0__REORIENTATIONTIME_2O5_CHOICE_H
#define C0P_PARAM_OBJECTS_SURFER__US_1O0__SURFTIMECONST_5O0__REORIENTATIONTIME_2O5_CHOICE_H
#pragma once
// THIS FILE SHOULD NOT BE EDITED DIRECTLY BY THE USERS.
// THIS FILE WILL BE AUTOMATICALLY EDITED WHEN THE
// CHOOSE COMMAND IS USED
// choose your object
#include "param/env/objects/surfer__us_1o0__surftimeconst_5o0__reorientationtime_2o5/group/choice.h"
namespace c0p {
using SurferUs1O0Surftimeconst5O0Reorientationtime2O5Step = SurferUs1O0Surftimeconst5O0Reorientationtime2O5GroupStep;
}
#endif
| 37.75 | 121 | 0.869205 |
b938e1952761571e78465c3ccdefd81164074ee3 | 165 | h | C | context_proxies/unix/ipc_impl_unix.h | getdnsapi/libnss_getdns | a7b082083a437846b0f6704004fb221619449164 | [
"BSD-3-Clause"
] | 3 | 2016-08-08T22:20:59.000Z | 2018-11-24T20:00:21.000Z | context_proxies/unix/ipc_impl_unix.h | getdnsapi/libnss_getdns | a7b082083a437846b0f6704004fb221619449164 | [
"BSD-3-Clause"
] | null | null | null | context_proxies/unix/ipc_impl_unix.h | getdnsapi/libnss_getdns | a7b082083a437846b0f6704004fb221619449164 | [
"BSD-3-Clause"
] | 3 | 2016-04-07T11:55:20.000Z | 2021-09-24T15:28:18.000Z | // Copyright Verisign, Inc and NLNetLabs. See LICENSE file for details
#include "../../context_interface.h"
void ipc_unix_listen();
void ipc_unix_start_daemon();
| 23.571429 | 71 | 0.757576 |
5f7ca494f066d6f437289ebccf5344ab78bee83b | 5,204 | h | C | MODBUS/registerlist.h | Fance/BacnetThermostat | a478d80c5ce1d15d24418f315e760aa7cfc8f31e | [
"MIT"
] | 14 | 2018-02-28T11:29:07.000Z | 2022-01-24T16:57:00.000Z | MODBUS/registerlist.h | Fance/BacnetThermostat | a478d80c5ce1d15d24418f315e760aa7cfc8f31e | [
"MIT"
] | 1 | 2019-10-02T04:10:55.000Z | 2019-10-02T04:10:55.000Z | MODBUS/registerlist.h | Fance/BacnetThermostat | a478d80c5ce1d15d24418f315e760aa7cfc8f31e | [
"MIT"
] | 9 | 2018-03-07T16:11:04.000Z | 2020-09-26T08:02:54.000Z | #ifndef __REGISTERLIST_H
#define __REGISTERLIST_H
//typedef enum
//{
// EEP_SERIALNUMBER_LOWORD = 0,
// EEP_SERIALNUMBER_HIWORD = EEP_SERIALNUMBER_LOWORD + 2,
// EEP_VERSION_NUMBER_LO = EEP_SERIALNUMBER_HIWORD + 2,
// EEP_VERSION_NUMBER_HI,
// EEP_ADDRESS,
// EEP_PRODUCT_MODEL,
// EEP_HARDWARE_REV,
// EEP_PIC_VER,
// EEP_BASE_ADDRESS,
// EEP_UPDATE_STATUS = 16,
// EEP_SERIALNUMBER_WRITE_FLAG,
//
// EEP_BAUDRATE,
//} EEP_MAP;
//typedef enum
//{
// MODBUS_SERIALNUMBER_LOWORD = 0,
// MODBUS_SERIALNUMBER_HIWORD = 2,
// MODBUS_VERSION_NUMBER_LO = 4,
// MODBUS_VERSION_NUMBER_HI = 5,
// MODBUS_ADDRESS = 6,
// MODBUS_PRODUCT_MODEL,
// MODBUS_HARDWARE_REV,
// //MODBUS_PIC_VERSION,
// MODBUS_ADDRESS_PLUG_N_PLAY,
// MODBUS_BASE_ADDRESS = 15, // base address select
// MODBUS_UPDATE_STATUS = 16, // status for update flash
// MODBUS_SERINALNUMBER_WRITE_FLAG = 99,
//
//
//
// #ifdef T38AI8AO6DO
// MODBUS_AO_CHANNLE0 = 100,
// MODBUS_AO_CHANNLE1 = 101,
// MODBUS_AO_CHANNLE2 = 102,
// MODBUS_AO_CHANNLE3 = 103,
// MODBUS_AO_CHANNLE4 = 104,
// MODBUS_AO_CHANNLE5 = 105,
// MODBUS_AO_CHANNLE6 = 106,
// MODBUS_AO_CHANNLE7 = 107,
//
// MODBUS_DO_CHANNLE0 = 108,
// MODBUS_DO_CHANNLE1 = 109,
// MODBUS_DO_CHANNLE2 = 110,
// MODBUS_DO_CHANNLE3 = 111,
// MODBUS_DO_CHANNLE4 = 112,
// MODBUS_DO_CHANNLE5 = 113,
//
// MODBUS_SWITCH_BANK0 = 114,
// MODBUS_SWITCH_BANK1 = 115,
//
// MODBUS_AI_CHANNLE0 = 116 ,
// MODBUS_AI_CHANNLE1 = 117 ,
// MODBUS_AI_CHANNLE2 = 118 ,
// MODBUS_AI_CHANNLE3 = 119 ,
// MODBUS_AI_CHANNLE4 = 120 ,
// MODBUS_AI_CHANNLE5 = 121 ,
// MODBUS_AI_CHANNLE6 = 122 ,
// MODBUS_AI_CHANNLE7 = 123 ,
//
// MODBUS_AI_FILTER0 = 200 ,
// MODBUS_AI_FILTER1 = 201 ,
// MODBUS_AI_FILTER2 = 202 ,
// MODBUS_AI_FILTER3 = 203 ,
// MODBUS_AI_FILTER4 = 204 ,
// MODBUS_AI_FILTER5 = 205 ,
// MODBUS_AI_FILTER6 = 206 ,
// MODBUS_AI_FILTER7 = 207 ,
//
// MODBUS_AI_RANGE0 = 225,
// MODBUS_AI_RANGE1 = 226,
// MODBUS_AI_RANGE2 = 227,
// MODBUS_AI_RANGE3 = 228,
// MODBUS_AI_RANGE4 = 229,
// MODBUS_AI_RANGE5 = 230,
// MODBUS_AI_RANGE6 = 231,
// MODBUS_AI_RANGE7 = 232,
// MODBUS_AI_RANGE8 = 233,
//
// MODBUS_AI_OFFSET0 = 250 ,
// MODBUS_AI_OFFSET1 = 251 ,
// MODBUS_AI_OFFSET2 = 252 ,
// MODBUS_AI_OFFSET3 = 253 ,
// MODBUS_AI_OFFSET4 = 254 ,
// MODBUS_AI_OFFSET5 = 255 ,
// MODBUS_AI_OFFSET6 = 256 ,
// MODBUS_AI_OFFSET7 = 257 ,
// #elif T322AI
// MODBUS_AI_CHANNLE0 = 100 ,
// MODBUS_AI_CHANNLE1 = 101 ,
// MODBUS_AI_CHANNLE2 = 102 ,
// MODBUS_AI_CHANNLE3 = 103 ,
// MODBUS_AI_CHANNLE4 = 104 ,
// MODBUS_AI_CHANNLE5 = 105 ,
// MODBUS_AI_CHANNLE6 = 106 ,
// MODBUS_AI_CHANNLE7 = 107 ,
// MODBUS_AI_CHANNLE8 = 108 ,
// MODBUS_AI_CHANNLE9 = 109 ,
// MODBUS_AI_CHANNLE10 = 110 ,
// MODBUS_AI_CHANNLE11 = 111 ,
// MODBUS_AI_CHANNLE12 = 112 ,
// MODBUS_AI_CHANNLE13 = 113 ,
// MODBUS_AI_CHANNLE14 = 114 ,
// MODBUS_AI_CHANNLE15 = 115 ,
// MODBUS_AI_CHANNLE16 = 116 ,
// MODBUS_AI_CHANNLE17 = 117 ,
// MODBUS_AI_CHANNLE18 = 118 ,
// MODBUS_AI_CHANNLE19 = 119 ,
// MODBUS_AI_CHANNLE20 = 120 ,
// MODBUS_AI_CHANNLE21 = 121 ,
//
// MODBUS_AI_FILTER0 = 200 ,
// MODBUS_AI_FILTER1 = 201 ,
// MODBUS_AI_FILTER2 = 202 ,
// MODBUS_AI_FILTER3 = 203 ,
// MODBUS_AI_FILTER4 = 204 ,
// MODBUS_AI_FILTER5 = 205 ,
// MODBUS_AI_FILTER6 = 206 ,
// MODBUS_AI_FILTER7 = 207 ,
// MODBUS_AI_FILTER8 = 208 ,
// MODBUS_AI_FILTER9 = 209 ,
// MODBUS_AI_FILTER10 = 210 ,
// MODBUS_AI_FILTER11 = 211 ,
// MODBUS_AI_FILTER12 = 212 ,
// MODBUS_AI_FILTER13 = 213 ,
// MODBUS_AI_FILTER14 = 214 ,
// MODBUS_AI_FILTER15 = 215 ,
// MODBUS_AI_FILTER16 = 216 ,
// MODBUS_AI_FILTER17 = 217 ,
// MODBUS_AI_FILTER18 = 218 ,
// MODBUS_AI_FILTER19 = 219 ,
// MODBUS_AI_FILTER20 = 220 ,
// MODBUS_AI_FILTER21 = 221 ,
//
// MODBUS_AI_RANGE0 = 225,
// MODBUS_AI_RANGE1 = 226,
// MODBUS_AI_RANGE2 = 227,
// MODBUS_AI_RANGE3 = 228,
// MODBUS_AI_RANGE4 = 229,
// MODBUS_AI_RANGE5 = 230,
// MODBUS_AI_RANGE6 = 231,
// MODBUS_AI_RANGE7 = 232,
// MODBUS_AI_RANGE8 = 233,
// MODBUS_AI_RANGE9 = 234,
// MODBUS_AI_RANGE10 = 235,
// MODBUS_AI_RANGE11 = 236,
// MODBUS_AI_RANGE12 = 237,
// MODBUS_AI_RANGE13 = 238,
// MODBUS_AI_RANGE14 = 239,
// MODBUS_AI_RANGE15 = 240,
// MODBUS_AI_RANGE16 = 241,
// MODBUS_AI_RANGE17 = 242,
// MODBUS_AI_RANGE18 = 243,
// MODBUS_AI_RANGE19 = 244,
// MODBUS_AI_RANGE20 = 245,
// MODBUS_AI_RANGE21 = 246,
//
// MODBUS_AI_OFFSET0 = 250 ,
// MODBUS_AI_OFFSET1 = 251 ,
// MODBUS_AI_OFFSET2 = 252 ,
// MODBUS_AI_OFFSET3 = 253 ,
// MODBUS_AI_OFFSET4 = 254 ,
// MODBUS_AI_OFFSET5 = 255 ,
// MODBUS_AI_OFFSET6 = 256 ,
// MODBUS_AI_OFFSET7 = 257 ,
// MODBUS_AI_OFFSET8 = 258 ,
// MODBUS_AI_OFFSET9 = 259 ,
// MODBUS_AI_OFFSET10 = 260 ,
// MODBUS_AI_OFFSET11 = 261 ,
// MODBUS_AI_OFFSET12 = 262 ,
// MODBUS_AI_OFFSET13 = 263 ,
// MODBUS_AI_OFFSET14 = 264 ,
// MODBUS_AI_OFFSET15 = 265 ,
// MODBUS_AI_OFFSET16 = 266 ,
// MODBUS_AI_OFFSET17 = 267 ,
// MODBUS_AI_OFFSET18 = 268 ,
// MODBUS_AI_OFFSET19 = 269 ,
// MODBUS_AI_OFFSET20 = 270 ,
// MODBUS_AI_OFFSET21 = 271 ,
// #endif
//
//
//
//
//
//
//
//
//
//}
//MODBUS_REGISTER_LIST;
#endif
| 24.317757 | 58 | 0.675442 |
e0e30389bfa6bc1aeed5e0e3791d9c07b09533d8 | 366 | h | C | HuaTRefresh/Classes/HuaTRefresh/UIImage+MHHome.h | XMiHu/HuaTRefresh | 2ab70e3733f0625421a5363e5084e6e5b0e4fd30 | [
"MIT"
] | null | null | null | HuaTRefresh/Classes/HuaTRefresh/UIImage+MHHome.h | XMiHu/HuaTRefresh | 2ab70e3733f0625421a5363e5084e6e5b0e4fd30 | [
"MIT"
] | null | null | null | HuaTRefresh/Classes/HuaTRefresh/UIImage+MHHome.h | XMiHu/HuaTRefresh | 2ab70e3733f0625421a5363e5084e6e5b0e4fd30 | [
"MIT"
] | null | null | null | //
// UIImage+MHHome.h
// HuaTRefresh
//
// Created by MiHu on 2018/4/27.
//
#import <UIKit/UIKit.h>
@interface UIImage (MHHome)
/**
获取图片的路径
@param imageName 图片的名字
@param bundle bundel
@param targetClass 调用的Class
@return 返回图片
*/
+ (instancetype)ff_imagePathWithName:(NSString *)imageName bundle:(NSString *)bundle targetClass:(Class)targetClass;
@end
| 15.25 | 116 | 0.715847 |
043ffd86293db4b1ae5d257fa487634581d34f76 | 5,845 | c | C | osprey/common/util/c_q_sqrt.c | sharugupta/OpenUH | daddd76858a53035f5d713f648d13373c22506e8 | [
"BSD-2-Clause"
] | null | null | null | osprey/common/util/c_q_sqrt.c | sharugupta/OpenUH | daddd76858a53035f5d713f648d13373c22506e8 | [
"BSD-2-Clause"
] | null | null | null | osprey/common/util/c_q_sqrt.c | sharugupta/OpenUH | daddd76858a53035f5d713f648d13373c22506e8 | [
"BSD-2-Clause"
] | null | null | null | /*
Copyright (C) 2000, 2001 Silicon Graphics, Inc. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it
under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation.
This program is distributed in the hope that it would be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Further, this software is distributed without any warranty that it is
free of the rightful claim of any third person regarding infringement
or the like. Any license provided herein, whether implied or
otherwise, applies only to this software file. Patent licenses, if
any, provided herein do not apply to combinations of this program with
other software, or any other product whatsoever.
You should have received a copy of the GNU General Public License along
with this program; if not, write the Free Software Foundation, Inc., 59
Temple Place - Suite 330, Boston MA 02111-1307, USA.
Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky,
Mountain View, CA 94043, or:
http://www.sgi.com
For further information regarding this notice, see:
http://oss.sgi.com/projects/GenInfo/NoticeExplan
*/
/* =======================================================================
* =======================================================================
*
* Module: c_q_sqrt.c
* $Revision$
* $Date$
* $Author$
* $Source$
*
* =======================================================================
* =======================================================================
*/
#ifndef _LP64
#include <sgidefs.h>
#endif /* _LP64 */
#include <math.h>
#include "defs.h"
#include "quad.h"
/* quad square root */
/* note that this routine must be kept in sync with the corresponding libm
* routine, qsqrt.
*/
typedef union
{
struct
{
UINT32 hi;
UINT32 lo;
} word;
double d;
} du;
#ifndef __MATH_H__
double sqrt(double);
#if _MIPS_ISA != _MIPS_ISA_MIPS1
#pragma intrinsic (sqrt)
#endif
#endif /* __MATH_H__ */
static double __dtwofloor(double);
/* const1 is 1.0 + 2^(53 - 53/2), i.e. 1.0 + 2^27 */
static const du const1 =
{0x41a00000, 0x02000000};
static const du twopm53 =
{0x3ca00000, 0x00000000};
static const du twopm54 =
{0x3c900000, 0x00000000};
static const du twopm6 =
{0x3f900000, 0x00000000};
static const du twop3 =
{0x40200000, 0x00000000};
static const du twop108 =
{0x46b00000, 0x00000000};
#if defined(BUILD_OS_DARWIN)
/* Can't use "pragma weak" to create aliases in Mach-O */
QUAD c_q_sqrt(QUAD x, INT *p_err );
QUAD __c_q_sqrt(QUAD x, INT *p_err ) { return c_q_sqrt(x, p_err); }
#else /* defined(BUILD_OS_DARWIN) */
#pragma weak c_q_sqrt = __c_q_sqrt
#define c_q_sqrt __c_q_sqrt
#endif /* defined(BUILD_OS_DARWIN) */
QUAD
c_q_sqrt(QUAD x, INT *p_err )
{
INT64 ix, xpt;
INT32 n;
double xfactor;
double w;
double quarterulp;
double p;
double hc, tc;
QUAD c;
QUAD u, z;
/* adapted from T. J. Dekker's sqrt2 subroutine */
*p_err = 0;
/* extract exponent of x for some quick screening */
DBL2LL(x.hi, ix);
xpt = (ix >> DMANTWIDTH);
xpt &= 0x7ff;
if ( ix < 0 )
{
z.hi = sqrt(x.hi);
z.lo = 0.0;
return ( z );
}
/* Avoid underflows and overflows in forming the products
c.hi*const1.d, c.hi*c.hi, and hc*hc by scaling if
necessary. x should also be scaled if tc*tc is
a denormal.
*/
if ( (0x06d < xpt) && (xpt < 0x7fb) )
{
/* normal case */
c.hi = sqrt(x.hi);
/*u.ld = _prodl(c.hi, c.hi);*/
p = c.hi*const1.d;
hc = (c.hi - p) + p;
tc = c.hi - hc;
u.hi = c.hi*c.hi;
u.lo = ((((hc*hc - u.hi) + hc*tc) + hc*tc) + tc*tc);
c.lo = 0.5*(((x.hi - u.hi) - u.lo) + x.lo)/c.hi;
/* if necessary, round c.lo so that the sum of c.hi and c.lo
has at most 107 significant bits
*/
/* Compute a quarter ulp of c.hi */
DBL2LL(c.hi, ix);
ix >>= DMANTWIDTH;
ix <<= DMANTWIDTH;
LL2DBL(ix, w); /* w = dtwofloor(c.hi) */
/* Note that the size of an ulp changes at a
* power of two.
*/
if ( (c.hi == w) && (c.lo < 0.0) )
w *= 0.5;
/* round c.lo if it's less than 1/4 ulp of w */
quarterulp = twopm54.d*fabs(w);
if ( fabs(c.lo) < quarterulp )
{
if ( c.lo >= 0.0 )
{
c.lo = (quarterulp + c.lo) - quarterulp;
}
else
{
c.lo = quarterulp + (c.lo - quarterulp);
}
}
z.hi = c.hi + c.lo;
z.lo = (c.hi - z.hi) + c.lo;
return ( z );
}
if ( xpt < 0x7ff )
{
if ( x.hi == 0.0 )
{
z.lo = 0.0;
z.hi = x.hi;
return ( z );
}
if ( xpt <= 0x06d )
{
x.hi *= twop108.d;
x.lo *= twop108.d;
xfactor = twopm54.d;
}
else
{
x.hi *= twopm6.d;
x.lo *= twopm6.d;
xfactor = twop3.d;
}
c.hi = sqrt(x.hi);
/*u.ld = _prodl(c.hi, c.hi);*/
p = c.hi*const1.d;
hc = (c.hi - p) + p;
tc = c.hi - hc;
u.hi = c.hi*c.hi;
u.lo = ((((hc*hc - u.hi) + hc*tc) + hc*tc) + tc*tc);
c.lo = 0.5*(((x.hi - u.hi) - u.lo) + x.lo)/c.hi;
/* if necessary, round c.lo so that the sum of c.hi and c.lo
has at most 107 significant bits
*/
/* Compute a quarter ulp of c.hi */
DBL2LL(c.hi, ix);
ix >>= DMANTWIDTH;
ix <<= DMANTWIDTH;
LL2DBL(ix, w); /* w = dtwofloor(c.hi) */
/* Note that the size of an ulp changes at a
* power of two.
*/
if ( (c.hi == w) && (c.lo < 0.0) )
w *= 0.5;
/* round c.lo if it's less than 1/4 ulp of w */
quarterulp = twopm54.d*fabs(w);
if ( fabs(c.lo) < quarterulp )
{
if ( c.lo >= 0.0 )
{
c.lo = (quarterulp + c.lo) - quarterulp;
}
else
{
c.lo = quarterulp + (c.lo - quarterulp);
}
}
c.hi *= xfactor;
c.lo *= xfactor;
z.hi = c.hi + c.lo;
z.lo = (c.hi - z.hi) + c.lo;
return ( z );
}
z.lo = 0.0;
z.hi = sqrt(x.hi);
return ( z );
}
| 19.680135 | 74 | 0.574337 |
a41cfefea30ce71c802a9031ca1dfd7277883bee | 414 | h | C | cppLearningExercises/GeometricObject.h | QueeniePun/cppLearningExercises | 4c4181573d1b7de9f67acdea1b0fd6d2245b8806 | [
"MIT"
] | null | null | null | cppLearningExercises/GeometricObject.h | QueeniePun/cppLearningExercises | 4c4181573d1b7de9f67acdea1b0fd6d2245b8806 | [
"MIT"
] | null | null | null | cppLearningExercises/GeometricObject.h | QueeniePun/cppLearningExercises | 4c4181573d1b7de9f67acdea1b0fd6d2245b8806 | [
"MIT"
] | null | null | null | #ifndef GEOMETRICOBJECT_H
#define GEOMETRICOBJECT_H
#include <string>
using namespace std;
class GeometricObject
{
public:
GeometricObject();
GeometricObject(const string& color, bool filled);
string getColor() const;
void setColor(const string& color);
bool isFilled() const;
void setFilled(bool filled);
string toString() const;
private:
string color;
bool filled;
};
#endif | 19.714286 | 54 | 0.717391 |
f2df573987ce340fa32704078b6d63f12494df4b | 1,276 | c | C | G/03/12/task1.c | elsys/po-2015 | 28d352ab8d7d4eb55620b01f9176f8e3f6838744 | [
"MIT"
] | 27 | 2015-09-28T19:47:23.000Z | 2016-07-25T15:17:32.000Z | G/03/12/task1.c | elsys/po-2015 | 28d352ab8d7d4eb55620b01f9176f8e3f6838744 | [
"MIT"
] | 391 | 2015-09-28T05:57:05.000Z | 2016-06-09T16:43:53.000Z | G/03/12/task1.c | elsys/po-2015 | 28d352ab8d7d4eb55620b01f9176f8e3f6838744 | [
"MIT"
] | 351 | 2015-06-29T17:17:31.000Z | 2016-05-04T17:57:14.000Z | #include <stdio.h>
#include <string.h>
int main(){
char arr[12];
int egn[10];
int counter;
int month = 0;
int days = 0;
int helper;
scanf("%s", arr);
if(strlen(arr) != 10){
printf("0");
return 0;
}
counter = 0;
for(; counter < 10; counter++){
egn[counter] = (arr[counter] - 48);
}
month = egn[2]*10 + egn[3];
days = egn[4]*10 + egn[5];
if(month%20 <= 12 && month/20 >=0 && month/20 <= 2){
if((month%20 == 4 || month%20 == 6 || month%20 == 9 || month%20 == 11) && days > 30){
printf("0");
return 0;
}
if((month%20 == 1 || month%20 == 3 || month%20 == 5 || month%20 == 7 || month%20 == 8 || month%20 == 10 || month%20 == 12) && days > 31){
printf("0");
return 0;
}
if(month%20 == 2 && days > 29){
printf("0");
return 0;
}
}else{
printf("0");
return 0;
}
helper = ((egn[0]*2) + (egn[1]*4) + (egn[2]*8) + (egn[3]*5) + (egn[4]*10) + (egn[5]*9) + (egn[6]*7) + (egn [7]*3) + (egn[8]*6))%11;
if(egn[9] != helper){
printf("0"); return 0;
}else{
printf("1");
}
return 0;
}
| 22 | 145 | 0.398903 |
925dc1a9a204f092fdc8c6db42e3b8e3fff10747 | 3,027 | h | C | Assignment5/ArrayList.h | stephe00/DataStructs260 | 931fc728ba184c7f19548579ec8254e4ed507b3a | [
"CC0-1.0"
] | null | null | null | Assignment5/ArrayList.h | stephe00/DataStructs260 | 931fc728ba184c7f19548579ec8254e4ed507b3a | [
"CC0-1.0"
] | null | null | null | Assignment5/ArrayList.h | stephe00/DataStructs260 | 931fc728ba184c7f19548579ec8254e4ed507b3a | [
"CC0-1.0"
] | null | null | null | #include <cstdlib>
#include <iostream>
using std::cout;
using std::endl;
#define MAX 10
template <class T>
class ArrayList
{
private:
T myList[MAX];
int topIndex;
public:
ArrayList();
void addItem(T newValue);
void deleteItem(T deleteData);
void printList();
};
template <class T>
ArrayList<T>::ArrayList() // Total: O(2n+1)
{
topIndex = -1; // O(1)
/*
// Initialze the array with NULL values
for (int i = 0; i < MAX; i++) // O(2n)
{
myList[i] = NULL; // O(n)
}
*/
}
template <class T>
void ArrayList<T>::addItem(T newValue) // Total (worst case): O(4n+4)
{
int insertIndex = 0;
// If the array is empty
if (topIndex < 0) // O(1)
{
// Add item to the empty list
topIndex++; // O(1)
myList[topIndex] = newValue; // O(1)
return; // O(1)
}
// If the array is full
else if (topIndex >= MAX-1)
{
cout << "The list is full!" << endl; // O(1)
return; // O(1)
}
else
{
// Travel through the list and find the existing
// value that is bigger than the value I am trying to add
while (newValue > myList[insertIndex] && insertIndex <= topIndex) // O(2n)
{
insertIndex++;
}
// Shift all items in the list up to make space for the new item
if (topIndex != 0)
{
topIndex++; // O(1)
for (int i = topIndex; i > insertIndex; i--) // O(2n)
{
myList[i] = myList[i-1]; // O(n)
}
// Place new item in its spot
myList[insertIndex] = newValue; // O(1)
}
// Special case where second element added is smaller than first
else
{
topIndex++;
myList[topIndex] = myList[topIndex-1];
myList[insertIndex] = newValue;
}
}
}
template <class T>
void ArrayList<T>::deleteItem(T deleteData) // Total (worst case): O(6n+4)
{
int listIndex = topIndex; // O(1)
// Seach backwards through the list for the item I want to delete
while (listIndex >= 0) // O(n)
{
if (myList[listIndex] != deleteData) // O(n)
{
listIndex--; // O(n)
}
else
{
topIndex--; // O(1)
break; // O(1)
}
}
// Run back up the list and shift all items over to fill the gap
while (listIndex <= topIndex) // O(n)
{
myList[listIndex] = myList[listIndex + 1]; // O(n)
listIndex++; // O(n)
}
// Remove copy of last item in list from index beyond topIndex
//myList[listIndex+1] = NULL; // O(1)
}
template <class T>
void ArrayList<T>::printList() // Total (worst case): O(2n)
{
for (int i = 0; i <= topIndex; i++) // O(n)
{
cout << myList[i] << endl; // O(n)
}
}
| 24.609756 | 83 | 0.484969 |
fac34e13c2c5fcf5874e640038f1e1fa1d9476f6 | 254 | c | C | kernel/kmain.c | tesla1889/osdev | 0f4c4867f5fc08e4ad35d56c1bb75597b9b0cbb1 | [
"MIT"
] | null | null | null | kernel/kmain.c | tesla1889/osdev | 0f4c4867f5fc08e4ad35d56c1bb75597b9b0cbb1 | [
"MIT"
] | null | null | null | kernel/kmain.c | tesla1889/osdev | 0f4c4867f5fc08e4ad35d56c1bb75597b9b0cbb1 | [
"MIT"
] | null | null | null | /*
kernel/kmain.c
Copyright (C) 2017 Nick Trebes
MIT License (MIT)
*/
#include <integer.h>
#include "vga.h"
extern uint32_t ksize __asm__("_ksize");
void kmain() {
ksize = ((ksize >> 12) + 1);
vga_init();
vga_puts("Success!\n");
for (;;) {}
} | 13.368421 | 40 | 0.614173 |
4d70c2945760d05e47d408bb7381aa88726663e2 | 1,192 | h | C | runtime-src/Classes/FFmpegVideoPlayer.h | shiniu0606/cocos_socket | 2c460a6b42a94c95d8413fe94d4a24afbbaf8788 | [
"MIT"
] | null | null | null | runtime-src/Classes/FFmpegVideoPlayer.h | shiniu0606/cocos_socket | 2c460a6b42a94c95d8413fe94d4a24afbbaf8788 | [
"MIT"
] | null | null | null | runtime-src/Classes/FFmpegVideoPlayer.h | shiniu0606/cocos_socket | 2c460a6b42a94c95d8413fe94d4a24afbbaf8788 | [
"MIT"
] | null | null | null | #ifndef __CFFMPEG_VIDEO_PLAYER_H__
#define __CFFMPEG_VIDEO_PLAYER_H__
#include "cocos2d.h"
#include "ui/CocosGUI.h"
#include <vector>
USING_NS_CC;
using namespace ui;
using namespace std;
class AVPicture;
class AVFormatContext;
class AVCodecContext;
class AVCodec;
class AVPacket;
class AVFrame;
class SwsContext;
class CFFmpegVideoPlayer :
public Sprite
{
public:
CFFmpegVideoPlayer();
virtual ~CFFmpegVideoPlayer();
static CFFmpegVideoPlayer* create(const char * filename, int width, int height, bool bLoop = true);
bool init(const char * filename, int width, int height, bool bLoop = true);
void play();
void stop();
private:
void updateTimer(float dt);
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
private:
bool m_bLoop;
Size m_videoSize;
Size m_videoDisplaySize;
float m_fDtPlay;
AVPicture * m_pAvpicture;
AVFormatContext * m_pFormatCtx;
AVCodecContext * m_pCodecCtx;
const AVCodec * m_codec;
AVFrame * m_pFrame;
SwsContext * m_img_convert_ctx;
int videoIndex;
};
int register_all_CFFmpegVideoPlayer(lua_State* tolua_S);
#endif // __CFFMPEG_VIDEO_PLAYER_H__
| 21.285714 | 101 | 0.744128 |
9e80c37c4bd1659097c81b66982b8caec422c85d | 24,833 | c | C | freebsd4/sys/contrib/dev/acpica/dswexec.c | MarginC/kame | 2ef74fe29e4cca9b4a87a1d5041191a9e2e8be30 | [
"BSD-3-Clause"
] | 91 | 2015-01-05T15:18:31.000Z | 2022-03-11T16:43:28.000Z | freebsd4/sys/contrib/dev/acpica/dswexec.c | MarginC/kame | 2ef74fe29e4cca9b4a87a1d5041191a9e2e8be30 | [
"BSD-3-Clause"
] | 1 | 2016-02-25T15:57:55.000Z | 2016-02-25T16:01:02.000Z | freebsd4/sys/contrib/dev/acpica/dswexec.c | MarginC/kame | 2ef74fe29e4cca9b4a87a1d5041191a9e2e8be30 | [
"BSD-3-Clause"
] | 21 | 2015-02-07T08:23:07.000Z | 2021-12-14T06:01:49.000Z | /******************************************************************************
*
* Module Name: dswexec - Dispatcher method execution callbacks;
* dispatch to interpreter.
* $Revision: 98 $
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2003, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* Code in any form, with the right to sublicense such rights; and
*
* 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
* license (with the right to sublicense), under only those claims of Intel
* patents that are infringed by the Original Intel Code, to make, use, sell,
* offer to sell, and import the Covered Code and derivative works thereof
* solely to the minimum extent necessary to exercise the above copyright
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************/
#define __DSWEXEC_C__
#include "acpi.h"
#include "acparser.h"
#include "amlcode.h"
#include "acdispat.h"
#include "acinterp.h"
#include "acnamesp.h"
#include "acdebug.h"
#define _COMPONENT ACPI_DISPATCHER
ACPI_MODULE_NAME ("dswexec")
/*
* Dispatch table for opcode classes
*/
static ACPI_EXECUTE_OP AcpiGbl_OpTypeDispatch [] = {
AcpiExOpcode_1A_0T_0R,
AcpiExOpcode_1A_0T_1R,
AcpiExOpcode_1A_1T_0R,
AcpiExOpcode_1A_1T_1R,
AcpiExOpcode_2A_0T_0R,
AcpiExOpcode_2A_0T_1R,
AcpiExOpcode_2A_1T_1R,
AcpiExOpcode_2A_2T_1R,
AcpiExOpcode_3A_0T_0R,
AcpiExOpcode_3A_1T_1R,
AcpiExOpcode_6A_0T_1R};
/*****************************************************************************
*
* FUNCTION: AcpiDsGetPredicateValue
*
* PARAMETERS: WalkState - Current state of the parse tree walk
*
* RETURN: Status
*
* DESCRIPTION: Get the result of a predicate evaluation
*
****************************************************************************/
ACPI_STATUS
AcpiDsGetPredicateValue (
ACPI_WALK_STATE *WalkState,
ACPI_OPERAND_OBJECT *ResultObj)
{
ACPI_STATUS Status = AE_OK;
ACPI_OPERAND_OBJECT *ObjDesc;
ACPI_FUNCTION_TRACE_PTR ("DsGetPredicateValue", WalkState);
WalkState->ControlState->Common.State = 0;
if (ResultObj)
{
Status = AcpiDsResultPop (&ObjDesc, WalkState);
if (ACPI_FAILURE (Status))
{
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Could not get result from predicate evaluation, %s\n",
AcpiFormatException (Status)));
return_ACPI_STATUS (Status);
}
}
else
{
Status = AcpiDsCreateOperand (WalkState, WalkState->Op, 0);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
Status = AcpiExResolveToValue (&WalkState->Operands [0], WalkState);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
ObjDesc = WalkState->Operands [0];
}
if (!ObjDesc)
{
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No predicate ObjDesc=%p State=%p\n",
ObjDesc, WalkState));
return_ACPI_STATUS (AE_AML_NO_OPERAND);
}
/*
* Result of predicate evaluation currently must
* be a number
*/
if (ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_INTEGER)
{
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Bad predicate (not a number) ObjDesc=%p State=%p Type=%X\n",
ObjDesc, WalkState, ACPI_GET_OBJECT_TYPE (ObjDesc)));
Status = AE_AML_OPERAND_TYPE;
goto Cleanup;
}
/* Truncate the predicate to 32-bits if necessary */
AcpiExTruncateFor32bitTable (ObjDesc);
/*
* Save the result of the predicate evaluation on
* the control stack
*/
if (ObjDesc->Integer.Value)
{
WalkState->ControlState->Common.Value = TRUE;
}
else
{
/*
* Predicate is FALSE, we will just toss the
* rest of the package
*/
WalkState->ControlState->Common.Value = FALSE;
Status = AE_CTRL_FALSE;
}
Cleanup:
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Completed a predicate eval=%X Op=%p\n",
WalkState->ControlState->Common.Value, WalkState->Op));
/* Break to debugger to display result */
ACPI_DEBUGGER_EXEC (AcpiDbDisplayResultObject (ObjDesc, WalkState));
/*
* Delete the predicate result object (we know that
* we don't need it anymore)
*/
AcpiUtRemoveReference (ObjDesc);
WalkState->ControlState->Common.State = ACPI_CONTROL_NORMAL;
return_ACPI_STATUS (Status);
}
/*****************************************************************************
*
* FUNCTION: AcpiDsExecBeginOp
*
* PARAMETERS: WalkState - Current state of the parse tree walk
* OutOp - Return op if a new one is created
*
* RETURN: Status
*
* DESCRIPTION: Descending callback used during the execution of control
* methods. This is where most operators and operands are
* dispatched to the interpreter.
*
****************************************************************************/
ACPI_STATUS
AcpiDsExecBeginOp (
ACPI_WALK_STATE *WalkState,
ACPI_PARSE_OBJECT **OutOp)
{
ACPI_PARSE_OBJECT *Op;
ACPI_STATUS Status = AE_OK;
UINT32 OpcodeClass;
ACPI_FUNCTION_TRACE_PTR ("DsExecBeginOp", WalkState);
Op = WalkState->Op;
if (!Op)
{
Status = AcpiDsLoad2BeginOp (WalkState, OutOp);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
Op = *OutOp;
WalkState->Op = Op;
WalkState->Opcode = Op->Common.AmlOpcode;
WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
if (AcpiNsOpensScope (WalkState->OpInfo->ObjectType))
{
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s) Popping scope for Op %p\n",
AcpiUtGetTypeName (WalkState->OpInfo->ObjectType), Op));
Status = AcpiDsScopeStackPop (WalkState);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
}
}
if (Op == WalkState->Origin)
{
if (OutOp)
{
*OutOp = Op;
}
return_ACPI_STATUS (AE_OK);
}
/*
* If the previous opcode was a conditional, this opcode
* must be the beginning of the associated predicate.
* Save this knowledge in the current scope descriptor
*/
if ((WalkState->ControlState) &&
(WalkState->ControlState->Common.State ==
ACPI_CONTROL_CONDITIONAL_EXECUTING))
{
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Exec predicate Op=%p State=%p\n",
Op, WalkState));
WalkState->ControlState->Common.State = ACPI_CONTROL_PREDICATE_EXECUTING;
/* Save start of predicate */
WalkState->ControlState->Control.PredicateOp = Op;
}
OpcodeClass = WalkState->OpInfo->Class;
/* We want to send namepaths to the load code */
if (Op->Common.AmlOpcode == AML_INT_NAMEPATH_OP)
{
OpcodeClass = AML_CLASS_NAMED_OBJECT;
}
/*
* Handle the opcode based upon the opcode type
*/
switch (OpcodeClass)
{
case AML_CLASS_CONTROL:
Status = AcpiDsResultStackPush (WalkState);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
Status = AcpiDsExecBeginControlOp (WalkState, Op);
break;
case AML_CLASS_NAMED_OBJECT:
if (WalkState->WalkType == ACPI_WALK_METHOD)
{
/*
* Found a named object declaration during method
* execution; we must enter this object into the
* namespace. The created object is temporary and
* will be deleted upon completion of the execution
* of this method.
*/
Status = AcpiDsLoad2BeginOp (WalkState, NULL);
}
if (Op->Common.AmlOpcode == AML_REGION_OP)
{
Status = AcpiDsResultStackPush (WalkState);
}
break;
case AML_CLASS_EXECUTE:
case AML_CLASS_CREATE:
/* most operators with arguments */
/* Start a new result/operand state */
Status = AcpiDsResultStackPush (WalkState);
break;
default:
break;
}
/* Nothing to do here during method execution */
return_ACPI_STATUS (Status);
}
/*****************************************************************************
*
* FUNCTION: AcpiDsExecEndOp
*
* PARAMETERS: WalkState - Current state of the parse tree walk
* Op - Op that has been just been completed in the
* walk; Arguments have now been evaluated.
*
* RETURN: Status
*
* DESCRIPTION: Ascending callback used during the execution of control
* methods. The only thing we really need to do here is to
* notice the beginning of IF, ELSE, and WHILE blocks.
*
****************************************************************************/
ACPI_STATUS
AcpiDsExecEndOp (
ACPI_WALK_STATE *WalkState)
{
ACPI_PARSE_OBJECT *Op;
ACPI_STATUS Status = AE_OK;
UINT32 OpType;
UINT32 OpClass;
ACPI_PARSE_OBJECT *NextOp;
ACPI_PARSE_OBJECT *FirstArg;
ACPI_FUNCTION_TRACE_PTR ("DsExecEndOp", WalkState);
Op = WalkState->Op;
OpType = WalkState->OpInfo->Type;
OpClass = WalkState->OpInfo->Class;
if (OpClass == AML_CLASS_UNKNOWN)
{
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown opcode %X\n", Op->Common.AmlOpcode));
return_ACPI_STATUS (AE_NOT_IMPLEMENTED);
}
FirstArg = Op->Common.Value.Arg;
/* Init the walk state */
WalkState->NumOperands = 0;
WalkState->ReturnDesc = NULL;
WalkState->ResultObj = NULL;
/* Call debugger for single step support (DEBUG build only) */
ACPI_DEBUGGER_EXEC (Status = AcpiDbSingleStep (WalkState, Op, OpClass));
ACPI_DEBUGGER_EXEC (if (ACPI_FAILURE (Status)) {return_ACPI_STATUS (Status);});
/* Decode the Opcode Class */
switch (OpClass)
{
case AML_CLASS_ARGUMENT: /* constants, literals, etc. -- do nothing */
break;
case AML_CLASS_EXECUTE: /* most operators with arguments */
/* Build resolved operand stack */
Status = AcpiDsCreateOperands (WalkState, FirstArg);
if (ACPI_FAILURE (Status))
{
goto Cleanup;
}
/* Done with this result state (Now that operand stack is built) */
Status = AcpiDsResultStackPop (WalkState);
if (ACPI_FAILURE (Status))
{
goto Cleanup;
}
/* Resolve all operands */
Status = AcpiExResolveOperands (WalkState->Opcode,
&(WalkState->Operands [WalkState->NumOperands -1]),
WalkState);
if (ACPI_SUCCESS (Status))
{
ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE,
AcpiPsGetOpcodeName (WalkState->Opcode),
WalkState->NumOperands, "after ExResolveOperands");
/*
* Dispatch the request to the appropriate interpreter handler
* routine. There is one routine per opcode "type" based upon the
* number of opcode arguments and return type.
*/
Status = AcpiGbl_OpTypeDispatch [OpType] (WalkState);
}
else
{
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"[%s]: Could not resolve operands, %s\n",
AcpiPsGetOpcodeName (WalkState->Opcode),
AcpiFormatException (Status)));
}
/* Always delete the argument objects and clear the operand stack */
AcpiDsClearOperands (WalkState);
/*
* If a result object was returned from above, push it on the
* current result stack
*/
if (ACPI_SUCCESS (Status) &&
WalkState->ResultObj)
{
Status = AcpiDsResultPush (WalkState->ResultObj, WalkState);
}
break;
default:
switch (OpType)
{
case AML_TYPE_CONTROL: /* Type 1 opcode, IF/ELSE/WHILE/NOOP */
/* 1 Operand, 0 ExternalResult, 0 InternalResult */
Status = AcpiDsExecEndControlOp (WalkState, Op);
if (ACPI_FAILURE (Status))
{
break;
}
Status = AcpiDsResultStackPop (WalkState);
break;
case AML_TYPE_METHOD_CALL:
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Method invocation, Op=%p\n", Op));
/*
* (AML_METHODCALL) Op->Value->Arg->Node contains
* the method Node pointer
*/
/* NextOp points to the op that holds the method name */
NextOp = FirstArg;
/* NextOp points to first argument op */
NextOp = NextOp->Common.Next;
/*
* Get the method's arguments and put them on the operand stack
*/
Status = AcpiDsCreateOperands (WalkState, NextOp);
if (ACPI_FAILURE (Status))
{
break;
}
/*
* Since the operands will be passed to another control method,
* we must resolve all local references here (Local variables,
* arguments to *this* method, etc.)
*/
Status = AcpiDsResolveOperands (WalkState);
if (ACPI_FAILURE (Status))
{
/* On error, clear all resolved operands */
AcpiDsClearOperands (WalkState);
break;
}
/*
* Tell the walk loop to preempt this running method and
* execute the new method
*/
Status = AE_CTRL_TRANSFER;
/*
* Return now; we don't want to disturb anything,
* especially the operand count!
*/
return_ACPI_STATUS (Status);
case AML_TYPE_CREATE_FIELD:
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
"Executing CreateField Buffer/Index Op=%p\n", Op));
Status = AcpiDsLoad2EndOp (WalkState);
if (ACPI_FAILURE (Status))
{
break;
}
Status = AcpiDsEvalBufferFieldOperands (WalkState, Op);
break;
case AML_TYPE_CREATE_OBJECT:
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
"Executing CreateObject (Buffer/Package) Op=%p\n", Op));
switch (Op->Common.Parent->Common.AmlOpcode)
{
case AML_NAME_OP:
/*
* Put the Node on the object stack (Contains the ACPI Name of
* this object)
*/
WalkState->Operands[0] = (void *) Op->Common.Parent->Common.Node;
WalkState->NumOperands = 1;
Status = AcpiDsCreateNode (WalkState, Op->Common.Parent->Common.Node, Op->Common.Parent);
if (ACPI_FAILURE (Status))
{
break;
}
/* Fall through */
/*lint -fallthrough */
case AML_INT_EVAL_SUBTREE_OP:
Status = AcpiDsEvalDataObjectOperands (WalkState, Op,
AcpiNsGetAttachedObject (Op->Common.Parent->Common.Node));
break;
default:
Status = AcpiDsEvalDataObjectOperands (WalkState, Op, NULL);
break;
}
/*
* If a result object was returned from above, push it on the
* current result stack
*/
if (ACPI_SUCCESS (Status) &&
WalkState->ResultObj)
{
Status = AcpiDsResultPush (WalkState->ResultObj, WalkState);
}
break;
case AML_TYPE_NAMED_FIELD:
case AML_TYPE_NAMED_COMPLEX:
case AML_TYPE_NAMED_SIMPLE:
case AML_TYPE_NAMED_NO_OBJ:
Status = AcpiDsLoad2EndOp (WalkState);
if (ACPI_FAILURE (Status))
{
break;
}
if (Op->Common.AmlOpcode == AML_REGION_OP)
{
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
"Executing OpRegion Address/Length Op=%p\n", Op));
Status = AcpiDsEvalRegionOperands (WalkState, Op);
if (ACPI_FAILURE (Status))
{
break;
}
Status = AcpiDsResultStackPop (WalkState);
}
break;
case AML_TYPE_UNDEFINED:
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Undefined opcode type Op=%p\n", Op));
return_ACPI_STATUS (AE_NOT_IMPLEMENTED);
case AML_TYPE_BOGUS:
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"Internal opcode=%X type Op=%p\n",
WalkState->Opcode, Op));
break;
default:
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Unimplemented opcode, class=%X type=%X Opcode=%X Op=%p\n",
OpClass, OpType, Op->Common.AmlOpcode, Op));
Status = AE_NOT_IMPLEMENTED;
break;
}
}
/*
* ACPI 2.0 support for 64-bit integers: Truncate numeric
* result value if we are executing from a 32-bit ACPI table
*/
AcpiExTruncateFor32bitTable (WalkState->ResultObj);
/*
* Check if we just completed the evaluation of a
* conditional predicate
*/
if ((WalkState->ControlState) &&
(WalkState->ControlState->Common.State ==
ACPI_CONTROL_PREDICATE_EXECUTING) &&
(WalkState->ControlState->Control.PredicateOp == Op))
{
Status = AcpiDsGetPredicateValue (WalkState, WalkState->ResultObj);
WalkState->ResultObj = NULL;
}
Cleanup:
if (WalkState->ResultObj)
{
/* Break to debugger to display result */
ACPI_DEBUGGER_EXEC (AcpiDbDisplayResultObject (WalkState->ResultObj, WalkState));
/*
* Delete the result op if and only if:
* Parent will not use the result -- such as any
* non-nested type2 op in a method (parent will be method)
*/
AcpiDsDeleteResultIfNotUsed (Op, WalkState->ResultObj, WalkState);
}
#if _UNDER_DEVELOPMENT
if (WalkState->ParserState.Aml == WalkState->ParserState.AmlEnd)
{
AcpiDbMethodEnd (WalkState);
}
#endif
/* Always clear the object stack */
WalkState->NumOperands = 0;
return_ACPI_STATUS (Status);
}
| 31.796415 | 105 | 0.592679 |
cff9ef4a7ce8c80cf6044c6ef5dec856448e2ecb | 8,240 | h | C | blingfireclient.library/inc/FATokenSegmentationTools_1best_t.h | palerdot/BlingFire | 7e0fbc719042a4857c824b42d9cb5fbefe48aa3e | [
"MIT"
] | 1,251 | 2019-03-30T00:13:56.000Z | 2019-05-06T15:05:24.000Z | blingfireclient.library/inc/FATokenSegmentationTools_1best_t.h | palerdot/BlingFire | 7e0fbc719042a4857c824b42d9cb5fbefe48aa3e | [
"MIT"
] | 57 | 2019-05-14T03:13:38.000Z | 2022-03-29T14:49:04.000Z | blingfireclient.library/inc/FATokenSegmentationTools_1best_t.h | palerdot/BlingFire | 7e0fbc719042a4857c824b42d9cb5fbefe48aa3e | [
"MIT"
] | 62 | 2019-05-07T21:45:39.000Z | 2022-01-22T01:14:59.000Z | /**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
#ifndef _FA_TOKENSEGMENTATIONTOOLS_1BEST_T_H_
#define _FA_TOKENSEGMENTATIONTOOLS_1BEST_T_H_
#include "FAConfig.h"
#include "FARSDfaCA.h"
#include "FAMealyDfaCA.h"
#include "FAArrayCA.h"
#include "FAMultiMapCA.h"
#include "FADictConfKeeper.h"
#include "FALimits.h"
#include "FASecurity.h"
#include "FATokenSegmentationToolsCA_t.h"
#include <vector>
#include <float.h>
namespace BlingFire
{
///
/// Splits input sequence into segments with smaller number of segments
/// and maximum sum of weights.
///
/// Input: sequence of characters
/// Output: array of tuples <TokenId, From, To>
///
/// If input sequence contains a subsequence of unknown characters then
/// this subsequence is treated as one unknown segment.
///
template < class Ty >
class FATokenSegmentationTools_1best_t : public FATokenSegmentationToolsCA_t <Ty> {
public:
FATokenSegmentationTools_1best_t ();
public:
/// initializes from the valid configuration object
void SetConf (const FADictConfKeeper * pConf);
/// writes an array of tuples <TokenId, From, To> into pOut
/// returns the actual / needed size of the array to fit all the tuples or
/// -1 in case of an error
const int Process (
const Ty * pIn,
const int InSize,
__out_ecount(MaxOutSize) int * pOut,
const int MaxOutSize,
const int UnkId
) const;
private:
// Mealy DFA keeping a map from a known segment to idx and
// and MultiMap keeping a realtion between idx and <ID, Score> pair
const FARSDfaCA * m_pDfa;
const FAMealyDfaCA * m_pMealy;
const FAArrayCA * m_pK2I; // note this is an identify since we don't have duplicate ID's
const FAMultiMapCA * m_pI2Info;
// unknown segment score
const float m_UnkScore;
// to keep track of arc data
struct _TArc {
int _Begin; // the begging position of the ssegment
int _Id; // ID of a segment from the vocab
double _Score; // cumulative score
public:
_TArc ():
_Begin(-1),
_Id(-1),
_Score(-FLT_MAX)
{}
};
// a helper method to add an arc into the pArcs
inline void AddArc (_TArc * pArcs, int start, int end, int OwSum) const;
// a helper method to add an arc if a token is not known
inline void AddUnknownArc (_TArc * pArcs, int start) const;
};
template < class Ty >
FATokenSegmentationTools_1best_t < Ty >::
FATokenSegmentationTools_1best_t () :
m_pDfa (NULL),
m_pMealy (NULL),
m_pK2I (NULL),
m_pI2Info (NULL),
m_UnkScore (-100000.0) // this is guaranteed lower than any of the segment scores
{}
template < class Ty >
void FATokenSegmentationTools_1best_t < Ty >::
SetConf (const FADictConfKeeper * pConf)
{
LogAssert (pConf);
LogAssert(FAFsmConst::TYPE_MEALY_DFA == pConf->GetFsmType());
m_pDfa = pConf->GetRsDfa ();
m_pMealy = pConf->GetMphMealy ();
m_pK2I = pConf->GetK2I ();
m_pI2Info = pConf->GetI2Info ();
LogAssert(0 < m_pK2I->GetCount ());
}
template < class Ty >
inline void FATokenSegmentationTools_1best_t < Ty >::
AddArc (_TArc * pArcs, int start, int end, int Key) const
{
// look up the score and the id of the segment
const int * pValues = NULL;
const int Count = m_pI2Info->Get (Key, &pValues);
LogAssert (2 == Count && NULL != pValues);
const float Score = *((const float*) &(pValues [1]));
// compute previous score given the start
const double prevScore = 0 < start ? pArcs [start - 1]._Score : 0;
// get a pointer to the arc object
_TArc * pA = pArcs + end;
// set the arc, if it was never set then it has smallest negative float number
// so the condition is always true
if (pA->_Score < Score + prevScore) {
pA->_Begin = start;
pA->_Id = pValues [0];
pA->_Score = Score + prevScore;
}
}
template < class Ty >
inline void FATokenSegmentationTools_1best_t < Ty >::
AddUnknownArc (_TArc * pArcs, int start) const
{
const int end = start;
// get a pointer to the arc object and previous arc object
_TArc * pA = pArcs + end;
_TArc * pPrevA = pA - 1;
// compute previous score given the start
const double prevScore = 0 < start ? pPrevA->_Score : 0;
// set the arc, if it was never set then it has smallest negative float number
// so the condition is always true
if (pA->_Score < m_UnkScore + prevScore) {
pA->_Begin = start;
pA->_Id = -1;
pA->_Score = m_UnkScore + prevScore;
// check if the previous arc is also Unknown then merge them
if (0 < start && -1 == pPrevA->_Id) {
pA->_Begin = pPrevA->_Begin;
}
}
}
template < class Ty >
const int FATokenSegmentationTools_1best_t < Ty >::
Process (
const Ty * pIn,
const int InSize,
__out_ecount(MaxOutSize) int * pOut,
const int MaxOutSize,
const int UnkId
) const
{
DebugLogAssert (m_pDfa && m_pMealy && m_pK2I && m_pI2Info);
if (0 >= InSize) {
return 0;
}
LogAssert (pIn && InSize <= FALimits::MaxArrSize);
// allocate storage for best arcs for each ending position
std::vector <_TArc> End2BestArc (InSize);
DebugLogAssert(InSize == End2BestArc.size ());
_TArc * pArcs = End2BestArc.data ();
// get the initial state
const int InitialState = m_pDfa->GetInitial ();
// populate the arcs
for (int start = 0; start < InSize; ++start) {
int State = InitialState;
int SumOw = 0;
int Ow = 0;
bool TokenUnknown = true;
// go as deep as we can from the start position
for (int i = start; i < InSize; ++i) {
const Ty Iw = pIn [i];
State = m_pMealy->GetDestOw (State, Iw, &Ow);
// see if the does not have a transition
if (-1 == State) {
break;
}
SumOw += Ow;
DebugLogAssert (0 <= Ow);
// see if the destination state is a final state
if (m_pDfa->IsFinal (State)) {
AddArc (pArcs, start, i, SumOw);
TokenUnknown = false;
}
} // of for(int i = start; i < InSize; ++start) ...
if (TokenUnknown) {
AddUnknownArc (pArcs, start);
}
} // for(int start = 0; start < InSize; ++start) ...
int ActualOutSize = 0;
int end = InSize - 1;
// now let's go in the reverse order and follow the best path
while (0 <= end) {
const _TArc * pA = pArcs + end;
const int start = pA->_Begin;
const int ID = pA->_Id;
// validate the invariant of the algorithm
DebugLogAssert (0 <= start && start < InSize);
DebugLogAssert (0 <= end && end < InSize);
DebugLogAssert (start <= end);
DebugLogAssert (-1 == ID || ID >= 0);
if (ActualOutSize + 3 <= MaxOutSize) {
// write the results in <t, f, id> order so when reversed the order is correct
pOut[ActualOutSize] = end;
pOut[ActualOutSize + 1] = start;
pOut[ActualOutSize + 2] = (-1 != ID) ? ID : UnkId;
}
ActualOutSize += 3;
// skip to the end of the previous segment
DebugLogAssert (start - 1 < end);
end = start - 1;
}
// see if the pOut contains all the results
if (MaxOutSize >= ActualOutSize) {
// reverse the array so the results <id, f, t> and in left to tight order
const int ActualOutSize_2 = ActualOutSize / 2;
for(int i = 0; i < ActualOutSize_2; ++i) {
int tmp = pOut[i];
pOut[i] = pOut[ActualOutSize - i - 1];
pOut[ActualOutSize - i - 1] = tmp;
}
}
return ActualOutSize;
}
}
#endif
| 29.014085 | 97 | 0.581311 |
3212422047f6e9c47814af8e5d31fc2426f1365c | 4,744 | h | C | CustomCode/Modules/Manager/OKWalletManager.h | danielsocials/ios | 0347c5da6da9529e4f0d7b49b49f5aa409dc848a | [
"MIT"
] | null | null | null | CustomCode/Modules/Manager/OKWalletManager.h | danielsocials/ios | 0347c5da6da9529e4f0d7b49b49f5aa409dc848a | [
"MIT"
] | null | null | null | CustomCode/Modules/Manager/OKWalletManager.h | danielsocials/ios | 0347c5da6da9529e4f0d7b49b49f5aa409dc848a | [
"MIT"
] | null | null | null | //
// OKWalletManager.h
// OneKey
//
// Created by xiaoliang on 2020/11/3.
// Copyright © 2020 OneKey. All rights reserved..
//
#import <Foundation/Foundation.h>
#import "OKWalletInfoModel.h"
#define COIN_BTC @"BTC"
#define COIN_ETH @"ETH"
#define COIN_HECO @"HECO"
#define COIN_BSC @"BSC"
#define kCNY @"CNY" //人民币
#define kUSD @"USD" //美元
#define kJPY @"JPY" //日元
#define kKRW @"KRW" //韩元
#define kGBP @"GBP" //英镑
#define kEUR @"EUR" //欧元
#define kHKD @"HKD" //马来西亚林吉特
#define kMYR @"MYR" //港币
#define kAUD @"AUD" //澳元
#define kINR @"INR" //卢布
#define kCNYSymbol @"¥" //人民币
#define kUSDSymbol @"$" //美元
#define kJPYSymbol @"¥" //日元
#define kKRWSymbol @"₩" //韩元
#define kGBPSymbol @"£" //英镑
#define kEURSymbol @"€" //欧元
#define kHKDSymbol @"RM" //马来西亚林吉特
#define kMYRSymbol @"$" //港币
#define kAUDSymbol @"$" //澳元
#define kINRSymbol @"₽" //卢布
#define kCurrentWalletInfo @"kCurrentWalletInfo"
#define kCurrentFiat @"kCurrentFiat"
#define kCurrentFiatSymbol @"kCurrentFiatSymbol"
#define kCurrentBitcoinUnit @"kCurrentBitcoinUnit"
#define kSelectedWalletListType @"kSelectedWalletListType"
#define kShowAssetKey @"kShowAssetKey"
#define kIsOpenAuthBiologicalKey @"kIsOpenAuthBiologicalKey"
#define kWalletManager (OKWalletManager.sharedInstance)
NS_ASSUME_NONNULL_BEGIN
// BTC 地址类型
typedef NS_ENUM(NSInteger, OKBTCAddressType) {
OKBTCAddressTypeNotBTC = 0, // 非 BTC 地址
OKBTCAddressTypeNormal = 44, // 普通地址,以 1 开头
OKBTCAddressTypeSegwit = 49, // 兼容隔离见证地址,以 3 开头
OKBTCAddressTypeNativeSegwit = 84, // 原生隔离见证地址,以 bc1 开头
};
//矿工费类型
typedef enum {
OKFeeTypeSlow,
OKFeeTypeRecommend,
OKFeeTypeFast
}OKFeeType;
//创建和导入的钱包类型
typedef enum {
OKAddTypeCreateHDDerived, //创建HD派生
OKAddTypeCreateSolo, //创建独立钱包
OKAddTypeImportSeed, //导出助记词
OKAddTypeImportPrivkeys, //导入私钥
OKAddTypeImportAddresses, //导入地址
OKAddTypeImportKeystore, //导入KeyStore
OKAddTypeImportXpub, //导入Xpub
OKAddTypeImport, //导入
OKAddTypeCreateHWDerived, //创建硬件派生钱包
OKAddTypeRestoredHWWallet, //恢复硬件钱包
OKAddTypeActivationHWWallet,//激活硬件钱包
OKAddTypeSpecialEquipmentHw //从特殊设备恢复HD钱包
}OKAddType;
//创建钱包跳转类型
typedef enum {
OKWhereToSelectTypeWalletList,
OKWhereToSelectTypeHDMag
}OKWhereToSelectType;
//删除钱包的跳转类型
typedef enum {
OKWhereToDeleteTypeDetail,
OKWhereToDeleteTypeMine,
OKWhereToDeleteTypeAPP
}OKWhereToDeleteType;
//助记词长度类型
typedef enum{
OKMnemonicLengthType12,
OKMnemonicLengthType24
}OKMnemonicLengthType;
@interface OKWalletManager : NSObject
@property (nonatomic,copy)NSString *currentSelectCoinType;
@property (nonatomic,strong, nullable)OKWalletInfoModel *currentWalletInfo;
@property (nonatomic,copy)NSString *currentFiat;
@property (nonatomic,copy)NSString *currentFiatSymbol;
@property (nonatomic,copy)NSString *currentBitcoinUnit;
@property (nonatomic,strong)NSArray *supportCoinArray;
@property (nonatomic,strong)NSArray *ethClassification;
@property (nonatomic,strong) NSArray *supportFiatArray;
@property (nonatomic,strong) NSArray *supportFiatsSymbol;
@property (nonatomic,strong) NSDictionary *precisionDict;
@property (nonatomic,strong) NSDictionary *unitIsDifferentDict;
@property (nonatomic,assign)BOOL showAsset;
@property (nonatomic,assign)BOOL isOpenAuthBiological;
- (BOOL)showAsset;
- (void)setShowAsset:(BOOL)showAsset;
- (void)setCurrentFiat:(NSString *)currentFiat;
- (NSString *)getWalletTypeShowStr:(NSString *)type;
- (OKWalletType)getWalletDetailType;
- (NSString *)getShowUICoinType:(NSString *)coinType;
+ (OKWalletManager *)sharedInstance;
- (void)clearCurrentWalletInfo;
- (BOOL)checkEveryWordInPlist:(NSArray *)wordsArr;
- (NSString *)getFeeBaseWithSat:(NSString *)sat;
- (BOOL)checkWalletName:(NSString *)name;
- (BOOL)checkIsHavePwd;
- (BOOL)haveHDWallet;
- (nullable OKWalletInfoModel *)getCurrentWalletAddress:(NSString *)wallletName;
- (NSString *)getUnitForCoinType;
- (NSArray <OKWalletInfoModel *>*)listWallets;
- (NSArray <OKWalletInfoModel *>*)listWalletsChainType:(OKWalletChainType)type;
- (BOOL)isETHClassification:(NSString *)coinType;
- (NSInteger)getPrecision:(NSString *)key;
- (NSString *)getBrowseAddressUrlTxHash:(NSString *)txHash;
@end
NS_ASSUME_NONNULL_END
| 32.054054 | 80 | 0.675169 |
322559acaae3e4d2fffaf0580f9e5d4534737847 | 9,799 | h | C | aws-cpp-sdk-neptune/include/aws/neptune/model/ValidStorageOptions.h | Neusoft-Technology-Solutions/aws-sdk-cpp | 88c041828b0dbee18a297c3cfe98c5ecd0706d0b | [
"Apache-2.0"
] | 1 | 2022-02-12T08:09:30.000Z | 2022-02-12T08:09:30.000Z | aws-cpp-sdk-neptune/include/aws/neptune/model/ValidStorageOptions.h | Neusoft-Technology-Solutions/aws-sdk-cpp | 88c041828b0dbee18a297c3cfe98c5ecd0706d0b | [
"Apache-2.0"
] | 1 | 2021-10-14T16:57:00.000Z | 2021-10-18T10:47:24.000Z | aws-cpp-sdk-neptune/include/aws/neptune/model/ValidStorageOptions.h | ravindra-wagh/aws-sdk-cpp | 7d5ff01b3c3b872f31ca98fb4ce868cd01e97696 | [
"Apache-2.0"
] | 1 | 2022-03-23T15:17:18.000Z | 2022-03-23T15:17:18.000Z | /**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#pragma once
#include <aws/neptune/Neptune_EXPORTS.h>
#include <aws/core/utils/memory/stl/AWSStreamFwd.h>
#include <aws/core/utils/memory/stl/AWSString.h>
#include <aws/core/utils/memory/stl/AWSVector.h>
#include <aws/neptune/model/Range.h>
#include <aws/neptune/model/DoubleRange.h>
#include <utility>
namespace Aws
{
namespace Utils
{
namespace Xml
{
class XmlNode;
} // namespace Xml
} // namespace Utils
namespace Neptune
{
namespace Model
{
/**
* <p>Information about valid modifications that you can make to your DB
* instance.</p> <p>Contains the result of a successful call to the
* <a>DescribeValidDBInstanceModifications</a> action.</p><p><h3>See Also:</h3>
* <a
* href="http://docs.aws.amazon.com/goto/WebAPI/neptune-2014-10-31/ValidStorageOptions">AWS
* API Reference</a></p>
*/
class AWS_NEPTUNE_API ValidStorageOptions
{
public:
ValidStorageOptions();
ValidStorageOptions(const Aws::Utils::Xml::XmlNode& xmlNode);
ValidStorageOptions& operator=(const Aws::Utils::Xml::XmlNode& xmlNode);
void OutputToStream(Aws::OStream& ostream, const char* location, unsigned index, const char* locationValue) const;
void OutputToStream(Aws::OStream& oStream, const char* location) const;
/**
* <p>The valid storage types for your DB instance. For example, gp2, io1.</p>
*/
inline const Aws::String& GetStorageType() const{ return m_storageType; }
/**
* <p>The valid storage types for your DB instance. For example, gp2, io1.</p>
*/
inline bool StorageTypeHasBeenSet() const { return m_storageTypeHasBeenSet; }
/**
* <p>The valid storage types for your DB instance. For example, gp2, io1.</p>
*/
inline void SetStorageType(const Aws::String& value) { m_storageTypeHasBeenSet = true; m_storageType = value; }
/**
* <p>The valid storage types for your DB instance. For example, gp2, io1.</p>
*/
inline void SetStorageType(Aws::String&& value) { m_storageTypeHasBeenSet = true; m_storageType = std::move(value); }
/**
* <p>The valid storage types for your DB instance. For example, gp2, io1.</p>
*/
inline void SetStorageType(const char* value) { m_storageTypeHasBeenSet = true; m_storageType.assign(value); }
/**
* <p>The valid storage types for your DB instance. For example, gp2, io1.</p>
*/
inline ValidStorageOptions& WithStorageType(const Aws::String& value) { SetStorageType(value); return *this;}
/**
* <p>The valid storage types for your DB instance. For example, gp2, io1.</p>
*/
inline ValidStorageOptions& WithStorageType(Aws::String&& value) { SetStorageType(std::move(value)); return *this;}
/**
* <p>The valid storage types for your DB instance. For example, gp2, io1.</p>
*/
inline ValidStorageOptions& WithStorageType(const char* value) { SetStorageType(value); return *this;}
/**
* <p>The valid range of storage in gibibytes. For example, 100 to 16384.</p>
*/
inline const Aws::Vector<Range>& GetStorageSize() const{ return m_storageSize; }
/**
* <p>The valid range of storage in gibibytes. For example, 100 to 16384.</p>
*/
inline bool StorageSizeHasBeenSet() const { return m_storageSizeHasBeenSet; }
/**
* <p>The valid range of storage in gibibytes. For example, 100 to 16384.</p>
*/
inline void SetStorageSize(const Aws::Vector<Range>& value) { m_storageSizeHasBeenSet = true; m_storageSize = value; }
/**
* <p>The valid range of storage in gibibytes. For example, 100 to 16384.</p>
*/
inline void SetStorageSize(Aws::Vector<Range>&& value) { m_storageSizeHasBeenSet = true; m_storageSize = std::move(value); }
/**
* <p>The valid range of storage in gibibytes. For example, 100 to 16384.</p>
*/
inline ValidStorageOptions& WithStorageSize(const Aws::Vector<Range>& value) { SetStorageSize(value); return *this;}
/**
* <p>The valid range of storage in gibibytes. For example, 100 to 16384.</p>
*/
inline ValidStorageOptions& WithStorageSize(Aws::Vector<Range>&& value) { SetStorageSize(std::move(value)); return *this;}
/**
* <p>The valid range of storage in gibibytes. For example, 100 to 16384.</p>
*/
inline ValidStorageOptions& AddStorageSize(const Range& value) { m_storageSizeHasBeenSet = true; m_storageSize.push_back(value); return *this; }
/**
* <p>The valid range of storage in gibibytes. For example, 100 to 16384.</p>
*/
inline ValidStorageOptions& AddStorageSize(Range&& value) { m_storageSizeHasBeenSet = true; m_storageSize.push_back(std::move(value)); return *this; }
/**
* <p>The valid range of provisioned IOPS. For example, 1000-20000.</p>
*/
inline const Aws::Vector<Range>& GetProvisionedIops() const{ return m_provisionedIops; }
/**
* <p>The valid range of provisioned IOPS. For example, 1000-20000.</p>
*/
inline bool ProvisionedIopsHasBeenSet() const { return m_provisionedIopsHasBeenSet; }
/**
* <p>The valid range of provisioned IOPS. For example, 1000-20000.</p>
*/
inline void SetProvisionedIops(const Aws::Vector<Range>& value) { m_provisionedIopsHasBeenSet = true; m_provisionedIops = value; }
/**
* <p>The valid range of provisioned IOPS. For example, 1000-20000.</p>
*/
inline void SetProvisionedIops(Aws::Vector<Range>&& value) { m_provisionedIopsHasBeenSet = true; m_provisionedIops = std::move(value); }
/**
* <p>The valid range of provisioned IOPS. For example, 1000-20000.</p>
*/
inline ValidStorageOptions& WithProvisionedIops(const Aws::Vector<Range>& value) { SetProvisionedIops(value); return *this;}
/**
* <p>The valid range of provisioned IOPS. For example, 1000-20000.</p>
*/
inline ValidStorageOptions& WithProvisionedIops(Aws::Vector<Range>&& value) { SetProvisionedIops(std::move(value)); return *this;}
/**
* <p>The valid range of provisioned IOPS. For example, 1000-20000.</p>
*/
inline ValidStorageOptions& AddProvisionedIops(const Range& value) { m_provisionedIopsHasBeenSet = true; m_provisionedIops.push_back(value); return *this; }
/**
* <p>The valid range of provisioned IOPS. For example, 1000-20000.</p>
*/
inline ValidStorageOptions& AddProvisionedIops(Range&& value) { m_provisionedIopsHasBeenSet = true; m_provisionedIops.push_back(std::move(value)); return *this; }
/**
* <p>The valid range of Provisioned IOPS to gibibytes of storage multiplier. For
* example, 3-10, which means that provisioned IOPS can be between 3 and 10 times
* storage.</p>
*/
inline const Aws::Vector<DoubleRange>& GetIopsToStorageRatio() const{ return m_iopsToStorageRatio; }
/**
* <p>The valid range of Provisioned IOPS to gibibytes of storage multiplier. For
* example, 3-10, which means that provisioned IOPS can be between 3 and 10 times
* storage.</p>
*/
inline bool IopsToStorageRatioHasBeenSet() const { return m_iopsToStorageRatioHasBeenSet; }
/**
* <p>The valid range of Provisioned IOPS to gibibytes of storage multiplier. For
* example, 3-10, which means that provisioned IOPS can be between 3 and 10 times
* storage.</p>
*/
inline void SetIopsToStorageRatio(const Aws::Vector<DoubleRange>& value) { m_iopsToStorageRatioHasBeenSet = true; m_iopsToStorageRatio = value; }
/**
* <p>The valid range of Provisioned IOPS to gibibytes of storage multiplier. For
* example, 3-10, which means that provisioned IOPS can be between 3 and 10 times
* storage.</p>
*/
inline void SetIopsToStorageRatio(Aws::Vector<DoubleRange>&& value) { m_iopsToStorageRatioHasBeenSet = true; m_iopsToStorageRatio = std::move(value); }
/**
* <p>The valid range of Provisioned IOPS to gibibytes of storage multiplier. For
* example, 3-10, which means that provisioned IOPS can be between 3 and 10 times
* storage.</p>
*/
inline ValidStorageOptions& WithIopsToStorageRatio(const Aws::Vector<DoubleRange>& value) { SetIopsToStorageRatio(value); return *this;}
/**
* <p>The valid range of Provisioned IOPS to gibibytes of storage multiplier. For
* example, 3-10, which means that provisioned IOPS can be between 3 and 10 times
* storage.</p>
*/
inline ValidStorageOptions& WithIopsToStorageRatio(Aws::Vector<DoubleRange>&& value) { SetIopsToStorageRatio(std::move(value)); return *this;}
/**
* <p>The valid range of Provisioned IOPS to gibibytes of storage multiplier. For
* example, 3-10, which means that provisioned IOPS can be between 3 and 10 times
* storage.</p>
*/
inline ValidStorageOptions& AddIopsToStorageRatio(const DoubleRange& value) { m_iopsToStorageRatioHasBeenSet = true; m_iopsToStorageRatio.push_back(value); return *this; }
/**
* <p>The valid range of Provisioned IOPS to gibibytes of storage multiplier. For
* example, 3-10, which means that provisioned IOPS can be between 3 and 10 times
* storage.</p>
*/
inline ValidStorageOptions& AddIopsToStorageRatio(DoubleRange&& value) { m_iopsToStorageRatioHasBeenSet = true; m_iopsToStorageRatio.push_back(std::move(value)); return *this; }
private:
Aws::String m_storageType;
bool m_storageTypeHasBeenSet;
Aws::Vector<Range> m_storageSize;
bool m_storageSizeHasBeenSet;
Aws::Vector<Range> m_provisionedIops;
bool m_provisionedIopsHasBeenSet;
Aws::Vector<DoubleRange> m_iopsToStorageRatio;
bool m_iopsToStorageRatioHasBeenSet;
};
} // namespace Model
} // namespace Neptune
} // namespace Aws
| 39.995918 | 181 | 0.691805 |
d609a94dfb2205e2cab6274070307ae25a56f879 | 8,590 | c | C | src/lib/fy-utils.c | mfederczuk/libfyaml | a32b65db2329d5332e22f5f70f6c411ccf0a177b | [
"MIT"
] | 1 | 2021-03-28T21:48:18.000Z | 2021-03-28T21:48:18.000Z | src/lib/fy-utils.c | rittelle/libfyaml | 12bb36689514b7f060d62beac1036595b0c7de94 | [
"MIT"
] | null | null | null | src/lib/fy-utils.c | rittelle/libfyaml | 12bb36689514b7f060d62beac1036595b0c7de94 | [
"MIT"
] | null | null | null | /*
* fy-utils.c - Generic utilities for functionality that's missing
* from platforms.
*
* For now only used to implement memstream for Apple platforms.
*
* Copyright (c) 2019 Pantelis Antoniou <pantelis.antoniou@konsulko.com>
*
* SPDX-License-Identifier: MIT
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "fy-utf8.h"
#include "fy-ctype.h"
#include "fy-utils.h"
#if defined(__APPLE__) && (_POSIX_C_SOURCE < 200809L)
/*
* adapted from http://piumarta.com/software/memstream/
*
* Under the MIT license.
*/
/*
* ----------------------------------------------------------------------------
*
* OPEN_MEMSTREAM(3) BSD and Linux Library Functions OPEN_MEMSTREAM(3)
*
* SYNOPSIS
* #include "memstream.h"
*
* FILE *open_memstream(char **bufp, size_t *sizep);
*
* DESCRIPTION
* The open_memstream() function opens a stream for writing to a buffer.
* The buffer is dynamically allocated (as with malloc(3)), and
* automatically grows as required. After closing the stream, the caller
* should free(3) this buffer.
*
* When the stream is closed (fclose(3)) or flushed (fflush(3)), the
* locations pointed to by bufp and sizep are updated to contain,
* respectively, a pointer to the buffer and the current size of the
* buffer. These values remain valid only as long as the caller performs
* no further output on the stream. If further output is performed, then
* the stream must again be flushed before trying to access these
* variables.
*
* A null byte is maintained at the end of the buffer. This byte is not
* included in the size value stored at sizep.
*
* The stream's file position can be changed with fseek(3) or fseeko(3).
* Moving the file position past the end of the data already written fills
* the intervening space with zeros.
*
* RETURN VALUE
* Upon successful completion open_memstream() returns a FILE pointer.
* Otherwise, NULL is returned and errno is set to indicate the error.
*
* CONFORMING TO
* POSIX.1-2008
*
* ----------------------------------------------------------------------------
*/
#ifndef min
#define min(X, Y) (((X) < (Y)) ? (X) : (Y))
#endif
struct memstream {
size_t position;
size_t size;
size_t capacity;
char *contents;
char **ptr;
size_t *sizeloc;
};
static int memstream_grow(struct memstream *ms, size_t minsize)
{
size_t newcap;
char *newcontents;
newcap = ms->capacity * 2;
while (newcap <= minsize + 1)
newcap *= 2;
newcontents = realloc(ms->contents, newcap);
if (!newcontents)
return -1;
ms->contents = newcontents;
memset(ms->contents + ms->capacity, 0, newcap - ms->capacity);
ms->capacity = newcap;
*ms->ptr = ms->contents;
return 0;
}
static int memstream_read(void *cookie, char *buf, int count)
{
struct memstream *ms = cookie;
size_t n;
n = min(ms->size - ms->position, (size_t)count);
if (n < 1)
return 0;
memcpy(buf, ms->contents, n);
ms->position += n;
return n;
}
static int memstream_write(void *cookie, const char *buf, int count)
{
struct memstream *ms = cookie;
if (ms->capacity <= ms->position + (size_t)count &&
memstream_grow(ms, ms->position + (size_t)count) < 0)
return -1;
memcpy(ms->contents + ms->position, buf, count);
ms->position += count;
ms->contents[ms->position] = '\0';
if (ms->size < ms->position)
*ms->sizeloc = ms->size = ms->position;
return count;
}
static fpos_t memstream_seek(void *cookie, fpos_t offset, int whence)
{
struct memstream *ms = cookie;
fpos_t pos= 0;
switch (whence) {
case SEEK_SET:
pos = offset;
break;
case SEEK_CUR:
pos = ms->position + offset;
break;
case SEEK_END:
pos = ms->size + offset;
break;
default:
errno= EINVAL;
return -1;
}
if (pos >= (fpos_t)ms->capacity && memstream_grow(ms, pos) < 0)
return -1;
ms->position = pos;
if (ms->size < ms->position)
*ms->sizeloc = ms->size = ms->position;
return pos;
}
static int memstream_close(void *cookie)
{
struct memstream *ms = cookie;
ms->size = min(ms->size, ms->position);
*ms->ptr = ms->contents;
*ms->sizeloc = ms->size;
ms->contents[ms->size]= 0;
/* ms->contents is what's returned */
free(ms);
return 0;
}
FILE *open_memstream(char **ptr, size_t *sizeloc)
{
struct memstream *ms;
FILE *fp;
if (!ptr || !sizeloc) {
errno= EINVAL;
goto err_out;
}
ms = calloc(1, sizeof(struct memstream));
if (!ms)
goto err_out;
ms->position = ms->size= 0;
ms->capacity = 4096;
ms->contents = calloc(ms->capacity, 1);
if (!ms->contents)
goto err_free_ms;
ms->ptr = ptr;
ms->sizeloc = sizeloc;
fp= funopen(ms, memstream_read, memstream_write,
memstream_seek, memstream_close);
if (!fp)
goto err_free_all;
*ptr = ms->contents;
*sizeloc = ms->size;
return fp;
err_free_all:
free(ms->contents);
err_free_ms:
free(ms);
err_out:
return NULL;
}
#endif /* __APPLE__ && _POSIX_C_SOURCE < 200809L */
bool fy_tag_uri_is_valid(const char *data, size_t len)
{
const char *s, *e;
int w, j, k, width, c;
uint8_t octet, esc_octets[4];
s = data;
e = s + len;
while ((c = fy_utf8_get(s, e - s, &w)) >= 0) {
if (c != '%') {
s += w;
continue;
}
width = 0;
k = 0;
do {
/* short URI escape */
if ((e - s) < 3)
return false;
if (width > 0) {
c = fy_utf8_get(s, e - s, &w);
if (c != '%')
return false;
}
s += w;
octet = 0;
for (j = 0; j < 2; j++) {
c = fy_utf8_get(s, e - s, &w);
if (!fy_is_hex(c))
return false;
s += w;
octet <<= 4;
if (c >= '0' && c <= '9')
octet |= c - '0';
else if (c >= 'a' && c <= 'f')
octet |= 10 + c - 'a';
else
octet |= 10 + c - 'A';
}
if (!width) {
width = fy_utf8_width_by_first_octet(octet);
if (width < 1 || width > 4)
return false;
k = 0;
}
esc_octets[k++] = octet;
} while (--width > 0);
/* now convert to utf8 */
c = fy_utf8_get(esc_octets, k, &w);
if (c < 0)
return false;
}
return true;
}
int fy_tag_handle_length(const char *data, size_t len)
{
const char *s, *e;
int c, w;
s = data;
e = s + len;
c = fy_utf8_get(s, e - s, &w);
if (c != '!')
return -1;
s += w;
c = fy_utf8_get(s, e - s, &w);
if (fy_is_ws(c))
return s - data;
/* if first character is !, empty handle */
if (c == '!') {
s += w;
return s - data;
}
if (!fy_is_first_alpha(c))
return -1;
s += w;
while (fy_is_alnum(c = fy_utf8_get(s, e - s, &w)))
s += w;
if (c == '!')
s += w;
return s - data;
}
int fy_tag_uri_length(const char *data, size_t len)
{
const char *s, *e;
int c, w, cn, wn, uri_length;
s = data;
e = s + len;
while (fy_is_uri(c = fy_utf8_get(s, e - s, &w))) {
cn = fy_utf8_get(s + w, e - (s + w), &wn);
if (fy_is_blankz(cn) && fy_utf8_strchr(",}]", c))
break;
s += w;
}
uri_length = s - data;
if (!fy_tag_uri_is_valid(data, uri_length))
return -1;
return uri_length;
}
int fy_tag_scan(const char *data, size_t len, struct fy_tag_scan_info *info)
{
const char *s, *e;
int total_length, handle_length, uri_length, prefix_length, suffix_length;
int c, cn, w, wn;
s = data;
e = s + len;
prefix_length = 0;
/* it must start with '!' */
c = fy_utf8_get(s, e - s, &w);
if (c != '!')
return -1;
cn = fy_utf8_get(s + w, e - (s + w), &wn);
if (cn == '<') {
prefix_length = 2;
suffix_length = 1;
} else
prefix_length = suffix_length = 0;
if (prefix_length) {
handle_length = 0; /* set the handle to '' */
s += prefix_length;
} else {
/* either !suffix or !handle!suffix */
/* we scan back to back, and split handle/suffix */
handle_length = fy_tag_handle_length(s, e - s);
if (handle_length <= 0)
return -1;
s += handle_length;
}
uri_length = fy_tag_uri_length(s, e - s);
if (uri_length < 0)
return -1;
/* a handle? */
if (!prefix_length && (handle_length == 0 || data[handle_length - 1] != '!')) {
/* special case, '!', handle set to '' and suffix to '!' */
if (handle_length == 1 && uri_length == 0) {
handle_length = 0;
uri_length = 1;
} else {
uri_length = handle_length - 1 + uri_length;
handle_length = 1;
}
}
total_length = prefix_length + handle_length + uri_length + suffix_length;
if (total_length != (int)len)
return -1;
info->total_length = total_length;
info->handle_length = handle_length;
info->uri_length = uri_length;
info->prefix_length = prefix_length;
info->suffix_length = suffix_length;
return 0;
}
| 21.80203 | 80 | 0.603725 |
324acfcf87b54981b93a5d209d1945d03ee5c191 | 671 | h | C | memscrimper_cpp_implementation/src/memdump.h | d-we/memscrimper | 7429583624a6e350a939bf3521c63561255c4878 | [
"BSD-2-Clause"
] | 25 | 2018-06-12T16:28:00.000Z | 2022-02-18T01:17:46.000Z | memscrimper_cpp_implementation/src/memdump.h | d-we/memscrimper | 7429583624a6e350a939bf3521c63561255c4878 | [
"BSD-2-Clause"
] | null | null | null | memscrimper_cpp_implementation/src/memdump.h | d-we/memscrimper | 7429583624a6e350a939bf3521c63561255c4878 | [
"BSD-2-Clause"
] | 8 | 2018-06-12T16:28:07.000Z | 2019-05-27T18:55:36.000Z | // Copyright [2019] <Daniel Weber>
#ifndef MEMDUMP_H_
#define MEMDUMP_H_
#include <mutex>
#include <set>
#include <string>
#include <unordered_map>
namespace mscr {
class memdump {
public:
explicit memdump(const std::string &name);
std::string getPath() const;
const std::unordered_map<std::string, std::set<uint32_t>> * getPages() const;
std::unordered_map<uint32_t, std::string> * getNumToPage();
int readDumpfile(uint32_t pagesize);
private:
std::mutex mu_;
std::string path_;
std::unordered_map<std::string, std::set<uint32_t>> page_map_;
std::unordered_map<uint32_t, std::string> num_to_page_;
};
} // namespace mscr
#endif // MEMDUMP_H_
| 21.645161 | 79 | 0.718331 |
328d4c818fdef6f8aac90738f25a1a8466cd31fb | 4,907 | h | C | compiled/types.h | xtompok/osmawalk | fc63a36deaffaaebfd5022235bd3c4cb134d3cb2 | [
"MIT"
] | 1 | 2017-02-22T10:10:01.000Z | 2017-02-22T10:10:01.000Z | compiled/types.h | xtompok/osmawalk | fc63a36deaffaaebfd5022235bd3c4cb134d3cb2 | [
"MIT"
] | null | null | null | compiled/types.h | xtompok/osmawalk | fc63a36deaffaaebfd5022235bd3c4cb134d3cb2 | [
"MIT"
] | null | null | null | #ifndef TYPES_H
#define TYPES_H
#include <ucw/lib.h>
#include <stdint.h>
#include "include/premap.pb-c.h"
#define SWEEP_TYPE int64_t
/*!
* @abstract Structures for preparing data
* @discussion This file contains almost all structures used when preparing data
*/
/*! @struct nodesIdxNode
* @field key Node id
* @field idx Index in nodes array
*/
struct nodesIdxNode {
int64_t key;
int idx;
};
/*! @struct waysIdxNode
* @field key Way id
* @field Index in ways array
*/
struct waysIdxNode {
int64_t key;
int idx;
};
/*! @struct nodeWaysNode
* @field nodeid Node id
* @field ways Array of ways on which node lies
*/
struct nodeWaysNode {
int64_t nodeid;
int64_t * ways;
};
/*! @struct mixed_num_t
* @abstract Struct for representing mixed numbers. numer/denom should be always
* lower than 1
* @field base Integral part of a number
* @field numer Numerator of a rational part
* @field denom Denominator of a rational part
*/
struct mixed_num_t {
int64_t base;
int64_t numer;
int64_t denom;
};
/*! @struct col_t
* @abstract Struct for representing collisions
* @field isCol Is it collision?
* @field atEndpoint Is the collision at endpoint of both lines?
* @field lon Longitude of a collision in mixed number
* @field lat Latitude of a collision in mixed number
*/
struct col_t {
uint8_t isCol;
uint8_t atEndpoint;
struct mixed_num_t lon;
struct mixed_num_t lat;
};
/*! @struct map_t
* @abstract Struct for representing map
* @field n_nodes Number of nodes
* @field nodes Array of nodes
* @field n_ways Number of ways
* @field ways Array of ways
* @field n_relations Number of relations
* @field relations Array of relations
* @field n_multipols Number of multipolygons
* @field multipols Array of multipolygons
*/
struct map_t {
int n_nodes;
Premap__Node ** nodes;
int n_ways;
Premap__Way ** ways;
int n_relations;
Premap__Relation ** relations;
int n_multipols;
Premap__Multipolygon ** multipols;
};
/*! @struct raster_t
* @abstract Struct for representing raster over a map
* @field minlon Longitude of a lower left corner of the raster
* @field minlon Latitude of a lower left corner of the raster
* @field lonparts Number of cells in longitude dimension
* @field latparts Number of cells in latitude dimension
* @field steplon Width of a cell
* @field steplat Height of a cell
* @field raster Raster array
*/
struct raster_t {
int64_t minlon;
int64_t minlat;
int64_t lonparts;
int64_t latparts;
int64_t steplon;
int64_t steplat;
int *** raster;
};
enum event_type {EVT_START=2,EVT_END=0,EVT_INTERSECT=1};
/*! @struct event_t
* @abstract Start or end event
* @field lon Longitude of an event
* @field lat Latitude of an event
* @field dlon Delta of longitude of a line
* @field dlat Delta of latitude of a line
* @field lineIdx Index of a line in lines array
*/
struct event_t {
enum event_type type;
SWEEP_TYPE lon;
SWEEP_TYPE lat;
SWEEP_TYPE dlon;
SWEEP_TYPE dlat;
unsigned int lineIdx;
};
/*! @struct int_event_t
* @abstract Intersecton event
* @field lon Longitude of an event
* @field lat Latitude of an event
* @field dlon Delta of longitude of a lower line
* @field dlat Delta of latitude of a lower line
* @field lineIdx Index of a first line in lines array
* @field line2Idx Index of a second line in lines array
*/
struct int_event_t {
enum event_type type;
struct mixed_num_t lon;
struct mixed_num_t lat;
SWEEP_TYPE dlon;
SWEEP_TYPE dlat;
unsigned int lineIdx;
unsigned int line2Idx;
};
/*! @struct line_t
* @abstract Struct for representing line
* @field startlon Longitude of a starting point
* @field startlat Latitude of a starting point
* @field endlon Longitude of an end point
* @field endlat Latitude of an end point
* @field startid Id of a srating point
* @field endid Id of a end point
* @field isBar Is it a barrier line?
* @field broken Is it a barrier or crossed by it?
* @field started Has the line started?
* @field ended Hase the line ended?
*/
struct line_t {
SWEEP_TYPE startlon;
SWEEP_TYPE startlat;
SWEEP_TYPE endlon;
SWEEP_TYPE endlat;
int64_t startid;
int64_t endid;
bool isBar;
bool broken;
bool started;
bool ended;
};
/*! @struct tree_node_t
* @abstract Structure for node in tree for sweeping
* @field lineIdx Index of a line
*/
struct tree_node_t{
int lineIdx;
};
/*! @struct walk_area_t
* @abstract Struct for representig walk areas
* @field periIdx Index of a line defining perimeter of the area
* @field n_nodes Number of nodes inside
* @field nodesIdxs Array of indexes to nodes inside
* @field n_bars Number of barriers inside
* @field barIdxs Array of indexes to barrier ways inside
* @field n_way Number of ways inside
* @field wayIdxs Array of indexes to ways inside
*/
struct walk_area_t{
int periIdx;
int n_nodes;
int * nodeIdxs;
int n_bars;
int * barIdxs;
int n_ways;
int * wayIdxs;
};
#endif
| 24.782828 | 80 | 0.732219 |
c586f9796d3666a49c6ccb97793805d00be7d51c | 3,641 | c | C | Real-Time Corruptor/BizHawk_RTC/libmupen64plus/mupen64plus-video-rice/src/osal_files_unix.c | redscientistlabs/Bizhawk50X-Vanguard | 96e0f5f87671a1230784c8faf935fe70baadfe48 | [
"MIT"
] | 1,414 | 2015-06-28T09:57:51.000Z | 2021-10-14T03:51:10.000Z | Real-Time Corruptor/BizHawk_RTC/libmupen64plus/mupen64plus-video-rice/src/osal_files_unix.c | redscientistlabs/Bizhawk50X-Vanguard | 96e0f5f87671a1230784c8faf935fe70baadfe48 | [
"MIT"
] | 2,369 | 2015-06-25T01:45:44.000Z | 2021-10-16T08:44:18.000Z | Real-Time Corruptor/BizHawk_RTC/libmupen64plus/mupen64plus-video-rice/src/osal_files_unix.c | redscientistlabs/Bizhawk50X-Vanguard | 96e0f5f87671a1230784c8faf935fe70baadfe48 | [
"MIT"
] | 430 | 2015-06-29T04:28:58.000Z | 2021-10-05T18:24:17.000Z | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus-core - osal_files_unix.c *
* Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *
* Copyright (C) 2009 Richard Goedeken *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* This file contains the definitions for the unix-specific file handling
* functions
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <dirent.h>
#include "osal_files.h"
/* global functions */
int osal_is_directory(const char* name)
{
DIR* dir;
dir = opendir(name);
if(dir != NULL)
{
closedir(dir);
return 1;
}
return 0;
}
int osal_mkdirp(const char *dirpath, int mode)
{
struct stat fileinfo;
int dirpathlen = strlen(dirpath);
char *currpath = strdup(dirpath);
/* first, break the path into pieces by replacing all of the slashes wil NULL chars */
while (strlen(currpath) > 1)
{
char *lastslash = strrchr(currpath, '/');
if (lastslash == NULL)
break;
*lastslash = 0;
}
/* then re-assemble the path from left to right until we get to a directory that doesn't exist */
while (strlen(currpath) < dirpathlen)
{
if (strlen(currpath) > 0 && stat(currpath, &fileinfo) != 0)
break;
currpath[strlen(currpath)] = '/';
}
/* then walk up the path chain, creating directories along the way */
do
{
if (stat(currpath, &fileinfo) != 0)
{
if (mkdir(currpath, mode) != 0)
{
free(currpath);
return 1; /* mkdir failed */
}
}
if (strlen(currpath) == dirpathlen)
break;
else
currpath[strlen(currpath)] = '/';
} while (1);
free(currpath);
return 0;
}
void * osal_search_dir_open(const char *pathname)
{
DIR *dir;
dir = opendir(pathname);
return dir;
}
const char *osal_search_dir_read_next(void * dir_handle)
{
DIR *dir = (DIR *) dir_handle;
struct dirent *entry;
entry = readdir(dir);
if (entry == NULL)
return NULL;
return entry->d_name;
}
void osal_search_dir_close(void * dir_handle)
{
closedir((DIR *) dir_handle);
}
| 31.119658 | 101 | 0.504257 |
303c0d6189e9be0070b11bbe469ebe5f6b4a8858 | 336 | h | C | order.h | jakeh999/restaurant | f4ab87bc3318ddf0cf3d3e22c056564822c2b3c9 | [
"MIT"
] | null | null | null | order.h | jakeh999/restaurant | f4ab87bc3318ddf0cf3d3e22c056564822c2b3c9 | [
"MIT"
] | null | null | null | order.h | jakeh999/restaurant | f4ab87bc3318ddf0cf3d3e22c056564822c2b3c9 | [
"MIT"
] | null | null | null | #include <iostream>
#include <string>
using namespace std;
class Order {
private:
string name;
double price;
public:
Order(string, double = 10);
string get_name() const;
double get_price() const;
//ostream& print(ostream&) const;
};
ostream& operator<<(ostream&, Order&);
| 17.684211 | 41 | 0.589286 |
30836420b0b706bca5fe2c26edd89f63f6e74cba | 545 | h | C | FarLight/src/FarLight/ResourceSystem/ResourceManager.h | NewBediver/FarLight | 1ffaf127f51bb88ea3f5eb8d05c04458532d5389 | [
"Apache-2.0"
] | null | null | null | FarLight/src/FarLight/ResourceSystem/ResourceManager.h | NewBediver/FarLight | 1ffaf127f51bb88ea3f5eb8d05c04458532d5389 | [
"Apache-2.0"
] | null | null | null | FarLight/src/FarLight/ResourceSystem/ResourceManager.h | NewBediver/FarLight | 1ffaf127f51bb88ea3f5eb8d05c04458532d5389 | [
"Apache-2.0"
] | null | null | null | #pragma once
#include "FarLight/Core/Core.h"
#include "FarLight/Abstraction/Singleton/Singleton.h"
#include "FarLight/ResourceSystem/Resources/ShaderLibrary.h"
namespace FarLight
{
class ResourceManager
: public Singleton<ResourceManager>
{
public:
explicit ResourceManager() noexcept
: m_ShaderLibrary(CreateScope<ShaderLibrary>())
{ }
Scope<ShaderLibrary>& GetShaderLibrary() noexcept { return m_ShaderLibrary; }
private:
Scope<ShaderLibrary> m_ShaderLibrary;
};
}
| 21.8 | 85 | 0.691743 |
d68956bd0e2fc5488cd35a50f19ca45e54d7c318 | 1,251 | c | C | d/avatars/lurue/masq_key_53.c | gesslar/shadowgate | 97ce5d33a2275bb75c0cf6556602564b7870bc77 | [
"MIT"
] | 13 | 2019-07-19T05:24:44.000Z | 2021-11-18T04:08:19.000Z | d/avatars/lurue/masq_key_53.c | gesslar/shadowgate | 97ce5d33a2275bb75c0cf6556602564b7870bc77 | [
"MIT"
] | null | null | null | d/avatars/lurue/masq_key_53.c | gesslar/shadowgate | 97ce5d33a2275bb75c0cf6556602564b7870bc77 | [
"MIT"
] | 13 | 2019-09-12T06:22:38.000Z | 2022-01-31T01:15:12.000Z | #include <std.h>
inherit OBJECT;
void create(){
::create();
set_name("masq_key_53");
set_id(({ "key", "masq_key_53", "white key" }));
set_short("%^RESET%^%^BOLD%^%^WHITE%^Key to Room Number 53%^RESET%^");
set_obvious_short("%^RESET%^%^BOLD%^%^WHITE%^Key to Room Number 53%^RESET%^");
set_long(
@AVATAR
%^RESET%^%^CYAN%^A piece of %^BOLD%^%^WHITE%^white crystal%^RESET%^%^CYAN%^ has been formed into the shape of a key with the number %^BOLD%^%^WHITE%^53%^RESET%^%^CYAN%^ emblazoned upon both sides. As you gaze at it, the following information comes into your mind:%^BOLD%^ You must have this key to enter room 53. Once you are in that room, put all costume items on the ground and log your main character out. You will be logging in with a special NPC character whose log-in information is: %^RED%^LOGIN: %^RESET%^%^BOLD%^%^WHITE%^masqbb %^BOLD%^%^RED%^PSWD: %^RESET%^%^BOLD%^%^WHITE%^nafna %^BOLD%^%^CYAN%^- They will be located in the same room you are in. You will need to use this PC as your masquerade PC. They will be rid after the masquerade so make sure you return to your room and drop equip so your main PC will be able to get it when they log in. More info is on your alt.%^RESET%^
AVATAR
);
set_weight(0);
set_value(0);
}
| 65.842105 | 896 | 0.695444 |
68178fd001dd28a9b0028034c708fb3076940aed | 12,304 | c | C | standalone/pruntime/rizin/librz/bin/format/elf/elf_symbols.c | ndkazu/guessNumber-vs-Bot | 6e756977ce849137c62edb0716df6926583da9b2 | [
"Apache-2.0"
] | null | null | null | standalone/pruntime/rizin/librz/bin/format/elf/elf_symbols.c | ndkazu/guessNumber-vs-Bot | 6e756977ce849137c62edb0716df6926583da9b2 | [
"Apache-2.0"
] | null | null | null | standalone/pruntime/rizin/librz/bin/format/elf/elf_symbols.c | ndkazu/guessNumber-vs-Bot | 6e756977ce849137c62edb0716df6926583da9b2 | [
"Apache-2.0"
] | null | null | null | // SPDX-FileCopyrightText: 2021 08A <08A@riseup.net>
// SPDX-FileCopyrightText: 2008-2020 nibble <nibble.ds@gmail.com>
// SPDX-FileCopyrightText: 2008-2020 pancake <pancake@nopcode.org>
// SPDX-FileCopyrightText: 2008-2020 alvaro_fe <alvaro.felipe91@gmail.com>
// SPDX-License-Identifier: LGPL-3.0-only
#include "elf.h"
#include <ht_uu.h>
#define HASH_NCHAIN_OFFSET(x) ((x) + 4)
struct symbols_segment {
ut64 offset;
ut64 number;
ut64 entry_size;
bool dynamic;
RZ_BORROW RzBinElfStrtab *strtab;
};
struct symbol_bind_translation {
unsigned char bind;
const char *name;
};
struct symbol_type_translation {
unsigned char type;
const char *name;
};
static struct symbol_bind_translation symbol_bind_translation_table[] = {
{ STB_LOCAL, RZ_BIN_BIND_LOCAL_STR },
{ STB_GLOBAL, RZ_BIN_BIND_GLOBAL_STR },
{ STB_WEAK, RZ_BIN_BIND_WEAK_STR },
{ STB_NUM, RZ_BIN_BIND_NUM_STR },
{ STB_LOOS, RZ_BIN_BIND_LOOS_STR },
{ STB_HIOS, RZ_BIN_BIND_HIOS_STR },
{ STB_LOPROC, RZ_BIN_BIND_LOPROC_STR },
{ STB_HIPROC, RZ_BIN_BIND_HIPROC_STR }
};
static const struct symbol_type_translation symbol_type_translation_table[] = {
{ STT_NOTYPE, RZ_BIN_TYPE_NOTYPE_STR },
{ STT_OBJECT, RZ_BIN_TYPE_OBJECT_STR },
{ STT_FUNC, RZ_BIN_TYPE_FUNC_STR },
{ STT_SECTION, RZ_BIN_TYPE_SECTION_STR },
{ STT_FILE, RZ_BIN_TYPE_FILE_STR },
{ STT_COMMON, RZ_BIN_TYPE_COMMON_STR },
{ STT_TLS, RZ_BIN_TYPE_TLS_STR },
{ STT_NUM, RZ_BIN_TYPE_NUM_STR },
{ STT_LOOS, RZ_BIN_TYPE_LOOS_STR },
{ STT_HIOS, RZ_BIN_TYPE_HIOS_STR },
{ STT_LOPROC, RZ_BIN_TYPE_LOPROC_STR },
{ STT_HIPROC, RZ_BIN_TYPE_HIPROC_STR }
};
static struct symbols_segment symbols_segment_init(ut64 offset, ut64 number, ut64 entry_size, bool dynamic, RzBinElfStrtab *strtab) {
return (struct symbols_segment){
.offset = offset,
.number = number,
.entry_size = entry_size,
.dynamic = dynamic,
.strtab = strtab
};
}
static Elf_(Word) get_number_of_symbols_from_heuristic_aux(ELFOBJ *bin, ut64 symtab_offset, ut64 strtab_offset) {
if (symtab_offset > strtab_offset) {
return 0;
}
ut64 symtab_size = strtab_offset - symtab_offset;
return symtab_size / sizeof(Elf_(Sym));
}
static Elf_(Word) get_number_of_symbols_from_heuristic(ELFOBJ *bin) {
ut64 symtab_addr;
ut64 strtab_addr;
if (!Elf_(rz_bin_elf_get_dt_info)(bin, DT_SYMTAB, &symtab_addr) || !Elf_(rz_bin_elf_get_dt_info)(bin, DT_STRTAB, &strtab_addr)) {
return 0;
}
ut64 symtab_offset = Elf_(rz_bin_elf_v2p_new)(bin, symtab_addr);
ut64 strtab_offset = Elf_(rz_bin_elf_v2p_new)(bin, strtab_addr);
if (symtab_offset == UT64_MAX || strtab_offset == UT64_MAX) {
return 0;
}
return get_number_of_symbols_from_heuristic_aux(bin, symtab_offset, strtab_offset);
}
static Elf_(Word) get_number_of_symbols_from_section(ELFOBJ *bin) {
RzBinElfSection *section = Elf_(rz_bin_elf_get_section_with_name)(bin, ".dynsym");
if (!section) {
return 0;
}
return section->size / sizeof(Elf_(Sym));
}
static bool is_special_arm_symbol(ELFOBJ *bin, Elf_(Sym) * sym, const char *name) {
if (!name) {
return false;
}
if (name[0] != '$') {
return false;
}
if (name[1] == 'a' || name[1] == 't' || name[1] == 'd' || name[1] == 'x') {
return (name[2] == '\0' || name[2] == '.') &&
ELF_ST_TYPE(sym->st_info) == STT_NOTYPE &&
ELF_ST_BIND(sym->st_info) == STB_LOCAL &&
ELF_ST_VISIBILITY(sym->st_info) == STV_DEFAULT;
}
return false;
}
static bool is_special_symbol(ELFOBJ *bin, Elf_(Sym) * sym, const char *name) {
switch (bin->ehdr.e_machine) {
case EM_ARM:
case EM_AARCH64:
return is_special_arm_symbol(bin, sym, name);
default:
return false;
}
}
static const char *symbol_type_to_str(ELFOBJ *bin, RzBinElfSymbol *ret, Elf_(Sym) * sym) {
if (bin && ret && is_special_symbol(bin, sym, ret->name)) {
return RZ_BIN_TYPE_SPECIAL_SYM_STR;
}
for (size_t i = 0; i < RZ_ARRAY_SIZE(symbol_type_translation_table); i++) {
if (ELF_ST_TYPE(sym->st_info) == symbol_type_translation_table[i].type) {
return symbol_type_translation_table[i].name;
}
}
return RZ_BIN_TYPE_UNKNOWN_STR;
}
static const char *symbol_bind_to_str(Elf_(Sym) * sym) {
for (size_t i = 0; i < RZ_ARRAY_SIZE(symbol_bind_translation_table); i++) {
if (ELF_ST_BIND(sym->st_info) == symbol_bind_translation_table[i].bind) {
return symbol_bind_translation_table[i].name;
}
}
return RZ_BIN_BIND_UNKNOWN_STR;
}
static bool get_symbol_entry_aux(ELFOBJ *bin, ut64 offset, Elf_(Sym) * result) {
#if RZ_BIN_ELF64
return Elf_(rz_bin_elf_read_word)(bin, &offset, &result->st_name) &&
Elf_(rz_bin_elf_read_char)(bin, &offset, &result->st_info) &&
Elf_(rz_bin_elf_read_char)(bin, &offset, &result->st_other) &&
Elf_(rz_bin_elf_read_section)(bin, &offset, &result->st_shndx) &&
Elf_(rz_bin_elf_read_addr)(bin, &offset, &result->st_value) &&
Elf_(rz_bin_elf_read_xword)(bin, &offset, &result->st_size);
#else
return Elf_(rz_bin_elf_read_word)(bin, &offset, &result->st_name) &&
Elf_(rz_bin_elf_read_addr)(bin, &offset, &result->st_value) &&
Elf_(rz_bin_elf_read_word)(bin, &offset, &result->st_size) &&
Elf_(rz_bin_elf_read_char)(bin, &offset, &result->st_info) &&
Elf_(rz_bin_elf_read_char)(bin, &offset, &result->st_other) &&
Elf_(rz_bin_elf_read_section)(bin, &offset, &result->st_shndx);
#endif
}
static bool get_symbol_entry(ELFOBJ *bin, ut64 offset, Elf_(Sym) * result) {
if (!get_symbol_entry_aux(bin, offset, result)) {
RZ_LOG_WARN("Failed to read symbol entry at 0x%" PFMT64x ".\n", offset);
return false;
}
return true;
}
static bool is_section_local_symbol(ELFOBJ *bin, Elf_(Sym) * symbol) {
if (symbol->st_name != 0) {
return false;
}
if (ELF_ST_TYPE(symbol->st_info) != STT_SECTION) {
return false;
}
if (ELF_ST_BIND(symbol->st_info) != STB_LOCAL) {
return false;
}
if (symbol->st_shndx >= bin->ehdr.e_shnum) {
return false;
}
return true;
}
static bool set_elf_symbol_name(ELFOBJ *bin, struct symbols_segment *segment, RzBinElfSymbol *elf_symbol, Elf_(Sym) * symbol, RzBinElfSection *section) {
if (section && is_section_local_symbol(bin, symbol)) {
elf_symbol->name = rz_str_new(section->name);
return elf_symbol->name;
}
if (!segment->strtab) {
return false;
}
elf_symbol->name = Elf_(rz_bin_elf_strtab_get_dup)(segment->strtab, symbol->st_name);
if (!elf_symbol->name) {
return false;
}
return true;
}
static bool convert_elf_symbol_entry(ELFOBJ *bin, struct symbols_segment *segment, RzBinElfSymbol *elf_symbol, Elf_(Sym) * symbol, size_t ordinal) {
RzBinElfSection *section = Elf_(rz_bin_elf_get_section)(bin, symbol->st_shndx);
elf_symbol->bind = symbol_bind_to_str(symbol);
elf_symbol->ordinal = ordinal;
elf_symbol->size = symbol->st_size;
if (Elf_(rz_bin_elf_is_relocatable)(bin) && section) {
elf_symbol->paddr = section->offset + symbol->st_value;
elf_symbol->vaddr = Elf_(rz_bin_elf_p2v_new)(bin, elf_symbol->paddr);
} else {
elf_symbol->vaddr = symbol->st_value;
elf_symbol->paddr = Elf_(rz_bin_elf_v2p_new)(bin, elf_symbol->vaddr);
}
if (!set_elf_symbol_name(bin, segment, elf_symbol, symbol, section)) {
return false;
}
elf_symbol->type = symbol_type_to_str(bin, elf_symbol, symbol);
return true;
}
static bool has_already_been_processed(ELFOBJ *bin, ut64 offset, HtUU *set) {
bool found;
ht_uu_find(set, offset, &found);
return found;
}
static void elf_symbol_fini(void *e, RZ_UNUSED void *user) {
RzBinElfSymbol *ptr = e;
free(ptr->name);
}
static bool compute_symbols_from_segment(ELFOBJ *bin, RzVector *result, struct symbols_segment *segment, RzBinElfSymbolFilter filter, HtUU *set) {
ut64 offset = segment->offset + segment->entry_size;
for (size_t i = 1; i < segment->number; i++) {
if (has_already_been_processed(bin, offset, set)) {
offset += segment->entry_size;
continue;
}
if (!ht_uu_insert(set, offset, offset)) {
return false;
}
Elf_(Sym) entry;
if (!get_symbol_entry(bin, offset, &entry)) {
return false;
}
if (!filter(bin, &entry, segment->dynamic)) {
offset += segment->entry_size;
continue;
}
RzBinElfSymbol symbol = { 0 };
if (!convert_elf_symbol_entry(bin, segment, &symbol, &entry, i)) {
return false;
}
if (!rz_vector_push(result, &symbol)) {
elf_symbol_fini(&symbol, NULL);
return false;
}
offset += segment->entry_size;
}
return true;
}
static bool get_dynamic_elf_symbols(ELFOBJ *bin, RzVector *result, RzBinElfSymbolFilter filter, HtUU *set) {
if (!Elf_(rz_bin_elf_is_executable)(bin)) {
return true;
}
ut64 addr;
ut64 entry_size;
if (!Elf_(rz_bin_elf_get_dt_info)(bin, DT_SYMTAB, &addr) || !Elf_(rz_bin_elf_get_dt_info)(bin, DT_SYMENT, &entry_size)) {
return true;
}
ut64 offset = Elf_(rz_bin_elf_v2p_new)(bin, addr);
if (offset == UT64_MAX) {
return true;
}
Elf_(Word) number = Elf_(rz_bin_elf_get_number_of_dynamic_symbols)(bin);
if (!number) {
return true;
}
struct symbols_segment segment = symbols_segment_init(offset, number, entry_size, true, bin->dynstr);
if (!compute_symbols_from_segment(bin, result, &segment, filter, set)) {
return false;
}
return true;
}
static bool get_section_elf_symbols(ELFOBJ *bin, RzVector *result, RzBinElfSymbolFilter filter, HtUU *set) {
size_t i;
RzBinElfSection *section;
rz_bin_elf_enumerate_sections(bin, section, i) {
if (!section->is_valid) {
continue;
}
if (section->type != SHT_SYMTAB && section->type != SHT_DYNSYM) {
continue;
}
if (!section->link) {
RZ_LOG_WARN("The section %zu has a null link.\n", i);
continue;
}
RzBinElfSection *strtab_section = Elf_(rz_bin_elf_get_section)(bin, section->link);
if (!strtab_section) {
continue;
}
RzBinElfStrtab *strtab = Elf_(rz_bin_elf_strtab_new)(bin, strtab_section->offset, strtab_section->size);
if (!strtab) {
continue;
}
ut64 number = (section->size / sizeof(Elf_(Sym)));
struct symbols_segment segment = symbols_segment_init(section->offset, number, sizeof(Elf_(Sym)), false, strtab);
if (!compute_symbols_from_segment(bin, result, &segment, filter, set)) {
Elf_(rz_bin_elf_strtab_free)(strtab);
return false;
}
Elf_(rz_bin_elf_strtab_free)(strtab);
}
return true;
}
static bool filter_symbol(RZ_UNUSED ELFOBJ *bin, Elf_(Sym) * symbol, RZ_UNUSED bool is_dynamic) {
return symbol->st_shndx != SHT_NULL;
}
Elf_(Word) Elf_(rz_bin_elf_get_number_of_dynamic_symbols)(RZ_NONNULL ELFOBJ *bin) {
rz_return_val_if_fail(bin, 0);
Elf_(Word) result = Elf_(rz_bin_elf_get_number_of_symbols_from_hash_table)(bin);
if (result) {
return result;
}
result = Elf_(rz_bin_elf_get_number_of_symbols_from_gnu_hash_table)(bin);
if (result) {
return result;
}
RZ_LOG_WARN("Neither hash nor gnu_hash exist. Falling back to heuristics for deducing the number of dynamic symbols...\n");
result = get_number_of_symbols_from_section(bin);
if (result) {
return result;
}
result = get_number_of_symbols_from_heuristic(bin);
if (result) {
return result;
}
RZ_LOG_ERROR("Failed to determine the number of dynamic symbols from heuristics.\n");
return 0;
}
RZ_BORROW RzBinElfSymbol *Elf_(rz_bin_elf_get_symbol)(RZ_NONNULL ELFOBJ *bin, ut32 ordinal) {
rz_return_val_if_fail(bin, NULL);
RzBinElfSymbol *symbol;
rz_bin_elf_foreach_symbols(bin, symbol) {
if (symbol->ordinal == ordinal) {
return symbol;
}
}
return NULL;
}
RZ_OWN RzVector *Elf_(rz_bin_elf_compute_symbols)(ELFOBJ *bin, RzBinElfSymbolFilter filter) {
RzVector *result = rz_vector_new(sizeof(RzBinElfSymbol), elf_symbol_fini, NULL);
if (!result) {
return NULL;
}
HtUU *set = ht_uu_new0();
if (!set) {
rz_vector_free(result);
return NULL;
}
if (!get_dynamic_elf_symbols(bin, result, filter, set)) {
rz_vector_free(result);
ht_uu_free(set);
return NULL;
}
if (!get_section_elf_symbols(bin, result, filter, set)) {
rz_vector_free(result);
ht_uu_free(set);
return NULL;
}
ht_uu_free(set);
if (!rz_vector_len(result)) {
rz_vector_free(result);
return NULL;
}
return result;
}
RZ_OWN RzVector *Elf_(rz_bin_elf_symbols_new)(RZ_NONNULL ELFOBJ *bin) {
rz_return_val_if_fail(bin, NULL);
RzVector *result = Elf_(rz_bin_elf_compute_symbols)(bin, filter_symbol);
if (!result) {
return NULL;
}
return result;
}
bool Elf_(rz_bin_elf_has_symbols)(RZ_NONNULL ELFOBJ *bin) {
rz_return_val_if_fail(bin, false);
return bin->symbols;
}
| 26.8061 | 153 | 0.725699 |
a92855f6e22a0f1c734247a159aa5050a43297fb | 19,332 | h | C | boards/spracing/h7extreme/nuttx-config/include/board.h | qperrotElistair/Firmware | 60d613ea049bc04cf37487f0226e3e754cd20572 | [
"BSD-3-Clause"
] | 2 | 2021-02-01T02:13:25.000Z | 2021-04-04T00:25:00.000Z | boards/spracing/h7extreme/nuttx-config/include/board.h | qperrotElistair/Firmware | 60d613ea049bc04cf37487f0226e3e754cd20572 | [
"BSD-3-Clause"
] | 16 | 2020-12-26T13:03:01.000Z | 2021-01-17T09:58:43.000Z | boards/spracing/h7extreme/nuttx-config/include/board.h | qperrotElistair/Firmware | 60d613ea049bc04cf37487f0226e3e754cd20572 | [
"BSD-3-Clause"
] | 4 | 2020-12-08T07:09:15.000Z | 2021-05-12T05:14:23.000Z | /************************************************************************************
* nuttx-configs/spracing/h7extreme/include/board.h
*
* Copyright (C) 2016-2020 Gregory Nutt. All rights reserved.
* Authors: Igor Misic <igy1000mb@gmail.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
************************************************************************************/
#ifndef __NUTTX_CONFIG_SPRACING_H7EXTREME_INCLUDE_BOARD_H
#define __NUTTX_CONFIG_SPRACING_H7EXTREME_INCLUDE_BOARD_H
/************************************************************************************
* Included Files
************************************************************************************/
#include "board_dma_map.h"
#include <nuttx/config.h>
#ifndef __ASSEMBLY__
# include <stdint.h>
#endif
#include "stm32_rcc.h"
#include "stm32_sdmmc.h"
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
/* Clocking *************************************************************************/
/* The sp racing h7 extreme board provides the following clock sources:
*
* X1: 25 MHz crystal for HSE
*
* So we have these clock source available within the STM32
*
* HSI: 64 MHz RC factory-trimmed
* HSE: 25 MHz crystal for HSE
*/
#define STM32_BOARD_XTAL 8000000ul
#define STM32_HSI_FREQUENCY 16000000ul
#define STM32_LSI_FREQUENCY 32000
#define STM32_HSE_FREQUENCY STM32_BOARD_XTAL
#define STM32_LSE_FREQUENCY 32768
/* Main PLL Configuration.
*
* PLL source is HSE = 8,000,000
*
* PLL_VCOx = (STM32_HSE_FREQUENCY / PLLM) * PLLN
* Subject to:
*
* 1 <= PLLM <= 63
* 4 <= PLLN <= 512
* 150 MHz <= PLL_VCOL <= 420MHz
* 192 MHz <= PLL_VCOH <= 836MHz
*
* SYSCLK = PLL_VCO / PLLP
* CPUCLK = SYSCLK / D1CPRE
* Subject to
*
* PLLP1 = {2, 4, 6, 8, ..., 128}
* PLLP2,3 = {2, 3, 4, ..., 128}
* CPUCLK <= 480 MHz
*/
#define STM32_BOARD_USEHSE
#define STM32_PLLCFG_PLLSRC RCC_PLLCKSELR_PLLSRC_HSE
/* PLL1, wide 4 - 8 MHz input, enable DIVP, DIVQ, DIVR
*
* PLL1_VCO = (25,000,000 / 5) * 160 = 800 MHz
*
* PLL1P = PLL1_VCO/2 = 800 MHz / 2 = 400 MHz
* PLL1Q = PLL1_VCO/4 = 800 MHz / 4 = 200 MHz
* PLL1R = PLL1_VCO/8 = 800 MHz / 8 = 100 MHz
*/
#define STM32_PLLCFG_PLL1CFG (RCC_PLLCFGR_PLL1VCOSEL_WIDE | \
RCC_PLLCFGR_PLL1RGE_4_8_MHZ | \
RCC_PLLCFGR_DIVP1EN | \
RCC_PLLCFGR_DIVQ1EN | \
RCC_PLLCFGR_DIVR1EN)
#define STM32_PLLCFG_PLL1M RCC_PLLCKSELR_DIVM1(2)
#define STM32_PLLCFG_PLL1N RCC_PLL1DIVR_N1(200)
#define STM32_PLLCFG_PLL1P RCC_PLL1DIVR_P1(2)
#define STM32_PLLCFG_PLL1Q RCC_PLL1DIVR_Q1(4)
#define STM32_PLLCFG_PLL1R RCC_PLL1DIVR_R1(2)
#define STM32_VCO1_FREQUENCY ((STM32_HSE_FREQUENCY / 2) * 200)
#define STM32_PLL1P_FREQUENCY (STM32_VCO1_FREQUENCY / 2)
#define STM32_PLL1Q_FREQUENCY (STM32_VCO1_FREQUENCY / 4)
#define STM32_PLL1R_FREQUENCY (STM32_VCO1_FREQUENCY / 2)
/* PLL2 */
#define STM32_PLLCFG_PLL2CFG (RCC_PLLCFGR_PLL2VCOSEL_WIDE | \
RCC_PLLCFGR_PLL2RGE_4_8_MHZ | \
RCC_PLLCFGR_DIVP2EN | \
RCC_PLLCFGR_DIVQ2EN | \
RCC_PLLCFGR_DIVR2EN)
#define STM32_PLLCFG_PLL2M RCC_PLLCKSELR_DIVM2(4)
#define STM32_PLLCFG_PLL2N RCC_PLL2DIVR_N2(260)
#define STM32_PLLCFG_PLL2P RCC_PLL2DIVR_P2(2)
#define STM32_PLLCFG_PLL2Q RCC_PLL2DIVR_Q2(10)
#define STM32_PLLCFG_PLL2R RCC_PLL2DIVR_R2(2)
#define STM32_VCO2_FREQUENCY ((STM32_HSE_FREQUENCY / 4) * 260)
#define STM32_PLL2P_FREQUENCY (STM32_VCO2_FREQUENCY / 2)
#define STM32_PLL2Q_FREQUENCY (STM32_VCO2_FREQUENCY / 10)
#define STM32_PLL2R_FREQUENCY (STM32_VCO2_FREQUENCY / 2)
/* PLL3 */
#define STM32_PLLCFG_PLL3CFG (RCC_PLLCFGR_PLL3VCOSEL_WIDE | \
RCC_PLLCFGR_PLL3RGE_4_8_MHZ | \
RCC_PLLCFGR_DIVP3EN | \
RCC_PLLCFGR_DIVQ3EN | \
RCC_PLLCFGR_DIVR3EN)
#define STM32_PLLCFG_PLL3M RCC_PLLCKSELR_DIVM3(2)
#define STM32_PLLCFG_PLL3N RCC_PLL3DIVR_N3(50)
#define STM32_PLLCFG_PLL3P RCC_PLL3DIVR_P3(2)
#define STM32_PLLCFG_PLL3Q RCC_PLL3DIVR_Q3(2)
#define STM32_PLLCFG_PLL3R RCC_PLL3DIVR_R3(2)
#define STM32_VCO3_FREQUENCY ((STM32_HSE_FREQUENCY / 2) * 50)
#define STM32_PLL3P_FREQUENCY (STM32_VCO3_FREQUENCY / 2)
#define STM32_PLL3Q_FREQUENCY (STM32_VCO3_FREQUENCY / 2)
#define STM32_PLL3R_FREQUENCY (STM32_VCO3_FREQUENCY / 2)
/* SYSCLK = PLL1P = 400MHz
* CPUCLK = SYSCLK / 1 = 400 MHz
*/
#define STM32_RCC_D1CFGR_D1CPRE (RCC_D1CFGR_D1CPRE_SYSCLK)
#define STM32_SYSCLK_FREQUENCY (STM32_PLL1P_FREQUENCY)
#define STM32_CPUCLK_FREQUENCY (STM32_SYSCLK_FREQUENCY / 1)
/* Configure Clock Assignments */
/* AHB clock (HCLK) is SYSCLK/2 (200 MHz max)
* HCLK1 = HCLK2 = HCLK3 = HCLK4 = 200
*/
#define STM32_RCC_D1CFGR_HPRE RCC_D1CFGR_HPRE_SYSCLKd2 /* HCLK = SYSCLK / 2 */
#define STM32_ACLK_FREQUENCY (STM32_CPUCLK_FREQUENCY / 2) /* ACLK in D1, HCLK3 in D1 */
#define STM32_HCLK_FREQUENCY (STM32_CPUCLK_FREQUENCY / 2) /* HCLK in D2, HCLK4 in D3 */
#define STM32_BOARD_HCLK STM32_HCLK_FREQUENCY /* same as above, to satisfy compiler */
/* APB1 clock (PCLK1) is HCLK/2 (100 MHz) */
#define STM32_RCC_D2CFGR_D2PPRE1 RCC_D2CFGR_D2PPRE1_HCLKd2 /* PCLK1 = HCLK / 2 */
#define STM32_PCLK1_FREQUENCY (STM32_HCLK_FREQUENCY/2)
/* APB2 clock (PCLK2) is HCLK/2 (50 MHz) */
#define STM32_RCC_D2CFGR_D2PPRE2 RCC_D2CFGR_D2PPRE2_HCLKd2 /* PCLK2 = HCLK / 2 */
#define STM32_PCLK2_FREQUENCY (STM32_HCLK_FREQUENCY/2)
/* APB3 clock (PCLK3) is HCLK/2 (50 MHz) */
#define STM32_RCC_D1CFGR_D1PPRE RCC_D1CFGR_D1PPRE_HCLKd2 /* PCLK3 = HCLK / 2 */
#define STM32_PCLK3_FREQUENCY (STM32_HCLK_FREQUENCY/2)
/* APB4 clock (PCLK4) is HCLK/4 (50 MHz) */
#define STM32_RCC_D3CFGR_D3PPRE RCC_D3CFGR_D3PPRE_HCLKd2 /* PCLK4 = HCLK / 2 */
#define STM32_PCLK4_FREQUENCY (STM32_HCLK_FREQUENCY/2)
/* Timer clock frequencies */
/* Timers driven from APB1 will be twice PCLK1 */
#define STM32_APB1_TIM2_CLKIN (2*STM32_PCLK1_FREQUENCY)
#define STM32_APB1_TIM3_CLKIN (2*STM32_PCLK1_FREQUENCY)
#define STM32_APB1_TIM4_CLKIN (2*STM32_PCLK1_FREQUENCY)
#define STM32_APB1_TIM5_CLKIN (2*STM32_PCLK1_FREQUENCY)
#define STM32_APB1_TIM6_CLKIN (2*STM32_PCLK1_FREQUENCY)
#define STM32_APB1_TIM7_CLKIN (2*STM32_PCLK1_FREQUENCY)
#define STM32_APB1_TIM12_CLKIN (2*STM32_PCLK1_FREQUENCY)
#define STM32_APB1_TIM13_CLKIN (2*STM32_PCLK1_FREQUENCY)
#define STM32_APB1_TIM14_CLKIN (2*STM32_PCLK1_FREQUENCY)
/* Timers driven from APB2 will be twice PCLK2 */
#define STM32_APB2_TIM1_CLKIN (2*STM32_PCLK2_FREQUENCY)
#define STM32_APB2_TIM8_CLKIN (2*STM32_PCLK2_FREQUENCY)
#define STM32_APB2_TIM15_CLKIN (2*STM32_PCLK2_FREQUENCY)
#define STM32_APB2_TIM16_CLKIN (2*STM32_PCLK2_FREQUENCY)
#define STM32_APB2_TIM17_CLKIN (2*STM32_PCLK2_FREQUENCY)
/* Kernel Clock Configuration
*
* Note: look at Table 54 in ST Manual
*/
/* I2C123 clock source */
#define STM32_RCC_D2CCIP2R_I2C123SRC RCC_D2CCIP2R_I2C123SEL_HSI
/* SPI123 clock source */
#define STM32_RCC_D2CCIP1R_SPI123SRC RCC_D2CCIP1R_SPI123SEL_PLL1
/* SPI45 clock source */
#define STM32_RCC_D2CCIP1R_SPI45SRC RCC_D2CCIP1R_SPI45SEL_APB
/* USB 1 and 2 clock source */
#define STM32_RCC_D2CCIP2R_USBSRC RCC_D2CCIP2R_USBSEL_HSI48
/* ADC 1 2 3 clock source */
#define STM32_RCC_D3CCIPR_ADCSEL RCC_D3CCIPR_ADCSEL_PLL2
/* QSPI clock source */
#define STM32_RCC_D1CCIPR_QSPISEL RCC_D1CCIPR_QSPISEL_PLL2
/* FLASH wait states
*
* ------------ ---------- -----------
* Vcore MAX ACLK WAIT STATES
* ------------ ---------- -----------
* 1.15-1.26 V 70 MHz 0
* (VOS1 level) 140 MHz 1
* 210 MHz 2
* 1.05-1.15 V 55 MHz 0
* (VOS2 level) 110 MHz 1
* 165 MHz 2
* 220 MHz 3
* 0.95-1.05 V 45 MHz 0
* (VOS3 level) 90 MHz 1
* 135 MHz 2
* 180 MHz 3
* 225 MHz 4
* ------------ ---------- -----------
*/
#define BOARD_FLASH_WAITSTATES 2
/* SDMMC definitions ********************************************************/
/* Init 400kHz, freq = PLL1Q/(2*div) div = PLL1Q/(2*freq) */
#define STM32_SDMMC_INIT_CLKDIV (300 << STM32_SDMMC_CLKCR_CLKDIV_SHIFT)
/* 25 MHz Max for now, 25 mHZ = PLL1Q/(2*div), div = PLL1Q/(2*freq)
* div = 4.8 = 240 / 50, So round up to 5 for default speed 24 MB/s
*/
#if defined(CONFIG_STM32H7_SDMMC_XDMA) || defined(CONFIG_STM32H7_SDMMC_IDMA)
# define STM32_SDMMC_MMCXFR_CLKDIV (5 << STM32_SDMMC_CLKCR_CLKDIV_SHIFT)
#else
# define STM32_SDMMC_MMCXFR_CLKDIV (100 << STM32_SDMMC_CLKCR_CLKDIV_SHIFT)
#endif
#if defined(CONFIG_STM32H7_SDMMC_XDMA) || defined(CONFIG_STM32H7_SDMMC_IDMA)
# define STM32_SDMMC_SDXFR_CLKDIV (5 << STM32_SDMMC_CLKCR_CLKDIV_SHIFT)
#else
# define STM32_SDMMC_SDXFR_CLKDIV (100 << STM32_SDMMC_CLKCR_CLKDIV_SHIFT)
#endif
#define STM32_SDMMC_CLKCR_EDGE STM32_SDMMC_CLKCR_NEGEDGE
/* LED definitions ******************************************************************/
/* The sp racing h7 extreme board has three, LED_GREEN a Green LED, LED_BLUE
* Red LED can be controlled by software.
*
* If CONFIG_ARCH_LEDS is not defined, then the user can control the LEDs in any way.
* The following definitions are used to access individual LEDs.
*/
/* LED index values for use with board_userled() */
#define BOARD_LED1 0
#define BOARD_NLEDS 1
#define BOARD_LED_RED BOARD_LED1
/* LED bits for use with board_userled_all() */
#define BOARD_LED1_BIT (1 << BOARD_LED1)
/* If CONFIG_ARCH_LEDS is defined, the usage by the board port is defined in
* include/board.h and src/stm32_leds.c. The LEDs are used to encode OS-related
* events as follows:
*
*
* SYMBOL Meaning LED state
* Red Green Blue
* ---------------------- -------------------------- ------ ------ ----*/
#define LED_STARTED 0 /* NuttX has been started OFF OFF OFF */
#define LED_HEAPALLOCATE 1 /* Heap has been allocated OFF OFF ON */
#define LED_IRQSENABLED 2 /* Interrupts enabled OFF ON OFF */
#define LED_STACKCREATED 3 /* Idle stack created OFF ON ON */
#define LED_INIRQ 4 /* In an interrupt N/C N/C GLOW */
#define LED_SIGNAL 5 /* In a signal handler N/C GLOW N/C */
#define LED_ASSERTION 6 /* An assertion failed GLOW N/C GLOW */
#define LED_PANIC 7 /* The system has crashed Blink OFF N/C */
#define LED_IDLE 8 /* MCU is in sleep mode ON OFF OFF */
/* Alternate function pin selections ************************************************/
#define GPIO_USART1_RX GPIO_USART1_RX_1 /* PB15 */
#define GPIO_USART1_TX GPIO_USART1_TX_1 /* PB14 */
#define GPIO_USART2_RX 0 /* Not in use */
#define GPIO_USART2_TX GPIO_USART2_TX_2 /* PD5 */
#define GPIO_USART3_RX GPIO_USART3_RX_3 /* PD9 */
#define GPIO_USART3_TX GPIO_USART3_TX_3 /* PD8 */
#define GPIO_UART4_RX GPIO_UART4_RX_5 /* PD0 */
#define GPIO_UART4_TX GPIO_UART4_TX_5 /* PD1 */
#define GPIO_UART5_RX GPIO_UART5_RX_2 /* PB5 */
#define GPIO_UART5_TX GPIO_UART5_TX_1 /* PB13 */
#define GPIO_USART6_RX GPIO_USART6_RX_1 /* PC7 */
#define GPIO_USART6_TX GPIO_USART6_TX_1 /* PC6 */
#define GPIO_UART8_RX GPIO_UART8_RX_1 /* PE0 */
#define GPIO_UART8_TX GPIO_UART8_TX_1 /* PE1 */
/* SPI
* SPI2 is gyro 1
* SPI3 is gyro 2
* SPI4 is BARO
*/
//#define GPIO_SPI1_MISO GPIO_SPI1_MISO_1 /* PA6 */
//#define GPIO_SPI1_MOSI GPIO_SPI1_MOSI_3 /* PD7 */
//#define GPIO_SPI1_SCK GPIO_SPI1_SCK_3 /* PG11 */
#define GPIO_SPI2_MISO GPIO_SPI2_MISO_2 /* PC2 */
#define GPIO_SPI2_MOSI GPIO_SPI2_MOSI_3 /* PC3 */
#define GPIO_SPI2_SCK GPIO_SPI2_SCK_5 /* PD3 */
#define GPIO_SPI3_MISO GPIO_SPI3_MISO_1 /* PB4 */
#define GPIO_SPI3_MOSI GPIO_SPI3_MOSI_1 /* PD6 */
#define GPIO_SPI3_SCK GPIO_SPI3_SCK_1 /* PB3 */
#define GPIO_SPI4_MISO GPIO_SPI4_MISO_1 /* PE13 */
#define GPIO_SPI4_MOSI GPIO_SPI4_MOSI_1 /* PE14 */
#define GPIO_SPI4_SCK GPIO_SPI4_SCK_1 /* PE12 */
/* I2C
*
* Each I2C is associated with a U[S]ART
* hence the naming I2C2_SDA_UART4 in FMU USAGE spreadsheet
*
* The optional _GPIO configurations allow the I2C driver to manually
* reset the bus to clear stuck slaves. They match the pin configuration,
* but are normally-high GPIOs.
*
*/
#define GPIO_I2C1_SCL GPIO_I2C1_SCL_2 /* PB8 */
#define GPIO_I2C1_SDA GPIO_I2C1_SDA_2 /* PB9 */
#define GPIO_I2C1_SCL_GPIO (GPIO_OUTPUT | GPIO_OPENDRAIN |GPIO_SPEED_50MHz | GPIO_OUTPUT_SET | GPIO_PORTB | GPIO_PIN8)
#define GPIO_I2C1_SDA_GPIO (GPIO_OUTPUT | GPIO_OPENDRAIN |GPIO_SPEED_50MHz | GPIO_OUTPUT_SET | GPIO_PORTB | GPIO_PIN9)
/* SDMMC1
*
* VDD 3.3
* GND
* SDMMC1_CK PC12
* SDMMC1_CMD PD2
* SDMMC1_D0 PC8
* SDMMC1_D1 PC9
* SDMMC1_D2 PC10
* SDMMC1_D3 PC11
* GPIO_SDMMC1_NCD PG0
*/
/* USB
*
* OTG_FS_DM PA11
* OTG_FS_DP PA12
* VBUS PA9
*/
/* Board provides GPIO or other Hardware for signaling to timing analyzer */
#if defined(CONFIG_BOARD_USE_PROBES)
# include "stm32_gpio.h"
# define PROBE_N(n) (1<<((n)-1))
# define PROBE_1 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTE|GPIO_PIN14) /* PE14 AUX1 */
# define PROBE_2 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTA|GPIO_PIN10) /* PA10 AUX2 */
# define PROBE_3 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTE|GPIO_PIN11) /* PE11 AUX3 */
# define PROBE_4 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTE|GPIO_PIN9) /* PE9 AUX4 */
# define PROBE_5 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTD|GPIO_PIN13) /* PD13 AUX5 */
# define PROBE_6 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTD|GPIO_PIN14) /* PD14 FMU_CAP6 */
# define PROBE_7 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTH|GPIO_PIN6) /* PH6 FMU_CAP5 */
# define PROBE_8 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTH|GPIO_PIN9) /* PH9 FMU_CAP4 */
# define PROBE_9 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTA|GPIO_PIN5) /* PA5 FMU_CAP3 */
# define PROBE_10 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTB|GPIO_PIN3) /* PB3 FMU_CAP2 */
# define PROBE_11 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTB|GPIO_PIN11) /* PB11 FMU_CAP1 */
# define PROBE_INIT(mask) \
do { \
if ((mask)& PROBE_N(1)) { stm32_configgpio(PROBE_1); } \
if ((mask)& PROBE_N(2)) { stm32_configgpio(PROBE_2); } \
if ((mask)& PROBE_N(3)) { stm32_configgpio(PROBE_3); } \
if ((mask)& PROBE_N(4)) { stm32_configgpio(PROBE_4); } \
if ((mask)& PROBE_N(5)) { stm32_configgpio(PROBE_5); } \
if ((mask)& PROBE_N(6)) { stm32_configgpio(PROBE_6); } \
if ((mask)& PROBE_N(7)) { stm32_configgpio(PROBE_7); } \
if ((mask)& PROBE_N(8)) { stm32_configgpio(PROBE_8); } \
if ((mask)& PROBE_N(9)) { stm32_configgpio(PROBE_9); } \
if ((mask)& PROBE_N(10)) { stm32_configgpio(PROBE_10); } \
if ((mask)& PROBE_N(11)) { stm32_configgpio(PROBE_11); } \
} while(0)
# define PROBE(n,s) do {stm32_gpiowrite(PROBE_##n,(s));}while(0)
# define PROBE_MARK(n) PROBE(n,false);PROBE(n,true)
#else
# define PROBE_INIT(mask)
# define PROBE(n,s)
# define PROBE_MARK(n)
#endif
/* QSPI configuration */
#define CONFIG_STM32H7_QUADSPI
#define CONFIG_STM32H7_QSPI_FLASH_SIZE 16777216 /* bytes */
#define CONFIG_STM32H7_QSPI_FIFO_THESHOLD 1
#define CONFIG_STM32H7_QSPI_CSHT 1 /* HIGH TIME 1 CYCLE */
#define GPIO_QSPI_CS GPIO_QUADSPI_BK1_NCS_3 /* PB10 */
#define GPIO_QSPI_IO0 GPIO_QUADSPI_BK1_IO0_3 /* PD11 */
#define GPIO_QSPI_IO1 GPIO_QUADSPI_BK1_IO1_3 /* PD12 */
#define GPIO_QSPI_IO2 GPIO_QUADSPI_BK1_IO2_1 /* PE2 */
#define GPIO_QSPI_IO3 GPIO_QUADSPI_BK1_IO3_2 /* PD13 */
#define GPIO_QSPI_SCK GPIO_QUADSPI_CLK_1 /* PB2 */
/************************************************************************************
* Public Data
************************************************************************************/
#ifndef __ASSEMBLY__
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/************************************************************************************
* Public Function Prototypes
************************************************************************************/
/************************************************************************************
* Name: stm32_boardinitialize
*
* Description:
* All STM32 architectures must provide the following entry point. This entry point
* is called early in the initialization -- after all memory has been configured
* and mapped but before any devices have been initialized.
*
************************************************************************************/
void stm32_boardinitialize(void);
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __ASSEMBLY__ */
#endif /*__NUTTX_CONFIG_SPRACING_H7EXTREME_INCLUDE_BOARD_H */
| 38.130178 | 135 | 0.6467 |
a9cca1182e36b81b1c60400417501c92f260f0cd | 24,027 | c | C | hw/sensor/src/sensor_oic.c | Nemo157/mynewt-core | 489b115361559814a68bf7beaf3e36f869817a38 | [
"Apache-2.0"
] | 16 | 2020-08-05T18:34:37.000Z | 2021-05-21T14:47:04.000Z | hw/sensor/src/sensor_oic.c | Nemo157/mynewt-core | 489b115361559814a68bf7beaf3e36f869817a38 | [
"Apache-2.0"
] | 2 | 2017-03-23T14:05:51.000Z | 2018-10-24T12:33:52.000Z | hw/sensor/src/sensor_oic.c | Nemo157/mynewt-core | 489b115361559814a68bf7beaf3e36f869817a38 | [
"Apache-2.0"
] | 9 | 2020-08-06T06:49:24.000Z | 2020-12-07T10:08:23.000Z | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#include "os/mynewt.h"
#if MYNEWT_VAL(SENSOR_OIC)
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <assert.h>
#include "sensor/sensor.h"
#include "sensor/accel.h"
#include "sensor/mag.h"
#include "sensor/light.h"
#include "sensor/quat.h"
#include "sensor/euler.h"
#include "sensor/color.h"
#include "sensor/temperature.h"
#include "sensor/pressure.h"
#include "sensor/humidity.h"
#include "sensor/gyro.h"
/* OIC */
#include <oic/oc_rep.h>
#include <oic/oc_ri.h>
#include <oic/oc_ri_const.h>
#include <oic/oc_api.h>
#include <oic/messaging/coap/observe.h>
static const char g_s_oic_dn[] = "x.mynewt.snsr.";
static int
sensor_oic_encode(struct sensor* sensor, void *arg, void *databuf,
sensor_type_t type)
{
if (!databuf) {
return SYS_EINVAL;
}
switch(type) {
/* Gyroscope supported */
case SENSOR_TYPE_GYROSCOPE:
if (((struct sensor_gyro_data *)(databuf))->sgd_x_is_valid) {
oc_rep_set_double(root, x,
((struct sensor_gyro_data *)(databuf))->sgd_x);
} else {
goto err;
}
if (((struct sensor_gyro_data *)(databuf))->sgd_y_is_valid) {
oc_rep_set_double(root, y,
((struct sensor_gyro_data *)(databuf))->sgd_y);
} else {
goto err;
}
if (((struct sensor_gyro_data *)(databuf))->sgd_z_is_valid) {
oc_rep_set_double(root, z,
((struct sensor_gyro_data *)(databuf))->sgd_z);
} else {
goto err;
}
break;
/* Accelerometer functionality supported */
case SENSOR_TYPE_ACCELEROMETER:
/* Linear Accelerometer (Without Gravity) */
case SENSOR_TYPE_LINEAR_ACCEL:
/* Gravity Sensor */
case SENSOR_TYPE_GRAVITY:
if (((struct sensor_accel_data *)(databuf))->sad_x_is_valid) {
oc_rep_set_double(root, x,
((struct sensor_accel_data *)(databuf))->sad_x);
} else {
goto err;
}
if (((struct sensor_accel_data *)(databuf))->sad_y_is_valid) {
oc_rep_set_double(root, y,
((struct sensor_accel_data *)(databuf))->sad_y);
} else {
goto err;
}
if (((struct sensor_accel_data *)(databuf))->sad_z_is_valid) {
oc_rep_set_double(root, z,
((struct sensor_accel_data *)(databuf))->sad_z);
} else {
goto err;
}
break;
/* Magnetic field supported */
case SENSOR_TYPE_MAGNETIC_FIELD:
if (((struct sensor_mag_data *)(databuf))->smd_x_is_valid) {
oc_rep_set_double(root, x,
((struct sensor_mag_data *)(databuf))->smd_x);
} else {
goto err;
}
if (((struct sensor_mag_data *)(databuf))->smd_y_is_valid) {
oc_rep_set_double(root, y,
((struct sensor_mag_data *)(databuf))->smd_y);
} else {
goto err;
}
if (((struct sensor_mag_data *)(databuf))->smd_z_is_valid) {
oc_rep_set_double(root, z,
((struct sensor_mag_data *)(databuf))->smd_z);
} else {
goto err;
}
break;
/* Light supported */
case SENSOR_TYPE_LIGHT:
if (((struct sensor_light_data *)(databuf))->sld_ir_is_valid) {
oc_rep_set_double(root, ir,
((struct sensor_light_data *)(databuf))->sld_ir);
} else {
goto err;
}
if (((struct sensor_light_data *)(databuf))->sld_full_is_valid) {
oc_rep_set_double(root, full,
((struct sensor_light_data *)(databuf))->sld_full);
} else {
goto err;
}
if (((struct sensor_light_data *)(databuf))->sld_lux_is_valid) {
oc_rep_set_double(root, lux,
((struct sensor_light_data *)(databuf))->sld_lux);
} else {
goto err;
}
break;
/* Temperature supported */
case SENSOR_TYPE_TEMPERATURE:
if (((struct sensor_temp_data *)(databuf))->std_temp_is_valid) {
oc_rep_set_double(root, temp,
((struct sensor_temp_data *)(databuf))->std_temp);
}
break;
/* Ambient temperature supported */
case SENSOR_TYPE_AMBIENT_TEMPERATURE:
if (((struct sensor_temp_data *)(databuf))->std_temp_is_valid) {
oc_rep_set_double(root, temp,
((struct sensor_temp_data *)(databuf))->std_temp);
}
break;
/* Pressure sensor supported */
case SENSOR_TYPE_PRESSURE:
if (((struct sensor_press_data *)(databuf))->spd_press_is_valid) {
oc_rep_set_double(root, press,
((struct sensor_press_data *)(databuf))->spd_press);
}
break;
/* Relative humidity supported */
case SENSOR_TYPE_RELATIVE_HUMIDITY:
if (((struct sensor_humid_data *)(databuf))->shd_humid_is_valid) {
oc_rep_set_double(root, humid,
((struct sensor_humid_data *)(databuf))->shd_humid);
}
break;
/* Rotation vector (quaternion) supported */
case SENSOR_TYPE_ROTATION_VECTOR:
if (((struct sensor_quat_data *)(databuf))->sqd_x_is_valid) {
oc_rep_set_double(root, x,
((struct sensor_quat_data *)(databuf))->sqd_x);
} else {
goto err;
}
if (((struct sensor_quat_data *)(databuf))->sqd_y_is_valid) {
oc_rep_set_double(root, y,
((struct sensor_quat_data *)(databuf))->sqd_y);
} else {
goto err;
}
if (((struct sensor_quat_data *)(databuf))->sqd_z_is_valid) {
oc_rep_set_double(root, z,
((struct sensor_quat_data *)(databuf))->sqd_z);
} else {
goto err;
}
if (((struct sensor_quat_data *)(databuf))->sqd_w_is_valid) {
oc_rep_set_double(root, w,
((struct sensor_quat_data *)(databuf))->sqd_w);
} else {
goto err;
}
break;
/* Euler Orientation Sensor */
case SENSOR_TYPE_EULER:
if (((struct sensor_euler_data *)(databuf))->sed_h_is_valid) {
oc_rep_set_double(root, h,
((struct sensor_euler_data *)(databuf))->sed_h);
} else {
goto err;
}
if (((struct sensor_euler_data *)(databuf))->sed_r_is_valid) {
oc_rep_set_double(root, r,
((struct sensor_euler_data *)(databuf))->sed_r);
} else {
goto err;
}
if (((struct sensor_euler_data *)(databuf))->sed_p_is_valid) {
oc_rep_set_double(root, p,
((struct sensor_euler_data *)(databuf))->sed_p);
} else {
goto err;
}
break;
/* Color Sensor */
case SENSOR_TYPE_COLOR:
if (((struct sensor_color_data *)(databuf))->scd_r_is_valid) {
oc_rep_set_uint(root, r,
((struct sensor_color_data *)(databuf))->scd_r);
} else {
goto err;
}
if (((struct sensor_color_data *)(databuf))->scd_g_is_valid) {
oc_rep_set_uint(root, g,
((struct sensor_color_data *)(databuf))->scd_g);
} else {
goto err;
}
if (((struct sensor_color_data *)(databuf))->scd_b_is_valid) {
oc_rep_set_uint(root, b,
((struct sensor_color_data *)(databuf))->scd_b);
} else {
goto err;
}
if (((struct sensor_color_data *)(databuf))->scd_lux_is_valid) {
oc_rep_set_uint(root, lux,
((struct sensor_color_data *)(databuf))->scd_lux);
} else {
goto err;
}
if (((struct sensor_color_data *)(databuf))->scd_colortemp_is_valid) {
oc_rep_set_uint(root, colortemp,
((struct sensor_color_data *)(databuf))->scd_colortemp);
} else {
goto err;
}
if (((struct sensor_color_data *)(databuf))->scd_saturation_is_valid) {
oc_rep_set_uint(root, saturation,
((struct sensor_color_data *)(databuf))->scd_saturation);
} else {
goto err;
}
if (((struct sensor_color_data *)(databuf))->scd_saturation75_is_valid) {
oc_rep_set_uint(root, saturation75,
((struct sensor_color_data *)(databuf))->scd_saturation75);
} else {
goto err;
}
if (((struct sensor_color_data *)(databuf))->scd_is_sat_is_valid) {
oc_rep_set_uint(root, is_sat,
((struct sensor_color_data *)(databuf))->scd_is_sat);
} else {
goto err;
}
if (((struct sensor_color_data *)(databuf))->scd_cratio_is_valid) {
oc_rep_set_double(root, cratio,
((struct sensor_color_data *)(databuf))->scd_cratio);
} else {
goto err;
}
if (((struct sensor_color_data *)(databuf))->scd_maxlux_is_valid) {
oc_rep_set_uint(root, maxlux,
((struct sensor_color_data *)(databuf))->scd_maxlux);
} else {
goto err;
}
if (((struct sensor_color_data *)(databuf))->scd_ir_is_valid) {
oc_rep_set_uint(root, ir,
((struct sensor_color_data *)(databuf))->scd_ir);
} else {
goto err;
}
break;
/* Support for these sensors is currently not there, hence
* encoding would fail for them
*/
/* Proximity sensor supported */
case SENSOR_TYPE_PROXIMITY:
/* Altitude Supported */
case SENSOR_TYPE_ALTITUDE:
/* Weight Supported */
case SENSOR_TYPE_WEIGHT:
/* User defined sensor type 1 */
case SENSOR_TYPE_USER_DEFINED_1:
/* User defined sensor type 2 */
case SENSOR_TYPE_USER_DEFINED_2:
/* User defined sensor type 3 */
case SENSOR_TYPE_USER_DEFINED_3:
/* User defined sensor type 4 */
case SENSOR_TYPE_USER_DEFINED_4:
/* User defined sensor type 5 */
case SENSOR_TYPE_USER_DEFINED_5:
/* User defined sensor type 6 */
case SENSOR_TYPE_USER_DEFINED_6:
/* None */
case SENSOR_TYPE_NONE:
default:
goto err;
}
oc_rep_set_uint(root, ts_secs, (long int)sensor->s_sts.st_ostv.tv_sec);
oc_rep_set_int(root, ts_usecs, (int)sensor->s_sts.st_ostv.tv_usec);
oc_rep_set_uint(root, ts_cputime, (unsigned int)sensor->s_sts.st_cputime);
return 0;
err:
return SYS_EINVAL;
}
static int
sensor_typename_to_type(char *typename, sensor_type_t *type,
struct sensor *sensor)
{
if (!strcmp(typename, "acc")) {
/* Accelerometer functionality supported */
*type = SENSOR_TYPE_ACCELEROMETER;
} else if (!strcmp(typename, "mag")) {
/* Magnetic field supported */
*type = SENSOR_TYPE_MAGNETIC_FIELD;
} else if (!strcmp(typename, "gyr")) {
/* Gyroscope supported */
*type = SENSOR_TYPE_GYROSCOPE;
} else if (!strcmp(typename, "lt")) {
/* Light supported */
*type = SENSOR_TYPE_LIGHT;
} else if (!strcmp(typename, "tmp")) {
/* Temperature supported */
*type = SENSOR_TYPE_TEMPERATURE;
} else if (!strcmp(typename, "ambtmp")) {
/* Ambient temperature supported */
*type = SENSOR_TYPE_AMBIENT_TEMPERATURE;
} else if (!strcmp(typename, "psr")) {
/* Pressure sensor supported */
*type = SENSOR_TYPE_PRESSURE;
} else if (!strcmp(typename, "prox")) {
/* Proximity sensor supported */
*type = SENSOR_TYPE_PROXIMITY;
} else if (!strcmp(typename, "rhmty")) {
/* Relative humidity supported */
*type = SENSOR_TYPE_RELATIVE_HUMIDITY;
} else if (!strcmp(typename, "quat")) {
/* Rotation vector (quaternion)) supported */
*type = SENSOR_TYPE_ROTATION_VECTOR;
} else if (!strcmp(typename, "alt")) {
/* Altitude Supported */
*type = SENSOR_TYPE_ALTITUDE;
} else if (!strcmp(typename, "wt")) {
/* Weight Supported */
*type = SENSOR_TYPE_WEIGHT;
} else if (!strcmp(typename, "lacc")) {
/* Linear Accelerometer (Without Gravity)) */
*type = SENSOR_TYPE_LINEAR_ACCEL;
} else if (!strcmp(typename, "grav")) {
/* Gravity Sensor */
*type = SENSOR_TYPE_GRAVITY;
} else if (!strcmp(typename, "eul")) {
/* Euler Orientation Sensor */
*type = SENSOR_TYPE_EULER;
} else if (!strcmp(typename, "col")) {
/* Color Sensor */
*type = SENSOR_TYPE_COLOR;
} else if (!strcmp(typename, "udef1")) {
/* User defined sensor type 1 */
*type = SENSOR_TYPE_USER_DEFINED_1;
} else if (!strcmp(typename, "udef2")) {
/* User defined sensor type 2 */
*type = SENSOR_TYPE_USER_DEFINED_2;
} else if (!strcmp(typename, "udef3")) {
/* User defined sensor type 3 */
*type = SENSOR_TYPE_USER_DEFINED_3;
} else if (!strcmp(typename, "udef4")) {
/* User defined sensor type 4 */
*type = SENSOR_TYPE_USER_DEFINED_4;
} else if (!strcmp(typename, "udef5")) {
/* User defined sensor type 5 */
*type = SENSOR_TYPE_USER_DEFINED_5;
} else if (!strcmp(typename, "udef6")) {
/* User defined sensor type 6 */
*type = SENSOR_TYPE_USER_DEFINED_6;
} else {
goto err;
}
return SYS_EOK;
err:
return SYS_EINVAL;
}
static int
sensor_type_to_typename(char **typename, sensor_type_t type,
struct sensor *sensor)
{
if (!sensor_mgr_match_bytype(sensor, (void *)&type)) {
goto err;
}
switch(type) {
/* Accelerometer functionality supported */
case SENSOR_TYPE_ACCELEROMETER:
*typename = "acc";
break;
/* Magnetic field supported */
case SENSOR_TYPE_MAGNETIC_FIELD:
*typename = "mag";
break;
/* Gyroscope supported */
case SENSOR_TYPE_GYROSCOPE:
*typename = "gyr";
break;
/* Light supported */
case SENSOR_TYPE_LIGHT:
*typename = "lt";
break;
/* Temperature supported */
case SENSOR_TYPE_TEMPERATURE:
*typename = "tmp";
break;
/* Ambient temperature supported */
case SENSOR_TYPE_AMBIENT_TEMPERATURE:
*typename = "ambtmp";
break;
/* Pressure sensor supported */
case SENSOR_TYPE_PRESSURE:
*typename = "psr";
break;
/* Proximity sensor supported */
case SENSOR_TYPE_PROXIMITY:
*typename = "prox";
break;
/* Relative humidity supported */
case SENSOR_TYPE_RELATIVE_HUMIDITY:
*typename = "rhmty";
break;
/* Rotation vector (quaternion)) supported */
case SENSOR_TYPE_ROTATION_VECTOR:
*typename = "quat";
break;
/* Altitude Supported */
case SENSOR_TYPE_ALTITUDE:
*typename = "alt";
break;
/* Weight Supported */
case SENSOR_TYPE_WEIGHT:
*typename = "wt";
break;
/* Linear Accelerometer (Without Gravity)) */
case SENSOR_TYPE_LINEAR_ACCEL:
*typename = "lacc";
break;
/* Gravity Sensor */
case SENSOR_TYPE_GRAVITY:
*typename = "grav";
break;
/* Euler Orientation Sensor */
case SENSOR_TYPE_EULER:
*typename = "eul";
break;
/* Color Sensor */
case SENSOR_TYPE_COLOR:
*typename = "col";
break;
/* User defined sensor type 1 */
case SENSOR_TYPE_USER_DEFINED_1:
*typename = "udef1";
break;
/* User defined sensor type 2 */
case SENSOR_TYPE_USER_DEFINED_2:
*typename = "udef2";
break;
/* User defined sensor type 3 */
case SENSOR_TYPE_USER_DEFINED_3:
*typename = "udef3";
break;
/* User defined sensor type 4 */
case SENSOR_TYPE_USER_DEFINED_4:
*typename = "udef4";
break;
/* User defined sensor type 5 */
case SENSOR_TYPE_USER_DEFINED_5:
*typename = "udef5";
break;
/* User defined sensor type 6 */
case SENSOR_TYPE_USER_DEFINED_6:
*typename = "udef6";
break;
default:
goto err;
}
return SYS_EOK;
err:
return SYS_EINVAL;
}
static void
sensor_oic_get_data(oc_request_t *request, oc_interface_mask_t interface)
{
int rc;
struct sensor *sensor;
char *devname;
char *typename;
sensor_type_t type;
char tmpstr[COAP_MAX_URI] = {0};
const char s[2] = "/";
memcpy(tmpstr, (char *)&(request->resource->uri.os_str[1]),
request->resource->uri.os_sz - 1);
/* Parse the sensor device name from the uri */
devname = strtok(tmpstr, s);
typename = strtok(NULL, s);
/* Look up sensor by name */
sensor = sensor_mgr_find_next_bydevname(devname, NULL);
if (!sensor) {
rc = SYS_EINVAL;
goto err;
}
if (memcmp(g_s_oic_dn, request->resource->types.oa_arr.s,
sizeof(g_s_oic_dn) - 1)) {
goto err;
}
oc_rep_start_root_object();
switch (interface) {
case OC_IF_BASELINE:
oc_process_baseline_interface(request->resource);
case OC_IF_R:
typename =
&(request->resource->types.oa_arr.s[sizeof(g_s_oic_dn) - 1]);
rc = sensor_typename_to_type(typename, &type, sensor);
if (rc) {
/* Type either not supported by sensor or not found */
goto err;
}
rc = sensor_read(sensor, type, sensor_oic_encode,
(uintptr_t *)SENSOR_IGN_LISTENER,
OS_TIMEOUT_NEVER);
if (rc) {
goto err;
}
break;
default:
break;
}
oc_rep_end_root_object();
oc_send_response(request, OC_STATUS_OK);
return;
err:
oc_send_response(request, OC_STATUS_NOT_FOUND);
}
/**
* Transmit OIC trigger
*
* @param ptr to the sensor
* @param ptr to sensor data
* @param The sensor type
*
* @return 0 on sucess, non-zero on failure
*/
int
sensor_oic_tx_trigger(struct sensor *sensor, void *arg, sensor_type_t type)
{
oc_request_t request = {};
oc_response_t response = {};
oc_response_buffer_t response_buffer;
struct os_mbuf *m = NULL;
struct sensor_type_traits *stt;
int rc;
(void)request;
memset(&response_buffer, 0, sizeof(response_buffer));
stt = sensor_get_type_traits_bytype(type, sensor);
if (!stt->stt_oic_res->num_observers) {
return 0;
}
m = os_msys_get_pkthdr(0, 0);
if (!m) {
rc = SYS_EINVAL;
goto err;
}
response_buffer.buffer = m;
response_buffer.block_offset = NULL;
response.response_buffer = &response_buffer;
request.resource = stt->stt_oic_res;
request.response = &response;
oc_rep_new(m);
oc_rep_start_root_object();
rc = sensor_oic_encode(sensor, NULL, arg, type);
if (rc) {
goto err;
}
oc_rep_end_root_object();
oc_send_response(&request, OC_STATUS_OK);
coap_notify_observers(stt->stt_oic_res, &response_buffer, NULL);
os_mbuf_free_chain(m);
return 0;
err:
return rc;
}
static int
sensor_oic_add_resource(struct sensor *sensor, sensor_type_t type)
{
char *typename;
char tmpstr[COAP_MAX_URI];
struct sensor_type_traits *stt;
int rc;
stt = sensor_get_type_traits_bytype(type, sensor);
if (!stt) {
stt = malloc(sizeof(struct sensor_type_traits));
memset(stt, 0, sizeof(struct sensor_type_traits));
sensor_lock(sensor);
SLIST_INSERT_HEAD(&sensor->s_type_traits_list, stt, stt_next);
sensor_unlock(sensor);
}
typename = NULL;
rc = sensor_type_to_typename(&typename, type, sensor);
if (rc) {
return rc;
}
memset(tmpstr, 0, sizeof(tmpstr));
snprintf(tmpstr, sizeof(tmpstr), "/%s/%s",
sensor->s_dev->od_name, typename);
sensor_lock(sensor);
stt->stt_sensor_type = type;
stt->stt_oic_res = oc_new_resource(tmpstr, 1, 0);
memset(tmpstr, 0, sizeof(tmpstr));
snprintf(tmpstr, sizeof(tmpstr), "%s%s", g_s_oic_dn, typename);
oc_resource_bind_resource_type(stt->stt_oic_res, tmpstr);
oc_resource_bind_resource_interface(stt->stt_oic_res, OC_IF_R);
oc_resource_set_default_interface(stt->stt_oic_res, OC_IF_R);
oc_resource_set_discoverable(stt->stt_oic_res);
#if MYNEWT_VAL(SENSOR_OIC_PERIODIC)
oc_resource_set_periodic_observable_ms(stt->stt_oic_res,
MYNEWT_VAL(SENSOR_OIC_OBS_RATE));
#else
oc_resource_set_observable(stt->stt_oic_res);
#endif
oc_resource_set_request_handler(stt->stt_oic_res, OC_GET,
sensor_oic_get_data);
oc_add_resource(stt->stt_oic_res);
sensor_unlock(sensor);
return 0;
}
/*
* Iterates through the sensor list and initializes OIC resources
* based on each sensor type
*/
void
sensor_oic_init(void)
{
struct sensor *sensor;
sensor_type_t type;
int i;
int rc;
sensor = NULL;
while (1) {
sensor_mgr_lock();
sensor = sensor_mgr_find_next_bytype(SENSOR_TYPE_ALL, sensor);
sensor_mgr_unlock();
if (sensor == NULL) {
/* Sensor not found */
break;
}
i = 0;
/* Iterate through N types of sensors */
while (i < 32) {
type = (1 << i);
if (sensor_mgr_match_bytype(sensor, &type)) {
rc = sensor_oic_add_resource(sensor, type);
if (rc) {
break;
}
sensor_trigger_init(sensor, type, sensor_oic_tx_trigger);
}
i++;
}
}
}
#endif
| 31.993342 | 85 | 0.555042 |
aa5adbb6eb5d48d3f573f83c227d45632f44a2c8 | 5,210 | c | C | linux-4.14.90-dev/linux-4.14.90/sound/usb/6fire/midi.c | bingchunjin/1806_SDK | d5ed0258fc22f60e00ec025b802d175f33da6e41 | [
"MIT"
] | 34 | 2019-07-19T20:44:15.000Z | 2022-03-07T12:09:00.000Z | linux-4.14.90-dev/linux-4.14.90/sound/usb/6fire/midi.c | bingchunjin/1806_SDK | d5ed0258fc22f60e00ec025b802d175f33da6e41 | [
"MIT"
] | 5 | 2020-04-04T09:24:09.000Z | 2020-04-19T12:33:55.000Z | linux-4.14.90-dev/linux-4.14.90/sound/usb/6fire/midi.c | bingchunjin/1806_SDK | d5ed0258fc22f60e00ec025b802d175f33da6e41 | [
"MIT"
] | 30 | 2018-05-02T08:43:27.000Z | 2022-01-23T03:25:54.000Z | /*
* Linux driver for TerraTec DMX 6Fire USB
*
* Rawmidi driver
*
* Author: Torsten Schenk <torsten.schenk@zoho.com>
* Created: Jan 01, 2011
* Copyright: (C) Torsten Schenk
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#include <sound/rawmidi.h>
#include "midi.h"
#include "chip.h"
#include "comm.h"
enum {
MIDI_BUFSIZE = 64
};
static void usb6fire_midi_out_handler(struct urb *urb)
{
struct midi_runtime *rt = urb->context;
int ret;
unsigned long flags;
spin_lock_irqsave(&rt->out_lock, flags);
if (rt->out) {
ret = snd_rawmidi_transmit(rt->out, rt->out_buffer + 4,
MIDI_BUFSIZE - 4);
if (ret > 0) { /* more data available, send next packet */
rt->out_buffer[1] = ret + 2;
rt->out_buffer[3] = rt->out_serial++;
urb->transfer_buffer_length = ret + 4;
ret = usb_submit_urb(urb, GFP_ATOMIC);
if (ret < 0)
dev_err(&urb->dev->dev,
"midi out urb submit failed: %d\n",
ret);
} else /* no more data to transmit */
rt->out = NULL;
}
spin_unlock_irqrestore(&rt->out_lock, flags);
}
static void usb6fire_midi_in_received(
struct midi_runtime *rt, u8 *data, int length)
{
unsigned long flags;
spin_lock_irqsave(&rt->in_lock, flags);
if (rt->in)
snd_rawmidi_receive(rt->in, data, length);
spin_unlock_irqrestore(&rt->in_lock, flags);
}
static int usb6fire_midi_out_open(struct snd_rawmidi_substream *alsa_sub)
{
return 0;
}
static int usb6fire_midi_out_close(struct snd_rawmidi_substream *alsa_sub)
{
return 0;
}
static void usb6fire_midi_out_trigger(
struct snd_rawmidi_substream *alsa_sub, int up)
{
struct midi_runtime *rt = alsa_sub->rmidi->private_data;
struct urb *urb = &rt->out_urb;
__s8 ret;
unsigned long flags;
spin_lock_irqsave(&rt->out_lock, flags);
if (up) { /* start transfer */
if (rt->out) { /* we are already transmitting so just return */
spin_unlock_irqrestore(&rt->out_lock, flags);
return;
}
ret = snd_rawmidi_transmit(alsa_sub, rt->out_buffer + 4,
MIDI_BUFSIZE - 4);
if (ret > 0) {
rt->out_buffer[1] = ret + 2;
rt->out_buffer[3] = rt->out_serial++;
urb->transfer_buffer_length = ret + 4;
ret = usb_submit_urb(urb, GFP_ATOMIC);
if (ret < 0)
dev_err(&urb->dev->dev,
"midi out urb submit failed: %d\n",
ret);
else
rt->out = alsa_sub;
}
} else if (rt->out == alsa_sub)
rt->out = NULL;
spin_unlock_irqrestore(&rt->out_lock, flags);
}
static void usb6fire_midi_out_drain(struct snd_rawmidi_substream *alsa_sub)
{
struct midi_runtime *rt = alsa_sub->rmidi->private_data;
int retry = 0;
while (rt->out && retry++ < 100)
msleep(10);
}
static int usb6fire_midi_in_open(struct snd_rawmidi_substream *alsa_sub)
{
return 0;
}
static int usb6fire_midi_in_close(struct snd_rawmidi_substream *alsa_sub)
{
return 0;
}
static void usb6fire_midi_in_trigger(
struct snd_rawmidi_substream *alsa_sub, int up)
{
struct midi_runtime *rt = alsa_sub->rmidi->private_data;
unsigned long flags;
spin_lock_irqsave(&rt->in_lock, flags);
if (up)
rt->in = alsa_sub;
else
rt->in = NULL;
spin_unlock_irqrestore(&rt->in_lock, flags);
}
static const struct snd_rawmidi_ops out_ops = {
.open = usb6fire_midi_out_open,
.close = usb6fire_midi_out_close,
.trigger = usb6fire_midi_out_trigger,
.drain = usb6fire_midi_out_drain
};
static const struct snd_rawmidi_ops in_ops = {
.open = usb6fire_midi_in_open,
.close = usb6fire_midi_in_close,
.trigger = usb6fire_midi_in_trigger
};
int usb6fire_midi_init(struct sfire_chip *chip)
{
int ret;
struct midi_runtime *rt = kzalloc(sizeof(struct midi_runtime),
GFP_KERNEL);
struct comm_runtime *comm_rt = chip->comm;
if (!rt)
return -ENOMEM;
rt->out_buffer = kzalloc(MIDI_BUFSIZE, GFP_KERNEL);
if (!rt->out_buffer) {
kfree(rt);
return -ENOMEM;
}
rt->chip = chip;
rt->in_received = usb6fire_midi_in_received;
rt->out_buffer[0] = 0x80; /* 'send midi' command */
rt->out_buffer[1] = 0x00; /* size of data */
rt->out_buffer[2] = 0x00; /* always 0 */
spin_lock_init(&rt->in_lock);
spin_lock_init(&rt->out_lock);
comm_rt->init_urb(comm_rt, &rt->out_urb, rt->out_buffer, rt,
usb6fire_midi_out_handler);
ret = snd_rawmidi_new(chip->card, "6FireUSB", 0, 1, 1, &rt->instance);
if (ret < 0) {
kfree(rt->out_buffer);
kfree(rt);
dev_err(&chip->dev->dev, "unable to create midi.\n");
return ret;
}
rt->instance->private_data = rt;
strcpy(rt->instance->name, "DMX6FireUSB MIDI");
rt->instance->info_flags = SNDRV_RAWMIDI_INFO_OUTPUT |
SNDRV_RAWMIDI_INFO_INPUT |
SNDRV_RAWMIDI_INFO_DUPLEX;
snd_rawmidi_set_ops(rt->instance, SNDRV_RAWMIDI_STREAM_OUTPUT,
&out_ops);
snd_rawmidi_set_ops(rt->instance, SNDRV_RAWMIDI_STREAM_INPUT,
&in_ops);
chip->midi = rt;
return 0;
}
void usb6fire_midi_abort(struct sfire_chip *chip)
{
struct midi_runtime *rt = chip->midi;
if (rt)
usb_poison_urb(&rt->out_urb);
}
void usb6fire_midi_destroy(struct sfire_chip *chip)
{
struct midi_runtime *rt = chip->midi;
kfree(rt->out_buffer);
kfree(rt);
chip->midi = NULL;
}
| 23.789954 | 75 | 0.705374 |
a627cf5ce15af5fd984c9e108d0397a6085c1d5f | 2,892 | h | C | src/latools/ITSOL_2/INC/ios.h | xywei/Mirana | 81d0ed67fad20cd3be8880ed672c12feff3c22c9 | [
"MIT"
] | null | null | null | src/latools/ITSOL_2/INC/ios.h | xywei/Mirana | 81d0ed67fad20cd3be8880ed672c12feff3c22c9 | [
"MIT"
] | null | null | null | src/latools/ITSOL_2/INC/ios.h | xywei/Mirana | 81d0ed67fad20cd3be8880ed672c12feff3c22c9 | [
"MIT"
] | null | null | null | #define MAX_MAT 100
#define MAX_LINE 256
#define MaxNamLen 64
#define HB 1
#define MM0 2
#define MM1 3
#define UNK 4
typedef struct _io_t {
FILE *fout; /* output file handle */
char outfile[MAX_LINE]; /* output filename */
char Fname[MAX_LINE]; /* full matrix path name */
char MatNam[MaxNamLen]; /* short name */
char PrecMeth[MAX_LINE]; /* preconditioner being tested */
char type[4]; /* type for HB matrices */
int Fmt; /* matrix format type */
int ndim; /* matrix size */
int nnz; /* number of nonzero */
/* parameters from inputs -----------------------------------------*/
int im; /* Dim of Krylov subspace [fgmr] */
int maxits; /* maximum number of fgmres iters */
double tol; /* tolerance for stopping fgmres */
double eps; /* for checking how close two rows of matrix are */
int nparam; /* number of tests for each preconditioner */
int lfil0; /* initial lfil */
int lfilInc; /* increment for lfil */
double tol0; /* initial drop tolerance */
double tolMul; /* multiplier for tol */
int fill_lev; /* initial level of fill for ILUK */
int fill_lev_inc; /* increment for level of fill for ILUK */
/* value always set to 1 */
int perm_type; /* indset perms (0) or PQ perms (1)*/
/* or coarsen (2) */
int Bsize; /* block size - dual role. see input file */
/* for explanations */
/* result for output ----------------------------------------------*/
double rt_v; /* compression rate of vertices */
double rt_e; /* compression rate of edges */
double ceff; /* compression efficiency */
double tm_h; /* time for hash method [vbilu] */
double tm_a; /* time for angle method [vbilu] */
double tm_b; /* time for initial blocks (s) */
double tm_p; /* time for preconditioner (s) */
double tm_i; /* time for iteration (s) */
double fillfact; /* memory used during precondition */
int its; /* number of iterations */
double enorm; /* error norm: || x- x0|| */
double rnorm; /* final residual norm: ||Ax-Ax0|| */
} io_t;
| 56.705882 | 76 | 0.434302 |
43f357e5589fb0ee85715569d32591acbbcea475 | 263 | h | C | Vibe/Plug-ins/MAXON CINEWARE AE/(CINEWARE Support)/lite/resource/modules/shader/description/xcloud.h | kaapiel/Vibe-Rendering-Template | d2aee7aab21dc32831e9e298576caac3db7bdef3 | [
"Apache-2.0"
] | 1 | 2022-02-06T06:24:04.000Z | 2022-02-06T06:24:04.000Z | Vibe/Plug-ins/MAXON CINEWARE AE/(CINEWARE Support)/lite/resource/modules/shader/description/xcloud.h | kaapiel/Vibe-Rendering-Template | d2aee7aab21dc32831e9e298576caac3db7bdef3 | [
"Apache-2.0"
] | null | null | null | Vibe/Plug-ins/MAXON CINEWARE AE/(CINEWARE Support)/lite/resource/modules/shader/description/xcloud.h | kaapiel/Vibe-Rendering-Template | d2aee7aab21dc32831e9e298576caac3db7bdef3 | [
"Apache-2.0"
] | null | null | null | #ifndef XCLOUD_H__
#define XCLOUD_H__
enum
{
CLOUDSHADER_SCALEX = 1002, // REAL
CLOUDSHADER_SCALEY = 1003, // REAL
CLOUDSHADER_LEVEL = 1004, // REAL
CLOUDSHADER_COLOR = 1005, // VECTOR
CLOUDSHADER_COMPATIBILITY = 1006
};
#endif // XCLOUD_H__
| 18.785714 | 40 | 0.69962 |
b745c464dbd4b1540269de50e78d4c97393d4997 | 1,252 | h | C | System/Library/PrivateFrameworks/DiagnosticExtensionsDaemon.framework/DEDWorkerProtocol.h | lechium/iOS1351Headers | 6bed3dada5ffc20366b27f7f2300a24a48a6284e | [
"MIT"
] | 2 | 2021-11-02T09:23:27.000Z | 2022-03-28T08:21:57.000Z | System/Library/PrivateFrameworks/DiagnosticExtensionsDaemon.framework/DEDWorkerProtocol.h | lechium/iOS1351Headers | 6bed3dada5ffc20366b27f7f2300a24a48a6284e | [
"MIT"
] | null | null | null | System/Library/PrivateFrameworks/DiagnosticExtensionsDaemon.framework/DEDWorkerProtocol.h | lechium/iOS1351Headers | 6bed3dada5ffc20366b27f7f2300a24a48a6284e | [
"MIT"
] | 1 | 2022-03-28T08:21:59.000Z | 2022-03-28T08:21:59.000Z | /*
* This header is generated by classdump-dyld 1.5
* on Wednesday, October 27, 2021 at 3:17:52 PM Mountain Standard Time
* Operating System: Version 13.5.1 (Build 17F80)
* Image Source: /System/Library/PrivateFrameworks/DiagnosticExtensionsDaemon.framework/DiagnosticExtensionsDaemon
* classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos. Updated by Kevin Bradley.
*/
@protocol DEDWorkerProtocol <NSObject>
@required
-(long long)transportType;
-(void)cancelSession:(id)arg1;
-(void)pingSession:(id)arg1;
-(void)listAvailableExtensionsForSession:(id)arg1;
-(void)getSessionStatusWithSession:(id)arg1;
-(void)syncSessionStatusWithSession:(id)arg1;
-(void)startDiagnosticWithIdentifier:(id)arg1 parameters:(id)arg2 session:(id)arg3;
-(void)startDiagnosticWithIdentifier:(id)arg1 parameters:(id)arg2 deferRunUntil:(id)arg3 session:(id)arg4;
-(void)scheduleNotificationForSession:(id)arg1;
-(void)cancelNotificationForSession:(id)arg1;
-(void)adoptFiles:(id)arg1 forSession:(id)arg2;
-(void)commitSession:(id)arg1;
-(void)terminateExtension:(id)arg1 info:(id)arg2 session:(id)arg3;
@end
| 44.714286 | 136 | 0.70607 |
2c41cbbd44a9c54f5f93ec9f65cd638c4d8f5177 | 202 | h | C | PYTHIA6/QPYTHIA/qpythiaLinkDef.h | AllaMaevskaya/AliRoot | c53712645bf1c7d5f565b0d3228e3a6b9b09011a | [
"BSD-3-Clause"
] | 52 | 2016-12-11T13:04:01.000Z | 2022-03-11T11:49:35.000Z | PYTHIA6/QPYTHIA/qpythiaLinkDef.h | AllaMaevskaya/AliRoot | c53712645bf1c7d5f565b0d3228e3a6b9b09011a | [
"BSD-3-Clause"
] | 1,388 | 2016-11-01T10:27:36.000Z | 2022-03-30T15:26:09.000Z | PYTHIA6/QPYTHIA/qpythiaLinkDef.h | AllaMaevskaya/AliRoot | c53712645bf1c7d5f565b0d3228e3a6b9b09011a | [
"BSD-3-Clause"
] | 275 | 2016-06-21T20:24:05.000Z | 2022-03-31T13:06:19.000Z | #ifdef __CINT__
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link C++ class AliQPythiaWrapper+;
//#pragma link C++ class AliPythiaRndm+;
#endif
| 20.2 | 42 | 0.747525 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.