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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
708c2d70b41993595940f6cc06c10e44eb269e41 | 510 | h | C | include/ed/convex_hull.h | tue-robotics/ed | 3ce42e4898ae3677b043d9448a47210d0b676124 | [
"BSD-2-Clause"
] | 44 | 2015-01-16T16:52:09.000Z | 2022-02-11T16:06:49.000Z | include/ed/convex_hull.h | tue-robotics/ed | 3ce42e4898ae3677b043d9448a47210d0b676124 | [
"BSD-2-Clause"
] | 69 | 2015-01-07T15:03:12.000Z | 2022-02-14T14:09:47.000Z | include/ed/convex_hull.h | tue-robotics/ed | 3ce42e4898ae3677b043d9448a47210d0b676124 | [
"BSD-2-Clause"
] | 18 | 2015-02-26T11:31:17.000Z | 2021-09-25T08:29:02.000Z | #ifndef ED_CONVEX_HULL_H_
#define ED_CONVEX_HULL_H_
#include <geolib/datatypes.h>
#include <vector>
namespace ed
{
struct ConvexHull
{
std::vector<geo::Vec2f> points;
std::vector<geo::Vec2f> edges;
std::vector<geo::Vec2f> normals;
float z_min, z_max;
float area; // is calculated based on points
bool complete;
ConvexHull() : area(0), complete(false) {}
double height() const { return z_max - z_min; }
double volume() const { return height() * area; }
};
}
#endif
| 16.451613 | 53 | 0.662745 |
7016b4e587982aae32ac38faea3dce1735c7ce9e | 1,833 | h | C | opensource/libomxil-bellagio/src/extension_struct.h | Obighbyd/android_device_samsung_golden | b9dc79c14525c14165390f38f5db1a521f55980d | [
"Apache-2.0"
] | 1 | 2019-03-04T21:36:55.000Z | 2019-03-04T21:36:55.000Z | opensource/libomxil-bellagio/src/extension_struct.h | Obighbyd/android_device_samsung_golden | b9dc79c14525c14165390f38f5db1a521f55980d | [
"Apache-2.0"
] | null | null | null | opensource/libomxil-bellagio/src/extension_struct.h | Obighbyd/android_device_samsung_golden | b9dc79c14525c14165390f38f5db1a521f55980d | [
"Apache-2.0"
] | null | null | null | /**
src/extension_struct.h
This file will include all the extension structures defined in Bellagio
and not present in the OpenMAX spec. These structure will be used
with the function getExtensionIndex defined in the standard.
Copyright (C) 2009 STMicroelectronics
Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 2.1 of the License, or (at your option)
any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA
*/
#ifndef EXTENSION_STRUCT_H_
#define EXTENSION_STRUCT_H_
/** This structure is threaded like a parameter with the
* extension index OMX_IndexParameterThreadsID
*/
typedef struct OMX_PARAM_BELLAGIOTHREADS_ID {
OMX_U32 nSize; /**< Size of the structure in bytes */
OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
long int nThreadBufferMngtID; /**< @param nThreadBufferMngtID the linux thread ID of the buffer management thread*/\
long int nThreadMessageID; /**< @param nThreadMessageID the linux thread ID of the message handler thread*/\
} OMX_PARAM_BELLAGIOTHREADS_ID;
typedef struct multiResourceDescriptor {
int CPUResourceRequested;
int MemoryResourceRequested;
} multiResourceDescriptor;
#endif
| 39 | 117 | 0.772504 |
2ad2abb80c7d8951a1a6b431abd3abda7473f554 | 23,502 | c | C | my_results_phase_5/my_results_phase_4_implementation/slprj/_sfprj/MPC_AVC_implementation/_self/sfun/src/c3_MPC_AVC_implementation.c | attaoveisi/MPC | 2de08ea788daf490abde61280d011b5062352481 | [
"BSD-2-Clause"
] | 2 | 2021-01-10T10:54:18.000Z | 2021-10-30T10:40:48.000Z | my_results_phase_5/my_results_phase_4_implementation/slprj/_sfprj/MPC_AVC_implementation/_self/sfun/src/c3_MPC_AVC_implementation.c | wuyou33/MPC-1 | 2de08ea788daf490abde61280d011b5062352481 | [
"BSD-2-Clause"
] | null | null | null | my_results_phase_5/my_results_phase_4_implementation/slprj/_sfprj/MPC_AVC_implementation/_self/sfun/src/c3_MPC_AVC_implementation.c | wuyou33/MPC-1 | 2de08ea788daf490abde61280d011b5062352481 | [
"BSD-2-Clause"
] | 3 | 2021-02-17T05:12:33.000Z | 2021-07-22T14:26:13.000Z | /* Include files */
#include "MPC_AVC_implementation_sfun.h"
#include "c3_MPC_AVC_implementation.h"
#define CHARTINSTANCE_CHARTNUMBER (chartInstance.chartNumber)
#define CHARTINSTANCE_INSTANCENUMBER (chartInstance.instanceNumber)
#include "MPC_AVC_implementation_sfun_debug_macros.h"
/* Type Definitions */
/* Named Constants */
#define c3_IN_NO_ACTIVE_CHILD (0)
/* Variable Declarations */
/* Variable Definitions */
static SFc3_MPC_AVC_implementationInstanceStruct chartInstance;
/* Function Declarations */
static void initialize_c3_MPC_AVC_implementation(void);
static void initialize_params_c3_MPC_AVC_implementation(void);
static void enable_c3_MPC_AVC_implementation(void);
static void disable_c3_MPC_AVC_implementation(void);
static void finalize_c3_MPC_AVC_implementation(void);
static void sf_c3_MPC_AVC_implementation(void);
static void init_script_number_translation(uint32_T c3_machineNumber, uint32_T
c3_chartNumber);
static const mxArray *c3_sf_marshall(void *c3_chartInstance, void *c3_u);
static const mxArray *c3_b_sf_marshall(void *c3_chartInstance, void *c3_u);
static const mxArray *c3_c_sf_marshall(void *c3_chartInstance, void *c3_u);
static void init_dsm_address_info(void);
/* Function Definitions */
static void initialize_c3_MPC_AVC_implementation(void)
{
_sfTime_ = (real_T)ssGetT(chartInstance.S);
chartInstance.c3_is_active_c3_MPC_AVC_implementation = 0U;
}
static void initialize_params_c3_MPC_AVC_implementation(void)
{
}
static void enable_c3_MPC_AVC_implementation(void)
{
_sfTime_ = (real_T)ssGetT(chartInstance.S);
}
static void disable_c3_MPC_AVC_implementation(void)
{
_sfTime_ = (real_T)ssGetT(chartInstance.S);
}
static void finalize_c3_MPC_AVC_implementation(void)
{
}
static void sf_c3_MPC_AVC_implementation(void)
{
int32_T c3_i0;
int32_T c3_i1;
int32_T c3_i2;
uint8_T c3_previousEvent;
int32_T c3_i3;
int32_T c3_i4;
static real_T c3_Lf[449982];
real_T c3_kk;
real_T c3_nargout = 1.0;
real_T c3_nargin = 2.0;
real_T c3_kk1;
real_T c3_y[18];
real_T c3_x;
real_T c3_b_x;
int32_T c3_b_kk1;
int32_T c3_i5;
int32_T c3_hoistedExpr;
int32_T c3_i6;
real_T *c3_b_kk;
real_T (*c3_b_y)[18];
real_T (*c3_b_Lf)[449982];
c3_b_y = (real_T (*)[18])ssGetOutputPortSignal(chartInstance.S, 1);
c3_b_kk = (real_T *)ssGetInputPortSignal(chartInstance.S, 1);
c3_b_Lf = (real_T (*)[449982])ssGetInputPortSignal(chartInstance.S, 0);
_sfTime_ = (real_T)ssGetT(chartInstance.S);
_SFD_CC_CALL(CHART_ENTER_SFUNCTION_TAG,1);
for (c3_i0 = 0; c3_i0 < 18; c3_i0 = c3_i0 + 1) {
_SFD_DATA_RANGE_CHECK((*c3_b_y)[c3_i0], 0U);
}
for (c3_i1 = 0; c3_i1 < 24999; c3_i1 = c3_i1 + 1) {
for (c3_i2 = 0; c3_i2 < 18; c3_i2 = c3_i2 + 1) {
_SFD_DATA_RANGE_CHECK((*c3_b_Lf)[c3_i2 + 18 * c3_i1], 1U);
}
}
_SFD_DATA_RANGE_CHECK(*c3_b_kk, 2U);
c3_previousEvent = _sfEvent_;
_sfEvent_ = CALL_EVENT;
_SFD_CC_CALL(CHART_ENTER_DURING_FUNCTION_TAG,1);
for (c3_i3 = 0; c3_i3 < 24999; c3_i3 = c3_i3 + 1) {
for (c3_i4 = 0; c3_i4 < 18; c3_i4 = c3_i4 + 1) {
c3_Lf[c3_i4 + 18 * c3_i3] = (*c3_b_Lf)[c3_i4 + 18 * c3_i3];
}
}
c3_kk = *c3_b_kk;
sf_debug_symbol_scope_push(6U, 0U);
sf_debug_symbol_scope_add_verbose("nargout", 0, 0U, 0U, 0U, 0U, 1.0, 0, 0.0,
0U, 0, 0U, 0, 0, &c3_nargout);
sf_debug_symbol_scope_add_verbose("nargin", 0, 0U, 0U, 0U, 0U, 1.0, 0, 0.0, 0U,
0, 0U, 0, 0, &c3_nargin);
sf_debug_symbol_scope_add("kk1", &c3_kk1, c3_b_sf_marshall);
sf_debug_symbol_scope_add("y", &c3_y, c3_c_sf_marshall);
sf_debug_symbol_scope_add("kk", &c3_kk, c3_b_sf_marshall);
sf_debug_symbol_scope_add("Lf", &c3_Lf, c3_sf_marshall);
CV_EML_FCN(0, 0);
_SFD_EML_CALL(0,4);
c3_x = c3_kk;
c3_b_x = c3_x;
c3_b_x = floor(c3_b_x);
c3_kk1 = c3_b_x + 1.0;
_SFD_EML_CALL(0,6);
c3_b_kk1 = (int32_T)_SFD_EML_ARRAY_BOUNDS_CHECK("Lf", (int32_T)
_SFD_INTEGER_CHECK("kk1", c3_kk1), 1, 24999, 2, 0) - 1;
for (c3_i5 = 0; c3_i5 < 18; c3_i5 = c3_i5 + 1) {
c3_hoistedExpr = 0;
c3_y[c3_i5] = c3_Lf[c3_i5 + 18 * c3_b_kk1];
}
_SFD_EML_CALL(0,-6);
sf_debug_symbol_scope_pop();
for (c3_i6 = 0; c3_i6 < 18; c3_i6 = c3_i6 + 1) {
(*c3_b_y)[c3_i6] = c3_y[c3_i6];
}
_SFD_CC_CALL(EXIT_OUT_OF_FUNCTION_TAG,1);
_sfEvent_ = c3_previousEvent;
sf_debug_check_for_state_inconsistency(_MPC_AVC_implementationMachineNumber_,
chartInstance.chartNumber, chartInstance.
instanceNumber);
}
static void init_script_number_translation(uint32_T c3_machineNumber, uint32_T
c3_chartNumber)
{
}
static const mxArray *c3_sf_marshall(void *c3_chartInstance, void *c3_u)
{
const mxArray *c3_y = NULL;
int32_T c3_i7;
int32_T c3_i8;
static real_T c3_b_u[449982];
const mxArray *c3_b_y = NULL;
c3_y = NULL;
for (c3_i7 = 0; c3_i7 < 24999; c3_i7 = c3_i7 + 1) {
for (c3_i8 = 0; c3_i8 < 18; c3_i8 = c3_i8 + 1) {
c3_b_u[c3_i8 + 18 * c3_i7] = (*((real_T (*)[449982])c3_u))[c3_i8 + 18 *
c3_i7];
}
}
c3_b_y = NULL;
sf_mex_assign(&c3_b_y, sf_mex_create(&c3_b_u, "y", 0, 0U, 1U, 2, 18, 24999));
sf_mex_assign(&c3_y, c3_b_y);
return c3_y;
}
static const mxArray *c3_b_sf_marshall(void *c3_chartInstance, void *c3_u)
{
const mxArray *c3_y = NULL;
real_T c3_b_u;
const mxArray *c3_b_y = NULL;
c3_y = NULL;
c3_b_u = *((real_T *)c3_u);
c3_b_y = NULL;
sf_mex_assign(&c3_b_y, sf_mex_create(&c3_b_u, "y", 0, 0U, 0U, 0));
sf_mex_assign(&c3_y, c3_b_y);
return c3_y;
}
static const mxArray *c3_c_sf_marshall(void *c3_chartInstance, void *c3_u)
{
const mxArray *c3_y = NULL;
int32_T c3_i9;
real_T c3_b_u[18];
const mxArray *c3_b_y = NULL;
c3_y = NULL;
for (c3_i9 = 0; c3_i9 < 18; c3_i9 = c3_i9 + 1) {
c3_b_u[c3_i9] = (*((real_T (*)[18])c3_u))[c3_i9];
}
c3_b_y = NULL;
sf_mex_assign(&c3_b_y, sf_mex_create(&c3_b_u, "y", 0, 0U, 1U, 1, 18));
sf_mex_assign(&c3_y, c3_b_y);
return c3_y;
}
const mxArray *sf_c3_MPC_AVC_implementation_get_eml_resolved_functions_info(void)
{
const mxArray *c3_nameCaptureInfo = NULL;
c3_ResolvedFunctionInfo c3_info[11];
c3_ResolvedFunctionInfo (*c3_b_info)[11];
const mxArray *c3_m0 = NULL;
int32_T c3_i10;
c3_ResolvedFunctionInfo *c3_r0;
c3_nameCaptureInfo = NULL;
c3_b_info = (c3_ResolvedFunctionInfo (*)[11])c3_info;
(*c3_b_info)[0].context =
"[I]$matlabroot$/toolbox/eml/lib/matlab/elfun/floor.m";
(*c3_b_info)[0].name = "eml_assert";
(*c3_b_info)[0].dominantType = "char";
(*c3_b_info)[0].resolved = "[B]eml_assert";
(*c3_b_info)[0].fileLength = 0U;
(*c3_b_info)[0].fileTime1 = 0U;
(*c3_b_info)[0].fileTime2 = 0U;
(*c3_b_info)[1].context =
"[I]$matlabroot$/toolbox/eml/lib/matlab/elfun/floor.m";
(*c3_b_info)[1].name = "isempty";
(*c3_b_info)[1].dominantType = "double";
(*c3_b_info)[1].resolved = "[B]isempty";
(*c3_b_info)[1].fileLength = 0U;
(*c3_b_info)[1].fileTime1 = 0U;
(*c3_b_info)[1].fileTime2 = 0U;
(*c3_b_info)[2].context =
"[I]$matlabroot$/toolbox/eml/lib/matlab/elfun/floor.m";
(*c3_b_info)[2].name = "isa";
(*c3_b_info)[2].dominantType = "double";
(*c3_b_info)[2].resolved = "[B]isa";
(*c3_b_info)[2].fileLength = 0U;
(*c3_b_info)[2].fileTime1 = 0U;
(*c3_b_info)[2].fileTime2 = 0U;
(*c3_b_info)[3].context = "";
(*c3_b_info)[3].name = "floor";
(*c3_b_info)[3].dominantType = "double";
(*c3_b_info)[3].resolved =
"[I]$matlabroot$/toolbox/eml/lib/matlab/elfun/floor.m";
(*c3_b_info)[3].fileLength = 550U;
(*c3_b_info)[3].fileTime1 = 1192466686U;
(*c3_b_info)[3].fileTime2 = 0U;
(*c3_b_info)[4].context =
"[I]$matlabroot$/toolbox/eml/lib/matlab/elfun/floor.m";
(*c3_b_info)[4].name = "isinteger";
(*c3_b_info)[4].dominantType = "double";
(*c3_b_info)[4].resolved = "[B]isinteger";
(*c3_b_info)[4].fileLength = 0U;
(*c3_b_info)[4].fileTime1 = 0U;
(*c3_b_info)[4].fileTime2 = 0U;
(*c3_b_info)[5].context = "";
(*c3_b_info)[5].name = "plus";
(*c3_b_info)[5].dominantType = "double";
(*c3_b_info)[5].resolved = "[B]plus";
(*c3_b_info)[5].fileLength = 0U;
(*c3_b_info)[5].fileTime1 = 0U;
(*c3_b_info)[5].fileTime2 = 0U;
(*c3_b_info)[6].context =
"[I]$matlabroot$/toolbox/eml/lib/matlab/elfun/floor.m";
(*c3_b_info)[6].name = "isscalar";
(*c3_b_info)[6].dominantType = "double";
(*c3_b_info)[6].resolved = "[B]isscalar";
(*c3_b_info)[6].fileLength = 0U;
(*c3_b_info)[6].fileTime1 = 0U;
(*c3_b_info)[6].fileTime2 = 0U;
(*c3_b_info)[7].context =
"[I]$matlabroot$/toolbox/eml/lib/matlab/elfun/floor.m";
(*c3_b_info)[7].name = "class";
(*c3_b_info)[7].dominantType = "double";
(*c3_b_info)[7].resolved = "[B]class";
(*c3_b_info)[7].fileLength = 0U;
(*c3_b_info)[7].fileTime1 = 0U;
(*c3_b_info)[7].fileTime2 = 0U;
(*c3_b_info)[8].context =
"[I]$matlabroot$/toolbox/eml/lib/matlab/elfun/floor.m";
(*c3_b_info)[8].name = "nargin";
(*c3_b_info)[8].dominantType = "";
(*c3_b_info)[8].resolved = "[B]nargin";
(*c3_b_info)[8].fileLength = 0U;
(*c3_b_info)[8].fileTime1 = 0U;
(*c3_b_info)[8].fileTime2 = 0U;
(*c3_b_info)[9].context =
"[I]$matlabroot$/toolbox/eml/lib/matlab/elfun/floor.m";
(*c3_b_info)[9].name = "gt";
(*c3_b_info)[9].dominantType = "double";
(*c3_b_info)[9].resolved = "[B]gt";
(*c3_b_info)[9].fileLength = 0U;
(*c3_b_info)[9].fileTime1 = 0U;
(*c3_b_info)[9].fileTime2 = 0U;
(*c3_b_info)[10].context =
"[I]$matlabroot$/toolbox/eml/lib/matlab/elfun/floor.m";
(*c3_b_info)[10].name = "isreal";
(*c3_b_info)[10].dominantType = "double";
(*c3_b_info)[10].resolved = "[B]isreal";
(*c3_b_info)[10].fileLength = 0U;
(*c3_b_info)[10].fileTime1 = 0U;
(*c3_b_info)[10].fileTime2 = 0U;
sf_mex_assign(&c3_m0, sf_mex_createstruct("nameCaptureInfo", 1, 11));
for (c3_i10 = 0; c3_i10 < 11; c3_i10 = c3_i10 + 1) {
c3_r0 = &c3_info[c3_i10];
sf_mex_addfield(c3_m0, sf_mex_create(c3_r0->context, "nameCaptureInfo", 13,
0U, 0U, 2, 1, strlen(c3_r0->context)), "context",
"nameCaptureInfo", c3_i10);
sf_mex_addfield(c3_m0, sf_mex_create(c3_r0->name, "nameCaptureInfo", 13, 0U,
0U, 2, 1, strlen(c3_r0->name)), "name",
"nameCaptureInfo", c3_i10);
sf_mex_addfield(c3_m0, sf_mex_create(c3_r0->dominantType, "nameCaptureInfo",
13, 0U, 0U, 2, 1, strlen(c3_r0->dominantType)),
"dominantType", "nameCaptureInfo", c3_i10);
sf_mex_addfield(c3_m0, sf_mex_create(c3_r0->resolved, "nameCaptureInfo", 13,
0U, 0U, 2, 1, strlen(c3_r0->resolved)), "resolved",
"nameCaptureInfo", c3_i10);
sf_mex_addfield(c3_m0, sf_mex_create(&c3_r0->fileLength, "nameCaptureInfo",
7, 0U, 0U, 0), "fileLength", "nameCaptureInfo", c3_i10);
sf_mex_addfield(c3_m0, sf_mex_create(&c3_r0->fileTime1, "nameCaptureInfo", 7,
0U, 0U, 0), "fileTime1", "nameCaptureInfo", c3_i10);
sf_mex_addfield(c3_m0, sf_mex_create(&c3_r0->fileTime2, "nameCaptureInfo", 7,
0U, 0U, 0), "fileTime2", "nameCaptureInfo", c3_i10);
}
sf_mex_assign(&c3_nameCaptureInfo, c3_m0);
return c3_nameCaptureInfo;
}
static void init_dsm_address_info(void)
{
}
/* SFunction Glue Code */
void sf_c3_MPC_AVC_implementation_get_check_sum(mxArray *plhs[])
{
((real_T *)mxGetPr((plhs[0])))[0] = (real_T)(1491425345U);
((real_T *)mxGetPr((plhs[0])))[1] = (real_T)(2507247845U);
((real_T *)mxGetPr((plhs[0])))[2] = (real_T)(2554905763U);
((real_T *)mxGetPr((plhs[0])))[3] = (real_T)(3954667797U);
}
mxArray *sf_c3_MPC_AVC_implementation_get_autoinheritance_info(void)
{
const char *autoinheritanceFields[] = { "checksum", "inputs", "parameters",
"outputs" };
mxArray *mxAutoinheritanceInfo = mxCreateStructMatrix(1,1,4,
autoinheritanceFields);
{
mxArray *mxChecksum = mxCreateDoubleMatrix(4,1,mxREAL);
double *pr = mxGetPr(mxChecksum);
pr[0] = (double)(2619459419U);
pr[1] = (double)(2829857596U);
pr[2] = (double)(4218653047U);
pr[3] = (double)(2606182936U);
mxSetField(mxAutoinheritanceInfo,0,"checksum",mxChecksum);
}
{
const char *dataFields[] = { "size", "type", "complexity" };
mxArray *mxData = mxCreateStructMatrix(1,2,3,dataFields);
{
mxArray *mxSize = mxCreateDoubleMatrix(1,2,mxREAL);
double *pr = mxGetPr(mxSize);
pr[0] = (double)(18);
pr[1] = (double)(24999);
mxSetField(mxData,0,"size",mxSize);
}
{
const char *typeFields[] = { "base", "aliasId", "fixpt" };
mxArray *mxType = mxCreateStructMatrix(1,1,3,typeFields);
mxSetField(mxType,0,"base",mxCreateDoubleScalar(10));
mxSetField(mxType,0,"aliasId",mxCreateDoubleScalar(0));
mxSetField(mxType,0,"fixpt",mxCreateDoubleMatrix(0,0,mxREAL));
mxSetField(mxData,0,"type",mxType);
}
mxSetField(mxData,0,"complexity",mxCreateDoubleScalar(0));
{
mxArray *mxSize = mxCreateDoubleMatrix(1,2,mxREAL);
double *pr = mxGetPr(mxSize);
pr[0] = (double)(1);
pr[1] = (double)(1);
mxSetField(mxData,1,"size",mxSize);
}
{
const char *typeFields[] = { "base", "aliasId", "fixpt" };
mxArray *mxType = mxCreateStructMatrix(1,1,3,typeFields);
mxSetField(mxType,0,"base",mxCreateDoubleScalar(10));
mxSetField(mxType,0,"aliasId",mxCreateDoubleScalar(0));
mxSetField(mxType,0,"fixpt",mxCreateDoubleMatrix(0,0,mxREAL));
mxSetField(mxData,1,"type",mxType);
}
mxSetField(mxData,1,"complexity",mxCreateDoubleScalar(0));
mxSetField(mxAutoinheritanceInfo,0,"inputs",mxData);
}
{
mxSetField(mxAutoinheritanceInfo,0,"parameters",mxCreateDoubleMatrix(0,0,
mxREAL));
}
{
const char *dataFields[] = { "size", "type", "complexity" };
mxArray *mxData = mxCreateStructMatrix(1,1,3,dataFields);
{
mxArray *mxSize = mxCreateDoubleMatrix(1,2,mxREAL);
double *pr = mxGetPr(mxSize);
pr[0] = (double)(18);
pr[1] = (double)(1);
mxSetField(mxData,0,"size",mxSize);
}
{
const char *typeFields[] = { "base", "aliasId", "fixpt" };
mxArray *mxType = mxCreateStructMatrix(1,1,3,typeFields);
mxSetField(mxType,0,"base",mxCreateDoubleScalar(10));
mxSetField(mxType,0,"aliasId",mxCreateDoubleScalar(0));
mxSetField(mxType,0,"fixpt",mxCreateDoubleMatrix(0,0,mxREAL));
mxSetField(mxData,0,"type",mxType);
}
mxSetField(mxData,0,"complexity",mxCreateDoubleScalar(0));
mxSetField(mxAutoinheritanceInfo,0,"outputs",mxData);
}
return(mxAutoinheritanceInfo);
}
static void chart_debug_initialization(SimStruct *S, unsigned int
fullDebuggerInitialization)
{
if (ssIsFirstInitCond(S) && fullDebuggerInitialization==1) {
/* do this only if simulation is starting */
if (!sim_mode_is_rtw_gen(S)) {
{
unsigned int chartAlreadyPresent;
chartAlreadyPresent = sf_debug_initialize_chart
(_MPC_AVC_implementationMachineNumber_,
3,
1,
1,
3,
0,
0,
0,
0,
0,
&(chartInstance.chartNumber),
&(chartInstance.instanceNumber),
ssGetPath(S),
(void *)S);
if (chartAlreadyPresent==0) {
/* this is the first instance */
init_script_number_translation(_MPC_AVC_implementationMachineNumber_,
chartInstance.chartNumber);
sf_debug_set_chart_disable_implicit_casting
(_MPC_AVC_implementationMachineNumber_,chartInstance.chartNumber,1);
sf_debug_set_chart_event_thresholds
(_MPC_AVC_implementationMachineNumber_,
chartInstance.chartNumber,
0,
0,
0);
{
unsigned int dimVector[1];
dimVector[0]= 18;
_SFD_SET_DATA_PROPS(0,2,0,1,SF_DOUBLE,1,&(dimVector[0]),0,0,0,0.0,
1.0,0,"y",0,c3_c_sf_marshall);
}
{
unsigned int dimVector[2];
dimVector[0]= 18;
dimVector[1]= 24999;
_SFD_SET_DATA_PROPS(1,1,1,0,SF_DOUBLE,2,&(dimVector[0]),0,0,0,0.0,
1.0,0,"Lf",0,c3_sf_marshall);
}
_SFD_SET_DATA_PROPS(2,1,1,0,SF_DOUBLE,0,NULL,0,0,0,0.0,1.0,0,"kk",0,
c3_b_sf_marshall);
_SFD_STATE_INFO(0,0,2);
_SFD_CH_SUBSTATE_COUNT(0);
_SFD_CH_SUBSTATE_DECOMP(0);
}
_SFD_CV_INIT_CHART(0,0,0,0);
{
_SFD_CV_INIT_STATE(0,0,0,0,0,0,NULL,NULL);
}
_SFD_CV_INIT_TRANS(0,0,NULL,NULL,0,NULL);
/* Initialization of EML Model Coverage */
_SFD_CV_INIT_EML(0,1,0,0,0,0,0,0);
_SFD_CV_INIT_EML_FCN(0,0,"eML_blk_kernel",0,-1,65);
_SFD_TRANS_COV_WTS(0,0,0,1,0);
if (chartAlreadyPresent==0) {
_SFD_TRANS_COV_MAPS(0,
0,NULL,NULL,
0,NULL,NULL,
1,NULL,NULL,
0,NULL,NULL);
}
{
real_T (*c3_y)[18];
real_T (*c3_Lf)[449982];
real_T *c3_kk;
c3_y = (real_T (*)[18])ssGetOutputPortSignal(chartInstance.S, 1);
c3_kk = (real_T *)ssGetInputPortSignal(chartInstance.S, 1);
c3_Lf = (real_T (*)[449982])ssGetInputPortSignal(chartInstance.S, 0);
_SFD_SET_DATA_VALUE_PTR(0U, c3_y);
_SFD_SET_DATA_VALUE_PTR(1U, c3_Lf);
_SFD_SET_DATA_VALUE_PTR(2U, c3_kk);
}
}
}
} else {
sf_debug_reset_current_state_configuration
(_MPC_AVC_implementationMachineNumber_,chartInstance.chartNumber,
chartInstance.instanceNumber);
}
}
static void sf_opaque_initialize_c3_MPC_AVC_implementation(void
*chartInstanceVar)
{
chart_debug_initialization(chartInstance.S,0);
initialize_params_c3_MPC_AVC_implementation();
initialize_c3_MPC_AVC_implementation();
}
static void sf_opaque_enable_c3_MPC_AVC_implementation(void *chartInstanceVar)
{
enable_c3_MPC_AVC_implementation();
}
static void sf_opaque_disable_c3_MPC_AVC_implementation(void *chartInstanceVar)
{
disable_c3_MPC_AVC_implementation();
}
static void sf_opaque_gateway_c3_MPC_AVC_implementation(void *chartInstanceVar)
{
sf_c3_MPC_AVC_implementation();
}
static void sf_opaque_terminate_c3_MPC_AVC_implementation(void *chartInstanceVar)
{
if (sim_mode_is_rtw_gen(chartInstance.S) || sim_mode_is_external
(chartInstance.S)) {
sf_clear_rtw_identifier(chartInstance.S);
}
finalize_c3_MPC_AVC_implementation();
}
extern unsigned int sf_machine_global_initializer_called(void);
static void mdlProcessParameters_c3_MPC_AVC_implementation(SimStruct *S)
{
int i;
for (i=0;i<ssGetNumRunTimeParams(S);i++) {
if (ssGetSFcnParamTunable(S,i)) {
ssUpdateDlgParamAsRunTimeParam(S,i);
}
}
if (sf_machine_global_initializer_called()) {
initialize_params_c3_MPC_AVC_implementation();
}
}
static void mdlSetWorkWidths_c3_MPC_AVC_implementation(SimStruct *S)
{
if (sim_mode_is_rtw_gen(S) || sim_mode_is_external(S)) {
int_T chartIsInlinable =
(int_T)sf_is_chart_inlinable("MPC_AVC_implementation",
"MPC_AVC_implementation",3);
ssSetStateflowIsInlinable(S,chartIsInlinable);
ssSetRTWCG(S,sf_rtw_info_uint_prop("MPC_AVC_implementation",
"MPC_AVC_implementation",3,"RTWCG"));
ssSetEnableFcnIsTrivial(S,1);
ssSetDisableFcnIsTrivial(S,1);
ssSetNotMultipleInlinable(S,sf_rtw_info_uint_prop("MPC_AVC_implementation",
"MPC_AVC_implementation",3,"gatewayCannotBeInlinedMultipleTimes"));
if (chartIsInlinable) {
ssSetInputPortOptimOpts(S, 0, SS_REUSABLE_AND_LOCAL);
ssSetInputPortOptimOpts(S, 1, SS_REUSABLE_AND_LOCAL);
sf_mark_chart_expressionable_inputs(S,"MPC_AVC_implementation",
"MPC_AVC_implementation",3,2);
sf_mark_chart_reusable_outputs(S,"MPC_AVC_implementation",
"MPC_AVC_implementation",3,1);
}
sf_set_rtw_dwork_info(S,"MPC_AVC_implementation","MPC_AVC_implementation",3);
ssSetHasSubFunctions(S,!(chartIsInlinable));
ssSetOptions(S,ssGetOptions(S)|SS_OPTION_WORKS_WITH_CODE_REUSE);
}
ssSetChecksum0(S,(4277455476U));
ssSetChecksum1(S,(2642450727U));
ssSetChecksum2(S,(2301620889U));
ssSetChecksum3(S,(275257670U));
ssSetmdlDerivatives(S, NULL);
ssSetExplicitFCSSCtrl(S,1);
}
static void mdlRTW_c3_MPC_AVC_implementation(SimStruct *S)
{
if (sim_mode_is_rtw_gen(S)) {
sf_write_symbol_mapping(S, "MPC_AVC_implementation",
"MPC_AVC_implementation",3);
ssWriteRTWStrParam(S, "StateflowChartType", "Embedded MATLAB");
}
}
static void mdlStart_c3_MPC_AVC_implementation(SimStruct *S)
{
chartInstance.chartInfo.chartInstance = NULL;
chartInstance.chartInfo.isEMLChart = 1;
chartInstance.chartInfo.chartInitialized = 0;
chartInstance.chartInfo.sFunctionGateway =
sf_opaque_gateway_c3_MPC_AVC_implementation;
chartInstance.chartInfo.initializeChart =
sf_opaque_initialize_c3_MPC_AVC_implementation;
chartInstance.chartInfo.terminateChart =
sf_opaque_terminate_c3_MPC_AVC_implementation;
chartInstance.chartInfo.enableChart =
sf_opaque_enable_c3_MPC_AVC_implementation;
chartInstance.chartInfo.disableChart =
sf_opaque_disable_c3_MPC_AVC_implementation;
chartInstance.chartInfo.zeroCrossings = NULL;
chartInstance.chartInfo.outputs = NULL;
chartInstance.chartInfo.derivatives = NULL;
chartInstance.chartInfo.mdlRTW = mdlRTW_c3_MPC_AVC_implementation;
chartInstance.chartInfo.mdlStart = mdlStart_c3_MPC_AVC_implementation;
chartInstance.chartInfo.mdlSetWorkWidths =
mdlSetWorkWidths_c3_MPC_AVC_implementation;
chartInstance.chartInfo.extModeExec = NULL;
chartInstance.chartInfo.restoreLastMajorStepConfiguration = NULL;
chartInstance.chartInfo.restoreBeforeLastMajorStepConfiguration = NULL;
chartInstance.chartInfo.storeCurrentConfiguration = NULL;
chartInstance.S = S;
ssSetUserData(S,(void *)(&(chartInstance.chartInfo)));/* register the chart instance with simstruct */
if (!sim_mode_is_rtw_gen(S)) {
init_dsm_address_info();
}
chart_debug_initialization(S,1);
}
void c3_MPC_AVC_implementation_method_dispatcher(SimStruct *S, int_T method,
void *data)
{
switch (method) {
case SS_CALL_MDL_START:
mdlStart_c3_MPC_AVC_implementation(S);
break;
case SS_CALL_MDL_SET_WORK_WIDTHS:
mdlSetWorkWidths_c3_MPC_AVC_implementation(S);
break;
case SS_CALL_MDL_PROCESS_PARAMETERS:
mdlProcessParameters_c3_MPC_AVC_implementation(S);
break;
default:
/* Unhandled method */
sf_mex_error_message("Stateflow Internal Error:\n"
"Error calling c3_MPC_AVC_implementation_method_dispatcher.\n"
"Can't handle method %d.\n", method);
break;
}
}
| 34.309489 | 105 | 0.660752 |
f21b8989035ea8688796c7476fcd31c26ce1a5f6 | 777 | c | C | grade-of-a-student/main.c | KabirKr/Basic-c-programs | 706c8bfe870e8d6c2e13e13e7db369de352ef235 | [
"MIT"
] | null | null | null | grade-of-a-student/main.c | KabirKr/Basic-c-programs | 706c8bfe870e8d6c2e13e13e7db369de352ef235 | [
"MIT"
] | null | null | null | grade-of-a-student/main.c | KabirKr/Basic-c-programs | 706c8bfe870e8d6c2e13e13e7db369de352ef235 | [
"MIT"
] | null | null | null | /* Show total mark, parcentage and grade of a student */
#include <stdio.h>
#include <conio.h>
int main()
{
int sub1, sub2, sub3, sub4, sub5, totalMark, percentage;
printf("Enter the numbers of five subjects: ");
scanf("%d %d %d %d %d", &sub1, &sub2, &sub3, &sub3, &sub4, &sub5);
totalMark = sub1 + sub2 + sub3 + sub4 + sub5;
percentage = totalMark / 5;
printf("Your total mark is %d \n", totalMark);
printf("Your percentage is %d \n", percentage);
// Grades
if (percentage >= 60)
{
printf("Grade A");
}
else if (percentage >= 45)
{
printf("Grade B");
}
else if (percentage >= 30)
{
printf("Grade C");
}
else
{
printf("Fail");
}
getch();
return 0;
}
| 19.425 | 70 | 0.537967 |
a8bbc3cdf427f853a43d9565e9c1d7e2a9b0339a | 6,023 | h | C | vpg/CombinedComposer.h | intel/hwc- | 3617c208959bd7c865021dd0d0bc69a94c804f99 | [
"Apache-2.0"
] | null | null | null | vpg/CombinedComposer.h | intel/hwc- | 3617c208959bd7c865021dd0d0bc69a94c804f99 | [
"Apache-2.0"
] | null | null | null | vpg/CombinedComposer.h | intel/hwc- | 3617c208959bd7c865021dd0d0bc69a94c804f99 | [
"Apache-2.0"
] | null | null | null | /*
// Copyright (c) 2017 Intel Corporation
//
// 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 INTEL_UFO_HWC_COMBINEDCOMPOSER_H
#define INTEL_UFO_HWC_COMBINEDCOMPOSER_H
#include "AbstractComposer.h"
#include <utils/Vector.h>
#include "CompositionManager.h"
namespace intel {
namespace ufo {
namespace hwc {
// Originally, every composition utilize one composer to do composition, here the composer is shared and not need any private data.
// But after combined composer is introduced, 2 or more compositions will be created in the combined composer,
// the sub-compositions' data should be stored in the combined composer, but considering that the combined composer should also be shared by multiple compositions,
// different compositions (using the same combined composer) have the different subCompositions in the combined composer.
// So we have to allocate a class in composition to store private data of combined composer and also pass it to combined composer when use this composer.
// CombinedComposerCompositionState is used for store sub-composition state
//
// TODO: better and more flexible CombinedComposerCompositionState define
class CombinedComposerCompositionState : public AbstractComposer::CompositionState
{
public:
CombinedComposerCompositionState( uint32_t subCompositionNum ):
mLayerCnt(0), mbLocked(false)
{
mSubCompositions.resize(subCompositionNum);
}
virtual ~CombinedComposerCompositionState()
{
unlock();
mSubCompositions.clear();
mLayerList.clear();
}
void lock( void )
{
ALOG_ASSERT( !mbLocked );
for ( uint32_t sc = 0; sc < mSubCompositions.size(); ++sc )
{
CompositionManager::getInstance().lockComposition( mSubCompositions[sc].mComposition );
}
mbLocked = true;
}
void unlock( void )
{
if ( mbLocked )
{
for ( uint32_t sc = 0; sc < mSubCompositions.size(); ++sc )
{
CompositionManager::getInstance().unlockComposition( mSubCompositions[sc].mComposition );
}
mbLocked = false;
}
}
class SubComposition
{
public:
SubComposition(): mComposition(NULL){};
~SubComposition(){}
AbstractComposition *mComposition; // SubComposition of combined composer.
Content::LayerStack mSrcLayerStack; // Input layer to the subComposition, which is split from the parent composition's input layer.
};
public:
Vector<SubComposition> mSubCompositions; // SubComposition vector.
std::vector<Layer> mLayerList; // Store the layer stack since input layer stack need to be modified in same case.
uint32_t mLayerCnt; // Input layer count of combined composer.
bool mbLocked:1; // Have the subcompositions been locked down?
};
class CombinedComposer : public AbstractComposer
{
public:
CombinedComposer():mbReentering(false) {}
~CombinedComposer(){}
virtual const char* getName() const = 0;
// Evaluate this combined composer:
// It will return dynamically allocated state block, which will be freed if this composer is not the best one.
//
// 1. preprocess input layerstack and setup composition chain:
// 1). Decide how many compositions will be used for the first stage.
// 2). Decide how to distribute layers into different compositions
// For example: there are 5 layers, layer 0~4
// For Widi 2 stage composer:
// First stage:
// layer 0~4 ==> firstStageCompositions[0] ==> RT0
// Second stage:
// RT0 ==> secondStageComposition ==> RT (NV12)
//
// For low loss composer("high quality frame for low resolution"):
// First stage:
// layer 0~4 ==> modify layers' destination parameters to make it do 1:1 composition
// ==> firstStageCompositions[0] ==> RT0
// Second stage:
// RT0 ==> modify RT0's destination parameters to match RT's so to do downscaling
// ==> secondStageComposition ==> RT
//
// Generic model: layer0~4 ' RT
// First stage:
// layer 0~1 ==> modify layer parameters if need ==> firstStageCompositions[0] ==> RT0
// layer 2~3 ==> modify layer parameters if need ==> firstStageCompositions[1] ==> RT1
// Second stage:
// RT0, RT1, layer 4 ==> modify layer parameters if need ==> secondStageComposition ==> RT
//
// 2. request composition.
// 1) request firstStageCompositions
// 2) request secondStageComposition
// 3. Get the cost for this composer
virtual float onEvaluate(const Content::LayerStack& src, const Layer& target, AbstractComposer::CompositionState** ppState, Cost type = Power) = 0;
virtual void onCompose(const Content::LayerStack& src, const Layer& target, AbstractComposer::CompositionState* pState ) = 0;
public:
// TODO: Better method to protect against re-entrancy.
bool mbReentering; // Is onEvaluate() reentering? It used to avoid nest calling onEvaluate().
};
}; // namespace hwc
}; // namespace ufo
}; // namespace intel
#endif // INTEL_UFO_HWC_VPPCOMPOSER_H
| 41.537931 | 163 | 0.647684 |
4ae00bcebafe9c48cc4e3e02b842df5a93473e94 | 395 | h | C | GameIntegration/Game.h | AdiBaby/NetworkingGame | 31b3ec1acd3711bdb43c609a74076e0650dea642 | [
"FSFAP"
] | null | null | null | GameIntegration/Game.h | AdiBaby/NetworkingGame | 31b3ec1acd3711bdb43c609a74076e0650dea642 | [
"FSFAP"
] | null | null | null | GameIntegration/Game.h | AdiBaby/NetworkingGame | 31b3ec1acd3711bdb43c609a74076e0650dea642 | [
"FSFAP"
] | null | null | null | #pragma once
#include "Map.h"
namespace Game
{
extern std::vector<Object*> objects;
extern BioMap::map_t map;
void main();
typedef enum
{
OBJT_DUDE,
OBJT_CITY,
OBJT_STRUCTURE,
} ObjectType;
struct Object
{
uint8_t x;
uint8_t y;
virtual bool autoUpdate();
virtual bool move();
virtual bool destroy();
virtual bool update();
};
}; | 12.34375 | 38 | 0.612658 |
2f44977d198797726b8d9942951bf1184bdfd76f | 222 | c | C | 1387/main.c | maateusx/UriOnlineJudge | cf1cd27684520af2e7b959b7469393ceaee1bb1f | [
"MIT"
] | null | null | null | 1387/main.c | maateusx/UriOnlineJudge | cf1cd27684520af2e7b959b7469393ceaee1bb1f | [
"MIT"
] | null | null | null | 1387/main.c | maateusx/UriOnlineJudge | cf1cd27684520af2e7b959b7469393ceaee1bb1f | [
"MIT"
] | null | null | null | #include <stdio.h>
#include <stdlib.h>
int main()
{
int l, r, n=1;
while(n!=0)
{
scanf("%d %d", &l, &r);
if(l==0 && r==0)
break;
printf("%d\n", l+r);
}
return 0;
}
| 13.058824 | 31 | 0.382883 |
9e38980d6aeafe9cbea1db47e901881eeed0d5ba | 1,183 | c | C | ioctl/ioctl.c | arshad512/lkb | 6d2d3c554d6b1d275853b4c9e350619cee8a775d | [
"MIT"
] | 2 | 2021-08-13T10:13:20.000Z | 2021-08-13T10:13:26.000Z | ioctl/ioctl.c | arshad512/lkb | 6d2d3c554d6b1d275853b4c9e350619cee8a775d | [
"MIT"
] | null | null | null | ioctl/ioctl.c | arshad512/lkb | 6d2d3c554d6b1d275853b4c9e350619cee8a775d | [
"MIT"
] | 3 | 2020-03-06T08:53:43.000Z | 2021-08-18T21:19:16.000Z | #include <sys/types.h>
#include <sys/mman.h> /* mmap */
#include <err.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/ioctl.h>
/*
* Arshad Hussain <arshad.super@gmail.com
*/
#define DEVICE "/dev/mmapchar"
#define QUERY_GET_VARIABLES _IOR('q', 1, int *)
#define QUERY_CLR_VARIABLES _IO('q', 2)
#define QUERY_SET_VARIABLES _IOW('q', 3, int *)
int main(void)
{
int fd;
int q = 0;
/* This will call driver's open method */
fd = open(DEVICE, O_RDWR);
if (fd < 0) {
/*
* Do check, backend mmap driver is loaded
*/
printf("open failed\n");
printf("make sure insmod code.ko is done\n");
return -1;
}
/*
* Read
*/
#if 0
if (ioctl(fd, QUERY_GET_VARIABLES, &q) == -1)
{
perror("query_apps ioctl get");
}
printf("five ... done...%d\n",q);
if (ioctl(fd, QUERY_CLR_VARIABLES, &q) == -1)
{
perror("query_apps ioctl get");
}
printf("five ... done...CLR\n");
#endif
/*
* Write
*/
q = 140;
if (ioctl(fd, QUERY_SET_VARIABLES, &q) == -1)
{
perror("error ioctl get");
}
printf("five ... done...SET\n");
/* This will call driver's release method */
close(fd);
return 0;
}
| 17.144928 | 47 | 0.610313 |
7faea630a17742368eeda4889c51474cfb091763 | 7,057 | c | C | LibSource/mpfr/tests/tai.c | ekzyis/CrypTool-2 | 1af234b4f74486fbfeb3b3c49228cc36533a8c89 | [
"Apache-2.0"
] | 12 | 2021-09-29T14:50:06.000Z | 2022-03-31T15:01:21.000Z | LibSource/mpfr/tests/tai.c | ekzyis/CrypTool-2 | 1af234b4f74486fbfeb3b3c49228cc36533a8c89 | [
"Apache-2.0"
] | 15 | 2021-12-24T22:53:49.000Z | 2021-12-25T10:03:13.000Z | LibSource/mpfr/tests/tai.c | ekzyis/CrypTool-2 | 1af234b4f74486fbfeb3b3c49228cc36533a8c89 | [
"Apache-2.0"
] | 10 | 2021-10-17T19:46:51.000Z | 2022-03-18T02:57:57.000Z | /* Test file for mpfr_ai.
Copyright 2010-2019 Free Software Foundation, Inc.
Contributed by the AriC and Caramba projects, INRIA.
This file is part of the GNU MPFR Library.
The GNU MPFR Library is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 3 of the License, or (at your
option) any later version.
The GNU MPFR Library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the GNU MPFR Library; see the file COPYING.LESSER. If not, see
https://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */
#include "mpfr-test.h"
#define TEST_FUNCTION mpfr_ai
#define TEST_RANDOM_EMIN -5
#define TEST_RANDOM_EMAX 5
#define REDUCE_EMAX 7 /* this is to avoid that test_generic() calls mpfr_ai
with too large inputs. FIXME: remove this once
mpfr_ai can handle large inputs */
#include "tgeneric.c"
static void
check_large (void)
{
mpfr_t x, y, z;
mpfr_init2 (x, 38);
mpfr_init2 (y, 110);
mpfr_init2 (z, 110);
mpfr_set_str_binary (x, "-1E8");
mpfr_ai (y, x, MPFR_RNDN);
mpfr_set_str_binary (z, "-10001110100001011111110001100011101100011100010000110100100101011111011100000101110101010010000000101110011111E-112");
if (mpfr_equal_p (y, z) == 0)
{
printf ("Error in mpfr_ai for x=-2^8\n");
exit (1);
}
#if 0 /* disabled since mpfr_ai does not currently handle large arguments */
mpfr_set_str_binary (x, "-1E26");
mpfr_ai (y, x, MPFR_RNDN);
mpfr_set_str_binary (z, "-110001111100000011001010010101001101001011001011101011001010100100001110001101101101000010000011001000001011E-118");
if (mpfr_equal_p (y, z) == 0)
{
printf ("Error in mpfr_ai for x=-2^26\n");
exit (1);
}
mpfr_set_str_binary (x, "-0.11111111111111111111111111111111111111E1073741823");
mpfr_ai (y, x, MPFR_RNDN);
/* FIXME: compute the correctly rounded value we should get for Ai(x),
and check we get this value */
#endif
mpfr_clear (x);
mpfr_clear (y);
mpfr_clear (z);
}
static void
check_zero (void)
{
mpfr_t x, y, r;
mpfr_init2 (x, 53);
mpfr_init2 (y, 53);
mpfr_init2 (r, 53);
mpfr_set_str_binary (r, "10110101110001100011110010110001001110001010110111E-51");
mpfr_set_ui (x, 0, MPFR_RNDN);
mpfr_ai (y, x, MPFR_RNDN);
if (mpfr_equal_p (y, r) == 0)
{
printf ("Error in mpfr_ai for x=0\n");
printf ("Expected "); mpfr_dump (r);
printf ("Got "); mpfr_dump (y);
exit (1);
}
mpfr_clear (x);
mpfr_clear (y);
mpfr_clear (r);
}
static void
bug20180107 (void)
{
mpfr_t x, y, z;
mpfr_exp_t emin;
int inex;
mpfr_flags_t flags;
mpfr_init2 (x, 152);
mpfr_init2 (y, 11);
mpfr_init2 (z, 11);
mpfr_set_str_binary (x, "0.11010101100111000111001001010110101001100001011110101111000010100111011101011110000100111011101100100100001010000110100011001000111010010001110000011100E5");
emin = mpfr_get_emin ();
mpfr_set_emin (-134);
mpfr_clear_flags ();
inex = mpfr_ai (y, x, MPFR_RNDA);
flags = __gmpfr_flags;
/* result should be 0.10011100000E-135 with unlimited exponent range,
and thus should be rounded to 0.1E-134 */
mpfr_set_str_binary (z, "0.1E-134");
MPFR_ASSERTN (mpfr_equal_p (y, z));
MPFR_ASSERTN (inex > 0);
MPFR_ASSERTN (flags == (MPFR_FLAGS_UNDERFLOW | MPFR_FLAGS_INEXACT));
mpfr_set_prec (x, 2);
mpfr_set_str_binary (x, "0.11E7");
mpfr_set_prec (y, 2);
mpfr_clear_flags ();
inex = mpfr_ai (y, x, MPFR_RNDA);
flags = __gmpfr_flags;
/* result should be 1.0E-908 with unlimited exponent range,
and thus should be rounded to 0.1E-134 */
mpfr_set_str_binary (z, "0.1E-134");
MPFR_ASSERTN (mpfr_equal_p (y, z));
MPFR_ASSERTN (inex > 0);
MPFR_ASSERTN (flags == (MPFR_FLAGS_UNDERFLOW | MPFR_FLAGS_INEXACT));
mpfr_set_emin (emin);
mpfr_clear (x);
mpfr_clear (y);
mpfr_clear (z);
}
/* exercise mpfr_ai near m*2^e, for precision p */
static void
test_near_m2e (long m, mpfr_exp_t e, mpfr_prec_t pmax)
{
mpfr_t x, xx, y, yy;
mpfr_prec_t p;
int inex;
mpfr_clear_flags ();
/* first determine the smallest precision for which m*2^e is exact */
for (p = MPFR_PREC_MIN; p <= pmax; p++)
{
mpfr_init2 (x, p);
inex = mpfr_set_si_2exp (x, m, e, MPFR_RNDN);
mpfr_clear (x);
if (inex == 0)
break;
}
mpfr_init2 (x, p);
inex = mpfr_set_si_2exp (x, m, e, MPFR_RNDN);
MPFR_ASSERTN(inex == 0);
for (; p <= pmax; p++)
{
mpfr_init2 (y, p);
mpfr_init2 (xx, p);
mpfr_init2 (yy, p);
mpfr_prec_round (x, p, MPFR_RNDN);
mpfr_ai (y, x, MPFR_RNDN);
while (1)
{
mpfr_set (xx, x, MPFR_RNDN);
mpfr_nextbelow (xx);
mpfr_ai (yy, xx, MPFR_RNDN);
if (mpfr_cmpabs (yy, y) >= 0)
break;
else
{
mpfr_set (x, xx, MPFR_RNDN);
mpfr_set (y, yy, MPFR_RNDN);
}
}
while (1)
{
mpfr_set (xx, x, MPFR_RNDN);
mpfr_nextabove (xx);
mpfr_ai (yy, xx, MPFR_RNDN);
if (mpfr_cmpabs (yy, y) >= 0)
break;
else
{
mpfr_set (x, xx, MPFR_RNDN);
mpfr_set (y, yy, MPFR_RNDN);
}
}
mpfr_clear (y);
mpfr_clear (xx);
mpfr_clear (yy);
}
mpfr_clear (x);
/* Since some tests don't really check that the result is not NaN... */
MPFR_ASSERTN (! mpfr_nanflag_p ());
}
/* example provided by Sylvain Chevillard, which exercises the case
wprec < err + 1, and thus correct_bits = 0, in src/ai.c */
static void
coverage (void)
{
mpfr_t x, y;
int inex;
mpfr_init2 (x, 800);
mpfr_init2 (y, 20);
mpfr_set_str (x, "-2.3381074104597670384891972524467354406385401456723878524838544372136680027002836477821640417313293202847600938532659527752254668583598667448688987168197275409731526749911127480659996456283534915503672", 10, MPFR_RNDN);
inex = mpfr_ai (y, x, MPFR_RNDN);
MPFR_ASSERTN(inex < 0);
MPFR_ASSERTN(mpfr_cmp_ui_2exp (y, 593131, -682) == 0);
mpfr_clear (x);
mpfr_clear (y);
}
int
main (int argc, char *argv[])
{
tests_start_mpfr ();
coverage ();
test_near_m2e (-5, -1, 100); /* exercise near -2.5 */
test_near_m2e (-4, 0, 100); /* exercise near -4 */
test_near_m2e (-11, -1, 100); /* exercise near -5.5 */
test_near_m2e (-27, -2, 100); /* exercise near -6.75 */
test_near_m2e (-31, -2, 100); /* exercise near -7.75 */
test_near_m2e (-15, -1, 100); /* exercise near -7.5 */
bug20180107 ();
check_large ();
check_zero ();
test_generic (MPFR_PREC_MIN, 100, 5);
tests_end_mpfr ();
return 0;
}
| 28.922131 | 240 | 0.657503 |
7ff7c30e39ca387d803ea988bbd1deaa353acf37 | 4,531 | h | C | include/dsa-verify.h | marcizhu/dsa-verify | 034c90b2b38adcdf2237f3955efd8bc72935a1e0 | [
"MIT"
] | 3 | 2021-02-27T17:29:26.000Z | 2021-02-28T08:53:21.000Z | include/dsa-verify.h | marcizhu/dsa-verify | 034c90b2b38adcdf2237f3955efd8bc72935a1e0 | [
"MIT"
] | null | null | null | include/dsa-verify.h | marcizhu/dsa-verify | 034c90b2b38adcdf2237f3955efd8bc72935a1e0 | [
"MIT"
] | null | null | null | /*
* This file is part of the dsa-verify library (https://github.com/marcizhu/dsa-verify)
*
* Copyright (C) 2021 Marc Izquierdo
*
* 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 _DSA_VERIFY_H_
#define _DSA_VERIFY_H_
#include <stdint.h>
#include <stddef.h>
/** @brief Alias for SHA1 hash */
typedef uint8_t SHA1_t[20];
enum
{
DSA_VERIFICATION_OK = 1, ///< Verification successful
DSA_VERIFICATION_FAILED = 0, ///< Verification failed
DSA_GENERIC_ERROR = -1, ///< Generic error, verification was not performed
DSA_KEY_FORMAT_ERROR = -2, ///< Invalid public key format
DSA_KEY_PARAM_ERROR = -3, ///< Invalid/missing public key parameters
DSA_SIGNATURE_FORMAT_ERROR = -4, ///< Invalid signature format
DSA_SIGNATURE_PARAM_ERROR = -5 ///< Invalid/missing signature parameters
};
#ifdef __cplusplus
extern "C" {
#endif
/**
* Verify a given blob
*
* This function verifies a blob of data using the given public key and signature.
* Effectively hashes the blob using SHA1 and afterwards calls @ref dsa_verify_hash()
* in order to verify data validity.
*
* @param data Pointer to the beginning of the data blob
* @param data_len Length of the data blob
* @param pubkey Null-terminated string with the contents of the public key,
* in PEM format.
* @param sig Null-terminated string with the signature of the file,
* encoded in base64.
*
* @returns Returns 1 (@ref DSA_VERIFICATION_OK) on success, 0 (@ref DSA_VERIFICATION_FAILED)
* on verification failure or any of @ref DSA_GENERIC_ERROR, @ref DSA_KEY_FORMAT_ERROR,
* @ref DSA_KEY_PARAM_ERROR, @ref DSA_SIGN_FORMAT_ERROR or @ref DSA_SIGN_PARAM_ERROR
* on error.
*/
int dsa_verify_blob(const unsigned char* data, size_t data_len, const char* pubkey, const char* sig);
/**
* Verify a given SHA1 hash
*
* This function verifies a SHA1 hash using the given public key and signature.
*
* @param sha1 SHA1 hash to be verified
* @param pubkey Null-terminated string with the contents of the public key,
* in PEM format.
* @param sig Null-terminated string with the signature of the file,
* encoded in base64.
*
* @returns Returns 1 (@ref DSA_VERIFICATION_OK) on success, 0 (@ref DSA_VERIFICATION_FAILED)
* on verification failure or any of @ref DSA_GENERIC_ERROR, @ref DSA_KEY_FORMAT_ERROR,
* @ref DSA_KEY_PARAM_ERROR, @ref DSA_SIGN_FORMAT_ERROR or @ref DSA_SIGN_PARAM_ERROR
* on error.
*/
int dsa_verify_hash(const SHA1_t sha1, const char* pubkey, const char* sig);
/**
* Verify a given SHA1 hash, key & signature in DER form
*
* This function verifies a SHA1 hash using the given public key and signature.
*
* @param sha1 SHA1 hash to be verified
* @param pubkey Binary DER representation of the public key
* @param pubkey_len Lenght of the public key
* @param sig Binary DER representation of the signature of the file
* @param sig_len Length of the signature
*
* @returns Returns 1 (@ref DSA_VERIFICATION_OK) on success, 0 (@ref DSA_VERIFICATION_FAILED)
* on verification failure or any of @ref DSA_GENERIC_ERROR, @ref DSA_KEY_FORMAT_ERROR,
* @ref DSA_KEY_PARAM_ERROR, @ref DSA_SIGN_FORMAT_ERROR or @ref DSA_SIGN_PARAM_ERROR
* on error.
*/
int dsa_verify_hash_der(const SHA1_t sha1, const unsigned char* pubkey, size_t pubkey_len, const unsigned char* sig, size_t sig_len);
#ifdef __cplusplus
}
#endif
#endif
| 40.455357 | 133 | 0.72655 |
3674df62f9bc327c25d787ca249ec94376825747 | 1,221 | h | C | RecoCTPPS/TotemRPLocal/interface/CTPPSDiamondRecHitProducerAlgorithm.h | nistefan/cmssw | ea13af97f7f2117a4f590a5e654e06ecd9825a5b | [
"Apache-2.0"
] | 1 | 2019-03-09T19:47:49.000Z | 2019-03-09T19:47:49.000Z | RecoCTPPS/TotemRPLocal/interface/CTPPSDiamondRecHitProducerAlgorithm.h | nistefan/cmssw | ea13af97f7f2117a4f590a5e654e06ecd9825a5b | [
"Apache-2.0"
] | null | null | null | RecoCTPPS/TotemRPLocal/interface/CTPPSDiamondRecHitProducerAlgorithm.h | nistefan/cmssw | ea13af97f7f2117a4f590a5e654e06ecd9825a5b | [
"Apache-2.0"
] | 1 | 2019-04-03T19:23:27.000Z | 2019-04-03T19:23:27.000Z | /****************************************************************************
*
* This is a part of CTPPS offline software.
* Authors:
* Laurent Forthomme (laurent.forthomme@cern.ch)
*
****************************************************************************/
#ifndef RecoCTPPS_TotemRPLocal_CTPPSDiamondRecHitProducerAlgorithm
#define RecoCTPPS_TotemRPLocal_CTPPSDiamondRecHitProducerAlgorithm
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "DataFormats/Common/interface/DetSetVector.h"
#include "DataFormats/CTPPSDetId/interface/CTPPSDiamondDetId.h"
#include "DataFormats/CTPPSDigi/interface/CTPPSDiamondDigi.h"
#include "DataFormats/CTPPSReco/interface/CTPPSDiamondRecHit.h"
#include "Geometry/VeryForwardRPTopology/interface/RPTopology.h"
#include "Geometry/VeryForwardGeometryBuilder/interface/CTPPSGeometry.h"
class CTPPSDiamondRecHitProducerAlgorithm
{
public:
CTPPSDiamondRecHitProducerAlgorithm( const edm::ParameterSet& conf );
void build( const CTPPSGeometry*, const edm::DetSetVector<CTPPSDiamondDigi>&, edm::DetSetVector<CTPPSDiamondRecHit>& );
private:
/// Conversion constant between HPTDC time slice and absolute time (in ns)
double ts_to_ns_;
};
#endif
| 33.916667 | 123 | 0.710893 |
36fb0f161d439dcaeb5550f39147bdc2d588b216 | 3,042 | c | C | d/magic/obj/weapons/nilith_knights.c | Dbevan/SunderingShadows | 6c15ec56cef43c36361899bae6dc08d0ee907304 | [
"MIT"
] | 13 | 2019-07-19T05:24:44.000Z | 2021-11-18T04:08:19.000Z | d/magic/obj/weapons/nilith_knights.c | Dbevan/SunderingShadows | 6c15ec56cef43c36361899bae6dc08d0ee907304 | [
"MIT"
] | 4 | 2021-03-15T18:56:39.000Z | 2021-08-17T17:08:22.000Z | d/magic/obj/weapons/nilith_knights.c | Dbevan/SunderingShadows | 6c15ec56cef43c36361899bae6dc08d0ee907304 | [
"MIT"
] | 13 | 2019-09-12T06:22:38.000Z | 2022-01-31T01:15:12.000Z | #include <std.h>
inherit "/d/magic/obj/weapons/godwpns";
void create(){
::create();
set_name("Lurid Splendor");
set_id(({"sword","weapon","gold sword","golden sword","splendor",
"lurid splendor","kilij","gold kilij","golden kilij"}));
set_obvious_short("%^RESET%^%^BLUE%^g%^BOLD%^%^BLUE%^e%^CYAN%^m%^RESET%^%^GREEN%^"
"-%^BOLD%^%^GREEN%^s%^YELLOW%^t%^RESET%^%^ORANGE%^u%^RED%^d"
"%^BOLD%^%^RED%^d%^RESET%^%^MAGENTA%^e%^BLUE%^d %^YELLOW%^g%^WHITE%^o"
"%^YELLOW%^l%^RESET%^%^ORANGE%^d%^BOLD%^%^BLACK%^e%^YELLOW%^n "
"%^RESET%^%^WHITE%^k%^BOLD%^i%^BLACK%^l%^RESET%^%^WHITE%^i"
"%^BOLD%^%^BLACK%^j%^RESET%^");
set_short("%^BOLD%^%^WHITE%^L%^GREEN%^u%^BLACK%^r"
"%^RESET%^%^WHITE%^i%^BOLD%^d %^BLACK%^Sp%^BLUE%^l%^RESET%^%^WHITE%^"
"e%^BOLD%^%^BLACK%^n%^RED%^d%^CYAN%^o%^BLACK%^r%^RESET%^");
set_long("%^YELLOW%^The blade of this opulent weapon is forged "
"from solid gold, inlaid with %^BLACK%^s%^RESET%^%^WHITE%^w%^BOLD%^i"
"%^BLACK%^r%^RESET%^%^WHITE%^l%^BOLD%^i%^BLACK%^n%^RESET%^%^WHITE%^g "
"%^RED%^a%^BOLD%^%^BLACK%^g%^RESET%^%^RED%^a%^BOLD%^%^RED%^t"
"%^RESET%^%^RED%^e %^YELLOW%^in its blood groove. The blade is similar"
" to a scimitar or cutlass; slim, curved, and gradually wider toward"
" the point of the blade, but the stabbing edge has a slight bulge "
"on the sides several inches down its length, adding a strange weight"
" to the weapon. Some arcane force took part in the creation of this"
" armament, as the blade is melded seamlessly with a hilt that seems"
" to be a humanoid %^WHITE%^femur%^YELLOW%^, its hip-joint end "
"evidently serving as the pommel. Various tiny, starburst-cut "
"%^BLUE%^g%^CYAN%^em%^GREEN%^st%^YELLOW%^on%^RED%^e%^MAGENTA%^s "
"%^YELLOW%^glint from an otherwise simple-looking crossguard, "
"forming a pair of lines down the handle to end in a whorl of "
"%^RESET%^%^RED%^bl%^BOLD%^%^RED%^o%^BLACK%^o%^RESET%^%^RED%^dst"
"%^BOLD%^%^RED%^o%^RESET%^%^RED%^ne %^YELLOW%^marbled into the "
"pommel.%^RESET%^");
set_value(0);
set_damage_type("slashing");
set_hit((:TO,"hit_func":));
}
int hit_func(object targ){
targ = ETO->query_current_attacker();
if(!objectp(ETO)) return 1;
if(!objectp(targ)) return 1;
if(!random(10)){
tell_object(ETO,"%^BOLD%^%^BLACK%^A sickening %^RED%^crunch"
" %^BLACK%^rings out as your weapon seems to %^RESET%^%^WHITE%^"
"pass %^BOLD%^%^BLACK%^right through "+targ->QCN+"%^BOLD%^%^BLACK%^,"
" leaving no obvious injury beyond a brief look of anguish!");
tell_object(targ,"%^BOLD%^%^BLACK%^"+ETO->QCN+"'s blade "
"seems to pass right through you like a %^RESET%^%^CYAN%^ghost,"
" %^BOLD%^%^BLACK%^but the agonizing %^RED%^fire %^BLACK%^in "
"the %^WHITE%^bo%^RESET%^ne%^BOLD%^s %^BLACK%^that crossed its "
"path tell you otherwise!");
tell_room(environment(ETO),"%^BOLD%^%^BLACK%^A sickening "
"%^RED%^crunch %^BLACK%^rings out as "+ETO->QCN+"'s weapon seems to pass through "+targ->QCN+"'s "
"flesh like a %^RESET%^%^BLUE%^sp%^CYAN%^e%^BLUE%^cter"
"%^BOLD%^%^BLACK%^!",({ETO,targ}));
return random(4)+8;
}
}
| 48.285714 | 98 | 0.633794 |
3c22a029d399b1e397a8815ddeb466d81ea41aae | 550 | h | C | Pod/Classes/Networking/YYClient+Misc.h | NSExceptional/YakKit | 78b496263364bcbeb7556eb833a6cc95412104f9 | [
"MIT"
] | 1 | 2017-04-13T08:52:47.000Z | 2017-04-13T08:52:47.000Z | Pod/Classes/Networking/YYClient+Misc.h | NSExceptional/YakKit | 78b496263364bcbeb7556eb833a6cc95412104f9 | [
"MIT"
] | null | null | null | Pod/Classes/Networking/YYClient+Misc.h | NSExceptional/YakKit | 78b496263364bcbeb7556eb833a6cc95412104f9 | [
"MIT"
] | null | null | null | //
// YYClient+Misc.h
// Pods
//
// Created by Tanner on 11/13/15.
//
//
#import "YYClient.h"
NS_ASSUME_NONNULL_BEGIN
@interface YYClient (Misc)
#pragma mark Misc
- (void)logEvent:(NSString *)event completion:(nullable ErrorBlock)completion;
- (void)refreshLocate:(nullable ErrorBlock)completion;
- (void)contactUs:(NSString *)topic message:(NSString *)message email:(NSString *)email completion:(nullable ErrorBlock)completion;
- (void)authenticateForLayer:(NSString *)nonce completion:(StringBlock)completion;
@end
NS_ASSUME_NONNULL_END
| 21.153846 | 131 | 0.758182 |
82c91c65029cb4f5ac3696215a90c10f1eb2f51c | 37,155 | h | C | Testing/Marlin-2.0.x/Marlin/src/lcd/language/language_ru.h | qisback/Geeetech-i3-B-pro-configs | a2c309923c4e68103addda677fda190238a1abe0 | [
"CC-BY-4.0"
] | 1 | 2020-11-29T18:04:31.000Z | 2020-11-29T18:04:31.000Z | Testing/Marlin-2.0.x/Marlin/src/lcd/language/language_ru.h | qisback/Geeetech-i3-B-pro-configs | a2c309923c4e68103addda677fda190238a1abe0 | [
"CC-BY-4.0"
] | 1 | 2020-09-27T14:53:34.000Z | 2020-09-27T14:53:34.000Z | src/lcd/language/language_ru.h | Sundancer78/Marlin-2.0.4_SKR_14_turbo_ender3 | d9dbef52e6fb4e110908a6d09d0af00fc0ac9b20 | [
"MIT"
] | null | null | null | /**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma once
/**
* Russian
*
* LCD Menu Messages
* See also http://marlinfw.org/docs/development/lcd_language.html
*
*/
#define DISPLAY_CHARSET_ISO10646_5
namespace Language_ru {
using namespace Language_en; // Inherit undefined strings from English
constexpr uint8_t CHARSIZE = 2;
PROGMEM Language_Str LANGUAGE = _UxGT("Russian");
PROGMEM Language_Str WELCOME_MSG = MACHINE_NAME _UxGT(" готов.");
PROGMEM Language_Str MSG_BACK = _UxGT("Назад");
PROGMEM Language_Str MSG_MEDIA_INSERTED = _UxGT("Карта вставлена");
PROGMEM Language_Str MSG_MEDIA_REMOVED = _UxGT("Карта извлечена");
PROGMEM Language_Str MSG_MEDIA_RELEASED = _UxGT("SD карта не активна");
PROGMEM Language_Str MSG_LCD_ENDSTOPS = _UxGT("Эндстопы"); // Max length 8 characters
PROGMEM Language_Str MSG_LCD_SOFT_ENDSTOPS = _UxGT("Прогр. эндстопы");
PROGMEM Language_Str MSG_MAIN = _UxGT("Меню");
PROGMEM Language_Str MSG_ADVANCED_SETTINGS = _UxGT("Другие настройки");
PROGMEM Language_Str MSG_CONFIGURATION = _UxGT("Настройки");
PROGMEM Language_Str MSG_AUTOSTART = _UxGT("Автостарт");
PROGMEM Language_Str MSG_DISABLE_STEPPERS = _UxGT("Выключить двигатели");
PROGMEM Language_Str MSG_DEBUG_MENU = _UxGT("Меню отладки");
PROGMEM Language_Str MSG_PROGRESS_BAR_TEST = _UxGT("Тест индикатора");
PROGMEM Language_Str MSG_AUTO_HOME = _UxGT("Парковка XYZ");
PROGMEM Language_Str MSG_AUTO_HOME_X = _UxGT("Парковка X");
PROGMEM Language_Str MSG_AUTO_HOME_Y = _UxGT("Парковка Y");
PROGMEM Language_Str MSG_AUTO_HOME_Z = _UxGT("Парковка Z");
PROGMEM Language_Str MSG_LEVEL_BED_HOMING = _UxGT("Нулевое положение");
PROGMEM Language_Str MSG_LEVEL_BED_WAITING = _UxGT("Нажмите чтобы начать");
PROGMEM Language_Str MSG_LEVEL_BED_NEXT_POINT = _UxGT("Следующая точка");
PROGMEM Language_Str MSG_LEVEL_BED_DONE = _UxGT("Выравнивание готово!");
PROGMEM Language_Str MSG_Z_FADE_HEIGHT = _UxGT("Высота спада");
PROGMEM Language_Str MSG_SET_HOME_OFFSETS = _UxGT("Запомнить парковку");
PROGMEM Language_Str MSG_HOME_OFFSETS_APPLIED = _UxGT("Коррекции применены");
PROGMEM Language_Str MSG_SET_ORIGIN = _UxGT("Запомнить ноль");
PROGMEM Language_Str MSG_PREHEAT_1 = _UxGT("Преднагрев ") PREHEAT_1_LABEL;
PROGMEM Language_Str MSG_PREHEAT_1_H = _UxGT("Нагрев ") PREHEAT_1_LABEL " ~";
PROGMEM Language_Str MSG_PREHEAT_1_END = _UxGT("Нагрев ") PREHEAT_1_LABEL _UxGT(" сопло");
PROGMEM Language_Str MSG_PREHEAT_1_END_E = _UxGT("Нагрев ") PREHEAT_1_LABEL _UxGT(" сопло ~");
PROGMEM Language_Str MSG_PREHEAT_1_ALL = _UxGT("Нагрев ") PREHEAT_1_LABEL _UxGT(" всё");
PROGMEM Language_Str MSG_PREHEAT_1_BEDONLY = _UxGT("Нагрев ") PREHEAT_1_LABEL _UxGT(" стол");
PROGMEM Language_Str MSG_PREHEAT_1_SETTINGS = _UxGT("Нагрев ") PREHEAT_1_LABEL _UxGT(" правка");
PROGMEM Language_Str MSG_PREHEAT_2 = _UxGT("Преднагрев ") PREHEAT_2_LABEL;
PROGMEM Language_Str MSG_PREHEAT_2_H = _UxGT("Нагрев ") PREHEAT_2_LABEL " ~";
PROGMEM Language_Str MSG_PREHEAT_2_END = _UxGT("Нагрев ") PREHEAT_2_LABEL _UxGT(" сопло");
PROGMEM Language_Str MSG_PREHEAT_2_END_E = _UxGT("Нагрев ") PREHEAT_2_LABEL _UxGT(" сопло ~");
PROGMEM Language_Str MSG_PREHEAT_2_ALL = _UxGT("Нагрев ") PREHEAT_2_LABEL _UxGT(" всё");
PROGMEM Language_Str MSG_PREHEAT_2_BEDONLY = _UxGT("Нагрев ") PREHEAT_2_LABEL _UxGT(" стол");
PROGMEM Language_Str MSG_PREHEAT_2_SETTINGS = _UxGT("Нагрев ") PREHEAT_2_LABEL _UxGT(" правка");
PROGMEM Language_Str MSG_COOLDOWN = _UxGT("Охлаждение");
PROGMEM Language_Str MSG_LASER_MENU = _UxGT("Управление лазером");
PROGMEM Language_Str MSG_LASER_OFF = _UxGT("Выключить лазер");
PROGMEM Language_Str MSG_LASER_ON = _UxGT("Включить лазер");
PROGMEM Language_Str MSG_LASER_POWER = _UxGT("Мощность лазера");
PROGMEM Language_Str MSG_SPINDLE_MENU = _UxGT("Шпиндель управление");
PROGMEM Language_Str MSG_SPINDLE_OFF = _UxGT("Выключить шпиндель");
PROGMEM Language_Str MSG_SPINDLE_ON = _UxGT("Включить шпиндель");
PROGMEM Language_Str MSG_SPINDLE_POWER = _UxGT("Мощность шпинделя");
PROGMEM Language_Str MSG_SPINDLE_REVERSE = _UxGT("Инверсия шпинделя");
PROGMEM Language_Str MSG_SWITCH_PS_ON = _UxGT("Включить питание");
PROGMEM Language_Str MSG_SWITCH_PS_OFF = _UxGT("Выключить питание");
PROGMEM Language_Str MSG_EXTRUDE = _UxGT("Экструзия");
PROGMEM Language_Str MSG_RETRACT = _UxGT("Втягивание");
PROGMEM Language_Str MSG_MOVE_AXIS = _UxGT("Движение по осям");
PROGMEM Language_Str MSG_BED_LEVELING = _UxGT("Калибровка стола");
PROGMEM Language_Str MSG_LEVEL_BED = _UxGT("Калибровать стол");
PROGMEM Language_Str MSG_LEVEL_CORNERS = _UxGT("Выровнять углы");
PROGMEM Language_Str MSG_NEXT_CORNER = _UxGT("Следующий угол");
PROGMEM Language_Str MSG_EDIT_MESH = _UxGT("Редактировать сетку");
PROGMEM Language_Str MSG_EDITING_STOPPED = _UxGT("Правка сетки окончена");
PROGMEM Language_Str MSG_PROBING_MESH = _UxGT("Точка сетки:");
PROGMEM Language_Str MSG_MESH_X = _UxGT("Индекс X");
PROGMEM Language_Str MSG_MESH_Y = _UxGT("Индекс Y");
PROGMEM Language_Str MSG_MESH_EDIT_Z = _UxGT("Значение Z");
PROGMEM Language_Str MSG_USER_MENU = _UxGT("Свои команды");
PROGMEM Language_Str MSG_M48_TEST = _UxGT("Проверка Z-датчика");
PROGMEM Language_Str MSG_M48_DEVIATION = _UxGT("Отклонение");
PROGMEM Language_Str MSG_M48_POINT = _UxGT("Измерение");
// TODO: IDEX Menu
PROGMEM Language_Str MSG_OFFSETS_MENU = _UxGT("Размещение сопел");
PROGMEM Language_Str MSG_HOTEND_OFFSET_X = _UxGT("2-е сопло X");
PROGMEM Language_Str MSG_HOTEND_OFFSET_Y = _UxGT("2-е сопло Y");
PROGMEM Language_Str MSG_HOTEND_OFFSET_Z = _UxGT("2-е сопло Z");
PROGMEM Language_Str MSG_UBL_DOING_G29 = _UxGT("Выполняем G29");
PROGMEM Language_Str MSG_UBL_TOOLS = _UxGT("Утилиты UBL");
PROGMEM Language_Str MSG_UBL_LEVEL_BED = _UxGT("Калибровка UBL");
PROGMEM Language_Str MSG_UBL_MANUAL_MESH = _UxGT("Правка сетки вручную");
PROGMEM Language_Str MSG_UBL_BC_INSERT = _UxGT("Z-пробник и замеры");
PROGMEM Language_Str MSG_UBL_BC_INSERT2 = _UxGT("Измерение");
PROGMEM Language_Str MSG_UBL_BC_REMOVE = _UxGT("Убрать и замер стола");
PROGMEM Language_Str MSG_UBL_MOVING_TO_NEXT = _UxGT("Двигаемся дальше");
PROGMEM Language_Str MSG_UBL_ACTIVATE_MESH = _UxGT("Активировать UBL");
PROGMEM Language_Str MSG_UBL_DEACTIVATE_MESH = _UxGT("Деактивировать UBL");
PROGMEM Language_Str MSG_UBL_SET_TEMP_BED = _UxGT("Температура стола");
PROGMEM Language_Str MSG_UBL_BED_TEMP_CUSTOM = _UxGT("Температура стола");
PROGMEM Language_Str MSG_UBL_SET_TEMP_HOTEND = _UxGT("Температура сопла");
PROGMEM Language_Str MSG_UBL_HOTEND_TEMP_CUSTOM = _UxGT("Температура сопла");
PROGMEM Language_Str MSG_UBL_MESH_EDIT = _UxGT("Редактор сеток");
PROGMEM Language_Str MSG_UBL_EDIT_CUSTOM_MESH = _UxGT("Править свою сетку");
PROGMEM Language_Str MSG_UBL_FINE_TUNE_MESH = _UxGT("Точная правка сетки");
PROGMEM Language_Str MSG_UBL_DONE_EDITING_MESH = _UxGT("Правка сетки завершена");
PROGMEM Language_Str MSG_UBL_BUILD_CUSTOM_MESH = _UxGT("Построить свою сетку");
PROGMEM Language_Str MSG_UBL_BUILD_MESH_MENU = _UxGT("Построить сетку");
PROGMEM Language_Str MSG_UBL_BUILD_MESH_M1 = _UxGT("Построить сетку ") PREHEAT_1_LABEL;
PROGMEM Language_Str MSG_UBL_BUILD_MESH_M2 = _UxGT("Построить сетку ") PREHEAT_2_LABEL;
PROGMEM Language_Str MSG_UBL_BUILD_COLD_MESH = _UxGT("Построить хол. сетку");
PROGMEM Language_Str MSG_UBL_MESH_HEIGHT_ADJUST = _UxGT("Правка высоты сетки");
PROGMEM Language_Str MSG_UBL_MESH_HEIGHT_AMOUNT = _UxGT("Высота");
PROGMEM Language_Str MSG_UBL_VALIDATE_MESH_MENU = _UxGT("Проверить сетку");
PROGMEM Language_Str MSG_UBL_VALIDATE_MESH_M1 = _UxGT("Проверить сетку ") PREHEAT_1_LABEL;
PROGMEM Language_Str MSG_UBL_VALIDATE_MESH_M2 = _UxGT("Проверить сетку ") PREHEAT_2_LABEL;
PROGMEM Language_Str MSG_UBL_VALIDATE_CUSTOM_MESH = _UxGT("Проверить свою сетку");
PROGMEM Language_Str MSG_UBL_CONTINUE_MESH = _UxGT("Продолжить сетку");
PROGMEM Language_Str MSG_UBL_MESH_LEVELING = _UxGT("Калибровка сетки");
PROGMEM Language_Str MSG_UBL_3POINT_MESH_LEVELING = _UxGT("Калибровка 3-х точек");
PROGMEM Language_Str MSG_UBL_GRID_MESH_LEVELING = _UxGT("Калибровка растера");
PROGMEM Language_Str MSG_UBL_MESH_LEVEL = _UxGT("Выровнить сетку");
PROGMEM Language_Str MSG_UBL_SIDE_POINTS = _UxGT("Крайние точки");
PROGMEM Language_Str MSG_UBL_MAP_TYPE = _UxGT("Тип карты");
PROGMEM Language_Str MSG_UBL_OUTPUT_MAP = _UxGT("Вывести карту сетки");
PROGMEM Language_Str MSG_UBL_OUTPUT_MAP_HOST = _UxGT("Вывести на хост");
PROGMEM Language_Str MSG_UBL_OUTPUT_MAP_CSV = _UxGT("Вывести в CSV");
PROGMEM Language_Str MSG_UBL_OUTPUT_MAP_BACKUP = _UxGT("Резервировать сетку");
PROGMEM Language_Str MSG_UBL_INFO_UBL = _UxGT("Вывод информации UBL");
PROGMEM Language_Str MSG_UBL_FILLIN_AMOUNT = _UxGT("Кол-во заполнителя");
PROGMEM Language_Str MSG_UBL_MANUAL_FILLIN = _UxGT("Ручное заполнение");
PROGMEM Language_Str MSG_UBL_SMART_FILLIN = _UxGT("Умное заполнение");
PROGMEM Language_Str MSG_UBL_FILLIN_MESH = _UxGT("Заполнить сетку");
PROGMEM Language_Str MSG_UBL_INVALIDATE_ALL = _UxGT("Аннулировать всё");
PROGMEM Language_Str MSG_UBL_INVALIDATE_CLOSEST = _UxGT("Обнулить ближ. точку");
PROGMEM Language_Str MSG_UBL_FINE_TUNE_ALL = _UxGT("Точная правка всего");
PROGMEM Language_Str MSG_UBL_FINE_TUNE_CLOSEST = _UxGT("Настр. ближ. точки");
PROGMEM Language_Str MSG_UBL_STORAGE_MESH_MENU = _UxGT("Хранилище сеток");
PROGMEM Language_Str MSG_UBL_STORAGE_SLOT = _UxGT("Слот памяти");
PROGMEM Language_Str MSG_UBL_LOAD_MESH = _UxGT("Загрузить сетку стола");
PROGMEM Language_Str MSG_UBL_SAVE_MESH = _UxGT("Сохранить сетку стола");
PROGMEM Language_Str MSG_MESH_LOADED = _UxGT("M117 Сетка %i загружена");
PROGMEM Language_Str MSG_MESH_SAVED = _UxGT("M117 Сетка %i сохранена");
PROGMEM Language_Str MSG_UBL_NO_STORAGE = _UxGT("Нет хранилища");
PROGMEM Language_Str MSG_UBL_SAVE_ERROR = _UxGT("Ошибка: Сохран. UBL");
PROGMEM Language_Str MSG_UBL_RESTORE_ERROR = _UxGT("Ошибка: Восстан. UBL");
PROGMEM Language_Str MSG_UBL_Z_OFFSET_STOPPED = _UxGT("Смещение Z останов.");
PROGMEM Language_Str MSG_UBL_STEP_BY_STEP_MENU = _UxGT("Пошаговое UBL");
PROGMEM Language_Str MSG_UBL_1_BUILD_COLD_MESH = _UxGT("1.Построить хол. сетку");
PROGMEM Language_Str MSG_UBL_2_SMART_FILLIN = _UxGT("2.Умное заполнение");
PROGMEM Language_Str MSG_UBL_3_VALIDATE_MESH_MENU = _UxGT("3.Проверить сетку");
PROGMEM Language_Str MSG_UBL_4_FINE_TUNE_ALL = _UxGT("4.Точная настр. всего");
PROGMEM Language_Str MSG_UBL_5_VALIDATE_MESH_MENU = _UxGT("5.Проверить сетку");
PROGMEM Language_Str MSG_UBL_6_FINE_TUNE_ALL = _UxGT("6.Точная настр. всего");
PROGMEM Language_Str MSG_UBL_7_SAVE_MESH = _UxGT("7.Сохранить сетку стола");
PROGMEM Language_Str MSG_LED_CONTROL = _UxGT("Настройка подсветки");
PROGMEM Language_Str MSG_LEDS = _UxGT("Подсветка");
PROGMEM Language_Str MSG_LED_PRESETS = _UxGT("Предустановки света");
PROGMEM Language_Str MSG_SET_LEDS_RED = _UxGT("Красный");
PROGMEM Language_Str MSG_SET_LEDS_ORANGE = _UxGT("Оранжевый");
PROGMEM Language_Str MSG_SET_LEDS_YELLOW = _UxGT("Жёлтый");
PROGMEM Language_Str MSG_SET_LEDS_GREEN = _UxGT("Зелёный");
PROGMEM Language_Str MSG_SET_LEDS_BLUE = _UxGT("Синий");
PROGMEM Language_Str MSG_SET_LEDS_INDIGO = _UxGT("Индиго");
PROGMEM Language_Str MSG_SET_LEDS_VIOLET = _UxGT("Фиолетовый");
PROGMEM Language_Str MSG_SET_LEDS_WHITE = _UxGT("Белый");
PROGMEM Language_Str MSG_SET_LEDS_DEFAULT = _UxGT("Свет по умолчанию");
PROGMEM Language_Str MSG_CUSTOM_LEDS = _UxGT("Свой цвет подсветки");
PROGMEM Language_Str MSG_INTENSITY_R = _UxGT("Уровень красного");
PROGMEM Language_Str MSG_INTENSITY_G = _UxGT("Уровень зелёного");
PROGMEM Language_Str MSG_INTENSITY_B = _UxGT("Уровень синего");
PROGMEM Language_Str MSG_INTENSITY_W = _UxGT("Уровень белого");
PROGMEM Language_Str MSG_LED_BRIGHTNESS = _UxGT("Яркость");
PROGMEM Language_Str MSG_MOVING = _UxGT("Движемся...");
PROGMEM Language_Str MSG_FREE_XY = _UxGT("Освобождаем XY");
PROGMEM Language_Str MSG_MOVE_X = _UxGT("Движение по X");
PROGMEM Language_Str MSG_MOVE_Y = _UxGT("Движение по Y");
PROGMEM Language_Str MSG_MOVE_Z = _UxGT("Движение по Z");
PROGMEM Language_Str MSG_MOVE_E = _UxGT("Экструдер");
PROGMEM Language_Str MSG_MOVE_EN = _UxGT("Экструдер *");
PROGMEM Language_Str MSG_HOTEND_TOO_COLD = _UxGT("Сопло не нагрето");
PROGMEM Language_Str MSG_MOVE_Z_DIST = _UxGT("Движение %sмм");
PROGMEM Language_Str MSG_MOVE_01MM = _UxGT("Движение 0.1мм");
PROGMEM Language_Str MSG_MOVE_1MM = _UxGT("Движение 1мм");
PROGMEM Language_Str MSG_MOVE_10MM = _UxGT("Движение 10мм");
PROGMEM Language_Str MSG_SPEED = _UxGT("Скорость");
PROGMEM Language_Str MSG_BED_Z = _UxGT("Z стола");
PROGMEM Language_Str MSG_NOZZLE = _UxGT("Сопло");
PROGMEM Language_Str MSG_NOZZLE_N = _UxGT("Сопло ~");
PROGMEM Language_Str MSG_BED = _UxGT("Стол");
PROGMEM Language_Str MSG_FAN_SPEED = _UxGT("Кулер");
PROGMEM Language_Str MSG_FAN_SPEED_N = _UxGT("Кулер ~");
PROGMEM Language_Str MSG_EXTRA_FAN_SPEED = _UxGT("Кулер доп.");
PROGMEM Language_Str MSG_EXTRA_FAN_SPEED_N = _UxGT("Кулер доп. ~");
PROGMEM Language_Str MSG_FLOW = _UxGT("Поток");
PROGMEM Language_Str MSG_FLOW_N = _UxGT("Поток ~");
PROGMEM Language_Str MSG_CONTROL = _UxGT("Настройки");
PROGMEM Language_Str MSG_MIN = " " LCD_STR_THERMOMETER _UxGT(" Мин");
PROGMEM Language_Str MSG_MAX = " " LCD_STR_THERMOMETER _UxGT(" Макс");
PROGMEM Language_Str MSG_FACTOR = " " LCD_STR_THERMOMETER _UxGT(" Фактор");
PROGMEM Language_Str MSG_AUTOTEMP = _UxGT("Автотемпература");
PROGMEM Language_Str MSG_LCD_ON = _UxGT("Вкл");
PROGMEM Language_Str MSG_LCD_OFF = _UxGT("Выкл");
PROGMEM Language_Str MSG_PID_AUTOTUNE = _UxGT("Автонастройка");
PROGMEM Language_Str MSG_PID_AUTOTUNE_E = _UxGT("Автонастройка *");
PROGMEM Language_Str MSG_SELECT = _UxGT("Выбор");
PROGMEM Language_Str MSG_SELECT_E = _UxGT("Выбор *");
PROGMEM Language_Str MSG_ACC = _UxGT("Ускорение");
PROGMEM Language_Str MSG_JERK = _UxGT("Рывок");
PROGMEM Language_Str MSG_VA_JERK = _UxGT("V") LCD_STR_A _UxGT("-рывок");
PROGMEM Language_Str MSG_VB_JERK = _UxGT("V") LCD_STR_B _UxGT("-рывок");
PROGMEM Language_Str MSG_VC_JERK = _UxGT("V") LCD_STR_C _UxGT("-рывок");
PROGMEM Language_Str MSG_VE_JERK = _UxGT("Ve-рывок");
PROGMEM Language_Str MSG_VELOCITY = _UxGT("Быстрота");
PROGMEM Language_Str MSG_VMAX_A = _UxGT("Vмакс ") LCD_STR_A;
PROGMEM Language_Str MSG_VMAX_B = _UxGT("Vмакс ") LCD_STR_B;
PROGMEM Language_Str MSG_VMAX_C = _UxGT("Vмакс ") LCD_STR_C;
PROGMEM Language_Str MSG_VMAX_E = _UxGT("Vмакс ") LCD_STR_E;
PROGMEM Language_Str MSG_VMAX_EN = _UxGT("Vмакс *");
PROGMEM Language_Str MSG_VMIN = _UxGT("Vмин");
PROGMEM Language_Str MSG_VTRAV_MIN = _UxGT("Vпутеш. мин");
PROGMEM Language_Str MSG_ACCELERATION = _UxGT("Ускорение");
PROGMEM Language_Str MSG_AMAX_A = _UxGT("Aмакс ") LCD_STR_A;
PROGMEM Language_Str MSG_AMAX_B = _UxGT("Aмакс ") LCD_STR_B;
PROGMEM Language_Str MSG_AMAX_C = _UxGT("Aмакс ") LCD_STR_C;
PROGMEM Language_Str MSG_AMAX_E = _UxGT("Aмакс ") LCD_STR_E;
PROGMEM Language_Str MSG_AMAX_EN = _UxGT("Aмакс *");
PROGMEM Language_Str MSG_A_RETRACT = _UxGT("A-втягивание");
PROGMEM Language_Str MSG_A_TRAVEL = _UxGT("A-путеш.");
PROGMEM Language_Str MSG_STEPS_PER_MM = _UxGT("Шаг/мм");
PROGMEM Language_Str MSG_A_STEPS = LCD_STR_A _UxGT("шаг/мм");
PROGMEM Language_Str MSG_B_STEPS = LCD_STR_B _UxGT("шаг/мм");
PROGMEM Language_Str MSG_C_STEPS = LCD_STR_C _UxGT("шаг/мм");
PROGMEM Language_Str MSG_E_STEPS = _UxGT("Eшаг/мм");
PROGMEM Language_Str MSG_EN_STEPS = _UxGT("*шаг/мм");
PROGMEM Language_Str MSG_TEMPERATURE = _UxGT("Температура");
PROGMEM Language_Str MSG_MOTION = _UxGT("Движение");
PROGMEM Language_Str MSG_FILAMENT = _UxGT("Филамент");
PROGMEM Language_Str MSG_VOLUMETRIC_ENABLED = _UxGT("E в мм³");
PROGMEM Language_Str MSG_FILAMENT_DIAM = _UxGT("Диаметр филамента");
PROGMEM Language_Str MSG_FILAMENT_DIAM_E = _UxGT("Диаметр филамента *");
PROGMEM Language_Str MSG_FILAMENT_UNLOAD = _UxGT("Загрузка мм");
PROGMEM Language_Str MSG_FILAMENT_LOAD = _UxGT("Выгрузка мм");
PROGMEM Language_Str MSG_ADVANCE_K = _UxGT("K продвижения");
PROGMEM Language_Str MSG_ADVANCE_K_E = _UxGT("K продвижения *");
PROGMEM Language_Str MSG_CONTRAST = _UxGT("Контраст LCD");
PROGMEM Language_Str MSG_STORE_EEPROM = _UxGT("Сохранить настройки");
PROGMEM Language_Str MSG_LOAD_EEPROM = _UxGT("Загрузить настройки");
PROGMEM Language_Str MSG_RESTORE_DEFAULTS = _UxGT("Вернуть настройки");
PROGMEM Language_Str MSG_INIT_EEPROM = _UxGT("Изначальный EEPROM");
PROGMEM Language_Str MSG_MEDIA_UPDATE = _UxGT("Обновление прошивки");
PROGMEM Language_Str MSG_RESET_PRINTER = _UxGT("Сброс принтера");
PROGMEM Language_Str MSG_REFRESH = LCD_STR_REFRESH _UxGT("Обновить");
PROGMEM Language_Str MSG_INFO_SCREEN = _UxGT("Главный экран");
PROGMEM Language_Str MSG_PREPARE = _UxGT("Подготовить");
PROGMEM Language_Str MSG_TUNE = _UxGT("Настроить");
PROGMEM Language_Str MSG_START_PRINT = _UxGT("Начало печати");
PROGMEM Language_Str MSG_BUTTON_NEXT = _UxGT("Дальше");
PROGMEM Language_Str MSG_BUTTON_INIT = _UxGT("Инициализация");
PROGMEM Language_Str MSG_BUTTON_STOP = _UxGT("Остановить");
PROGMEM Language_Str MSG_BUTTON_PRINT = _UxGT("Печать");
PROGMEM Language_Str MSG_BUTTON_RESET = _UxGT("Сброс");
PROGMEM Language_Str MSG_BUTTON_CANCEL = _UxGT("Отмена");
PROGMEM Language_Str MSG_BUTTON_DONE = _UxGT("Готово");
PROGMEM Language_Str MSG_PAUSE_PRINT = _UxGT("Пауза печати");
PROGMEM Language_Str MSG_RESUME_PRINT = _UxGT("Продолжить печать");
PROGMEM Language_Str MSG_STOP_PRINT = _UxGT("Остановить печать");
PROGMEM Language_Str MSG_OUTAGE_RECOVERY = _UxGT("Восстановение сбоя");
PROGMEM Language_Str MSG_MEDIA_MENU = _UxGT("Печать с SD карты");
PROGMEM Language_Str MSG_NO_MEDIA = _UxGT("Нет SD карты");
PROGMEM Language_Str MSG_DWELL = _UxGT("Сон...");
PROGMEM Language_Str MSG_USERWAIT = _UxGT("Продолжить...");
PROGMEM Language_Str MSG_PRINT_PAUSED = _UxGT("Печать на паузе");
PROGMEM Language_Str MSG_PRINT_ABORTED = _UxGT("Печать отменена");
PROGMEM Language_Str MSG_NO_MOVE = _UxGT("Нет движения.");
PROGMEM Language_Str MSG_KILLED = _UxGT("УБИТО. ");
PROGMEM Language_Str MSG_STOPPED = _UxGT("ОСТАНОВЛЕНО. ");
PROGMEM Language_Str MSG_CONTROL_RETRACT = _UxGT("Втягивание мм");
PROGMEM Language_Str MSG_CONTROL_RETRACT_SWAP = _UxGT("Втягивание смены мм");
PROGMEM Language_Str MSG_CONTROL_RETRACTF = _UxGT("Втягивание V");
PROGMEM Language_Str MSG_CONTROL_RETRACT_ZHOP = _UxGT("Втяг. прыжка мм");
PROGMEM Language_Str MSG_CONTROL_RETRACT_RECOVER = _UxGT("Возврат мм");
PROGMEM Language_Str MSG_CONTROL_RETRACT_RECOVER_SWAP = _UxGT("Возврат смены мм");
PROGMEM Language_Str MSG_CONTROL_RETRACT_RECOVERF = _UxGT("Возврат V");
PROGMEM Language_Str MSG_CONTROL_RETRACT_RECOVER_SWAPF = _UxGT("Возврат смены V");
PROGMEM Language_Str MSG_AUTORETRACT = _UxGT("Автовтягивание");
// TODO: Filament Change Swap / Purge Length
PROGMEM Language_Str MSG_TOOL_CHANGE = _UxGT("Смена сопел");
PROGMEM Language_Str MSG_TOOL_CHANGE_ZLIFT = _UxGT("Поднятие по Z");
// TODO: Singlenozzle, nozzle standby
PROGMEM Language_Str MSG_FILAMENTCHANGE = _UxGT("Смена филамента");
PROGMEM Language_Str MSG_FILAMENTCHANGE_E = _UxGT("Смена филамента *");
PROGMEM Language_Str MSG_FILAMENTLOAD = _UxGT("Загрузка филамента");
PROGMEM Language_Str MSG_FILAMENTLOAD_E = _UxGT("Загрузка филамента *");
PROGMEM Language_Str MSG_FILAMENTUNLOAD_E = _UxGT("Выгрузка филамента *");
PROGMEM Language_Str MSG_FILAMENTUNLOAD_ALL = _UxGT("Выгрузить всё");
PROGMEM Language_Str MSG_ATTACH_MEDIA = _UxGT("Активировать SD");
PROGMEM Language_Str MSG_CHANGE_MEDIA = _UxGT("Сменить SD карту");
PROGMEM Language_Str MSG_RELEASE_MEDIA = _UxGT("Деактивировать SD");
PROGMEM Language_Str MSG_ZPROBE_OUT = _UxGT("Z-датчик вне стола");
PROGMEM Language_Str MSG_SKEW_FACTOR = _UxGT("Фактор наклона");
PROGMEM Language_Str MSG_BLTOUCH = _UxGT("BLTouch");
PROGMEM Language_Str MSG_BLTOUCH_SELFTEST = _UxGT("Тестирование BLTouch");
PROGMEM Language_Str MSG_BLTOUCH_RESET = _UxGT("Сброс BLTouch");
PROGMEM Language_Str MSG_BLTOUCH_DEPLOY = _UxGT("Опустить BLTouch");
PROGMEM Language_Str MSG_BLTOUCH_STOW = _UxGT("Поднять BLTouch");
// TODO: TouchMI Probe, Manual deploy/stow
PROGMEM Language_Str MSG_HOME_FIRST = _UxGT("Паркуй %s%s%s сначала");
PROGMEM Language_Str MSG_ZPROBE_OFFSETS = _UxGT("Отступы Z-датчика");
PROGMEM Language_Str MSG_ZPROBE_XOFFSET = _UxGT("Смещение X");
PROGMEM Language_Str MSG_ZPROBE_YOFFSET = _UxGT("Смещение Y");
PROGMEM Language_Str MSG_ZPROBE_ZOFFSET = _UxGT("Смещение Z");
PROGMEM Language_Str MSG_BABYSTEP_X = _UxGT("Микрошаг X");
PROGMEM Language_Str MSG_BABYSTEP_Y = _UxGT("Микрошаг Y");
PROGMEM Language_Str MSG_BABYSTEP_Z = _UxGT("Микрошаг Z");
PROGMEM Language_Str MSG_ENDSTOP_ABORT = _UxGT("Сработал концевик");
PROGMEM Language_Str MSG_HEATING_FAILED_LCD = _UxGT("Разогрев не удался");
PROGMEM Language_Str MSG_HEATING_FAILED_LCD_BED = _UxGT("Неудача нагрева стола");
PROGMEM Language_Str MSG_ERR_REDUNDANT_TEMP = _UxGT("Ошибка: Избыточная Т");
PROGMEM Language_Str MSG_THERMAL_RUNAWAY = _UxGT("УБЕГАНИЕ ТЕПЛА");
PROGMEM Language_Str MSG_THERMAL_RUNAWAY_BED = _UxGT("УБЕГАНИЕ ТЕПЛА СТОЛА");
// TODO: Heated chamber
PROGMEM Language_Str MSG_ERR_MAXTEMP = _UxGT("Ошибка: Т макс.");
PROGMEM Language_Str MSG_ERR_MINTEMP = _UxGT("Ошибка: Т мин.");
PROGMEM Language_Str MSG_ERR_MAXTEMP_BED = _UxGT("Ошибка: Т стола макс");
PROGMEM Language_Str MSG_ERR_MINTEMP_BED = _UxGT("Ошибка: Т стола мин.");
// TODO: Heated chamber
PROGMEM Language_Str MSG_ERR_Z_HOMING = _UxGT("Паркуй XY сначала");
PROGMEM Language_Str MSG_HALTED = _UxGT("ПРИНТЕР ОСТАНОВЛЕН");
PROGMEM Language_Str MSG_PLEASE_RESET = _UxGT("Сделайте сброс");
PROGMEM Language_Str MSG_SHORT_DAY = _UxGT("д"); // One character only
PROGMEM Language_Str MSG_SHORT_HOUR = _UxGT("ч"); // One character only
PROGMEM Language_Str MSG_SHORT_MINUTE = _UxGT("м"); // One character only
PROGMEM Language_Str MSG_HEATING = _UxGT("Нагрев...");
PROGMEM Language_Str MSG_COOLING = _UxGT("Охлаждение...");
PROGMEM Language_Str MSG_BED_HEATING = _UxGT("Нагрев стола...");
PROGMEM Language_Str MSG_BED_COOLING = _UxGT("Охлаждение стола...");
// TODO: Heated chamber
PROGMEM Language_Str MSG_DELTA_CALIBRATE = _UxGT("Калибровка Delta");
PROGMEM Language_Str MSG_DELTA_CALIBRATE_X = _UxGT("Калибровать X");
PROGMEM Language_Str MSG_DELTA_CALIBRATE_Y = _UxGT("Калибровать Y");
PROGMEM Language_Str MSG_DELTA_CALIBRATE_Z = _UxGT("Калибровать Z");
PROGMEM Language_Str MSG_DELTA_CALIBRATE_CENTER = _UxGT("Калибровать центр");
PROGMEM Language_Str MSG_DELTA_SETTINGS = _UxGT("Настройки Delta");
PROGMEM Language_Str MSG_DELTA_AUTO_CALIBRATE = _UxGT("Авто калибровка");
PROGMEM Language_Str MSG_DELTA_HEIGHT_CALIBRATE = _UxGT("Задать высоту Delta");
PROGMEM Language_Str MSG_DELTA_Z_OFFSET_CALIBRATE = _UxGT("Задать Z-смещение");
PROGMEM Language_Str MSG_DELTA_DIAG_ROD = _UxGT("Диаг. стержень");
PROGMEM Language_Str MSG_DELTA_HEIGHT = _UxGT("Высота");
PROGMEM Language_Str MSG_DELTA_RADIUS = _UxGT("Радиус");
PROGMEM Language_Str MSG_INFO_MENU = _UxGT("О принтере");
PROGMEM Language_Str MSG_INFO_PRINTER_MENU = _UxGT("Данные принтера");
PROGMEM Language_Str MSG_3POINT_LEVELING = _UxGT("Калибровка 3-х точек");
PROGMEM Language_Str MSG_LINEAR_LEVELING = _UxGT("Калибровка линейная");
PROGMEM Language_Str MSG_BILINEAR_LEVELING = _UxGT("Калибровка билинейная");
PROGMEM Language_Str MSG_UBL_LEVELING = _UxGT("Калибровка UBL");
PROGMEM Language_Str MSG_MESH_LEVELING = _UxGT("Калибровка сетки");
PROGMEM Language_Str MSG_INFO_STATS_MENU = _UxGT("Статистика принтера");
PROGMEM Language_Str MSG_INFO_BOARD_MENU = _UxGT("Данные платы");
PROGMEM Language_Str MSG_INFO_THERMISTOR_MENU = _UxGT("Термисторы");
PROGMEM Language_Str MSG_INFO_EXTRUDERS = _UxGT("Экструдеры");
PROGMEM Language_Str MSG_INFO_BAUDRATE = _UxGT("Скорость БОД");
PROGMEM Language_Str MSG_INFO_PROTOCOL = _UxGT("Протокол");
PROGMEM Language_Str MSG_INFO_RUNAWAY_OFF = _UxGT("Контроль темп.: Выкл");
PROGMEM Language_Str MSG_INFO_RUNAWAY_ON = _UxGT("Контроль темп.: Вкл");
PROGMEM Language_Str MSG_CASE_LIGHT = _UxGT("Подсветка корпуса");
PROGMEM Language_Str MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Яркость подсветки");
PROGMEM Language_Str MSG_EXPECTED_PRINTER = _UxGT("Неверный принтер");
#if LCD_WIDTH >= 20
PROGMEM Language_Str MSG_INFO_PRINT_COUNT = _UxGT("Счётчик печати");
PROGMEM Language_Str MSG_INFO_COMPLETED_PRINTS = _UxGT("Закончено");
PROGMEM Language_Str MSG_INFO_PRINT_TIME = _UxGT("Общее время печати");
PROGMEM Language_Str MSG_INFO_PRINT_LONGEST = _UxGT("Наидольшее задание");
PROGMEM Language_Str MSG_INFO_PRINT_FILAMENT = _UxGT("Длина филамента");
#else
PROGMEM Language_Str MSG_INFO_PRINT_COUNT = _UxGT("Отпечатков");
PROGMEM Language_Str MSG_INFO_COMPLETED_PRINTS = _UxGT("Закончено");
PROGMEM Language_Str MSG_INFO_PRINT_TIME = _UxGT("Всего");
PROGMEM Language_Str MSG_INFO_PRINT_LONGEST = _UxGT("Наидольшее");
PROGMEM Language_Str MSG_INFO_PRINT_FILAMENT = _UxGT("Выдавлено");
#endif
PROGMEM Language_Str MSG_INFO_MIN_TEMP = _UxGT("Температура мин.");
PROGMEM Language_Str MSG_INFO_MAX_TEMP = _UxGT("Температура макс");
PROGMEM Language_Str MSG_INFO_PSU = _UxGT("БП");
PROGMEM Language_Str MSG_DRIVE_STRENGTH = _UxGT("Сила привода");
PROGMEM Language_Str MSG_DAC_PERCENT_X = _UxGT("X Привод %");
PROGMEM Language_Str MSG_DAC_PERCENT_Y = _UxGT("Y Привод %");
PROGMEM Language_Str MSG_DAC_PERCENT_Z = _UxGT("Z Привод %");
PROGMEM Language_Str MSG_DAC_PERCENT_E = _UxGT("E Привод %");
PROGMEM Language_Str MSG_DAC_EEPROM_WRITE = _UxGT("Запись DAC EEPROM");
PROGMEM Language_Str MSG_FILAMENT_CHANGE_HEADER_PAUSE = _UxGT("ПЕЧАТЬ НА ПАУЗЕ");
PROGMEM Language_Str MSG_FILAMENT_CHANGE_HEADER_LOAD = _UxGT("ЗАГРУЗКА ФИЛАМЕНТА");
PROGMEM Language_Str MSG_FILAMENT_CHANGE_HEADER_UNLOAD = _UxGT("ВЫГРУЗКА ФИЛАМЕНТА");
PROGMEM Language_Str MSG_FILAMENT_CHANGE_OPTION_HEADER = _UxGT("ОПЦИИ ВОЗОБНОВЛЕНИЯ:");
PROGMEM Language_Str MSG_FILAMENT_CHANGE_OPTION_PURGE = _UxGT("Выдавить ещё");
PROGMEM Language_Str MSG_FILAMENT_CHANGE_OPTION_RESUME = _UxGT("Возобновить печать");
PROGMEM Language_Str MSG_FILAMENT_CHANGE_NOZZLE = _UxGT(" Сопла: ");
PROGMEM Language_Str MSG_LCD_HOMING_FAILED = _UxGT("Возврат не удался");
PROGMEM Language_Str MSG_LCD_PROBING_FAILED = _UxGT("Не удалось прощупать");
PROGMEM Language_Str MSG_M600_TOO_COLD = _UxGT("M600: Низкая Т");
// TODO: MMU2
// TODO: Mixing
PROGMEM Language_Str MSG_GAMES = _UxGT("Игры");
PROGMEM Language_Str MSG_BRICKOUT = _UxGT("Кирпичи");
PROGMEM Language_Str MSG_INVADERS = _UxGT("Вторжение");
PROGMEM Language_Str MSG_SNAKE = _UxGT("Змейка");
PROGMEM Language_Str MSG_MAZE = _UxGT("Лабиринт");
//
// Filament Change screens show up to 3 lines on a 4-line display
// ...or up to 2 lines on a 3-line display
//
#if LCD_HEIGHT >= 4
PROGMEM Language_Str MSG_FILAMENT_CHANGE_INIT = _UxGT(MSG_3_LINE("Ожидайте", "начала смены", "филамента"));
PROGMEM Language_Str MSG_FILAMENT_CHANGE_UNLOAD = _UxGT(MSG_3_LINE("Ожидайте", "выгрузки", "филамента"));
PROGMEM Language_Str MSG_FILAMENT_CHANGE_INSERT = _UxGT(MSG_3_LINE("Вставьте пруток", "и нажмите кнопку", "для продолжения"));
PROGMEM Language_Str MSG_FILAMENT_CHANGE_HEAT = _UxGT(MSG_2_LINE("Нажмите кнопку для", "нагрева сопла..."));
PROGMEM Language_Str MSG_FILAMENT_CHANGE_HEATING = _UxGT(MSG_2_LINE("Нагрев сопла", "Ждите..."));
PROGMEM Language_Str MSG_FILAMENT_CHANGE_LOAD = _UxGT(MSG_2_LINE("Ожидайте", "загрузки прутка"));
PROGMEM Language_Str MSG_FILAMENT_CHANGE_PURGE = _UxGT(MSG_3_LINE("Ожидайте", "экструзии", "филамента"));
PROGMEM Language_Str MSG_FILAMENT_CHANGE_RESUME = _UxGT(MSG_3_LINE("Ожидайте", "возобновления", "печати"));
#else
PROGMEM Language_Str MSG_FILAMENT_CHANGE_INIT = _UxGT(MSG_1_LINE("Ожидайте..."));
PROGMEM Language_Str MSG_FILAMENT_CHANGE_UNLOAD = _UxGT(MSG_1_LINE("Выгрузка..."));
PROGMEM Language_Str MSG_FILAMENT_CHANGE_INSERT = _UxGT(MSG_1_LINE("Вставь и нажми"));
PROGMEM Language_Str MSG_FILAMENT_CHANGE_HEATING = _UxGT(MSG_1_LINE("Нагрев..."));
PROGMEM Language_Str MSG_FILAMENT_CHANGE_LOAD = _UxGT(MSG_1_LINE("Загрузка..."));
PROGMEM Language_Str MSG_FILAMENT_CHANGE_PURGE = _UxGT(MSG_1_LINE("Выдавливание..."));
PROGMEM Language_Str MSG_FILAMENT_CHANGE_RESUME = _UxGT(MSG_1_LINE("Возобновление..."));
#endif
PROGMEM Language_Str MSG_TMC_DRIVERS = _UxGT("Драйвера TMC");
PROGMEM Language_Str MSG_TMC_CURRENT = _UxGT("Текущие настройки");
PROGMEM Language_Str MSG_TMC_HYBRID_THRS = _UxGT("Гибридный режим");
PROGMEM Language_Str MSG_TMC_HOMING_THRS = _UxGT("Режим без эндстопов");
PROGMEM Language_Str MSG_TMC_STEPPING_MODE = _UxGT("Режим шага");
PROGMEM Language_Str MSG_TMC_STEALTH_ENABLED = _UxGT("Тихий режим вкл");
// TODO: Service
// TODO: Backlash
}
| 76.766529 | 137 | 0.631759 |
d20f687861b326f20eb799c4466fab1ee315fad9 | 20,406 | c | C | src/source/PeerConnection/Rtcp.c | Nomidia/amazon-kinesis-video-streams-webrtc-sdk-c | 3225b967267ed486b29c0901cdf82d6dc1231bcf | [
"Apache-2.0"
] | 4 | 2021-06-10T15:52:30.000Z | 2022-02-05T13:15:42.000Z | src/source/PeerConnection/Rtcp.c | Nomidia/amazon-kinesis-video-streams-webrtc-sdk-c | 3225b967267ed486b29c0901cdf82d6dc1231bcf | [
"Apache-2.0"
] | null | null | null | src/source/PeerConnection/Rtcp.c | Nomidia/amazon-kinesis-video-streams-webrtc-sdk-c | 3225b967267ed486b29c0901cdf82d6dc1231bcf | [
"Apache-2.0"
] | 2 | 2020-12-04T20:59:22.000Z | 2021-05-04T17:34:37.000Z | #define LOG_CLASS "RtcRtcp"
#include "../Include_i.h"
// TODO handle FIR packet https://tools.ietf.org/html/rfc2032#section-5.2.1
static STATUS onRtcpFIRPacket(PRtcpPacket pRtcpPacket, PKvsPeerConnection pKvsPeerConnection)
{
STATUS retStatus = STATUS_SUCCESS;
UINT32 mediaSSRC;
PKvsRtpTransceiver pTransceiver = NULL;
CHK(pKvsPeerConnection != NULL && pRtcpPacket != NULL, STATUS_NULL_ARG);
mediaSSRC = getUnalignedInt32BigEndian((pRtcpPacket->payload + (SIZEOF(UINT32))));
if (STATUS_SUCCEEDED(findTransceiverBySsrc(pKvsPeerConnection, &pTransceiver, mediaSSRC))) {
MUTEX_LOCK(pTransceiver->statsLock);
pTransceiver->outboundStats.firCount++;
MUTEX_UNLOCK(pTransceiver->statsLock);
if (pTransceiver->onPictureLoss != NULL) {
pTransceiver->onPictureLoss(pTransceiver->onPictureLossCustomData);
}
} else {
DLOGW("Received FIR for non existing ssrc: %u", mediaSSRC);
}
CleanUp:
return retStatus;
}
// TODO handle SLI packet https://tools.ietf.org/html/rfc4585#section-6.3.2
static STATUS onRtcpSLIPacket(PRtcpPacket pRtcpPacket, PKvsPeerConnection pKvsPeerConnection)
{
STATUS retStatus = STATUS_SUCCESS;
UINT32 mediaSSRC;
PKvsRtpTransceiver pTransceiver = NULL;
CHK(pKvsPeerConnection != NULL && pRtcpPacket != NULL, STATUS_NULL_ARG);
mediaSSRC = getUnalignedInt32BigEndian((pRtcpPacket->payload + (SIZEOF(UINT32))));
if (STATUS_SUCCEEDED(findTransceiverBySsrc(pKvsPeerConnection, &pTransceiver, mediaSSRC))) {
MUTEX_LOCK(pTransceiver->statsLock);
pTransceiver->outboundStats.sliCount++;
MUTEX_UNLOCK(pTransceiver->statsLock);
} else {
DLOGW("Received FIR for non existing ssrc: %u", mediaSSRC);
}
CleanUp:
return retStatus;
}
// TODO better sender report handling https://tools.ietf.org/html/rfc3550#section-6.4.1
static STATUS onRtcpSenderReport(PRtcpPacket pRtcpPacket, PKvsPeerConnection pKvsPeerConnection)
{
STATUS retStatus = STATUS_SUCCESS;
UINT32 senderSSRC;
PKvsRtpTransceiver pTransceiver = NULL;
CHK(pKvsPeerConnection != NULL && pRtcpPacket != NULL, STATUS_NULL_ARG);
if (pRtcpPacket->payloadLength != RTCP_PACKET_SENDER_REPORT_MINLEN) {
// TODO: handle sender report containing receiver report blocks
return STATUS_SUCCESS;
}
senderSSRC = getUnalignedInt32BigEndian(pRtcpPacket->payload);
if (STATUS_SUCCEEDED(findTransceiverBySsrc(pKvsPeerConnection, &pTransceiver, senderSSRC))) {
UINT64 ntpTime = getUnalignedInt64BigEndian(pRtcpPacket->payload + 4);
UINT32 rtpTs = getUnalignedInt32BigEndian(pRtcpPacket->payload + 12);
UINT32 packetCnt = getUnalignedInt32BigEndian(pRtcpPacket->payload + 16);
UINT32 octetCnt = getUnalignedInt32BigEndian(pRtcpPacket->payload + 20);
DLOGV("RTCP_PACKET_TYPE_SENDER_REPORT %d %" PRIu64 " rtpTs: %u %u pkts %u bytes", senderSSRC, ntpTime, rtpTs, packetCnt, octetCnt);
} else {
DLOGW("Received sender report for non existing ssrc: %u", senderSSRC);
}
CleanUp:
return retStatus;
}
static STATUS onRtcpReceiverReport(PRtcpPacket pRtcpPacket, PKvsPeerConnection pKvsPeerConnection)
{
STATUS retStatus = STATUS_SUCCESS;
PKvsRtpTransceiver pTransceiver = NULL;
DOUBLE fractionLost;
UINT32 rttPropDelayMsec = 0, rttPropDelay, delaySinceLastSR, lastSR, interarrivalJitter, extHiSeqNumReceived, cumulativeLost, senderSSRC, ssrc1;
UINT64 currentTimeNTP = convertTimestampToNTP(GETTIME());
CHK(pKvsPeerConnection != NULL && pRtcpPacket != NULL, STATUS_NULL_ARG);
// https://tools.ietf.org/html/rfc3550#section-6.4.2
if (pRtcpPacket->payloadLength != RTCP_PACKET_RECEIVER_REPORT_MINLEN) {
// TODO: handle multiple receiver report blocks
return STATUS_SUCCESS;
}
senderSSRC = getUnalignedInt32BigEndian(pRtcpPacket->payload);
ssrc1 = getUnalignedInt32BigEndian(pRtcpPacket->payload + 4);
if (STATUS_FAILED(findTransceiverBySsrc(pKvsPeerConnection, &pTransceiver, ssrc1))) {
DLOGW("Received receiver report for non existing ssrc: %u", ssrc1);
return STATUS_SUCCESS; // not really an error ?
}
fractionLost = pRtcpPacket->payload[8] / 255.0;
cumulativeLost = ((UINT32) getUnalignedInt32BigEndian(pRtcpPacket->payload + 8)) & 0x00ffffffu;
extHiSeqNumReceived = getUnalignedInt32BigEndian(pRtcpPacket->payload + 12);
interarrivalJitter = getUnalignedInt32BigEndian(pRtcpPacket->payload + 16);
lastSR = getUnalignedInt32BigEndian(pRtcpPacket->payload + 20);
delaySinceLastSR = getUnalignedInt32BigEndian(pRtcpPacket->payload + 24);
DLOGS("RTCP_PACKET_TYPE_RECEIVER_REPORT %u %u loss: %u %u seq: %u jit: %u lsr: %u dlsr: %u", senderSSRC, ssrc1, fractionLost, cumulativeLost,
extHiSeqNumReceived, interarrivalJitter, lastSR, delaySinceLastSR);
if (lastSR != 0) {
// https://tools.ietf.org/html/rfc3550#section-6.4.1
// Source SSRC_n can compute the round-trip propagation delay to
// SSRC_r by recording the time A when this reception report block is
// received. It calculates the total round-trip time A-LSR using the
// last SR timestamp (LSR) field, and then subtracting this field to
// leave the round-trip propagation delay as (A - LSR - DLSR).
rttPropDelay = MID_NTP(currentTimeNTP) - lastSR - delaySinceLastSR;
rttPropDelayMsec = KVS_CONVERT_TIMESCALE(rttPropDelay, DLSR_TIMESCALE, 1000);
DLOGS("RTCP_PACKET_TYPE_RECEIVER_REPORT rttPropDelay %u msec", rttPropDelayMsec);
}
MUTEX_LOCK(pTransceiver->statsLock);
pTransceiver->remoteInboundStats.reportsReceived++;
if (fractionLost > -1.0) {
pTransceiver->remoteInboundStats.fractionLost = fractionLost;
}
pTransceiver->remoteInboundStats.roundTripTimeMeasurements++;
pTransceiver->remoteInboundStats.totalRoundTripTime += rttPropDelayMsec;
pTransceiver->remoteInboundStats.roundTripTime = rttPropDelayMsec;
MUTEX_UNLOCK(pTransceiver->statsLock);
CleanUp:
return retStatus;
}
STATUS parseRtcpTwccPacket(PRtcpPacket pRtcpPacket, PTwccManager pTwccManager)
{
/*
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|V=2|P| FMT=15 | PT=205 | length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| SSRC of packet sender |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| SSRC of media source |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| base sequence number | packet status count |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| reference time | fb pkt. count |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| packet chunk | packet chunk |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
. .
. .
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| packet chunk | recv delta | recv delta |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
. .
. .
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| recv delta | recv delta | zero padding |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
STATUS retStatus = STATUS_SUCCESS;
INT32 packetsRemaining;
UINT16 baseSeqNum, packetStatusCount, packetSeqNum;
UINT32 chunkOffset, recvOffset;
UINT8 statusSymbol;
UINT32 packetChunk;
INT16 recvDelta;
UINT32 statuses;
UINT32 i;
UINT64 referenceTime;
CHK(pTwccManager != NULL && pRtcpPacket != NULL, STATUS_NULL_ARG);
baseSeqNum = getUnalignedInt16BigEndian(pRtcpPacket->payload + 8);
packetStatusCount = TWCC_PACKET_STATUS_COUNT(pRtcpPacket->payload);
referenceTime = (pRtcpPacket->payload[12] << 16) | (pRtcpPacket->payload[13] << 8) | (pRtcpPacket->payload[14] & 0xff);
referenceTime = KVS_CONVERT_TIMESCALE(referenceTime * 64, MILLISECONDS_PER_SECOND, HUNDREDS_OF_NANOS_IN_A_SECOND);
// TODO: handle lost twcc report packets
packetsRemaining = packetStatusCount;
chunkOffset = 16;
while (packetsRemaining > 0 && chunkOffset < pRtcpPacket->payloadLength) {
packetChunk = getUnalignedInt16BigEndian(pRtcpPacket->payload + chunkOffset);
if (IS_TWCC_RUNLEN(packetChunk)) {
packetsRemaining -= TWCC_RUNLEN_GET(packetChunk);
} else {
packetsRemaining -= MIN(TWCC_STATUSVECTOR_COUNT(packetChunk), packetsRemaining);
}
chunkOffset += TWCC_FB_PACKETCHUNK_SIZE;
}
recvOffset = chunkOffset;
chunkOffset = 16;
packetSeqNum = baseSeqNum;
packetsRemaining = packetStatusCount;
while (packetsRemaining > 0) {
packetChunk = getUnalignedInt16BigEndian(pRtcpPacket->payload + chunkOffset);
statusSymbol = TWCC_RUNLEN_STATUS_SYMBOL(packetChunk);
if (IS_TWCC_RUNLEN(packetChunk)) {
for (i = 0; i < TWCC_RUNLEN_GET(packetChunk); i++) {
recvDelta = MIN_INT16;
switch (statusSymbol) {
case TWCC_STATUS_SYMBOL_SMALLDELTA:
recvDelta = (INT16) pRtcpPacket->payload[recvOffset];
recvOffset++;
break;
case TWCC_STATUS_SYMBOL_LARGEDELTA:
recvDelta = getUnalignedInt16BigEndian(pRtcpPacket->payload + recvOffset);
recvOffset += 2;
break;
case TWCC_STATUS_SYMBOL_NOTRECEIVED:
DLOGS("runLength packetSeqNum %u not received %lu", packetSeqNum, referenceTime);
pTwccManager->twccPacketBySeqNum[packetSeqNum].remoteTimeKvs = TWCC_PACKET_LOST_TIME;
pTwccManager->lastReportedSeqNum = packetSeqNum;
break;
default:
DLOGD("runLength unhandled statusSymbol %u", statusSymbol);
}
if (recvDelta != MIN_INT16) {
referenceTime += KVS_CONVERT_TIMESCALE(recvDelta, TWCC_TICKS_PER_SECOND, HUNDREDS_OF_NANOS_IN_A_SECOND);
DLOGS("runLength packetSeqNum %u received %lu", packetSeqNum, referenceTime);
pTwccManager->twccPacketBySeqNum[packetSeqNum].remoteTimeKvs = referenceTime;
pTwccManager->lastReportedSeqNum = packetSeqNum;
}
packetSeqNum++;
packetsRemaining--;
}
} else {
statuses = MIN(TWCC_STATUSVECTOR_COUNT(packetChunk), packetsRemaining);
for (i = 0; i < statuses; i++) {
statusSymbol = TWCC_STATUSVECTOR_STATUS(packetChunk, i);
recvDelta = MIN_INT16;
switch (statusSymbol) {
case TWCC_STATUS_SYMBOL_SMALLDELTA:
recvDelta = (INT16) pRtcpPacket->payload[recvOffset];
recvOffset++;
break;
case TWCC_STATUS_SYMBOL_LARGEDELTA:
recvDelta = getUnalignedInt16BigEndian(pRtcpPacket->payload + recvOffset);
recvOffset += 2;
break;
case TWCC_STATUS_SYMBOL_NOTRECEIVED:
DLOGS("statusVector packetSeqNum %u not received %lu", packetSeqNum, referenceTime);
pTwccManager->twccPacketBySeqNum[packetSeqNum].remoteTimeKvs = TWCC_PACKET_LOST_TIME;
pTwccManager->lastReportedSeqNum = packetSeqNum;
break;
default:
DLOGD("statusVector unhandled statusSymbol %u", statusSymbol);
}
if (recvDelta != MIN_INT16) {
referenceTime += KVS_CONVERT_TIMESCALE(recvDelta, TWCC_TICKS_PER_SECOND, HUNDREDS_OF_NANOS_IN_A_SECOND);
DLOGS("statusVector packetSeqNum %u received %lu", packetSeqNum, referenceTime);
pTwccManager->twccPacketBySeqNum[packetSeqNum].remoteTimeKvs = referenceTime;
pTwccManager->lastReportedSeqNum = packetSeqNum;
}
packetSeqNum++;
packetsRemaining--;
}
}
chunkOffset += TWCC_FB_PACKETCHUNK_SIZE;
}
CleanUp:
CHK_LOG_ERR(retStatus);
return retStatus;
}
STATUS onRtcpTwccPacket(PRtcpPacket pRtcpPacket, PKvsPeerConnection pKvsPeerConnection)
{
STATUS retStatus = STATUS_SUCCESS;
PTwccManager twcc;
BOOL locked = FALSE;
BOOL empty = TRUE;
UINT64 sn = 0;
INT64 ageOfOldestPacket;
UINT64 localStartTimeKvs, localEndTimeKvs;
UINT64 sentBytes = 0, receivedBytes = 0;
UINT64 sentPackets = 0, receivedPackets = 0;
INT64 duration = 0;
UINT16 seqNum;
PTwccPacket twccPacket;
CHK(pKvsPeerConnection != NULL && pRtcpPacket != NULL, STATUS_NULL_ARG);
CHK(pKvsPeerConnection->onSenderBandwidthEstimation != NULL && pKvsPeerConnection->pTwccManager != NULL, STATUS_SUCCESS);
MUTEX_LOCK(pKvsPeerConnection->twccLock);
locked = TRUE;
twcc = pKvsPeerConnection->pTwccManager;
CHK_STATUS(parseRtcpTwccPacket(pRtcpPacket, twcc));
CHK_STATUS(stackQueueIsEmpty(&twcc->twccPackets, &empty));
CHK(!empty, STATUS_SUCCESS);
CHK_STATUS(stackQueuePeek(&twcc->twccPackets, &sn));
ageOfOldestPacket = twcc->lastLocalTimeKvs - twcc->twccPacketBySeqNum[(UINT16) sn].localTimeKvs;
CHK(ageOfOldestPacket > TWCC_ESTIMATOR_TIME_WINDOW / 2, STATUS_SUCCESS);
localStartTimeKvs = twcc->twccPacketBySeqNum[(UINT16)(sn - 1)].localTimeKvs;
if (localStartTimeKvs == TWCC_PACKET_UNITIALIZED_TIME) {
// time not yet set (only happens for first rtp packet)
localStartTimeKvs = twcc->twccPacketBySeqNum[(UINT16) sn].localTimeKvs;
}
for (seqNum = sn; duration < TWCC_ESTIMATOR_TIME_WINDOW && seqNum != twcc->lastReportedSeqNum; seqNum++) {
twccPacket = &twcc->twccPacketBySeqNum[seqNum];
localEndTimeKvs = twccPacket->localTimeKvs;
duration = localEndTimeKvs - localStartTimeKvs;
sentBytes += twccPacket->packetSize;
sentPackets++;
if (twccPacket->remoteTimeKvs != TWCC_PACKET_LOST_TIME) {
receivedBytes += twccPacket->packetSize;
receivedPackets++;
}
}
if (duration > 0) {
MUTEX_UNLOCK(pKvsPeerConnection->twccLock);
locked = FALSE;
pKvsPeerConnection->onSenderBandwidthEstimation(pKvsPeerConnection->onSenderBandwidthEstimationCustomData, sentBytes, receivedBytes,
sentPackets, receivedPackets, duration);
}
CleanUp:
CHK_LOG_ERR(retStatus);
if (locked) {
MUTEX_UNLOCK(pKvsPeerConnection->twccLock);
}
return retStatus;
}
STATUS onRtcpPacket(PKvsPeerConnection pKvsPeerConnection, PBYTE pBuff, UINT32 buffLen)
{
STATUS retStatus = STATUS_SUCCESS;
RtcpPacket rtcpPacket;
UINT32 currentOffset = 0;
CHK(pKvsPeerConnection != NULL && pBuff != NULL, STATUS_NULL_ARG);
while (currentOffset < buffLen) {
CHK_STATUS(setRtcpPacketFromBytes(pBuff + currentOffset, buffLen - currentOffset, &rtcpPacket));
switch (rtcpPacket.header.packetType) {
case RTCP_PACKET_TYPE_FIR:
CHK_STATUS(onRtcpFIRPacket(&rtcpPacket, pKvsPeerConnection));
break;
case RTCP_PACKET_TYPE_GENERIC_RTP_FEEDBACK:
if (rtcpPacket.header.receptionReportCount == RTCP_FEEDBACK_MESSAGE_TYPE_NACK) {
CHK_STATUS(resendPacketOnNack(&rtcpPacket, pKvsPeerConnection));
} else if (rtcpPacket.header.receptionReportCount == RTCP_FEEDBACK_MESSAGE_TYPE_APPLICATION_LAYER_FEEDBACK) {
CHK_STATUS(onRtcpTwccPacket(&rtcpPacket, pKvsPeerConnection));
} else {
DLOGW("unhandled RTCP_PACKET_TYPE_GENERIC_RTP_FEEDBACK %d", rtcpPacket.header.receptionReportCount);
}
break;
case RTCP_PACKET_TYPE_PAYLOAD_SPECIFIC_FEEDBACK:
if (rtcpPacket.header.receptionReportCount == RTCP_FEEDBACK_MESSAGE_TYPE_APPLICATION_LAYER_FEEDBACK &&
isRembPacket(rtcpPacket.payload, rtcpPacket.payloadLength) == STATUS_SUCCESS) {
CHK_STATUS(onRtcpRembPacket(&rtcpPacket, pKvsPeerConnection));
} else if (rtcpPacket.header.receptionReportCount == RTCP_PSFB_PLI) {
CHK_STATUS(onRtcpPLIPacket(&rtcpPacket, pKvsPeerConnection));
} else if (rtcpPacket.header.receptionReportCount == RTCP_PSFB_SLI) {
CHK_STATUS(onRtcpSLIPacket(&rtcpPacket, pKvsPeerConnection));
} else {
DLOGW("unhandled packet type RTCP_PACKET_TYPE_PAYLOAD_SPECIFIC_FEEDBACK %d", rtcpPacket.header.receptionReportCount);
}
break;
case RTCP_PACKET_TYPE_SENDER_REPORT:
CHK_STATUS(onRtcpSenderReport(&rtcpPacket, pKvsPeerConnection));
break;
case RTCP_PACKET_TYPE_RECEIVER_REPORT:
CHK_STATUS(onRtcpReceiverReport(&rtcpPacket, pKvsPeerConnection));
break;
case RTCP_PACKET_TYPE_SOURCE_DESCRIPTION:
DLOGV("unhandled packet type RTCP_PACKET_TYPE_SOURCE_DESCRIPTION");
break;
default:
DLOGW("unhandled packet type %d", rtcpPacket.header.packetType);
break;
}
currentOffset += (rtcpPacket.payloadLength + RTCP_PACKET_HEADER_LEN);
}
CleanUp:
CHK_LOG_ERR(retStatus);
return retStatus;
}
STATUS onRtcpRembPacket(PRtcpPacket pRtcpPacket, PKvsPeerConnection pKvsPeerConnection)
{
STATUS retStatus = STATUS_SUCCESS;
UINT32 ssrcList[MAX_UINT8] = {0};
DOUBLE maximumBitRate = 0;
UINT8 ssrcListLen;
UINT32 i;
PKvsRtpTransceiver pTransceiver = NULL;
CHK(pKvsPeerConnection != NULL && pRtcpPacket != NULL, STATUS_NULL_ARG);
CHK_STATUS(rembValueGet(pRtcpPacket->payload, pRtcpPacket->payloadLength, &maximumBitRate, (PUINT32) &ssrcList, &ssrcListLen));
for (i = 0; i < ssrcListLen; i++) {
pTransceiver = NULL;
if (STATUS_FAILED(findTransceiverBySsrc(pKvsPeerConnection, &pTransceiver, ssrcList[i]))) {
DLOGW("Received REMB for non existing ssrcs: ssrc %lu", ssrcList[i]);
}
if (pTransceiver != NULL && pTransceiver->onBandwidthEstimation != NULL) {
pTransceiver->onBandwidthEstimation(pTransceiver->onBandwidthEstimationCustomData, maximumBitRate);
}
}
CleanUp:
return retStatus;
}
STATUS onRtcpPLIPacket(PRtcpPacket pRtcpPacket, PKvsPeerConnection pKvsPeerConnection)
{
STATUS retStatus = STATUS_SUCCESS;
UINT32 mediaSSRC;
PKvsRtpTransceiver pTransceiver = NULL;
CHK(pKvsPeerConnection != NULL && pRtcpPacket != NULL, STATUS_NULL_ARG);
mediaSSRC = getUnalignedInt32BigEndian((pRtcpPacket->payload + (SIZEOF(UINT32))));
CHK_STATUS_ERR(findTransceiverBySsrc(pKvsPeerConnection, &pTransceiver, mediaSSRC), STATUS_RTCP_INPUT_SSRC_INVALID,
"Received PLI for non existing ssrc: %u", mediaSSRC);
MUTEX_LOCK(pTransceiver->statsLock);
pTransceiver->outboundStats.pliCount++;
MUTEX_UNLOCK(pTransceiver->statsLock);
if (pTransceiver->onPictureLoss != NULL) {
pTransceiver->onPictureLoss(pTransceiver->onPictureLossCustomData);
}
CleanUp:
return retStatus;
}
| 45.651007 | 148 | 0.625061 |
d62c54cc988e1f055a65124d3a6610e1e337c778 | 1,979 | h | C | model/ezsigndocument_get_temporary_proof_v1_response.h | ezmaxinc/eZmax-SDK-c | 725eab79d6311127a2d5bd731b978bce94142d69 | [
"curl",
"MIT"
] | null | null | null | model/ezsigndocument_get_temporary_proof_v1_response.h | ezmaxinc/eZmax-SDK-c | 725eab79d6311127a2d5bd731b978bce94142d69 | [
"curl",
"MIT"
] | null | null | null | model/ezsigndocument_get_temporary_proof_v1_response.h | ezmaxinc/eZmax-SDK-c | 725eab79d6311127a2d5bd731b978bce94142d69 | [
"curl",
"MIT"
] | null | null | null | /*
* ezsigndocument_get_temporary_proof_v1_response.h
*
* Response for GET /1/object/ezsigndocument/{pkiEzsigndocumentID}/getTemporaryProof
*/
#ifndef _ezsigndocument_get_temporary_proof_v1_response_H_
#define _ezsigndocument_get_temporary_proof_v1_response_H_
#include <string.h>
#include "../external/cJSON.h"
#include "../include/list.h"
#include "../include/keyValuePair.h"
#include "../include/binary.h"
typedef struct ezsigndocument_get_temporary_proof_v1_response_t ezsigndocument_get_temporary_proof_v1_response_t;
#include "common_response.h"
#include "common_response_obj_debug.h"
#include "common_response_obj_debug_payload.h"
#include "ezsigndocument_get_temporary_proof_v1_response_all_of.h"
#include "ezsigndocument_get_temporary_proof_v1_response_m_payload.h"
typedef struct ezsigndocument_get_temporary_proof_v1_response_t {
struct ezsigndocument_get_temporary_proof_v1_response_m_payload_t *m_payload; //model
struct common_response_obj_debug_payload_t *obj_debug_payload; //model
struct common_response_obj_debug_t *obj_debug; //model
} ezsigndocument_get_temporary_proof_v1_response_t;
ezsigndocument_get_temporary_proof_v1_response_t *ezsigndocument_get_temporary_proof_v1_response_create(
ezsigndocument_get_temporary_proof_v1_response_m_payload_t *m_payload,
common_response_obj_debug_payload_t *obj_debug_payload,
common_response_obj_debug_t *obj_debug
);
void ezsigndocument_get_temporary_proof_v1_response_free(ezsigndocument_get_temporary_proof_v1_response_t *ezsigndocument_get_temporary_proof_v1_response);
ezsigndocument_get_temporary_proof_v1_response_t *ezsigndocument_get_temporary_proof_v1_response_parseFromJSON(cJSON *ezsigndocument_get_temporary_proof_v1_responseJSON);
cJSON *ezsigndocument_get_temporary_proof_v1_response_convertToJSON(ezsigndocument_get_temporary_proof_v1_response_t *ezsigndocument_get_temporary_proof_v1_response);
#endif /* _ezsigndocument_get_temporary_proof_v1_response_H_ */
| 42.106383 | 170 | 0.880243 |
aac47d02b3f10fb8d99a4ea71a8d7c60d4f55bdc | 159 | h | C | iOS/10.0.2/protocols/INApplicationContextProviding.h | onmyway133/Runtime-Headers | e9b80e7ab9103f37ad421ad6b8b58ee06369d21f | [
"MIT"
] | 30 | 2016-10-09T20:13:00.000Z | 2022-01-24T04:14:57.000Z | iOS/10.0.2/protocols/INApplicationContextProviding.h | onmyway133/Runtime-Headers | e9b80e7ab9103f37ad421ad6b8b58ee06369d21f | [
"MIT"
] | null | null | null | iOS/10.0.2/protocols/INApplicationContextProviding.h | onmyway133/Runtime-Headers | e9b80e7ab9103f37ad421ad6b8b58ee06369d21f | [
"MIT"
] | 7 | 2017-08-29T14:41:25.000Z | 2022-01-19T17:14:54.000Z | /* Generated by RuntimeBrowser.
*/
@protocol INApplicationContextProviding <NSObject>
@required
- (INApplicationContext *)currentApplicationContext;
@end
| 14.454545 | 52 | 0.792453 |
cf81b51c8a924dbc1dda6c3605a6ee82a1384916 | 24,700 | h | C | SXR/SDK/backend_daydream/src/main/jni/vr/gvr/capi/include/gvr_types.h | apjagdale/sxrsdk | b478bd582074a8f8c267e4ad9d6ebc903efedf3a | [
"Apache-2.0"
] | 474 | 2015-03-27T17:14:43.000Z | 2022-03-30T23:10:38.000Z | SXR/SDK/backend_daydream/src/main/jni/vr/gvr/capi/include/gvr_types.h | apjagdale/sxrsdk | b478bd582074a8f8c267e4ad9d6ebc903efedf3a | [
"Apache-2.0"
] | 1,677 | 2015-03-28T02:00:21.000Z | 2019-10-21T13:28:44.000Z | SXR/SDK/backend_daydream/src/main/jni/vr/gvr/capi/include/gvr_types.h | apjagdale/sxrsdk | b478bd582074a8f8c267e4ad9d6ebc903efedf3a | [
"Apache-2.0"
] | 260 | 2015-03-27T23:55:12.000Z | 2022-03-18T03:46:41.000Z | /* Copyright 2016 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef VR_GVR_CAPI_INCLUDE_GVR_TYPES_H_
#define VR_GVR_CAPI_INCLUDE_GVR_TYPES_H_
#include <stdbool.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/// @defgroup types Google VR Types
/// @brief Various types used in the Google VR NDK.
/// @{
/// Primary context for invoking Google VR APIs.
typedef struct gvr_context_ gvr_context;
/// An enum for the left and right eye.
typedef enum {
GVR_LEFT_EYE = 0,
GVR_RIGHT_EYE,
GVR_NUM_EYES
} gvr_eye;
/// The type of VR viewer.
typedef enum {
/// A Cardboard-compatible viewer. A typical Cardboard viewer supports a
/// simple touchscreen-based trigger input mechanism. On most platforms, this
// is the default viewer type if no viewer has been explicitly paired.
GVR_VIEWER_TYPE_CARDBOARD = 0,
/// A Daydream-compatible viewer. A typical Daydream viewer supports 3DOF
/// controller input (as defined in gvr_controller.h), and is intended only
/// for Daydream-ready platforms. It does *not* support touchscreen-based
/// input unless Cardboard emulation is explicitly enabled.
GVR_VIEWER_TYPE_DAYDREAM = 1,
} gvr_viewer_type;
// Types of VR-specific features which may or may not be supported on the
// underlying platform.
typedef enum {
// Asynchronous reprojection warps the app's rendered frame using the most
// recent head pose just before pushing the frame to the display.
GVR_FEATURE_ASYNC_REPROJECTION = 0,
} gvr_feature;
/// @}
/// Version information for the Google VR API.
typedef struct gvr_version_ {
int32_t major;
int32_t minor;
int32_t patch;
} gvr_version;
/// An integral 2D size. Used for render target sizes.
typedef struct gvr_sizei {
int32_t width;
int32_t height;
} gvr_sizei;
/// An integral 2D rect. Used for window bounds in pixels.
typedef struct gvr_recti {
int32_t left;
int32_t right;
int32_t bottom;
int32_t top;
} gvr_recti;
/// A floating point 2D rect. Used for field of view, and also for ranges
/// in texture space. When used for a field of view, all angles are in positive
/// degrees from the optical axis.
typedef struct gvr_rectf {
float left;
float right;
float bottom;
float top;
} gvr_rectf;
/// A floating point 2D vector.
typedef struct gvr_vec2f {
float x;
float y;
} gvr_vec2f;
/// A floating point 3D vector.
typedef struct gvr_vec3f {
float x;
float y;
float z;
} gvr_vec3f;
/// A floating point 4x4 matrix.
typedef struct gvr_mat4f { float m[4][4]; } gvr_mat4f;
/// A floating point quaternion, in JPL format.
/// We use this simple struct in order not to impose a dependency on a
/// particular math library. The user of this API is free to encapsulate this
/// into any math library they want.
typedef struct gvr_quatf {
/// qx, qy, qz are the vector component.
float qx;
float qy;
float qz;
/// qw is the linelar component.
float qw;
} gvr_quatf;
/// A *monotonic system time* representation. On Android, this is equivalent to
/// System.nanoTime(), or clock_gettime(CLOCK_MONOTONIC). If there is any doubt
/// about how to get the current time for the current platform, simply use
/// gvr_get_time_point_now().
typedef struct gvr_clock_time_point {
int64_t monotonic_system_time_nanos;
} gvr_clock_time_point;
/// A structure that ties together a region of a buffer, the field of view
/// rendered into that region and a target eye index to define part of the
/// user's field of view. The SDK implementation uses this information to
/// transform the images generated by the app output into the final display that
/// is sent to the screen.
///
/// A set of these structures will most often be generated by the API, via
/// gvr_get_recommended_buffer_viewports() or
/// gvr_get_screen_buffer_viewports(). However, the client may also customize
/// these values via gvr_buffer_viewport_list_set(), constructing a custom
/// gvr_buffer_viewport_list for use in the distortion pass.
typedef struct gvr_buffer_viewport_ gvr_buffer_viewport;
/// List of buffer viewports that completely specifies how to transform the
/// frame's buffers into the image displayed on the screen.
typedef struct gvr_buffer_viewport_list_ gvr_buffer_viewport_list;
/// Specification of a pixel buffer. A pixel buffer can have color, depth and
/// stencil attachments and mostly corresponds to the OpenGL concept of a
/// framebuffer object. However, since there can be multiple such objects for
/// each frame, we avoid calling them "framebuffers". Pixel buffers which are
/// part of the currently acquired frame are immutable, i.e., they cannot be
/// resized or otherwise reconfigured.
typedef struct gvr_buffer_spec_ gvr_buffer_spec;
/// Swap chain that contains some number of frames. Frames in the swap chain
/// can be unused, in the process of being distorted and presented on the
/// screen, or acquired and being rendered to by the application. The swap chain
/// ensures that the most recent available frame is always shown and that the
/// application never has to wait to render the next frame.
typedef struct gvr_swap_chain_ gvr_swap_chain;
/// A single frame acquired from the swap chain. Each frame is composed of one
/// or more buffers, which are then lens distorted and composited into the final
/// output. Buffers are identified by indices that correspond to the position
/// of their gvr_buffer_spec in the list passed when constructing the swap
/// chain.
typedef struct gvr_frame_ gvr_frame;
/// @addtogroup types
/// @{
/// Constants that represent GVR error codes.
typedef enum {
GVR_ERROR_NONE = 0,
GVR_ERROR_CONTROLLER_CREATE_FAILED = 2,
GVR_ERROR_NO_FRAME_AVAILABLE = 3,
} gvr_error;
/// Controller API options (bit flags).
enum {
/// Indicates that controller orientation data should be reported.
GVR_CONTROLLER_ENABLE_ORIENTATION = 1 << 0,
/// Indicates that controller touchpad data should be reported.
GVR_CONTROLLER_ENABLE_TOUCH = 1 << 1,
/// Indicates that controller gyroscope data should be reported.
GVR_CONTROLLER_ENABLE_GYRO = 1 << 2,
/// Indicates that controller accelerometer data should be reported.
GVR_CONTROLLER_ENABLE_ACCEL = 1 << 3,
/// Indicates that controller gestures should be reported.
GVR_CONTROLLER_ENABLE_GESTURES = 1 << 4,
/// Indicates that controller pose prediction should be enabled.
GVR_CONTROLLER_ENABLE_POSE_PREDICTION = 1 << 5,
/// Indicates that controller position data should be reported.
GVR_CONTROLLER_ENABLE_POSITION = 1 << 6,
/// Indicates that controller battery data should be reported.
GVR_CONTROLLER_ENABLE_BATTERY = 1 << 7,
};
/// Constants that represent the status of the controller API.
typedef enum {
/// API is happy and healthy. This doesn't mean the controller itself
/// is connected, it just means that the underlying service is working
/// properly.
GVR_CONTROLLER_API_OK = 0,
/// Any other status represents a permanent failure that requires
/// external action to fix:
/// API failed because this device does not support controllers (API is too
/// low, or other required feature not present).
GVR_CONTROLLER_API_UNSUPPORTED = 1,
/// This app was not authorized to use the service (e.g., missing permissions,
/// the app is blacklisted by the underlying service, etc).
GVR_CONTROLLER_API_NOT_AUTHORIZED = 2,
/// The underlying VR service is not present.
GVR_CONTROLLER_API_UNAVAILABLE = 3,
/// The underlying VR service is too old, needs upgrade.
GVR_CONTROLLER_API_SERVICE_OBSOLETE = 4,
/// The underlying VR service is too new, is incompatible with current client.
GVR_CONTROLLER_API_CLIENT_OBSOLETE = 5,
/// The underlying VR service is malfunctioning. Try again later.
GVR_CONTROLLER_API_MALFUNCTION = 6,
} gvr_controller_api_status;
/// Constants that represent the state of the controller.
typedef enum {
/// Controller is disconnected.
GVR_CONTROLLER_DISCONNECTED = 0,
/// Controller is scanning.
GVR_CONTROLLER_SCANNING = 1,
/// Controller is connecting.
GVR_CONTROLLER_CONNECTING = 2,
/// Controller is connected.
GVR_CONTROLLER_CONNECTED = 3,
} gvr_controller_connection_state;
/// Controller buttons.
typedef enum {
GVR_CONTROLLER_BUTTON_NONE = 0,
GVR_CONTROLLER_BUTTON_CLICK = 1, ///< Touchpad Click.
GVR_CONTROLLER_BUTTON_HOME = 2,
GVR_CONTROLLER_BUTTON_APP = 3,
GVR_CONTROLLER_BUTTON_VOLUME_UP = 4,
GVR_CONTROLLER_BUTTON_VOLUME_DOWN = 5,
/// Note: there are 5 buttons on the controller, but the state arrays have
/// this many elements due to the inclusion of a dummy "none" button.
GVR_CONTROLLER_BUTTON_COUNT = 6,
} gvr_controller_button;
/// Controller battery states.
typedef enum {
GVR_CONTROLLER_BATTERY_LEVEL_UNKNOWN = 0,
GVR_CONTROLLER_BATTERY_LEVEL_CRITICAL_LOW = 1,
GVR_CONTROLLER_BATTERY_LEVEL_LOW = 2,
GVR_CONTROLLER_BATTERY_LEVEL_MEDIUM = 3,
GVR_CONTROLLER_BATTERY_LEVEL_ALMOST_FULL = 4,
GVR_CONTROLLER_BATTERY_LEVEL_FULL = 5,
/// Note: there are 5 distinct levels, but there are 6 due to the inclusion
/// of an UNKNOWN state before any battery information is collected, etc.
GVR_CONTROLLER_BATTERY_LEVEL_COUNT = 6,
} gvr_controller_battery_level;
/// @}
/// Opaque handle to controller state.
typedef struct gvr_controller_state_ gvr_controller_state;
/// @addtogroup types
/// @{
/// Rendering modes define CPU load / rendering quality balances.
typedef enum {
/// Stereo panning of all Sound Objects. This disables HRTF-based rendering.
GVR_AUDIO_RENDERING_STEREO_PANNING = 0,
/// HRTF-based rendering over a virtual array of 8 loudspeakers arranged in
/// a cube configuration around the listener’s head.
GVR_AUDIO_RENDERING_BINAURAL_LOW_QUALITY = 1,
/// HRTF-based rendering over a virtual array of 16 loudspeakers arranged in
/// an approximate equidistribution about the around the listener’s head.
GVR_AUDIO_RENDERING_BINAURAL_HIGH_QUALITY = 2,
} gvr_audio_rendering_mode;
/// Room surface material names, used to set room properties.
typedef enum {
/// Acoustically transparent material, reflects no sound.
GVR_AUDIO_MATERIAL_TRANSPARENT = 0,
/// Acoustic ceiling tiles, absorbs most frequencies.
GVR_AUDIO_MATERIAL_ACOUSTIC_CEILING_TILES = 1,
/// Bare brick, relatively reflective.
GVR_AUDIO_MATERIAL_BRICK_BARE = 2,
/// Painted brick
GVR_AUDIO_MATERIAL_BRICK_PAINTED = 3,
/// Coarse surface concrete block.
GVR_AUDIO_MATERIAL_CONCRETE_BLOCK_COARSE = 4,
/// Painted concrete block.
GVR_AUDIO_MATERIAL_CONCRETE_BLOCK_PAINTED = 5,
/// Heavy curtains.
GVR_AUDIO_MATERIAL_CURTAIN_HEAVY = 6,
/// Fiber glass insulation.
GVR_AUDIO_MATERIAL_FIBER_GLASS_INSULATION = 7,
/// Thin glass.
GVR_AUDIO_MATERIAL_GLASS_THIN = 8,
/// Thick glass.
GVR_AUDIO_MATERIAL_GLASS_THICK = 9,
/// Grass.
GVR_AUDIO_MATERIAL_GRASS = 10,
/// Linoleum on concrete.
GVR_AUDIO_MATERIAL_LINOLEUM_ON_CONCRETE = 11,
/// Marble.
GVR_AUDIO_MATERIAL_MARBLE = 12,
/// Galvanized sheet metal.
GVR_AUDIO_MATERIAL_METAL = 13,
/// Wooden parquet on concrete.
GVR_AUDIO_MATERIAL_PARQUET_ON_CONCRETE = 14,
/// Rough plaster surface.
GVR_AUDIO_MATERIAL_PLASTER_ROUGH = 15,
/// Smooth plaster surface.
GVR_AUDIO_MATERIAL_PLASTER_SMOOTH = 16,
/// Plywood panel.
GVR_AUDIO_MATERIAL_PLYWOOD_PANEL = 17,
/// Polished concrete OR tile surface.
GVR_AUDIO_MATERIAL_POLISHED_CONCRETE_OR_TILE = 18,
/// Sheet rock.
GVR_AUDIO_MATERIAL_SHEET_ROCK = 19,
/// Surface of water or ice.
GVR_AUDIO_MATERIAL_WATER_OR_ICE_SURFACE = 20,
/// Wooden ceiling.
GVR_AUDIO_MATERIAL_WOOD_CEILING = 21,
/// Wood paneling.
GVR_AUDIO_MATERIAL_WOOD_PANEL = 22,
} gvr_audio_material_type;
/// Distance rolloff models used for distance attenuation.
typedef enum {
/// Logarithmic distance rolloff model.
GVR_AUDIO_ROLLOFF_LOGARITHMIC = 0,
/// Linear distance rolloff model.
GVR_AUDIO_ROLLOFF_LINEAR = 1,
/// No distance attenuation will be applied.
GVR_AUDIO_ROLLOFF_NONE = 2,
} gvr_audio_distance_rolloff_type;
/// Sound object and sound field identifier.
typedef int32_t gvr_audio_source_id;
/// Supported surround sound formats.
typedef enum {
// Enables to initialize a yet undefined rendering mode.
GVR_AUDIO_SURROUND_FORMAT_INVALID = 0,
// Virtual stereo speakers at -30 degrees and +30 degrees.
GVR_AUDIO_SURROUND_FORMAT_SURROUND_STEREO = 1,
// 5.1 surround sound according to the ITU-R BS 775 speaker configuration
// recommendation:
// - Front left (FL) at 30 degrees.
// - Front right (FR) at -30 degrees.
// - Front center (FC) at 0 degrees.
// - Low frequency effects (LFE) at front center at 0 degrees.
// - Left side (LS) at 110 degrees.
// - Right side (RS) at -110 degrees.
//
// The 5.1 channel input layout must matches AAC: FL, FR, FC, LFE, LS, RS.
// Note that this differs from the Vorbis/Opus 5.1 channel layout, which
// is: FL, FC, FR, LS, RS, LFE.
GVR_AUDIO_SURROUND_FORMAT_SURROUND_FIVE_DOT_ONE = 2,
// First-order ambisonics (AmbiX format: 4 channels, ACN channel ordering,
// SN3D normalization).
GVR_AUDIO_SURROUND_FORMAT_FIRST_ORDER_AMBISONICS = 3,
// Second-order ambisonics (AmbiX format: 9 channels, ACN channel ordering,
// SN3D normalization).
GVR_AUDIO_SURROUND_FORMAT_SECOND_ORDER_AMBISONICS = 4,
// Third-order ambisonics (AmbiX format: 16 channels, ACN channel ordering,
// SN3D normalization).
GVR_AUDIO_SURROUND_FORMAT_THIRD_ORDER_AMBISONICS = 5,
} gvr_audio_surround_format_type;
/// Valid color formats for swap chain buffers.
typedef enum {
/// Equivalent to GL_RGBA8
GVR_COLOR_FORMAT_RGBA_8888 = 0,
/// Equivalent to GL_RGB565
GVR_COLOR_FORMAT_RGB_565 = 1,
} gvr_color_format_type;
typedef enum {
/// No depth or stencil buffer.
GVR_DEPTH_STENCIL_FORMAT_NONE = 255,
/// Equivalent to GL_DEPTH_COMPONENT16.
GVR_DEPTH_STENCIL_FORMAT_DEPTH_16 = 0,
/// Equivalent to GL_DEPTH_COMPONENT24.
GVR_DEPTH_STENCIL_FORMAT_DEPTH_24 = 1,
/// Equivlaent to GL_DEPTH24_STENCIL8.
GVR_DEPTH_STENCIL_FORMAT_DEPTH_24_STENCIL_8 = 2,
/// Equivalent to GL_DEPTH_COMPONENT32F.
GVR_DEPTH_STENCIL_FORMAT_DEPTH_32_F = 3,
/// Equivalent to GL_DEPTH_32F_STENCIL8.
GVR_DEPTH_STENCIL_FORMAT_DEPTH_32_F_STENCIL_8 = 4,
/// Equivalent to GL_STENCIL8.
GVR_DEPTH_STENCIL_FORMAT_STENCIL_8 = 5,
} gvr_depth_stencil_format_type;
/// Types of asynchronous reprojection.
typedef enum {
/// Do not reproject.
GVR_REPROJECTION_NONE = 0,
/// Reproject in all dimensions.
GVR_REPROJECTION_FULL = 1,
} gvr_reprojection;
typedef enum {
GVR_CONTROLLER_RIGHT_HANDED = 0,
GVR_CONTROLLER_LEFT_HANDED = 1,
} gvr_controller_handedness;
typedef struct gvr_user_prefs_ gvr_user_prefs;
// Anonymous enum for miscellaneous integer constants.
enum {
/// Constant that represents a nonexistent external surface. Pass to
/// gvr_buffer_viewport_set_external_surface_id() to disable sampling from
/// an external surface.
GVR_EXTERNAL_SURFACE_ID_NONE = -1,
/// Special index for a source buffer that has the same contents as the
/// external surface attached to the given viewport. Pass this to
/// gvr_buffer_viewport_set_source_buffer_index() to use the external surface
/// as the buffer contents.
GVR_BUFFER_INDEX_EXTERNAL_SURFACE = -1,
};
/// @}
#ifdef __cplusplus
} // extern "C"
#endif
#if defined(__cplusplus) && !defined(GVR_NO_CPP_WRAPPER)
// These typedefs convert the C-style names to C++-style names.
namespace gvr {
const int32_t kControllerEnableOrientation =
static_cast<int32_t>(GVR_CONTROLLER_ENABLE_ORIENTATION);
const int32_t kControllerEnableTouch =
static_cast<int32_t>(GVR_CONTROLLER_ENABLE_TOUCH);
const int32_t kControllerEnableGyro =
static_cast<int32_t>(GVR_CONTROLLER_ENABLE_GYRO);
const int32_t kControllerEnableAccel =
static_cast<int32_t>(GVR_CONTROLLER_ENABLE_ACCEL);
const int32_t kControllerEnableGestures =
static_cast<int32_t>(GVR_CONTROLLER_ENABLE_GESTURES);
const int32_t kControllerEnablePosePrediction =
static_cast<int32_t>(GVR_CONTROLLER_ENABLE_POSE_PREDICTION);
const int32_t kControllerEnablePosition =
static_cast<int32_t>(GVR_CONTROLLER_ENABLE_POSITION);
const int32_t kControllerEnableBattery =
static_cast<int32_t>(GVR_CONTROLLER_ENABLE_BATTERY);
typedef gvr_controller_api_status ControllerApiStatus;
const ControllerApiStatus kControllerApiOk =
static_cast<ControllerApiStatus>(GVR_CONTROLLER_API_OK);
const ControllerApiStatus kControllerApiUnsupported =
static_cast<ControllerApiStatus>(GVR_CONTROLLER_API_UNSUPPORTED);
const ControllerApiStatus kControllerApiNotAuthorized =
static_cast<ControllerApiStatus>(GVR_CONTROLLER_API_NOT_AUTHORIZED);
const ControllerApiStatus kControllerApiUnavailable =
static_cast<ControllerApiStatus>(GVR_CONTROLLER_API_UNAVAILABLE);
const ControllerApiStatus kControllerApiServiceObsolete =
static_cast<ControllerApiStatus>(GVR_CONTROLLER_API_SERVICE_OBSOLETE);
const ControllerApiStatus kControllerApiClientObsolete =
static_cast<ControllerApiStatus>(GVR_CONTROLLER_API_CLIENT_OBSOLETE);
const ControllerApiStatus kControllerApiMalfunction =
static_cast<ControllerApiStatus>(GVR_CONTROLLER_API_MALFUNCTION);
typedef gvr_controller_connection_state ControllerConnectionState;
const ControllerConnectionState kControllerDisconnected =
static_cast<ControllerConnectionState>(GVR_CONTROLLER_DISCONNECTED);
const ControllerConnectionState kControllerScanning =
static_cast<ControllerConnectionState>(GVR_CONTROLLER_SCANNING);
const ControllerConnectionState kControllerConnecting =
static_cast<ControllerConnectionState>(GVR_CONTROLLER_CONNECTING);
const ControllerConnectionState kControllerConnected =
static_cast<ControllerConnectionState>(GVR_CONTROLLER_CONNECTED);
typedef gvr_controller_button ControllerButton;
const ControllerButton kControllerButtonNone =
static_cast<ControllerButton>(GVR_CONTROLLER_BUTTON_NONE);
const ControllerButton kControllerButtonClick =
static_cast<ControllerButton>(GVR_CONTROLLER_BUTTON_CLICK);
const ControllerButton kControllerButtonHome =
static_cast<ControllerButton>(GVR_CONTROLLER_BUTTON_HOME);
const ControllerButton kControllerButtonApp =
static_cast<ControllerButton>(GVR_CONTROLLER_BUTTON_APP);
const ControllerButton kControllerButtonVolumeUp =
static_cast<ControllerButton>(GVR_CONTROLLER_BUTTON_VOLUME_UP);
const ControllerButton kControllerButtonVolumeDown =
static_cast<ControllerButton>(GVR_CONTROLLER_BUTTON_VOLUME_DOWN);
const ControllerButton kControllerButtonCount =
static_cast<ControllerButton>(GVR_CONTROLLER_BUTTON_COUNT);
typedef gvr_controller_battery_level ControllerBatteryLevel;
const ControllerBatteryLevel kControllerBatteryLevelUnknown =
static_cast<ControllerBatteryLevel>(
GVR_CONTROLLER_BATTERY_LEVEL_UNKNOWN);
const ControllerBatteryLevel kControllerBatteryLevelCriticalLow =
static_cast<ControllerBatteryLevel>(
GVR_CONTROLLER_BATTERY_LEVEL_CRITICAL_LOW);
const ControllerBatteryLevel kControllerBatteryLevelLow =
static_cast<ControllerBatteryLevel>(
GVR_CONTROLLER_BATTERY_LEVEL_LOW);
const ControllerBatteryLevel kControllerBatteryLevelMedium =
static_cast<ControllerBatteryLevel>(
GVR_CONTROLLER_BATTERY_LEVEL_MEDIUM);
const ControllerBatteryLevel kControllerBatteryLevelAlmostFull =
static_cast<ControllerBatteryLevel>(
GVR_CONTROLLER_BATTERY_LEVEL_ALMOST_FULL);
const ControllerBatteryLevel kControllerBatteryLevelFull =
static_cast<ControllerBatteryLevel>(
GVR_CONTROLLER_BATTERY_LEVEL_FULL);
/// An uninitialized external surface ID.
const int32_t kUninitializedExternalSurface = GVR_BUFFER_INDEX_EXTERNAL_SURFACE;
/// The default source buffer index for viewports.
const int32_t kDefaultBufferIndex = 0;
typedef gvr_eye Eye;
typedef gvr_viewer_type ViewerType;
const ViewerType kViewerTypeCardboard =
static_cast<ViewerType>(GVR_VIEWER_TYPE_CARDBOARD);
const ViewerType kViewerTypeDaydream =
static_cast<ViewerType>(GVR_VIEWER_TYPE_DAYDREAM);
typedef gvr_version Version;
typedef gvr_sizei Sizei;
typedef gvr_recti Recti;
typedef gvr_rectf Rectf;
typedef gvr_vec2f Vec2f;
typedef gvr_vec3f Vec3f;
typedef gvr_mat4f Mat4f;
typedef gvr_quatf Quatf;
typedef gvr_clock_time_point ClockTimePoint;
typedef gvr_vec2f ControllerVec2;
typedef gvr_vec3f ControllerVec3;
typedef gvr_quatf ControllerQuat;
typedef gvr_audio_rendering_mode AudioRenderingMode;
typedef gvr_audio_material_type AudioMaterialName;
typedef gvr_audio_distance_rolloff_type AudioRolloffMethod;
typedef gvr_audio_source_id AudioSourceId;
typedef gvr_audio_surround_format_type AudioSurroundFormat;
typedef gvr_color_format_type ColorFormat;
const ColorFormat kColorFormatRgba8888 =
static_cast<ColorFormat>(GVR_COLOR_FORMAT_RGBA_8888);
const ColorFormat kColorFormatRgb565 =
static_cast<ColorFormat>(GVR_COLOR_FORMAT_RGB_565);
typedef gvr_depth_stencil_format_type DepthStencilFormat;
const DepthStencilFormat kDepthStencilFormatNone =
static_cast<DepthStencilFormat>(GVR_DEPTH_STENCIL_FORMAT_NONE);
const DepthStencilFormat kDepthStencilFormatDepth16 =
static_cast<DepthStencilFormat>(GVR_DEPTH_STENCIL_FORMAT_DEPTH_16);
const DepthStencilFormat kDepthStencilFormatDepth24 =
static_cast<DepthStencilFormat>(GVR_DEPTH_STENCIL_FORMAT_DEPTH_24);
const DepthStencilFormat kDepthStencilFormatDepth24Stencil8 =
static_cast<DepthStencilFormat>(
GVR_DEPTH_STENCIL_FORMAT_DEPTH_24_STENCIL_8);
const DepthStencilFormat kDepthStencilFormatDepth32f =
static_cast<DepthStencilFormat>(GVR_DEPTH_STENCIL_FORMAT_DEPTH_32_F);
const DepthStencilFormat kDepthStencilFormatDepth32fStencil8 =
static_cast<DepthStencilFormat>(
GVR_DEPTH_STENCIL_FORMAT_DEPTH_32_F_STENCIL_8);
const DepthStencilFormat kDepthStencilFormatStencil8 =
static_cast<DepthStencilFormat>(GVR_DEPTH_STENCIL_FORMAT_STENCIL_8);
typedef gvr_controller_handedness ControllerHandedness;
const ControllerHandedness kControllerRightHanded =
static_cast<ControllerHandedness>(GVR_CONTROLLER_RIGHT_HANDED);
const ControllerHandedness kControllerLeftHanded =
static_cast<ControllerHandedness>(GVR_CONTROLLER_LEFT_HANDED);
typedef gvr_error Error;
const Error kErrorNone = static_cast<Error>(GVR_ERROR_NONE);
const Error kErrorControllerCreateFailed =
static_cast<Error>(GVR_ERROR_CONTROLLER_CREATE_FAILED);
const Error kErrorNoFrameAvailable =
static_cast<Error>(GVR_ERROR_NO_FRAME_AVAILABLE);
class AudioApi;
class BufferSpec;
class ControllerApi;
class ControllerState;
class Frame;
class GvrApi;
class BufferViewport;
class BufferViewportList;
class SwapChain;
class UserPrefs;
} // namespace gvr
// Non-member equality operators for convenience. Since typedefs do not trigger
// argument-dependent lookup, these operators have to be defined for the
// underlying types.
inline bool operator==(const gvr_vec2f& lhs, const gvr_vec2f& rhs) {
return lhs.x == rhs.x && lhs.y == rhs.y;
}
inline bool operator!=(const gvr_vec2f& lhs, const gvr_vec2f& rhs) {
return !(lhs == rhs);
}
inline bool operator==(const gvr_vec3f& lhs, const gvr_vec3f& rhs) {
return lhs.x == rhs.x && lhs.y == rhs.y;
}
inline bool operator!=(const gvr_vec3f& lhs, const gvr_vec3f& rhs) {
return !(lhs == rhs);
}
inline bool operator==(const gvr_recti& lhs, const gvr_recti& rhs) {
return lhs.left == rhs.left && lhs.right == rhs.right &&
lhs.bottom == rhs.bottom && lhs.top == rhs.top;
}
inline bool operator!=(const gvr_recti& lhs, const gvr_recti& rhs) {
return !(lhs == rhs);
}
inline bool operator==(const gvr_rectf& lhs, const gvr_rectf& rhs) {
return lhs.left == rhs.left && lhs.right == rhs.right &&
lhs.bottom == rhs.bottom && lhs.top == rhs.top;
}
inline bool operator!=(const gvr_rectf& lhs, const gvr_rectf& rhs) {
return !(lhs == rhs);
}
inline bool operator==(const gvr_sizei& lhs, const gvr_sizei& rhs) {
return lhs.width == rhs.width && lhs.height == rhs.height;
}
inline bool operator!=(const gvr_sizei& lhs, const gvr_sizei& rhs) {
return !(lhs == rhs);
}
#endif // #if defined(__cplusplus) && !defined(GVR_NO_CPP_WRAPPER)
#endif // VR_GVR_CAPI_INCLUDE_GVR_TYPES_H_
| 37.481032 | 80 | 0.782996 |
5ca8912f4583d3c4ad1dbf1eb69328ff7a69f941 | 2,761 | c | C | Delete node from the end of doubly linked list.c | vik673/C-basic-programs | 93b383ccb8751d5dd502f3147a02753ac1bc3fe0 | [
"MIT"
] | null | null | null | Delete node from the end of doubly linked list.c | vik673/C-basic-programs | 93b383ccb8751d5dd502f3147a02753ac1bc3fe0 | [
"MIT"
] | null | null | null | Delete node from the end of doubly linked list.c | vik673/C-basic-programs | 93b383ccb8751d5dd502f3147a02753ac1bc3fe0 | [
"MIT"
] | null | null | null | #include<stdio.h>
#include<conio.h>
#include<stdlib.h>
typedef struct node
{
int num;
struct node *prev,*next;
}node;
node *start=NULL,*end=NULL;
void insert_at_end()
{
node *current=(node *)malloc(sizeof(node));
if(current!=NULL)
{
int n;
printf("\nEnter a number\n");
scanf("%d",&n);
current->num=n;
if(start==NULL)
{
start=current;
start->prev=NULL;
}
else
{
end->next=current;
current->prev=end;
}
end=current;
end->next=NULL;
}
else
{
printf("\nMemory is not available\n");
}
}
void delete_from_end()
{
if(end!=NULL)
{
int n;
node *pos;
n=end->num;
pos=end;
if(start!=end)
{
end=end->prev;
end->next=NULL;
}
else{
start=end=NULL;
}
free(pos);
printf("\nEnter deleted from doubly linked list is %d\n",n);
}
else{
printf("\nDoubly linked list is empty\n");
}
}
void forward_traverse()
{
if(start!=NULL)
{
node *pos=start;
printf("\nElement of linked list are\n");
while(pos!=NULL)
{
printf("%d",pos->num);
pos=pos->next;
}
printf("\n");
}
else
{
printf("\n No node to traverse in linked list\n");
}
}
void backward_traverse()
{
if(end!=NULL)
{
node *pos=end;
printf("\nElement of linked list are\n");
while(pos!=NULL)
{
printf("%d",pos->num);
pos=pos->prev;
}
printf("\n");
}
else
{
printf("\n No node to traverse in linked list\n");
}
}
void main()
{
int ch;
do{
printf("\nEnter 1 to insert new node at begin\n");
printf("Enter 2 to delete node from end\n");
printf("Enter 3 to forward traversing all nodes\n");
printf("Enter 4 to backward traversing of all nodes\n");
printf("Enter 5 to exit\n");
scanf("%d",&ch);
switch(ch)
{
case 1:
insert_at_begin();
break;
case 2:
delete_from_end();
break;
case 3:
forward_traverse();
break;
case 4:
backward_traverse();
break;
case 5:
exit(0);
default:
printf("\nWrong choice entered\n");
}
printf("\nEnter 0 to continue\n");
scanf("%d",&ch);
}while(ch==0);
}
| 20.451852 | 69 | 0.437523 |
6812cb7b8d0dec12d70525bd5839a2a5610cfcb2 | 2,282 | h | C | sync/protocol/proto_enum_conversions.h | SlimKatLegacy/android_external_chromium_org | ee480ef5039d7c561fc66ccf52169ead186f1bea | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 2 | 2015-03-04T02:36:53.000Z | 2016-06-25T11:22:17.000Z | sync/protocol/proto_enum_conversions.h | j4ckfrost/android_external_chromium_org | a1a3dad8b08d1fcf6b6b36c267158ed63217c780 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null | sync/protocol/proto_enum_conversions.h | j4ckfrost/android_external_chromium_org | a1a3dad8b08d1fcf6b6b36c267158ed63217c780 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 4 | 2015-02-09T08:49:30.000Z | 2017-08-26T02:03:34.000Z | // Copyright 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SYNC_PROTOCOL_PROTO_ENUM_CONVERSIONS_H_
#define SYNC_PROTOCOL_PROTO_ENUM_CONVERSIONS_H_
// Keep this file in sync with the .proto files in this directory.
#include "sync/base/sync_export.h"
#include "sync/protocol/app_list_specifics.pb.h"
#include "sync/protocol/client_debug_info.pb.h"
#include "sync/protocol/session_specifics.pb.h"
#include "sync/protocol/sync.pb.h"
// Utility functions to get the string equivalent for some sync proto
// enums.
namespace syncer {
// The returned strings (which don't have to be freed) are in ASCII.
// The result of passing in an invalid enum value is undefined.
SYNC_EXPORT_PRIVATE const char* GetAppListItemTypeString(
sync_pb::AppListSpecifics::AppListItemType item_type);
SYNC_EXPORT_PRIVATE const char* GetBrowserTypeString(
sync_pb::SessionWindow::BrowserType browser_type);
SYNC_EXPORT_PRIVATE const char* GetPageTransitionString(
sync_pb::SyncEnums::PageTransition page_transition);
SYNC_EXPORT_PRIVATE const char* GetPageTransitionRedirectTypeString(
sync_pb::SyncEnums::PageTransitionRedirectType
redirect_type);
SYNC_EXPORT const char* GetUpdatesSourceString(
sync_pb::GetUpdatesCallerInfo::GetUpdatesSource updates_source);
SYNC_EXPORT const char* GetUpdatesOriginString(
sync_pb::SyncEnums::GetUpdatesOrigin origin);
SYNC_EXPORT_PRIVATE const char* GetResponseTypeString(
sync_pb::CommitResponse::ResponseType response_type);
SYNC_EXPORT_PRIVATE const char* GetErrorTypeString(
sync_pb::SyncEnums::ErrorType error_type);
SYNC_EXPORT_PRIVATE const char* GetActionString(
sync_pb::SyncEnums::Action action);
const char* GetDeviceTypeString(sync_pb::SyncEnums::DeviceType device_type);
const char* GetFaviconTypeString(sync_pb::SessionTab::FaviconType favicon_type);
const char* PassphraseTypeString(sync_pb::NigoriSpecifics::PassphraseType type);
const char* SingletonEventTypeString(
sync_pb::DebugEventInfo::SingletonEventType type);
const char* GetBlockedStateString(sync_pb::TabNavigation::BlockedState state);
} // namespace syncer
#endif // SYNC_PROTOCOL_PROTO_ENUM_CONVERSIONS_H_
| 34.575758 | 80 | 0.80894 |
fddf78c1268ef5bc4ac5e353d50d52d5765fb871 | 587 | h | C | apps/bare-expo/ios/Pods/SDWebImage/SDWebImage/Private/SDImageCachesManagerOperation.h | rudylee/expo | b3e65a7a5b205f14a3eb6cd6fa8d13c8d663b1cc | [
"Apache-2.0",
"MIT"
] | 6,947 | 2015-03-24T12:23:59.000Z | 2022-03-31T21:45:46.000Z | apps/bare-expo/ios/Pods/SDWebImage/SDWebImage/Private/SDImageCachesManagerOperation.h | rudylee/expo | b3e65a7a5b205f14a3eb6cd6fa8d13c8d663b1cc | [
"Apache-2.0",
"MIT"
] | 643 | 2015-03-25T04:29:47.000Z | 2022-02-24T03:50:33.000Z | apps/bare-expo/ios/Pods/SDWebImage/SDWebImage/Private/SDImageCachesManagerOperation.h | rudylee/expo | b3e65a7a5b205f14a3eb6cd6fa8d13c8d663b1cc | [
"Apache-2.0",
"MIT"
] | 1,867 | 2015-03-25T01:42:00.000Z | 2022-03-23T06:05:50.000Z | /*
* This file is part of the SDWebImage package.
* (c) Olivier Poitrey <rs@dailymotion.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
#import <Foundation/Foundation.h>
#import "SDWebImageCompat.h"
// This is used for operation management, but not for operation queue execute
@interface SDImageCachesManagerOperation : NSOperation
@property (nonatomic, assign, readonly) NSUInteger pendingCount;
- (void)beginWithTotalCount:(NSUInteger)totalCount;
- (void)completeOne;
- (void)done;
@end
| 26.681818 | 77 | 0.76661 |
658697a82f848de1e78709147184ba4e1f64eed9 | 1,057 | h | C | Telecomm/SharedLib/ewalletShareLib/include/pwrWidget/hostingAccountWidget/hostingcoinwidget.h | telecommai/windows | 30e34ffe0bc81f39c25be7624d16856bf42e03eb | [
"BSD-3-Clause"
] | 2 | 2019-04-13T07:09:19.000Z | 2019-04-19T08:06:17.000Z | Telecomm/SharedLib/ewalletShareLib/include/pwrWidget/hostingAccountWidget/hostingcoinwidget.h | telecommai/windows | 30e34ffe0bc81f39c25be7624d16856bf42e03eb | [
"BSD-3-Clause"
] | 9 | 2021-03-09T02:41:54.000Z | 2022-02-26T10:26:01.000Z | Telecomm/SharedLib/ewalletShareLib/include/pwrWidget/hostingAccountWidget/hostingcoinwidget.h | telecommai/windows | 30e34ffe0bc81f39c25be7624d16856bf42e03eb | [
"BSD-3-Clause"
] | null | null | null | #pragma once
#include <QWidget>
#include <QMouseEvent>
#include <QDoubleValidator>
#include <QStyledItemDelegate>
#include "opcommon.h"
#include "messagebox.h"
#include "oprequestsharelib.h"
#include "stdafx.h"
#include "../transferWidget/passwordwidget.h"
namespace Ui { class HostingCoinWidget; };
class HostingCoinWidget : public QWidget
{
Q_OBJECT
public:
HostingCoinWidget(QWidget *parent = Q_NULLPTR);
~HostingCoinWidget();
void setAsset(AssetInfo);
void setMainAddress(QString address) { this->mainAddress = address; }
private slots:
void slotInsertWallet(QList<ChildrenWallet>);
void slotAllBtn();
void slotChangeAddress(int);
void slotEnter();
void slotCoinValue();
void slotCoinResult(bool);
public slots:
void show();
private:
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
private:
Ui::HostingCoinWidget *ui;
QPoint mouse;
QString mainAddress;
AssetInfo asset;
};
| 20.72549 | 71 | 0.716178 |
aa1a6632e7683b9ad6289e81c9e9e8b7bfc79e66 | 10,188 | h | C | openbsd/sys/arch/sparc/include/param.h | shisa/kame-shisa | 25dfcf220c0cd8192e475a602501206ccbd9263e | [
"BSD-3-Clause"
] | 1 | 2019-10-15T06:29:32.000Z | 2019-10-15T06:29:32.000Z | openbsd/sys/arch/sparc/include/param.h | shisa/kame-shisa | 25dfcf220c0cd8192e475a602501206ccbd9263e | [
"BSD-3-Clause"
] | null | null | null | openbsd/sys/arch/sparc/include/param.h | shisa/kame-shisa | 25dfcf220c0cd8192e475a602501206ccbd9263e | [
"BSD-3-Clause"
] | 3 | 2017-01-09T02:15:36.000Z | 2019-10-15T06:30:25.000Z | /* $OpenBSD: param.h,v 1.27 2003/06/02 23:27:54 millert Exp $ */
/* $NetBSD: param.h,v 1.29 1997/03/10 22:50:37 pk Exp $ */
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This software was developed by the Computer Systems Engineering group
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
* contributed to Berkeley.
*
* 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, Lawrence Berkeley Laboratory.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University 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 REGENTS 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 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.
*
* @(#)param.h 8.1 (Berkeley) 6/11/93
*/
#ifndef _SPARC_PARAM_H_
#define _SPARC_PARAM_H_
/*
* Sun4M support by Aaron Brown, Harvard University.
* Changes Copyright (c) 1995 The President and Fellows of Harvard College.
* All rights reserved.
*/
#define _MACHINE sparc
#define MACHINE "sparc"
#define _MACHINE_ARCH sparc
#define MACHINE_ARCH "sparc"
#define MID_MACHINE MID_SPARC
#ifdef _KERNEL /* XXX */
#ifndef _LOCORE /* XXX */
#include <machine/cpu.h> /* XXX */
#endif /* XXX */
#endif /* XXX */
/*
* Round p (pointer or byte index) up to a correctly-aligned value for
* the machine's strictest data type. The result is u_int and must be
* cast to any desired pointer type.
*
* ALIGNED_POINTER is a boolean macro that checks whether an address
* is valid to fetch data elements of type t from on this architecture.
* This does not reflect the optimal alignment, just the possibility
* (within reasonable limits).
*
*/
#define ALIGNBYTES 7
#define ALIGN(p) (((u_int)(p) + ALIGNBYTES) & ~ALIGNBYTES)
#define ALIGNED_POINTER(p,t) ((((u_long)(p)) & (sizeof(t)-1)) == 0)
#define SUN4_PGSHIFT 13 /* for a sun4 machine */
#define SUN4CM_PGSHIFT 12 /* for a sun4c or sun4m machine */
#define KERNBASE 0xf8000000 /* start of kernel virtual space */
#define KERNTEXTOFF 0xf8004000 /* start of kernel text */
#define DEV_BSIZE 512
#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */
#define BLKDEV_IOSIZE 2048
#define MAXPHYS (64 * 1024)
#define SSIZE 1 /* initial stack size in pages */
#define USPACE 8192
/*
* Constants related to network buffer management.
* MCLBYTES must be no larger than the software page size, and,
* on machines that exchange pages of input or output buffers with mbuf
* clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
* of the hardware page size.
*/
#define MSIZE 256 /* size of an mbuf */
#define MCLSHIFT 11 /* log2(MCLBYTES) */
#define MCLBYTES (1 << MCLSHIFT) /* enough for whole Ethernet packet */
#define MCLOFSET (MCLBYTES - 1)
#ifndef NMBCLUSTERS
#ifdef GATEWAY
#define NMBCLUSTERS 1024 /* map size, max cluster allocation */
#else
#define NMBCLUSTERS 512 /* map size, max cluster allocation */
#endif
#endif
#define MSGBUFSIZE 4096 /* cannot be changed without great pain */
/*
* Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized
* logical pages.
*/
#define NKMEMPAGES_MIN_DEFAULT ((6 * 1024 * 1024) >> PAGE_SHIFT)
#define NKMEMPAGES_MAX_DEFAULT ((6 * 1024 * 1024) >> PAGE_SHIFT)
/* pages ("clicks") to disk blocks */
#define ctod(x) ((x) << (PGSHIFT - DEV_BSHIFT))
#define dtoc(x) ((x) >> (PGSHIFT - DEV_BSHIFT))
/* pages to bytes */
#define ctob(x) ((x) << PGSHIFT)
#define btoc(x) (((x) + PGOFSET) >> PGSHIFT)
/* bytes to disk blocks */
#define btodb(x) ((x) >> DEV_BSHIFT)
#define dbtob(x) ((x) << DEV_BSHIFT)
/*
* Map a ``block device block'' to a file system block.
* This should be device dependent, and should use the bsize
* field from the disk label.
* For now though just use DEV_BSIZE.
*/
#define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE / DEV_BSIZE))
/*
* Mach derived conversion macros
*/
#define sparc_btop(x) ((unsigned)(x) >> PGSHIFT)
#define sparc_ptob(x) ((unsigned)(x) << PGSHIFT)
/*
* dvmamap manages a range of DVMA addresses intended to create double
* mappings of physical memory. In a way, `dvmamap' is a submap of the
* VM map `phys_map'. The difference is the use of the `resource map'
* routines to manage page allocation, allowing DVMA addresses to be
* allocated and freed from within interrupt routines.
*
* Note that `phys_map' can still be used to allocate memory-backed pages
* in DVMA space.
*/
#ifdef _KERNEL
#ifndef _LOCORE
extern vaddr_t dvma_base;
extern vaddr_t dvma_end;
extern struct extent *dvmamap_extent;
extern caddr_t kdvma_mapin(caddr_t, int, int);
extern caddr_t dvma_malloc_space(size_t, void *, int, int);
extern void dvma_free(caddr_t, size_t, void *);
#define dvma_malloc(len,kaddr,flags) dvma_malloc_space(len,kaddr,flags,0)
extern void delay(unsigned int);
#define DELAY(n) delay(n)
extern int cputyp;
#if 0
extern int cpumod;
extern int mmumod;
#endif
#endif /* _LOCORE */
#endif /* _KERNEL */
/*
* Values for the cputyp variable.
*/
#define CPU_SUN4 0
#define CPU_SUN4C 1
#define CPU_SUN4M 2
/*
* Shorthand CPU-type macros. Enumerate all eight cases.
* Let compiler optimize away code conditional on constants.
*
* On a sun4 machine, the page size is 8192, while on a sun4c and sun4m
* it is 4096. Therefore, in the (SUN4 && (SUN4C || SUN4M)) cases below,
* NBPG, PGOFSET and PGSHIFT are defined as variables which are initialized
* early in locore.s after the machine type has been detected.
*
* Note that whenever the macros defined below evaluate to expressions
* involving variables, the kernel will perform slighly worse due to the
* extra memory references they'll generate.
*/
#if defined(SUN4M) && defined(SUN4C) && defined(SUN4)
# define CPU_ISSUN4M (cputyp == CPU_SUN4M)
# define CPU_ISSUN4C (cputyp == CPU_SUN4C)
# define CPU_ISSUN4 (cputyp == CPU_SUN4)
# define CPU_ISSUN4OR4C (cputyp == CPU_SUN4 || cputyp == CPU_SUN4C)
# define CPU_ISSUN4COR4M (cputyp == CPU_SUN4C || cputyp == CPU_SUN4M)
#elif defined(SUN4M) && defined(SUN4C) && !defined(SUN4)
# define CPU_ISSUN4M (cputyp == CPU_SUN4M)
# define CPU_ISSUN4C (cputyp == CPU_SUN4C)
# define CPU_ISSUN4 (0)
# define CPU_ISSUN4OR4C (cputyp == CPU_SUN4C)
# define CPU_ISSUN4COR4M (cputyp == CPU_SUN4C || cputyp == CPU_SUN4M)
# define NBPG 4096
# define PGOFSET (NBPG-1)
# define PGSHIFT SUN4CM_PGSHIFT
# define PAGE_SIZE 4096
# define PAGE_MASK (PAGE_SIZE - 1)
# define PAGE_SHIFT SUN4CM_PGSHIFT
#elif defined(SUN4M) && !defined(SUN4C) && defined(SUN4)
# define CPU_ISSUN4M (cputyp == CPU_SUN4M)
# define CPU_ISSUN4C (0)
# define CPU_ISSUN4 (cputyp == CPU_SUN4)
# define CPU_ISSUN4OR4C (cputyp == CPU_SUN4)
# define CPU_ISSUN4COR4M (cputyp == CPU_SUN4M)
#elif defined(SUN4M) && !defined(SUN4C) && !defined(SUN4)
# define CPU_ISSUN4M (1)
# define CPU_ISSUN4C (0)
# define CPU_ISSUN4 (0)
# define CPU_ISSUN4OR4C (0)
# define CPU_ISSUN4COR4M (1)
# define NBPG 4096
# define PGOFSET (NBPG-1)
# define PGSHIFT SUN4CM_PGSHIFT
# define PAGE_SIZE 4096
# define PAGE_MASK (PAGE_SIZE - 1)
# define PAGE_SHIFT SUN4CM_PGSHIFT
#elif !defined(SUN4M) && defined(SUN4C) && defined(SUN4)
# define CPU_ISSUN4M (0)
# define CPU_ISSUN4C (cputyp == CPU_SUN4C)
# define CPU_ISSUN4 (cputyp == CPU_SUN4)
# define CPU_ISSUN4OR4C (1)
# define CPU_ISSUN4COR4M (cputyp == CPU_SUN4C)
#elif !defined(SUN4M) && defined(SUN4C) && !defined(SUN4)
# define CPU_ISSUN4M (0)
# define CPU_ISSUN4C (1)
# define CPU_ISSUN4 (0)
# define CPU_ISSUN4OR4C (1)
# define CPU_ISSUN4COR4M (1)
# define NBPG 4096
# define PGOFSET (NBPG-1)
# define PGSHIFT SUN4CM_PGSHIFT
# define PAGE_SIZE 4096
# define PAGE_MASK (PAGE_SIZE - 1)
# define PAGE_SHIFT SUN4CM_PGSHIFT
#elif !defined(SUN4M) && !defined(SUN4C) && defined(SUN4)
# define CPU_ISSUN4M (0)
# define CPU_ISSUN4C (0)
# define CPU_ISSUN4 (1)
# define CPU_ISSUN4OR4C (1)
# define CPU_ISSUN4COR4M (0)
# define NBPG 8192
# define PGOFSET (NBPG-1)
# define PGSHIFT SUN4_PGSHIFT
# define PAGE_SIZE 8192
# define PAGE_MASK (PAGE_SIZE - 1)
# define PAGE_SHIFT SUN4_PGSHIFT
#elif !defined(SUN4M) && !defined(SUN4C) && !defined(SUN4)
# define CPU_ISSUN4M (cputyp == CPU_SUN4M)
# define CPU_ISSUN4C (cputyp == CPU_SUN4C)
# define CPU_ISSUN4 (cputyp == CPU_SUN4)
# define CPU_ISSUN4OR4C (cputyp == CPU_SUN4 || cputyp == CPU_SUN4C)
# define CPU_ISSUN4COR4M (cputyp == CPU_SUN4C || cputyp == CPU_SUN4M)
#endif
#ifndef NBPG
#ifdef STANDALONE /* boot blocks */
# define NBPG nbpg
# define PGOFSET pgofset
# define PGSHIFT pgshift
# define PAGE_SIZE nbpg
# define PAGE_MASK pgofset
# define PAGE_SHIFT pgshift
#else
# define NBPG uvmexp.pagesize
# define PGOFSET uvmexp.pagemask
# define PGSHIFT uvmexp.pageshift
# define PAGE_SIZE uvmexp.pagesize
# define PAGE_MASK uvmexp.pagemask
# define PAGE_SHIFT uvmexp.pageshift
#endif
#endif
#endif /* _SPARC_PARAM_H_ */
| 34.653061 | 77 | 0.732038 |
10f0aba572f29993ebf248e0b6fffedab756b1d3 | 1,076 | h | C | sniper/common/network/network_model_emesh_hop_counter.h | zhc0757/intersim | 83ea424f9a7b0a09cc3b1bc15068a23d2517ec6e | [
"MIT"
] | null | null | null | sniper/common/network/network_model_emesh_hop_counter.h | zhc0757/intersim | 83ea424f9a7b0a09cc3b1bc15068a23d2517ec6e | [
"MIT"
] | null | null | null | sniper/common/network/network_model_emesh_hop_counter.h | zhc0757/intersim | 83ea424f9a7b0a09cc3b1bc15068a23d2517ec6e | [
"MIT"
] | 2 | 2020-10-06T08:31:58.000Z | 2021-09-14T13:50:13.000Z | #ifndef NETWORK_MODEL_EMESH_HOP_COUNTER_H
#define NETWORK_MODEL_EMESH_HOP_COUNTER_H
#include "network.h"
#include "network_model.h"
#include "lock.h"
class NetworkModelEMeshHopCounter : public NetworkModel
{
public:
NetworkModelEMeshHopCounter(Network *net, EStaticNetwork net_type);
~NetworkModelEMeshHopCounter();
void routePacket(const NetPacket &pkt,
std::vector<Hop> &nextHops);
void processReceivedPacket(NetPacket &pkt);
void enable() { _enabled = true; }
void disable() { _enabled = false; }
private:
void computePosition(core_id_t core, SInt32 &x, SInt32 &y);
SInt32 computeDistance(SInt32 x1, SInt32 y1, SInt32 x2, SInt32 y2);
SubsecondTime computeSerializationLatency(UInt32 pkt_length);
ComponentLatency _hopLatency;
ComponentBandwidthPerCycle _linkBandwidth;
SInt32 _meshWidth;
SInt32 _meshHeight;
bool _enabled;
Lock _lock;
// Performance Counters
UInt64 _num_packets;
UInt64 _num_bytes;
SubsecondTime _total_latency;
};
#endif
| 23.911111 | 71 | 0.716543 |
b79cdf9129a08ad46cf65075001bf1f74df9c514 | 1,717 | h | C | kernel/linux-5.4/drivers/scsi/ufs/ufshcd-pltfrm.h | josehu07/SplitFS | d7442fa67a17de7057664f91defbfdbf10dd7f4a | [
"Apache-2.0"
] | 31 | 2021-04-27T08:50:40.000Z | 2022-03-01T02:26:21.000Z | kernel/linux-5.4/drivers/scsi/ufs/ufshcd-pltfrm.h | josehu07/SplitFS | d7442fa67a17de7057664f91defbfdbf10dd7f4a | [
"Apache-2.0"
] | 13 | 2021-07-10T04:36:17.000Z | 2022-03-03T10:50:05.000Z | kernel/linux-5.4/drivers/scsi/ufs/ufshcd-pltfrm.h | josehu07/SplitFS | d7442fa67a17de7057664f91defbfdbf10dd7f4a | [
"Apache-2.0"
] | 12 | 2021-04-06T02:23:10.000Z | 2022-02-28T11:43:19.000Z | /* SPDX-License-Identifier: GPL-2.0-only */
/* Copyright (c) 2015, The Linux Foundation. All rights reserved.
*/
#ifndef UFSHCD_PLTFRM_H_
#define UFSHCD_PLTFRM_H_
#include "ufshcd.h"
#define UFS_PWM_MODE 1
#define UFS_HS_MODE 2
struct ufs_dev_params {
u32 pwm_rx_gear; /* pwm rx gear to work in */
u32 pwm_tx_gear; /* pwm tx gear to work in */
u32 hs_rx_gear; /* hs rx gear to work in */
u32 hs_tx_gear; /* hs tx gear to work in */
u32 rx_lanes; /* number of rx lanes */
u32 tx_lanes; /* number of tx lanes */
u32 rx_pwr_pwm; /* rx pwm working pwr */
u32 tx_pwr_pwm; /* tx pwm working pwr */
u32 rx_pwr_hs; /* rx hs working pwr */
u32 tx_pwr_hs; /* tx hs working pwr */
u32 hs_rate; /* rate A/B to work in HS */
u32 desired_working_mode;
};
int ufshcd_get_pwr_dev_param(struct ufs_dev_params *dev_param,
struct ufs_pa_layer_attr *dev_max,
struct ufs_pa_layer_attr *agreed_pwr);
int ufshcd_pltfrm_init(struct platform_device *pdev,
const struct ufs_hba_variant_ops *vops);
void ufshcd_pltfrm_shutdown(struct platform_device *pdev);
#ifdef CONFIG_PM
int ufshcd_pltfrm_suspend(struct device *dev);
int ufshcd_pltfrm_resume(struct device *dev);
int ufshcd_pltfrm_runtime_suspend(struct device *dev);
int ufshcd_pltfrm_runtime_resume(struct device *dev);
int ufshcd_pltfrm_runtime_idle(struct device *dev);
#else /* !CONFIG_PM */
#define ufshcd_pltfrm_suspend NULL
#define ufshcd_pltfrm_resume NULL
#define ufshcd_pltfrm_runtime_suspend NULL
#define ufshcd_pltfrm_runtime_resume NULL
#define ufshcd_pltfrm_runtime_idle NULL
#endif /* CONFIG_PM */
#endif /* UFSHCD_PLTFRM_H_ */
| 31.796296 | 65 | 0.712289 |
a2c07f4f4662842a847b11631ec5e6c2ab95a7af | 625 | h | C | include/berrydb.h | google/berrydb | 02657eb5c43c133290a6d3cb68311f5adc0726f8 | [
"BSD-3-Clause"
] | 78 | 2017-06-21T22:12:58.000Z | 2022-03-09T08:36:18.000Z | include/berrydb.h | google/berrydb | 02657eb5c43c133290a6d3cb68311f5adc0726f8 | [
"BSD-3-Clause"
] | 3 | 2018-04-09T07:15:17.000Z | 2018-12-26T12:20:08.000Z | include/berrydb.h | google/berrydb | 02657eb5c43c133290a6d3cb68311f5adc0726f8 | [
"BSD-3-Clause"
] | 30 | 2017-06-25T13:17:38.000Z | 2021-10-21T01:10:12.000Z | // Copyright 2017 The BerryDB 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 BERRYDB_INCLUDE_BERRYDB_H_
#define BERRYDB_INCLUDE_BERRYDB_H_
namespace berrydb {} // namespace berrydb
#include "berrydb/catalog.h"
#include "berrydb/options.h"
#include "berrydb/pool.h"
#include "berrydb/space.h"
#include "berrydb/span.h"
#include "berrydb/status.h"
#include "berrydb/store.h"
#include "berrydb/transaction.h"
#include "berrydb/types.h"
#include "berrydb/version.h"
#include "berrydb/vfs.h"
#endif // BERRYDB_INCLUDE_BERRYDB_H_
| 27.173913 | 73 | 0.768 |
4e3503ddd1b33a96f1c0b669133fa7fdf855d918 | 1,134 | h | C | android/app/src/main/cpp/src/camera/Camera.h | comword/TCD20-DP-MobileApp | 94b21fb00f3c7b98dcbb19a3f2715ea6faaa9444 | [
"MIT"
] | null | null | null | android/app/src/main/cpp/src/camera/Camera.h | comword/TCD20-DP-MobileApp | 94b21fb00f3c7b98dcbb19a3f2715ea6faaa9444 | [
"MIT"
] | null | null | null | android/app/src/main/cpp/src/camera/Camera.h | comword/TCD20-DP-MobileApp | 94b21fb00f3c7b98dcbb19a3f2715ea6faaa9444 | [
"MIT"
] | null | null | null | #ifndef INVIGILATOR_CAMERA_H
#define INVIGILATOR_CAMERA_H
#include <string>
#include <memory>
#include <thread>
struct ACameraManager;
struct ANativeWindow;
class FaceDetector;
class IClassifier;
namespace cv
{
class Mat;
class VideoCapture;
}
class Camera
{
public:
enum Facing : uint8_t { FRONT = 0, BACK, EXTERNAL };
public:
Camera();
virtual ~Camera();
void initFaceDetector( const std::string &haarCascadePath, const std::string &modelLBFPath );
bool start( int index );
void stop();
bool setCaptureSize( int width, int height );
void initSurface( ANativeWindow *window );
std::tuple<int, int> getCaptureSize();
bool registerClassifier( IClassifier *ml );
bool unloadClassifier();
private:
std::shared_ptr<ACameraManager> cameraManager;
std::shared_ptr<ANativeWindow> textureWindow;
std::shared_ptr<cv::VideoCapture> cvCapture;
int cacheWidth = 0, cacheHeight = 0;
std::shared_ptr<FaceDetector> faceDetector;
volatile bool renderStop = false;
};
#endif //INVIGILATOR_CAMERA_H
| 25.772727 | 101 | 0.674603 |
2328da7f9445acbe8929c322368f6cbb5be8730a | 53 | h | C | Code/Controllers/MPHPageController.h | zadr/8mph | 0369e7e86b8bf0cf169b67e0f24774584597c7c2 | [
"BSD-2-Clause-FreeBSD"
] | 9 | 2015-06-22T05:46:46.000Z | 2018-11-14T03:42:55.000Z | Code/Controllers/MPHPageController.h | zadr/8mph | 0369e7e86b8bf0cf169b67e0f24774584597c7c2 | [
"BSD-2-Clause-FreeBSD"
] | null | null | null | Code/Controllers/MPHPageController.h | zadr/8mph | 0369e7e86b8bf0cf169b67e0f24774584597c7c2 | [
"BSD-2-Clause-FreeBSD"
] | null | null | null | @interface MPHPageController : NSPageController
@end
| 17.666667 | 47 | 0.849057 |
ea83e464dbe2f6867a6df48583f4198b6e9ca446 | 354 | h | C | yimediter/yimediter/ybzediter/items/DefualtUndoTypingItem.h | yiiim/yimediter | 5dfff3398d1a7e4413ec81c53b2cb58975fccdcc | [
"MIT"
] | 33 | 2017-12-05T07:30:06.000Z | 2021-07-26T07:44:32.000Z | yimediter/yimediter/ybzediter/items/DefualtUndoTypingItem.h | mohsinalimat/yimediter | 5dfff3398d1a7e4413ec81c53b2cb58975fccdcc | [
"MIT"
] | null | null | null | yimediter/yimediter/ybzediter/items/DefualtUndoTypingItem.h | mohsinalimat/yimediter | 5dfff3398d1a7e4413ec81c53b2cb58975fccdcc | [
"MIT"
] | 5 | 2017-12-14T22:51:04.000Z | 2021-05-31T10:27:39.000Z | //
// DefualtUndoTypingItem.h
// yimediter
//
// Created by ybz on 2017/12/4.
// Copyright © 2017年 ybz. All rights reserved.
//
#import "YIMEditerAccessoryMenuItem.h"
#import "YIMEditerProtocol.h"
@interface DefualtUndoTypingItem : YIMEditerAccessoryMenuItem <YIMEditerTextViewDelegate>
@property(nonatomic,weak)YIMEditerTextView *textView;
@end
| 20.823529 | 89 | 0.771186 |
d85ea89dd9305e8930edf39fd69504fb0da6c5f9 | 5,438 | h | C | tools/BladeRF/host/utilities/bladeRF-fsk/c/src/phy.h | Charmve/BLE-Security-Att-Def | 3652d84bf4ac0c694bb3c4c0f611098da9122af0 | [
"BSD-2-Clause"
] | 149 | 2020-10-23T23:31:51.000Z | 2022-03-15T00:25:35.000Z | tools/BladeRF/host/utilities/bladeRF-fsk/c/src/phy.h | Charmve/BLE-Security-Att-Def | 3652d84bf4ac0c694bb3c4c0f611098da9122af0 | [
"BSD-2-Clause"
] | 1 | 2021-04-12T19:24:00.000Z | 2021-04-27T03:11:07.000Z | tools/BladeRF/host/utilities/bladeRF-fsk/c/src/phy.h | Charmve/BLE-Security-Att-Def | 3652d84bf4ac0c694bb3c4c0f611098da9122af0 | [
"BSD-2-Clause"
] | 22 | 2020-11-17T02:52:40.000Z | 2022-03-15T00:26:38.000Z | /**
* @file
* @brief Physical layer code for modem
*
* This file handles transmission/reception of data frames over the air. It uses fsk.c to
* perform baseband IQ modulation and demodulation, and libbladeRF to transmit/receive
* samples using the bladeRF device. A different modulator could be used by swapping
* fsk.c with a file that implements a different modulator. On the receive side the file
* uses fir_filter.c to low-pass filter the received signal, pnorm.c to power normalize
* the input signal, and correlator.c to correlate the received signal with a preamble.
* waveform.
*
* The structure of a physical layer transmission is as follows:
* ```
* / ramp up | training sequence | preamble | link layer frame | ramp down \
* ```
* The ramps at the beginning/end are SAMP_PER_SYMB samples long
*
* This file is part of the bladeRF project
*
* Copyright (C) 2016 Nuand LLC
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef PHY_H
#define PHY_H
#include <stdbool.h>
#include <libbladeRF.h>
#include <string.h>
#include <pthread.h>
#include <errno.h>
#include <math.h>
#include "host_config.h"
#include "common.h"
#include "utils.h"
//Training sequence which goes at the start of every frame
//Note: In order for the preamble waveform not to be messed up, the last
//sample of the modulated training sequence MUST be 1 + 0j (2047 + 0j)
#define TRAINING_SEQ {0xAA, 0xAA, 0xAA, 0xAA}
//Length of training sequence in bytes
#define TRAINING_SEQ_LENGTH 4
//preamble which goes after the training sequence
#define PREAMBLE {0x2E, 0x69, 0x2C, 0xF0}
//Length of preamble in bytes
#define PREAMBLE_LENGTH 4
//Byte codes for data/ack frame
#define DATA_FRAME_CODE 0x00
#define ACK_FRAME_CODE 0xFF
//Frame lengths
#define DATA_FRAME_LENGTH 1009
#define ACK_FRAME_LENGTH 7
//Maximum frame size in bytes
#define MAX_LINK_FRAME_SIZE DATA_FRAME_LENGTH
//Seed for pseudorandom number sequence generator
#define PRNG_SEED 0x0109BBA53CFFD081
//Length (in samples) of ramp up/ramp down
#define RAMP_LENGTH SAMP_PER_SYMB
//Number of samples to receive at a time from bladeRF
#define NUM_SAMPLES_RX SYNC_BUFFER_SIZE
//Correlator countdown size
#define CORR_COUNTDOWN SAMP_PER_SYMB
struct phy_handle;
//----------------------Transmitter functions---------------------------
/**
* Start the PHY transmitter thread
*
* @param[in] phy pointer to phy_handle struct
*
* @return 0 on success, -1 on failure
*/
int phy_start_transmitter(struct phy_handle *phy);
/**
* Stop the PHY transmitter thread
*
* @param[in] phy pointer to phy_handle struct
*
* @return 0 on success, -1 on failure
*/
int phy_stop_transmitter(struct phy_handle *phy);
/**
* Fill the tx buffer so its data will be transmitted using phy_transmit_frames()
*
* @param[in] phy pointer to phy handle structure
* @param[in] data_buf bytes to transmit
* @param[in] length length of data buf
*
* @return 0 on success, -1 on failure
*/
int phy_fill_tx_buf(struct phy_handle *phy, uint8_t *data_buf, unsigned int length);
//------------------------Receiver functions---------------------------
/**
* Start the PHY receiver thread
*
* @param[in] phy pointer to phy_handle struct
*
* @return 0 on success, -1 on failure
*/
int phy_start_receiver(struct phy_handle *phy);
/**
* Stop the PHY receiver thread
*
* @param[in] phy pointer to phy_handle struct
*
* @return 0 on success, -1 on failure
*/
int phy_stop_receiver(struct phy_handle *phy);
/**
* Request a received frame from phy_receive_frames(). Caller should call
* phy_release_rx_buf() when done with the received frame so that
* phy_receive_frames() does not drop any frames.
*
* @param[in] phy pointer to phy_handle struct
* @param[in] timeout_ms amount of time to wait for a buffer from the PHY
*
* @return pointer to filled buffer with received frame inside
*/
uint8_t *phy_request_rx_buf(struct phy_handle *phy, unsigned int timeout_ms);
/**
* Release RX buffer so that phy_receive_frames() can copy new frames into the buffer
*
* @param[in] phy pointer to phy_handle struct
*/
void phy_release_rx_buf(struct phy_handle *phy);
//-----------------------Init/Deinit functions-------------------------
/**
* Open/Initialize a phy_handle
*
* @param[in] dev pointer to opened bladeRF device handle
* @param[in] params pointer to radio parameters struct
*
* @return allocated phy_handle on success, NULL on failure
*/
struct phy_handle *phy_init(struct bladerf *dev, struct radio_params *params);
/**
* Close a phy handle. Does nothing if handle is NULL
*
* @param[in] phy_handle to close
*/
void phy_close(struct phy_handle *phy);
#endif
| 32.369048 | 89 | 0.709452 |
f00a53e07ead573e49f6454cbcc6bf752ec248fe | 2,635 | h | C | usr/src/cmd/fm/modules/sun4v/generic-mem/gmem.h | AsahiOS/gate | 283d47da4e17a5871d9d575e7ffb81e8f6c52e51 | [
"MIT"
] | null | null | null | usr/src/cmd/fm/modules/sun4v/generic-mem/gmem.h | AsahiOS/gate | 283d47da4e17a5871d9d575e7ffb81e8f6c52e51 | [
"MIT"
] | null | null | null | usr/src/cmd/fm/modules/sun4v/generic-mem/gmem.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 (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 (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#ifndef _GMEM_H
#define _GMEM_H
#include <stdarg.h>
#include <fm/fmd_api.h>
#include <sys/param.h>
#include <gmem_util.h>
#ifdef __cplusplus
extern "C" {
#endif
#define GMEM_STAT_BUMP(name) gmem.gm_stats->name.fmds_value.ui64++
#define GMEM_FLTMAXCONF 95
typedef struct gmem_stat {
fmd_stat_t bad_mem_resource; /* # of malformed hc-scheme resource */
fmd_stat_t bad_close; /* # of inapplicable case closes */
fmd_stat_t old_erpt; /* # of erpts for removed components */
fmd_stat_t dimm_creat; /* # of DIMM state structs created */
fmd_stat_t page_creat; /* # of page state structs created */
fmd_stat_t ce_unknown; /* # of unknown CEs seen */
fmd_stat_t ce_interm; /* # of intermittent CEs seen */
fmd_stat_t ce_clearable_persis; /* # of clearable persistent CEs seen */
fmd_stat_t ce_sticky; /* # of sticky CEs seen */
fmd_stat_t dimm_migrat; /* # of DIMMs migrated to new version */
} gmem_stat_t;
typedef struct gmem_serd {
const char *cs_name;
uint_t cs_n;
hrtime_t cs_t;
} gmem_serd_t;
typedef struct gmem {
gmem_list_t gm_dimms; /* List of DIMM state structures */
gmem_list_t gm_pages; /* List of page state structures */
gmem_stat_t *gm_stats; /* Module statistics */
size_t gm_pagesize; /* Page size, in bytes */
uint64_t gm_pagemask; /* Mask for page alignments */
uint32_t gm_max_retired_pages; /* max num retired pages */
uint32_t gm_ce_n; /* serd n */
uint64_t gm_ce_t; /* serd t */
uint32_t gm_filter_ratio; /* serd filter ratio */
uint32_t gm_low_ce_thresh; /* low threshold retired pages */
uint32_t gm_nupos; /* same number of upos */
uint32_t gm_dupce; /* number of dup CEs */
} gmem_t;
extern gmem_t gmem;
#ifdef __cplusplus
}
#endif
#endif /* _GMEM_H */
| 32.134146 | 79 | 0.728653 |
002059d65b01e3fea0a4fc7e9478606cc43998b4 | 1,014 | h | C | EU4toV2/Source/Mappers/PartyTypes/PartyType.h | GregB76/EU4toVic2 | 0a8822101a36a16036fdc315e706d113d9231101 | [
"MIT"
] | 1 | 2020-10-03T16:01:28.000Z | 2020-10-03T16:01:28.000Z | EU4toV2/Source/Mappers/PartyTypes/PartyType.h | P4blo7/EU4toVic2 | 3f6d354a1f5e529f3d96b3616fe5109bc23f2972 | [
"MIT"
] | null | null | null | EU4toV2/Source/Mappers/PartyTypes/PartyType.h | P4blo7/EU4toVic2 | 3f6d354a1f5e529f3d96b3616fe5109bc23f2972 | [
"MIT"
] | null | null | null | #ifndef PARTY_TYPE_H
#define PARTY_TYPE_H
#include "Parser.h"
#include "Date.h"
namespace mappers
{
class PartyType : commonItems::parser
{
public:
PartyType() = default;
explicit PartyType(std::istream& theStream);
void setName(const std::string& partyName) { name = partyName; }
void setIdeology(const std::string& partyIdeology) { ideology = partyIdeology; }
[[nodiscard]] const auto& getName() const { return name; }
[[nodiscard]] const auto& getIdeology() const { return ideology; }
[[nodiscard]] const auto& getStartDate() const { return start_date; }
[[nodiscard]] const auto& getEndDate() const { return end_date; }
friend std::ostream& operator<<(std::ostream& output, const PartyType& partyDetails);
private:
std::string name;
std::string ideology;
date start_date;
date end_date;
std::string economic_policy;
std::string trade_policy;
std::string religious_policy;
std::string citizenship_policy;
std::string war_policy;
};
}
#endif // PARTY_TYPE_H | 24.731707 | 87 | 0.71499 |
536c82b6ae650d8acd43b9e406db21d96471ad2f | 881 | h | C | Inc/acc_rss_diagnostics.h | Monash-BoSL/radar-firmware | 5a922c625b2e0d82f28acbce5daa0c762b541825 | [
"MIT",
"BSD-3-Clause"
] | 1 | 2022-01-07T11:10:15.000Z | 2022-01-07T11:10:15.000Z | Inc/acc_rss_diagnostics.h | Monash-BoSL/xm132-radar-firmware | 5a922c625b2e0d82f28acbce5daa0c762b541825 | [
"MIT",
"BSD-3-Clause"
] | 1 | 2021-11-30T04:36:27.000Z | 2021-11-30T04:36:27.000Z | Inc/acc_rss_diagnostics.h | Monash-BoSL/xm132-radar-firmware | 5a922c625b2e0d82f28acbce5daa0c762b541825 | [
"MIT",
"BSD-3-Clause"
] | null | null | null | // Copyright (c) Acconeer AB, 2019-2021
// All rights reserved
#ifndef ACC_RSS_DIAGNOSTICS_H_
#define ACC_RSS_DIAGNOSTICS_H_
#include "acc_definitions_common.h"
#include <stdbool.h>
/**
* @defgroup Diagnostic_test Diagnostic test
* @ingroup RSS
*
* @brief RSS Diagnostic test
*
* @{
*/
/**
* @brief Run diagnostic test
*
* This function executes a suite of tests for diagnostic testing of the A111 sensor.
*
* @details
* - This function must be called after #acc_rss_activate.
* - This function must be called before any service is created.
* - If a test fails to execute the return value will be set to false.
*
* @param[in] sensor_id The sensor to run diagnostic test on
* @return True if successfully run, false otherwise
*/
bool acc_rss_diagnostic_test(acc_sensor_id_t sensor_id);
/**
* @}
*/
#endif
| 20.97619 | 86 | 0.681044 |
1566a7a1baca3d3a65127502a2f0a8f3f4cb46a6 | 3,379 | h | C | apps/qtViewer/sg/common/Serialization.h | mathstuf/ospray | 5c34884317b5bb84346e4e1e2e2bf8c7f50d307c | [
"Apache-2.0"
] | 1 | 2016-05-24T19:27:01.000Z | 2016-05-24T19:27:01.000Z | apps/qtViewer/sg/common/Serialization.h | mathstuf/ospray | 5c34884317b5bb84346e4e1e2e2bf8c7f50d307c | [
"Apache-2.0"
] | null | null | null | apps/qtViewer/sg/common/Serialization.h | mathstuf/ospray | 5c34884317b5bb84346e4e1e2e2bf8c7f50d307c | [
"Apache-2.0"
] | null | null | null | // ======================================================================== //
// Copyright 2009-2016 Intel Corporation //
// //
// 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 "sg/common/Common.h"
// ospcommon
#include "common/RefCount.h"
#include "common/AffineSpace.h"
// std
#include <vector>
namespace ospray {
namespace sg {
typedef ospcommon::AffineSpace3f affine3f;
/*! class one can use to serialize all nodes in the scene graph */
struct Serialization {
typedef enum {
/*! when serializing the scene graph, traverse through all
instances and record each and every occurrence of any object
(ie, an instanced object will appear multiple times in the
output, each with one instantiation info */
DO_FOLLOW_INSTANCES,
/*! when serializing the scene graph, record each instanced
object only ONCE, and list all its instantiations in its
instantiation vector */
DONT_FOLLOW_INSTANCES
} Mode;
struct Instantiation : public RefCount {
Ref<Instantiation> parentWorld;
affine3f xfm;
Instantiation() : parentWorld(NULL), xfm(one) {}
};
/*! describes one object that we encountered */
struct Object : public RefCount {
/*! the node itself */
Ref<sg::Node> node;
/*! the instantiation info when we traversed this node. May be
NULL if object isn't instanced (or only instanced once) */
Ref<Instantiation> instantiation;
// std::vector<Ref<Instantiation> > instantiation;
Object(sg::Node *node=NULL, Instantiation *inst=NULL)
: node(node), instantiation(inst)
{};
};
/*! the node that maintains all the traversal state when
traversing the scene graph */
struct State {
Ref<Instantiation> instantiation;
Serialization *serialization;
};
void serialize(Ref<sg::World> world, Serialization::Mode mode);
/*! clear all old objects */
void clear() { object.clear(); }
size_t size() const { return object.size(); }
/*! the vector containing all the objects encountered when
serializing the entire scene graph */
std::vector<Ref<Object> > object;
};
} // ::ospray::sg
} // ::ospray
| 38.397727 | 78 | 0.535957 |
afc3cbdb9aa7923921b9d33ced1789dc2595768a | 12,956 | h | C | platformio/components_check/src/internalIOExaminer.h | devATdbsutdio/watch_firmware | 2145b8feecf83166454456fc2cfe4ea345781a5b | [
"CC0-1.0"
] | null | null | null | platformio/components_check/src/internalIOExaminer.h | devATdbsutdio/watch_firmware | 2145b8feecf83166454456fc2cfe4ea345781a5b | [
"CC0-1.0"
] | null | null | null | platformio/components_check/src/internalIOExaminer.h | devATdbsutdio/watch_firmware | 2145b8feecf83166454456fc2cfe4ea345781a5b | [
"CC0-1.0"
] | null | null | null | /*
Description: For checking inetrnal IOs can be set properly and the registers are working
Author: Saurabh datta.
Time: Oct, 2021.
Loca: Beijing, China.
License: MIT
*/
#include <Arduino.h>
unsigned long pinTestModeStartMillis;
unsigned long pinTestModeCurrMillis;
const unsigned long testModeProgressPeriod = 100;
bool PORTA_checked;
bool PORTB_checked;
bool PORTC_checked;
bool pinExaminationFinished;
bool pinStatus;
//-- Helper function **
void printBinary(byte b)
{
for (int i = 7; i >= 0; i--)
{
Serial.print((b >> i) & 0X01); // shift and select first bit
}
Serial.println();
}
int pac = 1;
int pbc = 0;
int pcc = 0;
int portAStatus[7]; // PA1-PC7
int portBStatus[8]; // PB0-PB7
int portCStatus[6]; // PC0-PC5
/*
portAStatus[0] corresponds to PA1's state
portAStatus[1] corresponds to PA2's state
portAStatus[2] corresponds to PA3's state
portAStatus[3] corresponds to PA4's state
portAStatus[4] corresponds to PA5's state
portAStatus[5] corresponds to PA6's state
portAStatus[6] corresponds to PA7's state
portBStatus[0] corresponds to PB0's state
portBStatus[1] corresponds to PB1's state
portBStatus[2] corresponds to PB2's state - ignore
portBStatus[3] corresponds to PB3's state - ignore
portBStatus[4] corresponds to PB4's state
portBStatus[5] corresponds to PB5's state
portBStatus[6] corresponds to PB6's state
portBStatus[7] corresponds to PB7's state
portCStatus[0] corresponds to PC0's state
portCStatus[1] corresponds to PC1's state
portCStatus[2] corresponds to PC2's state
portCStatus[3] corresponds to PC3's state
portCStatus[4] corresponds to PC4's state
portCStatus[5] corresponds to PC5's state
*/
bool firstState;
bool secondState;
boolean isSerialPin;
void examinePins()
{
while (true)
{
pinTestModeCurrMillis = millis();
if (pinTestModeCurrMillis - pinTestModeStartMillis >= testModeProgressPeriod)
{
//--- For Port A (Before Port B & C) ---//
if (!PORTA_checked && !PORTB_checked && !PORTC_checked)
{
// Serial.print("Checking: PA-");
// Serial.print(pac);
// Serial.print(" : ");
// byte portAddrMask = (0b00000001 << pac);
byte portAddrMask = 0b00000001;
portAddrMask <<= pac;
// printBinary(portAddrMask);
// Set as OUTPUT & HIGH
cli();
PORTA.DIRSET = portAddrMask;
PORTA.OUTSET = portAddrMask;
// Set as INPUT and read STATE
PORTA.DIRCLR = portAddrMask;
firstState = PORTA.IN & portAddrMask;
// Serial.println(firstState);
// Set as OUTPUT & LOW
PORTA.DIRSET = portAddrMask;
PORTA.OUTCLR = portAddrMask;
// Set as INPUT and read STATE, again
PORTA.DIRCLR = portAddrMask;
secondState = PORTA.IN & portAddrMask;
// Serial.println(secondState);
// [DEBUG] [TEST] **Simulation for non-working pins
// if (pac == 4 || pac == 6) {
// secondState = HIGH;
// }
//------------------------------------------------//
sei();
// Serial.print(String(firstState) + " " + String(secondState));
// Mark that pin as "working: 1, if you see the pin has toggled!"
if (firstState == HIGH && secondState == LOW)
portAStatus[pac - 1] = 1;
else
portAStatus[pac - 1] = 0;
pac++;
if (pac > int(sizeof(portAStatus) / 2))
{
pac = 1;
PORTA_checked = true;
Serial.println("PORT-A IO check finished!");
int total_working_pins = 0;
// ** [BUG] [TBD] - size fo array is 14 , should be 7 ??
// Serial.print("Size of array: ");
// Serial.println(sizeof(portAStatus));
// ** Duct tape solution
for (int i = 0; i < int(sizeof(portAStatus) / 2); i++)
{
// Serial.print("PA");
// Serial.print(i + 1);
// Serial.print(": ");
// Serial.println(portAStatus[i]);
if (portAStatus[i] == 0)
{
Serial.print("[ERR] Internally, PA");
Serial.print(i + 1);
Serial.println(" not working!");
}
else
{
total_working_pins += 1;
}
}
if (total_working_pins == sizeof(portAStatus) / 2)
{
Serial.println("[/] In PORT A (PA1-PA7),");
Serial.println("All pins are working!\n");
}
else
{
Serial.println("[X] In PORT A (PA1-PA7), a total");
Serial.println("of only " + String(total_working_pins) + " pins are working!\n");
}
}
}
//--- For Port B (After Port A) ---//
if (PORTA_checked && !PORTB_checked && !PORTC_checked)
{
byte portAddrMask = 0b00000001; // pbc staring at 4
// PB2 and PB3 are serial, assuming they are working
if (pbc == 2 || pbc == 3)
{
isSerialPin = true;
// Serial.println("Not bitshifting, it is serial pin!");
// Just for filling in hardcoded data for later
firstState = LOW;
secondState = LOW;
}
else
{
isSerialPin = false;
}
if (!isSerialPin)
{
// bit shift and iterate through PORT
portAddrMask <<= pbc;
// printBinary(portAddrMask);
// Set as OUTPUT & HIGH
cli();
PORTB.DIRSET = portAddrMask;
PORTB.OUTSET = portAddrMask;
// Set as INPUT and read STATE
PORTB.DIRCLR = portAddrMask;
firstState = PORTB.IN & portAddrMask;
// Serial.println(firstState);
// Set as OUTPUT & LOW
PORTB.DIRSET = portAddrMask;
PORTB.OUTCLR = portAddrMask;
// Set as INPUT and read STATE, again!
PORTB.DIRCLR = portAddrMask;
secondState = PORTB.IN & portAddrMask;
// Serial.println(secondState);
// [DEBUG] [TEST] **Simulation for non-working pins
// if (pbc == 5) {
// secondState = HIGH;
// }
//------------------------------------------------//
sei();
}
// Mark that pin as "working: 1, if you see the pin has toggled!"
if (firstState == HIGH && secondState == LOW)
portBStatus[pbc] = 1;
else
portBStatus[pbc] = 0;
pbc++;
if (pbc > int(sizeof(portBStatus) / 2))
{
pbc = 0;
PORTB_checked = true;
Serial.println("PORT-B IO check finished!");
int total_working_pins = 0;
for (int i = 0; i < int(sizeof(portBStatus) / 2); i++)
{ // ignoring RX TX pin's registered states
// Serial.println(i);
if ((portBStatus[i] == 0) && i != 2 && i != 3)
{
Serial.print("[ERR] Internally, PB");
Serial.print(i);
Serial.println(" not working!");
}
else if ((portBStatus[i] == 0) && (i == 2 || i == 3))
{
// Serial.println("Ignoring Hardcoded values for Serial Pins!");
}
else
{
total_working_pins += 1;
}
}
if (total_working_pins == sizeof(portBStatus) / 2 - 2)
{ // ignoring RX TX pins
Serial.println("[/] In PORT B (PB0-PB1 & PB4-PB7),");
Serial.println("All pins are working!\n");
}
else
{
Serial.println("[X] In PORT B (PB0-PB1 & PB4-PB7), a total");
Serial.println("of only " + String(total_working_pins) + " pins are working!\n");
}
}
}
// For Port C (After Port A & Port B)
if (PORTA_checked && PORTB_checked && !PORTC_checked)
{
byte portAddrMask = 0b00000001;
portAddrMask <<= pcc;
// printBinary(portAddrMask);
// Set as OUTPUT & HIGH
cli();
PORTC.DIRSET = portAddrMask;
PORTC.OUTSET = portAddrMask;
// Set as INPUT and read STATE
PORTC.DIRCLR = portAddrMask;
firstState = PORTC.IN & portAddrMask;
// Serial.println(firstState);
// Set as OUTPUT & LOW
PORTC.DIRSET = portAddrMask;
PORTC.OUTCLR = portAddrMask;
// Set as INPUT and read STATE, again
PORTC.DIRCLR = portAddrMask;
secondState = PORTC.IN & portAddrMask;
// Serial.println(secondState);
// [DEBUG] [TEST] **Simulation for non-working pins
// if (pcc == 4) {
// secondState = HIGH;
// }
//------------------------------------------------//
sei();
if (firstState == HIGH && secondState == LOW)
{
// Means that particular pin state is changing and working
// Mark that pin as "working: 1"
// Serial.println("Working!");
portCStatus[pcc] = 1;
}
else
{
// Mark that pin as "not-working: 0"
// Serial.println("Not Working!");
portCStatus[pcc] = 0;
}
pcc++;
if (pcc > 5)
{
pcc = 0;
PORTC_checked = true;
Serial.println("PORT-C IO check finished!");
int total_working_pins = 0;
for (int i = 0; i < int(sizeof(portCStatus) / 2); i++)
{
if (portCStatus[i] == 0)
{
Serial.print("[ERR] Internally, PC");
Serial.print(i);
Serial.println(" not working!");
}
else
{
total_working_pins += 1;
}
}
if (total_working_pins == sizeof(portCStatus) / 2)
{
Serial.println("[/] In PORT C (PC0-PC5),");
Serial.println("All pins are working!\n");
}
else
{
Serial.println("[X] In PORT C (PC0-PC5), a total");
Serial.println("of only " + String(total_working_pins) + " pins are working!\n");
}
}
}
if (PORTA_checked && PORTB_checked && PORTC_checked)
{
Serial.println("\nATTINY Digital IO Test finished!\n");
break;
}
pinTestModeStartMillis = pinTestModeCurrMillis;
}
}
} | 36.70255 | 105 | 0.419111 |
c62a2fd2e96ad02c4f054803b314e7c20996c189 | 7,424 | h | C | multimedia/directx/dplay/dvoice/dxvtlib/supervis.h | npocmaka/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 17 | 2020-11-13T13:42:52.000Z | 2021-09-16T09:13:13.000Z | multimedia/directx/dplay/dvoice/dxvtlib/supervis.h | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 2 | 2020-10-19T08:02:06.000Z | 2020-10-19T08:23:18.000Z | multimedia/directx/dplay/dvoice/dxvtlib/supervis.h | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 14 | 2020-11-14T09:43:20.000Z | 2021-08-28T08:59:57.000Z | /*==========================================================================;
*
* Copyright (C) 1999 Microsoft Corporation. All Rights Reserved.
*
* File: supervis.h
* Content: Prototypes the SupervisorProcess function
* History:
* Date By Reason
* ============
* 08/19/99 pnewson created
* 10/27/99 pnewson change guid members from pointers to structs
* 11/04/99 pnewson Bug #115279 - fixed cancel processing
* - added HWND to check audio setup
* 11/30/99 pnewson default device mapping
* 01/21/2000 pnewson Update for UI revisions
* 01/23/2000 pnewson Improvded feedback for fatal errors (millen bug 114508)
* 01/24/2000 pnewson fixed bug in GetRenderDesc
* 04/04/2000 pnewson Added support for DVFLAGS_ALLOWBACK
* 04/19/2000 rodtoll Bug #31106 - Grey out recording sliders when no vol control avail
* 04/19/2000 pnewson Error handling cleanup
* 05/03/2000 pnewson bug #33878 - Wizard locks up when clicking Next/Cancel during speaker test
* 11/29/2000 rodtoll Bug #48348 - DPVOICE: Modify wizard to make use of DirectPlay8 as the transport.
*
***************************************************************************/
#ifndef _SUPERVIS_H_
#define _SUPERVIS_H_
#include "fdtipc.h"
extern HRESULT SupervisorCheckAudioSetup(
const GUID* lpguidRender,
const GUID* lpguidCapture,
HWND hwndParent,
DWORD dwFlags);
// App defined window messages
#define WM_APP_FULLDUP_TEST_COMPLETE (WM_APP)
#define WM_APP_STEP_PROGRESS_BAR (WM_APP + 1)
#define WM_APP_LOOPBACK_RUNNING (WM_APP + 2)
#define WM_APP_RECORDSTART (WM_APP + 3)
#define WM_APP_RECORDSTOP (WM_APP + 4)
// The UI element this is used for can only display about 40 chars anyway,
// so there's no point going through the hassle of allocating this off
// the heap and cleaning it up.
#define MAX_DEVICE_DESC_LEN 50
// class used to manage the supervisor state and shared info
class CSupervisorInfo
{
private:
CRegistry m_creg;
HFONT m_hfTitle;
HFONT m_hfBold;
CSupervisorIPC m_sipc;
GUID m_guidCaptureDevice;
GUID m_guidRenderDevice;
TCHAR m_szCaptureDeviceDesc[MAX_DEVICE_DESC_LEN];
TCHAR m_szRenderDeviceDesc[MAX_DEVICE_DESC_LEN];
HANDLE m_hFullDuplexThread;
BOOL m_fAbortFullDuplex;
HANDLE m_hLoopbackThread;
HANDLE m_hLoopbackThreadExitEvent;
HANDLE m_hLoopbackShutdownEvent;
BOOL m_fVoiceDetected;
BOOL m_fUserBack;
BOOL m_fUserCancel;
BOOL m_fWelcomeNext;
HWND m_hwndParent;
HWND m_hwndWizard;
HWND m_hwndDialog;
HWND m_hwndProgress;
HWND m_hwndInputPeak;
HWND m_hwndOutputPeak;
HWND m_hwndInputVolumeSlider;
LONG m_lInputVolumeSliderPos;
HWND m_hwndOutputVolumeSlider;
LPDIRECTPLAYVOICECLIENT m_lpdpvc;
HANDLE m_hMutex;
PROCESS_INFORMATION m_piSndVol32Record;
PROCESS_INFORMATION m_piSndVol32Playback;
UINT m_uiWaveInDeviceId;
UINT m_uiWaveOutDeviceId;
WAVEOUTCAPS m_woCaps;
DWORD m_dwLoopbackFlags;
DWORD m_dwCheckAudioSetupFlags;
HRESULT m_hrFullDuplexResults;
HRESULT m_hrError;
DWORD m_dwDeviceFlags;
BOOL m_fLoopbackRunning;
BOOL m_fCritSecInited;
DNCRITICAL_SECTION m_csLock;
static BOOL CALLBACK DSEnumCallback(LPGUID lpguid, LPCTSTR lpcstrDescription, LPCTSTR lpcstrModule, LPVOID lpContext);
static BOOL CALLBACK DSCEnumCallback(LPGUID lpguid, LPCTSTR lpcstrDescription, LPCTSTR lpcstrModule, LPVOID lpContext);
public:
CSupervisorInfo();
~CSupervisorInfo();
HRESULT ThereCanBeOnlyOne();
HRESULT CrashCheckIn();
HRESULT OpenRegKey(BOOL fCreate);
HRESULT CloseRegKey();
HRESULT QueryFullDuplex();
HRESULT InitIPC();
HRESULT DeinitIPC();
HRESULT TestCase(const WAVEFORMATEX* lpwfxPrimary, DWORD dwFlags);
HRESULT CreateFullDuplexThread();
HRESULT WaitForFullDuplexThreadExitCode();
HRESULT CreateLoopbackThread();
HRESULT WaitForLoopbackShutdownEvent();
HRESULT ShutdownLoopbackThread();
HRESULT SignalLoopbackThreadDone();
HRESULT CreateTitleFont();
HRESULT DestroyTitleFont();
HRESULT CreateBoldFont();
HRESULT DestroyBoldFont();
HRESULT Unmute();
HRESULT Mute();
HRESULT GetDeviceDescriptions();
LPCTSTR GetCaptureDesc() const { return m_szCaptureDeviceDesc; };
LPCTSTR GetRenderDesc() const { return m_szRenderDeviceDesc; };
BOOL GetLoopbackRunning() const { return m_fLoopbackRunning; };
void SetLoopbackRunning( BOOL fRunning ) { m_fLoopbackRunning = fRunning; };
BOOL InitClass();
HRESULT Finish();
HRESULT Cancel();
HRESULT CancelFullDuplexTest();
void GetDeviceFlags(DWORD *dwFlags) const;
void SetDeviceFlags(DWORD dwFlags);
HRESULT CancelLoopbackTest();
HRESULT Abort(HWND hDlg, HRESULT hr);
void GetReg(CRegistry* pcreg);
void GetTitleFont(HFONT* lphfTitle);
void GetBoldFont(HFONT* lphfTitle);
void SetCaptureDevice(const GUID& guidCaptureDevice);
void GetCaptureDevice(GUID* lpguidCaptureDevice);
void SetRenderDevice(const GUID& guidRenderDevice);
void GetRenderDevice(GUID* lpguidRenderDevice);
void GetHWNDParent(HWND* lphwnd);
void SetHWNDParent(HWND hwnd);
void GetHWNDWizard(HWND* lphwnd);
void SetHWNDWizard(HWND hwnd);
void GetHWNDDialog(HWND* lphwnd);
void SetHWNDDialog(HWND hwnd);
void GetHWNDProgress(HWND* lphwnd);
void SetHWNDProgress(HWND hwnd);
void GetHWNDInputPeak(HWND* lphwnd);
void SetHWNDInputPeak(HWND hwnd);
void GetHWNDOutputPeak(HWND* lphwnd);
void SetHWNDOutputPeak(HWND hwnd);
void GetHWNDInputVolumeSlider(HWND* lphwnd);
void SetHWNDInputVolumeSlider(HWND hwnd);
void GetInputVolumeSliderPos(LONG* lpl);
void SetInputVolumeSliderPos(LONG lpl);
void GetHWNDOutputVolumeSlider(HWND* lphwnd);
void SetHWNDOutputVolumeSlider(HWND hwnd);
void GetDPVC(LPDIRECTPLAYVOICECLIENT* lplpdpvc);
void SetDPVC(LPDIRECTPLAYVOICECLIENT lpdpvc);
void GetLoopbackShutdownEvent(HANDLE* lphEvent);
void SetLoopbackShutdownEvent(HANDLE hEvent);
void GetIPC(CSupervisorIPC** lplpsipc);
void GetAbortFullDuplex(BOOL* lpfAbort);
void ClearAbortFullDuplex();
void SetWaveOutHandle(HWAVEOUT hwo);
HRESULT SetWaveOutId(UINT ui);
void SetWaveInId(UINT ui);
void GetLoopbackFlags(DWORD* pdwFlags);
void SetLoopbackFlags(DWORD dwFlags);
void GetCheckAudioSetupFlags(DWORD* pdwFlags);
void SetCheckAudioSetupFlags(DWORD dwFlags);
void GetFullDuplexResults(HRESULT* hr);
void SetFullDuplexResults(HRESULT hr);
void GetError(HRESULT* hr);
void SetError(HRESULT hr);
HRESULT GetFullDuplex(DWORD* pdwFullDuplex);
HRESULT SetFullDuplex(DWORD dwFullDuplex);
HRESULT GetHalfDuplex(DWORD* pdwHalfDuplex);
HRESULT SetHalfDuplex(DWORD dwHalfDuplex);
HRESULT GetMicDetected(DWORD* pdwMicDetected);
HRESULT SetMicDetected(DWORD dwMicDetected);
HRESULT SetRecordVolume(LONG lVolume);
HRESULT LaunchWindowsVolumeControl(HWND hwndWizard, BOOL fRecord);
HRESULT CloseWindowsVolumeControl(BOOL fRecord);
HRESULT GetWaveOutVolume(DWORD* lpdwVolume);
HRESULT SetWaveOutVolume(DWORD dwVolume);
void CloseMutex();
void SetVoiceDetected();
void ClearVoiceDetected();
void GetVoiceDetected(BOOL* lpfPreviousCrash);
void SetUserBack();
void ClearUserBack();
void GetUserBack(BOOL* lpfUserBack);
void SetUserCancel();
void ClearUserCancel();
void GetUserCancel(BOOL* lpfUserCancel);
void SetWelcomeNext();
void ClearWelcomeNext();
void GetWelcomeNext(BOOL* lpfWelcomeNext);
};
#endif
| 34.85446 | 121 | 0.751616 |
7670e93037512174068351f3f69d5fe663312a36 | 1,177 | h | C | controlKeyboard.h | per1234/controlKeyboard | 76a6b0bc10fc133bcbbf1f71e5cf2bb066cdc192 | [
"Unlicense"
] | null | null | null | controlKeyboard.h | per1234/controlKeyboard | 76a6b0bc10fc133bcbbf1f71e5cf2bb066cdc192 | [
"Unlicense"
] | null | null | null | controlKeyboard.h | per1234/controlKeyboard | 76a6b0bc10fc133bcbbf1f71e5cf2bb066cdc192 | [
"Unlicense"
] | 1 | 2020-09-25T16:55:15.000Z | 2020-09-25T16:55:15.000Z | #ifndef CONTROL_KEYBOARD_H
#define CONTROL_KEYBOARD_H
#include <hidboot.h>
enum KeyboardModifiers {
LeftCtrl = 1,
LeftShift = 2,
Alt = 4,
LeftCmd = 8,
RightCtrl = 16,
RightShift = 32,
AltGr = 64,
RightCmd = 128
};
//key array contains state of keys 0 - Pressed, 1 - Released and 2 - Nothing
const int KEY_ARRAY_SIZE = 100;
class controlKeyboard : public KeyboardReportParser {
public:
controlKeyboard(USBHost &usb) : hostKeyboard(&usb), keyup(0),keydown(0), oemkey(0), modifiers(0) {
hostKeyboard.SetReportParser(0, this);
for(int i=0;i<KEY_ARRAY_SIZE;i++){
keys_array[i] = 2;
}
};
bool onKeyPress(int k);
bool onKeyRelease(int k);
void setDefault(int k);
uint8_t getKeyup(){ return keyup; };
uint8_t getKeydown(){ return keydown; };
uint8_t getModifiers(){ return modifiers; };
uint8_t getOemKey(){ return oemkey; };
protected:
virtual void OnKeyDown(uint8_t mod, uint8_t key);
virtual void OnKeyUp(uint8_t mod, uint8_t key);
private:
uint8_t keyup, keydown, oemkey, modifiers;
HIDBoot<HID_PROTOCOL_KEYBOARD> hostKeyboard;
int keys_array[KEY_ARRAY_SIZE];
};
#endif
| 25.586957 | 102 | 0.680544 |
4960ec1399b4015534fb5aba1969a46e5d1b47e5 | 3,999 | h | C | libnodejs/libnodejs.h | hoho/dosido | 54c257802873b1c9ba5da5736c9e7c87ffb4a893 | [
"MIT"
] | 5 | 2015-03-04T17:49:04.000Z | 2017-04-17T10:10:13.000Z | libnodejs/libnodejs.h | hoho/dosido | 54c257802873b1c9ba5da5736c9e7c87ffb4a893 | [
"MIT"
] | null | null | null | libnodejs/libnodejs.h | hoho/dosido | 54c257802873b1c9ba5da5736c9e7c87ffb4a893 | [
"MIT"
] | null | null | null | /*
* Copyright Marat Abdullin (https://github.com/hoho)
*/
#ifndef __LIBNODEJS_H__
#define __LIBNODEJS_H__
#include <stdlib.h>
#include <libnodejsExports.h>
typedef enum {
FROM_JS_ERROR = 1,
FROM_JS_READ_REQUEST_BODY,
FROM_JS_RESPONSE_HEADERS,
FROM_JS_RESPONSE_BODY,
FROM_JS_BEGIN_SUBREQUEST,
FROM_JS_SUBREQUEST_DONE,
FROM_JS_LOG
} nodejsFromJSCommandType;
typedef struct {
char *filename;
size_t len;
int index;
} nodejsJS;
typedef struct {
nodejsJS *js;
size_t len;
} nodejsJSArray;
// Should be the same to ngx_str_t structure.
typedef struct {
size_t len;
char *data;
} nodejsString;
typedef int64_t (*nodejsAtomicFetchAdd)(int64_t *value, int64_t add);
typedef void (*nodejsFreeFunc)(void *data);
typedef void (*nodejsLogger)(unsigned level, const char *fmt, ...);
typedef struct _nodejsContext nodejsContext;
struct _nodejsContext {
void *r;
unsigned refused:1;
size_t wait;
int64_t refCount;
nodejsAtomicFetchAdd afa;
void *_p; // To hold a persistent handle of destroy
// indicator.
void *jsCallback;
void *jsSubrequestCallback;
unsigned jsDone:1;
nodejsContext *rootCtx;
};
typedef struct {
nodejsFromJSCommandType type;
nodejsContext *jsCtx;
void *data;
nodejsFreeFunc free;
void *jsCallback;
} nodejsFromJS;
typedef struct {
nodejsString *strings;
unsigned long len;
int64_t statusCode;
nodejsString statusMessage;
} nodejsHeaders;
typedef struct {
nodejsString url;
nodejsString method;
nodejsString body;
nodejsHeaders headers;
} nodejsSubrequest;
// Should match with the level from ngx_log.h.
#define NODEJS_LOG_STDERR 0
#define NODEJS_LOG_EMERG 1
#define NODEJS_LOG_ALERT 2
#define NODEJS_LOG_CRIT 3
#define NODEJS_LOG_ERR 4
#define NODEJS_LOG_WARN 5
#define NODEJS_LOG_NOTICE 6
#define NODEJS_LOG_INFO 7
#define NODEJS_LOG_DEBUG 8
#ifdef __cplusplus
extern "C" {
#endif
LIBNODEJSPUBFUN int LIBNODEJSCALL
nodejsStart (nodejsLogger logger, int *fd);
LIBNODEJSPUBFUN void LIBNODEJSCALL
nodejsStop (void);
LIBNODEJSPUBFUN int LIBNODEJSCALL
nodejsNextScriptsVersion (void);
LIBNODEJSPUBFUN nodejsFromJS* LIBNODEJSCALL
nodejsFromJSRecv (void);
LIBNODEJSPUBFUN void LIBNODEJSCALL
nodejsFromJSFree (nodejsFromJS *cmd);
LIBNODEJSPUBFUN nodejsContext * LIBNODEJSCALL
nodejsContextCreate (void *r, nodejsContext *rootCtx,
nodejsAtomicFetchAdd afa);
LIBNODEJSPUBFUN void LIBNODEJSCALL
nodejsContextAttemptFree (nodejsContext *jsCtx);
LIBNODEJSPUBFUN int LIBNODEJSCALL
nodejsCall (nodejsString *module, nodejsContext *jsCtx,
nodejsString *method, nodejsString *uri,
nodejsString *httpProtocol,
nodejsString **headers,
nodejsString **params);
LIBNODEJSPUBFUN int LIBNODEJSCALL
nodejsChunk (nodejsContext *jsCtx, char *data,
size_t len, unsigned last, unsigned sr);
LIBNODEJSPUBFUN int LIBNODEJSCALL
nodejsSubrequestHeaders (nodejsContext *jsCtx, int status,
nodejsString *statusMsg,
nodejsString **headers);
#ifdef __cplusplus
}
#endif
#endif /* __LIBNODEJS_H__ */
| 27.965035 | 79 | 0.584646 |
a5f164e4a300afc1f6943923d626d8549b62b9af | 2,961 | c | C | libft/srcs/print_2.c | mgia/ft_ls | a4e36cedb0011711d30f2fceee2716d61b82a676 | [
"MIT"
] | 1 | 2018-09-10T22:50:31.000Z | 2018-09-10T22:50:31.000Z | libft/srcs/print_2.c | mgia/hashingAlgorithms | 272616e41cde3c6cdba133fbd3a44ac04dab28e6 | [
"MIT"
] | null | null | null | libft/srcs/print_2.c | mgia/hashingAlgorithms | 272616e41cde3c6cdba133fbd3a44ac04dab28e6 | [
"MIT"
] | null | null | null | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* print_2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mtan <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/03/12 17:02:24 by mtan #+# #+# */
/* Updated: 2018/03/12 17:02:38 by mtan ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
char *format_d(t_data *info, va_list args)
{
intmax_t num;
char *str;
int p;
num = get_signed(info, args);
p = (num < 0 || info->plus || info->space) ? 1 : 0;
str = ft_itoa(num);
str = (num < 0) ? slice_left(&str, 1) : str;
str = (info->precision) ? pad_left(&str, info->precision, '0') : str;
if (!info->minus && info->zero && !info->dot)
str = pad_left(&str, info->width - p, '0');
if (num < 0)
str = ft_strjoin("-", &str);
else if (info->plus)
str = ft_strjoin("+", &str);
else if (info->space)
str = ft_strjoin(" ", &str);
if (info->dot && !info->precision && !num)
str = ft_strdup("");
if (info->minus)
str = pad_right(&str, info->width, ' ');
else
str = pad_left(&str, info->width, ' ');
return (str);
}
static char *format_u_2(t_data *info, char *str)
{
int len;
len = ft_strlen(str);
if (info->dot)
{
if (!info->precision)
{
if (ft_strequ(str, "0"))
return (ft_strdup(""));
str[0] = '\0';
}
else if (len < info->precision)
str = pad_left(&str, info->precision, '0');
}
if (info->width)
{
if (info->minus)
str = pad_right(&str, info->width, ' ');
else if (info->zero)
str = pad_left(&str, info->width, '0');
else
str = pad_left(&str, info->width, ' ');
}
return (str);
}
char *format_u(t_data *info, va_list args)
{
char *str;
str = ft_itoa_base(get_unsigned(info, args), 10);
str = format_u_2(info, str);
return (str);
}
char *format_o(t_data *info, va_list args)
{
uintmax_t num;
char *str;
int p;
num = get_unsigned(info, args);
p = (info->hex) ? 1 : 0;
str = ft_itoa_base(num, 8);
if (info->dot && !info->precision && !num)
{
if (info->hex)
str = ft_strdup("0");
else
str = ft_strdup("");
}
if (info->precision)
str = pad_left(&str, info->precision - p, '0');
if (!info->minus && info->zero)
str = pad_left(&str, info->width, '0');
if (info->hex && num)
str = ft_strjoin("0", &str);
if (info->minus)
str = pad_right(&str, info->width, ' ');
else
str = pad_left(&str, info->width, ' ');
return (str);
}
| 27.416667 | 80 | 0.429247 |
9d3cbab399fc59d26c4f73241b5256557bb7c71f | 2,701 | h | C | stepperUNO.h | lechacal/stepperUNO | 188aa86de36faac9d5038a8fbfdd63c0fb09356a | [
"Unlicense"
] | null | null | null | stepperUNO.h | lechacal/stepperUNO | 188aa86de36faac9d5038a8fbfdd63c0fb09356a | [
"Unlicense"
] | null | null | null | stepperUNO.h | lechacal/stepperUNO | 188aa86de36faac9d5038a8fbfdd63c0fb09356a | [
"Unlicense"
] | null | null | null | #ifndef stepperUNO_h
#define stepperUNO_h
#include "config.h"
#include "Arduino.h"
#define BUTTON_ADC_PIN A0 // A0 is the button ADC input
#define BUTTON_RST_PIN 3
// ADC readings expected for the 5 buttons on the ADC input
#if KEYPAD_VERSION == 1
#define RIGHT_10BIT_ADC 0 // right
#define UP_10BIT_ADC 100 // up
#define DOWN_10BIT_ADC 256 // down
#define LEFT_10BIT_ADC 410 // left
#define SELECT_10BIT_ADC 640 // select
#elif KEYPAD_VERSION == 2
#define RIGHT_10BIT_ADC 0 // right
#define UP_10BIT_ADC 140 // up
#define DOWN_10BIT_ADC 340 // down
#define LEFT_10BIT_ADC 510 // left
#define SELECT_10BIT_ADC 730 // select
#else
#define RIGHT_10BIT_ADC 0 // right
#define UP_10BIT_ADC 130 // up
#define DOWN_10BIT_ADC 305 // down
#define LEFT_10BIT_ADC 480 // left
#define SELECT_10BIT_ADC 720 // select
#endif
#define SENSING_WINDOW 50 // button sensing window
#define DEBOUNCE_DELAY 20 // Debounce delay for SELECT/UP/DOWN/LEFT/RIGHT
//return values for ReadButtons()
#define BUTTON_NONE 0 //
#define BUTTON_RIGHT 1 //
#define BUTTON_UP 2 //
#define BUTTON_DOWN 3 //
#define BUTTON_LEFT 4 //
#define BUTTON_SELECT 5 //
class keypad
{
public:
//keypad();
uint8_t ReadKey();
bool RstReadKey();
bool buttonJustPressed = false; //this will be true after a ReadButtons() call if triggered
bool buttonJustReleased = false; //this will be true after a ReadButtons() call if triggered
bool rstbuttonJustPressed = false; //this will be true after a ReadButtons() call if triggered
bool rstbuttonJustReleased = false; //this will be true after a ReadButtons() call if triggered
bool rstbuttonLongPress = false;
private:
uint8_t buttonWas = BUTTON_NONE; //used by ReadButtons() for detection of button events
bool rstbuttonWas = true;
long Dtime = 0;
long rstDtime = 0;
bool rststate = true;
uint8_t prev_instant_button = BUTTON_NONE;
uint8_t apply_debounce(uint8_t BUTTON_INPUT, uint8_t button);
};
class stepMOTOR
{
public:
void speed(int speed_m1);
void setDirection(bool dir);
void enable();
void disable();
void step();
void stop();
uint8_t address;
void begin(uint8_t _address);
bool running;
bool direction;
private:
};
#endif
| 31.406977 | 103 | 0.604961 |
8b13cc7d294388d5c5d43c7dc5db60518dd582a4 | 2,085 | c | C | main.c | Lounarok/va_args-count-check-zero | 59fd1fa22533859a3da01753129ade6b6db2cbc1 | [
"MIT"
] | null | null | null | main.c | Lounarok/va_args-count-check-zero | 59fd1fa22533859a3da01753129ade6b6db2cbc1 | [
"MIT"
] | null | null | null | main.c | Lounarok/va_args-count-check-zero | 59fd1fa22533859a3da01753129ade6b6db2cbc1 | [
"MIT"
] | null | null | null | #include <stdio.h>
#include <stdarg.h>
#define PP_NARG(...) \
PP_NARG_(__VA_ARGS__,PP_RSEQ_N())
#define PP_NARG_(...) \
PP_128TH_ARG(__VA_ARGS__)
#define PP_128TH_ARG( \
_1, _2, _3, _4, _5, _6, _7, _8, _9,_10, \
_11,_12,_13,_14,_15,_16,_17,_18,_19,_20, \
_21,_22,_23,_24,_25,_26,_27,_28,_29,_30, \
_31,_32,_33,_34,_35,_36,_37,_38,_39,_40, \
_41,_42,_43,_44,_45,_46,_47,_48,_49,_50, \
_51,_52,_53,_54,_55,_56,_57,_58,_59,_60, \
_61,_62,_63,_64,_65,_66,_67,_68,_69,_70, \
_71,_72,_73,_74,_75,_76,_77,_78,_79,_80, \
_81,_82,_83,_84,_85,_86,_87,_88,_89,_90, \
_91,_92,_93,_94,_95,_96,_97,_98,_99,_100, \
_101,_102,_103,_104,_105,_106,_107,_108,_109,_110, \
_111,_112,_113,_114,_115,_116,_117,_118,_119,_120, \
_121,_122,_123,_124,_125,_126,_127,N,...) N
#define PP_RSEQ_N() \
127,126,125,124,123,122,121,120, \
119,118,117,116,115,114,113,112,111,110, \
109,108,107,106,105,104,103,102,101,100, \
99,98,97,96,95,94,93,92,91,90, \
89,88,87,86,85,84,83,82,81,80, \
79,78,77,76,75,74,73,72,71,70, \
69,68,67,66,65,64,63,62,61,60, \
59,58,57,56,55,54,53,52,51,50, \
49,48,47,46,45,44,43,42,41,40, \
39,38,37,36,35,34,33,32,31,30, \
29,28,27,26,25,24,23,22,21,20, \
19,18,17,16,15,14,13,12,11,10, \
9,8,7,6,5,4,3,2,1,0
void _variad(const char* fmt, size_t argc, ...) {
va_list ap;
va_start(ap, argc);
printf("Total count %ld\n", argc);
for (int i = 1; i < argc; i++) {
printf(" %s %d ", fmt, va_arg(ap, int));
}
printf("\n");
va_end(ap);
}
void _variad_no_args(const char* fmt){
printf("No arg\n");
}
// The double hashtags means if va args are zero0, then it will omit the ','
#define variad(fmt, ...) _variad( fmt, PP_NARG(__VA_ARGS__), ## __VA_ARGS__, 0)
int main(int argc, char* argv[]) {
variad("hi",2, "4", 6, 8, 10); // print all arg
variad("ho"); // print no arg
return 0;
} | 34.180328 | 79 | 0.560671 |
12a804c3c539d34fda052a8d3e65aa7d7fb9f465 | 822 | h | C | include/il2cpp/Pml/Local/RandomGenerator.h | martmists-gh/BDSP | d6326c5d3ad9697ea65269ed47aa0b63abac2a0a | [
"MIT"
] | 1 | 2022-01-15T20:20:27.000Z | 2022-01-15T20:20:27.000Z | include/il2cpp/Pml/Local/RandomGenerator.h | martmists-gh/BDSP | d6326c5d3ad9697ea65269ed47aa0b63abac2a0a | [
"MIT"
] | null | null | null | include/il2cpp/Pml/Local/RandomGenerator.h | martmists-gh/BDSP | d6326c5d3ad9697ea65269ed47aa0b63abac2a0a | [
"MIT"
] | null | null | null | #pragma once
#include "il2cpp.h"
void Pml_Local_RandomGenerator__Initialize (Pml_Local_RandomGenerator_o* __this, const MethodInfo* method_info);
void Pml_Local_RandomGenerator__Initialize (Pml_Local_RandomGenerator_o* __this, uint64_t seed, const MethodInfo* method_info);
uint64_t Pml_Local_RandomGenerator__GetSeed (Pml_Local_RandomGenerator_o* __this, const MethodInfo* method_info);
uint64_t Pml_Local_RandomGenerator__GenerateSeed (const MethodInfo* method_info);
uint32_t Pml_Local_RandomGenerator__GetRand (Pml_Local_RandomGenerator_o* __this, const MethodInfo* method_info);
uint32_t Pml_Local_RandomGenerator__GetRand (Pml_Local_RandomGenerator_o* __this, uint32_t max, const MethodInfo* method_info);
void Pml_Local_RandomGenerator___ctor (Pml_Local_RandomGenerator_o* __this, const MethodInfo* method_info);
| 68.5 | 127 | 0.873479 |
3fdf175191d9b361b169b0af7b84528b511b9a7b | 6,468 | h | C | tgfx/src/gpu/Surface.h | cy-j/libpag | 9b1636a0a67ad5e009d60c6c348034790d247692 | [
"BSL-1.0",
"CC0-1.0",
"MIT"
] | 2 | 2022-02-26T16:10:30.000Z | 2022-03-18T01:28:40.000Z | tgfx/src/gpu/Surface.h | cy-j/libpag | 9b1636a0a67ad5e009d60c6c348034790d247692 | [
"BSL-1.0",
"CC0-1.0",
"MIT"
] | null | null | null | tgfx/src/gpu/Surface.h | cy-j/libpag | 9b1636a0a67ad5e009d60c6c348034790d247692 | [
"BSL-1.0",
"CC0-1.0",
"MIT"
] | null | null | null | /////////////////////////////////////////////////////////////////////////////////////////////////
//
// Tencent is pleased to support the open source community by making libpag available.
//
// Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// unless required by applicable law or agreed to in writing, software distributed under the
// license is distributed on an "as is" basis, without warranties or conditions of any kind,
// either express or implied. see the license for the specific language governing permissions
// and limitations under the license.
//
/////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "core/Canvas.h"
#include "image/ImageInfo.h"
#include "pag/gpu.h"
#include "pag/types.h"
namespace pag {
/**
* Describes options of a given Surface. The caller can add some custom options to its subclass and
* parse them during drawing, which can sometimes optimize the rendering performance (e.g. disabling
* an expensive feature).
*/
class SurfaceOptions {
public:
virtual ~SurfaceOptions() = default;
};
class Canvas;
class Context;
class Texture;
/**
* Surface is responsible for managing the pixels that a canvas draws into. Surface takes care of
* allocating a Canvas that will draw into the surface. Call surface->getCanvas() to use that
* canvas (but don't delete it, it is owned by the surface). Surface always has non-zero dimensions.
* If there is a request for a new surface, and either of the requested dimensions are zero,
* then nullptr will be returned.
*/
class Surface {
public:
/**
* Creates a new Surface on GPU indicated by context. Allocates memory for pixels, based on the
* width, height and color type (alphaOnly). Return nullptr if alphaOnly is not supported or the
* size is zero.
*/
static std::shared_ptr<Surface> Make(Context* context, int width, int height,
bool alphaOnly = false, int sampleCount = 1);
/**
* Wraps a backed render target into Surface. Caller must ensure renderTarget is valid for the
* lifetime of returned Surface.
*/
static std::shared_ptr<Surface> MakeFrom(Context* context,
const BackendRenderTarget& renderTarget,
ImageOrigin origin);
/**
* Wraps a backed texture into Surface. Caller must ensure backendTexture is valid for the
* lifetime of returned Surface.
*/
static std::shared_ptr<Surface> MakeFrom(Context* context, const BackendTexture& backendTexture,
ImageOrigin origin);
explicit Surface(Context* context);
virtual ~Surface() = default;
/**
* Retrieves the context associated with this Surface.
*/
Context* getContext() const {
return context;
}
/**
* Returns SurfaceOptions for this surface.
*/
const SurfaceOptions* options() const {
return surfaceOptions.get();
}
/**
* Sets the options property for this surface.
*/
void setOptions(std::unique_ptr<SurfaceOptions> newOptions) {
surfaceOptions = std::move(newOptions);
}
/**
* Returns the width of this surface.
*/
virtual int width() const = 0;
/**
* Returns the height of this surface.
*/
virtual int height() const = 0;
/**
* Returns the origin of this surface, either ImageOrigin::TopLeft or ImageOrigin::BottomLeft.
*/
virtual ImageOrigin origin() const = 0;
/**
* Retrieves the texture which Surface renders onto. Return nullptr if Surface was made from a
* BackendRenderTarget.
*/
virtual std::shared_ptr<Texture> getTexture() const = 0;
/**
* Returns Canvas that draws into Surface. Subsequent calls return the same Canvas. Canvas
* returned is managed and owned by Surface, and is deleted when Surface is deleted.
*/
virtual Canvas* getCanvas() = 0;
/**
* Inserts a GPU semaphore that the current GPU-backed API must wait on before executing any more
* commands on the GPU for this surface. Surface will take ownership of the underlying semaphore
* and delete it once it has been signaled and waited on. If this call returns false, then the
* GPU back-end will not wait on the passed semaphore, and the client will still own the
* semaphore. Returns true if GPU is waiting on the semaphore.
*/
virtual bool wait(const BackendSemaphore& waitSemaphore) = 0;
/**
* Apply all pending changes to the render target immediately. After issuing all commands, the
* semaphore will be signaled by the GPU. If the signalSemaphore is not null and uninitialized,
* a new semaphore is created and initializes BackendSemaphore. The caller must delete the
* semaphore returned in signalSemaphore. BackendSemaphore can be deleted as soon as this function
* returns. If the back-end API is OpenGL only uninitialized backend semaphores are supported.
* If false is returned, the GPU back-end did not create or add a semaphore to signal on the GPU;
* the caller should not instruct the GPU to wait on the semaphore.
*/
virtual bool flush(BackendSemaphore* signalSemaphore) = 0;
/**
* Apply all pending changes to the render target immediately.
*/
void flush() {
flush(nullptr);
}
/**
* Copies a rect of pixels to dstPixels with specified ImageInfo. Copy starts at (srcX, srcY), and
* does not exceed Surface (width(), height()). Pixels are copied only if pixel conversion is
* possible. Returns true if pixels are copied to dstPixels.
*/
bool readPixels(const ImageInfo& dstInfo, void* dstPixels, int srcX = 0, int srcY = 0) const;
/**
* Evaluates the Surface to see if it overlaps or intersects with the specified point. The point
* is in the coordinate space of the Surface. This method always checks against the actual pixels
* of the Surface.
*/
bool hitTest(float x, float y) const;
protected:
virtual bool onReadPixels(const ImageInfo& dstInfo, void* dstPixels, int srcX,
int srcY) const = 0;
private:
Context* context = nullptr;
std::unique_ptr<SurfaceOptions> surfaceOptions = nullptr;
};
} // namespace pag | 36.75 | 100 | 0.678262 |
8f0429d4b79f698d5c0e77117a75a3210f49c34b | 1,157 | c | C | linux-lts-quantal-3.5.0/arch/arm/mach-prima2/prima2.c | huhong789/shortcut | bce8a64c4d99b3dca72ffa0a04c9f3485cbab13a | [
"BSD-2-Clause"
] | 47 | 2015-03-10T23:21:52.000Z | 2022-02-17T01:04:14.000Z | linux-lts-quantal-3.5.0/arch/arm/mach-prima2/prima2.c | shortcut-sosp19/shortcut | f0ff3d9170dbc6de38e0d8c200db056aa26b9c48 | [
"BSD-2-Clause"
] | 1 | 2020-06-30T18:01:37.000Z | 2020-06-30T18:01:37.000Z | linux-lts-quantal-3.5.0/arch/arm/mach-prima2/prima2.c | shortcut-sosp19/shortcut | f0ff3d9170dbc6de38e0d8c200db056aa26b9c48 | [
"BSD-2-Clause"
] | 19 | 2015-02-25T19:50:05.000Z | 2021-10-05T14:35:54.000Z | /*
* Defines machines for CSR SiRFprimaII
*
* Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company.
*
* Licensed under GPLv2 or later.
*/
#include <linux/init.h>
#include <linux/kernel.h>
#include <asm/sizes.h>
#include <asm/mach-types.h>
#include <asm/mach/arch.h>
#include <linux/of.h>
#include <linux/of_platform.h>
#include "common.h"
static struct of_device_id sirfsoc_of_bus_ids[] __initdata = {
{ .compatible = "simple-bus", },
{},
};
void __init sirfsoc_mach_init(void)
{
of_platform_bus_probe(NULL, sirfsoc_of_bus_ids, NULL);
}
void __init sirfsoc_init_late(void)
{
sirfsoc_pm_init();
}
static const char *prima2cb_dt_match[] __initdata = {
"sirf,prima2-cb",
NULL
};
MACHINE_START(PRIMA2_EVB, "prima2cb")
/* Maintainer: Barry Song <baohua.song@csr.com> */
.atag_offset = 0x100,
.init_early = sirfsoc_of_clk_init,
.map_io = sirfsoc_map_lluart,
.init_irq = sirfsoc_of_irq_init,
.timer = &sirfsoc_timer,
.dma_zone_size = SZ_256M,
.init_machine = sirfsoc_mach_init,
.init_late = sirfsoc_init_late,
.dt_compat = prima2cb_dt_match,
.restart = sirfsoc_restart,
MACHINE_END
| 22.686275 | 79 | 0.716508 |
acc55a6556fa092bfe798f3ab5226bb3121cceb8 | 4,939 | h | C | AppleMediaServices.framework/AMSMetrics.h | reels-research/iOS-Private-Frameworks | 9a4f4534939310a51fdbf5a439dd22487efb0f01 | [
"MIT"
] | 4 | 2021-10-06T12:15:26.000Z | 2022-02-21T02:26:00.000Z | AppleMediaServices.framework/AMSMetrics.h | reels-research/iOS-Private-Frameworks | 9a4f4534939310a51fdbf5a439dd22487efb0f01 | [
"MIT"
] | null | null | null | AppleMediaServices.framework/AMSMetrics.h | reels-research/iOS-Private-Frameworks | 9a4f4534939310a51fdbf5a439dd22487efb0f01 | [
"MIT"
] | 1 | 2021-10-08T07:40:53.000Z | 2021-10-08T07:40:53.000Z | /* Generated by RuntimeBrowser
Image: /System/Library/PrivateFrameworks/AppleMediaServices.framework/AppleMediaServices
*/
@interface AMSMetrics : NSObject {
AMSURLSession * _URLSession;
<AMSMetricsBagContract> * _bagContract;
NSMutableSet * _chainedFlushPromises;
NSObject<OS_dispatch_queue> * _completionQueue;
NSString * _containerId;
AMSMetricsDatabase * _database;
bool _disableFlushing;
bool _flushCancelled;
bool _flushOnForeground;
id /* block */ _flushTimerBlock;
NSDictionary * _lastMetricsDictionary;
long long _maxBatchSize;
long long _maxRequestCount;
NSObject<OS_dispatch_queue> * _metricsQueue;
bool _monitorsLifecycleEvents;
NSObject<OS_dispatch_queue> * _propertyQueue;
NSMutableSet * _requestPromises;
}
@property (nonatomic, retain) AMSURLSession *URLSession;
@property (nonatomic, retain) <AMSMetricsBagContract> *bagContract;
@property (nonatomic, retain) NSMutableSet *chainedFlushPromises;
@property (nonatomic, retain) NSObject<OS_dispatch_queue> *completionQueue;
@property (nonatomic, readonly) NSString *containerId;
@property (nonatomic, retain) AMSMetricsDatabase *database;
@property (nonatomic) bool disableFlushing;
@property (nonatomic, readonly) long long eventCount;
@property (nonatomic) bool flushCancelled;
@property (nonatomic, readonly) double flushInterval;
@property (nonatomic) bool flushOnForeground;
@property (nonatomic, copy) id /* block */ flushTimerBlock;
@property (nonatomic) bool flushTimerEnabled;
@property (nonatomic, retain) NSDictionary *lastMetricsDictionary;
@property (nonatomic) long long maxBatchSize;
@property (nonatomic) long long maxRequestCount;
@property (nonatomic, retain) NSObject<OS_dispatch_queue> *metricsQueue;
@property (nonatomic) bool monitorsLifecycleEvents;
@property (nonatomic, retain) NSObject<OS_dispatch_queue> *propertyQueue;
@property (nonatomic, retain) NSMutableSet *requestPromises;
+ (id)_sharedInstanceUsingContract:(id)arg1;
+ (id)_sharedTimerQueue;
+ (bool)disableBackgroundMetrics;
+ (bool)flushTimerEnabled;
+ (id)serverTimeFromDate:(id)arg1;
+ (id)serverTimeFromTimeInterval:(double)arg1;
+ (void)setDisableBackgroundMetrics:(bool)arg1;
+ (void)setFlushTimerEnabled:(bool)arg1;
+ (double)timeIntervalFromServerTime:(id)arg1;
- (void).cxx_destruct;
- (id)URLSession;
- (void)_addCancellablePromise:(id)arg1;
- (void)_applicationWillEnterForeground;
- (id)_baseMetricsURL;
- (void)_batchEventArray:(id)arg1 batchBlock:(id /* block */)arg2;
- (id)_createRequestWithURL:(id)arg1 canary:(id)arg2 account:(id)arg3 body:(id)arg4 signature:(id)arg5 logKey:(id)arg6 collectAdditonalMetrics:(bool)arg7;
- (void)_flushDatabaseMetricsWithLockKey:(id)arg1 logKey:(id)arg2 completion:(id /* block */)arg3;
- (void)_flushNextBatchWithTopic:(id)arg1 lockKey:(id)arg2 logKey:(id)arg3 requestCount:(long long)arg4 flushedEventCount:(long long)arg5 completion:(id /* block */)arg6;
- (void)_flushTimerInvalidate;
- (void)_flushTimerStart;
- (void)_flushTimerUpdated;
- (void)_handleFlushTimer;
- (id)_mescalSignatureWithBodyData:(id)arg1 logKey:(id)arg2;
- (id)_metricsDictionary;
- (id)_nextBatchWithTopic:(id)arg1 lockKey:(id)arg2 error:(id*)arg3;
- (id)_nextTopicWithLockKey:(id)arg1 error:(id*)arg2;
- (void)_openDatabaseIfNeeded;
- (void)_postEvents:(id)arg1 reportURL:(id)arg2 account:(id)arg3 logKey:(id)arg4 completion:(id /* block */)arg5;
- (id)_prepareEvent:(id)arg1;
- (bool)_shouldBlacklistEvent:(id)arg1;
- (bool)_shouldClearEventsDespiteError:(id)arg1 result:(id)arg2;
- (id)bagContract;
- (void)cancel;
- (id)chainedFlushPromises;
- (id)completionQueue;
- (id)containerId;
- (id)database;
- (void)dealloc;
- (bool)disableFlushing;
- (void)dropEvents;
- (id)enqueueAsyncEvents:(id)arg1;
- (void)enqueueEvent:(id)arg1;
- (void)enqueueEvents:(id)arg1;
- (long long)eventCount;
- (id)flush;
- (bool)flushCancelled;
- (id)flushEvents:(id)arg1;
- (double)flushInterval;
- (bool)flushOnForeground;
- (id /* block */)flushTimerBlock;
- (bool)flushTimerEnabled;
- (id)initWithContainerId:(id)arg1 bagContract:(id)arg2;
- (id)lastMetricsDictionary;
- (long long)maxBatchSize;
- (long long)maxRequestCount;
- (id)metricsQueue;
- (bool)monitorsLifecycleEvents;
- (id)propertyQueue;
- (id)requestPromises;
- (void)setBagContract:(id)arg1;
- (void)setChainedFlushPromises:(id)arg1;
- (void)setCompletionQueue:(id)arg1;
- (void)setDatabase:(id)arg1;
- (void)setDisableFlushing:(bool)arg1;
- (void)setFlushCancelled:(bool)arg1;
- (void)setFlushOnForeground:(bool)arg1;
- (void)setFlushTimerBlock:(id /* block */)arg1;
- (void)setFlushTimerEnabled:(bool)arg1;
- (void)setLastMetricsDictionary:(id)arg1;
- (void)setMaxBatchSize:(long long)arg1;
- (void)setMaxRequestCount:(long long)arg1;
- (void)setMetricsQueue:(id)arg1;
- (void)setMonitorsLifecycleEvents:(bool)arg1;
- (void)setPropertyQueue:(id)arg1;
- (void)setRequestPromises:(id)arg1;
- (void)setURLSession:(id)arg1;
@end
| 39.512 | 170 | 0.769184 |
5fb7f4e12a1fa3c17382efdd2b8b6efc3a606b97 | 1,414 | h | C | vector.h | tristanred/micros | 512d879e871d89b62f3dd916b5fda5328b7c24b1 | [
"MIT"
] | 4 | 2018-08-13T18:37:03.000Z | 2022-02-04T18:13:34.000Z | vector.h | kratosaurion7/micros | 512d879e871d89b62f3dd916b5fda5328b7c24b1 | [
"MIT"
] | 11 | 2017-04-05T21:59:45.000Z | 2017-06-01T03:02:51.000Z | vector.h | kratosaurion7/micros | 512d879e871d89b62f3dd916b5fda5328b7c24b1 | [
"MIT"
] | 1 | 2021-08-08T21:06:19.000Z | 2021-08-08T21:06:19.000Z | #ifndef vector_h
#define vector_h
#include <stdint.h>
#include <stddef.h>
#include "types.h"
// Kernel vector structure. This structure uses the kernel heap to allocate
// memory. Can ONLY be used in kernel mode.
// Can technically stack allocate data but the struct will use the heap when
// resizing the vector.
struct vector {
size_t size; // Size of the array's memory
size_t count; // Count of the elements in the array
uint32_t* dataElements;
};
// Vector public interface
struct vector* vector_create();
struct vector* vector_create_size(size_t size);
// This sets up a local vector BUT this does not create the array to store
// elements. So the first allocation will cause a resize. TODO : Need to handle
// that case.
void vector_setup(struct vector* vec);
void vector_add(struct vector* vec, void* element);
void vector_insert(struct vector* vec, size_t index, void* element);
void vector_remove(struct vector* vec, void* element);
void vector_remove_at(struct vector* vec, size_t index);
void* vector_get_at(struct vector* vec,size_t index);
void** vector_get_array(struct vector* vec, int* count);
BOOL vector_exists(struct vector* vec, void* element);
// Vector management methods
void vector_resize(struct vector* vec, size_t newSize);
void vector_shift_left(struct vector* vec, size_t startIndex);
void vector_shift_right(struct vector* vec, size_t startIndex);
#endif
| 30.085106 | 79 | 0.75884 |
5fec5575e96dd1080835f6b8c050fce35c46ae2e | 876 | h | C | aoc2019/include/utils.h | madfist/aoc2016 | 1e79c39506dd2cb5f4533c375f59005f5668cb93 | [
"MIT"
] | 1 | 2019-12-06T09:39:48.000Z | 2019-12-06T09:39:48.000Z | aoc2019/include/utils.h | madfist/aoc2016 | 1e79c39506dd2cb5f4533c375f59005f5668cb93 | [
"MIT"
] | null | null | null | aoc2019/include/utils.h | madfist/aoc2016 | 1e79c39506dd2cb5f4533c375f59005f5668cb93 | [
"MIT"
] | null | null | null | #include <iostream>
#include <vector>
#include <deque>
template<typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, const std::pair<T1,T2>& s) {
return os << s.first << ' ' << s.second;
}
std::ostream& operator<<(std::ostream& os, const std::vector<char> v) {
for (auto i = v.begin(); i != v.end(); ++i) {
os << static_cast<int>(*i);
if (i != v.end() - 1) {
os << ' ';
}
}
return os;
}
template<typename T>
std::ostream& operator<<(std::ostream& os, const std::vector<T> v) {
for (auto i = v.begin(); i != v.end(); ++i) {
os << *i;
if (i != v.end() - 1) {
os << ' ';
}
}
return os;
}
template<typename T>
std::ostream& operator<<(std::ostream& os, const std::deque<T> v) {
for (auto i = v.begin(); i != v.end(); ++i) {
os << *i;
if (i != v.end() - 1) {
os << ' ';
}
}
return os;
}
| 21.365854 | 71 | 0.510274 |
b1d709f01ba6f8c34aa2e8a0d75b2e2474be2f6b | 322 | c | C | test/simple-get-set.c | sphia/sphia | 506d0145ff87b030fa97123c53884ab6d7d58428 | [
"MIT"
] | 120 | 2015-01-30T14:20:53.000Z | 2021-05-27T01:50:54.000Z | test/simple-get-set.c | sphia/sphia | 506d0145ff87b030fa97123c53884ab6d7d58428 | [
"MIT"
] | 5 | 2015-01-07T11:33:05.000Z | 2015-12-22T16:50:30.000Z | test/simple-get-set.c | sphia/sphia | 506d0145ff87b030fa97123c53884ab6d7d58428 | [
"MIT"
] | 10 | 2015-01-07T16:06:44.000Z | 2017-01-03T01:44:03.000Z |
#include <stdlib.h>
#include "sphia-test.h"
static void
test_set_get() {
char key[] = "test-set-key";
char value[] = "test-set-value";
int rc = sphia_set(sphia, key, value);
assert(-1 != rc);
char *actual = sphia_get(sphia, key);
assert(0 == strncmp(actual, value, strlen(actual)));
}
TEST(test_set_get);
| 17.888889 | 54 | 0.642857 |
38ad7be7959a43fc75147346ee2754fb09369e2c | 482 | h | C | ATAuthSDK_D/YTXMonitor.framework/Headers/ACMMonitor.h | CaiChenghan/ATAuthSDK_D | 8ea1c3b21cbb943e982873770ae048d35d355d7b | [
"MIT"
] | 1 | 2021-01-06T03:12:15.000Z | 2021-01-06T03:12:15.000Z | ATAuthSDK_D/YTXMonitor.framework/Headers/ACMMonitor.h | CaiChenghan/ATAuthSDK_D | 8ea1c3b21cbb943e982873770ae048d35d355d7b | [
"MIT"
] | 2 | 2021-08-19T05:51:46.000Z | 2022-03-04T03:42:59.000Z | ATAuthSDK_D/YTXMonitor.framework/Headers/ACMMonitor.h | CaiChenghan/ATAuthSDK_D | 8ea1c3b21cbb943e982873770ae048d35d355d7b | [
"MIT"
] | 1 | 2020-11-06T03:53:47.000Z | 2020-11-06T03:53:47.000Z | //
// ACMMonitor.h
// Monitor
//
// Created by Vienta on 2019/11/13.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface ACMMonitor : NSObject
/**
* 上传非实时埋点
* @param obj 埋点内容
* @return 埋点存储结果
*/
+ (BOOL)monitorRecord:(id)obj;
/**
* 上传实时埋点
* @param obj 埋点内容
* @return 埋点上传准备结果
*/
+ (BOOL)monitorRealtimeRecord:(id)obj;
/**
* 开始手动上传,在设置uploadType为ACMMonitorUploadManual时生效
*/
+ (void)uploadMonitorByManual;
@end
NS_ASSUME_NONNULL_END
| 13.388889 | 50 | 0.682573 |
21f6c82b7c9ab24d977fb2d5b470e309afad5232 | 4,384 | c | C | tests/unit/s2n_choose_supported_group_test.c | ilelann/s2n | 7d8228641f2d7dc2b9f1a84f3c230da92cdca65f | [
"Apache-2.0"
] | null | null | null | tests/unit/s2n_choose_supported_group_test.c | ilelann/s2n | 7d8228641f2d7dc2b9f1a84f3c230da92cdca65f | [
"Apache-2.0"
] | null | null | null | tests/unit/s2n_choose_supported_group_test.c | ilelann/s2n | 7d8228641f2d7dc2b9f1a84f3c230da92cdca65f | [
"Apache-2.0"
] | null | null | null | /*
* Copyright Amazon.com, Inc. or its affiliates. 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.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file 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 "s2n_test.h"
#include "testlib/s2n_testlib.h"
#include "tls/s2n_tls.h"
#include "tls/s2n_tls13.h"
#include "tls/extensions/s2n_client_supported_groups.h"
#include "tls/s2n_security_policies.h"
int main(int argc, char **argv)
{
struct s2n_connection *server_conn;
BEGIN_TEST();
/* This test checks the logic in the function s2n_choose_supported_group, which should select the highest
* supported group or, if none are available, select NULL.
*/
{
/* If the list of mutually supported groups is empty, chosen curve should be set to null */
EXPECT_NOT_NULL(server_conn = s2n_connection_new(S2N_SERVER));
EXPECT_NULL(server_conn->secure.server_ecc_evp_params.negotiated_curve);
EXPECT_NOT_NULL(server_conn->config);
const struct s2n_security_policy *security_policy = NULL;
const struct s2n_ecc_preferences *ecc_pref = NULL;
EXPECT_SUCCESS(s2n_connection_get_security_policy(server_conn, &security_policy));
EXPECT_NOT_NULL(security_policy);
EXPECT_NOT_NULL(ecc_pref = security_policy->ecc_preferences);
for (int i = 0; i < ecc_pref->count; i++) {
EXPECT_NULL(server_conn->secure.mutually_supported_groups[i]);
}
EXPECT_FAILURE_WITH_ERRNO(s2n_choose_supported_group(server_conn, server_conn->secure.mutually_supported_groups,
&server_conn->secure.server_ecc_evp_params), S2N_ERR_ECDHE_UNSUPPORTED_CURVE);
EXPECT_NULL(server_conn->secure.server_ecc_evp_params.negotiated_curve);
EXPECT_SUCCESS(s2n_connection_free(server_conn));
}
{
/* If the list of mutually supported groups has one match, chosen curve should be set to that
* match.
*/
EXPECT_NOT_NULL(server_conn = s2n_connection_new(S2N_SERVER));
const struct s2n_security_policy *security_policy = NULL;
const struct s2n_ecc_preferences *ecc_pref = NULL;
EXPECT_SUCCESS(s2n_connection_get_security_policy(server_conn, &security_policy));
EXPECT_NOT_NULL(security_policy);
EXPECT_NOT_NULL(ecc_pref = security_policy->ecc_preferences);
EXPECT_NULL(server_conn->secure.server_ecc_evp_params.negotiated_curve);
server_conn->secure.mutually_supported_groups[1] = ecc_pref->ecc_curves[1];
EXPECT_SUCCESS(s2n_choose_supported_group(server_conn, server_conn->secure.mutually_supported_groups,
&server_conn->secure.server_ecc_evp_params));
EXPECT_EQUAL(server_conn->secure.server_ecc_evp_params.negotiated_curve, ecc_pref->ecc_curves[1]);
EXPECT_SUCCESS(s2n_connection_free(server_conn));
}
{
/* If the list of mutually supported groups has several matches, chosen curve should be set to the first
* match.
*/
EXPECT_NOT_NULL(server_conn = s2n_connection_new(S2N_SERVER));
EXPECT_NULL(server_conn->secure.server_ecc_evp_params.negotiated_curve);
const struct s2n_security_policy *security_policy = NULL;
const struct s2n_ecc_preferences *ecc_pref = NULL;
EXPECT_SUCCESS(s2n_connection_get_security_policy(server_conn, &security_policy));
EXPECT_NOT_NULL(security_policy);
EXPECT_NOT_NULL(ecc_pref = security_policy->ecc_preferences);
for (int i = 0; i < ecc_pref->count; i++) {
server_conn->secure.mutually_supported_groups[i] = ecc_pref->ecc_curves[i];
}
EXPECT_SUCCESS(s2n_choose_supported_group(server_conn, server_conn->secure.mutually_supported_groups,
&server_conn->secure.server_ecc_evp_params));
EXPECT_EQUAL(server_conn->secure.server_ecc_evp_params.negotiated_curve, ecc_pref->ecc_curves[0]);
EXPECT_SUCCESS(s2n_connection_free(server_conn));
}
END_TEST();
return 0;
}
| 41.752381 | 120 | 0.726505 |
592e6f9a1d2a7f53a390a6c3b680e4646f562152 | 801 | h | C | PrivateFrameworks/iWorkImport.framework/TSUNSProgressObserver.h | shaojiankui/iOS10-Runtime-Headers | 6b0d842bed0c52c2a7c1464087b3081af7e10c43 | [
"MIT"
] | 36 | 2016-04-20T04:19:04.000Z | 2018-10-08T04:12:25.000Z | PrivateFrameworks/iWorkImport.framework/TSUNSProgressObserver.h | shaojiankui/iOS10-Runtime-Headers | 6b0d842bed0c52c2a7c1464087b3081af7e10c43 | [
"MIT"
] | null | null | null | PrivateFrameworks/iWorkImport.framework/TSUNSProgressObserver.h | shaojiankui/iOS10-Runtime-Headers | 6b0d842bed0c52c2a7c1464087b3081af7e10c43 | [
"MIT"
] | 10 | 2016-06-16T02:40:44.000Z | 2019-01-15T03:31:45.000Z | /* Generated by RuntimeBrowser
Image: /System/Library/PrivateFrameworks/iWorkImport.framework/iWorkImport
*/
@interface TSUNSProgressObserver : NSObject {
TSUBasicProgress * _basicProgress;
double _basicProgressMaxValue;
bool _didStart;
NSProgress * _nsProgress;
TSUProgressContext * _progressContext;
}
+ (id)observerForNSProgress:(id)arg1 reportingToBasicProgress:(id)arg2 maxValue:(double)arg3;
+ (id)observerForNSProgress:(id)arg1 reportingToProgressContext:(id)arg2;
- (void).cxx_destruct;
- (void)dealloc;
- (id)init;
- (id)initWithNSProgress:(id)arg1 progressContext:(id)arg2 basicProgress:(id)arg3 basicProgressMaxValue:(double)arg4;
- (void)observeValueForKeyPath:(id)arg1 ofObject:(id)arg2 change:(id)arg3 context:(void*)arg4;
- (void)start;
- (void)stop;
@end
| 32.04 | 117 | 0.769039 |
0ec51d825e397a9af57d2dc9c56a2d15708f0409 | 185 | h | C | Kalman Filter - Map generation/params.h | juebrauer/Solutions-Exercises-MultimodalSensorSystems | b1f4bae5ce21d992ff740804af07b227d34f828b | [
"Unlicense"
] | 2 | 2021-06-15T11:50:21.000Z | 2022-01-05T15:52:06.000Z | Kalman Filter - Map generation/params.h | juebrauer/Solutions-Exercises-MultimodalSensorSystems | b1f4bae5ce21d992ff740804af07b227d34f828b | [
"Unlicense"
] | null | null | null | Kalman Filter - Map generation/params.h | juebrauer/Solutions-Exercises-MultimodalSensorSystems | b1f4bae5ce21d992ff740804af07b227d34f828b | [
"Unlicense"
] | 1 | 2021-05-23T19:10:54.000Z | 2021-05-23T19:10:54.000Z | #pragma once
// turn on or off continuous visualization here
#define VISUALIZATION true
// save occupancy grid & world images into files?
#define SAVE_VISUALIZATION_IMAGES false | 26.428571 | 50 | 0.778378 |
1dbb1a8e46a99f2361818833f5fcfe6d928ff4f6 | 7,241 | h | C | FreeRTOS/Demo/CORTEX_AT91SAM3U256_IAR/AT91Lib/peripherals/ac97c/ac97c.h | JVVJV/FreeRTOS | 2b956b97c76f48053e87b89df39afb2b9426eee5 | [
"MIT"
] | 2,603 | 2019-10-09T04:47:13.000Z | 2022-03-31T13:59:08.000Z | FreeRTOS/Demo/CORTEX_AT91SAM3U256_IAR/AT91Lib/peripherals/ac97c/ac97c.h | JVVJV/FreeRTOS | 2b956b97c76f48053e87b89df39afb2b9426eee5 | [
"MIT"
] | 296 | 2019-11-22T03:29:07.000Z | 2022-03-21T23:23:01.000Z | FreeRTOS/Demo/CORTEX_AT91SAM3U256_IAR/AT91Lib/peripherals/ac97c/ac97c.h | JVVJV/FreeRTOS | 2b956b97c76f48053e87b89df39afb2b9426eee5 | [
"MIT"
] | 1,040 | 2019-09-26T20:18:24.000Z | 2022-03-30T08:12:34.000Z | /* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2008, Atmel 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:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
* ----------------------------------------------------------------------------
*/
//------------------------------------------------------------------------------
/// \unit
///
/// !!!Purpose
///
/// This module provides definitions and functions for using the AC'97
/// controller (AC97C).
///
/// !!!Usage
///
/// -# Enable the AC'97 interface pins (see pio & board.h).
/// -# Configure the AC'97 controller using AC97C_Configure
/// -# Assign the input and output slots to channels, and the data size used to
/// transfer AC97 data stream.
/// - Three functions can be used:
/// - AC97C_AssignInputSlots: set slots for AC'97 data in, recording.
/// - AC97C_AssignOutputSlots: set slots for AC'97 data out, playing.
/// - AC97C_SetChannelSize: set data sizes in bits for AC'97 data stream.
/// - Three different channels can be configured:
/// - AC97C_CHANNEL_CODEC: AC'97 register access channel, its size is
/// fixed and #must not# change by AC97C_SetChannelSize
/// - AC97C_CHANNEL_A: AC'97 stream channel, with PDC support.
/// - AC97C_CHANNEL_B: AC'97 data channel, without PDC support.
/// -# Configure the used AC97 channel with AC97C_ConfigureChannel, to enable
/// the channel.
/// -# Then you can operate the connected AC'97 codec:
/// - AC97C_ReadCodec / AC97C_WriteCodec: Read / Write codec register.
/// - AC97C_Transfer: Transfer through AC97C channels to setup codec register
/// or transfer %audio data stream.
/// - AC97C_CODEC_TRANSFER: access the codec register.
/// - AC97C_CHANNEL_A_RECEIVE, AC97C_CHANNEL_B_RECEIVE: start reading.
/// - AC97C_CHANNEL_A_TRANSMIT, AC97C_CHANNEL_B_TRANSMIT: start writing.
/// Normally you can initialize a set of AC'97 codec registers to initialize
/// the codec for %audio playing and recording.
/// -# Example code for playing & recording:
/// - General process:
/// -# Configure the codec registers for the %audio settings and formats;
/// -# Setup the channel size if necessery;
/// -# Start %audio stream transfer.
/// - Audio playing sample:
/// \code
/// // Configure sample rate of codec
/// AC97C_WriteCodec(AD1981B_PMC_DAC, expectedSampleRate);
/// // Set channel size
/// AC97C_SetChannelSize(AC97C_CHANNEL_A, bitsPerSample);
/// // Start channel A transfer
/// AC97C_Transfer(AC97C_CHANNEL_A_TRANSMIT,
/// (unsigned char *) (pointerToAudioDataBuffer),
/// numberOfSamplesToSend,
/// (Ac97Callback) PlayingFinished,
/// 0);
/// \endcode
/// - Audio recording sample:
/// \code
/// // Enable recording
/// AC97C_WriteCodec(AD1981B_REC_SEL, 0);
/// // Set sample rate
/// AC97C_WriteCodec(AD1981B_PMC_ADC, 7000);
/// // Always use 16-bits recording
/// AC97C_SetChannelSize(AC97C_CHANNEL_A, 16);
/// // Start recording
/// AC97C_Transfer(AC97C_CHANNEL_A_RECEIVE,
/// (unsigned char *) RECORD_ADDRESS,
/// MAX_RECORD_SIZE,
/// (Ac97Callback) RecordFinished,
/// 0);
/// \endcode
//------------------------------------------------------------------------------
#ifndef AC97C_H
#define AC97C_H
//------------------------------------------------------------------------------
// Constants
//------------------------------------------------------------------------------
/// The channel is already busy with a transfer.
#define AC97C_ERROR_BUSY 1
/// The transfer has been stopped by the user.
#define AC97C_ERROR_STOPPED 2
/// Codec channel index.
#define AC97C_CHANNEL_CODEC 0
/// Channel A index.
#define AC97C_CHANNEL_A 1
/// Channel B index.
#define AC97C_CHANNEL_B 2
/// Codec transmit/receive transfer index.
#define AC97C_CODEC_TRANSFER 0
/// Channel A receive transfer index.
#define AC97C_CHANNEL_A_RECEIVE 1
/// Channel A transmit transfer index.
#define AC97C_CHANNEL_A_TRANSMIT 2
/// Channel B receive transfer index.
#define AC97C_CHANNEL_B_RECEIVE 3
/// Channel B transmit transfer index.
#define AC97C_CHANNEL_B_TRANSMIT 4
//------------------------------------------------------------------------------
// Types
//------------------------------------------------------------------------------
/// AC97C transfer callback function.
typedef void (*Ac97Callback)(void *pArg,
unsigned char status,
unsigned int remaining);
//------------------------------------------------------------------------------
// Exported functions
//------------------------------------------------------------------------------
extern void AC97C_Configure();
extern void AC97C_ConfigureChannel(unsigned char channel, unsigned int cfg);
extern void AC97C_AssignInputSlots(unsigned char channel, unsigned int slots);
extern void AC97C_AssignOutputSlots(unsigned char channel, unsigned int slots);
extern unsigned char AC97C_Transfer(
unsigned char channel,
unsigned char *pBuffer,
unsigned int numSamples,
Ac97Callback callback,
void *pArg);
extern unsigned char AC97C_IsFinished(unsigned char channel);
extern void AC97C_WriteCodec(unsigned char address, unsigned short data);
extern unsigned short AC97C_ReadCodec(unsigned char address);
extern void AC97C_SetChannelSize(unsigned char channel, unsigned char size);
extern void AC97C_CancelTransfer(unsigned char channel);
#endif //#ifndef AC97C_H
| 42.846154 | 81 | 0.587212 |
383138da79153695da5719ee0fd6380f8f7571ca | 274 | h | C | PirateHegemonyOnline/Classes/Home/HomeViewController.h | irons163/PirateHegemonyOnline | 42ececbf2bc9c249fcee8fb30e4bef170184cb57 | [
"MIT"
] | 5 | 2020-09-15T08:06:52.000Z | 2021-03-26T02:06:05.000Z | PirateHegemonyOnline/Classes/Home/HomeViewController.h | irons163/PirateHegemonyOnline | 42ececbf2bc9c249fcee8fb30e4bef170184cb57 | [
"MIT"
] | 2 | 2020-09-17T08:13:57.000Z | 2020-10-05T13:03:59.000Z | PirateHegemonyOnline/Classes/Home/HomeViewController.h | irons163/PirateHegemonyOnline | 42ececbf2bc9c249fcee8fb30e4bef170184cb57 | [
"MIT"
] | null | null | null | //
// HomeViewController.h
// PirateHegemonyOnline
//
// Created by irons on 2020/9/3.
// Copyright © 2020 irons163. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface HomeViewController : UIViewController
@end
NS_ASSUME_NONNULL_END
| 15.222222 | 51 | 0.751825 |
38332b9d37d1a3a32c78f0baa0c9d049644fd472 | 349 | h | C | Code/Shortcut.h | JaumeMontagut/CITM_3_GameEngine | 57a85b89a72723ce555a4eec3830e6bf00499de9 | [
"MIT"
] | 1 | 2020-07-09T00:38:40.000Z | 2020-07-09T00:38:40.000Z | Code/Shortcut.h | YessicaSD/CITM_3_GameEngine | 57a85b89a72723ce555a4eec3830e6bf00499de9 | [
"MIT"
] | null | null | null | Code/Shortcut.h | YessicaSD/CITM_3_GameEngine | 57a85b89a72723ce555a4eec3830e6bf00499de9 | [
"MIT"
] | null | null | null | #ifndef __SHORTCUT_H__
#define __SHORTCUT_H__
#include <vector>
#include <string>
#include "SDL/include/SDL_scancode.h"
class Shortcut
{
public:
Shortcut();
Shortcut(std::string name, std::vector<SDL_Scancode> keys);
bool Pressed();
bool Held();
public:
std::string name;
std::vector<SDL_Scancode> keys;
friend class ModuleGui;
};
#endif | 15.173913 | 60 | 0.73639 |
c03da5be98297b49ff13e896fb603a8964fab553 | 298 | h | C | AKLocationPickerExample/AKAppDelegate.h | zen4ever/AKLocationPicker | d41d7e00be5c602cddea17c9984be2c8ec3d18e6 | [
"MIT"
] | 2 | 2015-07-29T14:40:44.000Z | 2016-04-19T10:08:06.000Z | AKLocationPickerExample/AKAppDelegate.h | zen4ever/AKLocationPicker | d41d7e00be5c602cddea17c9984be2c8ec3d18e6 | [
"MIT"
] | null | null | null | AKLocationPickerExample/AKAppDelegate.h | zen4ever/AKLocationPicker | d41d7e00be5c602cddea17c9984be2c8ec3d18e6 | [
"MIT"
] | null | null | null | //
// AKAppDelegate.h
// AKLocationPicker
//
// Created by Andrew Kurinnyi on 10/8/13.
// Copyright (c) 2013 Andrew Kurinnyi. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface AKAppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@end
| 18.625 | 62 | 0.724832 |
35c4773465acbf8d9d0727929c79002d06eeb207 | 2,580 | c | C | lib/wizards/nalle/adventurers_hall.c | vlehtola/questmud | 8bc3099b5ad00a9e0261faeb6637c76b521b6dbe | [
"MIT"
] | null | null | null | lib/wizards/nalle/adventurers_hall.c | vlehtola/questmud | 8bc3099b5ad00a9e0261faeb6637c76b521b6dbe | [
"MIT"
] | null | null | null | lib/wizards/nalle/adventurers_hall.c | vlehtola/questmud | 8bc3099b5ad00a9e0261faeb6637c76b521b6dbe | [
"MIT"
] | null | null | null | inherit "room/room";
int i;
object board;
reset(status arg) {
if(arg) return;
short_desc = "Adventurers hall",
long_desc =
"The Adventurers hall deserves it's reputation as traveller's favorite\n"+
"resting place. A fireplace is warming the room. Staying here will certainly\n"+
"help you to recover faster.\n"+
"Available commands:\n\n"+
" 'lead' to try to lead a race.\n\n";
/*" 'quest pay' to halve the cost of the next level with quest points.\n"+
" 'quest cost' to see how many quest points halving the cost of next level
uses.\n\n";*/
add_exit("east", "/world/city/inn");
add_exit("south", "/obj/wish_room");
if(!i) {
call_out("tick", 12);
i = 1;
}
move_object(clone_object("/daemons/expplaque"), this_object());
move_object(clone_object("/daemons/vboard"), this_object());
set_not_out(1);
set_light(3);
property = allocate(4);
property[0] = "no_summon";
property[1] = "no_kill";
property[2] = "no_skill";
property[3] = "no_spell";
}
tick() {
object ob;
int i;
tell_room(this_object(), "The fireplace warms you comfortably.\n");
ob = all_inventory(this_object());
while(i<sizeof(ob)) {
if(ob[i]&&living(ob[i])) {
ob[i]->add_hp(40);
ob[i]->add_sp(40);
ob[i]->add_ep(40);
}
i += 1;
}
call_out("tick", 30);
}
init() {
::init();
add_action("lead", "lead");
/* add_action("quest", "quest"); */
add_action("south","south");
}
lead() {
call_other("/daemons/leader_d","new_leader");
return 1;
}
quest(str) {
int num,cost;
if (str == "pay") {
num = this_player()->query_level() + 1;
if (this_player()->query_level_advance()) {
write("You are all ready advancing a level.\n");
return 1;
}
if (this_player()->query_level_paid()) {
write("You already have payed for this level.\n");
return 1;
}
cost = num / 4 + 1;
if (this_player()->query_quest_points() < cost) {
write("You don't have enough quest points.\n");
return 1;
}
this_player()->reduce_quest_points(cost);
this_player()->set_level_paid(1);
write("You pay for level "+num+" with "+cost+" quest points.\n");
return 1;
}
if (str == "cost") {
num = this_player()->query_level() + 1;
cost = num / 4 + 1;
write(
"Halving the experience cost of level costs "+cost+" quest points.\n");
write(
"You have "+this_player()->query_quest_points()+" quest points.\n");
return 1;
}
write("Use 'quest pay' or 'quest cost'.\n");
return 1;
}
south() {
if (this_player()->query_level() < 10) {
write("You have to be atleast level 10 to enter that place.\n");
return 1;
}
}
| 23.454545 | 80 | 0.627907 |
0d4dba7f4b7fac38a1778ef6657cf7d0e389adf3 | 8,856 | h | C | sample3.h | TheMrCerebro/irrBM | b2733fab58fd1f7b1a6a9381f0ec107e32c97bc1 | [
"Zlib"
] | null | null | null | sample3.h | TheMrCerebro/irrBM | b2733fab58fd1f7b1a6a9381f0ec107e32c97bc1 | [
"Zlib"
] | null | null | null | sample3.h | TheMrCerebro/irrBM | b2733fab58fd1f7b1a6a9381f0ec107e32c97bc1 | [
"Zlib"
] | null | null | null | /*
*
* Copyright (c) 2022 TheMrCerebro
*
* irrBM - Zlib license.
*
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
*
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any
* source distribution.
*
*/
#ifndef SAMPLE3_H_INCLUDED
#define SAMPLE3_H_INCLUDED
//===============================================
// Mobius trans in hyper 3-space
// Creado por neozhaoliang en 2018-05-09
// https://www.shadertoy.com/view/4scfR2
//===============================================
namespace sample3
{
#define E_ 2.7182818285f
// Raymarching constants
#define MIN_TRACE_DIST 0.01f
#define MAX_TRACE_STEPS 255
#define PRECISION 1e-5
// grid and cone size
#define polar_grid vec2(0.4f, PI / 7.0f)
#define cone_angle normalize(vec2(1.5f, 1.0f));
// Intensity constants
#define intensity_divisor 40000.0f
#define intensity_factor_max 7.2f
#define center_intensity 12.0f
#define ppow 1.9f
// Color constants
#define center_hue 0.5f
#define center_sat 0.18f
// shape constants
#define dist_factor 3.0f
#define strong_factor 7.0f
#define weak_factor 1.0f
#define star_hv_factor vec2(30.0f, 1.0f)
#define star_diag_factor vec2(30.0f, 1.0f)
// hsv to rgb conversion
vec3 hsv2rgb(vec3 hsv)
{
const vec3 p = vec3(0.0f, 2.0f/3.0f, 1.0f/3.0f);
vec2 hsvyz = clamp(vec2(hsv.v[1],hsv.v[2]), 0.0f, 1.0f);
hsv.v[1] = hsvyz.v[0];
hsv.v[2] = hsvyz.v[1];
return hsv.v[2] * (0.63f * hsv.v[1] * (cos(2.0f * PI * (hsv.v[0] + p)) - 1.0f) + 1.0f);
}
// 2d rotation
vec2 rot2d(vec2 p, f32 a) { return cos(a) * p + sin(a) * vec2(p.v[1], -p.v[0]); }
// 2d polar grids
vec2 polarGrid(vec2 p, vec2 size)
{
f32 theta = atan2(p.v[1], p.v[0]);
f32 r = log(length(p));
return mod(vec2(r, theta) + 0.5f * size, size) - 0.5f * size;
}
//Quaternion arithmetic
vec4 qmul(vec4 p, vec4 q)
{
return vec4(p.v[0] * q.v[0] - dot(vec3(p.v[1],p.v[2],p.v[3]), vec3(q.v[1],q.v[2],q.v[3])), p.v[0] * vec3(q.v[1],q.v[2],q.v[3]) + q.v[0] * vec3(p.v[1],p.v[2],p.v[3]) + cross(vec3(p.v[1],p.v[2],p.v[3]), vec3(q.v[1],q.v[2],q.v[3])));
}
// Apply Mobius transformation on upper half space as quaternions
f32 applyMobius(vec3 p)
{
vec4 pt = vec4(p, 0.0);
vec4 p1 = qmul(vec4(vec2(-1.0f, 0.0f), 0.0f, 0.0f), pt) + vec4(vec2(1.2f, 0.0f), 0.0f, 0.0f);
vec4 p2 = qmul(vec4(vec2(-1.0f, 0.0f), 0.0f, 0.0f), pt) + vec4(vec2(-1.2f, 0.0f), 0.0f, 0.0f);
vec4 xyz = qmul(p1, vec4(p2.v[0], -vec3(p2.v[1],p2.v[2],p2.v[3])) / dot(p2, p2));
p.v[0] = xyz.v[0];
p.v[1] = xyz.v[1];
p.v[2] = xyz.v[2];
f32 scale = length(p);
return scale > 1.0f ? 1.0f / scale : scale;
}
// A Mobius transformation of hyperbolic type is conjugate to a pure scaling
void trans_hyperbolic(vec2 p)
{
f32 d = log(length(p)) - (iTime * 0.5f) * polar_grid.v[0];
d = mod(d + 0.5f * polar_grid.v[0], polar_grid.v[0]) - 0.5f * polar_grid.v[0];
p = normalize(p) * pow(E_,d);
}
// A Mobius transformation of elliptic type is conjugate to a pure rotation
void trans_elliptic(vec2 p)
{
p = rot2d(p, (iTime * 0.5f) * polar_grid.v[1]);
}
// signed distance function for sphere kissing at y=0 with radius r
f32 sdSphere2(vec3 p, f32 r)
{
p.v[1] -= r;
return length(p) - r;
}
// signed distance function for parabolic case
f32 sdScene1(vec3 p)
{
return min(p.v[1], sdSphere2(p, 1.0f));
}
vec3 getColor(vec2 p, f32 pint)
{
f32 sat = 0.75f / pow(pint, 2.5f) + center_sat;
f32 hue2 = (iTime * 0.3f) - log(length(p)) / 7.0f;
f32 hue = center_hue + hue2;
return hsv2rgb(vec3(hue, sat, pint)) + pint / 3.0f;
}
f32 getIntensity2(vec2 p)
{
f32 angle = atan2f(polar_grid.v[0], polar_grid.v[1]);
f32 dist = length(p);
f32 disth = length(p * star_hv_factor);
f32 distv = length(p * vec2(star_hv_factor.v[1],star_hv_factor.v[0]));
vec2 q1 = rot2d(p, angle);
f32 dist1 = length(q1 * star_diag_factor);
vec2 q2 = rot2d(p, -angle);
f32 dist2 = length(q2 * star_diag_factor);
f32 pint1 = 1.0f / (dist * dist_factor + 0.5f);
pint1 += weak_factor / (distv * dist_factor + 0.01f) +
strong_factor / (disth * dist_factor + 0.01f) +
weak_factor / (dist1 * dist_factor + 0.01f) +
weak_factor / (dist2 * dist_factor + 0.01f);
return intensity_factor_max * pow(pint1, ppow) / intensity_divisor * center_intensity * 3.0f;
}
vec3 getNormal(vec3 p)
{
const vec2 e = vec2(0.003f, 0.0f);
vec3 xyy = vec3(e.v[0],e.v[1],e.v[1]);
vec3 yxy = vec3(e.v[1],e.v[0],e.v[1]);
vec3 yyx = vec3(e.v[1],e.v[1],e.v[0]);
f32 d1 = sdScene1(p + xyy), d2 = sdScene1(p - xyy);
f32 d3 = sdScene1(p + yxy), d4 = sdScene1(p - yxy);
f32 d5 = sdScene1(p + yyx), d6 = sdScene1(p - yyx);
return normalize(vec3(d1 - d2, d3 - d4, d5 - d6));
}
f32 softShadow(vec3 ro, vec3 rd, f32 tmin, f32 tmax, f32 k)
{
f32 res = 1.0f, t = tmin;
for (int i=0; i<20; i++)
{
f32 h = sdScene1(ro + rd * t);
res = min(res, smoothstep(0.0f, 1.0f, k * h / t));
t += clamp(h, 0.01f, 0.2f);
if (abs(h) < 1e-4 || t > tmax)
break;
}
return clamp(res + 0.15f, 0.0f, 1.0f);
}
f32 calcAO(vec3 p, vec3 n)
{
f32 occ = 0.0f, sca = 1.0f;
for (int i=0; i<5; i++)
{
f32 h = 0.01f + 0.15f * f32(i) / 4.0f;
f32 d = sdScene1(p + h * n);
occ += (h - d) * sca;
sca *= 0.7f;
}
return clamp(1.0f - 3.0f * occ, 0.0f, 1.0f);
}
f32 trace(vec3 ro, vec3 rd, vec2& p, f32& pint)
{
f32 depth = MIN_TRACE_DIST, dist;
vec3 pos;
for (u32 i=0; i<MAX_TRACE_STEPS; i++)
{
pos = ro + rd * depth;
dist = sdScene1(pos);
if (dist < PRECISION || depth >= 100.0f)
break;
depth += dist;
}
applyMobius(pos);
p.v[0] = pos.v[0];
p.v[1] = pos.v[2];
trans_hyperbolic(vec2(pos.v[0],pos.v[2]));
trans_elliptic(vec2(pos.v[0],pos.v[2]));
vec2 polxz = polarGrid(vec2(pos.v[0],pos.v[2]), polar_grid);
pos.v[0] = polxz.v[0];
pos.v[2] = polxz.v[1];
pint = getIntensity2(vec2(pos.v[0],pos.v[2]));
return depth;
}
vec3 tonemap(vec3 color)
{
return (color * (2.51f * color + 0.03f)) / (color * (2.43f * color + 0.59f) + 0.14f);
}
vec3 test(u32 x, u32 y)
{
vec3 ro = vec3(-2.4f, 4.8f, 7.0f);
vec2 roxz = rot2d(vec2(ro.v[0], ro.v[2]), iTime * 0.3f);
ro.v[0] = roxz.v[0];
ro.v[2] = roxz.v[1];
vec3 lookat = vec3(0.0f, 0.6f, 0.0f);
vec3 up = vec3(0.0f, 1.0f, 0.0f);
vec3 f = normalize(lookat - ro);
vec3 r = normalize(cross(f, up));
vec3 u = normalize(cross(r, f));
vec3 tot = vec3(0.0f);
vec3 lp = ro + vec3(0.2f, 0.8f, -0.2f);
vec2 uv = vec2(x,y) / iResolution;
uv = 2.0f * uv - 1.0f;
uv.v[0] *= iResolution.v[0] / iResolution.v[1];
vec3 rd = normalize(uv.v[0] * r + uv.v[1] * u + 4.0f * f);
vec2 p;
f32 pint;
f32 t = trace(ro, rd, p, pint);
if (t >= 0.0f)
{
vec3 col = tonemap(4.0f * getColor(p, pint));
vec3 pos = ro + rd * t;
vec3 nor = getNormal(pos);
vec3 ld = lp - pos;
f32 dist = max(length(ld), 0.001f);
ld /= dist;
f32 at = 2.2f / (1.0f + dist * 0.1f + dist * dist * 0.05f);
f32 ao = calcAO(pos, nor);
f32 sh = softShadow(pos, ld, 0.04f, dist, 8.0f);
f32 diff = clamp(dot(nor, ld), 0.0f, 1.0f);
f32 spec = max( 0.0f, dot( reflect(-ld, nor), -rd));
spec = powf(spec, 50.0f);
tot += diff * 2.5f * col + vec3(0.6f, 0.8f, 0.8f) * spec * 2.0f;
tot *= ao * sh * at;
}
if(t >= 100.0f)
lp = normalize(lp - ro - rd * 100.0f);
vec3 bg = mix(vec3(0.5f, 0.7f, 1.0f), vec3(1.0f, 0.5f, 0.6f), 0.5f - 0.5f * lp.v[1]) * 0.3f;
tot = mix(clamp(tot, 0.0f, 1.0f), bg, smoothstep(0.0f, 100.0f - 2.0f, t));
return sqrt(clamp(tot, 0.0f, 1.0f));
}
}
#endif // SAMPLE3_H_INCLUDED
| 29.918919 | 235 | 0.558491 |
4bd2c814b5f143ba5e31ea1be9404d242bbae31d | 3,350 | h | C | gorock/ext/crawler.h | abdallah-elsharif/WRock | 7cfd4bf29e932bf0048ee357c16cf6c021e7fb81 | [
"MIT"
] | 14 | 2022-03-13T19:51:24.000Z | 2022-03-18T07:36:39.000Z | gorock/ext/crawler.h | abdallah-elsharif/WRock | 7cfd4bf29e932bf0048ee357c16cf6c021e7fb81 | [
"MIT"
] | null | null | null | gorock/ext/crawler.h | abdallah-elsharif/WRock | 7cfd4bf29e932bf0048ee357c16cf6c021e7fb81 | [
"MIT"
] | 3 | 2022-03-14T05:58:06.000Z | 2022-03-14T11:46:47.000Z | #ifndef _GOROCK_CRAWLER
#define _GOROCK_CRAWLER
#include "gorock.h"
typedef struct
{
PyObject_HEAD
PyObject *url;
PyObject *threads;
PyObject *depth;
PyObject *subsInScope;
PyObject *insecure;
PyObject *rawHeaders;
} Crawler;
/* Needed by Python VM */
static int Crawler_traverse(Crawler *self, visitproc visit, void *arg);
static int Crawler_clear(Crawler *self);
static PyObject *Crawler_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
static int Crawler_init(Crawler *self, PyObject *args, PyObject* kwds);
static void Crawler_dealloc(Crawler *self);
/* Setters && Getters */
static int Crawler_SetUrl(Crawler *self, PyObject *value, void *closure);
static PyObject *Crawler_GetUrl(Crawler *self, void *closure);
static int Crawler_SetThreads(Crawler *self, PyObject *value, void *closure);
static PyObject *Crawler_GetThreads(Crawler *self, void *closure);
static int Crawler_SetDepth(Crawler *self, PyObject *value, void *closure);
static PyObject *Crawler_GetDepth(Crawler *self, void *closure);
static int Crawler_SetSubsInScope(Crawler *self, PyObject *value, void *closure);
static PyObject *Crawler_GetSubsInScope(Crawler *self, void *closure);
static int Crawler_SetInsecure(Crawler *self, PyObject *value, void *closure);
static PyObject *Crawler_GetInsecure(Crawler *self, void *closure);
static int Crawler_SetRawHeaders(Crawler *self, PyObject *value, void *closure);
static PyObject *Crawler_GetRawHeaders(Crawler *self, void *closure);
static PyObject *Crawler_Start(Crawler *self, PyObject *Py_UNUSED(ignored));
PyMODINIT_FUNC PyInit_rockrawler(void);
static PyGetSetDef Crawler_getsetters[] = {
{"url", (getter) Crawler_GetUrl, (setter) Crawler_SetUrl,
"The target url.", NULL},
{"threads", (getter) Crawler_GetThreads, (setter) Crawler_SetThreads,
"Number of threads.", NULL},
{"depth", (getter) Crawler_GetDepth, (setter) Crawler_SetDepth,
"Depth to crawl. (default 2)", NULL},
{"subsInScope", (getter) Crawler_GetSubsInScope, (setter) Crawler_SetSubsInScope,
"Include subdomains for crawling.", NULL},
{"insecure", (getter) Crawler_GetInsecure, (setter) Crawler_SetInsecure,
"Disable TLS verification.", NULL},
{"rawHeaders", (getter) Crawler_GetRawHeaders, (setter) Crawler_SetRawHeaders,
"Custom headers separated by two semi-colons.", NULL},
{NULL} /* Sentinel */
};
static PyMethodDef Crawler_methods[] = {
{"Start", (PyCFunction) Crawler_Start, METH_NOARGS,
"Return results in a list"},
{NULL} /* Sentinel */
};
static PyTypeObject CrawlerType = {
PyVarObject_HEAD_INIT(NULL, 0)
.tp_name = "rockrawler.Crawler",
.tp_doc = "Crawler objects",
.tp_basicsize = sizeof(Crawler),
.tp_itemsize = 0,
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,
.tp_new = Crawler_new,
.tp_init = (initproc) Crawler_init,
.tp_dealloc = (destructor) Crawler_dealloc,
.tp_traverse = (traverseproc) Crawler_traverse,
.tp_clear = (inquiry) Crawler_clear,
.tp_methods = Crawler_methods,
.tp_getset = Crawler_getsetters,
};
static PyModuleDef rockrawlermodule = {
PyModuleDef_HEAD_INIT,
.m_name = "rockrawler",
.m_doc = "rockrawler module is an extension to RockRawler project.",
.m_size = -1
};
#endif | 33.838384 | 85 | 0.72597 |
35635d40143f2637afe8df43582df2485d65a086 | 217 | h | C | BWTransitions/BWTransitions/BWMainViewController.h | baiwhte/BWTransitions | 48d65a66b11bf59b80dee15ba0eec36c47436dd2 | [
"MIT"
] | null | null | null | BWTransitions/BWTransitions/BWMainViewController.h | baiwhte/BWTransitions | 48d65a66b11bf59b80dee15ba0eec36c47436dd2 | [
"MIT"
] | null | null | null | BWTransitions/BWTransitions/BWMainViewController.h | baiwhte/BWTransitions | 48d65a66b11bf59b80dee15ba0eec36c47436dd2 | [
"MIT"
] | null | null | null | //
// BWViewController.h
// BWTransitions
//
// Created by 陈修武 on 2017/5/8.
// Copyright © 2017年 baiwhte. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface BWMainViewController : UIViewController
@end
| 15.5 | 51 | 0.705069 |
98e1e2024bc4f3d9681b88825cd8220d6068f306 | 1,874 | h | C | usr/src/uts/common/sys/usb/clients/mass_storage/usb_cbi.h | AsahiOS/gate | 283d47da4e17a5871d9d575e7ffb81e8f6c52e51 | [
"MIT"
] | null | null | null | usr/src/uts/common/sys/usb/clients/mass_storage/usb_cbi.h | AsahiOS/gate | 283d47da4e17a5871d9d575e7ffb81e8f6c52e51 | [
"MIT"
] | null | null | null | usr/src/uts/common/sys/usb/clients/mass_storage/usb_cbi.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 (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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_USB_CBI_H
#define _SYS_USB_CBI_H
#ifdef __cplusplus
extern "C" {
#endif
/*
* This header file contains definitions used by
* USB Mass Storage Class's CBI transport.
*/
/* CBI Class req */
#define CBI_REQUEST_TYPE (USB_DEV_REQ_HOST_TO_DEV | \
USB_DEV_REQ_TYPE_CLASS | \
USB_DEV_REQ_RCPT_IF)
#define CBI_WVALUE 0x00 /* wValue: reserved to 00 */
#define CBI_SELF_TEST 0x04 /* For Command Block Reset */
#define CBI_CBR_VALUE 0xff /* Command Block Reset value */
#define CBI_CLASS_CMD_LEN 0x0C /* Command len 12 bytes */
/*
* CBI Command Block Status values
*/
#define CBI_STATUS_PASS 0x0 /* Command passed */
#define CBI_STATUS_FAILED 0x1 /* Command failed */
#define CBI_STATUS_PHASE_ERR 0x2 /* Command has a phase error */
#define CBI_STATUS_PERSISTENT_FAIL 0x3 /* Command fails persistently */
#define CBI_STATUS_MASK 0x3 /* Command status MASK */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_USB_CBI_H */
| 29.746032 | 71 | 0.740662 |
470ee70e748cbbe3687ec20c5baf0bfc6f721960 | 215 | h | C | ViewControllerTransitionTest/DebugView.h | master-nevi/ViewControllerTransitionTest | c8a0f6377477be050347b6bb4ad4fed119394228 | [
"MIT"
] | null | null | null | ViewControllerTransitionTest/DebugView.h | master-nevi/ViewControllerTransitionTest | c8a0f6377477be050347b6bb4ad4fed119394228 | [
"MIT"
] | null | null | null | ViewControllerTransitionTest/DebugView.h | master-nevi/ViewControllerTransitionTest | c8a0f6377477be050347b6bb4ad4fed119394228 | [
"MIT"
] | null | null | null | //
// DebugView.h
// ViewControllerTransitionTest
//
// Created by David Robles on 5/9/14.
// Copyright (c) 2014 955 Dreams. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface DebugView : UIView
@end
| 15.357143 | 55 | 0.688372 |
b837b201d6342722d76bf4df4ee279700eaac195 | 709 | h | C | source/glkernel/include/glkernel/sequence.h | ratnim/glkernel | b8eb8e8180e716407d35d7f70b4fa8759988c946 | [
"MIT"
] | null | null | null | source/glkernel/include/glkernel/sequence.h | ratnim/glkernel | b8eb8e8180e716407d35d7f70b4fa8759988c946 | [
"MIT"
] | null | null | null | source/glkernel/include/glkernel/sequence.h | ratnim/glkernel | b8eb8e8180e716407d35d7f70b4fa8759988c946 | [
"MIT"
] | null | null | null |
#pragma once
#include <glm/gtc/type_precision.hpp>
#include <glkernel/Kernel.h>
namespace glkernel
{
namespace sequence
{
template<typename T, typename std::enable_if<std::is_floating_point<T>::value>::type * = nullptr>
void uniform(tkernel<T> & kernel, T range_min, T range_max);
template <typename T, glm::precision P, template<typename, glm::precision> class V>
void uniform(tkernel<V<T, P>> & kernel, T range_min, T range_max);
template <typename T, glm::precision P, template<typename, glm::precision> class V>
void uniform(tkernel<V<T, P>> & kernel, const V<T, P> & range_min, const V<T, P> & range_max);
} // namespace sequence
} // namespace glkernel
#include <glkernel/sequence.hpp>
| 20.852941 | 97 | 0.720733 |
11c931a20127458a4ae415cf2a41ae65b16a44bb | 1,617 | h | C | PrivateFrameworks/NotesShared/ICServerChangeToken.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 17 | 2018-11-13T04:02:58.000Z | 2022-01-20T09:27:13.000Z | PrivateFrameworks/NotesShared/ICServerChangeToken.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 3 | 2018-04-06T02:02:27.000Z | 2018-10-02T01:12:10.000Z | PrivateFrameworks/NotesShared/ICServerChangeToken.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 1 | 2018-09-28T13:54:23.000Z | 2018-09-28T13:54:23.000Z | //
// Generated by class-dump 3.5 (64 bit).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard.
//
#import "NSManagedObject.h"
#import "ICLoggable.h"
@class CKRecordZoneID, CKServerChangeToken, ICAccount, NSData, NSString;
@interface ICServerChangeToken : NSManagedObject <ICLoggable>
{
CKRecordZoneID *_zoneID;
CKServerChangeToken *_ckServerChangeToken;
}
+ (id)serverChangeTokensMatchingPredicate:(id)arg1 inContext:(id)arg2;
+ (id)serverChangeTokenForAccount:(id)arg1 zoneID:(id)arg2 databaseScope:(long long)arg3 context:(id)arg4;
+ (id)addServerChangeTokenForAccount:(id)arg1 ckServerChangeToken:(id)arg2 zoneID:(id)arg3 databaseScope:(long long)arg4 context:(id)arg5;
- (void).cxx_destruct;
- (id)ic_loggingValues;
@property(readonly, nonatomic) CKRecordZoneID *zoneID; // @synthesize zoneID=_zoneID;
- (void)didTurnIntoFault;
@property(nonatomic) long long databaseScope; // @dynamic databaseScope;
@property(retain, nonatomic) CKServerChangeToken *ckServerChangeToken; // @synthesize ckServerChangeToken=_ckServerChangeToken;
// Remaining properties
@property(retain, nonatomic) ICAccount *account; // @dynamic account;
@property(retain, nonatomic) NSData *ckServerChangeTokenData; // @dynamic ckServerChangeTokenData;
@property(readonly, copy) NSString *debugDescription;
@property(readonly, copy) NSString *description;
@property(readonly) unsigned long long hash;
@property(retain, nonatomic) NSString *ownerName; // @dynamic ownerName;
@property(readonly) Class superclass;
@property(retain, nonatomic) NSString *zoneName; // @dynamic zoneName;
@end
| 39.439024 | 138 | 0.779839 |
f844d743588aa70cf42dc44b0ef4f554a66b90b9 | 1,628 | h | C | SileoSource/Dpkg/headers/atomic-file.h | iMokhles/SileoSource | 7d9d5d9b3c5196ead7c74703d91d9d052e9cf114 | [
"MIT"
] | 12 | 2019-03-07T16:36:29.000Z | 2020-03-14T22:24:38.000Z | SileoSource/Dpkg/headers/atomic-file.h | iMokhles/SileoSource | 7d9d5d9b3c5196ead7c74703d91d9d052e9cf114 | [
"MIT"
] | null | null | null | SileoSource/Dpkg/headers/atomic-file.h | iMokhles/SileoSource | 7d9d5d9b3c5196ead7c74703d91d9d052e9cf114 | [
"MIT"
] | 4 | 2019-04-20T15:56:24.000Z | 2019-08-13T07:44:38.000Z | /*
* libdpkg - Debian packaging suite library routines
* atomic-file.h - atomic file helper functions
*
* Copyright © 2011-2014 Guillem Jover <guillem@debian.org>
*
* This 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 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef LIBDPKG_ATOMIC_FILE_H
#define LIBDPKG_ATOMIC_FILE_H
#include <stdio.h>
#include "macros.h"
DPKG_BEGIN_DECLS
/**
* @defgroup atomic-file Atomic file operations
* @ingroup dpkg-internal
* @{
*/
enum atomic_file_flags {
ATOMIC_FILE_BACKUP = DPKG_BIT(0),
};
struct atomic_file {
enum atomic_file_flags flags;
char *name;
char *name_new;
FILE *fp;
};
struct atomic_file *
atomic_file_new(const char *filename, enum atomic_file_flags flags);
void atomic_file_open(struct atomic_file *file);
void atomic_file_sync(struct atomic_file *file);
void atomic_file_close(struct atomic_file *file);
void atomic_file_commit(struct atomic_file *file);
void atomic_file_remove(struct atomic_file *file);
void atomic_file_free(struct atomic_file *file);
/** @} */
DPKG_END_DECLS
#endif /* LIBDPKG_ATOMIC_FILE_H */
| 26.688525 | 73 | 0.757371 |
5006f81329a4c7d39b086327d1cab1a84bc0ac5f | 433 | h | C | scribo_le/examples/example_1/include/bar.h | petrveprek/obircs | 97ed8dd189fb7074467504113e3be950245b87b3 | [
"MIT"
] | null | null | null | scribo_le/examples/example_1/include/bar.h | petrveprek/obircs | 97ed8dd189fb7074467504113e3be950245b87b3 | [
"MIT"
] | null | null | null | scribo_le/examples/example_1/include/bar.h | petrveprek/obircs | 97ed8dd189fb7074467504113e3be950245b87b3 | [
"MIT"
] | null | null | null | // ---------------------------------------------------------------------------------------------------------------------
// Copyright (c) 2015, 2017 Petr Vepřek
// File: bar.h
// ---------------------------------------------------------------------------------------------------------------------
void doBar();
// End of file --------------------------------------------------------------------------------------------------------- | 54.125 | 120 | 0.124711 |
dde42c08e78672df01fe9c721dfa68a664bfd3fb | 8,248 | h | C | src/backtracking/solveCube.h | WareAnj/rubix_backtracking | b45423a825b25a43ef3575c528c2ac3b864fa43f | [
"MIT"
] | null | null | null | src/backtracking/solveCube.h | WareAnj/rubix_backtracking | b45423a825b25a43ef3575c528c2ac3b864fa43f | [
"MIT"
] | null | null | null | src/backtracking/solveCube.h | WareAnj/rubix_backtracking | b45423a825b25a43ef3575c528c2ac3b864fa43f | [
"MIT"
] | null | null | null | #include <stdio.h>
#include "rotateCube.h"
#define N 12
#define maxmoves 6
void solveCube (int rubixcube[6][3][3]) {
int savestate[6][3][3];
int start, move;
int nopts[N+2]; //array of top of stacks
int option[N+2][N+2]; //array of stacks of options
int candidate;
int num = 0;
int n, m;
int i, j, k;
for(i = 0; i < 6; i++){
for(j = 0; j < 3; j++){
for(k = 0; k < 3;k++){
savestate[i][j][k] = rubixcube[i][j][k];
}
}
}
for(n = 1; n <= maxmoves;n++){
move = start = 0;
nopts[start]= 1;
while (nopts[start] >0){//while dummy stack is not empty
if(nopts[move]>0){
move++;
nopts[move]=0; //initialize new move
if(move==n+1){ //solution found!
/*
w1 - w cw - 0, CLOCKWISE
w2 - w cc - 0
r1 - r cw - 1, CLOCKWISE
r2 - r cc - 1
b1 - b cw - 2, CLOCKWISE
b2 - b cc - 2
o1 - o cw - 3, CLOCKWISE
o2 - o cc - 3
g1 - g cw - 4, CLOCKWISE
g2 - g cc - 4
y1 - y cw - 5, CLOCKWISE
y2 - y cc - 5
*/
for(i=1;i<move;i++){
if(option[i][nopts[i]] == 1){
//printf("w cw \n");
rotateCube(rubixcube, 0, "CLOCKWISE");
}
if(option[i][nopts[i]] == 2){
//printf("w cc \n");
rotateCube(rubixcube, 0, "!CLOCKWISE");
}
if(option[i][nopts[i]] == 3){
//printf("r cw \n");
rotateCube(rubixcube, 1, "CLOCKWISE");
}
if(option[i][nopts[i]] == 4){
//printf("r cc \n");
rotateCube(rubixcube, 1, "!CLOCKWISE");
}
if(option[i][nopts[i]] == 5){
//printf("b cw \n");
rotateCube(rubixcube, 2, "CLOCKWISE");
}
if(option[i][nopts[i]] == 6){
//printf("b cc \n");
rotateCube(rubixcube, 2, "!CLOCKWISE");
}
if(option[i][nopts[i]] == 7){
//printf("o cw \n");
rotateCube(rubixcube, 3, "CLOCKWISE");
}
if(option[i][nopts[i]] == 8){
//printf("o cc \n");
rotateCube(rubixcube, 3, "!CLOCKWISE");
}
if(option[i][nopts[i]] == 9){
//printf("g cw \n");
rotateCube(rubixcube, 4, "CLOCKWISE");
}
if(option[i][nopts[i]] == 10){
//printf("g cc \n");
rotateCube(rubixcube, 4, "!CLOCKWISE");
}
if(option[i][nopts[i]] == 11){
//printf("y cw \n");
rotateCube(rubixcube, 5, "CLOCKWISE");
}
if(option[i][nopts[i]] == 12){
//printf("y cc \n");
rotateCube(rubixcube, 5, "!CLOCKWISE");
}
}
if(check(rubixcube) == 1){
//return the 'moves'
//The list of moves are all the
//values of option[i][nopts[i]]
// from i to move, where i is 0
for(i = 0;i < move;i++){
if( option[i][nopts[i]] == 1){
//printf("w cw \n");
printf("Move %d: rotateCube(cube, WHITE, CLOCKWISE)\n", i);
}
if(option[i][nopts[i]] == 2){
//printf("w cc \n");
printf("Move %d: rotateCube(cube, WHITE, !CLOCKWISE)\n", i);
}
if(option[i][nopts[i]] == 3){
//printf("r cw \n");
printf("Move %d: rotateCube(cube, RED, CLOCKWISE)\n", i);
}
if(option[i][nopts[i]] == 4){
//printf("r cc \n");
printf("Move %d: rotateCube(cube, RED, !CLOCKWISE)\n", i);
}
if(option[i][nopts[i]] == 5){
//printf("b cw \n");
printf("Move %d: rotateCube(cube, BLUE, CLOCKWISE)\n", i);
}
if(option[i][nopts[i]] == 6){
//printf("b cc \n");
printf("Move %d: rotateCube(cube, BLUE, !CLOCLWISE)\n", i);
}
if(option[i][nopts[i]] == 7){
//printf("o cw \n");
printf("Move %d: rotateCube(cube, ORANGE, CLOCKWISE)\n", i);
}
if(option[i][nopts[i]] == 8){
//printf("o cc \n");
printf("Move %d: rotateCube(cube, ORANGE, !CLOCKWISE)\n", i);
}
if(option[i][nopts[i]] == 9){
//printf("g cw \n");
printf("Move %d: rotateCube(cube, GREEN, CLOCKWISE)\n", i);
}
if(option[i][nopts[i]] == 10){
//printf("g cc \n");
printf("Move %d: rotateCube(cube, GREEN, !CLOCKWISE)", i);
}
if(option[i][nopts[i]] == 11){
//printf("y cw \n");
printf("Move %d: rotateCube(cube, YELLOW, CLOCKWISE)\n", i);
}
if(option[i][nopts[i]] == 12){
//printf("y cc \n");
printf("Move %d: rotateCube(cube, YELLOW, !CLOCKWISE)\n", i);
}
}
printf("SOLUTION FOUND");
print(rubixcube);
return 0;
}
else{
//UNDO MOVES
for(i = 0; i < 6; i++){
for(j = 0; j < 3; j++){
for(k = 0; k < 3;k++){
rubixcube[i][j][k] = savestate[i][j][k];
}
}
}
}
num++;
}
else { //populates options
for(candidate = N; candidate >=1; candidate --) {
nopts[move]++;
option[move][nopts[move]] = candidate;
//printf("nopts[move] %i candidate %i:\n", nopts[move], candidate);
}
}
}
else {
move--;
nopts[move]--;
}
}
}
}
| 36.175439 | 102 | 0.285766 |
20c806c94cc1b4b17902fa878299fde96b37a59d | 1,362 | h | C | piscine/C10/ex03/includes/ft_dumps.h | cheremushkin/school21 | aa151406acc0a5fdbcf62c3f27cd5f628e68dd51 | [
"Apache-2.0"
] | null | null | null | piscine/C10/ex03/includes/ft_dumps.h | cheremushkin/school21 | aa151406acc0a5fdbcf62c3f27cd5f628e68dd51 | [
"Apache-2.0"
] | null | null | null | piscine/C10/ex03/includes/ft_dumps.h | cheremushkin/school21 | aa151406acc0a5fdbcf62c3f27cd5f628e68dd51 | [
"Apache-2.0"
] | null | null | null | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_dumps.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lteresia <lteresia@student.school-2> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/09/11 02:15:06 by lteresia #+# #+# */
/* Updated: 2021/09/11 02:15:09 by lteresia ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef FT_DUMPS_H
# define FT_DUMPS_H
# include "ft_math.h"
# include "ft_base.h"
# include "ft_puts.h"
# include "ft_itoa.h"
# include "ft_puts2.h"
# include "ft_hexdump.h"
# include "ft_boolean.h"
void ft_hexdump_addr(int addr);
void ft_hexdump_fill_zero(int start, t_bool option);
void ft_hexdump_content_line(char *line, int len, t_bool option);
void ft_hexdump_line(char *content, int addr, t_bool option);
void ft_dump_content_line(char *line, int len);
#endif | 45.4 | 80 | 0.340675 |
1f515e57bacf390a1f6cc5c130a9d9b3052b6a5c | 1,533 | h | C | PrivateFrameworks/Mondrian/MOLiveUpdateController.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 17 | 2018-11-13T04:02:58.000Z | 2022-01-20T09:27:13.000Z | PrivateFrameworks/Mondrian/MOLiveUpdateController.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 3 | 2018-04-06T02:02:27.000Z | 2018-10-02T01:12:10.000Z | PrivateFrameworks/Mondrian/MOLiveUpdateController.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 1 | 2018-09-28T13:54:23.000Z | 2018-09-28T13:54:23.000Z | //
// Generated by class-dump 3.5 (64 bit).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard.
//
#import "NSObject.h"
@class NSCountedSet;
@interface MOLiveUpdateController : NSObject
{
id <MOLiveUpdateControllerDelegate> _delegate;
NSCountedSet *_inFlightUserActions;
struct _MOLiveUpdatePendingSession _pendingSession;
struct _MOLiveUpdatePendingSession _pendingUserActions;
unsigned long long _currentUserActionsRepeat;
struct {
unsigned int delegateShouldPerformAdditionalUpdateWithDelay:1;
unsigned int delegateDidNotPerformAnyActions:1;
unsigned int delegateShouldReplyToUserActionsForLiveUpdateController:1;
unsigned int delegateProvidesRetryDelay:1;
} _flags;
}
+ (void)notifyUserActionsInProgress;
@property(readonly) __weak id <MOLiveUpdateControllerDelegate> delegate; // @synthesize delegate=_delegate;
- (void).cxx_destruct;
- (void)cancelAllUpdates;
- (void)performUpdateAfterDelay:(double)arg1;
- (void)performUpdateNow;
- (void)endUserAction:(id)arg1;
- (void)beginUserAction:(id)arg1;
- (BOOL)hasUserActionInProgress;
- (BOOL)hasPendingUpdates;
- (void)_attemptUpdate;
- (double)_retryDelayForFailingAction:(SEL)arg1;
- (void)_performUpdateAfterDelay:(double)arg1 retry:(BOOL)arg2;
- (BOOL)_requestUserActionUpdate;
- (void)_setUserActionsModeForDelay:(double)arg1;
- (BOOL)_hasUserUpdatesInProgress;
- (void)_didExecuteUserActionsNotification:(id)arg1;
- (void)dealloc;
- (id)initWithDelegate:(id)arg1;
@end
| 31.9375 | 107 | 0.773646 |
5ac538e67ca20cf06c0d299afc372833a9dc91b3 | 4,135 | c | C | cachelab-handout/trans.c | lingxiaotang/csapp-lab | 8482c42e1dc7767701ac823a67186a9c61360acc | [
"MIT"
] | 1 | 2020-08-11T02:51:42.000Z | 2020-08-11T02:51:42.000Z | cachelab-handout/trans.c | lingxiaotang/csapp-lab | 8482c42e1dc7767701ac823a67186a9c61360acc | [
"MIT"
] | null | null | null | cachelab-handout/trans.c | lingxiaotang/csapp-lab | 8482c42e1dc7767701ac823a67186a9c61360acc | [
"MIT"
] | null | null | null | /*
* trans.c - Matrix transpose B = A^T
*
* Each transpose function must have a prototype of the form:
* void trans(int M, int N, int A[N][M], int B[M][N]);
*
* A transpose function is evaluated by counting the number of misses
* on a 1KB direct mapped cache with a block size of 32 bytes.
*/
#include <stdio.h>
#include "cachelab.h"
int is_transpose(int M, int N, int A[N][M], int B[M][N]);
/*
* transpose_submit - This is the solution transpose function that you
* will be graded on for Part B of the assignment. Do not change
* the description string "Transpose submission", as the driver
* searches for that string to identify the transpose function to
* be graded.
*/
char transpose_submit_desc[] = "Transpose submission";
void transpose_submit(int M, int N, int A[N][M], int B[M][N])
{
int a1;
int a2;
int a3;
int a4;
int a5;
int a6;
int a7;
int a8;
int i, j, ii, jj;
if (M==N&&M==32)
{
for (i=0;i<N/8;i++)
{
for (j=0;j<M/8;j++)
{
for (ii=0;ii<8;ii++)
{
a1=A[i*8+ii][j*8+0];
a2=A[i*8+ii][j*8+1];
a3=A[i*8+ii][j*8+2];
a4=A[i*8+ii][j*8+3];
a5=A[i*8+ii][j*8+4];
a6=A[i*8+ii][j*8+5];
a7=A[i*8+ii][j*8+6];
a8=A[i*8+ii][j*8+7];
B[j*8+0][i*8+ii]=a1;
B[j*8+1][i*8+ii]=a2;
B[j*8+2][i*8+ii]=a3;
B[j*8+3][i*8+ii]=a4;
B[j*8+4][i*8+ii]=a5;
B[j*8+5][i*8+ii]=a6;
B[j*8+6][i*8+ii]=a7;
B[j*8+7][i*8+ii]=a8;
}
}
}
}
if (M==N&&M==64)
{
for (i=0;i<N;i+=4)
{
for (j=0;j<M;j+=4)
{
for(ii=i;ii<i+4;ii+=2)
{
a1=A[ii][j];
a2=A[ii][j+1];
a3=A[ii][j+2];
a4=A[ii][j+3];
a5=A[ii+1][j];
a6=A[ii+1][j+1];
a7=A[ii+1][j+2];
a8=A[ii+1][j+3];
B[j][ii]=a1;
B[j+1][ii]=a2;
B[j+2][ii]=a3;
B[j+3][ii]=a4;
B[j][ii+1]=a5;
B[j+1][ii+1]=a6;
B[j+2][ii+1]=a7;
B[j+3][ii+1]=a8;
}
}
}
}
if (N==67&&M==61)
{
for(i=0;i<N;i+=16){
for(j=0;j<M;j+=16){
for(ii=i;ii<i+16&&ii<N;ii++){
for(jj=j;jj<j+16&&jj<M;jj++){
B[jj][ii]=A[ii][jj];
}
}
}
}
}
}
/*
* You can define additional transpose functions below. We've defined
* a simple one below to help you get started.
*/
/*
* trans - A simple baseline transpose function, not optimized for the cache.
*/
/*
* registerFunctions - This function registers your transpose
* functions with the driver. At runtime, the driver will
* evaluate each of the registered functions and summarize their
* performance. This is a handy way to experiment with different
* transpose strategies.
*/
void registerFunctions()
{
/* Register your solution function */
registerTransFunction(transpose_submit, transpose_submit_desc);
/* Register any additional transpose functions */
//registerTransFunction(trans, trans_desc);
}
/*
* is_transpose - This helper function checks if B is the transpose of
* A. You can check the correctness of your transpose by calling
* it before returning from the transpose function.
*/
int is_transpose(int M, int N, int A[N][M], int B[M][N])
{
int i, j;
for (i = 0; i < N; i++) {
for (j = 0; j < M; ++j) {
if (A[i][j] != B[j][i]) {
return 0;
}
}
}
return 1;
}
| 26.50641 | 78 | 0.437727 |
ea12cad7e799e65040742d1ebcef1c76643b72bb | 3,595 | h | C | src/cmd/pforth/pf_save.h | 610t/retrobsd | a0c256c1f0129ee6eb0d00f385e98da9b28d94c1 | [
"BSD-3-Clause"
] | 236 | 2015-01-13T12:33:26.000Z | 2022-03-16T07:18:49.000Z | src/cmd/pforth/pf_save.h | 610t/retrobsd | a0c256c1f0129ee6eb0d00f385e98da9b28d94c1 | [
"BSD-3-Clause"
] | 21 | 2015-04-26T07:35:34.000Z | 2020-12-18T13:31:55.000Z | src/cmd/pforth/pf_save.h | 610t/retrobsd | a0c256c1f0129ee6eb0d00f385e98da9b28d94c1 | [
"BSD-3-Clause"
] | 53 | 2015-01-21T12:54:44.000Z | 2022-01-14T07:01:39.000Z | /* @(#) pf_save.h 96/12/18 1.8 */
#ifndef _pforth_save_h
#define _pforth_save_h
/***************************************************************
** Include file for PForth SaveForth
**
** Author: Phil Burk
** Copyright 1994 3DO, Phil Burk, Larry Polansky, David Rosenboom
**
** The pForth software code is dedicated to the public domain,
** and any third party may reproduce, distribute and modify
** the pForth software code or any derivative works thereof
** without any compensation or license. The pForth software
** code is provided on an "as is" basis without any warranty
** of any kind, including, without limitation, the implied
** warranties of merchantability and fitness for a particular
** purpose and their equivalents under the laws of any jurisdiction.
**
** 941031 rdg fix redefinition of MAKE_ID and EVENUP to be conditional
**
***************************************************************/
typedef struct DictionaryInfoChunk
{
/* All fields are stored in BIG ENDIAN format for consistency in data files.
* All fields must be the same size for easy endian conversion.
* All fields must be 32 bit for file compatibility with older versions.
*/
int32_t sd_Version;
int32_t sd_RelContext; /* relative ptr to Dictionary Context */
int32_t sd_RelHeaderPtr; /* relative ptr to Dictionary Header Ptr */
int32_t sd_RelCodePtr; /* relative ptr to Dictionary Header Ptr */
int32_t sd_EntryPoint; /* relative ptr to entry point or NULL */
int32_t sd_UserStackSize; /* in bytes */
int32_t sd_ReturnStackSize; /* in bytes */
int32_t sd_NameSize; /* in bytes */
int32_t sd_CodeSize; /* in bytes */
int32_t sd_NumPrimitives; /* To distinguish between primitive and secondary. */
uint32_t sd_Flags;
int32_t sd_FloatSize; /* In bytes. Must match code. 0 means no floats. */
int32_t sd_CellSize; /* In bytes. Must match code. */
} DictionaryInfoChunk;
/* Bits in sd_Flags */
#define SD_F_BIG_ENDIAN_DIC (1<<0)
#ifndef MAKE_ID
#define MAKE_ID(a,b,c,d) ((((uint32_t)a)<<24)|(((uint32_t)b)<<16)|(((uint32_t)c)<<8)|((uint32_t)d))
#endif
#define ID_FORM MAKE_ID('F','O','R','M')
#define ID_P4TH MAKE_ID('P','4','T','H')
#define ID_P4DI MAKE_ID('P','4','D','I')
#define ID_P4NM MAKE_ID('P','4','N','M')
#define ID_P4CD MAKE_ID('P','4','C','D')
#define ID_BADF MAKE_ID('B','A','D','F')
#ifndef EVENUP
#define EVENUP(n) ((n+1)&(~1))
#endif
#ifdef __cplusplus
extern "C" {
#endif
cell_t ffSaveForth( const char *FileName, ExecToken EntryPoint, cell_t NameSize, cell_t CodeSize );
/* Endian-ness tools. */
int IsHostLittleEndian( void );
ucell_t ReadCellBigEndian( const uint8_t *addr );
uint32_t Read32BigEndian( const uint8_t *addr );
uint16_t Read16BigEndian( const uint8_t *addr );
ucell_t ReadCellLittleEndian( const uint8_t *addr );
uint32_t Read32LittleEndian( const uint8_t *addr );
uint16_t Read16LittleEndian( const uint8_t *addr );
void WriteCellBigEndian( uint8_t *addr, ucell_t data );
void Write32BigEndian( uint8_t *addr, uint32_t data );
void Write16BigEndian( uint8_t *addr, uint16_t data );
void WriteCellLittleEndian( uint8_t *addr, ucell_t data );
void Write32LittleEndian( uint8_t *addr, uint32_t data );
void Write16LittleEndian( uint8_t *addr, uint16_t data );
#ifdef PF_SUPPORT_FP
void WriteFloatBigEndian( PF_FLOAT *addr, PF_FLOAT data );
PF_FLOAT ReadFloatBigEndian( const PF_FLOAT *addr );
void WriteFloatLittleEndian( PF_FLOAT *addr, PF_FLOAT data );
PF_FLOAT ReadFloatLittleEndian( const PF_FLOAT *addr );
#endif
#ifdef __cplusplus
}
#endif
#endif /* _pforth_save_h */
| 35.594059 | 99 | 0.701808 |
ea3765576227377e711834435777f003158a4f95 | 9,426 | c | C | py/objarray.c | lurch/micropython | 28dfbc2ba2ef41a7810e4e39290031eb2207a0a9 | [
"MIT"
] | null | null | null | py/objarray.c | lurch/micropython | 28dfbc2ba2ef41a7810e4e39290031eb2207a0a9 | [
"MIT"
] | null | null | null | py/objarray.c | lurch/micropython | 28dfbc2ba2ef41a7810e4e39290031eb2207a0a9 | [
"MIT"
] | null | null | null | #include <string.h>
#include <assert.h>
#include "nlr.h"
#include "misc.h"
#include "mpconfig.h"
#include "qstr.h"
#include "obj.h"
#include "runtime0.h"
#include "runtime.h"
#include "binary.h"
typedef struct _mp_obj_array_t {
mp_obj_base_t base;
machine_uint_t typecode : 8;
// free is number of unused elements after len used elements
// alloc size = len + free
machine_uint_t free : (8 * sizeof(machine_uint_t) - 8);
machine_uint_t len; // in elements
void *items;
} mp_obj_array_t;
STATIC mp_obj_t array_iterator_new(mp_obj_t array_in);
STATIC mp_obj_array_t *array_new(char typecode, uint n);
STATIC mp_obj_t array_append(mp_obj_t self_in, mp_obj_t arg);
/******************************************************************************/
/* array */
STATIC void array_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in, mp_print_kind_t kind) {
mp_obj_array_t *o = o_in;
if (o->typecode == BYTEARRAY_TYPECODE) {
print(env, "bytearray(b", o->typecode);
mp_str_print_quoted(print, env, o->items, o->len);
} else {
print(env, "array('%c'", o->typecode);
if (o->len > 0) {
print(env, ", [");
for (int i = 0; i < o->len; i++) {
if (i > 0) {
print(env, ", ");
}
mp_obj_print_helper(print, env, mp_binary_get_val_array(o->typecode, o->items, i), PRINT_REPR);
}
print(env, "]");
}
}
print(env, ")");
}
STATIC mp_obj_t array_construct(char typecode, mp_obj_t initializer) {
uint len;
// Try to create array of exact len if initializer len is known
mp_obj_t len_in = mp_obj_len_maybe(initializer);
if (len_in == MP_OBJ_NULL) {
len = 0;
} else {
len = MP_OBJ_SMALL_INT_VALUE(len_in);
}
mp_obj_array_t *array = array_new(typecode, len);
mp_obj_t iterable = mp_getiter(initializer);
mp_obj_t item;
int i = 0;
while ((item = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) {
if (len == 0) {
array_append(array, item);
} else {
mp_binary_set_val_array(typecode, array->items, i++, item);
}
}
return array;
}
STATIC mp_obj_t array_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
mp_arg_check_num(n_args, n_kw, 1, 2, false);
// get typecode
uint l;
const char *typecode = mp_obj_str_get_data(args[0], &l);
if (n_args == 1) {
// 1 arg: make an empty array
return array_new(*typecode, 0);
} else {
// 2 args: construct the array from the given iterator
return array_construct(*typecode, args[1]);
}
}
STATIC mp_obj_t bytearray_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
mp_arg_check_num(n_args, n_kw, 0, 1, false);
if (n_args == 0) {
// no args: construct an empty bytearray
return array_new(BYTEARRAY_TYPECODE, 0);
} else if (MP_OBJ_IS_SMALL_INT(args[0])) {
// 1 arg, an integer: construct a blank bytearray of that length
uint len = MP_OBJ_SMALL_INT_VALUE(args[0]);
mp_obj_array_t *o = array_new(BYTEARRAY_TYPECODE, len);
memset(o->items, 0, len);
return o;
} else {
// 1 arg, an iterator: construct the bytearray from that
return array_construct(BYTEARRAY_TYPECODE, args[0]);
}
}
STATIC mp_obj_t array_unary_op(int op, mp_obj_t o_in) {
mp_obj_array_t *o = o_in;
switch (op) {
case MP_UNARY_OP_BOOL: return MP_BOOL(o->len != 0);
case MP_UNARY_OP_LEN: return MP_OBJ_NEW_SMALL_INT(o->len);
default: return MP_OBJ_NOT_SUPPORTED;
}
}
STATIC mp_obj_t array_append(mp_obj_t self_in, mp_obj_t arg) {
assert(MP_OBJ_IS_TYPE(self_in, &mp_type_array) || MP_OBJ_IS_TYPE(self_in, &mp_type_bytearray));
mp_obj_array_t *self = self_in;
if (self->free == 0) {
int item_sz = mp_binary_get_size('@', self->typecode, NULL);
// TODO: alloc policy
self->free = 8;
self->items = m_realloc(self->items, item_sz * self->len, item_sz * (self->len + self->free));
mp_seq_clear(self->items, self->len + 1, self->len + self->free, item_sz);
}
mp_binary_set_val_array(self->typecode, self->items, self->len++, arg);
self->free--;
return mp_const_none; // return None, as per CPython
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(array_append_obj, array_append);
STATIC mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) {
if (value == MP_OBJ_NULL) {
// delete item
// TODO implement
// TODO: confirmed that both bytearray and array.array support
// slice deletion
return MP_OBJ_NOT_SUPPORTED;
} else {
mp_obj_array_t *o = self_in;
if (MP_OBJ_IS_TYPE(index_in, &mp_type_slice)) {
if (value != MP_OBJ_SENTINEL) {
// Only getting a slice is suported so far, not assignment
// TODO: confirmed that both bytearray and array.array support
// slice assignment (incl. of different size)
return MP_OBJ_NOT_SUPPORTED;
}
machine_uint_t start, stop;
if (!m_seq_get_fast_slice_indexes(o->len, index_in, &start, &stop)) {
assert(0);
}
mp_obj_array_t *res = array_new(o->typecode, stop - start);
int sz = mp_binary_get_size('@', o->typecode, NULL);
assert(sz > 0);
byte *p = o->items;
memcpy(res->items, p + start * sz, (stop - start) * sz);
return res;
} else {
uint index = mp_get_index(o->base.type, o->len, index_in, false);
if (value == MP_OBJ_SENTINEL) {
// load
return mp_binary_get_val_array(o->typecode, o->items, index);
} else {
// store
mp_binary_set_val_array(o->typecode, o->items, index, value);
return mp_const_none;
}
}
}
}
STATIC machine_int_t array_get_buffer(mp_obj_t o_in, mp_buffer_info_t *bufinfo, int flags) {
mp_obj_array_t *o = o_in;
bufinfo->buf = o->items;
bufinfo->len = o->len * mp_binary_get_size('@', o->typecode, NULL);
bufinfo->typecode = o->typecode;
return 0;
}
STATIC const mp_map_elem_t array_locals_dict_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR_append), (mp_obj_t)&array_append_obj },
};
STATIC MP_DEFINE_CONST_DICT(array_locals_dict, array_locals_dict_table);
const mp_obj_type_t mp_type_array = {
{ &mp_type_type },
.name = MP_QSTR_array,
.print = array_print,
.make_new = array_make_new,
.getiter = array_iterator_new,
.unary_op = array_unary_op,
.subscr = array_subscr,
.buffer_p = { .get_buffer = array_get_buffer },
.locals_dict = (mp_obj_t)&array_locals_dict,
};
const mp_obj_type_t mp_type_bytearray = {
{ &mp_type_type },
.name = MP_QSTR_bytearray,
.print = array_print,
.make_new = bytearray_make_new,
.getiter = array_iterator_new,
.unary_op = array_unary_op,
.subscr = array_subscr,
.buffer_p = { .get_buffer = array_get_buffer },
.locals_dict = (mp_obj_t)&array_locals_dict,
};
STATIC mp_obj_array_t *array_new(char typecode, uint n) {
int typecode_size = mp_binary_get_size('@', typecode, NULL);
if (typecode_size <= 0) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "bad typecode"));
}
mp_obj_array_t *o = m_new_obj(mp_obj_array_t);
o->base.type = (typecode == BYTEARRAY_TYPECODE) ? &mp_type_bytearray : &mp_type_array;
o->typecode = typecode;
o->free = 0;
o->len = n;
o->items = m_malloc(typecode_size * o->len);
return o;
}
uint mp_obj_array_len(mp_obj_t self_in) {
return ((mp_obj_array_t *)self_in)->len;
}
mp_obj_t mp_obj_new_bytearray(uint n, void *items) {
mp_obj_array_t *o = array_new(BYTEARRAY_TYPECODE, n);
memcpy(o->items, items, n);
return o;
}
// Create bytearray which references specified memory area
mp_obj_t mp_obj_new_bytearray_by_ref(uint n, void *items) {
mp_obj_array_t *o = m_new_obj(mp_obj_array_t);
o->base.type = &mp_type_array;
o->typecode = BYTEARRAY_TYPECODE;
o->free = 0;
o->len = n;
o->items = items;
return o;
}
/******************************************************************************/
/* array iterator */
typedef struct _mp_obj_array_it_t {
mp_obj_base_t base;
mp_obj_array_t *array;
machine_uint_t cur;
} mp_obj_array_it_t;
STATIC mp_obj_t array_it_iternext(mp_obj_t self_in) {
mp_obj_array_it_t *self = self_in;
if (self->cur < self->array->len) {
return mp_binary_get_val_array(self->array->typecode, self->array->items, self->cur++);
} else {
return MP_OBJ_STOP_ITERATION;
}
}
STATIC const mp_obj_type_t array_it_type = {
{ &mp_type_type },
.name = MP_QSTR_iterator,
.getiter = mp_identity,
.iternext = array_it_iternext,
};
STATIC mp_obj_t array_iterator_new(mp_obj_t array_in) {
mp_obj_array_t *array = array_in;
mp_obj_array_it_t *o = m_new_obj(mp_obj_array_it_t);
o->base.type = &array_it_type;
o->array = array;
o->cur = 0;
return o;
}
| 33.425532 | 121 | 0.613834 |
208212f62dab270305ebed5091fc8861094ec0e3 | 1,971 | h | C | analytics/src/analytics_common.h | crazyhappygame/firebase-cpp-sdk | e8aeb120d2a2e9fa314d7965391d841ebf1c3915 | [
"Apache-2.0"
] | 1 | 2021-02-14T19:09:51.000Z | 2021-02-14T19:09:51.000Z | analytics/src/analytics_common.h | crazyhappygame/firebase-cpp-sdk | e8aeb120d2a2e9fa314d7965391d841ebf1c3915 | [
"Apache-2.0"
] | null | null | null | analytics/src/analytics_common.h | crazyhappygame/firebase-cpp-sdk | e8aeb120d2a2e9fa314d7965391d841ebf1c3915 | [
"Apache-2.0"
] | 1 | 2020-08-16T11:53:44.000Z | 2020-08-16T11:53:44.000Z | /*
* Copyright 2018 Google LLC
*
* 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 FIREBASE_ANALYTICS_CLIENT_CPP_SRC_ANALYTICS_COMMON_H__
#define FIREBASE_ANALYTICS_CLIENT_CPP_SRC_ANALYTICS_COMMON_H__
#include "app/src/reference_counted_future_impl.h"
namespace firebase {
namespace analytics {
namespace internal {
enum AnalyticsFn { kAnalyticsFnGetAnalyticsInstanceId, kAnalyticsFnCount };
// Data structure which holds the Future API for this module.
class FutureData {
public:
FutureData() : api_(kAnalyticsFnCount) {}
~FutureData() {}
ReferenceCountedFutureImpl* api() { return &api_; }
// Create FutureData singleton.
static FutureData* Create();
// Destroy the FutureData singleton.
static void Destroy();
// Get the Future data singleton.
static FutureData* Get();
private:
ReferenceCountedFutureImpl api_;
static FutureData* s_future_data_;
};
extern const char* kAnalyticsModuleName;
// Registers a cleanup task for this module if auto-initialization is disabled.
void RegisterTerminateOnDefaultAppDestroy();
// Unregisters the cleanup task for this module if auto-initialization is
// disabled.
void UnregisterTerminateOnDefaultAppDestroy();
// Determine whether the analytics module is initialized.
// This is implemented per platform.
bool IsInitialized();
} // namespace internal
} // namespace analytics
} // namespace firebase
#endif // FIREBASE_ANALYTICS_CLIENT_CPP_SRC_ANALYTICS_COMMON_H__
| 29.41791 | 79 | 0.773212 |
208710bc772711e817dd513287ac0a5b44147d91 | 161 | c | C | Validation/pyFrame3DD-master/gcc-master/gcc/testsuite/c-c++-common/Wconversion-pr40752b.c | djamal2727/Main-Bearing-Analytical-Model | 2f00c2219c71be0175c6f4f8f1d4cca231d97096 | [
"Apache-2.0"
] | null | null | null | Validation/pyFrame3DD-master/gcc-master/gcc/testsuite/c-c++-common/Wconversion-pr40752b.c | djamal2727/Main-Bearing-Analytical-Model | 2f00c2219c71be0175c6f4f8f1d4cca231d97096 | [
"Apache-2.0"
] | null | null | null | Validation/pyFrame3DD-master/gcc-master/gcc/testsuite/c-c++-common/Wconversion-pr40752b.c | djamal2727/Main-Bearing-Analytical-Model | 2f00c2219c71be0175c6f4f8f1d4cca231d97096 | [
"Apache-2.0"
] | null | null | null | // PR c++/40752
// { dg-additional-options -funsigned-char }
#pragma GCC diagnostic error "-Wsign-conversion"
void f(char *ar, int i)
{
ar[i] -= 'a' - 'A';
}
| 17.888889 | 48 | 0.614907 |
f5b95152948b2aae3a2bc04800b15a237535b083 | 3,399 | c | C | drivers/misc/wl127x-rfkill.c | tuxafgmur/OLD_Dhollmen_Kernel | 90ed4e2e3e6321de246fa193705ae40ede4e2d8e | [
"BSD-Source-Code"
] | 15 | 2018-04-02T12:41:27.000Z | 2021-06-26T13:13:43.000Z | drivers/misc/wl127x-rfkill.c | tuxafgmur/OLD_Dhollmen_Kernel | 90ed4e2e3e6321de246fa193705ae40ede4e2d8e | [
"BSD-Source-Code"
] | 1 | 2020-05-28T13:06:06.000Z | 2020-05-28T13:13:15.000Z | drivers/misc/wl127x-rfkill.c | tuxafgmur/OLD_Dhollmen_Kernel | 90ed4e2e3e6321de246fa193705ae40ede4e2d8e | [
"BSD-Source-Code"
] | 5 | 2018-05-16T16:36:08.000Z | 2020-11-04T05:51:11.000Z | /*
* Bluetooth TI wl127x rfkill power control via GPIO
*
* Copyright (C) 2009 Motorola, Inc.
* Copyright (C) 2008 Texas Instruments
* Initial code: Pavan Savoy <pavan.savoy@gmail.com> (wl127x_power.c)
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <linux/module.h>
#include <linux/init.h>
#include <linux/gpio.h>
#include <linux/rfkill.h>
#include <linux/platform_device.h>
#include <linux/wl127x-rfkill.h>
static int wl127x_rfkill_set_power(void *data, enum rfkill_state state)
{
int nshutdown_gpio = (int) data;
switch (state) {
case RFKILL_STATE_UNBLOCKED:
gpio_set_value(nshutdown_gpio, 1);
break;
case RFKILL_STATE_SOFT_BLOCKED:
gpio_set_value(nshutdown_gpio, 0);
break;
default:
printk(KERN_ERR "invalid bluetooth rfkill state %d\n", state);
}
return 0;
}
static int wl127x_rfkill_probe(struct platform_device *pdev)
{
int rc = 0;
struct wl127x_rfkill_platform_data *pdata = pdev->dev.platform_data;
enum rfkill_state default_state = RFKILL_STATE_SOFT_BLOCKED; /* off */
rc = gpio_request(pdata->nshutdown_gpio, "wl127x_nshutdown_gpio");
if (unlikely(rc))
return rc;
rc = gpio_direction_output(pdata->nshutdown_gpio, 0);
if (unlikely(rc))
return rc;
rfkill_set_default(RFKILL_TYPE_BLUETOOTH, default_state);
wl127x_rfkill_set_power(NULL, default_state);
pdata->rfkill = rfkill_allocate(&pdev->dev, RFKILL_TYPE_BLUETOOTH);
if (unlikely(!pdata->rfkill))
return -ENOMEM;
pdata->rfkill->name = "wl127x";
pdata->rfkill->state = default_state;
/* userspace cannot take exclusive control */
pdata->rfkill->user_claim_unsupported = 1;
pdata->rfkill->user_claim = 0;
pdata->rfkill->data = (void *) pdata->nshutdown_gpio;
pdata->rfkill->toggle_radio = wl127x_rfkill_set_power;
rc = rfkill_register(pdata->rfkill);
if (unlikely(rc))
rfkill_free(pdata->rfkill);
return 0;
}
static int wl127x_rfkill_remove(struct platform_device *pdev)
{
struct wl127x_rfkill_platform_data *pdata = pdev->dev.platform_data;
rfkill_unregister(pdata->rfkill);
rfkill_free(pdata->rfkill);
gpio_free(pdata->nshutdown_gpio);
return 0;
}
static struct platform_driver wl127x_rfkill_platform_driver = {
.probe = wl127x_rfkill_probe,
.remove = wl127x_rfkill_remove,
.driver = {
.name = "wl127x-rfkill",
.owner = THIS_MODULE,
},
};
static int __init wl127x_rfkill_init(void)
{
return platform_driver_register(&wl127x_rfkill_platform_driver);
}
static void __exit wl127x_rfkill_exit(void)
{
platform_driver_unregister(&wl127x_rfkill_platform_driver);
}
module_init(wl127x_rfkill_init);
module_exit(wl127x_rfkill_exit);
MODULE_ALIAS("platform:wl127x");
MODULE_DESCRIPTION("wl127x-rfkill");
MODULE_AUTHOR("Motorola");
MODULE_LICENSE("GPL");
| 27.860656 | 77 | 0.752868 |
6733d83ff53b5a17258b3dcdd02fe36162187bb6 | 480 | h | C | ch7_VO1/pose_estimation_3d3d/include/BA.h | ClovisChen/slam14 | 35fad23a491f2dd7666edab55ae849ac937d44c2 | [
"MIT"
] | null | null | null | ch7_VO1/pose_estimation_3d3d/include/BA.h | ClovisChen/slam14 | 35fad23a491f2dd7666edab55ae849ac937d44c2 | [
"MIT"
] | null | null | null | ch7_VO1/pose_estimation_3d3d/include/BA.h | ClovisChen/slam14 | 35fad23a491f2dd7666edab55ae849ac937d44c2 | [
"MIT"
] | null | null | null | //
// Created by chen-tian on 7/24/17.
//
#ifndef POSE_ESTIMATION_3D3D_BA_H
#define POSE_ESTIMATION_3D3D_BA_H
#include <opencv2/core/core.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace std;
using namespace cv;
class BA
{
public:
void bundleadjustment(
const vector<Point3f> pts1,
const vector<Point3f> pts2,
Mat& R,
Mat& t);
};
#endif //POSE_ESTIMATION_3D3D_BA_H
| 17.142857 | 44 | 0.68125 |
675f4f6f5b1387ce6d61169d16d65d721780d559 | 24,400 | c | C | pappl/printer-accessors.c | 2701gouravgoel/pappl | 31e5bc50f4b35b1fcdda393573c7eccf0fc80a4b | [
"Apache-2.0"
] | null | null | null | pappl/printer-accessors.c | 2701gouravgoel/pappl | 31e5bc50f4b35b1fcdda393573c7eccf0fc80a4b | [
"Apache-2.0"
] | null | null | null | pappl/printer-accessors.c | 2701gouravgoel/pappl | 31e5bc50f4b35b1fcdda393573c7eccf0fc80a4b | [
"Apache-2.0"
] | null | null | null | //
// Printer accessor functions for the Printer Application Framework
//
// Copyright © 2020 by Michael R Sweet.
//
// Licensed under Apache License v2.0. See the file "LICENSE" for more
// information.
//
//
// Include necessary headers...
//
#include "printer-private.h"
#include "system-private.h"
//
// 'papplPrinterCloseDevice()' - Close the device associated with the printer.
//
void
papplPrinterCloseDevice(
pappl_printer_t *printer) // I - Printer
{
if (!printer || !printer->device || !printer->device_in_use || printer->processing_job)
return;
pthread_rwlock_wrlock(&printer->rwlock);
papplDeviceClose(printer->device);
printer->device = NULL;
printer->device_in_use = false;
pthread_rwlock_unlock(&printer->rwlock);
}
//
// 'papplPrinterGetActiveJobs()' - Get the number of active (pending/processing) jobs.
//
int // O - Number of jobs
papplPrinterGetActiveJobs(
pappl_printer_t *printer) // I - Printer
{
int num_jobs = 0; // Number of jobs
if (printer)
{
pthread_rwlock_rdlock(&printer->rwlock);
num_jobs = cupsArrayCount(printer->active_jobs);
pthread_rwlock_unlock(&printer->rwlock);
}
return (num_jobs);
}
//
// 'papplPrinterGetContact()' - Get the "printer-contact" value.
//
pappl_contact_t * // O - Contact
papplPrinterGetContact(
pappl_printer_t *printer, // I - Printer
pappl_contact_t *contact) // O - Contact
{
if (!printer || !contact)
{
if (contact)
memset(contact, 0, sizeof(pappl_contact_t));
return (contact);
}
pthread_rwlock_rdlock(&printer->rwlock);
*contact = printer->contact;
pthread_rwlock_unlock(&printer->rwlock);
return (contact);
}
//
// 'papplPrinterGetDNSSDName()' - Get the current DNS-SD service name.
//
char * // O - DNS-SD service name or `NULL` for none
papplPrinterGetDNSSDName(
pappl_printer_t *printer, // I - Printer
char *buffer, // I - String buffer
size_t bufsize) // I - Size of string buffer
{
if (!printer || !printer->dns_sd_name || !buffer || bufsize == 0)
{
if (buffer)
*buffer = '\0';
return (NULL);
}
pthread_rwlock_rdlock(&printer->rwlock);
strlcpy(buffer, printer->dns_sd_name, bufsize);
pthread_rwlock_unlock(&printer->rwlock);
return (buffer);
}
//
// 'papplPrinterGetGeoLocation()' - Get the current geo-location as a "geo:" URI.
//
char * // O - "geo:" URI or `NULL` for unknown
papplPrinterGetGeoLocation(
pappl_printer_t *printer, // I - Printer
char *buffer, // I - String buffer
size_t bufsize) // I - Size of string buffer
{
if (!printer || !printer->geo_location || !buffer || bufsize == 0)
{
if (buffer)
*buffer = '\0';
return (NULL);
}
pthread_rwlock_rdlock(&printer->rwlock);
strlcpy(buffer, printer->geo_location, bufsize);
pthread_rwlock_unlock(&printer->rwlock);
return (buffer);
}
//
// 'papplPrinterGetID()' - Get the printer ID.
//
int // O - "printer-id" value or `0` for none
papplPrinterGetID(
pappl_printer_t *printer) // I - Printer
{
return (printer ? printer->printer_id : 0);
}
//
// 'papplPrinterGetImpressionsCompleted()' - Get the number of impressions (sides) that have been printed.
//
int // O - Number of printed impressions/sides
papplPrinterGetImpressionsCompleted(
pappl_printer_t *printer) // I - Printer
{
return (printer ? printer->impcompleted : 0);
}
//
// 'papplPrinterGetLocation()' - Get the location string.
//
char * // O - Location or `NULL` for none
papplPrinterGetLocation(
pappl_printer_t *printer, // I - Printer
char *buffer, // I - String buffer
size_t bufsize) // I - Size of string buffer
{
if (!printer || !printer->location || !buffer || bufsize == 0)
{
if (buffer)
*buffer = '\0';
return (NULL);
}
pthread_rwlock_rdlock(&printer->rwlock);
strlcpy(buffer, printer->location, bufsize);
pthread_rwlock_unlock(&printer->rwlock);
return (buffer);
}
//
// 'papplPrinterGetMaxActiveJobs()' - Get the maximum number of active (queued) jobs allowed by the printer.
//
int // O - Maximum number of active jobs
papplPrinterGetMaxActiveJobs(
pappl_printer_t *printer) // I - Printer
{
return (printer ? printer->max_active_jobs : 0);
}
//
// 'papplPrinterGetMaxCompletedJobs()' - Get the maximum number of jobs retained for history by the printer.
//
int // O - Maximum number of completed jobs
papplPrinterGetMaxCompletedJobs(
pappl_printer_t *printer) // I - Printer
{
return (printer ? printer->max_completed_jobs : 0);
}
//
// 'papplPrinterGetName()' - Get the printer name.
//
const char * // O - Printer name or `NULL` for none
papplPrinterGetName(
pappl_printer_t *printer) // I - Printer
{
return (printer ? printer->name : NULL);
}
//
// 'papplPrinterGetNextJobID()' - Get the next job ID.
//
int // O - Next job ID or `0` for none
papplPrinterGetNextJobID(
pappl_printer_t *printer) // I - Printer
{
return (printer ? printer->next_job_id : 0);
}
//
// 'papplPrinterGetNumberOfActiveJobs()' - Get the number of active print jobs.
//
int // O - Number of active print jobs
papplPrinterGetNumberOfActiveJobs(
pappl_printer_t *printer) // I - Printer
{
return (printer ? cupsArrayCount(printer->active_jobs) : 0);
}
//
// 'papplPrinterGetNumberOfCompletedJobs()' - Get the number of completed print jobs.
//
int // O - Number of completed print jobs
papplPrinterGetNumberOfCompletedJobs(
pappl_printer_t *printer) // I - Printer
{
return (printer ? cupsArrayCount(printer->completed_jobs) : 0);
}
//
// 'papplPrinterGetNumberOfJobs()' - Get the total number of print jobs.
//
int // O - Total number of print jobs
papplPrinterGetNumberOfJobs(
pappl_printer_t *printer) // I - Printer
{
return (printer ? cupsArrayCount(printer->all_jobs) : 0);
}
//
// 'papplPrinterGetOrganization()' - Get the organization name.
//
char * // O - Organization name or `NULL` for none
papplPrinterGetOrganization(
pappl_printer_t *printer, // I - Printer
char *buffer, // I - String buffer
size_t bufsize) // I - Size of string buffer
{
if (!printer || !printer->organization || !buffer || bufsize == 0)
{
if (buffer)
*buffer = '\0';
return (NULL);
}
pthread_rwlock_rdlock(&printer->rwlock);
strlcpy(buffer, printer->organization, bufsize);
pthread_rwlock_unlock(&printer->rwlock);
return (buffer);
}
//
// 'papplPrinterGetOrganizationalUnit()' - Get the organizational unit name.
//
char * // O - Organizational unit name or `NULL` for none
papplPrinterGetOrganizationalUnit(
pappl_printer_t *printer, // I - Printer
char *buffer, // I - String buffer
size_t bufsize) // I - Size of string buffer
{
if (!printer || !printer->org_unit || !buffer || bufsize == 0)
{
if (buffer)
*buffer = '\0';
return (NULL);
}
pthread_rwlock_rdlock(&printer->rwlock);
strlcpy(buffer, printer->org_unit, bufsize);
pthread_rwlock_unlock(&printer->rwlock);
return (buffer);
}
//
// 'papplPrinterGetPrintGroup()' - Get the print authorization group, if any.
//
char * // O - Print authorization group name or `NULL` for none
papplPrinterGetPrintGroup(
pappl_printer_t *printer, // I - Printer
char *buffer, // I - String buffer
size_t bufsize) // I - Size of string buffer
{
if (!printer || !printer->print_group || !buffer || bufsize == 0)
{
if (buffer)
*buffer = '\0';
return (NULL);
}
pthread_rwlock_rdlock(&printer->rwlock);
strlcpy(buffer, printer->print_group, bufsize);
pthread_rwlock_unlock(&printer->rwlock);
return (buffer);
}
//
// 'papplPrinterGetReasons()' - Get the current "printer-state-reasons" bit values.
//
pappl_preason_t // O - "printer-state-reasons" bit values
papplPrinterGetReasons(
pappl_printer_t *printer) // I - Printer
{
if (!printer)
return (PAPPL_PREASON_NONE);
if (!printer->device_in_use && !printer->processing_job && (time(NULL) - printer->status_time) > 1 && printer->driver_data.status)
{
// Update printer status...
(printer->driver_data.status)(printer);
printer->status_time = time(NULL);
}
return (printer->state_reasons);
}
//
// 'papplPrinterGetState()' - Get the current "printer-state" value.
//
ipp_pstate_t // O - "printer-state" value
papplPrinterGetState(
pappl_printer_t *printer) // I - Printer
{
return (printer ? printer->state : IPP_PSTATE_STOPPED);
}
//
// 'papplPrinterGetSupplies()' - Get the current "printer-supplies" values.
//
int // O - Number of values
papplPrinterGetSupplies(
pappl_printer_t *printer, // I - Printer
int max_supplies, // I - Maximum number of supplies
pappl_supply_t *supplies) // I - Array for supplies
{
int count; // Number of supplies
if (!printer || max_supplies < 0 || (max_supplies > 0 && !supplies))
return (0);
if (max_supplies == 0)
return (printer->num_supply);
memset(supplies, 0, (size_t)max_supplies * sizeof(pappl_supply_t));
pthread_rwlock_rdlock(&printer->rwlock);
if ((count = printer->num_supply) > max_supplies)
count = max_supplies;
memcpy(supplies, printer->supply, (size_t)count * sizeof(pappl_supply_t));
pthread_rwlock_unlock(&printer->rwlock);
return (count);
}
//
// 'papplPrinterGetSystem()' - Get the system associated with the printer.
//
pappl_system_t * // O - System
papplPrinterGetSystem(
pappl_printer_t *printer) // I - Printer
{
return (printer ? printer->system : NULL);
}
//
// 'papplPrinterGetType()' - Get the service type associated with the printer.
//
pappl_service_type_t // O - Service type
papplPrinterGetType(
pappl_printer_t *printer) // I - Printer
{
return (printer ? printer->type : PAPPL_SERVICE_TYPE_PRINT);
}
//
// 'papplPrinterIterateActiveJobs()' - Iterate over the active jobs.
//
void
papplPrinterIterateActiveJobs(
pappl_printer_t *printer, // I - Printer
pappl_job_cb_t cb, // I - Callback function
void *data, // I - Callback data
int job_index, // I - First job to iterate (1-based)
int limit) // I - Maximum jobs to iterate
{
pappl_job_t *job; // Current job
int count; // Number of jobs
if (!printer || !cb)
return;
pthread_rwlock_rdlock(&printer->rwlock);
for (job = (pappl_job_t *)cupsArrayIndex(printer->active_jobs, job_index - 1), count = 0; job; job = (pappl_job_t *)cupsArrayNext(printer->active_jobs), count ++)
{
if (limit == 0 || count < limit)
cb(job, data);
else
break;
}
pthread_rwlock_unlock(&printer->rwlock);
}
//
// 'papplPrinterIterateAllJobs()' - Iterate over all the jobs.
//
void
papplPrinterIterateAllJobs(
pappl_printer_t *printer, // I - Printer
pappl_job_cb_t cb, // I - Callback function
void *data, // I - Callback data
int job_index, // I - First job to iterate (1-based)
int limit) // I - Maximum jobs to iterate
{
pappl_job_t *job; // Current job
int count; // Number of jobs
if (!printer || !cb)
return;
pthread_rwlock_rdlock(&printer->rwlock);
for (job = (pappl_job_t *)cupsArrayIndex(printer->all_jobs, job_index - 1), count = 0; job; job = (pappl_job_t *)cupsArrayNext(printer->all_jobs), count ++)
{
if (limit == 0 || count < limit)
cb(job, data);
else
break;
}
pthread_rwlock_unlock(&printer->rwlock);
}
//
// 'papplPrinterIterateCompletedJobs()' - Iterate over the completed jobs.
//
void
papplPrinterIterateCompletedJobs(
pappl_printer_t *printer, // I - Printer
pappl_job_cb_t cb, // I - Callback function
void *data, // I - Callback data
int job_index, // I - First job to iterate (1-based)
int limit) // I - Maximum jobs to iterate
{
pappl_job_t *job; // Current job
int count; // Number of jobs
if (!printer || !cb)
return;
pthread_rwlock_rdlock(&printer->rwlock);
for (job = (pappl_job_t *)cupsArrayIndex(printer->completed_jobs, job_index - 1), count = 0; job; job = (pappl_job_t *)cupsArrayNext(printer->completed_jobs), count ++)
{
if (limit == 0 || count < limit)
cb(job, data);
else
break;
}
pthread_rwlock_unlock(&printer->rwlock);
}
//
// 'papplPrinterOpenDevice()' - Open the device associated with a printer.
//
pappl_device_t * // O - Device or `NULL` if not possible
papplPrinterOpenDevice(
pappl_printer_t *printer) // I - Printer
{
pappl_device_t *device = NULL; // Open device
if (!printer || printer->device_in_use || printer->processing_job || !printer->device_uri)
return (NULL);
pthread_rwlock_wrlock(&printer->rwlock);
if (!printer->device_in_use && !printer->processing_job)
{
printer->device = device = papplDeviceOpen(printer->device_uri, papplLogDevice, printer->system);
printer->device_in_use = device != NULL;
}
pthread_rwlock_wrlock(&printer->rwlock);
return (device);
}
//
// 'papplPrinterPause()' - Pause (stop) a printer.
//
// If the printer is currently processing (printing) a job, it will be
// completed before the printer is stopped.
//
void
papplPrinterPause(
pappl_printer_t *printer) // I - Printer
{
if (!printer)
return;
pthread_rwlock_wrlock(&printer->rwlock);
if (printer->processing_job)
printer->is_stopped = true;
else
printer->state = IPP_PSTATE_STOPPED;
pthread_rwlock_unlock(&printer->rwlock);
}
//
// 'papplPrinterResume()' - Resume (start) a printer.
//
void
papplPrinterResume(
pappl_printer_t *printer) // I - Printer
{
if (!printer)
return;
pthread_rwlock_wrlock(&printer->rwlock);
printer->is_stopped = false;
printer->state = IPP_PSTATE_IDLE;
pthread_rwlock_unlock(&printer->rwlock);
_papplPrinterCheckJobs(printer);
}
//
// 'papplPrinterSetContact()' - Set the "printer-contact" value.
//
void
papplPrinterSetContact(
pappl_printer_t *printer, // I - Printer
pappl_contact_t *contact) // I - Contact
{
if (!printer || !contact)
return;
pthread_rwlock_wrlock(&printer->rwlock);
printer->contact = *contact;
printer->config_time = time(NULL);
pthread_rwlock_unlock(&printer->rwlock);
_papplSystemConfigChanged(printer->system);
}
//
// 'papplPrinterSetDNSSDName()' - Set the DNS-SD service name.
//
void
papplPrinterSetDNSSDName(
pappl_printer_t *printer, // I - Printer
const char *value) // I - DNS-SD service name or `NULL` for none
{
if (!printer)
return;
pthread_rwlock_wrlock(&printer->rwlock);
free(printer->dns_sd_name);
printer->dns_sd_name = value ? strdup(value) : NULL;
printer->dns_sd_collision = false;
printer->dns_sd_serial = 0;
printer->config_time = time(NULL);
if (!value)
_papplPrinterUnregisterDNSSDNoLock(printer);
else
_papplPrinterRegisterDNSSDNoLock(printer);
pthread_rwlock_unlock(&printer->rwlock);
_papplSystemConfigChanged(printer->system);
}
//
// 'papplPrinterSetGeoLocation()' - Set the geo-location value as a "geo:" URI.
//
void
papplPrinterSetGeoLocation(
pappl_printer_t *printer, // I - Printer
const char *value) // I - "geo:" URI or `NULL` for unknown
{
if (!printer)
return;
pthread_rwlock_wrlock(&printer->rwlock);
free(printer->geo_location);
printer->geo_location = value ? strdup(value) : NULL;
printer->config_time = time(NULL);
_papplPrinterRegisterDNSSDNoLock(printer);
pthread_rwlock_unlock(&printer->rwlock);
_papplSystemConfigChanged(printer->system);
}
//
// 'papplPrinterSetImpressionsCompleted()' - Add impressions (sides) to the total count of printed impressions.
//
void
papplPrinterSetImpressionsCompleted(
pappl_printer_t *printer, // I - Printer
int add) // I - Number of impressions/sides to add
{
if (!printer || add <= 0)
return;
pthread_rwlock_wrlock(&printer->rwlock);
printer->impcompleted += add;
printer->state_time = time(NULL);
pthread_rwlock_unlock(&printer->rwlock);
_papplSystemConfigChanged(printer->system);
}
//
// 'papplPrinterSetLocation()' - Set the location string.
//
void
papplPrinterSetLocation(
pappl_printer_t *printer, // I - Printer
const char *value) // I - Location ("Bob's Office", etc.) or `NULL` for none
{
if (!printer)
return;
pthread_rwlock_wrlock(&printer->rwlock);
free(printer->location);
printer->location = value ? strdup(value) : NULL;
printer->config_time = time(NULL);
_papplPrinterRegisterDNSSDNoLock(printer);
pthread_rwlock_unlock(&printer->rwlock);
_papplSystemConfigChanged(printer->system);
}
//
// 'papplPrinterSetMaxActiveJobs()' - Set the maximum number of active jobs for the printer.
//
void
papplPrinterSetMaxActiveJobs(
pappl_printer_t *printer, // I - Printer
int max_active_jobs) // I - Maximum number of active jobs, `0` for unlimited
{
if (!printer || max_active_jobs < 0)
return;
pthread_rwlock_wrlock(&printer->rwlock);
printer->max_active_jobs = max_active_jobs;
printer->config_time = time(NULL);
pthread_rwlock_unlock(&printer->rwlock);
_papplSystemConfigChanged(printer->system);
}
//
// 'papplPrinterSetMaxCompletedJobs()' - Set the maximum number of completed jobs for the printer.
//
void
papplPrinterSetMaxCompletedJobs(
pappl_printer_t *printer, // I - Printer
int max_completed_jobs) // I - Maximum number of completed jobs, `0` for unlimited
{
if (!printer || max_completed_jobs < 0)
return;
pthread_rwlock_wrlock(&printer->rwlock);
printer->max_completed_jobs = max_completed_jobs;
printer->config_time = time(NULL);
pthread_rwlock_unlock(&printer->rwlock);
_papplSystemConfigChanged(printer->system);
}
//
// 'papplPrinterSetNextJobID()' - Set the next "job-id" value.
//
// Note: This function is normally only called once to restore the previous
// state of the printer.
//
void
papplPrinterSetNextJobID(
pappl_printer_t *printer, // I - Printer
int next_job_id) // I - Next "job-id" value
{
if (!printer || next_job_id < 1)
return;
pthread_rwlock_wrlock(&printer->rwlock);
printer->next_job_id = next_job_id;
printer->config_time = time(NULL);
pthread_rwlock_unlock(&printer->rwlock);
_papplSystemConfigChanged(printer->system);
}
//
// 'papplPrinterSetOrganization()' - Set the organization name.
//
void
papplPrinterSetOrganization(
pappl_printer_t *printer, // I - Printer
const char *value) // I - Organization name or `NULL` for none
{
if (!printer)
return;
pthread_rwlock_wrlock(&printer->rwlock);
free(printer->organization);
printer->organization = value ? strdup(value) : NULL;
printer->config_time = time(NULL);
pthread_rwlock_unlock(&printer->rwlock);
_papplSystemConfigChanged(printer->system);
}
//
// 'papplPrinterSetOrganizationalUnit()' - Set the organizational unit name.
//
void
papplPrinterSetOrganizationalUnit(
pappl_printer_t *printer, // I - Printer
const char *value) // I - Organizational unit name or `NULL` for none
{
if (!printer)
return;
pthread_rwlock_wrlock(&printer->rwlock);
free(printer->org_unit);
printer->org_unit = value ? strdup(value) : NULL;
printer->config_time = time(NULL);
pthread_rwlock_unlock(&printer->rwlock);
_papplSystemConfigChanged(printer->system);
}
//
// 'papplPrinterSetPrintDefaults()' - Set the default print option values.
//
// Note: Unlike @link papplPrinterSetPrintDriverData@, this function only changes
// the "xxx_default" member of the driver data and is considered lightweight.
//
void
papplPrinterSetPrintDefaults(
pappl_printer_t *printer, // I - Printer
pappl_pdriver_data_t *data) // I - Driver data
{
if (!printer || !data)
return;
pthread_rwlock_wrlock(&printer->rwlock);
printer->driver_data.color_default = data->color_default;
printer->driver_data.content_default = data->content_default;
printer->driver_data.quality_default = data->quality_default;
printer->driver_data.scaling_default = data->scaling_default;
printer->driver_data.sides_default = data->sides_default;
printer->driver_data.x_default = data->x_default;
printer->driver_data.y_default = data->y_default;
printer->driver_data.media_default = data->media_default;
printer->driver_data.speed_default = data->speed_default;
printer->driver_data.darkness_default = data->darkness_default;
printer->driver_data.mode_configured = data->mode_configured;
printer->driver_data.tear_offset_configured = data->tear_offset_configured;
printer->driver_data.darkness_configured = data->darkness_configured;
printer->driver_data.identify_default = data->identify_default;
printer->config_time = time(NULL);
pthread_rwlock_unlock(&printer->rwlock);
_papplSystemConfigChanged(printer->system);
}
//
// 'papplPrinterSetPrintGroup()' - Set the print authorization group, if any.
//
void
papplPrinterSetPrintGroup(
pappl_printer_t *printer, // I - Printer
const char *value) // I - Print authorization group or `NULL` for none
{
if (!printer)
return;
pthread_rwlock_wrlock(&printer->rwlock);
free(printer->print_group);
printer->print_group = value ? strdup(value) : NULL;
printer->config_time = time(NULL);
if (printer->print_group && strcmp(printer->print_group, "none"))
{
char buffer[8192]; // Buffer for strings
struct group grpbuf, // Group buffer
*grp = NULL; // Print group
if (getgrnam_r(printer->print_group, &grpbuf, buffer, sizeof(buffer), &grp) || !grp)
papplLogPrinter(printer, PAPPL_LOGLEVEL_ERROR, "Unable to find print group '%s'.", printer->print_group);
else
printer->print_gid = grp->gr_gid;
}
else
printer->print_gid = (gid_t)-1;
pthread_rwlock_unlock(&printer->rwlock);
_papplSystemConfigChanged(printer->system);
}
//
// 'papplPrinterSetReadyMedia()' - Set the ready (loaded) media.
//
void
papplPrinterSetReadyMedia(
pappl_printer_t *printer, // I - Printer
int num_ready, // I - Number of ready media
pappl_media_col_t *ready) // I - Array of ready media
{
if (!printer || num_ready <= 0 || !ready)
return;
pthread_rwlock_wrlock(&printer->rwlock);
if (num_ready > printer->driver_data.num_source)
num_ready = printer->driver_data.num_source;
memset(printer->driver_data.media_ready, 0, sizeof(printer->driver_data.media_ready));
memcpy(printer->driver_data.media_ready, ready, (size_t)num_ready * sizeof(pappl_media_col_t));
printer->state_time = time(NULL);
pthread_rwlock_unlock(&printer->rwlock);
_papplSystemConfigChanged(printer->system);
}
//
// 'papplPrinterSetReasons()' - Add or remove values from "printer-state-reasons".
//
void
papplPrinterSetReasons(
pappl_printer_t *printer, // I - Printer
pappl_preason_t add, // I - "printer-state-reasons" bit values to add or `PAPPL_PREASON_NONE` for none
pappl_preason_t remove) // I - "printer-state-reasons" bit values to remove or `PAPPL_PREASON_NONE` for none
{
if (!printer)
return;
pthread_rwlock_wrlock(&printer->rwlock);
printer->state_reasons &= ~remove;
printer->state_reasons |= add;
printer->state_time = printer->status_time = time(NULL);
pthread_rwlock_unlock(&printer->rwlock);
}
//
// 'papplPrinterSetSupplies()' - Set/update the supplies for a printer.
//
void
papplPrinterSetSupplies(
pappl_printer_t *printer, // I - Printer
int num_supplies, // I - Number of supplies
pappl_supply_t *supplies) // I - Array of supplies
{
if (!printer || num_supplies < 0 || num_supplies > PAPPL_MAX_SUPPLY || (num_supplies > 0 && !supplies))
return;
pthread_rwlock_wrlock(&printer->rwlock);
printer->num_supply = num_supplies;
memset(printer->supply, 0, sizeof(printer->supply));
if (supplies)
memcpy(printer->supply, supplies, num_supplies * sizeof(pappl_supply_t));
printer->state_time = time(NULL);
pthread_rwlock_unlock(&printer->rwlock);
}
| 23.945044 | 170 | 0.675246 |
e59acef71efe6e76a69f2bbc2159fe6ef2a64a7b | 6,791 | h | C | include/nuttx/analog/ltc1867l.h | eenurkka/incubator-nuttx | 5c3d6bba6d9ec5015896c3019cd2064696373210 | [
"Apache-2.0"
] | 1,006 | 2019-12-17T23:45:41.000Z | 2022-03-31T19:42:44.000Z | include/nuttx/analog/ltc1867l.h | eenurkka/incubator-nuttx | 5c3d6bba6d9ec5015896c3019cd2064696373210 | [
"Apache-2.0"
] | 2,661 | 2019-12-21T15:16:09.000Z | 2022-03-31T22:30:04.000Z | include/nuttx/analog/ltc1867l.h | eenurkka/incubator-nuttx | 5c3d6bba6d9ec5015896c3019cd2064696373210 | [
"Apache-2.0"
] | 613 | 2019-12-21T10:17:37.000Z | 2022-03-28T09:42:20.000Z | /****************************************************************************
* include/nuttx/analog/ltc1867l.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __INCLUDE_NUTTX_ANALOG_LTC1867L_H
#define __INCLUDE_NUTTX_ANALOG_LTC1867L_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/spi/spi.h>
#include <stdint.h>
#if defined(CONFIG_ADC_LTC1867L)
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* LTC1867L Configuration ***************************************************/
#define LTC1867L_CONFIG_BIT_SLP (1 << 1)
#define LTC1867L_CONFIG_BIT_UNI (1 << 2)
#define LTC1867L_CONFIG_BIT_COM (1 << 3)
#define LTC1867L_CONFIG_BIT_S0 (1 << 4)
#define LTC1867L_CONFIG_BIT_S1 (1 << 5)
#define LTC1867L_CONFIG_BIT_OS (1 << 6)
#define LTC1867L_CONFIG_BIT_SD (1 << 7)
/****************************************************************************
* Public Types
****************************************************************************/
enum ltc1867l_analog_multiplexer_config_e
{
LTC1867L_P_CH0_M_CH1 = 0,
LTC1867L_P_CH2_M_CH3 = LTC1867L_CONFIG_BIT_S0,
LTC1867L_P_CH4_M_CH5 = LTC1867L_CONFIG_BIT_S1,
LTC1867L_P_CH6_M_CH7 = LTC1867L_CONFIG_BIT_S1 |
LTC1867L_CONFIG_BIT_S0,
LTC1867L_P_CH1_M_CH0 = LTC1867L_CONFIG_BIT_OS,
LTC1867L_P_CH3_M_CH2 = LTC1867L_CONFIG_BIT_OS |
LTC1867L_CONFIG_BIT_S0,
LTC1867L_P_CH5_M_CH4 = LTC1867L_CONFIG_BIT_OS |
LTC1867L_CONFIG_BIT_S1,
LTC1867L_P_CH7_M_CH6 = LTC1867L_CONFIG_BIT_OS |
LTC1867L_CONFIG_BIT_S1 |
LTC1867L_CONFIG_BIT_S0,
LTC1867L_P_CH0_M_GND = LTC1867L_CONFIG_BIT_SD,
LTC1867L_P_CH2_M_GND = LTC1867L_CONFIG_BIT_SD |
LTC1867L_CONFIG_BIT_S0,
LTC1867L_P_CH4_M_GND = LTC1867L_CONFIG_BIT_SD |
LTC1867L_CONFIG_BIT_S1,
LTC1867L_P_CH6_M_GND = LTC1867L_CONFIG_BIT_SD |
LTC1867L_CONFIG_BIT_S1 |
LTC1867L_CONFIG_BIT_S0,
LTC1867L_P_CH1_M_GND = LTC1867L_CONFIG_BIT_SD |
LTC1867L_CONFIG_BIT_OS,
LTC1867L_P_CH3_M_GND = LTC1867L_CONFIG_BIT_SD |
LTC1867L_CONFIG_BIT_OS |
LTC1867L_CONFIG_BIT_S0,
LTC1867L_P_CH5_M_GND = LTC1867L_CONFIG_BIT_SD |
LTC1867L_CONFIG_BIT_OS |
LTC1867L_CONFIG_BIT_S1,
LTC1867L_P_CH7_M_GND = LTC1867L_CONFIG_BIT_SD |
LTC1867L_CONFIG_BIT_OS |
LTC1867L_CONFIG_BIT_S1 |
LTC1867L_CONFIG_BIT_S0,
LTC1867L_P_CH0_M_CH7COM = LTC1867L_CONFIG_BIT_SD |
LTC1867L_CONFIG_BIT_COM,
LTC1867L_P_CH2_M_CH7COM = LTC1867L_CONFIG_BIT_SD |
LTC1867L_CONFIG_BIT_S0 |
LTC1867L_CONFIG_BIT_COM,
LTC1867L_P_CH4_M_CH7COM = LTC1867L_CONFIG_BIT_SD |
LTC1867L_CONFIG_BIT_S1 |
LTC1867L_CONFIG_BIT_COM,
LTC1867L_P_CH6_M_CH7COM = LTC1867L_CONFIG_BIT_SD |
LTC1867L_CONFIG_BIT_S1 |
LTC1867L_CONFIG_BIT_S0 |
LTC1867L_CONFIG_BIT_COM,
LTC1867L_P_CH1_M_CH7COM = LTC1867L_CONFIG_BIT_SD |
LTC1867L_CONFIG_BIT_OS |
LTC1867L_CONFIG_BIT_COM,
LTC1867L_P_CH3_M_CH7COM = LTC1867L_CONFIG_BIT_SD |
LTC1867L_CONFIG_BIT_OS |
LTC1867L_CONFIG_BIT_S0 |
LTC1867L_CONFIG_BIT_COM,
LTC1867L_P_CH5_M_CH7COM = LTC1867L_CONFIG_BIT_SD |
LTC1867L_CONFIG_BIT_OS |
LTC1867L_CONFIG_BIT_S1 |
LTC1867L_CONFIG_BIT_COM
};
enum ltc1867l_analog_input_mode_e
{
LTC1867L_UNIPOLAR = LTC1867L_CONFIG_BIT_UNI,
LTC1867L_BIPOLAR = 0,
};
begin_packed_struct struct ltc1867l_channel_config_s
{
uint8_t channel; /* This will be the channel number returned in struct adc_msg_s for a conversion */
enum ltc1867l_analog_multiplexer_config_e analog_multiplexer_config; /* Analog multiplexer configuration */
enum ltc1867l_analog_input_mode_e analog_inputmode; /* Analog input mode */
} end_packed_struct;
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: ltc1867l_register
*
* Description:
* Register the LTC1867L character device as 'devpath'
*
* Input Parameters:
* devpath - The full path to the driver to register. E.g., "/dev/adc0"
* spi - An instance of the SPI interface to use to communicate with
* LTC1867L
* devno - SPI device number
* channel_config - A pointer to an array which holds the configuration
* for each sampled channel.
* channel_config_count - Number of channels to sample
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
int ltc1867l_register(FAR const char *devpath, FAR struct spi_dev_s *spi,
unsigned int devno,
FAR struct ltc1867l_channel_config_s *channel_config,
int channel_config_count);
#endif /* CONFIG_ADC_LTC1867L */
#endif /* __INCLUDE_NUTTX_ANALOG_LTC1867L_H */
| 43.532051 | 154 | 0.564424 |
0b872f142588a95f41a10827525b67d3c8d7ee3f | 747 | h | C | classes/Edible.h | Daria602/AdventureIn10 | 4ad0418d4020cfb552a5cb1ab894ffa895caab3e | [
"MIT"
] | 1 | 2021-05-03T12:29:52.000Z | 2021-05-03T12:29:52.000Z | classes/Edible.h | Daria602/AdventureIn10 | 4ad0418d4020cfb552a5cb1ab894ffa895caab3e | [
"MIT"
] | null | null | null | classes/Edible.h | Daria602/AdventureIn10 | 4ad0418d4020cfb552a5cb1ab894ffa895caab3e | [
"MIT"
] | null | null | null | #pragma once
#include <iostream>
#include <string>
#include <vector>
class Edible
{
private:
std::string name;
int replenishStamina;
int replenishHealth;
friend std::ostream& operator<<(std::ostream& os, const Edible& go_);
public:
Edible() { this->name = "NONE"; this->replenishStamina = 0; this->replenishHealth = 0; }
Edible(std::string name, int replenishStamina, int replenishHealth) { this->name = name; this->replenishStamina = replenishStamina; this->replenishHealth = replenishHealth; }
Edible(const Edible& go_);
virtual ~Edible();
std::string getName() { return this->name; }
int getReplenishStamina() { return this->replenishStamina; }
int getReplenishHealth() { return this->replenishHealth; }
};
| 31.125 | 176 | 0.708166 |
1bbd8e3cad4fc65df51647130cb48f694306bea2 | 1,224 | c | C | lab04/lab04.c | tiagodalloca/mc458-labs | e71230bb7188af8e65289f322e1f8fffa42ca2ec | [
"MIT"
] | null | null | null | lab04/lab04.c | tiagodalloca/mc458-labs | e71230bb7188af8e65289f322e1f8fffa42ca2ec | [
"MIT"
] | null | null | null | lab04/lab04.c | tiagodalloca/mc458-labs | e71230bb7188af8e65289f322e1f8fffa42ca2ec | [
"MIT"
] | null | null | null | #include <stdio.h>
#include <stdlib.h>
typedef struct {
int i, p;
} tarefa ;
short int compare_tarefa(tarefa a, tarefa b) {
if (a.p > b.p) return 1;
if (a.p < b.p) return -1;
return a.i <= b.i ? -1 : 1;
}
void swap(tarefa arr[], int i, int j) {
tarefa aux = arr[i];
arr[i] = arr[j];
arr[j] = aux;
}
int partition (tarefa arr[], int start, int end) {
tarefa p = arr[end];
int i = (start - 1);
for (int j = start; j <= end - 1; j++) {
if (compare_tarefa(arr[j], p) < 0) {
i++;
swap(arr, i, j);
}
}
swap(arr, i + 1, end);
return i + 1;
}
void quicksort(tarefa arr[], int start, int end) {
if (start < end) {
int p = partition(arr, start, end);
quicksort(arr, start, p - 1);
quicksort(arr, p + 1, end);
}
}
int main() {
int n;
scanf("%d", &n);
tarefa tarefas[n];
for (int i = 0; i < n; i++) {
int p;
scanf("%d", &p);
tarefas[i] = (tarefa) { i + 1, p};
}
quicksort(tarefas, 0, n - 1);
int cs[n];
int c = 0;
for (int i = 0; i < n; i++) {
c = c + tarefas[i].p;
cs[i] = c;
}
c = 0;
for (int i = 0; i < n; i++) {
c += cs[i];
}
printf("%d\n", c);
printf("%d", tarefas[0].i);
for (int i = 1; i < n; i++) {
printf(" %d", tarefas[i].i);
}
printf("\n");
}
| 15.896104 | 50 | 0.502451 |
1be47f905ca8a4574da05b63c3a1e045a6a8056b | 382 | c | C | ext/hal/silabs/gecko/emlib/src/em_timer.c | dmgerman/zephyrd3 | b6a23cc9c5d534c352e33fd18fff7799ac3c2886 | [
"Apache-2.0"
] | null | null | null | ext/hal/silabs/gecko/emlib/src/em_timer.c | dmgerman/zephyrd3 | b6a23cc9c5d534c352e33fd18fff7799ac3c2886 | [
"Apache-2.0"
] | null | null | null | ext/hal/silabs/gecko/emlib/src/em_timer.c | dmgerman/zephyrd3 | b6a23cc9c5d534c352e33fd18fff7799ac3c2886 | [
"Apache-2.0"
] | null | null | null | DECL|TIMER_InitCC|function|void TIMER_InitCC(TIMER_TypeDef *timer, unsigned int ch, const TIMER_InitCC_TypeDef *init)
DECL|TIMER_InitDTI|function|void TIMER_InitDTI(TIMER_TypeDef *timer, const TIMER_InitDTI_TypeDef *init)
DECL|TIMER_Init|function|void TIMER_Init(TIMER_TypeDef *timer, const TIMER_Init_TypeDef *init)
DECL|TIMER_Reset|function|void TIMER_Reset(TIMER_TypeDef *timer)
| 76.4 | 117 | 0.856021 |
5696723f5d47d517e70ecb451774115e07babe8e | 1,279 | c | C | libft/ft_strmapi.c | Himak1/push_swap | 5e7909921347e793917f72a3ac3bfc576d5a07c0 | [
"MIT"
] | null | null | null | libft/ft_strmapi.c | Himak1/push_swap | 5e7909921347e793917f72a3ac3bfc576d5a07c0 | [
"MIT"
] | null | null | null | libft/ft_strmapi.c | Himak1/push_swap | 5e7909921347e793917f72a3ac3bfc576d5a07c0 | [
"MIT"
] | null | null | null | /* ************************************************************************** */
/* */
/* :::::::: */
/* ft_strmapi.c :+: :+: */
/* +:+ */
/* By: jhille <marvin@codam.nl> +#+ */
/* +#+ */
/* Created: 2020/11/02 00:02:57 by jhille #+# #+# */
/* Updated: 2020/11/25 21:07:52 by jhille ######## odam.nl */
/* */
/* ************************************************************************** */
#include <stdlib.h>
char *ft_strmapi(char const *str, char (*f)(unsigned int, char))
{
unsigned int i;
unsigned int j;
char *ret;
if (str == 0 || f == 0)
return (NULL);
i = 0;
j = 0;
while (str[j] != '\0')
j++;
ret = malloc(j + 1 * sizeof(char));
if (ret == NULL)
return (NULL);
while (i < j)
{
ret[i] = (*f)(i, str[i]);
i++;
}
ret[i] = '\0';
return (ret);
}
| 33.657895 | 80 | 0.228303 |
73034f75177475a9369dad49778099bc9c00f2d1 | 1,781 | c | C | driver/main.c | chaos-mesh/chaos-driver | 00ff8f5bffd01e4752fcaadb383430b2bde82a8b | [
"Apache-2.0"
] | 5 | 2021-12-29T03:28:36.000Z | 2022-02-21T06:59:00.000Z | driver/main.c | chaos-mesh/chaos-driver | 00ff8f5bffd01e4752fcaadb383430b2bde82a8b | [
"Apache-2.0"
] | null | null | null | driver/main.c | chaos-mesh/chaos-driver | 00ff8f5bffd01e4752fcaadb383430b2bde82a8b | [
"Apache-2.0"
] | null | null | null | // Copyright 2021 Chaos Mesh Authors.
//
// 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,
// See the License for the specific language governing permissions and
// limitations under the License.
#include <linux/fs.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/printk.h>
#include <linux/device.h>
#include <linux/delay.h>
#include <linux/fdtable.h>
struct elevator_queue;
struct request;
#include <linux/elevator.h>
#include "config.h"
#include "chaos_device.h"
#include "injection.h"
#include "ioem.h"
static int __init chaos_main(void)
{
// Return value of the function
int ret = 0;
pr_info(MODULE_NAME " is loading \n");
ret = register_chaos_device();
if (ret < 0)
{
pr_err(MODULE_NAME ": register_chaos_device failed \n");
goto err;
}
ret = ioem_register();
if (ret < 0)
{
pr_err(MODULE_NAME ": register_chaos_device failed \n");
goto err;
}
err:
return ret;
}
static void __exit chaos_exit(void)
{
int ret = 0;
pr_info(MODULE_NAME " is unloading \n");
ret = recover_all();
if (ret != 0)
{
pr_err(MODULE_NAME ": fail to recover all injection\n");
}
unregister_chaos_device();
ioem_unregister();
}
module_init(chaos_main);
module_exit(chaos_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Chaos Mesh Authors");
MODULE_DESCRIPTION("Injection delay or errors into the system"); | 23.12987 | 70 | 0.681078 |
14be308e3a0ec9986dd44e7dd937d0d107d425da | 973 | c | C | src/convexHull/convexHull.c | jobtalle/ConvexHull | 26c91b0491a891e5a70bca8185ba3b98c7429ab1 | [
"BSD-3-Clause"
] | 13 | 2015-11-16T16:00:18.000Z | 2020-02-08T15:52:08.000Z | src/convexHull/convexHull.c | jobtalle/ConvexHull | 26c91b0491a891e5a70bca8185ba3b98c7429ab1 | [
"BSD-3-Clause"
] | 1 | 2015-12-22T13:57:32.000Z | 2015-12-22T13:57:32.000Z | src/convexHull/convexHull.c | jobtalle/ConvexHull | 26c91b0491a891e5a70bca8185ba3b98c7429ab1 | [
"BSD-3-Clause"
] | 4 | 2015-11-19T17:04:11.000Z | 2022-03-20T06:22:56.000Z | #include <stdlib.h>
#include "passes.h"
static uint32_t convexHullRayCount(const uint32_t width, const uint32_t height, const uint32_t spacing)
{
return (width + height) / (spacing >> 1);
}
convexHull convexHullCreate(const uint8_t *source, const uint32_t width, const uint32_t height, const convexHullVector pivot, const uint32_t spacing, const float precision)
{
convexHull convexHull;
convexHull.nodeCount = convexHullRayCount(width, height, spacing);
convexHull.nodes = malloc(sizeof(convexHullVector)* convexHull.nodeCount);
// Crop image
convexHullCrop(&convexHull, source, width, height, pivot);
// Trim insignificant nodes
convexHullTrimInsignificantNodes(&convexHull, precision);
// Graham scan
convexHullGrahamScan(&convexHull);
// Realloc trimmed graph
convexHull.nodes = realloc(convexHull.nodes, sizeof(convexHullVector)* convexHull.nodeCount);
return convexHull;
}
void convexHullFree(convexHull convexHull)
{
free(convexHull.nodes);
} | 27.8 | 172 | 0.784173 |
1af65fcb05db3d539a75e08e5df90093ec45ad03 | 1,292 | c | C | main.c | yasuharu/comp_lock | c6a0ac28773e9e97ba5c524ef90153eaaa9e60a3 | [
"MIT"
] | null | null | null | main.c | yasuharu/comp_lock | c6a0ac28773e9e97ba5c524ef90153eaaa9e60a3 | [
"MIT"
] | null | null | null | main.c | yasuharu/comp_lock | c6a0ac28773e9e97ba5c524ef90153eaaa9e60a3 | [
"MIT"
] | null | null | null | #include <stdio.h>
#include <pthread.h>
#include <semaphore.h>
#include <stdint.h>
// #define USE_PTHREAD
// #define USE_SEMAPHORE
#if (defined(USE_PTHREAD) && defined(USE_SEMAPHORE))
#error "env setting is wrong."
#endif
#define THREAD_NUM (5)
pthread_t threads[THREAD_NUM];
#ifdef USE_PTHREAD
pthread_mutex_t mutex;
void lock_init()
{
pthread_mutex_init(&mutex, NULL);
}
void lock_destroy()
{
pthread_mutex_destroy(&mutex);
}
void lock()
{
pthread_mutex_lock(&mutex);
}
void unlock()
{
pthread_mutex_unlock(&mutex);
}
#endif
#ifdef USE_SEMAPHORE
sem_t sem;
void lock_init()
{
sem_init(&sem, 0, 1);
}
void lock_destroy()
{
sem_destroy(&sem);
}
void lock()
{
sem_wait(&sem);
}
void unlock()
{
sem_post(&sem);
}
#endif
uint64_t value = 0;
#define END_COUNT (0x3FFFFFFL)
void *run(void *arg)
{
while(1)
{
lock();
value++;
if(value > END_COUNT)
{
unlock();
break;
}
unlock();
}
return NULL;
}
int main()
{
int i;
lock_init();
for(i = 0 ; i != THREAD_NUM ; i++)
{
pthread_create(&threads[i], NULL, run, NULL);
}
for(i = 0 ; i != THREAD_NUM ; i++)
{
pthread_join(threads[i], NULL);
}
lock_destroy();
}
| 12.423077 | 53 | 0.584365 |
5dc46ece3a0703a3f0d932776530581f72da2455 | 10,621 | h | C | src/include/mpichtimer.h | valiantljk/collectiveIO-profile | 844f6296384459a41ae889cbe5a67e3f9da4b923 | [
"Unlicense"
] | null | null | null | src/include/mpichtimer.h | valiantljk/collectiveIO-profile | 844f6296384459a41ae889cbe5a67e3f9da4b923 | [
"Unlicense"
] | null | null | null | src/include/mpichtimer.h | valiantljk/collectiveIO-profile | 844f6296384459a41ae889cbe5a67e3f9da4b923 | [
"Unlicense"
] | null | null | null | /* -*- Mode: C; c-basic-offset:4 ; -*- */
/*
* (C) 2001 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
#ifndef MPICHTIMER_H
#define MPICHTIMER_H
/*
* This include file provide the definitions that are necessary to use the
* timer calls, including the definition of the time stamp type and
* any inlined timer calls.
*
* The include file timerconf.h (created by autoheader from configure.ac)
* is needed only to build the function versions of the timers.
*/
/* Include the appropriate files */
#define USE_GETHRTIME 1
#define USE_CLOCK_GETTIME 2
#define USE_GETTIMEOFDAY 3
#define USE_LINUX86_CYCLE 4
#define USE_LINUXALPHA_CYCLE 5
#define USE_QUERYPERFORMANCECOUNTER 6
#define USE_WIN86_CYCLE 7
#define USE_GCC_IA64_CYCLE 8
/* The value "USE_DEVICE" means that the ADI device provides the timer */
#define USE_DEVICE 9
#define USE_WIN64_CYCLE 10
#define USE_MACH_ABSOLUTE_TIME 11
#define MPICH_TIMER_KIND USE_GETTIMEOFDAY
#if MPICH_TIMER_KIND == USE_GETHRTIME
#include <sys/time.h>
#elif MPICH_TIMER_KIND == USE_CLOCK_GETTIME
#include <time.h>
#ifdef NEEDS_SYS_TIME_H
/* Some OS'es mistakenly require sys/time.h to get the definition of
CLOCK_REALTIME (POSIX requires the definition to be in time.h) */
#include <sys/time.h>
#endif
#elif MPICH_TIMER_KIND == USE_GETTIMEOFDAY
#include <sys/types.h>
#include <sys/time.h>
#elif MPICH_TIMER_KIND == USE_LINUX86_CYCLE
#elif MPICH_TIMER_KIND == USE_GCC_IA64_CYCLE
#elif MPICH_TIMER_KIND == USE_LINUXALPHA_CYCLE
#elif MPICH_TIMER_KIND == USE_QUERYPERFORMANCECOUNTER
#include <winsock2.h>
#include <windows.h>
#elif MPICH_TIMER_KIND == USE_MACH_ABSOLUTE_TIME
#include <mach/mach_time.h>
#elif MPICH_TIMER_KIND == USE_WIN86_CYCLE
#include <winsock2.h>
#include <windows.h>
#endif
/* Define a time stamp */
typedef struct timeval MPID_Time_t;
/*
* Prototypes. These are defined here so that inlined timer calls can
* use them, as well as any profiling and timing code that is built into
* MPICH
*/
/*@
MPID_Wtime - Return a time stamp
Output Parameter:
. timeval - A pointer to an 'MPID_Wtime_t' variable.
Notes:
This routine returns an `opaque` time value. This difference between two
time values returned by 'MPID_Wtime' can be converted into an elapsed time
in seconds with the routine 'MPID_Wtime_diff'.
This routine is defined this way to simplify its implementation as a macro.
For example, the for Intel x86 and gcc,
.vb
#define MPID_Wtime(timeval) \
__asm__ __volatile__("rdtsc" : "=A" (*timeval))
.ve
For some purposes, it is important
that the timer calls change the timing of the code as little as possible.
This form of a timer routine provides for a very fast timer that has
minimal impact on the rest of the code.
From a semantic standpoint, this format emphasizes that any particular
timer value has no meaning; only the difference between two values is
meaningful.
Module:
Timer
Question:
MPI-2 allows 'MPI_Wtime' to be a macro. We should make that easy; this
version does not accomplish that.
@*/
void MPID_Wtime( MPID_Time_t * timeval);
/*@
MPID_Wtime_diff - Compute the difference between two time stamps
Input Parameters:
. t1, t2 - Two time values set by 'MPID_Wtime' on this process.
Output Parameter:
. diff - The different in time between t2 and t1, measured in seconds.
Note:
If 't1' is null, then 't2' is assumed to be differences accumulated with
'MPID_Wtime_acc', and the output value gives the number of seconds that
were accumulated.
Question:
Instead of handling a null value of 't1', should we have a separate
routine 'MPID_Wtime_todouble' that converts a single timestamp to a
double value?
Module:
Timer
@*/
void MPID_Wtime_diff( MPID_Time_t *t1, MPID_Time_t *t2, double *diff );
/*@
MPID_Wtime_acc - Accumulate time values
Input Parameters:
. t1,t2,t3 - Three time values. 't3' is updated with the difference between
't2' and 't1': '*t3 += (t2 - t1)'.
Notes:
This routine is used to accumulate the time spent with a block of code
without first converting the time stamps into a particular arithmetic
type such as a 'double'. For example, if the 'MPID_Wtime' routine accesses
a cycle counter, this routine (or macro) can perform the accumulation using
integer arithmetic.
To convert a time value accumulated with this routine, use 'MPID_Wtime_diff'
with a 't1' of zero.
Module:
Timer
@*/
void MPID_Wtime_acc( MPID_Time_t *t1, MPID_Time_t *t2, MPID_Time_t *t3 );
/*@
MPID_Wtime_todouble - Converts an MPID timestamp to a double
Input Parameter:
. timeval - 'MPID_Time_t' time stamp
Output Parameter:
. seconds - Time in seconds from an arbitrary (but fixed) time in the past
Notes:
This routine may be used to change a timestamp into a number of seconds,
suitable for 'MPI_Wtime'.
@*/
void MPID_Wtime_todouble( MPID_Time_t *timeval, double *seconds );
/*@
MPID_Wtick - Provide the resolution of the 'MPID_Wtime' timer
Return value:
Resolution of the timer in seconds. In many cases, this is the
time between ticks of the clock that 'MPID_Wtime' returns. In other
words, the minimum significant difference that can be computed by
'MPID_Wtime_diff'.
Note that in some cases, the resolution may be estimated. No application
should expect either the same estimate in different runs or the same
value on different processes.
Module:
Timer
@*/
double MPID_Wtick( void );
/*@
MPID_Wtime_init - Initialize the timer
Note:
This routine should perform any steps needed to initialize the timer.
In addition, it should set the value of the attribute 'MPI_WTIME_IS_GLOBAL'
if the timer is known to be the same for all processes in 'MPI_COMM_WORLD'
(the value is zero by default).
If any operations need to be performed when the MPI program calls
'MPI_Finalize' this routine should register a handler with 'MPI_Finalize'
(see the MPICH Design Document).
Return Values:
0 on success. -1 on Failure. 1 means that the timer may not be used
until after MPID_Init completes. This allows the device to set up the
timer (first needed for Blue Gene support).
Module:
Timer
@*/
int MPID_Wtime_init(void);
/* Inlined timers. Note that any definition of one of the functions
prototyped above in terms of a macro will simply cause the compiler
to use the macro instead of the function definition.
Currently, all except the Windows performance counter timers
define MPID_Wtime_init as null; by default, the value of
MPI_WTIME_IS_GLOBAL is false.
*/
/* MPIDM_Wtime_todouble() is a hack to get a macro version
of the todouble function.
The logging library should save the native MPID_Timer_t
structure to disk and use the todouble function in the
post-processsing step to convert the values to doubles.
*/
/* The timer kind is set using AC_SUBST in the MPICH configure */
#define MPICH_TIMER_KIND USE_GETTIMEOFDAY
#if MPICH_TIMER_KIND == USE_GETHRTIME
#define MPID_Wtime_init() 0
#define MPIDM_Wtime_todouble MPID_Wtime_todouble
#elif MPICH_TIMER_KIND == USE_CLOCK_GETTIME
#define MPID_Wtime_init() 0
#define MPIDM_Wtime_todouble MPID_Wtime_todouble
#elif MPICH_TIMER_KIND == USE_GETTIMEOFDAY
#define MPID_Wtime_init() 0
#define MPIDM_Wtime_todouble MPID_Wtime_todouble
#elif MPICH_TIMER_KIND == USE_LINUX86_CYCLE
/* The rdtsc instruction is not a "serializing" instruction, so the
processor is free to reorder it. In order to get more accurate
timing numbers with rdtsc, we need to put a serializing
instruction, like cpuid, before rdtsc. X86_64 architectures have
the rdtscp instruction which is synchronizing, we use this when we
can. */
#ifdef LINUX86_CYCLE_RDTSCP
#define MPID_Wtime(var_ptr) \
__asm__ __volatile__("push %%rbx ; cpuid ; rdtsc ; pop %%rbx ; shl $32, %%rdx; or %%rdx, %%rax" : "=a" (*var_ptr) : : "ecx", "rdx")
#elif defined(LINUX86_CYCLE_CPUID_RDTSC64)
/* Here we have to save the rbx register for when the compiler is
generating position independent code (e.g., when it's generating
shared libraries) */
#define MPID_Wtime(var_ptr) \
__asm__ __volatile__("push %%rbx ; cpuid ; rdtsc ; pop %%rbx" : "=A" (*var_ptr) : : "ecx")
#elif defined(LINUX86_CYCLE_CPUID_RDTSC32)
/* Here we have to save the ebx register for when the compiler is
generating position independent code (e.g., when it's generating
shared libraries) */
#define MPID_Wtime(var_ptr) \
__asm__ __volatile__("push %%ebx ; cpuid ; rdtsc ; pop %%ebx" : "=A" (*var_ptr) : : "ecx")
#elif defined(LINUX86_CYCLE_RDTSC)
/* The configure test using cpuid must have failed, try just rdtsc by itself */
#define MPID_Wtime(var_ptr) __asm__ __volatile__("rdtsc" : "=A" (*var_ptr))
#else
#error Dont know which Linux timer to use
#endif
extern double MPID_Seconds_per_tick;
#define MPIDM_Wtime_todouble(t, d) *d = (double)*t * MPID_Seconds_per_tick
#elif MPICH_TIMER_KIND == USE_GCC_IA64_CYCLE
#ifdef __INTEL_COMPILER
#include "ia64regs.h"
#define MPID_Wtime(var_ptr) { MPID_Time_t t_val;\
t_val=__getReg(_IA64_REG_AR_ITC); *var_ptr=t_val;}
#else
#define MPID_Wtime(var_ptr) { MPID_Time_t t_val;\
__asm__ __volatile__("mov %0=ar.itc" : "=r" (t_val)); *var_ptr=t_val;}
#endif
extern double MPID_Seconds_per_tick;
#define MPIDM_Wtime_todouble(t, d) *d = (double)*t * MPID_Seconds_per_tick
#elif MPICH_TIMER_KIND == USE_LINUXALPHA_CYCLE
#define MPID_Wtime_init() 0
#define MPIDM_Wtime_todouble MPID_Wtime_todouble
#elif MPICH_TIMER_KIND == USE_QUERYPERFORMANCECOUNTER
#define MPID_Wtime(var) QueryPerformanceCounter(var)
extern double MPID_Seconds_per_tick;
#define MPIDM_Wtime_todouble( t, d ) \
*d = (double)t->QuadPart * MPID_Seconds_per_tick /* convert to seconds */
#elif MPICH_TIMER_KIND == USE_WIN86_CYCLE
#define MPID_Wtime(var_ptr) \
{ \
register int *f1 = (int*)var_ptr; \
__asm cpuid \
__asm rdtsc \
__asm mov ecx, f1 \
__asm mov [ecx], eax \
__asm mov [ecx + TYPE int], edx \
}
extern double MPID_Seconds_per_tick;
#define MPIDM_Wtime_todouble(t, d) *d = (double)(__int64)*t * MPID_Seconds_per_tick
#define MPIDM_Wtime_diff(t1,t2,diff) *diff = (double)((__int64)( *t2 - *t1 )) * MPID_Seconds_per_tick
#elif MPICH_TIMER_KIND == USE_MACH_ABSOLUTE_TIME
#define MPIDM_Wtime_todouble MPID_Wtime_todouble
#endif
#endif
| 34.151125 | 135 | 0.730722 |
86a5aff084d8b1a4dfa78447bce9036970b14e44 | 12,878 | c | C | Talpa/src/components/services/configurator_impl/securityfs_configurator.c | vegupta/Talpa | 36025acf2e30627e476dba3ae35209984b96ae3d | [
"MIT"
] | null | null | null | Talpa/src/components/services/configurator_impl/securityfs_configurator.c | vegupta/Talpa | 36025acf2e30627e476dba3ae35209984b96ae3d | [
"MIT"
] | null | null | null | Talpa/src/components/services/configurator_impl/securityfs_configurator.c | vegupta/Talpa | 36025acf2e30627e476dba3ae35209984b96ae3d | [
"MIT"
] | null | null | null | /*
* securityfs_configurator.h
*
* TALPA Filesystem Interceptor
*
* Copyright (C) 2004-2017 Sophos Limited, Oxford, England.
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License Version 2 as published by the Free Software Foundation.
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <asm/errno.h>
#include <linux/kernel.h>
#include <linux/version.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/security.h>
#include "common/bool.h"
#define TALPA_SUBSYS "securityfs"
#include "common/talpa.h"
#include "common/list.h"
#include "platform/alloc.h"
#include "platform/uaccess.h"
#include "configurator/pod_configuration_element.h"
#include "securityfs_configurator.h"
/*
* Forward declare implementation methods.
*/
static int attach(void* self, EConfigurationGroup group, const IConfigurable* item);
static void detach(void* self, const IConfigurable* item);
static void deleteSecurityfsConfigurator(struct tag_SecurityfsConfigurator* object);
/*
* Singleton object.
*/
static SecurityfsConfigurator GL_object =
{
{
attach,
detach,
&GL_object,
(void (*)(void*))deleteSecurityfsConfigurator
},
deleteSecurityfsConfigurator,
TALPA_STATIC_MUTEX(GL_object.mSemaphore),
NULL,
TALPA_LIST_HEAD_INIT(GL_object.mGroups),
};
#define this ((SecurityfsConfigurator*)self)
/*
* Object creation/destruction.
*/
SecurityfsConfigurator* newSecurityfsConfigurator(void)
{
GL_object.mRoot = securityfs_create_dir("talpa", NULL);
if ( IS_ERR(GL_object.mRoot) )
{
dbg("securityfs_create_dir failed: %ld", PTR_ERR(GL_object.mRoot));
return NULL;
}
return &GL_object;
}
static void deleteSecurityfsConfigurator(struct tag_SecurityfsConfigurator* object)
{
if ( object->mRoot )
{
securityfs_remove(object->mRoot);
}
return;
}
/*
* Internal.
*/
static struct configurationGroup *getGroup(void* self, EConfigurationGroup id)
{
struct configurationGroup *group = NULL;
struct configurationGroup *gptr;
char *name;
talpa_mutex_lock(&this->mSemaphore);
talpa_list_for_each_entry(gptr, &this->mGroups, head)
{
if ( gptr->id == id )
{
group = gptr;
break;
}
}
if ( group )
{
group->usecnt++;
dbg("returning %d (%u) [0x%p]", group->id, group->usecnt, group->dentry);
goto out;
}
switch (id)
{
case ECG_Interceptor:
name = "interceptors";
break;
case ECG_InterceptProcessor:
name = "intercept-processors";
break;
case ECG_InterceptFilter:
name = "intercept-filters";
break;
case ECG_FilterInterfaces:
name = "filter-interfaces";
break;
default:
/* Fail on unknown group id */
goto out;
}
group = talpa_alloc(sizeof(struct configurationGroup));
if ( !group )
{
goto out;
}
group->usecnt = 1;
group->id = id;
group->dentry = securityfs_create_dir(name, this->mRoot);
if ( IS_ERR(group->dentry) )
{
dbg("creation failed %ld", PTR_ERR(group->dentry));
talpa_free(group);
group = NULL;
goto out;
}
TALPA_INIT_LIST_HEAD(&group->items);
talpa_list_add(&group->head, &this->mGroups);
dbg("added %d (%u) [0x%p]", group->id, group->usecnt, group->dentry);
out:
talpa_mutex_unlock(&this->mSemaphore);
return group;
}
static void putGroup(void* self, struct configurationGroup *group)
{
talpa_mutex_lock(&this->mSemaphore);
group->usecnt--;
if ( group->usecnt == 0 )
{
talpa_list_del(&group->head);
dbg("freeing %d (%u) [0x%p]", group->id, group->usecnt, group->dentry);
securityfs_remove(group->dentry);
talpa_free(group);
}
talpa_mutex_unlock(&this->mSemaphore);
}
/*
* Filesystem implementation.
*/
static int securityfsOpen(struct inode *inode, struct file *file)
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19) || defined TALPA_INODE_I_PRIVATE
if ( inode->i_private )
{
file->private_data = inode->i_private;
}
#else
if ( inode->u.generic_ip )
{
file->private_data = inode->u.generic_ip;
}
#endif
return 0;
}
static ssize_t securityfsRead(struct file *file, char __user *buf, size_t count, loff_t *ppos)
{
struct configurationElement *element;
IConfigurable *item;
char* data;
size_t len;
size_t amountToCopy;
size_t extraNewLine = 1;
if ( !count )
{
return 0;
}
if ( !file )
{
dbg("Attempting to read from null file");
return -EBADF;
}
element = (struct configurationElement *)file->private_data;
if ( !element )
{
return -EBADF;
}
item = element->owner;
if ( !item )
{
return -EBADF;
}
data = (char *)(item->get(item->object, element->name));
if (data == NULL)
{
return -ENOMEM;
}
/* Too noisy since we are reading for queue length */
//~ if ( strncmp(item->name(item->object), "VettingController", 17) != 0 )
//~ {
//~ dbg("reading %s/%s = %s", item->name(item->object), element->name, data);
//~ }
len = strlen(data) + extraNewLine; /* For the new line */
amountToCopy = len - file->f_pos;
if (amountToCopy <= 0)
{
return 0;
}
if ( amountToCopy > count )
{
/* User buffer is smaller than we have left, so copy from the data, and don't include
* the virtual new-line */
extraNewLine = 0;
amountToCopy = count;
}
if ( amountToCopy - extraNewLine > 0 )
{
/*
* Need to copy from the config data:
* Copy from data, accounting for the virtual new line.
*/
if ( copy_to_user(buf, data+file->f_pos, amountToCopy - extraNewLine) )
{
return -EFAULT;
}
}
if ( extraNewLine > 0 )
{
if ( put_user('\n', buf + amountToCopy - extraNewLine) )
{
return -EFAULT;
}
}
*ppos = file->f_pos + amountToCopy;
return amountToCopy;
}
static ssize_t securityfsWrite(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
{
struct configurationElement *element;
IConfigurable *item;
char *data;
size_t len;
const char __user *p;
char c;
if ( !count )
{
return 0;
}
if ( file->f_pos )
{
return -EINVAL;
}
element = (struct configurationElement *)file->private_data;
if ( !element )
{
return -EBADF;
}
item = element->owner;
if ( !item )
{
return -EBADF;
}
if ( strnlen_user(buf, count) < 0 )
{
return -EFAULT;
}
len = 0;
p = buf;
while ( len < count )
{
__get_user(c, p++);
if ( c == 0 || c == '\n' )
{
break;
}
len++;
}
if ( len > element->size )
{
len = element->size;
}
data = talpa_large_alloc(len + 1);
if ( !data )
{
return -ENOMEM;
}
if ( copy_from_user(data, buf, len) )
{
return -EFAULT;
}
*ppos = len;
if ( len == element->size )
{
len--;
}
data[len] = 0;
dbg("setting %s/%s = %s", item->name(item->object), element->name, data);
item->set(item->object, element->name, data);
talpa_large_free(data);
return count;
}
static struct file_operations securityfsOps = {
.owner = THIS_MODULE,
.open = securityfsOpen,
.read = securityfsRead,
.write = securityfsWrite,
};
/*
* IConfigurator.
*/
static int attach(void* self, EConfigurationGroup id, const IConfigurable* item)
{
int err = -ENOMEM;
const PODConfigurationElement* cfgElement;
int count;
struct configurationGroup *group = NULL;
struct configurationItem *cfgitem = NULL;
struct configurationElement *element;
mode_t mode;
/* Determine how big the directory contents is */
cfgElement = item->all(item->object);
if ( !cfgElement )
{
err = -ENODATA;
goto error;
}
for ( count = 0; cfgElement->name != NULL; count++, cfgElement++ )
{
/* No action */
}
if ( count == 0 )
{
err = -ENODATA;
goto error;
}
/* Get the parent group */
group = getGroup(self, id);
if ( !group )
{
goto error;
}
/* Allocate and initialise item */
cfgitem = talpa_zalloc(sizeof(struct configurationItem));
if ( !cfgitem )
{
dbg("item allocation failed");
goto error;
}
cfgitem->dentry = securityfs_create_dir(item->name(item->object), group->dentry);
if ( IS_ERR(cfgitem->dentry) )
{
err = PTR_ERR(cfgitem->dentry);
dbg("creation of %s failed %d", item->name(item->object), err);
goto error;
}
cfgitem->item = (IConfigurable *)item;
cfgitem->count = count;
/* Allocate and initialise elements */
cfgitem->elements = talpa_zalloc(sizeof(struct configurationElement)*count);
if ( !cfgitem->elements )
{
dbg("elements allocation failed");
goto error;
}
for ( cfgElement = item->all(item->object), element = cfgitem->elements;
cfgElement->name != NULL;
cfgElement++, element++ )
{
element->owner = (IConfigurable *)item;
element->name = cfgElement->name;
element->size = cfgElement->maxvalue_sz;
mode = S_IRUSR;
if ( cfgElement->writable )
{
mode |= S_IWUSR;
}
if ( cfgElement->world_readable )
{
mode |= S_IRGRP | S_IROTH;
}
element->dentry = securityfs_create_file(element->name, mode, cfgitem->dentry, element, &securityfsOps);
if ( IS_ERR(element->dentry) )
{
dbg("creation of %s failed %ld", cfgElement->name, PTR_ERR(element->dentry));
goto error;
}
}
/* Add item to the group */
talpa_mutex_lock(&this->mSemaphore);
talpa_list_add(&cfgitem->head, &group->items);
talpa_mutex_unlock(&this->mSemaphore);
return 0;
error:
if ( cfgitem )
{
if ( cfgitem->elements )
{
for ( cfgElement = item->all(item->object), element = cfgitem->elements;
cfgElement->name != NULL;
cfgElement++, element++ )
{
if ( element->dentry && !IS_ERR(element->dentry) )
{
dbg("removing %s", element->name);
securityfs_remove(element->dentry);
}
}
talpa_free(cfgitem->elements);
}
if ( cfgitem->dentry && !IS_ERR(cfgitem->dentry) )
{
dbg("removing %s", item->name(item->object));
securityfs_remove(cfgitem->dentry);
}
talpa_free(cfgitem);
}
if ( group )
{
putGroup(self, group);
}
return err;
}
static void detach(void* self, const IConfigurable* item)
{
struct configurationGroup *gptr, *group = NULL;
struct configurationItem *iptr, *cfgitem = NULL;
struct configurationElement *element;
unsigned int idx;
talpa_mutex_lock(&this->mSemaphore);
talpa_list_for_each_entry(gptr, &this->mGroups, head)
{
talpa_list_for_each_entry(iptr, &gptr->items, head)
{
if ( iptr->item == item )
{
group = gptr;
cfgitem = iptr;
break;
}
}
}
if ( !group || !cfgitem )
{
err("Incorrect configuration usage!");
talpa_mutex_unlock(&this->mSemaphore);
return;
}
for ( element = cfgitem->elements, idx = 0; idx < cfgitem->count; idx++, element++ )
{
dbg("removing %s", element->name);
securityfs_remove(element->dentry);
}
talpa_free(cfgitem->elements);
securityfs_remove(cfgitem->dentry);
talpa_list_del(&cfgitem->head);
talpa_free(cfgitem);
talpa_mutex_unlock(&this->mSemaphore);
putGroup(self, group);
return;
}
/*
* End of securityfs_configurator.c
*/
| 23.892393 | 112 | 0.579282 |
223ef612c8afb3154749566c03aa3cd4fb6167b4 | 385 | h | C | Applications/HeadBoard/HBRootItemObserver-Protocol.h | lechium/tvOS124Headers | 11d1b56dd4c0ffd88b9eac43f87a5fd6f7228475 | [
"MIT"
] | 4 | 2019-08-27T18:03:47.000Z | 2021-09-18T06:29:00.000Z | Applications/HeadBoard/HBRootItemObserver-Protocol.h | lechium/tvOS124Headers | 11d1b56dd4c0ffd88b9eac43f87a5fd6f7228475 | [
"MIT"
] | null | null | null | Applications/HeadBoard/HBRootItemObserver-Protocol.h | lechium/tvOS124Headers | 11d1b56dd4c0ffd88b9eac43f87a5fd6f7228475 | [
"MIT"
] | 4 | 2017-05-14T16:23:26.000Z | 2019-12-21T15:07:59.000Z | //
// Generated by class-dump 3.5 (64 bit).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard.
//
#import "NSObject.h"
@class HBRootItem;
@protocol HBRootItemObserver <NSObject>
@optional
- (void)badgeValueDidChange:(HBRootItem *)arg1;
- (void)displayNameDidChange:(HBRootItem *)arg1;
- (void)installStateDidChange:(HBRootItem *)arg1;
@end
| 20.263158 | 83 | 0.711688 |
05c68da888a3cf22e6174b38b98c2e619239af48 | 1,331 | h | C | src/util.h | wgtdkp/julia | ebe159b8fdc14c3904d24f94b52f7a195f1945de | [
"MIT"
] | 141 | 2016-10-29T13:37:25.000Z | 2021-12-27T07:41:52.000Z | src/util.h | wgtdkp/julia | ebe159b8fdc14c3904d24f94b52f7a195f1945de | [
"MIT"
] | 12 | 2016-04-20T14:26:09.000Z | 2018-04-11T12:57:08.000Z | src/util.h | wgtdkp/julia | ebe159b8fdc14c3904d24f94b52f7a195f1945de | [
"MIT"
] | 34 | 2016-11-01T02:01:13.000Z | 2021-07-23T20:14:54.000Z | #ifndef _JULIA_UTIL_H_
#define _JULIA_UTIL_H_
#define OK (0)
#define AGAIN (1)
#define EMPTY_LINE (2)
#define CLOSED (3)
#define ERROR (-1)
#define ERR_INVALID_REQUEST (-2)
#define ERR_INVALID_METHOD (-3)
#define ERR_INVALID_VERSION (-4)
#define ERR_INTERNAL_ERROR (-5)
#define ERR_INVALID_HEADER (-6)
#define ERR_INVALID_URI (-7)
#define ERR_UNSUPPORTED_VERSION (-8)
#define ERR_NOMEM (-9)
#define CRLF "\r\n"
#define ABORT_ON(cond, msg) \
do { \
if (cond) { \
fprintf(stderr, "%s: %d: ", \
__FILE__, __LINE__);\
perror(msg); \
abort(); \
} \
} while (0)
#define ERR_ON(cond, msg) \
do { \
if (cond) { \
fprintf(stderr, "%s: %d: ", \
__FILE__, __LINE__);\
perror(msg); \
} \
} while (0)
static inline int min(int x, int y) {
return x < y ? x: y;
}
static inline int max(int x, int y) {
return x > y ? x: y;
}
void ju_error(const char* format, ...);
void ju_log(const char* format, ...);
#endif
| 24.648148 | 39 | 0.444778 |
b221f9f2fff63115bb635296b47452fbc022fdfd | 2,856 | h | C | PrivateFrameworks/CoreWiFi/CWFClient.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 17 | 2018-11-13T04:02:58.000Z | 2022-01-20T09:27:13.000Z | PrivateFrameworks/CoreWiFi/CWFClient.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 3 | 2018-04-06T02:02:27.000Z | 2018-10-02T01:12:10.000Z | PrivateFrameworks/CoreWiFi/CWFClient.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 1 | 2018-09-28T13:54:23.000Z | 2018-09-28T13:54:23.000Z | //
// Generated by class-dump 3.5 (64 bit).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard.
//
#import "NSObject.h"
#import "CWFXPCEventProxyDelegate.h"
@class NSMutableDictionary, NSMutableSet, NSObject<OS_dispatch_queue>, NSXPCConnection, SFAuthorization;
@interface CWFClient : NSObject <CWFXPCEventProxyDelegate>
{
NSObject<OS_dispatch_queue> *_mutex;
NSMutableSet *_mutableEventIDs;
NSMutableDictionary *_mutableEventCallbackMap;
NSMutableDictionary *_mutableActivityMap;
BOOL _activated;
BOOL _invalidated;
SFAuthorization *_authorization;
long long _XPCServiceType;
NSXPCConnection *_XPCConnection;
}
@property BOOL invalidated; // @synthesize invalidated=_invalidated;
@property BOOL activated; // @synthesize activated=_activated;
@property(readonly, nonatomic) NSXPCConnection *XPCConnection; // @synthesize XPCConnection=_XPCConnection;
@property(readonly) long long XPCServiceType; // @synthesize XPCServiceType=_XPCServiceType;
@property(copy) SFAuthorization *authorization; // @synthesize authorization=_authorization;
- (void).cxx_destruct;
- (void)proxy:(id)arg1 receivedEvent:(id)arg2;
- (id)deviceUUID;
- (unsigned int)reachabilityFlags;
- (id)DNSServerAddresses;
- (id)IPv6Addresses;
- (id)IPv6RouterAddress;
- (id)IPv6ServiceName;
- (id)IPv6ServiceID;
- (id)IPv6InterfaceName;
- (id)IPv4Addresses;
- (id)IPv4RouterAddress;
- (id)IPv4ServiceName;
- (id)IPv4ServiceID;
- (id)IPv4InterfaceName;
- (BOOL)setThermalIndex:(long long)arg1 error:(id *)arg2;
- (long long)thermalIndex;
- (BOOL)removeKnownNetworkProfile:(id)arg1 reason:(long long)arg2 error:(id *)arg3;
- (BOOL)addKnownNetworkProfile:(id)arg1 error:(id *)arg2;
- (BOOL)updateKnownNetworkProfile:(id)arg1 properties:(id)arg2 error:(id *)arg3;
- (id)knownNetworkProfileMatchingNetworkProfile:(id)arg1;
- (id)knownNetworkProfileMatchingScanResult:(id)arg1;
- (id)knownNetworkProfilesWithProperties:(id)arg1;
- (id)mainInterface;
- (id)interfaceWithName:(id)arg1;
- (id)virtualInterfaceNames;
- (id)interfaceNames;
- (void)clearAllEventHandlers;
- (void)setEventHandler:(CDUnknownBlockType)arg1 matching:(id)arg2;
- (void)stopMonitoringAllEvents;
- (void)stopMonitoringEvent:(id)arg1;
- (BOOL)startMonitoringEvent:(id)arg1 error:(id *)arg2;
- (id)systemEventIDs;
- (id)eventIDs;
- (id)systemActivities;
- (id)activities;
- (void)performActivity:(id)arg1 usingBlock:(CDUnknownBlockType)arg2;
- (void)endAllActivities;
- (void)endActivityWithUUID:(id)arg1;
- (BOOL)beginActivity:(id)arg1 error:(id *)arg2;
- (BOOL)cancelRequestWithUUID:(id)arg1 error:(id *)arg2;
@property(copy) CDUnknownBlockType invalidationHandler;
@property(retain) NSObject<OS_dispatch_queue> *targetQueue;
- (void)invalidate;
- (void)activate;
- (void)dealloc;
- (id)init;
- (id)initWithXPCServiceType:(long long)arg1;
@end
| 34.829268 | 107 | 0.768557 |
58bdb1f871918585278d873fa1c66d4e6863c6e8 | 502 | h | C | src/Timing.h | monsanto-pinheiro/ngmlr | 8d7677929001d1d13c6b4593c409a52044180dca | [
"MIT"
] | 239 | 2017-01-18T15:14:34.000Z | 2022-03-09T10:44:08.000Z | src/Timing.h | monsanto-pinheiro/ngmlr | 8d7677929001d1d13c6b4593c409a52044180dca | [
"MIT"
] | 96 | 2017-01-13T15:03:29.000Z | 2022-02-07T14:27:18.000Z | src/Timing.h | monsanto-pinheiro/ngmlr | 8d7677929001d1d13c6b4593c409a52044180dca | [
"MIT"
] | 44 | 2017-03-17T20:31:08.000Z | 2021-12-02T07:27:09.000Z | /**
* Contact: philipp.rescheneder@gmail.com
*/
#ifndef __TIMING2_H__
#define __TIMING2_H__
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/time.h>
#include <sys/types.h>
class Timer
{
private:
timeval start, end;
public:
void ST()
{
gettimeofday(&start, NULL);
}
inline volatile float ET()
{
gettimeofday(&end, NULL);
return (float)(end.tv_sec - start.tv_sec) + (float)(end.tv_usec - start.tv_usec) / 1000000.0f;
}
};
#endif
| 15.212121 | 97 | 0.633466 |
0fbf6a7e05688c828b32c0ec80211ca0f053cc92 | 1,053 | h | C | UMTActiveUser.h | yihongmingfeng/Fruitday | 981f6ecdb03a42d95210b249590505db18195dfd | [
"MIT"
] | null | null | null | UMTActiveUser.h | yihongmingfeng/Fruitday | 981f6ecdb03a42d95210b249590505db18195dfd | [
"MIT"
] | null | null | null | UMTActiveUser.h | yihongmingfeng/Fruitday | 981f6ecdb03a42d95210b249590505db18195dfd | [
"MIT"
] | null | null | null | //
// Generated by class-dump 3.5 (64 bit).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard.
//
#import "NSObject.h"
#import "NSCoding.h"
#import "UMTBase.h"
@class NSString;
@interface UMTActiveUser : NSObject <UMTBase, NSCoding>
{
NSString *__provider;
NSString *__puid;
_Bool __provider_isset;
_Bool __puid_isset;
}
@property(readonly, copy) NSString *description;
- (void)validate;
- (void)write:(id)arg1;
- (void)read:(id)arg1;
- (void)unsetPuid;
- (_Bool)puidIsSet;
@property(retain, nonatomic, getter=puid, setter=setPuid:) NSString *puid;
- (void)unsetProvider;
- (_Bool)providerIsSet;
@property(retain, nonatomic, getter=provider, setter=setProvider:) NSString *provider;
- (void)dealloc;
- (void)encodeWithCoder:(id)arg1;
- (id)initWithCoder:(id)arg1;
- (id)initWithProvider:(id)arg1 puid:(id)arg2;
- (id)init;
// Remaining properties
@property(readonly, copy) NSString *debugDescription;
@property(readonly) unsigned long long hash;
@property(readonly) Class superclass;
@end
| 23.4 | 86 | 0.718898 |
c9f5a35f81804c5de128919fb428fc7291c7b5d5 | 2,690 | h | C | engine/helper/thread/Thread.h | MCMic/cChord | e0922db8882127bbe34616450b4bac9e57d06d19 | [
"MIT"
] | 1 | 2015-02-15T20:02:58.000Z | 2015-02-15T20:02:58.000Z | engine/helper/thread/Thread.h | MCMic/cChord | e0922db8882127bbe34616450b4bac9e57d06d19 | [
"MIT"
] | null | null | null | engine/helper/thread/Thread.h | MCMic/cChord | e0922db8882127bbe34616450b4bac9e57d06d19 | [
"MIT"
] | null | null | null | #ifndef __Thread__
#define __Thread__
#include <pthread.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <signal.h>
#include <iostream>
#include "Exception.h"
class Thread {
public:
private:
pthread_t theThread;
pthread_attr_t tattr;
pthread_mutex_t mutex;
pthread_cond_t cancel_cond;
pthread_mutex_t sleep_mutex;
pthread_cond_t notify_cond;
pthread_mutex_t wait_mutex;
bool done;
protected:
inline static void* _run(void* arg) {
Thread* t = (Thread*) arg;
t->thePid = getpid();
pthread_testcancel();
t->run();
t->done = true;
pthread_exit(0);
return t;
}
public:
int thePid;
Thread() {
this->theThread = 0;
pthread_mutex_init(&(this->mutex), 0);
pthread_mutex_init(&(this->wait_mutex), 0);
pthread_cond_init(&(this->notify_cond), 0);
pthread_mutex_init(&(this->sleep_mutex), 0);
pthread_cond_init(&(this->cancel_cond), 0);
if (pthread_attr_init(&this->tattr) != 0) {
throw(new Exception("could not initialize the pthread attr"));
}
this->done = false;
}
~Thread() {
//std::cout << "thread destructor" << std::endl;
pthread_attr_destroy(&(this->tattr));
pthread_mutex_destroy(&(this->mutex));
pthread_mutex_destroy(&(this->wait_mutex));
pthread_cond_destroy(&(this->notify_cond));
pthread_mutex_destroy(&(this->sleep_mutex));
pthread_cond_destroy(&(this->cancel_cond));
}
pthread_t getThreadID() {
return (pthread_self());
}
bool getMutex() {
//cout << "thread " << this->getThreadID() << " getting mutex" << endl;
if (pthread_mutex_lock(&(this->mutex)) != 0) {
throw(new Exception("could not get the mutex"));
//return false;
}
return true;
}
void releaseMutex() {
//cout << "thread " << this->getThreadID() << " releasing mutex" << endl;
if (pthread_mutex_unlock(&(this->mutex)) != 0) {
throw(new Exception("could not release the mutex"));
}
}
bool isDone() {
return this->done;
}
void setDetached() {
if (pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED) != 0) {
throw(new Exception("could not set detached state"));
}
}
virtual void run() {
}
void start();
void join();
int usleep(long micros);
void sleep(long sec = 0);
void wait();
void notify();
inline void kill() {
this->done = true;
if (this->theThread != 0) {
if (pthread_cancel(this->theThread) != 0) {
throw(new Exception("Unable to cancel the Thread"));
}
}
}
bool signal(int signal) {
if (pthread_kill(this->theThread, signal) != 0) {
return false;
}
return true;
}
inline bool cancel() {
if (pthread_cond_signal(&(this->cancel_cond)) != 0) {
return false;
}
return true;
}
};
#endif
| 19.078014 | 75 | 0.659851 |
a771c6bc7b0cb7b6c6d8d5d27b9497385dcb4e9c | 3,354 | h | C | platform/mcu/rda8955/inc/include/sys/stat.h | jinlongliu/AliOS-Things | ce051172a775f987183e7aca88bb6f3b809ea7b0 | [
"Apache-2.0"
] | 5 | 2018-10-29T06:43:46.000Z | 2019-09-25T07:17:27.000Z | platform/mcu/rda8955/inc/include/sys/stat.h | IamBaoMouMou/AliOS-Things | 195a9160b871b3d78de6f8cf6c2ab09a71977527 | [
"Apache-2.0"
] | 3 | 2018-12-17T13:06:46.000Z | 2018-12-28T01:40:59.000Z | platform/mcu/rda8955/inc/include/sys/stat.h | IamBaoMouMou/AliOS-Things | 195a9160b871b3d78de6f8cf6c2ab09a71977527 | [
"Apache-2.0"
] | 6 | 2019-08-30T09:43:03.000Z | 2021-04-05T04:20:41.000Z | #ifndef _SYS_STAT_H
#define _SYS_STAT_H
#ifdef __cplusplus
extern "C" {
#endif
struct stat
{
short /*dev_t*/ st_dev;
unsigned short /*ino_t*/ st_ino;
unsigned int /*mode_t*/ st_mode;
unsigned short /*nlink_t*/ st_nlink;
unsigned short /*uid_t*/ st_uid;
unsigned short /*gid_t*/ st_gid;
short /*dev_t*/ st_rdev;
long /*off_t*/ st_size;
long/*time_t*/ st_atime;
long st_spare1;
long /*time_t*/ st_mtime;
long st_spare2;
long/*time_t*/ st_ctime;
long st_spare3;
long st_blksize;
long st_blocks;
long st_spare4[2];
};
#define _IFMT 0170000 /* type of file */
#define _IFDIR 0040000 /* directory */
#define _IFCHR 0020000 /* character special */
#define _IFBLK 0060000 /* block special */
#define _IFREG 0100000 /* regular */
#define _IFLNK 0120000 /* symbolic link */
#define _IFSOCK 0140000 /* socket */
#define _IFIFO 0010000 /* fifo */
#define S_BLKSIZE 1024 /* size of a block */
#define S_ISUID 0004000 /* set user id on execution */
#define S_ISGID 0002000 /* set group id on execution */
#define S_ISVTX 0001000 /* save swapped text even after use */
#ifndef _POSIX_SOURCE
#define S_IREAD 0000400 /* read permission, owner */
#define S_IWRITE 0000200 /* write permission, owner */
#define S_IEXEC 0000100 /* execute/search permission, owner */
#define S_ENFMT 0002000 /* enforcement-mode locking */
#endif /* !_POSIX_SOURCE */
#define S_IFMT _IFMT
#define S_IFDIR _IFDIR
#define S_IFCHR _IFCHR
#define S_IFBLK _IFBLK
#define S_IFREG _IFREG
#define S_IFLNK _IFLNK
#define S_IFSOCK _IFSOCK
#define S_IFIFO _IFIFO
#ifdef _WIN32
/* The Windows header files define _S_ forms of these, so we do too
for easier portability. */
#define _S_IFMT _IFMT
#define _S_IFDIR _IFDIR
#define _S_IFCHR _IFCHR
#define _S_IFIFO _IFIFO
#define _S_IFREG _IFREG
#define _S_IREAD 0000400
#define _S_IWRITE 0000200
#define _S_IEXEC 0000100
#endif
#define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
#define S_IRUSR 0000400 /* read permission, owner */
#define S_IWUSR 0000200 /* write permission, owner */
#define S_IXUSR 0000100 /* execute/search permission, owner */
#define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
#define S_IRGRP 0000040 /* read permission, group */
#define S_IWGRP 0000020 /* write permission, grougroup */
#define S_IXGRP 0000010 /* execute/search permission, group */
#define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
#define S_IROTH 0000004 /* read permission, other */
#define S_IWOTH 0000002 /* write permission, other */
#define S_IXOTH 0000001 /* execute/search permission, other */
#ifndef _POSIX_SOURCE
#define ACCESSPERMS (S_IRWXU | S_IRWXG | S_IRWXO) /* 0777 */
#define ALLPERMS (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO) /* 07777 */
#define DEFFILEMODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) /* 0666 */
#endif
#define S_ISBLK(m) (((m)&_IFMT) == _IFBLK)
#define S_ISCHR(m) (((m)&_IFMT) == _IFCHR)
#define S_ISDIR(m) (((m)&_IFMT) == _IFDIR)
#define S_ISFIFO(m) (((m)&_IFMT) == _IFIFO)
#define S_ISREG(m) (((m)&_IFMT) == _IFREG)
#define S_ISLNK(m) (((m)&_IFMT) == _IFLNK)
#define S_ISSOCK(m) (((m)&_IFMT) == _IFSOCK)
#if defined(__CYGWIN__)
/* Special tv_nsec values for futimens(2) and utimensat(2). */
#define UTIME_NOW -2L
#define UTIME_OMIT -1L
#endif
#ifdef __cplusplus
}
#endif
#endif /* _SYS_STAT_H */
| 30.770642 | 91 | 0.708706 |
cb4302a1eef4d750f14220041384fa75af6411d0 | 22,170 | c | C | blend_mask_color/op_blend_mask_color_neon.c | jolfzverb/evas_neon_test | 4d6be543bfb6d481e744a4992a945780c232d738 | [
"BSD-2-Clause"
] | 2 | 2016-06-25T11:06:53.000Z | 2016-10-20T06:18:50.000Z | blend_mask_color/op_blend_mask_color_neon.c | jolfzverb/evas_neon_test | 4d6be543bfb6d481e744a4992a945780c232d738 | [
"BSD-2-Clause"
] | null | null | null | blend_mask_color/op_blend_mask_color_neon.c | jolfzverb/evas_neon_test | 4d6be543bfb6d481e744a4992a945780c232d738 | [
"BSD-2-Clause"
] | null | null | null | #ifdef BUILD_NEON
#ifdef BUILD_NEON_INTRINSICS
#include <arm_neon.h>
#endif
#endif
#define NEONDEBUG 0
#if NEONDEBUG
#define DEBUG_FNCOUNT(x) \
do { \
static int _foo = 0; \
if (_foo++%10000 ==0) \
printf("%s %+d %s: %d (%s)\n",__FILE__,__LINE__,__FUNCTION__,\
_foo, x " optimised");\
} while (0)
#else
#define DEBUG_FNCOUNT(x) ((void)x)
#endif
/* blend mask x color -> dst */
#ifdef BUILD_NEON
#ifdef BUILD_NEON_INTRINSICS
static void
_op_blend_rel_mas_c_dp_neon(DATA32 *s EINA_UNUSED, DATA8 *m, DATA32 c, DATA32 *d, int l) {
uint16x8_t dc0_16x8;
uint16x8_t dc1_16x8;
uint16x8_t m_16x8;
uint16x8_t mc0_16x8;
uint16x8_t mc1_16x8;
uint16x8_t temp0_16x8;
uint16x8_t temp1_16x8;
uint16x8_t x255_16x8;
uint32x2_t c_32x2;
uint32x2_t m_32x2;
uint32x4_t a_32x4;
uint32x4_t ad_32x4;
uint32x4_t cond_32x4;
uint32x4_t d_32x4;
uint32x4_t dc_32x4;
uint32x4_t m_32x4;
uint32x4_t temp_32x4;
uint32x4_t x0_32x4;
uint32x4_t x1_32x4;
uint8x16_t a_8x16;
uint8x16_t d_8x16;
uint8x16_t dc_8x16;
uint8x16_t m_8x16;
uint8x16_t mc_8x16;
uint8x16_t temp_8x16;
uint8x16_t x0_8x16;
uint8x16_t x1_8x16;
uint8x8_t a0_8x8;
uint8x8_t a1_8x8;
uint8x8_t c_8x8;
uint8x8_t d0_8x8;
uint8x8_t d1_8x8;
uint8x8_t dc0_8x8;
uint8x8_t dc1_8x8;
uint8x8_t m0_8x8;
uint8x8_t m1_8x8;
uint8x8_t m_8x8;
uint8x8_t mc0_8x8;
uint8x8_t mc1_8x8;
uint8x8_t temp0_8x8;
uint8x8_t temp1_8x8;
c_32x2 = vdup_n_u32(c);
c_8x8 = vreinterpret_u8_u32(c_32x2);
x1_8x16 = vdupq_n_u8(0x1);
x1_32x4 = vreinterpretq_u32_u8(x1_8x16);
x255_16x8 = vdupq_n_u16(0xff);
x0_8x16 = vdupq_n_u8(0x0);
x0_32x4 = vreinterpretq_u32_u8(x0_8x16);
DATA32 *end = d + (l & ~3);
while (d < end)
{
d_32x4 = vld1q_u32(d);
d_8x16 = vreinterpretq_u8_u32(d_32x4);
d0_8x8 = vget_low_u8(d_8x16);
d1_8x8 = vget_high_u8(d_8x16);
m_32x2 = vld1_lane_u32((DATA32*)m, m_32x2, 0);
m_8x8 = vreinterpret_u8_u32(m_32x2);
m_16x8 = vmovl_u8(m_8x8);
m_8x16 = vreinterpretq_u8_u16(m_16x8);
m_8x8 = vget_low_u8(m_8x16);
m_16x8 = vmovl_u8(m_8x8);
m_32x4 = vreinterpretq_u32_u16(m_16x8);
m_32x4 = vmulq_u32(m_32x4, x1_32x4);
m_8x16 = vreinterpretq_u8_u32(m_32x4);
m0_8x8 = vget_low_u8(m_8x16);
m1_8x8 = vget_high_u8(m_8x16);
mc0_16x8 = vmull_u8(m0_8x8, c_8x8);
mc1_16x8 = vmull_u8(m1_8x8, c_8x8);
mc0_16x8 = vaddq_u16(mc0_16x8, x255_16x8);
mc1_16x8 = vaddq_u16(mc1_16x8, x255_16x8);
mc0_8x8 = vshrn_n_u16(mc0_16x8, 8);
mc1_8x8 = vshrn_n_u16(mc1_16x8, 8);
mc_8x16 = vcombine_u8(mc0_8x8, mc1_8x8);
a_8x16 = vsubq_u8(x0_8x16, mc_8x16);
a_32x4 = vreinterpretq_u32_u8(a_8x16);
a_32x4 = vshrq_n_u32(a_32x4, 24);
a_32x4 = vmulq_u32(a_32x4, x1_32x4);
a_8x16 = vreinterpretq_u8_u32(a_32x4);
a0_8x8 = vget_low_u8(a_8x16);
a1_8x8 = vget_high_u8(a_8x16);
temp0_16x8 = vmull_u8(a0_8x8, d0_8x8);
temp1_16x8 = vmull_u8(a1_8x8, d1_8x8);
temp0_8x8 = vshrn_n_u16(temp0_16x8,8);
temp1_8x8 = vshrn_n_u16(temp1_16x8,8);
temp_8x16 = vcombine_u8(temp0_8x8, temp1_8x8);
temp_32x4 = vreinterpretq_u32_u8(temp_8x16);
cond_32x4 = vceqq_u32(a_32x4, x0_32x4);
ad_32x4 = vbslq_u32(cond_32x4, d_32x4, temp_32x4);
// shift (*d >> 24)
dc_32x4 = vshrq_n_u32(d_32x4, 24);
dc_32x4 = vmulq_u32(x1_32x4, dc_32x4);
dc_8x16 = vreinterpretq_u8_u32(dc_32x4);
dc0_8x8 = vget_low_u8(dc_8x16);
dc1_8x8 = vget_high_u8(dc_8x16);
// multiply MUL_256(*d >> 24, sc);
dc0_16x8 = vmull_u8(dc0_8x8, mc0_8x8);
dc1_16x8 = vmull_u8(dc1_8x8, mc1_8x8);
dc0_16x8 = vaddq_u16(dc0_16x8, x255_16x8);
dc1_16x8 = vaddq_u16(dc1_16x8, x255_16x8);
dc0_8x8 = vshrn_n_u16(dc0_16x8, 8);
dc1_8x8 = vshrn_n_u16(dc1_16x8, 8);
dc_8x16 = vcombine_u8(dc0_8x8, dc1_8x8);
// add up everything
dc_32x4 = vreinterpretq_u32_u8(dc_8x16);
d_32x4 = vaddq_u32(dc_32x4, ad_32x4);
// save result
vst1q_u32(d, d_32x4);
d+=4;
m+=4;
}
end += (l & 3);
while (d < end)
{
DATA32 mc = MUL_SYM(*m, c);
int alpha = 256 - (mc >> 24);
*d = MUL_SYM(*d >> 24, mc) + MUL_256(alpha, *d);
d++;
m++;
}
}
#endif
#endif
#ifdef BUILD_NEON
static void
_op_blend_mas_c_dp_neon(DATA32 *s EINA_UNUSED, DATA8 *m, DATA32 c, DATA32 *d, int l) {
#ifdef BUILD_NEON_INTRINSICS
uint16x8_t m_16x8;
uint16x8_t mc0_16x8;
uint16x8_t mc1_16x8;
uint16x8_t temp0_16x8;
uint16x8_t temp1_16x8;
uint16x8_t x255_16x8;
uint32x2_t c_32x2;
uint32x2_t m_32x2;
uint32x4_t a_32x4;
uint32x4_t ad_32x4;
uint32x4_t cond_32x4;
uint32x4_t d_32x4;
uint32x4_t m_32x4;
uint32x4_t temp_32x4;
uint32x4_t mc_32x4;
uint32x4_t x0_32x4;
uint32x4_t x1_32x4;
uint8x16_t a_8x16;
uint8x16_t d_8x16;
uint8x16_t m_8x16;
uint8x16_t mc_8x16;
uint8x16_t temp_8x16;
uint8x16_t x0_8x16;
uint8x16_t x1_8x16;
uint8x8_t a0_8x8;
uint8x8_t a1_8x8;
uint8x8_t c_8x8;
uint8x8_t d0_8x8;
uint8x8_t d1_8x8;
uint8x8_t m0_8x8;
uint8x8_t m1_8x8;
uint8x8_t m_8x8;
uint8x8_t mc0_8x8;
uint8x8_t mc1_8x8;
uint8x8_t temp0_8x8;
uint8x8_t temp1_8x8;
x1_8x16 = vdupq_n_u8(0x1);
x0_8x16 = vdupq_n_u8(0x0);
x0_32x4 = vreinterpretq_u32_u8(x0_8x16);
x255_16x8 = vdupq_n_u16(0xff);
x1_32x4 = vreinterpretq_u32_u8(x1_8x16);
c_32x2 = vdup_n_u32(c);
c_8x8 = vreinterpret_u8_u32(c_32x2);
DATA32 *start = d;
int size = l;
DATA32 *end = start + (size & ~3);
while (start < end) {
int k = *((int *)m);
if (k == 0)
{
m+=4;
start+=4;
continue;
}
m_32x2 = vld1_lane_u32((DATA32*)m, m_32x2, 0);
d_32x4 = vld1q_u32(start);
m_8x8 = vreinterpret_u8_u32(m_32x2);
m_16x8 = vmovl_u8(m_8x8);
m_8x16 = vreinterpretq_u8_u16(m_16x8);
m_8x8 = vget_low_u8(m_8x16);
m_16x8 = vmovl_u8(m_8x8);
m_32x4 = vreinterpretq_u32_u16(m_16x8);
m_32x4 = vmulq_u32(m_32x4, x1_32x4);
m_8x16 = vreinterpretq_u8_u32(m_32x4);
m0_8x8 = vget_low_u8(m_8x16);
m1_8x8 = vget_high_u8(m_8x16);
mc0_16x8 = vmull_u8(m0_8x8, c_8x8);
mc1_16x8 = vmull_u8(m1_8x8, c_8x8);
mc0_16x8 = vaddq_u16(mc0_16x8, x255_16x8);
mc1_16x8 = vaddq_u16(mc1_16x8, x255_16x8);
mc0_8x8 = vshrn_n_u16(mc0_16x8, 8);
mc1_8x8 = vshrn_n_u16(mc1_16x8, 8);
mc_8x16 = vcombine_u8(mc0_8x8, mc1_8x8);
a_8x16 = vsubq_u8(x0_8x16, mc_8x16);
a_32x4 = vreinterpretq_u32_u8(a_8x16);
a_32x4 = vshrq_n_u32(a_32x4, 24);
a_32x4 = vmulq_u32(a_32x4, x1_32x4);
a_8x16 = vreinterpretq_u8_u32(a_32x4);
a0_8x8 = vget_low_u8(a_8x16);
a1_8x8 = vget_high_u8(a_8x16);
d_8x16 = vreinterpretq_u8_u32(d_32x4);
d0_8x8 = vget_low_u8(d_8x16);
d1_8x8 = vget_high_u8(d_8x16);
temp0_16x8 = vmull_u8(a0_8x8, d0_8x8);
temp1_16x8 = vmull_u8(a1_8x8, d1_8x8);
temp0_8x8 = vshrn_n_u16(temp0_16x8,8);
temp1_8x8 = vshrn_n_u16(temp1_16x8,8);
temp_8x16 = vcombine_u8(temp0_8x8, temp1_8x8);
temp_32x4 = vreinterpretq_u32_u8(temp_8x16);
cond_32x4 = vceqq_u32(a_32x4, x0_32x4);
ad_32x4 = vbslq_u32(cond_32x4, d_32x4, temp_32x4);
mc_32x4 = vreinterpretq_u32_u8(mc_8x16);
d_32x4 = vaddq_u32(mc_32x4, ad_32x4);
vst1q_u32(start, d_32x4);
start+=4;
m+=4;
}
end += (size & 3);
while (start < end) {
DATA32 a = *m;
DATA32 mc = MUL_SYM(a, c);
a = 256 - (mc >> 24);
*start = mc + MUL_256(a, *start);
m++; start++;
}
#else
DATA32 *e = d + l;
// everything we can do only once per cycle
// loading of 'c', initialization of some registers
asm volatile (
" .fpu neon \n\t"
" vdup.i32 q15, %[c] \n\t"
" vmov.i8 q14, #1 \n\t"
" vmov.i16 q12, #255 \n\t"
:
: [c] "r" (c)
: "q12", "q14", "q15"
);
//here we do unaligned part of 'd'
while (((int)d & 0xf) && (d < e))
{
asm volatile (
" vld1.8 d0[0], [%[m]]! \n\t"
" vld1.32 d4[0], [%[d]] \n\t"
" vdup.u8 d0, d0[0] \n\t"
" vmull.u8 q4, d0, d30 \n\t"
" vadd.u16 q4, q4, q12 \n\t"
" vshrn.u16 d12, q4, #8 \n\t"
" vmvn.u16 d14, d12 \n\t"
" vshr.u32 d16, d14, #24 \n\t"
" vmul.u32 d16, d16, d28 \n\t"
" vmovl.u8 q9, d4 \n\t"
" vmull.u8 q7, d16, d4 \n\t"
" vadd.u16 q7, q9, q7 \n\t"
" vshrn.u16 d0, q7, #8 \n\t"
" vadd.u8 d0, d0, d12 \n\t"
" vst1.32 d0[0], [%[d]]! \n\t"
: [d] "+r" (d), [m] "+r" (m)
: [c] "r" (c)
: "q0", "q2", "q4", "q5", "q6", "q7", "q8", "q9",
"q10", "q15", "q14", "memory"
);
}
//here e - d should be divisible by 4
while((unsigned int)d < ((unsigned int)e & 0xfffffff0))
{
//check if all 4 *m values are zeros
int k = *((int *)m);
if (k == 0)
{
m+=4;
d+=4;
continue;
}
asm volatile (
// load pair '*d' and '*(d+1)' into vector register
" vld1.32 d0[0], [%[m]]! \n\t"
" vldm %[d], {q2} \n\t"
" vmovl.u8 q0, d0 \n\t"
" vmovl.u8 q0, d0 \n\t"
" vmul.u32 q0, q14 \n\t"
// Multiply a * c
" vmull.u8 q4, d0, d30 \n\t"
" vadd.u16 q4, q4, q12 \n\t"
" vmull.u8 q5, d1, d31 \n\t"
" vadd.u16 q5, q5, q12 \n\t"
// Shorten
" vshrn.u16 d12, q4, #8 \n\t"
" vshrn.u16 d13, q5, #8 \n\t"
// extract negated alpha
" vmvn.u16 q7, q6 \n\t"
" vshr.u32 q8, q7, #24 \n\t"
" vmul.u32 q8, q8, q14 \n\t"
// Multiply
" vmovl.u8 q9, d4 \n\t"
" vmull.u8 q7, d16, d4 \n\t"
" vadd.u16 q7, q9, q7 \n\t"
" vmovl.u8 q10, d5 \n\t"
" vmull.u8 q8, d17, d5 \n\t"
" vadd.u16 q8, q10, q8 \n\t"
" vshrn.u16 d0, q7, #8 \n\t"
" vshrn.u16 d1, q8, #8 \n\t"
// Add
" vadd.u8 q0, q0, q6 \n\t"
" vstm %[d]!, {d0,d1} \n\t"
: [d] "+r" (d), [m] "+r" (m)
: [c] "r" (c), [x] "r" (42)
: "q0", "q2", "q4", "q5", "q6", "q7", "q8", "q9",
"q10", "q15", "q14", "memory"
);
}
//do the remaining part
while (d < e)
{
asm volatile (
" vld1.8 d0[0], [%[m]]! \n\t"
" vld1.32 d4[0], [%[d]] \n\t"
" vdup.u8 d0, d0[0] \n\t"
" vmull.u8 q4, d0, d30 \n\t"
" vadd.u16 q4, q4, q12 \n\t"
" vshrn.u16 d12, q4, #8 \n\t"
" vmvn.u16 d14, d12 \n\t"
" vshr.u32 d16, d14, #24 \n\t"
" vmul.u32 d16, d16, d28 \n\t"
" vmovl.u8 q9, d4 \n\t"
" vmull.u8 q7, d16, d4 \n\t"
" vadd.u16 q7, q9, q7 \n\t"
" vshrn.u16 d0, q7, #8 \n\t"
" vadd.u8 d0, d0, d12 \n\t"
" vst1.32 d0[0], [%[d]]! \n\t"
: [d] "+r" (d), [m] "+r" (m)
: [c] "r" (c)
: "q0", "q2", "q4", "q5", "q6", "q7", "q8", "q9",
"q10", "q15", "q14", "memory"
);
}
#endif
}
#endif
#ifdef BUILD_NEON
static void
_op_blend_mas_can_dp_neon(DATA32 *s EINA_UNUSED, DATA8 *m, DATA32 c, DATA32 *d, int l) {
#ifdef BUILD_NEON_INTRINSICS
int16x8_t c_i16x8;
int16x8_t d0_i16x8;
int16x8_t d1_i16x8;
int16x8_t dc0_i16x8;
int16x8_t dc1_i16x8;
int16x8_t m0_i16x8;
int16x8_t m1_i16x8;
int8x16_t dc_i8x16;
int8x8_t dc0_i8x8;
int8x8_t dc1_i8x8;
uint16x8_t c_16x8;
uint16x8_t d0_16x8;
uint16x8_t d1_16x8;
uint16x8_t m0_16x8;
uint16x8_t m1_16x8;
uint16x8_t m_16x8;
uint32x2_t c_32x2;
uint32x2_t m_32x2;
uint32x4_t d_32x4;
uint32x4_t dc_32x4;
uint32x4_t m_32x4;
uint32x4_t x1_32x4;
uint8x16_t d_8x16;
uint8x16_t m_8x16;
uint8x16_t x1_8x16;
uint8x8_t c_8x8;
uint8x8_t d0_8x8;
uint8x8_t d1_8x8;
uint8x8_t m0_8x8;
uint8x8_t m1_8x8;
uint8x8_t m_8x8;
uint8x8_t x1_8x8;
uint32x4_t x0_32x4;
uint32x4_t cond_32x4;
c_32x2 = vdup_n_u32(c);
c_8x8 = vreinterpret_u8_u32(c_32x2);
c_16x8 = vmovl_u8(c_8x8);
c_i16x8 = vreinterpretq_s16_u16(c_16x8);
x1_8x16 = vdupq_n_u8(0x1);
x1_8x8 = vget_low_u8(x1_8x16);
x1_32x4 = vreinterpretq_u32_u8(x1_8x16);
x0_32x4 = vdupq_n_u32(0x0);
DATA32 *start = d;
int size = l;
DATA32 *end = start + (size & ~3);
while (start < end) {
int k = *((int *)m);
if (k == 0)
{
m+=4;
start+=4;
continue;
}
m_32x2 = vld1_lane_u32((DATA32*)m, m_32x2, 0);
d_32x4 = vld1q_u32(start);
d_8x16 = vreinterpretq_u8_u32(d_32x4);
d0_8x8 = vget_low_u8(d_8x16);
d1_8x8 = vget_high_u8(d_8x16);
m_8x8 = vreinterpret_u8_u32(m_32x2);
m_16x8 = vmovl_u8(m_8x8);
m_8x16 = vreinterpretq_u8_u16(m_16x8);
m_8x8 = vget_low_u8(m_8x16);
m_16x8 = vmovl_u8(m_8x8);
m_32x4 = vreinterpretq_u32_u16(m_16x8);
m_32x4 = vmulq_u32(m_32x4, x1_32x4);
m_8x16 = vreinterpretq_u8_u32(m_32x4);
m0_8x8 = vget_low_u8(m_8x16);
m1_8x8 = vget_high_u8(m_8x16);
m0_16x8 = vaddl_u8(m0_8x8, x1_8x8);
m1_16x8 = vaddl_u8(m1_8x8, x1_8x8);
m0_i16x8 = vreinterpretq_s16_u16(m0_16x8);
m1_i16x8 = vreinterpretq_s16_u16(m1_16x8);
d0_16x8 = vmovl_u8(d0_8x8);
d1_16x8 = vmovl_u8(d1_8x8);
d0_i16x8 = vreinterpretq_s16_u16(d0_16x8);
d1_i16x8 = vreinterpretq_s16_u16(d1_16x8);
dc0_i16x8 = vsubq_s16(c_i16x8, d0_i16x8);
dc1_i16x8 = vsubq_s16(c_i16x8, d1_i16x8);
dc0_i16x8 = vmulq_s16(dc0_i16x8, m0_i16x8);
dc1_i16x8 = vmulq_s16(dc1_i16x8, m1_i16x8);
dc0_i16x8 = vshrq_n_s16(dc0_i16x8, 8);
dc1_i16x8 = vshrq_n_s16(dc1_i16x8, 8);
dc0_i16x8 = vaddq_s16(dc0_i16x8, d0_i16x8);
dc1_i16x8 = vaddq_s16(dc1_i16x8, d1_i16x8);
dc0_i8x8 = vmovn_s16(dc0_i16x8);
dc1_i8x8 = vmovn_s16(dc1_i16x8);
dc_i8x16 = vcombine_s8(dc0_i8x8, dc1_i8x8);
dc_32x4 = vreinterpretq_u32_s8(dc_i8x16);
cond_32x4 = vceqq_u32(m_32x4, x0_32x4);
dc_32x4 = vbslq_u32(cond_32x4, d_32x4, dc_32x4);
vst1q_u32(start, dc_32x4);
m+=4;
start+=4;
}
end += (size & 3);
while (start < end) {
DATA32 alpha = *m;
alpha++;
*start = INTERP_256(alpha, c, *start);
m++; start++;
}
#else
DATA32 *e;
DEBUG_FNCOUNT("");
#define AP "_blend_mas_can_dp_neon_"
asm volatile (
".fpu neon \n\t"
"vdup.u32 q9, %[c] \n\t"
"vmov.i8 q15, #1 \n\t"
"vmov.i8 q14, #0 \n\t"
// Make C 16 bit (C in q3/q2)
"vmovl.u8 q3, d19 \n\t"
"vmovl.u8 q2, d18 \n\t"
// Which loop to start
" andS %[tmp], %[d],$0xf \n\t"
" beq "AP"quadloop \n\t"
" andS %[tmp], %[d], #4 \n\t"
" beq "AP"dualstart \n\t"
AP"singleloop: \n\t"
" vld1.8 d0[0], [%[m]]! \n\t"
" vld1.32 d8[0], [%[d]] \n\t"
" vdup.u8 d0, d0[0] \n\t"
" vshr.u8 d0, d0, #1 \n\t"
" vmovl.u8 q0, d0 \n\t"
" vmovl.u8 q4, d8 \n\t"
" vsub.s16 q6, q2, q4 \n\t"
" vmul.s16 q6, q0 \n\t"
" vshr.s16 q6, #7 \n\t"
" vadd.s16 q6, q4 \n\t"
" vqmovun.s16 d2, q6 \n\t"
" vst1.32 d2[0], [%[d]]! \n\t"
" andS %[tmp], %[d], $0xf \n\t"
" beq "AP"quadloop \n\t"
AP"dualstart: \n\t"
" sub %[tmp], %[e], %[d] \n\t"
" cmp %[tmp], #16 \n\t"
" blt "AP"loopout \n\t"
AP"dualloop: \n\t"
" vld1.16 d0[0], [%[m]]! \n\t"
" vldm %[d], {d8} \n\t"
" vmovl.u8 q0, d0 \n\t"
" vmovl.u8 q0, d0 \n\t"
" vmul.u32 d0, d0, d30 \n\t"
" vshr.u8 d0, d0, #1 \n\t"
" vmovl.u8 q0, d0 \n\t"
" vmovl.u8 q4, d8 \n\t"
" vsub.s16 q6, q2, q4 \n\t"
" vmul.s16 q6, q0 \n\t"
" vshr.s16 q6, #7 \n\t"
" vadd.s16 q6, q4 \n\t"
" vqmovun.s16 d2, q6 \n\t"
" vstm %[d]!, {d2} \n\t"
AP"quadloop: \n\t"
" sub %[tmp], %[e], %[d] \n\t"
" cmp %[tmp], #16 \n\t"
" blt "AP"loopout \n\t"
" sub %[tmp], %[e], #15 \n\t"
" sub %[d], #16 \n\t"
AP"fastloop: \n\t"
" add %[d], #16 \n\t"
" cmp %[tmp], %[d] \n\t"
" blt "AP"loopout \n\t"
AP"quadloopint: \n\t"
// Load the mask: 4 bytes: It has d0/d1
" ldr %[x], [%[m]] \n\t"
" add %[m], #4 \n\t"
// Check for shortcuts
" cmp %[x], #0 \n\t"
" beq "AP"fastloop \n\t"
" cmp %[x], $0xffffffff \n\t"
" beq "AP"quadstore \n\t"
" vmov.32 d0[0], %[x] \n\t"
// Load d into d8/d9 q4
" vldm %[d], {d8,d9} \n\t"
// Get the alpha channel ready (m)
" vmovl.u8 q0, d0 \n\t"
" vmovl.u8 q0, d0 \n\t"
" vmul.u32 q0, q0,q15 \n\t"
// Lop a bit off to prevent overflow
" vshr.u8 q0, q0, #1 \n\t"
// Now make it 16 bit
" vmovl.u8 q1, d1 \n\t"
" vmovl.u8 q0, d0 \n\t"
// 16 bit 'd'
" vmovl.u8 q5, d9 \n\t"
" vmovl.u8 q4, d8 \n\t"
// Diff 'd' & 'c'
" vsub.s16 q7, q3, q5 \n\t"
" vsub.s16 q6, q2, q4 \n\t"
" vmul.s16 q7, q1 \n\t"
" vmul.s16 q6, q0 \n\t"
// Shift results a bit
" vshr.s16 q7, #7 \n\t"
" vshr.s16 q6, #7 \n\t"
// Add 'd'
" vadd.s16 q7, q5 \n\t"
" vadd.s16 q6, q4 \n\t"
// Make sure none are negative
" vqmovun.s16 d9, q7 \n\t"
" vqmovun.s16 d8, q6 \n\t"
" vstm %[d]!, {d8,d9} \n\t"
" cmp %[tmp], %[d] \n\t"
" bhi "AP"quadloopint \n\t"
" b "AP"loopout \n\t"
AP"quadstore: \n\t"
" vstm %[d]!, {d18,d19} \n\t"
" cmp %[tmp], %[d] \n\t"
" bhi "AP"quadloopint \n\t"
AP"loopout: \n\t"
#if NEONDEBUG
"cmp %[d], %[e] \n\t"
"ble "AP"foo \n\t"
"sub %[tmp], %[tmp] \n\t"
"vst1.32 d0[0], [%[tmp]] \n\t"
AP"foo: \n\t"
#endif
" cmp %[e], %[d] \n\t"
" beq "AP"done \n\t"
" sub %[tmp],%[e], %[d] \n\t"
" cmp %[tmp],#8 \n\t"
" blt "AP"onebyte \n\t"
// Load the mask: 2 bytes: It has d0
" vld1.16 d0[0], [%[m]]! \n\t"
// Load d into d8/d9 q4
" vldm %[d], {d8} \n\t"
// Get the alpha channel ready (m)
" vmovl.u8 q0, d0 \n\t"
" vmovl.u8 q0, d0 \n\t"
" vmul.u32 d0, d0, d30 \n\t"
// Lop a bit off to prevent overflow
" vshr.u8 d0, d0, #1 \n\t"
// Now make it 16 bit
" vmovl.u8 q0, d0 \n\t"
// 16 bit 'd'
" vmovl.u8 q4, d8 \n\t"
// Diff 'd' & 'c'
" vsub.s16 q6, q2, q4 \n\t"
" vmul.s16 q6, q0 \n\t"
// Shift results a bit
" vshr.s16 q6, #7 \n\t"
// Add 'd'
"vadd.s16 q6, q4 \n\t"
// Make sure none are negative
"vqmovun.s16 d2, q6 \n\t"
"vstm %[d]!, {d2} \n\t"
"cmp %[e], %[d] \n\t"
"beq "AP"done \n\t"
AP"onebyte: \n\t"
"vld1.8 d0[0], [%[m]]! \n\t"
"vld1.32 d8[0], [%[d]] \n\t"
"vdup.u8 d0, d0[0] \n\t"
"vshr.u8 d0, d0, #1 \n\t"
"vmovl.u8 q0, d0 \n\t"
"vmovl.u8 q4, d8 \n\t"
"vsub.s16 q6, q2, q4 \n\t"
"vmul.s16 q6, q0 \n\t"
"vshr.s16 q6, #7 \n\t"
"vadd.s16 q6, q4 \n\t"
"vqmovun.s16 d2, q6 \n\t"
"vst1.32 d2[0], [%[d]]! \n\t"
AP"done: \n\t"
#if NEONDEBUG
"cmp %[d], %[e] \n\t"
"beq "AP"reallydone \n\t"
"sub %[m], %[m] \n\t"
"vst1.32 d0[0], [%[m]] \n\t"
AP"reallydone:"
#endif
: // output regs
// Input
: [e] "r" (e = d + l), [d] "r" (d), [c] "r" (c),
[m] "r" (m), [tmp] "r" (7), [x] "r" (33)
: "q0", "q1", "q2","q3", "q4","q5","q6", "q7","q9","q14","q15",
"memory" // clobbered
);
#undef AP
#endif
}
#endif
| 28.754864 | 90 | 0.488994 |
3bc31f0ee1cf2705945c76d588c828706241738c | 552 | h | C | src/UI/ImGuiLayer.h | TheJoKeR15/RaiTracer | fb7c498d49c6f886228d54aed1939580bbfb4043 | [
"Apache-2.0"
] | 1 | 2020-12-26T03:55:08.000Z | 2020-12-26T03:55:08.000Z | src/UI/ImGuiLayer.h | TheJoKeR15/RaiTracer | fb7c498d49c6f886228d54aed1939580bbfb4043 | [
"Apache-2.0"
] | null | null | null | src/UI/ImGuiLayer.h | TheJoKeR15/RaiTracer | fb7c498d49c6f886228d54aed1939580bbfb4043 | [
"Apache-2.0"
] | null | null | null | #pragma once
#include "imGui/imgui.h"
#include "imGui/imgui_impl_glfw.h"
#include "imgui/imgui_impl_opengl3.h"
#include <GLFW\glfw3.h>
class ImGuiLayer
{
public:
ImGuiLayer();
ImGuiLayer(GLFWwindow* window, ImVec2 DisplaySize);
~ImGuiLayer();
void Init();
void StartFrame();
void Render();
void Shutdown();
void SetupDockspace(bool* p_open);
void SetContext(GLFWwindow* window) { m_window = window; }
void SetDisplaySize(ImVec2 displaySize) { m_displaySize = displaySize; }
private:
GLFWwindow* m_window;
ImVec2 m_displaySize;
};
| 17.806452 | 73 | 0.737319 |
dfe39b6e1791014e750395ade526e4fcd5ff9111 | 504 | h | C | 03C++/Program/01work/hsbiao/StdAfx.h | L-Xiah/theVS | cc37eaba174cdeb5c3dfdf04073a4d6d9068b161 | [
"MIT"
] | null | null | null | 03C++/Program/01work/hsbiao/StdAfx.h | L-Xiah/theVS | cc37eaba174cdeb5c3dfdf04073a4d6d9068b161 | [
"MIT"
] | null | null | null | 03C++/Program/01work/hsbiao/StdAfx.h | L-Xiah/theVS | cc37eaba174cdeb5c3dfdf04073a4d6d9068b161 | [
"MIT"
] | null | null | null |
#if !defined(AFX_STDAFX_H__96A4134B_9BCA_11D2_8C07_444553540000__INCLUDED_)
#define AFX_STDAFX_H__96A4134B_9BCA_11D2_8C07_444553540000__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif
#define VC_EXTRALEAN
#include <afxwin.h>
#include <afxext.h>
#include <afxdisp.h>
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h>
#endif
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif
| 22.909091 | 103 | 0.765873 |
2a96bf42786544416caba567631ad923d6c1ce39 | 5,897 | h | C | src/core/CoreEngine/pendulumsystem.h | jbuckmccready/staticpendulum_gui | 8c14019e5903c531cca5cfefeeb22a1beca8b000 | [
"MIT"
] | null | null | null | src/core/CoreEngine/pendulumsystem.h | jbuckmccready/staticpendulum_gui | 8c14019e5903c531cca5cfefeeb22a1beca8b000 | [
"MIT"
] | null | null | null | src/core/CoreEngine/pendulumsystem.h | jbuckmccready/staticpendulum_gui | 8c14019e5903c531cca5cfefeeb22a1beca8b000 | [
"MIT"
] | null | null | null | /* ===========================================================================
* The MIT License (MIT)
*
* Copyright (c) 2016 Jedidiah Buck McCready <jbuckmccready@gmail.com>
*
* 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 PENDULUMSYSTEM_H
#define PENDULUMSYSTEM_H
#include <array>
#include <cmath>
#include <vector>
namespace staticpendulum {
//! Pendulum function object that returns the derivative of the current state.
/*! The pendulum system is described by the following system of differential
* equations:
*
* \f$\vec{F}_{g}=-mg\frac{\sqrt{1-\frac{x^2+y^2}{L^2}}}{L}(x\hat{i}+y\hat{j})\f$
* (force due to gravity)
*
* \f$\vec{F}_{a_n(x_n,y_n)}=\frac{-k[(x-x_n)\hat{i}+(y-y_n)\hat{j}]}{\left[(x-x_n)^2+(y-y_n)^2+\left(d+L-\sqrt{L^2-\left(x^2+y^2\right)}\right)\right]^{3/2}}\f$
* (force due to attractor)
*
* \f$\vec{F}_{d}=-b(v_{x}\hat{i}+v_{y}\hat{j})\f$ (force due to dampening)
*
* \f$a_x=\frac{d^2x}{dt^2}=\left(F_{gx} +
* \sum\limits_{n=1}^{n=N}\vec{F}_{a_{nx}} + F_{dx}\right) \times \frac{1}{m}\f$
* (acceleration in x direction)
*
* \f$a_y=\frac{d^2y}{dt^2}=\left(F_{gy} +
* \sum\limits_{n=1}^{n=N}\vec{F}_{a_{ny}} + F_{dy}\right) \times \frac{1}{m}\f$
* (acceleration in y direction)
*
* Where m is the mass of the pendulum head, L is the length of the pendulum, g
* is the acceleration due to gravity, b is the dampening coefficient,
* and d is the distance between the end of the pendulum at rest and the base
* plate of attractors.
*
* The system parameters are modified as public member variables while the
* attractors are modified by calling the respective member functions.
*
* The function is called using an overloaded () operator and returns through a
* reference parameter the derivative of the state passed in.
*/
struct PendulumSystem {
typedef std::array<double, 4> StateType; // container type for the state
//! Container for an attractor, stores the position as an x-y coordinate, and
//! an attractive force coefficient.
struct Attractor {
Attractor(double xPos, double yPos, double forceCoeff)
: xPosition(xPos), yPosition(yPos), forceCoeff(forceCoeff) {}
double xPosition; /*!< x coordinate position. */
double yPosition; /*!< y coordinate position. */
double
forceCoeff; /*!< Attractive force coefficient where \f$F_{attractor} =
\frac{-k}{x^2+y^2}\f$ */
};
double distance; /*!< Distance between the pendulum head at rest and the base
plate. */
double mass; /*!< Mass of the head of the pendulum. */
double gravity; /*!< Acceleration due to gravity. */
double drag; /*!< Linear drag coefficient. */
double length; /*!< Length of the pendulum. */
std::vector<Attractor>
attractorList; /*!< List of attractors for the system. */
PendulumSystem();
void operator()(const StateType &x, StateType &dxdt,
const double /* t */) const;
};
//! Function call that returns the derivative of the current state.
inline void PendulumSystem::operator()(
const StateType &
x /*!< Current state input; index 0 is x position, index 1 is y position, index 2 is x velocity, and index 3 is y velocity. */,
StateType &
dxdt /*!< Derivative of the state, value modified by reference; follows the same indexing as the input state. */,
const double /*t*/ /*!< Note: system has no time dependence. Parameter here to fit signature for integration.*/)
const {
// see latex equation or readme for more readable math, this is coded to
// minimize repeated calculations
const double xSquared = x[0] * x[0];
const double ySquared = x[1] * x[1];
const double lengthSquared = length * length;
const double normSquared = xSquared + ySquared;
const double sqrtTerm = std::sqrt(1.0 - normSquared / lengthSquared);
const double gravityValue = -mass * gravity / length * sqrtTerm;
double xAttractionForce = 0.0;
double yAttractionForce = 0.0;
const double value1 = distance + length * (1.0 - sqrtTerm);
const double value2 = value1 * value1;
// sum up all the attractor forces
for (auto attractor : attractorList) {
const double value3 = x[0] - attractor.xPosition;
const double value4 = x[1] - attractor.yPosition;
const double value5 = value3 * value3;
const double value6 = value4 * value4;
const double value7 =
-attractor.forceCoeff / std::pow(value5 + value6 + value2, 1.5);
xAttractionForce += value3 * value7;
yAttractionForce += value4 * value7;
}
dxdt[0] = x[2];
dxdt[1] = x[3];
dxdt[2] = (x[0] * gravityValue - drag * x[2] + xAttractionForce) / mass;
dxdt[3] = (x[1] * gravityValue - drag * x[3] + yAttractionForce) / mass;
}
} // namespace staticpendulum
#endif // PENDULUM_SYSTEM_H
| 43.043796 | 161 | 0.664745 |
466721e7a8e7a009fee92b7406b8e903cdd77c12 | 1,558 | h | C | freq/plain_expression.h | mehrdad-shokri/libwxfreq | 8281a2d530588f44661b42ea9be9474ba9316014 | [
"BSD-3-Clause"
] | 195 | 2018-01-01T01:54:14.000Z | 2021-11-30T09:52:16.000Z | freq/plain_expression.h | mehrdad-shokri/libwxfreq | 8281a2d530588f44661b42ea9be9474ba9316014 | [
"BSD-3-Clause"
] | 2 | 2018-03-12T04:41:03.000Z | 2018-05-14T08:52:48.000Z | freq/plain_expression.h | mehrdad-shokri/libwxfreq | 8281a2d530588f44661b42ea9be9474ba9316014 | [
"BSD-3-Clause"
] | 50 | 2018-01-02T00:54:16.000Z | 2022-01-13T09:31:15.000Z | /*
* Tencent is pleased to support the open source community by making libwxfreq available.
*
* Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved.
*
* Licensed under the BSD 3-Clause License (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of the License at
*
* https://opensource.org/licenses/BSD-3-Clause
*
* 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 FREQLIB_FREQ_PLAIN_EXPRESSION_H_
#define FREQLIB_FREQ_PLAIN_EXPRESSION_H_
#include <string>
#include "expression.h"
#include "log.h"
namespace libwxfreq {
class PlainExpression: public Expression {
public:
PlainExpression() { }
bool ParseItem(const std::string& item);
bool IsMatch(const FreqItem& freqitem) const;
std::string DebugString() const;
Expression* Clone() const;
private:
typedef bool (*cmp)(const FreqItem&, const unsigned int, const unsigned int);
PlainExpression(const cmp func, const unsigned int threshold,
const unsigned char key_index)
: cmp_(func),
threshold_(threshold),
key_index_(key_index) { }
// parse item
cmp cmp_;
unsigned int threshold_;
uint8_t key_index_;
};
} // namespace libwxfreq
#endif // FREQLIB_FREQ_PLAIN_EXPRESSION_H_
| 29.396226 | 88 | 0.738768 |
625a35efec936e2464d8bde132e4a22f8fc523ee | 31,476 | c | C | android/android_42/base/cmds/installd/utils.c | yakuizhao/intel-vaapi-driver | b2bb0383352694941826543a171b557efac2219b | [
"MIT"
] | null | null | null | android/android_42/base/cmds/installd/utils.c | yakuizhao/intel-vaapi-driver | b2bb0383352694941826543a171b557efac2219b | [
"MIT"
] | null | null | null | android/android_42/base/cmds/installd/utils.c | yakuizhao/intel-vaapi-driver | b2bb0383352694941826543a171b557efac2219b | [
"MIT"
] | null | null | null | /*
** Copyright 2008, The Android 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.
*/
#include "installd.h"
#define CACHE_NOISY(x) //x
int create_pkg_path_in_dir(char path[PKG_PATH_MAX],
const dir_rec_t* dir,
const char* pkgname,
const char* postfix)
{
const size_t postfix_len = strlen(postfix);
const size_t pkgname_len = strlen(pkgname);
if (pkgname_len > PKG_NAME_MAX) {
return -1;
}
if (is_valid_package_name(pkgname) < 0) {
return -1;
}
if ((pkgname_len + dir->len + postfix_len) >= PKG_PATH_MAX) {
return -1;
}
char *dst = path;
size_t dst_size = PKG_PATH_MAX;
if (append_and_increment(&dst, dir->path, &dst_size) < 0
|| append_and_increment(&dst, pkgname, &dst_size) < 0
|| append_and_increment(&dst, postfix, &dst_size) < 0) {
ALOGE("Error building APK path");
return -1;
}
return 0;
}
/**
* Create the package path name for a given package name with a postfix for
* a certain persona. Returns 0 on success, and -1 on failure.
*/
int create_pkg_path(char path[PKG_PATH_MAX],
const char *pkgname,
const char *postfix,
uid_t persona)
{
size_t uid_len;
char* persona_prefix;
if (persona == 0) {
persona_prefix = PRIMARY_USER_PREFIX;
uid_len = 0;
} else {
persona_prefix = SECONDARY_USER_PREFIX;
uid_len = snprintf(NULL, 0, "%d", persona);
}
const size_t prefix_len = android_data_dir.len + strlen(persona_prefix) + uid_len + 1 /*slash*/;
char prefix[prefix_len + 1];
char *dst = prefix;
size_t dst_size = sizeof(prefix);
if (append_and_increment(&dst, android_data_dir.path, &dst_size) < 0
|| append_and_increment(&dst, persona_prefix, &dst_size) < 0) {
ALOGE("Error building prefix for APK path");
return -1;
}
if (persona != 0) {
int ret = snprintf(dst, dst_size, "%d/", persona);
if (ret < 0 || (size_t) ret != uid_len + 1) {
ALOGW("Error appending UID to APK path");
return -1;
}
}
dir_rec_t dir;
dir.path = prefix;
dir.len = prefix_len;
return create_pkg_path_in_dir(path, &dir, pkgname, postfix);
}
/**
* Create the path name for user data for a certain persona.
* Returns 0 on success, and -1 on failure.
*/
int create_persona_path(char path[PKG_PATH_MAX],
uid_t persona)
{
size_t uid_len;
char* persona_prefix;
if (persona == 0) {
persona_prefix = PRIMARY_USER_PREFIX;
uid_len = 0;
} else {
persona_prefix = SECONDARY_USER_PREFIX;
uid_len = snprintf(NULL, 0, "%d/", persona);
}
char *dst = path;
size_t dst_size = PKG_PATH_MAX;
if (append_and_increment(&dst, android_data_dir.path, &dst_size) < 0
|| append_and_increment(&dst, persona_prefix, &dst_size) < 0) {
ALOGE("Error building prefix for user path");
return -1;
}
if (persona != 0) {
if (dst_size < uid_len + 1) {
ALOGE("Error building user path");
return -1;
}
int ret = snprintf(dst, dst_size, "%d/", persona);
if (ret < 0 || (size_t) ret != uid_len) {
ALOGE("Error appending persona id to path");
return -1;
}
}
return 0;
}
/**
* Create the path name for media for a certain persona.
* Returns 0 on success, and -1 on failure.
*/
int create_persona_media_path(char path[PATH_MAX], userid_t userid) {
if (snprintf(path, PATH_MAX, "%s%d", android_media_dir.path, userid) > PATH_MAX) {
return -1;
}
return 0;
}
int create_move_path(char path[PKG_PATH_MAX],
const char* pkgname,
const char* leaf,
uid_t persona)
{
if ((android_data_dir.len + strlen(PRIMARY_USER_PREFIX) + strlen(pkgname) + strlen(leaf) + 1)
>= PKG_PATH_MAX) {
return -1;
}
sprintf(path, "%s%s%s/%s", android_data_dir.path, PRIMARY_USER_PREFIX, pkgname, leaf);
return 0;
}
/**
* Checks whether the package name is valid. Returns -1 on error and
* 0 on success.
*/
int is_valid_package_name(const char* pkgname) {
const char *x = pkgname;
int alpha = -1;
while (*x) {
if (isalnum(*x) || (*x == '_')) {
/* alphanumeric or underscore are fine */
} else if (*x == '.') {
if ((x == pkgname) || (x[1] == '.') || (x[1] == 0)) {
/* periods must not be first, last, or doubled */
ALOGE("invalid package name '%s'\n", pkgname);
return -1;
}
} else if (*x == '-') {
/* Suffix -X is fine to let versioning of packages.
But whatever follows should be alphanumeric.*/
alpha = 1;
} else {
/* anything not A-Z, a-z, 0-9, _, or . is invalid */
ALOGE("invalid package name '%s'\n", pkgname);
return -1;
}
x++;
}
if (alpha == 1) {
// Skip current character
x++;
while (*x) {
if (!isalnum(*x)) {
ALOGE("invalid package name '%s' should include only numbers after -\n", pkgname);
return -1;
}
x++;
}
}
return 0;
}
static int _delete_dir_contents(DIR *d, const char *ignore)
{
int result = 0;
struct dirent *de;
int dfd;
dfd = dirfd(d);
if (dfd < 0) return -1;
while ((de = readdir(d))) {
const char *name = de->d_name;
/* skip the ignore name if provided */
if (ignore && !strcmp(name, ignore)) continue;
if (de->d_type == DT_DIR) {
int r, subfd;
DIR *subdir;
/* always skip "." and ".." */
if (name[0] == '.') {
if (name[1] == 0) continue;
if ((name[1] == '.') && (name[2] == 0)) continue;
}
subfd = openat(dfd, name, O_RDONLY | O_DIRECTORY);
if (subfd < 0) {
ALOGE("Couldn't openat %s: %s\n", name, strerror(errno));
result = -1;
continue;
}
subdir = fdopendir(subfd);
if (subdir == NULL) {
ALOGE("Couldn't fdopendir %s: %s\n", name, strerror(errno));
close(subfd);
result = -1;
continue;
}
if (_delete_dir_contents(subdir, 0)) {
result = -1;
}
closedir(subdir);
if (unlinkat(dfd, name, AT_REMOVEDIR) < 0) {
ALOGE("Couldn't unlinkat %s: %s\n", name, strerror(errno));
result = -1;
}
} else {
if (unlinkat(dfd, name, 0) < 0) {
ALOGE("Couldn't unlinkat %s: %s\n", name, strerror(errno));
result = -1;
}
}
}
return result;
}
int delete_dir_contents(const char *pathname,
int also_delete_dir,
const char *ignore)
{
int res = 0;
DIR *d;
d = opendir(pathname);
if (d == NULL) {
ALOGE("Couldn't opendir %s: %s\n", pathname, strerror(errno));
return -errno;
}
res = _delete_dir_contents(d, ignore);
closedir(d);
if (also_delete_dir) {
if (rmdir(pathname)) {
ALOGE("Couldn't rmdir %s: %s\n", pathname, strerror(errno));
res = -1;
}
}
return res;
}
int delete_dir_contents_fd(int dfd, const char *name)
{
int fd, res;
DIR *d;
fd = openat(dfd, name, O_RDONLY | O_DIRECTORY);
if (fd < 0) {
ALOGE("Couldn't openat %s: %s\n", name, strerror(errno));
return -1;
}
d = fdopendir(fd);
if (d == NULL) {
ALOGE("Couldn't fdopendir %s: %s\n", name, strerror(errno));
close(fd);
return -1;
}
res = _delete_dir_contents(d, 0);
closedir(d);
return res;
}
int lookup_media_dir(char basepath[PATH_MAX], const char *dir)
{
DIR *d;
struct dirent *de;
struct stat s;
char* dirpos = basepath + strlen(basepath);
if ((*(dirpos-1)) != '/') {
*dirpos = '/';
dirpos++;
}
CACHE_NOISY(ALOGI("Looking up %s in %s\n", dir, basepath));
// Verify the path won't extend beyond our buffer, to avoid
// repeated checking later.
if ((dirpos-basepath+strlen(dir)) >= (PATH_MAX-1)) {
ALOGW("Path exceeds limit: %s%s", basepath, dir);
return -1;
}
// First, can we find this directory with the case that is given?
strcpy(dirpos, dir);
if (stat(basepath, &s) >= 0) {
CACHE_NOISY(ALOGI("Found direct: %s\n", basepath));
return 0;
}
// Not found with that case... search through all entries to find
// one that matches regardless of case.
*dirpos = 0;
d = opendir(basepath);
if (d == NULL) {
return -1;
}
while ((de = readdir(d))) {
if (strcasecmp(de->d_name, dir) == 0) {
strcpy(dirpos, de->d_name);
closedir(d);
CACHE_NOISY(ALOGI("Found search: %s\n", basepath));
return 0;
}
}
ALOGW("Couldn't find %s in %s", dir, basepath);
closedir(d);
return -1;
}
int64_t data_disk_free()
{
struct statfs sfs;
if (statfs(android_data_dir.path, &sfs) == 0) {
return sfs.f_bavail * sfs.f_bsize;
} else {
ALOGE("Couldn't statfs %s: %s\n", android_data_dir.path, strerror(errno));
return -1;
}
}
cache_t* start_cache_collection()
{
cache_t* cache = (cache_t*)calloc(1, sizeof(cache_t));
return cache;
}
#define CACHE_BLOCK_SIZE (512*1024)
static void* _cache_malloc(cache_t* cache, size_t len)
{
len = (len+3)&~3;
if (len > (CACHE_BLOCK_SIZE/2)) {
// It doesn't make sense to try to put this allocation into one
// of our blocks, because it is so big. Instead, make a new dedicated
// block for it.
int8_t* res = (int8_t*)malloc(len+sizeof(void*));
if (res == NULL) {
return NULL;
}
CACHE_NOISY(ALOGI("Allocated large cache mem block: %p size %d", res, len));
// Link it into our list of blocks, not disrupting the current one.
if (cache->memBlocks == NULL) {
*(void**)res = NULL;
cache->memBlocks = res;
} else {
*(void**)res = *(void**)cache->memBlocks;
*(void**)cache->memBlocks = res;
}
return res + sizeof(void*);
}
int8_t* res = cache->curMemBlockAvail;
int8_t* nextPos = res + len;
if (cache->memBlocks == NULL || nextPos > cache->curMemBlockEnd) {
int8_t* newBlock = malloc(CACHE_BLOCK_SIZE);
if (newBlock == NULL) {
return NULL;
}
CACHE_NOISY(ALOGI("Allocated new cache mem block: %p", newBlock));
*(void**)newBlock = cache->memBlocks;
cache->memBlocks = newBlock;
res = cache->curMemBlockAvail = newBlock + sizeof(void*);
cache->curMemBlockEnd = newBlock + CACHE_BLOCK_SIZE;
nextPos = res + len;
}
CACHE_NOISY(ALOGI("cache_malloc: ret %p size %d, block=%p, nextPos=%p",
res, len, cache->memBlocks, nextPos));
cache->curMemBlockAvail = nextPos;
return res;
}
static void* _cache_realloc(cache_t* cache, void* cur, size_t origLen, size_t len)
{
// This isn't really a realloc, but it is good enough for our purposes here.
void* alloc = _cache_malloc(cache, len);
if (alloc != NULL && cur != NULL) {
memcpy(alloc, cur, origLen < len ? origLen : len);
}
return alloc;
}
static void _inc_num_cache_collected(cache_t* cache)
{
cache->numCollected++;
if ((cache->numCollected%20000) == 0) {
ALOGI("Collected cache so far: %d directories, %d files",
cache->numDirs, cache->numFiles);
}
}
static cache_dir_t* _add_cache_dir_t(cache_t* cache, cache_dir_t* parent, const char *name)
{
size_t nameLen = strlen(name);
cache_dir_t* dir = (cache_dir_t*)_cache_malloc(cache, sizeof(cache_dir_t)+nameLen+1);
if (dir != NULL) {
dir->parent = parent;
dir->childCount = 0;
dir->hiddenCount = 0;
dir->deleted = 0;
strcpy(dir->name, name);
if (cache->numDirs >= cache->availDirs) {
size_t newAvail = cache->availDirs < 1000 ? 1000 : cache->availDirs*2;
cache_dir_t** newDirs = (cache_dir_t**)_cache_realloc(cache, cache->dirs,
cache->availDirs*sizeof(cache_dir_t*), newAvail*sizeof(cache_dir_t*));
if (newDirs == NULL) {
ALOGE("Failure growing cache dirs array for %s\n", name);
return NULL;
}
cache->availDirs = newAvail;
cache->dirs = newDirs;
}
cache->dirs[cache->numDirs] = dir;
cache->numDirs++;
if (parent != NULL) {
parent->childCount++;
}
_inc_num_cache_collected(cache);
} else {
ALOGE("Failure allocating cache_dir_t for %s\n", name);
}
return dir;
}
static cache_file_t* _add_cache_file_t(cache_t* cache, cache_dir_t* dir, time_t modTime,
const char *name)
{
size_t nameLen = strlen(name);
cache_file_t* file = (cache_file_t*)_cache_malloc(cache, sizeof(cache_file_t)+nameLen+1);
if (file != NULL) {
file->dir = dir;
file->modTime = modTime;
strcpy(file->name, name);
if (cache->numFiles >= cache->availFiles) {
size_t newAvail = cache->availFiles < 1000 ? 1000 : cache->availFiles*2;
cache_file_t** newFiles = (cache_file_t**)_cache_realloc(cache, cache->files,
cache->availFiles*sizeof(cache_file_t*), newAvail*sizeof(cache_file_t*));
if (newFiles == NULL) {
ALOGE("Failure growing cache file array for %s\n", name);
return NULL;
}
cache->availFiles = newAvail;
cache->files = newFiles;
}
CACHE_NOISY(ALOGI("Setting file %p at position %d in array %p", file,
cache->numFiles, cache->files));
cache->files[cache->numFiles] = file;
cache->numFiles++;
dir->childCount++;
_inc_num_cache_collected(cache);
} else {
ALOGE("Failure allocating cache_file_t for %s\n", name);
}
return file;
}
static int _add_cache_files(cache_t *cache, cache_dir_t *parentDir, const char *dirName,
DIR* dir, char *pathBase, char *pathPos, size_t pathAvailLen)
{
struct dirent *de;
cache_dir_t* cacheDir = NULL;
int dfd;
CACHE_NOISY(ALOGI("_add_cache_files: parent=%p dirName=%s dir=%p pathBase=%s",
parentDir, dirName, dir, pathBase));
dfd = dirfd(dir);
if (dfd < 0) return 0;
// Sub-directories always get added to the data structure, so if they
// are empty we will know about them to delete them later.
cacheDir = _add_cache_dir_t(cache, parentDir, dirName);
while ((de = readdir(dir))) {
const char *name = de->d_name;
if (de->d_type == DT_DIR) {
int subfd;
DIR *subdir;
/* always skip "." and ".." */
if (name[0] == '.') {
if (name[1] == 0) continue;
if ((name[1] == '.') && (name[2] == 0)) continue;
}
subfd = openat(dfd, name, O_RDONLY | O_DIRECTORY);
if (subfd < 0) {
ALOGE("Couldn't openat %s: %s\n", name, strerror(errno));
continue;
}
subdir = fdopendir(subfd);
if (subdir == NULL) {
ALOGE("Couldn't fdopendir %s: %s\n", name, strerror(errno));
close(subfd);
continue;
}
if (cacheDir == NULL) {
cacheDir = _add_cache_dir_t(cache, parentDir, dirName);
}
if (cacheDir != NULL) {
// Update pathBase for the new path... this may change dirName
// if that is also pointing to the path, but we are done with it
// now.
size_t finallen = snprintf(pathPos, pathAvailLen, "/%s", name);
CACHE_NOISY(ALOGI("Collecting dir %s\n", pathBase));
if (finallen < pathAvailLen) {
_add_cache_files(cache, cacheDir, name, subdir, pathBase,
pathPos+finallen, pathAvailLen-finallen);
} else {
// Whoops, the final path is too long! We'll just delete
// this directory.
ALOGW("Cache dir %s truncated in path %s; deleting dir\n",
name, pathBase);
_delete_dir_contents(subdir, NULL);
if (unlinkat(dfd, name, AT_REMOVEDIR) < 0) {
ALOGE("Couldn't unlinkat %s: %s\n", name, strerror(errno));
}
}
}
closedir(subdir);
} else if (de->d_type == DT_REG) {
// Skip files that start with '.'; they will be deleted if
// their entire directory is deleted. This allows for metadata
// like ".nomedia" to remain in the directory until the entire
// directory is deleted.
if (cacheDir == NULL) {
cacheDir = _add_cache_dir_t(cache, parentDir, dirName);
}
if (name[0] == '.') {
cacheDir->hiddenCount++;
continue;
}
if (cacheDir != NULL) {
// Build final full path for file... this may change dirName
// if that is also pointing to the path, but we are done with it
// now.
size_t finallen = snprintf(pathPos, pathAvailLen, "/%s", name);
CACHE_NOISY(ALOGI("Collecting file %s\n", pathBase));
if (finallen < pathAvailLen) {
struct stat s;
if (stat(pathBase, &s) >= 0) {
_add_cache_file_t(cache, cacheDir, s.st_mtime, name);
} else {
ALOGW("Unable to stat cache file %s; deleting\n", pathBase);
if (unlink(pathBase) < 0) {
ALOGE("Couldn't unlink %s: %s\n", pathBase, strerror(errno));
}
}
} else {
// Whoops, the final path is too long! We'll just delete
// this file.
ALOGW("Cache file %s truncated in path %s; deleting\n",
name, pathBase);
if (unlinkat(dfd, name, 0) < 0) {
*pathPos = 0;
ALOGE("Couldn't unlinkat %s in %s: %s\n", name, pathBase,
strerror(errno));
}
}
}
} else {
cacheDir->hiddenCount++;
}
}
return 0;
}
void add_cache_files(cache_t* cache, const char *basepath, const char *cachedir)
{
DIR *d;
struct dirent *de;
char dirname[PATH_MAX];
CACHE_NOISY(ALOGI("add_cache_files: base=%s cachedir=%s\n", basepath, cachedir));
d = opendir(basepath);
if (d == NULL) {
return;
}
while ((de = readdir(d))) {
if (de->d_type == DT_DIR) {
DIR* subdir;
const char *name = de->d_name;
char* pathpos;
/* always skip "." and ".." */
if (name[0] == '.') {
if (name[1] == 0) continue;
if ((name[1] == '.') && (name[2] == 0)) continue;
}
strcpy(dirname, basepath);
pathpos = dirname + strlen(dirname);
if ((*(pathpos-1)) != '/') {
*pathpos = '/';
pathpos++;
*pathpos = 0;
}
if (cachedir != NULL) {
snprintf(pathpos, sizeof(dirname)-(pathpos-dirname), "%s/%s", name, cachedir);
} else {
snprintf(pathpos, sizeof(dirname)-(pathpos-dirname), "%s", name);
}
CACHE_NOISY(ALOGI("Adding cache files from dir: %s\n", dirname));
subdir = opendir(dirname);
if (subdir != NULL) {
size_t dirnameLen = strlen(dirname);
_add_cache_files(cache, NULL, dirname, subdir, dirname, dirname+dirnameLen,
PATH_MAX - dirnameLen);
closedir(subdir);
}
}
}
closedir(d);
}
static char *create_dir_path(char path[PATH_MAX], cache_dir_t* dir)
{
char *pos = path;
if (dir->parent != NULL) {
pos = create_dir_path(path, dir->parent);
}
// Note that we don't need to worry about going beyond the buffer,
// since when we were constructing the cache entries our maximum
// buffer size for full paths was PATH_MAX.
strcpy(pos, dir->name);
pos += strlen(pos);
*pos = '/';
pos++;
*pos = 0;
return pos;
}
static void delete_cache_dir(char path[PATH_MAX], cache_dir_t* dir)
{
if (dir->parent != NULL) {
create_dir_path(path, dir);
ALOGI("DEL DIR %s\n", path);
if (dir->hiddenCount <= 0) {
if (rmdir(path)) {
ALOGE("Couldn't rmdir %s: %s\n", path, strerror(errno));
return;
}
} else {
// The directory contains hidden files so we need to delete
// them along with the directory itself.
if (delete_dir_contents(path, 1, NULL)) {
return;
}
}
dir->parent->childCount--;
dir->deleted = 1;
if (dir->parent->childCount <= 0) {
delete_cache_dir(path, dir->parent);
}
} else if (dir->hiddenCount > 0) {
// This is a root directory, but it has hidden files. Get rid of
// all of those files, but not the directory itself.
create_dir_path(path, dir);
ALOGI("DEL CONTENTS %s\n", path);
delete_dir_contents(path, 0, NULL);
}
}
static int cache_modtime_sort(const void *lhsP, const void *rhsP)
{
const cache_file_t *lhs = *(const cache_file_t**)lhsP;
const cache_file_t *rhs = *(const cache_file_t**)rhsP;
return lhs->modTime < rhs->modTime ? -1 : (lhs->modTime > rhs->modTime ? 1 : 0);
}
void clear_cache_files(cache_t* cache, int64_t free_size)
{
size_t i;
int skip = 0;
char path[PATH_MAX];
ALOGI("Collected cache files: %d directories, %d files",
cache->numDirs, cache->numFiles);
CACHE_NOISY(ALOGI("Sorting files..."));
qsort(cache->files, cache->numFiles, sizeof(cache_file_t*),
cache_modtime_sort);
CACHE_NOISY(ALOGI("Cleaning empty directories..."));
for (i=cache->numDirs; i>0; i--) {
cache_dir_t* dir = cache->dirs[i-1];
if (dir->childCount <= 0 && !dir->deleted) {
delete_cache_dir(path, dir);
}
}
CACHE_NOISY(ALOGI("Trimming files..."));
for (i=0; i<cache->numFiles; i++) {
skip++;
if (skip > 10) {
if (data_disk_free() > free_size) {
return;
}
skip = 0;
}
cache_file_t* file = cache->files[i];
strcpy(create_dir_path(path, file->dir), file->name);
ALOGI("DEL (mod %d) %s\n", (int)file->modTime, path);
if (unlink(path) < 0) {
ALOGE("Couldn't unlink %s: %s\n", path, strerror(errno));
}
file->dir->childCount--;
if (file->dir->childCount <= 0) {
delete_cache_dir(path, file->dir);
}
}
}
void finish_cache_collection(cache_t* cache)
{
size_t i;
CACHE_NOISY(ALOGI("clear_cache_files: %d dirs, %d files\n", cache->numDirs, cache->numFiles));
CACHE_NOISY(
for (i=0; i<cache->numDirs; i++) {
cache_dir_t* dir = cache->dirs[i];
ALOGI("dir #%d: %p %s parent=%p\n", i, dir, dir->name, dir->parent);
})
CACHE_NOISY(
for (i=0; i<cache->numFiles; i++) {
cache_file_t* file = cache->files[i];
ALOGI("file #%d: %p %s time=%d dir=%p\n", i, file, file->name,
(int)file->modTime, file->dir);
})
void* block = cache->memBlocks;
while (block != NULL) {
void* nextBlock = *(void**)block;
CACHE_NOISY(ALOGI("Freeing cache mem block: %p", block));
free(block);
block = nextBlock;
}
free(cache);
}
/**
* Checks whether a path points to a system app (.apk file). Returns 0
* if it is a system app or -1 if it is not.
*/
int validate_system_app_path(const char* path) {
size_t i;
for (i = 0; i < android_system_dirs.count; i++) {
const size_t dir_len = android_system_dirs.dirs[i].len;
if (!strncmp(path, android_system_dirs.dirs[i].path, dir_len)) {
if (path[dir_len] == '.' || strchr(path + dir_len, '/') != NULL) {
ALOGE("invalid system apk path '%s' (trickery)\n", path);
return -1;
}
return 0;
}
}
return -1;
}
/**
* Get the contents of a environment variable that contains a path. Caller
* owns the string that is inserted into the directory record. Returns
* 0 on success and -1 on error.
*/
int get_path_from_env(dir_rec_t* rec, const char* var) {
const char* path = getenv(var);
int ret = get_path_from_string(rec, path);
if (ret < 0) {
ALOGW("Problem finding value for environment variable %s\n", var);
}
return ret;
}
/**
* Puts the string into the record as a directory. Appends '/' to the end
* of all paths. Caller owns the string that is inserted into the directory
* record. A null value will result in an error.
*
* Returns 0 on success and -1 on error.
*/
int get_path_from_string(dir_rec_t* rec, const char* path) {
if (path == NULL) {
return -1;
} else {
const size_t path_len = strlen(path);
if (path_len <= 0) {
return -1;
}
// Make sure path is absolute.
if (path[0] != '/') {
return -1;
}
if (path[path_len - 1] == '/') {
// Path ends with a forward slash. Make our own copy.
rec->path = strdup(path);
if (rec->path == NULL) {
return -1;
}
rec->len = path_len;
} else {
// Path does not end with a slash. Generate a new string.
char *dst;
// Add space for slash and terminating null.
size_t dst_size = path_len + 2;
rec->path = malloc(dst_size);
if (rec->path == NULL) {
return -1;
}
dst = rec->path;
if (append_and_increment(&dst, path, &dst_size) < 0
|| append_and_increment(&dst, "/", &dst_size)) {
ALOGE("Error canonicalizing path");
return -1;
}
rec->len = dst - rec->path;
}
}
return 0;
}
int copy_and_append(dir_rec_t* dst, const dir_rec_t* src, const char* suffix) {
dst->len = src->len + strlen(suffix);
const size_t dstSize = dst->len + 1;
dst->path = (char*) malloc(dstSize);
if (dst->path == NULL
|| snprintf(dst->path, dstSize, "%s%s", src->path, suffix)
!= (ssize_t) dst->len) {
ALOGE("Could not allocate memory to hold appended path; aborting\n");
return -1;
}
return 0;
}
/**
* Check whether path points to a valid path for an APK file. An ASEC
* directory is allowed to have one level of subdirectory names. Returns -1
* when an invalid path is encountered and 0 when a valid path is encountered.
*/
int validate_apk_path(const char *path)
{
int allowsubdir = 0;
char *subdir = NULL;
size_t dir_len;
size_t path_len;
if (!strncmp(path, android_app_dir.path, android_app_dir.len)) {
dir_len = android_app_dir.len;
} else if (!strncmp(path, android_app_private_dir.path, android_app_private_dir.len)) {
dir_len = android_app_private_dir.len;
} else if (!strncmp(path, android_asec_dir.path, android_asec_dir.len)) {
dir_len = android_asec_dir.len;
allowsubdir = 1;
} else {
ALOGE("invalid apk path '%s' (bad prefix)\n", path);
return -1;
}
path_len = strlen(path);
/*
* Only allow the path to have a subdirectory if it's been marked as being allowed.
*/
if ((subdir = strchr(path + dir_len, '/')) != NULL) {
++subdir;
if (!allowsubdir
|| (path_len > (size_t) (subdir - path) && (strchr(subdir, '/') != NULL))) {
ALOGE("invalid apk path '%s' (subdir?)\n", path);
return -1;
}
}
/*
* Directories can't have a period directly after the directory markers
* to prevent ".."
*/
if (path[dir_len] == '.'
|| (subdir != NULL && ((*subdir == '.') || (strchr(subdir, '/') != NULL)))) {
ALOGE("invalid apk path '%s' (trickery)\n", path);
return -1;
}
return 0;
}
int append_and_increment(char** dst, const char* src, size_t* dst_size) {
ssize_t ret = strlcpy(*dst, src, *dst_size);
if (ret < 0 || (size_t) ret >= *dst_size) {
return -1;
}
*dst += ret;
*dst_size -= ret;
return 0;
}
char *build_string2(char *s1, char *s2) {
if (s1 == NULL || s2 == NULL) return NULL;
int len_s1 = strlen(s1);
int len_s2 = strlen(s2);
int len = len_s1 + len_s2 + 1;
char *result = malloc(len);
if (result == NULL) return NULL;
strcpy(result, s1);
strcpy(result + len_s1, s2);
return result;
}
char *build_string3(char *s1, char *s2, char *s3) {
if (s1 == NULL || s2 == NULL || s3 == NULL) return NULL;
int len_s1 = strlen(s1);
int len_s2 = strlen(s2);
int len_s3 = strlen(s3);
int len = len_s1 + len_s2 + len_s3 + 1;
char *result = malloc(len);
if (result == NULL) return NULL;
strcpy(result, s1);
strcpy(result + len_s1, s2);
strcpy(result + len_s1 + len_s2, s3);
return result;
}
/* Ensure that /data/media directories are prepared for given user. */
int ensure_media_user_dirs(userid_t userid) {
char media_user_path[PATH_MAX];
char path[PATH_MAX];
// Ensure /data/media/<userid> exists
create_persona_media_path(media_user_path, userid);
if (fs_prepare_dir(media_user_path, 0770, AID_MEDIA_RW, AID_MEDIA_RW) == -1) {
return -1;
}
return 0;
}
| 31.2572 | 100 | 0.536917 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.