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
0d936ed8408afa53d6dc293011ae5505179f4888
1,645
c
C
src/stdin/stdin_next.c
almayor/Lem-in
11d96178316f6121c803b90220843fb5f5d3f383
[ "MIT" ]
1
2022-03-21T17:39:10.000Z
2022-03-21T17:39:10.000Z
src/stdin/stdin_next.c
almayor/lem-in
11d96178316f6121c803b90220843fb5f5d3f383
[ "MIT" ]
null
null
null
src/stdin/stdin_next.c
almayor/lem-in
11d96178316f6121c803b90220843fb5f5d3f383
[ "MIT" ]
null
null
null
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* stdin_next.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: user <user@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/09/09 19:42:02 by unite #+# #+# */ /* Updated: 2020/10/10 23:37:28 by user ### ########.fr */ /* */ /* ************************************************************************** */ #include "stdin.h" static void get_line(t_stdin *in) { in->line = in->ptr; if (!(in->ptr = ft_strchr(in->ptr, '\n'))) terminate(ERR_INVALID_INPUT); *(in->ptr) = '\0'; } const char *stdin_next(t_stdin *in) { ssize_t ret; size_t carryover; if (in->end) return (NULL); in->ptr++; if (ft_strchr(in->ptr, '\n') == NULL) { carryover = ft_strlen(in->ptr); ft_memmove(in->buffer, in->ptr, carryover + 1); in->ptr = in->buffer; ret = read(0, in->buffer + carryover, BUFFER_SIZE - carryover); if (ret < 0) terminate(ERR_STDIN); if (ret == 0) { in->line = in->ptr; in->end = 1; return (in->line); } in->buffer[carryover + ret] = '\0'; write(1, in->buffer + carryover, ret); } get_line(in); return (in->line); }
32.254902
80
0.323404
d9d64776341f47f2cfc2fde90a1d0c550d414d20
1,862
c
C
code/code1.c
chemchemnaresh/AdvancedC
f201a758765f3e3ffb7256f820724596c141b79b
[ "MIT" ]
null
null
null
code/code1.c
chemchemnaresh/AdvancedC
f201a758765f3e3ffb7256f820724596c141b79b
[ "MIT" ]
null
null
null
code/code1.c
chemchemnaresh/AdvancedC
f201a758765f3e3ffb7256f820724596c141b79b
[ "MIT" ]
1
2021-09-08T06:07:26.000Z
2021-09-08T06:07:26.000Z
#include<stdio.h> #include<string.h> #include<stdlib.h> /* * You know that C strings end with a '\0' character, without which string operations would be impossible * because they would not know where to stop processing. But this is not the only way to store strings. * * Dan proposes to store strings in character arrays as follows: * * - The first character n is interpreted as an integer giving the number of characters that constitute the string * The next n characters are the actual contents of the string * * For example, to represent the string * dan * we'd use an array of four characters: 3, 'd', 'a', 'n'. (Remember that a character is just a small int.) * *These are called Dan strings. * * Write the following function that takes a character array representing a Dan string, and allocates and * returns a proper null-terminated C string. s is NOT to be modified. * */ char *dan_to_c(const char *s) { char *ptr = (char *)malloc(s[0]+1); int i; for(i=1;i<s[0]+1;i++) { ptr[i-1] = s[i]; } ptr[i] = '\0'; return ptr; } /* * Write the following function that takes two arrays representing Dan strings and * concatenates the second to the first. s1 is to be modified. * * Assume the array s1 is always large enough. * */ void dan_strcatt(char *s1, const char *s2) { int i,n= s1[0]; for(i=1;i<s2[0]+1;i++) { s1[i+n] = s2[i]; } s1[0] = i-1+s1[0]; } void print(char *ptr,int n) { int i; for(i=1;i<n+1;i++) { printf("%c",ptr[i]); } printf("\n"); } int main() { char d_arr[20] = {6,'N','a','r','e','s','h'}; const char dan[] = {8,'c','h','e','m','c','h','e','m'}; char *a = dan_to_c(dan); printf("a: %s\n",a); dan_strcatt(d_arr,dan); print(d_arr,d_arr[0]); print(dan,dan[0]); return 0; }
23.871795
114
0.607411
8a3b8e87cda863f40a10d419d2afc7e1d2405633
1,462
h
C
include/OGLPlugin/RenderToCubeMap.h
Lut1n/ImpGears
d6fd13715780be41c91f24c9865bb0c2500c4efb
[ "MIT" ]
6
2015-02-23T12:16:26.000Z
2020-10-27T16:20:25.000Z
include/OGLPlugin/RenderToCubeMap.h
Lut1n/ImpGears
d6fd13715780be41c91f24c9865bb0c2500c4efb
[ "MIT" ]
1
2015-02-23T15:29:33.000Z
2015-02-24T22:29:10.000Z
include/OGLPlugin/RenderToCubeMap.h
Lut1n/ImpGears
d6fd13715780be41c91f24c9865bb0c2500c4efb
[ "MIT" ]
2
2015-02-23T13:35:46.000Z
2016-01-23T08:08:12.000Z
#ifndef IMP_RENDER_TO_CUBEMAP_H #define IMP_RENDER_TO_CUBEMAP_H #include <ImpGears/Core/Object.h> #include <ImpGears/Graphics/Sampler.h> #include <ImpGears/Renderer/RenderTarget.h> #include <ImpGears/Renderer/SceneRenderer.h> #include <ImpGears/SceneGraph/Graph.h> #include <ImpGears/SceneGraph/Camera.h> IMPGEARS_BEGIN class GlRenderer; class IMP_API RenderToCubeMap : public Object { public: Meta_Class(RenderToCubeMap) RenderToCubeMap(GlRenderer* renderer, CubeMapSampler::Ptr cubemap = nullptr); virtual ~RenderToCubeMap(); void setCubeMap(CubeMapSampler::Ptr cubemap); CubeMapSampler::Ptr getCubeMap(); void setRange(float near, float far); void setResolution(float resolution); void render(const Graph::Ptr& scene, const Vec3& center, SceneRenderer::RenderFrame frameType = SceneRenderer::RenderFrame_Default, ReflexionModel::Ptr overrideShader = nullptr); void render(RenderQueue::Ptr& queue, const Vec3& center, SceneRenderer::RenderFrame frameType = SceneRenderer::RenderFrame_Default, ReflexionModel::Ptr overrideShader = nullptr); protected: GlRenderer* _renderer; Graph::Ptr _clone; RenderQueue::Ptr _queue; CubeMapSampler::Ptr _cubemap; Matrix4 _proj; Camera::Ptr _camera; State::Ptr _state; Vec3 _directions[6]; Vec3 _upDirections[6]; RenderTarget::Ptr _targets[6]; Vec2 _range; float _resolution; }; IMPGEARS_END #endif // IMP_RENDER_TO_CUBEMAP_H
26.581818
182
0.757866
c06448f53bba104ec20d2c00ec2f26bd90690252
6,038
c
C
drivers/pinctrl/pinctrl_infineon_cat1.c
ifyall/zephyr
5fb80e74f15336fb256bea81f9e4802558de0188
[ "Apache-2.0" ]
null
null
null
drivers/pinctrl/pinctrl_infineon_cat1.c
ifyall/zephyr
5fb80e74f15336fb256bea81f9e4802558de0188
[ "Apache-2.0" ]
1
2022-02-04T15:54:34.000Z
2022-02-04T15:54:34.000Z
drivers/pinctrl/pinctrl_infineon_cat1.c
ifyall/zephyr
5fb80e74f15336fb256bea81f9e4802558de0188
[ "Apache-2.0" ]
1
2022-02-17T20:30:22.000Z
2022-02-17T20:30:22.000Z
/* Copyright 2022 Cypress Semiconductor Corporation (an Infineon company) or * an affiliate of Cypress Semiconductor Corporation * * SPDX-License-Identifier: Apache-2.0 * * 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. */ /** * @brief Pin control driver for Infineon CAT1 MCU family. */ #include <drivers/pinctrl.h> #include <cyhal_gpio.h> #include "cy_gpio.h" #if defined(GPIO_PRT0) #define GPIO0_REG_ADDR DT_REG_ADDR(DT_NODELABEL(gpio_prt0)) #else #define GPIO0_REG_ADDR NULL #endif #if defined(GPIO_PRT1) #define GPIO1_REG_ADDR DT_REG_ADDR(DT_NODELABEL(gpio_prt1)) #else #define GPIO1_REG_ADDR NULL #endif #if defined(GPIO_PRT2) #define GPIO2_REG_ADDR DT_REG_ADDR(DT_NODELABEL(gpio_prt2)) #else #define GPIO2_REG_ADDR NULL #endif #if defined(GPIO_PRT3) #define GPIO3_REG_ADDR DT_REG_ADDR(DT_NODELABEL(gpio_prt3)) #else #define GPIO3_REG_ADDR NULL #endif #if defined(GPIO_PRT4) #define GPIO4_REG_ADDR DT_REG_ADDR(DT_NODELABEL(gpio_prt4)) #else #define GPIO4_REG_ADDR NULL #endif #if defined(GPIO_PRT5) #define GPIO5_REG_ADDR DT_REG_ADDR(DT_NODELABEL(gpio_prt5)) #else #define GPIO5_REG_ADDR NULL #endif #if defined(GPIO_PRT6) #define GPIO6_REG_ADDR DT_REG_ADDR(DT_NODELABEL(gpio_prt6)) #else #define GPIO6_REG_ADDR NULL #endif #if defined(GPIO_PRT7) #define GPIO7_REG_ADDR DT_REG_ADDR(DT_NODELABEL(gpio_prt7)) #else #define GPIO7_REG_ADDR NULL #endif #if defined(GPIO_PRT8) #define GPIO8_REG_ADDR DT_REG_ADDR(DT_NODELABEL(gpio_prt8)) #else #define GPIO8_REG_ADDR NULL #endif #if defined(GPIO_PRT9) #define GPIO9_REG_ADDR DT_REG_ADDR(DT_NODELABEL(gpio_prt9)) #else #define GPIO9_REG_ADDR NULL #endif #if defined(GPIO_PRT10) #define GPIO10_REG_ADDR DT_REG_ADDR(DT_NODELABEL(gpio_prt10)) #else #define GPIO10_REG_ADDR NULL #endif #if defined(GPIO_PRT11) #define GPIO11_REG_ADDR DT_REG_ADDR(DT_NODELABEL(gpio_prt11)) #else #define GPIO11_REG_ADDR NULL #endif #if defined(GPIO_PRT12) #define GPIO12_REG_ADDR DT_REG_ADDR(DT_NODELABEL(gpio_prt12)) #else #define GPIO12_REG_ADDR NULL #endif #if defined(GPIO_PRT12) #define GPIO12_REG_ADDR DT_REG_ADDR(DT_NODELABEL(gpio_prt12)) #else #define GPIO12_REG_ADDR NULL #endif #if defined(GPIO_PRT13) #define GPIO13_REG_ADDR DT_REG_ADDR(DT_NODELABEL(gpio_prt13)) #else #define GPIO13_REG_ADDR NULL #endif #if defined(GPIO_PRT14) #define GPIO14_REG_ADDR DT_REG_ADDR(DT_NODELABEL(gpio_prt14)) #else #define GPIO14_REG_ADDR NULL #endif /* @brief Array containing pointers to each GPIO port. * * Entries will be NULL if the GPIO port is not enabled. */ static GPIO_PRT_Type *const gpio_ports[] = { (GPIO_PRT_Type *) GPIO0_REG_ADDR, (GPIO_PRT_Type *) GPIO1_REG_ADDR, (GPIO_PRT_Type *) GPIO2_REG_ADDR, (GPIO_PRT_Type *) GPIO3_REG_ADDR, (GPIO_PRT_Type *) GPIO4_REG_ADDR, (GPIO_PRT_Type *) GPIO5_REG_ADDR, (GPIO_PRT_Type *) GPIO6_REG_ADDR, (GPIO_PRT_Type *) GPIO7_REG_ADDR, (GPIO_PRT_Type *) GPIO8_REG_ADDR, (GPIO_PRT_Type *) GPIO9_REG_ADDR, (GPIO_PRT_Type *) GPIO10_REG_ADDR, (GPIO_PRT_Type *) GPIO11_REG_ADDR, (GPIO_PRT_Type *) GPIO12_REG_ADDR, (GPIO_PRT_Type *) GPIO13_REG_ADDR, (GPIO_PRT_Type *) GPIO14_REG_ADDR }; /* @brief This function returns gpio drive mode, according to. * bias and drive mode params defined in pinctrl node. * * @param flags - bias and drive mode flags from pinctrl node. */ static uint32_t soc_gpio_get_drv_mode(uint32_t flags) { uint32_t drv_mode = CY_GPIO_DM_ANALOG; flags = ((flags & SOC_GPIO_FLAGS_MASK) >> SOC_GPIO_FLAGS_POS); if (flags & SOC_GPIO_OPENDRAIN) { /* drive_open_drain */ drv_mode = CY_GPIO_DM_OD_DRIVESLOW_IN_OFF; } else if (flags & SOC_GPIO_OPENSOURCE) { /* drive_open_source */ drv_mode = CY_GPIO_DM_OD_DRIVESHIGH_IN_OFF; } else if (flags & SOC_GPIO_PUSHPULL) { /* drive_push_pull */ drv_mode = CY_GPIO_DM_STRONG_IN_OFF; } else if ((flags & SOC_GPIO_PULLUP) && (flags & SOC_GPIO_PULLDOWN)) { /* bias_pull_up and bias_pull_down */ drv_mode = CY_GPIO_DM_PULLUP_DOWN_IN_OFF; } else if (flags & SOC_GPIO_PULLUP) { /* bias_pull_up */ drv_mode = CY_GPIO_DM_PULLUP_IN_OFF; } else if (flags & SOC_GPIO_PULLDOWN) { /* bias_pull_down */ drv_mode = CY_GPIO_DM_PULLDOWN_IN_OFF; } else { ; } if (flags & SOC_GPIO_INPUTENABLE) { /* input_enable */ drv_mode |= CY_GPIO_DM_HIGHZ; } return drv_mode; } cyhal_gpio_t cat1_pinctrl_get_cyhal_gpio(const struct pinctrl_dev_config *config, uint8_t signal_name) { int ret; const struct pinctrl_state *state; ret = pinctrl_lookup_state(config, PINCTRL_STATE_DEFAULT, &state); if (ret != 0) { return NC; } for (uint32_t i = 0u; i < state->pin_cnt; i++) { if (CAT1_PINMUX_GET_SIGNAL(state->pins[i].pinmux) == signal_name) { uint32_t port = CAT1_PINMUX_GET_PORT_NUM(state->pins[i].pinmux); uint32_t pin = CAT1_PINMUX_GET_PIN_NUM(state->pins[i].pinmux); return CYHAL_GET_GPIO(port, pin); } } return NC; } int pinctrl_configure_pins(const pinctrl_soc_pin_t *pins, uint8_t pin_cnt, uintptr_t reg) { for (uint8_t i = 0U; i < pin_cnt; i++) { uint32_t drv_mode = soc_gpio_get_drv_mode(pins[i].pincfg); uint32_t hsiom = CAT1_PINMUX_GET_HSIOM_FUNC(pins[i].pinmux); uint32_t port_num = CAT1_PINMUX_GET_PORT_NUM(pins[i].pinmux); uint32_t pin_num = CAT1_PINMUX_GET_PIN_NUM(pins[i].pinmux); /* Configures the HSIOM connection to the pin */ Cy_GPIO_SetHSIOM(gpio_ports[port_num], pin_num, hsiom); /* Configures the pin output buffer drive mode and input buffer enable */ Cy_GPIO_SetDrivemode(gpio_ports[port_num], pin_num, drv_mode); } return 0; }
25.914163
81
0.76267
a30d83ee8dfcd8e66a2f6b3bf372c1b822038e5c
420
c
C
base/base.c
Dax89/CLib
5de0d324a86a3af32710e1d04dd20adfee58317e
[ "MIT" ]
2
2022-02-03T10:18:10.000Z
2022-02-07T09:19:03.000Z
base/base.c
Dax89/CLib
5de0d324a86a3af32710e1d04dd20adfee58317e
[ "MIT" ]
null
null
null
base/base.c
Dax89/CLib
5de0d324a86a3af32710e1d04dd20adfee58317e
[ "MIT" ]
1
2022-02-03T09:51:51.000Z
2022-02-03T09:51:51.000Z
#include "base.h" const char* ascii_letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; const char* ascii_lowercase = "abcdefghijklmnopqrstuvwxyz"; const char* ascii_uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; const char* digits = "0123456789"; const char* digits_ascii_lowercase = "0123456789abcdefghijklmnopqrstuvwxyz"; const char* digits_ascii_uppercase = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
46.666667
84
0.821429
35af788ed93c856ecd6f8ad0a1218987cc28efc4
2,867
h
C
B2G/external/bluetooth/bluez/audio/device.h
wilebeast/FireFox-OS
43067f28711d78c429a1d6d58c77130f6899135f
[ "Apache-2.0" ]
3
2015-08-31T15:24:31.000Z
2020-04-24T20:31:29.000Z
B2G/external/bluetooth/bluez/audio/device.h
wilebeast/FireFox-OS
43067f28711d78c429a1d6d58c77130f6899135f
[ "Apache-2.0" ]
null
null
null
B2G/external/bluetooth/bluez/audio/device.h
wilebeast/FireFox-OS
43067f28711d78c429a1d6d58c77130f6899135f
[ "Apache-2.0" ]
3
2015-07-29T07:17:15.000Z
2020-11-04T06:55:37.000Z
/* * * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2006-2010 Nokia Corporation * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * * * 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 St, Fifth Floor, Boston, MA 02110-1301 USA * */ #define GENERIC_AUDIO_UUID "00001203-0000-1000-8000-00805f9b34fb" #define HSP_HS_UUID "00001108-0000-1000-8000-00805f9b34fb" #define HSP_AG_UUID "00001112-0000-1000-8000-00805f9b34fb" #define HFP_HS_UUID "0000111e-0000-1000-8000-00805f9b34fb" #define HFP_AG_UUID "0000111f-0000-1000-8000-00805f9b34fb" #define ADVANCED_AUDIO_UUID "0000110d-0000-1000-8000-00805f9b34fb" #define A2DP_SOURCE_UUID "0000110a-0000-1000-8000-00805f9b34fb" #define A2DP_SINK_UUID "0000110b-0000-1000-8000-00805f9b34fb" #define AVRCP_REMOTE_UUID "0000110e-0000-1000-8000-00805f9b34fb" #define AVRCP_TARGET_UUID "0000110c-0000-1000-8000-00805f9b34fb" /* Move these to respective .h files once they exist */ #define AUDIO_SOURCE_INTERFACE "org.bluez.AudioSource" #define AUDIO_CONTROL_INTERFACE "org.bluez.Control" struct source; struct control; struct target; struct sink; struct headset; struct gateway; struct dev_priv; struct audio_device { struct btd_device *btd_dev; DBusConnection *conn; char *path; bdaddr_t src; bdaddr_t dst; gboolean auto_connect; struct headset *headset; struct gateway *gateway; struct sink *sink; struct source *source; struct control *control; struct target *target; guint hs_preauth_id; struct dev_priv *priv; }; struct audio_device *audio_device_register(DBusConnection *conn, struct btd_device *device, const char *path, const bdaddr_t *src, const bdaddr_t *dst); void audio_device_unregister(struct audio_device *device); gboolean audio_device_is_active(struct audio_device *dev, const char *interface); typedef void (*authorization_cb) (DBusError *derr, void *user_data); int audio_device_cancel_authorization(struct audio_device *dev, authorization_cb cb, void *user_data); int audio_device_request_authorization(struct audio_device *dev, const char *uuid, authorization_cb cb, void *user_data); void audio_device_set_authorized(struct audio_device *dev, gboolean auth);
30.178947
78
0.769445
dca15a76581e2e74bcfb576a7369bbcb1c38ddab
1,086
c
C
srcs/opt/opt_enable_wordmin.c
JonathanDUFOUR/lorem_generator
1a4049145263656af4e25880fd4f4685a31b929d
[ "MIT" ]
null
null
null
srcs/opt/opt_enable_wordmin.c
JonathanDUFOUR/lorem_generator
1a4049145263656af4e25880fd4f4685a31b929d
[ "MIT" ]
null
null
null
srcs/opt/opt_enable_wordmin.c
JonathanDUFOUR/lorem_generator
1a4049145263656af4e25880fd4f4685a31b929d
[ "MIT" ]
null
null
null
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* opt_enable_wordmin.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: jodufour <jodufour@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/12/29 01:11:36 by jodufour #+# #+# */ /* Updated: 2021/12/29 02:38:33 by jodufour ### ########.fr */ /* */ /* ************************************************************************** */ #include "ft_io.h" #include "t_opt.h" void opt_enable_wordmin(t_opt *const opt, char const *val) { opt->flagfield &= ~(1 << 1); opt->flagfield |= (1 << 2); opt->wordmin = ft_atosize(val); }
49.363636
80
0.217311
ed97f94cf1676a63a0bd2463cab927902506824b
132
h
C
Classes/LeadCell.h
ptshih/flipbook
a6647eb87b9bd08a0471b2872302c70c8a9cf4ac
[ "BSD-3-Clause" ]
null
null
null
Classes/LeadCell.h
ptshih/flipbook
a6647eb87b9bd08a0471b2872302c70c8a9cf4ac
[ "BSD-3-Clause" ]
null
null
null
Classes/LeadCell.h
ptshih/flipbook
a6647eb87b9bd08a0471b2872302c70c8a9cf4ac
[ "BSD-3-Clause" ]
null
null
null
// // LeadCell.h // Celery // // Created by Peter Shih on 4/17/13. // // #import "PSCell.h" @interface LeadCell : PSCell @end
9.428571
37
0.598485
e4fcf097aa2be6b24bb09daf24a5d802e5013322
109
h
C
settings/NittyRootListController.h
BlakeBoxberger/Nitty
862229aeb148305c3d801dd1668785a823ef444a
[ "Unlicense" ]
null
null
null
settings/NittyRootListController.h
BlakeBoxberger/Nitty
862229aeb148305c3d801dd1668785a823ef444a
[ "Unlicense" ]
null
null
null
settings/NittyRootListController.h
BlakeBoxberger/Nitty
862229aeb148305c3d801dd1668785a823ef444a
[ "Unlicense" ]
null
null
null
#import <CepheiPrefs/HBRootListController.h> @interface NittyRootListController : HBRootListController @end
21.8
57
0.853211
8e4023148b91b2d76931f3ee4fe05f44d960efe4
1,758
h
C
include/cool/frontend/scanner_state.h
giulioborghesi/cl-compiler
8c6633202af39ebb3d56d38bd405d5558afb7783
[ "MIT" ]
null
null
null
include/cool/frontend/scanner_state.h
giulioborghesi/cl-compiler
8c6633202af39ebb3d56d38bd405d5558afb7783
[ "MIT" ]
null
null
null
include/cool/frontend/scanner_state.h
giulioborghesi/cl-compiler
8c6633202af39ebb3d56d38bd405d5558afb7783
[ "MIT" ]
null
null
null
#ifndef COOL_FRONTEND_SCANNER_STATE_H #define COOL_FRONTEND_SCANNER_STATE_H #include <cool/core/status.h> #include <cool/frontend/error_codes.h> #include <cool/frontend/scanner_extra.h> #include <cool/frontend/scanner_spec.h> #include <cstdlib> #include <memory> #include <string> namespace cool { /// Forward declaration. Defined in implementation file class Buffer; /// RAII class to store the state of a FLEX scanner class ScannerState { public: ~ScannerState(); /// \brief Return the scanner state /// /// \return the scanner state yyscan_t scannerState() const { return state_; } /// \brief Return the last error code seen by the scanner, or 0 if no error /// occurred /// /// \return the last error code seen by the scanner FrontEndErrorCode lastErrorCode() const; /// \brief Factory method to create a ScannerState object from file /// /// \warning This method will throw an assertion should an error occur /// /// \param[in] filePath path to input file /// \return a unique pointer to a ScannerState object static std::unique_ptr<ScannerState> MakeFromFile(const std::string &filePath); /// \brief Factory method to create a ScannerState object from a string /// /// \warning This method will throw an assertion should an error occur /// /// \param[in] inputString string to parse /// \return a unique pointer to a ScannerState object static std::unique_ptr<ScannerState> MakeFromString(const std::string &inputString); /// \brief Reset the error code void resetErrorCode(); protected: /// Use factory method to create ScannerState objects ScannerState(); private: yyscan_t state_; ExtraState extraState_; std::unique_ptr<Buffer> buffer_; }; } // namespace cool #endif
25.478261
77
0.726394
8e9326685236efa812708d6f3c135465c50b7938
220
h
C
polarity/combatPrototype/combatPrototype/Utilities.h
doggan/code-dump
8f4c7bc32ea45ae0a775838e2a7f7217017cd1be
[ "Unlicense" ]
null
null
null
polarity/combatPrototype/combatPrototype/Utilities.h
doggan/code-dump
8f4c7bc32ea45ae0a775838e2a7f7217017cd1be
[ "Unlicense" ]
null
null
null
polarity/combatPrototype/combatPrototype/Utilities.h
doggan/code-dump
8f4c7bc32ea45ae0a775838e2a7f7217017cd1be
[ "Unlicense" ]
null
null
null
#ifndef _Utilities_h_ #define _Utilities_h_ #include <string> #include <sstream> inline std::string intToString( int aInt ) { std::stringstream ss; ss << aInt; return ss.str(); } #endif // _Utilities_h_
16.923077
45
0.681818
da78c52582d0c9bb3f4fcaaec0b7507cda6973fc
3,494
c
C
src/execution.c
leetonidas/impVM
2686f7a8f6fd1994e6bc94cd6e9139dc76e0ed73
[ "BSD-2-Clause" ]
null
null
null
src/execution.c
leetonidas/impVM
2686f7a8f6fd1994e6bc94cd6e9139dc76e0ed73
[ "BSD-2-Clause" ]
null
null
null
src/execution.c
leetonidas/impVM
2686f7a8f6fd1994e6bc94cd6e9139dc76e0ed73
[ "BSD-2-Clause" ]
null
null
null
#include <string.h> #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> #include "utils.h" #include "jitter.h" #include "profiler.h" #include "execution.h" #include "emulator.h" imp_prog prog; cpu_state state; int is_lockdown = 0; char rev_flag[50]; void lockdown() { if(!is_lockdown) { if (init_seccomp() == 0) { memset(rev_flag, 0, sizeof(rev_flag)); is_lockdown = 1; } else { printf("unable to init seccomp!\n"); exit(1); } } } uint64_t get_key_part(uint64_t *key, size_t index) { uint64_t k = key[index / 2]; if (index % 2 == 1) return k & 0xFFFFFFFF; else return k >> 32; } void xtea_encrypt(uint64_t *data, size_t dlen, uint64_t *key) { int i; size_t j; uint32_t sum = 0, tmp; for (i = 0; i < 32; i++) { for (j = 0; j < dlen; j++) { tmp = data[j] & 0xFFFFFFFF; tmp = (data[j] >> 32) + ((((tmp << 4) ^ (tmp >> 5)) + tmp) ^ (sum + get_key_part(key, sum & 3))); data[j] = (data[j] & 0xFFFFFFFF) | (((uint64_t) tmp) << 32); } sum += 0x9E3779B9; for (j = 0; j < dlen; j++) { tmp = data[j] >> 32; tmp = (data[j] + ((((tmp << 4) ^ (tmp >> 5)) + tmp) ^ (sum + get_key_part(key, (sum >> 11) & 3)))) & 0xFFFFFFFF; data[j] = ((data[j] >> 32) << 32) | tmp; } } } void init_challenge() { size_t n; if (is_lockdown) { printf("unable to initialize challenge in lockdown mode\n"); exit(1); } disable_jit(); if (prog.data_len < 6) { printf("data segment too small to initialize challenge\n"); exit(1); } int fd = open("rev_flag.txt", O_RDONLY); n = read(fd, rev_flag, 49); close(fd); rev_flag[n] = 0; fd = open("/dev/urandom", O_RDONLY); read(fd, prog.data + 4, 128 / 8); close(fd); memcpy(prog.data, rev_flag, sizeof(uint64_t) * 4); //memcpy(prog.data, "\x08\x07\x06\x05\x04\x03\x02\x01", 8); //memcpy(prog.data + 4, "\x78\x56\x34\x12\x67\x45\x23\x01\x9a\x78\x56\x34\x89\x67\x45\x23", 16); xtea_encrypt(prog.data, 4, prog.data + 4); } void check_challenge() { if (memcmp(rev_flag, prog.data, sizeof(uint64_t) * 4) == 0) printf("%s", rev_flag); else { printf("try harder next time\n"); } } int call_fun(size_t index) { cpu_state save; int ret = 0; switch (index) { case 255: vm_putc(); break; case 254: vm_getc(); break; case 253: check_challenge(); break; case 252: init_challenge(); break; default: if (index >= prog.fun_num) { ret = -1; break; } memcpy(&save, &state, sizeof(cpu_state)); state.fp = index; state.ip = 0; if (!should_jit(index)) ret = emu_run_fun(index); else ret = jit_run_fun(index); prog.stack[++save.sp] = prog.stack[state.sp]; memcpy(&state, &save, sizeof(cpu_state)); break; } return ret; } void vm_getc() { if (is_lockdown) { printf("JIT is way too fast to wait for input!\n"); prog.stack[++state.sp] = 0; } else { uint64_t val = (uint64_t) getchar(); prog.stack[++state.sp] = val; } } void vm_putc() { putchar((char) prog.stack[state.sp]); }
24.605634
124
0.520321
f7081f13b215399d233b10fe7c3efc8f791c04ce
7,695
c
C
test/test_rotating.c
fatcat22/rbtree
6ddcc7fb66d5d0be69dd147681ad432fee531d01
[ "MIT" ]
null
null
null
test/test_rotating.c
fatcat22/rbtree
6ddcc7fb66d5d0be69dd147681ad432fee531d01
[ "MIT" ]
null
null
null
test/test_rotating.c
fatcat22/rbtree
6ddcc7fb66d5d0be69dd147681ad432fee531d01
[ "MIT" ]
null
null
null
#include "_test_common.h" extern void _rotate_left(struct rbtree_t* tree, rbnode_t* node); extern void _rotate_right(struct rbtree_t* tree, rbnode_t* node); void setup_rotate_test_tree(void** state) { /* create a tree like this(R for red and B for black): 8B / \ 4R 10B / \ / \ 2B 6B 9R 11R / \ / \ 1R 3R 5R 7R */ const LargestIntegralType node_nums[] = { 8, 4, 10, 2, 6, 9, 11, 1, 3, 5, 7, }; int i; struct rbtree_t* tree = create_rbtree(_alloc_tnode, _free_tnode, _tnode_compare, _tvalue_compare); assert_true(NULL != tree); assert_true(sizeof(uintptr_t) <= sizeof(LargestIntegralType)); for (i = 0; i < countof(node_nums); i++) { assert_true(rbt_insert(tree, (void*)(int)node_nums[i])); } *state = tree; } void teardown_rotate_test_tree(void** state) { struct rbtree_t* tree = (struct rbtree_t*)*state; destroy_rbtree(tree); } typedef struct _node_expectation_t { int node_num; bool node_is_red; int left_num; int right_num; int parent_num; }_node_expectation_t; const _node_expectation_t* _get_node_expection(const _node_expectation_t* expects, const int expects_cnt, const int num) { int i; for (i = 0; i < expects_cnt; ++i) { if (num == expects[i].node_num) { return expects + i; } } assert_false("can't find num in rotate_results"); return NULL; } bool _node_is_red(const _node_expectation_t* expects, const int expects_cnt, const int num) { const _node_expectation_t* expect = _get_node_expection(expects, expects_cnt, num); return expect->node_is_red; } typedef struct _rotate_acc_t { const _node_expectation_t* expects; int expects_cnt; }_rotate_acc_t; static void _node_expect_check(rbnode_t* node, const int expect_num, const _node_expectation_t* expects, const int expects_cnt, const char* const fmt, ...) { tnode_t* tnode = container_of(node, tnode_t, node); bool expect_is_red; //va_list args; if (-1 == expect_num) { assert_true(NULL == node); return; } /* va_start(args, fmt); vprint_message(fmt, args); va_end(args); */ assert_true(NULL != node); assert_int_equal(expect_num, tnode->num); expect_is_red = _node_is_red(expects, expects_cnt, expect_num); assert_true(_is_red(node) == expect_is_red); } static void _assert_rotated_tree(tnode_t* tnode, int red_cnt, int black_cnt, void* arg) { const _rotate_acc_t* ra = (const _rotate_acc_t*)arg; rbnode_t* node = &tnode->node; rbnode_t *parent = _parent(node); rbnode_t *left = _left_child(node); rbnode_t *right = _right_child(node); const _node_expectation_t* expect = _get_node_expection(ra->expects, ra->expects_cnt, tnode->num); _node_expect_check(node, expect->node_num, ra->expects, ra->expects_cnt, "checking node %d", tnode->num); _node_expect_check(left, expect->left_num, ra->expects, ra->expects_cnt, "checking node %d left", tnode->num); _node_expect_check(right, expect->right_num, ra->expects, ra->expects_cnt, "checking node %d right", tnode->num); _node_expect_check(parent, expect->parent_num, ra->expects, ra->expects_cnt, "checking node %d parent", tnode->num); } void test_rbtree_rotate_left(void** state) { struct tnode_t* root_tnode; struct rbtree_t* tree = (struct rbtree_t*)*state; struct rbnode_t* rotating_node = _left_child(_root(tree)); /* after rotate left of rotating_node, the tree like this: 8B / \ 6R 10B / \ / \ 4B 7R 9R 11R / \ 2B 5R / \ 1R 3R */ const _node_expectation_t rotated_expects[] = { {1, true, -1, -1, 2}, {2, false, 1, 3, 4}, {3, true, -1, -1, 2}, {4, false, 2, 5, 6}, {5, true, -1, -1, 4}, {6, true, 4, 7, 8}, {7, true, -1, -1, 6}, {8, false, 6, 10, -1}, {9, true, -1, -1, 10}, {10, false, 9, 11, 8}, {11, true, -1, -1, 10}, }; _rotate_acc_t ra = {rotated_expects, countof(rotated_expects)}; assert(NULL != rotating_node); _rotate_left(tree, rotating_node); root_tnode = container_of(_root(tree), struct tnode_t, node); assert_int_equal(8, root_tnode->num); _pre_order_traversal(tree, _assert_rotated_tree, &ra); } void test_rbtree_rotate_right(void** state) { struct tnode_t* root_tnode; struct rbtree_t* tree = (struct rbtree_t*)*state; struct rbnode_t* rotating_node = _left_child(_root(tree)); /*after rotate right ot rotating_node, the tree looks like this: 8B / \ 2R 10B / \ / \ 1R 4B 9R 11R / \ 3R 6B / \ 5R 7R */ const _node_expectation_t rotated_expects[] = { {1, true, -1, -1, 2}, {2, true, 1, 4, 8}, {3, true, -1, -1, 4}, {4, false, 3, 6, 2}, {5, true, -1, -1, 6}, {6, false, 5, 7, 4}, {7, true, -1, -1, 6}, {8, false, 2, 10, -1}, {9, true, -1, -1, 10}, {10, false, 9, 11, 8}, {11, true, -1, -1, 10}, }; _rotate_acc_t ra = {rotated_expects, countof(rotated_expects)}; assert(NULL != rotating_node); _rotate_right(tree, rotating_node); root_tnode = container_of(_root(tree), tnode_t, node); assert_int_equal(8, root_tnode->num); _pre_order_traversal(tree, _assert_rotated_tree, &ra); } void test_rbtree_root_rotate_left(void** state) { struct tnode_t* root_tnode; struct rbtree_t* tree = (struct rbtree_t*)*state; struct rbnode_t* rotating_node = _root(tree); /*after rotate right ot rotating_node, the tree looks like this: 10B / \ 8B 11R / \ 4R 9R / \ 2B 6B / \ / \ 1R 3R 5R 7R */ const _node_expectation_t rotated_expects[] = { {1, true, -1, -1, 2}, {2, false, 1, 3, 4}, {3, true, -1, -1, 2}, {4, true, 2, 6, 8}, {5, true, -1, -1, 6}, {6, false, 5, 7, 4}, {7, true, -1, -1, 6}, {8, false, 4, 9, 10}, {9, true, -1, -1, 8}, {10, false, 8, 11, -1}, {11, true, -1, -1, 10}, }; _rotate_acc_t ra = {rotated_expects, countof(rotated_expects)}; assert(NULL != rotating_node); _rotate_left(tree, rotating_node); root_tnode = container_of(_root(tree), tnode_t, node); assert_int_equal(10, root_tnode->num); _pre_order_traversal(tree, _assert_rotated_tree, &ra); } void test_rbtree_root_rotate_right(void** state) { struct tnode_t* root_tnode; struct rbtree_t* tree = (struct rbtree_t*)*state; struct rbnode_t* rotating_node = _root(tree); /*after rotate right ot rotating_node, the tree looks like this: 4B / \ 2B 8R / \ / \ 1R 3R 6B 10B / \ / \ 5R 7R 9R 11R */ const _node_expectation_t rotated_expects[] = { {1, true, -1, -1, 2}, {2, false, 1, 3, 4}, {3, true, -1, -1, 2}, {4, false, 2, 8, -1}, {5, true, -1, -1, 6}, {6, false, 5, 7, 8}, {7, true, -1, -1, 6}, {8, true, 6, 10, 4}, {9, true, -1, -1, 10}, {10, false, 9, 11, 8}, {11, true, -1, -1, 10}, }; _rotate_acc_t ra = {rotated_expects, countof(rotated_expects)}; assert(NULL != rotating_node); _rotate_right(tree, rotating_node); root_tnode = container_of(_root(tree), tnode_t, node); assert_int_equal(4, root_tnode->num); _pre_order_traversal(tree, _assert_rotated_tree, &ra); }
29.596154
145
0.586875
130fdb2763fcef57ccb4c3aac3853185ab35863c
381
h
C
3rdparty/unistd/portable/ipc/PacketBuffer.h
dna2fork/darknet
85820fcf951fe021b2d3fa293633fe4c5957dbd7
[ "MIT" ]
168
2017-11-25T21:19:11.000Z
2022-03-28T15:41:46.000Z
3rdparty/unistd/portable/ipc/PacketBuffer.h
dna2fork/darknet
85820fcf951fe021b2d3fa293633fe4c5957dbd7
[ "MIT" ]
64
2018-08-31T11:13:22.000Z
2022-02-05T07:03:01.000Z
3rdparty/unistd/portable/ipc/PacketBuffer.h
dna2fork/darknet
85820fcf951fe021b2d3fa293633fe4c5957dbd7
[ "MIT" ]
31
2018-07-22T08:57:33.000Z
2022-01-11T15:44:07.000Z
// portable/PacketBuffer.h // Copyright 2016/1/16 Robin.Rowe@cinepaint.org // License open source MIT/BSD #ifndef PacketBuffer_h #define PacketBuffer_h #include "Packet.h" namespace portable { template <unsigned bufsize> class PacketBuffer { char buffer[bufsize]; public: operator PacketSizer() { return PacketSizer(buffer,bufsize); } }; } #endif
15.24
48
0.706037
daa3f8f74045f606db3d6aa8a866535be313f263
1,352
h
C
include/cd.h
JackWolfard/cash
a646c0b94d075fa424a93904b7499a0dee90ac89
[ "BSD-3-Clause" ]
14
2018-08-08T19:02:21.000Z
2022-01-07T14:42:43.000Z
include/cd.h
JackWolfard/cash
a646c0b94d075fa424a93904b7499a0dee90ac89
[ "BSD-3-Clause" ]
null
null
null
include/cd.h
JackWolfard/cash
a646c0b94d075fa424a93904b7499a0dee90ac89
[ "BSD-3-Clause" ]
3
2020-04-20T20:58:34.000Z
2021-11-23T14:50:14.000Z
#pragma once #include "bool.h" namespace ch { namespace internal { lnodeimpl* getCurrentClockNode(const source_location& sloc); lnodeimpl* getCurrentResetNode(const source_location& sloc); void pushClockDomain(const lnode& clock, const lnode& reset, bool pos_edge, const source_location& sloc); /////////////////////////////////////////////////////////////////////////////// inline auto ch_clock(CH_SLOC) { return make_logic_type<ch_bool>(getCurrentClockNode(sloc)); } inline auto ch_reset(CH_SLOC) { return make_logic_type<ch_bool>(getCurrentResetNode(sloc)); } template <typename C, typename R = ch_bool> void ch_pushcd(const C& clk, const R& reset = ch_reset(), bool pos_edge = true, CH_SLOC) { static_assert(is_bitbase_v<C>, "invalid type"); static_assert(ch_width_v<C> == 1, "invalid size"); static_assert(is_bitbase_v<R>, "invalid type"); static_assert(ch_width_v<R> == 1, "invalid size"); pushClockDomain(get_lnode(clk), get_lnode(reset), pos_edge, sloc); } void ch_popcd(); template <typename Func, typename C, typename R = ch_bool> void ch_cd(Func&& func, const C& clk, const R& reset = ch_reset(), bool pos_edge = true, CH_SRC_INFO) { ch_pushcd(clk, reset, pos_edge, srcinfo); func; ch_popcd(); } } }
26.509804
90
0.636095
25fb95ff66e9701e74cfd088f1943cd52fb2cd3d
9,066
h
C
src/vppinfra/llist.h
amithbraj/vpp
edf1da94dc099c6e2ab1d455ce8652fada3cdb04
[ "Apache-2.0" ]
52
2016-09-20T15:08:46.000Z
2020-12-22T23:03:25.000Z
src/vppinfra/llist.h
amithbraj/vpp
edf1da94dc099c6e2ab1d455ce8652fada3cdb04
[ "Apache-2.0" ]
63
2018-06-11T09:48:35.000Z
2021-01-05T09:11:03.000Z
src/vppinfra/llist.h
amithbraj/vpp
edf1da94dc099c6e2ab1d455ce8652fada3cdb04
[ "Apache-2.0" ]
36
2016-07-21T11:20:33.000Z
2022-01-16T15:55:45.000Z
/* * Copyright (c) 2019 Cisco and/or its affiliates. * 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. * * @file * @brief Circular doubly linked list with head sentinel. * List entries are allocated out of a "supporting" pool and all pool entries * must contain a list anchor struct for each list they pertain to. */ #ifndef SRC_VPPINFRA_CLIB_LLIST_H_ #define SRC_VPPINFRA_CLIB_LLIST_H_ #include <vppinfra/types.h> #include <vppinfra/pool.h> typedef u32 clib_llist_index_t; typedef struct clib_llist_anchor { clib_llist_index_t prev; clib_llist_index_t next; } clib_llist_anchor_t; #define CLIB_LLIST_INVALID_INDEX ((u32)~0) /** * Local variable naming macro. */ #define _ll_var(v) _llist_##v /** * Local macros to grab llist anchor next and prev from pool entry */ #define _lnext(E,name) ((E)->name).next #define _lprev(E,name) ((E)->name).prev /** * Get list entry index * * @param LP linked list pool * @param E pool entry * @return pool entry index */ #define clib_llist_entry_index(LP,E) ((E) - (LP)) /** * Get prev list entry index * * @param E pool entry * @name list anchor name * @return previous index */ #define clib_llist_prev_index(E,name) _lprev(E,name) /** * Get next list entry index * * @param E pool entry * @name list anchor name * @return next index */ #define clib_llist_next_index(E,name) _lnext(E,name) /** * Get next pool entry * * @param LP linked list pool * @param name list anchor name * @param E pool entry * @return next pool entry */ #define clib_llist_next(LP,name,E) pool_elt_at_index((LP),_lnext((E),name)) /** * Get previous pool entry * * @param LP linked list pool * @param name list anchor name * @param E pool entry * @return previous pool entry */ #define clib_llist_prev(LP,name,E) pool_elt_at_index((LP),_lprev((E),name)) /** * Initialize element in llist for entry * * @param LP linked list pool * @param name list anchor name * @param E entry whose ll anchor is to be initialized */ #define clib_llist_anchor_init(LP,name,E) \ do { \ _lprev ((E),name) = clib_llist_entry_index ((LP), (E)); \ _lnext ((E),name) = _lprev ((E),name); \ } while (0) /** * Initialize llist head * * @param LP linked list pool * @param name list anchor name */ #define clib_llist_make_head(LP,name) \ ({ \ typeof (LP) _ll_var (head); \ pool_get_zero ((LP), _ll_var (head)); \ clib_llist_anchor_init ((LP),name,_ll_var (head)); \ clib_llist_entry_index ((LP), _ll_var (head)); \ }) /** * Check is list is empty * * @param LP linked list pool * @param name list anchor name * @param H list head * @return 1 if sentinel is the only node part of the list, 0 otherwise */ #define clib_llist_is_empty(LP,name,H) \ (clib_llist_entry_index (LP,H) == (H)->name.next) /** * Check if element is linked in a list * * @param E list element * @param name list anchor name */ #define clib_llist_elt_is_linked(E,name) \ ((E)->name.next != CLIB_LLIST_INVALID_INDEX \ && (E)->name.prev != CLIB_LLIST_INVALID_INDEX) /** * Insert entry between previous and next * * Internal use. * * @param LP linked list pool * @param name list anchor name * @param E new entry * @param P previous in list * @param N next in list */ #define _llist_insert(LP,name,E,P,N) \ do { \ _lprev (E,name) = _lprev(N,name); \ _lnext (E,name) = _lnext(P,name); \ _lprev ((N),name) = clib_llist_entry_index ((LP),(E)); \ _lnext ((P),name) = clib_llist_entry_index ((LP),(E)); \ } while (0) /** * Insert entry after previous * * @param LP linked list pool * @param name list anchor name * @param E new entry * @param P previous in list */ #define clib_llist_insert(LP,name,E,P) \ do { \ typeof (LP) _ll_var (N) = clib_llist_next (LP,name,P); \ _llist_insert ((LP),name,(E),(P), _ll_var (N)); \ } while (0) /** * Add entry after head * * @param LP linked list pool * @param name list anchor name * @param E new entry * @param H list head */ #define clib_llist_add(LP,name,E,H) clib_llist_insert ((LP),name,(E),(H)) /** * Add entry after tail * * @param LP linked list pool * @param name list anchor name * @param E new entry * @param H list head */ #define clib_llist_add_tail(LP,name,E,H) \ do { \ typeof (LP) _ll_var (P) = clib_llist_prev ((LP),name,(H)); \ _llist_insert ((LP),name,(E),_ll_var (P),(H)); \ } while (0) /** * Remove entry from list * * @param LP linked list pool * @param name list anchor name * @param E entry to be removed */ #define clib_llist_remove(LP,name,E) \ do { \ ASSERT ((E) != clib_llist_next (LP,name,E));/* don't remove sentinel */\ ASSERT (_lnext (E,name) != CLIB_LLIST_INVALID_INDEX); \ ASSERT (_lprev (E,name) != CLIB_LLIST_INVALID_INDEX); \ typeof (LP) _ll_var (P) = clib_llist_prev ((LP),name,E); \ typeof (LP) _ll_var (N) = clib_llist_next ((LP),name,E); \ _lnext (_ll_var (P),name) = _lnext (E,name); \ _lprev (_ll_var (N),name) = _lprev (E,name); \ _lnext (E,name) = _lprev (E,name) = CLIB_LLIST_INVALID_INDEX; \ }while (0) /** * Removes and returns the first element in the list. * * The element is not freed. It's the responsability of the caller to * free it. * * @param LP linked list pool * @param name list anchor name * @param E storage the first entry * @param H list head entry */ #define clib_llist_pop_first(LP,name,E,H) \ do { \ E = clib_llist_next (LP,name,H); \ clib_llist_remove (LP,name,E); \ } while (0) /** * Splice two lists at a given position * * List spliced into destination list is left with 0 entries, i.e., head * is made to point to itself. * * @param LP linked list pool * @param name list anchor name * @param P position in destination where source list is spliced * @param H head of source list that will be spliced into destination */ #define clib_llist_splice(LP,name,P,H) \ do { \ typeof (LP) _ll_var (fe) = clib_llist_next (LP,name,H); \ if (_ll_var (fe) != (H)) \ { \ typeof (LP) _ll_var (le) = clib_llist_prev (LP,name,H); \ typeof (LP) _ll_var (ne) = clib_llist_next (LP,name,P); \ _lprev (_ll_var (fe),name) = clib_llist_entry_index(LP,P); \ _lnext (_ll_var (le),name) = clib_llist_entry_index(LP,_ll_var (ne));\ _lnext (P,name) = clib_llist_entry_index (LP,_ll_var (fe)); \ _lprev (_ll_var (ne),name) = clib_llist_entry_index(LP,_ll_var (le));\ _lnext (H,name) = clib_llist_entry_index(LP,H); \ _lprev (H,name) = _lnext (H,name); \ } \ } while (0) /** * Walk list starting at head * * @param LP linked list pool * @param name list anchor name * @param H head entry * @param E entry iterator * @param body code to be executed */ #define clib_llist_foreach(LP,name,H,E,body) \ do { \ typeof (LP) _ll_var (n); \ (E) = clib_llist_next (LP,name,H); \ while (E != H) \ { \ _ll_var (n) = clib_llist_next (LP,name,E); \ do { body; } while (0); \ (E) = _ll_var (n); \ } \ } while (0) /** * Walk list starting at head safe * * @param LP linked list pool * @param name list anchor name * @param HI head index * @param EI entry index iterator * @param body code to be executed */ #define clib_llist_foreach_safe(LP,name,H,E,body) \ do { \ clib_llist_index_t _ll_var (HI) = clib_llist_entry_index (LP, H); \ clib_llist_index_t _ll_var (EI), _ll_var (NI); \ _ll_var (EI) = _lnext ((H),name); \ while (_ll_var (EI) != _ll_var (HI)) \ { \ (E) = pool_elt_at_index (LP, _ll_var (EI)); \ _ll_var (NI) = _lnext ((E),name); \ do { body; } while (0); \ _ll_var (EI) = _ll_var (NI); \ } \ } while (0) /** * Walk list starting at head in reverse order * * @param LP linked list pool * @param name list anchor name * @param H head entry * @param E entry iterator * @param body code to be executed */ #define clib_llist_foreach_reverse(LP,name,H,E,body) \ do { \ typeof (LP) _ll_var (p); \ (E) = clib_llist_prev (LP,name,H); \ while (E != H) \ { \ _ll_var (p) = clib_llist_prev (LP,name,E); \ do { body; } while (0); \ (E) = _ll_var (p); \ } \ } while (0) #endif /* SRC_VPPINFRA_CLIB_LLIST_H_ */ /* * fd.io coding-style-patch-verification: ON * * Local Variables: * eval: (c-set-style "gnu") * End: */
28.509434
77
0.632473
973a996964034b2440f9475ae05d7d829e61bfa6
18,765
h
C
deps/mozjs/js/src/vm/Stack-inl.h
zpao/spidernode
843d5b5e9be55ce447fd03127aeeb2c7728ae168
[ "MIT" ]
48
2015-01-09T20:39:35.000Z
2021-12-21T21:17:52.000Z
deps/mozjs/js/src/vm/Stack-inl.h
ninja1002/spidernode
ada8fc559bd2c047a6e52c78af9d27ab273c87d5
[ "MIT" ]
2
2016-02-05T10:27:37.000Z
2019-01-22T16:22:51.000Z
deps/mozjs/js/src/vm/Stack-inl.h
ninja1002/spidernode
ada8fc559bd2c047a6e52c78af9d27ab273c87d5
[ "MIT" ]
8
2015-01-12T17:14:36.000Z
2018-09-15T14:10:27.000Z
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=4 sw=4 et tw=79 ft=cpp: * * ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.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 SpiderMonkey JavaScript engine. * * The Initial Developer of the Original Code is * Mozilla Corporation. * Portions created by the Initial Developer are Copyright (C) 2009 * the Initial Developer. All Rights Reserved. * * Contributor(s): * Luke Wagner <luke@mozilla.com> * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #ifndef Stack_inl_h__ #define Stack_inl_h__ #include "jscntxt.h" #include "jscompartment.h" #include "methodjit/MethodJIT.h" #include "vm/Stack.h" #include "jsscriptinlines.h" #include "ArgumentsObject-inl.h" #include "ScopeObject-inl.h" namespace js { /* * We cache name lookup results only for the global object or for native * non-global objects without prototype or with prototype that never mutates, * see bug 462734 and bug 487039. */ static inline bool IsCacheableNonGlobalScope(JSObject *obj) { bool cacheable = (obj->isCall() || obj->isBlock() || obj->isDeclEnv()); JS_ASSERT_IF(cacheable, !obj->getOps()->lookupProperty); return cacheable; } inline JSObject & StackFrame::scopeChain() const { JS_ASSERT_IF(!(flags_ & HAS_SCOPECHAIN), isFunctionFrame()); if (!(flags_ & HAS_SCOPECHAIN)) { scopeChain_ = callee().toFunction()->environment(); flags_ |= HAS_SCOPECHAIN; } return *scopeChain_; } inline JSObject & StackFrame::varObj() { JSObject *obj = &scopeChain(); while (!obj->isVarObj()) obj = obj->enclosingScope(); return *obj; } inline JSCompartment * StackFrame::compartment() const { JS_ASSERT_IF(isScriptFrame(), scopeChain().compartment() == script()->compartment()); return scopeChain().compartment(); } inline void StackFrame::initPrev(JSContext *cx) { JS_ASSERT(flags_ & HAS_PREVPC); if (FrameRegs *regs = cx->maybeRegs()) { prev_ = regs->fp(); prevpc_ = regs->pc; prevInline_ = regs->inlined(); JS_ASSERT_IF(!prev_->isDummyFrame(), uint32_t(prevpc_ - prev_->script()->code) < prev_->script()->length); } else { prev_ = NULL; #ifdef DEBUG prevpc_ = (jsbytecode *)0xbadc; prevInline_ = (JSInlinedSite *)0xbadc; #endif } } inline void StackFrame::resetGeneratorPrev(JSContext *cx) { flags_ |= HAS_PREVPC; initPrev(cx); } inline void StackFrame::initInlineFrame(JSFunction *fun, StackFrame *prevfp, jsbytecode *prevpc) { /* * Note: no need to ensure the scopeChain is instantiated for inline * frames. Functions which use the scope chain are never inlined. */ flags_ = StackFrame::FUNCTION; exec.fun = fun; resetInlinePrev(prevfp, prevpc); } inline void StackFrame::resetInlinePrev(StackFrame *prevfp, jsbytecode *prevpc) { JS_ASSERT_IF(flags_ & StackFrame::HAS_PREVPC, prevInline_); flags_ |= StackFrame::HAS_PREVPC; prev_ = prevfp; prevpc_ = prevpc; prevInline_ = NULL; } inline void StackFrame::initCallFrame(JSContext *cx, JSFunction &callee, JSScript *script, uint32_t nactual, StackFrame::Flags flagsArg) { JS_ASSERT((flagsArg & ~(CONSTRUCTING | LOWERED_CALL_APPLY | OVERFLOW_ARGS | UNDERFLOW_ARGS)) == 0); JS_ASSERT(script == callee.script()); /* Initialize stack frame members. */ flags_ = FUNCTION | HAS_PREVPC | HAS_SCOPECHAIN | HAS_BLOCKCHAIN | flagsArg; exec.fun = &callee; u.nactual = nactual; scopeChain_ = callee.environment(); ncode_ = NULL; initPrev(cx); blockChain_= NULL; JS_ASSERT(!hasBlockChain()); JS_ASSERT(!hasHookData()); JS_ASSERT(annotation() == NULL); JS_ASSERT(!hasCallObj()); SetValueRangeToUndefined(slots(), script->nfixed); } /* * Reinitialize the StackFrame fields that have been initialized up to the * point of FixupArity in the function prologue. */ inline void StackFrame::initFixupFrame(StackFrame *prev, StackFrame::Flags flags, void *ncode, uintN nactual) { JS_ASSERT((flags & ~(CONSTRUCTING | LOWERED_CALL_APPLY | FUNCTION | OVERFLOW_ARGS | UNDERFLOW_ARGS)) == 0); flags_ = FUNCTION | flags; prev_ = prev; ncode_ = ncode; u.nactual = nactual; } inline void StackFrame::overwriteCallee(JSObject &newCallee) { JS_ASSERT(callee().toFunction()->script() == newCallee.toFunction()->script()); mutableCalleev().setObject(newCallee); } inline Value & StackFrame::canonicalActualArg(uintN i) const { if (i < numFormalArgs()) return formalArg(i); JS_ASSERT(i < numActualArgs()); return actualArgs()[i]; } template <class Op> inline bool StackFrame::forEachCanonicalActualArg(Op op, uintN start /* = 0 */, uintN count /* = uintN(-1) */) { uintN nformal = fun()->nargs; JS_ASSERT(start <= nformal); Value *formals = formalArgsEnd() - nformal; uintN nactual = numActualArgs(); if (count == uintN(-1)) count = nactual - start; uintN end = start + count; JS_ASSERT(end >= start); JS_ASSERT(end <= nactual); if (end <= nformal) { Value *p = formals + start; for (; start < end; ++p, ++start) { if (!op(start, p)) return false; } } else { for (Value *p = formals + start; start < nformal; ++p, ++start) { if (!op(start, p)) return false; } JS_ASSERT(start >= nformal); Value *actuals = formals - (nactual + 2) + start; for (Value *p = actuals; start < end; ++p, ++start) { if (!op(start, p)) return false; } } return true; } template <class Op> inline bool StackFrame::forEachFormalArg(Op op) { Value *formals = formalArgsEnd() - fun()->nargs; Value *formalsEnd = formalArgsEnd(); uintN i = 0; for (Value *p = formals; p != formalsEnd; ++p, ++i) { if (!op(i, p)) return false; } return true; } struct CopyTo { Value *dst; CopyTo(Value *dst) : dst(dst) {} bool operator()(uintN, Value *src) { *dst++ = *src; return true; } }; inline uintN StackFrame::numActualArgs() const { /* * u.nactual is always coherent, except for method JIT frames where the * callee does not access its arguments and the number of actual arguments * matches the number of formal arguments. The JIT requires that all frames * which do not have an arguments object and use their arguments have a * coherent u.nactual (even though the below code may not use it), as * JIT code may access the field directly. */ JS_ASSERT(hasArgs()); if (JS_UNLIKELY(flags_ & (OVERFLOW_ARGS | UNDERFLOW_ARGS))) return u.nactual; return numFormalArgs(); } inline Value * StackFrame::actualArgs() const { JS_ASSERT(hasArgs()); Value *argv = formalArgs(); if (JS_UNLIKELY(flags_ & OVERFLOW_ARGS)) return argv - (2 + u.nactual); return argv; } inline Value * StackFrame::actualArgsEnd() const { JS_ASSERT(hasArgs()); if (JS_UNLIKELY(flags_ & OVERFLOW_ARGS)) return formalArgs() - 2; return formalArgs() + numActualArgs(); } inline void StackFrame::setArgsObj(ArgumentsObject &obj) { JS_ASSERT_IF(hasArgsObj(), &obj == argsObj_); JS_ASSERT_IF(!hasArgsObj(), numActualArgs() == obj.initialLength()); argsObj_ = &obj; flags_ |= HAS_ARGS_OBJ; } inline void StackFrame::setScopeChainNoCallObj(JSObject &obj) { #ifdef DEBUG JS_ASSERT(&obj != NULL); if (&obj != sInvalidScopeChain) { if (hasCallObj()) { JSObject *pobj = &obj; while (pobj && pobj->getPrivate() != this) pobj = pobj->enclosingScope(); JS_ASSERT(pobj); } else { for (JSObject *pobj = &obj; pobj->isScope(); pobj = pobj->enclosingScope()) JS_ASSERT_IF(pobj->isCall(), pobj->getPrivate() != this); } } #endif scopeChain_ = &obj; flags_ |= HAS_SCOPECHAIN; } inline void StackFrame::setScopeChainWithOwnCallObj(CallObject &obj) { JS_ASSERT(&obj != NULL); JS_ASSERT(!hasCallObj() && obj.maybeStackFrame() == this); scopeChain_ = &obj; flags_ |= HAS_SCOPECHAIN | HAS_CALL_OBJ; } inline CallObject & StackFrame::callObj() const { JS_ASSERT_IF(isNonEvalFunctionFrame() || isStrictEvalFrame(), hasCallObj()); JSObject *pobj = &scopeChain(); while (JS_UNLIKELY(!pobj->isCall())) pobj = pobj->enclosingScope(); return pobj->asCall(); } inline bool StackFrame::maintainNestingState() const { /* * Whether to invoke the nesting epilogue/prologue to maintain active * frame counts and check for reentrant outer functions. */ return isNonEvalFunctionFrame() && !isGeneratorFrame() && script()->nesting(); } inline bool StackFrame::functionPrologue(JSContext *cx) { JS_ASSERT(isNonEvalFunctionFrame()); JSFunction *fun = this->fun(); if (fun->isHeavyweight()) { if (!CreateFunCallObject(cx, this)) return false; } else { /* Force instantiation of the scope chain, for JIT frames. */ scopeChain(); } if (script()->nesting()) { JS_ASSERT(maintainNestingState()); types::NestingPrologue(cx, this); } return true; } inline void StackFrame::functionEpilogue() { JS_ASSERT(isNonEvalFunctionFrame()); if (flags_ & (HAS_ARGS_OBJ | HAS_CALL_OBJ)) { /* NB: there is an ordering dependency here. */ if (hasCallObj()) js_PutCallObject(this); else if (hasArgsObj()) js_PutArgsObject(this); } if (maintainNestingState()) types::NestingEpilogue(this); } inline void StackFrame::updateEpilogueFlags() { if (flags_ & (HAS_ARGS_OBJ | HAS_CALL_OBJ)) { if (hasArgsObj() && !argsObj().maybeStackFrame()) flags_ &= ~HAS_ARGS_OBJ; if (hasCallObj() && !callObj().maybeStackFrame()) { /* * For function frames, the call object may or may not have have an * enclosing DeclEnv object, so we use the callee's parent, since * it was the initial scope chain. For global (strict) eval frames, * there is no callee, but the call object's parent is the initial * scope chain. */ scopeChain_ = isFunctionFrame() ? callee().toFunction()->environment() : &scopeChain_->asScope().enclosingScope(); flags_ &= ~HAS_CALL_OBJ; } } /* * For outer/inner function frames, undo the active frame balancing so that * when we redo it in the epilogue we get the right final value. The other * nesting epilogue changes (update active args/vars) are idempotent. */ if (maintainNestingState()) script()->nesting()->activeFrames++; } /*****************************************************************************/ STATIC_POSTCONDITION(!return || ubound(from) >= nvals) JS_ALWAYS_INLINE bool StackSpace::ensureSpace(JSContext *cx, MaybeReportError report, Value *from, ptrdiff_t nvals, JSCompartment *dest) const { assertInvariants(); JS_ASSERT(from >= firstUnused()); #ifdef XP_WIN JS_ASSERT(from <= commitEnd_); #endif if (JS_UNLIKELY(conservativeEnd_ - from < nvals)) return ensureSpaceSlow(cx, report, from, nvals, dest); return true; } inline Value * StackSpace::getStackLimit(JSContext *cx, MaybeReportError report) { FrameRegs &regs = cx->regs(); uintN nvals = regs.fp()->numSlots() + STACK_JIT_EXTRA; return ensureSpace(cx, report, regs.sp, nvals) ? conservativeEnd_ : NULL; } /*****************************************************************************/ JS_ALWAYS_INLINE StackFrame * ContextStack::getCallFrame(JSContext *cx, MaybeReportError report, const CallArgs &args, JSFunction *fun, JSScript *script, StackFrame::Flags *flags) const { JS_ASSERT(fun->script() == script); uintN nformal = fun->nargs; Value *firstUnused = args.end(); JS_ASSERT(firstUnused == space().firstUnused()); /* Include extra space to satisfy the method-jit stackLimit invariant. */ uintN nvals = VALUES_PER_STACK_FRAME + script->nslots + StackSpace::STACK_JIT_EXTRA; /* Maintain layout invariant: &formalArgs[0] == ((Value *)fp) - nformal. */ if (args.length() == nformal) { if (!space().ensureSpace(cx, report, firstUnused, nvals)) return NULL; return reinterpret_cast<StackFrame *>(firstUnused); } if (args.length() < nformal) { *flags = StackFrame::Flags(*flags | StackFrame::UNDERFLOW_ARGS); uintN nmissing = nformal - args.length(); if (!space().ensureSpace(cx, report, firstUnused, nmissing + nvals)) return NULL; SetValueRangeToUndefined(firstUnused, nmissing); return reinterpret_cast<StackFrame *>(firstUnused + nmissing); } *flags = StackFrame::Flags(*flags | StackFrame::OVERFLOW_ARGS); uintN ncopy = 2 + nformal; if (!space().ensureSpace(cx, report, firstUnused, ncopy + nvals)) return NULL; Value *dst = firstUnused; Value *src = args.base(); PodCopy(dst, src, ncopy); return reinterpret_cast<StackFrame *>(firstUnused + ncopy); } JS_ALWAYS_INLINE bool ContextStack::pushInlineFrame(JSContext *cx, FrameRegs &regs, const CallArgs &args, JSFunction &callee, JSScript *script, InitialFrameFlags initial) { JS_ASSERT(onTop()); JS_ASSERT(regs.sp == args.end()); /* Cannot assert callee == args.callee() since this is called from LeaveTree. */ JS_ASSERT(script == callee.script()); StackFrame::Flags flags = ToFrameFlags(initial); StackFrame *fp = getCallFrame(cx, REPORT_ERROR, args, &callee, script, &flags); if (!fp) return false; /* Initialize frame, locals, regs. */ fp->initCallFrame(cx, callee, script, args.length(), flags); /* * N.B. regs may differ from the active registers, if the parent is about * to repoint the active registers to regs. See UncachedInlineCall. */ regs.prepareToRun(*fp, script); return true; } JS_ALWAYS_INLINE bool ContextStack::pushInlineFrame(JSContext *cx, FrameRegs &regs, const CallArgs &args, JSFunction &callee, JSScript *script, InitialFrameFlags initial, Value **stackLimit) { if (!pushInlineFrame(cx, regs, args, callee, script, initial)) return false; *stackLimit = space().conservativeEnd_; return true; } JS_ALWAYS_INLINE StackFrame * ContextStack::getFixupFrame(JSContext *cx, MaybeReportError report, const CallArgs &args, JSFunction *fun, JSScript *script, void *ncode, InitialFrameFlags initial, Value **stackLimit) { JS_ASSERT(onTop()); JS_ASSERT(fun->script() == args.callee().toFunction()->script()); JS_ASSERT(fun->script() == script); StackFrame::Flags flags = ToFrameFlags(initial); StackFrame *fp = getCallFrame(cx, report, args, fun, script, &flags); if (!fp) return NULL; /* Do not init late prologue or regs; this is done by jit code. */ fp->initFixupFrame(cx->fp(), flags, ncode, args.length()); *stackLimit = space().conservativeEnd_; return fp; } JS_ALWAYS_INLINE void ContextStack::popInlineFrame(FrameRegs &regs) { JS_ASSERT(onTop()); JS_ASSERT(&regs == &seg_->regs()); StackFrame *fp = regs.fp(); fp->functionEpilogue(); Value *newsp = fp->actualArgs() - 1; JS_ASSERT(newsp >= fp->prev()->base()); newsp[-1] = fp->returnValue(); regs.popFrame(newsp); } inline void ContextStack::popFrameAfterOverflow() { /* Restore the regs to what they were on entry to JSOP_CALL. */ FrameRegs &regs = seg_->regs(); StackFrame *fp = regs.fp(); regs.popFrame(fp->actualArgsEnd()); } inline JSScript * ContextStack::currentScript(jsbytecode **ppc) const { if (ppc) *ppc = NULL; FrameRegs *regs = maybeRegs(); StackFrame *fp = regs ? regs->fp() : NULL; while (fp && fp->isDummyFrame()) fp = fp->prev(); if (!fp) return NULL; #ifdef JS_METHODJIT mjit::CallSite *inlined = regs->inlined(); if (inlined) { mjit::JITChunk *chunk = fp->jit()->chunk(regs->pc); JS_ASSERT(inlined->inlineIndex < chunk->nInlineFrames); mjit::InlineFrame *frame = &chunk->inlineFrames()[inlined->inlineIndex]; JSScript *script = frame->fun->script(); if (script->compartment() != cx_->compartment) return NULL; if (ppc) *ppc = script->code + inlined->pcOffset; return script; } #endif JSScript *script = fp->script(); if (script->compartment() != cx_->compartment) return NULL; if (ppc) *ppc = fp->pcQuadratic(*this); return script; } inline JSObject * ContextStack::currentScriptedScopeChain() const { return &fp()->scopeChain(); } } /* namespace js */ #endif /* Stack_inl_h__ */
29.691456
98
0.628777
204ba010edf1ad673c1c9e4a7351b3e2049472e8
3,522
h
C
Code/CoreLibs/ShStandardHeaders.h
agh2OEb/ShareHouseEngine
9b83d120fee82522f9078801f27b0a54167c6207
[ "MIT" ]
3
2021-05-31T11:10:05.000Z
2021-10-19T07:55:18.000Z
Code/CoreLibs/ShStandardHeaders.h
agh2OEb/ShareHouseEngine
9b83d120fee82522f9078801f27b0a54167c6207
[ "MIT" ]
null
null
null
Code/CoreLibs/ShStandardHeaders.h
agh2OEb/ShareHouseEngine
9b83d120fee82522f9078801f27b0a54167c6207
[ "MIT" ]
1
2021-07-04T08:06:06.000Z
2021-07-04T08:06:06.000Z
#pragma once #include <cassert> #include <cstdio> #include <cstdlib> #include <ctime> #include <cstring> #include <cstdarg> #include <cmath> #include <memory> // STL containers #include <vector> #include <stack> #include <map> #include <string> #include <set> #include <list> #include <forward_list> #include <deque> #include <queue> #include <bitset> #include <array> #include <unordered_map> #include <unordered_set> // STL algorithms & functions #include <algorithm> #include <functional> #include <limits> #include <iterator> // C++ Stream stuff #include <fstream> #include <iostream> #include <iomanip> #include <sstream> extern "C" { #include <sys/types.h> #include <sys/stat.h> } #if SH_PLATFORM == SH_PLATFORM_MSW # undef min # undef max # if !defined(NOMINMAX) && defined(_MSC_VER) # define NOMINMAX # endif #endif #include "ShMemoryAllocator.h" SH_NAMESPACE_BEGIN struct EnumClassHash { template <typename _Type> constexpr std::size_t operator()(_Type t) const { return static_cast<std::size_t>(t); } }; template <typename _Key> using HashType = typename std::conditional<std::is_enum<_Key>::value, EnumClassHash, std::hash<_Key>>::type; template <typename _Type, typename _Alloc = StdAlloc<_Type>> using Deque = std::deque<_Type, _Alloc>; template <typename _Type, typename _Alloc = StdAlloc<_Type>> using Array = std::vector<_Type, _Alloc>; template <typename _Type, typename _Alloc = StdAlloc<_Type>> using List = std::list<_Type, _Alloc>; template <typename _Type, typename _Alloc = StdAlloc<_Type>> using ForwardList = std::forward_list<_Type, _Alloc>; template <typename _Type, typename _Alloc = StdAlloc<_Type>> using Stack = std::stack<_Type, std::deque<_Type, _Alloc>>; template <typename _Type, typename _Alloc = StdAlloc<_Type>> using Queue = std::queue<_Type, std::deque<_Type, _Alloc>>; template <typename _Type, typename _Predicate = std::less<_Type>, typename _Alloc = StdAlloc<_Type>> using Set = std::set<_Type, _Predicate, _Alloc>; template <typename _Key, typename _Value, typename _Predicate = std::less<_Key>, typename _Alloc = StdAlloc<std::pair<const _Key, _Value>>> using Map = std::map<_Key, _Value, _Predicate, _Alloc>; template <typename _Type, typename _Predicate = std::less<_Type>, typename _Alloc = StdAlloc<_Type>> using MultiSet = std::multiset<_Type, _Predicate, _Alloc>; template <typename _Key, typename _Value, typename _Predicate = std::less<_Key>, typename _Alloc = StdAlloc<std::pair<const _Key, _Value>>> using MultiMap = std::multimap<_Key, _Value, _Predicate, _Alloc>; template <typename _Type, typename _Hash = HashType<_Type>, typename _Cmp = std::equal_to<_Type>, typename _Alloc = StdAlloc<_Type>> using UnorderedSet = std::unordered_set<_Type, _Hash, _Cmp, _Alloc>; template <typename _Key, typename _Value, typename _Hash = HashType<_Key>, typename _Cmp = std::equal_to<_Key>, typename _Alloc = StdAlloc<std::pair<const _Key, _Value>>> using UnorderedMap = std::unordered_map<_Key, _Value, _Hash, _Cmp, _Alloc>; template <typename _Key, typename _Value, typename _Hash = HashType<_Key>, typename _Cmp = std::equal_to<_Key>, typename _Alloc = StdAlloc<std::pair<const _Key, _Value>>> using UnorderedMultimap = std::unordered_multimap<_Key, _Value, _Hash, _Cmp, _Alloc>; template <typename _Type> using SharedPtr = std::shared_ptr<_Type>; template <typename _Type> using WeakPtr = std::weak_ptr<_Type>; template <typename _Type, typename _Delete = Deleter<_Type>> using UniquePtr = std::unique_ptr<_Type, _Delete>; SH_NAMESPACE_END
31.446429
170
0.747019
31da2c0574729cc01fc2595aaabd54edceb54087
19,361
h
C
HALT-Sensor-Node/components/arduino-esp32/tools/sdk/include/esp-face/dl_lib_matrix3dq.h
eternalamit5/Highly-Accelerated-Life-Test-HALT-Monitoring-Tool
e04c0f3b5f446acd56de6329fbf1695792504efd
[ "MIT" ]
null
null
null
HALT-Sensor-Node/components/arduino-esp32/tools/sdk/include/esp-face/dl_lib_matrix3dq.h
eternalamit5/Highly-Accelerated-Life-Test-HALT-Monitoring-Tool
e04c0f3b5f446acd56de6329fbf1695792504efd
[ "MIT" ]
null
null
null
HALT-Sensor-Node/components/arduino-esp32/tools/sdk/include/esp-face/dl_lib_matrix3dq.h
eternalamit5/Highly-Accelerated-Life-Test-HALT-Monitoring-Tool
e04c0f3b5f446acd56de6329fbf1695792504efd
[ "MIT" ]
null
null
null
#pragma once #include "dl_lib_matrix3d.h" typedef int16_t qtp_t; /* * Matrix for 3d * @Warning: the sequence of variables is fixed, cannot be modified, otherwise there will be errors in esp_dsp_dot_float */ typedef struct { /******* fix start *******/ int w; // Width int h; // Height int c; // Channel int n; // Number, to record filter's out_channels. input and output must be 1 int stride; int exponent; qtp_t *item; /******* fix end *******/ } dl_matrix3dq_t; #ifndef DL_QTP_SHIFT #define DL_QTP_SHIFT 15 #define DL_ITMQ(m, x, y) m->itemq[(y) + (x)*m->stride] #define DL_QTP_RANGE ((1 << DL_QTP_SHIFT) - 1) #define DL_QTP_MAX 32767 #define DL_QTP_MIN -32768 #define DL_QTP_EXP_NA 255 //non-applicable exponent because matrix is null #define DL_SHIFT_AUTO 32 #endif typedef enum { DL_C_IMPL = 0, DL_XTENSA_IMPL = 1 } dl_conv_mode; typedef struct { int stride_x; int stride_y; dl_padding_type padding; dl_conv_mode mode; int dilate_exponent; int depthwise_exponent; int compress_exponent; } dl_matrix3dq_mobilenet_config_t; // // Utility // /* * @brief Allocate a 3D matrix * * @param n,w,h,c number, width, height, channel * @return 3d matrix */ dl_matrix3dq_t *dl_matrix3dq_alloc(int n, int w, int h, int c, int e); /* * @brief Free a 3D matrix * * @param m matrix */ void dl_matrix3dq_free(dl_matrix3dq_t *m); /** * @brief Zero out the matrix * Sets all entries in the matrix to 0. * * @param m Matrix to zero */ /** * @brief Copy a range of items from an existing matrix to a preallocated matrix * * @param in Old matrix (with foreign data) to re-use. Passing NULL will allocate a new matrix. * @param x X-offset of the origin of the returned matrix within the sliced matrix * @param y Y-offset of the origin of the returned matrix within the sliced matrix * @param w Width of the resulting matrix * @param h Height of the resulting matrix * @return The resulting slice matrix */ void dl_matrix3dq_slice_copy(dl_matrix3dq_t *dst, dl_matrix3dq_t *src, int x, int y, int w, int h); dl_matrix3d_t *dl_matrix3d_from_matrixq(dl_matrix3dq_t *m); dl_matrix3dq_t *dl_matrixq_from_matrix3d_qmf(dl_matrix3d_t *m, int exponent); dl_matrix3dq_t *dl_matrixq_from_matrix3d(dl_matrix3d_t *m); qtp_t dl_matrix3dq_quant_range_exceeded_checking(int64_t value, char *location); void dl_matrix3dq_shift_exponent(dl_matrix3dq_t *out, dl_matrix3dq_t *in, int exponent); void dl_matrix3dq_batch_normalize(dl_matrix3dq_t *m, dl_matrix3dq_t *scale, dl_matrix3dq_t *offset); dl_matrix3dq_t *dl_matrix3dq_add(dl_matrix3dq_t *in_1, dl_matrix3dq_t *in_2, int exponent); // // Activation // void dl_matrix3dq_relu(dl_matrix3dq_t *in); void dl_matrix3dq_relu_clip(dl_matrix3dq_t *in, fptp_t clip); void dl_matrix3dq_leaky_relu(dl_matrix3dq_t *in, fptp_t alpha, fptp_t clip); void dl_matrix3dq_p_relu(dl_matrix3dq_t *in, dl_matrix3dq_t *alpha); // // Concat // dl_matrix3dq_t *dl_matrix3dq_concat(dl_matrix3dq_t *in_1, dl_matrix3dq_t *in_2); dl_matrix3dq_t *dl_matrix3dq_concat_4(dl_matrix3dq_t *in_1, dl_matrix3dq_t *in_2, dl_matrix3dq_t *in_3, dl_matrix3dq_t *in_4); dl_matrix3dq_t *dl_matrix3dq_concat_8(dl_matrix3dq_t *in_1, dl_matrix3dq_t *in_2, dl_matrix3dq_t *in_3, dl_matrix3dq_t *in_4, dl_matrix3dq_t *in_5, dl_matrix3dq_t *in_6, dl_matrix3dq_t *in_7, dl_matrix3dq_t *in_8); // // Conv 1x1 // void dl_matrix3dqq_conv_1x1(dl_matrix3dq_t *out, dl_matrix3dq_t *in, dl_matrix3dq_t *filter, dl_conv_mode mode); void dl_matrix3dqq_conv_1x1_with_relu(dl_matrix3dq_t *out, dl_matrix3dq_t *in, dl_matrix3dq_t *filter, dl_conv_mode mode); void dl_matrix3dqq_conv_1x1_with_bias(dl_matrix3dq_t *out, dl_matrix3dq_t *in, dl_matrix3dq_t *filter, dl_matrix3dq_t *bias, dl_conv_mode mode, char *name); void dl_matrix3dqq_conv_1x1_with_prelu(dl_matrix3dq_t *out, dl_matrix3dq_t *in, dl_matrix3dq_t *filter, dl_matrix3dq_t *prelu, dl_conv_mode mode); void dl_matrix3dqq_conv_1x1_with_bias_relu(dl_matrix3dq_t *out, dl_matrix3dq_t *in, dl_matrix3dq_t *filter, dl_matrix3dq_t *bias, dl_conv_mode mode); void dl_matrix3duq_conv_1x1(dl_matrix3dq_t *out, dl_matrix3du_t *in, dl_matrix3dq_t *filter, dl_conv_mode mode); void dl_matrix3duq_conv_1x1_with_bias(dl_matrix3dq_t *out, dl_matrix3du_t *in, dl_matrix3dq_t *filter, dl_matrix3dq_t *bias, dl_conv_mode mode); // // Conv 3x3 // void dl_matrix3dqq_conv_3x3_op(dl_matrix3dq_t *out, dl_matrix3dq_t *in, dl_matrix3dq_t *f, int stride_x, int stride_y); dl_matrix3dq_t *dl_matrix3dqq_conv_3x3(dl_matrix3dq_t *in, dl_matrix3dq_t *filter, int stride_x, int stride_y, dl_padding_type padding, int exponent); dl_matrix3dq_t *dl_matrix3dqq_conv_3x3_with_bias(dl_matrix3dq_t *in, dl_matrix3dq_t *f, dl_matrix3dq_t *bias, int stride_x, int stride_y, dl_padding_type padding, int exponent, int relu); dl_matrix3dq_t *dl_matrix3duq_conv_3x3_with_bias(dl_matrix3du_t *in, dl_matrix3dq_t *filter, dl_matrix3dq_t *bias, int stride_x, int stride_y, dl_padding_type padding, int exponent, char *name); dl_matrix3dq_t *dl_matrix3duq_conv_3x3_with_bias_prelu(dl_matrix3du_t *in, dl_matrix3dq_t *filter, dl_matrix3dq_t *bias, dl_matrix3dq_t *prelu, int stride_x, int stride_y, dl_padding_type padding, int exponent, char *name); // // Conv common // /** * @brief Do a general CNN layer pass, dimension is (number, width, height, channel) * * @param in Input image * @param filter Weights of the neurons * @param bias Bias for the CNN layer. * @param stride_x The step length of the convolution window in x(width) direction * @param stride_y The step length of the convolution window in y(height) direction * @param padding One of VALID or SAME * @param mode Do convolution using C implement or xtensa implement, 0 or 1, with respect. * If ESP_PLATFORM is not defined, this value is not used. * @return The result of CNN layer. */ dl_matrix3dq_t *dl_matrix3dqq_conv_common(dl_matrix3dq_t *in, dl_matrix3dq_t *filter, dl_matrix3dq_t *bias, int stride_x, int stride_y, dl_padding_type padding, int exponent, dl_conv_mode mode); dl_matrix3dq_t *dl_matrix3duq_conv_common(dl_matrix3du_t *in, dl_matrix3dq_t *filter, dl_matrix3dq_t *bias, int stride_x, int stride_y, dl_padding_type padding, int exponent, dl_conv_mode mode); // // Depthwise 3x3 // dl_matrix3dq_t *dl_matrix3duq_depthwise_conv_3x3(dl_matrix3du_t *in, dl_matrix3dq_t *filter, int stride_x, int stride_y, dl_padding_type padding, int exponent); dl_matrix3dq_t *dl_matrix3dqq_depthwise_conv_3x3(dl_matrix3dq_t *in, dl_matrix3dq_t *filter, int stride_x, int stride_y, dl_padding_type padding, int exponent); #if CONFIG_DEVELOPING_CODE dl_matrix3dq_t *dl_matrix3dqq_depthwise_conv_3x3_2(dl_matrix3dq_t *in, dl_matrix3dq_t *filter, int stride_x, int stride_y, dl_padding_type padding, int exponent); dl_matrix3dq_t *dl_matrix3dqq_depthwise_conv_3x3_3(dl_matrix3dq_t *in, dl_matrix3dq_t *filter, int stride_x, int stride_y, dl_padding_type padding, int exponent); #endif dl_matrix3dq_t *dl_matrix3dqq_depthwise_conv_3x3_with_bias(dl_matrix3dq_t *in, dl_matrix3dq_t *f, dl_matrix3dq_t *bias, int stride_x, int stride_y, dl_padding_type padding, int exponent, int relu); dl_matrix3dq_t *dl_matrix3dqq_depthwise_conv_3x3_with_prelu(dl_matrix3dq_t *in, dl_matrix3dq_t *filter, dl_matrix3dq_t *prelu, int stride_x, int stride_y, dl_padding_type padding, int exponent); dl_matrix3dq_t *dl_matrix3dqq_depthwise_conv_3x3s1_with_bias(dl_matrix3dq_t *in, dl_matrix3dq_t *f, dl_matrix3dq_t *bias, dl_padding_type padding, int exponent, int relu); // // Depthwise Common // #if CONFIG_DEVELOPING_CODE dl_matrix3dq_t *dl_matrix3dqq_depthwise_conv_common(dl_matrix3dq_t *in, dl_matrix3dq_t *filter, int stride_x, int stride_y, dl_padding_type padding, int exponent, dl_conv_mode mode); dl_matrix3dq_t *dl_matrix3duq_depthwise_conv_common(dl_matrix3du_t *in, dl_matrix3dq_t *filter, int stride_x, int stride_y, dl_padding_type padding, int exponent, dl_conv_mode mode); #endif // // Dot Product // void dl_matrix3dqq_dot_product(dl_matrix3dq_t *out, dl_matrix3dq_t *in, dl_matrix3dq_t *filter, dl_conv_mode mode); // // FC // void dl_matrix3dqq_fc(dl_matrix3dq_t *out, dl_matrix3dq_t *in, dl_matrix3dq_t *filter, dl_conv_mode mode); void dl_matrix3dqq_fc_with_bias(dl_matrix3dq_t *out, dl_matrix3dq_t *in, dl_matrix3dq_t *filter, dl_matrix3dq_t *bias, dl_conv_mode mode, char *name); // // Mobilefaceblock // dl_matrix3dq_t *dl_matrix3dqq_mobilefaceblock_split(dl_matrix3dq_t *in, dl_matrix3dq_t *pw_1, dl_matrix3dq_t *pw_2, dl_matrix3dq_t *pw_bias, dl_matrix3dq_t *dw, dl_matrix3dq_t *dw_bias, dl_matrix3dq_t *pw_linear_1, dl_matrix3dq_t *pw_linear_2, dl_matrix3dq_t *pw_linear_bias, int pw_exponent, int dw_exponent, int pw_linear_exponent, int stride_x, int stride_y, dl_padding_type padding, dl_conv_mode mode, int shortcut); dl_matrix3dq_t *dl_matrix3dqq_mobilefaceblock(dl_matrix3dq_t *in, dl_matrix3dq_t *pw, dl_matrix3dq_t *pw_bias, dl_matrix3dq_t *dw, dl_matrix3dq_t *dw_bias, dl_matrix3dq_t *pw_linear, dl_matrix3dq_t *pw_linear_bias, int pw_exponent, int dw_exponent, int pw_linear_exponent, int stride_x, int stride_y, dl_padding_type padding, dl_conv_mode mode, int shortcut); // // Mobilenet // dl_matrix3dq_t *dl_matrix3dqq_mobilenet(dl_matrix3dq_t *in, dl_matrix3dq_t *dilate, dl_matrix3dq_t *dilate_prelu, dl_matrix3dq_t *depthwise, dl_matrix3dq_t *depth_prelu, dl_matrix3dq_t *compress, dl_matrix3dq_t *bias, dl_matrix3dq_mobilenet_config_t config, char *name); dl_matrix3dq_t *dl_matrix3duq_mobilenet(dl_matrix3du_t *in, dl_matrix3dq_t *dilate, dl_matrix3dq_t *dilate_prelu, dl_matrix3dq_t *depthwise, dl_matrix3dq_t *depth_prelu, dl_matrix3dq_t *compress, dl_matrix3dq_t *bias, dl_matrix3dq_mobilenet_config_t config, char *name); // // Padding // dl_error_type dl_matrix3dqq_padding(dl_matrix3dq_t **padded_in, dl_matrix3dq_t **out, dl_matrix3dq_t *in, int out_c, int stride_x, int stride_y, int padding, int exponent); dl_error_type dl_matrix3duq_padding(dl_matrix3du_t **padded_in, dl_matrix3dq_t **out, dl_matrix3du_t *in, int out_c, int stride_x, int stride_y, int padding, int exponent); // // Pooling // dl_matrix3dq_t *dl_matrix3dq_global_pool(dl_matrix3dq_t *in);
43.120267
120
0.417747
e168e223ac80eb396fe2dba8c4357694c7063599
5,996
c
C
ToolKit/lib/libm/common_source/expm1.c
kontais/EFI-MIPS
c4de746e6a926fc9df71231a539e2c0a170bcc90
[ "BSD-3-Clause" ]
11
2016-07-21T11:39:51.000Z
2022-01-06T10:35:12.000Z
ToolKit/lib/libm/common_source/expm1.c
kontais/EFI-MIPS
c4de746e6a926fc9df71231a539e2c0a170bcc90
[ "BSD-3-Clause" ]
1
2019-09-03T04:11:46.000Z
2019-09-03T04:11:46.000Z
ToolKit/lib/libm/common_source/expm1.c
kontais/EFI-MIPS
c4de746e6a926fc9df71231a539e2c0a170bcc90
[ "BSD-3-Clause" ]
3
2019-09-04T02:59:01.000Z
2021-08-23T06:07:28.000Z
/* * Copyright (c) 1985, 1993 * The Regents of the University of California. All rights reserved. * * Portions copyright (c) 1999, 2000 * Intel Corporation. * 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. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * * This product includes software developed by the University of * California, Berkeley, Intel Corporation, and its contributors. * * 4. Neither the name of University, Intel Corporation, or their respective * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS, INTEL CORPORATION 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 REGENTS, * INTEL CORPORATION 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 lint static char sccsid[] = "@(#)expm1.c 8.1 (Berkeley) 6/4/93"; #endif /* not lint */ /* EXPM1(X) * RETURN THE EXPONENTIAL OF X MINUS ONE * DOUBLE PRECISION (IEEE 53 BITS, VAX D FORMAT 56 BITS) * CODED IN C BY K.C. NG, 1/19/85; * REVISED BY K.C. NG on 2/6/85, 3/7/85, 3/21/85, 4/16/85. * * Required system supported functions: * scalb(x,n) * copysign(x,y) * finite(x) * * Kernel function: * exp__E(x,c) * * Method: * 1. Argument Reduction: given the input x, find r and integer k such * that * x = k*ln2 + r, |r| <= 0.5*ln2 . * r will be represented as r := z+c for better accuracy. * * 2. Compute EXPM1(r)=exp(r)-1 by * * EXPM1(r=z+c) := z + exp__E(z,c) * * 3. EXPM1(x) = 2^k * ( EXPM1(r) + 1-2^-k ). * * Remarks: * 1. When k=1 and z < -0.25, we use the following formula for * better accuracy: * EXPM1(x) = 2 * ( (z+0.5) + exp__E(z,c) ) * 2. To avoid rounding error in 1-2^-k where k is large, we use * EXPM1(x) = 2^k * { [z+(exp__E(z,c)-2^-k )] + 1 } * when k>56. * * Special cases: * EXPM1(INF) is INF, EXPM1(NaN) is NaN; * EXPM1(-INF)= -1; * for finite argument, only EXPM1(0)=0 is exact. * * Accuracy: * EXPM1(x) returns the exact (exp(x)-1) nearly rounded. In a test run with * 1,166,000 random arguments on a VAX, the maximum observed error was * .872 ulps (units of the last place). * * Constants: * The hexadecimal values are the intended ones for the following constants. * The decimal values may be used, provided that the compiler will convert * from decimal to binary accurately enough to produce the hexadecimal values * shown. */ #include "mathimpl.h" vc(ln2hi, 6.9314718055829871446E-1 ,7217,4031,0000,f7d0, 0, .B17217F7D00000) vc(ln2lo, 1.6465949582897081279E-12 ,bcd5,2ce7,d9cc,e4f1, -39, .E7BCD5E4F1D9CC) vc(lnhuge, 9.4961163736712506989E1 ,ec1d,43bd,9010,a73e, 7, .BDEC1DA73E9010) vc(invln2, 1.4426950408889634148E0 ,aa3b,40b8,17f1,295c, 1, .B8AA3B295C17F1) ic(ln2hi, 6.9314718036912381649E-1, -1, 1.62E42FEE00000) ic(ln2lo, 1.9082149292705877000E-10, -33, 1.A39EF35793C76) ic(lnhuge, 7.1602103751842355450E2, 9, 1.6602B15B7ECF2) ic(invln2, 1.4426950408889633870E0, 0, 1.71547652B82FE) #ifdef vccast #define ln2hi vccast(ln2hi) #define ln2lo vccast(ln2lo) #define lnhuge vccast(lnhuge) #define invln2 vccast(invln2) #endif double expm1(x) double x; { const static double one=1.0, half=1.0/2.0; double z,hi,lo,c; int k; #if defined(vax)||defined(tahoe) static int prec=56; #else /* defined(vax)||defined(tahoe) */ static int prec=53; #endif /* defined(vax)||defined(tahoe) */ #if !defined(vax)&&!defined(tahoe) #if defined(EFI32) || defined(EFI64) || defined(EFIX64) if (isnan(x)) return(x); /* Can't use x!=x to check for NaN with MS compiler */ #else if(x!=x) return(x); /* x is NaN */ #endif /* defined(EFI32)||defined(EFI64)||defined(EFIX64) */ #endif /* !defined(vax)&&!defined(tahoe) */ if( x <= lnhuge ) { if( x >= -40.0 ) { /* argument reduction : x - k*ln2 */ k= (int)(invln2 *x+copysign(0.5,x)); /* k=NINT(x/ln2) */ hi=x-k*ln2hi ; z=hi-(lo=k*ln2lo); c=(hi-z)-lo; if(k==0) return(z+__exp__E(z,c)); if(k==1) if(z< -0.25) {x=z+half;x +=__exp__E(z,c); return(x+x);} else {z+=__exp__E(z,c); x=half+z; return(x+x);} /* end of k=1 */ else { if(k<=prec) { x=one-scalb(one,-k); z += __exp__E(z,c);} else if(k<100) { x = __exp__E(z,c)-scalb(one,-k); x+=z; z=one;} else { x = __exp__E(z,c)+z; z=one;} return (scalb(x+z,k)); } } /* end of x > lnunfl */ else /* expm1(-big#) rounded to -1 (inexact) */ if(finite(x)) { z=ln2hi+ln2lo; return(-one);} /* expm1(-INF) is -1 */ else return(-one); } /* end of x < lnhuge */ else /* expm1(INF) is INF, expm1(+big#) overflows to INF */ return( finite(x) ? scalb(one,5000) : x); }
32.765027
90
0.654436
6e645af4158d562aab88cbf60fd3cc04262c4514
1,392
h
C
include/view/pkmnpartyview.h
lohathe/pkmnHacking
00814c2f67d8244addcafa6d8ed034c34b4aaea3
[ "MIT" ]
null
null
null
include/view/pkmnpartyview.h
lohathe/pkmnHacking
00814c2f67d8244addcafa6d8ed034c34b4aaea3
[ "MIT" ]
null
null
null
include/view/pkmnpartyview.h
lohathe/pkmnHacking
00814c2f67d8244addcafa6d8ed034c34b4aaea3
[ "MIT" ]
null
null
null
#ifndef PKMN_PARTY_VIEW #define PKMN_PARTY_VIEW #include <QWidget> #include <string> using std::string; #include "pkmnspeciespickerview.h" #include "pkmnmovepickerview.h" #include "pkmnlistview.h" #include "pkmninfoview.h" class PkmnSaveStateModel; class PkmnPartyView : public QWidget { Q_OBJECT public: PkmnPartyView(QWidget *); void connectModel(PkmnSaveStateModel *); void setSelectedPartyPkmn(int); void displayPkmnInfo(); void displaySpeciesPicker(); void displayMovePicker(); void setCoherencyEnabled(bool); signals: void partyPkmnSelectedEvent(int); void createPkmnEvent(); void deletePkmnEvent(); void pkmnSpeciesChangeEvent(); void pkmnSpeciesSelectedEvent(int); void pkmnMoveChangeEvent(int); void pkmnMoveSelectedEvent(int); void pkmnStrParamChangedEvent(int, const string &); void pkmnParameterChangedEvent(int, int); public slots: void manageChangedPkmnPartyList(); void manageChangedPkmnPartyInfo(); void managePkmnStrParamChanged(int, const string &); void managePkmnParameterChanged(int, int); void managePkmnSpeciesChange(); void managePkmnMoveChange(int); private: int _selectedPartyPkmn; bool _disableUpdate; PkmnSaveStateModel *_model; PkmnInfoView *_pkmnInfo; PkmnSpeciesPickerView *_speciesPicker; PkmnMovePickerView *_movePicker; PkmnListView *_partyList; }; #endif // PKMN_PARTY_VIEW
19.605634
54
0.77658
406aacd46562071df340386a69bde16661ca8fb5
3,049
h
C
Sources/Elastos/External/conscrypt/inc/org/conscrypt/CPlatform.h
xiaoweiruby/Elastos.RT
238e9b747f70fc129769ae7850def4362c43e443
[ "Apache-2.0" ]
1
2019-04-15T13:08:56.000Z
2019-04-15T13:08:56.000Z
Sources/Elastos/External/conscrypt/inc/org/conscrypt/CPlatform.h
xiaoweiruby/Elastos.RT
238e9b747f70fc129769ae7850def4362c43e443
[ "Apache-2.0" ]
null
null
null
Sources/Elastos/External/conscrypt/inc/org/conscrypt/CPlatform.h
xiaoweiruby/Elastos.RT
238e9b747f70fc129769ae7850def4362c43e443
[ "Apache-2.0" ]
null
null
null
//========================================================================= // Copyright (C) 2012 The Elastos Open Source Project // // 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 __ORG_CONSCRYPT_CPLATFORM_H__ #define __ORG_CONSCRYPT_CPLATFORM_H__ #include "_Org_Conscrypt_CPlatform.h" #include "elastos/core/Singleton.h" using Elastos::IO::IFileDescriptor; using Elastos::Net::ISocket; using Elastos::Security::Cert::IX509Certificate; using Elastos::Security::IPrivateKey; using Elastos::Security::Spec::IECParameterSpec; using Elastosx::Net::Ssl::ISSLParameters; using Elastosx::Net::Ssl::IX509TrustManager; namespace Org { namespace Conscrypt { CarClass(CPlatform) , public Singleton , public IPlatform { public: CAR_SINGLETON_DECL() CAR_INTERFACE_DECL() CARAPI Setup(); CARAPI GetFileDescriptor( /* [in] */ ISocket* s, /* [out] */ IFileDescriptor** result); CARAPI GetFileDescriptorFromSSLSocket( /* [in] */ IOpenSSLSocketImpl* openSSLSocketImpl, /* [out] */ IFileDescriptor** result); CARAPI GetCurveName( /* [in] */ IECParameterSpec* spec, /* [out] */ String* result); CARAPI SetCurveName( /* [in] */ IECParameterSpec* spec, /* [in] */ const String& curveName); CARAPI SetSocketTimeout( /* [in] */ ISocket* s, /* [in] */ Int64 timeoutMillis); CARAPI SetEndpointIdentificationAlgorithm( /* [in] */ ISSLParameters* params, /* [in] */ const String& endpointIdentificationAlgorithm); CARAPI GetEndpointIdentificationAlgorithm( /* [in] */ ISSLParameters* params, /* [out] */ String* result); CARAPI CheckServerTrusted( /* [in] */ IX509TrustManager* x509tm, /* [in] */ ArrayOf<IX509Certificate*>* chain, /* [in] */ const String& authType, /* [in] */ const String& host); /** * Wraps an old AndroidOpenSSL key instance. This is not needed on platform * builds since we didn't backport, so return null. This code is from * Chromium's net/android/java/src/org/chromium/net/DefaultAndroidKeyStore.java */ CARAPI WrapRsaKey( /* [in] */ IPrivateKey* javaKey, /* [out] */ IOpenSSLKey** result); /** * Logs to the system EventLog system. */ CARAPI LogEvent( /* [in] */ const String& message); }; } // namespace Conscrypt } // namespace Org #endif //__ORG_CONSCRYPT_CPLATFORM_H__
30.79798
83
0.63365
f6100e2203b07665400e5b9d1828838eb74b4b6f
523
h
C
player.h
t2222/Gamebox-version-1.000
d877c5456d908826e773278f19415b667c3a7479
[ "MIT" ]
1
2018-06-29T17:40:07.000Z
2018-06-29T17:40:07.000Z
player.h
t2222/Gamebox-version-1.000
d877c5456d908826e773278f19415b667c3a7479
[ "MIT" ]
null
null
null
player.h
t2222/Gamebox-version-1.000
d877c5456d908826e773278f19415b667c3a7479
[ "MIT" ]
1
2019-05-23T12:05:18.000Z
2019-05-23T12:05:18.000Z
#ifndef PLAYER_H #define PLAYER_H class player { int player_no; char symbol; string name; public: player(int n) { player_no = n; } void set_name() { cout << ">Player: " << player_no << " input your name :: "; cin >> name; } void set_symbol(char c) { symbol = c; } string get_name() { return name; } char get_symbol() { return symbol; } }; #endif // PLAYER_H
13.410256
68
0.453155
b6f8d214de2500f9e58d250a7f43155b30566f2c
580
h
C
include/gameaudio/IFileReader.h
YosukeM/GameAudio
49d4f5b56058b6f99d3f33438139adc07f56547a
[ "Unlicense", "MIT" ]
2
2015-06-21T09:49:21.000Z
2015-11-12T01:13:41.000Z
include/gameaudio/IFileReader.h
YosukeM/GameAudio
49d4f5b56058b6f99d3f33438139adc07f56547a
[ "Unlicense", "MIT" ]
null
null
null
include/gameaudio/IFileReader.h
YosukeM/GameAudio
49d4f5b56058b6f99d3f33438139adc07f56547a
[ "Unlicense", "MIT" ]
null
null
null
#ifndef INCLUDED_IFILEREADER_H_ #define INCLUDED_IFILEREADER_H_ namespace gameaudio { #if defined(_MSC_VER) || defined(__BORLANDC__) typedef unsigned __int64 uint64; #else typedef unsigned long long uint64; #endif class IFileReader { public: typedef enum { E_SEEK_BEG, E_SEEK_CUR, E_SEEK_END, } seek_type; virtual ~IFileReader() {}; virtual unsigned read(void* buffer, unsigned size_to_read) = 0; virtual bool seek(uint64 pos, seek_type whence = E_SEEK_BEG) = 0; virtual uint64 getSize() const = 0; virtual uint64 tell() const = 0; }; }; #endif
22.307692
67
0.727586
5e0bc1da353613078f67f73845d5af4d7b9099e7
925
h
C
include/dusk/AST/DiagnosticsParse.h
mattapet/dusk-lang
928b027429a3fd38cece78a89a9619406dcdd9f0
[ "MIT" ]
1
2022-03-30T22:01:44.000Z
2022-03-30T22:01:44.000Z
include/dusk/AST/DiagnosticsParse.h
mattapet/dusk-lang
928b027429a3fd38cece78a89a9619406dcdd9f0
[ "MIT" ]
null
null
null
include/dusk/AST/DiagnosticsParse.h
mattapet/dusk-lang
928b027429a3fd38cece78a89a9619406dcdd9f0
[ "MIT" ]
null
null
null
//===--- DiagnosticsParse.h - Parser and Lexer diagnostics ------*- C++ -*-===// // // dusk-lang // This source file is part of a dusk-lang project, which is a semestral // assignement for BI-PJP course at Czech Technical University in Prague. // The software is provided "AS IS", WITHOUT WARRANTY OF ANY KIND. // //===----------------------------------------------------------------------===// #ifndef DUSK_DIAGNOSTICS_PARSE_H #define DUSK_DIAGNOSTICS_PARSE_H #include "dusk/Basic/LLVM.h" #include "llvm/ADT/StringRef.h" namespace dusk { namespace diag { enum DiagID : unsigned { #define DIAG(Id, Text) Id, #include "dusk/AST/Diagnostics.def" }; static StringRef getTextForID(DiagID ID) { switch (ID) { #define DIAG(Id, Text) \ case DiagID::Id: return Text; #include "dusk/AST/Diagnostics.def" } } } // namespace diag } // namespace dusk #endif /* DUSK_DIAGNOSTICS_PARSE_H */
23.717949
80
0.619459
ab18f803835a8c7d10a6e3575bc4f5546619dbd8
952
h
C
FastEasyMappingTests/Models/Person.h
sathishmscict/FastEasyMappting-Report
ecb6e663b669f7f2b6f4609efefebbf0234d1343
[ "MIT" ]
586
2015-01-01T15:47:02.000Z
2021-12-10T20:27:43.000Z
FastEasyMappingTests/Models/Person.h
sathishmscict/FastEasyMappting-Report
ecb6e663b669f7f2b6f4609efefebbf0234d1343
[ "MIT" ]
100
2015-01-29T09:51:01.000Z
2020-12-10T05:43:19.000Z
FastEasyMappingTests/Models/Person.h
sathishmscict/FastEasyMappting-Report
ecb6e663b669f7f2b6f4609efefebbf0234d1343
[ "MIT" ]
115
2015-01-15T16:18:34.000Z
2022-02-22T20:11:59.000Z
// For License please refer to LICENSE file in the root of FastEasyMapping project #import <Foundation/Foundation.h> #import <CoreData/CoreData.h> @class Car; @interface Person : NSManagedObject @property (nonatomic, retain) NSNumber * personID; @property (nonatomic, retain) NSString * name; @property (nonatomic, retain) NSString * email; @property (nonatomic, retain) Car *car; @property (nonatomic, retain) NSSet *phones; @property (nonatomic, retain) NSSet<Person *> *friends; @property (nonatomic, retain) Person *partner; @end @interface Person (CoreDataGeneratedAccessors) - (void)addPhonesObject:(NSManagedObject *)value; - (void)removePhonesObject:(NSManagedObject *)value; - (void)addPhones:(NSSet *)values; - (void)removePhones:(NSSet *)values; - (void)addFriendsObject:(Person *)value; - (void)removeFriendsObject:(Person *)value; - (void)addFriends:(NSSet<Person *> *)values; - (void)removeFriends:(NSSet<Person *> *)values; @end
29.75
82
0.75
6651c7c7444c489ac6206a653209be3ef59ec14e
61
h
C
engine/source/develop/qht/public/cmake_config.h
qbkivlin1/QEngine
5cc7228892e34e0745c450a70597499b4341bdda
[ "MIT" ]
null
null
null
engine/source/develop/qht/public/cmake_config.h
qbkivlin1/QEngine
5cc7228892e34e0745c450a70597499b4341bdda
[ "MIT" ]
null
null
null
engine/source/develop/qht/public/cmake_config.h
qbkivlin1/QEngine
5cc7228892e34e0745c450a70597499b4341bdda
[ "MIT" ]
null
null
null
#define CMAKE_SOURCE_DIR "G:/QEngine/q_engine/engine/source"
30.5
60
0.819672
e2e6b9e2631c972cf8521ada83ee2549a8ba555b
1,037
h
C
common/src/main/threads/receive_from_peer_thread.h
JulianBiancardi/Wolfenstein-Taller1
28e72ce8438264919586785aa09ce9b0a5de222b
[ "MIT" ]
1
2021-04-23T19:57:40.000Z
2021-04-23T19:57:40.000Z
common/src/main/threads/receive_from_peer_thread.h
JulianBiancardi/Wolfenstein-Taller1
28e72ce8438264919586785aa09ce9b0a5de222b
[ "MIT" ]
null
null
null
common/src/main/threads/receive_from_peer_thread.h
JulianBiancardi/Wolfenstein-Taller1
28e72ce8438264919586785aa09ce9b0a5de222b
[ "MIT" ]
null
null
null
#ifndef RECEIVE_FROM_PEER_THREAD_H #define RECEIVE_FROM_PEER_THREAD_H #include <atomic> #include "../../../../common/src/main/data_structures/blocking_queue.h" #include "../../../../common/src/main/packets/packet.h" #include "../../../../common/src/main/socket/socket.h" #include "../../../../common/src/main/threads/thread.h" class ReceiveFromPeerThread : public Thread { private: unsigned int client_id; Socket& connected_socket; BlockingQueue<Packet>& reception_queue; std::atomic<bool> allowed_to_run; std::atomic<bool> running; void run() override; public: explicit ReceiveFromPeerThread(Socket& connected_socket, BlockingQueue<Packet>& reception_queue); explicit ReceiveFromPeerThread(unsigned int client_id, Socket& connected_socket, BlockingQueue<Packet>& reception_queue); ~ReceiveFromPeerThread(); void set_id(unsigned int id); bool is_running(); bool is_active(); void force_stop(); }; #endif
29.628571
73
0.672131
3948c7fc4f458495db23690e6178eef96fa47674
592
h
C
MetaNN/data/batch/batch_sequence.h
WorldEditor50/MetaNN
12c904698041904da19b71a1bdda0f939430d4c3
[ "BSL-1.0" ]
null
null
null
MetaNN/data/batch/batch_sequence.h
WorldEditor50/MetaNN
12c904698041904da19b71a1bdda0f939430d4c3
[ "BSL-1.0" ]
null
null
null
MetaNN/data/batch/batch_sequence.h
WorldEditor50/MetaNN
12c904698041904da19b71a1bdda0f939430d4c3
[ "BSL-1.0" ]
null
null
null
#ifndef DATA_BATCH_H #define DATA_BATCH_H #include "../facilities/category_tags.h" namespace MetaNN { template<typename TElem, typename TDevice> using BatchScalarSequence = StaticArray<TElem, TDevice, CategoryTags::BatchSequence, CategoryTags::Scalar>; template<typename TElem, typename TDevice> using BatchMatrixSequence = StaticArray<TElem, TDevice, CategoryTags::BatchSequence, CategoryTags::Matrix>; template<typename TElem, typename TDevice> using BatchThreeDArraySequence = StaticArray<TElem, TDevice, CategoryTags::BatchSequence, CategoryTags::ThreeDArray>; } #endif //DATA_BATCH_H
34.823529
117
0.822635
61830280555ba73768038f5643477b69f0966367
4,449
c
C
src/aeten/concurrent/posix/PThread.c
aeten/aeten-core-c
626fddf85797c5ca61b294beebb51926adb8c8b1
[ "MIT" ]
null
null
null
src/aeten/concurrent/posix/PThread.c
aeten/aeten-core-c
626fddf85797c5ca61b294beebb51926adb8c8b1
[ "MIT" ]
null
null
null
src/aeten/concurrent/posix/PThread.c
aeten/aeten-core-c
626fddf85797c5ca61b294beebb51926adb8c8b1
[ "MIT" ]
null
null
null
#define _GNU_SOURCE #include <sched.h> #include <sys/sysinfo.h> #include <pthread.h> #define impl #include "aeten/concurrent/posix/PThread.h" #define import #include "Callable.h" #include "aeten/concurrent/Lock.h" #include "aeten/concurrent/Condition.h" #include "aeten/concurrent/posix/ReentrantLock.h" #include "aeten/concurrent/posix/ReentrantLockCondition.h" /*! @startuml !include Callable.c !include aeten/concurrent/Thread.c !include aeten/concurrent/posix/ReentrantLock.c!ReentrantLock !include aeten/concurrent/posix/ReentrantLock.c!ReentrantLockCondition namespace aeten.concurrent.posix { class PThread<T> implements aeten.concurrent.Thread { + {static} PThread(char *name, Callable task, bool loop) <<constructor>> + {static} withPriorityAndAffinity(char *name, Callable task, bool loop, int priority, int scheduler, int cpu_affinity, bool detached) <<constructor>> + {static} withAttr(char *name, Callable task, bool loop, pthread_attr_t *attr) <<constructor>> - name: char* - thread: pthread_t - attr: pthread_attr_t - lock: ReentrantLock - started: ReentrantLockCondition - stopped: ReentrantLockCondition - task: Callable - run: bool <<volatile>> - running: bool } } @enduml */ static void* thread_task(void* arg); static inline void set_cpu_affinity(PThread *self, char *name, pthread_attr_t *attr, int cpu_affinity); void PThread_new(PThread *self, char *name, Callable task, bool loop) { pthread_attr_t attr; check(pthread_attr_init(&attr) == 0, PThreadException, "Unable to init attributes for thread %s", name); PThread_new_withAttr(self, name, task, loop, &attr); } void PThread_new_withPriorityAndAffinity(PThread *self, char *name, Callable task, bool loop, int priority, int scheduler, int cpu_affinity, bool detached) { pthread_attr_t attr; struct sched_param sched; check(pthread_attr_init(&attr) == 0, PThreadException, "Unable to init attributes for thread %s", name); set_cpu_affinity(self, name, &attr, cpu_affinity); sched.sched_priority = priority; check(sched_setscheduler(self->_thread, scheduler, &sched) == 0, PThreadException, "Unable to init sheduling for thread %s", name); pthread_attr_setdetachstate(&attr, detached? PTHREAD_CREATE_DETACHED: PTHREAD_CREATE_JOINABLE); PThread_new_withAttr(self, name, task, loop, &attr); } void PThread_new_withAttr(PThread *self, char *name, Callable task, bool loop, pthread_attr_t *attr) { self->_attr = *attr; self->_name = strdup(name); self->_task = task; self->_run = loop; init_ReentrantLock(&self->_lock); init_ReentrantLockCondition(&self->_started, &self->_lock._mutex); init_ReentrantLockCondition(&self->_stopped, &self->_lock._mutex); } void PThread_start(PThread *self) { ReentrantLock_lock(&self->_lock); check(pthread_create(&self->_thread, &self->_attr, &thread_task, self) != 0, PThreadException, "Unable to create thread %s", self->_name); ReentrantLock_unlock(&self->_lock); } void PThread_stop(PThread *self) { self->_run = false; } void *PThread_join(PThread *self) { void *retval; pthread_join(self->_thread, &retval); return retval; } void *thread_task(void* arg) { PThread *self = (PThread*)arg; void *retval; check(pthread_setname_np(self->_thread, self->_name) != 0, PThreadException, "Unable to rename thread to %s", self->_name); do { ReentrantLock_lock(&self->_lock); if (self->_running == false) { self->_running = true; ReentrantLockCondition_signalAll(&self->_started); } ReentrantLock_unlock(&self->_lock); retval = Callable_call(self->_task); } while(self->_run); ReentrantLock_lock(&self->_lock); self->_running = false; ReentrantLockCondition_signalAll(&self->_stopped); ReentrantLock_unlock(&self->_lock); return retval; } void set_cpu_affinity(PThread *self, char *name, pthread_attr_t *attr, int cpu_affinity) { cpu_set_t *cpusetp; size_t size; int num_cpus = get_nprocs_conf(); check((cpusetp = CPU_ALLOC(num_cpus)) != NULL, PThreadException, "Unable to allocate thread %s CPU affinity", name); size = CPU_ALLOC_SIZE(num_cpus); CPU_ZERO_S(size, cpusetp); for (int i=0; i<num_cpus; ++i) { if (((cpu_affinity >> i) & 0x1) == 0x1) { CPU_SET_S(i, size, cpusetp); } } check(pthread_attr_setaffinity_np(attr, size, cpusetp) == 0, PThreadException, "Unable to set thread %s CPU affinity 0x%x", name, cpu_affinity); CPU_FREE(cpusetp); }
35.879032
158
0.729377
5ea6682a87bdbe479b217350f421bdc048ad6fc7
3,214
c
C
testfarm/src/ck4_timer.c
hirakuni45/test
04254eab7d2398408aa0015194d4c21011f9bd7a
[ "BSD-3-Clause" ]
null
null
null
testfarm/src/ck4_timer.c
hirakuni45/test
04254eab7d2398408aa0015194d4c21011f9bd7a
[ "BSD-3-Clause" ]
null
null
null
testfarm/src/ck4_timer.c
hirakuni45/test
04254eab7d2398408aa0015194d4c21011f9bd7a
[ "BSD-3-Clause" ]
null
null
null
////////////////////////////////////////////////////////////////////////////////// // Company: T.S.Labolatory Coporation // Engineer: // // Create Date: Jul/18/2013 // Project Name: Checker4 // Module Name: ck4_imer.c // Tool versions: MPLAB v8.91 // Microchip XC16 // Description: // // Dependencies: // // Revision: 0.0.0.0 - Initial // Additional Comments: // // ////////////////////////////////////////////////////////////////////////////////// #include "common.h" #include "ck4_timer.h" #include "ck4_gpio.h" #include "ck4_gvar.h" #include "ck4_i2c.h" typedef struct { unsigned int counter; unsigned int enable; } USERTIMER; volatile USERTIMER usertimer[USERTIMER_LAST]; int c_device_no=0; #define RSW_CNT (5) /** タイマ初期化. */ void timer_init(void) { // タイマ1をオープン OpenTimer1( T1_ON /* Timer1 ON */ & T1_IDLE_CON /* operate during sleep */ & T1_GATE_OFF /* Timer Gate time accumulation disabled */ & T1_PS_1_256 /* Prescaler 1:256 */ & T1_SYNC_EXT_OFF /* Do not synch external clk input */ & T1_SOURCE_INT, /* Internal clock source */ TIMER_INTERVAL); // 1ms interval // タイマ1割り込み設定 ConfigIntTimer1( T1_INT_PRIOR_4 /* 100 = Interrupt is priority 4 */ & T1_INT_ON); /* Interrupt Enable */ } /** ユーザタイマ開始. * @param id ユーザタイマID * @param ms 時間(ms単位) */ void UserTimerStart(USERTIMER_ID id, int ms) { usertimer[id].enable = 0; // 以降の処理中にタイマ割り込みが入っても処理をしないように usertimer[id].counter = ms; // 時間(ms単位)を設定 usertimer[id].enable = 1; // 動作開始 } /** ユーザタイマ値取得 * @param id ユーザタイマID */ word UserTimerValue(USERTIMER_ID id) { return usertimer[id].counter; } /** ユーザタイマ停止. * @param id ユーザタイマID */ void UserTimerStop(USERTIMER_ID id) { usertimer[id].enable = 0; // カウンタを停止 } /** ユーザタイマ1状態. * @param id ユーザタイマID * @return カウンタ状態 1:動作中,0:停止中 */ int UserTimerStatus(USERTIMER_ID id) { return usertimer[id].enable; } /** ユーザタイマ処理. * タイマ割込みルーチンからコールされる(1msおき) */ void UserTimer_isr(void) { int i; for (i = 0; i < USERTIMER_LAST; i++) { if (usertimer[i].enable) { if (usertimer[i].counter) usertimer[i].counter--; else usertimer[i].enable = 0; } } } ///** ウェイト. // * @param ms 時間(ms単位) // */ //void wait_ms(int ms) //{ // UserTimerStart(USERTIMER1, ms); // while (UserTimerStatus(USERTIMER1)); //} /** タイマ割込み処理ルーチン. * 周期:1ms */ void __attribute__((interrupt, no_auto_psv)) _T1Interrupt(void) { static int interval_key_scan = INTERVAL_KEY_SCAN; // キーセンスマトリクス周期カウンタ int dn; TMR1 = 0; // タイマ初期化 _T1IF = 0; // 割り込みフラグクリア // 100ms周期 if (--interval_key_scan <= 0) { dn=~PORTE; dn=((dn>>4)&0xf)*10+(dn&0xf); if(pre_device_no!=dn){ c_device_no++; // if(pre_device_no!=dn) c_device_no=0; // pre_device_no=dn; if (c_device_no>=RSW_CNT){ if(define_reading==0){ device_no=dn; get_device_info(); pre_device_no=dn; } c_device_no=RSW_CNT; } } else { c_device_no=0; pre_device_no=dn; } interval_key_scan = INTERVAL_KEY_SCAN; } // ユーザタイマのカウント処理 UserTimer_isr(); }
19.245509
83
0.580896
ba8c7dd7a6d52941d304d8cf7a88d6407e6ee132
3,093
c
C
ompi/mca/mtl/portals/mtl_portals_recv_short.c
abouteiller/ulfm-legacy
720dfbd7d522b67b8ff0b3e1321676a1870c7fc8
[ "BSD-3-Clause-Open-MPI" ]
1
2021-11-22T02:06:51.000Z
2021-11-22T02:06:51.000Z
ompi/mca/mtl/portals/mtl_portals_recv_short.c
abouteiller/ulfm-legacy
720dfbd7d522b67b8ff0b3e1321676a1870c7fc8
[ "BSD-3-Clause-Open-MPI" ]
null
null
null
ompi/mca/mtl/portals/mtl_portals_recv_short.c
abouteiller/ulfm-legacy
720dfbd7d522b67b8ff0b3e1321676a1870c7fc8
[ "BSD-3-Clause-Open-MPI" ]
null
null
null
/* * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. * Copyright (c) 2004-2005 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow * * $HEADER$ */ #include "ompi_config.h" #include "ompi/constants.h" #include "mtl_portals.h" #include "mtl_portals_recv_short.h" OBJ_CLASS_INSTANCE(ompi_mtl_portals_recv_short_block_t, opal_list_item_t, NULL, NULL); int ompi_mtl_portals_recv_short_enable(mca_mtl_portals_module_t *mtl) { int i; /* create the recv blocks */ for (i = 0 ; i < mtl->ptl_recv_short_mds_num ; ++i) { ompi_mtl_portals_recv_short_block_t *block = ompi_mtl_portals_recv_short_block_init(mtl); if (NULL == block) { ompi_mtl_portals_recv_short_disable(mtl); return OMPI_ERROR; } opal_list_append(&(mtl->ptl_recv_short_blocks), (opal_list_item_t*) block); ompi_mtl_portals_activate_block(block); } return OMPI_SUCCESS; } int ompi_mtl_portals_recv_short_disable(mca_mtl_portals_module_t *mtl) { opal_list_item_t *item; if (opal_list_get_size(&mtl->ptl_recv_short_blocks) > 0) { while (NULL != (item = opal_list_remove_first(&mtl->ptl_recv_short_blocks))) { ompi_mtl_portals_recv_short_block_t *block = (ompi_mtl_portals_recv_short_block_t*) item; ompi_mtl_portals_recv_short_block_free(block); } } return OMPI_SUCCESS; } ompi_mtl_portals_recv_short_block_t* ompi_mtl_portals_recv_short_block_init(mca_mtl_portals_module_t *mtl) { ompi_mtl_portals_recv_short_block_t *block; block = OBJ_NEW(ompi_mtl_portals_recv_short_block_t); block->mtl = mtl; block->length = mtl->ptl_recv_short_mds_size; block->start = malloc(block->length); if (block->start == NULL) return NULL; block->me_h = PTL_INVALID_HANDLE; block->md_h = PTL_INVALID_HANDLE; block->full = false; block->pending = 0; return block; } int ompi_mtl_portals_recv_short_block_free(ompi_mtl_portals_recv_short_block_t *block) { /* need to clear out the md */ while (block->pending != 0) { ompi_mtl_portals_progress(); } if (PTL_INVALID_HANDLE != block->md_h) { PtlMDUnlink(block->md_h); block->md_h = PTL_INVALID_HANDLE; } if (NULL != block->start) { free(block->start); block->start = NULL; } block->length = 0; block->full = false; return OMPI_SUCCESS; }
26.895652
82
0.644682
b529837dbfe51c22a03143ac83b6671b6bec0303
9,494
c
C
utils/cli_parser.c
mrgabu/rpi-pico-simple-cli
6511ff219de5d536ac5f0bc6fc5d7eb600e1be9f
[ "MIT" ]
1
2022-01-24T00:56:57.000Z
2022-01-24T00:56:57.000Z
utils/cli_parser.c
mrgabu/rpi-pico-simple-cli
6511ff219de5d536ac5f0bc6fc5d7eb600e1be9f
[ "MIT" ]
null
null
null
utils/cli_parser.c
mrgabu/rpi-pico-simple-cli
6511ff219de5d536ac5f0bc6fc5d7eb600e1be9f
[ "MIT" ]
null
null
null
/******************************************************************************* * @file cli_parser.c * @brief Source file of cli parser implementation * @author gdurante (gbdurante@gmail.com) ********************************************************************************/ #include "pico/stdlib.h" #include "cli_parser.h" #include <errno.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> /******************************************************************************/ /*************************** Types Declarations *******************************/ /******************************************************************************/ // #define DEBUG #define CLI_PARSER_ECHO_BACK #define CLI_RX_BUFFERSIZE 1024 #define CLI_TOKENS_MAX 32 #define CLI_TOKEN_MATCH(X, Y) strcmp(X, (char const *)Y) == 0 #define CLI_COMMANDS_MAX 32 #define ASCII_EOT 4 #define ASCII_ENQ 5 #define ASCII_BS 8 #define ASCII_TAB 9 #define ASCII_LF 10 #define ASCII_VT 11 #define ASCII_FF 12 #define ASCII_CR 13 #define ASCII_SPC 32 #define ASCII_DEL 127 #define ASCII_NOT_CTRL(X) \ ((X != ASCII_EOT && X != ASCII_ENQ && X != ASCII_LF && X != ASCII_FF && \ X != ASCII_CR && X != ASCII_DEL && X != ASCII_BS)) #define ASCII_ISSPACE(X) \ ((X == ASCII_SPC || X == ASCII_TAB || X == ASCII_LF || X == ASCII_VT || \ X == ASCII_FF || X == ASCII_CR)) #define ASCII_IS_FMT_CHAR(X) \ ((X == 'i' || X == 'd' || X == 'o' || X == 'x' || X == 'f' || X == 'c' || \ X == 's')) /******************************************************************************/ /*************************** Local Variables **********************************/ /******************************************************************************/ static uint8_t cli_rx_buffer[CLI_RX_BUFFERSIZE] = {0}; static uint8_t cli_rx_buffer_idx = 0; static struct cli_parser_cmd_option cmd_option_list[CLI_COMMANDS_MAX] = {NULL}; /******************************************************************************/ /********************* Local Functions Definitions ****************************/ /******************************************************************************/ static void help_callback(int argc, const struct cli_parser_parsed_arg *args) { for (int i = 0; i < CLI_COMMANDS_MAX; i++) { if (cmd_option_list[i].name != NULL) { printf("[%s] [%i] [%s] [%s] [%s]\n", cmd_option_list[i].name, cmd_option_list[i].argc, (cmd_option_list[i].optstring != NULL) ? cmd_option_list[i].optstring : "noargs", (cmd_option_list[i].optypes != NULL) ? cmd_option_list[i].optypes : "notypes", cmd_option_list[i].help_msg); } } } static void cli_clear_buffer(void) { memset(&cli_rx_buffer[0], 0, sizeof(cli_rx_buffer)); cli_rx_buffer_idx = 0; } static uint16_t cli_tokenize_args(uint8_t *str, uint8_t **tokens) { if (!str) { return 0; } uint8_t nargs = 0; // catch 1st arg if (!ASCII_ISSPACE(*str)) { tokens[nargs++] = str; } // run through the args while (*str != '\0') { char *next_char = (char *)(str + 1); if (ASCII_ISSPACE(*str) && !ASCII_ISSPACE(*next_char)) { tokens[nargs++] = (uint8_t *)next_char; *str = '\0'; } str++; } #if defined(DEBUG) printf("nargs[%i]\n", nargs); #endif return nargs; } static uint16_t cli_tokenize_options(uint8_t *str, uint8_t **tokens) { if (!str) { return 0; } uint8_t nopts = 0; // run through the format string while (*str != '\0') { char delimiter = *(str - 1); if (ASCII_IS_FMT_CHAR(*str) && delimiter == '%') { #if defined(DEBUG) printf("fmt[%c%c]\n", delimiter, *str); #endif tokens[nopts++] = str; } str++; } #if defined(DEBUG) printf("nopts[%i]\n", nopts); #endif return nopts; } static char cli_parse_option_type(int opt, const char *optypes, int argc, int optind) { char *opts[CLI_TOKENS_MAX] = {0}; uint16_t optc = cli_tokenize_options((uint8_t *)optypes, (uint8_t **)opts); if (optc == argc) { char opt = *opts[optind]; #if defined(DEBUG) printf("opt[%c] optind[%i]\n", opt, optind); #endif return opt; } return -1; } static void cli_arg_parse(uint8_t *str) { char *argv[CLI_TOKENS_MAX] = {0}; uint16_t argc = cli_tokenize_args(str, (uint8_t **)argv); // process command for (int i = 0; i < CLI_COMMANDS_MAX; i++) { if (CLI_TOKEN_MATCH(argv[0], cmd_option_list[i].name)) { struct cli_parser_cmd_option cmd_option = cmd_option_list[i]; // parse args if (argc > 1 && argc == (cmd_option.argc + 1)) { optind = 0; int parsed_arg_idx = 0; struct cli_parser_parsed_arg cmd_parsed_arg_list[CLI_TOKENS_MAX]; while (1) { #if defined(DEBUG) printf("getopt argc[%i] optstring[%s]\n", argc, cmd_option.optstring); #endif int opt; opt = getopt(argc, argv, cmd_option.optstring); if (opt == -1 || opt == '?') { #if defined(DEBUG) printf("getopt opt[%s]\n", opt == -1 ? "-1" : "?"); #endif break; } #if defined(DEBUG) printf("opttypes [%s] idx[%i]\n", cmd_option.optypes, parsed_arg_idx); #endif char opttype = cli_parse_option_type(opt, cmd_option.optypes, cmd_option.argc, parsed_arg_idx); if (opttype != -1) { #if defined(DEBUG) printf("found matching opt[%c] optind[%i] type[%c] optarg[%s]\n", opt, optind, opttype, optarg); #endif // decode and store argument switch (opttype) { case 's': cmd_parsed_arg_list[parsed_arg_idx].type = opttype; cmd_parsed_arg_list[parsed_arg_idx].value.argument_s = optarg; parsed_arg_idx++; break; case 'i': cmd_parsed_arg_list[parsed_arg_idx].type = opttype; cmd_parsed_arg_list[parsed_arg_idx].value.argument_i = atoi(optarg); parsed_arg_idx++; break; case 'f': cmd_parsed_arg_list[parsed_arg_idx].type = opttype; cmd_parsed_arg_list[parsed_arg_idx].value.argument_f = atof(optarg); parsed_arg_idx++; break; default: break; } } } // callback if (cmd_option.callback) { cmd_option.callback(argc, cmd_parsed_arg_list); } return; } else if (argc == 1) { // callback if (cmd_option.callback) { cmd_option.callback(argc, NULL); } return; } printf("invalid number of arguments\n"); return; } } printf("command %s not found\n", argv[0]); } /******************************************************************************/ /************************ Functions Definitions *******************************/ /******************************************************************************/ void cli_parser_init(void) { // register help command cmd_option_list[0].name = "help"; cmd_option_list[0].help_msg = "print this help"; cmd_option_list[0].optstring = 0; cmd_option_list[0].optypes = 0; cmd_option_list[0].argc = 0; cmd_option_list[0].callback = help_callback; } void cli_parser_proc(void) { int rc = getchar_timeout_us(100); if (rc == PICO_ERROR_TIMEOUT) { return; } uint8_t cli_rx_data = (rc & 0xff); // check buffer size if (cli_rx_buffer_idx < CLI_RX_BUFFERSIZE) { // process current byte if (ASCII_NOT_CTRL(cli_rx_data)) // ignore unused ASCII codes { cli_rx_buffer[cli_rx_buffer_idx] = cli_rx_data; cli_rx_buffer_idx++; #if defined(CLI_PARSER_ECHO_BACK) putchar_raw(cli_rx_data); // echo data back to terminal #endif } else if (cli_rx_data == ASCII_BS || cli_rx_data == ASCII_DEL) // detele current data if backspace or delete { cli_rx_buffer[cli_rx_buffer_idx] = 0; if (cli_rx_buffer_idx >= 1) { cli_rx_buffer_idx--; } #if defined(CLI_PARSER_ECHO_BACK) putchar_raw(cli_rx_data); // echo data back to terminal #endif } else if (cli_rx_data == ASCII_CR) { if (cli_rx_buffer_idx == 0) { return; } // valid command, process it #if defined(CLI_PARSER_ECHO_BACK) putchar_raw(ASCII_FF); // clear terminal #endif printf("cli> %s\n", &cli_rx_buffer[0]); cli_arg_parse(&cli_rx_buffer[0]); cli_clear_buffer(); } } else { cli_clear_buffer(); } } void cli_parser_register_commands(const struct cli_parser_cmd_option *opts) { for (int i = 0; opts[i].name != NULL; i++) { for (int j = 0; j < CLI_COMMANDS_MAX; j++) { if (cmd_option_list[j].name == NULL) { // allocate into command list cmd_option_list[j].name = opts[i].name; cmd_option_list[j].help_msg = opts[i].help_msg; cmd_option_list[j].optstring = opts[i].optstring; cmd_option_list[j].optypes = opts[i].optypes; cmd_option_list[j].argc = opts[i].argc; cmd_option_list[j].callback = opts[i].callback; break; } } } }
31.026144
82
0.518327
b56652d28aaf79b34beb21df90b683a7c2b7d7a6
52
c
C
testdata/step_19/valid/sizeof_int_pointer_expr.c
gky360/mycc
3fe20c40e9be473578d1a6a5ba14bc460af2cf2a
[ "MIT" ]
2
2019-05-27T23:45:12.000Z
2019-06-20T14:02:11.000Z
testdata/step_19/valid/sizeof_int_pointer_expr.c
gky360/mycc
3fe20c40e9be473578d1a6a5ba14bc460af2cf2a
[ "MIT" ]
1
2019-06-07T17:23:31.000Z
2019-06-07T17:23:31.000Z
testdata/step_19/valid/sizeof_int_pointer_expr.c
gky360/mycc
3fe20c40e9be473578d1a6a5ba14bc460af2cf2a
[ "MIT" ]
null
null
null
int main() { int *p; return sizeof(p + 3); }
13
25
0.480769
d5243b3e0b1a94374b1373313d6419a9165ea45e
133
h
C
lib/textchanger.h
AlexGtTroll/Alphabet-main-project
c5838d394cfcd6891978ba75c2ebad0f7e99e985
[ "MIT" ]
6
2020-03-20T05:42:22.000Z
2020-05-30T04:35:32.000Z
lib/textchanger.h
AlexGtTroll/Alphabet-main-project
c5838d394cfcd6891978ba75c2ebad0f7e99e985
[ "MIT" ]
7
2020-03-20T06:29:22.000Z
2020-05-25T07:02:51.000Z
lib/textchanger.h
AlexGtTroll/Alphabet-main-project
c5838d394cfcd6891978ba75c2ebad0f7e99e985
[ "MIT" ]
3
2020-03-20T05:48:57.000Z
2020-05-26T06:46:20.000Z
#pragma once #include <iostream> #include <string> #include <vector> using namespace std; void textchanger(string& line, string& x);
19
42
0.75188
d5823653153f81b34d3d09fb14f6e3c54ecf15b6
1,480
h
C
src/fe/gc.h
dianpeng/sparrow
1d466bbd03e3be367e80f54f5576d20dfd77bf44
[ "MIT" ]
1
2016-10-22T18:38:56.000Z
2016-10-22T18:38:56.000Z
src/fe/gc.h
dianpeng/sparrow
1d466bbd03e3be367e80f54f5576d20dfd77bf44
[ "MIT" ]
null
null
null
src/fe/gc.h
dianpeng/sparrow
1d466bbd03e3be367e80f54f5576d20dfd77bf44
[ "MIT" ]
null
null
null
#ifndef GC_H_ #define GC_H_ #include "../conf.h" #include "object.h" #include <stdio.h> /* We just have a stop-the-world GC, but have a good trigger mechanism . In * generaly , the GC is teaked to avoid potential useless GC try. A useless * GC try means a GC is kicked in but end up without collecting anything. * We have a penalty system to avoid such GC trigger and also we have other * mechanism to avoid GC trigger becomes too lazy which means GC never tries * to kicks in at anytime */ /* helper function to *finalize* an GC manged object. Do not use it if you * don't know what it is */ void GCFinalizeObj( struct Sparrow* , struct GCRef* ); /* try to trigger a GC. If return is negative number, means no GC is triggered. * otherwise a postive number returned to represent how many objects has been * correctly touched */ int GCTry( struct Sparrow* ); /* Same as try but just force it to trigger anyway. So it will always return * a positive number */ void GCForce( struct Sparrow* ); /* Mark routine used for user to do customize cooperative GC in user data */ void GCMark ( Value value ); void GCMarkString( struct ObjStr* ); void GCMarkList( struct ObjList* ); void GCMarkMap ( struct ObjMap* ); void GCMarkUdata( struct ObjUdata* ); void GCMarkMethod(struct ObjMethod*); void GCMarkModule(struct ObjModule*); void GCMarkClosure( struct ObjClosure* ); void GCMarkComponent( struct ObjComponent* ); void GCMarkProto ( struct ObjProto* ); #endif /* GC_H_ */
37
79
0.737838
d59d323112b6da67a3ee06c432b7a800dd670f21
94,027
h
C
base/phy/phy_10g/chips/venice/vtss_venice_regs_venice_dev4.h
arktrin/mesa
9da743fa8b1cdd09bcdf3bd0fe1131df66b6b931
[ "MIT" ]
21
2020-04-21T12:15:22.000Z
2022-03-31T03:29:46.000Z
base/phy/phy_10g/chips/venice/vtss_venice_regs_venice_dev4.h
arktrin/mesa
9da743fa8b1cdd09bcdf3bd0fe1131df66b6b931
[ "MIT" ]
4
2020-12-29T12:13:29.000Z
2022-01-03T13:05:59.000Z
base/phy/phy_10g/chips/venice/vtss_venice_regs_venice_dev4.h
arktrin/mesa
9da743fa8b1cdd09bcdf3bd0fe1131df66b6b931
[ "MIT" ]
11
2020-10-14T09:43:07.000Z
2022-03-24T13:52:56.000Z
// Copyright (c) 2004-2020 Microchip Technology Inc. and its subsidiaries. // SPDX-License-Identifier: MIT #ifndef _VTSS_VENICE_REGS_VENICE_DEV4_H_ #define _VTSS_VENICE_REGS_VENICE_DEV4_H_ #include "vtss_venice_regs_common.h" /*********************************************************************** * * Target: \a VENICE_DEV4 * * * ***********************************************************************/ /** * Register Group: \a VENICE_DEV4:PHY_XS_Control_1 * * Not documented */ /** * \brief PHY XS Control 1 * * \details * Register: \a VENICE_DEV4:PHY_XS_Control_1:PHY_XS_Control_1 */ #define VTSS_VENICE_DEV4_PHY_XS_Control_1_PHY_XS_Control_1 VTSS_IOREG(0x04, 0, 0x0000) /** * \brief * MDIO Managable Device (MMD) software reset. This register resets all * portions of the channel on the host side of the failover mux. Data path * logic and configuration registers are reset. * * \details * 0: Normal operation * 1: Reset * * Field: VTSS_VENICE_DEV4_PHY_XS_Control_1_PHY_XS_Control_1 . SOFT_RST */ #define VTSS_F_VENICE_DEV4_PHY_XS_Control_1_PHY_XS_Control_1_SOFT_RST VTSS_BIT(15) /** * \brief * Enable PHY XS Network loopback (Loopback L1) * * \details * 0: Disable * 1: Enable * * Field: VTSS_VENICE_DEV4_PHY_XS_Control_1_PHY_XS_Control_1 . LPBK_L1 */ #define VTSS_F_VENICE_DEV4_PHY_XS_Control_1_PHY_XS_Control_1_LPBK_L1 VTSS_BIT(14) /** * \brief * PHY XS Speed capability * * \details * 0: Unspecified * 1: Operates at 10 Gbps or above * * Field: VTSS_VENICE_DEV4_PHY_XS_Control_1_PHY_XS_Control_1 . SPEED_SEL_A */ #define VTSS_F_VENICE_DEV4_PHY_XS_Control_1_PHY_XS_Control_1_SPEED_SEL_A VTSS_BIT(13) /** * \brief * PHY XS low power mode control. The channel's data path is placed into * low power mode with this register. The PMA in this channel is also * placed into low power mode regardless of the channel cross connect * configuration. The PMD_TRANSMIT_DISABLE.GLOBAL_PMD_TRANSMIT_DISABLE * register state can can be transmitted from a GPIO pin to shut off an * optics module's TX driver. * * \details * 0: Normal Operation * 1: Low Power Mode * * Field: VTSS_VENICE_DEV4_PHY_XS_Control_1_PHY_XS_Control_1 . LOW_PWR_PHYXS */ #define VTSS_F_VENICE_DEV4_PHY_XS_Control_1_PHY_XS_Control_1_LOW_PWR_PHYXS VTSS_BIT(11) /** * \brief * Speed selection * * \details * 0: Unspecified * 1: Operation at 10 Gb/s and above * * Field: VTSS_VENICE_DEV4_PHY_XS_Control_1_PHY_XS_Control_1 . SPEED_SEL_B */ #define VTSS_F_VENICE_DEV4_PHY_XS_Control_1_PHY_XS_Control_1_SPEED_SEL_B VTSS_BIT(6) /** * \brief * Speed selection * * \details * Field: VTSS_VENICE_DEV4_PHY_XS_Control_1_PHY_XS_Control_1 . SPEED_SEL_C */ #define VTSS_F_VENICE_DEV4_PHY_XS_Control_1_PHY_XS_Control_1_SPEED_SEL_C(x) VTSS_ENCODE_BITFIELD(x,2,4) #define VTSS_M_VENICE_DEV4_PHY_XS_Control_1_PHY_XS_Control_1_SPEED_SEL_C VTSS_ENCODE_BITMASK(2,4) #define VTSS_X_VENICE_DEV4_PHY_XS_Control_1_PHY_XS_Control_1_SPEED_SEL_C(x) VTSS_EXTRACT_BITFIELD(x,2,4) /** * Register Group: \a VENICE_DEV4:PHY_XS_Status_1 * * Not documented */ /** * \brief PHY XS Status1 * * \details * Register: \a VENICE_DEV4:PHY_XS_Status_1:PHY_XS_Status_1 */ #define VTSS_VENICE_DEV4_PHY_XS_Status_1_PHY_XS_Status_1 VTSS_IOREG(0x04, 0, 0x0001) /** * \brief * PHY XS fault status. Asserted when either PHY_XS_Status_2:FAULT_RX or * PHY_XS_Status_2:FAULT_TX are asserted. * * \details * 0: No faults asserted * 1: Fault(s) asserted * * Field: VTSS_VENICE_DEV4_PHY_XS_Status_1_PHY_XS_Status_1 . Fault */ #define VTSS_F_VENICE_DEV4_PHY_XS_Status_1_PHY_XS_Status_1_Fault VTSS_BIT(7) /** * \brief * PHY XS transmit link status. The latch-low bit is cleared when the * register is read. * * \details * 0: PHY XS transmit link is down (PHY_XS_Status_3.LANES_ALIGNED = 0) * 1: PHY XS transmit link is up (PHY_XS_Status_3.LANES_ALIGNED = 1) * * Field: VTSS_VENICE_DEV4_PHY_XS_Status_1_PHY_XS_Status_1 . PHY_XS_transmit_link_status */ #define VTSS_F_VENICE_DEV4_PHY_XS_Status_1_PHY_XS_Status_1_PHY_XS_transmit_link_status VTSS_BIT(2) /** * \brief * Low power mode support ability * * \details * 0: Not supported * 1: Supported * * Field: VTSS_VENICE_DEV4_PHY_XS_Status_1_PHY_XS_Status_1 . Low_power_ability */ #define VTSS_F_VENICE_DEV4_PHY_XS_Status_1_PHY_XS_Status_1_Low_power_ability VTSS_BIT(1) /** * Register Group: \a VENICE_DEV4:PHY_XS_Device_Identifier * * Not documented */ /** * \brief PHY XS Device Identifier 1 * * \details * Register: \a VENICE_DEV4:PHY_XS_Device_Identifier:PHY_XS_Device_Identifier_1 */ #define VTSS_VENICE_DEV4_PHY_XS_Device_Identifier_PHY_XS_Device_Identifier_1 VTSS_IOREG(0x04, 0, 0x0002) /** * \brief * Upper 16 bits of a 32-bit unique PHY XS device identifier. Bits 3-18 of * the device manufacturer's OUI. * * \details * Field: VTSS_VENICE_DEV4_PHY_XS_Device_Identifier_PHY_XS_Device_Identifier_1 . DEV_ID_MSW */ #define VTSS_F_VENICE_DEV4_PHY_XS_Device_Identifier_PHY_XS_Device_Identifier_1_DEV_ID_MSW(x) VTSS_ENCODE_BITFIELD(x,0,16) #define VTSS_M_VENICE_DEV4_PHY_XS_Device_Identifier_PHY_XS_Device_Identifier_1_DEV_ID_MSW VTSS_ENCODE_BITMASK(0,16) #define VTSS_X_VENICE_DEV4_PHY_XS_Device_Identifier_PHY_XS_Device_Identifier_1_DEV_ID_MSW(x) VTSS_EXTRACT_BITFIELD(x,0,16) /** * \brief PHY XS Device Identifier 2 * * \details * Register: \a VENICE_DEV4:PHY_XS_Device_Identifier:PHY_XS_Device_Identifier_2 */ #define VTSS_VENICE_DEV4_PHY_XS_Device_Identifier_PHY_XS_Device_Identifier_2 VTSS_IOREG(0x04, 0, 0x0003) /** * \brief * Lower 16 bits of a 32-bit unique PHY XS device identifier. Bits 19-24 of * the device manufacturer's OUI. Six-bit model number, and a four-bit * revision number. * * \details * Field: VTSS_VENICE_DEV4_PHY_XS_Device_Identifier_PHY_XS_Device_Identifier_2 . DEV_ID_LSW */ #define VTSS_F_VENICE_DEV4_PHY_XS_Device_Identifier_PHY_XS_Device_Identifier_2_DEV_ID_LSW(x) VTSS_ENCODE_BITFIELD(x,0,16) #define VTSS_M_VENICE_DEV4_PHY_XS_Device_Identifier_PHY_XS_Device_Identifier_2_DEV_ID_LSW VTSS_ENCODE_BITMASK(0,16) #define VTSS_X_VENICE_DEV4_PHY_XS_Device_Identifier_PHY_XS_Device_Identifier_2_DEV_ID_LSW(x) VTSS_EXTRACT_BITFIELD(x,0,16) /** * Register Group: \a VENICE_DEV4:PHY_XS_Speed_Capability * * Not documented */ /** * \brief PHY XS Speed Capability * * \details * Register: \a VENICE_DEV4:PHY_XS_Speed_Capability:PHY_XS_Speed_Capability */ #define VTSS_VENICE_DEV4_PHY_XS_Speed_Capability_PHY_XS_Speed_Capability VTSS_IOREG(0x04, 0, 0x0004) /** * \brief * PHY XS rate capability * * \details * 0: Not capable of 10 Gbps * 1: Capable of 10 Gbps * * Field: VTSS_VENICE_DEV4_PHY_XS_Speed_Capability_PHY_XS_Speed_Capability . RATE_ABILITY */ #define VTSS_F_VENICE_DEV4_PHY_XS_Speed_Capability_PHY_XS_Speed_Capability_RATE_ABILITY VTSS_BIT(0) /** * Register Group: \a VENICE_DEV4:PHY_XS_Devices_in_Package * * Not documented */ /** * \brief PHY XS Devices in Package 1 * * \details * Register: \a VENICE_DEV4:PHY_XS_Devices_in_Package:PHY_XS_Devices_in_Package_1 */ #define VTSS_VENICE_DEV4_PHY_XS_Devices_in_Package_PHY_XS_Devices_in_Package_1 VTSS_IOREG(0x04, 0, 0x0005) /** * \brief * Indicates whether device includes DTS XS * * \details * 0: Not present * 1: Present * * Field: VTSS_VENICE_DEV4_PHY_XS_Devices_in_Package_PHY_XS_Devices_in_Package_1 . DTE_XS_PRES */ #define VTSS_F_VENICE_DEV4_PHY_XS_Devices_in_Package_PHY_XS_Devices_in_Package_1_DTE_XS_PRES VTSS_BIT(5) /** * \brief * Indicates whether device includes PHY XS * * \details * 0: Not present * 1: Present * * Field: VTSS_VENICE_DEV4_PHY_XS_Devices_in_Package_PHY_XS_Devices_in_Package_1 . PHY_XS_PRES */ #define VTSS_F_VENICE_DEV4_PHY_XS_Devices_in_Package_PHY_XS_Devices_in_Package_1_PHY_XS_PRES VTSS_BIT(4) /** * \brief * Indicates whether PCS is present in the package * * \details * 0: Not present * 1: Present * * Field: VTSS_VENICE_DEV4_PHY_XS_Devices_in_Package_PHY_XS_Devices_in_Package_1 . PCS_PRES */ #define VTSS_F_VENICE_DEV4_PHY_XS_Devices_in_Package_PHY_XS_Devices_in_Package_1_PCS_PRES VTSS_BIT(3) /** * \brief * Indicates whether device includes WIS * * \details * 0: Not present * 1: Present * * Field: VTSS_VENICE_DEV4_PHY_XS_Devices_in_Package_PHY_XS_Devices_in_Package_1 . WIS_PRES */ #define VTSS_F_VENICE_DEV4_PHY_XS_Devices_in_Package_PHY_XS_Devices_in_Package_1_WIS_PRES VTSS_BIT(2) /** * \brief * Indicates whether PMA/PMD is present in the package * * \details * 0: Not present * 1: Present * * Field: VTSS_VENICE_DEV4_PHY_XS_Devices_in_Package_PHY_XS_Devices_in_Package_1 . PMD_PMA_PRES */ #define VTSS_F_VENICE_DEV4_PHY_XS_Devices_in_Package_PHY_XS_Devices_in_Package_1_PMD_PMA_PRES VTSS_BIT(1) /** * \brief * Indicates whether Clause 22 registers are present in the package * * \details * 0: Not present * 1: Present * * Field: VTSS_VENICE_DEV4_PHY_XS_Devices_in_Package_PHY_XS_Devices_in_Package_1 . CLS22_PRES */ #define VTSS_F_VENICE_DEV4_PHY_XS_Devices_in_Package_PHY_XS_Devices_in_Package_1_CLS22_PRES VTSS_BIT(0) /** * \brief PHY XS Devices in Package 2 * * \details * Register: \a VENICE_DEV4:PHY_XS_Devices_in_Package:PHY_XS_Devices_in_Package_2 */ #define VTSS_VENICE_DEV4_PHY_XS_Devices_in_Package_PHY_XS_Devices_in_Package_2 VTSS_IOREG(0x04, 0, 0x0006) /** * \brief * Vendor specific device 2 present * * \details * 0: Not present * 1: Present * * Field: VTSS_VENICE_DEV4_PHY_XS_Devices_in_Package_PHY_XS_Devices_in_Package_2 . VS2_PRES */ #define VTSS_F_VENICE_DEV4_PHY_XS_Devices_in_Package_PHY_XS_Devices_in_Package_2_VS2_PRES VTSS_BIT(15) /** * \brief * Vendor specific device 1 present * * \details * 0: Not present * 1: Present * * Field: VTSS_VENICE_DEV4_PHY_XS_Devices_in_Package_PHY_XS_Devices_in_Package_2 . VS1_PRES */ #define VTSS_F_VENICE_DEV4_PHY_XS_Devices_in_Package_PHY_XS_Devices_in_Package_2_VS1_PRES VTSS_BIT(14) /** * Register Group: \a VENICE_DEV4:PHY_XS_Status_2 * * Not documented */ /** * \brief PHY XS Status 2 * * \details * Register: \a VENICE_DEV4:PHY_XS_Status_2:PHY_XS_Status_2 */ #define VTSS_VENICE_DEV4_PHY_XS_Status_2_PHY_XS_Status_2 VTSS_IOREG(0x04, 0, 0x0008) /** * \brief * Reflects the presence of a MMD responding at this address * * \details * 10: Device responding at this address * 11: No device responding at this address * 10: No device responding at this address * 00: No device responding at this address * * Field: VTSS_VENICE_DEV4_PHY_XS_Status_2_PHY_XS_Status_2 . DEV_PRES */ #define VTSS_F_VENICE_DEV4_PHY_XS_Status_2_PHY_XS_Status_2_DEV_PRES(x) VTSS_ENCODE_BITFIELD(x,14,2) #define VTSS_M_VENICE_DEV4_PHY_XS_Status_2_PHY_XS_Status_2_DEV_PRES VTSS_ENCODE_BITMASK(14,2) #define VTSS_X_VENICE_DEV4_PHY_XS_Status_2_PHY_XS_Status_2_DEV_PRES(x) VTSS_EXTRACT_BITFIELD(x,14,2) /** * \brief * Indicates a fault condition on the transmit path. The latch-high bit is * cleared when the register is read. * * \details * 0: No fault condition. XGXS lanes are aligned, * PHY_XS_Status_3.LANES_ALIGNED=1 and no Tx FIFO underflow/overflow * condition. * 1: Fault condition. XGXS lanes are not aligned, * PHY_XS_Status_3.LANES_ALIGNED=0, or Tx FIFO had underflow/overflow * condition. * * Field: VTSS_VENICE_DEV4_PHY_XS_Status_2_PHY_XS_Status_2 . FAULT_TX */ #define VTSS_F_VENICE_DEV4_PHY_XS_Status_2_PHY_XS_Status_2_FAULT_TX VTSS_BIT(11) /** * \brief * Indicates a fault condition on the receive path. The latch-high bit is * cleared when the register is read. * * \details * 0: Rx PCS is locked to the data, and is not reporting a high bit error * rate, and no Rx FIFO underflow/overflow condition. * 1: Rx PCS block is not locked to the data, or is reporting a high bit * error rate, or Rx FIFO had underflow/overflow condition. * * Field: VTSS_VENICE_DEV4_PHY_XS_Status_2_PHY_XS_Status_2 . FAULT_RX */ #define VTSS_F_VENICE_DEV4_PHY_XS_Status_2_PHY_XS_Status_2_FAULT_RX VTSS_BIT(10) /** * Register Group: \a VENICE_DEV4:PHYXS_Package_Identifier * * Not documented */ /** * \brief PHYXS Package Identifier 1 * * \details * Register: \a VENICE_DEV4:PHYXS_Package_Identifier:PHYXS_Package_Identifier_1 */ #define VTSS_VENICE_DEV4_PHYXS_Package_Identifier_PHYXS_Package_Identifier_1 VTSS_IOREG(0x04, 0, 0x0009) /** * \brief * Upper 16 bits of a 32-bit unique PHY XS package identifier. Bits 3-18 of * the device manufacturer's OUI. Six-bit model number and a four-bit * revision number. * * \details * Field: VTSS_VENICE_DEV4_PHYXS_Package_Identifier_PHYXS_Package_Identifier_1 . PKG_ID_MSW */ #define VTSS_F_VENICE_DEV4_PHYXS_Package_Identifier_PHYXS_Package_Identifier_1_PKG_ID_MSW(x) VTSS_ENCODE_BITFIELD(x,0,16) #define VTSS_M_VENICE_DEV4_PHYXS_Package_Identifier_PHYXS_Package_Identifier_1_PKG_ID_MSW VTSS_ENCODE_BITMASK(0,16) #define VTSS_X_VENICE_DEV4_PHYXS_Package_Identifier_PHYXS_Package_Identifier_1_PKG_ID_MSW(x) VTSS_EXTRACT_BITFIELD(x,0,16) /** * \brief PHYXS Package Identifier 2 * * \details * Register: \a VENICE_DEV4:PHYXS_Package_Identifier:PHYXS_Package_Identifier_2 */ #define VTSS_VENICE_DEV4_PHYXS_Package_Identifier_PHYXS_Package_Identifier_2 VTSS_IOREG(0x04, 0, 0x000a) /** * \brief * Lower 16 bits of a 32-bit unique PHY XS package identifier. Bits 19-24 * of the device manufacturer's OUI. Six-bit model number and a four-bit * revision number. * * \details * Field: VTSS_VENICE_DEV4_PHYXS_Package_Identifier_PHYXS_Package_Identifier_2 . PKG_ID_LSW */ #define VTSS_F_VENICE_DEV4_PHYXS_Package_Identifier_PHYXS_Package_Identifier_2_PKG_ID_LSW(x) VTSS_ENCODE_BITFIELD(x,0,16) #define VTSS_M_VENICE_DEV4_PHYXS_Package_Identifier_PHYXS_Package_Identifier_2_PKG_ID_LSW VTSS_ENCODE_BITMASK(0,16) #define VTSS_X_VENICE_DEV4_PHYXS_Package_Identifier_PHYXS_Package_Identifier_2_PKG_ID_LSW(x) VTSS_EXTRACT_BITFIELD(x,0,16) /** * Register Group: \a VENICE_DEV4:PHY_XS_Status_3 * * Not documented */ /** * \brief PHY XS Status 3 * * \details * Register: \a VENICE_DEV4:PHY_XS_Status_3:PHY_XS_Status_3 */ #define VTSS_VENICE_DEV4_PHY_XS_Status_3_PHY_XS_Status_3 VTSS_IOREG(0x04, 0, 0x0018) /** * \brief * PHY XGXS lane alignment status. * Register bit applies only when the device is operating in 10G mode. * * \details * 0: Incoming PHY XS transmit path lanes are not aligned. * 1: Incoming PHY XS transmit path lanes are aligned. * * Field: VTSS_VENICE_DEV4_PHY_XS_Status_3_PHY_XS_Status_3 . LANES_ALIGNED */ #define VTSS_F_VENICE_DEV4_PHY_XS_Status_3_PHY_XS_Status_3_LANES_ALIGNED VTSS_BIT(12) /** * \brief * PHY XGXS test pattern generation ability * * \details * 0: PHY XS is not able to generate test patterns. * 1: PHY XS is able to generate test patterns. * * Field: VTSS_VENICE_DEV4_PHY_XS_Status_3_PHY_XS_Status_3 . PATT_ABILITY */ #define VTSS_F_VENICE_DEV4_PHY_XS_Status_3_PHY_XS_Status_3_PATT_ABILITY VTSS_BIT(11) /** * \brief * PHY XGXS loopback ability * * \details * 0: PHY XS does not have the ability to perform a loopback function * 1: PHY XS has the ability to perform a loopback function * * Field: VTSS_VENICE_DEV4_PHY_XS_Status_3_PHY_XS_Status_3 . LPBK_ABILITY */ #define VTSS_F_VENICE_DEV4_PHY_XS_Status_3_PHY_XS_Status_3_LPBK_ABILITY VTSS_BIT(10) /** * \brief * PHY XGXS lane 3 synchronization status. * Register bit applies only when the device is operating in 10G mode and * the XAUI client interface is enabled. This lane is not used in 10G * RXAUI mode. Status bit does not apply in 1G mode. * * \details * 0: Not synchronized * 1: Synchronized * * Field: VTSS_VENICE_DEV4_PHY_XS_Status_3_PHY_XS_Status_3 . LANE3_SYNC */ #define VTSS_F_VENICE_DEV4_PHY_XS_Status_3_PHY_XS_Status_3_LANE3_SYNC VTSS_BIT(3) /** * \brief * PHY XGXS lane 2 synchronization status. * Register bit applies only when the device is operating in 10G mode. * * \details * 0: Not synchronized * 1: Synchronized * * Field: VTSS_VENICE_DEV4_PHY_XS_Status_3_PHY_XS_Status_3 . LANE2_SYNC */ #define VTSS_F_VENICE_DEV4_PHY_XS_Status_3_PHY_XS_Status_3_LANE2_SYNC VTSS_BIT(2) /** * \brief * PHY XGXS lane 1 synchronization status. * Register bit applies only when the device is operating in 10G mode and * the XAUI client interface is enabled. This lane is not used in 10G * RXAUI mode. Status bit does not apply in 1G mode. * * \details * 0: Not synchronized * 1: Synchronized * * Field: VTSS_VENICE_DEV4_PHY_XS_Status_3_PHY_XS_Status_3 . LANE1_SYNC */ #define VTSS_F_VENICE_DEV4_PHY_XS_Status_3_PHY_XS_Status_3_LANE1_SYNC VTSS_BIT(1) /** * \brief * PHY XGXS lane 0 synchronization status. * Register bit applies only when the device is operating in 10G mode. * * \details * 0: Not synchronized * 1: Synchronized * * Field: VTSS_VENICE_DEV4_PHY_XS_Status_3_PHY_XS_Status_3 . LANE0_SYNC */ #define VTSS_F_VENICE_DEV4_PHY_XS_Status_3_PHY_XS_Status_3_LANE0_SYNC VTSS_BIT(0) /** * Register Group: \a VENICE_DEV4:PHY_XGXS_Test_Control_1 * * Not documented */ /** * \brief PHY XGXS Test Control 1 * * \details * Register: \a VENICE_DEV4:PHY_XGXS_Test_Control_1:PHY_XGXS_Test_Control_1 */ #define VTSS_VENICE_DEV4_PHY_XGXS_Test_Control_1_PHY_XGXS_Test_Control_1 VTSS_IOREG(0x04, 0, 0x0019) /** * \brief * PHYXS test pattern generator enable * Not supported, implemented elsewhere in the XGXS * * \details * Field: VTSS_VENICE_DEV4_PHY_XGXS_Test_Control_1_PHY_XGXS_Test_Control_1 . TST_PATT_GEN_ENA */ #define VTSS_F_VENICE_DEV4_PHY_XGXS_Test_Control_1_PHY_XGXS_Test_Control_1_TST_PATT_GEN_ENA VTSS_BIT(2) /** * \brief * PHYXS test pattern generator selection * Not supported, implemented elsewhere in the XGXS * * \details * Field: VTSS_VENICE_DEV4_PHY_XGXS_Test_Control_1_PHY_XGXS_Test_Control_1 . TST_PATT_GEN_SEL1 */ #define VTSS_F_VENICE_DEV4_PHY_XGXS_Test_Control_1_PHY_XGXS_Test_Control_1_TST_PATT_GEN_SEL1(x) VTSS_ENCODE_BITFIELD(x,0,2) #define VTSS_M_VENICE_DEV4_PHY_XGXS_Test_Control_1_PHY_XGXS_Test_Control_1_TST_PATT_GEN_SEL1 VTSS_ENCODE_BITMASK(0,2) #define VTSS_X_VENICE_DEV4_PHY_XGXS_Test_Control_1_PHY_XGXS_Test_Control_1_TST_PATT_GEN_SEL1(x) VTSS_EXTRACT_BITFIELD(x,0,2) /** * Register Group: \a VENICE_DEV4:SERDES6G_DIG_CFG * * SERDES6G Digital Configuration Registers */ /** * \brief SERDES6G Digital Configuration register * * \details * Configuration register for SERDES6G digital functions * * Register: \a VENICE_DEV4:SERDES6G_DIG_CFG:SERDES6G_DIG_CFG */ #define VTSS_VENICE_DEV4_SERDES6G_DIG_CFG_SERDES6G_DIG_CFG VTSS_IOREG(0x04, 0, 0xe600) /** * \brief * Signal detect assertion time * * \details * 0: 0 us * 1: 35 us * 2: 70 us * 3: 105 us * 4: 140 us * 5..7: reserved * * Field: VTSS_VENICE_DEV4_SERDES6G_DIG_CFG_SERDES6G_DIG_CFG . SIGDET_AST */ #define VTSS_F_VENICE_DEV4_SERDES6G_DIG_CFG_SERDES6G_DIG_CFG_SIGDET_AST(x) VTSS_ENCODE_BITFIELD(x,3,3) #define VTSS_M_VENICE_DEV4_SERDES6G_DIG_CFG_SERDES6G_DIG_CFG_SIGDET_AST VTSS_ENCODE_BITMASK(3,3) #define VTSS_X_VENICE_DEV4_SERDES6G_DIG_CFG_SERDES6G_DIG_CFG_SIGDET_AST(x) VTSS_EXTRACT_BITFIELD(x,3,3) /** * \brief * Signal detect de-assertion time * * \details * 0: 0 us * 1: 250 us * 2: 350 us * 3: 450 us * 4: 550 us * 5..7: reserved * * Field: VTSS_VENICE_DEV4_SERDES6G_DIG_CFG_SERDES6G_DIG_CFG . SIGDET_DST */ #define VTSS_F_VENICE_DEV4_SERDES6G_DIG_CFG_SERDES6G_DIG_CFG_SIGDET_DST(x) VTSS_ENCODE_BITFIELD(x,0,3) #define VTSS_M_VENICE_DEV4_SERDES6G_DIG_CFG_SERDES6G_DIG_CFG_SIGDET_DST VTSS_ENCODE_BITMASK(0,3) #define VTSS_X_VENICE_DEV4_SERDES6G_DIG_CFG_SERDES6G_DIG_CFG_SIGDET_DST(x) VTSS_EXTRACT_BITFIELD(x,0,3) /** * \brief SERDES6G DFT Configuration register 0 * * \details * Configuration register 0 for SERDES6G DFT functions * * Register: \a VENICE_DEV4:SERDES6G_DIG_CFG:SERDES6G_DFT_CFG0 */ #define VTSS_VENICE_DEV4_SERDES6G_DIG_CFG_SERDES6G_DFT_CFG0 VTSS_IOREG(0x04, 0, 0xe601) /** * \brief SERDES6G DFT Configuration register 1A * * \details * Configuration register 1A for SERDES6G DFT functions (TX direction) * * Register: \a VENICE_DEV4:SERDES6G_DIG_CFG:SERDES6G_DFT_CFG1A */ #define VTSS_VENICE_DEV4_SERDES6G_DIG_CFG_SERDES6G_DFT_CFG1A VTSS_IOREG(0x04, 0, 0xe602) /** * \brief SERDES6G DFT Configuration register 1B * * \details * Configuration register 1B for SERDES6G DFT functions (TX direction) * * Register: \a VENICE_DEV4:SERDES6G_DIG_CFG:SERDES6G_DFT_CFG1B */ #define VTSS_VENICE_DEV4_SERDES6G_DIG_CFG_SERDES6G_DFT_CFG1B VTSS_IOREG(0x04, 0, 0xe603) /** * \brief SERDES6G DFT Configuration register 2A * * \details * Configuration register 2A for SERDES6G DFT functions (RX direction) * * Register: \a VENICE_DEV4:SERDES6G_DIG_CFG:SERDES6G_DFT_CFG2A */ #define VTSS_VENICE_DEV4_SERDES6G_DIG_CFG_SERDES6G_DFT_CFG2A VTSS_IOREG(0x04, 0, 0xe604) /** * \brief SERDES6G DFT Configuration register 2B * * \details * Configuration register 2B for SERDES6G DFT functions (RX direction) * * Register: \a VENICE_DEV4:SERDES6G_DIG_CFG:SERDES6G_DFT_CFG2B */ #define VTSS_VENICE_DEV4_SERDES6G_DIG_CFG_SERDES6G_DFT_CFG2B VTSS_IOREG(0x04, 0, 0xe605) /** * \brief SERDES6G Test Pattern Configuration A * * \details * Test bits (pattern) for SERDES6G lane. These bits are used when * Lane_Test_cfg.Test_mode is set to 2 (fixed pattern) * * Register: \a VENICE_DEV4:SERDES6G_DIG_CFG:SERDES6G_TP_CFG0A */ #define VTSS_VENICE_DEV4_SERDES6G_DIG_CFG_SERDES6G_TP_CFG0A VTSS_IOREG(0x04, 0, 0xe606) /** * \brief SERDES6G Test Pattern Configuration B * * \details * Test bits (pattern) for SERDES6G lane. These bits are used when * Lane_Test_cfg.Test_mode is set to 2 (fixed pattern) * * Register: \a VENICE_DEV4:SERDES6G_DIG_CFG:SERDES6G_TP_CFG0B */ #define VTSS_VENICE_DEV4_SERDES6G_DIG_CFG_SERDES6G_TP_CFG0B VTSS_IOREG(0x04, 0, 0xe607) /** * \brief SERDES6G Test Pattern Configuration A * * \details * Test bits (pattern) for SERDES6G lane. These bits are used when * Lane_Test_cfg.Test_mode is set to 2 (fixed pattern) and * Lane_cfg.hr_mode_ena = '0'. In 20 bit modes bits from static_pattern and * static_pattern2 are transmitted alternating. * * Register: \a VENICE_DEV4:SERDES6G_DIG_CFG:SERDES6G_TP_CFG1A */ #define VTSS_VENICE_DEV4_SERDES6G_DIG_CFG_SERDES6G_TP_CFG1A VTSS_IOREG(0x04, 0, 0xe608) /** * \brief SERDES6G Test Pattern Configuration B * * \details * Test bits (pattern) for SERDES6G lane. These bits are used when * Lane_Test_cfg.Test_mode is set to 2 (fixed pattern) and * Lane_cfg.hr_mode_ena = '0'. In 20 bit modes bits from static_pattern and * static_pattern2 are transmitted alternating. * * Register: \a VENICE_DEV4:SERDES6G_DIG_CFG:SERDES6G_TP_CFG1B */ #define VTSS_VENICE_DEV4_SERDES6G_DIG_CFG_SERDES6G_TP_CFG1B VTSS_IOREG(0x04, 0, 0xe609) /** * \brief SERDES6G RCPLL BIST Configuration A * * \details * Configuration register A for the 6G RC-PLL BIST * * Register: \a VENICE_DEV4:SERDES6G_DIG_CFG:SERDES6G_RC_PLL_BIST_CFGA */ #define VTSS_VENICE_DEV4_SERDES6G_DIG_CFG_SERDES6G_RC_PLL_BIST_CFGA VTSS_IOREG(0x04, 0, 0xe60a) /** * \brief SERDES6G RCPLL BIST Configuration B * * \details * Configuration register B for the 6G RC-PLL BIST * * Register: \a VENICE_DEV4:SERDES6G_DIG_CFG:SERDES6G_RC_PLL_BIST_CFGB */ #define VTSS_VENICE_DEV4_SERDES6G_DIG_CFG_SERDES6G_RC_PLL_BIST_CFGB VTSS_IOREG(0x04, 0, 0xe60b) /** * \brief SERDES6G Misc Configuration * * \details * Configuration register for miscellaneous functions * * Register: \a VENICE_DEV4:SERDES6G_DIG_CFG:SERDES6G_MISC_CFG */ #define VTSS_VENICE_DEV4_SERDES6G_DIG_CFG_SERDES6G_MISC_CFG VTSS_IOREG(0x04, 0, 0xe60c) /** * \brief * Select recovered clock divider * * \details * 0: No clock dividing * 1: Divide clock by 5 * 2: Divide clock by 4 * 3: Reserved * * Field: VTSS_VENICE_DEV4_SERDES6G_DIG_CFG_SERDES6G_MISC_CFG . SEL_RECO_CLK */ #define VTSS_F_VENICE_DEV4_SERDES6G_DIG_CFG_SERDES6G_MISC_CFG_SEL_RECO_CLK(x) VTSS_ENCODE_BITFIELD(x,13,2) #define VTSS_M_VENICE_DEV4_SERDES6G_DIG_CFG_SERDES6G_MISC_CFG_SEL_RECO_CLK VTSS_ENCODE_BITMASK(13,2) #define VTSS_X_VENICE_DEV4_SERDES6G_DIG_CFG_SERDES6G_MISC_CFG_SEL_RECO_CLK(x) VTSS_EXTRACT_BITFIELD(x,13,2) /** * \brief * Enable deserializer cp/md handling for 100fx mode * * \details * 0: Disable * 1: Enable * * Field: VTSS_VENICE_DEV4_SERDES6G_DIG_CFG_SERDES6G_MISC_CFG . DES_100FX_CPMD_ENA */ #define VTSS_F_VENICE_DEV4_SERDES6G_DIG_CFG_SERDES6G_MISC_CFG_DES_100FX_CPMD_ENA VTSS_BIT(8) /** * \brief * Enable flipping rx databus (MSB - LSB) * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_DIG_CFG_SERDES6G_MISC_CFG . RX_BUS_FLIP_ENA */ #define VTSS_F_VENICE_DEV4_SERDES6G_DIG_CFG_SERDES6G_MISC_CFG_RX_BUS_FLIP_ENA VTSS_BIT(7) /** * \brief * Enable flipping tx databus (MSB - LSB) * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_DIG_CFG_SERDES6G_MISC_CFG . TX_BUS_FLIP_ENA */ #define VTSS_F_VENICE_DEV4_SERDES6G_DIG_CFG_SERDES6G_MISC_CFG_TX_BUS_FLIP_ENA VTSS_BIT(6) /** * \brief * Enable RX-Low-Power feature (Power control by LPI-FSM in connected PCS) * * \details * 0: Disable * 1: Enable * * Field: VTSS_VENICE_DEV4_SERDES6G_DIG_CFG_SERDES6G_MISC_CFG . RX_LPI_MODE_ENA */ #define VTSS_F_VENICE_DEV4_SERDES6G_DIG_CFG_SERDES6G_MISC_CFG_RX_LPI_MODE_ENA VTSS_BIT(5) /** * \brief * Enable TX-Low-Power feature (Power control by LPI-FSM in connected PCS) * * \details * 0: Disable * 1: Enable * * Field: VTSS_VENICE_DEV4_SERDES6G_DIG_CFG_SERDES6G_MISC_CFG . TX_LPI_MODE_ENA */ #define VTSS_F_VENICE_DEV4_SERDES6G_DIG_CFG_SERDES6G_MISC_CFG_TX_LPI_MODE_ENA VTSS_BIT(4) /** * \brief * Enable data inversion received from Deserializer * * \details * 0: Disable * 1: Enable * * Field: VTSS_VENICE_DEV4_SERDES6G_DIG_CFG_SERDES6G_MISC_CFG . RX_DATA_INV_ENA */ #define VTSS_F_VENICE_DEV4_SERDES6G_DIG_CFG_SERDES6G_MISC_CFG_RX_DATA_INV_ENA VTSS_BIT(3) /** * \brief * Enable data inversion sent to Serializer * * \details * 0: Disable * 1: Enable * * Field: VTSS_VENICE_DEV4_SERDES6G_DIG_CFG_SERDES6G_MISC_CFG . TX_DATA_INV_ENA */ #define VTSS_F_VENICE_DEV4_SERDES6G_DIG_CFG_SERDES6G_MISC_CFG_TX_DATA_INV_ENA VTSS_BIT(2) /** * \brief * Lane Reset * * \details * 0: No reset * 1: Reset (not self-clearing) * * Field: VTSS_VENICE_DEV4_SERDES6G_DIG_CFG_SERDES6G_MISC_CFG . LANE_RST */ #define VTSS_F_VENICE_DEV4_SERDES6G_DIG_CFG_SERDES6G_MISC_CFG_LANE_RST VTSS_BIT(0) /** * \brief SERDES6G OB ANEG Configuration A * * \details * Configuration register A for ANEG Output Buffer overwrite parameter. The * values are used during Backplane Ethernet Auto-Negotiation when the * output level of transmitter (OB output) have to be reduced. * * Register: \a VENICE_DEV4:SERDES6G_DIG_CFG:SERDES6G_OB_ANEG_CFGA */ #define VTSS_VENICE_DEV4_SERDES6G_DIG_CFG_SERDES6G_OB_ANEG_CFGA VTSS_IOREG(0x04, 0, 0xe60d) /** * \brief SERDES6G OB ANEG Configuration B * * \details * Configuration register B for ANEG Output Buffer overwrite parameter. The * values are used during Backplane Ethernet Auto-Negotiation when the * output level of transmitter (OB output) have to be reduced. * * Register: \a VENICE_DEV4:SERDES6G_DIG_CFG:SERDES6G_OB_ANEG_CFGB */ #define VTSS_VENICE_DEV4_SERDES6G_DIG_CFG_SERDES6G_OB_ANEG_CFGB VTSS_IOREG(0x04, 0, 0xe60e) /** * Register Group: \a VENICE_DEV4:SERDES6G_DIG_STATUS * * SERDES6G Digital Status Register */ /** * \brief SERDES6G DFT Status * * \details * Status register of SERDES6G DFT functions * * Register: \a VENICE_DEV4:SERDES6G_DIG_STATUS:SERDES6G_DFT_STATUS * * @param gi Register: SERDES6G_DIG_STATUS, 0-3 */ #define VTSS_VENICE_DEV4_SERDES6G_DIG_STATUS_SERDES6G_DFT_STATUS(gi) VTSS_IOREG_IX(0x04, 0, 0xe60f, gi, 2, 0, 0) /** * \brief SERDES6G Error Counter * * \details * Error counter for SERDES6G PRBS * * Register: \a VENICE_DEV4:SERDES6G_DIG_STATUS:SERDES6G_ERR_CNT * * @param gi Register: SERDES6G_DIG_STATUS, 0-3 */ #define VTSS_VENICE_DEV4_SERDES6G_DIG_STATUS_SERDES6G_ERR_CNT(gi) VTSS_IOREG_IX(0x04, 0, 0xe60f, gi, 2, 0, 1) /** * Register Group: \a VENICE_DEV4:SERDES6G_ANA_CFG * * SERDES6G Analog ConfigStatus Registers */ /** * \brief SERDES6G Deserializer CfgA * * \details * Configuration register A for SERDES6G deserializer * * Register: \a VENICE_DEV4:SERDES6G_ANA_CFG:SERDES6G_DES_CFGA */ #define VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_DES_CFGA VTSS_IOREG(0x04, 0, 0xe617) /** * \brief * Control of phase regulator logic (bit 3 selects input to integrator * block - 0: cp/md from DES, 1: cp/md from core) * * \details * 0: Disabled * 1: Enabled with 99 ppm limit * 2: Enabled with 202 ppm limit * 3: Enabled with 485 ppm limit * 4: Enabled if corresponding PCS is in sync with 50 ppm limit * 5: Enabled if corresponding PCS is in sync with 99 ppm limit * 6: Enabled if corresponding PCS is in sync with 202 ppm limit * 7: Enabled if corresponding PCS is in sync with 485 ppm limit * * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_DES_CFGA . DES_PHS_CTRL */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_DES_CFGA_DES_PHS_CTRL(x) VTSS_ENCODE_BITFIELD(x,0,4) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_DES_CFGA_DES_PHS_CTRL VTSS_ENCODE_BITMASK(0,4) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_DES_CFGA_DES_PHS_CTRL(x) VTSS_EXTRACT_BITFIELD(x,0,4) /** * \brief SERDES6G Deserializer CfgB * * \details * Configuration register B for SERDES6G deserializer * * Register: \a VENICE_DEV4:SERDES6G_ANA_CFG:SERDES6G_DES_CFGB */ #define VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_DES_CFGB VTSS_IOREG(0x04, 0, 0xe618) /** * \brief * Des phase control for 180 degrees deadlock block mode of operation * * \details * 000: Depending on density of input pattern * 001: Active until PCS has synchronized * 010: Depending on density of input pattern until PCS has synchronized * 011: Never * 100: Always * 111: Debug feature: Add cp/md of DES and cp/md from core * * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_DES_CFGB . DES_MBTR_CTRL */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_DES_CFGB_DES_MBTR_CTRL(x) VTSS_ENCODE_BITFIELD(x,10,3) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_DES_CFGB_DES_MBTR_CTRL VTSS_ENCODE_BITMASK(10,3) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_DES_CFGB_DES_MBTR_CTRL(x) VTSS_EXTRACT_BITFIELD(x,10,3) /** * \brief * DES phase control, main cp/md select * * \details * 00: Directly from DES * 01: Through hysteresis stage from DES * 10: From core * 11: Disabled * * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_DES_CFGB . DES_CPMD_SEL */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_DES_CFGB_DES_CPMD_SEL(x) VTSS_ENCODE_BITFIELD(x,8,2) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_DES_CFGB_DES_CPMD_SEL VTSS_ENCODE_BITMASK(8,2) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_DES_CFGB_DES_CPMD_SEL(x) VTSS_EXTRACT_BITFIELD(x,8,2) /** * \brief * Bandwidth selection. Selects dividing factor for hysteresis CP/MD * outputs. * * \details * 0: Divide by 2 * 1: Divide by 4 * 2: Divide by 8 * 3: Divide by 16 * 4: Divide by 32 * 5: Divide by 64 * 6: Divide by 128 * 7: Divide by 256 * * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_DES_CFGB . DES_BW_HYST */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_DES_CFGB_DES_BW_HYST(x) VTSS_ENCODE_BITFIELD(x,5,3) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_DES_CFGB_DES_BW_HYST VTSS_ENCODE_BITMASK(5,3) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_DES_CFGB_DES_BW_HYST(x) VTSS_EXTRACT_BITFIELD(x,5,3) /** * \brief * Bandwidth selection. Selects dividing factor for non-hysteresis CP/MD * outputs. * * \details * 0: No division * 1: Divide by 2 * 2: Divide by 4 * 3: Divide by 8 * 4: Divide by 16 * 5: Divide by 32 * 6: Divide by 64 * 7: Divide by 128 * * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_DES_CFGB . DES_BW_ANA */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_DES_CFGB_DES_BW_ANA(x) VTSS_ENCODE_BITFIELD(x,1,3) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_DES_CFGB_DES_BW_ANA VTSS_ENCODE_BITMASK(1,3) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_DES_CFGB_DES_BW_ANA(x) VTSS_EXTRACT_BITFIELD(x,1,3) /** * \brief SERDES6G IB Configuration register 0A * * \details * Configuration settings 0A * * Register: \a VENICE_DEV4:SERDES6G_ANA_CFG:SERDES6G_IB_CFG0A */ #define VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0A VTSS_IOREG(0x04, 0, 0xe619) /** * \brief * ??? * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0A . IB_SOFSI */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0A_IB_SOFSI(x) VTSS_ENCODE_BITFIELD(x,14,2) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0A_IB_SOFSI VTSS_ENCODE_BITMASK(14,2) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0A_IB_SOFSI(x) VTSS_EXTRACT_BITFIELD(x,14,2) /** * \brief * Controls Bulk Voltage of High Speed Cells * * \details * 0: High * 1: Low (mission mode) * * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0A . IB_VBULK_SEL */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0A_IB_VBULK_SEL VTSS_BIT(13) /** * \brief * Resistance adjustment for termination and CML cell regulation * * \details * 0: High R * 15: Low R * * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0A . IB_RTRM_ADJ */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0A_IB_RTRM_ADJ(x) VTSS_ENCODE_BITFIELD(x,9,4) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0A_IB_RTRM_ADJ VTSS_ENCODE_BITMASK(9,4) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0A_IB_RTRM_ADJ(x) VTSS_EXTRACT_BITFIELD(x,9,4) /** * \brief * Current adjustment for CML cells * * \details * 0: Low current * 1: high current * * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0A . IB_ICML_ADJ */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0A_IB_ICML_ADJ(x) VTSS_ENCODE_BITFIELD(x,5,4) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0A_IB_ICML_ADJ VTSS_ENCODE_BITMASK(5,4) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0A_IB_ICML_ADJ(x) VTSS_EXTRACT_BITFIELD(x,5,4) /** * \brief * Select common mode termination voltage * * \details * 0: Open * 1: VCM ref (mission mode) * 2: VDDI * 3: capacitance only * * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0A . IB_TERM_MODE_SEL */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0A_IB_TERM_MODE_SEL(x) VTSS_ENCODE_BITFIELD(x,3,2) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0A_IB_TERM_MODE_SEL VTSS_ENCODE_BITMASK(3,2) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0A_IB_TERM_MODE_SEL(x) VTSS_EXTRACT_BITFIELD(x,3,2) /** * \brief * Select signal detect clock: Frequency = 125 MHz / 2**n * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0A . IB_SIG_DET_CLK_SEL */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0A_IB_SIG_DET_CLK_SEL(x) VTSS_ENCODE_BITFIELD(x,0,3) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0A_IB_SIG_DET_CLK_SEL VTSS_ENCODE_BITMASK(0,3) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0A_IB_SIG_DET_CLK_SEL(x) VTSS_EXTRACT_BITFIELD(x,0,3) /** * \brief SERDES6G IB Configuration register 0B * * \details * Configuration settings 0B * * Register: \a VENICE_DEV4:SERDES6G_ANA_CFG:SERDES6G_IB_CFG0B */ #define VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0B VTSS_IOREG(0x04, 0, 0xe61a) /** * \brief * Selects pattern detection for regulation of high-pass-gain * * \details * 0: Only regulation assessment if basic pattern is detected * 1: Regulation assessment if basic and simplified pattern are detected * 2: Regulation assessment if basic and critical pattern are detected * 3: Regulation assessment if simplified * basic and critical pattern are detected. * * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0B . IB_REG_PAT_SEL_HP */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0B_IB_REG_PAT_SEL_HP(x) VTSS_ENCODE_BITFIELD(x,14,2) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0B_IB_REG_PAT_SEL_HP VTSS_ENCODE_BITMASK(14,2) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0B_IB_REG_PAT_SEL_HP(x) VTSS_EXTRACT_BITFIELD(x,14,2) /** * \brief * Selects pattern detection for regulation of mid-pass-gain * * \details * 0: Only regulation assessment if basic pattern is detected * 1: Regulation assessment if basic and simplified pattern are detected * 2: Regulation assessment if basic and critical pattern are detected * 3: Regulation assessment if simplified * basic and critical pattern are detected. * * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0B . IB_REG_PAT_SEL_MID */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0B_IB_REG_PAT_SEL_MID(x) VTSS_ENCODE_BITFIELD(x,12,2) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0B_IB_REG_PAT_SEL_MID VTSS_ENCODE_BITMASK(12,2) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0B_IB_REG_PAT_SEL_MID(x) VTSS_EXTRACT_BITFIELD(x,12,2) /** * \brief * Selects pattern detection for regulation of low-pass-gain * * \details * 0: Only regulation assessment if basic pattern is detected * 1: Regulation assessment if basic and simplified pattern are detected * 2: Regulation assessment if basic and critical pattern are detected * 3: Regulation assessment if simplified * basic and critical pattern are detected. * * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0B . IB_REG_PAT_SEL_LP */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0B_IB_REG_PAT_SEL_LP(x) VTSS_ENCODE_BITFIELD(x,10,2) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0B_IB_REG_PAT_SEL_LP VTSS_ENCODE_BITMASK(10,2) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0B_IB_REG_PAT_SEL_LP(x) VTSS_EXTRACT_BITFIELD(x,10,2) /** * \brief * Selects pattern detection for regulation of offset * * \details * 0: Only regulation assessment if basic pattern is detected * 1: Regulation assessment if basic and simplified pattern are detected * 2: Regulation assessment if basic and critical pattern are detected * 3: Regulation assessment if simplified * basic and critical pattern are detected. * * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0B . IB_REG_PAT_SEL_OFFSET */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0B_IB_REG_PAT_SEL_OFFSET(x) VTSS_ENCODE_BITFIELD(x,8,2) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0B_IB_REG_PAT_SEL_OFFSET VTSS_ENCODE_BITMASK(8,2) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0B_IB_REG_PAT_SEL_OFFSET(x) VTSS_EXTRACT_BITFIELD(x,8,2) /** * \brief * Enable analog test output. * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0B . IB_ANA_TEST_ENA */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0B_IB_ANA_TEST_ENA VTSS_BIT(6) /** * \brief * Enable signal detection. * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0B . IB_SIG_DET_ENA */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0B_IB_SIG_DET_ENA VTSS_BIT(5) /** * \brief * Constant current mode for CML cells * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0B . IB_CONCUR */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0B_IB_CONCUR VTSS_BIT(4) /** * \brief * Enable calibration * * \details * 0: Disable * 1: Enable * * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0B . IB_CAL_ENA */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0B_IB_CAL_ENA VTSS_BIT(3) /** * \brief * Enable SAMpling stage * * \details * 0: Disable * 1: Enable (mission mode) * * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0B . IB_SAM_ENA */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0B_IB_SAM_ENA VTSS_BIT(2) /** * \brief * Enable EQualiZation-Stage * * \details * 0: Disable * 1: Enable (mission mode) * * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0B . IB_EQZ_ENA */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0B_IB_EQZ_ENA VTSS_BIT(1) /** * \brief * Enable equalizer REGulation stage * * \details * 0: Disable * 1: Enable (mission mode) * * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0B . IB_REG_ENA */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG0B_IB_REG_ENA VTSS_BIT(0) /** * \brief SERDES6G IB Configuration register 1A * * \details * Configuration settings 1A * * Register: \a VENICE_DEV4:SERDES6G_ANA_CFG:SERDES6G_IB_CFG1A */ #define VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG1A VTSS_IOREG(0x04, 0, 0xe61b) /** * \brief * Selects threshold voltage for ac-jtag. Voltage = (n + 1) * 20 mV. * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG1A . IB_TJTAG */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG1A_IB_TJTAG(x) VTSS_ENCODE_BITFIELD(x,5,5) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG1A_IB_TJTAG VTSS_ENCODE_BITMASK(5,5) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG1A_IB_TJTAG(x) VTSS_EXTRACT_BITFIELD(x,5,5) /** * \brief * Selects threshold voltage for signal detect. Voltage = (n + 1) * 20 mV. * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG1A . IB_TSDET */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG1A_IB_TSDET(x) VTSS_ENCODE_BITFIELD(x,0,5) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG1A_IB_TSDET VTSS_ENCODE_BITMASK(0,5) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG1A_IB_TSDET(x) VTSS_EXTRACT_BITFIELD(x,0,5) /** * \brief SERDES6G IB Configuration register 1B * * \details * Configuration settings 1B * * Register: \a VENICE_DEV4:SERDES6G_ANA_CFG:SERDES6G_IB_CFG1B */ #define VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG1B VTSS_IOREG(0x04, 0, 0xe61c) /** * \brief * Selects number of calibration cycles. Zero means no calibartion, i.e. * keep default values * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG1B . IB_SCALY */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG1B_IB_SCALY(x) VTSS_ENCODE_BITFIELD(x,8,4) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG1B_IB_SCALY VTSS_ENCODE_BITMASK(8,4) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG1B_IB_SCALY(x) VTSS_EXTRACT_BITFIELD(x,8,4) /** * \brief * Selects doubled filtering of high-pass-gain regulation or set it to hold * if ib_frc_hp = 1 * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG1B . IB_FILT_HP */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG1B_IB_FILT_HP VTSS_BIT(7) /** * \brief * Selects doubled filtering of mid-pass-gain regulation or set it to hold * if ib_frc_mid = 1 * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG1B . IB_FILT_MID */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG1B_IB_FILT_MID VTSS_BIT(6) /** * \brief * Selects doubled filtering of low-pass-gain regulation or set it to hold * if ib_frc_lp = 1 * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG1B . IB_FILT_LP */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG1B_IB_FILT_LP VTSS_BIT(5) /** * \brief * Selects doubled filtering of offset regulation or set it to hold if * ib_frc_offset = 1 * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG1B . IB_FILT_OFFSET */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG1B_IB_FILT_OFFSET VTSS_BIT(4) /** * \brief * Selects manual control for high-pass-gain regulation * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG1B . IB_FRC_HP */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG1B_IB_FRC_HP VTSS_BIT(3) /** * \brief * Selects manual control for mid-pass-gain regulaltion * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG1B . IB_FRC_MID */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG1B_IB_FRC_MID VTSS_BIT(2) /** * \brief * Selects manual control for low-pass-gain regulation * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG1B . IB_FRC_LP */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG1B_IB_FRC_LP VTSS_BIT(1) /** * \brief * Selects manual control for offset regulation * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG1B . IB_FRC_OFFSET */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG1B_IB_FRC_OFFSET VTSS_BIT(0) /** * \brief SERDES6G IB Configuration register 2A * * \details * Configuration settings 2A * * Register: \a VENICE_DEV4:SERDES6G_ANA_CFG:SERDES6G_IB_CFG2A */ #define VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG2A VTSS_IOREG(0x04, 0, 0xe61d) /** * \brief * Selects maximum threshold influence for threshold calibration of vscope * samplers. Coding: 0: 40mV, 1: 80mV, ..., 7: 320mV. * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG2A . IB_TINFV */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG2A_IB_TINFV(x) VTSS_ENCODE_BITFIELD(x,12,3) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG2A_IB_TINFV VTSS_ENCODE_BITMASK(12,3) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG2A_IB_TINFV(x) VTSS_EXTRACT_BITFIELD(x,12,3) /** * \brief * Selects maximum offset influence for offset regulation. Coding: 0: 10mV, * 1: 20mV, ... * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG2A . IB_OINFI */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG2A_IB_OINFI(x) VTSS_ENCODE_BITFIELD(x,7,5) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG2A_IB_OINFI VTSS_ENCODE_BITMASK(7,5) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG2A_IB_OINFI(x) VTSS_EXTRACT_BITFIELD(x,7,5) /** * \brief * Selects maximum offset influence for offset calibration of main * samplers. Coding: 0: 40mV, 1: 80mV, ..., 7: 320mV. * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG2A . IB_OINFS */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG2A_IB_OINFS(x) VTSS_ENCODE_BITFIELD(x,0,3) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG2A_IB_OINFS VTSS_ENCODE_BITMASK(0,3) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG2A_IB_OINFS(x) VTSS_EXTRACT_BITFIELD(x,0,3) /** * \brief SERDES6G IB Configuration register 2B * * \details * Configuration settings 2B * * Register: \a VENICE_DEV4:SERDES6G_ANA_CFG:SERDES6G_IB_CFG2B */ #define VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG2B VTSS_IOREG(0x04, 0, 0xe61e) /** * \brief * Selects offset voltage for main sampler calibration. Coding: 0: -75mV, * 1: -70mV, ..., 15: 0mV, 16: 0mV, ..., 31: 75mV. * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG2B . IB_OCALS */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG2B_IB_OCALS(x) VTSS_ENCODE_BITFIELD(x,10,6) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG2B_IB_OCALS VTSS_ENCODE_BITMASK(10,6) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG2B_IB_OCALS(x) VTSS_EXTRACT_BITFIELD(x,10,6) /** * \brief * Selects threshold voltage for vscope sampler calibration. Coding: 0: * 10mV, 1: 20mV, ..., 31: 320mV. * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG2B . IB_TCALV */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG2B_IB_TCALV(x) VTSS_ENCODE_BITFIELD(x,5,5) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG2B_IB_TCALV VTSS_ENCODE_BITMASK(5,5) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG2B_IB_TCALV(x) VTSS_EXTRACT_BITFIELD(x,5,5) /** * \brief * Max. voltage of input signal. Coding: 0: 320mVppd, 1: 480mVppd, 2: * 640mVppd, 3: 800mVppd. * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG2B . IB_UMAX */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG2B_IB_UMAX(x) VTSS_ENCODE_BITFIELD(x,3,2) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG2B_IB_UMAX VTSS_ENCODE_BITMASK(3,2) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG2B_IB_UMAX(x) VTSS_EXTRACT_BITFIELD(x,3,2) /** * \brief * 0dB regulation voltage for high-speed-cells. Coding: 0: 160mV, 1: 180mV, * 2: 200mV, 3: 220mV, 4: 240mV, 5: 260mV, 6: 280mV, 7: 300mV. * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG2B . IB_UREG */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG2B_IB_UREG(x) VTSS_ENCODE_BITFIELD(x,0,3) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG2B_IB_UREG VTSS_ENCODE_BITMASK(0,3) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG2B_IB_UREG(x) VTSS_EXTRACT_BITFIELD(x,0,3) /** * \brief SERDES6G IB Configuration register 3A * * \details * Configuration settings 3A * * Register: \a VENICE_DEV4:SERDES6G_ANA_CFG:SERDES6G_IB_CFG3A */ #define VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG3A VTSS_IOREG(0x04, 0, 0xe61f) /** * \brief * Init force value for high-pass gain regulation * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG3A . IB_INI_HP */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG3A_IB_INI_HP(x) VTSS_ENCODE_BITFIELD(x,8,6) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG3A_IB_INI_HP VTSS_ENCODE_BITMASK(8,6) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG3A_IB_INI_HP(x) VTSS_EXTRACT_BITFIELD(x,8,6) /** * \brief * Init force value for mid-pass gain regulation * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG3A . IB_INI_MID */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG3A_IB_INI_MID(x) VTSS_ENCODE_BITFIELD(x,0,6) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG3A_IB_INI_MID VTSS_ENCODE_BITMASK(0,6) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG3A_IB_INI_MID(x) VTSS_EXTRACT_BITFIELD(x,0,6) /** * \brief SERDES6G IB Configuration register 3B * * \details * Configuration settings 3B * * Register: \a VENICE_DEV4:SERDES6G_ANA_CFG:SERDES6G_IB_CFG3B */ #define VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG3B VTSS_IOREG(0x04, 0, 0xe620) /** * \brief * Init force value for low-pass gain regulation * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG3B . IB_INI_LP */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG3B_IB_INI_LP(x) VTSS_ENCODE_BITFIELD(x,8,6) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG3B_IB_INI_LP VTSS_ENCODE_BITMASK(8,6) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG3B_IB_INI_LP(x) VTSS_EXTRACT_BITFIELD(x,8,6) /** * \brief * Init force value for offset gain regulation * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG3B . IB_INI_OFFSET */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG3B_IB_INI_OFFSET(x) VTSS_ENCODE_BITFIELD(x,0,6) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG3B_IB_INI_OFFSET VTSS_ENCODE_BITMASK(0,6) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG3B_IB_INI_OFFSET(x) VTSS_EXTRACT_BITFIELD(x,0,6) /** * \brief SERDES6G IB Configuration register 4A * * \details * Configuration settings 4A * * Register: \a VENICE_DEV4:SERDES6G_ANA_CFG:SERDES6G_IB_CFG4A */ #define VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG4A VTSS_IOREG(0x04, 0, 0xe621) /** * \brief * Max value for high-pass gain regulation * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG4A . IB_MAX_HP */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG4A_IB_MAX_HP(x) VTSS_ENCODE_BITFIELD(x,8,6) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG4A_IB_MAX_HP VTSS_ENCODE_BITMASK(8,6) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG4A_IB_MAX_HP(x) VTSS_EXTRACT_BITFIELD(x,8,6) /** * \brief * Max value for mid-pass gain regulation * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG4A . IB_MAX_MID */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG4A_IB_MAX_MID(x) VTSS_ENCODE_BITFIELD(x,0,6) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG4A_IB_MAX_MID VTSS_ENCODE_BITMASK(0,6) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG4A_IB_MAX_MID(x) VTSS_EXTRACT_BITFIELD(x,0,6) /** * \brief SERDES6G IB Configuration register 4B * * \details * Configuration settings 4B * * Register: \a VENICE_DEV4:SERDES6G_ANA_CFG:SERDES6G_IB_CFG4B */ #define VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG4B VTSS_IOREG(0x04, 0, 0xe622) /** * \brief * Max value for low-pass gain regulation * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG4B . IB_MAX_LP */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG4B_IB_MAX_LP(x) VTSS_ENCODE_BITFIELD(x,8,6) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG4B_IB_MAX_LP VTSS_ENCODE_BITMASK(8,6) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG4B_IB_MAX_LP(x) VTSS_EXTRACT_BITFIELD(x,8,6) /** * \brief * Max value for offset gain regulation * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG4B . IB_MAX_OFFSET */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG4B_IB_MAX_OFFSET(x) VTSS_ENCODE_BITFIELD(x,0,6) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG4B_IB_MAX_OFFSET VTSS_ENCODE_BITMASK(0,6) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG4B_IB_MAX_OFFSET(x) VTSS_EXTRACT_BITFIELD(x,0,6) /** * \brief SERDES6G IB Configuration register 5A * * \details * Configuration settings 5A * * Register: \a VENICE_DEV4:SERDES6G_ANA_CFG:SERDES6G_IB_CFG5A */ #define VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG5A VTSS_IOREG(0x04, 0, 0xe623) /** * \brief * Min value for high-pass gain regulation * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG5A . IB_MIN_HP */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG5A_IB_MIN_HP(x) VTSS_ENCODE_BITFIELD(x,8,6) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG5A_IB_MIN_HP VTSS_ENCODE_BITMASK(8,6) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG5A_IB_MIN_HP(x) VTSS_EXTRACT_BITFIELD(x,8,6) /** * \brief * Min value for mid-pass gain regulation * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG5A . IB_MIN_MID */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG5A_IB_MIN_MID(x) VTSS_ENCODE_BITFIELD(x,0,6) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG5A_IB_MIN_MID VTSS_ENCODE_BITMASK(0,6) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG5A_IB_MIN_MID(x) VTSS_EXTRACT_BITFIELD(x,0,6) /** * \brief SERDES6G IB Configuration register 5B * * \details * Configuration settings 5B * * Register: \a VENICE_DEV4:SERDES6G_ANA_CFG:SERDES6G_IB_CFG5B */ #define VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG5B VTSS_IOREG(0x04, 0, 0xe624) /** * \brief * Min value for low-pass gain regulation * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG5B . IB_MIN_LP */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG5B_IB_MIN_LP(x) VTSS_ENCODE_BITFIELD(x,8,6) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG5B_IB_MIN_LP VTSS_ENCODE_BITMASK(8,6) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG5B_IB_MIN_LP(x) VTSS_EXTRACT_BITFIELD(x,8,6) /** * \brief * Min value for offset gain regulation * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG5B . IB_MIN_OFFSET */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG5B_IB_MIN_OFFSET(x) VTSS_ENCODE_BITFIELD(x,0,6) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG5B_IB_MIN_OFFSET VTSS_ENCODE_BITMASK(0,6) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_IB_CFG5B_IB_MIN_OFFSET(x) VTSS_EXTRACT_BITFIELD(x,0,6) /** * \brief SERDES6G Output Buffer Cfg 0A * * \details * Configuration register 0A for SERDES6G output buffer * * Register: \a VENICE_DEV4:SERDES6G_ANA_CFG:SERDES6G_OB_CFG0A */ #define VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_OB_CFG0A VTSS_IOREG(0x04, 0, 0xe625) /** * \brief * PCIe support * * \details * 1: idle - force to 0V differential * 0: Normal mode * * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_OB_CFG0A . OB_IDLE */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_OB_CFG0A_OB_IDLE VTSS_BIT(15) /** * \brief * Output buffer supply voltage * * \details * 1: Set to nominal 1V * 0: Set to higher voltage * * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_OB_CFG0A . OB_ENA1V_MODE */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_OB_CFG0A_OB_ENA1V_MODE VTSS_BIT(14) /** * \brief * Polarity of output signal * * \details * 0: Normal * 1: Inverted * * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_OB_CFG0A . OB_POL */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_OB_CFG0A_OB_POL VTSS_BIT(13) /** * \brief * Coefficients for 1st Post Cursor (MSB is sign) * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_OB_CFG0A . OB_POST0 */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_OB_CFG0A_OB_POST0(x) VTSS_ENCODE_BITFIELD(x,7,6) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_OB_CFG0A_OB_POST0 VTSS_ENCODE_BITMASK(7,6) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_OB_CFG0A_OB_POST0(x) VTSS_EXTRACT_BITFIELD(x,7,6) /** * \brief * Coefficients for Pre Cursor (MSB is sign) * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_OB_CFG0A . OB_PREC */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_OB_CFG0A_OB_PREC(x) VTSS_ENCODE_BITFIELD(x,2,5) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_OB_CFG0A_OB_PREC VTSS_ENCODE_BITMASK(2,5) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_OB_CFG0A_OB_PREC(x) VTSS_EXTRACT_BITFIELD(x,2,5) /** * \brief SERDES6G Output Buffer Cfg 0B * * \details * Configuration register 0B for SERDES6G output buffer * * Register: \a VENICE_DEV4:SERDES6G_ANA_CFG:SERDES6G_OB_CFG0B */ #define VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_OB_CFG0B VTSS_IOREG(0x04, 0, 0xe626) /** * \brief * Coefficients for 2nd Post Cursor (MSB is sign) * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_OB_CFG0B . OB_POST1 */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_OB_CFG0B_OB_POST1(x) VTSS_ENCODE_BITFIELD(x,11,5) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_OB_CFG0B_OB_POST1 VTSS_ENCODE_BITMASK(11,5) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_OB_CFG0B_OB_POST1(x) VTSS_EXTRACT_BITFIELD(x,11,5) /** * \brief * Half the predriver speed, use for slew rate control * * \details * 0: Disable - slew rate < 60 ps * 1: Enable - slew rate > 60 ps * * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_OB_CFG0B . OB_SR_H */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_OB_CFG0B_OB_SR_H VTSS_BIT(8) /** * \brief * Driver speed, fine adjustment of slew rate 30-60ps (if OB_SR_H = 0), * 60-140ps (if OB_SR_H = 1) * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_OB_CFG0B . OB_SR */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_OB_CFG0B_OB_SR(x) VTSS_ENCODE_BITFIELD(x,4,4) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_OB_CFG0B_OB_SR VTSS_ENCODE_BITMASK(4,4) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_OB_CFG0B_OB_SR(x) VTSS_EXTRACT_BITFIELD(x,4,4) /** * \brief * Resistor offset (correction value) added to measured RCOMP value * (2-bit-complement, -8...7). * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_OB_CFG0B . OB_RESISTOR_CTRL */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_OB_CFG0B_OB_RESISTOR_CTRL(x) VTSS_ENCODE_BITFIELD(x,0,4) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_OB_CFG0B_OB_RESISTOR_CTRL VTSS_ENCODE_BITMASK(0,4) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_OB_CFG0B_OB_RESISTOR_CTRL(x) VTSS_EXTRACT_BITFIELD(x,0,4) /** * \brief SERDES6G Output Buffer Cfg1 * * \details * Configuration register 1 for SERDES6G output buffer * * Register: \a VENICE_DEV4:SERDES6G_ANA_CFG:SERDES6G_OB_CFG1 */ #define VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_OB_CFG1 VTSS_IOREG(0x04, 0, 0xe627) /** * \brief * Output skew, used for skew adjustment in SGMII mode * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_OB_CFG1 . OB_ENA_CAS */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_OB_CFG1_OB_ENA_CAS(x) VTSS_ENCODE_BITFIELD(x,6,3) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_OB_CFG1_OB_ENA_CAS VTSS_ENCODE_BITMASK(6,3) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_OB_CFG1_OB_ENA_CAS(x) VTSS_EXTRACT_BITFIELD(x,6,3) /** * \brief * Level of output amplitude * * \details * 0: lowest level * 63: highest level * * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_OB_CFG1 . OB_LEV */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_OB_CFG1_OB_LEV(x) VTSS_ENCODE_BITFIELD(x,0,6) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_OB_CFG1_OB_LEV VTSS_ENCODE_BITMASK(0,6) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_OB_CFG1_OB_LEV(x) VTSS_EXTRACT_BITFIELD(x,0,6) /** * \brief SERDES6G Serializer Cfg * * \details * Configuration register for SERDES6G serializer * * Register: \a VENICE_DEV4:SERDES6G_ANA_CFG:SERDES6G_SER_CFG */ #define VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_SER_CFG VTSS_IOREG(0x04, 0, 0xe628) /** * \brief * Select reference clock source for phase alignment * * \details * 00: RXCLKP * 01: RefClk15MHz * 10: RXCLKN * 11: ext. ALICLK * * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_SER_CFG . SER_ALISEL */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_SER_CFG_SER_ALISEL(x) VTSS_ENCODE_BITFIELD(x,4,2) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_SER_CFG_SER_ALISEL VTSS_ENCODE_BITMASK(4,2) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_SER_CFG_SER_ALISEL(x) VTSS_EXTRACT_BITFIELD(x,4,2) /** * \brief * Enable hysteresis for phase alignment * * \details * 0: Disable hysteresis * 1: Enable hysteresis * * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_SER_CFG . SER_ENHYS */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_SER_CFG_SER_ENHYS VTSS_BIT(3) /** * \brief * Enable window for phase alignment * * \details * 0: Disable window * 1: Enable window * * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_SER_CFG . SER_EN_WIN */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_SER_CFG_SER_EN_WIN VTSS_BIT(1) /** * \brief * Enable phase alignment * * \details * 0: Disable phase alignment * 1: Enable phase alignment * * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_SER_CFG . SER_ENALI */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_SER_CFG_SER_ENALI VTSS_BIT(0) /** * \brief SERDES6G Common CfgA * * \details * Configuration register A for common SERDES6G functions * * Register: \a VENICE_DEV4:SERDES6G_ANA_CFG:SERDES6G_COMMON_CFGA */ #define VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_COMMON_CFGA VTSS_IOREG(0x04, 0, 0xe629) /** * \brief * System reset (low active) * * \details * 0: Apply reset (not self-clearing) * 1: Reset released * * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_COMMON_CFGA . SYS_RST */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_COMMON_CFGA_SYS_RST VTSS_BIT(15) /** * \brief * Enable auto-squelching for sync. ethernet bus B * * \details * 0: Disable * 1: Enable * * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_COMMON_CFGA . SE_AUTO_SQUELCH_B_ENA */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_COMMON_CFGA_SE_AUTO_SQUELCH_B_ENA VTSS_BIT(6) /** * \brief * Enable auto-squelching for sync. ethernet bus A * * \details * 0: Disable * 1: Enable * * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_COMMON_CFGA . SE_AUTO_SQUELCH_A_ENA */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_COMMON_CFGA_SE_AUTO_SQUELCH_A_ENA VTSS_BIT(5) /** * \brief * Select recovered clock of this lane on sync. ethernet bus B * * \details * 0: Lane not selected * 1: Lane selected * * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_COMMON_CFGA . RECO_SEL_B */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_COMMON_CFGA_RECO_SEL_B VTSS_BIT(4) /** * \brief * Select recovered clock of this lane on sync. ethernet bus A * * \details * 0: Lane not selected * 1: Lane selected * * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_COMMON_CFGA . RECO_SEL_A */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_COMMON_CFGA_RECO_SEL_A VTSS_BIT(3) /** * \brief * Enable lane * * \details * 0: Disable lane * 1: Enable line * * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_COMMON_CFGA . ENA_LANE */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_COMMON_CFGA_ENA_LANE VTSS_BIT(2) /** * \brief SERDES6G Common CfgB * * \details * Configuration register B for common SERDES6G functions Note: When * enabling the facility loop (ena_floop) also the phase alignment in the * serializer has to be enabled and configured adequate. * * Register: \a VENICE_DEV4:SERDES6G_ANA_CFG:SERDES6G_COMMON_CFGB */ #define VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_COMMON_CFGB VTSS_IOREG(0x04, 0, 0xe62a) /** * \brief * Enable equipment loop * * \details * 0: Disable * 1: Enable * * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_COMMON_CFGB . ENA_ELOOP */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_COMMON_CFGB_ENA_ELOOP VTSS_BIT(11) /** * \brief * Enable facility loop * * \details * 0: Disable * 1: Enable * * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_COMMON_CFGB . ENA_FLOOP */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_COMMON_CFGB_ENA_FLOOP VTSS_BIT(10) /** * \brief * Enable half rate * * \details * 0: Disable * 1: Enable * * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_COMMON_CFGB . HRATE */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_COMMON_CFGB_HRATE VTSS_BIT(7) /** * \brief * Enable quarter rate * * \details * 0: Disable * 1: Enable * * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_COMMON_CFGB . QRATE */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_COMMON_CFGB_QRATE VTSS_BIT(6) /** * \brief * Interface mode * * \details * 0: 8-bit mode * 1: 10-bit mode * 2: 16-bit mode * 3: 20-bit mode * * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_COMMON_CFGB . IF_MODE */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_COMMON_CFGB_IF_MODE(x) VTSS_ENCODE_BITFIELD(x,4,2) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_COMMON_CFGB_IF_MODE VTSS_ENCODE_BITMASK(4,2) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_COMMON_CFGB_IF_MODE(x) VTSS_EXTRACT_BITFIELD(x,4,2) /** * \brief SERDES6G Pll CfgA * * \details * Configuration register A for SERDES6G RCPLL * * Register: \a VENICE_DEV4:SERDES6G_ANA_CFG:SERDES6G_PLL_CFGA */ #define VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_PLL_CFGA VTSS_IOREG(0x04, 0, 0xe62b) /** * \brief * Enable offset compensation B1: Feedback path; B0: VCO. * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_PLL_CFGA . PLL_ENA_OFFS */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_PLL_CFGA_PLL_ENA_OFFS(x) VTSS_ENCODE_BITFIELD(x,2,2) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_PLL_CFGA_PLL_ENA_OFFS VTSS_ENCODE_BITMASK(2,2) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_PLL_CFGA_PLL_ENA_OFFS(x) VTSS_EXTRACT_BITFIELD(x,2,2) /** * \brief * Enable div4 mode * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_PLL_CFGA . PLL_DIV4 */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_PLL_CFGA_PLL_DIV4 VTSS_BIT(1) /** * \brief * Enable rotation * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_PLL_CFGA . PLL_ENA_ROT */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_PLL_CFGA_PLL_ENA_ROT VTSS_BIT(0) /** * \brief SERDES6G Pll CfgB * * \details * Configuration register B for SERDES6G RCPLL * * Register: \a VENICE_DEV4:SERDES6G_ANA_CFG:SERDES6G_PLL_CFGB */ #define VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_PLL_CFGB VTSS_IOREG(0x04, 0, 0xe62c) /** * \brief * Control data for FSM * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_PLL_CFGB . PLL_FSM_CTRL_DATA */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_PLL_CFGB_PLL_FSM_CTRL_DATA(x) VTSS_ENCODE_BITFIELD(x,8,8) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_PLL_CFGB_PLL_FSM_CTRL_DATA VTSS_ENCODE_BITMASK(8,8) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_PLL_CFGB_PLL_FSM_CTRL_DATA(x) VTSS_EXTRACT_BITFIELD(x,8,8) /** * \brief * Enable FSM * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_PLL_CFGB . PLL_FSM_ENA */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_PLL_CFGB_PLL_FSM_ENA VTSS_BIT(7) /** * \brief * Select rotation direction * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_PLL_CFGB . PLL_ROT_DIR */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_PLL_CFGB_PLL_ROT_DIR VTSS_BIT(2) /** * \brief * Select rotation frequency * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_PLL_CFGB . PLL_ROT_FRQ */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_PLL_CFGB_PLL_ROT_FRQ VTSS_BIT(1) /** * \brief SERDES6G ACJTAG Cfg * * \details * Configuration register for (AC)JTAG debug capability * * Register: \a VENICE_DEV4:SERDES6G_ANA_CFG:SERDES6G_ACJTAG_CFG */ #define VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_ACJTAG_CFG VTSS_IOREG(0x04, 0, 0xe62d) /** * \brief * ACJTAG init data for n leg * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_ACJTAG_CFG . ACJTAG_INIT_DATA_N */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_ACJTAG_CFG_ACJTAG_INIT_DATA_N VTSS_BIT(5) /** * \brief * ACJTAG init data for p leg * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_ACJTAG_CFG . ACJTAG_INIT_DATA_P */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_ACJTAG_CFG_ACJTAG_INIT_DATA_P VTSS_BIT(4) /** * \brief * ACJTAG clock line * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_ACJTAG_CFG . ACJTAG_INIT_CLK */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_ACJTAG_CFG_ACJTAG_INIT_CLK VTSS_BIT(3) /** * \brief * JTAG direct output (directly driven) * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_ACJTAG_CFG . OB_DIRECT */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_ACJTAG_CFG_OB_DIRECT VTSS_BIT(2) /** * \brief * ACJTAG enable (ac_mode) * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_ACJTAG_CFG . ACJTAG_ENA */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_ACJTAG_CFG_ACJTAG_ENA VTSS_BIT(1) /** * \brief * Enable JTAG control via CSR * * \details * 0: External controlled * 1: CSR controlled * * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_ACJTAG_CFG . JTAG_CTRL_ENA */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_ACJTAG_CFG_JTAG_CTRL_ENA VTSS_BIT(0) /** * \brief SERDES6G GP CFGB * * \details * General purpose register B * * Register: \a VENICE_DEV4:SERDES6G_ANA_CFG:SERDES6G_GP_CFGB */ #define VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_GP_CFGB VTSS_IOREG(0x04, 0, 0xe62f) /** * \brief * To be defined * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_GP_CFGB . GP_LSB */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_GP_CFGB_GP_LSB(x) VTSS_ENCODE_BITFIELD(x,0,16) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_GP_CFGB_GP_LSB VTSS_ENCODE_BITMASK(0,16) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_CFG_SERDES6G_GP_CFGB_GP_LSB(x) VTSS_EXTRACT_BITFIELD(x,0,16) /** * Register Group: \a VENICE_DEV4:SERDES6G_ANA_STATUS * * SERDES6G Analog Status Registers */ /** * \brief SERDES6G IB Status register 0 * * \details * Status register for Signal Detect * * Register: \a VENICE_DEV4:SERDES6G_ANA_STATUS:SERDES6G_IB_STATUS0 * * @param gi Register: SERDES6G_ANA_STATUS, 0-3 */ #define VTSS_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_IB_STATUS0(gi) VTSS_IOREG_IX(0x04, 0, 0xe630, gi, 7, 0, 0) /** * \brief * Signals mission mode after calibration was done. * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_IB_STATUS0 . IB_CAL_DONE */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_IB_STATUS0_IB_CAL_DONE VTSS_BIT(8) /** * \brief * Flag high-pass-gain regulation activity. Caution: currently this signal * is generated with a clock of datarate/16 and NOT captured (sticky). * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_IB_STATUS0 . IB_HP_GAIN_ACT */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_IB_STATUS0_IB_HP_GAIN_ACT VTSS_BIT(7) /** * \brief * Flag mid-pass-gain regulation activity. Caution: currently this signal * is generated with a clock of datarate/16 and NOT captured (sticky). * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_IB_STATUS0 . IB_MID_GAIN_ACT */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_IB_STATUS0_IB_MID_GAIN_ACT VTSS_BIT(6) /** * \brief * Flag low-pass-gain regulation activity. Caution: currently this signal * is generated with a clock of datarate/16 and NOT captured (sticky). * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_IB_STATUS0 . IB_LP_GAIN_ACT */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_IB_STATUS0_IB_LP_GAIN_ACT VTSS_BIT(5) /** * \brief * Flag offset regulation activity. Caution: currently this signal is * generated with a clock of datarate/16 and NOT captured (sticky). * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_IB_STATUS0 . IB_OFFSET_ACT */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_IB_STATUS0_IB_OFFSET_ACT VTSS_BIT(4) /** * \brief * Valid average data of calibration process at ib_offset_stat available. * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_IB_STATUS0 . IB_OFFSET_VLD */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_IB_STATUS0_IB_OFFSET_VLD VTSS_BIT(3) /** * \brief * Overflow error during calibration process. Value at ib_offset_stat not * valid. * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_IB_STATUS0 . IB_OFFSET_ERR */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_IB_STATUS0_IB_OFFSET_ERR VTSS_BIT(2) /** * \brief * Detection of offset direction in selected (ib_offsx) sampling channels * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_IB_STATUS0 . IB_OFFSDIR */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_IB_STATUS0_IB_OFFSDIR VTSS_BIT(1) /** * \brief * Detection of toggling signal at PADP and PADN * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_IB_STATUS0 . IB_SIG_DET */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_IB_STATUS0_IB_SIG_DET VTSS_BIT(0) /** * \brief SERDES6G IB Status register 1A * * \details * Regulation stage status register A * * Register: \a VENICE_DEV4:SERDES6G_ANA_STATUS:SERDES6G_IB_STATUS1A * * @param gi Register: SERDES6G_ANA_STATUS, 0-3 */ #define VTSS_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_IB_STATUS1A(gi) VTSS_IOREG_IX(0x04, 0, 0xe630, gi, 7, 0, 1) /** * \brief * Current high-pass-gain regulation value * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_IB_STATUS1A . IB_HP_GAIN_STAT */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_IB_STATUS1A_IB_HP_GAIN_STAT(x) VTSS_ENCODE_BITFIELD(x,8,6) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_IB_STATUS1A_IB_HP_GAIN_STAT VTSS_ENCODE_BITMASK(8,6) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_IB_STATUS1A_IB_HP_GAIN_STAT(x) VTSS_EXTRACT_BITFIELD(x,8,6) /** * \brief * Current mid-pass-gain regulation value * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_IB_STATUS1A . IB_MID_GAIN_STAT */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_IB_STATUS1A_IB_MID_GAIN_STAT(x) VTSS_ENCODE_BITFIELD(x,0,6) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_IB_STATUS1A_IB_MID_GAIN_STAT VTSS_ENCODE_BITMASK(0,6) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_IB_STATUS1A_IB_MID_GAIN_STAT(x) VTSS_EXTRACT_BITFIELD(x,0,6) /** * \brief SERDES6G IB Status register 1B * * \details * Regulation stage status register B * * Register: \a VENICE_DEV4:SERDES6G_ANA_STATUS:SERDES6G_IB_STATUS1B * * @param gi Register: SERDES6G_ANA_STATUS, 0-3 */ #define VTSS_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_IB_STATUS1B(gi) VTSS_IOREG_IX(0x04, 0, 0xe630, gi, 7, 0, 2) /** * \brief * Current low-pass-gain regulation value * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_IB_STATUS1B . IB_LP_GAIN_STAT */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_IB_STATUS1B_IB_LP_GAIN_STAT(x) VTSS_ENCODE_BITFIELD(x,8,6) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_IB_STATUS1B_IB_LP_GAIN_STAT VTSS_ENCODE_BITMASK(8,6) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_IB_STATUS1B_IB_LP_GAIN_STAT(x) VTSS_EXTRACT_BITFIELD(x,8,6) /** * \brief * Current offset regulation value * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_IB_STATUS1B . IB_OFFSET_STAT */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_IB_STATUS1B_IB_OFFSET_STAT(x) VTSS_ENCODE_BITFIELD(x,0,6) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_IB_STATUS1B_IB_OFFSET_STAT VTSS_ENCODE_BITMASK(0,6) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_IB_STATUS1B_IB_OFFSET_STAT(x) VTSS_EXTRACT_BITFIELD(x,0,6) /** * \brief SERDES6G ACJTAG Status * * \details * Status register of (AC)JTAG debug capability * * Register: \a VENICE_DEV4:SERDES6G_ANA_STATUS:SERDES6G_ACJTAG_STATUS * * @param gi Register: SERDES6G_ANA_STATUS, 0-3 */ #define VTSS_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_ACJTAG_STATUS(gi) VTSS_IOREG_IX(0x04, 0, 0xe630, gi, 7, 0, 3) /** * \brief * ACJTAG captured data for n leg * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_ACJTAG_STATUS . ACJTAG_CAPT_DATA_N */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_ACJTAG_STATUS_ACJTAG_CAPT_DATA_N VTSS_BIT(5) /** * \brief * ACJTAG captured data for p leg * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_ACJTAG_STATUS . ACJTAG_CAPT_DATA_P */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_ACJTAG_STATUS_ACJTAG_CAPT_DATA_P VTSS_BIT(4) /** * \brief * JTAG direct input (directly driven) * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_ACJTAG_STATUS . IB_DIRECT */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_ACJTAG_STATUS_IB_DIRECT VTSS_BIT(2) /** * \brief SERDES6G Pll Status * * \details * Status register of SERDES6G RCPLL * * Register: \a VENICE_DEV4:SERDES6G_ANA_STATUS:SERDES6G_PLL_STATUS * * @param gi Register: SERDES6G_ANA_STATUS, 0-3 */ #define VTSS_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_PLL_STATUS(gi) VTSS_IOREG_IX(0x04, 0, 0xe630, gi, 7, 0, 4) /** * \brief * Calibration status * * \details * 0: Calibration not started or ongoing * 1: Calibration finished * * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_PLL_STATUS . PLL_CAL_NOT_DONE */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_PLL_STATUS_PLL_CAL_NOT_DONE VTSS_BIT(12) /** * \brief * Calibration error * * \details * 0: No error during calibration * 1: Errors occured during calibration * * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_PLL_STATUS . PLL_CAL_ERR */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_PLL_STATUS_PLL_CAL_ERR VTSS_BIT(11) /** * \brief * Out of range error * * \details * 0: No out of range condition detected * 1: Out of range condition since last calibration detected * * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_PLL_STATUS . PLL_OUT_OF_RANGE_ERR */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_PLL_STATUS_PLL_OUT_OF_RANGE_ERR VTSS_BIT(10) /** * \brief * PLL read-back data, depending on "pll_rb_data_sel" either the calibrated * setting or the measured period * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_PLL_STATUS . PLL_RB_DATA */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_PLL_STATUS_PLL_RB_DATA(x) VTSS_ENCODE_BITFIELD(x,0,8) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_PLL_STATUS_PLL_RB_DATA VTSS_ENCODE_BITMASK(0,8) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_PLL_STATUS_PLL_RB_DATA(x) VTSS_EXTRACT_BITFIELD(x,0,8) /** * \brief SERDES6G REVID A * * \details * Revision ID register A * * Register: \a VENICE_DEV4:SERDES6G_ANA_STATUS:SERDES6G_REVIDA * * @param gi Register: SERDES6G_ANA_STATUS, 0-3 */ #define VTSS_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_REVIDA(gi) VTSS_IOREG_IX(0x04, 0, 0xe630, gi, 7, 0, 5) /** * \brief * Serdes revision * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_REVIDA . SERDES_REV */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_REVIDA_SERDES_REV(x) VTSS_ENCODE_BITFIELD(x,10,6) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_REVIDA_SERDES_REV VTSS_ENCODE_BITMASK(10,6) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_REVIDA_SERDES_REV(x) VTSS_EXTRACT_BITFIELD(x,10,6) /** * \brief * RCPLL revision * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_REVIDA . RCPLL_REV */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_REVIDA_RCPLL_REV(x) VTSS_ENCODE_BITFIELD(x,5,5) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_REVIDA_RCPLL_REV VTSS_ENCODE_BITMASK(5,5) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_REVIDA_RCPLL_REV(x) VTSS_EXTRACT_BITFIELD(x,5,5) /** * \brief * SER revision * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_REVIDA . SER_REV */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_REVIDA_SER_REV(x) VTSS_ENCODE_BITFIELD(x,0,5) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_REVIDA_SER_REV VTSS_ENCODE_BITMASK(0,5) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_REVIDA_SER_REV(x) VTSS_EXTRACT_BITFIELD(x,0,5) /** * \brief SERDES6G REVID B * * \details * Revision ID register B * * Register: \a VENICE_DEV4:SERDES6G_ANA_STATUS:SERDES6G_REVIDB * * @param gi Register: SERDES6G_ANA_STATUS, 0-3 */ #define VTSS_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_REVIDB(gi) VTSS_IOREG_IX(0x04, 0, 0xe630, gi, 7, 0, 6) /** * \brief * DES revision * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_REVIDB . DES_REV */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_REVIDB_DES_REV(x) VTSS_ENCODE_BITFIELD(x,10,6) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_REVIDB_DES_REV VTSS_ENCODE_BITMASK(10,6) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_REVIDB_DES_REV(x) VTSS_EXTRACT_BITFIELD(x,10,6) /** * \brief * OB revision * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_REVIDB . OB_REV */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_REVIDB_OB_REV(x) VTSS_ENCODE_BITFIELD(x,5,5) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_REVIDB_OB_REV VTSS_ENCODE_BITMASK(5,5) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_REVIDB_OB_REV(x) VTSS_EXTRACT_BITFIELD(x,5,5) /** * \brief * IB revision * * \details * Field: VTSS_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_REVIDB . IB_REV */ #define VTSS_F_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_REVIDB_IB_REV(x) VTSS_ENCODE_BITFIELD(x,0,5) #define VTSS_M_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_REVIDB_IB_REV VTSS_ENCODE_BITMASK(0,5) #define VTSS_X_VENICE_DEV4_SERDES6G_ANA_STATUS_SERDES6G_REVIDB_IB_REV(x) VTSS_EXTRACT_BITFIELD(x,0,5) /** * Register Group: \a VENICE_DEV4:MACRO_CTRL_CFG * * MACRO_CTRL Configuration Registers */ /** * \brief MACRO CTRL FSM Cfg0 * * \details * Configuration register 0 for MACRO_CTRL state machine (FSM). Timer is * only used when MACRO_CTRL_FSM_CFG3.USE_PLL_CAL_DONE = 0. * * Register: \a VENICE_DEV4:MACRO_CTRL_CFG:MACRO_CTRL_FSM_CFG0 */ #define VTSS_VENICE_DEV4_MACRO_CTRL_CFG_MACRO_CTRL_FSM_CFG0 VTSS_IOREG(0x04, 0, 0xe800) /** * \brief * Setup (wait) time for RCPLL to calibrate. Wait time in number of * core_clk cycles. * * \details * Field: VTSS_VENICE_DEV4_MACRO_CTRL_CFG_MACRO_CTRL_FSM_CFG0 . SETUP_TIME_RCPLL */ #define VTSS_F_VENICE_DEV4_MACRO_CTRL_CFG_MACRO_CTRL_FSM_CFG0_SETUP_TIME_RCPLL(x) VTSS_ENCODE_BITFIELD(x,0,16) #define VTSS_M_VENICE_DEV4_MACRO_CTRL_CFG_MACRO_CTRL_FSM_CFG0_SETUP_TIME_RCPLL VTSS_ENCODE_BITMASK(0,16) #define VTSS_X_VENICE_DEV4_MACRO_CTRL_CFG_MACRO_CTRL_FSM_CFG0_SETUP_TIME_RCPLL(x) VTSS_EXTRACT_BITFIELD(x,0,16) /** * \brief MACRO CTRL FSM Cfg1 * * \details * Configuration register 1 for MACRO_CTRL state machine (FSM) * * Register: \a VENICE_DEV4:MACRO_CTRL_CFG:MACRO_CTRL_FSM_CFG1 */ #define VTSS_VENICE_DEV4_MACRO_CTRL_CFG_MACRO_CTRL_FSM_CFG1 VTSS_IOREG(0x04, 0, 0xe801) /** * \brief * Setup (wait) time for Input-Buffer. Wait time in number of core_clk * cycles. * * \details * Field: VTSS_VENICE_DEV4_MACRO_CTRL_CFG_MACRO_CTRL_FSM_CFG1 . SETUP_TIME_IB */ #define VTSS_F_VENICE_DEV4_MACRO_CTRL_CFG_MACRO_CTRL_FSM_CFG1_SETUP_TIME_IB(x) VTSS_ENCODE_BITFIELD(x,0,16) #define VTSS_M_VENICE_DEV4_MACRO_CTRL_CFG_MACRO_CTRL_FSM_CFG1_SETUP_TIME_IB VTSS_ENCODE_BITMASK(0,16) #define VTSS_X_VENICE_DEV4_MACRO_CTRL_CFG_MACRO_CTRL_FSM_CFG1_SETUP_TIME_IB(x) VTSS_EXTRACT_BITFIELD(x,0,16) /** * \brief MACRO CTRL FSM Cfg2 * * \details * Configuration register 2 for MACRO_CTRL state machine (FSM) * * Register: \a VENICE_DEV4:MACRO_CTRL_CFG:MACRO_CTRL_FSM_CFG2 */ #define VTSS_VENICE_DEV4_MACRO_CTRL_CFG_MACRO_CTRL_FSM_CFG2 VTSS_IOREG(0x04, 0, 0xe802) /** * \brief * Wait time after changing the operating mode. Wait time in number of * core_clk cycles. * * \details * Field: VTSS_VENICE_DEV4_MACRO_CTRL_CFG_MACRO_CTRL_FSM_CFG2 . SETUP_TIME_CHG_MODE */ #define VTSS_F_VENICE_DEV4_MACRO_CTRL_CFG_MACRO_CTRL_FSM_CFG2_SETUP_TIME_CHG_MODE(x) VTSS_ENCODE_BITFIELD(x,0,16) #define VTSS_M_VENICE_DEV4_MACRO_CTRL_CFG_MACRO_CTRL_FSM_CFG2_SETUP_TIME_CHG_MODE VTSS_ENCODE_BITMASK(0,16) #define VTSS_X_VENICE_DEV4_MACRO_CTRL_CFG_MACRO_CTRL_FSM_CFG2_SETUP_TIME_CHG_MODE(x) VTSS_EXTRACT_BITFIELD(x,0,16) /** * \brief MACRO CTRL FSM Cfg3 * * \details * Configuration register 3 for MACRO_CTRL state machine (FSM) * * Register: \a VENICE_DEV4:MACRO_CTRL_CFG:MACRO_CTRL_FSM_CFG3 */ #define VTSS_VENICE_DEV4_MACRO_CTRL_CFG_MACRO_CTRL_FSM_CFG3 VTSS_IOREG(0x04, 0, 0xe803) /** * \brief * Enable IB calibration after mode change additionally * * \details * 0: Calibrate IB only after power-up * 1: Calibrate IB after power up and every automatic mode change * * Field: VTSS_VENICE_DEV4_MACRO_CTRL_CFG_MACRO_CTRL_FSM_CFG3 . ALWAYS_CAL_IB */ #define VTSS_F_VENICE_DEV4_MACRO_CTRL_CFG_MACRO_CTRL_FSM_CFG3_ALWAYS_CAL_IB VTSS_BIT(6) /** * \brief * During automatic configuration wait on pll_cal_done instead of using the * rcpll_timer * * \details * 0: use timer * 1: use pll_cal_done status bit * * Field: VTSS_VENICE_DEV4_MACRO_CTRL_CFG_MACRO_CTRL_FSM_CFG3 . USE_PLL_CAL_DONE */ #define VTSS_F_VENICE_DEV4_MACRO_CTRL_CFG_MACRO_CTRL_FSM_CFG3_USE_PLL_CAL_DONE VTSS_BIT(5) /** * \brief * Lane enable in manual mode * * \details * 0: Automatic Mode * 1: Manual Mode * * Field: VTSS_VENICE_DEV4_MACRO_CTRL_CFG_MACRO_CTRL_FSM_CFG3 . LANE_ENA_MAN */ #define VTSS_F_VENICE_DEV4_MACRO_CTRL_CFG_MACRO_CTRL_FSM_CFG3_LANE_ENA_MAN(x) VTSS_ENCODE_BITFIELD(x,1,4) #define VTSS_M_VENICE_DEV4_MACRO_CTRL_CFG_MACRO_CTRL_FSM_CFG3_LANE_ENA_MAN VTSS_ENCODE_BITMASK(1,4) #define VTSS_X_VENICE_DEV4_MACRO_CTRL_CFG_MACRO_CTRL_FSM_CFG3_LANE_ENA_MAN(x) VTSS_EXTRACT_BITFIELD(x,1,4) /** * \brief * Disable automatic configuration mode (manual mode) * * \details * 0: Automatic Configuration Mode * 1: Manual Configuration Mode * * Field: VTSS_VENICE_DEV4_MACRO_CTRL_CFG_MACRO_CTRL_FSM_CFG3 . DISABLE_AUTO_MODE */ #define VTSS_F_VENICE_DEV4_MACRO_CTRL_CFG_MACRO_CTRL_FSM_CFG3_DISABLE_AUTO_MODE VTSS_BIT(0) /** * \brief SYNC ETH CFG * * \details * Configuration register for Synchronous Ethernet * * Register: \a VENICE_DEV4:MACRO_CTRL_CFG:SYNC_ETH_CFG */ #define VTSS_VENICE_DEV4_MACRO_CTRL_CFG_SYNC_ETH_CFG VTSS_IOREG(0x04, 0, 0xe804) /** * \brief * Select active (recovered) clock B source for sync ethernet. Each bit * matches clock of one lane. * * \details * 0000: clock disabled * 0001: lane 0 clock active * 0010: lane 1 clock active * 0100: lane 2 clock active * 1000: lane 3 clock active * * Field: VTSS_VENICE_DEV4_MACRO_CTRL_CFG_SYNC_ETH_CFG . RECO_CLK_B_ACTIVE */ #define VTSS_F_VENICE_DEV4_MACRO_CTRL_CFG_SYNC_ETH_CFG_RECO_CLK_B_ACTIVE(x) VTSS_ENCODE_BITFIELD(x,4,4) #define VTSS_M_VENICE_DEV4_MACRO_CTRL_CFG_SYNC_ETH_CFG_RECO_CLK_B_ACTIVE VTSS_ENCODE_BITMASK(4,4) #define VTSS_X_VENICE_DEV4_MACRO_CTRL_CFG_SYNC_ETH_CFG_RECO_CLK_B_ACTIVE(x) VTSS_EXTRACT_BITFIELD(x,4,4) /** * \brief * Select active (recovered) clock A source for sync ethernet. Each bit * matches clock of one lane. * * \details * 0000: clock disabled * 0001: lane 0 clock active * 0010: lane 1 clock active * 0100: lane 2 clock active * 1000: lane 3 clock active * * Field: VTSS_VENICE_DEV4_MACRO_CTRL_CFG_SYNC_ETH_CFG . RECO_CLK_A_ACTIVE */ #define VTSS_F_VENICE_DEV4_MACRO_CTRL_CFG_SYNC_ETH_CFG_RECO_CLK_A_ACTIVE(x) VTSS_ENCODE_BITFIELD(x,0,4) #define VTSS_M_VENICE_DEV4_MACRO_CTRL_CFG_SYNC_ETH_CFG_RECO_CLK_A_ACTIVE VTSS_ENCODE_BITMASK(0,4) #define VTSS_X_VENICE_DEV4_MACRO_CTRL_CFG_SYNC_ETH_CFG_RECO_CLK_A_ACTIVE(x) VTSS_EXTRACT_BITFIELD(x,0,4) /** * Register Group: \a VENICE_DEV4:MACRO_CTRL_STATUS * * MACRO_CTRL Status Registers */ /** * \brief MACRO CTRL Status * * \details * Status register of MACRO_CTRL state machine (FSM) * * Register: \a VENICE_DEV4:MACRO_CTRL_STATUS:MACRO_CTRL_STAT */ #define VTSS_VENICE_DEV4_MACRO_CTRL_STATUS_MACRO_CTRL_STAT VTSS_IOREG(0x04, 0, 0xe805) /** * \brief * State machine error occured * * \details * Bit is cleared by writing a 1 to this position. * * Field: VTSS_VENICE_DEV4_MACRO_CTRL_STATUS_MACRO_CTRL_STAT . FSM_ERR_STICKY */ #define VTSS_F_VENICE_DEV4_MACRO_CTRL_STATUS_MACRO_CTRL_STAT_FSM_ERR_STICKY VTSS_BIT(0) /** * \brief MACRO CTRL signal drive Status * * \details * Register allowing to observe the signals driven by the macro control * state machine (FSM). * * Register: \a VENICE_DEV4:MACRO_CTRL_STATUS:MACRO_CTRL_SIGDRV_STAT */ #define VTSS_VENICE_DEV4_MACRO_CTRL_STATUS_MACRO_CTRL_SIGDRV_STAT VTSS_IOREG(0x04, 0, 0xe806) /** * \brief * Current status of driven signal ena_lane(3:0), one bit per lane * * \details * Field: VTSS_VENICE_DEV4_MACRO_CTRL_STATUS_MACRO_CTRL_SIGDRV_STAT . ENA_LANE */ #define VTSS_F_VENICE_DEV4_MACRO_CTRL_STATUS_MACRO_CTRL_SIGDRV_STAT_ENA_LANE(x) VTSS_ENCODE_BITFIELD(x,8,4) #define VTSS_M_VENICE_DEV4_MACRO_CTRL_STATUS_MACRO_CTRL_SIGDRV_STAT_ENA_LANE VTSS_ENCODE_BITMASK(8,4) #define VTSS_X_VENICE_DEV4_MACRO_CTRL_STATUS_MACRO_CTRL_SIGDRV_STAT_ENA_LANE(x) VTSS_EXTRACT_BITFIELD(x,8,4) /** * \brief * Current status of driven signal ena_loop * * \details * Field: VTSS_VENICE_DEV4_MACRO_CTRL_STATUS_MACRO_CTRL_SIGDRV_STAT . ENA_LOOP */ #define VTSS_F_VENICE_DEV4_MACRO_CTRL_STATUS_MACRO_CTRL_SIGDRV_STAT_ENA_LOOP VTSS_BIT(6) /** * \brief * Current status of driven signal lane_rst * * \details * Field: VTSS_VENICE_DEV4_MACRO_CTRL_STATUS_MACRO_CTRL_SIGDRV_STAT . LANE_RST */ #define VTSS_F_VENICE_DEV4_MACRO_CTRL_STATUS_MACRO_CTRL_SIGDRV_STAT_LANE_RST VTSS_BIT(5) /** * \brief * Current status of driven signal system_rst_n * * \details * Field: VTSS_VENICE_DEV4_MACRO_CTRL_STATUS_MACRO_CTRL_SIGDRV_STAT . SYS_RST_N */ #define VTSS_F_VENICE_DEV4_MACRO_CTRL_STATUS_MACRO_CTRL_SIGDRV_STAT_SYS_RST_N VTSS_BIT(4) /** * \brief * Initialization done, device in normal operation mode * * \details * Field: VTSS_VENICE_DEV4_MACRO_CTRL_STATUS_MACRO_CTRL_SIGDRV_STAT . INIT_DONE */ #define VTSS_F_VENICE_DEV4_MACRO_CTRL_STATUS_MACRO_CTRL_SIGDRV_STAT_INIT_DONE VTSS_BIT(3) /** * \brief * Current operation mode * * \details * 0: XAUI * 1: RXAUI * 2: SGMII on lane 0 * 3: SGMII on lane 3 * 4-7: Reserved * * Field: VTSS_VENICE_DEV4_MACRO_CTRL_STATUS_MACRO_CTRL_SIGDRV_STAT . OP_MODE */ #define VTSS_F_VENICE_DEV4_MACRO_CTRL_STATUS_MACRO_CTRL_SIGDRV_STAT_OP_MODE(x) VTSS_ENCODE_BITFIELD(x,0,3) #define VTSS_M_VENICE_DEV4_MACRO_CTRL_STATUS_MACRO_CTRL_SIGDRV_STAT_OP_MODE VTSS_ENCODE_BITMASK(0,3) #define VTSS_X_VENICE_DEV4_MACRO_CTRL_STATUS_MACRO_CTRL_SIGDRV_STAT_OP_MODE(x) VTSS_EXTRACT_BITFIELD(x,0,3) #endif /* _VTSS_VENICE_REGS_VENICE_DEV4_H_ */
31.311022
126
0.791294
5f663aef9b1b8b019ed0a631a681ddcdc827d93f
1,513
h
C
arch/csky/abiv1/inc/abi/cacheflush.h
fergy/aplit_linux-5
a6ef4cb0e17e1eec9743c064e65f730c49765711
[ "MIT" ]
1
2022-01-30T20:01:25.000Z
2022-01-30T20:01:25.000Z
arch/csky/abiv1/inc/abi/cacheflush.h
fergy/aplit_linux-5
a6ef4cb0e17e1eec9743c064e65f730c49765711
[ "MIT" ]
null
null
null
arch/csky/abiv1/inc/abi/cacheflush.h
fergy/aplit_linux-5
a6ef4cb0e17e1eec9743c064e65f730c49765711
[ "MIT" ]
1
2019-10-11T07:35:58.000Z
2019-10-11T07:35:58.000Z
/* SPDX-License-Identifier: GPL-2.0 */ // Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd. #ifndef __ABI_CSKY_CACHEFLUSH_H #define __ABI_CSKY_CACHEFLUSH_H #include <linux/compiler.h> #include <asm/string.h> #include <asm/cache.h> #define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1 extern void flush_dcache_page(struct page *); #define flush_cache_mm(mm) cache_wbinv_all() #define flush_cache_page(vma, page, pfn) cache_wbinv_all() #define flush_cache_dup_mm(mm) cache_wbinv_all() /* * if (current_mm != vma->mm) cache_wbinv_range(start, end) will be broken. * Use cache_wbinv_all() here and need to be improved in future. */ #define flush_cache_range(vma, start, end) cache_wbinv_all() #define flush_cache_vmap(start, end) cache_wbinv_range(start, end) #define flush_cache_vunmap(start, end) cache_wbinv_range(start, end) #define flush_icache_page(vma, page) cache_wbinv_all() #define flush_icache_range(start, end) cache_wbinv_range(start, end) #define flush_icache_user_range(vma, pg, adr, len) \ cache_wbinv_range(adr, adr + len) #define copy_from_user_page(vma, page, vaddr, dst, src, len) \ do { \ cache_wbinv_all(); \ memcpy(dst, src, len); \ cache_wbinv_all(); \ } while (0) #define copy_to_user_page(vma, page, vaddr, dst, src, len) \ do { \ cache_wbinv_all(); \ memcpy(dst, src, len); \ cache_wbinv_all(); \ } while (0) #define flush_dcache_mmap_lock(mapping) do {} while (0) #define flush_dcache_mmap_unlock(mapping) do {} while (0) #endif /* __ABI_CSKY_CACHEFLUSH_H */
30.26
75
0.744878
dfd1a2b2923ce268b31ca2d45342a171fd7ba446
37,861
c
C
lupng.c
ducalex/LuPng
b4f10be2b3aac357a7d7b4258c819e1f9b678300
[ "MIT" ]
null
null
null
lupng.c
ducalex/LuPng
b4f10be2b3aac357a7d7b4258c819e1f9b678300
[ "MIT" ]
null
null
null
lupng.c
ducalex/LuPng
b4f10be2b3aac357a7d7b4258c819e1f9b678300
[ "MIT" ]
null
null
null
/* * The MIT License (MIT) * * Copyright (c) 2014 Jan Solanti * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdarg.h> #include <ctype.h> #ifndef LUPNG_USE_ZLIB #include <miniz.h> #else #include <zlib.h> #endif #include "lupng.h" #define PNG_NONE 0x00 #define PNG_IHDR 0x01 #define PNG_PLTE 0x02 #define PNG_IDAT 0x04 #define PNG_IEND 0x08 #define PNG_GRAYSCALE 0 #define PNG_TRUECOLOR 2 /* 24bpp RGB palette */ #define PNG_PALETTED 3 #define PNG_GRAYSCALE_ALPHA 4 #define PNG_TRUECOLOR_ALPHA 6 #define PNG_FILTER_NONE 0 #define PNG_FILTER_SUB 1 #define PNG_FILTER_UP 2 #define PNG_FILTER_AVERAGE 3 #define PNG_FILTER_PAETH 4 #define PNG_SIG_SIZE 8 #define BUF_SIZE 8192 #define MIN(x, y) ((x) < (y) ? (x) : (y)) #define MAX(x, y) ((x) > (y) ? (x) : (y)) #if defined(_MSC_VER) #define LU_INLINE __inline /* MS-specific inline */ #else #define LU_INLINE inline /* rest of the world... */ #endif #define SIZE_T_MAX_POSITIVE ( ((size_t)-1) >> 1 ) /******************************************************** * CRC computation as per PNG spec ********************************************************/ /* Precomputed table of CRCs of all 8-bit messages using the polynomial from the PNG spec, 0xEDB88320L. */ static const uint32_t crcTable[] = { 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D }; /* Update a running CRC with the bytes buf[0..len-1]--the CRC should be initialized to all 1's, and the transmitted value is the 1's complement of the final running CRC. */ static uint32_t crc(const uint8_t *buf, size_t len) { uint32_t crc = 0xFFFFFFFFL; for (size_t n = 0; n < len; n++) crc = crcTable[(crc ^ buf[n]) & 0xFF] ^ (crc >> 8); return crc ^ 0xFFFFFFFFL; } /******************************************************** * Helper structs ********************************************************/ typedef struct { uint32_t length; uint8_t *type; uint8_t *data; uint32_t crc; } PngChunk; typedef struct { const LuUserContext *userCtx; uint32_t chunksFound; /* IHDR info */ int32_t width; int32_t height; uint8_t depth; uint8_t colorType; uint8_t channels; uint8_t compression; uint8_t filter; uint8_t interlace; /* PLTE info */ uint8_t palette[256][3]; size_t paletteItems; /* fields used for (de)compression & (de-)filtering */ z_stream stream; int32_t scanlineBytes; int32_t bytesPerPixel; int32_t currentByte; int32_t currentCol; int32_t currentRow; int32_t currentElem; uint8_t *currentScanline; uint8_t *previousScanline; uint8_t currentFilter; uint8_t interlacePass; size_t compressedBytes; /* used for constructing 16 bit deep pixels */ int tmpCount; uint8_t tmpBytes[2]; /* the output image */ union { LuImage *img; const LuImage *cimg; }; } PngInfoStruct; /* helper macro to output warning via user context of the info struct */ #define LUPNG_WARN_UC(uc,...) do { if ((uc)->warnProc) { (uc)->warnProc((uc)->warnProcUserPtr, "LuPng: " __VA_ARGS__); }} while(0) #define LUPNG_WARN(info,...) LUPNG_WARN_UC((info)->userCtx, __VA_ARGS__) /* PNG header: */ /* P N G \r \n SUB \n */ #define PNG_SIG_BYTES 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A static const uint8_t PNG_SIG[] = {PNG_SIG_BYTES}; static const int8_t startingRow[] = { 0, 0, 0, 4, 0, 2, 0, 1 }; static const int8_t startingCol[] = { 0, 0, 4, 0, 2, 0, 1, 0 }; static const int8_t rowIncrement[] = { 1, 8, 8, 8, 4, 4, 2, 2 }; static const int8_t colIncrement[] = { 1, 8, 8, 4, 4, 2, 2, 1 }; /******************************************************** * Helper functions ********************************************************/ static LU_INLINE uint32_t swap32(uint32_t n) { union { unsigned char np[4]; uint32_t i; } u; u.i = n; return ((uint32_t)u.np[0] << 24) | ((uint32_t)u.np[1] << 16) | ((uint32_t)u.np[2] << 8) | (uint32_t)u.np[3]; } static LU_INLINE uint16_t swap16(uint16_t n) { union { unsigned char np[2]; uint16_t i; } u; u.i = n; return ((uint16_t)u.np[0] << 8) | (uint16_t)u.np[1]; } static int bytesEqual(const uint8_t *a, const uint8_t *b, size_t count) { for (size_t i = 0; i < count; ++i) { if (*(a+i) != *(b+i)) return 0; } return 1; } static void* internalMalloc(size_t size, void *userPtr) { (void)userPtr; /* not used */ return malloc(size); } static void internalFree(void *ptr, void *userPtr) { (void)userPtr; /* not used */ free(ptr); } static void internalPrintf(void *userPtr, const char *fmt, ...) { FILE *outStream = (FILE*)userPtr; va_list args; va_start(args, fmt); vfprintf(outStream, fmt, args); va_end(args); fputc('\n', outStream); } static size_t internalFread(void *ptr, size_t size, size_t count, void *userPtr) { return fread(ptr, size, count, (FILE *)userPtr); } static size_t internalFwrite(const void *ptr, size_t size, size_t count, void *userPtr) { return fwrite(ptr, size, count, (FILE *)userPtr); } /******************************************************** * Png filter functions ********************************************************/ static LU_INLINE int absi(int val) { return val > 0 ? val : -val; } static LU_INLINE uint8_t raw(PngInfoStruct *info, size_t col) { if (col > SIZE_T_MAX_POSITIVE) return 0; return info->currentScanline[col]; } static LU_INLINE uint8_t prior(PngInfoStruct *info, size_t col) { if (info->currentRow <= startingRow[info->interlacePass] || col > SIZE_T_MAX_POSITIVE) return 0; return info->previousScanline[col]; } static LU_INLINE uint8_t paethPredictor(uint8_t a, uint8_t b, uint8_t c) { unsigned int A = a, B = b, C = c; int p = (int)A + (int)B - (int)C; int pa = absi(p - (int)A); int pb = absi(p - (int)B); int pc = absi(p - (int)C); if (pa <= pb && pa <= pc) return a; if (pb <= pc) return b; return c; } static LU_INLINE uint8_t deSub(PngInfoStruct *info, uint8_t filtered) { return filtered + raw(info, info->currentByte-info->bytesPerPixel); } static LU_INLINE uint8_t deUp(PngInfoStruct *info, uint8_t filtered) { return filtered + prior(info, info->currentByte); } static LU_INLINE uint8_t deAverage(PngInfoStruct *info, uint8_t filtered) { uint16_t avg = (uint16_t)(raw(info, info->currentByte-info->bytesPerPixel) + prior(info, info->currentByte)); avg >>= 1; return filtered + avg; } static LU_INLINE uint8_t dePaeth(PngInfoStruct *info, uint8_t filtered) { return filtered + paethPredictor( raw(info, info->currentByte-info->bytesPerPixel), prior(info, info->currentByte), prior(info, info->currentByte-info->bytesPerPixel)); } static LU_INLINE uint8_t none(PngInfoStruct *info) { return raw(info, info->currentByte); } static LU_INLINE uint8_t sub(PngInfoStruct *info) { return raw(info, info->currentByte) - raw(info, info->currentByte-info->bytesPerPixel); } static LU_INLINE uint8_t up(PngInfoStruct *info) { return raw(info, info->currentByte) - prior(info, info->currentByte); } static LU_INLINE uint8_t average(PngInfoStruct *info) { uint16_t avg = (uint16_t)(raw(info, info->currentByte-info->bytesPerPixel) + prior(info, info->currentByte)); avg >>= 1; return raw(info, info->currentByte) - avg; } static LU_INLINE uint8_t paeth(PngInfoStruct *info) { return raw(info, info->currentByte) - paethPredictor( raw(info, info->currentByte-info->bytesPerPixel), prior(info, info->currentByte), prior(info, info->currentByte-info->bytesPerPixel)); } /******************************************************** * Actual implementation ********************************************************/ static LU_INLINE int parseIhdr(PngInfoStruct *info, PngChunk *chunk) { if (info->chunksFound) { LUPNG_WARN(info, "malformed PNG file!"); return PNG_ERROR; } info->chunksFound |= PNG_IHDR; info->width = swap32(*(uint32_t *)chunk->data); info->height = swap32(*((uint32_t *)chunk->data + 1)); info->depth = *(chunk->data + 8); info->colorType = *(chunk->data + 9); info->compression = *(chunk->data + 10); info->filter = *(chunk->data + 11); info->interlace = *(chunk->data + 12); switch (info->colorType) { case PNG_GRAYSCALE: info->channels = 1; break; case PNG_TRUECOLOR: info->channels = 3; break; case PNG_PALETTED: info->channels = 3; break; case PNG_GRAYSCALE_ALPHA: info->channels = 2; break; case PNG_TRUECOLOR_ALPHA: info->channels = 4; break; default: LUPNG_WARN(info, "illegal color type: %u", info->colorType); return PNG_ERROR; } if (info->width <= 0 || info->height <= 0) { LUPNG_WARN(info, "illegal dimensions"); return PNG_ERROR; } if ((info->colorType != PNG_GRAYSCALE && info->colorType != PNG_PALETTED && info->depth < 8) || (info->colorType == PNG_PALETTED && info->depth == 16) || info->depth > 16) { LUPNG_WARN(info, "illegal bit depth for color type"); return PNG_ERROR; } if (info->compression) { LUPNG_WARN(info, "unknown compression method: %u", info->compression); return PNG_ERROR; } if (info->filter) { LUPNG_WARN(info, "unknown filter scheme: %u", info->filter); return PNG_ERROR; } memset(&(info->stream), 0, sizeof(info->stream)); if(inflateInit(&(info->stream)) != Z_OK) { LUPNG_WARN(info, "PNG: inflateInit failed!"); return PNG_ERROR; } info->img = luImageCreate(info->width, info->height, info->channels, info->depth < 16 ? 8 : 16, NULL, info->userCtx); info->bytesPerPixel = MAX((info->channels * info->depth) >> 3, 1); info->scanlineBytes = info->width * info->bytesPerPixel; info->currentScanline = (uint8_t *)info->userCtx->allocProc(info->scanlineBytes, info->userCtx->allocProcUserPtr); info->previousScanline = (uint8_t *)info->userCtx->allocProc(info->scanlineBytes, info->userCtx->allocProcUserPtr); info->currentCol = -1; info->interlacePass = info->interlace ? 1 : 0; if (!info->img || !info->currentScanline || !info->previousScanline) { LUPNG_WARN(info, "memory allocation failed!"); return PNG_ERROR; } return PNG_OK; } static LU_INLINE int parsePlte(PngInfoStruct *info, PngChunk *chunk) { if (info->chunksFound & PNG_PLTE) { LUPNG_WARN(info, "too many palette chunks in file!"); return PNG_ERROR; } info->chunksFound |= PNG_PLTE; if ((info->chunksFound & PNG_IDAT) || !(info->chunksFound & PNG_IHDR)) { LUPNG_WARN(info, "malformed PNG file!"); return PNG_ERROR; } if (info->colorType == PNG_GRAYSCALE || info->colorType == PNG_GRAYSCALE_ALPHA) { LUPNG_WARN(info, "palettes are not allowed in grayscale images!"); return PNG_ERROR; } if (chunk->length < 1 || chunk->length > 768 || chunk->length % 3) { LUPNG_WARN(info, "invalid palette size!"); return PNG_ERROR; } memcpy(info->palette, chunk->data, chunk->length); info->paletteItems = chunk->length / 3; return PNG_OK; } static LU_INLINE void stretchBits(uint8_t inByte, uint8_t outBytes[8], int depth) { switch (depth) { case 1: for (int i = 0; i < 8; ++i) outBytes[i] = (inByte >> (7-i)) & 0x01; break; case 2: outBytes[0] = (inByte >> 6) & 0x03; outBytes[1] = (inByte >> 4) & 0x03; outBytes[2] = (inByte >> 2) & 0x03; outBytes[3] = inByte & 0x03; break; case 4: outBytes[0] = (inByte >> 4) & 0x0F; outBytes[1] = inByte & 0x0F; break; default: break; } } /* returns: 1 if at end of scanline, 0 otherwise */ static LU_INLINE int insertByte(PngInfoStruct *info, uint8_t byte) { const uint8_t scale[] = {0x00, 0xFF, 0x55, 0x00, 0x11, 0x00, 0x00, 0x00}; int advance = 0; /* for paletted images currentElem will always be 0 */ size_t idx = info->currentRow * info->width * info->channels + info->currentCol * info->channels + info->currentElem; if (info->colorType != PNG_PALETTED) { if (info->depth == 8) info->cimg->data[idx] = byte; else if (info->depth < 8) info->cimg->data[idx] = byte * scale[info->depth]; else /* depth == 16 */ { info->tmpBytes[info->tmpCount] = byte; if (info->tmpCount) /* just inserted 2nd byte */ { uint16_t val = *(uint16_t *)info->tmpBytes; val = swap16(val); info->tmpCount = 0; ((uint16_t *)(info->cimg->data))[idx] = val; } else { ++info->tmpCount; return 0; } } ++info->currentElem; if (info->currentElem >= info->channels) { advance = 1; info->currentElem = 0; } } else { /* The spec limits palette size to 256 entries */ if (byte < info->paletteItems) { info->img->data[idx ] = info->palette[byte][0]; info->img->data[idx+1] = info->palette[byte][1]; info->img->data[idx+2] = info->palette[byte][2]; } else { LUPNG_WARN(info, "invalid palette index encountered!"); } advance = 1; } if (advance) { /* advance to next pixel */ info->currentCol += colIncrement[info->interlacePass]; if (info->currentCol >= info->width) { uint8_t *tmp = info->currentScanline; info->currentScanline = info->previousScanline; info->previousScanline = tmp; info->currentCol = -1; info->currentByte = 0; info->currentRow += rowIncrement[info->interlacePass]; if (info->currentRow >= info->height && info->interlace) { ++info->interlacePass; while (startingCol[info->interlacePass] >= info->width || startingRow[info->interlacePass] >= info->height) ++info->interlacePass; info->currentRow = startingRow[info->interlacePass]; } return 1; } } return 0; } static LU_INLINE int parseIdat(PngInfoStruct *info, PngChunk *chunk) { unsigned char filtered[BUF_SIZE]; int status = Z_OK; if (!(info->chunksFound & PNG_IHDR)) { LUPNG_WARN(info, "malformed PNG file!"); return PNG_ERROR; } if (info->colorType == PNG_PALETTED && !(info->chunksFound & PNG_PLTE)) { LUPNG_WARN(info, "palette required but missing!"); return PNG_ERROR; } info->chunksFound |= PNG_IDAT; info->stream.next_in = (unsigned char *)chunk->data; info->stream.avail_in = chunk->length; do { size_t decompressed; size_t i; info->stream.next_out = filtered; info->stream.avail_out = BUF_SIZE; status = inflate(&(info->stream), Z_NO_FLUSH); decompressed = BUF_SIZE - info->stream.avail_out; if (status != Z_OK && status != Z_STREAM_END && status != Z_BUF_ERROR && status != Z_NEED_DICT) { LUPNG_WARN(info, "inflate error (%d)!", status); return PNG_ERROR; } for (i = 0; i < decompressed && info->currentCol < info->width && info->currentRow < info->height; ++i) { if (info->currentCol < 0) { info->currentCol = startingCol[info->interlacePass]; info->currentFilter = filtered[i]; } else { uint8_t rawByte = 0; uint8_t fullBytes[8] = {0}; switch (info->currentFilter) { case PNG_FILTER_NONE: rawByte = filtered[i]; break; case PNG_FILTER_SUB: rawByte = deSub(info, filtered[i]); break; case PNG_FILTER_UP: rawByte = deUp(info, filtered[i]); break; case PNG_FILTER_AVERAGE: rawByte = deAverage(info, filtered[i]); break; case PNG_FILTER_PAETH: rawByte = dePaeth(info, filtered[i]); break; default: break; } info->currentScanline[info->currentByte] = rawByte; ++info->currentByte; if (info->depth < 8) { stretchBits(rawByte, fullBytes, info->depth); for (int j = 0; j < 8/info->depth; ++j) if (insertByte(info, fullBytes[j])) break; } else insertByte(info, rawByte); } } } while ((info->stream.avail_in > 0 || info->stream.avail_out == 0) && info->currentCol < info->width && info->currentRow < info->height); return PNG_OK; } static LU_INLINE int readChunk(PngInfoStruct *info, PngChunk *chunk) { uint32_t data_len, chunk_crc; uint8_t *buffer = NULL; if (info->userCtx->readProc(&data_len, 4, 1, info->userCtx->readProcUserPtr) != 1) { LUPNG_WARN(info, "read error"); return PNG_ERROR; } data_len = swap32(data_len); if (data_len + 8 < data_len) { LUPNG_WARN(info, "chunk claims to be absurdly large"); return PNG_ERROR; } // Store chunk type and contents and crc in the same buffer for convenience buffer = info->userCtx->allocProc(data_len + 8, info->userCtx->allocProcUserPtr); if (!buffer) { LUPNG_WARN(info, "memory allocation failed!"); return PNG_ERROR; } if (!info->userCtx->readProc(buffer, data_len + 8, 1, info->userCtx->readProcUserPtr)) { LUPNG_WARN(info, "chunk data read error"); info->userCtx->freeProc(buffer, info->userCtx->freeProcUserPtr); return PNG_ERROR; } if (!isalpha(buffer[0]) || !isalpha(buffer[1]) || !isalpha(buffer[2]) || !isalpha(buffer[3])) { LUPNG_WARN(info, "invalid chunk name, possibly unprintable"); info->userCtx->freeProc(buffer, info->userCtx->freeProcUserPtr); return PNG_ERROR; } chunk_crc = swap32(*((uint32_t*)(buffer + data_len + 4))); if (crc(buffer, data_len + 4) != chunk->crc) { LUPNG_WARN(info, "CRC mismatch in chunk '%.4s'", (char *)buffer); info->userCtx->freeProc(buffer, info->userCtx->freeProcUserPtr); return PNG_ERROR; } chunk->type = buffer; chunk->data = buffer + 4; chunk->length = data_len; chunk->crc = chunk_crc; return PNG_OK; } static LU_INLINE int handleChunk(PngInfoStruct *info, PngChunk *chunk) { /* critical chunk */ if (!(chunk->type[0] & 0x20)) { if (bytesEqual(chunk->type, (const uint8_t *)"IHDR", 4)) return parseIhdr(info, chunk); if (bytesEqual(chunk->type, (const uint8_t *)"PLTE", 4)) return parsePlte(info, chunk); if (bytesEqual(chunk->type, (const uint8_t *)"IDAT", 4)) return parseIdat(info, chunk); if (bytesEqual(chunk->type, (const uint8_t *)"IEND", 4)) { info->chunksFound |= PNG_IEND; if (!(info->chunksFound & PNG_IDAT)) { LUPNG_WARN(info, "no IDAT chunk found"); return PNG_ERROR; } return PNG_DONE; } } /* ignore ancillary chunks for now */ return PNG_OK; } LuImage *luPngReadUC(const LuUserContext *userCtx) { uint8_t signature[PNG_SIG_SIZE]; PngInfoStruct info = {0}; PngChunk chunk = {0}; int status = PNG_OK; info.userCtx = userCtx; if (!userCtx->skipSig) { if (!userCtx->readProc((void*)signature, PNG_SIG_SIZE, 1, userCtx->readProcUserPtr) || !bytesEqual(signature, PNG_SIG, PNG_SIG_SIZE)) { LUPNG_WARN_UC(userCtx, "invalid signature"); return NULL; } } while (readChunk(&info, &chunk) == PNG_OK) { status = handleChunk(&info, &chunk); userCtx->freeProc(chunk.type, userCtx->freeProcUserPtr); if (status != PNG_OK) break; } userCtx->freeProc(info.currentScanline, userCtx->freeProcUserPtr); userCtx->freeProc(info.previousScanline, userCtx->freeProcUserPtr); inflateEnd(&info.stream); if (status == PNG_DONE) return info.img; if (info.img) luImageRelease(info.img, info.userCtx); return NULL; } LuImage *luPngRead(PngReadProc readProc, void *userPtr, int skipSig) { LuUserContext userCtx; luUserContextInitDefault(&userCtx); userCtx.readProc = readProc; userCtx.readProcUserPtr = userPtr; userCtx.skipSig = skipSig; return luPngReadUC(&userCtx); } LuImage *luPngReadFile(const char *filename) { LuUserContext userCtx; LuImage *img; FILE *f = fopen(filename,"rb"); luUserContextInitDefault(&userCtx); if (f) { userCtx.readProc = internalFread; userCtx.readProcUserPtr = f; img = luPngReadUC(&userCtx); fclose(f); } else { LUPNG_WARN_UC(&userCtx, "failed to open '%s'", filename); img = NULL; } return img; } static LU_INLINE int writeHeader(PngInfoStruct *info) { const uint8_t colorType[] = { PNG_GRAYSCALE, PNG_GRAYSCALE_ALPHA, PNG_TRUECOLOR, PNG_TRUECOLOR_ALPHA }; if (info->cimg->channels > 4) { LUPNG_WARN(info, "write error in chunk '%.4s'", (char*)buf); return PNG_ERROR; } uint8_t buffer[] = { PNG_SIG_BYTES, // PNG signature 0, 0, 0, 13, // Length 'I', 'H', 'D', 'R', // Type 0, 0, 0, 0, // Width, 0, 0, 0, 0, // Height, info->cimg->depth, // Depth, colorType[info->cimg->channels-1], // Color Type, 0, // Compression 0, // Filter 0, // Interlacing 0, 0, 0, 0 // crc }; *((uint32_t *)&buffer[8]) = swap32((uint32_t)info->cimg->width); *((uint32_t *)&buffer[12]) = swap32((uint32_t)info->cimg->height); *((uint32_t *)&buffer[29]) = swap32(crc((void*)buffer + 12, 17)); if (!info->userCtx->writeProc((void *)buffer, sizeof(buffer), 1, info->userCtx->writeProcUserPtr)) { return PNG_ERROR; } return PNG_OK; } static LU_INLINE void advanceBytep(PngInfoStruct *info, int is16bit) { if (is16bit) { if (info->currentByte%2) --info->currentByte; else info->currentByte+=3; } else ++info->currentByte; } static LU_INLINE size_t filterScanline(PngInfoStruct *info, uint8_t(*f)(PngInfoStruct *info), uint8_t filter, uint8_t *filterCandidate, int is16bit) { size_t curSum = 0; size_t fc; filterCandidate[0] = filter; for (info->currentByte = is16bit ? 1 : 0, fc = 1; info->currentByte < info->scanlineBytes; ++fc, advanceBytep(info, is16bit) ) { uint8_t val = f(info); filterCandidate[fc] = val; curSum += val; } return curSum; } /* * Processes the input image and calls writeIdat for every BUF_SIZE compressed * bytes. */ static LU_INLINE int processPixels(PngInfoStruct *info) { uint8_t *filterCandidate = (uint8_t *)info->userCtx->allocProc(info->scanlineBytes+1, info->userCtx->allocProcUserPtr); uint8_t *bestCandidate = (uint8_t *)info->userCtx->allocProc(info->scanlineBytes+1, info->userCtx->allocProcUserPtr); size_t minSum = (size_t)-1, curSum = 0; int status = Z_OK; int is16bit = info->cimg->depth == 16; struct __attribute__((packed)) { uint32_t length; uint8_t type[4]; uint8_t data[BUF_SIZE]; uint32_t crc; } chunk = {0, {'I', 'D', 'A', 'T'}, {0}, 0}; if (!filterCandidate || !bestCandidate) { LUPNG_WARN(info, "PNG: memory allocation failed!"); return PNG_ERROR; } memset(&info->stream, 0, sizeof(info->stream)); if (deflateInit(&info->stream, info->userCtx->compressionLevel) != Z_OK) { LUPNG_WARN(info, "PNG: deflateInit failed!"); info->userCtx->freeProc(filterCandidate, info->userCtx->freeProcUserPtr); info->userCtx->freeProc(bestCandidate, info->userCtx->freeProcUserPtr); return PNG_ERROR; } info->stream.avail_out = BUF_SIZE; info->stream.next_out = &chunk.data; for (info->currentRow = 0; info->currentRow < info->cimg->height; ++info->currentRow) { int flush = (info->currentRow < info->cimg->height-1) ? Z_NO_FLUSH : Z_FINISH; minSum = (size_t)-1; /* * 1st time it doesn't matter, the filters never look at the previous * scanline when processing row 0. And next time it'll be valid. */ info->previousScanline = info->currentScanline; info->currentScanline = info->cimg->data + (info->currentRow*info->scanlineBytes); /* * Try to choose the best filter for each scanline. * Breaks in case of overflow, but hey it's just a heuristic. */ for (info->currentFilter = PNG_FILTER_NONE; info->currentFilter <= PNG_FILTER_PAETH; ++info->currentFilter) { switch (info->currentFilter) { case PNG_FILTER_NONE: curSum = filterScanline(info, none, PNG_FILTER_NONE, filterCandidate, is16bit); break; case PNG_FILTER_SUB: curSum = filterScanline(info, sub, PNG_FILTER_SUB, filterCandidate, is16bit); break; case PNG_FILTER_UP: curSum = filterScanline(info, up, PNG_FILTER_UP, filterCandidate, is16bit); break; case PNG_FILTER_AVERAGE: curSum = filterScanline(info, average, PNG_FILTER_AVERAGE, filterCandidate, is16bit); break; case PNG_FILTER_PAETH: curSum = filterScanline(info, paeth, PNG_FILTER_PAETH, filterCandidate, is16bit); break; default: break; } if (curSum < minSum || !info->currentFilter) { uint8_t *tmp = bestCandidate; bestCandidate = filterCandidate; filterCandidate = tmp; minSum = curSum; } } info->stream.avail_in = (unsigned int)info->scanlineBytes+1; info->stream.next_in = bestCandidate; /* compress bestCandidate */ do { status = deflate(&info->stream, flush); if (info->stream.avail_out < BUF_SIZE) { uint32_t data_len = BUF_SIZE - info->stream.avail_out; chunk.length = swap32(data_len); chunk.crc = swap32(crc((void*)&chunk.type, data_len + 4)); if (data_len != BUF_SIZE) // Move crc to proper place memmove(&chunk.data[data_len], &chunk.crc, 4); if (!info->userCtx->writeProc((void *)&chunk, data_len + 12, 1, info->userCtx->writeProcUserPtr)) { LUPNG_WARN(info, "PNG: write error"); // return PNG_ERROR; } info->stream.next_out = &chunk.data; info->stream.avail_out = BUF_SIZE; } } while ((flush == Z_FINISH && status != Z_STREAM_END) || (flush == Z_NO_FLUSH && info->stream.avail_in)); } info->userCtx->freeProc(filterCandidate, info->userCtx->freeProcUserPtr); info->userCtx->freeProc(bestCandidate, info->userCtx->freeProcUserPtr); return PNG_OK; } static LU_INLINE int writeIend(PngInfoStruct *info) { uint8_t buffer[] = {0, 0, 0, 0, 'I', 'E', 'N', 'D', 0, 0, 0, 0}; ((uint32_t*)buffer)[2] = swap32(crc(buffer + 4, 4)); if (!info->userCtx->writeProc((void *)&buffer, 12, 1, info->userCtx->writeProcUserPtr)) { LUPNG_WARN(info, "PNG: write error"); return PNG_ERROR; } return PNG_OK; } int luPngWriteUC(const LuUserContext *userCtx, const LuImage *img) { PngInfoStruct info = {0}; info.userCtx = userCtx; info.cimg = img; info.bytesPerPixel = (info.cimg->channels * info.cimg->depth) >> 3; info.scanlineBytes = info.bytesPerPixel * info.cimg->width; if (writeHeader(&info) != PNG_OK) return PNG_ERROR; if (processPixels(&info) != PNG_OK) { deflateEnd(&(info.stream)); return PNG_ERROR; } deflateEnd(&(info.stream)); return writeIend(&info); } int luPngWrite(PngWriteProc writeProc, void *userPtr, const LuImage *img) { LuUserContext userCtx; luUserContextInitDefault(&userCtx); userCtx.writeProc = writeProc; userCtx.writeProcUserPtr = userPtr; return luPngWriteUC(&userCtx, img); } int luPngWriteFile(const char *filename, const LuImage *img) { LuUserContext userCtx; luUserContextInitDefault(&userCtx); if (!img || !filename) return PNG_ERROR; FILE *f = fopen(filename,"wb"); if (f) { userCtx.writeProc = internalFwrite; userCtx.writeProcUserPtr = f; luPngWriteUC(&userCtx, img); fclose(f); } else { LUPNG_WARN_UC(&userCtx, "failed to open '%s'", filename); return PNG_ERROR; } return PNG_OK; } void luImageRelease(LuImage *img, const LuUserContext *userCtx) { LuUserContext ucDefault; if (userCtx == NULL) { luUserContextInitDefault(&ucDefault); userCtx = &ucDefault; } if (!img->isUserData) userCtx->freeProc(img->data, userCtx->freeProcUserPtr); if (userCtx->overrideImage != img) userCtx->freeProc(img, userCtx->freeProcUserPtr); } LuImage *luImageCreate(size_t width, size_t height, uint8_t channels, uint8_t depth, uint8_t *buffer, const LuUserContext *userCtx) { LuImage *img; LuUserContext ucDefault; if (userCtx == NULL) { luUserContextInitDefault(&ucDefault); userCtx = &ucDefault; } if (depth != 8 && depth != 16) { LUPNG_WARN_UC(userCtx, "only bit depths 8 and 16 are supported!"); return NULL; } if (width > 0x7FFFFFFF || height > 0x7FFFFFFF) { LUPNG_WARN_UC(userCtx, "only 32 bit signed image dimensions are supported!"); return NULL; } if (userCtx->overrideImage) img = userCtx->overrideImage; else img = (LuImage *)userCtx->allocProc(sizeof(LuImage), userCtx->allocProcUserPtr); if (!img) return NULL; img->width = (int32_t)width; img->height = (int32_t)height; img->channels = channels; img->depth = depth; img->pitch = width * channels * (depth >> 3); img->dataSize = img->pitch * height; if (buffer) { img->data = buffer; img->isUserData = 1; } else { img->data = (uint8_t *)userCtx->allocProc(img->dataSize, userCtx->allocProcUserPtr); img->isUserData = 0; } if (img->data == NULL) { LUPNG_WARN_UC(userCtx, "Image->data: Out of memory!"); luImageRelease(img, userCtx); return NULL; } return img; } uint8_t *luImageExtractBufAndRelease(LuImage *img, const LuUserContext *userCtx) { LuUserContext ucDefault; if (!img) return NULL; if (userCtx == NULL) { luUserContextInitDefault(&ucDefault); userCtx = &ucDefault; } uint8_t *data = img->data; img->data = NULL; luImageRelease(img, userCtx); return data; } void luUserContextInitDefault(LuUserContext *userCtx) { userCtx->readProc=NULL; userCtx->readProcUserPtr=NULL; userCtx->skipSig = 0; userCtx->writeProc=NULL; userCtx->writeProcUserPtr=NULL; userCtx->compressionLevel=Z_DEFAULT_COMPRESSION; userCtx->allocProc=internalMalloc; userCtx->allocProcUserPtr=NULL; userCtx->freeProc=internalFree; userCtx->freeProcUserPtr=NULL; userCtx->warnProc=internalPrintf; userCtx->warnProcUserPtr=(void*)stderr; userCtx->overrideImage=NULL; }
30.120127
130
0.590238
2a6c31ae6a91a99c45843f4726e7f5d953104f70
3,600
h
C
archsim/inc/util/TimerManager.h
Linestro/Gensim_Y
031b74234a92622cf2d2d2ebc2d5ba03ca28ecf8
[ "MIT" ]
10
2020-07-14T22:09:30.000Z
2022-01-11T09:57:52.000Z
archsim/inc/util/TimerManager.h
Linestro/Gensim_Y
031b74234a92622cf2d2d2ebc2d5ba03ca28ecf8
[ "MIT" ]
6
2020-07-09T12:01:57.000Z
2021-04-27T10:23:58.000Z
archsim/inc/util/TimerManager.h
Linestro/Gensim_Y
031b74234a92622cf2d2d2ebc2d5ba03ca28ecf8
[ "MIT" ]
10
2020-07-29T17:05:26.000Z
2021-12-04T14:57:15.000Z
/* This file is Copyright University of Edinburgh 2018. For license details, see LICENSE. */ /* * TimerManager.h * * Created on: 17 Dec 2013 * Author: harry */ #ifndef TIMERMANAGER_H_ #define TIMERMANAGER_H_ #include "concurrent/Thread.h" #include "concurrent/Mutex.h" #include "concurrent/ConditionVariable.h" #include <atomic> #include <chrono> #include <cstdint> #include <list> #include <unistd.h> namespace gensim { class Processor; } namespace archsim { namespace util { namespace timing { typedef std::chrono::high_resolution_clock timing_clock_t; class TimerSource { public: virtual ~TimerSource(); typedef timing_clock_t::duration rt_duration_t; template <typename T> inline rt_duration_t WaitN(T duration) { return Wait(std::chrono::duration_cast<rt_duration_t>(duration)); } virtual rt_duration_t Wait(rt_duration_t ticks) = 0; virtual bool Interrupt(); }; template<typename clock_t=std::chrono::high_resolution_clock, typename tick_t = std::chrono::milliseconds, bool busy=false> class RealTimeTimerSource : public TimerSource { public: rt_duration_t Wait(rt_duration_t ticks) { Interrupted = false; typename clock_t::time_point pre_time = clock_t::now(); typename clock_t::time_point post_time = pre_time + ticks; while(!Interrupted && clock_t::now() < post_time) if(!busy)usleep(1000); return (std::chrono::duration_cast<tick_t>(clock_t::now() - pre_time)); } bool Interrupt() { Interrupted = true; return true; } private: bool Interrupted; }; class InstructionTimerSource : public TimerSource { public: InstructionTimerSource(const gensim::Processor &processor); uint32_t WaitTicks(uint32_t ticks); private: const gensim::Processor &cpu; }; class TimerState; typedef TimerState* TimerCtx; typedef void (*timer_callback_t)(TimerCtx, void*); class TimerState { public: typedef timing_clock_t timer_t; typedef timer_t::duration time_difference_t; typedef timer_t::time_point time_point_t; timer_callback_t callback; time_point_t issue_time; time_point_t invoke_time; void* data; inline time_difference_t get_ticks_left() const { return invoke_time - timer_t::now(); } inline time_difference_t get_delta() const { return invoke_time - issue_time; } }; } } } namespace archsim { namespace util { namespace timing { // Intelligent timer manager. Allows the registration of timer callbacks, callable after the given time. class TimerManager : public concurrent::Thread { public: TimerManager(TimerSource *source); ~TimerManager(); typedef timing_clock_t::duration mgr_duration_t; template <typename T> TimerCtx RegisterOneshot(T duration, timer_callback_t callback, void* data) { return RegisterOneshotInternal(std::chrono::duration_cast<mgr_duration_t>(duration), callback, data); } void ResetTimer(TimerCtx timer); void DeregisterTimer(TimerCtx timer); void run(); private: TimerCtx RegisterOneshotInternal(mgr_duration_t duration, timer_callback_t callback, void* data); TimerSource *timer_source; uint32_t next_ctx; //Mutex used to lock the timers vector while adding new timers concurrent::Mutex timers_mutex; concurrent::ConditionVariable timers_cond; typedef std::list<TimerState*> timer_vector_t; timer_vector_t timers; std::atomic<bool> terminate; }; } } } #endif /* TIMERMANAGER_H_ */
21.556886
173
0.704444
a4db68ec1664eb93502c9b12b5124ba6b0b58c55
334
h
C
FSImageDownloader/FSImageDownloader/FSImageDownloader.h
folse/FSImageDownloader
fc08dfc3b57757c110bbeca40e059cd8c3d63b96
[ "Apache-2.0" ]
null
null
null
FSImageDownloader/FSImageDownloader/FSImageDownloader.h
folse/FSImageDownloader
fc08dfc3b57757c110bbeca40e059cd8c3d63b96
[ "Apache-2.0" ]
null
null
null
FSImageDownloader/FSImageDownloader/FSImageDownloader.h
folse/FSImageDownloader
fc08dfc3b57757c110bbeca40e059cd8c3d63b96
[ "Apache-2.0" ]
null
null
null
// // FSImageDownloader.h // Folse // // Created by folse on 11/23/13. // Copyright (c) 2013 folse. All rights reserved. // @interface FSImageDownloader : NSObject @property (nonatomic) BOOL needCustomSize; @property (nonatomic, copy) void (^completionHandler)(UIImage *image); -(void)downloadImageFrom:(NSString *)url; @end
18.555556
70
0.715569
2bada943c7e14d27e70e8530fda5ff2c754c4ddb
3,162
c
C
source/hdk2/hdk2/hdkcli_cpp/unittest/unittest_schema.c
junnanx/rdkb-Utopia
88cec7b166bf0379d498c04248b9712424e2c0ad
[ "Apache-2.0" ]
5
2017-08-08T08:04:18.000Z
2020-03-11T16:19:43.000Z
source/hdk2/hdk2/hdkcli_cpp/unittest/unittest_schema.c
junnanx/rdkb-Utopia
88cec7b166bf0379d498c04248b9712424e2c0ad
[ "Apache-2.0" ]
1
2021-11-24T02:13:21.000Z
2021-11-24T02:13:21.000Z
source/hdk2/hdk2/hdkcli_cpp/unittest/unittest_schema.c
junnanx/rdkb-Utopia
88cec7b166bf0379d498c04248b9712424e2c0ad
[ "Apache-2.0" ]
7
2018-08-16T18:59:09.000Z
2021-11-23T05:04:33.000Z
/* * If not stated otherwise in this file or this component's Licenses.txt file the * following copyright and licenses apply: * * Copyright 2015 RDK Management * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /********************************************************************** Copyright [2014] [Cisco Systems, Inc.] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. **********************************************************************/ #include "unittest_schema.h" #include "unittest_util.h" #include <string.h> /* * Namespaces */ const HDK_XML_Namespace s_namespaces[] = { /* 0 */ "http://cisco.com/HDK/Unittest/Client/cpp/", HDK_XML_Schema_NamespacesEnd }; /* * Elements */ const HDK_XML_ElementNode s_elements[] = { /* Element_Blob */ { 0, "Blob" }, /* Element_BlobArray */ { 0, "BlobArray" }, /* Element_BoolArray */ { 0, "BoolArray" }, /* Element_DateTimeArray */ { 0, "DateTimeArray" }, /* Element_EnumMember */ { 0, "Enum" }, /* Element_EnumArray */ { 0, "EnumArray" }, /* Element_IPAddress */ { 0, "IPAddress" }, /* Element_IPAddressArray */ { 0, "IPAddressArray" }, /* Element_IntArray */ { 0, "IntArray" }, /* Element_LongArray */ { 0, "LongArray" }, /* Element_MACAddress */ { 0, "MACAddress" }, /* Element_MACAddressArray */ { 0, "MACAddressArray" }, /* Element_StringArray */ { 0, "StringArray" }, /* Element_Struct */ { 0, "Struct" }, /* Element_StructArray */ { 0, "StructArray" }, /* Element_UUID */ { 0, "UUID" }, /* Element_UUIDArray */ { 0, "UUIDArray" }, /* Element_bool */ { 0, "bool" }, /* Element_datetime */ { 0, "datetime" }, /* Element_int */ { 0, "int" }, /* Element_long */ { 0, "long" }, /* Element_string */ { 0, "string" }, HDK_XML_Schema_ElementsEnd }; static const HDK_XML_EnumValue s_enum_UnittestEnum[] = { "UnittestEnum_Value0", "UnittestEnum_Value1", "UnittestEnum_Value2", "UnittestEnum_Value3", "UnittestEnum_Value4", HDK_XML_Schema_EnumTypeValuesEnd }; /* * Enumeration types array */ const HDK_XML_EnumType s_enumTypes[] = { s_enum_UnittestEnum };
30.699029
81
0.639785
28ad6f8ee36b00754df4e7446435fac9f4d34d8e
2,137
h
C
src/game/engine/sprite.h
strdavis/tetris-clone
299b2cc954b87edff5c2d54bfc222d488925f4bd
[ "MIT" ]
1
2020-12-26T11:46:32.000Z
2020-12-26T11:46:32.000Z
src/game/engine/sprite.h
strdavis/tetris-clone
299b2cc954b87edff5c2d54bfc222d488925f4bd
[ "MIT" ]
null
null
null
src/game/engine/sprite.h
strdavis/tetris-clone
299b2cc954b87edff5c2d54bfc222d488925f4bd
[ "MIT" ]
null
null
null
/* * MIT License * * Copyright (c) 2020 Spencer Davis * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #pragma once #include <memory> #include "SDL_stdinc.h" #include "SDL_rect.h" class WrappedGpuImage; class GPU_Image; // Represents an image with a corresponding position and size. // // Sprites do not contain image data, keeping them lightweight. // They point to images in the image bank, // and contain information about how to draw those images. // // Coordinates for sprites are relative to the position of // the game element that owns them. class Sprite { public: Sprite(std::shared_ptr <WrappedGpuImage> image, int x = 0, int y = 0, int w = 0, int h = 0); Sprite(std::shared_ptr <Sprite> sprite); Sprite(); void setImage(std::shared_ptr <WrappedGpuImage> newImage); void setSize(Uint16 w, Uint16 h); void setPos(int x, int y); int getWidth(); int getHeight(); SDL_Point getPos(); GPU_Image* getRawImage(); std::shared_ptr <WrappedGpuImage> getImage(); private: int width; int height; SDL_Point pos; std::shared_ptr <WrappedGpuImage> image; };
31.895522
96
0.734675
9ee6be58242c6eea9151629fd6f30a4a7216df9a
5,898
h
C
src/graphics/lib/magma/src/magma_util/platform/platform_connection_client.h
EnderNightLord-ChromeBook/zircon-rpi
b09b1eb3aa7a127c65568229fe10edd251869283
[ "BSD-2-Clause" ]
null
null
null
src/graphics/lib/magma/src/magma_util/platform/platform_connection_client.h
EnderNightLord-ChromeBook/zircon-rpi
b09b1eb3aa7a127c65568229fe10edd251869283
[ "BSD-2-Clause" ]
null
null
null
src/graphics/lib/magma/src/magma_util/platform/platform_connection_client.h
EnderNightLord-ChromeBook/zircon-rpi
b09b1eb3aa7a127c65568229fe10edd251869283
[ "BSD-2-Clause" ]
null
null
null
// Copyright 2016 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef SRC_GRAPHICS_LIB_MAGMA_SRC_MAGMA_UTIL_PLATFORM_PLATFORM_CONNECTION_CLIENT_H_ #define SRC_GRAPHICS_LIB_MAGMA_SRC_MAGMA_UTIL_PLATFORM_PLATFORM_CONNECTION_CLIENT_H_ #include <memory> #include "magma.h" #include "magma_util/macros.h" #include "magma_util/status.h" #include "platform_buffer.h" #include "platform_object.h" #include "platform_thread.h" namespace magma { class PlatformPerfCountPoolClient { public: virtual ~PlatformPerfCountPoolClient() = default; virtual uint64_t pool_id() = 0; virtual magma_handle_t handle() = 0; virtual magma::Status ReadPerformanceCounterCompletion(uint32_t* trigger_id_out, uint64_t* buffer_id_out, uint32_t* buffer_offset_out, uint64_t* time_out, uint32_t* result_flags_out) = 0; }; // Any implementation of PlatformConnectionClient shall be threadsafe. class PlatformConnectionClient : public magma_connection { public: virtual ~PlatformConnectionClient() {} static std::unique_ptr<PlatformConnectionClient> Create(uint32_t device_handle, uint32_t device_notification_handle, uint64_t max_inflight_messages, uint64_t max_inflight_bytes); // Imports a buffer for use in the system driver virtual magma_status_t ImportBuffer(PlatformBuffer* buffer) = 0; // Destroys the buffer with |buffer_id| within this connection // returns false if |buffer_id| has not been imported virtual magma_status_t ReleaseBuffer(uint64_t buffer_id) = 0; // Imports an object for use in the system driver virtual magma_status_t ImportObject(uint32_t handle, PlatformObject::Type object_type) = 0; // Releases the connection's reference to the given object. virtual magma_status_t ReleaseObject(uint64_t object_id, PlatformObject::Type object_type) = 0; // Creates a context and returns the context id virtual void CreateContext(uint32_t* context_id_out) = 0; // Destroys a context for the given id virtual void DestroyContext(uint32_t context_id) = 0; virtual magma_status_t GetError() = 0; virtual magma_status_t MapBufferGpu(uint64_t buffer_id, uint64_t gpu_va, uint64_t page_offset, uint64_t page_count, uint64_t flags) = 0; virtual magma_status_t UnmapBufferGpu(uint64_t buffer_id, uint64_t gpu_va) = 0; virtual magma_status_t CommitBuffer(uint64_t buffer_id, uint64_t page_offset, uint64_t page_count) = 0; virtual magma_status_t BufferRangeOp(uint64_t buffer_id, uint32_t options, uint64_t start, uint64_t length) = 0; virtual uint32_t GetNotificationChannelHandle() = 0; virtual magma_status_t ReadNotificationChannel(void* buffer, size_t buffer_size, size_t* buffer_size_out, magma_bool_t* more_data_out) = 0; virtual void ExecuteCommandBufferWithResources(uint32_t context_id, magma_system_command_buffer* command_buffer, magma_system_exec_resource* resources, uint64_t* semaphores) = 0; virtual void ExecuteImmediateCommands(uint32_t context_id, uint64_t command_count, magma_inline_command_buffer* command_buffers, uint64_t* messages_sent_out) = 0; virtual magma_status_t AccessPerformanceCounters( std::unique_ptr<magma::PlatformHandle> handle) = 0; virtual magma_status_t IsPerformanceCounterAccessEnabled(bool* enabled_out) = 0; virtual magma::Status EnablePerformanceCounters(uint64_t* counters, uint64_t counter_count) = 0; virtual magma::Status CreatePerformanceCounterBufferPool( std::unique_ptr<PlatformPerfCountPoolClient>* pool_out) = 0; virtual magma::Status ReleasePerformanceCounterBufferPool(uint64_t pool_id) = 0; virtual magma::Status AddPerformanceCounterBufferOffsetsToPool(uint64_t pool_id, const magma_buffer_offset* offsets, uint64_t offsets_count) = 0; virtual magma::Status RemovePerformanceCounterBufferFromPool(uint64_t pool_id, uint64_t buffer_id) = 0; virtual magma::Status DumpPerformanceCounters(uint64_t pool_id, uint32_t trigger_id) = 0; virtual magma::Status ClearPerformanceCounters(uint64_t* counters, uint64_t counter_count) = 0; // Retrieve the performance counter access token from a channel to a gpu-performance-counters // device. static std::unique_ptr<magma::PlatformHandle> RetrieveAccessToken(magma::PlatformHandle* channel); static PlatformConnectionClient* cast(magma_connection_t connection) { DASSERT(connection); DASSERT(connection->magic_ == kMagic); return static_cast<PlatformConnectionClient*>(connection); } // Returns: inflight messages, inflight memory virtual std::pair<uint64_t, uint64_t> GetFlowControlCounts() = 0; protected: PlatformConnectionClient() { magic_ = kMagic; } private: static const uint32_t kMagic = 0x636f6e6e; // "conn" (Connection) }; } // namespace magma #endif // SRC_GRAPHICS_LIB_MAGMA_SRC_MAGMA_UTIL_PLATFORM_PLATFORM_CONNECTION_CLIENT_H_
49.15
100
0.663784
3d1c708fa97e43bf208d28fd12a0e6f18df1ee2b
1,122
h
C
src/ffmpeg/ffmpeg_vid_decoder.h
xyyangkun/rkmedia
63d0170d9e0e51c6d04963d3164d5ff9f7cf093b
[ "BSD-3-Clause" ]
null
null
null
src/ffmpeg/ffmpeg_vid_decoder.h
xyyangkun/rkmedia
63d0170d9e0e51c6d04963d3164d5ff9f7cf093b
[ "BSD-3-Clause" ]
null
null
null
src/ffmpeg/ffmpeg_vid_decoder.h
xyyangkun/rkmedia
63d0170d9e0e51c6d04963d3164d5ff9f7cf093b
[ "BSD-3-Clause" ]
null
null
null
// Copyright 2019 Fuzhou Rockchip Electronics Co., Ltd. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef __FFMPEG_VID_DECODER_ #define __FFMPEG_VID_DECODER_ #include "decoder.h" #include "ffmpeg_utils.h" namespace easymedia { class FFMpegDecoder : public VideoDecoder { public: FFMpegDecoder(const char *param); virtual ~FFMpegDecoder(); static const char *GetCodecName() { return "ffmpeg_vid"; } virtual bool Init() override; virtual int Process(const std::shared_ptr<MediaBuffer> &input, std::shared_ptr<MediaBuffer> &output, std::shared_ptr<MediaBuffer> extra_output) override; virtual int SendInput(const std::shared_ptr<MediaBuffer> &input) override; virtual std::shared_ptr<MediaBuffer> FetchOutput() override; private: int need_split; AVCodecID codec_id; bool support_sync; bool support_async; AVPacket *pkt; AVCodec *codec; AVCodecContext *ffmpeg_context; AVCodecParserContext *parser; }; } // namespace easymedia #endif // #ifndef __FFMPEG_VID_DECODER_
33
76
0.741533
fa079fdf81233cf042a32b896cd5a968d56ebbe5
17,762
c
C
benchmarks/ferreiradaselva-mathc/test.c
pointhi/benchmarks
68899480c0fc8d361079a81edc6d816d5f17d58e
[ "UPL-1.0" ]
7
2018-12-10T02:41:43.000Z
2020-06-18T06:13:59.000Z
benchmarks/ferreiradaselva-mathc/test.c
pointhi/benchmarks
68899480c0fc8d361079a81edc6d816d5f17d58e
[ "UPL-1.0" ]
23
2018-06-07T07:46:27.000Z
2018-08-06T17:57:39.000Z
benchmarks/ferreiradaselva-mathc/test.c
pointhi/benchmarks
68899480c0fc8d361079a81edc6d816d5f17d58e
[ "UPL-1.0" ]
2
2018-11-27T20:37:34.000Z
2019-04-23T15:38:35.000Z
/* Copyright (C) 2016 Felipe Ferreira da Silva This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include <stdio.h> #include <float.h> #include <stdbool.h> #include <stdint.h> #include "mathc.h" const float epsilon = FLT_EPSILON; struct cerror { int32_t failed; int32_t passed; int32_t passed_with_e10; int32_t passed_with_e100; int32_t passed_with_e1000; }; void printf_bool_test(struct cerror *error, char *msg, bool e, bool r) { if (e) { printf("%s:\n\tExpected true\n\t", msg); } else { printf("%s:\n\tExpected false\n\t", msg); } if (r) { printf(" Actual true\t"); } else { printf(" Actual false\t"); } if (e == r) { error->passed = error->passed + 1; printf("~passed~\n\n"); } else { error->failed = error->failed + 1; printf("~failed~\n\n"); } } void printf_1f_test(struct cerror *error, char *msg, float e1, float r1) { bool done = false; printf("%s:\n\tExpected % .4f\n\t Actual % .4f\t", msg, e1, r1); if (nearly_equal(e1, r1, epsilon)) { error->passed = error->passed + 1; done = true; printf("~passed~\n\n"); } if (!done && nearly_equal(e1, r1, epsilon * 10.0f)) { error->passed_with_e10 = error->passed_with_e10 + 1; done = true; printf("~passed with epsilon * 10.0~\n\n"); } if (!done && nearly_equal(e1, r1, epsilon * 100.0f)) { error->passed_with_e100 = error->passed_with_e100 + 1; done = true; printf("~passed with epsilon * 100.0~\n\n"); } if (!done && nearly_equal(e1, r1, epsilon * 1000.0f)) { error->passed_with_e1000 = error->passed_with_e1000 + 1; done = true; printf("~passed with epsilon * 1000.0~\n\n"); } if (!done) { error->failed = error->failed + 1; printf("~failed~\n\n"); } } void printf_2f_test(struct cerror *error, char *msg, float e1, float e2, float r1, float r2) { bool done = false; printf("%s:\n\tExpected % .4f, % .4f\n\t Actual % .4f, % .4f\t", msg, e1, e2, r1, r2); if (nearly_equal(e1, r1, epsilon) && nearly_equal(e2, r2, epsilon)) { error->passed = error->passed + 1; done = true; printf("~passed~\n\n"); } if (!done && nearly_equal(e1, r1, epsilon * 10.0f) && nearly_equal(e2, r2, epsilon * 10.0f)) { error->passed_with_e10 = error->passed_with_e10 + 1; done = true; printf("~passed with epsilon * 10.0~\n\n"); } if (!done && nearly_equal(e1, r1, epsilon * 100.0f) && nearly_equal(e2, r2, epsilon * 100.0f)) { error->passed_with_e100 = error->passed_with_e100 + 1; done = true; printf("~passed with epsilon * 100.0~\n\n"); } if (!done && nearly_equal(e1, r1, epsilon * 1000.0f) && nearly_equal(e2, r2, epsilon * 1000.0f)) { error->passed_with_e1000 = error->passed_with_e1000 + 1; done = true; printf("~passed with epsilon * 1000.0~\n\n"); } if (!done) { error->failed = error->failed + 1; printf("~failed~\n\n"); } } void printf_3f_test(struct cerror *error, char *msg, float e1, float e2, float e3, float r1, float r2, float r3) { bool done = false; printf("%s:\n\tExpected % .4f, % .4f, % .4f\n\t Actual % .4f, % .4f, % .4f\t", msg, e1, e2, e3, r1, r2, r3); if (nearly_equal(e1, r1, epsilon) && nearly_equal(e2, r2, epsilon) && nearly_equal(e3, r3, epsilon)) { error->passed = error->passed + 1; done = true; printf("~passed~\n\n"); } if (!done && nearly_equal(e1, r1, epsilon * 10.0f) && nearly_equal(e2, r2, epsilon * 10.0f) && nearly_equal(e3, r3, epsilon * 10.0f)) { error->passed_with_e10 = error->passed_with_e10 + 1; done = true; printf("~passed with epsilon * 10.0~\n\n"); } if (!done && nearly_equal(e1, r1, epsilon * 100.0f) && nearly_equal(e2, r2, epsilon * 100.0f) && nearly_equal(e2, r2, epsilon * 100.0f)) { error->passed_with_e100 = error->passed_with_e100 + 1; done = true; printf("~passed with epsilon * 100.0~\n\n"); } if (!done && nearly_equal(e1, r1, epsilon * 1000.0f) && nearly_equal(e2, r2, epsilon * 1000.0f) && nearly_equal(e2, r2, epsilon * 1000.0f)) { error->passed_with_e1000 = error->passed_with_e1000 + 1; done = true; printf("~passed with epsilon * 1000.0~\n\n"); } if (!done) { error->failed = error->failed + 1; printf("~failed~\n\n"); } } void printf_4f_test(struct cerror *error, char *msg, float e1, float e2, float e3, float e4, float r1, float r2, float r3, float r4) { bool done = false; printf("%s:\n\tExpected % .9f, % .9f, % .9f, % .9f\n\t Actual % .9f, % .9f, % .9f, % .9f\t", msg, e1, e2, e3, e4, r1, r2, r3, r4); if (nearly_equal(e1, r1, epsilon) && nearly_equal(e2, r2, epsilon) && nearly_equal(e3, r3, epsilon) && nearly_equal(e3, r3, epsilon)) { error->passed = error->passed + 1; done = true; printf("~passed~\n\n"); } if (!done && nearly_equal(e1, r1, epsilon * 10.0f) && nearly_equal(e2, r2, epsilon * 10.0f) && nearly_equal(e3, r3, epsilon * 10.0f) && nearly_equal(e3, r3, epsilon * 10.0f)) { error->passed_with_e10 = error->passed_with_e10 + 1; done = true; printf("~passed with epsilon * 10.0~\n\n"); } if (!done && nearly_equal(e1, r1, epsilon * 100.0f) && nearly_equal(e2, r2, epsilon * 100.0f) && nearly_equal(e3, r3, epsilon * 100.0f) && nearly_equal(e4, r4, epsilon * 100.0f)) { error->passed_with_e100 = error->passed_with_e100 + 1; done = true; printf("~passed with epsilon * 100.0~\n\n"); } if (!done && nearly_equal(e1, r1, epsilon * 1000.0f) && nearly_equal(e2, r2, epsilon * 1000.0f) && nearly_equal(e3, r3, epsilon * 1000.0f) && nearly_equal(e4, r4, epsilon * 1000.0f)) { error->passed_with_e1000 = error->passed_with_e1000 + 1; done = true; printf("~passed with epsilon * 1000.0~\n\n"); } if (!done) { error->failed = error->failed + 1; printf("~failed~\n\n"); } } void vector2_tests(struct cerror *error) { struct vec a; struct vec b; struct vec r; float p; printf("\n# Making tests with 2D vectors...\n"); a = to_vector2(1.11f, 2.5f); b = to_vector2(0.9f, 1.3f); r = vector2_add(a, b); printf_2f_test(error, "Add two vectors", 2.01f, 3.8f, r.x, r.y); a = to_vector2(1.11f, 2.5f); b = to_vector2(0.9f, 1.3f); r = vector2_subtract(a, b); printf_2f_test(error, "Subtract two vectors", 0.21f, 1.2f, r.x, r.y); a = to_vector2(1.11f, 2.5f); r = vector2_scale(a, 3.3f); printf_2f_test(error, "Scale vector", 3.663f, 8.25f, r.x, r.y); a = to_vector2(1.11f, 2.5f); b = to_vector2(0.9f, 1.3f); r = vector2_multiply(a, b); printf_2f_test(error, "Multiply two vectors", 0.999f, 3.25f, r.x, r.y); a = to_vector2(1.11f, 2.5f); b = to_vector2(0.9f, 1.3f); r = vector2_divide(a, b); printf_2f_test(error, "Divide two vectors", 1.2333333333f, 1.9230769231f, r.x, r.y); a = to_vector2(1.11f, 2.5f); r = vector2_negative(a); printf_2f_test(error, "Negative vector", -1.11f, -2.5f, r.x, r.y); a = to_vector2(1.11f, 2.5f); r = vector2_inverse(a); printf_2f_test(error, "Inverse vector", 0.9009009009f, 0.4f, r.x, r.y); a = to_vector2(-3.33f, 1.1f); r = vector2_abs(a); printf_2f_test(error, "Absolute vector", 3.33f, 1.1f, r.x, r.y); a = to_vector2(1.11f, -2.5f); r = vector2_floor(a); printf_2f_test(error, "Floor vector", 1.0f, -3.0f, r.x, r.y); a = to_vector2(-0.00011f, 3.999999f); r = vector2_floor(a); printf_2f_test(error, "Floor vector", -1.0f, 3.0f, r.x, r.y); a = to_vector2(1.11f, -2.5f); r = vector2_ceil(a); printf_2f_test(error, "Ceil vector", 2.0f, -2.0f, r.x, r.y); a = to_vector2(-0.00011f, 3.999999f); r = vector2_ceil(a); printf_2f_test(error, "Ceil vector", 0.0f, 4.0f, r.x, r.y); a = to_vector2(1.11f, -2.55f); r = vector2_round(a); printf_2f_test(error, "Round vector", 1.0f, -3.0f, r.x, r.y); a = to_vector2(4.31f, -6.65f); b = to_vector2(-3.41f, 2.7f); r = vector2_max(a, b); printf_2f_test(error, "Maximum of vectors", 4.31f, 2.7f, r.x, r.y); a = to_vector2(4.31f, -6.65f); b = to_vector2(-3.41f, 2.7f); r = vector2_min(a, b); printf_2f_test(error, "Minimum of vectors", -3.41f, -6.65f, r.x, r.y); a = to_vector2(4.31f, -6.65f); b = to_vector2(-3.41f, 2.7f); p = vector2_dot(a, b); printf_1f_test(error, "Dot value of vectors", -32.6521f, p); a = to_vector2(2.0f, 2.0f); p = vector2_angle(a); printf_1f_test(error, "Angle (radians) of vector", 0.78539816339745f, p); a = to_vector2(4.31f, -6.65f); p = vector2_angle(a); printf_1f_test(error, "Angle (radians) of vector", -0.99574364682817f, p); a = to_vector2(-5.31f, -7.33f); p = vector2_angle(a); printf_1f_test(error, "Angle (radians) of vector", -2.1977243674756f, p); a = to_vector2(3.33f, 2.0f); p = vector2_length_squared(a); printf_1f_test(error, "Length squared of vector", 15.0889f, p); a = to_vector2(3.33f, 2.0f); p = vector2_length(a); printf_1f_test(error, "Length of vector", 3.8844433321f, p); a = to_vector2(3.33f, 2.0f); r = vector2_normalize(a); printf_2f_test(error, "Normalize vector", 0.8572664271f, 0.514874731f, r.x, r.y); a = to_vector2(1.0f, -1.0f); b = to_vector2(0.0f, 1.0f); r = vector2_slide(a, b); printf_2f_test(error, "Slide vector by normal", 1.0f, 0.0f, r.x, r.y); a = to_vector2(-2.0f, 0.0f); b = vector2_normalize(to_vector2(1.0f, 1.0f)); r = vector2_slide(a, b); printf_2f_test(error, "Slide vector by normal", -1.0f, 1.0f, r.x, r.y); a = to_vector2(1.0f, -1.0f); b = to_vector2(-1.0f, 0.0f); r = vector2_reflect(a, b); printf_2f_test(error, "Reflect vector by another", -1.0f, -1.0f, r.x, r.y); a = to_vector2(1.0f, 1.0f); b = to_vector2(0.0f, -1.0f); r = vector2_reflect(a, b); printf_2f_test(error, "Reflect vector by another", 1.0f, -1.0f, r.x, r.y); a = to_vector2(2.0f, 1.0f); r = vector2_tangent(a); printf_2f_test(error, "Vector tangent", 1.0f, -2.0f, r.x, r.y); a = to_vector2(1.0f, 0.0f); r = vector2_rotate(a, 90.0f * M_PIF / 180.0f); printf_2f_test(error, "Rotate vector", 0.0f, 1.0f, r.x, r.y); a = to_vector2(1.0f, 0.0f); r = vector2_rotate(a, 45.0f * M_PIF / 180.0f); printf_2f_test(error, "Rotate vector", 0.707106781f,0.707106781f, r.x, r.y); a = to_vector2(1.0f, 0.0f); r = vector2_rotate(a, 130.0f * M_PIF / 180.0f); printf_2f_test(error, "Rotate vector", -0.64278761f,0.766044443f, r.x, r.y); a = to_vector2(-7.0f, -4.0f); b = to_vector2(17.0f, 6.5f); p = vector2_distance_to(a, b); printf_1f_test(error, "Distance between vector", 26.196374f, p); a = to_vector2(-7.0f, -4.0f); b = to_vector2(17.0f, 6.5f); p = vector2_distance_squared_to(a, b); printf_1f_test(error, "Distance squared between vector", 686.2500107479f, p); a = to_vector2(-7.0f, -4.0f); b = to_vector2(17.0f, 6.5f); r = vector2_linear_interpolation(a, b, 0.33f); printf_2f_test(error, "Linear interpolation between vectors", 0.92f, -0.535f, r.x, r.y); } void vector3_tests(struct cerror *error) { struct vec a; struct vec b; struct vec r; float p; printf("\n# Making tests with 3D vectors...\n"); a = to_vector3(1.11f, 2.5f, 0.0003f); b = to_vector3(0.9f, 1.3f, 3.999999f); r = vector3_add(a, b); printf_3f_test(error, "Add two vectors", 2.01f, 3.8f, 4.000299f, r.x, r.y, r.z); a = to_vector3(1.11f, 2.5f, 0.0003f); b = to_vector3(0.9f, 1.3f, 3.999999f); r = vector3_subtract(a, b); printf_3f_test(error, "Subtract vectors", 0.21f, 1.2f, -3.999699f, r.x, r.y, r.z); a = to_vector3(1.11f, 2.5f, 0.0003f); r = vector3_scale(a, 3.3f); printf_3f_test(error, "Scale vector", 3.663f, 8.25f, 0.000990f, r.x, r.y, r.z); a = to_vector3(1.11f, 2.5f, 0.0003f); b = to_vector3(0.9f, 1.3f, 3.999999f); r = vector3_multiply(a, b); printf_3f_test(error, "Multiply vectors", 0.999f, 3.25f, 0.001200f, r.x, r.y, r.z); a = to_vector3(1.11f, 2.5f, 0.0003f); b = to_vector3(0.9f, 1.3f, 3.999999f); r = vector3_divide(a, b); printf_3f_test(error, "Divide vectors", 1.2333333333f, 1.9230769231f, 0.000075f, r.x, r.y, r.z); a = to_vector3(1.11f, 2.5f, 0.0003f); r = vector3_negative(a); printf_3f_test(error, "Negative vector", -1.11f, -2.5f, -0.0003f, r.x, r.y, r.z); a = to_vector3(1.11f, 2.5f, 0.0003f); r = vector3_inverse(a); printf_3f_test(error, "Inverse vector", 0.9009009009f, 0.4f, 3333.3333333333f, r.x, r.y, r.z); a = to_vector3(-3.33f, 1.1f, -0.00001f); r = vector3_abs(a); printf_3f_test(error, "Absolute vector", 3.33f, 1.1f, 0.00001f, r.x, r.y, r.z); a = to_vector3(1.11f, -2.5f, 0.0003f); r = vector3_floor(a); printf_3f_test(error, "Floor vector", 1.0f, -3.0f, 0.0f, r.x, r.y, r.z); a = to_vector3(-0.00011f, 3.999999f, -0.99999f); r = vector3_floor(a); printf_3f_test(error, "Floor vector", -1.0f, 3.0f, -1.0f, r.x, r.y, r.z); a = to_vector3(1.11f, -2.5f, 9.99999f); r = vector3_ceil(a); printf_3f_test(error, "Ceil vector", 2.0f, -2.0f, 10.0f, r.x, r.y, r.z); a = to_vector3(-0.00011f, 3.999999f, 0.0000001f); r = vector3_ceil(a); printf_3f_test(error, "Ceil vector", 0.0f, 4.0f, 1.0f, r.x, r.y, r.z); a = to_vector3(1.11f, -2.55f, 3.50000001f); r = vector3_round(a); printf_3f_test(error, "Round vector", 1.0f, -3.0f, 4.0f, r.x, r.y, r.z); a = to_vector3(544.00001f, -233333.51f, 7999.50000001f); r = vector3_round(a); printf_3f_test(error, "Round vector", 544.0f, -233334.0f, 8000.0f, r.x, r.y, r.z); a = to_vector3(4.31f, -6.65f, 4.5f); b = to_vector3(-3.41f, 2.7f, -5.0f); r = vector3_max(a, b); printf_3f_test(error, "Maximum between vectors", 4.31f, 2.7f, 4.5f, r.x, r.y, r.z); a = to_vector3(4.31f, -6.65f, 4.5f); b = to_vector3(-3.41f, 2.7f, -5.0f); r = vector3_min(a, b); printf_3f_test(error, "Minimum between vectors", -3.41f, -6.65f, -5.0f, r.x, r.y, r.z); a = to_vector3(4.31f, -6.65f, 1.0f); b = to_vector3(-3.41f, 2.7f, 2.0f); p = vector3_dot(a, b); printf_1f_test(error, "Dot value of vectors", -30.652100f, p); a = to_vector3(3.33f, 2.0f, 3.0f); p = vector3_length_squared(a); printf_1f_test(error, "Length squared of vector", 24.088900f, p); a = to_vector3(3.33f, 2.0f, 3.0f); p = vector3_length(a); printf_1f_test(error, "Length of vector", 4.908044f, p); a = to_vector3(3.33f, 2.0f, 5.0f); r = vector3_normalize(a); printf_3f_test(error, "Normalize vector", 0.525935f, 0.315877f, 0.789692f, r.x, r.y, r.z); a = to_vector3(-7.0f, -4.0f, 99.9f); b = to_vector3(17.0f, 6.5f, 103.33f); p = vector3_distance_to(a, b); printf_1f_test(error, "Distance between vectors", 26.419971f, p); a = to_vector3(-7.0f, -4.0f, 99.9f); b = to_vector3(17.0f, 6.5f, 103.33f); p = vector3_distance_squared_to(a, b); printf_1f_test(error, "Distance squared between vectors", 698.014893f, p); a = to_vector3(-7.0f, -4.0f, 99.9f); b = to_vector3(17.0f, 6.5f, 103.33f); r = vector3_linear_interpolation(a, b, 0.33f); printf_3f_test(error, "Linear interpolation between vectors", 0.92f, -0.535f, 101.031898f, r.x, r.y, r.z); } void quaternion_tests(struct cerror *error) { struct vec a; struct vec b; struct vec r; float p; printf("\n# Making tests with quaternions...\n"); a = to_quaternion(0.0f, 1.0f, 0.0f, 1.0f); r = quaternion_normalize(a); printf_4f_test(error, "Normalize quaternion", 0.7071067812f, 0.0, 0.7071067812f, 0.0f, r.w, r.x, r.y, r.z); a = to_vector3(1.0f, 0.0f, 0.0f); r = quaternion_from_axis_angle(a, M_PIF_2); printf_4f_test(error, "Quaternion from axis-angle", 0.707099974f, 0.707099974f, 0.0f, 0.0f, r.w, r.x, r.y, r.z); a = to_quaternion(0.7071067812f, 0.0f, 0.0f, 0.7071067812f); r = quaternion_to_axis_angle(a); printf_4f_test(error, "Quaternion to axis-angle", 1.0f, 0.0f, 0.0f, 1.570796371f, r.x, r.y, r.z, r.w); } void matrix_tests(struct cerror *error) { struct mat a; struct mat b; struct mat r; float p; printf("\n# Making tests with matrices...\n"); a = matrix_identity(); b = matrix_identity(); r = matrix_multiply_matrix(a, b); } void intersection_tests(struct cerror *error) { struct vec a; struct vec b; struct vec c; struct vec d; printf("\n# Making tests with intersection...\n"); a = to_vector2(0.0f, 0.0f); b = to_vector2(0.0f, 1.0f); c = to_vector2(1.0f, 0.0f); d = to_vector2(0.5f, 0.5f); printf_bool_test(error, "2D vector in triangle", true, vector2_in_triangle(d, a, b, c)); a = to_vector2(0.0f, 0.0f); b = to_vector2(1.0f, 1.0f); c = to_vector2(1.0f, 0.0f); d = to_vector2(0.5f, 0.5f); printf_bool_test(error, "2D vector in triangle", true, vector2_in_triangle(d, a, b, c)); a = to_vector2(0.0f, 0.0f); b = to_vector2(1.0f, 1.0f); c = to_vector2(1.0f, 0.0f); d = to_vector2(0.5f, 0.6f); printf_bool_test(error, "2D vector in triangle", false, vector2_in_triangle(d, a, b, c)); a = to_vector2(0.0f, 1.0f); b = to_vector2(1.0f, 1.0f); c = to_vector2(1.0f, 0.0f); d = to_vector2(0.5f, 0.4f); printf_bool_test(error, "2D vector in triangle", false, vector2_in_triangle(d, a, b, c)); } int main(int argc, char **args) { struct cerror error = {0}; vector2_tests(&error); vector3_tests(&error); quaternion_tests(&error); matrix_tests(&error); intersection_tests(&error); printf("\nTotal of failed tests: %d\n", error.failed); printf("Total of tests that passed: %d\n", error.passed); printf("Total of tests that passed with epsilon * 10.0: %d\n", error.passed_with_e10); printf("Total of tests that passed with epsilon * 100.0: %d\n", error.passed_with_e100); printf("Total of tests that passed with epsilon * 1000.0: %d\n", error.passed_with_e1000); return error.failed; }
38.362851
185
0.655782
36ae652a2ae6a828fbbd186b4fcf45f999d2349d
11,679
h
C
src/http.h
CoolerVoid/OrionSocket
a865a14aea4e73474a48463598845c4d0fcf6703
[ "Apache-2.0" ]
1
2022-03-18T02:01:55.000Z
2022-03-18T02:01:55.000Z
src/http.h
CoolerVoid/OrionSocket
a865a14aea4e73474a48463598845c4d0fcf6703
[ "Apache-2.0" ]
null
null
null
src/http.h
CoolerVoid/OrionSocket
a865a14aea4e73474a48463598845c4d0fcf6703
[ "Apache-2.0" ]
null
null
null
/* OrionSocket - HTTP Request and Response handling -------------------------------- Author: Tiago Natel de Moura <tiago4orion@gmail.com> Copyright 2010, 2011 by Tiago Natel de Moura. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #ifndef __ORIONSOCKET_HTTP_H_ #define __ORIONSOCKET_HTTP_H_ #if HAVE_CONFIG_H #include <config.h> #endif #include "debug.h" #include "types.h" #include "api.h" #include "socket.h" #include "util.h" /** * Options */ #define ORION_OPTDEBUG_REQUEST 0x01 #define ORION_OPTDEBUG_RESPONSE 0x02 #define ORION_OPTDEBUG_PROGRESS 0x04 #define ORION_OPTRESPONSE_DETAIL 0x08 #define ORION_HTTP_PROTOCOL "HTTP/1.1" #define ORION_HTTP_PROTOCOL_1_0 0x00 #define ORION_HTTP_PROTOCOL_1_1 0x01 #define ORION_HTTP_PROTOCOL_UNKNOWN 0x02 #define ORION_PROTO_HTTP 0x00 #define ORION_PROTO_HTTPS 0x01 #define ORION_PROTO_FTP 0x02 /** * Response lengths */ #define ORION_HTTP_REQUEST_MAXLENGTH 2048 #define ORION_HTTP_RESPONSE_LENGTH 1024 #define ORION_HTTP_BIG_RESPONSE 8192 /** * Request methods */ #define ORION_METHOD_GET 0x01 #define ORION_METHOD_POST 0x02 #define ORION_METHOD_TRACE 0x03 #define ORION_METHOD_PUT 0x04 #define ORION_METHOD_DELETE 0x05 #define ORION_METHOD_UNKNOWN -0x01 /** * defaults */ #define ORIONSOCKET_NL "\r\n" /** * MACROS */ #define ORION_GETPARTCOOKIE(part,tam) \ do { \ bufHandle += tam+1; \ sz = strlen(bufHandle); \ for (i = 0; i < sz && bufHandle[i] != ';'; i++); \ if (i == sz-1) { \ free(lineBuffer); \ return; \ } \ bufHandle[i] = '\0'; \ cookie->part = strdup(bufHandle); \ bufHandle += i + 2; \ } while(0) #define ORION_DEBUG_PROTO(proto) \ do { \ if (proto == ORION_PROTO_HTTP) \ DEBUG("HTTP"); \ else if (proto == ORION_PROTO_HTTPS) \ DEBUG("HTTPS"); \ else if (proto == ORION_PROTO_FTP) \ DEBUG("FTP"); \ } while(0) #define ORION_DEBUG_HTTPREQUEST(req) \ do { \ DEBUG("PROTOCOL: "); ORION_DEBUG_PROTO(req->proto); DEBUG("\n");\ DEBUG("HOST: %s:%d\n", req->host, req->port); \ DEBUG("METHOD: %s\n", orion_getStrMethod(req->method)); \ if (req->auth) \ DEBUG("AUTH: %s\n", req->auth); \ if (req->pass) \ DEBUG("PASSWORD: %s\n", req->pass); \ DEBUG("PATH: %s\n", req->path); \ if (req->file_ext) \ DEBUG("FILE EXT: %s\n", req->file_ext); \ if (req->query) \ DEBUG("QUERY STRING: %s\n", req->query); \ _uint8 _it; \ if (req->headerLen > 0) {\ DEBUG("HEADER NAME\t|\tHEADER VALUE\n"); \ for (_it = 0; _it < req->headerLen; _it++) \ DEBUG("%s\t|\t%s\n",req->header[_it].name,req->header[_it].value); \ } \ } while (0); /** * Estrutura de Dados */ /** * Armazena as informações de cookie */ typedef struct { char* name; char* value; char* domain; char* path; char* proto; char* expires; } orion_cookie; /** * orionHttpRequest structure */ typedef struct { _uint8 proto; char* host; /* Host Target */ _uint16 port; /* Port Target */ /* Authentication */ char* auth; /* User */ char* pass; /* Password */ _uint8 method; /* HTTP Method */ char* path; /* URL Path */ char* file_ext; /* File extension */ char* query; /* Query String */ nameValue *header; /* HTTP Headers */ _uint8 headerLen; /* Number of headers */ orion_cookie *cookie; /* Array of cookies */ _uint8 cookieLen; /* Number of cookies */ _uint16 option; /* Extra Options */ } orion_httpRequest; /** * orionHttpResponse structure */ typedef struct { _uint8 version; /* HTTP version. 1.0 || 1.1 */ _uint16 code; /* Status Code */ char* message; /* Server Message */ char* serverName; /* Server Name */ char* date; /* Date */ char* expires; /* Expires time */ char* location; /* Location. */ char* mime_version; /* MIME-VERSION */ char* content_type; /* Content-Type */ char* charset; /* Charset */ _uint32 content_length; /* Length of the content; */ nameValue *header; /* HTTP Headers */ _uint8 headerLen; /* Number of headers */ orion_cookie *cookie; /* Set Cookie */ _uint8 cookieLen; /* Number of cookies */ char* body; /* Body of the response */ } orion_httpResponse; /******************************************************************************* * API FOR REQUEST * ******************************************************************************/ /** * Inicializa e aloca a memória necessária para a estrutura orion_httpRequest. * TODO : Remover esse cara * * @deprecated * @param orion_httpRequest **req * @return void */ extern void orion_httpRequestInit(orion_httpRequest **req); /** * Inicializa e aloca a memória necessária para a estrutura orion_httpRequest. * * @param orion_httpRequest **req * @return void */ extern void orion_initHttpRequest(orion_httpRequest **req); /** * Libera a memória alocada por orion_httpRequestInit * TODO : Remover esse cara * * @deprecated * @param orion_httpRequest *req * @return void */ extern void orion_httpRequestCleanup(orion_httpRequest *req); /** * Libera a memória alocada por orion_initHttpRequest * * @param orion_httpRequest *req * @return void */ extern void orion_cleanupHttpRequest(orion_httpRequest *req); extern void orion_cleanupCookie(orion_cookie* cookie); /** * Configura o host e a porta para a conexão HTTP. * * @param orion_httpRequest *req * @param const char* host * @param _uint16 port */ extern void orion_setHttpRequestHost(orion_httpRequest *req, const char* host, _uint16 port); /** * Configura a requisição a partir de uma url * * @param orion_httpRequest * #param char* */ extern void orion_setUrl(orion_httpRequest* req, const char* url); /** * Configura o Path da requisição. * Por exemplo, na URL http://www.bugsec.com.br/tools/ * temos que PATH=/tools/shells/c99.txt * * @param orion_httpRequest *req * @param const char* path * @return void */ extern void orion_setHttpRequestPath(orion_httpRequest *req, const char* path); extern void orion_setHttpRequestMethod(orion_httpRequest* req, const char* method); /** * Configura a query * Por exemplo, para um GET: http://[domain]/[path]?[query] * * @param orion_httpRequest *req * @param const char* query * @return void */ extern void orion_setHttpRequestQuery(orion_httpRequest *req, const char* query); extern void orion_setHttpRequestMethod(orion_httpRequest *req, const char* method); /** * Configura um header HTTP. * * @param orion_httpRequest *req * @param const char* name * @param const char* value * @return _uint8 */ extern _uint8 orion_setHttpRequestHeader(orion_httpRequest *req, const char* name, const char* value); /** * Configura uma opção de controle para a requisição. * * @param orion_httpRequest* req * @param _uint8 option * @return void */ extern void orion_setHttpRequestOption(orion_httpRequest* req, _uint16 option); /** * Monta a requisição HTTP a partir da estrutura orion_httpRequest * previamente montada. * * @param orion_httpRequest *req * @param char* reqBuffer * @return void */ extern void orion_buildHttpRequest(orion_httpRequest *req, char* reqBuffer); /** * Monta a estrutura orion_httpResponse a partir do cabeçalho retornado pelo * servidor. * * @param orion_httpResponse *res * @param char* resBuffer * @return void */ extern void orion_buildHttpResponse(orion_httpResponse *res, char* resBuffer); /** * Executa a requisição HTTP no host alvo. * Toda a resposta do host é armazenada na variável response. * Essa função não retornará até todos os dados forem obtidos. * Se voce deseja ter mais controle do stream de dados, utilize * a função orion_httpGet(). * * @param orion_httpRequest *req * @param char* response * @return _uint8 */ extern _uint8 orion_httpRequestPerform(orion_httpRequest *req, char** response); /** * Executa a requisição HTTP no host alvo. * A cada count bytes retornados pelo servidor, é chamada a função callback * passando a string e o numero de bytes lidos. * * @param orion_httpRequest* req * @param void (*callback)(char*, _uint32) * @param _uint32 count * @return _uint8 */ extern _uint8 orion_httpGet(orion_httpRequest* req, void (*callback)(char*,_uint32), _uint32 count); /** * Iniciliza a estrutura orion_cookie * @param orion_cookie** cookie * @return void */ extern void orion_initCookie(orion_cookie** cookie); extern void orion_cleanupCookie(orion_cookie* cookie); extern void orion_setCookie(orion_cookie *cookie, const char* name, const char* value, const char* domain, const char* path, const char* proto, const char* expires); extern _uint8 orion_addCookie(orion_httpResponse* response, orion_cookie* cookie); /******************************************************************************* * API FOR RESPONSE * ******************************************************************************/ /** * Initialize and allocate memory for the structure orion_httpResponse * * @param orion_httpResponse * @return void */ extern void orion_initHttpResponse(orion_httpResponse **res); /** * Free the memory allocated by orion_initHttpResponse * * @param orion_httpResponse * @return void */ extern void orion_cleanupHttpResponse(orion_httpResponse* res); /** * Add a header to the struct orion_httpResponse * * @param orion_httpResponse * @return void */ extern void orion_setHttpResponseHeader(orion_httpResponse* res, const char* name, const char* value); /** * Realiza o parser da linha e popula res * * @param orion_httpResponse * @param char* */ extern void orion_parseResponseLine(orion_httpResponse* res, char* line); /** * Constroi a estrutura orion_httpResponse com base em buf * * @param orion_httpResponse * @param char* */ extern void orion_buildHttpResponse(orion_httpResponse* res, char* buf); extern void orion_buildCookie(orion_cookie* cookie, char* lineBuffer); extern _uint8 orion_httpReqRes(orion_httpRequest* req, orion_httpResponse** res); #endif // __ORIONSOCKET_HTTP_H_
28.695332
165
0.611696
82e472cb415a33c858ba7483635b149aaa28d136
27,627
h
C
gdb-7.3/sim/m32r/cpux.h
vidkidz/crossbridge
ba0bf94aee0ce6cf7eb5be882382e52bc57ba396
[ "MIT" ]
1
2016-04-09T02:58:13.000Z
2016-04-09T02:58:13.000Z
gdb-7.3/sim/m32r/cpux.h
vidkidz/crossbridge
ba0bf94aee0ce6cf7eb5be882382e52bc57ba396
[ "MIT" ]
null
null
null
gdb-7.3/sim/m32r/cpux.h
vidkidz/crossbridge
ba0bf94aee0ce6cf7eb5be882382e52bc57ba396
[ "MIT" ]
null
null
null
/* CPU family header for m32rxf. THIS FILE IS MACHINE GENERATED WITH CGEN. Copyright 1996-2010 Free Software Foundation, Inc. This file is part of the GNU simulators. This file is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. It 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. */ #ifndef CPU_M32RXF_H #define CPU_M32RXF_H /* Maximum number of instructions that are fetched at a time. This is for LIW type instructions sets (e.g. m32r). */ #define MAX_LIW_INSNS 2 /* Maximum number of instructions that can be executed in parallel. */ #define MAX_PARALLEL_INSNS 2 /* The size of an "int" needed to hold an instruction word. This is usually 32 bits, but some architectures needs 64 bits. */ typedef CGEN_INSN_INT CGEN_INSN_WORD; #include "cgen-engine.h" /* CPU state information. */ typedef struct { /* Hardware elements. */ struct { /* program counter */ USI h_pc; #define GET_H_PC() CPU (h_pc) #define SET_H_PC(x) (CPU (h_pc) = (x)) /* general registers */ SI h_gr[16]; #define GET_H_GR(a1) CPU (h_gr)[a1] #define SET_H_GR(a1, x) (CPU (h_gr)[a1] = (x)) /* control registers */ USI h_cr[16]; #define GET_H_CR(index) m32rxf_h_cr_get_handler (current_cpu, index) #define SET_H_CR(index, x) \ do { \ m32rxf_h_cr_set_handler (current_cpu, (index), (x));\ ;} while (0) /* accumulator */ DI h_accum; #define GET_H_ACCUM() m32rxf_h_accum_get_handler (current_cpu) #define SET_H_ACCUM(x) \ do { \ m32rxf_h_accum_set_handler (current_cpu, (x));\ ;} while (0) /* accumulators */ DI h_accums[2]; #define GET_H_ACCUMS(index) m32rxf_h_accums_get_handler (current_cpu, index) #define SET_H_ACCUMS(index, x) \ do { \ m32rxf_h_accums_set_handler (current_cpu, (index), (x));\ ;} while (0) /* condition bit */ BI h_cond; #define GET_H_COND() CPU (h_cond) #define SET_H_COND(x) (CPU (h_cond) = (x)) /* psw part of psw */ UQI h_psw; #define GET_H_PSW() m32rxf_h_psw_get_handler (current_cpu) #define SET_H_PSW(x) \ do { \ m32rxf_h_psw_set_handler (current_cpu, (x));\ ;} while (0) /* backup psw */ UQI h_bpsw; #define GET_H_BPSW() CPU (h_bpsw) #define SET_H_BPSW(x) (CPU (h_bpsw) = (x)) /* backup bpsw */ UQI h_bbpsw; #define GET_H_BBPSW() CPU (h_bbpsw) #define SET_H_BBPSW(x) (CPU (h_bbpsw) = (x)) /* lock */ BI h_lock; #define GET_H_LOCK() CPU (h_lock) #define SET_H_LOCK(x) (CPU (h_lock) = (x)) } hardware; #define CPU_CGEN_HW(cpu) (& (cpu)->cpu_data.hardware) } M32RXF_CPU_DATA; /* Cover fns for register access. */ USI m32rxf_h_pc_get (SIM_CPU *); void m32rxf_h_pc_set (SIM_CPU *, USI); SI m32rxf_h_gr_get (SIM_CPU *, UINT); void m32rxf_h_gr_set (SIM_CPU *, UINT, SI); USI m32rxf_h_cr_get (SIM_CPU *, UINT); void m32rxf_h_cr_set (SIM_CPU *, UINT, USI); DI m32rxf_h_accum_get (SIM_CPU *); void m32rxf_h_accum_set (SIM_CPU *, DI); DI m32rxf_h_accums_get (SIM_CPU *, UINT); void m32rxf_h_accums_set (SIM_CPU *, UINT, DI); BI m32rxf_h_cond_get (SIM_CPU *); void m32rxf_h_cond_set (SIM_CPU *, BI); UQI m32rxf_h_psw_get (SIM_CPU *); void m32rxf_h_psw_set (SIM_CPU *, UQI); UQI m32rxf_h_bpsw_get (SIM_CPU *); void m32rxf_h_bpsw_set (SIM_CPU *, UQI); UQI m32rxf_h_bbpsw_get (SIM_CPU *); void m32rxf_h_bbpsw_set (SIM_CPU *, UQI); BI m32rxf_h_lock_get (SIM_CPU *); void m32rxf_h_lock_set (SIM_CPU *, BI); /* These must be hand-written. */ extern CPUREG_FETCH_FN m32rxf_fetch_register; extern CPUREG_STORE_FN m32rxf_store_register; typedef struct { int empty; } MODEL_M32RX_DATA; /* Instruction argument buffer. */ union sem_fields { struct { /* no operands */ int empty; } sfmt_empty; struct { /* */ UINT f_uimm8; } sfmt_clrpsw; struct { /* */ UINT f_uimm4; } sfmt_trap; struct { /* */ IADDR i_disp24; unsigned char out_h_gr_SI_14; } sfmt_bl24; struct { /* */ IADDR i_disp8; unsigned char out_h_gr_SI_14; } sfmt_bl8; struct { /* */ SI f_imm1; UINT f_accd; UINT f_accs; } sfmt_rac_dsi; struct { /* */ SI* i_dr; UINT f_hi16; UINT f_r1; unsigned char out_dr; } sfmt_seth; struct { /* */ SI* i_src1; UINT f_accs; UINT f_r1; unsigned char in_src1; } sfmt_mvtachi_a; struct { /* */ SI* i_dr; UINT f_accs; UINT f_r1; unsigned char out_dr; } sfmt_mvfachi_a; struct { /* */ ADDR i_uimm24; SI* i_dr; UINT f_r1; unsigned char out_dr; } sfmt_ld24; struct { /* */ SI* i_sr; UINT f_r2; unsigned char in_sr; unsigned char out_h_gr_SI_14; } sfmt_jl; struct { /* */ SI* i_sr; INT f_simm16; UINT f_r2; UINT f_uimm3; unsigned char in_sr; } sfmt_bset; struct { /* */ SI* i_dr; UINT f_r1; UINT f_uimm5; unsigned char in_dr; unsigned char out_dr; } sfmt_slli; struct { /* */ SI* i_dr; INT f_simm8; UINT f_r1; unsigned char in_dr; unsigned char out_dr; } sfmt_addi; struct { /* */ SI* i_src1; SI* i_src2; UINT f_r1; UINT f_r2; unsigned char in_src1; unsigned char in_src2; unsigned char out_src2; } sfmt_st_plus; struct { /* */ SI* i_src1; SI* i_src2; INT f_simm16; UINT f_r1; UINT f_r2; unsigned char in_src1; unsigned char in_src2; } sfmt_st_d; struct { /* */ SI* i_src1; SI* i_src2; UINT f_acc; UINT f_r1; UINT f_r2; unsigned char in_src1; unsigned char in_src2; } sfmt_machi_a; struct { /* */ SI* i_dr; SI* i_sr; UINT f_r1; UINT f_r2; unsigned char in_sr; unsigned char out_dr; unsigned char out_sr; } sfmt_ld_plus; struct { /* */ IADDR i_disp16; SI* i_src1; SI* i_src2; UINT f_r1; UINT f_r2; unsigned char in_src1; unsigned char in_src2; } sfmt_beq; struct { /* */ SI* i_dr; SI* i_sr; UINT f_r1; UINT f_r2; UINT f_uimm16; unsigned char in_sr; unsigned char out_dr; } sfmt_and3; struct { /* */ SI* i_dr; SI* i_sr; INT f_simm16; UINT f_r1; UINT f_r2; unsigned char in_sr; unsigned char out_dr; } sfmt_add3; struct { /* */ SI* i_dr; SI* i_sr; UINT f_r1; UINT f_r2; unsigned char in_dr; unsigned char in_sr; unsigned char out_dr; } sfmt_add; #if WITH_SCACHE_PBB /* Writeback handler. */ struct { /* Pointer to argbuf entry for insn whose results need writing back. */ const struct argbuf *abuf; } write; /* x-before handler */ struct { /*const SCACHE *insns[MAX_PARALLEL_INSNS];*/ int first_p; } before; /* x-after handler */ struct { int empty; } after; /* This entry is used to terminate each pbb. */ struct { /* Number of insns in pbb. */ int insn_count; /* Next pbb to execute. */ SCACHE *next; SCACHE *branch_target; } chain; #endif }; /* The ARGBUF struct. */ struct argbuf { /* These are the baseclass definitions. */ IADDR addr; const IDESC *idesc; char trace_p; char profile_p; /* ??? Temporary hack for skip insns. */ char skip_count; char unused; /* cpu specific data follows */ union sem semantic; int written; union sem_fields fields; }; /* A cached insn. ??? SCACHE used to contain more than just argbuf. We could delete the type entirely and always just use ARGBUF, but for future concerns and as a level of abstraction it is left in. */ struct scache { struct argbuf argbuf; }; /* Macros to simplify extraction, reading and semantic code. These define and assign the local vars that contain the insn's fields. */ #define EXTRACT_IFMT_EMPTY_VARS \ unsigned int length; #define EXTRACT_IFMT_EMPTY_CODE \ length = 0; \ #define EXTRACT_IFMT_ADD_VARS \ UINT f_op1; \ UINT f_r1; \ UINT f_op2; \ UINT f_r2; \ unsigned int length; #define EXTRACT_IFMT_ADD_CODE \ length = 2; \ f_op1 = EXTRACT_MSB0_UINT (insn, 16, 0, 4); \ f_r1 = EXTRACT_MSB0_UINT (insn, 16, 4, 4); \ f_op2 = EXTRACT_MSB0_UINT (insn, 16, 8, 4); \ f_r2 = EXTRACT_MSB0_UINT (insn, 16, 12, 4); \ #define EXTRACT_IFMT_ADD3_VARS \ UINT f_op1; \ UINT f_r1; \ UINT f_op2; \ UINT f_r2; \ INT f_simm16; \ unsigned int length; #define EXTRACT_IFMT_ADD3_CODE \ length = 4; \ f_op1 = EXTRACT_MSB0_UINT (insn, 32, 0, 4); \ f_r1 = EXTRACT_MSB0_UINT (insn, 32, 4, 4); \ f_op2 = EXTRACT_MSB0_UINT (insn, 32, 8, 4); \ f_r2 = EXTRACT_MSB0_UINT (insn, 32, 12, 4); \ f_simm16 = EXTRACT_MSB0_SINT (insn, 32, 16, 16); \ #define EXTRACT_IFMT_AND3_VARS \ UINT f_op1; \ UINT f_r1; \ UINT f_op2; \ UINT f_r2; \ UINT f_uimm16; \ unsigned int length; #define EXTRACT_IFMT_AND3_CODE \ length = 4; \ f_op1 = EXTRACT_MSB0_UINT (insn, 32, 0, 4); \ f_r1 = EXTRACT_MSB0_UINT (insn, 32, 4, 4); \ f_op2 = EXTRACT_MSB0_UINT (insn, 32, 8, 4); \ f_r2 = EXTRACT_MSB0_UINT (insn, 32, 12, 4); \ f_uimm16 = EXTRACT_MSB0_UINT (insn, 32, 16, 16); \ #define EXTRACT_IFMT_OR3_VARS \ UINT f_op1; \ UINT f_r1; \ UINT f_op2; \ UINT f_r2; \ UINT f_uimm16; \ unsigned int length; #define EXTRACT_IFMT_OR3_CODE \ length = 4; \ f_op1 = EXTRACT_MSB0_UINT (insn, 32, 0, 4); \ f_r1 = EXTRACT_MSB0_UINT (insn, 32, 4, 4); \ f_op2 = EXTRACT_MSB0_UINT (insn, 32, 8, 4); \ f_r2 = EXTRACT_MSB0_UINT (insn, 32, 12, 4); \ f_uimm16 = EXTRACT_MSB0_UINT (insn, 32, 16, 16); \ #define EXTRACT_IFMT_ADDI_VARS \ UINT f_op1; \ UINT f_r1; \ INT f_simm8; \ unsigned int length; #define EXTRACT_IFMT_ADDI_CODE \ length = 2; \ f_op1 = EXTRACT_MSB0_UINT (insn, 16, 0, 4); \ f_r1 = EXTRACT_MSB0_UINT (insn, 16, 4, 4); \ f_simm8 = EXTRACT_MSB0_SINT (insn, 16, 8, 8); \ #define EXTRACT_IFMT_ADDV3_VARS \ UINT f_op1; \ UINT f_r1; \ UINT f_op2; \ UINT f_r2; \ INT f_simm16; \ unsigned int length; #define EXTRACT_IFMT_ADDV3_CODE \ length = 4; \ f_op1 = EXTRACT_MSB0_UINT (insn, 32, 0, 4); \ f_r1 = EXTRACT_MSB0_UINT (insn, 32, 4, 4); \ f_op2 = EXTRACT_MSB0_UINT (insn, 32, 8, 4); \ f_r2 = EXTRACT_MSB0_UINT (insn, 32, 12, 4); \ f_simm16 = EXTRACT_MSB0_SINT (insn, 32, 16, 16); \ #define EXTRACT_IFMT_BC8_VARS \ UINT f_op1; \ UINT f_r1; \ SI f_disp8; \ unsigned int length; #define EXTRACT_IFMT_BC8_CODE \ length = 2; \ f_op1 = EXTRACT_MSB0_UINT (insn, 16, 0, 4); \ f_r1 = EXTRACT_MSB0_UINT (insn, 16, 4, 4); \ f_disp8 = ((((EXTRACT_MSB0_SINT (insn, 16, 8, 8)) << (2))) + (((pc) & (-4)))); \ #define EXTRACT_IFMT_BC24_VARS \ UINT f_op1; \ UINT f_r1; \ SI f_disp24; \ unsigned int length; #define EXTRACT_IFMT_BC24_CODE \ length = 4; \ f_op1 = EXTRACT_MSB0_UINT (insn, 32, 0, 4); \ f_r1 = EXTRACT_MSB0_UINT (insn, 32, 4, 4); \ f_disp24 = ((((EXTRACT_MSB0_SINT (insn, 32, 8, 24)) << (2))) + (pc)); \ #define EXTRACT_IFMT_BEQ_VARS \ UINT f_op1; \ UINT f_r1; \ UINT f_op2; \ UINT f_r2; \ SI f_disp16; \ unsigned int length; #define EXTRACT_IFMT_BEQ_CODE \ length = 4; \ f_op1 = EXTRACT_MSB0_UINT (insn, 32, 0, 4); \ f_r1 = EXTRACT_MSB0_UINT (insn, 32, 4, 4); \ f_op2 = EXTRACT_MSB0_UINT (insn, 32, 8, 4); \ f_r2 = EXTRACT_MSB0_UINT (insn, 32, 12, 4); \ f_disp16 = ((((EXTRACT_MSB0_SINT (insn, 32, 16, 16)) << (2))) + (pc)); \ #define EXTRACT_IFMT_BEQZ_VARS \ UINT f_op1; \ UINT f_r1; \ UINT f_op2; \ UINT f_r2; \ SI f_disp16; \ unsigned int length; #define EXTRACT_IFMT_BEQZ_CODE \ length = 4; \ f_op1 = EXTRACT_MSB0_UINT (insn, 32, 0, 4); \ f_r1 = EXTRACT_MSB0_UINT (insn, 32, 4, 4); \ f_op2 = EXTRACT_MSB0_UINT (insn, 32, 8, 4); \ f_r2 = EXTRACT_MSB0_UINT (insn, 32, 12, 4); \ f_disp16 = ((((EXTRACT_MSB0_SINT (insn, 32, 16, 16)) << (2))) + (pc)); \ #define EXTRACT_IFMT_CMP_VARS \ UINT f_op1; \ UINT f_r1; \ UINT f_op2; \ UINT f_r2; \ unsigned int length; #define EXTRACT_IFMT_CMP_CODE \ length = 2; \ f_op1 = EXTRACT_MSB0_UINT (insn, 16, 0, 4); \ f_r1 = EXTRACT_MSB0_UINT (insn, 16, 4, 4); \ f_op2 = EXTRACT_MSB0_UINT (insn, 16, 8, 4); \ f_r2 = EXTRACT_MSB0_UINT (insn, 16, 12, 4); \ #define EXTRACT_IFMT_CMPI_VARS \ UINT f_op1; \ UINT f_r1; \ UINT f_op2; \ UINT f_r2; \ INT f_simm16; \ unsigned int length; #define EXTRACT_IFMT_CMPI_CODE \ length = 4; \ f_op1 = EXTRACT_MSB0_UINT (insn, 32, 0, 4); \ f_r1 = EXTRACT_MSB0_UINT (insn, 32, 4, 4); \ f_op2 = EXTRACT_MSB0_UINT (insn, 32, 8, 4); \ f_r2 = EXTRACT_MSB0_UINT (insn, 32, 12, 4); \ f_simm16 = EXTRACT_MSB0_SINT (insn, 32, 16, 16); \ #define EXTRACT_IFMT_CMPZ_VARS \ UINT f_op1; \ UINT f_r1; \ UINT f_op2; \ UINT f_r2; \ unsigned int length; #define EXTRACT_IFMT_CMPZ_CODE \ length = 2; \ f_op1 = EXTRACT_MSB0_UINT (insn, 16, 0, 4); \ f_r1 = EXTRACT_MSB0_UINT (insn, 16, 4, 4); \ f_op2 = EXTRACT_MSB0_UINT (insn, 16, 8, 4); \ f_r2 = EXTRACT_MSB0_UINT (insn, 16, 12, 4); \ #define EXTRACT_IFMT_DIV_VARS \ UINT f_op1; \ UINT f_r1; \ UINT f_op2; \ UINT f_r2; \ INT f_simm16; \ unsigned int length; #define EXTRACT_IFMT_DIV_CODE \ length = 4; \ f_op1 = EXTRACT_MSB0_UINT (insn, 32, 0, 4); \ f_r1 = EXTRACT_MSB0_UINT (insn, 32, 4, 4); \ f_op2 = EXTRACT_MSB0_UINT (insn, 32, 8, 4); \ f_r2 = EXTRACT_MSB0_UINT (insn, 32, 12, 4); \ f_simm16 = EXTRACT_MSB0_SINT (insn, 32, 16, 16); \ #define EXTRACT_IFMT_JC_VARS \ UINT f_op1; \ UINT f_r1; \ UINT f_op2; \ UINT f_r2; \ unsigned int length; #define EXTRACT_IFMT_JC_CODE \ length = 2; \ f_op1 = EXTRACT_MSB0_UINT (insn, 16, 0, 4); \ f_r1 = EXTRACT_MSB0_UINT (insn, 16, 4, 4); \ f_op2 = EXTRACT_MSB0_UINT (insn, 16, 8, 4); \ f_r2 = EXTRACT_MSB0_UINT (insn, 16, 12, 4); \ #define EXTRACT_IFMT_LD24_VARS \ UINT f_op1; \ UINT f_r1; \ UINT f_uimm24; \ unsigned int length; #define EXTRACT_IFMT_LD24_CODE \ length = 4; \ f_op1 = EXTRACT_MSB0_UINT (insn, 32, 0, 4); \ f_r1 = EXTRACT_MSB0_UINT (insn, 32, 4, 4); \ f_uimm24 = EXTRACT_MSB0_UINT (insn, 32, 8, 24); \ #define EXTRACT_IFMT_LDI16_VARS \ UINT f_op1; \ UINT f_r1; \ UINT f_op2; \ UINT f_r2; \ INT f_simm16; \ unsigned int length; #define EXTRACT_IFMT_LDI16_CODE \ length = 4; \ f_op1 = EXTRACT_MSB0_UINT (insn, 32, 0, 4); \ f_r1 = EXTRACT_MSB0_UINT (insn, 32, 4, 4); \ f_op2 = EXTRACT_MSB0_UINT (insn, 32, 8, 4); \ f_r2 = EXTRACT_MSB0_UINT (insn, 32, 12, 4); \ f_simm16 = EXTRACT_MSB0_SINT (insn, 32, 16, 16); \ #define EXTRACT_IFMT_MACHI_A_VARS \ UINT f_op1; \ UINT f_r1; \ UINT f_acc; \ UINT f_op23; \ UINT f_r2; \ unsigned int length; #define EXTRACT_IFMT_MACHI_A_CODE \ length = 2; \ f_op1 = EXTRACT_MSB0_UINT (insn, 16, 0, 4); \ f_r1 = EXTRACT_MSB0_UINT (insn, 16, 4, 4); \ f_acc = EXTRACT_MSB0_UINT (insn, 16, 8, 1); \ f_op23 = EXTRACT_MSB0_UINT (insn, 16, 9, 3); \ f_r2 = EXTRACT_MSB0_UINT (insn, 16, 12, 4); \ #define EXTRACT_IFMT_MVFACHI_A_VARS \ UINT f_op1; \ UINT f_r1; \ UINT f_op2; \ UINT f_accs; \ UINT f_op3; \ unsigned int length; #define EXTRACT_IFMT_MVFACHI_A_CODE \ length = 2; \ f_op1 = EXTRACT_MSB0_UINT (insn, 16, 0, 4); \ f_r1 = EXTRACT_MSB0_UINT (insn, 16, 4, 4); \ f_op2 = EXTRACT_MSB0_UINT (insn, 16, 8, 4); \ f_accs = EXTRACT_MSB0_UINT (insn, 16, 12, 2); \ f_op3 = EXTRACT_MSB0_UINT (insn, 16, 14, 2); \ #define EXTRACT_IFMT_MVFC_VARS \ UINT f_op1; \ UINT f_r1; \ UINT f_op2; \ UINT f_r2; \ unsigned int length; #define EXTRACT_IFMT_MVFC_CODE \ length = 2; \ f_op1 = EXTRACT_MSB0_UINT (insn, 16, 0, 4); \ f_r1 = EXTRACT_MSB0_UINT (insn, 16, 4, 4); \ f_op2 = EXTRACT_MSB0_UINT (insn, 16, 8, 4); \ f_r2 = EXTRACT_MSB0_UINT (insn, 16, 12, 4); \ #define EXTRACT_IFMT_MVTACHI_A_VARS \ UINT f_op1; \ UINT f_r1; \ UINT f_op2; \ UINT f_accs; \ UINT f_op3; \ unsigned int length; #define EXTRACT_IFMT_MVTACHI_A_CODE \ length = 2; \ f_op1 = EXTRACT_MSB0_UINT (insn, 16, 0, 4); \ f_r1 = EXTRACT_MSB0_UINT (insn, 16, 4, 4); \ f_op2 = EXTRACT_MSB0_UINT (insn, 16, 8, 4); \ f_accs = EXTRACT_MSB0_UINT (insn, 16, 12, 2); \ f_op3 = EXTRACT_MSB0_UINT (insn, 16, 14, 2); \ #define EXTRACT_IFMT_MVTC_VARS \ UINT f_op1; \ UINT f_r1; \ UINT f_op2; \ UINT f_r2; \ unsigned int length; #define EXTRACT_IFMT_MVTC_CODE \ length = 2; \ f_op1 = EXTRACT_MSB0_UINT (insn, 16, 0, 4); \ f_r1 = EXTRACT_MSB0_UINT (insn, 16, 4, 4); \ f_op2 = EXTRACT_MSB0_UINT (insn, 16, 8, 4); \ f_r2 = EXTRACT_MSB0_UINT (insn, 16, 12, 4); \ #define EXTRACT_IFMT_NOP_VARS \ UINT f_op1; \ UINT f_r1; \ UINT f_op2; \ UINT f_r2; \ unsigned int length; #define EXTRACT_IFMT_NOP_CODE \ length = 2; \ f_op1 = EXTRACT_MSB0_UINT (insn, 16, 0, 4); \ f_r1 = EXTRACT_MSB0_UINT (insn, 16, 4, 4); \ f_op2 = EXTRACT_MSB0_UINT (insn, 16, 8, 4); \ f_r2 = EXTRACT_MSB0_UINT (insn, 16, 12, 4); \ #define EXTRACT_IFMT_RAC_DSI_VARS \ UINT f_op1; \ UINT f_accd; \ UINT f_bits67; \ UINT f_op2; \ UINT f_accs; \ UINT f_bit14; \ SI f_imm1; \ unsigned int length; #define EXTRACT_IFMT_RAC_DSI_CODE \ length = 2; \ f_op1 = EXTRACT_MSB0_UINT (insn, 16, 0, 4); \ f_accd = EXTRACT_MSB0_UINT (insn, 16, 4, 2); \ f_bits67 = EXTRACT_MSB0_UINT (insn, 16, 6, 2); \ f_op2 = EXTRACT_MSB0_UINT (insn, 16, 8, 4); \ f_accs = EXTRACT_MSB0_UINT (insn, 16, 12, 2); \ f_bit14 = EXTRACT_MSB0_UINT (insn, 16, 14, 1); \ f_imm1 = ((EXTRACT_MSB0_UINT (insn, 16, 15, 1)) + (1)); \ #define EXTRACT_IFMT_SETH_VARS \ UINT f_op1; \ UINT f_r1; \ UINT f_op2; \ UINT f_r2; \ UINT f_hi16; \ unsigned int length; #define EXTRACT_IFMT_SETH_CODE \ length = 4; \ f_op1 = EXTRACT_MSB0_UINT (insn, 32, 0, 4); \ f_r1 = EXTRACT_MSB0_UINT (insn, 32, 4, 4); \ f_op2 = EXTRACT_MSB0_UINT (insn, 32, 8, 4); \ f_r2 = EXTRACT_MSB0_UINT (insn, 32, 12, 4); \ f_hi16 = EXTRACT_MSB0_UINT (insn, 32, 16, 16); \ #define EXTRACT_IFMT_SLLI_VARS \ UINT f_op1; \ UINT f_r1; \ UINT f_shift_op2; \ UINT f_uimm5; \ unsigned int length; #define EXTRACT_IFMT_SLLI_CODE \ length = 2; \ f_op1 = EXTRACT_MSB0_UINT (insn, 16, 0, 4); \ f_r1 = EXTRACT_MSB0_UINT (insn, 16, 4, 4); \ f_shift_op2 = EXTRACT_MSB0_UINT (insn, 16, 8, 3); \ f_uimm5 = EXTRACT_MSB0_UINT (insn, 16, 11, 5); \ #define EXTRACT_IFMT_ST_D_VARS \ UINT f_op1; \ UINT f_r1; \ UINT f_op2; \ UINT f_r2; \ INT f_simm16; \ unsigned int length; #define EXTRACT_IFMT_ST_D_CODE \ length = 4; \ f_op1 = EXTRACT_MSB0_UINT (insn, 32, 0, 4); \ f_r1 = EXTRACT_MSB0_UINT (insn, 32, 4, 4); \ f_op2 = EXTRACT_MSB0_UINT (insn, 32, 8, 4); \ f_r2 = EXTRACT_MSB0_UINT (insn, 32, 12, 4); \ f_simm16 = EXTRACT_MSB0_SINT (insn, 32, 16, 16); \ #define EXTRACT_IFMT_TRAP_VARS \ UINT f_op1; \ UINT f_r1; \ UINT f_op2; \ UINT f_uimm4; \ unsigned int length; #define EXTRACT_IFMT_TRAP_CODE \ length = 2; \ f_op1 = EXTRACT_MSB0_UINT (insn, 16, 0, 4); \ f_r1 = EXTRACT_MSB0_UINT (insn, 16, 4, 4); \ f_op2 = EXTRACT_MSB0_UINT (insn, 16, 8, 4); \ f_uimm4 = EXTRACT_MSB0_UINT (insn, 16, 12, 4); \ #define EXTRACT_IFMT_SATB_VARS \ UINT f_op1; \ UINT f_r1; \ UINT f_op2; \ UINT f_r2; \ UINT f_uimm16; \ unsigned int length; #define EXTRACT_IFMT_SATB_CODE \ length = 4; \ f_op1 = EXTRACT_MSB0_UINT (insn, 32, 0, 4); \ f_r1 = EXTRACT_MSB0_UINT (insn, 32, 4, 4); \ f_op2 = EXTRACT_MSB0_UINT (insn, 32, 8, 4); \ f_r2 = EXTRACT_MSB0_UINT (insn, 32, 12, 4); \ f_uimm16 = EXTRACT_MSB0_UINT (insn, 32, 16, 16); \ #define EXTRACT_IFMT_CLRPSW_VARS \ UINT f_op1; \ UINT f_r1; \ UINT f_uimm8; \ unsigned int length; #define EXTRACT_IFMT_CLRPSW_CODE \ length = 2; \ f_op1 = EXTRACT_MSB0_UINT (insn, 16, 0, 4); \ f_r1 = EXTRACT_MSB0_UINT (insn, 16, 4, 4); \ f_uimm8 = EXTRACT_MSB0_UINT (insn, 16, 8, 8); \ #define EXTRACT_IFMT_BSET_VARS \ UINT f_op1; \ UINT f_bit4; \ UINT f_uimm3; \ UINT f_op2; \ UINT f_r2; \ INT f_simm16; \ unsigned int length; #define EXTRACT_IFMT_BSET_CODE \ length = 4; \ f_op1 = EXTRACT_MSB0_UINT (insn, 32, 0, 4); \ f_bit4 = EXTRACT_MSB0_UINT (insn, 32, 4, 1); \ f_uimm3 = EXTRACT_MSB0_UINT (insn, 32, 5, 3); \ f_op2 = EXTRACT_MSB0_UINT (insn, 32, 8, 4); \ f_r2 = EXTRACT_MSB0_UINT (insn, 32, 12, 4); \ f_simm16 = EXTRACT_MSB0_SINT (insn, 32, 16, 16); \ #define EXTRACT_IFMT_BTST_VARS \ UINT f_op1; \ UINT f_bit4; \ UINT f_uimm3; \ UINT f_op2; \ UINT f_r2; \ unsigned int length; #define EXTRACT_IFMT_BTST_CODE \ length = 2; \ f_op1 = EXTRACT_MSB0_UINT (insn, 16, 0, 4); \ f_bit4 = EXTRACT_MSB0_UINT (insn, 16, 4, 1); \ f_uimm3 = EXTRACT_MSB0_UINT (insn, 16, 5, 3); \ f_op2 = EXTRACT_MSB0_UINT (insn, 16, 8, 4); \ f_r2 = EXTRACT_MSB0_UINT (insn, 16, 12, 4); \ /* Queued output values of an instruction. */ struct parexec { union { struct { /* empty sformat for unspecified field list */ int empty; } sfmt_empty; struct { /* e.g. add $dr,$sr */ SI dr; } sfmt_add; struct { /* e.g. add3 $dr,$sr,$hash$slo16 */ SI dr; } sfmt_add3; struct { /* e.g. and3 $dr,$sr,$uimm16 */ SI dr; } sfmt_and3; struct { /* e.g. or3 $dr,$sr,$hash$ulo16 */ SI dr; } sfmt_or3; struct { /* e.g. addi $dr,$simm8 */ SI dr; } sfmt_addi; struct { /* e.g. addv $dr,$sr */ BI condbit; SI dr; } sfmt_addv; struct { /* e.g. addv3 $dr,$sr,$simm16 */ BI condbit; SI dr; } sfmt_addv3; struct { /* e.g. addx $dr,$sr */ BI condbit; SI dr; } sfmt_addx; struct { /* e.g. bc.s $disp8 */ USI pc; } sfmt_bc8; struct { /* e.g. bc.l $disp24 */ USI pc; } sfmt_bc24; struct { /* e.g. beq $src1,$src2,$disp16 */ USI pc; } sfmt_beq; struct { /* e.g. beqz $src2,$disp16 */ USI pc; } sfmt_beqz; struct { /* e.g. bl.s $disp8 */ SI h_gr_SI_14; USI pc; } sfmt_bl8; struct { /* e.g. bl.l $disp24 */ SI h_gr_SI_14; USI pc; } sfmt_bl24; struct { /* e.g. bcl.s $disp8 */ SI h_gr_SI_14; USI pc; } sfmt_bcl8; struct { /* e.g. bcl.l $disp24 */ SI h_gr_SI_14; USI pc; } sfmt_bcl24; struct { /* e.g. bra.s $disp8 */ USI pc; } sfmt_bra8; struct { /* e.g. bra.l $disp24 */ USI pc; } sfmt_bra24; struct { /* e.g. cmp $src1,$src2 */ BI condbit; } sfmt_cmp; struct { /* e.g. cmpi $src2,$simm16 */ BI condbit; } sfmt_cmpi; struct { /* e.g. cmpz $src2 */ BI condbit; } sfmt_cmpz; struct { /* e.g. div $dr,$sr */ SI dr; } sfmt_div; struct { /* e.g. jc $sr */ USI pc; } sfmt_jc; struct { /* e.g. jl $sr */ SI h_gr_SI_14; USI pc; } sfmt_jl; struct { /* e.g. jmp $sr */ USI pc; } sfmt_jmp; struct { /* e.g. ld $dr,@$sr */ SI dr; } sfmt_ld; struct { /* e.g. ld $dr,@($slo16,$sr) */ SI dr; } sfmt_ld_d; struct { /* e.g. ldb $dr,@$sr */ SI dr; } sfmt_ldb; struct { /* e.g. ldb $dr,@($slo16,$sr) */ SI dr; } sfmt_ldb_d; struct { /* e.g. ldh $dr,@$sr */ SI dr; } sfmt_ldh; struct { /* e.g. ldh $dr,@($slo16,$sr) */ SI dr; } sfmt_ldh_d; struct { /* e.g. ld $dr,@$sr+ */ SI dr; SI sr; } sfmt_ld_plus; struct { /* e.g. ld24 $dr,$uimm24 */ SI dr; } sfmt_ld24; struct { /* e.g. ldi8 $dr,$simm8 */ SI dr; } sfmt_ldi8; struct { /* e.g. ldi16 $dr,$hash$slo16 */ SI dr; } sfmt_ldi16; struct { /* e.g. lock $dr,@$sr */ SI dr; BI h_lock_BI; } sfmt_lock; struct { /* e.g. machi $src1,$src2,$acc */ DI acc; } sfmt_machi_a; struct { /* e.g. mulhi $src1,$src2,$acc */ DI acc; } sfmt_mulhi_a; struct { /* e.g. mv $dr,$sr */ SI dr; } sfmt_mv; struct { /* e.g. mvfachi $dr,$accs */ SI dr; } sfmt_mvfachi_a; struct { /* e.g. mvfc $dr,$scr */ SI dr; } sfmt_mvfc; struct { /* e.g. mvtachi $src1,$accs */ DI accs; } sfmt_mvtachi_a; struct { /* e.g. mvtc $sr,$dcr */ USI dcr; } sfmt_mvtc; struct { /* e.g. nop */ int empty; } sfmt_nop; struct { /* e.g. rac $accd,$accs,$imm1 */ DI accd; } sfmt_rac_dsi; struct { /* e.g. rte */ UQI h_bpsw_UQI; USI h_cr_USI_6; UQI h_psw_UQI; USI pc; } sfmt_rte; struct { /* e.g. seth $dr,$hash$hi16 */ SI dr; } sfmt_seth; struct { /* e.g. sll3 $dr,$sr,$simm16 */ SI dr; } sfmt_sll3; struct { /* e.g. slli $dr,$uimm5 */ SI dr; } sfmt_slli; struct { /* e.g. st $src1,@$src2 */ SI h_memory_SI_src2; USI h_memory_SI_src2_idx; } sfmt_st; struct { /* e.g. st $src1,@($slo16,$src2) */ SI h_memory_SI_add__SI_src2_slo16; USI h_memory_SI_add__SI_src2_slo16_idx; } sfmt_st_d; struct { /* e.g. stb $src1,@$src2 */ QI h_memory_QI_src2; USI h_memory_QI_src2_idx; } sfmt_stb; struct { /* e.g. stb $src1,@($slo16,$src2) */ QI h_memory_QI_add__SI_src2_slo16; USI h_memory_QI_add__SI_src2_slo16_idx; } sfmt_stb_d; struct { /* e.g. sth $src1,@$src2 */ HI h_memory_HI_src2; USI h_memory_HI_src2_idx; } sfmt_sth; struct { /* e.g. sth $src1,@($slo16,$src2) */ HI h_memory_HI_add__SI_src2_slo16; USI h_memory_HI_add__SI_src2_slo16_idx; } sfmt_sth_d; struct { /* e.g. st $src1,@+$src2 */ SI h_memory_SI_new_src2; USI h_memory_SI_new_src2_idx; SI src2; } sfmt_st_plus; struct { /* e.g. sth $src1,@$src2+ */ HI h_memory_HI_new_src2; USI h_memory_HI_new_src2_idx; SI src2; } sfmt_sth_plus; struct { /* e.g. stb $src1,@$src2+ */ QI h_memory_QI_new_src2; USI h_memory_QI_new_src2_idx; SI src2; } sfmt_stb_plus; struct { /* e.g. trap $uimm4 */ UQI h_bbpsw_UQI; UQI h_bpsw_UQI; USI h_cr_USI_14; USI h_cr_USI_6; UQI h_psw_UQI; USI pc; } sfmt_trap; struct { /* e.g. unlock $src1,@$src2 */ BI h_lock_BI; SI h_memory_SI_src2; USI h_memory_SI_src2_idx; } sfmt_unlock; struct { /* e.g. satb $dr,$sr */ SI dr; } sfmt_satb; struct { /* e.g. sat $dr,$sr */ SI dr; } sfmt_sat; struct { /* e.g. sadd */ DI h_accums_DI_0; } sfmt_sadd; struct { /* e.g. macwu1 $src1,$src2 */ DI h_accums_DI_1; } sfmt_macwu1; struct { /* e.g. msblo $src1,$src2 */ DI accum; } sfmt_msblo; struct { /* e.g. mulwu1 $src1,$src2 */ DI h_accums_DI_1; } sfmt_mulwu1; struct { /* e.g. sc */ int empty; } sfmt_sc; struct { /* e.g. clrpsw $uimm8 */ USI h_cr_USI_0; } sfmt_clrpsw; struct { /* e.g. setpsw $uimm8 */ USI h_cr_USI_0; } sfmt_setpsw; struct { /* e.g. bset $uimm3,@($slo16,$sr) */ QI h_memory_QI_add__SI_sr_slo16; USI h_memory_QI_add__SI_sr_slo16_idx; } sfmt_bset; struct { /* e.g. btst $uimm3,$sr */ BI condbit; } sfmt_btst; } operands; /* For conditionally written operands, bitmask of which ones were. */ int written; }; /* Collection of various things for the trace handler to use. */ typedef struct trace_record { IADDR pc; /* FIXME:wip */ } TRACE_RECORD; #endif /* CPU_M32RXF_H */
26.236467
82
0.621132
534bff1f7913a74d64fca5eb40fe098abcbf64c6
330
c
C
src/addtest.c
pchemguy/MinGW-DLL-Example
422ec40ee3b995935094fc844cb77a07bf019458
[ "Unlicense" ]
29
2018-02-14T14:40:01.000Z
2022-03-13T10:30:04.000Z
src/addtest.c
pchemguy/MinGW-DLL-Example
422ec40ee3b995935094fc844cb77a07bf019458
[ "Unlicense" ]
1
2019-01-14T09:36:55.000Z
2019-01-14T16:56:40.000Z
src/addtest.c
pchemguy/MinGW-DLL-Example
422ec40ee3b995935094fc844cb77a07bf019458
[ "Unlicense" ]
5
2020-11-18T09:52:55.000Z
2022-02-05T18:16:32.000Z
/* addtest.c Demonstrates using the function and variables exported by our DLL. */ #include <stdlib.h> #include <stdio.h> #include <add.h> int main(int argc, char** argv) { /* Add foo and bar variables exported from the DLL */ printf("%d + %d = %d\n", foo, bar, Add(foo, bar)); return EXIT_SUCCESS; }
19.411765
70
0.624242
535b86cad0e03d07995b13ecb69ef9634075ac05
781
h
C
util/qtColorUtil.h
Kitware/qtextensions
0ff5b486f08435c8cdfbc9f05d2f104f63b16aed
[ "BSD-3-Clause" ]
19
2015-12-17T14:48:11.000Z
2021-11-26T13:43:40.000Z
util/qtColorUtil.h
Kitware/qtextensions
0ff5b486f08435c8cdfbc9f05d2f104f63b16aed
[ "BSD-3-Clause" ]
26
2015-11-16T21:34:23.000Z
2021-01-29T13:41:21.000Z
util/qtColorUtil.h
Kitware/qtextensions
0ff5b486f08435c8cdfbc9f05d2f104f63b16aed
[ "BSD-3-Clause" ]
13
2015-11-10T02:44:47.000Z
2020-11-16T06:07:21.000Z
// This file is part of qtExtensions, and is distributed under the // OSI-approved BSD 3-Clause License. See top-level LICENSE file or // https://github.com/Kitware/qtExtensions/blob/master/LICENSE for details. #ifndef __qtColorUtil_h #define __qtColorUtil_h #include <QColor> #include "../core/qtGlobal.h" namespace qtColorUtil { QTE_EXPORT qreal blend(qreal a, qreal b, qreal t); QTE_EXPORT qreal blend(qreal a, qreal b, qreal c, qreal d, qreal t); QTE_EXPORT QColor blend(const QColor& a, const QColor& b, qreal t, QColor::Spec s = QColor::Rgb); QTE_EXPORT QColor blend(const QColor& a, const QColor& b, const QColor& c, const QColor& d, qreal t, QColor::Spec s = QColor::Rgb); } #endif
32.541667
75
0.663252
536d2b0f9425d6014bd8e82a789ab1305f90d94f
228
h
C
Demo/TestImagesViewController.h
kolyvan/kxutils
6ecb73e0e55da02db67c40749480bb98d60239a1
[ "BSD-2-Clause" ]
5
2015-06-15T04:52:04.000Z
2019-07-24T09:54:12.000Z
Demo/TestImagesViewController.h
kolyvan/kxutils
6ecb73e0e55da02db67c40749480bb98d60239a1
[ "BSD-2-Clause" ]
null
null
null
Demo/TestImagesViewController.h
kolyvan/kxutils
6ecb73e0e55da02db67c40749480bb98d60239a1
[ "BSD-2-Clause" ]
4
2015-04-21T09:52:52.000Z
2021-04-18T14:57:42.000Z
// // TestImagesViewController.h // kxutils // // Created by Kolyvan on 01.12.14. // Copyright (c) 2014 Kolyvan. All rights reserved. // #import <UIKit/UIKit.h> @interface TestImagesViewController : UIViewController @end
16.285714
54
0.714912
e9fc6e54776a83dc667c4308d56eda5b109260de
11,683
c
C
gss-sample/oid-func.c
twosigma/gsskrb5
1a8f4a98fa996daf7a2b39be52ba60d3a9218a04
[ "FSFAP" ]
2
2019-03-09T21:58:40.000Z
2020-08-07T18:37:03.000Z
gss-sample/oid-func.c
twosigma/gsskrb5
1a8f4a98fa996daf7a2b39be52ba60d3a9218a04
[ "FSFAP" ]
null
null
null
gss-sample/oid-func.c
twosigma/gsskrb5
1a8f4a98fa996daf7a2b39be52ba60d3a9218a04
[ "FSFAP" ]
null
null
null
/************************************************************************ * $Id: //tools/src/freeware/gsskrb5/gss-sample/oid-func.c#3 $ ************************************************************************ * * Copyright (c) 1997-2000 SAP AG. 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. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by SAP AG" * * 4. The name "SAP AG" must not be used to endorse or promote products * derived from this software without prior written permission. * For written permission, please contact www.press@sap.com * * 5. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by SAP AG" * * THIS SOFTWARE IS PROVIDED BY SAP AG ``AS IS'' AND ANY EXPRESSED * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. SAP AG SHALL BE LIABLE FOR ANY DAMAGES * ARISING OUT OF THE USE OF THIS SOFTWARE ONLY IF CAUSED BY SAP AG'S * INTENT OR GROSS NEGLIGENCE. IN CASE SAP AG IS LIABLE UNDER THIS * AGREEMENT FOR DAMAGES CAUSED BY SAP AG'S GROSS NEGLIGENCE SAP AG * FURTHER SHALL NOT BE LIABLE FOR ANY 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, AND SHALL NOT BE LIABLE IN EXCESS OF THE AMOUNT OF * DAMAGES TYPICALLY FORESEEABLE FOR SAP AG, WHICH SHALL IN NO EVENT * EXCEED US$ 500.000.- * ************************************************************************/ #include "gss-misc.h" typedef unsigned char Uchar; typedef unsigned int Uint; typedef unsigned long Ulong; #ifndef TRUE # define TRUE 1 #endif #ifndef FALSE # define FALSE 0 #endif /* * xigss_alloc_buffer() * * * */ static OM_uint32 xigss_alloc_buffer( OM_uint32 * pp_min_stat, gss_buffer_t p_buffer, void * p_source, size_t p_source_len, int p_add_nul ) { void * ptr; size_t dst_len; (*pp_min_stat) = 0; p_buffer->length = 0; p_buffer->value = NULL; if (p_source_len==0) return(GSS_S_COMPLETE); dst_len = p_source_len + ((p_add_nul==FALSE) ? 0 : 1); if ( dst_len==0 ) { return(GSS_S_COMPLETE); } ptr = malloc( dst_len ); if ( ptr==NULL ) { return(GSS_S_FAILURE); } if ( p_source!=NULL && p_source_len>0 ) { memcpy( ptr, p_source, p_source_len ); } p_buffer->value = ptr; p_buffer->length = p_source_len; if ( p_add_nul ) { ((unsigned char *)ptr)[dst_len-1] = '\0'; } return(GSS_S_COMPLETE); } /* xigss_alloc_buffer() */ /* * xgss_release_buffer() * * Needed to release the output of xgss_oid_to_str() * */ OM_uint32 xgss_release_buffer( OM_uint32 * pp_min_stat, gss_buffer_t p_buffer ) { (*pp_min_stat) = 0; if ( p_buffer == GSS_C_NO_BUFFER ) { return(GSS_S_COMPLETE); } if ( p_buffer->value==NULL && p_buffer->length==0 ) { return(GSS_S_COMPLETE); } if ( p_buffer->length!=0 && p_buffer->value!=NULL ) { memset( p_buffer->value, 0, p_buffer->length); free( p_buffer->value ); p_buffer->value = NULL; p_buffer->length = (size_t)0; return(GSS_S_COMPLETE); } return(GSS_S_CALL_BAD_STRUCTURE|GSS_S_FAILURE); } /* xgss_release_buffer() */ /* * xgss_oid_to_str() * * Status: This function is *NOT* part of GSS-API v2 !! * * LIMITS: For simplicity this function works on a * preallocated output buffer that will limit * the size of an OID which can be string-i-fied. * */ #define OID_STRING_BUFFER_MAX 1024 OM_uint32 xgss_oid_to_str( OM_uint32 * pp_min_stat, /* minor_status */ gss_OID p_oid, /* oid */ gss_buffer_t p_buffer /* oid_str */ ) { char oidbuf[OID_STRING_BUFFER_MAX]; char numbuf[64]; Ulong num = 0; OM_uint32 maj_stat; int more; Uint i, curlen, len, maxch; Uchar * bytes; Uchar uch; (*pp_min_stat) = 0; maxch = (sizeof(oidbuf)/sizeof(oidbuf[0])) - 4; memset(oidbuf, 0, sizeof(oidbuf)); if ( p_buffer==NULL ) { (*pp_min_stat) = 0; return(GSS_S_CALL_INACCESSIBLE_WRITE|GSS_S_FAILURE); } p_buffer->length = 0; p_buffer->value = NULL; if ( p_oid==NULL || p_oid->length==0 || p_oid->elements==NULL ) { (*pp_min_stat) = 0; return(GSS_S_CALL_BAD_STRUCTURE|GSS_S_FAILURE); } /* In an OID, the first two elements are encoded into the first byte */ /* split up the first byte here */ bytes = ((unsigned char *)p_oid->elements); uch = bytes[0]; sprintf(oidbuf, "{%u %u", (unsigned int)(uch/40), (unsigned int)(uch%40)); curlen = strlen(oidbuf); more = FALSE; for( i=1 ; i<p_oid->length ; i++ ) { uch = bytes[i]; num = (uch & 0x7f) + ( (more) ? (num<<7) : 0 ); more = ( (uch>127) ? TRUE : FALSE ); if (more==FALSE) { sprintf(numbuf," %lu", (unsigned long)num); len = strlen(numbuf); if ( len + 1 + curlen > maxch ) { (*pp_min_stat) = 0; return(GSS_S_FAILURE); } memcpy( &(oidbuf[curlen]), numbuf, (size_t)(len+1) ); curlen += len; } } if (more) { (*pp_min_stat) = 0; return(GSS_S_CALL_BAD_STRUCTURE|GSS_S_FAILURE); } oidbuf[curlen++] = '}'; oidbuf[curlen] = '\0'; /* The above trailing Zero is just for debugging, we don't count it */ /* gss_buffer_t should not include a trailing zero! */ /* For safety, we always include a trailing zero, but do not count it */ maj_stat = xigss_alloc_buffer( pp_min_stat, p_buffer, (void *)oidbuf, (size_t)curlen, TRUE ); return(maj_stat); } /* xgss_oid_to_str() */ /* * xigss_copy_oid() * * create a dynamically allocated copy of an OID * */ static OM_uint32 xigss_copy_oid( OM_uint32 * pp_min_stat, gss_OID p_src_oid, gss_OID * pp_dst_oid ) { gss_OID oid = NULL; /* dynamic, free on error */ void * elements = NULL; /* dynamic, free on error */ size_t length = 0; OM_uint32 maj_stat = GSS_S_COMPLETE; (*pp_min_stat) = 0; if ( pp_dst_oid==NULL ) return(GSS_S_FAILURE); (*pp_dst_oid) = GSS_C_NO_OID; /* cloning a non-OID is simple :-) */ if ( p_src_oid==GSS_C_NO_OID ) return(GSS_S_COMPLETE); if ( p_src_oid->elements==NULL || p_src_oid->length==0 ) return(GSS_S_FAILURE|GSS_S_CALL_BAD_STRUCTURE); /* cleanup alert: the next call creates a dynamic object */ oid = malloc(sizeof(gss_OID_desc)); if ( oid==NULL ) return(GSS_S_FAILURE); length = p_src_oid->length; elements = malloc(length); if ( elements==NULL ) { maj_stat = GSS_S_FAILURE; goto error; } memcpy( elements, p_src_oid->elements, length ); oid->elements = elements; oid->length = length; if ( maj_stat!=GSS_S_COMPLETE ) { error: if ( elements!=NULL ) { free(elements); elements = NULL; } if ( oid !=NULL ) { free(oid); oid = NULL; } } (*pp_dst_oid) = oid; return(maj_stat); } /* xigss_copy_oid() */ /* * xgss_str_to_oid() * * * */ OM_uint32 xgss_str_to_oid( OM_uint32 * pp_min_stat, /* minor_status */ gss_buffer_t p_in_oid_string, /* oid_string */ gss_OID * pp_out_oid /* oid */ ) { gss_OID_desc oid; OM_uint32 maj_stat; Uchar elements[256]; Uchar tmpbuf[4]; char * ptr; int opening_brace; int closing_brace; int within_number; int add_number; Ulong uvalue; Uint len; Uint i,j; size_t pos; Uchar uc; (*pp_min_stat) = 0; maj_stat = GSS_S_COMPLETE; (*pp_out_oid) = GSS_C_NO_OID; ptr = (char *) p_in_oid_string->value; opening_brace = closing_brace = 0; within_number = add_number = 0; len = 0; for ( pos=0 ; pos<p_in_oid_string->length ; pos++ ) { uc = ptr[pos]; if ( uc=='{' ) { within_number = 0; opening_brace = 1; } else if ( opening_brace && uc=='}' ) { within_number = 0; closing_brace = 1; add_number = 1; } else if ( opening_brace && isascii( uc ) && isdigit( uc ) ) { if ( within_number ) { uvalue *= 10; } else { uvalue = 0; } uvalue += ( uc - ((Uchar)'0') ); within_number = 1; } else { if ( !isascii(uc) || !isspace(uc) ) { /* invalid character encountered */ return(GSS_S_FAILURE); } if ( within_number ) { within_number = 0; add_number = 1; } } if ( add_number ) { add_number = 0; i = 0; do { tmpbuf[i++] = (Uchar)(uvalue & 0x7f); uvalue = uvalue / 128; } while ( uvalue > 0 ); for ( j=0 ; j<i ; j++ ) { uc = tmpbuf[i-j-1]; if ( j+1<i ) { uc |= 0x80; } elements[len++] = uc; } } if ( closing_brace ) { break; } } if ( opening_brace==0 || closing_brace==0 || within_number==1 ) { return(GSS_S_FAILURE); } if ( len<2 ) { /* *I* claim that this is not a valid OID */ (*pp_min_stat) = 0; return(GSS_S_FAILURE); } /* compress the first two values of the OID into the first byte */ elements[1] = elements[0] * 40 + elements[1]; oid.elements = &(elements[1]); oid.length = len-1; /* now make a dynamically allocated copy of this OID */ maj_stat = xigss_copy_oid( pp_min_stat, &oid, pp_out_oid ); return(maj_stat); } /* xgss_str_to_oid() */ /* * xgss_release_oid() * * */ OM_uint32 xgss_release_oid( OM_uint32 * pp_min_stat, gss_OID * pp_in_oid ) { (*pp_min_stat) = 0; if ( (*pp_in_oid) == GSS_C_NO_OID ) { return(GSS_S_COMPLETE); } /* We try to free() the components, as they should have */ /* dynamically created by xgss_str_to_oid() ... */ if ( (*pp_in_oid)->elements!=NULL ) { if ( (*pp_in_oid)->length>0 ) { memset( (*pp_in_oid)->elements, 0, (*pp_in_oid)->length ); } (*pp_in_oid)->elements = NULL; (*pp_in_oid)->length = 0; } free( (*pp_in_oid) ); (*pp_in_oid) = GSS_C_NO_OID; return(GSS_S_COMPLETE); } /* xgss_release_oid() */
24.963675
78
0.567577
1745d98c6b167435bee30f9f368b51706948f560
1,065
h
C
src/main.h
tasoskakour/sonar-vehicle
b9ef615dec039137d176c0f00ed6206d5386ce0c
[ "MIT" ]
null
null
null
src/main.h
tasoskakour/sonar-vehicle
b9ef615dec039137d176c0f00ed6206d5386ce0c
[ "MIT" ]
null
null
null
src/main.h
tasoskakour/sonar-vehicle
b9ef615dec039137d176c0f00ed6206d5386ce0c
[ "MIT" ]
null
null
null
#ifndef MAIN_H #define MAIN_H #ifndef F_CPU #warning "F_CPU undefined, set to 16MHz" #define F_CPU 16000000UL #endif #include <inttypes.h> /* Sonar Ports Definitions */ #define TRIGGER_ddr DDRB #define TRIGGER_port PORTB #define TRIGGER_bit PORTB4 #define ECHO_ddr DDRB #define ECHO_pin PINB #define ECHO_bit PINB5 #define LEFT_distance 0 #define RIGHT_distance 1 #define FORWARD_DISTANCE_COLLISION 30 /* Vehicle Speed Definitions */ #define STARTING_SPEED 90 #define STARTING_SPEEDindex 7 // according to starting speed #define SPEEDS_NUM 9 // how many speeds available volatile uint8_t speedTable[SPEEDS_NUM] = {25, 35, 45, 55, 65, 75, 85, 90, 95}; /* Main Sub routines declarations */ void sonar_init(void); double sonarDistanceDetected(void); void avoidCollision(void); double lookRightLeft(uint8_t direction); void vehicleExplorate(void); void moveForward(void); void moveBackward(void); void turnRight(void); void turnLeft(void); void setSpeed(uint8_t speedSelect); void vehicleStop(void); #endif
23.666667
80
0.747418
8d8334d25f9de4215d2323bfa1a20a4c39d9a639
2,351
h
C
lib/monkey/mk_core/deps/libevent/include/event2/rpc_compat.h
carrotop/fluent-bit
7083a0edf480f09424f25c8e634e4996bf1e101b
[ "Apache-2.0" ]
4,071
2018-12-13T04:17:38.000Z
2022-03-30T03:29:35.000Z
blaze/serving/thirdparty/libevent/include/event2/rpc_compat.h
laozhuang727/x-deeplearning
781545783a4e2bbbda48fc64318fb2c6d8bbb3cc
[ "Apache-2.0" ]
4,247
2015-05-20T15:59:38.000Z
2022-03-31T23:19:12.000Z
blaze/serving/thirdparty/libevent/include/event2/rpc_compat.h
laozhuang727/x-deeplearning
781545783a4e2bbbda48fc64318fb2c6d8bbb3cc
[ "Apache-2.0" ]
1,176
2015-05-20T08:31:11.000Z
2022-03-31T22:40:08.000Z
/* * Copyright (c) 2006-2007 Niels Provos <provos@citi.umich.edu> * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson * * 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. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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 EVENT2_RPC_COMPAT_H_INCLUDED_ #define EVENT2_RPC_COMPAT_H_INCLUDED_ /** @file event2/rpc_compat.h Deprecated versions of the functions in rpc.h: provided only for backwards compatibility. */ #ifdef __cplusplus extern "C" { #endif /** backwards compatible accessors that work only with gcc */ #if defined(__GNUC__) && !defined(__STRICT_ANSI__) #undef EVTAG_ASSIGN #undef EVTAG_GET #undef EVTAG_ADD #define EVTAG_ASSIGN(msg, member, args...) \ (*(msg)->base->member##_assign)(msg, ## args) #define EVTAG_GET(msg, member, args...) \ (*(msg)->base->member##_get)(msg, ## args) #define EVTAG_ADD(msg, member, args...) \ (*(msg)->base->member##_add)(msg, ## args) #endif #define EVTAG_LEN(msg, member) ((msg)->member##_length) #ifdef __cplusplus } #endif #endif /* EVENT2_EVENT_COMPAT_H_INCLUDED_ */
37.919355
76
0.749468
ae5fe7a4f820da1a827e582601e3d296c183d12f
488
h
C
bin/acquirers/gps.h
Acidburn0zzz/peridot
9a3b1fb8e834d0315092478d83d0176ef28cb765
[ "BSD-3-Clause" ]
1
2018-02-05T23:33:32.000Z
2018-02-05T23:33:32.000Z
bin/acquirers/gps.h
Acidburn0zzz/peridot
9a3b1fb8e834d0315092478d83d0176ef28cb765
[ "BSD-3-Clause" ]
null
null
null
bin/acquirers/gps.h
Acidburn0zzz/peridot
9a3b1fb8e834d0315092478d83d0176ef28cb765
[ "BSD-3-Clause" ]
null
null
null
// Copyright 2016 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef PERIDOT_BIN_ACQUIRERS_GPS_H_ #define PERIDOT_BIN_ACQUIRERS_GPS_H_ namespace maxwell { namespace acquirers { class GpsAcquirer { public: virtual ~GpsAcquirer() {} static constexpr char kLabel[] = "/location/gps"; }; } // namespace acquirers } // namespace maxwell #endif // PERIDOT_BIN_ACQUIRERS_GPS_H_
22.181818
73
0.756148
3ec6b605b7c0878062f1e45af349f7af08474528
3,481
h
C
api/nblib/kerneloptions.h
hejamu/gromacs
4f4b9e4b197ae78456faada74c9f4cab7d128de6
[ "BSD-2-Clause" ]
384
2015-01-02T19:44:15.000Z
2022-03-27T15:13:15.000Z
api/nblib/kerneloptions.h
hejamu/gromacs
4f4b9e4b197ae78456faada74c9f4cab7d128de6
[ "BSD-2-Clause" ]
9
2015-04-07T20:48:00.000Z
2022-01-24T21:29:26.000Z
api/nblib/kerneloptions.h
hejamu/gromacs
4f4b9e4b197ae78456faada74c9f4cab7d128de6
[ "BSD-2-Clause" ]
258
2015-01-19T11:19:57.000Z
2022-03-18T08:59:52.000Z
/* * This file is part of the GROMACS molecular simulation package. * * Copyright (c) 2020,2021, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. * * GROMACS 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. * * GROMACS 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 GROMACS; if not, see * http://www.gnu.org/licenses, or write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * If you want to redistribute modifications to GROMACS, please * consider that scientific software is very special. Version * control is crucial - bugs must be traceable. We will be happy to * consider code for inclusion in the official distribution, but * derived work must not be called official GROMACS. Details are found * in the README & COPYING files - if they are missing, get the * official version at http://www.gromacs.org. * * To help us fund GROMACS development, we humbly ask that you cite * the research papers on the package. Check out http://www.gromacs.org. */ /*! \inpublicapi \file * \brief * Implements nblib kernel setup options * * \author Berk Hess <hess@kth.se> * \author Victor Holanda <victor.holanda@cscs.ch> * \author Joe Jordan <ejjordan@kth.se> * \author Prashanth Kanduri <kanduri@cscs.ch> * \author Sebastian Keller <keller@cscs.ch> */ #ifndef NBLIB_KERNELOPTIONS_H #define NBLIB_KERNELOPTIONS_H #include <memory> #include "nblib/basicdefinitions.h" namespace nblib { //! Enum for selecting the SIMD kernel type enum class SimdKernels : int { SimdAuto, SimdNo, Simd4XM, Simd2XMM, Count }; //! Enum for selecting the combination rule enum class CombinationRule : int { Geometric, LorentzBerthelot, None, Count }; //! Enum for selecting coulomb type enum class CoulombType : int { Pme, Cutoff, ReactionField, Count }; /*! \internal \brief * The options for the nonbonded kernel caller */ struct NBKernelOptions final { //! Whether to use a GPU, currently GPUs are not supported bool useGpu = false; //! The number of OpenMP threads to use int numOpenMPThreads = 1; //! The SIMD type for the kernel SimdKernels nbnxmSimd = SimdKernels::SimdAuto; //! The LJ combination rule CombinationRule ljCombinationRule = CombinationRule::Geometric; //! The pairlist and interaction cut-off real pairlistCutoff = 1.0; //! The Coulomb interaction function CoulombType coulombType = CoulombType::Pme; //! Whether to use tabulated PME grid correction instead of analytical, not applicable with simd=no bool useTabulatedEwaldCorr = false; //! The number of iterations for each kernel int numIterations = 100; //! The time step real timestep = 0.001; }; } // namespace nblib #endif // NBLIB_KERNELOPTIONS_H
31.36036
103
0.723068
48c398f9971c244617af13bf757bfafc47a7258c
918
h
C
header/layer-data.h
Cvilian/NetFI
023d1eecf3d89a0eeabc0ea8e7c1ca521281370e
[ "BSD-3-Clause" ]
2
2020-11-28T09:10:47.000Z
2021-01-14T11:26:27.000Z
header/layer-data.h
cvlian/NetFI
023d1eecf3d89a0eeabc0ea8e7c1ca521281370e
[ "BSD-3-Clause" ]
null
null
null
header/layer-data.h
cvlian/NetFI
023d1eecf3d89a0eeabc0ea8e7c1ca521281370e
[ "BSD-3-Clause" ]
1
2020-11-28T18:17:54.000Z
2020-11-28T18:17:54.000Z
/* layer-data.h * * routines for the data packet parsing * * NetFI - a fast and simple tool to analyze the network flow */ #ifndef PUMP_LAYER_DATA #define PUMP_LAYER_DATA #include "layer.h" namespace pump { class DataLayer : public Layer { public: DataLayer(uint8_t* data, size_t datalen, Layer* prev_layer) : Layer(data, datalen, prev_layer) { l_proto = PROTO_DATA; } virtual ~DataLayer() {}; void dissectData() {} size_t getHeaderLen() const { return l_datalen; } }; class TrailerLayer : public Layer { public: TrailerLayer(uint8_t* data, size_t datalen, Layer* prev_layer) : Layer(data, datalen, prev_layer) { l_proto = PROTO_TRAILER; } virtual ~TrailerLayer() {}; void dissectData() {} size_t getHeaderLen() const { return l_datalen; } }; } #endif
19.125
138
0.603486
5b57055944bc56f515b605c21f9b8a322c480bbe
2,354
c
C
lang/c/stdlib/implement/math.h/math.c
liuyang1/test
a4560e0c9ffd0bc054d55bbcf12a894ab5b7d417
[ "MIT" ]
8
2015-06-07T13:25:48.000Z
2022-03-22T23:14:50.000Z
lang/c/stdlib/implement/math.h/math.c
liuyang1/test
a4560e0c9ffd0bc054d55bbcf12a894ab5b7d417
[ "MIT" ]
30
2016-01-29T01:36:41.000Z
2018-09-19T07:01:22.000Z
lang/c/stdlib/implement/math.h/math.c
liuyang1/test
a4560e0c9ffd0bc054d55bbcf12a894ab5b7d417
[ "MIT" ]
null
null
null
#include <stdio.h> #include <stdbool.h> #include <math.h> // base function double fabs(double x) { return x > 0 ? x : -x; } int sign(double x) { return (x > 0) - (x < 0); } double square(double x) { return x * x; } double cubic(double x) { return x * x * x; } // function in math.h const double pi = 3.1415926; double sin_p(double x) { if (fabs(x) < 0.0001) { return x; } double sx = sin_p(x / 3); return 3 * sx - 4 * cubic(sx); } double cos_p(double x) { return sin_p(pi / 2 - x); } void sincos_p(double x, double *psin, double *pcos) { *psin = sin_p(x); *pcos = cos_p(x); } double tan_p(double x) { return sin_p(x) / cos_p(x); } // TODO: // acos // asin // atan double ceil_p(double x) { return 0; } double floor_p(double x) { return 0; } double trunc(double x) { return 0; } double fmod_p(double x, double y) { return 0; } /** extract signed integeral and factional values from floating-point number */ double modf_p(double x, double *iptr) { return 0; } double copysign_p(double x, double y) { return fabs(x) * sign(y); } /** convert floating-number to fractional and integral components */ double frexp_p(double x, int *exp) { return 0; } double sqrt_p(double x) { return 0; } /** Euclidean distance function */ double hypot(double x, double y) { return sqrt_p(square(x) + square(y)); } const double e = 2.7182818; double exp_p(double x) { return 0; } double log_p(double x) { return 0; } double pow_p(double x) { return 0; } // test code bool unit_func(double (*f)(double), double (*std)(double), const char *funcname, double x) { double r = f(x); double e = std(x); double d = r - e; bool ret = fabs(d) < 0.0001; if (!ret) { printf("%s_p(%f) = %f %s(%f) = %f, diff=%f\n", funcname, x, r, funcname, x, e, d); } return ret; } bool unit_func_group(double x) { return unit_func(sin_p, sin, "sin", x) && unit_func(cos_p, cos, "cos", x) && unit_func(tan_p, tan, "tan", x); } int test_func() { unit_func_group(0.0001); unit_func_group(pi + 1); unit_func_group(2 * pi + 1); unit_func_group(-pi + 1); unit_func_group(-2 * pi + 1); unit_func_group(12.15); return 0; } int main() { test_func(); return 0; }
16.347222
90
0.581988
3e4a5487d227749de131fffe5ac8d0c862f676ad
2,694
c
C
WEEKS/CD_Sata-Structures/_RESOURCES/course-work/algos-wiki/The-C-Programming-Language/src/intro-project/double_pointer_lesson.c
webdevhub42/Lambda
b04b84fb5b82fe7c8b12680149e25ae0d27a0960
[ "MIT" ]
null
null
null
WEEKS/CD_Sata-Structures/_RESOURCES/course-work/algos-wiki/The-C-Programming-Language/src/intro-project/double_pointer_lesson.c
webdevhub42/Lambda
b04b84fb5b82fe7c8b12680149e25ae0d27a0960
[ "MIT" ]
null
null
null
WEEKS/CD_Sata-Structures/_RESOURCES/course-work/algos-wiki/The-C-Programming-Language/src/intro-project/double_pointer_lesson.c
webdevhub42/Lambda
b04b84fb5b82fe7c8b12680149e25ae0d27a0960
[ "MIT" ]
null
null
null
#include <stdio.h> #include <stdlib.h> #include <math.h> int main(int argc, char** argv) { int a = 5; printf("Process memory address of a: %p\n", &a); int* ap = &a; printf("Process memory address of ap: %p\n", ap); int* b; printf("Process memory address of b: %p\n", b); // these are the same: puts is put string // printf is print formatted puts("b has not been allocated yet"); printf("%s", "b has not been allocated yet\n"); //int* c = a; //printf("What in the binary value of a: %p",(void*)a); b = malloc(sizeof(int)); puts("b just got allocated"); printf("Process memory address of b: %p\n", b); *b = 6; printf("Value of b: %d\n", *b); free(b); int** d; //(cp->cp->c); //**c = 7; //printf("c: %d", **c); char e = 'e'; char f = 95; // javascript way of doing it dynamically: //let radical = {}; //let less_radical = []; //less_radical.push(5); int array[50]; int i; for (i = 0 ; i < 50 ; ++i ) { array[i] = i*i; } int ii; for (ii = 0 ; ii < 50 ; ii++ ) { printf("%d\n", array[ii]); } // pre-allocated array - not as useful int twoDArrayOldStyle[1000][1000]; for (i = 0 ; i < 1000; ++i ) { for (ii = 0 ; ii < 1000; ii++ ) { twoDArrayOldStyle[i][ii] = 1; } } puts("Too big?"); //int twoDArrayHuge[1000000][1000000]; // How much RAM you got? // dynamically allocated array int m = 100000; int n = 100000; int diameter = 5; // twoDArray is a memory address of an array of memory addresses int** twoDArray; // Allocate rows twoDArray = malloc(m * sizeof(int*)); // Allocate columns per row for (i = 0 ; i < m ; ++i ) { twoDArray[i] = malloc(n * sizeof(int)); } puts("Can I assign memory into my 2d array?"); for (i = 0 ; i < m; ++i ) { for (ii = 0 ; ii < n; ii++ ) { if ( sqrt(abs(i-m/2)*abs(ii-n/2)) < diameter && sqrt(abs(i-m/2)*abs(ii-n/2) > diameter-1 ) ) { twoDArray[i][ii] = 1; } else { twoDArray[i][ii] = 0; } } } /* for(i = 0 ; i < m ; ++i ) { for(ii = 0 ; ii < n; ii++ ) { printf("%d", twoDArray[i][ii]); } printf("\n"); } */ char x = getc(stdin); for (i = 0 ; i < m ; ++i ) { // The `free` function releases memory that has been allocated via `malloc` // // This lets the OS know that this block of memory is available to now be // reallocated // // Every time memory is allocated with `malloc`, it needs to be released // with a call to `free` // // Otherwise, you'll get memory leaks, meaning you'll slowly get all the // memory on your machine eaten up free(twoDArray[i]); } free(twoDArray); }
21.902439
100
0.543059
b2038bc954987caa05af21517514a18aba3663d2
18,249
h
C
src/lib/alglib/include/mlpbase.h
janailton/IGEst-Estatistica-Source-Code
e3fa9052962b8d744841ce617b2318320d1f75bd
[ "Naumen", "Condor-1.1", "MS-PL" ]
null
null
null
src/lib/alglib/include/mlpbase.h
janailton/IGEst-Estatistica-Source-Code
e3fa9052962b8d744841ce617b2318320d1f75bd
[ "Naumen", "Condor-1.1", "MS-PL" ]
null
null
null
src/lib/alglib/include/mlpbase.h
janailton/IGEst-Estatistica-Source-Code
e3fa9052962b8d744841ce617b2318320d1f75bd
[ "Naumen", "Condor-1.1", "MS-PL" ]
null
null
null
/************************************************************************* Copyright (c) 2007-2008, Sergey Bochkanov (ALGLIB project). >>> SOURCE LICENSE >>> 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 (www.fsf.org); 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. A copy of the GNU General Public License is available at http://www.fsf.org/licensing/licenses >>> END OF LICENSE >>> *************************************************************************/ #ifndef _mlpbase_h #define _mlpbase_h #include "ap.h" #include "ialglib.h" struct multilayerperceptron { ap::integer_1d_array structinfo; ap::real_1d_array weights; ap::real_1d_array columnmeans; ap::real_1d_array columnsigmas; ap::real_1d_array neurons; ap::real_1d_array dfdnet; ap::real_1d_array derror; ap::real_1d_array x; ap::real_1d_array y; ap::real_2d_array chunks; ap::real_1d_array nwbuf; }; /************************************************************************* Creates neural network with NIn inputs, NOut outputs, without hidden layers, with linear output layer. Network weights are filled with small random values. -- ALGLIB -- Copyright 04.11.2007 by Bochkanov Sergey *************************************************************************/ void mlpcreate0(int nin, int nout, multilayerperceptron& network); /************************************************************************* Same as MLPCreate0, but with one hidden layer (NHid neurons) with non-linear activation function. Output layer is linear. -- ALGLIB -- Copyright 04.11.2007 by Bochkanov Sergey *************************************************************************/ void mlpcreate1(int nin, int nhid, int nout, multilayerperceptron& network); /************************************************************************* Same as MLPCreate0, but with two hidden layers (NHid1 and NHid2 neurons) with non-linear activation function. Output layer is linear. $ALL -- ALGLIB -- Copyright 04.11.2007 by Bochkanov Sergey *************************************************************************/ void mlpcreate2(int nin, int nhid1, int nhid2, int nout, multilayerperceptron& network); /************************************************************************* Creates neural network with NIn inputs, NOut outputs, without hidden layers with non-linear output layer. Network weights are filled with small random values. Activation function of the output layer takes values: (B, +INF), if D>=0 or (-INF, B), if D<0. -- ALGLIB -- Copyright 30.03.2008 by Bochkanov Sergey *************************************************************************/ void mlpcreateb0(int nin, int nout, double b, double d, multilayerperceptron& network); /************************************************************************* Same as MLPCreateB0 but with non-linear hidden layer. -- ALGLIB -- Copyright 30.03.2008 by Bochkanov Sergey *************************************************************************/ void mlpcreateb1(int nin, int nhid, int nout, double b, double d, multilayerperceptron& network); /************************************************************************* Same as MLPCreateB0 but with two non-linear hidden layers. -- ALGLIB -- Copyright 30.03.2008 by Bochkanov Sergey *************************************************************************/ void mlpcreateb2(int nin, int nhid1, int nhid2, int nout, double b, double d, multilayerperceptron& network); /************************************************************************* Creates neural network with NIn inputs, NOut outputs, without hidden layers with non-linear output layer. Network weights are filled with small random values. Activation function of the output layer takes values [A,B]. -- ALGLIB -- Copyright 30.03.2008 by Bochkanov Sergey *************************************************************************/ void mlpcreater0(int nin, int nout, double a, double b, multilayerperceptron& network); /************************************************************************* Same as MLPCreateR0, but with non-linear hidden layer. -- ALGLIB -- Copyright 30.03.2008 by Bochkanov Sergey *************************************************************************/ void mlpcreater1(int nin, int nhid, int nout, double a, double b, multilayerperceptron& network); /************************************************************************* Same as MLPCreateR0, but with two non-linear hidden layers. -- ALGLIB -- Copyright 30.03.2008 by Bochkanov Sergey *************************************************************************/ void mlpcreater2(int nin, int nhid1, int nhid2, int nout, double a, double b, multilayerperceptron& network); /************************************************************************* Creates classifier network with NIn inputs and NOut possible classes. Network contains no hidden layers and linear output layer with SOFTMAX- normalization (so outputs sums up to 1.0 and converge to posterior probabilities). -- ALGLIB -- Copyright 04.11.2007 by Bochkanov Sergey *************************************************************************/ void mlpcreatec0(int nin, int nout, multilayerperceptron& network); /************************************************************************* Same as MLPCreateC0, but with one non-linear hidden layer. -- ALGLIB -- Copyright 04.11.2007 by Bochkanov Sergey *************************************************************************/ void mlpcreatec1(int nin, int nhid, int nout, multilayerperceptron& network); /************************************************************************* Same as MLPCreateC0, but with two non-linear hidden layers. -- ALGLIB -- Copyright 04.11.2007 by Bochkanov Sergey *************************************************************************/ void mlpcreatec2(int nin, int nhid1, int nhid2, int nout, multilayerperceptron& network); /************************************************************************* Copying of neural network INPUT PARAMETERS: Network1 - original OUTPUT PARAMETERS: Network2 - copy -- ALGLIB -- Copyright 04.11.2007 by Bochkanov Sergey *************************************************************************/ void mlpcopy(const multilayerperceptron& network1, multilayerperceptron& network2); /************************************************************************* Serialization of MultiLayerPerceptron strucure INPUT PARAMETERS: Network - original OUTPUT PARAMETERS: RA - array of real numbers which stores network, array[0..RLen-1] RLen - RA lenght -- ALGLIB -- Copyright 29.03.2008 by Bochkanov Sergey *************************************************************************/ void mlpserialize(const multilayerperceptron& network, ap::real_1d_array& ra, int& rlen); /************************************************************************* Unserialization of MultiLayerPerceptron strucure INPUT PARAMETERS: RA - real array which stores network OUTPUT PARAMETERS: Network - restored network -- ALGLIB -- Copyright 29.03.2008 by Bochkanov Sergey *************************************************************************/ void mlpunserialize(const ap::real_1d_array& ra, multilayerperceptron& network); /************************************************************************* Randomization of neural network weights -- ALGLIB -- Copyright 06.11.2007 by Bochkanov Sergey *************************************************************************/ void mlprandomize(multilayerperceptron& network); /************************************************************************* Randomization of neural network weights and standartisator -- ALGLIB -- Copyright 10.03.2008 by Bochkanov Sergey *************************************************************************/ void mlprandomizefull(multilayerperceptron& network); /************************************************************************* Internal subroutine. -- ALGLIB -- Copyright 30.03.2008 by Bochkanov Sergey *************************************************************************/ void mlpinitpreprocessor(multilayerperceptron& network, const ap::real_2d_array& xy, int ssize); /************************************************************************* Returns information about initialized network: number of inputs, outputs, weights. -- ALGLIB -- Copyright 04.11.2007 by Bochkanov Sergey *************************************************************************/ void mlpproperties(const multilayerperceptron& network, int& nin, int& nout, int& wcount); /************************************************************************* Tells whether network is SOFTMAX-normalized (i.e. classifier) or not. -- ALGLIB -- Copyright 04.11.2007 by Bochkanov Sergey *************************************************************************/ bool mlpissoftmax(const multilayerperceptron& network); /************************************************************************* Procesing INPUT PARAMETERS: Network - neural network X - input vector, array[0..NIn-1]. OUTPUT PARAMETERS: Y - result. Regression estimate when solving regression task, vector of posterior probabilities for classification task. Subroutine does not allocate memory for this vector, it is responsibility of a caller to allocate it. Array must be at least [0..NOut-1]. -- ALGLIB -- Copyright 04.11.2007 by Bochkanov Sergey *************************************************************************/ void mlpprocess(multilayerperceptron& network, const ap::real_1d_array& x, ap::real_1d_array& y); /************************************************************************* Error function for neural network, internal subroutine. -- ALGLIB -- Copyright 04.11.2007 by Bochkanov Sergey *************************************************************************/ double mlperror(multilayerperceptron& network, const ap::real_2d_array& xy, int ssize); /************************************************************************* Natural error function for neural network, internal subroutine. -- ALGLIB -- Copyright 04.11.2007 by Bochkanov Sergey *************************************************************************/ double mlperrorn(multilayerperceptron& network, const ap::real_2d_array& xy, int ssize); /************************************************************************* Classification error -- ALGLIB -- Copyright 04.11.2007 by Bochkanov Sergey *************************************************************************/ int mlpclserror(multilayerperceptron& network, const ap::real_2d_array& xy, int ssize); /************************************************************************* Relative classification error on the test set INPUT PARAMETERS: Network - network XY - test set NPoints - test set size RESULT: percent of incorrectly classified cases. Works both for classifier networks and general purpose networks used as classifiers. -- ALGLIB -- Copyright 25.12.2008 by Bochkanov Sergey *************************************************************************/ double mlprelclserror(multilayerperceptron& network, const ap::real_2d_array& xy, int npoints); /************************************************************************* Average cross-entropy (in bits per element) on the test set INPUT PARAMETERS: Network - neural network XY - test set NPoints - test set size RESULT: CrossEntropy/(NPoints*LN(2)). Zero if network solves regression task. -- ALGLIB -- Copyright 08.01.2009 by Bochkanov Sergey *************************************************************************/ double mlpavgce(multilayerperceptron& network, const ap::real_2d_array& xy, int npoints); /************************************************************************* RMS error on the test set INPUT PARAMETERS: Network - neural network XY - test set NPoints - test set size RESULT: root mean square error. Its meaning for regression task is obvious. As for classification task, RMS error means error when estimating posterior probabilities. -- ALGLIB -- Copyright 04.11.2007 by Bochkanov Sergey *************************************************************************/ double mlprmserror(multilayerperceptron& network, const ap::real_2d_array& xy, int npoints); /************************************************************************* Average error on the test set INPUT PARAMETERS: Network - neural network XY - test set NPoints - test set size RESULT: Its meaning for regression task is obvious. As for classification task, it means average error when estimating posterior probabilities. -- ALGLIB -- Copyright 11.03.2008 by Bochkanov Sergey *************************************************************************/ double mlpavgerror(multilayerperceptron& network, const ap::real_2d_array& xy, int npoints); /************************************************************************* Average relative error on the test set INPUT PARAMETERS: Network - neural network XY - test set NPoints - test set size RESULT: Its meaning for regression task is obvious. As for classification task, it means average relative error when estimating posterior probability of belonging to the correct class. -- ALGLIB -- Copyright 11.03.2008 by Bochkanov Sergey *************************************************************************/ double mlpavgrelerror(multilayerperceptron& network, const ap::real_2d_array& xy, int npoints); /************************************************************************* Gradient calculation. Internal subroutine. -- ALGLIB -- Copyright 04.11.2007 by Bochkanov Sergey *************************************************************************/ void mlpgrad(multilayerperceptron& network, const ap::real_1d_array& x, const ap::real_1d_array& desiredy, double& e, ap::real_1d_array& grad); /************************************************************************* Gradient calculation (natural error function). Internal subroutine. -- ALGLIB -- Copyright 04.11.2007 by Bochkanov Sergey *************************************************************************/ void mlpgradn(multilayerperceptron& network, const ap::real_1d_array& x, const ap::real_1d_array& desiredy, double& e, ap::real_1d_array& grad); /************************************************************************* Batch gradient calculation. Internal subroutine. -- ALGLIB -- Copyright 04.11.2007 by Bochkanov Sergey *************************************************************************/ void mlpgradbatch(multilayerperceptron& network, const ap::real_2d_array& xy, int ssize, double& e, ap::real_1d_array& grad); /************************************************************************* Batch gradient calculation (natural error function). Internal subroutine. -- ALGLIB -- Copyright 04.11.2007 by Bochkanov Sergey *************************************************************************/ void mlpgradnbatch(multilayerperceptron& network, const ap::real_2d_array& xy, int ssize, double& e, ap::real_1d_array& grad); /************************************************************************* Batch Hessian calculation (natural error function) using R-algorithm. Internal subroutine. -- ALGLIB -- Copyright 26.01.2008 by Bochkanov Sergey. Hessian calculation based on R-algorithm described in "Fast Exact Multiplication by the Hessian", B. A. Pearlmutter, Neural Computation, 1994. *************************************************************************/ void mlphessiannbatch(multilayerperceptron& network, const ap::real_2d_array& xy, int ssize, double& e, ap::real_1d_array& grad, ap::real_2d_array& h); /************************************************************************* Batch Hessian calculation using R-algorithm. Internal subroutine. -- ALGLIB -- Copyright 26.01.2008 by Bochkanov Sergey. Hessian calculation based on R-algorithm described in "Fast Exact Multiplication by the Hessian", B. A. Pearlmutter, Neural Computation, 1994. *************************************************************************/ void mlphessianbatch(multilayerperceptron& network, const ap::real_2d_array& xy, int ssize, double& e, ap::real_1d_array& grad, ap::real_2d_array& h); /************************************************************************* Internal subroutine, shouldn't be called by user. *************************************************************************/ void mlpinternalprocessvector(const ap::integer_1d_array& structinfo, const ap::real_1d_array& weights, const ap::real_1d_array& columnmeans, const ap::real_1d_array& columnsigmas, ap::real_1d_array& neurons, ap::real_1d_array& dfdnet, const ap::real_1d_array& x, ap::real_1d_array& y); #endif
31.409639
77
0.492739
e347e7c92b3e0407e85eed000066fc7054429830
10,591
h
C
include/rtl/core/Polygon3D.h
Robotics-BUT/Robotic-Template-Library
a93b31f5a8f5b12fbbd5fa134a714ea0f82c1578
[ "MIT" ]
8
2020-04-22T09:46:14.000Z
2022-03-17T00:09:38.000Z
include/rtl/core/Polygon3D.h
Robotics-BUT/Robotic-Template-Library
a93b31f5a8f5b12fbbd5fa134a714ea0f82c1578
[ "MIT" ]
1
2020-08-11T07:24:14.000Z
2020-10-05T12:47:05.000Z
include/rtl/core/Polygon3D.h
Robotics-BUT/Robotic-Template-Library
a93b31f5a8f5b12fbbd5fa134a714ea0f82c1578
[ "MIT" ]
null
null
null
// This file is part of the Robotic Template Library (RTL), a C++ // template library for usage in robotic research and applications // under the MIT licence: // // Copyright 2020 Brno University of Technology // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation // the rights to use, copy, modify, merge, publish, distribute, sublicense, // and/or sell copies of the Software, and to permit persons to whom // the Software is furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included // in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT // OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE // OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // // Contact person: Ales Jelinek <Ales.Jelinek@ceitec.vutbr.cz> #ifndef ROBOTICTEMPLATELIBRARY_POLYGON3D_H #define ROBOTICTEMPLATELIBRARY_POLYGON3D_H #include <vector> #include "rtl/core/VectorND.h" namespace rtl { template<int, typename> class TranslationND; template<int, typename> class RotationND; template<int, typename> class RigidTfND; //! Three dimensional polygon class. /*! * For now, it aggregates points in std::vector, stores data of the plane in which they lie and allow transformation by Transformation3D. * Extensions such as intersection with another polygon etc. are planned in the future. * @tparam Element base type of underlying data. */ template<typename Element> class Polygon3D { public: typedef Element ElementType; //!< Base type of underlying data. typedef VectorND<3, ElementType> VectorType; //!< VectorND specialization for internal data. //! Default constructor. The polygon contains no points. Polygon3D() = default; //! Construction from plane in which the polygon lies. /*! * * @param normal vector orthogonal to the plane of the polygon. Its length is normalized during construction. * @param distance along the (unit!) \p normal from origin to the plane. */ Polygon3D(VectorType normal, ElementType distance) : int_dist(distance) { int_normal = normal.normalized(); } //! Default destructor. ~Polygon3D() = default; //! Unit normal vector of the polygon. /*! * * @return unit normal vector. */ [[nodiscard]] VectorType normal() const { return int_normal; } //! Signed distance along the normal() from origin to the plane. /*! * * @return scalar distance value. */ [[nodiscard]] ElementType distance() const { return int_dist; } //! \a a coefficient from the general equation of a plane. /*! * The \a a coefficient from the \a ax + \a by + \a cz + \a d = 0 equation. Corresponds to \a x coordinate of normal(). * @return scalar coefficient. */ [[nodiscard]] ElementType a() const { return int_normal.x(); } //! \a b coefficient from the general equation of a plane. /*! * The \a b coefficient from the \a ax + \a by + \a cz + \a d = 0 equation. Corresponds to \a y coordinate of normal(). * @return scalar coefficient. */ [[nodiscard]] ElementType b() const { return int_normal.y(); } //! \a c coefficient from the general equation of a plane. /*! * The \a c coefficient from the \a ax + \a by + \a cz + \a d = 0 equation. Corresponds to \a z coordinate of normal(). * @return scalar coefficient. */ [[nodiscard]] ElementType c() const { return int_normal.z(); } //! \a d coefficient from the general equation of a plane. /*! * The \a d coefficient from the \a ax + \a by + \a cz + \a d = 0 equation. Corresponds to - distance(). * @return scalar coefficient. */ [[nodiscard]] ElementType d() const { return -int_dist; } //! Read only access to the vertices. [[nodiscard]] const std::vector<VectorType>& points() const { return int_pts; } //! Returns translated copy of the polygon. /*! * @param tr the translation to be applied. * @return new polygon after translation. */ Polygon3D<ElementType> transformed(const TranslationND<3, Element> &tr) const { ElementType new_dist = int_dist + tr.trVec().dot(int_normal); Polygon3D<ElementType> ret(int_normal, new_dist); for (const auto &p : int_pts) ret.addPointDirect(tr(p)); return ret; } //! Translates *this polygon in-place. /*! * * @param tr the translation to be applied. */ void transform(const TranslationND<3, Element> &tr) { int_dist += tr.trVec().dot(int_normal); for (auto &p : int_pts) p.transform(tr); } //! Returns rotated copy of the polygon. /*! * @param rot the rotation to be applied. * @return new polygon after rotation. */ Polygon3D<ElementType> transformed(const RotationND<3, Element> &rot) const { auto new_normal = rot(int_normal); Polygon3D<ElementType> ret(new_normal, int_dist); for (const auto &p : int_pts) ret.addPointDirect(rot(p)); return ret; } //! Rotates *this polygon in-place. /*! * * @param rot the rotation to be applied. */ void transform(const RotationND<3, Element> &rot) { int_normal.transform(rot); for (auto &p : int_pts) p.transform(rot); } //! Returns transformed copy of the polygon. /*! * @param tf the transformation to be applied. * @return new polygon after transformation. */ Polygon3D<ElementType> transformed(const RigidTfND<3, Element> &tf) const { auto new_normal = int_normal.transformed(tf.rot()); ElementType new_dist = int_dist + tf.trVec().dot(new_normal); Polygon3D<ElementType> ret(new_normal, new_dist); for (const auto &p : int_pts) ret.addPointDirect(tf(p)); return ret; } //! Transforms *this polygon in-place. /*! * * @param tf the transformation to be applied. */ void transform(const RigidTfND<3, Element> &tf) { int_normal.transform(tf.rot()); int_dist += tf.tr().dot(int_normal); for (auto &p : int_pts) p.transform(tf); } //! Reservation of the internal storage. /*! * Reallocates internal std::vector to carry \p cnt vertices. * @param cnt number of vertices the polygon should b able to store. */ void reservePoints(size_t cnt) { int_pts.reserve(cnt); } //! Adds projection of \p point as another vertex to the buffer. /*! * Projection of \p point to the polygon plane is performed to ensure the polygon is truly planar. * @param point new vertex to be added. */ void addPoint(const VectorType &point) { int_pts.emplace_back(point - (VectorType::scalarProjectionOnUnit(point, int_normal) - int_dist) * int_normal); } //! Adds projections of vertices from an iterable object using iterators. /*! * Traverses iterators pointing to \a VectorType vertices by incrementation of \p beg until the \p end is reached and adds their * projections into the polygon plane to the internal buffer. * @tparam Iter iterator type. * @param beg begin iterator. * @param end end (one behind, as usual) iterator. */ template <class Iter> void addPoints(Iter beg, Iter end) { static_assert(std::is_constructible<VectorType, typename Iter::value_type>::value, "Invalid iterator value_type."); for (auto it = beg; it != end; it++) addPoint(*it); } //! Adds \p point as another vertex to the buffer. /*! * No checks, whether \p point lies in the polygon plane are performed, so it is possible to make an invalid polygon that way. * Use for increased speed when \p point is guaranteed to be in the polygon plane. * @param point new vertex to be added. */ void addPointDirect(VectorType point) { int_pts.emplace_back(point); } //! Adds vertices from an iterable object using iterators. /*! * Traverses iterators pointing to \a VectorType vertices by incrementation of \p beg until the \p end is reached and adds directly * to the internal buffer. No checks, whether the vertices lie in the polygon plane are performed, so it is possible to make an invalid * polygon that way. Use for increased speed when vertices in the range \p beg to \p end are guaranteed to be in the polygon plane. * @tparam Iter iterator type. * @param beg begin iterator. * @param end end (one behind, as usual) iterator. */ template <class Iter> void addPointsDirect(Iter beg, Iter end) { static_assert(std::is_constructible<VectorType, typename Iter::value_type>::value, "Invalid iterator value_type."); for (auto it = beg; it != end; it++) addPointDirect(*it); } //! Dimensionality of the polygon. static constexpr int dimensionality() { return 3; } private: VectorType int_normal; ElementType int_dist{}; std::vector<VectorType> int_pts; }; } #endif //ROBOTICTEMPLATELIBRARY_POLYGON3D_H
38.653285
143
0.605892
3f13cdbf8c79809fa308dd1580eb5baf14f2fe0a
317
c
C
testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr45059.c
mewbak/cc-1
d673e9b70d4d716fd96e81a4d7dc9d532c6c0391
[ "BSD-3-Clause" ]
178
2016-03-03T12:31:18.000Z
2021-11-05T22:36:55.000Z
testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr45059.c
mewbak/cc-1
d673e9b70d4d716fd96e81a4d7dc9d532c6c0391
[ "BSD-3-Clause" ]
106
2016-03-03T13:11:42.000Z
2018-09-27T13:01:51.000Z
testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr45059.c
mewbak/cc-1
d673e9b70d4d716fd96e81a4d7dc9d532c6c0391
[ "BSD-3-Clause" ]
21
2016-03-03T14:21:36.000Z
2020-04-09T01:19:17.000Z
/* PR tree-optimization/45059 */ typedef unsigned int T; extern void foo (signed char *, int); static signed char a; static T b[1] = { -1 }; static unsigned char c; static inline short int bar (short v) { c |= a < b[0]; return 0; } int main () { signed char *e = &a; foo (e, bar (bar (c))); return 0; }
13.208333
37
0.602524
8baa6d50199ebbcc67eee736d859ba0b596dfcbb
641
h
C
ios/Pods/Headers/Public/ReactABI35_0_0/ABI35_0_0RCTDevLoadingView.h
rudylee/expo
b3e65a7a5b205f14a3eb6cd6fa8d13c8d663b1cc
[ "Apache-2.0", "MIT" ]
2
2020-05-26T01:52:51.000Z
2021-01-30T05:24:04.000Z
ios/Pods/Headers/Public/ReactABI35_0_0/ABI35_0_0RCTDevLoadingView.h
rudylee/expo
b3e65a7a5b205f14a3eb6cd6fa8d13c8d663b1cc
[ "Apache-2.0", "MIT" ]
16
2021-03-01T21:18:59.000Z
2022-02-27T08:18:52.000Z
ios/Pods/Headers/Public/ReactABI35_0_0/ABI35_0_0RCTDevLoadingView.h
rudylee/expo
b3e65a7a5b205f14a3eb6cd6fa8d13c8d663b1cc
[ "Apache-2.0", "MIT" ]
2
2019-02-22T08:41:09.000Z
2019-02-22T08:47:56.000Z
/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #import <UIKit/UIKit.h> #import <ReactABI35_0_0/ABI35_0_0RCTBridgeModule.h> @class ABI35_0_0RCTLoadingProgress; @interface ABI35_0_0RCTDevLoadingView : NSObject <ABI35_0_0RCTBridgeModule> + (void)setEnabled:(BOOL)enabled; - (void)showMessage:(NSString *)message color:(UIColor *)color backgroundColor:(UIColor *)backgroundColor; - (void)showWithURL:(NSURL *)URL; - (void)updateProgress:(ABI35_0_0RCTLoadingProgress *)progress; - (void)hide; @end
27.869565
106
0.765991
e98a6dc5ad19a4fcb546d8b7c05f50d87cac1361
5,244
h
C
Wallet/ShowWallet.h
ShowCoin/show-ios
31b2ff7fb59d573d1a0d11ba4b87e6ee9d72d178
[ "MIT" ]
13
2018-04-13T14:51:20.000Z
2020-03-06T01:20:36.000Z
Wallet/ShowWallet.h
ShowCoin/show-ios
31b2ff7fb59d573d1a0d11ba4b87e6ee9d72d178
[ "MIT" ]
null
null
null
Wallet/ShowWallet.h
ShowCoin/show-ios
31b2ff7fb59d573d1a0d11ba4b87e6ee9d72d178
[ "MIT" ]
4
2018-04-28T06:03:53.000Z
2019-07-16T02:30:05.000Z
// // ShowWallet.h // ShowLive // // Created by Mac on 2018/4/3. // Copyright © 2018年 VNing. All rights reserved. // #import <Foundation/Foundation.h> #import <ethers/Address.h> #import <ethers/BigNumber.h> #import <ethers/Payment.h> #import <ethers/Provider.h> #import <ethers/Transaction.h> #import <ethers/TransactionInfo.h> #import <ethers/Account.h> typedef NSUInteger AccountIndex; #define AccountNotFound NSIntegerMax static NSString *const ShowSessionAccount_token = @"kSessionAccount_token"; static NSString *const ShowSessionAccount_pass = @"kSessionAccount_pass"; static NSString *const ShowSessionAccount_mn = @"kSessionAccount_mn"; #pragma mark - Notifications extern const NSNotificationName ShowWalletAccountAddedNotification; extern const NSNotificationName ShowWalletAccountRemovedNotification; extern const NSNotificationName ShowWalletAccountsReorderedNotification; // 帐户更改名称。 extern const NSNotificationName ShowWalletAccountNicknameDidChangeNotification; // 如果账户余额发生变化。 extern const NSNotificationName ShowWalletAccountBalanceDidChangeNotification; // 如果活动帐户事务更改(包括确认计数) extern const NSNotificationName ShowWalletTransactionDidChangeNotification; // 账户历史更新 extern const NSNotificationName ShowWalletAccountHistoryUpdatedNotification; // 激活账户更新通知 extern const NSNotificationName ShowWalletActiveAccountDidChangeNotification; // 账户同步通知 extern const NSNotificationName ShowWalletDidSyncNotification; #pragma mark - Notification Keys // 账户地址私钥 extern const NSString* ShowWalletNotificationAddressKey; extern const NSString* ShowWalletNotificationProviderKey; extern const NSString* ShowWalletNotificationIndexKey; // 账户名称 extern const NSString* ShowWalletNotificationNicknameKey; // 余额变化 extern const NSString* ShowWalletNotificationBalanceKey; // 事务key extern const NSString* ShowWalletNotificationTransactionKey; // 同步时间 extern const NSString* ShowWalletNotificationSyncDateKey; #pragma mark - Errors extern NSErrorDomain WalletErrorDomain; //钱包的错误类型 typedef enum ShowWalletError { ShowWalletErrorNetwork = -1, ShowWalletErrorUnknown = -5, ShowWalletErrorSendCancelled = -11, ShowWalletErrorSendInsufficientFunds = -12, ShowWalletErrorNoAccount = -40, ShowWalletErrorNotImplemented = -50, } WalletError; #pragma mark - Constants //交易类型 typedef enum ShowWalletTransactionAction { ShowWalletTransactionActionNormal = 0, ShowWalletTransactionActionRush = 1, ShowWalletTransactionActionCancel = 2 } WalletTransactionAction ; //设置类型ear typedef enum ShowWalletOptionsType { ShowWalletOptionsTypeDebug, ShowWalletOptionsTypeFirefly } WalletOptionsType; @interface ShowWallet : NSObject // 根据keychain获取钱包 + (instancetype)show_walletWithKeychainKey: (NSString*)keychainKey; // keychain @property (nonatomic, readonly) NSString *keychainKey; // 同步的事件 @property (nonatomic, readonly) NSTimeInterval syncDate; //价格 @property (nonatomic, readonly) float etherPrice; //回调 - (void)show_refresh: (void (^)(BOOL))callback; #pragma mark - Accounts //活跃账户的下标 @property (nonatomic, assign) AccountIndex activeAccountIndex; //当前使用中钱包的地址 @property (nonatomic, readonly) show_Address *activeAccountAddress; @property (nonatomic, readonly) show_Provider *activeAccountProvider; //账户 @property (nonatomic, readonly) show_Account * account; @property (nonatomic, assign) NSUInteger activeAccountBlockNumber; //当前账户数 @property (nonatomic, readonly) NSUInteger numberOfAccounts; //下标对应的账户 - (Address*)show_addressForIndex: (AccountIndex)index; //下标对应的余额 - (BigNumber*)show_balanceForIndex: (AccountIndex)index; //chainID 对应的下标 - (ChainId)show_chainIdForIndex: (AccountIndex)index; //名字对应下标 - (NSString*)show_nicknameForIndex: (AccountIndex)index; //设置下标对应的名字 - (void)show_setNickname: (NSString*)nickname forIndex: (AccountIndex)index; //显示下标对应的历史 - (NSArray<TransactionInfo*>*)show_transactionHistoryForIndex: (AccountIndex)index; //显示下标对应的账户 - (void)show_moveAccountAtIndex: (NSUInteger)fromIndex toIndex: (NSUInteger)toIndex; #pragma mark - Account Management (Modal UI) //添加账户回调 - (void)show_addAccountCallback ; //主管账户回调 - (void)show_manageAccountAtIndex: (AccountIndex)index callback: (void (^)(void))callback; #pragma mark - Transactions (Modal UI) //scan回调 - (void)ShowScan: (void (^)(Transaction*, NSError*))callback; //发送交易 - (void)show_sendPayment: (Payment*)payment callback: (void (^)(Transaction*, NSError*))callback; - (void)show_sendTransaction: (Transaction*)transaction callback:(void (^)(Transaction*, NSError*))callback; - (void)show_overrideTransaction: (TransactionInfo*)oldTransaction action: (WalletTransactionAction)action callback:(void (^)(Transaction*, NSError*))callback; //签名的信息 - (void)show_signMessage: (NSData*)message callback:(void (^)(Signature*, NSError*))callback; #pragma mark - Debug (Modal UI) //显示debug的信息 - (void)show_showDebuggingOptions: (WalletOptionsType)walletOptionsType callback: (void (^)(void))callback; #pragma mark - Debugging Options @property (nonatomic, assign) BOOL fireflyEnabled; @property (nonatomic, assign) BOOL testnetEnabled; - (void)show_purgeCacheData; @end
30.137931
108
0.779367
b9ea9e716ee583fcf2837fdd08114fb1e024b222
465
h
C
ZhiHuDaily/ZhiHuDaily/Frameworks/XBUtils/Utility/XBFileMD5Hash/XBFileHash.h
xiabob/ZhihuDaily
eafad860c01cf30e55d9a481fce42d96017a1fa7
[ "MIT" ]
3
2017-03-17T15:20:31.000Z
2017-10-01T04:56:09.000Z
ZhiHuDaily/ZhiHuDaily/Frameworks/XBUtils/Utility/XBFileMD5Hash/XBFileHash.h
xiabob/ZhihuDaily
eafad860c01cf30e55d9a481fce42d96017a1fa7
[ "MIT" ]
null
null
null
ZhiHuDaily/ZhiHuDaily/Frameworks/XBUtils/Utility/XBFileMD5Hash/XBFileHash.h
xiabob/ZhihuDaily
eafad860c01cf30e55d9a481fce42d96017a1fa7
[ "MIT" ]
null
null
null
// // XBFileHash.h // XBUtils // // this file get from https://github.com/JoeKun/FileMD5Hash // // 可以方便快捷地计算大文件MD5、hash值 // // Created by xiabob on 16/10/31. // Copyright © 2016年 xiabob. All rights reserved. // #import <Foundation/Foundation.h> @interface XBFileHash : NSObject + (NSString *)md5HashOfFileAtPath:(NSString *)filePath; + (NSString *)sha1HashOfFileAtPath:(NSString *)filePath; + (NSString *)sha512HashOfFileAtPath:(NSString *)filePath; @end
21.136364
60
0.71828
6b357065cdc8702a2105b6d88bc0861b06818241
15,158
h
C
CoX/Driver/LCD_Character/UC1601/uc1601_single/lib/uc1601.h
coocox/cox
c94e4a65417301b76a02108be5a9eeea3663ef70
[ "BSD-3-Clause" ]
58
2015-01-23T11:12:14.000Z
2022-03-23T01:52:14.000Z
CoX/Driver/LCD_Character/UC1601/uc1601_single/lib/uc1601.h
eventus17/cox
c94e4a65417301b76a02108be5a9eeea3663ef70
[ "BSD-3-Clause" ]
1
2017-12-30T05:40:50.000Z
2017-12-30T05:40:50.000Z
CoX/Driver/LCD_Character/UC1601/uc1601_single/lib/uc1601.h
eventus17/cox
c94e4a65417301b76a02108be5a9eeea3663ef70
[ "BSD-3-Clause" ]
68
2015-01-22T11:03:59.000Z
2022-01-29T14:18:40.000Z
//***************************************************************************** // //! \file uc1601.h //! \brief Prototypes for the uc1601 Driver. //! \version V2.1.1.0 //! \date 9/22/2011 //! \author CooCoX //! \copy //! //! Copyright (c) 2011, CooCoX //! 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 the <ORGANIZATION> 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 __UC1601_H__ #define __UC1601_H__ #include "hw_uc1601.h" //***************************************************************************** // // If building with a C++ compiler, make all of the definitions in this header // have a C binding. // //***************************************************************************** #ifdef __cplusplus extern "C" { #endif //***************************************************************************** // //! \addtogroup CoX_Driver_Lib //! @{ // //***************************************************************************** //***************************************************************************** // //! \addtogroup Displays //! @{ // //***************************************************************************** //***************************************************************************** // //! \addtogroup Text_Displays //! @{ // //***************************************************************************** //***************************************************************************** // //! \addtogroup UC1601 //! @{ // //***************************************************************************** //***************************************************************************** //***************************************************************************** //! \addtogroup UC1601_Driver_Single UC1601 Single Driver //! @{ // //***************************************************************************** //***************************************************************************** //! \addtogroup UC1601_User_Config UC1601 User Config //! @{ // //***************************************************************************** // //! User write protect config,it can be UC1601_SPI_9BIT or UC1601_SPI_8BIT //! UC1601_8080 UC1601_6800. // #define UC1601_INTERFACE UC1601_SPI_9BIT //***************************************************************************** // //! @} // //***************************************************************************** //***************************************************************************** //! \addtogroup UC1601_Hardware_Config UC1601 Hardware Config //! @{ // //***************************************************************************** #if (UC1601_INTERFACE == UC1601_SPI_9BIT) // //! Define SPIx as a port connecting uc1601 which can be configured // #define LCD_PIN_SPI_CLK PD9 #define SPI_CLK SPI3CLK #define LCD_PIN_SPI_MOSI PD11 #define SPI_MOSI SPI3MOSI #define LCD_PIN_SPI_PORT SPI3_BASE // //! Configure GPIOD.8 as chip Select // #define LCD_PIN_SPI_CS PD8 // //! Configure GPIOD.10 as chip reset // #define LCD_PIN_RST PD10 #elif (UC1601_INTERFACE == UC1601_SPI_8BIT) // //! Define SPIx as a port connecting uc1601 which can be configured // #define LCD_PIN_SPI_CLK PD9 #define SPI_CLK SPI3CLK #define LCD_PIN_SPI_MOSI PD11 #define SPI_MOSI SPI3MOSI #define LCD_PIN_CD PD10 #define LCD_PIN_SPI_PORT SPI3_BASE // //! Configure GPIOD.8 as chip Select // #define LCD_PIN_SPI_CS PD8 #elif (UC1601_INTERFACE == UC1601_I2C) // //! Define I2Cx as a port connecting uc1601 which can be configured // #define LCD_PIN_I2C_SCK PA9 #define I2C_SCK I2C0SCK #define LCD_PIN_I2C_SDA PA8 #define I2C_SDA I2C0SDA #define LCD_PIN_I2C_PORT I2C0_BASE #elif (UC1601_INTERFACE == UC1601_8080) // //! Define GPIO as a port connecting uc1601 which can be configured // #define LCD_PIN_DATA0 PA0 #define LCD_PIN_DATA1 PA1 #define LCD_PIN_DATA2 PA2 #define LCD_PIN_DATA3 PA3 #define LCD_PIN_DATA4 PA4 #define LCD_PIN_DATA5 PA5 #define LCD_PIN_DATA6 PA6 #define LCD_PIN_DATA7 PA7 #define LCD_PIN_CD PA8 #define LCD_PIN_WR PA9 #define LCD_PIN_RD PA10 #define LCD_PIN_CS PA11 #define LCD_PIN_DATA_OUT \ do \ { \ xGPIOSPinDirModeSet(LCD_PIN_DATA0, xGPIO_DIR_MODE_OUT); \ xGPIOSPinDirModeSet(LCD_PIN_DATA1, xGPIO_DIR_MODE_OUT); \ xGPIOSPinDirModeSet(LCD_PIN_DATA2, xGPIO_DIR_MODE_OUT); \ xGPIOSPinDirModeSet(LCD_PIN_DATA3, xGPIO_DIR_MODE_OUT); \ xGPIOSPinDirModeSet(LCD_PIN_DATA4, xGPIO_DIR_MODE_OUT); \ xGPIOSPinDirModeSet(LCD_PIN_DATA5, xGPIO_DIR_MODE_OUT); \ xGPIOSPinDirModeSet(LCD_PIN_DATA6, xGPIO_DIR_MODE_OUT); \ xGPIOSPinDirModeSet(LCD_PIN_DATA7, xGPIO_DIR_MODE_OUT); \ }while(0) #define LCD_PIN_DATA_IN \ do \ { \ xGPIOSPinDirModeSet(LCD_PIN_DATA0, xGPIO_DIR_MODE_IN); \ xGPIOSPinDirModeSet(LCD_PIN_DATA1, xGPIO_DIR_MODE_IN); \ xGPIOSPinDirModeSet(LCD_PIN_DATA2, xGPIO_DIR_MODE_IN); \ xGPIOSPinDirModeSet(LCD_PIN_DATA3, xGPIO_DIR_MODE_IN); \ xGPIOSPinDirModeSet(LCD_PIN_DATA4, xGPIO_DIR_MODE_IN); \ xGPIOSPinDirModeSet(LCD_PIN_DATA5, xGPIO_DIR_MODE_IN); \ xGPIOSPinDirModeSet(LCD_PIN_DATA6, xGPIO_DIR_MODE_IN); \ xGPIOSPinDirModeSet(LCD_PIN_DATA7, xGPIO_DIR_MODE_IN); \ }while(0) #define LCD_DATA_OUT(Data) \ do \ { \ xGPIOSPinWrite(LCD_PIN_DATA0, 1&Data); \ xGPIOSPinWrite(LCD_PIN_DATA1, (Data&2)>>1); \ xGPIOSPinWrite(LCD_PIN_DATA2, (Data&4)>>2); \ xGPIOSPinWrite(LCD_PIN_DATA3, (Data&8)>>3); \ xGPIOSPinWrite(LCD_PIN_DATA4, (Data&16)>>4); \ xGPIOSPinWrite(LCD_PIN_DATA5, (Data&32)>>5); \ xGPIOSPinWrite(LCD_PIN_DATA6, (Data&64)>>6); \ xGPIOSPinWrite(LCD_PIN_DATA7, (Data&128)>>7); \ }while(0) #elif (UC1601_INTERFACE == UC1601_6800) // //! Define GPIO as a port connecting uc1601 which can be configured // #define LCD_PIN_DATA0 PA0 #define LCD_PIN_DATA1 PA1 #define LCD_PIN_DATA2 PA2 #define LCD_PIN_DATA3 PA3 #define LCD_PIN_DATA4 PA4 #define LCD_PIN_DATA5 PA5 #define LCD_PIN_DATA6 PA6 #define LCD_PIN_DATA7 PA7 #define LCD_PIN_CD PA8 #define LCD_PIN_RW PA9 #define LCD_PIN_E PA10 #define LCD_PIN_CS PA11 #define LCD_PIN_DATA_OUT \ do \ { \ xGPIOSPinDirModeSet(LCD_PIN_DATA0, xGPIO_DIR_MODE_OUT); \ xGPIOSPinDirModeSet(LCD_PIN_DATA1, xGPIO_DIR_MODE_OUT); \ xGPIOSPinDirModeSet(LCD_PIN_DATA2, xGPIO_DIR_MODE_OUT); \ xGPIOSPinDirModeSet(LCD_PIN_DATA3, xGPIO_DIR_MODE_OUT); \ xGPIOSPinDirModeSet(LCD_PIN_DATA4, xGPIO_DIR_MODE_OUT); \ xGPIOSPinDirModeSet(LCD_PIN_DATA5, xGPIO_DIR_MODE_OUT); \ xGPIOSPinDirModeSet(LCD_PIN_DATA6, xGPIO_DIR_MODE_OUT); \ xGPIOSPinDirModeSet(LCD_PIN_DATA7, xGPIO_DIR_MODE_OUT); \ }while(0) #define LCD_PIN_DATA_IN \ do \ { \ xGPIOSPinDirModeSet(LCD_PIN_DATA0, xGPIO_DIR_MODE_IN); \ xGPIOSPinDirModeSet(LCD_PIN_DATA1, xGPIO_DIR_MODE_IN); \ xGPIOSPinDirModeSet(LCD_PIN_DATA2, xGPIO_DIR_MODE_IN); \ xGPIOSPinDirModeSet(LCD_PIN_DATA3, xGPIO_DIR_MODE_IN); \ xGPIOSPinDirModeSet(LCD_PIN_DATA4, xGPIO_DIR_MODE_IN); \ xGPIOSPinDirModeSet(LCD_PIN_DATA5, xGPIO_DIR_MODE_IN); \ xGPIOSPinDirModeSet(LCD_PIN_DATA6, xGPIO_DIR_MODE_IN); \ xGPIOSPinDirModeSet(LCD_PIN_DATA7, xGPIO_DIR_MODE_IN); \ }while(0) #define LCD_DATA_OUT(Data) \ do \ { \ xGPIOSPinWrite(LCD_PIN_DATA0, 1&Data); \ xGPIOSPinWrite(LCD_PIN_DATA1, (Data&2)>>1); \ xGPIOSPinWrite(LCD_PIN_DATA2, (Data&4)>>2); \ xGPIOSPinWrite(LCD_PIN_DATA3, (Data&8)>>3); \ xGPIOSPinWrite(LCD_PIN_DATA4, (Data&16)>>4); \ xGPIOSPinWrite(LCD_PIN_DATA5, (Data&32)>>5); \ xGPIOSPinWrite(LCD_PIN_DATA6, (Data&64)>>6); \ xGPIOSPinWrite(LCD_PIN_DATA7, (Data&128)>>7); \ }while(0) #endif //***************************************************************************** // //! @} // //***************************************************************************** //***************************************************************************** // //! \addtogroup CoX_UC1601_Exported_APIs CoX UC1601 Exported APIs //! @{ // //***************************************************************************** extern void UC1601Init(unsigned long ulSpiClock); extern void UC1601DataWrite(unsigned char ucData); extern void UC1601CmdWrite(unsigned char ucCmd); extern void UC1601DoubleCmdWrite(unsigned char ucCmd, unsigned char ucData); extern void UC1601AddressSet(unsigned char ucPA, unsigned char ucCA); extern void UC1601Dispaly(unsigned char ucLine, unsigned char ucRow, unsigned char ucAsciiWord); extern void UC1601InverseDispaly(unsigned char ucLine, unsigned char ucRow, unsigned char ucAsciiWord); extern void UC1601CharDispaly(unsigned char ucLine, unsigned char ucRow, char *pcChar); extern void UC1601ChineseDispaly(unsigned char ucLine, unsigned char ucRow, unsigned char ucLength, char *pcChar); extern void HD44780DisplayN(unsigned char ucLine, unsigned char ucRow, unsigned long n); extern void UC1601Clear(void); extern void UC1601InverseEnable(void); extern void UC1601InverseDisable(void); extern void UC1601AllPixelOnEnable(void); extern void UC1601AllPixelOnDisable(void); extern void UC1601DisplayOn(void); extern void UC1601DisplayOff(void); extern void UC1601ScrollLineSet(unsigned char ucLine); extern void UC1601PMSet(unsigned char ucPM); extern void UC1601CENSet(unsigned char ucCEN); extern void UC1601DSTSet(unsigned char ucDST); extern void UC1601DENSet(unsigned char ucDEN); //***************************************************************************** // //! @} // //***************************************************************************** //***************************************************************************** // //! @} // //***************************************************************************** //***************************************************************************** // //! @} // //***************************************************************************** //***************************************************************************** // //! @} // //***************************************************************************** //***************************************************************************** // //! @} // //***************************************************************************** //***************************************************************************** // //! @} // //***************************************************************************** //***************************************************************************** // //! Mark the end of the C bindings section for C++ compilers. // //***************************************************************************** #ifdef __cplusplus } #endif #endif //__UC1601_H__
40.747312
79
0.446563
5bfe61a0f9986b89bf57fe143e1a18a9e7ae0283
2,595
h
C
src/palrt/shlwapip.h
CyberSys/coreclr-mono
83b2cb83b32faa45b4f790237b5c5e259692294a
[ "MIT" ]
277
2015-01-04T20:42:36.000Z
2022-03-21T06:52:03.000Z
src/palrt/shlwapip.h
CyberSys/coreclr-mono
83b2cb83b32faa45b4f790237b5c5e259692294a
[ "MIT" ]
31
2015-01-05T08:00:38.000Z
2016-01-05T01:18:59.000Z
src/palrt/shlwapip.h
CyberSys/coreclr-mono
83b2cb83b32faa45b4f790237b5c5e259692294a
[ "MIT" ]
46
2015-01-21T00:41:59.000Z
2021-03-23T07:00:01.000Z
// // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. // // // // =========================================================================== // File: shlwapi.h // // Header for ported shlwapi stuff // =========================================================================== #ifndef SHLWAPIP_H_INCLUDED #define SHLWAPIP_H_INCLUDED #define ARRAYSIZE(x) (sizeof(x)/sizeof(x[0])) #define SIZECHARS(sz) (sizeof(sz)/sizeof(sz[0])) #define SIZEOF(x) sizeof(x) #define PRIVATE #define PUBLIC #ifndef ASSERT #define ASSERT _ASSERTE #endif #define AssertMsg(f,m) _ASSERTE(f) #define RIP(f) _ASSERTE(f) #define RIPMSG(f,m) _ASSERTE(f) #define IsFlagSet(obj, f) (BOOL)(((obj) & (f)) == (f)) #define IsFlagClear(obj, f) (BOOL)(((obj) & (f)) != (f)) #define InRange(id, idFirst, idLast) ((UINT)((id)-(idFirst)) <= (UINT)((idLast)-(idFirst))) #define CbFromCch(cch) ((cch)*sizeof(TCHAR)) #define IS_VALID_READ_BUFFER(p, t, n) (p != NULL) #define IS_VALID_WRITE_BUFFER(p, t, n) (p != NULL) #define IS_VALID_READ_PTR(p, t) IS_VALID_READ_BUFFER(p, t, 1) #define IS_VALID_WRITE_PTR(p, t) IS_VALID_WRITE_BUFFER(p, t, 1) #define IS_VALID_STRING_PTR(p, c) (p != NULL) #define IS_VALID_STRING_PTRW(p, c) (p != NULL) #define CharLowerW _wcslwr inline int StrCmpNCW(LPCWSTR pch1, LPCWSTR pch2, int n) { if (n == 0) return 0; while (--n && *pch1 && *pch1 == *pch2) { pch1++; pch2++; } return *pch1 - *pch2; } typedef struct tagPARSEDURLW { DWORD cbSize; // Pointers into the buffer that was provided to ParseURL LPCWSTR pszProtocol; UINT cchProtocol; LPCWSTR pszSuffix; UINT cchSuffix; UINT nScheme; // One of URL_SCHEME_* } PARSEDURLW, * PPARSEDURLW; typedef enum { URL_SCHEME_INVALID = -1, URL_SCHEME_UNKNOWN = 0, URL_SCHEME_FTP = 1, URL_SCHEME_HTTP = 2, URL_SCHEME_FILE = 9, URL_SCHEME_HTTPS = 11, } URL_SCHEME; #define URL_ESCAPE_UNSAFE 0x20000000 #define URL_DONT_ESCAPE_EXTRA_INFO 0x02000000 #define URL_ESCAPE_SPACES_ONLY 0x04000000 #define URL_DONT_SIMPLIFY 0x08000000 #define URL_UNESCAPE_INPLACE 0x00100000 #define URL_ESCAPE_PERCENT 0x00001000 #define URL_ESCAPE_SEGMENT_ONLY 0x00002000 // Treat the entire URL param as one URL segment. #endif // ! SHLWAPIP_H_INCLUDED
28.833333
101
0.598073
b1ea427eb1487c903864a88a2db3c16b046c737e
227
h
C
src/mounts.h
brain0/appjail
5daada08b40b78c9b99923050ee8db5eea19ccdc
[ "WTFPL" ]
3
2016-02-14T21:47:12.000Z
2017-02-24T22:23:02.000Z
src/mounts.h
brain0/appjail
5daada08b40b78c9b99923050ee8db5eea19ccdc
[ "WTFPL" ]
null
null
null
src/mounts.h
brain0/appjail
5daada08b40b78c9b99923050ee8db5eea19ccdc
[ "WTFPL" ]
2
2016-01-16T04:11:15.000Z
2018-08-30T16:52:07.000Z
#pragma once #include "opts.h" void init_libmount(); void set_mount_propagation_slave(); void sanitize_mounts(appjail_options *opts); void unmount_directory(const char *path); void make_read_only(const appjail_options *opts);
25.222222
49
0.810573
3da360288fe626418332119e87c67b39ff83c8f8
14,802
h
C
vcgapps/OGF/math/symbolic/symbolic.h
mattjr/structured
0cb4635af7602f2a243a9b739e5ed757424ab2a7
[ "Apache-2.0" ]
14
2015-01-11T02:53:04.000Z
2021-11-25T17:31:22.000Z
vcgapps/OGF/math/symbolic/symbolic.h
skair39/structured
0cb4635af7602f2a243a9b739e5ed757424ab2a7
[ "Apache-2.0" ]
null
null
null
vcgapps/OGF/math/symbolic/symbolic.h
skair39/structured
0cb4635af7602f2a243a9b739e5ed757424ab2a7
[ "Apache-2.0" ]
14
2015-07-21T04:47:52.000Z
2020-03-12T12:31:25.000Z
/* * OGF/Graphite: Geometry and Graphics Programming Library + Utilities * Copyright (C) 2000 Bruno Levy * * 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., 675 Mass Ave, Cambridge, MA 02139, USA. * * If you modify this software, you should include a notice giving the * name of the person performing the modification, the date of modification, * and the reason for such modification. * * Contact: Bruno Levy * * levy@loria.fr * * ISA Project * LORIA, INRIA Lorraine, * Campus Scientifique, BP 239 * 54506 VANDOEUVRE LES NANCY CEDEX * FRANCE * * Note that the GNU General Public License does not permit incorporating * the Software into proprietary programs. */ #ifndef __OGF_MATH_SYMBOLIC_SYMBOLIC__ #define __OGF_MATH_SYMBOLIC_SYMBOLIC__ #include <OGF/math/common/common.h> #include <OGF/basic/types/counted.h> #include <OGF/basic/types/smart_pointer.h> #include <iostream> #include <vector> // We got enough to try a first implementation of the generic symbolic / numerical // solver. However, in the future, to get more performance, we should introduce // n-ary operators with canonical ordering of the children: // Sum // Product // Check if we can find an implementation of an unification algorithm (and use // a generic "Node" representation, with n children, and a "NodeType"). // We need to check the definition of the "normal semantic form" and use it. // Evaluation: we can have a virtual machine (stack + array of function pointers) // or use SoftWire on Intel architectures // a) use the system stack // b) group the expressions with subtrees of depth <= 8, and use // the registers of the math processor // c) check what we can do with the multi-media registers, katmai // instructions etc... // It would be cool to have also a parser: Sym::Expression = Sym::parse("x1*x2/cos(x3)") namespace OGF { namespace Symbolic { struct Context { std::vector<double> variables ; std::vector<double> parameters ; } ; class Node ; /** * Node_ptr encapsulates a pointer to a Node, * we need it to allow operators overloading * (operators overloading do not work with Node*, * it needs a class). */ class MATH_API Node_ptr { public: Node_ptr() : ptr_(nil) { } Node_ptr(const Node_ptr& rhs) : ptr_(rhs.ptr_) { } Node_ptr(Node* ptr) : ptr_(ptr) { } Node_ptr(double val) ; Node_ptr(int val) ; Node_ptr& operator=(const Node_ptr& rhs) { ptr_ = rhs.ptr_ ; return *this ; } Node_ptr& operator=(Node* rhs) { ptr_ = rhs ; return *this ; } operator Node*() const { return ptr_ ; } Node* operator->() { return ptr_ ; } Node& operator*() const { return *ptr_ ; } private: Node* ptr_ ; } ; /** * Node is an element of a mathematical expression. */ class MATH_API Node : public Counted { public: virtual double eval(const Context& context) const = 0 ; virtual void print(std::ostream& out) const = 0 ; virtual bool is_constant() const = 0 ; virtual bool depends_on_variable(int var_index) const = 0 ; virtual int max_variable_index() const = 0 ; virtual bool depends_on_parameter(int prm_index) const = 0 ; virtual int max_parameter_index() const = 0 ; virtual Node* derivative(int var_index) const = 0 ; } ; typedef SmartPointer<Node> Node_var ; /** * Expression is the user-type for mathematical * expression. Expression encapsulates a Node * SmartPointer. */ class MATH_API Expression : public Node_var { public: Expression(Node_ptr ptr) : Node_var(ptr) { } Expression(Node* ptr) : Node_var(ptr) { } Expression() ; Expression(double x) ; operator Node_ptr() const { const Node_var& n = *this ; return (Node*)(n) ; // return Node_var::operator Node*() ; } Expression& operator=(const Expression& rhs) { Node_var::operator=(rhs) ; return *this ; } Expression& operator=(Node_ptr rhs) { Node_var::operator=(rhs) ; return *this ; } } ; class MATH_API Variable : public Node { public: Variable(int index) : index_(index) { } int index() const { return index_ ; } virtual double eval(const Context& context) const ; virtual void print(std::ostream& out) const ; virtual bool is_constant() const ; virtual bool depends_on_variable(int var_index) const ; virtual int max_variable_index() const ; virtual bool depends_on_parameter(int prm_index) const ; virtual int max_parameter_index() const ; virtual Node* derivative(int var_index) const ; private: int index_ ; } ; // Cannot declare it inline, else the linker barks at x, // as a multiply defined symbol. class MATH_API Variables { public: Node_ptr operator[](int index) { return new Variable(index) ; } } ; extern MATH_API Variables x ; class MATH_API Constant : public Node { public: virtual bool is_constant() const ; virtual bool depends_on_variable(int var_index) const ; virtual Node* derivative(int var_index) const ; virtual int max_variable_index() const ; } ; class MATH_API Number : public Constant { public: Number(double value) : value_(value) { } double value() const { return value_ ; } virtual double eval(const Context& context) const ; virtual void print(std::ostream& out) const ; virtual bool depends_on_parameter(int prm_index) const ; virtual int max_parameter_index() const ; private: double value_ ; } ; class MATH_API Zero : public Number { public: Zero() : Number(0.0) { } } ; class MATH_API One : public Number { public: One() : Number(1.0) { } } ; class MATH_API Parameter : public Constant { public: Parameter(int index) : index_(index) { } int index() const { return index_ ; } virtual double eval(const Context& context) const ; virtual void print(std::ostream& out) const ; virtual bool depends_on_parameter(int prm_index) const ; virtual int max_parameter_index() const ; private: int index_ ; } ; // Cannot declare it inline, else the linker barks at x, // as a multiply defined symbol. class MATH_API Parameters { public: Node_ptr operator[](int index) { return new Parameter(index) ; } } ; extern MATH_API Parameters c ; inline Node_ptr constant(double value) { if(value == 0.0) { return new Zero ; } if(value == 1.0) { return new One ; } return new Number(value) ; } inline Node_ptr der(Node* e, int var_index) { return e->derivative(var_index) ; } //__________________________________________________________________ class MATH_API Operator : public Node { public: Operator(Node* left, Node* right) : left_(left), right_(right) { } Node_ptr left() const { return (Node*)left_ ; } Node_ptr right() const { return (Node*)right_ ; } virtual bool is_constant() const ; virtual bool depends_on_variable(int var_index) const ; virtual int max_variable_index() const ; virtual bool depends_on_parameter(int prm_index) const ; virtual int max_parameter_index() const ; private: Node_var left_ ; Node_var right_ ; } ; class MATH_API Plus : public Operator { public: Plus(Node* left, Node* right) : Operator(left, right) {} virtual double eval(const Context& context) const ; virtual void print(std::ostream& out) const ; virtual Node* derivative(int var_index) const ; } ; class MATH_API Minus : public Operator { public: Minus(Node* left, Node* right) : Operator(left, right) {} virtual double eval(const Context& context) const ; virtual void print(std::ostream& out) const ; virtual Node* derivative(int var_index) const ; } ; class MATH_API Times : public Operator { public: Times(Node* left, Node* right) : Operator(left, right) {} virtual double eval(const Context& context) const ; virtual void print(std::ostream& out) const ; virtual Node* derivative(int var_index) const ; } ; class MATH_API Divide : public Operator { public: Divide(Node* left, Node* right) : Operator(left, right) {} virtual double eval(const Context& context) const ; virtual void print(std::ostream& out) const ; virtual Node* derivative(int var_index) const ; } ; /* * Note: it seems that the C++ hat operator does not have the same * priority as a power. When in doubt, use parentheses. */ Node_ptr MATH_API operator+( Node_ptr left, Node_ptr right ) ; Node_ptr MATH_API operator-( Node_ptr left, Node_ptr right ) ; Node_ptr MATH_API operator*( Node_ptr left, Node_ptr right ) ; Node_ptr MATH_API operator/( Node_ptr left, Node_ptr right ) ; Node_ptr MATH_API operator^( Node_ptr left, Node_ptr right ) ; //__________________________________________________________________ class MATH_API Function : public Node { public: Function(Node* arg) : arg_(arg) { } Node_ptr arg() const { return (Node*)arg_ ; } virtual bool is_constant() const ; virtual bool depends_on_variable(int var_index) const ; virtual int max_variable_index() const ; virtual bool depends_on_parameter(int prm_index) const ; virtual int max_parameter_index() const ; private: Node_var arg_ ; } ; class MATH_API Neg : public Function { public: Neg(Node* arg) : Function(arg) { } virtual double eval(const Context& context) const ; virtual void print(std::ostream& out) const ; virtual Node* derivative(int var_index) const ; } ; class MATH_API Sin : public Function { public: Sin(Node* arg) : Function(arg) { } virtual double eval(const Context& context) const ; virtual void print(std::ostream& out) const ; virtual Node* derivative(int var_index) const ; } ; class MATH_API Cos : public Function { public: Cos(Node* arg) : Function(arg) { } virtual double eval(const Context& context) const ; virtual void print(std::ostream& out) const ; virtual Node* derivative(int var_index) const ; } ; class MATH_API Ln : public Function { public: Ln(Node* arg) : Function(arg) { } virtual double eval(const Context& context) const ; virtual void print(std::ostream& out) const ; virtual Node* derivative(int var_index) const ; } ; class MATH_API Exp : public Function { public: Exp(Node* arg) : Function(arg) { } virtual double eval(const Context& context) const ; virtual void print(std::ostream& out) const ; virtual Node* derivative(int var_index) const ; } ; class MATH_API Pow : public Function { public: Pow(Node* arg, double exponent) : Function(arg), exponent_(exponent) {} double exponent() const { return exponent_ ; } virtual double eval(const Context& context) const ; virtual void print(std::ostream& out) const ; virtual Node* derivative(int var_index) const ; private: double exponent_ ; } ; class MATH_API ArcSin : public Function { public: ArcSin(Node* arg) : Function(arg) { } virtual double eval(const Context& context) const ; virtual void print(std::ostream& out) const ; virtual Node* derivative(int var_index) const ; } ; class MATH_API ArcCos : public Function { public: ArcCos(Node* arg) : Function(arg) { } virtual double eval(const Context& context) const ; virtual void print(std::ostream& out) const ; virtual Node* derivative(int var_index) const ; } ; Node_ptr MATH_API operator-(Node_ptr arg) ; Node_ptr MATH_API sin(Node_ptr arg) ; Node_ptr MATH_API cos(Node_ptr arg) ; Node_ptr MATH_API sqrt(Node_ptr arg) ; Node_ptr MATH_API ln(Node_ptr arg) ; Node_ptr MATH_API exp(Node_ptr arg) ; Node_ptr MATH_API arcsin(Node_ptr arg) ; Node_ptr MATH_API arccos(Node_ptr arg) ; //__________________________________________________________________ } inline std::ostream& operator<<(std::ostream& out, Symbolic::Node_ptr n) { n->print(out) ; return out ; } inline std::ostream& operator<<(std::ostream& out, Symbolic::Expression n) { n->print(out) ; return out ; } } #endif
37.097744
89
0.588231
ad05cc29d3be6c78c3ceb9ea00bc9e57da1d7c72
12,349
h
C
hmc5883l.h
sanzaru/hmc5883l
90db00ea656da8b19c4d2a328b7d5f567282b2bb
[ "MIT" ]
null
null
null
hmc5883l.h
sanzaru/hmc5883l
90db00ea656da8b19c4d2a328b7d5f567282b2bb
[ "MIT" ]
null
null
null
hmc5883l.h
sanzaru/hmc5883l
90db00ea656da8b19c4d2a328b7d5f567282b2bb
[ "MIT" ]
null
null
null
/** * 3-Axis Digital Compass IC HMC5883LL header only library for Raspberry Pi. * * Author: Martin Albrecht * * * The MIT License (MIT) * Copyright (c) 2016 Martin Albrecht <martin.albrecht@javacoffee.de> * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ #ifndef __HMC5883L_H__ #define __HMC5883L_H__ #include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <string.h> #include <math.h> #include <wiringPi.h> #include <wiringPiI2C.h> /* I2C address */ #define HMC5883L_I2C_ADDRESS 0x1E /* Chip ID */ #define HMC5883L_ID (0b11010100) /* Internal name */ #define HMC5883L_SENSOR_NAME "HMC5883L" /* Registers */ #define HMC5883L_REGISTER_CRA 0x00 #define HMC5883L_REGISTER_CRB 0x01 #define HMC5883L_REGISTER_MR 0x02 #define HMC5883L_REGISTER_OUT_X_H_M 0x03 #define HMC5883L_REGISTER_OUT_X_L_M 0x04 #define HMC5883L_REGISTER_OUT_Z_H_M 0x05 #define HMC5883L_REGISTER_OUT_Z_L_M 0x06 #define HMC5883L_REGISTER_OUT_Y_H_M 0x07 #define HMC5883L_REGISTER_OUT_Y_L_M 0x08 #define HMC5883L_REGISTER_STATUS 0x09 #define HMC5883L_REGISTER_IRA 0x0A #define HMC5883L_REGISTER_IRB 0x0B #define HMC5883L_REGISTER_IRC 0x0C #define HMC5883L_REGISTER_TEMP_OUT_H_M 0x31 #define HMC5883L_REGISTER_TEMP_OUT_L_M 0x32 /* Gain definitions */ #define HMC5883L_GAIN_1_3 0x20 #define HMC5883L_GAIN_1_9 0x40 #define HMC5883L_GAIN_2_5 0x60 #define HMC5883L_GAIN_4_0 0x80 #define HMC5883L_GAIN_4_7 0xA0 #define HMC5883L_GAIN_5_6 0xC0 #define HMC5883L_GAIN_8_1 0xE0 /* Errors */ #define HMC5883L_ERR_UNKNOWN 0x01 #define HMC5883L_ERR_SETUP 0x02 #define HMC5883L_ERR_SELFTEST 0x03 #define HMC5883L_ERR_SELFTEST_RUNS 0x04 /* Status codes */ #define HMC5883L_STATUS_READY 0x01 #define HMC5883L_STATUS_LOCK 0x02 /* Constants */ #define HMC5883L_CONST_GAUSS2MTESLA 100 /* General stuff */ #define HMC5883L_OKAY 0 #define HMC5883L_ERROR -1 /* Predefined values, which change with gain setting */ static float _hmc5883l_Gauss_LSB_XY = 1100.0F; static float _hmc5883l_Gauss_LSB_Z = 980.0F; /* The HMC5883L object */ typedef struct { int _fd, _status, _min_delay, _max_value, _min_value; unsigned char _gain, _error; char _name[12]; float _resolution, _declination_angle, _scale; /* Magnetic field data */ struct { float x, y, z; } _magnetic; /* Sensor data */ struct { float x, y, z; float x_scaled, y_scaled, z_scaled; double orientation_deg; /* Degrees */ float orientation_rad; /* Radiants */ } _data; } HMC5883L; /* Function prototypes */ extern void hmc5883l_error(HMC5883L *hmc5883l, char code); extern void hmc5883l_read(HMC5883L *hmc5883l); extern void hmc5883l_set_gain(HMC5883L *hmc5883l, unsigned char gain); extern char hmc5883l_self_test(HMC5883L *hmc5883l); extern char hmc5883l_init(HMC5883L *hmc5883l); /* Set error flag in HMC5883L object */ inline void hmc5883l_error(HMC5883L *hmc5883l, char code) { switch(code) { case HMC5883L_ERR_SETUP: hmc5883l->_error = HMC5883L_ERR_SETUP; break; case HMC5883L_ERR_SELFTEST: hmc5883l->_error = HMC5883L_ERR_SELFTEST; break; case HMC5883L_ERR_SELFTEST_RUNS: hmc5883l->_error = HMC5883L_ERR_SELFTEST_RUNS; break; default: hmc5883l->_error = HMC5883L_ERR_UNKNOWN; break; } } /* Read status register */ inline void hmc5883l_status(HMC5883L *hmc5883l) { int status = 0; status = wiringPiI2CReadReg8(hmc5883l->_fd, HMC5883L_REGISTER_STATUS); hmc5883l->_status = 0; hmc5883l->_status |= (status & 1); /* Ready flag */ hmc5883l->_status |= (status & 2); /* Lock flag */ } /* Read raw data from sensor */ inline void hmc5883l_read(HMC5883L *hmc5883l) { int x0 = 0, x1 = 0, y0 = 0, y1 = 0, z0 = 0, z1 = 0; float heading = 0; /* Read the status register */ hmc5883l_status(hmc5883l); if( hmc5883l->_status == HMC5883L_STATUS_READY ) { /* Read data registers */ x0 = wiringPiI2CReadReg8(hmc5883l->_fd, HMC5883L_REGISTER_OUT_X_L_M); x1 = wiringPiI2CReadReg8(hmc5883l->_fd, HMC5883L_REGISTER_OUT_X_H_M); z0 = wiringPiI2CReadReg8(hmc5883l->_fd, HMC5883L_REGISTER_OUT_Z_L_M); z1 = wiringPiI2CReadReg8(hmc5883l->_fd, HMC5883L_REGISTER_OUT_Z_H_M); y0 = wiringPiI2CReadReg8(hmc5883l->_fd, HMC5883L_REGISTER_OUT_Y_L_M); y1 = wiringPiI2CReadReg8(hmc5883l->_fd, HMC5883L_REGISTER_OUT_Y_H_M); /* Combine 8 bit values to a 16 bit value */ hmc5883l->_data.x = (int16_t)(x0 | ((int16_t)x1 << 8)); hmc5883l->_data.y = (int16_t)(y0 | ((int16_t)y1 << 8)); hmc5883l->_data.z = (int16_t)(z0 | ((int16_t)z1 << 8)); hmc5883l->_data.x_scaled = hmc5883l->_scale * hmc5883l->_data.x; hmc5883l->_data.y_scaled = hmc5883l->_scale * hmc5883l->_data.y; hmc5883l->_data.z_scaled = hmc5883l->_scale * hmc5883l->_data.z; /* Magnetic field calculation */ hmc5883l->_magnetic.x = hmc5883l->_data.x / _hmc5883l_Gauss_LSB_XY * HMC5883L_CONST_GAUSS2MTESLA; hmc5883l->_magnetic.y = hmc5883l->_data.y / _hmc5883l_Gauss_LSB_XY * HMC5883L_CONST_GAUSS2MTESLA; hmc5883l->_magnetic.z = hmc5883l->_data.z / _hmc5883l_Gauss_LSB_Z * HMC5883L_CONST_GAUSS2MTESLA; /* Calculate heading */ heading = atan2(hmc5883l->_magnetic.y, hmc5883l->_magnetic.x); if( hmc5883l->_declination_angle > 0 ) { heading += hmc5883l->_declination_angle; } /* Normalize value */ if( heading < 0 ) heading += 2 * M_PI; if( heading > 2 * M_PI ) heading -= 2 * M_PI; hmc5883l->_data.orientation_rad = heading; hmc5883l->_data.orientation_deg = heading * 180 / M_PI; } } /* Set sensor gain and corresponding scale factor */ inline void hmc5883l_set_gain(HMC5883L *hmc5883l, unsigned char gain) { wiringPiI2CWriteReg8(hmc5883l->_fd, HMC5883L_REGISTER_CRB, gain); hmc5883l->_gain = gain; switch(gain) { /* +/- 1.3 gauss */ case HMC5883L_GAIN_1_3: _hmc5883l_Gauss_LSB_XY = 1090; _hmc5883l_Gauss_LSB_Z = 980; hmc5883l->_scale = 0.92; break; /* +/- 1.9 gauss */ case HMC5883L_GAIN_1_9: _hmc5883l_Gauss_LSB_XY = 820; _hmc5883l_Gauss_LSB_Z = 760; hmc5883l->_scale = 1.22; break; /* +/- 2.5 gauss */ case HMC5883L_GAIN_2_5: _hmc5883l_Gauss_LSB_XY = 660; _hmc5883l_Gauss_LSB_Z = 600; hmc5883l->_scale = 1.52; break; /* +/- 4.0 gauss */ case HMC5883L_GAIN_4_0: _hmc5883l_Gauss_LSB_XY = 440; _hmc5883l_Gauss_LSB_Z = 400; hmc5883l->_scale = 2.27; break; /* +/- 4.7 gauss */ case HMC5883L_GAIN_4_7: _hmc5883l_Gauss_LSB_XY = 390; _hmc5883l_Gauss_LSB_Z = 255; hmc5883l->_scale = 2.56; break; /* +/- 5.6 gauss */ case HMC5883L_GAIN_5_6: _hmc5883l_Gauss_LSB_XY = 330; _hmc5883l_Gauss_LSB_Z = 295; hmc5883l->_scale = 3.03; break; /* +/- 8.1 gauss */ case HMC5883L_GAIN_8_1: _hmc5883l_Gauss_LSB_XY = 230; _hmc5883l_Gauss_LSB_Z = 205; hmc5883l->_scale = 4.35; break; default: break; } } /* Self test */ inline char hmc5883l_self_test(HMC5883L *hmc5883l) { unsigned char passed = 0; unsigned int limit_low = 243, limit_high = 575; while(passed == 0) { /* Set the sensor to self test mode */ wiringPiI2CWriteReg8(hmc5883l->_fd, HMC5883L_REGISTER_CRA, 0x71); /* Set the gain to 5, limits are then 243-575) */ wiringPiI2CWriteReg8(hmc5883l->_fd, HMC5883L_REGISTER_CRB, 0xA0); /* Set continuous-measurement mode */ wiringPiI2CWriteReg8(hmc5883l->_fd, HMC5883L_REGISTER_MR, 0x00); delay(1); /* Read self test data */ hmc5883l_read(hmc5883l); /* Check the values */ if( hmc5883l->_data.x < limit_low || hmc5883l->_data.x > limit_high || hmc5883l->_data.y < limit_low || hmc5883l->_data.y > limit_high || hmc5883l->_data.z < limit_low || hmc5883l->_data.z > limit_high ) { if( hmc5883l->_gain < HMC5883L_GAIN_8_1 ) { hmc5883l_set_gain(hmc5883l, (hmc5883l->_gain + 0x20)); /* Set limits */ if( hmc5883l->_gain == HMC5883L_GAIN_5_6 ) { printf("Adjusted gain to 6\n"); limit_low = 206; limit_high = 487; } if( hmc5883l->_gain == HMC5883L_GAIN_8_1 ) { printf("Adjusted gain to 7\n"); limit_low = 143; limit_high = 339; } continue; } hmc5883l_error(hmc5883l, HMC5883L_ERR_SELFTEST); return HMC5883L_ERROR; } /* Exit self test mode, set defaults */ wiringPiI2CWriteReg8(hmc5883l->_fd, HMC5883L_REGISTER_CRA, 0x70); return HMC5883L_OKAY; } hmc5883l_error(hmc5883l, HMC5883L_ERR_SELFTEST_RUNS); return HMC5883L_ERROR; } /* * Constructor function */ inline char hmc5883l_init(HMC5883L *hmc5883l) { /* The I2C interface descriptor */ hmc5883l->_fd = wiringPiI2CSetup(HMC5883L_I2C_ADDRESS); if( hmc5883l->_fd == -1 ){ hmc5883l_error(hmc5883l, HMC5883L_ERR_SETUP); return HMC5883L_ERROR; } /* Set sensor data */ hmc5883l->_error = 0; hmc5883l->_status = 0; hmc5883l->_gain = 0; hmc5883l->_min_delay = 0; hmc5883l->_max_value = 800; /* 8 gauss == 800 microTesla */ hmc5883l->_min_value = -800; /* -8 gauss == -800 microTesla */ hmc5883l->_resolution = 0.2; /* 2 milligauss == 0.2 microTesla */ hmc5883l->_declination_angle = 0; hmc5883l->_data.x = 0; hmc5883l->_data.y = 0; hmc5883l->_data.z = 0; hmc5883l->_data.orientation_deg = 0; hmc5883l->_data.orientation_rad = 0; hmc5883l->_magnetic.x = 0; hmc5883l->_magnetic.y = 0; hmc5883l->_magnetic.z = 0; sprintf(hmc5883l->_name, HMC5883L_SENSOR_NAME); /* Set default configuration */ wiringPiI2CWriteReg8(hmc5883l->_fd, HMC5883L_REGISTER_CRA, 0x70); delay(1); /* Set the gain to a known level */ hmc5883l_set_gain(hmc5883l, HMC5883L_GAIN_1_3); /* Enable the magnetometer */ wiringPiI2CWriteReg8(hmc5883l->_fd, HMC5883L_REGISTER_MR, 0x00); return HMC5883L_OKAY; } #endif
31.105793
83
0.620455
ef3d83fa3091af690fc22a241f57b2740c4d6082
1,409
h
C
PushButton.h
salesvictor/emonitor
669ae31d12fe9a15bcf73d289cb9e13c4f5bec61
[ "Apache-2.0" ]
null
null
null
PushButton.h
salesvictor/emonitor
669ae31d12fe9a15bcf73d289cb9e13c4f5bec61
[ "Apache-2.0" ]
null
null
null
PushButton.h
salesvictor/emonitor
669ae31d12fe9a15bcf73d289cb9e13c4f5bec61
[ "Apache-2.0" ]
null
null
null
class PushButton { public: PushButton(uint8_t pin) // Constructor (executes when a PushButton object is created) : pin(pin) { // remember the push button pin pinMode(pin, INPUT_PULLUP); // enable the internal pull-up resistor }; bool isPressed() // read the button state check if the button has been pressed, debounce the button as well { bool pressed = false; bool state = digitalRead(pin); // read the button's state int8_t stateChange = state - previousState; // calculate the state change since last time if (stateChange == falling) { // If the button is pressed (went from high to low) if (millis() - previousBounceTime > debounceTime) { // check if the time since the last bounce is higher than the threshold pressed = true; // the button is pressed } } if (stateChange == rising) { // if the button is released or bounces previousBounceTime = millis(); // remember when this happened } previousState = state; // remember the current state return pressed; // return true if the button was pressed and didn't bounce }; private: uint8_t pin; bool previousState = HIGH; unsigned long previousBounceTime = 0; const static unsigned long debounceTime = 25; const static int8_t rising = HIGH - LOW; const static int8_t falling = LOW - HIGH; };
40.257143
131
0.659333
3538ee1140c93b9aab983f36bb09e13c138d3cf4
163
h
C
src/aux/left_right.h
epeec/Lapser
dd428e43c37249c7e372f1a37638f17feeb5c7f0
[ "MIT" ]
null
null
null
src/aux/left_right.h
epeec/Lapser
dd428e43c37249c7e372f1a37638f17feeb5c7f0
[ "MIT" ]
null
null
null
src/aux/left_right.h
epeec/Lapser
dd428e43c37249c7e372f1a37638f17feeb5c7f0
[ "MIT" ]
null
null
null
#ifndef LEFTRIGHT_H #define LEFTRIGHT_H #define RIGHT(iProc,nProc) ((iProc + nProc + 1) % nProc) #define LEFT(iProc,nProc) ((iProc + nProc - 1) % nProc) #endif
20.375
56
0.687117
c2e943a96d29fbb885af8530f3b7da6773027626
8,605
h
C
groups/bsl/bsls/bsls_atomicoperations_x64_win_msvc.h
seanbaxter/bde-1
149176ebc2ae49c3b563895a7332fe638a760782
[ "Apache-2.0" ]
1
2021-11-10T16:53:42.000Z
2021-11-10T16:53:42.000Z
groups/bsl/bsls/bsls_atomicoperations_x64_win_msvc.h
seanbaxter/bde-1
149176ebc2ae49c3b563895a7332fe638a760782
[ "Apache-2.0" ]
2
2020-11-05T15:20:55.000Z
2021-01-05T19:38:43.000Z
groups/bsl/bsls/bsls_atomicoperations_x64_win_msvc.h
seanbaxter/bde-1
149176ebc2ae49c3b563895a7332fe638a760782
[ "Apache-2.0" ]
2
2020-01-16T17:58:12.000Z
2020-08-11T20:59:30.000Z
// bsls_atomicoperations_x64_win_msvc.h -*-C++-*- #ifndef INCLUDED_BSLS_ATOMICOPERATIONS_X64_WIN_MSVC #define INCLUDED_BSLS_ATOMICOPERATIONS_X64_WIN_MSVC #include <bsls_ident.h> BSLS_IDENT("$Id: $") //@PURPOSE: Provide implementations of atomic operations for X86_64/MSVC/Win64. // //@CLASSES: // bsls::AtomicOperations_X64_WIN_MSVC: implementation of atomics for // X86_64/MSVC/Windows // //@DESCRIPTION: This component provides classes necessary to implement atomics // on the Windows X86_64 platform with MSVC compiler. The classes are for // private use only. See 'bsls_atomicoperations' and 'bsls_atomic' for the // public interface to atomics. #include <bsls_atomicoperations_default.h> #include <bsls_platform.h> #include <bsls_types.h> #if defined(BSLS_PLATFORM_CPU_X86_64) && defined(BSLS_PLATFORM_CMP_MSVC) #include <intrin.h> // Visual C++ implementation exploits the fact that 'volatile' loads and stores // have acquire and release semantics (load - acquire, store - release). So // these memory ordering guarantees come for free (and accidentally they are // no-op on x86). However the implementation of operations providing // the sequential consistency guarantee still requires a memory barrier. // // As for interlocked intrinsics, they provide the sequential consistency // guarantee, so no additional memory barrier is needed. // // For some explanations, see // http://blogs.msdn.com/b/kangsu/archive/2007/07/16/ // volatile-acquire-release-memory-fences-and-vc2005.aspx // and also MSDN documentation for 'volatile' and interlocked intrinsics in // VC++ 2005 and later. namespace BloombergLP { namespace bsls { struct AtomicOperations_X64_WIN_MSVC; typedef AtomicOperations_X64_WIN_MSVC AtomicOperations_Imp; // ======================================================= // struct Atomic_TypeTraits<AtomicOperations_X64_WIN_MSVC> // ======================================================= template <> struct Atomic_TypeTraits<AtomicOperations_X64_WIN_MSVC> { struct Int { __declspec(align(4)) volatile int d_value; }; struct Int64 { __declspec(align(8)) volatile Types::Int64 d_value; }; struct Uint { __declspec(align(4)) volatile unsigned int d_value; }; struct Uint64 { __declspec(align(8)) volatile Types::Uint64 d_value; }; struct Pointer { __declspec(align(8)) void * volatile d_value; }; }; // ==================================== // struct AtomicOperations_X64_WIN_MSVC // ==================================== struct AtomicOperations_X64_WIN_MSVC : AtomicOperations_Default64<AtomicOperations_X64_WIN_MSVC> { typedef Atomic_TypeTraits<AtomicOperations_X64_WIN_MSVC> AtomicTypes; // *** atomic functions for int *** static int getInt(const AtomicTypes::Int *atomicInt); static int getIntAcquire(const AtomicTypes::Int *atomicInt); static void setInt(AtomicTypes::Int *atomicInt, int value); static void setIntRelease(AtomicTypes::Int *atomicInt, int value); static int swapInt(AtomicTypes::Int *atomicInt, int swapValue); static int testAndSwapInt(AtomicTypes::Int *atomicInt, int compareValue, int swapValue); static int addIntNv(AtomicTypes::Int *atomicInt, int value); // *** atomic functions for Int64 *** static Types::Int64 getInt64(const AtomicTypes::Int64 *atomicInt); static Types::Int64 getInt64Acquire(const AtomicTypes::Int64 *atomicInt); static void setInt64(AtomicTypes::Int64 *atomicInt, Types::Int64 value); static void setInt64Release(AtomicTypes::Int64 *atomicInt, Types::Int64 value); static Types::Int64 swapInt64(AtomicTypes::Int64 *atomicInt, Types::Int64 swapValue); static Types::Int64 testAndSwapInt64(AtomicTypes::Int64 *atomicInt, Types::Int64 compareValue, Types::Int64 swapValue); static Types::Int64 addInt64Nv(AtomicTypes::Int64 *atomicInt, Types::Int64 value); }; // =========================================================================== // INLINE FUNCTION DEFINITIONS // =========================================================================== // ------------------------------------ // struct AtomicOperations_X64_WIN_MSVC // ------------------------------------ // Memory barrier for atomic operations with sequential consistency. #define BSLS_ATOMIC_FENCE() \ _mm_mfence() inline int AtomicOperations_X64_WIN_MSVC:: getInt(const AtomicTypes::Int *atomicInt) { BSLS_ATOMIC_FENCE(); return atomicInt->d_value; } inline int AtomicOperations_X64_WIN_MSVC:: getIntAcquire(const AtomicTypes::Int *atomicInt) { return atomicInt->d_value; } inline void AtomicOperations_X64_WIN_MSVC:: setInt(AtomicTypes::Int *atomicInt, int value) { atomicInt->d_value = value; BSLS_ATOMIC_FENCE(); } inline void AtomicOperations_X64_WIN_MSVC:: setIntRelease(AtomicTypes::Int *atomicInt, int value) { atomicInt->d_value = value; } inline int AtomicOperations_X64_WIN_MSVC:: swapInt(AtomicTypes::Int *atomicInt, int swapValue) { return _InterlockedExchange( reinterpret_cast<long volatile *>(&atomicInt->d_value), swapValue); } inline int AtomicOperations_X64_WIN_MSVC:: testAndSwapInt(AtomicTypes::Int *atomicInt, int compareValue, int swapValue) { return _InterlockedCompareExchange( reinterpret_cast<long volatile *>(&atomicInt->d_value), swapValue, compareValue); } inline int AtomicOperations_X64_WIN_MSVC:: addIntNv(AtomicTypes::Int *atomicInt, int value) { return _InterlockedExchangeAdd( reinterpret_cast<long volatile *>(&atomicInt->d_value), value) + value; } inline Types::Int64 AtomicOperations_X64_WIN_MSVC:: getInt64(const AtomicTypes::Int64 *atomicInt) { BSLS_ATOMIC_FENCE(); return atomicInt->d_value; } inline Types::Int64 AtomicOperations_X64_WIN_MSVC:: getInt64Acquire(const AtomicTypes::Int64 *atomicInt) { return atomicInt->d_value; } inline void AtomicOperations_X64_WIN_MSVC:: setInt64(AtomicTypes::Int64 *atomicInt, Types::Int64 value) { atomicInt->d_value = value; BSLS_ATOMIC_FENCE(); } inline void AtomicOperations_X64_WIN_MSVC:: setInt64Release(AtomicTypes::Int64 *atomicInt, Types::Int64 value) { atomicInt->d_value = value; } inline Types::Int64 AtomicOperations_X64_WIN_MSVC:: swapInt64(AtomicTypes::Int64 *atomicInt, Types::Int64 swapValue) { return _InterlockedExchange64(&atomicInt->d_value, swapValue); } inline Types::Int64 AtomicOperations_X64_WIN_MSVC:: testAndSwapInt64(AtomicTypes::Int64 *atomicInt, Types::Int64 compareValue, Types::Int64 swapValue) { return _InterlockedCompareExchange64( &atomicInt->d_value, swapValue, compareValue); } inline Types::Int64 AtomicOperations_X64_WIN_MSVC:: addInt64Nv(AtomicTypes::Int64 *atomicInt, Types::Int64 value) { return _InterlockedExchangeAdd64( &atomicInt->d_value, value) + value; } #undef BSLS_ATOMIC_FENCE } // close package namespace } // close enterprise namespace #endif // X86_64 && MSVC #endif // ---------------------------------------------------------------------------- // Copyright 2013 Bloomberg Finance L.P. // // 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. // ----------------------------- END-OF-FILE ----------------------------------
29.169492
79
0.630215
896eee697f2e33be40afd8b5febc24b05ad125dc
883
h
C
include/BootParamDef.h
HenriDellal/unisoc-dloader
479e289b2ba5c28a39e2438e65e0bb519e2f2a82
[ "Apache-2.0" ]
3
2021-02-11T07:28:07.000Z
2021-08-11T02:37:01.000Z
include/BootParamDef.h
plugnburn/dloader
9b293edc49d13484d7cfad1890e27ab540ea24dc
[ "Apache-2.0" ]
null
null
null
include/BootParamDef.h
plugnburn/dloader
9b293edc49d13484d7cfad1890e27ab540ea24dc
[ "Apache-2.0" ]
4
2020-10-15T05:16:13.000Z
2021-09-05T05:19:26.000Z
#ifndef BOOTPARAMDEF_H # define BOOTPARAMDEF_H /*lint -save -e756*/ typedef struct _OS_INFO { char Name[24]; char Description[48]; char Version[24]; unsigned short Offset; // in sectors unsigned short Size; // in sectors } OS_INFO /*, * POS_INFO */ ; typedef struct _BOOT_PARAM { unsigned char Magic[4]; unsigned short Size; unsigned short TotalSize; long TimeStamp; unsigned char TraceOn; unsigned char Reserved; unsigned char CurrentOS; unsigned char NumOfOS; unsigned short SizeOfOSInfo; unsigned short OSOffset; } BOOT_PARAM /*, * PBOOT_PARAM */ ; /*lint -restore */ inline unsigned short SwapWord (unsigned short src) { return MAKEWORD (HIBYTE (src), LOBYTE (src)); } inline unsigned long SwapDword (unsigned long src) { return MAKELONG (SwapWord (HIWORD (src)), SwapWord (LOWORD (src))); } #endif // BOOTPARAMDEF_H
20.534884
70
0.698754
374f37f441a5cb58c12f50cfc3ba24b462f93d1b
13,363
c
C
apps/riscv-tests/isa/rv64uv/vmadd.c
kmettias/ara
497ba6920a1f5ce790f5581f72092bd053bfd13a
[ "Apache-2.0" ]
null
null
null
apps/riscv-tests/isa/rv64uv/vmadd.c
kmettias/ara
497ba6920a1f5ce790f5581f72092bd053bfd13a
[ "Apache-2.0" ]
null
null
null
apps/riscv-tests/isa/rv64uv/vmadd.c
kmettias/ara
497ba6920a1f5ce790f5581f72092bd053bfd13a
[ "Apache-2.0" ]
1
2021-05-17T05:58:02.000Z
2021-05-17T05:58:02.000Z
// Copyright 2021 ETH Zurich and University of Bologna. // Solderpad Hardware License, Version 0.51, see LICENSE for details. // SPDX-License-Identifier: SHL-0.51 // // Author: Matheus Cavalcante <matheusd@iis.ee.ethz.ch> // Basile Bougenot <bbougenot@student.ethz.ch> #include "vector_macros.h" void TEST_CASE1() { VSET(16, e8, m1); VLOAD_8(v1, 0x21, 0x75, 0x7f, 0x3a, 0x50, 0x6d, 0x3f, 0x3e, 0x74, 0x11, 0x29, 0xea, 0x14, 0xce, 0xb0, 0x37); VLOAD_8(v2, 0xfe, 0xa7, 0x06, 0xaa, 0x35, 0x3c, 0x2c, 0x58, 0xa1, 0xc4, 0x40, 0x42, 0x52, 0x40, 0xa8, 0x53); VLOAD_8(v3, 0x30, 0xef, 0xb4, 0x12, 0x6d, 0x3b, 0x2c, 0x5e, 0xf0, 0x25, 0xd7, 0x70, 0xc2, 0x62, 0xe0, 0x99); asm volatile("vmadd.vv v1, v2, v3"); VCMP_U8(1, v1, 0xee, 0x42, 0xae, 0x96, 0xfd, 0xc7, 0x00, 0xae, 0xe4, 0x29, 0x17, 0xc4, 0x2a, 0xe2, 0x60, 0x6e); VSET(16, e16, m1); VLOAD_16(v1, 0x1c20, 0x11e4, 0xde38, 0x642f, 0x3eb5, 0xa0af, 0x48e1, 0x5fc4, 0x3d2a, 0x67d5, 0x3f07, 0x2889, 0x8812, 0x0bd9, 0x56f4, 0xe068); VLOAD_16(v2, 0x02cc, 0xd99c, 0xdba2, 0xf282, 0x0f99, 0xa219, 0x2dcc, 0x17cc, 0xe8fb, 0x1e83, 0xed20, 0xbfee, 0xee87, 0x6b0f, 0xf6cf, 0x4cd1); VLOAD_16(v3, 0xe3f0, 0x42db, 0x2fde, 0x1983, 0x910c, 0x853b, 0x82aa, 0x9ac2, 0x4631, 0x1f8b, 0x68c3, 0x6fbc, 0x3b5c, 0xf98b, 0x2db1, 0x8e75); asm volatile("vmadd.vv v1, v2, v3"); VCMP_U16(2, v1, 0x8d70, 0x6dcb, 0xb74e, 0x6761, 0xa639, 0xf452, 0x22f6, 0x86f2, 0x4e5f, 0x378a, 0xc4a3, 0x561a, 0xb8da, 0x5e42, 0xf4fd, 0xa35d); VSET(16, e32, m1); VLOAD_32(v1, 0x0401c584, 0x69049955, 0x4a71aa0c, 0xc651666f, 0x273fcd5d, 0x23ca1d7d, 0x599c994e, 0xb2d8adc5, 0x4710afae, 0x69c61cad, 0x96ee5026, 0x2c197996, 0xd95da451, 0x3a654fb9, 0xbe990e4b, 0xc41fd55a); VLOAD_32(v2, 0x39d5b56a, 0xc578a540, 0x51283b5c, 0x07b4ba9d, 0xe5aba5e4, 0x28720dc8, 0x600fb42b, 0xf2937fa7, 0x4032d36f, 0xc676e3b3, 0xf1cd5f96, 0x1c14bcbf, 0x7dea81ed, 0x40270562, 0x9577b3be, 0xea615f0a); VLOAD_32(v3, 0xa055bbb6, 0x71f9a668, 0x0be640c9, 0x2336ca55, 0xca121638, 0xbf234fb5, 0xe7c83142, 0xb7048f12, 0x8eb340e3, 0xef253e93, 0xffef4a03, 0xdf346833, 0xd0922181, 0xf159ee1d, 0xf86a7c06, 0xfcb24a2d); asm volatile("vmadd.vv v1, v2, v3"); VCMP_U32(3, v1, 0x448bd85e, 0xf2cbc4a8, 0x5cd02119, 0xf69b4268, 0x3c60ee0c, 0xa233b25d, 0x4c72c95c, 0xe2b1a595, 0xefb7d755, 0x95d6b28a, 0xd3be5a47, 0x6338471d, 0xfb1a117e, 0xabe00fef, 0xbede88b0, 0x913705b1); VSET(16, e64, m1); VLOAD_64(v1, 0x9cffef345b95f00b, 0x85d366e07e4bbc6b, 0xadfda1d2464c6433, 0x610bf2c1435b3cf6, 0x8a0c6e4bc950e81f, 0x4296e7147ef94d7a, 0x27d7ec90ba159756, 0x2a6c87932c3aef86, 0xbfd90c33e58a8fe3, 0x1114f7672cf625c1, 0x1a7b72dd8ac39fab, 0xdb80f952e5fd2e5b, 0x6b01c18a3daf288b, 0x69b4b0e4335f26d5, 0x0c059f365ec6d3d5, 0xc22568276f1dcdd0); VLOAD_64(v2, 0x6dc8e88769e54465, 0xce8cda83d16c3859, 0x1465ee5b6eb0d2b8, 0x4827a9b40add2507, 0xd24c4005695a64d6, 0xb97c8e41e912f84a, 0xc8c22e3b3b2e2fa1, 0x26712aa325bd00b6, 0xdf7ad19151df27b5, 0x68ba6d050ffcba1e, 0x94448979a2b854e6, 0x84bf5d544f97f739, 0x6d4bfa429e9d6ef0, 0xdb6c54b9a91ab935, 0x1a0051ca72162c5e, 0xe04b73fdf1b61f9c); VLOAD_64(v3, 0x32a4c1edbbfe5591, 0xf6baf4e747f4a120, 0x3a29727ae38b9b92, 0xf173f78d09c997e4, 0xaab9d34e4aeaa57a, 0xa8fe3bf12b7c95e8, 0xc4bd99b066821092, 0x9c2f1daf5fe2db9d, 0xa8b041a876aabcae, 0xb9a2e6f9ded9a60a, 0x8bdf55954f50101d, 0x704f0e648c11d63f, 0x0c8ca4d0a6d1a982, 0xa74d01c12ae6aea5, 0x3f2cd5d2e2f5b538, 0x79803b24efa2caa3); asm volatile("vmadd.vv v1, v2, v3"); VCMP_U64(4, v1, 0xf7c2044aeebff5e8, 0xad447a1b99a48a53, 0x78676efbe1b5763a, 0x813582af4d75d09e, 0x483adf8d811ecb64, 0x36d90fe4df2f2b2c, 0xf833b173685307a8, 0x955c2ac405b724e1, 0xdcf9681f074b0d2d, 0x10277404741c4ca8, 0x25d9bca0245d9fbf, 0x58439c4175d7f582, 0x27ae9e3365b265d2, 0xabfe86591f4ba5be, 0xd964de90eaae196e, 0xfb655e2263986563); } void TEST_CASE2() { VSET(16, e8, m1); VLOAD_8(v1, 0x21, 0x75, 0x7f, 0x3a, 0x50, 0x6d, 0x3f, 0x3e, 0x74, 0x11, 0x29, 0xea, 0x14, 0xce, 0xb0, 0x37); VLOAD_8(v2, 0xfe, 0xa7, 0x06, 0xaa, 0x35, 0x3c, 0x2c, 0x58, 0xa1, 0xc4, 0x40, 0x42, 0x52, 0x40, 0xa8, 0x53); VLOAD_8(v3, 0x30, 0xef, 0xb4, 0x12, 0x6d, 0x3b, 0x2c, 0x5e, 0xf0, 0x25, 0xd7, 0x70, 0xc2, 0x62, 0xe0, 0x99); VLOAD_8(v0, 0xAA, 0xAA); asm volatile("vmadd.vv v1, v2, v3, v0.t"); VCMP_U8(5, v1, 0x21, 0x42, 0x7f, 0x96, 0x50, 0xc7, 0x3f, 0xae, 0x74, 0x29, 0x29, 0xc4, 0x14, 0xe2, 0xb0, 0x6e); VSET(16, e16, m1); VLOAD_16(v1, 0x1c20, 0x11e4, 0xde38, 0x642f, 0x3eb5, 0xa0af, 0x48e1, 0x5fc4, 0x3d2a, 0x67d5, 0x3f07, 0x2889, 0x8812, 0x0bd9, 0x56f4, 0xe068); VLOAD_16(v2, 0x02cc, 0xd99c, 0xdba2, 0xf282, 0x0f99, 0xa219, 0x2dcc, 0x17cc, 0xe8fb, 0x1e83, 0xed20, 0xbfee, 0xee87, 0x6b0f, 0xf6cf, 0x4cd1); VLOAD_16(v3, 0xe3f0, 0x42db, 0x2fde, 0x1983, 0x910c, 0x853b, 0x82aa, 0x9ac2, 0x4631, 0x1f8b, 0x68c3, 0x6fbc, 0x3b5c, 0xf98b, 0x2db1, 0x8e75); VLOAD_8(v0, 0xAA, 0xAA); asm volatile("vmadd.vv v1, v2, v3, v0.t"); VCMP_U16(6, v1, 0x1c20, 0x6dcb, 0xde38, 0x6761, 0x3eb5, 0xf452, 0x48e1, 0x86f2, 0x3d2a, 0x378a, 0x3f07, 0x561a, 0x8812, 0x5e42, 0x56f4, 0xa35d); VSET(16, e32, m1); VLOAD_32(v1, 0x0401c584, 0x69049955, 0x4a71aa0c, 0xc651666f, 0x273fcd5d, 0x23ca1d7d, 0x599c994e, 0xb2d8adc5, 0x4710afae, 0x69c61cad, 0x96ee5026, 0x2c197996, 0xd95da451, 0x3a654fb9, 0xbe990e4b, 0xc41fd55a); VLOAD_32(v2, 0x39d5b56a, 0xc578a540, 0x51283b5c, 0x07b4ba9d, 0xe5aba5e4, 0x28720dc8, 0x600fb42b, 0xf2937fa7, 0x4032d36f, 0xc676e3b3, 0xf1cd5f96, 0x1c14bcbf, 0x7dea81ed, 0x40270562, 0x9577b3be, 0xea615f0a); VLOAD_32(v3, 0xa055bbb6, 0x71f9a668, 0x0be640c9, 0x2336ca55, 0xca121638, 0xbf234fb5, 0xe7c83142, 0xb7048f12, 0x8eb340e3, 0xef253e93, 0xffef4a03, 0xdf346833, 0xd0922181, 0xf159ee1d, 0xf86a7c06, 0xfcb24a2d); VLOAD_8(v0, 0xAA, 0xAA); asm volatile("vmadd.vv v1, v2, v3, v0.t"); VCMP_U32(7, v1, 0x0401c584, 0xf2cbc4a8, 0x4a71aa0c, 0xf69b4268, 0x273fcd5d, 0xa233b25d, 0x599c994e, 0xe2b1a595, 0x4710afae, 0x95d6b28a, 0x96ee5026, 0x6338471d, 0xd95da451, 0xabe00fef, 0xbe990e4b, 0x913705b1); VSET(16, e64, m1); VLOAD_64(v1, 0x9cffef345b95f00b, 0x85d366e07e4bbc6b, 0xadfda1d2464c6433, 0x610bf2c1435b3cf6, 0x8a0c6e4bc950e81f, 0x4296e7147ef94d7a, 0x27d7ec90ba159756, 0x2a6c87932c3aef86, 0xbfd90c33e58a8fe3, 0x1114f7672cf625c1, 0x1a7b72dd8ac39fab, 0xdb80f952e5fd2e5b, 0x6b01c18a3daf288b, 0x69b4b0e4335f26d5, 0x0c059f365ec6d3d5, 0xc22568276f1dcdd0); VLOAD_64(v2, 0x6dc8e88769e54465, 0xce8cda83d16c3859, 0x1465ee5b6eb0d2b8, 0x4827a9b40add2507, 0xd24c4005695a64d6, 0xb97c8e41e912f84a, 0xc8c22e3b3b2e2fa1, 0x26712aa325bd00b6, 0xdf7ad19151df27b5, 0x68ba6d050ffcba1e, 0x94448979a2b854e6, 0x84bf5d544f97f739, 0x6d4bfa429e9d6ef0, 0xdb6c54b9a91ab935, 0x1a0051ca72162c5e, 0xe04b73fdf1b61f9c); VLOAD_64(v3, 0x32a4c1edbbfe5591, 0xf6baf4e747f4a120, 0x3a29727ae38b9b92, 0xf173f78d09c997e4, 0xaab9d34e4aeaa57a, 0xa8fe3bf12b7c95e8, 0xc4bd99b066821092, 0x9c2f1daf5fe2db9d, 0xa8b041a876aabcae, 0xb9a2e6f9ded9a60a, 0x8bdf55954f50101d, 0x704f0e648c11d63f, 0x0c8ca4d0a6d1a982, 0xa74d01c12ae6aea5, 0x3f2cd5d2e2f5b538, 0x79803b24efa2caa3); VLOAD_8(v0, 0xAA, 0xAA); asm volatile("vmadd.vv v1, v2, v3, v0.t"); VCMP_U64(8, v1, 0x9cffef345b95f00b, 0xad447a1b99a48a53, 0xadfda1d2464c6433, 0x813582af4d75d09e, 0x8a0c6e4bc950e81f, 0x36d90fe4df2f2b2c, 0x27d7ec90ba159756, 0x955c2ac405b724e1, 0xbfd90c33e58a8fe3, 0x10277404741c4ca8, 0x1a7b72dd8ac39fab, 0x58439c4175d7f582, 0x6b01c18a3daf288b, 0xabfe86591f4ba5be, 0x0c059f365ec6d3d5, 0xfb655e2263986563); } void TEST_CASE3() { VSET(16, e8, m1); int64_t scalar = 5; VLOAD_8(v1, 0x60, 0xe3, 0xa0, 0xb7, 0x35, 0x23, 0xa3, 0xf4, 0x5f, 0x6e, 0x07, 0x01, 0xe7, 0x51, 0x53, 0x29); VLOAD_8(v2, 0xfb, 0x1b, 0xc0, 0x36, 0xa7, 0xe0, 0xc8, 0x47, 0x57, 0xe0, 0x51, 0xaa, 0xd2, 0x93, 0x83, 0xa8); asm volatile("vmadd.vx v1, %[A], v2" :: [A] "r" (scalar)); VCMP_U8(9, v1, 0xdb, 0x8a, 0xe0, 0xc9, 0xb0, 0x8f, 0xf7, 0x0b, 0x32, 0x06, 0x74, 0xaf, 0x55, 0x28, 0x22, 0x75); VSET(16, e16, m1); scalar = -5383; VLOAD_16(v1, 0x992e, 0x9a07, 0x90c3, 0xf1ce, 0xd53c, 0x8f07, 0x2d2f, 0x5ab1, 0x0a79, 0x0523, 0x6f34, 0xe5fd, 0xc95a, 0xca1c, 0x36bf, 0x16a1); VLOAD_16(v2, 0x0a9f, 0x7ee0, 0x494e, 0xb6d0, 0x394c, 0xc8e7, 0xc117, 0x8108, 0xb1af, 0x9f16, 0x22ab, 0xa244, 0xf1c9, 0xe363, 0x9bed, 0xa06f); asm volatile("vmadd.vx v1, %[A], v2" :: [A] "r" (scalar)); VCMP_U16(10, v1, 0x145d, 0xb5af, 0x54f9, 0x342e, 0x78a8, 0x4cb6, 0xa9ce, 0x8131, 0x7b60, 0x9c21, 0xd43f, 0x9759, 0x0e53, 0x109f, 0x71b4, 0xcd08); VSET(16, e32, m1); scalar = 6474219; VLOAD_32(v1, 0x709e784e, 0x8e13e48a, 0xad5df7fd, 0x738c8997, 0x0a0030d0, 0x7569b952, 0x507fd5c7, 0x5d09af12, 0x0bf1c209, 0x7be6ed49, 0x842ba667, 0x53360ec0, 0xd85d7415, 0xf20de61f, 0x153e7e16, 0xec5512e4); VLOAD_32(v2, 0xb2436fad, 0x6b162382, 0xd94eebe7, 0x9c43d906, 0xb80f178d, 0x5cf91d42, 0x7764b8a3, 0x6269f72c, 0xb0dff3a6, 0x838d6893, 0xa98a861e, 0x758b63de, 0xde488617, 0x371696ab, 0xc3ba8192, 0x7ca33236); asm volatile("vmadd.vx v1, %[A], v2" :: [A] "r" (scalar)); VCMP_U32(11, v1, 0x8e0d1d47, 0xf29d4830, 0xb5213626, 0xb21bb5a3, 0xbc2f367d, 0x18eb9d88, 0x91c53550, 0x69a6ceb2, 0xc09822e9, 0x66c98b96, 0xf6b125ab, 0xef3fae1e, 0x4c40925e, 0x6b652c20, 0x998385c4, 0x75d88d82); VSET(16, e64, m1); scalar = -598189234597999223; VLOAD_64(v1, 0x2a47beb4fd7729c5, 0x401c187818b15d1e, 0xbbaf5fe50c41f22a, 0x31eaddea171055a9, 0x609cbc4a78316c29, 0xd7bb8f31d8b59d88, 0x97860fd5fba018c0, 0x724cecf178bd2125, 0x866d16f96d3d8b67, 0x56153b0315164a5a, 0x6962bde49e3edf3f, 0x9b3f792bfbf5f343, 0x64cf433b239e7764, 0x583c3a4ae481fef0, 0x217e2df75fcf0d8d, 0x935ac02069fe54ce); VLOAD_64(v2, 0x0dc8fa1b817237e5, 0xc817934370de904d, 0xb015bdbf0f39ec01, 0x3c7e70a75643cce5, 0x80c45834a5026c02, 0xcdf1fcd83b8133a0, 0x9d31b9b802ae2db1, 0xba7e57975c5febf5, 0x8732f75adf268ddb, 0x5ff488a4187bd3f3, 0x6a259fe666091333, 0x5afc4de057de51c4, 0x8a479b7e3558e399, 0xbc21e79022996c26, 0xe2c7432cd7e3e81d, 0xdab377ddbdfb2df7); asm volatile("vmadd.vx v1, %[A], v2" :: [A] "r" (scalar)); VCMP_U64(12, v1, 0x093861b79ac45352, 0xfd3c909decf66b5b, 0x04eb13132ce4267b, 0xb258e6b065bbf956, 0x62775181e33422f3, 0xdc0ae0e371686968, 0xf8db06270cad2c71, 0x6c3cc52cd1fb49c2, 0x41c19c0ac1b5a2fa, 0x8867d35049c7b01d, 0x6d71fe0f35a1feea, 0xace16ac43ec0279f, 0x82faf4a574c9dc1d, 0xa875c9d17e310a96, 0x1f75616001b61192, 0x16ce205f44fb8635); } void TEST_CASE4() { VSET(16, e8, m1); int64_t scalar = 5; VLOAD_8(v1, 0x60, 0xe3, 0xa0, 0xb7, 0x35, 0x23, 0xa3, 0xf4, 0x5f, 0x6e, 0x07, 0x01, 0xe7, 0x51, 0x53, 0x29); VLOAD_8(v2, 0xfb, 0x1b, 0xc0, 0x36, 0xa7, 0xe0, 0xc8, 0x47, 0x57, 0xe0, 0x51, 0xaa, 0xd2, 0x93, 0x83, 0xa8); VLOAD_8(v0, 0xAA, 0xAA); asm volatile("vmadd.vx v1, %[A], v2, v0.t" :: [A] "r" (scalar)); VCMP_U8(13, v1, 0x60, 0x8a, 0xa0, 0xc9, 0x35, 0x8f, 0xa3, 0x0b, 0x5f, 0x06, 0x07, 0xaf, 0xe7, 0x28, 0x53, 0x75); VSET(16, e16, m1); scalar = -5383; VLOAD_16(v1, 0x992e, 0x9a07, 0x90c3, 0xf1ce, 0xd53c, 0x8f07, 0x2d2f, 0x5ab1, 0x0a79, 0x0523, 0x6f34, 0xe5fd, 0xc95a, 0xca1c, 0x36bf, 0x16a1); VLOAD_16(v2, 0x0a9f, 0x7ee0, 0x494e, 0xb6d0, 0x394c, 0xc8e7, 0xc117, 0x8108, 0xb1af, 0x9f16, 0x22ab, 0xa244, 0xf1c9, 0xe363, 0x9bed, 0xa06f); VLOAD_8(v0, 0xAA, 0xAA); asm volatile("vmadd.vx v1, %[A], v2, v0.t" :: [A] "r" (scalar)); VCMP_U16(14, v1, 0x992e, 0xb5af, 0x90c3, 0x342e, 0xd53c, 0x4cb6, 0x2d2f, 0x8131, 0x0a79, 0x9c21, 0x6f34, 0x9759, 0xc95a, 0x109f, 0x36bf, 0xcd08); VSET(16, e32, m1); scalar = 6474219; VLOAD_32(v1, 0x709e784e, 0x8e13e48a, 0xad5df7fd, 0x738c8997, 0x0a0030d0, 0x7569b952, 0x507fd5c7, 0x5d09af12, 0x0bf1c209, 0x7be6ed49, 0x842ba667, 0x53360ec0, 0xd85d7415, 0xf20de61f, 0x153e7e16, 0xec5512e4); VLOAD_32(v2, 0xb2436fad, 0x6b162382, 0xd94eebe7, 0x9c43d906, 0xb80f178d, 0x5cf91d42, 0x7764b8a3, 0x6269f72c, 0xb0dff3a6, 0x838d6893, 0xa98a861e, 0x758b63de, 0xde488617, 0x371696ab, 0xc3ba8192, 0x7ca33236); VLOAD_8(v0, 0xAA, 0xAA); asm volatile("vmadd.vx v1, %[A], v2, v0.t" :: [A] "r" (scalar)); VCMP_U32(15, v1, 0x709e784e, 0xf29d4830, 0xad5df7fd, 0xb21bb5a3, 0x0a0030d0, 0x18eb9d88, 0x507fd5c7, 0x69a6ceb2, 0x0bf1c209, 0x66c98b96, 0x842ba667, 0xef3fae1e, 0xd85d7415, 0x6b652c20, 0x153e7e16, 0x75d88d82); VSET(16, e64, m1); scalar = -598189234597999223; VLOAD_64(v1, 0x2a47beb4fd7729c5, 0x401c187818b15d1e, 0xbbaf5fe50c41f22a, 0x31eaddea171055a9, 0x609cbc4a78316c29, 0xd7bb8f31d8b59d88, 0x97860fd5fba018c0, 0x724cecf178bd2125, 0x866d16f96d3d8b67, 0x56153b0315164a5a, 0x6962bde49e3edf3f, 0x9b3f792bfbf5f343, 0x64cf433b239e7764, 0x583c3a4ae481fef0, 0x217e2df75fcf0d8d, 0x935ac02069fe54ce); VLOAD_64(v2, 0x0dc8fa1b817237e5, 0xc817934370de904d, 0xb015bdbf0f39ec01, 0x3c7e70a75643cce5, 0x80c45834a5026c02, 0xcdf1fcd83b8133a0, 0x9d31b9b802ae2db1, 0xba7e57975c5febf5, 0x8732f75adf268ddb, 0x5ff488a4187bd3f3, 0x6a259fe666091333, 0x5afc4de057de51c4, 0x8a479b7e3558e399, 0xbc21e79022996c26, 0xe2c7432cd7e3e81d, 0xdab377ddbdfb2df7); VLOAD_8(v0, 0xAA, 0xAA); asm volatile("vmadd.vx v1, %[A], v2, v0.t" :: [A] "r" (scalar)); VCMP_U64(16, v1, 0x2a47beb4fd7729c5, 0xfd3c909decf66b5b, 0xbbaf5fe50c41f22a, 0xb258e6b065bbf956, 0x609cbc4a78316c29, 0xdc0ae0e371686968, 0x97860fd5fba018c0, 0x6c3cc52cd1fb49c2, 0x866d16f96d3d8b67, 0x8867d35049c7b01d, 0x6962bde49e3edf3f, 0xace16ac43ec0279f, 0x64cf433b239e7764, 0xa875c9d17e310a96, 0x217e2df75fcf0d8d, 0x16ce205f44fb8635); } int main(void){ INIT_CHECK(); enable_vec(); TEST_CASE1(); TEST_CASE2(); TEST_CASE3(); TEST_CASE4(); EXIT_CHECK(); }
89.684564
339
0.773479
c704e9d6359985922db856cbd7c7994821c553d5
270
h
C
BusinessCard/DLabelCell.h
chuckSaldana/BCard
56f76ec0fbfa130f817c654cd61e634d566c5568
[ "BSD-2-Clause" ]
null
null
null
BusinessCard/DLabelCell.h
chuckSaldana/BCard
56f76ec0fbfa130f817c654cd61e634d566c5568
[ "BSD-2-Clause" ]
null
null
null
BusinessCard/DLabelCell.h
chuckSaldana/BCard
56f76ec0fbfa130f817c654cd61e634d566c5568
[ "BSD-2-Clause" ]
null
null
null
// // DLabelCell.h // Diamond // // Created by Carlos Saldaña Garcia on 23/04/14. // Copyright (c) 2014 Jaguar Labs. All rights reserved. // #import <UIKit/UIKit.h> @interface DLabelCell : UITableViewCell @property (weak, nonatomic) IBOutlet UILabel *label; @end
18
56
0.703704
547eb9941d48b5b5715e620d870095f146dc2268
268
h
C
include/pbm.h
ohnxmath/polynomials
d1cf143b79f7f1f1b0ce40514d19560d5aa38564
[ "MIT" ]
null
null
null
include/pbm.h
ohnxmath/polynomials
d1cf143b79f7f1f1b0ce40514d19560d5aa38564
[ "MIT" ]
null
null
null
include/pbm.h
ohnxmath/polynomials
d1cf143b79f7f1f1b0ce40514d19560d5aa38564
[ "MIT" ]
null
null
null
#ifndef _POLY_BASIC_MATH_H_INC #define _POLY_BASIC_MATH_H_INC #include "polynomial.h" #include "logger.h" #include "math.h" polynomial polynomial_subtract(const polynomial a, const polynomial b); long double polynomial_calc(const polynomial a, long double x); #endif
26.8
71
0.813433
7c0dfd4309c928337911f96e57ed42a9d1ed5899
214
h
C
Example/gcovFlushAdapter/SGViewController.h
chiyun1/gcovFlushAdapter
0d7f273d4425b5ba83eb88d39cda9088c10502ba
[ "MIT" ]
1
2021-10-19T01:53:08.000Z
2021-10-19T01:53:08.000Z
Example/gcovFlushAdapter/SGViewController.h
chiyun1/gcovFlushAdapter
0d7f273d4425b5ba83eb88d39cda9088c10502ba
[ "MIT" ]
1
2021-11-19T08:40:53.000Z
2022-02-25T11:36:52.000Z
Example/gcovFlushAdapter/SGViewController.h
chiyun1/gcovFlushAdapter
0d7f273d4425b5ba83eb88d39cda9088c10502ba
[ "MIT" ]
null
null
null
// // SGViewController.h // gcovFlushAdapter // // Created by chiyun1 on 09/27/2021. // Copyright (c) 2021 chiyun1. All rights reserved. // @import UIKit; @interface SGViewController : UIViewController @end
15.285714
52
0.71028
e65428aa900c66012ecf471a2c127aebbc0dc0ae
1,587
h
C
dependancies/include/gtkmm/giomm/private/tlsconnection_p.h
Illation/synthesizer
da77d55c1c69829bbad76d0c14b9c56a5261b642
[ "MIT" ]
2
2020-03-24T09:46:35.000Z
2020-06-16T01:42:46.000Z
dependancies/include/gtkmm/giomm/private/tlsconnection_p.h
Illation/synthesizer
da77d55c1c69829bbad76d0c14b9c56a5261b642
[ "MIT" ]
null
null
null
dependancies/include/gtkmm/giomm/private/tlsconnection_p.h
Illation/synthesizer
da77d55c1c69829bbad76d0c14b9c56a5261b642
[ "MIT" ]
null
null
null
// Generated by gmmproc 2.52.1 -- DO NOT MODIFY! #ifndef _GIOMM_TLSCONNECTION_P_H #define _GIOMM_TLSCONNECTION_P_H #include <giomm/private/iostream_p.h> #include <glibmm/class.h> namespace Gio { class TlsConnection_Class : public Glib::Class { public: #ifndef DOXYGEN_SHOULD_SKIP_THIS using CppObjectType = TlsConnection; using BaseObjectType = GTlsConnection; using BaseClassType = GTlsConnectionClass; using CppClassParent = IOStream_Class; using BaseClassParent = GIOStreamClass; friend class TlsConnection; #endif /* DOXYGEN_SHOULD_SKIP_THIS */ const Glib::Class& init(); static void class_init_function(void* g_class, void* class_data); static Glib::ObjectBase* wrap_new(GObject*); protected: //Callbacks (default signal handlers): //These will call the *_impl member methods, which will then call the existing default signal callbacks, if any. //You could prevent the original default signal handlers being called by overriding the *_impl method. static gboolean accept_certificate_callback(GTlsConnection* self, GTlsCertificate* p0, GTlsCertificateFlags p1); //Callbacks (virtual functions): static gboolean handshake_vfunc_callback(GTlsConnection* self, GCancellable* cancellable, GError** error); static void handshake_async_vfunc_callback(GTlsConnection* self, int io_priority, GCancellable* cancellable, GAsyncReadyCallback callback, gpointer user_data); static gboolean handshake_finish_vfunc_callback(GTlsConnection* self, GAsyncResult* result, GError** error); }; } // namespace Gio #endif /* _GIOMM_TLSCONNECTION_P_H */
30.519231
161
0.79017
f726aa87ba730ec8986a80e1104caa34cd0a82a0
1,113
h
C
interface/i_str.h
agrigomi/vx-1
a63f931b434b41c0204a8666b8de4c5cb8ef9682
[ "BSD-3-Clause" ]
null
null
null
interface/i_str.h
agrigomi/vx-1
a63f931b434b41c0204a8666b8de4c5cb8ef9682
[ "BSD-3-Clause" ]
null
null
null
interface/i_str.h
agrigomi/vx-1
a63f931b434b41c0204a8666b8de4c5cb8ef9682
[ "BSD-3-Clause" ]
null
null
null
#ifndef __I_STR_H__ #define __I_STR_H__ #include "mgtype.h" #define I_STR "i_str" typedef struct { void (*mem_cpy)(void *dst, void *src, _u32 sz); _s32 (*mem_cmp)(void *, void *, _u32); void (*mem_set)(void *, _u8, _u32); _u32 (*str_len)(_str_t); _s32 (*str_cmp)(_str_t, _str_t); _s32 (*str_ncmp)(_str_t, _str_t, _u32); _u32 (*str_cpy)(_str_t dst, _str_t src, _u32 sz); _u32 (*vsnprintf)(_str_t buf, _u32 sz, _cstr_t fmt, va_list args); _u32 (*snprintf)(_str_t buf, _u32 sz, _cstr_t fmt, ...); _s32 (*find_string)(_str_t text, _str_t str); _str_t (*toupper)(_str_t); _u32 (*str2i)(_str_t str, _s32 sz); void (*trim_left)(_str_t); void (*trim_right)(_str_t); void (*clrspc)(_str_t); _u8 (*div_str)(_str_t str, _str_t p1, _u32 sz_p1, _str_t p2, _u32 sz_p2, _cstr_t div); _u8 (*div_str_ex)(_str_t str, _str_t p1, _u32 sz_p1, _str_t p2, _u32 sz_p2, _cstr_t div, _s8 start_ex, _s8 stop_ex); _u32 (*wildcmp)(_str_t text, _str_t wild); _str_t (*itoa)(_s32 n, _str_t str, _u8 base); _str_t (*uitoa)(_u32 n, _str_t str, _u8 base); _str_t (*ulltoa)(_u64 n, _str_t str, _u8 base); }_i_str_t; #endif
33.727273
117
0.686433
743ea98af783f5c29b5a66ea551f41b48e109435
2,233
h
C
dtool/src/dtoolbase/selectThreadImpl.h
cmarshall108/panda3d-python3
8bea2c0c120b03ec1c9fd179701fdeb7510bb97b
[ "PHP-3.0", "PHP-3.01" ]
3
2020-01-02T08:43:36.000Z
2020-07-05T08:59:02.000Z
dtool/src/dtoolbase/selectThreadImpl.h
cmarshall108/panda3d-python3
8bea2c0c120b03ec1c9fd179701fdeb7510bb97b
[ "PHP-3.0", "PHP-3.01" ]
null
null
null
dtool/src/dtoolbase/selectThreadImpl.h
cmarshall108/panda3d-python3
8bea2c0c120b03ec1c9fd179701fdeb7510bb97b
[ "PHP-3.0", "PHP-3.01" ]
1
2020-03-11T17:38:45.000Z
2020-03-11T17:38:45.000Z
/** * PANDA 3D SOFTWARE * Copyright (c) Carnegie Mellon University. All rights reserved. * * All use of this software is subject to the terms of the revised BSD * license. You should have received a copy of this license along * with this source code in a file named "LICENSE." * * @file selectThreadImpl.h * @author drose * @date 2002-08-09 */ #ifndef SELECTTHREADIMPL_H #define SELECTTHREADIMPL_H #include "dtoolbase.h" /* * This file decides which of the core implementations of the various * threading and locking implementations we should use, based on platform * andor available libraries. This file, along with mutexImpl.h and the * various Mutex implementation classes, are defined in dtool so that some * form of critical-section protection will be available to view low-level * classes like TypeRegistry. Most of the rest of the threading and * synchronization classes are defined in pandasrcexpress. */ // This keyword should be used to mark any variable which is possibly volatile // because multiple threads might contend on it, unprotected by a mutex. It // will be defined out in the non-threaded case. Other uses for volatile (dma // buffers, for instance) should use the regular volatile keyword. #define TVOLATILE volatile #if !defined(HAVE_THREADS) || defined(CPPPARSER) // With threading disabled, use the do-nothing implementation. #define THREAD_DUMMY_IMPL 1 // And the TVOLATILE keyword means nothing in the absence of threads. #undef TVOLATILE #define TVOLATILE #elif defined(SIMPLE_THREADS) // Use the simulated threading library. #define THREAD_SIMPLE_IMPL 1 #undef TVOLATILE #define TVOLATILE #elif defined(WIN32_VC) // In Windows, use the native threading library. #define THREAD_WIN32_IMPL 1 #elif defined(HAVE_POSIX_THREADS) // Posix threads are nice. #define THREAD_POSIX_IMPL 1 #else // This is a configuration error. For some reason, HAVE_THREADS is defined // but we don't have any way to implement it. #error No thread implementation defined for platform. #endif // Let's also factor out some of the other configuration variables. #if defined(DO_PIPELINING) && defined(HAVE_THREADS) #define THREADED_PIPELINE 1 #else #undef THREADED_PIPELINE #endif #endif
29.381579
78
0.771608
747a886dda53f6c94a42a00764119cd29ea0b889
4,776
c
C
src/video/wayland/SDL_waylandkeyboard.c
ARPGLTD/SDL
f3fd1ffb99e44adde00a1c07acfa67a55e2e689e
[ "Zlib" ]
179
2015-02-07T09:24:41.000Z
2022-03-29T14:41:21.000Z
src/video/wayland/SDL_waylandkeyboard.c
ARPGLTD/SDL
f3fd1ffb99e44adde00a1c07acfa67a55e2e689e
[ "Zlib" ]
88
2015-01-24T01:06:28.000Z
2022-03-31T14:40:06.000Z
src/video/wayland/SDL_waylandkeyboard.c
ARPGLTD/SDL
f3fd1ffb99e44adde00a1c07acfa67a55e2e689e
[ "Zlib" ]
72
2018-10-31T13:50:02.000Z
2022-03-14T09:10:35.000Z
/* Simple DirectMedia Layer Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../../SDL_internal.h" #if SDL_VIDEO_DRIVER_WAYLAND #include "../SDL_sysvideo.h" #include "SDL_waylandvideo.h" #include "SDL_waylandevents_c.h" #include "text-input-unstable-v3-client-protocol.h" int Wayland_InitKeyboard(_THIS) { #ifdef SDL_USE_IME SDL_VideoData *driverdata = _this->driverdata; if (driverdata->text_input_manager == NULL) { SDL_IME_Init(); } #endif return 0; } void Wayland_QuitKeyboard(_THIS) { #ifdef SDL_USE_IME SDL_VideoData *driverdata = _this->driverdata; if (driverdata->text_input_manager == NULL) { SDL_IME_Quit(); } #endif } void Wayland_StartTextInput(_THIS) { SDL_VideoData *driverdata = _this->driverdata; if (driverdata->text_input_manager) { struct SDL_WaylandInput *input = driverdata->input; if (input != NULL && input->text_input) { const SDL_Rect *rect = &input->text_input->cursor_rect; /* For some reason this has to be done twice, it appears to be a * bug in mutter? Maybe? * -flibit */ zwp_text_input_v3_enable(input->text_input->text_input); zwp_text_input_v3_commit(input->text_input->text_input); zwp_text_input_v3_enable(input->text_input->text_input); zwp_text_input_v3_commit(input->text_input->text_input); /* Now that it's enabled, set the input properties */ zwp_text_input_v3_set_content_type(input->text_input->text_input, ZWP_TEXT_INPUT_V3_CONTENT_HINT_NONE, ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_NORMAL); if (!SDL_RectEmpty(rect)) { /* This gets reset on enable so we have to cache it */ zwp_text_input_v3_set_cursor_rectangle(input->text_input->text_input, rect->x, rect->y, rect->w, rect->h); } zwp_text_input_v3_commit(input->text_input->text_input); } } } void Wayland_StopTextInput(_THIS) { SDL_VideoData *driverdata = _this->driverdata; if (driverdata->text_input_manager) { struct SDL_WaylandInput *input = driverdata->input; if (input != NULL && input->text_input) { zwp_text_input_v3_disable(input->text_input->text_input); zwp_text_input_v3_commit(input->text_input->text_input); } } #ifdef SDL_USE_IME else { SDL_IME_Reset(); } #endif } void Wayland_SetTextInputRect(_THIS, SDL_Rect *rect) { SDL_VideoData *driverdata = _this->driverdata; if (!rect) { SDL_InvalidParamError("rect"); return; } if (driverdata->text_input_manager) { struct SDL_WaylandInput *input = driverdata->input; if (input != NULL && input->text_input) { SDL_memcpy(&input->text_input->cursor_rect, rect, sizeof(SDL_Rect)); zwp_text_input_v3_set_cursor_rectangle(input->text_input->text_input, rect->x, rect->y, rect->w, rect->h); zwp_text_input_v3_commit(input->text_input->text_input); } } #ifdef SDL_USE_IME else { SDL_IME_UpdateTextRect(rect); } #endif } SDL_bool Wayland_HasScreenKeyboardSupport(_THIS) { SDL_VideoData *driverdata = _this->driverdata; return (driverdata->text_input_manager != NULL); } #endif /* SDL_VIDEO_DRIVER_WAYLAND */ /* vi: set ts=4 sw=4 expandtab: */
31.84
89
0.610343
5968890a63d8a4a099a44c84d7c80d2962973c83
8,264
c
C
src/scene_game/Header.c
fabiopichler/Tic-Tac-Toe
e77b22331a6bd294e4d30d8a9c530bab62326578
[ "MIT" ]
null
null
null
src/scene_game/Header.c
fabiopichler/Tic-Tac-Toe
e77b22331a6bd294e4d30d8a9c530bab62326578
[ "MIT" ]
null
null
null
src/scene_game/Header.c
fabiopichler/Tic-Tac-Toe
e77b22331a6bd294e4d30d8a9c530bab62326578
[ "MIT" ]
null
null
null
//------------------------------------------------------------------------------- // Copyright (c) 2020 Fábio Pichler /*------------------------------------------------------------------------------- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------*/ #include "Header.h" #include "../base/Texture.h" #include <malloc.h> struct Header { const int space; const int margin; const float line_p1_x; const float line_p2_x; SDL_FRect line_rect; SDL_Renderer *renderer; SceneGameRect *rect; Player currentPlayer; Player gameResult; Texture *result; Texture *player1; Texture *player1Icon; Texture *player2; Texture *player2Icon; }; void Header_CreateResultText(Header *const this); void Header_CreatePlayer1Text(Header *const this); void Header_CreatePlayer2Text(Header *const this); void Header_SetupResultText(Header *const this); void Header_SetupPlayer1Text(Header *const this); void Header_SetupPlayer2Text(Header *const this); Header *Header_New(SDL_Renderer *renderer, SceneGameRect *rect) { Header *const this = malloc(sizeof (Header)); *(int *)&this->space = 6; *(int *)&this->margin = 20; const float w = 134; const float x = rect->sidebar_w + ((rect->content_w - w) / 2); *(float *)&this->line_p1_x = x - 85.f; *(float *)&this->line_p2_x = x + 85.f; this->line_rect = (SDL_FRect) {.x = this->line_p1_x, .y = 64.f, .w = w, .h = 4.f}; this->renderer = renderer; this->rect = rect; this->currentPlayer = Player_1; this->gameResult = None; Header_CreateResultText(this); Header_CreatePlayer1Text(this); Header_CreatePlayer2Text(this); return this; } void Header_Delete(Header *const this) { if (!this) return; Texture_Delete(this->result); Texture_Delete(this->player1); Texture_Delete(this->player1Icon); Texture_Delete(this->player2); Texture_Delete(this->player2Icon); free(this); } void Header_ProcessEvent(Header *const this, const SDL_Event *event) { (void)this;(void)event; } void Header_Update(Header *const this, double deltaTime) { for (int i = 0; i < 8; ++i) { if (this->currentPlayer == Player_1 && this->line_rect.x >= this->line_p1_x) this->line_rect.x -= 0.1 * deltaTime; else if (this->currentPlayer == Player_2 && this->line_rect.x <= this->line_p2_x) this->line_rect.x += 0.1 * deltaTime; } } void Header_Draw(Header *const this) { if (this->gameResult == None) { SDL_SetRenderDrawColor(this->renderer, 100, 180, 180, 255); SDL_RenderFillRectF(this->renderer, &this->line_rect); Texture_Draw(this->player1, NULL, NULL); Texture_Draw(this->player1Icon, NULL, NULL); Texture_Draw(this->player2, NULL, NULL); Texture_Draw(this->player2Icon, NULL, NULL); } else { int w = 302; int x = this->rect->sidebar_w + ((this->rect->content_w - w) / 2); SDL_Rect rect = (SDL_Rect) {.x = x, .y = 18, .w = w, .h = 58}; SDL_SetRenderDrawColor(this->renderer, 120, 200, 200, 255); SDL_RenderFillRect(this->renderer, &rect); rect.w -= 2; rect.h -= 2; rect.x -= 2; rect.y -= 2; SDL_SetRenderDrawColor(this->renderer, 230, 240, 240, 255); SDL_RenderFillRect(this->renderer, &rect); Texture_Draw(this->result, NULL, NULL); } } void Header_SetCurrentPlayer(Header *const this, Player currentPlayer, Player gameResult) { this->currentPlayer = currentPlayer; this->gameResult = gameResult; if (this->gameResult == Player_1) Texture_SetText(this->result, "Vitória do jogador 1"); else if (this->gameResult == Player_2) Texture_SetText(this->result, "Vitória do jogador 2"); else if (this->gameResult == Tied) Texture_SetText(this->result, "Deu empate!"); if (this->gameResult != None) { Texture_MakeText(this->result); Header_SetupResultText(this); } } void Header_CreateResultText(Header *const this) { this->result = Texture_New(this->renderer); Texture_SetupText(this->result, "...", 24, &(SDL_Color) {30, 120, 120, 255}); Texture_MakeText(this->result); Header_SetupResultText(this); } void Header_CreatePlayer1Text(Header *const this) { this->player1 = Texture_New(this->renderer); Texture_SetupText(this->player1, "Jogador 1", 20, &(SDL_Color) {30, 120, 120, 255}); Texture_MakeText(this->player1); this->player1Icon = Texture_New(this->renderer); Texture_LoadImageFromFile(this->player1Icon, "images/player_1.png"); Header_SetupPlayer1Text(this); } void Header_CreatePlayer2Text(Header *const this) { this->player2 = Texture_New(this->renderer); Texture_SetupText(this->player2, "Jogador 2", 20, &(SDL_Color) {30, 120, 120, 255}); Texture_MakeText(this->player2); this->player2Icon = Texture_New(this->renderer); Texture_LoadImageFromFile(this->player2Icon, "images/player_2.png"); Header_SetupPlayer2Text(this); } void Header_SetupResultText(Header *const this) { int w = Texture_GetWidth(this->result); int h = Texture_GetHeight(this->result); Texture_SetRect(this->result, &(SDL_Rect) { .x = this->rect->sidebar_w + ((this->rect->content_w - w) / 2), .y = 26, .w = w, .h = h }); } void Header_SetupPlayer1Text(Header *const this) { int text_w = Texture_GetWidth(this->player1); int text_h = Texture_GetHeight(this->player1); int icon_w = 28; int icon_h = 28; int text_x = (this->rect->sidebar_w + ((this->rect->content_w - text_w) / 2)) - (text_w / 2) - this->margin - icon_w - this->space; int icon_x = (this->rect->sidebar_w + ((this->rect->content_w - icon_w) / 2)) - (icon_w / 2) - this->margin; Texture_SetRect(this->player1, &(SDL_Rect) { .x = text_x, .y = 30, .w = text_w, .h = text_h }); Texture_SetRect(this->player1Icon, &(SDL_Rect) { .x = icon_x, .y = 32, .w = icon_w, .h = icon_h }); } void Header_SetupPlayer2Text(Header *const this) { int text_w = Texture_GetWidth(this->player2); int text_h = Texture_GetHeight(this->player2); int icon_w = 26; int icon_h = 26; int text_x = (this->rect->sidebar_w + ((this->rect->content_w - text_w) / 2)) + (text_w / 2) + this->margin + icon_w + this->space; int icon_x = (this->rect->sidebar_w + ((this->rect->content_w - icon_w) / 2)) + (icon_w / 2) + this->margin; Texture_SetRect(this->player2, &(SDL_Rect) { .x = text_x, .y = 30, .w = text_w, .h = text_h }); Texture_SetRect(this->player2Icon, &(SDL_Rect) { .x = icon_x, .y = 33, .w = icon_w, .h = icon_h }); }
32.28125
135
0.604671
59a22369f53eaaedebfad06e28637519fcdd05b4
2,051
h
C
usr/src/uts/sparc/v7/sys/privregs.h
AsahiOS/gate
283d47da4e17a5871d9d575e7ffb81e8f6c52e51
[ "MIT" ]
null
null
null
usr/src/uts/sparc/v7/sys/privregs.h
AsahiOS/gate
283d47da4e17a5871d9d575e7ffb81e8f6c52e51
[ "MIT" ]
null
null
null
usr/src/uts/sparc/v7/sys/privregs.h
AsahiOS/gate
283d47da4e17a5871d9d575e7ffb81e8f6c52e51
[ "MIT" ]
1
2020-12-30T00:04:16.000Z
2020-12-30T00:04:16.000Z
/* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 1986-1999,2002-2003 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #ifndef _SYS_PRIVREGS_H #define _SYS_PRIVREGS_H #ifdef __cplusplus extern "C" { #endif /* * This file is kernel isa dependent. */ /* * This file describes the cpu's privileged register set, and * how the machine state is saved on the stack when a trap occurs. */ #include <v7/sys/psr.h> #include <sys/fsr.h> #ifndef _ASM /* * This structure is only here for compatibility. It is not used by the kernel * and may be removed in a future release. A better way to access this data * is to use gregset_t; see proc(4) and ucontext(3HEAD). */ struct regs { long r_psr; /* processor status register */ long r_pc; /* program counter */ long r_npc; /* next program counter */ long r_y; /* the y register */ long r_g1; /* user global regs */ long r_g2; long r_g3; long r_g4; long r_g5; long r_g6; long r_g7; long r_o0; long r_o1; long r_o2; long r_o3; long r_o4; long r_o5; long r_o6; long r_o7; }; #define r_ps r_psr /* for portablility */ #define r_r0 r_o0 #define r_sp r_o6 #endif /* _ASM */ #ifdef __cplusplus } #endif #endif /* _SYS_PRIVREGS_H */
23.848837
79
0.711848
74d887db0237c94386916f1e629f6ea3c1e5e21c
815
c
C
Zestaw33-rozwiazany-zerowka/Zadanie_3/main.c
Wiktor-Wewe/zadaniaDoKolosaWewe
69519edae6b582bd81b5011871ce38f1e6a2447f
[ "MIT" ]
null
null
null
Zestaw33-rozwiazany-zerowka/Zadanie_3/main.c
Wiktor-Wewe/zadaniaDoKolosaWewe
69519edae6b582bd81b5011871ce38f1e6a2447f
[ "MIT" ]
null
null
null
Zestaw33-rozwiazany-zerowka/Zadanie_3/main.c
Wiktor-Wewe/zadaniaDoKolosaWewe
69519edae6b582bd81b5011871ce38f1e6a2447f
[ "MIT" ]
null
null
null
#include <stdio.h> #include <stdlib.h> struct Osoba { char *imie; int wiek; float wzrost; }; char *funkcja(struct Osoba *tablica, int n) { int najstarszy=0; for(int i=0; i<n; i++) { if(tablica[i].wiek>tablica[najstarszy].wiek) { najstarszy=i; } } return tablica[najstarszy].imie; } int main() { unsigned int n=4; struct Osoba tab[n]; tab[0].imie = "Michal"; tab[0].wiek = 20; tab[0].wzrost = 1.76; tab[1].imie = "Janusz"; tab[1].wiek = 11; tab[1].wzrost = 1.80; tab[2].imie = "Kornel"; tab[2].wiek = 21; tab[2].wzrost = 2.00; tab[3].imie = "Wiktor"; tab[3].wiek = 90S; tab[3].wzrost = 1.20; printf("%s",funkcja(tab,n)); return 0; }
17.717391
53
0.495706
74d9d163017a734701437a1db46cf8218c0a8f50
634
h
C
include/azule/core/Timer.h
ASxa86/azule
9bf89dfc5a80f296b02edd3ac608d9a90e4ea26b
[ "MIT" ]
1
2018-10-19T18:00:19.000Z
2018-10-19T18:00:19.000Z
include/azule/core/Timer.h
ASxa86/azule
9bf89dfc5a80f296b02edd3ac608d9a90e4ea26b
[ "MIT" ]
7
2019-06-13T00:48:55.000Z
2020-05-05T00:18:42.000Z
include/azule/core/Timer.h
ASxa86/AGE
9bf89dfc5a80f296b02edd3ac608d9a90e4ea26b
[ "MIT" ]
null
null
null
#pragma once #include <azule/export.hxx> #include <azule/utilities/Pimpl.h> #include <chrono> namespace azule { /// /// Define a seconds duration using double precision for chrono duration casting. /// typedef std::chrono::duration<double> seconds; /// /// \class Timer /// /// \brief This class manages tracking time. /// /// \date May 16, 2017 /// /// \author Aaron Shelley /// class AZULE_EXPORT Timer { public: Timer(); ~Timer(); /// /// Resets the timer and returns the time since reset() was last called. /// std::chrono::microseconds reset(); private: class Impl; Pimpl<Impl> pimpl; }; }
16.25641
82
0.646688
d379d5172ae96bbf83df9fd4b3ad7065bdc4ba86
2,226
h
C
src/srchilite/colormap.h
lingnand/Helium
d1f8fab6eb5d60e35b3287f6ea35cd1fae71f816
[ "BSD-3-Clause" ]
8
2021-04-16T02:05:54.000Z
2022-03-16T13:56:23.000Z
src/srchilite/colormap.h
lingnand/Helium
d1f8fab6eb5d60e35b3287f6ea35cd1fae71f816
[ "BSD-3-Clause" ]
null
null
null
src/srchilite/colormap.h
lingnand/Helium
d1f8fab6eb5d60e35b3287f6ea35cd1fae71f816
[ "BSD-3-Clause" ]
2
2021-04-17T10:49:58.000Z
2021-07-21T20:39:52.000Z
/* * Copyright (C) 1999-2009 Lorenzo Bettini, http://www.lorenzobettini.it * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #ifndef COLORMAP_H #define COLORMAP_H #include <map> #include <string> #include <boost/shared_ptr.hpp> #include <sstream> using std::map; using std::string; using std::ostringstream; namespace srchilite { /** * Simple map for colors (maps a color constant string to the * corresponding color of the output format) */ class ColorMap: public map<string, string> { protected: /// when no color corresponds to the requested one string default_color; public: /** * Sets the default color * @param d the default color */ void setDefault(const string &d) { default_color = d; } /** * @param key the color we're looking for * @return the color corresponding to the specified key, or the * default color if we don't have the requested key */ const string getColor(const string &key) { const_iterator it = find(key); if (it == end()) return default_color; else return it->second; } /** * Returns a string representation of the map. */ const string toString() const { ostringstream s; for (const_iterator it = begin(); it != end(); ++it) s << "[" << it->first << "]=" << it->second << "\n"; s << "default=" << default_color; return s.str(); } }; /// shared pointer for ColorMap typedef boost::shared_ptr<ColorMap> ColorMapPtr; } #endif // COLORMAP_H
26.819277
73
0.655436
20b8d433fbdc87b089ee20e812edda70a3f217bf
959
c
C
C programming/15.NESTING IF/main.c
idesign0/Programming-Repo
b38ef4cc498da764b4f04c8483f5b6c3e49e249c
[ "MIT" ]
1
2019-10-09T17:03:59.000Z
2019-10-09T17:03:59.000Z
C programming/15.NESTING IF/main.c
idesign0/dhruv.github.io
b38ef4cc498da764b4f04c8483f5b6c3e49e249c
[ "MIT" ]
null
null
null
C programming/15.NESTING IF/main.c
idesign0/dhruv.github.io
b38ef4cc498da764b4f04c8483f5b6c3e49e249c
[ "MIT" ]
null
null
null
#include <stdio.h> #include <stdlib.h> // nesting if basically makes program more interactive // taking example of if statement , we we have done previous time , please check it out if you haven't seen it. int main() { int age; int gender; //if you are using or any other softwere for c , just left one space whenever you are using converging character in scanf, // otherwise your code may not be recognize. printf("what's your age ?\n"); scanf(" %d",&age); printf("what's your gender ? (m/f)\n"); scanf(" %c",&gender); if(age>=18){ // logic 1 printf("you are allowed in Club"); if(gender == 'm'){ printf(" dude"); } if(gender == 'f'){ printf(" lady"); } } if(age<18){ //logic 2 printf("you are not allowed"); } // if you type below value 18 , whole logic 1 will skip and logic 2 will print out. return 0; }
23.390244
126
0.573514
97f2c857048e196caec41eaae9aa9779bd8dfd3f
3,178
c
C
tools/power/cpupower/utils/helpers/amd.c
jainsakshi2395/linux
7ccb860232bb83fb60cd6bcf5aaf0c008d903acb
[ "Linux-OpenIB" ]
5
2020-07-08T01:35:16.000Z
2021-04-12T16:35:29.000Z
tools/power/cpupower/utils/helpers/amd.c
jainsakshi2395/linux
7ccb860232bb83fb60cd6bcf5aaf0c008d903acb
[ "Linux-OpenIB" ]
1
2021-01-27T01:29:47.000Z
2021-01-27T01:29:47.000Z
tools/power/cpupower/utils/helpers/amd.c
jainsakshi2395/linux
7ccb860232bb83fb60cd6bcf5aaf0c008d903acb
[ "Linux-OpenIB" ]
null
null
null
// SPDX-License-Identifier: GPL-2.0 #if defined(__i386__) || defined(__x86_64__) #include <unistd.h> #include <errno.h> #include <stdio.h> #include <stdint.h> #include <pci/pci.h> #include "helpers/helpers.h" #define MSR_AMD_PSTATE_STATUS 0xc0010063 #define MSR_AMD_PSTATE 0xc0010064 #define MSR_AMD_PSTATE_LIMIT 0xc0010061 union core_pstate { /* pre fam 17h: */ struct { unsigned fid:6; unsigned did:3; unsigned vid:7; unsigned res1:6; unsigned nbdid:1; unsigned res2:2; unsigned nbvid:7; unsigned iddval:8; unsigned idddiv:2; unsigned res3:21; unsigned en:1; } pstate; /* since fam 17h: */ struct { unsigned fid:8; unsigned did:6; unsigned vid:8; unsigned iddval:8; unsigned idddiv:2; unsigned res1:31; unsigned en:1; } pstatedef; unsigned long long val; }; static int get_did(union core_pstate pstate) { int t; if (cpupower_cpu_info.caps & CPUPOWER_CAP_AMD_PSTATEDEF) t = pstate.pstatedef.did; else if (cpupower_cpu_info.family == 0x12) t = pstate.val & 0xf; else t = pstate.pstate.did; return t; } static int get_cof(union core_pstate pstate) { int t; int fid, did, cof; did = get_did(pstate); if (cpupower_cpu_info.caps & CPUPOWER_CAP_AMD_PSTATEDEF) { fid = pstate.pstatedef.fid; cof = 200 * fid / did; } else { t = 0x10; fid = pstate.pstate.fid; if (cpupower_cpu_info.family == 0x11) t = 0x8; cof = (100 * (fid + t)) >> did; } return cof; } /* Needs: * cpu -> the cpu that gets evaluated * boost_states -> how much boost states the machines support * * Fills up: * pstates -> a pointer to an array of size MAX_HW_PSTATES * must be initialized with zeros. * All available HW pstates (including boost states) * no -> amount of pstates above array got filled up with * * returns zero on success, -1 on failure */ int decode_pstates(unsigned int cpu, int boost_states, unsigned long *pstates, int *no) { int i, psmax; union core_pstate pstate; unsigned long long val; /* Only read out frequencies from HW if HW Pstate is supported, * otherwise frequencies are exported via ACPI tables. */ if (!(cpupower_cpu_info.caps & CPUPOWER_CAP_AMD_HW_PSTATE)) return -1; if (read_msr(cpu, MSR_AMD_PSTATE_LIMIT, &val)) return -1; psmax = (val >> 4) & 0x7; psmax += boost_states; for (i = 0; i <= psmax; i++) { if (i >= MAX_HW_PSTATES) { fprintf(stderr, "HW pstates [%d] exceeding max [%d]\n", psmax, MAX_HW_PSTATES); return -1; } if (read_msr(cpu, MSR_AMD_PSTATE + i, &pstate.val)) return -1; /* The enabled bit (bit 63) is common for all families */ if (!pstate.pstatedef.en) continue; pstates[i] = get_cof(pstate); } *no = i; return 0; } int amd_pci_get_num_boost_states(int *active, int *states) { struct pci_access *pci_acc; struct pci_dev *device; uint8_t val = 0; *active = *states = 0; device = pci_slot_func_init(&pci_acc, 0x18, 4); if (device == NULL) return -ENODEV; val = pci_read_byte(device, 0x15c); if (val & 3) *active = 1; else *active = 0; *states = (val >> 2) & 7; pci_cleanup(pci_acc); return 0; } #endif /* defined(__i386__) || defined(__x86_64__) */
21.186667
64
0.670548
5aeca6f9b8fd90af38df088eaafdd18f76e563d9
9,439
c
C
src/system/mapper.c
majestic53/nes
5226625c39340486b18e7a66e4f40f8021fe0f3f
[ "MIT" ]
3
2021-03-17T16:53:50.000Z
2022-01-26T12:13:24.000Z
src/system/mapper.c
majestic53/nes
5226625c39340486b18e7a66e4f40f8021fe0f3f
[ "MIT" ]
null
null
null
src/system/mapper.c
majestic53/nes
5226625c39340486b18e7a66e4f40f8021fe0f3f
[ "MIT" ]
null
null
null
/** * NES * Copyright (C) 2021-2022 David Jolly * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "../../include/system/mapper/mapper_0.h" #include "../../include/system/mapper/mapper_1.h" #include "../../include/system/mapper/mapper_4.h" /** * Initialize mapper handler * @param mapper Const pointer to mapper struct * @return NES_SUCC on success, NES_ERR otherwise */ typedef int (*nes_mapper_initialize_hdlr)( __inout nes_mapper_t *mapper ); /** * Interrupt mapper handler * @param mapper Const pointer to mapper struct */ typedef void (*nes_mapper_interrupt_hdlr)( __inout nes_mapper_t *mapper ); /** * Mapper RAM read handler * @param mapper Const pointer to mapper struct * @param type RAM type * @param address RAM address * @return RAM data byte */ typedef uint8_t (*nes_mapper_ram_read_hdlr)( __inout struct nes_mapper_s *mapper, __in int type, __in uint16_t address ); /** * Mapper RAM write handler * @param mapper Const pointer to mapper struct * @param type RAM type * @param address RAM address * @param data RAM data */ typedef void (*nes_mapper_ram_write_hdlr)( __inout struct nes_mapper_s *mapper, __in int type, __in uint16_t address, __in uint8_t data ); /** * Mapper ROM read handler * @param mapper Const pointer to mapper struct * @param type ROM type * @param address ROM address * @return ROM data byte */ typedef uint8_t (*nes_mapper_rom_read_hdlr)( __inout struct nes_mapper_s *mapper, __in int type, __in uint16_t address ); /** * Mapper ROM write handler * @param mapper Const pointer to mapper struct * @param type ROM type * @param address ROM address * @param data ROM data */ typedef void (*nes_mapper_rom_write_hdlr)( __inout struct nes_mapper_s *mapper, __in int type, __in uint16_t address, __in uint8_t data ); /** * Uninitialize mapper handler * @param mapper Const pointer to mapper struct * @return NES_SUCC on success, NES_ERR otherwise */ typedef void (*nes_mapper_uninitialize_hdlr)( __inout nes_mapper_t *mapper ); /** * Mapper context struct */ typedef struct { int type; /* Mapper type */ nes_mapper_initialize_hdlr initialize; /* (Optional) Initialization handler */ nes_mapper_uninitialize_hdlr uninitialize; /* (Optional) Uninitialization handler */ nes_mapper_interrupt_hdlr interrupt; /* (Optional) Interrupt handler */ nes_mapper_ram_read_hdlr ram_read; /* (Optional) RAM read handler */ nes_mapper_ram_write_hdlr ram_write; /* (Optional) RAM write handler */ nes_mapper_rom_read_hdlr rom_read; /* (Optional) ROM read handler */ nes_mapper_rom_write_hdlr rom_write; /* (Optional) ROM write handler */ } nes_mapper_context_t; /** * Mapper contexts */ static const nes_mapper_context_t MAP_CONTEXT[] = { /* Mapper-0 */ { NES_MAP_0, /* Mapper type */ nes_mapper_0_initialize, /* Initialization handler */ NULL, /* Uninitialization handler */ NULL, /* Interrupt handler */ nes_mapper_0_ram_read, /* RAM read handler */ nes_mapper_0_ram_write, /* RAM write handler */ nes_mapper_0_rom_read, /* ROM read handler */ NULL, /* ROM write handler */ }, /* Mapper-1 */ { NES_MAP_1, /* Mapper type */ nes_mapper_1_initialize, /* Initialization handler */ nes_mapper_1_uninitialize, /* Uninitialization handler */ NULL, /* Interrupt handler */ nes_mapper_1_ram_read, /* RAM read handler */ nes_mapper_1_ram_write, /* RAM write handler */ nes_mapper_1_rom_read, /* ROM read handler */ nes_mapper_1_rom_write, /* ROM write handler */ }, /* Mapper-4 */ { NES_MAP_4, /* Mapper type */ nes_mapper_4_initialize, /* Initialization handler */ nes_mapper_4_uninitialize, /* Uninitialization handler */ nes_mapper_4_interrupt, /* Interrupt handler */ nes_mapper_4_ram_read, /* RAM read handler */ nes_mapper_4_ram_write, /* RAM write handler */ nes_mapper_4_rom_read, /* ROM read handler */ nes_mapper_4_rom_write, /* ROM write handler */ }, }; /** * Mapper context count macro */ #define MAP_CONTEXT_COUNT \ sizeof(MAP_CONTEXT) / sizeof(*(MAP_CONTEXT)) #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ static int nes_mapper_context_initialize( __inout nes_mapper_t *mapper ) { int index, result = NES_ERR; const nes_mapper_context_t *context = NULL; for(index = 0; index < MAP_CONTEXT_COUNT; ++index) { context = &MAP_CONTEXT[index]; if((context->type == mapper->type) && context->initialize) { if((result = context->initialize(mapper)) != NES_SUCC) { goto exit; } break; } } if(index == MAP_CONTEXT_COUNT) { result = NES_ERR_SET(NES_ERR, "Unsupported mapper type -- %u", mapper->type); goto exit; } mapper->interrupt_hdlr = context->interrupt; mapper->ram_read_hdlr = context->ram_read; mapper->ram_write_hdlr = context->ram_write; mapper->rom_read_hdlr = context->rom_read; mapper->rom_write_hdlr = context->rom_write; exit: return result; } static void nes_mapper_context_uninitialize( __inout nes_mapper_t *mapper ) { for(int index = 0; index < MAP_CONTEXT_COUNT; ++index) { const nes_mapper_context_t *context = &MAP_CONTEXT[index]; if((context->type == mapper->type) && context->uninitialize) { context->uninitialize(mapper); break; } } mapper->interrupt_hdlr = NULL; mapper->ram_read_hdlr = NULL; mapper->ram_write_hdlr = NULL; mapper->rom_read_hdlr = NULL; mapper->rom_write_hdlr = NULL; } int nes_mapper_initialize( __inout nes_mapper_t *mapper, __in const void *data, __in int length ) { int result; if((result = nes_cartridge_initialize(&mapper->cartridge, data, length)) != NES_SUCC) { goto exit; } mapper->mirror = mapper->cartridge.header->flag_6.mirror; mapper->type = (mapper->cartridge.header->flag_7.type_high << 4) | mapper->cartridge.header->flag_6.type_low; if((result = nes_mapper_context_initialize(mapper)) != NES_SUCC) { goto exit; } exit: return result; } void nes_mapper_interrupt( __inout nes_mapper_t *mapper ) { if(mapper->interrupt_hdlr) { mapper->interrupt_hdlr(mapper); } } uint8_t nes_mapper_read( __inout nes_mapper_t *mapper, __in int type, __in uint16_t address ) { uint8_t result = 0; switch(type) { case NES_RAM_CHR: /* Fall-through */ case NES_RAM_PROG: if(mapper->ram_read_hdlr) { result = mapper->ram_read_hdlr(mapper, type, address); } break; case NES_ROM_CHR: /* Fall-through */ case NES_ROM_PROG: if(mapper->rom_read_hdlr) { result = mapper->rom_read_hdlr(mapper, type, address); } break; default: break; } return result; } void nes_mapper_uninitialize( __inout nes_mapper_t *mapper ) { nes_mapper_context_uninitialize(mapper); nes_cartridge_uninitialize(&mapper->cartridge); memset(mapper, 0, sizeof(*mapper)); } void nes_mapper_write( __inout nes_mapper_t *mapper, __in int type, __in uint16_t address, __in uint8_t data ) { switch(type) { case NES_RAM_CHR: /* Fall-through */ case NES_RAM_PROG: if(mapper->ram_write_hdlr) { mapper->ram_write_hdlr(mapper, type, address, data); } break; case NES_ROM_CHR: /* Fall-through */ case NES_ROM_PROG: if(mapper->rom_write_hdlr) { mapper->rom_write_hdlr(mapper, type, address, data); } break; default: break; } } #ifdef __cplusplus } #endif /* __cplusplus */
27.680352
113
0.633542
de420ccf4c59a1544bb0ba1134d18aca2da6de74
722
h
C
Model/CommonComponent/TableViewCell/OnlyTextViewTableViewCell.h
haomingzhi/Model
0e0d1344f474e2eade3da799aadfccc173960ce7
[ "MIT" ]
1
2018-10-23T07:52:28.000Z
2018-10-23T07:52:28.000Z
Model/CommonComponent/TableViewCell/OnlyTextViewTableViewCell.h
haomingzhi/Model
0e0d1344f474e2eade3da799aadfccc173960ce7
[ "MIT" ]
null
null
null
Model/CommonComponent/TableViewCell/OnlyTextViewTableViewCell.h
haomingzhi/Model
0e0d1344f474e2eade3da799aadfccc173960ce7
[ "MIT" ]
null
null
null
// // OnlyTextViewTableViewCell.h // ChaoLiu // // Created by air on 15/8/6. // Copyright (c) 2015年 ORANLLC_IOS1. All rights reserved. // #import <UIKit/UIKit.h> #import "JYAbstractTableViewCell.h" #import "YYTextView.h" @interface OnlyTextViewTableViewCell : JYAbstractTableViewCell<UITextViewDelegate> //@property(nonatomic,strong)MyTextView *textView; //-(void)setCellData:(NSDictionary *)dataDic; @property (strong, nonatomic) MyTextView *textTv; @property (strong, nonatomic) YYTextView *textYYTv; -(void)setYYTextViewHeight:(CGFloat)h; @property (nonatomic,strong) void (^handleTextViewDidBeginEditing)(id sender); -(void)setLimit:(NSInteger)num; -(void)setHiddenWarn:(BOOL)hidden; -(NSString *)getData; @end
31.391304
82
0.765928
2d35af861a47e17533b8c5b23d8224569286f6db
3,775
h
C
http/http_manager.h
zhangguolian/cpp-framework
47bdf67a9dd917fa25f4c0c1b9e57ea437967497
[ "Apache-2.0" ]
8
2019-06-06T06:20:03.000Z
2022-03-13T23:44:20.000Z
http/http_manager.h
Guolian-Zhang/cpp-framework
47bdf67a9dd917fa25f4c0c1b9e57ea437967497
[ "Apache-2.0" ]
null
null
null
http/http_manager.h
Guolian-Zhang/cpp-framework
47bdf67a9dd917fa25f4c0c1b9e57ea437967497
[ "Apache-2.0" ]
3
2019-12-02T04:06:57.000Z
2021-08-11T14:01:51.000Z
/* * * Copyright 2018 Guolian Zhang. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #pragma once #include <string> #include <map> #include <curl/curl.h> #include <async/async.h> #include <boost/thread/mutex.hpp> namespace http { class HttpRequest; // Http task scheduling class class HttpManager { public: // Callback data when the request is completed struct CallbackData { CallbackData() {} ~CallbackData() {} std::string buffer; std::shared_ptr<http::HttpRequest> request; }; // Request data to be used struct CURLData { CURLData() : curl_(NULL) , headers_(NULL) {} ~CURLData() { if (curl_ != NULL) { curl_easy_cleanup(curl_); curl_ = NULL; } if (headers_ != NULL) { curl_slist_free_all(headers_); headers_ = NULL; } } CURL* curl_; struct curl_slist* headers_; std::string post_data_; }; typedef std::map<std::shared_ptr<HttpRequest>, std::unique_ptr<CURLData>> REQUEST_LIST; typedef std::map<CURL*, CallbackData> CB_DATA_LIST; typedef std::map<curl_socket_t, boost::asio::ip::tcp::socket*> SOCKET_LIST; static HttpManager* GetInstance(); void Start(); void AddHttpRequest(const std::shared_ptr<HttpRequest>& request); void CancelHttpRequest(const std::shared_ptr<HttpRequest>& request); private: HttpManager(); ~HttpManager(); void HttpRequestComplete(CURLMsg* msg); CURLData* CreateCURLData(const std::shared_ptr<HttpRequest>& request); static int multi_timer_cb(CURLM* multi, long timeout_ms); static void timer_cb(); static int sock_cb(CURL* easy, curl_socket_t sock, int what, void* cbp, void* sockp); static void addsock(curl_socket_t sock, CURL* easy, int action); static void setsock(int* fdp, curl_socket_t sock, CURL* easy, int act, int oldact); static void remsock(int* fdp); static void event_cb(curl_socket_t s, int action, const boost::system::error_code& error, int* fdp); static curl_socket_t opensocket(void* clientp, curlsocktype purpose, struct curl_sockaddr* address); static int close_socket(void* clientp, curl_socket_t sock); static size_t write_cb(void* buffer, size_t size, size_t count, void* stream); static void check_multi_info(); private: bool is_running_; int still_running_; CURLM* curl_m_; async::Timer timer_; std::shared_ptr<async::Thread> thread_; REQUEST_LIST request_list_; CB_DATA_LIST callback_data_list_; SOCKET_LIST socket_list_; static HttpManager* http_manager_; }; }; // namespace http
29.724409
91
0.576159
f6b61610af4c1be2fee08f97edc27f8af22bb2d7
1,472
c
C
srcs/hud/crosshair.c
nde-jesu/Doom_Nukem
f91176a7634dd2122af7a17952bc8937d05192e4
[ "MIT" ]
2
2020-03-09T17:40:25.000Z
2021-04-09T06:37:06.000Z
srcs/hud/crosshair.c
nde-jesu/Doom_Nukem
f91176a7634dd2122af7a17952bc8937d05192e4
[ "MIT" ]
4
2020-03-10T23:24:50.000Z
2020-08-30T22:00:10.000Z
srcs/hud/crosshair.c
nde-jesu/Doom_Nukem
f91176a7634dd2122af7a17952bc8937d05192e4
[ "MIT" ]
3
2020-03-09T17:40:27.000Z
2022-01-06T08:43:59.000Z
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* crosshair.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: kibotrel <kibotrel@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/14 08:00:56 by kibotrel #+# #+# */ /* Updated: 2020/03/06 10:20:54 by reda-con ### ########.fr */ /* */ /* ************************************************************************** */ #include "structs.h" void negative(SDL_Surface *win, t_pos p) { int *pixel; pixel = win->pixels + p.y * win->pitch + p.x * win->format->BytesPerPixel; *pixel = ~*pixel; } void crosshair(t_env *env) { t_pos p; p.y = env->h / 2 - 11; while (++p.y < env->h / 2 + 11) { p.x = env->w / 2 - 2; while (++p.x < env->w / 2 + 2) negative(env->sdl.screen, p); } p.y = env->h / 2 - 2; while (++p.y < env->h / 2 + 2) { p.x = env->w / 2 - 11; while (++p.x < env->w / 2 + 11) if (p.x < env->w / 2 - 1 || p.x > env->w / 2 + 1) negative(env->sdl.screen, p); } }
34.232558
80
0.264946
0cbcc67ad3667d059faa781ded19546b29f34ad4
351
h
C
libraries/Controller/Controller.h
osulacam/Battlebot
40afbb60b810f92e0e98af9d958cb603c1bf3124
[ "Apache-2.0" ]
null
null
null
libraries/Controller/Controller.h
osulacam/Battlebot
40afbb60b810f92e0e98af9d958cb603c1bf3124
[ "Apache-2.0" ]
null
null
null
libraries/Controller/Controller.h
osulacam/Battlebot
40afbb60b810f92e0e98af9d958cb603c1bf3124
[ "Apache-2.0" ]
null
null
null
#pragma once #include <PID.h> #include <TimerOne.h> class Controller { private: double rVel; double lVel; double angle; double vel; double lastVel; double acc; PID pidr; PID pidl; public: Controller(PID pidr, PID pidl); void update(double rotS, double vScale,double curVel, double angleAdjust); void drive(double curVel); };
17.55
76
0.703704
5675d483ebe1aa3d5f7211eee7264abbed5bca15
794
c
C
7. Pyramid/7.44.c
Imran4424/C-Problems-and-Solutions-step-by-step
26d0af7a73b61b1c0113b63595fc286d125493ef
[ "MIT" ]
5
2018-11-11T13:51:54.000Z
2021-08-07T19:29:29.000Z
7. Pyramid/7.44.c
Imran4424/C-Problems-and-Solutions-step-by-step
26d0af7a73b61b1c0113b63595fc286d125493ef
[ "MIT" ]
null
null
null
7. Pyramid/7.44.c
Imran4424/C-Problems-and-Solutions-step-by-step
26d0af7a73b61b1c0113b63595fc286d125493ef
[ "MIT" ]
2
2019-02-17T14:18:30.000Z
2020-06-03T11:52:01.000Z
/** 7.44. Write a complete C++ program that asks the user for a number n and prints n squares made of ∗ symbols each with an upward diagonal stripe made of O symbols. Each square has height n and width n and the squares form a horizontal sequence. For example, if the user specified 4 for n, the program would print as follows: ***O ***O ***O ***O **O* **O* **O* **O* *O** *O** *O** *O** O*** O*** O*** O*** */ #include <stdio.h> int main(int argc, char const *argv[]) { int n; printf("Enter the value of n - "); scanf("%d", &n); printf("\n\n"); for (int r = 1; r <= n; r++) { for (int c = 1; c <= n * n; c++) { if ((c + r - 1) % n == 0) { printf("0"); } else { printf("*"); } if(c % n == 0) { printf(" "); } } printf("\n"); } return 0; }
20.358974
101
0.530227
bcb11fe70ab6277d5695737216aa76b4b13ef6f9
1,263
h
C
apiwdbe/WdbeQUsrMNUsergroup.h
mpsitech/wdbe-WhizniumDBE
27360ce6569dc55098a248b8a0a4b7e3913a6ce6
[ "MIT" ]
4
2020-10-27T14:33:25.000Z
2021-08-07T20:55:42.000Z
apiwdbe/WdbeQUsrMNUsergroup.h
mpsitech/wdbe-WhizniumDBE
27360ce6569dc55098a248b8a0a4b7e3913a6ce6
[ "MIT" ]
null
null
null
apiwdbe/WdbeQUsrMNUsergroup.h
mpsitech/wdbe-WhizniumDBE
27360ce6569dc55098a248b8a0a4b7e3913a6ce6
[ "MIT" ]
null
null
null
/** * \file WdbeQUsrMNUsergroup.h * API code for table TblWdbeQUsrMNUsergroup (declarations) * \copyright (C) 2016-2020 MPSI Technologies GmbH * \author Alexander Wirthmueller (auto-generation) * \date created: 5 Dec 2020 */ // IP header --- ABOVE #ifndef WDBEQUSRMNUSERGROUP_H #define WDBEQUSRMNUSERGROUP_H #include <sbecore/Xmlio.h> /** * WdbeQUsrMNUsergroup */ class WdbeQUsrMNUsergroup { public: WdbeQUsrMNUsergroup(const Sbecore::uint jnum = 0, const std::string stubMref = "", const std::string srefIxWdbeVUserlevel = "", const std::string titIxWdbeVUserlevel = ""); public: Sbecore::uint jnum; std::string stubMref; std::string srefIxWdbeVUserlevel; std::string titIxWdbeVUserlevel; public: bool readXML(xmlXPathContext* docctx, std::string basexpath = "", bool addbasetag = false); }; /** * ListWdbeQUsrMNUsergroup */ class ListWdbeQUsrMNUsergroup { public: ListWdbeQUsrMNUsergroup(); ListWdbeQUsrMNUsergroup(const ListWdbeQUsrMNUsergroup& src); ListWdbeQUsrMNUsergroup& operator=(const ListWdbeQUsrMNUsergroup& src); ~ListWdbeQUsrMNUsergroup(); void clear(); public: std::vector<WdbeQUsrMNUsergroup*> nodes; public: bool readXML(xmlXPathContext* docctx, std::string basexpath = "", bool addbasetag = false); }; #endif
23.388889
173
0.754553
299dd8dadc95cad69f2704a48ec7dafd00e820bd
827
h
C
src/rendering/engine-Vk/engine-impl/instance.h
Bargor/tempest
94837c6dcfef036827076446101e59afb7792f5d
[ "Apache-2.0", "MIT" ]
null
null
null
src/rendering/engine-Vk/engine-impl/instance.h
Bargor/tempest
94837c6dcfef036827076446101e59afb7792f5d
[ "Apache-2.0", "MIT" ]
1
2019-12-02T20:17:52.000Z
2019-12-02T20:17:52.000Z
src/rendering/engine-Vk/engine-impl/instance.h
Bargor/tempest
94837c6dcfef036827076446101e59afb7792f5d
[ "Apache-2.0", "MIT" ]
null
null
null
// This file is part of Tempest-engine project // Author: Karol Kontny #pragma once #include <vulkan/vulkan.hpp> #include <vector> namespace tst { namespace engine { namespace vulkan { class instance { friend class engine; friend class device; public: static const instance& get_instance() noexcept; static std::vector<const char*> get_validation_layers() noexcept; public: const vk::Instance& get_instance_handle() const noexcept; private: instance(std::vector<const char*>&& requiredValidationLayers); ~instance(); private: vk::Instance m_instance; vk::DebugUtilsMessengerEXT m_debugMessenger; }; } // namespace vulkan } // namespace engine } // namespace tst
24.323529
77
0.619105
293fdcd897292e2bae702ab61cfebfbe51ae5fa6
82
h
C
ios/Pods/Headers/Private/FirebaseInstanceID/FIRInstanceIDTokenFetchOperation.h
rudylee/expo
b3e65a7a5b205f14a3eb6cd6fa8d13c8d663b1cc
[ "Apache-2.0", "MIT" ]
169
2018-04-24T19:47:32.000Z
2019-04-16T12:04:49.000Z
ios/Pods/Headers/Private/FirebaseInstanceID/FIRInstanceIDTokenFetchOperation.h
rudylee/expo
b3e65a7a5b205f14a3eb6cd6fa8d13c8d663b1cc
[ "Apache-2.0", "MIT" ]
659
2018-04-23T20:40:43.000Z
2019-04-18T14:13:22.000Z
ios/Pods/Headers/Private/FirebaseInstanceID/FIRInstanceIDTokenFetchOperation.h
rudylee/expo
b3e65a7a5b205f14a3eb6cd6fa8d13c8d663b1cc
[ "Apache-2.0", "MIT" ]
149
2019-04-10T19:01:58.000Z
2022-03-12T13:27:07.000Z
../../../FirebaseInstanceID/Firebase/InstanceID/FIRInstanceIDTokenFetchOperation.h
82
82
0.841463
347e2769a1d8f8b3ee1663d43036b6b1ff62f2fc
223
h
C
SwipeTableViewDemo/SwipeTableViewDemo/MainViewController.h
Eenie-Meenie/SwipeTableViewDemo
f96ad2671fb377f30903d911fec46e9f29cdd849
[ "Apache-2.0" ]
null
null
null
SwipeTableViewDemo/SwipeTableViewDemo/MainViewController.h
Eenie-Meenie/SwipeTableViewDemo
f96ad2671fb377f30903d911fec46e9f29cdd849
[ "Apache-2.0" ]
null
null
null
SwipeTableViewDemo/SwipeTableViewDemo/MainViewController.h
Eenie-Meenie/SwipeTableViewDemo
f96ad2671fb377f30903d911fec46e9f29cdd849
[ "Apache-2.0" ]
null
null
null
// // MainViewController.h // SwipeTableViewDemo // // Created by hanbo on 2018/9/28. // Copyright © 2018年 hanbo. All rights reserved. // #import <UIKit/UIKit.h> @interface MainViewController : UIViewController @end
15.928571
49
0.713004
f60eae5c060e1922b7757e250598a273d103fd98
402
h
C
CWin/CWin/window/child_window.h
benbraide/CWin
0441b48a71fef0dbddabf61033d7286669772c1e
[ "MIT" ]
null
null
null
CWin/CWin/window/child_window.h
benbraide/CWin
0441b48a71fef0dbddabf61033d7286669772c1e
[ "MIT" ]
null
null
null
CWin/CWin/window/child_window.h
benbraide/CWin
0441b48a71fef0dbddabf61033d7286669772c1e
[ "MIT" ]
null
null
null
#pragma once #include "window_object.h" namespace cwin::window{ class child : public object{ public: explicit child(ui::surface &parent); child(ui::surface &parent, std::size_t index); virtual ~child(); protected: child(); virtual bool changing_parent_(tree *value) override; }; } namespace cwin::ui{ template <> struct parent_type<window::child>{ using value = surface; }; }
14.888889
54
0.691542